aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Documentation/DocBook/mac80211.tmpl2
-rw-r--r--Documentation/block/data-integrity.txt4
-rw-r--r--Documentation/cgroups/cpusets.txt12
-rw-r--r--Documentation/driver-model/driver.txt4
-rw-r--r--Documentation/dvb/get_dvb_firmware53
-rw-r--r--Documentation/feature-removal-schedule.txt10
-rw-r--r--Documentation/gcov.txt25
-rw-r--r--Documentation/kernel-parameters.txt13
-rw-r--r--Documentation/kmemleak.txt23
-rw-r--r--Documentation/leds-lp3944.txt50
-rw-r--r--Documentation/powerpc/booting-without-of.txt1168
-rw-r--r--Documentation/powerpc/dts-bindings/4xx/emac.txt148
-rw-r--r--Documentation/powerpc/dts-bindings/gpio/gpio.txt50
-rw-r--r--Documentation/powerpc/dts-bindings/gpio/led.txt17
-rw-r--r--Documentation/powerpc/dts-bindings/gpio/mdio.txt19
-rw-r--r--Documentation/powerpc/dts-bindings/marvell.txt521
-rw-r--r--Documentation/powerpc/dts-bindings/phy.txt25
-rw-r--r--Documentation/powerpc/dts-bindings/spi-bus.txt57
-rw-r--r--Documentation/powerpc/dts-bindings/usb-ehci.txt25
-rw-r--r--Documentation/powerpc/dts-bindings/xilinx.txt295
-rw-r--r--Documentation/sound/alsa/HD-Audio-Models.txt1
-rw-r--r--Documentation/spi/spidev_test.c10
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx1
-rw-r--r--Documentation/x86/00-INDEX2
-rw-r--r--Documentation/x86/exception-tables.txt (renamed from Documentation/exception.txt)202
-rw-r--r--MAINTAINERS83
-rw-r--r--Makefile11
-rw-r--r--arch/alpha/include/asm/percpu.h6
-rw-r--r--arch/alpha/include/asm/thread_info.h1
-rw-r--r--arch/alpha/kernel/ptrace.c1
-rw-r--r--arch/arm/Kconfig.debug8
-rw-r--r--arch/arm/configs/kb9202_defconfig1158
-rw-r--r--arch/arm/configs/s3c2410_defconfig2
-rw-r--r--arch/arm/configs/s3c6400_defconfig1
-rw-r--r--arch/arm/configs/tct_hammer_defconfig1
-rw-r--r--arch/arm/configs/u300_defconfig92
-rw-r--r--arch/arm/include/asm/page.h2
-rw-r--r--arch/arm/include/asm/pgtable.h53
-rw-r--r--arch/arm/include/asm/thread_info.h2
-rw-r--r--arch/arm/kernel/irq.c24
-rw-r--r--arch/arm/kernel/vmlinux.lds.S15
-rw-r--r--arch/arm/mach-at91/board-sam9g20ek.c54
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c6
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c3
-rw-r--r--arch/arm/mach-omap1/mailbox.c2
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c1
-rw-r--r--arch/arm/mach-omap2/gpmc-onenand.c21
-rw-r--r--arch/arm/mach-omap2/id.c22
-rw-r--r--arch/arm/mach-omap2/mailbox.c6
-rw-r--r--arch/arm/mach-omap2/mmc-twl4030.c13
-rw-r--r--arch/arm/mach-s3c2440/mach-mini2440.c3
-rw-r--r--arch/arm/mach-s3c2442/mach-gta02.c3
-rw-r--r--arch/arm/mach-u300/clock.c121
-rw-r--r--arch/arm/mm/proc-syms.c1
-rw-r--r--arch/arm/plat-omap/dma.c13
-rw-r--r--arch/arm/plat-omap/gpio.c1
-rw-r--r--arch/arm/plat-omap/include/mach/cpu.h22
-rw-r--r--arch/arm/plat-omap/include/mach/dma.h15
-rw-r--r--arch/arm/plat-omap/include/mach/io.h2
-rw-r--r--arch/arm/plat-omap/iommu.c2
-rw-r--r--arch/arm/plat-omap/sram.c7
-rw-r--r--arch/arm/plat-s3c/Makefile2
-rw-r--r--arch/arm/plat-s3c/include/plat/devs.h1
-rw-r--r--arch/arm/plat-s3c24xx/Makefile2
-rw-r--r--arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c3
-rw-r--r--arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c3
-rw-r--r--arch/avr32/include/asm/thread_info.h2
-rw-r--r--arch/avr32/kernel/traps.c13
-rw-r--r--arch/blackfin/include/asm/thread_info.h2
-rw-r--r--arch/blackfin/kernel/ptrace.c1
-rw-r--r--arch/blackfin/kernel/setup.c41
-rw-r--r--arch/blackfin/kernel/sys_bfin.c1
-rw-r--r--arch/blackfin/kernel/traps.c34
-rw-r--r--arch/cris/include/asm/thread_info.h4
-rw-r--r--arch/cris/kernel/sys_cris.c1
-rw-r--r--arch/frv/Kconfig1
-rw-r--r--arch/frv/include/asm/atomic.h68
-rw-r--r--arch/frv/include/asm/perf_counter.h17
-rw-r--r--arch/frv/include/asm/system.h2
-rw-r--r--arch/frv/include/asm/thread_info.h4
-rw-r--r--arch/frv/include/asm/unistd.h4
-rw-r--r--arch/frv/kernel/entry.S2
-rw-r--r--arch/frv/kernel/frv_ksyms.c4
-rw-r--r--arch/frv/lib/Makefile4
-rw-r--r--arch/frv/lib/atomic-ops.S3
-rw-r--r--arch/frv/lib/atomic64-ops.S162
-rw-r--r--arch/frv/lib/perf_counter.c19
-rw-r--r--arch/h8300/include/asm/thread_info.h2
-rw-r--r--arch/ia64/include/asm/thread_info.h2
-rw-r--r--arch/ia64/kernel/esi.c2
-rw-r--r--arch/ia64/kernel/perfmon.c2
-rw-r--r--arch/ia64/kernel/ptrace.c1
-rw-r--r--arch/ia64/kernel/salinfo.c2
-rw-r--r--arch/ia64/kvm/kvm_lib.c6
-rw-r--r--arch/ia64/kvm/process.c6
-rw-r--r--arch/ia64/kvm/vcpu.c2
-rw-r--r--arch/ia64/kvm/vtlb.c4
-rw-r--r--arch/ia64/pci/pci.c2
-rw-r--r--arch/ia64/sn/kernel/io_common.c3
-rw-r--r--arch/m32r/include/asm/thread_info.h4
-rw-r--r--arch/m32r/kernel/ptrace.c1
-rw-r--r--arch/m68k/include/asm/thread_info_mm.h1
-rw-r--r--arch/m68k/include/asm/thread_info_no.h1
-rw-r--r--arch/m68knommu/kernel/process.c21
-rw-r--r--arch/m68knommu/kernel/traps.c6
-rw-r--r--arch/microblaze/Kconfig3
-rw-r--r--arch/microblaze/include/asm/atomic.h101
-rw-r--r--arch/microblaze/include/asm/bitops.h26
-rw-r--r--arch/microblaze/include/asm/bug.h14
-rw-r--r--arch/microblaze/include/asm/bugs.h18
-rw-r--r--arch/microblaze/include/asm/checksum.h70
-rw-r--r--arch/microblaze/include/asm/fb.h1
-rw-r--r--arch/microblaze/include/asm/hardirq.h14
-rw-r--r--arch/microblaze/include/asm/ioctls.h92
-rw-r--r--arch/microblaze/include/asm/ipcbuf.h37
-rw-r--r--arch/microblaze/include/asm/irq.h6
-rw-r--r--arch/microblaze/include/asm/mman.h24
-rw-r--r--arch/microblaze/include/asm/mmu.h7
-rw-r--r--arch/microblaze/include/asm/mmu_context.h2
-rw-r--r--arch/microblaze/include/asm/mmu_context_no.h23
-rw-r--r--arch/microblaze/include/asm/module.h10
-rw-r--r--arch/microblaze/include/asm/msgbuf.h32
-rw-r--r--arch/microblaze/include/asm/param.h31
-rw-r--r--arch/microblaze/include/asm/parport.h1
-rw-r--r--arch/microblaze/include/asm/pci.h2
-rw-r--r--arch/microblaze/include/asm/posix_types.h68
-rw-r--r--arch/microblaze/include/asm/scatterlist.h29
-rw-r--r--arch/microblaze/include/asm/sembuf.h35
-rw-r--r--arch/microblaze/include/asm/serial.h15
-rw-r--r--arch/microblaze/include/asm/shmbuf.h43
-rw-r--r--arch/microblaze/include/asm/shmparam.h7
-rw-r--r--arch/microblaze/include/asm/siginfo.h14
-rw-r--r--arch/microblaze/include/asm/signal.h166
-rw-r--r--arch/microblaze/include/asm/socket.h70
-rw-r--r--arch/microblaze/include/asm/sockios.h24
-rw-r--r--arch/microblaze/include/asm/stat.h69
-rw-r--r--arch/microblaze/include/asm/swab.h9
-rw-r--r--arch/microblaze/include/asm/syscalls.h46
-rw-r--r--arch/microblaze/include/asm/system.h3
-rw-r--r--arch/microblaze/include/asm/termbits.h204
-rw-r--r--arch/microblaze/include/asm/termios.h89
-rw-r--r--arch/microblaze/include/asm/thread_info.h4
-rw-r--r--arch/microblaze/include/asm/timex.h6
-rw-r--r--arch/microblaze/include/asm/types.h39
-rw-r--r--arch/microblaze/include/asm/ucontext.h23
-rw-r--r--arch/microblaze/include/asm/unistd.h6
-rw-r--r--arch/microblaze/include/asm/vga.h2
-rw-r--r--arch/microblaze/kernel/entry-nommu.S20
-rw-r--r--arch/microblaze/kernel/entry.S34
-rw-r--r--arch/microblaze/kernel/ptrace.c1
-rw-r--r--arch/microblaze/kernel/signal.c175
-rw-r--r--arch/microblaze/kernel/sys_microblaze.c21
-rw-r--r--arch/microblaze/kernel/syscall_table.S14
-rw-r--r--arch/microblaze/lib/Makefile2
-rw-r--r--arch/microblaze/lib/checksum.c172
-rw-r--r--arch/microblaze/mm/init.c6
-rw-r--r--arch/mips/Kconfig29
-rw-r--r--arch/mips/Makefile7
-rw-r--r--arch/mips/ar7/Makefile10
-rw-r--r--arch/mips/ar7/clock.c440
-rw-r--r--arch/mips/ar7/gpio.c48
-rw-r--r--arch/mips/ar7/irq.c176
-rw-r--r--arch/mips/ar7/memory.c72
-rw-r--r--arch/mips/ar7/platform.c555
-rw-r--r--arch/mips/ar7/prom.c297
-rw-r--r--arch/mips/ar7/setup.c94
-rw-r--r--arch/mips/ar7/time.c30
-rw-r--r--arch/mips/cavium-octeon/Makefile4
-rw-r--r--arch/mips/cavium-octeon/dma-octeon.c2
-rw-r--r--arch/mips/cavium-octeon/pci-common.c137
-rw-r--r--arch/mips/cobalt/buttons.c2
-rw-r--r--arch/mips/cobalt/lcd.c2
-rw-r--r--arch/mips/cobalt/led.c2
-rw-r--r--arch/mips/cobalt/mtd.c2
-rw-r--r--arch/mips/cobalt/rtc.c2
-rw-r--r--arch/mips/cobalt/serial.c2
-rw-r--r--arch/mips/cobalt/time.c2
-rw-r--r--arch/mips/configs/ar7_defconfig1182
-rw-r--r--arch/mips/gt64120/wrppmc/serial.c2
-rw-r--r--arch/mips/include/asm/amon.h7
-rw-r--r--arch/mips/include/asm/ds1287.h2
-rw-r--r--arch/mips/include/asm/elf.h4
-rw-r--r--arch/mips/include/asm/gcmpregs.h2
-rw-r--r--arch/mips/include/asm/gic.h6
-rw-r--r--arch/mips/include/asm/irq_gt641xx.h2
-rw-r--r--arch/mips/include/asm/mach-ar7/ar7.h178
-rw-r--r--arch/mips/include/asm/mach-ar7/gpio.h110
-rw-r--r--arch/mips/include/asm/mach-ar7/irq.h16
-rw-r--r--arch/mips/include/asm/mach-ar7/prom.h25
-rw-r--r--arch/mips/include/asm/mach-ar7/spaces.h22
-rw-r--r--arch/mips/include/asm/mach-ar7/war.h25
-rw-r--r--arch/mips/include/asm/mach-cobalt/irq.h2
-rw-r--r--arch/mips/include/asm/mach-cobalt/mach-gt64120.h2
-rw-r--r--arch/mips/include/asm/octeon/pci-octeon.h (renamed from arch/mips/cavium-octeon/pci-common.h)30
-rw-r--r--arch/mips/include/asm/page.h9
-rw-r--r--arch/mips/include/asm/reg.h2
-rw-r--r--arch/mips/include/asm/swab.h8
-rw-r--r--arch/mips/include/asm/thread_info.h4
-rw-r--r--arch/mips/include/asm/unistd.h18
-rw-r--r--arch/mips/include/asm/vr41xx/capcella.h2
-rw-r--r--arch/mips/include/asm/vr41xx/giu.h22
-rw-r--r--arch/mips/include/asm/vr41xx/irq.h2
-rw-r--r--arch/mips/include/asm/vr41xx/mpc30x.h2
-rw-r--r--arch/mips/include/asm/vr41xx/pci.h2
-rw-r--r--arch/mips/include/asm/vr41xx/siu.h2
-rw-r--r--arch/mips/include/asm/vr41xx/tb0219.h2
-rw-r--r--arch/mips/include/asm/vr41xx/tb0226.h2
-rw-r--r--arch/mips/include/asm/vr41xx/vr41xx.h2
-rw-r--r--arch/mips/kernel/binfmt_elfo32.c20
-rw-r--r--arch/mips/kernel/cevt-ds1287.c2
-rw-r--r--arch/mips/kernel/cevt-gt641xx.c2
-rw-r--r--arch/mips/kernel/csrc-ioasic.c2
-rw-r--r--arch/mips/kernel/irq-gic.c19
-rw-r--r--arch/mips/kernel/irq-gt641xx.c2
-rw-r--r--arch/mips/kernel/ptrace32.c1
-rw-r--r--arch/mips/kernel/scall32-o32.S2
-rw-r--r--arch/mips/kernel/scall64-64.S2
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S2
-rw-r--r--arch/mips/kernel/smp-cmp.c66
-rw-r--r--arch/mips/kernel/sync-r4k.c31
-rw-r--r--arch/mips/kernel/vpe.c2
-rw-r--r--arch/mips/mm/hugetlbpage.c1
-rw-r--r--arch/mips/mti-malta/malta-init.c14
-rw-r--r--arch/mips/mti-malta/malta-int.c89
-rw-r--r--arch/mips/mti-malta/malta-reset.c3
-rw-r--r--arch/mips/pci/Makefile5
-rw-r--r--arch/mips/pci/fixup-capcella.c2
-rw-r--r--arch/mips/pci/fixup-mpc30x.c2
-rw-r--r--arch/mips/pci/fixup-tb0219.c2
-rw-r--r--arch/mips/pci/fixup-tb0226.c2
-rw-r--r--arch/mips/pci/fixup-tb0287.c2
-rw-r--r--arch/mips/pci/msi-octeon.c (renamed from arch/mips/cavium-octeon/msi.c)56
-rw-r--r--arch/mips/pci/ops-vr41xx.c6
-rw-r--r--arch/mips/pci/pci-octeon.c (renamed from arch/mips/cavium-octeon/pci.c)147
-rw-r--r--arch/mips/pci/pci-vr41xx.c6
-rw-r--r--arch/mips/pci/pci-vr41xx.h4
-rw-r--r--arch/mips/pci/pcie-octeon.c (renamed from arch/mips/cavium-octeon/pcie.c)37
-rw-r--r--arch/mips/vr41xx/casio-e55/setup.c2
-rw-r--r--arch/mips/vr41xx/common/bcu.c8
-rw-r--r--arch/mips/vr41xx/common/cmu.c8
-rw-r--r--arch/mips/vr41xx/common/giu.c2
-rw-r--r--arch/mips/vr41xx/common/icu.c8
-rw-r--r--arch/mips/vr41xx/common/init.c2
-rw-r--r--arch/mips/vr41xx/common/irq.c2
-rw-r--r--arch/mips/vr41xx/common/pmu.c2
-rw-r--r--arch/mips/vr41xx/common/rtc.c2
-rw-r--r--arch/mips/vr41xx/common/siu.c2
-rw-r--r--arch/mips/vr41xx/common/type.c2
-rw-r--r--arch/mips/vr41xx/ibm-workpad/setup.c2
-rw-r--r--arch/mn10300/include/asm/pci.h4
-rw-r--r--arch/mn10300/include/asm/thread_info.h4
-rw-r--r--arch/mn10300/include/asm/unistd.h4
-rw-r--r--arch/mn10300/kernel/entry.S2
-rw-r--r--arch/mn10300/kernel/ptrace.c1
-rw-r--r--arch/mn10300/kernel/signal.c1
-rw-r--r--arch/mn10300/kernel/sys_mn10300.c2
-rw-r--r--arch/mn10300/kernel/traps.c22
-rw-r--r--arch/mn10300/kernel/vmlinux.lds.S2
-rw-r--r--arch/mn10300/mm/fault.c1
-rw-r--r--arch/mn10300/mm/misalignment.c1
-rw-r--r--arch/parisc/Kconfig2
-rw-r--r--arch/parisc/include/asm/atomic.h14
-rw-r--r--arch/parisc/include/asm/dma.h3
-rw-r--r--arch/parisc/include/asm/perf_counter.h7
-rw-r--r--arch/parisc/include/asm/processor.h3
-rw-r--r--arch/parisc/include/asm/system.h4
-rw-r--r--arch/parisc/include/asm/thread_info.h2
-rw-r--r--arch/parisc/include/asm/tlbflush.h14
-rw-r--r--arch/parisc/include/asm/unistd.h6
-rw-r--r--arch/parisc/kernel/cache.c26
-rw-r--r--arch/parisc/kernel/inventory.c41
-rw-r--r--arch/parisc/kernel/irq.c10
-rw-r--r--arch/parisc/kernel/pci-dma.c12
-rw-r--r--arch/parisc/kernel/pci.c3
-rw-r--r--arch/parisc/kernel/process.c2
-rw-r--r--arch/parisc/kernel/processor.c19
-rw-r--r--arch/parisc/kernel/setup.c3
-rw-r--r--arch/parisc/kernel/sys_parisc32.c62
-rw-r--r--arch/parisc/kernel/syscall_table.S4
-rw-r--r--arch/parisc/kernel/time.c90
-rw-r--r--arch/parisc/kernel/traps.c20
-rw-r--r--arch/parisc/lib/checksum.c2
-rw-r--r--arch/parisc/lib/memcpy.c2
-rw-r--r--arch/parisc/math-emu/decode_exc.c2
-rw-r--r--arch/parisc/mm/fault.c3
-rw-r--r--arch/parisc/mm/init.c29
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/boot/.gitignore10
-rw-r--r--arch/powerpc/boot/dts/amigaone.dts4
-rw-r--r--arch/powerpc/boot/dts/mpc8569mds.dts1
-rw-r--r--arch/powerpc/boot/dts/warp.dts3
-rw-r--r--arch/powerpc/configs/44x/warp_defconfig200
-rw-r--r--arch/powerpc/include/asm/cpm1.h2
-rw-r--r--arch/powerpc/include/asm/delay.h2
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h24
-rw-r--r--arch/powerpc/include/asm/highmem.h57
-rw-r--r--arch/powerpc/include/asm/hw_irq.h20
-rw-r--r--arch/powerpc/include/asm/perf_counter.h2
-rw-r--r--arch/powerpc/include/asm/pte-hash64-64k.h3
-rw-r--r--arch/powerpc/include/asm/rtas.h5
-rw-r--r--arch/powerpc/include/asm/thread_info.h4
-rw-r--r--arch/powerpc/kernel/entry_32.S127
-rw-r--r--arch/powerpc/kernel/head_32.S17
-rw-r--r--arch/powerpc/kernel/mpc7450-pmu.c1
-rw-r--r--arch/powerpc/kernel/of_device.c2
-rw-r--r--arch/powerpc/kernel/power7-pmu.c1
-rw-r--r--arch/powerpc/kernel/ppc970-pmu.c1
-rw-r--r--arch/powerpc/kernel/process.c2
-rw-r--r--arch/powerpc/kernel/ptrace32.c1
-rw-r--r--arch/powerpc/kernel/rtas.c69
-rw-r--r--arch/powerpc/kernel/setup_32.c2
-rw-r--r--arch/powerpc/kernel/smp.c3
-rw-r--r--arch/powerpc/kernel/udbg_16550.c2
-rw-r--r--arch/powerpc/mm/Makefile1
-rw-r--r--arch/powerpc/mm/gup.c10
-rw-r--r--arch/powerpc/mm/highmem.c77
-rw-r--r--arch/powerpc/mm/mmu_context_nohash.c16
-rw-r--r--arch/powerpc/mm/pgtable.c4
-rw-r--r--arch/powerpc/mm/slb.c13
-rw-r--r--arch/powerpc/mm/tlb_hash64.c2
-rw-r--r--arch/powerpc/oprofile/cell/vma_map.c2
-rw-r--r--arch/powerpc/platforms/44x/warp.c63
-rw-r--r--arch/powerpc/platforms/82xx/pq2ads-pci-pic.c2
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c1
-rw-r--r--arch/powerpc/platforms/85xx/smp.c9
-rw-r--r--arch/powerpc/platforms/85xx/socrates.c6
-rw-r--r--arch/powerpc/platforms/85xx/xes_mpc85xx.c1
-rw-r--r--arch/powerpc/platforms/cell/axon_msi.c22
-rw-r--r--arch/powerpc/platforms/cell/smp.c30
-rw-r--r--arch/powerpc/platforms/chrp/smp.c33
-rw-r--r--arch/powerpc/platforms/pasemi/setup.c15
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_64.c2
-rw-r--r--arch/powerpc/platforms/powermac/pic.c2
-rw-r--r--arch/powerpc/platforms/powermac/setup.c41
-rw-r--r--arch/powerpc/platforms/powermac/smp.c166
-rw-r--r--arch/powerpc/platforms/ps3/system-bus.c1
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c18
-rw-r--r--arch/powerpc/platforms/pseries/smp.c30
-rw-r--r--arch/powerpc/platforms/pseries/xics.c8
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c2
-rw-r--r--arch/powerpc/sysdev/ipic.c4
-rw-r--r--arch/powerpc/sysdev/mpic.c43
-rw-r--r--arch/powerpc/sysdev/ppc4xx_pci.c4
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c9
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe_ic.c4
-rw-r--r--arch/powerpc/sysdev/uic.c3
-rw-r--r--arch/s390/Kconfig8
-rw-r--r--arch/s390/include/asm/atomic.h7
-rw-r--r--arch/s390/include/asm/kvm_host.h4
-rw-r--r--arch/s390/include/asm/perf_counter.h2
-rw-r--r--arch/s390/include/asm/thread_info.h2
-rw-r--r--arch/s390/kernel/dis.c1
-rw-r--r--arch/s390/kernel/ipl.c15
-rw-r--r--arch/s390/kernel/ptrace.c1
-rw-r--r--arch/s390/kvm/kvm-s390.c23
-rw-r--r--arch/s390/kvm/priv.c2
-rw-r--r--arch/s390/lib/Makefile2
-rw-r--r--arch/s390/lib/delay.c2
-rw-r--r--arch/s390/lib/ucmpdi2.c26
-rw-r--r--arch/s390/mm/fault.c1
-rw-r--r--arch/sh/Kconfig.debug4
-rw-r--r--arch/sh/boards/mach-se/7206/io.c2
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c148
-rw-r--r--arch/sh/configs/migor_defconfig53
-rw-r--r--arch/sh/configs/se7724_defconfig25
-rw-r--r--arch/sh/include/asm/perf_counter.h4
-rw-r--r--arch/sh/include/asm/syscall_32.h1
-rw-r--r--arch/sh/include/asm/thread_info.h2
-rw-r--r--arch/sh/include/mach-se/mach/se7724.h5
-rw-r--r--arch/sh/mm/fault_32.c61
-rw-r--r--arch/sh/mm/tlb-sh3.c1
-rw-r--r--arch/sh/mm/tlbflush_64.c15
-rw-r--r--arch/sparc/boot/Makefile6
-rw-r--r--arch/sparc/boot/piggyback_32.c4
-rw-r--r--arch/sparc/boot/piggyback_64.c1
-rw-r--r--arch/sparc/include/asm/thread_info_32.h4
-rw-r--r--arch/sparc/include/asm/thread_info_64.h4
-rw-r--r--arch/sparc/kernel/irq_64.c45
-rw-r--r--arch/sparc/kernel/ptrace_32.c1
-rw-r--r--arch/sparc/kernel/ptrace_64.c1
-rw-r--r--arch/sparc/kernel/time_64.c1
-rw-r--r--arch/sparc/kernel/traps_32.c1
-rw-r--r--arch/sparc/kernel/vio.c7
-rw-r--r--arch/um/drivers/slip_kern.c1
-rw-r--r--arch/um/drivers/slirp_kern.c1
-rw-r--r--arch/um/include/asm/dma-mapping.h4
-rw-r--r--arch/um/include/asm/thread_info.h2
-rw-r--r--arch/um/kernel/sysrq.c4
-rw-r--r--arch/x86/Kconfig13
-rw-r--r--arch/x86/boot/video-bios.c3
-rw-r--r--arch/x86/boot/video-vesa.c4
-rw-r--r--arch/x86/include/asm/atomic_32.h185
-rw-r--r--arch/x86/include/asm/atomic_64.h42
-rw-r--r--arch/x86/include/asm/boot.h6
-rw-r--r--arch/x86/include/asm/fixmap.h10
-rw-r--r--arch/x86/include/asm/msr-index.h4
-rw-r--r--arch/x86/include/asm/nmi.h1
-rw-r--r--arch/x86/include/asm/pci.h2
-rw-r--r--arch/x86/include/asm/percpu.h10
-rw-r--r--arch/x86/include/asm/perf_counter.h3
-rw-r--r--arch/x86/include/asm/proto.h11
-rw-r--r--arch/x86/include/asm/spinlock.h4
-rw-r--r--arch/x86/include/asm/stacktrace.h2
-rw-r--r--arch/x86/include/asm/thread_info.h2
-rw-r--r--arch/x86/kernel/Makefile2
-rw-r--r--arch/x86/kernel/amd_iommu.c4
-rw-r--r--arch/x86/kernel/amd_iommu_init.c13
-rw-r--r--arch/x86/kernel/apic/apic.c2
-rw-r--r--arch/x86/kernel/apic/io_apic.c30
-rw-r--r--arch/x86/kernel/cpu/amd.c4
-rw-r--r--arch/x86/kernel/cpu/common.c3
-rw-r--r--arch/x86/kernel/cpu/cpufreq/powernow-k8.c32
-rw-r--r--arch/x86/kernel/cpu/cpufreq/powernow-k8.h3
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c16
-rw-r--r--arch/x86/kernel/cpu/perf_counter.c30
-rw-r--r--arch/x86/kernel/cpu/perfctr-watchdog.c5
-rw-r--r--arch/x86/kernel/dumpstack.c1
-rw-r--r--arch/x86/kernel/dumpstack_32.c6
-rw-r--r--arch/x86/kernel/dumpstack_64.c22
-rw-r--r--arch/x86/kernel/e820.c23
-rw-r--r--arch/x86/kernel/kvm.c2
-rw-r--r--arch/x86/kernel/pci-dma.c2
-rw-r--r--arch/x86/kernel/pci-gart_64.c2
-rw-r--r--arch/x86/kernel/setup.c16
-rw-r--r--arch/x86/kernel/setup_percpu.c219
-rw-r--r--arch/x86/kernel/tlb_uv.c9
-rw-r--r--arch/x86/kernel/traps.c3
-rw-r--r--arch/x86/kvm/mmu.c6
-rw-r--r--arch/x86/kvm/paging_tmpl.h2
-rw-r--r--arch/x86/kvm/vmx.c15
-rw-r--r--arch/x86/kvm/x86.c1
-rw-r--r--arch/x86/kvm/x86_emulate.c2
-rw-r--r--arch/x86/lib/Makefile1
-rw-r--r--arch/x86/lib/atomic64_32.c230
-rw-r--r--arch/x86/lib/clear_page_64.S5
-rw-r--r--arch/x86/lib/copy_user_64.S1
-rw-r--r--arch/x86/lib/delay.c3
-rw-r--r--arch/x86/lib/usercopy_32.c2
-rw-r--r--arch/x86/mm/fault.c9
-rw-r--r--arch/x86/mm/init.c18
-rw-r--r--arch/x86/mm/init_64.c9
-rw-r--r--arch/x86/mm/pageattr.c65
-rw-r--r--arch/x86/oprofile/nmi_int.c2
-rw-r--r--arch/x86/pci/acpi.c59
-rw-r--r--arch/x86/pci/amd_bus.c8
-rw-r--r--arch/x86/power/Makefile2
-rw-r--r--arch/x86/power/cpu.c2
-rw-r--r--arch/xtensa/include/asm/thread_info.h4
-rw-r--r--arch/xtensa/kernel/traps.c6
-rw-r--r--block/Makefile2
-rw-r--r--block/blk-core.c14
-rw-r--r--block/blk-merge.c6
-rw-r--r--block/bsg.c2
-rw-r--r--block/cfq-iosched.c178
-rw-r--r--block/cmd-filter.c233
-rw-r--r--block/elevator.c8
-rw-r--r--block/scsi_ioctl.c44
-rw-r--r--drivers/acpi/pci_root.c2
-rw-r--r--drivers/amba/bus.c12
-rw-r--r--drivers/base/devres.c3
-rw-r--r--drivers/base/firmware_class.c12
-rw-r--r--drivers/base/power/main.c1
-rw-r--r--drivers/block/DAC960.c1
-rw-r--r--drivers/block/Kconfig16
-rw-r--r--drivers/block/Makefile1
-rw-r--r--drivers/block/amiflop.c2
-rw-r--r--drivers/block/cciss.c16
-rw-r--r--drivers/block/cciss_cmd.h1
-rw-r--r--drivers/block/floppy.c5
-rw-r--r--drivers/block/loop.c1
-rw-r--r--drivers/block/osdblk.c701
-rw-r--r--drivers/block/pktcdvd.c10
-rw-r--r--drivers/block/xsysace.c7
-rw-r--r--drivers/bluetooth/hci_vhci.c1
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/amiserial.c1
-rw-r--r--drivers/char/bsr.c42
-rw-r--r--drivers/char/cyclades.c1
-rw-r--r--drivers/char/epca.c1
-rw-r--r--drivers/char/hw_random/intel-rng.c9
-rw-r--r--drivers/char/isicom.c17
-rw-r--r--drivers/char/istallion.c1
-rw-r--r--drivers/char/moxa.c1
-rw-r--r--drivers/char/mxser.c1
-rw-r--r--drivers/char/n_hdlc.c1
-rw-r--r--drivers/char/n_r3964.c1
-rw-r--r--drivers/char/pty.c155
-rw-r--r--drivers/char/rio/rio_linux.c1
-rw-r--r--drivers/char/riscom8.c1
-rw-r--r--drivers/char/rocket.c1
-rw-r--r--drivers/char/serial167.c1
-rw-r--r--drivers/char/specialix.c1
-rw-r--r--drivers/char/sx.c1
-rw-r--r--drivers/char/synclink.c1
-rw-r--r--drivers/char/synclink_gt.c1
-rw-r--r--drivers/char/synclinkmp.c1
-rw-r--r--drivers/char/tb0219.c4
-rw-r--r--drivers/char/tpm/tpm.c1
-rw-r--r--drivers/char/tty_ioctl.c1
-rw-r--r--drivers/char/tty_ldisc.c16
-rw-r--r--drivers/char/vr41xx_giu.c680
-rw-r--r--drivers/char/vt.c1
-rw-r--r--drivers/char/vt_ioctl.c1
-rw-r--r--drivers/clocksource/sh_tmu.c2
-rw-r--r--drivers/cpufreq/cpufreq.c76
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c49
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c77
-rw-r--r--drivers/edac/amd64_edac.c25
-rw-r--r--drivers/edac/amd64_edac.h2
-rw-r--r--drivers/edac/edac_core.h4
-rw-r--r--drivers/edac/edac_mc_sysfs.c4
-rw-r--r--drivers/edac/mpc85xx_edac.c6
-rw-r--r--drivers/edac/mpc85xx_edac.h1
-rw-r--r--drivers/firewire/core-card.c14
-rw-r--r--drivers/firewire/core-cdev.c4
-rw-r--r--drivers/firewire/core-iso.c24
-rw-r--r--drivers/firewire/core.h3
-rw-r--r--drivers/firewire/sbp2.c10
-rw-r--r--drivers/gpio/Kconfig6
-rw-r--r--drivers/gpio/Makefile1
-rw-r--r--drivers/gpio/pl061.c20
-rw-r--r--drivers/gpio/vr41xx_giu.c585
-rw-r--r--drivers/gpu/drm/Kconfig1
-rw-r--r--drivers/gpu/drm/Makefile2
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c2
-rw-r--r--drivers/gpu/drm/drm_edid.c12
-rw-r--r--drivers/gpu/drm/i915/Makefile2
-rw-r--r--drivers/gpu/drm/i915/dvo.h4
-rw-r--r--drivers/gpu/drm/i915/dvo_ch7017.c20
-rw-r--r--drivers/gpu/drm/i915/dvo_ch7xxx.c25
-rw-r--r--drivers/gpu/drm/i915/dvo_ivch.c21
-rw-r--r--drivers/gpu/drm/i915/dvo_sil164.c25
-rw-r--r--drivers/gpu/drm/i915/dvo_tfp410.c25
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c72
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c13
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h39
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c55
-rw-r--r--drivers/gpu/drm/i915/i915_gem_debug.c6
-rw-r--r--drivers/gpu/drm/i915/i915_gem_debugfs.c44
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c8
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c155
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h81
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c251
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c32
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c30
-rw-r--r--drivers/gpu/drm/i915/intel_display.c623
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c1156
-rw-r--r--drivers/gpu/drm/i915/intel_dp.h144
-rw-r--r--drivers/gpu/drm/i915/intel_dp_i2c.c273
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h17
-rw-r--r--drivers/gpu/drm/i915/intel_dvo.c16
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c18
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c35
-rw-r--r--drivers/gpu/drm/i915/intel_i2c.c16
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c418
-rw-r--r--drivers/gpu/drm/i915/intel_modes.c14
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c186
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo_regs.h1
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c53
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c22
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_fb.c33
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c30
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c1
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_vm.c1
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c1
-rw-r--r--drivers/hid/usbhid/hid-core.c1
-rw-r--r--drivers/hwmon/abituguru3.c6
-rw-r--r--drivers/hwmon/max6650.c1
-rw-r--r--drivers/hwmon/sht15.c2
-rw-r--r--drivers/i2c/busses/Kconfig1
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c9
-rw-r--r--drivers/ide/cs5520.c1
-rw-r--r--drivers/ide/ide-acpi.c37
-rw-r--r--drivers/ide/ide-cd.c24
-rw-r--r--drivers/ide/ide-devsets.c2
-rw-r--r--drivers/ide/ide-dma.c21
-rw-r--r--drivers/ide/ide-eh.c2
-rw-r--r--drivers/ide/ide-floppy.c2
-rw-r--r--drivers/ide/ide-io.c14
-rw-r--r--drivers/ide/ide-ioctls.c3
-rw-r--r--drivers/ide/ide-iops.c4
-rw-r--r--drivers/ide/ide-pm.c30
-rw-r--r--drivers/ide/ide-probe.c23
-rw-r--r--drivers/ieee1394/sbp2.c1
-rw-r--r--drivers/ieee1394/sbp2.h8
-rw-r--r--drivers/input/keyboard/Kconfig294
-rw-r--r--drivers/input/keyboard/Makefile33
-rw-r--r--drivers/input/keyboard/gpio_keys.c33
-rw-r--r--drivers/input/keyboard/matrix_keypad.c453
-rw-r--r--drivers/input/misc/cobalt_btns.c4
-rw-r--r--drivers/input/mouse/gpio_mouse.c11
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h28
-rw-r--r--drivers/input/serio/i8042.c7
-rw-r--r--drivers/input/serio/serio.c7
-rw-r--r--drivers/input/tablet/wacom_wac.c6
-rw-r--r--drivers/isdn/gigaset/ev-layer.c44
-rw-r--r--drivers/isdn/gigaset/isocdata.c6
-rw-r--r--drivers/isdn/hisax/hfc_usb.c1
-rw-r--r--drivers/isdn/i4l/isdn_tty.c1
-rw-r--r--drivers/isdn/mISDN/stack.c1
-rw-r--r--drivers/leds/Kconfig14
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-alix2.c7
-rw-r--r--drivers/leds/leds-bd2802.c96
-rw-r--r--drivers/leds/leds-cobalt-raq.c2
-rw-r--r--drivers/leds/leds-gpio.c22
-rw-r--r--drivers/leds/leds-lp3944.c466
-rw-r--r--drivers/leds/leds-pca9532.c58
-rw-r--r--drivers/lguest/lg.h2
-rw-r--r--drivers/lguest/lguest_user.c4
-rw-r--r--drivers/macintosh/macio_asic.c11
-rw-r--r--drivers/md/dm-crypt.c2
-rw-r--r--drivers/md/dm-exception-store.c9
-rw-r--r--drivers/md/dm-table.c2
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/md/linear.c4
-rw-r--r--drivers/md/md.c74
-rw-r--r--drivers/md/multipath.c7
-rw-r--r--drivers/md/raid0.c9
-rw-r--r--drivers/md/raid1.c9
-rw-r--r--drivers/md/raid10.c19
-rw-r--r--drivers/md/raid5.c28
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.c13
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c1
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.h1
-rw-r--r--drivers/media/dvb/ttpci/Kconfig1
-rw-r--r--drivers/media/dvb/ttpci/av7110.c1
-rw-r--r--drivers/media/radio/radio-mr800.c1
-rw-r--r--drivers/media/radio/radio-si470x.c6
-rw-r--r--drivers/media/video/Kconfig8
-rw-r--r--drivers/media/video/Makefile1
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c1
-rw-r--r--drivers/media/video/cx18/cx18-cards.c34
-rw-r--r--drivers/media/video/cx18/cx18-dvb.c160
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c1
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c30
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c1
-rw-r--r--drivers/media/video/cx23885/cx23885.h4
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c1
-rw-r--r--drivers/media/video/cx88/cx88-video.c1
-rw-r--r--drivers/media/video/dabusb.c1
-rw-r--r--drivers/media/video/em28xx/Kconfig2
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c84
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c32
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c28
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c92
-rw-r--r--drivers/media/video/em28xx/em28xx.h3
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx.h4
-rw-r--r--drivers/media/video/mt9v011.c431
-rw-r--r--drivers/media/video/mt9v011.h35
-rw-r--r--drivers/media/video/pwc/pwc-if.c1
-rw-r--r--drivers/media/video/pwc/pwc.h1
-rw-r--r--drivers/media/video/s2255drv.c1
-rw-r--r--drivers/media/video/saa5246a.c1
-rw-r--r--drivers/media/video/saa5249.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c1
-rw-r--r--drivers/media/video/se401.c1
-rw-r--r--drivers/media/video/soc_camera.c12
-rw-r--r--drivers/media/video/stk-webcam.c1
-rw-r--r--drivers/media/video/stradis.c1
-rw-r--r--drivers/media/video/stv680.c1
-rw-r--r--drivers/media/video/usbvideo/vicam.c1
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c1
-rw-r--r--drivers/media/video/v4l2-dev.c1
-rw-r--r--drivers/media/video/vivi.c99
-rw-r--r--drivers/media/video/zoran/zoran_driver.c1
-rw-r--r--drivers/mfd/dm355evm_msp.c3
-rw-r--r--drivers/mfd/ezx-pcap.c4
-rw-r--r--drivers/mfd/sm501.c3
-rw-r--r--drivers/misc/sgi-gru/grufile.c1
-rw-r--r--drivers/misc/sgi-gru/grukservices.c1
-rw-r--r--drivers/misc/sgi-xp/xpnet.c4
-rw-r--r--drivers/mmc/host/mmc_spi.c6
-rw-r--r--drivers/mtd/cmdlinepart.c2
-rw-r--r--drivers/mtd/devices/m25p80.c2
-rw-r--r--drivers/mtd/inftlcore.c11
-rw-r--r--drivers/mtd/maps/integrator-flash.c22
-rw-r--r--drivers/mtd/nand/atmel_nand.c2
-rw-r--r--drivers/mtd/nand/omap2.c7
-rw-r--r--drivers/mtd/nftlcore.c16
-rw-r--r--drivers/mtd/ubi/build.c6
-rw-r--r--drivers/mtd/ubi/debug.c2
-rw-r--r--drivers/mtd/ubi/debug.h7
-rw-r--r--drivers/mtd/ubi/io.c157
-rw-r--r--drivers/mtd/ubi/scan.c14
-rw-r--r--drivers/mtd/ubi/scan.h2
-rw-r--r--drivers/mtd/ubi/ubi-media.h12
-rw-r--r--drivers/mtd/ubi/ubi.h6
-rw-r--r--drivers/mtd/ubi/wl.c8
-rw-r--r--drivers/net/a2065.c12
-rw-r--r--drivers/net/arcnet/arcnet.c26
-rw-r--r--drivers/net/atl1c/atl1c_ethtool.c2
-rw-r--r--drivers/net/atl1e/atl1e_ethtool.c2
-rw-r--r--drivers/net/benet/be.h2
-rw-r--r--drivers/net/benet/be_ethtool.c4
-rw-r--r--drivers/net/benet/be_hw.h4
-rw-r--r--drivers/net/benet/be_main.c61
-rw-r--r--drivers/net/bmac.c7
-rw-r--r--drivers/net/bnx2x.h2
-rw-r--r--drivers/net/bnx2x_main.c29
-rw-r--r--drivers/net/cpmac.c2
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c3
-rw-r--r--drivers/net/davinci_emac.c12
-rw-r--r--drivers/net/dl2k.c17
-rw-r--r--drivers/net/e1000/e1000_main.c11
-rw-r--r--drivers/net/e1000e/defines.h3
-rw-r--r--drivers/net/e1000e/hw.h4
-rw-r--r--drivers/net/e1000e/ich8lan.c270
-rw-r--r--drivers/net/e1000e/lib.c6
-rw-r--r--drivers/net/e1000e/netdev.c3
-rw-r--r--drivers/net/e1000e/phy.c12
-rw-r--r--drivers/net/epic100.c5
-rw-r--r--drivers/net/fealnx.c15
-rw-r--r--drivers/net/fec.h12
-rw-r--r--drivers/net/forcedeth.c25
-rw-r--r--drivers/net/fsl_pq_mdio.c8
-rw-r--r--drivers/net/hamachi.c23
-rw-r--r--drivers/net/hamradio/baycom_epp.c2
-rw-r--r--drivers/net/hamradio/baycom_par.c2
-rw-r--r--drivers/net/hamradio/baycom_ser_fdx.c2
-rw-r--r--drivers/net/hamradio/baycom_ser_hdx.c2
-rw-r--r--drivers/net/igb/e1000_82575.c4
-rw-r--r--drivers/net/igb/igb_main.c14
-rw-r--r--drivers/net/irda/bfin_sir.c16
-rw-r--r--drivers/net/irda/irtty-sir.c1
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_nl.c6
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c6
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c88
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.c3
-rw-r--r--drivers/net/mdio.c4
-rw-r--r--drivers/net/natsemi.c4
-rw-r--r--drivers/net/ne.c2
-rw-r--r--drivers/net/netxen/netxen_nic.h17
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h1
-rw-r--r--drivers/net/netxen/netxen_nic_init.c111
-rw-r--r--drivers/net/netxen/netxen_nic_main.c4
-rw-r--r--drivers/net/pci-skeleton.c2
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c13
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c15
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c1
-rw-r--r--drivers/net/pcnet32.c50
-rw-r--r--drivers/net/phy/phy.c25
-rw-r--r--drivers/net/qlge/qlge.h2
-rw-r--r--drivers/net/qlge/qlge_ethtool.c4
-rw-r--r--drivers/net/qlge/qlge_main.c153
-rw-r--r--drivers/net/qlge/qlge_mpi.c6
-rw-r--r--drivers/net/r6040.c9
-rw-r--r--drivers/net/sh_eth.c9
-rw-r--r--drivers/net/sky2.c2
-rw-r--r--drivers/net/smsc911x.c6
-rw-r--r--drivers/net/starfire.c2
-rw-r--r--drivers/net/sundance.c6
-rw-r--r--drivers/net/tsi108_eth.c8
-rw-r--r--drivers/net/tulip/de2104x.c7
-rw-r--r--drivers/net/tulip/tulip_core.c14
-rw-r--r--drivers/net/tulip/winbond-840.c6
-rw-r--r--drivers/net/tun.c20
-rw-r--r--drivers/net/usb/cdc_eem.c2
-rw-r--r--drivers/net/usb/dm9601.c10
-rw-r--r--drivers/net/usb/net1080.c12
-rw-r--r--drivers/net/usb/rndis_host.c2
-rw-r--r--drivers/net/usb/smsc95xx.c10
-rw-r--r--drivers/net/usb/usbnet.c30
-rw-r--r--drivers/net/veth.c41
-rw-r--r--drivers/net/wan/hd64570.c3
-rw-r--r--drivers/net/wan/hd64572.c3
-rw-r--r--drivers/net/wan/sbni.c8
-rw-r--r--drivers/net/wireless/ath/Kconfig1
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c9
-rw-r--r--drivers/net/wireless/b43/b43.h1
-rw-r--r--drivers/net/wireless/b43/main.c7
-rw-r--r--drivers/net/wireless/b43/pcmcia.c1
-rw-r--r--drivers/net/wireless/b43legacy/b43legacy.h1
-rw-r--r--drivers/net/wireless/b43legacy/main.c7
-rw-r--r--drivers/net/wireless/iwmc3200wifi/Kconfig9
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c1
-rw-r--r--drivers/net/wireless/p54/p54common.c51
-rw-r--r--drivers/net/wireless/ray_cs.c9
-rw-r--r--drivers/net/wireless/wavelan_cs.c13
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c3
-rw-r--r--drivers/net/yellowfin.c23
-rw-r--r--drivers/oprofile/oprofile_stats.c1
-rw-r--r--drivers/parisc/ccio-dma.c7
-rw-r--r--drivers/parisc/dino.c12
-rw-r--r--drivers/parisc/eisa.c2
-rw-r--r--drivers/parisc/eisa_enumerator.c14
-rw-r--r--drivers/parisc/gsc.c4
-rw-r--r--drivers/parisc/gsc.h2
-rw-r--r--drivers/parisc/iosapic.c2
-rw-r--r--drivers/parisc/lba_pci.c41
-rw-r--r--drivers/parisc/sba_iommu.c2
-rw-r--r--drivers/parisc/superio.c6
-rw-r--r--drivers/parport/parport_pc.c5
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c1
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c2
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c1
-rw-r--r--drivers/pci/intel-iommu.c791
-rw-r--r--drivers/pci/iova.c26
-rw-r--r--drivers/pci/msi.c64
-rw-r--r--drivers/pci/msi.h10
-rw-r--r--drivers/pci/pci.c15
-rw-r--r--drivers/pci/pcie/aer/ecrc.c2
-rw-r--r--drivers/pci/quirks.c5
-rw-r--r--drivers/pci/slot.c4
-rw-r--r--drivers/pci/syscall.c1
-rw-r--r--drivers/pcmcia/tcic.c3
-rw-r--r--drivers/pcmcia/vrc4171_card.c4
-rw-r--r--drivers/pcmcia/vrc4173_cardu.c4
-rw-r--r--drivers/pcmcia/vrc4173_cardu.h2
-rw-r--r--drivers/platform/x86/Kconfig1
-rw-r--r--drivers/platform/x86/eeepc-laptop.c346
-rw-r--r--drivers/platform/x86/hp-wmi.c2
-rw-r--r--drivers/power/wm97xx_battery.c4
-rw-r--r--drivers/rtc/rtc-bfin.c30
-rw-r--r--drivers/rtc/rtc-ds1374.c4
-rw-r--r--drivers/rtc/rtc-vr41xx.c4
-rw-r--r--drivers/s390/block/dasd_eckd.c45
-rw-r--r--drivers/s390/block/dasd_erp.c2
-rw-r--r--drivers/s390/block/dasd_fba.c25
-rw-r--r--drivers/s390/block/dasd_int.h3
-rw-r--r--drivers/s390/block/dasd_ioctl.c1
-rw-r--r--drivers/s390/block/dcssblk.c7
-rw-r--r--drivers/s390/block/xpram.c2
-rw-r--r--drivers/s390/char/monreader.c4
-rw-r--r--drivers/s390/char/sclp_rw.h5
-rw-r--r--drivers/s390/char/vmwatchdog.c8
-rw-r--r--drivers/scsi/atari_NCR5380.c3
-rw-r--r--drivers/scsi/cxgb3i/Kbuild2
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_iscsi.c4
-rw-r--r--drivers/scsi/fnic/fnic_main.c8
-rw-r--r--drivers/scsi/fnic/fnic_scsi.c7
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c7
-rw-r--r--drivers/scsi/mac53c94.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c1
-rw-r--r--drivers/scsi/scsi_transport_fc.c5
-rw-r--r--drivers/scsi/sg.c10
-rw-r--r--drivers/scsi/sun3_NCR5380.c3
-rw-r--r--drivers/scsi/zalon.c2
-rw-r--r--drivers/serial/8250_pci.c17
-rw-r--r--drivers/serial/sh-sci.c11
-rw-r--r--drivers/serial/vr41xx_siu.c2
-rw-r--r--drivers/spi/omap_uwire.c2
-rw-r--r--drivers/spi/spi_bitbang.c24
-rw-r--r--drivers/spi/spidev.c17
-rw-r--r--drivers/ssb/driver_mipscore.c85
-rw-r--r--drivers/ssb/pcmcia.c10
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.c2
-rw-r--r--drivers/staging/comedi/drivers/s626.c35
-rw-r--r--drivers/staging/go7007/s2250-loader.c1
-rw-r--r--drivers/staging/meilhaus/TODO2
-rw-r--r--drivers/staging/rspiusb/rspiusb.c14
-rw-r--r--drivers/staging/rt2870/rt2870.h1
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c12
-rw-r--r--drivers/staging/rtl8192su/Kconfig2
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_module.c1
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c14
-rw-r--r--drivers/staging/rtl8192su/r8192U_core.c23
-rw-r--r--drivers/staging/rtl8192su/r8192U_pm.c8
-rw-r--r--drivers/staging/serqt_usb2/serqt_usb2.c8
-rw-r--r--drivers/staging/stlc45xx/stlc45xx.c27
-rw-r--r--drivers/staging/usbip/usbip_common.c1
-rw-r--r--drivers/staging/vt6655/device_main.c10
-rw-r--r--drivers/telephony/ixj.c1
-rw-r--r--drivers/telephony/phonedev.c1
-rw-r--r--drivers/usb/class/cdc-acm.c35
-rw-r--r--drivers/usb/class/cdc-wdm.c1
-rw-r--r--drivers/usb/class/usbtmc.c10
-rw-r--r--drivers/usb/core/Kconfig2
-rw-r--r--drivers/usb/core/devices.c10
-rw-r--r--drivers/usb/core/devio.c78
-rw-r--r--drivers/usb/core/hcd.c2
-rw-r--r--drivers/usb/core/hcd.h4
-rw-r--r--drivers/usb/core/hub.c40
-rw-r--r--drivers/usb/core/hub.h6
-rw-r--r--drivers/usb/core/message.c63
-rw-r--r--drivers/usb/gadget/Kconfig43
-rw-r--r--drivers/usb/gadget/amd5536udc.c1
-rw-r--r--drivers/usb/gadget/audio.c6
-rw-r--r--drivers/usb/gadget/ether.c11
-rw-r--r--drivers/usb/gadget/langwell_udc.c1
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c24
-rw-r--r--drivers/usb/gadget/rndis.c2
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c1
-rw-r--r--drivers/usb/host/Kconfig33
-rw-r--r--drivers/usb/host/ehci-au1xxx.c2
-rw-r--r--drivers/usb/host/ehci-fsl.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c37
-rw-r--r--drivers/usb/host/ehci-ixp4xx.c2
-rw-r--r--drivers/usb/host/ehci-orion.c2
-rw-r--r--drivers/usb/host/ehci-pci.c2
-rw-r--r--drivers/usb/host/ehci-ppc-of.c2
-rw-r--r--drivers/usb/host/ehci-ps3.c2
-rw-r--r--drivers/usb/host/ehci-q.c140
-rw-r--r--drivers/usb/host/ehci-sched.c12
-rw-r--r--drivers/usb/host/ehci.h2
-rw-r--r--drivers/usb/host/fhci-sched.c8
-rw-r--r--drivers/usb/host/isp1760-if.c2
-rw-r--r--drivers/usb/host/r8a66597-hcd.c1
-rw-r--r--drivers/usb/misc/iowarrior.c1
-rw-r--r--drivers/usb/misc/rio500.c1
-rw-r--r--drivers/usb/misc/usblcd.c1
-rw-r--r--drivers/usb/mon/mon_bin.c2
-rw-r--r--drivers/usb/musb/cppi_dma.h1
-rw-r--r--drivers/usb/musb/davinci.c32
-rw-r--r--drivers/usb/musb/musb_core.h1
-rw-r--r--drivers/usb/musb/musb_host.c27
-rw-r--r--drivers/usb/otg/Kconfig14
-rw-r--r--drivers/usb/otg/Makefile1
-rw-r--r--drivers/usb/otg/langwell_otg.c1915
-rw-r--r--drivers/usb/otg/nop-usb-xceiv.c1
-rw-r--r--drivers/usb/serial/console.c13
-rw-r--r--drivers/usb/serial/cp210x.c2
-rw-r--r--drivers/usb/serial/cypress_m8.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c70
-rw-r--r--drivers/usb/serial/ftdi_sio.h18
-rw-r--r--drivers/usb/serial/generic.c20
-rw-r--r--drivers/usb/serial/mos7840.c1
-rw-r--r--drivers/usb/serial/option.c45
-rw-r--r--drivers/usb/serial/pl2303.c59
-rw-r--r--drivers/usb/serial/pl2303.h4
-rw-r--r--drivers/usb/serial/sierra.c51
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c3
-rw-r--r--drivers/usb/serial/usb-serial.c7
-rw-r--r--drivers/usb/storage/option_ms.c3
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/amba-clcd.c7
-rw-r--r--drivers/video/atafb.c8
-rw-r--r--drivers/video/atmel_lcdfb.c3
-rw-r--r--drivers/video/aty/atyfb.h3
-rw-r--r--drivers/video/aty/atyfb_base.c141
-rw-r--r--drivers/video/aty/mach64_accel.c7
-rw-r--r--drivers/video/backlight/tdo24m.c2
-rw-r--r--drivers/video/cobalt_lcdfb.c2
-rw-r--r--drivers/video/fbmem.c14
-rw-r--r--drivers/video/fsl-diu-fb.c20
-rw-r--r--drivers/video/hitfb.c66
-rw-r--r--drivers/video/i810/i810_main.c5
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.c4
-rw-r--r--drivers/video/matrox/matroxfb_Ti3026.c4
-rw-r--r--drivers/video/matrox/matroxfb_base.c4
-rw-r--r--drivers/video/matrox/matroxfb_crtc2.c7
-rw-r--r--drivers/video/mx3fb.c22
-rw-r--r--drivers/video/omap/omapfb_main.c18
-rw-r--r--drivers/video/platinumfb.c2
-rw-r--r--drivers/video/pxafb.c2
-rw-r--r--drivers/video/s3c-fb.c17
-rw-r--r--drivers/video/sh7760fb.c19
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c91
-rw-r--r--drivers/video/sis/sis_main.c3
-rw-r--r--drivers/video/sm501fb.c26
-rw-r--r--drivers/video/stifb.c7
-rw-r--r--drivers/video/w100fb.c4
-rw-r--r--drivers/vlynq/Kconfig2
-rw-r--r--drivers/vlynq/vlynq.c2
-rw-r--r--drivers/watchdog/bcm47xx_wdt.c2
-rw-r--r--drivers/watchdog/sa1100_wdt.c5
-rw-r--r--drivers/watchdog/w83627hf_wdt.c5
-rw-r--r--drivers/watchdog/w83697ug_wdt.c4
-rw-r--r--drivers/watchdog/wdrtas.c8
-rw-r--r--drivers/xen/events.c4
-rw-r--r--fs/adfs/super.c1
-rw-r--r--fs/afs/dir.c2
-rw-r--r--fs/afs/flock.c1
-rw-r--r--fs/afs/mntpt.c1
-rw-r--r--fs/afs/super.c1
-rw-r--r--fs/aio.c24
-rw-r--r--fs/autofs4/dev-ioctl.c1
-rw-r--r--fs/bfs/dir.c1
-rw-r--r--fs/bfs/file.c1
-rw-r--r--fs/binfmt_elf.c9
-rw-r--r--fs/bio-integrity.c170
-rw-r--r--fs/bio.c33
-rw-r--r--fs/btrfs/async-thread.c2
-rw-r--r--fs/btrfs/compression.c1
-rw-r--r--fs/btrfs/ctree.h3
-rw-r--r--fs/btrfs/extent-tree.c566
-rw-r--r--fs/btrfs/file.c6
-rw-r--r--fs/btrfs/inode.c26
-rw-r--r--fs/btrfs/ioctl.c7
-rw-r--r--fs/btrfs/relocation.c5
-rw-r--r--fs/btrfs/super.c1
-rw-r--r--fs/btrfs/transaction.c4
-rw-r--r--fs/char_dev.c1
-rw-r--r--fs/cifs/CHANGES6
-rw-r--r--fs/cifs/asn1.c55
-rw-r--r--fs/cifs/cifs_spnego.c9
-rw-r--r--fs/cifs/cifsacl.c26
-rw-r--r--fs/cifs/cifsfs.c158
-rw-r--r--fs/cifs/cifsfs.h15
-rw-r--r--fs/cifs/cifsglob.h30
-rw-r--r--fs/cifs/cifspdu.h14
-rw-r--r--fs/cifs/cifsproto.h23
-rw-r--r--fs/cifs/cifssmb.c147
-rw-r--r--fs/cifs/connect.c39
-rw-r--r--fs/cifs/dir.c52
-rw-r--r--fs/cifs/dns_resolve.c25
-rw-r--r--fs/cifs/file.c40
-rw-r--r--fs/cifs/inode.c777
-rw-r--r--fs/cifs/link.c3
-rw-r--r--fs/cifs/netmisc.c56
-rw-r--r--fs/cifs/readdir.c505
-rw-r--r--fs/cifs/sess.c2
-rw-r--r--fs/cifs/xattr.c12
-rw-r--r--fs/compat.c5
-rw-r--r--fs/compat_ioctl.c1
-rw-r--r--fs/eventfd.c122
-rw-r--r--fs/exec.c4
-rw-r--r--fs/exofs/common.h4
-rw-r--r--fs/exofs/dir.c4
-rw-r--r--fs/exofs/exofs.h7
-rw-r--r--fs/exofs/file.c21
-rw-r--r--fs/exofs/inode.c7
-rw-r--r--fs/exofs/namei.c4
-rw-r--r--fs/exofs/osd.c4
-rw-r--r--fs/exofs/super.c7
-rw-r--r--fs/exofs/symlink.c4
-rw-r--r--fs/ext2/ioctl.c1
-rw-r--r--fs/ext2/namei.c12
-rw-r--r--fs/ext4/ext4.h14
-rw-r--r--fs/ext4/ext4_jbd2.c4
-rw-r--r--fs/ext4/ext4_jbd2.h6
-rw-r--r--fs/ext4/extents.c1
-rw-r--r--fs/ext4/ialloc.c2
-rw-r--r--fs/ext4/inode.c384
-rw-r--r--fs/ext4/ioctl.c21
-rw-r--r--fs/ext4/mballoc.c50
-rw-r--r--fs/fat/dir.c1
-rw-r--r--fs/fat/file.c2
-rw-r--r--fs/fat/namei_msdos.c1
-rw-r--r--fs/fat/namei_vfat.c1
-rw-r--r--fs/fcntl.c1
-rw-r--r--fs/freevxfs/vxfs_super.c1
-rw-r--r--fs/fuse/dev.c91
-rw-r--r--fs/fuse/dir.c57
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/fuse/fuse_i.h27
-rw-r--r--fs/fuse/inode.c68
-rw-r--r--fs/hfs/super.c1
-rw-r--r--fs/hfsplus/super.c1
-rw-r--r--fs/hostfs/hostfs_kern.c1
-rw-r--r--fs/hpfs/dir.c1
-rw-r--r--fs/hpfs/file.c1
-rw-r--r--fs/hpfs/hpfs_fn.h1
-rw-r--r--fs/hpfs/inode.c1
-rw-r--r--fs/hpfs/namei.c1
-rw-r--r--fs/isofs/inode.c4
-rw-r--r--fs/jbd2/journal.c31
-rw-r--r--fs/jbd2/transaction.c68
-rw-r--r--fs/jffs2/erase.c10
-rw-r--r--fs/jffs2/scan.c4
-rw-r--r--fs/jffs2/super.c1
-rw-r--r--fs/lockd/clntproc.c1
-rw-r--r--fs/lockd/svc4proc.c1
-rw-r--r--fs/lockd/svcproc.c1
-rw-r--r--fs/namei.c7
-rw-r--r--fs/namespace.c1
-rw-r--r--fs/nfs/delegation.c1
-rw-r--r--fs/nfs/dir.c1
-rw-r--r--fs/nfs/file.c1
-rw-r--r--fs/nfs/getroot.c1
-rw-r--r--fs/nfs/inode.c1
-rw-r--r--fs/nfs/nfs4proc.c1
-rw-r--r--fs/nfs/read.c1
-rw-r--r--fs/nfs/write.c8
-rw-r--r--fs/nfsd/nfsctl.c1
-rw-r--r--fs/nfsd/nfssvc.c1
-rw-r--r--fs/nfsd/vfs.c3
-rw-r--r--fs/nilfs2/bmap.c5
-rw-r--r--fs/nilfs2/cpfile.c5
-rw-r--r--fs/nilfs2/dat.c9
-rw-r--r--fs/nilfs2/dir.c1
-rw-r--r--fs/nilfs2/segment.c30
-rw-r--r--fs/notify/inotify/inotify_user.c3
-rw-r--r--fs/ocfs2/ioctl.c1
-rw-r--r--fs/partitions/check.c2
-rw-r--r--fs/quota/dquot.c4
-rw-r--r--fs/reiserfs/journal.c2
-rw-r--r--fs/reiserfs/super.c1
-rw-r--r--fs/reiserfs/xattr.c1
-rw-r--r--fs/squashfs/super.c1
-rw-r--r--fs/sync.c5
-rw-r--r--fs/sysfs/bin.c1
-rw-r--r--fs/ubifs/io.c57
-rw-r--r--fs/ubifs/ioctl.c1
-rw-r--r--fs/ubifs/recovery.c57
-rw-r--r--fs/ubifs/replay.c9
-rw-r--r--fs/ubifs/scan.c20
-rw-r--r--fs/ubifs/super.c14
-rw-r--r--fs/ubifs/ubifs.h11
-rw-r--r--fs/xfs/linux-2.6/kmem.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c1
-rw-r--r--include/asm-generic/percpu.h4
-rw-r--r--include/asm-generic/vmlinux.lds.h15
-rw-r--r--include/drm/drm_edid.h38
-rw-r--r--include/linux/aio.h4
-rw-r--r--include/linux/backing-dev.h11
-rw-r--r--include/linux/bio.h22
-rw-r--r--include/linux/blkdev.h29
-rw-r--r--include/linux/crash_dump.h1
-rw-r--r--include/linux/device.h2
-rw-r--r--include/linux/elfcore.h5
-rw-r--r--include/linux/eventfd.h35
-rw-r--r--include/linux/fb.h1
-rw-r--r--include/linux/firewire.h1
-rw-r--r--include/linux/fsnotify_backend.h2
-rw-r--r--include/linux/fuse.h36
-rw-r--r--include/linux/hardirq.h2
-rw-r--r--include/linux/hrtimer.h5
-rw-r--r--include/linux/ide.h5
-rw-r--r--include/linux/if_ether.h1
-rw-r--r--include/linux/ima.h6
-rw-r--r--include/linux/init_task.h3
-rw-r--r--include/linux/input/matrix_keypad.h65
-rw-r--r--include/linux/kernel.h1
-rw-r--r--include/linux/kmemleak.h4
-rw-r--r--include/linux/kvm_host.h1
-rw-r--r--include/linux/leds-lp3944.h53
-rw-r--r--include/linux/leds.h14
-rw-r--r--include/linux/linkage.h9
-rw-r--r--include/linux/mm.h2
-rw-r--r--include/linux/mnt_namespace.h13
-rw-r--r--include/linux/netfilter/xt_conntrack.h13
-rw-r--r--include/linux/netfilter/xt_osf.h2
-rw-r--r--include/linux/pci.h2
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/percpu-defs.h3
-rw-r--r--include/linux/perf_counter.h46
-rw-r--r--include/linux/personality.h5
-rw-r--r--include/linux/quotaops.h1
-rw-r--r--include/linux/rfkill.h1
-rw-r--r--include/linux/sched.h25
-rw-r--r--include/linux/slub_def.h2
-rw-r--r--include/linux/spi/spi.h6
-rw-r--r--include/linux/spi/spidev.h2
-rw-r--r--include/linux/spinlock.h5
-rw-r--r--include/linux/sunrpc/xdr.h1
-rw-r--r--include/linux/syscalls.h2
-rw-r--r--include/linux/sysrq.h2
-rw-r--r--include/linux/timer.h4
-rw-r--r--include/linux/usb.h6
-rw-r--r--include/linux/usb/langwell_otg.h177
-rw-r--r--include/linux/usb/serial.h3
-rw-r--r--include/linux/usb/usbnet.h1
-rw-r--r--include/linux/videodev2.h2
-rw-r--r--include/media/v4l2-chip-ident.h3
-rw-r--r--include/net/netfilter/nf_conntrack.h4
-rw-r--r--include/net/phonet/pn_dev.h1
-rw-r--r--include/net/sock.h69
-rw-r--r--include/trace/events/ext4.h48
-rw-r--r--ipc/mqueue.c2
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/acct.c6
-rw-r--r--kernel/exit.c1
-rw-r--r--kernel/fork.c1
-rw-r--r--kernel/futex.c2
-rw-r--r--kernel/kmod.c1
-rw-r--r--kernel/kprobes.c6
-rw-r--r--kernel/module.c6
-rw-r--r--kernel/perf_counter.c322
-rw-r--r--kernel/power/user.c1
-rw-r--r--kernel/ptrace.c4
-rw-r--r--kernel/rcutree.c3
-rw-r--r--kernel/resource.c2
-rw-r--r--kernel/sched.c14
-rw-r--r--kernel/sysctl.c13
-rw-r--r--kernel/time/timer_stats.c16
-rw-r--r--kernel/timer.c2
-rw-r--r--kernel/trace/Kconfig6
-rw-r--r--kernel/trace/blktrace.c1
-rw-r--r--kernel/trace/ftrace.c60
-rw-r--r--kernel/trace/ring_buffer.c11
-rw-r--r--kernel/trace/trace.c24
-rw-r--r--kernel/trace/trace.h7
-rw-r--r--kernel/trace/trace_event_types.h3
-rw-r--r--kernel/trace/trace_events.c28
-rw-r--r--kernel/trace/trace_functions.c3
-rw-r--r--kernel/trace/trace_output.c3
-rw-r--r--kernel/trace/trace_printk.c26
-rw-r--r--kernel/trace/trace_stack.c4
-rw-r--r--kernel/trace/trace_stat.c6
-rw-r--r--lib/Kconfig.debug12
-rw-r--r--lib/dma-debug.c26
-rw-r--r--mm/backing-dev.c7
-rw-r--r--mm/bootmem.c6
-rw-r--r--mm/dmapool.c2
-rw-r--r--mm/filemap.c1
-rw-r--r--mm/kmemleak.c405
-rw-r--r--mm/memcontrol.c2
-rw-r--r--mm/memory.c26
-rw-r--r--mm/nommu.c33
-rw-r--r--mm/page-writeback.c13
-rw-r--r--mm/page_alloc.c33
-rw-r--r--mm/percpu.c24
-rw-r--r--mm/slab.c8
-rw-r--r--mm/slob.c2
-rw-r--r--mm/slub.c12
-rw-r--r--mm/vmscan.c8
-rw-r--r--net/9p/trans_fd.c14
-rw-r--r--net/appletalk/ddp.c1
-rw-r--r--net/atm/common.c6
-rw-r--r--net/bridge/br.c2
-rw-r--r--net/core/datagram.c2
-rw-r--r--net/core/dev.c8
-rw-r--r--net/core/netpoll.c2
-rw-r--r--net/core/sock.c8
-rw-r--r--net/dccp/output.c2
-rw-r--r--net/dccp/proto.c2
-rw-r--r--net/decnet/af_decnet.c2
-rw-r--r--net/dsa/mv88e6xxx.c2
-rw-r--r--net/ieee802154/netlink.c6
-rw-r--r--net/ipv4/arp.c7
-rw-r--r--net/ipv4/fib_trie.c7
-rw-r--r--net/ipv4/ip_input.c3
-rw-r--r--net/ipv4/netfilter/nf_nat_helper.c17
-rw-r--r--net/ipv4/tcp.c17
-rw-r--r--net/ipv4/tcp_minisocks.c3
-rw-r--r--net/ipv4/tcp_output.c3
-rw-r--r--net/ipv4/xfrm4_policy.c3
-rw-r--r--net/ipv6/addrconf.c35
-rw-r--r--net/ipv6/af_inet6.c2
-rw-r--r--net/ipv6/ip6_input.c3
-rw-r--r--net/ipv6/xfrm6_policy.c6
-rw-r--r--net/ipx/af_ipx.c1
-rw-r--r--net/irda/af_irda.c1
-rw-r--r--net/irda/irnet/irnet.h1
-rw-r--r--net/irda/irnet/irnet_ppp.c1
-rw-r--r--net/iucv/af_iucv.c4
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/mac80211/mesh_hwmp.c2
-rw-r--r--net/mac80211/rc80211_minstrel.c5
-rw-r--r--net/netfilter/nf_conntrack_expect.c4
-rw-r--r--net/netfilter/nf_conntrack_extend.c2
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c6
-rw-r--r--net/netfilter/xt_conntrack.c66
-rw-r--r--net/phonet/pn_dev.c52
-rw-r--r--net/phonet/pn_netlink.c4
-rw-r--r--net/rxrpc/af_rxrpc.c4
-rw-r--r--net/sctp/output.c2
-rw-r--r--net/sctp/socket.c25
-rw-r--r--net/sunrpc/clnt.c1
-rw-r--r--net/sunrpc/sched.c1
-rw-r--r--net/sunrpc/sunrpc_syms.c1
-rw-r--r--net/sunrpc/svc_xprt.c1
-rw-r--r--net/unix/af_unix.c8
-rw-r--r--net/wanrouter/wanmain.c1
-rw-r--r--net/wireless/nl80211.c1
-rw-r--r--net/wireless/scan.c1
-rw-r--r--net/x25/af_x25.c1
-rw-r--r--net/xfrm/xfrm_algo.c4
-rw-r--r--net/xfrm/xfrm_state.c57
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/dtc/.gitignore5
-rwxr-xr-xscripts/kernel-doc4
-rw-r--r--scripts/package/builddeb2
-rw-r--r--scripts/pnmtologo.c4
-rw-r--r--security/integrity/ima/ima_main.c29
-rw-r--r--security/integrity/ima/ima_queue.c3
-rw-r--r--sound/arm/pxa2xx-pcm-lib.c2
-rw-r--r--sound/oss/kahlua.c2
-rw-r--r--sound/oss/mpu401.c16
-rw-r--r--sound/pci/atiixp.c8
-rw-r--r--sound/pci/atiixp_modem.c4
-rw-r--r--sound/pci/au88x0/au8810.c3
-rw-r--r--sound/pci/au88x0/au8820.c3
-rw-r--r--sound/pci/au88x0/au8830.c3
-rw-r--r--sound/pci/ca0106/ca0106_main.c2
-rw-r--r--sound/pci/cmipci.c10
-rw-r--r--sound/pci/cs4281.c2
-rw-r--r--sound/pci/cs46xx/cs46xx.c6
-rw-r--r--sound/pci/ctxfi/ctdaio.c4
-rw-r--r--sound/pci/emu10k1/emu10k1.c6
-rw-r--r--sound/pci/emu10k1/emu10k1x.c2
-rw-r--r--sound/pci/emu10k1/p16v.c2
-rw-r--r--sound/pci/ens1370.c8
-rw-r--r--sound/pci/es1938.c2
-rw-r--r--sound/pci/hda/hda_beep.c11
-rw-r--r--sound/pci/hda/hda_codec.c20
-rw-r--r--sound/pci/hda/hda_intel.c29
-rw-r--r--sound/pci/hda/patch_analog.c156
-rw-r--r--sound/pci/hda/patch_ca0110.c2
-rw-r--r--sound/pci/hda/patch_realtek.c88
-rw-r--r--sound/pci/hda/patch_sigmatel.c11
-rw-r--r--sound/pci/hda/patch_via.c89
-rw-r--r--sound/pci/ice1712/ice1712.c2
-rw-r--r--sound/pci/ice1712/ice1724.c2
-rw-r--r--sound/pci/intel8x0.c46
-rw-r--r--sound/pci/intel8x0m.c34
-rw-r--r--sound/pci/lx6464es/lx6464es.c7
-rw-r--r--sound/pci/mixart/mixart.c2
-rw-r--r--sound/pci/nm256/nm256.c6
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c28
-rw-r--r--sound/pci/oxygen/virtuoso.c2
-rw-r--r--sound/pci/rme32.c9
-rw-r--r--sound/pci/rme96.c12
-rw-r--r--sound/pci/sonicvibes.c2
-rw-r--r--sound/pci/via82xx.c4
-rw-r--r--sound/pci/via82xx_modem.c2
-rw-r--r--sound/pci/ymfpci/ymfpci.c12
-rw-r--r--sound/soc/codecs/wm8753.c6
-rw-r--r--sound/soc/codecs/wm8988.c4
-rw-r--r--sound/soc/fsl/Kconfig6
-rw-r--r--sound/soc/fsl/mpc5200_dma.c1
-rw-r--r--sound/soc/fsl/mpc5200_dma.h1
-rw-r--r--sound/soc/fsl/mpc5200_psc_ac97.c17
-rw-r--r--sound/soc/omap/omap-pcm.c11
-rw-r--r--sound/soc/pxa/pxa2xx-i2s.c7
-rw-r--r--sound/sound_core.c5
-rw-r--r--sound/usb/caiaq/device.c10
-rw-r--r--sound/usb/usbaudio.c14
-rw-r--r--sound/usb/usx2y/us122l.c2
-rw-r--r--sound/usb/usx2y/usbusx2y.c2
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c7
-rw-r--r--tools/perf/CREDITS30
-rw-r--r--tools/perf/Documentation/perf-report.txt14
-rw-r--r--tools/perf/Documentation/perf-stat.txt6
-rw-r--r--tools/perf/Makefile26
-rw-r--r--tools/perf/builtin-annotate.c77
-rw-r--r--tools/perf/builtin-help.c6
-rw-r--r--tools/perf/builtin-list.c2
-rw-r--r--tools/perf/builtin-record.c131
-rw-r--r--tools/perf/builtin-report.c595
-rw-r--r--tools/perf/builtin-stat.c216
-rw-r--r--tools/perf/builtin-top.c81
-rw-r--r--tools/perf/perf.c5
-rw-r--r--tools/perf/perf.h27
-rw-r--r--tools/perf/util/alias.c2
-rw-r--r--tools/perf/util/cache.h1
-rw-r--r--tools/perf/util/callchain.c335
-rw-r--r--tools/perf/util/callchain.h54
-rw-r--r--tools/perf/util/color.c37
-rw-r--r--tools/perf/util/color.h5
-rw-r--r--tools/perf/util/config.c18
-rw-r--r--tools/perf/util/exec_cmd.c5
-rw-r--r--tools/perf/util/header.c242
-rw-r--r--tools/perf/util/header.h37
-rw-r--r--tools/perf/util/help.c41
-rw-r--r--tools/perf/util/help.h6
-rw-r--r--tools/perf/util/include/asm/system.h1
-rw-r--r--tools/perf/util/include/linux/kernel.h21
-rw-r--r--tools/perf/util/include/linux/list.h18
-rw-r--r--tools/perf/util/include/linux/module.h6
-rw-r--r--tools/perf/util/include/linux/poison.h1
-rw-r--r--tools/perf/util/include/linux/prefetch.h6
-rw-r--r--tools/perf/util/include/linux/rbtree.h1
-rw-r--r--tools/perf/util/list.h603
-rw-r--r--tools/perf/util/module.c509
-rw-r--r--tools/perf/util/module.h53
-rw-r--r--tools/perf/util/pager.c5
-rw-r--r--tools/perf/util/parse-events.c378
-rw-r--r--tools/perf/util/parse-options.c5
-rw-r--r--tools/perf/util/parse-options.h27
-rw-r--r--tools/perf/util/quote.c46
-rw-r--r--tools/perf/util/quote.h2
-rw-r--r--tools/perf/util/rbtree.c383
-rw-r--r--tools/perf/util/rbtree.h171
-rw-r--r--tools/perf/util/run-command.c95
-rw-r--r--tools/perf/util/run-command.h5
-rw-r--r--tools/perf/util/strbuf.c15
-rw-r--r--tools/perf/util/strbuf.h10
-rw-r--r--tools/perf/util/string.h2
-rw-r--r--tools/perf/util/strlist.c184
-rw-r--r--tools/perf/util/strlist.h32
-rw-r--r--tools/perf/util/symbol.c183
-rw-r--r--tools/perf/util/symbol.h14
-rw-r--r--tools/perf/util/types.h (renamed from tools/perf/types.h)0
-rw-r--r--tools/perf/util/util.h15
-rw-r--r--tools/perf/util/wrapper.c5
-rw-r--r--virt/kvm/kvm_main.c5
1376 files changed, 27453 insertions, 16587 deletions
diff --git a/.gitignore b/.gitignore
index cecb3b040cc1..b93fb7eff942 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,7 @@
27*.gz 27*.gz
28*.lzma 28*.lzma
29*.patch 29*.patch
30*.gcno
30 31
31# 32#
32# Top-level generic files 33# Top-level generic files
diff --git a/Documentation/DocBook/mac80211.tmpl b/Documentation/DocBook/mac80211.tmpl
index e36986663570..f3f37f141dbd 100644
--- a/Documentation/DocBook/mac80211.tmpl
+++ b/Documentation/DocBook/mac80211.tmpl
@@ -184,8 +184,6 @@ usage should require reading the full document.
184!Finclude/net/mac80211.h ieee80211_ctstoself_get 184!Finclude/net/mac80211.h ieee80211_ctstoself_get
185!Finclude/net/mac80211.h ieee80211_ctstoself_duration 185!Finclude/net/mac80211.h ieee80211_ctstoself_duration
186!Finclude/net/mac80211.h ieee80211_generic_frame_duration 186!Finclude/net/mac80211.h ieee80211_generic_frame_duration
187!Finclude/net/mac80211.h ieee80211_get_hdrlen_from_skb
188!Finclude/net/mac80211.h ieee80211_hdrlen
189!Finclude/net/mac80211.h ieee80211_wake_queue 187!Finclude/net/mac80211.h ieee80211_wake_queue
190!Finclude/net/mac80211.h ieee80211_stop_queue 188!Finclude/net/mac80211.h ieee80211_stop_queue
191!Finclude/net/mac80211.h ieee80211_wake_queues 189!Finclude/net/mac80211.h ieee80211_wake_queues
diff --git a/Documentation/block/data-integrity.txt b/Documentation/block/data-integrity.txt
index e8ca040ba2cf..2d735b0ae383 100644
--- a/Documentation/block/data-integrity.txt
+++ b/Documentation/block/data-integrity.txt
@@ -50,7 +50,7 @@ encouraged them to allow separation of the data and integrity metadata
50scatter-gather lists. 50scatter-gather lists.
51 51
52The controller will interleave the buffers on write and split them on 52The controller will interleave the buffers on write and split them on
53read. This means that the Linux can DMA the data buffers to and from 53read. This means that Linux can DMA the data buffers to and from
54host memory without changes to the page cache. 54host memory without changes to the page cache.
55 55
56Also, the 16-bit CRC checksum mandated by both the SCSI and SATA specs 56Also, the 16-bit CRC checksum mandated by both the SCSI and SATA specs
@@ -66,7 +66,7 @@ software RAID5).
66 66
67The IP checksum is weaker than the CRC in terms of detecting bit 67The IP checksum is weaker than the CRC in terms of detecting bit
68errors. However, the strength is really in the separation of the data 68errors. However, the strength is really in the separation of the data
69buffers and the integrity metadata. These two distinct buffers much 69buffers and the integrity metadata. These two distinct buffers must
70match up for an I/O to complete. 70match up for an I/O to complete.
71 71
72The separation of the data and integrity metadata buffers as well as 72The separation of the data and integrity metadata buffers as well as
diff --git a/Documentation/cgroups/cpusets.txt b/Documentation/cgroups/cpusets.txt
index f9ca389dddf4..1d7e9784439a 100644
--- a/Documentation/cgroups/cpusets.txt
+++ b/Documentation/cgroups/cpusets.txt
@@ -777,6 +777,18 @@ in cpuset directories:
777# /bin/echo 1-4 > cpus -> set cpus list to cpus 1,2,3,4 777# /bin/echo 1-4 > cpus -> set cpus list to cpus 1,2,3,4
778# /bin/echo 1,2,3,4 > cpus -> set cpus list to cpus 1,2,3,4 778# /bin/echo 1,2,3,4 > cpus -> set cpus list to cpus 1,2,3,4
779 779
780To add a CPU to a cpuset, write the new list of CPUs including the
781CPU to be added. To add 6 to the above cpuset:
782
783# /bin/echo 1-4,6 > cpus -> set cpus list to cpus 1,2,3,4,6
784
785Similarly to remove a CPU from a cpuset, write the new list of CPUs
786without the CPU to be removed.
787
788To remove all the CPUs:
789
790# /bin/echo "" > cpus -> clear cpus list
791
7802.3 Setting flags 7922.3 Setting flags
781----------------- 793-----------------
782 794
diff --git a/Documentation/driver-model/driver.txt b/Documentation/driver-model/driver.txt
index 82132169d47a..60120fb3b961 100644
--- a/Documentation/driver-model/driver.txt
+++ b/Documentation/driver-model/driver.txt
@@ -207,8 +207,8 @@ Attributes
207~~~~~~~~~~ 207~~~~~~~~~~
208struct driver_attribute { 208struct driver_attribute {
209 struct attribute attr; 209 struct attribute attr;
210 ssize_t (*show)(struct device_driver *, char * buf, size_t count, loff_t off); 210 ssize_t (*show)(struct device_driver *driver, char *buf);
211 ssize_t (*store)(struct device_driver *, const char * buf, size_t count, loff_t off); 211 ssize_t (*store)(struct device_driver *, const char * buf, size_t count);
212}; 212};
213 213
214Device drivers can export attributes via their sysfs directories. 214Device drivers can export attributes via their sysfs directories.
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
index a52adfc9a57f..3d1b0ab70c8e 100644
--- a/Documentation/dvb/get_dvb_firmware
+++ b/Documentation/dvb/get_dvb_firmware
@@ -25,7 +25,7 @@ use IO::Handle;
25 "tda10046lifeview", "av7110", "dec2000t", "dec2540t", 25 "tda10046lifeview", "av7110", "dec2000t", "dec2540t",
26 "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004", 26 "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
27 "or51211", "or51132_qam", "or51132_vsb", "bluebird", 27 "or51211", "or51132_qam", "or51132_vsb", "bluebird",
28 "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2" ); 28 "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718" );
29 29
30# Check args 30# Check args
31syntax() if (scalar(@ARGV) != 1); 31syntax() if (scalar(@ARGV) != 1);
@@ -381,6 +381,57 @@ sub cx18 {
381 $allfiles; 381 $allfiles;
382} 382}
383 383
384sub mpc718 {
385 my $archive = 'Yuan MPC718 TV Tuner Card 2.13.10.1016.zip';
386 my $url = "ftp://ftp.work.acer-euro.com/desktop/aspire_idea510/vista/Drivers/$archive";
387 my $fwfile = "dvb-cx18-mpc718-mt352.fw";
388 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
389
390 checkstandard();
391 wgetfile($archive, $url);
392 unzip($archive, $tmpdir);
393
394 my $sourcefile = "$tmpdir/Yuan MPC718 TV Tuner Card 2.13.10.1016/mpc718_32bit/yuanrap.sys";
395 my $found = 0;
396
397 open IN, '<', $sourcefile or die "Couldn't open $sourcefile to extract $fwfile data\n";
398 binmode IN;
399 open OUT, '>', $fwfile;
400 binmode OUT;
401 {
402 # Block scope because we change the line terminator variable $/
403 my $prevlen = 0;
404 my $currlen;
405
406 # Buried in the data segment are 3 runs of almost identical
407 # register-value pairs that end in 0x5d 0x01 which is a "TUNER GO"
408 # command for the MT352.
409 # Pull out the middle run (because it's easy) of register-value
410 # pairs to make the "firmware" file.
411
412 local $/ = "\x5d\x01"; # MT352 "TUNER GO"
413
414 while (<IN>) {
415 $currlen = length($_);
416 if ($prevlen == $currlen && $currlen <= 64) {
417 chop; chop; # Get rid of "TUNER GO"
418 s/^\0\0//; # get rid of leading 00 00 if it's there
419 printf OUT "$_";
420 $found = 1;
421 last;
422 }
423 $prevlen = $currlen;
424 }
425 }
426 close OUT;
427 close IN;
428 if (!$found) {
429 unlink $fwfile;
430 die "Couldn't find valid register-value sequence in $sourcefile for $fwfile\n";
431 }
432 $fwfile;
433}
434
384sub cx23885 { 435sub cx23885 {
385 my $url = "http://linuxtv.org/downloads/firmware/"; 436 my $url = "http://linuxtv.org/downloads/firmware/";
386 437
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index f8cd450be9aa..09e031c55887 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -458,3 +458,13 @@ Why: Remove the old legacy 32bit machine check code. This has been
458 but the old version has been kept around for easier testing. Note this 458 but the old version has been kept around for easier testing. Note this
459 doesn't impact the old P5 and WinChip machine check handlers. 459 doesn't impact the old P5 and WinChip machine check handlers.
460Who: Andi Kleen <andi@firstfloor.org> 460Who: Andi Kleen <andi@firstfloor.org>
461
462----------------------------
463
464What: lock_policy_rwsem_* and unlock_policy_rwsem_* will not be
465 exported interface anymore.
466When: 2.6.33
467Why: cpu_policy_rwsem has a new cleaner definition making it local to
468 cpufreq core and contained inside cpufreq.c. Other dependent
469 drivers should not use it in order to safely avoid lockdep issues.
470Who: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
diff --git a/Documentation/gcov.txt b/Documentation/gcov.txt
index e716aadb3a33..40ec63352760 100644
--- a/Documentation/gcov.txt
+++ b/Documentation/gcov.txt
@@ -188,13 +188,18 @@ Solution: Exclude affected source files from profiling by specifying
188 GCOV_PROFILE := n or GCOV_PROFILE_basename.o := n in the 188 GCOV_PROFILE := n or GCOV_PROFILE_basename.o := n in the
189 corresponding Makefile. 189 corresponding Makefile.
190 190
191Problem: Files copied from sysfs appear empty or incomplete.
192Cause: Due to the way seq_file works, some tools such as cp or tar
193 may not correctly copy files from sysfs.
194Solution: Use 'cat' to read .gcda files and 'cp -d' to copy links.
195 Alternatively use the mechanism shown in Appendix B.
196
191 197
192Appendix A: gather_on_build.sh 198Appendix A: gather_on_build.sh
193============================== 199==============================
194 200
195Sample script to gather coverage meta files on the build machine 201Sample script to gather coverage meta files on the build machine
196(see 6a): 202(see 6a):
197
198#!/bin/bash 203#!/bin/bash
199 204
200KSRC=$1 205KSRC=$1
@@ -226,7 +231,7 @@ Appendix B: gather_on_test.sh
226Sample script to gather coverage data files on the test machine 231Sample script to gather coverage data files on the test machine
227(see 6b): 232(see 6b):
228 233
229#!/bin/bash 234#!/bin/bash -e
230 235
231DEST=$1 236DEST=$1
232GCDA=/sys/kernel/debug/gcov 237GCDA=/sys/kernel/debug/gcov
@@ -236,11 +241,13 @@ if [ -z "$DEST" ] ; then
236 exit 1 241 exit 1
237fi 242fi
238 243
239find $GCDA -name '*.gcno' -o -name '*.gcda' | tar cfz $DEST -T - 244TEMPDIR=$(mktemp -d)
245echo Collecting data..
246find $GCDA -type d -exec mkdir -p $TEMPDIR/\{\} \;
247find $GCDA -name '*.gcda' -exec sh -c 'cat < $0 > '$TEMPDIR'/$0' {} \;
248find $GCDA -name '*.gcno' -exec sh -c 'cp -d $0 '$TEMPDIR'/$0' {} \;
249tar czf $DEST -C $TEMPDIR sys
250rm -rf $TEMPDIR
240 251
241if [ $? -eq 0 ] ; then 252echo "$DEST successfully created, copy to build system and unpack with:"
242 echo "$DEST successfully created, copy to build system and unpack with:" 253echo " tar xfz $DEST"
243 echo " tar xfz $DEST"
244else
245 echo "Could not create file $DEST"
246fi
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index d08759aa0903..dd1a6d4bb747 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1720,8 +1720,8 @@ and is between 256 and 4096 characters. It is defined in the file
1720 oprofile.cpu_type= Force an oprofile cpu type 1720 oprofile.cpu_type= Force an oprofile cpu type
1721 This might be useful if you have an older oprofile 1721 This might be useful if you have an older oprofile
1722 userland or if you want common events. 1722 userland or if you want common events.
1723 Format: { archperfmon } 1723 Format: { arch_perfmon }
1724 archperfmon: [X86] Force use of architectural 1724 arch_perfmon: [X86] Force use of architectural
1725 perfmon on Intel CPUs instead of the 1725 perfmon on Intel CPUs instead of the
1726 CPU specific event set. 1726 CPU specific event set.
1727 1727
@@ -1915,6 +1915,12 @@ and is between 256 and 4096 characters. It is defined in the file
1915 Format: { 0 | 1 } 1915 Format: { 0 | 1 }
1916 See arch/parisc/kernel/pdc_chassis.c 1916 See arch/parisc/kernel/pdc_chassis.c
1917 1917
1918 percpu_alloc= [X86] Select which percpu first chunk allocator to use.
1919 Allowed values are one of "lpage", "embed" and "4k".
1920 See comments in arch/x86/kernel/setup_percpu.c for
1921 details on each allocator. This parameter is primarily
1922 for debugging and performance comparison.
1923
1918 pf. [PARIDE] 1924 pf. [PARIDE]
1919 See Documentation/blockdev/paride.txt. 1925 See Documentation/blockdev/paride.txt.
1920 1926
@@ -2467,7 +2473,8 @@ and is between 256 and 4096 characters. It is defined in the file
2467 2473
2468 tp720= [HW,PS2] 2474 tp720= [HW,PS2]
2469 2475
2470 trace_buf_size=nn[KMG] [ftrace] will set tracing buffer size. 2476 trace_buf_size=nn[KMG]
2477 [FTRACE] will set tracing buffer size.
2471 2478
2472 trix= [HW,OSS] MediaTrix AudioTrix Pro 2479 trix= [HW,OSS] MediaTrix AudioTrix Pro
2473 Format: 2480 Format:
diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt
index 0112da3b9ab8..89068030b01b 100644
--- a/Documentation/kmemleak.txt
+++ b/Documentation/kmemleak.txt
@@ -16,13 +16,17 @@ Usage
16----- 16-----
17 17
18CONFIG_DEBUG_KMEMLEAK in "Kernel hacking" has to be enabled. A kernel 18CONFIG_DEBUG_KMEMLEAK in "Kernel hacking" has to be enabled. A kernel
19thread scans the memory every 10 minutes (by default) and prints any new 19thread scans the memory every 10 minutes (by default) and prints the
20unreferenced objects found. To trigger an intermediate scan and display 20number of new unreferenced objects found. To display the details of all
21all the possible memory leaks: 21the possible memory leaks:
22 22
23 # mount -t debugfs nodev /sys/kernel/debug/ 23 # mount -t debugfs nodev /sys/kernel/debug/
24 # cat /sys/kernel/debug/kmemleak 24 # cat /sys/kernel/debug/kmemleak
25 25
26To trigger an intermediate memory scan:
27
28 # echo scan > /sys/kernel/debug/kmemleak
29
26Note that the orphan objects are listed in the order they were allocated 30Note that the orphan objects are listed in the order they were allocated
27and one object at the beginning of the list may cause other subsequent 31and one object at the beginning of the list may cause other subsequent
28objects to be reported as orphan. 32objects to be reported as orphan.
@@ -31,16 +35,21 @@ Memory scanning parameters can be modified at run-time by writing to the
31/sys/kernel/debug/kmemleak file. The following parameters are supported: 35/sys/kernel/debug/kmemleak file. The following parameters are supported:
32 36
33 off - disable kmemleak (irreversible) 37 off - disable kmemleak (irreversible)
34 stack=on - enable the task stacks scanning 38 stack=on - enable the task stacks scanning (default)
35 stack=off - disable the tasks stacks scanning 39 stack=off - disable the tasks stacks scanning
36 scan=on - start the automatic memory scanning thread 40 scan=on - start the automatic memory scanning thread (default)
37 scan=off - stop the automatic memory scanning thread 41 scan=off - stop the automatic memory scanning thread
38 scan=<secs> - set the automatic memory scanning period in seconds (0 42 scan=<secs> - set the automatic memory scanning period in seconds
39 to disable it) 43 (default 600, 0 to stop the automatic scanning)
44 scan - trigger a memory scan
40 45
41Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on 46Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on
42the kernel command line. 47the kernel command line.
43 48
49Memory may be allocated or freed before kmemleak is initialised and
50these actions are stored in an early log buffer. The size of this buffer
51is configured via the CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE option.
52
44Basic Algorithm 53Basic Algorithm
45--------------- 54---------------
46 55
diff --git a/Documentation/leds-lp3944.txt b/Documentation/leds-lp3944.txt
new file mode 100644
index 000000000000..c6eda18b15ef
--- /dev/null
+++ b/Documentation/leds-lp3944.txt
@@ -0,0 +1,50 @@
1Kernel driver lp3944
2====================
3
4 * National Semiconductor LP3944 Fun-light Chip
5 Prefix: 'lp3944'
6 Addresses scanned: None (see the Notes section below)
7 Datasheet: Publicly available at the National Semiconductor website
8 http://www.national.com/pf/LP/LP3944.html
9
10Authors:
11 Antonio Ospite <ospite@studenti.unina.it>
12
13
14Description
15-----------
16The LP3944 is a helper chip that can drive up to 8 leds, with two programmable
17DIM modes; it could even be used as a gpio expander but this driver assumes it
18is used as a led controller.
19
20The DIM modes are used to set _blink_ patterns for leds, the pattern is
21specified supplying two parameters:
22 - period: from 0s to 1.6s
23 - duty cycle: percentage of the period the led is on, from 0 to 100
24
25Setting a led in DIM0 or DIM1 mode makes it blink according to the pattern.
26See the datasheet for details.
27
28LP3944 can be found on Motorola A910 smartphone, where it drives the rgb
29leds, the camera flash light and the lcds power.
30
31
32Notes
33-----
34The chip is used mainly in embedded contexts, so this driver expects it is
35registered using the i2c_board_info mechanism.
36
37To register the chip at address 0x60 on adapter 0, set the platform data
38according to include/linux/leds-lp3944.h, set the i2c board info:
39
40 static struct i2c_board_info __initdata a910_i2c_board_info[] = {
41 {
42 I2C_BOARD_INFO("lp3944", 0x60),
43 .platform_data = &a910_lp3944_leds,
44 },
45 };
46
47and register it in the platform init function
48
49 i2c_register_board_info(0, a910_i2c_board_info,
50 ARRAY_SIZE(a910_i2c_board_info));
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index 8d999d862d0e..79f533f38c61 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1238,1122 +1238,7 @@ descriptions for the SOC devices for which new nodes have been
1238defined; this list will expand as more and more SOC-containing 1238defined; this list will expand as more and more SOC-containing
1239platforms are moved over to use the flattened-device-tree model. 1239platforms are moved over to use the flattened-device-tree model.
1240 1240
1241 a) PHY nodes 1241VII - Specifying interrupt information for devices
1242
1243 Required properties:
1244
1245 - device_type : Should be "ethernet-phy"
1246 - interrupts : <a b> where a is the interrupt number and b is a
1247 field that represents an encoding of the sense and level
1248 information for the interrupt. This should be encoded based on
1249 the information in section 2) depending on the type of interrupt
1250 controller you have.
1251 - interrupt-parent : the phandle for the interrupt controller that
1252 services interrupts for this device.
1253 - reg : The ID number for the phy, usually a small integer
1254 - linux,phandle : phandle for this node; likely referenced by an
1255 ethernet controller node.
1256
1257
1258 Example:
1259
1260 ethernet-phy@0 {
1261 linux,phandle = <2452000>
1262 interrupt-parent = <40000>;
1263 interrupts = <35 1>;
1264 reg = <0>;
1265 device_type = "ethernet-phy";
1266 };
1267
1268
1269 b) Interrupt controllers
1270
1271 Some SOC devices contain interrupt controllers that are different
1272 from the standard Open PIC specification. The SOC device nodes for
1273 these types of controllers should be specified just like a standard
1274 OpenPIC controller. Sense and level information should be encoded
1275 as specified in section 2) of this chapter for each device that
1276 specifies an interrupt.
1277
1278 Example :
1279
1280 pic@40000 {
1281 linux,phandle = <40000>;
1282 interrupt-controller;
1283 #address-cells = <0>;
1284 reg = <40000 40000>;
1285 compatible = "chrp,open-pic";
1286 device_type = "open-pic";
1287 };
1288
1289 c) 4xx/Axon EMAC ethernet nodes
1290
1291 The EMAC ethernet controller in IBM and AMCC 4xx chips, and also
1292 the Axon bridge. To operate this needs to interact with a ths
1293 special McMAL DMA controller, and sometimes an RGMII or ZMII
1294 interface. In addition to the nodes and properties described
1295 below, the node for the OPB bus on which the EMAC sits must have a
1296 correct clock-frequency property.
1297
1298 i) The EMAC node itself
1299
1300 Required properties:
1301 - device_type : "network"
1302
1303 - compatible : compatible list, contains 2 entries, first is
1304 "ibm,emac-CHIP" where CHIP is the host ASIC (440gx,
1305 405gp, Axon) and second is either "ibm,emac" or
1306 "ibm,emac4". For Axon, thus, we have: "ibm,emac-axon",
1307 "ibm,emac4"
1308 - interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ>
1309 - interrupt-parent : optional, if needed for interrupt mapping
1310 - reg : <registers mapping>
1311 - local-mac-address : 6 bytes, MAC address
1312 - mal-device : phandle of the associated McMAL node
1313 - mal-tx-channel : 1 cell, index of the tx channel on McMAL associated
1314 with this EMAC
1315 - mal-rx-channel : 1 cell, index of the rx channel on McMAL associated
1316 with this EMAC
1317 - cell-index : 1 cell, hardware index of the EMAC cell on a given
1318 ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on
1319 each Axon chip)
1320 - max-frame-size : 1 cell, maximum frame size supported in bytes
1321 - rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec
1322 operations.
1323 For Axon, 2048
1324 - tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec
1325 operations.
1326 For Axon, 2048.
1327 - fifo-entry-size : 1 cell, size of a fifo entry (used to calculate
1328 thresholds).
1329 For Axon, 0x00000010
1330 - mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds)
1331 in bytes.
1332 For Axon, 0x00000100 (I think ...)
1333 - phy-mode : string, mode of operations of the PHY interface.
1334 Supported values are: "mii", "rmii", "smii", "rgmii",
1335 "tbi", "gmii", rtbi", "sgmii".
1336 For Axon on CAB, it is "rgmii"
1337 - mdio-device : 1 cell, required iff using shared MDIO registers
1338 (440EP). phandle of the EMAC to use to drive the
1339 MDIO lines for the PHY used by this EMAC.
1340 - zmii-device : 1 cell, required iff connected to a ZMII. phandle of
1341 the ZMII device node
1342 - zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII
1343 channel or 0xffffffff if ZMII is only used for MDIO.
1344 - rgmii-device : 1 cell, required iff connected to an RGMII. phandle
1345 of the RGMII device node.
1346 For Axon: phandle of plb5/plb4/opb/rgmii
1347 - rgmii-channel : 1 cell, required iff connected to an RGMII. Which
1348 RGMII channel is used by this EMAC.
1349 Fox Axon: present, whatever value is appropriate for each
1350 EMAC, that is the content of the current (bogus) "phy-port"
1351 property.
1352
1353 Optional properties:
1354 - phy-address : 1 cell, optional, MDIO address of the PHY. If absent,
1355 a search is performed.
1356 - phy-map : 1 cell, optional, bitmap of addresses to probe the PHY
1357 for, used if phy-address is absent. bit 0x00000001 is
1358 MDIO address 0.
1359 For Axon it can be absent, though my current driver
1360 doesn't handle phy-address yet so for now, keep
1361 0x00ffffff in it.
1362 - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
1363 operations (if absent the value is the same as
1364 rx-fifo-size). For Axon, either absent or 2048.
1365 - tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec
1366 operations (if absent the value is the same as
1367 tx-fifo-size). For Axon, either absent or 2048.
1368 - tah-device : 1 cell, optional. If connected to a TAH engine for
1369 offload, phandle of the TAH device node.
1370 - tah-channel : 1 cell, optional. If appropriate, channel used on the
1371 TAH engine.
1372
1373 Example:
1374
1375 EMAC0: ethernet@40000800 {
1376 device_type = "network";
1377 compatible = "ibm,emac-440gp", "ibm,emac";
1378 interrupt-parent = <&UIC1>;
1379 interrupts = <1c 4 1d 4>;
1380 reg = <40000800 70>;
1381 local-mac-address = [00 04 AC E3 1B 1E];
1382 mal-device = <&MAL0>;
1383 mal-tx-channel = <0 1>;
1384 mal-rx-channel = <0>;
1385 cell-index = <0>;
1386 max-frame-size = <5dc>;
1387 rx-fifo-size = <1000>;
1388 tx-fifo-size = <800>;
1389 phy-mode = "rmii";
1390 phy-map = <00000001>;
1391 zmii-device = <&ZMII0>;
1392 zmii-channel = <0>;
1393 };
1394
1395 ii) McMAL node
1396
1397 Required properties:
1398 - device_type : "dma-controller"
1399 - compatible : compatible list, containing 2 entries, first is
1400 "ibm,mcmal-CHIP" where CHIP is the host ASIC (like
1401 emac) and the second is either "ibm,mcmal" or
1402 "ibm,mcmal2".
1403 For Axon, "ibm,mcmal-axon","ibm,mcmal2"
1404 - interrupts : <interrupt mapping for the MAL interrupts sources:
1405 5 sources: tx_eob, rx_eob, serr, txde, rxde>.
1406 For Axon: This is _different_ from the current
1407 firmware. We use the "delayed" interrupts for txeob
1408 and rxeob. Thus we end up with mapping those 5 MPIC
1409 interrupts, all level positive sensitive: 10, 11, 32,
1410 33, 34 (in decimal)
1411 - dcr-reg : < DCR registers range >
1412 - dcr-parent : if needed for dcr-reg
1413 - num-tx-chans : 1 cell, number of Tx channels
1414 - num-rx-chans : 1 cell, number of Rx channels
1415
1416 iii) ZMII node
1417
1418 Required properties:
1419 - compatible : compatible list, containing 2 entries, first is
1420 "ibm,zmii-CHIP" where CHIP is the host ASIC (like
1421 EMAC) and the second is "ibm,zmii".
1422 For Axon, there is no ZMII node.
1423 - reg : <registers mapping>
1424
1425 iv) RGMII node
1426
1427 Required properties:
1428 - compatible : compatible list, containing 2 entries, first is
1429 "ibm,rgmii-CHIP" where CHIP is the host ASIC (like
1430 EMAC) and the second is "ibm,rgmii".
1431 For Axon, "ibm,rgmii-axon","ibm,rgmii"
1432 - reg : <registers mapping>
1433 - revision : as provided by the RGMII new version register if
1434 available.
1435 For Axon: 0x0000012a
1436
1437 d) Xilinx IP cores
1438
1439 The Xilinx EDK toolchain ships with a set of IP cores (devices) for use
1440 in Xilinx Spartan and Virtex FPGAs. The devices cover the whole range
1441 of standard device types (network, serial, etc.) and miscellaneous
1442 devices (gpio, LCD, spi, etc). Also, since these devices are
1443 implemented within the fpga fabric every instance of the device can be
1444 synthesised with different options that change the behaviour.
1445
1446 Each IP-core has a set of parameters which the FPGA designer can use to
1447 control how the core is synthesized. Historically, the EDK tool would
1448 extract the device parameters relevant to device drivers and copy them
1449 into an 'xparameters.h' in the form of #define symbols. This tells the
1450 device drivers how the IP cores are configured, but it requres the kernel
1451 to be recompiled every time the FPGA bitstream is resynthesized.
1452
1453 The new approach is to export the parameters into the device tree and
1454 generate a new device tree each time the FPGA bitstream changes. The
1455 parameters which used to be exported as #defines will now become
1456 properties of the device node. In general, device nodes for IP-cores
1457 will take the following form:
1458
1459 (name): (generic-name)@(base-address) {
1460 compatible = "xlnx,(ip-core-name)-(HW_VER)"
1461 [, (list of compatible devices), ...];
1462 reg = <(baseaddr) (size)>;
1463 interrupt-parent = <&interrupt-controller-phandle>;
1464 interrupts = < ... >;
1465 xlnx,(parameter1) = "(string-value)";
1466 xlnx,(parameter2) = <(int-value)>;
1467 };
1468
1469 (generic-name): an open firmware-style name that describes the
1470 generic class of device. Preferably, this is one word, such
1471 as 'serial' or 'ethernet'.
1472 (ip-core-name): the name of the ip block (given after the BEGIN
1473 directive in system.mhs). Should be in lowercase
1474 and all underscores '_' converted to dashes '-'.
1475 (name): is derived from the "PARAMETER INSTANCE" value.
1476 (parameter#): C_* parameters from system.mhs. The C_ prefix is
1477 dropped from the parameter name, the name is converted
1478 to lowercase and all underscore '_' characters are
1479 converted to dashes '-'.
1480 (baseaddr): the baseaddr parameter value (often named C_BASEADDR).
1481 (HW_VER): from the HW_VER parameter.
1482 (size): the address range size (often C_HIGHADDR - C_BASEADDR + 1).
1483
1484 Typically, the compatible list will include the exact IP core version
1485 followed by an older IP core version which implements the same
1486 interface or any other device with the same interface.
1487
1488 'reg', 'interrupt-parent' and 'interrupts' are all optional properties.
1489
1490 For example, the following block from system.mhs:
1491
1492 BEGIN opb_uartlite
1493 PARAMETER INSTANCE = opb_uartlite_0
1494 PARAMETER HW_VER = 1.00.b
1495 PARAMETER C_BAUDRATE = 115200
1496 PARAMETER C_DATA_BITS = 8
1497 PARAMETER C_ODD_PARITY = 0
1498 PARAMETER C_USE_PARITY = 0
1499 PARAMETER C_CLK_FREQ = 50000000
1500 PARAMETER C_BASEADDR = 0xEC100000
1501 PARAMETER C_HIGHADDR = 0xEC10FFFF
1502 BUS_INTERFACE SOPB = opb_7
1503 PORT OPB_Clk = CLK_50MHz
1504 PORT Interrupt = opb_uartlite_0_Interrupt
1505 PORT RX = opb_uartlite_0_RX
1506 PORT TX = opb_uartlite_0_TX
1507 PORT OPB_Rst = sys_bus_reset_0
1508 END
1509
1510 becomes the following device tree node:
1511
1512 opb_uartlite_0: serial@ec100000 {
1513 device_type = "serial";
1514 compatible = "xlnx,opb-uartlite-1.00.b";
1515 reg = <ec100000 10000>;
1516 interrupt-parent = <&opb_intc_0>;
1517 interrupts = <1 0>; // got this from the opb_intc parameters
1518 current-speed = <d#115200>; // standard serial device prop
1519 clock-frequency = <d#50000000>; // standard serial device prop
1520 xlnx,data-bits = <8>;
1521 xlnx,odd-parity = <0>;
1522 xlnx,use-parity = <0>;
1523 };
1524
1525 Some IP cores actually implement 2 or more logical devices. In
1526 this case, the device should still describe the whole IP core with
1527 a single node and add a child node for each logical device. The
1528 ranges property can be used to translate from parent IP-core to the
1529 registers of each device. In addition, the parent node should be
1530 compatible with the bus type 'xlnx,compound', and should contain
1531 #address-cells and #size-cells, as with any other bus. (Note: this
1532 makes the assumption that both logical devices have the same bus
1533 binding. If this is not true, then separate nodes should be used
1534 for each logical device). The 'cell-index' property can be used to
1535 enumerate logical devices within an IP core. For example, the
1536 following is the system.mhs entry for the dual ps2 controller found
1537 on the ml403 reference design.
1538
1539 BEGIN opb_ps2_dual_ref
1540 PARAMETER INSTANCE = opb_ps2_dual_ref_0
1541 PARAMETER HW_VER = 1.00.a
1542 PARAMETER C_BASEADDR = 0xA9000000
1543 PARAMETER C_HIGHADDR = 0xA9001FFF
1544 BUS_INTERFACE SOPB = opb_v20_0
1545 PORT Sys_Intr1 = ps2_1_intr
1546 PORT Sys_Intr2 = ps2_2_intr
1547 PORT Clkin1 = ps2_clk_rx_1
1548 PORT Clkin2 = ps2_clk_rx_2
1549 PORT Clkpd1 = ps2_clk_tx_1
1550 PORT Clkpd2 = ps2_clk_tx_2
1551 PORT Rx1 = ps2_d_rx_1
1552 PORT Rx2 = ps2_d_rx_2
1553 PORT Txpd1 = ps2_d_tx_1
1554 PORT Txpd2 = ps2_d_tx_2
1555 END
1556
1557 It would result in the following device tree nodes:
1558
1559 opb_ps2_dual_ref_0: opb-ps2-dual-ref@a9000000 {
1560 #address-cells = <1>;
1561 #size-cells = <1>;
1562 compatible = "xlnx,compound";
1563 ranges = <0 a9000000 2000>;
1564 // If this device had extra parameters, then they would
1565 // go here.
1566 ps2@0 {
1567 compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
1568 reg = <0 40>;
1569 interrupt-parent = <&opb_intc_0>;
1570 interrupts = <3 0>;
1571 cell-index = <0>;
1572 };
1573 ps2@1000 {
1574 compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
1575 reg = <1000 40>;
1576 interrupt-parent = <&opb_intc_0>;
1577 interrupts = <3 0>;
1578 cell-index = <0>;
1579 };
1580 };
1581
1582 Also, the system.mhs file defines bus attachments from the processor
1583 to the devices. The device tree structure should reflect the bus
1584 attachments. Again an example; this system.mhs fragment:
1585
1586 BEGIN ppc405_virtex4
1587 PARAMETER INSTANCE = ppc405_0
1588 PARAMETER HW_VER = 1.01.a
1589 BUS_INTERFACE DPLB = plb_v34_0
1590 BUS_INTERFACE IPLB = plb_v34_0
1591 END
1592
1593 BEGIN opb_intc
1594 PARAMETER INSTANCE = opb_intc_0
1595 PARAMETER HW_VER = 1.00.c
1596 PARAMETER C_BASEADDR = 0xD1000FC0
1597 PARAMETER C_HIGHADDR = 0xD1000FDF
1598 BUS_INTERFACE SOPB = opb_v20_0
1599 END
1600
1601 BEGIN opb_uart16550
1602 PARAMETER INSTANCE = opb_uart16550_0
1603 PARAMETER HW_VER = 1.00.d
1604 PARAMETER C_BASEADDR = 0xa0000000
1605 PARAMETER C_HIGHADDR = 0xa0001FFF
1606 BUS_INTERFACE SOPB = opb_v20_0
1607 END
1608
1609 BEGIN plb_v34
1610 PARAMETER INSTANCE = plb_v34_0
1611 PARAMETER HW_VER = 1.02.a
1612 END
1613
1614 BEGIN plb_bram_if_cntlr
1615 PARAMETER INSTANCE = plb_bram_if_cntlr_0
1616 PARAMETER HW_VER = 1.00.b
1617 PARAMETER C_BASEADDR = 0xFFFF0000
1618 PARAMETER C_HIGHADDR = 0xFFFFFFFF
1619 BUS_INTERFACE SPLB = plb_v34_0
1620 END
1621
1622 BEGIN plb2opb_bridge
1623 PARAMETER INSTANCE = plb2opb_bridge_0
1624 PARAMETER HW_VER = 1.01.a
1625 PARAMETER C_RNG0_BASEADDR = 0x20000000
1626 PARAMETER C_RNG0_HIGHADDR = 0x3FFFFFFF
1627 PARAMETER C_RNG1_BASEADDR = 0x60000000
1628 PARAMETER C_RNG1_HIGHADDR = 0x7FFFFFFF
1629 PARAMETER C_RNG2_BASEADDR = 0x80000000
1630 PARAMETER C_RNG2_HIGHADDR = 0xBFFFFFFF
1631 PARAMETER C_RNG3_BASEADDR = 0xC0000000
1632 PARAMETER C_RNG3_HIGHADDR = 0xDFFFFFFF
1633 BUS_INTERFACE SPLB = plb_v34_0
1634 BUS_INTERFACE MOPB = opb_v20_0
1635 END
1636
1637 Gives this device tree (some properties removed for clarity):
1638
1639 plb@0 {
1640 #address-cells = <1>;
1641 #size-cells = <1>;
1642 compatible = "xlnx,plb-v34-1.02.a";
1643 device_type = "ibm,plb";
1644 ranges; // 1:1 translation
1645
1646 plb_bram_if_cntrl_0: bram@ffff0000 {
1647 reg = <ffff0000 10000>;
1648 }
1649
1650 opb@20000000 {
1651 #address-cells = <1>;
1652 #size-cells = <1>;
1653 ranges = <20000000 20000000 20000000
1654 60000000 60000000 20000000
1655 80000000 80000000 40000000
1656 c0000000 c0000000 20000000>;
1657
1658 opb_uart16550_0: serial@a0000000 {
1659 reg = <a00000000 2000>;
1660 };
1661
1662 opb_intc_0: interrupt-controller@d1000fc0 {
1663 reg = <d1000fc0 20>;
1664 };
1665 };
1666 };
1667
1668 That covers the general approach to binding xilinx IP cores into the
1669 device tree. The following are bindings for specific devices:
1670
1671 i) Xilinx ML300 Framebuffer
1672
1673 Simple framebuffer device from the ML300 reference design (also on the
1674 ML403 reference design as well as others).
1675
1676 Optional properties:
1677 - resolution = <xres yres> : pixel resolution of framebuffer. Some
1678 implementations use a different resolution.
1679 Default is <d#640 d#480>
1680 - virt-resolution = <xvirt yvirt> : Size of framebuffer in memory.
1681 Default is <d#1024 d#480>.
1682 - rotate-display (empty) : rotate display 180 degrees.
1683
1684 ii) Xilinx SystemACE
1685
1686 The Xilinx SystemACE device is used to program FPGAs from an FPGA
1687 bitstream stored on a CF card. It can also be used as a generic CF
1688 interface device.
1689
1690 Optional properties:
1691 - 8-bit (empty) : Set this property for SystemACE in 8 bit mode
1692
1693 iii) Xilinx EMAC and Xilinx TEMAC
1694
1695 Xilinx Ethernet devices. In addition to general xilinx properties
1696 listed above, nodes for these devices should include a phy-handle
1697 property, and may include other common network device properties
1698 like local-mac-address.
1699
1700 iv) Xilinx Uartlite
1701
1702 Xilinx uartlite devices are simple fixed speed serial ports.
1703
1704 Required properties:
1705 - current-speed : Baud rate of uartlite
1706
1707 v) Xilinx hwicap
1708
1709 Xilinx hwicap devices provide access to the configuration logic
1710 of the FPGA through the Internal Configuration Access Port
1711 (ICAP). The ICAP enables partial reconfiguration of the FPGA,
1712 readback of the configuration information, and some control over
1713 'warm boots' of the FPGA fabric.
1714
1715 Required properties:
1716 - xlnx,family : The family of the FPGA, necessary since the
1717 capabilities of the underlying ICAP hardware
1718 differ between different families. May be
1719 'virtex2p', 'virtex4', or 'virtex5'.
1720
1721 vi) Xilinx Uart 16550
1722
1723 Xilinx UART 16550 devices are very similar to the NS16550 but with
1724 different register spacing and an offset from the base address.
1725
1726 Required properties:
1727 - clock-frequency : Frequency of the clock input
1728 - reg-offset : A value of 3 is required
1729 - reg-shift : A value of 2 is required
1730
1731 e) USB EHCI controllers
1732
1733 Required properties:
1734 - compatible : should be "usb-ehci".
1735 - reg : should contain at least address and length of the standard EHCI
1736 register set for the device. Optional platform-dependent registers
1737 (debug-port or other) can be also specified here, but only after
1738 definition of standard EHCI registers.
1739 - interrupts : one EHCI interrupt should be described here.
1740 If device registers are implemented in big endian mode, the device
1741 node should have "big-endian-regs" property.
1742 If controller implementation operates with big endian descriptors,
1743 "big-endian-desc" property should be specified.
1744 If both big endian registers and descriptors are used by the controller
1745 implementation, "big-endian" property can be specified instead of having
1746 both "big-endian-regs" and "big-endian-desc".
1747
1748 Example (Sequoia 440EPx):
1749 ehci@e0000300 {
1750 compatible = "ibm,usb-ehci-440epx", "usb-ehci";
1751 interrupt-parent = <&UIC0>;
1752 interrupts = <1a 4>;
1753 reg = <0 e0000300 90 0 e0000390 70>;
1754 big-endian;
1755 };
1756
1757 f) MDIO on GPIOs
1758
1759 Currently defined compatibles:
1760 - virtual,gpio-mdio
1761
1762 MDC and MDIO lines connected to GPIO controllers are listed in the
1763 gpios property as described in section VIII.1 in the following order:
1764
1765 MDC, MDIO.
1766
1767 Example:
1768
1769 mdio {
1770 compatible = "virtual,mdio-gpio";
1771 #address-cells = <1>;
1772 #size-cells = <0>;
1773 gpios = <&qe_pio_a 11
1774 &qe_pio_c 6>;
1775 };
1776
1777 g) SPI (Serial Peripheral Interface) busses
1778
1779 SPI busses can be described with a node for the SPI master device
1780 and a set of child nodes for each SPI slave on the bus. For this
1781 discussion, it is assumed that the system's SPI controller is in
1782 SPI master mode. This binding does not describe SPI controllers
1783 in slave mode.
1784
1785 The SPI master node requires the following properties:
1786 - #address-cells - number of cells required to define a chip select
1787 address on the SPI bus.
1788 - #size-cells - should be zero.
1789 - compatible - name of SPI bus controller following generic names
1790 recommended practice.
1791 No other properties are required in the SPI bus node. It is assumed
1792 that a driver for an SPI bus device will understand that it is an SPI bus.
1793 However, the binding does not attempt to define the specific method for
1794 assigning chip select numbers. Since SPI chip select configuration is
1795 flexible and non-standardized, it is left out of this binding with the
1796 assumption that board specific platform code will be used to manage
1797 chip selects. Individual drivers can define additional properties to
1798 support describing the chip select layout.
1799
1800 SPI slave nodes must be children of the SPI master node and can
1801 contain the following properties.
1802 - reg - (required) chip select address of device.
1803 - compatible - (required) name of SPI device following generic names
1804 recommended practice
1805 - spi-max-frequency - (required) Maximum SPI clocking speed of device in Hz
1806 - spi-cpol - (optional) Empty property indicating device requires
1807 inverse clock polarity (CPOL) mode
1808 - spi-cpha - (optional) Empty property indicating device requires
1809 shifted clock phase (CPHA) mode
1810 - spi-cs-high - (optional) Empty property indicating device requires
1811 chip select active high
1812
1813 SPI example for an MPC5200 SPI bus:
1814 spi@f00 {
1815 #address-cells = <1>;
1816 #size-cells = <0>;
1817 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
1818 reg = <0xf00 0x20>;
1819 interrupts = <2 13 0 2 14 0>;
1820 interrupt-parent = <&mpc5200_pic>;
1821
1822 ethernet-switch@0 {
1823 compatible = "micrel,ks8995m";
1824 spi-max-frequency = <1000000>;
1825 reg = <0>;
1826 };
1827
1828 codec@1 {
1829 compatible = "ti,tlv320aic26";
1830 spi-max-frequency = <100000>;
1831 reg = <1>;
1832 };
1833 };
1834
1835VII - Marvell Discovery mv64[345]6x System Controller chips
1836===========================================================
1837
1838The Marvell mv64[345]60 series of system controller chips contain
1839many of the peripherals needed to implement a complete computer
1840system. In this section, we define device tree nodes to describe
1841the system controller chip itself and each of the peripherals
1842which it contains. Compatible string values for each node are
1843prefixed with the string "marvell,", for Marvell Technology Group Ltd.
1844
18451) The /system-controller node
1846
1847 This node is used to represent the system-controller and must be
1848 present when the system uses a system controller chip. The top-level
1849 system-controller node contains information that is global to all
1850 devices within the system controller chip. The node name begins
1851 with "system-controller" followed by the unit address, which is
1852 the base address of the memory-mapped register set for the system
1853 controller chip.
1854
1855 Required properties:
1856
1857 - ranges : Describes the translation of system controller addresses
1858 for memory mapped registers.
1859 - clock-frequency: Contains the main clock frequency for the system
1860 controller chip.
1861 - reg : This property defines the address and size of the
1862 memory-mapped registers contained within the system controller
1863 chip. The address specified in the "reg" property should match
1864 the unit address of the system-controller node.
1865 - #address-cells : Address representation for system controller
1866 devices. This field represents the number of cells needed to
1867 represent the address of the memory-mapped registers of devices
1868 within the system controller chip.
1869 - #size-cells : Size representation for for the memory-mapped
1870 registers within the system controller chip.
1871 - #interrupt-cells : Defines the width of cells used to represent
1872 interrupts.
1873
1874 Optional properties:
1875
1876 - model : The specific model of the system controller chip. Such
1877 as, "mv64360", "mv64460", or "mv64560".
1878 - compatible : A string identifying the compatibility identifiers
1879 of the system controller chip.
1880
1881 The system-controller node contains child nodes for each system
1882 controller device that the platform uses. Nodes should not be created
1883 for devices which exist on the system controller chip but are not used
1884
1885 Example Marvell Discovery mv64360 system-controller node:
1886
1887 system-controller@f1000000 { /* Marvell Discovery mv64360 */
1888 #address-cells = <1>;
1889 #size-cells = <1>;
1890 model = "mv64360"; /* Default */
1891 compatible = "marvell,mv64360";
1892 clock-frequency = <133333333>;
1893 reg = <0xf1000000 0x10000>;
1894 virtual-reg = <0xf1000000>;
1895 ranges = <0x88000000 0x88000000 0x1000000 /* PCI 0 I/O Space */
1896 0x80000000 0x80000000 0x8000000 /* PCI 0 MEM Space */
1897 0xa0000000 0xa0000000 0x4000000 /* User FLASH */
1898 0x00000000 0xf1000000 0x0010000 /* Bridge's regs */
1899 0xf2000000 0xf2000000 0x0040000>;/* Integrated SRAM */
1900
1901 [ child node definitions... ]
1902 }
1903
19042) Child nodes of /system-controller
1905
1906 a) Marvell Discovery MDIO bus
1907
1908 The MDIO is a bus to which the PHY devices are connected. For each
1909 device that exists on this bus, a child node should be created. See
1910 the definition of the PHY node below for an example of how to define
1911 a PHY.
1912
1913 Required properties:
1914 - #address-cells : Should be <1>
1915 - #size-cells : Should be <0>
1916 - device_type : Should be "mdio"
1917 - compatible : Should be "marvell,mv64360-mdio"
1918
1919 Example:
1920
1921 mdio {
1922 #address-cells = <1>;
1923 #size-cells = <0>;
1924 device_type = "mdio";
1925 compatible = "marvell,mv64360-mdio";
1926
1927 ethernet-phy@0 {
1928 ......
1929 };
1930 };
1931
1932
1933 b) Marvell Discovery ethernet controller
1934
1935 The Discover ethernet controller is described with two levels
1936 of nodes. The first level describes an ethernet silicon block
1937 and the second level describes up to 3 ethernet nodes within
1938 that block. The reason for the multiple levels is that the
1939 registers for the node are interleaved within a single set
1940 of registers. The "ethernet-block" level describes the
1941 shared register set, and the "ethernet" nodes describe ethernet
1942 port-specific properties.
1943
1944 Ethernet block node
1945
1946 Required properties:
1947 - #address-cells : <1>
1948 - #size-cells : <0>
1949 - compatible : "marvell,mv64360-eth-block"
1950 - reg : Offset and length of the register set for this block
1951
1952 Example Discovery Ethernet block node:
1953 ethernet-block@2000 {
1954 #address-cells = <1>;
1955 #size-cells = <0>;
1956 compatible = "marvell,mv64360-eth-block";
1957 reg = <0x2000 0x2000>;
1958 ethernet@0 {
1959 .......
1960 };
1961 };
1962
1963 Ethernet port node
1964
1965 Required properties:
1966 - device_type : Should be "network".
1967 - compatible : Should be "marvell,mv64360-eth".
1968 - reg : Should be <0>, <1>, or <2>, according to which registers
1969 within the silicon block the device uses.
1970 - interrupts : <a> where a is the interrupt number for the port.
1971 - interrupt-parent : the phandle for the interrupt controller
1972 that services interrupts for this device.
1973 - phy : the phandle for the PHY connected to this ethernet
1974 controller.
1975 - local-mac-address : 6 bytes, MAC address
1976
1977 Example Discovery Ethernet port node:
1978 ethernet@0 {
1979 device_type = "network";
1980 compatible = "marvell,mv64360-eth";
1981 reg = <0>;
1982 interrupts = <32>;
1983 interrupt-parent = <&PIC>;
1984 phy = <&PHY0>;
1985 local-mac-address = [ 00 00 00 00 00 00 ];
1986 };
1987
1988
1989
1990 c) Marvell Discovery PHY nodes
1991
1992 Required properties:
1993 - device_type : Should be "ethernet-phy"
1994 - interrupts : <a> where a is the interrupt number for this phy.
1995 - interrupt-parent : the phandle for the interrupt controller that
1996 services interrupts for this device.
1997 - reg : The ID number for the phy, usually a small integer
1998
1999 Example Discovery PHY node:
2000 ethernet-phy@1 {
2001 device_type = "ethernet-phy";
2002 compatible = "broadcom,bcm5421";
2003 interrupts = <76>; /* GPP 12 */
2004 interrupt-parent = <&PIC>;
2005 reg = <1>;
2006 };
2007
2008
2009 d) Marvell Discovery SDMA nodes
2010
2011 Represent DMA hardware associated with the MPSC (multiprotocol
2012 serial controllers).
2013
2014 Required properties:
2015 - compatible : "marvell,mv64360-sdma"
2016 - reg : Offset and length of the register set for this device
2017 - interrupts : <a> where a is the interrupt number for the DMA
2018 device.
2019 - interrupt-parent : the phandle for the interrupt controller
2020 that services interrupts for this device.
2021
2022 Example Discovery SDMA node:
2023 sdma@4000 {
2024 compatible = "marvell,mv64360-sdma";
2025 reg = <0x4000 0xc18>;
2026 virtual-reg = <0xf1004000>;
2027 interrupts = <36>;
2028 interrupt-parent = <&PIC>;
2029 };
2030
2031
2032 e) Marvell Discovery BRG nodes
2033
2034 Represent baud rate generator hardware associated with the MPSC
2035 (multiprotocol serial controllers).
2036
2037 Required properties:
2038 - compatible : "marvell,mv64360-brg"
2039 - reg : Offset and length of the register set for this device
2040 - clock-src : A value from 0 to 15 which selects the clock
2041 source for the baud rate generator. This value corresponds
2042 to the CLKS value in the BRGx configuration register. See
2043 the mv64x60 User's Manual.
2044 - clock-frequence : The frequency (in Hz) of the baud rate
2045 generator's input clock.
2046 - current-speed : The current speed setting (presumably by
2047 firmware) of the baud rate generator.
2048
2049 Example Discovery BRG node:
2050 brg@b200 {
2051 compatible = "marvell,mv64360-brg";
2052 reg = <0xb200 0x8>;
2053 clock-src = <8>;
2054 clock-frequency = <133333333>;
2055 current-speed = <9600>;
2056 };
2057
2058
2059 f) Marvell Discovery CUNIT nodes
2060
2061 Represent the Serial Communications Unit device hardware.
2062
2063 Required properties:
2064 - reg : Offset and length of the register set for this device
2065
2066 Example Discovery CUNIT node:
2067 cunit@f200 {
2068 reg = <0xf200 0x200>;
2069 };
2070
2071
2072 g) Marvell Discovery MPSCROUTING nodes
2073
2074 Represent the Discovery's MPSC routing hardware
2075
2076 Required properties:
2077 - reg : Offset and length of the register set for this device
2078
2079 Example Discovery CUNIT node:
2080 mpscrouting@b500 {
2081 reg = <0xb400 0xc>;
2082 };
2083
2084
2085 h) Marvell Discovery MPSCINTR nodes
2086
2087 Represent the Discovery's MPSC DMA interrupt hardware registers
2088 (SDMA cause and mask registers).
2089
2090 Required properties:
2091 - reg : Offset and length of the register set for this device
2092
2093 Example Discovery MPSCINTR node:
2094 mpsintr@b800 {
2095 reg = <0xb800 0x100>;
2096 };
2097
2098
2099 i) Marvell Discovery MPSC nodes
2100
2101 Represent the Discovery's MPSC (Multiprotocol Serial Controller)
2102 serial port.
2103
2104 Required properties:
2105 - device_type : "serial"
2106 - compatible : "marvell,mv64360-mpsc"
2107 - reg : Offset and length of the register set for this device
2108 - sdma : the phandle for the SDMA node used by this port
2109 - brg : the phandle for the BRG node used by this port
2110 - cunit : the phandle for the CUNIT node used by this port
2111 - mpscrouting : the phandle for the MPSCROUTING node used by this port
2112 - mpscintr : the phandle for the MPSCINTR node used by this port
2113 - cell-index : the hardware index of this cell in the MPSC core
2114 - max_idle : value needed for MPSC CHR3 (Maximum Frame Length)
2115 register
2116 - interrupts : <a> where a is the interrupt number for the MPSC.
2117 - interrupt-parent : the phandle for the interrupt controller
2118 that services interrupts for this device.
2119
2120 Example Discovery MPSCINTR node:
2121 mpsc@8000 {
2122 device_type = "serial";
2123 compatible = "marvell,mv64360-mpsc";
2124 reg = <0x8000 0x38>;
2125 virtual-reg = <0xf1008000>;
2126 sdma = <&SDMA0>;
2127 brg = <&BRG0>;
2128 cunit = <&CUNIT>;
2129 mpscrouting = <&MPSCROUTING>;
2130 mpscintr = <&MPSCINTR>;
2131 cell-index = <0>;
2132 max_idle = <40>;
2133 interrupts = <40>;
2134 interrupt-parent = <&PIC>;
2135 };
2136
2137
2138 j) Marvell Discovery Watch Dog Timer nodes
2139
2140 Represent the Discovery's watchdog timer hardware
2141
2142 Required properties:
2143 - compatible : "marvell,mv64360-wdt"
2144 - reg : Offset and length of the register set for this device
2145
2146 Example Discovery Watch Dog Timer node:
2147 wdt@b410 {
2148 compatible = "marvell,mv64360-wdt";
2149 reg = <0xb410 0x8>;
2150 };
2151
2152
2153 k) Marvell Discovery I2C nodes
2154
2155 Represent the Discovery's I2C hardware
2156
2157 Required properties:
2158 - device_type : "i2c"
2159 - compatible : "marvell,mv64360-i2c"
2160 - reg : Offset and length of the register set for this device
2161 - interrupts : <a> where a is the interrupt number for the I2C.
2162 - interrupt-parent : the phandle for the interrupt controller
2163 that services interrupts for this device.
2164
2165 Example Discovery I2C node:
2166 compatible = "marvell,mv64360-i2c";
2167 reg = <0xc000 0x20>;
2168 virtual-reg = <0xf100c000>;
2169 interrupts = <37>;
2170 interrupt-parent = <&PIC>;
2171 };
2172
2173
2174 l) Marvell Discovery PIC (Programmable Interrupt Controller) nodes
2175
2176 Represent the Discovery's PIC hardware
2177
2178 Required properties:
2179 - #interrupt-cells : <1>
2180 - #address-cells : <0>
2181 - compatible : "marvell,mv64360-pic"
2182 - reg : Offset and length of the register set for this device
2183 - interrupt-controller
2184
2185 Example Discovery PIC node:
2186 pic {
2187 #interrupt-cells = <1>;
2188 #address-cells = <0>;
2189 compatible = "marvell,mv64360-pic";
2190 reg = <0x0 0x88>;
2191 interrupt-controller;
2192 };
2193
2194
2195 m) Marvell Discovery MPP (Multipurpose Pins) multiplexing nodes
2196
2197 Represent the Discovery's MPP hardware
2198
2199 Required properties:
2200 - compatible : "marvell,mv64360-mpp"
2201 - reg : Offset and length of the register set for this device
2202
2203 Example Discovery MPP node:
2204 mpp@f000 {
2205 compatible = "marvell,mv64360-mpp";
2206 reg = <0xf000 0x10>;
2207 };
2208
2209
2210 n) Marvell Discovery GPP (General Purpose Pins) nodes
2211
2212 Represent the Discovery's GPP hardware
2213
2214 Required properties:
2215 - compatible : "marvell,mv64360-gpp"
2216 - reg : Offset and length of the register set for this device
2217
2218 Example Discovery GPP node:
2219 gpp@f000 {
2220 compatible = "marvell,mv64360-gpp";
2221 reg = <0xf100 0x20>;
2222 };
2223
2224
2225 o) Marvell Discovery PCI host bridge node
2226
2227 Represents the Discovery's PCI host bridge device. The properties
2228 for this node conform to Rev 2.1 of the PCI Bus Binding to IEEE
2229 1275-1994. A typical value for the compatible property is
2230 "marvell,mv64360-pci".
2231
2232 Example Discovery PCI host bridge node
2233 pci@80000000 {
2234 #address-cells = <3>;
2235 #size-cells = <2>;
2236 #interrupt-cells = <1>;
2237 device_type = "pci";
2238 compatible = "marvell,mv64360-pci";
2239 reg = <0xcf8 0x8>;
2240 ranges = <0x01000000 0x0 0x0
2241 0x88000000 0x0 0x01000000
2242 0x02000000 0x0 0x80000000
2243 0x80000000 0x0 0x08000000>;
2244 bus-range = <0 255>;
2245 clock-frequency = <66000000>;
2246 interrupt-parent = <&PIC>;
2247 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
2248 interrupt-map = <
2249 /* IDSEL 0x0a */
2250 0x5000 0 0 1 &PIC 80
2251 0x5000 0 0 2 &PIC 81
2252 0x5000 0 0 3 &PIC 91
2253 0x5000 0 0 4 &PIC 93
2254
2255 /* IDSEL 0x0b */
2256 0x5800 0 0 1 &PIC 91
2257 0x5800 0 0 2 &PIC 93
2258 0x5800 0 0 3 &PIC 80
2259 0x5800 0 0 4 &PIC 81
2260
2261 /* IDSEL 0x0c */
2262 0x6000 0 0 1 &PIC 91
2263 0x6000 0 0 2 &PIC 93
2264 0x6000 0 0 3 &PIC 80
2265 0x6000 0 0 4 &PIC 81
2266
2267 /* IDSEL 0x0d */
2268 0x6800 0 0 1 &PIC 93
2269 0x6800 0 0 2 &PIC 80
2270 0x6800 0 0 3 &PIC 81
2271 0x6800 0 0 4 &PIC 91
2272 >;
2273 };
2274
2275
2276 p) Marvell Discovery CPU Error nodes
2277
2278 Represent the Discovery's CPU error handler device.
2279
2280 Required properties:
2281 - compatible : "marvell,mv64360-cpu-error"
2282 - reg : Offset and length of the register set for this device
2283 - interrupts : the interrupt number for this device
2284 - interrupt-parent : the phandle for the interrupt controller
2285 that services interrupts for this device.
2286
2287 Example Discovery CPU Error node:
2288 cpu-error@0070 {
2289 compatible = "marvell,mv64360-cpu-error";
2290 reg = <0x70 0x10 0x128 0x28>;
2291 interrupts = <3>;
2292 interrupt-parent = <&PIC>;
2293 };
2294
2295
2296 q) Marvell Discovery SRAM Controller nodes
2297
2298 Represent the Discovery's SRAM controller device.
2299
2300 Required properties:
2301 - compatible : "marvell,mv64360-sram-ctrl"
2302 - reg : Offset and length of the register set for this device
2303 - interrupts : the interrupt number for this device
2304 - interrupt-parent : the phandle for the interrupt controller
2305 that services interrupts for this device.
2306
2307 Example Discovery SRAM Controller node:
2308 sram-ctrl@0380 {
2309 compatible = "marvell,mv64360-sram-ctrl";
2310 reg = <0x380 0x80>;
2311 interrupts = <13>;
2312 interrupt-parent = <&PIC>;
2313 };
2314
2315
2316 r) Marvell Discovery PCI Error Handler nodes
2317
2318 Represent the Discovery's PCI error handler device.
2319
2320 Required properties:
2321 - compatible : "marvell,mv64360-pci-error"
2322 - reg : Offset and length of the register set for this device
2323 - interrupts : the interrupt number for this device
2324 - interrupt-parent : the phandle for the interrupt controller
2325 that services interrupts for this device.
2326
2327 Example Discovery PCI Error Handler node:
2328 pci-error@1d40 {
2329 compatible = "marvell,mv64360-pci-error";
2330 reg = <0x1d40 0x40 0xc28 0x4>;
2331 interrupts = <12>;
2332 interrupt-parent = <&PIC>;
2333 };
2334
2335
2336 s) Marvell Discovery Memory Controller nodes
2337
2338 Represent the Discovery's memory controller device.
2339
2340 Required properties:
2341 - compatible : "marvell,mv64360-mem-ctrl"
2342 - reg : Offset and length of the register set for this device
2343 - interrupts : the interrupt number for this device
2344 - interrupt-parent : the phandle for the interrupt controller
2345 that services interrupts for this device.
2346
2347 Example Discovery Memory Controller node:
2348 mem-ctrl@1400 {
2349 compatible = "marvell,mv64360-mem-ctrl";
2350 reg = <0x1400 0x60>;
2351 interrupts = <17>;
2352 interrupt-parent = <&PIC>;
2353 };
2354
2355
2356VIII - Specifying interrupt information for devices
2357=================================================== 1242===================================================
2358 1243
2359The device tree represents the busses and devices of a hardware 1244The device tree represents the busses and devices of a hardware
@@ -2439,56 +1324,7 @@ encodings listed below:
2439 2 = high to low edge sensitive type enabled 1324 2 = high to low edge sensitive type enabled
2440 3 = low to high edge sensitive type enabled 1325 3 = low to high edge sensitive type enabled
2441 1326
2442IX - Specifying GPIO information for devices 1327VIII - Specifying Device Power Management Information (sleep property)
2443============================================
2444
24451) gpios property
2446-----------------
2447
2448Nodes that makes use of GPIOs should define them using `gpios' property,
2449format of which is: <&gpio-controller1-phandle gpio1-specifier
2450 &gpio-controller2-phandle gpio2-specifier
2451 0 /* holes are permitted, means no GPIO 3 */
2452 &gpio-controller4-phandle gpio4-specifier
2453 ...>;
2454
2455Note that gpio-specifier length is controller dependent.
2456
2457gpio-specifier may encode: bank, pin position inside the bank,
2458whether pin is open-drain and whether pin is logically inverted.
2459
2460Example of the node using GPIOs:
2461
2462 node {
2463 gpios = <&qe_pio_e 18 0>;
2464 };
2465
2466In this example gpio-specifier is "18 0" and encodes GPIO pin number,
2467and empty GPIO flags as accepted by the "qe_pio_e" gpio-controller.
2468
24692) gpio-controller nodes
2470------------------------
2471
2472Every GPIO controller node must have #gpio-cells property defined,
2473this information will be used to translate gpio-specifiers.
2474
2475Example of two SOC GPIO banks defined as gpio-controller nodes:
2476
2477 qe_pio_a: gpio-controller@1400 {
2478 #gpio-cells = <2>;
2479 compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
2480 reg = <0x1400 0x18>;
2481 gpio-controller;
2482 };
2483
2484 qe_pio_e: gpio-controller@1460 {
2485 #gpio-cells = <2>;
2486 compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank";
2487 reg = <0x1460 0x18>;
2488 gpio-controller;
2489 };
2490
2491X - Specifying Device Power Management Information (sleep property)
2492=================================================================== 1328===================================================================
2493 1329
2494Devices on SOCs often have mechanisms for placing devices into low-power 1330Devices on SOCs often have mechanisms for placing devices into low-power
diff --git a/Documentation/powerpc/dts-bindings/4xx/emac.txt b/Documentation/powerpc/dts-bindings/4xx/emac.txt
new file mode 100644
index 000000000000..2161334a7ca5
--- /dev/null
+++ b/Documentation/powerpc/dts-bindings/4xx/emac.txt
@@ -0,0 +1,148 @@
1 4xx/Axon EMAC ethernet nodes
2
3 The EMAC ethernet controller in IBM and AMCC 4xx chips, and also
4 the Axon bridge. To operate this needs to interact with a ths
5 special McMAL DMA controller, and sometimes an RGMII or ZMII
6 interface. In addition to the nodes and properties described
7 below, the node for the OPB bus on which the EMAC sits must have a
8 correct clock-frequency property.
9
10 i) The EMAC node itself
11
12 Required properties:
13 - device_type : "network"
14
15 - compatible : compatible list, contains 2 entries, first is
16 "ibm,emac-CHIP" where CHIP is the host ASIC (440gx,
17 405gp, Axon) and second is either "ibm,emac" or
18 "ibm,emac4". For Axon, thus, we have: "ibm,emac-axon",
19 "ibm,emac4"
20 - interrupts : <interrupt mapping for EMAC IRQ and WOL IRQ>
21 - interrupt-parent : optional, if needed for interrupt mapping
22 - reg : <registers mapping>
23 - local-mac-address : 6 bytes, MAC address
24 - mal-device : phandle of the associated McMAL node
25 - mal-tx-channel : 1 cell, index of the tx channel on McMAL associated
26 with this EMAC
27 - mal-rx-channel : 1 cell, index of the rx channel on McMAL associated
28 with this EMAC
29 - cell-index : 1 cell, hardware index of the EMAC cell on a given
30 ASIC (typically 0x0 and 0x1 for EMAC0 and EMAC1 on
31 each Axon chip)
32 - max-frame-size : 1 cell, maximum frame size supported in bytes
33 - rx-fifo-size : 1 cell, Rx fifo size in bytes for 10 and 100 Mb/sec
34 operations.
35 For Axon, 2048
36 - tx-fifo-size : 1 cell, Tx fifo size in bytes for 10 and 100 Mb/sec
37 operations.
38 For Axon, 2048.
39 - fifo-entry-size : 1 cell, size of a fifo entry (used to calculate
40 thresholds).
41 For Axon, 0x00000010
42 - mal-burst-size : 1 cell, MAL burst size (used to calculate thresholds)
43 in bytes.
44 For Axon, 0x00000100 (I think ...)
45 - phy-mode : string, mode of operations of the PHY interface.
46 Supported values are: "mii", "rmii", "smii", "rgmii",
47 "tbi", "gmii", rtbi", "sgmii".
48 For Axon on CAB, it is "rgmii"
49 - mdio-device : 1 cell, required iff using shared MDIO registers
50 (440EP). phandle of the EMAC to use to drive the
51 MDIO lines for the PHY used by this EMAC.
52 - zmii-device : 1 cell, required iff connected to a ZMII. phandle of
53 the ZMII device node
54 - zmii-channel : 1 cell, required iff connected to a ZMII. Which ZMII
55 channel or 0xffffffff if ZMII is only used for MDIO.
56 - rgmii-device : 1 cell, required iff connected to an RGMII. phandle
57 of the RGMII device node.
58 For Axon: phandle of plb5/plb4/opb/rgmii
59 - rgmii-channel : 1 cell, required iff connected to an RGMII. Which
60 RGMII channel is used by this EMAC.
61 Fox Axon: present, whatever value is appropriate for each
62 EMAC, that is the content of the current (bogus) "phy-port"
63 property.
64
65 Optional properties:
66 - phy-address : 1 cell, optional, MDIO address of the PHY. If absent,
67 a search is performed.
68 - phy-map : 1 cell, optional, bitmap of addresses to probe the PHY
69 for, used if phy-address is absent. bit 0x00000001 is
70 MDIO address 0.
71 For Axon it can be absent, though my current driver
72 doesn't handle phy-address yet so for now, keep
73 0x00ffffff in it.
74 - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec
75 operations (if absent the value is the same as
76 rx-fifo-size). For Axon, either absent or 2048.
77 - tx-fifo-size-gige : 1 cell, Tx fifo size in bytes for 1000 Mb/sec
78 operations (if absent the value is the same as
79 tx-fifo-size). For Axon, either absent or 2048.
80 - tah-device : 1 cell, optional. If connected to a TAH engine for
81 offload, phandle of the TAH device node.
82 - tah-channel : 1 cell, optional. If appropriate, channel used on the
83 TAH engine.
84
85 Example:
86
87 EMAC0: ethernet@40000800 {
88 device_type = "network";
89 compatible = "ibm,emac-440gp", "ibm,emac";
90 interrupt-parent = <&UIC1>;
91 interrupts = <1c 4 1d 4>;
92 reg = <40000800 70>;
93 local-mac-address = [00 04 AC E3 1B 1E];
94 mal-device = <&MAL0>;
95 mal-tx-channel = <0 1>;
96 mal-rx-channel = <0>;
97 cell-index = <0>;
98 max-frame-size = <5dc>;
99 rx-fifo-size = <1000>;
100 tx-fifo-size = <800>;
101 phy-mode = "rmii";
102 phy-map = <00000001>;
103 zmii-device = <&ZMII0>;
104 zmii-channel = <0>;
105 };
106
107 ii) McMAL node
108
109 Required properties:
110 - device_type : "dma-controller"
111 - compatible : compatible list, containing 2 entries, first is
112 "ibm,mcmal-CHIP" where CHIP is the host ASIC (like
113 emac) and the second is either "ibm,mcmal" or
114 "ibm,mcmal2".
115 For Axon, "ibm,mcmal-axon","ibm,mcmal2"
116 - interrupts : <interrupt mapping for the MAL interrupts sources:
117 5 sources: tx_eob, rx_eob, serr, txde, rxde>.
118 For Axon: This is _different_ from the current
119 firmware. We use the "delayed" interrupts for txeob
120 and rxeob. Thus we end up with mapping those 5 MPIC
121 interrupts, all level positive sensitive: 10, 11, 32,
122 33, 34 (in decimal)
123 - dcr-reg : < DCR registers range >
124 - dcr-parent : if needed for dcr-reg
125 - num-tx-chans : 1 cell, number of Tx channels
126 - num-rx-chans : 1 cell, number of Rx channels
127
128 iii) ZMII node
129
130 Required properties:
131 - compatible : compatible list, containing 2 entries, first is
132 "ibm,zmii-CHIP" where CHIP is the host ASIC (like
133 EMAC) and the second is "ibm,zmii".
134 For Axon, there is no ZMII node.
135 - reg : <registers mapping>
136
137 iv) RGMII node
138
139 Required properties:
140 - compatible : compatible list, containing 2 entries, first is
141 "ibm,rgmii-CHIP" where CHIP is the host ASIC (like
142 EMAC) and the second is "ibm,rgmii".
143 For Axon, "ibm,rgmii-axon","ibm,rgmii"
144 - reg : <registers mapping>
145 - revision : as provided by the RGMII new version register if
146 available.
147 For Axon: 0x0000012a
148
diff --git a/Documentation/powerpc/dts-bindings/gpio/gpio.txt b/Documentation/powerpc/dts-bindings/gpio/gpio.txt
new file mode 100644
index 000000000000..edaa84d288a1
--- /dev/null
+++ b/Documentation/powerpc/dts-bindings/gpio/gpio.txt
@@ -0,0 +1,50 @@
1Specifying GPIO information for devices
2============================================
3
41) gpios property
5-----------------
6
7Nodes that makes use of GPIOs should define them using `gpios' property,
8format of which is: <&gpio-controller1-phandle gpio1-specifier
9 &gpio-controller2-phandle gpio2-specifier
10 0 /* holes are permitted, means no GPIO 3 */
11 &gpio-controller4-phandle gpio4-specifier
12 ...>;
13
14Note that gpio-specifier length is controller dependent.
15
16gpio-specifier may encode: bank, pin position inside the bank,
17whether pin is open-drain and whether pin is logically inverted.
18
19Example of the node using GPIOs:
20
21 node {
22 gpios = <&qe_pio_e 18 0>;
23 };
24
25In this example gpio-specifier is "18 0" and encodes GPIO pin number,
26and empty GPIO flags as accepted by the "qe_pio_e" gpio-controller.
27
282) gpio-controller nodes
29------------------------
30
31Every GPIO controller node must have #gpio-cells property defined,
32this information will be used to translate gpio-specifiers.
33
34Example of two SOC GPIO banks defined as gpio-controller nodes:
35
36 qe_pio_a: gpio-controller@1400 {
37 #gpio-cells = <2>;
38 compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
39 reg = <0x1400 0x18>;
40 gpio-controller;
41 };
42
43 qe_pio_e: gpio-controller@1460 {
44 #gpio-cells = <2>;
45 compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank";
46 reg = <0x1460 0x18>;
47 gpio-controller;
48 };
49
50
diff --git a/Documentation/powerpc/dts-bindings/gpio/led.txt b/Documentation/powerpc/dts-bindings/gpio/led.txt
index 4fe14deedc0a..064db928c3c1 100644
--- a/Documentation/powerpc/dts-bindings/gpio/led.txt
+++ b/Documentation/powerpc/dts-bindings/gpio/led.txt
@@ -16,10 +16,17 @@ LED sub-node properties:
16 string defining the trigger assigned to the LED. Current triggers are: 16 string defining the trigger assigned to the LED. Current triggers are:
17 "backlight" - LED will act as a back-light, controlled by the framebuffer 17 "backlight" - LED will act as a back-light, controlled by the framebuffer
18 system 18 system
19 "default-on" - LED will turn on 19 "default-on" - LED will turn on, but see "default-state" below
20 "heartbeat" - LED "double" flashes at a load average based rate 20 "heartbeat" - LED "double" flashes at a load average based rate
21 "ide-disk" - LED indicates disk activity 21 "ide-disk" - LED indicates disk activity
22 "timer" - LED flashes at a fixed, configurable rate 22 "timer" - LED flashes at a fixed, configurable rate
23- default-state: (optional) The initial state of the LED. Valid
24 values are "on", "off", and "keep". If the LED is already on or off
25 and the default-state property is set the to same value, then no
26 glitch should be produced where the LED momentarily turns off (or
27 on). The "keep" setting will keep the LED at whatever its current
28 state is, without producing a glitch. The default is off if this
29 property is not present.
23 30
24Examples: 31Examples:
25 32
@@ -30,14 +37,22 @@ leds {
30 gpios = <&mcu_pio 0 1>; /* Active low */ 37 gpios = <&mcu_pio 0 1>; /* Active low */
31 linux,default-trigger = "ide-disk"; 38 linux,default-trigger = "ide-disk";
32 }; 39 };
40
41 fault {
42 gpios = <&mcu_pio 1 0>;
43 /* Keep LED on if BIOS detected hardware fault */
44 default-state = "keep";
45 };
33}; 46};
34 47
35run-control { 48run-control {
36 compatible = "gpio-leds"; 49 compatible = "gpio-leds";
37 red { 50 red {
38 gpios = <&mpc8572 6 0>; 51 gpios = <&mpc8572 6 0>;
52 default-state = "off";
39 }; 53 };
40 green { 54 green {
41 gpios = <&mpc8572 7 0>; 55 gpios = <&mpc8572 7 0>;
56 default-state = "on";
42 }; 57 };
43} 58}
diff --git a/Documentation/powerpc/dts-bindings/gpio/mdio.txt b/Documentation/powerpc/dts-bindings/gpio/mdio.txt
new file mode 100644
index 000000000000..bc9549529014
--- /dev/null
+++ b/Documentation/powerpc/dts-bindings/gpio/mdio.txt
@@ -0,0 +1,19 @@
1MDIO on GPIOs
2
3Currently defined compatibles:
4- virtual,gpio-mdio
5
6MDC and MDIO lines connected to GPIO controllers are listed in the
7gpios property as described in section VIII.1 in the following order:
8
9MDC, MDIO.
10
11Example:
12
13mdio {
14 compatible = "virtual,mdio-gpio";
15 #address-cells = <1>;
16 #size-cells = <0>;
17 gpios = <&qe_pio_a 11
18 &qe_pio_c 6>;
19};
diff --git a/Documentation/powerpc/dts-bindings/marvell.txt b/Documentation/powerpc/dts-bindings/marvell.txt
new file mode 100644
index 000000000000..3708a2fd4747
--- /dev/null
+++ b/Documentation/powerpc/dts-bindings/marvell.txt
@@ -0,0 +1,521 @@
1Marvell Discovery mv64[345]6x System Controller chips
2===========================================================
3
4The Marvell mv64[345]60 series of system controller chips contain
5many of the peripherals needed to implement a complete computer
6system. In this section, we define device tree nodes to describe
7the system controller chip itself and each of the peripherals
8which it contains. Compatible string values for each node are
9prefixed with the string "marvell,", for Marvell Technology Group Ltd.
10
111) The /system-controller node
12
13 This node is used to represent the system-controller and must be
14 present when the system uses a system controller chip. The top-level
15 system-controller node contains information that is global to all
16 devices within the system controller chip. The node name begins
17 with "system-controller" followed by the unit address, which is
18 the base address of the memory-mapped register set for the system
19 controller chip.
20
21 Required properties:
22
23 - ranges : Describes the translation of system controller addresses
24 for memory mapped registers.
25 - clock-frequency: Contains the main clock frequency for the system
26 controller chip.
27 - reg : This property defines the address and size of the
28 memory-mapped registers contained within the system controller
29 chip. The address specified in the "reg" property should match
30 the unit address of the system-controller node.
31 - #address-cells : Address representation for system controller
32 devices. This field represents the number of cells needed to
33 represent the address of the memory-mapped registers of devices
34 within the system controller chip.
35 - #size-cells : Size representation for for the memory-mapped
36 registers within the system controller chip.
37 - #interrupt-cells : Defines the width of cells used to represent
38 interrupts.
39
40 Optional properties:
41
42 - model : The specific model of the system controller chip. Such
43 as, "mv64360", "mv64460", or "mv64560".
44 - compatible : A string identifying the compatibility identifiers
45 of the system controller chip.
46
47 The system-controller node contains child nodes for each system
48 controller device that the platform uses. Nodes should not be created
49 for devices which exist on the system controller chip but are not used
50
51 Example Marvell Discovery mv64360 system-controller node:
52
53 system-controller@f1000000 { /* Marvell Discovery mv64360 */
54 #address-cells = <1>;
55 #size-cells = <1>;
56 model = "mv64360"; /* Default */
57 compatible = "marvell,mv64360";
58 clock-frequency = <133333333>;
59 reg = <0xf1000000 0x10000>;
60 virtual-reg = <0xf1000000>;
61 ranges = <0x88000000 0x88000000 0x1000000 /* PCI 0 I/O Space */
62 0x80000000 0x80000000 0x8000000 /* PCI 0 MEM Space */
63 0xa0000000 0xa0000000 0x4000000 /* User FLASH */
64 0x00000000 0xf1000000 0x0010000 /* Bridge's regs */
65 0xf2000000 0xf2000000 0x0040000>;/* Integrated SRAM */
66
67 [ child node definitions... ]
68 }
69
702) Child nodes of /system-controller
71
72 a) Marvell Discovery MDIO bus
73
74 The MDIO is a bus to which the PHY devices are connected. For each
75 device that exists on this bus, a child node should be created. See
76 the definition of the PHY node below for an example of how to define
77 a PHY.
78
79 Required properties:
80 - #address-cells : Should be <1>
81 - #size-cells : Should be <0>
82 - device_type : Should be "mdio"
83 - compatible : Should be "marvell,mv64360-mdio"
84
85 Example:
86
87 mdio {
88 #address-cells = <1>;
89 #size-cells = <0>;
90 device_type = "mdio";
91 compatible = "marvell,mv64360-mdio";
92
93 ethernet-phy@0 {
94 ......
95 };
96 };
97
98
99 b) Marvell Discovery ethernet controller
100
101 The Discover ethernet controller is described with two levels
102 of nodes. The first level describes an ethernet silicon block
103 and the second level describes up to 3 ethernet nodes within
104 that block. The reason for the multiple levels is that the
105 registers for the node are interleaved within a single set
106 of registers. The "ethernet-block" level describes the
107 shared register set, and the "ethernet" nodes describe ethernet
108 port-specific properties.
109
110 Ethernet block node
111
112 Required properties:
113 - #address-cells : <1>
114 - #size-cells : <0>
115 - compatible : "marvell,mv64360-eth-block"
116 - reg : Offset and length of the register set for this block
117
118 Example Discovery Ethernet block node:
119 ethernet-block@2000 {
120 #address-cells = <1>;
121 #size-cells = <0>;
122 compatible = "marvell,mv64360-eth-block";
123 reg = <0x2000 0x2000>;
124 ethernet@0 {
125 .......
126 };
127 };
128
129 Ethernet port node
130
131 Required properties:
132 - device_type : Should be "network".
133 - compatible : Should be "marvell,mv64360-eth".
134 - reg : Should be <0>, <1>, or <2>, according to which registers
135 within the silicon block the device uses.
136 - interrupts : <a> where a is the interrupt number for the port.
137 - interrupt-parent : the phandle for the interrupt controller
138 that services interrupts for this device.
139 - phy : the phandle for the PHY connected to this ethernet
140 controller.
141 - local-mac-address : 6 bytes, MAC address
142
143 Example Discovery Ethernet port node:
144 ethernet@0 {
145 device_type = "network";
146 compatible = "marvell,mv64360-eth";
147 reg = <0>;
148 interrupts = <32>;
149 interrupt-parent = <&PIC>;
150 phy = <&PHY0>;
151 local-mac-address = [ 00 00 00 00 00 00 ];
152 };
153
154
155
156 c) Marvell Discovery PHY nodes
157
158 Required properties:
159 - device_type : Should be "ethernet-phy"
160 - interrupts : <a> where a is the interrupt number for this phy.
161 - interrupt-parent : the phandle for the interrupt controller that
162 services interrupts for this device.
163 - reg : The ID number for the phy, usually a small integer
164
165 Example Discovery PHY node:
166 ethernet-phy@1 {
167 device_type = "ethernet-phy";
168 compatible = "broadcom,bcm5421";
169 interrupts = <76>; /* GPP 12 */
170 interrupt-parent = <&PIC>;
171 reg = <1>;
172 };
173
174
175 d) Marvell Discovery SDMA nodes
176
177 Represent DMA hardware associated with the MPSC (multiprotocol
178 serial controllers).
179
180 Required properties:
181 - compatible : "marvell,mv64360-sdma"
182 - reg : Offset and length of the register set for this device
183 - interrupts : <a> where a is the interrupt number for the DMA
184 device.
185 - interrupt-parent : the phandle for the interrupt controller
186 that services interrupts for this device.
187
188 Example Discovery SDMA node:
189 sdma@4000 {
190 compatible = "marvell,mv64360-sdma";
191 reg = <0x4000 0xc18>;
192 virtual-reg = <0xf1004000>;
193 interrupts = <36>;
194 interrupt-parent = <&PIC>;
195 };
196
197
198 e) Marvell Discovery BRG nodes
199
200 Represent baud rate generator hardware associated with the MPSC
201 (multiprotocol serial controllers).
202
203 Required properties:
204 - compatible : "marvell,mv64360-brg"
205 - reg : Offset and length of the register set for this device
206 - clock-src : A value from 0 to 15 which selects the clock
207 source for the baud rate generator. This value corresponds
208 to the CLKS value in the BRGx configuration register. See
209 the mv64x60 User's Manual.
210 - clock-frequence : The frequency (in Hz) of the baud rate
211 generator's input clock.
212 - current-speed : The current speed setting (presumably by
213 firmware) of the baud rate generator.
214
215 Example Discovery BRG node:
216 brg@b200 {
217 compatible = "marvell,mv64360-brg";
218 reg = <0xb200 0x8>;
219 clock-src = <8>;
220 clock-frequency = <133333333>;
221 current-speed = <9600>;
222 };
223
224
225 f) Marvell Discovery CUNIT nodes
226
227 Represent the Serial Communications Unit device hardware.
228
229 Required properties:
230 - reg : Offset and length of the register set for this device
231
232 Example Discovery CUNIT node:
233 cunit@f200 {
234 reg = <0xf200 0x200>;
235 };
236
237
238 g) Marvell Discovery MPSCROUTING nodes
239
240 Represent the Discovery's MPSC routing hardware
241
242 Required properties:
243 - reg : Offset and length of the register set for this device
244
245 Example Discovery CUNIT node:
246 mpscrouting@b500 {
247 reg = <0xb400 0xc>;
248 };
249
250
251 h) Marvell Discovery MPSCINTR nodes
252
253 Represent the Discovery's MPSC DMA interrupt hardware registers
254 (SDMA cause and mask registers).
255
256 Required properties:
257 - reg : Offset and length of the register set for this device
258
259 Example Discovery MPSCINTR node:
260 mpsintr@b800 {
261 reg = <0xb800 0x100>;
262 };
263
264
265 i) Marvell Discovery MPSC nodes
266
267 Represent the Discovery's MPSC (Multiprotocol Serial Controller)
268 serial port.
269
270 Required properties:
271 - device_type : "serial"
272 - compatible : "marvell,mv64360-mpsc"
273 - reg : Offset and length of the register set for this device
274 - sdma : the phandle for the SDMA node used by this port
275 - brg : the phandle for the BRG node used by this port
276 - cunit : the phandle for the CUNIT node used by this port
277 - mpscrouting : the phandle for the MPSCROUTING node used by this port
278 - mpscintr : the phandle for the MPSCINTR node used by this port
279 - cell-index : the hardware index of this cell in the MPSC core
280 - max_idle : value needed for MPSC CHR3 (Maximum Frame Length)
281 register
282 - interrupts : <a> where a is the interrupt number for the MPSC.
283 - interrupt-parent : the phandle for the interrupt controller
284 that services interrupts for this device.
285
286 Example Discovery MPSCINTR node:
287 mpsc@8000 {
288 device_type = "serial";
289 compatible = "marvell,mv64360-mpsc";
290 reg = <0x8000 0x38>;
291 virtual-reg = <0xf1008000>;
292 sdma = <&SDMA0>;
293 brg = <&BRG0>;
294 cunit = <&CUNIT>;
295 mpscrouting = <&MPSCROUTING>;
296 mpscintr = <&MPSCINTR>;
297 cell-index = <0>;
298 max_idle = <40>;
299 interrupts = <40>;
300 interrupt-parent = <&PIC>;
301 };
302
303
304 j) Marvell Discovery Watch Dog Timer nodes
305
306 Represent the Discovery's watchdog timer hardware
307
308 Required properties:
309 - compatible : "marvell,mv64360-wdt"
310 - reg : Offset and length of the register set for this device
311
312 Example Discovery Watch Dog Timer node:
313 wdt@b410 {
314 compatible = "marvell,mv64360-wdt";
315 reg = <0xb410 0x8>;
316 };
317
318
319 k) Marvell Discovery I2C nodes
320
321 Represent the Discovery's I2C hardware
322
323 Required properties:
324 - device_type : "i2c"
325 - compatible : "marvell,mv64360-i2c"
326 - reg : Offset and length of the register set for this device
327 - interrupts : <a> where a is the interrupt number for the I2C.
328 - interrupt-parent : the phandle for the interrupt controller
329 that services interrupts for this device.
330
331 Example Discovery I2C node:
332 compatible = "marvell,mv64360-i2c";
333 reg = <0xc000 0x20>;
334 virtual-reg = <0xf100c000>;
335 interrupts = <37>;
336 interrupt-parent = <&PIC>;
337 };
338
339
340 l) Marvell Discovery PIC (Programmable Interrupt Controller) nodes
341
342 Represent the Discovery's PIC hardware
343
344 Required properties:
345 - #interrupt-cells : <1>
346 - #address-cells : <0>
347 - compatible : "marvell,mv64360-pic"
348 - reg : Offset and length of the register set for this device
349 - interrupt-controller
350
351 Example Discovery PIC node:
352 pic {
353 #interrupt-cells = <1>;
354 #address-cells = <0>;
355 compatible = "marvell,mv64360-pic";
356 reg = <0x0 0x88>;
357 interrupt-controller;
358 };
359
360
361 m) Marvell Discovery MPP (Multipurpose Pins) multiplexing nodes
362
363 Represent the Discovery's MPP hardware
364
365 Required properties:
366 - compatible : "marvell,mv64360-mpp"
367 - reg : Offset and length of the register set for this device
368
369 Example Discovery MPP node:
370 mpp@f000 {
371 compatible = "marvell,mv64360-mpp";
372 reg = <0xf000 0x10>;
373 };
374
375
376 n) Marvell Discovery GPP (General Purpose Pins) nodes
377
378 Represent the Discovery's GPP hardware
379
380 Required properties:
381 - compatible : "marvell,mv64360-gpp"
382 - reg : Offset and length of the register set for this device
383
384 Example Discovery GPP node:
385 gpp@f000 {
386 compatible = "marvell,mv64360-gpp";
387 reg = <0xf100 0x20>;
388 };
389
390
391 o) Marvell Discovery PCI host bridge node
392
393 Represents the Discovery's PCI host bridge device. The properties
394 for this node conform to Rev 2.1 of the PCI Bus Binding to IEEE
395 1275-1994. A typical value for the compatible property is
396 "marvell,mv64360-pci".
397
398 Example Discovery PCI host bridge node
399 pci@80000000 {
400 #address-cells = <3>;
401 #size-cells = <2>;
402 #interrupt-cells = <1>;
403 device_type = "pci";
404 compatible = "marvell,mv64360-pci";
405 reg = <0xcf8 0x8>;
406 ranges = <0x01000000 0x0 0x0
407 0x88000000 0x0 0x01000000
408 0x02000000 0x0 0x80000000
409 0x80000000 0x0 0x08000000>;
410 bus-range = <0 255>;
411 clock-frequency = <66000000>;
412 interrupt-parent = <&PIC>;
413 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
414 interrupt-map = <
415 /* IDSEL 0x0a */
416 0x5000 0 0 1 &PIC 80
417 0x5000 0 0 2 &PIC 81
418 0x5000 0 0 3 &PIC 91
419 0x5000 0 0 4 &PIC 93
420
421 /* IDSEL 0x0b */
422 0x5800 0 0 1 &PIC 91
423 0x5800 0 0 2 &PIC 93
424 0x5800 0 0 3 &PIC 80
425 0x5800 0 0 4 &PIC 81
426
427 /* IDSEL 0x0c */
428 0x6000 0 0 1 &PIC 91
429 0x6000 0 0 2 &PIC 93
430 0x6000 0 0 3 &PIC 80
431 0x6000 0 0 4 &PIC 81
432
433 /* IDSEL 0x0d */
434 0x6800 0 0 1 &PIC 93
435 0x6800 0 0 2 &PIC 80
436 0x6800 0 0 3 &PIC 81
437 0x6800 0 0 4 &PIC 91
438 >;
439 };
440
441
442 p) Marvell Discovery CPU Error nodes
443
444 Represent the Discovery's CPU error handler device.
445
446 Required properties:
447 - compatible : "marvell,mv64360-cpu-error"
448 - reg : Offset and length of the register set for this device
449 - interrupts : the interrupt number for this device
450 - interrupt-parent : the phandle for the interrupt controller
451 that services interrupts for this device.
452
453 Example Discovery CPU Error node:
454 cpu-error@0070 {
455 compatible = "marvell,mv64360-cpu-error";
456 reg = <0x70 0x10 0x128 0x28>;
457 interrupts = <3>;
458 interrupt-parent = <&PIC>;
459 };
460
461
462 q) Marvell Discovery SRAM Controller nodes
463
464 Represent the Discovery's SRAM controller device.
465
466 Required properties:
467 - compatible : "marvell,mv64360-sram-ctrl"
468 - reg : Offset and length of the register set for this device
469 - interrupts : the interrupt number for this device
470 - interrupt-parent : the phandle for the interrupt controller
471 that services interrupts for this device.
472
473 Example Discovery SRAM Controller node:
474 sram-ctrl@0380 {
475 compatible = "marvell,mv64360-sram-ctrl";
476 reg = <0x380 0x80>;
477 interrupts = <13>;
478 interrupt-parent = <&PIC>;
479 };
480
481
482 r) Marvell Discovery PCI Error Handler nodes
483
484 Represent the Discovery's PCI error handler device.
485
486 Required properties:
487 - compatible : "marvell,mv64360-pci-error"
488 - reg : Offset and length of the register set for this device
489 - interrupts : the interrupt number for this device
490 - interrupt-parent : the phandle for the interrupt controller
491 that services interrupts for this device.
492
493 Example Discovery PCI Error Handler node:
494 pci-error@1d40 {
495 compatible = "marvell,mv64360-pci-error";
496 reg = <0x1d40 0x40 0xc28 0x4>;
497 interrupts = <12>;
498 interrupt-parent = <&PIC>;
499 };
500
501
502 s) Marvell Discovery Memory Controller nodes
503
504 Represent the Discovery's memory controller device.
505
506 Required properties:
507 - compatible : "marvell,mv64360-mem-ctrl"
508 - reg : Offset and length of the register set for this device
509 - interrupts : the interrupt number for this device
510 - interrupt-parent : the phandle for the interrupt controller
511 that services interrupts for this device.
512
513 Example Discovery Memory Controller node:
514 mem-ctrl@1400 {
515 compatible = "marvell,mv64360-mem-ctrl";
516 reg = <0x1400 0x60>;
517 interrupts = <17>;
518 interrupt-parent = <&PIC>;
519 };
520
521
diff --git a/Documentation/powerpc/dts-bindings/phy.txt b/Documentation/powerpc/dts-bindings/phy.txt
new file mode 100644
index 000000000000..bb8c742eb8c5
--- /dev/null
+++ b/Documentation/powerpc/dts-bindings/phy.txt
@@ -0,0 +1,25 @@
1PHY nodes
2
3Required properties:
4
5 - device_type : Should be "ethernet-phy"
6 - interrupts : <a b> where a is the interrupt number and b is a
7 field that represents an encoding of the sense and level
8 information for the interrupt. This should be encoded based on
9 the information in section 2) depending on the type of interrupt
10 controller you have.
11 - interrupt-parent : the phandle for the interrupt controller that
12 services interrupts for this device.
13 - reg : The ID number for the phy, usually a small integer
14 - linux,phandle : phandle for this node; likely referenced by an
15 ethernet controller node.
16
17Example:
18
19ethernet-phy@0 {
20 linux,phandle = <2452000>
21 interrupt-parent = <40000>;
22 interrupts = <35 1>;
23 reg = <0>;
24 device_type = "ethernet-phy";
25};
diff --git a/Documentation/powerpc/dts-bindings/spi-bus.txt b/Documentation/powerpc/dts-bindings/spi-bus.txt
new file mode 100644
index 000000000000..e782add2e457
--- /dev/null
+++ b/Documentation/powerpc/dts-bindings/spi-bus.txt
@@ -0,0 +1,57 @@
1SPI (Serial Peripheral Interface) busses
2
3SPI busses can be described with a node for the SPI master device
4and a set of child nodes for each SPI slave on the bus. For this
5discussion, it is assumed that the system's SPI controller is in
6SPI master mode. This binding does not describe SPI controllers
7in slave mode.
8
9The SPI master node requires the following properties:
10- #address-cells - number of cells required to define a chip select
11 address on the SPI bus.
12- #size-cells - should be zero.
13- compatible - name of SPI bus controller following generic names
14 recommended practice.
15No other properties are required in the SPI bus node. It is assumed
16that a driver for an SPI bus device will understand that it is an SPI bus.
17However, the binding does not attempt to define the specific method for
18assigning chip select numbers. Since SPI chip select configuration is
19flexible and non-standardized, it is left out of this binding with the
20assumption that board specific platform code will be used to manage
21chip selects. Individual drivers can define additional properties to
22support describing the chip select layout.
23
24SPI slave nodes must be children of the SPI master node and can
25contain the following properties.
26- reg - (required) chip select address of device.
27- compatible - (required) name of SPI device following generic names
28 recommended practice
29- spi-max-frequency - (required) Maximum SPI clocking speed of device in Hz
30- spi-cpol - (optional) Empty property indicating device requires
31 inverse clock polarity (CPOL) mode
32- spi-cpha - (optional) Empty property indicating device requires
33 shifted clock phase (CPHA) mode
34- spi-cs-high - (optional) Empty property indicating device requires
35 chip select active high
36
37SPI example for an MPC5200 SPI bus:
38 spi@f00 {
39 #address-cells = <1>;
40 #size-cells = <0>;
41 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
42 reg = <0xf00 0x20>;
43 interrupts = <2 13 0 2 14 0>;
44 interrupt-parent = <&mpc5200_pic>;
45
46 ethernet-switch@0 {
47 compatible = "micrel,ks8995m";
48 spi-max-frequency = <1000000>;
49 reg = <0>;
50 };
51
52 codec@1 {
53 compatible = "ti,tlv320aic26";
54 spi-max-frequency = <100000>;
55 reg = <1>;
56 };
57 };
diff --git a/Documentation/powerpc/dts-bindings/usb-ehci.txt b/Documentation/powerpc/dts-bindings/usb-ehci.txt
new file mode 100644
index 000000000000..fa18612f757b
--- /dev/null
+++ b/Documentation/powerpc/dts-bindings/usb-ehci.txt
@@ -0,0 +1,25 @@
1USB EHCI controllers
2
3Required properties:
4 - compatible : should be "usb-ehci".
5 - reg : should contain at least address and length of the standard EHCI
6 register set for the device. Optional platform-dependent registers
7 (debug-port or other) can be also specified here, but only after
8 definition of standard EHCI registers.
9 - interrupts : one EHCI interrupt should be described here.
10If device registers are implemented in big endian mode, the device
11node should have "big-endian-regs" property.
12If controller implementation operates with big endian descriptors,
13"big-endian-desc" property should be specified.
14If both big endian registers and descriptors are used by the controller
15implementation, "big-endian" property can be specified instead of having
16both "big-endian-regs" and "big-endian-desc".
17
18Example (Sequoia 440EPx):
19 ehci@e0000300 {
20 compatible = "ibm,usb-ehci-440epx", "usb-ehci";
21 interrupt-parent = <&UIC0>;
22 interrupts = <1a 4>;
23 reg = <0 e0000300 90 0 e0000390 70>;
24 big-endian;
25 };
diff --git a/Documentation/powerpc/dts-bindings/xilinx.txt b/Documentation/powerpc/dts-bindings/xilinx.txt
new file mode 100644
index 000000000000..80339fe4300b
--- /dev/null
+++ b/Documentation/powerpc/dts-bindings/xilinx.txt
@@ -0,0 +1,295 @@
1 d) Xilinx IP cores
2
3 The Xilinx EDK toolchain ships with a set of IP cores (devices) for use
4 in Xilinx Spartan and Virtex FPGAs. The devices cover the whole range
5 of standard device types (network, serial, etc.) and miscellaneous
6 devices (gpio, LCD, spi, etc). Also, since these devices are
7 implemented within the fpga fabric every instance of the device can be
8 synthesised with different options that change the behaviour.
9
10 Each IP-core has a set of parameters which the FPGA designer can use to
11 control how the core is synthesized. Historically, the EDK tool would
12 extract the device parameters relevant to device drivers and copy them
13 into an 'xparameters.h' in the form of #define symbols. This tells the
14 device drivers how the IP cores are configured, but it requres the kernel
15 to be recompiled every time the FPGA bitstream is resynthesized.
16
17 The new approach is to export the parameters into the device tree and
18 generate a new device tree each time the FPGA bitstream changes. The
19 parameters which used to be exported as #defines will now become
20 properties of the device node. In general, device nodes for IP-cores
21 will take the following form:
22
23 (name): (generic-name)@(base-address) {
24 compatible = "xlnx,(ip-core-name)-(HW_VER)"
25 [, (list of compatible devices), ...];
26 reg = <(baseaddr) (size)>;
27 interrupt-parent = <&interrupt-controller-phandle>;
28 interrupts = < ... >;
29 xlnx,(parameter1) = "(string-value)";
30 xlnx,(parameter2) = <(int-value)>;
31 };
32
33 (generic-name): an open firmware-style name that describes the
34 generic class of device. Preferably, this is one word, such
35 as 'serial' or 'ethernet'.
36 (ip-core-name): the name of the ip block (given after the BEGIN
37 directive in system.mhs). Should be in lowercase
38 and all underscores '_' converted to dashes '-'.
39 (name): is derived from the "PARAMETER INSTANCE" value.
40 (parameter#): C_* parameters from system.mhs. The C_ prefix is
41 dropped from the parameter name, the name is converted
42 to lowercase and all underscore '_' characters are
43 converted to dashes '-'.
44 (baseaddr): the baseaddr parameter value (often named C_BASEADDR).
45 (HW_VER): from the HW_VER parameter.
46 (size): the address range size (often C_HIGHADDR - C_BASEADDR + 1).
47
48 Typically, the compatible list will include the exact IP core version
49 followed by an older IP core version which implements the same
50 interface or any other device with the same interface.
51
52 'reg', 'interrupt-parent' and 'interrupts' are all optional properties.
53
54 For example, the following block from system.mhs:
55
56 BEGIN opb_uartlite
57 PARAMETER INSTANCE = opb_uartlite_0
58 PARAMETER HW_VER = 1.00.b
59 PARAMETER C_BAUDRATE = 115200
60 PARAMETER C_DATA_BITS = 8
61 PARAMETER C_ODD_PARITY = 0
62 PARAMETER C_USE_PARITY = 0
63 PARAMETER C_CLK_FREQ = 50000000
64 PARAMETER C_BASEADDR = 0xEC100000
65 PARAMETER C_HIGHADDR = 0xEC10FFFF
66 BUS_INTERFACE SOPB = opb_7
67 PORT OPB_Clk = CLK_50MHz
68 PORT Interrupt = opb_uartlite_0_Interrupt
69 PORT RX = opb_uartlite_0_RX
70 PORT TX = opb_uartlite_0_TX
71 PORT OPB_Rst = sys_bus_reset_0
72 END
73
74 becomes the following device tree node:
75
76 opb_uartlite_0: serial@ec100000 {
77 device_type = "serial";
78 compatible = "xlnx,opb-uartlite-1.00.b";
79 reg = <ec100000 10000>;
80 interrupt-parent = <&opb_intc_0>;
81 interrupts = <1 0>; // got this from the opb_intc parameters
82 current-speed = <d#115200>; // standard serial device prop
83 clock-frequency = <d#50000000>; // standard serial device prop
84 xlnx,data-bits = <8>;
85 xlnx,odd-parity = <0>;
86 xlnx,use-parity = <0>;
87 };
88
89 Some IP cores actually implement 2 or more logical devices. In
90 this case, the device should still describe the whole IP core with
91 a single node and add a child node for each logical device. The
92 ranges property can be used to translate from parent IP-core to the
93 registers of each device. In addition, the parent node should be
94 compatible with the bus type 'xlnx,compound', and should contain
95 #address-cells and #size-cells, as with any other bus. (Note: this
96 makes the assumption that both logical devices have the same bus
97 binding. If this is not true, then separate nodes should be used
98 for each logical device). The 'cell-index' property can be used to
99 enumerate logical devices within an IP core. For example, the
100 following is the system.mhs entry for the dual ps2 controller found
101 on the ml403 reference design.
102
103 BEGIN opb_ps2_dual_ref
104 PARAMETER INSTANCE = opb_ps2_dual_ref_0
105 PARAMETER HW_VER = 1.00.a
106 PARAMETER C_BASEADDR = 0xA9000000
107 PARAMETER C_HIGHADDR = 0xA9001FFF
108 BUS_INTERFACE SOPB = opb_v20_0
109 PORT Sys_Intr1 = ps2_1_intr
110 PORT Sys_Intr2 = ps2_2_intr
111 PORT Clkin1 = ps2_clk_rx_1
112 PORT Clkin2 = ps2_clk_rx_2
113 PORT Clkpd1 = ps2_clk_tx_1
114 PORT Clkpd2 = ps2_clk_tx_2
115 PORT Rx1 = ps2_d_rx_1
116 PORT Rx2 = ps2_d_rx_2
117 PORT Txpd1 = ps2_d_tx_1
118 PORT Txpd2 = ps2_d_tx_2
119 END
120
121 It would result in the following device tree nodes:
122
123 opb_ps2_dual_ref_0: opb-ps2-dual-ref@a9000000 {
124 #address-cells = <1>;
125 #size-cells = <1>;
126 compatible = "xlnx,compound";
127 ranges = <0 a9000000 2000>;
128 // If this device had extra parameters, then they would
129 // go here.
130 ps2@0 {
131 compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
132 reg = <0 40>;
133 interrupt-parent = <&opb_intc_0>;
134 interrupts = <3 0>;
135 cell-index = <0>;
136 };
137 ps2@1000 {
138 compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
139 reg = <1000 40>;
140 interrupt-parent = <&opb_intc_0>;
141 interrupts = <3 0>;
142 cell-index = <0>;
143 };
144 };
145
146 Also, the system.mhs file defines bus attachments from the processor
147 to the devices. The device tree structure should reflect the bus
148 attachments. Again an example; this system.mhs fragment:
149
150 BEGIN ppc405_virtex4
151 PARAMETER INSTANCE = ppc405_0
152 PARAMETER HW_VER = 1.01.a
153 BUS_INTERFACE DPLB = plb_v34_0
154 BUS_INTERFACE IPLB = plb_v34_0
155 END
156
157 BEGIN opb_intc
158 PARAMETER INSTANCE = opb_intc_0
159 PARAMETER HW_VER = 1.00.c
160 PARAMETER C_BASEADDR = 0xD1000FC0
161 PARAMETER C_HIGHADDR = 0xD1000FDF
162 BUS_INTERFACE SOPB = opb_v20_0
163 END
164
165 BEGIN opb_uart16550
166 PARAMETER INSTANCE = opb_uart16550_0
167 PARAMETER HW_VER = 1.00.d
168 PARAMETER C_BASEADDR = 0xa0000000
169 PARAMETER C_HIGHADDR = 0xa0001FFF
170 BUS_INTERFACE SOPB = opb_v20_0
171 END
172
173 BEGIN plb_v34
174 PARAMETER INSTANCE = plb_v34_0
175 PARAMETER HW_VER = 1.02.a
176 END
177
178 BEGIN plb_bram_if_cntlr
179 PARAMETER INSTANCE = plb_bram_if_cntlr_0
180 PARAMETER HW_VER = 1.00.b
181 PARAMETER C_BASEADDR = 0xFFFF0000
182 PARAMETER C_HIGHADDR = 0xFFFFFFFF
183 BUS_INTERFACE SPLB = plb_v34_0
184 END
185
186 BEGIN plb2opb_bridge
187 PARAMETER INSTANCE = plb2opb_bridge_0
188 PARAMETER HW_VER = 1.01.a
189 PARAMETER C_RNG0_BASEADDR = 0x20000000
190 PARAMETER C_RNG0_HIGHADDR = 0x3FFFFFFF
191 PARAMETER C_RNG1_BASEADDR = 0x60000000
192 PARAMETER C_RNG1_HIGHADDR = 0x7FFFFFFF
193 PARAMETER C_RNG2_BASEADDR = 0x80000000
194 PARAMETER C_RNG2_HIGHADDR = 0xBFFFFFFF
195 PARAMETER C_RNG3_BASEADDR = 0xC0000000
196 PARAMETER C_RNG3_HIGHADDR = 0xDFFFFFFF
197 BUS_INTERFACE SPLB = plb_v34_0
198 BUS_INTERFACE MOPB = opb_v20_0
199 END
200
201 Gives this device tree (some properties removed for clarity):
202
203 plb@0 {
204 #address-cells = <1>;
205 #size-cells = <1>;
206 compatible = "xlnx,plb-v34-1.02.a";
207 device_type = "ibm,plb";
208 ranges; // 1:1 translation
209
210 plb_bram_if_cntrl_0: bram@ffff0000 {
211 reg = <ffff0000 10000>;
212 }
213
214 opb@20000000 {
215 #address-cells = <1>;
216 #size-cells = <1>;
217 ranges = <20000000 20000000 20000000
218 60000000 60000000 20000000
219 80000000 80000000 40000000
220 c0000000 c0000000 20000000>;
221
222 opb_uart16550_0: serial@a0000000 {
223 reg = <a00000000 2000>;
224 };
225
226 opb_intc_0: interrupt-controller@d1000fc0 {
227 reg = <d1000fc0 20>;
228 };
229 };
230 };
231
232 That covers the general approach to binding xilinx IP cores into the
233 device tree. The following are bindings for specific devices:
234
235 i) Xilinx ML300 Framebuffer
236
237 Simple framebuffer device from the ML300 reference design (also on the
238 ML403 reference design as well as others).
239
240 Optional properties:
241 - resolution = <xres yres> : pixel resolution of framebuffer. Some
242 implementations use a different resolution.
243 Default is <d#640 d#480>
244 - virt-resolution = <xvirt yvirt> : Size of framebuffer in memory.
245 Default is <d#1024 d#480>.
246 - rotate-display (empty) : rotate display 180 degrees.
247
248 ii) Xilinx SystemACE
249
250 The Xilinx SystemACE device is used to program FPGAs from an FPGA
251 bitstream stored on a CF card. It can also be used as a generic CF
252 interface device.
253
254 Optional properties:
255 - 8-bit (empty) : Set this property for SystemACE in 8 bit mode
256
257 iii) Xilinx EMAC and Xilinx TEMAC
258
259 Xilinx Ethernet devices. In addition to general xilinx properties
260 listed above, nodes for these devices should include a phy-handle
261 property, and may include other common network device properties
262 like local-mac-address.
263
264 iv) Xilinx Uartlite
265
266 Xilinx uartlite devices are simple fixed speed serial ports.
267
268 Required properties:
269 - current-speed : Baud rate of uartlite
270
271 v) Xilinx hwicap
272
273 Xilinx hwicap devices provide access to the configuration logic
274 of the FPGA through the Internal Configuration Access Port
275 (ICAP). The ICAP enables partial reconfiguration of the FPGA,
276 readback of the configuration information, and some control over
277 'warm boots' of the FPGA fabric.
278
279 Required properties:
280 - xlnx,family : The family of the FPGA, necessary since the
281 capabilities of the underlying ICAP hardware
282 differ between different families. May be
283 'virtex2p', 'virtex4', or 'virtex5'.
284
285 vi) Xilinx Uart 16550
286
287 Xilinx UART 16550 devices are very similar to the NS16550 but with
288 different register spacing and an offset from the base address.
289
290 Required properties:
291 - clock-frequency : Frequency of the clock input
292 - reg-offset : A value of 3 is required
293 - reg-shift : A value of 2 is required
294
295
diff --git a/Documentation/sound/alsa/HD-Audio-Models.txt b/Documentation/sound/alsa/HD-Audio-Models.txt
index 0d8d23581c44..939a3dd58148 100644
--- a/Documentation/sound/alsa/HD-Audio-Models.txt
+++ b/Documentation/sound/alsa/HD-Audio-Models.txt
@@ -240,6 +240,7 @@ AD1986A
240 laptop-automute 2-channel with EAPD and HP-automute (Lenovo N100) 240 laptop-automute 2-channel with EAPD and HP-automute (Lenovo N100)
241 ultra 2-channel with EAPD (Samsung Ultra tablet PC) 241 ultra 2-channel with EAPD (Samsung Ultra tablet PC)
242 samsung 2-channel with EAPD (Samsung R65) 242 samsung 2-channel with EAPD (Samsung R65)
243 samsung-p50 2-channel with HP-automute (Samsung P50)
243 244
244AD1988/AD1988B/AD1989A/AD1989B 245AD1988/AD1988B/AD1989A/AD1989B
245============================== 246==============================
diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c
index cf0e3ce0d526..c1a5aad3c75a 100644
--- a/Documentation/spi/spidev_test.c
+++ b/Documentation/spi/spidev_test.c
@@ -99,11 +99,13 @@ void parse_opts(int argc, char *argv[])
99 { "lsb", 0, 0, 'L' }, 99 { "lsb", 0, 0, 'L' },
100 { "cs-high", 0, 0, 'C' }, 100 { "cs-high", 0, 0, 'C' },
101 { "3wire", 0, 0, '3' }, 101 { "3wire", 0, 0, '3' },
102 { "no-cs", 0, 0, 'N' },
103 { "ready", 0, 0, 'R' },
102 { NULL, 0, 0, 0 }, 104 { NULL, 0, 0, 0 },
103 }; 105 };
104 int c; 106 int c;
105 107
106 c = getopt_long(argc, argv, "D:s:d:b:lHOLC3", lopts, NULL); 108 c = getopt_long(argc, argv, "D:s:d:b:lHOLC3NR", lopts, NULL);
107 109
108 if (c == -1) 110 if (c == -1)
109 break; 111 break;
@@ -139,6 +141,12 @@ void parse_opts(int argc, char *argv[])
139 case '3': 141 case '3':
140 mode |= SPI_3WIRE; 142 mode |= SPI_3WIRE;
141 break; 143 break;
144 case 'N':
145 mode |= SPI_NO_CS;
146 break;
147 case 'R':
148 mode |= SPI_READY;
149 break;
142 default: 150 default:
143 print_usage(argv[0]); 151 print_usage(argv[0]);
144 break; 152 break;
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index 873630e7e53e..014d255231fc 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -66,3 +66,4 @@
66 68 -> Terratec AV350 (em2860) [0ccd:0084] 66 68 -> Terratec AV350 (em2860) [0ccd:0084]
67 69 -> KWorld ATSC 315U HDTV TV Box (em2882) [eb1a:a313] 67 69 -> KWorld ATSC 315U HDTV TV Box (em2882) [eb1a:a313]
68 70 -> Evga inDtube (em2882) 68 70 -> Evga inDtube (em2882)
69 71 -> Silvercrest Webcam 1.3mpix (em2820/em2840)
diff --git a/Documentation/x86/00-INDEX b/Documentation/x86/00-INDEX
index dbe3377754af..f37b46d34861 100644
--- a/Documentation/x86/00-INDEX
+++ b/Documentation/x86/00-INDEX
@@ -2,3 +2,5 @@
2 - this file 2 - this file
3mtrr.txt 3mtrr.txt
4 - how to use x86 Memory Type Range Registers to increase performance 4 - how to use x86 Memory Type Range Registers to increase performance
5exception-tables.txt
6 - why and how Linux kernel uses exception tables on x86
diff --git a/Documentation/exception.txt b/Documentation/x86/exception-tables.txt
index 2d5aded64247..32901aa36f0a 100644
--- a/Documentation/exception.txt
+++ b/Documentation/x86/exception-tables.txt
@@ -1,123 +1,123 @@
1 Kernel level exception handling in Linux 2.1.8 1 Kernel level exception handling in Linux
2 Commentary by Joerg Pommnitz <joerg@raleigh.ibm.com> 2 Commentary by Joerg Pommnitz <joerg@raleigh.ibm.com>
3 3
4When a process runs in kernel mode, it often has to access user 4When a process runs in kernel mode, it often has to access user
5mode memory whose address has been passed by an untrusted program. 5mode memory whose address has been passed by an untrusted program.
6To protect itself the kernel has to verify this address. 6To protect itself the kernel has to verify this address.
7 7
8In older versions of Linux this was done with the 8In older versions of Linux this was done with the
9int verify_area(int type, const void * addr, unsigned long size) 9int verify_area(int type, const void * addr, unsigned long size)
10function (which has since been replaced by access_ok()). 10function (which has since been replaced by access_ok()).
11 11
12This function verified that the memory area starting at address 12This function verified that the memory area starting at address
13'addr' and of size 'size' was accessible for the operation specified 13'addr' and of size 'size' was accessible for the operation specified
14in type (read or write). To do this, verify_read had to look up the 14in type (read or write). To do this, verify_read had to look up the
15virtual memory area (vma) that contained the address addr. In the 15virtual memory area (vma) that contained the address addr. In the
16normal case (correctly working program), this test was successful. 16normal case (correctly working program), this test was successful.
17It only failed for a few buggy programs. In some kernel profiling 17It only failed for a few buggy programs. In some kernel profiling
18tests, this normally unneeded verification used up a considerable 18tests, this normally unneeded verification used up a considerable
19amount of time. 19amount of time.
20 20
21To overcome this situation, Linus decided to let the virtual memory 21To overcome this situation, Linus decided to let the virtual memory
22hardware present in every Linux-capable CPU handle this test. 22hardware present in every Linux-capable CPU handle this test.
23 23
24How does this work? 24How does this work?
25 25
26Whenever the kernel tries to access an address that is currently not 26Whenever the kernel tries to access an address that is currently not
27accessible, the CPU generates a page fault exception and calls the 27accessible, the CPU generates a page fault exception and calls the
28page fault handler 28page fault handler
29 29
30void do_page_fault(struct pt_regs *regs, unsigned long error_code) 30void do_page_fault(struct pt_regs *regs, unsigned long error_code)
31 31
32in arch/i386/mm/fault.c. The parameters on the stack are set up by 32in arch/x86/mm/fault.c. The parameters on the stack are set up by
33the low level assembly glue in arch/i386/kernel/entry.S. The parameter 33the low level assembly glue in arch/x86/kernel/entry_32.S. The parameter
34regs is a pointer to the saved registers on the stack, error_code 34regs is a pointer to the saved registers on the stack, error_code
35contains a reason code for the exception. 35contains a reason code for the exception.
36 36
37do_page_fault first obtains the unaccessible address from the CPU 37do_page_fault first obtains the unaccessible address from the CPU
38control register CR2. If the address is within the virtual address 38control register CR2. If the address is within the virtual address
39space of the process, the fault probably occurred, because the page 39space of the process, the fault probably occurred, because the page
40was not swapped in, write protected or something similar. However, 40was not swapped in, write protected or something similar. However,
41we are interested in the other case: the address is not valid, there 41we are interested in the other case: the address is not valid, there
42is no vma that contains this address. In this case, the kernel jumps 42is no vma that contains this address. In this case, the kernel jumps
43to the bad_area label. 43to the bad_area label.
44 44
45There it uses the address of the instruction that caused the exception 45There it uses the address of the instruction that caused the exception
46(i.e. regs->eip) to find an address where the execution can continue 46(i.e. regs->eip) to find an address where the execution can continue
47(fixup). If this search is successful, the fault handler modifies the 47(fixup). If this search is successful, the fault handler modifies the
48return address (again regs->eip) and returns. The execution will 48return address (again regs->eip) and returns. The execution will
49continue at the address in fixup. 49continue at the address in fixup.
50 50
51Where does fixup point to? 51Where does fixup point to?
52 52
53Since we jump to the contents of fixup, fixup obviously points 53Since we jump to the contents of fixup, fixup obviously points
54to executable code. This code is hidden inside the user access macros. 54to executable code. This code is hidden inside the user access macros.
55I have picked the get_user macro defined in include/asm/uaccess.h as an 55I have picked the get_user macro defined in arch/x86/include/asm/uaccess.h
56example. The definition is somewhat hard to follow, so let's peek at 56as an example. The definition is somewhat hard to follow, so let's peek at
57the code generated by the preprocessor and the compiler. I selected 57the code generated by the preprocessor and the compiler. I selected
58the get_user call in drivers/char/console.c for a detailed examination. 58the get_user call in drivers/char/sysrq.c for a detailed examination.
59 59
60The original code in console.c line 1405: 60The original code in sysrq.c line 587:
61 get_user(c, buf); 61 get_user(c, buf);
62 62
63The preprocessor output (edited to become somewhat readable): 63The preprocessor output (edited to become somewhat readable):
64 64
65( 65(
66 { 66 {
67 long __gu_err = - 14 , __gu_val = 0; 67 long __gu_err = - 14 , __gu_val = 0;
68 const __typeof__(*( ( buf ) )) *__gu_addr = ((buf)); 68 const __typeof__(*( ( buf ) )) *__gu_addr = ((buf));
69 if (((((0 + current_set[0])->tss.segment) == 0x18 ) || 69 if (((((0 + current_set[0])->tss.segment) == 0x18 ) ||
70 (((sizeof(*(buf))) <= 0xC0000000UL) && 70 (((sizeof(*(buf))) <= 0xC0000000UL) &&
71 ((unsigned long)(__gu_addr ) <= 0xC0000000UL - (sizeof(*(buf))))))) 71 ((unsigned long)(__gu_addr ) <= 0xC0000000UL - (sizeof(*(buf)))))))
72 do { 72 do {
73 __gu_err = 0; 73 __gu_err = 0;
74 switch ((sizeof(*(buf)))) { 74 switch ((sizeof(*(buf)))) {
75 case 1: 75 case 1:
76 __asm__ __volatile__( 76 __asm__ __volatile__(
77 "1: mov" "b" " %2,%" "b" "1\n" 77 "1: mov" "b" " %2,%" "b" "1\n"
78 "2:\n" 78 "2:\n"
79 ".section .fixup,\"ax\"\n" 79 ".section .fixup,\"ax\"\n"
80 "3: movl %3,%0\n" 80 "3: movl %3,%0\n"
81 " xor" "b" " %" "b" "1,%" "b" "1\n" 81 " xor" "b" " %" "b" "1,%" "b" "1\n"
82 " jmp 2b\n" 82 " jmp 2b\n"
83 ".section __ex_table,\"a\"\n" 83 ".section __ex_table,\"a\"\n"
84 " .align 4\n" 84 " .align 4\n"
85 " .long 1b,3b\n" 85 " .long 1b,3b\n"
86 ".text" : "=r"(__gu_err), "=q" (__gu_val): "m"((*(struct __large_struct *) 86 ".text" : "=r"(__gu_err), "=q" (__gu_val): "m"((*(struct __large_struct *)
87 ( __gu_addr )) ), "i"(- 14 ), "0"( __gu_err )) ; 87 ( __gu_addr )) ), "i"(- 14 ), "0"( __gu_err )) ;
88 break; 88 break;
89 case 2: 89 case 2:
90 __asm__ __volatile__( 90 __asm__ __volatile__(
91 "1: mov" "w" " %2,%" "w" "1\n" 91 "1: mov" "w" " %2,%" "w" "1\n"
92 "2:\n" 92 "2:\n"
93 ".section .fixup,\"ax\"\n" 93 ".section .fixup,\"ax\"\n"
94 "3: movl %3,%0\n" 94 "3: movl %3,%0\n"
95 " xor" "w" " %" "w" "1,%" "w" "1\n" 95 " xor" "w" " %" "w" "1,%" "w" "1\n"
96 " jmp 2b\n" 96 " jmp 2b\n"
97 ".section __ex_table,\"a\"\n" 97 ".section __ex_table,\"a\"\n"
98 " .align 4\n" 98 " .align 4\n"
99 " .long 1b,3b\n" 99 " .long 1b,3b\n"
100 ".text" : "=r"(__gu_err), "=r" (__gu_val) : "m"((*(struct __large_struct *) 100 ".text" : "=r"(__gu_err), "=r" (__gu_val) : "m"((*(struct __large_struct *)
101 ( __gu_addr )) ), "i"(- 14 ), "0"( __gu_err )); 101 ( __gu_addr )) ), "i"(- 14 ), "0"( __gu_err ));
102 break; 102 break;
103 case 4: 103 case 4:
104 __asm__ __volatile__( 104 __asm__ __volatile__(
105 "1: mov" "l" " %2,%" "" "1\n" 105 "1: mov" "l" " %2,%" "" "1\n"
106 "2:\n" 106 "2:\n"
107 ".section .fixup,\"ax\"\n" 107 ".section .fixup,\"ax\"\n"
108 "3: movl %3,%0\n" 108 "3: movl %3,%0\n"
109 " xor" "l" " %" "" "1,%" "" "1\n" 109 " xor" "l" " %" "" "1,%" "" "1\n"
110 " jmp 2b\n" 110 " jmp 2b\n"
111 ".section __ex_table,\"a\"\n" 111 ".section __ex_table,\"a\"\n"
112 " .align 4\n" " .long 1b,3b\n" 112 " .align 4\n" " .long 1b,3b\n"
113 ".text" : "=r"(__gu_err), "=r" (__gu_val) : "m"((*(struct __large_struct *) 113 ".text" : "=r"(__gu_err), "=r" (__gu_val) : "m"((*(struct __large_struct *)
114 ( __gu_addr )) ), "i"(- 14 ), "0"(__gu_err)); 114 ( __gu_addr )) ), "i"(- 14 ), "0"(__gu_err));
115 break; 115 break;
116 default: 116 default:
117 (__gu_val) = __get_user_bad(); 117 (__gu_val) = __get_user_bad();
118 } 118 }
119 } while (0) ; 119 } while (0) ;
120 ((c)) = (__typeof__(*((buf))))__gu_val; 120 ((c)) = (__typeof__(*((buf))))__gu_val;
121 __gu_err; 121 __gu_err;
122 } 122 }
123); 123);
@@ -127,12 +127,12 @@ see what code gcc generates:
127 127
128 > xorl %edx,%edx 128 > xorl %edx,%edx
129 > movl current_set,%eax 129 > movl current_set,%eax
130 > cmpl $24,788(%eax) 130 > cmpl $24,788(%eax)
131 > je .L1424 131 > je .L1424
132 > cmpl $-1073741825,64(%esp) 132 > cmpl $-1073741825,64(%esp)
133 > ja .L1423 133 > ja .L1423
134 > .L1424: 134 > .L1424:
135 > movl %edx,%eax 135 > movl %edx,%eax
136 > movl 64(%esp),%ebx 136 > movl 64(%esp),%ebx
137 > #APP 137 > #APP
138 > 1: movb (%ebx),%dl /* this is the actual user access */ 138 > 1: movb (%ebx),%dl /* this is the actual user access */
@@ -149,17 +149,17 @@ see what code gcc generates:
149 > .L1423: 149 > .L1423:
150 > movzbl %dl,%esi 150 > movzbl %dl,%esi
151 151
152The optimizer does a good job and gives us something we can actually 152The optimizer does a good job and gives us something we can actually
153understand. Can we? The actual user access is quite obvious. Thanks 153understand. Can we? The actual user access is quite obvious. Thanks
154to the unified address space we can just access the address in user 154to the unified address space we can just access the address in user
155memory. But what does the .section stuff do????? 155memory. But what does the .section stuff do?????
156 156
157To understand this we have to look at the final kernel: 157To understand this we have to look at the final kernel:
158 158
159 > objdump --section-headers vmlinux 159 > objdump --section-headers vmlinux
160 > 160 >
161 > vmlinux: file format elf32-i386 161 > vmlinux: file format elf32-i386
162 > 162 >
163 > Sections: 163 > Sections:
164 > Idx Name Size VMA LMA File off Algn 164 > Idx Name Size VMA LMA File off Algn
165 > 0 .text 00098f40 c0100000 c0100000 00001000 2**4 165 > 0 .text 00098f40 c0100000 c0100000 00001000 2**4
@@ -198,18 +198,18 @@ final kernel executable:
198 198
199The whole user memory access is reduced to 10 x86 machine instructions. 199The whole user memory access is reduced to 10 x86 machine instructions.
200The instructions bracketed in the .section directives are no longer 200The instructions bracketed in the .section directives are no longer
201in the normal execution path. They are located in a different section 201in the normal execution path. They are located in a different section
202of the executable file: 202of the executable file:
203 203
204 > objdump --disassemble --section=.fixup vmlinux 204 > objdump --disassemble --section=.fixup vmlinux
205 > 205 >
206 > c0199ff5 <.fixup+10b5> movl $0xfffffff2,%eax 206 > c0199ff5 <.fixup+10b5> movl $0xfffffff2,%eax
207 > c0199ffa <.fixup+10ba> xorb %dl,%dl 207 > c0199ffa <.fixup+10ba> xorb %dl,%dl
208 > c0199ffc <.fixup+10bc> jmp c017e7a7 <do_con_write+e3> 208 > c0199ffc <.fixup+10bc> jmp c017e7a7 <do_con_write+e3>
209 209
210And finally: 210And finally:
211 > objdump --full-contents --section=__ex_table vmlinux 211 > objdump --full-contents --section=__ex_table vmlinux
212 > 212 >
213 > c01aa7c4 93c017c0 e09f19c0 97c017c0 99c017c0 ................ 213 > c01aa7c4 93c017c0 e09f19c0 97c017c0 99c017c0 ................
214 > c01aa7d4 f6c217c0 e99f19c0 a5e717c0 f59f19c0 ................ 214 > c01aa7d4 f6c217c0 e99f19c0 a5e717c0 f59f19c0 ................
215 > c01aa7e4 080a18c0 01a019c0 0a0a18c0 04a019c0 ................ 215 > c01aa7e4 080a18c0 01a019c0 0a0a18c0 04a019c0 ................
@@ -235,8 +235,8 @@ sections in the ELF object file. So the instructions
235ended up in the .fixup section of the object file and the addresses 235ended up in the .fixup section of the object file and the addresses
236 .long 1b,3b 236 .long 1b,3b
237ended up in the __ex_table section of the object file. 1b and 3b 237ended up in the __ex_table section of the object file. 1b and 3b
238are local labels. The local label 1b (1b stands for next label 1 238are local labels. The local label 1b (1b stands for next label 1
239backward) is the address of the instruction that might fault, i.e. 239backward) is the address of the instruction that might fault, i.e.
240in our case the address of the label 1 is c017e7a5: 240in our case the address of the label 1 is c017e7a5:
241the original assembly code: > 1: movb (%ebx),%dl 241the original assembly code: > 1: movb (%ebx),%dl
242and linked in vmlinux : > c017e7a5 <do_con_write+e1> movb (%ebx),%dl 242and linked in vmlinux : > c017e7a5 <do_con_write+e1> movb (%ebx),%dl
@@ -254,7 +254,7 @@ The assembly code
254becomes the value pair 254becomes the value pair
255 > c01aa7d4 c017c2f6 c0199fe9 c017e7a5 c0199ff5 ................ 255 > c01aa7d4 c017c2f6 c0199fe9 c017e7a5 c0199ff5 ................
256 ^this is ^this is 256 ^this is ^this is
257 1b 3b 257 1b 3b
258c017e7a5,c0199ff5 in the exception table of the kernel. 258c017e7a5,c0199ff5 in the exception table of the kernel.
259 259
260So, what actually happens if a fault from kernel mode with no suitable 260So, what actually happens if a fault from kernel mode with no suitable
@@ -266,9 +266,9 @@ vma occurs?
2663.) CPU calls do_page_fault 2663.) CPU calls do_page_fault
2674.) do page fault calls search_exception_table (regs->eip == c017e7a5); 2674.) do page fault calls search_exception_table (regs->eip == c017e7a5);
2685.) search_exception_table looks up the address c017e7a5 in the 2685.) search_exception_table looks up the address c017e7a5 in the
269 exception table (i.e. the contents of the ELF section __ex_table) 269 exception table (i.e. the contents of the ELF section __ex_table)
270 and returns the address of the associated fault handle code c0199ff5. 270 and returns the address of the associated fault handle code c0199ff5.
2716.) do_page_fault modifies its own return address to point to the fault 2716.) do_page_fault modifies its own return address to point to the fault
272 handle code and returns. 272 handle code and returns.
2737.) execution continues in the fault handling code. 2737.) execution continues in the fault handling code.
2748.) 8a) EAX becomes -EFAULT (== -14) 2748.) 8a) EAX becomes -EFAULT (== -14)
diff --git a/MAINTAINERS b/MAINTAINERS
index fa2a16def17a..18c3f0c41c95 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -867,12 +867,22 @@ M: alex@shark-linux.de
867W: http://www.shark-linux.de/shark.html 867W: http://www.shark-linux.de/shark.html
868S: Maintained 868S: Maintained
869 869
870ARM/SAMSUNG ARM ARCHITECTURES
871P: Ben Dooks
872M: ben-linux@fluff.org
873L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
874W: http://www.fluff.org/ben/linux/
875S: Maintained
876F: arch/arm/plat-s3c/
877F: arch/arm/plat-s3c24xx/
878
870ARM/S3C2410 ARM ARCHITECTURE 879ARM/S3C2410 ARM ARCHITECTURE
871P: Ben Dooks 880P: Ben Dooks
872M: ben-linux@fluff.org 881M: ben-linux@fluff.org
873L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only) 882L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
874W: http://www.fluff.org/ben/linux/ 883W: http://www.fluff.org/ben/linux/
875S: Maintained 884S: Maintained
885F: arch/arm/mach-s3c2410/
876 886
877ARM/S3C2440 ARM ARCHITECTURE 887ARM/S3C2440 ARM ARCHITECTURE
878P: Ben Dooks 888P: Ben Dooks
@@ -880,6 +890,39 @@ M: ben-linux@fluff.org
880L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only) 890L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
881W: http://www.fluff.org/ben/linux/ 891W: http://www.fluff.org/ben/linux/
882S: Maintained 892S: Maintained
893F: arch/arm/mach-s3c2440/
894
895ARM/S3C2442 ARM ARCHITECTURE
896P: Ben Dooks
897M: ben-linux@fluff.org
898L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
899W: http://www.fluff.org/ben/linux/
900S: Maintained
901F: arch/arm/mach-s3c2442/
902
903ARM/S3C2443 ARM ARCHITECTURE
904P: Ben Dooks
905M: ben-linux@fluff.org
906L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
907W: http://www.fluff.org/ben/linux/
908S: Maintained
909F: arch/arm/mach-s3c2443/
910
911ARM/S3C6400 ARM ARCHITECTURE
912P: Ben Dooks
913M: ben-linux@fluff.org
914L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
915W: http://www.fluff.org/ben/linux/
916S: Maintained
917F: arch/arm/mach-s3c6400/
918
919ARM/S3C6410 ARM ARCHITECTURE
920P: Ben Dooks
921M: ben-linux@fluff.org
922L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
923W: http://www.fluff.org/ben/linux/
924S: Maintained
925F: arch/arm/mach-s3c6410/
883 926
884ARM/TECHNOLOGIC SYSTEMS TS7250 MACHINE SUPPORT 927ARM/TECHNOLOGIC SYSTEMS TS7250 MACHINE SUPPORT
885P: Lennert Buytenhek 928P: Lennert Buytenhek
@@ -2087,9 +2130,9 @@ F: drivers/edac/i5400_edac.c
2087 2130
2088EDAC-I82975X 2131EDAC-I82975X
2089P: Ranganathan Desikan 2132P: Ranganathan Desikan
2090M: rdesikan@jetzbroadband.com 2133M: ravi@jetztechnologies.com
2091P: Arvind R. 2134P: Arvind R.
2092M: arvind@acarlab.com 2135M: arvind@jetztechnologies.com
2093L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers) 2136L: bluesmoke-devel@lists.sourceforge.net (moderated for non-subscribers)
2094W: bluesmoke.sourceforge.net 2137W: bluesmoke.sourceforge.net
2095S: Maintained 2138S: Maintained
@@ -2808,7 +2851,9 @@ S: Maintained
2808 2851
2809IA64 (Itanium) PLATFORM 2852IA64 (Itanium) PLATFORM
2810P: Tony Luck 2853P: Tony Luck
2854P: Fenghua Yu
2811M: tony.luck@intel.com 2855M: tony.luck@intel.com
2856M: fenghua.yu@intel.com
2812L: linux-ia64@vger.kernel.org 2857L: linux-ia64@vger.kernel.org
2813W: http://www.ia64-linux.org/ 2858W: http://www.ia64-linux.org/
2814T: git git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6.git 2859T: git git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6.git
@@ -2886,7 +2931,7 @@ P: Dmitry Eremin-Solenikov
2886M: dbaryshkov@gmail.com 2931M: dbaryshkov@gmail.com
2887P: Sergey Lapin 2932P: Sergey Lapin
2888M: slapin@ossfans.org 2933M: slapin@ossfans.org
2889L: linux-zigbee-devel@lists.sourceforge.net 2934L: linux-zigbee-devel@lists.sourceforge.net (moderated for non-subscribers)
2890W: http://apps.sourceforge.net/trac/linux-zigbee 2935W: http://apps.sourceforge.net/trac/linux-zigbee
2891T: git git://git.kernel.org/pub/scm/linux/kernel/git/lowpan/lowpan.git 2936T: git git://git.kernel.org/pub/scm/linux/kernel/git/lowpan/lowpan.git
2892S: Maintained 2937S: Maintained
@@ -3242,11 +3287,11 @@ F: include/linux/ivtv*
3242 3287
3243JFS FILESYSTEM 3288JFS FILESYSTEM
3244P: Dave Kleikamp 3289P: Dave Kleikamp
3245M: shaggy@austin.ibm.com 3290M: shaggy@linux.vnet.ibm.com
3246L: jfs-discussion@lists.sourceforge.net 3291L: jfs-discussion@lists.sourceforge.net
3247W: http://jfs.sourceforge.net/ 3292W: http://jfs.sourceforge.net/
3248T: git git://git.kernel.org/pub/scm/linux/kernel/git/shaggy/jfs-2.6.git 3293T: git git://git.kernel.org/pub/scm/linux/kernel/git/shaggy/jfs-2.6.git
3249S: Supported 3294S: Maintained
3250F: Documentation/filesystems/jfs.txt 3295F: Documentation/filesystems/jfs.txt
3251F: fs/jfs/ 3296F: fs/jfs/
3252 3297
@@ -4362,7 +4407,7 @@ W: http://www.nongnu.org/orinoco/
4362S: Maintained 4407S: Maintained
4363F: drivers/net/wireless/orinoco/ 4408F: drivers/net/wireless/orinoco/
4364 4409
4365OSD LIBRARY 4410OSD LIBRARY and FILESYSTEM
4366P: Boaz Harrosh 4411P: Boaz Harrosh
4367M: bharrosh@panasas.com 4412M: bharrosh@panasas.com
4368P: Benny Halevy 4413P: Benny Halevy
@@ -4371,6 +4416,9 @@ L: osd-dev@open-osd.org
4371W: http://open-osd.org 4416W: http://open-osd.org
4372T: git git://git.open-osd.org/open-osd.git 4417T: git git://git.open-osd.org/open-osd.git
4373S: Maintained 4418S: Maintained
4419F: drivers/scsi/osd/
4420F: drivers/include/scsi/osd_*
4421F: fs/exofs/
4374 4422
4375P54 WIRELESS DRIVER 4423P54 WIRELESS DRIVER
4376P: Michael Wu 4424P: Michael Wu
@@ -5533,8 +5581,8 @@ F: drivers/staging/
5533 5581
5534STARFIRE/DURALAN NETWORK DRIVER 5582STARFIRE/DURALAN NETWORK DRIVER
5535P: Ion Badulescu 5583P: Ion Badulescu
5536M: ionut@cs.columbia.edu 5584M: ionut@badula.org
5537S: Maintained 5585S: Odd Fixes
5538F: drivers/net/starfire* 5586F: drivers/net/starfire*
5539 5587
5540STARMODE RADIO IP (STRIP) PROTOCOL DRIVER 5588STARMODE RADIO IP (STRIP) PROTOCOL DRIVER
@@ -5668,6 +5716,13 @@ F: drivers/misc/tifm*
5668F: drivers/mmc/host/tifm_sd.c 5716F: drivers/mmc/host/tifm_sd.c
5669F: include/linux/tifm.h 5717F: include/linux/tifm.h
5670 5718
5719TI TWL4030 SERIES SOC CODEC DRIVER
5720P: Peter Ujfalusi
5721M: peter.ujfalusi@nokia.com
5722L: alsa-devel@alsa-project.org (moderated for non-subscribers)
5723S: Maintained
5724F: sound/soc/codecs/twl4030*
5725
5671TIPC NETWORK LAYER 5726TIPC NETWORK LAYER
5672P: Per Liden 5727P: Per Liden
5673M: per.liden@ericsson.com 5728M: per.liden@ericsson.com
@@ -5751,17 +5806,17 @@ P: Jiri Kosina
5751M: trivial@kernel.org 5806M: trivial@kernel.org
5752T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git 5807T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
5753S: Maintained 5808S: Maintained
5754F: drivers/char/tty_*
5755F: drivers/serial/serial_core.c
5756F: include/linux/serial_core.h
5757F: include/linux/serial.h
5758F: include/linux/tty.h
5759 5809
5760TTY LAYER 5810TTY LAYER
5761P: Alan Cox 5811P: Alan Cox
5762M: alan@lxorguk.ukuu.org.uk 5812M: alan@lxorguk.ukuu.org.uk
5763S: Maintained 5813S: Maintained
5764T: stgit http://zeniv.linux.org.uk/~alan/ttydev/ 5814T: stgit http://zeniv.linux.org.uk/~alan/ttydev/
5815F: drivers/char/tty_*
5816F: drivers/serial/serial_core.c
5817F: include/linux/serial_core.h
5818F: include/linux/serial.h
5819F: include/linux/tty.h
5765 5820
5766TULIP NETWORK DRIVERS 5821TULIP NETWORK DRIVERS
5767P: Grant Grundler 5822P: Grant Grundler
@@ -5799,7 +5854,7 @@ UBI FILE SYSTEM (UBIFS)
5799P: Artem Bityutskiy 5854P: Artem Bityutskiy
5800M: dedekind@infradead.org 5855M: dedekind@infradead.org
5801P: Adrian Hunter 5856P: Adrian Hunter
5802M: ext-adrian.hunter@nokia.com 5857M: adrian.hunter@nokia.com
5803L: linux-mtd@lists.infradead.org 5858L: linux-mtd@lists.infradead.org
5804T: git git://git.infradead.org/ubifs-2.6.git 5859T: git git://git.infradead.org/ubifs-2.6.git
5805W: http://www.linux-mtd.infradead.org/doc/ubifs.html 5860W: http://www.linux-mtd.infradead.org/doc/ubifs.html
diff --git a/Makefile b/Makefile
index d1216fea0c92..be0abacd042d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 31 3SUBLEVEL = 31
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc3
5NAME = Man-Eating Seals of Antiquity 5NAME = Man-Eating Seals of Antiquity
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -140,15 +140,13 @@ _all: modules
140endif 140endif
141 141
142srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) 142srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
143TOPDIR := $(srctree)
144# FIXME - TOPDIR is obsolete, use srctree/objtree
145objtree := $(CURDIR) 143objtree := $(CURDIR)
146src := $(srctree) 144src := $(srctree)
147obj := $(objtree) 145obj := $(objtree)
148 146
149VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) 147VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
150 148
151export srctree objtree VPATH TOPDIR 149export srctree objtree VPATH
152 150
153 151
154# SUBARCH tells the usermode build what the underlying arch is. That is set 152# SUBARCH tells the usermode build what the underlying arch is. That is set
@@ -344,7 +342,8 @@ KBUILD_CPPFLAGS := -D__KERNEL__
344 342
345KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 343KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
346 -fno-strict-aliasing -fno-common \ 344 -fno-strict-aliasing -fno-common \
347 -Werror-implicit-function-declaration 345 -Werror-implicit-function-declaration \
346 -Wno-format-security
348KBUILD_AFLAGS := -D__ASSEMBLY__ 347KBUILD_AFLAGS := -D__ASSEMBLY__
349 348
350# Read KERNELRELEASE from include/config/kernel.release (if it exists) 349# Read KERNELRELEASE from include/config/kernel.release (if it exists)
@@ -566,7 +565,7 @@ KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
566KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,) 565KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
567 566
568# disable invalid "can't wrap" optimizations for signed / pointers 567# disable invalid "can't wrap" optimizations for signed / pointers
569KBUILD_CFLAGS += $(call cc-option,-fwrapv) 568KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
570 569
571# revert to pre-gcc-4.4 behaviour of .eh_frame 570# revert to pre-gcc-4.4 behaviour of .eh_frame
572KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm) 571KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
diff --git a/arch/alpha/include/asm/percpu.h b/arch/alpha/include/asm/percpu.h
index 06c5c7a4afd3..b663f1f10b6a 100644
--- a/arch/alpha/include/asm/percpu.h
+++ b/arch/alpha/include/asm/percpu.h
@@ -30,7 +30,7 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
30 30
31#ifndef MODULE 31#ifndef MODULE
32#define SHIFT_PERCPU_PTR(var, offset) RELOC_HIDE(&per_cpu_var(var), (offset)) 32#define SHIFT_PERCPU_PTR(var, offset) RELOC_HIDE(&per_cpu_var(var), (offset))
33#define PER_CPU_ATTRIBUTES 33#define PER_CPU_DEF_ATTRIBUTES
34#else 34#else
35/* 35/*
36 * To calculate addresses of locally defined variables, GCC uses 32-bit 36 * To calculate addresses of locally defined variables, GCC uses 32-bit
@@ -49,7 +49,7 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
49 : "=&r"(__ptr), "=&r"(tmp_gp)); \ 49 : "=&r"(__ptr), "=&r"(tmp_gp)); \
50 (typeof(&per_cpu_var(var)))(__ptr + (offset)); }) 50 (typeof(&per_cpu_var(var)))(__ptr + (offset)); })
51 51
52#define PER_CPU_ATTRIBUTES __used 52#define PER_CPU_DEF_ATTRIBUTES __used
53 53
54#endif /* MODULE */ 54#endif /* MODULE */
55 55
@@ -71,7 +71,7 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
71#define __get_cpu_var(var) per_cpu_var(var) 71#define __get_cpu_var(var) per_cpu_var(var)
72#define __raw_get_cpu_var(var) per_cpu_var(var) 72#define __raw_get_cpu_var(var) per_cpu_var(var)
73 73
74#define PER_CPU_ATTRIBUTES 74#define PER_CPU_DEF_ATTRIBUTES
75 75
76#endif /* SMP */ 76#endif /* SMP */
77 77
diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h
index d069526bd767..60c83abfde70 100644
--- a/arch/alpha/include/asm/thread_info.h
+++ b/arch/alpha/include/asm/thread_info.h
@@ -37,6 +37,7 @@ struct thread_info {
37 .task = &tsk, \ 37 .task = &tsk, \
38 .exec_domain = &default_exec_domain, \ 38 .exec_domain = &default_exec_domain, \
39 .addr_limit = KERNEL_DS, \ 39 .addr_limit = KERNEL_DS, \
40 .preempt_count = INIT_PREEMPT_COUNT, \
40 .restart_block = { \ 41 .restart_block = { \
41 .fn = do_no_restart_syscall, \ 42 .fn = do_no_restart_syscall, \
42 }, \ 43 }, \
diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c
index 1e9ad52c460e..e072041d19f8 100644
--- a/arch/alpha/kernel/ptrace.c
+++ b/arch/alpha/kernel/ptrace.c
@@ -8,7 +8,6 @@
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/smp.h> 10#include <linux/smp.h>
11#include <linux/smp_lock.h>
12#include <linux/errno.h> 11#include <linux/errno.h>
13#include <linux/ptrace.h> 12#include <linux/ptrace.h>
14#include <linux/user.h> 13#include <linux/user.h>
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index a71fd941ade7..a89e4734b8f0 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -99,14 +99,6 @@ config DEBUG_CLPS711X_UART2
99 output to the second serial port on these devices. Saying N will 99 output to the second serial port on these devices. Saying N will
100 cause the debug messages to appear on the first serial port. 100 cause the debug messages to appear on the first serial port.
101 101
102config DEBUG_S3C_PORT
103 depends on DEBUG_LL && PLAT_S3C
104 bool "Kernel low-level debugging messages via S3C UART"
105 help
106 Say Y here if you want debug print routines to go to one of the
107 S3C internal UARTs. The chosen UART must have been configured
108 before it is used.
109
110config DEBUG_S3C_UART 102config DEBUG_S3C_UART
111 depends on PLAT_S3C 103 depends on PLAT_S3C
112 int "S3C UART to use for low-level debug" 104 int "S3C UART to use for low-level debug"
diff --git a/arch/arm/configs/kb9202_defconfig b/arch/arm/configs/kb9202_defconfig
index 8e74c66f239d..605a8462f172 100644
--- a/arch/arm/configs/kb9202_defconfig
+++ b/arch/arm/configs/kb9202_defconfig
@@ -1,109 +1,246 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-rc2 3# Linux kernel version: 2.6.30-rc8
4# Sun Aug 14 19:26:59 2005 4# Wed Jun 3 13:52:33 2009
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y
7CONFIG_MMU=y 11CONFIG_MMU=y
8CONFIG_UID16=y 12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
16CONFIG_LOCKDEP_SUPPORT=y
17CONFIG_TRACE_IRQFLAGS_SUPPORT=y
18CONFIG_HARDIRQS_SW_RESEND=y
19CONFIG_GENERIC_IRQ_PROBE=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 20CONFIG_RWSEM_GENERIC_SPINLOCK=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y 24CONFIG_GENERIC_CALIBRATE_DELAY=y
25CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
26CONFIG_VECTORS_BASE=0xffff0000
27CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
11 28
12# 29#
13# Code maturity level options 30# General setup
14# 31#
15# CONFIG_EXPERIMENTAL is not set 32CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y 33CONFIG_BROKEN_ON_SMP=y
34CONFIG_LOCK_KERNEL=y
18CONFIG_INIT_ENV_ARG_LIMIT=32 35CONFIG_INIT_ENV_ARG_LIMIT=32
19
20#
21# General setup
22#
23CONFIG_LOCALVERSION="" 36CONFIG_LOCALVERSION=""
37CONFIG_LOCALVERSION_AUTO=y
24# CONFIG_SWAP is not set 38# CONFIG_SWAP is not set
25# CONFIG_SYSVIPC is not set 39CONFIG_SYSVIPC=y
26# CONFIG_BSD_PROCESS_ACCT is not set 40CONFIG_SYSVIPC_SYSCTL=y
41CONFIG_POSIX_MQUEUE=y
42CONFIG_POSIX_MQUEUE_SYSCTL=y
43CONFIG_BSD_PROCESS_ACCT=y
44# CONFIG_BSD_PROCESS_ACCT_V3 is not set
45# CONFIG_TASKSTATS is not set
46CONFIG_AUDIT=y
47
48#
49# RCU Subsystem
50#
51CONFIG_CLASSIC_RCU=y
52# CONFIG_TREE_RCU is not set
53# CONFIG_PREEMPT_RCU is not set
54# CONFIG_TREE_RCU_TRACE is not set
55# CONFIG_PREEMPT_RCU_TRACE is not set
56CONFIG_IKCONFIG=y
57CONFIG_IKCONFIG_PROC=y
58CONFIG_LOG_BUF_SHIFT=17
59# CONFIG_GROUP_SCHED is not set
60# CONFIG_CGROUPS is not set
61# CONFIG_SYSFS_DEPRECATED_V2 is not set
62# CONFIG_RELAY is not set
63CONFIG_NAMESPACES=y
64# CONFIG_UTS_NS is not set
65# CONFIG_IPC_NS is not set
66# CONFIG_USER_NS is not set
67# CONFIG_PID_NS is not set
68# CONFIG_NET_NS is not set
69CONFIG_BLK_DEV_INITRD=y
70CONFIG_INITRAMFS_SOURCE=""
71CONFIG_RD_GZIP=y
72CONFIG_RD_BZIP2=y
73CONFIG_RD_LZMA=y
74CONFIG_CC_OPTIMIZE_FOR_SIZE=y
27CONFIG_SYSCTL=y 75CONFIG_SYSCTL=y
28# CONFIG_AUDIT is not set 76CONFIG_ANON_INODES=y
29CONFIG_HOTPLUG=y
30# CONFIG_KOBJECT_UEVENT is not set
31# CONFIG_IKCONFIG is not set
32# CONFIG_EMBEDDED is not set 77# CONFIG_EMBEDDED is not set
78CONFIG_UID16=y
79CONFIG_SYSCTL_SYSCALL=y
33CONFIG_KALLSYMS=y 80CONFIG_KALLSYMS=y
34# CONFIG_KALLSYMS_ALL is not set 81# CONFIG_KALLSYMS_ALL is not set
35# CONFIG_KALLSYMS_EXTRA_PASS is not set 82CONFIG_KALLSYMS_EXTRA_PASS=y
83# CONFIG_STRIP_ASM_SYMS is not set
84CONFIG_HOTPLUG=y
36CONFIG_PRINTK=y 85CONFIG_PRINTK=y
37CONFIG_BUG=y 86CONFIG_BUG=y
87CONFIG_ELF_CORE=y
38CONFIG_BASE_FULL=y 88CONFIG_BASE_FULL=y
39CONFIG_FUTEX=y 89CONFIG_FUTEX=y
40CONFIG_EPOLL=y 90CONFIG_EPOLL=y
41CONFIG_CC_OPTIMIZE_FOR_SIZE=y 91CONFIG_SIGNALFD=y
92CONFIG_TIMERFD=y
93CONFIG_EVENTFD=y
42CONFIG_SHMEM=y 94CONFIG_SHMEM=y
43CONFIG_CC_ALIGN_FUNCTIONS=0 95CONFIG_AIO=y
44CONFIG_CC_ALIGN_LABELS=0 96CONFIG_VM_EVENT_COUNTERS=y
45CONFIG_CC_ALIGN_LOOPS=0 97CONFIG_SLUB_DEBUG=y
46CONFIG_CC_ALIGN_JUMPS=0 98CONFIG_COMPAT_BRK=y
47# CONFIG_TINY_SHMEM is not set 99# CONFIG_SLAB is not set
100CONFIG_SLUB=y
101# CONFIG_SLOB is not set
102# CONFIG_PROFILING is not set
103CONFIG_TRACEPOINTS=y
104CONFIG_MARKERS=y
105CONFIG_HAVE_OPROFILE=y
106# CONFIG_KPROBES is not set
107CONFIG_HAVE_KPROBES=y
108CONFIG_HAVE_KRETPROBES=y
109CONFIG_HAVE_CLK=y
110# CONFIG_SLOW_WORK is not set
111CONFIG_HAVE_GENERIC_DMA_COHERENT=y
112CONFIG_SLABINFO=y
113CONFIG_RT_MUTEXES=y
48CONFIG_BASE_SMALL=0 114CONFIG_BASE_SMALL=0
115CONFIG_MODULES=y
116# CONFIG_MODULE_FORCE_LOAD is not set
117CONFIG_MODULE_UNLOAD=y
118# CONFIG_MODULE_FORCE_UNLOAD is not set
119CONFIG_MODVERSIONS=y
120CONFIG_MODULE_SRCVERSION_ALL=y
121CONFIG_BLOCK=y
122# CONFIG_LBD is not set
123# CONFIG_BLK_DEV_BSG is not set
124# CONFIG_BLK_DEV_INTEGRITY is not set
49 125
50# 126#
51# Loadable module support 127# IO Schedulers
52# 128#
53CONFIG_MODULES=y 129CONFIG_IOSCHED_NOOP=y
54CONFIG_MODULE_UNLOAD=y 130# CONFIG_IOSCHED_AS is not set
55CONFIG_OBSOLETE_MODPARM=y 131# CONFIG_IOSCHED_DEADLINE is not set
56# CONFIG_MODULE_SRCVERSION_ALL is not set 132CONFIG_IOSCHED_CFQ=y
57CONFIG_KMOD=y 133# CONFIG_DEFAULT_AS is not set
134# CONFIG_DEFAULT_DEADLINE is not set
135CONFIG_DEFAULT_CFQ=y
136# CONFIG_DEFAULT_NOOP is not set
137CONFIG_DEFAULT_IOSCHED="cfq"
138# CONFIG_FREEZER is not set
58 139
59# 140#
60# System Type 141# System Type
61# 142#
62# CONFIG_ARCH_CLPS7500 is not set 143# CONFIG_ARCH_AAEC2000 is not set
144# CONFIG_ARCH_INTEGRATOR is not set
145# CONFIG_ARCH_REALVIEW is not set
146# CONFIG_ARCH_VERSATILE is not set
147CONFIG_ARCH_AT91=y
63# CONFIG_ARCH_CLPS711X is not set 148# CONFIG_ARCH_CLPS711X is not set
64# CONFIG_ARCH_CO285 is not set
65# CONFIG_ARCH_EBSA110 is not set 149# CONFIG_ARCH_EBSA110 is not set
150# CONFIG_ARCH_EP93XX is not set
151# CONFIG_ARCH_GEMINI is not set
66# CONFIG_ARCH_FOOTBRIDGE is not set 152# CONFIG_ARCH_FOOTBRIDGE is not set
67# CONFIG_ARCH_INTEGRATOR is not set 153# CONFIG_ARCH_NETX is not set
68# CONFIG_ARCH_IOP3XX is not set 154# CONFIG_ARCH_H720X is not set
69# CONFIG_ARCH_IXP4XX is not set 155# CONFIG_ARCH_IMX is not set
156# CONFIG_ARCH_IOP13XX is not set
157# CONFIG_ARCH_IOP32X is not set
158# CONFIG_ARCH_IOP33X is not set
159# CONFIG_ARCH_IXP23XX is not set
70# CONFIG_ARCH_IXP2000 is not set 160# CONFIG_ARCH_IXP2000 is not set
161# CONFIG_ARCH_IXP4XX is not set
71# CONFIG_ARCH_L7200 is not set 162# CONFIG_ARCH_L7200 is not set
163# CONFIG_ARCH_KIRKWOOD is not set
164# CONFIG_ARCH_KS8695 is not set
165# CONFIG_ARCH_NS9XXX is not set
166# CONFIG_ARCH_LOKI is not set
167# CONFIG_ARCH_MV78XX0 is not set
168# CONFIG_ARCH_MXC is not set
169# CONFIG_ARCH_ORION5X is not set
170# CONFIG_ARCH_PNX4008 is not set
72# CONFIG_ARCH_PXA is not set 171# CONFIG_ARCH_PXA is not set
172# CONFIG_ARCH_MMP is not set
73# CONFIG_ARCH_RPC is not set 173# CONFIG_ARCH_RPC is not set
74# CONFIG_ARCH_SA1100 is not set 174# CONFIG_ARCH_SA1100 is not set
75# CONFIG_ARCH_S3C2410 is not set 175# CONFIG_ARCH_S3C2410 is not set
176# CONFIG_ARCH_S3C64XX is not set
76# CONFIG_ARCH_SHARK is not set 177# CONFIG_ARCH_SHARK is not set
77# CONFIG_ARCH_LH7A40X is not set 178# CONFIG_ARCH_LH7A40X is not set
179# CONFIG_ARCH_DAVINCI is not set
78# CONFIG_ARCH_OMAP is not set 180# CONFIG_ARCH_OMAP is not set
79# CONFIG_ARCH_VERSATILE is not set 181# CONFIG_ARCH_MSM is not set
80# CONFIG_ARCH_IMX is not set 182# CONFIG_ARCH_W90X900 is not set
81# CONFIG_ARCH_H720X is not set 183
82# CONFIG_ARCH_AAEC2000 is not set 184#
83CONFIG_ARCH_AT91=y 185# Atmel AT91 System-on-Chip
186#
84CONFIG_ARCH_AT91RM9200=y 187CONFIG_ARCH_AT91RM9200=y
188# CONFIG_ARCH_AT91SAM9260 is not set
189# CONFIG_ARCH_AT91SAM9261 is not set
190# CONFIG_ARCH_AT91SAM9263 is not set
191# CONFIG_ARCH_AT91SAM9RL is not set
192# CONFIG_ARCH_AT91SAM9G20 is not set
193# CONFIG_ARCH_AT91CAP9 is not set
194# CONFIG_ARCH_AT91X40 is not set
195CONFIG_AT91_PMC_UNIT=y
85 196
86# 197#
87# AT91RM9200 Implementations 198# AT91RM9200 Board Type
88# 199#
200# CONFIG_MACH_ONEARM is not set
89# CONFIG_ARCH_AT91RM9200DK is not set 201# CONFIG_ARCH_AT91RM9200DK is not set
90# CONFIG_MACH_AT91RM9200EK is not set 202# CONFIG_MACH_AT91RM9200EK is not set
91# CONFIG_MACH_CSB337 is not set 203# CONFIG_MACH_CSB337 is not set
92# CONFIG_MACH_CSB637 is not set 204# CONFIG_MACH_CSB637 is not set
93# CONFIG_MACH_CARMEVA is not set 205# CONFIG_MACH_CARMEVA is not set
206# CONFIG_MACH_ATEB9200 is not set
94CONFIG_MACH_KB9200=y 207CONFIG_MACH_KB9200=y
208# CONFIG_MACH_PICOTUX2XX is not set
209# CONFIG_MACH_KAFA is not set
210# CONFIG_MACH_ECBAT91 is not set
211# CONFIG_MACH_YL9200 is not set
212
213#
214# AT91 Board Options
215#
216
217#
218# AT91 Feature Selections
219#
220CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
221CONFIG_AT91_TIMER_HZ=128
222CONFIG_AT91_EARLY_DBGU=y
223# CONFIG_AT91_EARLY_USART0 is not set
224# CONFIG_AT91_EARLY_USART1 is not set
225# CONFIG_AT91_EARLY_USART2 is not set
226# CONFIG_AT91_EARLY_USART3 is not set
227# CONFIG_AT91_EARLY_USART4 is not set
228# CONFIG_AT91_EARLY_USART5 is not set
95 229
96# 230#
97# Processor Type 231# Processor Type
98# 232#
99CONFIG_CPU_32=y 233CONFIG_CPU_32=y
100CONFIG_CPU_ARM920T=y 234CONFIG_CPU_ARM920T=y
101CONFIG_CPU_32v4=y 235CONFIG_CPU_32v4T=y
102CONFIG_CPU_ABRT_EV4T=y 236CONFIG_CPU_ABRT_EV4T=y
237CONFIG_CPU_PABRT_NOIFAR=y
103CONFIG_CPU_CACHE_V4WT=y 238CONFIG_CPU_CACHE_V4WT=y
104CONFIG_CPU_CACHE_VIVT=y 239CONFIG_CPU_CACHE_VIVT=y
105CONFIG_CPU_COPY_V4WB=y 240CONFIG_CPU_COPY_V4WB=y
106CONFIG_CPU_TLB_V4WBI=y 241CONFIG_CPU_TLB_V4WBI=y
242CONFIG_CPU_CP15=y
243CONFIG_CPU_CP15_MMU=y
107 244
108# 245#
109# Processor Features 246# Processor Features
@@ -112,23 +249,48 @@ CONFIG_ARM_THUMB=y
112# CONFIG_CPU_ICACHE_DISABLE is not set 249# CONFIG_CPU_ICACHE_DISABLE is not set
113# CONFIG_CPU_DCACHE_DISABLE is not set 250# CONFIG_CPU_DCACHE_DISABLE is not set
114# CONFIG_CPU_DCACHE_WRITETHROUGH is not set 251# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
252# CONFIG_OUTER_CACHE is not set
115 253
116# 254#
117# Bus support 255# Bus support
118# 256#
119CONFIG_ISA_DMA_API=y 257# CONFIG_PCI_SYSCALL is not set
120 258# CONFIG_ARCH_SUPPORTS_MSI is not set
121#
122# PCCARD (PCMCIA/CardBus) support
123#
124# CONFIG_PCCARD is not set 259# CONFIG_PCCARD is not set
125 260
126# 261#
127# Kernel Features 262# Kernel Features
128# 263#
129# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set 264CONFIG_TICK_ONESHOT=y
265CONFIG_NO_HZ=y
266CONFIG_HIGH_RES_TIMERS=y
267CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
268CONFIG_VMSPLIT_3G=y
269# CONFIG_VMSPLIT_2G is not set
270# CONFIG_VMSPLIT_1G is not set
271CONFIG_PAGE_OFFSET=0xC0000000
272CONFIG_PREEMPT=y
273CONFIG_HZ=128
274CONFIG_AEABI=y
275CONFIG_OABI_COMPAT=y
276# CONFIG_ARCH_HAS_HOLES_MEMORYMODEL is not set
277# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
278# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
279# CONFIG_HIGHMEM is not set
280CONFIG_SELECT_MEMORY_MODEL=y
281CONFIG_FLATMEM_MANUAL=y
282# CONFIG_DISCONTIGMEM_MANUAL is not set
283# CONFIG_SPARSEMEM_MANUAL is not set
130CONFIG_FLATMEM=y 284CONFIG_FLATMEM=y
131CONFIG_FLAT_NODE_MEM_MAP=y 285CONFIG_FLAT_NODE_MEM_MAP=y
286CONFIG_PAGEFLAGS_EXTENDED=y
287CONFIG_SPLIT_PTLOCK_CPUS=4096
288# CONFIG_PHYS_ADDR_T_64BIT is not set
289CONFIG_ZONE_DMA_FLAG=0
290CONFIG_VIRT_TO_BUS=y
291CONFIG_UNEVICTABLE_LRU=y
292CONFIG_HAVE_MLOCK=y
293CONFIG_HAVE_MLOCKED_PAGE_BIT=y
132# CONFIG_LEDS is not set 294# CONFIG_LEDS is not set
133CONFIG_ALIGNMENT_TRAP=y 295CONFIG_ALIGNMENT_TRAP=y
134 296
@@ -137,8 +299,16 @@ CONFIG_ALIGNMENT_TRAP=y
137# 299#
138CONFIG_ZBOOT_ROM_TEXT=0x10000000 300CONFIG_ZBOOT_ROM_TEXT=0x10000000
139CONFIG_ZBOOT_ROM_BSS=0x20040000 301CONFIG_ZBOOT_ROM_BSS=0x20040000
140CONFIG_ZBOOT_ROM=y 302# CONFIG_ZBOOT_ROM is not set
141CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/ram rw initrd=0x20210000,654933" 303CONFIG_CMDLINE="noinitrd root=/dev/mtdblock0 rootfstype=jffs2 mem=64M"
304# CONFIG_XIP_KERNEL is not set
305CONFIG_KEXEC=y
306CONFIG_ATAGS_PROC=y
307
308#
309# CPU Power Management
310#
311# CONFIG_CPU_IDLE is not set
142 312
143# 313#
144# Floating point emulation 314# Floating point emulation
@@ -149,74 +319,251 @@ CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/ram rw initrd=0x20210000,654933"
149# 319#
150CONFIG_FPE_NWFPE=y 320CONFIG_FPE_NWFPE=y
151# CONFIG_FPE_NWFPE_XP is not set 321# CONFIG_FPE_NWFPE_XP is not set
322# CONFIG_FPE_FASTFPE is not set
152 323
153# 324#
154# Userspace binary formats 325# Userspace binary formats
155# 326#
156CONFIG_BINFMT_ELF=y 327CONFIG_BINFMT_ELF=y
157CONFIG_BINFMT_AOUT=y 328# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
329CONFIG_HAVE_AOUT=y
330# CONFIG_BINFMT_AOUT is not set
158CONFIG_BINFMT_MISC=y 331CONFIG_BINFMT_MISC=y
159# CONFIG_ARTHUR is not set
160 332
161# 333#
162# Power management options 334# Power management options
163# 335#
164# CONFIG_PM is not set 336# CONFIG_PM is not set
337CONFIG_ARCH_SUSPEND_POSSIBLE=y
338CONFIG_NET=y
165 339
166# 340#
167# Device Drivers 341# Networking options
168# 342#
343CONFIG_PACKET=y
344# CONFIG_PACKET_MMAP is not set
345CONFIG_UNIX=y
346# CONFIG_NET_KEY is not set
347CONFIG_INET=y
348# CONFIG_IP_MULTICAST is not set
349# CONFIG_IP_ADVANCED_ROUTER is not set
350CONFIG_IP_FIB_HASH=y
351CONFIG_IP_PNP=y
352CONFIG_IP_PNP_DHCP=y
353CONFIG_IP_PNP_BOOTP=y
354# CONFIG_IP_PNP_RARP is not set
355# CONFIG_NET_IPIP is not set
356# CONFIG_NET_IPGRE is not set
357# CONFIG_ARPD is not set
358# CONFIG_SYN_COOKIES is not set
359# CONFIG_INET_AH is not set
360# CONFIG_INET_ESP is not set
361# CONFIG_INET_IPCOMP is not set
362# CONFIG_INET_XFRM_TUNNEL is not set
363# CONFIG_INET_TUNNEL is not set
364# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
365# CONFIG_INET_XFRM_MODE_TUNNEL is not set
366# CONFIG_INET_XFRM_MODE_BEET is not set
367# CONFIG_INET_LRO is not set
368# CONFIG_INET_DIAG is not set
369# CONFIG_TCP_CONG_ADVANCED is not set
370CONFIG_TCP_CONG_CUBIC=y
371CONFIG_DEFAULT_TCP_CONG="cubic"
372# CONFIG_TCP_MD5SIG is not set
373# CONFIG_IPV6 is not set
374# CONFIG_NETWORK_SECMARK is not set
375# CONFIG_NETFILTER is not set
376# CONFIG_IP_DCCP is not set
377# CONFIG_IP_SCTP is not set
378# CONFIG_TIPC is not set
379# CONFIG_ATM is not set
380# CONFIG_BRIDGE is not set
381# CONFIG_NET_DSA is not set
382# CONFIG_VLAN_8021Q is not set
383# CONFIG_DECNET is not set
384# CONFIG_LLC2 is not set
385# CONFIG_IPX is not set
386# CONFIG_ATALK is not set
387# CONFIG_X25 is not set
388# CONFIG_LAPB is not set
389# CONFIG_ECONET is not set
390# CONFIG_WAN_ROUTER is not set
391# CONFIG_PHONET is not set
392# CONFIG_NET_SCHED is not set
393# CONFIG_DCB is not set
169 394
170# 395#
171# Generic Driver Options 396# Network testing
172# 397#
173CONFIG_STANDALONE=y 398# CONFIG_NET_PKTGEN is not set
174CONFIG_PREVENT_FIRMWARE_BUILD=y 399# CONFIG_NET_DROP_MONITOR is not set
175# CONFIG_FW_LOADER is not set 400# CONFIG_HAMRADIO is not set
176CONFIG_DEBUG_DRIVER=y 401# CONFIG_CAN is not set
402# CONFIG_IRDA is not set
403# CONFIG_BT is not set
404# CONFIG_AF_RXRPC is not set
405# CONFIG_WIRELESS is not set
406# CONFIG_WIMAX is not set
407# CONFIG_RFKILL is not set
408# CONFIG_NET_9P is not set
177 409
178# 410#
179# Memory Technology Devices (MTD) 411# Device Drivers
180# 412#
181# CONFIG_MTD is not set
182 413
183# 414#
184# Parallel port support 415# Generic Driver Options
185# 416#
417CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
418CONFIG_STANDALONE=y
419CONFIG_PREVENT_FIRMWARE_BUILD=y
420CONFIG_FW_LOADER=y
421# CONFIG_FIRMWARE_IN_KERNEL is not set
422CONFIG_EXTRA_FIRMWARE=""
423# CONFIG_DEBUG_DRIVER is not set
424# CONFIG_DEBUG_DEVRES is not set
425# CONFIG_SYS_HYPERVISOR is not set
426# CONFIG_CONNECTOR is not set
427CONFIG_MTD=y
428# CONFIG_MTD_DEBUG is not set
429CONFIG_MTD_CONCAT=y
430CONFIG_MTD_PARTITIONS=y
431# CONFIG_MTD_TESTS is not set
432# CONFIG_MTD_REDBOOT_PARTS is not set
433CONFIG_MTD_CMDLINE_PARTS=y
434# CONFIG_MTD_AFS_PARTS is not set
435# CONFIG_MTD_AR7_PARTS is not set
436
437#
438# User Modules And Translation Layers
439#
440CONFIG_MTD_CHAR=y
441CONFIG_MTD_BLKDEVS=y
442CONFIG_MTD_BLOCK=y
443# CONFIG_FTL is not set
444# CONFIG_NFTL is not set
445# CONFIG_INFTL is not set
446# CONFIG_RFD_FTL is not set
447# CONFIG_SSFDC is not set
448# CONFIG_MTD_OOPS is not set
449
450#
451# RAM/ROM/Flash chip drivers
452#
453CONFIG_MTD_CFI=y
454# CONFIG_MTD_JEDECPROBE is not set
455CONFIG_MTD_GEN_PROBE=y
456# CONFIG_MTD_CFI_ADV_OPTIONS is not set
457CONFIG_MTD_MAP_BANK_WIDTH_1=y
458CONFIG_MTD_MAP_BANK_WIDTH_2=y
459CONFIG_MTD_MAP_BANK_WIDTH_4=y
460# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
461# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
462# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
463CONFIG_MTD_CFI_I1=y
464CONFIG_MTD_CFI_I2=y
465# CONFIG_MTD_CFI_I4 is not set
466# CONFIG_MTD_CFI_I8 is not set
467CONFIG_MTD_CFI_INTELEXT=y
468# CONFIG_MTD_CFI_AMDSTD is not set
469# CONFIG_MTD_CFI_STAA is not set
470CONFIG_MTD_CFI_UTIL=y
471# CONFIG_MTD_RAM is not set
472# CONFIG_MTD_ROM is not set
473# CONFIG_MTD_ABSENT is not set
474
475#
476# Mapping drivers for chip access
477#
478CONFIG_MTD_COMPLEX_MAPPINGS=y
479CONFIG_MTD_PHYSMAP=y
480# CONFIG_MTD_PHYSMAP_COMPAT is not set
481# CONFIG_MTD_ARM_INTEGRATOR is not set
482# CONFIG_MTD_PLATRAM is not set
483
484#
485# Self-contained MTD device drivers
486#
487# CONFIG_MTD_SLRAM is not set
488# CONFIG_MTD_PHRAM is not set
489# CONFIG_MTD_MTDRAM is not set
490# CONFIG_MTD_BLOCK2MTD is not set
491
492#
493# Disk-On-Chip Device Drivers
494#
495# CONFIG_MTD_DOC2000 is not set
496# CONFIG_MTD_DOC2001 is not set
497# CONFIG_MTD_DOC2001PLUS is not set
498CONFIG_MTD_NAND=y
499# CONFIG_MTD_NAND_VERIFY_WRITE is not set
500# CONFIG_MTD_NAND_ECC_SMC is not set
501# CONFIG_MTD_NAND_MUSEUM_IDS is not set
502# CONFIG_MTD_NAND_GPIO is not set
503CONFIG_MTD_NAND_IDS=y
504# CONFIG_MTD_NAND_DISKONCHIP is not set
505CONFIG_MTD_NAND_ATMEL=y
506# CONFIG_MTD_NAND_ATMEL_ECC_HW is not set
507CONFIG_MTD_NAND_ATMEL_ECC_SOFT=y
508# CONFIG_MTD_NAND_ATMEL_ECC_NONE is not set
509# CONFIG_MTD_NAND_NANDSIM is not set
510# CONFIG_MTD_NAND_PLATFORM is not set
511# CONFIG_MTD_ALAUDA is not set
512# CONFIG_MTD_ONENAND is not set
513
514#
515# LPDDR flash memory drivers
516#
517# CONFIG_MTD_LPDDR is not set
518
519#
520# UBI - Unsorted block images
521#
522CONFIG_MTD_UBI=y
523CONFIG_MTD_UBI_WL_THRESHOLD=4096
524CONFIG_MTD_UBI_BEB_RESERVE=1
525CONFIG_MTD_UBI_GLUEBI=y
526
527#
528# UBI debugging options
529#
530# CONFIG_MTD_UBI_DEBUG is not set
186# CONFIG_PARPORT is not set 531# CONFIG_PARPORT is not set
187 532CONFIG_BLK_DEV=y
188#
189# Plug and Play support
190#
191
192#
193# Block devices
194#
195# CONFIG_BLK_DEV_COW_COMMON is not set 533# CONFIG_BLK_DEV_COW_COMMON is not set
196CONFIG_BLK_DEV_LOOP=y 534CONFIG_BLK_DEV_LOOP=y
197# CONFIG_BLK_DEV_CRYPTOLOOP is not set 535# CONFIG_BLK_DEV_CRYPTOLOOP is not set
198CONFIG_BLK_DEV_NBD=y 536# CONFIG_BLK_DEV_NBD is not set
199# CONFIG_BLK_DEV_UB is not set 537# CONFIG_BLK_DEV_UB is not set
200CONFIG_BLK_DEV_RAM=y 538CONFIG_BLK_DEV_RAM=y
201CONFIG_BLK_DEV_RAM_COUNT=16 539CONFIG_BLK_DEV_RAM_COUNT=16
202CONFIG_BLK_DEV_RAM_SIZE=4096 540CONFIG_BLK_DEV_RAM_SIZE=16384
203CONFIG_BLK_DEV_INITRD=y 541# CONFIG_BLK_DEV_XIP is not set
204CONFIG_INITRAMFS_SOURCE=""
205# CONFIG_CDROM_PKTCDVD is not set 542# CONFIG_CDROM_PKTCDVD is not set
543# CONFIG_ATA_OVER_ETH is not set
544CONFIG_MISC_DEVICES=y
545CONFIG_ATMEL_TCLIB=y
546CONFIG_ATMEL_TCB_CLKSRC=y
547CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
548CONFIG_ATMEL_SSC=y
549# CONFIG_ENCLOSURE_SERVICES is not set
550# CONFIG_C2PORT is not set
206 551
207# 552#
208# IO Schedulers 553# EEPROM support
209# 554#
210CONFIG_IOSCHED_NOOP=y 555# CONFIG_EEPROM_93CX6 is not set
211CONFIG_IOSCHED_AS=y 556CONFIG_HAVE_IDE=y
212CONFIG_IOSCHED_DEADLINE=y 557# CONFIG_IDE is not set
213CONFIG_IOSCHED_CFQ=y
214# CONFIG_ATA_OVER_ETH is not set
215 558
216# 559#
217# SCSI device support 560# SCSI device support
218# 561#
562# CONFIG_RAID_ATTRS is not set
219CONFIG_SCSI=y 563CONFIG_SCSI=y
564CONFIG_SCSI_DMA=y
565# CONFIG_SCSI_TGT is not set
566# CONFIG_SCSI_NETLINK is not set
220CONFIG_SCSI_PROC_FS=y 567CONFIG_SCSI_PROC_FS=y
221 568
222# 569#
@@ -232,145 +579,87 @@ CONFIG_CHR_DEV_SG=y
232# 579#
233# Some SCSI devices (e.g. CD jukebox) support multiple LUNs 580# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
234# 581#
235# CONFIG_SCSI_MULTI_LUN is not set 582CONFIG_SCSI_MULTI_LUN=y
236# CONFIG_SCSI_CONSTANTS is not set 583CONFIG_SCSI_CONSTANTS=y
237# CONFIG_SCSI_LOGGING is not set 584CONFIG_SCSI_LOGGING=y
585# CONFIG_SCSI_SCAN_ASYNC is not set
586CONFIG_SCSI_WAIT_SCAN=m
238 587
239# 588#
240# SCSI Transport Attributes 589# SCSI Transports
241# 590#
242# CONFIG_SCSI_SPI_ATTRS is not set 591CONFIG_SCSI_SPI_ATTRS=m
243# CONFIG_SCSI_FC_ATTRS is not set 592# CONFIG_SCSI_FC_ATTRS is not set
244# CONFIG_SCSI_ISCSI_ATTRS is not set 593# CONFIG_SCSI_ISCSI_ATTRS is not set
245 594# CONFIG_SCSI_SAS_LIBSAS is not set
246# 595# CONFIG_SCSI_SRP_ATTRS is not set
247# SCSI low-level drivers 596# CONFIG_SCSI_LOWLEVEL is not set
248# 597# CONFIG_SCSI_DH is not set
249# CONFIG_SCSI_SATA is not set 598# CONFIG_SCSI_OSD_INITIATOR is not set
250# CONFIG_SCSI_DEBUG is not set 599# CONFIG_ATA is not set
251
252#
253# Multi-device support (RAID and LVM)
254#
255# CONFIG_MD is not set 600# CONFIG_MD is not set
256
257#
258# Fusion MPT device support
259#
260# CONFIG_FUSION is not set
261
262#
263# IEEE 1394 (FireWire) support
264#
265
266#
267# I2O device support
268#
269
270#
271# Networking support
272#
273CONFIG_NET=y
274
275#
276# Networking options
277#
278CONFIG_PACKET=y
279# CONFIG_PACKET_MMAP is not set
280CONFIG_UNIX=y
281# CONFIG_NET_KEY is not set
282CONFIG_INET=y
283CONFIG_IP_MULTICAST=y
284# CONFIG_IP_ADVANCED_ROUTER is not set
285CONFIG_IP_FIB_HASH=y
286CONFIG_IP_PNP=y
287CONFIG_IP_PNP_DHCP=y
288# CONFIG_IP_PNP_BOOTP is not set
289# CONFIG_IP_PNP_RARP is not set
290# CONFIG_NET_IPIP is not set
291# CONFIG_NET_IPGRE is not set
292# CONFIG_IP_MROUTE is not set
293# CONFIG_SYN_COOKIES is not set
294# CONFIG_INET_AH is not set
295# CONFIG_INET_ESP is not set
296# CONFIG_INET_IPCOMP is not set
297# CONFIG_INET_TUNNEL is not set
298# CONFIG_IP_TCPDIAG is not set
299# CONFIG_IP_TCPDIAG_IPV6 is not set
300# CONFIG_TCP_CONG_ADVANCED is not set
301CONFIG_TCP_CONG_BIC=y
302# CONFIG_IPV6 is not set
303# CONFIG_NETFILTER is not set
304# CONFIG_BRIDGE is not set
305# CONFIG_VLAN_8021Q is not set
306# CONFIG_DECNET is not set
307# CONFIG_LLC2 is not set
308# CONFIG_IPX is not set
309# CONFIG_ATALK is not set
310
311#
312# QoS and/or fair queueing
313#
314# CONFIG_NET_SCHED is not set
315# CONFIG_NET_CLS_ROUTE is not set
316
317#
318# Network testing
319#
320# CONFIG_NET_PKTGEN is not set
321# CONFIG_NETPOLL is not set
322# CONFIG_NET_POLL_CONTROLLER is not set
323# CONFIG_HAMRADIO is not set
324# CONFIG_IRDA is not set
325# CONFIG_BT is not set
326CONFIG_NETDEVICES=y 601CONFIG_NETDEVICES=y
602CONFIG_COMPAT_NET_DEV_OPS=y
327# CONFIG_DUMMY is not set 603# CONFIG_DUMMY is not set
328# CONFIG_BONDING is not set 604# CONFIG_BONDING is not set
605# CONFIG_MACVLAN is not set
329# CONFIG_EQUALIZER is not set 606# CONFIG_EQUALIZER is not set
330# CONFIG_TUN is not set 607# CONFIG_TUN is not set
331 608# CONFIG_VETH is not set
332# 609# CONFIG_PHYLIB is not set
333# Ethernet (10 or 100Mbit)
334#
335CONFIG_NET_ETHERNET=y 610CONFIG_NET_ETHERNET=y
336CONFIG_MII=y 611CONFIG_MII=y
337CONFIG_ARM_AT91_ETHER=y 612CONFIG_ARM_AT91_ETHER=y
613# CONFIG_AX88796 is not set
338# CONFIG_SMC91X is not set 614# CONFIG_SMC91X is not set
339# CONFIG_DM9000 is not set 615# CONFIG_DM9000 is not set
616# CONFIG_ETHOC is not set
617# CONFIG_SMC911X is not set
618# CONFIG_SMSC911X is not set
619# CONFIG_DNET is not set
620# CONFIG_IBM_NEW_EMAC_ZMII is not set
621# CONFIG_IBM_NEW_EMAC_RGMII is not set
622# CONFIG_IBM_NEW_EMAC_TAH is not set
623# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
624# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
625# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
626# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
627# CONFIG_B44 is not set
628# CONFIG_NETDEV_1000 is not set
629# CONFIG_NETDEV_10000 is not set
340 630
341# 631#
342# Ethernet (1000 Mbit) 632# Wireless LAN
343#
344
345#
346# Ethernet (10000 Mbit)
347#
348
349#
350# Token Ring devices
351# 633#
634# CONFIG_WLAN_PRE80211 is not set
635# CONFIG_WLAN_80211 is not set
352 636
353# 637#
354# Wireless LAN (non-hamradio) 638# Enable WiMAX (Networking options) to see the WiMAX drivers
355# 639#
356# CONFIG_NET_RADIO is not set
357 640
358# 641#
359# Wan interfaces 642# USB Network Adapters
360# 643#
644# CONFIG_USB_CATC is not set
645# CONFIG_USB_KAWETH is not set
646# CONFIG_USB_PEGASUS is not set
647# CONFIG_USB_RTL8150 is not set
648# CONFIG_USB_USBNET is not set
361# CONFIG_WAN is not set 649# CONFIG_WAN is not set
362# CONFIG_PPP is not set 650# CONFIG_PPP is not set
363# CONFIG_SLIP is not set 651# CONFIG_SLIP is not set
364 652# CONFIG_NETCONSOLE is not set
365# 653# CONFIG_NETPOLL is not set
366# ISDN subsystem 654# CONFIG_NET_POLL_CONTROLLER is not set
367#
368# CONFIG_ISDN is not set 655# CONFIG_ISDN is not set
369 656
370# 657#
371# Input device support 658# Input device support
372# 659#
373CONFIG_INPUT=y 660CONFIG_INPUT=y
661# CONFIG_INPUT_FF_MEMLESS is not set
662# CONFIG_INPUT_POLLDEV is not set
374 663
375# 664#
376# Userland interfaces 665# Userland interfaces
@@ -380,7 +669,6 @@ CONFIG_INPUT_MOUSEDEV=y
380CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 669CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
381CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 670CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
382# CONFIG_INPUT_JOYDEV is not set 671# CONFIG_INPUT_JOYDEV is not set
383# CONFIG_INPUT_TSDEV is not set
384# CONFIG_INPUT_EVDEV is not set 672# CONFIG_INPUT_EVDEV is not set
385# CONFIG_INPUT_EVBUG is not set 673# CONFIG_INPUT_EVBUG is not set
386 674
@@ -390,23 +678,25 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
390# CONFIG_INPUT_KEYBOARD is not set 678# CONFIG_INPUT_KEYBOARD is not set
391# CONFIG_INPUT_MOUSE is not set 679# CONFIG_INPUT_MOUSE is not set
392# CONFIG_INPUT_JOYSTICK is not set 680# CONFIG_INPUT_JOYSTICK is not set
681# CONFIG_INPUT_TABLET is not set
393# CONFIG_INPUT_TOUCHSCREEN is not set 682# CONFIG_INPUT_TOUCHSCREEN is not set
394# CONFIG_INPUT_MISC is not set 683# CONFIG_INPUT_MISC is not set
395 684
396# 685#
397# Hardware I/O ports 686# Hardware I/O ports
398# 687#
399CONFIG_SERIO=y 688# CONFIG_SERIO is not set
400# CONFIG_SERIO_SERPORT is not set
401# CONFIG_SERIO_RAW is not set
402# CONFIG_GAMEPORT is not set 689# CONFIG_GAMEPORT is not set
403 690
404# 691#
405# Character devices 692# Character devices
406# 693#
407CONFIG_VT=y 694CONFIG_VT=y
695CONFIG_CONSOLE_TRANSLATIONS=y
408CONFIG_VT_CONSOLE=y 696CONFIG_VT_CONSOLE=y
409CONFIG_HW_CONSOLE=y 697CONFIG_HW_CONSOLE=y
698# CONFIG_VT_HW_CONSOLE_BINDING is not set
699CONFIG_DEVKMEM=y
410# CONFIG_SERIAL_NONSTANDARD is not set 700# CONFIG_SERIAL_NONSTANDARD is not set
411 701
412# 702#
@@ -419,215 +709,362 @@ CONFIG_HW_CONSOLE=y
419# 709#
420CONFIG_SERIAL_ATMEL=y 710CONFIG_SERIAL_ATMEL=y
421CONFIG_SERIAL_ATMEL_CONSOLE=y 711CONFIG_SERIAL_ATMEL_CONSOLE=y
712CONFIG_SERIAL_ATMEL_PDC=y
713# CONFIG_SERIAL_ATMEL_TTYAT is not set
422CONFIG_SERIAL_CORE=y 714CONFIG_SERIAL_CORE=y
423CONFIG_SERIAL_CORE_CONSOLE=y 715CONFIG_SERIAL_CORE_CONSOLE=y
424CONFIG_UNIX98_PTYS=y 716CONFIG_UNIX98_PTYS=y
425CONFIG_LEGACY_PTYS=y 717# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
426CONFIG_LEGACY_PTY_COUNT=256 718# CONFIG_LEGACY_PTYS is not set
719# CONFIG_IPMI_HANDLER is not set
720# CONFIG_HW_RANDOM is not set
721# CONFIG_R3964 is not set
722# CONFIG_RAW_DRIVER is not set
723# CONFIG_TCG_TPM is not set
724# CONFIG_I2C is not set
725# CONFIG_SPI is not set
726CONFIG_ARCH_REQUIRE_GPIOLIB=y
727CONFIG_GPIOLIB=y
728# CONFIG_DEBUG_GPIO is not set
729# CONFIG_GPIO_SYSFS is not set
427 730
428# 731#
429# IPMI 732# Memory mapped GPIO expanders:
430# 733#
431# CONFIG_IPMI_HANDLER is not set
432 734
433# 735#
434# Watchdog Cards 736# I2C GPIO expanders:
435# 737#
436# CONFIG_WATCHDOG is not set
437# CONFIG_NVRAM is not set
438# CONFIG_RTC is not set
439# CONFIG_AT91RM9200_RTC is not set
440# CONFIG_DTLK is not set
441# CONFIG_R3964 is not set
442 738
443# 739#
444# Ftape, the floppy tape device driver 740# PCI GPIO expanders:
445# 741#
446# CONFIG_RAW_DRIVER is not set
447 742
448# 743#
449# TPM devices 744# SPI GPIO expanders:
450# 745#
451# CONFIG_AT91_SPI is not set 746# CONFIG_W1 is not set
747# CONFIG_POWER_SUPPLY is not set
748# CONFIG_HWMON is not set
749# CONFIG_THERMAL is not set
750# CONFIG_THERMAL_HWMON is not set
751CONFIG_WATCHDOG=y
752# CONFIG_WATCHDOG_NOWAYOUT is not set
452 753
453# 754#
454# I2C support 755# Watchdog Device Drivers
455# 756#
456# CONFIG_I2C is not set 757# CONFIG_SOFT_WATCHDOG is not set
758CONFIG_AT91RM9200_WATCHDOG=y
759
760#
761# USB-based Watchdog Cards
762#
763# CONFIG_USBPCWATCHDOG is not set
764CONFIG_SSB_POSSIBLE=y
457 765
458# 766#
459# Misc devices 767# Sonics Silicon Backplane
460# 768#
769# CONFIG_SSB is not set
770
771#
772# Multifunction device drivers
773#
774# CONFIG_MFD_CORE is not set
775# CONFIG_MFD_SM501 is not set
776# CONFIG_MFD_ASIC3 is not set
777# CONFIG_HTC_EGPIO is not set
778# CONFIG_HTC_PASIC3 is not set
779# CONFIG_MFD_TMIO is not set
780# CONFIG_MFD_T7L66XB is not set
781# CONFIG_MFD_TC6387XB is not set
782# CONFIG_MFD_TC6393XB is not set
461 783
462# 784#
463# Multimedia devices 785# Multimedia devices
464# 786#
787
788#
789# Multimedia core support
790#
465# CONFIG_VIDEO_DEV is not set 791# CONFIG_VIDEO_DEV is not set
792# CONFIG_DVB_CORE is not set
793# CONFIG_VIDEO_MEDIA is not set
466 794
467# 795#
468# Digital Video Broadcasting Devices 796# Multimedia drivers
469# 797#
470# CONFIG_DVB is not set 798# CONFIG_DAB is not set
471 799
472# 800#
473# Graphics support 801# Graphics support
474# 802#
475# CONFIG_FB is not set 803# CONFIG_VGASTATE is not set
804# CONFIG_VIDEO_OUTPUT_CONTROL is not set
805CONFIG_FB=y
806# CONFIG_FIRMWARE_EDID is not set
807# CONFIG_FB_DDC is not set
808# CONFIG_FB_BOOT_VESA_SUPPORT is not set
809# CONFIG_FB_CFB_FILLRECT is not set
810# CONFIG_FB_CFB_COPYAREA is not set
811# CONFIG_FB_CFB_IMAGEBLIT is not set
812# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
813# CONFIG_FB_SYS_FILLRECT is not set
814# CONFIG_FB_SYS_COPYAREA is not set
815# CONFIG_FB_SYS_IMAGEBLIT is not set
816# CONFIG_FB_FOREIGN_ENDIAN is not set
817# CONFIG_FB_SYS_FOPS is not set
818# CONFIG_FB_SVGALIB is not set
819# CONFIG_FB_MACMODES is not set
820# CONFIG_FB_BACKLIGHT is not set
821CONFIG_FB_MODE_HELPERS=y
822CONFIG_FB_TILEBLITTING=y
823
824#
825# Frame buffer hardware drivers
826#
827# CONFIG_FB_S1D13XXX is not set
828# CONFIG_FB_VIRTUAL is not set
829# CONFIG_FB_METRONOME is not set
830# CONFIG_FB_MB862XX is not set
831# CONFIG_FB_BROADSHEET is not set
832CONFIG_BACKLIGHT_LCD_SUPPORT=y
833# CONFIG_LCD_CLASS_DEVICE is not set
834CONFIG_BACKLIGHT_CLASS_DEVICE=y
835# CONFIG_BACKLIGHT_GENERIC is not set
836
837#
838# Display device support
839#
840# CONFIG_DISPLAY_SUPPORT is not set
476 841
477# 842#
478# Console display driver support 843# Console display driver support
479# 844#
480# CONFIG_VGA_CONSOLE is not set 845# CONFIG_VGA_CONSOLE is not set
481CONFIG_DUMMY_CONSOLE=y 846CONFIG_DUMMY_CONSOLE=y
482 847CONFIG_FRAMEBUFFER_CONSOLE=y
483# 848# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
484# Sound 849# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
485# 850CONFIG_FONTS=y
851# CONFIG_FONT_8x8 is not set
852# CONFIG_FONT_8x16 is not set
853# CONFIG_FONT_6x11 is not set
854# CONFIG_FONT_7x14 is not set
855# CONFIG_FONT_PEARL_8x8 is not set
856# CONFIG_FONT_ACORN_8x8 is not set
857CONFIG_FONT_MINI_4x6=y
858# CONFIG_FONT_SUN8x16 is not set
859# CONFIG_FONT_SUN12x22 is not set
860# CONFIG_FONT_10x18 is not set
861# CONFIG_LOGO is not set
486# CONFIG_SOUND is not set 862# CONFIG_SOUND is not set
487 863# CONFIG_HID_SUPPORT is not set
488# 864CONFIG_USB_SUPPORT=y
489# USB support
490#
491CONFIG_USB_ARCH_HAS_HCD=y 865CONFIG_USB_ARCH_HAS_HCD=y
492CONFIG_USB_ARCH_HAS_OHCI=y 866CONFIG_USB_ARCH_HAS_OHCI=y
867# CONFIG_USB_ARCH_HAS_EHCI is not set
493CONFIG_USB=y 868CONFIG_USB=y
494CONFIG_USB_DEBUG=y 869# CONFIG_USB_DEBUG is not set
870# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
495 871
496# 872#
497# Miscellaneous USB options 873# Miscellaneous USB options
498# 874#
499CONFIG_USB_DEVICEFS=y 875CONFIG_USB_DEVICEFS=y
876CONFIG_USB_DEVICE_CLASS=y
877# CONFIG_USB_DYNAMIC_MINORS is not set
878# CONFIG_USB_OTG is not set
879# CONFIG_USB_MON is not set
880# CONFIG_USB_WUSB is not set
881# CONFIG_USB_WUSB_CBAF is not set
500 882
501# 883#
502# USB Host Controller Drivers 884# USB Host Controller Drivers
503# 885#
886# CONFIG_USB_C67X00_HCD is not set
887# CONFIG_USB_OXU210HP_HCD is not set
504# CONFIG_USB_ISP116X_HCD is not set 888# CONFIG_USB_ISP116X_HCD is not set
889# CONFIG_USB_ISP1760_HCD is not set
505CONFIG_USB_OHCI_HCD=y 890CONFIG_USB_OHCI_HCD=y
506# CONFIG_USB_OHCI_BIG_ENDIAN is not set 891# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
892# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
507CONFIG_USB_OHCI_LITTLE_ENDIAN=y 893CONFIG_USB_OHCI_LITTLE_ENDIAN=y
508# CONFIG_USB_SL811_HCD is not set 894# CONFIG_USB_SL811_HCD is not set
895# CONFIG_USB_R8A66597_HCD is not set
896# CONFIG_USB_HWA_HCD is not set
897# CONFIG_USB_MUSB_HDRC is not set
509 898
510# 899#
511# USB Device Class drivers 900# USB Device Class drivers
512# 901#
513# CONFIG_USB_BLUETOOTH_TTY is not set
514# CONFIG_USB_ACM is not set 902# CONFIG_USB_ACM is not set
515# CONFIG_USB_PRINTER is not set 903# CONFIG_USB_PRINTER is not set
904# CONFIG_USB_WDM is not set
905# CONFIG_USB_TMC is not set
516 906
517# 907#
518# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information 908# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
519# 909#
520CONFIG_USB_STORAGE=y
521CONFIG_USB_STORAGE_DEBUG=y
522# CONFIG_USB_STORAGE_FREECOM is not set
523# CONFIG_USB_STORAGE_DPCM is not set
524
525#
526# USB Input Devices
527#
528# CONFIG_USB_HID is not set
529 910
530# 911#
531# USB HID Boot Protocol drivers 912# also be needed; see USB_STORAGE Help for more info
532# 913#
533# CONFIG_USB_KBD is not set 914CONFIG_USB_STORAGE=y
534# CONFIG_USB_MOUSE is not set 915# CONFIG_USB_STORAGE_DEBUG is not set
535# CONFIG_USB_AIPTEK is not set 916# CONFIG_USB_STORAGE_DATAFAB is not set
536# CONFIG_USB_WACOM is not set 917# CONFIG_USB_STORAGE_FREECOM is not set
537# CONFIG_USB_ACECAD is not set 918# CONFIG_USB_STORAGE_ISD200 is not set
538# CONFIG_USB_KBTAB is not set 919# CONFIG_USB_STORAGE_USBAT is not set
539# CONFIG_USB_POWERMATE is not set 920# CONFIG_USB_STORAGE_SDDR09 is not set
540# CONFIG_USB_MTOUCH is not set 921# CONFIG_USB_STORAGE_SDDR55 is not set
541# CONFIG_USB_ITMTOUCH is not set 922# CONFIG_USB_STORAGE_JUMPSHOT is not set
542# CONFIG_USB_EGALAX is not set 923# CONFIG_USB_STORAGE_ALAUDA is not set
543# CONFIG_USB_XPAD is not set 924# CONFIG_USB_STORAGE_ONETOUCH is not set
544# CONFIG_USB_ATI_REMOTE is not set 925# CONFIG_USB_STORAGE_KARMA is not set
926# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
927CONFIG_USB_LIBUSUAL=y
545 928
546# 929#
547# USB Imaging devices 930# USB Imaging devices
548# 931#
932# CONFIG_USB_MDC800 is not set
549# CONFIG_USB_MICROTEK is not set 933# CONFIG_USB_MICROTEK is not set
550 934
551# 935#
552# USB Multimedia devices 936# USB port drivers
553# 937#
554# CONFIG_USB_DABUSB is not set 938# CONFIG_USB_SERIAL is not set
555 939
556# 940#
557# Video4Linux support is needed for USB Multimedia device support 941# USB Miscellaneous drivers
558# 942#
943# CONFIG_USB_EMI62 is not set
944# CONFIG_USB_EMI26 is not set
945# CONFIG_USB_ADUTUX is not set
946# CONFIG_USB_SEVSEG is not set
947# CONFIG_USB_RIO500 is not set
948# CONFIG_USB_LEGOTOWER is not set
949# CONFIG_USB_LCD is not set
950# CONFIG_USB_BERRY_CHARGE is not set
951# CONFIG_USB_LED is not set
952# CONFIG_USB_CYPRESS_CY7C63 is not set
953# CONFIG_USB_CYTHERM is not set
954# CONFIG_USB_IDMOUSE is not set
955# CONFIG_USB_FTDI_ELAN is not set
956# CONFIG_USB_APPLEDISPLAY is not set
957# CONFIG_USB_LD is not set
958# CONFIG_USB_TRANCEVIBRATOR is not set
959# CONFIG_USB_IOWARRIOR is not set
960# CONFIG_USB_TEST is not set
961# CONFIG_USB_ISIGHTFW is not set
962# CONFIG_USB_VST is not set
963# CONFIG_USB_GADGET is not set
559 964
560# 965#
561# USB Network Adapters 966# OTG and related infrastructure
562# 967#
563# CONFIG_USB_KAWETH is not set 968# CONFIG_USB_GPIO_VBUS is not set
564# CONFIG_USB_PEGASUS is not set 969# CONFIG_NOP_USB_XCEIV is not set
565# CONFIG_USB_USBNET is not set 970CONFIG_MMC=y
566# CONFIG_USB_MON is not set 971# CONFIG_MMC_DEBUG is not set
972# CONFIG_MMC_UNSAFE_RESUME is not set
567 973
568# 974#
569# USB port drivers 975# MMC/SD/SDIO Card Drivers
570# 976#
977CONFIG_MMC_BLOCK=y
978CONFIG_MMC_BLOCK_BOUNCE=y
979# CONFIG_SDIO_UART is not set
980# CONFIG_MMC_TEST is not set
571 981
572# 982#
573# USB Serial Converter support 983# MMC/SD/SDIO Host Controller Drivers
574# 984#
575# CONFIG_USB_SERIAL is not set 985# CONFIG_MMC_SDHCI is not set
986CONFIG_MMC_AT91=y
987# CONFIG_MEMSTICK is not set
988# CONFIG_ACCESSIBILITY is not set
989# CONFIG_NEW_LEDS is not set
990CONFIG_RTC_LIB=y
991CONFIG_RTC_CLASS=y
992CONFIG_RTC_HCTOSYS=y
993CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
994# CONFIG_RTC_DEBUG is not set
576 995
577# 996#
578# USB Miscellaneous drivers 997# RTC interfaces
579# 998#
580# CONFIG_USB_EMI62 is not set 999CONFIG_RTC_INTF_SYSFS=y
581# CONFIG_USB_EMI26 is not set 1000CONFIG_RTC_INTF_PROC=y
582# CONFIG_USB_LCD is not set 1001CONFIG_RTC_INTF_DEV=y
583# CONFIG_USB_LED is not set 1002# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
584# CONFIG_USB_CYTHERM is not set 1003# CONFIG_RTC_DRV_TEST is not set
585# CONFIG_USB_PHIDGETKIT is not set
586# CONFIG_USB_PHIDGETSERVO is not set
587# CONFIG_USB_IDMOUSE is not set
588 1004
589# 1005#
590# USB DSL modem support 1006# SPI RTC drivers
591# 1007#
592 1008
593# 1009#
594# USB Gadget Support 1010# Platform RTC drivers
595# 1011#
596# CONFIG_USB_GADGET is not set 1012# CONFIG_RTC_DRV_CMOS is not set
1013# CONFIG_RTC_DRV_DS1286 is not set
1014# CONFIG_RTC_DRV_DS1511 is not set
1015# CONFIG_RTC_DRV_DS1553 is not set
1016# CONFIG_RTC_DRV_DS1742 is not set
1017# CONFIG_RTC_DRV_STK17TA8 is not set
1018# CONFIG_RTC_DRV_M48T86 is not set
1019# CONFIG_RTC_DRV_M48T35 is not set
1020# CONFIG_RTC_DRV_M48T59 is not set
1021# CONFIG_RTC_DRV_BQ4802 is not set
1022# CONFIG_RTC_DRV_V3020 is not set
597 1023
598# 1024#
599# MMC/SD Card support 1025# on-CPU RTC drivers
600# 1026#
601# CONFIG_MMC is not set 1027CONFIG_RTC_DRV_AT91RM9200=y
1028# CONFIG_DMADEVICES is not set
1029# CONFIG_AUXDISPLAY is not set
1030# CONFIG_REGULATOR is not set
1031# CONFIG_UIO is not set
1032# CONFIG_STAGING is not set
602 1033
603# 1034#
604# File systems 1035# File systems
605# 1036#
606CONFIG_EXT2_FS=y 1037CONFIG_EXT2_FS=y
607CONFIG_EXT2_FS_XATTR=y 1038# CONFIG_EXT2_FS_XATTR is not set
608# CONFIG_EXT2_FS_POSIX_ACL is not set
609# CONFIG_EXT2_FS_SECURITY is not set
610# CONFIG_EXT2_FS_XIP is not set 1039# CONFIG_EXT2_FS_XIP is not set
611CONFIG_EXT3_FS=y 1040CONFIG_EXT3_FS=y
1041# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
612CONFIG_EXT3_FS_XATTR=y 1042CONFIG_EXT3_FS_XATTR=y
613# CONFIG_EXT3_FS_POSIX_ACL is not set 1043# CONFIG_EXT3_FS_POSIX_ACL is not set
614# CONFIG_EXT3_FS_SECURITY is not set 1044# CONFIG_EXT3_FS_SECURITY is not set
1045# CONFIG_EXT4_FS is not set
615CONFIG_JBD=y 1046CONFIG_JBD=y
616# CONFIG_JBD_DEBUG is not set 1047# CONFIG_JBD_DEBUG is not set
617CONFIG_FS_MBCACHE=y 1048CONFIG_FS_MBCACHE=y
618# CONFIG_REISERFS_FS is not set 1049# CONFIG_REISERFS_FS is not set
619# CONFIG_JFS_FS is not set 1050# CONFIG_JFS_FS is not set
1051# CONFIG_FS_POSIX_ACL is not set
1052CONFIG_FILE_LOCKING=y
1053# CONFIG_XFS_FS is not set
1054# CONFIG_OCFS2_FS is not set
1055# CONFIG_BTRFS_FS is not set
1056# CONFIG_DNOTIFY is not set
1057CONFIG_INOTIFY=y
1058CONFIG_INOTIFY_USER=y
1059# CONFIG_QUOTA is not set
1060# CONFIG_AUTOFS_FS is not set
1061# CONFIG_AUTOFS4_FS is not set
1062# CONFIG_FUSE_FS is not set
620 1063
621# 1064#
622# XFS support 1065# Caches
623# 1066#
624# CONFIG_XFS_FS is not set 1067# CONFIG_FSCACHE is not set
625# CONFIG_MINIX_FS is not set
626# CONFIG_ROMFS_FS is not set
627# CONFIG_QUOTA is not set
628CONFIG_DNOTIFY=y
629CONFIG_AUTOFS_FS=y
630CONFIG_AUTOFS4_FS=y
631 1068
632# 1069#
633# CD-ROM/DVD Filesystems 1070# CD-ROM/DVD Filesystems
@@ -639,7 +1076,7 @@ CONFIG_AUTOFS4_FS=y
639# DOS/FAT/NT Filesystems 1076# DOS/FAT/NT Filesystems
640# 1077#
641CONFIG_FAT_FS=y 1078CONFIG_FAT_FS=y
642CONFIG_MSDOS_FS=y 1079# CONFIG_MSDOS_FS is not set
643CONFIG_VFAT_FS=y 1080CONFIG_VFAT_FS=y
644CONFIG_FAT_DEFAULT_CODEPAGE=437 1081CONFIG_FAT_DEFAULT_CODEPAGE=437
645CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" 1082CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
@@ -649,53 +1086,70 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
649# Pseudo filesystems 1086# Pseudo filesystems
650# 1087#
651CONFIG_PROC_FS=y 1088CONFIG_PROC_FS=y
1089CONFIG_PROC_SYSCTL=y
1090CONFIG_PROC_PAGE_MONITOR=y
652CONFIG_SYSFS=y 1091CONFIG_SYSFS=y
653CONFIG_DEVPTS_FS_XATTR=y
654# CONFIG_DEVPTS_FS_SECURITY is not set
655CONFIG_TMPFS=y 1092CONFIG_TMPFS=y
656# CONFIG_TMPFS_XATTR is not set 1093# CONFIG_TMPFS_POSIX_ACL is not set
657# CONFIG_HUGETLB_PAGE is not set 1094# CONFIG_HUGETLB_PAGE is not set
658CONFIG_RAMFS=y 1095CONFIG_CONFIGFS_FS=y
659 1096CONFIG_MISC_FILESYSTEMS=y
660# 1097# CONFIG_ADFS_FS is not set
661# Miscellaneous filesystems 1098# CONFIG_AFFS_FS is not set
662# 1099# CONFIG_HFS_FS is not set
663# CONFIG_HFSPLUS_FS is not set 1100# CONFIG_HFSPLUS_FS is not set
1101# CONFIG_BEFS_FS is not set
1102# CONFIG_BFS_FS is not set
1103# CONFIG_EFS_FS is not set
1104CONFIG_JFFS2_FS=y
1105CONFIG_JFFS2_FS_DEBUG=0
1106CONFIG_JFFS2_FS_WRITEBUFFER=y
1107# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
1108# CONFIG_JFFS2_SUMMARY is not set
1109# CONFIG_JFFS2_FS_XATTR is not set
1110# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1111CONFIG_JFFS2_ZLIB=y
1112# CONFIG_JFFS2_LZO is not set
1113CONFIG_JFFS2_RTIME=y
1114# CONFIG_JFFS2_RUBIN is not set
1115# CONFIG_UBIFS_FS is not set
664# CONFIG_CRAMFS is not set 1116# CONFIG_CRAMFS is not set
1117# CONFIG_SQUASHFS is not set
665# CONFIG_VXFS_FS is not set 1118# CONFIG_VXFS_FS is not set
1119# CONFIG_MINIX_FS is not set
1120# CONFIG_OMFS_FS is not set
666# CONFIG_HPFS_FS is not set 1121# CONFIG_HPFS_FS is not set
667# CONFIG_QNX4FS_FS is not set 1122# CONFIG_QNX4FS_FS is not set
1123# CONFIG_ROMFS_FS is not set
668# CONFIG_SYSV_FS is not set 1124# CONFIG_SYSV_FS is not set
669# CONFIG_UFS_FS is not set 1125# CONFIG_UFS_FS is not set
670 1126# CONFIG_NILFS2_FS is not set
671# 1127CONFIG_NETWORK_FILESYSTEMS=y
672# Network File Systems
673#
674CONFIG_NFS_FS=y 1128CONFIG_NFS_FS=y
675CONFIG_NFS_V3=y 1129CONFIG_NFS_V3=y
676# CONFIG_NFS_V3_ACL is not set 1130# CONFIG_NFS_V3_ACL is not set
677# CONFIG_NFSD is not set 1131# CONFIG_NFS_V4 is not set
678CONFIG_ROOT_NFS=y 1132CONFIG_ROOT_NFS=y
1133# CONFIG_NFSD is not set
679CONFIG_LOCKD=y 1134CONFIG_LOCKD=y
680CONFIG_LOCKD_V4=y 1135CONFIG_LOCKD_V4=y
681CONFIG_NFS_COMMON=y 1136CONFIG_NFS_COMMON=y
682CONFIG_SUNRPC=y 1137CONFIG_SUNRPC=y
1138# CONFIG_RPCSEC_GSS_KRB5 is not set
1139# CONFIG_RPCSEC_GSS_SPKM3 is not set
683# CONFIG_SMB_FS is not set 1140# CONFIG_SMB_FS is not set
684# CONFIG_CIFS is not set 1141# CONFIG_CIFS is not set
685# CONFIG_NCP_FS is not set 1142# CONFIG_NCP_FS is not set
686# CONFIG_CODA_FS is not set 1143# CONFIG_CODA_FS is not set
1144# CONFIG_AFS_FS is not set
687 1145
688# 1146#
689# Partition Types 1147# Partition Types
690# 1148#
691# CONFIG_PARTITION_ADVANCED is not set 1149# CONFIG_PARTITION_ADVANCED is not set
692CONFIG_MSDOS_PARTITION=y 1150CONFIG_MSDOS_PARTITION=y
693
694#
695# Native Language Support
696#
697CONFIG_NLS=y 1151CONFIG_NLS=y
698CONFIG_NLS_DEFAULT="utf8" 1152CONFIG_NLS_DEFAULT="iso8859-1"
699CONFIG_NLS_CODEPAGE_437=y 1153CONFIG_NLS_CODEPAGE_437=y
700# CONFIG_NLS_CODEPAGE_737 is not set 1154# CONFIG_NLS_CODEPAGE_737 is not set
701# CONFIG_NLS_CODEPAGE_775 is not set 1155# CONFIG_NLS_CODEPAGE_775 is not set
@@ -719,7 +1173,7 @@ CONFIG_NLS_CODEPAGE_437=y
719# CONFIG_NLS_ISO8859_8 is not set 1173# CONFIG_NLS_ISO8859_8 is not set
720# CONFIG_NLS_CODEPAGE_1250 is not set 1174# CONFIG_NLS_CODEPAGE_1250 is not set
721# CONFIG_NLS_CODEPAGE_1251 is not set 1175# CONFIG_NLS_CODEPAGE_1251 is not set
722CONFIG_NLS_ASCII=y 1176# CONFIG_NLS_ASCII is not set
723# CONFIG_NLS_ISO8859_1 is not set 1177# CONFIG_NLS_ISO8859_1 is not set
724# CONFIG_NLS_ISO8859_2 is not set 1178# CONFIG_NLS_ISO8859_2 is not set
725# CONFIG_NLS_ISO8859_3 is not set 1179# CONFIG_NLS_ISO8859_3 is not set
@@ -733,47 +1187,119 @@ CONFIG_NLS_ASCII=y
733# CONFIG_NLS_ISO8859_15 is not set 1187# CONFIG_NLS_ISO8859_15 is not set
734# CONFIG_NLS_KOI8_R is not set 1188# CONFIG_NLS_KOI8_R is not set
735# CONFIG_NLS_KOI8_U is not set 1189# CONFIG_NLS_KOI8_U is not set
736# CONFIG_NLS_UTF8 is not set 1190CONFIG_NLS_UTF8=y
1191# CONFIG_DLM is not set
737 1192
738# 1193#
739# Kernel hacking 1194# Kernel hacking
740# 1195#
741# CONFIG_PRINTK_TIME is not set 1196# CONFIG_PRINTK_TIME is not set
1197CONFIG_ENABLE_WARN_DEPRECATED=y
1198CONFIG_ENABLE_MUST_CHECK=y
1199CONFIG_FRAME_WARN=1024
1200CONFIG_MAGIC_SYSRQ=y
1201# CONFIG_UNUSED_SYMBOLS is not set
1202CONFIG_DEBUG_FS=y
1203# CONFIG_HEADERS_CHECK is not set
742CONFIG_DEBUG_KERNEL=y 1204CONFIG_DEBUG_KERNEL=y
743# CONFIG_MAGIC_SYSRQ is not set 1205# CONFIG_DEBUG_SHIRQ is not set
744CONFIG_LOG_BUF_SHIFT=14 1206CONFIG_DETECT_SOFTLOCKUP=y
1207# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1208CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1209CONFIG_DETECT_HUNG_TASK=y
1210# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1211CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
1212# CONFIG_SCHED_DEBUG is not set
745# CONFIG_SCHEDSTATS is not set 1213# CONFIG_SCHEDSTATS is not set
746# CONFIG_DEBUG_SLAB is not set 1214# CONFIG_TIMER_STATS is not set
1215# CONFIG_DEBUG_OBJECTS is not set
1216# CONFIG_SLUB_DEBUG_ON is not set
1217# CONFIG_SLUB_STATS is not set
1218# CONFIG_DEBUG_PREEMPT is not set
1219# CONFIG_DEBUG_RT_MUTEXES is not set
1220# CONFIG_RT_MUTEX_TESTER is not set
747# CONFIG_DEBUG_SPINLOCK is not set 1221# CONFIG_DEBUG_SPINLOCK is not set
1222# CONFIG_DEBUG_MUTEXES is not set
1223# CONFIG_DEBUG_LOCK_ALLOC is not set
1224# CONFIG_PROVE_LOCKING is not set
1225# CONFIG_LOCK_STAT is not set
748# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1226# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1227# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
749# CONFIG_DEBUG_KOBJECT is not set 1228# CONFIG_DEBUG_KOBJECT is not set
750CONFIG_DEBUG_BUGVERBOSE=y 1229CONFIG_DEBUG_BUGVERBOSE=y
751# CONFIG_DEBUG_INFO is not set 1230# CONFIG_DEBUG_INFO is not set
752# CONFIG_DEBUG_FS is not set 1231# CONFIG_DEBUG_VM is not set
753CONFIG_FRAME_POINTER=y 1232# CONFIG_DEBUG_WRITECOUNT is not set
754CONFIG_DEBUG_USER=y 1233CONFIG_DEBUG_MEMORY_INIT=y
755CONFIG_DEBUG_ERRORS=y 1234# CONFIG_DEBUG_LIST is not set
756CONFIG_DEBUG_LL=y 1235# CONFIG_DEBUG_SG is not set
757# CONFIG_DEBUG_ICEDCC is not set 1236# CONFIG_DEBUG_NOTIFIERS is not set
1237# CONFIG_BOOT_PRINTK_DELAY is not set
1238# CONFIG_RCU_TORTURE_TEST is not set
1239# CONFIG_RCU_CPU_STALL_DETECTOR is not set
1240# CONFIG_BACKTRACE_SELF_TEST is not set
1241# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1242# CONFIG_FAULT_INJECTION is not set
1243# CONFIG_LATENCYTOP is not set
1244# CONFIG_SYSCTL_SYSCALL_CHECK is not set
1245# CONFIG_PAGE_POISONING is not set
1246CONFIG_HAVE_FUNCTION_TRACER=y
1247CONFIG_TRACING_SUPPORT=y
1248
1249#
1250# Tracers
1251#
1252# CONFIG_FUNCTION_TRACER is not set
1253# CONFIG_IRQSOFF_TRACER is not set
1254# CONFIG_PREEMPT_TRACER is not set
1255# CONFIG_SCHED_TRACER is not set
1256# CONFIG_CONTEXT_SWITCH_TRACER is not set
1257# CONFIG_EVENT_TRACER is not set
1258# CONFIG_BOOT_TRACER is not set
1259# CONFIG_TRACE_BRANCH_PROFILING is not set
1260# CONFIG_STACK_TRACER is not set
1261# CONFIG_KMEMTRACE is not set
1262# CONFIG_WORKQUEUE_TRACER is not set
1263# CONFIG_BLK_DEV_IO_TRACE is not set
1264# CONFIG_DYNAMIC_DEBUG is not set
1265# CONFIG_SAMPLES is not set
1266CONFIG_HAVE_ARCH_KGDB=y
1267# CONFIG_KGDB is not set
1268CONFIG_ARM_UNWIND=y
1269# CONFIG_DEBUG_USER is not set
1270# CONFIG_DEBUG_ERRORS is not set
1271# CONFIG_DEBUG_STACK_USAGE is not set
1272# CONFIG_DEBUG_LL is not set
758 1273
759# 1274#
760# Security options 1275# Security options
761# 1276#
762# CONFIG_KEYS is not set 1277# CONFIG_KEYS is not set
763# CONFIG_SECURITY is not set 1278# CONFIG_SECURITY is not set
764 1279# CONFIG_SECURITYFS is not set
765# 1280# CONFIG_SECURITY_FILE_CAPABILITIES is not set
766# Cryptographic options
767#
768# CONFIG_CRYPTO is not set 1281# CONFIG_CRYPTO is not set
769 1282# CONFIG_BINARY_PRINTF is not set
770#
771# Hardware crypto devices
772#
773 1283
774# 1284#
775# Library routines 1285# Library routines
776# 1286#
1287CONFIG_BITREVERSE=y
1288CONFIG_GENERIC_FIND_LAST_BIT=y
777# CONFIG_CRC_CCITT is not set 1289# CONFIG_CRC_CCITT is not set
1290# CONFIG_CRC16 is not set
1291# CONFIG_CRC_T10DIF is not set
1292# CONFIG_CRC_ITU_T is not set
778CONFIG_CRC32=y 1293CONFIG_CRC32=y
1294# CONFIG_CRC7 is not set
779# CONFIG_LIBCRC32C is not set 1295# CONFIG_LIBCRC32C is not set
1296CONFIG_AUDIT_GENERIC=y
1297CONFIG_ZLIB_INFLATE=y
1298CONFIG_ZLIB_DEFLATE=y
1299CONFIG_DECOMPRESS_GZIP=y
1300CONFIG_DECOMPRESS_BZIP2=y
1301CONFIG_DECOMPRESS_LZMA=y
1302CONFIG_HAS_IOMEM=y
1303CONFIG_HAS_IOPORT=y
1304CONFIG_HAS_DMA=y
1305CONFIG_NLATTR=y
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index 2d58b8fe59be..b49810461e41 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -260,6 +260,7 @@ CONFIG_MACH_NEXCODER_2440=y
260CONFIG_SMDK2440_CPU2440=y 260CONFIG_SMDK2440_CPU2440=y
261CONFIG_MACH_AT2440EVB=y 261CONFIG_MACH_AT2440EVB=y
262CONFIG_CPU_S3C2442=y 262CONFIG_CPU_S3C2442=y
263CONFIG_MACH_MINI2440=y
263 264
264# 265#
265# S3C2442 Machines 266# S3C2442 Machines
@@ -2298,7 +2299,6 @@ CONFIG_DEBUG_ERRORS=y
2298# CONFIG_DEBUG_STACK_USAGE is not set 2299# CONFIG_DEBUG_STACK_USAGE is not set
2299CONFIG_DEBUG_LL=y 2300CONFIG_DEBUG_LL=y
2300# CONFIG_DEBUG_ICEDCC is not set 2301# CONFIG_DEBUG_ICEDCC is not set
2301CONFIG_DEBUG_S3C_PORT=y
2302CONFIG_DEBUG_S3C_UART=0 2302CONFIG_DEBUG_S3C_UART=0
2303 2303
2304# 2304#
diff --git a/arch/arm/configs/s3c6400_defconfig b/arch/arm/configs/s3c6400_defconfig
index 2e8fa50e9a09..32860609e057 100644
--- a/arch/arm/configs/s3c6400_defconfig
+++ b/arch/arm/configs/s3c6400_defconfig
@@ -816,7 +816,6 @@ CONFIG_DEBUG_ERRORS=y
816# CONFIG_DEBUG_STACK_USAGE is not set 816# CONFIG_DEBUG_STACK_USAGE is not set
817CONFIG_DEBUG_LL=y 817CONFIG_DEBUG_LL=y
818# CONFIG_DEBUG_ICEDCC is not set 818# CONFIG_DEBUG_ICEDCC is not set
819CONFIG_DEBUG_S3C_PORT=y
820CONFIG_DEBUG_S3C_UART=0 819CONFIG_DEBUG_S3C_UART=0
821 820
822# 821#
diff --git a/arch/arm/configs/tct_hammer_defconfig b/arch/arm/configs/tct_hammer_defconfig
index 07dfb98df4f0..9d32faef05f6 100644
--- a/arch/arm/configs/tct_hammer_defconfig
+++ b/arch/arm/configs/tct_hammer_defconfig
@@ -857,7 +857,6 @@ CONFIG_DEBUG_ERRORS=y
857# CONFIG_DEBUG_STACK_USAGE is not set 857# CONFIG_DEBUG_STACK_USAGE is not set
858CONFIG_DEBUG_LL=y 858CONFIG_DEBUG_LL=y
859# CONFIG_DEBUG_ICEDCC is not set 859# CONFIG_DEBUG_ICEDCC is not set
860# CONFIG_DEBUG_S3C_PORT is not set
861CONFIG_DEBUG_S3C_UART=0 860CONFIG_DEBUG_S3C_UART=0
862 861
863# 862#
diff --git a/arch/arm/configs/u300_defconfig b/arch/arm/configs/u300_defconfig
index 2d827e121147..4762d9001298 100644
--- a/arch/arm/configs/u300_defconfig
+++ b/arch/arm/configs/u300_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30-rc6 3# Linux kernel version: 2.6.31-rc1
4# Mon Jun 1 09:18:22 2009 4# Thu Jul 2 00:16:59 2009
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y 7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -9,7 +9,7 @@ CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y 9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y 10CONFIG_GENERIC_CLOCKEVENTS=y
11CONFIG_MMU=y 11CONFIG_MMU=y
12# CONFIG_NO_IOPORT is not set 12CONFIG_HAVE_TCM=y
13CONFIG_GENERIC_HARDIRQS=y 13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y 14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y 15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
@@ -18,13 +18,12 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
18CONFIG_HARDIRQS_SW_RESEND=y 18CONFIG_HARDIRQS_SW_RESEND=y
19CONFIG_GENERIC_IRQ_PROBE=y 19CONFIG_GENERIC_IRQ_PROBE=y
20CONFIG_RWSEM_GENERIC_SPINLOCK=y 20CONFIG_RWSEM_GENERIC_SPINLOCK=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_GENERIC_HWEIGHT=y 21CONFIG_GENERIC_HWEIGHT=y
24CONFIG_GENERIC_CALIBRATE_DELAY=y 22CONFIG_GENERIC_CALIBRATE_DELAY=y
25CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 23CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
26CONFIG_VECTORS_BASE=0xffff0000 24CONFIG_VECTORS_BASE=0xffff0000
27CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 25CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
26CONFIG_CONSTRUCTORS=y
28 27
29# 28#
30# General setup 29# General setup
@@ -68,7 +67,6 @@ CONFIG_SYSCTL_SYSCALL=y
68CONFIG_KALLSYMS=y 67CONFIG_KALLSYMS=y
69# CONFIG_KALLSYMS_ALL is not set 68# CONFIG_KALLSYMS_ALL is not set
70# CONFIG_KALLSYMS_EXTRA_PASS is not set 69# CONFIG_KALLSYMS_EXTRA_PASS is not set
71# CONFIG_STRIP_ASM_SYMS is not set
72CONFIG_HOTPLUG=y 70CONFIG_HOTPLUG=y
73CONFIG_PRINTK=y 71CONFIG_PRINTK=y
74CONFIG_BUG=y 72CONFIG_BUG=y
@@ -81,8 +79,13 @@ CONFIG_TIMERFD=y
81CONFIG_EVENTFD=y 79CONFIG_EVENTFD=y
82CONFIG_SHMEM=y 80CONFIG_SHMEM=y
83# CONFIG_AIO is not set 81# CONFIG_AIO is not set
82
83#
84# Performance Counters
85#
84# CONFIG_VM_EVENT_COUNTERS is not set 86# CONFIG_VM_EVENT_COUNTERS is not set
85CONFIG_SLUB_DEBUG=y 87CONFIG_SLUB_DEBUG=y
88# CONFIG_STRIP_ASM_SYMS is not set
86CONFIG_COMPAT_BRK=y 89CONFIG_COMPAT_BRK=y
87# CONFIG_SLAB is not set 90# CONFIG_SLAB is not set
88CONFIG_SLUB=y 91CONFIG_SLUB=y
@@ -94,6 +97,10 @@ CONFIG_HAVE_OPROFILE=y
94CONFIG_HAVE_KPROBES=y 97CONFIG_HAVE_KPROBES=y
95CONFIG_HAVE_KRETPROBES=y 98CONFIG_HAVE_KRETPROBES=y
96CONFIG_HAVE_CLK=y 99CONFIG_HAVE_CLK=y
100
101#
102# GCOV-based kernel profiling
103#
97# CONFIG_SLOW_WORK is not set 104# CONFIG_SLOW_WORK is not set
98CONFIG_HAVE_GENERIC_DMA_COHERENT=y 105CONFIG_HAVE_GENERIC_DMA_COHERENT=y
99CONFIG_SLABINFO=y 106CONFIG_SLABINFO=y
@@ -106,7 +113,7 @@ CONFIG_MODULE_UNLOAD=y
106# CONFIG_MODVERSIONS is not set 113# CONFIG_MODVERSIONS is not set
107# CONFIG_MODULE_SRCVERSION_ALL is not set 114# CONFIG_MODULE_SRCVERSION_ALL is not set
108CONFIG_BLOCK=y 115CONFIG_BLOCK=y
109# CONFIG_LBD is not set 116CONFIG_LBDAF=y
110# CONFIG_BLK_DEV_BSG is not set 117# CONFIG_BLK_DEV_BSG is not set
111# CONFIG_BLK_DEV_INTEGRITY is not set 118# CONFIG_BLK_DEV_INTEGRITY is not set
112 119
@@ -138,9 +145,9 @@ CONFIG_DEFAULT_IOSCHED="deadline"
138# CONFIG_ARCH_EP93XX is not set 145# CONFIG_ARCH_EP93XX is not set
139# CONFIG_ARCH_FOOTBRIDGE is not set 146# CONFIG_ARCH_FOOTBRIDGE is not set
140# CONFIG_ARCH_MXC is not set 147# CONFIG_ARCH_MXC is not set
148# CONFIG_ARCH_STMP3XXX is not set
141# CONFIG_ARCH_NETX is not set 149# CONFIG_ARCH_NETX is not set
142# CONFIG_ARCH_H720X is not set 150# CONFIG_ARCH_H720X is not set
143# CONFIG_ARCH_IMX is not set
144# CONFIG_ARCH_IOP13XX is not set 151# CONFIG_ARCH_IOP13XX is not set
145# CONFIG_ARCH_IOP32X is not set 152# CONFIG_ARCH_IOP32X is not set
146# CONFIG_ARCH_IOP33X is not set 153# CONFIG_ARCH_IOP33X is not set
@@ -216,8 +223,8 @@ CONFIG_ARM_THUMB=y
216# CONFIG_CPU_DCACHE_DISABLE is not set 223# CONFIG_CPU_DCACHE_DISABLE is not set
217# CONFIG_CPU_DCACHE_WRITETHROUGH is not set 224# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
218# CONFIG_CPU_CACHE_ROUND_ROBIN is not set 225# CONFIG_CPU_CACHE_ROUND_ROBIN is not set
219# CONFIG_OUTER_CACHE is not set
220CONFIG_ARM_VIC=y 226CONFIG_ARM_VIC=y
227CONFIG_ARM_VIC_NR=2
221CONFIG_COMMON_CLKDEV=y 228CONFIG_COMMON_CLKDEV=y
222 229
223# 230#
@@ -243,7 +250,6 @@ CONFIG_PREEMPT=y
243CONFIG_HZ=100 250CONFIG_HZ=100
244CONFIG_AEABI=y 251CONFIG_AEABI=y
245CONFIG_OABI_COMPAT=y 252CONFIG_OABI_COMPAT=y
246CONFIG_ARCH_FLATMEM_HAS_HOLES=y
247# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set 253# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
248# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set 254# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
249# CONFIG_HIGHMEM is not set 255# CONFIG_HIGHMEM is not set
@@ -258,17 +264,18 @@ CONFIG_SPLIT_PTLOCK_CPUS=4096
258# CONFIG_PHYS_ADDR_T_64BIT is not set 264# CONFIG_PHYS_ADDR_T_64BIT is not set
259CONFIG_ZONE_DMA_FLAG=0 265CONFIG_ZONE_DMA_FLAG=0
260CONFIG_VIRT_TO_BUS=y 266CONFIG_VIRT_TO_BUS=y
261CONFIG_UNEVICTABLE_LRU=y
262CONFIG_HAVE_MLOCK=y 267CONFIG_HAVE_MLOCK=y
263CONFIG_HAVE_MLOCKED_PAGE_BIT=y 268CONFIG_HAVE_MLOCKED_PAGE_BIT=y
269CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
264CONFIG_ALIGNMENT_TRAP=y 270CONFIG_ALIGNMENT_TRAP=y
271# CONFIG_UACCESS_WITH_MEMCPY is not set
265 272
266# 273#
267# Boot options 274# Boot options
268# 275#
269CONFIG_ZBOOT_ROM_TEXT=0x0 276CONFIG_ZBOOT_ROM_TEXT=0x0
270CONFIG_ZBOOT_ROM_BSS=0x0 277CONFIG_ZBOOT_ROM_BSS=0x0
271CONFIG_CMDLINE="root=/dev/mtdblock2 rw rootfstype=yaffs2 console=ttyAMA0,115200n8 ab3100.force=0,0x48 mtdparts=u300nand:128k@0x0(bootrecords)ro,8064k@128k(free)ro,253952k@8192k(platform) lpj=515072" 278CONFIG_CMDLINE="root=/dev/ram0 rw rootfstype=rootfs console=ttyAMA0,115200n8 lpj=515072"
272# CONFIG_XIP_KERNEL is not set 279# CONFIG_XIP_KERNEL is not set
273# CONFIG_KEXEC is not set 280# CONFIG_KEXEC is not set
274 281
@@ -359,6 +366,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
359# CONFIG_ECONET is not set 366# CONFIG_ECONET is not set
360# CONFIG_WAN_ROUTER is not set 367# CONFIG_WAN_ROUTER is not set
361# CONFIG_PHONET is not set 368# CONFIG_PHONET is not set
369# CONFIG_IEEE802154 is not set
362# CONFIG_NET_SCHED is not set 370# CONFIG_NET_SCHED is not set
363# CONFIG_DCB is not set 371# CONFIG_DCB is not set
364 372
@@ -497,6 +505,7 @@ CONFIG_MISC_DEVICES=y
497# CONFIG_EEPROM_AT24 is not set 505# CONFIG_EEPROM_AT24 is not set
498# CONFIG_EEPROM_AT25 is not set 506# CONFIG_EEPROM_AT25 is not set
499# CONFIG_EEPROM_LEGACY is not set 507# CONFIG_EEPROM_LEGACY is not set
508# CONFIG_EEPROM_MAX6875 is not set
500# CONFIG_EEPROM_93CX6 is not set 509# CONFIG_EEPROM_93CX6 is not set
501CONFIG_HAVE_IDE=y 510CONFIG_HAVE_IDE=y
502# CONFIG_IDE is not set 511# CONFIG_IDE is not set
@@ -538,6 +547,7 @@ CONFIG_INPUT_KEYBOARD=y
538# CONFIG_KEYBOARD_XTKBD is not set 547# CONFIG_KEYBOARD_XTKBD is not set
539# CONFIG_KEYBOARD_NEWTON is not set 548# CONFIG_KEYBOARD_NEWTON is not set
540# CONFIG_KEYBOARD_STOWAWAY is not set 549# CONFIG_KEYBOARD_STOWAWAY is not set
550# CONFIG_KEYBOARD_LM8323 is not set
541# CONFIG_KEYBOARD_GPIO is not set 551# CONFIG_KEYBOARD_GPIO is not set
542# CONFIG_INPUT_MOUSE is not set 552# CONFIG_INPUT_MOUSE is not set
543# CONFIG_INPUT_JOYSTICK is not set 553# CONFIG_INPUT_JOYSTICK is not set
@@ -597,9 +607,11 @@ CONFIG_I2C_HELPER_AUTO=y
597# 607#
598# I2C system bus drivers (mostly embedded / system-on-chip) 608# I2C system bus drivers (mostly embedded / system-on-chip)
599# 609#
610# CONFIG_I2C_DESIGNWARE is not set
600# CONFIG_I2C_GPIO is not set 611# CONFIG_I2C_GPIO is not set
601# CONFIG_I2C_OCORES is not set 612# CONFIG_I2C_OCORES is not set
602# CONFIG_I2C_SIMTEC is not set 613# CONFIG_I2C_SIMTEC is not set
614CONFIG_I2C_STU300=y
603 615
604# 616#
605# External I2C/SMBus adapter drivers 617# External I2C/SMBus adapter drivers
@@ -620,7 +632,6 @@ CONFIG_I2C_HELPER_AUTO=y
620# CONFIG_SENSORS_PCF8574 is not set 632# CONFIG_SENSORS_PCF8574 is not set
621# CONFIG_PCF8575 is not set 633# CONFIG_PCF8575 is not set
622# CONFIG_SENSORS_PCA9539 is not set 634# CONFIG_SENSORS_PCA9539 is not set
623# CONFIG_SENSORS_MAX6875 is not set
624# CONFIG_SENSORS_TSL2550 is not set 635# CONFIG_SENSORS_TSL2550 is not set
625# CONFIG_I2C_DEBUG_CORE is not set 636# CONFIG_I2C_DEBUG_CORE is not set
626# CONFIG_I2C_DEBUG_ALGO is not set 637# CONFIG_I2C_DEBUG_ALGO is not set
@@ -635,6 +646,7 @@ CONFIG_SPI_MASTER=y
635# 646#
636# CONFIG_SPI_BITBANG is not set 647# CONFIG_SPI_BITBANG is not set
637# CONFIG_SPI_GPIO is not set 648# CONFIG_SPI_GPIO is not set
649CONFIG_SPI_PL022=y
638 650
639# 651#
640# SPI Protocol Masters 652# SPI Protocol Masters
@@ -647,6 +659,7 @@ CONFIG_POWER_SUPPLY=y
647# CONFIG_PDA_POWER is not set 659# CONFIG_PDA_POWER is not set
648# CONFIG_BATTERY_DS2760 is not set 660# CONFIG_BATTERY_DS2760 is not set
649# CONFIG_BATTERY_BQ27x00 is not set 661# CONFIG_BATTERY_BQ27x00 is not set
662# CONFIG_BATTERY_MAX17040 is not set
650# CONFIG_HWMON is not set 663# CONFIG_HWMON is not set
651# CONFIG_THERMAL is not set 664# CONFIG_THERMAL is not set
652# CONFIG_THERMAL_HWMON is not set 665# CONFIG_THERMAL_HWMON is not set
@@ -657,6 +670,7 @@ CONFIG_WATCHDOG=y
657# Watchdog Device Drivers 670# Watchdog Device Drivers
658# 671#
659# CONFIG_SOFT_WATCHDOG is not set 672# CONFIG_SOFT_WATCHDOG is not set
673CONFIG_COH901327_WATCHDOG=y
660CONFIG_SSB_POSSIBLE=y 674CONFIG_SSB_POSSIBLE=y
661 675
662# 676#
@@ -678,22 +692,9 @@ CONFIG_SSB_POSSIBLE=y
678# CONFIG_MFD_WM8400 is not set 692# CONFIG_MFD_WM8400 is not set
679# CONFIG_MFD_WM8350_I2C is not set 693# CONFIG_MFD_WM8350_I2C is not set
680# CONFIG_MFD_PCF50633 is not set 694# CONFIG_MFD_PCF50633 is not set
681 695CONFIG_AB3100_CORE=y
682# 696# CONFIG_EZX_PCAP is not set
683# Multimedia devices 697# CONFIG_MEDIA_SUPPORT is not set
684#
685
686#
687# Multimedia core support
688#
689# CONFIG_VIDEO_DEV is not set
690# CONFIG_DVB_CORE is not set
691# CONFIG_VIDEO_MEDIA is not set
692
693#
694# Multimedia drivers
695#
696# CONFIG_DAB is not set
697 698
698# 699#
699# Graphics support 700# Graphics support
@@ -760,6 +761,11 @@ CONFIG_SND_JACK=y
760# CONFIG_SND_VERBOSE_PROCFS is not set 761# CONFIG_SND_VERBOSE_PROCFS is not set
761# CONFIG_SND_VERBOSE_PRINTK is not set 762# CONFIG_SND_VERBOSE_PRINTK is not set
762# CONFIG_SND_DEBUG is not set 763# CONFIG_SND_DEBUG is not set
764# CONFIG_SND_RAWMIDI_SEQ is not set
765# CONFIG_SND_OPL3_LIB_SEQ is not set
766# CONFIG_SND_OPL4_LIB_SEQ is not set
767# CONFIG_SND_SBAWE_SEQ is not set
768# CONFIG_SND_EMU10K1_SEQ is not set
763# CONFIG_SND_DRIVERS is not set 769# CONFIG_SND_DRIVERS is not set
764# CONFIG_SND_ARM is not set 770# CONFIG_SND_ARM is not set
765# CONFIG_SND_SPI is not set 771# CONFIG_SND_SPI is not set
@@ -770,7 +776,7 @@ CONFIG_SND_SOC_I2C_AND_SPI=y
770# CONFIG_HID_SUPPORT is not set 776# CONFIG_HID_SUPPORT is not set
771# CONFIG_USB_SUPPORT is not set 777# CONFIG_USB_SUPPORT is not set
772CONFIG_MMC=y 778CONFIG_MMC=y
773# CONFIG_MMC_DEBUG is not set 779CONFIG_MMC_DEBUG=y
774# CONFIG_MMC_UNSAFE_RESUME is not set 780# CONFIG_MMC_UNSAFE_RESUME is not set
775 781
776# 782#
@@ -797,7 +803,7 @@ CONFIG_LEDS_CLASS=y
797# 803#
798# CONFIG_LEDS_PCA9532 is not set 804# CONFIG_LEDS_PCA9532 is not set
799# CONFIG_LEDS_GPIO is not set 805# CONFIG_LEDS_GPIO is not set
800# CONFIG_LEDS_LP5521 is not set 806# CONFIG_LEDS_LP3944 is not set
801# CONFIG_LEDS_PCA955X is not set 807# CONFIG_LEDS_PCA955X is not set
802# CONFIG_LEDS_DAC124S085 is not set 808# CONFIG_LEDS_DAC124S085 is not set
803# CONFIG_LEDS_BD2802 is not set 809# CONFIG_LEDS_BD2802 is not set
@@ -845,6 +851,7 @@ CONFIG_RTC_INTF_DEV=y
845# CONFIG_RTC_DRV_S35390A is not set 851# CONFIG_RTC_DRV_S35390A is not set
846# CONFIG_RTC_DRV_FM3130 is not set 852# CONFIG_RTC_DRV_FM3130 is not set
847# CONFIG_RTC_DRV_RX8581 is not set 853# CONFIG_RTC_DRV_RX8581 is not set
854# CONFIG_RTC_DRV_RX8025 is not set
848 855
849# 856#
850# SPI RTC drivers 857# SPI RTC drivers
@@ -887,7 +894,10 @@ CONFIG_REGULATOR=y
887# CONFIG_REGULATOR_DEBUG is not set 894# CONFIG_REGULATOR_DEBUG is not set
888# CONFIG_REGULATOR_FIXED_VOLTAGE is not set 895# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
889# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set 896# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
897# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set
890# CONFIG_REGULATOR_BQ24022 is not set 898# CONFIG_REGULATOR_BQ24022 is not set
899# CONFIG_REGULATOR_MAX1586 is not set
900# CONFIG_REGULATOR_LP3971 is not set
891# CONFIG_UIO is not set 901# CONFIG_UIO is not set
892# CONFIG_STAGING is not set 902# CONFIG_STAGING is not set
893 903
@@ -900,16 +910,20 @@ CONFIG_REGULATOR=y
900# CONFIG_REISERFS_FS is not set 910# CONFIG_REISERFS_FS is not set
901# CONFIG_JFS_FS is not set 911# CONFIG_JFS_FS is not set
902# CONFIG_FS_POSIX_ACL is not set 912# CONFIG_FS_POSIX_ACL is not set
903CONFIG_FILE_LOCKING=y
904# CONFIG_XFS_FS is not set 913# CONFIG_XFS_FS is not set
914# CONFIG_GFS2_FS is not set
905# CONFIG_OCFS2_FS is not set 915# CONFIG_OCFS2_FS is not set
906# CONFIG_BTRFS_FS is not set 916# CONFIG_BTRFS_FS is not set
917CONFIG_FILE_LOCKING=y
918CONFIG_FSNOTIFY=y
907# CONFIG_DNOTIFY is not set 919# CONFIG_DNOTIFY is not set
908# CONFIG_INOTIFY is not set 920# CONFIG_INOTIFY is not set
921CONFIG_INOTIFY_USER=y
909# CONFIG_QUOTA is not set 922# CONFIG_QUOTA is not set
910# CONFIG_AUTOFS_FS is not set 923# CONFIG_AUTOFS_FS is not set
911# CONFIG_AUTOFS4_FS is not set 924# CONFIG_AUTOFS4_FS is not set
912CONFIG_FUSE_FS=y 925CONFIG_FUSE_FS=y
926# CONFIG_CUSE is not set
913 927
914# 928#
915# Caches 929# Caches
@@ -1033,6 +1047,7 @@ CONFIG_TIMER_STATS=y
1033# CONFIG_DEBUG_OBJECTS is not set 1047# CONFIG_DEBUG_OBJECTS is not set
1034# CONFIG_SLUB_DEBUG_ON is not set 1048# CONFIG_SLUB_DEBUG_ON is not set
1035# CONFIG_SLUB_STATS is not set 1049# CONFIG_SLUB_STATS is not set
1050# CONFIG_DEBUG_KMEMLEAK is not set
1036# CONFIG_DEBUG_PREEMPT is not set 1051# CONFIG_DEBUG_PREEMPT is not set
1037# CONFIG_DEBUG_RT_MUTEXES is not set 1052# CONFIG_DEBUG_RT_MUTEXES is not set
1038# CONFIG_RT_MUTEX_TESTER is not set 1053# CONFIG_RT_MUTEX_TESTER is not set
@@ -1063,18 +1078,16 @@ CONFIG_DEBUG_INFO=y
1063# CONFIG_PAGE_POISONING is not set 1078# CONFIG_PAGE_POISONING is not set
1064CONFIG_HAVE_FUNCTION_TRACER=y 1079CONFIG_HAVE_FUNCTION_TRACER=y
1065CONFIG_TRACING_SUPPORT=y 1080CONFIG_TRACING_SUPPORT=y
1066 1081CONFIG_FTRACE=y
1067#
1068# Tracers
1069#
1070# CONFIG_FUNCTION_TRACER is not set 1082# CONFIG_FUNCTION_TRACER is not set
1071# CONFIG_IRQSOFF_TRACER is not set 1083# CONFIG_IRQSOFF_TRACER is not set
1072# CONFIG_PREEMPT_TRACER is not set 1084# CONFIG_PREEMPT_TRACER is not set
1073# CONFIG_SCHED_TRACER is not set 1085# CONFIG_SCHED_TRACER is not set
1074# CONFIG_CONTEXT_SWITCH_TRACER is not set 1086# CONFIG_ENABLE_DEFAULT_TRACERS is not set
1075# CONFIG_EVENT_TRACER is not set
1076# CONFIG_BOOT_TRACER is not set 1087# CONFIG_BOOT_TRACER is not set
1077# CONFIG_TRACE_BRANCH_PROFILING is not set 1088CONFIG_BRANCH_PROFILE_NONE=y
1089# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
1090# CONFIG_PROFILE_ALL_BRANCHES is not set
1078# CONFIG_STACK_TRACER is not set 1091# CONFIG_STACK_TRACER is not set
1079# CONFIG_KMEMTRACE is not set 1092# CONFIG_KMEMTRACE is not set
1080# CONFIG_WORKQUEUE_TRACER is not set 1093# CONFIG_WORKQUEUE_TRACER is not set
@@ -1109,6 +1122,7 @@ CONFIG_GENERIC_FIND_LAST_BIT=y
1109# CONFIG_CRC32 is not set 1122# CONFIG_CRC32 is not set
1110# CONFIG_CRC7 is not set 1123# CONFIG_CRC7 is not set
1111# CONFIG_LIBCRC32C is not set 1124# CONFIG_LIBCRC32C is not set
1125CONFIG_GENERIC_ALLOCATOR=y
1112CONFIG_HAS_IOMEM=y 1126CONFIG_HAS_IOMEM=y
1113CONFIG_HAS_IOPORT=y 1127CONFIG_HAS_IOPORT=y
1114CONFIG_HAS_DMA=y 1128CONFIG_HAS_DMA=y
diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index be962c1349c4..9c746af1bf6e 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -12,7 +12,7 @@
12 12
13/* PAGE_SHIFT determines the page size */ 13/* PAGE_SHIFT determines the page size */
14#define PAGE_SHIFT 12 14#define PAGE_SHIFT 12
15#define PAGE_SIZE (1UL << PAGE_SHIFT) 15#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
16#define PAGE_MASK (~(PAGE_SIZE-1)) 16#define PAGE_MASK (~(PAGE_SIZE-1))
17 17
18#ifndef __ASSEMBLY__ 18#ifndef __ASSEMBLY__
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index 1cd2d6416bda..c433c6c73112 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -285,15 +285,6 @@ extern struct page *empty_zero_page;
285#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG) 285#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG)
286#define pte_special(pte) (0) 286#define pte_special(pte) (0)
287 287
288/*
289 * The following only works if pte_present() is not true.
290 */
291#define pte_file(pte) (pte_val(pte) & L_PTE_FILE)
292#define pte_to_pgoff(x) (pte_val(x) >> 2)
293#define pgoff_to_pte(x) __pte(((x) << 2) | L_PTE_FILE)
294
295#define PTE_FILE_MAX_BITS 30
296
297#define PTE_BIT_FUNC(fn,op) \ 288#define PTE_BIT_FUNC(fn,op) \
298static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; } 289static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; }
299 290
@@ -384,16 +375,50 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
384 375
385extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 376extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
386 377
387/* Encode and decode a swap entry. 378/*
379 * Encode and decode a swap entry. Swap entries are stored in the Linux
380 * page tables as follows:
388 * 381 *
389 * We support up to 32GB of swap on 4k machines 382 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
383 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
384 * <--------------- offset --------------------> <--- type --> 0 0
385 *
386 * This gives us up to 127 swap files and 32GB per swap file. Note that
387 * the offset field is always non-zero.
390 */ 388 */
391#define __swp_type(x) (((x).val >> 2) & 0x7f) 389#define __SWP_TYPE_SHIFT 2
392#define __swp_offset(x) ((x).val >> 9) 390#define __SWP_TYPE_BITS 7
393#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << 2) | ((offset) << 9) }) 391#define __SWP_TYPE_MASK ((1 << __SWP_TYPE_BITS) - 1)
392#define __SWP_OFFSET_SHIFT (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT)
393
394#define __swp_type(x) (((x).val >> __SWP_TYPE_SHIFT) & __SWP_TYPE_MASK)
395#define __swp_offset(x) ((x).val >> __SWP_OFFSET_SHIFT)
396#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << __SWP_TYPE_SHIFT) | ((offset) << __SWP_OFFSET_SHIFT) })
397
394#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 398#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
395#define __swp_entry_to_pte(swp) ((pte_t) { (swp).val }) 399#define __swp_entry_to_pte(swp) ((pte_t) { (swp).val })
396 400
401/*
402 * It is an error for the kernel to have more swap files than we can
403 * encode in the PTEs. This ensures that we know when MAX_SWAPFILES
404 * is increased beyond what we presently support.
405 */
406#define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > __SWP_TYPE_BITS)
407
408/*
409 * Encode and decode a file entry. File entries are stored in the Linux
410 * page tables as follows:
411 *
412 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
413 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
414 * <------------------------ offset -------------------------> 1 0
415 */
416#define pte_file(pte) (pte_val(pte) & L_PTE_FILE)
417#define pte_to_pgoff(x) (pte_val(x) >> 2)
418#define pgoff_to_pte(x) __pte(((x) << 2) | L_PTE_FILE)
419
420#define PTE_FILE_MAX_BITS 30
421
397/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */ 422/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
398/* FIXME: this is not correct */ 423/* FIXME: this is not correct */
399#define kern_addr_valid(addr) (1) 424#define kern_addr_valid(addr) (1)
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index 4f8848260ee2..73394e50cbca 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -73,7 +73,7 @@ struct thread_info {
73 .task = &tsk, \ 73 .task = &tsk, \
74 .exec_domain = &default_exec_domain, \ 74 .exec_domain = &default_exec_domain, \
75 .flags = 0, \ 75 .flags = 0, \
76 .preempt_count = 1, \ 76 .preempt_count = INIT_PREEMPT_COUNT, \
77 .addr_limit = KERNEL_DS, \ 77 .addr_limit = KERNEL_DS, \
78 .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \ 78 .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
79 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \ 79 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 096f600dc8d8..b7c3490eaa24 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -98,17 +98,6 @@ unlock:
98 return 0; 98 return 0;
99} 99}
100 100
101/* Handle bad interrupts */
102static struct irq_desc bad_irq_desc = {
103 .handle_irq = handle_bad_irq,
104 .lock = __SPIN_LOCK_UNLOCKED(bad_irq_desc.lock),
105};
106
107#ifdef CONFIG_CPUMASK_OFFSTACK
108/* We are not allocating bad_irq_desc.affinity or .pending_mask */
109#error "ARM architecture does not support CONFIG_CPUMASK_OFFSTACK."
110#endif
111
112/* 101/*
113 * do_IRQ handles all hardware IRQ's. Decoded IRQs should not 102 * do_IRQ handles all hardware IRQ's. Decoded IRQs should not
114 * come via this function. Instead, they should provide their 103 * come via this function. Instead, they should provide their
@@ -124,10 +113,13 @@ asmlinkage void __exception asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
124 * Some hardware gives randomly wrong interrupts. Rather 113 * Some hardware gives randomly wrong interrupts. Rather
125 * than crashing, do something sensible. 114 * than crashing, do something sensible.
126 */ 115 */
127 if (irq >= NR_IRQS) 116 if (unlikely(irq >= NR_IRQS)) {
128 handle_bad_irq(irq, &bad_irq_desc); 117 if (printk_ratelimit())
129 else 118 printk(KERN_WARNING "Bad IRQ%u\n", irq);
119 ack_bad_irq(irq);
120 } else {
130 generic_handle_irq(irq); 121 generic_handle_irq(irq);
122 }
131 123
132 /* AT91 specific workaround */ 124 /* AT91 specific workaround */
133 irq_finish(irq); 125 irq_finish(irq);
@@ -165,10 +157,6 @@ void __init init_IRQ(void)
165 for (irq = 0; irq < NR_IRQS; irq++) 157 for (irq = 0; irq < NR_IRQS; irq++)
166 irq_desc[irq].status |= IRQ_NOREQUEST | IRQ_NOPROBE; 158 irq_desc[irq].status |= IRQ_NOREQUEST | IRQ_NOPROBE;
167 159
168#ifdef CONFIG_SMP
169 cpumask_setall(bad_irq_desc.affinity);
170 bad_irq_desc.node = smp_processor_id();
171#endif
172 init_arch_irq(); 160 init_arch_irq();
173} 161}
174 162
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 4340bf3d2c84..69371028a202 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -6,6 +6,7 @@
6#include <asm-generic/vmlinux.lds.h> 6#include <asm-generic/vmlinux.lds.h>
7#include <asm/thread_info.h> 7#include <asm/thread_info.h>
8#include <asm/memory.h> 8#include <asm/memory.h>
9#include <asm/page.h>
9 10
10OUTPUT_ARCH(arm) 11OUTPUT_ARCH(arm)
11ENTRY(stext) 12ENTRY(stext)
@@ -63,7 +64,7 @@ SECTIONS
63 usr/built-in.o(.init.ramfs) 64 usr/built-in.o(.init.ramfs)
64 __initramfs_end = .; 65 __initramfs_end = .;
65#endif 66#endif
66 . = ALIGN(4096); 67 . = ALIGN(PAGE_SIZE);
67 __per_cpu_load = .; 68 __per_cpu_load = .;
68 __per_cpu_start = .; 69 __per_cpu_start = .;
69 *(.data.percpu.page_aligned) 70 *(.data.percpu.page_aligned)
@@ -73,7 +74,7 @@ SECTIONS
73#ifndef CONFIG_XIP_KERNEL 74#ifndef CONFIG_XIP_KERNEL
74 __init_begin = _stext; 75 __init_begin = _stext;
75 INIT_DATA 76 INIT_DATA
76 . = ALIGN(4096); 77 . = ALIGN(PAGE_SIZE);
77 __init_end = .; 78 __init_end = .;
78#endif 79#endif
79 } 80 }
@@ -118,7 +119,7 @@ SECTIONS
118 *(.got) /* Global offset table */ 119 *(.got) /* Global offset table */
119 } 120 }
120 121
121 RODATA 122 RO_DATA(PAGE_SIZE)
122 123
123 _etext = .; /* End of text and rodata section */ 124 _etext = .; /* End of text and rodata section */
124 125
@@ -158,17 +159,17 @@ SECTIONS
158 *(.data.init_task) 159 *(.data.init_task)
159 160
160#ifdef CONFIG_XIP_KERNEL 161#ifdef CONFIG_XIP_KERNEL
161 . = ALIGN(4096); 162 . = ALIGN(PAGE_SIZE);
162 __init_begin = .; 163 __init_begin = .;
163 INIT_DATA 164 INIT_DATA
164 . = ALIGN(4096); 165 . = ALIGN(PAGE_SIZE);
165 __init_end = .; 166 __init_end = .;
166#endif 167#endif
167 168
168 . = ALIGN(4096); 169 . = ALIGN(PAGE_SIZE);
169 __nosave_begin = .; 170 __nosave_begin = .;
170 *(.data.nosave) 171 *(.data.nosave)
171 . = ALIGN(4096); 172 . = ALIGN(PAGE_SIZE);
172 __nosave_end = .; 173 __nosave_end = .;
173 174
174 /* 175 /*
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index cc270beadd5d..a55398ed1211 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -24,6 +24,8 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
26#include <linux/spi/at73c213.h> 26#include <linux/spi/at73c213.h>
27#include <linux/gpio_keys.h>
28#include <linux/input.h>
27#include <linux/clk.h> 29#include <linux/clk.h>
28 30
29#include <mach/hardware.h> 31#include <mach/hardware.h>
@@ -218,6 +220,56 @@ static struct gpio_led ek_leds[] = {
218 } 220 }
219}; 221};
220 222
223
224/*
225 * GPIO Buttons
226 */
227#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
228static struct gpio_keys_button ek_buttons[] = {
229 {
230 .gpio = AT91_PIN_PA30,
231 .code = BTN_3,
232 .desc = "Button 3",
233 .active_low = 1,
234 .wakeup = 1,
235 },
236 {
237 .gpio = AT91_PIN_PA31,
238 .code = BTN_4,
239 .desc = "Button 4",
240 .active_low = 1,
241 .wakeup = 1,
242 }
243};
244
245static struct gpio_keys_platform_data ek_button_data = {
246 .buttons = ek_buttons,
247 .nbuttons = ARRAY_SIZE(ek_buttons),
248};
249
250static struct platform_device ek_button_device = {
251 .name = "gpio-keys",
252 .id = -1,
253 .num_resources = 0,
254 .dev = {
255 .platform_data = &ek_button_data,
256 }
257};
258
259static void __init ek_add_device_buttons(void)
260{
261 at91_set_gpio_input(AT91_PIN_PA30, 1); /* btn3 */
262 at91_set_deglitch(AT91_PIN_PA30, 1);
263 at91_set_gpio_input(AT91_PIN_PA31, 1); /* btn4 */
264 at91_set_deglitch(AT91_PIN_PA31, 1);
265
266 platform_device_register(&ek_button_device);
267}
268#else
269static void __init ek_add_device_buttons(void) {}
270#endif
271
272
221static struct i2c_board_info __initdata ek_i2c_devices[] = { 273static struct i2c_board_info __initdata ek_i2c_devices[] = {
222 { 274 {
223 I2C_BOARD_INFO("24c512", 0x50), 275 I2C_BOARD_INFO("24c512", 0x50),
@@ -245,6 +297,8 @@ static void __init ek_board_init(void)
245 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices)); 297 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
246 /* LEDs */ 298 /* LEDs */
247 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); 299 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
300 /* Push Buttons */
301 ek_add_device_buttons();
248 /* PCK0 provides MCLK to the WM8731 */ 302 /* PCK0 provides MCLK to the WM8731 */
249 at91_set_B_periph(AT91_PIN_PC1, 0); 303 at91_set_B_periph(AT91_PIN_PC1, 0);
250 /* SSC (for WM8731) */ 304 /* SSC (for WM8731) */
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index 35e12a49d1a6..f6b5672cabd6 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -186,19 +186,21 @@ static struct fb_monspecs at91fb_default_monspecs = {
186static void at91_lcdc_power_control(int on) 186static void at91_lcdc_power_control(int on)
187{ 187{
188 if (on) 188 if (on)
189 at91_set_gpio_value(AT91_PIN_PA30, 0); /* power up */ 189 at91_set_gpio_value(AT91_PIN_PC1, 0); /* power up */
190 else 190 else
191 at91_set_gpio_value(AT91_PIN_PA30, 1); /* power down */ 191 at91_set_gpio_value(AT91_PIN_PC1, 1); /* power down */
192} 192}
193 193
194/* Driver datas */ 194/* Driver datas */
195static struct atmel_lcdfb_info __initdata ek_lcdc_data = { 195static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
196 .lcdcon_is_backlight = true,
196 .default_bpp = 16, 197 .default_bpp = 16,
197 .default_dmacon = ATMEL_LCDC_DMAEN, 198 .default_dmacon = ATMEL_LCDC_DMAEN,
198 .default_lcdcon2 = AT91SAM9RL_DEFAULT_LCDCON2, 199 .default_lcdcon2 = AT91SAM9RL_DEFAULT_LCDCON2,
199 .default_monspecs = &at91fb_default_monspecs, 200 .default_monspecs = &at91fb_default_monspecs,
200 .atmel_lcdfb_power_control = at91_lcdc_power_control, 201 .atmel_lcdfb_power_control = at91_lcdc_power_control,
201 .guard_time = 1, 202 .guard_time = 1,
203 .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB,
202}; 204};
203 205
204#else 206#else
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index e70fc7c66bbb..ed2a48a9ce74 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -36,7 +36,6 @@
36#include <mach/hwa742.h> 36#include <mach/hwa742.h>
37#include <mach/lcd_mipid.h> 37#include <mach/lcd_mipid.h>
38#include <mach/mmc.h> 38#include <mach/mmc.h>
39#include <mach/usb.h>
40#include <mach/clock.h> 39#include <mach/clock.h>
41 40
42#define ADS7846_PENDOWN_GPIO 15 41#define ADS7846_PENDOWN_GPIO 15
@@ -205,9 +204,11 @@ static int nokia770_mmc_get_cover_state(struct device *dev, int slot)
205static struct omap_mmc_platform_data nokia770_mmc2_data = { 204static struct omap_mmc_platform_data nokia770_mmc2_data = {
206 .nr_slots = 1, 205 .nr_slots = 1,
207 .dma_mask = 0xffffffff, 206 .dma_mask = 0xffffffff,
207 .max_freq = 12000000,
208 .slots[0] = { 208 .slots[0] = {
209 .set_power = nokia770_mmc_set_power, 209 .set_power = nokia770_mmc_set_power,
210 .get_cover_state = nokia770_mmc_get_cover_state, 210 .get_cover_state = nokia770_mmc_get_cover_state,
211 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
211 .name = "mmcblk", 212 .name = "mmcblk",
212 }, 213 },
213}; 214};
diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c
index 0af4d6c85b47..6810b4aeb02c 100644
--- a/arch/arm/mach-omap1/mailbox.c
+++ b/arch/arm/mach-omap1/mailbox.c
@@ -203,5 +203,5 @@ module_exit(omap1_mbox_exit);
203 203
204MODULE_LICENSE("GPL v2"); 204MODULE_LICENSE("GPL v2");
205MODULE_DESCRIPTION("omap mailbox: omap1 architecture specific functions"); 205MODULE_DESCRIPTION("omap mailbox: omap1 architecture specific functions");
206MODULE_AUTHOR("Hiroshi DOYU" <Hiroshi.DOYU@nokia.com>); 206MODULE_AUTHOR("Hiroshi DOYU <Hiroshi.DOYU@nokia.com>");
207MODULE_ALIAS("platform:omap1-mailbox"); 207MODULE_ALIAS("platform:omap1-mailbox");
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index da93b86234ed..9a0bf6744a05 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -362,6 +362,7 @@ static struct omap_onenand_platform_data board_onenand_data = {
362 .gpio_irq = 65, 362 .gpio_irq = 65,
363 .parts = onenand_partitions, 363 .parts = onenand_partitions,
364 .nr_parts = ARRAY_SIZE(onenand_partitions), 364 .nr_parts = ARRAY_SIZE(onenand_partitions),
365 .flags = ONENAND_SYNC_READWRITE,
365}; 366};
366 367
367static void __init board_onenand_init(void) 368static void __init board_onenand_init(void)
diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c
index 2fd22f9c5f0e..54fec53a48e7 100644
--- a/arch/arm/mach-omap2/gpmc-onenand.c
+++ b/arch/arm/mach-omap2/gpmc-onenand.c
@@ -31,6 +31,8 @@ static struct platform_device gpmc_onenand_device = {
31static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base) 31static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)
32{ 32{
33 struct gpmc_timings t; 33 struct gpmc_timings t;
34 u32 reg;
35 int err;
34 36
35 const int t_cer = 15; 37 const int t_cer = 15;
36 const int t_avdp = 12; 38 const int t_avdp = 12;
@@ -43,6 +45,11 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)
43 const int t_wpl = 40; 45 const int t_wpl = 40;
44 const int t_wph = 30; 46 const int t_wph = 30;
45 47
48 /* Ensure sync read and sync write are disabled */
49 reg = readw(onenand_base + ONENAND_REG_SYS_CFG1);
50 reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE;
51 writew(reg, onenand_base + ONENAND_REG_SYS_CFG1);
52
46 memset(&t, 0, sizeof(t)); 53 memset(&t, 0, sizeof(t));
47 t.sync_clk = 0; 54 t.sync_clk = 0;
48 t.cs_on = 0; 55 t.cs_on = 0;
@@ -74,7 +81,16 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)
74 GPMC_CONFIG1_DEVICESIZE_16 | 81 GPMC_CONFIG1_DEVICESIZE_16 |
75 GPMC_CONFIG1_MUXADDDATA); 82 GPMC_CONFIG1_MUXADDDATA);
76 83
77 return gpmc_cs_set_timings(cs, &t); 84 err = gpmc_cs_set_timings(cs, &t);
85 if (err)
86 return err;
87
88 /* Ensure sync read and sync write are disabled */
89 reg = readw(onenand_base + ONENAND_REG_SYS_CFG1);
90 reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE;
91 writew(reg, onenand_base + ONENAND_REG_SYS_CFG1);
92
93 return 0;
78} 94}
79 95
80static void set_onenand_cfg(void __iomem *onenand_base, int latency, 96static void set_onenand_cfg(void __iomem *onenand_base, int latency,
@@ -124,7 +140,8 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
124 } else if (cfg->flags & ONENAND_SYNC_READWRITE) { 140 } else if (cfg->flags & ONENAND_SYNC_READWRITE) {
125 sync_read = 1; 141 sync_read = 1;
126 sync_write = 1; 142 sync_write = 1;
127 } 143 } else
144 return omap2_onenand_set_async_mode(cs, onenand_base);
128 145
129 if (!freq) { 146 if (!freq) {
130 /* Very first call freq is not known */ 147 /* Very first call freq is not known */
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 458990e20c60..a98201cc265c 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -48,6 +48,28 @@ int omap_chip_is(struct omap_chip_id oci)
48} 48}
49EXPORT_SYMBOL(omap_chip_is); 49EXPORT_SYMBOL(omap_chip_is);
50 50
51int omap_type(void)
52{
53 u32 val = 0;
54
55 if (cpu_is_omap24xx())
56 val = omap_ctrl_readl(OMAP24XX_CONTROL_STATUS);
57 else if (cpu_is_omap34xx())
58 val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
59 else {
60 pr_err("Cannot detect omap type!\n");
61 goto out;
62 }
63
64 val &= OMAP2_DEVICETYPE_MASK;
65 val >>= 8;
66
67out:
68 return val;
69}
70EXPORT_SYMBOL(omap_type);
71
72
51/*----------------------------------------------------------------------------*/ 73/*----------------------------------------------------------------------------*/
52 74
53#define OMAP_TAP_IDCODE 0x0204 75#define OMAP_TAP_IDCODE 0x0204
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index fd5b8a5925cc..6f71f3730c97 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -282,12 +282,12 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev)
282 return -ENOMEM; 282 return -ENOMEM;
283 283
284 /* DSP or IVA2 IRQ */ 284 /* DSP or IVA2 IRQ */
285 mbox_dsp_info.irq = platform_get_irq(pdev, 0); 285 ret = platform_get_irq(pdev, 0);
286 if (mbox_dsp_info.irq < 0) { 286 if (ret < 0) {
287 dev_err(&pdev->dev, "invalid irq resource\n"); 287 dev_err(&pdev->dev, "invalid irq resource\n");
288 ret = -ENODEV;
289 goto err_dsp; 288 goto err_dsp;
290 } 289 }
290 mbox_dsp_info.irq = ret;
291 291
292 ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info); 292 ret = omap_mbox_register(&pdev->dev, &mbox_dsp_info);
293 if (ret) 293 if (ret)
diff --git a/arch/arm/mach-omap2/mmc-twl4030.c b/arch/arm/mach-omap2/mmc-twl4030.c
index 9756a878fd90..1541fd4c8d0f 100644
--- a/arch/arm/mach-omap2/mmc-twl4030.c
+++ b/arch/arm/mach-omap2/mmc-twl4030.c
@@ -263,8 +263,19 @@ static int twl_mmc1_set_power(struct device *dev, int slot, int power_on,
263static int twl_mmc23_set_power(struct device *dev, int slot, int power_on, int vdd) 263static int twl_mmc23_set_power(struct device *dev, int slot, int power_on, int vdd)
264{ 264{
265 int ret = 0; 265 int ret = 0;
266 struct twl_mmc_controller *c = &hsmmc[1]; 266 struct twl_mmc_controller *c = NULL;
267 struct omap_mmc_platform_data *mmc = dev->platform_data; 267 struct omap_mmc_platform_data *mmc = dev->platform_data;
268 int i;
269
270 for (i = 1; i < ARRAY_SIZE(hsmmc); i++) {
271 if (mmc == hsmmc[i].mmc) {
272 c = &hsmmc[i];
273 break;
274 }
275 }
276
277 if (c == NULL)
278 return -ENODEV;
268 279
269 /* If we don't see a Vcc regulator, assume it's a fixed 280 /* If we don't see a Vcc regulator, assume it's a fixed
270 * voltage always-on regulator. 281 * voltage always-on regulator.
diff --git a/arch/arm/mach-s3c2440/mach-mini2440.c b/arch/arm/mach-s3c2440/mach-mini2440.c
index 6a5bc3021bdb..ec71a6965786 100644
--- a/arch/arm/mach-s3c2440/mach-mini2440.c
+++ b/arch/arm/mach-s3c2440/mach-mini2440.c
@@ -48,8 +48,6 @@
48#include <plat/mci.h> 48#include <plat/mci.h>
49#include <plat/udc.h> 49#include <plat/udc.h>
50 50
51#include <plat/regs-serial.h>
52
53#include <linux/mtd/mtd.h> 51#include <linux/mtd/mtd.h>
54#include <linux/mtd/nand.h> 52#include <linux/mtd/nand.h>
55#include <linux/mtd/nand_ecc.h> 53#include <linux/mtd/nand_ecc.h>
@@ -275,6 +273,7 @@ static struct s3c2410_nand_set mini2440_nand_sets[] __initdata = {
275 .nr_chips = 1, 273 .nr_chips = 1,
276 .nr_partitions = ARRAY_SIZE(mini2440_default_nand_part), 274 .nr_partitions = ARRAY_SIZE(mini2440_default_nand_part),
277 .partitions = mini2440_default_nand_part, 275 .partitions = mini2440_default_nand_part,
276 .flash_bbt = 1, /* we use u-boot to create a BBT */
278 }, 277 },
279}; 278};
280 279
diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c
index e23b581aa0e1..0fb385bd9cd9 100644
--- a/arch/arm/mach-s3c2442/mach-gta02.c
+++ b/arch/arm/mach-s3c2442/mach-gta02.c
@@ -433,8 +433,7 @@ static struct s3c2410_nand_set gta02_nand_sets[] = {
433 */ 433 */
434 .name = "neo1973-nand", 434 .name = "neo1973-nand",
435 .nr_chips = 1, 435 .nr_chips = 1,
436 .use_bbt = 1, 436 .flash_bbt = 1,
437 .force_soft_ecc = 1,
438 }, 437 },
439}; 438};
440 439
diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
index 5cd04d6751b3..111f7ea32b38 100644
--- a/arch/arm/mach-u300/clock.c
+++ b/arch/arm/mach-u300/clock.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/timer.h> 25#include <linux/timer.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/seq_file.h>
27 28
28#include <asm/clkdev.h> 29#include <asm/clkdev.h>
29#include <mach/hardware.h> 30#include <mach/hardware.h>
@@ -702,6 +703,7 @@ static struct clk amba_clk = {
702 .rate = 52000000, /* this varies! */ 703 .rate = 52000000, /* this varies! */
703 .hw_ctrld = true, 704 .hw_ctrld = true,
704 .reset = false, 705 .reset = false,
706 .lock = __SPIN_LOCK_UNLOCKED(amba_clk.lock),
705}; 707};
706 708
707/* 709/*
@@ -720,6 +722,7 @@ static struct clk cpu_clk = {
720 .set_rate = clk_set_rate_cpuclk, 722 .set_rate = clk_set_rate_cpuclk,
721 .get_rate = clk_get_rate_cpuclk, 723 .get_rate = clk_get_rate_cpuclk,
722 .round_rate = clk_round_rate_cpuclk, 724 .round_rate = clk_round_rate_cpuclk,
725 .lock = __SPIN_LOCK_UNLOCKED(cpu_clk.lock),
723}; 726};
724 727
725static struct clk nandif_clk = { 728static struct clk nandif_clk = {
@@ -732,6 +735,7 @@ static struct clk nandif_clk = {
732 .clk_val = U300_SYSCON_SBCER_NANDIF_CLK_EN, 735 .clk_val = U300_SYSCON_SBCER_NANDIF_CLK_EN,
733 .enable = syscon_clk_enable, 736 .enable = syscon_clk_enable,
734 .disable = syscon_clk_disable, 737 .disable = syscon_clk_disable,
738 .lock = __SPIN_LOCK_UNLOCKED(nandif_clk.lock),
735}; 739};
736 740
737static struct clk semi_clk = { 741static struct clk semi_clk = {
@@ -744,6 +748,7 @@ static struct clk semi_clk = {
744 .clk_val = U300_SYSCON_SBCER_SEMI_CLK_EN, 748 .clk_val = U300_SYSCON_SBCER_SEMI_CLK_EN,
745 .enable = syscon_clk_enable, 749 .enable = syscon_clk_enable,
746 .disable = syscon_clk_disable, 750 .disable = syscon_clk_disable,
751 .lock = __SPIN_LOCK_UNLOCKED(semi_clk.lock),
747}; 752};
748 753
749#ifdef CONFIG_MACH_U300_BS335 754#ifdef CONFIG_MACH_U300_BS335
@@ -758,6 +763,7 @@ static struct clk isp_clk = {
758 .clk_val = U300_SYSCON_SBCER_ISP_CLK_EN, 763 .clk_val = U300_SYSCON_SBCER_ISP_CLK_EN,
759 .enable = syscon_clk_enable, 764 .enable = syscon_clk_enable,
760 .disable = syscon_clk_disable, 765 .disable = syscon_clk_disable,
766 .lock = __SPIN_LOCK_UNLOCKED(isp_clk.lock),
761}; 767};
762 768
763static struct clk cds_clk = { 769static struct clk cds_clk = {
@@ -771,6 +777,7 @@ static struct clk cds_clk = {
771 .clk_val = U300_SYSCON_SBCER_CDS_CLK_EN, 777 .clk_val = U300_SYSCON_SBCER_CDS_CLK_EN,
772 .enable = syscon_clk_enable, 778 .enable = syscon_clk_enable,
773 .disable = syscon_clk_disable, 779 .disable = syscon_clk_disable,
780 .lock = __SPIN_LOCK_UNLOCKED(cds_clk.lock),
774}; 781};
775#endif 782#endif
776 783
@@ -785,6 +792,7 @@ static struct clk dma_clk = {
785 .clk_val = U300_SYSCON_SBCER_DMAC_CLK_EN, 792 .clk_val = U300_SYSCON_SBCER_DMAC_CLK_EN,
786 .enable = syscon_clk_enable, 793 .enable = syscon_clk_enable,
787 .disable = syscon_clk_disable, 794 .disable = syscon_clk_disable,
795 .lock = __SPIN_LOCK_UNLOCKED(dma_clk.lock),
788}; 796};
789 797
790static struct clk aaif_clk = { 798static struct clk aaif_clk = {
@@ -798,6 +806,7 @@ static struct clk aaif_clk = {
798 .clk_val = U300_SYSCON_SBCER_AAIF_CLK_EN, 806 .clk_val = U300_SYSCON_SBCER_AAIF_CLK_EN,
799 .enable = syscon_clk_enable, 807 .enable = syscon_clk_enable,
800 .disable = syscon_clk_disable, 808 .disable = syscon_clk_disable,
809 .lock = __SPIN_LOCK_UNLOCKED(aaif_clk.lock),
801}; 810};
802 811
803static struct clk apex_clk = { 812static struct clk apex_clk = {
@@ -811,6 +820,7 @@ static struct clk apex_clk = {
811 .clk_val = U300_SYSCON_SBCER_APEX_CLK_EN, 820 .clk_val = U300_SYSCON_SBCER_APEX_CLK_EN,
812 .enable = syscon_clk_enable, 821 .enable = syscon_clk_enable,
813 .disable = syscon_clk_disable, 822 .disable = syscon_clk_disable,
823 .lock = __SPIN_LOCK_UNLOCKED(apex_clk.lock),
814}; 824};
815 825
816static struct clk video_enc_clk = { 826static struct clk video_enc_clk = {
@@ -825,6 +835,7 @@ static struct clk video_enc_clk = {
825 .clk_val = U300_SYSCON_SBCER_VIDEO_ENC_CLK_EN, 835 .clk_val = U300_SYSCON_SBCER_VIDEO_ENC_CLK_EN,
826 .enable = syscon_clk_enable, 836 .enable = syscon_clk_enable,
827 .disable = syscon_clk_disable, 837 .disable = syscon_clk_disable,
838 .lock = __SPIN_LOCK_UNLOCKED(video_enc_clk.lock),
828}; 839};
829 840
830static struct clk xgam_clk = { 841static struct clk xgam_clk = {
@@ -839,6 +850,7 @@ static struct clk xgam_clk = {
839 .get_rate = clk_get_rate_xgamclk, 850 .get_rate = clk_get_rate_xgamclk,
840 .enable = syscon_clk_enable, 851 .enable = syscon_clk_enable,
841 .disable = syscon_clk_disable, 852 .disable = syscon_clk_disable,
853 .lock = __SPIN_LOCK_UNLOCKED(xgam_clk.lock),
842}; 854};
843 855
844/* This clock is used to activate the video encoder */ 856/* This clock is used to activate the video encoder */
@@ -854,6 +866,7 @@ static struct clk ahb_clk = {
854 .enable = syscon_clk_enable, 866 .enable = syscon_clk_enable,
855 .disable = syscon_clk_disable, 867 .disable = syscon_clk_disable,
856 .get_rate = clk_get_rate_ahb_clk, 868 .get_rate = clk_get_rate_ahb_clk,
869 .lock = __SPIN_LOCK_UNLOCKED(ahb_clk.lock),
857}; 870};
858 871
859 872
@@ -871,6 +884,7 @@ static struct clk ahb_subsys_clk = {
871 .enable = syscon_clk_enable, 884 .enable = syscon_clk_enable,
872 .disable = syscon_clk_disable, 885 .disable = syscon_clk_disable,
873 .get_rate = clk_get_rate_ahb_clk, 886 .get_rate = clk_get_rate_ahb_clk,
887 .lock = __SPIN_LOCK_UNLOCKED(ahb_subsys_clk.lock),
874}; 888};
875 889
876static struct clk intcon_clk = { 890static struct clk intcon_clk = {
@@ -882,6 +896,8 @@ static struct clk intcon_clk = {
882 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR, 896 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RRR,
883 .res_mask = U300_SYSCON_RRR_INTCON_RESET_EN, 897 .res_mask = U300_SYSCON_RRR_INTCON_RESET_EN,
884 /* INTCON can be reset but not clock-gated */ 898 /* INTCON can be reset but not clock-gated */
899 .lock = __SPIN_LOCK_UNLOCKED(intcon_clk.lock),
900
885}; 901};
886 902
887static struct clk mspro_clk = { 903static struct clk mspro_clk = {
@@ -895,6 +911,7 @@ static struct clk mspro_clk = {
895 .clk_val = U300_SYSCON_SBCER_MSPRO_CLK_EN, 911 .clk_val = U300_SYSCON_SBCER_MSPRO_CLK_EN,
896 .enable = syscon_clk_enable, 912 .enable = syscon_clk_enable,
897 .disable = syscon_clk_disable, 913 .disable = syscon_clk_disable,
914 .lock = __SPIN_LOCK_UNLOCKED(mspro_clk.lock),
898}; 915};
899 916
900static struct clk emif_clk = { 917static struct clk emif_clk = {
@@ -909,6 +926,7 @@ static struct clk emif_clk = {
909 .enable = syscon_clk_enable, 926 .enable = syscon_clk_enable,
910 .disable = syscon_clk_disable, 927 .disable = syscon_clk_disable,
911 .get_rate = clk_get_rate_emif_clk, 928 .get_rate = clk_get_rate_emif_clk,
929 .lock = __SPIN_LOCK_UNLOCKED(emif_clk.lock),
912}; 930};
913 931
914 932
@@ -926,6 +944,7 @@ static struct clk fast_clk = {
926 .clk_val = U300_SYSCON_SBCER_FAST_BRIDGE_CLK_EN, 944 .clk_val = U300_SYSCON_SBCER_FAST_BRIDGE_CLK_EN,
927 .enable = syscon_clk_enable, 945 .enable = syscon_clk_enable,
928 .disable = syscon_clk_disable, 946 .disable = syscon_clk_disable,
947 .lock = __SPIN_LOCK_UNLOCKED(fast_clk.lock),
929}; 948};
930 949
931static struct clk mmcsd_clk = { 950static struct clk mmcsd_clk = {
@@ -942,6 +961,7 @@ static struct clk mmcsd_clk = {
942 .round_rate = clk_round_rate_mclk, 961 .round_rate = clk_round_rate_mclk,
943 .disable = syscon_clk_disable, 962 .disable = syscon_clk_disable,
944 .enable = syscon_clk_enable, 963 .enable = syscon_clk_enable,
964 .lock = __SPIN_LOCK_UNLOCKED(mmcsd_clk.lock),
945}; 965};
946 966
947static struct clk i2s0_clk = { 967static struct clk i2s0_clk = {
@@ -956,6 +976,7 @@ static struct clk i2s0_clk = {
956 .enable = syscon_clk_enable, 976 .enable = syscon_clk_enable,
957 .disable = syscon_clk_disable, 977 .disable = syscon_clk_disable,
958 .get_rate = clk_get_rate_i2s_i2c_spi, 978 .get_rate = clk_get_rate_i2s_i2c_spi,
979 .lock = __SPIN_LOCK_UNLOCKED(i2s0_clk.lock),
959}; 980};
960 981
961static struct clk i2s1_clk = { 982static struct clk i2s1_clk = {
@@ -970,6 +991,7 @@ static struct clk i2s1_clk = {
970 .enable = syscon_clk_enable, 991 .enable = syscon_clk_enable,
971 .disable = syscon_clk_disable, 992 .disable = syscon_clk_disable,
972 .get_rate = clk_get_rate_i2s_i2c_spi, 993 .get_rate = clk_get_rate_i2s_i2c_spi,
994 .lock = __SPIN_LOCK_UNLOCKED(i2s1_clk.lock),
973}; 995};
974 996
975static struct clk i2c0_clk = { 997static struct clk i2c0_clk = {
@@ -984,6 +1006,7 @@ static struct clk i2c0_clk = {
984 .enable = syscon_clk_enable, 1006 .enable = syscon_clk_enable,
985 .disable = syscon_clk_disable, 1007 .disable = syscon_clk_disable,
986 .get_rate = clk_get_rate_i2s_i2c_spi, 1008 .get_rate = clk_get_rate_i2s_i2c_spi,
1009 .lock = __SPIN_LOCK_UNLOCKED(i2c0_clk.lock),
987}; 1010};
988 1011
989static struct clk i2c1_clk = { 1012static struct clk i2c1_clk = {
@@ -998,6 +1021,7 @@ static struct clk i2c1_clk = {
998 .enable = syscon_clk_enable, 1021 .enable = syscon_clk_enable,
999 .disable = syscon_clk_disable, 1022 .disable = syscon_clk_disable,
1000 .get_rate = clk_get_rate_i2s_i2c_spi, 1023 .get_rate = clk_get_rate_i2s_i2c_spi,
1024 .lock = __SPIN_LOCK_UNLOCKED(i2c1_clk.lock),
1001}; 1025};
1002 1026
1003static struct clk spi_clk = { 1027static struct clk spi_clk = {
@@ -1012,6 +1036,7 @@ static struct clk spi_clk = {
1012 .enable = syscon_clk_enable, 1036 .enable = syscon_clk_enable,
1013 .disable = syscon_clk_disable, 1037 .disable = syscon_clk_disable,
1014 .get_rate = clk_get_rate_i2s_i2c_spi, 1038 .get_rate = clk_get_rate_i2s_i2c_spi,
1039 .lock = __SPIN_LOCK_UNLOCKED(spi_clk.lock),
1015}; 1040};
1016 1041
1017#ifdef CONFIG_MACH_U300_BS335 1042#ifdef CONFIG_MACH_U300_BS335
@@ -1026,6 +1051,7 @@ static struct clk uart1_clk = {
1026 .clk_val = U300_SYSCON_SBCER_UART1_CLK_EN, 1051 .clk_val = U300_SYSCON_SBCER_UART1_CLK_EN,
1027 .enable = syscon_clk_enable, 1052 .enable = syscon_clk_enable,
1028 .disable = syscon_clk_disable, 1053 .disable = syscon_clk_disable,
1054 .lock = __SPIN_LOCK_UNLOCKED(uart1_clk.lock),
1029}; 1055};
1030#endif 1056#endif
1031 1057
@@ -1044,6 +1070,7 @@ static struct clk slow_clk = {
1044 .clk_val = U300_SYSCON_SBCER_SLOW_BRIDGE_CLK_EN, 1070 .clk_val = U300_SYSCON_SBCER_SLOW_BRIDGE_CLK_EN,
1045 .enable = syscon_clk_enable, 1071 .enable = syscon_clk_enable,
1046 .disable = syscon_clk_disable, 1072 .disable = syscon_clk_disable,
1073 .lock = __SPIN_LOCK_UNLOCKED(slow_clk.lock),
1047}; 1074};
1048 1075
1049/* TODO: implement SYSCON clock? */ 1076/* TODO: implement SYSCON clock? */
@@ -1055,6 +1082,7 @@ static struct clk wdog_clk = {
1055 .rate = 32768, 1082 .rate = 32768,
1056 .reset = false, 1083 .reset = false,
1057 /* This is always on, cannot be enabled/disabled or reset */ 1084 /* This is always on, cannot be enabled/disabled or reset */
1085 .lock = __SPIN_LOCK_UNLOCKED(wdog_clk.lock),
1058}; 1086};
1059 1087
1060/* This one is hardwired to PLL13 */ 1088/* This one is hardwired to PLL13 */
@@ -1069,6 +1097,7 @@ static struct clk uart_clk = {
1069 .clk_val = U300_SYSCON_SBCER_UART_CLK_EN, 1097 .clk_val = U300_SYSCON_SBCER_UART_CLK_EN,
1070 .enable = syscon_clk_enable, 1098 .enable = syscon_clk_enable,
1071 .disable = syscon_clk_disable, 1099 .disable = syscon_clk_disable,
1100 .lock = __SPIN_LOCK_UNLOCKED(uart_clk.lock),
1072}; 1101};
1073 1102
1074static struct clk keypad_clk = { 1103static struct clk keypad_clk = {
@@ -1082,6 +1111,7 @@ static struct clk keypad_clk = {
1082 .clk_val = U300_SYSCON_SBCER_KEYPAD_CLK_EN, 1111 .clk_val = U300_SYSCON_SBCER_KEYPAD_CLK_EN,
1083 .enable = syscon_clk_enable, 1112 .enable = syscon_clk_enable,
1084 .disable = syscon_clk_disable, 1113 .disable = syscon_clk_disable,
1114 .lock = __SPIN_LOCK_UNLOCKED(keypad_clk.lock),
1085}; 1115};
1086 1116
1087static struct clk gpio_clk = { 1117static struct clk gpio_clk = {
@@ -1095,6 +1125,7 @@ static struct clk gpio_clk = {
1095 .clk_val = U300_SYSCON_SBCER_GPIO_CLK_EN, 1125 .clk_val = U300_SYSCON_SBCER_GPIO_CLK_EN,
1096 .enable = syscon_clk_enable, 1126 .enable = syscon_clk_enable,
1097 .disable = syscon_clk_disable, 1127 .disable = syscon_clk_disable,
1128 .lock = __SPIN_LOCK_UNLOCKED(gpio_clk.lock),
1098}; 1129};
1099 1130
1100static struct clk rtc_clk = { 1131static struct clk rtc_clk = {
@@ -1106,6 +1137,7 @@ static struct clk rtc_clk = {
1106 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR, 1137 .res_reg = U300_SYSCON_VBASE + U300_SYSCON_RSR,
1107 .res_mask = U300_SYSCON_RSR_RTC_RESET_EN, 1138 .res_mask = U300_SYSCON_RSR_RTC_RESET_EN,
1108 /* This clock is always on, cannot be enabled/disabled */ 1139 /* This clock is always on, cannot be enabled/disabled */
1140 .lock = __SPIN_LOCK_UNLOCKED(rtc_clk.lock),
1109}; 1141};
1110 1142
1111static struct clk bustr_clk = { 1143static struct clk bustr_clk = {
@@ -1119,6 +1151,7 @@ static struct clk bustr_clk = {
1119 .clk_val = U300_SYSCON_SBCER_BTR_CLK_EN, 1151 .clk_val = U300_SYSCON_SBCER_BTR_CLK_EN,
1120 .enable = syscon_clk_enable, 1152 .enable = syscon_clk_enable,
1121 .disable = syscon_clk_disable, 1153 .disable = syscon_clk_disable,
1154 .lock = __SPIN_LOCK_UNLOCKED(bustr_clk.lock),
1122}; 1155};
1123 1156
1124static struct clk evhist_clk = { 1157static struct clk evhist_clk = {
@@ -1132,6 +1165,7 @@ static struct clk evhist_clk = {
1132 .clk_val = U300_SYSCON_SBCER_EH_CLK_EN, 1165 .clk_val = U300_SYSCON_SBCER_EH_CLK_EN,
1133 .enable = syscon_clk_enable, 1166 .enable = syscon_clk_enable,
1134 .disable = syscon_clk_disable, 1167 .disable = syscon_clk_disable,
1168 .lock = __SPIN_LOCK_UNLOCKED(evhist_clk.lock),
1135}; 1169};
1136 1170
1137static struct clk timer_clk = { 1171static struct clk timer_clk = {
@@ -1145,6 +1179,7 @@ static struct clk timer_clk = {
1145 .clk_val = U300_SYSCON_SBCER_ACC_TMR_CLK_EN, 1179 .clk_val = U300_SYSCON_SBCER_ACC_TMR_CLK_EN,
1146 .enable = syscon_clk_enable, 1180 .enable = syscon_clk_enable,
1147 .disable = syscon_clk_disable, 1181 .disable = syscon_clk_disable,
1182 .lock = __SPIN_LOCK_UNLOCKED(timer_clk.lock),
1148}; 1183};
1149 1184
1150static struct clk app_timer_clk = { 1185static struct clk app_timer_clk = {
@@ -1158,6 +1193,7 @@ static struct clk app_timer_clk = {
1158 .clk_val = U300_SYSCON_SBCER_APP_TMR_CLK_EN, 1193 .clk_val = U300_SYSCON_SBCER_APP_TMR_CLK_EN,
1159 .enable = syscon_clk_enable, 1194 .enable = syscon_clk_enable,
1160 .disable = syscon_clk_disable, 1195 .disable = syscon_clk_disable,
1196 .lock = __SPIN_LOCK_UNLOCKED(app_timer_clk.lock),
1161}; 1197};
1162 1198
1163#ifdef CONFIG_MACH_U300_BS335 1199#ifdef CONFIG_MACH_U300_BS335
@@ -1172,6 +1208,7 @@ static struct clk ppm_clk = {
1172 .clk_val = U300_SYSCON_SBCER_PPM_CLK_EN, 1208 .clk_val = U300_SYSCON_SBCER_PPM_CLK_EN,
1173 .enable = syscon_clk_enable, 1209 .enable = syscon_clk_enable,
1174 .disable = syscon_clk_disable, 1210 .disable = syscon_clk_disable,
1211 .lock = __SPIN_LOCK_UNLOCKED(ppm_clk.lock),
1175}; 1212};
1176#endif 1213#endif
1177 1214
@@ -1187,53 +1224,53 @@ static struct clk ppm_clk = {
1187 */ 1224 */
1188static struct clk_lookup lookups[] = { 1225static struct clk_lookup lookups[] = {
1189 /* Connected directly to the AMBA bus */ 1226 /* Connected directly to the AMBA bus */
1190 DEF_LOOKUP("amba", &amba_clk), 1227 DEF_LOOKUP("amba", &amba_clk),
1191 DEF_LOOKUP("cpu", &cpu_clk), 1228 DEF_LOOKUP("cpu", &cpu_clk),
1192 DEF_LOOKUP("nandif", &nandif_clk), 1229 DEF_LOOKUP("fsmc", &nandif_clk),
1193 DEF_LOOKUP("semi", &semi_clk), 1230 DEF_LOOKUP("semi", &semi_clk),
1194#ifdef CONFIG_MACH_U300_BS335 1231#ifdef CONFIG_MACH_U300_BS335
1195 DEF_LOOKUP("isp", &isp_clk), 1232 DEF_LOOKUP("isp", &isp_clk),
1196 DEF_LOOKUP("cds", &cds_clk), 1233 DEF_LOOKUP("cds", &cds_clk),
1197#endif 1234#endif
1198 DEF_LOOKUP("dma", &dma_clk), 1235 DEF_LOOKUP("dma", &dma_clk),
1199 DEF_LOOKUP("aaif", &aaif_clk), 1236 DEF_LOOKUP("msl", &aaif_clk),
1200 DEF_LOOKUP("apex", &apex_clk), 1237 DEF_LOOKUP("apex", &apex_clk),
1201 DEF_LOOKUP("video_enc", &video_enc_clk), 1238 DEF_LOOKUP("video_enc", &video_enc_clk),
1202 DEF_LOOKUP("xgam", &xgam_clk), 1239 DEF_LOOKUP("xgam", &xgam_clk),
1203 DEF_LOOKUP("ahb", &ahb_clk), 1240 DEF_LOOKUP("ahb", &ahb_clk),
1204 /* AHB bridge clocks */ 1241 /* AHB bridge clocks */
1205 DEF_LOOKUP("ahb", &ahb_subsys_clk), 1242 DEF_LOOKUP("ahb_subsys", &ahb_subsys_clk),
1206 DEF_LOOKUP("intcon", &intcon_clk), 1243 DEF_LOOKUP("intcon", &intcon_clk),
1207 DEF_LOOKUP("mspro", &mspro_clk), 1244 DEF_LOOKUP("mspro", &mspro_clk),
1208 DEF_LOOKUP("pl172", &emif_clk), 1245 DEF_LOOKUP("pl172", &emif_clk),
1209 /* FAST bridge clocks */ 1246 /* FAST bridge clocks */
1210 DEF_LOOKUP("fast", &fast_clk), 1247 DEF_LOOKUP("fast", &fast_clk),
1211 DEF_LOOKUP("mmci", &mmcsd_clk), 1248 DEF_LOOKUP("mmci", &mmcsd_clk),
1212 /* 1249 /*
1213 * The .0 and .1 identifiers on these comes from the platform device 1250 * The .0 and .1 identifiers on these comes from the platform device
1214 * .id field and are assigned when the platform devices are registered. 1251 * .id field and are assigned when the platform devices are registered.
1215 */ 1252 */
1216 DEF_LOOKUP("i2s.0", &i2s0_clk), 1253 DEF_LOOKUP("i2s.0", &i2s0_clk),
1217 DEF_LOOKUP("i2s.1", &i2s1_clk), 1254 DEF_LOOKUP("i2s.1", &i2s1_clk),
1218 DEF_LOOKUP("stddci2c.0", &i2c0_clk), 1255 DEF_LOOKUP("stu300.0", &i2c0_clk),
1219 DEF_LOOKUP("stddci2c.1", &i2c1_clk), 1256 DEF_LOOKUP("stu300.1", &i2c1_clk),
1220 DEF_LOOKUP("pl022", &spi_clk), 1257 DEF_LOOKUP("pl022", &spi_clk),
1221#ifdef CONFIG_MACH_U300_BS335 1258#ifdef CONFIG_MACH_U300_BS335
1222 DEF_LOOKUP("uart1", &uart1_clk), 1259 DEF_LOOKUP("uart1", &uart1_clk),
1223#endif 1260#endif
1224 /* SLOW bridge clocks */ 1261 /* SLOW bridge clocks */
1225 DEF_LOOKUP("slow", &slow_clk), 1262 DEF_LOOKUP("slow", &slow_clk),
1226 DEF_LOOKUP("wdog", &wdog_clk), 1263 DEF_LOOKUP("coh901327_wdog", &wdog_clk),
1227 DEF_LOOKUP("uart0", &uart_clk), 1264 DEF_LOOKUP("uart0", &uart_clk),
1228 DEF_LOOKUP("apptimer", &app_timer_clk), 1265 DEF_LOOKUP("apptimer", &app_timer_clk),
1229 DEF_LOOKUP("keypad", &keypad_clk), 1266 DEF_LOOKUP("coh901461-keypad", &keypad_clk),
1230 DEF_LOOKUP("u300-gpio", &gpio_clk), 1267 DEF_LOOKUP("u300-gpio", &gpio_clk),
1231 DEF_LOOKUP("rtc0", &rtc_clk), 1268 DEF_LOOKUP("rtc-coh901331", &rtc_clk),
1232 DEF_LOOKUP("bustr", &bustr_clk), 1269 DEF_LOOKUP("bustr", &bustr_clk),
1233 DEF_LOOKUP("evhist", &evhist_clk), 1270 DEF_LOOKUP("evhist", &evhist_clk),
1234 DEF_LOOKUP("timer", &timer_clk), 1271 DEF_LOOKUP("timer", &timer_clk),
1235#ifdef CONFIG_MACH_U300_BS335 1272#ifdef CONFIG_MACH_U300_BS335
1236 DEF_LOOKUP("ppm", &ppm_clk), 1273 DEF_LOOKUP("ppm", &ppm_clk),
1237#endif 1274#endif
1238}; 1275};
1239 1276
@@ -1427,16 +1464,20 @@ static const struct file_operations u300_clocks_operations = {
1427 .release = single_release, 1464 .release = single_release,
1428}; 1465};
1429 1466
1430static void init_clk_read_procfs(void) 1467static int __init init_clk_read_debugfs(void)
1431{ 1468{
1432 /* Expose a simple debugfs interface to view all clocks */ 1469 /* Expose a simple debugfs interface to view all clocks */
1433 (void) debugfs_create_file("u300_clocks", S_IFREG | S_IRUGO, 1470 (void) debugfs_create_file("u300_clocks", S_IFREG | S_IRUGO,
1434 NULL, NULL, &u300_clocks_operations); 1471 NULL, NULL,
1435} 1472 &u300_clocks_operations);
1436#else 1473 return 0;
1437static inline void init_clk_read_procfs(void)
1438{
1439} 1474}
1475/*
1476 * This needs to come in after the core_initcall() for the
1477 * overall clocks, because debugfs is not available until
1478 * the subsystems come up.
1479 */
1480module_init(init_clk_read_debugfs);
1440#endif 1481#endif
1441 1482
1442static int __init u300_clock_init(void) 1483static int __init u300_clock_init(void)
@@ -1462,8 +1503,6 @@ static int __init u300_clock_init(void)
1462 1503
1463 clk_register(); 1504 clk_register();
1464 1505
1465 init_clk_read_procfs();
1466
1467 /* 1506 /*
1468 * Some of these may be on when we boot the system so make sure they 1507 * Some of these may be on when we boot the system so make sure they
1469 * are turned OFF. 1508 * are turned OFF.
diff --git a/arch/arm/mm/proc-syms.c b/arch/arm/mm/proc-syms.c
index 195e48edd8c2..ac5c80062b70 100644
--- a/arch/arm/mm/proc-syms.c
+++ b/arch/arm/mm/proc-syms.c
@@ -27,6 +27,7 @@ EXPORT_SYMBOL(__cpuc_flush_kern_all);
27EXPORT_SYMBOL(__cpuc_flush_user_all); 27EXPORT_SYMBOL(__cpuc_flush_user_all);
28EXPORT_SYMBOL(__cpuc_flush_user_range); 28EXPORT_SYMBOL(__cpuc_flush_user_range);
29EXPORT_SYMBOL(__cpuc_coherent_kern_range); 29EXPORT_SYMBOL(__cpuc_coherent_kern_range);
30EXPORT_SYMBOL(__cpuc_flush_dcache_page);
30EXPORT_SYMBOL(dmac_inv_range); /* because of flush_ioremap_region() */ 31EXPORT_SYMBOL(dmac_inv_range); /* because of flush_ioremap_region() */
31#else 32#else
32EXPORT_SYMBOL(cpu_cache); 33EXPORT_SYMBOL(cpu_cache);
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index def14ec265b3..7677a4a1cef2 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -2457,6 +2457,19 @@ static int __init omap_init_dma(void)
2457 setup_irq(irq, &omap24xx_dma_irq); 2457 setup_irq(irq, &omap24xx_dma_irq);
2458 } 2458 }
2459 2459
2460 /* Enable smartidle idlemodes and autoidle */
2461 if (cpu_is_omap34xx()) {
2462 u32 v = dma_read(OCP_SYSCONFIG);
2463 v &= ~(DMA_SYSCONFIG_MIDLEMODE_MASK |
2464 DMA_SYSCONFIG_SIDLEMODE_MASK |
2465 DMA_SYSCONFIG_AUTOIDLE);
2466 v |= (DMA_SYSCONFIG_MIDLEMODE(DMA_IDLEMODE_SMARTIDLE) |
2467 DMA_SYSCONFIG_SIDLEMODE(DMA_IDLEMODE_SMARTIDLE) |
2468 DMA_SYSCONFIG_AUTOIDLE);
2469 dma_write(v , OCP_SYSCONFIG);
2470 }
2471
2472
2460 /* FIXME: Update LCD DMA to work on 24xx */ 2473 /* FIXME: Update LCD DMA to work on 24xx */
2461 if (cpu_class_is_omap1()) { 2474 if (cpu_class_is_omap1()) {
2462 r = request_irq(INT_DMA_LCD, lcd_dma_irq_handler, 0, 2475 r = request_irq(INT_DMA_LCD, lcd_dma_irq_handler, 0,
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 7fd89ba8d3b5..26b387c12423 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -1585,6 +1585,7 @@ static int __init _omap_gpio_init(void)
1585 __raw_writel(0x00000000, bank->base + OMAP24XX_GPIO_IRQENABLE1); 1585 __raw_writel(0x00000000, bank->base + OMAP24XX_GPIO_IRQENABLE1);
1586 __raw_writel(0xffffffff, bank->base + OMAP24XX_GPIO_IRQSTATUS1); 1586 __raw_writel(0xffffffff, bank->base + OMAP24XX_GPIO_IRQSTATUS1);
1587 __raw_writew(0x0015, bank->base + OMAP24XX_GPIO_SYSCONFIG); 1587 __raw_writew(0x0015, bank->base + OMAP24XX_GPIO_SYSCONFIG);
1588 __raw_writel(0x00000000, bank->base + OMAP24XX_GPIO_DEBOUNCE_EN);
1588 1589
1589 /* Initialize interface clock ungated, module enabled */ 1590 /* Initialize interface clock ungated, module enabled */
1590 __raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL); 1591 __raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
diff --git a/arch/arm/plat-omap/include/mach/cpu.h b/arch/arm/plat-omap/include/mach/cpu.h
index fc60c4ebcc28..285eaa3a8275 100644
--- a/arch/arm/plat-omap/include/mach/cpu.h
+++ b/arch/arm/plat-omap/include/mach/cpu.h
@@ -30,6 +30,17 @@
30#ifndef __ASM_ARCH_OMAP_CPU_H 30#ifndef __ASM_ARCH_OMAP_CPU_H
31#define __ASM_ARCH_OMAP_CPU_H 31#define __ASM_ARCH_OMAP_CPU_H
32 32
33/*
34 * Omap device type i.e. EMU/HS/TST/GP/BAD
35 */
36#define OMAP2_DEVICE_TYPE_TEST 0
37#define OMAP2_DEVICE_TYPE_EMU 1
38#define OMAP2_DEVICE_TYPE_SEC 2
39#define OMAP2_DEVICE_TYPE_GP 3
40#define OMAP2_DEVICE_TYPE_BAD 4
41
42int omap_type(void);
43
33struct omap_chip_id { 44struct omap_chip_id {
34 u8 oc; 45 u8 oc;
35 u8 type; 46 u8 type;
@@ -424,17 +435,6 @@ IS_OMAP_TYPE(3430, 0x3430)
424 435
425 436
426int omap_chip_is(struct omap_chip_id oci); 437int omap_chip_is(struct omap_chip_id oci);
427int omap_type(void);
428
429/*
430 * Macro to detect device type i.e. EMU/HS/TST/GP/BAD
431 */
432#define OMAP2_DEVICE_TYPE_TEST 0
433#define OMAP2_DEVICE_TYPE_EMU 1
434#define OMAP2_DEVICE_TYPE_SEC 2
435#define OMAP2_DEVICE_TYPE_GP 3
436#define OMAP2_DEVICE_TYPE_BAD 4
437
438void omap2_check_revision(void); 438void omap2_check_revision(void);
439 439
440#endif /* defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) */ 440#endif /* defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) */
diff --git a/arch/arm/plat-omap/include/mach/dma.h b/arch/arm/plat-omap/include/mach/dma.h
index 8c1eae88737e..7b939cc01962 100644
--- a/arch/arm/plat-omap/include/mach/dma.h
+++ b/arch/arm/plat-omap/include/mach/dma.h
@@ -389,6 +389,21 @@
389#define DMA_THREAD_FIFO_25 (0x02 << 14) 389#define DMA_THREAD_FIFO_25 (0x02 << 14)
390#define DMA_THREAD_FIFO_50 (0x03 << 14) 390#define DMA_THREAD_FIFO_50 (0x03 << 14)
391 391
392/* DMA4_OCP_SYSCONFIG bits */
393#define DMA_SYSCONFIG_MIDLEMODE_MASK (3 << 12)
394#define DMA_SYSCONFIG_CLOCKACTIVITY_MASK (3 << 8)
395#define DMA_SYSCONFIG_EMUFREE (1 << 5)
396#define DMA_SYSCONFIG_SIDLEMODE_MASK (3 << 3)
397#define DMA_SYSCONFIG_SOFTRESET (1 << 2)
398#define DMA_SYSCONFIG_AUTOIDLE (1 << 0)
399
400#define DMA_SYSCONFIG_MIDLEMODE(n) ((n) << 12)
401#define DMA_SYSCONFIG_SIDLEMODE(n) ((n) << 3)
402
403#define DMA_IDLEMODE_SMARTIDLE 0x2
404#define DMA_IDLEMODE_NO_IDLE 0x1
405#define DMA_IDLEMODE_FORCE_IDLE 0x0
406
392/* Chaining modes*/ 407/* Chaining modes*/
393#ifndef CONFIG_ARCH_OMAP1 408#ifndef CONFIG_ARCH_OMAP1
394#define OMAP_DMA_STATIC_CHAIN 0x1 409#define OMAP_DMA_STATIC_CHAIN 0x1
diff --git a/arch/arm/plat-omap/include/mach/io.h b/arch/arm/plat-omap/include/mach/io.h
index 3b2814720569..73f483d56ca6 100644
--- a/arch/arm/plat-omap/include/mach/io.h
+++ b/arch/arm/plat-omap/include/mach/io.h
@@ -201,7 +201,7 @@
201#define OMAP2_IO_ADDRESS(pa) IOMEM(__OMAP2_IO_ADDRESS(pa)) 201#define OMAP2_IO_ADDRESS(pa) IOMEM(__OMAP2_IO_ADDRESS(pa))
202 202
203#ifdef __ASSEMBLER__ 203#ifdef __ASSEMBLER__
204#define IOMEM(x) x 204#define IOMEM(x) (x)
205#else 205#else
206#define IOMEM(x) ((void __force __iomem *)(x)) 206#define IOMEM(x) ((void __force __iomem *)(x))
207 207
diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index 4cf449fa2cb5..4a0301399013 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -298,7 +298,7 @@ void flush_iotlb_page(struct iommu *obj, u32 da)
298 if ((start <= da) && (da < start + bytes)) { 298 if ((start <= da) && (da < start + bytes)) {
299 dev_dbg(obj->dev, "%s: %08x<=%08x(%x)\n", 299 dev_dbg(obj->dev, "%s: %08x<=%08x(%x)\n",
300 __func__, start, da, bytes); 300 __func__, start, da, bytes);
301 301 iotlb_load_cr(obj, &cr);
302 iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY); 302 iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY);
303 } 303 }
304 } 304 }
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 65006df3f1b7..4ea73804d21e 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -133,7 +133,12 @@ void __init omap_detect_sram(void)
133 if (cpu_is_omap34xx()) { 133 if (cpu_is_omap34xx()) {
134 omap_sram_base = OMAP3_SRAM_PUB_VA; 134 omap_sram_base = OMAP3_SRAM_PUB_VA;
135 omap_sram_start = OMAP3_SRAM_PUB_PA; 135 omap_sram_start = OMAP3_SRAM_PUB_PA;
136 omap_sram_size = 0x8000; /* 32K */ 136 if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) ||
137 (omap_type() == OMAP2_DEVICE_TYPE_SEC)) {
138 omap_sram_size = 0x7000; /* 28K */
139 } else {
140 omap_sram_size = 0x8000; /* 32K */
141 }
137 } else { 142 } else {
138 omap_sram_base = OMAP2_SRAM_PUB_VA; 143 omap_sram_base = OMAP2_SRAM_PUB_VA;
139 omap_sram_start = OMAP2_SRAM_PUB_PA; 144 omap_sram_start = OMAP2_SRAM_PUB_PA;
diff --git a/arch/arm/plat-s3c/Makefile b/arch/arm/plat-s3c/Makefile
index 74bb7cb5da49..0761766b1833 100644
--- a/arch/arm/plat-s3c/Makefile
+++ b/arch/arm/plat-s3c/Makefile
@@ -34,7 +34,7 @@ obj-$(CONFIG_S3C_DEV_HSMMC) += dev-hsmmc.o
34obj-$(CONFIG_S3C_DEV_HSMMC1) += dev-hsmmc1.o 34obj-$(CONFIG_S3C_DEV_HSMMC1) += dev-hsmmc1.o
35obj-y += dev-i2c0.o 35obj-y += dev-i2c0.o
36obj-$(CONFIG_S3C_DEV_I2C1) += dev-i2c1.o 36obj-$(CONFIG_S3C_DEV_I2C1) += dev-i2c1.o
37obj-$(CONFIG_SND_S3C24XX_SOC) += dev-audio.o 37obj-$(CONFIG_SND_S3C64XX_SOC_I2S) += dev-audio.o
38obj-$(CONFIG_S3C_DEV_FB) += dev-fb.o 38obj-$(CONFIG_S3C_DEV_FB) += dev-fb.o
39obj-$(CONFIG_S3C_DEV_USB_HOST) += dev-usb.o 39obj-$(CONFIG_S3C_DEV_USB_HOST) += dev-usb.o
40obj-$(CONFIG_S3C_DEV_USB_HSOTG) += dev-usb-hsotg.o 40obj-$(CONFIG_S3C_DEV_USB_HSOTG) += dev-usb-hsotg.o
diff --git a/arch/arm/plat-s3c/include/plat/devs.h b/arch/arm/plat-s3c/include/plat/devs.h
index b5b9c4d46e9a..2e170827e0b0 100644
--- a/arch/arm/plat-s3c/include/plat/devs.h
+++ b/arch/arm/plat-s3c/include/plat/devs.h
@@ -37,6 +37,7 @@ extern struct platform_device s3c_device_i2c1;
37extern struct platform_device s3c_device_rtc; 37extern struct platform_device s3c_device_rtc;
38extern struct platform_device s3c_device_adc; 38extern struct platform_device s3c_device_adc;
39extern struct platform_device s3c_device_sdi; 39extern struct platform_device s3c_device_sdi;
40extern struct platform_device s3c_device_iis;
40extern struct platform_device s3c_device_hwmon; 41extern struct platform_device s3c_device_hwmon;
41extern struct platform_device s3c_device_hsmmc0; 42extern struct platform_device s3c_device_hsmmc0;
42extern struct platform_device s3c_device_hsmmc1; 43extern struct platform_device s3c_device_hsmmc1;
diff --git a/arch/arm/plat-s3c24xx/Makefile b/arch/arm/plat-s3c24xx/Makefile
index 636cb12711df..579a165c2827 100644
--- a/arch/arm/plat-s3c24xx/Makefile
+++ b/arch/arm/plat-s3c24xx/Makefile
@@ -29,7 +29,7 @@ obj-$(CONFIG_PM_SIMTEC) += pm-simtec.o
29obj-$(CONFIG_PM) += pm.o 29obj-$(CONFIG_PM) += pm.o
30obj-$(CONFIG_PM) += irq-pm.o 30obj-$(CONFIG_PM) += irq-pm.o
31obj-$(CONFIG_PM) += sleep.o 31obj-$(CONFIG_PM) += sleep.o
32obj-$(CONFIG_HAVE_PWM) += pwm.o 32obj-$(CONFIG_S3C24XX_PWM) += pwm.o
33obj-$(CONFIG_S3C2410_CLOCK) += s3c2410-clock.o 33obj-$(CONFIG_S3C2410_CLOCK) += s3c2410-clock.o
34obj-$(CONFIG_S3C2410_DMA) += dma.o 34obj-$(CONFIG_S3C2410_DMA) += dma.o
35obj-$(CONFIG_S3C24XX_ADC) += adc.o 35obj-$(CONFIG_S3C24XX_ADC) += adc.o
diff --git a/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c b/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c
index 9edf7894eedd..da7a61728c18 100644
--- a/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c
+++ b/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c
@@ -12,8 +12,7 @@
12*/ 12*/
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15 15#include <linux/gpio.h>
16#include <mach/hardware.h>
17 16
18#include <mach/spi.h> 17#include <mach/spi.h>
19#include <mach/regs-gpio.h> 18#include <mach/regs-gpio.h>
diff --git a/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c b/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c
index f34d0fc69ad8..86b9edc67413 100644
--- a/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c
+++ b/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c
@@ -12,8 +12,7 @@
12*/ 12*/
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15 15#include <linux/gpio.h>
16#include <mach/hardware.h>
17 16
18#include <mach/spi.h> 17#include <mach/spi.h>
19#include <mach/regs-gpio.h> 18#include <mach/regs-gpio.h>
diff --git a/arch/avr32/include/asm/thread_info.h b/arch/avr32/include/asm/thread_info.h
index 4442f8d2d423..fc42de5ca209 100644
--- a/arch/avr32/include/asm/thread_info.h
+++ b/arch/avr32/include/asm/thread_info.h
@@ -40,7 +40,7 @@ struct thread_info {
40 .exec_domain = &default_exec_domain, \ 40 .exec_domain = &default_exec_domain, \
41 .flags = 0, \ 41 .flags = 0, \
42 .cpu = 0, \ 42 .cpu = 0, \
43 .preempt_count = 1, \ 43 .preempt_count = INIT_PREEMPT_COUNT, \
44 .restart_block = { \ 44 .restart_block = { \
45 .fn = do_no_restart_syscall \ 45 .fn = do_no_restart_syscall \
46 } \ 46 } \
diff --git a/arch/avr32/kernel/traps.c b/arch/avr32/kernel/traps.c
index 6e3d491184ea..b91b2044af9c 100644
--- a/arch/avr32/kernel/traps.c
+++ b/arch/avr32/kernel/traps.c
@@ -32,22 +32,25 @@ void NORET_TYPE die(const char *str, struct pt_regs *regs, long err)
32 spin_lock_irq(&die_lock); 32 spin_lock_irq(&die_lock);
33 bust_spinlocks(1); 33 bust_spinlocks(1);
34 34
35 printk(KERN_ALERT "Oops: %s, sig: %ld [#%d]\n" KERN_EMERG, 35 printk(KERN_ALERT "Oops: %s, sig: %ld [#%d]\n",
36 str, err, ++die_counter); 36 str, err, ++die_counter);
37
38 printk(KERN_EMERG);
39
37#ifdef CONFIG_PREEMPT 40#ifdef CONFIG_PREEMPT
38 printk("PREEMPT "); 41 printk(KERN_CONT "PREEMPT ");
39#endif 42#endif
40#ifdef CONFIG_FRAME_POINTER 43#ifdef CONFIG_FRAME_POINTER
41 printk("FRAME_POINTER "); 44 printk(KERN_CONT "FRAME_POINTER ");
42#endif 45#endif
43 if (current_cpu_data.features & AVR32_FEATURE_OCD) { 46 if (current_cpu_data.features & AVR32_FEATURE_OCD) {
44 unsigned long did = ocd_read(DID); 47 unsigned long did = ocd_read(DID);
45 printk("chip: 0x%03lx:0x%04lx rev %lu\n", 48 printk(KERN_CONT "chip: 0x%03lx:0x%04lx rev %lu\n",
46 (did >> 1) & 0x7ff, 49 (did >> 1) & 0x7ff,
47 (did >> 12) & 0x7fff, 50 (did >> 12) & 0x7fff,
48 (did >> 28) & 0xf); 51 (did >> 28) & 0xf);
49 } else { 52 } else {
50 printk("cpu: arch %u r%u / core %u r%u\n", 53 printk(KERN_CONT "cpu: arch %u r%u / core %u r%u\n",
51 current_cpu_data.arch_type, 54 current_cpu_data.arch_type,
52 current_cpu_data.arch_revision, 55 current_cpu_data.arch_revision,
53 current_cpu_data.cpu_type, 56 current_cpu_data.cpu_type,
diff --git a/arch/blackfin/include/asm/thread_info.h b/arch/blackfin/include/asm/thread_info.h
index 2920087516f2..2bbfdd950afc 100644
--- a/arch/blackfin/include/asm/thread_info.h
+++ b/arch/blackfin/include/asm/thread_info.h
@@ -77,7 +77,7 @@ struct thread_info {
77 .exec_domain = &default_exec_domain, \ 77 .exec_domain = &default_exec_domain, \
78 .flags = 0, \ 78 .flags = 0, \
79 .cpu = 0, \ 79 .cpu = 0, \
80 .preempt_count = 1, \ 80 .preempt_count = INIT_PREEMPT_COUNT, \
81 .restart_block = { \ 81 .restart_block = { \
82 .fn = do_no_restart_syscall, \ 82 .fn = do_no_restart_syscall, \
83 }, \ 83 }, \
diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
index d76618db50df..6a387eec6b65 100644
--- a/arch/blackfin/kernel/ptrace.c
+++ b/arch/blackfin/kernel/ptrace.c
@@ -31,7 +31,6 @@
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/smp.h> 33#include <linux/smp.h>
34#include <linux/smp_lock.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <linux/ptrace.h> 35#include <linux/ptrace.h>
37#include <linux/user.h> 36#include <linux/user.h>
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 298f023bcc09..6136c33e919f 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -408,13 +408,14 @@ static void __init print_memory_map(char *who)
408 bfin_memmap.map[i].addr + bfin_memmap.map[i].size); 408 bfin_memmap.map[i].addr + bfin_memmap.map[i].size);
409 switch (bfin_memmap.map[i].type) { 409 switch (bfin_memmap.map[i].type) {
410 case BFIN_MEMMAP_RAM: 410 case BFIN_MEMMAP_RAM:
411 printk("(usable)\n"); 411 printk(KERN_CONT "(usable)\n");
412 break; 412 break;
413 case BFIN_MEMMAP_RESERVED: 413 case BFIN_MEMMAP_RESERVED:
414 printk("(reserved)\n"); 414 printk(KERN_CONT "(reserved)\n");
415 break; 415 break;
416 default: printk("type %lu\n", bfin_memmap.map[i].type); 416 default:
417 break; 417 printk(KERN_CONT "type %lu\n", bfin_memmap.map[i].type);
418 break;
418 } 419 }
419 } 420 }
420} 421}
@@ -614,19 +615,19 @@ static __init void memory_setup(void)
614 printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20); 615 printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20);
615 616
616 printk(KERN_INFO "Memory map:\n" 617 printk(KERN_INFO "Memory map:\n"
617 KERN_INFO " fixedcode = 0x%p-0x%p\n" 618 " fixedcode = 0x%p-0x%p\n"
618 KERN_INFO " text = 0x%p-0x%p\n" 619 " text = 0x%p-0x%p\n"
619 KERN_INFO " rodata = 0x%p-0x%p\n" 620 " rodata = 0x%p-0x%p\n"
620 KERN_INFO " bss = 0x%p-0x%p\n" 621 " bss = 0x%p-0x%p\n"
621 KERN_INFO " data = 0x%p-0x%p\n" 622 " data = 0x%p-0x%p\n"
622 KERN_INFO " stack = 0x%p-0x%p\n" 623 " stack = 0x%p-0x%p\n"
623 KERN_INFO " init = 0x%p-0x%p\n" 624 " init = 0x%p-0x%p\n"
624 KERN_INFO " available = 0x%p-0x%p\n" 625 " available = 0x%p-0x%p\n"
625#ifdef CONFIG_MTD_UCLINUX 626#ifdef CONFIG_MTD_UCLINUX
626 KERN_INFO " rootfs = 0x%p-0x%p\n" 627 " rootfs = 0x%p-0x%p\n"
627#endif 628#endif
628#if DMA_UNCACHED_REGION > 0 629#if DMA_UNCACHED_REGION > 0
629 KERN_INFO " DMA Zone = 0x%p-0x%p\n" 630 " DMA Zone = 0x%p-0x%p\n"
630#endif 631#endif
631 , (void *)FIXED_CODE_START, (void *)FIXED_CODE_END, 632 , (void *)FIXED_CODE_START, (void *)FIXED_CODE_END,
632 _stext, _etext, 633 _stext, _etext,
@@ -859,13 +860,13 @@ void __init setup_arch(char **cmdline_p)
859#endif 860#endif
860 printk(KERN_INFO "Hardware Trace "); 861 printk(KERN_INFO "Hardware Trace ");
861 if (bfin_read_TBUFCTL() & 0x1) 862 if (bfin_read_TBUFCTL() & 0x1)
862 printk("Active "); 863 printk(KERN_CONT "Active ");
863 else 864 else
864 printk("Off "); 865 printk(KERN_CONT "Off ");
865 if (bfin_read_TBUFCTL() & 0x2) 866 if (bfin_read_TBUFCTL() & 0x2)
866 printk("and Enabled\n"); 867 printk(KERN_CONT "and Enabled\n");
867 else 868 else
868 printk("and Disabled\n"); 869 printk(KERN_CONT "and Disabled\n");
869 870
870#if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH) 871#if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH)
871 /* we need to initialize the Flashrom device here since we might 872 /* we need to initialize the Flashrom device here since we might
diff --git a/arch/blackfin/kernel/sys_bfin.c b/arch/blackfin/kernel/sys_bfin.c
index a8f1329c15a4..3da60fb13ce4 100644
--- a/arch/blackfin/kernel/sys_bfin.c
+++ b/arch/blackfin/kernel/sys_bfin.c
@@ -29,7 +29,6 @@
29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */ 30 */
31 31
32#include <linux/smp_lock.h>
33#include <linux/spinlock.h> 32#include <linux/spinlock.h>
34#include <linux/sem.h> 33#include <linux/sem.h>
35#include <linux/msg.h> 34#include <linux/msg.h>
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index 8eeb457ce5d5..8a1caf2bb5b9 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -212,7 +212,7 @@ asmlinkage void double_fault_c(struct pt_regs *fp)
212 console_verbose(); 212 console_verbose();
213 oops_in_progress = 1; 213 oops_in_progress = 1;
214#ifdef CONFIG_DEBUG_VERBOSE 214#ifdef CONFIG_DEBUG_VERBOSE
215 printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n"); 215 printk(KERN_EMERG "Double Fault\n");
216#ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT 216#ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT
217 if (((long)fp->seqstat & SEQSTAT_EXCAUSE) == VEC_UNCOV) { 217 if (((long)fp->seqstat & SEQSTAT_EXCAUSE) == VEC_UNCOV) {
218 unsigned int cpu = smp_processor_id(); 218 unsigned int cpu = smp_processor_id();
@@ -583,15 +583,14 @@ asmlinkage void trap_c(struct pt_regs *fp)
583#ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE 583#ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
584 if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M) 584 if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M)
585 verbose_printk(KERN_NOTICE "No trace since you do not have " 585 verbose_printk(KERN_NOTICE "No trace since you do not have "
586 "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n" 586 "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n\n");
587 KERN_NOTICE "\n");
588 else 587 else
589#endif 588#endif
590 dump_bfin_trace_buffer(); 589 dump_bfin_trace_buffer();
591 590
592 if (oops_in_progress) { 591 if (oops_in_progress) {
593 /* Dump the current kernel stack */ 592 /* Dump the current kernel stack */
594 verbose_printk(KERN_NOTICE "\n" KERN_NOTICE "Kernel Stack\n"); 593 verbose_printk(KERN_NOTICE "Kernel Stack\n");
595 show_stack(current, NULL); 594 show_stack(current, NULL);
596 print_modules(); 595 print_modules();
597#ifndef CONFIG_ACCESS_CHECK 596#ifndef CONFIG_ACCESS_CHECK
@@ -906,7 +905,7 @@ void show_stack(struct task_struct *task, unsigned long *stack)
906 905
907 ret_addr = 0; 906 ret_addr = 0;
908 if (!j && i % 8 == 0) 907 if (!j && i % 8 == 0)
909 printk("\n" KERN_NOTICE "%p:",addr); 908 printk(KERN_NOTICE "%p:",addr);
910 909
911 /* if it is an odd address, or zero, just skip it */ 910 /* if it is an odd address, or zero, just skip it */
912 if (*addr & 0x1 || !*addr) 911 if (*addr & 0x1 || !*addr)
@@ -996,9 +995,9 @@ void dump_bfin_process(struct pt_regs *fp)
996 995
997 printk(KERN_NOTICE "CPU = %d\n", current_thread_info()->cpu); 996 printk(KERN_NOTICE "CPU = %d\n", current_thread_info()->cpu);
998 if (!((unsigned long)current->mm & 0x3) && (unsigned long)current->mm >= FIXED_CODE_START) 997 if (!((unsigned long)current->mm & 0x3) && (unsigned long)current->mm >= FIXED_CODE_START)
999 verbose_printk(KERN_NOTICE "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n" 998 verbose_printk(KERN_NOTICE
1000 KERN_NOTICE " BSS = 0x%p-0x%p USER-STACK = 0x%p\n" 999 "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n"
1001 KERN_NOTICE "\n", 1000 " BSS = 0x%p-0x%p USER-STACK = 0x%p\n\n",
1002 (void *)current->mm->start_code, 1001 (void *)current->mm->start_code,
1003 (void *)current->mm->end_code, 1002 (void *)current->mm->end_code,
1004 (void *)current->mm->start_data, 1003 (void *)current->mm->start_data,
@@ -1009,8 +1008,8 @@ void dump_bfin_process(struct pt_regs *fp)
1009 else 1008 else
1010 verbose_printk(KERN_NOTICE "invalid mm\n"); 1009 verbose_printk(KERN_NOTICE "invalid mm\n");
1011 } else 1010 } else
1012 verbose_printk(KERN_NOTICE "\n" KERN_NOTICE 1011 verbose_printk(KERN_NOTICE
1013 "No Valid process in current context\n"); 1012 "No Valid process in current context\n");
1014#endif 1013#endif
1015} 1014}
1016 1015
@@ -1028,7 +1027,7 @@ void dump_bfin_mem(struct pt_regs *fp)
1028 addr < (unsigned short *)((unsigned long)erraddr & ~0xF) + 0x10; 1027 addr < (unsigned short *)((unsigned long)erraddr & ~0xF) + 0x10;
1029 addr++) { 1028 addr++) {
1030 if (!((unsigned long)addr & 0xF)) 1029 if (!((unsigned long)addr & 0xF))
1031 verbose_printk("\n" KERN_NOTICE "0x%p: ", addr); 1030 verbose_printk(KERN_NOTICE "0x%p: ", addr);
1032 1031
1033 if (!get_instruction(&val, addr)) { 1032 if (!get_instruction(&val, addr)) {
1034 val = 0; 1033 val = 0;
@@ -1056,9 +1055,9 @@ void dump_bfin_mem(struct pt_regs *fp)
1056 oops_in_progress)){ 1055 oops_in_progress)){
1057 verbose_printk(KERN_NOTICE "Looks like this was a deferred error - sorry\n"); 1056 verbose_printk(KERN_NOTICE "Looks like this was a deferred error - sorry\n");
1058#ifndef CONFIG_DEBUG_HWERR 1057#ifndef CONFIG_DEBUG_HWERR
1059 verbose_printk(KERN_NOTICE "The remaining message may be meaningless\n" 1058 verbose_printk(KERN_NOTICE
1060 KERN_NOTICE "You should enable CONFIG_DEBUG_HWERR to get a" 1059"The remaining message may be meaningless\n"
1061 " better idea where it came from\n"); 1060"You should enable CONFIG_DEBUG_HWERR to get a better idea where it came from\n");
1062#else 1061#else
1063 /* If we are handling only one peripheral interrupt 1062 /* If we are handling only one peripheral interrupt
1064 * and current mm and pid are valid, and the last error 1063 * and current mm and pid are valid, and the last error
@@ -1114,9 +1113,10 @@ void show_regs(struct pt_regs *fp)
1114 1113
1115 verbose_printk(KERN_NOTICE "%s", linux_banner); 1114 verbose_printk(KERN_NOTICE "%s", linux_banner);
1116 1115
1117 verbose_printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\t\t%s\n", print_tainted()); 1116 verbose_printk(KERN_NOTICE "\nSEQUENCER STATUS:\t\t%s\n",
1117 print_tainted());
1118 verbose_printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n", 1118 verbose_printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n",
1119 (long)fp->seqstat, fp->ipend, fp->syscfg); 1119 (long)fp->seqstat, fp->ipend, fp->syscfg);
1120 if ((fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR) { 1120 if ((fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR) {
1121 verbose_printk(KERN_NOTICE " HWERRCAUSE: 0x%lx\n", 1121 verbose_printk(KERN_NOTICE " HWERRCAUSE: 0x%lx\n",
1122 (fp->seqstat & SEQSTAT_HWERRCAUSE) >> 14); 1122 (fp->seqstat & SEQSTAT_HWERRCAUSE) >> 14);
@@ -1184,7 +1184,7 @@ unlock:
1184 verbose_printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf); 1184 verbose_printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf);
1185 } 1185 }
1186 1186
1187 verbose_printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n"); 1187 verbose_printk(KERN_NOTICE "PROCESSOR STATE:\n");
1188 verbose_printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n", 1188 verbose_printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n",
1189 fp->r0, fp->r1, fp->r2, fp->r3); 1189 fp->r0, fp->r1, fp->r2, fp->r3);
1190 verbose_printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n", 1190 verbose_printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n",
diff --git a/arch/cris/include/asm/thread_info.h b/arch/cris/include/asm/thread_info.h
index bc5b2935ca53..c3aade36c330 100644
--- a/arch/cris/include/asm/thread_info.h
+++ b/arch/cris/include/asm/thread_info.h
@@ -50,8 +50,6 @@ struct thread_info {
50 50
51/* 51/*
52 * macros/functions for gaining access to the thread information structure 52 * macros/functions for gaining access to the thread information structure
53 *
54 * preempt_count needs to be 1 initially, until the scheduler is functional.
55 */ 53 */
56#ifndef __ASSEMBLY__ 54#ifndef __ASSEMBLY__
57#define INIT_THREAD_INFO(tsk) \ 55#define INIT_THREAD_INFO(tsk) \
@@ -60,7 +58,7 @@ struct thread_info {
60 .exec_domain = &default_exec_domain, \ 58 .exec_domain = &default_exec_domain, \
61 .flags = 0, \ 59 .flags = 0, \
62 .cpu = 0, \ 60 .cpu = 0, \
63 .preempt_count = 1, \ 61 .preempt_count = INIT_PREEMPT_COUNT, \
64 .addr_limit = KERNEL_DS, \ 62 .addr_limit = KERNEL_DS, \
65 .restart_block = { \ 63 .restart_block = { \
66 .fn = do_no_restart_syscall, \ 64 .fn = do_no_restart_syscall, \
diff --git a/arch/cris/kernel/sys_cris.c b/arch/cris/kernel/sys_cris.c
index a79fbd87021b..2ad962c7e88e 100644
--- a/arch/cris/kernel/sys_cris.c
+++ b/arch/cris/kernel/sys_cris.c
@@ -15,7 +15,6 @@
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/smp_lock.h>
19#include <linux/sem.h> 18#include <linux/sem.h>
20#include <linux/msg.h> 19#include <linux/msg.h>
21#include <linux/shm.h> 20#include <linux/shm.h>
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index 8a5bd7a9c6f5..b86e19c9b5b0 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -7,6 +7,7 @@ config FRV
7 default y 7 default y
8 select HAVE_IDE 8 select HAVE_IDE
9 select HAVE_ARCH_TRACEHOOK 9 select HAVE_ARCH_TRACEHOOK
10 select HAVE_PERF_COUNTERS
10 11
11config ZONE_DMA 12config ZONE_DMA
12 bool 13 bool
diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
index 0409d981fd39..00a57af79afc 100644
--- a/arch/frv/include/asm/atomic.h
+++ b/arch/frv/include/asm/atomic.h
@@ -121,10 +121,72 @@ static inline void atomic_dec(atomic_t *v)
121#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) 121#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
122#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0) 122#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
123 123
124/*
125 * 64-bit atomic ops
126 */
127typedef struct {
128 volatile long long counter;
129} atomic64_t;
130
131#define ATOMIC64_INIT(i) { (i) }
132
133static inline long long atomic64_read(atomic64_t *v)
134{
135 long long counter;
136
137 asm("ldd%I1 %M1,%0"
138 : "=e"(counter)
139 : "m"(v->counter));
140 return counter;
141}
142
143static inline void atomic64_set(atomic64_t *v, long long i)
144{
145 asm volatile("std%I0 %1,%M0"
146 : "=m"(v->counter)
147 : "e"(i));
148}
149
150extern long long atomic64_inc_return(atomic64_t *v);
151extern long long atomic64_dec_return(atomic64_t *v);
152extern long long atomic64_add_return(long long i, atomic64_t *v);
153extern long long atomic64_sub_return(long long i, atomic64_t *v);
154
155static inline long long atomic64_add_negative(long long i, atomic64_t *v)
156{
157 return atomic64_add_return(i, v) < 0;
158}
159
160static inline void atomic64_add(long long i, atomic64_t *v)
161{
162 atomic64_add_return(i, v);
163}
164
165static inline void atomic64_sub(long long i, atomic64_t *v)
166{
167 atomic64_sub_return(i, v);
168}
169
170static inline void atomic64_inc(atomic64_t *v)
171{
172 atomic64_inc_return(v);
173}
174
175static inline void atomic64_dec(atomic64_t *v)
176{
177 atomic64_dec_return(v);
178}
179
180#define atomic64_sub_and_test(i,v) (atomic64_sub_return((i), (v)) == 0)
181#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
182#define atomic64_inc_and_test(v) (atomic64_inc_return((v)) == 0)
183
124/*****************************************************************************/ 184/*****************************************************************************/
125/* 185/*
126 * exchange value with memory 186 * exchange value with memory
127 */ 187 */
188extern uint64_t __xchg_64(uint64_t i, volatile void *v);
189
128#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS 190#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
129 191
130#define xchg(ptr, x) \ 192#define xchg(ptr, x) \
@@ -174,8 +236,10 @@ extern uint32_t __xchg_32(uint32_t i, volatile void *v);
174 236
175#define tas(ptr) (xchg((ptr), 1)) 237#define tas(ptr) (xchg((ptr), 1))
176 238
177#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new)) 239#define atomic_cmpxchg(v, old, new) (cmpxchg(&(v)->counter, old, new))
178#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 240#define atomic_xchg(v, new) (xchg(&(v)->counter, new))
241#define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
242#define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
179 243
180static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) 244static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
181{ 245{
diff --git a/arch/frv/include/asm/perf_counter.h b/arch/frv/include/asm/perf_counter.h
new file mode 100644
index 000000000000..ccf726e61b2e
--- /dev/null
+++ b/arch/frv/include/asm/perf_counter.h
@@ -0,0 +1,17 @@
1/* FRV performance counter support
2 *
3 * Copyright (C) 2009 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_PERF_COUNTER_H
13#define _ASM_PERF_COUNTER_H
14
15#define PERF_COUNTER_INDEX_OFFSET 0
16
17#endif /* _ASM_PERF_COUNTER_H */
diff --git a/arch/frv/include/asm/system.h b/arch/frv/include/asm/system.h
index 7742ec000cc4..efd22d9077ac 100644
--- a/arch/frv/include/asm/system.h
+++ b/arch/frv/include/asm/system.h
@@ -208,6 +208,8 @@ extern void free_initmem(void);
208 * - if (*ptr == test) then orig = *ptr; *ptr = test; 208 * - if (*ptr == test) then orig = *ptr; *ptr = test;
209 * - if (*ptr != test) then orig = *ptr; 209 * - if (*ptr != test) then orig = *ptr;
210 */ 210 */
211extern uint64_t __cmpxchg_64(uint64_t test, uint64_t new, volatile uint64_t *v);
212
211#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS 213#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
212 214
213#define cmpxchg(ptr, test, new) \ 215#define cmpxchg(ptr, test, new) \
diff --git a/arch/frv/include/asm/thread_info.h b/arch/frv/include/asm/thread_info.h
index e8a5ed7be021..e608e056bb53 100644
--- a/arch/frv/include/asm/thread_info.h
+++ b/arch/frv/include/asm/thread_info.h
@@ -56,8 +56,6 @@ struct thread_info {
56 56
57/* 57/*
58 * macros/functions for gaining access to the thread information structure 58 * macros/functions for gaining access to the thread information structure
59 *
60 * preempt_count needs to be 1 initially, until the scheduler is functional.
61 */ 59 */
62#ifndef __ASSEMBLY__ 60#ifndef __ASSEMBLY__
63 61
@@ -67,7 +65,7 @@ struct thread_info {
67 .exec_domain = &default_exec_domain, \ 65 .exec_domain = &default_exec_domain, \
68 .flags = 0, \ 66 .flags = 0, \
69 .cpu = 0, \ 67 .cpu = 0, \
70 .preempt_count = 1, \ 68 .preempt_count = INIT_PREEMPT_COUNT, \
71 .addr_limit = KERNEL_DS, \ 69 .addr_limit = KERNEL_DS, \
72 .restart_block = { \ 70 .restart_block = { \
73 .fn = do_no_restart_syscall, \ 71 .fn = do_no_restart_syscall, \
diff --git a/arch/frv/include/asm/unistd.h b/arch/frv/include/asm/unistd.h
index 96d78d5d2c41..4a8fb427ce0a 100644
--- a/arch/frv/include/asm/unistd.h
+++ b/arch/frv/include/asm/unistd.h
@@ -341,10 +341,12 @@
341#define __NR_inotify_init1 332 341#define __NR_inotify_init1 332
342#define __NR_preadv 333 342#define __NR_preadv 333
343#define __NR_pwritev 334 343#define __NR_pwritev 334
344#define __NR_rt_tgsigqueueinfo 335
345#define __NR_perf_counter_open 336
344 346
345#ifdef __KERNEL__ 347#ifdef __KERNEL__
346 348
347#define NR_syscalls 335 349#define NR_syscalls 337
348 350
349#define __ARCH_WANT_IPC_PARSE_VERSION 351#define __ARCH_WANT_IPC_PARSE_VERSION
350/* #define __ARCH_WANT_OLD_READDIR */ 352/* #define __ARCH_WANT_OLD_READDIR */
diff --git a/arch/frv/kernel/entry.S b/arch/frv/kernel/entry.S
index 356e0e327a89..fde1e446b440 100644
--- a/arch/frv/kernel/entry.S
+++ b/arch/frv/kernel/entry.S
@@ -1524,5 +1524,7 @@ sys_call_table:
1524 .long sys_inotify_init1 1524 .long sys_inotify_init1
1525 .long sys_preadv 1525 .long sys_preadv
1526 .long sys_pwritev 1526 .long sys_pwritev
1527 .long sys_rt_tgsigqueueinfo /* 335 */
1528 .long sys_perf_counter_open
1527 1529
1528syscall_table_size = (. - sys_call_table) 1530syscall_table_size = (. - sys_call_table)
diff --git a/arch/frv/kernel/frv_ksyms.c b/arch/frv/kernel/frv_ksyms.c
index 0316b3c50eff..a89803b58b9a 100644
--- a/arch/frv/kernel/frv_ksyms.c
+++ b/arch/frv/kernel/frv_ksyms.c
@@ -67,6 +67,10 @@ EXPORT_SYMBOL(atomic_sub_return);
67EXPORT_SYMBOL(__xchg_32); 67EXPORT_SYMBOL(__xchg_32);
68EXPORT_SYMBOL(__cmpxchg_32); 68EXPORT_SYMBOL(__cmpxchg_32);
69#endif 69#endif
70EXPORT_SYMBOL(atomic64_add_return);
71EXPORT_SYMBOL(atomic64_sub_return);
72EXPORT_SYMBOL(__xchg_64);
73EXPORT_SYMBOL(__cmpxchg_64);
70 74
71EXPORT_SYMBOL(__debug_bug_printk); 75EXPORT_SYMBOL(__debug_bug_printk);
72EXPORT_SYMBOL(__delay_loops_MHz); 76EXPORT_SYMBOL(__delay_loops_MHz);
diff --git a/arch/frv/lib/Makefile b/arch/frv/lib/Makefile
index 08be305c9f44..0a377210c89b 100644
--- a/arch/frv/lib/Makefile
+++ b/arch/frv/lib/Makefile
@@ -4,5 +4,5 @@
4 4
5lib-y := \ 5lib-y := \
6 __ashldi3.o __lshrdi3.o __muldi3.o __ashrdi3.o __negdi2.o __ucmpdi2.o \ 6 __ashldi3.o __lshrdi3.o __muldi3.o __ashrdi3.o __negdi2.o __ucmpdi2.o \
7 checksum.o memcpy.o memset.o atomic-ops.o \ 7 checksum.o memcpy.o memset.o atomic-ops.o atomic64-ops.o \
8 outsl_ns.o outsl_sw.o insl_ns.o insl_sw.o cache.o 8 outsl_ns.o outsl_sw.o insl_ns.o insl_sw.o cache.o perf_counter.o
diff --git a/arch/frv/lib/atomic-ops.S b/arch/frv/lib/atomic-ops.S
index ee0ac905fb08..5e9e6ab5dd0e 100644
--- a/arch/frv/lib/atomic-ops.S
+++ b/arch/frv/lib/atomic-ops.S
@@ -163,11 +163,10 @@ __cmpxchg_32:
163 ld.p @(gr11,gr0),gr8 163 ld.p @(gr11,gr0),gr8
164 orcr cc7,cc7,cc3 164 orcr cc7,cc7,cc3
165 subcc gr8,gr9,gr7,icc0 165 subcc gr8,gr9,gr7,icc0
166 bne icc0,#0,1f 166 bnelr icc0,#0
167 cst.p gr10,@(gr11,gr0) ,cc3,#1 167 cst.p gr10,@(gr11,gr0) ,cc3,#1
168 corcc gr29,gr29,gr0 ,cc3,#1 168 corcc gr29,gr29,gr0 ,cc3,#1
169 beq icc3,#0,0b 169 beq icc3,#0,0b
1701:
171 bralr 170 bralr
172 171
173 .size __cmpxchg_32, .-__cmpxchg_32 172 .size __cmpxchg_32, .-__cmpxchg_32
diff --git a/arch/frv/lib/atomic64-ops.S b/arch/frv/lib/atomic64-ops.S
new file mode 100644
index 000000000000..b6194eeac127
--- /dev/null
+++ b/arch/frv/lib/atomic64-ops.S
@@ -0,0 +1,162 @@
1/* kernel atomic64 operations
2 *
3 * For an explanation of how atomic ops work in this arch, see:
4 * Documentation/frv/atomic-ops.txt
5 *
6 * Copyright (C) 2009 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#include <asm/spr-regs.h>
16
17 .text
18 .balign 4
19
20
21###############################################################################
22#
23# long long atomic64_inc_return(atomic64_t *v)
24#
25###############################################################################
26 .globl atomic64_inc_return
27 .type atomic64_inc_return,@function
28atomic64_inc_return:
29 or.p gr8,gr8,gr10
300:
31 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
32 ckeq icc3,cc7
33 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
34 orcr cc7,cc7,cc3 /* set CC3 to true */
35 addicc gr9,#1,gr9,icc0
36 addxi gr8,#0,gr8,icc0
37 cstd.p gr8,@(gr10,gr0) ,cc3,#1
38 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
39 beq icc3,#0,0b
40 bralr
41
42 .size atomic64_inc_return, .-atomic64_inc_return
43
44###############################################################################
45#
46# long long atomic64_dec_return(atomic64_t *v)
47#
48###############################################################################
49 .globl atomic64_dec_return
50 .type atomic64_dec_return,@function
51atomic64_dec_return:
52 or.p gr8,gr8,gr10
530:
54 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
55 ckeq icc3,cc7
56 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
57 orcr cc7,cc7,cc3 /* set CC3 to true */
58 subicc gr9,#1,gr9,icc0
59 subxi gr8,#0,gr8,icc0
60 cstd.p gr8,@(gr10,gr0) ,cc3,#1
61 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
62 beq icc3,#0,0b
63 bralr
64
65 .size atomic64_dec_return, .-atomic64_dec_return
66
67###############################################################################
68#
69# long long atomic64_add_return(long long i, atomic64_t *v)
70#
71###############################################################################
72 .globl atomic64_add_return
73 .type atomic64_add_return,@function
74atomic64_add_return:
75 or.p gr8,gr8,gr4
76 or gr9,gr9,gr5
770:
78 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
79 ckeq icc3,cc7
80 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
81 orcr cc7,cc7,cc3 /* set CC3 to true */
82 addcc gr9,gr5,gr9,icc0
83 addx gr8,gr4,gr8,icc0
84 cstd.p gr8,@(gr10,gr0) ,cc3,#1
85 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
86 beq icc3,#0,0b
87 bralr
88
89 .size atomic64_add_return, .-atomic64_add_return
90
91###############################################################################
92#
93# long long atomic64_sub_return(long long i, atomic64_t *v)
94#
95###############################################################################
96 .globl atomic64_sub_return
97 .type atomic64_sub_return,@function
98atomic64_sub_return:
99 or.p gr8,gr8,gr4
100 or gr9,gr9,gr5
1010:
102 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
103 ckeq icc3,cc7
104 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
105 orcr cc7,cc7,cc3 /* set CC3 to true */
106 subcc gr9,gr5,gr9,icc0
107 subx gr8,gr4,gr8,icc0
108 cstd.p gr8,@(gr10,gr0) ,cc3,#1
109 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
110 beq icc3,#0,0b
111 bralr
112
113 .size atomic64_sub_return, .-atomic64_sub_return
114
115###############################################################################
116#
117# uint64_t __xchg_64(uint64_t i, uint64_t *v)
118#
119###############################################################################
120 .globl __xchg_64
121 .type __xchg_64,@function
122__xchg_64:
123 or.p gr8,gr8,gr4
124 or gr9,gr9,gr5
1250:
126 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
127 ckeq icc3,cc7
128 ldd.p @(gr10,gr0),gr8 /* LDD.P/ORCR must be atomic */
129 orcr cc7,cc7,cc3 /* set CC3 to true */
130 cstd.p gr4,@(gr10,gr0) ,cc3,#1
131 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
132 beq icc3,#0,0b
133 bralr
134
135 .size __xchg_64, .-__xchg_64
136
137###############################################################################
138#
139# uint64_t __cmpxchg_64(uint64_t test, uint64_t new, uint64_t *v)
140#
141###############################################################################
142 .globl __cmpxchg_64
143 .type __cmpxchg_64,@function
144__cmpxchg_64:
145 or.p gr8,gr8,gr4
146 or gr9,gr9,gr5
1470:
148 orcc gr0,gr0,gr0,icc3 /* set ICC3.Z */
149 ckeq icc3,cc7
150 ldd.p @(gr12,gr0),gr8 /* LDD.P/ORCR must be atomic */
151 orcr cc7,cc7,cc3
152 subcc gr8,gr4,gr0,icc0
153 subcc.p gr9,gr5,gr0,icc1
154 bnelr icc0,#0
155 bnelr icc1,#0
156 cstd.p gr10,@(gr12,gr0) ,cc3,#1
157 corcc gr29,gr29,gr0 ,cc3,#1 /* clear ICC3.Z if store happens */
158 beq icc3,#0,0b
159 bralr
160
161 .size __cmpxchg_64, .-__cmpxchg_64
162
diff --git a/arch/frv/lib/perf_counter.c b/arch/frv/lib/perf_counter.c
new file mode 100644
index 000000000000..2000feecd571
--- /dev/null
+++ b/arch/frv/lib/perf_counter.c
@@ -0,0 +1,19 @@
1/* Performance counter handling
2 *
3 * Copyright (C) 2009 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#include <linux/perf_counter.h>
13
14/*
15 * mark the performance counter as pending
16 */
17void set_perf_counter_pending(void)
18{
19}
diff --git a/arch/h8300/include/asm/thread_info.h b/arch/h8300/include/asm/thread_info.h
index 700014d2155f..8bbc8b0ee45d 100644
--- a/arch/h8300/include/asm/thread_info.h
+++ b/arch/h8300/include/asm/thread_info.h
@@ -36,7 +36,7 @@ struct thread_info {
36 .exec_domain = &default_exec_domain, \ 36 .exec_domain = &default_exec_domain, \
37 .flags = 0, \ 37 .flags = 0, \
38 .cpu = 0, \ 38 .cpu = 0, \
39 .preempt_count = 1, \ 39 .preempt_count = INIT_PREEMPT_COUNT, \
40 .restart_block = { \ 40 .restart_block = { \
41 .fn = do_no_restart_syscall, \ 41 .fn = do_no_restart_syscall, \
42 }, \ 42 }, \
diff --git a/arch/ia64/include/asm/thread_info.h b/arch/ia64/include/asm/thread_info.h
index ae6922626bf4..8ce2e388e37c 100644
--- a/arch/ia64/include/asm/thread_info.h
+++ b/arch/ia64/include/asm/thread_info.h
@@ -48,7 +48,7 @@ struct thread_info {
48 .flags = 0, \ 48 .flags = 0, \
49 .cpu = 0, \ 49 .cpu = 0, \
50 .addr_limit = KERNEL_DS, \ 50 .addr_limit = KERNEL_DS, \
51 .preempt_count = 0, \ 51 .preempt_count = INIT_PREEMPT_COUNT, \
52 .restart_block = { \ 52 .restart_block = { \
53 .fn = do_no_restart_syscall, \ 53 .fn = do_no_restart_syscall, \
54 }, \ 54 }, \
diff --git a/arch/ia64/kernel/esi.c b/arch/ia64/kernel/esi.c
index ebf4e988e78c..d5764a3d74af 100644
--- a/arch/ia64/kernel/esi.c
+++ b/arch/ia64/kernel/esi.c
@@ -65,7 +65,7 @@ static int __init esi_init (void)
65 } 65 }
66 66
67 if (!esi) 67 if (!esi)
68 return -ENODEV;; 68 return -ENODEV;
69 69
70 systab = __va(esi); 70 systab = __va(esi);
71 71
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index abce2468a40b..f1782705b1f7 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -5603,7 +5603,7 @@ pfm_interrupt_handler(int irq, void *arg)
5603 * /proc/perfmon interface, for debug only 5603 * /proc/perfmon interface, for debug only
5604 */ 5604 */
5605 5605
5606#define PFM_PROC_SHOW_HEADER ((void *)nr_cpu_ids+1) 5606#define PFM_PROC_SHOW_HEADER ((void *)(long)nr_cpu_ids+1)
5607 5607
5608static void * 5608static void *
5609pfm_proc_start(struct seq_file *m, loff_t *pos) 5609pfm_proc_start(struct seq_file *m, loff_t *pos)
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index 92c9689b7d97..9daa87fdb018 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -15,7 +15,6 @@
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/ptrace.h> 17#include <linux/ptrace.h>
18#include <linux/smp_lock.h>
19#include <linux/user.h> 18#include <linux/user.h>
20#include <linux/security.h> 19#include <linux/security.h>
21#include <linux/audit.h> 20#include <linux/audit.h>
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index 7053c55b7649..e6676fca4828 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -192,7 +192,7 @@ struct salinfo_platform_oemdata_parms {
192static void 192static void
193salinfo_work_to_do(struct salinfo_data *data) 193salinfo_work_to_do(struct salinfo_data *data)
194{ 194{
195 down_trylock(&data->mutex); 195 (void)(down_trylock(&data->mutex) ?: 0);
196 up(&data->mutex); 196 up(&data->mutex);
197} 197}
198 198
diff --git a/arch/ia64/kvm/kvm_lib.c b/arch/ia64/kvm/kvm_lib.c
index a85cb611ecd7..f1268b8e6f9e 100644
--- a/arch/ia64/kvm/kvm_lib.c
+++ b/arch/ia64/kvm/kvm_lib.c
@@ -11,5 +11,11 @@
11 * 11 *
12 */ 12 */
13#undef CONFIG_MODULES 13#undef CONFIG_MODULES
14#include <linux/module.h>
15#undef CONFIG_KALLSYMS
16#undef EXPORT_SYMBOL
17#undef EXPORT_SYMBOL_GPL
18#define EXPORT_SYMBOL(sym)
19#define EXPORT_SYMBOL_GPL(sym)
14#include "../../../lib/vsprintf.c" 20#include "../../../lib/vsprintf.c"
15#include "../../../lib/ctype.c" 21#include "../../../lib/ctype.c"
diff --git a/arch/ia64/kvm/process.c b/arch/ia64/kvm/process.c
index a8f84da04b49..bb862fb224f2 100644
--- a/arch/ia64/kvm/process.c
+++ b/arch/ia64/kvm/process.c
@@ -130,7 +130,7 @@ static void collect_interruption(struct kvm_vcpu *vcpu)
130 if (vdcr & IA64_DCR_PP) { 130 if (vdcr & IA64_DCR_PP) {
131 vpsr |= IA64_PSR_PP; 131 vpsr |= IA64_PSR_PP;
132 } else { 132 } else {
133 vpsr &= ~IA64_PSR_PP;; 133 vpsr &= ~IA64_PSR_PP;
134 } 134 }
135 135
136 vcpu_set_psr(vcpu, vpsr); 136 vcpu_set_psr(vcpu, vpsr);
@@ -594,11 +594,11 @@ static void set_pal_call_data(struct kvm_vcpu *vcpu)
594 p->u.pal_data.gr30 = vcpu_get_gr(vcpu, 30); 594 p->u.pal_data.gr30 = vcpu_get_gr(vcpu, 30);
595 break; 595 break;
596 case PAL_BRAND_INFO: 596 case PAL_BRAND_INFO:
597 p->u.pal_data.gr29 = gr29;; 597 p->u.pal_data.gr29 = gr29;
598 p->u.pal_data.gr30 = kvm_trans_pal_call_args(vcpu, gr30); 598 p->u.pal_data.gr30 = kvm_trans_pal_call_args(vcpu, gr30);
599 break; 599 break;
600 default: 600 default:
601 p->u.pal_data.gr29 = gr29;; 601 p->u.pal_data.gr29 = gr29;
602 p->u.pal_data.gr30 = vcpu_get_gr(vcpu, 30); 602 p->u.pal_data.gr30 = vcpu_get_gr(vcpu, 30);
603 } 603 }
604 p->u.pal_data.gr28 = gr28; 604 p->u.pal_data.gr28 = gr28;
diff --git a/arch/ia64/kvm/vcpu.c b/arch/ia64/kvm/vcpu.c
index a2c6c15e4761..46b02cbcc874 100644
--- a/arch/ia64/kvm/vcpu.c
+++ b/arch/ia64/kvm/vcpu.c
@@ -406,7 +406,7 @@ void getreg(unsigned long regnum, unsigned long *val,
406 * Now look at registers in [0-31] range and init correct UNAT 406 * Now look at registers in [0-31] range and init correct UNAT
407 */ 407 */
408 addr = (unsigned long)regs; 408 addr = (unsigned long)regs;
409 unat = &regs->eml_unat;; 409 unat = &regs->eml_unat;
410 410
411 addr += gr_info[regnum]; 411 addr += gr_info[regnum];
412 412
diff --git a/arch/ia64/kvm/vtlb.c b/arch/ia64/kvm/vtlb.c
index 4290a429bf7c..20b3852f7a6e 100644
--- a/arch/ia64/kvm/vtlb.c
+++ b/arch/ia64/kvm/vtlb.c
@@ -135,7 +135,7 @@ struct thash_data *__vtr_lookup(struct kvm_vcpu *vcpu, u64 va, int type)
135 u64 rid; 135 u64 rid;
136 136
137 rid = vcpu_get_rr(vcpu, va); 137 rid = vcpu_get_rr(vcpu, va);
138 rid = rid & RR_RID_MASK;; 138 rid = rid & RR_RID_MASK;
139 if (type == D_TLB) { 139 if (type == D_TLB) {
140 if (vcpu_quick_region_check(vcpu->arch.dtr_regions, va)) { 140 if (vcpu_quick_region_check(vcpu->arch.dtr_regions, va)) {
141 for (trp = (struct thash_data *)&vcpu->arch.dtrs, i = 0; 141 for (trp = (struct thash_data *)&vcpu->arch.dtrs, i = 0;
@@ -518,7 +518,7 @@ struct thash_data *vtlb_lookup(struct kvm_vcpu *v, u64 va, int is_data)
518 518
519 struct thash_cb *hcb = &v->arch.vtlb; 519 struct thash_cb *hcb = &v->arch.vtlb;
520 520
521 cch = __vtr_lookup(v, va, is_data);; 521 cch = __vtr_lookup(v, va, is_data);
522 if (cch) 522 if (cch)
523 return cch; 523 return cch;
524 524
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 729298f4b234..7de76dd352fe 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -537,7 +537,7 @@ pcibios_align_resource (void *data, struct resource *res,
537/* 537/*
538 * PCI BIOS setup, always defaults to SAL interface 538 * PCI BIOS setup, always defaults to SAL interface
539 */ 539 */
540char * __devinit 540char * __init
541pcibios_setup (char *str) 541pcibios_setup (char *str)
542{ 542{
543 return str; 543 return str;
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 76645cf6ac5d..25831c47c579 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -435,7 +435,8 @@ void sn_generate_path(struct pci_bus *pci_bus, char *address)
435 bricktype = MODULE_GET_BTYPE(moduleid); 435 bricktype = MODULE_GET_BTYPE(moduleid);
436 if ((bricktype == L1_BRICKTYPE_191010) || 436 if ((bricktype == L1_BRICKTYPE_191010) ||
437 (bricktype == L1_BRICKTYPE_1932)) 437 (bricktype == L1_BRICKTYPE_1932))
438 sprintf(address, "%s^%d", address, geo_slot(geoid)); 438 sprintf(address + strlen(address), "^%d",
439 geo_slot(geoid));
439} 440}
440 441
441void __devinit 442void __devinit
diff --git a/arch/m32r/include/asm/thread_info.h b/arch/m32r/include/asm/thread_info.h
index 8589d462df27..07bb5bd00e2a 100644
--- a/arch/m32r/include/asm/thread_info.h
+++ b/arch/m32r/include/asm/thread_info.h
@@ -57,8 +57,6 @@ struct thread_info {
57 57
58/* 58/*
59 * macros/functions for gaining access to the thread information structure 59 * macros/functions for gaining access to the thread information structure
60 *
61 * preempt_count needs to be 1 initially, until the scheduler is functional.
62 */ 60 */
63#ifndef __ASSEMBLY__ 61#ifndef __ASSEMBLY__
64 62
@@ -68,7 +66,7 @@ struct thread_info {
68 .exec_domain = &default_exec_domain, \ 66 .exec_domain = &default_exec_domain, \
69 .flags = 0, \ 67 .flags = 0, \
70 .cpu = 0, \ 68 .cpu = 0, \
71 .preempt_count = 1, \ 69 .preempt_count = INIT_PREEMPT_COUNT, \
72 .addr_limit = KERNEL_DS, \ 70 .addr_limit = KERNEL_DS, \
73 .restart_block = { \ 71 .restart_block = { \
74 .fn = do_no_restart_syscall, \ 72 .fn = do_no_restart_syscall, \
diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c
index bf0abe9e1f73..98b8feb12ed8 100644
--- a/arch/m32r/kernel/ptrace.c
+++ b/arch/m32r/kernel/ptrace.c
@@ -19,7 +19,6 @@
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/smp.h> 21#include <linux/smp.h>
22#include <linux/smp_lock.h>
23#include <linux/errno.h> 22#include <linux/errno.h>
24#include <linux/ptrace.h> 23#include <linux/ptrace.h>
25#include <linux/user.h> 24#include <linux/user.h>
diff --git a/arch/m68k/include/asm/thread_info_mm.h b/arch/m68k/include/asm/thread_info_mm.h
index af0fda46e94b..6ea5c33b3c56 100644
--- a/arch/m68k/include/asm/thread_info_mm.h
+++ b/arch/m68k/include/asm/thread_info_mm.h
@@ -19,6 +19,7 @@ struct thread_info {
19{ \ 19{ \
20 .task = &tsk, \ 20 .task = &tsk, \
21 .exec_domain = &default_exec_domain, \ 21 .exec_domain = &default_exec_domain, \
22 .preempt_count = INIT_PREEMPT_COUNT, \
22 .restart_block = { \ 23 .restart_block = { \
23 .fn = do_no_restart_syscall, \ 24 .fn = do_no_restart_syscall, \
24 }, \ 25 }, \
diff --git a/arch/m68k/include/asm/thread_info_no.h b/arch/m68k/include/asm/thread_info_no.h
index 82529f424ea3..c2bde5e24b0b 100644
--- a/arch/m68k/include/asm/thread_info_no.h
+++ b/arch/m68k/include/asm/thread_info_no.h
@@ -49,6 +49,7 @@ struct thread_info {
49 .exec_domain = &default_exec_domain, \ 49 .exec_domain = &default_exec_domain, \
50 .flags = 0, \ 50 .flags = 0, \
51 .cpu = 0, \ 51 .cpu = 0, \
52 .preempt_count = INIT_PREEMPT_COUNT, \
52 .restart_block = { \ 53 .restart_block = { \
53 .fn = do_no_restart_syscall, \ 54 .fn = do_no_restart_syscall, \
54 }, \ 55 }, \
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c
index 1e96c6eb6312..8f8f4abab2ff 100644
--- a/arch/m68knommu/kernel/process.c
+++ b/arch/m68knommu/kernel/process.c
@@ -290,7 +290,7 @@ void dump(struct pt_regs *fp)
290 unsigned char *tp; 290 unsigned char *tp;
291 int i; 291 int i;
292 292
293 printk(KERN_EMERG "\n" KERN_EMERG "CURRENT PROCESS:\n" KERN_EMERG "\n"); 293 printk(KERN_EMERG "\nCURRENT PROCESS:\n\n");
294 printk(KERN_EMERG "COMM=%s PID=%d\n", current->comm, current->pid); 294 printk(KERN_EMERG "COMM=%s PID=%d\n", current->comm, current->pid);
295 295
296 if (current->mm) { 296 if (current->mm) {
@@ -301,8 +301,7 @@ void dump(struct pt_regs *fp)
301 (int) current->mm->end_data, 301 (int) current->mm->end_data,
302 (int) current->mm->end_data, 302 (int) current->mm->end_data,
303 (int) current->mm->brk); 303 (int) current->mm->brk);
304 printk(KERN_EMERG "USER-STACK=%08x KERNEL-STACK=%08x\n" 304 printk(KERN_EMERG "USER-STACK=%08x KERNEL-STACK=%08x\n\n",
305 KERN_EMERG "\n",
306 (int) current->mm->start_stack, 305 (int) current->mm->start_stack,
307 (int)(((unsigned long) current) + THREAD_SIZE)); 306 (int)(((unsigned long) current) + THREAD_SIZE));
308 } 307 }
@@ -313,35 +312,35 @@ void dump(struct pt_regs *fp)
313 fp->d0, fp->d1, fp->d2, fp->d3); 312 fp->d0, fp->d1, fp->d2, fp->d3);
314 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n", 313 printk(KERN_EMERG "d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
315 fp->d4, fp->d5, fp->a0, fp->a1); 314 fp->d4, fp->d5, fp->a0, fp->a1);
316 printk(KERN_EMERG "\n" KERN_EMERG "USP: %08x TRAPFRAME: %08x\n", 315 printk(KERN_EMERG "\nUSP: %08x TRAPFRAME: %08x\n",
317 (unsigned int) rdusp(), (unsigned int) fp); 316 (unsigned int) rdusp(), (unsigned int) fp);
318 317
319 printk(KERN_EMERG "\n" KERN_EMERG "CODE:"); 318 printk(KERN_EMERG "\nCODE:");
320 tp = ((unsigned char *) fp->pc) - 0x20; 319 tp = ((unsigned char *) fp->pc) - 0x20;
321 for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) { 320 for (sp = (unsigned long *) tp, i = 0; (i < 0x40); i += 4) {
322 if ((i % 0x10) == 0) 321 if ((i % 0x10) == 0)
323 printk("\n" KERN_EMERG "%08x: ", (int) (tp + i)); 322 printk(KERN_EMERG "%08x: ", (int) (tp + i));
324 printk("%08x ", (int) *sp++); 323 printk("%08x ", (int) *sp++);
325 } 324 }
326 printk("\n" KERN_EMERG "\n"); 325 printk(KERN_EMERG "\n");
327 326
328 printk(KERN_EMERG "KERNEL STACK:"); 327 printk(KERN_EMERG "KERNEL STACK:");
329 tp = ((unsigned char *) fp) - 0x40; 328 tp = ((unsigned char *) fp) - 0x40;
330 for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) { 329 for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
331 if ((i % 0x10) == 0) 330 if ((i % 0x10) == 0)
332 printk("\n" KERN_EMERG "%08x: ", (int) (tp + i)); 331 printk(KERN_EMERG "%08x: ", (int) (tp + i));
333 printk("%08x ", (int) *sp++); 332 printk("%08x ", (int) *sp++);
334 } 333 }
335 printk("\n" KERN_EMERG "\n"); 334 printk(KERN_EMERG "\n");
336 335
337 printk(KERN_EMERG "USER STACK:"); 336 printk(KERN_EMERG "USER STACK:");
338 tp = (unsigned char *) (rdusp() - 0x10); 337 tp = (unsigned char *) (rdusp() - 0x10);
339 for (sp = (unsigned long *) tp, i = 0; (i < 0x80); i += 4) { 338 for (sp = (unsigned long *) tp, i = 0; (i < 0x80); i += 4) {
340 if ((i % 0x10) == 0) 339 if ((i % 0x10) == 0)
341 printk("\n" KERN_EMERG "%08x: ", (int) (tp + i)); 340 printk(KERN_EMERG "%08x: ", (int) (tp + i));
342 printk("%08x ", (int) *sp++); 341 printk("%08x ", (int) *sp++);
343 } 342 }
344 printk("\n" KERN_EMERG "\n"); 343 printk(KERN_EMERG "\n");
345} 344}
346 345
347/* 346/*
diff --git a/arch/m68knommu/kernel/traps.c b/arch/m68knommu/kernel/traps.c
index 51d325343ab5..3739c8f657d7 100644
--- a/arch/m68knommu/kernel/traps.c
+++ b/arch/m68knommu/kernel/traps.c
@@ -111,7 +111,7 @@ static void print_this_address(unsigned long addr, int i)
111 if (i % 5) 111 if (i % 5)
112 printk(KERN_CONT " [%08lx] ", addr); 112 printk(KERN_CONT " [%08lx] ", addr);
113 else 113 else
114 printk(KERN_CONT "\n" KERN_EMERG " [%08lx] ", addr); 114 printk(KERN_EMERG " [%08lx] ", addr);
115 i++; 115 i++;
116#endif 116#endif
117} 117}
@@ -137,8 +137,8 @@ static void __show_stack(struct task_struct *task, unsigned long *stack)
137 if (stack + 1 + i > endstack) 137 if (stack + 1 + i > endstack)
138 break; 138 break;
139 if (i % 8 == 0) 139 if (i % 8 == 0)
140 printk("\n" KERN_EMERG " "); 140 printk(KERN_EMERG " ");
141 printk(" %08lx", *(stack + i)); 141 printk(KERN_CONT " %08lx", *(stack + i));
142 } 142 }
143 printk("\n"); 143 printk("\n");
144 i = 0; 144 i = 0;
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index b50b845fdd50..2db722d80d4d 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -53,6 +53,9 @@ config GENERIC_HARDIRQS_NO__DO_IRQ
53config GENERIC_GPIO 53config GENERIC_GPIO
54 def_bool y 54 def_bool y
55 55
56config GENERIC_CSUM
57 def_bool y
58
56config PCI 59config PCI
57 def_bool n 60 def_bool n
58 61
diff --git a/arch/microblaze/include/asm/atomic.h b/arch/microblaze/include/asm/atomic.h
index 0de612ad7cb2..6d2e1d418be7 100644
--- a/arch/microblaze/include/asm/atomic.h
+++ b/arch/microblaze/include/asm/atomic.h
@@ -1,95 +1,7 @@
1/*
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_ATOMIC_H 1#ifndef _ASM_MICROBLAZE_ATOMIC_H
10#define _ASM_MICROBLAZE_ATOMIC_H 2#define _ASM_MICROBLAZE_ATOMIC_H
11 3
12#include <linux/types.h> 4#include <asm-generic/atomic.h>
13#include <linux/compiler.h> /* likely */
14#include <asm/system.h> /* local_irq_XXX and friends */
15
16#define ATOMIC_INIT(i) { (i) }
17#define atomic_read(v) ((v)->counter)
18#define atomic_set(v, i) (((v)->counter) = (i))
19
20#define atomic_inc(v) (atomic_add_return(1, (v)))
21#define atomic_dec(v) (atomic_sub_return(1, (v)))
22
23#define atomic_add(i, v) (atomic_add_return(i, (v)))
24#define atomic_sub(i, v) (atomic_sub_return(i, (v)))
25
26#define atomic_inc_return(v) (atomic_add_return(1, (v)))
27#define atomic_dec_return(v) (atomic_sub_return(1, (v)))
28
29#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
30#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
31
32#define atomic_inc_not_zero(v) (atomic_add_unless((v), 1, 0))
33
34#define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0)
35
36static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
37{
38 int ret;
39 unsigned long flags;
40
41 local_irq_save(flags);
42 ret = v->counter;
43 if (likely(ret == old))
44 v->counter = new;
45 local_irq_restore(flags);
46
47 return ret;
48}
49
50static inline int atomic_add_unless(atomic_t *v, int a, int u)
51{
52 int c, old;
53
54 c = atomic_read(v);
55 while (c != u && (old = atomic_cmpxchg((v), c, c + a)) != c)
56 c = old;
57 return c != u;
58}
59
60static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
61{
62 unsigned long flags;
63
64 local_irq_save(flags);
65 *addr &= ~mask;
66 local_irq_restore(flags);
67}
68
69/**
70 * atomic_add_return - add and return
71 * @i: integer value to add
72 * @v: pointer of type atomic_t
73 *
74 * Atomically adds @i to @v and returns @i + @v
75 */
76static inline int atomic_add_return(int i, atomic_t *v)
77{
78 unsigned long flags;
79 int val;
80
81 local_irq_save(flags);
82 val = v->counter;
83 v->counter = val += i;
84 local_irq_restore(flags);
85
86 return val;
87}
88
89static inline int atomic_sub_return(int i, atomic_t *v)
90{
91 return atomic_add_return(-i, v);
92}
93 5
94/* 6/*
95 * Atomically test *v and decrement if it is greater than 0. 7 * Atomically test *v and decrement if it is greater than 0.
@@ -109,15 +21,4 @@ static inline int atomic_dec_if_positive(atomic_t *v)
109 return res; 21 return res;
110} 22}
111 23
112#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
113#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
114
115/* Atomic operations are already serializing */
116#define smp_mb__before_atomic_dec() barrier()
117#define smp_mb__after_atomic_dec() barrier()
118#define smp_mb__before_atomic_inc() barrier()
119#define smp_mb__after_atomic_inc() barrier()
120
121#include <asm-generic/atomic-long.h>
122
123#endif /* _ASM_MICROBLAZE_ATOMIC_H */ 24#endif /* _ASM_MICROBLAZE_ATOMIC_H */
diff --git a/arch/microblaze/include/asm/bitops.h b/arch/microblaze/include/asm/bitops.h
index d6df1fd4e1e8..a72468f15c8b 100644
--- a/arch/microblaze/include/asm/bitops.h
+++ b/arch/microblaze/include/asm/bitops.h
@@ -1,27 +1 @@
1/*
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_BITOPS_H
10#define _ASM_MICROBLAZE_BITOPS_H
11
12/*
13 * Copyright 1992, Linus Torvalds.
14 */
15
16#include <asm/byteorder.h> /* swab32 */
17#include <asm/system.h> /* save_flags */
18
19/*
20 * clear_bit() doesn't provide any barrier for the compiler.
21 */
22#define smp_mb__before_clear_bit() barrier()
23#define smp_mb__after_clear_bit() barrier()
24#include <asm-generic/bitops.h> #include <asm-generic/bitops.h>
25#include <asm-generic/bitops/__fls.h>
26
27#endif /* _ASM_MICROBLAZE_BITOPS_H */
diff --git a/arch/microblaze/include/asm/bug.h b/arch/microblaze/include/asm/bug.h
index 8eb2cdde11d7..b12fd89e42e9 100644
--- a/arch/microblaze/include/asm/bug.h
+++ b/arch/microblaze/include/asm/bug.h
@@ -1,15 +1 @@
1/*
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_BUG_H
10#define _ASM_MICROBLAZE_BUG_H
11
12#include <linux/kernel.h>
13#include <asm-generic/bug.h> #include <asm-generic/bug.h>
14
15#endif /* _ASM_MICROBLAZE_BUG_H */
diff --git a/arch/microblaze/include/asm/bugs.h b/arch/microblaze/include/asm/bugs.h
index f2c6593653fb..61791e1ad9f5 100644
--- a/arch/microblaze/include/asm/bugs.h
+++ b/arch/microblaze/include/asm/bugs.h
@@ -1,17 +1 @@
1/* #include <asm-generic/bugs.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_BUGS_H
10#define _ASM_MICROBLAZE_BUGS_H
11
12static inline void check_bugs(void)
13{
14 /* nothing to do */
15}
16
17#endif /* _ASM_MICROBLAZE_BUGS_H */
diff --git a/arch/microblaze/include/asm/checksum.h b/arch/microblaze/include/asm/checksum.h
index 97ea46b5cf80..128bf03b54b7 100644
--- a/arch/microblaze/include/asm/checksum.h
+++ b/arch/microblaze/include/asm/checksum.h
@@ -10,12 +10,11 @@
10#ifndef _ASM_MICROBLAZE_CHECKSUM_H 10#ifndef _ASM_MICROBLAZE_CHECKSUM_H
11#define _ASM_MICROBLAZE_CHECKSUM_H 11#define _ASM_MICROBLAZE_CHECKSUM_H
12 12
13#include <linux/in6.h>
14
15/* 13/*
16 * computes the checksum of the TCP/UDP pseudo-header 14 * computes the checksum of the TCP/UDP pseudo-header
17 * returns a 16-bit checksum, already complemented 15 * returns a 16-bit checksum, already complemented
18 */ 16 */
17#define csum_tcpudp_nofold csum_tcpudp_nofold
19static inline __wsum 18static inline __wsum
20csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, 19csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
21 unsigned short proto, __wsum sum) 20 unsigned short proto, __wsum sum)
@@ -30,71 +29,6 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
30 return sum; 29 return sum;
31} 30}
32 31
33/* 32#include <asm-generic/checksum.h>
34 * computes the checksum of a memory block at buff, length len,
35 * and adds in "sum" (32-bit)
36 *
37 * returns a 32-bit number suitable for feeding into itself
38 * or csum_tcpudp_magic
39 *
40 * this function must be called with even lengths, except
41 * for the last fragment, which may be odd
42 *
43 * it's best to have buff aligned on a 32-bit boundary
44 */
45extern __wsum csum_partial(const void *buff, int len, __wsum sum);
46
47/*
48 * the same as csum_partial, but copies from src while it
49 * checksums
50 *
51 * here even more important to align src and dst on a 32-bit (or even
52 * better 64-bit) boundary
53 */
54extern __wsum csum_partial_copy(const void *src, void *dst, int len,
55 __wsum sum);
56
57/*
58 * the same as csum_partial_copy, but copies from user space.
59 *
60 * here even more important to align src and dst on a 32-bit (or even
61 * better 64-bit) boundary
62 */
63extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
64 int len, __wsum sum, int *csum_err);
65
66#define csum_partial_copy_nocheck(src, dst, len, sum) \
67 csum_partial_copy((src), (dst), (len), (sum))
68
69/*
70 * This is a version of ip_compute_csum() optimized for IP headers,
71 * which always checksum on 4 octet boundaries.
72 *
73 */
74extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
75
76/*
77 * Fold a partial checksum
78 */
79static inline __sum16 csum_fold(__wsum csum)
80{
81 u32 sum = (__force u32)csum;
82 sum = (sum & 0xffff) + (sum >> 16);
83 sum = (sum & 0xffff) + (sum >> 16);
84 return (__force __sum16)~sum;
85}
86
87static inline __sum16
88csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
89 unsigned short proto, __wsum sum)
90{
91 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
92}
93
94/*
95 * this routine is used for miscellaneous IP-like checksums, mainly
96 * in icmp.c
97 */
98extern __sum16 ip_compute_csum(const void *buff, int len);
99 33
100#endif /* _ASM_MICROBLAZE_CHECKSUM_H */ 34#endif /* _ASM_MICROBLAZE_CHECKSUM_H */
diff --git a/arch/microblaze/include/asm/fb.h b/arch/microblaze/include/asm/fb.h
new file mode 100644
index 000000000000..3a4988e8df45
--- /dev/null
+++ b/arch/microblaze/include/asm/fb.h
@@ -0,0 +1 @@
#include <asm-generic/fb.h>
diff --git a/arch/microblaze/include/asm/hardirq.h b/arch/microblaze/include/asm/hardirq.h
index 0f2d6b013e11..41e1e1aa36ac 100644
--- a/arch/microblaze/include/asm/hardirq.h
+++ b/arch/microblaze/include/asm/hardirq.h
@@ -9,21 +9,11 @@
9#ifndef _ASM_MICROBLAZE_HARDIRQ_H 9#ifndef _ASM_MICROBLAZE_HARDIRQ_H
10#define _ASM_MICROBLAZE_HARDIRQ_H 10#define _ASM_MICROBLAZE_HARDIRQ_H
11 11
12#include <linux/cache.h>
13#include <linux/irq.h>
14#include <asm/irq.h>
15#include <asm/current.h>
16#include <linux/ptrace.h>
17
18/* should be defined in each interrupt controller driver */ 12/* should be defined in each interrupt controller driver */
19extern unsigned int get_irq(struct pt_regs *regs); 13extern unsigned int get_irq(struct pt_regs *regs);
20 14
21typedef struct { 15#define ack_bad_irq ack_bad_irq
22 unsigned int __softirq_pending;
23} ____cacheline_aligned irq_cpustat_t;
24
25void ack_bad_irq(unsigned int irq); 16void ack_bad_irq(unsigned int irq);
26 17#include <asm-generic/hardirq.h>
27#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
28 18
29#endif /* _ASM_MICROBLAZE_HARDIRQ_H */ 19#endif /* _ASM_MICROBLAZE_HARDIRQ_H */
diff --git a/arch/microblaze/include/asm/ioctls.h b/arch/microblaze/include/asm/ioctls.h
index 03582b249204..ec34c760665e 100644
--- a/arch/microblaze/include/asm/ioctls.h
+++ b/arch/microblaze/include/asm/ioctls.h
@@ -1,91 +1 @@
1/* #include <asm-generic/ioctls.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_IOCTLS_H
10#define _ASM_MICROBLAZE_IOCTLS_H
11
12#include <linux/ioctl.h>
13
14/* 0x54 is just a magic number to make these relatively unique ('T') */
15
16#define TCGETS 0x5401
17#define TCSETS 0x5402
18#define TCSETSW 0x5403
19#define TCSETSF 0x5404
20#define TCGETA 0x5405
21#define TCSETA 0x5406
22#define TCSETAW 0x5407
23#define TCSETAF 0x5408
24#define TCSBRK 0x5409
25#define TCXONC 0x540A
26#define TCFLSH 0x540B
27#define TIOCEXCL 0x540C
28#define TIOCNXCL 0x540D
29#define TIOCSCTTY 0x540E
30#define TIOCGPGRP 0x540F
31#define TIOCSPGRP 0x5410
32#define TIOCOUTQ 0x5411
33#define TIOCSTI 0x5412
34#define TIOCGWINSZ 0x5413
35#define TIOCSWINSZ 0x5414
36#define TIOCMGET 0x5415
37#define TIOCMBIS 0x5416
38#define TIOCMBIC 0x5417
39#define TIOCMSET 0x5418
40#define TIOCGSOFTCAR 0x5419
41#define TIOCSSOFTCAR 0x541A
42#define FIONREAD 0x541B
43#define TIOCINQ FIONREAD
44#define TIOCLINUX 0x541C
45#define TIOCCONS 0x541D
46#define TIOCGSERIAL 0x541E
47#define TIOCSSERIAL 0x541F
48#define TIOCPKT 0x5420
49#define FIONBIO 0x5421
50#define TIOCNOTTY 0x5422
51#define TIOCSETD 0x5423
52#define TIOCGETD 0x5424
53#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
54#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
55#define TIOCSBRK 0x5427 /* BSD compatibility */
56#define TIOCCBRK 0x5428 /* BSD compatibility */
57#define TIOCGSID 0x5429 /* Return the session ID of FD */
58/* Get Pty Number (of pty-mux device) */
59#define TIOCGPTN _IOR('T', 0x30, unsigned int)
60#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */
61
62#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
63#define FIOCLEX 0x5451
64#define FIOASYNC 0x5452
65#define TIOCSERCONFIG 0x5453
66#define TIOCSERGWILD 0x5454
67#define TIOCSERSWILD 0x5455
68#define TIOCGLCKTRMIOS 0x5456
69#define TIOCSLCKTRMIOS 0x5457
70#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
71#define TIOCSERGETLSR 0x5459 /* Get line status register */
72#define TIOCSERGETMULTI 0x545A /* Get multiport config */
73#define TIOCSERSETMULTI 0x545B /* Set multiport config */
74
75#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
76#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
77
78#define FIOQSIZE 0x545E
79
80/* Used for packet mode */
81#define TIOCPKT_DATA 0
82#define TIOCPKT_FLUSHREAD 1
83#define TIOCPKT_FLUSHWRITE 2
84#define TIOCPKT_STOP 4
85#define TIOCPKT_START 8
86#define TIOCPKT_NOSTOP 16
87#define TIOCPKT_DOSTOP 32
88
89#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
90
91#endif /* _ASM_MICROBLAZE_IOCTLS_H */
diff --git a/arch/microblaze/include/asm/ipcbuf.h b/arch/microblaze/include/asm/ipcbuf.h
index b056fa420654..84c7e51cb6d0 100644
--- a/arch/microblaze/include/asm/ipcbuf.h
+++ b/arch/microblaze/include/asm/ipcbuf.h
@@ -1,36 +1 @@
1/* #include <asm-generic/ipcbuf.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_IPCBUF_H
10#define _ASM_MICROBLAZE_IPCBUF_H
11
12/*
13 * The user_ipc_perm structure for microblaze architecture.
14 * Note extra padding because this structure is passed back and forth
15 * between kernel and user space.
16 *
17 * Pad space is left for:
18 * - 32-bit mode_t and seq
19 * - 2 miscellaneous 32-bit values
20 */
21
22struct ipc64_perm {
23 __kernel_key_t key;
24 __kernel_uid32_t uid;
25 __kernel_gid32_t gid;
26 __kernel_uid32_t cuid;
27 __kernel_gid32_t cgid;
28 __kernel_mode_t mode;
29 unsigned short __pad1;
30 unsigned short seq;
31 unsigned short __pad2;
32 unsigned long __unused1;
33 unsigned long __unused2;
34};
35
36#endif /* _ASM_MICROBLAZE_IPCBUF_H */
diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h
index db515deaa720..90f050535ebe 100644
--- a/arch/microblaze/include/asm/irq.h
+++ b/arch/microblaze/include/asm/irq.h
@@ -10,6 +10,7 @@
10#define _ASM_MICROBLAZE_IRQ_H 10#define _ASM_MICROBLAZE_IRQ_H
11 11
12#define NR_IRQS 32 12#define NR_IRQS 32
13#include <asm-generic/irq.h>
13 14
14#include <linux/interrupt.h> 15#include <linux/interrupt.h>
15 16
@@ -17,11 +18,6 @@ extern unsigned int nr_irq;
17 18
18#define NO_IRQ (-1) 19#define NO_IRQ (-1)
19 20
20static inline int irq_canonicalize(int irq)
21{
22 return irq;
23}
24
25struct pt_regs; 21struct pt_regs;
26extern void do_IRQ(struct pt_regs *regs); 22extern void do_IRQ(struct pt_regs *regs);
27 23
diff --git a/arch/microblaze/include/asm/mman.h b/arch/microblaze/include/asm/mman.h
index 4914b1329445..8eebf89f5ab1 100644
--- a/arch/microblaze/include/asm/mman.h
+++ b/arch/microblaze/include/asm/mman.h
@@ -1,25 +1 @@
1/*
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_MMAN_H
10#define _ASM_MICROBLAZE_MMAN_H
11
12#include <asm-generic/mman.h> #include <asm-generic/mman.h>
13
14#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
15#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
16#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
17#define MAP_LOCKED 0x2000 /* pages are locked */
18#define MAP_NORESERVE 0x4000 /* don't check for reservations */
19#define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
20#define MAP_NONBLOCK 0x10000 /* do not block on IO */
21
22#define MCL_CURRENT 1 /* lock all current mappings */
23#define MCL_FUTURE 2 /* lock all future mappings */
24
25#endif /* _ASM_MICROBLAZE_MMAN_H */
diff --git a/arch/microblaze/include/asm/mmu.h b/arch/microblaze/include/asm/mmu.h
index 66cad6a99d77..8d6a654ceffb 100644
--- a/arch/microblaze/include/asm/mmu.h
+++ b/arch/microblaze/include/asm/mmu.h
@@ -12,12 +12,7 @@
12#define _ASM_MICROBLAZE_MMU_H 12#define _ASM_MICROBLAZE_MMU_H
13 13
14# ifndef CONFIG_MMU 14# ifndef CONFIG_MMU
15# ifndef __ASSEMBLY__ 15# include <asm-generic/mmu.h>
16typedef struct {
17 struct vm_list_struct *vmlist;
18 unsigned long end_brk;
19} mm_context_t;
20# endif /* __ASSEMBLY__ */
21# else /* CONFIG_MMU */ 16# else /* CONFIG_MMU */
22# ifdef __KERNEL__ 17# ifdef __KERNEL__
23# ifndef __ASSEMBLY__ 18# ifndef __ASSEMBLY__
diff --git a/arch/microblaze/include/asm/mmu_context.h b/arch/microblaze/include/asm/mmu_context.h
index 385fed16bbfb..24eab1674d3e 100644
--- a/arch/microblaze/include/asm/mmu_context.h
+++ b/arch/microblaze/include/asm/mmu_context.h
@@ -1,5 +1,5 @@
1#ifdef CONFIG_MMU 1#ifdef CONFIG_MMU
2# include "mmu_context_mm.h" 2# include "mmu_context_mm.h"
3#else 3#else
4# include "mmu_context_no.h" 4# include <asm-generic/mmu_context.h>
5#endif 5#endif
diff --git a/arch/microblaze/include/asm/mmu_context_no.h b/arch/microblaze/include/asm/mmu_context_no.h
deleted file mode 100644
index ba5567190154..000000000000
--- a/arch/microblaze/include/asm/mmu_context_no.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2008-2009 PetaLogix
4 * Copyright (C) 2006 Atmark Techno, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _ASM_MICROBLAZE_MMU_CONTEXT_H
12#define _ASM_MICROBLAZE_MMU_CONTEXT_H
13
14# define init_new_context(tsk, mm) ({ 0; })
15
16# define enter_lazy_tlb(mm, tsk) do {} while (0)
17# define change_mm_context(old, ctx, _pml4) do {} while (0)
18# define destroy_context(mm) do {} while (0)
19# define deactivate_mm(tsk, mm) do {} while (0)
20# define switch_mm(prev, next, tsk) do {} while (0)
21# define activate_mm(prev, next) do {} while (0)
22
23#endif /* _ASM_MICROBLAZE_MMU_CONTEXT_H */
diff --git a/arch/microblaze/include/asm/module.h b/arch/microblaze/include/asm/module.h
index 914565a90315..7be1347fce42 100644
--- a/arch/microblaze/include/asm/module.h
+++ b/arch/microblaze/include/asm/module.h
@@ -9,6 +9,8 @@
9#ifndef _ASM_MICROBLAZE_MODULE_H 9#ifndef _ASM_MICROBLAZE_MODULE_H
10#define _ASM_MICROBLAZE_MODULE_H 10#define _ASM_MICROBLAZE_MODULE_H
11 11
12#include <asm-generic/module.h>
13
12/* Microblaze Relocations */ 14/* Microblaze Relocations */
13#define R_MICROBLAZE_NONE 0 15#define R_MICROBLAZE_NONE 0
14#define R_MICROBLAZE_32 1 16#define R_MICROBLAZE_32 1
@@ -24,14 +26,6 @@
24/* Keep this the last entry. */ 26/* Keep this the last entry. */
25#define R_MICROBLAZE_NUM 11 27#define R_MICROBLAZE_NUM 11
26 28
27struct mod_arch_specific {
28 int foo;
29};
30
31#define Elf_Shdr Elf32_Shdr
32#define Elf_Sym Elf32_Sym
33#define Elf_Ehdr Elf32_Ehdr
34
35typedef struct { volatile int counter; } module_t; 29typedef struct { volatile int counter; } module_t;
36 30
37#endif /* _ASM_MICROBLAZE_MODULE_H */ 31#endif /* _ASM_MICROBLAZE_MODULE_H */
diff --git a/arch/microblaze/include/asm/msgbuf.h b/arch/microblaze/include/asm/msgbuf.h
index 09dd97097211..809134c644a6 100644
--- a/arch/microblaze/include/asm/msgbuf.h
+++ b/arch/microblaze/include/asm/msgbuf.h
@@ -1,31 +1 @@
1#ifndef _ASM_MICROBLAZE_MSGBUF_H #include <asm-generic/msgbuf.h>
2#define _ASM_MICROBLAZE_MSGBUF_H
3
4/*
5 * The msqid64_ds structure for microblaze architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 64-bit time_t to solve y2038 problem
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct msqid64_ds {
15 struct ipc64_perm msg_perm;
16 __kernel_time_t msg_stime; /* last msgsnd time */
17 unsigned long __unused1;
18 __kernel_time_t msg_rtime; /* last msgrcv time */
19 unsigned long __unused2;
20 __kernel_time_t msg_ctime; /* last change time */
21 unsigned long __unused3;
22 unsigned long msg_cbytes; /* current number of bytes on queue */
23 unsigned long msg_qnum; /* number of messages in queue */
24 unsigned long msg_qbytes; /* max number of bytes on queue */
25 __kernel_pid_t msg_lspid; /* pid of last msgsnd */
26 __kernel_pid_t msg_lrpid; /* last receive pid */
27 unsigned long __unused4;
28 unsigned long __unused5;
29};
30
31#endif /* _ASM_MICROBLAZE_MSGBUF_H */
diff --git a/arch/microblaze/include/asm/param.h b/arch/microblaze/include/asm/param.h
index 8c538a49616d..965d45427975 100644
--- a/arch/microblaze/include/asm/param.h
+++ b/arch/microblaze/include/asm/param.h
@@ -1,30 +1 @@
1/* #include <asm-generic/param.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_PARAM_H
10#define _ASM_MICROBLAZE_PARAM_H
11
12#ifdef __KERNEL__
13#define HZ CONFIG_HZ /* internal kernel timer frequency */
14#define USER_HZ 100 /* for user interfaces in "ticks" */
15#define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */
16#endif /* __KERNEL__ */
17
18#ifndef HZ
19#define HZ 100
20#endif
21
22#define EXEC_PAGESIZE 4096
23
24#ifndef NOGROUP
25#define NOGROUP (-1)
26#endif
27
28#define MAXHOSTNAMELEN 64 /* max length of hostname */
29
30#endif /* _ASM_MICROBLAZE_PARAM_H */
diff --git a/arch/microblaze/include/asm/parport.h b/arch/microblaze/include/asm/parport.h
new file mode 100644
index 000000000000..cf252af64590
--- /dev/null
+++ b/arch/microblaze/include/asm/parport.h
@@ -0,0 +1 @@
#include <asm-generic/parport.h>
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h
index ca03794cf3f0..9f0df5faf2c8 100644
--- a/arch/microblaze/include/asm/pci.h
+++ b/arch/microblaze/include/asm/pci.h
@@ -1 +1 @@
#include <linux/io.h> #include <asm-generic/pci.h>
diff --git a/arch/microblaze/include/asm/posix_types.h b/arch/microblaze/include/asm/posix_types.h
index 8c758b231f37..0e15039673e3 100644
--- a/arch/microblaze/include/asm/posix_types.h
+++ b/arch/microblaze/include/asm/posix_types.h
@@ -1,73 +1,9 @@
1/*
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_POSIX_TYPES_H 1#ifndef _ASM_MICROBLAZE_POSIX_TYPES_H
10#define _ASM_MICROBLAZE_POSIX_TYPES_H 2#define _ASM_MICROBLAZE_POSIX_TYPES_H
11 3
12/*
13 * This file is generally used by user-level software, so you need to
14 * be a little careful about namespace pollution etc. Also, we cannot
15 * assume GCC is being used.
16 */
17
18typedef unsigned long __kernel_ino_t;
19typedef unsigned short __kernel_mode_t; 4typedef unsigned short __kernel_mode_t;
20typedef unsigned int __kernel_nlink_t; 5#define __kernel_mode_t __kernel_mode_t
21typedef long __kernel_off_t;
22typedef int __kernel_pid_t;
23typedef unsigned int __kernel_ipc_pid_t;
24typedef unsigned int __kernel_uid_t;
25typedef unsigned int __kernel_gid_t;
26typedef unsigned long __kernel_size_t;
27typedef long __kernel_ssize_t;
28typedef int __kernel_ptrdiff_t;
29typedef long __kernel_time_t;
30typedef long __kernel_suseconds_t;
31typedef long __kernel_clock_t;
32typedef int __kernel_timer_t;
33typedef int __kernel_clockid_t;
34typedef int __kernel_daddr_t;
35typedef char *__kernel_caddr_t;
36typedef unsigned short __kernel_uid16_t;
37typedef unsigned short __kernel_gid16_t;
38typedef unsigned int __kernel_uid32_t;
39typedef unsigned int __kernel_gid32_t;
40
41typedef unsigned int __kernel_old_uid_t;
42typedef unsigned int __kernel_old_gid_t;
43typedef unsigned int __kernel_old_dev_t;
44
45#ifdef __GNUC__
46typedef long long __kernel_loff_t;
47#endif
48
49typedef struct {
50#if defined(__KERNEL__) || defined(__USE_ALL)
51 int val[2];
52#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
53 int __val[2];
54#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
55} __kernel_fsid_t;
56
57#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
58
59#undef __FD_SET
60#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
61
62#undef __FD_CLR
63#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
64
65#undef __FD_ISSET
66#define __FD_ISSET(d, set) (!!((set)->fds_bits[__FDELT(d)] & __FDMASK(d)))
67
68#undef __FD_ZERO
69#define __FD_ZERO(fdsetp) (memset(fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
70 6
71#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ 7#include <asm-generic/posix_types.h>
72 8
73#endif /* _ASM_MICROBLAZE_POSIX_TYPES_H */ 9#endif /* _ASM_MICROBLAZE_POSIX_TYPES_H */
diff --git a/arch/microblaze/include/asm/scatterlist.h b/arch/microblaze/include/asm/scatterlist.h
index 08ff1d049b42..35d786fe93ae 100644
--- a/arch/microblaze/include/asm/scatterlist.h
+++ b/arch/microblaze/include/asm/scatterlist.h
@@ -1,28 +1 @@
1/* #include <asm-generic/scatterlist.h>
2 * Copyright (C) 2008 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2006 Atmark Techno, Inc.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9
10#ifndef _ASM_MICROBLAZE_SCATTERLIST_H
11#define _ASM_MICROBLAZE_SCATTERLIST_H
12
13struct scatterlist {
14#ifdef CONFIG_DEBUG_SG
15 unsigned long sg_magic;
16#endif
17 unsigned long page_link;
18 dma_addr_t dma_address;
19 unsigned int offset;
20 unsigned int length;
21};
22
23#define sg_dma_address(sg) ((sg)->dma_address)
24#define sg_dma_len(sg) ((sg)->length)
25
26#define ISA_DMA_THRESHOLD (~0UL)
27
28#endif /* _ASM_MICROBLAZE_SCATTERLIST_H */
diff --git a/arch/microblaze/include/asm/sembuf.h b/arch/microblaze/include/asm/sembuf.h
index b804ed71a57e..7673b83cfef7 100644
--- a/arch/microblaze/include/asm/sembuf.h
+++ b/arch/microblaze/include/asm/sembuf.h
@@ -1,34 +1 @@
1/* #include <asm-generic/sembuf.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_SEMBUF_H
10#define _ASM_MICROBLAZE_SEMBUF_H
11
12/*
13 * The semid64_ds structure for microblaze architecture.
14 * Note extra padding because this structure is passed back and forth
15 * between kernel and user space.
16 *
17 * Pad space is left for:
18 * - 64-bit time_t to solve y2038 problem
19 * - 2 miscellaneous 32-bit values
20 */
21
22struct semid64_ds {
23 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
24 __kernel_time_t sem_otime; /* last semop time */
25 unsigned long __unused1;
26 __kernel_time_t sem_ctime; /* last change time */
27 unsigned long __unused2;
28 unsigned long sem_nsems; /* no. of semaphores in array */
29 unsigned long __unused3;
30 unsigned long __unused4;
31};
32
33
34#endif /* _ASM_MICROBLAZE_SEMBUF_H */
diff --git a/arch/microblaze/include/asm/serial.h b/arch/microblaze/include/asm/serial.h
index 39bfc8ce6af5..a0cb0caff152 100644
--- a/arch/microblaze/include/asm/serial.h
+++ b/arch/microblaze/include/asm/serial.h
@@ -1,14 +1 @@
1/* #include <asm-generic/serial.h>
2 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_SERIAL_H
10#define _ASM_MICROBLAZE_SERIAL_H
11
12# define BASE_BAUD (1843200 / 16)
13
14#endif /* _ASM_MICROBLAZE_SERIAL_H */
diff --git a/arch/microblaze/include/asm/shmbuf.h b/arch/microblaze/include/asm/shmbuf.h
index f829c5843618..83c05fc2de38 100644
--- a/arch/microblaze/include/asm/shmbuf.h
+++ b/arch/microblaze/include/asm/shmbuf.h
@@ -1,42 +1 @@
1#ifndef _ASM_MICROBLAZE_SHMBUF_H #include <asm-generic/shmbuf.h>
2#define _ASM_MICROBLAZE_SHMBUF_H
3
4/*
5 * The shmid64_ds structure for microblaze architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 64-bit time_t to solve y2038 problem
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct shmid64_ds {
15 struct ipc64_perm shm_perm; /* operation perms */
16 size_t shm_segsz; /* size of segment (bytes) */
17 __kernel_time_t shm_atime; /* last attach time */
18 unsigned long __unused1;
19 __kernel_time_t shm_dtime; /* last detach time */
20 unsigned long __unused2;
21 __kernel_time_t shm_ctime; /* last change time */
22 unsigned long __unused3;
23 __kernel_pid_t shm_cpid; /* pid of creator */
24 __kernel_pid_t shm_lpid; /* pid of last operator */
25 unsigned long shm_nattch; /* no. of current attaches */
26 unsigned long __unused4;
27 unsigned long __unused5;
28};
29
30struct shminfo64 {
31 unsigned long shmmax;
32 unsigned long shmmin;
33 unsigned long shmmni;
34 unsigned long shmseg;
35 unsigned long shmall;
36 unsigned long __unused1;
37 unsigned long __unused2;
38 unsigned long __unused3;
39 unsigned long __unused4;
40};
41
42#endif /* _ASM_MICROBLAZE_SHMBUF_H */
diff --git a/arch/microblaze/include/asm/shmparam.h b/arch/microblaze/include/asm/shmparam.h
index 9f5fc2b3b6a3..93f30deb95d0 100644
--- a/arch/microblaze/include/asm/shmparam.h
+++ b/arch/microblaze/include/asm/shmparam.h
@@ -1,6 +1 @@
1#ifndef _ASM_MICROBLAZE_SHMPARAM_H #include <asm-generic/shmparam.h>
2#define _ASM_MICROBLAZE_SHMPARAM_H
3
4#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
5
6#endif /* _ASM_MICROBLAZE_SHMPARAM_H */
diff --git a/arch/microblaze/include/asm/siginfo.h b/arch/microblaze/include/asm/siginfo.h
index f162911a8f50..0815d29d82e5 100644
--- a/arch/microblaze/include/asm/siginfo.h
+++ b/arch/microblaze/include/asm/siginfo.h
@@ -1,15 +1 @@
1/*
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_SIGINFO_H
10#define _ASM_MICROBLAZE_SIGINFO_H
11
12#include <linux/types.h>
13#include <asm-generic/siginfo.h> #include <asm-generic/siginfo.h>
14
15#endif /* _ASM_MICROBLAZE_SIGINFO_H */
diff --git a/arch/microblaze/include/asm/signal.h b/arch/microblaze/include/asm/signal.h
index 46bc2267d949..7b1573ce19de 100644
--- a/arch/microblaze/include/asm/signal.h
+++ b/arch/microblaze/include/asm/signal.h
@@ -1,165 +1 @@
1/* #include <asm-generic/signal.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 * Yasushi SHOJI <yashi@atmark-techno.com>
4 * Tetsuya OHKAWA <tetsuya@atmark-techno.com>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _ASM_MICROBLAZE_SIGNAL_H
12#define _ASM_MICROBLAZE_SIGNAL_H
13
14#define SIGHUP 1
15#define SIGINT 2
16#define SIGQUIT 3
17#define SIGILL 4
18#define SIGTRAP 5
19#define SIGABRT 6
20#define SIGIOT 6
21#define SIGBUS 7
22#define SIGFPE 8
23#define SIGKILL 9
24#define SIGUSR1 10
25#define SIGSEGV 11
26#define SIGUSR2 12
27#define SIGPIPE 13
28#define SIGALRM 14
29#define SIGTERM 15
30#define SIGSTKFLT 16
31#define SIGCHLD 17
32#define SIGCONT 18
33#define SIGSTOP 19
34#define SIGTSTP 20
35#define SIGTTIN 21
36#define SIGTTOU 22
37#define SIGURG 23
38#define SIGXCPU 24
39#define SIGXFSZ 25
40#define SIGVTALRM 26
41#define SIGPROF 27
42#define SIGWINCH 28
43#define SIGIO 29
44#define SIGPOLL SIGIO
45/*
46#define SIGLOST 29
47*/
48#define SIGPWR 30
49#define SIGSYS 31
50#define SIGUNUSED 31
51
52/* These should not be considered constants from userland. */
53#define SIGRTMIN 32
54#define SIGRTMAX _NSIG
55
56/*
57 * SA_FLAGS values:
58 *
59 * SA_ONSTACK indicates that a registered stack_t will be used.
60 * SA_RESTART flag to get restarting signals (which were the default long ago)
61 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
62 * SA_RESETHAND clears the handler when the signal is delivered.
63 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
64 * SA_NODEFER prevents the current signal from being masked in the handler.
65 *
66 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
67 * Unix names RESETHAND and NODEFER respectively.
68 */
69#define SA_NOCLDSTOP 0x00000001
70#define SA_NOCLDWAIT 0x00000002
71#define SA_SIGINFO 0x00000004
72#define SA_ONSTACK 0x08000000
73#define SA_RESTART 0x10000000
74#define SA_NODEFER 0x40000000
75#define SA_RESETHAND 0x80000000
76
77#define SA_NOMASK SA_NODEFER
78#define SA_ONESHOT SA_RESETHAND
79
80#define SA_RESTORER 0x04000000
81
82/*
83 * sigaltstack controls
84 */
85#define SS_ONSTACK 1
86#define SS_DISABLE 2
87
88#define MINSIGSTKSZ 2048
89#define SIGSTKSZ 8192
90
91# ifndef __ASSEMBLY__
92# include <linux/types.h>
93# include <asm-generic/signal-defs.h>
94
95/* Avoid too many header ordering problems. */
96struct siginfo;
97
98# ifdef __KERNEL__
99/*
100 * Most things should be clean enough to redefine this at will, if care
101 * is taken to make libc match.
102 */
103# define _NSIG 64
104# define _NSIG_BPW 32
105# define _NSIG_WORDS (_NSIG / _NSIG_BPW)
106
107typedef unsigned long old_sigset_t; /* at least 32 bits */
108
109typedef struct {
110 unsigned long sig[_NSIG_WORDS];
111} sigset_t;
112
113struct old_sigaction {
114 __sighandler_t sa_handler;
115 old_sigset_t sa_mask;
116 unsigned long sa_flags;
117 void (*sa_restorer)(void);
118};
119
120struct sigaction {
121 __sighandler_t sa_handler;
122 unsigned long sa_flags;
123 void (*sa_restorer)(void);
124 sigset_t sa_mask; /* mask last for extensibility */
125};
126
127struct k_sigaction {
128 struct sigaction sa;
129};
130
131# include <asm/sigcontext.h>
132# undef __HAVE_ARCH_SIG_BITOPS
133
134# define ptrace_signal_deliver(regs, cookie) do { } while (0)
135
136# else /* !__KERNEL__ */
137
138/* Here we must cater to libcs that poke about in kernel headers. */
139
140# define NSIG 32
141typedef unsigned long sigset_t;
142
143struct sigaction {
144 union {
145 __sighandler_t _sa_handler;
146 void (*_sa_sigaction)(int, struct siginfo *, void *);
147 } _u;
148 sigset_t sa_mask;
149 unsigned long sa_flags;
150 void (*sa_restorer)(void);
151};
152
153# define sa_handler _u._sa_handler
154# define sa_sigaction _u._sa_sigaction
155
156# endif /* __KERNEL__ */
157
158typedef struct sigaltstack {
159 void *ss_sp;
160 int ss_flags;
161 size_t ss_size;
162} stack_t;
163
164# endif /* __ASSEMBLY__ */
165#endif /* _ASM_MICROBLAZE_SIGNAL_H */
diff --git a/arch/microblaze/include/asm/socket.h b/arch/microblaze/include/asm/socket.h
index 825936860314..6b71384b9d8b 100644
--- a/arch/microblaze/include/asm/socket.h
+++ b/arch/microblaze/include/asm/socket.h
@@ -1,69 +1 @@
1/* #include <asm-generic/socket.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_SOCKET_H
10#define _ASM_MICROBLAZE_SOCKET_H
11
12#include <asm/sockios.h>
13
14/* For setsockoptions(2) */
15#define SOL_SOCKET 1
16
17#define SO_DEBUG 1
18#define SO_REUSEADDR 2
19#define SO_TYPE 3
20#define SO_ERROR 4
21#define SO_DONTROUTE 5
22#define SO_BROADCAST 6
23#define SO_SNDBUF 7
24#define SO_RCVBUF 8
25#define SO_SNDBUFFORCE 32
26#define SO_RCVBUFFORCE 33
27#define SO_KEEPALIVE 9
28#define SO_OOBINLINE 10
29#define SO_NO_CHECK 11
30#define SO_PRIORITY 12
31#define SO_LINGER 13
32#define SO_BSDCOMPAT 14
33/* To add :#define SO_REUSEPORT 15 */
34#define SO_PASSCRED 16
35#define SO_PEERCRED 17
36#define SO_RCVLOWAT 18
37#define SO_SNDLOWAT 19
38#define SO_RCVTIMEO 20
39#define SO_SNDTIMEO 21
40
41/* Security levels - as per NRL IPv6 - don't actually do anything */
42#define SO_SECURITY_AUTHENTICATION 22
43#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
44#define SO_SECURITY_ENCRYPTION_NETWORK 24
45
46#define SO_BINDTODEVICE 25
47
48/* Socket filtering */
49#define SO_ATTACH_FILTER 26
50#define SO_DETACH_FILTER 27
51
52#define SO_PEERNAME 28
53#define SO_TIMESTAMP 29
54#define SCM_TIMESTAMP SO_TIMESTAMP
55
56#define SO_ACCEPTCONN 30
57
58#define SO_PEERSEC 31
59#define SO_PASSSEC 34
60
61#define SO_TIMESTAMPNS 35
62#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
63
64#define SO_MARK 36
65
66#define SO_TIMESTAMPING 37
67#define SCM_TIMESTAMPING SO_TIMESTAMPING
68
69#endif /* _ASM_MICROBLAZE_SOCKET_H */
diff --git a/arch/microblaze/include/asm/sockios.h b/arch/microblaze/include/asm/sockios.h
index 9fff57a701e1..def6d4746ee7 100644
--- a/arch/microblaze/include/asm/sockios.h
+++ b/arch/microblaze/include/asm/sockios.h
@@ -1,23 +1 @@
1/* #include <asm-generic/sockios.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_SOCKIOS_H
10#define _ASM_MICROBLAZE_SOCKIOS_H
11
12#include <linux/ioctl.h>
13
14/* Socket-level I/O control calls. */
15#define FIOSETOWN 0x8901
16#define SIOCSPGRP 0x8902
17#define FIOGETOWN 0x8903
18#define SIOCGPGRP 0x8904
19#define SIOCATMARK 0x8905
20#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
21#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
22
23#endif /* _ASM_MICROBLAZE_SOCKIOS_H */
diff --git a/arch/microblaze/include/asm/stat.h b/arch/microblaze/include/asm/stat.h
index a15f77520bfd..3dc90fa92c70 100644
--- a/arch/microblaze/include/asm/stat.h
+++ b/arch/microblaze/include/asm/stat.h
@@ -1,68 +1 @@
1/* #include <asm-generic/stat.h>
2 * Microblaze stat structure
3 *
4 * Copyright (C) 2001,02,03 NEC Electronics Corporation
5 * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
6 *
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file COPYING in the main directory of this
9 * archive for more details.
10 *
11 * Written by Miles Bader <miles@gnu.org>
12 */
13
14#ifndef _ASM_MICROBLAZE_STAT_H
15#define _ASM_MICROBLAZE_STAT_H
16
17#include <linux/posix_types.h>
18
19#define STAT_HAVE_NSEC 1
20
21struct stat {
22 unsigned long st_dev;
23 unsigned long st_ino;
24 unsigned int st_mode;
25 unsigned int st_nlink;
26 unsigned int st_uid;
27 unsigned int st_gid;
28 unsigned long st_rdev;
29 unsigned long __pad1;
30 long st_size;
31 int st_blksize;
32 int __pad2;
33 long st_blocks;
34 int st_atime;
35 unsigned int st_atime_nsec;
36 int st_mtime;
37 unsigned int st_mtime_nsec;
38 int st_ctime;
39 unsigned int st_ctime_nsec;
40 unsigned long __unused4;
41 unsigned long __unused5;
42};
43
44struct stat64 {
45 unsigned long long st_dev; /* Device. */
46 unsigned long long st_ino; /* File serial number. */
47 unsigned int st_mode; /* File mode. */
48 unsigned int st_nlink; /* Link count. */
49 unsigned int st_uid; /* User ID of the file's owner. */
50 unsigned int st_gid; /* Group ID of the file's group. */
51 unsigned long long st_rdev; /* Device number, if device. */
52 unsigned long long __pad1;
53 long long st_size; /* Size of file, in bytes. */
54 int st_blksize; /* Optimal block size for I/O. */
55 int __pad2;
56 long long st_blocks; /* Number 512-byte blocks allocated. */
57 int st_atime; /* Time of last access. */
58 unsigned int st_atime_nsec;
59 int st_mtime; /* Time of last modification. */
60 unsigned int st_mtime_nsec;
61 int st_ctime; /* Time of last status change. */
62 unsigned int st_ctime_nsec;
63 unsigned int __unused4;
64 unsigned int __unused5;
65};
66
67#endif /* _ASM_MICROBLAZE_STAT_H */
68
diff --git a/arch/microblaze/include/asm/swab.h b/arch/microblaze/include/asm/swab.h
index b375d7b65ad7..7847e563ab66 100644
--- a/arch/microblaze/include/asm/swab.h
+++ b/arch/microblaze/include/asm/swab.h
@@ -1,8 +1 @@
1#ifndef _ASM_MICROBLAZE_SWAB_H #include <asm-generic/swab.h>
2#define _ASM_MICROBLAZE_SWAB_H
3
4#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
5#define __SWAB_64_THRU_32__
6#endif
7
8#endif /* _ASM_MICROBLAZE_SWAB_H */
diff --git a/arch/microblaze/include/asm/syscalls.h b/arch/microblaze/include/asm/syscalls.h
index ddea9eb31f8d..720761cc741f 100644
--- a/arch/microblaze/include/asm/syscalls.h
+++ b/arch/microblaze/include/asm/syscalls.h
@@ -1,48 +1,8 @@
1#ifndef __ASM_MICROBLAZE_SYSCALLS_H 1#ifndef __ASM_MICROBLAZE_SYSCALLS_H
2#define __ASM_MICROBLAZE_SYSCALLS_H
3#ifdef __KERNEL__
4 2
5#include <linux/compiler.h> 3asmlinkage long sys_clone(int flags, unsigned long stack, struct pt_regs *regs);
6#include <linux/linkage.h> 4#define sys_clone sys_clone
7#include <linux/types.h>
8#include <linux/signal.h>
9 5
10/* FIXME will be removed */ 6#include <asm-generic/syscalls.h>
11asmlinkage int sys_ipc(uint call, int first, int second,
12 int third, void *ptr, long fifth);
13 7
14struct pt_regs;
15asmlinkage int sys_vfork(struct pt_regs *regs);
16asmlinkage int sys_clone(int flags, unsigned long stack, struct pt_regs *regs);
17asmlinkage int sys_execve(char __user *filenamei, char __user *__user *argv,
18 char __user *__user *envp, struct pt_regs *regs);
19
20asmlinkage unsigned long sys_mmap2(unsigned long addr, size_t len,
21 unsigned long prot, unsigned long flags,
22 unsigned long fd, unsigned long pgoff);
23
24asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len,
25 unsigned long prot, unsigned long flags,
26 unsigned long fd, off_t offset);
27
28/* from signal.c */
29asmlinkage int sys_sigsuspend(old_sigset_t mask, struct pt_regs *regs);
30
31asmlinkage int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize,
32 struct pt_regs *regs);
33
34asmlinkage int sys_sigaction(int sig, const struct old_sigaction *act,
35 struct old_sigaction *oact);
36
37asmlinkage long sys_rt_sigaction(int sig, const struct sigaction __user *act,
38 struct sigaction __user *oact, size_t sigsetsize);
39
40asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
41 struct pt_regs *regs);
42
43asmlinkage int sys_sigreturn(struct pt_regs *regs);
44
45asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
46
47#endif /* __KERNEL__ */
48#endif /* __ASM_MICROBLAZE_SYSCALLS_H */ 8#endif /* __ASM_MICROBLAZE_SYSCALLS_H */
diff --git a/arch/microblaze/include/asm/system.h b/arch/microblaze/include/asm/system.h
index c4e308850b5d..b1ed61590660 100644
--- a/arch/microblaze/include/asm/system.h
+++ b/arch/microblaze/include/asm/system.h
@@ -13,6 +13,9 @@
13#include <asm/setup.h> 13#include <asm/setup.h>
14#include <asm/irqflags.h> 14#include <asm/irqflags.h>
15 15
16#include <asm-generic/cmpxchg.h>
17#include <asm-generic/cmpxchg-local.h>
18
16struct task_struct; 19struct task_struct;
17struct thread_info; 20struct thread_info;
18 21
diff --git a/arch/microblaze/include/asm/termbits.h b/arch/microblaze/include/asm/termbits.h
index a1b64bc4724a..3935b106de79 100644
--- a/arch/microblaze/include/asm/termbits.h
+++ b/arch/microblaze/include/asm/termbits.h
@@ -1,203 +1 @@
1/* #include <asm-generic/termbits.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_TERMBITS_H
10#define _ASM_MICROBLAZE_TERMBITS_H
11
12#include <linux/posix_types.h>
13
14typedef unsigned char cc_t;
15typedef unsigned int speed_t;
16typedef unsigned int tcflag_t;
17
18#define NCCS 19
19struct termios {
20 tcflag_t c_iflag; /* input mode flags */
21 tcflag_t c_oflag; /* output mode flags */
22 tcflag_t c_cflag; /* control mode flags */
23 tcflag_t c_lflag; /* local mode flags */
24 cc_t c_line; /* line discipline */
25 cc_t c_cc[NCCS]; /* control characters */
26};
27
28struct ktermios {
29 tcflag_t c_iflag; /* input mode flags */
30 tcflag_t c_oflag; /* output mode flags */
31 tcflag_t c_cflag; /* control mode flags */
32 tcflag_t c_lflag; /* local mode flags */
33 cc_t c_line; /* line discipline */
34 cc_t c_cc[NCCS]; /* control characters */
35 speed_t c_ispeed; /* input speed */
36 speed_t c_ospeed; /* output speed */
37};
38
39/* c_cc characters */
40
41#define VINTR 0
42#define VQUIT 1
43#define VERASE 2
44#define VKILL 3
45#define VEOF 4
46#define VTIME 5
47#define VMIN 6
48#define VSWTC 7
49#define VSTART 8
50#define VSTOP 9
51#define VSUSP 10
52#define VEOL 11
53#define VREPRINT 12
54#define VDISCARD 13
55#define VWERASE 14
56#define VLNEXT 15
57#define VEOL2 16
58
59/* c_iflag bits */
60
61#define IGNBRK 0000001
62#define BRKINT 0000002
63#define IGNPAR 0000004
64#define PARMRK 0000010
65#define INPCK 0000020
66#define ISTRIP 0000040
67#define INLCR 0000100
68#define IGNCR 0000200
69#define ICRNL 0000400
70#define IUCLC 0001000
71#define IXON 0002000
72#define IXANY 0004000
73#define IXOFF 0010000
74#define IMAXBEL 0020000
75#define IUTF8 0040000
76
77/* c_oflag bits */
78
79#define OPOST 0000001
80#define OLCUC 0000002
81#define ONLCR 0000004
82#define OCRNL 0000010
83#define ONOCR 0000020
84#define ONLRET 0000040
85#define OFILL 0000100
86#define OFDEL 0000200
87#define NLDLY 0000400
88#define NL0 0000000
89#define NL1 0000400
90#define CRDLY 0003000
91#define CR0 0000000
92#define CR1 0001000
93#define CR2 0002000
94#define CR3 0003000
95#define TABDLY 0014000
96#define TAB0 0000000
97#define TAB1 0004000
98#define TAB2 0010000
99#define TAB3 0014000
100#define XTABS 0014000
101#define BSDLY 0020000
102#define BS0 0000000
103#define BS1 0020000
104#define VTDLY 0040000
105#define VT0 0000000
106#define VT1 0040000
107#define FFDLY 0100000
108#define FF0 0000000
109#define FF1 0100000
110
111/* c_cflag bit meaning */
112
113#define CBAUD 0010017
114#define B0 0000000 /* hang up */
115#define B50 0000001
116#define B75 0000002
117#define B110 0000003
118#define B134 0000004
119#define B150 0000005
120#define B200 0000006
121#define B300 0000007
122#define B600 0000010
123#define B1200 0000011
124#define B1800 0000012
125#define B2400 0000013
126#define B4800 0000014
127#define B9600 0000015
128#define B19200 0000016
129#define B38400 0000017
130#define EXTA B19200
131#define EXTB B38400
132#define CSIZE 0000060
133#define CS5 0000000
134#define CS6 0000020
135#define CS7 0000040
136#define CS8 0000060
137#define CSTOPB 0000100
138#define CREAD 0000200
139#define PARENB 0000400
140#define PARODD 0001000
141#define HUPCL 0002000
142#define CLOCAL 0004000
143#define CBAUDEX 0010000
144#define B57600 0010001
145#define B115200 0010002
146#define B230400 0010003
147#define B460800 0010004
148#define B500000 0010005
149#define B576000 0010006
150#define B921600 0010007
151#define BOTHER 0010000
152#define B1000000 0010010
153#define B1152000 0010011
154#define B1500000 0010012
155#define B2000000 0010013
156#define B2500000 0010014
157#define B3000000 0010015
158#define B3500000 0010016
159#define B4000000 0010017
160#define CIBAUD 002003600000 /* input baud rate (not used) */
161#define CMSPAR 010000000000 /* mark or space (stick) parity */
162#define CRTSCTS 020000000000 /* flow control */
163
164#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
165
166/* c_lflag bits */
167
168#define ISIG 0000001
169#define ICANON 0000002
170#define XCASE 0000004
171#define ECHO 0000010
172#define ECHOE 0000020
173#define ECHOK 0000040
174#define ECHONL 0000100
175#define NOFLSH 0000200
176#define TOSTOP 0000400
177#define ECHOCTL 0001000
178#define ECHOPRT 0002000
179#define ECHOKE 0004000
180#define FLUSHO 0010000
181#define PENDIN 0040000
182#define IEXTEN 0100000
183
184/* tcflow() and TCXONC use these */
185
186#define TCOOFF 0
187#define TCOON 1
188#define TCIOFF 2
189#define TCION 3
190
191/* tcflush() and TCFLSH use these */
192
193#define TCIFLUSH 0
194#define TCOFLUSH 1
195#define TCIOFLUSH 2
196
197/* tcsetattr uses these */
198
199#define TCSANOW 0
200#define TCSADRAIN 1
201#define TCSAFLUSH 2
202
203#endif /* _ASM_MICROBLAZE_TERMBITS_H */
diff --git a/arch/microblaze/include/asm/termios.h b/arch/microblaze/include/asm/termios.h
index 47a46d1fbe26..280d78a9d966 100644
--- a/arch/microblaze/include/asm/termios.h
+++ b/arch/microblaze/include/asm/termios.h
@@ -1,88 +1 @@
1/* #include <asm-generic/termios.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_TERMIOS_H
10#define _ASM_MICROBLAZE_TERMIOS_H
11
12#include <linux/string.h>
13#include <asm/termbits.h>
14#include <asm/ioctls.h>
15
16struct winsize {
17 unsigned short ws_row;
18 unsigned short ws_col;
19 unsigned short ws_xpixel;
20 unsigned short ws_ypixel;
21};
22
23#define NCC 8
24struct termio {
25 unsigned short c_iflag; /* input mode flags */
26 unsigned short c_oflag; /* output mode flags */
27 unsigned short c_cflag; /* control mode flags */
28 unsigned short c_lflag; /* local mode flags */
29 unsigned char c_line; /* line discipline */
30 unsigned char c_cc[NCC]; /* control characters */
31};
32
33#ifdef __KERNEL__
34/* intr=^C quit=^| erase=del kill=^U
35 eof=^D vtime=\0 vmin=\1 sxtc=\0
36 start=^Q stop=^S susp=^Z eol=\0
37 reprint=^R discard=^U werase=^W lnext=^V
38 eol2=\0
39*/
40#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
41#endif
42
43/* Modem lines */
44
45#define TIOCM_LE 0x001
46#define TIOCM_DTR 0x002
47#define TIOCM_RTS 0x004
48#define TIOCM_ST 0x008
49#define TIOCM_SR 0x010
50#define TIOCM_CTS 0x020
51#define TIOCM_CAR 0x040
52#define TIOCM_RNG 0x080
53#define TIOCM_DSR 0x100
54#define TIOCM_CD TIOCM_CAR
55#define TIOCM_RI TIOCM_RNG
56#define TIOCM_OUT1 0x2000
57#define TIOCM_OUT2 0x4000
58#define TIOCM_LOOP 0x8000
59
60/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
61
62/* Line disciplines */
63
64#define N_TTY 0
65#define N_SLIP 1
66#define N_MOUSE 2
67#define N_PPP 3
68#define N_STRIP 4
69#define N_AX25 5
70#define N_X25 6 /* X.25 async */
71#define N_6PACK 7
72#define N_MASC 8 /* Reserved for Mobitex module <kaz@cafe.net> */
73#define N_R3964 9 /* Reserved for Simatic R3964 module */
74#define N_PROFIBUS_FDL 10 /* Reserved for Profibus <Dave@mvhi.com> */
75#define N_IRDA 11 /* Linux IR - http://irda.sourceforge.net/ */
76#define N_SMSBLOCK 12 /* SMS block mode - for talking to GSM data cards
77 about SMS messages */
78#define N_HDLC 13 /* synchronous HDLC */
79#define N_SYNC_PPP 14
80#define N_HCI 15 /* Bluetooth HCI UART */
81
82#ifdef __KERNEL__
83
84#include <asm-generic/termios-base.h>
85
86#endif /* __KERNEL__ */
87
88#endif /* _ASM_MICROBLAZE_TERMIOS_H */
diff --git a/arch/microblaze/include/asm/thread_info.h b/arch/microblaze/include/asm/thread_info.h
index 7fac44498445..6e92885d381a 100644
--- a/arch/microblaze/include/asm/thread_info.h
+++ b/arch/microblaze/include/asm/thread_info.h
@@ -75,8 +75,6 @@ struct thread_info {
75 75
76/* 76/*
77 * macros/functions for gaining access to the thread information structure 77 * macros/functions for gaining access to the thread information structure
78 *
79 * preempt_count needs to be 1 initially, until the scheduler is functional.
80 */ 78 */
81#define INIT_THREAD_INFO(tsk) \ 79#define INIT_THREAD_INFO(tsk) \
82{ \ 80{ \
@@ -84,7 +82,7 @@ struct thread_info {
84 .exec_domain = &default_exec_domain, \ 82 .exec_domain = &default_exec_domain, \
85 .flags = 0, \ 83 .flags = 0, \
86 .cpu = 0, \ 84 .cpu = 0, \
87 .preempt_count = 1, \ 85 .preempt_count = INIT_PREEMPT_COUNT, \
88 .addr_limit = KERNEL_DS, \ 86 .addr_limit = KERNEL_DS, \
89 .restart_block = { \ 87 .restart_block = { \
90 .fn = do_no_restart_syscall, \ 88 .fn = do_no_restart_syscall, \
diff --git a/arch/microblaze/include/asm/timex.h b/arch/microblaze/include/asm/timex.h
index 678525dc6d0b..befcf3de5532 100644
--- a/arch/microblaze/include/asm/timex.h
+++ b/arch/microblaze/include/asm/timex.h
@@ -9,10 +9,8 @@
9#ifndef _ASM_MICROBLAZE_TIMEX_H 9#ifndef _ASM_MICROBLAZE_TIMEX_H
10#define _ASM_MICROBLAZE_TIMEX_H 10#define _ASM_MICROBLAZE_TIMEX_H
11 11
12#define CLOCK_TICK_RATE 1000 /* Timer input freq. */ 12#include <asm-generic/timex.h>
13
14typedef unsigned long cycles_t;
15 13
16#define get_cycles() (0) 14#define CLOCK_TICK_RATE 1000 /* Timer input freq. */
17 15
18#endif /* _ASM_TIMEX_H */ 16#endif /* _ASM_TIMEX_H */
diff --git a/arch/microblaze/include/asm/types.h b/arch/microblaze/include/asm/types.h
index bebc018318f5..b9e79bc580dd 100644
--- a/arch/microblaze/include/asm/types.h
+++ b/arch/microblaze/include/asm/types.h
@@ -1,38 +1 @@
1/* #include <asm-generic/types.h>
2 * Copyright (C) Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_TYPES_H
10#define _ASM_MICROBLAZE_TYPES_H
11
12/*
13 * This file is never included by application software unless
14 * explicitly requested (e.g., via linux/types.h) in which case the
15 * application is Linux specific so (user-) name space pollution is
16 * not a major issue. However, for interoperability, libraries still
17 * need to be careful to avoid a name clashes.
18 */
19
20#include <asm-generic/int-ll64.h>
21
22# ifndef __ASSEMBLY__
23
24typedef unsigned short umode_t;
25
26/*
27 * These aren't exported outside the kernel to avoid name space clashes
28 */
29# ifdef __KERNEL__
30# define BITS_PER_LONG 32
31
32/* Dma addresses are 32-bits wide. */
33
34typedef u32 dma_addr_t;
35
36# endif/* __KERNEL__ */
37# endif /* __ASSEMBLY__ */
38#endif /* _ASM_MICROBLAZE_TYPES_H */
diff --git a/arch/microblaze/include/asm/ucontext.h b/arch/microblaze/include/asm/ucontext.h
index 11f6bb3ae3a4..9bc07b9f30fb 100644
--- a/arch/microblaze/include/asm/ucontext.h
+++ b/arch/microblaze/include/asm/ucontext.h
@@ -1,22 +1 @@
1/* #include <asm-generic/ucontext.h>
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_UCONTEXT_H
10#define _ASM_MICROBLAZE_UCONTEXT_H
11
12#include <asm/sigcontext.h>
13
14struct ucontext {
15 unsigned long uc_flags;
16 struct ucontext *uc_link;
17 stack_t uc_stack;
18 struct sigcontext uc_mcontext;
19 sigset_t uc_sigmask; /* mask last for extensibility */
20};
21
22#endif /* _ASM_MICROBLAZE_UCONTEXT_H */
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index b5e2f5fa5c53..0b852327c0e7 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -380,8 +380,10 @@
380#define __NR_accept04 362 /* new */ 380#define __NR_accept04 362 /* new */
381#define __NR_preadv 363 /* new */ 381#define __NR_preadv 363 /* new */
382#define __NR_pwritev 364 /* new */ 382#define __NR_pwritev 364 /* new */
383#define __NR_rt_tgsigqueueinfo 365 /* new */
384#define __NR_perf_counter_open 366 /* new */
383 385
384#define __NR_syscalls 365 386#define __NR_syscalls 367
385 387
386#ifdef __KERNEL__ 388#ifdef __KERNEL__
387#ifndef __ASSEMBLY__ 389#ifndef __ASSEMBLY__
@@ -408,7 +410,7 @@
408#define __ARCH_WANT_SYS_SIGPENDING 410#define __ARCH_WANT_SYS_SIGPENDING
409#define __ARCH_WANT_SYS_SIGPROCMASK 411#define __ARCH_WANT_SYS_SIGPROCMASK
410#define __ARCH_WANT_SYS_RT_SIGACTION 412#define __ARCH_WANT_SYS_RT_SIGACTION
411/* #define __ARCH_WANT_SYS_RT_SIGSUSPEND */ 413#define __ARCH_WANT_SYS_RT_SIGSUSPEND
412 414
413/* 415/*
414 * "Conditional" syscalls 416 * "Conditional" syscalls
diff --git a/arch/microblaze/include/asm/vga.h b/arch/microblaze/include/asm/vga.h
index 8b137891791f..89d82fd8fcf1 100644
--- a/arch/microblaze/include/asm/vga.h
+++ b/arch/microblaze/include/asm/vga.h
@@ -1 +1 @@
#include <asm-generic/vga.h>
diff --git a/arch/microblaze/kernel/entry-nommu.S b/arch/microblaze/kernel/entry-nommu.S
index 1fce6b803f54..9083d85376a4 100644
--- a/arch/microblaze/kernel/entry-nommu.S
+++ b/arch/microblaze/kernel/entry-nommu.S
@@ -551,30 +551,22 @@ no_work_pending:
551 rtid r14, 0 551 rtid r14, 0
552 nop 552 nop
553 553
554sys_vfork_wrapper: 554sys_vfork:
555 brid sys_vfork 555 brid microblaze_vfork
556 addk r5, r1, r0 556 addk r5, r1, r0
557 557
558sys_clone_wrapper: 558sys_clone:
559 brid sys_clone 559 brid microblaze_clone
560 addk r7, r1, r0 560 addk r7, r1, r0
561 561
562sys_execve_wrapper: 562sys_execve:
563 brid sys_execve 563 brid microblaze_execve
564 addk r8, r1, r0 564 addk r8, r1, r0
565 565
566sys_sigreturn_wrapper:
567 brid sys_sigreturn
568 addk r5, r1, r0
569
570sys_rt_sigreturn_wrapper: 566sys_rt_sigreturn_wrapper:
571 brid sys_rt_sigreturn 567 brid sys_rt_sigreturn
572 addk r5, r1, r0 568 addk r5, r1, r0
573 569
574sys_sigsuspend_wrapper:
575 brid sys_rt_sigsuspend
576 addk r6, r1, r0
577
578sys_rt_sigsuspend_wrapper: 570sys_rt_sigsuspend_wrapper:
579 brid sys_rt_sigsuspend 571 brid sys_rt_sigsuspend
580 addk r7, r1, r0 572 addk r7, r1, r0
diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S
index 91a0e7b185dd..c7353e79f4a2 100644
--- a/arch/microblaze/kernel/entry.S
+++ b/arch/microblaze/kernel/entry.S
@@ -429,12 +429,11 @@ C_ENTRY(ret_from_fork):
429 brid ret_from_trap; /* Do normal trap return */ 429 brid ret_from_trap; /* Do normal trap return */
430 nop; 430 nop;
431 431
432C_ENTRY(sys_vfork_wrapper): 432C_ENTRY(sys_vfork):
433 brid microblaze_vfork /* Do real work (tail-call) */
433 la r5, r1, PTO 434 la r5, r1, PTO
434 brid sys_vfork /* Do real work (tail-call) */
435 nop
436 435
437C_ENTRY(sys_clone_wrapper): 436C_ENTRY(sys_clone):
438 bnei r6, 1f; /* See if child SP arg (arg 1) is 0. */ 437 bnei r6, 1f; /* See if child SP arg (arg 1) is 0. */
439 lwi r6, r1, PTO+PT_R1; /* If so, use paret's stack ptr */ 438 lwi r6, r1, PTO+PT_R1; /* If so, use paret's stack ptr */
4401: la r7, r1, PTO; /* Arg 2: parent context */ 4391: la r7, r1, PTO; /* Arg 2: parent context */
@@ -444,20 +443,9 @@ C_ENTRY(sys_clone_wrapper):
444 brid do_fork /* Do real work (tail-call) */ 443 brid do_fork /* Do real work (tail-call) */
445 nop; 444 nop;
446 445
447C_ENTRY(sys_execve_wrapper): 446C_ENTRY(sys_execve):
448 la r8, r1, PTO; /* add user context as 4th arg */ 447 la r8, r1, PTO; /* add user context as 4th arg */
449 brid sys_execve; /* Do real work (tail-call).*/ 448 brid microblaze_execve; /* Do real work (tail-call).*/
450 nop;
451
452C_ENTRY(sys_sigsuspend_wrapper):
453 swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
454 swi r4, r1, PTO+PT_R4;
455 la r6, r1, PTO; /* add user context as 2nd arg */
456 bralid r15, sys_sigsuspend; /* Do real work.*/
457 nop;
458 lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
459 lwi r4, r1, PTO+PT_R4;
460 bri ret_from_trap /* fall through will not work here due to align */
461 nop; 449 nop;
462 450
463C_ENTRY(sys_rt_sigsuspend_wrapper): 451C_ENTRY(sys_rt_sigsuspend_wrapper):
@@ -471,18 +459,6 @@ C_ENTRY(sys_rt_sigsuspend_wrapper):
471 bri ret_from_trap /* fall through will not work here due to align */ 459 bri ret_from_trap /* fall through will not work here due to align */
472 nop; 460 nop;
473 461
474
475C_ENTRY(sys_sigreturn_wrapper):
476 swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
477 swi r4, r1, PTO+PT_R4;
478 la r5, r1, PTO; /* add user context as 1st arg */
479 brlid r15, sys_sigreturn; /* Do real work.*/
480 nop;
481 lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
482 lwi r4, r1, PTO+PT_R4;
483 bri ret_from_trap /* fall through will not work here due to align */
484 nop;
485
486C_ENTRY(sys_rt_sigreturn_wrapper): 462C_ENTRY(sys_rt_sigreturn_wrapper):
487 swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ 463 swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
488 swi r4, r1, PTO+PT_R4; 464 swi r4, r1, PTO+PT_R4;
diff --git a/arch/microblaze/kernel/ptrace.c b/arch/microblaze/kernel/ptrace.c
index b86aa623e36d..53ff39af6a5c 100644
--- a/arch/microblaze/kernel/ptrace.c
+++ b/arch/microblaze/kernel/ptrace.c
@@ -27,7 +27,6 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/smp_lock.h>
31#include <linux/ptrace.h> 30#include <linux/ptrace.h>
32#include <linux/signal.h> 31#include <linux/signal.h>
33 32
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 4c0e6521b114..1c80e4fc40ce 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -21,7 +21,6 @@
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/smp.h> 23#include <linux/smp.h>
24#include <linux/smp_lock.h>
25#include <linux/kernel.h> 24#include <linux/kernel.h>
26#include <linux/signal.h> 25#include <linux/signal.h>
27#include <linux/errno.h> 26#include <linux/errno.h>
@@ -45,91 +44,8 @@
45 44
46asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset, int in_sycall); 45asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset, int in_sycall);
47 46
48/*
49 * Atomically swap in the new signal mask, and wait for a signal.
50 */
51asmlinkage int
52sys_sigsuspend(old_sigset_t mask, struct pt_regs *regs)
53{
54 sigset_t saveset;
55
56 mask &= _BLOCKABLE;
57 spin_lock_irq(&current->sighand->siglock);
58 saveset = current->blocked;
59 siginitset(&current->blocked, mask);
60 recalc_sigpending();
61 spin_unlock_irq(&current->sighand->siglock);
62
63 regs->r3 = -EINTR;
64 while (1) {
65 current->state = TASK_INTERRUPTIBLE;
66 schedule();
67 if (do_signal(regs, &saveset, 1))
68 return -EINTR;
69 }
70}
71
72asmlinkage int
73sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize,
74 struct pt_regs *regs)
75{
76 sigset_t saveset, newset;
77
78 /* XXX: Don't preclude handling different sized sigset_t's. */
79 if (sigsetsize != sizeof(sigset_t))
80 return -EINVAL;
81
82 if (copy_from_user(&newset, unewset, sizeof(newset)))
83 return -EFAULT;
84 sigdelsetmask(&newset, ~_BLOCKABLE);
85 spin_lock_irq(&current->sighand->siglock);
86 saveset = current->blocked;
87 current->blocked = newset;
88 recalc_sigpending();
89 spin_unlock_irq(&current->sighand->siglock);
90
91 regs->r3 = -EINTR;
92 while (1) {
93 current->state = TASK_INTERRUPTIBLE;
94 schedule();
95 if (do_signal(regs, &saveset, 1))
96 return -EINTR;
97 }
98}
99
100asmlinkage int
101sys_sigaction(int sig, const struct old_sigaction *act,
102 struct old_sigaction *oact)
103{
104 struct k_sigaction new_ka, old_ka;
105 int ret;
106
107 if (act) {
108 old_sigset_t mask;
109 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
110 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
111 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
112 return -EFAULT;
113 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
114 __get_user(mask, &act->sa_mask);
115 siginitset(&new_ka.sa.sa_mask, mask);
116 }
117 47
118 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); 48asmlinkage long
119
120 if (!ret && oact) {
121 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
122 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
123 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
124 return -EFAULT;
125 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
126 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
127 }
128
129 return ret;
130}
131
132asmlinkage int
133sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, 49sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
134 struct pt_regs *regs) 50 struct pt_regs *regs)
135{ 51{
@@ -139,7 +55,6 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
139/* 55/*
140 * Do a signal return; undo the signal stack. 56 * Do a signal return; undo the signal stack.
141 */ 57 */
142
143struct sigframe { 58struct sigframe {
144 struct sigcontext sc; 59 struct sigcontext sc;
145 unsigned long extramask[_NSIG_WORDS-1]; 60 unsigned long extramask[_NSIG_WORDS-1];
@@ -176,40 +91,7 @@ static int restore_sigcontext(struct pt_regs *regs,
176 return err; 91 return err;
177} 92}
178 93
179asmlinkage int sys_sigreturn(struct pt_regs *regs) 94asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
180{
181 struct sigframe *frame =
182 (struct sigframe *)(regs->r1 + STATE_SAVE_ARG_SPACE);
183
184 sigset_t set;
185 int rval;
186
187 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
188 goto badframe;
189
190 if (__get_user(set.sig[0], &frame->sc.oldmask)
191 || (_NSIG_WORDS > 1
192 && __copy_from_user(&set.sig[1], &frame->extramask,
193 sizeof(frame->extramask))))
194 goto badframe;
195
196 sigdelsetmask(&set, ~_BLOCKABLE);
197
198 spin_lock_irq(&current->sighand->siglock);
199 current->blocked = set;
200 recalc_sigpending();
201 spin_unlock_irq(&current->sighand->siglock);
202
203 if (restore_sigcontext(regs, &frame->sc, &rval))
204 goto badframe;
205 return rval;
206
207badframe:
208 force_sig(SIGSEGV, current);
209 return 0;
210}
211
212asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
213{ 95{
214 struct rt_sigframe __user *frame = 96 struct rt_sigframe __user *frame =
215 (struct rt_sigframe __user *)(regs->r1 + STATE_SAVE_ARG_SPACE); 97 (struct rt_sigframe __user *)(regs->r1 + STATE_SAVE_ARG_SPACE);
@@ -324,21 +206,17 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
324 /* Set up to return from userspace. If provided, use a stub 206 /* Set up to return from userspace. If provided, use a stub
325 already in userspace. */ 207 already in userspace. */
326 /* minus 8 is offset to cater for "rtsd r15,8" */ 208 /* minus 8 is offset to cater for "rtsd r15,8" */
327 if (ka->sa.sa_flags & SA_RESTORER) { 209 /* addi r12, r0, __NR_sigreturn */
328 regs->r15 = ((unsigned long)ka->sa.sa_restorer)-8; 210 err |= __put_user(0x31800000 | __NR_rt_sigreturn ,
329 } else { 211 frame->tramp + 0);
330 /* addi r12, r0, __NR_sigreturn */ 212 /* brki r14, 0x8 */
331 err |= __put_user(0x31800000 | __NR_rt_sigreturn , 213 err |= __put_user(0xb9cc0008, frame->tramp + 1);
332 frame->tramp + 0); 214
333 /* brki r14, 0x8 */ 215 /* Return from sighandler will jump to the tramp.
334 err |= __put_user(0xb9cc0008, frame->tramp + 1); 216 Negative 8 offset because return is rtsd r15, 8 */
335 217 regs->r15 = ((unsigned long)frame->tramp)-8;
336 /* Return from sighandler will jump to the tramp. 218
337 Negative 8 offset because return is rtsd r15, 8 */ 219 __invalidate_cache_sigtramp((unsigned long)frame->tramp);
338 regs->r15 = ((unsigned long)frame->tramp)-8;
339
340 __invalidate_cache_sigtramp((unsigned long)frame->tramp);
341 }
342 220
343 if (err) 221 if (err)
344 goto give_sigsegv; 222 goto give_sigsegv;
@@ -405,7 +283,7 @@ do_restart:
405 * OK, we're invoking a handler 283 * OK, we're invoking a handler
406 */ 284 */
407 285
408static void 286static int
409handle_signal(unsigned long sig, struct k_sigaction *ka, 287handle_signal(unsigned long sig, struct k_sigaction *ka,
410 siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) 288 siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
411{ 289{
@@ -426,6 +304,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
426 recalc_sigpending(); 304 recalc_sigpending();
427 spin_unlock_irq(&current->sighand->siglock); 305 spin_unlock_irq(&current->sighand->siglock);
428 } 306 }
307 return 1;
429} 308}
430 309
431/* 310/*
@@ -456,7 +335,9 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int in_syscall)
456 if (kernel_mode(regs)) 335 if (kernel_mode(regs))
457 return 1; 336 return 1;
458 337
459 if (!oldset) 338 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
339 oldset = &current->saved_sigmask;
340 else
460 oldset = &current->blocked; 341 oldset = &current->blocked;
461 342
462 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 343 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
@@ -464,13 +345,31 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int in_syscall)
464 /* Whee! Actually deliver the signal. */ 345 /* Whee! Actually deliver the signal. */
465 if (in_syscall) 346 if (in_syscall)
466 handle_restart(regs, &ka, 1); 347 handle_restart(regs, &ka, 1);
467 handle_signal(signr, &ka, &info, oldset, regs); 348 if (handle_signal(signr, &ka, &info, oldset, regs)) {
349 /*
350 * A signal was successfully delivered; the saved
351 * sigmask will have been stored in the signal frame,
352 * and will be restored by sigreturn, so we can simply
353 * clear the TS_RESTORE_SIGMASK flag.
354 */
355 current_thread_info()->status &=
356 ~TS_RESTORE_SIGMASK;
357 }
468 return 1; 358 return 1;
469 } 359 }
470 360
471 if (in_syscall) 361 if (in_syscall)
472 handle_restart(regs, NULL, 0); 362 handle_restart(regs, NULL, 0);
473 363
364 /*
365 * If there's no signal to deliver, we just put the saved sigmask
366 * back.
367 */
368 if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
369 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
370 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
371 }
372
474 /* Did we come from a system call? */ 373 /* Did we come from a system call? */
475 return 0; 374 return 0;
476} 375}
diff --git a/arch/microblaze/kernel/sys_microblaze.c b/arch/microblaze/kernel/sys_microblaze.c
index 31905ff590b7..e000bce09b2b 100644
--- a/arch/microblaze/kernel/sys_microblaze.c
+++ b/arch/microblaze/kernel/sys_microblaze.c
@@ -15,7 +15,6 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/smp_lock.h>
19#include <linux/syscalls.h> 18#include <linux/syscalls.h>
20#include <linux/sem.h> 19#include <linux/sem.h>
21#include <linux/msg.h> 20#include <linux/msg.h>
@@ -39,7 +38,7 @@
39 * 38 *
40 * This is really horribly ugly. This will be remove with new toolchain. 39 * This is really horribly ugly. This will be remove with new toolchain.
41 */ 40 */
42asmlinkage int 41asmlinkage long
43sys_ipc(uint call, int first, int second, int third, void *ptr, long fifth) 42sys_ipc(uint call, int first, int second, int third, void *ptr, long fifth)
44{ 43{
45 int version, ret; 44 int version, ret;
@@ -134,20 +133,20 @@ sys_ipc(uint call, int first, int second, int third, void *ptr, long fifth)
134 return ret; 133 return ret;
135} 134}
136 135
137asmlinkage int sys_vfork(struct pt_regs *regs) 136asmlinkage long microblaze_vfork(struct pt_regs *regs)
138{ 137{
139 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->r1, 138 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->r1,
140 regs, 0, NULL, NULL); 139 regs, 0, NULL, NULL);
141} 140}
142 141
143asmlinkage int sys_clone(int flags, unsigned long stack, struct pt_regs *regs) 142asmlinkage long microblaze_clone(int flags, unsigned long stack, struct pt_regs *regs)
144{ 143{
145 if (!stack) 144 if (!stack)
146 stack = regs->r1; 145 stack = regs->r1;
147 return do_fork(flags, stack, regs, 0, NULL, NULL); 146 return do_fork(flags, stack, regs, 0, NULL, NULL);
148} 147}
149 148
150asmlinkage int sys_execve(char __user *filenamei, char __user *__user *argv, 149asmlinkage long microblaze_execve(char __user *filenamei, char __user *__user *argv,
151 char __user *__user *envp, struct pt_regs *regs) 150 char __user *__user *envp, struct pt_regs *regs)
152{ 151{
153 int error; 152 int error;
@@ -163,8 +162,8 @@ out:
163 return error; 162 return error;
164} 163}
165 164
166asmlinkage unsigned long 165asmlinkage long
167sys_mmap2(unsigned long addr, size_t len, 166sys_mmap2(unsigned long addr, unsigned long len,
168 unsigned long prot, unsigned long flags, 167 unsigned long prot, unsigned long flags,
169 unsigned long fd, unsigned long pgoff) 168 unsigned long fd, unsigned long pgoff)
170{ 169{
@@ -189,18 +188,18 @@ out:
189 return ret; 188 return ret;
190} 189}
191 190
192asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len, 191asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
193 unsigned long prot, unsigned long flags, 192 unsigned long prot, unsigned long flags,
194 unsigned long fd, off_t offset) 193 unsigned long fd, off_t pgoff)
195{ 194{
196 int err = -EINVAL; 195 int err = -EINVAL;
197 196
198 if (offset & ~PAGE_MASK) { 197 if (pgoff & ~PAGE_MASK) {
199 printk(KERN_INFO "no pagemask in mmap\r\n"); 198 printk(KERN_INFO "no pagemask in mmap\r\n");
200 goto out; 199 goto out;
201 } 200 }
202 201
203 err = sys_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT); 202 err = sys_mmap2(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);
204out: 203out:
205 return err; 204 return err;
206} 205}
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index 376d1789f7c0..31b32a6c5f4e 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -15,7 +15,7 @@ ENTRY(sys_call_table)
15 .long sys_creat 15 .long sys_creat
16 .long sys_link 16 .long sys_link
17 .long sys_unlink /* 10 */ 17 .long sys_unlink /* 10 */
18 .long sys_execve_wrapper 18 .long sys_execve
19 .long sys_chdir 19 .long sys_chdir
20 .long sys_time 20 .long sys_time
21 .long sys_mknod 21 .long sys_mknod
@@ -71,12 +71,12 @@ ENTRY(sys_call_table)
71 .long sys_getppid 71 .long sys_getppid
72 .long sys_getpgrp /* 65 */ 72 .long sys_getpgrp /* 65 */
73 .long sys_setsid 73 .long sys_setsid
74 .long sys_sigaction 74 .long sys_ni_syscall /* sys_sigaction */
75 .long sys_sgetmask 75 .long sys_sgetmask
76 .long sys_ssetmask 76 .long sys_ssetmask
77 .long sys_setreuid /* 70 */ 77 .long sys_setreuid /* 70 */
78 .long sys_setregid 78 .long sys_setregid
79 .long sys_sigsuspend_wrapper 79 .long sys_ni_syscall /* sys_sigsuspend_wrapper */
80 .long sys_sigpending 80 .long sys_sigpending
81 .long sys_sethostname 81 .long sys_sethostname
82 .long sys_setrlimit /* 75 */ 82 .long sys_setrlimit /* 75 */
@@ -123,8 +123,8 @@ ENTRY(sys_call_table)
123 .long sys_sysinfo 123 .long sys_sysinfo
124 .long sys_ipc 124 .long sys_ipc
125 .long sys_fsync 125 .long sys_fsync
126 .long sys_sigreturn_wrapper 126 .long sys_ni_syscall /* sys_sigreturn_wrapper */
127 .long sys_clone_wrapper /* 120 */ 127 .long sys_clone /* 120 */
128 .long sys_setdomainname 128 .long sys_setdomainname
129 .long sys_newuname 129 .long sys_newuname
130 .long sys_ni_syscall /* modify_ldt */ 130 .long sys_ni_syscall /* modify_ldt */
@@ -194,7 +194,7 @@ ENTRY(sys_call_table)
194 .long sys_sendfile 194 .long sys_sendfile
195 .long sys_ni_syscall /* reserved for streams1 */ 195 .long sys_ni_syscall /* reserved for streams1 */
196 .long sys_ni_syscall /* reserved for streams2 */ 196 .long sys_ni_syscall /* reserved for streams2 */
197 .long sys_vfork_wrapper /* 190 */ 197 .long sys_vfork /* 190 */
198 .long sys_getrlimit 198 .long sys_getrlimit
199 .long sys_mmap2 /* mmap2 */ 199 .long sys_mmap2 /* mmap2 */
200 .long sys_truncate64 200 .long sys_truncate64
@@ -369,3 +369,5 @@ ENTRY(sys_call_table)
369 .long sys_ni_syscall 369 .long sys_ni_syscall
370 .long sys_ni_syscall 370 .long sys_ni_syscall
371 .long sys_ni_syscall 371 .long sys_ni_syscall
372 .long sys_rt_tgsigqueueinfo /* 365 */
373 .long sys_perf_counter_open
diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile
index 71c8cb6c9e43..b579db068c06 100644
--- a/arch/microblaze/lib/Makefile
+++ b/arch/microblaze/lib/Makefile
@@ -2,7 +2,7 @@
2# Makefile 2# Makefile
3# 3#
4 4
5lib-y := memset.o checksum.o 5lib-y := memset.o
6 6
7ifeq ($(CONFIG_OPT_LIB_ASM),y) 7ifeq ($(CONFIG_OPT_LIB_ASM),y)
8lib-y += fastcopy.o 8lib-y += fastcopy.o
diff --git a/arch/microblaze/lib/checksum.c b/arch/microblaze/lib/checksum.c
deleted file mode 100644
index f08e74591418..000000000000
--- a/arch/microblaze/lib/checksum.c
+++ /dev/null
@@ -1,172 +0,0 @@
1/*
2 *
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
6 *
7 * IP/TCP/UDP checksumming routines
8 *
9 * Authors: Jorge Cwik, <jorge@laser.satlink.net>
10 * Arnt Gulbrandsen, <agulbra@nvg.unit.no>
11 * Tom May, <ftom@netcom.com>
12 * Andreas Schwab, <schwab@issan.informatik.uni-dortmund.de>
13 * Lots of code moved from tcp.c and ip.c; see those files
14 * for more names.
15 *
16 * 03/02/96 Jes Sorensen, Andreas Schwab, Roman Hodek:
17 * Fixed some nasty bugs, causing some horrible crashes.
18 * A: At some points, the sum (%0) was used as
19 * length-counter instead of the length counter
20 * (%1). Thanks to Roman Hodek for pointing this out.
21 * B: GCC seems to mess up if one uses too many
22 * data-registers to hold input values and one tries to
23 * specify d0 and d1 as scratch registers. Letting gcc
24 * choose these registers itself solves the problem.
25 *
26 * This program is free software; you can redistribute it and/or
27 * modify it under the terms of the GNU General Public License
28 * as published by the Free Software Foundation; either version
29 * 2 of the License, or (at your option) any later version.
30 */
31
32/* Revised by Kenneth Albanowski for m68knommu. Basic problem: unaligned access
33 kills, so most of the assembly has to go. */
34
35#include <linux/module.h>
36#include <net/checksum.h>
37
38#include <asm/byteorder.h>
39
40static inline unsigned short from32to16(unsigned long x)
41{
42 /* add up 16-bit and 16-bit for 16+c bit */
43 x = (x & 0xffff) + (x >> 16);
44 /* add up carry.. */
45 x = (x & 0xffff) + (x >> 16);
46 return x;
47}
48
49static unsigned int do_csum(const unsigned char *buff, int len)
50{
51 int odd, count;
52 unsigned long result = 0;
53
54 if (len <= 0)
55 goto out;
56 odd = 1 & (unsigned long) buff;
57 if (odd) {
58 result = *buff;
59 len--;
60 buff++;
61 }
62 count = len >> 1; /* nr of 16-bit words.. */
63 if (count) {
64 if (2 & (unsigned long) buff) {
65 result += *(unsigned short *) buff;
66 count--;
67 len -= 2;
68 buff += 2;
69 }
70 count >>= 1; /* nr of 32-bit words.. */
71 if (count) {
72 unsigned long carry = 0;
73 do {
74 unsigned long w = *(unsigned long *) buff;
75 count--;
76 buff += 4;
77 result += carry;
78 result += w;
79 carry = (w > result);
80 } while (count);
81 result += carry;
82 result = (result & 0xffff) + (result >> 16);
83 }
84 if (len & 2) {
85 result += *(unsigned short *) buff;
86 buff += 2;
87 }
88 }
89 if (len & 1)
90 result += (*buff << 8);
91 result = from32to16(result);
92 if (odd)
93 result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
94out:
95 return result;
96}
97
98/*
99 * This is a version of ip_compute_csum() optimized for IP headers,
100 * which always checksum on 4 octet boundaries.
101 */
102__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
103{
104 return (__force __sum16)~do_csum(iph, ihl*4);
105}
106EXPORT_SYMBOL(ip_fast_csum);
107
108/*
109 * computes the checksum of a memory block at buff, length len,
110 * and adds in "sum" (32-bit)
111 *
112 * returns a 32-bit number suitable for feeding into itself
113 * or csum_tcpudp_magic
114 *
115 * this function must be called with even lengths, except
116 * for the last fragment, which may be odd
117 *
118 * it's best to have buff aligned on a 32-bit boundary
119 */
120__wsum csum_partial(const void *buff, int len, __wsum wsum)
121{
122 unsigned int sum = (__force unsigned int)wsum;
123 unsigned int result = do_csum(buff, len);
124
125 /* add in old sum, and carry.. */
126 result += sum;
127 if (sum > result)
128 result += 1;
129 return (__force __wsum)result;
130}
131EXPORT_SYMBOL(csum_partial);
132
133/*
134 * this routine is used for miscellaneous IP-like checksums, mainly
135 * in icmp.c
136 */
137__sum16 ip_compute_csum(const void *buff, int len)
138{
139 return (__force __sum16)~do_csum(buff, len);
140}
141EXPORT_SYMBOL(ip_compute_csum);
142
143/*
144 * copy from fs while checksumming, otherwise like csum_partial
145 */
146__wsum
147csum_partial_copy_from_user(const void __user *src, void *dst, int len,
148 __wsum sum, int *csum_err)
149{
150 int missing;
151
152 missing = __copy_from_user(dst, src, len);
153 if (missing) {
154 memset(dst + len - missing, 0, missing);
155 *csum_err = -EFAULT;
156 } else
157 *csum_err = 0;
158
159 return csum_partial(dst, len, sum);
160}
161EXPORT_SYMBOL(csum_partial_copy_from_user);
162
163/*
164 * copy from ds while checksumming, otherwise like csum_partial
165 */
166__wsum
167csum_partial_copy(const void *src, void *dst, int len, __wsum sum)
168{
169 memcpy(dst, src, len);
170 return csum_partial(dst, len, sum);
171}
172EXPORT_SYMBOL(csum_partial_copy);
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index b5a701cd71e0..8d92c4efe9a4 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -80,15 +80,15 @@ void __init setup_memory(void)
80 memory_size = memory_end - memory_start; 80 memory_size = memory_end - memory_start;
81 PAGE_OFFSET = memory_start; 81 PAGE_OFFSET = memory_start;
82 printk(KERN_INFO "%s: Main mem: 0x%x-0x%x, " 82 printk(KERN_INFO "%s: Main mem: 0x%x-0x%x, "
83 "size 0x%08x\n", __func__, memory_start, 83 "size 0x%08x\n", __func__, (u32) memory_start,
84 memory_end, memory_size); 84 (u32) memory_end, (u32) memory_size);
85 break; 85 break;
86 } 86 }
87 } 87 }
88 88
89 if (!memory_start || !memory_end) { 89 if (!memory_start || !memory_end) {
90 panic("%s: Missing memory setting 0x%08x-0x%08x\n", 90 panic("%s: Missing memory setting 0x%08x-0x%08x\n",
91 __func__, memory_start, memory_end); 91 __func__, (u32) memory_start, (u32) memory_end);
92 } 92 }
93 93
94 /* reservation of region where is the kernel */ 94 /* reservation of region where is the kernel */
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 8c4be1f301cf..3ca0fe1a9123 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -22,6 +22,26 @@ choice
22config MACH_ALCHEMY 22config MACH_ALCHEMY
23 bool "Alchemy processor based machines" 23 bool "Alchemy processor based machines"
24 24
25config AR7
26 bool "Texas Instruments AR7"
27 select BOOT_ELF32
28 select DMA_NONCOHERENT
29 select CEVT_R4K
30 select CSRC_R4K
31 select IRQ_CPU
32 select NO_EXCEPT_FILL
33 select SWAP_IO_SPACE
34 select SYS_HAS_CPU_MIPS32_R1
35 select SYS_HAS_EARLY_PRINTK
36 select SYS_SUPPORTS_32BIT_KERNEL
37 select SYS_SUPPORTS_LITTLE_ENDIAN
38 select GENERIC_GPIO
39 select GCD
40 select VLYNQ
41 help
42 Support for the Texas Instruments AR7 System-on-a-Chip
43 family: TNETD7100, 7200 and 7300.
44
25config BASLER_EXCITE 45config BASLER_EXCITE
26 bool "Basler eXcite smart camera" 46 bool "Basler eXcite smart camera"
27 select CEVT_R4K 47 select CEVT_R4K
@@ -209,7 +229,7 @@ config MIPS_MALTA
209 select SYS_SUPPORTS_64BIT_KERNEL 229 select SYS_SUPPORTS_64BIT_KERNEL
210 select SYS_SUPPORTS_BIG_ENDIAN 230 select SYS_SUPPORTS_BIG_ENDIAN
211 select SYS_SUPPORTS_LITTLE_ENDIAN 231 select SYS_SUPPORTS_LITTLE_ENDIAN
212 select SYS_SUPPORTS_MIPS_CMP if BROKEN # because SYNC_R4K is broken 232 select SYS_SUPPORTS_MIPS_CMP
213 select SYS_SUPPORTS_MULTITHREADING 233 select SYS_SUPPORTS_MULTITHREADING
214 select SYS_SUPPORTS_SMARTMIPS 234 select SYS_SUPPORTS_SMARTMIPS
215 help 235 help
@@ -247,6 +267,7 @@ config MACH_VR41XX
247 select CEVT_R4K 267 select CEVT_R4K
248 select CSRC_R4K 268 select CSRC_R4K
249 select SYS_HAS_CPU_VR41XX 269 select SYS_HAS_CPU_VR41XX
270 select ARCH_REQUIRE_GPIOLIB
250 271
251config NXP_STB220 272config NXP_STB220
252 bool "NXP STB220 board" 273 bool "NXP STB220 board"
@@ -1635,7 +1656,7 @@ config MIPS_APSP_KSPD
1635config MIPS_CMP 1656config MIPS_CMP
1636 bool "MIPS CMP framework support" 1657 bool "MIPS CMP framework support"
1637 depends on SYS_SUPPORTS_MIPS_CMP 1658 depends on SYS_SUPPORTS_MIPS_CMP
1638 select SYNC_R4K if BROKEN 1659 select SYNC_R4K
1639 select SYS_SUPPORTS_SMP 1660 select SYS_SUPPORTS_SMP
1640 select SYS_SUPPORTS_SCHED_SMT if SMP 1661 select SYS_SUPPORTS_SCHED_SMT if SMP
1641 select WEAK_ORDERING 1662 select WEAK_ORDERING
@@ -2147,11 +2168,11 @@ menu "Power management options"
2147 2168
2148config ARCH_HIBERNATION_POSSIBLE 2169config ARCH_HIBERNATION_POSSIBLE
2149 def_bool y 2170 def_bool y
2150 depends on SYS_SUPPORTS_HOTPLUG_CPU 2171 depends on SYS_SUPPORTS_HOTPLUG_CPU || !SMP
2151 2172
2152config ARCH_SUSPEND_POSSIBLE 2173config ARCH_SUSPEND_POSSIBLE
2153 def_bool y 2174 def_bool y
2154 depends on SYS_SUPPORTS_HOTPLUG_CPU 2175 depends on SYS_SUPPORTS_HOTPLUG_CPU || !SMP
2155 2176
2156source "kernel/power/Kconfig" 2177source "kernel/power/Kconfig"
2157 2178
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 807572a6a4d2..861da514a468 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -173,6 +173,13 @@ libs-y += arch/mips/fw/lib/
173# 173#
174 174
175# 175#
176# Texas Instruments AR7
177#
178core-$(CONFIG_AR7) += arch/mips/ar7/
179cflags-$(CONFIG_AR7) += -I$(srctree)/arch/mips/include/asm/mach-ar7
180load-$(CONFIG_AR7) += 0xffffffff94100000
181
182#
176# Acer PICA 61, Mips Magnum 4000 and Olivetti M700. 183# Acer PICA 61, Mips Magnum 4000 and Olivetti M700.
177# 184#
178core-$(CONFIG_MACH_JAZZ) += arch/mips/jazz/ 185core-$(CONFIG_MACH_JAZZ) += arch/mips/jazz/
diff --git a/arch/mips/ar7/Makefile b/arch/mips/ar7/Makefile
new file mode 100644
index 000000000000..7435e44b3964
--- /dev/null
+++ b/arch/mips/ar7/Makefile
@@ -0,0 +1,10 @@
1
2obj-y := \
3 prom.o \
4 setup.o \
5 memory.o \
6 irq.o \
7 time.o \
8 platform.o \
9 gpio.o \
10 clock.o
diff --git a/arch/mips/ar7/clock.c b/arch/mips/ar7/clock.c
new file mode 100644
index 000000000000..27dc6663f2fa
--- /dev/null
+++ b/arch/mips/ar7/clock.c
@@ -0,0 +1,440 @@
1/*
2 * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2007 Eugene Konev <ejka@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/types.h>
23#include <linux/module.h>
24#include <linux/delay.h>
25#include <linux/gcd.h>
26#include <linux/io.h>
27
28#include <asm/addrspace.h>
29#include <asm/mach-ar7/ar7.h>
30
31#define BOOT_PLL_SOURCE_MASK 0x3
32#define CPU_PLL_SOURCE_SHIFT 16
33#define BUS_PLL_SOURCE_SHIFT 14
34#define USB_PLL_SOURCE_SHIFT 18
35#define DSP_PLL_SOURCE_SHIFT 22
36#define BOOT_PLL_SOURCE_AFE 0
37#define BOOT_PLL_SOURCE_BUS 0
38#define BOOT_PLL_SOURCE_REF 1
39#define BOOT_PLL_SOURCE_XTAL 2
40#define BOOT_PLL_SOURCE_CPU 3
41#define BOOT_PLL_BYPASS 0x00000020
42#define BOOT_PLL_ASYNC_MODE 0x02000000
43#define BOOT_PLL_2TO1_MODE 0x00008000
44
45#define TNETD7200_CLOCK_ID_CPU 0
46#define TNETD7200_CLOCK_ID_DSP 1
47#define TNETD7200_CLOCK_ID_USB 2
48
49#define TNETD7200_DEF_CPU_CLK 211000000
50#define TNETD7200_DEF_DSP_CLK 125000000
51#define TNETD7200_DEF_USB_CLK 48000000
52
53struct tnetd7300_clock {
54 u32 ctrl;
55#define PREDIV_MASK 0x001f0000
56#define PREDIV_SHIFT 16
57#define POSTDIV_MASK 0x0000001f
58 u32 unused1[3];
59 u32 pll;
60#define MUL_MASK 0x0000f000
61#define MUL_SHIFT 12
62#define PLL_MODE_MASK 0x00000001
63#define PLL_NDIV 0x00000800
64#define PLL_DIV 0x00000002
65#define PLL_STATUS 0x00000001
66 u32 unused2[3];
67};
68
69struct tnetd7300_clocks {
70 struct tnetd7300_clock bus;
71 struct tnetd7300_clock cpu;
72 struct tnetd7300_clock usb;
73 struct tnetd7300_clock dsp;
74};
75
76struct tnetd7200_clock {
77 u32 ctrl;
78 u32 unused1[3];
79#define DIVISOR_ENABLE_MASK 0x00008000
80 u32 mul;
81 u32 prediv;
82 u32 postdiv;
83 u32 postdiv2;
84 u32 unused2[6];
85 u32 cmd;
86 u32 status;
87 u32 cmden;
88 u32 padding[15];
89};
90
91struct tnetd7200_clocks {
92 struct tnetd7200_clock cpu;
93 struct tnetd7200_clock dsp;
94 struct tnetd7200_clock usb;
95};
96
97int ar7_cpu_clock = 150000000;
98EXPORT_SYMBOL(ar7_cpu_clock);
99int ar7_bus_clock = 125000000;
100EXPORT_SYMBOL(ar7_bus_clock);
101int ar7_dsp_clock;
102EXPORT_SYMBOL(ar7_dsp_clock);
103
104static void approximate(int base, int target, int *prediv,
105 int *postdiv, int *mul)
106{
107 int i, j, k, freq, res = target;
108 for (i = 1; i <= 16; i++)
109 for (j = 1; j <= 32; j++)
110 for (k = 1; k <= 32; k++) {
111 freq = abs(base / j * i / k - target);
112 if (freq < res) {
113 res = freq;
114 *mul = i;
115 *prediv = j;
116 *postdiv = k;
117 }
118 }
119}
120
121static void calculate(int base, int target, int *prediv, int *postdiv,
122 int *mul)
123{
124 int tmp_gcd, tmp_base, tmp_freq;
125
126 for (*prediv = 1; *prediv <= 32; (*prediv)++) {
127 tmp_base = base / *prediv;
128 tmp_gcd = gcd(target, tmp_base);
129 *mul = target / tmp_gcd;
130 *postdiv = tmp_base / tmp_gcd;
131 if ((*mul < 1) || (*mul >= 16))
132 continue;
133 if ((*postdiv > 0) & (*postdiv <= 32))
134 break;
135 }
136
137 if (base / *prediv * *mul / *postdiv != target) {
138 approximate(base, target, prediv, postdiv, mul);
139 tmp_freq = base / *prediv * *mul / *postdiv;
140 printk(KERN_WARNING
141 "Adjusted requested frequency %d to %d\n",
142 target, tmp_freq);
143 }
144
145 printk(KERN_DEBUG "Clocks: prediv: %d, postdiv: %d, mul: %d\n",
146 *prediv, *postdiv, *mul);
147}
148
149static int tnetd7300_dsp_clock(void)
150{
151 u32 didr1, didr2;
152 u8 rev = ar7_chip_rev();
153 didr1 = readl((void *)KSEG1ADDR(AR7_REGS_GPIO + 0x18));
154 didr2 = readl((void *)KSEG1ADDR(AR7_REGS_GPIO + 0x1c));
155 if (didr2 & (1 << 23))
156 return 0;
157 if ((rev >= 0x23) && (rev != 0x57))
158 return 250000000;
159 if ((((didr2 & 0x1fff) << 10) | ((didr1 & 0xffc00000) >> 22))
160 > 4208000)
161 return 250000000;
162 return 0;
163}
164
165static int tnetd7300_get_clock(u32 shift, struct tnetd7300_clock *clock,
166 u32 *bootcr, u32 bus_clock)
167{
168 int product;
169 int base_clock = AR7_REF_CLOCK;
170 u32 ctrl = readl(&clock->ctrl);
171 u32 pll = readl(&clock->pll);
172 int prediv = ((ctrl & PREDIV_MASK) >> PREDIV_SHIFT) + 1;
173 int postdiv = (ctrl & POSTDIV_MASK) + 1;
174 int divisor = prediv * postdiv;
175 int mul = ((pll & MUL_MASK) >> MUL_SHIFT) + 1;
176
177 switch ((*bootcr & (BOOT_PLL_SOURCE_MASK << shift)) >> shift) {
178 case BOOT_PLL_SOURCE_BUS:
179 base_clock = bus_clock;
180 break;
181 case BOOT_PLL_SOURCE_REF:
182 base_clock = AR7_REF_CLOCK;
183 break;
184 case BOOT_PLL_SOURCE_XTAL:
185 base_clock = AR7_XTAL_CLOCK;
186 break;
187 case BOOT_PLL_SOURCE_CPU:
188 base_clock = ar7_cpu_clock;
189 break;
190 }
191
192 if (*bootcr & BOOT_PLL_BYPASS)
193 return base_clock / divisor;
194
195 if ((pll & PLL_MODE_MASK) == 0)
196 return (base_clock >> (mul / 16 + 1)) / divisor;
197
198 if ((pll & (PLL_NDIV | PLL_DIV)) == (PLL_NDIV | PLL_DIV)) {
199 product = (mul & 1) ?
200 (base_clock * mul) >> 1 :
201 (base_clock * (mul - 1)) >> 2;
202 return product / divisor;
203 }
204
205 if (mul == 16)
206 return base_clock / divisor;
207
208 return base_clock * mul / divisor;
209}
210
211static void tnetd7300_set_clock(u32 shift, struct tnetd7300_clock *clock,
212 u32 *bootcr, u32 frequency)
213{
214 int prediv, postdiv, mul;
215 int base_clock = ar7_bus_clock;
216
217 switch ((*bootcr & (BOOT_PLL_SOURCE_MASK << shift)) >> shift) {
218 case BOOT_PLL_SOURCE_BUS:
219 base_clock = ar7_bus_clock;
220 break;
221 case BOOT_PLL_SOURCE_REF:
222 base_clock = AR7_REF_CLOCK;
223 break;
224 case BOOT_PLL_SOURCE_XTAL:
225 base_clock = AR7_XTAL_CLOCK;
226 break;
227 case BOOT_PLL_SOURCE_CPU:
228 base_clock = ar7_cpu_clock;
229 break;
230 }
231
232 calculate(base_clock, frequency, &prediv, &postdiv, &mul);
233
234 writel(((prediv - 1) << PREDIV_SHIFT) | (postdiv - 1), &clock->ctrl);
235 msleep(1);
236 writel(4, &clock->pll);
237 while (readl(&clock->pll) & PLL_STATUS)
238 ;
239 writel(((mul - 1) << MUL_SHIFT) | (0xff << 3) | 0x0e, &clock->pll);
240 msleep(75);
241}
242
243static void __init tnetd7300_init_clocks(void)
244{
245 u32 *bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4);
246 struct tnetd7300_clocks *clocks =
247 ioremap_nocache(UR8_REGS_CLOCKS,
248 sizeof(struct tnetd7300_clocks));
249
250 ar7_bus_clock = tnetd7300_get_clock(BUS_PLL_SOURCE_SHIFT,
251 &clocks->bus, bootcr, AR7_AFE_CLOCK);
252
253 if (*bootcr & BOOT_PLL_ASYNC_MODE)
254 ar7_cpu_clock = tnetd7300_get_clock(CPU_PLL_SOURCE_SHIFT,
255 &clocks->cpu, bootcr, AR7_AFE_CLOCK);
256 else
257 ar7_cpu_clock = ar7_bus_clock;
258
259 if (ar7_dsp_clock == 250000000)
260 tnetd7300_set_clock(DSP_PLL_SOURCE_SHIFT, &clocks->dsp,
261 bootcr, ar7_dsp_clock);
262
263 iounmap(clocks);
264 iounmap(bootcr);
265}
266
267static int tnetd7200_get_clock(int base, struct tnetd7200_clock *clock,
268 u32 *bootcr, u32 bus_clock)
269{
270 int divisor = ((readl(&clock->prediv) & 0x1f) + 1) *
271 ((readl(&clock->postdiv) & 0x1f) + 1);
272
273 if (*bootcr & BOOT_PLL_BYPASS)
274 return base / divisor;
275
276 return base * ((readl(&clock->mul) & 0xf) + 1) / divisor;
277}
278
279
280static void tnetd7200_set_clock(int base, struct tnetd7200_clock *clock,
281 int prediv, int postdiv, int postdiv2, int mul, u32 frequency)
282{
283 printk(KERN_INFO
284 "Clocks: base = %d, frequency = %u, prediv = %d, "
285 "postdiv = %d, postdiv2 = %d, mul = %d\n",
286 base, frequency, prediv, postdiv, postdiv2, mul);
287
288 writel(0, &clock->ctrl);
289 writel(DIVISOR_ENABLE_MASK | ((prediv - 1) & 0x1F), &clock->prediv);
290 writel((mul - 1) & 0xF, &clock->mul);
291
292 while (readl(&clock->status) & 0x1)
293 ; /* nop */
294
295 writel(DIVISOR_ENABLE_MASK | ((postdiv - 1) & 0x1F), &clock->postdiv);
296
297 writel(readl(&clock->cmden) | 1, &clock->cmden);
298 writel(readl(&clock->cmd) | 1, &clock->cmd);
299
300 while (readl(&clock->status) & 0x1)
301 ; /* nop */
302
303 writel(DIVISOR_ENABLE_MASK | ((postdiv2 - 1) & 0x1F), &clock->postdiv2);
304
305 writel(readl(&clock->cmden) | 1, &clock->cmden);
306 writel(readl(&clock->cmd) | 1, &clock->cmd);
307
308 while (readl(&clock->status) & 0x1)
309 ; /* nop */
310
311 writel(readl(&clock->ctrl) | 1, &clock->ctrl);
312}
313
314static int tnetd7200_get_clock_base(int clock_id, u32 *bootcr)
315{
316 if (*bootcr & BOOT_PLL_ASYNC_MODE)
317 /* Async */
318 switch (clock_id) {
319 case TNETD7200_CLOCK_ID_DSP:
320 return AR7_REF_CLOCK;
321 default:
322 return AR7_AFE_CLOCK;
323 }
324 else
325 /* Sync */
326 if (*bootcr & BOOT_PLL_2TO1_MODE)
327 /* 2:1 */
328 switch (clock_id) {
329 case TNETD7200_CLOCK_ID_DSP:
330 return AR7_REF_CLOCK;
331 default:
332 return AR7_AFE_CLOCK;
333 }
334 else
335 /* 1:1 */
336 return AR7_REF_CLOCK;
337}
338
339
340static void __init tnetd7200_init_clocks(void)
341{
342 u32 *bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4);
343 struct tnetd7200_clocks *clocks =
344 ioremap_nocache(AR7_REGS_CLOCKS,
345 sizeof(struct tnetd7200_clocks));
346 int cpu_base, cpu_mul, cpu_prediv, cpu_postdiv;
347 int dsp_base, dsp_mul, dsp_prediv, dsp_postdiv;
348 int usb_base, usb_mul, usb_prediv, usb_postdiv;
349
350 cpu_base = tnetd7200_get_clock_base(TNETD7200_CLOCK_ID_CPU, bootcr);
351 dsp_base = tnetd7200_get_clock_base(TNETD7200_CLOCK_ID_DSP, bootcr);
352
353 if (*bootcr & BOOT_PLL_ASYNC_MODE) {
354 printk(KERN_INFO "Clocks: Async mode\n");
355
356 printk(KERN_INFO "Clocks: Setting DSP clock\n");
357 calculate(dsp_base, TNETD7200_DEF_DSP_CLK,
358 &dsp_prediv, &dsp_postdiv, &dsp_mul);
359 ar7_bus_clock =
360 ((dsp_base / dsp_prediv) * dsp_mul) / dsp_postdiv;
361 tnetd7200_set_clock(dsp_base, &clocks->dsp,
362 dsp_prediv, dsp_postdiv * 2, dsp_postdiv, dsp_mul * 2,
363 ar7_bus_clock);
364
365 printk(KERN_INFO "Clocks: Setting CPU clock\n");
366 calculate(cpu_base, TNETD7200_DEF_CPU_CLK, &cpu_prediv,
367 &cpu_postdiv, &cpu_mul);
368 ar7_cpu_clock =
369 ((cpu_base / cpu_prediv) * cpu_mul) / cpu_postdiv;
370 tnetd7200_set_clock(cpu_base, &clocks->cpu,
371 cpu_prediv, cpu_postdiv, -1, cpu_mul,
372 ar7_cpu_clock);
373
374 } else
375 if (*bootcr & BOOT_PLL_2TO1_MODE) {
376 printk(KERN_INFO "Clocks: Sync 2:1 mode\n");
377
378 printk(KERN_INFO "Clocks: Setting CPU clock\n");
379 calculate(cpu_base, TNETD7200_DEF_CPU_CLK, &cpu_prediv,
380 &cpu_postdiv, &cpu_mul);
381 ar7_cpu_clock = ((cpu_base / cpu_prediv) * cpu_mul)
382 / cpu_postdiv;
383 tnetd7200_set_clock(cpu_base, &clocks->cpu,
384 cpu_prediv, cpu_postdiv, -1, cpu_mul,
385 ar7_cpu_clock);
386
387 printk(KERN_INFO "Clocks: Setting DSP clock\n");
388 calculate(dsp_base, TNETD7200_DEF_DSP_CLK, &dsp_prediv,
389 &dsp_postdiv, &dsp_mul);
390 ar7_bus_clock = ar7_cpu_clock / 2;
391 tnetd7200_set_clock(dsp_base, &clocks->dsp,
392 dsp_prediv, dsp_postdiv * 2, dsp_postdiv,
393 dsp_mul * 2, ar7_bus_clock);
394 } else {
395 printk(KERN_INFO "Clocks: Sync 1:1 mode\n");
396
397 printk(KERN_INFO "Clocks: Setting DSP clock\n");
398 calculate(dsp_base, TNETD7200_DEF_DSP_CLK, &dsp_prediv,
399 &dsp_postdiv, &dsp_mul);
400 ar7_bus_clock = ((dsp_base / dsp_prediv) * dsp_mul)
401 / dsp_postdiv;
402 tnetd7200_set_clock(dsp_base, &clocks->dsp,
403 dsp_prediv, dsp_postdiv * 2, dsp_postdiv,
404 dsp_mul * 2, ar7_bus_clock);
405
406 ar7_cpu_clock = ar7_bus_clock;
407 }
408
409 printk(KERN_INFO "Clocks: Setting USB clock\n");
410 usb_base = ar7_bus_clock;
411 calculate(usb_base, TNETD7200_DEF_USB_CLK, &usb_prediv,
412 &usb_postdiv, &usb_mul);
413 tnetd7200_set_clock(usb_base, &clocks->usb,
414 usb_prediv, usb_postdiv, -1, usb_mul,
415 TNETD7200_DEF_USB_CLK);
416
417 ar7_dsp_clock = ar7_cpu_clock;
418
419 iounmap(clocks);
420 iounmap(bootcr);
421}
422
423int __init ar7_init_clocks(void)
424{
425 switch (ar7_chip_id()) {
426 case AR7_CHIP_7100:
427 case AR7_CHIP_7200:
428 tnetd7200_init_clocks();
429 break;
430 case AR7_CHIP_7300:
431 ar7_dsp_clock = tnetd7300_dsp_clock();
432 tnetd7300_init_clocks();
433 break;
434 default:
435 break;
436 }
437
438 return 0;
439}
440arch_initcall(ar7_init_clocks);
diff --git a/arch/mips/ar7/gpio.c b/arch/mips/ar7/gpio.c
new file mode 100644
index 000000000000..74e14a3dbf4a
--- /dev/null
+++ b/arch/mips/ar7/gpio.c
@@ -0,0 +1,48 @@
1/*
2 * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2007 Eugene Konev <ejka@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <linux/module.h>
21
22#include <asm/mach-ar7/gpio.h>
23
24static const char *ar7_gpio_list[AR7_GPIO_MAX];
25
26int gpio_request(unsigned gpio, const char *label)
27{
28 if (gpio >= AR7_GPIO_MAX)
29 return -EINVAL;
30
31 if (ar7_gpio_list[gpio])
32 return -EBUSY;
33
34 if (label)
35 ar7_gpio_list[gpio] = label;
36 else
37 ar7_gpio_list[gpio] = "busy";
38
39 return 0;
40}
41EXPORT_SYMBOL(gpio_request);
42
43void gpio_free(unsigned gpio)
44{
45 BUG_ON(!ar7_gpio_list[gpio]);
46 ar7_gpio_list[gpio] = NULL;
47}
48EXPORT_SYMBOL(gpio_free);
diff --git a/arch/mips/ar7/irq.c b/arch/mips/ar7/irq.c
new file mode 100644
index 000000000000..c781556c44e4
--- /dev/null
+++ b/arch/mips/ar7/irq.c
@@ -0,0 +1,176 @@
1/*
2 * Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2006,2007 Eugene Konev <ejka@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <linux/interrupt.h>
21#include <linux/io.h>
22
23#include <asm/irq_cpu.h>
24#include <asm/mipsregs.h>
25#include <asm/mach-ar7/ar7.h>
26
27#define EXCEPT_OFFSET 0x80
28#define PACE_OFFSET 0xA0
29#define CHNLS_OFFSET 0x200
30
31#define REG_OFFSET(irq, reg) ((irq) / 32 * 0x4 + reg * 0x10)
32#define SEC_REG_OFFSET(reg) (EXCEPT_OFFSET + reg * 0x8)
33#define SEC_SR_OFFSET (SEC_REG_OFFSET(0)) /* 0x80 */
34#define CR_OFFSET(irq) (REG_OFFSET(irq, 1)) /* 0x10 */
35#define SEC_CR_OFFSET (SEC_REG_OFFSET(1)) /* 0x88 */
36#define ESR_OFFSET(irq) (REG_OFFSET(irq, 2)) /* 0x20 */
37#define SEC_ESR_OFFSET (SEC_REG_OFFSET(2)) /* 0x90 */
38#define ECR_OFFSET(irq) (REG_OFFSET(irq, 3)) /* 0x30 */
39#define SEC_ECR_OFFSET (SEC_REG_OFFSET(3)) /* 0x98 */
40#define PIR_OFFSET (0x40)
41#define MSR_OFFSET (0x44)
42#define PM_OFFSET(irq) (REG_OFFSET(irq, 5)) /* 0x50 */
43#define TM_OFFSET(irq) (REG_OFFSET(irq, 6)) /* 0x60 */
44
45#define REG(addr) ((u32 *)(KSEG1ADDR(AR7_REGS_IRQ) + addr))
46
47#define CHNL_OFFSET(chnl) (CHNLS_OFFSET + (chnl * 4))
48
49static int ar7_irq_base;
50
51static void ar7_unmask_irq(unsigned int irq)
52{
53 writel(1 << ((irq - ar7_irq_base) % 32),
54 REG(ESR_OFFSET(irq - ar7_irq_base)));
55}
56
57static void ar7_mask_irq(unsigned int irq)
58{
59 writel(1 << ((irq - ar7_irq_base) % 32),
60 REG(ECR_OFFSET(irq - ar7_irq_base)));
61}
62
63static void ar7_ack_irq(unsigned int irq)
64{
65 writel(1 << ((irq - ar7_irq_base) % 32),
66 REG(CR_OFFSET(irq - ar7_irq_base)));
67}
68
69static void ar7_unmask_sec_irq(unsigned int irq)
70{
71 writel(1 << (irq - ar7_irq_base - 40), REG(SEC_ESR_OFFSET));
72}
73
74static void ar7_mask_sec_irq(unsigned int irq)
75{
76 writel(1 << (irq - ar7_irq_base - 40), REG(SEC_ECR_OFFSET));
77}
78
79static void ar7_ack_sec_irq(unsigned int irq)
80{
81 writel(1 << (irq - ar7_irq_base - 40), REG(SEC_CR_OFFSET));
82}
83
84static struct irq_chip ar7_irq_type = {
85 .name = "AR7",
86 .unmask = ar7_unmask_irq,
87 .mask = ar7_mask_irq,
88 .ack = ar7_ack_irq
89};
90
91static struct irq_chip ar7_sec_irq_type = {
92 .name = "AR7",
93 .unmask = ar7_unmask_sec_irq,
94 .mask = ar7_mask_sec_irq,
95 .ack = ar7_ack_sec_irq,
96};
97
98static struct irqaction ar7_cascade_action = {
99 .handler = no_action,
100 .name = "AR7 cascade interrupt"
101};
102
103static void __init ar7_irq_init(int base)
104{
105 int i;
106 /*
107 * Disable interrupts and clear pending
108 */
109 writel(0xffffffff, REG(ECR_OFFSET(0)));
110 writel(0xff, REG(ECR_OFFSET(32)));
111 writel(0xffffffff, REG(SEC_ECR_OFFSET));
112 writel(0xffffffff, REG(CR_OFFSET(0)));
113 writel(0xff, REG(CR_OFFSET(32)));
114 writel(0xffffffff, REG(SEC_CR_OFFSET));
115
116 ar7_irq_base = base;
117
118 for (i = 0; i < 40; i++) {
119 writel(i, REG(CHNL_OFFSET(i)));
120 /* Primary IRQ's */
121 set_irq_chip_and_handler(base + i, &ar7_irq_type,
122 handle_level_irq);
123 /* Secondary IRQ's */
124 if (i < 32)
125 set_irq_chip_and_handler(base + i + 40,
126 &ar7_sec_irq_type,
127 handle_level_irq);
128 }
129
130 setup_irq(2, &ar7_cascade_action);
131 setup_irq(ar7_irq_base, &ar7_cascade_action);
132 set_c0_status(IE_IRQ0);
133}
134
135void __init arch_init_irq(void)
136{
137 mips_cpu_irq_init();
138 ar7_irq_init(8);
139}
140
141static void ar7_cascade(void)
142{
143 u32 status;
144 int i, irq;
145
146 /* Primary IRQ's */
147 irq = readl(REG(PIR_OFFSET)) & 0x3f;
148 if (irq) {
149 do_IRQ(ar7_irq_base + irq);
150 return;
151 }
152
153 /* Secondary IRQ's are cascaded through primary '0' */
154 writel(1, REG(CR_OFFSET(irq)));
155 status = readl(REG(SEC_SR_OFFSET));
156 for (i = 0; i < 32; i++) {
157 if (status & 1) {
158 do_IRQ(ar7_irq_base + i + 40);
159 return;
160 }
161 status >>= 1;
162 }
163
164 spurious_interrupt();
165}
166
167asmlinkage void plat_irq_dispatch(void)
168{
169 unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
170 if (pending & STATUSF_IP7) /* cpu timer */
171 do_IRQ(7);
172 else if (pending & STATUSF_IP2) /* int0 hardware line */
173 ar7_cascade();
174 else
175 spurious_interrupt();
176}
diff --git a/arch/mips/ar7/memory.c b/arch/mips/ar7/memory.c
new file mode 100644
index 000000000000..46fed44825a6
--- /dev/null
+++ b/arch/mips/ar7/memory.c
@@ -0,0 +1,72 @@
1/*
2 * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2007 Eugene Konev <ejka@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#include <linux/bootmem.h>
20#include <linux/init.h>
21#include <linux/mm.h>
22#include <linux/module.h>
23#include <linux/pfn.h>
24#include <linux/proc_fs.h>
25#include <linux/string.h>
26#include <linux/swap.h>
27
28#include <asm/bootinfo.h>
29#include <asm/page.h>
30#include <asm/sections.h>
31
32#include <asm/mach-ar7/ar7.h>
33#include <asm/mips-boards/prom.h>
34
35static int __init memsize(void)
36{
37 u32 size = (64 << 20);
38 u32 *addr = (u32 *)KSEG1ADDR(AR7_SDRAM_BASE + size - 4);
39 u32 *kernel_end = (u32 *)KSEG1ADDR(CPHYSADDR((u32)&_end));
40 u32 *tmpaddr = addr;
41
42 while (tmpaddr > kernel_end) {
43 *tmpaddr = (u32)tmpaddr;
44 size >>= 1;
45 tmpaddr -= size >> 2;
46 }
47
48 do {
49 tmpaddr += size >> 2;
50 if (*tmpaddr != (u32)tmpaddr)
51 break;
52 size <<= 1;
53 } while (size < (64 << 20));
54
55 writel(tmpaddr, &addr);
56
57 return size;
58}
59
60void __init prom_meminit(void)
61{
62 unsigned long pages;
63
64 pages = memsize() >> PAGE_SHIFT;
65 add_memory_region(PHYS_OFFSET, pages << PAGE_SHIFT,
66 BOOT_MEM_RAM);
67}
68
69void __init prom_free_prom_memory(void)
70{
71 /* Nothing to free */
72}
diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
new file mode 100644
index 000000000000..542244961780
--- /dev/null
+++ b/arch/mips/ar7/platform.c
@@ -0,0 +1,555 @@
1/*
2 * Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2006,2007 Eugene Konev <ejka@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <linux/init.h>
21#include <linux/types.h>
22#include <linux/module.h>
23#include <linux/delay.h>
24#include <linux/dma-mapping.h>
25#include <linux/platform_device.h>
26#include <linux/mtd/physmap.h>
27#include <linux/serial.h>
28#include <linux/serial_8250.h>
29#include <linux/ioport.h>
30#include <linux/io.h>
31#include <linux/version.h>
32#include <linux/vlynq.h>
33#include <linux/leds.h>
34#include <linux/string.h>
35#include <linux/etherdevice.h>
36
37#include <asm/addrspace.h>
38#include <asm/mach-ar7/ar7.h>
39#include <asm/mach-ar7/gpio.h>
40#include <asm/mach-ar7/prom.h>
41
42struct plat_vlynq_data {
43 struct plat_vlynq_ops ops;
44 int gpio_bit;
45 int reset_bit;
46};
47
48
49static int vlynq_on(struct vlynq_device *dev)
50{
51 int result;
52 struct plat_vlynq_data *pdata = dev->dev.platform_data;
53
54 result = gpio_request(pdata->gpio_bit, "vlynq");
55 if (result)
56 goto out;
57
58 ar7_device_reset(pdata->reset_bit);
59
60 result = ar7_gpio_disable(pdata->gpio_bit);
61 if (result)
62 goto out_enabled;
63
64 result = ar7_gpio_enable(pdata->gpio_bit);
65 if (result)
66 goto out_enabled;
67
68 result = gpio_direction_output(pdata->gpio_bit, 0);
69 if (result)
70 goto out_gpio_enabled;
71
72 msleep(50);
73
74 gpio_set_value(pdata->gpio_bit, 1);
75 msleep(50);
76
77 return 0;
78
79out_gpio_enabled:
80 ar7_gpio_disable(pdata->gpio_bit);
81out_enabled:
82 ar7_device_disable(pdata->reset_bit);
83 gpio_free(pdata->gpio_bit);
84out:
85 return result;
86}
87
88static void vlynq_off(struct vlynq_device *dev)
89{
90 struct plat_vlynq_data *pdata = dev->dev.platform_data;
91 ar7_gpio_disable(pdata->gpio_bit);
92 gpio_free(pdata->gpio_bit);
93 ar7_device_disable(pdata->reset_bit);
94}
95
96static struct resource physmap_flash_resource = {
97 .name = "mem",
98 .flags = IORESOURCE_MEM,
99 .start = 0x10000000,
100 .end = 0x107fffff,
101};
102
103static struct resource cpmac_low_res[] = {
104 {
105 .name = "regs",
106 .flags = IORESOURCE_MEM,
107 .start = AR7_REGS_MAC0,
108 .end = AR7_REGS_MAC0 + 0x7ff,
109 },
110 {
111 .name = "irq",
112 .flags = IORESOURCE_IRQ,
113 .start = 27,
114 .end = 27,
115 },
116};
117
118static struct resource cpmac_high_res[] = {
119 {
120 .name = "regs",
121 .flags = IORESOURCE_MEM,
122 .start = AR7_REGS_MAC1,
123 .end = AR7_REGS_MAC1 + 0x7ff,
124 },
125 {
126 .name = "irq",
127 .flags = IORESOURCE_IRQ,
128 .start = 41,
129 .end = 41,
130 },
131};
132
133static struct resource vlynq_low_res[] = {
134 {
135 .name = "regs",
136 .flags = IORESOURCE_MEM,
137 .start = AR7_REGS_VLYNQ0,
138 .end = AR7_REGS_VLYNQ0 + 0xff,
139 },
140 {
141 .name = "irq",
142 .flags = IORESOURCE_IRQ,
143 .start = 29,
144 .end = 29,
145 },
146 {
147 .name = "mem",
148 .flags = IORESOURCE_MEM,
149 .start = 0x04000000,
150 .end = 0x04ffffff,
151 },
152 {
153 .name = "devirq",
154 .flags = IORESOURCE_IRQ,
155 .start = 80,
156 .end = 111,
157 },
158};
159
160static struct resource vlynq_high_res[] = {
161 {
162 .name = "regs",
163 .flags = IORESOURCE_MEM,
164 .start = AR7_REGS_VLYNQ1,
165 .end = AR7_REGS_VLYNQ1 + 0xff,
166 },
167 {
168 .name = "irq",
169 .flags = IORESOURCE_IRQ,
170 .start = 33,
171 .end = 33,
172 },
173 {
174 .name = "mem",
175 .flags = IORESOURCE_MEM,
176 .start = 0x0c000000,
177 .end = 0x0cffffff,
178 },
179 {
180 .name = "devirq",
181 .flags = IORESOURCE_IRQ,
182 .start = 112,
183 .end = 143,
184 },
185};
186
187static struct resource usb_res[] = {
188 {
189 .name = "regs",
190 .flags = IORESOURCE_MEM,
191 .start = AR7_REGS_USB,
192 .end = AR7_REGS_USB + 0xff,
193 },
194 {
195 .name = "irq",
196 .flags = IORESOURCE_IRQ,
197 .start = 32,
198 .end = 32,
199 },
200 {
201 .name = "mem",
202 .flags = IORESOURCE_MEM,
203 .start = 0x03400000,
204 .end = 0x034001fff,
205 },
206};
207
208static struct physmap_flash_data physmap_flash_data = {
209 .width = 2,
210};
211
212static struct plat_cpmac_data cpmac_low_data = {
213 .reset_bit = 17,
214 .power_bit = 20,
215 .phy_mask = 0x80000000,
216};
217
218static struct plat_cpmac_data cpmac_high_data = {
219 .reset_bit = 21,
220 .power_bit = 22,
221 .phy_mask = 0x7fffffff,
222};
223
224static struct plat_vlynq_data vlynq_low_data = {
225 .ops.on = vlynq_on,
226 .ops.off = vlynq_off,
227 .reset_bit = 20,
228 .gpio_bit = 18,
229};
230
231static struct plat_vlynq_data vlynq_high_data = {
232 .ops.on = vlynq_on,
233 .ops.off = vlynq_off,
234 .reset_bit = 16,
235 .gpio_bit = 19,
236};
237
238static struct platform_device physmap_flash = {
239 .id = 0,
240 .name = "physmap-flash",
241 .dev.platform_data = &physmap_flash_data,
242 .resource = &physmap_flash_resource,
243 .num_resources = 1,
244};
245
246static u64 cpmac_dma_mask = DMA_32BIT_MASK;
247static struct platform_device cpmac_low = {
248 .id = 0,
249 .name = "cpmac",
250 .dev = {
251 .dma_mask = &cpmac_dma_mask,
252 .coherent_dma_mask = DMA_32BIT_MASK,
253 .platform_data = &cpmac_low_data,
254 },
255 .resource = cpmac_low_res,
256 .num_resources = ARRAY_SIZE(cpmac_low_res),
257};
258
259static struct platform_device cpmac_high = {
260 .id = 1,
261 .name = "cpmac",
262 .dev = {
263 .dma_mask = &cpmac_dma_mask,
264 .coherent_dma_mask = DMA_32BIT_MASK,
265 .platform_data = &cpmac_high_data,
266 },
267 .resource = cpmac_high_res,
268 .num_resources = ARRAY_SIZE(cpmac_high_res),
269};
270
271static struct platform_device vlynq_low = {
272 .id = 0,
273 .name = "vlynq",
274 .dev.platform_data = &vlynq_low_data,
275 .resource = vlynq_low_res,
276 .num_resources = ARRAY_SIZE(vlynq_low_res),
277};
278
279static struct platform_device vlynq_high = {
280 .id = 1,
281 .name = "vlynq",
282 .dev.platform_data = &vlynq_high_data,
283 .resource = vlynq_high_res,
284 .num_resources = ARRAY_SIZE(vlynq_high_res),
285};
286
287
288static struct gpio_led default_leds[] = {
289 {
290 .name = "status",
291 .gpio = 8,
292 .active_low = 1,
293 },
294};
295
296static struct gpio_led dsl502t_leds[] = {
297 {
298 .name = "status",
299 .gpio = 9,
300 .active_low = 1,
301 },
302 {
303 .name = "ethernet",
304 .gpio = 7,
305 .active_low = 1,
306 },
307 {
308 .name = "usb",
309 .gpio = 12,
310 .active_low = 1,
311 },
312};
313
314static struct gpio_led dg834g_leds[] = {
315 {
316 .name = "ppp",
317 .gpio = 6,
318 .active_low = 1,
319 },
320 {
321 .name = "status",
322 .gpio = 7,
323 .active_low = 1,
324 },
325 {
326 .name = "adsl",
327 .gpio = 8,
328 .active_low = 1,
329 },
330 {
331 .name = "wifi",
332 .gpio = 12,
333 .active_low = 1,
334 },
335 {
336 .name = "power",
337 .gpio = 14,
338 .active_low = 1,
339 .default_trigger = "default-on",
340 },
341};
342
343static struct gpio_led fb_sl_leds[] = {
344 {
345 .name = "1",
346 .gpio = 7,
347 },
348 {
349 .name = "2",
350 .gpio = 13,
351 .active_low = 1,
352 },
353 {
354 .name = "3",
355 .gpio = 10,
356 .active_low = 1,
357 },
358 {
359 .name = "4",
360 .gpio = 12,
361 .active_low = 1,
362 },
363 {
364 .name = "5",
365 .gpio = 9,
366 .active_low = 1,
367 },
368};
369
370static struct gpio_led fb_fon_leds[] = {
371 {
372 .name = "1",
373 .gpio = 8,
374 },
375 {
376 .name = "2",
377 .gpio = 3,
378 .active_low = 1,
379 },
380 {
381 .name = "3",
382 .gpio = 5,
383 },
384 {
385 .name = "4",
386 .gpio = 4,
387 .active_low = 1,
388 },
389 {
390 .name = "5",
391 .gpio = 11,
392 .active_low = 1,
393 },
394};
395
396static struct gpio_led_platform_data ar7_led_data;
397
398static struct platform_device ar7_gpio_leds = {
399 .name = "leds-gpio",
400 .id = -1,
401 .dev = {
402 .platform_data = &ar7_led_data,
403 }
404};
405
406static struct platform_device ar7_udc = {
407 .id = -1,
408 .name = "ar7_udc",
409 .resource = usb_res,
410 .num_resources = ARRAY_SIZE(usb_res),
411};
412
413static inline unsigned char char2hex(char h)
414{
415 switch (h) {
416 case '0': case '1': case '2': case '3': case '4':
417 case '5': case '6': case '7': case '8': case '9':
418 return h - '0';
419 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
420 return h - 'A' + 10;
421 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
422 return h - 'a' + 10;
423 default:
424 return 0;
425 }
426}
427
428static void cpmac_get_mac(int instance, unsigned char *dev_addr)
429{
430 int i;
431 char name[5], default_mac[ETH_ALEN], *mac;
432
433 mac = NULL;
434 sprintf(name, "mac%c", 'a' + instance);
435 mac = prom_getenv(name);
436 if (!mac) {
437 sprintf(name, "mac%c", 'a');
438 mac = prom_getenv(name);
439 }
440 if (!mac) {
441 random_ether_addr(default_mac);
442 mac = default_mac;
443 }
444 for (i = 0; i < 6; i++)
445 dev_addr[i] = (char2hex(mac[i * 3]) << 4) +
446 char2hex(mac[i * 3 + 1]);
447}
448
449static void __init detect_leds(void)
450{
451 char *prid, *usb_prod;
452
453 /* Default LEDs */
454 ar7_led_data.num_leds = ARRAY_SIZE(default_leds);
455 ar7_led_data.leds = default_leds;
456
457 /* FIXME: the whole thing is unreliable */
458 prid = prom_getenv("ProductID");
459 usb_prod = prom_getenv("usb_prod");
460
461 /* If we can't get the product id from PROM, use the default LEDs */
462 if (!prid)
463 return;
464
465 if (strstr(prid, "Fritz_Box_FON")) {
466 ar7_led_data.num_leds = ARRAY_SIZE(fb_fon_leds);
467 ar7_led_data.leds = fb_fon_leds;
468 } else if (strstr(prid, "Fritz_Box_")) {
469 ar7_led_data.num_leds = ARRAY_SIZE(fb_sl_leds);
470 ar7_led_data.leds = fb_sl_leds;
471 } else if ((!strcmp(prid, "AR7RD") || !strcmp(prid, "AR7DB"))
472 && usb_prod != NULL && strstr(usb_prod, "DSL-502T")) {
473 ar7_led_data.num_leds = ARRAY_SIZE(dsl502t_leds);
474 ar7_led_data.leds = dsl502t_leds;
475 } else if (strstr(prid, "DG834")) {
476 ar7_led_data.num_leds = ARRAY_SIZE(dg834g_leds);
477 ar7_led_data.leds = dg834g_leds;
478 }
479}
480
481static int __init ar7_register_devices(void)
482{
483 int res;
484 static struct uart_port uart_port[2];
485
486 memset(uart_port, 0, sizeof(struct uart_port) * 2);
487
488 uart_port[0].type = PORT_16550A;
489 uart_port[0].line = 0;
490 uart_port[0].irq = AR7_IRQ_UART0;
491 uart_port[0].uartclk = ar7_bus_freq() / 2;
492 uart_port[0].iotype = UPIO_MEM32;
493 uart_port[0].mapbase = AR7_REGS_UART0;
494 uart_port[0].membase = ioremap(uart_port[0].mapbase, 256);
495 uart_port[0].regshift = 2;
496 res = early_serial_setup(&uart_port[0]);
497 if (res)
498 return res;
499
500
501 /* Only TNETD73xx have a second serial port */
502 if (ar7_has_second_uart()) {
503 uart_port[1].type = PORT_16550A;
504 uart_port[1].line = 1;
505 uart_port[1].irq = AR7_IRQ_UART1;
506 uart_port[1].uartclk = ar7_bus_freq() / 2;
507 uart_port[1].iotype = UPIO_MEM32;
508 uart_port[1].mapbase = UR8_REGS_UART1;
509 uart_port[1].membase = ioremap(uart_port[1].mapbase, 256);
510 uart_port[1].regshift = 2;
511 res = early_serial_setup(&uart_port[1]);
512 if (res)
513 return res;
514 }
515
516 res = platform_device_register(&physmap_flash);
517 if (res)
518 return res;
519
520 ar7_device_disable(vlynq_low_data.reset_bit);
521 res = platform_device_register(&vlynq_low);
522 if (res)
523 return res;
524
525 if (ar7_has_high_vlynq()) {
526 ar7_device_disable(vlynq_high_data.reset_bit);
527 res = platform_device_register(&vlynq_high);
528 if (res)
529 return res;
530 }
531
532 if (ar7_has_high_cpmac()) {
533 cpmac_get_mac(1, cpmac_high_data.dev_addr);
534 res = platform_device_register(&cpmac_high);
535 if (res)
536 return res;
537 } else {
538 cpmac_low_data.phy_mask = 0xffffffff;
539 }
540
541 cpmac_get_mac(0, cpmac_low_data.dev_addr);
542 res = platform_device_register(&cpmac_low);
543 if (res)
544 return res;
545
546 detect_leds();
547 res = platform_device_register(&ar7_gpio_leds);
548 if (res)
549 return res;
550
551 res = platform_device_register(&ar7_udc);
552
553 return res;
554}
555arch_initcall(ar7_register_devices);
diff --git a/arch/mips/ar7/prom.c b/arch/mips/ar7/prom.c
new file mode 100644
index 000000000000..a320bceb2f9d
--- /dev/null
+++ b/arch/mips/ar7/prom.c
@@ -0,0 +1,297 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Putting things on the screen/serial line using YAMONs facilities.
19 */
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/serial_reg.h>
23#include <linux/spinlock.h>
24#include <linux/module.h>
25#include <linux/string.h>
26#include <linux/io.h>
27#include <asm/bootinfo.h>
28
29#include <asm/mach-ar7/ar7.h>
30#include <asm/mach-ar7/prom.h>
31
32#define MAX_ENTRY 80
33
34struct env_var {
35 char *name;
36 char *value;
37};
38
39static struct env_var adam2_env[MAX_ENTRY];
40
41char *prom_getenv(const char *name)
42{
43 int i;
44 for (i = 0; (i < MAX_ENTRY) && adam2_env[i].name; i++)
45 if (!strcmp(name, adam2_env[i].name))
46 return adam2_env[i].value;
47
48 return NULL;
49}
50EXPORT_SYMBOL(prom_getenv);
51
52char * __init prom_getcmdline(void)
53{
54 return &(arcs_cmdline[0]);
55}
56
57static void __init ar7_init_cmdline(int argc, char *argv[])
58{
59 char *cp;
60 int actr;
61
62 actr = 1; /* Always ignore argv[0] */
63
64 cp = &(arcs_cmdline[0]);
65 while (actr < argc) {
66 strcpy(cp, argv[actr]);
67 cp += strlen(argv[actr]);
68 *cp++ = ' ';
69 actr++;
70 }
71 if (cp != &(arcs_cmdline[0])) {
72 /* get rid of trailing space */
73 --cp;
74 *cp = '\0';
75 }
76}
77
78struct psbl_rec {
79 u32 psbl_size;
80 u32 env_base;
81 u32 env_size;
82 u32 ffs_base;
83 u32 ffs_size;
84};
85
86static __initdata char psp_env_version[] = "TIENV0.8";
87
88struct psp_env_chunk {
89 u8 num;
90 u8 ctrl;
91 u16 csum;
92 u8 len;
93 char data[11];
94} __attribute__ ((packed));
95
96struct psp_var_map_entry {
97 u8 num;
98 char *value;
99};
100
101static struct psp_var_map_entry psp_var_map[] = {
102 { 1, "cpufrequency" },
103 { 2, "memsize" },
104 { 3, "flashsize" },
105 { 4, "modetty0" },
106 { 5, "modetty1" },
107 { 8, "maca" },
108 { 9, "macb" },
109 { 28, "sysfrequency" },
110 { 38, "mipsfrequency" },
111};
112
113/*
114
115Well-known variable (num is looked up in table above for matching variable name)
116Example: cpufrequency=211968000
117+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
118| 01 |CTRL|CHECKSUM | 01 | _2 | _1 | _1 | _9 | _6 | _8 | _0 | _0 | _0 | \0 | FF
119+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
120
121Name=Value pair in a single chunk
122Example: NAME=VALUE
123+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
124| 00 |CTRL|CHECKSUM | 01 | _N | _A | _M | _E | _0 | _V | _A | _L | _U | _E | \0
125+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
126
127Name=Value pair in 2 chunks (len is the number of chunks)
128Example: bootloaderVersion=1.3.7.15
129+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
130| 00 |CTRL|CHECKSUM | 02 | _b | _o | _o | _t | _l | _o | _a | _d | _e | _r | _V
131+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
132| _e | _r | _s | _i | _o | _n | \0 | _1 | _. | _3 | _. | _7 | _. | _1 | _5 | \0
133+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---
134
135Data is padded with 0xFF
136
137*/
138
139#define PSP_ENV_SIZE 4096
140
141static char psp_env_data[PSP_ENV_SIZE] = { 0, };
142
143static char * __init lookup_psp_var_map(u8 num)
144{
145 int i;
146
147 for (i = 0; i < sizeof(psp_var_map); i++)
148 if (psp_var_map[i].num == num)
149 return psp_var_map[i].value;
150
151 return NULL;
152}
153
154static void __init add_adam2_var(char *name, char *value)
155{
156 int i;
157 for (i = 0; i < MAX_ENTRY; i++) {
158 if (!adam2_env[i].name) {
159 adam2_env[i].name = name;
160 adam2_env[i].value = value;
161 return;
162 } else if (!strcmp(adam2_env[i].name, name)) {
163 adam2_env[i].value = value;
164 return;
165 }
166 }
167}
168
169static int __init parse_psp_env(void *psp_env_base)
170{
171 int i, n;
172 char *name, *value;
173 struct psp_env_chunk *chunks = (struct psp_env_chunk *)psp_env_data;
174
175 memcpy_fromio(chunks, psp_env_base, PSP_ENV_SIZE);
176
177 i = 1;
178 n = PSP_ENV_SIZE / sizeof(struct psp_env_chunk);
179 while (i < n) {
180 if ((chunks[i].num == 0xff) || ((i + chunks[i].len) > n))
181 break;
182 value = chunks[i].data;
183 if (chunks[i].num) {
184 name = lookup_psp_var_map(chunks[i].num);
185 } else {
186 name = value;
187 value += strlen(name) + 1;
188 }
189 if (name)
190 add_adam2_var(name, value);
191 i += chunks[i].len;
192 }
193 return 0;
194}
195
196static void __init ar7_init_env(struct env_var *env)
197{
198 int i;
199 struct psbl_rec *psbl = (struct psbl_rec *)(KSEG1ADDR(0x14000300));
200 void *psp_env = (void *)KSEG1ADDR(psbl->env_base);
201
202 if (strcmp(psp_env, psp_env_version) == 0) {
203 parse_psp_env(psp_env);
204 } else {
205 for (i = 0; i < MAX_ENTRY; i++, env++)
206 if (env->name)
207 add_adam2_var(env->name, env->value);
208 }
209}
210
211static void __init console_config(void)
212{
213#ifdef CONFIG_SERIAL_8250_CONSOLE
214 char console_string[40];
215 int baud = 0;
216 char parity = '\0', bits = '\0', flow = '\0';
217 char *s, *p;
218
219 if (strstr(prom_getcmdline(), "console="))
220 return;
221
222#ifdef CONFIG_KGDB
223 if (!strstr(prom_getcmdline(), "nokgdb")) {
224 strcat(prom_getcmdline(), " console=kgdb");
225 kgdb_enabled = 1;
226 return;
227 }
228#endif
229
230 s = prom_getenv("modetty0");
231 if (s) {
232 baud = simple_strtoul(s, &p, 10);
233 s = p;
234 if (*s == ',')
235 s++;
236 if (*s)
237 parity = *s++;
238 if (*s == ',')
239 s++;
240 if (*s)
241 bits = *s++;
242 if (*s == ',')
243 s++;
244 if (*s == 'h')
245 flow = 'r';
246 }
247
248 if (baud == 0)
249 baud = 38400;
250 if (parity != 'n' && parity != 'o' && parity != 'e')
251 parity = 'n';
252 if (bits != '7' && bits != '8')
253 bits = '8';
254
255 if (flow == 'r')
256 sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
257 parity, bits, flow);
258 else
259 sprintf(console_string, " console=ttyS0,%d%c%c", baud, parity,
260 bits);
261 strcat(prom_getcmdline(), console_string);
262#endif
263}
264
265void __init prom_init(void)
266{
267 ar7_init_cmdline(fw_arg0, (char **)fw_arg1);
268 ar7_init_env((struct env_var *)fw_arg2);
269 console_config();
270}
271
272#define PORT(offset) (KSEG1ADDR(AR7_REGS_UART0 + (offset * 4)))
273static inline unsigned int serial_in(int offset)
274{
275 return readl((void *)PORT(offset));
276}
277
278static inline void serial_out(int offset, int value)
279{
280 writel(value, (void *)PORT(offset));
281}
282
283char prom_getchar(void)
284{
285 while (!(serial_in(UART_LSR) & UART_LSR_DR))
286 ;
287 return serial_in(UART_RX);
288}
289
290int prom_putchar(char c)
291{
292 while ((serial_in(UART_LSR) & UART_LSR_TEMT) == 0)
293 ;
294 serial_out(UART_TX, c);
295 return 1;
296}
297
diff --git a/arch/mips/ar7/setup.c b/arch/mips/ar7/setup.c
new file mode 100644
index 000000000000..6ebb5f16d967
--- /dev/null
+++ b/arch/mips/ar7/setup.c
@@ -0,0 +1,94 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 */
18#include <linux/version.h>
19#include <linux/init.h>
20#include <linux/ioport.h>
21#include <linux/pm.h>
22#include <linux/time.h>
23
24#include <asm/reboot.h>
25#include <asm/mach-ar7/ar7.h>
26#include <asm/mach-ar7/prom.h>
27
28static void ar7_machine_restart(char *command)
29{
30 u32 *softres_reg = ioremap(AR7_REGS_RESET +
31 AR7_RESET_SOFTWARE, 1);
32 writel(1, softres_reg);
33}
34
35static void ar7_machine_halt(void)
36{
37 while (1)
38 ;
39}
40
41static void ar7_machine_power_off(void)
42{
43 u32 *power_reg = (u32 *)ioremap(AR7_REGS_POWER, 1);
44 u32 power_state = readl(power_reg) | (3 << 30);
45 writel(power_state, power_reg);
46 ar7_machine_halt();
47}
48
49const char *get_system_type(void)
50{
51 u16 chip_id = ar7_chip_id();
52 switch (chip_id) {
53 case AR7_CHIP_7300:
54 return "TI AR7 (TNETD7300)";
55 case AR7_CHIP_7100:
56 return "TI AR7 (TNETD7100)";
57 case AR7_CHIP_7200:
58 return "TI AR7 (TNETD7200)";
59 default:
60 return "TI AR7 (Unknown)";
61 }
62}
63
64static int __init ar7_init_console(void)
65{
66 return 0;
67}
68console_initcall(ar7_init_console);
69
70/*
71 * Initializes basic routines and structures pointers, memory size (as
72 * given by the bios and saves the command line.
73 */
74
75void __init plat_mem_setup(void)
76{
77 unsigned long io_base;
78
79 _machine_restart = ar7_machine_restart;
80 _machine_halt = ar7_machine_halt;
81 pm_power_off = ar7_machine_power_off;
82 panic_timeout = 3;
83
84 io_base = (unsigned long)ioremap(AR7_REGS_BASE, 0x10000);
85 if (!io_base)
86 panic("Can't remap IO base!\n");
87 set_io_port_base(io_base);
88
89 prom_meminit();
90
91 printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n",
92 get_system_type(),
93 ar7_chip_id(), ar7_chip_rev());
94}
diff --git a/arch/mips/ar7/time.c b/arch/mips/ar7/time.c
new file mode 100644
index 000000000000..a1fba894daa2
--- /dev/null
+++ b/arch/mips/ar7/time.c
@@ -0,0 +1,30 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Setting up the clock on the MIPS boards.
19 */
20
21#include <linux/init.h>
22#include <linux/time.h>
23
24#include <asm/time.h>
25#include <asm/mach-ar7/ar7.h>
26
27void __init plat_time_init(void)
28{
29 mips_hpt_frequency = ar7_cpu_freq() / 2;
30}
diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile
index 7c0528b0e34c..d6903c3f3d51 100644
--- a/arch/mips/cavium-octeon/Makefile
+++ b/arch/mips/cavium-octeon/Makefile
@@ -14,9 +14,5 @@ obj-y += dma-octeon.o flash_setup.o
14obj-y += octeon-memcpy.o 14obj-y += octeon-memcpy.o
15 15
16obj-$(CONFIG_SMP) += smp.o 16obj-$(CONFIG_SMP) += smp.o
17obj-$(CONFIG_PCI) += pci-common.o
18obj-$(CONFIG_PCI) += pci.o
19obj-$(CONFIG_PCI) += pcie.o
20obj-$(CONFIG_PCI_MSI) += msi.o
21 17
22EXTRA_CFLAGS += -Werror 18EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
index 627c162a6159..4b92bfc662db 100644
--- a/arch/mips/cavium-octeon/dma-octeon.c
+++ b/arch/mips/cavium-octeon/dma-octeon.c
@@ -29,7 +29,7 @@
29#include <dma-coherence.h> 29#include <dma-coherence.h>
30 30
31#ifdef CONFIG_PCI 31#ifdef CONFIG_PCI
32#include "pci-common.h" 32#include <asm/octeon/pci-octeon.h>
33#endif 33#endif
34 34
35#define BAR2_PCI_ADDRESS 0x8000000000ul 35#define BAR2_PCI_ADDRESS 0x8000000000ul
diff --git a/arch/mips/cavium-octeon/pci-common.c b/arch/mips/cavium-octeon/pci-common.c
deleted file mode 100644
index cd029f88da7f..000000000000
--- a/arch/mips/cavium-octeon/pci-common.c
+++ /dev/null
@@ -1,137 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005-2007 Cavium Networks
7 */
8#include <linux/kernel.h>
9#include <linux/init.h>
10#include <linux/pci.h>
11#include <linux/interrupt.h>
12#include <linux/time.h>
13#include <linux/delay.h>
14#include "pci-common.h"
15
16typeof(pcibios_map_irq) *octeon_pcibios_map_irq;
17enum octeon_dma_bar_type octeon_dma_bar_type = OCTEON_DMA_BAR_TYPE_INVALID;
18
19/**
20 * Map a PCI device to the appropriate interrupt line
21 *
22 * @param dev The Linux PCI device structure for the device to map
23 * @param slot The slot number for this device on __BUS 0__. Linux
24 * enumerates through all the bridges and figures out the
25 * slot on Bus 0 where this device eventually hooks to.
26 * @param pin The PCI interrupt pin read from the device, then swizzled
27 * as it goes through each bridge.
28 * @return Interrupt number for the device
29 */
30int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
31{
32 if (octeon_pcibios_map_irq)
33 return octeon_pcibios_map_irq(dev, slot, pin);
34 else
35 panic("octeon_pcibios_map_irq doesn't point to a "
36 "pcibios_map_irq() function");
37}
38
39
40/**
41 * Called to perform platform specific PCI setup
42 *
43 * @param dev
44 * @return
45 */
46int pcibios_plat_dev_init(struct pci_dev *dev)
47{
48 uint16_t config;
49 uint32_t dconfig;
50 int pos;
51 /*
52 * Force the Cache line setting to 64 bytes. The standard
53 * Linux bus scan doesn't seem to set it. Octeon really has
54 * 128 byte lines, but Intel bridges get really upset if you
55 * try and set values above 64 bytes. Value is specified in
56 * 32bit words.
57 */
58 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 64 / 4);
59 /* Set latency timers for all devices */
60 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 48);
61
62 /* Enable reporting System errors and parity errors on all devices */
63 /* Enable parity checking and error reporting */
64 pci_read_config_word(dev, PCI_COMMAND, &config);
65 config |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
66 pci_write_config_word(dev, PCI_COMMAND, config);
67
68 if (dev->subordinate) {
69 /* Set latency timers on sub bridges */
70 pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 48);
71 /* More bridge error detection */
72 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &config);
73 config |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
74 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, config);
75 }
76
77 /* Enable the PCIe normal error reporting */
78 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
79 if (pos) {
80 /* Update Device Control */
81 pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &config);
82 /* Correctable Error Reporting */
83 config |= PCI_EXP_DEVCTL_CERE;
84 /* Non-Fatal Error Reporting */
85 config |= PCI_EXP_DEVCTL_NFERE;
86 /* Fatal Error Reporting */
87 config |= PCI_EXP_DEVCTL_FERE;
88 /* Unsupported Request */
89 config |= PCI_EXP_DEVCTL_URRE;
90 pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, config);
91 }
92
93 /* Find the Advanced Error Reporting capability */
94 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
95 if (pos) {
96 /* Clear Uncorrectable Error Status */
97 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
98 &dconfig);
99 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
100 dconfig);
101 /* Enable reporting of all uncorrectable errors */
102 /* Uncorrectable Error Mask - turned on bits disable errors */
103 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
104 /*
105 * Leave severity at HW default. This only controls if
106 * errors are reported as uncorrectable or
107 * correctable, not if the error is reported.
108 */
109 /* PCI_ERR_UNCOR_SEVER - Uncorrectable Error Severity */
110 /* Clear Correctable Error Status */
111 pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &dconfig);
112 pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, dconfig);
113 /* Enable reporting of all correctable errors */
114 /* Correctable Error Mask - turned on bits disable errors */
115 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, 0);
116 /* Advanced Error Capabilities */
117 pci_read_config_dword(dev, pos + PCI_ERR_CAP, &dconfig);
118 /* ECRC Generation Enable */
119 if (config & PCI_ERR_CAP_ECRC_GENC)
120 config |= PCI_ERR_CAP_ECRC_GENE;
121 /* ECRC Check Enable */
122 if (config & PCI_ERR_CAP_ECRC_CHKC)
123 config |= PCI_ERR_CAP_ECRC_CHKE;
124 pci_write_config_dword(dev, pos + PCI_ERR_CAP, dconfig);
125 /* PCI_ERR_HEADER_LOG - Header Log Register (16 bytes) */
126 /* Report all errors to the root complex */
127 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND,
128 PCI_ERR_ROOT_CMD_COR_EN |
129 PCI_ERR_ROOT_CMD_NONFATAL_EN |
130 PCI_ERR_ROOT_CMD_FATAL_EN);
131 /* Clear the Root status register */
132 pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &dconfig);
133 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig);
134 }
135
136 return 0;
137}
diff --git a/arch/mips/cobalt/buttons.c b/arch/mips/cobalt/buttons.c
index 9e143989c7b8..4eaec8b46e0c 100644
--- a/arch/mips/cobalt/buttons.c
+++ b/arch/mips/cobalt/buttons.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cobalt buttons platform device. 2 * Cobalt buttons platform device.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cobalt/lcd.c b/arch/mips/cobalt/lcd.c
index 0720e4fae311..0f1cd90f37ed 100644
--- a/arch/mips/cobalt/lcd.c
+++ b/arch/mips/cobalt/lcd.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Registration of Cobalt LCD platform device. 2 * Registration of Cobalt LCD platform device.
3 * 3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cobalt/led.c b/arch/mips/cobalt/led.c
index 1c6ebd468b07..d3ce6fa1dc74 100644
--- a/arch/mips/cobalt/led.c
+++ b/arch/mips/cobalt/led.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Registration of Cobalt LED platform device. 2 * Registration of Cobalt LED platform device.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cobalt/mtd.c b/arch/mips/cobalt/mtd.c
index 2b088ef3839a..691d620b6766 100644
--- a/arch/mips/cobalt/mtd.c
+++ b/arch/mips/cobalt/mtd.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Registration of Cobalt MTD device. 2 * Registration of Cobalt MTD device.
3 * 3 *
4 * Copyright (C) 2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2006 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cobalt/rtc.c b/arch/mips/cobalt/rtc.c
index e70794b8bcba..3ab39898b4e4 100644
--- a/arch/mips/cobalt/rtc.c
+++ b/arch/mips/cobalt/rtc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Registration of Cobalt RTC platform device. 2 * Registration of Cobalt RTC platform device.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cobalt/serial.c b/arch/mips/cobalt/serial.c
index 53b8d0d6da90..7cb51f57275e 100644
--- a/arch/mips/cobalt/serial.c
+++ b/arch/mips/cobalt/serial.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Registration of Cobalt UART platform device. 2 * Registration of Cobalt UART platform device.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cobalt/time.c b/arch/mips/cobalt/time.c
index 4a570e7145fe..0162f9edc693 100644
--- a/arch/mips/cobalt/time.c
+++ b/arch/mips/cobalt/time.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cobalt time initialization. 2 * Cobalt time initialization.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/configs/ar7_defconfig b/arch/mips/configs/ar7_defconfig
new file mode 100644
index 000000000000..dad5b6769d74
--- /dev/null
+++ b/arch/mips/configs/ar7_defconfig
@@ -0,0 +1,1182 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30
4# Wed Jun 24 14:08:59 2009
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11# CONFIG_MACH_ALCHEMY is not set
12CONFIG_AR7=y
13# CONFIG_BASLER_EXCITE is not set
14# CONFIG_BCM47XX is not set
15# CONFIG_MIPS_COBALT is not set
16# CONFIG_MACH_DECSTATION is not set
17# CONFIG_MACH_JAZZ is not set
18# CONFIG_LASAT is not set
19# CONFIG_LEMOTE_FULONG is not set
20# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SIM is not set
22# CONFIG_NEC_MARKEINS is not set
23# CONFIG_MACH_VR41XX is not set
24# CONFIG_NXP_STB220 is not set
25# CONFIG_NXP_STB225 is not set
26# CONFIG_PNX8550_JBS is not set
27# CONFIG_PNX8550_STB810 is not set
28# CONFIG_PMC_MSP is not set
29# CONFIG_PMC_YOSEMITE is not set
30# CONFIG_SGI_IP22 is not set
31# CONFIG_SGI_IP27 is not set
32# CONFIG_SGI_IP28 is not set
33# CONFIG_SGI_IP32 is not set
34# CONFIG_SIBYTE_CRHINE is not set
35# CONFIG_SIBYTE_CARMEL is not set
36# CONFIG_SIBYTE_CRHONE is not set
37# CONFIG_SIBYTE_RHONE is not set
38# CONFIG_SIBYTE_SWARM is not set
39# CONFIG_SIBYTE_LITTLESUR is not set
40# CONFIG_SIBYTE_SENTOSA is not set
41# CONFIG_SIBYTE_BIGSUR is not set
42# CONFIG_SNI_RM is not set
43# CONFIG_MACH_TX39XX is not set
44# CONFIG_MACH_TX49XX is not set
45# CONFIG_MIKROTIK_RB532 is not set
46# CONFIG_WR_PPMC is not set
47# CONFIG_CAVIUM_OCTEON_SIMULATOR is not set
48# CONFIG_CAVIUM_OCTEON_REFERENCE_BOARD is not set
49# CONFIG_ALCHEMY_GPIO_INDIRECT is not set
50CONFIG_RWSEM_GENERIC_SPINLOCK=y
51# CONFIG_ARCH_HAS_ILOG2_U32 is not set
52# CONFIG_ARCH_HAS_ILOG2_U64 is not set
53CONFIG_ARCH_SUPPORTS_OPROFILE=y
54CONFIG_GENERIC_FIND_NEXT_BIT=y
55CONFIG_GENERIC_HWEIGHT=y
56CONFIG_GENERIC_CALIBRATE_DELAY=y
57CONFIG_GENERIC_CLOCKEVENTS=y
58CONFIG_GENERIC_TIME=y
59CONFIG_GENERIC_CMOS_UPDATE=y
60CONFIG_SCHED_OMIT_FRAME_POINTER=y
61CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
62CONFIG_CEVT_R4K_LIB=y
63CONFIG_CEVT_R4K=y
64CONFIG_CSRC_R4K_LIB=y
65CONFIG_CSRC_R4K=y
66CONFIG_DMA_NONCOHERENT=y
67CONFIG_DMA_NEED_PCI_MAP_STATE=y
68CONFIG_EARLY_PRINTK=y
69CONFIG_SYS_HAS_EARLY_PRINTK=y
70# CONFIG_HOTPLUG_CPU is not set
71# CONFIG_NO_IOPORT is not set
72CONFIG_GENERIC_GPIO=y
73# CONFIG_CPU_BIG_ENDIAN is not set
74CONFIG_CPU_LITTLE_ENDIAN=y
75CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
76CONFIG_IRQ_CPU=y
77CONFIG_NO_EXCEPT_FILL=y
78CONFIG_SWAP_IO_SPACE=y
79CONFIG_BOOT_ELF32=y
80CONFIG_MIPS_L1_CACHE_SHIFT=5
81
82#
83# CPU selection
84#
85# CONFIG_CPU_LOONGSON2 is not set
86CONFIG_CPU_MIPS32_R1=y
87# CONFIG_CPU_MIPS32_R2 is not set
88# CONFIG_CPU_MIPS64_R1 is not set
89# CONFIG_CPU_MIPS64_R2 is not set
90# CONFIG_CPU_R3000 is not set
91# CONFIG_CPU_TX39XX is not set
92# CONFIG_CPU_VR41XX is not set
93# CONFIG_CPU_R4300 is not set
94# CONFIG_CPU_R4X00 is not set
95# CONFIG_CPU_TX49XX is not set
96# CONFIG_CPU_R5000 is not set
97# CONFIG_CPU_R5432 is not set
98# CONFIG_CPU_R5500 is not set
99# CONFIG_CPU_R6000 is not set
100# CONFIG_CPU_NEVADA is not set
101# CONFIG_CPU_R8000 is not set
102# CONFIG_CPU_R10000 is not set
103# CONFIG_CPU_RM7000 is not set
104# CONFIG_CPU_RM9000 is not set
105# CONFIG_CPU_SB1 is not set
106# CONFIG_CPU_CAVIUM_OCTEON is not set
107CONFIG_SYS_HAS_CPU_MIPS32_R1=y
108CONFIG_CPU_MIPS32=y
109CONFIG_CPU_MIPSR1=y
110CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
111CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
112CONFIG_HARDWARE_WATCHPOINTS=y
113
114#
115# Kernel type
116#
117CONFIG_32BIT=y
118# CONFIG_64BIT is not set
119CONFIG_PAGE_SIZE_4KB=y
120# CONFIG_PAGE_SIZE_8KB is not set
121# CONFIG_PAGE_SIZE_16KB is not set
122# CONFIG_PAGE_SIZE_32KB is not set
123# CONFIG_PAGE_SIZE_64KB is not set
124CONFIG_CPU_HAS_PREFETCH=y
125CONFIG_MIPS_MT_DISABLED=y
126# CONFIG_MIPS_MT_SMP is not set
127# CONFIG_MIPS_MT_SMTC is not set
128CONFIG_CPU_HAS_LLSC=y
129CONFIG_CPU_HAS_SYNC=y
130CONFIG_GENERIC_HARDIRQS=y
131CONFIG_GENERIC_IRQ_PROBE=y
132CONFIG_CPU_SUPPORTS_HIGHMEM=y
133CONFIG_ARCH_FLATMEM_ENABLE=y
134CONFIG_ARCH_POPULATES_NODE_MAP=y
135CONFIG_SELECT_MEMORY_MODEL=y
136CONFIG_FLATMEM_MANUAL=y
137# CONFIG_DISCONTIGMEM_MANUAL is not set
138# CONFIG_SPARSEMEM_MANUAL is not set
139CONFIG_FLATMEM=y
140CONFIG_FLAT_NODE_MEM_MAP=y
141CONFIG_PAGEFLAGS_EXTENDED=y
142CONFIG_SPLIT_PTLOCK_CPUS=4
143# CONFIG_PHYS_ADDR_T_64BIT is not set
144CONFIG_ZONE_DMA_FLAG=0
145CONFIG_VIRT_TO_BUS=y
146CONFIG_HAVE_MLOCK=y
147CONFIG_HAVE_MLOCKED_PAGE_BIT=y
148CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
149CONFIG_TICK_ONESHOT=y
150# CONFIG_NO_HZ is not set
151CONFIG_HIGH_RES_TIMERS=y
152CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
153# CONFIG_HZ_48 is not set
154CONFIG_HZ_100=y
155# CONFIG_HZ_128 is not set
156# CONFIG_HZ_250 is not set
157# CONFIG_HZ_256 is not set
158# CONFIG_HZ_1000 is not set
159# CONFIG_HZ_1024 is not set
160CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
161CONFIG_HZ=100
162CONFIG_PREEMPT_NONE=y
163# CONFIG_PREEMPT_VOLUNTARY is not set
164# CONFIG_PREEMPT is not set
165CONFIG_KEXEC=y
166# CONFIG_SECCOMP is not set
167CONFIG_LOCKDEP_SUPPORT=y
168CONFIG_STACKTRACE_SUPPORT=y
169CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
170
171#
172# General setup
173#
174CONFIG_EXPERIMENTAL=y
175CONFIG_BROKEN_ON_SMP=y
176CONFIG_INIT_ENV_ARG_LIMIT=32
177CONFIG_LOCALVERSION=""
178# CONFIG_LOCALVERSION_AUTO is not set
179CONFIG_SWAP=y
180CONFIG_SYSVIPC=y
181CONFIG_SYSVIPC_SYSCTL=y
182# CONFIG_POSIX_MQUEUE is not set
183CONFIG_BSD_PROCESS_ACCT=y
184# CONFIG_BSD_PROCESS_ACCT_V3 is not set
185# CONFIG_TASKSTATS is not set
186# CONFIG_AUDIT is not set
187
188#
189# RCU Subsystem
190#
191CONFIG_CLASSIC_RCU=y
192# CONFIG_TREE_RCU is not set
193# CONFIG_PREEMPT_RCU is not set
194# CONFIG_TREE_RCU_TRACE is not set
195# CONFIG_PREEMPT_RCU_TRACE is not set
196# CONFIG_IKCONFIG is not set
197CONFIG_LOG_BUF_SHIFT=14
198# CONFIG_GROUP_SCHED is not set
199# CONFIG_CGROUPS is not set
200CONFIG_SYSFS_DEPRECATED=y
201CONFIG_SYSFS_DEPRECATED_V2=y
202CONFIG_RELAY=y
203# CONFIG_NAMESPACES is not set
204CONFIG_BLK_DEV_INITRD=y
205CONFIG_INITRAMFS_SOURCE=""
206CONFIG_RD_GZIP=y
207# CONFIG_RD_BZIP2 is not set
208CONFIG_RD_LZMA=y
209CONFIG_CC_OPTIMIZE_FOR_SIZE=y
210CONFIG_SYSCTL=y
211CONFIG_ANON_INODES=y
212CONFIG_EMBEDDED=y
213CONFIG_SYSCTL_SYSCALL=y
214# CONFIG_KALLSYMS is not set
215CONFIG_HOTPLUG=y
216CONFIG_PRINTK=y
217CONFIG_BUG=y
218# CONFIG_ELF_CORE is not set
219# CONFIG_PCSPKR_PLATFORM is not set
220CONFIG_BASE_FULL=y
221CONFIG_FUTEX=y
222CONFIG_EPOLL=y
223CONFIG_SIGNALFD=y
224CONFIG_TIMERFD=y
225CONFIG_EVENTFD=y
226CONFIG_SHMEM=y
227CONFIG_AIO=y
228
229#
230# Performance Counters
231#
232# CONFIG_VM_EVENT_COUNTERS is not set
233CONFIG_STRIP_ASM_SYMS=y
234# CONFIG_COMPAT_BRK is not set
235CONFIG_SLAB=y
236# CONFIG_SLUB is not set
237# CONFIG_SLOB is not set
238# CONFIG_PROFILING is not set
239# CONFIG_MARKERS is not set
240CONFIG_HAVE_OPROFILE=y
241# CONFIG_SLOW_WORK is not set
242# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
243CONFIG_SLABINFO=y
244CONFIG_RT_MUTEXES=y
245CONFIG_BASE_SMALL=0
246CONFIG_MODULES=y
247# CONFIG_MODULE_FORCE_LOAD is not set
248CONFIG_MODULE_UNLOAD=y
249# CONFIG_MODULE_FORCE_UNLOAD is not set
250# CONFIG_MODVERSIONS is not set
251# CONFIG_MODULE_SRCVERSION_ALL is not set
252CONFIG_BLOCK=y
253# CONFIG_LBD is not set
254# CONFIG_BLK_DEV_BSG is not set
255# CONFIG_BLK_DEV_INTEGRITY is not set
256
257#
258# IO Schedulers
259#
260CONFIG_IOSCHED_NOOP=y
261# CONFIG_IOSCHED_AS is not set
262CONFIG_IOSCHED_DEADLINE=y
263# CONFIG_IOSCHED_CFQ is not set
264# CONFIG_DEFAULT_AS is not set
265CONFIG_DEFAULT_DEADLINE=y
266# CONFIG_DEFAULT_CFQ is not set
267# CONFIG_DEFAULT_NOOP is not set
268CONFIG_DEFAULT_IOSCHED="deadline"
269CONFIG_PROBE_INITRD_HEADER=y
270# CONFIG_FREEZER is not set
271
272#
273# Bus options (PCI, PCMCIA, EISA, ISA, TC)
274#
275# CONFIG_ARCH_SUPPORTS_MSI is not set
276CONFIG_MMU=y
277# CONFIG_PCCARD is not set
278
279#
280# Executable file formats
281#
282CONFIG_BINFMT_ELF=y
283# CONFIG_HAVE_AOUT is not set
284# CONFIG_BINFMT_MISC is not set
285CONFIG_TRAD_SIGNALS=y
286
287#
288# Power management options
289#
290CONFIG_ARCH_HIBERNATION_POSSIBLE=y
291CONFIG_ARCH_SUSPEND_POSSIBLE=y
292# CONFIG_PM is not set
293CONFIG_NET=y
294
295#
296# Networking options
297#
298CONFIG_PACKET=y
299CONFIG_PACKET_MMAP=y
300CONFIG_UNIX=y
301# CONFIG_NET_KEY is not set
302CONFIG_INET=y
303CONFIG_IP_MULTICAST=y
304CONFIG_IP_ADVANCED_ROUTER=y
305CONFIG_ASK_IP_FIB_HASH=y
306# CONFIG_IP_FIB_TRIE is not set
307CONFIG_IP_FIB_HASH=y
308CONFIG_IP_MULTIPLE_TABLES=y
309CONFIG_IP_ROUTE_MULTIPATH=y
310CONFIG_IP_ROUTE_VERBOSE=y
311# CONFIG_IP_PNP is not set
312# CONFIG_NET_IPIP is not set
313# CONFIG_NET_IPGRE is not set
314CONFIG_IP_MROUTE=y
315# CONFIG_IP_PIMSM_V1 is not set
316# CONFIG_IP_PIMSM_V2 is not set
317CONFIG_ARPD=y
318CONFIG_SYN_COOKIES=y
319# CONFIG_INET_AH is not set
320# CONFIG_INET_ESP is not set
321# CONFIG_INET_IPCOMP is not set
322# CONFIG_INET_XFRM_TUNNEL is not set
323# CONFIG_INET_TUNNEL is not set
324# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
325# CONFIG_INET_XFRM_MODE_TUNNEL is not set
326# CONFIG_INET_XFRM_MODE_BEET is not set
327# CONFIG_INET_LRO is not set
328# CONFIG_INET_DIAG is not set
329CONFIG_TCP_CONG_ADVANCED=y
330# CONFIG_TCP_CONG_BIC is not set
331# CONFIG_TCP_CONG_CUBIC is not set
332CONFIG_TCP_CONG_WESTWOOD=y
333# CONFIG_TCP_CONG_HTCP is not set
334# CONFIG_TCP_CONG_HSTCP is not set
335# CONFIG_TCP_CONG_HYBLA is not set
336# CONFIG_TCP_CONG_VEGAS is not set
337# CONFIG_TCP_CONG_SCALABLE is not set
338# CONFIG_TCP_CONG_LP is not set
339# CONFIG_TCP_CONG_VENO is not set
340# CONFIG_TCP_CONG_YEAH is not set
341# CONFIG_TCP_CONG_ILLINOIS is not set
342# CONFIG_DEFAULT_BIC is not set
343# CONFIG_DEFAULT_CUBIC is not set
344# CONFIG_DEFAULT_HTCP is not set
345# CONFIG_DEFAULT_VEGAS is not set
346CONFIG_DEFAULT_WESTWOOD=y
347# CONFIG_DEFAULT_RENO is not set
348CONFIG_DEFAULT_TCP_CONG="westwood"
349# CONFIG_TCP_MD5SIG is not set
350# CONFIG_IPV6 is not set
351# CONFIG_NETWORK_SECMARK is not set
352CONFIG_NETFILTER=y
353# CONFIG_NETFILTER_DEBUG is not set
354CONFIG_NETFILTER_ADVANCED=y
355# CONFIG_BRIDGE_NETFILTER is not set
356
357#
358# Core Netfilter Configuration
359#
360# CONFIG_NETFILTER_NETLINK_QUEUE is not set
361# CONFIG_NETFILTER_NETLINK_LOG is not set
362CONFIG_NF_CONNTRACK=m
363# CONFIG_NF_CT_ACCT is not set
364CONFIG_NF_CONNTRACK_MARK=y
365# CONFIG_NF_CONNTRACK_EVENTS is not set
366# CONFIG_NF_CT_PROTO_DCCP is not set
367# CONFIG_NF_CT_PROTO_SCTP is not set
368# CONFIG_NF_CT_PROTO_UDPLITE is not set
369# CONFIG_NF_CONNTRACK_AMANDA is not set
370CONFIG_NF_CONNTRACK_FTP=m
371# CONFIG_NF_CONNTRACK_H323 is not set
372CONFIG_NF_CONNTRACK_IRC=m
373# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set
374# CONFIG_NF_CONNTRACK_PPTP is not set
375# CONFIG_NF_CONNTRACK_SANE is not set
376# CONFIG_NF_CONNTRACK_SIP is not set
377CONFIG_NF_CONNTRACK_TFTP=m
378# CONFIG_NF_CT_NETLINK is not set
379# CONFIG_NETFILTER_TPROXY is not set
380CONFIG_NETFILTER_XTABLES=m
381# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set
382# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set
383# CONFIG_NETFILTER_XT_TARGET_DSCP is not set
384# CONFIG_NETFILTER_XT_TARGET_HL is not set
385# CONFIG_NETFILTER_XT_TARGET_LED is not set
386# CONFIG_NETFILTER_XT_TARGET_MARK is not set
387# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set
388# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set
389CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
390# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
391# CONFIG_NETFILTER_XT_TARGET_TRACE is not set
392CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
393# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
394# CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set
395# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set
396# CONFIG_NETFILTER_XT_MATCH_CONNBYTES is not set
397# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
398# CONFIG_NETFILTER_XT_MATCH_CONNMARK is not set
399# CONFIG_NETFILTER_XT_MATCH_CONNTRACK is not set
400# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
401# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
402# CONFIG_NETFILTER_XT_MATCH_ESP is not set
403# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set
404# CONFIG_NETFILTER_XT_MATCH_HELPER is not set
405# CONFIG_NETFILTER_XT_MATCH_HL is not set
406# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set
407# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set
408CONFIG_NETFILTER_XT_MATCH_LIMIT=m
409CONFIG_NETFILTER_XT_MATCH_MAC=m
410# CONFIG_NETFILTER_XT_MATCH_MARK is not set
411CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
412# CONFIG_NETFILTER_XT_MATCH_OWNER is not set
413# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
414# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
415# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set
416# CONFIG_NETFILTER_XT_MATCH_REALM is not set
417# CONFIG_NETFILTER_XT_MATCH_RECENT is not set
418# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
419CONFIG_NETFILTER_XT_MATCH_STATE=m
420# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
421# CONFIG_NETFILTER_XT_MATCH_STRING is not set
422# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
423# CONFIG_NETFILTER_XT_MATCH_TIME is not set
424# CONFIG_NETFILTER_XT_MATCH_U32 is not set
425# CONFIG_IP_VS is not set
426
427#
428# IP: Netfilter Configuration
429#
430CONFIG_NF_DEFRAG_IPV4=m
431CONFIG_NF_CONNTRACK_IPV4=m
432CONFIG_NF_CONNTRACK_PROC_COMPAT=y
433# CONFIG_IP_NF_QUEUE is not set
434CONFIG_IP_NF_IPTABLES=m
435# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
436# CONFIG_IP_NF_MATCH_AH is not set
437# CONFIG_IP_NF_MATCH_ECN is not set
438# CONFIG_IP_NF_MATCH_TTL is not set
439CONFIG_IP_NF_FILTER=m
440CONFIG_IP_NF_TARGET_REJECT=m
441CONFIG_IP_NF_TARGET_LOG=m
442# CONFIG_IP_NF_TARGET_ULOG is not set
443CONFIG_NF_NAT=m
444CONFIG_NF_NAT_NEEDED=y
445CONFIG_IP_NF_TARGET_MASQUERADE=m
446# CONFIG_IP_NF_TARGET_NETMAP is not set
447# CONFIG_IP_NF_TARGET_REDIRECT is not set
448# CONFIG_NF_NAT_SNMP_BASIC is not set
449CONFIG_NF_NAT_FTP=m
450CONFIG_NF_NAT_IRC=m
451CONFIG_NF_NAT_TFTP=m
452# CONFIG_NF_NAT_AMANDA is not set
453# CONFIG_NF_NAT_PPTP is not set
454# CONFIG_NF_NAT_H323 is not set
455# CONFIG_NF_NAT_SIP is not set
456CONFIG_IP_NF_MANGLE=m
457# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
458# CONFIG_IP_NF_TARGET_ECN is not set
459# CONFIG_IP_NF_TARGET_TTL is not set
460CONFIG_IP_NF_RAW=m
461# CONFIG_IP_NF_ARPTABLES is not set
462# CONFIG_IP_DCCP is not set
463# CONFIG_IP_SCTP is not set
464# CONFIG_TIPC is not set
465CONFIG_ATM=m
466# CONFIG_ATM_CLIP is not set
467# CONFIG_ATM_LANE is not set
468CONFIG_ATM_BR2684=m
469CONFIG_ATM_BR2684_IPFILTER=y
470CONFIG_STP=y
471CONFIG_BRIDGE=y
472# CONFIG_NET_DSA is not set
473CONFIG_VLAN_8021Q=y
474# CONFIG_VLAN_8021Q_GVRP is not set
475# CONFIG_DECNET is not set
476CONFIG_LLC=y
477# CONFIG_LLC2 is not set
478# CONFIG_IPX is not set
479# CONFIG_ATALK is not set
480# CONFIG_X25 is not set
481# CONFIG_LAPB is not set
482# CONFIG_ECONET is not set
483# CONFIG_WAN_ROUTER is not set
484# CONFIG_PHONET is not set
485# CONFIG_IEEE802154 is not set
486CONFIG_NET_SCHED=y
487
488#
489# Queueing/Scheduling
490#
491# CONFIG_NET_SCH_CBQ is not set
492# CONFIG_NET_SCH_HTB is not set
493# CONFIG_NET_SCH_HFSC is not set
494# CONFIG_NET_SCH_ATM is not set
495# CONFIG_NET_SCH_PRIO is not set
496# CONFIG_NET_SCH_MULTIQ is not set
497# CONFIG_NET_SCH_RED is not set
498# CONFIG_NET_SCH_SFQ is not set
499# CONFIG_NET_SCH_TEQL is not set
500# CONFIG_NET_SCH_TBF is not set
501# CONFIG_NET_SCH_GRED is not set
502# CONFIG_NET_SCH_DSMARK is not set
503# CONFIG_NET_SCH_NETEM is not set
504# CONFIG_NET_SCH_DRR is not set
505# CONFIG_NET_SCH_INGRESS is not set
506
507#
508# Classification
509#
510# CONFIG_NET_CLS_BASIC is not set
511# CONFIG_NET_CLS_TCINDEX is not set
512# CONFIG_NET_CLS_ROUTE4 is not set
513# CONFIG_NET_CLS_FW is not set
514# CONFIG_NET_CLS_U32 is not set
515# CONFIG_NET_CLS_RSVP is not set
516# CONFIG_NET_CLS_RSVP6 is not set
517# CONFIG_NET_CLS_FLOW is not set
518# CONFIG_NET_EMATCH is not set
519CONFIG_NET_CLS_ACT=y
520CONFIG_NET_ACT_POLICE=y
521# CONFIG_NET_ACT_GACT is not set
522# CONFIG_NET_ACT_MIRRED is not set
523# CONFIG_NET_ACT_IPT is not set
524# CONFIG_NET_ACT_NAT is not set
525# CONFIG_NET_ACT_PEDIT is not set
526# CONFIG_NET_ACT_SIMP is not set
527# CONFIG_NET_ACT_SKBEDIT is not set
528CONFIG_NET_SCH_FIFO=y
529# CONFIG_DCB is not set
530
531#
532# Network testing
533#
534# CONFIG_NET_PKTGEN is not set
535CONFIG_HAMRADIO=y
536
537#
538# Packet Radio protocols
539#
540# CONFIG_AX25 is not set
541# CONFIG_CAN is not set
542# CONFIG_IRDA is not set
543# CONFIG_BT is not set
544# CONFIG_AF_RXRPC is not set
545CONFIG_FIB_RULES=y
546CONFIG_WIRELESS=y
547CONFIG_CFG80211=m
548# CONFIG_CFG80211_REG_DEBUG is not set
549# CONFIG_CFG80211_DEBUGFS is not set
550# CONFIG_WIRELESS_OLD_REGULATORY is not set
551CONFIG_WIRELESS_EXT=y
552CONFIG_WIRELESS_EXT_SYSFS=y
553# CONFIG_LIB80211 is not set
554CONFIG_MAC80211=m
555CONFIG_MAC80211_DEFAULT_PS=y
556CONFIG_MAC80211_DEFAULT_PS_VALUE=1
557
558#
559# Rate control algorithm selection
560#
561CONFIG_MAC80211_RC_PID=y
562CONFIG_MAC80211_RC_MINSTREL=y
563CONFIG_MAC80211_RC_DEFAULT_PID=y
564# CONFIG_MAC80211_RC_DEFAULT_MINSTREL is not set
565CONFIG_MAC80211_RC_DEFAULT="pid"
566# CONFIG_MAC80211_MESH is not set
567# CONFIG_MAC80211_LEDS is not set
568# CONFIG_MAC80211_DEBUGFS is not set
569# CONFIG_MAC80211_DEBUG_MENU is not set
570# CONFIG_WIMAX is not set
571# CONFIG_RFKILL is not set
572# CONFIG_NET_9P is not set
573
574#
575# Device Drivers
576#
577
578#
579# Generic Driver Options
580#
581CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
582CONFIG_STANDALONE=y
583CONFIG_PREVENT_FIRMWARE_BUILD=y
584CONFIG_FW_LOADER=y
585# CONFIG_FIRMWARE_IN_KERNEL is not set
586CONFIG_EXTRA_FIRMWARE=""
587# CONFIG_SYS_HYPERVISOR is not set
588# CONFIG_CONNECTOR is not set
589CONFIG_MTD=y
590# CONFIG_MTD_DEBUG is not set
591# CONFIG_MTD_CONCAT is not set
592CONFIG_MTD_PARTITIONS=y
593# CONFIG_MTD_TESTS is not set
594# CONFIG_MTD_REDBOOT_PARTS is not set
595# CONFIG_MTD_CMDLINE_PARTS is not set
596# CONFIG_MTD_AR7_PARTS is not set
597
598#
599# User Modules And Translation Layers
600#
601CONFIG_MTD_CHAR=y
602CONFIG_MTD_BLKDEVS=y
603CONFIG_MTD_BLOCK=y
604# CONFIG_FTL is not set
605# CONFIG_NFTL is not set
606# CONFIG_INFTL is not set
607# CONFIG_RFD_FTL is not set
608# CONFIG_SSFDC is not set
609# CONFIG_MTD_OOPS is not set
610
611#
612# RAM/ROM/Flash chip drivers
613#
614CONFIG_MTD_CFI=y
615# CONFIG_MTD_JEDECPROBE is not set
616CONFIG_MTD_GEN_PROBE=y
617# CONFIG_MTD_CFI_ADV_OPTIONS is not set
618CONFIG_MTD_MAP_BANK_WIDTH_1=y
619CONFIG_MTD_MAP_BANK_WIDTH_2=y
620CONFIG_MTD_MAP_BANK_WIDTH_4=y
621# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
622# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
623# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
624CONFIG_MTD_CFI_I1=y
625CONFIG_MTD_CFI_I2=y
626# CONFIG_MTD_CFI_I4 is not set
627# CONFIG_MTD_CFI_I8 is not set
628CONFIG_MTD_CFI_INTELEXT=y
629CONFIG_MTD_CFI_AMDSTD=y
630CONFIG_MTD_CFI_STAA=y
631CONFIG_MTD_CFI_UTIL=y
632# CONFIG_MTD_RAM is not set
633# CONFIG_MTD_ROM is not set
634# CONFIG_MTD_ABSENT is not set
635
636#
637# Mapping drivers for chip access
638#
639CONFIG_MTD_COMPLEX_MAPPINGS=y
640CONFIG_MTD_PHYSMAP=y
641# CONFIG_MTD_PHYSMAP_COMPAT is not set
642# CONFIG_MTD_PLATRAM is not set
643
644#
645# Self-contained MTD device drivers
646#
647# CONFIG_MTD_SLRAM is not set
648# CONFIG_MTD_PHRAM is not set
649# CONFIG_MTD_MTDRAM is not set
650# CONFIG_MTD_BLOCK2MTD is not set
651
652#
653# Disk-On-Chip Device Drivers
654#
655# CONFIG_MTD_DOC2000 is not set
656# CONFIG_MTD_DOC2001 is not set
657# CONFIG_MTD_DOC2001PLUS is not set
658# CONFIG_MTD_NAND is not set
659# CONFIG_MTD_ONENAND is not set
660
661#
662# LPDDR flash memory drivers
663#
664# CONFIG_MTD_LPDDR is not set
665
666#
667# UBI - Unsorted block images
668#
669# CONFIG_MTD_UBI is not set
670# CONFIG_PARPORT is not set
671CONFIG_BLK_DEV=y
672# CONFIG_BLK_DEV_COW_COMMON is not set
673# CONFIG_BLK_DEV_LOOP is not set
674# CONFIG_BLK_DEV_NBD is not set
675# CONFIG_BLK_DEV_RAM is not set
676# CONFIG_CDROM_PKTCDVD is not set
677# CONFIG_ATA_OVER_ETH is not set
678# CONFIG_BLK_DEV_HD is not set
679CONFIG_MISC_DEVICES=y
680# CONFIG_ENCLOSURE_SERVICES is not set
681# CONFIG_C2PORT is not set
682
683#
684# EEPROM support
685#
686# CONFIG_EEPROM_93CX6 is not set
687CONFIG_HAVE_IDE=y
688# CONFIG_IDE is not set
689
690#
691# SCSI device support
692#
693# CONFIG_RAID_ATTRS is not set
694# CONFIG_SCSI is not set
695# CONFIG_SCSI_DMA is not set
696# CONFIG_SCSI_NETLINK is not set
697# CONFIG_ATA is not set
698# CONFIG_MD is not set
699CONFIG_NETDEVICES=y
700# CONFIG_IFB is not set
701# CONFIG_DUMMY is not set
702# CONFIG_BONDING is not set
703# CONFIG_MACVLAN is not set
704# CONFIG_EQUALIZER is not set
705# CONFIG_TUN is not set
706# CONFIG_VETH is not set
707CONFIG_PHYLIB=y
708
709#
710# MII PHY device drivers
711#
712# CONFIG_MARVELL_PHY is not set
713# CONFIG_DAVICOM_PHY is not set
714# CONFIG_QSEMI_PHY is not set
715# CONFIG_LXT_PHY is not set
716# CONFIG_CICADA_PHY is not set
717# CONFIG_VITESSE_PHY is not set
718# CONFIG_SMSC_PHY is not set
719# CONFIG_BROADCOM_PHY is not set
720# CONFIG_ICPLUS_PHY is not set
721# CONFIG_REALTEK_PHY is not set
722# CONFIG_NATIONAL_PHY is not set
723# CONFIG_STE10XP is not set
724# CONFIG_LSI_ET1011C_PHY is not set
725CONFIG_FIXED_PHY=y
726# CONFIG_MDIO_BITBANG is not set
727CONFIG_NET_ETHERNET=y
728CONFIG_MII=y
729# CONFIG_AX88796 is not set
730# CONFIG_SMC91X is not set
731# CONFIG_DM9000 is not set
732# CONFIG_ETHOC is not set
733# CONFIG_DNET is not set
734# CONFIG_IBM_NEW_EMAC_ZMII is not set
735# CONFIG_IBM_NEW_EMAC_RGMII is not set
736# CONFIG_IBM_NEW_EMAC_TAH is not set
737# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
738# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
739# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
740# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
741# CONFIG_B44 is not set
742# CONFIG_KS8842 is not set
743CONFIG_CPMAC=y
744# CONFIG_NETDEV_1000 is not set
745# CONFIG_NETDEV_10000 is not set
746
747#
748# Wireless LAN
749#
750# CONFIG_WLAN_PRE80211 is not set
751CONFIG_WLAN_80211=y
752# CONFIG_LIBERTAS is not set
753# CONFIG_LIBERTAS_THINFIRM is not set
754# CONFIG_MAC80211_HWSIM is not set
755# CONFIG_P54_COMMON is not set
756# CONFIG_HOSTAP is not set
757# CONFIG_B43 is not set
758# CONFIG_B43LEGACY is not set
759# CONFIG_RT2X00 is not set
760
761#
762# Enable WiMAX (Networking options) to see the WiMAX drivers
763#
764# CONFIG_WAN is not set
765CONFIG_ATM_DRIVERS=y
766# CONFIG_ATM_DUMMY is not set
767# CONFIG_ATM_TCP is not set
768CONFIG_PPP=m
769CONFIG_PPP_MULTILINK=y
770CONFIG_PPP_FILTER=y
771CONFIG_PPP_ASYNC=m
772# CONFIG_PPP_SYNC_TTY is not set
773# CONFIG_PPP_DEFLATE is not set
774# CONFIG_PPP_BSDCOMP is not set
775# CONFIG_PPP_MPPE is not set
776CONFIG_PPPOE=m
777CONFIG_PPPOATM=m
778# CONFIG_PPPOL2TP is not set
779# CONFIG_SLIP is not set
780CONFIG_SLHC=m
781# CONFIG_NETCONSOLE is not set
782# CONFIG_NETPOLL is not set
783# CONFIG_NET_POLL_CONTROLLER is not set
784# CONFIG_ISDN is not set
785# CONFIG_PHONE is not set
786
787#
788# Input device support
789#
790# CONFIG_INPUT is not set
791
792#
793# Hardware I/O ports
794#
795# CONFIG_SERIO is not set
796# CONFIG_GAMEPORT is not set
797
798#
799# Character devices
800#
801# CONFIG_VT is not set
802# CONFIG_DEVKMEM is not set
803# CONFIG_SERIAL_NONSTANDARD is not set
804
805#
806# Serial drivers
807#
808CONFIG_SERIAL_8250=y
809CONFIG_SERIAL_8250_CONSOLE=y
810CONFIG_SERIAL_8250_NR_UARTS=2
811CONFIG_SERIAL_8250_RUNTIME_UARTS=2
812# CONFIG_SERIAL_8250_EXTENDED is not set
813
814#
815# Non-8250 serial port support
816#
817CONFIG_SERIAL_CORE=y
818CONFIG_SERIAL_CORE_CONSOLE=y
819CONFIG_UNIX98_PTYS=y
820# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
821# CONFIG_LEGACY_PTYS is not set
822# CONFIG_IPMI_HANDLER is not set
823CONFIG_HW_RANDOM=y
824# CONFIG_HW_RANDOM_TIMERIOMEM is not set
825# CONFIG_R3964 is not set
826# CONFIG_RAW_DRIVER is not set
827# CONFIG_TCG_TPM is not set
828# CONFIG_I2C is not set
829# CONFIG_SPI is not set
830# CONFIG_W1 is not set
831# CONFIG_POWER_SUPPLY is not set
832# CONFIG_HWMON is not set
833# CONFIG_THERMAL is not set
834# CONFIG_THERMAL_HWMON is not set
835CONFIG_WATCHDOG=y
836# CONFIG_WATCHDOG_NOWAYOUT is not set
837
838#
839# Watchdog Device Drivers
840#
841# CONFIG_SOFT_WATCHDOG is not set
842CONFIG_AR7_WDT=y
843CONFIG_SSB_POSSIBLE=y
844
845#
846# Sonics Silicon Backplane
847#
848CONFIG_SSB=y
849# CONFIG_SSB_SILENT is not set
850# CONFIG_SSB_DEBUG is not set
851CONFIG_SSB_SERIAL=y
852CONFIG_SSB_DRIVER_MIPS=y
853CONFIG_SSB_EMBEDDED=y
854CONFIG_SSB_DRIVER_EXTIF=y
855
856#
857# Multifunction device drivers
858#
859# CONFIG_MFD_CORE is not set
860# CONFIG_MFD_SM501 is not set
861# CONFIG_HTC_PASIC3 is not set
862# CONFIG_MFD_TMIO is not set
863# CONFIG_REGULATOR is not set
864# CONFIG_MEDIA_SUPPORT is not set
865
866#
867# Graphics support
868#
869# CONFIG_VGASTATE is not set
870# CONFIG_VIDEO_OUTPUT_CONTROL is not set
871# CONFIG_FB is not set
872# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
873
874#
875# Display device support
876#
877# CONFIG_DISPLAY_SUPPORT is not set
878# CONFIG_SOUND is not set
879# CONFIG_USB_SUPPORT is not set
880# CONFIG_MMC is not set
881# CONFIG_MEMSTICK is not set
882CONFIG_NEW_LEDS=y
883CONFIG_LEDS_CLASS=y
884
885#
886# LED drivers
887#
888# CONFIG_LEDS_GPIO is not set
889
890#
891# LED Triggers
892#
893CONFIG_LEDS_TRIGGERS=y
894CONFIG_LEDS_TRIGGER_TIMER=y
895CONFIG_LEDS_TRIGGER_HEARTBEAT=y
896# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
897CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
898
899#
900# iptables trigger is under Netfilter config (LED target)
901#
902# CONFIG_ACCESSIBILITY is not set
903CONFIG_RTC_LIB=y
904# CONFIG_RTC_CLASS is not set
905# CONFIG_DMADEVICES is not set
906# CONFIG_AUXDISPLAY is not set
907# CONFIG_UIO is not set
908
909#
910# TI VLYNQ
911#
912CONFIG_VLYNQ=y
913# CONFIG_STAGING is not set
914
915#
916# File systems
917#
918# CONFIG_EXT2_FS is not set
919# CONFIG_EXT3_FS is not set
920# CONFIG_EXT4_FS is not set
921# CONFIG_REISERFS_FS is not set
922# CONFIG_JFS_FS is not set
923# CONFIG_FS_POSIX_ACL is not set
924# CONFIG_XFS_FS is not set
925# CONFIG_OCFS2_FS is not set
926# CONFIG_BTRFS_FS is not set
927CONFIG_FILE_LOCKING=y
928CONFIG_FSNOTIFY=y
929# CONFIG_DNOTIFY is not set
930# CONFIG_INOTIFY is not set
931CONFIG_INOTIFY_USER=y
932# CONFIG_QUOTA is not set
933# CONFIG_AUTOFS_FS is not set
934# CONFIG_AUTOFS4_FS is not set
935# CONFIG_FUSE_FS is not set
936
937#
938# Caches
939#
940# CONFIG_FSCACHE is not set
941
942#
943# CD-ROM/DVD Filesystems
944#
945# CONFIG_ISO9660_FS is not set
946# CONFIG_UDF_FS is not set
947
948#
949# DOS/FAT/NT Filesystems
950#
951# CONFIG_MSDOS_FS is not set
952# CONFIG_VFAT_FS is not set
953# CONFIG_NTFS_FS is not set
954
955#
956# Pseudo filesystems
957#
958CONFIG_PROC_FS=y
959CONFIG_PROC_KCORE=y
960CONFIG_PROC_SYSCTL=y
961# CONFIG_PROC_PAGE_MONITOR is not set
962CONFIG_SYSFS=y
963CONFIG_TMPFS=y
964# CONFIG_TMPFS_POSIX_ACL is not set
965# CONFIG_HUGETLB_PAGE is not set
966# CONFIG_CONFIGFS_FS is not set
967CONFIG_MISC_FILESYSTEMS=y
968# CONFIG_ADFS_FS is not set
969# CONFIG_AFFS_FS is not set
970# CONFIG_HFS_FS is not set
971# CONFIG_HFSPLUS_FS is not set
972# CONFIG_BEFS_FS is not set
973# CONFIG_BFS_FS is not set
974# CONFIG_EFS_FS is not set
975CONFIG_JFFS2_FS=y
976CONFIG_JFFS2_FS_DEBUG=0
977CONFIG_JFFS2_FS_WRITEBUFFER=y
978# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
979CONFIG_JFFS2_SUMMARY=y
980# CONFIG_JFFS2_FS_XATTR is not set
981CONFIG_JFFS2_COMPRESSION_OPTIONS=y
982CONFIG_JFFS2_ZLIB=y
983# CONFIG_JFFS2_LZO is not set
984CONFIG_JFFS2_RTIME=y
985# CONFIG_JFFS2_RUBIN is not set
986# CONFIG_JFFS2_CMODE_NONE is not set
987CONFIG_JFFS2_CMODE_PRIORITY=y
988# CONFIG_JFFS2_CMODE_SIZE is not set
989# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
990# CONFIG_CRAMFS is not set
991CONFIG_SQUASHFS=y
992# CONFIG_SQUASHFS_EMBEDDED is not set
993CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
994# CONFIG_VXFS_FS is not set
995# CONFIG_MINIX_FS is not set
996# CONFIG_OMFS_FS is not set
997# CONFIG_HPFS_FS is not set
998# CONFIG_QNX4FS_FS is not set
999# CONFIG_ROMFS_FS is not set
1000# CONFIG_SYSV_FS is not set
1001# CONFIG_UFS_FS is not set
1002# CONFIG_NILFS2_FS is not set
1003CONFIG_NETWORK_FILESYSTEMS=y
1004# CONFIG_NFS_FS is not set
1005# CONFIG_NFSD is not set
1006# CONFIG_SMB_FS is not set
1007# CONFIG_CIFS is not set
1008# CONFIG_NCP_FS is not set
1009# CONFIG_CODA_FS is not set
1010# CONFIG_AFS_FS is not set
1011
1012#
1013# Partition Types
1014#
1015CONFIG_PARTITION_ADVANCED=y
1016# CONFIG_ACORN_PARTITION is not set
1017# CONFIG_OSF_PARTITION is not set
1018# CONFIG_AMIGA_PARTITION is not set
1019# CONFIG_ATARI_PARTITION is not set
1020# CONFIG_MAC_PARTITION is not set
1021CONFIG_MSDOS_PARTITION=y
1022CONFIG_BSD_DISKLABEL=y
1023# CONFIG_MINIX_SUBPARTITION is not set
1024# CONFIG_SOLARIS_X86_PARTITION is not set
1025# CONFIG_UNIXWARE_DISKLABEL is not set
1026# CONFIG_LDM_PARTITION is not set
1027# CONFIG_SGI_PARTITION is not set
1028# CONFIG_ULTRIX_PARTITION is not set
1029# CONFIG_SUN_PARTITION is not set
1030# CONFIG_KARMA_PARTITION is not set
1031# CONFIG_EFI_PARTITION is not set
1032# CONFIG_SYSV68_PARTITION is not set
1033# CONFIG_NLS is not set
1034# CONFIG_DLM is not set
1035
1036#
1037# Kernel hacking
1038#
1039CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1040# CONFIG_PRINTK_TIME is not set
1041CONFIG_ENABLE_WARN_DEPRECATED=y
1042# CONFIG_ENABLE_MUST_CHECK is not set
1043CONFIG_FRAME_WARN=1024
1044# CONFIG_MAGIC_SYSRQ is not set
1045# CONFIG_UNUSED_SYMBOLS is not set
1046CONFIG_DEBUG_FS=y
1047# CONFIG_HEADERS_CHECK is not set
1048# CONFIG_DEBUG_KERNEL is not set
1049# CONFIG_DEBUG_MEMORY_INIT is not set
1050# CONFIG_RCU_CPU_STALL_DETECTOR is not set
1051CONFIG_SYSCTL_SYSCALL_CHECK=y
1052CONFIG_TRACING_SUPPORT=y
1053# CONFIG_FTRACE is not set
1054# CONFIG_DYNAMIC_DEBUG is not set
1055# CONFIG_SAMPLES is not set
1056CONFIG_HAVE_ARCH_KGDB=y
1057CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
1058
1059#
1060# Security options
1061#
1062# CONFIG_KEYS is not set
1063# CONFIG_SECURITY is not set
1064# CONFIG_SECURITYFS is not set
1065# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1066CONFIG_CRYPTO=y
1067
1068#
1069# Crypto core or helper
1070#
1071# CONFIG_CRYPTO_FIPS is not set
1072CONFIG_CRYPTO_ALGAPI=m
1073CONFIG_CRYPTO_ALGAPI2=m
1074CONFIG_CRYPTO_AEAD2=m
1075CONFIG_CRYPTO_BLKCIPHER=m
1076CONFIG_CRYPTO_BLKCIPHER2=m
1077CONFIG_CRYPTO_HASH2=m
1078CONFIG_CRYPTO_RNG2=m
1079CONFIG_CRYPTO_PCOMP=m
1080CONFIG_CRYPTO_MANAGER=m
1081CONFIG_CRYPTO_MANAGER2=m
1082# CONFIG_CRYPTO_GF128MUL is not set
1083# CONFIG_CRYPTO_NULL is not set
1084CONFIG_CRYPTO_WORKQUEUE=m
1085# CONFIG_CRYPTO_CRYPTD is not set
1086# CONFIG_CRYPTO_AUTHENC is not set
1087# CONFIG_CRYPTO_TEST is not set
1088
1089#
1090# Authenticated Encryption with Associated Data
1091#
1092# CONFIG_CRYPTO_CCM is not set
1093# CONFIG_CRYPTO_GCM is not set
1094# CONFIG_CRYPTO_SEQIV is not set
1095
1096#
1097# Block modes
1098#
1099# CONFIG_CRYPTO_CBC is not set
1100# CONFIG_CRYPTO_CTR is not set
1101# CONFIG_CRYPTO_CTS is not set
1102CONFIG_CRYPTO_ECB=m
1103# CONFIG_CRYPTO_LRW is not set
1104# CONFIG_CRYPTO_PCBC is not set
1105# CONFIG_CRYPTO_XTS is not set
1106
1107#
1108# Hash modes
1109#
1110# CONFIG_CRYPTO_HMAC is not set
1111# CONFIG_CRYPTO_XCBC is not set
1112
1113#
1114# Digest
1115#
1116# CONFIG_CRYPTO_CRC32C is not set
1117# CONFIG_CRYPTO_MD4 is not set
1118# CONFIG_CRYPTO_MD5 is not set
1119# CONFIG_CRYPTO_MICHAEL_MIC is not set
1120# CONFIG_CRYPTO_RMD128 is not set
1121# CONFIG_CRYPTO_RMD160 is not set
1122# CONFIG_CRYPTO_RMD256 is not set
1123# CONFIG_CRYPTO_RMD320 is not set
1124# CONFIG_CRYPTO_SHA1 is not set
1125# CONFIG_CRYPTO_SHA256 is not set
1126# CONFIG_CRYPTO_SHA512 is not set
1127# CONFIG_CRYPTO_TGR192 is not set
1128# CONFIG_CRYPTO_WP512 is not set
1129
1130#
1131# Ciphers
1132#
1133CONFIG_CRYPTO_AES=m
1134# CONFIG_CRYPTO_ANUBIS is not set
1135CONFIG_CRYPTO_ARC4=m
1136# CONFIG_CRYPTO_BLOWFISH is not set
1137# CONFIG_CRYPTO_CAMELLIA is not set
1138# CONFIG_CRYPTO_CAST5 is not set
1139# CONFIG_CRYPTO_CAST6 is not set
1140# CONFIG_CRYPTO_DES is not set
1141# CONFIG_CRYPTO_FCRYPT is not set
1142# CONFIG_CRYPTO_KHAZAD is not set
1143# CONFIG_CRYPTO_SALSA20 is not set
1144# CONFIG_CRYPTO_SEED is not set
1145# CONFIG_CRYPTO_SERPENT is not set
1146# CONFIG_CRYPTO_TEA is not set
1147# CONFIG_CRYPTO_TWOFISH is not set
1148
1149#
1150# Compression
1151#
1152# CONFIG_CRYPTO_DEFLATE is not set
1153# CONFIG_CRYPTO_ZLIB is not set
1154# CONFIG_CRYPTO_LZO is not set
1155
1156#
1157# Random Number Generation
1158#
1159# CONFIG_CRYPTO_ANSI_CPRNG is not set
1160# CONFIG_CRYPTO_HW is not set
1161# CONFIG_BINARY_PRINTF is not set
1162
1163#
1164# Library routines
1165#
1166CONFIG_BITREVERSE=y
1167CONFIG_GENERIC_FIND_LAST_BIT=y
1168CONFIG_CRC_CCITT=m
1169# CONFIG_CRC16 is not set
1170# CONFIG_CRC_T10DIF is not set
1171# CONFIG_CRC_ITU_T is not set
1172CONFIG_CRC32=y
1173# CONFIG_CRC7 is not set
1174# CONFIG_LIBCRC32C is not set
1175CONFIG_ZLIB_INFLATE=y
1176CONFIG_ZLIB_DEFLATE=y
1177CONFIG_DECOMPRESS_GZIP=y
1178CONFIG_DECOMPRESS_LZMA=y
1179CONFIG_HAS_IOMEM=y
1180CONFIG_HAS_IOPORT=y
1181CONFIG_HAS_DMA=y
1182CONFIG_NLATTR=y
diff --git a/arch/mips/gt64120/wrppmc/serial.c b/arch/mips/gt64120/wrppmc/serial.c
index 5ec1c2ffd3a5..6f9d0858f596 100644
--- a/arch/mips/gt64120/wrppmc/serial.c
+++ b/arch/mips/gt64120/wrppmc/serial.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Registration of WRPPMC UART platform device. 2 * Registration of WRPPMC UART platform device.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/include/asm/amon.h b/arch/mips/include/asm/amon.h
new file mode 100644
index 000000000000..c3dc1a68dd8d
--- /dev/null
+++ b/arch/mips/include/asm/amon.h
@@ -0,0 +1,7 @@
1/*
2 * Amon support
3 */
4
5int amon_cpu_avail(int);
6void amon_cpu_start(int, unsigned long, unsigned long,
7 unsigned long, unsigned long);
diff --git a/arch/mips/include/asm/ds1287.h b/arch/mips/include/asm/ds1287.h
index ba1702e86931..3af0b8fb3b8c 100644
--- a/arch/mips/include/asm/ds1287.h
+++ b/arch/mips/include/asm/ds1287.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * DS1287 timer functions. 2 * DS1287 timer functions.
3 * 3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index d58f128aa747..7990694cda22 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -316,9 +316,13 @@ extern void elf_dump_regs(elf_greg_t *, struct pt_regs *regs);
316extern int dump_task_regs(struct task_struct *, elf_gregset_t *); 316extern int dump_task_regs(struct task_struct *, elf_gregset_t *);
317extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *); 317extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
318 318
319#ifndef ELF_CORE_COPY_REGS
319#define ELF_CORE_COPY_REGS(elf_regs, regs) \ 320#define ELF_CORE_COPY_REGS(elf_regs, regs) \
320 elf_dump_regs((elf_greg_t *)&(elf_regs), regs); 321 elf_dump_regs((elf_greg_t *)&(elf_regs), regs);
322#endif
323#ifndef ELF_CORE_COPY_TASK_REGS
321#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) 324#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
325#endif
322#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) \ 326#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) \
323 dump_task_fpu(tsk, elf_fpregs) 327 dump_task_fpu(tsk, elf_fpregs)
324 328
diff --git a/arch/mips/include/asm/gcmpregs.h b/arch/mips/include/asm/gcmpregs.h
index d74a8a4ca861..36fd969d64d6 100644
--- a/arch/mips/include/asm/gcmpregs.h
+++ b/arch/mips/include/asm/gcmpregs.h
@@ -114,4 +114,6 @@
114#define GCMP_CCB_DINTGROUP_OFS 0x0030 /* DINT Group Participate */ 114#define GCMP_CCB_DINTGROUP_OFS 0x0030 /* DINT Group Participate */
115#define GCMP_CCB_DBGGROUP_OFS 0x0100 /* DebugBreak Group */ 115#define GCMP_CCB_DBGGROUP_OFS 0x0100 /* DebugBreak Group */
116 116
117extern int __init gcmp_probe(unsigned long, unsigned long);
118
117#endif /* _ASM_GCMPREGS_H */ 119#endif /* _ASM_GCMPREGS_H */
diff --git a/arch/mips/include/asm/gic.h b/arch/mips/include/asm/gic.h
index 954807d9d66a..10292e37c1f7 100644
--- a/arch/mips/include/asm/gic.h
+++ b/arch/mips/include/asm/gic.h
@@ -20,7 +20,11 @@
20#define GIC_TRIG_EDGE 1 20#define GIC_TRIG_EDGE 1
21#define GIC_TRIG_LEVEL 0 21#define GIC_TRIG_LEVEL 0
22 22
23#if CONFIG_SMP
24#define GIC_NUM_INTRS (24 + NR_CPUS * 2)
25#else
23#define GIC_NUM_INTRS 32 26#define GIC_NUM_INTRS 32
27#endif
24 28
25#define MSK(n) ((1 << (n)) - 1) 29#define MSK(n) ((1 << (n)) - 1)
26#define REG32(addr) (*(volatile unsigned int *) (addr)) 30#define REG32(addr) (*(volatile unsigned int *) (addr))
@@ -483,5 +487,7 @@ extern void gic_init(unsigned long gic_base_addr,
483 487
484extern unsigned int gic_get_int(void); 488extern unsigned int gic_get_int(void);
485extern void gic_send_ipi(unsigned int intr); 489extern void gic_send_ipi(unsigned int intr);
490extern unsigned int plat_ipi_call_int_xlate(unsigned int);
491extern unsigned int plat_ipi_resched_int_xlate(unsigned int);
486 492
487#endif /* _ASM_GICREGS_H */ 493#endif /* _ASM_GICREGS_H */
diff --git a/arch/mips/include/asm/irq_gt641xx.h b/arch/mips/include/asm/irq_gt641xx.h
index f9a7c3ac2e66..250a2407b599 100644
--- a/arch/mips/include/asm/irq_gt641xx.h
+++ b/arch/mips/include/asm/irq_gt641xx.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Galileo/Marvell GT641xx IRQ definitions. 2 * Galileo/Marvell GT641xx IRQ definitions.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/include/asm/mach-ar7/ar7.h b/arch/mips/include/asm/mach-ar7/ar7.h
new file mode 100644
index 000000000000..de71694614de
--- /dev/null
+++ b/arch/mips/include/asm/mach-ar7/ar7.h
@@ -0,0 +1,178 @@
1/*
2 * Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2006,2007 Eugene Konev <ejka@openwrt.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef __AR7_H__
21#define __AR7_H__
22
23#include <linux/delay.h>
24#include <linux/io.h>
25#include <linux/errno.h>
26
27#include <asm/addrspace.h>
28
29#define AR7_SDRAM_BASE 0x14000000
30
31#define AR7_REGS_BASE 0x08610000
32
33#define AR7_REGS_MAC0 (AR7_REGS_BASE + 0x0000)
34#define AR7_REGS_GPIO (AR7_REGS_BASE + 0x0900)
35/* 0x08610A00 - 0x08610BFF (512 bytes, 128 bytes / clock) */
36#define AR7_REGS_POWER (AR7_REGS_BASE + 0x0a00)
37#define AR7_REGS_CLOCKS (AR7_REGS_POWER + 0x80)
38#define UR8_REGS_CLOCKS (AR7_REGS_POWER + 0x20)
39#define AR7_REGS_UART0 (AR7_REGS_BASE + 0x0e00)
40#define AR7_REGS_USB (AR7_REGS_BASE + 0x1200)
41#define AR7_REGS_RESET (AR7_REGS_BASE + 0x1600)
42#define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800)
43#define AR7_REGS_DCL (AR7_REGS_BASE + 0x1a00)
44#define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1c00)
45#define AR7_REGS_MDIO (AR7_REGS_BASE + 0x1e00)
46#define AR7_REGS_IRQ (AR7_REGS_BASE + 0x2400)
47#define AR7_REGS_MAC1 (AR7_REGS_BASE + 0x2800)
48
49#define AR7_REGS_WDT (AR7_REGS_BASE + 0x1f00)
50#define UR8_REGS_WDT (AR7_REGS_BASE + 0x0b00)
51#define UR8_REGS_UART1 (AR7_REGS_BASE + 0x0f00)
52
53#define AR7_RESET_PEREPHERIAL 0x0
54#define AR7_RESET_SOFTWARE 0x4
55#define AR7_RESET_STATUS 0x8
56
57#define AR7_RESET_BIT_CPMAC_LO 17
58#define AR7_RESET_BIT_CPMAC_HI 21
59#define AR7_RESET_BIT_MDIO 22
60#define AR7_RESET_BIT_EPHY 26
61
62/* GPIO control registers */
63#define AR7_GPIO_INPUT 0x0
64#define AR7_GPIO_OUTPUT 0x4
65#define AR7_GPIO_DIR 0x8
66#define AR7_GPIO_ENABLE 0xc
67
68#define AR7_CHIP_7100 0x18
69#define AR7_CHIP_7200 0x2b
70#define AR7_CHIP_7300 0x05
71
72/* Interrupts */
73#define AR7_IRQ_UART0 15
74#define AR7_IRQ_UART1 16
75
76/* Clocks */
77#define AR7_AFE_CLOCK 35328000
78#define AR7_REF_CLOCK 25000000
79#define AR7_XTAL_CLOCK 24000000
80
81struct plat_cpmac_data {
82 int reset_bit;
83 int power_bit;
84 u32 phy_mask;
85 char dev_addr[6];
86};
87
88struct plat_dsl_data {
89 int reset_bit_dsl;
90 int reset_bit_sar;
91};
92
93extern int ar7_cpu_clock, ar7_bus_clock, ar7_dsp_clock;
94
95static inline u16 ar7_chip_id(void)
96{
97 return readl((void *)KSEG1ADDR(AR7_REGS_GPIO + 0x14)) & 0xffff;
98}
99
100static inline u8 ar7_chip_rev(void)
101{
102 return (readl((void *)KSEG1ADDR(AR7_REGS_GPIO + 0x14)) >> 16) & 0xff;
103}
104
105static inline int ar7_cpu_freq(void)
106{
107 return ar7_cpu_clock;
108}
109
110static inline int ar7_bus_freq(void)
111{
112 return ar7_bus_clock;
113}
114
115static inline int ar7_vbus_freq(void)
116{
117 return ar7_bus_clock / 2;
118}
119#define ar7_cpmac_freq ar7_vbus_freq
120
121static inline int ar7_dsp_freq(void)
122{
123 return ar7_dsp_clock;
124}
125
126static inline int ar7_has_high_cpmac(void)
127{
128 u16 chip_id = ar7_chip_id();
129 switch (chip_id) {
130 case AR7_CHIP_7100:
131 case AR7_CHIP_7200:
132 return 0;
133 case AR7_CHIP_7300:
134 return 1;
135 default:
136 return -ENXIO;
137 }
138}
139#define ar7_has_high_vlynq ar7_has_high_cpmac
140#define ar7_has_second_uart ar7_has_high_cpmac
141
142static inline void ar7_device_enable(u32 bit)
143{
144 void *reset_reg =
145 (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PEREPHERIAL);
146 writel(readl(reset_reg) | (1 << bit), reset_reg);
147 msleep(20);
148}
149
150static inline void ar7_device_disable(u32 bit)
151{
152 void *reset_reg =
153 (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PEREPHERIAL);
154 writel(readl(reset_reg) & ~(1 << bit), reset_reg);
155 msleep(20);
156}
157
158static inline void ar7_device_reset(u32 bit)
159{
160 ar7_device_disable(bit);
161 ar7_device_enable(bit);
162}
163
164static inline void ar7_device_on(u32 bit)
165{
166 void *power_reg = (void *)KSEG1ADDR(AR7_REGS_POWER);
167 writel(readl(power_reg) | (1 << bit), power_reg);
168 msleep(20);
169}
170
171static inline void ar7_device_off(u32 bit)
172{
173 void *power_reg = (void *)KSEG1ADDR(AR7_REGS_POWER);
174 writel(readl(power_reg) & ~(1 << bit), power_reg);
175 msleep(20);
176}
177
178#endif /* __AR7_H__ */
diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h
new file mode 100644
index 000000000000..cbe9c4f126df
--- /dev/null
+++ b/arch/mips/include/asm/mach-ar7/gpio.h
@@ -0,0 +1,110 @@
1/*
2 * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef __AR7_GPIO_H__
20#define __AR7_GPIO_H__
21
22#include <asm/mach-ar7/ar7.h>
23
24#define AR7_GPIO_MAX 32
25
26extern int gpio_request(unsigned gpio, const char *label);
27extern void gpio_free(unsigned gpio);
28
29/* Common GPIO layer */
30static inline int gpio_get_value(unsigned gpio)
31{
32 void __iomem *gpio_in =
33 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT);
34
35 return readl(gpio_in) & (1 << gpio);
36}
37
38static inline void gpio_set_value(unsigned gpio, int value)
39{
40 void __iomem *gpio_out =
41 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT);
42 unsigned tmp;
43
44 tmp = readl(gpio_out) & ~(1 << gpio);
45 if (value)
46 tmp |= 1 << gpio;
47 writel(tmp, gpio_out);
48}
49
50static inline int gpio_direction_input(unsigned gpio)
51{
52 void __iomem *gpio_dir =
53 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
54
55 if (gpio >= AR7_GPIO_MAX)
56 return -EINVAL;
57
58 writel(readl(gpio_dir) | (1 << gpio), gpio_dir);
59
60 return 0;
61}
62
63static inline int gpio_direction_output(unsigned gpio, int value)
64{
65 void __iomem *gpio_dir =
66 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR);
67
68 if (gpio >= AR7_GPIO_MAX)
69 return -EINVAL;
70
71 gpio_set_value(gpio, value);
72 writel(readl(gpio_dir) & ~(1 << gpio), gpio_dir);
73
74 return 0;
75}
76
77static inline int gpio_to_irq(unsigned gpio)
78{
79 return -EINVAL;
80}
81
82static inline int irq_to_gpio(unsigned irq)
83{
84 return -EINVAL;
85}
86
87/* Board specific GPIO functions */
88static inline int ar7_gpio_enable(unsigned gpio)
89{
90 void __iomem *gpio_en =
91 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE);
92
93 writel(readl(gpio_en) | (1 << gpio), gpio_en);
94
95 return 0;
96}
97
98static inline int ar7_gpio_disable(unsigned gpio)
99{
100 void __iomem *gpio_en =
101 (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE);
102
103 writel(readl(gpio_en) & ~(1 << gpio), gpio_en);
104
105 return 0;
106}
107
108#include <asm-generic/gpio.h>
109
110#endif
diff --git a/arch/mips/include/asm/mach-ar7/irq.h b/arch/mips/include/asm/mach-ar7/irq.h
new file mode 100644
index 000000000000..39e9757e3d93
--- /dev/null
+++ b/arch/mips/include/asm/mach-ar7/irq.h
@@ -0,0 +1,16 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Shamelessly copied from asm-mips/mach-emma2rh/
7 * Copyright (C) 2003 by Ralf Baechle
8 */
9#ifndef __ASM_AR7_IRQ_H
10#define __ASM_AR7_IRQ_H
11
12#define NR_IRQS 256
13
14#include_next <irq.h>
15
16#endif /* __ASM_AR7_IRQ_H */
diff --git a/arch/mips/include/asm/mach-ar7/prom.h b/arch/mips/include/asm/mach-ar7/prom.h
new file mode 100644
index 000000000000..088f61fe85ea
--- /dev/null
+++ b/arch/mips/include/asm/mach-ar7/prom.h
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2006, 2007 Florian Fainelli <florian@openwrt.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef __PROM_H__
20#define __PROM_H__
21
22extern char *prom_getenv(const char *name);
23extern void prom_meminit(void);
24
25#endif /* __PROM_H__ */
diff --git a/arch/mips/include/asm/mach-ar7/spaces.h b/arch/mips/include/asm/mach-ar7/spaces.h
new file mode 100644
index 000000000000..ac28f273449c
--- /dev/null
+++ b/arch/mips/include/asm/mach-ar7/spaces.h
@@ -0,0 +1,22 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 1999, 2000, 03, 04 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
9 */
10#ifndef _ASM_AR7_SPACES_H
11#define _ASM_AR7_SPACES_H
12
13/*
14 * This handles the memory map.
15 * We handle pages at KSEG0 for kernels with 32 bit address space.
16 */
17#define PAGE_OFFSET 0x94000000UL
18#define PHYS_OFFSET 0x14000000UL
19
20#include <asm/mach-generic/spaces.h>
21
22#endif /* __ASM_AR7_SPACES_H */
diff --git a/arch/mips/include/asm/mach-ar7/war.h b/arch/mips/include/asm/mach-ar7/war.h
new file mode 100644
index 000000000000..f4862b563080
--- /dev/null
+++ b/arch/mips/include/asm/mach-ar7/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MIPS_MACH_AR7_WAR_H
9#define __ASM_MIPS_MACH_AR7_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MIPS_MACH_AR7_WAR_H */
diff --git a/arch/mips/include/asm/mach-cobalt/irq.h b/arch/mips/include/asm/mach-cobalt/irq.h
index 57c8c9ac5851..9da9acf5dcba 100644
--- a/arch/mips/include/asm/mach-cobalt/irq.h
+++ b/arch/mips/include/asm/mach-cobalt/irq.h
@@ -8,7 +8,7 @@
8 * Copyright (C) 1997 Cobalt Microserver 8 * Copyright (C) 1997 Cobalt Microserver
9 * Copyright (C) 1997, 2003 Ralf Baechle 9 * Copyright (C) 1997, 2003 Ralf Baechle
10 * Copyright (C) 2001-2003 Liam Davies (ldavies@agile.tv) 10 * Copyright (C) 2001-2003 Liam Davies (ldavies@agile.tv)
11 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 11 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
12 */ 12 */
13#ifndef _ASM_COBALT_IRQ_H 13#ifndef _ASM_COBALT_IRQ_H
14#define _ASM_COBALT_IRQ_H 14#define _ASM_COBALT_IRQ_H
diff --git a/arch/mips/include/asm/mach-cobalt/mach-gt64120.h b/arch/mips/include/asm/mach-cobalt/mach-gt64120.h
index ae9c5523c7ef..f8afec3f2943 100644
--- a/arch/mips/include/asm/mach-cobalt/mach-gt64120.h
+++ b/arch/mips/include/asm/mach-cobalt/mach-gt64120.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 2 * Copyright (C) 2006 Yoichi Yuasa <yuasa@linux-mips.org>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cavium-octeon/pci-common.h b/arch/mips/include/asm/octeon/pci-octeon.h
index 74ae79991e45..6ac5d3e3398e 100644
--- a/arch/mips/cavium-octeon/pci-common.h
+++ b/arch/mips/include/asm/octeon/pci-octeon.h
@@ -3,23 +3,29 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2005-2007 Cavium Networks 6 * Copyright (C) 2005-2009 Cavium Networks
7 */ 7 */
8#ifndef __OCTEON_PCI_COMMON_H__ 8
9#define __OCTEON_PCI_COMMON_H__ 9#ifndef __PCI_OCTEON_H__
10#define __PCI_OCTEON_H__
10 11
11#include <linux/pci.h> 12#include <linux/pci.h>
12 13
13/* Some PCI cards require delays when accessing config space. */ 14/* Some PCI cards require delays when accessing config space. */
14#define PCI_CONFIG_SPACE_DELAY 10000 15#define PCI_CONFIG_SPACE_DELAY 10000
15 16
16/* pcibios_map_irq() is defined inside pci-common.c. All it does is call the 17/*
17 Octeon specific version pointed to by this variable. This function needs to 18 * pcibios_map_irq() is defined inside pci-octeon.c. All it does is
18 change for PCI or PCIe based hosts */ 19 * call the Octeon specific version pointed to by this variable. This
19extern typeof(pcibios_map_irq) *octeon_pcibios_map_irq; 20 * function needs to change for PCI or PCIe based hosts.
21 */
22extern int (*octeon_pcibios_map_irq)(const struct pci_dev *dev,
23 u8 slot, u8 pin);
20 24
21/* The following defines are only used when octeon_dma_bar_type = 25/*
22 OCTEON_DMA_BAR_TYPE_BIG */ 26 * The following defines are used when octeon_dma_bar_type =
27 * OCTEON_DMA_BAR_TYPE_BIG
28 */
23#define OCTEON_PCI_BAR1_HOLE_BITS 5 29#define OCTEON_PCI_BAR1_HOLE_BITS 5
24#define OCTEON_PCI_BAR1_HOLE_SIZE (1ul<<(OCTEON_PCI_BAR1_HOLE_BITS+3)) 30#define OCTEON_PCI_BAR1_HOLE_SIZE (1ul<<(OCTEON_PCI_BAR1_HOLE_BITS+3))
25 31
@@ -30,9 +36,9 @@ enum octeon_dma_bar_type {
30 OCTEON_DMA_BAR_TYPE_PCIE 36 OCTEON_DMA_BAR_TYPE_PCIE
31}; 37};
32 38
33/** 39/*
34 * This is a variable to tell the DMA mapping system in dma-octeon.c 40 * This tells the DMA mapping system in dma-octeon.c how to map PCI
35 * how to map PCI DMA addresses. 41 * DMA addresses.
36 */ 42 */
37extern enum octeon_dma_bar_type octeon_dma_bar_type; 43extern enum octeon_dma_bar_type octeon_dma_bar_type;
38 44
diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
index dc0eaa731281..96a14a426a7c 100644
--- a/arch/mips/include/asm/page.h
+++ b/arch/mips/include/asm/page.h
@@ -165,7 +165,14 @@ typedef struct { unsigned long pgprot; } pgprot_t;
165 165
166#ifdef CONFIG_FLATMEM 166#ifdef CONFIG_FLATMEM
167 167
168#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < max_mapnr) 168#define pfn_valid(pfn) \
169({ \
170 unsigned long __pfn = (pfn); \
171 /* avoid <linux/bootmem.h> include hell */ \
172 extern unsigned long min_low_pfn; \
173 \
174 __pfn >= min_low_pfn && __pfn < max_mapnr; \
175})
169 176
170#elif defined(CONFIG_SPARSEMEM) 177#elif defined(CONFIG_SPARSEMEM)
171 178
diff --git a/arch/mips/include/asm/reg.h b/arch/mips/include/asm/reg.h
index 634b55d7e7f6..910e71a12466 100644
--- a/arch/mips/include/asm/reg.h
+++ b/arch/mips/include/asm/reg.h
@@ -69,7 +69,7 @@
69 69
70#endif 70#endif
71 71
72#ifdef CONFIG_64BIT 72#if defined(CONFIG_64BIT) && !defined(WANT_COMPAT_REG_H)
73 73
74#define EF_R0 0 74#define EF_R0 0
75#define EF_R1 1 75#define EF_R1 1
diff --git a/arch/mips/include/asm/swab.h b/arch/mips/include/asm/swab.h
index 99993c0d6c12..97c2f81b4b43 100644
--- a/arch/mips/include/asm/swab.h
+++ b/arch/mips/include/asm/swab.h
@@ -38,7 +38,11 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
38} 38}
39#define __arch_swab32 __arch_swab32 39#define __arch_swab32 __arch_swab32
40 40
41#ifdef CONFIG_CPU_MIPS64_R2 41/*
42 * Having already checked for CONFIG_CPU_MIPSR2, enable the
43 * optimized version for 64-bit kernel on r2 CPUs.
44 */
45#ifdef CONFIG_64BIT
42static inline __attribute_const__ __u64 __arch_swab64(__u64 x) 46static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
43{ 47{
44 __asm__( 48 __asm__(
@@ -50,6 +54,6 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
50 return x; 54 return x;
51} 55}
52#define __arch_swab64 __arch_swab64 56#define __arch_swab64 __arch_swab64
53#endif /* CONFIG_CPU_MIPS64_R2 */ 57#endif /* CONFIG_64BIT */
54#endif /* CONFIG_CPU_MIPSR2 */ 58#endif /* CONFIG_CPU_MIPSR2 */
55#endif /* _ASM_SWAB_H */ 59#endif /* _ASM_SWAB_H */
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
index 143a48136a4b..f9df720d2e40 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -39,8 +39,6 @@ struct thread_info {
39 39
40/* 40/*
41 * macros/functions for gaining access to the thread information structure 41 * macros/functions for gaining access to the thread information structure
42 *
43 * preempt_count needs to be 1 initially, until the scheduler is functional.
44 */ 42 */
45#define INIT_THREAD_INFO(tsk) \ 43#define INIT_THREAD_INFO(tsk) \
46{ \ 44{ \
@@ -48,7 +46,7 @@ struct thread_info {
48 .exec_domain = &default_exec_domain, \ 46 .exec_domain = &default_exec_domain, \
49 .flags = _TIF_FIXADE, \ 47 .flags = _TIF_FIXADE, \
50 .cpu = 0, \ 48 .cpu = 0, \
51 .preempt_count = 1, \ 49 .preempt_count = INIT_PREEMPT_COUNT, \
52 .addr_limit = KERNEL_DS, \ 50 .addr_limit = KERNEL_DS, \
53 .restart_block = { \ 51 .restart_block = { \
54 .fn = do_no_restart_syscall, \ 52 .fn = do_no_restart_syscall, \
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
index 40005010827c..b70c49fdda26 100644
--- a/arch/mips/include/asm/unistd.h
+++ b/arch/mips/include/asm/unistd.h
@@ -352,16 +352,18 @@
352#define __NR_inotify_init1 (__NR_Linux + 329) 352#define __NR_inotify_init1 (__NR_Linux + 329)
353#define __NR_preadv (__NR_Linux + 330) 353#define __NR_preadv (__NR_Linux + 330)
354#define __NR_pwritev (__NR_Linux + 331) 354#define __NR_pwritev (__NR_Linux + 331)
355#define __NR_rt_tgsigqueueinfo (__NR_Linux + 332)
356#define __NR_perf_counter_open (__NR_Linux + 333)
355 357
356/* 358/*
357 * Offset of the last Linux o32 flavoured syscall 359 * Offset of the last Linux o32 flavoured syscall
358 */ 360 */
359#define __NR_Linux_syscalls 331 361#define __NR_Linux_syscalls 333
360 362
361#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 363#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
362 364
363#define __NR_O32_Linux 4000 365#define __NR_O32_Linux 4000
364#define __NR_O32_Linux_syscalls 331 366#define __NR_O32_Linux_syscalls 333
365 367
366#if _MIPS_SIM == _MIPS_SIM_ABI64 368#if _MIPS_SIM == _MIPS_SIM_ABI64
367 369
@@ -660,16 +662,18 @@
660#define __NR_inotify_init1 (__NR_Linux + 288) 662#define __NR_inotify_init1 (__NR_Linux + 288)
661#define __NR_preadv (__NR_Linux + 289) 663#define __NR_preadv (__NR_Linux + 289)
662#define __NR_pwritev (__NR_Linux + 290) 664#define __NR_pwritev (__NR_Linux + 290)
665#define __NR_rt_tgsigqueueinfo (__NR_Linux + 291)
666#define __NR_perf_counter_open (__NR_Linux + 292)
663 667
664/* 668/*
665 * Offset of the last Linux 64-bit flavoured syscall 669 * Offset of the last Linux 64-bit flavoured syscall
666 */ 670 */
667#define __NR_Linux_syscalls 290 671#define __NR_Linux_syscalls 292
668 672
669#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 673#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
670 674
671#define __NR_64_Linux 5000 675#define __NR_64_Linux 5000
672#define __NR_64_Linux_syscalls 290 676#define __NR_64_Linux_syscalls 292
673 677
674#if _MIPS_SIM == _MIPS_SIM_NABI32 678#if _MIPS_SIM == _MIPS_SIM_NABI32
675 679
@@ -972,16 +976,18 @@
972#define __NR_inotify_init1 (__NR_Linux + 292) 976#define __NR_inotify_init1 (__NR_Linux + 292)
973#define __NR_preadv (__NR_Linux + 293) 977#define __NR_preadv (__NR_Linux + 293)
974#define __NR_pwritev (__NR_Linux + 294) 978#define __NR_pwritev (__NR_Linux + 294)
979#define __NR_rt_tgsigqueueinfo (__NR_Linux + 295)
980#define __NR_perf_counter_open (__NR_Linux + 296)
975 981
976/* 982/*
977 * Offset of the last N32 flavoured syscall 983 * Offset of the last N32 flavoured syscall
978 */ 984 */
979#define __NR_Linux_syscalls 294 985#define __NR_Linux_syscalls 296
980 986
981#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 987#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
982 988
983#define __NR_N32_Linux 6000 989#define __NR_N32_Linux 6000
984#define __NR_N32_Linux_syscalls 294 990#define __NR_N32_Linux_syscalls 296
985 991
986#ifdef __KERNEL__ 992#ifdef __KERNEL__
987 993
diff --git a/arch/mips/include/asm/vr41xx/capcella.h b/arch/mips/include/asm/vr41xx/capcella.h
index e0ee05a3dfcc..fcc6569414fa 100644
--- a/arch/mips/include/asm/vr41xx/capcella.h
+++ b/arch/mips/include/asm/vr41xx/capcella.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * capcella.h, Include file for ZAO Networks Capcella. 2 * capcella.h, Include file for ZAO Networks Capcella.
3 * 3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002-2004 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/include/asm/vr41xx/giu.h b/arch/mips/include/asm/vr41xx/giu.h
index 0bcdd3a5c256..6a90bc1d916b 100644
--- a/arch/mips/include/asm/vr41xx/giu.h
+++ b/arch/mips/include/asm/vr41xx/giu.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Include file for NEC VR4100 series General-purpose I/O Unit. 2 * Include file for NEC VR4100 series General-purpose I/O Unit.
3 * 3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2005-2009 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -41,7 +41,8 @@ typedef enum {
41 IRQ_SIGNAL_HOLD, 41 IRQ_SIGNAL_HOLD,
42} irq_signal_t; 42} irq_signal_t;
43 43
44extern void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger, irq_signal_t signal); 44extern void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger,
45 irq_signal_t signal);
45 46
46typedef enum { 47typedef enum {
47 IRQ_LEVEL_LOW, 48 IRQ_LEVEL_LOW,
@@ -51,23 +52,6 @@ typedef enum {
51extern void vr41xx_set_irq_level(unsigned int pin, irq_level_t level); 52extern void vr41xx_set_irq_level(unsigned int pin, irq_level_t level);
52 53
53typedef enum { 54typedef enum {
54 GPIO_DATA_LOW,
55 GPIO_DATA_HIGH,
56 GPIO_DATA_INVAL,
57} gpio_data_t;
58
59extern gpio_data_t vr41xx_gpio_get_pin(unsigned int pin);
60extern int vr41xx_gpio_set_pin(unsigned int pin, gpio_data_t data);
61
62typedef enum {
63 GPIO_INPUT,
64 GPIO_OUTPUT,
65 GPIO_OUTPUT_DISABLE,
66} gpio_direction_t;
67
68extern int vr41xx_gpio_set_direction(unsigned int pin, gpio_direction_t dir);
69
70typedef enum {
71 GPIO_PULL_DOWN, 55 GPIO_PULL_DOWN,
72 GPIO_PULL_UP, 56 GPIO_PULL_UP,
73 GPIO_PULL_DISABLE, 57 GPIO_PULL_DISABLE,
diff --git a/arch/mips/include/asm/vr41xx/irq.h b/arch/mips/include/asm/vr41xx/irq.h
index d315dfbc08f2..b07f7321751d 100644
--- a/arch/mips/include/asm/vr41xx/irq.h
+++ b/arch/mips/include/asm/vr41xx/irq.h
@@ -7,7 +7,7 @@
7 * Copyright (C) 2001, 2002 Paul Mundt 7 * Copyright (C) 2001, 2002 Paul Mundt
8 * Copyright (C) 2002 MontaVista Software, Inc. 8 * Copyright (C) 2002 MontaVista Software, Inc.
9 * Copyright (C) 2002 TimeSys Corp. 9 * Copyright (C) 2002 TimeSys Corp.
10 * Copyright (C) 2003-2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 10 * Copyright (C) 2003-2006 Yoichi Yuasa <yuasa@linux-mips.org>
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
diff --git a/arch/mips/include/asm/vr41xx/mpc30x.h b/arch/mips/include/asm/vr41xx/mpc30x.h
index 1d67df843dc3..130d09d8c8cb 100644
--- a/arch/mips/include/asm/vr41xx/mpc30x.h
+++ b/arch/mips/include/asm/vr41xx/mpc30x.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * mpc30x.h, Include file for Victor MP-C303/304. 2 * mpc30x.h, Include file for Victor MP-C303/304.
3 * 3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002-2004 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/include/asm/vr41xx/pci.h b/arch/mips/include/asm/vr41xx/pci.h
index 6fc01ce19777..c231a3d6cfd8 100644
--- a/arch/mips/include/asm/vr41xx/pci.h
+++ b/arch/mips/include/asm/vr41xx/pci.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Include file for NEC VR4100 series PCI Control Unit. 2 * Include file for NEC VR4100 series PCI Control Unit.
3 * 3 *
4 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/include/asm/vr41xx/siu.h b/arch/mips/include/asm/vr41xx/siu.h
index da9f6e373409..ca806bc4ddc8 100644
--- a/arch/mips/include/asm/vr41xx/siu.h
+++ b/arch/mips/include/asm/vr41xx/siu.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Include file for NEC VR4100 series Serial Interface Unit. 2 * Include file for NEC VR4100 series Serial Interface Unit.
3 * 3 *
4 * Copyright (C) 2005-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2005-2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/include/asm/vr41xx/tb0219.h b/arch/mips/include/asm/vr41xx/tb0219.h
index dc981b4be0a4..c78e8243b447 100644
--- a/arch/mips/include/asm/vr41xx/tb0219.h
+++ b/arch/mips/include/asm/vr41xx/tb0219.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * tb0219.h, Include file for TANBAC TB0219. 2 * tb0219.h, Include file for TANBAC TB0219.
3 * 3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002-2004 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * Modified for TANBAC TB0219: 6 * Modified for TANBAC TB0219:
7 * Copyright (C) 2003 Megasolution Inc. <matsu@megasolution.jp> 7 * Copyright (C) 2003 Megasolution Inc. <matsu@megasolution.jp>
diff --git a/arch/mips/include/asm/vr41xx/tb0226.h b/arch/mips/include/asm/vr41xx/tb0226.h
index de527dcfa5f3..36f5f798e416 100644
--- a/arch/mips/include/asm/vr41xx/tb0226.h
+++ b/arch/mips/include/asm/vr41xx/tb0226.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * tb0226.h, Include file for TANBAC TB0226. 2 * tb0226.h, Include file for TANBAC TB0226.
3 * 3 *
4 * Copyright (C) 2002-2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002-2004 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/include/asm/vr41xx/vr41xx.h b/arch/mips/include/asm/vr41xx/vr41xx.h
index 22be64971cc6..7b96a43b72ba 100644
--- a/arch/mips/include/asm/vr41xx/vr41xx.h
+++ b/arch/mips/include/asm/vr41xx/vr41xx.h
@@ -7,7 +7,7 @@
7 * Copyright (C) 2001, 2002 Paul Mundt 7 * Copyright (C) 2001, 2002 Paul Mundt
8 * Copyright (C) 2002 MontaVista Software, Inc. 8 * Copyright (C) 2002 MontaVista Software, Inc.
9 * Copyright (C) 2002 TimeSys Corp. 9 * Copyright (C) 2002 TimeSys Corp.
10 * Copyright (C) 2003-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 10 * Copyright (C) 2003-2008 Yoichi Yuasa <yuasa@linux-mips.org>
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
index e1333d7319e2..ff448233dab5 100644
--- a/arch/mips/kernel/binfmt_elfo32.c
+++ b/arch/mips/kernel/binfmt_elfo32.c
@@ -53,6 +53,23 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
53#define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2) 53#define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
54 54
55#include <asm/processor.h> 55#include <asm/processor.h>
56
57/*
58 * When this file is selected, we are definitely running a 64bit kernel.
59 * So using the right regs define in asm/reg.h
60 */
61#define WANT_COMPAT_REG_H
62
63/* These MUST be defined before elf.h gets included */
64extern void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs);
65#define ELF_CORE_COPY_REGS(_dest, _regs) elf32_core_copy_regs(_dest, _regs);
66#define ELF_CORE_COPY_TASK_REGS(_tsk, _dest) \
67({ \
68 int __res = 1; \
69 elf32_core_copy_regs(*(_dest), task_pt_regs(_tsk)); \
70 __res; \
71})
72
56#include <linux/module.h> 73#include <linux/module.h>
57#include <linux/elfcore.h> 74#include <linux/elfcore.h>
58#include <linux/compat.h> 75#include <linux/compat.h>
@@ -110,9 +127,6 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
110 value->tv_usec = rem / NSEC_PER_USEC; 127 value->tv_usec = rem / NSEC_PER_USEC;
111} 128}
112 129
113#undef ELF_CORE_COPY_REGS
114#define ELF_CORE_COPY_REGS(_dest, _regs) elf32_core_copy_regs(_dest, _regs);
115
116void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs) 130void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs)
117{ 131{
118 int i; 132 int i;
diff --git a/arch/mips/kernel/cevt-ds1287.c b/arch/mips/kernel/cevt-ds1287.c
index 1ada45ea0700..6996da4d74a2 100644
--- a/arch/mips/kernel/cevt-ds1287.c
+++ b/arch/mips/kernel/cevt-ds1287.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * DS1287 clockevent driver 2 * DS1287 clockevent driver
3 * 3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/kernel/cevt-gt641xx.c b/arch/mips/kernel/cevt-gt641xx.c
index e9b787feedcb..92351e00ae0e 100644
--- a/arch/mips/kernel/cevt-gt641xx.c
+++ b/arch/mips/kernel/cevt-gt641xx.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * GT641xx clockevent routines. 2 * GT641xx clockevent routines.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/kernel/csrc-ioasic.c b/arch/mips/kernel/csrc-ioasic.c
index b551f48d3a07..23da108506b0 100644
--- a/arch/mips/kernel/csrc-ioasic.c
+++ b/arch/mips/kernel/csrc-ioasic.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * DEC I/O ASIC's counter clocksource 2 * DEC I/O ASIC's counter clocksource
3 * 3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/kernel/irq-gic.c b/arch/mips/kernel/irq-gic.c
index 39000f103f2c..d2072cd38592 100644
--- a/arch/mips/kernel/irq-gic.c
+++ b/arch/mips/kernel/irq-gic.c
@@ -107,9 +107,7 @@ static unsigned int gic_irq_startup(unsigned int irq)
107{ 107{
108 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 108 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);
109 irq -= _irqbase; 109 irq -= _irqbase;
110 /* FIXME: this is wrong for !GICISWORDLITTLEENDIAN */ 110 GIC_SET_INTR_MASK(irq, 1);
111 GICWRITE(GIC_REG_ADDR(SHARED, (GIC_SH_SMASK_31_0_OFS + (irq / 32))),
112 1 << (irq % 32));
113 return 0; 111 return 0;
114} 112}
115 113
@@ -120,8 +118,7 @@ static void gic_irq_ack(unsigned int irq)
120#endif 118#endif
121 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 119 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);
122 irq -= _irqbase; 120 irq -= _irqbase;
123 GICWRITE(GIC_REG_ADDR(SHARED, (GIC_SH_RMASK_31_0_OFS + (irq / 32))), 121 GIC_CLR_INTR_MASK(irq, 1);
124 1 << (irq % 32));
125 122
126 if (_intrmap[irq].trigtype == GIC_TRIG_EDGE) { 123 if (_intrmap[irq].trigtype == GIC_TRIG_EDGE) {
127 if (!gic_wedgeb2bok) 124 if (!gic_wedgeb2bok)
@@ -138,18 +135,14 @@ static void gic_mask_irq(unsigned int irq)
138{ 135{
139 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 136 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);
140 irq -= _irqbase; 137 irq -= _irqbase;
141 /* FIXME: this is wrong for !GICISWORDLITTLEENDIAN */ 138 GIC_CLR_INTR_MASK(irq, 1);
142 GICWRITE(GIC_REG_ADDR(SHARED, (GIC_SH_RMASK_31_0_OFS + (irq / 32))),
143 1 << (irq % 32));
144} 139}
145 140
146static void gic_unmask_irq(unsigned int irq) 141static void gic_unmask_irq(unsigned int irq)
147{ 142{
148 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq); 143 pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);
149 irq -= _irqbase; 144 irq -= _irqbase;
150 /* FIXME: this is wrong for !GICISWORDLITTLEENDIAN */ 145 GIC_SET_INTR_MASK(irq, 1);
151 GICWRITE(GIC_REG_ADDR(SHARED, (GIC_SH_SMASK_31_0_OFS + (irq / 32))),
152 1 << (irq % 32));
153} 146}
154 147
155#ifdef CONFIG_SMP 148#ifdef CONFIG_SMP
@@ -254,6 +247,10 @@ static void __init gic_basic_init(void)
254 if (cpu == X) 247 if (cpu == X)
255 continue; 248 continue;
256 249
250 if (cpu == 0 && i != 0 && _intrmap[i].intrnum == 0 &&
251 _intrmap[i].ipiflag == 0)
252 continue;
253
257 setup_intr(_intrmap[i].intrnum, 254 setup_intr(_intrmap[i].intrnum,
258 _intrmap[i].cpunum, 255 _intrmap[i].cpunum,
259 _intrmap[i].pin, 256 _intrmap[i].pin,
diff --git a/arch/mips/kernel/irq-gt641xx.c b/arch/mips/kernel/irq-gt641xx.c
index 1b81b131f43c..ebcc5f7ad9c2 100644
--- a/arch/mips/kernel/irq-gt641xx.c
+++ b/arch/mips/kernel/irq-gt641xx.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * GT641xx IRQ routines. 2 * GT641xx IRQ routines.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
index c4f9ac17474a..32644b4a0714 100644
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -22,7 +22,6 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/ptrace.h> 23#include <linux/ptrace.h>
24#include <linux/smp.h> 24#include <linux/smp.h>
25#include <linux/smp_lock.h>
26#include <linux/user.h> 25#include <linux/user.h>
27#include <linux/security.h> 26#include <linux/security.h>
28 27
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 0b31b9bda048..20a86e08fd58 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -652,6 +652,8 @@ einval: li v0, -ENOSYS
652 sys sys_inotify_init1 1 652 sys sys_inotify_init1 1
653 sys sys_preadv 6 /* 4330 */ 653 sys sys_preadv 6 /* 4330 */
654 sys sys_pwritev 6 654 sys sys_pwritev 6
655 sys sys_rt_tgsigqueueinfo 4
656 sys sys_perf_counter_open 5
655 .endm 657 .endm
656 658
657 /* We pre-compute the number of _instruction_ bytes needed to 659 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index c647fd6e722f..b046130d4c5d 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -489,4 +489,6 @@ sys_call_table:
489 PTR sys_inotify_init1 489 PTR sys_inotify_init1
490 PTR sys_preadv 490 PTR sys_preadv
491 PTR sys_pwritev /* 5390 */ 491 PTR sys_pwritev /* 5390 */
492 PTR sys_rt_tgsigqueueinfo
493 PTR sys_perf_counter_open
492 .size sys_call_table,.-sys_call_table 494 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 93cc672f4522..15874f9812cc 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -415,4 +415,6 @@ EXPORT(sysn32_call_table)
415 PTR sys_inotify_init1 415 PTR sys_inotify_init1
416 PTR sys_preadv 416 PTR sys_preadv
417 PTR sys_pwritev 417 PTR sys_pwritev
418 PTR compat_sys_rt_tgsigqueueinfo /* 5295 */
419 PTR sys_perf_counter_open
418 .size sysn32_call_table,.-sysn32_call_table 420 .size sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index a5598b2339dd..781e0f1e9533 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -535,4 +535,6 @@ sys_call_table:
535 PTR sys_inotify_init1 535 PTR sys_inotify_init1
536 PTR compat_sys_preadv /* 4330 */ 536 PTR compat_sys_preadv /* 4330 */
537 PTR compat_sys_pwritev 537 PTR compat_sys_pwritev
538 PTR compat_sys_rt_tgsigqueueinfo
539 PTR sys_perf_counter_open
538 .size sys_call_table,.-sys_call_table 540 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/smp-cmp.c b/arch/mips/kernel/smp-cmp.c
index 653be061b9ec..ad0ff5dc4d59 100644
--- a/arch/mips/kernel/smp-cmp.c
+++ b/arch/mips/kernel/smp-cmp.c
@@ -37,80 +37,24 @@
37#include <asm/mipsregs.h> 37#include <asm/mipsregs.h>
38#include <asm/mipsmtregs.h> 38#include <asm/mipsmtregs.h>
39#include <asm/mips_mt.h> 39#include <asm/mips_mt.h>
40 40#include <asm/amon.h>
41/* 41#include <asm/gic.h>
42 * Crude manipulation of the CPU masks to control which
43 * which CPU's are brought online during initialisation
44 *
45 * Beware... this needs to be called after CPU discovery
46 * but before CPU bringup
47 */
48static int __init allowcpus(char *str)
49{
50 cpumask_t cpu_allow_map;
51 char buf[256];
52 int len;
53
54 cpus_clear(cpu_allow_map);
55 if (cpulist_parse(str, &cpu_allow_map) == 0) {
56 cpu_set(0, cpu_allow_map);
57 cpus_and(cpu_possible_map, cpu_possible_map, cpu_allow_map);
58 len = cpulist_scnprintf(buf, sizeof(buf)-1, &cpu_possible_map);
59 buf[len] = '\0';
60 pr_debug("Allowable CPUs: %s\n", buf);
61 return 1;
62 } else
63 return 0;
64}
65__setup("allowcpus=", allowcpus);
66 42
67static void ipi_call_function(unsigned int cpu) 43static void ipi_call_function(unsigned int cpu)
68{ 44{
69 unsigned int action = 0;
70
71 pr_debug("CPU%d: %s cpu %d status %08x\n", 45 pr_debug("CPU%d: %s cpu %d status %08x\n",
72 smp_processor_id(), __func__, cpu, read_c0_status()); 46 smp_processor_id(), __func__, cpu, read_c0_status());
73 47
74 switch (cpu) { 48 gic_send_ipi(plat_ipi_call_int_xlate(cpu));
75 case 0:
76 action = GIC_IPI_EXT_INTR_CALLFNC_VPE0;
77 break;
78 case 1:
79 action = GIC_IPI_EXT_INTR_CALLFNC_VPE1;
80 break;
81 case 2:
82 action = GIC_IPI_EXT_INTR_CALLFNC_VPE2;
83 break;
84 case 3:
85 action = GIC_IPI_EXT_INTR_CALLFNC_VPE3;
86 break;
87 }
88 gic_send_ipi(action);
89} 49}
90 50
91 51
92static void ipi_resched(unsigned int cpu) 52static void ipi_resched(unsigned int cpu)
93{ 53{
94 unsigned int action = 0;
95
96 pr_debug("CPU%d: %s cpu %d status %08x\n", 54 pr_debug("CPU%d: %s cpu %d status %08x\n",
97 smp_processor_id(), __func__, cpu, read_c0_status()); 55 smp_processor_id(), __func__, cpu, read_c0_status());
98 56
99 switch (cpu) { 57 gic_send_ipi(plat_ipi_resched_int_xlate(cpu));
100 case 0:
101 action = GIC_IPI_EXT_INTR_RESCHED_VPE0;
102 break;
103 case 1:
104 action = GIC_IPI_EXT_INTR_RESCHED_VPE1;
105 break;
106 case 2:
107 action = GIC_IPI_EXT_INTR_RESCHED_VPE2;
108 break;
109 case 3:
110 action = GIC_IPI_EXT_INTR_RESCHED_VPE3;
111 break;
112 }
113 gic_send_ipi(action);
114} 58}
115 59
116/* 60/*
@@ -206,7 +150,7 @@ static void cmp_boot_secondary(int cpu, struct task_struct *idle)
206 (unsigned long)(gp + sizeof(struct thread_info))); 150 (unsigned long)(gp + sizeof(struct thread_info)));
207#endif 151#endif
208 152
209 amon_cpu_start(cpu, pc, sp, gp, a0); 153 amon_cpu_start(cpu, pc, sp, (unsigned long)gp, a0);
210} 154}
211 155
212/* 156/*
diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
index 9021108eb9c1..05dd170a83f7 100644
--- a/arch/mips/kernel/sync-r4k.c
+++ b/arch/mips/kernel/sync-r4k.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Count register synchronisation. 2 * Count register synchronisation.
3 * 3 *
4 * All CPUs will have their count registers synchronised to the CPU0 expirelo 4 * All CPUs will have their count registers synchronised to the CPU0 next time
5 * value. This can cause a small timewarp for CPU0. All other CPU's should 5 * value. This can cause a small timewarp for CPU0. All other CPU's should
6 * not have done anything significant (but they may have had interrupts 6 * not have done anything significant (but they may have had interrupts
7 * enabled briefly - prom_smp_finish() should not be responsible for enabling 7 * enabled briefly - prom_smp_finish() should not be responsible for enabling
@@ -13,21 +13,22 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/irqflags.h> 15#include <linux/irqflags.h>
16#include <linux/r4k-timer.h> 16#include <linux/cpumask.h>
17 17
18#include <asm/r4k-timer.h>
18#include <asm/atomic.h> 19#include <asm/atomic.h>
19#include <asm/barrier.h> 20#include <asm/barrier.h>
20#include <asm/cpumask.h>
21#include <asm/mipsregs.h> 21#include <asm/mipsregs.h>
22 22
23static atomic_t __initdata count_start_flag = ATOMIC_INIT(0); 23static atomic_t __cpuinitdata count_start_flag = ATOMIC_INIT(0);
24static atomic_t __initdata count_count_start = ATOMIC_INIT(0); 24static atomic_t __cpuinitdata count_count_start = ATOMIC_INIT(0);
25static atomic_t __initdata count_count_stop = ATOMIC_INIT(0); 25static atomic_t __cpuinitdata count_count_stop = ATOMIC_INIT(0);
26static atomic_t __cpuinitdata count_reference = ATOMIC_INIT(0);
26 27
27#define COUNTON 100 28#define COUNTON 100
28#define NR_LOOPS 5 29#define NR_LOOPS 5
29 30
30void __init synchronise_count_master(void) 31void __cpuinit synchronise_count_master(void)
31{ 32{
32 int i; 33 int i;
33 unsigned long flags; 34 unsigned long flags;
@@ -42,19 +43,20 @@ void __init synchronise_count_master(void)
42 return; 43 return;
43#endif 44#endif
44 45
45 pr_info("Checking COUNT synchronization across %u CPUs: ", 46 printk(KERN_INFO "Synchronize counters across %u CPUs: ",
46 num_online_cpus()); 47 num_online_cpus());
47 48
48 local_irq_save(flags); 49 local_irq_save(flags);
49 50
50 /* 51 /*
51 * Notify the slaves that it's time to start 52 * Notify the slaves that it's time to start
52 */ 53 */
54 atomic_set(&count_reference, read_c0_count());
53 atomic_set(&count_start_flag, 1); 55 atomic_set(&count_start_flag, 1);
54 smp_wmb(); 56 smp_wmb();
55 57
56 /* Count will be initialised to expirelo for all CPU's */ 58 /* Count will be initialised to current timer for all CPU's */
57 initcount = expirelo; 59 initcount = read_c0_count();
58 60
59 /* 61 /*
60 * We loop a few times to get a primed instruction cache, 62 * We loop a few times to get a primed instruction cache,
@@ -106,7 +108,7 @@ void __init synchronise_count_master(void)
106 printk("done.\n"); 108 printk("done.\n");
107} 109}
108 110
109void __init synchronise_count_slave(void) 111void __cpuinit synchronise_count_slave(void)
110{ 112{
111 int i; 113 int i;
112 unsigned long flags; 114 unsigned long flags;
@@ -131,8 +133,8 @@ void __init synchronise_count_slave(void)
131 while (!atomic_read(&count_start_flag)) 133 while (!atomic_read(&count_start_flag))
132 mb(); 134 mb();
133 135
134 /* Count will be initialised to expirelo for all CPU's */ 136 /* Count will be initialised to next expire for all CPU's */
135 initcount = expirelo; 137 initcount = atomic_read(&count_reference);
136 138
137 ncpus = num_online_cpus(); 139 ncpus = num_online_cpus();
138 for (i = 0; i < NR_LOOPS; i++) { 140 for (i = 0; i < NR_LOOPS; i++) {
@@ -156,4 +158,3 @@ void __init synchronise_count_slave(void)
156 local_irq_restore(flags); 158 local_irq_restore(flags);
157} 159}
158#undef NR_LOOPS 160#undef NR_LOOPS
159#endif
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 3ca5f42e819d..07b9ec2c6e3d 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -1387,7 +1387,7 @@ static ssize_t store_ntcs(struct device *dev, struct device_attribute *attr,
1387 return len; 1387 return len;
1388 1388
1389out_einval: 1389out_einval:
1390 return -EINVAL;; 1390 return -EINVAL;
1391} 1391}
1392 1392
1393static struct device_attribute vpe_class_attributes[] = { 1393static struct device_attribute vpe_class_attributes[] = {
diff --git a/arch/mips/mm/hugetlbpage.c b/arch/mips/mm/hugetlbpage.c
index 471c09aa1614..8c2834f5919d 100644
--- a/arch/mips/mm/hugetlbpage.c
+++ b/arch/mips/mm/hugetlbpage.c
@@ -16,7 +16,6 @@
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/hugetlb.h> 17#include <linux/hugetlb.h>
18#include <linux/pagemap.h> 18#include <linux/pagemap.h>
19#include <linux/smp_lock.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21#include <linux/err.h> 20#include <linux/err.h>
22#include <linux/sysctl.h> 21#include <linux/sysctl.h>
diff --git a/arch/mips/mti-malta/malta-init.c b/arch/mips/mti-malta/malta-init.c
index 475038a141a6..27c807b67fea 100644
--- a/arch/mips/mti-malta/malta-init.c
+++ b/arch/mips/mti-malta/malta-init.c
@@ -30,6 +30,7 @@
30#include <asm/cacheflush.h> 30#include <asm/cacheflush.h>
31#include <asm/traps.h> 31#include <asm/traps.h>
32 32
33#include <asm/gcmpregs.h>
33#include <asm/mips-boards/prom.h> 34#include <asm/mips-boards/prom.h>
34#include <asm/mips-boards/generic.h> 35#include <asm/mips-boards/generic.h>
35#include <asm/mips-boards/bonito64.h> 36#include <asm/mips-boards/bonito64.h>
@@ -192,6 +193,8 @@ extern struct plat_smp_ops msmtc_smp_ops;
192 193
193void __init prom_init(void) 194void __init prom_init(void)
194{ 195{
196 int result;
197
195 prom_argc = fw_arg0; 198 prom_argc = fw_arg0;
196 _prom_argv = (int *) fw_arg1; 199 _prom_argv = (int *) fw_arg1;
197 _prom_envp = (int *) fw_arg2; 200 _prom_envp = (int *) fw_arg2;
@@ -358,12 +361,21 @@ void __init prom_init(void)
358#ifdef CONFIG_SERIAL_8250_CONSOLE 361#ifdef CONFIG_SERIAL_8250_CONSOLE
359 console_config(); 362 console_config();
360#endif 363#endif
364 /* Early detection of CMP support */
365 result = gcmp_probe(GCMP_BASE_ADDR, GCMP_ADDRSPACE_SZ);
366
361#ifdef CONFIG_MIPS_CMP 367#ifdef CONFIG_MIPS_CMP
362 register_smp_ops(&cmp_smp_ops); 368 if (result)
369 register_smp_ops(&cmp_smp_ops);
363#endif 370#endif
364#ifdef CONFIG_MIPS_MT_SMP 371#ifdef CONFIG_MIPS_MT_SMP
372#ifdef CONFIG_MIPS_CMP
373 if (!result)
374 register_smp_ops(&vsmp_smp_ops);
375#else
365 register_smp_ops(&vsmp_smp_ops); 376 register_smp_ops(&vsmp_smp_ops);
366#endif 377#endif
378#endif
367#ifdef CONFIG_MIPS_MT_SMTC 379#ifdef CONFIG_MIPS_MT_SMTC
368 register_smp_ops(&msmtc_smp_ops); 380 register_smp_ops(&msmtc_smp_ops);
369#endif 381#endif
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c
index b4eaf137e4a7..a8756f82c31b 100644
--- a/arch/mips/mti-malta/malta-int.c
+++ b/arch/mips/mti-malta/malta-int.c
@@ -331,6 +331,21 @@ static struct irqaction irq_call = {
331 .flags = IRQF_DISABLED|IRQF_PERCPU, 331 .flags = IRQF_DISABLED|IRQF_PERCPU,
332 .name = "IPI_call" 332 .name = "IPI_call"
333}; 333};
334
335static int gic_resched_int_base;
336static int gic_call_int_base;
337#define GIC_RESCHED_INT(cpu) (gic_resched_int_base+(cpu))
338#define GIC_CALL_INT(cpu) (gic_call_int_base+(cpu))
339
340unsigned int plat_ipi_call_int_xlate(unsigned int cpu)
341{
342 return GIC_CALL_INT(cpu);
343}
344
345unsigned int plat_ipi_resched_int_xlate(unsigned int cpu)
346{
347 return GIC_RESCHED_INT(cpu);
348}
334#endif /* CONFIG_MIPS_MT_SMP */ 349#endif /* CONFIG_MIPS_MT_SMP */
335 350
336static struct irqaction i8259irq = { 351static struct irqaction i8259irq = {
@@ -370,7 +385,7 @@ static int __initdata msc_nr_eicirqs = ARRAY_SIZE(msc_eicirqmap);
370 * Interrupts and CPUs/Core Interrupts. The nature of the External 385 * Interrupts and CPUs/Core Interrupts. The nature of the External
371 * Interrupts is also defined here - polarity/trigger. 386 * Interrupts is also defined here - polarity/trigger.
372 */ 387 */
373static struct gic_intr_map gic_intr_map[] = { 388static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = {
374 { GIC_EXT_INTR(0), X, X, X, X, 0 }, 389 { GIC_EXT_INTR(0), X, X, X, X, 0 },
375 { GIC_EXT_INTR(1), X, X, X, X, 0 }, 390 { GIC_EXT_INTR(1), X, X, X, X, 0 },
376 { GIC_EXT_INTR(2), X, X, X, X, 0 }, 391 { GIC_EXT_INTR(2), X, X, X, X, 0 },
@@ -387,21 +402,14 @@ static struct gic_intr_map gic_intr_map[] = {
387 { GIC_EXT_INTR(13), 0, GIC_MAP_TO_NMI_MSK, GIC_POL_POS, GIC_TRIG_LEVEL, 0 }, 402 { GIC_EXT_INTR(13), 0, GIC_MAP_TO_NMI_MSK, GIC_POL_POS, GIC_TRIG_LEVEL, 0 },
388 { GIC_EXT_INTR(14), 0, GIC_MAP_TO_NMI_MSK, GIC_POL_POS, GIC_TRIG_LEVEL, 0 }, 403 { GIC_EXT_INTR(14), 0, GIC_MAP_TO_NMI_MSK, GIC_POL_POS, GIC_TRIG_LEVEL, 0 },
389 { GIC_EXT_INTR(15), X, X, X, X, 0 }, 404 { GIC_EXT_INTR(15), X, X, X, X, 0 },
390 { GIC_EXT_INTR(16), 0, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_EDGE, 1 }, 405/* This is the end of the general interrupts now we do IPI ones */
391 { GIC_EXT_INTR(17), 0, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
392 { GIC_EXT_INTR(18), 1, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
393 { GIC_EXT_INTR(19), 1, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
394 { GIC_EXT_INTR(20), 2, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
395 { GIC_EXT_INTR(21), 2, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
396 { GIC_EXT_INTR(22), 3, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
397 { GIC_EXT_INTR(23), 3, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
398}; 406};
399#endif 407#endif
400 408
401/* 409/*
402 * GCMP needs to be detected before any SMP initialisation 410 * GCMP needs to be detected before any SMP initialisation
403 */ 411 */
404static int __init gcmp_probe(unsigned long addr, unsigned long size) 412int __init gcmp_probe(unsigned long addr, unsigned long size)
405{ 413{
406 if (gcmp_present >= 0) 414 if (gcmp_present >= 0)
407 return gcmp_present; 415 return gcmp_present;
@@ -416,28 +424,36 @@ static int __init gcmp_probe(unsigned long addr, unsigned long size)
416} 424}
417 425
418#if defined(CONFIG_MIPS_MT_SMP) 426#if defined(CONFIG_MIPS_MT_SMP)
427static void __init fill_ipi_map1(int baseintr, int cpu, int cpupin)
428{
429 int intr = baseintr + cpu;
430 gic_intr_map[intr].intrnum = GIC_EXT_INTR(intr);
431 gic_intr_map[intr].cpunum = cpu;
432 gic_intr_map[intr].pin = cpupin;
433 gic_intr_map[intr].polarity = GIC_POL_POS;
434 gic_intr_map[intr].trigtype = GIC_TRIG_EDGE;
435 gic_intr_map[intr].ipiflag = 1;
436 ipi_map[cpu] |= (1 << (cpupin + 2));
437}
438
419static void __init fill_ipi_map(void) 439static void __init fill_ipi_map(void)
420{ 440{
421 int i; 441 int cpu;
422 442
423 for (i = 0; i < ARRAY_SIZE(gic_intr_map); i++) { 443 for (cpu = 0; cpu < NR_CPUS; cpu++) {
424 if (gic_intr_map[i].ipiflag && (gic_intr_map[i].cpunum != X)) 444 fill_ipi_map1(gic_resched_int_base, cpu, GIC_CPU_INT1);
425 ipi_map[gic_intr_map[i].cpunum] |= 445 fill_ipi_map1(gic_call_int_base, cpu, GIC_CPU_INT2);
426 (1 << (gic_intr_map[i].pin + 2));
427 } 446 }
428} 447}
429#endif 448#endif
430 449
431void __init arch_init_irq(void) 450void __init arch_init_irq(void)
432{ 451{
433 int gic_present, gcmp_present;
434
435 init_i8259_irqs(); 452 init_i8259_irqs();
436 453
437 if (!cpu_has_veic) 454 if (!cpu_has_veic)
438 mips_cpu_irq_init(); 455 mips_cpu_irq_init();
439 456
440 gcmp_present = gcmp_probe(GCMP_BASE_ADDR, GCMP_ADDRSPACE_SZ);
441 if (gcmp_present) { 457 if (gcmp_present) {
442 GCMPGCB(GICBA) = GIC_BASE_ADDR | GCMP_GCB_GICBA_EN_MSK; 458 GCMPGCB(GICBA) = GIC_BASE_ADDR | GCMP_GCB_GICBA_EN_MSK;
443 gic_present = 1; 459 gic_present = 1;
@@ -514,24 +530,10 @@ void __init arch_init_irq(void)
514 if (gic_present) { 530 if (gic_present) {
515 /* FIXME */ 531 /* FIXME */
516 int i; 532 int i;
517 struct { 533
518 unsigned int resched; 534 gic_call_int_base = GIC_NUM_INTRS - NR_CPUS;
519 unsigned int call; 535 gic_resched_int_base = gic_call_int_base - NR_CPUS;
520 } ipiirq[] = { 536
521 {
522 .resched = GIC_IPI_EXT_INTR_RESCHED_VPE0,
523 .call = GIC_IPI_EXT_INTR_CALLFNC_VPE0},
524 {
525 .resched = GIC_IPI_EXT_INTR_RESCHED_VPE1,
526 .call = GIC_IPI_EXT_INTR_CALLFNC_VPE1
527 }, {
528 .resched = GIC_IPI_EXT_INTR_RESCHED_VPE2,
529 .call = GIC_IPI_EXT_INTR_CALLFNC_VPE2
530 }, {
531 .resched = GIC_IPI_EXT_INTR_RESCHED_VPE3,
532 .call = GIC_IPI_EXT_INTR_CALLFNC_VPE3
533 }
534 };
535 fill_ipi_map(); 537 fill_ipi_map();
536 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map, ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE); 538 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map, ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE);
537 if (!gcmp_present) { 539 if (!gcmp_present) {
@@ -553,12 +555,15 @@ void __init arch_init_irq(void)
553 printk("CPU%d: status register now %08x\n", smp_processor_id(), read_c0_status()); 555 printk("CPU%d: status register now %08x\n", smp_processor_id(), read_c0_status());
554 write_c0_status(0x1100dc00); 556 write_c0_status(0x1100dc00);
555 printk("CPU%d: status register frc %08x\n", smp_processor_id(), read_c0_status()); 557 printk("CPU%d: status register frc %08x\n", smp_processor_id(), read_c0_status());
556 for (i = 0; i < ARRAY_SIZE(ipiirq); i++) { 558 for (i = 0; i < NR_CPUS; i++) {
557 setup_irq(MIPS_GIC_IRQ_BASE + ipiirq[i].resched, &irq_resched); 559 setup_irq(MIPS_GIC_IRQ_BASE +
558 setup_irq(MIPS_GIC_IRQ_BASE + ipiirq[i].call, &irq_call); 560 GIC_RESCHED_INT(i), &irq_resched);
559 561 setup_irq(MIPS_GIC_IRQ_BASE +
560 set_irq_handler(MIPS_GIC_IRQ_BASE + ipiirq[i].resched, handle_percpu_irq); 562 GIC_CALL_INT(i), &irq_call);
561 set_irq_handler(MIPS_GIC_IRQ_BASE + ipiirq[i].call, handle_percpu_irq); 563 set_irq_handler(MIPS_GIC_IRQ_BASE +
564 GIC_RESCHED_INT(i), handle_percpu_irq);
565 set_irq_handler(MIPS_GIC_IRQ_BASE +
566 GIC_CALL_INT(i), handle_percpu_irq);
562 } 567 }
563 } else { 568 } else {
564 /* set up ipi interrupts */ 569 /* set up ipi interrupts */
diff --git a/arch/mips/mti-malta/malta-reset.c b/arch/mips/mti-malta/malta-reset.c
index 42dee4da37ba..f48d60e84290 100644
--- a/arch/mips/mti-malta/malta-reset.c
+++ b/arch/mips/mti-malta/malta-reset.c
@@ -28,9 +28,6 @@
28#include <asm/reboot.h> 28#include <asm/reboot.h>
29#include <asm/mips-boards/generic.h> 29#include <asm/mips-boards/generic.h>
30 30
31static void mips_machine_restart(char *command);
32static void mips_machine_halt(void);
33
34static void mips_machine_restart(char *command) 31static void mips_machine_restart(char *command)
35{ 32{
36 unsigned int __iomem *softres_reg = 33 unsigned int __iomem *softres_reg =
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index e8a97f59e066..63d8a297c58d 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -52,3 +52,8 @@ obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o
52obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o 52obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o
53obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o 53obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o
54obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o 54obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o
55obj-$(CONFIG_CPU_CAVIUM_OCTEON) += pci-octeon.o pcie-octeon.o
56
57ifdef CONFIG_PCI_MSI
58obj-$(CONFIG_CPU_CAVIUM_OCTEON) += msi-octeon.o
59endif
diff --git a/arch/mips/pci/fixup-capcella.c b/arch/mips/pci/fixup-capcella.c
index 1416bca6d1a3..1c02f5737367 100644
--- a/arch/mips/pci/fixup-capcella.c
+++ b/arch/mips/pci/fixup-capcella.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-cappcela.c, The ZAO Networks Capcella specific PCI fixups. 2 * fixup-cappcela.c, The ZAO Networks Capcella specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2002,2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002,2004 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/fixup-mpc30x.c b/arch/mips/pci/fixup-mpc30x.c
index 591159625722..e08f49cb6875 100644
--- a/arch/mips/pci/fixup-mpc30x.c
+++ b/arch/mips/pci/fixup-mpc30x.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-mpc30x.c, The Victor MP-C303/304 specific PCI fixups. 2 * fixup-mpc30x.c, The Victor MP-C303/304 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2002,2004 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002,2004 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/fixup-tb0219.c b/arch/mips/pci/fixup-tb0219.c
index ed87733f6796..8084b17d4406 100644
--- a/arch/mips/pci/fixup-tb0219.c
+++ b/arch/mips/pci/fixup-tb0219.c
@@ -2,7 +2,7 @@
2 * fixup-tb0219.c, The TANBAC TB0219 specific PCI fixups. 2 * fixup-tb0219.c, The TANBAC TB0219 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2003 Megasolution Inc. <matsu@megasolution.jp> 4 * Copyright (C) 2003 Megasolution Inc. <matsu@megasolution.jp>
5 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 5 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@linux-mips.org>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/fixup-tb0226.c b/arch/mips/pci/fixup-tb0226.c
index e3eedf4bf9bd..4196ccf3ea3d 100644
--- a/arch/mips/pci/fixup-tb0226.c
+++ b/arch/mips/pci/fixup-tb0226.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-tb0226.c, The TANBAC TB0226 specific PCI fixups. 2 * fixup-tb0226.c, The TANBAC TB0226 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2002-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002-2005 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/pci/fixup-tb0287.c b/arch/mips/pci/fixup-tb0287.c
index 267ab3dc3d42..2fe29db43725 100644
--- a/arch/mips/pci/fixup-tb0287.c
+++ b/arch/mips/pci/fixup-tb0287.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fixup-tb0287.c, The TANBAC TB0287 specific PCI fixups. 2 * fixup-tb0287.c, The TANBAC TB0287 specific PCI fixups.
3 * 3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2005 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cavium-octeon/msi.c b/arch/mips/pci/msi-octeon.c
index 964b03b75a8f..03742e647657 100644
--- a/arch/mips/cavium-octeon/msi.c
+++ b/arch/mips/pci/msi-octeon.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2005-2007 Cavium Networks 6 * Copyright (C) 2005-2009 Cavium Networks
7 */ 7 */
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/init.h> 9#include <linux/init.h>
@@ -16,8 +16,7 @@
16#include <asm/octeon/cvmx-pci-defs.h> 16#include <asm/octeon/cvmx-pci-defs.h>
17#include <asm/octeon/cvmx-npei-defs.h> 17#include <asm/octeon/cvmx-npei-defs.h>
18#include <asm/octeon/cvmx-pexp-defs.h> 18#include <asm/octeon/cvmx-pexp-defs.h>
19 19#include <asm/octeon/pci-octeon.h>
20#include "pci-common.h"
21 20
22/* 21/*
23 * Each bit in msi_free_irq_bitmask represents a MSI interrupt that is 22 * Each bit in msi_free_irq_bitmask represents a MSI interrupt that is
@@ -47,8 +46,8 @@ static DEFINE_SPINLOCK(msi_free_irq_bitmask_lock);
47 * programming the MSI control bits [6:4] before calling 46 * programming the MSI control bits [6:4] before calling
48 * pci_enable_msi(). 47 * pci_enable_msi().
49 * 48 *
50 * @param dev Device requesting MSI interrupts 49 * @dev: Device requesting MSI interrupts
51 * @param desc MSI descriptor 50 * @desc: MSI descriptor
52 * 51 *
53 * Returns 0 on success. 52 * Returns 0 on success.
54 */ 53 */
@@ -213,14 +212,9 @@ void arch_teardown_msi_irq(unsigned int irq)
213} 212}
214 213
215 214
216/** 215/*
217 * Called by the interrupt handling code when an MSI interrupt 216 * Called by the interrupt handling code when an MSI interrupt
218 * occurs. 217 * occurs.
219 *
220 * @param cpl
221 * @param dev_id
222 *
223 * @return
224 */ 218 */
225static irqreturn_t octeon_msi_interrupt(int cpl, void *dev_id) 219static irqreturn_t octeon_msi_interrupt(int cpl, void *dev_id)
226{ 220{
@@ -256,31 +250,37 @@ static irqreturn_t octeon_msi_interrupt(int cpl, void *dev_id)
256} 250}
257 251
258 252
259/** 253/*
260 * Initializes the MSI interrupt handling code 254 * Initializes the MSI interrupt handling code
261 *
262 * @return
263 */ 255 */
264int octeon_msi_initialize(void) 256int octeon_msi_initialize(void)
265{ 257{
266 int r;
267 if (octeon_has_feature(OCTEON_FEATURE_PCIE)) { 258 if (octeon_has_feature(OCTEON_FEATURE_PCIE)) {
268 r = request_irq(OCTEON_IRQ_PCI_MSI0, octeon_msi_interrupt, 259 if (request_irq(OCTEON_IRQ_PCI_MSI0, octeon_msi_interrupt,
269 IRQF_SHARED, 260 IRQF_SHARED,
270 "MSI[0:63]", octeon_msi_interrupt); 261 "MSI[0:63]", octeon_msi_interrupt))
262 panic("request_irq(OCTEON_IRQ_PCI_MSI0) failed");
271 } else if (octeon_is_pci_host()) { 263 } else if (octeon_is_pci_host()) {
272 r = request_irq(OCTEON_IRQ_PCI_MSI0, octeon_msi_interrupt, 264 if (request_irq(OCTEON_IRQ_PCI_MSI0, octeon_msi_interrupt,
273 IRQF_SHARED, 265 IRQF_SHARED,
274 "MSI[0:15]", octeon_msi_interrupt); 266 "MSI[0:15]", octeon_msi_interrupt))
275 r += request_irq(OCTEON_IRQ_PCI_MSI1, octeon_msi_interrupt, 267 panic("request_irq(OCTEON_IRQ_PCI_MSI0) failed");
276 IRQF_SHARED, 268
277 "MSI[16:31]", octeon_msi_interrupt); 269 if (request_irq(OCTEON_IRQ_PCI_MSI1, octeon_msi_interrupt,
278 r += request_irq(OCTEON_IRQ_PCI_MSI2, octeon_msi_interrupt, 270 IRQF_SHARED,
279 IRQF_SHARED, 271 "MSI[16:31]", octeon_msi_interrupt))
280 "MSI[32:47]", octeon_msi_interrupt); 272 panic("request_irq(OCTEON_IRQ_PCI_MSI1) failed");
281 r += request_irq(OCTEON_IRQ_PCI_MSI3, octeon_msi_interrupt, 273
282 IRQF_SHARED, 274 if (request_irq(OCTEON_IRQ_PCI_MSI2, octeon_msi_interrupt,
283 "MSI[48:63]", octeon_msi_interrupt); 275 IRQF_SHARED,
276 "MSI[32:47]", octeon_msi_interrupt))
277 panic("request_irq(OCTEON_IRQ_PCI_MSI2) failed");
278
279 if (request_irq(OCTEON_IRQ_PCI_MSI3, octeon_msi_interrupt,
280 IRQF_SHARED,
281 "MSI[48:63]", octeon_msi_interrupt))
282 panic("request_irq(OCTEON_IRQ_PCI_MSI3) failed");
283
284 } 284 }
285 return 0; 285 return 0;
286} 286}
diff --git a/arch/mips/pci/ops-vr41xx.c b/arch/mips/pci/ops-vr41xx.c
index 900c6b32576c..28962a7c6606 100644
--- a/arch/mips/pci/ops-vr41xx.c
+++ b/arch/mips/pci/ops-vr41xx.c
@@ -2,8 +2,8 @@
2 * ops-vr41xx.c, PCI configuration routines for the PCIU of NEC VR4100 series. 2 * ops-vr41xx.c, PCI configuration routines for the PCIU of NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2001-2003 MontaVista Software Inc. 4 * Copyright (C) 2001-2003 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <source@mvista.com>
6 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 6 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@linux-mips.org>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
21 */ 21 */
22/* 22/*
23 * Changes: 23 * Changes:
24 * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com> 24 * MontaVista Software Inc. <source@mvista.com>
25 * - New creation, NEC VR4122 and VR4131 are supported. 25 * - New creation, NEC VR4122 and VR4131 are supported.
26 */ 26 */
27#include <linux/pci.h> 27#include <linux/pci.h>
diff --git a/arch/mips/cavium-octeon/pci.c b/arch/mips/pci/pci-octeon.c
index 67c0ff5e92f1..9cb0c807f564 100644
--- a/arch/mips/cavium-octeon/pci.c
+++ b/arch/mips/pci/pci-octeon.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2005-2007 Cavium Networks 6 * Copyright (C) 2005-2009 Cavium Networks
7 */ 7 */
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/init.h> 9#include <linux/init.h>
@@ -17,8 +17,7 @@
17#include <asm/octeon/octeon.h> 17#include <asm/octeon/octeon.h>
18#include <asm/octeon/cvmx-npi-defs.h> 18#include <asm/octeon/cvmx-npi-defs.h>
19#include <asm/octeon/cvmx-pci-defs.h> 19#include <asm/octeon/cvmx-pci-defs.h>
20 20#include <asm/octeon/pci-octeon.h>
21#include "pci-common.h"
22 21
23#define USE_OCTEON_INTERNAL_ARBITER 22#define USE_OCTEON_INTERNAL_ARBITER
24 23
@@ -54,6 +53,126 @@ union octeon_pci_address {
54 } s; 53 } s;
55}; 54};
56 55
56int __initdata (*octeon_pcibios_map_irq)(const struct pci_dev *dev,
57 u8 slot, u8 pin);
58enum octeon_dma_bar_type octeon_dma_bar_type = OCTEON_DMA_BAR_TYPE_INVALID;
59
60/**
61 * Map a PCI device to the appropriate interrupt line
62 *
63 * @dev: The Linux PCI device structure for the device to map
64 * @slot: The slot number for this device on __BUS 0__. Linux
65 * enumerates through all the bridges and figures out the
66 * slot on Bus 0 where this device eventually hooks to.
67 * @pin: The PCI interrupt pin read from the device, then swizzled
68 * as it goes through each bridge.
69 * Returns Interrupt number for the device
70 */
71int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
72{
73 if (octeon_pcibios_map_irq)
74 return octeon_pcibios_map_irq(dev, slot, pin);
75 else
76 panic("octeon_pcibios_map_irq not set.");
77}
78
79
80/*
81 * Called to perform platform specific PCI setup
82 */
83int pcibios_plat_dev_init(struct pci_dev *dev)
84{
85 uint16_t config;
86 uint32_t dconfig;
87 int pos;
88 /*
89 * Force the Cache line setting to 64 bytes. The standard
90 * Linux bus scan doesn't seem to set it. Octeon really has
91 * 128 byte lines, but Intel bridges get really upset if you
92 * try and set values above 64 bytes. Value is specified in
93 * 32bit words.
94 */
95 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 64 / 4);
96 /* Set latency timers for all devices */
97 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 48);
98
99 /* Enable reporting System errors and parity errors on all devices */
100 /* Enable parity checking and error reporting */
101 pci_read_config_word(dev, PCI_COMMAND, &config);
102 config |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
103 pci_write_config_word(dev, PCI_COMMAND, config);
104
105 if (dev->subordinate) {
106 /* Set latency timers on sub bridges */
107 pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 48);
108 /* More bridge error detection */
109 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &config);
110 config |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
111 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, config);
112 }
113
114 /* Enable the PCIe normal error reporting */
115 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
116 if (pos) {
117 /* Update Device Control */
118 pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &config);
119 /* Correctable Error Reporting */
120 config |= PCI_EXP_DEVCTL_CERE;
121 /* Non-Fatal Error Reporting */
122 config |= PCI_EXP_DEVCTL_NFERE;
123 /* Fatal Error Reporting */
124 config |= PCI_EXP_DEVCTL_FERE;
125 /* Unsupported Request */
126 config |= PCI_EXP_DEVCTL_URRE;
127 pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, config);
128 }
129
130 /* Find the Advanced Error Reporting capability */
131 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
132 if (pos) {
133 /* Clear Uncorrectable Error Status */
134 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
135 &dconfig);
136 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
137 dconfig);
138 /* Enable reporting of all uncorrectable errors */
139 /* Uncorrectable Error Mask - turned on bits disable errors */
140 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
141 /*
142 * Leave severity at HW default. This only controls if
143 * errors are reported as uncorrectable or
144 * correctable, not if the error is reported.
145 */
146 /* PCI_ERR_UNCOR_SEVER - Uncorrectable Error Severity */
147 /* Clear Correctable Error Status */
148 pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &dconfig);
149 pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, dconfig);
150 /* Enable reporting of all correctable errors */
151 /* Correctable Error Mask - turned on bits disable errors */
152 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, 0);
153 /* Advanced Error Capabilities */
154 pci_read_config_dword(dev, pos + PCI_ERR_CAP, &dconfig);
155 /* ECRC Generation Enable */
156 if (config & PCI_ERR_CAP_ECRC_GENC)
157 config |= PCI_ERR_CAP_ECRC_GENE;
158 /* ECRC Check Enable */
159 if (config & PCI_ERR_CAP_ECRC_CHKC)
160 config |= PCI_ERR_CAP_ECRC_CHKE;
161 pci_write_config_dword(dev, pos + PCI_ERR_CAP, dconfig);
162 /* PCI_ERR_HEADER_LOG - Header Log Register (16 bytes) */
163 /* Report all errors to the root complex */
164 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND,
165 PCI_ERR_ROOT_CMD_COR_EN |
166 PCI_ERR_ROOT_CMD_NONFATAL_EN |
167 PCI_ERR_ROOT_CMD_FATAL_EN);
168 /* Clear the Root status register */
169 pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &dconfig);
170 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig);
171 }
172
173 return 0;
174}
175
57/** 176/**
58 * Return the mapping of PCI device number to IRQ line. Each 177 * Return the mapping of PCI device number to IRQ line. Each
59 * character in the return string represents the interrupt 178 * character in the return string represents the interrupt
@@ -136,9 +255,8 @@ int __init octeon_pci_pcibios_map_irq(const struct pci_dev *dev,
136} 255}
137 256
138 257
139/** 258/*
140 * Read a value from configuration space 259 * Read a value from configuration space
141 *
142 */ 260 */
143static int octeon_read_config(struct pci_bus *bus, unsigned int devfn, 261static int octeon_read_config(struct pci_bus *bus, unsigned int devfn,
144 int reg, int size, u32 *val) 262 int reg, int size, u32 *val)
@@ -174,15 +292,8 @@ static int octeon_read_config(struct pci_bus *bus, unsigned int devfn,
174} 292}
175 293
176 294
177/** 295/*
178 * Write a value to PCI configuration space 296 * Write a value to PCI configuration space
179 *
180 * @bus:
181 * @devfn:
182 * @reg:
183 * @size:
184 * @val:
185 * Returns
186 */ 297 */
187static int octeon_write_config(struct pci_bus *bus, unsigned int devfn, 298static int octeon_write_config(struct pci_bus *bus, unsigned int devfn,
188 int reg, int size, u32 val) 299 int reg, int size, u32 val)
@@ -251,10 +362,8 @@ static struct pci_controller octeon_pci_controller = {
251}; 362};
252 363
253 364
254/** 365/*
255 * Low level initialize the Octeon PCI controller 366 * Low level initialize the Octeon PCI controller
256 *
257 * Returns
258 */ 367 */
259static void octeon_pci_initialize(void) 368static void octeon_pci_initialize(void)
260{ 369{
@@ -398,7 +507,7 @@ static void octeon_pci_initialize(void)
398 pci_int_arb_cfg.s.en = 1; /* Internal arbiter enable */ 507 pci_int_arb_cfg.s.en = 1; /* Internal arbiter enable */
399 cvmx_write_csr(CVMX_NPI_PCI_INT_ARB_CFG, pci_int_arb_cfg.u64); 508 cvmx_write_csr(CVMX_NPI_PCI_INT_ARB_CFG, pci_int_arb_cfg.u64);
400 } 509 }
401#endif /* USE_OCTEON_INTERNAL_ARBITER */ 510#endif /* USE_OCTEON_INTERNAL_ARBITER */
402 511
403 /* 512 /*
404 * Preferrably written to 1 to set MLTD. [RDSATI,TRTAE, 513 * Preferrably written to 1 to set MLTD. [RDSATI,TRTAE,
@@ -457,10 +566,8 @@ static void octeon_pci_initialize(void)
457} 566}
458 567
459 568
460/** 569/*
461 * Initialize the Octeon PCI controller 570 * Initialize the Octeon PCI controller
462 *
463 * Returns
464 */ 571 */
465static int __init octeon_pci_setup(void) 572static int __init octeon_pci_setup(void)
466{ 573{
diff --git a/arch/mips/pci/pci-vr41xx.c b/arch/mips/pci/pci-vr41xx.c
index d1e049b55f34..56525711f8b7 100644
--- a/arch/mips/pci/pci-vr41xx.c
+++ b/arch/mips/pci/pci-vr41xx.c
@@ -2,8 +2,8 @@
2 * pci-vr41xx.c, PCI Control Unit routines for the NEC VR4100 series. 2 * pci-vr41xx.c, PCI Control Unit routines for the NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2001-2003 MontaVista Software Inc. 4 * Copyright (C) 2001-2003 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <source@mvista.com>
6 * Copyright (C) 2004-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 6 * Copyright (C) 2004-2008 Yoichi Yuasa <yuasa@linux-mips.org>
7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org) 7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,7 @@
22 */ 22 */
23/* 23/*
24 * Changes: 24 * Changes:
25 * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com> 25 * MontaVista Software Inc. <source@mvista.com>
26 * - New creation, NEC VR4122 and VR4131 are supported. 26 * - New creation, NEC VR4122 and VR4131 are supported.
27 */ 27 */
28#include <linux/init.h> 28#include <linux/init.h>
diff --git a/arch/mips/pci/pci-vr41xx.h b/arch/mips/pci/pci-vr41xx.h
index 8a35e32b8376..6b1ae2eb1c06 100644
--- a/arch/mips/pci/pci-vr41xx.h
+++ b/arch/mips/pci/pci-vr41xx.h
@@ -2,8 +2,8 @@
2 * pci-vr41xx.h, Include file for PCI Control Unit of the NEC VR4100 series. 2 * pci-vr41xx.h, Include file for PCI Control Unit of the NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2002 MontaVista Software Inc. 4 * Copyright (C) 2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <source@mvista.com>
6 * Copyright (C) 2004-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 6 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@linux-mips.org>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/cavium-octeon/pcie.c b/arch/mips/pci/pcie-octeon.c
index 49d14081b3b5..75262247f3e4 100644
--- a/arch/mips/cavium-octeon/pcie.c
+++ b/arch/mips/pci/pcie-octeon.c
@@ -18,8 +18,7 @@
18#include <asm/octeon/cvmx-pescx-defs.h> 18#include <asm/octeon/cvmx-pescx-defs.h>
19#include <asm/octeon/cvmx-pexp-defs.h> 19#include <asm/octeon/cvmx-pexp-defs.h>
20#include <asm/octeon/cvmx-helper-errata.h> 20#include <asm/octeon/cvmx-helper-errata.h>
21 21#include <asm/octeon/pci-octeon.h>
22#include "pci-common.h"
23 22
24union cvmx_pcie_address { 23union cvmx_pcie_address {
25 uint64_t u64; 24 uint64_t u64;
@@ -976,13 +975,13 @@ static int cvmx_pcie_rc_initialize(int pcie_port)
976/** 975/**
977 * Map a PCI device to the appropriate interrupt line 976 * Map a PCI device to the appropriate interrupt line
978 * 977 *
979 * @param dev The Linux PCI device structure for the device to map 978 * @dev: The Linux PCI device structure for the device to map
980 * @param slot The slot number for this device on __BUS 0__. Linux 979 * @slot: The slot number for this device on __BUS 0__. Linux
981 * enumerates through all the bridges and figures out the 980 * enumerates through all the bridges and figures out the
982 * slot on Bus 0 where this device eventually hooks to. 981 * slot on Bus 0 where this device eventually hooks to.
983 * @param pin The PCI interrupt pin read from the device, then swizzled 982 * @pin: The PCI interrupt pin read from the device, then swizzled
984 * as it goes through each bridge. 983 * as it goes through each bridge.
985 * @return Interrupt number for the device 984 * Returns Interrupt number for the device
986 */ 985 */
987int __init octeon_pcie_pcibios_map_irq(const struct pci_dev *dev, 986int __init octeon_pcie_pcibios_map_irq(const struct pci_dev *dev,
988 u8 slot, u8 pin) 987 u8 slot, u8 pin)
@@ -1025,12 +1024,12 @@ int __init octeon_pcie_pcibios_map_irq(const struct pci_dev *dev,
1025/** 1024/**
1026 * Read a value from configuration space 1025 * Read a value from configuration space
1027 * 1026 *
1028 * @param bus 1027 * @bus:
1029 * @param devfn 1028 * @devfn:
1030 * @param reg 1029 * @reg:
1031 * @param size 1030 * @size:
1032 * @param val 1031 * @val:
1033 * @return 1032 * Returns
1034 */ 1033 */
1035static inline int octeon_pcie_read_config(int pcie_port, struct pci_bus *bus, 1034static inline int octeon_pcie_read_config(int pcie_port, struct pci_bus *bus,
1036 unsigned int devfn, int reg, int size, 1035 unsigned int devfn, int reg, int size,
@@ -1156,12 +1155,12 @@ static int octeon_pcie1_read_config(struct pci_bus *bus, unsigned int devfn,
1156/** 1155/**
1157 * Write a value to PCI configuration space 1156 * Write a value to PCI configuration space
1158 * 1157 *
1159 * @param bus 1158 * @bus:
1160 * @param devfn 1159 * @devfn:
1161 * @param reg 1160 * @reg:
1162 * @param size 1161 * @size:
1163 * @param val 1162 * @val:
1164 * @return 1163 * Returns
1165 */ 1164 */
1166static inline int octeon_pcie_write_config(int pcie_port, struct pci_bus *bus, 1165static inline int octeon_pcie_write_config(int pcie_port, struct pci_bus *bus,
1167 unsigned int devfn, int reg, 1166 unsigned int devfn, int reg,
@@ -1254,7 +1253,7 @@ static struct pci_controller octeon_pcie1_controller = {
1254/** 1253/**
1255 * Initialize the Octeon PCIe controllers 1254 * Initialize the Octeon PCIe controllers
1256 * 1255 *
1257 * @return 1256 * Returns
1258 */ 1257 */
1259static int __init octeon_pcie_setup(void) 1258static int __init octeon_pcie_setup(void)
1260{ 1259{
diff --git a/arch/mips/vr41xx/casio-e55/setup.c b/arch/mips/vr41xx/casio-e55/setup.c
index 6d9bab890587..719f4a5b9844 100644
--- a/arch/mips/vr41xx/casio-e55/setup.c
+++ b/arch/mips/vr41xx/casio-e55/setup.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * setup.c, Setup for the CASIO CASSIOPEIA E-11/15/55/65. 2 * setup.c, Setup for the CASIO CASSIOPEIA E-11/15/55/65.
3 * 3 *
4 * Copyright (C) 2002-2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002-2006 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/bcu.c b/arch/mips/vr41xx/common/bcu.c
index d77c330a0d59..6346c59c9f9d 100644
--- a/arch/mips/vr41xx/common/bcu.c
+++ b/arch/mips/vr41xx/common/bcu.c
@@ -2,8 +2,8 @@
2 * bcu.c, Bus Control Unit routines for the NEC VR4100 series. 2 * bcu.c, Bus Control Unit routines for the NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2002 MontaVista Software Inc. 4 * Copyright (C) 2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> 5 * Author: Yoichi Yuasa <source@mvista.com>
6 * Copyright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 6 * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@linux-mips.org>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -21,11 +21,11 @@
21 */ 21 */
22/* 22/*
23 * Changes: 23 * Changes:
24 * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com> 24 * MontaVista Software Inc. <source@mvista.com>
25 * - New creation, NEC VR4122 and VR4131 are supported. 25 * - New creation, NEC VR4122 and VR4131 are supported.
26 * - Added support for NEC VR4111 and VR4121. 26 * - Added support for NEC VR4111 and VR4121.
27 * 27 *
28 * Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 28 * Yoichi Yuasa <yuasa@linux-mips.org>
29 * - Added support for NEC VR4133. 29 * - Added support for NEC VR4133.
30 */ 30 */
31#include <linux/kernel.h> 31#include <linux/kernel.h>
diff --git a/arch/mips/vr41xx/common/cmu.c b/arch/mips/vr41xx/common/cmu.c
index ad0e8e3409d9..8ba7d04a5ec5 100644
--- a/arch/mips/vr41xx/common/cmu.c
+++ b/arch/mips/vr41xx/common/cmu.c
@@ -2,8 +2,8 @@
2 * cmu.c, Clock Mask Unit routines for the NEC VR4100 series. 2 * cmu.c, Clock Mask Unit routines for the NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2001-2002 MontaVista Software Inc. 4 * Copyright (C) 2001-2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <source@mvista.com>
6 * Copuright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 6 * Copuright (C) 2003-2005 Yoichi Yuasa <yuasa@linux-mips.org>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -21,11 +21,11 @@
21 */ 21 */
22/* 22/*
23 * Changes: 23 * Changes:
24 * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com> 24 * MontaVista Software Inc. <source@mvista.com>
25 * - New creation, NEC VR4122 and VR4131 are supported. 25 * - New creation, NEC VR4122 and VR4131 are supported.
26 * - Added support for NEC VR4111 and VR4121. 26 * - Added support for NEC VR4111 and VR4121.
27 * 27 *
28 * Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 28 * Yoichi Yuasa <yuasa@linux-mips.org>
29 * - Added support for NEC VR4133. 29 * - Added support for NEC VR4133.
30 */ 30 */
31#include <linux/init.h> 31#include <linux/init.h>
diff --git a/arch/mips/vr41xx/common/giu.c b/arch/mips/vr41xx/common/giu.c
index 2b272f1496fe..22cc6f2100a1 100644
--- a/arch/mips/vr41xx/common/giu.c
+++ b/arch/mips/vr41xx/common/giu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * NEC VR4100 series GIU platform device. 2 * NEC VR4100 series GIU platform device.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
index 3f23d9fda662..6d39e222b170 100644
--- a/arch/mips/vr41xx/common/icu.c
+++ b/arch/mips/vr41xx/common/icu.c
@@ -2,8 +2,8 @@
2 * icu.c, Interrupt Control Unit routines for the NEC VR4100 series. 2 * icu.c, Interrupt Control Unit routines for the NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2001-2002 MontaVista Software Inc. 4 * Copyright (C) 2001-2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <source@mvista.com>
6 * Copyright (C) 2003-2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 6 * Copyright (C) 2003-2006 Yoichi Yuasa <yuasa@linux-mips.org>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -21,11 +21,11 @@
21 */ 21 */
22/* 22/*
23 * Changes: 23 * Changes:
24 * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com> 24 * MontaVista Software Inc. <source@mvista.com>
25 * - New creation, NEC VR4122 and VR4131 are supported. 25 * - New creation, NEC VR4122 and VR4131 are supported.
26 * - Added support for NEC VR4111 and VR4121. 26 * - Added support for NEC VR4111 and VR4121.
27 * 27 *
28 * Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 28 * Yoichi Yuasa <yuasa@linux-mips.org>
29 * - Coped with INTASSIGN of NEC VR4133. 29 * - Coped with INTASSIGN of NEC VR4133.
30 */ 30 */
31#include <linux/errno.h> 31#include <linux/errno.h>
diff --git a/arch/mips/vr41xx/common/init.c b/arch/mips/vr41xx/common/init.c
index c64995342ba8..1386e6f081c8 100644
--- a/arch/mips/vr41xx/common/init.c
+++ b/arch/mips/vr41xx/common/init.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * init.c, Common initialization routines for NEC VR4100 series. 2 * init.c, Common initialization routines for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2003-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2003-2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
index 9cc389109b19..bef06872f012 100644
--- a/arch/mips/vr41xx/common/irq.c
+++ b/arch/mips/vr41xx/common/irq.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Interrupt handing routines for NEC VR4100 series. 2 * Interrupt handing routines for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2005-2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2005-2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/pmu.c b/arch/mips/vr41xx/common/pmu.c
index 028aaf75eb21..692b4e85b7fc 100644
--- a/arch/mips/vr41xx/common/pmu.c
+++ b/arch/mips/vr41xx/common/pmu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * pmu.c, Power Management Unit routines for NEC VR4100 series. 2 * pmu.c, Power Management Unit routines for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2003-2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2003-2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/rtc.c b/arch/mips/vr41xx/common/rtc.c
index 9f26c14edcac..ebc5dcf0ed8e 100644
--- a/arch/mips/vr41xx/common/rtc.c
+++ b/arch/mips/vr41xx/common/rtc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * NEC VR4100 series RTC platform device. 2 * NEC VR4100 series RTC platform device.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/siu.c b/arch/mips/vr41xx/common/siu.c
index 654dee6208be..54eae56108fb 100644
--- a/arch/mips/vr41xx/common/siu.c
+++ b/arch/mips/vr41xx/common/siu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * NEC VR4100 series SIU platform device. 2 * NEC VR4100 series SIU platform device.
3 * 3 *
4 * Copyright (C) 2007-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007-2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/common/type.c b/arch/mips/vr41xx/common/type.c
index e0c1ac5e988e..ff841422b638 100644
--- a/arch/mips/vr41xx/common/type.c
+++ b/arch/mips/vr41xx/common/type.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * type.c, System type for NEC VR4100 series. 2 * type.c, System type for NEC VR4100 series.
3 * 3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2005 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mips/vr41xx/ibm-workpad/setup.c b/arch/mips/vr41xx/ibm-workpad/setup.c
index 9eef297eca1a..3982f378a3e6 100644
--- a/arch/mips/vr41xx/ibm-workpad/setup.c
+++ b/arch/mips/vr41xx/ibm-workpad/setup.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * setup.c, Setup for the IBM WorkPad z50. 2 * setup.c, Setup for the IBM WorkPad z50.
3 * 3 *
4 * Copyright (C) 2002-2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2002-2006 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/arch/mn10300/include/asm/pci.h b/arch/mn10300/include/asm/pci.h
index e58b9a46e1b1..35d2ed6396f6 100644
--- a/arch/mn10300/include/asm/pci.h
+++ b/arch/mn10300/include/asm/pci.h
@@ -70,10 +70,6 @@ struct pci_dev;
70 */ 70 */
71#define PCI_DMA_BUS_IS_PHYS (1) 71#define PCI_DMA_BUS_IS_PHYS (1)
72 72
73
74/* This is always fine. */
75#define pci_dac_dma_supported(pci_dev, mask) (0)
76
77/* Return the index of the PCI controller for device. */ 73/* Return the index of the PCI controller for device. */
78static inline int pci_controller_num(struct pci_dev *dev) 74static inline int pci_controller_num(struct pci_dev *dev)
79{ 75{
diff --git a/arch/mn10300/include/asm/thread_info.h b/arch/mn10300/include/asm/thread_info.h
index 78a3881f3c12..58d64f8b2cc3 100644
--- a/arch/mn10300/include/asm/thread_info.h
+++ b/arch/mn10300/include/asm/thread_info.h
@@ -65,8 +65,6 @@ struct thread_info {
65 65
66/* 66/*
67 * macros/functions for gaining access to the thread information structure 67 * macros/functions for gaining access to the thread information structure
68 *
69 * preempt_count needs to be 1 initially, until the scheduler is functional.
70 */ 68 */
71#ifndef __ASSEMBLY__ 69#ifndef __ASSEMBLY__
72 70
@@ -76,7 +74,7 @@ struct thread_info {
76 .exec_domain = &default_exec_domain, \ 74 .exec_domain = &default_exec_domain, \
77 .flags = 0, \ 75 .flags = 0, \
78 .cpu = 0, \ 76 .cpu = 0, \
79 .preempt_count = 1, \ 77 .preempt_count = INIT_PREEMPT_COUNT, \
80 .addr_limit = KERNEL_DS, \ 78 .addr_limit = KERNEL_DS, \
81 .restart_block = { \ 79 .restart_block = { \
82 .fn = do_no_restart_syscall, \ 80 .fn = do_no_restart_syscall, \
diff --git a/arch/mn10300/include/asm/unistd.h b/arch/mn10300/include/asm/unistd.h
index fef5b434dadc..fad68616af32 100644
--- a/arch/mn10300/include/asm/unistd.h
+++ b/arch/mn10300/include/asm/unistd.h
@@ -346,10 +346,12 @@
346#define __NR_inotify_init1 333 346#define __NR_inotify_init1 333
347#define __NR_preadv 334 347#define __NR_preadv 334
348#define __NR_pwritev 335 348#define __NR_pwritev 335
349#define __NR_rt_tgsigqueueinfo 336
350#define __NR_perf_counter_open 337
349 351
350#ifdef __KERNEL__ 352#ifdef __KERNEL__
351 353
352#define NR_syscalls 326 354#define NR_syscalls 338
353 355
354/* 356/*
355 * specify the deprecated syscalls we want to support on this arch 357 * specify the deprecated syscalls we want to support on this arch
diff --git a/arch/mn10300/kernel/entry.S b/arch/mn10300/kernel/entry.S
index 7408a27199f3..e0d2563af4f2 100644
--- a/arch/mn10300/kernel/entry.S
+++ b/arch/mn10300/kernel/entry.S
@@ -722,6 +722,8 @@ ENTRY(sys_call_table)
722 .long sys_inotify_init1 722 .long sys_inotify_init1
723 .long sys_preadv 723 .long sys_preadv
724 .long sys_pwritev /* 335 */ 724 .long sys_pwritev /* 335 */
725 .long sys_rt_tgsigqueueinfo
726 .long sys_perf_counter_open
725 727
726 728
727nr_syscalls=(.-sys_call_table)/4 729nr_syscalls=(.-sys_call_table)/4
diff --git a/arch/mn10300/kernel/ptrace.c b/arch/mn10300/kernel/ptrace.c
index e143339ad28e..cf847dabc1bd 100644
--- a/arch/mn10300/kernel/ptrace.c
+++ b/arch/mn10300/kernel/ptrace.c
@@ -13,7 +13,6 @@
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/smp.h> 15#include <linux/smp.h>
16#include <linux/smp_lock.h>
17#include <linux/errno.h> 16#include <linux/errno.h>
18#include <linux/ptrace.h> 17#include <linux/ptrace.h>
19#include <linux/user.h> 18#include <linux/user.h>
diff --git a/arch/mn10300/kernel/signal.c b/arch/mn10300/kernel/signal.c
index 9f7572a0f578..feb2f2e810db 100644
--- a/arch/mn10300/kernel/signal.c
+++ b/arch/mn10300/kernel/signal.c
@@ -12,7 +12,6 @@
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/smp.h> 14#include <linux/smp.h>
15#include <linux/smp_lock.h>
16#include <linux/kernel.h> 15#include <linux/kernel.h>
17#include <linux/signal.h> 16#include <linux/signal.h>
18#include <linux/errno.h> 17#include <linux/errno.h>
diff --git a/arch/mn10300/kernel/sys_mn10300.c b/arch/mn10300/kernel/sys_mn10300.c
index bca5a84dc72c..3e52a1054327 100644
--- a/arch/mn10300/kernel/sys_mn10300.c
+++ b/arch/mn10300/kernel/sys_mn10300.c
@@ -13,7 +13,6 @@
13#include <linux/syscalls.h> 13#include <linux/syscalls.h>
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/smp.h> 15#include <linux/smp.h>
16#include <linux/smp_lock.h>
17#include <linux/sem.h> 16#include <linux/sem.h>
18#include <linux/msg.h> 17#include <linux/msg.h>
19#include <linux/shm.h> 18#include <linux/shm.h>
@@ -21,7 +20,6 @@
21#include <linux/mman.h> 20#include <linux/mman.h>
22#include <linux/file.h> 21#include <linux/file.h>
23#include <linux/utsname.h> 22#include <linux/utsname.h>
24#include <linux/syscalls.h>
25#include <linux/tty.h> 23#include <linux/tty.h>
26 24
27#include <asm/uaccess.h> 25#include <asm/uaccess.h>
diff --git a/arch/mn10300/kernel/traps.c b/arch/mn10300/kernel/traps.c
index 681ad8c9e4fb..91365adba4f5 100644
--- a/arch/mn10300/kernel/traps.c
+++ b/arch/mn10300/kernel/traps.c
@@ -17,7 +17,6 @@
17#include <linux/timer.h> 17#include <linux/timer.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/smp_lock.h>
21#include <linux/init.h> 20#include <linux/init.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/spinlock.h> 22#include <linux/spinlock.h>
@@ -136,8 +135,7 @@ void show_trace(unsigned long *sp)
136 unsigned long *stack, addr, module_start, module_end; 135 unsigned long *stack, addr, module_start, module_end;
137 int i; 136 int i;
138 137
139 printk(KERN_EMERG "\n" 138 printk(KERN_EMERG "\nCall Trace:");
140 KERN_EMERG "Call Trace:");
141 139
142 stack = sp; 140 stack = sp;
143 i = 0; 141 i = 0;
@@ -153,7 +151,7 @@ void show_trace(unsigned long *sp)
153 printk("\n"); 151 printk("\n");
154#else 152#else
155 if ((i % 6) == 0) 153 if ((i % 6) == 0)
156 printk("\n" KERN_EMERG " "); 154 printk(KERN_EMERG " ");
157 printk("[<%08lx>] ", addr); 155 printk("[<%08lx>] ", addr);
158 i++; 156 i++;
159#endif 157#endif
@@ -180,7 +178,7 @@ void show_stack(struct task_struct *task, unsigned long *sp)
180 if (((long) stack & (THREAD_SIZE - 1)) == 0) 178 if (((long) stack & (THREAD_SIZE - 1)) == 0)
181 break; 179 break;
182 if ((i % 8) == 0) 180 if ((i % 8) == 0)
183 printk("\n" KERN_EMERG " "); 181 printk(KERN_EMERG " ");
184 printk("%08lx ", *stack++); 182 printk("%08lx ", *stack++);
185 } 183 }
186 184
@@ -264,8 +262,7 @@ void show_registers(struct pt_regs *regs)
264 show_stack(current, (unsigned long *) sp); 262 show_stack(current, (unsigned long *) sp);
265 263
266#if 0 264#if 0
267 printk(KERN_EMERG "\n" 265 printk(KERN_EMERG "\nCode: ");
268 KERN_EMERG "Code: ");
269 if (regs->pc < PAGE_OFFSET) 266 if (regs->pc < PAGE_OFFSET)
270 goto bad; 267 goto bad;
271 268
@@ -311,16 +308,14 @@ void die(const char *str, struct pt_regs *regs, enum exception_code code)
311{ 308{
312 console_verbose(); 309 console_verbose();
313 spin_lock_irq(&die_lock); 310 spin_lock_irq(&die_lock);
314 printk(KERN_EMERG "\n" 311 printk(KERN_EMERG "\n%s: %04x\n",
315 KERN_EMERG "%s: %04x\n",
316 str, code & 0xffff); 312 str, code & 0xffff);
317 show_registers(regs); 313 show_registers(regs);
318 314
319 if (regs->pc >= 0x02000000 && regs->pc < 0x04000000 && 315 if (regs->pc >= 0x02000000 && regs->pc < 0x04000000 &&
320 (regs->epsw & (EPSW_IM | EPSW_IE)) != (EPSW_IM | EPSW_IE)) { 316 (regs->epsw & (EPSW_IM | EPSW_IE)) != (EPSW_IM | EPSW_IE)) {
321 printk(KERN_EMERG "Exception in usermode interrupt handler\n"); 317 printk(KERN_EMERG "Exception in usermode interrupt handler\n");
322 printk(KERN_EMERG "\n" 318 printk(KERN_EMERG "\nPlease connect to kernel debugger !!\n");
323 KERN_EMERG " Please connect to kernel debugger !!\n");
324 asm volatile ("0: bra 0b"); 319 asm volatile ("0: bra 0b");
325 } 320 }
326 321
@@ -429,9 +424,8 @@ asmlinkage void io_bus_error(u32 bcberr, u32 bcbear, struct pt_regs *regs)
429{ 424{
430 console_verbose(); 425 console_verbose();
431 426
432 printk(KERN_EMERG "\n" 427 printk(KERN_EMERG "Asynchronous I/O Bus Error\n");
433 KERN_EMERG "Asynchronous I/O Bus Error\n" 428 printk(KERN_EMERG "==========================\n");
434 KERN_EMERG "==========================\n");
435 429
436 if (bcberr & BCBERR_BEME) 430 if (bcberr & BCBERR_BEME)
437 printk(KERN_EMERG "- Multiple recorded errors\n"); 431 printk(KERN_EMERG "- Multiple recorded errors\n");
diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index bcebcefb4ad7..c96ba3da95ac 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -61,7 +61,7 @@ SECTIONS
61 _edata = .; /* End of data section */ 61 _edata = .; /* End of data section */
62 } 62 }
63 63
64 .data.init_task : { INIT_TASK(THREAD_SIZE); } 64 .data.init_task : { INIT_TASK_DATA(THREAD_SIZE); }
65 65
66 /* might get freed after init */ 66 /* might get freed after init */
67 . = ALIGN(PAGE_SIZE); 67 . = ALIGN(PAGE_SIZE);
diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c
index a62e1e138bc1..53bb17d0f068 100644
--- a/arch/mn10300/mm/fault.c
+++ b/arch/mn10300/mm/fault.c
@@ -20,7 +20,6 @@
20#include <linux/mman.h> 20#include <linux/mman.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <linux/smp_lock.h>
24#include <linux/interrupt.h> 23#include <linux/interrupt.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/vt_kern.h> /* For unblank_screen() */ 25#include <linux/vt_kern.h> /* For unblank_screen() */
diff --git a/arch/mn10300/mm/misalignment.c b/arch/mn10300/mm/misalignment.c
index 94c4a4358065..30016251f658 100644
--- a/arch/mn10300/mm/misalignment.c
+++ b/arch/mn10300/mm/misalignment.c
@@ -17,7 +17,6 @@
17#include <linux/timer.h> 17#include <linux/timer.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/smp_lock.h>
21#include <linux/init.h> 20#include <linux/init.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/spinlock.h> 22#include <linux/spinlock.h>
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 9038f39d9d73..06f8d5b5b0f9 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -16,6 +16,8 @@ config PARISC
16 select RTC_DRV_GENERIC 16 select RTC_DRV_GENERIC
17 select INIT_ALL_POSSIBLE 17 select INIT_ALL_POSSIBLE
18 select BUG 18 select BUG
19 select HAVE_PERF_COUNTERS
20 select GENERIC_ATOMIC64 if !64BIT
19 help 21 help
20 The PA-RISC microprocessor is designed by Hewlett-Packard and used 22 The PA-RISC microprocessor is designed by Hewlett-Packard and used
21 in many of their workstations & servers (HP9000 700 and 800 series, 23 in many of their workstations & servers (HP9000 700 and 800 series,
diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
index 7eeaff944360..8bc9e96699b2 100644
--- a/arch/parisc/include/asm/atomic.h
+++ b/arch/parisc/include/asm/atomic.h
@@ -222,13 +222,13 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
222 222
223#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 223#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
224 224
225#define atomic_add(i,v) ((void)(__atomic_add_return( ((int)(i)),(v)))) 225#define atomic_add(i,v) ((void)(__atomic_add_return( (i),(v))))
226#define atomic_sub(i,v) ((void)(__atomic_add_return(-((int)(i)),(v)))) 226#define atomic_sub(i,v) ((void)(__atomic_add_return(-(i),(v))))
227#define atomic_inc(v) ((void)(__atomic_add_return( 1,(v)))) 227#define atomic_inc(v) ((void)(__atomic_add_return( 1,(v))))
228#define atomic_dec(v) ((void)(__atomic_add_return( -1,(v)))) 228#define atomic_dec(v) ((void)(__atomic_add_return( -1,(v))))
229 229
230#define atomic_add_return(i,v) (__atomic_add_return( ((int)(i)),(v))) 230#define atomic_add_return(i,v) (__atomic_add_return( (i),(v)))
231#define atomic_sub_return(i,v) (__atomic_add_return(-((int)(i)),(v))) 231#define atomic_sub_return(i,v) (__atomic_add_return(-(i),(v)))
232#define atomic_inc_return(v) (__atomic_add_return( 1,(v))) 232#define atomic_inc_return(v) (__atomic_add_return( 1,(v)))
233#define atomic_dec_return(v) (__atomic_add_return( -1,(v))) 233#define atomic_dec_return(v) (__atomic_add_return( -1,(v)))
234 234
@@ -336,7 +336,11 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
336 336
337#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) 337#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
338 338
339#endif /* CONFIG_64BIT */ 339#else /* CONFIG_64BIT */
340
341#include <asm-generic/atomic64.h>
342
343#endif /* !CONFIG_64BIT */
340 344
341#include <asm-generic/atomic-long.h> 345#include <asm-generic/atomic-long.h>
342 346
diff --git a/arch/parisc/include/asm/dma.h b/arch/parisc/include/asm/dma.h
index 31ad0f05af3d..f7a18f968703 100644
--- a/arch/parisc/include/asm/dma.h
+++ b/arch/parisc/include/asm/dma.h
@@ -1,5 +1,4 @@
1/* $Id: dma.h,v 1.2 1999/04/27 00:46:18 deller Exp $ 1/* asm/dma.h: Defines for using and allocating dma channels.
2 * linux/include/asm/dma.h: Defines for using and allocating dma channels.
3 * Written by Hennus Bergman, 1992. 2 * Written by Hennus Bergman, 1992.
4 * High DMA channel support & info by Hannu Savolainen 3 * High DMA channel support & info by Hannu Savolainen
5 * and John Boyd, Nov. 1992. 4 * and John Boyd, Nov. 1992.
diff --git a/arch/parisc/include/asm/perf_counter.h b/arch/parisc/include/asm/perf_counter.h
new file mode 100644
index 000000000000..dc9e829f7013
--- /dev/null
+++ b/arch/parisc/include/asm/perf_counter.h
@@ -0,0 +1,7 @@
1#ifndef __ASM_PARISC_PERF_COUNTER_H
2#define __ASM_PARISC_PERF_COUNTER_H
3
4/* parisc only supports software counters through this interface. */
5static inline void set_perf_counter_pending(void) { }
6
7#endif /* __ASM_PARISC_PERF_COUNTER_H */
diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
index 9d64df8754ba..9ce66e9d1c2b 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -18,6 +18,7 @@
18#include <asm/types.h> 18#include <asm/types.h>
19#include <asm/system.h> 19#include <asm/system.h>
20#include <asm/percpu.h> 20#include <asm/percpu.h>
21
21#endif /* __ASSEMBLY__ */ 22#endif /* __ASSEMBLY__ */
22 23
23#define KERNEL_STACK_SIZE (4*PAGE_SIZE) 24#define KERNEL_STACK_SIZE (4*PAGE_SIZE)
@@ -127,6 +128,8 @@ struct thread_struct {
127 unsigned long flags; 128 unsigned long flags;
128}; 129};
129 130
131#define task_pt_regs(tsk) ((struct pt_regs *)&((tsk)->thread.regs))
132
130/* Thread struct flags. */ 133/* Thread struct flags. */
131#define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */ 134#define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
132#define PARISC_UAC_SIGBUS (1UL << 1) 135#define PARISC_UAC_SIGBUS (1UL << 1)
diff --git a/arch/parisc/include/asm/system.h b/arch/parisc/include/asm/system.h
index ee80c920b464..d91357bca5b4 100644
--- a/arch/parisc/include/asm/system.h
+++ b/arch/parisc/include/asm/system.h
@@ -168,8 +168,8 @@ static inline void set_eiem(unsigned long val)
168/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */ 168/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
169#define __ldcw(a) ({ \ 169#define __ldcw(a) ({ \
170 unsigned __ret; \ 170 unsigned __ret; \
171 __asm__ __volatile__(__LDCW " 0(%1),%0" \ 171 __asm__ __volatile__(__LDCW " 0(%2),%0" \
172 : "=r" (__ret) : "r" (a)); \ 172 : "=r" (__ret), "+m" (*(a)) : "r" (a)); \
173 __ret; \ 173 __ret; \
174}) 174})
175 175
diff --git a/arch/parisc/include/asm/thread_info.h b/arch/parisc/include/asm/thread_info.h
index 0407959da489..4ce0edfbe969 100644
--- a/arch/parisc/include/asm/thread_info.h
+++ b/arch/parisc/include/asm/thread_info.h
@@ -23,7 +23,7 @@ struct thread_info {
23 .flags = 0, \ 23 .flags = 0, \
24 .cpu = 0, \ 24 .cpu = 0, \
25 .addr_limit = KERNEL_DS, \ 25 .addr_limit = KERNEL_DS, \
26 .preempt_count = 1, \ 26 .preempt_count = INIT_PREEMPT_COUNT, \
27 .restart_block = { \ 27 .restart_block = { \
28 .fn = do_no_restart_syscall \ 28 .fn = do_no_restart_syscall \
29 } \ 29 } \
diff --git a/arch/parisc/include/asm/tlbflush.h b/arch/parisc/include/asm/tlbflush.h
index 1f6fd4fc05b9..8f1a8100bf2d 100644
--- a/arch/parisc/include/asm/tlbflush.h
+++ b/arch/parisc/include/asm/tlbflush.h
@@ -12,14 +12,12 @@
12 * N class systems, only one PxTLB inter processor broadcast can be 12 * N class systems, only one PxTLB inter processor broadcast can be
13 * active at any one time on the Merced bus. This tlb purge 13 * active at any one time on the Merced bus. This tlb purge
14 * synchronisation is fairly lightweight and harmless so we activate 14 * synchronisation is fairly lightweight and harmless so we activate
15 * it on all SMP systems not just the N class. We also need to have 15 * it on all systems not just the N class.
16 * preemption disabled on uniprocessor machines, and spin_lock does that
17 * nicely.
18 */ 16 */
19extern spinlock_t pa_tlb_lock; 17extern spinlock_t pa_tlb_lock;
20 18
21#define purge_tlb_start(x) spin_lock(&pa_tlb_lock) 19#define purge_tlb_start(flags) spin_lock_irqsave(&pa_tlb_lock, flags)
22#define purge_tlb_end(x) spin_unlock(&pa_tlb_lock) 20#define purge_tlb_end(flags) spin_unlock_irqrestore(&pa_tlb_lock, flags)
23 21
24extern void flush_tlb_all(void); 22extern void flush_tlb_all(void);
25extern void flush_tlb_all_local(void *); 23extern void flush_tlb_all_local(void *);
@@ -63,14 +61,16 @@ static inline void flush_tlb_mm(struct mm_struct *mm)
63static inline void flush_tlb_page(struct vm_area_struct *vma, 61static inline void flush_tlb_page(struct vm_area_struct *vma,
64 unsigned long addr) 62 unsigned long addr)
65{ 63{
64 unsigned long flags;
65
66 /* For one page, it's not worth testing the split_tlb variable */ 66 /* For one page, it's not worth testing the split_tlb variable */
67 67
68 mb(); 68 mb();
69 mtsp(vma->vm_mm->context,1); 69 mtsp(vma->vm_mm->context,1);
70 purge_tlb_start(); 70 purge_tlb_start(flags);
71 pdtlb(addr); 71 pdtlb(addr);
72 pitlb(addr); 72 pitlb(addr);
73 purge_tlb_end(); 73 purge_tlb_end(flags);
74} 74}
75 75
76void __flush_tlb_range(unsigned long sid, 76void __flush_tlb_range(unsigned long sid,
diff --git a/arch/parisc/include/asm/unistd.h b/arch/parisc/include/asm/unistd.h
index ef26b009dc5d..f3d3b8b012c4 100644
--- a/arch/parisc/include/asm/unistd.h
+++ b/arch/parisc/include/asm/unistd.h
@@ -807,8 +807,12 @@
807#define __NR_dup3 (__NR_Linux + 312) 807#define __NR_dup3 (__NR_Linux + 312)
808#define __NR_pipe2 (__NR_Linux + 313) 808#define __NR_pipe2 (__NR_Linux + 313)
809#define __NR_inotify_init1 (__NR_Linux + 314) 809#define __NR_inotify_init1 (__NR_Linux + 314)
810#define __NR_preadv (__NR_Linux + 315)
811#define __NR_pwritev (__NR_Linux + 316)
812#define __NR_rt_tgsigqueueinfo (__NR_Linux + 317)
813#define __NR_perf_counter_open (__NR_Linux + 318)
810 814
811#define __NR_Linux_syscalls (__NR_inotify_init1 + 1) 815#define __NR_Linux_syscalls (__NR_perf_counter_open + 1)
812 816
813 817
814#define __IGNORE_select /* newselect */ 818#define __IGNORE_select /* newselect */
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index 837530ea32e7..b6ed34de14e1 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -1,5 +1,4 @@
1/* $Id: cache.c,v 1.4 2000/01/25 00:11:38 prumpf Exp $ 1/*
2 *
3 * This file is subject to the terms and conditions of the GNU General Public 2 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
5 * for more details. 4 * for more details.
@@ -398,12 +397,13 @@ EXPORT_SYMBOL(flush_kernel_icache_range_asm);
398 397
399void clear_user_page_asm(void *page, unsigned long vaddr) 398void clear_user_page_asm(void *page, unsigned long vaddr)
400{ 399{
400 unsigned long flags;
401 /* This function is implemented in assembly in pacache.S */ 401 /* This function is implemented in assembly in pacache.S */
402 extern void __clear_user_page_asm(void *page, unsigned long vaddr); 402 extern void __clear_user_page_asm(void *page, unsigned long vaddr);
403 403
404 purge_tlb_start(); 404 purge_tlb_start(flags);
405 __clear_user_page_asm(page, vaddr); 405 __clear_user_page_asm(page, vaddr);
406 purge_tlb_end(); 406 purge_tlb_end(flags);
407} 407}
408 408
409#define FLUSH_THRESHOLD 0x80000 /* 0.5MB */ 409#define FLUSH_THRESHOLD 0x80000 /* 0.5MB */
@@ -444,20 +444,24 @@ extern void clear_user_page_asm(void *page, unsigned long vaddr);
444 444
445void clear_user_page(void *page, unsigned long vaddr, struct page *pg) 445void clear_user_page(void *page, unsigned long vaddr, struct page *pg)
446{ 446{
447 unsigned long flags;
448
447 purge_kernel_dcache_page((unsigned long)page); 449 purge_kernel_dcache_page((unsigned long)page);
448 purge_tlb_start(); 450 purge_tlb_start(flags);
449 pdtlb_kernel(page); 451 pdtlb_kernel(page);
450 purge_tlb_end(); 452 purge_tlb_end(flags);
451 clear_user_page_asm(page, vaddr); 453 clear_user_page_asm(page, vaddr);
452} 454}
453EXPORT_SYMBOL(clear_user_page); 455EXPORT_SYMBOL(clear_user_page);
454 456
455void flush_kernel_dcache_page_addr(void *addr) 457void flush_kernel_dcache_page_addr(void *addr)
456{ 458{
459 unsigned long flags;
460
457 flush_kernel_dcache_page_asm(addr); 461 flush_kernel_dcache_page_asm(addr);
458 purge_tlb_start(); 462 purge_tlb_start(flags);
459 pdtlb_kernel(addr); 463 pdtlb_kernel(addr);
460 purge_tlb_end(); 464 purge_tlb_end(flags);
461} 465}
462EXPORT_SYMBOL(flush_kernel_dcache_page_addr); 466EXPORT_SYMBOL(flush_kernel_dcache_page_addr);
463 467
@@ -490,8 +494,10 @@ void __flush_tlb_range(unsigned long sid, unsigned long start,
490 if (npages >= 512) /* 2MB of space: arbitrary, should be tuned */ 494 if (npages >= 512) /* 2MB of space: arbitrary, should be tuned */
491 flush_tlb_all(); 495 flush_tlb_all();
492 else { 496 else {
497 unsigned long flags;
498
493 mtsp(sid, 1); 499 mtsp(sid, 1);
494 purge_tlb_start(); 500 purge_tlb_start(flags);
495 if (split_tlb) { 501 if (split_tlb) {
496 while (npages--) { 502 while (npages--) {
497 pdtlb(start); 503 pdtlb(start);
@@ -504,7 +510,7 @@ void __flush_tlb_range(unsigned long sid, unsigned long start,
504 start += PAGE_SIZE; 510 start += PAGE_SIZE;
505 } 511 }
506 } 512 }
507 purge_tlb_end(); 513 purge_tlb_end(flags);
508 } 514 }
509} 515}
510 516
diff --git a/arch/parisc/kernel/inventory.c b/arch/parisc/kernel/inventory.c
index bd1f7f1ff74e..d228d8237879 100644
--- a/arch/parisc/kernel/inventory.c
+++ b/arch/parisc/kernel/inventory.c
@@ -170,23 +170,27 @@ static void __init pagezero_memconfig(void)
170static int __init 170static int __init
171pat_query_module(ulong pcell_loc, ulong mod_index) 171pat_query_module(ulong pcell_loc, ulong mod_index)
172{ 172{
173 pdc_pat_cell_mod_maddr_block_t pa_pdc_cell; 173 pdc_pat_cell_mod_maddr_block_t *pa_pdc_cell;
174 unsigned long bytecnt; 174 unsigned long bytecnt;
175 unsigned long temp; /* 64-bit scratch value */ 175 unsigned long temp; /* 64-bit scratch value */
176 long status; /* PDC return value status */ 176 long status; /* PDC return value status */
177 struct parisc_device *dev; 177 struct parisc_device *dev;
178 178
179 pa_pdc_cell = kmalloc(sizeof (*pa_pdc_cell), GFP_KERNEL);
180 if (!pa_pdc_cell)
181 panic("couldn't allocate memory for PDC_PAT_CELL!");
182
179 /* return cell module (PA or Processor view) */ 183 /* return cell module (PA or Processor view) */
180 status = pdc_pat_cell_module(&bytecnt, pcell_loc, mod_index, 184 status = pdc_pat_cell_module(&bytecnt, pcell_loc, mod_index,
181 PA_VIEW, &pa_pdc_cell); 185 PA_VIEW, pa_pdc_cell);
182 186
183 if (status != PDC_OK) { 187 if (status != PDC_OK) {
184 /* no more cell modules or error */ 188 /* no more cell modules or error */
185 return status; 189 return status;
186 } 190 }
187 191
188 temp = pa_pdc_cell.cba; 192 temp = pa_pdc_cell->cba;
189 dev = alloc_pa_dev(PAT_GET_CBA(temp), &pa_pdc_cell.mod_path); 193 dev = alloc_pa_dev(PAT_GET_CBA(temp), &(pa_pdc_cell->mod_path));
190 if (!dev) { 194 if (!dev) {
191 return PDC_OK; 195 return PDC_OK;
192 } 196 }
@@ -203,8 +207,8 @@ pat_query_module(ulong pcell_loc, ulong mod_index)
203 207
204 /* save generic info returned from the call */ 208 /* save generic info returned from the call */
205 /* REVISIT: who is the consumer of this? not sure yet... */ 209 /* REVISIT: who is the consumer of this? not sure yet... */
206 dev->mod_info = pa_pdc_cell.mod_info; /* pass to PAT_GET_ENTITY() */ 210 dev->mod_info = pa_pdc_cell->mod_info; /* pass to PAT_GET_ENTITY() */
207 dev->pmod_loc = pa_pdc_cell.mod_location; 211 dev->pmod_loc = pa_pdc_cell->mod_location;
208 212
209 register_parisc_device(dev); /* advertise device */ 213 register_parisc_device(dev); /* advertise device */
210 214
@@ -216,14 +220,14 @@ pat_query_module(ulong pcell_loc, ulong mod_index)
216 220
217 case PAT_ENTITY_PROC: 221 case PAT_ENTITY_PROC:
218 printk(KERN_DEBUG "PAT_ENTITY_PROC: id_eid 0x%lx\n", 222 printk(KERN_DEBUG "PAT_ENTITY_PROC: id_eid 0x%lx\n",
219 pa_pdc_cell.mod[0]); 223 pa_pdc_cell->mod[0]);
220 break; 224 break;
221 225
222 case PAT_ENTITY_MEM: 226 case PAT_ENTITY_MEM:
223 printk(KERN_DEBUG 227 printk(KERN_DEBUG
224 "PAT_ENTITY_MEM: amount 0x%lx min_gni_base 0x%lx min_gni_len 0x%lx\n", 228 "PAT_ENTITY_MEM: amount 0x%lx min_gni_base 0x%lx min_gni_len 0x%lx\n",
225 pa_pdc_cell.mod[0], pa_pdc_cell.mod[1], 229 pa_pdc_cell->mod[0], pa_pdc_cell->mod[1],
226 pa_pdc_cell.mod[2]); 230 pa_pdc_cell->mod[2]);
227 break; 231 break;
228 case PAT_ENTITY_CA: 232 case PAT_ENTITY_CA:
229 printk(KERN_DEBUG "PAT_ENTITY_CA: %ld\n", pcell_loc); 233 printk(KERN_DEBUG "PAT_ENTITY_CA: %ld\n", pcell_loc);
@@ -243,23 +247,26 @@ pat_query_module(ulong pcell_loc, ulong mod_index)
243 print_ranges: 247 print_ranges:
244 pdc_pat_cell_module(&bytecnt, pcell_loc, mod_index, 248 pdc_pat_cell_module(&bytecnt, pcell_loc, mod_index,
245 IO_VIEW, &io_pdc_cell); 249 IO_VIEW, &io_pdc_cell);
246 printk(KERN_DEBUG "ranges %ld\n", pa_pdc_cell.mod[1]); 250 printk(KERN_DEBUG "ranges %ld\n", pa_pdc_cell->mod[1]);
247 for (i = 0; i < pa_pdc_cell.mod[1]; i++) { 251 for (i = 0; i < pa_pdc_cell->mod[1]; i++) {
248 printk(KERN_DEBUG 252 printk(KERN_DEBUG
249 " PA_VIEW %ld: 0x%016lx 0x%016lx 0x%016lx\n", 253 " PA_VIEW %ld: 0x%016lx 0x%016lx 0x%016lx\n",
250 i, pa_pdc_cell.mod[2 + i * 3], /* type */ 254 i, pa_pdc_cell->mod[2 + i * 3], /* type */
251 pa_pdc_cell.mod[3 + i * 3], /* start */ 255 pa_pdc_cell->mod[3 + i * 3], /* start */
252 pa_pdc_cell.mod[4 + i * 3]); /* finish (ie end) */ 256 pa_pdc_cell->mod[4 + i * 3]); /* finish (ie end) */
253 printk(KERN_DEBUG 257 printk(KERN_DEBUG
254 " IO_VIEW %ld: 0x%016lx 0x%016lx 0x%016lx\n", 258 " IO_VIEW %ld: 0x%016lx 0x%016lx 0x%016lx\n",
255 i, io_pdc_cell.mod[2 + i * 3], /* type */ 259 i, io_pdc_cell->mod[2 + i * 3], /* type */
256 io_pdc_cell.mod[3 + i * 3], /* start */ 260 io_pdc_cell->mod[3 + i * 3], /* start */
257 io_pdc_cell.mod[4 + i * 3]); /* finish (ie end) */ 261 io_pdc_cell->mod[4 + i * 3]); /* finish (ie end) */
258 } 262 }
259 printk(KERN_DEBUG "\n"); 263 printk(KERN_DEBUG "\n");
260 break; 264 break;
261 } 265 }
262#endif /* DEBUG_PAT */ 266#endif /* DEBUG_PAT */
267
268 kfree(pa_pdc_cell);
269
263 return PDC_OK; 270 return PDC_OK;
264} 271}
265 272
diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c
index 8007f1e65729..330f536a9324 100644
--- a/arch/parisc/kernel/irq.c
+++ b/arch/parisc/kernel/irq.c
@@ -120,7 +120,7 @@ int cpu_check_affinity(unsigned int irq, const struct cpumask *dest)
120 if (CHECK_IRQ_PER_CPU(irq)) { 120 if (CHECK_IRQ_PER_CPU(irq)) {
121 /* Bad linux design decision. The mask has already 121 /* Bad linux design decision. The mask has already
122 * been set; we must reset it */ 122 * been set; we must reset it */
123 cpumask_setall(&irq_desc[irq].affinity); 123 cpumask_setall(irq_desc[irq].affinity);
124 return -EINVAL; 124 return -EINVAL;
125 } 125 }
126 126
@@ -138,13 +138,13 @@ static int cpu_set_affinity_irq(unsigned int irq, const struct cpumask *dest)
138 if (cpu_dest < 0) 138 if (cpu_dest < 0)
139 return -1; 139 return -1;
140 140
141 cpumask_copy(&irq_desc[irq].affinity, dest); 141 cpumask_copy(irq_desc[irq].affinity, dest);
142 142
143 return 0; 143 return 0;
144} 144}
145#endif 145#endif
146 146
147static struct hw_interrupt_type cpu_interrupt_type = { 147static struct irq_chip cpu_interrupt_type = {
148 .typename = "CPU", 148 .typename = "CPU",
149 .startup = cpu_startup_irq, 149 .startup = cpu_startup_irq,
150 .shutdown = cpu_disable_irq, 150 .shutdown = cpu_disable_irq,
@@ -299,7 +299,7 @@ int txn_alloc_irq(unsigned int bits_wide)
299unsigned long txn_affinity_addr(unsigned int irq, int cpu) 299unsigned long txn_affinity_addr(unsigned int irq, int cpu)
300{ 300{
301#ifdef CONFIG_SMP 301#ifdef CONFIG_SMP
302 cpumask_copy(&irq_desc[irq].affinity, cpumask_of(cpu)); 302 cpumask_copy(irq_desc[irq].affinity, cpumask_of(cpu));
303#endif 303#endif
304 304
305 return per_cpu(cpu_data, cpu).txn_addr; 305 return per_cpu(cpu_data, cpu).txn_addr;
@@ -356,7 +356,7 @@ void do_cpu_irq_mask(struct pt_regs *regs)
356 irq = eirr_to_irq(eirr_val); 356 irq = eirr_to_irq(eirr_val);
357 357
358#ifdef CONFIG_SMP 358#ifdef CONFIG_SMP
359 cpumask_copy(&dest, &irq_desc[irq].affinity); 359 cpumask_copy(&dest, irq_desc[irq].affinity);
360 if (CHECK_IRQ_PER_CPU(irq_desc[irq].status) && 360 if (CHECK_IRQ_PER_CPU(irq_desc[irq].status) &&
361 !cpu_isset(smp_processor_id(), dest)) { 361 !cpu_isset(smp_processor_id(), dest)) {
362 int cpu = first_cpu(dest); 362 int cpu = first_cpu(dest);
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index 7d927eac932b..c07f618ff7da 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -90,12 +90,14 @@ static inline int map_pte_uncached(pte_t * pte,
90 if (end > PMD_SIZE) 90 if (end > PMD_SIZE)
91 end = PMD_SIZE; 91 end = PMD_SIZE;
92 do { 92 do {
93 unsigned long flags;
94
93 if (!pte_none(*pte)) 95 if (!pte_none(*pte))
94 printk(KERN_ERR "map_pte_uncached: page already exists\n"); 96 printk(KERN_ERR "map_pte_uncached: page already exists\n");
95 set_pte(pte, __mk_pte(*paddr_ptr, PAGE_KERNEL_UNC)); 97 set_pte(pte, __mk_pte(*paddr_ptr, PAGE_KERNEL_UNC));
96 purge_tlb_start(); 98 purge_tlb_start(flags);
97 pdtlb_kernel(orig_vaddr); 99 pdtlb_kernel(orig_vaddr);
98 purge_tlb_end(); 100 purge_tlb_end(flags);
99 vaddr += PAGE_SIZE; 101 vaddr += PAGE_SIZE;
100 orig_vaddr += PAGE_SIZE; 102 orig_vaddr += PAGE_SIZE;
101 (*paddr_ptr) += PAGE_SIZE; 103 (*paddr_ptr) += PAGE_SIZE;
@@ -168,11 +170,13 @@ static inline void unmap_uncached_pte(pmd_t * pmd, unsigned long vaddr,
168 if (end > PMD_SIZE) 170 if (end > PMD_SIZE)
169 end = PMD_SIZE; 171 end = PMD_SIZE;
170 do { 172 do {
173 unsigned long flags;
171 pte_t page = *pte; 174 pte_t page = *pte;
175
172 pte_clear(&init_mm, vaddr, pte); 176 pte_clear(&init_mm, vaddr, pte);
173 purge_tlb_start(); 177 purge_tlb_start(flags);
174 pdtlb_kernel(orig_vaddr); 178 pdtlb_kernel(orig_vaddr);
175 purge_tlb_end(); 179 purge_tlb_end(flags);
176 vaddr += PAGE_SIZE; 180 vaddr += PAGE_SIZE;
177 orig_vaddr += PAGE_SIZE; 181 orig_vaddr += PAGE_SIZE;
178 pte++; 182 pte++;
diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c
index 6936386c9861..f7064abc3bb6 100644
--- a/arch/parisc/kernel/pci.c
+++ b/arch/parisc/kernel/pci.c
@@ -1,5 +1,4 @@
1/* $Id: pci.c,v 1.6 2000/01/29 00:12:05 grundler Exp $ 1/*
2 *
3 * This file is subject to the terms and conditions of the GNU General Public 2 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
5 * for more details. 4 * for more details.
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index 61c07078c072..1f3aa8db0203 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -156,7 +156,7 @@ void machine_power_off(void)
156 * software. The user has to press the button himself. */ 156 * software. The user has to press the button himself. */
157 157
158 printk(KERN_EMERG "System shut down completed.\n" 158 printk(KERN_EMERG "System shut down completed.\n"
159 KERN_EMERG "Please power this system off now."); 159 "Please power this system off now.");
160} 160}
161 161
162void (*pm_power_off)(void) = machine_power_off; 162void (*pm_power_off)(void) = machine_power_off;
diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c
index e09d0f7fb6b0..c8fb61ed32f4 100644
--- a/arch/parisc/kernel/processor.c
+++ b/arch/parisc/kernel/processor.c
@@ -1,5 +1,4 @@
1/* $Id: processor.c,v 1.1 2002/07/20 16:27:06 rhirst Exp $ 1/*
2 *
3 * Initial setup-routines for HP 9000 based hardware. 2 * Initial setup-routines for HP 9000 based hardware.
4 * 3 *
5 * Copyright (C) 1991, 1992, 1995 Linus Torvalds 4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
@@ -121,22 +120,28 @@ static int __cpuinit processor_probe(struct parisc_device *dev)
121 if (is_pdc_pat()) { 120 if (is_pdc_pat()) {
122 ulong status; 121 ulong status;
123 unsigned long bytecnt; 122 unsigned long bytecnt;
124 pdc_pat_cell_mod_maddr_block_t pa_pdc_cell; 123 pdc_pat_cell_mod_maddr_block_t *pa_pdc_cell;
125#undef USE_PAT_CPUID 124#undef USE_PAT_CPUID
126#ifdef USE_PAT_CPUID 125#ifdef USE_PAT_CPUID
127 struct pdc_pat_cpu_num cpu_info; 126 struct pdc_pat_cpu_num cpu_info;
128#endif 127#endif
129 128
129 pa_pdc_cell = kmalloc(sizeof (*pa_pdc_cell), GFP_KERNEL);
130 if (!pa_pdc_cell)
131 panic("couldn't allocate memory for PDC_PAT_CELL!");
132
130 status = pdc_pat_cell_module(&bytecnt, dev->pcell_loc, 133 status = pdc_pat_cell_module(&bytecnt, dev->pcell_loc,
131 dev->mod_index, PA_VIEW, &pa_pdc_cell); 134 dev->mod_index, PA_VIEW, pa_pdc_cell);
132 135
133 BUG_ON(PDC_OK != status); 136 BUG_ON(PDC_OK != status);
134 137
135 /* verify it's the same as what do_pat_inventory() found */ 138 /* verify it's the same as what do_pat_inventory() found */
136 BUG_ON(dev->mod_info != pa_pdc_cell.mod_info); 139 BUG_ON(dev->mod_info != pa_pdc_cell->mod_info);
137 BUG_ON(dev->pmod_loc != pa_pdc_cell.mod_location); 140 BUG_ON(dev->pmod_loc != pa_pdc_cell->mod_location);
141
142 txn_addr = pa_pdc_cell->mod[0]; /* id_eid for IO sapic */
138 143
139 txn_addr = pa_pdc_cell.mod[0]; /* id_eid for IO sapic */ 144 kfree(pa_pdc_cell);
140 145
141#ifdef USE_PAT_CPUID 146#ifdef USE_PAT_CPUID
142/* We need contiguous numbers for cpuid. Firmware's notion 147/* We need contiguous numbers for cpuid. Firmware's notion
diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index 82131ca8e05c..cb71f3dac995 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -1,5 +1,4 @@
1/* $Id: setup.c,v 1.8 2000/02/02 04:42:38 prumpf Exp $ 1/*
2 *
3 * Initial setup-routines for HP 9000 based hardware. 2 * Initial setup-routines for HP 9000 based hardware.
4 * 3 *
5 * Copyright (C) 1991, 1992, 1995 Linus Torvalds 4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
index 1adb40c81669..92a0acaa0d12 100644
--- a/arch/parisc/kernel/sys_parisc32.c
+++ b/arch/parisc/kernel/sys_parisc32.c
@@ -174,68 +174,6 @@ asmlinkage long sys32_sched_rr_get_interval(pid_t pid,
174 return ret; 174 return ret;
175} 175}
176 176
177/*** copied from mips64 ***/
178/*
179 * Ooo, nasty. We need here to frob 32-bit unsigned longs to
180 * 64-bit unsigned longs.
181 */
182
183static inline int
184get_fd_set32(unsigned long n, u32 *ufdset, unsigned long *fdset)
185{
186 n = (n + 8*sizeof(u32) - 1) / (8*sizeof(u32));
187 if (ufdset) {
188 unsigned long odd;
189
190 if (!access_ok(VERIFY_WRITE, ufdset, n*sizeof(u32)))
191 return -EFAULT;
192
193 odd = n & 1UL;
194 n &= ~1UL;
195 while (n) {
196 unsigned long h, l;
197 __get_user(l, ufdset);
198 __get_user(h, ufdset+1);
199 ufdset += 2;
200 *fdset++ = h << 32 | l;
201 n -= 2;
202 }
203 if (odd)
204 __get_user(*fdset, ufdset);
205 } else {
206 /* Tricky, must clear full unsigned long in the
207 * kernel fdset at the end, this makes sure that
208 * actually happens.
209 */
210 memset(fdset, 0, ((n + 1) & ~1)*sizeof(u32));
211 }
212 return 0;
213}
214
215static inline void
216set_fd_set32(unsigned long n, u32 *ufdset, unsigned long *fdset)
217{
218 unsigned long odd;
219 n = (n + 8*sizeof(u32) - 1) / (8*sizeof(u32));
220
221 if (!ufdset)
222 return;
223
224 odd = n & 1UL;
225 n &= ~1UL;
226 while (n) {
227 unsigned long h, l;
228 l = *fdset++;
229 h = l >> 32;
230 __put_user(l, ufdset);
231 __put_user(h, ufdset+1);
232 ufdset += 2;
233 n -= 2;
234 }
235 if (odd)
236 __put_user(*fdset, ufdset);
237}
238
239struct msgbuf32 { 177struct msgbuf32 {
240 int mtype; 178 int mtype;
241 char mtext[1]; 179 char mtext[1];
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 03b9a01bc16c..cf145eb026b3 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -413,6 +413,10 @@
413 ENTRY_SAME(dup3) 413 ENTRY_SAME(dup3)
414 ENTRY_SAME(pipe2) 414 ENTRY_SAME(pipe2)
415 ENTRY_SAME(inotify_init1) 415 ENTRY_SAME(inotify_init1)
416 ENTRY_COMP(preadv) /* 315 */
417 ENTRY_COMP(pwritev)
418 ENTRY_COMP(rt_tgsigqueueinfo)
419 ENTRY_SAME(perf_counter_open)
416 420
417 /* Nothing yet */ 421 /* Nothing yet */
418 422
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index d4dd05674c62..a79c6f9e7e2c 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -56,9 +56,9 @@ static unsigned long clocktick __read_mostly; /* timer cycles per tick */
56 */ 56 */
57irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id) 57irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
58{ 58{
59 unsigned long now; 59 unsigned long now, now2;
60 unsigned long next_tick; 60 unsigned long next_tick;
61 unsigned long cycles_elapsed, ticks_elapsed; 61 unsigned long cycles_elapsed, ticks_elapsed = 1;
62 unsigned long cycles_remainder; 62 unsigned long cycles_remainder;
63 unsigned int cpu = smp_processor_id(); 63 unsigned int cpu = smp_processor_id();
64 struct cpuinfo_parisc *cpuinfo = &per_cpu(cpu_data, cpu); 64 struct cpuinfo_parisc *cpuinfo = &per_cpu(cpu_data, cpu);
@@ -71,44 +71,24 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
71 /* Initialize next_tick to the expected tick time. */ 71 /* Initialize next_tick to the expected tick time. */
72 next_tick = cpuinfo->it_value; 72 next_tick = cpuinfo->it_value;
73 73
74 /* Get current interval timer. 74 /* Get current cycle counter (Control Register 16). */
75 * CR16 reads as 64 bits in CPU wide mode.
76 * CR16 reads as 32 bits in CPU narrow mode.
77 */
78 now = mfctl(16); 75 now = mfctl(16);
79 76
80 cycles_elapsed = now - next_tick; 77 cycles_elapsed = now - next_tick;
81 78
82 if ((cycles_elapsed >> 5) < cpt) { 79 if ((cycles_elapsed >> 6) < cpt) {
83 /* use "cheap" math (add/subtract) instead 80 /* use "cheap" math (add/subtract) instead
84 * of the more expensive div/mul method 81 * of the more expensive div/mul method
85 */ 82 */
86 cycles_remainder = cycles_elapsed; 83 cycles_remainder = cycles_elapsed;
87 ticks_elapsed = 1;
88 while (cycles_remainder > cpt) { 84 while (cycles_remainder > cpt) {
89 cycles_remainder -= cpt; 85 cycles_remainder -= cpt;
90 ticks_elapsed++; 86 ticks_elapsed++;
91 } 87 }
92 } else { 88 } else {
89 /* TODO: Reduce this to one fdiv op */
93 cycles_remainder = cycles_elapsed % cpt; 90 cycles_remainder = cycles_elapsed % cpt;
94 ticks_elapsed = 1 + cycles_elapsed / cpt; 91 ticks_elapsed += cycles_elapsed / cpt;
95 }
96
97 /* Can we differentiate between "early CR16" (aka Scenario 1) and
98 * "long delay" (aka Scenario 3)? I don't think so.
99 *
100 * We expected timer_interrupt to be delivered at least a few hundred
101 * cycles after the IT fires. But it's arbitrary how much time passes
102 * before we call it "late". I've picked one second.
103 */
104 if (unlikely(ticks_elapsed > HZ)) {
105 /* Scenario 3: very long delay? bad in any case */
106 printk (KERN_CRIT "timer_interrupt(CPU %d): delayed!"
107 " cycles %lX rem %lX "
108 " next/now %lX/%lX\n",
109 cpu,
110 cycles_elapsed, cycles_remainder,
111 next_tick, now );
112 } 92 }
113 93
114 /* convert from "division remainder" to "remainder of clock tick" */ 94 /* convert from "division remainder" to "remainder of clock tick" */
@@ -122,18 +102,56 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
122 102
123 cpuinfo->it_value = next_tick; 103 cpuinfo->it_value = next_tick;
124 104
125 /* Skip one clocktick on purpose if we are likely to miss next_tick. 105 /* Program the IT when to deliver the next interrupt.
126 * We want to avoid the new next_tick being less than CR16. 106 * Only bottom 32-bits of next_tick are writable in CR16!
127 * If that happened, itimer wouldn't fire until CR16 wrapped.
128 * We'll catch the tick we missed on the tick after that.
129 */ 107 */
130 if (!(cycles_remainder >> 13))
131 next_tick += cpt;
132
133 /* Program the IT when to deliver the next interrupt. */
134 /* Only bottom 32-bits of next_tick are written to cr16. */
135 mtctl(next_tick, 16); 108 mtctl(next_tick, 16);
136 109
110 /* Skip one clocktick on purpose if we missed next_tick.
111 * The new CR16 must be "later" than current CR16 otherwise
112 * itimer would not fire until CR16 wrapped - e.g 4 seconds
113 * later on a 1Ghz processor. We'll account for the missed
114 * tick on the next timer interrupt.
115 *
116 * "next_tick - now" will always give the difference regardless
117 * if one or the other wrapped. If "now" is "bigger" we'll end up
118 * with a very large unsigned number.
119 */
120 now2 = mfctl(16);
121 if (next_tick - now2 > cpt)
122 mtctl(next_tick+cpt, 16);
123
124#if 1
125/*
126 * GGG: DEBUG code for how many cycles programming CR16 used.
127 */
128 if (unlikely(now2 - now > 0x3000)) /* 12K cycles */
129 printk (KERN_CRIT "timer_interrupt(CPU %d): SLOW! 0x%lx cycles!"
130 " cyc %lX rem %lX "
131 " next/now %lX/%lX\n",
132 cpu, now2 - now, cycles_elapsed, cycles_remainder,
133 next_tick, now );
134#endif
135
136 /* Can we differentiate between "early CR16" (aka Scenario 1) and
137 * "long delay" (aka Scenario 3)? I don't think so.
138 *
139 * Timer_interrupt will be delivered at least a few hundred cycles
140 * after the IT fires. But it's arbitrary how much time passes
141 * before we call it "late". I've picked one second.
142 *
143 * It's important NO printk's are between reading CR16 and
144 * setting up the next value. May introduce huge variance.
145 */
146 if (unlikely(ticks_elapsed > HZ)) {
147 /* Scenario 3: very long delay? bad in any case */
148 printk (KERN_CRIT "timer_interrupt(CPU %d): delayed!"
149 " cycles %lX rem %lX "
150 " next/now %lX/%lX\n",
151 cpu,
152 cycles_elapsed, cycles_remainder,
153 next_tick, now );
154 }
137 155
138 /* Done mucking with unreliable delivery of interrupts. 156 /* Done mucking with unreliable delivery of interrupts.
139 * Go do system house keeping. 157 * Go do system house keeping.
@@ -173,7 +191,7 @@ EXPORT_SYMBOL(profile_pc);
173 191
174/* clock source code */ 192/* clock source code */
175 193
176static cycle_t read_cr16(void) 194static cycle_t read_cr16(struct clocksource *cs)
177{ 195{
178 return get_cycles(); 196 return get_cycles();
179} 197}
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index c32f5d6d778e..528f0ff9b273 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -250,15 +250,14 @@ void die_if_kernel(char *str, struct pt_regs *regs, long err)
250 oops_enter(); 250 oops_enter();
251 251
252 /* Amuse the user in a SPARC fashion */ 252 /* Amuse the user in a SPARC fashion */
253 if (err) printk( 253 if (err) printk(KERN_CRIT
254KERN_CRIT " _______________________________ \n" 254 " _______________________________ \n"
255KERN_CRIT " < Your System ate a SPARC! Gah! >\n" 255 " < Your System ate a SPARC! Gah! >\n"
256KERN_CRIT " ------------------------------- \n" 256 " ------------------------------- \n"
257KERN_CRIT " \\ ^__^\n" 257 " \\ ^__^\n"
258KERN_CRIT " \\ (xx)\\_______\n" 258 " (__)\\ )\\/\\\n"
259KERN_CRIT " (__)\\ )\\/\\\n" 259 " U ||----w |\n"
260KERN_CRIT " U ||----w |\n" 260 " || ||\n");
261KERN_CRIT " || ||\n");
262 261
263 /* unlock the pdc lock if necessary */ 262 /* unlock the pdc lock if necessary */
264 pdc_emergency_unlock(); 263 pdc_emergency_unlock();
@@ -797,7 +796,8 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
797 else 796 else
798 printk(KERN_DEBUG "User Fault (long pointer) (fault %d) ", 797 printk(KERN_DEBUG "User Fault (long pointer) (fault %d) ",
799 code); 798 code);
800 printk("pid=%d command='%s'\n", task_pid_nr(current), current->comm); 799 printk(KERN_CONT "pid=%d command='%s'\n",
800 task_pid_nr(current), current->comm);
801 show_regs(regs); 801 show_regs(regs);
802#endif 802#endif
803 si.si_signo = SIGSEGV; 803 si.si_signo = SIGSEGV;
diff --git a/arch/parisc/lib/checksum.c b/arch/parisc/lib/checksum.c
index 462696d30d3b..ae66d31f9ecf 100644
--- a/arch/parisc/lib/checksum.c
+++ b/arch/parisc/lib/checksum.c
@@ -13,8 +13,6 @@
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version. 15 * 2 of the License, or (at your option) any later version.
16 *
17 * $Id: checksum.c,v 1.3 1997/12/01 17:57:34 ralf Exp $
18 */ 16 */
19#include <linux/module.h> 17#include <linux/module.h>
20#include <linux/types.h> 18#include <linux/types.h>
diff --git a/arch/parisc/lib/memcpy.c b/arch/parisc/lib/memcpy.c
index bbda909c866e..abf41f4632a9 100644
--- a/arch/parisc/lib/memcpy.c
+++ b/arch/parisc/lib/memcpy.c
@@ -405,7 +405,7 @@ byte_copy:
405 405
406unaligned_copy: 406unaligned_copy:
407 /* possibly we are aligned on a word, but not on a double... */ 407 /* possibly we are aligned on a word, but not on a double... */
408 if (likely(t1 & (sizeof(unsigned int)-1)) == 0) { 408 if (likely((t1 & (sizeof(unsigned int)-1)) == 0)) {
409 t2 = src & (sizeof(unsigned int) - 1); 409 t2 = src & (sizeof(unsigned int) - 1);
410 410
411 if (unlikely(t2 != 0)) { 411 if (unlikely(t2 != 0)) {
diff --git a/arch/parisc/math-emu/decode_exc.c b/arch/parisc/math-emu/decode_exc.c
index 66c8a9f6a27e..3ca1c6149218 100644
--- a/arch/parisc/math-emu/decode_exc.c
+++ b/arch/parisc/math-emu/decode_exc.c
@@ -40,7 +40,7 @@
40 * END_DESC 40 * END_DESC
41*/ 41*/
42 42
43 43#include <linux/kernel.h>
44#include "float.h" 44#include "float.h"
45#include "sgl_float.h" 45#include "sgl_float.h"
46#include "dbl_float.h" 46#include "dbl_float.h"
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index bfb6dd6ab380..c6afbfc95770 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -1,5 +1,4 @@
1/* $Id: fault.c,v 1.5 2000/01/26 16:20:29 jsm Exp $ 1/*
2 *
3 * This file is subject to the terms and conditions of the GNU General Public 2 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
5 * for more details. 4 * for more details.
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 4356ceb1e366..b0831d9e35cb 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -370,34 +370,22 @@ static void __init setup_bootmem(void)
370 370
371void free_initmem(void) 371void free_initmem(void)
372{ 372{
373 unsigned long addr, init_begin, init_end; 373 unsigned long addr;
374 374 unsigned long init_begin = (unsigned long)__init_begin;
375 printk(KERN_INFO "Freeing unused kernel memory: "); 375 unsigned long init_end = (unsigned long)__init_end;
376 376
377#ifdef CONFIG_DEBUG_KERNEL 377#ifdef CONFIG_DEBUG_KERNEL
378 /* Attempt to catch anyone trying to execute code here 378 /* Attempt to catch anyone trying to execute code here
379 * by filling the page with BRK insns. 379 * by filling the page with BRK insns.
380 *
381 * If we disable interrupts for all CPUs, then IPI stops working.
382 * Kinda breaks the global cache flushing.
383 */ 380 */
384 local_irq_disable(); 381 memset((void *)init_begin, 0x00, init_end - init_begin);
385 382 flush_icache_range(init_begin, init_end);
386 memset(__init_begin, 0x00,
387 (unsigned long)__init_end - (unsigned long)__init_begin);
388
389 flush_data_cache();
390 asm volatile("sync" : : );
391 flush_icache_range((unsigned long)__init_begin, (unsigned long)__init_end);
392 asm volatile("sync" : : );
393
394 local_irq_enable();
395#endif 383#endif
396 384
397 /* align __init_begin and __init_end to page size, 385 /* align __init_begin and __init_end to page size,
398 ignoring linker script where we might have tried to save RAM */ 386 ignoring linker script where we might have tried to save RAM */
399 init_begin = PAGE_ALIGN((unsigned long)(__init_begin)); 387 init_begin = PAGE_ALIGN(init_begin);
400 init_end = PAGE_ALIGN((unsigned long)(__init_end)); 388 init_end = PAGE_ALIGN(init_end);
401 for (addr = init_begin; addr < init_end; addr += PAGE_SIZE) { 389 for (addr = init_begin; addr < init_end; addr += PAGE_SIZE) {
402 ClearPageReserved(virt_to_page(addr)); 390 ClearPageReserved(virt_to_page(addr));
403 init_page_count(virt_to_page(addr)); 391 init_page_count(virt_to_page(addr));
@@ -409,7 +397,8 @@ void free_initmem(void)
409 /* set up a new led state on systems shipped LED State panel */ 397 /* set up a new led state on systems shipped LED State panel */
410 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE); 398 pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE);
411 399
412 printk("%luk freed\n", (init_end - init_begin) >> 10); 400 printk(KERN_INFO "Freeing unused kernel memory: %luk freed\n",
401 (init_end - init_begin) >> 10);
413} 402}
414 403
415 404
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index bf6cedfa05db..d00131ca0835 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -62,7 +62,6 @@ config HAVE_LATENCYTOP_SUPPORT
62 62
63config TRACE_IRQFLAGS_SUPPORT 63config TRACE_IRQFLAGS_SUPPORT
64 bool 64 bool
65 depends on PPC64
66 default y 65 default y
67 66
68config LOCKDEP_SUPPORT 67config LOCKDEP_SUPPORT
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
index 2f50acd11a60..3d80c3e9cf60 100644
--- a/arch/powerpc/boot/.gitignore
+++ b/arch/powerpc/boot/.gitignore
@@ -36,3 +36,13 @@ zImage.pseries
36zconf.h 36zconf.h
37zlib.h 37zlib.h
38zutil.h 38zutil.h
39fdt.c
40fdt.h
41fdt_ro.c
42fdt_rw.c
43fdt_strerror.c
44fdt_sw.c
45fdt_wip.c
46libfdt.h
47libfdt_internal.h
48
diff --git a/arch/powerpc/boot/dts/amigaone.dts b/arch/powerpc/boot/dts/amigaone.dts
index 26549fca2ed4..49ac36b16dd7 100644
--- a/arch/powerpc/boot/dts/amigaone.dts
+++ b/arch/powerpc/boot/dts/amigaone.dts
@@ -70,8 +70,8 @@
70 devsel-speed = <0x00000001>; 70 devsel-speed = <0x00000001>;
71 min-grant = <0>; 71 min-grant = <0>;
72 max-latency = <0>; 72 max-latency = <0>;
73 /* First 64k for I/O at 0x0 on PCI mapped to 0x0 on ISA. */ 73 /* First 4k for I/O at 0x0 on PCI mapped to 0x0 on ISA. */
74 ranges = <0x00000001 0 0x01000000 0 0x00000000 0x00010000>; 74 ranges = <0x00000001 0 0x01000000 0 0x00000000 0x00001000>;
75 interrupt-parent = <&i8259>; 75 interrupt-parent = <&i8259>;
76 #interrupt-cells = <2>; 76 #interrupt-cells = <2>;
77 #address-cells = <2>; 77 #address-cells = <2>;
diff --git a/arch/powerpc/boot/dts/mpc8569mds.dts b/arch/powerpc/boot/dts/mpc8569mds.dts
index a8dcb018c4a5..a680165292f2 100644
--- a/arch/powerpc/boot/dts/mpc8569mds.dts
+++ b/arch/powerpc/boot/dts/mpc8569mds.dts
@@ -253,6 +253,7 @@
253 /* Filled in by U-Boot */ 253 /* Filled in by U-Boot */
254 clock-frequency = <0>; 254 clock-frequency = <0>;
255 status = "disabled"; 255 status = "disabled";
256 sdhci,1-bit-only;
256 }; 257 };
257 258
258 crypto@30000 { 259 crypto@30000 {
diff --git a/arch/powerpc/boot/dts/warp.dts b/arch/powerpc/boot/dts/warp.dts
index 01bfb56bbe80..31605ee4afb6 100644
--- a/arch/powerpc/boot/dts/warp.dts
+++ b/arch/powerpc/boot/dts/warp.dts
@@ -261,10 +261,11 @@
261 compatible = "gpio-leds"; 261 compatible = "gpio-leds";
262 green { 262 green {
263 gpios = <&GPIO1 0 0>; 263 gpios = <&GPIO1 0 0>;
264 default-state = "on"; 264 default-state = "keep";
265 }; 265 };
266 red { 266 red {
267 gpios = <&GPIO1 1 0>; 267 gpios = <&GPIO1 1 0>;
268 default-state = "keep";
268 }; 269 };
269 }; 270 };
270 271
diff --git a/arch/powerpc/configs/44x/warp_defconfig b/arch/powerpc/configs/44x/warp_defconfig
index 3b77f092abe1..787635f23d8f 100644
--- a/arch/powerpc/configs/44x/warp_defconfig
+++ b/arch/powerpc/configs/44x/warp_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.29-rc2 3# Linux kernel version: 2.6.30
4# Fri Jan 23 07:57:16 2009 4# Tue Jun 9 23:35:36 2009
5# 5#
6# CONFIG_PPC64 is not set 6# CONFIG_PPC64 is not set
7 7
@@ -41,6 +41,7 @@ CONFIG_ARCH_HAS_ILOG2_U32=y
41CONFIG_GENERIC_HWEIGHT=y 41CONFIG_GENERIC_HWEIGHT=y
42CONFIG_GENERIC_CALIBRATE_DELAY=y 42CONFIG_GENERIC_CALIBRATE_DELAY=y
43CONFIG_GENERIC_FIND_NEXT_BIT=y 43CONFIG_GENERIC_FIND_NEXT_BIT=y
44CONFIG_GENERIC_GPIO=y
44# CONFIG_ARCH_NO_VIRT_TO_BUS is not set 45# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
45CONFIG_PPC=y 46CONFIG_PPC=y
46CONFIG_EARLY_PRINTK=y 47CONFIG_EARLY_PRINTK=y
@@ -53,10 +54,12 @@ CONFIG_PPC_UDBG_16550=y
53# CONFIG_GENERIC_TBSYNC is not set 54# CONFIG_GENERIC_TBSYNC is not set
54CONFIG_AUDIT_ARCH=y 55CONFIG_AUDIT_ARCH=y
55CONFIG_GENERIC_BUG=y 56CONFIG_GENERIC_BUG=y
57CONFIG_DTC=y
56# CONFIG_DEFAULT_UIMAGE is not set 58# CONFIG_DEFAULT_UIMAGE is not set
57CONFIG_PPC_DCR_NATIVE=y 59CONFIG_PPC_DCR_NATIVE=y
58# CONFIG_PPC_DCR_MMIO is not set 60# CONFIG_PPC_DCR_MMIO is not set
59CONFIG_PPC_DCR=y 61CONFIG_PPC_DCR=y
62CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
60CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 63CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
61 64
62# 65#
@@ -74,7 +77,17 @@ CONFIG_SYSVIPC_SYSCTL=y
74# CONFIG_BSD_PROCESS_ACCT is not set 77# CONFIG_BSD_PROCESS_ACCT is not set
75# CONFIG_TASKSTATS is not set 78# CONFIG_TASKSTATS is not set
76# CONFIG_AUDIT is not set 79# CONFIG_AUDIT is not set
77# CONFIG_IKCONFIG is not set 80
81#
82# RCU Subsystem
83#
84CONFIG_CLASSIC_RCU=y
85# CONFIG_TREE_RCU is not set
86# CONFIG_PREEMPT_RCU is not set
87# CONFIG_TREE_RCU_TRACE is not set
88# CONFIG_PREEMPT_RCU_TRACE is not set
89CONFIG_IKCONFIG=y
90CONFIG_IKCONFIG_PROC=y
78CONFIG_LOG_BUF_SHIFT=14 91CONFIG_LOG_BUF_SHIFT=14
79CONFIG_GROUP_SCHED=y 92CONFIG_GROUP_SCHED=y
80CONFIG_FAIR_GROUP_SCHED=y 93CONFIG_FAIR_GROUP_SCHED=y
@@ -82,27 +95,29 @@ CONFIG_FAIR_GROUP_SCHED=y
82CONFIG_USER_SCHED=y 95CONFIG_USER_SCHED=y
83# CONFIG_CGROUP_SCHED is not set 96# CONFIG_CGROUP_SCHED is not set
84# CONFIG_CGROUPS is not set 97# CONFIG_CGROUPS is not set
85CONFIG_SYSFS_DEPRECATED=y 98# CONFIG_SYSFS_DEPRECATED_V2 is not set
86CONFIG_SYSFS_DEPRECATED_V2=y
87# CONFIG_RELAY is not set 99# CONFIG_RELAY is not set
88# CONFIG_NAMESPACES is not set 100# CONFIG_NAMESPACES is not set
89CONFIG_BLK_DEV_INITRD=y 101CONFIG_BLK_DEV_INITRD=y
90CONFIG_INITRAMFS_SOURCE="" 102CONFIG_INITRAMFS_SOURCE=""
103CONFIG_RD_GZIP=y
104# CONFIG_RD_BZIP2 is not set
105# CONFIG_RD_LZMA is not set
91# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 106# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
92CONFIG_SYSCTL=y 107CONFIG_SYSCTL=y
108CONFIG_ANON_INODES=y
93CONFIG_EMBEDDED=y 109CONFIG_EMBEDDED=y
94CONFIG_SYSCTL_SYSCALL=y 110CONFIG_SYSCTL_SYSCALL=y
95CONFIG_KALLSYMS=y 111CONFIG_KALLSYMS=y
96# CONFIG_KALLSYMS_ALL is not set 112# CONFIG_KALLSYMS_ALL is not set
97# CONFIG_KALLSYMS_EXTRA_PASS is not set 113# CONFIG_KALLSYMS_EXTRA_PASS is not set
98# CONFIG_HOTPLUG is not set 114# CONFIG_STRIP_ASM_SYMS is not set
115CONFIG_HOTPLUG=y
99CONFIG_PRINTK=y 116CONFIG_PRINTK=y
100CONFIG_BUG=y 117CONFIG_BUG=y
101CONFIG_ELF_CORE=y 118CONFIG_ELF_CORE=y
102CONFIG_COMPAT_BRK=y
103CONFIG_BASE_FULL=y 119CONFIG_BASE_FULL=y
104CONFIG_FUTEX=y 120CONFIG_FUTEX=y
105CONFIG_ANON_INODES=y
106CONFIG_EPOLL=y 121CONFIG_EPOLL=y
107CONFIG_SIGNALFD=y 122CONFIG_SIGNALFD=y
108CONFIG_TIMERFD=y 123CONFIG_TIMERFD=y
@@ -110,10 +125,13 @@ CONFIG_EVENTFD=y
110CONFIG_SHMEM=y 125CONFIG_SHMEM=y
111CONFIG_AIO=y 126CONFIG_AIO=y
112CONFIG_VM_EVENT_COUNTERS=y 127CONFIG_VM_EVENT_COUNTERS=y
113CONFIG_SLAB=y 128CONFIG_SLUB_DEBUG=y
114# CONFIG_SLUB is not set 129CONFIG_COMPAT_BRK=y
130# CONFIG_SLAB is not set
131CONFIG_SLUB=y
115# CONFIG_SLOB is not set 132# CONFIG_SLOB is not set
116# CONFIG_PROFILING is not set 133# CONFIG_PROFILING is not set
134# CONFIG_MARKERS is not set
117CONFIG_HAVE_OPROFILE=y 135CONFIG_HAVE_OPROFILE=y
118# CONFIG_KPROBES is not set 136# CONFIG_KPROBES is not set
119CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y 137CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
@@ -121,6 +139,7 @@ CONFIG_HAVE_IOREMAP_PROT=y
121CONFIG_HAVE_KPROBES=y 139CONFIG_HAVE_KPROBES=y
122CONFIG_HAVE_KRETPROBES=y 140CONFIG_HAVE_KRETPROBES=y
123CONFIG_HAVE_ARCH_TRACEHOOK=y 141CONFIG_HAVE_ARCH_TRACEHOOK=y
142# CONFIG_SLOW_WORK is not set
124# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 143# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
125CONFIG_SLABINFO=y 144CONFIG_SLABINFO=y
126CONFIG_RT_MUTEXES=y 145CONFIG_RT_MUTEXES=y
@@ -133,7 +152,6 @@ CONFIG_MODULE_UNLOAD=y
133# CONFIG_MODULE_SRCVERSION_ALL is not set 152# CONFIG_MODULE_SRCVERSION_ALL is not set
134CONFIG_BLOCK=y 153CONFIG_BLOCK=y
135# CONFIG_LBD is not set 154# CONFIG_LBD is not set
136# CONFIG_BLK_DEV_IO_TRACE is not set
137# CONFIG_BLK_DEV_BSG is not set 155# CONFIG_BLK_DEV_BSG is not set
138# CONFIG_BLK_DEV_INTEGRITY is not set 156# CONFIG_BLK_DEV_INTEGRITY is not set
139 157
@@ -149,11 +167,6 @@ CONFIG_DEFAULT_AS=y
149# CONFIG_DEFAULT_CFQ is not set 167# CONFIG_DEFAULT_CFQ is not set
150# CONFIG_DEFAULT_NOOP is not set 168# CONFIG_DEFAULT_NOOP is not set
151CONFIG_DEFAULT_IOSCHED="anticipatory" 169CONFIG_DEFAULT_IOSCHED="anticipatory"
152CONFIG_CLASSIC_RCU=y
153# CONFIG_TREE_RCU is not set
154# CONFIG_PREEMPT_RCU is not set
155# CONFIG_TREE_RCU_TRACE is not set
156# CONFIG_PREEMPT_RCU_TRACE is not set
157# CONFIG_FREEZER is not set 170# CONFIG_FREEZER is not set
158 171
159# 172#
@@ -173,10 +186,11 @@ CONFIG_WARP=y
173# CONFIG_ARCHES is not set 186# CONFIG_ARCHES is not set
174# CONFIG_CANYONLANDS is not set 187# CONFIG_CANYONLANDS is not set
175# CONFIG_GLACIER is not set 188# CONFIG_GLACIER is not set
189# CONFIG_REDWOOD is not set
176# CONFIG_YOSEMITE is not set 190# CONFIG_YOSEMITE is not set
177# CONFIG_XILINX_VIRTEX440_GENERIC_BOARD is not set 191# CONFIG_XILINX_VIRTEX440_GENERIC_BOARD is not set
178# CONFIG_PPC44x_SIMPLE is not set 192# CONFIG_PPC44x_SIMPLE is not set
179# CONFIG_PPC4xx_GPIO is not set 193CONFIG_PPC4xx_GPIO=y
180CONFIG_440EP=y 194CONFIG_440EP=y
181CONFIG_IBM440EP_ERR42=y 195CONFIG_IBM440EP_ERR42=y
182# CONFIG_IPIC is not set 196# CONFIG_IPIC is not set
@@ -235,9 +249,13 @@ CONFIG_ZONE_DMA_FLAG=1
235CONFIG_BOUNCE=y 249CONFIG_BOUNCE=y
236CONFIG_VIRT_TO_BUS=y 250CONFIG_VIRT_TO_BUS=y
237CONFIG_UNEVICTABLE_LRU=y 251CONFIG_UNEVICTABLE_LRU=y
252CONFIG_HAVE_MLOCK=y
253CONFIG_HAVE_MLOCKED_PAGE_BIT=y
254CONFIG_STDBINUTILS=y
238CONFIG_PPC_4K_PAGES=y 255CONFIG_PPC_4K_PAGES=y
239# CONFIG_PPC_16K_PAGES is not set 256# CONFIG_PPC_16K_PAGES is not set
240# CONFIG_PPC_64K_PAGES is not set 257# CONFIG_PPC_64K_PAGES is not set
258# CONFIG_PPC_256K_PAGES is not set
241CONFIG_FORCE_MAX_ZONEORDER=11 259CONFIG_FORCE_MAX_ZONEORDER=11
242CONFIG_PROC_DEVICETREE=y 260CONFIG_PROC_DEVICETREE=y
243CONFIG_CMDLINE_BOOL=y 261CONFIG_CMDLINE_BOOL=y
@@ -256,6 +274,7 @@ CONFIG_PPC_PCI_CHOICE=y
256# CONFIG_PCI_DOMAINS is not set 274# CONFIG_PCI_DOMAINS is not set
257# CONFIG_PCI_SYSCALL is not set 275# CONFIG_PCI_SYSCALL is not set
258# CONFIG_ARCH_SUPPORTS_MSI is not set 276# CONFIG_ARCH_SUPPORTS_MSI is not set
277# CONFIG_PCCARD is not set
259# CONFIG_HAS_RAPIDIO is not set 278# CONFIG_HAS_RAPIDIO is not set
260 279
261# 280#
@@ -271,14 +290,12 @@ CONFIG_PAGE_OFFSET=0xc0000000
271CONFIG_KERNEL_START=0xc0000000 290CONFIG_KERNEL_START=0xc0000000
272CONFIG_PHYSICAL_START=0x00000000 291CONFIG_PHYSICAL_START=0x00000000
273CONFIG_TASK_SIZE=0xc0000000 292CONFIG_TASK_SIZE=0xc0000000
274CONFIG_CONSISTENT_START=0xff100000
275CONFIG_CONSISTENT_SIZE=0x00200000 293CONFIG_CONSISTENT_SIZE=0x00200000
276CONFIG_NET=y 294CONFIG_NET=y
277 295
278# 296#
279# Networking options 297# Networking options
280# 298#
281CONFIG_COMPAT_NET_DEV_OPS=y
282CONFIG_PACKET=y 299CONFIG_PACKET=y
283# CONFIG_PACKET_MMAP is not set 300# CONFIG_PACKET_MMAP is not set
284CONFIG_UNIX=y 301CONFIG_UNIX=y
@@ -353,6 +370,7 @@ CONFIG_VLAN_8021Q=y
353# CONFIG_LAPB is not set 370# CONFIG_LAPB is not set
354# CONFIG_ECONET is not set 371# CONFIG_ECONET is not set
355# CONFIG_WAN_ROUTER is not set 372# CONFIG_WAN_ROUTER is not set
373# CONFIG_PHONET is not set
356# CONFIG_NET_SCHED is not set 374# CONFIG_NET_SCHED is not set
357# CONFIG_DCB is not set 375# CONFIG_DCB is not set
358 376
@@ -365,7 +383,6 @@ CONFIG_VLAN_8021Q=y
365# CONFIG_IRDA is not set 383# CONFIG_IRDA is not set
366# CONFIG_BT is not set 384# CONFIG_BT is not set
367# CONFIG_AF_RXRPC is not set 385# CONFIG_AF_RXRPC is not set
368# CONFIG_PHONET is not set
369# CONFIG_WIRELESS is not set 386# CONFIG_WIRELESS is not set
370# CONFIG_WIMAX is not set 387# CONFIG_WIMAX is not set
371# CONFIG_RFKILL is not set 388# CONFIG_RFKILL is not set
@@ -378,8 +395,12 @@ CONFIG_VLAN_8021Q=y
378# 395#
379# Generic Driver Options 396# Generic Driver Options
380# 397#
398CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
381# CONFIG_STANDALONE is not set 399# CONFIG_STANDALONE is not set
382CONFIG_PREVENT_FIRMWARE_BUILD=y 400CONFIG_PREVENT_FIRMWARE_BUILD=y
401CONFIG_FW_LOADER=y
402# CONFIG_FIRMWARE_IN_KERNEL is not set
403CONFIG_EXTRA_FIRMWARE=""
383# CONFIG_DEBUG_DRIVER is not set 404# CONFIG_DEBUG_DRIVER is not set
384# CONFIG_DEBUG_DEVRES is not set 405# CONFIG_DEBUG_DEVRES is not set
385# CONFIG_SYS_HYPERVISOR is not set 406# CONFIG_SYS_HYPERVISOR is not set
@@ -471,13 +492,21 @@ CONFIG_MTD_NAND_NDFC=y
471# LPDDR flash memory drivers 492# LPDDR flash memory drivers
472# 493#
473# CONFIG_MTD_LPDDR is not set 494# CONFIG_MTD_LPDDR is not set
474# CONFIG_MTD_QINFO_PROBE is not set
475 495
476# 496#
477# UBI - Unsorted block images 497# UBI - Unsorted block images
478# 498#
479# CONFIG_MTD_UBI is not set 499CONFIG_MTD_UBI=y
500CONFIG_MTD_UBI_WL_THRESHOLD=4096
501CONFIG_MTD_UBI_BEB_RESERVE=1
502# CONFIG_MTD_UBI_GLUEBI is not set
503
504#
505# UBI debugging options
506#
507# CONFIG_MTD_UBI_DEBUG is not set
480CONFIG_OF_DEVICE=y 508CONFIG_OF_DEVICE=y
509CONFIG_OF_GPIO=y
481CONFIG_OF_I2C=y 510CONFIG_OF_I2C=y
482# CONFIG_PARPORT is not set 511# CONFIG_PARPORT is not set
483CONFIG_BLK_DEV=y 512CONFIG_BLK_DEV=y
@@ -495,10 +524,17 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
495# CONFIG_XILINX_SYSACE is not set 524# CONFIG_XILINX_SYSACE is not set
496# CONFIG_BLK_DEV_HD is not set 525# CONFIG_BLK_DEV_HD is not set
497CONFIG_MISC_DEVICES=y 526CONFIG_MISC_DEVICES=y
498# CONFIG_EEPROM_93CX6 is not set
499# CONFIG_ICS932S401 is not set 527# CONFIG_ICS932S401 is not set
500# CONFIG_ENCLOSURE_SERVICES is not set 528# CONFIG_ENCLOSURE_SERVICES is not set
529# CONFIG_ISL29003 is not set
501# CONFIG_C2PORT is not set 530# CONFIG_C2PORT is not set
531
532#
533# EEPROM support
534#
535CONFIG_EEPROM_AT24=y
536# CONFIG_EEPROM_LEGACY is not set
537# CONFIG_EEPROM_93CX6 is not set
502CONFIG_HAVE_IDE=y 538CONFIG_HAVE_IDE=y
503# CONFIG_IDE is not set 539# CONFIG_IDE is not set
504 540
@@ -529,7 +565,7 @@ CONFIG_BLK_DEV_SD=y
529# CONFIG_SCSI_CONSTANTS is not set 565# CONFIG_SCSI_CONSTANTS is not set
530# CONFIG_SCSI_LOGGING is not set 566# CONFIG_SCSI_LOGGING is not set
531# CONFIG_SCSI_SCAN_ASYNC is not set 567# CONFIG_SCSI_SCAN_ASYNC is not set
532CONFIG_SCSI_WAIT_SCAN=m 568# CONFIG_SCSI_WAIT_SCAN is not set
533 569
534# 570#
535# SCSI Transports 571# SCSI Transports
@@ -541,10 +577,12 @@ CONFIG_SCSI_SPI_ATTRS=y
541# CONFIG_SCSI_SRP_ATTRS is not set 577# CONFIG_SCSI_SRP_ATTRS is not set
542# CONFIG_SCSI_LOWLEVEL is not set 578# CONFIG_SCSI_LOWLEVEL is not set
543# CONFIG_SCSI_DH is not set 579# CONFIG_SCSI_DH is not set
580# CONFIG_SCSI_OSD_INITIATOR is not set
544# CONFIG_ATA is not set 581# CONFIG_ATA is not set
545# CONFIG_MD is not set 582# CONFIG_MD is not set
546# CONFIG_MACINTOSH_DRIVERS is not set 583# CONFIG_MACINTOSH_DRIVERS is not set
547CONFIG_NETDEVICES=y 584CONFIG_NETDEVICES=y
585CONFIG_COMPAT_NET_DEV_OPS=y
548# CONFIG_DUMMY is not set 586# CONFIG_DUMMY is not set
549# CONFIG_BONDING is not set 587# CONFIG_BONDING is not set
550# CONFIG_MACVLAN is not set 588# CONFIG_MACVLAN is not set
@@ -554,6 +592,8 @@ CONFIG_NETDEVICES=y
554# CONFIG_PHYLIB is not set 592# CONFIG_PHYLIB is not set
555CONFIG_NET_ETHERNET=y 593CONFIG_NET_ETHERNET=y
556CONFIG_MII=y 594CONFIG_MII=y
595# CONFIG_ETHOC is not set
596# CONFIG_DNET is not set
557CONFIG_IBM_NEW_EMAC=y 597CONFIG_IBM_NEW_EMAC=y
558CONFIG_IBM_NEW_EMAC_RXB=128 598CONFIG_IBM_NEW_EMAC_RXB=128
559CONFIG_IBM_NEW_EMAC_TXB=64 599CONFIG_IBM_NEW_EMAC_TXB=64
@@ -577,7 +617,6 @@ CONFIG_IBM_NEW_EMAC_ZMII=y
577# 617#
578# CONFIG_WLAN_PRE80211 is not set 618# CONFIG_WLAN_PRE80211 is not set
579# CONFIG_WLAN_80211 is not set 619# CONFIG_WLAN_80211 is not set
580# CONFIG_IWLWIFI_LEDS is not set
581 620
582# 621#
583# Enable WiMAX (Networking options) to see the WiMAX drivers 622# Enable WiMAX (Networking options) to see the WiMAX drivers
@@ -646,6 +685,7 @@ CONFIG_LEGACY_PTY_COUNT=256
646# CONFIG_HVC_UDBG is not set 685# CONFIG_HVC_UDBG is not set
647# CONFIG_IPMI_HANDLER is not set 686# CONFIG_IPMI_HANDLER is not set
648CONFIG_HW_RANDOM=y 687CONFIG_HW_RANDOM=y
688# CONFIG_HW_RANDOM_TIMERIOMEM is not set
649# CONFIG_NVRAM is not set 689# CONFIG_NVRAM is not set
650# CONFIG_GEN_RTC is not set 690# CONFIG_GEN_RTC is not set
651# CONFIG_R3964 is not set 691# CONFIG_R3964 is not set
@@ -663,6 +703,7 @@ CONFIG_I2C_HELPER_AUTO=y
663# 703#
664# I2C system bus drivers (mostly embedded / system-on-chip) 704# I2C system bus drivers (mostly embedded / system-on-chip)
665# 705#
706# CONFIG_I2C_GPIO is not set
666CONFIG_I2C_IBM_IIC=y 707CONFIG_I2C_IBM_IIC=y
667# CONFIG_I2C_MPC is not set 708# CONFIG_I2C_MPC is not set
668# CONFIG_I2C_OCORES is not set 709# CONFIG_I2C_OCORES is not set
@@ -685,12 +726,9 @@ CONFIG_I2C_IBM_IIC=y
685# Miscellaneous I2C Chip support 726# Miscellaneous I2C Chip support
686# 727#
687# CONFIG_DS1682 is not set 728# CONFIG_DS1682 is not set
688CONFIG_EEPROM_AT24=y
689CONFIG_EEPROM_LEGACY=y
690# CONFIG_SENSORS_PCF8574 is not set 729# CONFIG_SENSORS_PCF8574 is not set
691# CONFIG_PCF8575 is not set 730# CONFIG_PCF8575 is not set
692# CONFIG_SENSORS_PCA9539 is not set 731# CONFIG_SENSORS_PCA9539 is not set
693# CONFIG_SENSORS_PCF8591 is not set
694# CONFIG_SENSORS_MAX6875 is not set 732# CONFIG_SENSORS_MAX6875 is not set
695# CONFIG_SENSORS_TSL2550 is not set 733# CONFIG_SENSORS_TSL2550 is not set
696# CONFIG_I2C_DEBUG_CORE is not set 734# CONFIG_I2C_DEBUG_CORE is not set
@@ -699,7 +737,30 @@ CONFIG_EEPROM_LEGACY=y
699# CONFIG_I2C_DEBUG_CHIP is not set 737# CONFIG_I2C_DEBUG_CHIP is not set
700# CONFIG_SPI is not set 738# CONFIG_SPI is not set
701CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y 739CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
702# CONFIG_GPIOLIB is not set 740CONFIG_ARCH_REQUIRE_GPIOLIB=y
741CONFIG_GPIOLIB=y
742# CONFIG_DEBUG_GPIO is not set
743CONFIG_GPIO_SYSFS=y
744
745#
746# Memory mapped GPIO expanders:
747#
748# CONFIG_GPIO_XILINX is not set
749
750#
751# I2C GPIO expanders:
752#
753# CONFIG_GPIO_MAX732X is not set
754# CONFIG_GPIO_PCA953X is not set
755# CONFIG_GPIO_PCF857X is not set
756
757#
758# PCI GPIO expanders:
759#
760
761#
762# SPI GPIO expanders:
763#
703# CONFIG_W1 is not set 764# CONFIG_W1 is not set
704# CONFIG_POWER_SUPPLY is not set 765# CONFIG_POWER_SUPPLY is not set
705CONFIG_HWMON=y 766CONFIG_HWMON=y
@@ -721,6 +782,7 @@ CONFIG_SENSORS_AD7414=y
721# CONFIG_SENSORS_F71805F is not set 782# CONFIG_SENSORS_F71805F is not set
722# CONFIG_SENSORS_F71882FG is not set 783# CONFIG_SENSORS_F71882FG is not set
723# CONFIG_SENSORS_F75375S is not set 784# CONFIG_SENSORS_F75375S is not set
785# CONFIG_SENSORS_G760A is not set
724# CONFIG_SENSORS_GL518SM is not set 786# CONFIG_SENSORS_GL518SM is not set
725# CONFIG_SENSORS_GL520SM is not set 787# CONFIG_SENSORS_GL520SM is not set
726# CONFIG_SENSORS_IT87 is not set 788# CONFIG_SENSORS_IT87 is not set
@@ -735,11 +797,15 @@ CONFIG_SENSORS_AD7414=y
735# CONFIG_SENSORS_LM90 is not set 797# CONFIG_SENSORS_LM90 is not set
736# CONFIG_SENSORS_LM92 is not set 798# CONFIG_SENSORS_LM92 is not set
737# CONFIG_SENSORS_LM93 is not set 799# CONFIG_SENSORS_LM93 is not set
800# CONFIG_SENSORS_LTC4215 is not set
738# CONFIG_SENSORS_LTC4245 is not set 801# CONFIG_SENSORS_LTC4245 is not set
802# CONFIG_SENSORS_LM95241 is not set
739# CONFIG_SENSORS_MAX1619 is not set 803# CONFIG_SENSORS_MAX1619 is not set
740# CONFIG_SENSORS_MAX6650 is not set 804# CONFIG_SENSORS_MAX6650 is not set
741# CONFIG_SENSORS_PC87360 is not set 805# CONFIG_SENSORS_PC87360 is not set
742# CONFIG_SENSORS_PC87427 is not set 806# CONFIG_SENSORS_PC87427 is not set
807# CONFIG_SENSORS_PCF8591 is not set
808# CONFIG_SENSORS_SHT15 is not set
743# CONFIG_SENSORS_DME1737 is not set 809# CONFIG_SENSORS_DME1737 is not set
744# CONFIG_SENSORS_SMSC47M1 is not set 810# CONFIG_SENSORS_SMSC47M1 is not set
745# CONFIG_SENSORS_SMSC47M192 is not set 811# CONFIG_SENSORS_SMSC47M192 is not set
@@ -785,6 +851,7 @@ CONFIG_SSB_POSSIBLE=y
785# CONFIG_MFD_CORE is not set 851# CONFIG_MFD_CORE is not set
786# CONFIG_MFD_SM501 is not set 852# CONFIG_MFD_SM501 is not set
787# CONFIG_HTC_PASIC3 is not set 853# CONFIG_HTC_PASIC3 is not set
854# CONFIG_TPS65010 is not set
788# CONFIG_TWL4030_CORE is not set 855# CONFIG_TWL4030_CORE is not set
789# CONFIG_MFD_TMIO is not set 856# CONFIG_MFD_TMIO is not set
790# CONFIG_PMIC_DA903X is not set 857# CONFIG_PMIC_DA903X is not set
@@ -870,11 +937,11 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
870# CONFIG_USB_TMC is not set 937# CONFIG_USB_TMC is not set
871 938
872# 939#
873# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; 940# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
874# 941#
875 942
876# 943#
877# see USB_STORAGE Help for more information 944# also be needed; see USB_STORAGE Help for more info
878# 945#
879CONFIG_USB_STORAGE=y 946CONFIG_USB_STORAGE=y
880# CONFIG_USB_STORAGE_DEBUG is not set 947# CONFIG_USB_STORAGE_DEBUG is not set
@@ -915,7 +982,6 @@ CONFIG_USB_STORAGE=y
915# CONFIG_USB_LED is not set 982# CONFIG_USB_LED is not set
916# CONFIG_USB_CYPRESS_CY7C63 is not set 983# CONFIG_USB_CYPRESS_CY7C63 is not set
917# CONFIG_USB_CYTHERM is not set 984# CONFIG_USB_CYTHERM is not set
918# CONFIG_USB_PHIDGET is not set
919# CONFIG_USB_IDMOUSE is not set 985# CONFIG_USB_IDMOUSE is not set
920# CONFIG_USB_FTDI_ELAN is not set 986# CONFIG_USB_FTDI_ELAN is not set
921# CONFIG_USB_APPLEDISPLAY is not set 987# CONFIG_USB_APPLEDISPLAY is not set
@@ -929,6 +995,8 @@ CONFIG_USB_STORAGE=y
929# 995#
930# OTG and related infrastructure 996# OTG and related infrastructure
931# 997#
998# CONFIG_USB_GPIO_VBUS is not set
999# CONFIG_NOP_USB_XCEIV is not set
932CONFIG_MMC=y 1000CONFIG_MMC=y
933# CONFIG_MMC_DEBUG is not set 1001# CONFIG_MMC_DEBUG is not set
934# CONFIG_MMC_UNSAFE_RESUME is not set 1002# CONFIG_MMC_UNSAFE_RESUME is not set
@@ -946,6 +1014,7 @@ CONFIG_MMC_BLOCK_BOUNCE=y
946# 1014#
947# CONFIG_MMC_SDHCI is not set 1015# CONFIG_MMC_SDHCI is not set
948# CONFIG_MMC_WBSD is not set 1016# CONFIG_MMC_WBSD is not set
1017CONFIG_MMC_PIKASD=y
949# CONFIG_MEMSTICK is not set 1018# CONFIG_MEMSTICK is not set
950CONFIG_NEW_LEDS=y 1019CONFIG_NEW_LEDS=y
951CONFIG_LEDS_CLASS=y 1020CONFIG_LEDS_CLASS=y
@@ -953,16 +1022,31 @@ CONFIG_LEDS_CLASS=y
953# 1022#
954# LED drivers 1023# LED drivers
955# 1024#
1025CONFIG_LEDS_GPIO=y
1026# CONFIG_LEDS_GPIO_PLATFORM is not set
1027CONFIG_LEDS_GPIO_OF=y
1028# CONFIG_LEDS_LP5521 is not set
956# CONFIG_LEDS_PCA955X is not set 1029# CONFIG_LEDS_PCA955X is not set
1030# CONFIG_LEDS_BD2802 is not set
957 1031
958# 1032#
959# LED Triggers 1033# LED Triggers
960# 1034#
961# CONFIG_LEDS_TRIGGERS is not set 1035CONFIG_LEDS_TRIGGERS=y
1036# CONFIG_LEDS_TRIGGER_TIMER is not set
1037# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
1038# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
1039# CONFIG_LEDS_TRIGGER_GPIO is not set
1040CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
1041
1042#
1043# iptables trigger is under Netfilter config (LED target)
1044#
962# CONFIG_ACCESSIBILITY is not set 1045# CONFIG_ACCESSIBILITY is not set
963# CONFIG_EDAC is not set 1046# CONFIG_EDAC is not set
964# CONFIG_RTC_CLASS is not set 1047# CONFIG_RTC_CLASS is not set
965# CONFIG_DMADEVICES is not set 1048# CONFIG_DMADEVICES is not set
1049# CONFIG_AUXDISPLAY is not set
966# CONFIG_UIO is not set 1050# CONFIG_UIO is not set
967# CONFIG_STAGING is not set 1051# CONFIG_STAGING is not set
968 1052
@@ -973,6 +1057,7 @@ CONFIG_EXT2_FS=y
973# CONFIG_EXT2_FS_XATTR is not set 1057# CONFIG_EXT2_FS_XATTR is not set
974# CONFIG_EXT2_FS_XIP is not set 1058# CONFIG_EXT2_FS_XIP is not set
975CONFIG_EXT3_FS=y 1059CONFIG_EXT3_FS=y
1060# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
976# CONFIG_EXT3_FS_XATTR is not set 1061# CONFIG_EXT3_FS_XATTR is not set
977# CONFIG_EXT4_FS is not set 1062# CONFIG_EXT4_FS is not set
978CONFIG_JBD=y 1063CONFIG_JBD=y
@@ -993,6 +1078,11 @@ CONFIG_INOTIFY_USER=y
993# CONFIG_FUSE_FS is not set 1078# CONFIG_FUSE_FS is not set
994 1079
995# 1080#
1081# Caches
1082#
1083# CONFIG_FSCACHE is not set
1084
1085#
996# CD-ROM/DVD Filesystems 1086# CD-ROM/DVD Filesystems
997# 1087#
998# CONFIG_ISO9660_FS is not set 1088# CONFIG_ISO9660_FS is not set
@@ -1039,6 +1129,12 @@ CONFIG_JFFS2_ZLIB=y
1039# CONFIG_JFFS2_LZO is not set 1129# CONFIG_JFFS2_LZO is not set
1040CONFIG_JFFS2_RTIME=y 1130CONFIG_JFFS2_RTIME=y
1041# CONFIG_JFFS2_RUBIN is not set 1131# CONFIG_JFFS2_RUBIN is not set
1132CONFIG_UBIFS_FS=y
1133# CONFIG_UBIFS_FS_XATTR is not set
1134# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
1135CONFIG_UBIFS_FS_LZO=y
1136CONFIG_UBIFS_FS_ZLIB=y
1137# CONFIG_UBIFS_FS_DEBUG is not set
1042CONFIG_CRAMFS=y 1138CONFIG_CRAMFS=y
1043# CONFIG_SQUASHFS is not set 1139# CONFIG_SQUASHFS is not set
1044# CONFIG_VXFS_FS is not set 1140# CONFIG_VXFS_FS is not set
@@ -1049,6 +1145,7 @@ CONFIG_CRAMFS=y
1049# CONFIG_ROMFS_FS is not set 1145# CONFIG_ROMFS_FS is not set
1050# CONFIG_SYSV_FS is not set 1146# CONFIG_SYSV_FS is not set
1051# CONFIG_UFS_FS is not set 1147# CONFIG_UFS_FS is not set
1148# CONFIG_NILFS2_FS is not set
1052CONFIG_NETWORK_FILESYSTEMS=y 1149CONFIG_NETWORK_FILESYSTEMS=y
1053CONFIG_NFS_FS=y 1150CONFIG_NFS_FS=y
1054CONFIG_NFS_V3=y 1151CONFIG_NFS_V3=y
@@ -1060,7 +1157,6 @@ CONFIG_LOCKD=y
1060CONFIG_LOCKD_V4=y 1157CONFIG_LOCKD_V4=y
1061CONFIG_NFS_COMMON=y 1158CONFIG_NFS_COMMON=y
1062CONFIG_SUNRPC=y 1159CONFIG_SUNRPC=y
1063# CONFIG_SUNRPC_REGISTER_V4 is not set
1064# CONFIG_RPCSEC_GSS_KRB5 is not set 1160# CONFIG_RPCSEC_GSS_KRB5 is not set
1065# CONFIG_RPCSEC_GSS_SPKM3 is not set 1161# CONFIG_RPCSEC_GSS_SPKM3 is not set
1066# CONFIG_SMB_FS is not set 1162# CONFIG_SMB_FS is not set
@@ -1115,6 +1211,7 @@ CONFIG_NLS_ISO8859_15=y
1115# CONFIG_NLS_KOI8_U is not set 1211# CONFIG_NLS_KOI8_U is not set
1116CONFIG_NLS_UTF8=y 1212CONFIG_NLS_UTF8=y
1117# CONFIG_DLM is not set 1213# CONFIG_DLM is not set
1214# CONFIG_BINARY_PRINTF is not set
1118 1215
1119# 1216#
1120# Library routines 1217# Library routines
@@ -1122,7 +1219,7 @@ CONFIG_NLS_UTF8=y
1122CONFIG_BITREVERSE=y 1219CONFIG_BITREVERSE=y
1123CONFIG_GENERIC_FIND_LAST_BIT=y 1220CONFIG_GENERIC_FIND_LAST_BIT=y
1124CONFIG_CRC_CCITT=y 1221CONFIG_CRC_CCITT=y
1125# CONFIG_CRC16 is not set 1222CONFIG_CRC16=y
1126CONFIG_CRC_T10DIF=y 1223CONFIG_CRC_T10DIF=y
1127# CONFIG_CRC_ITU_T is not set 1224# CONFIG_CRC_ITU_T is not set
1128CONFIG_CRC32=y 1225CONFIG_CRC32=y
@@ -1130,16 +1227,19 @@ CONFIG_CRC32=y
1130# CONFIG_LIBCRC32C is not set 1227# CONFIG_LIBCRC32C is not set
1131CONFIG_ZLIB_INFLATE=y 1228CONFIG_ZLIB_INFLATE=y
1132CONFIG_ZLIB_DEFLATE=y 1229CONFIG_ZLIB_DEFLATE=y
1133CONFIG_PLIST=y 1230CONFIG_LZO_COMPRESS=y
1231CONFIG_LZO_DECOMPRESS=y
1232CONFIG_DECOMPRESS_GZIP=y
1134CONFIG_HAS_IOMEM=y 1233CONFIG_HAS_IOMEM=y
1135CONFIG_HAS_IOPORT=y 1234CONFIG_HAS_IOPORT=y
1136CONFIG_HAS_DMA=y 1235CONFIG_HAS_DMA=y
1137CONFIG_HAVE_LMB=y 1236CONFIG_HAVE_LMB=y
1237CONFIG_NLATTR=y
1138 1238
1139# 1239#
1140# Kernel hacking 1240# Kernel hacking
1141# 1241#
1142# CONFIG_PRINTK_TIME is not set 1242CONFIG_PRINTK_TIME=y
1143CONFIG_ENABLE_WARN_DEPRECATED=y 1243CONFIG_ENABLE_WARN_DEPRECATED=y
1144CONFIG_ENABLE_MUST_CHECK=y 1244CONFIG_ENABLE_MUST_CHECK=y
1145CONFIG_FRAME_WARN=1024 1245CONFIG_FRAME_WARN=1024
@@ -1152,11 +1252,15 @@ CONFIG_DEBUG_KERNEL=y
1152CONFIG_DETECT_SOFTLOCKUP=y 1252CONFIG_DETECT_SOFTLOCKUP=y
1153# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set 1253# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1154CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0 1254CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1255CONFIG_DETECT_HUNG_TASK=y
1256# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1257CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
1155# CONFIG_SCHED_DEBUG is not set 1258# CONFIG_SCHED_DEBUG is not set
1156# CONFIG_SCHEDSTATS is not set 1259# CONFIG_SCHEDSTATS is not set
1157# CONFIG_TIMER_STATS is not set 1260# CONFIG_TIMER_STATS is not set
1158# CONFIG_DEBUG_OBJECTS is not set 1261# CONFIG_DEBUG_OBJECTS is not set
1159# CONFIG_DEBUG_SLAB is not set 1262# CONFIG_SLUB_DEBUG_ON is not set
1263# CONFIG_SLUB_STATS is not set
1160# CONFIG_DEBUG_RT_MUTEXES is not set 1264# CONFIG_DEBUG_RT_MUTEXES is not set
1161# CONFIG_RT_MUTEX_TESTER is not set 1265# CONFIG_RT_MUTEX_TESTER is not set
1162# CONFIG_DEBUG_SPINLOCK is not set 1266# CONFIG_DEBUG_SPINLOCK is not set
@@ -1180,9 +1284,12 @@ CONFIG_DEBUG_INFO=y
1180# CONFIG_FAULT_INJECTION is not set 1284# CONFIG_FAULT_INJECTION is not set
1181# CONFIG_LATENCYTOP is not set 1285# CONFIG_LATENCYTOP is not set
1182CONFIG_SYSCTL_SYSCALL_CHECK=y 1286CONFIG_SYSCTL_SYSCALL_CHECK=y
1287# CONFIG_DEBUG_PAGEALLOC is not set
1183CONFIG_HAVE_FUNCTION_TRACER=y 1288CONFIG_HAVE_FUNCTION_TRACER=y
1289CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
1184CONFIG_HAVE_DYNAMIC_FTRACE=y 1290CONFIG_HAVE_DYNAMIC_FTRACE=y
1185CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y 1291CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
1292CONFIG_TRACING_SUPPORT=y
1186 1293
1187# 1294#
1188# Tracers 1295# Tracers
@@ -1190,24 +1297,27 @@ CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
1190# CONFIG_FUNCTION_TRACER is not set 1297# CONFIG_FUNCTION_TRACER is not set
1191# CONFIG_SCHED_TRACER is not set 1298# CONFIG_SCHED_TRACER is not set
1192# CONFIG_CONTEXT_SWITCH_TRACER is not set 1299# CONFIG_CONTEXT_SWITCH_TRACER is not set
1300# CONFIG_EVENT_TRACER is not set
1193# CONFIG_BOOT_TRACER is not set 1301# CONFIG_BOOT_TRACER is not set
1194# CONFIG_TRACE_BRANCH_PROFILING is not set 1302# CONFIG_TRACE_BRANCH_PROFILING is not set
1195# CONFIG_STACK_TRACER is not set 1303# CONFIG_STACK_TRACER is not set
1196# CONFIG_DYNAMIC_PRINTK_DEBUG is not set 1304# CONFIG_KMEMTRACE is not set
1305# CONFIG_WORKQUEUE_TRACER is not set
1306# CONFIG_BLK_DEV_IO_TRACE is not set
1307# CONFIG_DYNAMIC_DEBUG is not set
1197# CONFIG_SAMPLES is not set 1308# CONFIG_SAMPLES is not set
1198CONFIG_HAVE_ARCH_KGDB=y 1309CONFIG_HAVE_ARCH_KGDB=y
1199# CONFIG_KGDB is not set 1310# CONFIG_KGDB is not set
1200CONFIG_PRINT_STACK_DEPTH=64 1311CONFIG_PRINT_STACK_DEPTH=64
1201# CONFIG_DEBUG_STACKOVERFLOW is not set 1312# CONFIG_DEBUG_STACKOVERFLOW is not set
1202# CONFIG_DEBUG_STACK_USAGE is not set 1313# CONFIG_DEBUG_STACK_USAGE is not set
1203# CONFIG_DEBUG_PAGEALLOC is not set
1204# CONFIG_CODE_PATCHING_SELFTEST is not set 1314# CONFIG_CODE_PATCHING_SELFTEST is not set
1205# CONFIG_FTR_FIXUP_SELFTEST is not set 1315# CONFIG_FTR_FIXUP_SELFTEST is not set
1206# CONFIG_MSI_BITMAP_SELFTEST is not set 1316# CONFIG_MSI_BITMAP_SELFTEST is not set
1207# CONFIG_XMON is not set 1317# CONFIG_XMON is not set
1208CONFIG_IRQSTACKS=y 1318CONFIG_IRQSTACKS=y
1209# CONFIG_VIRQ_DEBUG is not set 1319# CONFIG_VIRQ_DEBUG is not set
1210CONFIG_BDI_SWITCH=y 1320# CONFIG_BDI_SWITCH is not set
1211# CONFIG_PPC_EARLY_DEBUG is not set 1321# CONFIG_PPC_EARLY_DEBUG is not set
1212 1322
1213# 1323#
@@ -1223,6 +1333,8 @@ CONFIG_CRYPTO=y
1223# Crypto core or helper 1333# Crypto core or helper
1224# 1334#
1225# CONFIG_CRYPTO_FIPS is not set 1335# CONFIG_CRYPTO_FIPS is not set
1336CONFIG_CRYPTO_ALGAPI=y
1337CONFIG_CRYPTO_ALGAPI2=y
1226# CONFIG_CRYPTO_MANAGER is not set 1338# CONFIG_CRYPTO_MANAGER is not set
1227# CONFIG_CRYPTO_MANAGER2 is not set 1339# CONFIG_CRYPTO_MANAGER2 is not set
1228# CONFIG_CRYPTO_GF128MUL is not set 1340# CONFIG_CRYPTO_GF128MUL is not set
@@ -1294,13 +1406,15 @@ CONFIG_CRYPTO=y
1294# 1406#
1295# Compression 1407# Compression
1296# 1408#
1297# CONFIG_CRYPTO_DEFLATE is not set 1409CONFIG_CRYPTO_DEFLATE=y
1298# CONFIG_CRYPTO_LZO is not set 1410# CONFIG_CRYPTO_ZLIB is not set
1411CONFIG_CRYPTO_LZO=y
1299 1412
1300# 1413#
1301# Random Number Generation 1414# Random Number Generation
1302# 1415#
1303# CONFIG_CRYPTO_ANSI_CPRNG is not set 1416# CONFIG_CRYPTO_ANSI_CPRNG is not set
1304CONFIG_CRYPTO_HW=y 1417CONFIG_CRYPTO_HW=y
1418# CONFIG_CRYPTO_DEV_PPC4XX is not set
1305# CONFIG_PPC_CLOCK is not set 1419# CONFIG_PPC_CLOCK is not set
1306# CONFIG_VIRTUALIZATION is not set 1420# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/powerpc/include/asm/cpm1.h b/arch/powerpc/include/asm/cpm1.h
index 2ff798744c1d..7685ffde8821 100644
--- a/arch/powerpc/include/asm/cpm1.h
+++ b/arch/powerpc/include/asm/cpm1.h
@@ -598,8 +598,6 @@ typedef struct risc_timer_pram {
598#define CICR_IEN ((uint)0x00000080) /* Int. enable */ 598#define CICR_IEN ((uint)0x00000080) /* Int. enable */
599#define CICR_SPS ((uint)0x00000001) /* SCC Spread */ 599#define CICR_SPS ((uint)0x00000001) /* SCC Spread */
600 600
601#define IMAP_ADDR (get_immrbase())
602
603#define CPM_PIN_INPUT 0 601#define CPM_PIN_INPUT 0
604#define CPM_PIN_OUTPUT 1 602#define CPM_PIN_OUTPUT 1
605#define CPM_PIN_PRIMARY 0 603#define CPM_PIN_PRIMARY 0
diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h
index 1e2eb41fa057..52e4d54da2a9 100644
--- a/arch/powerpc/include/asm/delay.h
+++ b/arch/powerpc/include/asm/delay.h
@@ -63,6 +63,8 @@ extern void udelay(unsigned long usecs);
63 udelay(delay); \ 63 udelay(delay); \
64 else \ 64 else \
65 cpu_relax(); \ 65 cpu_relax(); \
66 if (!__ret) \
67 __ret = (condition); \
66 __ret; \ 68 __ret; \
67}) 69})
68 70
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 3d9e887c3c0c..b44aaabdd1a6 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -309,7 +309,9 @@ static inline void dma_sync_single_for_cpu(struct device *dev,
309 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 309 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
310 310
311 BUG_ON(!dma_ops); 311 BUG_ON(!dma_ops);
312 dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0, 312
313 if (dma_ops->sync_single_range_for_cpu)
314 dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0,
313 size, direction); 315 size, direction);
314} 316}
315 317
@@ -320,7 +322,9 @@ static inline void dma_sync_single_for_device(struct device *dev,
320 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 322 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
321 323
322 BUG_ON(!dma_ops); 324 BUG_ON(!dma_ops);
323 dma_ops->sync_single_range_for_device(dev, dma_handle, 325
326 if (dma_ops->sync_single_range_for_device)
327 dma_ops->sync_single_range_for_device(dev, dma_handle,
324 0, size, direction); 328 0, size, direction);
325} 329}
326 330
@@ -331,7 +335,9 @@ static inline void dma_sync_sg_for_cpu(struct device *dev,
331 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 335 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
332 336
333 BUG_ON(!dma_ops); 337 BUG_ON(!dma_ops);
334 dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction); 338
339 if (dma_ops->sync_sg_for_cpu)
340 dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction);
335} 341}
336 342
337static inline void dma_sync_sg_for_device(struct device *dev, 343static inline void dma_sync_sg_for_device(struct device *dev,
@@ -341,7 +347,9 @@ static inline void dma_sync_sg_for_device(struct device *dev,
341 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 347 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
342 348
343 BUG_ON(!dma_ops); 349 BUG_ON(!dma_ops);
344 dma_ops->sync_sg_for_device(dev, sgl, nents, direction); 350
351 if (dma_ops->sync_sg_for_device)
352 dma_ops->sync_sg_for_device(dev, sgl, nents, direction);
345} 353}
346 354
347static inline void dma_sync_single_range_for_cpu(struct device *dev, 355static inline void dma_sync_single_range_for_cpu(struct device *dev,
@@ -351,7 +359,9 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
351 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 359 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
352 360
353 BUG_ON(!dma_ops); 361 BUG_ON(!dma_ops);
354 dma_ops->sync_single_range_for_cpu(dev, dma_handle, 362
363 if (dma_ops->sync_single_range_for_cpu)
364 dma_ops->sync_single_range_for_cpu(dev, dma_handle,
355 offset, size, direction); 365 offset, size, direction);
356} 366}
357 367
@@ -362,7 +372,9 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
362 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 372 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
363 373
364 BUG_ON(!dma_ops); 374 BUG_ON(!dma_ops);
365 dma_ops->sync_single_range_for_device(dev, dma_handle, offset, 375
376 if (dma_ops->sync_single_range_for_device)
377 dma_ops->sync_single_range_for_device(dev, dma_handle, offset,
366 size, direction); 378 size, direction);
367} 379}
368#else /* CONFIG_PPC_NEED_DMA_SYNC_OPS */ 380#else /* CONFIG_PPC_NEED_DMA_SYNC_OPS */
diff --git a/arch/powerpc/include/asm/highmem.h b/arch/powerpc/include/asm/highmem.h
index 684a73f4324f..a74c4ee6c020 100644
--- a/arch/powerpc/include/asm/highmem.h
+++ b/arch/powerpc/include/asm/highmem.h
@@ -22,9 +22,7 @@
22 22
23#ifdef __KERNEL__ 23#ifdef __KERNEL__
24 24
25#include <linux/init.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
27#include <linux/highmem.h>
28#include <asm/kmap_types.h> 26#include <asm/kmap_types.h>
29#include <asm/tlbflush.h> 27#include <asm/tlbflush.h>
30#include <asm/page.h> 28#include <asm/page.h>
@@ -62,6 +60,9 @@ extern pte_t *pkmap_page_table;
62 60
63extern void *kmap_high(struct page *page); 61extern void *kmap_high(struct page *page);
64extern void kunmap_high(struct page *page); 62extern void kunmap_high(struct page *page);
63extern void *kmap_atomic_prot(struct page *page, enum km_type type,
64 pgprot_t prot);
65extern void kunmap_atomic(void *kvaddr, enum km_type type);
65 66
66static inline void *kmap(struct page *page) 67static inline void *kmap(struct page *page)
67{ 68{
@@ -79,62 +80,11 @@ static inline void kunmap(struct page *page)
79 kunmap_high(page); 80 kunmap_high(page);
80} 81}
81 82
82/*
83 * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
84 * gives a more generic (and caching) interface. But kmap_atomic can
85 * be used in IRQ contexts, so in some (very limited) cases we need
86 * it.
87 */
88static inline void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
89{
90 unsigned int idx;
91 unsigned long vaddr;
92
93 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
94 pagefault_disable();
95 if (!PageHighMem(page))
96 return page_address(page);
97
98 debug_kmap_atomic(type);
99 idx = type + KM_TYPE_NR*smp_processor_id();
100 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
101#ifdef CONFIG_DEBUG_HIGHMEM
102 BUG_ON(!pte_none(*(kmap_pte-idx)));
103#endif
104 __set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot), 1);
105 local_flush_tlb_page(NULL, vaddr);
106
107 return (void*) vaddr;
108}
109
110static inline void *kmap_atomic(struct page *page, enum km_type type) 83static inline void *kmap_atomic(struct page *page, enum km_type type)
111{ 84{
112 return kmap_atomic_prot(page, type, kmap_prot); 85 return kmap_atomic_prot(page, type, kmap_prot);
113} 86}
114 87
115static inline void kunmap_atomic(void *kvaddr, enum km_type type)
116{
117#ifdef CONFIG_DEBUG_HIGHMEM
118 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
119 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
120
121 if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
122 pagefault_enable();
123 return;
124 }
125
126 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
127
128 /*
129 * force other mappings to Oops if they'll try to access
130 * this pte without first remap it
131 */
132 pte_clear(&init_mm, vaddr, kmap_pte-idx);
133 local_flush_tlb_page(NULL, vaddr);
134#endif
135 pagefault_enable();
136}
137
138static inline struct page *kmap_atomic_to_page(void *ptr) 88static inline struct page *kmap_atomic_to_page(void *ptr)
139{ 89{
140 unsigned long idx, vaddr = (unsigned long) ptr; 90 unsigned long idx, vaddr = (unsigned long) ptr;
@@ -148,6 +98,7 @@ static inline struct page *kmap_atomic_to_page(void *ptr)
148 return pte_page(*pte); 98 return pte_page(*pte);
149} 99}
150 100
101
151#define flush_cache_kmaps() flush_cache_all() 102#define flush_cache_kmaps() flush_cache_all()
152 103
153#endif /* __KERNEL__ */ 104#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index 867ab8ed69b3..8b505eaaa38a 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -68,13 +68,13 @@ static inline int irqs_disabled_flags(unsigned long flags)
68 68
69#if defined(CONFIG_BOOKE) 69#if defined(CONFIG_BOOKE)
70#define SET_MSR_EE(x) mtmsr(x) 70#define SET_MSR_EE(x) mtmsr(x)
71#define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory") 71#define raw_local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory")
72#else 72#else
73#define SET_MSR_EE(x) mtmsr(x) 73#define SET_MSR_EE(x) mtmsr(x)
74#define local_irq_restore(flags) mtmsr(flags) 74#define raw_local_irq_restore(flags) mtmsr(flags)
75#endif 75#endif
76 76
77static inline void local_irq_disable(void) 77static inline void raw_local_irq_disable(void)
78{ 78{
79#ifdef CONFIG_BOOKE 79#ifdef CONFIG_BOOKE
80 __asm__ __volatile__("wrteei 0": : :"memory"); 80 __asm__ __volatile__("wrteei 0": : :"memory");
@@ -86,7 +86,7 @@ static inline void local_irq_disable(void)
86#endif 86#endif
87} 87}
88 88
89static inline void local_irq_enable(void) 89static inline void raw_local_irq_enable(void)
90{ 90{
91#ifdef CONFIG_BOOKE 91#ifdef CONFIG_BOOKE
92 __asm__ __volatile__("wrteei 1": : :"memory"); 92 __asm__ __volatile__("wrteei 1": : :"memory");
@@ -98,7 +98,7 @@ static inline void local_irq_enable(void)
98#endif 98#endif
99} 99}
100 100
101static inline void local_irq_save_ptr(unsigned long *flags) 101static inline void raw_local_irq_save_ptr(unsigned long *flags)
102{ 102{
103 unsigned long msr; 103 unsigned long msr;
104 msr = mfmsr(); 104 msr = mfmsr();
@@ -110,12 +110,12 @@ static inline void local_irq_save_ptr(unsigned long *flags)
110#endif 110#endif
111} 111}
112 112
113#define local_save_flags(flags) ((flags) = mfmsr()) 113#define raw_local_save_flags(flags) ((flags) = mfmsr())
114#define local_irq_save(flags) local_irq_save_ptr(&flags) 114#define raw_local_irq_save(flags) raw_local_irq_save_ptr(&flags)
115#define irqs_disabled() ((mfmsr() & MSR_EE) == 0) 115#define raw_irqs_disabled() ((mfmsr() & MSR_EE) == 0)
116#define raw_irqs_disabled_flags(flags) (((flags) & MSR_EE) == 0)
116 117
117#define hard_irq_enable() local_irq_enable() 118#define hard_irq_disable() raw_local_irq_disable()
118#define hard_irq_disable() local_irq_disable()
119 119
120static inline int irqs_disabled_flags(unsigned long flags) 120static inline int irqs_disabled_flags(unsigned long flags)
121{ 121{
diff --git a/arch/powerpc/include/asm/perf_counter.h b/arch/powerpc/include/asm/perf_counter.h
index 8ccd4e155768..0ea0639fcf75 100644
--- a/arch/powerpc/include/asm/perf_counter.h
+++ b/arch/powerpc/include/asm/perf_counter.h
@@ -61,6 +61,8 @@ struct pt_regs;
61extern unsigned long perf_misc_flags(struct pt_regs *regs); 61extern unsigned long perf_misc_flags(struct pt_regs *regs);
62extern unsigned long perf_instruction_pointer(struct pt_regs *regs); 62extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
63 63
64#define PERF_COUNTER_INDEX_OFFSET 1
65
64/* 66/*
65 * Only override the default definitions in include/linux/perf_counter.h 67 * Only override the default definitions in include/linux/perf_counter.h
66 * if we have hardware PMU support. 68 * if we have hardware PMU support.
diff --git a/arch/powerpc/include/asm/pte-hash64-64k.h b/arch/powerpc/include/asm/pte-hash64-64k.h
index e05d26fa372f..82b72207c51c 100644
--- a/arch/powerpc/include/asm/pte-hash64-64k.h
+++ b/arch/powerpc/include/asm/pte-hash64-64k.h
@@ -47,7 +47,8 @@
47 * generic accessors and iterators here 47 * generic accessors and iterators here
48 */ 48 */
49#define __real_pte(e,p) ((real_pte_t) { \ 49#define __real_pte(e,p) ((real_pte_t) { \
50 (e), pte_val(*((p) + PTRS_PER_PTE)) }) 50 (e), ((e) & _PAGE_COMBO) ? \
51 (pte_val(*((p) + PTRS_PER_PTE))) : 0 })
51#define __rpte_to_hidx(r,index) ((pte_val((r).pte) & _PAGE_COMBO) ? \ 52#define __rpte_to_hidx(r,index) ((pte_val((r).pte) & _PAGE_COMBO) ? \
52 (((r).hidx >> ((index)<<2)) & 0xf) : ((pte_val((r).pte) >> 12) & 0xf)) 53 (((r).hidx >> ((index)<<2)) & 0xf) : ((pte_val((r).pte) >> 12) & 0xf))
53#define __rpte_to_pte(r) ((r).pte) 54#define __rpte_to_pte(r) ((r).pte)
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 01c12339b304..168fce726201 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -58,7 +58,7 @@ struct rtas_t {
58 unsigned long entry; /* physical address pointer */ 58 unsigned long entry; /* physical address pointer */
59 unsigned long base; /* physical address pointer */ 59 unsigned long base; /* physical address pointer */
60 unsigned long size; 60 unsigned long size;
61 spinlock_t lock; 61 raw_spinlock_t lock;
62 struct rtas_args args; 62 struct rtas_args args;
63 struct device_node *dev; /* virtual address pointer */ 63 struct device_node *dev; /* virtual address pointer */
64}; 64};
@@ -245,5 +245,8 @@ static inline u32 rtas_config_addr(int busno, int devfn, int reg)
245 (devfn << 8) | (reg & 0xff); 245 (devfn << 8) | (reg & 0xff);
246} 246}
247 247
248extern void __cpuinit rtas_give_timebase(void);
249extern void __cpuinit rtas_take_timebase(void);
250
248#endif /* __KERNEL__ */ 251#endif /* __KERNEL__ */
249#endif /* _POWERPC_RTAS_H */ 252#endif /* _POWERPC_RTAS_H */
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 9aba5a38a7c4..c8b329255678 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -46,15 +46,13 @@ struct thread_info {
46 46
47/* 47/*
48 * macros/functions for gaining access to the thread information structure 48 * macros/functions for gaining access to the thread information structure
49 *
50 * preempt_count needs to be 1 initially, until the scheduler is functional.
51 */ 49 */
52#define INIT_THREAD_INFO(tsk) \ 50#define INIT_THREAD_INFO(tsk) \
53{ \ 51{ \
54 .task = &tsk, \ 52 .task = &tsk, \
55 .exec_domain = &default_exec_domain, \ 53 .exec_domain = &default_exec_domain, \
56 .cpu = 0, \ 54 .cpu = 0, \
57 .preempt_count = 1, \ 55 .preempt_count = INIT_PREEMPT_COUNT, \
58 .restart_block = { \ 56 .restart_block = { \
59 .fn = do_no_restart_syscall, \ 57 .fn = do_no_restart_syscall, \
60 }, \ 58 }, \
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 4dd38f129153..3cadba60a4b6 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -191,11 +191,49 @@ transfer_to_handler_cont:
191 mflr r9 191 mflr r9
192 lwz r11,0(r9) /* virtual address of handler */ 192 lwz r11,0(r9) /* virtual address of handler */
193 lwz r9,4(r9) /* where to go when done */ 193 lwz r9,4(r9) /* where to go when done */
194#ifdef CONFIG_TRACE_IRQFLAGS
195 lis r12,reenable_mmu@h
196 ori r12,r12,reenable_mmu@l
197 mtspr SPRN_SRR0,r12
198 mtspr SPRN_SRR1,r10
199 SYNC
200 RFI
201reenable_mmu: /* re-enable mmu so we can */
202 mfmsr r10
203 lwz r12,_MSR(r1)
204 xor r10,r10,r12
205 andi. r10,r10,MSR_EE /* Did EE change? */
206 beq 1f
207
208 /* Save handler and return address into the 2 unused words
209 * of the STACK_FRAME_OVERHEAD (sneak sneak sneak). Everything
210 * else can be recovered from the pt_regs except r3 which for
211 * normal interrupts has been set to pt_regs and for syscalls
212 * is an argument, so we temporarily use ORIG_GPR3 to save it
213 */
214 stw r9,8(r1)
215 stw r11,12(r1)
216 stw r3,ORIG_GPR3(r1)
217 bl trace_hardirqs_off
218 lwz r0,GPR0(r1)
219 lwz r3,ORIG_GPR3(r1)
220 lwz r4,GPR4(r1)
221 lwz r5,GPR5(r1)
222 lwz r6,GPR6(r1)
223 lwz r7,GPR7(r1)
224 lwz r8,GPR8(r1)
225 lwz r9,8(r1)
226 lwz r11,12(r1)
2271: mtctr r11
228 mtlr r9
229 bctr /* jump to handler */
230#else /* CONFIG_TRACE_IRQFLAGS */
194 mtspr SPRN_SRR0,r11 231 mtspr SPRN_SRR0,r11
195 mtspr SPRN_SRR1,r10 232 mtspr SPRN_SRR1,r10
196 mtlr r9 233 mtlr r9
197 SYNC 234 SYNC
198 RFI /* jump to handler, enable MMU */ 235 RFI /* jump to handler, enable MMU */
236#endif /* CONFIG_TRACE_IRQFLAGS */
199 237
200#if defined (CONFIG_6xx) || defined(CONFIG_E500) 238#if defined (CONFIG_6xx) || defined(CONFIG_E500)
2014: rlwinm r12,r12,0,~_TLF_NAPPING 2394: rlwinm r12,r12,0,~_TLF_NAPPING
@@ -251,6 +289,31 @@ _GLOBAL(DoSyscall)
251#ifdef SHOW_SYSCALLS 289#ifdef SHOW_SYSCALLS
252 bl do_show_syscall 290 bl do_show_syscall
253#endif /* SHOW_SYSCALLS */ 291#endif /* SHOW_SYSCALLS */
292#ifdef CONFIG_TRACE_IRQFLAGS
293 /* Return from syscalls can (and generally will) hard enable
294 * interrupts. You aren't supposed to call a syscall with
295 * interrupts disabled in the first place. However, to ensure
296 * that we get it right vs. lockdep if it happens, we force
297 * that hard enable here with appropriate tracing if we see
298 * that we have been called with interrupts off
299 */
300 mfmsr r11
301 andi. r12,r11,MSR_EE
302 bne+ 1f
303 /* We came in with interrupts disabled, we enable them now */
304 bl trace_hardirqs_on
305 mfmsr r11
306 lwz r0,GPR0(r1)
307 lwz r3,GPR3(r1)
308 lwz r4,GPR4(r1)
309 ori r11,r11,MSR_EE
310 lwz r5,GPR5(r1)
311 lwz r6,GPR6(r1)
312 lwz r7,GPR7(r1)
313 lwz r8,GPR8(r1)
314 mtmsr r11
3151:
316#endif /* CONFIG_TRACE_IRQFLAGS */
254 rlwinm r10,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */ 317 rlwinm r10,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */
255 lwz r11,TI_FLAGS(r10) 318 lwz r11,TI_FLAGS(r10)
256 andi. r11,r11,_TIF_SYSCALL_T_OR_A 319 andi. r11,r11,_TIF_SYSCALL_T_OR_A
@@ -275,6 +338,7 @@ ret_from_syscall:
275 rlwinm r12,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */ 338 rlwinm r12,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */
276 /* disable interrupts so current_thread_info()->flags can't change */ 339 /* disable interrupts so current_thread_info()->flags can't change */
277 LOAD_MSR_KERNEL(r10,MSR_KERNEL) /* doesn't include MSR_EE */ 340 LOAD_MSR_KERNEL(r10,MSR_KERNEL) /* doesn't include MSR_EE */
341 /* Note: We don't bother telling lockdep about it */
278 SYNC 342 SYNC
279 MTMSRD(r10) 343 MTMSRD(r10)
280 lwz r9,TI_FLAGS(r12) 344 lwz r9,TI_FLAGS(r12)
@@ -288,6 +352,19 @@ ret_from_syscall:
288 oris r11,r11,0x1000 /* Set SO bit in CR */ 352 oris r11,r11,0x1000 /* Set SO bit in CR */
289 stw r11,_CCR(r1) 353 stw r11,_CCR(r1)
290syscall_exit_cont: 354syscall_exit_cont:
355 lwz r8,_MSR(r1)
356#ifdef CONFIG_TRACE_IRQFLAGS
357 /* If we are going to return from the syscall with interrupts
358 * off, we trace that here. It shouldn't happen though but we
359 * want to catch the bugger if it does right ?
360 */
361 andi. r10,r8,MSR_EE
362 bne+ 1f
363 stw r3,GPR3(r1)
364 bl trace_hardirqs_off
365 lwz r3,GPR3(r1)
3661:
367#endif /* CONFIG_TRACE_IRQFLAGS */
291#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) 368#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
292 /* If the process has its own DBCR0 value, load it up. The internal 369 /* If the process has its own DBCR0 value, load it up. The internal
293 debug mode bit tells us that dbcr0 should be loaded. */ 370 debug mode bit tells us that dbcr0 should be loaded. */
@@ -311,7 +388,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
311 mtlr r4 388 mtlr r4
312 mtcr r5 389 mtcr r5
313 lwz r7,_NIP(r1) 390 lwz r7,_NIP(r1)
314 lwz r8,_MSR(r1)
315 FIX_SRR1(r8, r0) 391 FIX_SRR1(r8, r0)
316 lwz r2,GPR2(r1) 392 lwz r2,GPR2(r1)
317 lwz r1,GPR1(r1) 393 lwz r1,GPR1(r1)
@@ -394,7 +470,9 @@ syscall_exit_work:
394 andi. r0,r9,(_TIF_SYSCALL_T_OR_A|_TIF_SINGLESTEP) 470 andi. r0,r9,(_TIF_SYSCALL_T_OR_A|_TIF_SINGLESTEP)
395 beq ret_from_except 471 beq ret_from_except
396 472
397 /* Re-enable interrupts */ 473 /* Re-enable interrupts. There is no need to trace that with
474 * lockdep as we are supposed to have IRQs on at this point
475 */
398 ori r10,r10,MSR_EE 476 ori r10,r10,MSR_EE
399 SYNC 477 SYNC
400 MTMSRD(r10) 478 MTMSRD(r10)
@@ -705,6 +783,7 @@ ret_from_except:
705 /* Hard-disable interrupts so that current_thread_info()->flags 783 /* Hard-disable interrupts so that current_thread_info()->flags
706 * can't change between when we test it and when we return 784 * can't change between when we test it and when we return
707 * from the interrupt. */ 785 * from the interrupt. */
786 /* Note: We don't bother telling lockdep about it */
708 LOAD_MSR_KERNEL(r10,MSR_KERNEL) 787 LOAD_MSR_KERNEL(r10,MSR_KERNEL)
709 SYNC /* Some chip revs have problems here... */ 788 SYNC /* Some chip revs have problems here... */
710 MTMSRD(r10) /* disable interrupts */ 789 MTMSRD(r10) /* disable interrupts */
@@ -744,11 +823,24 @@ resume_kernel:
744 beq+ restore 823 beq+ restore
745 andi. r0,r3,MSR_EE /* interrupts off? */ 824 andi. r0,r3,MSR_EE /* interrupts off? */
746 beq restore /* don't schedule if so */ 825 beq restore /* don't schedule if so */
826#ifdef CONFIG_TRACE_IRQFLAGS
827 /* Lockdep thinks irqs are enabled, we need to call
828 * preempt_schedule_irq with IRQs off, so we inform lockdep
829 * now that we -did- turn them off already
830 */
831 bl trace_hardirqs_off
832#endif
7471: bl preempt_schedule_irq 8331: bl preempt_schedule_irq
748 rlwinm r9,r1,0,0,(31-THREAD_SHIFT) 834 rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
749 lwz r3,TI_FLAGS(r9) 835 lwz r3,TI_FLAGS(r9)
750 andi. r0,r3,_TIF_NEED_RESCHED 836 andi. r0,r3,_TIF_NEED_RESCHED
751 bne- 1b 837 bne- 1b
838#ifdef CONFIG_TRACE_IRQFLAGS
839 /* And now, to properly rebalance the above, we tell lockdep they
840 * are being turned back on, which will happen when we return
841 */
842 bl trace_hardirqs_on
843#endif
752#else 844#else
753resume_kernel: 845resume_kernel:
754#endif /* CONFIG_PREEMPT */ 846#endif /* CONFIG_PREEMPT */
@@ -765,6 +857,28 @@ restore:
765 stw r6,icache_44x_need_flush@l(r4) 857 stw r6,icache_44x_need_flush@l(r4)
7661: 8581:
767#endif /* CONFIG_44x */ 859#endif /* CONFIG_44x */
860
861 lwz r9,_MSR(r1)
862#ifdef CONFIG_TRACE_IRQFLAGS
863 /* Lockdep doesn't know about the fact that IRQs are temporarily turned
864 * off in this assembly code while peeking at TI_FLAGS() and such. However
865 * we need to inform it if the exception turned interrupts off, and we
866 * are about to trun them back on.
867 *
868 * The problem here sadly is that we don't know whether the exceptions was
869 * one that turned interrupts off or not. So we always tell lockdep about
870 * turning them on here when we go back to wherever we came from with EE
871 * on, even if that may meen some redudant calls being tracked. Maybe later
872 * we could encode what the exception did somewhere or test the exception
873 * type in the pt_regs but that sounds overkill
874 */
875 andi. r10,r9,MSR_EE
876 beq 1f
877 bl trace_hardirqs_on
878 lwz r9,_MSR(r1)
8791:
880#endif /* CONFIG_TRACE_IRQFLAGS */
881
768 lwz r0,GPR0(r1) 882 lwz r0,GPR0(r1)
769 lwz r2,GPR2(r1) 883 lwz r2,GPR2(r1)
770 REST_4GPRS(3, r1) 884 REST_4GPRS(3, r1)
@@ -782,7 +896,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
782 stwcx. r0,0,r1 /* to clear the reservation */ 896 stwcx. r0,0,r1 /* to clear the reservation */
783 897
784#if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE)) 898#if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE))
785 lwz r9,_MSR(r1)
786 andi. r10,r9,MSR_RI /* check if this exception occurred */ 899 andi. r10,r9,MSR_RI /* check if this exception occurred */
787 beql nonrecoverable /* at a bad place (MSR:RI = 0) */ 900 beql nonrecoverable /* at a bad place (MSR:RI = 0) */
788 901
@@ -805,7 +918,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
805 MTMSRD(r10) /* clear the RI bit */ 918 MTMSRD(r10) /* clear the RI bit */
806 .globl exc_exit_restart 919 .globl exc_exit_restart
807exc_exit_restart: 920exc_exit_restart:
808 lwz r9,_MSR(r1)
809 lwz r12,_NIP(r1) 921 lwz r12,_NIP(r1)
810 FIX_SRR1(r9,r10) 922 FIX_SRR1(r9,r10)
811 mtspr SPRN_SRR0,r12 923 mtspr SPRN_SRR0,r12
@@ -1035,11 +1147,18 @@ do_work: /* r10 contains MSR_KERNEL here */
1035 beq do_user_signal 1147 beq do_user_signal
1036 1148
1037do_resched: /* r10 contains MSR_KERNEL here */ 1149do_resched: /* r10 contains MSR_KERNEL here */
1150 /* Note: We don't need to inform lockdep that we are enabling
1151 * interrupts here. As far as it knows, they are already enabled
1152 */
1038 ori r10,r10,MSR_EE 1153 ori r10,r10,MSR_EE
1039 SYNC 1154 SYNC
1040 MTMSRD(r10) /* hard-enable interrupts */ 1155 MTMSRD(r10) /* hard-enable interrupts */
1041 bl schedule 1156 bl schedule
1042recheck: 1157recheck:
1158 /* Note: And we don't tell it we are disabling them again
1159 * neither. Those disable/enable cycles used to peek at
1160 * TI_FLAGS aren't advertised.
1161 */
1043 LOAD_MSR_KERNEL(r10,MSR_KERNEL) 1162 LOAD_MSR_KERNEL(r10,MSR_KERNEL)
1044 SYNC 1163 SYNC
1045 MTMSRD(r10) /* disable interrupts */ 1164 MTMSRD(r10) /* disable interrupts */
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 48469463f89e..fc2132942754 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -1124,9 +1124,8 @@ mmu_off:
1124 RFI 1124 RFI
1125 1125
1126/* 1126/*
1127 * Use the first pair of BAT registers to map the 1st 16MB 1127 * On 601, we use 3 BATs to map up to 24M of RAM at _PAGE_OFFSET
1128 * of RAM to PAGE_OFFSET. From this point on we can't safely 1128 * (we keep one for debugging) and on others, we use one 256M BAT.
1129 * call OF any more.
1130 */ 1129 */
1131initial_bats: 1130initial_bats:
1132 lis r11,PAGE_OFFSET@h 1131 lis r11,PAGE_OFFSET@h
@@ -1136,12 +1135,16 @@ initial_bats:
1136 bne 4f 1135 bne 4f
1137 ori r11,r11,4 /* set up BAT registers for 601 */ 1136 ori r11,r11,4 /* set up BAT registers for 601 */
1138 li r8,0x7f /* valid, block length = 8MB */ 1137 li r8,0x7f /* valid, block length = 8MB */
1139 oris r9,r11,0x800000@h /* set up BAT reg for 2nd 8M */
1140 oris r10,r8,0x800000@h /* set up BAT reg for 2nd 8M */
1141 mtspr SPRN_IBAT0U,r11 /* N.B. 601 has valid bit in */ 1138 mtspr SPRN_IBAT0U,r11 /* N.B. 601 has valid bit in */
1142 mtspr SPRN_IBAT0L,r8 /* lower BAT register */ 1139 mtspr SPRN_IBAT0L,r8 /* lower BAT register */
1143 mtspr SPRN_IBAT1U,r9 1140 addis r11,r11,0x800000@h
1144 mtspr SPRN_IBAT1L,r10 1141 addis r8,r8,0x800000@h
1142 mtspr SPRN_IBAT1U,r11
1143 mtspr SPRN_IBAT1L,r8
1144 addis r11,r11,0x800000@h
1145 addis r8,r8,0x800000@h
1146 mtspr SPRN_IBAT2U,r11
1147 mtspr SPRN_IBAT2L,r8
1145 isync 1148 isync
1146 blr 1149 blr
1147 1150
diff --git a/arch/powerpc/kernel/mpc7450-pmu.c b/arch/powerpc/kernel/mpc7450-pmu.c
index 75ff47fed7bf..c244133c67a6 100644
--- a/arch/powerpc/kernel/mpc7450-pmu.c
+++ b/arch/powerpc/kernel/mpc7450-pmu.c
@@ -10,7 +10,6 @@
10 */ 10 */
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/perf_counter.h> 12#include <linux/perf_counter.h>
13#include <linux/string.h>
14#include <asm/reg.h> 13#include <asm/reg.h>
15#include <asm/cputable.h> 14#include <asm/cputable.h>
16 15
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index fa983a59c4ce..a359cb08e900 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -76,7 +76,7 @@ struct of_device *of_device_alloc(struct device_node *np,
76 dev->dev.archdata.of_node = np; 76 dev->dev.archdata.of_node = np;
77 77
78 if (bus_id) 78 if (bus_id)
79 dev_set_name(&dev->dev, bus_id); 79 dev_set_name(&dev->dev, "%s", bus_id);
80 else 80 else
81 of_device_make_bus_id(dev); 81 of_device_make_bus_id(dev);
82 82
diff --git a/arch/powerpc/kernel/power7-pmu.c b/arch/powerpc/kernel/power7-pmu.c
index 5d755ef7ac8f..5a9f5cbd40a4 100644
--- a/arch/powerpc/kernel/power7-pmu.c
+++ b/arch/powerpc/kernel/power7-pmu.c
@@ -358,6 +358,7 @@ static struct power_pmu power7_pmu = {
358 .get_constraint = power7_get_constraint, 358 .get_constraint = power7_get_constraint,
359 .get_alternatives = power7_get_alternatives, 359 .get_alternatives = power7_get_alternatives,
360 .disable_pmc = power7_disable_pmc, 360 .disable_pmc = power7_disable_pmc,
361 .flags = PPMU_ALT_SIPR,
361 .n_generic = ARRAY_SIZE(power7_generic_events), 362 .n_generic = ARRAY_SIZE(power7_generic_events),
362 .generic_events = power7_generic_events, 363 .generic_events = power7_generic_events,
363 .cache_events = &power7_cache_events, 364 .cache_events = &power7_cache_events,
diff --git a/arch/powerpc/kernel/ppc970-pmu.c b/arch/powerpc/kernel/ppc970-pmu.c
index 6637c87fe70e..833097ac45dc 100644
--- a/arch/powerpc/kernel/ppc970-pmu.c
+++ b/arch/powerpc/kernel/ppc970-pmu.c
@@ -10,7 +10,6 @@
10 */ 10 */
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/perf_counter.h> 12#include <linux/perf_counter.h>
13#include <linux/string.h>
14#include <asm/reg.h> 13#include <asm/reg.h>
15#include <asm/cputable.h> 14#include <asm/cputable.h>
16 15
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 3e7135bbe40f..892a9f2e6d76 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -528,7 +528,7 @@ void show_regs(struct pt_regs * regs)
528 528
529 for (i = 0; i < 32; i++) { 529 for (i = 0; i < 32; i++) {
530 if ((i % REGS_PER_LINE) == 0) 530 if ((i % REGS_PER_LINE) == 0)
531 printk("\n" KERN_INFO "GPR%02d: ", i); 531 printk("\nGPR%02d: ", i);
532 printk(REG " ", regs->gpr[i]); 532 printk(REG " ", regs->gpr[i]);
533 if (i == LAST_VOLATILE && !FULL_REGS(regs)) 533 if (i == LAST_VOLATILE && !FULL_REGS(regs))
534 break; 534 break;
diff --git a/arch/powerpc/kernel/ptrace32.c b/arch/powerpc/kernel/ptrace32.c
index 297632cba047..8a6daf4129f6 100644
--- a/arch/powerpc/kernel/ptrace32.c
+++ b/arch/powerpc/kernel/ptrace32.c
@@ -21,7 +21,6 @@
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/smp.h> 23#include <linux/smp.h>
24#include <linux/smp_lock.h>
25#include <linux/errno.h> 24#include <linux/errno.h>
26#include <linux/ptrace.h> 25#include <linux/ptrace.h>
27#include <linux/regset.h> 26#include <linux/regset.h>
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index ee4c7609b649..c434823b8c83 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -38,9 +38,10 @@
38#include <asm/syscalls.h> 38#include <asm/syscalls.h>
39#include <asm/smp.h> 39#include <asm/smp.h>
40#include <asm/atomic.h> 40#include <asm/atomic.h>
41#include <asm/time.h>
41 42
42struct rtas_t rtas = { 43struct rtas_t rtas = {
43 .lock = SPIN_LOCK_UNLOCKED 44 .lock = __RAW_SPIN_LOCK_UNLOCKED
44}; 45};
45EXPORT_SYMBOL(rtas); 46EXPORT_SYMBOL(rtas);
46 47
@@ -67,6 +68,28 @@ unsigned long rtas_rmo_buf;
67void (*rtas_flash_term_hook)(int); 68void (*rtas_flash_term_hook)(int);
68EXPORT_SYMBOL(rtas_flash_term_hook); 69EXPORT_SYMBOL(rtas_flash_term_hook);
69 70
71/* RTAS use home made raw locking instead of spin_lock_irqsave
72 * because those can be called from within really nasty contexts
73 * such as having the timebase stopped which would lockup with
74 * normal locks and spinlock debugging enabled
75 */
76static unsigned long lock_rtas(void)
77{
78 unsigned long flags;
79
80 local_irq_save(flags);
81 preempt_disable();
82 __raw_spin_lock_flags(&rtas.lock, flags);
83 return flags;
84}
85
86static void unlock_rtas(unsigned long flags)
87{
88 __raw_spin_unlock(&rtas.lock);
89 local_irq_restore(flags);
90 preempt_enable();
91}
92
70/* 93/*
71 * call_rtas_display_status and call_rtas_display_status_delay 94 * call_rtas_display_status and call_rtas_display_status_delay
72 * are designed only for very early low-level debugging, which 95 * are designed only for very early low-level debugging, which
@@ -79,7 +102,7 @@ static void call_rtas_display_status(char c)
79 102
80 if (!rtas.base) 103 if (!rtas.base)
81 return; 104 return;
82 spin_lock_irqsave(&rtas.lock, s); 105 s = lock_rtas();
83 106
84 args->token = 10; 107 args->token = 10;
85 args->nargs = 1; 108 args->nargs = 1;
@@ -89,7 +112,7 @@ static void call_rtas_display_status(char c)
89 112
90 enter_rtas(__pa(args)); 113 enter_rtas(__pa(args));
91 114
92 spin_unlock_irqrestore(&rtas.lock, s); 115 unlock_rtas(s);
93} 116}
94 117
95static void call_rtas_display_status_delay(char c) 118static void call_rtas_display_status_delay(char c)
@@ -411,8 +434,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
411 if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE) 434 if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE)
412 return -1; 435 return -1;
413 436
414 /* Gotta do something different here, use global lock for now... */ 437 s = lock_rtas();
415 spin_lock_irqsave(&rtas.lock, s);
416 rtas_args = &rtas.args; 438 rtas_args = &rtas.args;
417 439
418 rtas_args->token = token; 440 rtas_args->token = token;
@@ -439,8 +461,7 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
439 outputs[i] = rtas_args->rets[i+1]; 461 outputs[i] = rtas_args->rets[i+1];
440 ret = (nret > 0)? rtas_args->rets[0]: 0; 462 ret = (nret > 0)? rtas_args->rets[0]: 0;
441 463
442 /* Gotta do something different here, use global lock for now... */ 464 unlock_rtas(s);
443 spin_unlock_irqrestore(&rtas.lock, s);
444 465
445 if (buff_copy) { 466 if (buff_copy) {
446 log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0); 467 log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0);
@@ -837,7 +858,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
837 858
838 buff_copy = get_errorlog_buffer(); 859 buff_copy = get_errorlog_buffer();
839 860
840 spin_lock_irqsave(&rtas.lock, flags); 861 flags = lock_rtas();
841 862
842 rtas.args = args; 863 rtas.args = args;
843 enter_rtas(__pa(&rtas.args)); 864 enter_rtas(__pa(&rtas.args));
@@ -848,7 +869,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
848 if (args.rets[0] == -1) 869 if (args.rets[0] == -1)
849 errbuf = __fetch_rtas_last_error(buff_copy); 870 errbuf = __fetch_rtas_last_error(buff_copy);
850 871
851 spin_unlock_irqrestore(&rtas.lock, flags); 872 unlock_rtas(flags);
852 873
853 if (buff_copy) { 874 if (buff_copy) {
854 if (errbuf) 875 if (errbuf)
@@ -951,3 +972,33 @@ int __init early_init_dt_scan_rtas(unsigned long node,
951 /* break now */ 972 /* break now */
952 return 1; 973 return 1;
953} 974}
975
976static raw_spinlock_t timebase_lock;
977static u64 timebase = 0;
978
979void __cpuinit rtas_give_timebase(void)
980{
981 unsigned long flags;
982
983 local_irq_save(flags);
984 hard_irq_disable();
985 __raw_spin_lock(&timebase_lock);
986 rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
987 timebase = get_tb();
988 __raw_spin_unlock(&timebase_lock);
989
990 while (timebase)
991 barrier();
992 rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
993 local_irq_restore(flags);
994}
995
996void __cpuinit rtas_take_timebase(void)
997{
998 while (!timebase)
999 barrier();
1000 __raw_spin_lock(&timebase_lock);
1001 set_tb(timebase >> 32, timebase & 0xffffffff);
1002 timebase = 0;
1003 __raw_spin_unlock(&timebase_lock);
1004}
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 1d154248cf40..e1e3059cf34b 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -119,6 +119,8 @@ notrace unsigned long __init early_init(unsigned long dt_ptr)
119 */ 119 */
120notrace void __init machine_init(unsigned long dt_ptr) 120notrace void __init machine_init(unsigned long dt_ptr)
121{ 121{
122 lockdep_init();
123
122 /* Enable early debugging if any specified (see udbg.h) */ 124 /* Enable early debugging if any specified (see udbg.h) */
123 udbg_early_init(); 125 udbg_early_init();
124 126
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 65484b2200b3..0b47de07302d 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -68,7 +68,8 @@ EXPORT_PER_CPU_SYMBOL(cpu_core_map);
68/* SMP operations for this machine */ 68/* SMP operations for this machine */
69struct smp_ops_t *smp_ops; 69struct smp_ops_t *smp_ops;
70 70
71static volatile unsigned int cpu_callin_map[NR_CPUS]; 71/* Can't be static due to PowerMac hackery */
72volatile unsigned int cpu_callin_map[NR_CPUS];
72 73
73int smt_enabled_at_boot = 1; 74int smt_enabled_at_boot = 1;
74 75
diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c
index 0362a891e54e..acb74a17bbbf 100644
--- a/arch/powerpc/kernel/udbg_16550.c
+++ b/arch/powerpc/kernel/udbg_16550.c
@@ -219,7 +219,7 @@ void udbg_init_pas_realmode(void)
219#ifdef CONFIG_PPC_EARLY_DEBUG_44x 219#ifdef CONFIG_PPC_EARLY_DEBUG_44x
220#include <platforms/44x/44x.h> 220#include <platforms/44x/44x.h>
221 221
222static int udbg_44x_as1_flush(void) 222static void udbg_44x_as1_flush(void)
223{ 223{
224 if (udbg_comport) { 224 if (udbg_comport) {
225 while ((as1_readb(&udbg_comport->lsr) & LSR_THRE) == 0) 225 while ((as1_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index 2d2192e48de7..3e68363405b7 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -30,3 +30,4 @@ obj-$(CONFIG_PPC_MM_SLICES) += slice.o
30obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 30obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
31obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage-prot.o 31obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage-prot.o
32obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o 32obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o
33obj-$(CONFIG_HIGHMEM) += highmem.o
diff --git a/arch/powerpc/mm/gup.c b/arch/powerpc/mm/gup.c
index bc400c78c97f..bc122a120bf0 100644
--- a/arch/powerpc/mm/gup.c
+++ b/arch/powerpc/mm/gup.c
@@ -159,7 +159,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
159 int psize; 159 int psize;
160#endif 160#endif
161 161
162 pr_debug("%s(%lx,%x,%s)\n", __func__, start, nr_pages, write ? "write" : "read"); 162 pr_devel("%s(%lx,%x,%s)\n", __func__, start, nr_pages, write ? "write" : "read");
163 163
164 start &= PAGE_MASK; 164 start &= PAGE_MASK;
165 addr = start; 165 addr = start;
@@ -170,7 +170,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
170 start, len))) 170 start, len)))
171 goto slow_irqon; 171 goto slow_irqon;
172 172
173 pr_debug(" aligned: %lx .. %lx\n", start, end); 173 pr_devel(" aligned: %lx .. %lx\n", start, end);
174 174
175#ifdef CONFIG_HUGETLB_PAGE 175#ifdef CONFIG_HUGETLB_PAGE
176 /* We bail out on slice boundary crossing when hugetlb is 176 /* We bail out on slice boundary crossing when hugetlb is
@@ -234,7 +234,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
234 do { 234 do {
235 VM_BUG_ON(shift != mmu_psize_defs[get_slice_psize(mm, a)].shift); 235 VM_BUG_ON(shift != mmu_psize_defs[get_slice_psize(mm, a)].shift);
236 ptep = huge_pte_offset(mm, a); 236 ptep = huge_pte_offset(mm, a);
237 pr_debug(" %016lx: huge ptep %p\n", a, ptep); 237 pr_devel(" %016lx: huge ptep %p\n", a, ptep);
238 if (!ptep || !gup_huge_pte(ptep, hstate, &a, end, write, pages, 238 if (!ptep || !gup_huge_pte(ptep, hstate, &a, end, write, pages,
239 &nr)) 239 &nr))
240 goto slow; 240 goto slow;
@@ -249,7 +249,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
249#ifdef CONFIG_PPC64 249#ifdef CONFIG_PPC64
250 VM_BUG_ON(shift != mmu_psize_defs[get_slice_psize(mm, addr)].shift); 250 VM_BUG_ON(shift != mmu_psize_defs[get_slice_psize(mm, addr)].shift);
251#endif 251#endif
252 pr_debug(" %016lx: normal pgd %p\n", addr, 252 pr_devel(" %016lx: normal pgd %p\n", addr,
253 (void *)pgd_val(pgd)); 253 (void *)pgd_val(pgd));
254 next = pgd_addr_end(addr, end); 254 next = pgd_addr_end(addr, end);
255 if (pgd_none(pgd)) 255 if (pgd_none(pgd))
@@ -269,7 +269,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
269slow: 269slow:
270 local_irq_enable(); 270 local_irq_enable();
271slow_irqon: 271slow_irqon:
272 pr_debug(" slow path ! nr = %d\n", nr); 272 pr_devel(" slow path ! nr = %d\n", nr);
273 273
274 /* Try to get the remaining pages with get_user_pages */ 274 /* Try to get the remaining pages with get_user_pages */
275 start += nr << PAGE_SHIFT; 275 start += nr << PAGE_SHIFT;
diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
new file mode 100644
index 000000000000..c2186c74c85a
--- /dev/null
+++ b/arch/powerpc/mm/highmem.c
@@ -0,0 +1,77 @@
1/*
2 * highmem.c: virtual kernel memory mappings for high memory
3 *
4 * PowerPC version, stolen from the i386 version.
5 *
6 * Used in CONFIG_HIGHMEM systems for memory pages which
7 * are not addressable by direct kernel virtual addresses.
8 *
9 * Copyright (C) 1999 Gerhard Wichert, Siemens AG
10 * Gerhard.Wichert@pdb.siemens.de
11 *
12 *
13 * Redesigned the x86 32-bit VM architecture to deal with
14 * up to 16 Terrabyte physical memory. With current x86 CPUs
15 * we now support up to 64 Gigabytes physical RAM.
16 *
17 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
18 *
19 * Reworked for PowerPC by various contributors. Moved from
20 * highmem.h by Benjamin Herrenschmidt (c) 2009 IBM Corp.
21 */
22
23#include <linux/highmem.h>
24#include <linux/module.h>
25
26/*
27 * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
28 * gives a more generic (and caching) interface. But kmap_atomic can
29 * be used in IRQ contexts, so in some (very limited) cases we need
30 * it.
31 */
32void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
33{
34 unsigned int idx;
35 unsigned long vaddr;
36
37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
38 pagefault_disable();
39 if (!PageHighMem(page))
40 return page_address(page);
41
42 debug_kmap_atomic(type);
43 idx = type + KM_TYPE_NR*smp_processor_id();
44 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
45#ifdef CONFIG_DEBUG_HIGHMEM
46 BUG_ON(!pte_none(*(kmap_pte-idx)));
47#endif
48 __set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot), 1);
49 local_flush_tlb_page(NULL, vaddr);
50
51 return (void*) vaddr;
52}
53EXPORT_SYMBOL(kmap_atomic_prot);
54
55void kunmap_atomic(void *kvaddr, enum km_type type)
56{
57#ifdef CONFIG_DEBUG_HIGHMEM
58 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
59 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
60
61 if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
62 pagefault_enable();
63 return;
64 }
65
66 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
67
68 /*
69 * force other mappings to Oops if they'll try to access
70 * this pte without first remap it
71 */
72 pte_clear(&init_mm, vaddr, kmap_pte-idx);
73 local_flush_tlb_page(NULL, vaddr);
74#endif
75 pagefault_enable();
76}
77EXPORT_SYMBOL(kunmap_atomic);
diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
index 8343986809c0..92a197117d5b 100644
--- a/arch/powerpc/mm/mmu_context_nohash.c
+++ b/arch/powerpc/mm/mmu_context_nohash.c
@@ -89,7 +89,7 @@ static unsigned int steal_context_smp(unsigned int id)
89 id = first_context; 89 id = first_context;
90 continue; 90 continue;
91 } 91 }
92 pr_debug("[%d] steal context %d from mm @%p\n", 92 pr_devel("[%d] steal context %d from mm @%p\n",
93 smp_processor_id(), id, mm); 93 smp_processor_id(), id, mm);
94 94
95 /* Mark this mm has having no context anymore */ 95 /* Mark this mm has having no context anymore */
@@ -126,7 +126,7 @@ static unsigned int steal_context_up(unsigned int id)
126 /* Pick up the victim mm */ 126 /* Pick up the victim mm */
127 mm = context_mm[id]; 127 mm = context_mm[id];
128 128
129 pr_debug("[%d] steal context %d from mm @%p\n", cpu, id, mm); 129 pr_devel("[%d] steal context %d from mm @%p\n", cpu, id, mm);
130 130
131 /* Flush the TLB for that context */ 131 /* Flush the TLB for that context */
132 local_flush_tlb_mm(mm); 132 local_flush_tlb_mm(mm);
@@ -180,7 +180,7 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
180 spin_lock(&context_lock); 180 spin_lock(&context_lock);
181 181
182#ifndef DEBUG_STEAL_ONLY 182#ifndef DEBUG_STEAL_ONLY
183 pr_debug("[%d] activating context for mm @%p, active=%d, id=%d\n", 183 pr_devel("[%d] activating context for mm @%p, active=%d, id=%d\n",
184 cpu, next, next->context.active, next->context.id); 184 cpu, next, next->context.active, next->context.id);
185#endif 185#endif
186 186
@@ -189,7 +189,7 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
189 next->context.active++; 189 next->context.active++;
190 if (prev) { 190 if (prev) {
191#ifndef DEBUG_STEAL_ONLY 191#ifndef DEBUG_STEAL_ONLY
192 pr_debug(" old context %p active was: %d\n", 192 pr_devel(" old context %p active was: %d\n",
193 prev, prev->context.active); 193 prev, prev->context.active);
194#endif 194#endif
195 WARN_ON(prev->context.active < 1); 195 WARN_ON(prev->context.active < 1);
@@ -236,7 +236,7 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
236 next->context.id = id; 236 next->context.id = id;
237 237
238#ifndef DEBUG_STEAL_ONLY 238#ifndef DEBUG_STEAL_ONLY
239 pr_debug("[%d] picked up new id %d, nrf is now %d\n", 239 pr_devel("[%d] picked up new id %d, nrf is now %d\n",
240 cpu, id, nr_free_contexts); 240 cpu, id, nr_free_contexts);
241#endif 241#endif
242 242
@@ -247,7 +247,7 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
247 * local TLB for it and unmark it before we use it 247 * local TLB for it and unmark it before we use it
248 */ 248 */
249 if (test_bit(id, stale_map[cpu])) { 249 if (test_bit(id, stale_map[cpu])) {
250 pr_debug("[%d] flushing stale context %d for mm @%p !\n", 250 pr_devel("[%d] flushing stale context %d for mm @%p !\n",
251 cpu, id, next); 251 cpu, id, next);
252 local_flush_tlb_mm(next); 252 local_flush_tlb_mm(next);
253 253
@@ -314,13 +314,13 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
314 switch (action) { 314 switch (action) {
315 case CPU_ONLINE: 315 case CPU_ONLINE:
316 case CPU_ONLINE_FROZEN: 316 case CPU_ONLINE_FROZEN:
317 pr_debug("MMU: Allocating stale context map for CPU %d\n", cpu); 317 pr_devel("MMU: Allocating stale context map for CPU %d\n", cpu);
318 stale_map[cpu] = kzalloc(CTX_MAP_SIZE, GFP_KERNEL); 318 stale_map[cpu] = kzalloc(CTX_MAP_SIZE, GFP_KERNEL);
319 break; 319 break;
320#ifdef CONFIG_HOTPLUG_CPU 320#ifdef CONFIG_HOTPLUG_CPU
321 case CPU_DEAD: 321 case CPU_DEAD:
322 case CPU_DEAD_FROZEN: 322 case CPU_DEAD_FROZEN:
323 pr_debug("MMU: Freeing stale context map for CPU %d\n", cpu); 323 pr_devel("MMU: Freeing stale context map for CPU %d\n", cpu);
324 kfree(stale_map[cpu]); 324 kfree(stale_map[cpu]);
325 stale_map[cpu] = NULL; 325 stale_map[cpu] = NULL;
326 break; 326 break;
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index ae1d67cc090c..627767d6169b 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -129,12 +129,12 @@ static pte_t do_dcache_icache_coherency(pte_t pte)
129 page = pfn_to_page(pfn); 129 page = pfn_to_page(pfn);
130 130
131 if (!PageReserved(page) && !test_bit(PG_arch_1, &page->flags)) { 131 if (!PageReserved(page) && !test_bit(PG_arch_1, &page->flags)) {
132 pr_debug("do_dcache_icache_coherency... flushing\n"); 132 pr_devel("do_dcache_icache_coherency... flushing\n");
133 flush_dcache_icache_page(page); 133 flush_dcache_icache_page(page);
134 set_bit(PG_arch_1, &page->flags); 134 set_bit(PG_arch_1, &page->flags);
135 } 135 }
136 else 136 else
137 pr_debug("do_dcache_icache_coherency... already clean\n"); 137 pr_devel("do_dcache_icache_coherency... already clean\n");
138 return __pte(pte_val(pte) | _PAGE_HWEXEC); 138 return __pte(pte_val(pte) | _PAGE_HWEXEC);
139} 139}
140 140
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index 3b52c80e5e33..5b7038f248b6 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -14,8 +14,6 @@
14 * 2 of the License, or (at your option) any later version. 14 * 2 of the License, or (at your option) any later version.
15 */ 15 */
16 16
17#undef DEBUG
18
19#include <asm/pgtable.h> 17#include <asm/pgtable.h>
20#include <asm/mmu.h> 18#include <asm/mmu.h>
21#include <asm/mmu_context.h> 19#include <asm/mmu_context.h>
@@ -27,11 +25,6 @@
27#include <linux/compiler.h> 25#include <linux/compiler.h>
28#include <asm/udbg.h> 26#include <asm/udbg.h>
29 27
30#ifdef DEBUG
31#define DBG(fmt...) printk(fmt)
32#else
33#define DBG pr_debug
34#endif
35 28
36extern void slb_allocate_realmode(unsigned long ea); 29extern void slb_allocate_realmode(unsigned long ea);
37extern void slb_allocate_user(unsigned long ea); 30extern void slb_allocate_user(unsigned long ea);
@@ -285,13 +278,13 @@ void slb_initialize(void)
285 patch_slb_encoding(slb_compare_rr_to_size, 278 patch_slb_encoding(slb_compare_rr_to_size,
286 mmu_slb_size); 279 mmu_slb_size);
287 280
288 DBG("SLB: linear LLP = %04lx\n", linear_llp); 281 pr_devel("SLB: linear LLP = %04lx\n", linear_llp);
289 DBG("SLB: io LLP = %04lx\n", io_llp); 282 pr_devel("SLB: io LLP = %04lx\n", io_llp);
290 283
291#ifdef CONFIG_SPARSEMEM_VMEMMAP 284#ifdef CONFIG_SPARSEMEM_VMEMMAP
292 patch_slb_encoding(slb_miss_kernel_load_vmemmap, 285 patch_slb_encoding(slb_miss_kernel_load_vmemmap,
293 SLB_VSID_KERNEL | vmemmap_llp); 286 SLB_VSID_KERNEL | vmemmap_llp);
294 DBG("SLB: vmemmap LLP = %04lx\n", vmemmap_llp); 287 pr_devel("SLB: vmemmap LLP = %04lx\n", vmemmap_llp);
295#endif 288#endif
296 } 289 }
297 290
diff --git a/arch/powerpc/mm/tlb_hash64.c b/arch/powerpc/mm/tlb_hash64.c
index 1be1b5e59796..937eb90677d9 100644
--- a/arch/powerpc/mm/tlb_hash64.c
+++ b/arch/powerpc/mm/tlb_hash64.c
@@ -72,7 +72,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
72 */ 72 */
73 if (huge) { 73 if (huge) {
74#ifdef CONFIG_HUGETLB_PAGE 74#ifdef CONFIG_HUGETLB_PAGE
75 psize = get_slice_psize(mm, addr);; 75 psize = get_slice_psize(mm, addr);
76#else 76#else
77 BUG(); 77 BUG();
78 psize = pte_pagesize_index(mm, addr, pte); /* shutup gcc */ 78 psize = pte_pagesize_index(mm, addr, pte); /* shutup gcc */
diff --git a/arch/powerpc/oprofile/cell/vma_map.c b/arch/powerpc/oprofile/cell/vma_map.c
index 258fa4411e9e..c591339daf58 100644
--- a/arch/powerpc/oprofile/cell/vma_map.c
+++ b/arch/powerpc/oprofile/cell/vma_map.c
@@ -185,7 +185,7 @@ struct vma_to_fileoffset_map *create_vma_map(const struct spu *aSpu,
185 goto fail; 185 goto fail;
186 186
187 if (shdr_str.sh_type != SHT_STRTAB) 187 if (shdr_str.sh_type != SHT_STRTAB)
188 goto fail;; 188 goto fail;
189 189
190 for (j = 0; j < shdr.sh_size / sizeof (sym); j++) { 190 for (j = 0; j < shdr.sh_size / sizeof (sym); j++) {
191 if (copy_from_user(&sym, spu_elf_start + 191 if (copy_from_user(&sym, spu_elf_start +
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index 42e09a9f77e2..e5c1b096c3e1 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -16,6 +16,7 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/of_gpio.h> 18#include <linux/of_gpio.h>
19#include <linux/of_i2c.h>
19 20
20#include <asm/machdep.h> 21#include <asm/machdep.h>
21#include <asm/prom.h> 22#include <asm/prom.h>
@@ -63,9 +64,6 @@ define_machine(warp) {
63}; 64};
64 65
65 66
66static u32 post_info;
67
68/* I am not sure this is the best place for this... */
69static int __init warp_post_info(void) 67static int __init warp_post_info(void)
70{ 68{
71 struct device_node *np; 69 struct device_node *np;
@@ -87,10 +85,9 @@ static int __init warp_post_info(void)
87 85
88 iounmap(fpga); 86 iounmap(fpga);
89 87
90 if (post1 || post2) { 88 if (post1 || post2)
91 printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2); 89 printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2);
92 post_info = 1; 90 else
93 } else
94 printk(KERN_INFO "Warp POST OK\n"); 91 printk(KERN_INFO "Warp POST OK\n");
95 92
96 return 0; 93 return 0;
@@ -166,6 +163,9 @@ static irqreturn_t temp_isr(int irq, void *context)
166 value ^= 1; 163 value ^= 1;
167 mdelay(500); 164 mdelay(500);
168 } 165 }
166
167 /* Not reached */
168 return IRQ_HANDLED;
169} 169}
170 170
171static int pika_setup_leds(void) 171static int pika_setup_leds(void)
@@ -179,24 +179,19 @@ static int pika_setup_leds(void)
179 } 179 }
180 180
181 for_each_child_of_node(np, child) 181 for_each_child_of_node(np, child)
182 if (strcmp(child->name, "green") == 0) { 182 if (strcmp(child->name, "green") == 0)
183 green_led = of_get_gpio(child, 0); 183 green_led = of_get_gpio(child, 0);
184 /* Turn back on the green LED */ 184 else if (strcmp(child->name, "red") == 0)
185 gpio_set_value(green_led, 1);
186 } else if (strcmp(child->name, "red") == 0) {
187 red_led = of_get_gpio(child, 0); 185 red_led = of_get_gpio(child, 0);
188 /* Set based on post */
189 gpio_set_value(red_led, post_info);
190 }
191 186
192 of_node_put(np); 187 of_node_put(np);
193 188
194 return 0; 189 return 0;
195} 190}
196 191
197static void pika_setup_critical_temp(struct i2c_client *client) 192static void pika_setup_critical_temp(struct device_node *np,
193 struct i2c_client *client)
198{ 194{
199 struct device_node *np;
200 int irq, rc; 195 int irq, rc;
201 196
202 /* Do this before enabling critical temp interrupt since we 197 /* Do this before enabling critical temp interrupt since we
@@ -208,14 +203,7 @@ static void pika_setup_critical_temp(struct i2c_client *client)
208 i2c_smbus_write_byte_data(client, 2, 65); /* Thigh */ 203 i2c_smbus_write_byte_data(client, 2, 65); /* Thigh */
209 i2c_smbus_write_byte_data(client, 3, 0); /* Tlow */ 204 i2c_smbus_write_byte_data(client, 3, 0); /* Tlow */
210 205
211 np = of_find_compatible_node(NULL, NULL, "adi,ad7414");
212 if (np == NULL) {
213 printk(KERN_ERR __FILE__ ": Unable to find ad7414\n");
214 return;
215 }
216
217 irq = irq_of_parse_and_map(np, 0); 206 irq = irq_of_parse_and_map(np, 0);
218 of_node_put(np);
219 if (irq == NO_IRQ) { 207 if (irq == NO_IRQ) {
220 printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n"); 208 printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n");
221 return; 209 return;
@@ -244,32 +232,24 @@ static inline void pika_dtm_check_fan(void __iomem *fpga)
244 232
245static int pika_dtm_thread(void __iomem *fpga) 233static int pika_dtm_thread(void __iomem *fpga)
246{ 234{
247 struct i2c_adapter *adap; 235 struct device_node *np;
248 struct i2c_client *client; 236 struct i2c_client *client;
249 237
250 /* We loop in case either driver was compiled as a module and 238 np = of_find_compatible_node(NULL, NULL, "adi,ad7414");
251 * has not been insmoded yet. 239 if (np == NULL)
252 */ 240 return -ENOENT;
253 while (!(adap = i2c_get_adapter(0))) {
254 set_current_state(TASK_INTERRUPTIBLE);
255 schedule_timeout(HZ);
256 }
257
258 while (1) {
259 list_for_each_entry(client, &adap->clients, list)
260 if (client->addr == 0x4a)
261 goto found_it;
262 241
263 set_current_state(TASK_INTERRUPTIBLE); 242 client = of_find_i2c_device_by_node(np);
264 schedule_timeout(HZ); 243 if (client == NULL) {
244 of_node_put(np);
245 return -ENOENT;
265 } 246 }
266 247
267found_it: 248 pika_setup_critical_temp(np, client);
268 pika_setup_critical_temp(client);
269 249
270 i2c_put_adapter(adap); 250 of_node_put(np);
271 251
272 printk(KERN_INFO "PIKA DTM thread running.\n"); 252 printk(KERN_INFO "Warp DTM thread running.\n");
273 253
274 while (!kthread_should_stop()) { 254 while (!kthread_should_stop()) {
275 int val; 255 int val;
@@ -291,7 +271,6 @@ found_it:
291 return 0; 271 return 0;
292} 272}
293 273
294
295static int __init pika_dtm_start(void) 274static int __init pika_dtm_start(void)
296{ 275{
297 struct task_struct *dtm_thread; 276 struct task_struct *dtm_thread;
diff --git a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
index ddf0bdc0fc8b..7ee979f323d1 100644
--- a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
+++ b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
@@ -147,7 +147,7 @@ int __init pq2ads_pci_init_irq(void)
147 goto out; 147 goto out;
148 } 148 }
149 149
150 priv = alloc_bootmem(sizeof(struct pq2ads_pci_pic)); 150 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
151 if (!priv) { 151 if (!priv) {
152 of_node_put(np); 152 of_node_put(np);
153 ret = -ENOMEM; 153 ret = -ENOMEM;
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 77f90b356356..60ed9c067b1d 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -285,6 +285,7 @@ static struct of_device_id mpc85xx_ids[] = {
285 { .type = "qe", }, 285 { .type = "qe", },
286 { .compatible = "fsl,qe", }, 286 { .compatible = "fsl,qe", },
287 { .compatible = "gianfar", }, 287 { .compatible = "gianfar", },
288 { .compatible = "fsl,rapidio-delta", },
288 {}, 289 {},
289}; 290};
290 291
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index cc0b0db8a6f3..62c592ede641 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -52,20 +52,19 @@ smp_85xx_kick_cpu(int nr)
52 52
53 pr_debug("smp_85xx_kick_cpu: kick CPU #%d\n", nr); 53 pr_debug("smp_85xx_kick_cpu: kick CPU #%d\n", nr);
54 54
55 local_irq_save(flags);
56
57 np = of_get_cpu_node(nr, NULL); 55 np = of_get_cpu_node(nr, NULL);
58 cpu_rel_addr = of_get_property(np, "cpu-release-addr", NULL); 56 cpu_rel_addr = of_get_property(np, "cpu-release-addr", NULL);
59 57
60 if (cpu_rel_addr == NULL) { 58 if (cpu_rel_addr == NULL) {
61 printk(KERN_ERR "No cpu-release-addr for cpu %d\n", nr); 59 printk(KERN_ERR "No cpu-release-addr for cpu %d\n", nr);
62 local_irq_restore(flags);
63 return; 60 return;
64 } 61 }
65 62
66 /* Map the spin table */ 63 /* Map the spin table */
67 bptr_vaddr = ioremap(*cpu_rel_addr, SIZE_BOOT_ENTRY); 64 bptr_vaddr = ioremap(*cpu_rel_addr, SIZE_BOOT_ENTRY);
68 65
66 local_irq_save(flags);
67
69 out_be32(bptr_vaddr + BOOT_ENTRY_PIR, nr); 68 out_be32(bptr_vaddr + BOOT_ENTRY_PIR, nr);
70 out_be32(bptr_vaddr + BOOT_ENTRY_ADDR_LOWER, __pa(__early_start)); 69 out_be32(bptr_vaddr + BOOT_ENTRY_ADDR_LOWER, __pa(__early_start));
71 70
@@ -73,10 +72,10 @@ smp_85xx_kick_cpu(int nr)
73 while ((__secondary_hold_acknowledge != nr) && (++n < 1000)) 72 while ((__secondary_hold_acknowledge != nr) && (++n < 1000))
74 mdelay(1); 73 mdelay(1);
75 74
76 iounmap(bptr_vaddr);
77
78 local_irq_restore(flags); 75 local_irq_restore(flags);
79 76
77 iounmap(bptr_vaddr);
78
80 pr_debug("waited %d msecs for CPU #%d.\n", n, nr); 79 pr_debug("waited %d msecs for CPU #%d.\n", n, nr);
81} 80}
82 81
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index d0e8443b12c6..747d8fb3ab82 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -102,10 +102,11 @@ static struct of_device_id __initdata socrates_of_bus_ids[] = {
102 {}, 102 {},
103}; 103};
104 104
105static void __init socrates_init(void) 105static int __init socrates_publish_devices(void)
106{ 106{
107 of_platform_bus_probe(NULL, socrates_of_bus_ids, NULL); 107 return of_platform_bus_probe(NULL, socrates_of_bus_ids, NULL);
108} 108}
109machine_device_initcall(socrates, socrates_publish_devices);
109 110
110/* 111/*
111 * Called very early, device-tree isn't unflattened 112 * Called very early, device-tree isn't unflattened
@@ -124,7 +125,6 @@ define_machine(socrates) {
124 .name = "Socrates", 125 .name = "Socrates",
125 .probe = socrates_probe, 126 .probe = socrates_probe,
126 .setup_arch = socrates_setup_arch, 127 .setup_arch = socrates_setup_arch,
127 .init = socrates_init,
128 .init_IRQ = socrates_pic_init, 128 .init_IRQ = socrates_pic_init,
129 .get_irq = mpic_get_irq, 129 .get_irq = mpic_get_irq,
130 .restart = fsl_rstcr_restart, 130 .restart = fsl_rstcr_restart,
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index ee01532786e4..1b426050a2f9 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -32,7 +32,6 @@
32 32
33#include <sysdev/fsl_soc.h> 33#include <sysdev/fsl_soc.h>
34#include <sysdev/fsl_pci.h> 34#include <sysdev/fsl_pci.h>
35#include <linux/of_platform.h>
36 35
37/* A few bit definitions needed for fixups on some boards */ 36/* A few bit definitions needed for fixups on some boards */
38#define MPC85xx_L2CTL_L2E 0x80000000 /* L2 enable */ 37#define MPC85xx_L2CTL_L2E 0x80000000 /* L2 enable */
diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index c71498dbf211..aca5741ddc67 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -85,7 +85,7 @@ static inline void axon_msi_debug_setup(struct device_node *dn,
85 85
86static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val) 86static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val)
87{ 87{
88 pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n); 88 pr_devel("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n);
89 89
90 dcr_write(msic->dcr_host, dcr_n, val); 90 dcr_write(msic->dcr_host, dcr_n, val);
91} 91}
@@ -98,7 +98,7 @@ static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc)
98 int retry = 0; 98 int retry = 0;
99 99
100 write_offset = dcr_read(msic->dcr_host, MSIC_WRITE_OFFSET_REG); 100 write_offset = dcr_read(msic->dcr_host, MSIC_WRITE_OFFSET_REG);
101 pr_debug("axon_msi: original write_offset 0x%x\n", write_offset); 101 pr_devel("axon_msi: original write_offset 0x%x\n", write_offset);
102 102
103 /* write_offset doesn't wrap properly, so we have to mask it */ 103 /* write_offset doesn't wrap properly, so we have to mask it */
104 write_offset &= MSIC_FIFO_SIZE_MASK; 104 write_offset &= MSIC_FIFO_SIZE_MASK;
@@ -108,7 +108,7 @@ static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc)
108 msi = le32_to_cpu(msic->fifo_virt[idx]); 108 msi = le32_to_cpu(msic->fifo_virt[idx]);
109 msi &= 0xFFFF; 109 msi &= 0xFFFF;
110 110
111 pr_debug("axon_msi: woff %x roff %x msi %x\n", 111 pr_devel("axon_msi: woff %x roff %x msi %x\n",
112 write_offset, msic->read_offset, msi); 112 write_offset, msic->read_offset, msi);
113 113
114 if (msi < NR_IRQS && irq_map[msi].host == msic->irq_host) { 114 if (msi < NR_IRQS && irq_map[msi].host == msic->irq_host) {
@@ -123,12 +123,12 @@ static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc)
123 */ 123 */
124 udelay(1); 124 udelay(1);
125 retry++; 125 retry++;
126 pr_debug("axon_msi: invalid irq 0x%x!\n", msi); 126 pr_devel("axon_msi: invalid irq 0x%x!\n", msi);
127 continue; 127 continue;
128 } 128 }
129 129
130 if (retry) { 130 if (retry) {
131 pr_debug("axon_msi: late irq 0x%x, retry %d\n", 131 pr_devel("axon_msi: late irq 0x%x, retry %d\n",
132 msi, retry); 132 msi, retry);
133 retry = 0; 133 retry = 0;
134 } 134 }
@@ -332,7 +332,7 @@ static int axon_msi_shutdown(struct of_device *device)
332 struct axon_msic *msic = dev_get_drvdata(&device->dev); 332 struct axon_msic *msic = dev_get_drvdata(&device->dev);
333 u32 tmp; 333 u32 tmp;
334 334
335 pr_debug("axon_msi: disabling %s\n", 335 pr_devel("axon_msi: disabling %s\n",
336 msic->irq_host->of_node->full_name); 336 msic->irq_host->of_node->full_name);
337 tmp = dcr_read(msic->dcr_host, MSIC_CTRL_REG); 337 tmp = dcr_read(msic->dcr_host, MSIC_CTRL_REG);
338 tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE; 338 tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE;
@@ -349,7 +349,7 @@ static int axon_msi_probe(struct of_device *device,
349 unsigned int virq; 349 unsigned int virq;
350 int dcr_base, dcr_len; 350 int dcr_base, dcr_len;
351 351
352 pr_debug("axon_msi: setting up dn %s\n", dn->full_name); 352 pr_devel("axon_msi: setting up dn %s\n", dn->full_name);
353 353
354 msic = kzalloc(sizeof(struct axon_msic), GFP_KERNEL); 354 msic = kzalloc(sizeof(struct axon_msic), GFP_KERNEL);
355 if (!msic) { 355 if (!msic) {
@@ -403,7 +403,7 @@ static int axon_msi_probe(struct of_device *device,
403 403
404 set_irq_data(virq, msic); 404 set_irq_data(virq, msic);
405 set_irq_chained_handler(virq, axon_msi_cascade); 405 set_irq_chained_handler(virq, axon_msi_cascade);
406 pr_debug("axon_msi: irq 0x%x setup for axon_msi\n", virq); 406 pr_devel("axon_msi: irq 0x%x setup for axon_msi\n", virq);
407 407
408 /* Enable the MSIC hardware */ 408 /* Enable the MSIC hardware */
409 msic_dcr_write(msic, MSIC_BASE_ADDR_HI_REG, msic->fifo_phys >> 32); 409 msic_dcr_write(msic, MSIC_BASE_ADDR_HI_REG, msic->fifo_phys >> 32);
@@ -484,13 +484,13 @@ void axon_msi_debug_setup(struct device_node *dn, struct axon_msic *msic)
484 484
485 addr = of_translate_address(dn, of_get_property(dn, "reg", NULL)); 485 addr = of_translate_address(dn, of_get_property(dn, "reg", NULL));
486 if (addr == OF_BAD_ADDR) { 486 if (addr == OF_BAD_ADDR) {
487 pr_debug("axon_msi: couldn't translate reg property\n"); 487 pr_devel("axon_msi: couldn't translate reg property\n");
488 return; 488 return;
489 } 489 }
490 490
491 msic->trigger = ioremap(addr, 0x4); 491 msic->trigger = ioremap(addr, 0x4);
492 if (!msic->trigger) { 492 if (!msic->trigger) {
493 pr_debug("axon_msi: ioremap failed\n"); 493 pr_devel("axon_msi: ioremap failed\n");
494 return; 494 return;
495 } 495 }
496 496
@@ -498,7 +498,7 @@ void axon_msi_debug_setup(struct device_node *dn, struct axon_msic *msic)
498 498
499 if (!debugfs_create_file(name, 0600, powerpc_debugfs_root, 499 if (!debugfs_create_file(name, 0600, powerpc_debugfs_root,
500 msic, &fops_msic)) { 500 msic, &fops_msic)) {
501 pr_debug("axon_msi: debugfs_create_file failed!\n"); 501 pr_devel("axon_msi: debugfs_create_file failed!\n");
502 return; 502 return;
503 } 503 }
504} 504}
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index 9046803c8276..bc97fada48c6 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -36,7 +36,6 @@
36#include <asm/prom.h> 36#include <asm/prom.h>
37#include <asm/smp.h> 37#include <asm/smp.h>
38#include <asm/paca.h> 38#include <asm/paca.h>
39#include <asm/time.h>
40#include <asm/machdep.h> 39#include <asm/machdep.h>
41#include <asm/cputable.h> 40#include <asm/cputable.h>
42#include <asm/firmware.h> 41#include <asm/firmware.h>
@@ -140,31 +139,6 @@ static void __devinit smp_cell_setup_cpu(int cpu)
140 mtspr(SPRN_DABRX, DABRX_KERNEL | DABRX_USER); 139 mtspr(SPRN_DABRX, DABRX_KERNEL | DABRX_USER);
141} 140}
142 141
143static DEFINE_SPINLOCK(timebase_lock);
144static unsigned long timebase = 0;
145
146static void __devinit cell_give_timebase(void)
147{
148 spin_lock(&timebase_lock);
149 rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
150 timebase = get_tb();
151 spin_unlock(&timebase_lock);
152
153 while (timebase)
154 barrier();
155 rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
156}
157
158static void __devinit cell_take_timebase(void)
159{
160 while (!timebase)
161 barrier();
162 spin_lock(&timebase_lock);
163 set_tb(timebase >> 32, timebase & 0xffffffff);
164 timebase = 0;
165 spin_unlock(&timebase_lock);
166}
167
168static void __devinit smp_cell_kick_cpu(int nr) 142static void __devinit smp_cell_kick_cpu(int nr)
169{ 143{
170 BUG_ON(nr < 0 || nr >= NR_CPUS); 144 BUG_ON(nr < 0 || nr >= NR_CPUS);
@@ -224,8 +198,8 @@ void __init smp_init_cell(void)
224 198
225 /* Non-lpar has additional take/give timebase */ 199 /* Non-lpar has additional take/give timebase */
226 if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) { 200 if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) {
227 smp_ops->give_timebase = cell_give_timebase; 201 smp_ops->give_timebase = rtas_give_timebase;
228 smp_ops->take_timebase = cell_take_timebase; 202 smp_ops->take_timebase = rtas_take_timebase;
229 } 203 }
230 204
231 DBG(" <- smp_init_cell()\n"); 205 DBG(" <- smp_init_cell()\n");
diff --git a/arch/powerpc/platforms/chrp/smp.c b/arch/powerpc/platforms/chrp/smp.c
index 10a4a4d063b6..02cafecc90e3 100644
--- a/arch/powerpc/platforms/chrp/smp.c
+++ b/arch/powerpc/platforms/chrp/smp.c
@@ -26,7 +26,6 @@
26#include <asm/io.h> 26#include <asm/io.h>
27#include <asm/prom.h> 27#include <asm/prom.h>
28#include <asm/smp.h> 28#include <asm/smp.h>
29#include <asm/time.h>
30#include <asm/machdep.h> 29#include <asm/machdep.h>
31#include <asm/mpic.h> 30#include <asm/mpic.h>
32#include <asm/rtas.h> 31#include <asm/rtas.h>
@@ -42,40 +41,12 @@ static void __devinit smp_chrp_setup_cpu(int cpu_nr)
42 mpic_setup_this_cpu(); 41 mpic_setup_this_cpu();
43} 42}
44 43
45static DEFINE_SPINLOCK(timebase_lock);
46static unsigned int timebase_upper = 0, timebase_lower = 0;
47
48void __devinit smp_chrp_give_timebase(void)
49{
50 spin_lock(&timebase_lock);
51 rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
52 timebase_upper = get_tbu();
53 timebase_lower = get_tbl();
54 spin_unlock(&timebase_lock);
55
56 while (timebase_upper || timebase_lower)
57 barrier();
58 rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
59}
60
61void __devinit smp_chrp_take_timebase(void)
62{
63 while (!(timebase_upper || timebase_lower))
64 barrier();
65 spin_lock(&timebase_lock);
66 set_tb(timebase_upper, timebase_lower);
67 timebase_upper = 0;
68 timebase_lower = 0;
69 spin_unlock(&timebase_lock);
70 printk("CPU %i taken timebase\n", smp_processor_id());
71}
72
73/* CHRP with openpic */ 44/* CHRP with openpic */
74struct smp_ops_t chrp_smp_ops = { 45struct smp_ops_t chrp_smp_ops = {
75 .message_pass = smp_mpic_message_pass, 46 .message_pass = smp_mpic_message_pass,
76 .probe = smp_mpic_probe, 47 .probe = smp_mpic_probe,
77 .kick_cpu = smp_chrp_kick_cpu, 48 .kick_cpu = smp_chrp_kick_cpu,
78 .setup_cpu = smp_chrp_setup_cpu, 49 .setup_cpu = smp_chrp_setup_cpu,
79 .give_timebase = smp_chrp_give_timebase, 50 .give_timebase = rtas_give_timebase,
80 .take_timebase = smp_chrp_take_timebase, 51 .take_timebase = rtas_take_timebase,
81}; 52};
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index 153051eb6d93..a4619347aa7e 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -71,20 +71,25 @@ static void pas_restart(char *cmd)
71} 71}
72 72
73#ifdef CONFIG_SMP 73#ifdef CONFIG_SMP
74static DEFINE_SPINLOCK(timebase_lock); 74static raw_spinlock_t timebase_lock;
75static unsigned long timebase; 75static unsigned long timebase;
76 76
77static void __devinit pas_give_timebase(void) 77static void __devinit pas_give_timebase(void)
78{ 78{
79 spin_lock(&timebase_lock); 79 unsigned long flags;
80
81 local_irq_save(flags);
82 hard_irq_disable();
83 __raw_spin_lock(&timebase_lock);
80 mtspr(SPRN_TBCTL, TBCTL_FREEZE); 84 mtspr(SPRN_TBCTL, TBCTL_FREEZE);
81 isync(); 85 isync();
82 timebase = get_tb(); 86 timebase = get_tb();
83 spin_unlock(&timebase_lock); 87 __raw_spin_unlock(&timebase_lock);
84 88
85 while (timebase) 89 while (timebase)
86 barrier(); 90 barrier();
87 mtspr(SPRN_TBCTL, TBCTL_RESTART); 91 mtspr(SPRN_TBCTL, TBCTL_RESTART);
92 local_irq_restore(flags);
88} 93}
89 94
90static void __devinit pas_take_timebase(void) 95static void __devinit pas_take_timebase(void)
@@ -92,10 +97,10 @@ static void __devinit pas_take_timebase(void)
92 while (!timebase) 97 while (!timebase)
93 smp_rmb(); 98 smp_rmb();
94 99
95 spin_lock(&timebase_lock); 100 __raw_spin_lock(&timebase_lock);
96 set_tb(timebase >> 32, timebase & 0xffffffff); 101 set_tb(timebase >> 32, timebase & 0xffffffff);
97 timebase = 0; 102 timebase = 0;
98 spin_unlock(&timebase_lock); 103 __raw_spin_unlock(&timebase_lock);
99} 104}
100 105
101struct smp_ops_t pas_smp_ops = { 106struct smp_ops_t pas_smp_ops = {
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c
index 22ecfbe7183d..708c75133377 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_64.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_64.c
@@ -251,7 +251,7 @@ static void g5_pfunc_switch_volt(int speed_mode)
251static struct pmf_function *pfunc_cpu_setfreq_high; 251static struct pmf_function *pfunc_cpu_setfreq_high;
252static struct pmf_function *pfunc_cpu_setfreq_low; 252static struct pmf_function *pfunc_cpu_setfreq_low;
253static struct pmf_function *pfunc_cpu_getfreq; 253static struct pmf_function *pfunc_cpu_getfreq;
254static struct pmf_function *pfunc_slewing_done;; 254static struct pmf_function *pfunc_slewing_done;
255 255
256static int g5_pfunc_switch_freq(int speed_mode) 256static int g5_pfunc_switch_freq(int speed_mode)
257{ 257{
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index dce736349107..d212006a5b3c 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -609,7 +609,7 @@ static int pmacpic_find_viaint(void)
609 np = of_find_node_by_name(NULL, "via-pmu"); 609 np = of_find_node_by_name(NULL, "via-pmu");
610 if (np == NULL) 610 if (np == NULL)
611 goto not_found; 611 goto not_found;
612 viaint = irq_of_parse_and_map(np, 0);; 612 viaint = irq_of_parse_and_map(np, 0);
613 613
614not_found: 614not_found:
615#endif /* CONFIG_ADB_PMU */ 615#endif /* CONFIG_ADB_PMU */
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 86f69a4eb49b..c20522656367 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -103,11 +103,6 @@ unsigned long smu_cmdbuf_abs;
103EXPORT_SYMBOL(smu_cmdbuf_abs); 103EXPORT_SYMBOL(smu_cmdbuf_abs);
104#endif 104#endif
105 105
106#ifdef CONFIG_SMP
107extern struct smp_ops_t psurge_smp_ops;
108extern struct smp_ops_t core99_smp_ops;
109#endif /* CONFIG_SMP */
110
111static void pmac_show_cpuinfo(struct seq_file *m) 106static void pmac_show_cpuinfo(struct seq_file *m)
112{ 107{
113 struct device_node *np; 108 struct device_node *np;
@@ -341,34 +336,6 @@ static void __init pmac_setup_arch(void)
341 ROOT_DEV = DEFAULT_ROOT_DEVICE; 336 ROOT_DEV = DEFAULT_ROOT_DEVICE;
342#endif 337#endif
343 338
344#ifdef CONFIG_SMP
345 /* Check for Core99 */
346 ic = of_find_node_by_name(NULL, "uni-n");
347 if (!ic)
348 ic = of_find_node_by_name(NULL, "u3");
349 if (!ic)
350 ic = of_find_node_by_name(NULL, "u4");
351 if (ic) {
352 of_node_put(ic);
353 smp_ops = &core99_smp_ops;
354 }
355#ifdef CONFIG_PPC32
356 else {
357 /*
358 * We have to set bits in cpu_possible_map here since the
359 * secondary CPU(s) aren't in the device tree, and
360 * setup_per_cpu_areas only allocates per-cpu data for
361 * CPUs in the cpu_possible_map.
362 */
363 int cpu;
364
365 for (cpu = 1; cpu < 4 && cpu < NR_CPUS; ++cpu)
366 cpu_set(cpu, cpu_possible_map);
367 smp_ops = &psurge_smp_ops;
368 }
369#endif
370#endif /* CONFIG_SMP */
371
372#ifdef CONFIG_ADB 339#ifdef CONFIG_ADB
373 if (strstr(cmd_line, "adb_sync")) { 340 if (strstr(cmd_line, "adb_sync")) {
374 extern int __adb_probe_sync; 341 extern int __adb_probe_sync;
@@ -512,6 +479,14 @@ static void __init pmac_init_early(void)
512#ifdef CONFIG_PPC64 479#ifdef CONFIG_PPC64
513 iommu_init_early_dart(); 480 iommu_init_early_dart();
514#endif 481#endif
482
483 /* SMP Init has to be done early as we need to patch up
484 * cpu_possible_map before interrupt stacks are allocated
485 * or kaboom...
486 */
487#ifdef CONFIG_SMP
488 pmac_setup_smp();
489#endif
515} 490}
516 491
517static int __init pmac_declare_of_platform_devices(void) 492static int __init pmac_declare_of_platform_devices(void)
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index cf1dbe758890..6d4da7b46b41 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -64,10 +64,11 @@
64extern void __secondary_start_pmac_0(void); 64extern void __secondary_start_pmac_0(void);
65extern int pmac_pfunc_base_install(void); 65extern int pmac_pfunc_base_install(void);
66 66
67#ifdef CONFIG_PPC32 67static void (*pmac_tb_freeze)(int freeze);
68static u64 timebase;
69static int tb_req;
68 70
69/* Sync flag for HW tb sync */ 71#ifdef CONFIG_PPC32
70static volatile int sec_tb_reset = 0;
71 72
72/* 73/*
73 * Powersurge (old powermac SMP) support. 74 * Powersurge (old powermac SMP) support.
@@ -294,6 +295,9 @@ static int __init smp_psurge_probe(void)
294 psurge_quad_init(); 295 psurge_quad_init();
295 /* All released cards using this HW design have 4 CPUs */ 296 /* All released cards using this HW design have 4 CPUs */
296 ncpus = 4; 297 ncpus = 4;
298 /* No sure how timebase sync works on those, let's use SW */
299 smp_ops->give_timebase = smp_generic_give_timebase;
300 smp_ops->take_timebase = smp_generic_take_timebase;
297 } else { 301 } else {
298 iounmap(quad_base); 302 iounmap(quad_base);
299 if ((in_8(hhead_base + HHEAD_CONFIG) & 0x02) == 0) { 303 if ((in_8(hhead_base + HHEAD_CONFIG) & 0x02) == 0) {
@@ -308,18 +312,15 @@ static int __init smp_psurge_probe(void)
308 psurge_start = ioremap(PSURGE_START, 4); 312 psurge_start = ioremap(PSURGE_START, 4);
309 psurge_pri_intr = ioremap(PSURGE_PRI_INTR, 4); 313 psurge_pri_intr = ioremap(PSURGE_PRI_INTR, 4);
310 314
311 /* 315 /* This is necessary because OF doesn't know about the
312 * This is necessary because OF doesn't know about the
313 * secondary cpu(s), and thus there aren't nodes in the 316 * secondary cpu(s), and thus there aren't nodes in the
314 * device tree for them, and smp_setup_cpu_maps hasn't 317 * device tree for them, and smp_setup_cpu_maps hasn't
315 * set their bits in cpu_possible_map and cpu_present_map. 318 * set their bits in cpu_present_map.
316 */ 319 */
317 if (ncpus > NR_CPUS) 320 if (ncpus > NR_CPUS)
318 ncpus = NR_CPUS; 321 ncpus = NR_CPUS;
319 for (i = 1; i < ncpus ; ++i) { 322 for (i = 1; i < ncpus ; ++i)
320 cpu_set(i, cpu_present_map); 323 cpu_set(i, cpu_present_map);
321 set_hard_smp_processor_id(i, i);
322 }
323 324
324 if (ppc_md.progress) ppc_md.progress("smp_psurge_probe - done", 0x352); 325 if (ppc_md.progress) ppc_md.progress("smp_psurge_probe - done", 0x352);
325 326
@@ -329,8 +330,14 @@ static int __init smp_psurge_probe(void)
329static void __init smp_psurge_kick_cpu(int nr) 330static void __init smp_psurge_kick_cpu(int nr)
330{ 331{
331 unsigned long start = __pa(__secondary_start_pmac_0) + nr * 8; 332 unsigned long start = __pa(__secondary_start_pmac_0) + nr * 8;
332 unsigned long a; 333 unsigned long a, flags;
333 int i; 334 int i, j;
335
336 /* Defining this here is evil ... but I prefer hiding that
337 * crap to avoid giving people ideas that they can do the
338 * same.
339 */
340 extern volatile unsigned int cpu_callin_map[NR_CPUS];
334 341
335 /* may need to flush here if secondary bats aren't setup */ 342 /* may need to flush here if secondary bats aren't setup */
336 for (a = KERNELBASE; a < KERNELBASE + 0x800000; a += 32) 343 for (a = KERNELBASE; a < KERNELBASE + 0x800000; a += 32)
@@ -339,47 +346,52 @@ static void __init smp_psurge_kick_cpu(int nr)
339 346
340 if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu", 0x353); 347 if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu", 0x353);
341 348
349 /* This is going to freeze the timeebase, we disable interrupts */
350 local_irq_save(flags);
351
342 out_be32(psurge_start, start); 352 out_be32(psurge_start, start);
343 mb(); 353 mb();
344 354
345 psurge_set_ipi(nr); 355 psurge_set_ipi(nr);
356
346 /* 357 /*
347 * We can't use udelay here because the timebase is now frozen. 358 * We can't use udelay here because the timebase is now frozen.
348 */ 359 */
349 for (i = 0; i < 2000; ++i) 360 for (i = 0; i < 2000; ++i)
350 barrier(); 361 asm volatile("nop" : : : "memory");
351 psurge_clr_ipi(nr); 362 psurge_clr_ipi(nr);
352 363
353 if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu - done", 0x354); 364 /*
354} 365 * Also, because the timebase is frozen, we must not return to the
355 366 * caller which will try to do udelay's etc... Instead, we wait -here-
356/* 367 * for the CPU to callin.
357 * With the dual-cpu powersurge board, the decrementers and timebases 368 */
358 * of both cpus are frozen after the secondary cpu is started up, 369 for (i = 0; i < 100000 && !cpu_callin_map[nr]; ++i) {
359 * until we give the secondary cpu another interrupt. This routine 370 for (j = 1; j < 10000; j++)
360 * uses this to get the timebases synchronized. 371 asm volatile("nop" : : : "memory");
361 * -- paulus. 372 asm volatile("sync" : : : "memory");
362 */ 373 }
363static void __init psurge_dual_sync_tb(int cpu_nr) 374 if (!cpu_callin_map[nr])
364{ 375 goto stuck;
365 int t; 376
366 377 /* And we do the TB sync here too for standard dual CPU cards */
367 set_dec(tb_ticks_per_jiffy); 378 if (psurge_type == PSURGE_DUAL) {
368 /* XXX fixme */ 379 while(!tb_req)
369 set_tb(0, 0); 380 barrier();
370 381 tb_req = 0;
371 if (cpu_nr > 0) { 382 mb();
383 timebase = get_tb();
384 mb();
385 while (timebase)
386 barrier();
372 mb(); 387 mb();
373 sec_tb_reset = 1;
374 return;
375 } 388 }
389 stuck:
390 /* now interrupt the secondary, restarting both TBs */
391 if (psurge_type == PSURGE_DUAL)
392 psurge_set_ipi(1);
376 393
377 /* wait for the secondary to have reset its TB before proceeding */ 394 if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu - done", 0x354);
378 for (t = 10000000; t > 0 && !sec_tb_reset; --t)
379 ;
380
381 /* now interrupt the secondary, starting both TBs */
382 psurge_set_ipi(1);
383} 395}
384 396
385static struct irqaction psurge_irqaction = { 397static struct irqaction psurge_irqaction = {
@@ -390,36 +402,35 @@ static struct irqaction psurge_irqaction = {
390 402
391static void __init smp_psurge_setup_cpu(int cpu_nr) 403static void __init smp_psurge_setup_cpu(int cpu_nr)
392{ 404{
405 if (cpu_nr != 0)
406 return;
393 407
394 if (cpu_nr == 0) { 408 /* reset the entry point so if we get another intr we won't
395 /* If we failed to start the second CPU, we should still 409 * try to startup again */
396 * send it an IPI to start the timebase & DEC or we might 410 out_be32(psurge_start, 0x100);
397 * have them stuck. 411 if (setup_irq(30, &psurge_irqaction))
398 */ 412 printk(KERN_ERR "Couldn't get primary IPI interrupt");
399 if (num_online_cpus() < 2) {
400 if (psurge_type == PSURGE_DUAL)
401 psurge_set_ipi(1);
402 return;
403 }
404 /* reset the entry point so if we get another intr we won't
405 * try to startup again */
406 out_be32(psurge_start, 0x100);
407 if (setup_irq(30, &psurge_irqaction))
408 printk(KERN_ERR "Couldn't get primary IPI interrupt");
409 }
410
411 if (psurge_type == PSURGE_DUAL)
412 psurge_dual_sync_tb(cpu_nr);
413} 413}
414 414
415void __init smp_psurge_take_timebase(void) 415void __init smp_psurge_take_timebase(void)
416{ 416{
417 /* Dummy implementation */ 417 if (psurge_type != PSURGE_DUAL)
418 return;
419
420 tb_req = 1;
421 mb();
422 while (!timebase)
423 barrier();
424 mb();
425 set_tb(timebase >> 32, timebase & 0xffffffff);
426 timebase = 0;
427 mb();
428 set_dec(tb_ticks_per_jiffy/2);
418} 429}
419 430
420void __init smp_psurge_give_timebase(void) 431void __init smp_psurge_give_timebase(void)
421{ 432{
422 /* Dummy implementation */ 433 /* Nothing to do here */
423} 434}
424 435
425/* PowerSurge-style Macs */ 436/* PowerSurge-style Macs */
@@ -437,9 +448,6 @@ struct smp_ops_t psurge_smp_ops = {
437 * Core 99 and later support 448 * Core 99 and later support
438 */ 449 */
439 450
440static void (*pmac_tb_freeze)(int freeze);
441static u64 timebase;
442static int tb_req;
443 451
444static void smp_core99_give_timebase(void) 452static void smp_core99_give_timebase(void)
445{ 453{
@@ -478,7 +486,6 @@ static void __devinit smp_core99_take_timebase(void)
478 set_tb(timebase >> 32, timebase & 0xffffffff); 486 set_tb(timebase >> 32, timebase & 0xffffffff);
479 timebase = 0; 487 timebase = 0;
480 mb(); 488 mb();
481 set_dec(tb_ticks_per_jiffy/2);
482 489
483 local_irq_restore(flags); 490 local_irq_restore(flags);
484} 491}
@@ -920,3 +927,34 @@ struct smp_ops_t core99_smp_ops = {
920# endif 927# endif
921#endif 928#endif
922}; 929};
930
931void __init pmac_setup_smp(void)
932{
933 struct device_node *np;
934
935 /* Check for Core99 */
936 np = of_find_node_by_name(NULL, "uni-n");
937 if (!np)
938 np = of_find_node_by_name(NULL, "u3");
939 if (!np)
940 np = of_find_node_by_name(NULL, "u4");
941 if (np) {
942 of_node_put(np);
943 smp_ops = &core99_smp_ops;
944 }
945#ifdef CONFIG_PPC32
946 else {
947 /* We have to set bits in cpu_possible_map here since the
948 * secondary CPU(s) aren't in the device tree. Various
949 * things won't be initialized for CPUs not in the possible
950 * map, so we really need to fix it up here.
951 */
952 int cpu;
953
954 for (cpu = 1; cpu < 4 && cpu < NR_CPUS; ++cpu)
955 cpu_set(cpu, cpu_possible_map);
956 smp_ops = &psurge_smp_ops;
957 }
958#endif /* CONFIG_PPC32 */
959}
960
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index 9fead0faf38b..3f763c5284ac 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -284,7 +284,6 @@ static int ps3_sb_free_mmio_region(struct ps3_mmio_region *r)
284 int result; 284 int result;
285 285
286 dump_mmio_region(r); 286 dump_mmio_region(r);
287;
288 result = lv1_unmap_device_mmio_region(r->dev->bus_id, r->dev->dev_id, 287 result = lv1_unmap_device_mmio_region(r->dev->bus_id, r->dev->dev_id,
289 r->lpar_addr); 288 r->lpar_addr);
290 289
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index e3139fa5e556..903eb9eec687 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -286,7 +286,7 @@ static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
286 unsigned long hpte_v, hpte_r; 286 unsigned long hpte_v, hpte_r;
287 287
288 if (!(vflags & HPTE_V_BOLTED)) 288 if (!(vflags & HPTE_V_BOLTED))
289 pr_debug("hpte_insert(group=%lx, va=%016lx, pa=%016lx, " 289 pr_devel("hpte_insert(group=%lx, va=%016lx, pa=%016lx, "
290 "rflags=%lx, vflags=%lx, psize=%d)\n", 290 "rflags=%lx, vflags=%lx, psize=%d)\n",
291 hpte_group, va, pa, rflags, vflags, psize); 291 hpte_group, va, pa, rflags, vflags, psize);
292 292
@@ -294,7 +294,7 @@ static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
294 hpte_r = hpte_encode_r(pa, psize) | rflags; 294 hpte_r = hpte_encode_r(pa, psize) | rflags;
295 295
296 if (!(vflags & HPTE_V_BOLTED)) 296 if (!(vflags & HPTE_V_BOLTED))
297 pr_debug(" hpte_v=%016lx, hpte_r=%016lx\n", hpte_v, hpte_r); 297 pr_devel(" hpte_v=%016lx, hpte_r=%016lx\n", hpte_v, hpte_r);
298 298
299 /* Now fill in the actual HPTE */ 299 /* Now fill in the actual HPTE */
300 /* Set CEC cookie to 0 */ 300 /* Set CEC cookie to 0 */
@@ -311,7 +311,7 @@ static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
311 lpar_rc = plpar_pte_enter(flags, hpte_group, hpte_v, hpte_r, &slot); 311 lpar_rc = plpar_pte_enter(flags, hpte_group, hpte_v, hpte_r, &slot);
312 if (unlikely(lpar_rc == H_PTEG_FULL)) { 312 if (unlikely(lpar_rc == H_PTEG_FULL)) {
313 if (!(vflags & HPTE_V_BOLTED)) 313 if (!(vflags & HPTE_V_BOLTED))
314 pr_debug(" full\n"); 314 pr_devel(" full\n");
315 return -1; 315 return -1;
316 } 316 }
317 317
@@ -322,11 +322,11 @@ static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
322 */ 322 */
323 if (unlikely(lpar_rc != H_SUCCESS)) { 323 if (unlikely(lpar_rc != H_SUCCESS)) {
324 if (!(vflags & HPTE_V_BOLTED)) 324 if (!(vflags & HPTE_V_BOLTED))
325 pr_debug(" lpar err %lu\n", lpar_rc); 325 pr_devel(" lpar err %lu\n", lpar_rc);
326 return -2; 326 return -2;
327 } 327 }
328 if (!(vflags & HPTE_V_BOLTED)) 328 if (!(vflags & HPTE_V_BOLTED))
329 pr_debug(" -> slot: %lu\n", slot & 7); 329 pr_devel(" -> slot: %lu\n", slot & 7);
330 330
331 /* Because of iSeries, we have to pass down the secondary 331 /* Because of iSeries, we have to pass down the secondary
332 * bucket bit here as well 332 * bucket bit here as well
@@ -418,17 +418,17 @@ static long pSeries_lpar_hpte_updatepp(unsigned long slot,
418 418
419 want_v = hpte_encode_avpn(va, psize, ssize); 419 want_v = hpte_encode_avpn(va, psize, ssize);
420 420
421 pr_debug(" update: avpnv=%016lx, hash=%016lx, f=%lx, psize: %d ...", 421 pr_devel(" update: avpnv=%016lx, hash=%016lx, f=%lx, psize: %d ...",
422 want_v, slot, flags, psize); 422 want_v, slot, flags, psize);
423 423
424 lpar_rc = plpar_pte_protect(flags, slot, want_v); 424 lpar_rc = plpar_pte_protect(flags, slot, want_v);
425 425
426 if (lpar_rc == H_NOT_FOUND) { 426 if (lpar_rc == H_NOT_FOUND) {
427 pr_debug("not found !\n"); 427 pr_devel("not found !\n");
428 return -1; 428 return -1;
429 } 429 }
430 430
431 pr_debug("ok\n"); 431 pr_devel("ok\n");
432 432
433 BUG_ON(lpar_rc != H_SUCCESS); 433 BUG_ON(lpar_rc != H_SUCCESS);
434 434
@@ -503,7 +503,7 @@ static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long va,
503 unsigned long lpar_rc; 503 unsigned long lpar_rc;
504 unsigned long dummy1, dummy2; 504 unsigned long dummy1, dummy2;
505 505
506 pr_debug(" inval : slot=%lx, va=%016lx, psize: %d, local: %d\n", 506 pr_devel(" inval : slot=%lx, va=%016lx, psize: %d, local: %d\n",
507 slot, va, psize, local); 507 slot, va, psize, local);
508 508
509 want_v = hpte_encode_avpn(va, psize, ssize); 509 want_v = hpte_encode_avpn(va, psize, ssize);
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 1a231c389ba0..1f8f6cfb94f7 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -35,7 +35,6 @@
35#include <asm/prom.h> 35#include <asm/prom.h>
36#include <asm/smp.h> 36#include <asm/smp.h>
37#include <asm/paca.h> 37#include <asm/paca.h>
38#include <asm/time.h>
39#include <asm/machdep.h> 38#include <asm/machdep.h>
40#include <asm/cputable.h> 39#include <asm/cputable.h>
41#include <asm/firmware.h> 40#include <asm/firmware.h>
@@ -118,31 +117,6 @@ static void __devinit smp_xics_setup_cpu(int cpu)
118} 117}
119#endif /* CONFIG_XICS */ 118#endif /* CONFIG_XICS */
120 119
121static DEFINE_SPINLOCK(timebase_lock);
122static unsigned long timebase = 0;
123
124static void __devinit pSeries_give_timebase(void)
125{
126 spin_lock(&timebase_lock);
127 rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
128 timebase = get_tb();
129 spin_unlock(&timebase_lock);
130
131 while (timebase)
132 barrier();
133 rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
134}
135
136static void __devinit pSeries_take_timebase(void)
137{
138 while (!timebase)
139 barrier();
140 spin_lock(&timebase_lock);
141 set_tb(timebase >> 32, timebase & 0xffffffff);
142 timebase = 0;
143 spin_unlock(&timebase_lock);
144}
145
146static void __devinit smp_pSeries_kick_cpu(int nr) 120static void __devinit smp_pSeries_kick_cpu(int nr)
147{ 121{
148 BUG_ON(nr < 0 || nr >= NR_CPUS); 122 BUG_ON(nr < 0 || nr >= NR_CPUS);
@@ -209,8 +183,8 @@ static void __init smp_init_pseries(void)
209 183
210 /* Non-lpar has additional take/give timebase */ 184 /* Non-lpar has additional take/give timebase */
211 if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) { 185 if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) {
212 smp_ops->give_timebase = pSeries_give_timebase; 186 smp_ops->give_timebase = rtas_give_timebase;
213 smp_ops->take_timebase = pSeries_take_timebase; 187 smp_ops->take_timebase = rtas_take_timebase;
214 } 188 }
215 189
216 pr_debug(" <- smp_init_pSeries()\n"); 190 pr_debug(" <- smp_init_pSeries()\n");
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index be3581a8c294..419f8a637ffe 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -190,10 +190,10 @@ static void xics_unmask_irq(unsigned int virq)
190 int call_status; 190 int call_status;
191 int server; 191 int server;
192 192
193 pr_debug("xics: unmask virq %d\n", virq); 193 pr_devel("xics: unmask virq %d\n", virq);
194 194
195 irq = (unsigned int)irq_map[virq].hwirq; 195 irq = (unsigned int)irq_map[virq].hwirq;
196 pr_debug(" -> map to hwirq 0x%x\n", irq); 196 pr_devel(" -> map to hwirq 0x%x\n", irq);
197 if (irq == XICS_IPI || irq == XICS_IRQ_SPURIOUS) 197 if (irq == XICS_IPI || irq == XICS_IRQ_SPURIOUS)
198 return; 198 return;
199 199
@@ -252,7 +252,7 @@ static void xics_mask_irq(unsigned int virq)
252{ 252{
253 unsigned int irq; 253 unsigned int irq;
254 254
255 pr_debug("xics: mask virq %d\n", virq); 255 pr_devel("xics: mask virq %d\n", virq);
256 256
257 irq = (unsigned int)irq_map[virq].hwirq; 257 irq = (unsigned int)irq_map[virq].hwirq;
258 if (irq == XICS_IPI || irq == XICS_IRQ_SPURIOUS) 258 if (irq == XICS_IPI || irq == XICS_IRQ_SPURIOUS)
@@ -414,7 +414,7 @@ static int xics_host_match(struct irq_host *h, struct device_node *node)
414static int xics_host_map(struct irq_host *h, unsigned int virq, 414static int xics_host_map(struct irq_host *h, unsigned int virq,
415 irq_hw_number_t hw) 415 irq_hw_number_t hw)
416{ 416{
417 pr_debug("xics: map virq %d, hwirq 0x%lx\n", virq, hw); 417 pr_devel("xics: map virq %d, hwirq 0x%lx\n", virq, hw);
418 418
419 /* Insert the interrupt mapping into the radix tree for fast lookup */ 419 /* Insert the interrupt mapping into the radix tree for fast lookup */
420 irq_radix_revmap_insert(xics_host, virq, hw); 420 irq_radix_revmap_insert(xics_host, virq, hw);
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 39db9d1155d2..cbb3bed75d3c 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -965,7 +965,7 @@ static inline void fsl_rio_info(struct device *dev, u32 ccsr)
965 break; 965 break;
966 default: 966 default:
967 str = "Unknown"; 967 str = "Unknown";
968 break;; 968 break;
969 } 969 }
970 dev_info(dev, "Hardware port width: %s\n", str); 970 dev_info(dev, "Hardware port width: %s\n", str);
971 971
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index a86d3ce01ead..69e2630c9062 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -728,12 +728,10 @@ struct ipic * __init ipic_init(struct device_node *node, unsigned int flags)
728 if (ret) 728 if (ret)
729 return NULL; 729 return NULL;
730 730
731 ipic = alloc_bootmem(sizeof(struct ipic)); 731 ipic = kzalloc(sizeof(*ipic), GFP_KERNEL);
732 if (ipic == NULL) 732 if (ipic == NULL)
733 return NULL; 733 return NULL;
734 734
735 memset(ipic, 0, sizeof(struct ipic));
736
737 ipic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR, 735 ipic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
738 NR_IPIC_INTS, 736 NR_IPIC_INTS,
739 &ipic_host_ops, 0); 737 &ipic_host_ops, 0);
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 9c3af5045495..3981ae4cb58e 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -279,28 +279,29 @@ static void _mpic_map_mmio(struct mpic *mpic, phys_addr_t phys_addr,
279} 279}
280 280
281#ifdef CONFIG_PPC_DCR 281#ifdef CONFIG_PPC_DCR
282static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb, 282static void _mpic_map_dcr(struct mpic *mpic, struct device_node *node,
283 struct mpic_reg_bank *rb,
283 unsigned int offset, unsigned int size) 284 unsigned int offset, unsigned int size)
284{ 285{
285 const u32 *dbasep; 286 const u32 *dbasep;
286 287
287 dbasep = of_get_property(mpic->irqhost->of_node, "dcr-reg", NULL); 288 dbasep = of_get_property(node, "dcr-reg", NULL);
288 289
289 rb->dhost = dcr_map(mpic->irqhost->of_node, *dbasep + offset, size); 290 rb->dhost = dcr_map(node, *dbasep + offset, size);
290 BUG_ON(!DCR_MAP_OK(rb->dhost)); 291 BUG_ON(!DCR_MAP_OK(rb->dhost));
291} 292}
292 293
293static inline void mpic_map(struct mpic *mpic, phys_addr_t phys_addr, 294static inline void mpic_map(struct mpic *mpic, struct device_node *node,
294 struct mpic_reg_bank *rb, unsigned int offset, 295 phys_addr_t phys_addr, struct mpic_reg_bank *rb,
295 unsigned int size) 296 unsigned int offset, unsigned int size)
296{ 297{
297 if (mpic->flags & MPIC_USES_DCR) 298 if (mpic->flags & MPIC_USES_DCR)
298 _mpic_map_dcr(mpic, rb, offset, size); 299 _mpic_map_dcr(mpic, node, rb, offset, size);
299 else 300 else
300 _mpic_map_mmio(mpic, phys_addr, rb, offset, size); 301 _mpic_map_mmio(mpic, phys_addr, rb, offset, size);
301} 302}
302#else /* CONFIG_PPC_DCR */ 303#else /* CONFIG_PPC_DCR */
303#define mpic_map(m,p,b,o,s) _mpic_map_mmio(m,p,b,o,s) 304#define mpic_map(m,n,p,b,o,s) _mpic_map_mmio(m,p,b,o,s)
304#endif /* !CONFIG_PPC_DCR */ 305#endif /* !CONFIG_PPC_DCR */
305 306
306 307
@@ -507,9 +508,8 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
507 printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n"); 508 printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n");
508 509
509 /* Allocate fixups array */ 510 /* Allocate fixups array */
510 mpic->fixups = alloc_bootmem(128 * sizeof(struct mpic_irq_fixup)); 511 mpic->fixups = kzalloc(128 * sizeof(*mpic->fixups), GFP_KERNEL);
511 BUG_ON(mpic->fixups == NULL); 512 BUG_ON(mpic->fixups == NULL);
512 memset(mpic->fixups, 0, 128 * sizeof(struct mpic_irq_fixup));
513 513
514 /* Init spinlock */ 514 /* Init spinlock */
515 spin_lock_init(&mpic->fixup_lock); 515 spin_lock_init(&mpic->fixup_lock);
@@ -1052,11 +1052,10 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1052 int intvec_top; 1052 int intvec_top;
1053 u64 paddr = phys_addr; 1053 u64 paddr = phys_addr;
1054 1054
1055 mpic = alloc_bootmem(sizeof(struct mpic)); 1055 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL);
1056 if (mpic == NULL) 1056 if (mpic == NULL)
1057 return NULL; 1057 return NULL;
1058 1058
1059 memset(mpic, 0, sizeof(struct mpic));
1060 mpic->name = name; 1059 mpic->name = name;
1061 1060
1062 mpic->hc_irq = mpic_irq_chip; 1061 mpic->hc_irq = mpic_irq_chip;
@@ -1109,9 +1108,8 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1109 psize /= 4; 1108 psize /= 4;
1110 bits = intvec_top + 1; 1109 bits = intvec_top + 1;
1111 mapsize = BITS_TO_LONGS(bits) * sizeof(unsigned long); 1110 mapsize = BITS_TO_LONGS(bits) * sizeof(unsigned long);
1112 mpic->protected = alloc_bootmem(mapsize); 1111 mpic->protected = kzalloc(mapsize, GFP_KERNEL);
1113 BUG_ON(mpic->protected == NULL); 1112 BUG_ON(mpic->protected == NULL);
1114 memset(mpic->protected, 0, mapsize);
1115 for (i = 0; i < psize; i++) { 1113 for (i = 0; i < psize; i++) {
1116 if (psrc[i] > intvec_top) 1114 if (psrc[i] > intvec_top)
1117 continue; 1115 continue;
@@ -1152,8 +1150,8 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1152 } 1150 }
1153 1151
1154 /* Map the global registers */ 1152 /* Map the global registers */
1155 mpic_map(mpic, paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000); 1153 mpic_map(mpic, node, paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
1156 mpic_map(mpic, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000); 1154 mpic_map(mpic, node, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
1157 1155
1158 /* Reset */ 1156 /* Reset */
1159 if (flags & MPIC_WANTS_RESET) { 1157 if (flags & MPIC_WANTS_RESET) {
@@ -1194,7 +1192,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1194 1192
1195 /* Map the per-CPU registers */ 1193 /* Map the per-CPU registers */
1196 for (i = 0; i < mpic->num_cpus; i++) { 1194 for (i = 0; i < mpic->num_cpus; i++) {
1197 mpic_map(mpic, paddr, &mpic->cpuregs[i], 1195 mpic_map(mpic, node, paddr, &mpic->cpuregs[i],
1198 MPIC_INFO(CPU_BASE) + i * MPIC_INFO(CPU_STRIDE), 1196 MPIC_INFO(CPU_BASE) + i * MPIC_INFO(CPU_STRIDE),
1199 0x1000); 1197 0x1000);
1200 } 1198 }
@@ -1202,7 +1200,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1202 /* Initialize main ISU if none provided */ 1200 /* Initialize main ISU if none provided */
1203 if (mpic->isu_size == 0) { 1201 if (mpic->isu_size == 0) {
1204 mpic->isu_size = mpic->num_sources; 1202 mpic->isu_size = mpic->num_sources;
1205 mpic_map(mpic, paddr, &mpic->isus[0], 1203 mpic_map(mpic, node, paddr, &mpic->isus[0],
1206 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size); 1204 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
1207 } 1205 }
1208 mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1); 1206 mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
@@ -1256,8 +1254,10 @@ void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
1256 1254
1257 BUG_ON(isu_num >= MPIC_MAX_ISU); 1255 BUG_ON(isu_num >= MPIC_MAX_ISU);
1258 1256
1259 mpic_map(mpic, paddr, &mpic->isus[isu_num], 0, 1257 mpic_map(mpic, mpic->irqhost->of_node,
1258 paddr, &mpic->isus[isu_num], 0,
1260 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size); 1259 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
1260
1261 if ((isu_first + mpic->isu_size) > mpic->num_sources) 1261 if ((isu_first + mpic->isu_size) > mpic->num_sources)
1262 mpic->num_sources = isu_first + mpic->isu_size; 1262 mpic->num_sources = isu_first + mpic->isu_size;
1263} 1263}
@@ -1351,7 +1351,8 @@ void __init mpic_init(struct mpic *mpic)
1351 1351
1352#ifdef CONFIG_PM 1352#ifdef CONFIG_PM
1353 /* allocate memory to save mpic state */ 1353 /* allocate memory to save mpic state */
1354 mpic->save_data = alloc_bootmem(mpic->num_sources * sizeof(struct mpic_irq_save)); 1354 mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data),
1355 GFP_KERNEL);
1355 BUG_ON(mpic->save_data == NULL); 1356 BUG_ON(mpic->save_data == NULL);
1356#endif 1357#endif
1357} 1358}
diff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/sysdev/ppc4xx_pci.c
index daefc93ddffe..6ff9d71b4c0d 100644
--- a/arch/powerpc/sysdev/ppc4xx_pci.c
+++ b/arch/powerpc/sysdev/ppc4xx_pci.c
@@ -1531,7 +1531,7 @@ static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port,
1531 */ 1531 */
1532 1532
1533 /* Calculate window size */ 1533 /* Calculate window size */
1534 sa = (0xffffffffffffffffull << ilog2(ep_size));; 1534 sa = (0xffffffffffffffffull << ilog2(ep_size));
1535 1535
1536 /* Setup BAR0 */ 1536 /* Setup BAR0 */
1537 out_le32(mbase + PECFG_BAR0HMPA, RES_TO_U32_HIGH(sa)); 1537 out_le32(mbase + PECFG_BAR0HMPA, RES_TO_U32_HIGH(sa));
@@ -1550,7 +1550,7 @@ static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port,
1550 out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(ep_addr)); 1550 out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(ep_addr));
1551 } else { 1551 } else {
1552 /* Calculate window size */ 1552 /* Calculate window size */
1553 sa = (0xffffffffffffffffull << ilog2(size));; 1553 sa = (0xffffffffffffffffull << ilog2(size));
1554 if (res->flags & IORESOURCE_PREFETCH) 1554 if (res->flags & IORESOURCE_PREFETCH)
1555 sa |= 0x8; 1555 sa |= 0x8;
1556 1556
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index b28b0e512d67..237e3654f48c 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -112,6 +112,7 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)
112{ 112{
113 unsigned long flags; 113 unsigned long flags;
114 u8 mcn_shift = 0, dev_shift = 0; 114 u8 mcn_shift = 0, dev_shift = 0;
115 u32 ret;
115 116
116 spin_lock_irqsave(&qe_lock, flags); 117 spin_lock_irqsave(&qe_lock, flags);
117 if (cmd == QE_RESET) { 118 if (cmd == QE_RESET) {
@@ -139,11 +140,13 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)
139 } 140 }
140 141
141 /* wait for the QE_CR_FLG to clear */ 142 /* wait for the QE_CR_FLG to clear */
142 while(in_be32(&qe_immr->cp.cecr) & QE_CR_FLG) 143 ret = spin_event_timeout((in_be32(&qe_immr->cp.cecr) & QE_CR_FLG) == 0,
143 cpu_relax(); 144 100, 0);
145 /* On timeout (e.g. failure), the expression will be false (ret == 0),
146 otherwise it will be true (ret == 1). */
144 spin_unlock_irqrestore(&qe_lock, flags); 147 spin_unlock_irqrestore(&qe_lock, flags);
145 148
146 return 0; 149 return ret == 1;
147} 150}
148EXPORT_SYMBOL(qe_issue_cmd); 151EXPORT_SYMBOL(qe_issue_cmd);
149 152
diff --git a/arch/powerpc/sysdev/qe_lib/qe_ic.c b/arch/powerpc/sysdev/qe_lib/qe_ic.c
index 63cdf9887f36..074905c3ee5a 100644
--- a/arch/powerpc/sysdev/qe_lib/qe_ic.c
+++ b/arch/powerpc/sysdev/qe_lib/qe_ic.c
@@ -333,12 +333,10 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags,
333 if (ret) 333 if (ret)
334 return; 334 return;
335 335
336 qe_ic = alloc_bootmem(sizeof(struct qe_ic)); 336 qe_ic = kzalloc(sizeof(*qe_ic), GFP_KERNEL);
337 if (qe_ic == NULL) 337 if (qe_ic == NULL)
338 return; 338 return;
339 339
340 memset(qe_ic, 0, sizeof(struct qe_ic));
341
342 qe_ic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR, 340 qe_ic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
343 NR_QE_IC_INTS, &qe_ic_host_ops, 0); 341 NR_QE_IC_INTS, &qe_ic_host_ops, 0);
344 if (qe_ic->irqhost == NULL) 342 if (qe_ic->irqhost == NULL)
diff --git a/arch/powerpc/sysdev/uic.c b/arch/powerpc/sysdev/uic.c
index d35405c59434..466ce9ace127 100644
--- a/arch/powerpc/sysdev/uic.c
+++ b/arch/powerpc/sysdev/uic.c
@@ -258,11 +258,10 @@ static struct uic * __init uic_init_one(struct device_node *node)
258 258
259 BUG_ON(! of_device_is_compatible(node, "ibm,uic")); 259 BUG_ON(! of_device_is_compatible(node, "ibm,uic"));
260 260
261 uic = alloc_bootmem(sizeof(*uic)); 261 uic = kzalloc(sizeof(*uic), GFP_KERNEL);
262 if (! uic) 262 if (! uic)
263 return NULL; /* FIXME: panic? */ 263 return NULL; /* FIXME: panic? */
264 264
265 memset(uic, 0, sizeof(*uic));
266 spin_lock_init(&uic->lock); 265 spin_lock_init(&uic->lock);
267 indexp = of_get_property(node, "cell-index", &len); 266 indexp = of_get_property(node, "cell-index", &len);
268 if (!indexp || (len != sizeof(u32))) { 267 if (!indexp || (len != sizeof(u32))) {
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index e577839f3073..2ae5d72f47ed 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -95,6 +95,11 @@ config S390
95 select HAVE_ARCH_TRACEHOOK 95 select HAVE_ARCH_TRACEHOOK
96 select INIT_ALL_POSSIBLE 96 select INIT_ALL_POSSIBLE
97 select HAVE_PERF_COUNTERS 97 select HAVE_PERF_COUNTERS
98 select GENERIC_ATOMIC64 if !64BIT
99
100config SCHED_OMIT_FRAME_POINTER
101 bool
102 default y
98 103
99source "init/Kconfig" 104source "init/Kconfig"
100 105
@@ -116,6 +121,9 @@ config 32BIT
116 bool 121 bool
117 default y if !64BIT 122 default y if !64BIT
118 123
124config KTIME_SCALAR
125 def_bool 32BIT
126
119config SMP 127config SMP
120 bool "Symmetric multi-processing support" 128 bool "Symmetric multi-processing support"
121 ---help--- 129 ---help---
diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
index fca9dffcc669..c7d0abfb0f00 100644
--- a/arch/s390/include/asm/atomic.h
+++ b/arch/s390/include/asm/atomic.h
@@ -268,7 +268,12 @@ static __inline__ int atomic64_add_unless(atomic64_t *v,
268#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) 268#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
269 269
270#undef __CSG_LOOP 270#undef __CSG_LOOP
271#endif 271
272#else /* __s390x__ */
273
274#include <asm-generic/atomic64.h>
275
276#endif /* __s390x__ */
272 277
273#define smp_mb__before_atomic_dec() smp_mb() 278#define smp_mb__before_atomic_dec() smp_mb()
274#define smp_mb__after_atomic_dec() smp_mb() 279#define smp_mb__after_atomic_dec() smp_mb()
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index a27d0d5a6f86..1cd02f6073a0 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -99,7 +99,9 @@ struct kvm_s390_sie_block {
99 __u8 reservedd0[48]; /* 0x00d0 */ 99 __u8 reservedd0[48]; /* 0x00d0 */
100 __u64 gcr[16]; /* 0x0100 */ 100 __u64 gcr[16]; /* 0x0100 */
101 __u64 gbea; /* 0x0180 */ 101 __u64 gbea; /* 0x0180 */
102 __u8 reserved188[120]; /* 0x0188 */ 102 __u8 reserved188[24]; /* 0x0188 */
103 __u32 fac; /* 0x01a0 */
104 __u8 reserved1a4[92]; /* 0x01a4 */
103} __attribute__((packed)); 105} __attribute__((packed));
104 106
105struct kvm_vcpu_stat { 107struct kvm_vcpu_stat {
diff --git a/arch/s390/include/asm/perf_counter.h b/arch/s390/include/asm/perf_counter.h
index a7205a3828cb..7015188c2cc2 100644
--- a/arch/s390/include/asm/perf_counter.h
+++ b/arch/s390/include/asm/perf_counter.h
@@ -6,3 +6,5 @@
6 6
7static inline void set_perf_counter_pending(void) {} 7static inline void set_perf_counter_pending(void) {}
8static inline void clear_perf_counter_pending(void) {} 8static inline void clear_perf_counter_pending(void) {}
9
10#define PERF_COUNTER_INDEX_OFFSET 0
diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h
index 925bcc649035..ba1cab9fc1f9 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -61,7 +61,7 @@ struct thread_info {
61 .exec_domain = &default_exec_domain, \ 61 .exec_domain = &default_exec_domain, \
62 .flags = 0, \ 62 .flags = 0, \
63 .cpu = 0, \ 63 .cpu = 0, \
64 .preempt_count = 1, \ 64 .preempt_count = INIT_PREEMPT_COUNT, \
65 .restart_block = { \ 65 .restart_block = { \
66 .fn = do_no_restart_syscall, \ 66 .fn = do_no_restart_syscall, \
67 }, \ 67 }, \
diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
index d2f270c995d9..db943a7ec513 100644
--- a/arch/s390/kernel/dis.c
+++ b/arch/s390/kernel/dis.c
@@ -15,7 +15,6 @@
15#include <linux/timer.h> 15#include <linux/timer.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/smp_lock.h>
19#include <linux/init.h> 18#include <linux/init.h>
20#include <linux/interrupt.h> 19#include <linux/interrupt.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index b8bf4b140065..371a2d88f4ac 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -70,6 +70,7 @@ struct shutdown_action {
70 char *name; 70 char *name;
71 void (*fn) (struct shutdown_trigger *trigger); 71 void (*fn) (struct shutdown_trigger *trigger);
72 int (*init) (void); 72 int (*init) (void);
73 int init_rc;
73}; 74};
74 75
75static char *ipl_type_str(enum ipl_type type) 76static char *ipl_type_str(enum ipl_type type)
@@ -1486,11 +1487,13 @@ static int set_trigger(const char *buf, struct shutdown_trigger *trigger,
1486 int i; 1487 int i;
1487 1488
1488 for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) { 1489 for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
1489 if (!shutdown_actions_list[i])
1490 continue;
1491 if (sysfs_streq(buf, shutdown_actions_list[i]->name)) { 1490 if (sysfs_streq(buf, shutdown_actions_list[i]->name)) {
1492 trigger->action = shutdown_actions_list[i]; 1491 if (shutdown_actions_list[i]->init_rc) {
1493 return len; 1492 return shutdown_actions_list[i]->init_rc;
1493 } else {
1494 trigger->action = shutdown_actions_list[i];
1495 return len;
1496 }
1494 } 1497 }
1495 } 1498 }
1496 return -EINVAL; 1499 return -EINVAL;
@@ -1640,8 +1643,8 @@ static void __init shutdown_actions_init(void)
1640 for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) { 1643 for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
1641 if (!shutdown_actions_list[i]->init) 1644 if (!shutdown_actions_list[i]->init)
1642 continue; 1645 continue;
1643 if (shutdown_actions_list[i]->init()) 1646 shutdown_actions_list[i]->init_rc =
1644 shutdown_actions_list[i] = NULL; 1647 shutdown_actions_list[i]->init();
1645 } 1648 }
1646} 1649}
1647 1650
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 490b39934d65..43acd73105b7 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -26,7 +26,6 @@
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/smp.h> 28#include <linux/smp.h>
29#include <linux/smp_lock.h>
30#include <linux/errno.h> 29#include <linux/errno.h>
31#include <linux/ptrace.h> 30#include <linux/ptrace.h>
32#include <linux/user.h> 31#include <linux/user.h>
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index c18b21d6991c..90d9d1ba258b 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -25,6 +25,7 @@
25#include <asm/lowcore.h> 25#include <asm/lowcore.h>
26#include <asm/pgtable.h> 26#include <asm/pgtable.h>
27#include <asm/nmi.h> 27#include <asm/nmi.h>
28#include <asm/system.h>
28#include "kvm-s390.h" 29#include "kvm-s390.h"
29#include "gaccess.h" 30#include "gaccess.h"
30 31
@@ -69,6 +70,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
69 { NULL } 70 { NULL }
70}; 71};
71 72
73static unsigned long long *facilities;
72 74
73/* Section: not file related */ 75/* Section: not file related */
74void kvm_arch_hardware_enable(void *garbage) 76void kvm_arch_hardware_enable(void *garbage)
@@ -288,6 +290,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
288 vcpu->arch.sie_block->gmsor = vcpu->kvm->arch.guest_origin; 290 vcpu->arch.sie_block->gmsor = vcpu->kvm->arch.guest_origin;
289 vcpu->arch.sie_block->ecb = 2; 291 vcpu->arch.sie_block->ecb = 2;
290 vcpu->arch.sie_block->eca = 0xC1002001U; 292 vcpu->arch.sie_block->eca = 0xC1002001U;
293 vcpu->arch.sie_block->fac = (int) (long) facilities;
291 hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS); 294 hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
292 tasklet_init(&vcpu->arch.tasklet, kvm_s390_tasklet, 295 tasklet_init(&vcpu->arch.tasklet, kvm_s390_tasklet,
293 (unsigned long) vcpu); 296 (unsigned long) vcpu);
@@ -739,11 +742,29 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
739 742
740static int __init kvm_s390_init(void) 743static int __init kvm_s390_init(void)
741{ 744{
742 return kvm_init(NULL, sizeof(struct kvm_vcpu), THIS_MODULE); 745 int ret;
746 ret = kvm_init(NULL, sizeof(struct kvm_vcpu), THIS_MODULE);
747 if (ret)
748 return ret;
749
750 /*
751 * guests can ask for up to 255+1 double words, we need a full page
752 * to hold the maximum amount of facilites. On the other hand, we
753 * only set facilities that are known to work in KVM.
754 */
755 facilities = (unsigned long long *) get_zeroed_page(GFP_DMA);
756 if (!facilities) {
757 kvm_exit();
758 return -ENOMEM;
759 }
760 stfle(facilities, 1);
761 facilities[0] &= 0xff00fff3f0700000ULL;
762 return 0;
743} 763}
744 764
745static void __exit kvm_s390_exit(void) 765static void __exit kvm_s390_exit(void)
746{ 766{
767 free_page((unsigned long) facilities);
747 kvm_exit(); 768 kvm_exit();
748} 769}
749 770
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 93ecd06e1a74..d426aac8095d 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -158,7 +158,7 @@ static int handle_stfl(struct kvm_vcpu *vcpu)
158 158
159 vcpu->stat.instruction_stfl++; 159 vcpu->stat.instruction_stfl++;
160 /* only pass the facility bits, which we can handle */ 160 /* only pass the facility bits, which we can handle */
161 facility_list &= 0xfe00fff3; 161 facility_list &= 0xff00fff3;
162 162
163 rc = copy_to_guest(vcpu, offsetof(struct _lowcore, stfl_fac_list), 163 rc = copy_to_guest(vcpu, offsetof(struct _lowcore, stfl_fac_list),
164 &facility_list, sizeof(facility_list)); 164 &facility_list, sizeof(facility_list));
diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile
index ab6735df2d21..97975ec7a274 100644
--- a/arch/s390/lib/Makefile
+++ b/arch/s390/lib/Makefile
@@ -3,6 +3,6 @@
3# 3#
4 4
5lib-y += delay.o string.o uaccess_std.o uaccess_pt.o 5lib-y += delay.o string.o uaccess_std.o uaccess_pt.o
6obj-$(CONFIG_32BIT) += div64.o qrnnd.o 6obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o
7lib-$(CONFIG_64BIT) += uaccess_mvcos.o 7lib-$(CONFIG_64BIT) += uaccess_mvcos.o
8lib-$(CONFIG_SMP) += spinlock.o 8lib-$(CONFIG_SMP) += spinlock.o
diff --git a/arch/s390/lib/delay.c b/arch/s390/lib/delay.c
index 3f5f680726ed..97c1eca83cc2 100644
--- a/arch/s390/lib/delay.c
+++ b/arch/s390/lib/delay.c
@@ -36,9 +36,11 @@ static void __udelay_disabled(unsigned long usecs)
36 cr0 = (cr0_saved & 0xffff00e0) | 0x00000800; 36 cr0 = (cr0_saved & 0xffff00e0) | 0x00000800;
37 __ctl_load(cr0 , 0, 0); 37 __ctl_load(cr0 , 0, 0);
38 mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT; 38 mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT;
39 lockdep_off();
39 trace_hardirqs_on(); 40 trace_hardirqs_on();
40 __load_psw_mask(mask); 41 __load_psw_mask(mask);
41 local_irq_disable(); 42 local_irq_disable();
43 lockdep_on();
42 __ctl_load(cr0_saved, 0, 0); 44 __ctl_load(cr0_saved, 0, 0);
43 local_tick_enable(clock_saved); 45 local_tick_enable(clock_saved);
44 set_clock_comparator(S390_lowcore.clock_comparator); 46 set_clock_comparator(S390_lowcore.clock_comparator);
diff --git a/arch/s390/lib/ucmpdi2.c b/arch/s390/lib/ucmpdi2.c
new file mode 100644
index 000000000000..3e05ff532582
--- /dev/null
+++ b/arch/s390/lib/ucmpdi2.c
@@ -0,0 +1,26 @@
1#include <linux/module.h>
2
3union ull_union {
4 unsigned long long ull;
5 struct {
6 unsigned int high;
7 unsigned int low;
8 } ui;
9};
10
11int __ucmpdi2(unsigned long long a, unsigned long long b)
12{
13 union ull_union au = {.ull = a};
14 union ull_union bu = {.ull = b};
15
16 if (au.ui.high < bu.ui.high)
17 return 0;
18 else if (au.ui.high > bu.ui.high)
19 return 2;
20 if (au.ui.low < bu.ui.low)
21 return 0;
22 else if (au.ui.low > bu.ui.low)
23 return 2;
24 return 1;
25}
26EXPORT_SYMBOL(__ucmpdi2);
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 74eb26bf1970..e5e119fe03b2 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -22,7 +22,6 @@
22#include <linux/compat.h> 22#include <linux/compat.h>
23#include <linux/smp.h> 23#include <linux/smp.h>
24#include <linux/kdebug.h> 24#include <linux/kdebug.h>
25#include <linux/smp_lock.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/console.h> 26#include <linux/console.h>
28#include <linux/module.h> 27#include <linux/module.h>
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index 8ece0b5bd028..39224b57c6ef 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -61,10 +61,6 @@ config EARLY_PRINTK
61 select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using 61 select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using
62 the kernel command line option to toggle back and forth. 62 the kernel command line option to toggle back and forth.
63 63
64config DEBUG_BOOTMEM
65 depends on DEBUG_KERNEL
66 bool "Debug BOOTMEM initialization"
67
68config DEBUG_STACKOVERFLOW 64config DEBUG_STACKOVERFLOW
69 bool "Check for stack overflows" 65 bool "Check for stack overflows"
70 depends on DEBUG_KERNEL && SUPERH32 66 depends on DEBUG_KERNEL && SUPERH32
diff --git a/arch/sh/boards/mach-se/7206/io.c b/arch/sh/boards/mach-se/7206/io.c
index 9c3a33210d61..180455642a43 100644
--- a/arch/sh/boards/mach-se/7206/io.c
+++ b/arch/sh/boards/mach-se/7206/io.c
@@ -50,7 +50,7 @@ unsigned char se7206_inb_p(unsigned long port)
50 50
51unsigned short se7206_inw(unsigned long port) 51unsigned short se7206_inw(unsigned long port)
52{ 52{
53 return *port2adr(port);; 53 return *port2adr(port);
54} 54}
55 55
56void se7206_outb(unsigned char value, unsigned long port) 56void se7206_outb(unsigned char value, unsigned long port)
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index 9cd04bd558b8..8fed45a2fb85 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -19,10 +19,13 @@
19#include <linux/smc91x.h> 19#include <linux/smc91x.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/input.h> 21#include <linux/input.h>
22#include <linux/usb/r8a66597.h>
22#include <video/sh_mobile_lcdc.h> 23#include <video/sh_mobile_lcdc.h>
23#include <media/sh_mobile_ceu.h> 24#include <media/sh_mobile_ceu.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include <asm/heartbeat.h> 26#include <asm/heartbeat.h>
27#include <asm/sh_eth.h>
28#include <asm/clock.h>
26#include <asm/sh_keysc.h> 29#include <asm/sh_keysc.h>
27#include <cpu/sh7724.h> 30#include <cpu/sh7724.h>
28#include <mach-se/mach/se7724.h> 31#include <mach-se/mach/se7724.h>
@@ -272,6 +275,62 @@ static struct platform_device keysc_device = {
272 }, 275 },
273}; 276};
274 277
278/* SH Eth */
279static struct resource sh_eth_resources[] = {
280 [0] = {
281 .start = SH_ETH_ADDR,
282 .end = SH_ETH_ADDR + 0x1FC,
283 .flags = IORESOURCE_MEM,
284 },
285 [1] = {
286 .start = 91,
287 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
288 },
289};
290
291struct sh_eth_plat_data sh_eth_plat = {
292 .phy = 0x1f, /* SMSC LAN8187 */
293 .edmac_endian = EDMAC_LITTLE_ENDIAN,
294};
295
296static struct platform_device sh_eth_device = {
297 .name = "sh-eth",
298 .id = 0,
299 .dev = {
300 .platform_data = &sh_eth_plat,
301 },
302 .num_resources = ARRAY_SIZE(sh_eth_resources),
303 .resource = sh_eth_resources,
304};
305
306static struct r8a66597_platdata sh7724_usb0_host_data = {
307};
308
309static struct resource sh7724_usb0_host_resources[] = {
310 [0] = {
311 .start = 0xa4d80000,
312 .end = 0xa4d800ff,
313 .flags = IORESOURCE_MEM,
314 },
315 [1] = {
316 .start = 65,
317 .end = 65,
318 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
319 },
320};
321
322static struct platform_device sh7724_usb0_host_device = {
323 .name = "r8a66597_hcd",
324 .id = 0,
325 .dev = {
326 .dma_mask = NULL, /* not use dma */
327 .coherent_dma_mask = 0xffffffff,
328 .platform_data = &sh7724_usb0_host_data,
329 },
330 .num_resources = ARRAY_SIZE(sh7724_usb0_host_resources),
331 .resource = sh7724_usb0_host_resources,
332};
333
275static struct platform_device *ms7724se_devices[] __initdata = { 334static struct platform_device *ms7724se_devices[] __initdata = {
276 &heartbeat_device, 335 &heartbeat_device,
277 &smc91x_eth_device, 336 &smc91x_eth_device,
@@ -280,11 +339,62 @@ static struct platform_device *ms7724se_devices[] __initdata = {
280 &ceu0_device, 339 &ceu0_device,
281 &ceu1_device, 340 &ceu1_device,
282 &keysc_device, 341 &keysc_device,
342 &sh_eth_device,
343 &sh7724_usb0_host_device,
283}; 344};
284 345
346#define EEPROM_OP 0xBA206000
347#define EEPROM_ADR 0xBA206004
348#define EEPROM_DATA 0xBA20600C
349#define EEPROM_STAT 0xBA206010
350#define EEPROM_STRT 0xBA206014
351static int __init sh_eth_is_eeprom_ready(void)
352{
353 int t = 10000;
354
355 while (t--) {
356 if (!ctrl_inw(EEPROM_STAT))
357 return 1;
358 cpu_relax();
359 }
360
361 printk(KERN_ERR "ms7724se can not access to eeprom\n");
362 return 0;
363}
364
365static void __init sh_eth_init(void)
366{
367 int i;
368 u16 mac[3];
369
370 /* check EEPROM status */
371 if (!sh_eth_is_eeprom_ready())
372 return;
373
374 /* read MAC addr from EEPROM */
375 for (i = 0 ; i < 3 ; i++) {
376 ctrl_outw(0x0, EEPROM_OP); /* read */
377 ctrl_outw(i*2, EEPROM_ADR);
378 ctrl_outw(0x1, EEPROM_STRT);
379 if (!sh_eth_is_eeprom_ready())
380 return;
381
382 mac[i] = ctrl_inw(EEPROM_DATA);
383 mac[i] = ((mac[i] & 0xFF) << 8) | (mac[i] >> 8); /* swap */
384 }
385
386 /* reset sh-eth */
387 ctrl_outl(0x1, SH_ETH_ADDR + 0x0);
388
389 /* set MAC addr */
390 ctrl_outl(((mac[0] << 16) | (mac[1])), SH_ETH_MAHR);
391 ctrl_outl((mac[2]), SH_ETH_MALR);
392}
393
285#define SW4140 0xBA201000 394#define SW4140 0xBA201000
286#define FPGA_OUT 0xBA200400 395#define FPGA_OUT 0xBA200400
287#define PORT_HIZA 0xA4050158 396#define PORT_HIZA 0xA4050158
397#define PORT_MSELCRB 0xA4050182
288 398
289#define SW41_A 0x0100 399#define SW41_A 0x0100
290#define SW41_B 0x0200 400#define SW41_B 0x0200
@@ -294,6 +404,7 @@ static struct platform_device *ms7724se_devices[] __initdata = {
294#define SW41_F 0x2000 404#define SW41_F 0x2000
295#define SW41_G 0x4000 405#define SW41_G 0x4000
296#define SW41_H 0x8000 406#define SW41_H 0x8000
407
297static int __init devices_setup(void) 408static int __init devices_setup(void)
298{ 409{
299 u16 sw = ctrl_inw(SW4140); /* select camera, monitor */ 410 u16 sw = ctrl_inw(SW4140); /* select camera, monitor */
@@ -302,9 +413,16 @@ static int __init devices_setup(void)
302 ctrl_outw(ctrl_inw(FPGA_OUT) & 413 ctrl_outw(ctrl_inw(FPGA_OUT) &
303 ~((1 << 1) | /* LAN */ 414 ~((1 << 1) | /* LAN */
304 (1 << 6) | /* VIDEO DAC */ 415 (1 << 6) | /* VIDEO DAC */
305 (1 << 12)), /* USB0 */ 416 (1 << 12) | /* USB0 */
417 (1 << 14)), /* RMII */
306 FPGA_OUT); 418 FPGA_OUT);
307 419
420 /* turn on USB clocks, use external clock */
421 ctrl_outw((ctrl_inw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB);
422
423 /* enable USB0 port */
424 ctrl_outw(0x0600, 0xa40501d4);
425
308 /* enable IRQ 0,1,2 */ 426 /* enable IRQ 0,1,2 */
309 gpio_request(GPIO_FN_INTC_IRQ0, NULL); 427 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
310 gpio_request(GPIO_FN_INTC_IRQ1, NULL); 428 gpio_request(GPIO_FN_INTC_IRQ1, NULL);
@@ -374,7 +492,7 @@ static int __init devices_setup(void)
374 gpio_request(GPIO_FN_VIO0_CLK, NULL); 492 gpio_request(GPIO_FN_VIO0_CLK, NULL);
375 gpio_request(GPIO_FN_VIO0_FLD, NULL); 493 gpio_request(GPIO_FN_VIO0_FLD, NULL);
376 gpio_request(GPIO_FN_VIO0_HD, NULL); 494 gpio_request(GPIO_FN_VIO0_HD, NULL);
377 platform_resource_setup_memory(&ceu0_device, "ceu", 4 << 20); 495 platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
378 496
379 /* enable CEU1 */ 497 /* enable CEU1 */
380 gpio_request(GPIO_FN_VIO1_D7, NULL); 498 gpio_request(GPIO_FN_VIO1_D7, NULL);
@@ -389,7 +507,7 @@ static int __init devices_setup(void)
389 gpio_request(GPIO_FN_VIO1_HD, NULL); 507 gpio_request(GPIO_FN_VIO1_HD, NULL);
390 gpio_request(GPIO_FN_VIO1_VD, NULL); 508 gpio_request(GPIO_FN_VIO1_VD, NULL);
391 gpio_request(GPIO_FN_VIO1_CLK, NULL); 509 gpio_request(GPIO_FN_VIO1_CLK, NULL);
392 platform_resource_setup_memory(&ceu1_device, "ceu", 4 << 20); 510 platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
393 511
394 /* KEYSC */ 512 /* KEYSC */
395 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL); 513 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
@@ -404,6 +522,28 @@ static int __init devices_setup(void)
404 gpio_request(GPIO_FN_KEYOUT1, NULL); 522 gpio_request(GPIO_FN_KEYOUT1, NULL);
405 gpio_request(GPIO_FN_KEYOUT0, NULL); 523 gpio_request(GPIO_FN_KEYOUT0, NULL);
406 524
525 /*
526 * enable SH-Eth
527 *
528 * please remove J33 pin from your board !!
529 *
530 * ms7724 board should not use GPIO_FN_LNKSTA pin
531 * So, This time PTX5 is set to input pin
532 */
533 gpio_request(GPIO_FN_RMII_RXD0, NULL);
534 gpio_request(GPIO_FN_RMII_RXD1, NULL);
535 gpio_request(GPIO_FN_RMII_TXD0, NULL);
536 gpio_request(GPIO_FN_RMII_TXD1, NULL);
537 gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
538 gpio_request(GPIO_FN_RMII_TX_EN, NULL);
539 gpio_request(GPIO_FN_RMII_RX_ER, NULL);
540 gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
541 gpio_request(GPIO_FN_MDIO, NULL);
542 gpio_request(GPIO_FN_MDC, NULL);
543 gpio_request(GPIO_PTX5, NULL);
544 gpio_direction_input(GPIO_PTX5);
545 sh_eth_init();
546
407 if (sw & SW41_B) { 547 if (sw & SW41_B) {
408 /* SVGA */ 548 /* SVGA */
409 lcdc_info.ch[0].lcd_cfg.xres = 800; 549 lcdc_info.ch[0].lcd_cfg.xres = 800;
@@ -437,7 +577,7 @@ static int __init devices_setup(void)
437 } 577 }
438 578
439 return platform_add_devices(ms7724se_devices, 579 return platform_add_devices(ms7724se_devices,
440 ARRAY_SIZE(ms7724se_devices)); 580 ARRAY_SIZE(ms7724se_devices));
441} 581}
442device_initcall(devices_setup); 582device_initcall(devices_setup);
443 583
diff --git a/arch/sh/configs/migor_defconfig b/arch/sh/configs/migor_defconfig
index da627d22c009..b18cfd39cac6 100644
--- a/arch/sh/configs/migor_defconfig
+++ b/arch/sh/configs/migor_defconfig
@@ -309,7 +309,7 @@ CONFIG_ZERO_PAGE_OFFSET=0x00001000
309CONFIG_BOOT_LINK_OFFSET=0x00800000 309CONFIG_BOOT_LINK_OFFSET=0x00800000
310CONFIG_ENTRY_OFFSET=0x00001000 310CONFIG_ENTRY_OFFSET=0x00001000
311CONFIG_CMDLINE_BOOL=y 311CONFIG_CMDLINE_BOOL=y
312CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ip=on root=/dev/nfs ip=dhcp" 312CONFIG_CMDLINE="console=tty0 console=ttySC0,115200 earlyprintk=serial ip=on root=/dev/nfs ip=dhcp"
313 313
314# 314#
315# Bus options 315# Bus options
@@ -858,7 +858,35 @@ CONFIG_VIDEO_SH_MOBILE_CEU=y
858# 858#
859# CONFIG_VGASTATE is not set 859# CONFIG_VGASTATE is not set
860# CONFIG_VIDEO_OUTPUT_CONTROL is not set 860# CONFIG_VIDEO_OUTPUT_CONTROL is not set
861# CONFIG_FB is not set 861CONFIG_FB=y
862# CONFIG_FIRMWARE_EDID is not set
863# CONFIG_FB_DDC is not set
864# CONFIG_FB_BOOT_VESA_SUPPORT is not set
865# CONFIG_FB_CFB_FILLRECT is not set
866# CONFIG_FB_CFB_COPYAREA is not set
867# CONFIG_FB_CFB_IMAGEBLIT is not set
868# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
869CONFIG_FB_SYS_FILLRECT=y
870CONFIG_FB_SYS_COPYAREA=y
871CONFIG_FB_SYS_IMAGEBLIT=y
872# CONFIG_FB_FOREIGN_ENDIAN is not set
873CONFIG_FB_SYS_FOPS=y
874CONFIG_FB_DEFERRED_IO=y
875# CONFIG_FB_SVGALIB is not set
876# CONFIG_FB_MACMODES is not set
877# CONFIG_FB_BACKLIGHT is not set
878# CONFIG_FB_MODE_HELPERS is not set
879# CONFIG_FB_TILEBLITTING is not set
880
881#
882# Frame buffer hardware drivers
883#
884# CONFIG_FB_S1D13XXX is not set
885CONFIG_FB_SH_MOBILE_LCDC=y
886# CONFIG_FB_VIRTUAL is not set
887# CONFIG_FB_METRONOME is not set
888# CONFIG_FB_MB862XX is not set
889# CONFIG_FB_BROADSHEET is not set
862# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 890# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
863 891
864# 892#
@@ -870,6 +898,27 @@ CONFIG_VIDEO_SH_MOBILE_CEU=y
870# Console display driver support 898# Console display driver support
871# 899#
872CONFIG_DUMMY_CONSOLE=y 900CONFIG_DUMMY_CONSOLE=y
901CONFIG_FRAMEBUFFER_CONSOLE=y
902CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
903# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
904CONFIG_FONTS=y
905# CONFIG_FONT_8x8 is not set
906# CONFIG_FONT_8x16 is not set
907# CONFIG_FONT_6x11 is not set
908# CONFIG_FONT_7x14 is not set
909# CONFIG_FONT_PEARL_8x8 is not set
910# CONFIG_FONT_ACORN_8x8 is not set
911CONFIG_FONT_MINI_4x6=y
912# CONFIG_FONT_SUN8x16 is not set
913# CONFIG_FONT_SUN12x22 is not set
914# CONFIG_FONT_10x18 is not set
915CONFIG_LOGO=y
916# CONFIG_LOGO_LINUX_MONO is not set
917# CONFIG_LOGO_LINUX_VGA16 is not set
918# CONFIG_LOGO_LINUX_CLUT224 is not set
919# CONFIG_LOGO_SUPERH_MONO is not set
920CONFIG_LOGO_SUPERH_VGA16=y
921# CONFIG_LOGO_SUPERH_CLUT224 is not set
873# CONFIG_SOUND is not set 922# CONFIG_SOUND is not set
874CONFIG_HID_SUPPORT=y 923CONFIG_HID_SUPPORT=y
875CONFIG_HID=y 924CONFIG_HID=y
diff --git a/arch/sh/configs/se7724_defconfig b/arch/sh/configs/se7724_defconfig
index 3840270283e4..3ee783a0a075 100644
--- a/arch/sh/configs/se7724_defconfig
+++ b/arch/sh/configs/se7724_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30 3# Linux kernel version: 2.6.30
4# Thu Jun 18 16:09:05 2009 4# Mon Jun 29 16:28:43 2009
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y 7CONFIG_SUPERH32=y
@@ -14,6 +14,7 @@ CONFIG_GENERIC_HWEIGHT=y
14CONFIG_GENERIC_HARDIRQS=y 14CONFIG_GENERIC_HARDIRQS=y
15CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 15CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
16CONFIG_GENERIC_IRQ_PROBE=y 16CONFIG_GENERIC_IRQ_PROBE=y
17CONFIG_IRQ_PER_CPU=y
17CONFIG_GENERIC_GPIO=y 18CONFIG_GENERIC_GPIO=y
18CONFIG_GENERIC_TIME=y 19CONFIG_GENERIC_TIME=y
19CONFIG_GENERIC_CLOCKEVENTS=y 20CONFIG_GENERIC_CLOCKEVENTS=y
@@ -28,7 +29,9 @@ CONFIG_HAVE_LATENCYTOP_SUPPORT=y
28# CONFIG_ARCH_HAS_ILOG2_U64 is not set 29# CONFIG_ARCH_HAS_ILOG2_U64 is not set
29CONFIG_ARCH_NO_VIRT_TO_BUS=y 30CONFIG_ARCH_NO_VIRT_TO_BUS=y
30CONFIG_ARCH_HAS_DEFAULT_IDLE=y 31CONFIG_ARCH_HAS_DEFAULT_IDLE=y
32CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
31CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 33CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
34CONFIG_CONSTRUCTORS=y
32 35
33# 36#
34# General setup 37# General setup
@@ -88,10 +91,12 @@ CONFIG_TIMERFD=y
88CONFIG_EVENTFD=y 91CONFIG_EVENTFD=y
89CONFIG_SHMEM=y 92CONFIG_SHMEM=y
90CONFIG_AIO=y 93CONFIG_AIO=y
94CONFIG_HAVE_PERF_COUNTERS=y
91 95
92# 96#
93# Performance Counters 97# Performance Counters
94# 98#
99# CONFIG_PERF_COUNTERS is not set
95CONFIG_VM_EVENT_COUNTERS=y 100CONFIG_VM_EVENT_COUNTERS=y
96# CONFIG_STRIP_ASM_SYMS is not set 101# CONFIG_STRIP_ASM_SYMS is not set
97CONFIG_COMPAT_BRK=y 102CONFIG_COMPAT_BRK=y
@@ -107,6 +112,10 @@ CONFIG_HAVE_KRETPROBES=y
107CONFIG_HAVE_ARCH_TRACEHOOK=y 112CONFIG_HAVE_ARCH_TRACEHOOK=y
108CONFIG_HAVE_CLK=y 113CONFIG_HAVE_CLK=y
109CONFIG_HAVE_DMA_API_DEBUG=y 114CONFIG_HAVE_DMA_API_DEBUG=y
115
116#
117# GCOV-based kernel profiling
118#
110# CONFIG_SLOW_WORK is not set 119# CONFIG_SLOW_WORK is not set
111CONFIG_HAVE_GENERIC_DMA_COHERENT=y 120CONFIG_HAVE_GENERIC_DMA_COHERENT=y
112CONFIG_SLABINFO=y 121CONFIG_SLABINFO=y
@@ -119,7 +128,7 @@ CONFIG_MODULE_UNLOAD=y
119# CONFIG_MODVERSIONS is not set 128# CONFIG_MODVERSIONS is not set
120# CONFIG_MODULE_SRCVERSION_ALL is not set 129# CONFIG_MODULE_SRCVERSION_ALL is not set
121CONFIG_BLOCK=y 130CONFIG_BLOCK=y
122# CONFIG_LBD is not set 131CONFIG_LBDAF=y
123# CONFIG_BLK_DEV_BSG is not set 132# CONFIG_BLK_DEV_BSG is not set
124# CONFIG_BLK_DEV_INTEGRITY is not set 133# CONFIG_BLK_DEV_INTEGRITY is not set
125 134
@@ -584,7 +593,6 @@ CONFIG_SCSI_WAIT_SCAN=m
584# CONFIG_SCSI_SRP_ATTRS is not set 593# CONFIG_SCSI_SRP_ATTRS is not set
585CONFIG_SCSI_LOWLEVEL=y 594CONFIG_SCSI_LOWLEVEL=y
586# CONFIG_ISCSI_TCP is not set 595# CONFIG_ISCSI_TCP is not set
587# CONFIG_SCSI_BNX2_ISCSI is not set
588# CONFIG_LIBFC is not set 596# CONFIG_LIBFC is not set
589# CONFIG_LIBFCOE is not set 597# CONFIG_LIBFCOE is not set
590# CONFIG_SCSI_DEBUG is not set 598# CONFIG_SCSI_DEBUG is not set
@@ -624,7 +632,7 @@ CONFIG_NET_ETHERNET=y
624CONFIG_MII=y 632CONFIG_MII=y
625# CONFIG_AX88796 is not set 633# CONFIG_AX88796 is not set
626# CONFIG_STNIC is not set 634# CONFIG_STNIC is not set
627# CONFIG_SH_ETH is not set 635CONFIG_SH_ETH=y
628CONFIG_SMC91X=y 636CONFIG_SMC91X=y
629# CONFIG_ENC28J60 is not set 637# CONFIG_ENC28J60 is not set
630# CONFIG_ETHOC is not set 638# CONFIG_ETHOC is not set
@@ -801,6 +809,11 @@ CONFIG_SPI_BITBANG=y
801# 809#
802# CONFIG_SPI_SPIDEV is not set 810# CONFIG_SPI_SPIDEV is not set
803# CONFIG_SPI_TLE62X0 is not set 811# CONFIG_SPI_TLE62X0 is not set
812
813#
814# PPS support
815#
816# CONFIG_PPS is not set
804CONFIG_ARCH_REQUIRE_GPIOLIB=y 817CONFIG_ARCH_REQUIRE_GPIOLIB=y
805CONFIG_GPIOLIB=y 818CONFIG_GPIOLIB=y
806# CONFIG_GPIO_SYSFS is not set 819# CONFIG_GPIO_SYSFS is not set
@@ -851,6 +864,8 @@ CONFIG_SSB_POSSIBLE=y
851# CONFIG_MFD_WM8400 is not set 864# CONFIG_MFD_WM8400 is not set
852# CONFIG_MFD_WM8350_I2C is not set 865# CONFIG_MFD_WM8350_I2C is not set
853# CONFIG_MFD_PCF50633 is not set 866# CONFIG_MFD_PCF50633 is not set
867# CONFIG_AB3100_CORE is not set
868# CONFIG_EZX_PCAP is not set
854# CONFIG_REGULATOR is not set 869# CONFIG_REGULATOR is not set
855CONFIG_MEDIA_SUPPORT=y 870CONFIG_MEDIA_SUPPORT=y
856 871
@@ -1196,6 +1211,7 @@ CONFIG_RTC_DRV_PCF8563=y
1196# CONFIG_RTC_DRV_S35390A is not set 1211# CONFIG_RTC_DRV_S35390A is not set
1197# CONFIG_RTC_DRV_FM3130 is not set 1212# CONFIG_RTC_DRV_FM3130 is not set
1198# CONFIG_RTC_DRV_RX8581 is not set 1213# CONFIG_RTC_DRV_RX8581 is not set
1214# CONFIG_RTC_DRV_RX8025 is not set
1199 1215
1200# 1216#
1201# SPI RTC drivers 1217# SPI RTC drivers
@@ -1260,6 +1276,7 @@ CONFIG_FS_MBCACHE=y
1260# CONFIG_JFS_FS is not set 1276# CONFIG_JFS_FS is not set
1261CONFIG_FS_POSIX_ACL=y 1277CONFIG_FS_POSIX_ACL=y
1262# CONFIG_XFS_FS is not set 1278# CONFIG_XFS_FS is not set
1279# CONFIG_GFS2_FS is not set
1263# CONFIG_OCFS2_FS is not set 1280# CONFIG_OCFS2_FS is not set
1264# CONFIG_BTRFS_FS is not set 1281# CONFIG_BTRFS_FS is not set
1265CONFIG_FILE_LOCKING=y 1282CONFIG_FILE_LOCKING=y
diff --git a/arch/sh/include/asm/perf_counter.h b/arch/sh/include/asm/perf_counter.h
index a8153c2aa6fa..d8e6bb9c0ccc 100644
--- a/arch/sh/include/asm/perf_counter.h
+++ b/arch/sh/include/asm/perf_counter.h
@@ -2,6 +2,8 @@
2#define __ASM_SH_PERF_COUNTER_H 2#define __ASM_SH_PERF_COUNTER_H
3 3
4/* SH only supports software counters through this interface. */ 4/* SH only supports software counters through this interface. */
5#define set_perf_counter_pending() do { } while (0) 5static inline void set_perf_counter_pending(void) {}
6
7#define PERF_COUNTER_INDEX_OFFSET 0
6 8
7#endif /* __ASM_SH_PERF_COUNTER_H */ 9#endif /* __ASM_SH_PERF_COUNTER_H */
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h
index 5bc34681d994..6f83f2cc45c1 100644
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/sched.h> 5#include <linux/sched.h>
6#include <linux/err.h>
6#include <asm/ptrace.h> 7#include <asm/ptrace.h>
7 8
8/* The system call number is given by the user in R3 */ 9/* The system call number is given by the user in R3 */
diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h
index f09ac4806294..d570ac2e5cb9 100644
--- a/arch/sh/include/asm/thread_info.h
+++ b/arch/sh/include/asm/thread_info.h
@@ -51,7 +51,7 @@ struct thread_info {
51 .exec_domain = &default_exec_domain, \ 51 .exec_domain = &default_exec_domain, \
52 .flags = 0, \ 52 .flags = 0, \
53 .cpu = 0, \ 53 .cpu = 0, \
54 .preempt_count = 1, \ 54 .preempt_count = INIT_PREEMPT_COUNT, \
55 .addr_limit = KERNEL_DS, \ 55 .addr_limit = KERNEL_DS, \
56 .restart_block = { \ 56 .restart_block = { \
57 .fn = do_no_restart_syscall, \ 57 .fn = do_no_restart_syscall, \
diff --git a/arch/sh/include/mach-se/mach/se7724.h b/arch/sh/include/mach-se/mach/se7724.h
index 74164b60d0db..29514a39d0f5 100644
--- a/arch/sh/include/mach-se/mach/se7724.h
+++ b/arch/sh/include/mach-se/mach/se7724.h
@@ -20,6 +20,11 @@
20 */ 20 */
21#include <asm/addrspace.h> 21#include <asm/addrspace.h>
22 22
23/* SH Eth */
24#define SH_ETH_ADDR (0xA4600000)
25#define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0)
26#define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8)
27
23#define PA_LED (0xba203000) /* 8bit LED */ 28#define PA_LED (0xba203000) /* 8bit LED */
24#define IRQ_MODE (0xba200010) 29#define IRQ_MODE (0xba200010)
25#define IRQ0_SR (0xba200014) 30#define IRQ0_SR (0xba200014)
diff --git a/arch/sh/mm/fault_32.c b/arch/sh/mm/fault_32.c
index cc8ddbdf3d7a..71925946f1e1 100644
--- a/arch/sh/mm/fault_32.c
+++ b/arch/sh/mm/fault_32.c
@@ -15,12 +15,28 @@
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/hardirq.h> 16#include <linux/hardirq.h>
17#include <linux/kprobes.h> 17#include <linux/kprobes.h>
18#include <linux/marker.h> 18#include <linux/perf_counter.h>
19#include <asm/io_trapped.h> 19#include <asm/io_trapped.h>
20#include <asm/system.h> 20#include <asm/system.h>
21#include <asm/mmu_context.h> 21#include <asm/mmu_context.h>
22#include <asm/tlbflush.h> 22#include <asm/tlbflush.h>
23 23
24static inline int notify_page_fault(struct pt_regs *regs, int trap)
25{
26 int ret = 0;
27
28#ifdef CONFIG_KPROBES
29 if (!user_mode(regs)) {
30 preempt_disable();
31 if (kprobe_running() && kprobe_fault_handler(regs, trap))
32 ret = 1;
33 preempt_enable();
34 }
35#endif
36
37 return ret;
38}
39
24/* 40/*
25 * This routine handles page faults. It determines the address, 41 * This routine handles page faults. It determines the address,
26 * and the problem, and then passes it off to one of the appropriate 42 * and the problem, and then passes it off to one of the appropriate
@@ -87,13 +103,16 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
87 return; 103 return;
88 } 104 }
89 105
106 mm = tsk->mm;
107
108 if (unlikely(notify_page_fault(regs, lookup_exception_vector())))
109 return;
110
90 /* Only enable interrupts if they were on before the fault */ 111 /* Only enable interrupts if they were on before the fault */
91 if ((regs->sr & SR_IMASK) != SR_IMASK) { 112 if ((regs->sr & SR_IMASK) != SR_IMASK)
92 trace_hardirqs_on();
93 local_irq_enable(); 113 local_irq_enable();
94 }
95 114
96 mm = tsk->mm; 115 perf_swcounter_event(PERF_COUNT_SW_PAGE_FAULTS, 1, 0, regs, address);
97 116
98 /* 117 /*
99 * If we're in an interrupt or have no user 118 * If we're in an interrupt or have no user
@@ -141,10 +160,15 @@ survive:
141 goto do_sigbus; 160 goto do_sigbus;
142 BUG(); 161 BUG();
143 } 162 }
144 if (fault & VM_FAULT_MAJOR) 163 if (fault & VM_FAULT_MAJOR) {
145 tsk->maj_flt++; 164 tsk->maj_flt++;
146 else 165 perf_swcounter_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0,
166 regs, address);
167 } else {
147 tsk->min_flt++; 168 tsk->min_flt++;
169 perf_swcounter_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0,
170 regs, address);
171 }
148 172
149 up_read(&mm->mmap_sem); 173 up_read(&mm->mmap_sem);
150 return; 174 return;
@@ -245,22 +269,6 @@ do_sigbus:
245 goto no_context; 269 goto no_context;
246} 270}
247 271
248static inline int notify_page_fault(struct pt_regs *regs, int trap)
249{
250 int ret = 0;
251
252#ifdef CONFIG_KPROBES
253 if (!user_mode(regs)) {
254 preempt_disable();
255 if (kprobe_running() && kprobe_fault_handler(regs, trap))
256 ret = 1;
257 preempt_enable();
258 }
259#endif
260
261 return ret;
262}
263
264/* 272/*
265 * Called with interrupts disabled. 273 * Called with interrupts disabled.
266 */ 274 */
@@ -273,12 +281,7 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
273 pmd_t *pmd; 281 pmd_t *pmd;
274 pte_t *pte; 282 pte_t *pte;
275 pte_t entry; 283 pte_t entry;
276 int ret = 0; 284 int ret = 1;
277
278 if (notify_page_fault(regs, lookup_exception_vector()))
279 goto out;
280
281 ret = 1;
282 285
283 /* 286 /*
284 * We don't take page faults for P1, P2, and parts of P4, these 287 * We don't take page faults for P1, P2, and parts of P4, these
diff --git a/arch/sh/mm/tlb-sh3.c b/arch/sh/mm/tlb-sh3.c
index 7fbfd5a11ffa..17cb7c3adf22 100644
--- a/arch/sh/mm/tlb-sh3.c
+++ b/arch/sh/mm/tlb-sh3.c
@@ -18,7 +18,6 @@
18#include <linux/mman.h> 18#include <linux/mman.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/smp.h> 20#include <linux/smp.h>
21#include <linux/smp_lock.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
23 22
24#include <asm/system.h> 23#include <asm/system.h>
diff --git a/arch/sh/mm/tlbflush_64.c b/arch/sh/mm/tlbflush_64.c
index fcbb6e135cef..3ce40ea34824 100644
--- a/arch/sh/mm/tlbflush_64.c
+++ b/arch/sh/mm/tlbflush_64.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2000, 2001 Paolo Alberelli 4 * Copyright (C) 2000, 2001 Paolo Alberelli
5 * Copyright (C) 2003 Richard Curnow (/proc/tlb, bug fixes) 5 * Copyright (C) 2003 Richard Curnow (/proc/tlb, bug fixes)
6 * Copyright (C) 2003 Paul Mundt 6 * Copyright (C) 2003 - 2009 Paul Mundt
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -20,6 +20,7 @@
20#include <linux/mman.h> 20#include <linux/mman.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <linux/perf_counter.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <asm/system.h> 25#include <asm/system.h>
25#include <asm/io.h> 26#include <asm/io.h>
@@ -115,6 +116,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
115 /* Not an IO address, so reenable interrupts */ 116 /* Not an IO address, so reenable interrupts */
116 local_irq_enable(); 117 local_irq_enable();
117 118
119 perf_swcounter_event(PERF_COUNT_SW_PAGE_FAULTS, 1, 0, regs, address);
120
118 /* 121 /*
119 * If we're in an interrupt or have no user 122 * If we're in an interrupt or have no user
120 * context, we must not take the fault.. 123 * context, we must not take the fault..
@@ -195,10 +198,16 @@ survive:
195 goto do_sigbus; 198 goto do_sigbus;
196 BUG(); 199 BUG();
197 } 200 }
198 if (fault & VM_FAULT_MAJOR) 201
202 if (fault & VM_FAULT_MAJOR) {
199 tsk->maj_flt++; 203 tsk->maj_flt++;
200 else 204 perf_swcounter_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0,
205 regs, address);
206 } else {
201 tsk->min_flt++; 207 tsk->min_flt++;
208 perf_swcounter_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0,
209 regs, address);
210 }
202 211
203 /* If we get here, the page fault has been handled. Do the TLB refill 212 /* If we get here, the page fault has been handled. Do the TLB refill
204 now from the newly-setup PTE, to avoid having to fault again right 213 now from the newly-setup PTE, to avoid having to fault again right
diff --git a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile
index 96041a8d39e8..1ff0fd924756 100644
--- a/arch/sparc/boot/Makefile
+++ b/arch/sparc/boot/Makefile
@@ -15,7 +15,7 @@ quiet_cmd_elftoaout = ELFTOAOUT $@
15 15
16ifeq ($(CONFIG_SPARC32),y) 16ifeq ($(CONFIG_SPARC32),y)
17quiet_cmd_piggy = PIGGY $@ 17quiet_cmd_piggy = PIGGY $@
18 cmd_piggy = $(obj)/piggyback_32 $@ $(obj)/System.map $(ROOT_IMG) 18 cmd_piggy = $(obj)/piggyback_32 $@ System.map $(ROOT_IMG)
19quiet_cmd_btfix = BTFIX $@ 19quiet_cmd_btfix = BTFIX $@
20 cmd_btfix = $(OBJDUMP) -x vmlinux | $(obj)/btfixupprep > $@ 20 cmd_btfix = $(OBJDUMP) -x vmlinux | $(obj)/btfixupprep > $@
21quiet_cmd_sysmap = SYSMAP $(obj)/System.map 21quiet_cmd_sysmap = SYSMAP $(obj)/System.map
@@ -58,7 +58,7 @@ $(obj)/image: $(obj)/btfix.o FORCE
58$(obj)/zImage: $(obj)/image 58$(obj)/zImage: $(obj)/image
59 $(call if_changed,strip) 59 $(call if_changed,strip)
60 60
61$(obj)/tftpboot.img: $(obj)/piggyback $(obj)/System.map $(obj)/image FORCE 61$(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback_32 System.map $(ROOT_IMG) FORCE
62 $(call if_changed,elftoaout) 62 $(call if_changed,elftoaout)
63 $(call if_changed,piggy) 63 $(call if_changed,piggy)
64 64
@@ -79,7 +79,7 @@ $(obj)/image: vmlinux FORCE
79 $(call if_changed,strip) 79 $(call if_changed,strip)
80 @echo ' kernel: $@ is ready' 80 @echo ' kernel: $@ is ready'
81 81
82$(obj)/tftpboot.img: vmlinux $(obj)/piggyback_64 System.map $(ROOT_IMG) FORCE 82$(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback_64 System.map $(ROOT_IMG) FORCE
83 $(call if_changed,elftoaout) 83 $(call if_changed,elftoaout)
84 $(call if_changed,piggy) 84 $(call if_changed,piggy)
85 @echo ' kernel: $@ is ready' 85 @echo ' kernel: $@ is ready'
diff --git a/arch/sparc/boot/piggyback_32.c b/arch/sparc/boot/piggyback_32.c
index c9f500c1a8b2..e8dc9adfcd61 100644
--- a/arch/sparc/boot/piggyback_32.c
+++ b/arch/sparc/boot/piggyback_32.c
@@ -70,7 +70,7 @@ void die(char *str)
70int main(int argc,char **argv) 70int main(int argc,char **argv)
71{ 71{
72 static char aout_magic[] = { 0x01, 0x03, 0x01, 0x07 }; 72 static char aout_magic[] = { 0x01, 0x03, 0x01, 0x07 };
73 unsigned char buffer[1024], *q, *r; 73 char buffer[1024], *q, *r;
74 unsigned int i, j, k, start, end, offset; 74 unsigned int i, j, k, start, end, offset;
75 FILE *map; 75 FILE *map;
76 struct stat s; 76 struct stat s;
@@ -84,7 +84,7 @@ int main(int argc,char **argv)
84 while (fgets (buffer, 1024, map)) { 84 while (fgets (buffer, 1024, map)) {
85 if (!strcmp (buffer + 8, " T start\n") || !strcmp (buffer + 16, " T start\n")) 85 if (!strcmp (buffer + 8, " T start\n") || !strcmp (buffer + 16, " T start\n"))
86 start = strtoul (buffer, NULL, 16); 86 start = strtoul (buffer, NULL, 16);
87 else if (!strcmp (buffer + 8, " A end\n") || !strcmp (buffer + 16, " A end\n")) 87 else if (!strcmp (buffer + 8, " A _end\n") || !strcmp (buffer + 16, " A _end\n"))
88 end = strtoul (buffer, NULL, 16); 88 end = strtoul (buffer, NULL, 16);
89 } 89 }
90 fclose (map); 90 fclose (map);
diff --git a/arch/sparc/boot/piggyback_64.c b/arch/sparc/boot/piggyback_64.c
index de364bfed0bb..c63fd1b6bdd4 100644
--- a/arch/sparc/boot/piggyback_64.c
+++ b/arch/sparc/boot/piggyback_64.c
@@ -46,6 +46,7 @@ int main(int argc,char **argv)
46 struct stat s; 46 struct stat s;
47 int image, tail; 47 int image, tail;
48 48
49 start = end = 0;
49 if (stat (argv[3], &s) < 0) die (argv[3]); 50 if (stat (argv[3], &s) < 0) die (argv[3]);
50 map = fopen (argv[2], "r"); 51 map = fopen (argv[2], "r");
51 if (!map) die(argv[2]); 52 if (!map) die(argv[2]);
diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
index 0f7b0e5fb1c7..844d73a0340c 100644
--- a/arch/sparc/include/asm/thread_info_32.h
+++ b/arch/sparc/include/asm/thread_info_32.h
@@ -54,8 +54,6 @@ struct thread_info {
54 54
55/* 55/*
56 * macros/functions for gaining access to the thread information structure 56 * macros/functions for gaining access to the thread information structure
57 *
58 * preempt_count needs to be 1 initially, until the scheduler is functional.
59 */ 57 */
60#define INIT_THREAD_INFO(tsk) \ 58#define INIT_THREAD_INFO(tsk) \
61{ \ 59{ \
@@ -64,7 +62,7 @@ struct thread_info {
64 .exec_domain = &default_exec_domain, \ 62 .exec_domain = &default_exec_domain, \
65 .flags = 0, \ 63 .flags = 0, \
66 .cpu = 0, \ 64 .cpu = 0, \
67 .preempt_count = 1, \ 65 .preempt_count = INIT_PREEMPT_COUNT, \
68 .restart_block = { \ 66 .restart_block = { \
69 .fn = do_no_restart_syscall, \ 67 .fn = do_no_restart_syscall, \
70 }, \ 68 }, \
diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
index 65865726b283..1b45a7bbe407 100644
--- a/arch/sparc/include/asm/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -125,8 +125,6 @@ struct thread_info {
125 125
126/* 126/*
127 * macros/functions for gaining access to the thread information structure 127 * macros/functions for gaining access to the thread information structure
128 *
129 * preempt_count needs to be 1 initially, until the scheduler is functional.
130 */ 128 */
131#ifndef __ASSEMBLY__ 129#ifndef __ASSEMBLY__
132 130
@@ -135,7 +133,7 @@ struct thread_info {
135 .task = &tsk, \ 133 .task = &tsk, \
136 .flags = ((unsigned long)ASI_P) << TI_FLAG_CURRENT_DS_SHIFT, \ 134 .flags = ((unsigned long)ASI_P) << TI_FLAG_CURRENT_DS_SHIFT, \
137 .exec_domain = &default_exec_domain, \ 135 .exec_domain = &default_exec_domain, \
138 .preempt_count = 1, \ 136 .preempt_count = INIT_PREEMPT_COUNT, \
139 .restart_block = { \ 137 .restart_block = { \
140 .fn = do_no_restart_syscall, \ 138 .fn = do_no_restart_syscall, \
141 }, \ 139 }, \
diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
index bd075054942b..f0ee79055409 100644
--- a/arch/sparc/kernel/irq_64.c
+++ b/arch/sparc/kernel/irq_64.c
@@ -20,7 +20,6 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/bootmem.h>
24#include <linux/irq.h> 23#include <linux/irq.h>
25 24
26#include <asm/ptrace.h> 25#include <asm/ptrace.h>
@@ -914,25 +913,19 @@ void __cpuinit notrace sun4v_register_mondo_queues(int this_cpu)
914 tb->nonresum_qmask); 913 tb->nonresum_qmask);
915} 914}
916 915
917static void __init alloc_one_mondo(unsigned long *pa_ptr, unsigned long qmask) 916/* Each queue region must be a power of 2 multiple of 64 bytes in
918{ 917 * size. The base real address must be aligned to the size of the
919 unsigned long size = PAGE_ALIGN(qmask + 1); 918 * region. Thus, an 8KB queue must be 8KB aligned, for example.
920 void *p = __alloc_bootmem(size, size, 0); 919 */
921 if (!p) { 920static void __init alloc_one_queue(unsigned long *pa_ptr, unsigned long qmask)
922 prom_printf("SUN4V: Error, cannot allocate mondo queue.\n");
923 prom_halt();
924 }
925
926 *pa_ptr = __pa(p);
927}
928
929static void __init alloc_one_kbuf(unsigned long *pa_ptr, unsigned long qmask)
930{ 921{
931 unsigned long size = PAGE_ALIGN(qmask + 1); 922 unsigned long size = PAGE_ALIGN(qmask + 1);
932 void *p = __alloc_bootmem(size, size, 0); 923 unsigned long order = get_order(size);
924 unsigned long p;
933 925
926 p = __get_free_pages(GFP_KERNEL, order);
934 if (!p) { 927 if (!p) {
935 prom_printf("SUN4V: Error, cannot allocate kbuf page.\n"); 928 prom_printf("SUN4V: Error, cannot allocate queue.\n");
936 prom_halt(); 929 prom_halt();
937 } 930 }
938 931
@@ -942,11 +935,11 @@ static void __init alloc_one_kbuf(unsigned long *pa_ptr, unsigned long qmask)
942static void __init init_cpu_send_mondo_info(struct trap_per_cpu *tb) 935static void __init init_cpu_send_mondo_info(struct trap_per_cpu *tb)
943{ 936{
944#ifdef CONFIG_SMP 937#ifdef CONFIG_SMP
945 void *page; 938 unsigned long page;
946 939
947 BUILD_BUG_ON((NR_CPUS * sizeof(u16)) > (PAGE_SIZE - 64)); 940 BUILD_BUG_ON((NR_CPUS * sizeof(u16)) > (PAGE_SIZE - 64));
948 941
949 page = alloc_bootmem_pages(PAGE_SIZE); 942 page = get_zeroed_page(GFP_KERNEL);
950 if (!page) { 943 if (!page) {
951 prom_printf("SUN4V: Error, cannot allocate cpu mondo page.\n"); 944 prom_printf("SUN4V: Error, cannot allocate cpu mondo page.\n");
952 prom_halt(); 945 prom_halt();
@@ -965,13 +958,13 @@ static void __init sun4v_init_mondo_queues(void)
965 for_each_possible_cpu(cpu) { 958 for_each_possible_cpu(cpu) {
966 struct trap_per_cpu *tb = &trap_block[cpu]; 959 struct trap_per_cpu *tb = &trap_block[cpu];
967 960
968 alloc_one_mondo(&tb->cpu_mondo_pa, tb->cpu_mondo_qmask); 961 alloc_one_queue(&tb->cpu_mondo_pa, tb->cpu_mondo_qmask);
969 alloc_one_mondo(&tb->dev_mondo_pa, tb->dev_mondo_qmask); 962 alloc_one_queue(&tb->dev_mondo_pa, tb->dev_mondo_qmask);
970 alloc_one_mondo(&tb->resum_mondo_pa, tb->resum_qmask); 963 alloc_one_queue(&tb->resum_mondo_pa, tb->resum_qmask);
971 alloc_one_kbuf(&tb->resum_kernel_buf_pa, tb->resum_qmask); 964 alloc_one_queue(&tb->resum_kernel_buf_pa, tb->resum_qmask);
972 alloc_one_mondo(&tb->nonresum_mondo_pa, tb->nonresum_qmask); 965 alloc_one_queue(&tb->nonresum_mondo_pa, tb->nonresum_qmask);
973 alloc_one_kbuf(&tb->nonresum_kernel_buf_pa, 966 alloc_one_queue(&tb->nonresum_kernel_buf_pa,
974 tb->nonresum_qmask); 967 tb->nonresum_qmask);
975 } 968 }
976} 969}
977 970
@@ -999,7 +992,7 @@ void __init init_IRQ(void)
999 kill_prom_timer(); 992 kill_prom_timer();
1000 993
1001 size = sizeof(struct ino_bucket) * NUM_IVECS; 994 size = sizeof(struct ino_bucket) * NUM_IVECS;
1002 ivector_table = alloc_bootmem(size); 995 ivector_table = kzalloc(size, GFP_KERNEL);
1003 if (!ivector_table) { 996 if (!ivector_table) {
1004 prom_printf("Fatal error, cannot allocate ivector_table\n"); 997 prom_printf("Fatal error, cannot allocate ivector_table\n");
1005 prom_halt(); 998 prom_halt();
diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c
index 8ce6285a06d5..7e3dfd9bb97e 100644
--- a/arch/sparc/kernel/ptrace_32.c
+++ b/arch/sparc/kernel/ptrace_32.c
@@ -16,7 +16,6 @@
16#include <linux/ptrace.h> 16#include <linux/ptrace.h>
17#include <linux/user.h> 17#include <linux/user.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/smp_lock.h>
20#include <linux/security.h> 19#include <linux/security.h>
21#include <linux/signal.h> 20#include <linux/signal.h>
22#include <linux/regset.h> 21#include <linux/regset.h>
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
index a941c610e7ce..4ae91dc2feb9 100644
--- a/arch/sparc/kernel/ptrace_64.c
+++ b/arch/sparc/kernel/ptrace_64.c
@@ -17,7 +17,6 @@
17#include <linux/ptrace.h> 17#include <linux/ptrace.h>
18#include <linux/user.h> 18#include <linux/user.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/smp_lock.h>
21#include <linux/security.h> 20#include <linux/security.h>
22#include <linux/seccomp.h> 21#include <linux/seccomp.h>
23#include <linux/audit.h> 22#include <linux/audit.h>
diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c
index 5c12e79b4bdf..da1218e8ee87 100644
--- a/arch/sparc/kernel/time_64.c
+++ b/arch/sparc/kernel/time_64.c
@@ -11,7 +11,6 @@
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/smp_lock.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/param.h> 15#include <linux/param.h>
17#include <linux/string.h> 16#include <linux/string.h>
diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
index 358283341b47..c0490c7bbde0 100644
--- a/arch/sparc/kernel/traps_32.c
+++ b/arch/sparc/kernel/traps_32.c
@@ -13,7 +13,6 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/signal.h> 14#include <linux/signal.h>
15#include <linux/smp.h> 15#include <linux/smp.h>
16#include <linux/smp_lock.h>
17#include <linux/kdebug.h> 16#include <linux/kdebug.h>
18 17
19#include <asm/delay.h> 18#include <asm/delay.h>
diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
index 753d128ed158..c28c71449a6c 100644
--- a/arch/sparc/kernel/vio.c
+++ b/arch/sparc/kernel/vio.c
@@ -224,7 +224,12 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
224 if (!strcmp(type, "domain-services-port")) 224 if (!strcmp(type, "domain-services-port"))
225 bus_id_name = "ds"; 225 bus_id_name = "ds";
226 226
227 if (strlen(bus_id_name) >= BUS_ID_SIZE - 4) { 227 /*
228 * 20 char is the old driver-core name size limit, which is no more.
229 * This check can probably be removed after review and possible
230 * adaption of the vio users name length handling.
231 */
232 if (strlen(bus_id_name) >= 20 - 4) {
228 printk(KERN_ERR "VIO: bus_id_name [%s] is too long.\n", 233 printk(KERN_ERR "VIO: bus_id_name [%s] is too long.\n",
229 bus_id_name); 234 bus_id_name);
230 return NULL; 235 return NULL;
diff --git a/arch/um/drivers/slip_kern.c b/arch/um/drivers/slip_kern.c
index 5ec17563142e..dd2aadc14af0 100644
--- a/arch/um/drivers/slip_kern.c
+++ b/arch/um/drivers/slip_kern.c
@@ -30,7 +30,6 @@ static void slip_init(struct net_device *dev, void *data)
30 30
31 slip_proto_init(&spri->slip); 31 slip_proto_init(&spri->slip);
32 32
33 dev->init = NULL;
34 dev->hard_header_len = 0; 33 dev->hard_header_len = 0;
35 dev->header_ops = NULL; 34 dev->header_ops = NULL;
36 dev->addr_len = 0; 35 dev->addr_len = 0;
diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c
index f15a6e7654f3..e376284f0fb7 100644
--- a/arch/um/drivers/slirp_kern.c
+++ b/arch/um/drivers/slirp_kern.c
@@ -32,7 +32,6 @@ void slirp_init(struct net_device *dev, void *data)
32 32
33 slip_proto_init(&spri->slip); 33 slip_proto_init(&spri->slip);
34 34
35 dev->init = NULL;
36 dev->hard_header_len = 0; 35 dev->hard_header_len = 0;
37 dev->header_ops = NULL; 36 dev->header_ops = NULL;
38 dev->addr_len = 0; 37 dev->addr_len = 0;
diff --git a/arch/um/include/asm/dma-mapping.h b/arch/um/include/asm/dma-mapping.h
index 90fc708b320e..378de4bbf49f 100644
--- a/arch/um/include/asm/dma-mapping.h
+++ b/arch/um/include/asm/dma-mapping.h
@@ -79,14 +79,14 @@ dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
79} 79}
80 80
81static inline void 81static inline void
82dma_sync_single(struct device *dev, dma_addr_t dma_handle, size_t size, 82dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
83 enum dma_data_direction direction) 83 enum dma_data_direction direction)
84{ 84{
85 BUG(); 85 BUG();
86} 86}
87 87
88static inline void 88static inline void
89dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems, 89dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
90 enum dma_data_direction direction) 90 enum dma_data_direction direction)
91{ 91{
92 BUG(); 92 BUG();
diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h
index 62274ab9471f..fd911f855367 100644
--- a/arch/um/include/asm/thread_info.h
+++ b/arch/um/include/asm/thread_info.h
@@ -32,7 +32,7 @@ struct thread_info {
32 .exec_domain = &default_exec_domain, \ 32 .exec_domain = &default_exec_domain, \
33 .flags = 0, \ 33 .flags = 0, \
34 .cpu = 0, \ 34 .cpu = 0, \
35 .preempt_count = 1, \ 35 .preempt_count = INIT_PREEMPT_COUNT, \
36 .addr_limit = KERNEL_DS, \ 36 .addr_limit = KERNEL_DS, \
37 .restart_block = { \ 37 .restart_block = { \
38 .fn = do_no_restart_syscall, \ 38 .fn = do_no_restart_syscall, \
diff --git a/arch/um/kernel/sysrq.c b/arch/um/kernel/sysrq.c
index 56d43d0a3960..0960de54495a 100644
--- a/arch/um/kernel/sysrq.c
+++ b/arch/um/kernel/sysrq.c
@@ -70,8 +70,8 @@ void show_stack(struct task_struct *task, unsigned long *esp)
70 if (kstack_end(stack)) 70 if (kstack_end(stack))
71 break; 71 break;
72 if (i && ((i % 8) == 0)) 72 if (i && ((i % 8) == 0))
73 printk("\n" KERN_INFO " "); 73 printk(KERN_INFO " ");
74 printk("%08lx ", *stack++); 74 printk(KERN_CONT "%08lx ", *stack++);
75 } 75 }
76 76
77 show_trace(task, esp); 77 show_trace(task, esp);
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d1430ef6b4f9..738bdc6b0f8b 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1913,25 +1913,26 @@ config DMAR_DEFAULT_ON
1913 recommended you say N here while the DMAR code remains 1913 recommended you say N here while the DMAR code remains
1914 experimental. 1914 experimental.
1915 1915
1916config DMAR_GFX_WA 1916config DMAR_BROKEN_GFX_WA
1917 def_bool y 1917 def_bool n
1918 prompt "Support for Graphics workaround" 1918 prompt "Workaround broken graphics drivers (going away soon)"
1919 depends on DMAR 1919 depends on DMAR
1920 ---help--- 1920 ---help---
1921 Current Graphics drivers tend to use physical address 1921 Current Graphics drivers tend to use physical address
1922 for DMA and avoid using DMA APIs. Setting this config 1922 for DMA and avoid using DMA APIs. Setting this config
1923 option permits the IOMMU driver to set a unity map for 1923 option permits the IOMMU driver to set a unity map for
1924 all the OS-visible memory. Hence the driver can continue 1924 all the OS-visible memory. Hence the driver can continue
1925 to use physical addresses for DMA. 1925 to use physical addresses for DMA, at least until this
1926 option is removed in the 2.6.32 kernel.
1926 1927
1927config DMAR_FLOPPY_WA 1928config DMAR_FLOPPY_WA
1928 def_bool y 1929 def_bool y
1929 depends on DMAR 1930 depends on DMAR
1930 ---help--- 1931 ---help---
1931 Floppy disk drivers are know to bypass DMA API calls 1932 Floppy disk drivers are known to bypass DMA API calls
1932 thereby failing to work when IOMMU is enabled. This 1933 thereby failing to work when IOMMU is enabled. This
1933 workaround will setup a 1:1 mapping for the first 1934 workaround will setup a 1:1 mapping for the first
1934 16M to make floppy (an ISA device) work. 1935 16MiB to make floppy (an ISA device) work.
1935 1936
1936config INTR_REMAP 1937config INTR_REMAP
1937 bool "Support for Interrupt Remapping (EXPERIMENTAL)" 1938 bool "Support for Interrupt Remapping (EXPERIMENTAL)"
diff --git a/arch/x86/boot/video-bios.c b/arch/x86/boot/video-bios.c
index d660be492363..49e0c18833e0 100644
--- a/arch/x86/boot/video-bios.c
+++ b/arch/x86/boot/video-bios.c
@@ -37,14 +37,13 @@ static int set_bios_mode(u8 mode)
37 ireg.al = mode; /* AH=0x00 Set Video Mode */ 37 ireg.al = mode; /* AH=0x00 Set Video Mode */
38 intcall(0x10, &ireg, NULL); 38 intcall(0x10, &ireg, NULL);
39 39
40
41 ireg.ah = 0x0f; /* Get Current Video Mode */ 40 ireg.ah = 0x0f; /* Get Current Video Mode */
42 intcall(0x10, &ireg, &oreg); 41 intcall(0x10, &ireg, &oreg);
43 42
44 do_restore = 1; /* Assume video contents were lost */ 43 do_restore = 1; /* Assume video contents were lost */
45 44
46 /* Not all BIOSes are clean with the top bit */ 45 /* Not all BIOSes are clean with the top bit */
47 new_mode = ireg.al & 0x7f; 46 new_mode = oreg.al & 0x7f;
48 47
49 if (new_mode == mode) 48 if (new_mode == mode)
50 return 0; /* Mode change OK */ 49 return 0; /* Mode change OK */
diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
index c700147d6ffb..275dd177f198 100644
--- a/arch/x86/boot/video-vesa.c
+++ b/arch/x86/boot/video-vesa.c
@@ -45,7 +45,7 @@ static int vesa_probe(void)
45 ireg.di = (size_t)&vginfo; 45 ireg.di = (size_t)&vginfo;
46 intcall(0x10, &ireg, &oreg); 46 intcall(0x10, &ireg, &oreg);
47 47
48 if (ireg.ax != 0x004f || 48 if (oreg.ax != 0x004f ||
49 vginfo.signature != VESA_MAGIC || 49 vginfo.signature != VESA_MAGIC ||
50 vginfo.version < 0x0102) 50 vginfo.version < 0x0102)
51 return 0; /* Not present */ 51 return 0; /* Not present */
@@ -70,7 +70,7 @@ static int vesa_probe(void)
70 ireg.di = (size_t)&vminfo; 70 ireg.di = (size_t)&vminfo;
71 intcall(0x10, &ireg, &oreg); 71 intcall(0x10, &ireg, &oreg);
72 72
73 if (ireg.ax != 0x004f) 73 if (oreg.ax != 0x004f)
74 continue; 74 continue;
75 75
76 if ((vminfo.mode_attr & 0x15) == 0x05) { 76 if ((vminfo.mode_attr & 0x15) == 0x05) {
diff --git a/arch/x86/include/asm/atomic_32.h b/arch/x86/include/asm/atomic_32.h
index 2503d4e64c2a..dc5a667ff791 100644
--- a/arch/x86/include/asm/atomic_32.h
+++ b/arch/x86/include/asm/atomic_32.h
@@ -19,7 +19,10 @@
19 * 19 *
20 * Atomically reads the value of @v. 20 * Atomically reads the value of @v.
21 */ 21 */
22#define atomic_read(v) ((v)->counter) 22static inline int atomic_read(const atomic_t *v)
23{
24 return v->counter;
25}
23 26
24/** 27/**
25 * atomic_set - set atomic variable 28 * atomic_set - set atomic variable
@@ -28,7 +31,10 @@
28 * 31 *
29 * Atomically sets the value of @v to @i. 32 * Atomically sets the value of @v to @i.
30 */ 33 */
31#define atomic_set(v, i) (((v)->counter) = (i)) 34static inline void atomic_set(atomic_t *v, int i)
35{
36 v->counter = i;
37}
32 38
33/** 39/**
34 * atomic_add - add integer to atomic variable 40 * atomic_add - add integer to atomic variable
@@ -200,8 +206,15 @@ static inline int atomic_sub_return(int i, atomic_t *v)
200 return atomic_add_return(-i, v); 206 return atomic_add_return(-i, v);
201} 207}
202 208
203#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) 209static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
204#define atomic_xchg(v, new) (xchg(&((v)->counter), (new))) 210{
211 return cmpxchg(&v->counter, old, new);
212}
213
214static inline int atomic_xchg(atomic_t *v, int new)
215{
216 return xchg(&v->counter, new);
217}
205 218
206/** 219/**
207 * atomic_add_unless - add unless the number is already a given value 220 * atomic_add_unless - add unless the number is already a given value
@@ -250,45 +263,12 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
250/* An 64bit atomic type */ 263/* An 64bit atomic type */
251 264
252typedef struct { 265typedef struct {
253 unsigned long long counter; 266 u64 __aligned(8) counter;
254} atomic64_t; 267} atomic64_t;
255 268
256#define ATOMIC64_INIT(val) { (val) } 269#define ATOMIC64_INIT(val) { (val) }
257 270
258/** 271extern u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old_val, u64 new_val);
259 * atomic64_read - read atomic64 variable
260 * @ptr: pointer of type atomic64_t
261 *
262 * Atomically reads the value of @v.
263 * Doesn't imply a read memory barrier.
264 */
265#define __atomic64_read(ptr) ((ptr)->counter)
266
267static inline unsigned long long
268cmpxchg8b(unsigned long long *ptr, unsigned long long old, unsigned long long new)
269{
270 asm volatile(
271
272 LOCK_PREFIX "cmpxchg8b (%[ptr])\n"
273
274 : "=A" (old)
275
276 : [ptr] "D" (ptr),
277 "A" (old),
278 "b" (ll_low(new)),
279 "c" (ll_high(new))
280
281 : "memory");
282
283 return old;
284}
285
286static inline unsigned long long
287atomic64_cmpxchg(atomic64_t *ptr, unsigned long long old_val,
288 unsigned long long new_val)
289{
290 return cmpxchg8b(&ptr->counter, old_val, new_val);
291}
292 272
293/** 273/**
294 * atomic64_xchg - xchg atomic64 variable 274 * atomic64_xchg - xchg atomic64 variable
@@ -298,18 +278,7 @@ atomic64_cmpxchg(atomic64_t *ptr, unsigned long long old_val,
298 * Atomically xchgs the value of @ptr to @new_val and returns 278 * Atomically xchgs the value of @ptr to @new_val and returns
299 * the old value. 279 * the old value.
300 */ 280 */
301 281extern u64 atomic64_xchg(atomic64_t *ptr, u64 new_val);
302static inline unsigned long long
303atomic64_xchg(atomic64_t *ptr, unsigned long long new_val)
304{
305 unsigned long long old_val;
306
307 do {
308 old_val = atomic_read(ptr);
309 } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);
310
311 return old_val;
312}
313 282
314/** 283/**
315 * atomic64_set - set atomic64 variable 284 * atomic64_set - set atomic64 variable
@@ -318,10 +287,7 @@ atomic64_xchg(atomic64_t *ptr, unsigned long long new_val)
318 * 287 *
319 * Atomically sets the value of @ptr to @new_val. 288 * Atomically sets the value of @ptr to @new_val.
320 */ 289 */
321static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val) 290extern void atomic64_set(atomic64_t *ptr, u64 new_val);
322{
323 atomic64_xchg(ptr, new_val);
324}
325 291
326/** 292/**
327 * atomic64_read - read atomic64 variable 293 * atomic64_read - read atomic64 variable
@@ -329,17 +295,30 @@ static inline void atomic64_set(atomic64_t *ptr, unsigned long long new_val)
329 * 295 *
330 * Atomically reads the value of @ptr and returns it. 296 * Atomically reads the value of @ptr and returns it.
331 */ 297 */
332static inline unsigned long long atomic64_read(atomic64_t *ptr) 298static inline u64 atomic64_read(atomic64_t *ptr)
333{ 299{
334 unsigned long long curr_val; 300 u64 res;
335 301
336 do { 302 /*
337 curr_val = __atomic64_read(ptr); 303 * Note, we inline this atomic64_t primitive because
338 } while (atomic64_cmpxchg(ptr, curr_val, curr_val) != curr_val); 304 * it only clobbers EAX/EDX and leaves the others
339 305 * untouched. We also (somewhat subtly) rely on the
340 return curr_val; 306 * fact that cmpxchg8b returns the current 64-bit value
307 * of the memory location we are touching:
308 */
309 asm volatile(
310 "mov %%ebx, %%eax\n\t"
311 "mov %%ecx, %%edx\n\t"
312 LOCK_PREFIX "cmpxchg8b %1\n"
313 : "=&A" (res)
314 : "m" (*ptr)
315 );
316
317 return res;
341} 318}
342 319
320extern u64 atomic64_read(atomic64_t *ptr);
321
343/** 322/**
344 * atomic64_add_return - add and return 323 * atomic64_add_return - add and return
345 * @delta: integer value to add 324 * @delta: integer value to add
@@ -347,34 +326,14 @@ static inline unsigned long long atomic64_read(atomic64_t *ptr)
347 * 326 *
348 * Atomically adds @delta to @ptr and returns @delta + *@ptr 327 * Atomically adds @delta to @ptr and returns @delta + *@ptr
349 */ 328 */
350static inline unsigned long long 329extern u64 atomic64_add_return(u64 delta, atomic64_t *ptr);
351atomic64_add_return(unsigned long long delta, atomic64_t *ptr)
352{
353 unsigned long long old_val, new_val;
354
355 do {
356 old_val = atomic_read(ptr);
357 new_val = old_val + delta;
358
359 } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);
360
361 return new_val;
362}
363
364static inline long atomic64_sub_return(unsigned long long delta, atomic64_t *ptr)
365{
366 return atomic64_add_return(-delta, ptr);
367}
368 330
369static inline long atomic64_inc_return(atomic64_t *ptr) 331/*
370{ 332 * Other variants with different arithmetic operators:
371 return atomic64_add_return(1, ptr); 333 */
372} 334extern u64 atomic64_sub_return(u64 delta, atomic64_t *ptr);
373 335extern u64 atomic64_inc_return(atomic64_t *ptr);
374static inline long atomic64_dec_return(atomic64_t *ptr) 336extern u64 atomic64_dec_return(atomic64_t *ptr);
375{
376 return atomic64_sub_return(1, ptr);
377}
378 337
379/** 338/**
380 * atomic64_add - add integer to atomic64 variable 339 * atomic64_add - add integer to atomic64 variable
@@ -383,10 +342,7 @@ static inline long atomic64_dec_return(atomic64_t *ptr)
383 * 342 *
384 * Atomically adds @delta to @ptr. 343 * Atomically adds @delta to @ptr.
385 */ 344 */
386static inline void atomic64_add(unsigned long long delta, atomic64_t *ptr) 345extern void atomic64_add(u64 delta, atomic64_t *ptr);
387{
388 atomic64_add_return(delta, ptr);
389}
390 346
391/** 347/**
392 * atomic64_sub - subtract the atomic64 variable 348 * atomic64_sub - subtract the atomic64 variable
@@ -395,10 +351,7 @@ static inline void atomic64_add(unsigned long long delta, atomic64_t *ptr)
395 * 351 *
396 * Atomically subtracts @delta from @ptr. 352 * Atomically subtracts @delta from @ptr.
397 */ 353 */
398static inline void atomic64_sub(unsigned long long delta, atomic64_t *ptr) 354extern void atomic64_sub(u64 delta, atomic64_t *ptr);
399{
400 atomic64_add(-delta, ptr);
401}
402 355
403/** 356/**
404 * atomic64_sub_and_test - subtract value from variable and test result 357 * atomic64_sub_and_test - subtract value from variable and test result
@@ -409,13 +362,7 @@ static inline void atomic64_sub(unsigned long long delta, atomic64_t *ptr)
409 * true if the result is zero, or false for all 362 * true if the result is zero, or false for all
410 * other cases. 363 * other cases.
411 */ 364 */
412static inline int 365extern int atomic64_sub_and_test(u64 delta, atomic64_t *ptr);
413atomic64_sub_and_test(unsigned long long delta, atomic64_t *ptr)
414{
415 unsigned long long old_val = atomic64_sub_return(delta, ptr);
416
417 return old_val == 0;
418}
419 366
420/** 367/**
421 * atomic64_inc - increment atomic64 variable 368 * atomic64_inc - increment atomic64 variable
@@ -423,10 +370,7 @@ atomic64_sub_and_test(unsigned long long delta, atomic64_t *ptr)
423 * 370 *
424 * Atomically increments @ptr by 1. 371 * Atomically increments @ptr by 1.
425 */ 372 */
426static inline void atomic64_inc(atomic64_t *ptr) 373extern void atomic64_inc(atomic64_t *ptr);
427{
428 atomic64_add(1, ptr);
429}
430 374
431/** 375/**
432 * atomic64_dec - decrement atomic64 variable 376 * atomic64_dec - decrement atomic64 variable
@@ -434,10 +378,7 @@ static inline void atomic64_inc(atomic64_t *ptr)
434 * 378 *
435 * Atomically decrements @ptr by 1. 379 * Atomically decrements @ptr by 1.
436 */ 380 */
437static inline void atomic64_dec(atomic64_t *ptr) 381extern void atomic64_dec(atomic64_t *ptr);
438{
439 atomic64_sub(1, ptr);
440}
441 382
442/** 383/**
443 * atomic64_dec_and_test - decrement and test 384 * atomic64_dec_and_test - decrement and test
@@ -447,10 +388,7 @@ static inline void atomic64_dec(atomic64_t *ptr)
447 * returns true if the result is 0, or false for all other 388 * returns true if the result is 0, or false for all other
448 * cases. 389 * cases.
449 */ 390 */
450static inline int atomic64_dec_and_test(atomic64_t *ptr) 391extern int atomic64_dec_and_test(atomic64_t *ptr);
451{
452 return atomic64_sub_and_test(1, ptr);
453}
454 392
455/** 393/**
456 * atomic64_inc_and_test - increment and test 394 * atomic64_inc_and_test - increment and test
@@ -460,10 +398,7 @@ static inline int atomic64_dec_and_test(atomic64_t *ptr)
460 * and returns true if the result is zero, or false for all 398 * and returns true if the result is zero, or false for all
461 * other cases. 399 * other cases.
462 */ 400 */
463static inline int atomic64_inc_and_test(atomic64_t *ptr) 401extern int atomic64_inc_and_test(atomic64_t *ptr);
464{
465 return atomic64_sub_and_test(-1, ptr);
466}
467 402
468/** 403/**
469 * atomic64_add_negative - add and test if negative 404 * atomic64_add_negative - add and test if negative
@@ -474,13 +409,7 @@ static inline int atomic64_inc_and_test(atomic64_t *ptr)
474 * if the result is negative, or false when 409 * if the result is negative, or false when
475 * result is greater than or equal to zero. 410 * result is greater than or equal to zero.
476 */ 411 */
477static inline int 412extern int atomic64_add_negative(u64 delta, atomic64_t *ptr);
478atomic64_add_negative(unsigned long long delta, atomic64_t *ptr)
479{
480 long long old_val = atomic64_add_return(delta, ptr);
481
482 return old_val < 0;
483}
484 413
485#include <asm-generic/atomic-long.h> 414#include <asm-generic/atomic-long.h>
486#endif /* _ASM_X86_ATOMIC_32_H */ 415#endif /* _ASM_X86_ATOMIC_32_H */
diff --git a/arch/x86/include/asm/atomic_64.h b/arch/x86/include/asm/atomic_64.h
index 0d6360220007..d605dc268e79 100644
--- a/arch/x86/include/asm/atomic_64.h
+++ b/arch/x86/include/asm/atomic_64.h
@@ -18,7 +18,10 @@
18 * 18 *
19 * Atomically reads the value of @v. 19 * Atomically reads the value of @v.
20 */ 20 */
21#define atomic_read(v) ((v)->counter) 21static inline int atomic_read(const atomic_t *v)
22{
23 return v->counter;
24}
22 25
23/** 26/**
24 * atomic_set - set atomic variable 27 * atomic_set - set atomic variable
@@ -27,7 +30,10 @@
27 * 30 *
28 * Atomically sets the value of @v to @i. 31 * Atomically sets the value of @v to @i.
29 */ 32 */
30#define atomic_set(v, i) (((v)->counter) = (i)) 33static inline void atomic_set(atomic_t *v, int i)
34{
35 v->counter = i;
36}
31 37
32/** 38/**
33 * atomic_add - add integer to atomic variable 39 * atomic_add - add integer to atomic variable
@@ -192,7 +198,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
192 * Atomically reads the value of @v. 198 * Atomically reads the value of @v.
193 * Doesn't imply a read memory barrier. 199 * Doesn't imply a read memory barrier.
194 */ 200 */
195#define atomic64_read(v) ((v)->counter) 201static inline long atomic64_read(const atomic64_t *v)
202{
203 return v->counter;
204}
196 205
197/** 206/**
198 * atomic64_set - set atomic64 variable 207 * atomic64_set - set atomic64 variable
@@ -201,7 +210,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
201 * 210 *
202 * Atomically sets the value of @v to @i. 211 * Atomically sets the value of @v to @i.
203 */ 212 */
204#define atomic64_set(v, i) (((v)->counter) = (i)) 213static inline void atomic64_set(atomic64_t *v, long i)
214{
215 v->counter = i;
216}
205 217
206/** 218/**
207 * atomic64_add - add integer to atomic64 variable 219 * atomic64_add - add integer to atomic64 variable
@@ -355,11 +367,25 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
355#define atomic64_inc_return(v) (atomic64_add_return(1, (v))) 367#define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
356#define atomic64_dec_return(v) (atomic64_sub_return(1, (v))) 368#define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
357 369
358#define atomic64_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) 370static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
359#define atomic64_xchg(v, new) (xchg(&((v)->counter), new)) 371{
372 return cmpxchg(&v->counter, old, new);
373}
374
375static inline long atomic64_xchg(atomic64_t *v, long new)
376{
377 return xchg(&v->counter, new);
378}
360 379
361#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) 380static inline long atomic_cmpxchg(atomic_t *v, int old, int new)
362#define atomic_xchg(v, new) (xchg(&((v)->counter), (new))) 381{
382 return cmpxchg(&v->counter, old, new);
383}
384
385static inline long atomic_xchg(atomic_t *v, int new)
386{
387 return xchg(&v->counter, new);
388}
363 389
364/** 390/**
365 * atomic_add_unless - add unless the number is a given value 391 * atomic_add_unless - add unless the number is a given value
diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
index 418e632d4a80..7a1065958ba9 100644
--- a/arch/x86/include/asm/boot.h
+++ b/arch/x86/include/asm/boot.h
@@ -8,7 +8,7 @@
8 8
9#ifdef __KERNEL__ 9#ifdef __KERNEL__
10 10
11#include <asm/page_types.h> 11#include <asm/pgtable_types.h>
12 12
13/* Physical address where kernel should be loaded. */ 13/* Physical address where kernel should be loaded. */
14#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \ 14#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
@@ -16,10 +16,10 @@
16 & ~(CONFIG_PHYSICAL_ALIGN - 1)) 16 & ~(CONFIG_PHYSICAL_ALIGN - 1))
17 17
18/* Minimum kernel alignment, as a power of two */ 18/* Minimum kernel alignment, as a power of two */
19#ifdef CONFIG_x86_64 19#ifdef CONFIG_X86_64
20#define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT 20#define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
21#else 21#else
22#define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT+1) 22#define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_ORDER)
23#endif 23#endif
24#define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2) 24#define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2)
25 25
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 2d81af3974a0..7b2d71df39a6 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -111,12 +111,9 @@ enum fixed_addresses {
111#ifdef CONFIG_PARAVIRT 111#ifdef CONFIG_PARAVIRT
112 FIX_PARAVIRT_BOOTMAP, 112 FIX_PARAVIRT_BOOTMAP,
113#endif 113#endif
114 FIX_TEXT_POKE0, /* reserve 2 pages for text_poke() */ 114 FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */
115 FIX_TEXT_POKE1, 115 FIX_TEXT_POKE0, /* first page is last, because allocation is backward */
116 __end_of_permanent_fixed_addresses, 116 __end_of_permanent_fixed_addresses,
117#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
118 FIX_OHCI1394_BASE,
119#endif
120 /* 117 /*
121 * 256 temporary boot-time mappings, used by early_ioremap(), 118 * 256 temporary boot-time mappings, used by early_ioremap(),
122 * before ioremap() is functional. 119 * before ioremap() is functional.
@@ -129,6 +126,9 @@ enum fixed_addresses {
129 FIX_BTMAP_END = __end_of_permanent_fixed_addresses + 256 - 126 FIX_BTMAP_END = __end_of_permanent_fixed_addresses + 256 -
130 (__end_of_permanent_fixed_addresses & 255), 127 (__end_of_permanent_fixed_addresses & 255),
131 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_SLOTS - 1, 128 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_SLOTS - 1,
129#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
130 FIX_OHCI1394_BASE,
131#endif
132#ifdef CONFIG_X86_32 132#ifdef CONFIG_X86_32
133 FIX_WP_TEST, 133 FIX_WP_TEST,
134#endif 134#endif
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 1692fb5050e3..6be7fc254b59 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -246,10 +246,6 @@
246#define MSR_IA32_MISC_ENABLE_TURBO_DISABLE (1ULL << 38) 246#define MSR_IA32_MISC_ENABLE_TURBO_DISABLE (1ULL << 38)
247#define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE (1ULL << 39) 247#define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE (1ULL << 39)
248 248
249/* Intel Model 6 */
250#define MSR_P6_EVNTSEL0 0x00000186
251#define MSR_P6_EVNTSEL1 0x00000187
252
253/* P4/Xeon+ specific */ 249/* P4/Xeon+ specific */
254#define MSR_IA32_MCG_EAX 0x00000180 250#define MSR_IA32_MCG_EAX 0x00000180
255#define MSR_IA32_MCG_EBX 0x00000181 251#define MSR_IA32_MCG_EBX 0x00000181
diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
index c97264409934..c86e5ed4af51 100644
--- a/arch/x86/include/asm/nmi.h
+++ b/arch/x86/include/asm/nmi.h
@@ -72,7 +72,6 @@ void lapic_watchdog_stop(void);
72int lapic_watchdog_init(unsigned nmi_hz); 72int lapic_watchdog_init(unsigned nmi_hz);
73int lapic_wd_event(unsigned nmi_hz); 73int lapic_wd_event(unsigned nmi_hz);
74unsigned lapic_adjust_nmi_hz(unsigned hz); 74unsigned lapic_adjust_nmi_hz(unsigned hz);
75int lapic_watchdog_ok(void);
76void disable_lapic_nmi_watchdog(void); 75void disable_lapic_nmi_watchdog(void);
77void enable_lapic_nmi_watchdog(void); 76void enable_lapic_nmi_watchdog(void);
78void stop_nmi(void); 77void stop_nmi(void);
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 927958d13c19..1ff685ca221c 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -91,7 +91,7 @@ extern void pci_iommu_alloc(void);
91 91
92#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) 92#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
93 93
94#if defined(CONFIG_X86_64) || defined(CONFIG_DMA_API_DEBUG) 94#if defined(CONFIG_X86_64) || defined(CONFIG_DMAR) || defined(CONFIG_DMA_API_DEBUG)
95 95
96#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ 96#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
97 dma_addr_t ADDR_NAME; 97 dma_addr_t ADDR_NAME;
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 02ecb30982a3..103f1ddb0d85 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -42,6 +42,7 @@
42 42
43#else /* ...!ASSEMBLY */ 43#else /* ...!ASSEMBLY */
44 44
45#include <linux/kernel.h>
45#include <linux/stringify.h> 46#include <linux/stringify.h>
46 47
47#ifdef CONFIG_SMP 48#ifdef CONFIG_SMP
@@ -155,6 +156,15 @@ do { \
155/* We can use this directly for local CPU (faster). */ 156/* We can use this directly for local CPU (faster). */
156DECLARE_PER_CPU(unsigned long, this_cpu_off); 157DECLARE_PER_CPU(unsigned long, this_cpu_off);
157 158
159#ifdef CONFIG_NEED_MULTIPLE_NODES
160void *pcpu_lpage_remapped(void *kaddr);
161#else
162static inline void *pcpu_lpage_remapped(void *kaddr)
163{
164 return NULL;
165}
166#endif
167
158#endif /* !__ASSEMBLY__ */ 168#endif /* !__ASSEMBLY__ */
159 169
160#ifdef CONFIG_SMP 170#ifdef CONFIG_SMP
diff --git a/arch/x86/include/asm/perf_counter.h b/arch/x86/include/asm/perf_counter.h
index 5fb33e160ea0..fa64e401589d 100644
--- a/arch/x86/include/asm/perf_counter.h
+++ b/arch/x86/include/asm/perf_counter.h
@@ -87,6 +87,9 @@ union cpuid10_edx {
87#ifdef CONFIG_PERF_COUNTERS 87#ifdef CONFIG_PERF_COUNTERS
88extern void init_hw_perf_counters(void); 88extern void init_hw_perf_counters(void);
89extern void perf_counters_lapic_init(void); 89extern void perf_counters_lapic_init(void);
90
91#define PERF_COUNTER_INDEX_OFFSET 0
92
90#else 93#else
91static inline void init_hw_perf_counters(void) { } 94static inline void init_hw_perf_counters(void) { }
92static inline void perf_counters_lapic_init(void) { } 95static inline void perf_counters_lapic_init(void) { }
diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h
index 49fb3ecf3bb3..621f56d73121 100644
--- a/arch/x86/include/asm/proto.h
+++ b/arch/x86/include/asm/proto.h
@@ -22,7 +22,14 @@ extern int reboot_force;
22 22
23long do_arch_prctl(struct task_struct *task, int code, unsigned long addr); 23long do_arch_prctl(struct task_struct *task, int code, unsigned long addr);
24 24
25#define round_up(x, y) (((x) + (y) - 1) & ~((y) - 1)) 25/*
26#define round_down(x, y) ((x) & ~((y) - 1)) 26 * This looks more complex than it should be. But we need to
27 * get the type for the ~ right in round_down (it needs to be
28 * as wide as the result!), and we want to evaluate the macro
29 * arguments just once each.
30 */
31#define __round_mask(x,y) ((__typeof__(x))((y)-1))
32#define round_up(x,y) ((((x)-1) | __round_mask(x,y))+1)
33#define round_down(x,y) ((x) & ~__round_mask(x,y))
27 34
28#endif /* _ASM_X86_PROTO_H */ 35#endif /* _ASM_X86_PROTO_H */
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index b7e5db876399..4e77853321db 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -302,4 +302,8 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
302#define _raw_read_relax(lock) cpu_relax() 302#define _raw_read_relax(lock) cpu_relax()
303#define _raw_write_relax(lock) cpu_relax() 303#define _raw_write_relax(lock) cpu_relax()
304 304
305/* The {read|write|spin}_lock() on x86 are full memory barriers. */
306static inline void smp_mb__after_lock(void) { }
307#define ARCH_HAS_SMP_MB_AFTER_LOCK
308
305#endif /* _ASM_X86_SPINLOCK_H */ 309#endif /* _ASM_X86_SPINLOCK_H */
diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
index f517944b2b17..cf86a5e73815 100644
--- a/arch/x86/include/asm/stacktrace.h
+++ b/arch/x86/include/asm/stacktrace.h
@@ -3,6 +3,8 @@
3 3
4extern int kstack_depth_to_print; 4extern int kstack_depth_to_print;
5 5
6int x86_is_stack_id(int id, char *name);
7
6/* Generic stack tracer with callbacks */ 8/* Generic stack tracer with callbacks */
7 9
8struct stacktrace_ops { 10struct stacktrace_ops {
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index b0783520988b..fad7d40b75f8 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -49,7 +49,7 @@ struct thread_info {
49 .exec_domain = &default_exec_domain, \ 49 .exec_domain = &default_exec_domain, \
50 .flags = 0, \ 50 .flags = 0, \
51 .cpu = 0, \ 51 .cpu = 0, \
52 .preempt_count = 1, \ 52 .preempt_count = INIT_PREEMPT_COUNT, \
53 .addr_limit = KERNEL_DS, \ 53 .addr_limit = KERNEL_DS, \
54 .restart_block = { \ 54 .restart_block = { \
55 .fn = do_no_restart_syscall, \ 55 .fn = do_no_restart_syscall, \
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 6c327b852e23..430d5b24af7b 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -26,6 +26,8 @@ CFLAGS_tsc.o := $(nostackp)
26CFLAGS_paravirt.o := $(nostackp) 26CFLAGS_paravirt.o := $(nostackp)
27GCOV_PROFILE_vsyscall_64.o := n 27GCOV_PROFILE_vsyscall_64.o := n
28GCOV_PROFILE_hpet.o := n 28GCOV_PROFILE_hpet.o := n
29GCOV_PROFILE_tsc.o := n
30GCOV_PROFILE_paravirt.o := n
29 31
30obj-y := process_$(BITS).o signal.o entry_$(BITS).o 32obj-y := process_$(BITS).o signal.o entry_$(BITS).o
31obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o 33obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 9372f0406ad4..6c99f5037801 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1192,7 +1192,7 @@ out:
1192 return 0; 1192 return 0;
1193} 1193}
1194 1194
1195struct notifier_block device_nb = { 1195static struct notifier_block device_nb = {
1196 .notifier_call = device_change_notifier, 1196 .notifier_call = device_change_notifier,
1197}; 1197};
1198 1198
@@ -1763,7 +1763,7 @@ static void *alloc_coherent(struct device *dev, size_t size,
1763 flag |= __GFP_ZERO; 1763 flag |= __GFP_ZERO;
1764 virt_addr = (void *)__get_free_pages(flag, get_order(size)); 1764 virt_addr = (void *)__get_free_pages(flag, get_order(size));
1765 if (!virt_addr) 1765 if (!virt_addr)
1766 return 0; 1766 return NULL;
1767 1767
1768 paddr = virt_to_phys(virt_addr); 1768 paddr = virt_to_phys(virt_addr);
1769 1769
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 10b2accd12ea..c1b17e97252e 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -472,6 +472,8 @@ static u8 * __init alloc_event_buffer(struct amd_iommu *iommu)
472 if (iommu->evt_buf == NULL) 472 if (iommu->evt_buf == NULL)
473 return NULL; 473 return NULL;
474 474
475 iommu->evt_buf_size = EVT_BUFFER_SIZE;
476
475 return iommu->evt_buf; 477 return iommu->evt_buf;
476} 478}
477 479
@@ -691,6 +693,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
691 693
692 devid = e->devid; 694 devid = e->devid;
693 devid_to = e->ext >> 8; 695 devid_to = e->ext >> 8;
696 set_dev_entry_from_acpi(iommu, devid , e->flags, 0);
694 set_dev_entry_from_acpi(iommu, devid_to, e->flags, 0); 697 set_dev_entry_from_acpi(iommu, devid_to, e->flags, 0);
695 amd_iommu_alias_table[devid] = devid_to; 698 amd_iommu_alias_table[devid] = devid_to;
696 break; 699 break;
@@ -749,11 +752,13 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
749 752
750 devid = e->devid; 753 devid = e->devid;
751 for (dev_i = devid_start; dev_i <= devid; ++dev_i) { 754 for (dev_i = devid_start; dev_i <= devid; ++dev_i) {
752 if (alias) 755 if (alias) {
753 amd_iommu_alias_table[dev_i] = devid_to; 756 amd_iommu_alias_table[dev_i] = devid_to;
754 set_dev_entry_from_acpi(iommu, 757 set_dev_entry_from_acpi(iommu,
755 amd_iommu_alias_table[dev_i], 758 devid_to, flags, ext_flags);
756 flags, ext_flags); 759 }
760 set_dev_entry_from_acpi(iommu, dev_i,
761 flags, ext_flags);
757 } 762 }
758 break; 763 break;
759 default: 764 default:
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 8c7c042ecad1..0a1c2830ec66 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -140,7 +140,6 @@ int x2apic_mode;
140#ifdef CONFIG_X86_X2APIC 140#ifdef CONFIG_X86_X2APIC
141/* x2apic enabled before OS handover */ 141/* x2apic enabled before OS handover */
142static int x2apic_preenabled; 142static int x2apic_preenabled;
143static int disable_x2apic;
144static __init int setup_nox2apic(char *str) 143static __init int setup_nox2apic(char *str)
145{ 144{
146 if (x2apic_enabled()) { 145 if (x2apic_enabled()) {
@@ -149,7 +148,6 @@ static __init int setup_nox2apic(char *str)
149 return 0; 148 return 0;
150 } 149 }
151 150
152 disable_x2apic = 1;
153 setup_clear_cpu_cap(X86_FEATURE_X2APIC); 151 setup_clear_cpu_cap(X86_FEATURE_X2APIC);
154 return 0; 152 return 0;
155} 153}
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 4d0216fcb36c..90b5e6efa938 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1716,25 +1716,19 @@ __apicdebuginit(void) print_IO_APIC(void)
1716 return; 1716 return;
1717} 1717}
1718 1718
1719__apicdebuginit(void) print_APIC_bitfield(int base) 1719__apicdebuginit(void) print_APIC_field(int base)
1720{ 1720{
1721 unsigned int v; 1721 int i;
1722 int i, j;
1723 1722
1724 if (apic_verbosity == APIC_QUIET) 1723 if (apic_verbosity == APIC_QUIET)
1725 return; 1724 return;
1726 1725
1727 printk(KERN_DEBUG "0123456789abcdef0123456789abcdef\n" KERN_DEBUG); 1726 printk(KERN_DEBUG);
1728 for (i = 0; i < 8; i++) { 1727
1729 v = apic_read(base + i*0x10); 1728 for (i = 0; i < 8; i++)
1730 for (j = 0; j < 32; j++) { 1729 printk(KERN_CONT "%08x", apic_read(base + i*0x10));
1731 if (v & (1<<j)) 1730
1732 printk("1"); 1731 printk(KERN_CONT "\n");
1733 else
1734 printk("0");
1735 }
1736 printk("\n");
1737 }
1738} 1732}
1739 1733
1740__apicdebuginit(void) print_local_APIC(void *dummy) 1734__apicdebuginit(void) print_local_APIC(void *dummy)
@@ -1745,7 +1739,7 @@ __apicdebuginit(void) print_local_APIC(void *dummy)
1745 if (apic_verbosity == APIC_QUIET) 1739 if (apic_verbosity == APIC_QUIET)
1746 return; 1740 return;
1747 1741
1748 printk("\n" KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n", 1742 printk(KERN_DEBUG "printing local APIC contents on CPU#%d/%d:\n",
1749 smp_processor_id(), hard_smp_processor_id()); 1743 smp_processor_id(), hard_smp_processor_id());
1750 v = apic_read(APIC_ID); 1744 v = apic_read(APIC_ID);
1751 printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, read_apic_id()); 1745 printk(KERN_INFO "... APIC ID: %08x (%01x)\n", v, read_apic_id());
@@ -1786,11 +1780,11 @@ __apicdebuginit(void) print_local_APIC(void *dummy)
1786 printk(KERN_DEBUG "... APIC SPIV: %08x\n", v); 1780 printk(KERN_DEBUG "... APIC SPIV: %08x\n", v);
1787 1781
1788 printk(KERN_DEBUG "... APIC ISR field:\n"); 1782 printk(KERN_DEBUG "... APIC ISR field:\n");
1789 print_APIC_bitfield(APIC_ISR); 1783 print_APIC_field(APIC_ISR);
1790 printk(KERN_DEBUG "... APIC TMR field:\n"); 1784 printk(KERN_DEBUG "... APIC TMR field:\n");
1791 print_APIC_bitfield(APIC_TMR); 1785 print_APIC_field(APIC_TMR);
1792 printk(KERN_DEBUG "... APIC IRR field:\n"); 1786 printk(KERN_DEBUG "... APIC IRR field:\n");
1793 print_APIC_bitfield(APIC_IRR); 1787 print_APIC_field(APIC_IRR);
1794 1788
1795 if (APIC_INTEGRATED(ver)) { /* !82489DX */ 1789 if (APIC_INTEGRATED(ver)) { /* !82489DX */
1796 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ 1790 if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index e5b27d8f1b47..28e5f5956042 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -258,13 +258,15 @@ static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
258{ 258{
259#ifdef CONFIG_X86_HT 259#ifdef CONFIG_X86_HT
260 unsigned bits; 260 unsigned bits;
261 int cpu = smp_processor_id();
261 262
262 bits = c->x86_coreid_bits; 263 bits = c->x86_coreid_bits;
263
264 /* Low order bits define the core id (index of core in socket) */ 264 /* Low order bits define the core id (index of core in socket) */
265 c->cpu_core_id = c->initial_apicid & ((1 << bits)-1); 265 c->cpu_core_id = c->initial_apicid & ((1 << bits)-1);
266 /* Convert the initial APIC ID into the socket ID */ 266 /* Convert the initial APIC ID into the socket ID */
267 c->phys_proc_id = c->initial_apicid >> bits; 267 c->phys_proc_id = c->initial_apicid >> bits;
268 /* use socket ID also for last level cache */
269 per_cpu(cpu_llc_id, cpu) = c->phys_proc_id;
268#endif 270#endif
269} 271}
270 272
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 6b26d4deada0..f1961c07af9a 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -848,9 +848,6 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
848#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64) 848#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64)
849 numa_add_cpu(smp_processor_id()); 849 numa_add_cpu(smp_processor_id());
850#endif 850#endif
851
852 /* Cap the iomem address space to what is addressable on all CPUs */
853 iomem_resource.end &= (1ULL << c->x86_phys_bits) - 1;
854} 851}
855 852
856#ifdef CONFIG_X86_64 853#ifdef CONFIG_X86_64
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 81cbe64ed6b4..2a50ef891000 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -299,7 +299,7 @@ static int transition_pstate(struct powernow_k8_data *data, u32 pstate)
299static int transition_fid_vid(struct powernow_k8_data *data, 299static int transition_fid_vid(struct powernow_k8_data *data,
300 u32 reqfid, u32 reqvid) 300 u32 reqfid, u32 reqvid)
301{ 301{
302 if (core_voltage_pre_transition(data, reqvid)) 302 if (core_voltage_pre_transition(data, reqvid, reqfid))
303 return 1; 303 return 1;
304 304
305 if (core_frequency_transition(data, reqfid)) 305 if (core_frequency_transition(data, reqfid))
@@ -327,17 +327,20 @@ static int transition_fid_vid(struct powernow_k8_data *data,
327 327
328/* Phase 1 - core voltage transition ... setup voltage */ 328/* Phase 1 - core voltage transition ... setup voltage */
329static int core_voltage_pre_transition(struct powernow_k8_data *data, 329static int core_voltage_pre_transition(struct powernow_k8_data *data,
330 u32 reqvid) 330 u32 reqvid, u32 reqfid)
331{ 331{
332 u32 rvosteps = data->rvo; 332 u32 rvosteps = data->rvo;
333 u32 savefid = data->currfid; 333 u32 savefid = data->currfid;
334 u32 maxvid, lo; 334 u32 maxvid, lo, rvomult = 1;
335 335
336 dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, " 336 dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, "
337 "reqvid 0x%x, rvo 0x%x\n", 337 "reqvid 0x%x, rvo 0x%x\n",
338 smp_processor_id(), 338 smp_processor_id(),
339 data->currfid, data->currvid, reqvid, data->rvo); 339 data->currfid, data->currvid, reqvid, data->rvo);
340 340
341 if ((savefid < LO_FID_TABLE_TOP) && (reqfid < LO_FID_TABLE_TOP))
342 rvomult = 2;
343 rvosteps *= rvomult;
341 rdmsr(MSR_FIDVID_STATUS, lo, maxvid); 344 rdmsr(MSR_FIDVID_STATUS, lo, maxvid);
342 maxvid = 0x1f & (maxvid >> 16); 345 maxvid = 0x1f & (maxvid >> 16);
343 dprintk("ph1 maxvid=0x%x\n", maxvid); 346 dprintk("ph1 maxvid=0x%x\n", maxvid);
@@ -351,7 +354,8 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data,
351 return 1; 354 return 1;
352 } 355 }
353 356
354 while ((rvosteps > 0) && ((data->rvo + data->currvid) > reqvid)) { 357 while ((rvosteps > 0) &&
358 ((rvomult * data->rvo + data->currvid) > reqvid)) {
355 if (data->currvid == maxvid) { 359 if (data->currvid == maxvid) {
356 rvosteps = 0; 360 rvosteps = 0;
357 } else { 361 } else {
@@ -384,13 +388,6 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid)
384 u32 vcoreqfid, vcocurrfid, vcofiddiff; 388 u32 vcoreqfid, vcocurrfid, vcofiddiff;
385 u32 fid_interval, savevid = data->currvid; 389 u32 fid_interval, savevid = data->currvid;
386 390
387 if ((reqfid < HI_FID_TABLE_BOTTOM) &&
388 (data->currfid < HI_FID_TABLE_BOTTOM)) {
389 printk(KERN_ERR PFX "ph2: illegal lo-lo transition "
390 "0x%x 0x%x\n", reqfid, data->currfid);
391 return 1;
392 }
393
394 if (data->currfid == reqfid) { 391 if (data->currfid == reqfid) {
395 printk(KERN_ERR PFX "ph2 null fid transition 0x%x\n", 392 printk(KERN_ERR PFX "ph2 null fid transition 0x%x\n",
396 data->currfid); 393 data->currfid);
@@ -407,6 +404,9 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid)
407 vcofiddiff = vcocurrfid > vcoreqfid ? vcocurrfid - vcoreqfid 404 vcofiddiff = vcocurrfid > vcoreqfid ? vcocurrfid - vcoreqfid
408 : vcoreqfid - vcocurrfid; 405 : vcoreqfid - vcocurrfid;
409 406
407 if ((reqfid <= LO_FID_TABLE_TOP) && (data->currfid <= LO_FID_TABLE_TOP))
408 vcofiddiff = 0;
409
410 while (vcofiddiff > 2) { 410 while (vcofiddiff > 2) {
411 (data->currfid & 1) ? (fid_interval = 1) : (fid_interval = 2); 411 (data->currfid & 1) ? (fid_interval = 1) : (fid_interval = 2);
412 412
@@ -1081,14 +1081,6 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,
1081 return 0; 1081 return 0;
1082 } 1082 }
1083 1083
1084 if ((fid < HI_FID_TABLE_BOTTOM) &&
1085 (data->currfid < HI_FID_TABLE_BOTTOM)) {
1086 printk(KERN_ERR PFX
1087 "ignoring illegal change in lo freq table-%x to 0x%x\n",
1088 data->currfid, fid);
1089 return 1;
1090 }
1091
1092 dprintk("cpu %d, changing to fid 0x%x, vid 0x%x\n", 1084 dprintk("cpu %d, changing to fid 0x%x, vid 0x%x\n",
1093 smp_processor_id(), fid, vid); 1085 smp_processor_id(), fid, vid);
1094 freqs.old = find_khz_freq_from_fid(data->currfid); 1086 freqs.old = find_khz_freq_from_fid(data->currfid);
@@ -1267,7 +1259,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1267{ 1259{
1268 static const char ACPI_PSS_BIOS_BUG_MSG[] = 1260 static const char ACPI_PSS_BIOS_BUG_MSG[] =
1269 KERN_ERR FW_BUG PFX "No compatible ACPI _PSS objects found.\n" 1261 KERN_ERR FW_BUG PFX "No compatible ACPI _PSS objects found.\n"
1270 KERN_ERR FW_BUG PFX "Try again with latest BIOS.\n"; 1262 FW_BUG PFX "Try again with latest BIOS.\n";
1271 struct powernow_k8_data *data; 1263 struct powernow_k8_data *data;
1272 struct init_on_cpu init_on_cpu; 1264 struct init_on_cpu init_on_cpu;
1273 int rc; 1265 int rc;
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
index c9c1190b5e1f..02ce824073cb 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h
@@ -215,7 +215,8 @@ struct pst_s {
215 215
216#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "powernow-k8", msg) 216#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "powernow-k8", msg)
217 217
218static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid); 218static int core_voltage_pre_transition(struct powernow_k8_data *data,
219 u32 reqvid, u32 regfid);
219static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvid); 220static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvid);
220static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid); 221static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);
221 222
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 284d1de968bc..484c1e5f658e 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -194,14 +194,14 @@ static void print_mce(struct mce *m)
194 m->cs, m->ip); 194 m->cs, m->ip);
195 if (m->cs == __KERNEL_CS) 195 if (m->cs == __KERNEL_CS)
196 print_symbol("{%s}", m->ip); 196 print_symbol("{%s}", m->ip);
197 printk("\n"); 197 printk(KERN_CONT "\n");
198 } 198 }
199 printk(KERN_EMERG "TSC %llx ", m->tsc); 199 printk(KERN_EMERG "TSC %llx ", m->tsc);
200 if (m->addr) 200 if (m->addr)
201 printk("ADDR %llx ", m->addr); 201 printk(KERN_CONT "ADDR %llx ", m->addr);
202 if (m->misc) 202 if (m->misc)
203 printk("MISC %llx ", m->misc); 203 printk(KERN_CONT "MISC %llx ", m->misc);
204 printk("\n"); 204 printk(KERN_CONT "\n");
205 printk(KERN_EMERG "PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x\n", 205 printk(KERN_EMERG "PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x\n",
206 m->cpuvendor, m->cpuid, m->time, m->socketid, 206 m->cpuvendor, m->cpuid, m->time, m->socketid,
207 m->apicid); 207 m->apicid);
@@ -209,13 +209,13 @@ static void print_mce(struct mce *m)
209 209
210static void print_mce_head(void) 210static void print_mce_head(void)
211{ 211{
212 printk(KERN_EMERG "\n" KERN_EMERG "HARDWARE ERROR\n"); 212 printk(KERN_EMERG "\nHARDWARE ERROR\n");
213} 213}
214 214
215static void print_mce_tail(void) 215static void print_mce_tail(void)
216{ 216{
217 printk(KERN_EMERG "This is not a software problem!\n" 217 printk(KERN_EMERG "This is not a software problem!\n"
218 KERN_EMERG "Run through mcelog --ascii to decode and contact your hardware vendor\n"); 218 "Run through mcelog --ascii to decode and contact your hardware vendor\n");
219} 219}
220 220
221#define PANIC_TIMEOUT 5 /* 5 seconds */ 221#define PANIC_TIMEOUT 5 /* 5 seconds */
@@ -1117,7 +1117,7 @@ static void mcheck_timer(unsigned long data)
1117 *n = min(*n*2, (int)round_jiffies_relative(check_interval*HZ)); 1117 *n = min(*n*2, (int)round_jiffies_relative(check_interval*HZ));
1118 1118
1119 t->expires = jiffies + *n; 1119 t->expires = jiffies + *n;
1120 add_timer(t); 1120 add_timer_on(t, smp_processor_id());
1121} 1121}
1122 1122
1123static void mce_do_trigger(struct work_struct *work) 1123static void mce_do_trigger(struct work_struct *work)
@@ -1321,7 +1321,7 @@ static void mce_init_timer(void)
1321 return; 1321 return;
1322 setup_timer(t, mcheck_timer, smp_processor_id()); 1322 setup_timer(t, mcheck_timer, smp_processor_id());
1323 t->expires = round_jiffies(jiffies + *n); 1323 t->expires = round_jiffies(jiffies + *n);
1324 add_timer(t); 1324 add_timer_on(t, smp_processor_id());
1325} 1325}
1326 1326
1327/* 1327/*
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index 76dfef23f789..36c3dc7b8991 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -401,7 +401,7 @@ static const u64 amd_hw_cache_event_ids
401 [ C(RESULT_MISS) ] = 0x0041, /* Data Cache Misses */ 401 [ C(RESULT_MISS) ] = 0x0041, /* Data Cache Misses */
402 }, 402 },
403 [ C(OP_WRITE) ] = { 403 [ C(OP_WRITE) ] = {
404 [ C(RESULT_ACCESS) ] = 0x0042, /* Data Cache Refills from L2 */ 404 [ C(RESULT_ACCESS) ] = 0x0142, /* Data Cache Refills :system */
405 [ C(RESULT_MISS) ] = 0, 405 [ C(RESULT_MISS) ] = 0,
406 }, 406 },
407 [ C(OP_PREFETCH) ] = { 407 [ C(OP_PREFETCH) ] = {
@@ -912,6 +912,8 @@ x86_perf_counter_set_period(struct perf_counter *counter,
912 err = checking_wrmsrl(hwc->counter_base + idx, 912 err = checking_wrmsrl(hwc->counter_base + idx,
913 (u64)(-left) & x86_pmu.counter_mask); 913 (u64)(-left) & x86_pmu.counter_mask);
914 914
915 perf_counter_update_userpage(counter);
916
915 return ret; 917 return ret;
916} 918}
917 919
@@ -969,13 +971,6 @@ fixed_mode_idx(struct perf_counter *counter, struct hw_perf_counter *hwc)
969 if (!x86_pmu.num_counters_fixed) 971 if (!x86_pmu.num_counters_fixed)
970 return -1; 972 return -1;
971 973
972 /*
973 * Quirk, IA32_FIXED_CTRs do not work on current Atom processors:
974 */
975 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
976 boot_cpu_data.x86_model == 28)
977 return -1;
978
979 event = hwc->config & ARCH_PERFMON_EVENT_MASK; 974 event = hwc->config & ARCH_PERFMON_EVENT_MASK;
980 975
981 if (unlikely(event == x86_pmu.event_map(PERF_COUNT_HW_INSTRUCTIONS))) 976 if (unlikely(event == x86_pmu.event_map(PERF_COUNT_HW_INSTRUCTIONS)))
@@ -1041,6 +1036,8 @@ try_generic:
1041 x86_perf_counter_set_period(counter, hwc, idx); 1036 x86_perf_counter_set_period(counter, hwc, idx);
1042 x86_pmu.enable(hwc, idx); 1037 x86_pmu.enable(hwc, idx);
1043 1038
1039 perf_counter_update_userpage(counter);
1040
1044 return 0; 1041 return 0;
1045} 1042}
1046 1043
@@ -1133,6 +1130,8 @@ static void x86_pmu_disable(struct perf_counter *counter)
1133 x86_perf_counter_update(counter, hwc, idx); 1130 x86_perf_counter_update(counter, hwc, idx);
1134 cpuc->counters[idx] = NULL; 1131 cpuc->counters[idx] = NULL;
1135 clear_bit(idx, cpuc->used_mask); 1132 clear_bit(idx, cpuc->used_mask);
1133
1134 perf_counter_update_userpage(counter);
1136} 1135}
1137 1136
1138/* 1137/*
@@ -1428,8 +1427,6 @@ static int intel_pmu_init(void)
1428 */ 1427 */
1429 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3); 1428 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
1430 1429
1431 rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
1432
1433 /* 1430 /*
1434 * Install the hw-cache-events table: 1431 * Install the hw-cache-events table:
1435 */ 1432 */
@@ -1499,21 +1496,22 @@ void __init init_hw_perf_counters(void)
1499 pr_cont("%s PMU driver.\n", x86_pmu.name); 1496 pr_cont("%s PMU driver.\n", x86_pmu.name);
1500 1497
1501 if (x86_pmu.num_counters > X86_PMC_MAX_GENERIC) { 1498 if (x86_pmu.num_counters > X86_PMC_MAX_GENERIC) {
1502 x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
1503 WARN(1, KERN_ERR "hw perf counters %d > max(%d), clipping!", 1499 WARN(1, KERN_ERR "hw perf counters %d > max(%d), clipping!",
1504 x86_pmu.num_counters, X86_PMC_MAX_GENERIC); 1500 x86_pmu.num_counters, X86_PMC_MAX_GENERIC);
1501 x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
1505 } 1502 }
1506 perf_counter_mask = (1 << x86_pmu.num_counters) - 1; 1503 perf_counter_mask = (1 << x86_pmu.num_counters) - 1;
1507 perf_max_counters = x86_pmu.num_counters; 1504 perf_max_counters = x86_pmu.num_counters;
1508 1505
1509 if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) { 1506 if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) {
1510 x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
1511 WARN(1, KERN_ERR "hw perf counters fixed %d > max(%d), clipping!", 1507 WARN(1, KERN_ERR "hw perf counters fixed %d > max(%d), clipping!",
1512 x86_pmu.num_counters_fixed, X86_PMC_MAX_FIXED); 1508 x86_pmu.num_counters_fixed, X86_PMC_MAX_FIXED);
1509 x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
1513 } 1510 }
1514 1511
1515 perf_counter_mask |= 1512 perf_counter_mask |=
1516 ((1LL << x86_pmu.num_counters_fixed)-1) << X86_PMC_IDX_FIXED; 1513 ((1LL << x86_pmu.num_counters_fixed)-1) << X86_PMC_IDX_FIXED;
1514 x86_pmu.intel_ctrl = perf_counter_mask;
1517 1515
1518 perf_counters_lapic_init(); 1516 perf_counters_lapic_init();
1519 register_die_notifier(&perf_counter_nmi_notifier); 1517 register_die_notifier(&perf_counter_nmi_notifier);
@@ -1563,6 +1561,7 @@ void callchain_store(struct perf_callchain_entry *entry, u64 ip)
1563 1561
1564static DEFINE_PER_CPU(struct perf_callchain_entry, irq_entry); 1562static DEFINE_PER_CPU(struct perf_callchain_entry, irq_entry);
1565static DEFINE_PER_CPU(struct perf_callchain_entry, nmi_entry); 1563static DEFINE_PER_CPU(struct perf_callchain_entry, nmi_entry);
1564static DEFINE_PER_CPU(int, in_nmi_frame);
1566 1565
1567 1566
1568static void 1567static void
@@ -1578,7 +1577,9 @@ static void backtrace_warning(void *data, char *msg)
1578 1577
1579static int backtrace_stack(void *data, char *name) 1578static int backtrace_stack(void *data, char *name)
1580{ 1579{
1581 /* Process all stacks: */ 1580 per_cpu(in_nmi_frame, smp_processor_id()) =
1581 x86_is_stack_id(NMI_STACK, name);
1582
1582 return 0; 1583 return 0;
1583} 1584}
1584 1585
@@ -1586,6 +1587,9 @@ static void backtrace_address(void *data, unsigned long addr, int reliable)
1586{ 1587{
1587 struct perf_callchain_entry *entry = data; 1588 struct perf_callchain_entry *entry = data;
1588 1589
1590 if (per_cpu(in_nmi_frame, smp_processor_id()))
1591 return;
1592
1589 if (reliable) 1593 if (reliable)
1590 callchain_store(entry, addr); 1594 callchain_store(entry, addr);
1591} 1595}
diff --git a/arch/x86/kernel/cpu/perfctr-watchdog.c b/arch/x86/kernel/cpu/perfctr-watchdog.c
index 5c481f6205bf..e60ed740d2b3 100644
--- a/arch/x86/kernel/cpu/perfctr-watchdog.c
+++ b/arch/x86/kernel/cpu/perfctr-watchdog.c
@@ -803,8 +803,3 @@ int __kprobes lapic_wd_event(unsigned nmi_hz)
803 wd_ops->rearm(wd, nmi_hz); 803 wd_ops->rearm(wd, nmi_hz);
804 return 1; 804 return 1;
805} 805}
806
807int lapic_watchdog_ok(void)
808{
809 return wd_ops != NULL;
810}
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 95ea5fa7d444..c8405718a4c3 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -22,6 +22,7 @@
22#include "dumpstack.h" 22#include "dumpstack.h"
23 23
24int panic_on_unrecovered_nmi; 24int panic_on_unrecovered_nmi;
25int panic_on_io_nmi;
25unsigned int code_bytes = 64; 26unsigned int code_bytes = 64;
26int kstack_depth_to_print = 3 * STACKSLOTS_PER_LINE; 27int kstack_depth_to_print = 3 * STACKSLOTS_PER_LINE;
27static int die_counter; 28static int die_counter;
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index d593cd1f58dc..bca5fba91c9e 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -19,6 +19,12 @@
19 19
20#include "dumpstack.h" 20#include "dumpstack.h"
21 21
22/* Just a stub for now */
23int x86_is_stack_id(int id, char *name)
24{
25 return 0;
26}
27
22void dump_trace(struct task_struct *task, struct pt_regs *regs, 28void dump_trace(struct task_struct *task, struct pt_regs *regs,
23 unsigned long *stack, unsigned long bp, 29 unsigned long *stack, unsigned long bp,
24 const struct stacktrace_ops *ops, void *data) 30 const struct stacktrace_ops *ops, void *data)
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index d35db5993fd6..54b0a3276766 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -19,10 +19,8 @@
19 19
20#include "dumpstack.h" 20#include "dumpstack.h"
21 21
22static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack, 22
23 unsigned *usedp, char **idp) 23static char x86_stack_ids[][8] = {
24{
25 static char ids[][8] = {
26 [DEBUG_STACK - 1] = "#DB", 24 [DEBUG_STACK - 1] = "#DB",
27 [NMI_STACK - 1] = "NMI", 25 [NMI_STACK - 1] = "NMI",
28 [DOUBLEFAULT_STACK - 1] = "#DF", 26 [DOUBLEFAULT_STACK - 1] = "#DF",
@@ -33,6 +31,15 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
33 N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]" 31 N_EXCEPTION_STACKS + DEBUG_STKSZ / EXCEPTION_STKSZ - 2] = "#DB[?]"
34#endif 32#endif
35 }; 33 };
34
35int x86_is_stack_id(int id, char *name)
36{
37 return x86_stack_ids[id - 1] == name;
38}
39
40static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
41 unsigned *usedp, char **idp)
42{
36 unsigned k; 43 unsigned k;
37 44
38 /* 45 /*
@@ -61,7 +68,7 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
61 if (*usedp & (1U << k)) 68 if (*usedp & (1U << k))
62 break; 69 break;
63 *usedp |= 1U << k; 70 *usedp |= 1U << k;
64 *idp = ids[k]; 71 *idp = x86_stack_ids[k];
65 return (unsigned long *)end; 72 return (unsigned long *)end;
66 } 73 }
67 /* 74 /*
@@ -81,12 +88,13 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
81 do { 88 do {
82 ++j; 89 ++j;
83 end -= EXCEPTION_STKSZ; 90 end -= EXCEPTION_STKSZ;
84 ids[j][4] = '1' + (j - N_EXCEPTION_STACKS); 91 x86_stack_ids[j][4] = '1' +
92 (j - N_EXCEPTION_STACKS);
85 } while (stack < end - EXCEPTION_STKSZ); 93 } while (stack < end - EXCEPTION_STKSZ);
86 if (*usedp & (1U << j)) 94 if (*usedp & (1U << j))
87 break; 95 break;
88 *usedp |= 1U << j; 96 *usedp |= 1U << j;
89 *idp = ids[j]; 97 *idp = x86_stack_ids[j];
90 return (unsigned long *)end; 98 return (unsigned long *)end;
91 } 99 }
92#endif 100#endif
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 7271fa33d791..5cb5725b2bae 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -627,10 +627,9 @@ __init void e820_setup_gap(void)
627#ifdef CONFIG_X86_64 627#ifdef CONFIG_X86_64
628 if (!found) { 628 if (!found) {
629 gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024; 629 gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024;
630 printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit " 630 printk(KERN_ERR
631 "address range\n" 631 "PCI: Warning: Cannot find a gap in the 32bit address range\n"
632 KERN_ERR "PCI: Unassigned devices with 32bit resource " 632 "PCI: Unassigned devices with 32bit resource registers may break!\n");
633 "registers may break!\n");
634 } 633 }
635#endif 634#endif
636 635
@@ -1383,6 +1382,8 @@ static unsigned long ram_alignment(resource_size_t pos)
1383 return 32*1024*1024; 1382 return 32*1024*1024;
1384} 1383}
1385 1384
1385#define MAX_RESOURCE_SIZE ((resource_size_t)-1)
1386
1386void __init e820_reserve_resources_late(void) 1387void __init e820_reserve_resources_late(void)
1387{ 1388{
1388 int i; 1389 int i;
@@ -1400,17 +1401,19 @@ void __init e820_reserve_resources_late(void)
1400 * avoid stolen RAM: 1401 * avoid stolen RAM:
1401 */ 1402 */
1402 for (i = 0; i < e820.nr_map; i++) { 1403 for (i = 0; i < e820.nr_map; i++) {
1403 struct e820entry *entry = &e820_saved.map[i]; 1404 struct e820entry *entry = &e820.map[i];
1404 resource_size_t start, end; 1405 u64 start, end;
1405 1406
1406 if (entry->type != E820_RAM) 1407 if (entry->type != E820_RAM)
1407 continue; 1408 continue;
1408 start = entry->addr + entry->size; 1409 start = entry->addr + entry->size;
1409 end = round_up(start, ram_alignment(start)); 1410 end = round_up(start, ram_alignment(start)) - 1;
1410 if (start == end) 1411 if (end > MAX_RESOURCE_SIZE)
1412 end = MAX_RESOURCE_SIZE;
1413 if (start >= end)
1411 continue; 1414 continue;
1412 reserve_region_with_split(&iomem_resource, start, 1415 reserve_region_with_split(&iomem_resource, start, end,
1413 end - 1, "RAM buffer"); 1416 "RAM buffer");
1414 } 1417 }
1415} 1418}
1416 1419
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index a78ecad0c900..c664d515f613 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -200,7 +200,7 @@ static void kvm_leave_lazy_mmu(void)
200 state->mode = paravirt_get_lazy_mode(); 200 state->mode = paravirt_get_lazy_mode();
201} 201}
202 202
203static void paravirt_ops_setup(void) 203static void __init paravirt_ops_setup(void)
204{ 204{
205 pv_info.name = "KVM"; 205 pv_info.name = "KVM";
206 pv_info.paravirt_enabled = 1; 206 pv_info.paravirt_enabled = 1;
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 47630479b067..1a041bcf506b 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -211,11 +211,11 @@ static __init int iommu_setup(char *p)
211#ifdef CONFIG_SWIOTLB 211#ifdef CONFIG_SWIOTLB
212 if (!strncmp(p, "soft", 4)) 212 if (!strncmp(p, "soft", 4))
213 swiotlb = 1; 213 swiotlb = 1;
214#endif
214 if (!strncmp(p, "pt", 2)) { 215 if (!strncmp(p, "pt", 2)) {
215 iommu_pass_through = 1; 216 iommu_pass_through = 1;
216 return 1; 217 return 1;
217 } 218 }
218#endif
219 219
220 gart_parse_options(p); 220 gart_parse_options(p);
221 221
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index cfd9f9063896..d2e56b8f48e7 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -675,7 +675,7 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
675 nommu: 675 nommu:
676 /* Should not happen anymore */ 676 /* Should not happen anymore */
677 printk(KERN_WARNING "PCI-DMA: More than 4GB of RAM and no IOMMU\n" 677 printk(KERN_WARNING "PCI-DMA: More than 4GB of RAM and no IOMMU\n"
678 KERN_WARNING "falling back to iommu=soft.\n"); 678 "falling back to iommu=soft.\n");
679 return -1; 679 return -1;
680} 680}
681 681
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index be5ae80f897f..de2cab132844 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -289,6 +289,20 @@ void * __init extend_brk(size_t size, size_t align)
289 return ret; 289 return ret;
290} 290}
291 291
292#ifdef CONFIG_X86_64
293static void __init init_gbpages(void)
294{
295 if (direct_gbpages && cpu_has_gbpages)
296 printk(KERN_INFO "Using GB pages for direct mapping\n");
297 else
298 direct_gbpages = 0;
299}
300#else
301static inline void init_gbpages(void)
302{
303}
304#endif
305
292static void __init reserve_brk(void) 306static void __init reserve_brk(void)
293{ 307{
294 if (_brk_end > _brk_start) 308 if (_brk_end > _brk_start)
@@ -871,6 +885,8 @@ void __init setup_arch(char **cmdline_p)
871 885
872 reserve_brk(); 886 reserve_brk();
873 887
888 init_gbpages();
889
874 /* max_pfn_mapped is updated here */ 890 /* max_pfn_mapped is updated here */
875 max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT); 891 max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT);
876 max_pfn_mapped = max_low_pfn_mapped; 892 max_pfn_mapped = max_low_pfn_mapped;
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 9c3f0823e6aa..29a3eef7cf4a 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -124,7 +124,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, unsigned long size,
124} 124}
125 125
126/* 126/*
127 * Remap allocator 127 * Large page remap allocator
128 * 128 *
129 * This allocator uses PMD page as unit. A PMD page is allocated for 129 * This allocator uses PMD page as unit. A PMD page is allocated for
130 * each cpu and each is remapped into vmalloc area using PMD mapping. 130 * each cpu and each is remapped into vmalloc area using PMD mapping.
@@ -137,105 +137,185 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, unsigned long size,
137 * better than only using 4k mappings while still being NUMA friendly. 137 * better than only using 4k mappings while still being NUMA friendly.
138 */ 138 */
139#ifdef CONFIG_NEED_MULTIPLE_NODES 139#ifdef CONFIG_NEED_MULTIPLE_NODES
140static size_t pcpur_size __initdata; 140struct pcpul_ent {
141static void **pcpur_ptrs __initdata; 141 unsigned int cpu;
142 void *ptr;
143};
144
145static size_t pcpul_size;
146static struct pcpul_ent *pcpul_map;
147static struct vm_struct pcpul_vm;
142 148
143static struct page * __init pcpur_get_page(unsigned int cpu, int pageno) 149static struct page * __init pcpul_get_page(unsigned int cpu, int pageno)
144{ 150{
145 size_t off = (size_t)pageno << PAGE_SHIFT; 151 size_t off = (size_t)pageno << PAGE_SHIFT;
146 152
147 if (off >= pcpur_size) 153 if (off >= pcpul_size)
148 return NULL; 154 return NULL;
149 155
150 return virt_to_page(pcpur_ptrs[cpu] + off); 156 return virt_to_page(pcpul_map[cpu].ptr + off);
151} 157}
152 158
153static ssize_t __init setup_pcpu_remap(size_t static_size) 159static ssize_t __init setup_pcpu_lpage(size_t static_size, bool chosen)
154{ 160{
155 static struct vm_struct vm; 161 size_t map_size, dyn_size;
156 size_t ptrs_size, dyn_size;
157 unsigned int cpu; 162 unsigned int cpu;
163 int i, j;
158 ssize_t ret; 164 ssize_t ret;
159 165
160 /* 166 if (!chosen) {
161 * If large page isn't supported, there's no benefit in doing 167 size_t vm_size = VMALLOC_END - VMALLOC_START;
162 * this. Also, on non-NUMA, embedding is better. 168 size_t tot_size = num_possible_cpus() * PMD_SIZE;
163 * 169
164 * NOTE: disabled for now. 170 /* on non-NUMA, embedding is better */
165 */ 171 if (!pcpu_need_numa())
166 if (true || !cpu_has_pse || !pcpu_need_numa()) 172 return -EINVAL;
173
174 /* don't consume more than 20% of vmalloc area */
175 if (tot_size > vm_size / 5) {
176 pr_info("PERCPU: too large chunk size %zuMB for "
177 "large page remap\n", tot_size >> 20);
178 return -EINVAL;
179 }
180 }
181
182 /* need PSE */
183 if (!cpu_has_pse) {
184 pr_warning("PERCPU: lpage allocator requires PSE\n");
167 return -EINVAL; 185 return -EINVAL;
186 }
168 187
169 /* 188 /*
170 * Currently supports only single page. Supporting multiple 189 * Currently supports only single page. Supporting multiple
171 * pages won't be too difficult if it ever becomes necessary. 190 * pages won't be too difficult if it ever becomes necessary.
172 */ 191 */
173 pcpur_size = PFN_ALIGN(static_size + PERCPU_MODULE_RESERVE + 192 pcpul_size = PFN_ALIGN(static_size + PERCPU_MODULE_RESERVE +
174 PERCPU_DYNAMIC_RESERVE); 193 PERCPU_DYNAMIC_RESERVE);
175 if (pcpur_size > PMD_SIZE) { 194 if (pcpul_size > PMD_SIZE) {
176 pr_warning("PERCPU: static data is larger than large page, " 195 pr_warning("PERCPU: static data is larger than large page, "
177 "can't use large page\n"); 196 "can't use large page\n");
178 return -EINVAL; 197 return -EINVAL;
179 } 198 }
180 dyn_size = pcpur_size - static_size - PERCPU_FIRST_CHUNK_RESERVE; 199 dyn_size = pcpul_size - static_size - PERCPU_FIRST_CHUNK_RESERVE;
181 200
182 /* allocate pointer array and alloc large pages */ 201 /* allocate pointer array and alloc large pages */
183 ptrs_size = PFN_ALIGN(num_possible_cpus() * sizeof(pcpur_ptrs[0])); 202 map_size = PFN_ALIGN(num_possible_cpus() * sizeof(pcpul_map[0]));
184 pcpur_ptrs = alloc_bootmem(ptrs_size); 203 pcpul_map = alloc_bootmem(map_size);
185 204
186 for_each_possible_cpu(cpu) { 205 for_each_possible_cpu(cpu) {
187 pcpur_ptrs[cpu] = pcpu_alloc_bootmem(cpu, PMD_SIZE, PMD_SIZE); 206 pcpul_map[cpu].cpu = cpu;
188 if (!pcpur_ptrs[cpu]) 207 pcpul_map[cpu].ptr = pcpu_alloc_bootmem(cpu, PMD_SIZE,
208 PMD_SIZE);
209 if (!pcpul_map[cpu].ptr) {
210 pr_warning("PERCPU: failed to allocate large page "
211 "for cpu%u\n", cpu);
189 goto enomem; 212 goto enomem;
213 }
190 214
191 /* 215 /*
192 * Only use pcpur_size bytes and give back the rest. 216 * Only use pcpul_size bytes and give back the rest.
193 * 217 *
194 * Ingo: The 2MB up-rounding bootmem is needed to make 218 * Ingo: The 2MB up-rounding bootmem is needed to make
195 * sure the partial 2MB page is still fully RAM - it's 219 * sure the partial 2MB page is still fully RAM - it's
196 * not well-specified to have a PAT-incompatible area 220 * not well-specified to have a PAT-incompatible area
197 * (unmapped RAM, device memory, etc.) in that hole. 221 * (unmapped RAM, device memory, etc.) in that hole.
198 */ 222 */
199 free_bootmem(__pa(pcpur_ptrs[cpu] + pcpur_size), 223 free_bootmem(__pa(pcpul_map[cpu].ptr + pcpul_size),
200 PMD_SIZE - pcpur_size); 224 PMD_SIZE - pcpul_size);
201 225
202 memcpy(pcpur_ptrs[cpu], __per_cpu_load, static_size); 226 memcpy(pcpul_map[cpu].ptr, __per_cpu_load, static_size);
203 } 227 }
204 228
205 /* allocate address and map */ 229 /* allocate address and map */
206 vm.flags = VM_ALLOC; 230 pcpul_vm.flags = VM_ALLOC;
207 vm.size = num_possible_cpus() * PMD_SIZE; 231 pcpul_vm.size = num_possible_cpus() * PMD_SIZE;
208 vm_area_register_early(&vm, PMD_SIZE); 232 vm_area_register_early(&pcpul_vm, PMD_SIZE);
209 233
210 for_each_possible_cpu(cpu) { 234 for_each_possible_cpu(cpu) {
211 pmd_t *pmd; 235 pmd_t *pmd, pmd_v;
212 236
213 pmd = populate_extra_pmd((unsigned long)vm.addr 237 pmd = populate_extra_pmd((unsigned long)pcpul_vm.addr +
214 + cpu * PMD_SIZE); 238 cpu * PMD_SIZE);
215 set_pmd(pmd, pfn_pmd(page_to_pfn(virt_to_page(pcpur_ptrs[cpu])), 239 pmd_v = pfn_pmd(page_to_pfn(virt_to_page(pcpul_map[cpu].ptr)),
216 PAGE_KERNEL_LARGE)); 240 PAGE_KERNEL_LARGE);
241 set_pmd(pmd, pmd_v);
217 } 242 }
218 243
219 /* we're ready, commit */ 244 /* we're ready, commit */
220 pr_info("PERCPU: Remapped at %p with large pages, static data " 245 pr_info("PERCPU: Remapped at %p with large pages, static data "
221 "%zu bytes\n", vm.addr, static_size); 246 "%zu bytes\n", pcpul_vm.addr, static_size);
222 247
223 ret = pcpu_setup_first_chunk(pcpur_get_page, static_size, 248 ret = pcpu_setup_first_chunk(pcpul_get_page, static_size,
224 PERCPU_FIRST_CHUNK_RESERVE, dyn_size, 249 PERCPU_FIRST_CHUNK_RESERVE, dyn_size,
225 PMD_SIZE, vm.addr, NULL); 250 PMD_SIZE, pcpul_vm.addr, NULL);
226 goto out_free_ar; 251
252 /* sort pcpul_map array for pcpu_lpage_remapped() */
253 for (i = 0; i < num_possible_cpus() - 1; i++)
254 for (j = i + 1; j < num_possible_cpus(); j++)
255 if (pcpul_map[i].ptr > pcpul_map[j].ptr) {
256 struct pcpul_ent tmp = pcpul_map[i];
257 pcpul_map[i] = pcpul_map[j];
258 pcpul_map[j] = tmp;
259 }
260
261 return ret;
227 262
228enomem: 263enomem:
229 for_each_possible_cpu(cpu) 264 for_each_possible_cpu(cpu)
230 if (pcpur_ptrs[cpu]) 265 if (pcpul_map[cpu].ptr)
231 free_bootmem(__pa(pcpur_ptrs[cpu]), PMD_SIZE); 266 free_bootmem(__pa(pcpul_map[cpu].ptr), pcpul_size);
232 ret = -ENOMEM; 267 free_bootmem(__pa(pcpul_map), map_size);
233out_free_ar: 268 return -ENOMEM;
234 free_bootmem(__pa(pcpur_ptrs), ptrs_size); 269}
235 return ret; 270
271/**
272 * pcpu_lpage_remapped - determine whether a kaddr is in pcpul recycled area
273 * @kaddr: the kernel address in question
274 *
275 * Determine whether @kaddr falls in the pcpul recycled area. This is
276 * used by pageattr to detect VM aliases and break up the pcpu PMD
277 * mapping such that the same physical page is not mapped under
278 * different attributes.
279 *
280 * The recycled area is always at the tail of a partially used PMD
281 * page.
282 *
283 * RETURNS:
284 * Address of corresponding remapped pcpu address if match is found;
285 * otherwise, NULL.
286 */
287void *pcpu_lpage_remapped(void *kaddr)
288{
289 void *pmd_addr = (void *)((unsigned long)kaddr & PMD_MASK);
290 unsigned long offset = (unsigned long)kaddr & ~PMD_MASK;
291 int left = 0, right = num_possible_cpus() - 1;
292 int pos;
293
294 /* pcpul in use at all? */
295 if (!pcpul_map)
296 return NULL;
297
298 /* okay, perform binary search */
299 while (left <= right) {
300 pos = (left + right) / 2;
301
302 if (pcpul_map[pos].ptr < pmd_addr)
303 left = pos + 1;
304 else if (pcpul_map[pos].ptr > pmd_addr)
305 right = pos - 1;
306 else {
307 /* it shouldn't be in the area for the first chunk */
308 WARN_ON(offset < pcpul_size);
309
310 return pcpul_vm.addr +
311 pcpul_map[pos].cpu * PMD_SIZE + offset;
312 }
313 }
314
315 return NULL;
236} 316}
237#else 317#else
238static ssize_t __init setup_pcpu_remap(size_t static_size) 318static ssize_t __init setup_pcpu_lpage(size_t static_size, bool chosen)
239{ 319{
240 return -EINVAL; 320 return -EINVAL;
241} 321}
@@ -249,7 +329,7 @@ static ssize_t __init setup_pcpu_remap(size_t static_size)
249 * mapping so that it can use PMD mapping without additional TLB 329 * mapping so that it can use PMD mapping without additional TLB
250 * pressure. 330 * pressure.
251 */ 331 */
252static ssize_t __init setup_pcpu_embed(size_t static_size) 332static ssize_t __init setup_pcpu_embed(size_t static_size, bool chosen)
253{ 333{
254 size_t reserve = PERCPU_MODULE_RESERVE + PERCPU_DYNAMIC_RESERVE; 334 size_t reserve = PERCPU_MODULE_RESERVE + PERCPU_DYNAMIC_RESERVE;
255 335
@@ -258,7 +338,7 @@ static ssize_t __init setup_pcpu_embed(size_t static_size)
258 * this. Also, embedding allocation doesn't play well with 338 * this. Also, embedding allocation doesn't play well with
259 * NUMA. 339 * NUMA.
260 */ 340 */
261 if (!cpu_has_pse || pcpu_need_numa()) 341 if (!chosen && (!cpu_has_pse || pcpu_need_numa()))
262 return -EINVAL; 342 return -EINVAL;
263 343
264 return pcpu_embed_first_chunk(static_size, PERCPU_FIRST_CHUNK_RESERVE, 344 return pcpu_embed_first_chunk(static_size, PERCPU_FIRST_CHUNK_RESERVE,
@@ -308,8 +388,11 @@ static ssize_t __init setup_pcpu_4k(size_t static_size)
308 void *ptr; 388 void *ptr;
309 389
310 ptr = pcpu_alloc_bootmem(cpu, PAGE_SIZE, PAGE_SIZE); 390 ptr = pcpu_alloc_bootmem(cpu, PAGE_SIZE, PAGE_SIZE);
311 if (!ptr) 391 if (!ptr) {
392 pr_warning("PERCPU: failed to allocate "
393 "4k page for cpu%u\n", cpu);
312 goto enomem; 394 goto enomem;
395 }
313 396
314 memcpy(ptr, __per_cpu_load + i * PAGE_SIZE, PAGE_SIZE); 397 memcpy(ptr, __per_cpu_load + i * PAGE_SIZE, PAGE_SIZE);
315 pcpu4k_pages[j++] = virt_to_page(ptr); 398 pcpu4k_pages[j++] = virt_to_page(ptr);
@@ -333,6 +416,16 @@ out_free_ar:
333 return ret; 416 return ret;
334} 417}
335 418
419/* for explicit first chunk allocator selection */
420static char pcpu_chosen_alloc[16] __initdata;
421
422static int __init percpu_alloc_setup(char *str)
423{
424 strncpy(pcpu_chosen_alloc, str, sizeof(pcpu_chosen_alloc) - 1);
425 return 0;
426}
427early_param("percpu_alloc", percpu_alloc_setup);
428
336static inline void setup_percpu_segment(int cpu) 429static inline void setup_percpu_segment(int cpu)
337{ 430{
338#ifdef CONFIG_X86_32 431#ifdef CONFIG_X86_32
@@ -346,11 +439,6 @@ static inline void setup_percpu_segment(int cpu)
346#endif 439#endif
347} 440}
348 441
349/*
350 * Great future plan:
351 * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data.
352 * Always point %gs to its beginning
353 */
354void __init setup_per_cpu_areas(void) 442void __init setup_per_cpu_areas(void)
355{ 443{
356 size_t static_size = __per_cpu_end - __per_cpu_start; 444 size_t static_size = __per_cpu_end - __per_cpu_start;
@@ -367,9 +455,26 @@ void __init setup_per_cpu_areas(void)
367 * of large page mappings. Please read comments on top of 455 * of large page mappings. Please read comments on top of
368 * each allocator for details. 456 * each allocator for details.
369 */ 457 */
370 ret = setup_pcpu_remap(static_size); 458 ret = -EINVAL;
371 if (ret < 0) 459 if (strlen(pcpu_chosen_alloc)) {
372 ret = setup_pcpu_embed(static_size); 460 if (strcmp(pcpu_chosen_alloc, "4k")) {
461 if (!strcmp(pcpu_chosen_alloc, "lpage"))
462 ret = setup_pcpu_lpage(static_size, true);
463 else if (!strcmp(pcpu_chosen_alloc, "embed"))
464 ret = setup_pcpu_embed(static_size, true);
465 else
466 pr_warning("PERCPU: unknown allocator %s "
467 "specified\n", pcpu_chosen_alloc);
468 if (ret < 0)
469 pr_warning("PERCPU: %s allocator failed (%zd), "
470 "falling back to 4k\n",
471 pcpu_chosen_alloc, ret);
472 }
473 } else {
474 ret = setup_pcpu_lpage(static_size, false);
475 if (ret < 0)
476 ret = setup_pcpu_embed(static_size, false);
477 }
373 if (ret < 0) 478 if (ret < 0)
374 ret = setup_pcpu_4k(static_size); 479 ret = setup_pcpu_4k(static_size);
375 if (ret < 0) 480 if (ret < 0)
diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c
index 124d40c575df..8ccabb8a2f6a 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/kernel/tlb_uv.c
@@ -711,7 +711,6 @@ uv_activation_descriptor_init(int node, int pnode)
711 unsigned long pa; 711 unsigned long pa;
712 unsigned long m; 712 unsigned long m;
713 unsigned long n; 713 unsigned long n;
714 unsigned long mmr_image;
715 struct bau_desc *adp; 714 struct bau_desc *adp;
716 struct bau_desc *ad2; 715 struct bau_desc *ad2;
717 716
@@ -727,12 +726,8 @@ uv_activation_descriptor_init(int node, int pnode)
727 n = pa >> uv_nshift; 726 n = pa >> uv_nshift;
728 m = pa & uv_mmask; 727 m = pa & uv_mmask;
729 728
730 mmr_image = uv_read_global_mmr64(pnode, UVH_LB_BAU_SB_DESCRIPTOR_BASE); 729 uv_write_global_mmr64(pnode, UVH_LB_BAU_SB_DESCRIPTOR_BASE,
731 if (mmr_image) { 730 (n << UV_DESC_BASE_PNODE_SHIFT | m));
732 uv_write_global_mmr64(pnode, (unsigned long)
733 UVH_LB_BAU_SB_DESCRIPTOR_BASE,
734 (n << UV_DESC_BASE_PNODE_SHIFT | m));
735 }
736 731
737 /* 732 /*
738 * initializing all 8 (UV_ITEMS_PER_DESCRIPTOR) descriptors for each 733 * initializing all 8 (UV_ITEMS_PER_DESCRIPTOR) descriptors for each
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index a0f48f5671c0..5204332f475d 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -346,6 +346,9 @@ io_check_error(unsigned char reason, struct pt_regs *regs)
346 printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n"); 346 printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
347 show_registers(regs); 347 show_registers(regs);
348 348
349 if (panic_on_io_nmi)
350 panic("NMI IOCK error: Not continuing");
351
349 /* Re-enable the IOCK line, wait for a few seconds */ 352 /* Re-enable the IOCK line, wait for a few seconds */
350 reason = (reason & 0xf) | 8; 353 reason = (reason & 0xf) | 8;
351 outb(reason, 0x61); 354 outb(reason, 0x61);
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 5c3d6e81a7dc..7030b5f911bf 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2157,7 +2157,7 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level)
2157 else 2157 else
2158 /* 32 bits PSE 4MB page */ 2158 /* 32 bits PSE 4MB page */
2159 context->rsvd_bits_mask[1][1] = rsvd_bits(13, 21); 2159 context->rsvd_bits_mask[1][1] = rsvd_bits(13, 21);
2160 context->rsvd_bits_mask[1][0] = ~0ull; 2160 context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[1][0];
2161 break; 2161 break;
2162 case PT32E_ROOT_LEVEL: 2162 case PT32E_ROOT_LEVEL:
2163 context->rsvd_bits_mask[0][2] = 2163 context->rsvd_bits_mask[0][2] =
@@ -2170,7 +2170,7 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level)
2170 context->rsvd_bits_mask[1][1] = exb_bit_rsvd | 2170 context->rsvd_bits_mask[1][1] = exb_bit_rsvd |
2171 rsvd_bits(maxphyaddr, 62) | 2171 rsvd_bits(maxphyaddr, 62) |
2172 rsvd_bits(13, 20); /* large page */ 2172 rsvd_bits(13, 20); /* large page */
2173 context->rsvd_bits_mask[1][0] = ~0ull; 2173 context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[1][0];
2174 break; 2174 break;
2175 case PT64_ROOT_LEVEL: 2175 case PT64_ROOT_LEVEL:
2176 context->rsvd_bits_mask[0][3] = exb_bit_rsvd | 2176 context->rsvd_bits_mask[0][3] = exb_bit_rsvd |
@@ -2186,7 +2186,7 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level)
2186 context->rsvd_bits_mask[1][1] = exb_bit_rsvd | 2186 context->rsvd_bits_mask[1][1] = exb_bit_rsvd |
2187 rsvd_bits(maxphyaddr, 51) | 2187 rsvd_bits(maxphyaddr, 51) |
2188 rsvd_bits(13, 20); /* large page */ 2188 rsvd_bits(13, 20); /* large page */
2189 context->rsvd_bits_mask[1][0] = ~0ull; 2189 context->rsvd_bits_mask[1][0] = context->rsvd_bits_mask[1][0];
2190 break; 2190 break;
2191 } 2191 }
2192} 2192}
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 258e4591e1ca..67785f635399 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -281,7 +281,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
281{ 281{
282 unsigned access = gw->pt_access; 282 unsigned access = gw->pt_access;
283 struct kvm_mmu_page *shadow_page; 283 struct kvm_mmu_page *shadow_page;
284 u64 spte, *sptep; 284 u64 spte, *sptep = NULL;
285 int direct; 285 int direct;
286 gfn_t table_gfn; 286 gfn_t table_gfn;
287 int r; 287 int r;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index e770bf349ec4..356a0ce85c68 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3012,6 +3012,12 @@ static int handle_vmcall(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3012 return 1; 3012 return 1;
3013} 3013}
3014 3014
3015static int handle_vmx_insn(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3016{
3017 kvm_queue_exception(vcpu, UD_VECTOR);
3018 return 1;
3019}
3020
3015static int handle_invlpg(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3021static int handle_invlpg(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3016{ 3022{
3017 unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION); 3023 unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
@@ -3198,6 +3204,15 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu,
3198 [EXIT_REASON_HLT] = handle_halt, 3204 [EXIT_REASON_HLT] = handle_halt,
3199 [EXIT_REASON_INVLPG] = handle_invlpg, 3205 [EXIT_REASON_INVLPG] = handle_invlpg,
3200 [EXIT_REASON_VMCALL] = handle_vmcall, 3206 [EXIT_REASON_VMCALL] = handle_vmcall,
3207 [EXIT_REASON_VMCLEAR] = handle_vmx_insn,
3208 [EXIT_REASON_VMLAUNCH] = handle_vmx_insn,
3209 [EXIT_REASON_VMPTRLD] = handle_vmx_insn,
3210 [EXIT_REASON_VMPTRST] = handle_vmx_insn,
3211 [EXIT_REASON_VMREAD] = handle_vmx_insn,
3212 [EXIT_REASON_VMRESUME] = handle_vmx_insn,
3213 [EXIT_REASON_VMWRITE] = handle_vmx_insn,
3214 [EXIT_REASON_VMOFF] = handle_vmx_insn,
3215 [EXIT_REASON_VMON] = handle_vmx_insn,
3201 [EXIT_REASON_TPR_BELOW_THRESHOLD] = handle_tpr_below_threshold, 3216 [EXIT_REASON_TPR_BELOW_THRESHOLD] = handle_tpr_below_threshold,
3202 [EXIT_REASON_APIC_ACCESS] = handle_apic_access, 3217 [EXIT_REASON_APIC_ACCESS] = handle_apic_access,
3203 [EXIT_REASON_WBINVD] = handle_wbinvd, 3218 [EXIT_REASON_WBINVD] = handle_wbinvd,
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 249540f98513..fe5474aec41a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -898,6 +898,7 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
898 case MSR_VM_HSAVE_PA: 898 case MSR_VM_HSAVE_PA:
899 case MSR_P6_EVNTSEL0: 899 case MSR_P6_EVNTSEL0:
900 case MSR_P6_EVNTSEL1: 900 case MSR_P6_EVNTSEL1:
901 case MSR_K7_EVNTSEL0:
901 data = 0; 902 data = 0;
902 break; 903 break;
903 case MSR_MTRRcap: 904 case MSR_MTRRcap:
diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index c1b6c232e02b..616de4628d60 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -1361,7 +1361,7 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt,
1361 return 0; 1361 return 0;
1362} 1362}
1363 1363
1364void toggle_interruptibility(struct x86_emulate_ctxt *ctxt, u32 mask) 1364static void toggle_interruptibility(struct x86_emulate_ctxt *ctxt, u32 mask)
1365{ 1365{
1366 u32 int_shadow = kvm_x86_ops->get_interrupt_shadow(ctxt->vcpu, mask); 1366 u32 int_shadow = kvm_x86_ops->get_interrupt_shadow(ctxt->vcpu, mask);
1367 /* 1367 /*
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index f9d35632666b..07c31899c9c2 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -10,6 +10,7 @@ lib-y += usercopy_$(BITS).o getuser.o putuser.o
10lib-y += memcpy_$(BITS).o 10lib-y += memcpy_$(BITS).o
11 11
12ifeq ($(CONFIG_X86_32),y) 12ifeq ($(CONFIG_X86_32),y)
13 obj-y += atomic64_32.o
13 lib-y += checksum_32.o 14 lib-y += checksum_32.o
14 lib-y += strstr_32.o 15 lib-y += strstr_32.o
15 lib-y += semaphore_32.o string_32.o 16 lib-y += semaphore_32.o string_32.o
diff --git a/arch/x86/lib/atomic64_32.c b/arch/x86/lib/atomic64_32.c
new file mode 100644
index 000000000000..824fa0be55a3
--- /dev/null
+++ b/arch/x86/lib/atomic64_32.c
@@ -0,0 +1,230 @@
1#include <linux/compiler.h>
2#include <linux/module.h>
3#include <linux/types.h>
4
5#include <asm/processor.h>
6#include <asm/cmpxchg.h>
7#include <asm/atomic.h>
8
9static noinline u64 cmpxchg8b(u64 *ptr, u64 old, u64 new)
10{
11 u32 low = new;
12 u32 high = new >> 32;
13
14 asm volatile(
15 LOCK_PREFIX "cmpxchg8b %1\n"
16 : "+A" (old), "+m" (*ptr)
17 : "b" (low), "c" (high)
18 );
19 return old;
20}
21
22u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old_val, u64 new_val)
23{
24 return cmpxchg8b(&ptr->counter, old_val, new_val);
25}
26EXPORT_SYMBOL(atomic64_cmpxchg);
27
28/**
29 * atomic64_xchg - xchg atomic64 variable
30 * @ptr: pointer to type atomic64_t
31 * @new_val: value to assign
32 *
33 * Atomically xchgs the value of @ptr to @new_val and returns
34 * the old value.
35 */
36u64 atomic64_xchg(atomic64_t *ptr, u64 new_val)
37{
38 /*
39 * Try first with a (possibly incorrect) assumption about
40 * what we have there. We'll do two loops most likely,
41 * but we'll get an ownership MESI transaction straight away
42 * instead of a read transaction followed by a
43 * flush-for-ownership transaction:
44 */
45 u64 old_val, real_val = 0;
46
47 do {
48 old_val = real_val;
49
50 real_val = atomic64_cmpxchg(ptr, old_val, new_val);
51
52 } while (real_val != old_val);
53
54 return old_val;
55}
56EXPORT_SYMBOL(atomic64_xchg);
57
58/**
59 * atomic64_set - set atomic64 variable
60 * @ptr: pointer to type atomic64_t
61 * @new_val: value to assign
62 *
63 * Atomically sets the value of @ptr to @new_val.
64 */
65void atomic64_set(atomic64_t *ptr, u64 new_val)
66{
67 atomic64_xchg(ptr, new_val);
68}
69EXPORT_SYMBOL(atomic64_set);
70
71/**
72EXPORT_SYMBOL(atomic64_read);
73 * atomic64_add_return - add and return
74 * @delta: integer value to add
75 * @ptr: pointer to type atomic64_t
76 *
77 * Atomically adds @delta to @ptr and returns @delta + *@ptr
78 */
79noinline u64 atomic64_add_return(u64 delta, atomic64_t *ptr)
80{
81 /*
82 * Try first with a (possibly incorrect) assumption about
83 * what we have there. We'll do two loops most likely,
84 * but we'll get an ownership MESI transaction straight away
85 * instead of a read transaction followed by a
86 * flush-for-ownership transaction:
87 */
88 u64 old_val, new_val, real_val = 0;
89
90 do {
91 old_val = real_val;
92 new_val = old_val + delta;
93
94 real_val = atomic64_cmpxchg(ptr, old_val, new_val);
95
96 } while (real_val != old_val);
97
98 return new_val;
99}
100EXPORT_SYMBOL(atomic64_add_return);
101
102u64 atomic64_sub_return(u64 delta, atomic64_t *ptr)
103{
104 return atomic64_add_return(-delta, ptr);
105}
106EXPORT_SYMBOL(atomic64_sub_return);
107
108u64 atomic64_inc_return(atomic64_t *ptr)
109{
110 return atomic64_add_return(1, ptr);
111}
112EXPORT_SYMBOL(atomic64_inc_return);
113
114u64 atomic64_dec_return(atomic64_t *ptr)
115{
116 return atomic64_sub_return(1, ptr);
117}
118EXPORT_SYMBOL(atomic64_dec_return);
119
120/**
121 * atomic64_add - add integer to atomic64 variable
122 * @delta: integer value to add
123 * @ptr: pointer to type atomic64_t
124 *
125 * Atomically adds @delta to @ptr.
126 */
127void atomic64_add(u64 delta, atomic64_t *ptr)
128{
129 atomic64_add_return(delta, ptr);
130}
131EXPORT_SYMBOL(atomic64_add);
132
133/**
134 * atomic64_sub - subtract the atomic64 variable
135 * @delta: integer value to subtract
136 * @ptr: pointer to type atomic64_t
137 *
138 * Atomically subtracts @delta from @ptr.
139 */
140void atomic64_sub(u64 delta, atomic64_t *ptr)
141{
142 atomic64_add(-delta, ptr);
143}
144EXPORT_SYMBOL(atomic64_sub);
145
146/**
147 * atomic64_sub_and_test - subtract value from variable and test result
148 * @delta: integer value to subtract
149 * @ptr: pointer to type atomic64_t
150 *
151 * Atomically subtracts @delta from @ptr and returns
152 * true if the result is zero, or false for all
153 * other cases.
154 */
155int atomic64_sub_and_test(u64 delta, atomic64_t *ptr)
156{
157 u64 new_val = atomic64_sub_return(delta, ptr);
158
159 return new_val == 0;
160}
161EXPORT_SYMBOL(atomic64_sub_and_test);
162
163/**
164 * atomic64_inc - increment atomic64 variable
165 * @ptr: pointer to type atomic64_t
166 *
167 * Atomically increments @ptr by 1.
168 */
169void atomic64_inc(atomic64_t *ptr)
170{
171 atomic64_add(1, ptr);
172}
173EXPORT_SYMBOL(atomic64_inc);
174
175/**
176 * atomic64_dec - decrement atomic64 variable
177 * @ptr: pointer to type atomic64_t
178 *
179 * Atomically decrements @ptr by 1.
180 */
181void atomic64_dec(atomic64_t *ptr)
182{
183 atomic64_sub(1, ptr);
184}
185EXPORT_SYMBOL(atomic64_dec);
186
187/**
188 * atomic64_dec_and_test - decrement and test
189 * @ptr: pointer to type atomic64_t
190 *
191 * Atomically decrements @ptr by 1 and
192 * returns true if the result is 0, or false for all other
193 * cases.
194 */
195int atomic64_dec_and_test(atomic64_t *ptr)
196{
197 return atomic64_sub_and_test(1, ptr);
198}
199EXPORT_SYMBOL(atomic64_dec_and_test);
200
201/**
202 * atomic64_inc_and_test - increment and test
203 * @ptr: pointer to type atomic64_t
204 *
205 * Atomically increments @ptr by 1
206 * and returns true if the result is zero, or false for all
207 * other cases.
208 */
209int atomic64_inc_and_test(atomic64_t *ptr)
210{
211 return atomic64_sub_and_test(-1, ptr);
212}
213EXPORT_SYMBOL(atomic64_inc_and_test);
214
215/**
216 * atomic64_add_negative - add and test if negative
217 * @delta: integer value to add
218 * @ptr: pointer to type atomic64_t
219 *
220 * Atomically adds @delta to @ptr and returns true
221 * if the result is negative, or false when
222 * result is greater than or equal to zero.
223 */
224int atomic64_add_negative(u64 delta, atomic64_t *ptr)
225{
226 s64 new_val = atomic64_add_return(delta, ptr);
227
228 return new_val < 0;
229}
230EXPORT_SYMBOL(atomic64_add_negative);
diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
index 9a10a78bb4a4..ebeafcce04a9 100644
--- a/arch/x86/lib/clear_page_64.S
+++ b/arch/x86/lib/clear_page_64.S
@@ -5,15 +5,14 @@
5 * Zero a page. 5 * Zero a page.
6 * rdi page 6 * rdi page
7 */ 7 */
8 ALIGN 8ENTRY(clear_page_c)
9clear_page_c:
10 CFI_STARTPROC 9 CFI_STARTPROC
11 movl $4096/8,%ecx 10 movl $4096/8,%ecx
12 xorl %eax,%eax 11 xorl %eax,%eax
13 rep stosq 12 rep stosq
14 ret 13 ret
15 CFI_ENDPROC 14 CFI_ENDPROC
16ENDPROC(clear_page) 15ENDPROC(clear_page_c)
17 16
18ENTRY(clear_page) 17ENTRY(clear_page)
19 CFI_STARTPROC 18 CFI_STARTPROC
diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
index f118c110af32..6ba0f7bb85ea 100644
--- a/arch/x86/lib/copy_user_64.S
+++ b/arch/x86/lib/copy_user_64.S
@@ -75,6 +75,7 @@ ENTRY(copy_to_user)
75 jae bad_to_user 75 jae bad_to_user
76 ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string 76 ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
77 CFI_ENDPROC 77 CFI_ENDPROC
78ENDPROC(copy_to_user)
78 79
79/* Standard copy_from_user with segment limit checking */ 80/* Standard copy_from_user with segment limit checking */
80ENTRY(copy_from_user) 81ENTRY(copy_from_user)
diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
index f4568605d7d5..ff485d361182 100644
--- a/arch/x86/lib/delay.c
+++ b/arch/x86/lib/delay.c
@@ -55,8 +55,10 @@ static void delay_tsc(unsigned long loops)
55 55
56 preempt_disable(); 56 preempt_disable();
57 cpu = smp_processor_id(); 57 cpu = smp_processor_id();
58 rdtsc_barrier();
58 rdtscl(bclock); 59 rdtscl(bclock);
59 for (;;) { 60 for (;;) {
61 rdtsc_barrier();
60 rdtscl(now); 62 rdtscl(now);
61 if ((now - bclock) >= loops) 63 if ((now - bclock) >= loops)
62 break; 64 break;
@@ -78,6 +80,7 @@ static void delay_tsc(unsigned long loops)
78 if (unlikely(cpu != smp_processor_id())) { 80 if (unlikely(cpu != smp_processor_id())) {
79 loops -= (now - bclock); 81 loops -= (now - bclock);
80 cpu = smp_processor_id(); 82 cpu = smp_processor_id();
83 rdtsc_barrier();
81 rdtscl(bclock); 84 rdtscl(bclock);
82 } 85 }
83 } 86 }
diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
index 7c8ca91bb9ec..1f118d462acc 100644
--- a/arch/x86/lib/usercopy_32.c
+++ b/arch/x86/lib/usercopy_32.c
@@ -751,7 +751,7 @@ survive:
751 751
752 if (retval == -ENOMEM && is_global_init(current)) { 752 if (retval == -ENOMEM && is_global_init(current)) {
753 up_read(&current->mm->mmap_sem); 753 up_read(&current->mm->mmap_sem);
754 congestion_wait(WRITE, HZ/50); 754 congestion_wait(BLK_RW_ASYNC, HZ/50);
755 goto survive; 755 goto survive;
756 } 756 }
757 757
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 78a5fff857be..85307cc6e45f 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -426,10 +426,11 @@ static noinline int vmalloc_fault(unsigned long address)
426} 426}
427 427
428static const char errata93_warning[] = 428static const char errata93_warning[] =
429KERN_ERR "******* Your BIOS seems to not contain a fix for K8 errata #93\n" 429KERN_ERR
430KERN_ERR "******* Working around it, but it may cause SEGVs or burn power.\n" 430"******* Your BIOS seems to not contain a fix for K8 errata #93\n"
431KERN_ERR "******* Please consider a BIOS update.\n" 431"******* Working around it, but it may cause SEGVs or burn power.\n"
432KERN_ERR "******* Disabling USB legacy in the BIOS may also help.\n"; 432"******* Please consider a BIOS update.\n"
433"******* Disabling USB legacy in the BIOS may also help.\n";
433 434
434/* 435/*
435 * No vm86 mode in 64-bit mode: 436 * No vm86 mode in 64-bit mode:
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index f53b57e4086f..0607119cef94 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -12,6 +12,7 @@
12#include <asm/system.h> 12#include <asm/system.h>
13#include <asm/tlbflush.h> 13#include <asm/tlbflush.h>
14#include <asm/tlb.h> 14#include <asm/tlb.h>
15#include <asm/proto.h>
15 16
16DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 17DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
17 18
@@ -177,20 +178,6 @@ static int __meminit save_mr(struct map_range *mr, int nr_range,
177 return nr_range; 178 return nr_range;
178} 179}
179 180
180#ifdef CONFIG_X86_64
181static void __init init_gbpages(void)
182{
183 if (direct_gbpages && cpu_has_gbpages)
184 printk(KERN_INFO "Using GB pages for direct mapping\n");
185 else
186 direct_gbpages = 0;
187}
188#else
189static inline void init_gbpages(void)
190{
191}
192#endif
193
194/* 181/*
195 * Setup the direct mapping of the physical memory at PAGE_OFFSET. 182 * Setup the direct mapping of the physical memory at PAGE_OFFSET.
196 * This runs before bootmem is initialized and gets pages directly from 183 * This runs before bootmem is initialized and gets pages directly from
@@ -210,9 +197,6 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
210 197
211 printk(KERN_INFO "init_memory_mapping: %016lx-%016lx\n", start, end); 198 printk(KERN_INFO "init_memory_mapping: %016lx-%016lx\n", start, end);
212 199
213 if (!after_bootmem)
214 init_gbpages();
215
216#if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK) 200#if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
217 /* 201 /*
218 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages. 202 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index c4378f4fd4a5..6176fe8f29e0 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -598,6 +598,15 @@ void __init paging_init(void)
598 598
599 sparse_memory_present_with_active_regions(MAX_NUMNODES); 599 sparse_memory_present_with_active_regions(MAX_NUMNODES);
600 sparse_init(); 600 sparse_init();
601
602 /*
603 * clear the default setting with node 0
604 * note: don't use nodes_clear here, that is really clearing when
605 * numa support is not compiled in, and later node_set_state
606 * will not set it back.
607 */
608 node_clear_state(0, N_NORMAL_MEMORY);
609
601 free_area_init_nodes(max_zone_pfns); 610 free_area_init_nodes(max_zone_pfns);
602} 611}
603 612
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 3cfe9ced8a4c..1b734d7a8966 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -11,6 +11,7 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
13#include <linux/debugfs.h> 13#include <linux/debugfs.h>
14#include <linux/pfn.h>
14 15
15#include <asm/e820.h> 16#include <asm/e820.h>
16#include <asm/processor.h> 17#include <asm/processor.h>
@@ -681,8 +682,9 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias);
681static int cpa_process_alias(struct cpa_data *cpa) 682static int cpa_process_alias(struct cpa_data *cpa)
682{ 683{
683 struct cpa_data alias_cpa; 684 struct cpa_data alias_cpa;
684 int ret = 0; 685 unsigned long laddr = (unsigned long)__va(cpa->pfn << PAGE_SHIFT);
685 unsigned long temp_cpa_vaddr, vaddr; 686 unsigned long vaddr, remapped;
687 int ret;
686 688
687 if (cpa->pfn >= max_pfn_mapped) 689 if (cpa->pfn >= max_pfn_mapped)
688 return 0; 690 return 0;
@@ -706,42 +708,55 @@ static int cpa_process_alias(struct cpa_data *cpa)
706 PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT)))) { 708 PAGE_OFFSET + (max_pfn_mapped << PAGE_SHIFT)))) {
707 709
708 alias_cpa = *cpa; 710 alias_cpa = *cpa;
709 temp_cpa_vaddr = (unsigned long) __va(cpa->pfn << PAGE_SHIFT); 711 alias_cpa.vaddr = &laddr;
710 alias_cpa.vaddr = &temp_cpa_vaddr;
711 alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY); 712 alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY);
712 713
713
714 ret = __change_page_attr_set_clr(&alias_cpa, 0); 714 ret = __change_page_attr_set_clr(&alias_cpa, 0);
715 if (ret)
716 return ret;
715 } 717 }
716 718
717#ifdef CONFIG_X86_64 719#ifdef CONFIG_X86_64
718 if (ret)
719 return ret;
720 /* 720 /*
721 * No need to redo, when the primary call touched the high 721 * If the primary call didn't touch the high mapping already
722 * mapping already: 722 * and the physical address is inside the kernel map, we need
723 */
724 if (within(vaddr, (unsigned long) _text, _brk_end))
725 return 0;
726
727 /*
728 * If the physical address is inside the kernel map, we need
729 * to touch the high mapped kernel as well: 723 * to touch the high mapped kernel as well:
730 */ 724 */
731 if (!within(cpa->pfn, highmap_start_pfn(), highmap_end_pfn())) 725 if (!within(vaddr, (unsigned long)_text, _brk_end) &&
732 return 0; 726 within(cpa->pfn, highmap_start_pfn(), highmap_end_pfn())) {
727 unsigned long temp_cpa_vaddr = (cpa->pfn << PAGE_SHIFT) +
728 __START_KERNEL_map - phys_base;
729 alias_cpa = *cpa;
730 alias_cpa.vaddr = &temp_cpa_vaddr;
731 alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY);
733 732
734 alias_cpa = *cpa; 733 /*
735 temp_cpa_vaddr = (cpa->pfn << PAGE_SHIFT) + __START_KERNEL_map - phys_base; 734 * The high mapping range is imprecise, so ignore the
736 alias_cpa.vaddr = &temp_cpa_vaddr; 735 * return value.
737 alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY); 736 */
737 __change_page_attr_set_clr(&alias_cpa, 0);
738 }
739#endif
738 740
739 /* 741 /*
740 * The high mapping range is imprecise, so ignore the return value. 742 * If the PMD page was partially used for per-cpu remapping,
743 * the recycled area needs to be split and modified. Because
744 * the area is always proper subset of a PMD page
745 * cpa->numpages is guaranteed to be 1 for these areas, so
746 * there's no need to loop over and check for further remaps.
741 */ 747 */
742 __change_page_attr_set_clr(&alias_cpa, 0); 748 remapped = (unsigned long)pcpu_lpage_remapped((void *)laddr);
743#endif 749 if (remapped) {
744 return ret; 750 WARN_ON(cpa->numpages > 1);
751 alias_cpa = *cpa;
752 alias_cpa.vaddr = &remapped;
753 alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY);
754 ret = __change_page_attr_set_clr(&alias_cpa, 0);
755 if (ret)
756 return ret;
757 }
758
759 return 0;
745} 760}
746 761
747static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias) 762static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index b07dd8d0b321..89b9a5cd63da 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -390,7 +390,7 @@ static int __init p4_init(char **cpu_type)
390static int force_arch_perfmon; 390static int force_arch_perfmon;
391static int force_cpu_type(const char *str, struct kernel_param *kp) 391static int force_cpu_type(const char *str, struct kernel_param *kp)
392{ 392{
393 if (!strcmp(str, "archperfmon")) { 393 if (!strcmp(str, "arch_perfmon")) {
394 force_arch_perfmon = 1; 394 force_arch_perfmon = 1;
395 printk(KERN_INFO "oprofile: forcing architectural perfmon\n"); 395 printk(KERN_INFO "oprofile: forcing architectural perfmon\n");
396 } 396 }
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index b26626dc517c..1014eb4bfc37 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -68,6 +68,10 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
68 unsigned long flags; 68 unsigned long flags;
69 struct resource *root; 69 struct resource *root;
70 int max_root_bus_resources = PCI_BUS_NUM_RESOURCES; 70 int max_root_bus_resources = PCI_BUS_NUM_RESOURCES;
71 u64 start, end;
72
73 if (bus_has_transparent_bridge(info->bus))
74 max_root_bus_resources -= 3;
71 75
72 status = resource_to_addr(acpi_res, &addr); 76 status = resource_to_addr(acpi_res, &addr);
73 if (!ACPI_SUCCESS(status)) 77 if (!ACPI_SUCCESS(status))
@@ -84,25 +88,24 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
84 } else 88 } else
85 return AE_OK; 89 return AE_OK;
86 90
87 res = &info->res[info->res_num]; 91 start = addr.minimum + addr.translation_offset;
88 res->name = info->name; 92 end = start + addr.address_length - 1;
89 res->flags = flags;
90 res->start = addr.minimum + addr.translation_offset;
91 res->end = res->start + addr.address_length - 1;
92 res->child = NULL;
93
94 if (bus_has_transparent_bridge(info->bus))
95 max_root_bus_resources -= 3;
96 if (info->res_num >= max_root_bus_resources) { 93 if (info->res_num >= max_root_bus_resources) {
97 printk(KERN_WARNING "PCI: Failed to allocate 0x%lx-0x%lx " 94 printk(KERN_WARNING "PCI: Failed to allocate 0x%lx-0x%lx "
98 "from %s for %s due to _CRS returning more than " 95 "from %s for %s due to _CRS returning more than "
99 "%d resource descriptors\n", (unsigned long) res->start, 96 "%d resource descriptors\n", (unsigned long) start,
100 (unsigned long) res->end, root->name, info->name, 97 (unsigned long) end, root->name, info->name,
101 max_root_bus_resources); 98 max_root_bus_resources);
102 info->res_num++;
103 return AE_OK; 99 return AE_OK;
104 } 100 }
105 101
102 res = &info->res[info->res_num];
103 res->name = info->name;
104 res->flags = flags;
105 res->start = start;
106 res->end = end;
107 res->child = NULL;
108
106 if (insert_resource(root, res)) { 109 if (insert_resource(root, res)) {
107 printk(KERN_ERR "PCI: Failed to allocate 0x%lx-0x%lx " 110 printk(KERN_ERR "PCI: Failed to allocate 0x%lx-0x%lx "
108 "from %s for %s\n", (unsigned long) res->start, 111 "from %s for %s\n", (unsigned long) res->start,
@@ -115,23 +118,6 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
115} 118}
116 119
117static void 120static void
118adjust_transparent_bridge_resources(struct pci_bus *bus)
119{
120 struct pci_dev *dev;
121
122 list_for_each_entry(dev, &bus->devices, bus_list) {
123 int i;
124 u16 class = dev->class >> 8;
125
126 if (class == PCI_CLASS_BRIDGE_PCI && dev->transparent) {
127 for(i = 3; i < PCI_BUS_NUM_RESOURCES; i++)
128 dev->subordinate->resource[i] =
129 dev->bus->resource[i - 3];
130 }
131 }
132}
133
134static void
135get_current_resources(struct acpi_device *device, int busnum, 121get_current_resources(struct acpi_device *device, int busnum,
136 int domain, struct pci_bus *bus) 122 int domain, struct pci_bus *bus)
137{ 123{
@@ -158,8 +144,6 @@ get_current_resources(struct acpi_device *device, int busnum,
158 info.res_num = 0; 144 info.res_num = 0;
159 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, 145 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource,
160 &info); 146 &info);
161 if (info.res_num)
162 adjust_transparent_bridge_resources(bus);
163 147
164 return; 148 return;
165 149
@@ -222,8 +206,15 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do
222 */ 206 */
223 memcpy(bus->sysdata, sd, sizeof(*sd)); 207 memcpy(bus->sysdata, sd, sizeof(*sd));
224 kfree(sd); 208 kfree(sd);
225 } else 209 } else {
226 bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd); 210 bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd);
211 if (bus) {
212 if (pci_probe & PCI_USE__CRS)
213 get_current_resources(device, busnum, domain,
214 bus);
215 bus->subordinate = pci_scan_child_bus(bus);
216 }
217 }
227 218
228 if (!bus) 219 if (!bus)
229 kfree(sd); 220 kfree(sd);
@@ -238,8 +229,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do
238#endif 229#endif
239 } 230 }
240 231
241 if (bus && (pci_probe & PCI_USE__CRS))
242 get_current_resources(device, busnum, domain, bus);
243 return bus; 232 return bus;
244} 233}
245 234
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index f893d6a6e803..3ffa10df20b9 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -100,8 +100,9 @@ void x86_pci_root_bus_res_quirks(struct pci_bus *b)
100 int j; 100 int j;
101 struct pci_root_info *info; 101 struct pci_root_info *info;
102 102
103 /* don't go for it if _CRS is used */ 103 /* don't go for it if _CRS is used already */
104 if (pci_probe & PCI_USE__CRS) 104 if (b->resource[0] != &ioport_resource ||
105 b->resource[1] != &iomem_resource)
105 return; 106 return;
106 107
107 /* if only one root bus, don't need to anything */ 108 /* if only one root bus, don't need to anything */
@@ -116,6 +117,9 @@ void x86_pci_root_bus_res_quirks(struct pci_bus *b)
116 if (i == pci_root_num) 117 if (i == pci_root_num)
117 return; 118 return;
118 119
120 printk(KERN_DEBUG "PCI: peer root bus %02x res updated from pci conf\n",
121 b->number);
122
119 info = &pci_root_info[i]; 123 info = &pci_root_info[i];
120 for (j = 0; j < info->res_num; j++) { 124 for (j = 0; j < info->res_num; j++) {
121 struct resource *res; 125 struct resource *res;
diff --git a/arch/x86/power/Makefile b/arch/x86/power/Makefile
index de2abbd07544..a6a198c33623 100644
--- a/arch/x86/power/Makefile
+++ b/arch/x86/power/Makefile
@@ -1,7 +1,7 @@
1# __restore_processor_state() restores %gs after S3 resume and so should not 1# __restore_processor_state() restores %gs after S3 resume and so should not
2# itself be stack-protected 2# itself be stack-protected
3nostackp := $(call cc-option, -fno-stack-protector) 3nostackp := $(call cc-option, -fno-stack-protector)
4CFLAGS_cpu_$(BITS).o := $(nostackp) 4CFLAGS_cpu.o := $(nostackp)
5 5
6obj-$(CONFIG_PM_SLEEP) += cpu.o 6obj-$(CONFIG_PM_SLEEP) += cpu.o
7obj-$(CONFIG_HIBERNATION) += hibernate_$(BITS).o hibernate_asm_$(BITS).o 7obj-$(CONFIG_HIBERNATION) += hibernate_$(BITS).o hibernate_asm_$(BITS).o
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
index d277ef1eea51..b3d20b9cac63 100644
--- a/arch/x86/power/cpu.c
+++ b/arch/x86/power/cpu.c
@@ -244,7 +244,7 @@ static void __restore_processor_state(struct saved_context *ctxt)
244 do_fpu_end(); 244 do_fpu_end();
245 mtrr_ap_init(); 245 mtrr_ap_init();
246 246
247#ifdef CONFIG_X86_32 247#ifdef CONFIG_X86_OLD_MCE
248 mcheck_init(&boot_cpu_data); 248 mcheck_init(&boot_cpu_data);
249#endif 249#endif
250} 250}
diff --git a/arch/xtensa/include/asm/thread_info.h b/arch/xtensa/include/asm/thread_info.h
index 0f4fe1faf9ba..13165641cc51 100644
--- a/arch/xtensa/include/asm/thread_info.h
+++ b/arch/xtensa/include/asm/thread_info.h
@@ -80,8 +80,6 @@ struct thread_info {
80 80
81/* 81/*
82 * macros/functions for gaining access to the thread information structure 82 * macros/functions for gaining access to the thread information structure
83 *
84 * preempt_count needs to be 1 initially, until the scheduler is functional.
85 */ 83 */
86 84
87#ifndef __ASSEMBLY__ 85#ifndef __ASSEMBLY__
@@ -92,7 +90,7 @@ struct thread_info {
92 .exec_domain = &default_exec_domain, \ 90 .exec_domain = &default_exec_domain, \
93 .flags = 0, \ 91 .flags = 0, \
94 .cpu = 0, \ 92 .cpu = 0, \
95 .preempt_count = 1, \ 93 .preempt_count = INIT_PREEMPT_COUNT, \
96 .addr_limit = KERNEL_DS, \ 94 .addr_limit = KERNEL_DS, \
97 .restart_block = { \ 95 .restart_block = { \
98 .fn = do_no_restart_syscall, \ 96 .fn = do_no_restart_syscall, \
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index ba9ab9349782..e64efac3b9db 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -354,10 +354,10 @@ void show_regs(struct pt_regs * regs)
354 354
355 for (i = 0; i < 16; i++) { 355 for (i = 0; i < 16; i++) {
356 if ((i % 8) == 0) 356 if ((i % 8) == 0)
357 printk ("\n" KERN_INFO "a%02d: ", i); 357 printk(KERN_INFO "a%02d:", i);
358 printk("%08lx ", regs->areg[i]); 358 printk(KERN_CONT " %08lx", regs->areg[i]);
359 } 359 }
360 printk("\n"); 360 printk(KERN_CONT "\n");
361 361
362 printk("pc: %08lx, ps: %08lx, depc: %08lx, excvaddr: %08lx\n", 362 printk("pc: %08lx, ps: %08lx, depc: %08lx, excvaddr: %08lx\n",
363 regs->pc, regs->ps, regs->depc, regs->excvaddr); 363 regs->pc, regs->ps, regs->depc, regs->excvaddr);
diff --git a/block/Makefile b/block/Makefile
index e9fa4dd690f2..6c54ed0ff755 100644
--- a/block/Makefile
+++ b/block/Makefile
@@ -5,7 +5,7 @@
5obj-$(CONFIG_BLOCK) := elevator.o blk-core.o blk-tag.o blk-sysfs.o \ 5obj-$(CONFIG_BLOCK) := elevator.o blk-core.o blk-tag.o blk-sysfs.o \
6 blk-barrier.o blk-settings.o blk-ioc.o blk-map.o \ 6 blk-barrier.o blk-settings.o blk-ioc.o blk-map.o \
7 blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \ 7 blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \
8 ioctl.o genhd.o scsi_ioctl.o cmd-filter.o 8 ioctl.o genhd.o scsi_ioctl.o
9 9
10obj-$(CONFIG_BLK_DEV_BSG) += bsg.o 10obj-$(CONFIG_BLK_DEV_BSG) += bsg.o
11obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o 11obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o
diff --git a/block/blk-core.c b/block/blk-core.c
index b06cf5c2a829..4b45435c6eaf 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -595,8 +595,6 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
595 595
596 q->sg_reserved_size = INT_MAX; 596 q->sg_reserved_size = INT_MAX;
597 597
598 blk_set_cmd_filter_defaults(&q->cmd_filter);
599
600 /* 598 /*
601 * all done 599 * all done
602 */ 600 */
@@ -1172,6 +1170,11 @@ static int __make_request(struct request_queue *q, struct bio *bio)
1172 const int unplug = bio_unplug(bio); 1170 const int unplug = bio_unplug(bio);
1173 int rw_flags; 1171 int rw_flags;
1174 1172
1173 if (bio_barrier(bio) && bio_has_data(bio) &&
1174 (q->next_ordered == QUEUE_ORDERED_NONE)) {
1175 bio_endio(bio, -EOPNOTSUPP);
1176 return 0;
1177 }
1175 /* 1178 /*
1176 * low level driver can indicate that it wants pages above a 1179 * low level driver can indicate that it wants pages above a
1177 * certain limit bounced to low memory (ie for highmem, or even 1180 * certain limit bounced to low memory (ie for highmem, or even
@@ -1472,11 +1475,6 @@ static inline void __generic_make_request(struct bio *bio)
1472 err = -EOPNOTSUPP; 1475 err = -EOPNOTSUPP;
1473 goto end_io; 1476 goto end_io;
1474 } 1477 }
1475 if (bio_barrier(bio) && bio_has_data(bio) &&
1476 (q->next_ordered == QUEUE_ORDERED_NONE)) {
1477 err = -EOPNOTSUPP;
1478 goto end_io;
1479 }
1480 1478
1481 ret = q->make_request_fn(q, bio); 1479 ret = q->make_request_fn(q, bio);
1482 } while (ret); 1480 } while (ret);
@@ -2365,7 +2363,7 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
2365 __bio_clone(bio, bio_src); 2363 __bio_clone(bio, bio_src);
2366 2364
2367 if (bio_integrity(bio_src) && 2365 if (bio_integrity(bio_src) &&
2368 bio_integrity_clone(bio, bio_src, gfp_mask)) 2366 bio_integrity_clone(bio, bio_src, gfp_mask, bs))
2369 goto free_and_out; 2367 goto free_and_out;
2370 2368
2371 if (bio_ctr && bio_ctr(bio, bio_src, data)) 2369 if (bio_ctr && bio_ctr(bio, bio_src, data))
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 39ce64432ba6..e1999679a4d5 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -350,6 +350,12 @@ static int attempt_merge(struct request_queue *q, struct request *req,
350 if (blk_integrity_rq(req) != blk_integrity_rq(next)) 350 if (blk_integrity_rq(req) != blk_integrity_rq(next))
351 return 0; 351 return 0;
352 352
353 /* don't merge requests of different failfast settings */
354 if (blk_failfast_dev(req) != blk_failfast_dev(next) ||
355 blk_failfast_transport(req) != blk_failfast_transport(next) ||
356 blk_failfast_driver(req) != blk_failfast_driver(next))
357 return 0;
358
353 /* 359 /*
354 * If we are allowed to merge, then append bio list 360 * If we are allowed to merge, then append bio list
355 * from next to rq and release next. merge_requests_fn 361 * from next to rq and release next. merge_requests_fn
diff --git a/block/bsg.c b/block/bsg.c
index e7d475254248..5f184bb3ff9e 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -186,7 +186,7 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
186 return -EFAULT; 186 return -EFAULT;
187 187
188 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) { 188 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
189 if (blk_verify_command(&q->cmd_filter, rq->cmd, has_write_perm)) 189 if (blk_verify_command(rq->cmd, has_write_perm))
190 return -EPERM; 190 return -EPERM;
191 } else if (!capable(CAP_SYS_RAWIO)) 191 } else if (!capable(CAP_SYS_RAWIO))
192 return -EPERM; 192 return -EPERM;
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 833ec18eaa63..fd7080ed7935 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -71,6 +71,51 @@ struct cfq_rb_root {
71#define CFQ_RB_ROOT (struct cfq_rb_root) { RB_ROOT, NULL, } 71#define CFQ_RB_ROOT (struct cfq_rb_root) { RB_ROOT, NULL, }
72 72
73/* 73/*
74 * Per process-grouping structure
75 */
76struct cfq_queue {
77 /* reference count */
78 atomic_t ref;
79 /* various state flags, see below */
80 unsigned int flags;
81 /* parent cfq_data */
82 struct cfq_data *cfqd;
83 /* service_tree member */
84 struct rb_node rb_node;
85 /* service_tree key */
86 unsigned long rb_key;
87 /* prio tree member */
88 struct rb_node p_node;
89 /* prio tree root we belong to, if any */
90 struct rb_root *p_root;
91 /* sorted list of pending requests */
92 struct rb_root sort_list;
93 /* if fifo isn't expired, next request to serve */
94 struct request *next_rq;
95 /* requests queued in sort_list */
96 int queued[2];
97 /* currently allocated requests */
98 int allocated[2];
99 /* fifo list of requests in sort_list */
100 struct list_head fifo;
101
102 unsigned long slice_end;
103 long slice_resid;
104 unsigned int slice_dispatch;
105
106 /* pending metadata requests */
107 int meta_pending;
108 /* number of requests that are on the dispatch list or inside driver */
109 int dispatched;
110
111 /* io prio of this group */
112 unsigned short ioprio, org_ioprio;
113 unsigned short ioprio_class, org_ioprio_class;
114
115 pid_t pid;
116};
117
118/*
74 * Per block device queue structure 119 * Per block device queue structure
75 */ 120 */
76struct cfq_data { 121struct cfq_data {
@@ -135,51 +180,11 @@ struct cfq_data {
135 unsigned int cfq_slice_idle; 180 unsigned int cfq_slice_idle;
136 181
137 struct list_head cic_list; 182 struct list_head cic_list;
138};
139 183
140/* 184 /*
141 * Per process-grouping structure 185 * Fallback dummy cfqq for extreme OOM conditions
142 */ 186 */
143struct cfq_queue { 187 struct cfq_queue oom_cfqq;
144 /* reference count */
145 atomic_t ref;
146 /* various state flags, see below */
147 unsigned int flags;
148 /* parent cfq_data */
149 struct cfq_data *cfqd;
150 /* service_tree member */
151 struct rb_node rb_node;
152 /* service_tree key */
153 unsigned long rb_key;
154 /* prio tree member */
155 struct rb_node p_node;
156 /* prio tree root we belong to, if any */
157 struct rb_root *p_root;
158 /* sorted list of pending requests */
159 struct rb_root sort_list;
160 /* if fifo isn't expired, next request to serve */
161 struct request *next_rq;
162 /* requests queued in sort_list */
163 int queued[2];
164 /* currently allocated requests */
165 int allocated[2];
166 /* fifo list of requests in sort_list */
167 struct list_head fifo;
168
169 unsigned long slice_end;
170 long slice_resid;
171 unsigned int slice_dispatch;
172
173 /* pending metadata requests */
174 int meta_pending;
175 /* number of requests that are on the dispatch list or inside driver */
176 int dispatched;
177
178 /* io prio of this group */
179 unsigned short ioprio, org_ioprio;
180 unsigned short ioprio_class, org_ioprio_class;
181
182 pid_t pid;
183}; 188};
184 189
185enum cfqq_state_flags { 190enum cfqq_state_flags {
@@ -1641,6 +1646,26 @@ static void cfq_ioc_set_ioprio(struct io_context *ioc)
1641 ioc->ioprio_changed = 0; 1646 ioc->ioprio_changed = 0;
1642} 1647}
1643 1648
1649static void cfq_init_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1650 pid_t pid, int is_sync)
1651{
1652 RB_CLEAR_NODE(&cfqq->rb_node);
1653 RB_CLEAR_NODE(&cfqq->p_node);
1654 INIT_LIST_HEAD(&cfqq->fifo);
1655
1656 atomic_set(&cfqq->ref, 0);
1657 cfqq->cfqd = cfqd;
1658
1659 cfq_mark_cfqq_prio_changed(cfqq);
1660
1661 if (is_sync) {
1662 if (!cfq_class_idle(cfqq))
1663 cfq_mark_cfqq_idle_window(cfqq);
1664 cfq_mark_cfqq_sync(cfqq);
1665 }
1666 cfqq->pid = pid;
1667}
1668
1644static struct cfq_queue * 1669static struct cfq_queue *
1645cfq_find_alloc_queue(struct cfq_data *cfqd, int is_sync, 1670cfq_find_alloc_queue(struct cfq_data *cfqd, int is_sync,
1646 struct io_context *ioc, gfp_t gfp_mask) 1671 struct io_context *ioc, gfp_t gfp_mask)
@@ -1653,56 +1678,40 @@ retry:
1653 /* cic always exists here */ 1678 /* cic always exists here */
1654 cfqq = cic_to_cfqq(cic, is_sync); 1679 cfqq = cic_to_cfqq(cic, is_sync);
1655 1680
1656 if (!cfqq) { 1681 /*
1682 * Always try a new alloc if we fell back to the OOM cfqq
1683 * originally, since it should just be a temporary situation.
1684 */
1685 if (!cfqq || cfqq == &cfqd->oom_cfqq) {
1686 cfqq = NULL;
1657 if (new_cfqq) { 1687 if (new_cfqq) {
1658 cfqq = new_cfqq; 1688 cfqq = new_cfqq;
1659 new_cfqq = NULL; 1689 new_cfqq = NULL;
1660 } else if (gfp_mask & __GFP_WAIT) { 1690 } else if (gfp_mask & __GFP_WAIT) {
1661 /*
1662 * Inform the allocator of the fact that we will
1663 * just repeat this allocation if it fails, to allow
1664 * the allocator to do whatever it needs to attempt to
1665 * free memory.
1666 */
1667 spin_unlock_irq(cfqd->queue->queue_lock); 1691 spin_unlock_irq(cfqd->queue->queue_lock);
1668 new_cfqq = kmem_cache_alloc_node(cfq_pool, 1692 new_cfqq = kmem_cache_alloc_node(cfq_pool,
1669 gfp_mask | __GFP_NOFAIL | __GFP_ZERO, 1693 gfp_mask | __GFP_ZERO,
1670 cfqd->queue->node); 1694 cfqd->queue->node);
1671 spin_lock_irq(cfqd->queue->queue_lock); 1695 spin_lock_irq(cfqd->queue->queue_lock);
1672 goto retry; 1696 if (new_cfqq)
1697 goto retry;
1673 } else { 1698 } else {
1674 cfqq = kmem_cache_alloc_node(cfq_pool, 1699 cfqq = kmem_cache_alloc_node(cfq_pool,
1675 gfp_mask | __GFP_ZERO, 1700 gfp_mask | __GFP_ZERO,
1676 cfqd->queue->node); 1701 cfqd->queue->node);
1677 if (!cfqq)
1678 goto out;
1679 } 1702 }
1680 1703
1681 RB_CLEAR_NODE(&cfqq->rb_node); 1704 if (cfqq) {
1682 RB_CLEAR_NODE(&cfqq->p_node); 1705 cfq_init_cfqq(cfqd, cfqq, current->pid, is_sync);
1683 INIT_LIST_HEAD(&cfqq->fifo); 1706 cfq_init_prio_data(cfqq, ioc);
1684 1707 cfq_log_cfqq(cfqd, cfqq, "alloced");
1685 atomic_set(&cfqq->ref, 0); 1708 } else
1686 cfqq->cfqd = cfqd; 1709 cfqq = &cfqd->oom_cfqq;
1687
1688 cfq_mark_cfqq_prio_changed(cfqq);
1689
1690 cfq_init_prio_data(cfqq, ioc);
1691
1692 if (is_sync) {
1693 if (!cfq_class_idle(cfqq))
1694 cfq_mark_cfqq_idle_window(cfqq);
1695 cfq_mark_cfqq_sync(cfqq);
1696 }
1697 cfqq->pid = current->pid;
1698 cfq_log_cfqq(cfqd, cfqq, "alloced");
1699 } 1710 }
1700 1711
1701 if (new_cfqq) 1712 if (new_cfqq)
1702 kmem_cache_free(cfq_pool, new_cfqq); 1713 kmem_cache_free(cfq_pool, new_cfqq);
1703 1714
1704out:
1705 WARN_ON((gfp_mask & __GFP_WAIT) && !cfqq);
1706 return cfqq; 1715 return cfqq;
1707} 1716}
1708 1717
@@ -1735,11 +1744,8 @@ cfq_get_queue(struct cfq_data *cfqd, int is_sync, struct io_context *ioc,
1735 cfqq = *async_cfqq; 1744 cfqq = *async_cfqq;
1736 } 1745 }
1737 1746
1738 if (!cfqq) { 1747 if (!cfqq)
1739 cfqq = cfq_find_alloc_queue(cfqd, is_sync, ioc, gfp_mask); 1748 cfqq = cfq_find_alloc_queue(cfqd, is_sync, ioc, gfp_mask);
1740 if (!cfqq)
1741 return NULL;
1742 }
1743 1749
1744 /* 1750 /*
1745 * pin the queue now that it's allocated, scheduler exit will prune it 1751 * pin the queue now that it's allocated, scheduler exit will prune it
@@ -2305,12 +2311,8 @@ cfq_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)
2305 goto queue_fail; 2311 goto queue_fail;
2306 2312
2307 cfqq = cic_to_cfqq(cic, is_sync); 2313 cfqq = cic_to_cfqq(cic, is_sync);
2308 if (!cfqq) { 2314 if (!cfqq || cfqq == &cfqd->oom_cfqq) {
2309 cfqq = cfq_get_queue(cfqd, is_sync, cic->ioc, gfp_mask); 2315 cfqq = cfq_get_queue(cfqd, is_sync, cic->ioc, gfp_mask);
2310
2311 if (!cfqq)
2312 goto queue_fail;
2313
2314 cic_set_cfqq(cic, cfqq, is_sync); 2316 cic_set_cfqq(cic, cfqq, is_sync);
2315 } 2317 }
2316 2318
@@ -2465,6 +2467,14 @@ static void *cfq_init_queue(struct request_queue *q)
2465 for (i = 0; i < CFQ_PRIO_LISTS; i++) 2467 for (i = 0; i < CFQ_PRIO_LISTS; i++)
2466 cfqd->prio_trees[i] = RB_ROOT; 2468 cfqd->prio_trees[i] = RB_ROOT;
2467 2469
2470 /*
2471 * Our fallback cfqq if cfq_find_alloc_queue() runs into OOM issues.
2472 * Grab a permanent reference to it, so that the normal code flow
2473 * will not attempt to free it.
2474 */
2475 cfq_init_cfqq(cfqd, &cfqd->oom_cfqq, 1, 0);
2476 atomic_inc(&cfqd->oom_cfqq.ref);
2477
2468 INIT_LIST_HEAD(&cfqd->cic_list); 2478 INIT_LIST_HEAD(&cfqd->cic_list);
2469 2479
2470 cfqd->queue = q; 2480 cfqd->queue = q;
diff --git a/block/cmd-filter.c b/block/cmd-filter.c
deleted file mode 100644
index 572bbc2f900d..000000000000
--- a/block/cmd-filter.c
+++ /dev/null
@@ -1,233 +0,0 @@
1/*
2 * Copyright 2004 Peter M. Jones <pjones@redhat.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public Licens
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
17 *
18 */
19
20#include <linux/list.h>
21#include <linux/genhd.h>
22#include <linux/spinlock.h>
23#include <linux/capability.h>
24#include <linux/bitops.h>
25#include <linux/blkdev.h>
26
27#include <scsi/scsi.h>
28#include <linux/cdrom.h>
29
30int blk_verify_command(struct blk_cmd_filter *filter,
31 unsigned char *cmd, fmode_t has_write_perm)
32{
33 /* root can do any command. */
34 if (capable(CAP_SYS_RAWIO))
35 return 0;
36
37 /* if there's no filter set, assume we're filtering everything out */
38 if (!filter)
39 return -EPERM;
40
41 /* Anybody who can open the device can do a read-safe command */
42 if (test_bit(cmd[0], filter->read_ok))
43 return 0;
44
45 /* Write-safe commands require a writable open */
46 if (test_bit(cmd[0], filter->write_ok) && has_write_perm)
47 return 0;
48
49 return -EPERM;
50}
51EXPORT_SYMBOL(blk_verify_command);
52
53#if 0
54/* and now, the sysfs stuff */
55static ssize_t rcf_cmds_show(struct blk_cmd_filter *filter, char *page,
56 int rw)
57{
58 char *npage = page;
59 unsigned long *okbits;
60 int i;
61
62 if (rw == READ)
63 okbits = filter->read_ok;
64 else
65 okbits = filter->write_ok;
66
67 for (i = 0; i < BLK_SCSI_MAX_CMDS; i++) {
68 if (test_bit(i, okbits)) {
69 npage += sprintf(npage, "0x%02x", i);
70 if (i < BLK_SCSI_MAX_CMDS - 1)
71 sprintf(npage++, " ");
72 }
73 }
74
75 if (npage != page)
76 npage += sprintf(npage, "\n");
77
78 return npage - page;
79}
80
81static ssize_t rcf_readcmds_show(struct blk_cmd_filter *filter, char *page)
82{
83 return rcf_cmds_show(filter, page, READ);
84}
85
86static ssize_t rcf_writecmds_show(struct blk_cmd_filter *filter,
87 char *page)
88{
89 return rcf_cmds_show(filter, page, WRITE);
90}
91
92static ssize_t rcf_cmds_store(struct blk_cmd_filter *filter,
93 const char *page, size_t count, int rw)
94{
95 unsigned long okbits[BLK_SCSI_CMD_PER_LONG], *target_okbits;
96 int cmd, set;
97 char *p, *status;
98
99 if (rw == READ) {
100 memcpy(&okbits, filter->read_ok, sizeof(okbits));
101 target_okbits = filter->read_ok;
102 } else {
103 memcpy(&okbits, filter->write_ok, sizeof(okbits));
104 target_okbits = filter->write_ok;
105 }
106
107 while ((p = strsep((char **)&page, " ")) != NULL) {
108 set = 1;
109
110 if (p[0] == '+') {
111 p++;
112 } else if (p[0] == '-') {
113 set = 0;
114 p++;
115 }
116
117 cmd = simple_strtol(p, &status, 16);
118
119 /* either of these cases means invalid input, so do nothing. */
120 if ((status == p) || cmd >= BLK_SCSI_MAX_CMDS)
121 return -EINVAL;
122
123 if (set)
124 __set_bit(cmd, okbits);
125 else
126 __clear_bit(cmd, okbits);
127 }
128
129 memcpy(target_okbits, okbits, sizeof(okbits));
130 return count;
131}
132
133static ssize_t rcf_readcmds_store(struct blk_cmd_filter *filter,
134 const char *page, size_t count)
135{
136 return rcf_cmds_store(filter, page, count, READ);
137}
138
139static ssize_t rcf_writecmds_store(struct blk_cmd_filter *filter,
140 const char *page, size_t count)
141{
142 return rcf_cmds_store(filter, page, count, WRITE);
143}
144
145struct rcf_sysfs_entry {
146 struct attribute attr;
147 ssize_t (*show)(struct blk_cmd_filter *, char *);
148 ssize_t (*store)(struct blk_cmd_filter *, const char *, size_t);
149};
150
151static struct rcf_sysfs_entry rcf_readcmds_entry = {
152 .attr = { .name = "read_table", .mode = S_IRUGO | S_IWUSR },
153 .show = rcf_readcmds_show,
154 .store = rcf_readcmds_store,
155};
156
157static struct rcf_sysfs_entry rcf_writecmds_entry = {
158 .attr = {.name = "write_table", .mode = S_IRUGO | S_IWUSR },
159 .show = rcf_writecmds_show,
160 .store = rcf_writecmds_store,
161};
162
163static struct attribute *default_attrs[] = {
164 &rcf_readcmds_entry.attr,
165 &rcf_writecmds_entry.attr,
166 NULL,
167};
168
169#define to_rcf(atr) container_of((atr), struct rcf_sysfs_entry, attr)
170
171static ssize_t
172rcf_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
173{
174 struct rcf_sysfs_entry *entry = to_rcf(attr);
175 struct blk_cmd_filter *filter;
176
177 filter = container_of(kobj, struct blk_cmd_filter, kobj);
178 if (entry->show)
179 return entry->show(filter, page);
180
181 return 0;
182}
183
184static ssize_t
185rcf_attr_store(struct kobject *kobj, struct attribute *attr,
186 const char *page, size_t length)
187{
188 struct rcf_sysfs_entry *entry = to_rcf(attr);
189 struct blk_cmd_filter *filter;
190
191 if (!capable(CAP_SYS_RAWIO))
192 return -EPERM;
193
194 if (!entry->store)
195 return -EINVAL;
196
197 filter = container_of(kobj, struct blk_cmd_filter, kobj);
198 return entry->store(filter, page, length);
199}
200
201static struct sysfs_ops rcf_sysfs_ops = {
202 .show = rcf_attr_show,
203 .store = rcf_attr_store,
204};
205
206static struct kobj_type rcf_ktype = {
207 .sysfs_ops = &rcf_sysfs_ops,
208 .default_attrs = default_attrs,
209};
210
211int blk_register_filter(struct gendisk *disk)
212{
213 int ret;
214 struct blk_cmd_filter *filter = &disk->queue->cmd_filter;
215
216 ret = kobject_init_and_add(&filter->kobj, &rcf_ktype,
217 &disk_to_dev(disk)->kobj,
218 "%s", "cmd_filter");
219 if (ret < 0)
220 return ret;
221
222 return 0;
223}
224EXPORT_SYMBOL(blk_register_filter);
225
226void blk_unregister_filter(struct gendisk *disk)
227{
228 struct blk_cmd_filter *filter = &disk->queue->cmd_filter;
229
230 kobject_put(&filter->kobj);
231}
232EXPORT_SYMBOL(blk_unregister_filter);
233#endif
diff --git a/block/elevator.c b/block/elevator.c
index ca861927ba41..6f2375339a99 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -100,6 +100,14 @@ int elv_rq_merge_ok(struct request *rq, struct bio *bio)
100 if (bio_integrity(bio) != blk_integrity_rq(rq)) 100 if (bio_integrity(bio) != blk_integrity_rq(rq))
101 return 0; 101 return 0;
102 102
103 /*
104 * Don't merge if failfast settings don't match
105 */
106 if (bio_failfast_dev(bio) != blk_failfast_dev(rq) ||
107 bio_failfast_transport(bio) != blk_failfast_transport(rq) ||
108 bio_failfast_driver(bio) != blk_failfast_driver(rq))
109 return 0;
110
103 if (!elv_iosched_allow_merge(rq, bio)) 111 if (!elv_iosched_allow_merge(rq, bio))
104 return 0; 112 return 0;
105 113
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 5f8e798ede4e..e5b10017a50b 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -32,6 +32,11 @@
32#include <scsi/scsi_ioctl.h> 32#include <scsi/scsi_ioctl.h>
33#include <scsi/scsi_cmnd.h> 33#include <scsi/scsi_cmnd.h>
34 34
35struct blk_cmd_filter {
36 unsigned long read_ok[BLK_SCSI_CMD_PER_LONG];
37 unsigned long write_ok[BLK_SCSI_CMD_PER_LONG];
38} blk_default_cmd_filter;
39
35/* Command group 3 is reserved and should never be used. */ 40/* Command group 3 is reserved and should never be used. */
36const unsigned char scsi_command_size_tbl[8] = 41const unsigned char scsi_command_size_tbl[8] =
37{ 42{
@@ -105,7 +110,7 @@ static int sg_emulated_host(struct request_queue *q, int __user *p)
105 return put_user(1, p); 110 return put_user(1, p);
106} 111}
107 112
108void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter) 113static void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
109{ 114{
110 /* Basic read-only commands */ 115 /* Basic read-only commands */
111 __set_bit(TEST_UNIT_READY, filter->read_ok); 116 __set_bit(TEST_UNIT_READY, filter->read_ok);
@@ -187,14 +192,37 @@ void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
187 __set_bit(GPCMD_SET_STREAMING, filter->write_ok); 192 __set_bit(GPCMD_SET_STREAMING, filter->write_ok);
188 __set_bit(GPCMD_SET_READ_AHEAD, filter->write_ok); 193 __set_bit(GPCMD_SET_READ_AHEAD, filter->write_ok);
189} 194}
190EXPORT_SYMBOL_GPL(blk_set_cmd_filter_defaults); 195
196int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm)
197{
198 struct blk_cmd_filter *filter = &blk_default_cmd_filter;
199
200 /* root can do any command. */
201 if (capable(CAP_SYS_RAWIO))
202 return 0;
203
204 /* if there's no filter set, assume we're filtering everything out */
205 if (!filter)
206 return -EPERM;
207
208 /* Anybody who can open the device can do a read-safe command */
209 if (test_bit(cmd[0], filter->read_ok))
210 return 0;
211
212 /* Write-safe commands require a writable open */
213 if (test_bit(cmd[0], filter->write_ok) && has_write_perm)
214 return 0;
215
216 return -EPERM;
217}
218EXPORT_SYMBOL(blk_verify_command);
191 219
192static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq, 220static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
193 struct sg_io_hdr *hdr, fmode_t mode) 221 struct sg_io_hdr *hdr, fmode_t mode)
194{ 222{
195 if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len)) 223 if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
196 return -EFAULT; 224 return -EFAULT;
197 if (blk_verify_command(&q->cmd_filter, rq->cmd, mode & FMODE_WRITE)) 225 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
198 return -EPERM; 226 return -EPERM;
199 227
200 /* 228 /*
@@ -427,7 +455,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
427 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len)) 455 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
428 goto error; 456 goto error;
429 457
430 err = blk_verify_command(&q->cmd_filter, rq->cmd, mode & FMODE_WRITE); 458 err = blk_verify_command(rq->cmd, mode & FMODE_WRITE);
431 if (err) 459 if (err)
432 goto error; 460 goto error;
433 461
@@ -645,5 +673,11 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod
645 blk_put_queue(q); 673 blk_put_queue(q);
646 return err; 674 return err;
647} 675}
648
649EXPORT_SYMBOL(scsi_cmd_ioctl); 676EXPORT_SYMBOL(scsi_cmd_ioctl);
677
678int __init blk_scsi_ioctl_init(void)
679{
680 blk_set_cmd_filter_defaults(&blk_default_cmd_filter);
681 return 0;
682}
683fs_initcall(blk_scsi_ioctl_init);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 8a5bf3b356fa..55b5b90c2a44 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -395,7 +395,7 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
395 fn = adr & 0xffff; 395 fn = adr & 0xffff;
396 396
397 pdev = pci_get_slot(pbus, PCI_DEVFN(dev, fn)); 397 pdev = pci_get_slot(pbus, PCI_DEVFN(dev, fn));
398 if (hnd == handle) 398 if (!pdev || hnd == handle)
399 break; 399 break;
400 400
401 pbus = pdev->subordinate; 401 pbus = pdev->subordinate;
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 3d763fdf99b7..246650673010 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -207,6 +207,16 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
207 void __iomem *tmp; 207 void __iomem *tmp;
208 int i, ret; 208 int i, ret;
209 209
210 device_initialize(&dev->dev);
211
212 /*
213 * Copy from device_add
214 */
215 if (dev->dev.init_name) {
216 dev_set_name(&dev->dev, "%s", dev->dev.init_name);
217 dev->dev.init_name = NULL;
218 }
219
210 dev->dev.release = amba_device_release; 220 dev->dev.release = amba_device_release;
211 dev->dev.bus = &amba_bustype; 221 dev->dev.bus = &amba_bustype;
212 dev->dev.dma_mask = &dev->dma_mask; 222 dev->dev.dma_mask = &dev->dma_mask;
@@ -240,7 +250,7 @@ int amba_device_register(struct amba_device *dev, struct resource *parent)
240 goto err_release; 250 goto err_release;
241 } 251 }
242 252
243 ret = device_register(&dev->dev); 253 ret = device_add(&dev->dev);
244 if (ret) 254 if (ret)
245 goto err_release; 255 goto err_release;
246 256
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index e8beb8e5b626..05dd307e8f02 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -428,6 +428,9 @@ int devres_release_all(struct device *dev)
428{ 428{
429 unsigned long flags; 429 unsigned long flags;
430 430
431 /* Looks like an uninitialized device structure */
432 if (WARN_ON(dev->devres_head.next == NULL))
433 return -ENODEV;
431 spin_lock_irqsave(&dev->devres_lock, flags); 434 spin_lock_irqsave(&dev->devres_lock, flags);
432 return release_nodes(dev, dev->devres_head.next, &dev->devres_head, 435 return release_nodes(dev, dev->devres_head.next, &dev->devres_head,
433 flags); 436 flags);
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index ddeb819c8f87..f285f441fab9 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -217,8 +217,10 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr,
217 ret_count = -ENODEV; 217 ret_count = -ENODEV;
218 goto out; 218 goto out;
219 } 219 }
220 if (offset > fw->size) 220 if (offset > fw->size) {
221 return 0; 221 ret_count = 0;
222 goto out;
223 }
222 if (count > fw->size - offset) 224 if (count > fw->size - offset)
223 count = fw->size - offset; 225 count = fw->size - offset;
224 226
@@ -357,7 +359,7 @@ static void fw_dev_release(struct device *dev)
357 kfree(fw_priv->pages); 359 kfree(fw_priv->pages);
358 kfree(fw_priv->fw_id); 360 kfree(fw_priv->fw_id);
359 kfree(fw_priv); 361 kfree(fw_priv);
360 put_device(dev); 362 kfree(dev);
361 363
362 module_put(THIS_MODULE); 364 module_put(THIS_MODULE);
363} 365}
@@ -408,13 +410,11 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
408 if (retval) { 410 if (retval) {
409 dev_err(device, "%s: device_register failed\n", __func__); 411 dev_err(device, "%s: device_register failed\n", __func__);
410 put_device(f_dev); 412 put_device(f_dev);
411 goto error_kfree_fw_id; 413 return retval;
412 } 414 }
413 *dev_p = f_dev; 415 *dev_p = f_dev;
414 return 0; 416 return 0;
415 417
416error_kfree_fw_id:
417 kfree(fw_priv->fw_id);
418error_kfree: 418error_kfree:
419 kfree(f_dev); 419 kfree(f_dev);
420 kfree(fw_priv); 420 kfree(fw_priv);
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index fae725458981..58a3e572f2c9 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -762,6 +762,7 @@ static int dpm_prepare(pm_message_t state)
762 dev->power.status = DPM_ON; 762 dev->power.status = DPM_ON;
763 if (error == -EAGAIN) { 763 if (error == -EAGAIN) {
764 put_device(dev); 764 put_device(dev);
765 error = 0;
765 continue; 766 continue;
766 } 767 }
767 printk(KERN_ERR "PM: Failed to prepare device %s " 768 printk(KERN_ERR "PM: Failed to prepare device %s "
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 668dc234b8e2..1e6b7c14f697 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -36,6 +36,7 @@
36#include <linux/ioport.h> 36#include <linux/ioport.h>
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/smp_lock.h>
39#include <linux/proc_fs.h> 40#include <linux/proc_fs.h>
40#include <linux/reboot.h> 41#include <linux/reboot.h>
41#include <linux/spinlock.h> 42#include <linux/spinlock.h>
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index bb72ada9f074..1d886e079c58 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -298,6 +298,22 @@ config BLK_DEV_NBD
298 298
299 If unsure, say N. 299 If unsure, say N.
300 300
301config BLK_DEV_OSD
302 tristate "OSD object-as-blkdev support"
303 depends on SCSI_OSD_ULD
304 ---help---
305 Saying Y or M here will allow the exporting of a single SCSI
306 OSD (object-based storage) object as a Linux block device.
307
308 For example, if you create a 2G object on an OSD device,
309 you can then use this module to present that 2G object as
310 a Linux block device.
311
312 To compile this driver as a module, choose M here: the
313 module will be called osdblk.
314
315 If unsure, say N.
316
301config BLK_DEV_SX8 317config BLK_DEV_SX8
302 tristate "Promise SATA SX8 support" 318 tristate "Promise SATA SX8 support"
303 depends on PCI 319 depends on PCI
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 7755a5e2a85e..cdaa3f8fddf0 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_XILINX_SYSACE) += xsysace.o
23obj-$(CONFIG_CDROM_PKTCDVD) += pktcdvd.o 23obj-$(CONFIG_CDROM_PKTCDVD) += pktcdvd.o
24obj-$(CONFIG_MG_DISK) += mg_disk.o 24obj-$(CONFIG_MG_DISK) += mg_disk.o
25obj-$(CONFIG_SUNVDC) += sunvdc.o 25obj-$(CONFIG_SUNVDC) += sunvdc.o
26obj-$(CONFIG_BLK_DEV_OSD) += osdblk.o
26 27
27obj-$(CONFIG_BLK_DEV_UMEM) += umem.o 28obj-$(CONFIG_BLK_DEV_UMEM) += umem.o
28obj-$(CONFIG_BLK_DEV_NBD) += nbd.o 29obj-$(CONFIG_BLK_DEV_NBD) += nbd.o
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 9c6e5b0fe894..2f07b7c99a95 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1645,7 +1645,7 @@ static int __init fd_probe_drives(void)
1645{ 1645{
1646 int drive,drives,nomem; 1646 int drive,drives,nomem;
1647 1647
1648 printk(KERN_INFO "FD: probing units\n" KERN_INFO "found "); 1648 printk(KERN_INFO "FD: probing units\nfound ");
1649 drives=0; 1649 drives=0;
1650 nomem=0; 1650 nomem=0;
1651 for(drive=0;drive<FD_MAX_UNITS;drive++) { 1651 for(drive=0;drive<FD_MAX_UNITS;drive++) {
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index c7a527c08a09..a52cc7fe45ea 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -26,6 +26,7 @@
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/smp_lock.h>
29#include <linux/delay.h> 30#include <linux/delay.h>
30#include <linux/major.h> 31#include <linux/major.h>
31#include <linux/fs.h> 32#include <linux/fs.h>
@@ -226,8 +227,18 @@ static inline void addQ(struct hlist_head *list, CommandList_struct *c)
226 227
227static inline void removeQ(CommandList_struct *c) 228static inline void removeQ(CommandList_struct *c)
228{ 229{
229 if (WARN_ON(hlist_unhashed(&c->list))) 230 /*
231 * After kexec/dump some commands might still
232 * be in flight, which the firmware will try
233 * to complete. Resetting the firmware doesn't work
234 * with old fw revisions, so we have to mark
235 * them off as 'stale' to prevent the driver from
236 * falling over.
237 */
238 if (WARN_ON(hlist_unhashed(&c->list))) {
239 c->cmd_type = CMD_MSG_STALE;
230 return; 240 return;
241 }
231 242
232 hlist_del_init(&c->list); 243 hlist_del_init(&c->list);
233} 244}
@@ -4246,7 +4257,8 @@ static void fail_all_cmds(unsigned long ctlr)
4246 while (!hlist_empty(&h->cmpQ)) { 4257 while (!hlist_empty(&h->cmpQ)) {
4247 c = hlist_entry(h->cmpQ.first, CommandList_struct, list); 4258 c = hlist_entry(h->cmpQ.first, CommandList_struct, list);
4248 removeQ(c); 4259 removeQ(c);
4249 c->err_info->CommandStatus = CMD_HARDWARE_ERR; 4260 if (c->cmd_type != CMD_MSG_STALE)
4261 c->err_info->CommandStatus = CMD_HARDWARE_ERR;
4250 if (c->cmd_type == CMD_RWREQ) { 4262 if (c->cmd_type == CMD_RWREQ) {
4251 complete_command(h, c, 0); 4263 complete_command(h, c, 0);
4252 } else if (c->cmd_type == CMD_IOCTL_PEND) 4264 } else if (c->cmd_type == CMD_IOCTL_PEND)
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h
index cd665b00c7c5..dbaed1ea0da3 100644
--- a/drivers/block/cciss_cmd.h
+++ b/drivers/block/cciss_cmd.h
@@ -274,6 +274,7 @@ typedef struct _ErrorInfo_struct {
274#define CMD_SCSI 0x03 274#define CMD_SCSI 0x03
275#define CMD_MSG_DONE 0x04 275#define CMD_MSG_DONE 0x04
276#define CMD_MSG_TIMEOUT 0x05 276#define CMD_MSG_TIMEOUT 0x05
277#define CMD_MSG_STALE 0xff
277 278
278/* This structure needs to be divisible by 8 for new 279/* This structure needs to be divisible by 8 for new
279 * indexing method. 280 * indexing method.
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 862b40c90181..91b753013780 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3327,7 +3327,10 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
3327 if (!capable(CAP_SYS_ADMIN)) 3327 if (!capable(CAP_SYS_ADMIN))
3328 return -EPERM; 3328 return -EPERM;
3329 mutex_lock(&open_lock); 3329 mutex_lock(&open_lock);
3330 LOCK_FDC(drive, 1); 3330 if (lock_fdc(drive, 1)) {
3331 mutex_unlock(&open_lock);
3332 return -EINTR;
3333 }
3331 floppy_type[type] = *g; 3334 floppy_type[type] = *g;
3332 floppy_type[type].name = "user format"; 3335 floppy_type[type].name = "user format";
3333 for (cnt = type << 2; cnt < (type << 2) + 4; cnt++) 3336 for (cnt = type << 2; cnt < (type << 2) + 4; cnt++)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 801f4ab83302..5757188cd1fb 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -61,7 +61,6 @@
61#include <linux/blkdev.h> 61#include <linux/blkdev.h>
62#include <linux/blkpg.h> 62#include <linux/blkpg.h>
63#include <linux/init.h> 63#include <linux/init.h>
64#include <linux/smp_lock.h>
65#include <linux/swap.h> 64#include <linux/swap.h>
66#include <linux/slab.h> 65#include <linux/slab.h>
67#include <linux/loop.h> 66#include <linux/loop.h>
diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c
new file mode 100644
index 000000000000..13c1aee6aa3f
--- /dev/null
+++ b/drivers/block/osdblk.c
@@ -0,0 +1,701 @@
1
2/*
3 osdblk.c -- Export a single SCSI OSD object as a Linux block device
4
5
6 Copyright 2009 Red Hat, Inc.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21
22 Instructions for use
23 --------------------
24
25 1) Map a Linux block device to an existing OSD object.
26
27 In this example, we will use partition id 1234, object id 5678,
28 OSD device /dev/osd1.
29
30 $ echo "1234 5678 /dev/osd1" > /sys/class/osdblk/add
31
32
33 2) List all active blkdev<->object mappings.
34
35 In this example, we have performed step #1 twice, creating two blkdevs,
36 mapped to two separate OSD objects.
37
38 $ cat /sys/class/osdblk/list
39 0 174 1234 5678 /dev/osd1
40 1 179 1994 897123 /dev/osd0
41
42 The columns, in order, are:
43 - blkdev unique id
44 - blkdev assigned major
45 - OSD object partition id
46 - OSD object id
47 - OSD device
48
49
50 3) Remove an active blkdev<->object mapping.
51
52 In this example, we remove the mapping with blkdev unique id 1.
53
54 $ echo 1 > /sys/class/osdblk/remove
55
56
57 NOTE: The actual creation and deletion of OSD objects is outside the scope
58 of this driver.
59
60 */
61
62#include <linux/kernel.h>
63#include <linux/device.h>
64#include <linux/module.h>
65#include <linux/fs.h>
66#include <scsi/osd_initiator.h>
67#include <scsi/osd_attributes.h>
68#include <scsi/osd_sec.h>
69#include <scsi/scsi_device.h>
70
71#define DRV_NAME "osdblk"
72#define PFX DRV_NAME ": "
73
74/* #define _OSDBLK_DEBUG */
75#ifdef _OSDBLK_DEBUG
76#define OSDBLK_DEBUG(fmt, a...) \
77 printk(KERN_NOTICE "osdblk @%s:%d: " fmt, __func__, __LINE__, ##a)
78#else
79#define OSDBLK_DEBUG(fmt, a...) \
80 do { if (0) printk(fmt, ##a); } while (0)
81#endif
82
83MODULE_AUTHOR("Jeff Garzik <jeff@garzik.org>");
84MODULE_DESCRIPTION("block device inside an OSD object osdblk.ko");
85MODULE_LICENSE("GPL");
86
87struct osdblk_device;
88
89enum {
90 OSDBLK_MINORS_PER_MAJOR = 256, /* max minors per blkdev */
91 OSDBLK_MAX_REQ = 32, /* max parallel requests */
92 OSDBLK_OP_TIMEOUT = 4 * 60, /* sync OSD req timeout */
93};
94
95struct osdblk_request {
96 struct request *rq; /* blk layer request */
97 struct bio *bio; /* cloned bio */
98 struct osdblk_device *osdev; /* associated blkdev */
99};
100
101struct osdblk_device {
102 int id; /* blkdev unique id */
103
104 int major; /* blkdev assigned major */
105 struct gendisk *disk; /* blkdev's gendisk and rq */
106 struct request_queue *q;
107
108 struct osd_dev *osd; /* associated OSD */
109
110 char name[32]; /* blkdev name, e.g. osdblk34 */
111
112 spinlock_t lock; /* queue lock */
113
114 struct osd_obj_id obj; /* OSD partition, obj id */
115 uint8_t obj_cred[OSD_CAP_LEN]; /* OSD cred */
116
117 struct osdblk_request req[OSDBLK_MAX_REQ]; /* request table */
118
119 struct list_head node;
120
121 char osd_path[0]; /* OSD device path */
122};
123
124static struct class *class_osdblk; /* /sys/class/osdblk */
125static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */
126static LIST_HEAD(osdblkdev_list);
127
128static struct block_device_operations osdblk_bd_ops = {
129 .owner = THIS_MODULE,
130};
131
132static const struct osd_attr g_attr_logical_length = ATTR_DEF(
133 OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8);
134
135static void osdblk_make_credential(u8 cred_a[OSD_CAP_LEN],
136 const struct osd_obj_id *obj)
137{
138 osd_sec_init_nosec_doall_caps(cred_a, obj, false, true);
139}
140
141/* copied from exofs; move to libosd? */
142/*
143 * Perform a synchronous OSD operation. copied from exofs; move to libosd?
144 */
145static int osd_sync_op(struct osd_request *or, int timeout, uint8_t *credential)
146{
147 int ret;
148
149 or->timeout = timeout;
150 ret = osd_finalize_request(or, 0, credential, NULL);
151 if (ret)
152 return ret;
153
154 ret = osd_execute_request(or);
155
156 /* osd_req_decode_sense(or, ret); */
157 return ret;
158}
159
160/*
161 * Perform an asynchronous OSD operation. copied from exofs; move to libosd?
162 */
163static int osd_async_op(struct osd_request *or, osd_req_done_fn *async_done,
164 void *caller_context, u8 *cred)
165{
166 int ret;
167
168 ret = osd_finalize_request(or, 0, cred, NULL);
169 if (ret)
170 return ret;
171
172 ret = osd_execute_request_async(or, async_done, caller_context);
173
174 return ret;
175}
176
177/* copied from exofs; move to libosd? */
178static int extract_attr_from_req(struct osd_request *or, struct osd_attr *attr)
179{
180 struct osd_attr cur_attr = {.attr_page = 0}; /* start with zeros */
181 void *iter = NULL;
182 int nelem;
183
184 do {
185 nelem = 1;
186 osd_req_decode_get_attr_list(or, &cur_attr, &nelem, &iter);
187 if ((cur_attr.attr_page == attr->attr_page) &&
188 (cur_attr.attr_id == attr->attr_id)) {
189 attr->len = cur_attr.len;
190 attr->val_ptr = cur_attr.val_ptr;
191 return 0;
192 }
193 } while (iter);
194
195 return -EIO;
196}
197
198static int osdblk_get_obj_size(struct osdblk_device *osdev, u64 *size_out)
199{
200 struct osd_request *or;
201 struct osd_attr attr;
202 int ret;
203
204 /* start request */
205 or = osd_start_request(osdev->osd, GFP_KERNEL);
206 if (!or)
207 return -ENOMEM;
208
209 /* create a get-attributes(length) request */
210 osd_req_get_attributes(or, &osdev->obj);
211
212 osd_req_add_get_attr_list(or, &g_attr_logical_length, 1);
213
214 /* execute op synchronously */
215 ret = osd_sync_op(or, OSDBLK_OP_TIMEOUT, osdev->obj_cred);
216 if (ret)
217 goto out;
218
219 /* extract length from returned attribute info */
220 attr = g_attr_logical_length;
221 ret = extract_attr_from_req(or, &attr);
222 if (ret)
223 goto out;
224
225 *size_out = get_unaligned_be64(attr.val_ptr);
226
227out:
228 osd_end_request(or);
229 return ret;
230
231}
232
233static void osdblk_osd_complete(struct osd_request *or, void *private)
234{
235 struct osdblk_request *orq = private;
236 struct osd_sense_info osi;
237 int ret = osd_req_decode_sense(or, &osi);
238
239 if (ret) {
240 ret = -EIO;
241 OSDBLK_DEBUG("osdblk_osd_complete with err=%d\n", ret);
242 }
243
244 /* complete OSD request */
245 osd_end_request(or);
246
247 /* complete request passed to osdblk by block layer */
248 __blk_end_request_all(orq->rq, ret);
249}
250
251static void bio_chain_put(struct bio *chain)
252{
253 struct bio *tmp;
254
255 while (chain) {
256 tmp = chain;
257 chain = chain->bi_next;
258
259 bio_put(tmp);
260 }
261}
262
263static struct bio *bio_chain_clone(struct bio *old_chain, gfp_t gfpmask)
264{
265 struct bio *tmp, *new_chain = NULL, *tail = NULL;
266
267 while (old_chain) {
268 tmp = bio_kmalloc(gfpmask, old_chain->bi_max_vecs);
269 if (!tmp)
270 goto err_out;
271
272 __bio_clone(tmp, old_chain);
273 tmp->bi_bdev = NULL;
274 gfpmask &= ~__GFP_WAIT;
275 tmp->bi_next = NULL;
276
277 if (!new_chain)
278 new_chain = tail = tmp;
279 else {
280 tail->bi_next = tmp;
281 tail = tmp;
282 }
283
284 old_chain = old_chain->bi_next;
285 }
286
287 return new_chain;
288
289err_out:
290 OSDBLK_DEBUG("bio_chain_clone with err\n");
291 bio_chain_put(new_chain);
292 return NULL;
293}
294
295static void osdblk_rq_fn(struct request_queue *q)
296{
297 struct osdblk_device *osdev = q->queuedata;
298
299 while (1) {
300 struct request *rq;
301 struct osdblk_request *orq;
302 struct osd_request *or;
303 struct bio *bio;
304 bool do_write, do_flush;
305
306 /* peek at request from block layer */
307 rq = blk_fetch_request(q);
308 if (!rq)
309 break;
310
311 /* filter out block requests we don't understand */
312 if (!blk_fs_request(rq) && !blk_barrier_rq(rq)) {
313 blk_end_request_all(rq, 0);
314 continue;
315 }
316
317 /* deduce our operation (read, write, flush) */
318 /* I wish the block layer simplified cmd_type/cmd_flags/cmd[]
319 * into a clearly defined set of RPC commands:
320 * read, write, flush, scsi command, power mgmt req,
321 * driver-specific, etc.
322 */
323
324 do_flush = (rq->special == (void *) 0xdeadbeefUL);
325 do_write = (rq_data_dir(rq) == WRITE);
326
327 if (!do_flush) { /* osd_flush does not use a bio */
328 /* a bio clone to be passed down to OSD request */
329 bio = bio_chain_clone(rq->bio, GFP_ATOMIC);
330 if (!bio)
331 break;
332 } else
333 bio = NULL;
334
335 /* alloc internal OSD request, for OSD command execution */
336 or = osd_start_request(osdev->osd, GFP_ATOMIC);
337 if (!or) {
338 bio_chain_put(bio);
339 OSDBLK_DEBUG("osd_start_request with err\n");
340 break;
341 }
342
343 orq = &osdev->req[rq->tag];
344 orq->rq = rq;
345 orq->bio = bio;
346 orq->osdev = osdev;
347
348 /* init OSD command: flush, write or read */
349 if (do_flush)
350 osd_req_flush_object(or, &osdev->obj,
351 OSD_CDB_FLUSH_ALL, 0, 0);
352 else if (do_write)
353 osd_req_write(or, &osdev->obj, blk_rq_pos(rq) * 512ULL,
354 bio, blk_rq_bytes(rq));
355 else
356 osd_req_read(or, &osdev->obj, blk_rq_pos(rq) * 512ULL,
357 bio, blk_rq_bytes(rq));
358
359 OSDBLK_DEBUG("%s 0x%x bytes at 0x%llx\n",
360 do_flush ? "flush" : do_write ?
361 "write" : "read", blk_rq_bytes(rq),
362 blk_rq_pos(rq) * 512ULL);
363
364 /* begin OSD command execution */
365 if (osd_async_op(or, osdblk_osd_complete, orq,
366 osdev->obj_cred)) {
367 osd_end_request(or);
368 blk_requeue_request(q, rq);
369 bio_chain_put(bio);
370 OSDBLK_DEBUG("osd_execute_request_async with err\n");
371 break;
372 }
373
374 /* remove the special 'flush' marker, now that the command
375 * is executing
376 */
377 rq->special = NULL;
378 }
379}
380
381static void osdblk_prepare_flush(struct request_queue *q, struct request *rq)
382{
383 /* add driver-specific marker, to indicate that this request
384 * is a flush command
385 */
386 rq->special = (void *) 0xdeadbeefUL;
387}
388
389static void osdblk_free_disk(struct osdblk_device *osdev)
390{
391 struct gendisk *disk = osdev->disk;
392
393 if (!disk)
394 return;
395
396 if (disk->flags & GENHD_FL_UP)
397 del_gendisk(disk);
398 if (disk->queue)
399 blk_cleanup_queue(disk->queue);
400 put_disk(disk);
401}
402
403static int osdblk_init_disk(struct osdblk_device *osdev)
404{
405 struct gendisk *disk;
406 struct request_queue *q;
407 int rc;
408 u64 obj_size = 0;
409
410 /* contact OSD, request size info about the object being mapped */
411 rc = osdblk_get_obj_size(osdev, &obj_size);
412 if (rc)
413 return rc;
414
415 /* create gendisk info */
416 disk = alloc_disk(OSDBLK_MINORS_PER_MAJOR);
417 if (!disk)
418 return -ENOMEM;
419
420 sprintf(disk->disk_name, DRV_NAME "%d", osdev->id);
421 disk->major = osdev->major;
422 disk->first_minor = 0;
423 disk->fops = &osdblk_bd_ops;
424 disk->private_data = osdev;
425
426 /* init rq */
427 q = blk_init_queue(osdblk_rq_fn, &osdev->lock);
428 if (!q) {
429 put_disk(disk);
430 return -ENOMEM;
431 }
432
433 /* switch queue to TCQ mode; allocate tag map */
434 rc = blk_queue_init_tags(q, OSDBLK_MAX_REQ, NULL);
435 if (rc) {
436 blk_cleanup_queue(q);
437 put_disk(disk);
438 return rc;
439 }
440
441 /* Set our limits to the lower device limits, because osdblk cannot
442 * sleep when allocating a lower-request and therefore cannot be
443 * bouncing.
444 */
445 blk_queue_stack_limits(q, osd_request_queue(osdev->osd));
446
447 blk_queue_prep_rq(q, blk_queue_start_tag);
448 blk_queue_ordered(q, QUEUE_ORDERED_DRAIN_FLUSH, osdblk_prepare_flush);
449
450 disk->queue = q;
451
452 q->queuedata = osdev;
453
454 osdev->disk = disk;
455 osdev->q = q;
456
457 /* finally, announce the disk to the world */
458 set_capacity(disk, obj_size / 512ULL);
459 add_disk(disk);
460
461 printk(KERN_INFO "%s: Added of size 0x%llx\n",
462 disk->disk_name, (unsigned long long)obj_size);
463
464 return 0;
465}
466
467/********************************************************************
468 * /sys/class/osdblk/
469 * add map OSD object to blkdev
470 * remove unmap OSD object
471 * list show mappings
472 *******************************************************************/
473
474static void class_osdblk_release(struct class *cls)
475{
476 kfree(cls);
477}
478
479static ssize_t class_osdblk_list(struct class *c, char *data)
480{
481 int n = 0;
482 struct list_head *tmp;
483
484 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
485
486 list_for_each(tmp, &osdblkdev_list) {
487 struct osdblk_device *osdev;
488
489 osdev = list_entry(tmp, struct osdblk_device, node);
490
491 n += sprintf(data+n, "%d %d %llu %llu %s\n",
492 osdev->id,
493 osdev->major,
494 osdev->obj.partition,
495 osdev->obj.id,
496 osdev->osd_path);
497 }
498
499 mutex_unlock(&ctl_mutex);
500 return n;
501}
502
503static ssize_t class_osdblk_add(struct class *c, const char *buf, size_t count)
504{
505 struct osdblk_device *osdev;
506 ssize_t rc;
507 int irc, new_id = 0;
508 struct list_head *tmp;
509
510 if (!try_module_get(THIS_MODULE))
511 return -ENODEV;
512
513 /* new osdblk_device object */
514 osdev = kzalloc(sizeof(*osdev) + strlen(buf) + 1, GFP_KERNEL);
515 if (!osdev) {
516 rc = -ENOMEM;
517 goto err_out_mod;
518 }
519
520 /* static osdblk_device initialization */
521 spin_lock_init(&osdev->lock);
522 INIT_LIST_HEAD(&osdev->node);
523
524 /* generate unique id: find highest unique id, add one */
525
526 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
527
528 list_for_each(tmp, &osdblkdev_list) {
529 struct osdblk_device *osdev;
530
531 osdev = list_entry(tmp, struct osdblk_device, node);
532 if (osdev->id > new_id)
533 new_id = osdev->id + 1;
534 }
535
536 osdev->id = new_id;
537
538 /* add to global list */
539 list_add_tail(&osdev->node, &osdblkdev_list);
540
541 mutex_unlock(&ctl_mutex);
542
543 /* parse add command */
544 if (sscanf(buf, "%llu %llu %s", &osdev->obj.partition, &osdev->obj.id,
545 osdev->osd_path) != 3) {
546 rc = -EINVAL;
547 goto err_out_slot;
548 }
549
550 /* initialize rest of new object */
551 sprintf(osdev->name, DRV_NAME "%d", osdev->id);
552
553 /* contact requested OSD */
554 osdev->osd = osduld_path_lookup(osdev->osd_path);
555 if (IS_ERR(osdev->osd)) {
556 rc = PTR_ERR(osdev->osd);
557 goto err_out_slot;
558 }
559
560 /* build OSD credential */
561 osdblk_make_credential(osdev->obj_cred, &osdev->obj);
562
563 /* register our block device */
564 irc = register_blkdev(0, osdev->name);
565 if (irc < 0) {
566 rc = irc;
567 goto err_out_osd;
568 }
569
570 osdev->major = irc;
571
572 /* set up and announce blkdev mapping */
573 rc = osdblk_init_disk(osdev);
574 if (rc)
575 goto err_out_blkdev;
576
577 return count;
578
579err_out_blkdev:
580 unregister_blkdev(osdev->major, osdev->name);
581err_out_osd:
582 osduld_put_device(osdev->osd);
583err_out_slot:
584 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
585 list_del_init(&osdev->node);
586 mutex_unlock(&ctl_mutex);
587
588 kfree(osdev);
589err_out_mod:
590 OSDBLK_DEBUG("Error adding device %s\n", buf);
591 module_put(THIS_MODULE);
592 return rc;
593}
594
595static ssize_t class_osdblk_remove(struct class *c, const char *buf,
596 size_t count)
597{
598 struct osdblk_device *osdev = NULL;
599 int target_id, rc;
600 unsigned long ul;
601 struct list_head *tmp;
602
603 rc = strict_strtoul(buf, 10, &ul);
604 if (rc)
605 return rc;
606
607 /* convert to int; abort if we lost anything in the conversion */
608 target_id = (int) ul;
609 if (target_id != ul)
610 return -EINVAL;
611
612 /* remove object from list immediately */
613 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
614
615 list_for_each(tmp, &osdblkdev_list) {
616 osdev = list_entry(tmp, struct osdblk_device, node);
617 if (osdev->id == target_id) {
618 list_del_init(&osdev->node);
619 break;
620 }
621 osdev = NULL;
622 }
623
624 mutex_unlock(&ctl_mutex);
625
626 if (!osdev)
627 return -ENOENT;
628
629 /* clean up and free blkdev and associated OSD connection */
630 osdblk_free_disk(osdev);
631 unregister_blkdev(osdev->major, osdev->name);
632 osduld_put_device(osdev->osd);
633 kfree(osdev);
634
635 /* release module ref */
636 module_put(THIS_MODULE);
637
638 return count;
639}
640
641static struct class_attribute class_osdblk_attrs[] = {
642 __ATTR(add, 0200, NULL, class_osdblk_add),
643 __ATTR(remove, 0200, NULL, class_osdblk_remove),
644 __ATTR(list, 0444, class_osdblk_list, NULL),
645 __ATTR_NULL
646};
647
648static int osdblk_sysfs_init(void)
649{
650 int ret = 0;
651
652 /*
653 * create control files in sysfs
654 * /sys/class/osdblk/...
655 */
656 class_osdblk = kzalloc(sizeof(*class_osdblk), GFP_KERNEL);
657 if (!class_osdblk)
658 return -ENOMEM;
659
660 class_osdblk->name = DRV_NAME;
661 class_osdblk->owner = THIS_MODULE;
662 class_osdblk->class_release = class_osdblk_release;
663 class_osdblk->class_attrs = class_osdblk_attrs;
664
665 ret = class_register(class_osdblk);
666 if (ret) {
667 kfree(class_osdblk);
668 class_osdblk = NULL;
669 printk(PFX "failed to create class osdblk\n");
670 return ret;
671 }
672
673 return 0;
674}
675
676static void osdblk_sysfs_cleanup(void)
677{
678 if (class_osdblk)
679 class_destroy(class_osdblk);
680 class_osdblk = NULL;
681}
682
683static int __init osdblk_init(void)
684{
685 int rc;
686
687 rc = osdblk_sysfs_init();
688 if (rc)
689 return rc;
690
691 return 0;
692}
693
694static void __exit osdblk_exit(void)
695{
696 osdblk_sysfs_cleanup();
697}
698
699module_init(osdblk_init);
700module_exit(osdblk_exit);
701
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 83650e00632d..99a506f619b7 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -1372,8 +1372,10 @@ try_next_bio:
1372 wakeup = (pd->write_congestion_on > 0 1372 wakeup = (pd->write_congestion_on > 0
1373 && pd->bio_queue_size <= pd->write_congestion_off); 1373 && pd->bio_queue_size <= pd->write_congestion_off);
1374 spin_unlock(&pd->lock); 1374 spin_unlock(&pd->lock);
1375 if (wakeup) 1375 if (wakeup) {
1376 clear_bdi_congested(&pd->disk->queue->backing_dev_info, WRITE); 1376 clear_bdi_congested(&pd->disk->queue->backing_dev_info,
1377 BLK_RW_ASYNC);
1378 }
1377 1379
1378 pkt->sleep_time = max(PACKET_WAIT_TIME, 1); 1380 pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
1379 pkt_set_state(pkt, PACKET_WAITING_STATE); 1381 pkt_set_state(pkt, PACKET_WAITING_STATE);
@@ -2592,10 +2594,10 @@ static int pkt_make_request(struct request_queue *q, struct bio *bio)
2592 spin_lock(&pd->lock); 2594 spin_lock(&pd->lock);
2593 if (pd->write_congestion_on > 0 2595 if (pd->write_congestion_on > 0
2594 && pd->bio_queue_size >= pd->write_congestion_on) { 2596 && pd->bio_queue_size >= pd->write_congestion_on) {
2595 set_bdi_congested(&q->backing_dev_info, WRITE); 2597 set_bdi_congested(&q->backing_dev_info, BLK_RW_ASYNC);
2596 do { 2598 do {
2597 spin_unlock(&pd->lock); 2599 spin_unlock(&pd->lock);
2598 congestion_wait(WRITE, HZ); 2600 congestion_wait(BLK_RW_ASYNC, HZ);
2599 spin_lock(&pd->lock); 2601 spin_lock(&pd->lock);
2600 } while(pd->bio_queue_size > pd->write_congestion_off); 2602 } while(pd->bio_queue_size > pd->write_congestion_off);
2601 } 2603 }
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index f08491a3a813..b20abe102a2b 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -390,9 +390,10 @@ static inline void ace_dump_mem(void *base, int len)
390 390
391static void ace_dump_regs(struct ace_device *ace) 391static void ace_dump_regs(struct ace_device *ace)
392{ 392{
393 dev_info(ace->dev, " ctrl: %.8x seccnt/cmd: %.4x ver:%.4x\n" 393 dev_info(ace->dev,
394 KERN_INFO " status:%.8x mpu_lba:%.8x busmode:%4x\n" 394 " ctrl: %.8x seccnt/cmd: %.4x ver:%.4x\n"
395 KERN_INFO " error: %.8x cfg_lba:%.8x fatstat:%.4x\n", 395 " status:%.8x mpu_lba:%.8x busmode:%4x\n"
396 " error: %.8x cfg_lba:%.8x fatstat:%.4x\n",
396 ace_in32(ace, ACE_CTRL), 397 ace_in32(ace, ACE_CTRL),
397 ace_in(ace, ACE_SECCNTCMD), 398 ace_in(ace, ACE_SECCNTCMD),
398 ace_in(ace, ACE_VERSION), 399 ace_in(ace, ACE_VERSION),
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 1df9dda2e377..d5cde6d86f89 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -28,7 +28,6 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/smp_lock.h>
32#include <linux/types.h> 31#include <linux/types.h>
33#include <linux/errno.h> 32#include <linux/errno.h>
34#include <linux/sched.h> 33#include <linux/sched.h>
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 0bd01f49cfd8..6a06913b01d3 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -1029,10 +1029,6 @@ config CS5535_GPIO
1029 1029
1030 If compiled as a module, it will be called cs5535_gpio. 1030 If compiled as a module, it will be called cs5535_gpio.
1031 1031
1032config GPIO_VR41XX
1033 tristate "NEC VR4100 series General-purpose I/O Unit support"
1034 depends on CPU_VR41XX
1035
1036config RAW_DRIVER 1032config RAW_DRIVER
1037 tristate "RAW driver (/dev/raw/rawN)" 1033 tristate "RAW driver (/dev/raw/rawN)"
1038 depends on BLOCK 1034 depends on BLOCK
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 189efcff08ce..66f779ad4f4c 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -95,7 +95,6 @@ obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
95obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o 95obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o
96obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o 96obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o
97obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o 97obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
98obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
99obj-$(CONFIG_GPIO_TB0219) += tb0219.o 98obj-$(CONFIG_GPIO_TB0219) += tb0219.o
100obj-$(CONFIG_TELCLOCK) += tlclk.o 99obj-$(CONFIG_TELCLOCK) += tlclk.o
101 100
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 72429b6b2fa8..6c32fbf07164 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -81,6 +81,7 @@ static char *serial_version = "4.30";
81#include <linux/mm.h> 81#include <linux/mm.h>
82#include <linux/seq_file.h> 82#include <linux/seq_file.h>
83#include <linux/slab.h> 83#include <linux/slab.h>
84#include <linux/smp_lock.h>
84#include <linux/init.h> 85#include <linux/init.h>
85#include <linux/bitops.h> 86#include <linux/bitops.h>
86 87
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index 140ea10ecb88..c02db01f736e 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -27,6 +27,7 @@
27#include <linux/cdev.h> 27#include <linux/cdev.h>
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <asm/pgtable.h>
30#include <asm/io.h> 31#include <asm/io.h>
31 32
32/* 33/*
@@ -75,12 +76,13 @@ static struct class *bsr_class;
75static int bsr_major; 76static int bsr_major;
76 77
77enum { 78enum {
78 BSR_8 = 0, 79 BSR_8 = 0,
79 BSR_16 = 1, 80 BSR_16 = 1,
80 BSR_64 = 2, 81 BSR_64 = 2,
81 BSR_128 = 3, 82 BSR_128 = 3,
82 BSR_UNKNOWN = 4, 83 BSR_4096 = 4,
83 BSR_MAX = 5, 84 BSR_UNKNOWN = 5,
85 BSR_MAX = 6,
84}; 86};
85 87
86static unsigned bsr_types[BSR_MAX]; 88static unsigned bsr_types[BSR_MAX];
@@ -117,15 +119,22 @@ static int bsr_mmap(struct file *filp, struct vm_area_struct *vma)
117{ 119{
118 unsigned long size = vma->vm_end - vma->vm_start; 120 unsigned long size = vma->vm_end - vma->vm_start;
119 struct bsr_dev *dev = filp->private_data; 121 struct bsr_dev *dev = filp->private_data;
122 int ret;
120 123
121 if (size > dev->bsr_len || (size & (PAGE_SIZE-1)))
122 return -EINVAL;
123
124 vma->vm_flags |= (VM_IO | VM_DONTEXPAND);
125 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 124 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
126 125
127 if (io_remap_pfn_range(vma, vma->vm_start, dev->bsr_addr >> PAGE_SHIFT, 126 /* check for the case of a small BSR device and map one 4k page for it*/
128 size, vma->vm_page_prot)) 127 if (dev->bsr_len < PAGE_SIZE && size == PAGE_SIZE)
128 ret = remap_4k_pfn(vma, vma->vm_start, dev->bsr_addr >> 12,
129 vma->vm_page_prot);
130 else if (size <= dev->bsr_len)
131 ret = io_remap_pfn_range(vma, vma->vm_start,
132 dev->bsr_addr >> PAGE_SHIFT,
133 size, vma->vm_page_prot);
134 else
135 return -EINVAL;
136
137 if (ret)
129 return -EAGAIN; 138 return -EAGAIN;
130 139
131 return 0; 140 return 0;
@@ -205,6 +214,11 @@ static int bsr_add_node(struct device_node *bn)
205 cur->bsr_stride = bsr_stride[i]; 214 cur->bsr_stride = bsr_stride[i];
206 cur->bsr_dev = MKDEV(bsr_major, i + total_bsr_devs); 215 cur->bsr_dev = MKDEV(bsr_major, i + total_bsr_devs);
207 216
217 /* if we have a bsr_len of > 4k and less then PAGE_SIZE (64k pages) */
218 /* we can only map 4k of it, so only advertise the 4k in sysfs */
219 if (cur->bsr_len > 4096 && cur->bsr_len < PAGE_SIZE)
220 cur->bsr_len = 4096;
221
208 switch(cur->bsr_bytes) { 222 switch(cur->bsr_bytes) {
209 case 8: 223 case 8:
210 cur->bsr_type = BSR_8; 224 cur->bsr_type = BSR_8;
@@ -218,9 +232,11 @@ static int bsr_add_node(struct device_node *bn)
218 case 128: 232 case 128:
219 cur->bsr_type = BSR_128; 233 cur->bsr_type = BSR_128;
220 break; 234 break;
235 case 4096:
236 cur->bsr_type = BSR_4096;
237 break;
221 default: 238 default:
222 cur->bsr_type = BSR_UNKNOWN; 239 cur->bsr_type = BSR_UNKNOWN;
223 printk(KERN_INFO "unknown BSR size %d\n",cur->bsr_bytes);
224 } 240 }
225 241
226 cur->bsr_num = bsr_types[cur->bsr_type]; 242 cur->bsr_num = bsr_types[cur->bsr_type];
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index f3366d3f06cf..2dafc2da0648 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -633,6 +633,7 @@
633#include <linux/tty.h> 633#include <linux/tty.h>
634#include <linux/tty_flip.h> 634#include <linux/tty_flip.h>
635#include <linux/serial.h> 635#include <linux/serial.h>
636#include <linux/smp_lock.h>
636#include <linux/major.h> 637#include <linux/major.h>
637#include <linux/string.h> 638#include <linux/string.h>
638#include <linux/fcntl.h> 639#include <linux/fcntl.h>
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index abef1f7d84fe..ff647ca1c489 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -36,6 +36,7 @@
36#include <linux/tty.h> 36#include <linux/tty.h>
37#include <linux/tty_flip.h> 37#include <linux/tty_flip.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/smp_lock.h>
39#include <linux/ioport.h> 40#include <linux/ioport.h>
40#include <linux/interrupt.h> 41#include <linux/interrupt.h>
41#include <linux/uaccess.h> 42#include <linux/uaccess.h>
diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
index 5dcbe603eca2..91b53eb1c053 100644
--- a/drivers/char/hw_random/intel-rng.c
+++ b/drivers/char/hw_random/intel-rng.c
@@ -305,10 +305,11 @@ static int __init intel_init_hw_struct(struct intel_rng_hw *intel_rng_hw,
305 (BIOS_CNTL_LOCK_ENABLE_MASK|BIOS_CNTL_WRITE_ENABLE_MASK)) 305 (BIOS_CNTL_LOCK_ENABLE_MASK|BIOS_CNTL_WRITE_ENABLE_MASK))
306 == BIOS_CNTL_LOCK_ENABLE_MASK) { 306 == BIOS_CNTL_LOCK_ENABLE_MASK) {
307 static __initdata /*const*/ char warning[] = 307 static __initdata /*const*/ char warning[] =
308 KERN_WARNING PFX "Firmware space is locked read-only. If you can't or\n" 308 KERN_WARNING
309 KERN_WARNING PFX "don't want to disable this in firmware setup, and if\n" 309PFX "Firmware space is locked read-only. If you can't or\n"
310 KERN_WARNING PFX "you are certain that your system has a functional\n" 310PFX "don't want to disable this in firmware setup, and if\n"
311 KERN_WARNING PFX "RNG, try using the 'no_fwh_detect' option.\n"; 311PFX "you are certain that your system has a functional\n"
312PFX "RNG, try using the 'no_fwh_detect' option.\n";
312 313
313 if (no_fwh_detect) 314 if (no_fwh_detect)
314 return -ENODEV; 315 return -ENODEV;
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 4159292e35cf..4f1f4cd670da 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -122,6 +122,7 @@
122#include <linux/fs.h> 122#include <linux/fs.h>
123#include <linux/sched.h> 123#include <linux/sched.h>
124#include <linux/serial.h> 124#include <linux/serial.h>
125#include <linux/smp_lock.h>
125#include <linux/mm.h> 126#include <linux/mm.h>
126#include <linux/interrupt.h> 127#include <linux/interrupt.h>
127#include <linux/timer.h> 128#include <linux/timer.h>
@@ -1478,10 +1479,10 @@ static int __devinit load_firmware(struct pci_dev *pdev,
1478 status = inw(base + 0x4); 1479 status = inw(base + 0x4);
1479 if (status != 0) { 1480 if (status != 0) {
1480 dev_warn(&pdev->dev, "Card%d rejected load header:\n" 1481 dev_warn(&pdev->dev, "Card%d rejected load header:\n"
1481 KERN_WARNING "Address:0x%x\n" 1482 "Address:0x%x\n"
1482 KERN_WARNING "Count:0x%x\n" 1483 "Count:0x%x\n"
1483 KERN_WARNING "Status:0x%x\n", 1484 "Status:0x%x\n",
1484 index + 1, frame->addr, frame->count, status); 1485 index + 1, frame->addr, frame->count, status);
1485 goto errrelfw; 1486 goto errrelfw;
1486 } 1487 }
1487 outsw(base, frame->data, word_count); 1488 outsw(base, frame->data, word_count);
@@ -1526,10 +1527,10 @@ static int __devinit load_firmware(struct pci_dev *pdev,
1526 status = inw(base + 0x4); 1527 status = inw(base + 0x4);
1527 if (status != 0) { 1528 if (status != 0) {
1528 dev_warn(&pdev->dev, "Card%d rejected verify header:\n" 1529 dev_warn(&pdev->dev, "Card%d rejected verify header:\n"
1529 KERN_WARNING "Address:0x%x\n" 1530 "Address:0x%x\n"
1530 KERN_WARNING "Count:0x%x\n" 1531 "Count:0x%x\n"
1531 KERN_WARNING "Status: 0x%x\n", 1532 "Status: 0x%x\n",
1532 index + 1, frame->addr, frame->count, status); 1533 index + 1, frame->addr, frame->count, status);
1533 goto errrelfw; 1534 goto errrelfw;
1534 } 1535 }
1535 1536
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 0c999f5bb3db..ab2f3349c5c4 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/smp_lock.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/tty.h> 25#include <linux/tty.h>
25#include <linux/tty_flip.h> 26#include <linux/tty_flip.h>
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 65b6ff2442c6..dd0083bbb64a 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -34,6 +34,7 @@
34#include <linux/tty.h> 34#include <linux/tty.h>
35#include <linux/tty_flip.h> 35#include <linux/tty_flip.h>
36#include <linux/major.h> 36#include <linux/major.h>
37#include <linux/smp_lock.h>
37#include <linux/string.h> 38#include <linux/string.h>
38#include <linux/fcntl.h> 39#include <linux/fcntl.h>
39#include <linux/ptrace.h> 40#include <linux/ptrace.h>
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 52d953eb30c3..dbf8d52f31d0 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -23,6 +23,7 @@
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/signal.h> 24#include <linux/signal.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/smp_lock.h>
26#include <linux/timer.h> 27#include <linux/timer.h>
27#include <linux/interrupt.h> 28#include <linux/interrupt.h>
28#include <linux/tty.h> 29#include <linux/tty.h>
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
index 1c43c8cdee25..c68118efad84 100644
--- a/drivers/char/n_hdlc.c
+++ b/drivers/char/n_hdlc.c
@@ -97,6 +97,7 @@
97#include <linux/slab.h> 97#include <linux/slab.h>
98#include <linux/tty.h> 98#include <linux/tty.h>
99#include <linux/errno.h> 99#include <linux/errno.h>
100#include <linux/smp_lock.h>
100#include <linux/string.h> /* used in new tty drivers */ 101#include <linux/string.h> /* used in new tty drivers */
101#include <linux/signal.h> /* used in new tty drivers */ 102#include <linux/signal.h> /* used in new tty drivers */
102#include <linux/if.h> 103#include <linux/if.h>
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
index 2e99158ebb8a..6934025a1ac1 100644
--- a/drivers/char/n_r3964.c
+++ b/drivers/char/n_r3964.c
@@ -58,6 +58,7 @@
58#include <linux/ioport.h> 58#include <linux/ioport.h>
59#include <linux/in.h> 59#include <linux/in.h>
60#include <linux/slab.h> 60#include <linux/slab.h>
61#include <linux/smp_lock.h>
61#include <linux/tty.h> 62#include <linux/tty.h>
62#include <linux/errno.h> 63#include <linux/errno.h>
63#include <linux/string.h> /* used in new tty drivers */ 64#include <linux/string.h> /* used in new tty drivers */
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index daebe1ba43d4..6e6942c45f5b 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -22,6 +22,7 @@
22#include <linux/major.h> 22#include <linux/major.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/smp_lock.h>
25#include <linux/sysctl.h> 26#include <linux/sysctl.h>
26#include <linux/device.h> 27#include <linux/device.h>
27#include <linux/uaccess.h> 28#include <linux/uaccess.h>
@@ -75,114 +76,88 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
75 */ 76 */
76static void pty_unthrottle(struct tty_struct *tty) 77static void pty_unthrottle(struct tty_struct *tty)
77{ 78{
78 struct tty_struct *o_tty = tty->link; 79 tty_wakeup(tty->link);
79
80 if (!o_tty)
81 return;
82
83 tty_wakeup(o_tty);
84 set_bit(TTY_THROTTLED, &tty->flags); 80 set_bit(TTY_THROTTLED, &tty->flags);
85} 81}
86 82
87/* 83/**
88 * WSH 05/24/97: modified to 84 * pty_space - report space left for writing
89 * (1) use space in tty->flip instead of a shared temp buffer 85 * @to: tty we are writing into
90 * The flip buffers aren't being used for a pty, so there's lots
91 * of space available. The buffer is protected by a per-pty
92 * semaphore that should almost never come under contention.
93 * (2) avoid redundant copying for cases where count >> receive_room
94 * N.B. Calls from user space may now return an error code instead of
95 * a count.
96 * 86 *
97 * FIXME: Our pty_write method is called with our ldisc lock held but 87 * The tty buffers allow 64K but we sneak a peak and clip at 8K this
98 * not our partners. We can't just wait on the other one blindly without 88 * allows a lot of overspill room for echo and other fun messes to
99 * risking deadlocks. At some point when everything has settled down we need 89 * be handled properly
100 * to look into making pty_write at least able to sleep over an ldisc change. 90 */
91
92static int pty_space(struct tty_struct *to)
93{
94 int n = 8192 - to->buf.memory_used;
95 if (n < 0)
96 return 0;
97 return n;
98}
99
100/**
101 * pty_write - write to a pty
102 * @tty: the tty we write from
103 * @buf: kernel buffer of data
104 * @count: bytes to write
101 * 105 *
102 * The return on no ldisc is a bit counter intuitive but the logic works 106 * Our "hardware" write method. Data is coming from the ldisc which
103 * like this. During an ldisc change the other end will flush its buffers. We 107 * may be in a non sleeping state. We simply throw this at the other
104 * thus return the full length which is identical to the case where we had 108 * end of the link as if we were an IRQ handler receiving stuff for
105 * proper locking and happened to queue the bytes just before the flush during 109 * the other side of the pty/tty pair.
106 * the ldisc change.
107 */ 110 */
111
108static int pty_write(struct tty_struct *tty, const unsigned char *buf, 112static int pty_write(struct tty_struct *tty, const unsigned char *buf,
109 int count) 113 int count)
110{ 114{
111 struct tty_struct *to = tty->link; 115 struct tty_struct *to = tty->link;
112 struct tty_ldisc *ld; 116 int c;
113 int c = count;
114 117
115 if (!to || tty->stopped) 118 if (tty->stopped)
116 return 0; 119 return 0;
117 ld = tty_ldisc_ref(to); 120
118 121 /* This isn't locked but our 8K is quite sloppy so no
119 if (ld) { 122 big deal */
120 c = to->receive_room; 123
121 if (c > count) 124 c = pty_space(to);
122 c = count; 125 if (c > count)
123 ld->ops->receive_buf(to, buf, NULL, c); 126 c = count;
124 tty_ldisc_deref(ld); 127 if (c > 0) {
128 /* Stuff the data into the input queue of the other end */
129 c = tty_insert_flip_string(to, buf, c);
130 /* And shovel */
131 tty_flip_buffer_push(to);
132 tty_wakeup(tty);
125 } 133 }
126 return c; 134 return c;
127} 135}
128 136
137/**
138 * pty_write_room - write space
139 * @tty: tty we are writing from
140 *
141 * Report how many bytes the ldisc can send into the queue for
142 * the other device.
143 */
144
129static int pty_write_room(struct tty_struct *tty) 145static int pty_write_room(struct tty_struct *tty)
130{ 146{
131 struct tty_struct *to = tty->link; 147 return pty_space(tty->link);
132
133 if (!to || tty->stopped)
134 return 0;
135
136 return to->receive_room;
137} 148}
138 149
139/* 150/**
140 * WSH 05/24/97: Modified for asymmetric MASTER/SLAVE behavior 151 * pty_chars_in_buffer - characters currently in our tx queue
141 * The chars_in_buffer() value is used by the ldisc select() function 152 * @tty: our tty
142 * to hold off writing when chars_in_buffer > WAKEUP_CHARS (== 256).
143 * The pty driver chars_in_buffer() Master/Slave must behave differently:
144 *
145 * The Master side needs to allow typed-ahead commands to accumulate
146 * while being canonicalized, so we report "our buffer" as empty until
147 * some threshold is reached, and then report the count. (Any count >
148 * WAKEUP_CHARS is regarded by select() as "full".) To avoid deadlock
149 * the count returned must be 0 if no canonical data is available to be
150 * read. (The N_TTY ldisc.chars_in_buffer now knows this.)
151 * 153 *
152 * The Slave side passes all characters in raw mode to the Master side's 154 * Report how much we have in the transmit queue. As everything is
153 * buffer where they can be read immediately, so in this case we can 155 * instantly at the other end this is easy to implement.
154 * return the true count in the buffer.
155 */ 156 */
157
156static int pty_chars_in_buffer(struct tty_struct *tty) 158static int pty_chars_in_buffer(struct tty_struct *tty)
157{ 159{
158 struct tty_struct *to = tty->link; 160 return 0;
159 struct tty_ldisc *ld;
160 int count = 0;
161
162 /* We should get the line discipline lock for "tty->link" */
163 if (!to)
164 return 0;
165 /* We cannot take a sleeping reference here without deadlocking with
166 an ldisc change - but it doesn't really matter */
167 ld = tty_ldisc_ref(to);
168 if (ld == NULL)
169 return 0;
170
171 /* The ldisc must report 0 if no characters available to be read */
172 if (ld->ops->chars_in_buffer)
173 count = ld->ops->chars_in_buffer(to);
174
175 tty_ldisc_deref(ld);
176
177 if (tty->driver->subtype == PTY_TYPE_SLAVE)
178 return count;
179
180 /* Master side driver ... if the other side's read buffer is less than
181 * half full, return 0 to allow writers to proceed; otherwise return
182 * the count. This leaves a comfortable margin to avoid overflow,
183 * and still allows half a buffer's worth of typed-ahead commands.
184 */
185 return (count < N_TTY_BUF_SIZE/2) ? 0 : count;
186} 161}
187 162
188/* Set the lock flag on a pty */ 163/* Set the lock flag on a pty */
@@ -202,20 +177,10 @@ static void pty_flush_buffer(struct tty_struct *tty)
202{ 177{
203 struct tty_struct *to = tty->link; 178 struct tty_struct *to = tty->link;
204 unsigned long flags; 179 unsigned long flags;
205 struct tty_ldisc *ld;
206 180
207 if (!to) 181 if (!to)
208 return; 182 return;
209 ld = tty_ldisc_ref(to); 183 /* tty_buffer_flush(to); FIXME */
210
211 /* The other end is changing discipline */
212 if (!ld)
213 return;
214
215 if (ld->ops->flush_buffer)
216 to->ldisc->ops->flush_buffer(to);
217 tty_ldisc_deref(ld);
218
219 if (to->packet) { 184 if (to->packet) {
220 spin_lock_irqsave(&tty->ctrl_lock, flags); 185 spin_lock_irqsave(&tty->ctrl_lock, flags);
221 tty->ctrl_status |= TIOCPKT_FLUSHWRITE; 186 tty->ctrl_status |= TIOCPKT_FLUSHWRITE;
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index ce81da5b2da9..d58c2eb07f07 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -44,6 +44,7 @@
44#include <linux/delay.h> 44#include <linux/delay.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/smp_lock.h>
47#include <linux/miscdevice.h> 48#include <linux/miscdevice.h>
48#include <linux/init.h> 49#include <linux/init.h>
49 50
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 217660451237..171711acf5cd 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -47,6 +47,7 @@
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/tty_flip.h> 49#include <linux/tty_flip.h>
50#include <linux/smp_lock.h>
50#include <linux/spinlock.h> 51#include <linux/spinlock.h>
51#include <linux/device.h> 52#include <linux/device.h>
52 53
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 63d5b628477a..0e29a23ec4c5 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -73,6 +73,7 @@
73#include <linux/tty_driver.h> 73#include <linux/tty_driver.h>
74#include <linux/tty_flip.h> 74#include <linux/tty_flip.h>
75#include <linux/serial.h> 75#include <linux/serial.h>
76#include <linux/smp_lock.h>
76#include <linux/string.h> 77#include <linux/string.h>
77#include <linux/fcntl.h> 78#include <linux/fcntl.h>
78#include <linux/ptrace.h> 79#include <linux/ptrace.h>
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index f1f24f0ee26f..51e7a46787be 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -52,6 +52,7 @@
52#include <linux/interrupt.h> 52#include <linux/interrupt.h>
53#include <linux/serial.h> 53#include <linux/serial.h>
54#include <linux/serialP.h> 54#include <linux/serialP.h>
55#include <linux/smp_lock.h>
55#include <linux/string.h> 56#include <linux/string.h>
56#include <linux/fcntl.h> 57#include <linux/fcntl.h>
57#include <linux/ptrace.h> 58#include <linux/ptrace.h>
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index e72be4190a44..bfe4cdb2febb 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -87,6 +87,7 @@
87#include <linux/tty_flip.h> 87#include <linux/tty_flip.h>
88#include <linux/mm.h> 88#include <linux/mm.h>
89#include <linux/serial.h> 89#include <linux/serial.h>
90#include <linux/smp_lock.h>
90#include <linux/fcntl.h> 91#include <linux/fcntl.h>
91#include <linux/major.h> 92#include <linux/major.h>
92#include <linux/delay.h> 93#include <linux/delay.h>
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 518f2a25d91e..a81ec4fcf6ff 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -216,6 +216,7 @@
216#include <linux/eisa.h> 216#include <linux/eisa.h>
217#include <linux/pci.h> 217#include <linux/pci.h>
218#include <linux/slab.h> 218#include <linux/slab.h>
219#include <linux/smp_lock.h>
219#include <linux/init.h> 220#include <linux/init.h>
220#include <linux/miscdevice.h> 221#include <linux/miscdevice.h>
221#include <linux/bitops.h> 222#include <linux/bitops.h>
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index afded3a2379c..813552f14884 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -81,6 +81,7 @@
81#include <linux/mm.h> 81#include <linux/mm.h>
82#include <linux/seq_file.h> 82#include <linux/seq_file.h>
83#include <linux/slab.h> 83#include <linux/slab.h>
84#include <linux/smp_lock.h>
84#include <linux/delay.h> 85#include <linux/delay.h>
85#include <linux/netdevice.h> 86#include <linux/netdevice.h>
86#include <linux/vmalloc.h> 87#include <linux/vmalloc.h>
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index a2e67e6df3a1..91f20a92fddf 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -62,6 +62,7 @@
62#include <linux/mm.h> 62#include <linux/mm.h>
63#include <linux/seq_file.h> 63#include <linux/seq_file.h>
64#include <linux/slab.h> 64#include <linux/slab.h>
65#include <linux/smp_lock.h>
65#include <linux/netdevice.h> 66#include <linux/netdevice.h>
66#include <linux/vmalloc.h> 67#include <linux/vmalloc.h>
67#include <linux/init.h> 68#include <linux/init.h>
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 6f727e3c53ad..8d4a2a8a0a70 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -52,6 +52,7 @@
52#include <linux/mm.h> 52#include <linux/mm.h>
53#include <linux/seq_file.h> 53#include <linux/seq_file.h>
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/smp_lock.h>
55#include <linux/netdevice.h> 56#include <linux/netdevice.h>
56#include <linux/vmalloc.h> 57#include <linux/vmalloc.h>
57#include <linux/init.h> 58#include <linux/init.h>
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index 6062b62800fd..b3ec9b10e292 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for TANBAC TB0219 base board. 2 * Driver for TANBAC TB0219 base board.
3 * 3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2005 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
28#include <asm/vr41xx/giu.h> 28#include <asm/vr41xx/giu.h>
29#include <asm/vr41xx/tb0219.h> 29#include <asm/vr41xx/tb0219.h>
30 30
31MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>"); 31MODULE_AUTHOR("Yoichi Yuasa <yuasa@linux-mips.org>");
32MODULE_DESCRIPTION("TANBAC TB0219 base board driver"); 32MODULE_DESCRIPTION("TANBAC TB0219 base board driver");
33MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
34 34
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index ccdd828adcef..b0603b2e5684 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -26,7 +26,6 @@
26#include <linux/poll.h> 26#include <linux/poll.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <linux/smp_lock.h>
30 29
31#include "tpm.h" 30#include "tpm.h"
32 31
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index b24f6c6a1ea3..ad6ba4ed2808 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -21,7 +21,6 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/bitops.h> 22#include <linux/bitops.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/smp_lock.h>
25 24
26#include <asm/io.h> 25#include <asm/io.h>
27#include <asm/uaccess.h> 26#include <asm/uaccess.h>
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index a19e935847b0..0ef0dc97ba20 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -21,7 +21,6 @@
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/smp_lock.h>
25#include <linux/device.h> 24#include <linux/device.h>
26#include <linux/wait.h> 25#include <linux/wait.h>
27#include <linux/bitops.h> 26#include <linux/bitops.h>
@@ -867,15 +866,22 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
867 tty_ldisc_wait_idle(tty); 866 tty_ldisc_wait_idle(tty);
868 867
869 /* 868 /*
870 * Shutdown the current line discipline, and reset it to N_TTY. 869 * Now kill off the ldisc
871 *
872 * FIXME: this MUST get fixed for the new reflocking
873 */ 870 */
871 tty_ldisc_close(tty, tty->ldisc);
872 tty_ldisc_put(tty->ldisc);
873 /* Force an oops if we mess this up */
874 tty->ldisc = NULL;
875
876 /* Ensure the next open requests the N_TTY ldisc */
877 tty_set_termios_ldisc(tty, N_TTY);
874 878
875 tty_ldisc_reinit(tty);
876 /* This will need doing differently if we need to lock */ 879 /* This will need doing differently if we need to lock */
877 if (o_tty) 880 if (o_tty)
878 tty_ldisc_release(o_tty, NULL); 881 tty_ldisc_release(o_tty, NULL);
882
883 /* And the memory resources remaining (buffers, termios) will be
884 disposed of when the kref hits zero */
879} 885}
880 886
881/** 887/**
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
index 54c837288d19..e69de29bb2d1 100644
--- a/drivers/char/vr41xx_giu.c
+++ b/drivers/char/vr41xx_giu.c
@@ -1,680 +0,0 @@
1/*
2 * Driver for NEC VR4100 series General-purpose I/O Unit.
3 *
4 * Copyright (C) 2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copyright (C) 2003-2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#include <linux/errno.h>
23#include <linux/fs.h>
24#include <linux/init.h>
25#include <linux/interrupt.h>
26#include <linux/irq.h>
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/platform_device.h>
30#include <linux/smp_lock.h>
31#include <linux/spinlock.h>
32#include <linux/types.h>
33
34#include <asm/io.h>
35#include <asm/vr41xx/giu.h>
36#include <asm/vr41xx/irq.h>
37#include <asm/vr41xx/vr41xx.h>
38
39MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>");
40MODULE_DESCRIPTION("NEC VR4100 series General-purpose I/O Unit driver");
41MODULE_LICENSE("GPL");
42
43static int major; /* default is dynamic major device number */
44module_param(major, int, 0);
45MODULE_PARM_DESC(major, "Major device number");
46
47#define GIUIOSELL 0x00
48#define GIUIOSELH 0x02
49#define GIUPIODL 0x04
50#define GIUPIODH 0x06
51#define GIUINTSTATL 0x08
52#define GIUINTSTATH 0x0a
53#define GIUINTENL 0x0c
54#define GIUINTENH 0x0e
55#define GIUINTTYPL 0x10
56#define GIUINTTYPH 0x12
57#define GIUINTALSELL 0x14
58#define GIUINTALSELH 0x16
59#define GIUINTHTSELL 0x18
60#define GIUINTHTSELH 0x1a
61#define GIUPODATL 0x1c
62#define GIUPODATEN 0x1c
63#define GIUPODATH 0x1e
64 #define PIOEN0 0x0100
65 #define PIOEN1 0x0200
66#define GIUPODAT 0x1e
67#define GIUFEDGEINHL 0x20
68#define GIUFEDGEINHH 0x22
69#define GIUREDGEINHL 0x24
70#define GIUREDGEINHH 0x26
71
72#define GIUUSEUPDN 0x1e0
73#define GIUTERMUPDN 0x1e2
74
75#define GPIO_HAS_PULLUPDOWN_IO 0x0001
76#define GPIO_HAS_OUTPUT_ENABLE 0x0002
77#define GPIO_HAS_INTERRUPT_EDGE_SELECT 0x0100
78
79static spinlock_t giu_lock;
80static unsigned long giu_flags;
81static unsigned int giu_nr_pins;
82
83static void __iomem *giu_base;
84
85#define giu_read(offset) readw(giu_base + (offset))
86#define giu_write(offset, value) writew((value), giu_base + (offset))
87
88#define GPIO_PIN_OF_IRQ(irq) ((irq) - GIU_IRQ_BASE)
89#define GIUINT_HIGH_OFFSET 16
90#define GIUINT_HIGH_MAX 32
91
92static inline uint16_t giu_set(uint16_t offset, uint16_t set)
93{
94 uint16_t data;
95
96 data = giu_read(offset);
97 data |= set;
98 giu_write(offset, data);
99
100 return data;
101}
102
103static inline uint16_t giu_clear(uint16_t offset, uint16_t clear)
104{
105 uint16_t data;
106
107 data = giu_read(offset);
108 data &= ~clear;
109 giu_write(offset, data);
110
111 return data;
112}
113
114static void ack_giuint_low(unsigned int irq)
115{
116 giu_write(GIUINTSTATL, 1 << GPIO_PIN_OF_IRQ(irq));
117}
118
119static void mask_giuint_low(unsigned int irq)
120{
121 giu_clear(GIUINTENL, 1 << GPIO_PIN_OF_IRQ(irq));
122}
123
124static void mask_ack_giuint_low(unsigned int irq)
125{
126 unsigned int pin;
127
128 pin = GPIO_PIN_OF_IRQ(irq);
129 giu_clear(GIUINTENL, 1 << pin);
130 giu_write(GIUINTSTATL, 1 << pin);
131}
132
133static void unmask_giuint_low(unsigned int irq)
134{
135 giu_set(GIUINTENL, 1 << GPIO_PIN_OF_IRQ(irq));
136}
137
138static struct irq_chip giuint_low_irq_chip = {
139 .name = "GIUINTL",
140 .ack = ack_giuint_low,
141 .mask = mask_giuint_low,
142 .mask_ack = mask_ack_giuint_low,
143 .unmask = unmask_giuint_low,
144};
145
146static void ack_giuint_high(unsigned int irq)
147{
148 giu_write(GIUINTSTATH, 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
149}
150
151static void mask_giuint_high(unsigned int irq)
152{
153 giu_clear(GIUINTENH, 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
154}
155
156static void mask_ack_giuint_high(unsigned int irq)
157{
158 unsigned int pin;
159
160 pin = GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET;
161 giu_clear(GIUINTENH, 1 << pin);
162 giu_write(GIUINTSTATH, 1 << pin);
163}
164
165static void unmask_giuint_high(unsigned int irq)
166{
167 giu_set(GIUINTENH, 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
168}
169
170static struct irq_chip giuint_high_irq_chip = {
171 .name = "GIUINTH",
172 .ack = ack_giuint_high,
173 .mask = mask_giuint_high,
174 .mask_ack = mask_ack_giuint_high,
175 .unmask = unmask_giuint_high,
176};
177
178static int giu_get_irq(unsigned int irq)
179{
180 uint16_t pendl, pendh, maskl, maskh;
181 int i;
182
183 pendl = giu_read(GIUINTSTATL);
184 pendh = giu_read(GIUINTSTATH);
185 maskl = giu_read(GIUINTENL);
186 maskh = giu_read(GIUINTENH);
187
188 maskl &= pendl;
189 maskh &= pendh;
190
191 if (maskl) {
192 for (i = 0; i < 16; i++) {
193 if (maskl & (1 << i))
194 return GIU_IRQ(i);
195 }
196 } else if (maskh) {
197 for (i = 0; i < 16; i++) {
198 if (maskh & (1 << i))
199 return GIU_IRQ(i + GIUINT_HIGH_OFFSET);
200 }
201 }
202
203 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
204 maskl, pendl, maskh, pendh);
205
206 atomic_inc(&irq_err_count);
207
208 return -EINVAL;
209}
210
211void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger, irq_signal_t signal)
212{
213 uint16_t mask;
214
215 if (pin < GIUINT_HIGH_OFFSET) {
216 mask = 1 << pin;
217 if (trigger != IRQ_TRIGGER_LEVEL) {
218 giu_set(GIUINTTYPL, mask);
219 if (signal == IRQ_SIGNAL_HOLD)
220 giu_set(GIUINTHTSELL, mask);
221 else
222 giu_clear(GIUINTHTSELL, mask);
223 if (giu_flags & GPIO_HAS_INTERRUPT_EDGE_SELECT) {
224 switch (trigger) {
225 case IRQ_TRIGGER_EDGE_FALLING:
226 giu_set(GIUFEDGEINHL, mask);
227 giu_clear(GIUREDGEINHL, mask);
228 break;
229 case IRQ_TRIGGER_EDGE_RISING:
230 giu_clear(GIUFEDGEINHL, mask);
231 giu_set(GIUREDGEINHL, mask);
232 break;
233 default:
234 giu_set(GIUFEDGEINHL, mask);
235 giu_set(GIUREDGEINHL, mask);
236 break;
237 }
238 }
239 set_irq_chip_and_handler(GIU_IRQ(pin),
240 &giuint_low_irq_chip,
241 handle_edge_irq);
242 } else {
243 giu_clear(GIUINTTYPL, mask);
244 giu_clear(GIUINTHTSELL, mask);
245 set_irq_chip_and_handler(GIU_IRQ(pin),
246 &giuint_low_irq_chip,
247 handle_level_irq);
248 }
249 giu_write(GIUINTSTATL, mask);
250 } else if (pin < GIUINT_HIGH_MAX) {
251 mask = 1 << (pin - GIUINT_HIGH_OFFSET);
252 if (trigger != IRQ_TRIGGER_LEVEL) {
253 giu_set(GIUINTTYPH, mask);
254 if (signal == IRQ_SIGNAL_HOLD)
255 giu_set(GIUINTHTSELH, mask);
256 else
257 giu_clear(GIUINTHTSELH, mask);
258 if (giu_flags & GPIO_HAS_INTERRUPT_EDGE_SELECT) {
259 switch (trigger) {
260 case IRQ_TRIGGER_EDGE_FALLING:
261 giu_set(GIUFEDGEINHH, mask);
262 giu_clear(GIUREDGEINHH, mask);
263 break;
264 case IRQ_TRIGGER_EDGE_RISING:
265 giu_clear(GIUFEDGEINHH, mask);
266 giu_set(GIUREDGEINHH, mask);
267 break;
268 default:
269 giu_set(GIUFEDGEINHH, mask);
270 giu_set(GIUREDGEINHH, mask);
271 break;
272 }
273 }
274 set_irq_chip_and_handler(GIU_IRQ(pin),
275 &giuint_high_irq_chip,
276 handle_edge_irq);
277 } else {
278 giu_clear(GIUINTTYPH, mask);
279 giu_clear(GIUINTHTSELH, mask);
280 set_irq_chip_and_handler(GIU_IRQ(pin),
281 &giuint_high_irq_chip,
282 handle_level_irq);
283 }
284 giu_write(GIUINTSTATH, mask);
285 }
286}
287EXPORT_SYMBOL_GPL(vr41xx_set_irq_trigger);
288
289void vr41xx_set_irq_level(unsigned int pin, irq_level_t level)
290{
291 uint16_t mask;
292
293 if (pin < GIUINT_HIGH_OFFSET) {
294 mask = 1 << pin;
295 if (level == IRQ_LEVEL_HIGH)
296 giu_set(GIUINTALSELL, mask);
297 else
298 giu_clear(GIUINTALSELL, mask);
299 giu_write(GIUINTSTATL, mask);
300 } else if (pin < GIUINT_HIGH_MAX) {
301 mask = 1 << (pin - GIUINT_HIGH_OFFSET);
302 if (level == IRQ_LEVEL_HIGH)
303 giu_set(GIUINTALSELH, mask);
304 else
305 giu_clear(GIUINTALSELH, mask);
306 giu_write(GIUINTSTATH, mask);
307 }
308}
309EXPORT_SYMBOL_GPL(vr41xx_set_irq_level);
310
311gpio_data_t vr41xx_gpio_get_pin(unsigned int pin)
312{
313 uint16_t reg, mask;
314
315 if (pin >= giu_nr_pins)
316 return GPIO_DATA_INVAL;
317
318 if (pin < 16) {
319 reg = giu_read(GIUPIODL);
320 mask = (uint16_t)1 << pin;
321 } else if (pin < 32) {
322 reg = giu_read(GIUPIODH);
323 mask = (uint16_t)1 << (pin - 16);
324 } else if (pin < 48) {
325 reg = giu_read(GIUPODATL);
326 mask = (uint16_t)1 << (pin - 32);
327 } else {
328 reg = giu_read(GIUPODATH);
329 mask = (uint16_t)1 << (pin - 48);
330 }
331
332 if (reg & mask)
333 return GPIO_DATA_HIGH;
334
335 return GPIO_DATA_LOW;
336}
337EXPORT_SYMBOL_GPL(vr41xx_gpio_get_pin);
338
339int vr41xx_gpio_set_pin(unsigned int pin, gpio_data_t data)
340{
341 uint16_t offset, mask, reg;
342 unsigned long flags;
343
344 if (pin >= giu_nr_pins)
345 return -EINVAL;
346
347 if (pin < 16) {
348 offset = GIUPIODL;
349 mask = (uint16_t)1 << pin;
350 } else if (pin < 32) {
351 offset = GIUPIODH;
352 mask = (uint16_t)1 << (pin - 16);
353 } else if (pin < 48) {
354 offset = GIUPODATL;
355 mask = (uint16_t)1 << (pin - 32);
356 } else {
357 offset = GIUPODATH;
358 mask = (uint16_t)1 << (pin - 48);
359 }
360
361 spin_lock_irqsave(&giu_lock, flags);
362
363 reg = giu_read(offset);
364 if (data == GPIO_DATA_HIGH)
365 reg |= mask;
366 else
367 reg &= ~mask;
368 giu_write(offset, reg);
369
370 spin_unlock_irqrestore(&giu_lock, flags);
371
372 return 0;
373}
374EXPORT_SYMBOL_GPL(vr41xx_gpio_set_pin);
375
376int vr41xx_gpio_set_direction(unsigned int pin, gpio_direction_t dir)
377{
378 uint16_t offset, mask, reg;
379 unsigned long flags;
380
381 if (pin >= giu_nr_pins)
382 return -EINVAL;
383
384 if (pin < 16) {
385 offset = GIUIOSELL;
386 mask = (uint16_t)1 << pin;
387 } else if (pin < 32) {
388 offset = GIUIOSELH;
389 mask = (uint16_t)1 << (pin - 16);
390 } else {
391 if (giu_flags & GPIO_HAS_OUTPUT_ENABLE) {
392 offset = GIUPODATEN;
393 mask = (uint16_t)1 << (pin - 32);
394 } else {
395 switch (pin) {
396 case 48:
397 offset = GIUPODATH;
398 mask = PIOEN0;
399 break;
400 case 49:
401 offset = GIUPODATH;
402 mask = PIOEN1;
403 break;
404 default:
405 return -EINVAL;
406 }
407 }
408 }
409
410 spin_lock_irqsave(&giu_lock, flags);
411
412 reg = giu_read(offset);
413 if (dir == GPIO_OUTPUT)
414 reg |= mask;
415 else
416 reg &= ~mask;
417 giu_write(offset, reg);
418
419 spin_unlock_irqrestore(&giu_lock, flags);
420
421 return 0;
422}
423EXPORT_SYMBOL_GPL(vr41xx_gpio_set_direction);
424
425int vr41xx_gpio_pullupdown(unsigned int pin, gpio_pull_t pull)
426{
427 uint16_t reg, mask;
428 unsigned long flags;
429
430 if ((giu_flags & GPIO_HAS_PULLUPDOWN_IO) != GPIO_HAS_PULLUPDOWN_IO)
431 return -EPERM;
432
433 if (pin >= 15)
434 return -EINVAL;
435
436 mask = (uint16_t)1 << pin;
437
438 spin_lock_irqsave(&giu_lock, flags);
439
440 if (pull == GPIO_PULL_UP || pull == GPIO_PULL_DOWN) {
441 reg = giu_read(GIUTERMUPDN);
442 if (pull == GPIO_PULL_UP)
443 reg |= mask;
444 else
445 reg &= ~mask;
446 giu_write(GIUTERMUPDN, reg);
447
448 reg = giu_read(GIUUSEUPDN);
449 reg |= mask;
450 giu_write(GIUUSEUPDN, reg);
451 } else {
452 reg = giu_read(GIUUSEUPDN);
453 reg &= ~mask;
454 giu_write(GIUUSEUPDN, reg);
455 }
456
457 spin_unlock_irqrestore(&giu_lock, flags);
458
459 return 0;
460}
461EXPORT_SYMBOL_GPL(vr41xx_gpio_pullupdown);
462
463static ssize_t gpio_read(struct file *file, char __user *buf, size_t len,
464 loff_t *ppos)
465{
466 unsigned int pin;
467 char value = '0';
468
469 pin = iminor(file->f_path.dentry->d_inode);
470 if (pin >= giu_nr_pins)
471 return -EBADF;
472
473 if (vr41xx_gpio_get_pin(pin) == GPIO_DATA_HIGH)
474 value = '1';
475
476 if (len <= 0)
477 return -EFAULT;
478
479 if (put_user(value, buf))
480 return -EFAULT;
481
482 return 1;
483}
484
485static ssize_t gpio_write(struct file *file, const char __user *data,
486 size_t len, loff_t *ppos)
487{
488 unsigned int pin;
489 size_t i;
490 char c;
491 int retval = 0;
492
493 pin = iminor(file->f_path.dentry->d_inode);
494 if (pin >= giu_nr_pins)
495 return -EBADF;
496
497 for (i = 0; i < len; i++) {
498 if (get_user(c, data + i))
499 return -EFAULT;
500
501 switch (c) {
502 case '0':
503 retval = vr41xx_gpio_set_pin(pin, GPIO_DATA_LOW);
504 break;
505 case '1':
506 retval = vr41xx_gpio_set_pin(pin, GPIO_DATA_HIGH);
507 break;
508 case 'D':
509 printk(KERN_INFO "GPIO%d: pull down\n", pin);
510 retval = vr41xx_gpio_pullupdown(pin, GPIO_PULL_DOWN);
511 break;
512 case 'd':
513 printk(KERN_INFO "GPIO%d: pull up/down disable\n", pin);
514 retval = vr41xx_gpio_pullupdown(pin, GPIO_PULL_DISABLE);
515 break;
516 case 'I':
517 printk(KERN_INFO "GPIO%d: input\n", pin);
518 retval = vr41xx_gpio_set_direction(pin, GPIO_INPUT);
519 break;
520 case 'O':
521 printk(KERN_INFO "GPIO%d: output\n", pin);
522 retval = vr41xx_gpio_set_direction(pin, GPIO_OUTPUT);
523 break;
524 case 'o':
525 printk(KERN_INFO "GPIO%d: output disable\n", pin);
526 retval = vr41xx_gpio_set_direction(pin, GPIO_OUTPUT_DISABLE);
527 break;
528 case 'P':
529 printk(KERN_INFO "GPIO%d: pull up\n", pin);
530 retval = vr41xx_gpio_pullupdown(pin, GPIO_PULL_UP);
531 break;
532 case 'p':
533 printk(KERN_INFO "GPIO%d: pull up/down disable\n", pin);
534 retval = vr41xx_gpio_pullupdown(pin, GPIO_PULL_DISABLE);
535 break;
536 default:
537 break;
538 }
539
540 if (retval < 0)
541 break;
542 }
543
544 return i;
545}
546
547static int gpio_open(struct inode *inode, struct file *file)
548{
549 unsigned int pin;
550
551 cycle_kernel_lock();
552 pin = iminor(inode);
553 if (pin >= giu_nr_pins)
554 return -EBADF;
555
556 return nonseekable_open(inode, file);
557}
558
559static int gpio_release(struct inode *inode, struct file *file)
560{
561 unsigned int pin;
562
563 pin = iminor(inode);
564 if (pin >= giu_nr_pins)
565 return -EBADF;
566
567 return 0;
568}
569
570static const struct file_operations gpio_fops = {
571 .owner = THIS_MODULE,
572 .read = gpio_read,
573 .write = gpio_write,
574 .open = gpio_open,
575 .release = gpio_release,
576};
577
578static int __devinit giu_probe(struct platform_device *dev)
579{
580 struct resource *res;
581 unsigned int trigger, i, pin;
582 struct irq_chip *chip;
583 int irq, retval;
584
585 switch (dev->id) {
586 case GPIO_50PINS_PULLUPDOWN:
587 giu_flags = GPIO_HAS_PULLUPDOWN_IO;
588 giu_nr_pins = 50;
589 break;
590 case GPIO_36PINS:
591 giu_nr_pins = 36;
592 break;
593 case GPIO_48PINS_EDGE_SELECT:
594 giu_flags = GPIO_HAS_INTERRUPT_EDGE_SELECT;
595 giu_nr_pins = 48;
596 break;
597 default:
598 printk(KERN_ERR "GIU: unknown ID %d\n", dev->id);
599 return -ENODEV;
600 }
601
602 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
603 if (!res)
604 return -EBUSY;
605
606 giu_base = ioremap(res->start, res->end - res->start + 1);
607 if (!giu_base)
608 return -ENOMEM;
609
610 retval = register_chrdev(major, "GIU", &gpio_fops);
611 if (retval < 0) {
612 iounmap(giu_base);
613 giu_base = NULL;
614 return retval;
615 }
616
617 if (major == 0) {
618 major = retval;
619 printk(KERN_INFO "GIU: major number %d\n", major);
620 }
621
622 spin_lock_init(&giu_lock);
623
624 giu_write(GIUINTENL, 0);
625 giu_write(GIUINTENH, 0);
626
627 trigger = giu_read(GIUINTTYPH) << 16;
628 trigger |= giu_read(GIUINTTYPL);
629 for (i = GIU_IRQ_BASE; i <= GIU_IRQ_LAST; i++) {
630 pin = GPIO_PIN_OF_IRQ(i);
631 if (pin < GIUINT_HIGH_OFFSET)
632 chip = &giuint_low_irq_chip;
633 else
634 chip = &giuint_high_irq_chip;
635
636 if (trigger & (1 << pin))
637 set_irq_chip_and_handler(i, chip, handle_edge_irq);
638 else
639 set_irq_chip_and_handler(i, chip, handle_level_irq);
640
641 }
642
643 irq = platform_get_irq(dev, 0);
644 if (irq < 0 || irq >= nr_irqs)
645 return -EBUSY;
646
647 return cascade_irq(irq, giu_get_irq);
648}
649
650static int __devexit giu_remove(struct platform_device *dev)
651{
652 if (giu_base) {
653 iounmap(giu_base);
654 giu_base = NULL;
655 }
656
657 return 0;
658}
659
660static struct platform_driver giu_device_driver = {
661 .probe = giu_probe,
662 .remove = __devexit_p(giu_remove),
663 .driver = {
664 .name = "GIU",
665 .owner = THIS_MODULE,
666 },
667};
668
669static int __init vr41xx_giu_init(void)
670{
671 return platform_driver_register(&giu_device_driver);
672}
673
674static void __exit vr41xx_giu_exit(void)
675{
676 platform_driver_unregister(&giu_device_driver);
677}
678
679module_init(vr41xx_giu_init);
680module_exit(vr41xx_giu_exit);
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index d9113b4c76e3..7947bd1b4cf7 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -89,6 +89,7 @@
89#include <linux/mutex.h> 89#include <linux/mutex.h>
90#include <linux/vt_kern.h> 90#include <linux/vt_kern.h>
91#include <linux/selection.h> 91#include <linux/selection.h>
92#include <linux/smp_lock.h>
92#include <linux/tiocl.h> 93#include <linux/tiocl.h>
93#include <linux/kbd_kern.h> 94#include <linux/kbd_kern.h>
94#include <linux/consolemap.h> 95#include <linux/consolemap.h>
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 7539bed0f7e0..95189f288f8c 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -25,6 +25,7 @@
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/consolemap.h> 26#include <linux/consolemap.h>
27#include <linux/signal.h> 27#include <linux/signal.h>
28#include <linux/smp_lock.h>
28#include <linux/timex.h> 29#include <linux/timex.h>
29 30
30#include <asm/io.h> 31#include <asm/io.h>
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 9ffb05f4095d..93c2322feab7 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -161,7 +161,7 @@ static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta,
161 if (periodic) 161 if (periodic)
162 sh_tmu_write(p, TCOR, delta); 162 sh_tmu_write(p, TCOR, delta);
163 else 163 else
164 sh_tmu_write(p, TCOR, 0); 164 sh_tmu_write(p, TCOR, 0xffffffff);
165 165
166 sh_tmu_write(p, TCNT, delta); 166 sh_tmu_write(p, TCNT, delta);
167 167
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6e2ec0b18948..b90eda8b3440 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -761,6 +761,10 @@ static struct kobj_type ktype_cpufreq = {
761 * cpufreq_add_dev - add a CPU device 761 * cpufreq_add_dev - add a CPU device
762 * 762 *
763 * Adds the cpufreq interface for a CPU device. 763 * Adds the cpufreq interface for a CPU device.
764 *
765 * The Oracle says: try running cpufreq registration/unregistration concurrently
766 * with with cpu hotplugging and all hell will break loose. Tried to clean this
767 * mess up, but more thorough testing is needed. - Mathieu
764 */ 768 */
765static int cpufreq_add_dev(struct sys_device *sys_dev) 769static int cpufreq_add_dev(struct sys_device *sys_dev)
766{ 770{
@@ -772,9 +776,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
772 struct sys_device *cpu_sys_dev; 776 struct sys_device *cpu_sys_dev;
773 unsigned long flags; 777 unsigned long flags;
774 unsigned int j; 778 unsigned int j;
775#ifdef CONFIG_SMP
776 struct cpufreq_policy *managed_policy;
777#endif
778 779
779 if (cpu_is_offline(cpu)) 780 if (cpu_is_offline(cpu))
780 return 0; 781 return 0;
@@ -804,15 +805,12 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
804 goto nomem_out; 805 goto nomem_out;
805 } 806 }
806 if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) { 807 if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) {
807 kfree(policy);
808 ret = -ENOMEM; 808 ret = -ENOMEM;
809 goto nomem_out; 809 goto err_free_policy;
810 } 810 }
811 if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) { 811 if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) {
812 free_cpumask_var(policy->cpus);
813 kfree(policy);
814 ret = -ENOMEM; 812 ret = -ENOMEM;
815 goto nomem_out; 813 goto err_free_cpumask;
816 } 814 }
817 815
818 policy->cpu = cpu; 816 policy->cpu = cpu;
@@ -820,7 +818,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
820 818
821 /* Initially set CPU itself as the policy_cpu */ 819 /* Initially set CPU itself as the policy_cpu */
822 per_cpu(policy_cpu, cpu) = cpu; 820 per_cpu(policy_cpu, cpu) = cpu;
823 lock_policy_rwsem_write(cpu); 821 ret = (lock_policy_rwsem_write(cpu) < 0);
822 WARN_ON(ret);
824 823
825 init_completion(&policy->kobj_unregister); 824 init_completion(&policy->kobj_unregister);
826 INIT_WORK(&policy->update, handle_update); 825 INIT_WORK(&policy->update, handle_update);
@@ -833,7 +832,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
833 ret = cpufreq_driver->init(policy); 832 ret = cpufreq_driver->init(policy);
834 if (ret) { 833 if (ret) {
835 dprintk("initialization failed\n"); 834 dprintk("initialization failed\n");
836 goto err_out; 835 goto err_unlock_policy;
837 } 836 }
838 policy->user_policy.min = policy->min; 837 policy->user_policy.min = policy->min;
839 policy->user_policy.max = policy->max; 838 policy->user_policy.max = policy->max;
@@ -852,21 +851,29 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
852#endif 851#endif
853 852
854 for_each_cpu(j, policy->cpus) { 853 for_each_cpu(j, policy->cpus) {
854 struct cpufreq_policy *managed_policy;
855
855 if (cpu == j) 856 if (cpu == j)
856 continue; 857 continue;
857 858
858 /* Check for existing affected CPUs. 859 /* Check for existing affected CPUs.
859 * They may not be aware of it due to CPU Hotplug. 860 * They may not be aware of it due to CPU Hotplug.
860 */ 861 */
861 managed_policy = cpufreq_cpu_get(j); /* FIXME: Where is this released? What about error paths? */ 862 managed_policy = cpufreq_cpu_get(j);
862 if (unlikely(managed_policy)) { 863 if (unlikely(managed_policy)) {
863 864
864 /* Set proper policy_cpu */ 865 /* Set proper policy_cpu */
865 unlock_policy_rwsem_write(cpu); 866 unlock_policy_rwsem_write(cpu);
866 per_cpu(policy_cpu, cpu) = managed_policy->cpu; 867 per_cpu(policy_cpu, cpu) = managed_policy->cpu;
867 868
868 if (lock_policy_rwsem_write(cpu) < 0) 869 if (lock_policy_rwsem_write(cpu) < 0) {
869 goto err_out_driver_exit; 870 /* Should not go through policy unlock path */
871 if (cpufreq_driver->exit)
872 cpufreq_driver->exit(policy);
873 ret = -EBUSY;
874 cpufreq_cpu_put(managed_policy);
875 goto err_free_cpumask;
876 }
870 877
871 spin_lock_irqsave(&cpufreq_driver_lock, flags); 878 spin_lock_irqsave(&cpufreq_driver_lock, flags);
872 cpumask_copy(managed_policy->cpus, policy->cpus); 879 cpumask_copy(managed_policy->cpus, policy->cpus);
@@ -877,12 +884,14 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
877 ret = sysfs_create_link(&sys_dev->kobj, 884 ret = sysfs_create_link(&sys_dev->kobj,
878 &managed_policy->kobj, 885 &managed_policy->kobj,
879 "cpufreq"); 886 "cpufreq");
880 if (ret) 887 if (!ret)
881 goto err_out_driver_exit; 888 cpufreq_cpu_put(managed_policy);
882 889 /*
883 cpufreq_debug_enable_ratelimit(); 890 * Success. We only needed to be added to the mask.
884 ret = 0; 891 * Call driver->exit() because only the cpu parent of
885 goto err_out_driver_exit; /* call driver->exit() */ 892 * the kobj needed to call init().
893 */
894 goto out_driver_exit; /* call driver->exit() */
886 } 895 }
887 } 896 }
888#endif 897#endif
@@ -892,25 +901,25 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
892 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj, 901 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj,
893 "cpufreq"); 902 "cpufreq");
894 if (ret) 903 if (ret)
895 goto err_out_driver_exit; 904 goto out_driver_exit;
896 905
897 /* set up files for this cpu device */ 906 /* set up files for this cpu device */
898 drv_attr = cpufreq_driver->attr; 907 drv_attr = cpufreq_driver->attr;
899 while ((drv_attr) && (*drv_attr)) { 908 while ((drv_attr) && (*drv_attr)) {
900 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); 909 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
901 if (ret) 910 if (ret)
902 goto err_out_driver_exit; 911 goto err_out_kobj_put;
903 drv_attr++; 912 drv_attr++;
904 } 913 }
905 if (cpufreq_driver->get) { 914 if (cpufreq_driver->get) {
906 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); 915 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr);
907 if (ret) 916 if (ret)
908 goto err_out_driver_exit; 917 goto err_out_kobj_put;
909 } 918 }
910 if (cpufreq_driver->target) { 919 if (cpufreq_driver->target) {
911 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); 920 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr);
912 if (ret) 921 if (ret)
913 goto err_out_driver_exit; 922 goto err_out_kobj_put;
914 } 923 }
915 924
916 spin_lock_irqsave(&cpufreq_driver_lock, flags); 925 spin_lock_irqsave(&cpufreq_driver_lock, flags);
@@ -922,18 +931,22 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
922 931
923 /* symlink affected CPUs */ 932 /* symlink affected CPUs */
924 for_each_cpu(j, policy->cpus) { 933 for_each_cpu(j, policy->cpus) {
934 struct cpufreq_policy *managed_policy;
935
925 if (j == cpu) 936 if (j == cpu)
926 continue; 937 continue;
927 if (!cpu_online(j)) 938 if (!cpu_online(j))
928 continue; 939 continue;
929 940
930 dprintk("CPU %u already managed, adding link\n", j); 941 dprintk("CPU %u already managed, adding link\n", j);
931 cpufreq_cpu_get(cpu); 942 managed_policy = cpufreq_cpu_get(cpu);
932 cpu_sys_dev = get_cpu_sysdev(j); 943 cpu_sys_dev = get_cpu_sysdev(j);
933 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, 944 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
934 "cpufreq"); 945 "cpufreq");
935 if (ret) 946 if (ret) {
947 cpufreq_cpu_put(managed_policy);
936 goto err_out_unregister; 948 goto err_out_unregister;
949 }
937 } 950 }
938 951
939 policy->governor = NULL; /* to assure that the starting sequence is 952 policy->governor = NULL; /* to assure that the starting sequence is
@@ -965,17 +978,20 @@ err_out_unregister:
965 per_cpu(cpufreq_cpu_data, j) = NULL; 978 per_cpu(cpufreq_cpu_data, j) = NULL;
966 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 979 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
967 980
981err_out_kobj_put:
968 kobject_put(&policy->kobj); 982 kobject_put(&policy->kobj);
969 wait_for_completion(&policy->kobj_unregister); 983 wait_for_completion(&policy->kobj_unregister);
970 984
971err_out_driver_exit: 985out_driver_exit:
972 if (cpufreq_driver->exit) 986 if (cpufreq_driver->exit)
973 cpufreq_driver->exit(policy); 987 cpufreq_driver->exit(policy);
974 988
975err_out: 989err_unlock_policy:
976 unlock_policy_rwsem_write(cpu); 990 unlock_policy_rwsem_write(cpu);
991err_free_cpumask:
992 free_cpumask_var(policy->cpus);
993err_free_policy:
977 kfree(policy); 994 kfree(policy);
978
979nomem_out: 995nomem_out:
980 module_put(cpufreq_driver->owner); 996 module_put(cpufreq_driver->owner);
981module_out: 997module_out:
@@ -1070,8 +1086,6 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1070 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1086 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1071#endif 1087#endif
1072 1088
1073 unlock_policy_rwsem_write(cpu);
1074
1075 if (cpufreq_driver->target) 1089 if (cpufreq_driver->target)
1076 __cpufreq_governor(data, CPUFREQ_GOV_STOP); 1090 __cpufreq_governor(data, CPUFREQ_GOV_STOP);
1077 1091
@@ -1088,6 +1102,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1088 if (cpufreq_driver->exit) 1102 if (cpufreq_driver->exit)
1089 cpufreq_driver->exit(data); 1103 cpufreq_driver->exit(data);
1090 1104
1105 unlock_policy_rwsem_write(cpu);
1106
1091 free_cpumask_var(data->related_cpus); 1107 free_cpumask_var(data->related_cpus);
1092 free_cpumask_var(data->cpus); 1108 free_cpumask_var(data->cpus);
1093 kfree(data); 1109 kfree(data);
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 7fc58af748b4..57490502b21c 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -63,22 +63,20 @@ struct cpu_dbs_info_s {
63 unsigned int down_skip; 63 unsigned int down_skip;
64 unsigned int requested_freq; 64 unsigned int requested_freq;
65 int cpu; 65 int cpu;
66 unsigned int enable:1; 66 /*
67 * percpu mutex that serializes governor limit change with
68 * do_dbs_timer invocation. We do not want do_dbs_timer to run
69 * when user is changing the governor or limits.
70 */
71 struct mutex timer_mutex;
67}; 72};
68static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); 73static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
69 74
70static unsigned int dbs_enable; /* number of CPUs using this policy */ 75static unsigned int dbs_enable; /* number of CPUs using this policy */
71 76
72/* 77/*
73 * DEADLOCK ALERT! There is a ordering requirement between cpu_hotplug 78 * dbs_mutex protects data in dbs_tuners_ins from concurrent changes on
74 * lock and dbs_mutex. cpu_hotplug lock should always be held before 79 * different CPUs. It protects dbs_enable in governor start/stop.
75 * dbs_mutex. If any function that can potentially take cpu_hotplug lock
76 * (like __cpufreq_driver_target()) is being called with dbs_mutex taken, then
77 * cpu_hotplug lock should be taken before that. Note that cpu_hotplug lock
78 * is recursive for the same process. -Venki
79 * DEADLOCK ALERT! (2) : do_dbs_timer() must not take the dbs_mutex, because it
80 * would deadlock with cancel_delayed_work_sync(), which is needed for proper
81 * raceless workqueue teardown.
82 */ 80 */
83static DEFINE_MUTEX(dbs_mutex); 81static DEFINE_MUTEX(dbs_mutex);
84 82
@@ -143,9 +141,6 @@ dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
143 141
144 struct cpufreq_policy *policy; 142 struct cpufreq_policy *policy;
145 143
146 if (!this_dbs_info->enable)
147 return 0;
148
149 policy = this_dbs_info->cur_policy; 144 policy = this_dbs_info->cur_policy;
150 145
151 /* 146 /*
@@ -488,18 +483,12 @@ static void do_dbs_timer(struct work_struct *work)
488 483
489 delay -= jiffies % delay; 484 delay -= jiffies % delay;
490 485
491 if (lock_policy_rwsem_write(cpu) < 0) 486 mutex_lock(&dbs_info->timer_mutex);
492 return;
493
494 if (!dbs_info->enable) {
495 unlock_policy_rwsem_write(cpu);
496 return;
497 }
498 487
499 dbs_check_cpu(dbs_info); 488 dbs_check_cpu(dbs_info);
500 489
501 queue_delayed_work_on(cpu, kconservative_wq, &dbs_info->work, delay); 490 queue_delayed_work_on(cpu, kconservative_wq, &dbs_info->work, delay);
502 unlock_policy_rwsem_write(cpu); 491 mutex_unlock(&dbs_info->timer_mutex);
503} 492}
504 493
505static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info) 494static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
@@ -508,7 +497,6 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
508 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 497 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
509 delay -= jiffies % delay; 498 delay -= jiffies % delay;
510 499
511 dbs_info->enable = 1;
512 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer); 500 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
513 queue_delayed_work_on(dbs_info->cpu, kconservative_wq, &dbs_info->work, 501 queue_delayed_work_on(dbs_info->cpu, kconservative_wq, &dbs_info->work,
514 delay); 502 delay);
@@ -516,7 +504,6 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
516 504
517static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) 505static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
518{ 506{
519 dbs_info->enable = 0;
520 cancel_delayed_work_sync(&dbs_info->work); 507 cancel_delayed_work_sync(&dbs_info->work);
521} 508}
522 509
@@ -535,9 +522,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
535 if ((!cpu_online(cpu)) || (!policy->cur)) 522 if ((!cpu_online(cpu)) || (!policy->cur))
536 return -EINVAL; 523 return -EINVAL;
537 524
538 if (this_dbs_info->enable) /* Already enabled */
539 break;
540
541 mutex_lock(&dbs_mutex); 525 mutex_lock(&dbs_mutex);
542 526
543 rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); 527 rc = sysfs_create_group(&policy->kobj, &dbs_attr_group);
@@ -561,6 +545,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
561 this_dbs_info->down_skip = 0; 545 this_dbs_info->down_skip = 0;
562 this_dbs_info->requested_freq = policy->cur; 546 this_dbs_info->requested_freq = policy->cur;
563 547
548 mutex_init(&this_dbs_info->timer_mutex);
564 dbs_enable++; 549 dbs_enable++;
565 /* 550 /*
566 * Start the timerschedule work, when this governor 551 * Start the timerschedule work, when this governor
@@ -590,17 +575,19 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
590 &dbs_cpufreq_notifier_block, 575 &dbs_cpufreq_notifier_block,
591 CPUFREQ_TRANSITION_NOTIFIER); 576 CPUFREQ_TRANSITION_NOTIFIER);
592 } 577 }
593 dbs_timer_init(this_dbs_info);
594
595 mutex_unlock(&dbs_mutex); 578 mutex_unlock(&dbs_mutex);
596 579
580 dbs_timer_init(this_dbs_info);
581
597 break; 582 break;
598 583
599 case CPUFREQ_GOV_STOP: 584 case CPUFREQ_GOV_STOP:
600 mutex_lock(&dbs_mutex);
601 dbs_timer_exit(this_dbs_info); 585 dbs_timer_exit(this_dbs_info);
586
587 mutex_lock(&dbs_mutex);
602 sysfs_remove_group(&policy->kobj, &dbs_attr_group); 588 sysfs_remove_group(&policy->kobj, &dbs_attr_group);
603 dbs_enable--; 589 dbs_enable--;
590 mutex_destroy(&this_dbs_info->timer_mutex);
604 591
605 /* 592 /*
606 * Stop the timerschedule work, when this governor 593 * Stop the timerschedule work, when this governor
@@ -616,7 +603,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
616 break; 603 break;
617 604
618 case CPUFREQ_GOV_LIMITS: 605 case CPUFREQ_GOV_LIMITS:
619 mutex_lock(&dbs_mutex); 606 mutex_lock(&this_dbs_info->timer_mutex);
620 if (policy->max < this_dbs_info->cur_policy->cur) 607 if (policy->max < this_dbs_info->cur_policy->cur)
621 __cpufreq_driver_target( 608 __cpufreq_driver_target(
622 this_dbs_info->cur_policy, 609 this_dbs_info->cur_policy,
@@ -625,7 +612,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
625 __cpufreq_driver_target( 612 __cpufreq_driver_target(
626 this_dbs_info->cur_policy, 613 this_dbs_info->cur_policy,
627 policy->min, CPUFREQ_RELATION_L); 614 policy->min, CPUFREQ_RELATION_L);
628 mutex_unlock(&dbs_mutex); 615 mutex_unlock(&this_dbs_info->timer_mutex);
629 616
630 break; 617 break;
631 } 618 }
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 1911d1729353..d6ba14276bb1 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -70,23 +70,21 @@ struct cpu_dbs_info_s {
70 unsigned int freq_lo_jiffies; 70 unsigned int freq_lo_jiffies;
71 unsigned int freq_hi_jiffies; 71 unsigned int freq_hi_jiffies;
72 int cpu; 72 int cpu;
73 unsigned int enable:1, 73 unsigned int sample_type:1;
74 sample_type:1; 74 /*
75 * percpu mutex that serializes governor limit change with
76 * do_dbs_timer invocation. We do not want do_dbs_timer to run
77 * when user is changing the governor or limits.
78 */
79 struct mutex timer_mutex;
75}; 80};
76static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); 81static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
77 82
78static unsigned int dbs_enable; /* number of CPUs using this policy */ 83static unsigned int dbs_enable; /* number of CPUs using this policy */
79 84
80/* 85/*
81 * DEADLOCK ALERT! There is a ordering requirement between cpu_hotplug 86 * dbs_mutex protects data in dbs_tuners_ins from concurrent changes on
82 * lock and dbs_mutex. cpu_hotplug lock should always be held before 87 * different CPUs. It protects dbs_enable in governor start/stop.
83 * dbs_mutex. If any function that can potentially take cpu_hotplug lock
84 * (like __cpufreq_driver_target()) is being called with dbs_mutex taken, then
85 * cpu_hotplug lock should be taken before that. Note that cpu_hotplug lock
86 * is recursive for the same process. -Venki
87 * DEADLOCK ALERT! (2) : do_dbs_timer() must not take the dbs_mutex, because it
88 * would deadlock with cancel_delayed_work_sync(), which is needed for proper
89 * raceless workqueue teardown.
90 */ 88 */
91static DEFINE_MUTEX(dbs_mutex); 89static DEFINE_MUTEX(dbs_mutex);
92 90
@@ -192,13 +190,18 @@ static unsigned int powersave_bias_target(struct cpufreq_policy *policy,
192 return freq_hi; 190 return freq_hi;
193} 191}
194 192
193static void ondemand_powersave_bias_init_cpu(int cpu)
194{
195 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu);
196 dbs_info->freq_table = cpufreq_frequency_get_table(cpu);
197 dbs_info->freq_lo = 0;
198}
199
195static void ondemand_powersave_bias_init(void) 200static void ondemand_powersave_bias_init(void)
196{ 201{
197 int i; 202 int i;
198 for_each_online_cpu(i) { 203 for_each_online_cpu(i) {
199 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, i); 204 ondemand_powersave_bias_init_cpu(i);
200 dbs_info->freq_table = cpufreq_frequency_get_table(i);
201 dbs_info->freq_lo = 0;
202 } 205 }
203} 206}
204 207
@@ -240,12 +243,10 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
240 unsigned int input; 243 unsigned int input;
241 int ret; 244 int ret;
242 ret = sscanf(buf, "%u", &input); 245 ret = sscanf(buf, "%u", &input);
246 if (ret != 1)
247 return -EINVAL;
243 248
244 mutex_lock(&dbs_mutex); 249 mutex_lock(&dbs_mutex);
245 if (ret != 1) {
246 mutex_unlock(&dbs_mutex);
247 return -EINVAL;
248 }
249 dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate); 250 dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate);
250 mutex_unlock(&dbs_mutex); 251 mutex_unlock(&dbs_mutex);
251 252
@@ -259,13 +260,12 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
259 int ret; 260 int ret;
260 ret = sscanf(buf, "%u", &input); 261 ret = sscanf(buf, "%u", &input);
261 262
262 mutex_lock(&dbs_mutex);
263 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || 263 if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD ||
264 input < MIN_FREQUENCY_UP_THRESHOLD) { 264 input < MIN_FREQUENCY_UP_THRESHOLD) {
265 mutex_unlock(&dbs_mutex);
266 return -EINVAL; 265 return -EINVAL;
267 } 266 }
268 267
268 mutex_lock(&dbs_mutex);
269 dbs_tuners_ins.up_threshold = input; 269 dbs_tuners_ins.up_threshold = input;
270 mutex_unlock(&dbs_mutex); 270 mutex_unlock(&dbs_mutex);
271 271
@@ -363,9 +363,6 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
363 struct cpufreq_policy *policy; 363 struct cpufreq_policy *policy;
364 unsigned int j; 364 unsigned int j;
365 365
366 if (!this_dbs_info->enable)
367 return;
368
369 this_dbs_info->freq_lo = 0; 366 this_dbs_info->freq_lo = 0;
370 policy = this_dbs_info->cur_policy; 367 policy = this_dbs_info->cur_policy;
371 368
@@ -493,14 +490,7 @@ static void do_dbs_timer(struct work_struct *work)
493 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 490 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
494 491
495 delay -= jiffies % delay; 492 delay -= jiffies % delay;
496 493 mutex_lock(&dbs_info->timer_mutex);
497 if (lock_policy_rwsem_write(cpu) < 0)
498 return;
499
500 if (!dbs_info->enable) {
501 unlock_policy_rwsem_write(cpu);
502 return;
503 }
504 494
505 /* Common NORMAL_SAMPLE setup */ 495 /* Common NORMAL_SAMPLE setup */
506 dbs_info->sample_type = DBS_NORMAL_SAMPLE; 496 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
@@ -517,7 +507,7 @@ static void do_dbs_timer(struct work_struct *work)
517 dbs_info->freq_lo, CPUFREQ_RELATION_H); 507 dbs_info->freq_lo, CPUFREQ_RELATION_H);
518 } 508 }
519 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); 509 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay);
520 unlock_policy_rwsem_write(cpu); 510 mutex_unlock(&dbs_info->timer_mutex);
521} 511}
522 512
523static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info) 513static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
@@ -526,8 +516,6 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
526 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 516 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
527 delay -= jiffies % delay; 517 delay -= jiffies % delay;
528 518
529 dbs_info->enable = 1;
530 ondemand_powersave_bias_init();
531 dbs_info->sample_type = DBS_NORMAL_SAMPLE; 519 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
532 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer); 520 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
533 queue_delayed_work_on(dbs_info->cpu, kondemand_wq, &dbs_info->work, 521 queue_delayed_work_on(dbs_info->cpu, kondemand_wq, &dbs_info->work,
@@ -536,7 +524,6 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
536 524
537static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) 525static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
538{ 526{
539 dbs_info->enable = 0;
540 cancel_delayed_work_sync(&dbs_info->work); 527 cancel_delayed_work_sync(&dbs_info->work);
541} 528}
542 529
@@ -555,19 +542,15 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
555 if ((!cpu_online(cpu)) || (!policy->cur)) 542 if ((!cpu_online(cpu)) || (!policy->cur))
556 return -EINVAL; 543 return -EINVAL;
557 544
558 if (this_dbs_info->enable) /* Already enabled */
559 break;
560
561 mutex_lock(&dbs_mutex); 545 mutex_lock(&dbs_mutex);
562 dbs_enable++;
563 546
564 rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); 547 rc = sysfs_create_group(&policy->kobj, &dbs_attr_group);
565 if (rc) { 548 if (rc) {
566 dbs_enable--;
567 mutex_unlock(&dbs_mutex); 549 mutex_unlock(&dbs_mutex);
568 return rc; 550 return rc;
569 } 551 }
570 552
553 dbs_enable++;
571 for_each_cpu(j, policy->cpus) { 554 for_each_cpu(j, policy->cpus) {
572 struct cpu_dbs_info_s *j_dbs_info; 555 struct cpu_dbs_info_s *j_dbs_info;
573 j_dbs_info = &per_cpu(cpu_dbs_info, j); 556 j_dbs_info = &per_cpu(cpu_dbs_info, j);
@@ -581,6 +564,8 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
581 } 564 }
582 } 565 }
583 this_dbs_info->cpu = cpu; 566 this_dbs_info->cpu = cpu;
567 ondemand_powersave_bias_init_cpu(cpu);
568 mutex_init(&this_dbs_info->timer_mutex);
584 /* 569 /*
585 * Start the timerschedule work, when this governor 570 * Start the timerschedule work, when this governor
586 * is used for first time 571 * is used for first time
@@ -598,29 +583,31 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
598 max(min_sampling_rate, 583 max(min_sampling_rate,
599 latency * LATENCY_MULTIPLIER); 584 latency * LATENCY_MULTIPLIER);
600 } 585 }
601 dbs_timer_init(this_dbs_info);
602
603 mutex_unlock(&dbs_mutex); 586 mutex_unlock(&dbs_mutex);
587
588 dbs_timer_init(this_dbs_info);
604 break; 589 break;
605 590
606 case CPUFREQ_GOV_STOP: 591 case CPUFREQ_GOV_STOP:
607 mutex_lock(&dbs_mutex);
608 dbs_timer_exit(this_dbs_info); 592 dbs_timer_exit(this_dbs_info);
593
594 mutex_lock(&dbs_mutex);
609 sysfs_remove_group(&policy->kobj, &dbs_attr_group); 595 sysfs_remove_group(&policy->kobj, &dbs_attr_group);
596 mutex_destroy(&this_dbs_info->timer_mutex);
610 dbs_enable--; 597 dbs_enable--;
611 mutex_unlock(&dbs_mutex); 598 mutex_unlock(&dbs_mutex);
612 599
613 break; 600 break;
614 601
615 case CPUFREQ_GOV_LIMITS: 602 case CPUFREQ_GOV_LIMITS:
616 mutex_lock(&dbs_mutex); 603 mutex_lock(&this_dbs_info->timer_mutex);
617 if (policy->max < this_dbs_info->cur_policy->cur) 604 if (policy->max < this_dbs_info->cur_policy->cur)
618 __cpufreq_driver_target(this_dbs_info->cur_policy, 605 __cpufreq_driver_target(this_dbs_info->cur_policy,
619 policy->max, CPUFREQ_RELATION_H); 606 policy->max, CPUFREQ_RELATION_H);
620 else if (policy->min > this_dbs_info->cur_policy->cur) 607 else if (policy->min > this_dbs_info->cur_policy->cur)
621 __cpufreq_driver_target(this_dbs_info->cur_policy, 608 __cpufreq_driver_target(this_dbs_info->cur_policy,
622 policy->min, CPUFREQ_RELATION_L); 609 policy->min, CPUFREQ_RELATION_L);
623 mutex_unlock(&dbs_mutex); 610 mutex_unlock(&this_dbs_info->timer_mutex);
624 break; 611 break;
625 } 612 }
626 return 0; 613 return 0;
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index c36bf40568cf..858fe6037223 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -754,13 +754,13 @@ static void amd64_cpu_display_info(struct amd64_pvt *pvt)
754static enum edac_type amd64_determine_edac_cap(struct amd64_pvt *pvt) 754static enum edac_type amd64_determine_edac_cap(struct amd64_pvt *pvt)
755{ 755{
756 int bit; 756 int bit;
757 enum dev_type edac_cap = EDAC_NONE; 757 enum dev_type edac_cap = EDAC_FLAG_NONE;
758 758
759 bit = (boot_cpu_data.x86 > 0xf || pvt->ext_model >= OPTERON_CPU_REV_F) 759 bit = (boot_cpu_data.x86 > 0xf || pvt->ext_model >= OPTERON_CPU_REV_F)
760 ? 19 760 ? 19
761 : 17; 761 : 17;
762 762
763 if (pvt->dclr0 >> BIT(bit)) 763 if (pvt->dclr0 & BIT(bit))
764 edac_cap = EDAC_FLAG_SECDED; 764 edac_cap = EDAC_FLAG_SECDED;
765 765
766 return edac_cap; 766 return edac_cap;
@@ -1269,7 +1269,7 @@ static int f10_early_channel_count(struct amd64_pvt *pvt)
1269 if (channels == 0) 1269 if (channels == 0)
1270 channels = 1; 1270 channels = 1;
1271 1271
1272 debugf0("DIMM count= %d\n", channels); 1272 debugf0("MCT channel count: %d\n", channels);
1273 1273
1274 return channels; 1274 return channels;
1275 1275
@@ -2966,7 +2966,12 @@ static int amd64_check_ecc_enabled(struct amd64_pvt *pvt)
2966 " Use of the override can cause " 2966 " Use of the override can cause "
2967 "unknown side effects.\n"); 2967 "unknown side effects.\n");
2968 ret = -ENODEV; 2968 ret = -ENODEV;
2969 } 2969 } else
2970 /*
2971 * enable further driver loading if ECC enable is
2972 * overridden.
2973 */
2974 ret = 0;
2970 } else { 2975 } else {
2971 amd64_printk(KERN_INFO, 2976 amd64_printk(KERN_INFO,
2972 "ECC is enabled by BIOS, Proceeding " 2977 "ECC is enabled by BIOS, Proceeding "
@@ -3006,7 +3011,6 @@ static void amd64_setup_mci_misc_attributes(struct mem_ctl_info *mci)
3006 3011
3007 mci->mtype_cap = MEM_FLAG_DDR2 | MEM_FLAG_RDDR2; 3012 mci->mtype_cap = MEM_FLAG_DDR2 | MEM_FLAG_RDDR2;
3008 mci->edac_ctl_cap = EDAC_FLAG_NONE; 3013 mci->edac_ctl_cap = EDAC_FLAG_NONE;
3009 mci->edac_cap = EDAC_FLAG_NONE;
3010 3014
3011 if (pvt->nbcap & K8_NBCAP_SECDED) 3015 if (pvt->nbcap & K8_NBCAP_SECDED)
3012 mci->edac_ctl_cap |= EDAC_FLAG_SECDED; 3016 mci->edac_ctl_cap |= EDAC_FLAG_SECDED;
@@ -3052,7 +3056,7 @@ static int amd64_probe_one_instance(struct pci_dev *dram_f2_ctl,
3052 if (!pvt) 3056 if (!pvt)
3053 goto err_exit; 3057 goto err_exit;
3054 3058
3055 pvt->mc_node_id = get_mc_node_id_from_pdev(dram_f2_ctl); 3059 pvt->mc_node_id = get_node_id(dram_f2_ctl);
3056 3060
3057 pvt->dram_f2_ctl = dram_f2_ctl; 3061 pvt->dram_f2_ctl = dram_f2_ctl;
3058 pvt->ext_model = boot_cpu_data.x86_model >> 4; 3062 pvt->ext_model = boot_cpu_data.x86_model >> 4;
@@ -3179,8 +3183,7 @@ static int __devinit amd64_init_one_instance(struct pci_dev *pdev,
3179{ 3183{
3180 int ret = 0; 3184 int ret = 0;
3181 3185
3182 debugf0("(MC node=%d,mc_type='%s')\n", 3186 debugf0("(MC node=%d,mc_type='%s')\n", get_node_id(pdev),
3183 get_mc_node_id_from_pdev(pdev),
3184 get_amd_family_name(mc_type->driver_data)); 3187 get_amd_family_name(mc_type->driver_data));
3185 3188
3186 ret = pci_enable_device(pdev); 3189 ret = pci_enable_device(pdev);
@@ -3319,15 +3322,17 @@ static int __init amd64_edac_init(void)
3319 3322
3320 err = amd64_init_2nd_stage(pvt_lookup[nb]); 3323 err = amd64_init_2nd_stage(pvt_lookup[nb]);
3321 if (err) 3324 if (err)
3322 goto err_exit; 3325 goto err_2nd_stage;
3323 } 3326 }
3324 3327
3325 amd64_setup_pci_device(); 3328 amd64_setup_pci_device();
3326 3329
3327 return 0; 3330 return 0;
3328 3331
3332err_2nd_stage:
3333 debugf0("2nd stage failed\n");
3334
3329err_exit: 3335err_exit:
3330 debugf0("'finish_setup' stage failed\n");
3331 pci_unregister_driver(&amd64_pci_driver); 3336 pci_unregister_driver(&amd64_pci_driver);
3332 3337
3333 return err; 3338 return err;
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index a159957e167b..ba73015af8e4 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -444,7 +444,7 @@ enum {
444#define K8_MSR_MC4ADDR 0x0412 444#define K8_MSR_MC4ADDR 0x0412
445 445
446/* AMD sets the first MC device at device ID 0x18. */ 446/* AMD sets the first MC device at device ID 0x18. */
447static inline int get_mc_node_id_from_pdev(struct pci_dev *pdev) 447static inline int get_node_id(struct pci_dev *pdev)
448{ 448{
449 return PCI_SLOT(pdev->devfn) - 0x18; 449 return PCI_SLOT(pdev->devfn) - 0x18;
450} 450}
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index 3493c6bdb820..871c13b4c148 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -150,6 +150,8 @@ enum mem_type {
150 MEM_FB_DDR2, /* fully buffered DDR2 */ 150 MEM_FB_DDR2, /* fully buffered DDR2 */
151 MEM_RDDR2, /* Registered DDR2 RAM */ 151 MEM_RDDR2, /* Registered DDR2 RAM */
152 MEM_XDR, /* Rambus XDR */ 152 MEM_XDR, /* Rambus XDR */
153 MEM_DDR3, /* DDR3 RAM */
154 MEM_RDDR3, /* Registered DDR3 RAM */
153}; 155};
154 156
155#define MEM_FLAG_EMPTY BIT(MEM_EMPTY) 157#define MEM_FLAG_EMPTY BIT(MEM_EMPTY)
@@ -167,6 +169,8 @@ enum mem_type {
167#define MEM_FLAG_FB_DDR2 BIT(MEM_FB_DDR2) 169#define MEM_FLAG_FB_DDR2 BIT(MEM_FB_DDR2)
168#define MEM_FLAG_RDDR2 BIT(MEM_RDDR2) 170#define MEM_FLAG_RDDR2 BIT(MEM_RDDR2)
169#define MEM_FLAG_XDR BIT(MEM_XDR) 171#define MEM_FLAG_XDR BIT(MEM_XDR)
172#define MEM_FLAG_DDR3 BIT(MEM_DDR3)
173#define MEM_FLAG_RDDR3 BIT(MEM_RDDR3)
170 174
171/* chipset Error Detection and Correction capabilities and mode */ 175/* chipset Error Detection and Correction capabilities and mode */
172enum edac_type { 176enum edac_type {
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index ad218fe4942d..e1d4ce083481 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -94,7 +94,9 @@ static const char *mem_types[] = {
94 [MEM_DDR2] = "Unbuffered-DDR2", 94 [MEM_DDR2] = "Unbuffered-DDR2",
95 [MEM_FB_DDR2] = "FullyBuffered-DDR2", 95 [MEM_FB_DDR2] = "FullyBuffered-DDR2",
96 [MEM_RDDR2] = "Registered-DDR2", 96 [MEM_RDDR2] = "Registered-DDR2",
97 [MEM_XDR] = "XDR" 97 [MEM_XDR] = "XDR",
98 [MEM_DDR3] = "Unbuffered-DDR3",
99 [MEM_RDDR3] = "Registered-DDR3"
98}; 100};
99 101
100static const char *dev_types[] = { 102static const char *dev_types[] = {
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 7c8c2d72916f..3f2ccfc6407c 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -757,6 +757,9 @@ static void __devinit mpc85xx_init_csrows(struct mem_ctl_info *mci)
757 case DSC_SDTYPE_DDR2: 757 case DSC_SDTYPE_DDR2:
758 mtype = MEM_RDDR2; 758 mtype = MEM_RDDR2;
759 break; 759 break;
760 case DSC_SDTYPE_DDR3:
761 mtype = MEM_RDDR3;
762 break;
760 default: 763 default:
761 mtype = MEM_UNKNOWN; 764 mtype = MEM_UNKNOWN;
762 break; 765 break;
@@ -769,6 +772,9 @@ static void __devinit mpc85xx_init_csrows(struct mem_ctl_info *mci)
769 case DSC_SDTYPE_DDR2: 772 case DSC_SDTYPE_DDR2:
770 mtype = MEM_DDR2; 773 mtype = MEM_DDR2;
771 break; 774 break;
775 case DSC_SDTYPE_DDR3:
776 mtype = MEM_DDR3;
777 break;
772 default: 778 default:
773 mtype = MEM_UNKNOWN; 779 mtype = MEM_UNKNOWN;
774 break; 780 break;
diff --git a/drivers/edac/mpc85xx_edac.h b/drivers/edac/mpc85xx_edac.h
index 135b3539a030..52432ee7c4b9 100644
--- a/drivers/edac/mpc85xx_edac.h
+++ b/drivers/edac/mpc85xx_edac.h
@@ -53,6 +53,7 @@
53 53
54#define DSC_SDTYPE_DDR 0x02000000 54#define DSC_SDTYPE_DDR 0x02000000
55#define DSC_SDTYPE_DDR2 0x03000000 55#define DSC_SDTYPE_DDR2 0x03000000
56#define DSC_SDTYPE_DDR3 0x07000000
56#define DSC_X32_EN 0x00000020 57#define DSC_X32_EN 0x00000020
57 58
58/* Err_Int_En */ 59/* Err_Int_En */
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
index 543fccac81bb..f74edae5cb4c 100644
--- a/drivers/firewire/core-card.c
+++ b/drivers/firewire/core-card.c
@@ -196,8 +196,8 @@ static void allocate_broadcast_channel(struct fw_card *card, int generation)
196{ 196{
197 int channel, bandwidth = 0; 197 int channel, bandwidth = 0;
198 198
199 fw_iso_resource_manage(card, generation, 1ULL << 31, 199 fw_iso_resource_manage(card, generation, 1ULL << 31, &channel,
200 &channel, &bandwidth, true); 200 &bandwidth, true, card->bm_transaction_data);
201 if (channel == 31) { 201 if (channel == 31) {
202 card->broadcast_channel_allocated = true; 202 card->broadcast_channel_allocated = true;
203 device_for_each_child(card->device, (void *)(long)generation, 203 device_for_each_child(card->device, (void *)(long)generation,
@@ -230,7 +230,6 @@ static void fw_card_bm_work(struct work_struct *work)
230 bool do_reset = false; 230 bool do_reset = false;
231 bool root_device_is_running; 231 bool root_device_is_running;
232 bool root_device_is_cmc; 232 bool root_device_is_cmc;
233 __be32 lock_data[2];
234 233
235 spin_lock_irqsave(&card->lock, flags); 234 spin_lock_irqsave(&card->lock, flags);
236 235
@@ -273,22 +272,23 @@ static void fw_card_bm_work(struct work_struct *work)
273 goto pick_me; 272 goto pick_me;
274 } 273 }
275 274
276 lock_data[0] = cpu_to_be32(0x3f); 275 card->bm_transaction_data[0] = cpu_to_be32(0x3f);
277 lock_data[1] = cpu_to_be32(local_id); 276 card->bm_transaction_data[1] = cpu_to_be32(local_id);
278 277
279 spin_unlock_irqrestore(&card->lock, flags); 278 spin_unlock_irqrestore(&card->lock, flags);
280 279
281 rcode = fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, 280 rcode = fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP,
282 irm_id, generation, SCODE_100, 281 irm_id, generation, SCODE_100,
283 CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, 282 CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID,
284 lock_data, sizeof(lock_data)); 283 card->bm_transaction_data,
284 sizeof(card->bm_transaction_data));
285 285
286 if (rcode == RCODE_GENERATION) 286 if (rcode == RCODE_GENERATION)
287 /* Another bus reset, BM work has been rescheduled. */ 287 /* Another bus reset, BM work has been rescheduled. */
288 goto out; 288 goto out;
289 289
290 if (rcode == RCODE_COMPLETE && 290 if (rcode == RCODE_COMPLETE &&
291 lock_data[0] != cpu_to_be32(0x3f)) { 291 card->bm_transaction_data[0] != cpu_to_be32(0x3f)) {
292 292
293 /* Somebody else is BM. Only act as IRM. */ 293 /* Somebody else is BM. Only act as IRM. */
294 if (local_id == irm_id) 294 if (local_id == irm_id)
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index d1d30c615b0f..ced186d7e9a9 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -125,6 +125,7 @@ struct iso_resource {
125 int generation; 125 int generation;
126 u64 channels; 126 u64 channels;
127 s32 bandwidth; 127 s32 bandwidth;
128 __be32 transaction_data[2];
128 struct iso_resource_event *e_alloc, *e_dealloc; 129 struct iso_resource_event *e_alloc, *e_dealloc;
129}; 130};
130 131
@@ -1049,7 +1050,8 @@ static void iso_resource_work(struct work_struct *work)
1049 r->channels, &channel, &bandwidth, 1050 r->channels, &channel, &bandwidth,
1050 todo == ISO_RES_ALLOC || 1051 todo == ISO_RES_ALLOC ||
1051 todo == ISO_RES_REALLOC || 1052 todo == ISO_RES_REALLOC ||
1052 todo == ISO_RES_ALLOC_ONCE); 1053 todo == ISO_RES_ALLOC_ONCE,
1054 r->transaction_data);
1053 /* 1055 /*
1054 * Is this generation outdated already? As long as this resource sticks 1056 * Is this generation outdated already? As long as this resource sticks
1055 * in the idr, it will be scheduled again for a newer generation or at 1057 * in the idr, it will be scheduled again for a newer generation or at
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index 166f19c6d38d..110e731f5574 100644
--- a/drivers/firewire/core-iso.c
+++ b/drivers/firewire/core-iso.c
@@ -177,9 +177,8 @@ EXPORT_SYMBOL(fw_iso_context_stop);
177 */ 177 */
178 178
179static int manage_bandwidth(struct fw_card *card, int irm_id, int generation, 179static int manage_bandwidth(struct fw_card *card, int irm_id, int generation,
180 int bandwidth, bool allocate) 180 int bandwidth, bool allocate, __be32 data[2])
181{ 181{
182 __be32 data[2];
183 int try, new, old = allocate ? BANDWIDTH_AVAILABLE_INITIAL : 0; 182 int try, new, old = allocate ? BANDWIDTH_AVAILABLE_INITIAL : 0;
184 183
185 /* 184 /*
@@ -215,9 +214,9 @@ static int manage_bandwidth(struct fw_card *card, int irm_id, int generation,
215} 214}
216 215
217static int manage_channel(struct fw_card *card, int irm_id, int generation, 216static int manage_channel(struct fw_card *card, int irm_id, int generation,
218 u32 channels_mask, u64 offset, bool allocate) 217 u32 channels_mask, u64 offset, bool allocate, __be32 data[2])
219{ 218{
220 __be32 data[2], c, all, old; 219 __be32 c, all, old;
221 int i, retry = 5; 220 int i, retry = 5;
222 221
223 old = all = allocate ? cpu_to_be32(~0) : 0; 222 old = all = allocate ? cpu_to_be32(~0) : 0;
@@ -260,7 +259,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
260} 259}
261 260
262static void deallocate_channel(struct fw_card *card, int irm_id, 261static void deallocate_channel(struct fw_card *card, int irm_id,
263 int generation, int channel) 262 int generation, int channel, __be32 buffer[2])
264{ 263{
265 u32 mask; 264 u32 mask;
266 u64 offset; 265 u64 offset;
@@ -269,7 +268,7 @@ static void deallocate_channel(struct fw_card *card, int irm_id,
269 offset = channel < 32 ? CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI : 268 offset = channel < 32 ? CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI :
270 CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO; 269 CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO;
271 270
272 manage_channel(card, irm_id, generation, mask, offset, false); 271 manage_channel(card, irm_id, generation, mask, offset, false, buffer);
273} 272}
274 273
275/** 274/**
@@ -298,7 +297,7 @@ static void deallocate_channel(struct fw_card *card, int irm_id,
298 */ 297 */
299void fw_iso_resource_manage(struct fw_card *card, int generation, 298void fw_iso_resource_manage(struct fw_card *card, int generation,
300 u64 channels_mask, int *channel, int *bandwidth, 299 u64 channels_mask, int *channel, int *bandwidth,
301 bool allocate) 300 bool allocate, __be32 buffer[2])
302{ 301{
303 u32 channels_hi = channels_mask; /* channels 31...0 */ 302 u32 channels_hi = channels_mask; /* channels 31...0 */
304 u32 channels_lo = channels_mask >> 32; /* channels 63...32 */ 303 u32 channels_lo = channels_mask >> 32; /* channels 63...32 */
@@ -310,10 +309,12 @@ void fw_iso_resource_manage(struct fw_card *card, int generation,
310 309
311 if (channels_hi) 310 if (channels_hi)
312 c = manage_channel(card, irm_id, generation, channels_hi, 311 c = manage_channel(card, irm_id, generation, channels_hi,
313 CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI, allocate); 312 CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_HI,
313 allocate, buffer);
314 if (channels_lo && c < 0) { 314 if (channels_lo && c < 0) {
315 c = manage_channel(card, irm_id, generation, channels_lo, 315 c = manage_channel(card, irm_id, generation, channels_lo,
316 CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO, allocate); 316 CSR_REGISTER_BASE + CSR_CHANNELS_AVAILABLE_LO,
317 allocate, buffer);
317 if (c >= 0) 318 if (c >= 0)
318 c += 32; 319 c += 32;
319 } 320 }
@@ -325,12 +326,13 @@ void fw_iso_resource_manage(struct fw_card *card, int generation,
325 if (*bandwidth == 0) 326 if (*bandwidth == 0)
326 return; 327 return;
327 328
328 ret = manage_bandwidth(card, irm_id, generation, *bandwidth, allocate); 329 ret = manage_bandwidth(card, irm_id, generation, *bandwidth,
330 allocate, buffer);
329 if (ret < 0) 331 if (ret < 0)
330 *bandwidth = 0; 332 *bandwidth = 0;
331 333
332 if (allocate && ret < 0 && c >= 0) { 334 if (allocate && ret < 0 && c >= 0) {
333 deallocate_channel(card, irm_id, generation, c); 335 deallocate_channel(card, irm_id, generation, c, buffer);
334 *channel = ret; 336 *channel = ret;
335 } 337 }
336} 338}
diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
index c3cfc647e5e3..6052816be353 100644
--- a/drivers/firewire/core.h
+++ b/drivers/firewire/core.h
@@ -120,7 +120,8 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event);
120 120
121int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma); 121int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma);
122void fw_iso_resource_manage(struct fw_card *card, int generation, 122void fw_iso_resource_manage(struct fw_card *card, int generation,
123 u64 channels_mask, int *channel, int *bandwidth, bool allocate); 123 u64 channels_mask, int *channel, int *bandwidth,
124 bool allocate, __be32 buffer[2]);
124 125
125 126
126/* -topology */ 127/* -topology */
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 24c45635376a..8d51568ee143 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -201,6 +201,12 @@ static struct fw_device *target_device(struct sbp2_target *tgt)
201#define SBP2_CYCLE_LIMIT (0xc8 << 12) /* 200 125us cycles */ 201#define SBP2_CYCLE_LIMIT (0xc8 << 12) /* 200 125us cycles */
202 202
203/* 203/*
204 * There is no transport protocol limit to the CDB length, but we implement
205 * a fixed length only. 16 bytes is enough for disks larger than 2 TB.
206 */
207#define SBP2_MAX_CDB_SIZE 16
208
209/*
204 * The default maximum s/g segment size of a FireWire controller is 210 * The default maximum s/g segment size of a FireWire controller is
205 * usually 0x10000, but SBP-2 only allows 0xffff. Since buffers have to 211 * usually 0x10000, but SBP-2 only allows 0xffff. Since buffers have to
206 * be quadlet-aligned, we set the length limit to 0xffff & ~3. 212 * be quadlet-aligned, we set the length limit to 0xffff & ~3.
@@ -312,7 +318,7 @@ struct sbp2_command_orb {
312 struct sbp2_pointer next; 318 struct sbp2_pointer next;
313 struct sbp2_pointer data_descriptor; 319 struct sbp2_pointer data_descriptor;
314 __be32 misc; 320 __be32 misc;
315 u8 command_block[12]; 321 u8 command_block[SBP2_MAX_CDB_SIZE];
316 } request; 322 } request;
317 struct scsi_cmnd *cmd; 323 struct scsi_cmnd *cmd;
318 scsi_done_fn_t done; 324 scsi_done_fn_t done;
@@ -1146,6 +1152,8 @@ static int sbp2_probe(struct device *dev)
1146 if (fw_device_enable_phys_dma(device) < 0) 1152 if (fw_device_enable_phys_dma(device) < 0)
1147 goto fail_shost_put; 1153 goto fail_shost_put;
1148 1154
1155 shost->max_cmd_len = SBP2_MAX_CDB_SIZE;
1156
1149 if (scsi_add_host(shost, &unit->device) < 0) 1157 if (scsi_add_host(shost, &unit->device) < 0)
1150 goto fail_shost_put; 1158 goto fail_shost_put;
1151 1159
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 3582c39f9725..96dda81c9228 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -79,6 +79,12 @@ config GPIO_XILINX
79 help 79 help
80 Say yes here to support the Xilinx FPGA GPIO device 80 Say yes here to support the Xilinx FPGA GPIO device
81 81
82config GPIO_VR41XX
83 tristate "NEC VR4100 series General-purpose I/O Uint support"
84 depends on CPU_VR41XX
85 help
86 Say yes here to support the NEC VR4100 series General-purpose I/O Uint
87
82comment "I2C GPIO expanders:" 88comment "I2C GPIO expanders:"
83 89
84config GPIO_MAX732X 90config GPIO_MAX732X
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index ef90203e8f3c..9244c6fcd8be 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_GPIO_PL061) += pl061.o
13obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o 13obj-$(CONFIG_GPIO_TWL4030) += twl4030-gpio.o
14obj-$(CONFIG_GPIO_XILINX) += xilinx_gpio.o 14obj-$(CONFIG_GPIO_XILINX) += xilinx_gpio.o
15obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o 15obj-$(CONFIG_GPIO_BT8XX) += bt8xxgpio.o
16obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
diff --git a/drivers/gpio/pl061.c b/drivers/gpio/pl061.c
index aa8e7cb020d9..4ee4c8367a3f 100644
--- a/drivers/gpio/pl061.c
+++ b/drivers/gpio/pl061.c
@@ -109,6 +109,16 @@ static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value)
109 writeb(!!value << offset, chip->base + (1 << (offset + 2))); 109 writeb(!!value << offset, chip->base + (1 << (offset + 2)));
110} 110}
111 111
112static int pl061_to_irq(struct gpio_chip *gc, unsigned offset)
113{
114 struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
115
116 if (chip->irq_base == (unsigned) -1)
117 return -EINVAL;
118
119 return chip->irq_base + offset;
120}
121
112/* 122/*
113 * PL061 GPIO IRQ 123 * PL061 GPIO IRQ
114 */ 124 */
@@ -200,7 +210,7 @@ static void pl061_irq_handler(unsigned irq, struct irq_desc *desc)
200 desc->chip->ack(irq); 210 desc->chip->ack(irq);
201 list_for_each(ptr, chip_list) { 211 list_for_each(ptr, chip_list) {
202 unsigned long pending; 212 unsigned long pending;
203 int gpio; 213 int offset;
204 214
205 chip = list_entry(ptr, struct pl061_gpio, list); 215 chip = list_entry(ptr, struct pl061_gpio, list);
206 pending = readb(chip->base + GPIOMIS); 216 pending = readb(chip->base + GPIOMIS);
@@ -209,8 +219,8 @@ static void pl061_irq_handler(unsigned irq, struct irq_desc *desc)
209 if (pending == 0) 219 if (pending == 0)
210 continue; 220 continue;
211 221
212 for_each_bit(gpio, &pending, PL061_GPIO_NR) 222 for_each_bit(offset, &pending, PL061_GPIO_NR)
213 generic_handle_irq(gpio_to_irq(gpio)); 223 generic_handle_irq(pl061_to_irq(&chip->gc, offset));
214 } 224 }
215 desc->chip->unmask(irq); 225 desc->chip->unmask(irq);
216} 226}
@@ -221,7 +231,7 @@ static int __init pl061_probe(struct amba_device *dev, struct amba_id *id)
221 struct pl061_gpio *chip; 231 struct pl061_gpio *chip;
222 struct list_head *chip_list; 232 struct list_head *chip_list;
223 int ret, irq, i; 233 int ret, irq, i;
224 static unsigned long init_irq[BITS_TO_LONGS(NR_IRQS)]; 234 static DECLARE_BITMAP(init_irq, NR_IRQS);
225 235
226 pdata = dev->dev.platform_data; 236 pdata = dev->dev.platform_data;
227 if (pdata == NULL) 237 if (pdata == NULL)
@@ -251,6 +261,7 @@ static int __init pl061_probe(struct amba_device *dev, struct amba_id *id)
251 chip->gc.direction_output = pl061_direction_output; 261 chip->gc.direction_output = pl061_direction_output;
252 chip->gc.get = pl061_get_value; 262 chip->gc.get = pl061_get_value;
253 chip->gc.set = pl061_set_value; 263 chip->gc.set = pl061_set_value;
264 chip->gc.to_irq = pl061_to_irq;
254 chip->gc.base = pdata->gpio_base; 265 chip->gc.base = pdata->gpio_base;
255 chip->gc.ngpio = PL061_GPIO_NR; 266 chip->gc.ngpio = PL061_GPIO_NR;
256 chip->gc.label = dev_name(&dev->dev); 267 chip->gc.label = dev_name(&dev->dev);
@@ -280,6 +291,7 @@ static int __init pl061_probe(struct amba_device *dev, struct amba_id *id)
280 if (!test_and_set_bit(irq, init_irq)) { /* list initialized? */ 291 if (!test_and_set_bit(irq, init_irq)) { /* list initialized? */
281 chip_list = kmalloc(sizeof(*chip_list), GFP_KERNEL); 292 chip_list = kmalloc(sizeof(*chip_list), GFP_KERNEL);
282 if (chip_list == NULL) { 293 if (chip_list == NULL) {
294 clear_bit(irq, init_irq);
283 ret = -ENOMEM; 295 ret = -ENOMEM;
284 goto iounmap; 296 goto iounmap;
285 } 297 }
diff --git a/drivers/gpio/vr41xx_giu.c b/drivers/gpio/vr41xx_giu.c
new file mode 100644
index 000000000000..b16c9a8c03f5
--- /dev/null
+++ b/drivers/gpio/vr41xx_giu.c
@@ -0,0 +1,585 @@
1/*
2 * Driver for NEC VR4100 series General-purpose I/O Unit.
3 *
4 * Copyright (C) 2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <source@mvista.com>
6 * Copyright (C) 2003-2009 Yoichi Yuasa <yuasa@linux-mips.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#include <linux/errno.h>
23#include <linux/fs.h>
24#include <linux/gpio.h>
25#include <linux/init.h>
26#include <linux/interrupt.h>
27#include <linux/io.h>
28#include <linux/irq.h>
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/platform_device.h>
32#include <linux/spinlock.h>
33#include <linux/types.h>
34
35#include <asm/vr41xx/giu.h>
36#include <asm/vr41xx/irq.h>
37#include <asm/vr41xx/vr41xx.h>
38
39MODULE_AUTHOR("Yoichi Yuasa <yuasa@linux-mips.org>");
40MODULE_DESCRIPTION("NEC VR4100 series General-purpose I/O Unit driver");
41MODULE_LICENSE("GPL");
42
43#define GIUIOSELL 0x00
44#define GIUIOSELH 0x02
45#define GIUPIODL 0x04
46#define GIUPIODH 0x06
47#define GIUINTSTATL 0x08
48#define GIUINTSTATH 0x0a
49#define GIUINTENL 0x0c
50#define GIUINTENH 0x0e
51#define GIUINTTYPL 0x10
52#define GIUINTTYPH 0x12
53#define GIUINTALSELL 0x14
54#define GIUINTALSELH 0x16
55#define GIUINTHTSELL 0x18
56#define GIUINTHTSELH 0x1a
57#define GIUPODATL 0x1c
58#define GIUPODATEN 0x1c
59#define GIUPODATH 0x1e
60 #define PIOEN0 0x0100
61 #define PIOEN1 0x0200
62#define GIUPODAT 0x1e
63#define GIUFEDGEINHL 0x20
64#define GIUFEDGEINHH 0x22
65#define GIUREDGEINHL 0x24
66#define GIUREDGEINHH 0x26
67
68#define GIUUSEUPDN 0x1e0
69#define GIUTERMUPDN 0x1e2
70
71#define GPIO_HAS_PULLUPDOWN_IO 0x0001
72#define GPIO_HAS_OUTPUT_ENABLE 0x0002
73#define GPIO_HAS_INTERRUPT_EDGE_SELECT 0x0100
74
75enum {
76 GPIO_INPUT,
77 GPIO_OUTPUT,
78};
79
80static DEFINE_SPINLOCK(giu_lock);
81static unsigned long giu_flags;
82
83static void __iomem *giu_base;
84
85#define giu_read(offset) readw(giu_base + (offset))
86#define giu_write(offset, value) writew((value), giu_base + (offset))
87
88#define GPIO_PIN_OF_IRQ(irq) ((irq) - GIU_IRQ_BASE)
89#define GIUINT_HIGH_OFFSET 16
90#define GIUINT_HIGH_MAX 32
91
92static inline u16 giu_set(u16 offset, u16 set)
93{
94 u16 data;
95
96 data = giu_read(offset);
97 data |= set;
98 giu_write(offset, data);
99
100 return data;
101}
102
103static inline u16 giu_clear(u16 offset, u16 clear)
104{
105 u16 data;
106
107 data = giu_read(offset);
108 data &= ~clear;
109 giu_write(offset, data);
110
111 return data;
112}
113
114static void ack_giuint_low(unsigned int irq)
115{
116 giu_write(GIUINTSTATL, 1 << GPIO_PIN_OF_IRQ(irq));
117}
118
119static void mask_giuint_low(unsigned int irq)
120{
121 giu_clear(GIUINTENL, 1 << GPIO_PIN_OF_IRQ(irq));
122}
123
124static void mask_ack_giuint_low(unsigned int irq)
125{
126 unsigned int pin;
127
128 pin = GPIO_PIN_OF_IRQ(irq);
129 giu_clear(GIUINTENL, 1 << pin);
130 giu_write(GIUINTSTATL, 1 << pin);
131}
132
133static void unmask_giuint_low(unsigned int irq)
134{
135 giu_set(GIUINTENL, 1 << GPIO_PIN_OF_IRQ(irq));
136}
137
138static struct irq_chip giuint_low_irq_chip = {
139 .name = "GIUINTL",
140 .ack = ack_giuint_low,
141 .mask = mask_giuint_low,
142 .mask_ack = mask_ack_giuint_low,
143 .unmask = unmask_giuint_low,
144};
145
146static void ack_giuint_high(unsigned int irq)
147{
148 giu_write(GIUINTSTATH,
149 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
150}
151
152static void mask_giuint_high(unsigned int irq)
153{
154 giu_clear(GIUINTENH, 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
155}
156
157static void mask_ack_giuint_high(unsigned int irq)
158{
159 unsigned int pin;
160
161 pin = GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET;
162 giu_clear(GIUINTENH, 1 << pin);
163 giu_write(GIUINTSTATH, 1 << pin);
164}
165
166static void unmask_giuint_high(unsigned int irq)
167{
168 giu_set(GIUINTENH, 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
169}
170
171static struct irq_chip giuint_high_irq_chip = {
172 .name = "GIUINTH",
173 .ack = ack_giuint_high,
174 .mask = mask_giuint_high,
175 .mask_ack = mask_ack_giuint_high,
176 .unmask = unmask_giuint_high,
177};
178
179static int giu_get_irq(unsigned int irq)
180{
181 u16 pendl, pendh, maskl, maskh;
182 int i;
183
184 pendl = giu_read(GIUINTSTATL);
185 pendh = giu_read(GIUINTSTATH);
186 maskl = giu_read(GIUINTENL);
187 maskh = giu_read(GIUINTENH);
188
189 maskl &= pendl;
190 maskh &= pendh;
191
192 if (maskl) {
193 for (i = 0; i < 16; i++) {
194 if (maskl & (1 << i))
195 return GIU_IRQ(i);
196 }
197 } else if (maskh) {
198 for (i = 0; i < 16; i++) {
199 if (maskh & (1 << i))
200 return GIU_IRQ(i + GIUINT_HIGH_OFFSET);
201 }
202 }
203
204 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
205 maskl, pendl, maskh, pendh);
206
207 atomic_inc(&irq_err_count);
208
209 return -EINVAL;
210}
211
212void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger,
213 irq_signal_t signal)
214{
215 u16 mask;
216
217 if (pin < GIUINT_HIGH_OFFSET) {
218 mask = 1 << pin;
219 if (trigger != IRQ_TRIGGER_LEVEL) {
220 giu_set(GIUINTTYPL, mask);
221 if (signal == IRQ_SIGNAL_HOLD)
222 giu_set(GIUINTHTSELL, mask);
223 else
224 giu_clear(GIUINTHTSELL, mask);
225 if (giu_flags & GPIO_HAS_INTERRUPT_EDGE_SELECT) {
226 switch (trigger) {
227 case IRQ_TRIGGER_EDGE_FALLING:
228 giu_set(GIUFEDGEINHL, mask);
229 giu_clear(GIUREDGEINHL, mask);
230 break;
231 case IRQ_TRIGGER_EDGE_RISING:
232 giu_clear(GIUFEDGEINHL, mask);
233 giu_set(GIUREDGEINHL, mask);
234 break;
235 default:
236 giu_set(GIUFEDGEINHL, mask);
237 giu_set(GIUREDGEINHL, mask);
238 break;
239 }
240 }
241 set_irq_chip_and_handler(GIU_IRQ(pin),
242 &giuint_low_irq_chip,
243 handle_edge_irq);
244 } else {
245 giu_clear(GIUINTTYPL, mask);
246 giu_clear(GIUINTHTSELL, mask);
247 set_irq_chip_and_handler(GIU_IRQ(pin),
248 &giuint_low_irq_chip,
249 handle_level_irq);
250 }
251 giu_write(GIUINTSTATL, mask);
252 } else if (pin < GIUINT_HIGH_MAX) {
253 mask = 1 << (pin - GIUINT_HIGH_OFFSET);
254 if (trigger != IRQ_TRIGGER_LEVEL) {
255 giu_set(GIUINTTYPH, mask);
256 if (signal == IRQ_SIGNAL_HOLD)
257 giu_set(GIUINTHTSELH, mask);
258 else
259 giu_clear(GIUINTHTSELH, mask);
260 if (giu_flags & GPIO_HAS_INTERRUPT_EDGE_SELECT) {
261 switch (trigger) {
262 case IRQ_TRIGGER_EDGE_FALLING:
263 giu_set(GIUFEDGEINHH, mask);
264 giu_clear(GIUREDGEINHH, mask);
265 break;
266 case IRQ_TRIGGER_EDGE_RISING:
267 giu_clear(GIUFEDGEINHH, mask);
268 giu_set(GIUREDGEINHH, mask);
269 break;
270 default:
271 giu_set(GIUFEDGEINHH, mask);
272 giu_set(GIUREDGEINHH, mask);
273 break;
274 }
275 }
276 set_irq_chip_and_handler(GIU_IRQ(pin),
277 &giuint_high_irq_chip,
278 handle_edge_irq);
279 } else {
280 giu_clear(GIUINTTYPH, mask);
281 giu_clear(GIUINTHTSELH, mask);
282 set_irq_chip_and_handler(GIU_IRQ(pin),
283 &giuint_high_irq_chip,
284 handle_level_irq);
285 }
286 giu_write(GIUINTSTATH, mask);
287 }
288}
289EXPORT_SYMBOL_GPL(vr41xx_set_irq_trigger);
290
291void vr41xx_set_irq_level(unsigned int pin, irq_level_t level)
292{
293 u16 mask;
294
295 if (pin < GIUINT_HIGH_OFFSET) {
296 mask = 1 << pin;
297 if (level == IRQ_LEVEL_HIGH)
298 giu_set(GIUINTALSELL, mask);
299 else
300 giu_clear(GIUINTALSELL, mask);
301 giu_write(GIUINTSTATL, mask);
302 } else if (pin < GIUINT_HIGH_MAX) {
303 mask = 1 << (pin - GIUINT_HIGH_OFFSET);
304 if (level == IRQ_LEVEL_HIGH)
305 giu_set(GIUINTALSELH, mask);
306 else
307 giu_clear(GIUINTALSELH, mask);
308 giu_write(GIUINTSTATH, mask);
309 }
310}
311EXPORT_SYMBOL_GPL(vr41xx_set_irq_level);
312
313static int giu_set_direction(struct gpio_chip *chip, unsigned pin, int dir)
314{
315 u16 offset, mask, reg;
316 unsigned long flags;
317
318 if (pin >= chip->ngpio)
319 return -EINVAL;
320
321 if (pin < 16) {
322 offset = GIUIOSELL;
323 mask = 1 << pin;
324 } else if (pin < 32) {
325 offset = GIUIOSELH;
326 mask = 1 << (pin - 16);
327 } else {
328 if (giu_flags & GPIO_HAS_OUTPUT_ENABLE) {
329 offset = GIUPODATEN;
330 mask = 1 << (pin - 32);
331 } else {
332 switch (pin) {
333 case 48:
334 offset = GIUPODATH;
335 mask = PIOEN0;
336 break;
337 case 49:
338 offset = GIUPODATH;
339 mask = PIOEN1;
340 break;
341 default:
342 return -EINVAL;
343 }
344 }
345 }
346
347 spin_lock_irqsave(&giu_lock, flags);
348
349 reg = giu_read(offset);
350 if (dir == GPIO_OUTPUT)
351 reg |= mask;
352 else
353 reg &= ~mask;
354 giu_write(offset, reg);
355
356 spin_unlock_irqrestore(&giu_lock, flags);
357
358 return 0;
359}
360
361int vr41xx_gpio_pullupdown(unsigned int pin, gpio_pull_t pull)
362{
363 u16 reg, mask;
364 unsigned long flags;
365
366 if ((giu_flags & GPIO_HAS_PULLUPDOWN_IO) != GPIO_HAS_PULLUPDOWN_IO)
367 return -EPERM;
368
369 if (pin >= 15)
370 return -EINVAL;
371
372 mask = 1 << pin;
373
374 spin_lock_irqsave(&giu_lock, flags);
375
376 if (pull == GPIO_PULL_UP || pull == GPIO_PULL_DOWN) {
377 reg = giu_read(GIUTERMUPDN);
378 if (pull == GPIO_PULL_UP)
379 reg |= mask;
380 else
381 reg &= ~mask;
382 giu_write(GIUTERMUPDN, reg);
383
384 reg = giu_read(GIUUSEUPDN);
385 reg |= mask;
386 giu_write(GIUUSEUPDN, reg);
387 } else {
388 reg = giu_read(GIUUSEUPDN);
389 reg &= ~mask;
390 giu_write(GIUUSEUPDN, reg);
391 }
392
393 spin_unlock_irqrestore(&giu_lock, flags);
394
395 return 0;
396}
397EXPORT_SYMBOL_GPL(vr41xx_gpio_pullupdown);
398
399static int vr41xx_gpio_get(struct gpio_chip *chip, unsigned pin)
400{
401 u16 reg, mask;
402
403 if (pin >= chip->ngpio)
404 return -EINVAL;
405
406 if (pin < 16) {
407 reg = giu_read(GIUPIODL);
408 mask = 1 << pin;
409 } else if (pin < 32) {
410 reg = giu_read(GIUPIODH);
411 mask = 1 << (pin - 16);
412 } else if (pin < 48) {
413 reg = giu_read(GIUPODATL);
414 mask = 1 << (pin - 32);
415 } else {
416 reg = giu_read(GIUPODATH);
417 mask = 1 << (pin - 48);
418 }
419
420 if (reg & mask)
421 return 1;
422
423 return 0;
424}
425
426static void vr41xx_gpio_set(struct gpio_chip *chip, unsigned pin,
427 int value)
428{
429 u16 offset, mask, reg;
430 unsigned long flags;
431
432 if (pin >= chip->ngpio)
433 return;
434
435 if (pin < 16) {
436 offset = GIUPIODL;
437 mask = 1 << pin;
438 } else if (pin < 32) {
439 offset = GIUPIODH;
440 mask = 1 << (pin - 16);
441 } else if (pin < 48) {
442 offset = GIUPODATL;
443 mask = 1 << (pin - 32);
444 } else {
445 offset = GIUPODATH;
446 mask = 1 << (pin - 48);
447 }
448
449 spin_lock_irqsave(&giu_lock, flags);
450
451 reg = giu_read(offset);
452 if (value)
453 reg |= mask;
454 else
455 reg &= ~mask;
456 giu_write(offset, reg);
457
458 spin_unlock_irqrestore(&giu_lock, flags);
459}
460
461
462static int vr41xx_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
463{
464 return giu_set_direction(chip, offset, GPIO_INPUT);
465}
466
467static int vr41xx_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
468 int value)
469{
470 vr41xx_gpio_set(chip, offset, value);
471
472 return giu_set_direction(chip, offset, GPIO_OUTPUT);
473}
474
475static int vr41xx_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
476{
477 if (offset >= chip->ngpio)
478 return -EINVAL;
479
480 return GIU_IRQ_BASE + offset;
481}
482
483static struct gpio_chip vr41xx_gpio_chip = {
484 .label = "vr41xx",
485 .owner = THIS_MODULE,
486 .direction_input = vr41xx_gpio_direction_input,
487 .get = vr41xx_gpio_get,
488 .direction_output = vr41xx_gpio_direction_output,
489 .set = vr41xx_gpio_set,
490 .to_irq = vr41xx_gpio_to_irq,
491};
492
493static int __devinit giu_probe(struct platform_device *pdev)
494{
495 struct resource *res;
496 unsigned int trigger, i, pin;
497 struct irq_chip *chip;
498 int irq, retval;
499
500 switch (pdev->id) {
501 case GPIO_50PINS_PULLUPDOWN:
502 giu_flags = GPIO_HAS_PULLUPDOWN_IO;
503 vr41xx_gpio_chip.ngpio = 50;
504 break;
505 case GPIO_36PINS:
506 vr41xx_gpio_chip.ngpio = 36;
507 break;
508 case GPIO_48PINS_EDGE_SELECT:
509 giu_flags = GPIO_HAS_INTERRUPT_EDGE_SELECT;
510 vr41xx_gpio_chip.ngpio = 48;
511 break;
512 default:
513 dev_err(&pdev->dev, "GIU: unknown ID %d\n", pdev->id);
514 return -ENODEV;
515 }
516
517 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
518 if (!res)
519 return -EBUSY;
520
521 giu_base = ioremap(res->start, res->end - res->start + 1);
522 if (!giu_base)
523 return -ENOMEM;
524
525 vr41xx_gpio_chip.dev = &pdev->dev;
526
527 retval = gpiochip_add(&vr41xx_gpio_chip);
528
529 giu_write(GIUINTENL, 0);
530 giu_write(GIUINTENH, 0);
531
532 trigger = giu_read(GIUINTTYPH) << 16;
533 trigger |= giu_read(GIUINTTYPL);
534 for (i = GIU_IRQ_BASE; i <= GIU_IRQ_LAST; i++) {
535 pin = GPIO_PIN_OF_IRQ(i);
536 if (pin < GIUINT_HIGH_OFFSET)
537 chip = &giuint_low_irq_chip;
538 else
539 chip = &giuint_high_irq_chip;
540
541 if (trigger & (1 << pin))
542 set_irq_chip_and_handler(i, chip, handle_edge_irq);
543 else
544 set_irq_chip_and_handler(i, chip, handle_level_irq);
545
546 }
547
548 irq = platform_get_irq(pdev, 0);
549 if (irq < 0 || irq >= nr_irqs)
550 return -EBUSY;
551
552 return cascade_irq(irq, giu_get_irq);
553}
554
555static int __devexit giu_remove(struct platform_device *pdev)
556{
557 if (giu_base) {
558 iounmap(giu_base);
559 giu_base = NULL;
560 }
561
562 return 0;
563}
564
565static struct platform_driver giu_device_driver = {
566 .probe = giu_probe,
567 .remove = __devexit_p(giu_remove),
568 .driver = {
569 .name = "GIU",
570 .owner = THIS_MODULE,
571 },
572};
573
574static int __init vr41xx_giu_init(void)
575{
576 return platform_driver_register(&giu_device_driver);
577}
578
579static void __exit vr41xx_giu_exit(void)
580{
581 platform_driver_unregister(&giu_device_driver);
582}
583
584module_init(vr41xx_giu_init);
585module_exit(vr41xx_giu_exit);
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index c961fe415aef..39b393d38bb3 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -81,6 +81,7 @@ config DRM_I830
81 81
82config DRM_I915 82config DRM_I915
83 tristate "i915 driver" 83 tristate "i915 driver"
84 depends on AGP_INTEL
84 select FB_CFB_FILLRECT 85 select FB_CFB_FILLRECT
85 select FB_CFB_COPYAREA 86 select FB_CFB_COPYAREA
86 select FB_CFB_IMAGEBLIT 87 select FB_CFB_IMAGEBLIT
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4e89ab08b7b8..fe23f29f7cba 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -16,6 +16,7 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \
16drm-$(CONFIG_COMPAT) += drm_ioc32.o 16drm-$(CONFIG_COMPAT) += drm_ioc32.o
17 17
18obj-$(CONFIG_DRM) += drm.o 18obj-$(CONFIG_DRM) += drm.o
19obj-$(CONFIG_DRM_TTM) += ttm/
19obj-$(CONFIG_DRM_TDFX) += tdfx/ 20obj-$(CONFIG_DRM_TDFX) += tdfx/
20obj-$(CONFIG_DRM_R128) += r128/ 21obj-$(CONFIG_DRM_R128) += r128/
21obj-$(CONFIG_DRM_RADEON)+= radeon/ 22obj-$(CONFIG_DRM_RADEON)+= radeon/
@@ -26,4 +27,3 @@ obj-$(CONFIG_DRM_I915) += i915/
26obj-$(CONFIG_DRM_SIS) += sis/ 27obj-$(CONFIG_DRM_SIS) += sis/
27obj-$(CONFIG_DRM_SAVAGE)+= savage/ 28obj-$(CONFIG_DRM_SAVAGE)+= savage/
28obj-$(CONFIG_DRM_VIA) +=via/ 29obj-$(CONFIG_DRM_VIA) +=via/
29obj-$(CONFIG_DRM_TTM) += ttm/
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index a6f73f1e99d9..3da9cfa31848 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -1090,6 +1090,8 @@ int drm_helper_resume_force_mode(struct drm_device *dev)
1090 if (ret == false) 1090 if (ret == false)
1091 DRM_ERROR("failed to set mode on crtc %p\n", crtc); 1091 DRM_ERROR("failed to set mode on crtc %p\n", crtc);
1092 } 1092 }
1093 /* disable the unused connectors while restoring the modesetting */
1094 drm_helper_disable_unused_functions(dev);
1093 return 0; 1095 return 0;
1094} 1096}
1095EXPORT_SYMBOL(drm_helper_resume_force_mode); 1097EXPORT_SYMBOL(drm_helper_resume_force_mode);
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 7d0835226f6e..80cc6d06d61b 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -294,10 +294,10 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
294 unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo; 294 unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
295 unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo; 295 unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
296 unsigned vblank = (pt->vactive_vblank_hi & 0xf) << 8 | pt->vblank_lo; 296 unsigned vblank = (pt->vactive_vblank_hi & 0xf) << 8 | pt->vblank_lo;
297 unsigned hsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0x3) << 8 | pt->hsync_offset_lo; 297 unsigned hsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc0) << 2 | pt->hsync_offset_lo;
298 unsigned hsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0xc) << 6 | pt->hsync_pulse_width_lo; 298 unsigned hsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0x30) << 4 | pt->hsync_pulse_width_lo;
299 unsigned vsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0x30) | (pt->vsync_offset_pulse_width_lo & 0xf); 299 unsigned vsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc) >> 2 | pt->vsync_offset_pulse_width_lo >> 4;
300 unsigned vsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0xc0) >> 2 | pt->vsync_offset_pulse_width_lo >> 4; 300 unsigned vsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0x3) << 4 | (pt->vsync_offset_pulse_width_lo & 0xf);
301 301
302 /* ignore tiny modes */ 302 /* ignore tiny modes */
303 if (hactive < 64 || vactive < 64) 303 if (hactive < 64 || vactive < 64)
@@ -347,8 +347,8 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
347 mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ? 347 mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
348 DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; 348 DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
349 349
350 mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf) << 8; 350 mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
351 mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4; 351 mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
352 352
353 if (quirks & EDID_QUIRK_DETAILED_IN_CM) { 353 if (quirks & EDID_QUIRK_DETAILED_IN_CM) {
354 mode->width_mm *= 10; 354 mode->width_mm *= 10;
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 51c5a050aa73..30d6b99fb302 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -13,6 +13,8 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
13 intel_crt.o \ 13 intel_crt.o \
14 intel_lvds.o \ 14 intel_lvds.o \
15 intel_bios.o \ 15 intel_bios.o \
16 intel_dp.o \
17 intel_dp_i2c.o \
16 intel_hdmi.o \ 18 intel_hdmi.o \
17 intel_sdvo.o \ 19 intel_sdvo.o \
18 intel_modes.o \ 20 intel_modes.o \
diff --git a/drivers/gpu/drm/i915/dvo.h b/drivers/gpu/drm/i915/dvo.h
index e747ac42fe3a..288fc50627e2 100644
--- a/drivers/gpu/drm/i915/dvo.h
+++ b/drivers/gpu/drm/i915/dvo.h
@@ -37,7 +37,7 @@ struct intel_dvo_device {
37 /* GPIO register used for i2c bus to control this device */ 37 /* GPIO register used for i2c bus to control this device */
38 u32 gpio; 38 u32 gpio;
39 int slave_addr; 39 int slave_addr;
40 struct intel_i2c_chan *i2c_bus; 40 struct i2c_adapter *i2c_bus;
41 41
42 const struct intel_dvo_dev_ops *dev_ops; 42 const struct intel_dvo_dev_ops *dev_ops;
43 void *dev_priv; 43 void *dev_priv;
@@ -52,7 +52,7 @@ struct intel_dvo_dev_ops {
52 * Returns NULL if the device does not exist. 52 * Returns NULL if the device does not exist.
53 */ 53 */
54 bool (*init)(struct intel_dvo_device *dvo, 54 bool (*init)(struct intel_dvo_device *dvo,
55 struct intel_i2c_chan *i2cbus); 55 struct i2c_adapter *i2cbus);
56 56
57 /* 57 /*
58 * Called to allow the output a chance to create properties after the 58 * Called to allow the output a chance to create properties after the
diff --git a/drivers/gpu/drm/i915/dvo_ch7017.c b/drivers/gpu/drm/i915/dvo_ch7017.c
index 03d4b4973b02..621815b531db 100644
--- a/drivers/gpu/drm/i915/dvo_ch7017.c
+++ b/drivers/gpu/drm/i915/dvo_ch7017.c
@@ -176,19 +176,20 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, int mode);
176 176
177static bool ch7017_read(struct intel_dvo_device *dvo, int addr, uint8_t *val) 177static bool ch7017_read(struct intel_dvo_device *dvo, int addr, uint8_t *val)
178{ 178{
179 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 179 struct i2c_adapter *adapter = dvo->i2c_bus;
180 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
180 u8 out_buf[2]; 181 u8 out_buf[2];
181 u8 in_buf[2]; 182 u8 in_buf[2];
182 183
183 struct i2c_msg msgs[] = { 184 struct i2c_msg msgs[] = {
184 { 185 {
185 .addr = i2cbus->slave_addr, 186 .addr = dvo->slave_addr,
186 .flags = 0, 187 .flags = 0,
187 .len = 1, 188 .len = 1,
188 .buf = out_buf, 189 .buf = out_buf,
189 }, 190 },
190 { 191 {
191 .addr = i2cbus->slave_addr, 192 .addr = dvo->slave_addr,
192 .flags = I2C_M_RD, 193 .flags = I2C_M_RD,
193 .len = 1, 194 .len = 1,
194 .buf = in_buf, 195 .buf = in_buf,
@@ -208,10 +209,11 @@ static bool ch7017_read(struct intel_dvo_device *dvo, int addr, uint8_t *val)
208 209
209static bool ch7017_write(struct intel_dvo_device *dvo, int addr, uint8_t val) 210static bool ch7017_write(struct intel_dvo_device *dvo, int addr, uint8_t val)
210{ 211{
211 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 212 struct i2c_adapter *adapter = dvo->i2c_bus;
213 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
212 uint8_t out_buf[2]; 214 uint8_t out_buf[2];
213 struct i2c_msg msg = { 215 struct i2c_msg msg = {
214 .addr = i2cbus->slave_addr, 216 .addr = dvo->slave_addr,
215 .flags = 0, 217 .flags = 0,
216 .len = 2, 218 .len = 2,
217 .buf = out_buf, 219 .buf = out_buf,
@@ -228,8 +230,9 @@ static bool ch7017_write(struct intel_dvo_device *dvo, int addr, uint8_t val)
228 230
229/** Probes for a CH7017 on the given bus and slave address. */ 231/** Probes for a CH7017 on the given bus and slave address. */
230static bool ch7017_init(struct intel_dvo_device *dvo, 232static bool ch7017_init(struct intel_dvo_device *dvo,
231 struct intel_i2c_chan *i2cbus) 233 struct i2c_adapter *adapter)
232{ 234{
235 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
233 struct ch7017_priv *priv; 236 struct ch7017_priv *priv;
234 uint8_t val; 237 uint8_t val;
235 238
@@ -237,8 +240,7 @@ static bool ch7017_init(struct intel_dvo_device *dvo,
237 if (priv == NULL) 240 if (priv == NULL)
238 return false; 241 return false;
239 242
240 dvo->i2c_bus = i2cbus; 243 dvo->i2c_bus = adapter;
241 dvo->i2c_bus->slave_addr = dvo->slave_addr;
242 dvo->dev_priv = priv; 244 dvo->dev_priv = priv;
243 245
244 if (!ch7017_read(dvo, CH7017_DEVICE_ID, &val)) 246 if (!ch7017_read(dvo, CH7017_DEVICE_ID, &val))
@@ -248,7 +250,7 @@ static bool ch7017_init(struct intel_dvo_device *dvo,
248 val != CH7018_DEVICE_ID_VALUE && 250 val != CH7018_DEVICE_ID_VALUE &&
249 val != CH7019_DEVICE_ID_VALUE) { 251 val != CH7019_DEVICE_ID_VALUE) {
250 DRM_DEBUG("ch701x not detected, got %d: from %s Slave %d.\n", 252 DRM_DEBUG("ch701x not detected, got %d: from %s Slave %d.\n",
251 val, i2cbus->adapter.name,i2cbus->slave_addr); 253 val, i2cbus->adapter.name,dvo->slave_addr);
252 goto fail; 254 goto fail;
253 } 255 }
254 256
diff --git a/drivers/gpu/drm/i915/dvo_ch7xxx.c b/drivers/gpu/drm/i915/dvo_ch7xxx.c
index d2fd95dbd034..a9b896289680 100644
--- a/drivers/gpu/drm/i915/dvo_ch7xxx.c
+++ b/drivers/gpu/drm/i915/dvo_ch7xxx.c
@@ -123,19 +123,20 @@ static char *ch7xxx_get_id(uint8_t vid)
123static bool ch7xxx_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch) 123static bool ch7xxx_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
124{ 124{
125 struct ch7xxx_priv *ch7xxx= dvo->dev_priv; 125 struct ch7xxx_priv *ch7xxx= dvo->dev_priv;
126 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 126 struct i2c_adapter *adapter = dvo->i2c_bus;
127 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
127 u8 out_buf[2]; 128 u8 out_buf[2];
128 u8 in_buf[2]; 129 u8 in_buf[2];
129 130
130 struct i2c_msg msgs[] = { 131 struct i2c_msg msgs[] = {
131 { 132 {
132 .addr = i2cbus->slave_addr, 133 .addr = dvo->slave_addr,
133 .flags = 0, 134 .flags = 0,
134 .len = 1, 135 .len = 1,
135 .buf = out_buf, 136 .buf = out_buf,
136 }, 137 },
137 { 138 {
138 .addr = i2cbus->slave_addr, 139 .addr = dvo->slave_addr,
139 .flags = I2C_M_RD, 140 .flags = I2C_M_RD,
140 .len = 1, 141 .len = 1,
141 .buf = in_buf, 142 .buf = in_buf,
@@ -152,7 +153,7 @@ static bool ch7xxx_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
152 153
153 if (!ch7xxx->quiet) { 154 if (!ch7xxx->quiet) {
154 DRM_DEBUG("Unable to read register 0x%02x from %s:%02x.\n", 155 DRM_DEBUG("Unable to read register 0x%02x from %s:%02x.\n",
155 addr, i2cbus->adapter.name, i2cbus->slave_addr); 156 addr, i2cbus->adapter.name, dvo->slave_addr);
156 } 157 }
157 return false; 158 return false;
158} 159}
@@ -161,10 +162,11 @@ static bool ch7xxx_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
161static bool ch7xxx_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch) 162static bool ch7xxx_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch)
162{ 163{
163 struct ch7xxx_priv *ch7xxx = dvo->dev_priv; 164 struct ch7xxx_priv *ch7xxx = dvo->dev_priv;
164 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 165 struct i2c_adapter *adapter = dvo->i2c_bus;
166 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
165 uint8_t out_buf[2]; 167 uint8_t out_buf[2];
166 struct i2c_msg msg = { 168 struct i2c_msg msg = {
167 .addr = i2cbus->slave_addr, 169 .addr = dvo->slave_addr,
168 .flags = 0, 170 .flags = 0,
169 .len = 2, 171 .len = 2,
170 .buf = out_buf, 172 .buf = out_buf,
@@ -178,14 +180,14 @@ static bool ch7xxx_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch)
178 180
179 if (!ch7xxx->quiet) { 181 if (!ch7xxx->quiet) {
180 DRM_DEBUG("Unable to write register 0x%02x to %s:%d.\n", 182 DRM_DEBUG("Unable to write register 0x%02x to %s:%d.\n",
181 addr, i2cbus->adapter.name, i2cbus->slave_addr); 183 addr, i2cbus->adapter.name, dvo->slave_addr);
182 } 184 }
183 185
184 return false; 186 return false;
185} 187}
186 188
187static bool ch7xxx_init(struct intel_dvo_device *dvo, 189static bool ch7xxx_init(struct intel_dvo_device *dvo,
188 struct intel_i2c_chan *i2cbus) 190 struct i2c_adapter *adapter)
189{ 191{
190 /* this will detect the CH7xxx chip on the specified i2c bus */ 192 /* this will detect the CH7xxx chip on the specified i2c bus */
191 struct ch7xxx_priv *ch7xxx; 193 struct ch7xxx_priv *ch7xxx;
@@ -196,8 +198,7 @@ static bool ch7xxx_init(struct intel_dvo_device *dvo,
196 if (ch7xxx == NULL) 198 if (ch7xxx == NULL)
197 return false; 199 return false;
198 200
199 dvo->i2c_bus = i2cbus; 201 dvo->i2c_bus = adapter;
200 dvo->i2c_bus->slave_addr = dvo->slave_addr;
201 dvo->dev_priv = ch7xxx; 202 dvo->dev_priv = ch7xxx;
202 ch7xxx->quiet = true; 203 ch7xxx->quiet = true;
203 204
@@ -207,7 +208,7 @@ static bool ch7xxx_init(struct intel_dvo_device *dvo,
207 name = ch7xxx_get_id(vendor); 208 name = ch7xxx_get_id(vendor);
208 if (!name) { 209 if (!name) {
209 DRM_DEBUG("ch7xxx not detected; got 0x%02x from %s slave %d.\n", 210 DRM_DEBUG("ch7xxx not detected; got 0x%02x from %s slave %d.\n",
210 vendor, i2cbus->adapter.name, i2cbus->slave_addr); 211 vendor, adapter->name, dvo->slave_addr);
211 goto out; 212 goto out;
212 } 213 }
213 214
@@ -217,7 +218,7 @@ static bool ch7xxx_init(struct intel_dvo_device *dvo,
217 218
218 if (device != CH7xxx_DID) { 219 if (device != CH7xxx_DID) {
219 DRM_DEBUG("ch7xxx not detected; got 0x%02x from %s slave %d.\n", 220 DRM_DEBUG("ch7xxx not detected; got 0x%02x from %s slave %d.\n",
220 vendor, i2cbus->adapter.name, i2cbus->slave_addr); 221 vendor, adapter->name, dvo->slave_addr);
221 goto out; 222 goto out;
222 } 223 }
223 224
diff --git a/drivers/gpu/drm/i915/dvo_ivch.c b/drivers/gpu/drm/i915/dvo_ivch.c
index 0c8d375e8e37..aa176f9921fe 100644
--- a/drivers/gpu/drm/i915/dvo_ivch.c
+++ b/drivers/gpu/drm/i915/dvo_ivch.c
@@ -169,13 +169,14 @@ static void ivch_dump_regs(struct intel_dvo_device *dvo);
169static bool ivch_read(struct intel_dvo_device *dvo, int addr, uint16_t *data) 169static bool ivch_read(struct intel_dvo_device *dvo, int addr, uint16_t *data)
170{ 170{
171 struct ivch_priv *priv = dvo->dev_priv; 171 struct ivch_priv *priv = dvo->dev_priv;
172 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 172 struct i2c_adapter *adapter = dvo->i2c_bus;
173 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
173 u8 out_buf[1]; 174 u8 out_buf[1];
174 u8 in_buf[2]; 175 u8 in_buf[2];
175 176
176 struct i2c_msg msgs[] = { 177 struct i2c_msg msgs[] = {
177 { 178 {
178 .addr = i2cbus->slave_addr, 179 .addr = dvo->slave_addr,
179 .flags = I2C_M_RD, 180 .flags = I2C_M_RD,
180 .len = 0, 181 .len = 0,
181 }, 182 },
@@ -186,7 +187,7 @@ static bool ivch_read(struct intel_dvo_device *dvo, int addr, uint16_t *data)
186 .buf = out_buf, 187 .buf = out_buf,
187 }, 188 },
188 { 189 {
189 .addr = i2cbus->slave_addr, 190 .addr = dvo->slave_addr,
190 .flags = I2C_M_RD | I2C_M_NOSTART, 191 .flags = I2C_M_RD | I2C_M_NOSTART,
191 .len = 2, 192 .len = 2,
192 .buf = in_buf, 193 .buf = in_buf,
@@ -202,7 +203,7 @@ static bool ivch_read(struct intel_dvo_device *dvo, int addr, uint16_t *data)
202 203
203 if (!priv->quiet) { 204 if (!priv->quiet) {
204 DRM_DEBUG("Unable to read register 0x%02x from %s:%02x.\n", 205 DRM_DEBUG("Unable to read register 0x%02x from %s:%02x.\n",
205 addr, i2cbus->adapter.name, i2cbus->slave_addr); 206 addr, i2cbus->adapter.name, dvo->slave_addr);
206 } 207 }
207 return false; 208 return false;
208} 209}
@@ -211,10 +212,11 @@ static bool ivch_read(struct intel_dvo_device *dvo, int addr, uint16_t *data)
211static bool ivch_write(struct intel_dvo_device *dvo, int addr, uint16_t data) 212static bool ivch_write(struct intel_dvo_device *dvo, int addr, uint16_t data)
212{ 213{
213 struct ivch_priv *priv = dvo->dev_priv; 214 struct ivch_priv *priv = dvo->dev_priv;
214 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 215 struct i2c_adapter *adapter = dvo->i2c_bus;
216 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
215 u8 out_buf[3]; 217 u8 out_buf[3];
216 struct i2c_msg msg = { 218 struct i2c_msg msg = {
217 .addr = i2cbus->slave_addr, 219 .addr = dvo->slave_addr,
218 .flags = 0, 220 .flags = 0,
219 .len = 3, 221 .len = 3,
220 .buf = out_buf, 222 .buf = out_buf,
@@ -229,7 +231,7 @@ static bool ivch_write(struct intel_dvo_device *dvo, int addr, uint16_t data)
229 231
230 if (!priv->quiet) { 232 if (!priv->quiet) {
231 DRM_DEBUG("Unable to write register 0x%02x to %s:%d.\n", 233 DRM_DEBUG("Unable to write register 0x%02x to %s:%d.\n",
232 addr, i2cbus->adapter.name, i2cbus->slave_addr); 234 addr, i2cbus->adapter.name, dvo->slave_addr);
233 } 235 }
234 236
235 return false; 237 return false;
@@ -237,7 +239,7 @@ static bool ivch_write(struct intel_dvo_device *dvo, int addr, uint16_t data)
237 239
238/** Probes the given bus and slave address for an ivch */ 240/** Probes the given bus and slave address for an ivch */
239static bool ivch_init(struct intel_dvo_device *dvo, 241static bool ivch_init(struct intel_dvo_device *dvo,
240 struct intel_i2c_chan *i2cbus) 242 struct i2c_adapter *adapter)
241{ 243{
242 struct ivch_priv *priv; 244 struct ivch_priv *priv;
243 uint16_t temp; 245 uint16_t temp;
@@ -246,8 +248,7 @@ static bool ivch_init(struct intel_dvo_device *dvo,
246 if (priv == NULL) 248 if (priv == NULL)
247 return false; 249 return false;
248 250
249 dvo->i2c_bus = i2cbus; 251 dvo->i2c_bus = adapter;
250 dvo->i2c_bus->slave_addr = dvo->slave_addr;
251 dvo->dev_priv = priv; 252 dvo->dev_priv = priv;
252 priv->quiet = true; 253 priv->quiet = true;
253 254
diff --git a/drivers/gpu/drm/i915/dvo_sil164.c b/drivers/gpu/drm/i915/dvo_sil164.c
index 033a4bb070b2..e1c1f7341e5c 100644
--- a/drivers/gpu/drm/i915/dvo_sil164.c
+++ b/drivers/gpu/drm/i915/dvo_sil164.c
@@ -76,19 +76,20 @@ struct sil164_priv {
76static bool sil164_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch) 76static bool sil164_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
77{ 77{
78 struct sil164_priv *sil = dvo->dev_priv; 78 struct sil164_priv *sil = dvo->dev_priv;
79 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 79 struct i2c_adapter *adapter = dvo->i2c_bus;
80 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
80 u8 out_buf[2]; 81 u8 out_buf[2];
81 u8 in_buf[2]; 82 u8 in_buf[2];
82 83
83 struct i2c_msg msgs[] = { 84 struct i2c_msg msgs[] = {
84 { 85 {
85 .addr = i2cbus->slave_addr, 86 .addr = dvo->slave_addr,
86 .flags = 0, 87 .flags = 0,
87 .len = 1, 88 .len = 1,
88 .buf = out_buf, 89 .buf = out_buf,
89 }, 90 },
90 { 91 {
91 .addr = i2cbus->slave_addr, 92 .addr = dvo->slave_addr,
92 .flags = I2C_M_RD, 93 .flags = I2C_M_RD,
93 .len = 1, 94 .len = 1,
94 .buf = in_buf, 95 .buf = in_buf,
@@ -105,7 +106,7 @@ static bool sil164_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
105 106
106 if (!sil->quiet) { 107 if (!sil->quiet) {
107 DRM_DEBUG("Unable to read register 0x%02x from %s:%02x.\n", 108 DRM_DEBUG("Unable to read register 0x%02x from %s:%02x.\n",
108 addr, i2cbus->adapter.name, i2cbus->slave_addr); 109 addr, i2cbus->adapter.name, dvo->slave_addr);
109 } 110 }
110 return false; 111 return false;
111} 112}
@@ -113,10 +114,11 @@ static bool sil164_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
113static bool sil164_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch) 114static bool sil164_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch)
114{ 115{
115 struct sil164_priv *sil= dvo->dev_priv; 116 struct sil164_priv *sil= dvo->dev_priv;
116 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 117 struct i2c_adapter *adapter = dvo->i2c_bus;
118 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
117 uint8_t out_buf[2]; 119 uint8_t out_buf[2];
118 struct i2c_msg msg = { 120 struct i2c_msg msg = {
119 .addr = i2cbus->slave_addr, 121 .addr = dvo->slave_addr,
120 .flags = 0, 122 .flags = 0,
121 .len = 2, 123 .len = 2,
122 .buf = out_buf, 124 .buf = out_buf,
@@ -130,7 +132,7 @@ static bool sil164_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch)
130 132
131 if (!sil->quiet) { 133 if (!sil->quiet) {
132 DRM_DEBUG("Unable to write register 0x%02x to %s:%d.\n", 134 DRM_DEBUG("Unable to write register 0x%02x to %s:%d.\n",
133 addr, i2cbus->adapter.name, i2cbus->slave_addr); 135 addr, i2cbus->adapter.name, dvo->slave_addr);
134 } 136 }
135 137
136 return false; 138 return false;
@@ -138,7 +140,7 @@ static bool sil164_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch)
138 140
139/* Silicon Image 164 driver for chip on i2c bus */ 141/* Silicon Image 164 driver for chip on i2c bus */
140static bool sil164_init(struct intel_dvo_device *dvo, 142static bool sil164_init(struct intel_dvo_device *dvo,
141 struct intel_i2c_chan *i2cbus) 143 struct i2c_adapter *adapter)
142{ 144{
143 /* this will detect the SIL164 chip on the specified i2c bus */ 145 /* this will detect the SIL164 chip on the specified i2c bus */
144 struct sil164_priv *sil; 146 struct sil164_priv *sil;
@@ -148,8 +150,7 @@ static bool sil164_init(struct intel_dvo_device *dvo,
148 if (sil == NULL) 150 if (sil == NULL)
149 return false; 151 return false;
150 152
151 dvo->i2c_bus = i2cbus; 153 dvo->i2c_bus = adapter;
152 dvo->i2c_bus->slave_addr = dvo->slave_addr;
153 dvo->dev_priv = sil; 154 dvo->dev_priv = sil;
154 sil->quiet = true; 155 sil->quiet = true;
155 156
@@ -158,7 +159,7 @@ static bool sil164_init(struct intel_dvo_device *dvo,
158 159
159 if (ch != (SIL164_VID & 0xff)) { 160 if (ch != (SIL164_VID & 0xff)) {
160 DRM_DEBUG("sil164 not detected got %d: from %s Slave %d.\n", 161 DRM_DEBUG("sil164 not detected got %d: from %s Slave %d.\n",
161 ch, i2cbus->adapter.name, i2cbus->slave_addr); 162 ch, adapter->name, dvo->slave_addr);
162 goto out; 163 goto out;
163 } 164 }
164 165
@@ -167,7 +168,7 @@ static bool sil164_init(struct intel_dvo_device *dvo,
167 168
168 if (ch != (SIL164_DID & 0xff)) { 169 if (ch != (SIL164_DID & 0xff)) {
169 DRM_DEBUG("sil164 not detected got %d: from %s Slave %d.\n", 170 DRM_DEBUG("sil164 not detected got %d: from %s Slave %d.\n",
170 ch, i2cbus->adapter.name, i2cbus->slave_addr); 171 ch, adapter->name, dvo->slave_addr);
171 goto out; 172 goto out;
172 } 173 }
173 sil->quiet = false; 174 sil->quiet = false;
diff --git a/drivers/gpu/drm/i915/dvo_tfp410.c b/drivers/gpu/drm/i915/dvo_tfp410.c
index 207fda806ebf..9ecc907384ec 100644
--- a/drivers/gpu/drm/i915/dvo_tfp410.c
+++ b/drivers/gpu/drm/i915/dvo_tfp410.c
@@ -101,19 +101,20 @@ struct tfp410_priv {
101static bool tfp410_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch) 101static bool tfp410_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
102{ 102{
103 struct tfp410_priv *tfp = dvo->dev_priv; 103 struct tfp410_priv *tfp = dvo->dev_priv;
104 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 104 struct i2c_adapter *adapter = dvo->i2c_bus;
105 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
105 u8 out_buf[2]; 106 u8 out_buf[2];
106 u8 in_buf[2]; 107 u8 in_buf[2];
107 108
108 struct i2c_msg msgs[] = { 109 struct i2c_msg msgs[] = {
109 { 110 {
110 .addr = i2cbus->slave_addr, 111 .addr = dvo->slave_addr,
111 .flags = 0, 112 .flags = 0,
112 .len = 1, 113 .len = 1,
113 .buf = out_buf, 114 .buf = out_buf,
114 }, 115 },
115 { 116 {
116 .addr = i2cbus->slave_addr, 117 .addr = dvo->slave_addr,
117 .flags = I2C_M_RD, 118 .flags = I2C_M_RD,
118 .len = 1, 119 .len = 1,
119 .buf = in_buf, 120 .buf = in_buf,
@@ -130,7 +131,7 @@ static bool tfp410_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
130 131
131 if (!tfp->quiet) { 132 if (!tfp->quiet) {
132 DRM_DEBUG("Unable to read register 0x%02x from %s:%02x.\n", 133 DRM_DEBUG("Unable to read register 0x%02x from %s:%02x.\n",
133 addr, i2cbus->adapter.name, i2cbus->slave_addr); 134 addr, i2cbus->adapter.name, dvo->slave_addr);
134 } 135 }
135 return false; 136 return false;
136} 137}
@@ -138,10 +139,11 @@ static bool tfp410_readb(struct intel_dvo_device *dvo, int addr, uint8_t *ch)
138static bool tfp410_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch) 139static bool tfp410_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch)
139{ 140{
140 struct tfp410_priv *tfp = dvo->dev_priv; 141 struct tfp410_priv *tfp = dvo->dev_priv;
141 struct intel_i2c_chan *i2cbus = dvo->i2c_bus; 142 struct i2c_adapter *adapter = dvo->i2c_bus;
143 struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter);
142 uint8_t out_buf[2]; 144 uint8_t out_buf[2];
143 struct i2c_msg msg = { 145 struct i2c_msg msg = {
144 .addr = i2cbus->slave_addr, 146 .addr = dvo->slave_addr,
145 .flags = 0, 147 .flags = 0,
146 .len = 2, 148 .len = 2,
147 .buf = out_buf, 149 .buf = out_buf,
@@ -155,7 +157,7 @@ static bool tfp410_writeb(struct intel_dvo_device *dvo, int addr, uint8_t ch)
155 157
156 if (!tfp->quiet) { 158 if (!tfp->quiet) {
157 DRM_DEBUG("Unable to write register 0x%02x to %s:%d.\n", 159 DRM_DEBUG("Unable to write register 0x%02x to %s:%d.\n",
158 addr, i2cbus->adapter.name, i2cbus->slave_addr); 160 addr, i2cbus->adapter.name, dvo->slave_addr);
159 } 161 }
160 162
161 return false; 163 return false;
@@ -174,7 +176,7 @@ static int tfp410_getid(struct intel_dvo_device *dvo, int addr)
174 176
175/* Ti TFP410 driver for chip on i2c bus */ 177/* Ti TFP410 driver for chip on i2c bus */
176static bool tfp410_init(struct intel_dvo_device *dvo, 178static bool tfp410_init(struct intel_dvo_device *dvo,
177 struct intel_i2c_chan *i2cbus) 179 struct i2c_adapter *adapter)
178{ 180{
179 /* this will detect the tfp410 chip on the specified i2c bus */ 181 /* this will detect the tfp410 chip on the specified i2c bus */
180 struct tfp410_priv *tfp; 182 struct tfp410_priv *tfp;
@@ -184,20 +186,19 @@ static bool tfp410_init(struct intel_dvo_device *dvo,
184 if (tfp == NULL) 186 if (tfp == NULL)
185 return false; 187 return false;
186 188
187 dvo->i2c_bus = i2cbus; 189 dvo->i2c_bus = adapter;
188 dvo->i2c_bus->slave_addr = dvo->slave_addr;
189 dvo->dev_priv = tfp; 190 dvo->dev_priv = tfp;
190 tfp->quiet = true; 191 tfp->quiet = true;
191 192
192 if ((id = tfp410_getid(dvo, TFP410_VID_LO)) != TFP410_VID) { 193 if ((id = tfp410_getid(dvo, TFP410_VID_LO)) != TFP410_VID) {
193 DRM_DEBUG("tfp410 not detected got VID %X: from %s Slave %d.\n", 194 DRM_DEBUG("tfp410 not detected got VID %X: from %s Slave %d.\n",
194 id, i2cbus->adapter.name, i2cbus->slave_addr); 195 id, adapter->name, dvo->slave_addr);
195 goto out; 196 goto out;
196 } 197 }
197 198
198 if ((id = tfp410_getid(dvo, TFP410_DID_LO)) != TFP410_DID) { 199 if ((id = tfp410_getid(dvo, TFP410_DID_LO)) != TFP410_DID) {
199 DRM_DEBUG("tfp410 not detected got DID %X: from %s Slave %d.\n", 200 DRM_DEBUG("tfp410 not detected got DID %X: from %s Slave %d.\n",
200 id, i2cbus->adapter.name, i2cbus->slave_addr); 201 id, adapter->name, dvo->slave_addr);
201 goto out; 202 goto out;
202 } 203 }
203 tfp->quiet = false; 204 tfp->quiet = false;
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index f112c769d533..8c4783180bf6 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -846,7 +846,7 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
846 return 0; 846 return 0;
847 } 847 }
848 848
849 printk(KERN_DEBUG "set status page addr 0x%08x\n", (u32)hws->addr); 849 DRM_DEBUG("set status page addr 0x%08x\n", (u32)hws->addr);
850 850
851 dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12); 851 dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12);
852 852
@@ -885,8 +885,8 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
885 * some RAM for the framebuffer at early boot. This code figures out 885 * some RAM for the framebuffer at early boot. This code figures out
886 * how much was set aside so we can use it for our own purposes. 886 * how much was set aside so we can use it for our own purposes.
887 */ 887 */
888static int i915_probe_agp(struct drm_device *dev, unsigned long *aperture_size, 888static int i915_probe_agp(struct drm_device *dev, uint32_t *aperture_size,
889 unsigned long *preallocated_size) 889 uint32_t *preallocated_size)
890{ 890{
891 struct pci_dev *bridge_dev; 891 struct pci_dev *bridge_dev;
892 u16 tmp = 0; 892 u16 tmp = 0;
@@ -984,10 +984,11 @@ static int i915_probe_agp(struct drm_device *dev, unsigned long *aperture_size,
984 return 0; 984 return 0;
985} 985}
986 986
987static int i915_load_modeset_init(struct drm_device *dev) 987static int i915_load_modeset_init(struct drm_device *dev,
988 unsigned long prealloc_size,
989 unsigned long agp_size)
988{ 990{
989 struct drm_i915_private *dev_priv = dev->dev_private; 991 struct drm_i915_private *dev_priv = dev->dev_private;
990 unsigned long agp_size, prealloc_size;
991 int fb_bar = IS_I9XX(dev) ? 2 : 0; 992 int fb_bar = IS_I9XX(dev) ? 2 : 0;
992 int ret = 0; 993 int ret = 0;
993 994
@@ -1002,10 +1003,6 @@ static int i915_load_modeset_init(struct drm_device *dev)
1002 if (IS_I965G(dev) || IS_G33(dev)) 1003 if (IS_I965G(dev) || IS_G33(dev))
1003 dev_priv->cursor_needs_physical = false; 1004 dev_priv->cursor_needs_physical = false;
1004 1005
1005 ret = i915_probe_agp(dev, &agp_size, &prealloc_size);
1006 if (ret)
1007 goto out;
1008
1009 /* Basic memrange allocator for stolen space (aka vram) */ 1006 /* Basic memrange allocator for stolen space (aka vram) */
1010 drm_mm_init(&dev_priv->vram, 0, prealloc_size); 1007 drm_mm_init(&dev_priv->vram, 0, prealloc_size);
1011 1008
@@ -1082,6 +1079,44 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master)
1082 master->driver_priv = NULL; 1079 master->driver_priv = NULL;
1083} 1080}
1084 1081
1082static void i915_get_mem_freq(struct drm_device *dev)
1083{
1084 drm_i915_private_t *dev_priv = dev->dev_private;
1085 u32 tmp;
1086
1087 if (!IS_IGD(dev))
1088 return;
1089
1090 tmp = I915_READ(CLKCFG);
1091
1092 switch (tmp & CLKCFG_FSB_MASK) {
1093 case CLKCFG_FSB_533:
1094 dev_priv->fsb_freq = 533; /* 133*4 */
1095 break;
1096 case CLKCFG_FSB_800:
1097 dev_priv->fsb_freq = 800; /* 200*4 */
1098 break;
1099 case CLKCFG_FSB_667:
1100 dev_priv->fsb_freq = 667; /* 167*4 */
1101 break;
1102 case CLKCFG_FSB_400:
1103 dev_priv->fsb_freq = 400; /* 100*4 */
1104 break;
1105 }
1106
1107 switch (tmp & CLKCFG_MEM_MASK) {
1108 case CLKCFG_MEM_533:
1109 dev_priv->mem_freq = 533;
1110 break;
1111 case CLKCFG_MEM_667:
1112 dev_priv->mem_freq = 667;
1113 break;
1114 case CLKCFG_MEM_800:
1115 dev_priv->mem_freq = 800;
1116 break;
1117 }
1118}
1119
1085/** 1120/**
1086 * i915_driver_load - setup chip and create an initial config 1121 * i915_driver_load - setup chip and create an initial config
1087 * @dev: DRM device 1122 * @dev: DRM device
@@ -1098,6 +1133,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1098 struct drm_i915_private *dev_priv = dev->dev_private; 1133 struct drm_i915_private *dev_priv = dev->dev_private;
1099 resource_size_t base, size; 1134 resource_size_t base, size;
1100 int ret = 0, mmio_bar = IS_I9XX(dev) ? 0 : 1; 1135 int ret = 0, mmio_bar = IS_I9XX(dev) ? 0 : 1;
1136 uint32_t agp_size, prealloc_size;
1101 1137
1102 /* i915 has 4 more counters */ 1138 /* i915 has 4 more counters */
1103 dev->counters += 4; 1139 dev->counters += 4;
@@ -1146,9 +1182,22 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1146 "performance may suffer.\n"); 1182 "performance may suffer.\n");
1147 } 1183 }
1148 1184
1185 ret = i915_probe_agp(dev, &agp_size, &prealloc_size);
1186 if (ret)
1187 goto out_iomapfree;
1188
1149 /* enable GEM by default */ 1189 /* enable GEM by default */
1150 dev_priv->has_gem = 1; 1190 dev_priv->has_gem = 1;
1151 1191
1192 if (prealloc_size > agp_size * 3 / 4) {
1193 DRM_ERROR("Detected broken video BIOS with %d/%dkB of video "
1194 "memory stolen.\n",
1195 prealloc_size / 1024, agp_size / 1024);
1196 DRM_ERROR("Disabling GEM. (try reducing stolen memory or "
1197 "updating the BIOS to fix).\n");
1198 dev_priv->has_gem = 0;
1199 }
1200
1152 dev->driver->get_vblank_counter = i915_get_vblank_counter; 1201 dev->driver->get_vblank_counter = i915_get_vblank_counter;
1153 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */ 1202 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
1154 if (IS_G4X(dev) || IS_IGDNG(dev)) { 1203 if (IS_G4X(dev) || IS_IGDNG(dev)) {
@@ -1165,6 +1214,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1165 goto out_iomapfree; 1214 goto out_iomapfree;
1166 } 1215 }
1167 1216
1217 i915_get_mem_freq(dev);
1218
1168 /* On the 945G/GM, the chipset reports the MSI capability on the 1219 /* On the 945G/GM, the chipset reports the MSI capability on the
1169 * integrated graphics even though the support isn't actually there 1220 * integrated graphics even though the support isn't actually there
1170 * according to the published specs. It doesn't appear to function 1221 * according to the published specs. It doesn't appear to function
@@ -1180,6 +1231,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1180 pci_enable_msi(dev->pdev); 1231 pci_enable_msi(dev->pdev);
1181 1232
1182 spin_lock_init(&dev_priv->user_irq_lock); 1233 spin_lock_init(&dev_priv->user_irq_lock);
1234 spin_lock_init(&dev_priv->error_lock);
1183 dev_priv->user_irq_refcount = 0; 1235 dev_priv->user_irq_refcount = 0;
1184 1236
1185 ret = drm_vblank_init(dev, I915_NUM_PIPE); 1237 ret = drm_vblank_init(dev, I915_NUM_PIPE);
@@ -1190,7 +1242,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1190 } 1242 }
1191 1243
1192 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 1244 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1193 ret = i915_load_modeset_init(dev); 1245 ret = i915_load_modeset_init(dev, prealloc_size, agp_size);
1194 if (ret < 0) { 1246 if (ret < 0) {
1195 DRM_ERROR("failed to init modeset\n"); 1247 DRM_ERROR("failed to init modeset\n");
1196 goto out_rmmap; 1248 goto out_rmmap;
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 98560e1e899a..fc4b68aa2d05 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -35,6 +35,7 @@
35 35
36#include "drm_pciids.h" 36#include "drm_pciids.h"
37#include <linux/console.h> 37#include <linux/console.h>
38#include "drm_crtc_helper.h"
38 39
39static unsigned int i915_modeset = -1; 40static unsigned int i915_modeset = -1;
40module_param_named(modeset, i915_modeset, int, 0400); 41module_param_named(modeset, i915_modeset, int, 0400);
@@ -57,8 +58,8 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
57 struct drm_i915_private *dev_priv = dev->dev_private; 58 struct drm_i915_private *dev_priv = dev->dev_private;
58 59
59 if (!dev || !dev_priv) { 60 if (!dev || !dev_priv) {
60 printk(KERN_ERR "dev: %p, dev_priv: %p\n", dev, dev_priv); 61 DRM_ERROR("dev: %p, dev_priv: %p\n", dev, dev_priv);
61 printk(KERN_ERR "DRM not initialized, aborting suspend.\n"); 62 DRM_ERROR("DRM not initialized, aborting suspend.\n");
62 return -ENODEV; 63 return -ENODEV;
63 } 64 }
64 65
@@ -67,8 +68,6 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
67 68
68 pci_save_state(dev->pdev); 69 pci_save_state(dev->pdev);
69 70
70 i915_save_state(dev);
71
72 /* If KMS is active, we do the leavevt stuff here */ 71 /* If KMS is active, we do the leavevt stuff here */
73 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 72 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
74 if (i915_gem_idle(dev)) 73 if (i915_gem_idle(dev))
@@ -77,6 +76,8 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
77 drm_irq_uninstall(dev); 76 drm_irq_uninstall(dev);
78 } 77 }
79 78
79 i915_save_state(dev);
80
80 intel_opregion_free(dev, 1); 81 intel_opregion_free(dev, 1);
81 82
82 if (state.event == PM_EVENT_SUSPEND) { 83 if (state.event == PM_EVENT_SUSPEND) {
@@ -115,6 +116,10 @@ static int i915_resume(struct drm_device *dev)
115 116
116 drm_irq_install(dev); 117 drm_irq_install(dev);
117 } 118 }
119 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
120 /* Resume the modeset for every activated CRTC */
121 drm_helper_resume_force_mode(dev);
122 }
118 123
119 return ret; 124 return ret;
120} 125}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 7a84f04e8439..d08752875885 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -133,6 +133,22 @@ struct sdvo_device_mapping {
133 u8 initialized; 133 u8 initialized;
134}; 134};
135 135
136struct drm_i915_error_state {
137 u32 eir;
138 u32 pgtbl_er;
139 u32 pipeastat;
140 u32 pipebstat;
141 u32 ipeir;
142 u32 ipehr;
143 u32 instdone;
144 u32 acthd;
145 u32 instpm;
146 u32 instps;
147 u32 instdone1;
148 u32 seqno;
149 struct timeval time;
150};
151
136typedef struct drm_i915_private { 152typedef struct drm_i915_private {
137 struct drm_device *dev; 153 struct drm_device *dev;
138 154
@@ -209,6 +225,11 @@ typedef struct drm_i915_private {
209 int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */ 225 int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */
210 int num_fence_regs; /* 8 on pre-965, 16 otherwise */ 226 int num_fence_regs; /* 8 on pre-965, 16 otherwise */
211 227
228 unsigned int fsb_freq, mem_freq;
229
230 spinlock_t error_lock;
231 struct drm_i915_error_state *first_error;
232
212 /* Register state */ 233 /* Register state */
213 u8 saveLBB; 234 u8 saveLBB;
214 u32 saveDSPACNTR; 235 u32 saveDSPACNTR;
@@ -306,6 +327,17 @@ typedef struct drm_i915_private {
306 u32 saveCURBPOS; 327 u32 saveCURBPOS;
307 u32 saveCURBBASE; 328 u32 saveCURBBASE;
308 u32 saveCURSIZE; 329 u32 saveCURSIZE;
330 u32 saveDP_B;
331 u32 saveDP_C;
332 u32 saveDP_D;
333 u32 savePIPEA_GMCH_DATA_M;
334 u32 savePIPEB_GMCH_DATA_M;
335 u32 savePIPEA_GMCH_DATA_N;
336 u32 savePIPEB_GMCH_DATA_N;
337 u32 savePIPEA_DP_LINK_M;
338 u32 savePIPEB_DP_LINK_M;
339 u32 savePIPEA_DP_LINK_N;
340 u32 savePIPEB_DP_LINK_N;
309 341
310 struct { 342 struct {
311 struct drm_mm gtt_space; 343 struct drm_mm gtt_space;
@@ -457,9 +489,6 @@ struct drm_i915_gem_object {
457 */ 489 */
458 int fence_reg; 490 int fence_reg;
459 491
460 /** Boolean whether this object has a valid gtt offset. */
461 int gtt_bound;
462
463 /** How many users have pinned this object in GTT space */ 492 /** How many users have pinned this object in GTT space */
464 int pin_count; 493 int pin_count;
465 494
@@ -644,6 +673,7 @@ void i915_gem_free_object(struct drm_gem_object *obj);
644int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment); 673int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment);
645void i915_gem_object_unpin(struct drm_gem_object *obj); 674void i915_gem_object_unpin(struct drm_gem_object *obj);
646int i915_gem_object_unbind(struct drm_gem_object *obj); 675int i915_gem_object_unbind(struct drm_gem_object *obj);
676void i915_gem_release_mmap(struct drm_gem_object *obj);
647void i915_gem_lastclose(struct drm_device *dev); 677void i915_gem_lastclose(struct drm_device *dev);
648uint32_t i915_get_gem_seqno(struct drm_device *dev); 678uint32_t i915_get_gem_seqno(struct drm_device *dev);
649int i915_gem_object_get_fence_reg(struct drm_gem_object *obj); 679int i915_gem_object_get_fence_reg(struct drm_gem_object *obj);
@@ -857,7 +887,10 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
857#define HAS_128_BYTE_Y_TILING(dev) (IS_I9XX(dev) && !(IS_I915G(dev) || \ 887#define HAS_128_BYTE_Y_TILING(dev) (IS_I9XX(dev) && !(IS_I915G(dev) || \
858 IS_I915GM(dev))) 888 IS_I915GM(dev)))
859#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev) || IS_IGDNG(dev)) 889#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev) || IS_IGDNG(dev))
890#define SUPPORTS_INTEGRATED_DP(dev) (IS_G4X(dev) || IS_IGDNG(dev))
860#define I915_HAS_HOTPLUG(dev) (IS_I945G(dev) || IS_I945GM(dev) || IS_I965G(dev)) 891#define I915_HAS_HOTPLUG(dev) (IS_I945G(dev) || IS_I945GM(dev) || IS_I965G(dev))
892/* dsparb controlled by hw only */
893#define DSPARB_HWCONTROL(dev) (IS_G4X(dev) || IS_IGDNG(dev))
861 894
862#define PRIMARY_RINGBUFFER_SIZE (128*1024) 895#define PRIMARY_RINGBUFFER_SIZE (128*1024)
863 896
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index fd2b8bdffe3f..5bf420378b6d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1006,7 +1006,7 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
1006 1006
1007 mutex_lock(&dev->struct_mutex); 1007 mutex_lock(&dev->struct_mutex);
1008#if WATCH_BUF 1008#if WATCH_BUF
1009 DRM_INFO("set_domain_ioctl %p(%d), %08x %08x\n", 1009 DRM_INFO("set_domain_ioctl %p(%zd), %08x %08x\n",
1010 obj, obj->size, read_domains, write_domain); 1010 obj, obj->size, read_domains, write_domain);
1011#endif 1011#endif
1012 if (read_domains & I915_GEM_DOMAIN_GTT) { 1012 if (read_domains & I915_GEM_DOMAIN_GTT) {
@@ -1050,7 +1050,7 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
1050 } 1050 }
1051 1051
1052#if WATCH_BUF 1052#if WATCH_BUF
1053 DRM_INFO("%s: sw_finish %d (%p %d)\n", 1053 DRM_INFO("%s: sw_finish %d (%p %zd)\n",
1054 __func__, args->handle, obj, obj->size); 1054 __func__, args->handle, obj, obj->size);
1055#endif 1055#endif
1056 obj_priv = obj->driver_private; 1056 obj_priv = obj->driver_private;
@@ -1252,6 +1252,31 @@ out_free_list:
1252 return ret; 1252 return ret;
1253} 1253}
1254 1254
1255/**
1256 * i915_gem_release_mmap - remove physical page mappings
1257 * @obj: obj in question
1258 *
1259 * Preserve the reservation of the mmaping with the DRM core code, but
1260 * relinquish ownership of the pages back to the system.
1261 *
1262 * It is vital that we remove the page mapping if we have mapped a tiled
1263 * object through the GTT and then lose the fence register due to
1264 * resource pressure. Similarly if the object has been moved out of the
1265 * aperture, than pages mapped into userspace must be revoked. Removing the
1266 * mapping will then trigger a page fault on the next user access, allowing
1267 * fixup by i915_gem_fault().
1268 */
1269void
1270i915_gem_release_mmap(struct drm_gem_object *obj)
1271{
1272 struct drm_device *dev = obj->dev;
1273 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1274
1275 if (dev->dev_mapping)
1276 unmap_mapping_range(dev->dev_mapping,
1277 obj_priv->mmap_offset, obj->size, 1);
1278}
1279
1255static void 1280static void
1256i915_gem_free_mmap_offset(struct drm_gem_object *obj) 1281i915_gem_free_mmap_offset(struct drm_gem_object *obj)
1257{ 1282{
@@ -1861,7 +1886,6 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
1861{ 1886{
1862 struct drm_device *dev = obj->dev; 1887 struct drm_device *dev = obj->dev;
1863 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1888 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1864 loff_t offset;
1865 int ret = 0; 1889 int ret = 0;
1866 1890
1867#if WATCH_BUF 1891#if WATCH_BUF
@@ -1898,9 +1922,7 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
1898 BUG_ON(obj_priv->active); 1922 BUG_ON(obj_priv->active);
1899 1923
1900 /* blow away mappings if mapped through GTT */ 1924 /* blow away mappings if mapped through GTT */
1901 offset = ((loff_t) obj->map_list.hash.key) << PAGE_SHIFT; 1925 i915_gem_release_mmap(obj);
1902 if (dev->dev_mapping)
1903 unmap_mapping_range(dev->dev_mapping, offset, obj->size, 1);
1904 1926
1905 if (obj_priv->fence_reg != I915_FENCE_REG_NONE) 1927 if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
1906 i915_gem_clear_fence_reg(obj); 1928 i915_gem_clear_fence_reg(obj);
@@ -2222,7 +2244,6 @@ try_again:
2222 /* None available, try to steal one or wait for a user to finish */ 2244 /* None available, try to steal one or wait for a user to finish */
2223 if (i == dev_priv->num_fence_regs) { 2245 if (i == dev_priv->num_fence_regs) {
2224 uint32_t seqno = dev_priv->mm.next_gem_seqno; 2246 uint32_t seqno = dev_priv->mm.next_gem_seqno;
2225 loff_t offset;
2226 2247
2227 if (avail == 0) 2248 if (avail == 0)
2228 return -ENOSPC; 2249 return -ENOSPC;
@@ -2274,10 +2295,7 @@ try_again:
2274 * Zap this virtual mapping so we can set up a fence again 2295 * Zap this virtual mapping so we can set up a fence again
2275 * for this object next time we need it. 2296 * for this object next time we need it.
2276 */ 2297 */
2277 offset = ((loff_t) reg->obj->map_list.hash.key) << PAGE_SHIFT; 2298 i915_gem_release_mmap(reg->obj);
2278 if (dev->dev_mapping)
2279 unmap_mapping_range(dev->dev_mapping, offset,
2280 reg->obj->size, 1);
2281 old_obj_priv->fence_reg = I915_FENCE_REG_NONE; 2299 old_obj_priv->fence_reg = I915_FENCE_REG_NONE;
2282 } 2300 }
2283 2301
@@ -2423,7 +2441,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
2423 } 2441 }
2424 2442
2425#if WATCH_BUF 2443#if WATCH_BUF
2426 DRM_INFO("Binding object of size %d at 0x%08x\n", 2444 DRM_INFO("Binding object of size %zd at 0x%08x\n",
2427 obj->size, obj_priv->gtt_offset); 2445 obj->size, obj_priv->gtt_offset);
2428#endif 2446#endif
2429 ret = i915_gem_object_get_pages(obj); 2447 ret = i915_gem_object_get_pages(obj);
@@ -4227,6 +4245,7 @@ i915_gem_lastclose(struct drm_device *dev)
4227void 4245void
4228i915_gem_load(struct drm_device *dev) 4246i915_gem_load(struct drm_device *dev)
4229{ 4247{
4248 int i;
4230 drm_i915_private_t *dev_priv = dev->dev_private; 4249 drm_i915_private_t *dev_priv = dev->dev_private;
4231 4250
4232 spin_lock_init(&dev_priv->mm.active_list_lock); 4251 spin_lock_init(&dev_priv->mm.active_list_lock);
@@ -4246,6 +4265,18 @@ i915_gem_load(struct drm_device *dev)
4246 else 4265 else
4247 dev_priv->num_fence_regs = 8; 4266 dev_priv->num_fence_regs = 8;
4248 4267
4268 /* Initialize fence registers to zero */
4269 if (IS_I965G(dev)) {
4270 for (i = 0; i < 16; i++)
4271 I915_WRITE64(FENCE_REG_965_0 + (i * 8), 0);
4272 } else {
4273 for (i = 0; i < 8; i++)
4274 I915_WRITE(FENCE_REG_830_0 + (i * 4), 0);
4275 if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
4276 for (i = 0; i < 8; i++)
4277 I915_WRITE(FENCE_REG_945_8 + (i * 4), 0);
4278 }
4279
4249 i915_gem_detect_bit_6_swizzle(dev); 4280 i915_gem_detect_bit_6_swizzle(dev);
4250} 4281}
4251 4282
diff --git a/drivers/gpu/drm/i915/i915_gem_debug.c b/drivers/gpu/drm/i915/i915_gem_debug.c
index 8d0b943e2c5a..e602614bd3f8 100644
--- a/drivers/gpu/drm/i915/i915_gem_debug.c
+++ b/drivers/gpu/drm/i915/i915_gem_debug.c
@@ -87,7 +87,7 @@ i915_gem_dump_object(struct drm_gem_object *obj, int len,
87 chunk_len = page_len - chunk; 87 chunk_len = page_len - chunk;
88 if (chunk_len > 128) 88 if (chunk_len > 128)
89 chunk_len = 128; 89 chunk_len = 128;
90 i915_gem_dump_page(obj_priv->page_list[page], 90 i915_gem_dump_page(obj_priv->pages[page],
91 chunk, chunk + chunk_len, 91 chunk, chunk + chunk_len,
92 obj_priv->gtt_offset + 92 obj_priv->gtt_offset +
93 page * PAGE_SIZE, 93 page * PAGE_SIZE,
@@ -143,7 +143,7 @@ i915_gem_object_check_coherency(struct drm_gem_object *obj, int handle)
143 uint32_t *backing_map = NULL; 143 uint32_t *backing_map = NULL;
144 int bad_count = 0; 144 int bad_count = 0;
145 145
146 DRM_INFO("%s: checking coherency of object %p@0x%08x (%d, %dkb):\n", 146 DRM_INFO("%s: checking coherency of object %p@0x%08x (%d, %zdkb):\n",
147 __func__, obj, obj_priv->gtt_offset, handle, 147 __func__, obj, obj_priv->gtt_offset, handle,
148 obj->size / 1024); 148 obj->size / 1024);
149 149
@@ -157,7 +157,7 @@ i915_gem_object_check_coherency(struct drm_gem_object *obj, int handle)
157 for (page = 0; page < obj->size / PAGE_SIZE; page++) { 157 for (page = 0; page < obj->size / PAGE_SIZE; page++) {
158 int i; 158 int i;
159 159
160 backing_map = kmap_atomic(obj_priv->page_list[page], KM_USER0); 160 backing_map = kmap_atomic(obj_priv->pages[page], KM_USER0);
161 161
162 if (backing_map == NULL) { 162 if (backing_map == NULL) {
163 DRM_ERROR("failed to map backing page\n"); 163 DRM_ERROR("failed to map backing page\n");
diff --git a/drivers/gpu/drm/i915/i915_gem_debugfs.c b/drivers/gpu/drm/i915/i915_gem_debugfs.c
index 28146e405e87..9a44bfcb8139 100644
--- a/drivers/gpu/drm/i915/i915_gem_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_gem_debugfs.c
@@ -75,11 +75,10 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
75 case ACTIVE_LIST: 75 case ACTIVE_LIST:
76 seq_printf(m, "Active:\n"); 76 seq_printf(m, "Active:\n");
77 lock = &dev_priv->mm.active_list_lock; 77 lock = &dev_priv->mm.active_list_lock;
78 spin_lock(lock);
79 head = &dev_priv->mm.active_list; 78 head = &dev_priv->mm.active_list;
80 break; 79 break;
81 case INACTIVE_LIST: 80 case INACTIVE_LIST:
82 seq_printf(m, "Inctive:\n"); 81 seq_printf(m, "Inactive:\n");
83 head = &dev_priv->mm.inactive_list; 82 head = &dev_priv->mm.inactive_list;
84 break; 83 break;
85 case FLUSHING_LIST: 84 case FLUSHING_LIST:
@@ -91,6 +90,8 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
91 return 0; 90 return 0;
92 } 91 }
93 92
93 if (lock)
94 spin_lock(lock);
94 list_for_each_entry(obj_priv, head, list) 95 list_for_each_entry(obj_priv, head, list)
95 { 96 {
96 struct drm_gem_object *obj = obj_priv->obj; 97 struct drm_gem_object *obj = obj_priv->obj;
@@ -104,7 +105,10 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
104 if (obj->name) 105 if (obj->name)
105 seq_printf(m, " (name: %d)", obj->name); 106 seq_printf(m, " (name: %d)", obj->name);
106 if (obj_priv->fence_reg != I915_FENCE_REG_NONE) 107 if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
107 seq_printf(m, " (fence: %d)\n", obj_priv->fence_reg); 108 seq_printf(m, " (fence: %d)", obj_priv->fence_reg);
109 if (obj_priv->gtt_space != NULL)
110 seq_printf(m, " (gtt_offset: %08x)", obj_priv->gtt_offset);
111
108 seq_printf(m, "\n"); 112 seq_printf(m, "\n");
109 } 113 }
110 114
@@ -323,6 +327,39 @@ static int i915_ringbuffer_info(struct seq_file *m, void *data)
323 return 0; 327 return 0;
324} 328}
325 329
330static int i915_error_state(struct seq_file *m, void *unused)
331{
332 struct drm_info_node *node = (struct drm_info_node *) m->private;
333 struct drm_device *dev = node->minor->dev;
334 drm_i915_private_t *dev_priv = dev->dev_private;
335 struct drm_i915_error_state *error;
336 unsigned long flags;
337
338 spin_lock_irqsave(&dev_priv->error_lock, flags);
339 if (!dev_priv->first_error) {
340 seq_printf(m, "no error state collected\n");
341 goto out;
342 }
343
344 error = dev_priv->first_error;
345
346 seq_printf(m, "EIR: 0x%08x\n", error->eir);
347 seq_printf(m, " PGTBL_ER: 0x%08x\n", error->pgtbl_er);
348 seq_printf(m, " INSTPM: 0x%08x\n", error->instpm);
349 seq_printf(m, " IPEIR: 0x%08x\n", error->ipeir);
350 seq_printf(m, " IPEHR: 0x%08x\n", error->ipehr);
351 seq_printf(m, " INSTDONE: 0x%08x\n", error->instdone);
352 seq_printf(m, " ACTHD: 0x%08x\n", error->acthd);
353 if (IS_I965G(dev)) {
354 seq_printf(m, " INSTPS: 0x%08x\n", error->instps);
355 seq_printf(m, " INSTDONE1: 0x%08x\n", error->instdone1);
356 }
357
358out:
359 spin_unlock_irqrestore(&dev_priv->error_lock, flags);
360
361 return 0;
362}
326 363
327static struct drm_info_list i915_gem_debugfs_list[] = { 364static struct drm_info_list i915_gem_debugfs_list[] = {
328 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST}, 365 {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
@@ -336,6 +373,7 @@ static struct drm_info_list i915_gem_debugfs_list[] = {
336 {"i915_ringbuffer_data", i915_ringbuffer_data, 0}, 373 {"i915_ringbuffer_data", i915_ringbuffer_data, 0},
337 {"i915_ringbuffer_info", i915_ringbuffer_info, 0}, 374 {"i915_ringbuffer_info", i915_ringbuffer_info, 0},
338 {"i915_batchbuffers", i915_batchbuffer_info, 0}, 375 {"i915_batchbuffers", i915_batchbuffer_info, 0},
376 {"i915_error_state", i915_error_state, 0},
339}; 377};
340#define I915_GEM_DEBUGFS_ENTRIES ARRAY_SIZE(i915_gem_debugfs_list) 378#define I915_GEM_DEBUGFS_ENTRIES ARRAY_SIZE(i915_gem_debugfs_list)
341 379
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index 5c1ceec49f5b..a2d527b22ec4 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -114,11 +114,13 @@ intel_alloc_mchbar_resource(struct drm_device *dev)
114 mchbar_addr = ((u64)temp_hi << 32) | temp_lo; 114 mchbar_addr = ((u64)temp_hi << 32) | temp_lo;
115 115
116 /* If ACPI doesn't have it, assume we need to allocate it ourselves */ 116 /* If ACPI doesn't have it, assume we need to allocate it ourselves */
117#ifdef CONFIG_PNP
117 if (mchbar_addr && 118 if (mchbar_addr &&
118 pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE)) { 119 pnp_range_reserved(mchbar_addr, mchbar_addr + MCHBAR_SIZE)) {
119 ret = 0; 120 ret = 0;
120 goto out_put; 121 goto out_put;
121 } 122 }
123#endif
122 124
123 /* Get some space for it */ 125 /* Get some space for it */
124 ret = pci_bus_alloc_resource(bridge_dev->bus, &dev_priv->mch_res, 126 ret = pci_bus_alloc_resource(bridge_dev->bus, &dev_priv->mch_res,
@@ -519,6 +521,12 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
519 goto err; 521 goto err;
520 } 522 }
521 523
524 /* If we've changed tiling, GTT-mappings of the object
525 * need to re-fault to ensure that the correct fence register
526 * setup is in place.
527 */
528 i915_gem_release_mmap(obj);
529
522 obj_priv->tiling_mode = args->tiling_mode; 530 obj_priv->tiling_mode = args->tiling_mode;
523 obj_priv->stride = args->stride; 531 obj_priv->stride = args->stride;
524 } 532 }
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index b86b7b7130c6..7ba23a69a0c0 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -26,6 +26,7 @@
26 * 26 *
27 */ 27 */
28 28
29#include <linux/sysrq.h>
29#include "drmP.h" 30#include "drmP.h"
30#include "drm.h" 31#include "drm.h"
31#include "i915_drm.h" 32#include "i915_drm.h"
@@ -41,9 +42,10 @@
41 * we leave them always unmasked in IMR and then control enabling them through 42 * we leave them always unmasked in IMR and then control enabling them through
42 * PIPESTAT alone. 43 * PIPESTAT alone.
43 */ 44 */
44#define I915_INTERRUPT_ENABLE_FIX (I915_ASLE_INTERRUPT | \ 45#define I915_INTERRUPT_ENABLE_FIX (I915_ASLE_INTERRUPT | \
45 I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \ 46 I915_DISPLAY_PIPE_A_EVENT_INTERRUPT | \
46 I915_DISPLAY_PIPE_B_EVENT_INTERRUPT) 47 I915_DISPLAY_PIPE_B_EVENT_INTERRUPT | \
48 I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
47 49
48/** Interrupts that we mask and unmask at runtime. */ 50/** Interrupts that we mask and unmask at runtime. */
49#define I915_INTERRUPT_ENABLE_VAR (I915_USER_INTERRUPT) 51#define I915_INTERRUPT_ENABLE_VAR (I915_USER_INTERRUPT)
@@ -232,7 +234,17 @@ static void i915_hotplug_work_func(struct work_struct *work)
232 drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t, 234 drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t,
233 hotplug_work); 235 hotplug_work);
234 struct drm_device *dev = dev_priv->dev; 236 struct drm_device *dev = dev_priv->dev;
235 237 struct drm_mode_config *mode_config = &dev->mode_config;
238 struct drm_connector *connector;
239
240 if (mode_config->num_connector) {
241 list_for_each_entry(connector, &mode_config->connector_list, head) {
242 struct intel_output *intel_output = to_intel_output(connector);
243
244 if (intel_output->hot_plug)
245 (*intel_output->hot_plug) (intel_output);
246 }
247 }
236 /* Just fire off a uevent and let userspace tell us what to do */ 248 /* Just fire off a uevent and let userspace tell us what to do */
237 drm_sysfs_hotplug_event(dev); 249 drm_sysfs_hotplug_event(dev);
238} 250}
@@ -278,6 +290,47 @@ irqreturn_t igdng_irq_handler(struct drm_device *dev)
278 return ret; 290 return ret;
279} 291}
280 292
293static void i915_capture_error_state(struct drm_device *dev)
294{
295 struct drm_i915_private *dev_priv = dev->dev_private;
296 struct drm_i915_error_state *error;
297 unsigned long flags;
298
299 spin_lock_irqsave(&dev_priv->error_lock, flags);
300 if (dev_priv->first_error)
301 goto out;
302
303 error = kmalloc(sizeof(*error), GFP_ATOMIC);
304 if (!error) {
305 DRM_DEBUG("out ot memory, not capturing error state\n");
306 goto out;
307 }
308
309 error->eir = I915_READ(EIR);
310 error->pgtbl_er = I915_READ(PGTBL_ER);
311 error->pipeastat = I915_READ(PIPEASTAT);
312 error->pipebstat = I915_READ(PIPEBSTAT);
313 error->instpm = I915_READ(INSTPM);
314 if (!IS_I965G(dev)) {
315 error->ipeir = I915_READ(IPEIR);
316 error->ipehr = I915_READ(IPEHR);
317 error->instdone = I915_READ(INSTDONE);
318 error->acthd = I915_READ(ACTHD);
319 } else {
320 error->ipeir = I915_READ(IPEIR_I965);
321 error->ipehr = I915_READ(IPEHR_I965);
322 error->instdone = I915_READ(INSTDONE_I965);
323 error->instps = I915_READ(INSTPS);
324 error->instdone1 = I915_READ(INSTDONE1);
325 error->acthd = I915_READ(ACTHD_I965);
326 }
327
328 dev_priv->first_error = error;
329
330out:
331 spin_unlock_irqrestore(&dev_priv->error_lock, flags);
332}
333
281irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) 334irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
282{ 335{
283 struct drm_device *dev = (struct drm_device *) arg; 336 struct drm_device *dev = (struct drm_device *) arg;
@@ -323,11 +376,15 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
323 * Clear the PIPE(A|B)STAT regs before the IIR 376 * Clear the PIPE(A|B)STAT regs before the IIR
324 */ 377 */
325 if (pipea_stats & 0x8000ffff) { 378 if (pipea_stats & 0x8000ffff) {
379 if (pipea_stats & PIPE_FIFO_UNDERRUN_STATUS)
380 DRM_DEBUG("pipe a underrun\n");
326 I915_WRITE(PIPEASTAT, pipea_stats); 381 I915_WRITE(PIPEASTAT, pipea_stats);
327 irq_received = 1; 382 irq_received = 1;
328 } 383 }
329 384
330 if (pipeb_stats & 0x8000ffff) { 385 if (pipeb_stats & 0x8000ffff) {
386 if (pipeb_stats & PIPE_FIFO_UNDERRUN_STATUS)
387 DRM_DEBUG("pipe b underrun\n");
331 I915_WRITE(PIPEBSTAT, pipeb_stats); 388 I915_WRITE(PIPEBSTAT, pipeb_stats);
332 irq_received = 1; 389 irq_received = 1;
333 } 390 }
@@ -352,6 +409,80 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
352 I915_READ(PORT_HOTPLUG_STAT); 409 I915_READ(PORT_HOTPLUG_STAT);
353 } 410 }
354 411
412 if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) {
413 u32 eir = I915_READ(EIR);
414
415 i915_capture_error_state(dev);
416
417 printk(KERN_ERR "render error detected, EIR: 0x%08x\n",
418 eir);
419 if (eir & I915_ERROR_PAGE_TABLE) {
420 u32 pgtbl_err = I915_READ(PGTBL_ER);
421 printk(KERN_ERR "page table error\n");
422 printk(KERN_ERR " PGTBL_ER: 0x%08x\n",
423 pgtbl_err);
424 I915_WRITE(PGTBL_ER, pgtbl_err);
425 (void)I915_READ(PGTBL_ER);
426 }
427 if (eir & I915_ERROR_MEMORY_REFRESH) {
428 printk(KERN_ERR "memory refresh error\n");
429 printk(KERN_ERR "PIPEASTAT: 0x%08x\n",
430 pipea_stats);
431 printk(KERN_ERR "PIPEBSTAT: 0x%08x\n",
432 pipeb_stats);
433 /* pipestat has already been acked */
434 }
435 if (eir & I915_ERROR_INSTRUCTION) {
436 printk(KERN_ERR "instruction error\n");
437 printk(KERN_ERR " INSTPM: 0x%08x\n",
438 I915_READ(INSTPM));
439 if (!IS_I965G(dev)) {
440 u32 ipeir = I915_READ(IPEIR);
441
442 printk(KERN_ERR " IPEIR: 0x%08x\n",
443 I915_READ(IPEIR));
444 printk(KERN_ERR " IPEHR: 0x%08x\n",
445 I915_READ(IPEHR));
446 printk(KERN_ERR " INSTDONE: 0x%08x\n",
447 I915_READ(INSTDONE));
448 printk(KERN_ERR " ACTHD: 0x%08x\n",
449 I915_READ(ACTHD));
450 I915_WRITE(IPEIR, ipeir);
451 (void)I915_READ(IPEIR);
452 } else {
453 u32 ipeir = I915_READ(IPEIR_I965);
454
455 printk(KERN_ERR " IPEIR: 0x%08x\n",
456 I915_READ(IPEIR_I965));
457 printk(KERN_ERR " IPEHR: 0x%08x\n",
458 I915_READ(IPEHR_I965));
459 printk(KERN_ERR " INSTDONE: 0x%08x\n",
460 I915_READ(INSTDONE_I965));
461 printk(KERN_ERR " INSTPS: 0x%08x\n",
462 I915_READ(INSTPS));
463 printk(KERN_ERR " INSTDONE1: 0x%08x\n",
464 I915_READ(INSTDONE1));
465 printk(KERN_ERR " ACTHD: 0x%08x\n",
466 I915_READ(ACTHD_I965));
467 I915_WRITE(IPEIR_I965, ipeir);
468 (void)I915_READ(IPEIR_I965);
469 }
470 }
471
472 I915_WRITE(EIR, eir);
473 (void)I915_READ(EIR);
474 eir = I915_READ(EIR);
475 if (eir) {
476 /*
477 * some errors might have become stuck,
478 * mask them.
479 */
480 DRM_ERROR("EIR stuck: 0x%08x, masking\n", eir);
481 I915_WRITE(EMR, I915_READ(EMR) | eir);
482 I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
483 }
484 }
485
355 I915_WRITE(IIR, iir); 486 I915_WRITE(IIR, iir);
356 new_iir = I915_READ(IIR); /* Flush posted writes */ 487 new_iir = I915_READ(IIR); /* Flush posted writes */
357 488
@@ -722,6 +853,7 @@ int i915_driver_irq_postinstall(struct drm_device *dev)
722{ 853{
723 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 854 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
724 u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR; 855 u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR;
856 u32 error_mask;
725 857
726 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); 858 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
727 859
@@ -758,6 +890,21 @@ int i915_driver_irq_postinstall(struct drm_device *dev)
758 i915_enable_irq(dev_priv, I915_DISPLAY_PORT_INTERRUPT); 890 i915_enable_irq(dev_priv, I915_DISPLAY_PORT_INTERRUPT);
759 } 891 }
760 892
893 /*
894 * Enable some error detection, note the instruction error mask
895 * bit is reserved, so we leave it masked.
896 */
897 if (IS_G4X(dev)) {
898 error_mask = ~(GM45_ERROR_PAGE_TABLE |
899 GM45_ERROR_MEM_PRIV |
900 GM45_ERROR_CP_PRIV |
901 I915_ERROR_MEMORY_REFRESH);
902 } else {
903 error_mask = ~(I915_ERROR_PAGE_TABLE |
904 I915_ERROR_MEMORY_REFRESH);
905 }
906 I915_WRITE(EMR, error_mask);
907
761 /* Disable pipe interrupt enables, clear pending pipe status */ 908 /* Disable pipe interrupt enables, clear pending pipe status */
762 I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff); 909 I915_WRITE(PIPEASTAT, I915_READ(PIPEASTAT) & 0x8000ffff);
763 I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff); 910 I915_WRITE(PIPEBSTAT, I915_READ(PIPEBSTAT) & 0x8000ffff);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index f6237a0b1133..6c0858484094 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -206,6 +206,7 @@
206/* 206/*
207 * Instruction and interrupt control regs 207 * Instruction and interrupt control regs
208 */ 208 */
209#define PGTBL_ER 0x02024
209#define PRB0_TAIL 0x02030 210#define PRB0_TAIL 0x02030
210#define PRB0_HEAD 0x02034 211#define PRB0_HEAD 0x02034
211#define PRB0_START 0x02038 212#define PRB0_START 0x02038
@@ -226,11 +227,18 @@
226#define PRB1_HEAD 0x02044 /* 915+ only */ 227#define PRB1_HEAD 0x02044 /* 915+ only */
227#define PRB1_START 0x02048 /* 915+ only */ 228#define PRB1_START 0x02048 /* 915+ only */
228#define PRB1_CTL 0x0204c /* 915+ only */ 229#define PRB1_CTL 0x0204c /* 915+ only */
230#define IPEIR_I965 0x02064
231#define IPEHR_I965 0x02068
232#define INSTDONE_I965 0x0206c
233#define INSTPS 0x02070 /* 965+ only */
234#define INSTDONE1 0x0207c /* 965+ only */
229#define ACTHD_I965 0x02074 235#define ACTHD_I965 0x02074
230#define HWS_PGA 0x02080 236#define HWS_PGA 0x02080
231#define HWS_ADDRESS_MASK 0xfffff000 237#define HWS_ADDRESS_MASK 0xfffff000
232#define HWS_START_ADDRESS_SHIFT 4 238#define HWS_START_ADDRESS_SHIFT 4
233#define IPEIR 0x02088 239#define IPEIR 0x02088
240#define IPEHR 0x0208c
241#define INSTDONE 0x02090
234#define NOPID 0x02094 242#define NOPID 0x02094
235#define HWSTAM 0x02098 243#define HWSTAM 0x02098
236#define SCPD0 0x0209c /* 915+ only */ 244#define SCPD0 0x0209c /* 915+ only */
@@ -258,10 +266,22 @@
258#define EIR 0x020b0 266#define EIR 0x020b0
259#define EMR 0x020b4 267#define EMR 0x020b4
260#define ESR 0x020b8 268#define ESR 0x020b8
269#define GM45_ERROR_PAGE_TABLE (1<<5)
270#define GM45_ERROR_MEM_PRIV (1<<4)
271#define I915_ERROR_PAGE_TABLE (1<<4)
272#define GM45_ERROR_CP_PRIV (1<<3)
273#define I915_ERROR_MEMORY_REFRESH (1<<1)
274#define I915_ERROR_INSTRUCTION (1<<0)
261#define INSTPM 0x020c0 275#define INSTPM 0x020c0
262#define ACTHD 0x020c8 276#define ACTHD 0x020c8
263#define FW_BLC 0x020d8 277#define FW_BLC 0x020d8
278#define FW_BLC2 0x020dc
264#define FW_BLC_SELF 0x020e0 /* 915+ only */ 279#define FW_BLC_SELF 0x020e0 /* 915+ only */
280#define FW_BLC_SELF_EN (1<<15)
281#define MM_BURST_LENGTH 0x00700000
282#define MM_FIFO_WATERMARK 0x0001F000
283#define LM_BURST_LENGTH 0x00000700
284#define LM_FIFO_WATERMARK 0x0000001F
265#define MI_ARB_STATE 0x020e4 /* 915+ only */ 285#define MI_ARB_STATE 0x020e4 /* 915+ only */
266#define CACHE_MODE_0 0x02120 /* 915+ only */ 286#define CACHE_MODE_0 0x02120 /* 915+ only */
267#define CM0_MASK_SHIFT 16 287#define CM0_MASK_SHIFT 16
@@ -569,6 +589,23 @@
569#define C0DRB3 0x10206 589#define C0DRB3 0x10206
570#define C1DRB3 0x10606 590#define C1DRB3 0x10606
571 591
592/* Clocking configuration register */
593#define CLKCFG 0x10c00
594#define CLKCFG_FSB_400 (5 << 0) /* hrawclk 100 */
595#define CLKCFG_FSB_533 (1 << 0) /* hrawclk 133 */
596#define CLKCFG_FSB_667 (3 << 0) /* hrawclk 166 */
597#define CLKCFG_FSB_800 (2 << 0) /* hrawclk 200 */
598#define CLKCFG_FSB_1067 (6 << 0) /* hrawclk 266 */
599#define CLKCFG_FSB_1333 (7 << 0) /* hrawclk 333 */
600/* Note, below two are guess */
601#define CLKCFG_FSB_1600 (4 << 0) /* hrawclk 400 */
602#define CLKCFG_FSB_1600_ALT (0 << 0) /* hrawclk 400 */
603#define CLKCFG_FSB_MASK (7 << 0)
604#define CLKCFG_MEM_533 (1 << 4)
605#define CLKCFG_MEM_667 (2 << 4)
606#define CLKCFG_MEM_800 (3 << 4)
607#define CLKCFG_MEM_MASK (7 << 4)
608
572/** GM965 GM45 render standby register */ 609/** GM965 GM45 render standby register */
573#define MCHBAR_RENDER_STANDBY 0x111B8 610#define MCHBAR_RENDER_STANDBY 0x111B8
574 611
@@ -834,9 +871,25 @@
834#define HORIZ_INTERP_MASK (3 << 6) 871#define HORIZ_INTERP_MASK (3 << 6)
835#define HORIZ_AUTO_SCALE (1 << 5) 872#define HORIZ_AUTO_SCALE (1 << 5)
836#define PANEL_8TO6_DITHER_ENABLE (1 << 3) 873#define PANEL_8TO6_DITHER_ENABLE (1 << 3)
874#define PFIT_FILTER_FUZZY (0 << 24)
875#define PFIT_SCALING_AUTO (0 << 26)
876#define PFIT_SCALING_PROGRAMMED (1 << 26)
877#define PFIT_SCALING_PILLAR (2 << 26)
878#define PFIT_SCALING_LETTER (3 << 26)
837#define PFIT_PGM_RATIOS 0x61234 879#define PFIT_PGM_RATIOS 0x61234
838#define PFIT_VERT_SCALE_MASK 0xfff00000 880#define PFIT_VERT_SCALE_MASK 0xfff00000
839#define PFIT_HORIZ_SCALE_MASK 0x0000fff0 881#define PFIT_HORIZ_SCALE_MASK 0x0000fff0
882/* Pre-965 */
883#define PFIT_VERT_SCALE_SHIFT 20
884#define PFIT_VERT_SCALE_MASK 0xfff00000
885#define PFIT_HORIZ_SCALE_SHIFT 4
886#define PFIT_HORIZ_SCALE_MASK 0x0000fff0
887/* 965+ */
888#define PFIT_VERT_SCALE_SHIFT_965 16
889#define PFIT_VERT_SCALE_MASK_965 0x1fff0000
890#define PFIT_HORIZ_SCALE_SHIFT_965 0
891#define PFIT_HORIZ_SCALE_MASK_965 0x00001fff
892
840#define PFIT_AUTO_RATIOS 0x61238 893#define PFIT_AUTO_RATIOS 0x61238
841 894
842/* Backlight control */ 895/* Backlight control */
@@ -1552,6 +1605,34 @@
1552#define DSPARB_CSTART_SHIFT 7 1605#define DSPARB_CSTART_SHIFT 7
1553#define DSPARB_BSTART_MASK (0x7f) 1606#define DSPARB_BSTART_MASK (0x7f)
1554#define DSPARB_BSTART_SHIFT 0 1607#define DSPARB_BSTART_SHIFT 0
1608#define DSPARB_BEND_SHIFT 9 /* on 855 */
1609#define DSPARB_AEND_SHIFT 0
1610
1611#define DSPFW1 0x70034
1612#define DSPFW2 0x70038
1613#define DSPFW3 0x7003c
1614#define IGD_SELF_REFRESH_EN (1<<30)
1615
1616/* FIFO watermark sizes etc */
1617#define I915_FIFO_LINE_SIZE 64
1618#define I830_FIFO_LINE_SIZE 32
1619#define I945_FIFO_SIZE 127 /* 945 & 965 */
1620#define I915_FIFO_SIZE 95
1621#define I855GM_FIFO_SIZE 255
1622#define I830_FIFO_SIZE 95
1623#define I915_MAX_WM 0x3f
1624
1625#define IGD_DISPLAY_FIFO 512 /* in 64byte unit */
1626#define IGD_FIFO_LINE_SIZE 64
1627#define IGD_MAX_WM 0x1ff
1628#define IGD_DFT_WM 0x3f
1629#define IGD_DFT_HPLLOFF_WM 0
1630#define IGD_GUARD_WM 10
1631#define IGD_CURSOR_FIFO 64
1632#define IGD_CURSOR_MAX_WM 0x3f
1633#define IGD_CURSOR_DFT_WM 0
1634#define IGD_CURSOR_GUARD_WM 5
1635
1555/* 1636/*
1556 * The two pipe frame counter registers are not synchronized, so 1637 * The two pipe frame counter registers are not synchronized, so
1557 * reading a stable value is somewhat tricky. The following code 1638 * reading a stable value is somewhat tricky. The following code
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index a98e2831ed31..9e1d16e5c3ea 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -222,23 +222,12 @@ static void i915_restore_vga(struct drm_device *dev)
222 I915_WRITE8(VGA_DACMASK, dev_priv->saveDACMASK); 222 I915_WRITE8(VGA_DACMASK, dev_priv->saveDACMASK);
223} 223}
224 224
225int i915_save_state(struct drm_device *dev) 225static void i915_save_modeset_reg(struct drm_device *dev)
226{ 226{
227 struct drm_i915_private *dev_priv = dev->dev_private; 227 struct drm_i915_private *dev_priv = dev->dev_private;
228 int i;
229
230 pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB);
231
232 /* Render Standby */
233 if (IS_I965G(dev) && IS_MOBILE(dev))
234 dev_priv->saveRENDERSTANDBY = I915_READ(MCHBAR_RENDER_STANDBY);
235
236 /* Hardware status page */
237 dev_priv->saveHWS = I915_READ(HWS_PGA);
238
239 /* Display arbitration control */
240 dev_priv->saveDSPARB = I915_READ(DSPARB);
241 228
229 if (drm_core_check_feature(dev, DRIVER_MODESET))
230 return;
242 /* Pipe & plane A info */ 231 /* Pipe & plane A info */
243 dev_priv->savePIPEACONF = I915_READ(PIPEACONF); 232 dev_priv->savePIPEACONF = I915_READ(PIPEACONF);
244 dev_priv->savePIPEASRC = I915_READ(PIPEASRC); 233 dev_priv->savePIPEASRC = I915_READ(PIPEASRC);
@@ -294,7 +283,122 @@ int i915_save_state(struct drm_device *dev)
294 } 283 }
295 i915_save_palette(dev, PIPE_B); 284 i915_save_palette(dev, PIPE_B);
296 dev_priv->savePIPEBSTAT = I915_READ(PIPEBSTAT); 285 dev_priv->savePIPEBSTAT = I915_READ(PIPEBSTAT);
286 return;
287}
288static void i915_restore_modeset_reg(struct drm_device *dev)
289{
290 struct drm_i915_private *dev_priv = dev->dev_private;
291
292 if (drm_core_check_feature(dev, DRIVER_MODESET))
293 return;
294
295 /* Pipe & plane A info */
296 /* Prime the clock */
297 if (dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) {
298 I915_WRITE(DPLL_A, dev_priv->saveDPLL_A &
299 ~DPLL_VCO_ENABLE);
300 DRM_UDELAY(150);
301 }
302 I915_WRITE(FPA0, dev_priv->saveFPA0);
303 I915_WRITE(FPA1, dev_priv->saveFPA1);
304 /* Actually enable it */
305 I915_WRITE(DPLL_A, dev_priv->saveDPLL_A);
306 DRM_UDELAY(150);
307 if (IS_I965G(dev))
308 I915_WRITE(DPLL_A_MD, dev_priv->saveDPLL_A_MD);
309 DRM_UDELAY(150);
310
311 /* Restore mode */
312 I915_WRITE(HTOTAL_A, dev_priv->saveHTOTAL_A);
313 I915_WRITE(HBLANK_A, dev_priv->saveHBLANK_A);
314 I915_WRITE(HSYNC_A, dev_priv->saveHSYNC_A);
315 I915_WRITE(VTOTAL_A, dev_priv->saveVTOTAL_A);
316 I915_WRITE(VBLANK_A, dev_priv->saveVBLANK_A);
317 I915_WRITE(VSYNC_A, dev_priv->saveVSYNC_A);
318 I915_WRITE(BCLRPAT_A, dev_priv->saveBCLRPAT_A);
319
320 /* Restore plane info */
321 I915_WRITE(DSPASIZE, dev_priv->saveDSPASIZE);
322 I915_WRITE(DSPAPOS, dev_priv->saveDSPAPOS);
323 I915_WRITE(PIPEASRC, dev_priv->savePIPEASRC);
324 I915_WRITE(DSPAADDR, dev_priv->saveDSPAADDR);
325 I915_WRITE(DSPASTRIDE, dev_priv->saveDSPASTRIDE);
326 if (IS_I965G(dev)) {
327 I915_WRITE(DSPASURF, dev_priv->saveDSPASURF);
328 I915_WRITE(DSPATILEOFF, dev_priv->saveDSPATILEOFF);
329 }
330
331 I915_WRITE(PIPEACONF, dev_priv->savePIPEACONF);
332
333 i915_restore_palette(dev, PIPE_A);
334 /* Enable the plane */
335 I915_WRITE(DSPACNTR, dev_priv->saveDSPACNTR);
336 I915_WRITE(DSPAADDR, I915_READ(DSPAADDR));
337
338 /* Pipe & plane B info */
339 if (dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) {
340 I915_WRITE(DPLL_B, dev_priv->saveDPLL_B &
341 ~DPLL_VCO_ENABLE);
342 DRM_UDELAY(150);
343 }
344 I915_WRITE(FPB0, dev_priv->saveFPB0);
345 I915_WRITE(FPB1, dev_priv->saveFPB1);
346 /* Actually enable it */
347 I915_WRITE(DPLL_B, dev_priv->saveDPLL_B);
348 DRM_UDELAY(150);
349 if (IS_I965G(dev))
350 I915_WRITE(DPLL_B_MD, dev_priv->saveDPLL_B_MD);
351 DRM_UDELAY(150);
352
353 /* Restore mode */
354 I915_WRITE(HTOTAL_B, dev_priv->saveHTOTAL_B);
355 I915_WRITE(HBLANK_B, dev_priv->saveHBLANK_B);
356 I915_WRITE(HSYNC_B, dev_priv->saveHSYNC_B);
357 I915_WRITE(VTOTAL_B, dev_priv->saveVTOTAL_B);
358 I915_WRITE(VBLANK_B, dev_priv->saveVBLANK_B);
359 I915_WRITE(VSYNC_B, dev_priv->saveVSYNC_B);
360 I915_WRITE(BCLRPAT_B, dev_priv->saveBCLRPAT_B);
361
362 /* Restore plane info */
363 I915_WRITE(DSPBSIZE, dev_priv->saveDSPBSIZE);
364 I915_WRITE(DSPBPOS, dev_priv->saveDSPBPOS);
365 I915_WRITE(PIPEBSRC, dev_priv->savePIPEBSRC);
366 I915_WRITE(DSPBADDR, dev_priv->saveDSPBADDR);
367 I915_WRITE(DSPBSTRIDE, dev_priv->saveDSPBSTRIDE);
368 if (IS_I965G(dev)) {
369 I915_WRITE(DSPBSURF, dev_priv->saveDSPBSURF);
370 I915_WRITE(DSPBTILEOFF, dev_priv->saveDSPBTILEOFF);
371 }
372
373 I915_WRITE(PIPEBCONF, dev_priv->savePIPEBCONF);
374
375 i915_restore_palette(dev, PIPE_B);
376 /* Enable the plane */
377 I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR);
378 I915_WRITE(DSPBADDR, I915_READ(DSPBADDR));
297 379
380 return;
381}
382int i915_save_state(struct drm_device *dev)
383{
384 struct drm_i915_private *dev_priv = dev->dev_private;
385 int i;
386
387 pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB);
388
389 /* Render Standby */
390 if (IS_I965G(dev) && IS_MOBILE(dev))
391 dev_priv->saveRENDERSTANDBY = I915_READ(MCHBAR_RENDER_STANDBY);
392
393 /* Hardware status page */
394 dev_priv->saveHWS = I915_READ(HWS_PGA);
395
396 /* Display arbitration control */
397 dev_priv->saveDSPARB = I915_READ(DSPARB);
398
399 /* This is only meaningful in non-KMS mode */
400 /* Don't save them in KMS mode */
401 i915_save_modeset_reg(dev);
298 /* Cursor state */ 402 /* Cursor state */
299 dev_priv->saveCURACNTR = I915_READ(CURACNTR); 403 dev_priv->saveCURACNTR = I915_READ(CURACNTR);
300 dev_priv->saveCURAPOS = I915_READ(CURAPOS); 404 dev_priv->saveCURAPOS = I915_READ(CURAPOS);
@@ -322,6 +426,20 @@ int i915_save_state(struct drm_device *dev)
322 dev_priv->savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS); 426 dev_priv->savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS);
323 dev_priv->savePP_DIVISOR = I915_READ(PP_DIVISOR); 427 dev_priv->savePP_DIVISOR = I915_READ(PP_DIVISOR);
324 428
429 /* Display Port state */
430 if (SUPPORTS_INTEGRATED_DP(dev)) {
431 dev_priv->saveDP_B = I915_READ(DP_B);
432 dev_priv->saveDP_C = I915_READ(DP_C);
433 dev_priv->saveDP_D = I915_READ(DP_D);
434 dev_priv->savePIPEA_GMCH_DATA_M = I915_READ(PIPEA_GMCH_DATA_M);
435 dev_priv->savePIPEB_GMCH_DATA_M = I915_READ(PIPEB_GMCH_DATA_M);
436 dev_priv->savePIPEA_GMCH_DATA_N = I915_READ(PIPEA_GMCH_DATA_N);
437 dev_priv->savePIPEB_GMCH_DATA_N = I915_READ(PIPEB_GMCH_DATA_N);
438 dev_priv->savePIPEA_DP_LINK_M = I915_READ(PIPEA_DP_LINK_M);
439 dev_priv->savePIPEB_DP_LINK_M = I915_READ(PIPEB_DP_LINK_M);
440 dev_priv->savePIPEA_DP_LINK_N = I915_READ(PIPEA_DP_LINK_N);
441 dev_priv->savePIPEB_DP_LINK_N = I915_READ(PIPEB_DP_LINK_N);
442 }
325 /* FIXME: save TV & SDVO state */ 443 /* FIXME: save TV & SDVO state */
326 444
327 /* FBC state */ 445 /* FBC state */
@@ -404,92 +522,21 @@ int i915_restore_state(struct drm_device *dev)
404 for (i = 0; i < 8; i++) 522 for (i = 0; i < 8; i++)
405 I915_WRITE(FENCE_REG_945_8 + (i * 4), dev_priv->saveFENCE[i+8]); 523 I915_WRITE(FENCE_REG_945_8 + (i * 4), dev_priv->saveFENCE[i+8]);
406 } 524 }
407 525
408 /* Pipe & plane A info */ 526 /* Display port ratios (must be done before clock is set) */
409 /* Prime the clock */ 527 if (SUPPORTS_INTEGRATED_DP(dev)) {
410 if (dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) { 528 I915_WRITE(PIPEA_GMCH_DATA_M, dev_priv->savePIPEA_GMCH_DATA_M);
411 I915_WRITE(DPLL_A, dev_priv->saveDPLL_A & 529 I915_WRITE(PIPEB_GMCH_DATA_M, dev_priv->savePIPEB_GMCH_DATA_M);
412 ~DPLL_VCO_ENABLE); 530 I915_WRITE(PIPEA_GMCH_DATA_N, dev_priv->savePIPEA_GMCH_DATA_N);
413 DRM_UDELAY(150); 531 I915_WRITE(PIPEB_GMCH_DATA_N, dev_priv->savePIPEB_GMCH_DATA_N);
532 I915_WRITE(PIPEA_DP_LINK_M, dev_priv->savePIPEA_DP_LINK_M);
533 I915_WRITE(PIPEB_DP_LINK_M, dev_priv->savePIPEB_DP_LINK_M);
534 I915_WRITE(PIPEA_DP_LINK_N, dev_priv->savePIPEA_DP_LINK_N);
535 I915_WRITE(PIPEB_DP_LINK_N, dev_priv->savePIPEB_DP_LINK_N);
414 } 536 }
415 I915_WRITE(FPA0, dev_priv->saveFPA0); 537 /* This is only meaningful in non-KMS mode */
416 I915_WRITE(FPA1, dev_priv->saveFPA1); 538 /* Don't restore them in KMS mode */
417 /* Actually enable it */ 539 i915_restore_modeset_reg(dev);
418 I915_WRITE(DPLL_A, dev_priv->saveDPLL_A);
419 DRM_UDELAY(150);
420 if (IS_I965G(dev))
421 I915_WRITE(DPLL_A_MD, dev_priv->saveDPLL_A_MD);
422 DRM_UDELAY(150);
423
424 /* Restore mode */
425 I915_WRITE(HTOTAL_A, dev_priv->saveHTOTAL_A);
426 I915_WRITE(HBLANK_A, dev_priv->saveHBLANK_A);
427 I915_WRITE(HSYNC_A, dev_priv->saveHSYNC_A);
428 I915_WRITE(VTOTAL_A, dev_priv->saveVTOTAL_A);
429 I915_WRITE(VBLANK_A, dev_priv->saveVBLANK_A);
430 I915_WRITE(VSYNC_A, dev_priv->saveVSYNC_A);
431 I915_WRITE(BCLRPAT_A, dev_priv->saveBCLRPAT_A);
432
433 /* Restore plane info */
434 I915_WRITE(DSPASIZE, dev_priv->saveDSPASIZE);
435 I915_WRITE(DSPAPOS, dev_priv->saveDSPAPOS);
436 I915_WRITE(PIPEASRC, dev_priv->savePIPEASRC);
437 I915_WRITE(DSPAADDR, dev_priv->saveDSPAADDR);
438 I915_WRITE(DSPASTRIDE, dev_priv->saveDSPASTRIDE);
439 if (IS_I965G(dev)) {
440 I915_WRITE(DSPASURF, dev_priv->saveDSPASURF);
441 I915_WRITE(DSPATILEOFF, dev_priv->saveDSPATILEOFF);
442 }
443
444 I915_WRITE(PIPEACONF, dev_priv->savePIPEACONF);
445
446 i915_restore_palette(dev, PIPE_A);
447 /* Enable the plane */
448 I915_WRITE(DSPACNTR, dev_priv->saveDSPACNTR);
449 I915_WRITE(DSPAADDR, I915_READ(DSPAADDR));
450
451 /* Pipe & plane B info */
452 if (dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) {
453 I915_WRITE(DPLL_B, dev_priv->saveDPLL_B &
454 ~DPLL_VCO_ENABLE);
455 DRM_UDELAY(150);
456 }
457 I915_WRITE(FPB0, dev_priv->saveFPB0);
458 I915_WRITE(FPB1, dev_priv->saveFPB1);
459 /* Actually enable it */
460 I915_WRITE(DPLL_B, dev_priv->saveDPLL_B);
461 DRM_UDELAY(150);
462 if (IS_I965G(dev))
463 I915_WRITE(DPLL_B_MD, dev_priv->saveDPLL_B_MD);
464 DRM_UDELAY(150);
465
466 /* Restore mode */
467 I915_WRITE(HTOTAL_B, dev_priv->saveHTOTAL_B);
468 I915_WRITE(HBLANK_B, dev_priv->saveHBLANK_B);
469 I915_WRITE(HSYNC_B, dev_priv->saveHSYNC_B);
470 I915_WRITE(VTOTAL_B, dev_priv->saveVTOTAL_B);
471 I915_WRITE(VBLANK_B, dev_priv->saveVBLANK_B);
472 I915_WRITE(VSYNC_B, dev_priv->saveVSYNC_B);
473 I915_WRITE(BCLRPAT_B, dev_priv->saveBCLRPAT_B);
474
475 /* Restore plane info */
476 I915_WRITE(DSPBSIZE, dev_priv->saveDSPBSIZE);
477 I915_WRITE(DSPBPOS, dev_priv->saveDSPBPOS);
478 I915_WRITE(PIPEBSRC, dev_priv->savePIPEBSRC);
479 I915_WRITE(DSPBADDR, dev_priv->saveDSPBADDR);
480 I915_WRITE(DSPBSTRIDE, dev_priv->saveDSPBSTRIDE);
481 if (IS_I965G(dev)) {
482 I915_WRITE(DSPBSURF, dev_priv->saveDSPBSURF);
483 I915_WRITE(DSPBTILEOFF, dev_priv->saveDSPBTILEOFF);
484 }
485
486 I915_WRITE(PIPEBCONF, dev_priv->savePIPEBCONF);
487
488 i915_restore_palette(dev, PIPE_B);
489 /* Enable the plane */
490 I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR);
491 I915_WRITE(DSPBADDR, I915_READ(DSPBADDR));
492
493 /* Cursor state */ 540 /* Cursor state */
494 I915_WRITE(CURAPOS, dev_priv->saveCURAPOS); 541 I915_WRITE(CURAPOS, dev_priv->saveCURAPOS);
495 I915_WRITE(CURACNTR, dev_priv->saveCURACNTR); 542 I915_WRITE(CURACNTR, dev_priv->saveCURACNTR);
@@ -518,6 +565,12 @@ int i915_restore_state(struct drm_device *dev)
518 I915_WRITE(PP_DIVISOR, dev_priv->savePP_DIVISOR); 565 I915_WRITE(PP_DIVISOR, dev_priv->savePP_DIVISOR);
519 I915_WRITE(PP_CONTROL, dev_priv->savePP_CONTROL); 566 I915_WRITE(PP_CONTROL, dev_priv->savePP_CONTROL);
520 567
568 /* Display Port state */
569 if (SUPPORTS_INTEGRATED_DP(dev)) {
570 I915_WRITE(DP_B, dev_priv->saveDP_B);
571 I915_WRITE(DP_C, dev_priv->saveDP_C);
572 I915_WRITE(DP_D, dev_priv->saveDP_D);
573 }
521 /* FIXME: restore TV & SDVO state */ 574 /* FIXME: restore TV & SDVO state */
522 575
523 /* FBC info */ 576 /* FBC info */
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index cdd126d068a7..7cc447191028 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -97,11 +97,14 @@ static void
97parse_lfp_panel_data(struct drm_i915_private *dev_priv, 97parse_lfp_panel_data(struct drm_i915_private *dev_priv,
98 struct bdb_header *bdb) 98 struct bdb_header *bdb)
99{ 99{
100 struct drm_device *dev = dev_priv->dev;
100 struct bdb_lvds_options *lvds_options; 101 struct bdb_lvds_options *lvds_options;
101 struct bdb_lvds_lfp_data *lvds_lfp_data; 102 struct bdb_lvds_lfp_data *lvds_lfp_data;
103 struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
102 struct bdb_lvds_lfp_data_entry *entry; 104 struct bdb_lvds_lfp_data_entry *entry;
103 struct lvds_dvo_timing *dvo_timing; 105 struct lvds_dvo_timing *dvo_timing;
104 struct drm_display_mode *panel_fixed_mode; 106 struct drm_display_mode *panel_fixed_mode;
107 int lfp_data_size;
105 108
106 /* Defaults if we can't find VBT info */ 109 /* Defaults if we can't find VBT info */
107 dev_priv->lvds_dither = 0; 110 dev_priv->lvds_dither = 0;
@@ -119,10 +122,25 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
119 if (!lvds_lfp_data) 122 if (!lvds_lfp_data)
120 return; 123 return;
121 124
125 lvds_lfp_data_ptrs = find_section(bdb, BDB_LVDS_LFP_DATA_PTRS);
126 if (!lvds_lfp_data_ptrs)
127 return;
128
122 dev_priv->lvds_vbt = 1; 129 dev_priv->lvds_vbt = 1;
123 130
124 entry = &lvds_lfp_data->data[lvds_options->panel_type]; 131 lfp_data_size = lvds_lfp_data_ptrs->ptr[1].dvo_timing_offset -
125 dvo_timing = &entry->dvo_timing; 132 lvds_lfp_data_ptrs->ptr[0].dvo_timing_offset;
133 entry = (struct bdb_lvds_lfp_data_entry *)
134 ((uint8_t *)lvds_lfp_data->data + (lfp_data_size *
135 lvds_options->panel_type));
136
137 /* On IGDNG mobile, LVDS data block removes panel fitting registers.
138 So dec 2 dword from dvo_timing offset */
139 if (IS_IGDNG(dev))
140 dvo_timing = (struct lvds_dvo_timing *)
141 ((u8 *)&entry->dvo_timing - 8);
142 else
143 dvo_timing = &entry->dvo_timing;
126 144
127 panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL); 145 panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
128 146
@@ -185,10 +203,12 @@ parse_general_features(struct drm_i915_private *dev_priv,
185 dev_priv->lvds_use_ssc = general->enable_ssc; 203 dev_priv->lvds_use_ssc = general->enable_ssc;
186 204
187 if (dev_priv->lvds_use_ssc) { 205 if (dev_priv->lvds_use_ssc) {
188 if (IS_I855(dev_priv->dev)) 206 if (IS_I85X(dev_priv->dev))
189 dev_priv->lvds_ssc_freq = general->ssc_freq ? 66 : 48; 207 dev_priv->lvds_ssc_freq =
190 else 208 general->ssc_freq ? 66 : 48;
191 dev_priv->lvds_ssc_freq = general->ssc_freq ? 100 : 96; 209 else
210 dev_priv->lvds_ssc_freq =
211 general->ssc_freq ? 100 : 96;
192 } 212 }
193 } 213 }
194} 214}
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 6de97fc66029..d6a1a6e5539a 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -46,7 +46,7 @@ static void intel_crt_dpms(struct drm_encoder *encoder, int mode)
46 46
47 temp = I915_READ(reg); 47 temp = I915_READ(reg);
48 temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE); 48 temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE);
49 temp |= ADPA_DAC_ENABLE; 49 temp &= ~ADPA_DAC_ENABLE;
50 50
51 switch(mode) { 51 switch(mode) {
52 case DRM_MODE_DPMS_ON: 52 case DRM_MODE_DPMS_ON:
@@ -428,8 +428,34 @@ static void intel_crt_destroy(struct drm_connector *connector)
428 428
429static int intel_crt_get_modes(struct drm_connector *connector) 429static int intel_crt_get_modes(struct drm_connector *connector)
430{ 430{
431 int ret;
431 struct intel_output *intel_output = to_intel_output(connector); 432 struct intel_output *intel_output = to_intel_output(connector);
432 return intel_ddc_get_modes(intel_output); 433 struct i2c_adapter *ddcbus;
434 struct drm_device *dev = connector->dev;
435
436
437 ret = intel_ddc_get_modes(intel_output);
438 if (ret || !IS_G4X(dev))
439 goto end;
440
441 ddcbus = intel_output->ddc_bus;
442 /* Try to probe digital port for output in DVI-I -> VGA mode. */
443 intel_output->ddc_bus =
444 intel_i2c_create(connector->dev, GPIOD, "CRTDDC_D");
445
446 if (!intel_output->ddc_bus) {
447 intel_output->ddc_bus = ddcbus;
448 dev_printk(KERN_ERR, &connector->dev->pdev->dev,
449 "DDC bus registration failed for CRTDDC_D.\n");
450 goto end;
451 }
452 /* Try to get modes by GPIOD port */
453 ret = intel_ddc_get_modes(intel_output);
454 intel_i2c_destroy(ddcbus);
455
456end:
457 return ret;
458
433} 459}
434 460
435static int intel_crt_set_property(struct drm_connector *connector, 461static int intel_crt_set_property(struct drm_connector *connector,
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 3e1c78162119..508838ee31e0 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -25,14 +25,17 @@
25 */ 25 */
26 26
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/kernel.h>
28#include "drmP.h" 29#include "drmP.h"
29#include "intel_drv.h" 30#include "intel_drv.h"
30#include "i915_drm.h" 31#include "i915_drm.h"
31#include "i915_drv.h" 32#include "i915_drv.h"
33#include "intel_dp.h"
32 34
33#include "drm_crtc_helper.h" 35#include "drm_crtc_helper.h"
34 36
35bool intel_pipe_has_type (struct drm_crtc *crtc, int type); 37bool intel_pipe_has_type (struct drm_crtc *crtc, int type);
38static void intel_update_watermarks(struct drm_device *dev);
36 39
37typedef struct { 40typedef struct {
38 /* given values */ 41 /* given values */
@@ -127,19 +130,6 @@ struct intel_limit {
127#define I9XX_P2_LVDS_FAST 7 130#define I9XX_P2_LVDS_FAST 7
128#define I9XX_P2_LVDS_SLOW_LIMIT 112000 131#define I9XX_P2_LVDS_SLOW_LIMIT 112000
129 132
130#define INTEL_LIMIT_I8XX_DVO_DAC 0
131#define INTEL_LIMIT_I8XX_LVDS 1
132#define INTEL_LIMIT_I9XX_SDVO_DAC 2
133#define INTEL_LIMIT_I9XX_LVDS 3
134#define INTEL_LIMIT_G4X_SDVO 4
135#define INTEL_LIMIT_G4X_HDMI_DAC 5
136#define INTEL_LIMIT_G4X_SINGLE_CHANNEL_LVDS 6
137#define INTEL_LIMIT_G4X_DUAL_CHANNEL_LVDS 7
138#define INTEL_LIMIT_IGD_SDVO_DAC 8
139#define INTEL_LIMIT_IGD_LVDS 9
140#define INTEL_LIMIT_IGDNG_SDVO_DAC 10
141#define INTEL_LIMIT_IGDNG_LVDS 11
142
143/*The parameter is for SDVO on G4x platform*/ 133/*The parameter is for SDVO on G4x platform*/
144#define G4X_DOT_SDVO_MIN 25000 134#define G4X_DOT_SDVO_MIN 25000
145#define G4X_DOT_SDVO_MAX 270000 135#define G4X_DOT_SDVO_MAX 270000
@@ -218,6 +208,25 @@ struct intel_limit {
218#define G4X_P2_DUAL_CHANNEL_LVDS_FAST 7 208#define G4X_P2_DUAL_CHANNEL_LVDS_FAST 7
219#define G4X_P2_DUAL_CHANNEL_LVDS_LIMIT 0 209#define G4X_P2_DUAL_CHANNEL_LVDS_LIMIT 0
220 210
211/*The parameter is for DISPLAY PORT on G4x platform*/
212#define G4X_DOT_DISPLAY_PORT_MIN 161670
213#define G4X_DOT_DISPLAY_PORT_MAX 227000
214#define G4X_N_DISPLAY_PORT_MIN 1
215#define G4X_N_DISPLAY_PORT_MAX 2
216#define G4X_M_DISPLAY_PORT_MIN 97
217#define G4X_M_DISPLAY_PORT_MAX 108
218#define G4X_M1_DISPLAY_PORT_MIN 0x10
219#define G4X_M1_DISPLAY_PORT_MAX 0x12
220#define G4X_M2_DISPLAY_PORT_MIN 0x05
221#define G4X_M2_DISPLAY_PORT_MAX 0x06
222#define G4X_P_DISPLAY_PORT_MIN 10
223#define G4X_P_DISPLAY_PORT_MAX 20
224#define G4X_P1_DISPLAY_PORT_MIN 1
225#define G4X_P1_DISPLAY_PORT_MAX 2
226#define G4X_P2_DISPLAY_PORT_SLOW 10
227#define G4X_P2_DISPLAY_PORT_FAST 10
228#define G4X_P2_DISPLAY_PORT_LIMIT 0
229
221/* IGDNG */ 230/* IGDNG */
222/* as we calculate clock using (register_value + 2) for 231/* as we calculate clock using (register_value + 2) for
223 N/M1/M2, so here the range value for them is (actual_value-2). 232 N/M1/M2, so here the range value for them is (actual_value-2).
@@ -256,8 +265,11 @@ static bool
256intel_igdng_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc, 265intel_igdng_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
257 int target, int refclk, intel_clock_t *best_clock); 266 int target, int refclk, intel_clock_t *best_clock);
258 267
259static const intel_limit_t intel_limits[] = { 268static bool
260 { /* INTEL_LIMIT_I8XX_DVO_DAC */ 269intel_find_pll_g4x_dp(const intel_limit_t *, struct drm_crtc *crtc,
270 int target, int refclk, intel_clock_t *best_clock);
271
272static const intel_limit_t intel_limits_i8xx_dvo = {
261 .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX }, 273 .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX },
262 .vco = { .min = I8XX_VCO_MIN, .max = I8XX_VCO_MAX }, 274 .vco = { .min = I8XX_VCO_MIN, .max = I8XX_VCO_MAX },
263 .n = { .min = I8XX_N_MIN, .max = I8XX_N_MAX }, 275 .n = { .min = I8XX_N_MIN, .max = I8XX_N_MAX },
@@ -269,8 +281,9 @@ static const intel_limit_t intel_limits[] = {
269 .p2 = { .dot_limit = I8XX_P2_SLOW_LIMIT, 281 .p2 = { .dot_limit = I8XX_P2_SLOW_LIMIT,
270 .p2_slow = I8XX_P2_SLOW, .p2_fast = I8XX_P2_FAST }, 282 .p2_slow = I8XX_P2_SLOW, .p2_fast = I8XX_P2_FAST },
271 .find_pll = intel_find_best_PLL, 283 .find_pll = intel_find_best_PLL,
272 }, 284};
273 { /* INTEL_LIMIT_I8XX_LVDS */ 285
286static const intel_limit_t intel_limits_i8xx_lvds = {
274 .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX }, 287 .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX },
275 .vco = { .min = I8XX_VCO_MIN, .max = I8XX_VCO_MAX }, 288 .vco = { .min = I8XX_VCO_MIN, .max = I8XX_VCO_MAX },
276 .n = { .min = I8XX_N_MIN, .max = I8XX_N_MAX }, 289 .n = { .min = I8XX_N_MIN, .max = I8XX_N_MAX },
@@ -282,8 +295,9 @@ static const intel_limit_t intel_limits[] = {
282 .p2 = { .dot_limit = I8XX_P2_SLOW_LIMIT, 295 .p2 = { .dot_limit = I8XX_P2_SLOW_LIMIT,
283 .p2_slow = I8XX_P2_LVDS_SLOW, .p2_fast = I8XX_P2_LVDS_FAST }, 296 .p2_slow = I8XX_P2_LVDS_SLOW, .p2_fast = I8XX_P2_LVDS_FAST },
284 .find_pll = intel_find_best_PLL, 297 .find_pll = intel_find_best_PLL,
285 }, 298};
286 { /* INTEL_LIMIT_I9XX_SDVO_DAC */ 299
300static const intel_limit_t intel_limits_i9xx_sdvo = {
287 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX }, 301 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX },
288 .vco = { .min = I9XX_VCO_MIN, .max = I9XX_VCO_MAX }, 302 .vco = { .min = I9XX_VCO_MIN, .max = I9XX_VCO_MAX },
289 .n = { .min = I9XX_N_MIN, .max = I9XX_N_MAX }, 303 .n = { .min = I9XX_N_MIN, .max = I9XX_N_MAX },
@@ -295,8 +309,9 @@ static const intel_limit_t intel_limits[] = {
295 .p2 = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT, 309 .p2 = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT,
296 .p2_slow = I9XX_P2_SDVO_DAC_SLOW, .p2_fast = I9XX_P2_SDVO_DAC_FAST }, 310 .p2_slow = I9XX_P2_SDVO_DAC_SLOW, .p2_fast = I9XX_P2_SDVO_DAC_FAST },
297 .find_pll = intel_find_best_PLL, 311 .find_pll = intel_find_best_PLL,
298 }, 312};
299 { /* INTEL_LIMIT_I9XX_LVDS */ 313
314static const intel_limit_t intel_limits_i9xx_lvds = {
300 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX }, 315 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX },
301 .vco = { .min = I9XX_VCO_MIN, .max = I9XX_VCO_MAX }, 316 .vco = { .min = I9XX_VCO_MIN, .max = I9XX_VCO_MAX },
302 .n = { .min = I9XX_N_MIN, .max = I9XX_N_MAX }, 317 .n = { .min = I9XX_N_MIN, .max = I9XX_N_MAX },
@@ -311,9 +326,10 @@ static const intel_limit_t intel_limits[] = {
311 .p2 = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT, 326 .p2 = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT,
312 .p2_slow = I9XX_P2_LVDS_SLOW, .p2_fast = I9XX_P2_LVDS_FAST }, 327 .p2_slow = I9XX_P2_LVDS_SLOW, .p2_fast = I9XX_P2_LVDS_FAST },
313 .find_pll = intel_find_best_PLL, 328 .find_pll = intel_find_best_PLL,
314 }, 329};
330
315 /* below parameter and function is for G4X Chipset Family*/ 331 /* below parameter and function is for G4X Chipset Family*/
316 { /* INTEL_LIMIT_G4X_SDVO */ 332static const intel_limit_t intel_limits_g4x_sdvo = {
317 .dot = { .min = G4X_DOT_SDVO_MIN, .max = G4X_DOT_SDVO_MAX }, 333 .dot = { .min = G4X_DOT_SDVO_MIN, .max = G4X_DOT_SDVO_MAX },
318 .vco = { .min = G4X_VCO_MIN, .max = G4X_VCO_MAX}, 334 .vco = { .min = G4X_VCO_MIN, .max = G4X_VCO_MAX},
319 .n = { .min = G4X_N_SDVO_MIN, .max = G4X_N_SDVO_MAX }, 335 .n = { .min = G4X_N_SDVO_MIN, .max = G4X_N_SDVO_MAX },
@@ -327,8 +343,9 @@ static const intel_limit_t intel_limits[] = {
327 .p2_fast = G4X_P2_SDVO_FAST 343 .p2_fast = G4X_P2_SDVO_FAST
328 }, 344 },
329 .find_pll = intel_g4x_find_best_PLL, 345 .find_pll = intel_g4x_find_best_PLL,
330 }, 346};
331 { /* INTEL_LIMIT_G4X_HDMI_DAC */ 347
348static const intel_limit_t intel_limits_g4x_hdmi = {
332 .dot = { .min = G4X_DOT_HDMI_DAC_MIN, .max = G4X_DOT_HDMI_DAC_MAX }, 349 .dot = { .min = G4X_DOT_HDMI_DAC_MIN, .max = G4X_DOT_HDMI_DAC_MAX },
333 .vco = { .min = G4X_VCO_MIN, .max = G4X_VCO_MAX}, 350 .vco = { .min = G4X_VCO_MIN, .max = G4X_VCO_MAX},
334 .n = { .min = G4X_N_HDMI_DAC_MIN, .max = G4X_N_HDMI_DAC_MAX }, 351 .n = { .min = G4X_N_HDMI_DAC_MIN, .max = G4X_N_HDMI_DAC_MAX },
@@ -342,8 +359,9 @@ static const intel_limit_t intel_limits[] = {
342 .p2_fast = G4X_P2_HDMI_DAC_FAST 359 .p2_fast = G4X_P2_HDMI_DAC_FAST
343 }, 360 },
344 .find_pll = intel_g4x_find_best_PLL, 361 .find_pll = intel_g4x_find_best_PLL,
345 }, 362};
346 { /* INTEL_LIMIT_G4X_SINGLE_CHANNEL_LVDS */ 363
364static const intel_limit_t intel_limits_g4x_single_channel_lvds = {
347 .dot = { .min = G4X_DOT_SINGLE_CHANNEL_LVDS_MIN, 365 .dot = { .min = G4X_DOT_SINGLE_CHANNEL_LVDS_MIN,
348 .max = G4X_DOT_SINGLE_CHANNEL_LVDS_MAX }, 366 .max = G4X_DOT_SINGLE_CHANNEL_LVDS_MAX },
349 .vco = { .min = G4X_VCO_MIN, 367 .vco = { .min = G4X_VCO_MIN,
@@ -365,8 +383,9 @@ static const intel_limit_t intel_limits[] = {
365 .p2_fast = G4X_P2_SINGLE_CHANNEL_LVDS_FAST 383 .p2_fast = G4X_P2_SINGLE_CHANNEL_LVDS_FAST
366 }, 384 },
367 .find_pll = intel_g4x_find_best_PLL, 385 .find_pll = intel_g4x_find_best_PLL,
368 }, 386};
369 { /* INTEL_LIMIT_G4X_DUAL_CHANNEL_LVDS */ 387
388static const intel_limit_t intel_limits_g4x_dual_channel_lvds = {
370 .dot = { .min = G4X_DOT_DUAL_CHANNEL_LVDS_MIN, 389 .dot = { .min = G4X_DOT_DUAL_CHANNEL_LVDS_MIN,
371 .max = G4X_DOT_DUAL_CHANNEL_LVDS_MAX }, 390 .max = G4X_DOT_DUAL_CHANNEL_LVDS_MAX },
372 .vco = { .min = G4X_VCO_MIN, 391 .vco = { .min = G4X_VCO_MIN,
@@ -388,8 +407,32 @@ static const intel_limit_t intel_limits[] = {
388 .p2_fast = G4X_P2_DUAL_CHANNEL_LVDS_FAST 407 .p2_fast = G4X_P2_DUAL_CHANNEL_LVDS_FAST
389 }, 408 },
390 .find_pll = intel_g4x_find_best_PLL, 409 .find_pll = intel_g4x_find_best_PLL,
391 }, 410};
392 { /* INTEL_LIMIT_IGD_SDVO */ 411
412static const intel_limit_t intel_limits_g4x_display_port = {
413 .dot = { .min = G4X_DOT_DISPLAY_PORT_MIN,
414 .max = G4X_DOT_DISPLAY_PORT_MAX },
415 .vco = { .min = G4X_VCO_MIN,
416 .max = G4X_VCO_MAX},
417 .n = { .min = G4X_N_DISPLAY_PORT_MIN,
418 .max = G4X_N_DISPLAY_PORT_MAX },
419 .m = { .min = G4X_M_DISPLAY_PORT_MIN,
420 .max = G4X_M_DISPLAY_PORT_MAX },
421 .m1 = { .min = G4X_M1_DISPLAY_PORT_MIN,
422 .max = G4X_M1_DISPLAY_PORT_MAX },
423 .m2 = { .min = G4X_M2_DISPLAY_PORT_MIN,
424 .max = G4X_M2_DISPLAY_PORT_MAX },
425 .p = { .min = G4X_P_DISPLAY_PORT_MIN,
426 .max = G4X_P_DISPLAY_PORT_MAX },
427 .p1 = { .min = G4X_P1_DISPLAY_PORT_MIN,
428 .max = G4X_P1_DISPLAY_PORT_MAX},
429 .p2 = { .dot_limit = G4X_P2_DISPLAY_PORT_LIMIT,
430 .p2_slow = G4X_P2_DISPLAY_PORT_SLOW,
431 .p2_fast = G4X_P2_DISPLAY_PORT_FAST },
432 .find_pll = intel_find_pll_g4x_dp,
433};
434
435static const intel_limit_t intel_limits_igd_sdvo = {
393 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX}, 436 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX},
394 .vco = { .min = IGD_VCO_MIN, .max = IGD_VCO_MAX }, 437 .vco = { .min = IGD_VCO_MIN, .max = IGD_VCO_MAX },
395 .n = { .min = IGD_N_MIN, .max = IGD_N_MAX }, 438 .n = { .min = IGD_N_MIN, .max = IGD_N_MAX },
@@ -401,8 +444,9 @@ static const intel_limit_t intel_limits[] = {
401 .p2 = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT, 444 .p2 = { .dot_limit = I9XX_P2_SDVO_DAC_SLOW_LIMIT,
402 .p2_slow = I9XX_P2_SDVO_DAC_SLOW, .p2_fast = I9XX_P2_SDVO_DAC_FAST }, 445 .p2_slow = I9XX_P2_SDVO_DAC_SLOW, .p2_fast = I9XX_P2_SDVO_DAC_FAST },
403 .find_pll = intel_find_best_PLL, 446 .find_pll = intel_find_best_PLL,
404 }, 447};
405 { /* INTEL_LIMIT_IGD_LVDS */ 448
449static const intel_limit_t intel_limits_igd_lvds = {
406 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX }, 450 .dot = { .min = I9XX_DOT_MIN, .max = I9XX_DOT_MAX },
407 .vco = { .min = IGD_VCO_MIN, .max = IGD_VCO_MAX }, 451 .vco = { .min = IGD_VCO_MIN, .max = IGD_VCO_MAX },
408 .n = { .min = IGD_N_MIN, .max = IGD_N_MAX }, 452 .n = { .min = IGD_N_MIN, .max = IGD_N_MAX },
@@ -415,8 +459,9 @@ static const intel_limit_t intel_limits[] = {
415 .p2 = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT, 459 .p2 = { .dot_limit = I9XX_P2_LVDS_SLOW_LIMIT,
416 .p2_slow = I9XX_P2_LVDS_SLOW, .p2_fast = I9XX_P2_LVDS_SLOW }, 460 .p2_slow = I9XX_P2_LVDS_SLOW, .p2_fast = I9XX_P2_LVDS_SLOW },
417 .find_pll = intel_find_best_PLL, 461 .find_pll = intel_find_best_PLL,
418 }, 462};
419 { /* INTEL_LIMIT_IGDNG_SDVO_DAC */ 463
464static const intel_limit_t intel_limits_igdng_sdvo = {
420 .dot = { .min = IGDNG_DOT_MIN, .max = IGDNG_DOT_MAX }, 465 .dot = { .min = IGDNG_DOT_MIN, .max = IGDNG_DOT_MAX },
421 .vco = { .min = IGDNG_VCO_MIN, .max = IGDNG_VCO_MAX }, 466 .vco = { .min = IGDNG_VCO_MIN, .max = IGDNG_VCO_MAX },
422 .n = { .min = IGDNG_N_MIN, .max = IGDNG_N_MAX }, 467 .n = { .min = IGDNG_N_MIN, .max = IGDNG_N_MAX },
@@ -429,8 +474,9 @@ static const intel_limit_t intel_limits[] = {
429 .p2_slow = IGDNG_P2_SDVO_DAC_SLOW, 474 .p2_slow = IGDNG_P2_SDVO_DAC_SLOW,
430 .p2_fast = IGDNG_P2_SDVO_DAC_FAST }, 475 .p2_fast = IGDNG_P2_SDVO_DAC_FAST },
431 .find_pll = intel_igdng_find_best_PLL, 476 .find_pll = intel_igdng_find_best_PLL,
432 }, 477};
433 { /* INTEL_LIMIT_IGDNG_LVDS */ 478
479static const intel_limit_t intel_limits_igdng_lvds = {
434 .dot = { .min = IGDNG_DOT_MIN, .max = IGDNG_DOT_MAX }, 480 .dot = { .min = IGDNG_DOT_MIN, .max = IGDNG_DOT_MAX },
435 .vco = { .min = IGDNG_VCO_MIN, .max = IGDNG_VCO_MAX }, 481 .vco = { .min = IGDNG_VCO_MIN, .max = IGDNG_VCO_MAX },
436 .n = { .min = IGDNG_N_MIN, .max = IGDNG_N_MAX }, 482 .n = { .min = IGDNG_N_MIN, .max = IGDNG_N_MAX },
@@ -443,16 +489,15 @@ static const intel_limit_t intel_limits[] = {
443 .p2_slow = IGDNG_P2_LVDS_SLOW, 489 .p2_slow = IGDNG_P2_LVDS_SLOW,
444 .p2_fast = IGDNG_P2_LVDS_FAST }, 490 .p2_fast = IGDNG_P2_LVDS_FAST },
445 .find_pll = intel_igdng_find_best_PLL, 491 .find_pll = intel_igdng_find_best_PLL,
446 },
447}; 492};
448 493
449static const intel_limit_t *intel_igdng_limit(struct drm_crtc *crtc) 494static const intel_limit_t *intel_igdng_limit(struct drm_crtc *crtc)
450{ 495{
451 const intel_limit_t *limit; 496 const intel_limit_t *limit;
452 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) 497 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
453 limit = &intel_limits[INTEL_LIMIT_IGDNG_LVDS]; 498 limit = &intel_limits_igdng_lvds;
454 else 499 else
455 limit = &intel_limits[INTEL_LIMIT_IGDNG_SDVO_DAC]; 500 limit = &intel_limits_igdng_sdvo;
456 501
457 return limit; 502 return limit;
458} 503}
@@ -467,19 +512,19 @@ static const intel_limit_t *intel_g4x_limit(struct drm_crtc *crtc)
467 if ((I915_READ(LVDS) & LVDS_CLKB_POWER_MASK) == 512 if ((I915_READ(LVDS) & LVDS_CLKB_POWER_MASK) ==
468 LVDS_CLKB_POWER_UP) 513 LVDS_CLKB_POWER_UP)
469 /* LVDS with dual channel */ 514 /* LVDS with dual channel */
470 limit = &intel_limits 515 limit = &intel_limits_g4x_dual_channel_lvds;
471 [INTEL_LIMIT_G4X_DUAL_CHANNEL_LVDS];
472 else 516 else
473 /* LVDS with dual channel */ 517 /* LVDS with dual channel */
474 limit = &intel_limits 518 limit = &intel_limits_g4x_single_channel_lvds;
475 [INTEL_LIMIT_G4X_SINGLE_CHANNEL_LVDS];
476 } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI) || 519 } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI) ||
477 intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG)) { 520 intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG)) {
478 limit = &intel_limits[INTEL_LIMIT_G4X_HDMI_DAC]; 521 limit = &intel_limits_g4x_hdmi;
479 } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_SDVO)) { 522 } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_SDVO)) {
480 limit = &intel_limits[INTEL_LIMIT_G4X_SDVO]; 523 limit = &intel_limits_g4x_sdvo;
524 } else if (intel_pipe_has_type (crtc, INTEL_OUTPUT_DISPLAYPORT)) {
525 limit = &intel_limits_g4x_display_port;
481 } else /* The option is for other outputs */ 526 } else /* The option is for other outputs */
482 limit = &intel_limits[INTEL_LIMIT_I9XX_SDVO_DAC]; 527 limit = &intel_limits_i9xx_sdvo;
483 528
484 return limit; 529 return limit;
485} 530}
@@ -495,19 +540,19 @@ static const intel_limit_t *intel_limit(struct drm_crtc *crtc)
495 limit = intel_g4x_limit(crtc); 540 limit = intel_g4x_limit(crtc);
496 } else if (IS_I9XX(dev) && !IS_IGD(dev)) { 541 } else if (IS_I9XX(dev) && !IS_IGD(dev)) {
497 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) 542 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
498 limit = &intel_limits[INTEL_LIMIT_I9XX_LVDS]; 543 limit = &intel_limits_i9xx_lvds;
499 else 544 else
500 limit = &intel_limits[INTEL_LIMIT_I9XX_SDVO_DAC]; 545 limit = &intel_limits_i9xx_sdvo;
501 } else if (IS_IGD(dev)) { 546 } else if (IS_IGD(dev)) {
502 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) 547 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
503 limit = &intel_limits[INTEL_LIMIT_IGD_LVDS]; 548 limit = &intel_limits_igd_lvds;
504 else 549 else
505 limit = &intel_limits[INTEL_LIMIT_IGD_SDVO_DAC]; 550 limit = &intel_limits_igd_sdvo;
506 } else { 551 } else {
507 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) 552 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS))
508 limit = &intel_limits[INTEL_LIMIT_I8XX_LVDS]; 553 limit = &intel_limits_i8xx_lvds;
509 else 554 else
510 limit = &intel_limits[INTEL_LIMIT_I8XX_DVO_DAC]; 555 limit = &intel_limits_i8xx_dvo;
511 } 556 }
512 return limit; 557 return limit;
513} 558}
@@ -764,6 +809,32 @@ out:
764 return found; 809 return found;
765} 810}
766 811
812/* DisplayPort has only two frequencies, 162MHz and 270MHz */
813static bool
814intel_find_pll_g4x_dp(const intel_limit_t *limit, struct drm_crtc *crtc,
815 int target, int refclk, intel_clock_t *best_clock)
816{
817 intel_clock_t clock;
818 if (target < 200000) {
819 clock.p1 = 2;
820 clock.p2 = 10;
821 clock.n = 2;
822 clock.m1 = 23;
823 clock.m2 = 8;
824 } else {
825 clock.p1 = 1;
826 clock.p2 = 10;
827 clock.n = 1;
828 clock.m1 = 14;
829 clock.m2 = 2;
830 }
831 clock.m = 5 * (clock.m1 + 2) + (clock.m2 + 2);
832 clock.p = (clock.p1 * clock.p2);
833 clock.dot = 96000 * clock.m / (clock.n + 2) / clock.p;
834 memcpy(best_clock, &clock, sizeof(intel_clock_t));
835 return true;
836}
837
767void 838void
768intel_wait_for_vblank(struct drm_device *dev) 839intel_wait_for_vblank(struct drm_device *dev)
769{ 840{
@@ -933,7 +1004,7 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
933 struct drm_i915_private *dev_priv = dev->dev_private; 1004 struct drm_i915_private *dev_priv = dev->dev_private;
934 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 1005 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
935 int pipe = intel_crtc->pipe; 1006 int pipe = intel_crtc->pipe;
936 int plane = intel_crtc->pipe; 1007 int plane = intel_crtc->plane;
937 int pch_dpll_reg = (pipe == 0) ? PCH_DPLL_A : PCH_DPLL_B; 1008 int pch_dpll_reg = (pipe == 0) ? PCH_DPLL_A : PCH_DPLL_B;
938 int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; 1009 int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
939 int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR; 1010 int dspcntr_reg = (plane == 0) ? DSPACNTR : DSPBCNTR;
@@ -1263,8 +1334,10 @@ static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode)
1263 1334
1264 /* Give the overlay scaler a chance to enable if it's on this pipe */ 1335 /* Give the overlay scaler a chance to enable if it's on this pipe */
1265 //intel_crtc_dpms_video(crtc, true); TODO 1336 //intel_crtc_dpms_video(crtc, true); TODO
1337 intel_update_watermarks(dev);
1266 break; 1338 break;
1267 case DRM_MODE_DPMS_OFF: 1339 case DRM_MODE_DPMS_OFF:
1340 intel_update_watermarks(dev);
1268 /* Give the overlay scaler a chance to disable if it's on this pipe */ 1341 /* Give the overlay scaler a chance to disable if it's on this pipe */
1269 //intel_crtc_dpms_video(crtc, FALSE); TODO 1342 //intel_crtc_dpms_video(crtc, FALSE); TODO
1270 1343
@@ -1443,7 +1516,6 @@ static int intel_get_core_clock_speed(struct drm_device *dev)
1443 return 0; /* Silence gcc warning */ 1516 return 0; /* Silence gcc warning */
1444} 1517}
1445 1518
1446
1447/** 1519/**
1448 * Return the pipe currently connected to the panel fitter, 1520 * Return the pipe currently connected to the panel fitter,
1449 * or -1 if the panel fitter is not present or not in use 1521 * or -1 if the panel fitter is not present or not in use
@@ -1502,7 +1574,7 @@ igdng_compute_m_n(int bytes_per_pixel, int nlanes,
1502 1574
1503 temp = (u64) DATA_N * pixel_clock; 1575 temp = (u64) DATA_N * pixel_clock;
1504 temp = div_u64(temp, link_clock); 1576 temp = div_u64(temp, link_clock);
1505 m_n->gmch_m = (temp * bytes_per_pixel) / nlanes; 1577 m_n->gmch_m = div_u64(temp * bytes_per_pixel, nlanes);
1506 m_n->gmch_n = DATA_N; 1578 m_n->gmch_n = DATA_N;
1507 fdi_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n); 1579 fdi_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n);
1508 1580
@@ -1513,6 +1585,420 @@ igdng_compute_m_n(int bytes_per_pixel, int nlanes,
1513} 1585}
1514 1586
1515 1587
1588struct intel_watermark_params {
1589 unsigned long fifo_size;
1590 unsigned long max_wm;
1591 unsigned long default_wm;
1592 unsigned long guard_size;
1593 unsigned long cacheline_size;
1594};
1595
1596/* IGD has different values for various configs */
1597static struct intel_watermark_params igd_display_wm = {
1598 IGD_DISPLAY_FIFO,
1599 IGD_MAX_WM,
1600 IGD_DFT_WM,
1601 IGD_GUARD_WM,
1602 IGD_FIFO_LINE_SIZE
1603};
1604static struct intel_watermark_params igd_display_hplloff_wm = {
1605 IGD_DISPLAY_FIFO,
1606 IGD_MAX_WM,
1607 IGD_DFT_HPLLOFF_WM,
1608 IGD_GUARD_WM,
1609 IGD_FIFO_LINE_SIZE
1610};
1611static struct intel_watermark_params igd_cursor_wm = {
1612 IGD_CURSOR_FIFO,
1613 IGD_CURSOR_MAX_WM,
1614 IGD_CURSOR_DFT_WM,
1615 IGD_CURSOR_GUARD_WM,
1616 IGD_FIFO_LINE_SIZE,
1617};
1618static struct intel_watermark_params igd_cursor_hplloff_wm = {
1619 IGD_CURSOR_FIFO,
1620 IGD_CURSOR_MAX_WM,
1621 IGD_CURSOR_DFT_WM,
1622 IGD_CURSOR_GUARD_WM,
1623 IGD_FIFO_LINE_SIZE
1624};
1625static struct intel_watermark_params i945_wm_info = {
1626 I915_FIFO_LINE_SIZE,
1627 I915_MAX_WM,
1628 1,
1629 0,
1630 IGD_FIFO_LINE_SIZE
1631};
1632static struct intel_watermark_params i915_wm_info = {
1633 I945_FIFO_SIZE,
1634 I915_MAX_WM,
1635 1,
1636 0,
1637 I915_FIFO_LINE_SIZE
1638};
1639static struct intel_watermark_params i855_wm_info = {
1640 I855GM_FIFO_SIZE,
1641 I915_MAX_WM,
1642 1,
1643 0,
1644 I830_FIFO_LINE_SIZE
1645};
1646static struct intel_watermark_params i830_wm_info = {
1647 I830_FIFO_SIZE,
1648 I915_MAX_WM,
1649 1,
1650 0,
1651 I830_FIFO_LINE_SIZE
1652};
1653
1654static unsigned long intel_calculate_wm(unsigned long clock_in_khz,
1655 struct intel_watermark_params *wm,
1656 int pixel_size,
1657 unsigned long latency_ns)
1658{
1659 unsigned long bytes_required, wm_size;
1660
1661 bytes_required = (clock_in_khz * pixel_size * latency_ns) / 1000000;
1662 bytes_required /= wm->cacheline_size;
1663 wm_size = wm->fifo_size - bytes_required - wm->guard_size;
1664
1665 if (wm_size > wm->max_wm)
1666 wm_size = wm->max_wm;
1667 if (wm_size == 0)
1668 wm_size = wm->default_wm;
1669 return wm_size;
1670}
1671
1672struct cxsr_latency {
1673 int is_desktop;
1674 unsigned long fsb_freq;
1675 unsigned long mem_freq;
1676 unsigned long display_sr;
1677 unsigned long display_hpll_disable;
1678 unsigned long cursor_sr;
1679 unsigned long cursor_hpll_disable;
1680};
1681
1682static struct cxsr_latency cxsr_latency_table[] = {
1683 {1, 800, 400, 3382, 33382, 3983, 33983}, /* DDR2-400 SC */
1684 {1, 800, 667, 3354, 33354, 3807, 33807}, /* DDR2-667 SC */
1685 {1, 800, 800, 3347, 33347, 3763, 33763}, /* DDR2-800 SC */
1686
1687 {1, 667, 400, 3400, 33400, 4021, 34021}, /* DDR2-400 SC */
1688 {1, 667, 667, 3372, 33372, 3845, 33845}, /* DDR2-667 SC */
1689 {1, 667, 800, 3386, 33386, 3822, 33822}, /* DDR2-800 SC */
1690
1691 {1, 400, 400, 3472, 33472, 4173, 34173}, /* DDR2-400 SC */
1692 {1, 400, 667, 3443, 33443, 3996, 33996}, /* DDR2-667 SC */
1693 {1, 400, 800, 3430, 33430, 3946, 33946}, /* DDR2-800 SC */
1694
1695 {0, 800, 400, 3438, 33438, 4065, 34065}, /* DDR2-400 SC */
1696 {0, 800, 667, 3410, 33410, 3889, 33889}, /* DDR2-667 SC */
1697 {0, 800, 800, 3403, 33403, 3845, 33845}, /* DDR2-800 SC */
1698
1699 {0, 667, 400, 3456, 33456, 4103, 34106}, /* DDR2-400 SC */
1700 {0, 667, 667, 3428, 33428, 3927, 33927}, /* DDR2-667 SC */
1701 {0, 667, 800, 3443, 33443, 3905, 33905}, /* DDR2-800 SC */
1702
1703 {0, 400, 400, 3528, 33528, 4255, 34255}, /* DDR2-400 SC */
1704 {0, 400, 667, 3500, 33500, 4079, 34079}, /* DDR2-667 SC */
1705 {0, 400, 800, 3487, 33487, 4029, 34029}, /* DDR2-800 SC */
1706};
1707
1708static struct cxsr_latency *intel_get_cxsr_latency(int is_desktop, int fsb,
1709 int mem)
1710{
1711 int i;
1712 struct cxsr_latency *latency;
1713
1714 if (fsb == 0 || mem == 0)
1715 return NULL;
1716
1717 for (i = 0; i < ARRAY_SIZE(cxsr_latency_table); i++) {
1718 latency = &cxsr_latency_table[i];
1719 if (is_desktop == latency->is_desktop &&
1720 fsb == latency->fsb_freq && mem == latency->mem_freq)
1721 break;
1722 }
1723 if (i >= ARRAY_SIZE(cxsr_latency_table)) {
1724 DRM_DEBUG("Unknown FSB/MEM found, disable CxSR\n");
1725 return NULL;
1726 }
1727 return latency;
1728}
1729
1730static void igd_disable_cxsr(struct drm_device *dev)
1731{
1732 struct drm_i915_private *dev_priv = dev->dev_private;
1733 u32 reg;
1734
1735 /* deactivate cxsr */
1736 reg = I915_READ(DSPFW3);
1737 reg &= ~(IGD_SELF_REFRESH_EN);
1738 I915_WRITE(DSPFW3, reg);
1739 DRM_INFO("Big FIFO is disabled\n");
1740}
1741
1742static void igd_enable_cxsr(struct drm_device *dev, unsigned long clock,
1743 int pixel_size)
1744{
1745 struct drm_i915_private *dev_priv = dev->dev_private;
1746 u32 reg;
1747 unsigned long wm;
1748 struct cxsr_latency *latency;
1749
1750 latency = intel_get_cxsr_latency(IS_IGDG(dev), dev_priv->fsb_freq,
1751 dev_priv->mem_freq);
1752 if (!latency) {
1753 DRM_DEBUG("Unknown FSB/MEM found, disable CxSR\n");
1754 igd_disable_cxsr(dev);
1755 return;
1756 }
1757
1758 /* Display SR */
1759 wm = intel_calculate_wm(clock, &igd_display_wm, pixel_size,
1760 latency->display_sr);
1761 reg = I915_READ(DSPFW1);
1762 reg &= 0x7fffff;
1763 reg |= wm << 23;
1764 I915_WRITE(DSPFW1, reg);
1765 DRM_DEBUG("DSPFW1 register is %x\n", reg);
1766
1767 /* cursor SR */
1768 wm = intel_calculate_wm(clock, &igd_cursor_wm, pixel_size,
1769 latency->cursor_sr);
1770 reg = I915_READ(DSPFW3);
1771 reg &= ~(0x3f << 24);
1772 reg |= (wm & 0x3f) << 24;
1773 I915_WRITE(DSPFW3, reg);
1774
1775 /* Display HPLL off SR */
1776 wm = intel_calculate_wm(clock, &igd_display_hplloff_wm,
1777 latency->display_hpll_disable, I915_FIFO_LINE_SIZE);
1778 reg = I915_READ(DSPFW3);
1779 reg &= 0xfffffe00;
1780 reg |= wm & 0x1ff;
1781 I915_WRITE(DSPFW3, reg);
1782
1783 /* cursor HPLL off SR */
1784 wm = intel_calculate_wm(clock, &igd_cursor_hplloff_wm, pixel_size,
1785 latency->cursor_hpll_disable);
1786 reg = I915_READ(DSPFW3);
1787 reg &= ~(0x3f << 16);
1788 reg |= (wm & 0x3f) << 16;
1789 I915_WRITE(DSPFW3, reg);
1790 DRM_DEBUG("DSPFW3 register is %x\n", reg);
1791
1792 /* activate cxsr */
1793 reg = I915_READ(DSPFW3);
1794 reg |= IGD_SELF_REFRESH_EN;
1795 I915_WRITE(DSPFW3, reg);
1796
1797 DRM_INFO("Big FIFO is enabled\n");
1798
1799 return;
1800}
1801
1802const static int latency_ns = 5000; /* default for non-igd platforms */
1803
1804
1805static void i965_update_wm(struct drm_device *dev)
1806{
1807 struct drm_i915_private *dev_priv = dev->dev_private;
1808
1809 DRM_DEBUG("Setting FIFO watermarks - A: 8, B: 8, C: 8, SR 8\n");
1810
1811 /* 965 has limitations... */
1812 I915_WRITE(DSPFW1, (8 << 16) | (8 << 8) | (8 << 0));
1813 I915_WRITE(DSPFW2, (8 << 8) | (8 << 0));
1814}
1815
1816static void i9xx_update_wm(struct drm_device *dev, int planea_clock,
1817 int planeb_clock, int sr_hdisplay, int pixel_size)
1818{
1819 struct drm_i915_private *dev_priv = dev->dev_private;
1820 uint32_t fwater_lo = I915_READ(FW_BLC) & MM_FIFO_WATERMARK;
1821 uint32_t fwater_hi = I915_READ(FW_BLC2) & LM_FIFO_WATERMARK;
1822 int bsize, asize, cwm, bwm = 1, awm = 1, srwm = 1;
1823 uint32_t dsparb = I915_READ(DSPARB);
1824 int planea_entries, planeb_entries;
1825 struct intel_watermark_params *wm_params;
1826 unsigned long line_time_us;
1827 int sr_clock, sr_entries = 0;
1828
1829 if (IS_I965GM(dev) || IS_I945GM(dev))
1830 wm_params = &i945_wm_info;
1831 else if (IS_I9XX(dev))
1832 wm_params = &i915_wm_info;
1833 else
1834 wm_params = &i855_wm_info;
1835
1836 planea_entries = intel_calculate_wm(planea_clock, wm_params,
1837 pixel_size, latency_ns);
1838 planeb_entries = intel_calculate_wm(planeb_clock, wm_params,
1839 pixel_size, latency_ns);
1840
1841 DRM_DEBUG("FIFO entries - A: %d, B: %d\n", planea_entries,
1842 planeb_entries);
1843
1844 if (IS_I9XX(dev)) {
1845 asize = dsparb & 0x7f;
1846 bsize = (dsparb >> DSPARB_CSTART_SHIFT) & 0x7f;
1847 } else {
1848 asize = dsparb & 0x1ff;
1849 bsize = (dsparb >> DSPARB_BEND_SHIFT) & 0x1ff;
1850 }
1851 DRM_DEBUG("FIFO size - A: %d, B: %d\n", asize, bsize);
1852
1853 /* Two extra entries for padding */
1854 awm = asize - (planea_entries + 2);
1855 bwm = bsize - (planeb_entries + 2);
1856
1857 /* Sanity check against potentially bad FIFO allocations */
1858 if (awm <= 0) {
1859 /* pipe is on but has too few FIFO entries */
1860 if (planea_entries != 0)
1861 DRM_DEBUG("plane A needs more FIFO entries\n");
1862 awm = 1;
1863 }
1864 if (bwm <= 0) {
1865 if (planeb_entries != 0)
1866 DRM_DEBUG("plane B needs more FIFO entries\n");
1867 bwm = 1;
1868 }
1869
1870 /*
1871 * Overlay gets an aggressive default since video jitter is bad.
1872 */
1873 cwm = 2;
1874
1875 /* Calc sr entries for one pipe configs */
1876 if (!planea_clock || !planeb_clock) {
1877 sr_clock = planea_clock ? planea_clock : planeb_clock;
1878 line_time_us = (sr_hdisplay * 1000) / sr_clock;
1879 sr_entries = (((latency_ns / line_time_us) + 1) * pixel_size *
1880 sr_hdisplay) / 1000;
1881 sr_entries = roundup(sr_entries / wm_params->cacheline_size, 1);
1882 if (sr_entries < wm_params->fifo_size)
1883 srwm = wm_params->fifo_size - sr_entries;
1884 }
1885
1886 DRM_DEBUG("Setting FIFO watermarks - A: %d, B: %d, C: %d, SR %d\n",
1887 awm, bwm, cwm, srwm);
1888
1889 fwater_lo = fwater_lo | ((bwm & 0x3f) << 16) | (awm & 0x3f);
1890 fwater_hi = fwater_hi | (cwm & 0x1f);
1891
1892 I915_WRITE(FW_BLC, fwater_lo);
1893 I915_WRITE(FW_BLC2, fwater_hi);
1894 if (IS_I9XX(dev))
1895 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN | (srwm & 0x3f));
1896}
1897
1898static void i830_update_wm(struct drm_device *dev, int planea_clock,
1899 int pixel_size)
1900{
1901 struct drm_i915_private *dev_priv = dev->dev_private;
1902 uint32_t dsparb = I915_READ(DSPARB);
1903 uint32_t fwater_lo = I915_READ(FW_BLC) & MM_FIFO_WATERMARK;
1904 unsigned int asize, awm;
1905 int planea_entries;
1906
1907 planea_entries = intel_calculate_wm(planea_clock, &i830_wm_info,
1908 pixel_size, latency_ns);
1909
1910 asize = dsparb & 0x7f;
1911
1912 awm = asize - planea_entries;
1913
1914 fwater_lo = fwater_lo | awm;
1915
1916 I915_WRITE(FW_BLC, fwater_lo);
1917}
1918
1919/**
1920 * intel_update_watermarks - update FIFO watermark values based on current modes
1921 *
1922 * Calculate watermark values for the various WM regs based on current mode
1923 * and plane configuration.
1924 *
1925 * There are several cases to deal with here:
1926 * - normal (i.e. non-self-refresh)
1927 * - self-refresh (SR) mode
1928 * - lines are large relative to FIFO size (buffer can hold up to 2)
1929 * - lines are small relative to FIFO size (buffer can hold more than 2
1930 * lines), so need to account for TLB latency
1931 *
1932 * The normal calculation is:
1933 * watermark = dotclock * bytes per pixel * latency
1934 * where latency is platform & configuration dependent (we assume pessimal
1935 * values here).
1936 *
1937 * The SR calculation is:
1938 * watermark = (trunc(latency/line time)+1) * surface width *
1939 * bytes per pixel
1940 * where
1941 * line time = htotal / dotclock
1942 * and latency is assumed to be high, as above.
1943 *
1944 * The final value programmed to the register should always be rounded up,
1945 * and include an extra 2 entries to account for clock crossings.
1946 *
1947 * We don't use the sprite, so we can ignore that. And on Crestline we have
1948 * to set the non-SR watermarks to 8.
1949 */
1950static void intel_update_watermarks(struct drm_device *dev)
1951{
1952 struct drm_crtc *crtc;
1953 struct intel_crtc *intel_crtc;
1954 int sr_hdisplay = 0;
1955 unsigned long planea_clock = 0, planeb_clock = 0, sr_clock = 0;
1956 int enabled = 0, pixel_size = 0;
1957
1958 if (DSPARB_HWCONTROL(dev))
1959 return;
1960
1961 /* Get the clock config from both planes */
1962 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1963 intel_crtc = to_intel_crtc(crtc);
1964 if (crtc->enabled) {
1965 enabled++;
1966 if (intel_crtc->plane == 0) {
1967 DRM_DEBUG("plane A (pipe %d) clock: %d\n",
1968 intel_crtc->pipe, crtc->mode.clock);
1969 planea_clock = crtc->mode.clock;
1970 } else {
1971 DRM_DEBUG("plane B (pipe %d) clock: %d\n",
1972 intel_crtc->pipe, crtc->mode.clock);
1973 planeb_clock = crtc->mode.clock;
1974 }
1975 sr_hdisplay = crtc->mode.hdisplay;
1976 sr_clock = crtc->mode.clock;
1977 if (crtc->fb)
1978 pixel_size = crtc->fb->bits_per_pixel / 8;
1979 else
1980 pixel_size = 4; /* by default */
1981 }
1982 }
1983
1984 if (enabled <= 0)
1985 return;
1986
1987 /* Single pipe configs can enable self refresh */
1988 if (enabled == 1 && IS_IGD(dev))
1989 igd_enable_cxsr(dev, sr_clock, pixel_size);
1990 else if (IS_IGD(dev))
1991 igd_disable_cxsr(dev);
1992
1993 if (IS_I965G(dev))
1994 i965_update_wm(dev);
1995 else if (IS_I9XX(dev) || IS_MOBILE(dev))
1996 i9xx_update_wm(dev, planea_clock, planeb_clock, sr_hdisplay,
1997 pixel_size);
1998 else
1999 i830_update_wm(dev, planea_clock, pixel_size);
2000}
2001
1516static int intel_crtc_mode_set(struct drm_crtc *crtc, 2002static int intel_crtc_mode_set(struct drm_crtc *crtc,
1517 struct drm_display_mode *mode, 2003 struct drm_display_mode *mode,
1518 struct drm_display_mode *adjusted_mode, 2004 struct drm_display_mode *adjusted_mode,
@@ -1541,7 +2027,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
1541 intel_clock_t clock; 2027 intel_clock_t clock;
1542 u32 dpll = 0, fp = 0, dspcntr, pipeconf; 2028 u32 dpll = 0, fp = 0, dspcntr, pipeconf;
1543 bool ok, is_sdvo = false, is_dvo = false; 2029 bool ok, is_sdvo = false, is_dvo = false;
1544 bool is_crt = false, is_lvds = false, is_tv = false; 2030 bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false;
1545 struct drm_mode_config *mode_config = &dev->mode_config; 2031 struct drm_mode_config *mode_config = &dev->mode_config;
1546 struct drm_connector *connector; 2032 struct drm_connector *connector;
1547 const intel_limit_t *limit; 2033 const intel_limit_t *limit;
@@ -1585,6 +2071,9 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
1585 case INTEL_OUTPUT_ANALOG: 2071 case INTEL_OUTPUT_ANALOG:
1586 is_crt = true; 2072 is_crt = true;
1587 break; 2073 break;
2074 case INTEL_OUTPUT_DISPLAYPORT:
2075 is_dp = true;
2076 break;
1588 } 2077 }
1589 2078
1590 num_outputs++; 2079 num_outputs++;
@@ -1600,6 +2089,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
1600 } else { 2089 } else {
1601 refclk = 48000; 2090 refclk = 48000;
1602 } 2091 }
2092
1603 2093
1604 /* 2094 /*
1605 * Returns a set of divisors for the desired target clock with the given 2095 * Returns a set of divisors for the desired target clock with the given
@@ -1662,6 +2152,8 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
1662 else if (IS_IGDNG(dev)) 2152 else if (IS_IGDNG(dev))
1663 dpll |= (sdvo_pixel_multiply - 1) << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT; 2153 dpll |= (sdvo_pixel_multiply - 1) << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT;
1664 } 2154 }
2155 if (is_dp)
2156 dpll |= DPLL_DVO_HIGH_SPEED;
1665 2157
1666 /* compute bitmask from p1 value */ 2158 /* compute bitmask from p1 value */
1667 if (IS_IGD(dev)) 2159 if (IS_IGD(dev))
@@ -1809,6 +2301,8 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
1809 I915_WRITE(lvds_reg, lvds); 2301 I915_WRITE(lvds_reg, lvds);
1810 I915_READ(lvds_reg); 2302 I915_READ(lvds_reg);
1811 } 2303 }
2304 if (is_dp)
2305 intel_dp_set_m_n(crtc, mode, adjusted_mode);
1812 2306
1813 I915_WRITE(fp_reg, fp); 2307 I915_WRITE(fp_reg, fp);
1814 I915_WRITE(dpll_reg, dpll); 2308 I915_WRITE(dpll_reg, dpll);
@@ -1871,6 +2365,9 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
1871 2365
1872 /* Flush the plane changes */ 2366 /* Flush the plane changes */
1873 ret = intel_pipe_set_base(crtc, x, y, old_fb); 2367 ret = intel_pipe_set_base(crtc, x, y, old_fb);
2368
2369 intel_update_watermarks(dev);
2370
1874 drm_vblank_post_modeset(dev, pipe); 2371 drm_vblank_post_modeset(dev, pipe);
1875 2372
1876 return ret; 2373 return ret;
@@ -2359,6 +2856,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
2359 2856
2360 drm_mode_crtc_set_gamma_size(&intel_crtc->base, 256); 2857 drm_mode_crtc_set_gamma_size(&intel_crtc->base, 256);
2361 intel_crtc->pipe = pipe; 2858 intel_crtc->pipe = pipe;
2859 intel_crtc->plane = pipe;
2362 for (i = 0; i < 256; i++) { 2860 for (i = 0; i < 256; i++) {
2363 intel_crtc->lut_r[i] = i; 2861 intel_crtc->lut_r[i] = i;
2364 intel_crtc->lut_g[i] = i; 2862 intel_crtc->lut_g[i] = i;
@@ -2475,6 +2973,8 @@ static void intel_setup_outputs(struct drm_device *dev)
2475 found = intel_sdvo_init(dev, SDVOB); 2973 found = intel_sdvo_init(dev, SDVOB);
2476 if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) 2974 if (!found && SUPPORTS_INTEGRATED_HDMI(dev))
2477 intel_hdmi_init(dev, SDVOB); 2975 intel_hdmi_init(dev, SDVOB);
2976 if (!found && SUPPORTS_INTEGRATED_DP(dev))
2977 intel_dp_init(dev, DP_B);
2478 } 2978 }
2479 2979
2480 /* Before G4X SDVOC doesn't have its own detect register */ 2980 /* Before G4X SDVOC doesn't have its own detect register */
@@ -2487,7 +2987,11 @@ static void intel_setup_outputs(struct drm_device *dev)
2487 found = intel_sdvo_init(dev, SDVOC); 2987 found = intel_sdvo_init(dev, SDVOC);
2488 if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) 2988 if (!found && SUPPORTS_INTEGRATED_HDMI(dev))
2489 intel_hdmi_init(dev, SDVOC); 2989 intel_hdmi_init(dev, SDVOC);
2990 if (!found && SUPPORTS_INTEGRATED_DP(dev))
2991 intel_dp_init(dev, DP_C);
2490 } 2992 }
2993 if (SUPPORTS_INTEGRATED_DP(dev) && (I915_READ(DP_D) & DP_DETECTED))
2994 intel_dp_init(dev, DP_D);
2491 } else 2995 } else
2492 intel_dvo_init(dev); 2996 intel_dvo_init(dev);
2493 2997
@@ -2530,6 +3034,11 @@ static void intel_setup_outputs(struct drm_device *dev)
2530 (1 << 1)); 3034 (1 << 1));
2531 clone_mask = (1 << INTEL_OUTPUT_TVOUT); 3035 clone_mask = (1 << INTEL_OUTPUT_TVOUT);
2532 break; 3036 break;
3037 case INTEL_OUTPUT_DISPLAYPORT:
3038 crtc_mask = ((1 << 0) |
3039 (1 << 1));
3040 clone_mask = (1 << INTEL_OUTPUT_DISPLAYPORT);
3041 break;
2533 } 3042 }
2534 encoder->possible_crtcs = crtc_mask; 3043 encoder->possible_crtcs = crtc_mask;
2535 encoder->possible_clones = intel_connector_clones(dev, clone_mask); 3044 encoder->possible_clones = intel_connector_clones(dev, clone_mask);
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
new file mode 100644
index 000000000000..6770ae88370d
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -0,0 +1,1156 @@
1/*
2 * Copyright © 2008 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Keith Packard <keithp@keithp.com>
25 *
26 */
27
28#include <linux/i2c.h>
29#include "drmP.h"
30#include "drm.h"
31#include "drm_crtc.h"
32#include "drm_crtc_helper.h"
33#include "intel_drv.h"
34#include "i915_drm.h"
35#include "i915_drv.h"
36#include "intel_dp.h"
37
38#define DP_LINK_STATUS_SIZE 6
39#define DP_LINK_CHECK_TIMEOUT (10 * 1000)
40
41#define DP_LINK_CONFIGURATION_SIZE 9
42
43struct intel_dp_priv {
44 uint32_t output_reg;
45 uint32_t DP;
46 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE];
47 uint32_t save_DP;
48 uint8_t save_link_configuration[DP_LINK_CONFIGURATION_SIZE];
49 bool has_audio;
50 int dpms_mode;
51 uint8_t link_bw;
52 uint8_t lane_count;
53 uint8_t dpcd[4];
54 struct intel_output *intel_output;
55 struct i2c_adapter adapter;
56 struct i2c_algo_dp_aux_data algo;
57};
58
59static void
60intel_dp_link_train(struct intel_output *intel_output, uint32_t DP,
61 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE]);
62
63static void
64intel_dp_link_down(struct intel_output *intel_output, uint32_t DP);
65
66static int
67intel_dp_max_lane_count(struct intel_output *intel_output)
68{
69 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
70 int max_lane_count = 4;
71
72 if (dp_priv->dpcd[0] >= 0x11) {
73 max_lane_count = dp_priv->dpcd[2] & 0x1f;
74 switch (max_lane_count) {
75 case 1: case 2: case 4:
76 break;
77 default:
78 max_lane_count = 4;
79 }
80 }
81 return max_lane_count;
82}
83
84static int
85intel_dp_max_link_bw(struct intel_output *intel_output)
86{
87 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
88 int max_link_bw = dp_priv->dpcd[1];
89
90 switch (max_link_bw) {
91 case DP_LINK_BW_1_62:
92 case DP_LINK_BW_2_7:
93 break;
94 default:
95 max_link_bw = DP_LINK_BW_1_62;
96 break;
97 }
98 return max_link_bw;
99}
100
101static int
102intel_dp_link_clock(uint8_t link_bw)
103{
104 if (link_bw == DP_LINK_BW_2_7)
105 return 270000;
106 else
107 return 162000;
108}
109
110/* I think this is a fiction */
111static int
112intel_dp_link_required(int pixel_clock)
113{
114 return pixel_clock * 3;
115}
116
117static int
118intel_dp_mode_valid(struct drm_connector *connector,
119 struct drm_display_mode *mode)
120{
121 struct intel_output *intel_output = to_intel_output(connector);
122 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_output));
123 int max_lanes = intel_dp_max_lane_count(intel_output);
124
125 if (intel_dp_link_required(mode->clock) > max_link_clock * max_lanes)
126 return MODE_CLOCK_HIGH;
127
128 if (mode->clock < 10000)
129 return MODE_CLOCK_LOW;
130
131 return MODE_OK;
132}
133
134static uint32_t
135pack_aux(uint8_t *src, int src_bytes)
136{
137 int i;
138 uint32_t v = 0;
139
140 if (src_bytes > 4)
141 src_bytes = 4;
142 for (i = 0; i < src_bytes; i++)
143 v |= ((uint32_t) src[i]) << ((3-i) * 8);
144 return v;
145}
146
147static void
148unpack_aux(uint32_t src, uint8_t *dst, int dst_bytes)
149{
150 int i;
151 if (dst_bytes > 4)
152 dst_bytes = 4;
153 for (i = 0; i < dst_bytes; i++)
154 dst[i] = src >> ((3-i) * 8);
155}
156
157/* hrawclock is 1/4 the FSB frequency */
158static int
159intel_hrawclk(struct drm_device *dev)
160{
161 struct drm_i915_private *dev_priv = dev->dev_private;
162 uint32_t clkcfg;
163
164 clkcfg = I915_READ(CLKCFG);
165 switch (clkcfg & CLKCFG_FSB_MASK) {
166 case CLKCFG_FSB_400:
167 return 100;
168 case CLKCFG_FSB_533:
169 return 133;
170 case CLKCFG_FSB_667:
171 return 166;
172 case CLKCFG_FSB_800:
173 return 200;
174 case CLKCFG_FSB_1067:
175 return 266;
176 case CLKCFG_FSB_1333:
177 return 333;
178 /* these two are just a guess; one of them might be right */
179 case CLKCFG_FSB_1600:
180 case CLKCFG_FSB_1600_ALT:
181 return 400;
182 default:
183 return 133;
184 }
185}
186
187static int
188intel_dp_aux_ch(struct intel_output *intel_output,
189 uint8_t *send, int send_bytes,
190 uint8_t *recv, int recv_size)
191{
192 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
193 uint32_t output_reg = dp_priv->output_reg;
194 struct drm_device *dev = intel_output->base.dev;
195 struct drm_i915_private *dev_priv = dev->dev_private;
196 uint32_t ch_ctl = output_reg + 0x10;
197 uint32_t ch_data = ch_ctl + 4;
198 int i;
199 int recv_bytes;
200 uint32_t ctl;
201 uint32_t status;
202 uint32_t aux_clock_divider;
203 int try;
204
205 /* The clock divider is based off the hrawclk,
206 * and would like to run at 2MHz. So, take the
207 * hrawclk value and divide by 2 and use that
208 */
209 aux_clock_divider = intel_hrawclk(dev) / 2;
210 /* Must try at least 3 times according to DP spec */
211 for (try = 0; try < 5; try++) {
212 /* Load the send data into the aux channel data registers */
213 for (i = 0; i < send_bytes; i += 4) {
214 uint32_t d = pack_aux(send + i, send_bytes - i);;
215
216 I915_WRITE(ch_data + i, d);
217 }
218
219 ctl = (DP_AUX_CH_CTL_SEND_BUSY |
220 DP_AUX_CH_CTL_TIME_OUT_400us |
221 (send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) |
222 (5 << DP_AUX_CH_CTL_PRECHARGE_2US_SHIFT) |
223 (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT) |
224 DP_AUX_CH_CTL_DONE |
225 DP_AUX_CH_CTL_TIME_OUT_ERROR |
226 DP_AUX_CH_CTL_RECEIVE_ERROR);
227
228 /* Send the command and wait for it to complete */
229 I915_WRITE(ch_ctl, ctl);
230 (void) I915_READ(ch_ctl);
231 for (;;) {
232 udelay(100);
233 status = I915_READ(ch_ctl);
234 if ((status & DP_AUX_CH_CTL_SEND_BUSY) == 0)
235 break;
236 }
237
238 /* Clear done status and any errors */
239 I915_WRITE(ch_ctl, (ctl |
240 DP_AUX_CH_CTL_DONE |
241 DP_AUX_CH_CTL_TIME_OUT_ERROR |
242 DP_AUX_CH_CTL_RECEIVE_ERROR));
243 (void) I915_READ(ch_ctl);
244 if ((status & DP_AUX_CH_CTL_TIME_OUT_ERROR) == 0)
245 break;
246 }
247
248 if ((status & DP_AUX_CH_CTL_DONE) == 0) {
249 DRM_ERROR("dp_aux_ch not done status 0x%08x\n", status);
250 return -EBUSY;
251 }
252
253 /* Check for timeout or receive error.
254 * Timeouts occur when the sink is not connected
255 */
256 if (status & DP_AUX_CH_CTL_RECEIVE_ERROR) {
257 DRM_ERROR("dp_aux_ch receive error status 0x%08x\n", status);
258 return -EIO;
259 }
260
261 /* Timeouts occur when the device isn't connected, so they're
262 * "normal" -- don't fill the kernel log with these */
263 if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR) {
264 DRM_DEBUG("dp_aux_ch timeout status 0x%08x\n", status);
265 return -ETIMEDOUT;
266 }
267
268 /* Unload any bytes sent back from the other side */
269 recv_bytes = ((status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK) >>
270 DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT);
271
272 if (recv_bytes > recv_size)
273 recv_bytes = recv_size;
274
275 for (i = 0; i < recv_bytes; i += 4) {
276 uint32_t d = I915_READ(ch_data + i);
277
278 unpack_aux(d, recv + i, recv_bytes - i);
279 }
280
281 return recv_bytes;
282}
283
284/* Write data to the aux channel in native mode */
285static int
286intel_dp_aux_native_write(struct intel_output *intel_output,
287 uint16_t address, uint8_t *send, int send_bytes)
288{
289 int ret;
290 uint8_t msg[20];
291 int msg_bytes;
292 uint8_t ack;
293
294 if (send_bytes > 16)
295 return -1;
296 msg[0] = AUX_NATIVE_WRITE << 4;
297 msg[1] = address >> 8;
298 msg[2] = address;
299 msg[3] = send_bytes - 1;
300 memcpy(&msg[4], send, send_bytes);
301 msg_bytes = send_bytes + 4;
302 for (;;) {
303 ret = intel_dp_aux_ch(intel_output, msg, msg_bytes, &ack, 1);
304 if (ret < 0)
305 return ret;
306 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK)
307 break;
308 else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER)
309 udelay(100);
310 else
311 return -EIO;
312 }
313 return send_bytes;
314}
315
316/* Write a single byte to the aux channel in native mode */
317static int
318intel_dp_aux_native_write_1(struct intel_output *intel_output,
319 uint16_t address, uint8_t byte)
320{
321 return intel_dp_aux_native_write(intel_output, address, &byte, 1);
322}
323
324/* read bytes from a native aux channel */
325static int
326intel_dp_aux_native_read(struct intel_output *intel_output,
327 uint16_t address, uint8_t *recv, int recv_bytes)
328{
329 uint8_t msg[4];
330 int msg_bytes;
331 uint8_t reply[20];
332 int reply_bytes;
333 uint8_t ack;
334 int ret;
335
336 msg[0] = AUX_NATIVE_READ << 4;
337 msg[1] = address >> 8;
338 msg[2] = address & 0xff;
339 msg[3] = recv_bytes - 1;
340
341 msg_bytes = 4;
342 reply_bytes = recv_bytes + 1;
343
344 for (;;) {
345 ret = intel_dp_aux_ch(intel_output, msg, msg_bytes,
346 reply, reply_bytes);
347 if (ret == 0)
348 return -EPROTO;
349 if (ret < 0)
350 return ret;
351 ack = reply[0];
352 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) {
353 memcpy(recv, reply + 1, ret - 1);
354 return ret - 1;
355 }
356 else if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_DEFER)
357 udelay(100);
358 else
359 return -EIO;
360 }
361}
362
363static int
364intel_dp_i2c_aux_ch(struct i2c_adapter *adapter,
365 uint8_t *send, int send_bytes,
366 uint8_t *recv, int recv_bytes)
367{
368 struct intel_dp_priv *dp_priv = container_of(adapter,
369 struct intel_dp_priv,
370 adapter);
371 struct intel_output *intel_output = dp_priv->intel_output;
372
373 return intel_dp_aux_ch(intel_output,
374 send, send_bytes, recv, recv_bytes);
375}
376
377static int
378intel_dp_i2c_init(struct intel_output *intel_output, const char *name)
379{
380 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
381
382 DRM_ERROR("i2c_init %s\n", name);
383 dp_priv->algo.running = false;
384 dp_priv->algo.address = 0;
385 dp_priv->algo.aux_ch = intel_dp_i2c_aux_ch;
386
387 memset(&dp_priv->adapter, '\0', sizeof (dp_priv->adapter));
388 dp_priv->adapter.owner = THIS_MODULE;
389 dp_priv->adapter.class = I2C_CLASS_DDC;
390 strncpy (dp_priv->adapter.name, name, sizeof dp_priv->adapter.name - 1);
391 dp_priv->adapter.name[sizeof dp_priv->adapter.name - 1] = '\0';
392 dp_priv->adapter.algo_data = &dp_priv->algo;
393 dp_priv->adapter.dev.parent = &intel_output->base.kdev;
394
395 return i2c_dp_aux_add_bus(&dp_priv->adapter);
396}
397
398static bool
399intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
400 struct drm_display_mode *adjusted_mode)
401{
402 struct intel_output *intel_output = enc_to_intel_output(encoder);
403 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
404 int lane_count, clock;
405 int max_lane_count = intel_dp_max_lane_count(intel_output);
406 int max_clock = intel_dp_max_link_bw(intel_output) == DP_LINK_BW_2_7 ? 1 : 0;
407 static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };
408
409 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
410 for (clock = 0; clock <= max_clock; clock++) {
411 int link_avail = intel_dp_link_clock(bws[clock]) * lane_count;
412
413 if (intel_dp_link_required(mode->clock) <= link_avail) {
414 dp_priv->link_bw = bws[clock];
415 dp_priv->lane_count = lane_count;
416 adjusted_mode->clock = intel_dp_link_clock(dp_priv->link_bw);
417 DRM_DEBUG("Display port link bw %02x lane count %d clock %d\n",
418 dp_priv->link_bw, dp_priv->lane_count,
419 adjusted_mode->clock);
420 return true;
421 }
422 }
423 }
424 return false;
425}
426
427struct intel_dp_m_n {
428 uint32_t tu;
429 uint32_t gmch_m;
430 uint32_t gmch_n;
431 uint32_t link_m;
432 uint32_t link_n;
433};
434
435static void
436intel_reduce_ratio(uint32_t *num, uint32_t *den)
437{
438 while (*num > 0xffffff || *den > 0xffffff) {
439 *num >>= 1;
440 *den >>= 1;
441 }
442}
443
444static void
445intel_dp_compute_m_n(int bytes_per_pixel,
446 int nlanes,
447 int pixel_clock,
448 int link_clock,
449 struct intel_dp_m_n *m_n)
450{
451 m_n->tu = 64;
452 m_n->gmch_m = pixel_clock * bytes_per_pixel;
453 m_n->gmch_n = link_clock * nlanes;
454 intel_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n);
455 m_n->link_m = pixel_clock;
456 m_n->link_n = link_clock;
457 intel_reduce_ratio(&m_n->link_m, &m_n->link_n);
458}
459
460void
461intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
462 struct drm_display_mode *adjusted_mode)
463{
464 struct drm_device *dev = crtc->dev;
465 struct drm_mode_config *mode_config = &dev->mode_config;
466 struct drm_connector *connector;
467 struct drm_i915_private *dev_priv = dev->dev_private;
468 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
469 int lane_count = 4;
470 struct intel_dp_m_n m_n;
471
472 /*
473 * Find the lane count in the intel_output private
474 */
475 list_for_each_entry(connector, &mode_config->connector_list, head) {
476 struct intel_output *intel_output = to_intel_output(connector);
477 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
478
479 if (!connector->encoder || connector->encoder->crtc != crtc)
480 continue;
481
482 if (intel_output->type == INTEL_OUTPUT_DISPLAYPORT) {
483 lane_count = dp_priv->lane_count;
484 break;
485 }
486 }
487
488 /*
489 * Compute the GMCH and Link ratios. The '3' here is
490 * the number of bytes_per_pixel post-LUT, which we always
491 * set up for 8-bits of R/G/B, or 3 bytes total.
492 */
493 intel_dp_compute_m_n(3, lane_count,
494 mode->clock, adjusted_mode->clock, &m_n);
495
496 if (intel_crtc->pipe == 0) {
497 I915_WRITE(PIPEA_GMCH_DATA_M,
498 ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
499 m_n.gmch_m);
500 I915_WRITE(PIPEA_GMCH_DATA_N,
501 m_n.gmch_n);
502 I915_WRITE(PIPEA_DP_LINK_M, m_n.link_m);
503 I915_WRITE(PIPEA_DP_LINK_N, m_n.link_n);
504 } else {
505 I915_WRITE(PIPEB_GMCH_DATA_M,
506 ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
507 m_n.gmch_m);
508 I915_WRITE(PIPEB_GMCH_DATA_N,
509 m_n.gmch_n);
510 I915_WRITE(PIPEB_DP_LINK_M, m_n.link_m);
511 I915_WRITE(PIPEB_DP_LINK_N, m_n.link_n);
512 }
513}
514
515static void
516intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
517 struct drm_display_mode *adjusted_mode)
518{
519 struct intel_output *intel_output = enc_to_intel_output(encoder);
520 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
521 struct drm_crtc *crtc = intel_output->enc.crtc;
522 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
523
524 dp_priv->DP = (DP_LINK_TRAIN_OFF |
525 DP_VOLTAGE_0_4 |
526 DP_PRE_EMPHASIS_0 |
527 DP_SYNC_VS_HIGH |
528 DP_SYNC_HS_HIGH);
529
530 switch (dp_priv->lane_count) {
531 case 1:
532 dp_priv->DP |= DP_PORT_WIDTH_1;
533 break;
534 case 2:
535 dp_priv->DP |= DP_PORT_WIDTH_2;
536 break;
537 case 4:
538 dp_priv->DP |= DP_PORT_WIDTH_4;
539 break;
540 }
541 if (dp_priv->has_audio)
542 dp_priv->DP |= DP_AUDIO_OUTPUT_ENABLE;
543
544 memset(dp_priv->link_configuration, 0, DP_LINK_CONFIGURATION_SIZE);
545 dp_priv->link_configuration[0] = dp_priv->link_bw;
546 dp_priv->link_configuration[1] = dp_priv->lane_count;
547
548 /*
549 * Check for DPCD version > 1.1,
550 * enable enahanced frame stuff in that case
551 */
552 if (dp_priv->dpcd[0] >= 0x11) {
553 dp_priv->link_configuration[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
554 dp_priv->DP |= DP_ENHANCED_FRAMING;
555 }
556
557 if (intel_crtc->pipe == 1)
558 dp_priv->DP |= DP_PIPEB_SELECT;
559}
560
561
562static void
563intel_dp_dpms(struct drm_encoder *encoder, int mode)
564{
565 struct intel_output *intel_output = enc_to_intel_output(encoder);
566 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
567 struct drm_device *dev = intel_output->base.dev;
568 struct drm_i915_private *dev_priv = dev->dev_private;
569 uint32_t dp_reg = I915_READ(dp_priv->output_reg);
570
571 if (mode != DRM_MODE_DPMS_ON) {
572 if (dp_reg & DP_PORT_EN)
573 intel_dp_link_down(intel_output, dp_priv->DP);
574 } else {
575 if (!(dp_reg & DP_PORT_EN))
576 intel_dp_link_train(intel_output, dp_priv->DP, dp_priv->link_configuration);
577 }
578 dp_priv->dpms_mode = mode;
579}
580
581/*
582 * Fetch AUX CH registers 0x202 - 0x207 which contain
583 * link status information
584 */
585static bool
586intel_dp_get_link_status(struct intel_output *intel_output,
587 uint8_t link_status[DP_LINK_STATUS_SIZE])
588{
589 int ret;
590
591 ret = intel_dp_aux_native_read(intel_output,
592 DP_LANE0_1_STATUS,
593 link_status, DP_LINK_STATUS_SIZE);
594 if (ret != DP_LINK_STATUS_SIZE)
595 return false;
596 return true;
597}
598
599static uint8_t
600intel_dp_link_status(uint8_t link_status[DP_LINK_STATUS_SIZE],
601 int r)
602{
603 return link_status[r - DP_LANE0_1_STATUS];
604}
605
606static void
607intel_dp_save(struct drm_connector *connector)
608{
609 struct intel_output *intel_output = to_intel_output(connector);
610 struct drm_device *dev = intel_output->base.dev;
611 struct drm_i915_private *dev_priv = dev->dev_private;
612 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
613
614 dp_priv->save_DP = I915_READ(dp_priv->output_reg);
615 intel_dp_aux_native_read(intel_output, DP_LINK_BW_SET,
616 dp_priv->save_link_configuration,
617 sizeof (dp_priv->save_link_configuration));
618}
619
620static uint8_t
621intel_get_adjust_request_voltage(uint8_t link_status[DP_LINK_STATUS_SIZE],
622 int lane)
623{
624 int i = DP_ADJUST_REQUEST_LANE0_1 + (lane >> 1);
625 int s = ((lane & 1) ?
626 DP_ADJUST_VOLTAGE_SWING_LANE1_SHIFT :
627 DP_ADJUST_VOLTAGE_SWING_LANE0_SHIFT);
628 uint8_t l = intel_dp_link_status(link_status, i);
629
630 return ((l >> s) & 3) << DP_TRAIN_VOLTAGE_SWING_SHIFT;
631}
632
633static uint8_t
634intel_get_adjust_request_pre_emphasis(uint8_t link_status[DP_LINK_STATUS_SIZE],
635 int lane)
636{
637 int i = DP_ADJUST_REQUEST_LANE0_1 + (lane >> 1);
638 int s = ((lane & 1) ?
639 DP_ADJUST_PRE_EMPHASIS_LANE1_SHIFT :
640 DP_ADJUST_PRE_EMPHASIS_LANE0_SHIFT);
641 uint8_t l = intel_dp_link_status(link_status, i);
642
643 return ((l >> s) & 3) << DP_TRAIN_PRE_EMPHASIS_SHIFT;
644}
645
646
647#if 0
648static char *voltage_names[] = {
649 "0.4V", "0.6V", "0.8V", "1.2V"
650};
651static char *pre_emph_names[] = {
652 "0dB", "3.5dB", "6dB", "9.5dB"
653};
654static char *link_train_names[] = {
655 "pattern 1", "pattern 2", "idle", "off"
656};
657#endif
658
659/*
660 * These are source-specific values; current Intel hardware supports
661 * a maximum voltage of 800mV and a maximum pre-emphasis of 6dB
662 */
663#define I830_DP_VOLTAGE_MAX DP_TRAIN_VOLTAGE_SWING_800
664
665static uint8_t
666intel_dp_pre_emphasis_max(uint8_t voltage_swing)
667{
668 switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) {
669 case DP_TRAIN_VOLTAGE_SWING_400:
670 return DP_TRAIN_PRE_EMPHASIS_6;
671 case DP_TRAIN_VOLTAGE_SWING_600:
672 return DP_TRAIN_PRE_EMPHASIS_6;
673 case DP_TRAIN_VOLTAGE_SWING_800:
674 return DP_TRAIN_PRE_EMPHASIS_3_5;
675 case DP_TRAIN_VOLTAGE_SWING_1200:
676 default:
677 return DP_TRAIN_PRE_EMPHASIS_0;
678 }
679}
680
681static void
682intel_get_adjust_train(struct intel_output *intel_output,
683 uint8_t link_status[DP_LINK_STATUS_SIZE],
684 int lane_count,
685 uint8_t train_set[4])
686{
687 uint8_t v = 0;
688 uint8_t p = 0;
689 int lane;
690
691 for (lane = 0; lane < lane_count; lane++) {
692 uint8_t this_v = intel_get_adjust_request_voltage(link_status, lane);
693 uint8_t this_p = intel_get_adjust_request_pre_emphasis(link_status, lane);
694
695 if (this_v > v)
696 v = this_v;
697 if (this_p > p)
698 p = this_p;
699 }
700
701 if (v >= I830_DP_VOLTAGE_MAX)
702 v = I830_DP_VOLTAGE_MAX | DP_TRAIN_MAX_SWING_REACHED;
703
704 if (p >= intel_dp_pre_emphasis_max(v))
705 p = intel_dp_pre_emphasis_max(v) | DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
706
707 for (lane = 0; lane < 4; lane++)
708 train_set[lane] = v | p;
709}
710
711static uint32_t
712intel_dp_signal_levels(uint8_t train_set, int lane_count)
713{
714 uint32_t signal_levels = 0;
715
716 switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) {
717 case DP_TRAIN_VOLTAGE_SWING_400:
718 default:
719 signal_levels |= DP_VOLTAGE_0_4;
720 break;
721 case DP_TRAIN_VOLTAGE_SWING_600:
722 signal_levels |= DP_VOLTAGE_0_6;
723 break;
724 case DP_TRAIN_VOLTAGE_SWING_800:
725 signal_levels |= DP_VOLTAGE_0_8;
726 break;
727 case DP_TRAIN_VOLTAGE_SWING_1200:
728 signal_levels |= DP_VOLTAGE_1_2;
729 break;
730 }
731 switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) {
732 case DP_TRAIN_PRE_EMPHASIS_0:
733 default:
734 signal_levels |= DP_PRE_EMPHASIS_0;
735 break;
736 case DP_TRAIN_PRE_EMPHASIS_3_5:
737 signal_levels |= DP_PRE_EMPHASIS_3_5;
738 break;
739 case DP_TRAIN_PRE_EMPHASIS_6:
740 signal_levels |= DP_PRE_EMPHASIS_6;
741 break;
742 case DP_TRAIN_PRE_EMPHASIS_9_5:
743 signal_levels |= DP_PRE_EMPHASIS_9_5;
744 break;
745 }
746 return signal_levels;
747}
748
749static uint8_t
750intel_get_lane_status(uint8_t link_status[DP_LINK_STATUS_SIZE],
751 int lane)
752{
753 int i = DP_LANE0_1_STATUS + (lane >> 1);
754 int s = (lane & 1) * 4;
755 uint8_t l = intel_dp_link_status(link_status, i);
756
757 return (l >> s) & 0xf;
758}
759
760/* Check for clock recovery is done on all channels */
761static bool
762intel_clock_recovery_ok(uint8_t link_status[DP_LINK_STATUS_SIZE], int lane_count)
763{
764 int lane;
765 uint8_t lane_status;
766
767 for (lane = 0; lane < lane_count; lane++) {
768 lane_status = intel_get_lane_status(link_status, lane);
769 if ((lane_status & DP_LANE_CR_DONE) == 0)
770 return false;
771 }
772 return true;
773}
774
775/* Check to see if channel eq is done on all channels */
776#define CHANNEL_EQ_BITS (DP_LANE_CR_DONE|\
777 DP_LANE_CHANNEL_EQ_DONE|\
778 DP_LANE_SYMBOL_LOCKED)
779static bool
780intel_channel_eq_ok(uint8_t link_status[DP_LINK_STATUS_SIZE], int lane_count)
781{
782 uint8_t lane_align;
783 uint8_t lane_status;
784 int lane;
785
786 lane_align = intel_dp_link_status(link_status,
787 DP_LANE_ALIGN_STATUS_UPDATED);
788 if ((lane_align & DP_INTERLANE_ALIGN_DONE) == 0)
789 return false;
790 for (lane = 0; lane < lane_count; lane++) {
791 lane_status = intel_get_lane_status(link_status, lane);
792 if ((lane_status & CHANNEL_EQ_BITS) != CHANNEL_EQ_BITS)
793 return false;
794 }
795 return true;
796}
797
798static bool
799intel_dp_set_link_train(struct intel_output *intel_output,
800 uint32_t dp_reg_value,
801 uint8_t dp_train_pat,
802 uint8_t train_set[4],
803 bool first)
804{
805 struct drm_device *dev = intel_output->base.dev;
806 struct drm_i915_private *dev_priv = dev->dev_private;
807 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
808 int ret;
809
810 I915_WRITE(dp_priv->output_reg, dp_reg_value);
811 POSTING_READ(dp_priv->output_reg);
812 if (first)
813 intel_wait_for_vblank(dev);
814
815 intel_dp_aux_native_write_1(intel_output,
816 DP_TRAINING_PATTERN_SET,
817 dp_train_pat);
818
819 ret = intel_dp_aux_native_write(intel_output,
820 DP_TRAINING_LANE0_SET, train_set, 4);
821 if (ret != 4)
822 return false;
823
824 return true;
825}
826
827static void
828intel_dp_link_train(struct intel_output *intel_output, uint32_t DP,
829 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE])
830{
831 struct drm_device *dev = intel_output->base.dev;
832 struct drm_i915_private *dev_priv = dev->dev_private;
833 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
834 uint8_t train_set[4];
835 uint8_t link_status[DP_LINK_STATUS_SIZE];
836 int i;
837 uint8_t voltage;
838 bool clock_recovery = false;
839 bool channel_eq = false;
840 bool first = true;
841 int tries;
842
843 /* Write the link configuration data */
844 intel_dp_aux_native_write(intel_output, 0x100,
845 link_configuration, DP_LINK_CONFIGURATION_SIZE);
846
847 DP |= DP_PORT_EN;
848 DP &= ~DP_LINK_TRAIN_MASK;
849 memset(train_set, 0, 4);
850 voltage = 0xff;
851 tries = 0;
852 clock_recovery = false;
853 for (;;) {
854 /* Use train_set[0] to set the voltage and pre emphasis values */
855 uint32_t signal_levels = intel_dp_signal_levels(train_set[0], dp_priv->lane_count);
856 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels;
857
858 if (!intel_dp_set_link_train(intel_output, DP | DP_LINK_TRAIN_PAT_1,
859 DP_TRAINING_PATTERN_1, train_set, first))
860 break;
861 first = false;
862 /* Set training pattern 1 */
863
864 udelay(100);
865 if (!intel_dp_get_link_status(intel_output, link_status))
866 break;
867
868 if (intel_clock_recovery_ok(link_status, dp_priv->lane_count)) {
869 clock_recovery = true;
870 break;
871 }
872
873 /* Check to see if we've tried the max voltage */
874 for (i = 0; i < dp_priv->lane_count; i++)
875 if ((train_set[i] & DP_TRAIN_MAX_SWING_REACHED) == 0)
876 break;
877 if (i == dp_priv->lane_count)
878 break;
879
880 /* Check to see if we've tried the same voltage 5 times */
881 if ((train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK) == voltage) {
882 ++tries;
883 if (tries == 5)
884 break;
885 } else
886 tries = 0;
887 voltage = train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
888
889 /* Compute new train_set as requested by target */
890 intel_get_adjust_train(intel_output, link_status, dp_priv->lane_count, train_set);
891 }
892
893 /* channel equalization */
894 tries = 0;
895 channel_eq = false;
896 for (;;) {
897 /* Use train_set[0] to set the voltage and pre emphasis values */
898 uint32_t signal_levels = intel_dp_signal_levels(train_set[0], dp_priv->lane_count);
899 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels;
900
901 /* channel eq pattern */
902 if (!intel_dp_set_link_train(intel_output, DP | DP_LINK_TRAIN_PAT_2,
903 DP_TRAINING_PATTERN_2, train_set,
904 false))
905 break;
906
907 udelay(400);
908 if (!intel_dp_get_link_status(intel_output, link_status))
909 break;
910
911 if (intel_channel_eq_ok(link_status, dp_priv->lane_count)) {
912 channel_eq = true;
913 break;
914 }
915
916 /* Try 5 times */
917 if (tries > 5)
918 break;
919
920 /* Compute new train_set as requested by target */
921 intel_get_adjust_train(intel_output, link_status, dp_priv->lane_count, train_set);
922 ++tries;
923 }
924
925 I915_WRITE(dp_priv->output_reg, DP | DP_LINK_TRAIN_OFF);
926 POSTING_READ(dp_priv->output_reg);
927 intel_dp_aux_native_write_1(intel_output,
928 DP_TRAINING_PATTERN_SET, DP_TRAINING_PATTERN_DISABLE);
929}
930
931static void
932intel_dp_link_down(struct intel_output *intel_output, uint32_t DP)
933{
934 struct drm_device *dev = intel_output->base.dev;
935 struct drm_i915_private *dev_priv = dev->dev_private;
936 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
937
938 I915_WRITE(dp_priv->output_reg, DP & ~DP_PORT_EN);
939 POSTING_READ(dp_priv->output_reg);
940}
941
942static void
943intel_dp_restore(struct drm_connector *connector)
944{
945 struct intel_output *intel_output = to_intel_output(connector);
946 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
947
948 if (dp_priv->save_DP & DP_PORT_EN)
949 intel_dp_link_train(intel_output, dp_priv->save_DP, dp_priv->save_link_configuration);
950 else
951 intel_dp_link_down(intel_output, dp_priv->save_DP);
952}
953
954/*
955 * According to DP spec
956 * 5.1.2:
957 * 1. Read DPCD
958 * 2. Configure link according to Receiver Capabilities
959 * 3. Use Link Training from 2.5.3.3 and 3.5.1.3
960 * 4. Check link status on receipt of hot-plug interrupt
961 */
962
963static void
964intel_dp_check_link_status(struct intel_output *intel_output)
965{
966 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
967 uint8_t link_status[DP_LINK_STATUS_SIZE];
968
969 if (!intel_output->enc.crtc)
970 return;
971
972 if (!intel_dp_get_link_status(intel_output, link_status)) {
973 intel_dp_link_down(intel_output, dp_priv->DP);
974 return;
975 }
976
977 if (!intel_channel_eq_ok(link_status, dp_priv->lane_count))
978 intel_dp_link_train(intel_output, dp_priv->DP, dp_priv->link_configuration);
979}
980
981/**
982 * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect DP connection.
983 *
984 * \return true if DP port is connected.
985 * \return false if DP port is disconnected.
986 */
987static enum drm_connector_status
988intel_dp_detect(struct drm_connector *connector)
989{
990 struct intel_output *intel_output = to_intel_output(connector);
991 struct drm_device *dev = intel_output->base.dev;
992 struct drm_i915_private *dev_priv = dev->dev_private;
993 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
994 uint32_t temp, bit;
995 enum drm_connector_status status;
996
997 dp_priv->has_audio = false;
998
999 temp = I915_READ(PORT_HOTPLUG_EN);
1000
1001 I915_WRITE(PORT_HOTPLUG_EN,
1002 temp |
1003 DPB_HOTPLUG_INT_EN |
1004 DPC_HOTPLUG_INT_EN |
1005 DPD_HOTPLUG_INT_EN);
1006
1007 POSTING_READ(PORT_HOTPLUG_EN);
1008
1009 switch (dp_priv->output_reg) {
1010 case DP_B:
1011 bit = DPB_HOTPLUG_INT_STATUS;
1012 break;
1013 case DP_C:
1014 bit = DPC_HOTPLUG_INT_STATUS;
1015 break;
1016 case DP_D:
1017 bit = DPD_HOTPLUG_INT_STATUS;
1018 break;
1019 default:
1020 return connector_status_unknown;
1021 }
1022
1023 temp = I915_READ(PORT_HOTPLUG_STAT);
1024
1025 if ((temp & bit) == 0)
1026 return connector_status_disconnected;
1027
1028 status = connector_status_disconnected;
1029 if (intel_dp_aux_native_read(intel_output,
1030 0x000, dp_priv->dpcd,
1031 sizeof (dp_priv->dpcd)) == sizeof (dp_priv->dpcd))
1032 {
1033 if (dp_priv->dpcd[0] != 0)
1034 status = connector_status_connected;
1035 }
1036 return status;
1037}
1038
1039static int intel_dp_get_modes(struct drm_connector *connector)
1040{
1041 struct intel_output *intel_output = to_intel_output(connector);
1042
1043 /* We should parse the EDID data and find out if it has an audio sink
1044 */
1045
1046 return intel_ddc_get_modes(intel_output);
1047}
1048
1049static void
1050intel_dp_destroy (struct drm_connector *connector)
1051{
1052 struct intel_output *intel_output = to_intel_output(connector);
1053
1054 if (intel_output->i2c_bus)
1055 intel_i2c_destroy(intel_output->i2c_bus);
1056 drm_sysfs_connector_remove(connector);
1057 drm_connector_cleanup(connector);
1058 kfree(intel_output);
1059}
1060
1061static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = {
1062 .dpms = intel_dp_dpms,
1063 .mode_fixup = intel_dp_mode_fixup,
1064 .prepare = intel_encoder_prepare,
1065 .mode_set = intel_dp_mode_set,
1066 .commit = intel_encoder_commit,
1067};
1068
1069static const struct drm_connector_funcs intel_dp_connector_funcs = {
1070 .dpms = drm_helper_connector_dpms,
1071 .save = intel_dp_save,
1072 .restore = intel_dp_restore,
1073 .detect = intel_dp_detect,
1074 .fill_modes = drm_helper_probe_single_connector_modes,
1075 .destroy = intel_dp_destroy,
1076};
1077
1078static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = {
1079 .get_modes = intel_dp_get_modes,
1080 .mode_valid = intel_dp_mode_valid,
1081 .best_encoder = intel_best_encoder,
1082};
1083
1084static void intel_dp_enc_destroy(struct drm_encoder *encoder)
1085{
1086 drm_encoder_cleanup(encoder);
1087}
1088
1089static const struct drm_encoder_funcs intel_dp_enc_funcs = {
1090 .destroy = intel_dp_enc_destroy,
1091};
1092
1093void
1094intel_dp_hot_plug(struct intel_output *intel_output)
1095{
1096 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
1097
1098 if (dp_priv->dpms_mode == DRM_MODE_DPMS_ON)
1099 intel_dp_check_link_status(intel_output);
1100}
1101
1102void
1103intel_dp_init(struct drm_device *dev, int output_reg)
1104{
1105 struct drm_i915_private *dev_priv = dev->dev_private;
1106 struct drm_connector *connector;
1107 struct intel_output *intel_output;
1108 struct intel_dp_priv *dp_priv;
1109
1110 intel_output = kcalloc(sizeof(struct intel_output) +
1111 sizeof(struct intel_dp_priv), 1, GFP_KERNEL);
1112 if (!intel_output)
1113 return;
1114
1115 dp_priv = (struct intel_dp_priv *)(intel_output + 1);
1116
1117 connector = &intel_output->base;
1118 drm_connector_init(dev, connector, &intel_dp_connector_funcs,
1119 DRM_MODE_CONNECTOR_DisplayPort);
1120 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
1121
1122 intel_output->type = INTEL_OUTPUT_DISPLAYPORT;
1123
1124 connector->interlace_allowed = true;
1125 connector->doublescan_allowed = 0;
1126
1127 dp_priv->intel_output = intel_output;
1128 dp_priv->output_reg = output_reg;
1129 dp_priv->has_audio = false;
1130 dp_priv->dpms_mode = DRM_MODE_DPMS_ON;
1131 intel_output->dev_priv = dp_priv;
1132
1133 drm_encoder_init(dev, &intel_output->enc, &intel_dp_enc_funcs,
1134 DRM_MODE_ENCODER_TMDS);
1135 drm_encoder_helper_add(&intel_output->enc, &intel_dp_helper_funcs);
1136
1137 drm_mode_connector_attach_encoder(&intel_output->base,
1138 &intel_output->enc);
1139 drm_sysfs_connector_add(connector);
1140
1141 /* Set up the DDC bus. */
1142 intel_dp_i2c_init(intel_output,
1143 (output_reg == DP_B) ? "DPDDC-B" :
1144 (output_reg == DP_C) ? "DPDDC-C" : "DPDDC-D");
1145 intel_output->ddc_bus = &dp_priv->adapter;
1146 intel_output->hot_plug = intel_dp_hot_plug;
1147
1148 /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written
1149 * 0xd. Failure to do so will result in spurious interrupts being
1150 * generated on the port when a cable is not attached.
1151 */
1152 if (IS_G4X(dev) && !IS_GM45(dev)) {
1153 u32 temp = I915_READ(PEG_BAND_GAP_DATA);
1154 I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd);
1155 }
1156}
diff --git a/drivers/gpu/drm/i915/intel_dp.h b/drivers/gpu/drm/i915/intel_dp.h
new file mode 100644
index 000000000000..2b38054d3b6d
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel_dp.h
@@ -0,0 +1,144 @@
1/*
2 * Copyright © 2008 Keith Packard
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#ifndef _INTEL_DP_H_
24#define _INTEL_DP_H_
25
26/* From the VESA DisplayPort spec */
27
28#define AUX_NATIVE_WRITE 0x8
29#define AUX_NATIVE_READ 0x9
30#define AUX_I2C_WRITE 0x0
31#define AUX_I2C_READ 0x1
32#define AUX_I2C_STATUS 0x2
33#define AUX_I2C_MOT 0x4
34
35#define AUX_NATIVE_REPLY_ACK (0x0 << 4)
36#define AUX_NATIVE_REPLY_NACK (0x1 << 4)
37#define AUX_NATIVE_REPLY_DEFER (0x2 << 4)
38#define AUX_NATIVE_REPLY_MASK (0x3 << 4)
39
40#define AUX_I2C_REPLY_ACK (0x0 << 6)
41#define AUX_I2C_REPLY_NACK (0x1 << 6)
42#define AUX_I2C_REPLY_DEFER (0x2 << 6)
43#define AUX_I2C_REPLY_MASK (0x3 << 6)
44
45/* AUX CH addresses */
46#define DP_LINK_BW_SET 0x100
47# define DP_LINK_BW_1_62 0x06
48# define DP_LINK_BW_2_7 0x0a
49
50#define DP_LANE_COUNT_SET 0x101
51# define DP_LANE_COUNT_MASK 0x0f
52# define DP_LANE_COUNT_ENHANCED_FRAME_EN (1 << 7)
53
54#define DP_TRAINING_PATTERN_SET 0x102
55
56# define DP_TRAINING_PATTERN_DISABLE 0
57# define DP_TRAINING_PATTERN_1 1
58# define DP_TRAINING_PATTERN_2 2
59# define DP_TRAINING_PATTERN_MASK 0x3
60
61# define DP_LINK_QUAL_PATTERN_DISABLE (0 << 2)
62# define DP_LINK_QUAL_PATTERN_D10_2 (1 << 2)
63# define DP_LINK_QUAL_PATTERN_ERROR_RATE (2 << 2)
64# define DP_LINK_QUAL_PATTERN_PRBS7 (3 << 2)
65# define DP_LINK_QUAL_PATTERN_MASK (3 << 2)
66
67# define DP_RECOVERED_CLOCK_OUT_EN (1 << 4)
68# define DP_LINK_SCRAMBLING_DISABLE (1 << 5)
69
70# define DP_SYMBOL_ERROR_COUNT_BOTH (0 << 6)
71# define DP_SYMBOL_ERROR_COUNT_DISPARITY (1 << 6)
72# define DP_SYMBOL_ERROR_COUNT_SYMBOL (2 << 6)
73# define DP_SYMBOL_ERROR_COUNT_MASK (3 << 6)
74
75#define DP_TRAINING_LANE0_SET 0x103
76#define DP_TRAINING_LANE1_SET 0x104
77#define DP_TRAINING_LANE2_SET 0x105
78#define DP_TRAINING_LANE3_SET 0x106
79
80# define DP_TRAIN_VOLTAGE_SWING_MASK 0x3
81# define DP_TRAIN_VOLTAGE_SWING_SHIFT 0
82# define DP_TRAIN_MAX_SWING_REACHED (1 << 2)
83# define DP_TRAIN_VOLTAGE_SWING_400 (0 << 0)
84# define DP_TRAIN_VOLTAGE_SWING_600 (1 << 0)
85# define DP_TRAIN_VOLTAGE_SWING_800 (2 << 0)
86# define DP_TRAIN_VOLTAGE_SWING_1200 (3 << 0)
87
88# define DP_TRAIN_PRE_EMPHASIS_MASK (3 << 3)
89# define DP_TRAIN_PRE_EMPHASIS_0 (0 << 3)
90# define DP_TRAIN_PRE_EMPHASIS_3_5 (1 << 3)
91# define DP_TRAIN_PRE_EMPHASIS_6 (2 << 3)
92# define DP_TRAIN_PRE_EMPHASIS_9_5 (3 << 3)
93
94# define DP_TRAIN_PRE_EMPHASIS_SHIFT 3
95# define DP_TRAIN_MAX_PRE_EMPHASIS_REACHED (1 << 5)
96
97#define DP_DOWNSPREAD_CTRL 0x107
98# define DP_SPREAD_AMP_0_5 (1 << 4)
99
100#define DP_MAIN_LINK_CHANNEL_CODING_SET 0x108
101# define DP_SET_ANSI_8B10B (1 << 0)
102
103#define DP_LANE0_1_STATUS 0x202
104#define DP_LANE2_3_STATUS 0x203
105
106# define DP_LANE_CR_DONE (1 << 0)
107# define DP_LANE_CHANNEL_EQ_DONE (1 << 1)
108# define DP_LANE_SYMBOL_LOCKED (1 << 2)
109
110#define DP_LANE_ALIGN_STATUS_UPDATED 0x204
111
112#define DP_INTERLANE_ALIGN_DONE (1 << 0)
113#define DP_DOWNSTREAM_PORT_STATUS_CHANGED (1 << 6)
114#define DP_LINK_STATUS_UPDATED (1 << 7)
115
116#define DP_SINK_STATUS 0x205
117
118#define DP_RECEIVE_PORT_0_STATUS (1 << 0)
119#define DP_RECEIVE_PORT_1_STATUS (1 << 1)
120
121#define DP_ADJUST_REQUEST_LANE0_1 0x206
122#define DP_ADJUST_REQUEST_LANE2_3 0x207
123
124#define DP_ADJUST_VOLTAGE_SWING_LANE0_MASK 0x03
125#define DP_ADJUST_VOLTAGE_SWING_LANE0_SHIFT 0
126#define DP_ADJUST_PRE_EMPHASIS_LANE0_MASK 0x0c
127#define DP_ADJUST_PRE_EMPHASIS_LANE0_SHIFT 2
128#define DP_ADJUST_VOLTAGE_SWING_LANE1_MASK 0x30
129#define DP_ADJUST_VOLTAGE_SWING_LANE1_SHIFT 4
130#define DP_ADJUST_PRE_EMPHASIS_LANE1_MASK 0xc0
131#define DP_ADJUST_PRE_EMPHASIS_LANE1_SHIFT 6
132
133struct i2c_algo_dp_aux_data {
134 bool running;
135 u16 address;
136 int (*aux_ch) (struct i2c_adapter *adapter,
137 uint8_t *send, int send_bytes,
138 uint8_t *recv, int recv_bytes);
139};
140
141int
142i2c_dp_aux_add_bus(struct i2c_adapter *adapter);
143
144#endif /* _INTEL_DP_H_ */
diff --git a/drivers/gpu/drm/i915/intel_dp_i2c.c b/drivers/gpu/drm/i915/intel_dp_i2c.c
new file mode 100644
index 000000000000..a63b6f57d2d4
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel_dp_i2c.c
@@ -0,0 +1,273 @@
1/*
2 * Copyright © 2009 Keith Packard
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/delay.h>
26#include <linux/slab.h>
27#include <linux/init.h>
28#include <linux/errno.h>
29#include <linux/sched.h>
30#include <linux/i2c.h>
31#include "intel_dp.h"
32#include "drmP.h"
33
34/* Run a single AUX_CH I2C transaction, writing/reading data as necessary */
35
36#define MODE_I2C_START 1
37#define MODE_I2C_WRITE 2
38#define MODE_I2C_READ 4
39#define MODE_I2C_STOP 8
40
41static int
42i2c_algo_dp_aux_transaction(struct i2c_adapter *adapter, int mode,
43 uint8_t write_byte, uint8_t *read_byte)
44{
45 struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data;
46 uint16_t address = algo_data->address;
47 uint8_t msg[5];
48 uint8_t reply[2];
49 int msg_bytes;
50 int reply_bytes;
51 int ret;
52
53 /* Set up the command byte */
54 if (mode & MODE_I2C_READ)
55 msg[0] = AUX_I2C_READ << 4;
56 else
57 msg[0] = AUX_I2C_WRITE << 4;
58
59 if (!(mode & MODE_I2C_STOP))
60 msg[0] |= AUX_I2C_MOT << 4;
61
62 msg[1] = address >> 8;
63 msg[2] = address;
64
65 switch (mode) {
66 case MODE_I2C_WRITE:
67 msg[3] = 0;
68 msg[4] = write_byte;
69 msg_bytes = 5;
70 reply_bytes = 1;
71 break;
72 case MODE_I2C_READ:
73 msg[3] = 0;
74 msg_bytes = 4;
75 reply_bytes = 2;
76 break;
77 default:
78 msg_bytes = 3;
79 reply_bytes = 1;
80 break;
81 }
82
83 for (;;) {
84 ret = (*algo_data->aux_ch)(adapter,
85 msg, msg_bytes,
86 reply, reply_bytes);
87 if (ret < 0) {
88 DRM_DEBUG("aux_ch failed %d\n", ret);
89 return ret;
90 }
91 switch (reply[0] & AUX_I2C_REPLY_MASK) {
92 case AUX_I2C_REPLY_ACK:
93 if (mode == MODE_I2C_READ) {
94 *read_byte = reply[1];
95 }
96 return reply_bytes - 1;
97 case AUX_I2C_REPLY_NACK:
98 DRM_DEBUG("aux_ch nack\n");
99 return -EREMOTEIO;
100 case AUX_I2C_REPLY_DEFER:
101 DRM_DEBUG("aux_ch defer\n");
102 udelay(100);
103 break;
104 default:
105 DRM_ERROR("aux_ch invalid reply 0x%02x\n", reply[0]);
106 return -EREMOTEIO;
107 }
108 }
109}
110
111/*
112 * I2C over AUX CH
113 */
114
115/*
116 * Send the address. If the I2C link is running, this 'restarts'
117 * the connection with the new address, this is used for doing
118 * a write followed by a read (as needed for DDC)
119 */
120static int
121i2c_algo_dp_aux_address(struct i2c_adapter *adapter, u16 address, bool reading)
122{
123 struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data;
124 int mode = MODE_I2C_START;
125 int ret;
126
127 if (reading)
128 mode |= MODE_I2C_READ;
129 else
130 mode |= MODE_I2C_WRITE;
131 algo_data->address = address;
132 algo_data->running = true;
133 ret = i2c_algo_dp_aux_transaction(adapter, mode, 0, NULL);
134 return ret;
135}
136
137/*
138 * Stop the I2C transaction. This closes out the link, sending
139 * a bare address packet with the MOT bit turned off
140 */
141static void
142i2c_algo_dp_aux_stop(struct i2c_adapter *adapter, bool reading)
143{
144 struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data;
145 int mode = MODE_I2C_STOP;
146
147 if (reading)
148 mode |= MODE_I2C_READ;
149 else
150 mode |= MODE_I2C_WRITE;
151 if (algo_data->running) {
152 (void) i2c_algo_dp_aux_transaction(adapter, mode, 0, NULL);
153 algo_data->running = false;
154 }
155}
156
157/*
158 * Write a single byte to the current I2C address, the
159 * the I2C link must be running or this returns -EIO
160 */
161static int
162i2c_algo_dp_aux_put_byte(struct i2c_adapter *adapter, u8 byte)
163{
164 struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data;
165 int ret;
166
167 if (!algo_data->running)
168 return -EIO;
169
170 ret = i2c_algo_dp_aux_transaction(adapter, MODE_I2C_WRITE, byte, NULL);
171 return ret;
172}
173
174/*
175 * Read a single byte from the current I2C address, the
176 * I2C link must be running or this returns -EIO
177 */
178static int
179i2c_algo_dp_aux_get_byte(struct i2c_adapter *adapter, u8 *byte_ret)
180{
181 struct i2c_algo_dp_aux_data *algo_data = adapter->algo_data;
182 int ret;
183
184 if (!algo_data->running)
185 return -EIO;
186
187 ret = i2c_algo_dp_aux_transaction(adapter, MODE_I2C_READ, 0, byte_ret);
188 return ret;
189}
190
191static int
192i2c_algo_dp_aux_xfer(struct i2c_adapter *adapter,
193 struct i2c_msg *msgs,
194 int num)
195{
196 int ret = 0;
197 bool reading = false;
198 int m;
199 int b;
200
201 for (m = 0; m < num; m++) {
202 u16 len = msgs[m].len;
203 u8 *buf = msgs[m].buf;
204 reading = (msgs[m].flags & I2C_M_RD) != 0;
205 ret = i2c_algo_dp_aux_address(adapter, msgs[m].addr, reading);
206 if (ret < 0)
207 break;
208 if (reading) {
209 for (b = 0; b < len; b++) {
210 ret = i2c_algo_dp_aux_get_byte(adapter, &buf[b]);
211 if (ret < 0)
212 break;
213 }
214 } else {
215 for (b = 0; b < len; b++) {
216 ret = i2c_algo_dp_aux_put_byte(adapter, buf[b]);
217 if (ret < 0)
218 break;
219 }
220 }
221 if (ret < 0)
222 break;
223 }
224 if (ret >= 0)
225 ret = num;
226 i2c_algo_dp_aux_stop(adapter, reading);
227 DRM_DEBUG("dp_aux_xfer return %d\n", ret);
228 return ret;
229}
230
231static u32
232i2c_algo_dp_aux_functionality(struct i2c_adapter *adapter)
233{
234 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
235 I2C_FUNC_SMBUS_READ_BLOCK_DATA |
236 I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
237 I2C_FUNC_10BIT_ADDR;
238}
239
240static const struct i2c_algorithm i2c_dp_aux_algo = {
241 .master_xfer = i2c_algo_dp_aux_xfer,
242 .functionality = i2c_algo_dp_aux_functionality,
243};
244
245static void
246i2c_dp_aux_reset_bus(struct i2c_adapter *adapter)
247{
248 (void) i2c_algo_dp_aux_address(adapter, 0, false);
249 (void) i2c_algo_dp_aux_stop(adapter, false);
250
251}
252
253static int
254i2c_dp_aux_prepare_bus(struct i2c_adapter *adapter)
255{
256 adapter->algo = &i2c_dp_aux_algo;
257 adapter->retries = 3;
258 i2c_dp_aux_reset_bus(adapter);
259 return 0;
260}
261
262int
263i2c_dp_aux_add_bus(struct i2c_adapter *adapter)
264{
265 int error;
266
267 error = i2c_dp_aux_prepare_bus(adapter);
268 if (error)
269 return error;
270 error = i2c_add_adapter(adapter);
271 return error;
272}
273EXPORT_SYMBOL(i2c_dp_aux_add_bus);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index cd4b9c5f715e..004541c935a8 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -54,6 +54,7 @@
54#define INTEL_OUTPUT_LVDS 4 54#define INTEL_OUTPUT_LVDS 4
55#define INTEL_OUTPUT_TVOUT 5 55#define INTEL_OUTPUT_TVOUT 5
56#define INTEL_OUTPUT_HDMI 6 56#define INTEL_OUTPUT_HDMI 6
57#define INTEL_OUTPUT_DISPLAYPORT 7
57 58
58#define INTEL_DVO_CHIP_NONE 0 59#define INTEL_DVO_CHIP_NONE 0
59#define INTEL_DVO_CHIP_LVDS 1 60#define INTEL_DVO_CHIP_LVDS 1
@@ -65,7 +66,6 @@ struct intel_i2c_chan {
65 u32 reg; /* GPIO reg */ 66 u32 reg; /* GPIO reg */
66 struct i2c_adapter adapter; 67 struct i2c_adapter adapter;
67 struct i2c_algo_bit_data algo; 68 struct i2c_algo_bit_data algo;
68 u8 slave_addr;
69}; 69};
70 70
71struct intel_framebuffer { 71struct intel_framebuffer {
@@ -79,11 +79,12 @@ struct intel_output {
79 79
80 struct drm_encoder enc; 80 struct drm_encoder enc;
81 int type; 81 int type;
82 struct intel_i2c_chan *i2c_bus; /* for control functions */ 82 struct i2c_adapter *i2c_bus;
83 struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */ 83 struct i2c_adapter *ddc_bus;
84 bool load_detect_temp; 84 bool load_detect_temp;
85 bool needs_tv_clock; 85 bool needs_tv_clock;
86 void *dev_priv; 86 void *dev_priv;
87 void (*hot_plug)(struct intel_output *);
87}; 88};
88 89
89struct intel_crtc { 90struct intel_crtc {
@@ -104,9 +105,9 @@ struct intel_crtc {
104#define enc_to_intel_output(x) container_of(x, struct intel_output, enc) 105#define enc_to_intel_output(x) container_of(x, struct intel_output, enc)
105#define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base) 106#define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
106 107
107struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg, 108struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg,
108 const char *name); 109 const char *name);
109void intel_i2c_destroy(struct intel_i2c_chan *chan); 110void intel_i2c_destroy(struct i2c_adapter *adapter);
110int intel_ddc_get_modes(struct intel_output *intel_output); 111int intel_ddc_get_modes(struct intel_output *intel_output);
111extern bool intel_ddc_probe(struct intel_output *intel_output); 112extern bool intel_ddc_probe(struct intel_output *intel_output);
112void intel_i2c_quirk_set(struct drm_device *dev, bool enable); 113void intel_i2c_quirk_set(struct drm_device *dev, bool enable);
@@ -116,6 +117,10 @@ extern bool intel_sdvo_init(struct drm_device *dev, int output_device);
116extern void intel_dvo_init(struct drm_device *dev); 117extern void intel_dvo_init(struct drm_device *dev);
117extern void intel_tv_init(struct drm_device *dev); 118extern void intel_tv_init(struct drm_device *dev);
118extern void intel_lvds_init(struct drm_device *dev); 119extern void intel_lvds_init(struct drm_device *dev);
120extern void intel_dp_init(struct drm_device *dev, int dp_reg);
121void
122intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
123 struct drm_display_mode *adjusted_mode);
119 124
120extern void intel_crtc_load_lut(struct drm_crtc *crtc); 125extern void intel_crtc_load_lut(struct drm_crtc *crtc);
121extern void intel_encoder_prepare (struct drm_encoder *encoder); 126extern void intel_encoder_prepare (struct drm_encoder *encoder);
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
index 1ee3007d6ec0..13bff20930e8 100644
--- a/drivers/gpu/drm/i915/intel_dvo.c
+++ b/drivers/gpu/drm/i915/intel_dvo.c
@@ -384,10 +384,9 @@ void intel_dvo_init(struct drm_device *dev)
384{ 384{
385 struct intel_output *intel_output; 385 struct intel_output *intel_output;
386 struct intel_dvo_device *dvo; 386 struct intel_dvo_device *dvo;
387 struct intel_i2c_chan *i2cbus = NULL; 387 struct i2c_adapter *i2cbus = NULL;
388 int ret = 0; 388 int ret = 0;
389 int i; 389 int i;
390 int gpio_inited = 0;
391 int encoder_type = DRM_MODE_ENCODER_NONE; 390 int encoder_type = DRM_MODE_ENCODER_NONE;
392 intel_output = kzalloc (sizeof(struct intel_output), GFP_KERNEL); 391 intel_output = kzalloc (sizeof(struct intel_output), GFP_KERNEL);
393 if (!intel_output) 392 if (!intel_output)
@@ -420,14 +419,11 @@ void intel_dvo_init(struct drm_device *dev)
420 * It appears that everything is on GPIOE except for panels 419 * It appears that everything is on GPIOE except for panels
421 * on i830 laptops, which are on GPIOB (DVOA). 420 * on i830 laptops, which are on GPIOB (DVOA).
422 */ 421 */
423 if (gpio_inited != gpio) { 422 if (i2cbus != NULL)
424 if (i2cbus != NULL) 423 intel_i2c_destroy(i2cbus);
425 intel_i2c_destroy(i2cbus); 424 if (!(i2cbus = intel_i2c_create(dev, gpio,
426 if (!(i2cbus = intel_i2c_create(dev, gpio, 425 gpio == GPIOB ? "DVOI2C_B" : "DVOI2C_E"))) {
427 gpio == GPIOB ? "DVOI2C_B" : "DVOI2C_E"))) { 426 continue;
428 continue;
429 }
430 gpio_inited = gpio;
431 } 427 }
432 428
433 if (dvo->dev_ops!= NULL) 429 if (dvo->dev_ops!= NULL)
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index 1af7d68e3807..1d30802e773e 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -453,7 +453,7 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
453 size = ALIGN(size, PAGE_SIZE); 453 size = ALIGN(size, PAGE_SIZE);
454 fbo = drm_gem_object_alloc(dev, size); 454 fbo = drm_gem_object_alloc(dev, size);
455 if (!fbo) { 455 if (!fbo) {
456 printk(KERN_ERR "failed to allocate framebuffer\n"); 456 DRM_ERROR("failed to allocate framebuffer\n");
457 ret = -ENOMEM; 457 ret = -ENOMEM;
458 goto out; 458 goto out;
459 } 459 }
@@ -610,8 +610,8 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
610 par->dev = dev; 610 par->dev = dev;
611 611
612 /* To allow resizeing without swapping buffers */ 612 /* To allow resizeing without swapping buffers */
613 printk("allocated %dx%d fb: 0x%08x, bo %p\n", intel_fb->base.width, 613 DRM_DEBUG("allocated %dx%d fb: 0x%08x, bo %p\n", intel_fb->base.width,
614 intel_fb->base.height, obj_priv->gtt_offset, fbo); 614 intel_fb->base.height, obj_priv->gtt_offset, fbo);
615 615
616 mutex_unlock(&dev->struct_mutex); 616 mutex_unlock(&dev->struct_mutex);
617 return 0; 617 return 0;
@@ -698,13 +698,13 @@ static int intelfb_multi_fb_probe_crtc(struct drm_device *dev, struct drm_crtc *
698 } else 698 } else
699 intelfb_set_par(info); 699 intelfb_set_par(info);
700 700
701 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, 701 DRM_INFO("fb%d: %s frame buffer device\n", info->node,
702 info->fix.id); 702 info->fix.id);
703 703
704 /* Switch back to kernel console on panic */ 704 /* Switch back to kernel console on panic */
705 kernelfb_mode = *modeset; 705 kernelfb_mode = *modeset;
706 atomic_notifier_chain_register(&panic_notifier_list, &paniced); 706 atomic_notifier_chain_register(&panic_notifier_list, &paniced);
707 printk(KERN_INFO "registered panic notifier\n"); 707 DRM_DEBUG("registered panic notifier\n");
708 708
709 return 0; 709 return 0;
710} 710}
@@ -852,13 +852,13 @@ static int intelfb_single_fb_probe(struct drm_device *dev)
852 } else 852 } else
853 intelfb_set_par(info); 853 intelfb_set_par(info);
854 854
855 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, 855 DRM_INFO("fb%d: %s frame buffer device\n", info->node,
856 info->fix.id); 856 info->fix.id);
857 857
858 /* Switch back to kernel console on panic */ 858 /* Switch back to kernel console on panic */
859 kernelfb_mode = *modeset; 859 kernelfb_mode = *modeset;
860 atomic_notifier_chain_register(&panic_notifier_list, &paniced); 860 atomic_notifier_chain_register(&panic_notifier_list, &paniced);
861 printk(KERN_INFO "registered panic notifier\n"); 861 DRM_DEBUG("registered panic notifier\n");
862 862
863 return 0; 863 return 0;
864} 864}
@@ -872,8 +872,8 @@ void intelfb_restore(void)
872{ 872{
873 int ret; 873 int ret;
874 if ((ret = drm_crtc_helper_set_config(&kernelfb_mode)) != 0) { 874 if ((ret = drm_crtc_helper_set_config(&kernelfb_mode)) != 0) {
875 printk(KERN_ERR "Failed to restore crtc configuration: %d\n", 875 DRM_ERROR("Failed to restore crtc configuration: %d\n",
876 ret); 876 ret);
877 } 877 }
878} 878}
879 879
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 4ea2a651b92c..9e30daae37dc 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -31,6 +31,7 @@
31#include "drmP.h" 31#include "drmP.h"
32#include "drm.h" 32#include "drm.h"
33#include "drm_crtc.h" 33#include "drm_crtc.h"
34#include "drm_edid.h"
34#include "intel_drv.h" 35#include "intel_drv.h"
35#include "i915_drm.h" 36#include "i915_drm.h"
36#include "i915_drv.h" 37#include "i915_drv.h"
@@ -56,8 +57,7 @@ static void intel_hdmi_mode_set(struct drm_encoder *encoder,
56 sdvox = SDVO_ENCODING_HDMI | 57 sdvox = SDVO_ENCODING_HDMI |
57 SDVO_BORDER_ENABLE | 58 SDVO_BORDER_ENABLE |
58 SDVO_VSYNC_ACTIVE_HIGH | 59 SDVO_VSYNC_ACTIVE_HIGH |
59 SDVO_HSYNC_ACTIVE_HIGH | 60 SDVO_HSYNC_ACTIVE_HIGH;
60 SDVO_NULL_PACKETS_DURING_VSYNC;
61 61
62 if (hdmi_priv->has_hdmi_sink) 62 if (hdmi_priv->has_hdmi_sink)
63 sdvox |= SDVO_AUDIO_ENABLE; 63 sdvox |= SDVO_AUDIO_ENABLE;
@@ -129,20 +129,26 @@ static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder,
129 return true; 129 return true;
130} 130}
131 131
132static void 132static enum drm_connector_status
133intel_hdmi_sink_detect(struct drm_connector *connector) 133intel_hdmi_edid_detect(struct drm_connector *connector)
134{ 134{
135 struct intel_output *intel_output = to_intel_output(connector); 135 struct intel_output *intel_output = to_intel_output(connector);
136 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv; 136 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv;
137 struct edid *edid = NULL; 137 struct edid *edid = NULL;
138 enum drm_connector_status status = connector_status_disconnected;
138 139
139 edid = drm_get_edid(&intel_output->base, 140 edid = drm_get_edid(&intel_output->base,
140 &intel_output->ddc_bus->adapter); 141 intel_output->ddc_bus);
141 if (edid != NULL) { 142 hdmi_priv->has_hdmi_sink = false;
142 hdmi_priv->has_hdmi_sink = drm_detect_hdmi_monitor(edid); 143 if (edid) {
143 kfree(edid); 144 if (edid->input & DRM_EDID_INPUT_DIGITAL) {
145 status = connector_status_connected;
146 hdmi_priv->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
147 }
144 intel_output->base.display_info.raw_edid = NULL; 148 intel_output->base.display_info.raw_edid = NULL;
149 kfree(edid);
145 } 150 }
151 return status;
146} 152}
147 153
148static enum drm_connector_status 154static enum drm_connector_status
@@ -154,11 +160,7 @@ igdng_hdmi_detect(struct drm_connector *connector)
154 /* FIXME hotplug detect */ 160 /* FIXME hotplug detect */
155 161
156 hdmi_priv->has_hdmi_sink = false; 162 hdmi_priv->has_hdmi_sink = false;
157 intel_hdmi_sink_detect(connector); 163 return intel_hdmi_edid_detect(connector);
158 if (hdmi_priv->has_hdmi_sink)
159 return connector_status_connected;
160 else
161 return connector_status_disconnected;
162} 164}
163 165
164static enum drm_connector_status 166static enum drm_connector_status
@@ -201,10 +203,9 @@ intel_hdmi_detect(struct drm_connector *connector)
201 return connector_status_unknown; 203 return connector_status_unknown;
202 } 204 }
203 205
204 if ((I915_READ(PORT_HOTPLUG_STAT) & bit) != 0) { 206 if ((I915_READ(PORT_HOTPLUG_STAT) & bit) != 0)
205 intel_hdmi_sink_detect(connector); 207 return intel_hdmi_edid_detect(connector);
206 return connector_status_connected; 208 else
207 } else
208 return connector_status_disconnected; 209 return connector_status_disconnected;
209} 210}
210 211
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index f7061f68d050..62b8bead7652 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -124,6 +124,7 @@ static void set_data(void *data, int state_high)
124 * @output: driver specific output device 124 * @output: driver specific output device
125 * @reg: GPIO reg to use 125 * @reg: GPIO reg to use
126 * @name: name for this bus 126 * @name: name for this bus
127 * @slave_addr: slave address (if fixed)
127 * 128 *
128 * Creates and registers a new i2c bus with the Linux i2c layer, for use 129 * Creates and registers a new i2c bus with the Linux i2c layer, for use
129 * in output probing and control (e.g. DDC or SDVO control functions). 130 * in output probing and control (e.g. DDC or SDVO control functions).
@@ -139,8 +140,8 @@ static void set_data(void *data, int state_high)
139 * %GPIOH 140 * %GPIOH
140 * see PRM for details on how these different busses are used. 141 * see PRM for details on how these different busses are used.
141 */ 142 */
142struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg, 143struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg,
143 const char *name) 144 const char *name)
144{ 145{
145 struct intel_i2c_chan *chan; 146 struct intel_i2c_chan *chan;
146 147
@@ -174,7 +175,7 @@ struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg,
174 intel_i2c_quirk_set(dev, false); 175 intel_i2c_quirk_set(dev, false);
175 udelay(20); 176 udelay(20);
176 177
177 return chan; 178 return &chan->adapter;
178 179
179out_free: 180out_free:
180 kfree(chan); 181 kfree(chan);
@@ -187,11 +188,16 @@ out_free:
187 * 188 *
188 * Unregister the adapter from the i2c layer, then free the structure. 189 * Unregister the adapter from the i2c layer, then free the structure.
189 */ 190 */
190void intel_i2c_destroy(struct intel_i2c_chan *chan) 191void intel_i2c_destroy(struct i2c_adapter *adapter)
191{ 192{
192 if (!chan) 193 struct intel_i2c_chan *chan;
194
195 if (!adapter)
193 return; 196 return;
194 197
198 chan = container_of(adapter,
199 struct intel_i2c_chan,
200 adapter);
195 i2c_del_adapter(&chan->adapter); 201 i2c_del_adapter(&chan->adapter);
196 kfree(chan); 202 kfree(chan);
197} 203}
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index f073ed8432e8..9ab38efffecf 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -36,9 +36,25 @@
36#include "intel_drv.h" 36#include "intel_drv.h"
37#include "i915_drm.h" 37#include "i915_drm.h"
38#include "i915_drv.h" 38#include "i915_drv.h"
39#include <linux/acpi.h>
39 40
40#define I915_LVDS "i915_lvds" 41#define I915_LVDS "i915_lvds"
41 42
43/*
44 * the following four scaling options are defined.
45 * #define DRM_MODE_SCALE_NON_GPU 0
46 * #define DRM_MODE_SCALE_FULLSCREEN 1
47 * #define DRM_MODE_SCALE_NO_SCALE 2
48 * #define DRM_MODE_SCALE_ASPECT 3
49 */
50
51/* Private structure for the integrated LVDS support */
52struct intel_lvds_priv {
53 int fitting_mode;
54 u32 pfit_control;
55 u32 pfit_pgm_ratios;
56};
57
42/** 58/**
43 * Sets the backlight level. 59 * Sets the backlight level.
44 * 60 *
@@ -213,26 +229,45 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
213 struct drm_display_mode *mode, 229 struct drm_display_mode *mode,
214 struct drm_display_mode *adjusted_mode) 230 struct drm_display_mode *adjusted_mode)
215{ 231{
232 /*
233 * float point operation is not supported . So the PANEL_RATIO_FACTOR
234 * is defined, which can avoid the float point computation when
235 * calculating the panel ratio.
236 */
237#define PANEL_RATIO_FACTOR 8192
216 struct drm_device *dev = encoder->dev; 238 struct drm_device *dev = encoder->dev;
217 struct drm_i915_private *dev_priv = dev->dev_private; 239 struct drm_i915_private *dev_priv = dev->dev_private;
218 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); 240 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
219 struct drm_encoder *tmp_encoder; 241 struct drm_encoder *tmp_encoder;
242 struct intel_output *intel_output = enc_to_intel_output(encoder);
243 struct intel_lvds_priv *lvds_priv = intel_output->dev_priv;
244 u32 pfit_control = 0, pfit_pgm_ratios = 0;
245 int left_border = 0, right_border = 0, top_border = 0;
246 int bottom_border = 0;
247 bool border = 0;
248 int panel_ratio, desired_ratio, vert_scale, horiz_scale;
249 int horiz_ratio, vert_ratio;
250 u32 hsync_width, vsync_width;
251 u32 hblank_width, vblank_width;
252 u32 hsync_pos, vsync_pos;
220 253
221 /* Should never happen!! */ 254 /* Should never happen!! */
222 if (!IS_I965G(dev) && intel_crtc->pipe == 0) { 255 if (!IS_I965G(dev) && intel_crtc->pipe == 0) {
223 printk(KERN_ERR "Can't support LVDS on pipe A\n"); 256 DRM_ERROR("Can't support LVDS on pipe A\n");
224 return false; 257 return false;
225 } 258 }
226 259
227 /* Should never happen!! */ 260 /* Should never happen!! */
228 list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list, head) { 261 list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list, head) {
229 if (tmp_encoder != encoder && tmp_encoder->crtc == encoder->crtc) { 262 if (tmp_encoder != encoder && tmp_encoder->crtc == encoder->crtc) {
230 printk(KERN_ERR "Can't enable LVDS and another " 263 DRM_ERROR("Can't enable LVDS and another "
231 "encoder on the same pipe\n"); 264 "encoder on the same pipe\n");
232 return false; 265 return false;
233 } 266 }
234 } 267 }
235 268 /* If we don't have a panel mode, there is nothing we can do */
269 if (dev_priv->panel_fixed_mode == NULL)
270 return true;
236 /* 271 /*
237 * If we have timings from the BIOS for the panel, put them in 272 * If we have timings from the BIOS for the panel, put them in
238 * to the adjusted mode. The CRTC will be set up for this mode, 273 * to the adjusted mode. The CRTC will be set up for this mode,
@@ -256,6 +291,243 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
256 drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V); 291 drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
257 } 292 }
258 293
294 /* Make sure pre-965s set dither correctly */
295 if (!IS_I965G(dev)) {
296 if (dev_priv->panel_wants_dither || dev_priv->lvds_dither)
297 pfit_control |= PANEL_8TO6_DITHER_ENABLE;
298 }
299
300 /* Native modes don't need fitting */
301 if (adjusted_mode->hdisplay == mode->hdisplay &&
302 adjusted_mode->vdisplay == mode->vdisplay) {
303 pfit_pgm_ratios = 0;
304 border = 0;
305 goto out;
306 }
307
308 /* 965+ wants fuzzy fitting */
309 if (IS_I965G(dev))
310 pfit_control |= (intel_crtc->pipe << PFIT_PIPE_SHIFT) |
311 PFIT_FILTER_FUZZY;
312
313 hsync_width = adjusted_mode->crtc_hsync_end -
314 adjusted_mode->crtc_hsync_start;
315 vsync_width = adjusted_mode->crtc_vsync_end -
316 adjusted_mode->crtc_vsync_start;
317 hblank_width = adjusted_mode->crtc_hblank_end -
318 adjusted_mode->crtc_hblank_start;
319 vblank_width = adjusted_mode->crtc_vblank_end -
320 adjusted_mode->crtc_vblank_start;
321 /*
322 * Deal with panel fitting options. Figure out how to stretch the
323 * image based on its aspect ratio & the current panel fitting mode.
324 */
325 panel_ratio = adjusted_mode->hdisplay * PANEL_RATIO_FACTOR /
326 adjusted_mode->vdisplay;
327 desired_ratio = mode->hdisplay * PANEL_RATIO_FACTOR /
328 mode->vdisplay;
329 /*
330 * Enable automatic panel scaling for non-native modes so that they fill
331 * the screen. Should be enabled before the pipe is enabled, according
332 * to register description and PRM.
333 * Change the value here to see the borders for debugging
334 */
335 I915_WRITE(BCLRPAT_A, 0);
336 I915_WRITE(BCLRPAT_B, 0);
337
338 switch (lvds_priv->fitting_mode) {
339 case DRM_MODE_SCALE_NO_SCALE:
340 /*
341 * For centered modes, we have to calculate border widths &
342 * heights and modify the values programmed into the CRTC.
343 */
344 left_border = (adjusted_mode->hdisplay - mode->hdisplay) / 2;
345 right_border = left_border;
346 if (mode->hdisplay & 1)
347 right_border++;
348 top_border = (adjusted_mode->vdisplay - mode->vdisplay) / 2;
349 bottom_border = top_border;
350 if (mode->vdisplay & 1)
351 bottom_border++;
352 /* Set active & border values */
353 adjusted_mode->crtc_hdisplay = mode->hdisplay;
354 /* Keep the boder be even */
355 if (right_border & 1)
356 right_border++;
357 /* use the border directly instead of border minuse one */
358 adjusted_mode->crtc_hblank_start = mode->hdisplay +
359 right_border;
360 /* keep the blank width constant */
361 adjusted_mode->crtc_hblank_end =
362 adjusted_mode->crtc_hblank_start + hblank_width;
363 /* get the hsync pos relative to hblank start */
364 hsync_pos = (hblank_width - hsync_width) / 2;
365 /* keep the hsync pos be even */
366 if (hsync_pos & 1)
367 hsync_pos++;
368 adjusted_mode->crtc_hsync_start =
369 adjusted_mode->crtc_hblank_start + hsync_pos;
370 /* keep the hsync width constant */
371 adjusted_mode->crtc_hsync_end =
372 adjusted_mode->crtc_hsync_start + hsync_width;
373 adjusted_mode->crtc_vdisplay = mode->vdisplay;
374 /* use the border instead of border minus one */
375 adjusted_mode->crtc_vblank_start = mode->vdisplay +
376 bottom_border;
377 /* keep the vblank width constant */
378 adjusted_mode->crtc_vblank_end =
379 adjusted_mode->crtc_vblank_start + vblank_width;
380 /* get the vsync start postion relative to vblank start */
381 vsync_pos = (vblank_width - vsync_width) / 2;
382 adjusted_mode->crtc_vsync_start =
383 adjusted_mode->crtc_vblank_start + vsync_pos;
384 /* keep the vsync width constant */
385 adjusted_mode->crtc_vsync_end =
386 adjusted_mode->crtc_vblank_start + vsync_width;
387 border = 1;
388 break;
389 case DRM_MODE_SCALE_ASPECT:
390 /* Scale but preserve the spect ratio */
391 pfit_control |= PFIT_ENABLE;
392 if (IS_I965G(dev)) {
393 /* 965+ is easy, it does everything in hw */
394 if (panel_ratio > desired_ratio)
395 pfit_control |= PFIT_SCALING_PILLAR;
396 else if (panel_ratio < desired_ratio)
397 pfit_control |= PFIT_SCALING_LETTER;
398 else
399 pfit_control |= PFIT_SCALING_AUTO;
400 } else {
401 /*
402 * For earlier chips we have to calculate the scaling
403 * ratio by hand and program it into the
404 * PFIT_PGM_RATIO register
405 */
406 u32 horiz_bits, vert_bits, bits = 12;
407 horiz_ratio = mode->hdisplay * PANEL_RATIO_FACTOR/
408 adjusted_mode->hdisplay;
409 vert_ratio = mode->vdisplay * PANEL_RATIO_FACTOR/
410 adjusted_mode->vdisplay;
411 horiz_scale = adjusted_mode->hdisplay *
412 PANEL_RATIO_FACTOR / mode->hdisplay;
413 vert_scale = adjusted_mode->vdisplay *
414 PANEL_RATIO_FACTOR / mode->vdisplay;
415
416 /* retain aspect ratio */
417 if (panel_ratio > desired_ratio) { /* Pillar */
418 u32 scaled_width;
419 scaled_width = mode->hdisplay * vert_scale /
420 PANEL_RATIO_FACTOR;
421 horiz_ratio = vert_ratio;
422 pfit_control |= (VERT_AUTO_SCALE |
423 VERT_INTERP_BILINEAR |
424 HORIZ_INTERP_BILINEAR);
425 /* Pillar will have left/right borders */
426 left_border = (adjusted_mode->hdisplay -
427 scaled_width) / 2;
428 right_border = left_border;
429 if (mode->hdisplay & 1) /* odd resolutions */
430 right_border++;
431 /* keep the border be even */
432 if (right_border & 1)
433 right_border++;
434 adjusted_mode->crtc_hdisplay = scaled_width;
435 /* use border instead of border minus one */
436 adjusted_mode->crtc_hblank_start =
437 scaled_width + right_border;
438 /* keep the hblank width constant */
439 adjusted_mode->crtc_hblank_end =
440 adjusted_mode->crtc_hblank_start +
441 hblank_width;
442 /*
443 * get the hsync start pos relative to
444 * hblank start
445 */
446 hsync_pos = (hblank_width - hsync_width) / 2;
447 /* keep the hsync_pos be even */
448 if (hsync_pos & 1)
449 hsync_pos++;
450 adjusted_mode->crtc_hsync_start =
451 adjusted_mode->crtc_hblank_start +
452 hsync_pos;
453 /* keept hsync width constant */
454 adjusted_mode->crtc_hsync_end =
455 adjusted_mode->crtc_hsync_start +
456 hsync_width;
457 border = 1;
458 } else if (panel_ratio < desired_ratio) { /* letter */
459 u32 scaled_height = mode->vdisplay *
460 horiz_scale / PANEL_RATIO_FACTOR;
461 vert_ratio = horiz_ratio;
462 pfit_control |= (HORIZ_AUTO_SCALE |
463 VERT_INTERP_BILINEAR |
464 HORIZ_INTERP_BILINEAR);
465 /* Letterbox will have top/bottom border */
466 top_border = (adjusted_mode->vdisplay -
467 scaled_height) / 2;
468 bottom_border = top_border;
469 if (mode->vdisplay & 1)
470 bottom_border++;
471 adjusted_mode->crtc_vdisplay = scaled_height;
472 /* use border instead of border minus one */
473 adjusted_mode->crtc_vblank_start =
474 scaled_height + bottom_border;
475 /* keep the vblank width constant */
476 adjusted_mode->crtc_vblank_end =
477 adjusted_mode->crtc_vblank_start +
478 vblank_width;
479 /*
480 * get the vsync start pos relative to
481 * vblank start
482 */
483 vsync_pos = (vblank_width - vsync_width) / 2;
484 adjusted_mode->crtc_vsync_start =
485 adjusted_mode->crtc_vblank_start +
486 vsync_pos;
487 /* keep the vsync width constant */
488 adjusted_mode->crtc_vsync_end =
489 adjusted_mode->crtc_vsync_start +
490 vsync_width;
491 border = 1;
492 } else {
493 /* Aspects match, Let hw scale both directions */
494 pfit_control |= (VERT_AUTO_SCALE |
495 HORIZ_AUTO_SCALE |
496 VERT_INTERP_BILINEAR |
497 HORIZ_INTERP_BILINEAR);
498 }
499 horiz_bits = (1 << bits) * horiz_ratio /
500 PANEL_RATIO_FACTOR;
501 vert_bits = (1 << bits) * vert_ratio /
502 PANEL_RATIO_FACTOR;
503 pfit_pgm_ratios =
504 ((vert_bits << PFIT_VERT_SCALE_SHIFT) &
505 PFIT_VERT_SCALE_MASK) |
506 ((horiz_bits << PFIT_HORIZ_SCALE_SHIFT) &
507 PFIT_HORIZ_SCALE_MASK);
508 }
509 break;
510
511 case DRM_MODE_SCALE_FULLSCREEN:
512 /*
513 * Full scaling, even if it changes the aspect ratio.
514 * Fortunately this is all done for us in hw.
515 */
516 pfit_control |= PFIT_ENABLE;
517 if (IS_I965G(dev))
518 pfit_control |= PFIT_SCALING_AUTO;
519 else
520 pfit_control |= (VERT_AUTO_SCALE | HORIZ_AUTO_SCALE |
521 VERT_INTERP_BILINEAR |
522 HORIZ_INTERP_BILINEAR);
523 break;
524 default:
525 break;
526 }
527
528out:
529 lvds_priv->pfit_control = pfit_control;
530 lvds_priv->pfit_pgm_ratios = pfit_pgm_ratios;
259 /* 531 /*
260 * XXX: It would be nice to support lower refresh rates on the 532 * XXX: It would be nice to support lower refresh rates on the
261 * panels to reduce power consumption, and perhaps match the 533 * panels to reduce power consumption, and perhaps match the
@@ -301,8 +573,8 @@ static void intel_lvds_mode_set(struct drm_encoder *encoder,
301{ 573{
302 struct drm_device *dev = encoder->dev; 574 struct drm_device *dev = encoder->dev;
303 struct drm_i915_private *dev_priv = dev->dev_private; 575 struct drm_i915_private *dev_priv = dev->dev_private;
304 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); 576 struct intel_output *intel_output = enc_to_intel_output(encoder);
305 u32 pfit_control; 577 struct intel_lvds_priv *lvds_priv = intel_output->dev_priv;
306 578
307 /* 579 /*
308 * The LVDS pin pair will already have been turned on in the 580 * The LVDS pin pair will already have been turned on in the
@@ -319,22 +591,8 @@ static void intel_lvds_mode_set(struct drm_encoder *encoder,
319 * screen. Should be enabled before the pipe is enabled, according to 591 * screen. Should be enabled before the pipe is enabled, according to
320 * register description and PRM. 592 * register description and PRM.
321 */ 593 */
322 if (mode->hdisplay != adjusted_mode->hdisplay || 594 I915_WRITE(PFIT_PGM_RATIOS, lvds_priv->pfit_pgm_ratios);
323 mode->vdisplay != adjusted_mode->vdisplay) 595 I915_WRITE(PFIT_CONTROL, lvds_priv->pfit_control);
324 pfit_control = (PFIT_ENABLE | VERT_AUTO_SCALE |
325 HORIZ_AUTO_SCALE | VERT_INTERP_BILINEAR |
326 HORIZ_INTERP_BILINEAR);
327 else
328 pfit_control = 0;
329
330 if (!IS_I965G(dev)) {
331 if (dev_priv->panel_wants_dither || dev_priv->lvds_dither)
332 pfit_control |= PANEL_8TO6_DITHER_ENABLE;
333 }
334 else
335 pfit_control |= intel_crtc->pipe << PFIT_PIPE_SHIFT;
336
337 I915_WRITE(PFIT_CONTROL, pfit_control);
338} 596}
339 597
340/** 598/**
@@ -406,6 +664,34 @@ static int intel_lvds_set_property(struct drm_connector *connector,
406 struct drm_property *property, 664 struct drm_property *property,
407 uint64_t value) 665 uint64_t value)
408{ 666{
667 struct drm_device *dev = connector->dev;
668 struct intel_output *intel_output =
669 to_intel_output(connector);
670
671 if (property == dev->mode_config.scaling_mode_property &&
672 connector->encoder) {
673 struct drm_crtc *crtc = connector->encoder->crtc;
674 struct intel_lvds_priv *lvds_priv = intel_output->dev_priv;
675 if (value == DRM_MODE_SCALE_NON_GPU) {
676 DRM_DEBUG_KMS(I915_LVDS,
677 "non_GPU property is unsupported\n");
678 return 0;
679 }
680 if (lvds_priv->fitting_mode == value) {
681 /* the LVDS scaling property is not changed */
682 return 0;
683 }
684 lvds_priv->fitting_mode = value;
685 if (crtc && crtc->enabled) {
686 /*
687 * If the CRTC is enabled, the display will be changed
688 * according to the new panel fitting mode.
689 */
690 drm_crtc_helper_set_mode(crtc, &crtc->mode,
691 crtc->x, crtc->y, crtc->fb);
692 }
693 }
694
409 return 0; 695 return 0;
410} 696}
411 697
@@ -456,7 +742,7 @@ static const struct dmi_system_id intel_no_lvds[] = {
456 .callback = intel_no_lvds_dmi_callback, 742 .callback = intel_no_lvds_dmi_callback,
457 .ident = "Apple Mac Mini (Core series)", 743 .ident = "Apple Mac Mini (Core series)",
458 .matches = { 744 .matches = {
459 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), 745 DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
460 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"), 746 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
461 }, 747 },
462 }, 748 },
@@ -464,7 +750,7 @@ static const struct dmi_system_id intel_no_lvds[] = {
464 .callback = intel_no_lvds_dmi_callback, 750 .callback = intel_no_lvds_dmi_callback,
465 .ident = "Apple Mac Mini (Core 2 series)", 751 .ident = "Apple Mac Mini (Core 2 series)",
466 .matches = { 752 .matches = {
467 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), 753 DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
468 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini2,1"), 754 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini2,1"),
469 }, 755 },
470 }, 756 },
@@ -503,6 +789,65 @@ static const struct dmi_system_id intel_no_lvds[] = {
503 { } /* terminating entry */ 789 { } /* terminating entry */
504}; 790};
505 791
792#ifdef CONFIG_ACPI
793/*
794 * check_lid_device -- check whether @handle is an ACPI LID device.
795 * @handle: ACPI device handle
796 * @level : depth in the ACPI namespace tree
797 * @context: the number of LID device when we find the device
798 * @rv: a return value to fill if desired (Not use)
799 */
800static acpi_status
801check_lid_device(acpi_handle handle, u32 level, void *context,
802 void **return_value)
803{
804 struct acpi_device *acpi_dev;
805 int *lid_present = context;
806
807 acpi_dev = NULL;
808 /* Get the acpi device for device handle */
809 if (acpi_bus_get_device(handle, &acpi_dev) || !acpi_dev) {
810 /* If there is no ACPI device for handle, return */
811 return AE_OK;
812 }
813
814 if (!strncmp(acpi_device_hid(acpi_dev), "PNP0C0D", 7))
815 *lid_present = 1;
816
817 return AE_OK;
818}
819
820/**
821 * check whether there exists the ACPI LID device by enumerating the ACPI
822 * device tree.
823 */
824static int intel_lid_present(void)
825{
826 int lid_present = 0;
827
828 if (acpi_disabled) {
829 /* If ACPI is disabled, there is no ACPI device tree to
830 * check, so assume the LID device would have been present.
831 */
832 return 1;
833 }
834
835 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
836 ACPI_UINT32_MAX,
837 check_lid_device, &lid_present, NULL);
838
839 return lid_present;
840}
841#else
842static int intel_lid_present(void)
843{
844 /* In the absence of ACPI built in, assume that the LID device would
845 * have been present.
846 */
847 return 1;
848}
849#endif
850
506/** 851/**
507 * intel_lvds_init - setup LVDS connectors on this device 852 * intel_lvds_init - setup LVDS connectors on this device
508 * @dev: drm device 853 * @dev: drm device
@@ -518,6 +863,7 @@ void intel_lvds_init(struct drm_device *dev)
518 struct drm_encoder *encoder; 863 struct drm_encoder *encoder;
519 struct drm_display_mode *scan; /* *modes, *bios_mode; */ 864 struct drm_display_mode *scan; /* *modes, *bios_mode; */
520 struct drm_crtc *crtc; 865 struct drm_crtc *crtc;
866 struct intel_lvds_priv *lvds_priv;
521 u32 lvds; 867 u32 lvds;
522 int pipe, gpio = GPIOC; 868 int pipe, gpio = GPIOC;
523 869
@@ -525,13 +871,24 @@ void intel_lvds_init(struct drm_device *dev)
525 if (dmi_check_system(intel_no_lvds)) 871 if (dmi_check_system(intel_no_lvds))
526 return; 872 return;
527 873
874 /* Assume that any device without an ACPI LID device also doesn't
875 * have an integrated LVDS. We would be better off parsing the BIOS
876 * to get a reliable indicator, but that code isn't written yet.
877 *
878 * In the case of all-in-one desktops using LVDS that we've seen,
879 * they're using SDVO LVDS.
880 */
881 if (!intel_lid_present())
882 return;
883
528 if (IS_IGDNG(dev)) { 884 if (IS_IGDNG(dev)) {
529 if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0) 885 if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0)
530 return; 886 return;
531 gpio = PCH_GPIOC; 887 gpio = PCH_GPIOC;
532 } 888 }
533 889
534 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); 890 intel_output = kzalloc(sizeof(struct intel_output) +
891 sizeof(struct intel_lvds_priv), GFP_KERNEL);
535 if (!intel_output) { 892 if (!intel_output) {
536 return; 893 return;
537 } 894 }
@@ -553,7 +910,18 @@ void intel_lvds_init(struct drm_device *dev)
553 connector->interlace_allowed = false; 910 connector->interlace_allowed = false;
554 connector->doublescan_allowed = false; 911 connector->doublescan_allowed = false;
555 912
913 lvds_priv = (struct intel_lvds_priv *)(intel_output + 1);
914 intel_output->dev_priv = lvds_priv;
915 /* create the scaling mode property */
916 drm_mode_create_scaling_mode_property(dev);
917 /*
918 * the initial panel fitting mode will be FULL_SCREEN.
919 */
556 920
921 drm_connector_attach_property(&intel_output->base,
922 dev->mode_config.scaling_mode_property,
923 DRM_MODE_SCALE_FULLSCREEN);
924 lvds_priv->fitting_mode = DRM_MODE_SCALE_FULLSCREEN;
557 /* 925 /*
558 * LVDS discovery: 926 * LVDS discovery:
559 * 1) check for EDID on DDC 927 * 1) check for EDID on DDC
@@ -649,5 +1017,5 @@ failed:
649 if (intel_output->ddc_bus) 1017 if (intel_output->ddc_bus)
650 intel_i2c_destroy(intel_output->ddc_bus); 1018 intel_i2c_destroy(intel_output->ddc_bus);
651 drm_connector_cleanup(connector); 1019 drm_connector_cleanup(connector);
652 kfree(connector); 1020 kfree(intel_output);
653} 1021}
diff --git a/drivers/gpu/drm/i915/intel_modes.c b/drivers/gpu/drm/i915/intel_modes.c
index e0910fefce87..67e2f4632a24 100644
--- a/drivers/gpu/drm/i915/intel_modes.c
+++ b/drivers/gpu/drm/i915/intel_modes.c
@@ -53,10 +53,9 @@ bool intel_ddc_probe(struct intel_output *intel_output)
53 } 53 }
54 }; 54 };
55 55
56 intel_i2c_quirk_set(intel_output->ddc_bus->drm_dev, true); 56 intel_i2c_quirk_set(intel_output->base.dev, true);
57 ret = i2c_transfer(&intel_output->ddc_bus->adapter, msgs, 2); 57 ret = i2c_transfer(intel_output->ddc_bus, msgs, 2);
58 intel_i2c_quirk_set(intel_output->ddc_bus->drm_dev, false); 58 intel_i2c_quirk_set(intel_output->base.dev, false);
59
60 if (ret == 2) 59 if (ret == 2)
61 return true; 60 return true;
62 61
@@ -74,10 +73,9 @@ int intel_ddc_get_modes(struct intel_output *intel_output)
74 struct edid *edid; 73 struct edid *edid;
75 int ret = 0; 74 int ret = 0;
76 75
77 intel_i2c_quirk_set(intel_output->ddc_bus->drm_dev, true); 76 intel_i2c_quirk_set(intel_output->base.dev, true);
78 edid = drm_get_edid(&intel_output->base, 77 edid = drm_get_edid(&intel_output->base, intel_output->ddc_bus);
79 &intel_output->ddc_bus->adapter); 78 intel_i2c_quirk_set(intel_output->base.dev, false);
80 intel_i2c_quirk_set(intel_output->ddc_bus->drm_dev, false);
81 if (edid) { 79 if (edid) {
82 drm_mode_connector_update_edid_property(&intel_output->base, 80 drm_mode_connector_update_edid_property(&intel_output->base,
83 edid); 81 edid);
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 9a00adb3a508..4f0c30948bc4 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -38,8 +38,7 @@
38#undef SDVO_DEBUG 38#undef SDVO_DEBUG
39#define I915_SDVO "i915_sdvo" 39#define I915_SDVO "i915_sdvo"
40struct intel_sdvo_priv { 40struct intel_sdvo_priv {
41 struct intel_i2c_chan *i2c_bus; 41 u8 slave_addr;
42 int slaveaddr;
43 42
44 /* Register for the SDVO device: SDVOB or SDVOC */ 43 /* Register for the SDVO device: SDVOB or SDVOC */
45 int output_device; 44 int output_device;
@@ -69,12 +68,23 @@ struct intel_sdvo_priv {
69 * This is set if we treat the device as HDMI, instead of DVI. 68 * This is set if we treat the device as HDMI, instead of DVI.
70 */ 69 */
71 bool is_hdmi; 70 bool is_hdmi;
71
72 /** 72 /**
73 * This is set if we detect output of sdvo device as LVDS. 73 * This is set if we detect output of sdvo device as LVDS.
74 */ 74 */
75 bool is_lvds; 75 bool is_lvds;
76 76
77 /** 77 /**
78 * This is sdvo flags for input timing.
79 */
80 uint8_t sdvo_flags;
81
82 /**
83 * This is sdvo fixed pannel mode pointer
84 */
85 struct drm_display_mode *sdvo_lvds_fixed_mode;
86
87 /**
78 * Returned SDTV resolutions allowed for the current format, if the 88 * Returned SDTV resolutions allowed for the current format, if the
79 * device reported it. 89 * device reported it.
80 */ 90 */
@@ -146,13 +156,13 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr,
146 156
147 struct i2c_msg msgs[] = { 157 struct i2c_msg msgs[] = {
148 { 158 {
149 .addr = sdvo_priv->i2c_bus->slave_addr, 159 .addr = sdvo_priv->slave_addr >> 1,
150 .flags = 0, 160 .flags = 0,
151 .len = 1, 161 .len = 1,
152 .buf = out_buf, 162 .buf = out_buf,
153 }, 163 },
154 { 164 {
155 .addr = sdvo_priv->i2c_bus->slave_addr, 165 .addr = sdvo_priv->slave_addr >> 1,
156 .flags = I2C_M_RD, 166 .flags = I2C_M_RD,
157 .len = 1, 167 .len = 1,
158 .buf = buf, 168 .buf = buf,
@@ -162,7 +172,7 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr,
162 out_buf[0] = addr; 172 out_buf[0] = addr;
163 out_buf[1] = 0; 173 out_buf[1] = 0;
164 174
165 if ((ret = i2c_transfer(&sdvo_priv->i2c_bus->adapter, msgs, 2)) == 2) 175 if ((ret = i2c_transfer(intel_output->i2c_bus, msgs, 2)) == 2)
166 { 176 {
167 *ch = buf[0]; 177 *ch = buf[0];
168 return true; 178 return true;
@@ -175,10 +185,11 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr,
175static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr, 185static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr,
176 u8 ch) 186 u8 ch)
177{ 187{
188 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
178 u8 out_buf[2]; 189 u8 out_buf[2];
179 struct i2c_msg msgs[] = { 190 struct i2c_msg msgs[] = {
180 { 191 {
181 .addr = intel_output->i2c_bus->slave_addr, 192 .addr = sdvo_priv->slave_addr >> 1,
182 .flags = 0, 193 .flags = 0,
183 .len = 2, 194 .len = 2,
184 .buf = out_buf, 195 .buf = out_buf,
@@ -188,7 +199,7 @@ static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr,
188 out_buf[0] = addr; 199 out_buf[0] = addr;
189 out_buf[1] = ch; 200 out_buf[1] = ch;
190 201
191 if (i2c_transfer(&intel_output->i2c_bus->adapter, msgs, 1) == 1) 202 if (i2c_transfer(intel_output->i2c_bus, msgs, 1) == 1)
192 { 203 {
193 return true; 204 return true;
194 } 205 }
@@ -592,6 +603,7 @@ intel_sdvo_create_preferred_input_timing(struct intel_output *output,
592 uint16_t height) 603 uint16_t height)
593{ 604{
594 struct intel_sdvo_preferred_input_timing_args args; 605 struct intel_sdvo_preferred_input_timing_args args;
606 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
595 uint8_t status; 607 uint8_t status;
596 608
597 memset(&args, 0, sizeof(args)); 609 memset(&args, 0, sizeof(args));
@@ -599,7 +611,12 @@ intel_sdvo_create_preferred_input_timing(struct intel_output *output,
599 args.width = width; 611 args.width = width;
600 args.height = height; 612 args.height = height;
601 args.interlace = 0; 613 args.interlace = 0;
602 args.scaled = 0; 614
615 if (sdvo_priv->is_lvds &&
616 (sdvo_priv->sdvo_lvds_fixed_mode->hdisplay != width ||
617 sdvo_priv->sdvo_lvds_fixed_mode->vdisplay != height))
618 args.scaled = 1;
619
603 intel_sdvo_write_cmd(output, SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING, 620 intel_sdvo_write_cmd(output, SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING,
604 &args, sizeof(args)); 621 &args, sizeof(args));
605 status = intel_sdvo_read_response(output, NULL, 0); 622 status = intel_sdvo_read_response(output, NULL, 0);
@@ -944,12 +961,7 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
944 struct intel_output *output = enc_to_intel_output(encoder); 961 struct intel_output *output = enc_to_intel_output(encoder);
945 struct intel_sdvo_priv *dev_priv = output->dev_priv; 962 struct intel_sdvo_priv *dev_priv = output->dev_priv;
946 963
947 if (!dev_priv->is_tv) { 964 if (dev_priv->is_tv) {
948 /* Make the CRTC code factor in the SDVO pixel multiplier. The
949 * SDVO device will be told of the multiplier during mode_set.
950 */
951 adjusted_mode->clock *= intel_sdvo_get_pixel_multiplier(mode);
952 } else {
953 struct intel_sdvo_dtd output_dtd; 965 struct intel_sdvo_dtd output_dtd;
954 bool success; 966 bool success;
955 967
@@ -980,6 +992,7 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
980 intel_sdvo_get_preferred_input_timing(output, 992 intel_sdvo_get_preferred_input_timing(output,
981 &input_dtd); 993 &input_dtd);
982 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd); 994 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd);
995 dev_priv->sdvo_flags = input_dtd.part2.sdvo_flags;
983 996
984 drm_mode_set_crtcinfo(adjusted_mode, 0); 997 drm_mode_set_crtcinfo(adjusted_mode, 0);
985 998
@@ -990,6 +1003,52 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
990 } else { 1003 } else {
991 return false; 1004 return false;
992 } 1005 }
1006 } else if (dev_priv->is_lvds) {
1007 struct intel_sdvo_dtd output_dtd;
1008 bool success;
1009
1010 drm_mode_set_crtcinfo(dev_priv->sdvo_lvds_fixed_mode, 0);
1011 /* Set output timings */
1012 intel_sdvo_get_dtd_from_mode(&output_dtd,
1013 dev_priv->sdvo_lvds_fixed_mode);
1014
1015 intel_sdvo_set_target_output(output,
1016 dev_priv->controlled_output);
1017 intel_sdvo_set_output_timing(output, &output_dtd);
1018
1019 /* Set the input timing to the screen. Assume always input 0. */
1020 intel_sdvo_set_target_input(output, true, false);
1021
1022
1023 success = intel_sdvo_create_preferred_input_timing(
1024 output,
1025 mode->clock / 10,
1026 mode->hdisplay,
1027 mode->vdisplay);
1028
1029 if (success) {
1030 struct intel_sdvo_dtd input_dtd;
1031
1032 intel_sdvo_get_preferred_input_timing(output,
1033 &input_dtd);
1034 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd);
1035 dev_priv->sdvo_flags = input_dtd.part2.sdvo_flags;
1036
1037 drm_mode_set_crtcinfo(adjusted_mode, 0);
1038
1039 mode->clock = adjusted_mode->clock;
1040
1041 adjusted_mode->clock *=
1042 intel_sdvo_get_pixel_multiplier(mode);
1043 } else {
1044 return false;
1045 }
1046
1047 } else {
1048 /* Make the CRTC code factor in the SDVO pixel multiplier. The
1049 * SDVO device will be told of the multiplier during mode_set.
1050 */
1051 adjusted_mode->clock *= intel_sdvo_get_pixel_multiplier(mode);
993 } 1052 }
994 return true; 1053 return true;
995} 1054}
@@ -1033,15 +1092,16 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1033 1092
1034 /* We have tried to get input timing in mode_fixup, and filled into 1093 /* We have tried to get input timing in mode_fixup, and filled into
1035 adjusted_mode */ 1094 adjusted_mode */
1036 if (sdvo_priv->is_tv) 1095 if (sdvo_priv->is_tv || sdvo_priv->is_lvds) {
1037 intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode); 1096 intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
1038 else 1097 input_dtd.part2.sdvo_flags = sdvo_priv->sdvo_flags;
1098 } else
1039 intel_sdvo_get_dtd_from_mode(&input_dtd, mode); 1099 intel_sdvo_get_dtd_from_mode(&input_dtd, mode);
1040 1100
1041 /* If it's a TV, we already set the output timing in mode_fixup. 1101 /* If it's a TV, we already set the output timing in mode_fixup.
1042 * Otherwise, the output timing is equal to the input timing. 1102 * Otherwise, the output timing is equal to the input timing.
1043 */ 1103 */
1044 if (!sdvo_priv->is_tv) { 1104 if (!sdvo_priv->is_tv && !sdvo_priv->is_lvds) {
1045 /* Set the output timing to the screen */ 1105 /* Set the output timing to the screen */
1046 intel_sdvo_set_target_output(output, 1106 intel_sdvo_set_target_output(output,
1047 sdvo_priv->controlled_output); 1107 sdvo_priv->controlled_output);
@@ -1116,6 +1176,8 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1116 sdvox |= (sdvo_pixel_multiply - 1) << SDVO_PORT_MULTIPLY_SHIFT; 1176 sdvox |= (sdvo_pixel_multiply - 1) << SDVO_PORT_MULTIPLY_SHIFT;
1117 } 1177 }
1118 1178
1179 if (sdvo_priv->sdvo_flags & SDVO_NEED_TO_STALL)
1180 sdvox |= SDVO_STALL_SELECT;
1119 intel_sdvo_write_sdvox(output, sdvox); 1181 intel_sdvo_write_sdvox(output, sdvox);
1120} 1182}
1121 1183
@@ -1276,6 +1338,17 @@ static int intel_sdvo_mode_valid(struct drm_connector *connector,
1276 if (sdvo_priv->pixel_clock_max < mode->clock) 1338 if (sdvo_priv->pixel_clock_max < mode->clock)
1277 return MODE_CLOCK_HIGH; 1339 return MODE_CLOCK_HIGH;
1278 1340
1341 if (sdvo_priv->is_lvds == true) {
1342 if (sdvo_priv->sdvo_lvds_fixed_mode == NULL)
1343 return MODE_PANEL;
1344
1345 if (mode->hdisplay > sdvo_priv->sdvo_lvds_fixed_mode->hdisplay)
1346 return MODE_PANEL;
1347
1348 if (mode->vdisplay > sdvo_priv->sdvo_lvds_fixed_mode->vdisplay)
1349 return MODE_PANEL;
1350 }
1351
1279 return MODE_OK; 1352 return MODE_OK;
1280} 1353}
1281 1354
@@ -1369,9 +1442,8 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1369 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1442 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1370 struct edid *edid = NULL; 1443 struct edid *edid = NULL;
1371 1444
1372 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
1373 edid = drm_get_edid(&intel_output->base, 1445 edid = drm_get_edid(&intel_output->base,
1374 &intel_output->ddc_bus->adapter); 1446 intel_output->ddc_bus);
1375 if (edid != NULL) { 1447 if (edid != NULL) {
1376 sdvo_priv->is_hdmi = drm_detect_hdmi_monitor(edid); 1448 sdvo_priv->is_hdmi = drm_detect_hdmi_monitor(edid);
1377 kfree(edid); 1449 kfree(edid);
@@ -1549,23 +1621,21 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
1549static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) 1621static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
1550{ 1622{
1551 struct intel_output *intel_output = to_intel_output(connector); 1623 struct intel_output *intel_output = to_intel_output(connector);
1552 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1553 struct drm_i915_private *dev_priv = connector->dev->dev_private; 1624 struct drm_i915_private *dev_priv = connector->dev->dev_private;
1625 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1626 struct drm_display_mode *newmode;
1554 1627
1555 /* 1628 /*
1556 * Attempt to get the mode list from DDC. 1629 * Attempt to get the mode list from DDC.
1557 * Assume that the preferred modes are 1630 * Assume that the preferred modes are
1558 * arranged in priority order. 1631 * arranged in priority order.
1559 */ 1632 */
1560 /* set the bus switch and get the modes */
1561 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
1562 intel_ddc_get_modes(intel_output); 1633 intel_ddc_get_modes(intel_output);
1563 if (list_empty(&connector->probed_modes) == false) 1634 if (list_empty(&connector->probed_modes) == false)
1564 return; 1635 goto end;
1565 1636
1566 /* Fetch modes from VBT */ 1637 /* Fetch modes from VBT */
1567 if (dev_priv->sdvo_lvds_vbt_mode != NULL) { 1638 if (dev_priv->sdvo_lvds_vbt_mode != NULL) {
1568 struct drm_display_mode *newmode;
1569 newmode = drm_mode_duplicate(connector->dev, 1639 newmode = drm_mode_duplicate(connector->dev,
1570 dev_priv->sdvo_lvds_vbt_mode); 1640 dev_priv->sdvo_lvds_vbt_mode);
1571 if (newmode != NULL) { 1641 if (newmode != NULL) {
@@ -1575,6 +1645,16 @@ static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
1575 drm_mode_probed_add(connector, newmode); 1645 drm_mode_probed_add(connector, newmode);
1576 } 1646 }
1577 } 1647 }
1648
1649end:
1650 list_for_each_entry(newmode, &connector->probed_modes, head) {
1651 if (newmode->type & DRM_MODE_TYPE_PREFERRED) {
1652 sdvo_priv->sdvo_lvds_fixed_mode =
1653 drm_mode_duplicate(connector->dev, newmode);
1654 break;
1655 }
1656 }
1657
1578} 1658}
1579 1659
1580static int intel_sdvo_get_modes(struct drm_connector *connector) 1660static int intel_sdvo_get_modes(struct drm_connector *connector)
@@ -1597,14 +1677,20 @@ static int intel_sdvo_get_modes(struct drm_connector *connector)
1597static void intel_sdvo_destroy(struct drm_connector *connector) 1677static void intel_sdvo_destroy(struct drm_connector *connector)
1598{ 1678{
1599 struct intel_output *intel_output = to_intel_output(connector); 1679 struct intel_output *intel_output = to_intel_output(connector);
1680 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1600 1681
1601 if (intel_output->i2c_bus) 1682 if (intel_output->i2c_bus)
1602 intel_i2c_destroy(intel_output->i2c_bus); 1683 intel_i2c_destroy(intel_output->i2c_bus);
1603 if (intel_output->ddc_bus) 1684 if (intel_output->ddc_bus)
1604 intel_i2c_destroy(intel_output->ddc_bus); 1685 intel_i2c_destroy(intel_output->ddc_bus);
1605 1686
1687 if (sdvo_priv->sdvo_lvds_fixed_mode != NULL)
1688 drm_mode_destroy(connector->dev,
1689 sdvo_priv->sdvo_lvds_fixed_mode);
1690
1606 drm_sysfs_connector_remove(connector); 1691 drm_sysfs_connector_remove(connector);
1607 drm_connector_cleanup(connector); 1692 drm_connector_cleanup(connector);
1693
1608 kfree(intel_output); 1694 kfree(intel_output);
1609} 1695}
1610 1696
@@ -1709,7 +1795,7 @@ intel_sdvo_chan_to_intel_output(struct intel_i2c_chan *chan)
1709 1795
1710 list_for_each_entry(connector, 1796 list_for_each_entry(connector,
1711 &dev->mode_config.connector_list, head) { 1797 &dev->mode_config.connector_list, head) {
1712 if (to_intel_output(connector)->ddc_bus == chan) { 1798 if (to_intel_output(connector)->ddc_bus == &chan->adapter) {
1713 intel_output = to_intel_output(connector); 1799 intel_output = to_intel_output(connector);
1714 break; 1800 break;
1715 } 1801 }
@@ -1723,7 +1809,7 @@ static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap,
1723 struct intel_output *intel_output; 1809 struct intel_output *intel_output;
1724 struct intel_sdvo_priv *sdvo_priv; 1810 struct intel_sdvo_priv *sdvo_priv;
1725 struct i2c_algo_bit_data *algo_data; 1811 struct i2c_algo_bit_data *algo_data;
1726 struct i2c_algorithm *algo; 1812 const struct i2c_algorithm *algo;
1727 1813
1728 algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data; 1814 algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data;
1729 intel_output = 1815 intel_output =
@@ -1733,7 +1819,7 @@ static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap,
1733 return -EINVAL; 1819 return -EINVAL;
1734 1820
1735 sdvo_priv = intel_output->dev_priv; 1821 sdvo_priv = intel_output->dev_priv;
1736 algo = (struct i2c_algorithm *)intel_output->i2c_bus->adapter.algo; 1822 algo = intel_output->i2c_bus->algo;
1737 1823
1738 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); 1824 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
1739 return algo->master_xfer(i2c_adap, msgs, num); 1825 return algo->master_xfer(i2c_adap, msgs, num);
@@ -1785,13 +1871,11 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1785 struct drm_connector *connector; 1871 struct drm_connector *connector;
1786 struct intel_output *intel_output; 1872 struct intel_output *intel_output;
1787 struct intel_sdvo_priv *sdvo_priv; 1873 struct intel_sdvo_priv *sdvo_priv;
1788 struct intel_i2c_chan *i2cbus = NULL; 1874
1789 struct intel_i2c_chan *ddcbus = NULL;
1790 int connector_type; 1875 int connector_type;
1791 u8 ch[0x40]; 1876 u8 ch[0x40];
1792 int i; 1877 int i;
1793 int encoder_type, output_id; 1878 int encoder_type;
1794 u8 slave_addr;
1795 1879
1796 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); 1880 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL);
1797 if (!intel_output) { 1881 if (!intel_output) {
@@ -1799,29 +1883,24 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1799 } 1883 }
1800 1884
1801 sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1); 1885 sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1);
1886 sdvo_priv->output_device = output_device;
1887
1888 intel_output->dev_priv = sdvo_priv;
1802 intel_output->type = INTEL_OUTPUT_SDVO; 1889 intel_output->type = INTEL_OUTPUT_SDVO;
1803 1890
1804 /* setup the DDC bus. */ 1891 /* setup the DDC bus. */
1805 if (output_device == SDVOB) 1892 if (output_device == SDVOB)
1806 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB"); 1893 intel_output->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB");
1807 else 1894 else
1808 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); 1895 intel_output->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC");
1809 1896
1810 if (!i2cbus) 1897 if (!intel_output->i2c_bus)
1811 goto err_inteloutput; 1898 goto err_inteloutput;
1812 1899
1813 slave_addr = intel_sdvo_get_slave_addr(dev, output_device); 1900 sdvo_priv->slave_addr = intel_sdvo_get_slave_addr(dev, output_device);
1814 sdvo_priv->i2c_bus = i2cbus;
1815 1901
1816 if (output_device == SDVOB) { 1902 /* Save the bit-banging i2c functionality for use by the DDC wrapper */
1817 output_id = 1; 1903 intel_sdvo_i2c_bit_algo.functionality = intel_output->i2c_bus->algo->functionality;
1818 } else {
1819 output_id = 2;
1820 }
1821 sdvo_priv->i2c_bus->slave_addr = slave_addr >> 1;
1822 sdvo_priv->output_device = output_device;
1823 intel_output->i2c_bus = i2cbus;
1824 intel_output->dev_priv = sdvo_priv;
1825 1904
1826 /* Read the regs to test if we can talk to the device */ 1905 /* Read the regs to test if we can talk to the device */
1827 for (i = 0; i < 0x40; i++) { 1906 for (i = 0; i < 0x40; i++) {
@@ -1835,17 +1914,15 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1835 1914
1836 /* setup the DDC bus. */ 1915 /* setup the DDC bus. */
1837 if (output_device == SDVOB) 1916 if (output_device == SDVOB)
1838 ddcbus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS"); 1917 intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS");
1839 else 1918 else
1840 ddcbus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS"); 1919 intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS");
1841 1920
1842 if (ddcbus == NULL) 1921 if (intel_output->ddc_bus == NULL)
1843 goto err_i2c; 1922 goto err_i2c;
1844 1923
1845 intel_sdvo_i2c_bit_algo.functionality = 1924 /* Wrap with our custom algo which switches to DDC mode */
1846 intel_output->i2c_bus->adapter.algo->functionality; 1925 intel_output->ddc_bus->algo = &intel_sdvo_i2c_bit_algo;
1847 ddcbus->adapter.algo = &intel_sdvo_i2c_bit_algo;
1848 intel_output->ddc_bus = ddcbus;
1849 1926
1850 /* In defaut case sdvo lvds is false */ 1927 /* In defaut case sdvo lvds is false */
1851 sdvo_priv->is_lvds = false; 1928 sdvo_priv->is_lvds = false;
@@ -1965,9 +2042,10 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1965 return true; 2042 return true;
1966 2043
1967err_i2c: 2044err_i2c:
1968 if (ddcbus != NULL) 2045 if (intel_output->ddc_bus != NULL)
1969 intel_i2c_destroy(intel_output->ddc_bus); 2046 intel_i2c_destroy(intel_output->ddc_bus);
1970 intel_i2c_destroy(intel_output->i2c_bus); 2047 if (intel_output->i2c_bus != NULL)
2048 intel_i2c_destroy(intel_output->i2c_bus);
1971err_inteloutput: 2049err_inteloutput:
1972 kfree(intel_output); 2050 kfree(intel_output);
1973 2051
diff --git a/drivers/gpu/drm/i915/intel_sdvo_regs.h b/drivers/gpu/drm/i915/intel_sdvo_regs.h
index 193938b7d7f9..ba5cdf8ae40b 100644
--- a/drivers/gpu/drm/i915/intel_sdvo_regs.h
+++ b/drivers/gpu/drm/i915/intel_sdvo_regs.h
@@ -715,6 +715,7 @@ struct intel_sdvo_enhancements_arg {
715 #define SDVO_HBUF_TX_ONCE (2 << 6) 715 #define SDVO_HBUF_TX_ONCE (2 << 6)
716 #define SDVO_HBUF_TX_VSYNC (3 << 6) 716 #define SDVO_HBUF_TX_VSYNC (3 << 6)
717#define SDVO_CMD_GET_AUDIO_TX_INFO 0x9c 717#define SDVO_CMD_GET_AUDIO_TX_INFO 0x9c
718#define SDVO_NEED_TO_STALL (1 << 7)
718 719
719struct intel_sdvo_encode{ 720struct intel_sdvo_encode{
720 u8 dvi_rev; 721 u8 dvi_rev;
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index ea68992e4416..a43c98e3f077 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -1383,34 +1383,31 @@ intel_tv_detect_type (struct drm_crtc *crtc, struct intel_output *intel_output)
1383 /* 1383 /*
1384 * Detect TV by polling) 1384 * Detect TV by polling)
1385 */ 1385 */
1386 if (intel_output->load_detect_temp) { 1386 save_tv_dac = tv_dac;
1387 /* TV not currently running, prod it with destructive detect */ 1387 tv_ctl = I915_READ(TV_CTL);
1388 save_tv_dac = tv_dac; 1388 save_tv_ctl = tv_ctl;
1389 tv_ctl = I915_READ(TV_CTL); 1389 tv_ctl &= ~TV_ENC_ENABLE;
1390 save_tv_ctl = tv_ctl; 1390 tv_ctl &= ~TV_TEST_MODE_MASK;
1391 tv_ctl &= ~TV_ENC_ENABLE; 1391 tv_ctl |= TV_TEST_MODE_MONITOR_DETECT;
1392 tv_ctl &= ~TV_TEST_MODE_MASK; 1392 tv_dac &= ~TVDAC_SENSE_MASK;
1393 tv_ctl |= TV_TEST_MODE_MONITOR_DETECT; 1393 tv_dac &= ~DAC_A_MASK;
1394 tv_dac &= ~TVDAC_SENSE_MASK; 1394 tv_dac &= ~DAC_B_MASK;
1395 tv_dac &= ~DAC_A_MASK; 1395 tv_dac &= ~DAC_C_MASK;
1396 tv_dac &= ~DAC_B_MASK; 1396 tv_dac |= (TVDAC_STATE_CHG_EN |
1397 tv_dac &= ~DAC_C_MASK; 1397 TVDAC_A_SENSE_CTL |
1398 tv_dac |= (TVDAC_STATE_CHG_EN | 1398 TVDAC_B_SENSE_CTL |
1399 TVDAC_A_SENSE_CTL | 1399 TVDAC_C_SENSE_CTL |
1400 TVDAC_B_SENSE_CTL | 1400 DAC_CTL_OVERRIDE |
1401 TVDAC_C_SENSE_CTL | 1401 DAC_A_0_7_V |
1402 DAC_CTL_OVERRIDE | 1402 DAC_B_0_7_V |
1403 DAC_A_0_7_V | 1403 DAC_C_0_7_V);
1404 DAC_B_0_7_V | 1404 I915_WRITE(TV_CTL, tv_ctl);
1405 DAC_C_0_7_V); 1405 I915_WRITE(TV_DAC, tv_dac);
1406 I915_WRITE(TV_CTL, tv_ctl); 1406 intel_wait_for_vblank(dev);
1407 I915_WRITE(TV_DAC, tv_dac); 1407 tv_dac = I915_READ(TV_DAC);
1408 intel_wait_for_vblank(dev); 1408 I915_WRITE(TV_DAC, save_tv_dac);
1409 tv_dac = I915_READ(TV_DAC); 1409 I915_WRITE(TV_CTL, save_tv_ctl);
1410 I915_WRITE(TV_DAC, save_tv_dac); 1410 intel_wait_for_vblank(dev);
1411 I915_WRITE(TV_CTL, save_tv_ctl);
1412 intel_wait_for_vblank(dev);
1413 }
1414 /* 1411 /*
1415 * A B C 1412 * A B C
1416 * 0 1 1 Composite 1413 * 0 1 1 Composite
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index f30aa7274a54..f97563db4e59 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -35,6 +35,23 @@
35#include "atom.h" 35#include "atom.h"
36 36
37/* 37/*
38 * Clear GPU surface registers.
39 */
40static void radeon_surface_init(struct radeon_device *rdev)
41{
42 /* FIXME: check this out */
43 if (rdev->family < CHIP_R600) {
44 int i;
45
46 for (i = 0; i < 8; i++) {
47 WREG32(RADEON_SURFACE0_INFO +
48 i * (RADEON_SURFACE1_INFO - RADEON_SURFACE0_INFO),
49 0);
50 }
51 }
52}
53
54/*
38 * GPU scratch registers helpers function. 55 * GPU scratch registers helpers function.
39 */ 56 */
40static void radeon_scratch_init(struct radeon_device *rdev) 57static void radeon_scratch_init(struct radeon_device *rdev)
@@ -496,6 +513,8 @@ int radeon_device_init(struct radeon_device *rdev,
496 radeon_errata(rdev); 513 radeon_errata(rdev);
497 /* Initialize scratch registers */ 514 /* Initialize scratch registers */
498 radeon_scratch_init(rdev); 515 radeon_scratch_init(rdev);
516 /* Initialize surface registers */
517 radeon_surface_init(rdev);
499 518
500 /* TODO: disable VGA need to use VGA request */ 519 /* TODO: disable VGA need to use VGA request */
501 /* BIOS*/ 520 /* BIOS*/
@@ -604,9 +623,6 @@ int radeon_device_init(struct radeon_device *rdev,
604 if (r) { 623 if (r) {
605 return r; 624 return r;
606 } 625 }
607 if (rdev->fbdev_rfb && rdev->fbdev_rfb->obj) {
608 rdev->fbdev_robj = rdev->fbdev_rfb->obj->driver_private;
609 }
610 if (!ret) { 626 if (!ret) {
611 DRM_INFO("radeon: kernel modesetting successfully initialized.\n"); 627 DRM_INFO("radeon: kernel modesetting successfully initialized.\n");
612 } 628 }
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 09c9fb9f6210..84ba69f48784 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -345,7 +345,7 @@ static void __exit radeon_exit(void)
345 drm_exit(driver); 345 drm_exit(driver);
346} 346}
347 347
348late_initcall(radeon_init); 348module_init(radeon_init);
349module_exit(radeon_exit); 349module_exit(radeon_exit);
350 350
351MODULE_AUTHOR(DRIVER_AUTHOR); 351MODULE_AUTHOR(DRIVER_AUTHOR);
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index fa86d398945e..9e8f191eb64a 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -478,14 +478,16 @@ int radeonfb_create(struct radeon_device *rdev,
478{ 478{
479 struct fb_info *info; 479 struct fb_info *info;
480 struct radeon_fb_device *rfbdev; 480 struct radeon_fb_device *rfbdev;
481 struct drm_framebuffer *fb; 481 struct drm_framebuffer *fb = NULL;
482 struct radeon_framebuffer *rfb; 482 struct radeon_framebuffer *rfb;
483 struct drm_mode_fb_cmd mode_cmd; 483 struct drm_mode_fb_cmd mode_cmd;
484 struct drm_gem_object *gobj = NULL; 484 struct drm_gem_object *gobj = NULL;
485 struct radeon_object *robj = NULL; 485 struct radeon_object *robj = NULL;
486 struct device *device = &rdev->pdev->dev; 486 struct device *device = &rdev->pdev->dev;
487 int size, aligned_size, ret; 487 int size, aligned_size, ret;
488 u64 fb_gpuaddr;
488 void *fbptr = NULL; 489 void *fbptr = NULL;
490 unsigned long tmp;
489 491
490 mode_cmd.width = surface_width; 492 mode_cmd.width = surface_width;
491 mode_cmd.height = surface_height; 493 mode_cmd.height = surface_height;
@@ -498,11 +500,12 @@ int radeonfb_create(struct radeon_device *rdev,
498 aligned_size = ALIGN(size, PAGE_SIZE); 500 aligned_size = ALIGN(size, PAGE_SIZE);
499 501
500 ret = radeon_gem_object_create(rdev, aligned_size, 0, 502 ret = radeon_gem_object_create(rdev, aligned_size, 0,
501 RADEON_GEM_DOMAIN_VRAM, 503 RADEON_GEM_DOMAIN_VRAM,
502 false, ttm_bo_type_kernel, 504 false, ttm_bo_type_kernel,
503 false, &gobj); 505 false, &gobj);
504 if (ret) { 506 if (ret) {
505 printk(KERN_ERR "failed to allocate framebuffer\n"); 507 printk(KERN_ERR "failed to allocate framebuffer (%d %d)\n",
508 surface_width, surface_height);
506 ret = -ENOMEM; 509 ret = -ENOMEM;
507 goto out; 510 goto out;
508 } 511 }
@@ -515,12 +518,19 @@ int radeonfb_create(struct radeon_device *rdev,
515 ret = -ENOMEM; 518 ret = -ENOMEM;
516 goto out_unref; 519 goto out_unref;
517 } 520 }
521 ret = radeon_object_pin(robj, RADEON_GEM_DOMAIN_VRAM, &fb_gpuaddr);
522 if (ret) {
523 printk(KERN_ERR "failed to pin framebuffer\n");
524 ret = -ENOMEM;
525 goto out_unref;
526 }
518 527
519 list_add(&fb->filp_head, &rdev->ddev->mode_config.fb_kernel_list); 528 list_add(&fb->filp_head, &rdev->ddev->mode_config.fb_kernel_list);
520 529
521 rfb = to_radeon_framebuffer(fb); 530 rfb = to_radeon_framebuffer(fb);
522 *rfb_p = rfb; 531 *rfb_p = rfb;
523 rdev->fbdev_rfb = rfb; 532 rdev->fbdev_rfb = rfb;
533 rdev->fbdev_robj = robj;
524 534
525 info = framebuffer_alloc(sizeof(struct radeon_fb_device), device); 535 info = framebuffer_alloc(sizeof(struct radeon_fb_device), device);
526 if (info == NULL) { 536 if (info == NULL) {
@@ -541,13 +551,13 @@ int radeonfb_create(struct radeon_device *rdev,
541 info->fix.xpanstep = 1; /* doing it in hw */ 551 info->fix.xpanstep = 1; /* doing it in hw */
542 info->fix.ypanstep = 1; /* doing it in hw */ 552 info->fix.ypanstep = 1; /* doing it in hw */
543 info->fix.ywrapstep = 0; 553 info->fix.ywrapstep = 0;
544 info->fix.accel = FB_ACCEL_I830; 554 info->fix.accel = FB_ACCEL_NONE;
545 info->fix.type_aux = 0; 555 info->fix.type_aux = 0;
546 info->flags = FBINFO_DEFAULT; 556 info->flags = FBINFO_DEFAULT;
547 info->fbops = &radeonfb_ops; 557 info->fbops = &radeonfb_ops;
548 info->fix.line_length = fb->pitch; 558 info->fix.line_length = fb->pitch;
549 info->screen_base = fbptr; 559 tmp = fb_gpuaddr - rdev->mc.vram_location;
550 info->fix.smem_start = (unsigned long)fbptr; 560 info->fix.smem_start = rdev->mc.aper_base + tmp;
551 info->fix.smem_len = size; 561 info->fix.smem_len = size;
552 info->screen_base = fbptr; 562 info->screen_base = fbptr;
553 info->screen_size = size; 563 info->screen_size = size;
@@ -562,8 +572,8 @@ int radeonfb_create(struct radeon_device *rdev,
562 info->var.width = -1; 572 info->var.width = -1;
563 info->var.xres = fb_width; 573 info->var.xres = fb_width;
564 info->var.yres = fb_height; 574 info->var.yres = fb_height;
565 info->fix.mmio_start = pci_resource_start(rdev->pdev, 2); 575 info->fix.mmio_start = 0;
566 info->fix.mmio_len = pci_resource_len(rdev->pdev, 2); 576 info->fix.mmio_len = 0;
567 info->pixmap.size = 64*1024; 577 info->pixmap.size = 64*1024;
568 info->pixmap.buf_align = 8; 578 info->pixmap.buf_align = 8;
569 info->pixmap.access_align = 32; 579 info->pixmap.access_align = 32;
@@ -644,7 +654,7 @@ out_unref:
644 if (robj) { 654 if (robj) {
645 radeon_object_kunmap(robj); 655 radeon_object_kunmap(robj);
646 } 656 }
647 if (ret) { 657 if (fb && ret) {
648 list_del(&fb->filp_head); 658 list_del(&fb->filp_head);
649 drm_gem_object_unreference(gobj); 659 drm_gem_object_unreference(gobj);
650 drm_framebuffer_cleanup(fb); 660 drm_framebuffer_cleanup(fb);
@@ -813,6 +823,7 @@ int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb)
813 robj = rfb->obj->driver_private; 823 robj = rfb->obj->driver_private;
814 unregister_framebuffer(info); 824 unregister_framebuffer(info);
815 radeon_object_kunmap(robj); 825 radeon_object_kunmap(robj);
826 radeon_object_unpin(robj);
816 framebuffer_release(info); 827 framebuffer_release(info);
817 } 828 }
818 829
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 983e8df5e000..bac0d06c52ac 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -223,7 +223,6 @@ int radeon_object_pin(struct radeon_object *robj, uint32_t domain,
223{ 223{
224 uint32_t flags; 224 uint32_t flags;
225 uint32_t tmp; 225 uint32_t tmp;
226 void *fbptr;
227 int r; 226 int r;
228 227
229 flags = radeon_object_flags_from_domain(domain); 228 flags = radeon_object_flags_from_domain(domain);
@@ -242,10 +241,6 @@ int radeon_object_pin(struct radeon_object *robj, uint32_t domain,
242 DRM_ERROR("radeon: failed to reserve object for pinning it.\n"); 241 DRM_ERROR("radeon: failed to reserve object for pinning it.\n");
243 return r; 242 return r;
244 } 243 }
245 if (robj->rdev->fbdev_robj == robj) {
246 mutex_lock(&robj->rdev->fbdev_info->lock);
247 radeon_object_kunmap(robj);
248 }
249 tmp = robj->tobj.mem.placement; 244 tmp = robj->tobj.mem.placement;
250 ttm_flag_masked(&tmp, flags, TTM_PL_MASK_MEM); 245 ttm_flag_masked(&tmp, flags, TTM_PL_MASK_MEM);
251 robj->tobj.proposed_placement = tmp | TTM_PL_FLAG_NO_EVICT | TTM_PL_MASK_CACHING; 246 robj->tobj.proposed_placement = tmp | TTM_PL_FLAG_NO_EVICT | TTM_PL_MASK_CACHING;
@@ -261,23 +256,12 @@ int radeon_object_pin(struct radeon_object *robj, uint32_t domain,
261 DRM_ERROR("radeon: failed to pin object.\n"); 256 DRM_ERROR("radeon: failed to pin object.\n");
262 } 257 }
263 radeon_object_unreserve(robj); 258 radeon_object_unreserve(robj);
264 if (robj->rdev->fbdev_robj == robj) {
265 if (!r) {
266 r = radeon_object_kmap(robj, &fbptr);
267 }
268 if (!r) {
269 robj->rdev->fbdev_info->screen_base = fbptr;
270 robj->rdev->fbdev_info->fix.smem_start = (unsigned long)fbptr;
271 }
272 mutex_unlock(&robj->rdev->fbdev_info->lock);
273 }
274 return r; 259 return r;
275} 260}
276 261
277void radeon_object_unpin(struct radeon_object *robj) 262void radeon_object_unpin(struct radeon_object *robj)
278{ 263{
279 uint32_t flags; 264 uint32_t flags;
280 void *fbptr;
281 int r; 265 int r;
282 266
283 spin_lock(&robj->tobj.lock); 267 spin_lock(&robj->tobj.lock);
@@ -297,10 +281,6 @@ void radeon_object_unpin(struct radeon_object *robj)
297 DRM_ERROR("radeon: failed to reserve object for unpinning it.\n"); 281 DRM_ERROR("radeon: failed to reserve object for unpinning it.\n");
298 return; 282 return;
299 } 283 }
300 if (robj->rdev->fbdev_robj == robj) {
301 mutex_lock(&robj->rdev->fbdev_info->lock);
302 radeon_object_kunmap(robj);
303 }
304 flags = robj->tobj.mem.placement; 284 flags = robj->tobj.mem.placement;
305 robj->tobj.proposed_placement = flags & ~TTM_PL_FLAG_NO_EVICT; 285 robj->tobj.proposed_placement = flags & ~TTM_PL_FLAG_NO_EVICT;
306 r = ttm_buffer_object_validate(&robj->tobj, 286 r = ttm_buffer_object_validate(&robj->tobj,
@@ -310,16 +290,6 @@ void radeon_object_unpin(struct radeon_object *robj)
310 DRM_ERROR("radeon: failed to unpin buffer.\n"); 290 DRM_ERROR("radeon: failed to unpin buffer.\n");
311 } 291 }
312 radeon_object_unreserve(robj); 292 radeon_object_unreserve(robj);
313 if (robj->rdev->fbdev_robj == robj) {
314 if (!r) {
315 r = radeon_object_kmap(robj, &fbptr);
316 }
317 if (!r) {
318 robj->rdev->fbdev_info->screen_base = fbptr;
319 robj->rdev->fbdev_info->fix.smem_start = (unsigned long)fbptr;
320 }
321 mutex_unlock(&robj->rdev->fbdev_info->lock);
322 }
323} 293}
324 294
325int radeon_object_wait(struct radeon_object *robj) 295int radeon_object_wait(struct radeon_object *robj)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 517c84559633..bdec583901eb 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -34,7 +34,6 @@
34#include <linux/highmem.h> 34#include <linux/highmem.h>
35#include <linux/wait.h> 35#include <linux/wait.h>
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/version.h>
38#include <linux/module.h> 37#include <linux/module.h>
39 38
40void ttm_bo_free_old_node(struct ttm_buffer_object *bo) 39void ttm_bo_free_old_node(struct ttm_buffer_object *bo)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 27b146c54fbc..40b75032ea47 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -32,7 +32,6 @@
32#include <ttm/ttm_bo_driver.h> 32#include <ttm/ttm_bo_driver.h>
33#include <ttm/ttm_placement.h> 33#include <ttm/ttm_placement.h>
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/version.h>
36#include <linux/rbtree.h> 35#include <linux/rbtree.h>
37#include <linux/module.h> 36#include <linux/module.h>
38#include <linux/uaccess.h> 37#include <linux/uaccess.h>
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 0331fa74cd3f..75dc8bd24592 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -28,7 +28,6 @@
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> 28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 */ 29 */
30 30
31#include <linux/version.h>
32#include <linux/vmalloc.h> 31#include <linux/vmalloc.h>
33#include <linux/sched.h> 32#include <linux/sched.h>
34#include <linux/highmem.h> 33#include <linux/highmem.h>
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 76c4bbe9dccb..3c1fcb7640ab 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -22,7 +22,6 @@
22#include <linux/list.h> 22#include <linux/list.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/smp_lock.h>
26#include <linux/spinlock.h> 25#include <linux/spinlock.h>
27#include <asm/unaligned.h> 26#include <asm/unaligned.h>
28#include <asm/byteorder.h> 27#include <asm/byteorder.h>
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index ad2b3431b725..7d3f15d32fdf 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -357,7 +357,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
357 { "AUX5 Fan", 39, 2, 60, 1, 0 }, 357 { "AUX5 Fan", 39, 2, 60, 1, 0 },
358 { NULL, 0, 0, 0, 0, 0 } } 358 { NULL, 0, 0, 0, 0, 0 } }
359 }, 359 },
360 { 0x0014, NULL /* Abit AB9 Pro, need DMI string */, { 360 { 0x0014, "AB9", /* + AB9 Pro */ {
361 { "CPU Core", 0, 0, 10, 1, 0 }, 361 { "CPU Core", 0, 0, 10, 1, 0 },
362 { "DDR", 1, 0, 10, 1, 0 }, 362 { "DDR", 1, 0, 10, 1, 0 },
363 { "DDR VTT", 2, 0, 10, 1, 0 }, 363 { "DDR VTT", 2, 0, 10, 1, 0 },
@@ -455,7 +455,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
455 { "AUX3 FAN", 37, 2, 60, 1, 0 }, 455 { "AUX3 FAN", 37, 2, 60, 1, 0 },
456 { NULL, 0, 0, 0, 0, 0 } } 456 { NULL, 0, 0, 0, 0, 0 } }
457 }, 457 },
458 { 0x0018, NULL /* Unknown, need DMI string */, { 458 { 0x0018, "AB9 QuadGT", {
459 { "CPU Core", 0, 0, 10, 1, 0 }, 459 { "CPU Core", 0, 0, 10, 1, 0 },
460 { "DDR2", 1, 0, 20, 1, 0 }, 460 { "DDR2", 1, 0, 20, 1, 0 },
461 { "DDR2 VTT", 2, 0, 10, 1, 0 }, 461 { "DDR2 VTT", 2, 0, 10, 1, 0 },
@@ -564,7 +564,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
564 { "AUX3 Fan", 36, 2, 60, 1, 0 }, 564 { "AUX3 Fan", 36, 2, 60, 1, 0 },
565 { NULL, 0, 0, 0, 0, 0 } } 565 { NULL, 0, 0, 0, 0, 0 } }
566 }, 566 },
567 { 0x001C, NULL /* Unknown, need DMI string */, { 567 { 0x001C, "IX38 QuadGT", {
568 { "CPU Core", 0, 0, 10, 1, 0 }, 568 { "CPU Core", 0, 0, 10, 1, 0 },
569 { "DDR2", 1, 0, 20, 1, 0 }, 569 { "DDR2", 1, 0, 20, 1, 0 },
570 { "DDR2 VTT", 2, 0, 10, 1, 0 }, 570 { "DDR2 VTT", 2, 0, 10, 1, 0 },
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index 86142a858238..58f66be61b1f 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -418,6 +418,7 @@ static ssize_t set_div(struct device *dev, struct device_attribute *devattr,
418 data->count = 3; 418 data->count = 3;
419 break; 419 break;
420 default: 420 default:
421 mutex_unlock(&data->update_lock);
421 dev_err(&client->dev, 422 dev_err(&client->dev,
422 "illegal value for fan divider (%d)\n", div); 423 "illegal value for fan divider (%d)\n", div);
423 return -EINVAL; 424 return -EINVAL;
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index 56cd6004da36..6290a259456e 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -257,7 +257,7 @@ static inline int sht15_update_single_val(struct sht15_data *data,
257 (data->flag == SHT15_READING_NOTHING), 257 (data->flag == SHT15_READING_NOTHING),
258 msecs_to_jiffies(timeout_msecs)); 258 msecs_to_jiffies(timeout_msecs));
259 if (ret == 0) {/* timeout occurred */ 259 if (ret == 0) {/* timeout occurred */
260 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));; 260 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
261 sht15_connection_reset(data); 261 sht15_connection_reset(data);
262 return -ETIME; 262 return -ETIME;
263 } 263 }
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index aa87b6a3bbef..8206442fbabd 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -328,6 +328,7 @@ config I2C_DAVINCI
328 328
329config I2C_DESIGNWARE 329config I2C_DESIGNWARE
330 tristate "Synopsys DesignWare" 330 tristate "Synopsys DesignWare"
331 depends on HAVE_CLK
331 help 332 help
332 If you say yes to this option, support will be included for the 333 If you say yes to this option, support will be included for the
333 Synopsys DesignWare I2C adapter. Only master mode is supported. 334 Synopsys DesignWare I2C adapter. Only master mode is supported.
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index e4476743f203..b1bc6e277d2a 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -85,10 +85,11 @@ static void dump_iic_regs(const char* header, struct ibm_iic_private* dev)
85{ 85{
86 volatile struct iic_regs __iomem *iic = dev->vaddr; 86 volatile struct iic_regs __iomem *iic = dev->vaddr;
87 printk(KERN_DEBUG "ibm-iic%d: %s\n", dev->idx, header); 87 printk(KERN_DEBUG "ibm-iic%d: %s\n", dev->idx, header);
88 printk(KERN_DEBUG " cntl = 0x%02x, mdcntl = 0x%02x\n" 88 printk(KERN_DEBUG
89 KERN_DEBUG " sts = 0x%02x, extsts = 0x%02x\n" 89 " cntl = 0x%02x, mdcntl = 0x%02x\n"
90 KERN_DEBUG " clkdiv = 0x%02x, xfrcnt = 0x%02x\n" 90 " sts = 0x%02x, extsts = 0x%02x\n"
91 KERN_DEBUG " xtcntlss = 0x%02x, directcntl = 0x%02x\n", 91 " clkdiv = 0x%02x, xfrcnt = 0x%02x\n"
92 " xtcntlss = 0x%02x, directcntl = 0x%02x\n",
92 in_8(&iic->cntl), in_8(&iic->mdcntl), in_8(&iic->sts), 93 in_8(&iic->cntl), in_8(&iic->mdcntl), in_8(&iic->sts),
93 in_8(&iic->extsts), in_8(&iic->clkdiv), in_8(&iic->xfrcnt), 94 in_8(&iic->extsts), in_8(&iic->clkdiv), in_8(&iic->xfrcnt),
94 in_8(&iic->xtcntlss), in_8(&iic->directcntl)); 95 in_8(&iic->xtcntlss), in_8(&iic->directcntl));
diff --git a/drivers/ide/cs5520.c b/drivers/ide/cs5520.c
index bd066bb9d611..09f98ed0731f 100644
--- a/drivers/ide/cs5520.c
+++ b/drivers/ide/cs5520.c
@@ -135,6 +135,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
135 135
136 ide_pci_setup_ports(dev, d, &hw[0], &hws[0]); 136 ide_pci_setup_ports(dev, d, &hw[0], &hws[0]);
137 hw[0].irq = 14; 137 hw[0].irq = 14;
138 hw[1].irq = 15;
138 139
139 return ide_host_add(d, hws, 2, NULL); 140 return ide_host_add(d, hws, 2, NULL);
140} 141}
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index 77f79d26b264..c509c9916464 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -92,6 +92,11 @@ int ide_acpi_init(void)
92 return 0; 92 return 0;
93} 93}
94 94
95bool ide_port_acpi(ide_hwif_t *hwif)
96{
97 return ide_noacpi == 0 && hwif->acpidata;
98}
99
95/** 100/**
96 * ide_get_dev_handle - finds acpi_handle and PCI device.function 101 * ide_get_dev_handle - finds acpi_handle and PCI device.function
97 * @dev: device to locate 102 * @dev: device to locate
@@ -352,9 +357,6 @@ int ide_acpi_exec_tfs(ide_drive_t *drive)
352 unsigned long gtf_address; 357 unsigned long gtf_address;
353 unsigned long obj_loc; 358 unsigned long obj_loc;
354 359
355 if (ide_noacpi)
356 return 0;
357
358 DEBPRINT("call get_GTF, drive=%s port=%d\n", drive->name, drive->dn); 360 DEBPRINT("call get_GTF, drive=%s port=%d\n", drive->name, drive->dn);
359 361
360 ret = do_drive_get_GTF(drive, &gtf_length, &gtf_address, &obj_loc); 362 ret = do_drive_get_GTF(drive, &gtf_length, &gtf_address, &obj_loc);
@@ -389,16 +391,6 @@ void ide_acpi_get_timing(ide_hwif_t *hwif)
389 struct acpi_buffer output; 391 struct acpi_buffer output;
390 union acpi_object *out_obj; 392 union acpi_object *out_obj;
391 393
392 if (ide_noacpi)
393 return;
394
395 DEBPRINT("ENTER:\n");
396
397 if (!hwif->acpidata) {
398 DEBPRINT("no ACPI data for %s\n", hwif->name);
399 return;
400 }
401
402 /* Setting up output buffer for _GTM */ 394 /* Setting up output buffer for _GTM */
403 output.length = ACPI_ALLOCATE_BUFFER; 395 output.length = ACPI_ALLOCATE_BUFFER;
404 output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ 396 output.pointer = NULL; /* ACPI-CA sets this; save/free it later */
@@ -479,16 +471,6 @@ void ide_acpi_push_timing(ide_hwif_t *hwif)
479 struct ide_acpi_drive_link *master = &hwif->acpidata->master; 471 struct ide_acpi_drive_link *master = &hwif->acpidata->master;
480 struct ide_acpi_drive_link *slave = &hwif->acpidata->slave; 472 struct ide_acpi_drive_link *slave = &hwif->acpidata->slave;
481 473
482 if (ide_noacpi)
483 return;
484
485 DEBPRINT("ENTER:\n");
486
487 if (!hwif->acpidata) {
488 DEBPRINT("no ACPI data for %s\n", hwif->name);
489 return;
490 }
491
492 /* Give the GTM buffer + drive Identify data to the channel via the 474 /* Give the GTM buffer + drive Identify data to the channel via the
493 * _STM method: */ 475 * _STM method: */
494 /* setup input parameters buffer for _STM */ 476 /* setup input parameters buffer for _STM */
@@ -527,16 +509,11 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
527 ide_drive_t *drive; 509 ide_drive_t *drive;
528 int i; 510 int i;
529 511
530 if (ide_noacpi || ide_noacpi_psx) 512 if (ide_noacpi_psx)
531 return; 513 return;
532 514
533 DEBPRINT("ENTER:\n"); 515 DEBPRINT("ENTER:\n");
534 516
535 if (!hwif->acpidata) {
536 DEBPRINT("no ACPI data for %s\n", hwif->name);
537 return;
538 }
539
540 /* channel first and then drives for power on and verse versa for power off */ 517 /* channel first and then drives for power on and verse versa for power off */
541 if (on) 518 if (on)
542 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); 519 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
@@ -616,7 +593,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
616 drive->name, err); 593 drive->name, err);
617 } 594 }
618 595
619 if (!ide_acpionboot) { 596 if (ide_noacpi || ide_acpionboot == 0) {
620 DEBPRINT("ACPI methods disabled on boot\n"); 597 DEBPRINT("ACPI methods disabled on boot\n");
621 return; 598 return;
622 } 599 }
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 4a19686fcfe9..6a9a769bffc1 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -592,9 +592,19 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
592 } 592 }
593 } else if (!blk_pc_request(rq)) { 593 } else if (!blk_pc_request(rq)) {
594 ide_cd_request_sense_fixup(drive, cmd); 594 ide_cd_request_sense_fixup(drive, cmd);
595 /* complain if we still have data left to transfer */ 595
596 uptodate = cmd->nleft ? 0 : 1; 596 uptodate = cmd->nleft ? 0 : 1;
597 if (uptodate == 0) 597
598 /*
599 * suck out the remaining bytes from the drive in an
600 * attempt to complete the data xfer. (see BZ#13399)
601 */
602 if (!(stat & ATA_ERR) && !uptodate && thislen) {
603 ide_pio_bytes(drive, cmd, write, thislen);
604 uptodate = cmd->nleft ? 0 : 1;
605 }
606
607 if (!uptodate)
598 rq->cmd_flags |= REQ_FAILED; 608 rq->cmd_flags |= REQ_FAILED;
599 } 609 }
600 goto out_end; 610 goto out_end;
@@ -876,9 +886,12 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
876 return stat; 886 return stat;
877 887
878 /* 888 /*
879 * Sanity check the given block size 889 * Sanity check the given block size, in so far as making
890 * sure the sectors_per_frame we give to the caller won't
891 * end up being bogus.
880 */ 892 */
881 blocklen = be32_to_cpu(capbuf.blocklen); 893 blocklen = be32_to_cpu(capbuf.blocklen);
894 blocklen = (blocklen >> SECTOR_BITS) << SECTOR_BITS;
882 switch (blocklen) { 895 switch (blocklen) {
883 case 512: 896 case 512:
884 case 1024: 897 case 1024:
@@ -886,10 +899,9 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
886 case 4096: 899 case 4096:
887 break; 900 break;
888 default: 901 default:
889 printk(KERN_ERR PFX "%s: weird block size %u\n", 902 printk_once(KERN_ERR PFX "%s: weird block size %u; "
903 "setting default block size to 2048\n",
890 drive->name, blocklen); 904 drive->name, blocklen);
891 printk(KERN_ERR PFX "%s: default to 2kb block size\n",
892 drive->name);
893 blocklen = 2048; 905 blocklen = 2048;
894 break; 906 break;
895 } 907 }
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c
index 5bf958e5b1d5..1099bf7cf968 100644
--- a/drivers/ide/ide-devsets.c
+++ b/drivers/ide/ide-devsets.c
@@ -183,6 +183,6 @@ ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq)
183 err = setfunc(drive, *(int *)&rq->cmd[1]); 183 err = setfunc(drive, *(int *)&rq->cmd[1]);
184 if (err) 184 if (err)
185 rq->errors = err; 185 rq->errors = err;
186 ide_complete_rq(drive, err, ide_rq_bytes(rq)); 186 ide_complete_rq(drive, err, blk_rq_bytes(rq));
187 return ide_stopped; 187 return ide_stopped;
188} 188}
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 219e6fb78dc6..ee58c88dee5a 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -361,9 +361,6 @@ static int ide_tune_dma(ide_drive_t *drive)
361 if (__ide_dma_bad_drive(drive)) 361 if (__ide_dma_bad_drive(drive))
362 return 0; 362 return 0;
363 363
364 if (ide_id_dma_bug(drive))
365 return 0;
366
367 if (hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA) 364 if (hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA)
368 return config_drive_for_dma(drive); 365 return config_drive_for_dma(drive);
369 366
@@ -394,24 +391,6 @@ static int ide_dma_check(ide_drive_t *drive)
394 return -1; 391 return -1;
395} 392}
396 393
397int ide_id_dma_bug(ide_drive_t *drive)
398{
399 u16 *id = drive->id;
400
401 if (id[ATA_ID_FIELD_VALID] & 4) {
402 if ((id[ATA_ID_UDMA_MODES] >> 8) &&
403 (id[ATA_ID_MWDMA_MODES] >> 8))
404 goto err_out;
405 } else if ((id[ATA_ID_MWDMA_MODES] >> 8) &&
406 (id[ATA_ID_SWDMA_MODES] >> 8))
407 goto err_out;
408
409 return 0;
410err_out:
411 printk(KERN_ERR "%s: bad DMA info in identify block\n", drive->name);
412 return 1;
413}
414
415int ide_set_dma(ide_drive_t *drive) 394int ide_set_dma(ide_drive_t *drive)
416{ 395{
417 int rc; 396 int rc;
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c
index 2b9141979613..e9abf2c3c335 100644
--- a/drivers/ide/ide-eh.c
+++ b/drivers/ide/ide-eh.c
@@ -149,7 +149,7 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
149 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) { 149 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) {
150 if (err <= 0 && rq->errors == 0) 150 if (err <= 0 && rq->errors == 0)
151 rq->errors = -EIO; 151 rq->errors = -EIO;
152 ide_complete_rq(drive, err ? err : 0, ide_rq_bytes(rq)); 152 ide_complete_rq(drive, err ? err : 0, blk_rq_bytes(rq));
153 } 153 }
154} 154}
155 155
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 8b3f204f7d73..fefbdfc8db06 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -293,7 +293,7 @@ out_end:
293 drive->failed_pc = NULL; 293 drive->failed_pc = NULL;
294 if (blk_fs_request(rq) == 0 && rq->errors == 0) 294 if (blk_fs_request(rq) == 0 && rq->errors == 0)
295 rq->errors = -EIO; 295 rq->errors = -EIO;
296 ide_complete_rq(drive, -EIO, ide_rq_bytes(rq)); 296 ide_complete_rq(drive, -EIO, blk_rq_bytes(rq));
297 return ide_stopped; 297 return ide_stopped;
298} 298}
299 299
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 1059f809b809..db96138fefcd 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -112,16 +112,6 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
112 } 112 }
113} 113}
114 114
115/* obsolete, blk_rq_bytes() should be used instead */
116unsigned int ide_rq_bytes(struct request *rq)
117{
118 if (blk_pc_request(rq))
119 return blk_rq_bytes(rq);
120 else
121 return blk_rq_cur_sectors(rq) << 9;
122}
123EXPORT_SYMBOL_GPL(ide_rq_bytes);
124
125int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes) 115int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes)
126{ 116{
127 ide_hwif_t *hwif = drive->hwif; 117 ide_hwif_t *hwif = drive->hwif;
@@ -152,14 +142,14 @@ void ide_kill_rq(ide_drive_t *drive, struct request *rq)
152 142
153 if ((media == ide_floppy || media == ide_tape) && drv_req) { 143 if ((media == ide_floppy || media == ide_tape) && drv_req) {
154 rq->errors = 0; 144 rq->errors = 0;
155 ide_complete_rq(drive, 0, blk_rq_bytes(rq));
156 } else { 145 } else {
157 if (media == ide_tape) 146 if (media == ide_tape)
158 rq->errors = IDE_DRV_ERROR_GENERAL; 147 rq->errors = IDE_DRV_ERROR_GENERAL;
159 else if (blk_fs_request(rq) == 0 && rq->errors == 0) 148 else if (blk_fs_request(rq) == 0 && rq->errors == 0)
160 rq->errors = -EIO; 149 rq->errors = -EIO;
161 ide_complete_rq(drive, -EIO, ide_rq_bytes(rq));
162 } 150 }
151
152 ide_complete_rq(drive, -EIO, blk_rq_bytes(rq));
163} 153}
164 154
165static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) 155static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index 82f252c3ee6e..e246d3d3fbcc 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -64,7 +64,8 @@ static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd,
64 goto out; 64 goto out;
65 } 65 }
66 66
67 id = kmalloc(size, GFP_KERNEL); 67 /* ata_id_to_hd_driveid() relies on 'id' to be fully allocated. */
68 id = kmalloc(ATA_ID_WORDS * 2, GFP_KERNEL);
68 if (id == NULL) { 69 if (id == NULL) {
69 rc = -ENOMEM; 70 rc = -ENOMEM;
70 goto out; 71 goto out;
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index fa047150a1c6..2892b242bbe1 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -210,6 +210,7 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list);
210 */ 210 */
211static const struct drive_list_entry ivb_list[] = { 211static const struct drive_list_entry ivb_list[] = {
212 { "QUANTUM FIREBALLlct10 05" , "A03.0900" }, 212 { "QUANTUM FIREBALLlct10 05" , "A03.0900" },
213 { "QUANTUM FIREBALLlct20 30" , "APL.0900" },
213 { "TSSTcorp CDDVDW SH-S202J" , "SB00" }, 214 { "TSSTcorp CDDVDW SH-S202J" , "SB00" },
214 { "TSSTcorp CDDVDW SH-S202J" , "SB01" }, 215 { "TSSTcorp CDDVDW SH-S202J" , "SB01" },
215 { "TSSTcorp CDDVDW SH-S202N" , "SB00" }, 216 { "TSSTcorp CDDVDW SH-S202N" , "SB00" },
@@ -329,9 +330,6 @@ int ide_driveid_update(ide_drive_t *drive)
329 330
330 kfree(id); 331 kfree(id);
331 332
332 if ((drive->dev_flags & IDE_DFLAG_USING_DMA) && ide_id_dma_bug(drive))
333 ide_dma_off(drive);
334
335 return 1; 333 return 1;
336out_err: 334out_err:
337 if (rc == 2) 335 if (rc == 2)
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index c14ca144cffe..ad7be2669dcb 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -10,9 +10,11 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
10 struct request_pm_state rqpm; 10 struct request_pm_state rqpm;
11 int ret; 11 int ret;
12 12
13 /* call ACPI _GTM only once */ 13 if (ide_port_acpi(hwif)) {
14 if ((drive->dn & 1) == 0 || pair == NULL) 14 /* call ACPI _GTM only once */
15 ide_acpi_get_timing(hwif); 15 if ((drive->dn & 1) == 0 || pair == NULL)
16 ide_acpi_get_timing(hwif);
17 }
16 18
17 memset(&rqpm, 0, sizeof(rqpm)); 19 memset(&rqpm, 0, sizeof(rqpm));
18 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 20 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
@@ -26,9 +28,11 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
26 ret = blk_execute_rq(drive->queue, NULL, rq, 0); 28 ret = blk_execute_rq(drive->queue, NULL, rq, 0);
27 blk_put_request(rq); 29 blk_put_request(rq);
28 30
29 /* call ACPI _PS3 only after both devices are suspended */ 31 if (ret == 0 && ide_port_acpi(hwif)) {
30 if (ret == 0 && ((drive->dn & 1) || pair == NULL)) 32 /* call ACPI _PS3 only after both devices are suspended */
31 ide_acpi_set_state(hwif, 0); 33 if ((drive->dn & 1) || pair == NULL)
34 ide_acpi_set_state(hwif, 0);
35 }
32 36
33 return ret; 37 return ret;
34} 38}
@@ -42,13 +46,15 @@ int generic_ide_resume(struct device *dev)
42 struct request_pm_state rqpm; 46 struct request_pm_state rqpm;
43 int err; 47 int err;
44 48
45 /* call ACPI _PS0 / _STM only once */ 49 if (ide_port_acpi(hwif)) {
46 if ((drive->dn & 1) == 0 || pair == NULL) { 50 /* call ACPI _PS0 / _STM only once */
47 ide_acpi_set_state(hwif, 1); 51 if ((drive->dn & 1) == 0 || pair == NULL) {
48 ide_acpi_push_timing(hwif); 52 ide_acpi_set_state(hwif, 1);
49 } 53 ide_acpi_push_timing(hwif);
54 }
50 55
51 ide_acpi_exec_tfs(drive); 56 ide_acpi_exec_tfs(drive);
57 }
52 58
53 memset(&rqpm, 0, sizeof(rqpm)); 59 memset(&rqpm, 0, sizeof(rqpm));
54 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 60 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 51af4eea0d36..1bb106f6221a 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -818,6 +818,24 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
818 return j; 818 return j;
819} 819}
820 820
821static void ide_host_enable_irqs(struct ide_host *host)
822{
823 ide_hwif_t *hwif;
824 int i;
825
826 ide_host_for_each_port(i, hwif, host) {
827 if (hwif == NULL)
828 continue;
829
830 /* clear any pending IRQs */
831 hwif->tp_ops->read_status(hwif);
832
833 /* unmask IRQs */
834 if (hwif->io_ports.ctl_addr)
835 hwif->tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS);
836 }
837}
838
821/* 839/*
822 * This routine sets up the IRQ for an IDE interface. 840 * This routine sets up the IRQ for an IDE interface.
823 */ 841 */
@@ -831,9 +849,6 @@ static int init_irq (ide_hwif_t *hwif)
831 if (irq_handler == NULL) 849 if (irq_handler == NULL)
832 irq_handler = ide_intr; 850 irq_handler = ide_intr;
833 851
834 if (io_ports->ctl_addr)
835 hwif->tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS);
836
837 if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) 852 if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif))
838 goto out_up; 853 goto out_up;
839 854
@@ -1404,6 +1419,8 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1404 ide_port_tune_devices(hwif); 1419 ide_port_tune_devices(hwif);
1405 } 1420 }
1406 1421
1422 ide_host_enable_irqs(host);
1423
1407 ide_host_for_each_port(i, hwif, host) { 1424 ide_host_for_each_port(i, hwif, host) {
1408 if (hwif == NULL) 1425 if (hwif == NULL)
1409 continue; 1426 continue;
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 83b734aec923..52b25f8b111d 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -880,6 +880,7 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
880 } 880 }
881 881
882 shost->hostdata[0] = (unsigned long)lu; 882 shost->hostdata[0] = (unsigned long)lu;
883 shost->max_cmd_len = SBP2_MAX_CDB_SIZE;
883 884
884 if (!scsi_add_host(shost, &ud->device)) { 885 if (!scsi_add_host(shost, &ud->device)) {
885 lu->shost = shost; 886 lu->shost = shost;
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index c5036f1cc5b0..64a3a66a8a39 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -25,6 +25,12 @@
25#define SBP2_DEVICE_NAME "sbp2" 25#define SBP2_DEVICE_NAME "sbp2"
26 26
27/* 27/*
28 * There is no transport protocol limit to the CDB length, but we implement
29 * a fixed length only. 16 bytes is enough for disks larger than 2 TB.
30 */
31#define SBP2_MAX_CDB_SIZE 16
32
33/*
28 * SBP-2 specific definitions 34 * SBP-2 specific definitions
29 */ 35 */
30 36
@@ -51,7 +57,7 @@ struct sbp2_command_orb {
51 u32 data_descriptor_hi; 57 u32 data_descriptor_hi;
52 u32 data_descriptor_lo; 58 u32 data_descriptor_lo;
53 u32 misc; 59 u32 misc;
54 u8 cdb[12]; 60 u8 cdb[SBP2_MAX_CDB_SIZE];
55} __attribute__((packed)); 61} __attribute__((packed));
56 62
57#define SBP2_LOGIN_REQUEST 0x0 63#define SBP2_LOGIN_REQUEST 0x0
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 9d8f796c6745..a6b989a9dc07 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -12,6 +12,42 @@ menuconfig INPUT_KEYBOARD
12 12
13if INPUT_KEYBOARD 13if INPUT_KEYBOARD
14 14
15config KEYBOARD_AAED2000
16 tristate "AAED-2000 keyboard"
17 depends on MACH_AAED2000
18 select INPUT_POLLDEV
19 default y
20 help
21 Say Y here to enable the keyboard on the Agilent AAED-2000
22 development board.
23
24 To compile this driver as a module, choose M here: the
25 module will be called aaed2000_kbd.
26
27config KEYBOARD_AMIGA
28 tristate "Amiga keyboard"
29 depends on AMIGA
30 help
31 Say Y here if you are running Linux on any AMIGA and have a keyboard
32 attached.
33
34 To compile this driver as a module, choose M here: the
35 module will be called amikbd.
36
37config ATARI_KBD_CORE
38 bool
39
40config KEYBOARD_ATARI
41 tristate "Atari keyboard"
42 depends on ATARI
43 select ATARI_KBD_CORE
44 help
45 Say Y here if you are running Linux on any Atari and have a keyboard
46 attached.
47
48 To compile this driver as a module, choose M here: the
49 module will be called atakbd.
50
15config KEYBOARD_ATKBD 51config KEYBOARD_ATKBD
16 tristate "AT keyboard" if EMBEDDED || !X86 52 tristate "AT keyboard" if EMBEDDED || !X86
17 default y 53 default y
@@ -68,69 +104,14 @@ config KEYBOARD_ATKBD_RDI_KEYCODES
68 right-hand column will be interpreted as the key shown in the 104 right-hand column will be interpreted as the key shown in the
69 left-hand column. 105 left-hand column.
70 106
71config KEYBOARD_SUNKBD 107config KEYBOARD_BFIN
72 tristate "Sun Type 4 and Type 5 keyboard" 108 tristate "Blackfin BF54x keypad support"
73 select SERIO 109 depends on (BF54x && !BF544)
74 help
75 Say Y here if you want to use a Sun Type 4 or Type 5 keyboard,
76 connected either to the Sun keyboard connector or to an serial
77 (RS-232) port via a simple adapter.
78
79 To compile this driver as a module, choose M here: the
80 module will be called sunkbd.
81
82config KEYBOARD_LKKBD
83 tristate "DECstation/VAXstation LK201/LK401 keyboard"
84 select SERIO
85 help
86 Say Y here if you want to use a LK201 or LK401 style serial
87 keyboard. This keyboard is also useable on PCs if you attach
88 it with the inputattach program. The connector pinout is
89 described within lkkbd.c.
90
91 To compile this driver as a module, choose M here: the
92 module will be called lkkbd.
93
94config KEYBOARD_LOCOMO
95 tristate "LoCoMo Keyboard Support"
96 depends on SHARP_LOCOMO && INPUT_KEYBOARD
97 help
98 Say Y here if you are running Linux on a Sharp Zaurus Collie or Poodle based PDA
99
100 To compile this driver as a module, choose M here: the
101 module will be called locomokbd.
102
103config KEYBOARD_XTKBD
104 tristate "XT keyboard"
105 select SERIO
106 help
107 Say Y here if you want to use the old IBM PC/XT keyboard (or
108 compatible) on your system. This is only possible with a
109 parallel port keyboard adapter, you cannot connect it to the
110 keyboard port on a PC that runs Linux.
111
112 To compile this driver as a module, choose M here: the
113 module will be called xtkbd.
114
115config KEYBOARD_NEWTON
116 tristate "Newton keyboard"
117 select SERIO
118 help
119 Say Y here if you have a Newton keyboard on a serial port.
120
121 To compile this driver as a module, choose M here: the
122 module will be called newtonkbd.
123
124config KEYBOARD_STOWAWAY
125 tristate "Stowaway keyboard"
126 select SERIO
127 help 110 help
128 Say Y here if you have a Stowaway keyboard on a serial port. 111 Say Y here if you want to use the BF54x keypad.
129 Stowaway compatible keyboards like Dicota Input-PDA keyboard
130 are also supported by this driver.
131 112
132 To compile this driver as a module, choose M here: the 113 To compile this driver as a module, choose M here: the
133 module will be called stowaway. 114 module will be called bf54x-keys.
134 115
135config KEYBOARD_CORGI 116config KEYBOARD_CORGI
136 tristate "Corgi keyboard" 117 tristate "Corgi keyboard"
@@ -143,61 +124,50 @@ config KEYBOARD_CORGI
143 To compile this driver as a module, choose M here: the 124 To compile this driver as a module, choose M here: the
144 module will be called corgikbd. 125 module will be called corgikbd.
145 126
146config KEYBOARD_SPITZ 127config KEYBOARD_LKKBD
147 tristate "Spitz keyboard" 128 tristate "DECstation/VAXstation LK201/LK401 keyboard"
148 depends on PXA_SHARPSL 129 select SERIO
149 default y
150 help 130 help
151 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000, 131 Say Y here if you want to use a LK201 or LK401 style serial
152 SL-C3000 and Sl-C3100 series of PDAs. 132 keyboard. This keyboard is also useable on PCs if you attach
133 it with the inputattach program. The connector pinout is
134 described within lkkbd.c.
153 135
154 To compile this driver as a module, choose M here: the 136 To compile this driver as a module, choose M here: the
155 module will be called spitzkbd. 137 module will be called lkkbd.
156 138
157config KEYBOARD_TOSA 139config KEYBOARD_EP93XX
158 tristate "Tosa keyboard" 140 tristate "EP93xx Matrix Keypad support"
159 depends on MACH_TOSA 141 depends on ARCH_EP93XX
160 default y
161 help 142 help
162 Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa) 143 Say Y here to enable the matrix keypad on the Cirrus EP93XX.
163 144
164 To compile this driver as a module, choose M here: the 145 To compile this driver as a module, choose M here: the
165 module will be called tosakbd. 146 module will be called ep93xx_keypad.
166 147
167config KEYBOARD_TOSA_USE_EXT_KEYCODES 148config KEYBOARD_GPIO
168 bool "Tosa keyboard: use extended keycodes" 149 tristate "GPIO Buttons"
169 depends on KEYBOARD_TOSA 150 depends on GENERIC_GPIO
170 default n
171 help 151 help
172 Say Y here to enable the tosa keyboard driver to generate extended 152 This driver implements support for buttons connected
173 (>= 127) keycodes. Be aware, that they can't be correctly interpreted 153 to GPIO pins of various CPUs (and some other chips).
174 by either console keyboard driver or by Kdrive keybd driver.
175
176 Say Y only if you know, what you are doing!
177 154
178config KEYBOARD_AMIGA 155 Say Y here if your device has buttons connected
179 tristate "Amiga keyboard" 156 directly to such GPIO pins. Your board-specific
180 depends on AMIGA 157 setup logic must also provide a platform device,
181 help 158 with configuration data saying which GPIOs are used.
182 Say Y here if you are running Linux on any AMIGA and have a keyboard
183 attached.
184 159
185 To compile this driver as a module, choose M here: the 160 To compile this driver as a module, choose M here: the
186 module will be called amikbd. 161 module will be called gpio_keys.
187 162
188config ATARI_KBD_CORE 163config KEYBOARD_MATRIX
189 bool 164 tristate "GPIO driven matrix keypad support"
190 165 depends on GENERIC_GPIO
191config KEYBOARD_ATARI
192 tristate "Atari keyboard"
193 depends on ATARI
194 select ATARI_KBD_CORE
195 help 166 help
196 Say Y here if you are running Linux on any Atari and have a keyboard 167 Enable support for GPIO driven matrix keypad.
197 attached.
198 168
199 To compile this driver as a module, choose M here: the 169 To compile this driver as a module, choose M here: the
200 module will be called atakbd. 170 module will be called matrix_keypad.
201 171
202config KEYBOARD_HIL_OLD 172config KEYBOARD_HIL_OLD
203 tristate "HP HIL keyboard support (simple driver)" 173 tristate "HP HIL keyboard support (simple driver)"
@@ -261,20 +231,39 @@ config KEYBOARD_LM8323
261 To compile this driver as a module, choose M here: the 231 To compile this driver as a module, choose M here: the
262 module will be called lm8323. 232 module will be called lm8323.
263 233
264config KEYBOARD_OMAP 234config KEYBOARD_LOCOMO
265 tristate "TI OMAP keypad support" 235 tristate "LoCoMo Keyboard Support"
266 depends on (ARCH_OMAP1 || ARCH_OMAP2) 236 depends on SHARP_LOCOMO
267 help 237 help
268 Say Y here if you want to use the OMAP keypad. 238 Say Y here if you are running Linux on a Sharp Zaurus Collie or Poodle based PDA
269 239
270 To compile this driver as a module, choose M here: the 240 To compile this driver as a module, choose M here: the
271 module will be called omap-keypad. 241 module will be called locomokbd.
242
243config KEYBOARD_MAPLE
244 tristate "Maple bus keyboard"
245 depends on SH_DREAMCAST && MAPLE
246 help
247 Say Y here if you have a Dreamcast console running Linux and have
248 a keyboard attached to its Maple bus.
249
250 To compile this driver as a module, choose M here: the
251 module will be called maple_keyb.
252
253config KEYBOARD_NEWTON
254 tristate "Newton keyboard"
255 select SERIO
256 help
257 Say Y here if you have a Newton keyboard on a serial port.
258
259 To compile this driver as a module, choose M here: the
260 module will be called newtonkbd.
272 261
273config KEYBOARD_PXA27x 262config KEYBOARD_PXA27x
274 tristate "PXA27x/PXA3xx keypad support" 263 tristate "PXA27x/PXA3xx keypad support"
275 depends on PXA27x || PXA3xx 264 depends on PXA27x || PXA3xx
276 help 265 help
277 Enable support for PXA27x/PXA3xx keypad controller 266 Enable support for PXA27x/PXA3xx keypad controller.
278 267
279 To compile this driver as a module, choose M here: the 268 To compile this driver as a module, choose M here: the
280 module will be called pxa27x_keypad. 269 module will be called pxa27x_keypad.
@@ -288,51 +277,38 @@ config KEYBOARD_PXA930_ROTARY
288 To compile this driver as a module, choose M here: the 277 To compile this driver as a module, choose M here: the
289 module will be called pxa930_rotary. 278 module will be called pxa930_rotary.
290 279
291config KEYBOARD_AAED2000 280config KEYBOARD_SPITZ
292 tristate "AAED-2000 keyboard" 281 tristate "Spitz keyboard"
293 depends on MACH_AAED2000 282 depends on PXA_SHARPSL
294 select INPUT_POLLDEV
295 default y 283 default y
296 help 284 help
297 Say Y here to enable the keyboard on the Agilent AAED-2000 285 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000,
298 development board. 286 SL-C3000 and Sl-C3100 series of PDAs.
299
300 To compile this driver as a module, choose M here: the
301 module will be called aaed2000_kbd.
302
303config KEYBOARD_GPIO
304 tristate "GPIO Buttons"
305 depends on GENERIC_GPIO
306 help
307 This driver implements support for buttons connected
308 to GPIO pins of various CPUs (and some other chips).
309
310 Say Y here if your device has buttons connected
311 directly to such GPIO pins. Your board-specific
312 setup logic must also provide a platform device,
313 with configuration data saying which GPIOs are used.
314 287
315 To compile this driver as a module, choose M here: the 288 To compile this driver as a module, choose M here: the
316 module will be called gpio-keys. 289 module will be called spitzkbd.
317 290
318config KEYBOARD_MAPLE 291config KEYBOARD_STOWAWAY
319 tristate "Maple bus keyboard" 292 tristate "Stowaway keyboard"
320 depends on SH_DREAMCAST && MAPLE 293 select SERIO
321 help 294 help
322 Say Y here if you have a Dreamcast console running Linux and have 295 Say Y here if you have a Stowaway keyboard on a serial port.
323 a keyboard attached to its Maple bus. 296 Stowaway compatible keyboards like Dicota Input-PDA keyboard
297 are also supported by this driver.
324 298
325 To compile this driver as a module, choose M here: the 299 To compile this driver as a module, choose M here: the
326 module will be called maple_keyb. 300 module will be called stowaway.
327 301
328config KEYBOARD_BFIN 302config KEYBOARD_SUNKBD
329 tristate "Blackfin BF54x keypad support" 303 tristate "Sun Type 4 and Type 5 keyboard"
330 depends on (BF54x && !BF544) 304 select SERIO
331 help 305 help
332 Say Y here if you want to use the BF54x keypad. 306 Say Y here if you want to use a Sun Type 4 or Type 5 keyboard,
307 connected either to the Sun keyboard connector or to an serial
308 (RS-232) port via a simple adapter.
333 309
334 To compile this driver as a module, choose M here: the 310 To compile this driver as a module, choose M here: the
335 module will be called bf54x-keys. 311 module will be called sunkbd.
336 312
337config KEYBOARD_SH_KEYSC 313config KEYBOARD_SH_KEYSC
338 tristate "SuperH KEYSC keypad support" 314 tristate "SuperH KEYSC keypad support"
@@ -344,13 +320,45 @@ config KEYBOARD_SH_KEYSC
344 To compile this driver as a module, choose M here: the 320 To compile this driver as a module, choose M here: the
345 module will be called sh_keysc. 321 module will be called sh_keysc.
346 322
347config KEYBOARD_EP93XX 323config KEYBOARD_OMAP
348 tristate "EP93xx Matrix Keypad support" 324 tristate "TI OMAP keypad support"
349 depends on ARCH_EP93XX 325 depends on (ARCH_OMAP1 || ARCH_OMAP2)
350 help 326 help
351 Say Y here to enable the matrix keypad on the Cirrus EP93XX. 327 Say Y here if you want to use the OMAP keypad.
352 328
353 To compile this driver as a module, choose M here: the 329 To compile this driver as a module, choose M here: the
354 module will be called ep93xx_keypad. 330 module will be called omap-keypad.
331
332config KEYBOARD_TOSA
333 tristate "Tosa keyboard"
334 depends on MACH_TOSA
335 default y
336 help
337 Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
338
339 To compile this driver as a module, choose M here: the
340 module will be called tosakbd.
341
342config KEYBOARD_TOSA_USE_EXT_KEYCODES
343 bool "Tosa keyboard: use extended keycodes"
344 depends on KEYBOARD_TOSA
345 help
346 Say Y here to enable the tosa keyboard driver to generate extended
347 (>= 127) keycodes. Be aware, that they can't be correctly interpreted
348 by either console keyboard driver or by Kdrive keybd driver.
349
350 Say Y only if you know, what you are doing!
351
352config KEYBOARD_XTKBD
353 tristate "XT keyboard"
354 select SERIO
355 help
356 Say Y here if you want to use the old IBM PC/XT keyboard (or
357 compatible) on your system. This is only possible with a
358 parallel port keyboard adapter, you cannot connect it to the
359 keyboard port on a PC that runs Linux.
360
361 To compile this driver as a module, choose M here: the
362 module will be called xtkbd.
355 363
356endif 364endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 156b647a259b..b5b5eae9724f 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -4,29 +4,30 @@
4 4
5# Each configuration option enables a list of files. 5# Each configuration option enables a list of files.
6 6
7obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o 7obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o
8obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
9obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
10obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
11obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o 8obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o
12obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o 9obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o
13obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o 10obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o
14obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o 11obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
15obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
16obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o 12obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
17obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o 13obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o
18obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o 14obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
19obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 15obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
20obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 16obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
17obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
18obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
19obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
21obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o 20obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o
21obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o
22obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o
23obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o
24obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
22obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o 25obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
23obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o 26obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o
24obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o 27obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o
25obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o
26obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
27obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
28obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
29obj-$(CONFIG_KEYBOARD_MAPLE) += maple_keyb.o
30obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
31obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o 28obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
32obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o 29obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
30obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
31obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
32obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
33obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 2157cd7de00c..efed0c9e242e 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -29,7 +29,8 @@
29struct gpio_button_data { 29struct gpio_button_data {
30 struct gpio_keys_button *button; 30 struct gpio_keys_button *button;
31 struct input_dev *input; 31 struct input_dev *input;
32 struct delayed_work work; 32 struct timer_list timer;
33 struct work_struct work;
33}; 34};
34 35
35struct gpio_keys_drvdata { 36struct gpio_keys_drvdata {
@@ -40,7 +41,7 @@ struct gpio_keys_drvdata {
40static void gpio_keys_report_event(struct work_struct *work) 41static void gpio_keys_report_event(struct work_struct *work)
41{ 42{
42 struct gpio_button_data *bdata = 43 struct gpio_button_data *bdata =
43 container_of(work, struct gpio_button_data, work.work); 44 container_of(work, struct gpio_button_data, work);
44 struct gpio_keys_button *button = bdata->button; 45 struct gpio_keys_button *button = bdata->button;
45 struct input_dev *input = bdata->input; 46 struct input_dev *input = bdata->input;
46 unsigned int type = button->type ?: EV_KEY; 47 unsigned int type = button->type ?: EV_KEY;
@@ -50,17 +51,25 @@ static void gpio_keys_report_event(struct work_struct *work)
50 input_sync(input); 51 input_sync(input);
51} 52}
52 53
54static void gpio_keys_timer(unsigned long _data)
55{
56 struct gpio_button_data *data = (struct gpio_button_data *)_data;
57
58 schedule_work(&data->work);
59}
60
53static irqreturn_t gpio_keys_isr(int irq, void *dev_id) 61static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
54{ 62{
55 struct gpio_button_data *bdata = dev_id; 63 struct gpio_button_data *bdata = dev_id;
56 struct gpio_keys_button *button = bdata->button; 64 struct gpio_keys_button *button = bdata->button;
57 unsigned long delay;
58 65
59 BUG_ON(irq != gpio_to_irq(button->gpio)); 66 BUG_ON(irq != gpio_to_irq(button->gpio));
60 67
61 delay = button->debounce_interval ? 68 if (button->debounce_interval)
62 msecs_to_jiffies(button->debounce_interval) : 0; 69 mod_timer(&bdata->timer,
63 schedule_delayed_work(&bdata->work, delay); 70 jiffies + msecs_to_jiffies(button->debounce_interval));
71 else
72 schedule_work(&bdata->work);
64 73
65 return IRQ_HANDLED; 74 return IRQ_HANDLED;
66} 75}
@@ -107,7 +116,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
107 116
108 bdata->input = input; 117 bdata->input = input;
109 bdata->button = button; 118 bdata->button = button;
110 INIT_DELAYED_WORK(&bdata->work, gpio_keys_report_event); 119 setup_timer(&bdata->timer,
120 gpio_keys_timer, (unsigned long)bdata);
121 INIT_WORK(&bdata->work, gpio_keys_report_event);
111 122
112 error = gpio_request(button->gpio, button->desc ?: "gpio_keys"); 123 error = gpio_request(button->gpio, button->desc ?: "gpio_keys");
113 if (error < 0) { 124 if (error < 0) {
@@ -166,7 +177,9 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
166 fail2: 177 fail2:
167 while (--i >= 0) { 178 while (--i >= 0) {
168 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); 179 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);
169 cancel_delayed_work_sync(&ddata->data[i].work); 180 if (pdata->buttons[i].debounce_interval)
181 del_timer_sync(&ddata->data[i].timer);
182 cancel_work_sync(&ddata->data[i].work);
170 gpio_free(pdata->buttons[i].gpio); 183 gpio_free(pdata->buttons[i].gpio);
171 } 184 }
172 185
@@ -190,7 +203,9 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
190 for (i = 0; i < pdata->nbuttons; i++) { 203 for (i = 0; i < pdata->nbuttons; i++) {
191 int irq = gpio_to_irq(pdata->buttons[i].gpio); 204 int irq = gpio_to_irq(pdata->buttons[i].gpio);
192 free_irq(irq, &ddata->data[i]); 205 free_irq(irq, &ddata->data[i]);
193 cancel_delayed_work_sync(&ddata->data[i].work); 206 if (pdata->buttons[i].debounce_interval)
207 del_timer_sync(&ddata->data[i].timer);
208 cancel_work_sync(&ddata->data[i].work);
194 gpio_free(pdata->buttons[i].gpio); 209 gpio_free(pdata->buttons[i].gpio);
195 } 210 }
196 211
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
new file mode 100644
index 000000000000..e9b2e7cb05be
--- /dev/null
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -0,0 +1,453 @@
1/*
2 * GPIO driven matrix keyboard driver
3 *
4 * Copyright (c) 2008 Marek Vasut <marek.vasut@gmail.com>
5 *
6 * Based on corgikbd.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/types.h>
15#include <linux/delay.h>
16#include <linux/platform_device.h>
17#include <linux/init.h>
18#include <linux/input.h>
19#include <linux/irq.h>
20#include <linux/interrupt.h>
21#include <linux/jiffies.h>
22#include <linux/module.h>
23#include <linux/gpio.h>
24#include <linux/input/matrix_keypad.h>
25
26struct matrix_keypad {
27 const struct matrix_keypad_platform_data *pdata;
28 struct input_dev *input_dev;
29 unsigned short *keycodes;
30
31 uint32_t last_key_state[MATRIX_MAX_COLS];
32 struct delayed_work work;
33 bool scan_pending;
34 bool stopped;
35 spinlock_t lock;
36};
37
38/*
39 * NOTE: normally the GPIO has to be put into HiZ when de-activated to cause
40 * minmal side effect when scanning other columns, here it is configured to
41 * be input, and it should work on most platforms.
42 */
43static void __activate_col(const struct matrix_keypad_platform_data *pdata,
44 int col, bool on)
45{
46 bool level_on = !pdata->active_low;
47
48 if (on) {
49 gpio_direction_output(pdata->col_gpios[col], level_on);
50 } else {
51 gpio_set_value_cansleep(pdata->col_gpios[col], !level_on);
52 gpio_direction_input(pdata->col_gpios[col]);
53 }
54}
55
56static void activate_col(const struct matrix_keypad_platform_data *pdata,
57 int col, bool on)
58{
59 __activate_col(pdata, col, on);
60
61 if (on && pdata->col_scan_delay_us)
62 udelay(pdata->col_scan_delay_us);
63}
64
65static void activate_all_cols(const struct matrix_keypad_platform_data *pdata,
66 bool on)
67{
68 int col;
69
70 for (col = 0; col < pdata->num_col_gpios; col++)
71 __activate_col(pdata, col, on);
72}
73
74static bool row_asserted(const struct matrix_keypad_platform_data *pdata,
75 int row)
76{
77 return gpio_get_value_cansleep(pdata->row_gpios[row]) ?
78 !pdata->active_low : pdata->active_low;
79}
80
81static void enable_row_irqs(struct matrix_keypad *keypad)
82{
83 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
84 int i;
85
86 for (i = 0; i < pdata->num_row_gpios; i++)
87 enable_irq(gpio_to_irq(pdata->row_gpios[i]));
88}
89
90static void disable_row_irqs(struct matrix_keypad *keypad)
91{
92 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
93 int i;
94
95 for (i = 0; i < pdata->num_row_gpios; i++)
96 disable_irq_nosync(gpio_to_irq(pdata->row_gpios[i]));
97}
98
99/*
100 * This gets the keys from keyboard and reports it to input subsystem
101 */
102static void matrix_keypad_scan(struct work_struct *work)
103{
104 struct matrix_keypad *keypad =
105 container_of(work, struct matrix_keypad, work.work);
106 struct input_dev *input_dev = keypad->input_dev;
107 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
108 uint32_t new_state[MATRIX_MAX_COLS];
109 int row, col, code;
110
111 /* de-activate all columns for scanning */
112 activate_all_cols(pdata, false);
113
114 memset(new_state, 0, sizeof(new_state));
115
116 /* assert each column and read the row status out */
117 for (col = 0; col < pdata->num_col_gpios; col++) {
118
119 activate_col(pdata, col, true);
120
121 for (row = 0; row < pdata->num_row_gpios; row++)
122 new_state[col] |=
123 row_asserted(pdata, row) ? (1 << row) : 0;
124
125 activate_col(pdata, col, false);
126 }
127
128 for (col = 0; col < pdata->num_col_gpios; col++) {
129 uint32_t bits_changed;
130
131 bits_changed = keypad->last_key_state[col] ^ new_state[col];
132 if (bits_changed == 0)
133 continue;
134
135 for (row = 0; row < pdata->num_row_gpios; row++) {
136 if ((bits_changed & (1 << row)) == 0)
137 continue;
138
139 code = (row << 4) + col;
140 input_event(input_dev, EV_MSC, MSC_SCAN, code);
141 input_report_key(input_dev,
142 keypad->keycodes[code],
143 new_state[col] & (1 << row));
144 }
145 }
146 input_sync(input_dev);
147
148 memcpy(keypad->last_key_state, new_state, sizeof(new_state));
149
150 activate_all_cols(pdata, true);
151
152 /* Enable IRQs again */
153 spin_lock_irq(&keypad->lock);
154 keypad->scan_pending = false;
155 enable_row_irqs(keypad);
156 spin_unlock_irq(&keypad->lock);
157}
158
159static irqreturn_t matrix_keypad_interrupt(int irq, void *id)
160{
161 struct matrix_keypad *keypad = id;
162 unsigned long flags;
163
164 spin_lock_irqsave(&keypad->lock, flags);
165
166 /*
167 * See if another IRQ beaten us to it and scheduled the
168 * scan already. In that case we should not try to
169 * disable IRQs again.
170 */
171 if (unlikely(keypad->scan_pending || keypad->stopped))
172 goto out;
173
174 disable_row_irqs(keypad);
175 keypad->scan_pending = true;
176 schedule_delayed_work(&keypad->work,
177 msecs_to_jiffies(keypad->pdata->debounce_ms));
178
179out:
180 spin_unlock_irqrestore(&keypad->lock, flags);
181 return IRQ_HANDLED;
182}
183
184static int matrix_keypad_start(struct input_dev *dev)
185{
186 struct matrix_keypad *keypad = input_get_drvdata(dev);
187
188 keypad->stopped = false;
189 mb();
190
191 /*
192 * Schedule an immediate key scan to capture current key state;
193 * columns will be activated and IRQs be enabled after the scan.
194 */
195 schedule_delayed_work(&keypad->work, 0);
196
197 return 0;
198}
199
200static void matrix_keypad_stop(struct input_dev *dev)
201{
202 struct matrix_keypad *keypad = input_get_drvdata(dev);
203
204 keypad->stopped = true;
205 mb();
206 flush_work(&keypad->work.work);
207 /*
208 * matrix_keypad_scan() will leave IRQs enabled;
209 * we should disable them now.
210 */
211 disable_row_irqs(keypad);
212}
213
214#ifdef CONFIG_PM
215static int matrix_keypad_suspend(struct platform_device *pdev, pm_message_t state)
216{
217 struct matrix_keypad *keypad = platform_get_drvdata(pdev);
218 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
219 int i;
220
221 matrix_keypad_stop(keypad->input_dev);
222
223 if (device_may_wakeup(&pdev->dev))
224 for (i = 0; i < pdata->num_row_gpios; i++)
225 enable_irq_wake(gpio_to_irq(pdata->row_gpios[i]));
226
227 return 0;
228}
229
230static int matrix_keypad_resume(struct platform_device *pdev)
231{
232 struct matrix_keypad *keypad = platform_get_drvdata(pdev);
233 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
234 int i;
235
236 if (device_may_wakeup(&pdev->dev))
237 for (i = 0; i < pdata->num_row_gpios; i++)
238 disable_irq_wake(gpio_to_irq(pdata->row_gpios[i]));
239
240 matrix_keypad_start(keypad->input_dev);
241
242 return 0;
243}
244#else
245#define matrix_keypad_suspend NULL
246#define matrix_keypad_resume NULL
247#endif
248
249static int __devinit init_matrix_gpio(struct platform_device *pdev,
250 struct matrix_keypad *keypad)
251{
252 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
253 int i, err = -EINVAL;
254
255 /* initialized strobe lines as outputs, activated */
256 for (i = 0; i < pdata->num_col_gpios; i++) {
257 err = gpio_request(pdata->col_gpios[i], "matrix_kbd_col");
258 if (err) {
259 dev_err(&pdev->dev,
260 "failed to request GPIO%d for COL%d\n",
261 pdata->col_gpios[i], i);
262 goto err_free_cols;
263 }
264
265 gpio_direction_output(pdata->col_gpios[i], !pdata->active_low);
266 }
267
268 for (i = 0; i < pdata->num_row_gpios; i++) {
269 err = gpio_request(pdata->row_gpios[i], "matrix_kbd_row");
270 if (err) {
271 dev_err(&pdev->dev,
272 "failed to request GPIO%d for ROW%d\n",
273 pdata->row_gpios[i], i);
274 goto err_free_rows;
275 }
276
277 gpio_direction_input(pdata->row_gpios[i]);
278 }
279
280 for (i = 0; i < pdata->num_row_gpios; i++) {
281 err = request_irq(gpio_to_irq(pdata->row_gpios[i]),
282 matrix_keypad_interrupt,
283 IRQF_DISABLED |
284 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
285 "matrix-keypad", keypad);
286 if (err) {
287 dev_err(&pdev->dev,
288 "Unable to acquire interrupt for GPIO line %i\n",
289 pdata->row_gpios[i]);
290 goto err_free_irqs;
291 }
292 }
293
294 /* initialized as disabled - enabled by input->open */
295 disable_row_irqs(keypad);
296 return 0;
297
298err_free_irqs:
299 while (--i >= 0)
300 free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad);
301 i = pdata->num_row_gpios;
302err_free_rows:
303 while (--i >= 0)
304 gpio_free(pdata->row_gpios[i]);
305 i = pdata->num_col_gpios;
306err_free_cols:
307 while (--i >= 0)
308 gpio_free(pdata->col_gpios[i]);
309
310 return err;
311}
312
313static int __devinit matrix_keypad_probe(struct platform_device *pdev)
314{
315 const struct matrix_keypad_platform_data *pdata;
316 const struct matrix_keymap_data *keymap_data;
317 struct matrix_keypad *keypad;
318 struct input_dev *input_dev;
319 unsigned short *keycodes;
320 int i;
321 int err;
322
323 pdata = pdev->dev.platform_data;
324 if (!pdata) {
325 dev_err(&pdev->dev, "no platform data defined\n");
326 return -EINVAL;
327 }
328
329 keymap_data = pdata->keymap_data;
330 if (!keymap_data) {
331 dev_err(&pdev->dev, "no keymap data defined\n");
332 return -EINVAL;
333 }
334
335 if (!keymap_data->max_keymap_size) {
336 dev_err(&pdev->dev, "invalid keymap data supplied\n");
337 return -EINVAL;
338 }
339
340 keypad = kzalloc(sizeof(struct matrix_keypad), GFP_KERNEL);
341 keycodes = kzalloc(keymap_data->max_keymap_size *
342 sizeof(keypad->keycodes),
343 GFP_KERNEL);
344 input_dev = input_allocate_device();
345 if (!keypad || !keycodes || !input_dev) {
346 err = -ENOMEM;
347 goto err_free_mem;
348 }
349
350 keypad->input_dev = input_dev;
351 keypad->pdata = pdata;
352 keypad->keycodes = keycodes;
353 keypad->stopped = true;
354 INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan);
355 spin_lock_init(&keypad->lock);
356
357 input_dev->name = pdev->name;
358 input_dev->id.bustype = BUS_HOST;
359 input_dev->dev.parent = &pdev->dev;
360 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
361 input_dev->open = matrix_keypad_start;
362 input_dev->close = matrix_keypad_stop;
363
364 input_dev->keycode = keycodes;
365 input_dev->keycodesize = sizeof(*keycodes);
366 input_dev->keycodemax = keymap_data->max_keymap_size;
367
368 for (i = 0; i < keymap_data->keymap_size; i++) {
369 unsigned int key = keymap_data->keymap[i];
370 unsigned int row = KEY_ROW(key);
371 unsigned int col = KEY_COL(key);
372 unsigned short code = KEY_VAL(key);
373
374 keycodes[(row << 4) + col] = code;
375 __set_bit(code, input_dev->keybit);
376 }
377 __clear_bit(KEY_RESERVED, input_dev->keybit);
378
379 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
380 input_set_drvdata(input_dev, keypad);
381
382 err = init_matrix_gpio(pdev, keypad);
383 if (err)
384 goto err_free_mem;
385
386 err = input_register_device(keypad->input_dev);
387 if (err)
388 goto err_free_mem;
389
390 device_init_wakeup(&pdev->dev, pdata->wakeup);
391 platform_set_drvdata(pdev, keypad);
392
393 return 0;
394
395err_free_mem:
396 input_free_device(input_dev);
397 kfree(keycodes);
398 kfree(keypad);
399 return err;
400}
401
402static int __devexit matrix_keypad_remove(struct platform_device *pdev)
403{
404 struct matrix_keypad *keypad = platform_get_drvdata(pdev);
405 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
406 int i;
407
408 device_init_wakeup(&pdev->dev, 0);
409
410 for (i = 0; i < pdata->num_row_gpios; i++) {
411 free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad);
412 gpio_free(pdata->row_gpios[i]);
413 }
414
415 for (i = 0; i < pdata->num_col_gpios; i++)
416 gpio_free(pdata->col_gpios[i]);
417
418 input_unregister_device(keypad->input_dev);
419 platform_set_drvdata(pdev, NULL);
420 kfree(keypad->keycodes);
421 kfree(keypad);
422
423 return 0;
424}
425
426static struct platform_driver matrix_keypad_driver = {
427 .probe = matrix_keypad_probe,
428 .remove = __devexit_p(matrix_keypad_remove),
429 .suspend = matrix_keypad_suspend,
430 .resume = matrix_keypad_resume,
431 .driver = {
432 .name = "matrix-keypad",
433 .owner = THIS_MODULE,
434 },
435};
436
437static int __init matrix_keypad_init(void)
438{
439 return platform_driver_register(&matrix_keypad_driver);
440}
441
442static void __exit matrix_keypad_exit(void)
443{
444 platform_driver_unregister(&matrix_keypad_driver);
445}
446
447module_init(matrix_keypad_init);
448module_exit(matrix_keypad_exit);
449
450MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
451MODULE_DESCRIPTION("GPIO Driven Matrix Keypad Driver");
452MODULE_LICENSE("GPL v2");
453MODULE_ALIAS("platform:matrix-keypad");
diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c
index 2adf9cb265da..d114d3a9e1e9 100644
--- a/drivers/input/misc/cobalt_btns.c
+++ b/drivers/input/misc/cobalt_btns.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cobalt button interface driver. 2 * Cobalt button interface driver.
3 * 3 *
4 * Copyright (C) 2007-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007-2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -148,7 +148,7 @@ static int __devexit cobalt_buttons_remove(struct platform_device *pdev)
148 return 0; 148 return 0;
149} 149}
150 150
151MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>"); 151MODULE_AUTHOR("Yoichi Yuasa <yuasa@linux-mips.org>");
152MODULE_DESCRIPTION("Cobalt button interface driver"); 152MODULE_DESCRIPTION("Cobalt button interface driver");
153MODULE_LICENSE("GPL"); 153MODULE_LICENSE("GPL");
154/* work with hotplug and coldplug */ 154/* work with hotplug and coldplug */
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
index 5e5eb88d8d1e..7b6ce178f1b6 100644
--- a/drivers/input/mouse/gpio_mouse.c
+++ b/drivers/input/mouse/gpio_mouse.c
@@ -46,7 +46,7 @@ static void gpio_mouse_scan(struct input_polled_dev *dev)
46 input_sync(input); 46 input_sync(input);
47} 47}
48 48
49static int __init gpio_mouse_probe(struct platform_device *pdev) 49static int __devinit gpio_mouse_probe(struct platform_device *pdev)
50{ 50{
51 struct gpio_mouse_platform_data *pdata = pdev->dev.platform_data; 51 struct gpio_mouse_platform_data *pdata = pdev->dev.platform_data;
52 struct input_polled_dev *input_poll; 52 struct input_polled_dev *input_poll;
@@ -170,10 +170,8 @@ static int __devexit gpio_mouse_remove(struct platform_device *pdev)
170 return 0; 170 return 0;
171} 171}
172 172
173/* work with hotplug and coldplug */
174MODULE_ALIAS("platform:gpio_mouse");
175
176static struct platform_driver gpio_mouse_device_driver = { 173static struct platform_driver gpio_mouse_device_driver = {
174 .probe = gpio_mouse_probe,
177 .remove = __devexit_p(gpio_mouse_remove), 175 .remove = __devexit_p(gpio_mouse_remove),
178 .driver = { 176 .driver = {
179 .name = "gpio_mouse", 177 .name = "gpio_mouse",
@@ -183,8 +181,7 @@ static struct platform_driver gpio_mouse_device_driver = {
183 181
184static int __init gpio_mouse_init(void) 182static int __init gpio_mouse_init(void)
185{ 183{
186 return platform_driver_probe(&gpio_mouse_device_driver, 184 return platform_driver_register(&gpio_mouse_device_driver);
187 gpio_mouse_probe);
188} 185}
189module_init(gpio_mouse_init); 186module_init(gpio_mouse_init);
190 187
@@ -197,3 +194,5 @@ module_exit(gpio_mouse_exit);
197MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>"); 194MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
198MODULE_DESCRIPTION("GPIO mouse driver"); 195MODULE_DESCRIPTION("GPIO mouse driver");
199MODULE_LICENSE("GPL"); 196MODULE_LICENSE("GPL");
197MODULE_ALIAS("platform:gpio_mouse"); /* work with hotplug and coldplug */
198
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index fb8a3cd3ffd0..924e8ed7f2cf 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -392,6 +392,34 @@ static struct dmi_system_id __initdata i8042_dmi_reset_table[] = {
392 DMI_MATCH(DMI_BOARD_VENDOR, "LG Electronics Inc."), 392 DMI_MATCH(DMI_BOARD_VENDOR, "LG Electronics Inc."),
393 }, 393 },
394 }, 394 },
395 {
396 .ident = "Acer Aspire One 150",
397 .matches = {
398 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
399 DMI_MATCH(DMI_PRODUCT_NAME, "AOA150"),
400 },
401 },
402 {
403 .ident = "Advent 4211",
404 .matches = {
405 DMI_MATCH(DMI_SYS_VENDOR, "DIXONSXP"),
406 DMI_MATCH(DMI_PRODUCT_NAME, "Advent 4211"),
407 },
408 },
409 {
410 .ident = "Medion Akoya Mini E1210",
411 .matches = {
412 DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
413 DMI_MATCH(DMI_PRODUCT_NAME, "E1210"),
414 },
415 },
416 {
417 .ident = "Mivvy M310",
418 .matches = {
419 DMI_MATCH(DMI_SYS_VENDOR, "VIOOO"),
420 DMI_MATCH(DMI_PRODUCT_NAME, "N10"),
421 },
422 },
395 { } 423 { }
396}; 424};
397 425
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index f919bf57293c..582245c497eb 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -934,10 +934,11 @@ static bool i8042_suspended;
934 934
935static int i8042_suspend(struct platform_device *dev, pm_message_t state) 935static int i8042_suspend(struct platform_device *dev, pm_message_t state)
936{ 936{
937 if (!i8042_suspended && state.event == PM_EVENT_SUSPEND) { 937 if (!i8042_suspended && state.event == PM_EVENT_SUSPEND)
938 i8042_controller_reset(); 938 i8042_controller_reset();
939 i8042_suspended = true; 939
940 } 940 i8042_suspended = state.event == PM_EVENT_SUSPEND ||
941 state.event == PM_EVENT_FREEZE;
941 942
942 return 0; 943 return 0;
943} 944}
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index fb17573f8f2d..d66f4944f2a0 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -935,10 +935,11 @@ static int serio_suspend(struct device *dev, pm_message_t state)
935{ 935{
936 struct serio *serio = to_serio_port(dev); 936 struct serio *serio = to_serio_port(dev);
937 937
938 if (!serio->suspended && state.event == PM_EVENT_SUSPEND) { 938 if (!serio->suspended && state.event == PM_EVENT_SUSPEND)
939 serio_cleanup(serio); 939 serio_cleanup(serio);
940 serio->suspended = true; 940
941 } 941 serio->suspended = state.event == PM_EVENT_SUSPEND ||
942 state.event == PM_EVENT_FREEZE;
942 943
943 return 0; 944 return 0;
944} 945}
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 38bf86384aeb..c896d6a21b7e 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -384,6 +384,8 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
384 wacom_report_key(wcombo, BTN_STYLUS2, 0); 384 wacom_report_key(wcombo, BTN_STYLUS2, 0);
385 wacom_report_key(wcombo, BTN_TOUCH, 0); 385 wacom_report_key(wcombo, BTN_TOUCH, 0);
386 wacom_report_abs(wcombo, ABS_WHEEL, 0); 386 wacom_report_abs(wcombo, ABS_WHEEL, 0);
387 if (wacom->features->type >= INTUOS3S)
388 wacom_report_abs(wcombo, ABS_Z, 0);
387 } 389 }
388 wacom_report_key(wcombo, wacom->tool[idx], 0); 390 wacom_report_key(wcombo, wacom->tool[idx], 0);
389 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ 391 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
@@ -836,6 +838,7 @@ static struct wacom_features wacom_features[] = {
836 { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL }, 838 { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL },
837 { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL }, 839 { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL },
838 { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL }, 840 { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL },
841 { "Wacom DTF720a", 8, 6858, 5506, 511, 0, PL },
839 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU }, 842 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU },
840 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 31, INTUOS }, 843 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 31, INTUOS },
841 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS }, 844 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
@@ -897,8 +900,9 @@ static struct usb_device_id wacom_ids[] = {
897 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) }, 900 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
898 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) }, 901 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
899 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) }, 902 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
900 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
901 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) }, 903 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
904 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
905 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC2) },
902 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) }, 906 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
903 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) }, 907 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
904 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) }, 908 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index ec5169604a6a..2d91049571a4 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -294,32 +294,33 @@ struct reply_t gigaset_tab_cid[] =
294 {RSP_OK, 604,604, -1, 605, 5, {ACT_CMD+AT_MSN}}, 294 {RSP_OK, 604,604, -1, 605, 5, {ACT_CMD+AT_MSN}},
295 {RSP_OK, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}}, 295 {RSP_OK, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}},
296 {RSP_NULL, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}}, 296 {RSP_NULL, 605,605, -1, 606, 5, {ACT_CMD+AT_ISO}},
297 {RSP_OK, 606,606, -1, 607, 5, {0}, "+VLS=17\r"}, /* set "Endgeraetemodus" */ 297 {RSP_OK, 606,606, -1, 607, 5, {0}, "+VLS=17\r"},
298 {RSP_OK, 607,607, -1, 608,-1}, 298 {RSP_OK, 607,607, -1, 608,-1},
299 //{RSP_ZSAU, 608,608,ZSAU_PROCEEDING, 608, 0, {ACT_ERROR}},//DELETE
300 {RSP_ZSAU, 608,608,ZSAU_PROCEEDING, 609, 5, {ACT_CMD+AT_DIAL}}, 299 {RSP_ZSAU, 608,608,ZSAU_PROCEEDING, 609, 5, {ACT_CMD+AT_DIAL}},
301 {RSP_OK, 609,609, -1, 650, 0, {ACT_DIALING}}, 300 {RSP_OK, 609,609, -1, 650, 0, {ACT_DIALING}},
302 301
303 {RSP_ZVLS, 608,608, 17, -1,-1, {ACT_DEBUG}},
304 {RSP_ZCTP, 609,609, -1, -1,-1, {ACT_DEBUG}},
305 {RSP_ZCPN, 609,609, -1, -1,-1, {ACT_DEBUG}},
306 {RSP_ERROR, 601,609, -1, 0, 0, {ACT_ABORTDIAL}}, 302 {RSP_ERROR, 601,609, -1, 0, 0, {ACT_ABORTDIAL}},
307 {EV_TIMEOUT, 601,609, -1, 0, 0, {ACT_ABORTDIAL}}, 303 {EV_TIMEOUT, 601,609, -1, 0, 0, {ACT_ABORTDIAL}},
308 304
309 /* dialing */ 305 /* optional dialing responses */
310 {RSP_ZCTP, 650,650, -1, -1,-1, {ACT_DEBUG}}, 306 {EV_BC_OPEN, 650,650, -1, 651,-1},
311 {RSP_ZCPN, 650,650, -1, -1,-1, {ACT_DEBUG}}, 307 {RSP_ZVLS, 608,651, 17, -1,-1, {ACT_DEBUG}},
312 {RSP_ZSAU, 650,650,ZSAU_CALL_DELIVERED, -1,-1, {ACT_DEBUG}}, /* some devices don't send this */ 308 {RSP_ZCTP, 609,651, -1, -1,-1, {ACT_DEBUG}},
313 309 {RSP_ZCPN, 609,651, -1, -1,-1, {ACT_DEBUG}},
314 /* connection established */ 310 {RSP_ZSAU, 650,651,ZSAU_CALL_DELIVERED, -1,-1, {ACT_DEBUG}},
315 {RSP_ZSAU, 650,650,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}}, //FIXME -> DLE1 311
316 {RSP_ZSAU, 750,750,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}}, //FIXME -> DLE1 312 /* connect */
317 313 {RSP_ZSAU, 650,650,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}},
318 {EV_BC_OPEN, 800,800, -1, 800,-1, {ACT_NOTIFY_BC_UP}}, //FIXME new constate + timeout 314 {RSP_ZSAU, 651,651,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT,
315 ACT_NOTIFY_BC_UP}},
316 {RSP_ZSAU, 750,750,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT}},
317 {RSP_ZSAU, 751,751,ZSAU_ACTIVE, 800,-1, {ACT_CONNECT,
318 ACT_NOTIFY_BC_UP}},
319 {EV_BC_OPEN, 800,800, -1, 800,-1, {ACT_NOTIFY_BC_UP}},
319 320
320 /* remote hangup */ 321 /* remote hangup */
321 {RSP_ZSAU, 650,650,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT}}, 322 {RSP_ZSAU, 650,651,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEREJECT}},
322 {RSP_ZSAU, 750,750,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}}, 323 {RSP_ZSAU, 750,751,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}},
323 {RSP_ZSAU, 800,800,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}}, 324 {RSP_ZSAU, 800,800,ZSAU_DISCONNECT_IND, 0, 0, {ACT_REMOTEHUP}},
324 325
325 /* hangup */ 326 /* hangup */
@@ -358,7 +359,8 @@ struct reply_t gigaset_tab_cid[] =
358 {RSP_ZSAU, 700,729,ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT}}, 359 {RSP_ZSAU, 700,729,ZSAU_ACTIVE, 0, 0, {ACT_ABORTACCEPT}},
359 {RSP_ZSAU, 700,729,ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT}}, 360 {RSP_ZSAU, 700,729,ZSAU_DISCONNECT_IND, 0, 0, {ACT_ABORTACCEPT}},
360 361
361 {EV_TIMEOUT, 750,750, -1, 0, 0, {ACT_CONNTIMEOUT}}, 362 {EV_BC_OPEN, 750,750, -1, 751,-1},
363 {EV_TIMEOUT, 750,751, -1, 0, 0, {ACT_CONNTIMEOUT}},
362 364
363 /* B channel closed (general case) */ 365 /* B channel closed (general case) */
364 {EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME 366 {EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME
@@ -876,12 +878,6 @@ static void bchannel_down(struct bc_state *bcs)
876 878
877static void bchannel_up(struct bc_state *bcs) 879static void bchannel_up(struct bc_state *bcs)
878{ 880{
879 if (!(bcs->chstate & CHS_D_UP)) {
880 dev_notice(bcs->cs->dev, "%s: D channel not up\n", __func__);
881 bcs->chstate |= CHS_D_UP;
882 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
883 }
884
885 if (bcs->chstate & CHS_B_UP) { 881 if (bcs->chstate & CHS_B_UP) {
886 dev_notice(bcs->cs->dev, "%s: B channel already up\n", 882 dev_notice(bcs->cs->dev, "%s: B channel already up\n",
887 __func__); 883 __func__);
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index db3a1e4cd489..bed38fcc432b 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -174,12 +174,6 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
174 pr_err("invalid size %d\n", size); 174 pr_err("invalid size %d\n", size);
175 return -EINVAL; 175 return -EINVAL;
176 } 176 }
177 src = iwb->read;
178 if (unlikely(limit >= BAS_OUTBUFSIZE + BAS_OUTBUFPAD ||
179 (read < src && limit >= src))) {
180 pr_err("isoc write buffer frame reservation violated\n");
181 return -EFAULT;
182 }
183#endif 177#endif
184 178
185 if (read < write) { 179 if (read < write) {
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index 8df889b0c1a9..9de54202c90c 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -37,7 +37,6 @@
37#include <linux/kernel_stat.h> 37#include <linux/kernel_stat.h>
38#include <linux/usb.h> 38#include <linux/usb.h>
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/smp_lock.h>
41#include <linux/sched.h> 40#include <linux/sched.h>
42#include <linux/moduleparam.h> 41#include <linux/moduleparam.h>
43#include "hisax.h" 42#include "hisax.h"
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index b4d4522e5071..2881a66c1aa9 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/isdn.h> 14#include <linux/isdn.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/smp_lock.h>
16#include "isdn_common.h" 17#include "isdn_common.h"
17#include "isdn_tty.h" 18#include "isdn_tty.h"
18#ifdef CONFIG_ISDN_AUDIO 19#ifdef CONFIG_ISDN_AUDIO
diff --git a/drivers/isdn/mISDN/stack.c b/drivers/isdn/mISDN/stack.c
index e2f45019ebf0..3e1532a180ff 100644
--- a/drivers/isdn/mISDN/stack.c
+++ b/drivers/isdn/mISDN/stack.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/mISDNif.h> 18#include <linux/mISDNif.h>
19#include <linux/kthread.h> 19#include <linux/kthread.h>
20#include <linux/smp_lock.h>
20#include "core.h" 21#include "core.h"
21 22
22static u_int *debug; 23static u_int *debug;
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 9b60b6b684d9..7c8e7122aaa9 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -75,6 +75,7 @@ config LEDS_ALIX2
75 depends on LEDS_CLASS && X86 && EXPERIMENTAL 75 depends on LEDS_CLASS && X86 && EXPERIMENTAL
76 help 76 help
77 This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs. 77 This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs.
78 You have to set leds-alix2.force=1 for boards with Award BIOS.
78 79
79config LEDS_H1940 80config LEDS_H1940
80 tristate "LED Support for iPAQ H1940 device" 81 tristate "LED Support for iPAQ H1940 device"
@@ -145,15 +146,16 @@ config LEDS_GPIO_OF
145 of_platform devices. For instance, LEDs which are listed in a "dts" 146 of_platform devices. For instance, LEDs which are listed in a "dts"
146 file. 147 file.
147 148
148config LEDS_LP5521 149config LEDS_LP3944
149 tristate "LED Support for the LP5521 LEDs" 150 tristate "LED Support for N.S. LP3944 (Fun Light) I2C chip"
150 depends on LEDS_CLASS && I2C 151 depends on LEDS_CLASS && I2C
151 help 152 help
152 If you say 'Y' here you get support for the National Semiconductor 153 This option enables support for LEDs connected to the National
153 LP5521 LED driver used in n8x0 boards. 154 Semiconductor LP3944 Lighting Management Unit (LMU) also known as
155 Fun Light Chip.
154 156
155 This driver can be built as a module by choosing 'M'. The module 157 To compile this driver as a module, choose M here: the
156 will be called leds-lp5521. 158 module will be called leds-lp3944.
157 159
158config LEDS_CLEVO_MAIL 160config LEDS_CLEVO_MAIL
159 tristate "Mail LED on Clevo notebook" 161 tristate "Mail LED on Clevo notebook"
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 2d41c4dcf92f..e8cdcf77a4c3 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
20obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o 20obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o
21obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o 21obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o
22obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o 22obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
23obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o
23obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o 24obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
24obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o 25obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
25obj-$(CONFIG_LEDS_FSG) += leds-fsg.o 26obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
diff --git a/drivers/leds/leds-alix2.c b/drivers/leds/leds-alix2.c
index ddbd7730dfc8..731d4eef3425 100644
--- a/drivers/leds/leds-alix2.c
+++ b/drivers/leds/leds-alix2.c
@@ -14,7 +14,7 @@
14 14
15static int force = 0; 15static int force = 0;
16module_param(force, bool, 0444); 16module_param(force, bool, 0444);
17MODULE_PARM_DESC(force, "Assume system has ALIX.2 style LEDs"); 17MODULE_PARM_DESC(force, "Assume system has ALIX.2/ALIX.3 style LEDs");
18 18
19struct alix_led { 19struct alix_led {
20 struct led_classdev cdev; 20 struct led_classdev cdev;
@@ -155,6 +155,11 @@ static int __init alix_led_init(void)
155 goto out; 155 goto out;
156 } 156 }
157 157
158 /* enable output on GPIO for LED 1,2,3 */
159 outl(1 << 6, 0x6104);
160 outl(1 << 9, 0x6184);
161 outl(1 << 11, 0x6184);
162
158 pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0); 163 pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
159 if (!IS_ERR(pdev)) { 164 if (!IS_ERR(pdev)) {
160 ret = platform_driver_probe(&alix_led_driver, alix_led_probe); 165 ret = platform_driver_probe(&alix_led_driver, alix_led_probe);
diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c
index 4149ecb3a9b2..779d7f262c04 100644
--- a/drivers/leds/leds-bd2802.c
+++ b/drivers/leds/leds-bd2802.c
@@ -97,6 +97,10 @@ struct bd2802_led {
97 enum led_ids led_id; 97 enum led_ids led_id;
98 enum led_colors color; 98 enum led_colors color;
99 enum led_bits state; 99 enum led_bits state;
100
101 /* General attributes of RGB LEDs */
102 int wave_pattern;
103 int rgb_current;
100}; 104};
101 105
102 106
@@ -254,7 +258,7 @@ static void bd2802_set_on(struct bd2802_led *led, enum led_ids id,
254 bd2802_reset_cancel(led); 258 bd2802_reset_cancel(led);
255 259
256 reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT1SETUP); 260 reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT1SETUP);
257 bd2802_write_byte(led->client, reg, BD2802_CURRENT_032); 261 bd2802_write_byte(led->client, reg, led->rgb_current);
258 reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT2SETUP); 262 reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT2SETUP);
259 bd2802_write_byte(led->client, reg, BD2802_CURRENT_000); 263 bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
260 reg = bd2802_get_reg_addr(id, color, BD2802_REG_WAVEPATTERN); 264 reg = bd2802_get_reg_addr(id, color, BD2802_REG_WAVEPATTERN);
@@ -275,9 +279,9 @@ static void bd2802_set_blink(struct bd2802_led *led, enum led_ids id,
275 reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT1SETUP); 279 reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT1SETUP);
276 bd2802_write_byte(led->client, reg, BD2802_CURRENT_000); 280 bd2802_write_byte(led->client, reg, BD2802_CURRENT_000);
277 reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT2SETUP); 281 reg = bd2802_get_reg_addr(id, color, BD2802_REG_CURRENT2SETUP);
278 bd2802_write_byte(led->client, reg, BD2802_CURRENT_032); 282 bd2802_write_byte(led->client, reg, led->rgb_current);
279 reg = bd2802_get_reg_addr(id, color, BD2802_REG_WAVEPATTERN); 283 reg = bd2802_get_reg_addr(id, color, BD2802_REG_WAVEPATTERN);
280 bd2802_write_byte(led->client, reg, BD2802_PATTERN_HALF); 284 bd2802_write_byte(led->client, reg, led->wave_pattern);
281 285
282 bd2802_enable(led, id); 286 bd2802_enable(led, id);
283 bd2802_update_state(led, id, color, BD2802_BLINK); 287 bd2802_update_state(led, id, color, BD2802_BLINK);
@@ -406,7 +410,7 @@ static void bd2802_enable_adv_conf(struct bd2802_led *led)
406 ret = device_create_file(&led->client->dev, 410 ret = device_create_file(&led->client->dev,
407 bd2802_addr_attributes[i]); 411 bd2802_addr_attributes[i]);
408 if (ret) { 412 if (ret) {
409 dev_err(&led->client->dev, "failed to sysfs file %s\n", 413 dev_err(&led->client->dev, "failed: sysfs file %s\n",
410 bd2802_addr_attributes[i]->attr.name); 414 bd2802_addr_attributes[i]->attr.name);
411 goto failed_remove_files; 415 goto failed_remove_files;
412 } 416 }
@@ -483,6 +487,52 @@ static struct device_attribute bd2802_adv_conf_attr = {
483 .store = bd2802_store_adv_conf, 487 .store = bd2802_store_adv_conf,
484}; 488};
485 489
490#define BD2802_CONTROL_ATTR(attr_name, name_str) \
491static ssize_t bd2802_show_##attr_name(struct device *dev, \
492 struct device_attribute *attr, char *buf) \
493{ \
494 struct bd2802_led *led = i2c_get_clientdata(to_i2c_client(dev));\
495 ssize_t ret; \
496 down_read(&led->rwsem); \
497 ret = sprintf(buf, "0x%02x\n", led->attr_name); \
498 up_read(&led->rwsem); \
499 return ret; \
500} \
501static ssize_t bd2802_store_##attr_name(struct device *dev, \
502 struct device_attribute *attr, const char *buf, size_t count) \
503{ \
504 struct bd2802_led *led = i2c_get_clientdata(to_i2c_client(dev));\
505 unsigned long val; \
506 int ret; \
507 if (!count) \
508 return -EINVAL; \
509 ret = strict_strtoul(buf, 16, &val); \
510 if (ret) \
511 return ret; \
512 down_write(&led->rwsem); \
513 led->attr_name = val; \
514 up_write(&led->rwsem); \
515 return count; \
516} \
517static struct device_attribute bd2802_##attr_name##_attr = { \
518 .attr = { \
519 .name = name_str, \
520 .mode = 0644, \
521 .owner = THIS_MODULE \
522 }, \
523 .show = bd2802_show_##attr_name, \
524 .store = bd2802_store_##attr_name, \
525};
526
527BD2802_CONTROL_ATTR(wave_pattern, "wave_pattern");
528BD2802_CONTROL_ATTR(rgb_current, "rgb_current");
529
530static struct device_attribute *bd2802_attributes[] = {
531 &bd2802_adv_conf_attr,
532 &bd2802_wave_pattern_attr,
533 &bd2802_rgb_current_attr,
534};
535
486static void bd2802_led_work(struct work_struct *work) 536static void bd2802_led_work(struct work_struct *work)
487{ 537{
488 struct bd2802_led *led = container_of(work, struct bd2802_led, work); 538 struct bd2802_led *led = container_of(work, struct bd2802_led, work);
@@ -538,7 +588,6 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
538 led->cdev_led1r.brightness = LED_OFF; 588 led->cdev_led1r.brightness = LED_OFF;
539 led->cdev_led1r.brightness_set = bd2802_set_led1r_brightness; 589 led->cdev_led1r.brightness_set = bd2802_set_led1r_brightness;
540 led->cdev_led1r.blink_set = bd2802_set_led1r_blink; 590 led->cdev_led1r.blink_set = bd2802_set_led1r_blink;
541 led->cdev_led1r.flags |= LED_CORE_SUSPENDRESUME;
542 591
543 ret = led_classdev_register(&led->client->dev, &led->cdev_led1r); 592 ret = led_classdev_register(&led->client->dev, &led->cdev_led1r);
544 if (ret < 0) { 593 if (ret < 0) {
@@ -551,7 +600,6 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
551 led->cdev_led1g.brightness = LED_OFF; 600 led->cdev_led1g.brightness = LED_OFF;
552 led->cdev_led1g.brightness_set = bd2802_set_led1g_brightness; 601 led->cdev_led1g.brightness_set = bd2802_set_led1g_brightness;
553 led->cdev_led1g.blink_set = bd2802_set_led1g_blink; 602 led->cdev_led1g.blink_set = bd2802_set_led1g_blink;
554 led->cdev_led1g.flags |= LED_CORE_SUSPENDRESUME;
555 603
556 ret = led_classdev_register(&led->client->dev, &led->cdev_led1g); 604 ret = led_classdev_register(&led->client->dev, &led->cdev_led1g);
557 if (ret < 0) { 605 if (ret < 0) {
@@ -564,7 +612,6 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
564 led->cdev_led1b.brightness = LED_OFF; 612 led->cdev_led1b.brightness = LED_OFF;
565 led->cdev_led1b.brightness_set = bd2802_set_led1b_brightness; 613 led->cdev_led1b.brightness_set = bd2802_set_led1b_brightness;
566 led->cdev_led1b.blink_set = bd2802_set_led1b_blink; 614 led->cdev_led1b.blink_set = bd2802_set_led1b_blink;
567 led->cdev_led1b.flags |= LED_CORE_SUSPENDRESUME;
568 615
569 ret = led_classdev_register(&led->client->dev, &led->cdev_led1b); 616 ret = led_classdev_register(&led->client->dev, &led->cdev_led1b);
570 if (ret < 0) { 617 if (ret < 0) {
@@ -577,7 +624,6 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
577 led->cdev_led2r.brightness = LED_OFF; 624 led->cdev_led2r.brightness = LED_OFF;
578 led->cdev_led2r.brightness_set = bd2802_set_led2r_brightness; 625 led->cdev_led2r.brightness_set = bd2802_set_led2r_brightness;
579 led->cdev_led2r.blink_set = bd2802_set_led2r_blink; 626 led->cdev_led2r.blink_set = bd2802_set_led2r_blink;
580 led->cdev_led2r.flags |= LED_CORE_SUSPENDRESUME;
581 627
582 ret = led_classdev_register(&led->client->dev, &led->cdev_led2r); 628 ret = led_classdev_register(&led->client->dev, &led->cdev_led2r);
583 if (ret < 0) { 629 if (ret < 0) {
@@ -590,7 +636,6 @@ static int bd2802_register_led_classdev(struct bd2802_led *led)
590 led->cdev_led2g.brightness = LED_OFF; 636 led->cdev_led2g.brightness = LED_OFF;
591 led->cdev_led2g.brightness_set = bd2802_set_led2g_brightness; 637 led->cdev_led2g.brightness_set = bd2802_set_led2g_brightness;
592 led->cdev_led2g.blink_set = bd2802_set_led2g_blink; 638 led->cdev_led2g.blink_set = bd2802_set_led2g_blink;
593 led->cdev_led2g.flags |= LED_CORE_SUSPENDRESUME;
594 639
595 ret = led_classdev_register(&led->client->dev, &led->cdev_led2g); 640 ret = led_classdev_register(&led->client->dev, &led->cdev_led2g);
596 if (ret < 0) { 641 if (ret < 0) {
@@ -640,7 +685,7 @@ static int __devinit bd2802_probe(struct i2c_client *client,
640{ 685{
641 struct bd2802_led *led; 686 struct bd2802_led *led;
642 struct bd2802_led_platform_data *pdata; 687 struct bd2802_led_platform_data *pdata;
643 int ret; 688 int ret, i;
644 689
645 led = kzalloc(sizeof(struct bd2802_led), GFP_KERNEL); 690 led = kzalloc(sizeof(struct bd2802_led), GFP_KERNEL);
646 if (!led) { 691 if (!led) {
@@ -670,13 +715,20 @@ static int __devinit bd2802_probe(struct i2c_client *client,
670 /* To save the power, reset BD2802 after detecting */ 715 /* To save the power, reset BD2802 after detecting */
671 gpio_set_value(led->pdata->reset_gpio, 0); 716 gpio_set_value(led->pdata->reset_gpio, 0);
672 717
718 /* Default attributes */
719 led->wave_pattern = BD2802_PATTERN_HALF;
720 led->rgb_current = BD2802_CURRENT_032;
721
673 init_rwsem(&led->rwsem); 722 init_rwsem(&led->rwsem);
674 723
675 ret = device_create_file(&client->dev, &bd2802_adv_conf_attr); 724 for (i = 0; i < ARRAY_SIZE(bd2802_attributes); i++) {
676 if (ret) { 725 ret = device_create_file(&led->client->dev,
677 dev_err(&client->dev, "failed to create sysfs file %s\n", 726 bd2802_attributes[i]);
678 bd2802_adv_conf_attr.attr.name); 727 if (ret) {
679 goto failed_free; 728 dev_err(&led->client->dev, "failed: sysfs file %s\n",
729 bd2802_attributes[i]->attr.name);
730 goto failed_unregister_dev_file;
731 }
680 } 732 }
681 733
682 ret = bd2802_register_led_classdev(led); 734 ret = bd2802_register_led_classdev(led);
@@ -686,7 +738,8 @@ static int __devinit bd2802_probe(struct i2c_client *client,
686 return 0; 738 return 0;
687 739
688failed_unregister_dev_file: 740failed_unregister_dev_file:
689 device_remove_file(&client->dev, &bd2802_adv_conf_attr); 741 for (i--; i >= 0; i--)
742 device_remove_file(&led->client->dev, bd2802_attributes[i]);
690failed_free: 743failed_free:
691 i2c_set_clientdata(client, NULL); 744 i2c_set_clientdata(client, NULL);
692 kfree(led); 745 kfree(led);
@@ -697,12 +750,14 @@ failed_free:
697static int __exit bd2802_remove(struct i2c_client *client) 750static int __exit bd2802_remove(struct i2c_client *client)
698{ 751{
699 struct bd2802_led *led = i2c_get_clientdata(client); 752 struct bd2802_led *led = i2c_get_clientdata(client);
753 int i;
700 754
701 bd2802_unregister_led_classdev(led);
702 gpio_set_value(led->pdata->reset_gpio, 0); 755 gpio_set_value(led->pdata->reset_gpio, 0);
756 bd2802_unregister_led_classdev(led);
703 if (led->adf_on) 757 if (led->adf_on)
704 bd2802_disable_adv_conf(led); 758 bd2802_disable_adv_conf(led);
705 device_remove_file(&client->dev, &bd2802_adv_conf_attr); 759 for (i = 0; i < ARRAY_SIZE(bd2802_attributes); i++)
760 device_remove_file(&led->client->dev, bd2802_attributes[i]);
706 i2c_set_clientdata(client, NULL); 761 i2c_set_clientdata(client, NULL);
707 kfree(led); 762 kfree(led);
708 763
@@ -723,8 +778,7 @@ static int bd2802_resume(struct i2c_client *client)
723 struct bd2802_led *led = i2c_get_clientdata(client); 778 struct bd2802_led *led = i2c_get_clientdata(client);
724 779
725 if (!bd2802_is_all_off(led) || led->adf_on) { 780 if (!bd2802_is_all_off(led) || led->adf_on) {
726 gpio_set_value(led->pdata->reset_gpio, 1); 781 bd2802_reset_cancel(led);
727 udelay(100);
728 bd2802_restore_state(led); 782 bd2802_restore_state(led);
729 } 783 }
730 784
@@ -762,4 +816,4 @@ module_exit(bd2802_exit);
762 816
763MODULE_AUTHOR("Kim Kyuwon <q1.kim@samsung.com>"); 817MODULE_AUTHOR("Kim Kyuwon <q1.kim@samsung.com>");
764MODULE_DESCRIPTION("BD2802 LED driver"); 818MODULE_DESCRIPTION("BD2802 LED driver");
765MODULE_LICENSE("GPL"); 819MODULE_LICENSE("GPL v2");
diff --git a/drivers/leds/leds-cobalt-raq.c b/drivers/leds/leds-cobalt-raq.c
index ff0e8c3fbf9b..5f1ce810815f 100644
--- a/drivers/leds/leds-cobalt-raq.c
+++ b/drivers/leds/leds-cobalt-raq.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * LEDs driver for the Cobalt Raq series. 2 * LEDs driver for the Cobalt Raq series.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index d2109054de85..6b06638eb5b4 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -76,7 +76,7 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
76 struct gpio_led_data *led_dat, struct device *parent, 76 struct gpio_led_data *led_dat, struct device *parent,
77 int (*blink_set)(unsigned, unsigned long *, unsigned long *)) 77 int (*blink_set)(unsigned, unsigned long *, unsigned long *))
78{ 78{
79 int ret; 79 int ret, state;
80 80
81 /* skip leds that aren't available */ 81 /* skip leds that aren't available */
82 if (!gpio_is_valid(template->gpio)) { 82 if (!gpio_is_valid(template->gpio)) {
@@ -99,11 +99,15 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
99 led_dat->cdev.blink_set = gpio_blink_set; 99 led_dat->cdev.blink_set = gpio_blink_set;
100 } 100 }
101 led_dat->cdev.brightness_set = gpio_led_set; 101 led_dat->cdev.brightness_set = gpio_led_set;
102 led_dat->cdev.brightness = LED_OFF; 102 if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP)
103 state = !!gpio_get_value(led_dat->gpio) ^ led_dat->active_low;
104 else
105 state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
106 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
103 if (!template->retain_state_suspended) 107 if (!template->retain_state_suspended)
104 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; 108 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
105 109
106 ret = gpio_direction_output(led_dat->gpio, led_dat->active_low); 110 ret = gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state);
107 if (ret < 0) 111 if (ret < 0)
108 goto err; 112 goto err;
109 113
@@ -129,7 +133,7 @@ static void delete_gpio_led(struct gpio_led_data *led)
129} 133}
130 134
131#ifdef CONFIG_LEDS_GPIO_PLATFORM 135#ifdef CONFIG_LEDS_GPIO_PLATFORM
132static int gpio_led_probe(struct platform_device *pdev) 136static int __devinit gpio_led_probe(struct platform_device *pdev)
133{ 137{
134 struct gpio_led_platform_data *pdata = pdev->dev.platform_data; 138 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
135 struct gpio_led_data *leds_data; 139 struct gpio_led_data *leds_data;
@@ -223,12 +227,22 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev,
223 memset(&led, 0, sizeof(led)); 227 memset(&led, 0, sizeof(led));
224 for_each_child_of_node(np, child) { 228 for_each_child_of_node(np, child) {
225 enum of_gpio_flags flags; 229 enum of_gpio_flags flags;
230 const char *state;
226 231
227 led.gpio = of_get_gpio_flags(child, 0, &flags); 232 led.gpio = of_get_gpio_flags(child, 0, &flags);
228 led.active_low = flags & OF_GPIO_ACTIVE_LOW; 233 led.active_low = flags & OF_GPIO_ACTIVE_LOW;
229 led.name = of_get_property(child, "label", NULL) ? : child->name; 234 led.name = of_get_property(child, "label", NULL) ? : child->name;
230 led.default_trigger = 235 led.default_trigger =
231 of_get_property(child, "linux,default-trigger", NULL); 236 of_get_property(child, "linux,default-trigger", NULL);
237 state = of_get_property(child, "default-state", NULL);
238 if (state) {
239 if (!strcmp(state, "keep"))
240 led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
241 else if(!strcmp(state, "on"))
242 led.default_state = LEDS_GPIO_DEFSTATE_ON;
243 else
244 led.default_state = LEDS_GPIO_DEFSTATE_OFF;
245 }
232 246
233 ret = create_gpio_led(&led, &pdata->led_data[pdata->num_leds++], 247 ret = create_gpio_led(&led, &pdata->led_data[pdata->num_leds++],
234 &ofdev->dev, NULL); 248 &ofdev->dev, NULL);
diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
new file mode 100644
index 000000000000..5946208ba26e
--- /dev/null
+++ b/drivers/leds/leds-lp3944.c
@@ -0,0 +1,466 @@
1/*
2 * leds-lp3944.c - driver for National Semiconductor LP3944 Funlight Chip
3 *
4 * Copyright (C) 2009 Antonio Ospite <ospite@studenti.unina.it>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12/*
13 * I2C driver for National Semiconductor LP3944 Funlight Chip
14 * http://www.national.com/pf/LP/LP3944.html
15 *
16 * This helper chip can drive up to 8 leds, with two programmable DIM modes;
17 * it could even be used as a gpio expander but this driver assumes it is used
18 * as a led controller.
19 *
20 * The DIM modes are used to set _blink_ patterns for leds, the pattern is
21 * specified supplying two parameters:
22 * - period: from 0s to 1.6s
23 * - duty cycle: percentage of the period the led is on, from 0 to 100
24 *
25 * LP3944 can be found on Motorola A910 smartphone, where it drives the rgb
26 * leds, the camera flash light and the displays backlights.
27 */
28
29#include <linux/module.h>
30#include <linux/i2c.h>
31#include <linux/leds.h>
32#include <linux/mutex.h>
33#include <linux/workqueue.h>
34#include <linux/leds-lp3944.h>
35
36/* Read Only Registers */
37#define LP3944_REG_INPUT1 0x00 /* LEDs 0-7 InputRegister (Read Only) */
38#define LP3944_REG_REGISTER1 0x01 /* None (Read Only) */
39
40#define LP3944_REG_PSC0 0x02 /* Frequency Prescaler 0 (R/W) */
41#define LP3944_REG_PWM0 0x03 /* PWM Register 0 (R/W) */
42#define LP3944_REG_PSC1 0x04 /* Frequency Prescaler 1 (R/W) */
43#define LP3944_REG_PWM1 0x05 /* PWM Register 1 (R/W) */
44#define LP3944_REG_LS0 0x06 /* LEDs 0-3 Selector (R/W) */
45#define LP3944_REG_LS1 0x07 /* LEDs 4-7 Selector (R/W) */
46
47/* These registers are not used to control leds in LP3944, they can store
48 * arbitrary values which the chip will ignore.
49 */
50#define LP3944_REG_REGISTER8 0x08
51#define LP3944_REG_REGISTER9 0x09
52
53#define LP3944_DIM0 0
54#define LP3944_DIM1 1
55
56/* period in ms */
57#define LP3944_PERIOD_MIN 0
58#define LP3944_PERIOD_MAX 1600
59
60/* duty cycle is a percentage */
61#define LP3944_DUTY_CYCLE_MIN 0
62#define LP3944_DUTY_CYCLE_MAX 100
63
64#define ldev_to_led(c) container_of(c, struct lp3944_led_data, ldev)
65
66/* Saved data */
67struct lp3944_led_data {
68 u8 id;
69 enum lp3944_type type;
70 enum lp3944_status status;
71 struct led_classdev ldev;
72 struct i2c_client *client;
73 struct work_struct work;
74};
75
76struct lp3944_data {
77 struct mutex lock;
78 struct i2c_client *client;
79 struct lp3944_led_data leds[LP3944_LEDS_MAX];
80};
81
82static int lp3944_reg_read(struct i2c_client *client, u8 reg, u8 *value)
83{
84 int tmp;
85
86 tmp = i2c_smbus_read_byte_data(client, reg);
87 if (tmp < 0)
88 return -EINVAL;
89
90 *value = tmp;
91
92 return 0;
93}
94
95static int lp3944_reg_write(struct i2c_client *client, u8 reg, u8 value)
96{
97 return i2c_smbus_write_byte_data(client, reg, value);
98}
99
100/**
101 * Set the period for DIM status
102 *
103 * @client: the i2c client
104 * @dim: either LP3944_DIM0 or LP3944_DIM1
105 * @period: period of a blink, that is a on/off cycle, expressed in ms.
106 */
107static int lp3944_dim_set_period(struct i2c_client *client, u8 dim, u16 period)
108{
109 u8 psc_reg;
110 u8 psc_value;
111 int err;
112
113 if (dim == LP3944_DIM0)
114 psc_reg = LP3944_REG_PSC0;
115 else if (dim == LP3944_DIM1)
116 psc_reg = LP3944_REG_PSC1;
117 else
118 return -EINVAL;
119
120 /* Convert period to Prescaler value */
121 if (period > LP3944_PERIOD_MAX)
122 return -EINVAL;
123
124 psc_value = (period * 255) / LP3944_PERIOD_MAX;
125
126 err = lp3944_reg_write(client, psc_reg, psc_value);
127
128 return err;
129}
130
131/**
132 * Set the duty cycle for DIM status
133 *
134 * @client: the i2c client
135 * @dim: either LP3944_DIM0 or LP3944_DIM1
136 * @duty_cycle: percentage of a period during which a led is ON
137 */
138static int lp3944_dim_set_dutycycle(struct i2c_client *client, u8 dim,
139 u8 duty_cycle)
140{
141 u8 pwm_reg;
142 u8 pwm_value;
143 int err;
144
145 if (dim == LP3944_DIM0)
146 pwm_reg = LP3944_REG_PWM0;
147 else if (dim == LP3944_DIM1)
148 pwm_reg = LP3944_REG_PWM1;
149 else
150 return -EINVAL;
151
152 /* Convert duty cycle to PWM value */
153 if (duty_cycle > LP3944_DUTY_CYCLE_MAX)
154 return -EINVAL;
155
156 pwm_value = (duty_cycle * 255) / LP3944_DUTY_CYCLE_MAX;
157
158 err = lp3944_reg_write(client, pwm_reg, pwm_value);
159
160 return err;
161}
162
163/**
164 * Set the led status
165 *
166 * @led: a lp3944_led_data structure
167 * @status: one of LP3944_LED_STATUS_OFF
168 * LP3944_LED_STATUS_ON
169 * LP3944_LED_STATUS_DIM0
170 * LP3944_LED_STATUS_DIM1
171 */
172static int lp3944_led_set(struct lp3944_led_data *led, u8 status)
173{
174 struct lp3944_data *data = i2c_get_clientdata(led->client);
175 u8 id = led->id;
176 u8 reg;
177 u8 val = 0;
178 int err;
179
180 dev_dbg(&led->client->dev, "%s: %s, status before normalization:%d\n",
181 __func__, led->ldev.name, status);
182
183 switch (id) {
184 case LP3944_LED0:
185 case LP3944_LED1:
186 case LP3944_LED2:
187 case LP3944_LED3:
188 reg = LP3944_REG_LS0;
189 break;
190 case LP3944_LED4:
191 case LP3944_LED5:
192 case LP3944_LED6:
193 case LP3944_LED7:
194 id -= LP3944_LED4;
195 reg = LP3944_REG_LS1;
196 break;
197 default:
198 return -EINVAL;
199 }
200
201 if (status > LP3944_LED_STATUS_DIM1)
202 return -EINVAL;
203
204 /* invert only 0 and 1, leave unchanged the other values,
205 * remember we are abusing status to set blink patterns
206 */
207 if (led->type == LP3944_LED_TYPE_LED_INVERTED && status < 2)
208 status = 1 - status;
209
210 mutex_lock(&data->lock);
211 lp3944_reg_read(led->client, reg, &val);
212
213 val &= ~(LP3944_LED_STATUS_MASK << (id << 1));
214 val |= (status << (id << 1));
215
216 dev_dbg(&led->client->dev, "%s: %s, reg:%d id:%d status:%d val:%#x\n",
217 __func__, led->ldev.name, reg, id, status, val);
218
219 /* set led status */
220 err = lp3944_reg_write(led->client, reg, val);
221 mutex_unlock(&data->lock);
222
223 return err;
224}
225
226static int lp3944_led_set_blink(struct led_classdev *led_cdev,
227 unsigned long *delay_on,
228 unsigned long *delay_off)
229{
230 struct lp3944_led_data *led = ldev_to_led(led_cdev);
231 u16 period;
232 u8 duty_cycle;
233 int err;
234
235 /* units are in ms */
236 if (*delay_on + *delay_off > LP3944_PERIOD_MAX)
237 return -EINVAL;
238
239 if (*delay_on == 0 && *delay_off == 0) {
240 /* Special case: the leds subsystem requires a default user
241 * friendly blink pattern for the LED. Let's blink the led
242 * slowly (1Hz).
243 */
244 *delay_on = 500;
245 *delay_off = 500;
246 }
247
248 period = (*delay_on) + (*delay_off);
249
250 /* duty_cycle is the percentage of period during which the led is ON */
251 duty_cycle = 100 * (*delay_on) / period;
252
253 /* invert duty cycle for inverted leds, this has the same effect of
254 * swapping delay_on and delay_off
255 */
256 if (led->type == LP3944_LED_TYPE_LED_INVERTED)
257 duty_cycle = 100 - duty_cycle;
258
259 /* NOTE: using always the first DIM mode, this means that all leds
260 * will have the same blinking pattern.
261 *
262 * We could find a way later to have two leds blinking in hardware
263 * with different patterns at the same time, falling back to software
264 * control for the other ones.
265 */
266 err = lp3944_dim_set_period(led->client, LP3944_DIM0, period);
267 if (err)
268 return err;
269
270 err = lp3944_dim_set_dutycycle(led->client, LP3944_DIM0, duty_cycle);
271 if (err)
272 return err;
273
274 dev_dbg(&led->client->dev, "%s: OK hardware accelerated blink!\n",
275 __func__);
276
277 led->status = LP3944_LED_STATUS_DIM0;
278 schedule_work(&led->work);
279
280 return 0;
281}
282
283static void lp3944_led_set_brightness(struct led_classdev *led_cdev,
284 enum led_brightness brightness)
285{
286 struct lp3944_led_data *led = ldev_to_led(led_cdev);
287
288 dev_dbg(&led->client->dev, "%s: %s, %d\n",
289 __func__, led_cdev->name, brightness);
290
291 led->status = brightness;
292 schedule_work(&led->work);
293}
294
295static void lp3944_led_work(struct work_struct *work)
296{
297 struct lp3944_led_data *led;
298
299 led = container_of(work, struct lp3944_led_data, work);
300 lp3944_led_set(led, led->status);
301}
302
303static int lp3944_configure(struct i2c_client *client,
304 struct lp3944_data *data,
305 struct lp3944_platform_data *pdata)
306{
307 int i, err = 0;
308
309 for (i = 0; i < pdata->leds_size; i++) {
310 struct lp3944_led *pled = &pdata->leds[i];
311 struct lp3944_led_data *led = &data->leds[i];
312 led->client = client;
313 led->id = i;
314
315 switch (pled->type) {
316
317 case LP3944_LED_TYPE_LED:
318 case LP3944_LED_TYPE_LED_INVERTED:
319 led->type = pled->type;
320 led->status = pled->status;
321 led->ldev.name = pled->name;
322 led->ldev.max_brightness = 1;
323 led->ldev.brightness_set = lp3944_led_set_brightness;
324 led->ldev.blink_set = lp3944_led_set_blink;
325 led->ldev.flags = LED_CORE_SUSPENDRESUME;
326
327 INIT_WORK(&led->work, lp3944_led_work);
328 err = led_classdev_register(&client->dev, &led->ldev);
329 if (err < 0) {
330 dev_err(&client->dev,
331 "couldn't register LED %s\n",
332 led->ldev.name);
333 goto exit;
334 }
335
336 /* to expose the default value to userspace */
337 led->ldev.brightness = led->status;
338
339 /* Set the default led status */
340 err = lp3944_led_set(led, led->status);
341 if (err < 0) {
342 dev_err(&client->dev,
343 "%s couldn't set STATUS %d\n",
344 led->ldev.name, led->status);
345 goto exit;
346 }
347 break;
348
349 case LP3944_LED_TYPE_NONE:
350 default:
351 break;
352
353 }
354 }
355 return 0;
356
357exit:
358 if (i > 0)
359 for (i = i - 1; i >= 0; i--)
360 switch (pdata->leds[i].type) {
361
362 case LP3944_LED_TYPE_LED:
363 case LP3944_LED_TYPE_LED_INVERTED:
364 led_classdev_unregister(&data->leds[i].ldev);
365 cancel_work_sync(&data->leds[i].work);
366 break;
367
368 case LP3944_LED_TYPE_NONE:
369 default:
370 break;
371 }
372
373 return err;
374}
375
376static int __devinit lp3944_probe(struct i2c_client *client,
377 const struct i2c_device_id *id)
378{
379 struct lp3944_platform_data *lp3944_pdata = client->dev.platform_data;
380 struct lp3944_data *data;
381
382 if (lp3944_pdata == NULL) {
383 dev_err(&client->dev, "no platform data\n");
384 return -EINVAL;
385 }
386
387 /* Let's see whether this adapter can support what we need. */
388 if (!i2c_check_functionality(client->adapter,
389 I2C_FUNC_SMBUS_BYTE_DATA)) {
390 dev_err(&client->dev, "insufficient functionality!\n");
391 return -ENODEV;
392 }
393
394 data = kzalloc(sizeof(struct lp3944_data), GFP_KERNEL);
395 if (!data)
396 return -ENOMEM;
397
398 data->client = client;
399 i2c_set_clientdata(client, data);
400
401 mutex_init(&data->lock);
402
403 dev_info(&client->dev, "lp3944 enabled\n");
404
405 lp3944_configure(client, data, lp3944_pdata);
406 return 0;
407}
408
409static int __devexit lp3944_remove(struct i2c_client *client)
410{
411 struct lp3944_platform_data *pdata = client->dev.platform_data;
412 struct lp3944_data *data = i2c_get_clientdata(client);
413 int i;
414
415 for (i = 0; i < pdata->leds_size; i++)
416 switch (data->leds[i].type) {
417 case LP3944_LED_TYPE_LED:
418 case LP3944_LED_TYPE_LED_INVERTED:
419 led_classdev_unregister(&data->leds[i].ldev);
420 cancel_work_sync(&data->leds[i].work);
421 break;
422
423 case LP3944_LED_TYPE_NONE:
424 default:
425 break;
426 }
427
428 kfree(data);
429 i2c_set_clientdata(client, NULL);
430
431 return 0;
432}
433
434/* lp3944 i2c driver struct */
435static const struct i2c_device_id lp3944_id[] = {
436 {"lp3944", 0},
437 {}
438};
439
440MODULE_DEVICE_TABLE(i2c, lp3944_id);
441
442static struct i2c_driver lp3944_driver = {
443 .driver = {
444 .name = "lp3944",
445 },
446 .probe = lp3944_probe,
447 .remove = __devexit_p(lp3944_remove),
448 .id_table = lp3944_id,
449};
450
451static int __init lp3944_module_init(void)
452{
453 return i2c_add_driver(&lp3944_driver);
454}
455
456static void __exit lp3944_module_exit(void)
457{
458 i2c_del_driver(&lp3944_driver);
459}
460
461module_init(lp3944_module_init);
462module_exit(lp3944_module_exit);
463
464MODULE_AUTHOR("Antonio Ospite <ospite@studenti.unina.it>");
465MODULE_DESCRIPTION("LP3944 Fun Light Chip");
466MODULE_LICENSE("GPL");
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index 3937244fdcab..dba8921240f2 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -35,7 +35,7 @@ struct pca9532_data {
35 struct pca9532_led leds[16]; 35 struct pca9532_led leds[16];
36 struct mutex update_lock; 36 struct mutex update_lock;
37 struct input_dev *idev; 37 struct input_dev *idev;
38 struct work_struct work; 38 struct work_struct work;
39 u8 pwm[2]; 39 u8 pwm[2];
40 u8 psc[2]; 40 u8 psc[2];
41}; 41};
@@ -87,14 +87,14 @@ static int pca9532_calcpwm(struct i2c_client *client, int pwm, int blink,
87 if (b > 0xFF) 87 if (b > 0xFF)
88 return -EINVAL; 88 return -EINVAL;
89 data->pwm[pwm] = b; 89 data->pwm[pwm] = b;
90 data->psc[pwm] = blink; 90 data->psc[pwm] = blink;
91 return 0; 91 return 0;
92} 92}
93 93
94static int pca9532_setpwm(struct i2c_client *client, int pwm) 94static int pca9532_setpwm(struct i2c_client *client, int pwm)
95{ 95{
96 struct pca9532_data *data = i2c_get_clientdata(client); 96 struct pca9532_data *data = i2c_get_clientdata(client);
97 mutex_lock(&data->update_lock); 97 mutex_lock(&data->update_lock);
98 i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(pwm), 98 i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(pwm),
99 data->pwm[pwm]); 99 data->pwm[pwm]);
100 i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(pwm), 100 i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(pwm),
@@ -132,11 +132,11 @@ static void pca9532_set_brightness(struct led_classdev *led_cdev,
132 led->state = PCA9532_ON; 132 led->state = PCA9532_ON;
133 else { 133 else {
134 led->state = PCA9532_PWM0; /* Thecus: hardcode one pwm */ 134 led->state = PCA9532_PWM0; /* Thecus: hardcode one pwm */
135 err = pca9532_calcpwm(led->client, 0, 0, value); 135 err = pca9532_calcpwm(led->client, 0, 0, value);
136 if (err) 136 if (err)
137 return; /* XXX: led api doesn't allow error code? */ 137 return; /* XXX: led api doesn't allow error code? */
138 } 138 }
139 schedule_work(&led->work); 139 schedule_work(&led->work);
140} 140}
141 141
142static int pca9532_set_blink(struct led_classdev *led_cdev, 142static int pca9532_set_blink(struct led_classdev *led_cdev,
@@ -145,7 +145,7 @@ static int pca9532_set_blink(struct led_classdev *led_cdev,
145 struct pca9532_led *led = ldev_to_led(led_cdev); 145 struct pca9532_led *led = ldev_to_led(led_cdev);
146 struct i2c_client *client = led->client; 146 struct i2c_client *client = led->client;
147 int psc; 147 int psc;
148 int err = 0; 148 int err = 0;
149 149
150 if (*delay_on == 0 && *delay_off == 0) { 150 if (*delay_on == 0 && *delay_off == 0) {
151 /* led subsystem ask us for a blink rate */ 151 /* led subsystem ask us for a blink rate */
@@ -157,11 +157,11 @@ static int pca9532_set_blink(struct led_classdev *led_cdev,
157 157
158 /* Thecus specific: only use PSC/PWM 0 */ 158 /* Thecus specific: only use PSC/PWM 0 */
159 psc = (*delay_on * 152-1)/1000; 159 psc = (*delay_on * 152-1)/1000;
160 err = pca9532_calcpwm(client, 0, psc, led_cdev->brightness); 160 err = pca9532_calcpwm(client, 0, psc, led_cdev->brightness);
161 if (err) 161 if (err)
162 return err; 162 return err;
163 schedule_work(&led->work); 163 schedule_work(&led->work);
164 return 0; 164 return 0;
165} 165}
166 166
167static int pca9532_event(struct input_dev *dev, unsigned int type, 167static int pca9532_event(struct input_dev *dev, unsigned int type,
@@ -178,15 +178,15 @@ static int pca9532_event(struct input_dev *dev, unsigned int type,
178 else 178 else
179 data->pwm[1] = 0; 179 data->pwm[1] = 0;
180 180
181 schedule_work(&data->work); 181 schedule_work(&data->work);
182 182
183 return 0; 183 return 0;
184} 184}
185 185
186static void pca9532_input_work(struct work_struct *work) 186static void pca9532_input_work(struct work_struct *work)
187{ 187{
188 struct pca9532_data *data; 188 struct pca9532_data *data;
189 data = container_of(work, struct pca9532_data, work); 189 data = container_of(work, struct pca9532_data, work);
190 mutex_lock(&data->update_lock); 190 mutex_lock(&data->update_lock);
191 i2c_smbus_write_byte_data(data->client, PCA9532_REG_PWM(1), 191 i2c_smbus_write_byte_data(data->client, PCA9532_REG_PWM(1),
192 data->pwm[1]); 192 data->pwm[1]);
@@ -195,11 +195,11 @@ static void pca9532_input_work(struct work_struct *work)
195 195
196static void pca9532_led_work(struct work_struct *work) 196static void pca9532_led_work(struct work_struct *work)
197{ 197{
198 struct pca9532_led *led; 198 struct pca9532_led *led;
199 led = container_of(work, struct pca9532_led, work); 199 led = container_of(work, struct pca9532_led, work);
200 if (led->state == PCA9532_PWM0) 200 if (led->state == PCA9532_PWM0)
201 pca9532_setpwm(led->client, 0); 201 pca9532_setpwm(led->client, 0);
202 pca9532_setled(led); 202 pca9532_setled(led);
203} 203}
204 204
205static int pca9532_configure(struct i2c_client *client, 205static int pca9532_configure(struct i2c_client *client,
@@ -232,7 +232,7 @@ static int pca9532_configure(struct i2c_client *client,
232 led->ldev.brightness = LED_OFF; 232 led->ldev.brightness = LED_OFF;
233 led->ldev.brightness_set = pca9532_set_brightness; 233 led->ldev.brightness_set = pca9532_set_brightness;
234 led->ldev.blink_set = pca9532_set_blink; 234 led->ldev.blink_set = pca9532_set_blink;
235 INIT_WORK(&led->work, pca9532_led_work); 235 INIT_WORK(&led->work, pca9532_led_work);
236 err = led_classdev_register(&client->dev, &led->ldev); 236 err = led_classdev_register(&client->dev, &led->ldev);
237 if (err < 0) { 237 if (err < 0) {
238 dev_err(&client->dev, 238 dev_err(&client->dev,
@@ -262,11 +262,11 @@ static int pca9532_configure(struct i2c_client *client,
262 BIT_MASK(SND_TONE); 262 BIT_MASK(SND_TONE);
263 data->idev->event = pca9532_event; 263 data->idev->event = pca9532_event;
264 input_set_drvdata(data->idev, data); 264 input_set_drvdata(data->idev, data);
265 INIT_WORK(&data->work, pca9532_input_work); 265 INIT_WORK(&data->work, pca9532_input_work);
266 err = input_register_device(data->idev); 266 err = input_register_device(data->idev);
267 if (err) { 267 if (err) {
268 input_free_device(data->idev); 268 input_free_device(data->idev);
269 cancel_work_sync(&data->work); 269 cancel_work_sync(&data->work);
270 data->idev = NULL; 270 data->idev = NULL;
271 goto exit; 271 goto exit;
272 } 272 }
@@ -283,13 +283,13 @@ exit:
283 break; 283 break;
284 case PCA9532_TYPE_LED: 284 case PCA9532_TYPE_LED:
285 led_classdev_unregister(&data->leds[i].ldev); 285 led_classdev_unregister(&data->leds[i].ldev);
286 cancel_work_sync(&data->leds[i].work); 286 cancel_work_sync(&data->leds[i].work);
287 break; 287 break;
288 case PCA9532_TYPE_N2100_BEEP: 288 case PCA9532_TYPE_N2100_BEEP:
289 if (data->idev != NULL) { 289 if (data->idev != NULL) {
290 input_unregister_device(data->idev); 290 input_unregister_device(data->idev);
291 input_free_device(data->idev); 291 input_free_device(data->idev);
292 cancel_work_sync(&data->work); 292 cancel_work_sync(&data->work);
293 data->idev = NULL; 293 data->idev = NULL;
294 } 294 }
295 break; 295 break;
@@ -340,13 +340,13 @@ static int pca9532_remove(struct i2c_client *client)
340 break; 340 break;
341 case PCA9532_TYPE_LED: 341 case PCA9532_TYPE_LED:
342 led_classdev_unregister(&data->leds[i].ldev); 342 led_classdev_unregister(&data->leds[i].ldev);
343 cancel_work_sync(&data->leds[i].work); 343 cancel_work_sync(&data->leds[i].work);
344 break; 344 break;
345 case PCA9532_TYPE_N2100_BEEP: 345 case PCA9532_TYPE_N2100_BEEP:
346 if (data->idev != NULL) { 346 if (data->idev != NULL) {
347 input_unregister_device(data->idev); 347 input_unregister_device(data->idev);
348 input_free_device(data->idev); 348 input_free_device(data->idev);
349 cancel_work_sync(&data->work); 349 cancel_work_sync(&data->work);
350 data->idev = NULL; 350 data->idev = NULL;
351 } 351 }
352 break; 352 break;
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index d4e8979735cb..9c3138265f8e 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -82,7 +82,7 @@ struct lg_cpu {
82 82
83struct lg_eventfd { 83struct lg_eventfd {
84 unsigned long addr; 84 unsigned long addr;
85 struct file *event; 85 struct eventfd_ctx *event;
86}; 86};
87 87
88struct lg_eventfd_map { 88struct lg_eventfd_map {
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 32e297121058..9f9a2953b383 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -50,7 +50,7 @@ static int add_eventfd(struct lguest *lg, unsigned long addr, int fd)
50 50
51 /* Now append new entry. */ 51 /* Now append new entry. */
52 new->map[new->num].addr = addr; 52 new->map[new->num].addr = addr;
53 new->map[new->num].event = eventfd_fget(fd); 53 new->map[new->num].event = eventfd_ctx_fdget(fd);
54 if (IS_ERR(new->map[new->num].event)) { 54 if (IS_ERR(new->map[new->num].event)) {
55 kfree(new); 55 kfree(new);
56 return PTR_ERR(new->map[new->num].event); 56 return PTR_ERR(new->map[new->num].event);
@@ -357,7 +357,7 @@ static int close(struct inode *inode, struct file *file)
357 357
358 /* Release any eventfds they registered. */ 358 /* Release any eventfds they registered. */
359 for (i = 0; i < lg->eventfds->num; i++) 359 for (i = 0; i < lg->eventfds->num; i++)
360 fput(lg->eventfds->map[i].event); 360 eventfd_ctx_put(lg->eventfds->map[i].event);
361 kfree(lg->eventfds); 361 kfree(lg->eventfds);
362 362
363 /* If lg->dead doesn't contain an error code it will be NULL or a 363 /* If lg->dead doesn't contain an error code it will be NULL or a
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 6e149f4a1fff..a0f68386c12f 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -378,6 +378,17 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
378 dev->ofdev.dev.bus = &macio_bus_type; 378 dev->ofdev.dev.bus = &macio_bus_type;
379 dev->ofdev.dev.release = macio_release_dev; 379 dev->ofdev.dev.release = macio_release_dev;
380 380
381#ifdef CONFIG_PCI
382 /* Set the DMA ops to the ones from the PCI device, this could be
383 * fishy if we didn't know that on PowerMac it's always direct ops
384 * or iommu ops that will work fine
385 */
386 dev->ofdev.dev.archdata.dma_ops =
387 chip->lbus.pdev->dev.archdata.dma_ops;
388 dev->ofdev.dev.archdata.dma_data =
389 chip->lbus.pdev->dev.archdata.dma_data;
390#endif /* CONFIG_PCI */
391
381#ifdef DEBUG 392#ifdef DEBUG
382 printk("preparing mdev @%p, ofdev @%p, dev @%p, kobj @%p\n", 393 printk("preparing mdev @%p, ofdev @%p, dev @%p, kobj @%p\n",
383 dev, &dev->ofdev, &dev->ofdev.dev, &dev->ofdev.dev.kobj); 394 dev, &dev->ofdev, &dev->ofdev.dev, &dev->ofdev.dev.kobj);
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 9933eb861c71..529e2ba505c3 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -776,7 +776,7 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
776 * But don't wait if split was due to the io size restriction 776 * But don't wait if split was due to the io size restriction
777 */ 777 */
778 if (unlikely(out_of_pages)) 778 if (unlikely(out_of_pages))
779 congestion_wait(WRITE, HZ/100); 779 congestion_wait(BLK_RW_ASYNC, HZ/100);
780 780
781 /* 781 /*
782 * With async crypto it is unsafe to share the crypto context 782 * With async crypto it is unsafe to share the crypto context
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index c3ae51584b12..3710ff88fc10 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -195,7 +195,7 @@ int dm_exception_store_create(struct dm_target *ti, int argc, char **argv,
195 struct dm_exception_store **store) 195 struct dm_exception_store **store)
196{ 196{
197 int r = 0; 197 int r = 0;
198 struct dm_exception_store_type *type; 198 struct dm_exception_store_type *type = NULL;
199 struct dm_exception_store *tmp_store; 199 struct dm_exception_store *tmp_store;
200 char persistent; 200 char persistent;
201 201
@@ -211,12 +211,15 @@ int dm_exception_store_create(struct dm_target *ti, int argc, char **argv,
211 } 211 }
212 212
213 persistent = toupper(*argv[1]); 213 persistent = toupper(*argv[1]);
214 if (persistent != 'P' && persistent != 'N') { 214 if (persistent == 'P')
215 type = get_type("P");
216 else if (persistent == 'N')
217 type = get_type("N");
218 else {
215 ti->error = "Persistent flag is not P or N"; 219 ti->error = "Persistent flag is not P or N";
216 return -EINVAL; 220 return -EINVAL;
217 } 221 }
218 222
219 type = get_type(&persistent);
220 if (!type) { 223 if (!type) {
221 ti->error = "Exception store type not recognised"; 224 ti->error = "Exception store type not recognised";
222 r = -EINVAL; 225 r = -EINVAL;
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 4899ebe767c8..2cba557d9e61 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -495,7 +495,7 @@ int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
495 return 0; 495 return 0;
496 } 496 }
497 497
498 if (blk_stack_limits(limits, &q->limits, start) < 0) 498 if (blk_stack_limits(limits, &q->limits, start << 9) < 0)
499 DMWARN("%s: target device %s is misaligned", 499 DMWARN("%s: target device %s is misaligned",
500 dm_device_name(ti->table->md), bdevname(bdev, b)); 500 dm_device_name(ti->table->md), bdevname(bdev, b));
501 501
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 3c6d4ee8921d..9acd54a5cffb 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1017,7 +1017,7 @@ static struct bio *split_bvec(struct bio *bio, sector_t sector,
1017 clone->bi_flags |= 1 << BIO_CLONED; 1017 clone->bi_flags |= 1 << BIO_CLONED;
1018 1018
1019 if (bio_integrity(bio)) { 1019 if (bio_integrity(bio)) {
1020 bio_integrity_clone(clone, bio, GFP_NOIO); 1020 bio_integrity_clone(clone, bio, GFP_NOIO, bs);
1021 bio_integrity_trim(clone, 1021 bio_integrity_trim(clone,
1022 bio_sector_offset(bio, idx, offset), len); 1022 bio_sector_offset(bio, idx, offset), len);
1023 } 1023 }
@@ -1045,7 +1045,7 @@ static struct bio *clone_bio(struct bio *bio, sector_t sector,
1045 clone->bi_flags &= ~(1 << BIO_SEG_VALID); 1045 clone->bi_flags &= ~(1 << BIO_SEG_VALID);
1046 1046
1047 if (bio_integrity(bio)) { 1047 if (bio_integrity(bio)) {
1048 bio_integrity_clone(clone, bio, GFP_NOIO); 1048 bio_integrity_clone(clone, bio, GFP_NOIO, bs);
1049 1049
1050 if (idx != bio->bi_idx || clone->bi_size < bio->bi_size) 1050 if (idx != bio->bi_idx || clone->bi_size < bio->bi_size)
1051 bio_integrity_trim(clone, 1051 bio_integrity_trim(clone,
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 15c8b7b25a9b..5810fa906af0 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -166,8 +166,8 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
166 rdev->sectors = sectors * mddev->chunk_sectors; 166 rdev->sectors = sectors * mddev->chunk_sectors;
167 } 167 }
168 168
169 blk_queue_stack_limits(mddev->queue, 169 disk_stack_limits(mddev->gendisk, rdev->bdev,
170 rdev->bdev->bd_disk->queue); 170 rdev->data_offset << 9);
171 /* as we don't honour merge_bvec_fn, we must never risk 171 /* as we don't honour merge_bvec_fn, we must never risk
172 * violating it, so limit ->max_sector to one PAGE, as 172 * violating it, so limit ->max_sector to one PAGE, as
173 * a one page request is never in violation. 173 * a one page request is never in violation.
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 09be637d52cb..d4351ff0849f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1756,9 +1756,10 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
1756 __u8 *uuid; 1756 __u8 *uuid;
1757 1757
1758 uuid = sb->set_uuid; 1758 uuid = sb->set_uuid;
1759 printk(KERN_INFO "md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x" 1759 printk(KERN_INFO
1760 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n" 1760 "md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x"
1761 KERN_INFO "md: Name: \"%s\" CT:%llu\n", 1761 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n"
1762 "md: Name: \"%s\" CT:%llu\n",
1762 le32_to_cpu(sb->major_version), 1763 le32_to_cpu(sb->major_version),
1763 le32_to_cpu(sb->feature_map), 1764 le32_to_cpu(sb->feature_map),
1764 uuid[0], uuid[1], uuid[2], uuid[3], 1765 uuid[0], uuid[1], uuid[2], uuid[3],
@@ -1770,12 +1771,13 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
1770 & MD_SUPERBLOCK_1_TIME_SEC_MASK); 1771 & MD_SUPERBLOCK_1_TIME_SEC_MASK);
1771 1772
1772 uuid = sb->device_uuid; 1773 uuid = sb->device_uuid;
1773 printk(KERN_INFO "md: L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu" 1774 printk(KERN_INFO
1775 "md: L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu"
1774 " RO:%llu\n" 1776 " RO:%llu\n"
1775 KERN_INFO "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x" 1777 "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x"
1776 ":%02x%02x%02x%02x%02x%02x\n" 1778 ":%02x%02x%02x%02x%02x%02x\n"
1777 KERN_INFO "md: (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n" 1779 "md: (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n"
1778 KERN_INFO "md: (MaxDev:%u) \n", 1780 "md: (MaxDev:%u) \n",
1779 le32_to_cpu(sb->level), 1781 le32_to_cpu(sb->level),
1780 (unsigned long long)le64_to_cpu(sb->size), 1782 (unsigned long long)le64_to_cpu(sb->size),
1781 le32_to_cpu(sb->raid_disks), 1783 le32_to_cpu(sb->raid_disks),
@@ -3573,7 +3575,8 @@ suspend_lo_store(mddev_t *mddev, const char *buf, size_t len)
3573 char *e; 3575 char *e;
3574 unsigned long long new = simple_strtoull(buf, &e, 10); 3576 unsigned long long new = simple_strtoull(buf, &e, 10);
3575 3577
3576 if (mddev->pers->quiesce == NULL) 3578 if (mddev->pers == NULL ||
3579 mddev->pers->quiesce == NULL)
3577 return -EINVAL; 3580 return -EINVAL;
3578 if (buf == e || (*e && *e != '\n')) 3581 if (buf == e || (*e && *e != '\n'))
3579 return -EINVAL; 3582 return -EINVAL;
@@ -3601,7 +3604,8 @@ suspend_hi_store(mddev_t *mddev, const char *buf, size_t len)
3601 char *e; 3604 char *e;
3602 unsigned long long new = simple_strtoull(buf, &e, 10); 3605 unsigned long long new = simple_strtoull(buf, &e, 10);
3603 3606
3604 if (mddev->pers->quiesce == NULL) 3607 if (mddev->pers == NULL ||
3608 mddev->pers->quiesce == NULL)
3605 return -EINVAL; 3609 return -EINVAL;
3606 if (buf == e || (*e && *e != '\n')) 3610 if (buf == e || (*e && *e != '\n'))
3607 return -EINVAL; 3611 return -EINVAL;
@@ -3844,11 +3848,9 @@ static int md_alloc(dev_t dev, char *name)
3844 flush_scheduled_work(); 3848 flush_scheduled_work();
3845 3849
3846 mutex_lock(&disks_mutex); 3850 mutex_lock(&disks_mutex);
3847 if (mddev->gendisk) { 3851 error = -EEXIST;
3848 mutex_unlock(&disks_mutex); 3852 if (mddev->gendisk)
3849 mddev_put(mddev); 3853 goto abort;
3850 return -EEXIST;
3851 }
3852 3854
3853 if (name) { 3855 if (name) {
3854 /* Need to ensure that 'name' is not a duplicate. 3856 /* Need to ensure that 'name' is not a duplicate.
@@ -3860,17 +3862,15 @@ static int md_alloc(dev_t dev, char *name)
3860 if (mddev2->gendisk && 3862 if (mddev2->gendisk &&
3861 strcmp(mddev2->gendisk->disk_name, name) == 0) { 3863 strcmp(mddev2->gendisk->disk_name, name) == 0) {
3862 spin_unlock(&all_mddevs_lock); 3864 spin_unlock(&all_mddevs_lock);
3863 return -EEXIST; 3865 goto abort;
3864 } 3866 }
3865 spin_unlock(&all_mddevs_lock); 3867 spin_unlock(&all_mddevs_lock);
3866 } 3868 }
3867 3869
3870 error = -ENOMEM;
3868 mddev->queue = blk_alloc_queue(GFP_KERNEL); 3871 mddev->queue = blk_alloc_queue(GFP_KERNEL);
3869 if (!mddev->queue) { 3872 if (!mddev->queue)
3870 mutex_unlock(&disks_mutex); 3873 goto abort;
3871 mddev_put(mddev);
3872 return -ENOMEM;
3873 }
3874 mddev->queue->queuedata = mddev; 3874 mddev->queue->queuedata = mddev;
3875 3875
3876 /* Can be unlocked because the queue is new: no concurrency */ 3876 /* Can be unlocked because the queue is new: no concurrency */
@@ -3880,11 +3880,9 @@ static int md_alloc(dev_t dev, char *name)
3880 3880
3881 disk = alloc_disk(1 << shift); 3881 disk = alloc_disk(1 << shift);
3882 if (!disk) { 3882 if (!disk) {
3883 mutex_unlock(&disks_mutex);
3884 blk_cleanup_queue(mddev->queue); 3883 blk_cleanup_queue(mddev->queue);
3885 mddev->queue = NULL; 3884 mddev->queue = NULL;
3886 mddev_put(mddev); 3885 goto abort;
3887 return -ENOMEM;
3888 } 3886 }
3889 disk->major = MAJOR(mddev->unit); 3887 disk->major = MAJOR(mddev->unit);
3890 disk->first_minor = unit << shift; 3888 disk->first_minor = unit << shift;
@@ -3906,16 +3904,22 @@ static int md_alloc(dev_t dev, char *name)
3906 mddev->gendisk = disk; 3904 mddev->gendisk = disk;
3907 error = kobject_init_and_add(&mddev->kobj, &md_ktype, 3905 error = kobject_init_and_add(&mddev->kobj, &md_ktype,
3908 &disk_to_dev(disk)->kobj, "%s", "md"); 3906 &disk_to_dev(disk)->kobj, "%s", "md");
3909 mutex_unlock(&disks_mutex); 3907 if (error) {
3910 if (error) 3908 /* This isn't possible, but as kobject_init_and_add is marked
3909 * __must_check, we must do something with the result
3910 */
3911 printk(KERN_WARNING "md: cannot register %s/md - name in use\n", 3911 printk(KERN_WARNING "md: cannot register %s/md - name in use\n",
3912 disk->disk_name); 3912 disk->disk_name);
3913 else { 3913 error = 0;
3914 }
3915 abort:
3916 mutex_unlock(&disks_mutex);
3917 if (!error) {
3914 kobject_uevent(&mddev->kobj, KOBJ_ADD); 3918 kobject_uevent(&mddev->kobj, KOBJ_ADD);
3915 mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state"); 3919 mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state");
3916 } 3920 }
3917 mddev_put(mddev); 3921 mddev_put(mddev);
3918 return 0; 3922 return error;
3919} 3923}
3920 3924
3921static struct kobject *md_probe(dev_t dev, int *part, void *data) 3925static struct kobject *md_probe(dev_t dev, int *part, void *data)
@@ -6334,10 +6338,16 @@ void md_do_sync(mddev_t *mddev)
6334 sysfs_notify(&mddev->kobj, NULL, "sync_completed"); 6338 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
6335 } 6339 }
6336 6340
6337 if (j >= mddev->resync_max) 6341 while (j >= mddev->resync_max && !kthread_should_stop()) {
6338 wait_event(mddev->recovery_wait, 6342 /* As this condition is controlled by user-space,
6339 mddev->resync_max > j 6343 * we can block indefinitely, so use '_interruptible'
6340 || kthread_should_stop()); 6344 * to avoid triggering warnings.
6345 */
6346 flush_signals(current); /* just in case */
6347 wait_event_interruptible(mddev->recovery_wait,
6348 mddev->resync_max > j
6349 || kthread_should_stop());
6350 }
6341 6351
6342 if (kthread_should_stop()) 6352 if (kthread_should_stop())
6343 goto interrupted; 6353 goto interrupted;
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index cbe368fa6598..237fe3fd235c 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -294,7 +294,8 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
294 for (path = first; path <= last; path++) 294 for (path = first; path <= last; path++)
295 if ((p=conf->multipaths+path)->rdev == NULL) { 295 if ((p=conf->multipaths+path)->rdev == NULL) {
296 q = rdev->bdev->bd_disk->queue; 296 q = rdev->bdev->bd_disk->queue;
297 blk_queue_stack_limits(mddev->queue, q); 297 disk_stack_limits(mddev->gendisk, rdev->bdev,
298 rdev->data_offset << 9);
298 299
299 /* as we don't honour merge_bvec_fn, we must never risk 300 /* as we don't honour merge_bvec_fn, we must never risk
300 * violating it, so limit ->max_sector to one PAGE, as 301 * violating it, so limit ->max_sector to one PAGE, as
@@ -463,9 +464,9 @@ static int multipath_run (mddev_t *mddev)
463 464
464 disk = conf->multipaths + disk_idx; 465 disk = conf->multipaths + disk_idx;
465 disk->rdev = rdev; 466 disk->rdev = rdev;
467 disk_stack_limits(mddev->gendisk, rdev->bdev,
468 rdev->data_offset << 9);
466 469
467 blk_queue_stack_limits(mddev->queue,
468 rdev->bdev->bd_disk->queue);
469 /* as we don't honour merge_bvec_fn, we must never risk 470 /* as we don't honour merge_bvec_fn, we must never risk
470 * violating it, not that we ever expect a device with 471 * violating it, not that we ever expect a device with
471 * a merge_bvec_fn to be involved in multipath */ 472 * a merge_bvec_fn to be involved in multipath */
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index ab4a489d8695..335f490dcad6 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -170,8 +170,8 @@ static int create_strip_zones(mddev_t *mddev)
170 } 170 }
171 dev[j] = rdev1; 171 dev[j] = rdev1;
172 172
173 blk_queue_stack_limits(mddev->queue, 173 disk_stack_limits(mddev->gendisk, rdev1->bdev,
174 rdev1->bdev->bd_disk->queue); 174 rdev1->data_offset << 9);
175 /* as we don't honour merge_bvec_fn, we must never risk 175 /* as we don't honour merge_bvec_fn, we must never risk
176 * violating it, so limit ->max_sector to one PAGE, as 176 * violating it, so limit ->max_sector to one PAGE, as
177 * a one page request is never in violation. 177 * a one page request is never in violation.
@@ -250,6 +250,11 @@ static int create_strip_zones(mddev_t *mddev)
250 mddev->chunk_sectors << 9); 250 mddev->chunk_sectors << 9);
251 goto abort; 251 goto abort;
252 } 252 }
253
254 blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9);
255 blk_queue_io_opt(mddev->queue,
256 (mddev->chunk_sectors << 9) * mddev->raid_disks);
257
253 printk(KERN_INFO "raid0: done.\n"); 258 printk(KERN_INFO "raid0: done.\n");
254 mddev->private = conf; 259 mddev->private = conf;
255 return 0; 260 return 0;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 89939a7aef57..0569efba0c02 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1123,8 +1123,8 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1123 for (mirror = first; mirror <= last; mirror++) 1123 for (mirror = first; mirror <= last; mirror++)
1124 if ( !(p=conf->mirrors+mirror)->rdev) { 1124 if ( !(p=conf->mirrors+mirror)->rdev) {
1125 1125
1126 blk_queue_stack_limits(mddev->queue, 1126 disk_stack_limits(mddev->gendisk, rdev->bdev,
1127 rdev->bdev->bd_disk->queue); 1127 rdev->data_offset << 9);
1128 /* as we don't honour merge_bvec_fn, we must never risk 1128 /* as we don't honour merge_bvec_fn, we must never risk
1129 * violating it, so limit ->max_sector to one PAGE, as 1129 * violating it, so limit ->max_sector to one PAGE, as
1130 * a one page request is never in violation. 1130 * a one page request is never in violation.
@@ -1988,9 +1988,8 @@ static int run(mddev_t *mddev)
1988 disk = conf->mirrors + disk_idx; 1988 disk = conf->mirrors + disk_idx;
1989 1989
1990 disk->rdev = rdev; 1990 disk->rdev = rdev;
1991 1991 disk_stack_limits(mddev->gendisk, rdev->bdev,
1992 blk_queue_stack_limits(mddev->queue, 1992 rdev->data_offset << 9);
1993 rdev->bdev->bd_disk->queue);
1994 /* as we don't honour merge_bvec_fn, we must never risk 1993 /* as we don't honour merge_bvec_fn, we must never risk
1995 * violating it, so limit ->max_sector to one PAGE, as 1994 * violating it, so limit ->max_sector to one PAGE, as
1996 * a one page request is never in violation. 1995 * a one page request is never in violation.
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index ae12ceafe10c..7298a5e5a183 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1151,8 +1151,8 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1151 for ( ; mirror <= last ; mirror++) 1151 for ( ; mirror <= last ; mirror++)
1152 if ( !(p=conf->mirrors+mirror)->rdev) { 1152 if ( !(p=conf->mirrors+mirror)->rdev) {
1153 1153
1154 blk_queue_stack_limits(mddev->queue, 1154 disk_stack_limits(mddev->gendisk, rdev->bdev,
1155 rdev->bdev->bd_disk->queue); 1155 rdev->data_offset << 9);
1156 /* as we don't honour merge_bvec_fn, we must never risk 1156 /* as we don't honour merge_bvec_fn, we must never risk
1157 * violating it, so limit ->max_sector to one PAGE, as 1157 * violating it, so limit ->max_sector to one PAGE, as
1158 * a one page request is never in violation. 1158 * a one page request is never in violation.
@@ -2044,7 +2044,7 @@ raid10_size(mddev_t *mddev, sector_t sectors, int raid_disks)
2044static int run(mddev_t *mddev) 2044static int run(mddev_t *mddev)
2045{ 2045{
2046 conf_t *conf; 2046 conf_t *conf;
2047 int i, disk_idx; 2047 int i, disk_idx, chunk_size;
2048 mirror_info_t *disk; 2048 mirror_info_t *disk;
2049 mdk_rdev_t *rdev; 2049 mdk_rdev_t *rdev;
2050 int nc, fc, fo; 2050 int nc, fc, fo;
@@ -2130,6 +2130,14 @@ static int run(mddev_t *mddev)
2130 spin_lock_init(&conf->device_lock); 2130 spin_lock_init(&conf->device_lock);
2131 mddev->queue->queue_lock = &conf->device_lock; 2131 mddev->queue->queue_lock = &conf->device_lock;
2132 2132
2133 chunk_size = mddev->chunk_sectors << 9;
2134 blk_queue_io_min(mddev->queue, chunk_size);
2135 if (conf->raid_disks % conf->near_copies)
2136 blk_queue_io_opt(mddev->queue, chunk_size * conf->raid_disks);
2137 else
2138 blk_queue_io_opt(mddev->queue, chunk_size *
2139 (conf->raid_disks / conf->near_copies));
2140
2133 list_for_each_entry(rdev, &mddev->disks, same_set) { 2141 list_for_each_entry(rdev, &mddev->disks, same_set) {
2134 disk_idx = rdev->raid_disk; 2142 disk_idx = rdev->raid_disk;
2135 if (disk_idx >= mddev->raid_disks 2143 if (disk_idx >= mddev->raid_disks
@@ -2138,9 +2146,8 @@ static int run(mddev_t *mddev)
2138 disk = conf->mirrors + disk_idx; 2146 disk = conf->mirrors + disk_idx;
2139 2147
2140 disk->rdev = rdev; 2148 disk->rdev = rdev;
2141 2149 disk_stack_limits(mddev->gendisk, rdev->bdev,
2142 blk_queue_stack_limits(mddev->queue, 2150 rdev->data_offset << 9);
2143 rdev->bdev->bd_disk->queue);
2144 /* as we don't honour merge_bvec_fn, we must never risk 2151 /* as we don't honour merge_bvec_fn, we must never risk
2145 * violating it, so limit ->max_sector to one PAGE, as 2152 * violating it, so limit ->max_sector to one PAGE, as
2146 * a one page request is never in violation. 2153 * a one page request is never in violation.
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index f9f991e6e138..37835538b58e 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3699,13 +3699,21 @@ static int make_request(struct request_queue *q, struct bio * bi)
3699 goto retry; 3699 goto retry;
3700 } 3700 }
3701 } 3701 }
3702 /* FIXME what if we get a false positive because these 3702
3703 * are being updated. 3703 if (bio_data_dir(bi) == WRITE &&
3704 */ 3704 logical_sector >= mddev->suspend_lo &&
3705 if (logical_sector >= mddev->suspend_lo &&
3706 logical_sector < mddev->suspend_hi) { 3705 logical_sector < mddev->suspend_hi) {
3707 release_stripe(sh); 3706 release_stripe(sh);
3708 schedule(); 3707 /* As the suspend_* range is controlled by
3708 * userspace, we want an interruptible
3709 * wait.
3710 */
3711 flush_signals(current);
3712 prepare_to_wait(&conf->wait_for_overlap,
3713 &w, TASK_INTERRUPTIBLE);
3714 if (logical_sector >= mddev->suspend_lo &&
3715 logical_sector < mddev->suspend_hi)
3716 schedule();
3709 goto retry; 3717 goto retry;
3710 } 3718 }
3711 3719
@@ -4452,7 +4460,7 @@ static raid5_conf_t *setup_conf(mddev_t *mddev)
4452static int run(mddev_t *mddev) 4460static int run(mddev_t *mddev)
4453{ 4461{
4454 raid5_conf_t *conf; 4462 raid5_conf_t *conf;
4455 int working_disks = 0; 4463 int working_disks = 0, chunk_size;
4456 mdk_rdev_t *rdev; 4464 mdk_rdev_t *rdev;
4457 4465
4458 if (mddev->recovery_cp != MaxSector) 4466 if (mddev->recovery_cp != MaxSector)
@@ -4607,6 +4615,14 @@ static int run(mddev_t *mddev)
4607 md_set_array_sectors(mddev, raid5_size(mddev, 0, 0)); 4615 md_set_array_sectors(mddev, raid5_size(mddev, 0, 0));
4608 4616
4609 blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec); 4617 blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec);
4618 chunk_size = mddev->chunk_sectors << 9;
4619 blk_queue_io_min(mddev->queue, chunk_size);
4620 blk_queue_io_opt(mddev->queue, chunk_size *
4621 (conf->raid_disks - conf->max_degraded));
4622
4623 list_for_each_entry(rdev, &mddev->disks, same_set)
4624 disk_stack_limits(mddev->gendisk, rdev->bdev,
4625 rdev->data_offset << 9);
4610 4626
4611 return 0; 4627 return 0;
4612abort: 4628abort:
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c
index b6da9c3873fe..aa20ce8cc668 100644
--- a/drivers/media/common/tuners/tuner-xc2028.c
+++ b/drivers/media/common/tuners/tuner-xc2028.c
@@ -1096,8 +1096,19 @@ static int xc2028_set_params(struct dvb_frontend *fe,
1096 } 1096 }
1097 1097
1098 /* All S-code tables need a 200kHz shift */ 1098 /* All S-code tables need a 200kHz shift */
1099 if (priv->ctrl.demod) 1099 if (priv->ctrl.demod) {
1100 demod = priv->ctrl.demod + 200; 1100 demod = priv->ctrl.demod + 200;
1101 /*
1102 * The DTV7 S-code table needs a 700 kHz shift.
1103 * Thanks to Terry Wu <terrywu2009@gmail.com> for reporting this
1104 *
1105 * DTV7 is only used in Australia. Germany or Italy may also
1106 * use this firmware after initialization, but a tune to a UHF
1107 * channel should then cause DTV78 to be used.
1108 */
1109 if (type & DTV7)
1110 demod += 500;
1111 }
1101 1112
1102 return generic_set_freq(fe, p->frequency, 1113 return generic_set_freq(fe, p->frequency,
1103 T_DIGITAL_TV, type, 0, demod); 1114 T_DIGITAL_TV, type, 0, demod);
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index 4601b059b2b2..0e246eaad05a 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -21,6 +21,7 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/smp_lock.h>
24#include <linux/string.h> 25#include <linux/string.h>
25#include <linux/dvb/ca.h> 26#include <linux/dvb/ca.h>
26#include "dvbdev.h" 27#include "dvbdev.h"
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index 79927305e84d..487919bea7ae 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -27,7 +27,6 @@
27#include <linux/poll.h> 27#include <linux/poll.h>
28#include <linux/fs.h> 28#include <linux/fs.h>
29#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/smp_lock.h>
31 30
32#define DVB_MAJOR 212 31#define DVB_MAJOR 212
33 32
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index 68eb4493f991..d8d4214fd65f 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -1,5 +1,6 @@
1config TTPCI_EEPROM 1config TTPCI_EEPROM
2 tristate 2 tristate
3 depends on I2C
3 default n 4 default n
4 5
5config DVB_AV7110 6config DVB_AV7110
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index d1d959ed37b7..8d65c652ba50 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -36,7 +36,6 @@
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/timer.h> 37#include <linux/timer.h>
38#include <linux/poll.h> 38#include <linux/poll.h>
39#include <linux/smp_lock.h>
40 39
41#include <linux/kernel.h> 40#include <linux/kernel.h>
42#include <linux/sched.h> 41#include <linux/sched.h>
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 837467f93805..575bf9d89419 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -58,6 +58,7 @@
58#include <linux/module.h> 58#include <linux/module.h>
59#include <linux/init.h> 59#include <linux/init.h>
60#include <linux/slab.h> 60#include <linux/slab.h>
61#include <linux/smp_lock.h>
61#include <linux/input.h> 62#include <linux/input.h>
62#include <linux/videodev2.h> 63#include <linux/videodev2.h>
63#include <media/v4l2-device.h> 64#include <media/v4l2-device.h>
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c
index 640421ceb24a..e85f318b4d2b 100644
--- a/drivers/media/radio/radio-si470x.c
+++ b/drivers/media/radio/radio-si470x.c
@@ -127,6 +127,7 @@
127#include <linux/module.h> 127#include <linux/module.h>
128#include <linux/init.h> 128#include <linux/init.h>
129#include <linux/slab.h> 129#include <linux/slab.h>
130#include <linux/smp_lock.h>
130#include <linux/input.h> 131#include <linux/input.h>
131#include <linux/usb.h> 132#include <linux/usb.h>
132#include <linux/hid.h> 133#include <linux/hid.h>
@@ -1200,7 +1201,7 @@ static int si470x_fops_release(struct file *file)
1200 video_unregister_device(radio->videodev); 1201 video_unregister_device(radio->videodev);
1201 kfree(radio->buffer); 1202 kfree(radio->buffer);
1202 kfree(radio); 1203 kfree(radio);
1203 goto done; 1204 goto unlock;
1204 } 1205 }
1205 1206
1206 /* stop rds reception */ 1207 /* stop rds reception */
@@ -1213,9 +1214,8 @@ static int si470x_fops_release(struct file *file)
1213 retval = si470x_stop(radio); 1214 retval = si470x_stop(radio);
1214 usb_autopm_put_interface(radio->intf); 1215 usb_autopm_put_interface(radio->intf);
1215 } 1216 }
1216 1217unlock:
1217 mutex_unlock(&radio->disconnect_lock); 1218 mutex_unlock(&radio->disconnect_lock);
1218
1219done: 1219done:
1220 return retval; 1220 return retval;
1221} 1221}
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 061e147f6f26..84b6fc15519d 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -312,6 +312,14 @@ config VIDEO_OV7670
312 OV7670 VGA camera. It currently only works with the M88ALP01 312 OV7670 VGA camera. It currently only works with the M88ALP01
313 controller. 313 controller.
314 314
315config VIDEO_MT9V011
316 tristate "Micron mt9v011 sensor support"
317 depends on I2C && VIDEO_V4L2
318 ---help---
319 This is a Video4Linux2 sensor-level driver for the Micron
320 mt0v011 1.3 Mpixel camera. It currently only works with the
321 em28xx driver.
322
315config VIDEO_TCM825X 323config VIDEO_TCM825X
316 tristate "TCM825x camera sensor support" 324 tristate "TCM825x camera sensor support"
317 depends on I2C && VIDEO_V4L2 325 depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 7fb3add1b387..9f2e3214a482 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
69obj-$(CONFIG_VIDEO_OV7670) += ov7670.o 69obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
70obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o 70obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o
71obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o 71obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
72obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o
72 73
73obj-$(CONFIG_SOC_CAMERA_MT9M001) += mt9m001.o 74obj-$(CONFIG_SOC_CAMERA_MT9M001) += mt9m001.o
74obj-$(CONFIG_SOC_CAMERA_MT9M111) += mt9m111.o 75obj-$(CONFIG_SOC_CAMERA_MT9M111) += mt9m111.o
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 5eb1464af670..d147d29bb0d3 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -41,6 +41,7 @@
41#include <linux/fs.h> 41#include <linux/fs.h>
42#include <linux/kernel.h> 42#include <linux/kernel.h>
43#include <linux/sched.h> 43#include <linux/sched.h>
44#include <linux/smp_lock.h>
44#include <linux/interrupt.h> 45#include <linux/interrupt.h>
45#include <linux/kdev_t.h> 46#include <linux/kdev_t.h>
46#include "bttvp.h" 47#include "bttvp.h"
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c
index c92a25036f0e..36f2d76006fd 100644
--- a/drivers/media/video/cx18/cx18-cards.c
+++ b/drivers/media/video/cx18/cx18-cards.c
@@ -198,11 +198,14 @@ static const struct cx18_card_pci_info cx18_pci_mpc718[] = {
198 198
199static const struct cx18_card cx18_card_mpc718 = { 199static const struct cx18_card cx18_card_mpc718 = {
200 .type = CX18_CARD_YUAN_MPC718, 200 .type = CX18_CARD_YUAN_MPC718,
201 .name = "Yuan MPC718", 201 .name = "Yuan MPC718 MiniPCI DVB-T/Analog",
202 .comment = "Analog video capture works; some audio line in may not.\n", 202 .comment = "Experimenters needed for device to work well.\n"
203 "\tTo help, mail the ivtv-devel list (www.ivtvdriver.org).\n",
203 .v4l2_capabilities = CX18_CAP_ENCODER, 204 .v4l2_capabilities = CX18_CAP_ENCODER,
204 .hw_audio_ctrl = CX18_HW_418_AV, 205 .hw_audio_ctrl = CX18_HW_418_AV,
205 .hw_all = CX18_HW_418_AV | CX18_HW_TUNER | CX18_HW_GPIO_RESET_CTRL, 206 .hw_muxer = CX18_HW_GPIO_MUX,
207 .hw_all = CX18_HW_418_AV | CX18_HW_TUNER |
208 CX18_HW_GPIO_MUX | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
206 .video_inputs = { 209 .video_inputs = {
207 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 }, 210 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
208 { CX18_CARD_INPUT_SVIDEO1, 1, 211 { CX18_CARD_INPUT_SVIDEO1, 1,
@@ -211,27 +214,34 @@ static const struct cx18_card cx18_card_mpc718 = {
211 { CX18_CARD_INPUT_SVIDEO2, 2, 214 { CX18_CARD_INPUT_SVIDEO2, 2,
212 CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 }, 215 CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
213 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 }, 216 { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
214 { CX18_CARD_INPUT_COMPOSITE3, 2, CX18_AV_COMPOSITE3 },
215 }, 217 },
216 .audio_inputs = { 218 .audio_inputs = {
217 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 }, 219 { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 },
218 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 0 }, 220 { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL1, 1 },
219 { CX18_CARD_INPUT_LINE_IN2, CX18_AV_AUDIO_SERIAL1, 0 }, 221 { CX18_CARD_INPUT_LINE_IN2, CX18_AV_AUDIO_SERIAL2, 1 },
220 }, 222 },
221 .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 0 },
222 .tuners = { 223 .tuners = {
223 /* XC3028 tuner */ 224 /* XC3028 tuner */
224 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, 225 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
225 }, 226 },
227 /* FIXME - the FM radio is just a guess and driver doesn't use SIF */
228 .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 2 },
226 .ddr = { 229 .ddr = {
227 /* Probably Samsung K4D263238G-VC33 memory */ 230 /* Hynix HY5DU283222B DDR RAM */
228 .chip_config = 0x003, 231 .chip_config = 0x303,
229 .refresh = 0x30c, 232 .refresh = 0x3bd,
230 .timing1 = 0x23230b73, 233 .timing1 = 0x36320966,
231 .timing2 = 0x08, 234 .timing2 = 0x1f,
232 .tune_lane = 0, 235 .tune_lane = 0,
233 .initial_emrs = 2, 236 .initial_emrs = 2,
234 }, 237 },
238 .gpio_init.initial_value = 0x1,
239 .gpio_init.direction = 0x3,
240 /* FIXME - these GPIO's are just guesses */
241 .gpio_audio_input = { .mask = 0x3,
242 .tuner = 0x1,
243 .linein = 0x3,
244 .radio = 0x1 },
235 .xceive_pin = 0, 245 .xceive_pin = 0,
236 .pci_list = cx18_pci_mpc718, 246 .pci_list = cx18_pci_mpc718,
237 .i2c = &cx18_i2c_std, 247 .i2c = &cx18_i2c_std,
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c
index 6ea3fe623ef4..51a0c33b25b7 100644
--- a/drivers/media/video/cx18/cx18-dvb.c
+++ b/drivers/media/video/cx18/cx18-dvb.c
@@ -30,6 +30,10 @@
30#include "s5h1409.h" 30#include "s5h1409.h"
31#include "mxl5005s.h" 31#include "mxl5005s.h"
32#include "zl10353.h" 32#include "zl10353.h"
33
34#include <linux/firmware.h>
35#include "mt352.h"
36#include "mt352_priv.h"
33#include "tuner-xc2028.h" 37#include "tuner-xc2028.h"
34 38
35DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 39DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
@@ -38,6 +42,11 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
38#define CX18_CLOCK_ENABLE2 0xc71024 42#define CX18_CLOCK_ENABLE2 0xc71024
39#define CX18_DMUX_CLK_MASK 0x0080 43#define CX18_DMUX_CLK_MASK 0x0080
40 44
45/*
46 * CX18_CARD_HVR_1600_ESMT
47 * CX18_CARD_HVR_1600_SAMSUNG
48 */
49
41static struct mxl5005s_config hauppauge_hvr1600_tuner = { 50static struct mxl5005s_config hauppauge_hvr1600_tuner = {
42 .i2c_address = 0xC6 >> 1, 51 .i2c_address = 0xC6 >> 1,
43 .if_freq = IF_FREQ_5380000HZ, 52 .if_freq = IF_FREQ_5380000HZ,
@@ -65,6 +74,9 @@ static struct s5h1409_config hauppauge_hvr1600_config = {
65 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK 74 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
66}; 75};
67 76
77/*
78 * CX18_CARD_LEADTEK_DVR3100H
79 */
68/* Information/confirmation of proper config values provided by Terry Wu */ 80/* Information/confirmation of proper config values provided by Terry Wu */
69static struct zl10353_config leadtek_dvr3100h_demod = { 81static struct zl10353_config leadtek_dvr3100h_demod = {
70 .demod_address = 0x1e >> 1, /* Datasheet suggested straps */ 82 .demod_address = 0x1e >> 1, /* Datasheet suggested straps */
@@ -74,6 +86,121 @@ static struct zl10353_config leadtek_dvr3100h_demod = {
74 .disable_i2c_gate_ctrl = 1, /* Disable the I2C gate */ 86 .disable_i2c_gate_ctrl = 1, /* Disable the I2C gate */
75}; 87};
76 88
89/*
90 * CX18_CARD_YUAN_MPC718
91 */
92/*
93 * Due to
94 *
95 * 1. an absence of information on how to prgram the MT352
96 * 2. the Linux mt352 module pushing MT352 initialzation off onto us here
97 *
98 * We have to use an init sequence that *you* must extract from the Windows
99 * driver (yuanrap.sys) and which we load as a firmware.
100 *
101 * If someone can provide me with a Zarlink MT352 (Intel CE6352?) Design Manual
102 * with chip programming details, then I can remove this annoyance.
103 */
104static int yuan_mpc718_mt352_reqfw(struct cx18_stream *stream,
105 const struct firmware **fw)
106{
107 struct cx18 *cx = stream->cx;
108 const char *fn = "dvb-cx18-mpc718-mt352.fw";
109 int ret;
110
111 ret = request_firmware(fw, fn, &cx->pci_dev->dev);
112 if (ret)
113 CX18_ERR("Unable to open firmware file %s\n", fn);
114 else {
115 size_t sz = (*fw)->size;
116 if (sz < 2 || sz > 64 || (sz % 2) != 0) {
117 CX18_ERR("Firmware %s has a bad size: %lu bytes\n",
118 fn, (unsigned long) sz);
119 ret = -EILSEQ;
120 release_firmware(*fw);
121 *fw = NULL;
122 }
123 }
124
125 if (ret) {
126 CX18_ERR("The MPC718 board variant with the MT352 DVB-T"
127 "demodualtor will not work without it\n");
128 CX18_ERR("Run 'linux/Documentation/dvb/get_dvb_firmware "
129 "mpc718' if you need the firmware\n");
130 }
131 return ret;
132}
133
134static int yuan_mpc718_mt352_init(struct dvb_frontend *fe)
135{
136 struct cx18_dvb *dvb = container_of(fe->dvb,
137 struct cx18_dvb, dvb_adapter);
138 struct cx18_stream *stream = container_of(dvb, struct cx18_stream, dvb);
139 const struct firmware *fw = NULL;
140 int ret;
141 int i;
142 u8 buf[3];
143
144 ret = yuan_mpc718_mt352_reqfw(stream, &fw);
145 if (ret)
146 return ret;
147
148 /* Loop through all the register-value pairs in the firmware file */
149 for (i = 0; i < fw->size; i += 2) {
150 buf[0] = fw->data[i];
151 /* Intercept a few registers we want to set ourselves */
152 switch (buf[0]) {
153 case TRL_NOMINAL_RATE_0:
154 /* Set our custom OFDM bandwidth in the case below */
155 break;
156 case TRL_NOMINAL_RATE_1:
157 /* 6 MHz: 64/7 * 6/8 / 20.48 * 2^16 = 0x55b6.db6 */
158 /* 7 MHz: 64/7 * 7/8 / 20.48 * 2^16 = 0x6400 */
159 /* 8 MHz: 64/7 * 8/8 / 20.48 * 2^16 = 0x7249.249 */
160 buf[1] = 0x72;
161 buf[2] = 0x49;
162 mt352_write(fe, buf, 3);
163 break;
164 case INPUT_FREQ_0:
165 /* Set our custom IF in the case below */
166 break;
167 case INPUT_FREQ_1:
168 /* 4.56 MHz IF: (20.48 - 4.56)/20.48 * 2^14 = 0x31c0 */
169 buf[1] = 0x31;
170 buf[2] = 0xc0;
171 mt352_write(fe, buf, 3);
172 break;
173 default:
174 /* Pass through the register-value pair from the fw */
175 buf[1] = fw->data[i+1];
176 mt352_write(fe, buf, 2);
177 break;
178 }
179 }
180
181 buf[0] = (u8) TUNER_GO;
182 buf[1] = 0x01; /* Go */
183 mt352_write(fe, buf, 2);
184 release_firmware(fw);
185 return 0;
186}
187
188static struct mt352_config yuan_mpc718_mt352_demod = {
189 .demod_address = 0x1e >> 1,
190 .adc_clock = 20480, /* 20.480 MHz */
191 .if2 = 4560, /* 4.560 MHz */
192 .no_tuner = 1, /* XC3028 is not behind the gate */
193 .demod_init = yuan_mpc718_mt352_init,
194};
195
196static struct zl10353_config yuan_mpc718_zl10353_demod = {
197 .demod_address = 0x1e >> 1, /* Datasheet suggested straps */
198 .if2 = 45600, /* 4.560 MHz IF from the XC3028 */
199 .parallel_ts = 1, /* Not a serial TS */
200 .no_tuner = 1, /* XC3028 is not behind the gate */
201 .disable_i2c_gate_ctrl = 1, /* Disable the I2C gate */
202};
203
77static int dvb_register(struct cx18_stream *stream); 204static int dvb_register(struct cx18_stream *stream);
78 205
79/* Kernel DVB framework calls this when the feed needs to start. 206/* Kernel DVB framework calls this when the feed needs to start.
@@ -113,6 +240,7 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed)
113 break; 240 break;
114 241
115 case CX18_CARD_LEADTEK_DVR3100H: 242 case CX18_CARD_LEADTEK_DVR3100H:
243 case CX18_CARD_YUAN_MPC718:
116 default: 244 default:
117 /* Assumption - Parallel transport - Signalling 245 /* Assumption - Parallel transport - Signalling
118 * undefined or default. 246 * undefined or default.
@@ -326,6 +454,38 @@ static int dvb_register(struct cx18_stream *stream)
326 fe->ops.tuner_ops.set_config(fe, &ctrl); 454 fe->ops.tuner_ops.set_config(fe, &ctrl);
327 } 455 }
328 break; 456 break;
457 case CX18_CARD_YUAN_MPC718:
458 /*
459 * TODO
460 * Apparently, these cards also could instead have a
461 * DiBcom demod supported by one of the db7000 drivers
462 */
463 dvb->fe = dvb_attach(mt352_attach,
464 &yuan_mpc718_mt352_demod,
465 &cx->i2c_adap[1]);
466 if (dvb->fe == NULL)
467 dvb->fe = dvb_attach(zl10353_attach,
468 &yuan_mpc718_zl10353_demod,
469 &cx->i2c_adap[1]);
470 if (dvb->fe != NULL) {
471 struct dvb_frontend *fe;
472 struct xc2028_config cfg = {
473 .i2c_adap = &cx->i2c_adap[1],
474 .i2c_addr = 0xc2 >> 1,
475 .ctrl = NULL,
476 };
477 static struct xc2028_ctrl ctrl = {
478 .fname = XC2028_DEFAULT_FIRMWARE,
479 .max_len = 64,
480 .demod = XC3028_FE_ZARLINK456,
481 .type = XC2028_AUTO,
482 };
483
484 fe = dvb_attach(xc2028_attach, dvb->fe, &cfg);
485 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
486 fe->ops.tuner_ops.set_config(fe, &ctrl);
487 }
488 break;
329 default: 489 default:
330 /* No Digital Tv Support */ 490 /* No Digital Tv Support */
331 break; 491 break;
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index 2943bfd32a94..428f0c45e6b7 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -31,6 +31,7 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/firmware.h> 33#include <linux/firmware.h>
34#include <linux/smp_lock.h>
34#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
35#include <media/v4l2-ioctl.h> 36#include <media/v4l2-ioctl.h>
36#include <media/cx2341x.h> 37#include <media/cx2341x.h>
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index 48a975134ac5..86ac529e62be 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -463,6 +463,30 @@ static struct xc5000_config mygica_x8506_xc5000_config = {
463 .if_khz = 5380, 463 .if_khz = 5380,
464}; 464};
465 465
466static int cx23885_dvb_set_frontend(struct dvb_frontend *fe,
467 struct dvb_frontend_parameters *param)
468{
469 struct cx23885_tsport *port = fe->dvb->priv;
470 struct cx23885_dev *dev = port->dev;
471
472 switch (dev->board) {
473 case CX23885_BOARD_HAUPPAUGE_HVR1275:
474 switch (param->u.vsb.modulation) {
475 case VSB_8:
476 cx23885_gpio_clear(dev, GPIO_5);
477 break;
478 case QAM_64:
479 case QAM_256:
480 default:
481 cx23885_gpio_set(dev, GPIO_5);
482 break;
483 }
484 break;
485 }
486 return (port->set_frontend_save) ?
487 port->set_frontend_save(fe, param) : -ENODEV;
488}
489
466static int dvb_register(struct cx23885_tsport *port) 490static int dvb_register(struct cx23885_tsport *port)
467{ 491{
468 struct cx23885_dev *dev = port->dev; 492 struct cx23885_dev *dev = port->dev;
@@ -502,6 +526,12 @@ static int dvb_register(struct cx23885_tsport *port)
502 0x60, &dev->i2c_bus[1].i2c_adap, 526 0x60, &dev->i2c_bus[1].i2c_adap,
503 &hauppauge_hvr127x_config); 527 &hauppauge_hvr127x_config);
504 } 528 }
529
530 /* FIXME: temporary hack */
531 /* define bridge override to set_frontend */
532 port->set_frontend_save = fe0->dvb.frontend->ops.set_frontend;
533 fe0->dvb.frontend->ops.set_frontend = cx23885_dvb_set_frontend;
534
505 break; 535 break;
506 case CX23885_BOARD_HAUPPAUGE_HVR1255: 536 case CX23885_BOARD_HAUPPAUGE_HVR1255:
507 i2c_bus = &dev->i2c_bus[0]; 537 i2c_bus = &dev->i2c_bus[0];
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 70836af3ab48..5d6093336300 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -26,6 +26,7 @@
26#include <linux/kmod.h> 26#include <linux/kmod.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/smp_lock.h>
29#include <linux/interrupt.h> 30#include <linux/interrupt.h>
30#include <linux/delay.h> 31#include <linux/delay.h>
31#include <linux/kthread.h> 32#include <linux/kthread.h>
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h
index 1a2ac518a3f1..214a55e943b7 100644
--- a/drivers/media/video/cx23885/cx23885.h
+++ b/drivers/media/video/cx23885/cx23885.h
@@ -288,6 +288,10 @@ struct cx23885_tsport {
288 /* Allow a single tsport to have multiple frontends */ 288 /* Allow a single tsport to have multiple frontends */
289 u32 num_frontends; 289 u32 num_frontends;
290 void *port_priv; 290 void *port_priv;
291
292 /* FIXME: temporary hack */
293 int (*set_frontend_save) (struct dvb_frontend *,
294 struct dvb_frontend_parameters *);
291}; 295};
292 296
293struct cx23885_dev { 297struct cx23885_dev {
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 44eacfb0d0d6..356d6896da3f 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -32,6 +32,7 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/firmware.h> 34#include <linux/firmware.h>
35#include <linux/smp_lock.h>
35#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
36#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
37#include <media/cx2341x.h> 38#include <media/cx2341x.h>
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index b12770848c00..2bb54c3ef5cd 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -31,6 +31,7 @@
31#include <linux/kmod.h> 31#include <linux/kmod.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/smp_lock.h>
34#include <linux/interrupt.h> 35#include <linux/interrupt.h>
35#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c
index ec2f45dde164..0664d111085f 100644
--- a/drivers/media/video/dabusb.c
+++ b/drivers/media/video/dabusb.c
@@ -32,6 +32,7 @@
32#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/vmalloc.h> 33#include <linux/vmalloc.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/smp_lock.h>
35#include <linux/init.h> 36#include <linux/init.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
37#include <asm/atomic.h> 38#include <asm/atomic.h>
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index 16a5af30e9d1..6524b493e033 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -8,6 +8,8 @@ config VIDEO_EM28XX
8 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO 8 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
9 select VIDEO_TVP5150 if VIDEO_HELPER_CHIPS_AUTO 9 select VIDEO_TVP5150 if VIDEO_HELPER_CHIPS_AUTO
10 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO 10 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO
11 select VIDEO_MT9V011 if VIDEO_HELPER_CHIPS_AUTO
12
11 ---help--- 13 ---help---
12 This is a video4linux driver for Empia 28xx based TV cards. 14 This is a video4linux driver for Empia 28xx based TV cards.
13 15
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index c43fdb9bc888..ebd24a25fb85 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -58,6 +58,8 @@ static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
58module_param_array(card, int, NULL, 0444); 58module_param_array(card, int, NULL, 0444);
59MODULE_PARM_DESC(card, "card type"); 59MODULE_PARM_DESC(card, "card type");
60 60
61#define MT9V011_VERSION 0x8243
62
61/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */ 63/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */
62static unsigned long em28xx_devused; 64static unsigned long em28xx_devused;
63 65
@@ -191,6 +193,13 @@ static struct em28xx_reg_seq terratec_av350_unmute_gpio[] = {
191 {EM28XX_R08_GPIO, 0xff, 0xff, 10}, 193 {EM28XX_R08_GPIO, 0xff, 0xff, 10},
192 { -1, -1, -1, -1}, 194 { -1, -1, -1, -1},
193}; 195};
196
197static struct em28xx_reg_seq silvercrest_reg_seq[] = {
198 {EM28XX_R08_GPIO, 0xff, 0xff, 10},
199 {EM28XX_R08_GPIO, 0x01, 0xf7, 10},
200 { -1, -1, -1, -1},
201};
202
194/* 203/*
195 * Board definitions 204 * Board definitions
196 */ 205 */
@@ -438,6 +447,18 @@ struct em28xx_board em28xx_boards[] = {
438 .amux = EM28XX_AMUX_VIDEO, 447 .amux = EM28XX_AMUX_VIDEO,
439 } }, 448 } },
440 }, 449 },
450 [EM2820_BOARD_SILVERCREST_WEBCAM] = {
451 .name = "Silvercrest Webcam 1.3mpix",
452 .tuner_type = TUNER_ABSENT,
453 .is_27xx = 1,
454 .decoder = EM28XX_MT9V011,
455 .input = { {
456 .type = EM28XX_VMUX_COMPOSITE1,
457 .vmux = 0,
458 .amux = EM28XX_AMUX_VIDEO,
459 .gpio = silvercrest_reg_seq,
460 } },
461 },
441 [EM2821_BOARD_SUPERCOMP_USB_2] = { 462 [EM2821_BOARD_SUPERCOMP_USB_2] = {
442 .name = "Supercomp USB 2.0 TV", 463 .name = "Supercomp USB 2.0 TV",
443 .valid = EM28XX_BOARD_NOT_VALIDATED, 464 .valid = EM28XX_BOARD_NOT_VALIDATED,
@@ -826,7 +847,7 @@ struct em28xx_board em28xx_boards[] = {
826 .tuner_gpio = default_tuner_gpio, 847 .tuner_gpio = default_tuner_gpio,
827 .decoder = EM28XX_TVP5150, 848 .decoder = EM28XX_TVP5150,
828 .has_dvb = 1, 849 .has_dvb = 1,
829 .dvb_gpio = default_analog, 850 .dvb_gpio = default_digital,
830 .input = { { 851 .input = { {
831 .type = EM28XX_VMUX_TELEVISION, 852 .type = EM28XX_VMUX_TELEVISION,
832 .vmux = TVP5150_COMPOSITE0, 853 .vmux = TVP5150_COMPOSITE0,
@@ -1639,6 +1660,11 @@ static unsigned short tvp5150_addrs[] = {
1639 I2C_CLIENT_END 1660 I2C_CLIENT_END
1640}; 1661};
1641 1662
1663static unsigned short mt9v011_addrs[] = {
1664 0xba >> 1,
1665 I2C_CLIENT_END
1666};
1667
1642static unsigned short msp3400_addrs[] = { 1668static unsigned short msp3400_addrs[] = {
1643 0x80 >> 1, 1669 0x80 >> 1,
1644 0x88 >> 1, 1670 0x88 >> 1,
@@ -1678,6 +1704,46 @@ static inline void em28xx_set_model(struct em28xx *dev)
1678 EM28XX_I2C_FREQ_100_KHZ; 1704 EM28XX_I2C_FREQ_100_KHZ;
1679} 1705}
1680 1706
1707/* HINT method: webcam I2C chips
1708 *
1709 * This method work for webcams with Micron sensors
1710 */
1711static int em28xx_hint_sensor(struct em28xx *dev)
1712{
1713 int rc;
1714 char *sensor_name;
1715 unsigned char cmd;
1716 __be16 version_be;
1717 u16 version;
1718
1719 if (dev->model != EM2820_BOARD_UNKNOWN)
1720 return 0;
1721
1722 dev->i2c_client.addr = 0xba >> 1;
1723 cmd = 0;
1724 i2c_master_send(&dev->i2c_client, &cmd, 1);
1725 rc = i2c_master_recv(&dev->i2c_client, (char *)&version_be, 2);
1726 if (rc != 2)
1727 return -EINVAL;
1728
1729 version = be16_to_cpu(version_be);
1730
1731 switch (version) {
1732 case MT9V011_VERSION:
1733 dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
1734 sensor_name = "mt9v011";
1735 break;
1736 default:
1737 printk("Unknown Sensor 0x%04x\n", be16_to_cpu(version));
1738 return -EINVAL;
1739 }
1740
1741 em28xx_errdev("Sensor is %s, assuming that webcam is %s\n",
1742 sensor_name, em28xx_boards[dev->model].name);
1743
1744 return 0;
1745}
1746
1681/* Since em28xx_pre_card_setup() requires a proper dev->model, 1747/* Since em28xx_pre_card_setup() requires a proper dev->model,
1682 * this won't work for boards with generic PCI IDs 1748 * this won't work for boards with generic PCI IDs
1683 */ 1749 */
@@ -1706,7 +1772,10 @@ void em28xx_pre_card_setup(struct em28xx *dev)
1706 em28xx_info("chip ID is em2750\n"); 1772 em28xx_info("chip ID is em2750\n");
1707 break; 1773 break;
1708 case CHIP_ID_EM2820: 1774 case CHIP_ID_EM2820:
1709 em28xx_info("chip ID is em2820\n"); 1775 if (dev->board.is_27xx)
1776 em28xx_info("chip is em2710\n");
1777 else
1778 em28xx_info("chip ID is em2820\n");
1710 break; 1779 break;
1711 case CHIP_ID_EM2840: 1780 case CHIP_ID_EM2840:
1712 em28xx_info("chip ID is em2840\n"); 1781 em28xx_info("chip ID is em2840\n");
@@ -2158,6 +2227,10 @@ void em28xx_card_setup(struct em28xx *dev)
2158 before probing the i2c bus. */ 2227 before probing the i2c bus. */
2159 em28xx_set_mode(dev, EM28XX_ANALOG_MODE); 2228 em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2160 break; 2229 break;
2230 case EM2820_BOARD_SILVERCREST_WEBCAM:
2231 /* FIXME: need to document the registers bellow */
2232 em28xx_write_reg(dev, 0x0d, 0x42);
2233 em28xx_write_reg(dev, 0x13, 0x08);
2161 } 2234 }
2162 2235
2163 if (dev->board.has_snapshot_button) 2236 if (dev->board.has_snapshot_button)
@@ -2189,6 +2262,10 @@ void em28xx_card_setup(struct em28xx *dev)
2189 v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap, 2262 v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2190 "tvp5150", "tvp5150", tvp5150_addrs); 2263 "tvp5150", "tvp5150", tvp5150_addrs);
2191 2264
2265 if (dev->board.decoder == EM28XX_MT9V011)
2266 v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2267 "mt9v011", "mt9v011", mt9v011_addrs);
2268
2192 if (dev->board.adecoder == EM28XX_TVAUDIO) 2269 if (dev->board.adecoder == EM28XX_TVAUDIO)
2193 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 2270 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2194 "tvaudio", "tvaudio", dev->board.tvaudio_addr); 2271 "tvaudio", "tvaudio", dev->board.tvaudio_addr);
@@ -2333,6 +2410,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2333 return errCode; 2410 return errCode;
2334 } 2411 }
2335 2412
2413 em28xx_hint_sensor(dev);
2414
2336 /* Do board specific init and eeprom reading */ 2415 /* Do board specific init and eeprom reading */
2337 em28xx_card_setup(dev); 2416 em28xx_card_setup(dev);
2338 2417
@@ -2573,6 +2652,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2573 retval = em28xx_init_dev(&dev, udev, interface, nr); 2652 retval = em28xx_init_dev(&dev, udev, interface, nr);
2574 if (retval) { 2653 if (retval) {
2575 em28xx_devused &= ~(1<<dev->devno); 2654 em28xx_devused &= ~(1<<dev->devno);
2655 mutex_unlock(&dev->lock);
2576 kfree(dev); 2656 kfree(dev);
2577 goto err; 2657 goto err;
2578 } 2658 }
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index c8d7ce8fbd36..079ab4d563a6 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -648,17 +648,28 @@ int em28xx_capture_start(struct em28xx *dev, int start)
648int em28xx_set_outfmt(struct em28xx *dev) 648int em28xx_set_outfmt(struct em28xx *dev)
649{ 649{
650 int ret; 650 int ret;
651 int vinmode, vinctl, outfmt;
652
653 outfmt = dev->format->reg;
654
655 if (dev->board.is_27xx) {
656 vinmode = 0x0d;
657 vinctl = 0x00;
658 } else {
659 vinmode = 0x10;
660 vinctl = 0x11;
661 }
651 662
652 ret = em28xx_write_reg_bits(dev, EM28XX_R27_OUTFMT, 663 ret = em28xx_write_reg_bits(dev, EM28XX_R27_OUTFMT,
653 dev->format->reg | 0x20, 0x3f); 664 outfmt | 0x20, 0xff);
654 if (ret < 0) 665 if (ret < 0)
655 return ret; 666 return ret;
656 667
657 ret = em28xx_write_reg(dev, EM28XX_R10_VINMODE, 0x10); 668 ret = em28xx_write_reg(dev, EM28XX_R10_VINMODE, vinmode);
658 if (ret < 0) 669 if (ret < 0)
659 return ret; 670 return ret;
660 671
661 return em28xx_write_reg(dev, EM28XX_R11_VINCTRL, 0x11); 672 return em28xx_write_reg(dev, EM28XX_R11_VINCTRL, vinctl);
662} 673}
663 674
664static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, 675static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax,
@@ -695,13 +706,19 @@ static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
695{ 706{
696 u8 mode; 707 u8 mode;
697 /* the em2800 scaler only supports scaling down to 50% */ 708 /* the em2800 scaler only supports scaling down to 50% */
698 if (dev->board.is_em2800) 709
710 if (dev->board.is_27xx) {
711 /* FIXME: Don't use the scaler yet */
712 mode = 0;
713 } else if (dev->board.is_em2800) {
699 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00); 714 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00);
700 else { 715 } else {
701 u8 buf[2]; 716 u8 buf[2];
717
702 buf[0] = h; 718 buf[0] = h;
703 buf[1] = h >> 8; 719 buf[1] = h >> 8;
704 em28xx_write_regs(dev, EM28XX_R30_HSCALELOW, (char *)buf, 2); 720 em28xx_write_regs(dev, EM28XX_R30_HSCALELOW, (char *)buf, 2);
721
705 buf[0] = v; 722 buf[0] = v;
706 buf[1] = v >> 8; 723 buf[1] = v >> 8;
707 em28xx_write_regs(dev, EM28XX_R32_VSCALELOW, (char *)buf, 2); 724 em28xx_write_regs(dev, EM28XX_R32_VSCALELOW, (char *)buf, 2);
@@ -720,8 +737,11 @@ int em28xx_resolution_set(struct em28xx *dev)
720 height = norm_maxh(dev) >> 1; 737 height = norm_maxh(dev) >> 1;
721 738
722 em28xx_set_outfmt(dev); 739 em28xx_set_outfmt(dev);
740
741
723 em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2); 742 em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2);
724 em28xx_capture_area_set(dev, 0, 0, width >> 2, height >> 2); 743 em28xx_capture_area_set(dev, 0, 0, width >> 2, height >> 2);
744
725 return em28xx_scaler_set(dev, dev->hscale, dev->vscale); 745 return em28xx_scaler_set(dev, dev->hscale, dev->vscale);
726} 746}
727 747
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index e7b47c8da8f3..3da97c32b8fa 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -243,6 +243,14 @@ static struct s5h1409_config em28xx_s5h1409_with_xc3028 = {
243 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK 243 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
244}; 244};
245 245
246static struct zl10353_config em28xx_terratec_xs_zl10353_xc3028 = {
247 .demod_address = (0x1e >> 1),
248 .no_tuner = 1,
249 .disable_i2c_gate_ctrl = 1,
250 .parallel_ts = 1,
251 .if2 = 45600,
252};
253
246#ifdef EM28XX_DRX397XD_SUPPORT 254#ifdef EM28XX_DRX397XD_SUPPORT
247/* [TODO] djh - not sure yet what the device config needs to contain */ 255/* [TODO] djh - not sure yet what the device config needs to contain */
248static struct drx397xD_config em28xx_drx397xD_with_xc3028 = { 256static struct drx397xD_config em28xx_drx397xD_with_xc3028 = {
@@ -433,7 +441,6 @@ static int dvb_init(struct em28xx *dev)
433 } 441 }
434 break; 442 break;
435 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: 443 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
436 case EM2880_BOARD_TERRATEC_HYBRID_XS:
437 case EM2880_BOARD_KWORLD_DVB_310U: 444 case EM2880_BOARD_KWORLD_DVB_310U:
438 case EM2880_BOARD_EMPIRE_DUAL_TV: 445 case EM2880_BOARD_EMPIRE_DUAL_TV:
439 dvb->frontend = dvb_attach(zl10353_attach, 446 dvb->frontend = dvb_attach(zl10353_attach,
@@ -444,6 +451,25 @@ static int dvb_init(struct em28xx *dev)
444 goto out_free; 451 goto out_free;
445 } 452 }
446 break; 453 break;
454 case EM2880_BOARD_TERRATEC_HYBRID_XS:
455 dvb->frontend = dvb_attach(zl10353_attach,
456 &em28xx_terratec_xs_zl10353_xc3028,
457 &dev->i2c_adap);
458 if (dvb->frontend == NULL) {
459 /* This board could have either a zl10353 or a mt352.
460 If the chip id isn't for zl10353, try mt352 */
461
462 /* FIXME: make support for mt352 work */
463 printk(KERN_ERR "version of this board with mt352 not "
464 "currently supported\n");
465 result = -EINVAL;
466 goto out_free;
467 }
468 if (attach_xc3028(0x61, dev) < 0) {
469 result = -EINVAL;
470 goto out_free;
471 }
472 break;
447 case EM2883_BOARD_KWORLD_HYBRID_330U: 473 case EM2883_BOARD_KWORLD_HYBRID_330U:
448 case EM2882_BOARD_EVGA_INDTUBE: 474 case EM2882_BOARD_EVGA_INDTUBE:
449 dvb->frontend = dvb_attach(s5h1409_attach, 475 dvb->frontend = dvb_attach(s5h1409_attach,
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index 2c86fcf089f5..27e33a287dfc 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -483,7 +483,7 @@ static char *i2c_devs[128] = {
483 [0xa0 >> 1] = "eeprom", 483 [0xa0 >> 1] = "eeprom",
484 [0xb0 >> 1] = "tda9874", 484 [0xb0 >> 1] = "tda9874",
485 [0xb8 >> 1] = "tvp5150a", 485 [0xb8 >> 1] = "tvp5150a",
486 [0xba >> 1] = "tvp5150a", 486 [0xba >> 1] = "webcam sensor or tvp5150a",
487 [0xc0 >> 1] = "tuner (analog)", 487 [0xc0 >> 1] = "tuner (analog)",
488 [0xc2 >> 1] = "tuner (analog)", 488 [0xc2 >> 1] = "tuner (analog)",
489 [0xc4 >> 1] = "tuner (analog)", 489 [0xc4 >> 1] = "tuner (analog)",
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 8fe1beecfffa..14316c912179 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -90,10 +90,35 @@ MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
90/* supported video standards */ 90/* supported video standards */
91static struct em28xx_fmt format[] = { 91static struct em28xx_fmt format[] = {
92 { 92 {
93 .name = "16bpp YUY2, 4:2:2, packed", 93 .name = "16 bpp YUY2, 4:2:2, packed",
94 .fourcc = V4L2_PIX_FMT_YUYV, 94 .fourcc = V4L2_PIX_FMT_YUYV,
95 .depth = 16, 95 .depth = 16,
96 .reg = EM28XX_OUTFMT_YUV422_Y0UY1V, 96 .reg = EM28XX_OUTFMT_YUV422_Y0UY1V,
97 }, {
98 .name = "16 bpp RGB 565, LE",
99 .fourcc = V4L2_PIX_FMT_RGB565,
100 .depth = 16,
101 .reg = EM28XX_OUTFMT_RGB_16_656,
102 }, {
103 .name = "8 bpp Bayer BGBG..GRGR",
104 .fourcc = V4L2_PIX_FMT_SBGGR8,
105 .depth = 8,
106 .reg = EM28XX_OUTFMT_RGB_8_BGBG,
107 }, {
108 .name = "8 bpp Bayer GRGR..BGBG",
109 .fourcc = V4L2_PIX_FMT_SGRBG8,
110 .depth = 8,
111 .reg = EM28XX_OUTFMT_RGB_8_GRGR,
112 }, {
113 .name = "8 bpp Bayer GBGB..RGRG",
114 .fourcc = V4L2_PIX_FMT_SGBRG8,
115 .depth = 8,
116 .reg = EM28XX_OUTFMT_RGB_8_GBGB,
117 }, {
118 .name = "12 bpp YUV411",
119 .fourcc = V4L2_PIX_FMT_YUV411P,
120 .depth = 12,
121 .reg = EM28XX_OUTFMT_YUV411,
97 }, 122 },
98}; 123};
99 124
@@ -701,7 +726,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
701 return -EINVAL; 726 return -EINVAL;
702 } 727 }
703 728
704 if (dev->board.is_em2800) { 729 if (dev->board.is_27xx) {
730 /* FIXME: This is the only supported fmt */
731 width = 640;
732 height = 480;
733 } else if (dev->board.is_em2800) {
705 /* the em2800 can only scale down to 50% */ 734 /* the em2800 can only scale down to 50% */
706 height = height > (3 * maxh / 4) ? maxh : maxh / 2; 735 height = height > (3 * maxh / 4) ? maxh : maxh / 2;
707 width = width > (3 * maxw / 4) ? maxw : maxw / 2; 736 width = width > (3 * maxw / 4) ? maxw : maxw / 2;
@@ -733,13 +762,40 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
733 return 0; 762 return 0;
734} 763}
735 764
765static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc,
766 unsigned width, unsigned height)
767{
768 struct em28xx_fmt *fmt;
769
770 /* FIXME: This is the only supported fmt */
771 if (dev->board.is_27xx) {
772 width = 640;
773 height = 480;
774 }
775
776 fmt = format_by_fourcc(fourcc);
777 if (!fmt)
778 return -EINVAL;
779
780 dev->format = fmt;
781 dev->width = width;
782 dev->height = height;
783
784 /* set new image size */
785 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
786
787 em28xx_set_alternate(dev);
788 em28xx_resolution_set(dev);
789
790 return 0;
791}
792
736static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 793static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
737 struct v4l2_format *f) 794 struct v4l2_format *f)
738{ 795{
739 struct em28xx_fh *fh = priv; 796 struct em28xx_fh *fh = priv;
740 struct em28xx *dev = fh->dev; 797 struct em28xx *dev = fh->dev;
741 int rc; 798 int rc;
742 struct em28xx_fmt *fmt;
743 799
744 rc = check_dev(dev); 800 rc = check_dev(dev);
745 if (rc < 0) 801 if (rc < 0)
@@ -749,12 +805,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
749 805
750 vidioc_try_fmt_vid_cap(file, priv, f); 806 vidioc_try_fmt_vid_cap(file, priv, f);
751 807
752 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
753 if (!fmt) {
754 rc = -EINVAL;
755 goto out;
756 }
757
758 if (videobuf_queue_is_busy(&fh->vb_vidq)) { 808 if (videobuf_queue_is_busy(&fh->vb_vidq)) {
759 em28xx_errdev("%s queue busy\n", __func__); 809 em28xx_errdev("%s queue busy\n", __func__);
760 rc = -EBUSY; 810 rc = -EBUSY;
@@ -767,16 +817,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
767 goto out; 817 goto out;
768 } 818 }
769 819
770 /* set new image size */ 820 rc = em28xx_set_video_format(dev, f->fmt.pix.pixelformat,
771 dev->width = f->fmt.pix.width; 821 f->fmt.pix.width, f->fmt.pix.height);
772 dev->height = f->fmt.pix.height;
773 dev->format = fmt;
774 get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
775
776 em28xx_set_alternate(dev);
777 em28xx_resolution_set(dev);
778
779 rc = 0;
780 822
781out: 823out:
782 mutex_unlock(&dev->lock); 824 mutex_unlock(&dev->lock);
@@ -1616,11 +1658,6 @@ static int em28xx_v4l2_open(struct file *filp)
1616 filp->private_data = fh; 1658 filp->private_data = fh;
1617 1659
1618 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { 1660 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) {
1619 dev->width = norm_maxw(dev);
1620 dev->height = norm_maxh(dev);
1621 dev->hscale = 0;
1622 dev->vscale = 0;
1623
1624 em28xx_set_mode(dev, EM28XX_ANALOG_MODE); 1661 em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
1625 em28xx_set_alternate(dev); 1662 em28xx_set_alternate(dev);
1626 em28xx_resolution_set(dev); 1663 em28xx_resolution_set(dev);
@@ -1962,15 +1999,14 @@ int em28xx_register_analog_devices(struct em28xx *dev)
1962 1999
1963 /* set default norm */ 2000 /* set default norm */
1964 dev->norm = em28xx_video_template.current_norm; 2001 dev->norm = em28xx_video_template.current_norm;
1965 dev->width = norm_maxw(dev);
1966 dev->height = norm_maxh(dev);
1967 dev->interlaced = EM28XX_INTERLACED_DEFAULT; 2002 dev->interlaced = EM28XX_INTERLACED_DEFAULT;
1968 dev->hscale = 0;
1969 dev->vscale = 0;
1970 dev->ctl_input = 0; 2003 dev->ctl_input = 0;
1971 2004
1972 /* Analog specific initialization */ 2005 /* Analog specific initialization */
1973 dev->format = &format[0]; 2006 dev->format = &format[0];
2007 em28xx_set_video_format(dev, format[0].fourcc,
2008 norm_maxw(dev), norm_maxh(dev));
2009
1974 video_mux(dev, dev->ctl_input); 2010 video_mux(dev, dev->ctl_input);
1975 2011
1976 /* Audio defaults */ 2012 /* Audio defaults */
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 813ce45c2f99..d90fef463764 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -107,6 +107,7 @@
107#define EM2860_BOARD_TERRATEC_AV350 68 107#define EM2860_BOARD_TERRATEC_AV350 68
108#define EM2882_BOARD_KWORLD_ATSC_315U 69 108#define EM2882_BOARD_KWORLD_ATSC_315U 69
109#define EM2882_BOARD_EVGA_INDTUBE 70 109#define EM2882_BOARD_EVGA_INDTUBE 70
110#define EM2820_BOARD_SILVERCREST_WEBCAM 71
110 111
111/* Limits minimum and default number of buffers */ 112/* Limits minimum and default number of buffers */
112#define EM28XX_MIN_BUF 4 113#define EM28XX_MIN_BUF 4
@@ -360,6 +361,7 @@ enum em28xx_decoder {
360 EM28XX_NODECODER, 361 EM28XX_NODECODER,
361 EM28XX_TVP5150, 362 EM28XX_TVP5150,
362 EM28XX_SAA711X, 363 EM28XX_SAA711X,
364 EM28XX_MT9V011,
363}; 365};
364 366
365enum em28xx_adecoder { 367enum em28xx_adecoder {
@@ -388,6 +390,7 @@ struct em28xx_board {
388 unsigned int max_range_640_480:1; 390 unsigned int max_range_640_480:1;
389 unsigned int has_dvb:1; 391 unsigned int has_dvb:1;
390 unsigned int has_snapshot_button:1; 392 unsigned int has_snapshot_button:1;
393 unsigned int is_27xx:1;
391 unsigned int valid:1; 394 unsigned int valid:1;
392 395
393 unsigned char xclk, i2c_speed; 396 unsigned char xclk, i2c_speed;
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.h b/drivers/media/video/gspca/stv06xx/stv06xx.h
index 9df7137fe67e..992ce530f138 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx.h
+++ b/drivers/media/video/gspca/stv06xx/stv06xx.h
@@ -36,10 +36,6 @@
36 36
37#define STV_ISOC_ENDPOINT_ADDR 0x81 37#define STV_ISOC_ENDPOINT_ADDR 0x81
38 38
39#ifndef V4L2_PIX_FMT_SGRBG8
40#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G')
41#endif
42
43#define STV_REG23 0x0423 39#define STV_REG23 0x0423
44 40
45/* Control registers of the STV0600 ASIC */ 41/* Control registers of the STV0600 ASIC */
diff --git a/drivers/media/video/mt9v011.c b/drivers/media/video/mt9v011.c
new file mode 100644
index 000000000000..1fe8fc9183a7
--- /dev/null
+++ b/drivers/media/video/mt9v011.c
@@ -0,0 +1,431 @@
1/*
2 * mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor
3 *
4 * Copyright (c) 2009 Mauro Carvalho Chehab (mchehab@redhat.com)
5 * This code is placed under the terms of the GNU General Public License v2
6 */
7
8#include <linux/i2c.h>
9#include <linux/videodev2.h>
10#include <linux/delay.h>
11#include <media/v4l2-device.h>
12#include "mt9v011.h"
13#include <media/v4l2-i2c-drv.h>
14#include <media/v4l2-chip-ident.h>
15
16MODULE_DESCRIPTION("Micron mt9v011 sensor driver");
17MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
18MODULE_LICENSE("GPL");
19
20
21static int debug;
22module_param(debug, int, 0);
23MODULE_PARM_DESC(debug, "Debug level (0-2)");
24
25/* supported controls */
26static struct v4l2_queryctrl mt9v011_qctrl[] = {
27 {
28 .id = V4L2_CID_GAIN,
29 .type = V4L2_CTRL_TYPE_INTEGER,
30 .name = "Gain",
31 .minimum = 0,
32 .maximum = (1 << 10) - 1,
33 .step = 1,
34 .default_value = 0x0020,
35 .flags = 0,
36 }, {
37 .id = V4L2_CID_RED_BALANCE,
38 .type = V4L2_CTRL_TYPE_INTEGER,
39 .name = "Red Balance",
40 .minimum = -1 << 9,
41 .maximum = (1 << 9) - 1,
42 .step = 1,
43 .default_value = 0,
44 .flags = 0,
45 }, {
46 .id = V4L2_CID_BLUE_BALANCE,
47 .type = V4L2_CTRL_TYPE_INTEGER,
48 .name = "Blue Balance",
49 .minimum = -1 << 9,
50 .maximum = (1 << 9) - 1,
51 .step = 1,
52 .default_value = 0,
53 .flags = 0,
54 },
55};
56
57struct mt9v011 {
58 struct v4l2_subdev sd;
59 unsigned width, height;
60
61 u16 global_gain, red_bal, blue_bal;
62};
63
64static inline struct mt9v011 *to_mt9v011(struct v4l2_subdev *sd)
65{
66 return container_of(sd, struct mt9v011, sd);
67}
68
69static int mt9v011_read(struct v4l2_subdev *sd, unsigned char addr)
70{
71 struct i2c_client *c = v4l2_get_subdevdata(sd);
72 __be16 buffer;
73 int rc, val;
74
75 rc = i2c_master_send(c, &addr, 1);
76 if (rc != 1)
77 v4l2_dbg(0, debug, sd,
78 "i2c i/o error: rc == %d (should be 1)\n", rc);
79
80 msleep(10);
81
82 rc = i2c_master_recv(c, (char *)&buffer, 2);
83 if (rc != 2)
84 v4l2_dbg(0, debug, sd,
85 "i2c i/o error: rc == %d (should be 2)\n", rc);
86
87 val = be16_to_cpu(buffer);
88
89 v4l2_dbg(2, debug, sd, "mt9v011: read 0x%02x = 0x%04x\n", addr, val);
90
91 return val;
92}
93
94static void mt9v011_write(struct v4l2_subdev *sd, unsigned char addr,
95 u16 value)
96{
97 struct i2c_client *c = v4l2_get_subdevdata(sd);
98 unsigned char buffer[3];
99 int rc;
100
101 buffer[0] = addr;
102 buffer[1] = value >> 8;
103 buffer[2] = value & 0xff;
104
105 v4l2_dbg(2, debug, sd,
106 "mt9v011: writing 0x%02x 0x%04x\n", buffer[0], value);
107 rc = i2c_master_send(c, buffer, 3);
108 if (rc != 3)
109 v4l2_dbg(0, debug, sd,
110 "i2c i/o error: rc == %d (should be 3)\n", rc);
111}
112
113
114struct i2c_reg_value {
115 unsigned char reg;
116 u16 value;
117};
118
119/*
120 * Values used at the original driver
121 * Some values are marked as Reserved at the datasheet
122 */
123static const struct i2c_reg_value mt9v011_init_default[] = {
124 { R0D_MT9V011_RESET, 0x0001 },
125 { R0D_MT9V011_RESET, 0x0000 },
126
127 { R0C_MT9V011_SHUTTER_DELAY, 0x0000 },
128 { R09_MT9V011_SHUTTER_WIDTH, 0x1fc },
129
130 { R0A_MT9V011_CLK_SPEED, 0x0000 },
131 { R1E_MT9V011_DIGITAL_ZOOM, 0x0000 },
132 { R20_MT9V011_READ_MODE, 0x1000 },
133
134 { R07_MT9V011_OUT_CTRL, 0x000a }, /* chip enable */
135};
136
137static void set_balance(struct v4l2_subdev *sd)
138{
139 struct mt9v011 *core = to_mt9v011(sd);
140 u16 green1_gain, green2_gain, blue_gain, red_gain;
141
142 green1_gain = core->global_gain;
143 green2_gain = core->global_gain;
144
145 blue_gain = core->global_gain +
146 core->global_gain * core->blue_bal / (1 << 9);
147
148 red_gain = core->global_gain +
149 core->global_gain * core->blue_bal / (1 << 9);
150
151 mt9v011_write(sd, R2B_MT9V011_GREEN_1_GAIN, green1_gain);
152 mt9v011_write(sd, R2E_MT9V011_GREEN_2_GAIN, green1_gain);
153 mt9v011_write(sd, R2C_MT9V011_BLUE_GAIN, blue_gain);
154 mt9v011_write(sd, R2D_MT9V011_RED_GAIN, red_gain);
155}
156
157static void set_res(struct v4l2_subdev *sd)
158{
159 struct mt9v011 *core = to_mt9v011(sd);
160 unsigned vstart, hstart;
161
162 /*
163 * The mt9v011 doesn't have scaling. So, in order to select the desired
164 * resolution, we're cropping at the middle of the sensor.
165 * hblank and vblank should be adjusted, in order to warrant that
166 * we'll preserve the line timings for 30 fps, no matter what resolution
167 * is selected.
168 * NOTE: datasheet says that width (and height) should be filled with
169 * width-1. However, this doesn't work, since one pixel per line will
170 * be missing.
171 */
172
173 hstart = 14 + (640 - core->width) / 2;
174 mt9v011_write(sd, R02_MT9V011_COLSTART, hstart);
175 mt9v011_write(sd, R04_MT9V011_WIDTH, core->width);
176 mt9v011_write(sd, R05_MT9V011_HBLANK, 771 - core->width);
177
178 vstart = 8 + (640 - core->height) / 2;
179 mt9v011_write(sd, R01_MT9V011_ROWSTART, vstart);
180 mt9v011_write(sd, R03_MT9V011_HEIGHT, core->height);
181 mt9v011_write(sd, R06_MT9V011_VBLANK, 508 - core->height);
182};
183
184static int mt9v011_reset(struct v4l2_subdev *sd, u32 val)
185{
186 int i;
187
188 for (i = 0; i < ARRAY_SIZE(mt9v011_init_default); i++)
189 mt9v011_write(sd, mt9v011_init_default[i].reg,
190 mt9v011_init_default[i].value);
191
192 set_balance(sd);
193 set_res(sd);
194
195 return 0;
196};
197
198static int mt9v011_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
199{
200 struct mt9v011 *core = to_mt9v011(sd);
201
202 v4l2_dbg(1, debug, sd, "g_ctrl called\n");
203
204 switch (ctrl->id) {
205 case V4L2_CID_GAIN:
206 ctrl->value = core->global_gain;
207 return 0;
208 case V4L2_CID_RED_BALANCE:
209 ctrl->value = core->red_bal;
210 return 0;
211 case V4L2_CID_BLUE_BALANCE:
212 ctrl->value = core->blue_bal;
213 return 0;
214 }
215 return -EINVAL;
216}
217
218static int mt9v011_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
219{
220 struct mt9v011 *core = to_mt9v011(sd);
221 u8 i, n;
222 n = ARRAY_SIZE(mt9v011_qctrl);
223
224 for (i = 0; i < n; i++) {
225 if (ctrl->id != mt9v011_qctrl[i].id)
226 continue;
227 if (ctrl->value < mt9v011_qctrl[i].minimum ||
228 ctrl->value > mt9v011_qctrl[i].maximum)
229 return -ERANGE;
230 v4l2_dbg(1, debug, sd, "s_ctrl: id=%d, value=%d\n",
231 ctrl->id, ctrl->value);
232 break;
233 }
234
235 switch (ctrl->id) {
236 case V4L2_CID_GAIN:
237 core->global_gain = ctrl->value;
238 break;
239 case V4L2_CID_RED_BALANCE:
240 core->red_bal = ctrl->value;
241 break;
242 case V4L2_CID_BLUE_BALANCE:
243 core->blue_bal = ctrl->value;
244 break;
245 default:
246 return -EINVAL;
247 }
248
249 set_balance(sd);
250
251 return 0;
252}
253
254static int mt9v011_enum_fmt(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
255{
256 if (fmt->index > 0)
257 return -EINVAL;
258
259 fmt->flags = 0;
260 strcpy(fmt->description, "8 bpp Bayer GRGR..BGBG");
261 fmt->pixelformat = V4L2_PIX_FMT_SGRBG8;
262
263 return 0;
264}
265
266static int mt9v011_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
267{
268 struct v4l2_pix_format *pix = &fmt->fmt.pix;
269
270 if (pix->pixelformat != V4L2_PIX_FMT_SGRBG8)
271 return -EINVAL;
272
273 v4l_bound_align_image(&pix->width, 48, 639, 1,
274 &pix->height, 32, 480, 1, 0);
275
276 return 0;
277}
278
279static int mt9v011_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
280{
281 struct v4l2_pix_format *pix = &fmt->fmt.pix;
282 struct mt9v011 *core = to_mt9v011(sd);
283 int rc;
284
285 rc = mt9v011_try_fmt(sd, fmt);
286 if (rc < 0)
287 return -EINVAL;
288
289 core->width = pix->width;
290 core->height = pix->height;
291
292 set_res(sd);
293
294 return 0;
295}
296
297
298#ifdef CONFIG_VIDEO_ADV_DEBUG
299static int mt9v011_g_register(struct v4l2_subdev *sd,
300 struct v4l2_dbg_register *reg)
301{
302 struct i2c_client *client = v4l2_get_subdevdata(sd);
303
304 if (!v4l2_chip_match_i2c_client(client, &reg->match))
305 return -EINVAL;
306 if (!capable(CAP_SYS_ADMIN))
307 return -EPERM;
308
309 reg->val = mt9v011_read(sd, reg->reg & 0xff);
310 reg->size = 2;
311
312 return 0;
313}
314
315static int mt9v011_s_register(struct v4l2_subdev *sd,
316 struct v4l2_dbg_register *reg)
317{
318 struct i2c_client *client = v4l2_get_subdevdata(sd);
319
320 if (!v4l2_chip_match_i2c_client(client, &reg->match))
321 return -EINVAL;
322 if (!capable(CAP_SYS_ADMIN))
323 return -EPERM;
324
325 mt9v011_write(sd, reg->reg & 0xff, reg->val & 0xffff);
326
327 return 0;
328}
329#endif
330
331static int mt9v011_g_chip_ident(struct v4l2_subdev *sd,
332 struct v4l2_dbg_chip_ident *chip)
333{
334 struct i2c_client *client = v4l2_get_subdevdata(sd);
335
336 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_MT9V011,
337 MT9V011_VERSION);
338}
339
340static const struct v4l2_subdev_core_ops mt9v011_core_ops = {
341 .g_ctrl = mt9v011_g_ctrl,
342 .s_ctrl = mt9v011_s_ctrl,
343 .reset = mt9v011_reset,
344 .g_chip_ident = mt9v011_g_chip_ident,
345#ifdef CONFIG_VIDEO_ADV_DEBUG
346 .g_register = mt9v011_g_register,
347 .s_register = mt9v011_s_register,
348#endif
349};
350
351static const struct v4l2_subdev_video_ops mt9v011_video_ops = {
352 .enum_fmt = mt9v011_enum_fmt,
353 .try_fmt = mt9v011_try_fmt,
354 .s_fmt = mt9v011_s_fmt,
355};
356
357static const struct v4l2_subdev_ops mt9v011_ops = {
358 .core = &mt9v011_core_ops,
359 .video = &mt9v011_video_ops,
360};
361
362
363/****************************************************************************
364 I2C Client & Driver
365 ****************************************************************************/
366
367static int mt9v011_probe(struct i2c_client *c,
368 const struct i2c_device_id *id)
369{
370 u16 version;
371 struct mt9v011 *core;
372 struct v4l2_subdev *sd;
373
374 /* Check if the adapter supports the needed features */
375 if (!i2c_check_functionality(c->adapter,
376 I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
377 return -EIO;
378
379 core = kzalloc(sizeof(struct mt9v011), GFP_KERNEL);
380 if (!core)
381 return -ENOMEM;
382
383 sd = &core->sd;
384 v4l2_i2c_subdev_init(sd, c, &mt9v011_ops);
385
386 /* Check if the sensor is really a MT9V011 */
387 version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION);
388 if (version != MT9V011_VERSION) {
389 v4l2_info(sd, "*** unknown micron chip detected (0x%04x.\n",
390 version);
391 kfree(core);
392 return -EINVAL;
393 }
394
395 core->global_gain = 0x0024;
396 core->width = 640;
397 core->height = 480;
398
399 v4l_info(c, "chip found @ 0x%02x (%s)\n",
400 c->addr << 1, c->adapter->name);
401
402 return 0;
403}
404
405static int mt9v011_remove(struct i2c_client *c)
406{
407 struct v4l2_subdev *sd = i2c_get_clientdata(c);
408
409 v4l2_dbg(1, debug, sd,
410 "mt9v011.c: removing mt9v011 adapter on address 0x%x\n",
411 c->addr << 1);
412
413 v4l2_device_unregister_subdev(sd);
414 kfree(to_mt9v011(sd));
415 return 0;
416}
417
418/* ----------------------------------------------------------------------- */
419
420static const struct i2c_device_id mt9v011_id[] = {
421 { "mt9v011", 0 },
422 { }
423};
424MODULE_DEVICE_TABLE(i2c, mt9v011_id);
425
426static struct v4l2_i2c_driver_data v4l2_i2c_data = {
427 .name = "mt9v011",
428 .probe = mt9v011_probe,
429 .remove = mt9v011_remove,
430 .id_table = mt9v011_id,
431};
diff --git a/drivers/media/video/mt9v011.h b/drivers/media/video/mt9v011.h
new file mode 100644
index 000000000000..9e443ee30558
--- /dev/null
+++ b/drivers/media/video/mt9v011.h
@@ -0,0 +1,35 @@
1/*
2 * mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor
3 *
4 * Copyright (c) 2009 Mauro Carvalho Chehab (mchehab@redhat.com)
5 * This code is placed under the terms of the GNU General Public License v2
6 */
7
8#ifndef MT9V011_H_
9#define MT9V011_H_
10
11#define R00_MT9V011_CHIP_VERSION 0x00
12#define R01_MT9V011_ROWSTART 0x01
13#define R02_MT9V011_COLSTART 0x02
14#define R03_MT9V011_HEIGHT 0x03
15#define R04_MT9V011_WIDTH 0x04
16#define R05_MT9V011_HBLANK 0x05
17#define R06_MT9V011_VBLANK 0x06
18#define R07_MT9V011_OUT_CTRL 0x07
19#define R09_MT9V011_SHUTTER_WIDTH 0x09
20#define R0A_MT9V011_CLK_SPEED 0x0a
21#define R0B_MT9V011_RESTART 0x0b
22#define R0C_MT9V011_SHUTTER_DELAY 0x0c
23#define R0D_MT9V011_RESET 0x0d
24#define R1E_MT9V011_DIGITAL_ZOOM 0x1e
25#define R20_MT9V011_READ_MODE 0x20
26#define R2B_MT9V011_GREEN_1_GAIN 0x2b
27#define R2C_MT9V011_BLUE_GAIN 0x2c
28#define R2D_MT9V011_RED_GAIN 0x2d
29#define R2E_MT9V011_GREEN_2_GAIN 0x2e
30#define R35_MT9V011_GLOBAL_GAIN 0x35
31#define RF1_MT9V011_CHIP_ENABLE 0xf1
32
33#define MT9V011_VERSION 0x8243
34
35#endif
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index db25c3034c11..8d17cf613306 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -62,6 +62,7 @@
62#include <linux/module.h> 62#include <linux/module.h>
63#include <linux/poll.h> 63#include <linux/poll.h>
64#include <linux/slab.h> 64#include <linux/slab.h>
65#include <linux/smp_lock.h>
65#ifdef CONFIG_USB_PWC_INPUT_EVDEV 66#ifdef CONFIG_USB_PWC_INPUT_EVDEV
66#include <linux/usb/input.h> 67#include <linux/usb/input.h>
67#endif 68#endif
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 0be6f814f539..0b658dee05a4 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -29,7 +29,6 @@
29#include <linux/usb.h> 29#include <linux/usb.h>
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <linux/wait.h> 31#include <linux/wait.h>
32#include <linux/smp_lock.h>
33#include <linux/version.h> 32#include <linux/version.h>
34#include <linux/mutex.h> 33#include <linux/mutex.h>
35#include <linux/mm.h> 34#include <linux/mm.h>
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 6be845ccc7d7..9e3262c0ba37 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -48,6 +48,7 @@
48#include <linux/videodev2.h> 48#include <linux/videodev2.h>
49#include <linux/version.h> 49#include <linux/version.h>
50#include <linux/mm.h> 50#include <linux/mm.h>
51#include <linux/smp_lock.h>
51#include <media/videobuf-vmalloc.h> 52#include <media/videobuf-vmalloc.h>
52#include <media/v4l2-common.h> 53#include <media/v4l2-common.h>
53#include <media/v4l2-ioctl.h> 54#include <media/v4l2-ioctl.h>
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index 155804b061e9..b624a4c01fdc 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -43,7 +43,6 @@
43#include <linux/mm.h> 43#include <linux/mm.h>
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/i2c.h> 45#include <linux/i2c.h>
46#include <linux/smp_lock.h>
47#include <linux/mutex.h> 46#include <linux/mutex.h>
48#include <linux/videotext.h> 47#include <linux/videotext.h>
49#include <linux/videodev2.h> 48#include <linux/videodev2.h>
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 271d6e931b75..12835fb82c95 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -46,7 +46,6 @@
46#include <linux/mm.h> 46#include <linux/mm.h>
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/i2c.h> 48#include <linux/i2c.h>
49#include <linux/smp_lock.h>
50#include <linux/mutex.h> 49#include <linux/mutex.h>
51#include <linux/delay.h> 50#include <linux/delay.h>
52#include <linux/videotext.h> 51#include <linux/videotext.h>
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index add1757f8930..296788c3bf0e 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/smp_lock.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26 27
27#include "saa7134-reg.h" 28#include "saa7134-reg.h"
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c
index c8f05297d0f0..85ffc2cba039 100644
--- a/drivers/media/video/se401.c
+++ b/drivers/media/video/se401.c
@@ -31,6 +31,7 @@ static const char version[] = "0.24";
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/smp_lock.h>
34#include <linux/pagemap.h> 35#include <linux/pagemap.h>
35#include <linux/usb.h> 36#include <linux/usb.h>
36#include "se401.h" 37#include "se401.h"
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 16f595d4337a..9f5ae8167855 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -237,11 +237,11 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
237 return -ENOMEM; 237 return -ENOMEM;
238 238
239 icd->num_user_formats = fmts; 239 icd->num_user_formats = fmts;
240 fmts = 0;
241 240
242 dev_dbg(&icd->dev, "Found %d supported formats.\n", fmts); 241 dev_dbg(&icd->dev, "Found %d supported formats.\n", fmts);
243 242
244 /* Second pass - actually fill data formats */ 243 /* Second pass - actually fill data formats */
244 fmts = 0;
245 for (i = 0; i < icd->num_formats; i++) 245 for (i = 0; i < icd->num_formats; i++)
246 if (!ici->ops->get_formats) { 246 if (!ici->ops->get_formats) {
247 icd->user_formats[i].host_fmt = icd->formats + i; 247 icd->user_formats[i].host_fmt = icd->formats + i;
@@ -877,8 +877,11 @@ static int soc_camera_probe(struct device *dev)
877 (unsigned short)~0; 877 (unsigned short)~0;
878 878
879 ret = soc_camera_init_user_formats(icd); 879 ret = soc_camera_init_user_formats(icd);
880 if (ret < 0) 880 if (ret < 0) {
881 if (icd->ops->remove)
882 icd->ops->remove(icd);
881 goto eiufmt; 883 goto eiufmt;
884 }
882 885
883 icd->height = DEFAULT_HEIGHT; 886 icd->height = DEFAULT_HEIGHT;
884 icd->width = DEFAULT_WIDTH; 887 icd->width = DEFAULT_WIDTH;
@@ -902,8 +905,10 @@ static int soc_camera_remove(struct device *dev)
902{ 905{
903 struct soc_camera_device *icd = to_soc_camera_dev(dev); 906 struct soc_camera_device *icd = to_soc_camera_dev(dev);
904 907
908 mutex_lock(&icd->video_lock);
905 if (icd->ops->remove) 909 if (icd->ops->remove)
906 icd->ops->remove(icd); 910 icd->ops->remove(icd);
911 mutex_unlock(&icd->video_lock);
907 912
908 soc_camera_free_user_formats(icd); 913 soc_camera_free_user_formats(icd);
909 914
@@ -1145,6 +1150,7 @@ evidallocd:
1145} 1150}
1146EXPORT_SYMBOL(soc_camera_video_start); 1151EXPORT_SYMBOL(soc_camera_video_start);
1147 1152
1153/* Called from client .remove() methods with .video_lock held */
1148void soc_camera_video_stop(struct soc_camera_device *icd) 1154void soc_camera_video_stop(struct soc_camera_device *icd)
1149{ 1155{
1150 struct video_device *vdev = icd->vdev; 1156 struct video_device *vdev = icd->vdev;
@@ -1154,10 +1160,8 @@ void soc_camera_video_stop(struct soc_camera_device *icd)
1154 if (!icd->dev.parent || !vdev) 1160 if (!icd->dev.parent || !vdev)
1155 return; 1161 return;
1156 1162
1157 mutex_lock(&icd->video_lock);
1158 video_unregister_device(vdev); 1163 video_unregister_device(vdev);
1159 icd->vdev = NULL; 1164 icd->vdev = NULL;
1160 mutex_unlock(&icd->video_lock);
1161} 1165}
1162EXPORT_SYMBOL(soc_camera_video_stop); 1166EXPORT_SYMBOL(soc_camera_video_stop);
1163 1167
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index 2e5937047278..4d6785e63455 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/smp_lock.h>
30 31
31#include <linux/usb.h> 32#include <linux/usb.h>
32#include <linux/mm.h> 33#include <linux/mm.h>
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index 0eb313082c97..eaada39c76fd 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/major.h> 27#include <linux/major.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/smp_lock.h>
29#include <linux/mm.h> 30#include <linux/mm.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/poll.h> 32#include <linux/poll.h>
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 75f286f7a2e9..8b4e7dafce7b 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -62,6 +62,7 @@
62#include <linux/init.h> 62#include <linux/init.h>
63#include <linux/vmalloc.h> 63#include <linux/vmalloc.h>
64#include <linux/slab.h> 64#include <linux/slab.h>
65#include <linux/smp_lock.h>
65#include <linux/pagemap.h> 66#include <linux/pagemap.h>
66#include <linux/errno.h> 67#include <linux/errno.h>
67#include <linux/videodev.h> 68#include <linux/videodev.h>
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 8d73979596f9..45fce39ec9ad 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -43,6 +43,7 @@
43#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/slab.h> 45#include <linux/slab.h>
46#include <linux/smp_lock.h>
46#include <linux/mutex.h> 47#include <linux/mutex.h>
47#include <linux/firmware.h> 48#include <linux/firmware.h>
48#include <linux/ihex.h> 49#include <linux/ihex.h>
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 90b58914f984..90d9b5c0e9a7 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -50,6 +50,7 @@
50#include <linux/list.h> 50#include <linux/list.h>
51#include <linux/timer.h> 51#include <linux/timer.h>
52#include <linux/slab.h> 52#include <linux/slab.h>
53#include <linux/smp_lock.h>
53#include <linux/mm.h> 54#include <linux/mm.h>
54#include <linux/utsname.h> 55#include <linux/utsname.h>
55#include <linux/highmem.h> 56#include <linux/highmem.h>
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 31eac66411d7..a7f1b69a7dab 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -25,7 +25,6 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/kmod.h> 26#include <linux/kmod.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/smp_lock.h>
29#include <asm/uaccess.h> 28#include <asm/uaccess.h>
30#include <asm/system.h> 29#include <asm/system.h>
31 30
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index cd7266858462..7705fc6baf00 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -343,6 +343,53 @@ static struct bar_std bars[] = {
343#define TO_U(r, g, b) \ 343#define TO_U(r, g, b) \
344 (((-9714 * r - 19070 * g + 28784 * b + 32768) >> 16) + 128) 344 (((-9714 * r - 19070 * g + 28784 * b + 32768) >> 16) + 128)
345 345
346/* precalculate color bar values to speed up rendering */
347static void precalculate_bars(struct vivi_fh *fh)
348{
349 struct vivi_dev *dev = fh->dev;
350 unsigned char r, g, b;
351 int k, is_yuv;
352
353 fh->input = dev->input;
354
355 for (k = 0; k < 8; k++) {
356 r = bars[fh->input].bar[k][0];
357 g = bars[fh->input].bar[k][1];
358 b = bars[fh->input].bar[k][2];
359 is_yuv = 0;
360
361 switch (fh->fmt->fourcc) {
362 case V4L2_PIX_FMT_YUYV:
363 case V4L2_PIX_FMT_UYVY:
364 is_yuv = 1;
365 break;
366 case V4L2_PIX_FMT_RGB565:
367 case V4L2_PIX_FMT_RGB565X:
368 r >>= 3;
369 g >>= 2;
370 b >>= 3;
371 break;
372 case V4L2_PIX_FMT_RGB555:
373 case V4L2_PIX_FMT_RGB555X:
374 r >>= 3;
375 g >>= 3;
376 b >>= 3;
377 break;
378 }
379
380 if (is_yuv) {
381 fh->bars[k][0] = TO_Y(r, g, b); /* Luma */
382 fh->bars[k][1] = TO_U(r, g, b); /* Cb */
383 fh->bars[k][2] = TO_V(r, g, b); /* Cr */
384 } else {
385 fh->bars[k][0] = r;
386 fh->bars[k][1] = g;
387 fh->bars[k][2] = b;
388 }
389 }
390
391}
392
346#define TSTAMP_MIN_Y 24 393#define TSTAMP_MIN_Y 24
347#define TSTAMP_MAX_Y (TSTAMP_MIN_Y + 15) 394#define TSTAMP_MAX_Y (TSTAMP_MIN_Y + 15)
348#define TSTAMP_INPUT_X 10 395#define TSTAMP_INPUT_X 10
@@ -755,6 +802,8 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
755 buf->vb.height = fh->height; 802 buf->vb.height = fh->height;
756 buf->vb.field = field; 803 buf->vb.field = field;
757 804
805 precalculate_bars(fh);
806
758 if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { 807 if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
759 rc = videobuf_iolock(vq, &buf->vb, NULL); 808 rc = videobuf_iolock(vq, &buf->vb, NULL);
760 if (rc < 0) 809 if (rc < 0)
@@ -893,53 +942,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
893 return 0; 942 return 0;
894} 943}
895 944
896/* precalculate color bar values to speed up rendering */
897static void precalculate_bars(struct vivi_fh *fh)
898{
899 struct vivi_dev *dev = fh->dev;
900 unsigned char r, g, b;
901 int k, is_yuv;
902
903 fh->input = dev->input;
904
905 for (k = 0; k < 8; k++) {
906 r = bars[fh->input].bar[k][0];
907 g = bars[fh->input].bar[k][1];
908 b = bars[fh->input].bar[k][2];
909 is_yuv = 0;
910
911 switch (fh->fmt->fourcc) {
912 case V4L2_PIX_FMT_YUYV:
913 case V4L2_PIX_FMT_UYVY:
914 is_yuv = 1;
915 break;
916 case V4L2_PIX_FMT_RGB565:
917 case V4L2_PIX_FMT_RGB565X:
918 r >>= 3;
919 g >>= 2;
920 b >>= 3;
921 break;
922 case V4L2_PIX_FMT_RGB555:
923 case V4L2_PIX_FMT_RGB555X:
924 r >>= 3;
925 g >>= 3;
926 b >>= 3;
927 break;
928 }
929
930 if (is_yuv) {
931 fh->bars[k][0] = TO_Y(r, g, b); /* Luma */
932 fh->bars[k][1] = TO_U(r, g, b); /* Cb */
933 fh->bars[k][2] = TO_V(r, g, b); /* Cr */
934 } else {
935 fh->bars[k][0] = r;
936 fh->bars[k][1] = g;
937 fh->bars[k][2] = b;
938 }
939 }
940
941}
942
943/*FIXME: This seems to be generic enough to be at videodev2 */ 945/*FIXME: This seems to be generic enough to be at videodev2 */
944static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 946static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
945 struct v4l2_format *f) 947 struct v4l2_format *f)
@@ -965,8 +967,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
965 fh->vb_vidq.field = f->fmt.pix.field; 967 fh->vb_vidq.field = f->fmt.pix.field;
966 fh->type = f->type; 968 fh->type = f->type;
967 969
968 precalculate_bars(fh);
969
970 ret = 0; 970 ret = 0;
971out: 971out:
972 mutex_unlock(&q->vb_lock); 972 mutex_unlock(&q->vb_lock);
@@ -1357,6 +1357,7 @@ static int __init vivi_create_instance(int inst)
1357 goto unreg_dev; 1357 goto unreg_dev;
1358 1358
1359 *vfd = vivi_template; 1359 *vfd = vivi_template;
1360 vfd->debug = debug;
1360 1361
1361 ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr); 1362 ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
1362 if (ret < 0) 1363 if (ret < 0)
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c
index 3d7df32a3d87..bcdefb1bcb3d 100644
--- a/drivers/media/video/zoran/zoran_driver.c
+++ b/drivers/media/video/zoran/zoran_driver.c
@@ -49,6 +49,7 @@
49#include <linux/module.h> 49#include <linux/module.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/slab.h> 51#include <linux/slab.h>
52#include <linux/smp_lock.h>
52#include <linux/pci.h> 53#include <linux/pci.h>
53#include <linux/vmalloc.h> 54#include <linux/vmalloc.h>
54#include <linux/wait.h> 55#include <linux/wait.h>
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 7ac12cb0be4a..5b6e58a3ba46 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -32,8 +32,7 @@
32 * This driver was tested with firmware revision A4. 32 * This driver was tested with firmware revision A4.
33 */ 33 */
34 34
35#if defined(CONFIG_KEYBOARD_DM355EVM) \ 35#if defined(CONFIG_INPUT_DM355EVM) || defined(CONFIG_INPUT_DM355EVM_MODULE)
36 || defined(CONFIG_KEYBOARD_DM355EVM_MODULE)
37#define msp_has_keyboard() true 36#define msp_has_keyboard() true
38#else 37#else
39#define msp_has_keyboard() false 38#define msp_has_keyboard() false
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index 671a7efe86a8..c1de4afa89a6 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -238,8 +238,10 @@ static irqreturn_t pcap_adc_irq(int irq, void *_pcap)
238 mutex_lock(&pcap->adc_mutex); 238 mutex_lock(&pcap->adc_mutex);
239 req = pcap->adc_queue[pcap->adc_head]; 239 req = pcap->adc_queue[pcap->adc_head];
240 240
241 if (WARN(!req, KERN_WARNING "adc irq without pending request\n")) 241 if (WARN(!req, KERN_WARNING "adc irq without pending request\n")) {
242 mutex_unlock(&pcap->adc_mutex);
242 return IRQ_HANDLED; 243 return IRQ_HANDLED;
244 }
243 245
244 /* read requested channels results */ 246 /* read requested channels results */
245 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp); 247 ezx_pcap_read(pcap, PCAP_REG_ADC, &tmp);
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 4c7b7962f6b8..0cc5eeff5ee8 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -367,7 +367,8 @@ int sm501_unit_power(struct device *dev, unsigned int unit, unsigned int to)
367 break; 367 break;
368 368
369 default: 369 default:
370 return -1; 370 gate = -1;
371 goto already;
371 } 372 }
372 373
373 writel(mode, sm->regs + SM501_POWER_MODE_CONTROL); 374 writel(mode, sm->regs + SM501_POWER_MODE_CONTROL);
diff --git a/drivers/misc/sgi-gru/grufile.c b/drivers/misc/sgi-gru/grufile.c
index fa2d93a9fb8d..aed609832bc2 100644
--- a/drivers/misc/sgi-gru/grufile.c
+++ b/drivers/misc/sgi-gru/grufile.c
@@ -29,7 +29,6 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/io.h> 31#include <linux/io.h>
32#include <linux/smp_lock.h>
33#include <linux/spinlock.h> 32#include <linux/spinlock.h>
34#include <linux/device.h> 33#include <linux/device.h>
35#include <linux/miscdevice.h> 34#include <linux/miscdevice.h>
diff --git a/drivers/misc/sgi-gru/grukservices.c b/drivers/misc/sgi-gru/grukservices.c
index eedbf9c32760..79689b10f937 100644
--- a/drivers/misc/sgi-gru/grukservices.c
+++ b/drivers/misc/sgi-gru/grukservices.c
@@ -24,7 +24,6 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/smp_lock.h>
28#include <linux/spinlock.h> 27#include <linux/spinlock.h>
29#include <linux/device.h> 28#include <linux/device.h>
30#include <linux/miscdevice.h> 29#include <linux/miscdevice.h>
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index 8d1c60a3f0df..5d778ec8cdb2 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -235,7 +235,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
235 skb->ip_summed = CHECKSUM_UNNECESSARY; 235 skb->ip_summed = CHECKSUM_UNNECESSARY;
236 236
237 dev_dbg(xpnet, "passing skb to network layer\n" 237 dev_dbg(xpnet, "passing skb to network layer\n"
238 KERN_DEBUG "\tskb->head=0x%p skb->data=0x%p skb->tail=0x%p " 238 "\tskb->head=0x%p skb->data=0x%p skb->tail=0x%p "
239 "skb->end=0x%p skb->len=%d\n", 239 "skb->end=0x%p skb->len=%d\n",
240 (void *)skb->head, (void *)skb->data, skb_tail_pointer(skb), 240 (void *)skb->head, (void *)skb->data, skb_tail_pointer(skb),
241 skb_end_pointer(skb), skb->len); 241 skb_end_pointer(skb), skb->len);
@@ -399,7 +399,7 @@ xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg,
399 msg->buf_pa = xp_pa((void *)start_addr); 399 msg->buf_pa = xp_pa((void *)start_addr);
400 400
401 dev_dbg(xpnet, "sending XPC message to %d:%d\n" 401 dev_dbg(xpnet, "sending XPC message to %d:%d\n"
402 KERN_DEBUG "msg->buf_pa=0x%lx, msg->size=%u, " 402 "msg->buf_pa=0x%lx, msg->size=%u, "
403 "msg->leadin_ignore=%u, msg->tailout_ignore=%u\n", 403 "msg->leadin_ignore=%u, msg->tailout_ignore=%u\n",
404 dest_partid, XPC_NET_CHANNEL, msg->buf_pa, msg->size, 404 dest_partid, XPC_NET_CHANNEL, msg->buf_pa, msg->size,
405 msg->leadin_ignore, msg->tailout_ignore); 405 msg->leadin_ignore, msg->tailout_ignore);
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 240608cc7ae9..a461017ce5ce 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1313,6 +1313,12 @@ static int mmc_spi_probe(struct spi_device *spi)
1313 struct mmc_spi_host *host; 1313 struct mmc_spi_host *host;
1314 int status; 1314 int status;
1315 1315
1316 /* We rely on full duplex transfers, mostly to reduce
1317 * per-transfer overheads (by making fewer transfers).
1318 */
1319 if (spi->master->flags & SPI_MASTER_HALF_DUPLEX)
1320 return -EINVAL;
1321
1316 /* MMC and SD specs only seem to care that sampling is on the 1322 /* MMC and SD specs only seem to care that sampling is on the
1317 * rising edge ... meaning SPI modes 0 or 3. So either SPI mode 1323 * rising edge ... meaning SPI modes 0 or 3. So either SPI mode
1318 * should be legit. We'll use mode 0 since the steady state is 0, 1324 * should be legit. We'll use mode 0 since the steady state is 0,
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index 5011fa73f918..1479da6d3aa6 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -194,7 +194,7 @@ static struct mtd_partition * newpart(char *s,
194 parts[this_part].name = extra_mem; 194 parts[this_part].name = extra_mem;
195 extra_mem += name_len + 1; 195 extra_mem += name_len + 1;
196 196
197 dbg(("partition %d: name <%s>, offset %x, size %x, mask flags %x\n", 197 dbg(("partition %d: name <%s>, offset %llx, size %llx, mask flags %x\n",
198 this_part, 198 this_part,
199 parts[this_part].name, 199 parts[this_part].name,
200 parts[this_part].offset, 200 parts[this_part].offset,
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 59c46126a5ce..ae5fe91867e1 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -54,7 +54,7 @@
54#define SR_SRWD 0x80 /* SR write protect */ 54#define SR_SRWD 0x80 /* SR write protect */
55 55
56/* Define max times to check status register before we give up. */ 56/* Define max times to check status register before we give up. */
57#define MAX_READY_WAIT_JIFFIES (10 * HZ) /* eg. M25P128 specs 6s max sector erase */ 57#define MAX_READY_WAIT_JIFFIES (40 * HZ) /* M25P16 specs 40s max chip erase */
58#define CMD_SIZE 4 58#define CMD_SIZE 4
59 59
60#ifdef CONFIG_M25PXX_USE_FAST_READ 60#ifdef CONFIG_M25PXX_USE_FAST_READ
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
index 73f05227dc8c..d8cf29c01cc4 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -226,7 +226,7 @@ static u16 INFTL_findfreeblock(struct INFTLrecord *inftl, int desperate)
226 if (!desperate && inftl->numfreeEUNs < 2) { 226 if (!desperate && inftl->numfreeEUNs < 2) {
227 DEBUG(MTD_DEBUG_LEVEL1, "INFTL: there are too few free " 227 DEBUG(MTD_DEBUG_LEVEL1, "INFTL: there are too few free "
228 "EUNs (%d)\n", inftl->numfreeEUNs); 228 "EUNs (%d)\n", inftl->numfreeEUNs);
229 return 0xffff; 229 return BLOCK_NIL;
230 } 230 }
231 231
232 /* Scan for a free block */ 232 /* Scan for a free block */
@@ -281,7 +281,8 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
281 silly = MAX_LOOPS; 281 silly = MAX_LOOPS;
282 while (thisEUN < inftl->nb_blocks) { 282 while (thisEUN < inftl->nb_blocks) {
283 for (block = 0; block < inftl->EraseSize/SECTORSIZE; block ++) { 283 for (block = 0; block < inftl->EraseSize/SECTORSIZE; block ++) {
284 if ((BlockMap[block] != 0xffff) || BlockDeleted[block]) 284 if ((BlockMap[block] != BLOCK_NIL) ||
285 BlockDeleted[block])
285 continue; 286 continue;
286 287
287 if (inftl_read_oob(mtd, (thisEUN * inftl->EraseSize) 288 if (inftl_read_oob(mtd, (thisEUN * inftl->EraseSize)
@@ -525,7 +526,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
525 if (!silly--) { 526 if (!silly--) {
526 printk(KERN_WARNING "INFTL: infinite loop in " 527 printk(KERN_WARNING "INFTL: infinite loop in "
527 "Virtual Unit Chain 0x%x\n", thisVUC); 528 "Virtual Unit Chain 0x%x\n", thisVUC);
528 return 0xffff; 529 return BLOCK_NIL;
529 } 530 }
530 531
531 /* Skip to next block in chain */ 532 /* Skip to next block in chain */
@@ -549,7 +550,7 @@ hitused:
549 * waiting to be picked up. We're going to have to fold 550 * waiting to be picked up. We're going to have to fold
550 * a chain to make room. 551 * a chain to make room.
551 */ 552 */
552 thisEUN = INFTL_makefreeblock(inftl, 0xffff); 553 thisEUN = INFTL_makefreeblock(inftl, BLOCK_NIL);
553 554
554 /* 555 /*
555 * Hopefully we free something, lets try again. 556 * Hopefully we free something, lets try again.
@@ -631,7 +632,7 @@ hitused:
631 632
632 printk(KERN_WARNING "INFTL: error folding to make room for Virtual " 633 printk(KERN_WARNING "INFTL: error folding to make room for Virtual "
633 "Unit Chain 0x%x\n", thisVUC); 634 "Unit Chain 0x%x\n", thisVUC);
634 return 0xffff; 635 return BLOCK_NIL;
635} 636}
636 637
637/* 638/*
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
index b08a798ee254..2aac41bde8b3 100644
--- a/drivers/mtd/maps/integrator-flash.c
+++ b/drivers/mtd/maps/integrator-flash.c
@@ -42,10 +42,8 @@
42#include <mach/hardware.h> 42#include <mach/hardware.h>
43#include <asm/system.h> 43#include <asm/system.h>
44 44
45#define SUBDEV_NAME_SIZE (BUS_ID_SIZE + 2)
46
47struct armflash_subdev_info { 45struct armflash_subdev_info {
48 char name[SUBDEV_NAME_SIZE]; 46 char *name;
49 struct mtd_info *mtd; 47 struct mtd_info *mtd;
50 struct map_info map; 48 struct map_info map;
51 struct flash_platform_data *plat; 49 struct flash_platform_data *plat;
@@ -134,6 +132,8 @@ static void armflash_subdev_remove(struct armflash_subdev_info *subdev)
134 map_destroy(subdev->mtd); 132 map_destroy(subdev->mtd);
135 if (subdev->map.virt) 133 if (subdev->map.virt)
136 iounmap(subdev->map.virt); 134 iounmap(subdev->map.virt);
135 kfree(subdev->name);
136 subdev->name = NULL;
137 release_mem_region(subdev->map.phys, subdev->map.size); 137 release_mem_region(subdev->map.phys, subdev->map.size);
138} 138}
139 139
@@ -177,16 +177,22 @@ static int armflash_probe(struct platform_device *dev)
177 177
178 if (nr == 1) 178 if (nr == 1)
179 /* No MTD concatenation, just use the default name */ 179 /* No MTD concatenation, just use the default name */
180 snprintf(subdev->name, SUBDEV_NAME_SIZE, "%s", 180 subdev->name = kstrdup(dev_name(&dev->dev), GFP_KERNEL);
181 dev_name(&dev->dev));
182 else 181 else
183 snprintf(subdev->name, SUBDEV_NAME_SIZE, "%s-%d", 182 subdev->name = kasprintf(GFP_KERNEL, "%s-%d",
184 dev_name(&dev->dev), i); 183 dev_name(&dev->dev), i);
184 if (!subdev->name) {
185 err = -ENOMEM;
186 break;
187 }
185 subdev->plat = plat; 188 subdev->plat = plat;
186 189
187 err = armflash_subdev_probe(subdev, res); 190 err = armflash_subdev_probe(subdev, res);
188 if (err) 191 if (err) {
192 kfree(subdev->name);
193 subdev->name = NULL;
189 break; 194 break;
195 }
190 } 196 }
191 info->nr_subdev = i; 197 info->nr_subdev = i;
192 198
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 2802992b39da..20c828ba9405 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -534,7 +534,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
534 &num_partitions); 534 &num_partitions);
535 535
536 if ((!partitions) || (num_partitions == 0)) { 536 if ((!partitions) || (num_partitions == 0)) {
537 printk(KERN_ERR "atmel_nand: No parititions defined, or unsupported device.\n"); 537 printk(KERN_ERR "atmel_nand: No partitions defined, or unsupported device.\n");
538 res = ENXIO; 538 res = ENXIO;
539 goto err_no_partitions; 539 goto err_no_partitions;
540 } 540 }
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 0cd76f89f4b0..ebd07e95b814 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -11,6 +11,8 @@
11#include <linux/platform_device.h> 11#include <linux/platform_device.h>
12#include <linux/dma-mapping.h> 12#include <linux/dma-mapping.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/jiffies.h>
15#include <linux/sched.h>
14#include <linux/mtd/mtd.h> 16#include <linux/mtd/mtd.h>
15#include <linux/mtd/nand.h> 17#include <linux/mtd/nand.h>
16#include <linux/mtd/partitions.h> 18#include <linux/mtd/partitions.h>
@@ -541,7 +543,7 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)
541 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 543 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
542 mtd); 544 mtd);
543 unsigned long timeo = jiffies; 545 unsigned long timeo = jiffies;
544 int status, state = this->state; 546 int status = NAND_STATUS_FAIL, state = this->state;
545 547
546 if (state == FL_ERASING) 548 if (state == FL_ERASING)
547 timeo += (HZ * 400) / 1000; 549 timeo += (HZ * 400) / 1000;
@@ -556,8 +558,9 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)
556 558
557 while (time_before(jiffies, timeo)) { 559 while (time_before(jiffies, timeo)) {
558 status = __raw_readb(this->IO_ADDR_R); 560 status = __raw_readb(this->IO_ADDR_R);
559 if (!(status & 0x40)) 561 if (status & NAND_STATUS_READY)
560 break; 562 break;
563 cond_resched();
561 } 564 }
562 return status; 565 return status;
563} 566}
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index e3f8495a94c2..fb86cacd5bdb 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -208,7 +208,7 @@ static u16 NFTL_findfreeblock(struct NFTLrecord *nftl, int desperate )
208 /* Normally, we force a fold to happen before we run out of free blocks completely */ 208 /* Normally, we force a fold to happen before we run out of free blocks completely */
209 if (!desperate && nftl->numfreeEUNs < 2) { 209 if (!desperate && nftl->numfreeEUNs < 2) {
210 DEBUG(MTD_DEBUG_LEVEL1, "NFTL_findfreeblock: there are too few free EUNs\n"); 210 DEBUG(MTD_DEBUG_LEVEL1, "NFTL_findfreeblock: there are too few free EUNs\n");
211 return 0xffff; 211 return BLOCK_NIL;
212 } 212 }
213 213
214 /* Scan for a free block */ 214 /* Scan for a free block */
@@ -230,11 +230,11 @@ static u16 NFTL_findfreeblock(struct NFTLrecord *nftl, int desperate )
230 printk("Argh! No free blocks found! LastFreeEUN = %d, " 230 printk("Argh! No free blocks found! LastFreeEUN = %d, "
231 "FirstEUN = %d\n", nftl->LastFreeEUN, 231 "FirstEUN = %d\n", nftl->LastFreeEUN,
232 le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)); 232 le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN));
233 return 0xffff; 233 return BLOCK_NIL;
234 } 234 }
235 } while (pot != nftl->LastFreeEUN); 235 } while (pot != nftl->LastFreeEUN);
236 236
237 return 0xffff; 237 return BLOCK_NIL;
238} 238}
239 239
240static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned pendingblock ) 240static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned pendingblock )
@@ -431,7 +431,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
431 431
432 /* add the header so that it is now a valid chain */ 432 /* add the header so that it is now a valid chain */
433 oob.u.a.VirtUnitNum = oob.u.a.SpareVirtUnitNum = cpu_to_le16(thisVUC); 433 oob.u.a.VirtUnitNum = oob.u.a.SpareVirtUnitNum = cpu_to_le16(thisVUC);
434 oob.u.a.ReplUnitNum = oob.u.a.SpareReplUnitNum = 0xffff; 434 oob.u.a.ReplUnitNum = oob.u.a.SpareReplUnitNum = BLOCK_NIL;
435 435
436 nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 8, 436 nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 8,
437 8, &retlen, (char *)&oob.u); 437 8, &retlen, (char *)&oob.u);
@@ -515,7 +515,7 @@ static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
515 if (ChainLength < 2) { 515 if (ChainLength < 2) {
516 printk(KERN_WARNING "No Virtual Unit Chains available for folding. " 516 printk(KERN_WARNING "No Virtual Unit Chains available for folding. "
517 "Failing request\n"); 517 "Failing request\n");
518 return 0xffff; 518 return BLOCK_NIL;
519 } 519 }
520 520
521 return NFTL_foldchain (nftl, LongestChain, pendingblock); 521 return NFTL_foldchain (nftl, LongestChain, pendingblock);
@@ -578,7 +578,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
578 printk(KERN_WARNING 578 printk(KERN_WARNING
579 "Infinite loop in Virtual Unit Chain 0x%x\n", 579 "Infinite loop in Virtual Unit Chain 0x%x\n",
580 thisVUC); 580 thisVUC);
581 return 0xffff; 581 return BLOCK_NIL;
582 } 582 }
583 583
584 /* Skip to next block in chain */ 584 /* Skip to next block in chain */
@@ -601,7 +601,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
601 //u16 startEUN = nftl->EUNtable[thisVUC]; 601 //u16 startEUN = nftl->EUNtable[thisVUC];
602 602
603 //printk("Write to VirtualUnitChain %d, calling makefreeblock()\n", thisVUC); 603 //printk("Write to VirtualUnitChain %d, calling makefreeblock()\n", thisVUC);
604 writeEUN = NFTL_makefreeblock(nftl, 0xffff); 604 writeEUN = NFTL_makefreeblock(nftl, BLOCK_NIL);
605 605
606 if (writeEUN == BLOCK_NIL) { 606 if (writeEUN == BLOCK_NIL) {
607 /* OK, we accept that the above comment is 607 /* OK, we accept that the above comment is
@@ -673,7 +673,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
673 673
674 printk(KERN_WARNING "Error folding to make room for Virtual Unit Chain 0x%x\n", 674 printk(KERN_WARNING "Error folding to make room for Virtual Unit Chain 0x%x\n",
675 thisVUC); 675 thisVUC);
676 return 0xffff; 676 return BLOCK_NIL;
677} 677}
678 678
679static int nftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block, 679static int nftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block,
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 286ed594e5a0..e1f7d0a78b9d 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -657,6 +657,11 @@ static int io_init(struct ubi_device *ubi)
657 if (ubi->mtd->block_isbad && ubi->mtd->block_markbad) 657 if (ubi->mtd->block_isbad && ubi->mtd->block_markbad)
658 ubi->bad_allowed = 1; 658 ubi->bad_allowed = 1;
659 659
660 if (ubi->mtd->type == MTD_NORFLASH) {
661 ubi_assert(ubi->mtd->writesize == 1);
662 ubi->nor_flash = 1;
663 }
664
660 ubi->min_io_size = ubi->mtd->writesize; 665 ubi->min_io_size = ubi->mtd->writesize;
661 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; 666 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
662 667
@@ -996,6 +1001,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
996 ubi_msg("number of PEBs reserved for bad PEB handling: %d", 1001 ubi_msg("number of PEBs reserved for bad PEB handling: %d",
997 ubi->beb_rsvd_pebs); 1002 ubi->beb_rsvd_pebs);
998 ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec); 1003 ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec);
1004 ubi_msg("image sequence number: %d", ubi->image_seq);
999 1005
1000 /* 1006 /*
1001 * The below lock makes sure we do not race with 'ubi_thread()' which 1007 * The below lock makes sure we do not race with 'ubi_thread()' which
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index c0ed60e8ade9..54b0186915fb 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -44,6 +44,8 @@ void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr)
44 be32_to_cpu(ec_hdr->vid_hdr_offset)); 44 be32_to_cpu(ec_hdr->vid_hdr_offset));
45 printk(KERN_DEBUG "\tdata_offset %d\n", 45 printk(KERN_DEBUG "\tdata_offset %d\n",
46 be32_to_cpu(ec_hdr->data_offset)); 46 be32_to_cpu(ec_hdr->data_offset));
47 printk(KERN_DEBUG "\timage_seq %d\n",
48 be32_to_cpu(ec_hdr->image_seq));
47 printk(KERN_DEBUG "\thdr_crc %#08x\n", 49 printk(KERN_DEBUG "\thdr_crc %#08x\n",
48 be32_to_cpu(ec_hdr->hdr_crc)); 50 be32_to_cpu(ec_hdr->hdr_crc));
49 printk(KERN_DEBUG "erase counter header hexdump:\n"); 51 printk(KERN_DEBUG "erase counter header hexdump:\n");
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index 13777e5beac9..a4da7a09b949 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -93,6 +93,12 @@ void ubi_dbg_dump_mkvol_req(const struct ubi_mkvol_req *req);
93#define UBI_IO_DEBUG 0 93#define UBI_IO_DEBUG 0
94#endif 94#endif
95 95
96#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
97int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len);
98#else
99#define ubi_dbg_check_all_ff(ubi, pnum, offset, len) 0
100#endif
101
96#ifdef CONFIG_MTD_UBI_DEBUG_DISABLE_BGT 102#ifdef CONFIG_MTD_UBI_DEBUG_DISABLE_BGT
97#define DBG_DISABLE_BGT 1 103#define DBG_DISABLE_BGT 1
98#else 104#else
@@ -167,6 +173,7 @@ static inline int ubi_dbg_is_erase_failure(void)
167#define ubi_dbg_is_bitflip() 0 173#define ubi_dbg_is_bitflip() 0
168#define ubi_dbg_is_write_failure() 0 174#define ubi_dbg_is_write_failure() 0
169#define ubi_dbg_is_erase_failure() 0 175#define ubi_dbg_is_erase_failure() 0
176#define ubi_dbg_check_all_ff(ubi, pnum, offset, len) 0
170 177
171#endif /* !CONFIG_MTD_UBI_DEBUG */ 178#endif /* !CONFIG_MTD_UBI_DEBUG */
172#endif /* !__UBI_DEBUG_H__ */ 179#endif /* !__UBI_DEBUG_H__ */
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index effaff28bab1..4cb69925d8d9 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -98,17 +98,12 @@ static int paranoid_check_ec_hdr(const struct ubi_device *ubi, int pnum,
98static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum); 98static int paranoid_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum);
99static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum, 99static int paranoid_check_vid_hdr(const struct ubi_device *ubi, int pnum,
100 const struct ubi_vid_hdr *vid_hdr); 100 const struct ubi_vid_hdr *vid_hdr);
101static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
102 int len);
103static int paranoid_check_empty(struct ubi_device *ubi, int pnum);
104#else 101#else
105#define paranoid_check_not_bad(ubi, pnum) 0 102#define paranoid_check_not_bad(ubi, pnum) 0
106#define paranoid_check_peb_ec_hdr(ubi, pnum) 0 103#define paranoid_check_peb_ec_hdr(ubi, pnum) 0
107#define paranoid_check_ec_hdr(ubi, pnum, ec_hdr) 0 104#define paranoid_check_ec_hdr(ubi, pnum, ec_hdr) 0
108#define paranoid_check_peb_vid_hdr(ubi, pnum) 0 105#define paranoid_check_peb_vid_hdr(ubi, pnum) 0
109#define paranoid_check_vid_hdr(ubi, pnum, vid_hdr) 0 106#define paranoid_check_vid_hdr(ubi, pnum, vid_hdr) 0
110#define paranoid_check_all_ff(ubi, pnum, offset, len) 0
111#define paranoid_check_empty(ubi, pnum) 0
112#endif 107#endif
113 108
114/** 109/**
@@ -244,7 +239,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
244 return err > 0 ? -EINVAL : err; 239 return err > 0 ? -EINVAL : err;
245 240
246 /* The area we are writing to has to contain all 0xFF bytes */ 241 /* The area we are writing to has to contain all 0xFF bytes */
247 err = paranoid_check_all_ff(ubi, pnum, offset, len); 242 err = ubi_dbg_check_all_ff(ubi, pnum, offset, len);
248 if (err) 243 if (err)
249 return err > 0 ? -EINVAL : err; 244 return err > 0 ? -EINVAL : err;
250 245
@@ -271,8 +266,8 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
271 addr = (loff_t)pnum * ubi->peb_size + offset; 266 addr = (loff_t)pnum * ubi->peb_size + offset;
272 err = ubi->mtd->write(ubi->mtd, addr, len, &written, buf); 267 err = ubi->mtd->write(ubi->mtd, addr, len, &written, buf);
273 if (err) { 268 if (err) {
274 ubi_err("error %d while writing %d bytes to PEB %d:%d, written" 269 ubi_err("error %d while writing %d bytes to PEB %d:%d, written "
275 " %zd bytes", err, len, pnum, offset, written); 270 "%zd bytes", err, len, pnum, offset, written);
276 ubi_dbg_dump_stack(); 271 ubi_dbg_dump_stack();
277 } else 272 } else
278 ubi_assert(written == len); 273 ubi_assert(written == len);
@@ -350,7 +345,7 @@ retry:
350 return -EIO; 345 return -EIO;
351 } 346 }
352 347
353 err = paranoid_check_all_ff(ubi, pnum, 0, ubi->peb_size); 348 err = ubi_dbg_check_all_ff(ubi, pnum, 0, ubi->peb_size);
354 if (err) 349 if (err)
355 return err > 0 ? -EINVAL : err; 350 return err > 0 ? -EINVAL : err;
356 351
@@ -459,6 +454,54 @@ out:
459} 454}
460 455
461/** 456/**
457 * nor_erase_prepare - prepare a NOR flash PEB for erasure.
458 * @ubi: UBI device description object
459 * @pnum: physical eraseblock number to prepare
460 *
461 * NOR flash, or at least some of them, have peculiar embedded PEB erasure
462 * algorithm: the PEB is first filled with zeroes, then it is erased. And
463 * filling with zeroes starts from the end of the PEB. This was observed with
464 * Spansion S29GL512N NOR flash.
465 *
466 * This means that in case of a power cut we may end up with intact data at the
467 * beginning of the PEB, and all zeroes at the end of PEB. In other words, the
468 * EC and VID headers are OK, but a large chunk of data at the end of PEB is
469 * zeroed. This makes UBI mistakenly treat this PEB as used and associate it
470 * with an LEB, which leads to subsequent failures (e.g., UBIFS fails).
471 *
472 * This function is called before erasing NOR PEBs and it zeroes out EC and VID
473 * magic numbers in order to invalidate them and prevent the failures. Returns
474 * zero in case of success and a negative error code in case of failure.
475 */
476static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
477{
478 int err;
479 size_t written;
480 loff_t addr;
481 uint32_t data = 0;
482
483 addr = (loff_t)pnum * ubi->peb_size;
484 err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data);
485 if (err) {
486 ubi_err("error %d while writing 4 bytes to PEB %d:%d, written "
487 "%zd bytes", err, pnum, 0, written);
488 ubi_dbg_dump_stack();
489 return err;
490 }
491
492 addr += ubi->vid_hdr_aloffset;
493 err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data);
494 if (err) {
495 ubi_err("error %d while writing 4 bytes to PEB %d:%d, written "
496 "%zd bytes", err, pnum, ubi->vid_hdr_aloffset, written);
497 ubi_dbg_dump_stack();
498 return err;
499 }
500
501 return 0;
502}
503
504/**
462 * ubi_io_sync_erase - synchronously erase a physical eraseblock. 505 * ubi_io_sync_erase - synchronously erase a physical eraseblock.
463 * @ubi: UBI device description object 506 * @ubi: UBI device description object
464 * @pnum: physical eraseblock number to erase 507 * @pnum: physical eraseblock number to erase
@@ -489,6 +532,12 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)
489 return -EROFS; 532 return -EROFS;
490 } 533 }
491 534
535 if (ubi->nor_flash) {
536 err = nor_erase_prepare(ubi, pnum);
537 if (err)
538 return err;
539 }
540
492 if (torture) { 541 if (torture) {
493 ret = torture_peb(ubi, pnum); 542 ret = torture_peb(ubi, pnum);
494 if (ret < 0) 543 if (ret < 0)
@@ -672,11 +721,6 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
672 if (read_err != -EBADMSG && 721 if (read_err != -EBADMSG &&
673 check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) { 722 check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
674 /* The physical eraseblock is supposedly empty */ 723 /* The physical eraseblock is supposedly empty */
675 err = paranoid_check_all_ff(ubi, pnum, 0,
676 ubi->peb_size);
677 if (err)
678 return err > 0 ? UBI_IO_BAD_EC_HDR : err;
679
680 if (verbose) 724 if (verbose)
681 ubi_warn("no EC header found at PEB %d, " 725 ubi_warn("no EC header found at PEB %d, "
682 "only 0xFF bytes", pnum); 726 "only 0xFF bytes", pnum);
@@ -752,6 +796,7 @@ int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum,
752 ec_hdr->version = UBI_VERSION; 796 ec_hdr->version = UBI_VERSION;
753 ec_hdr->vid_hdr_offset = cpu_to_be32(ubi->vid_hdr_offset); 797 ec_hdr->vid_hdr_offset = cpu_to_be32(ubi->vid_hdr_offset);
754 ec_hdr->data_offset = cpu_to_be32(ubi->leb_start); 798 ec_hdr->data_offset = cpu_to_be32(ubi->leb_start);
799 ec_hdr->image_seq = cpu_to_be32(ubi->image_seq);
755 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); 800 crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC);
756 ec_hdr->hdr_crc = cpu_to_be32(crc); 801 ec_hdr->hdr_crc = cpu_to_be32(crc);
757 802
@@ -947,15 +992,6 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
947 if (read_err != -EBADMSG && 992 if (read_err != -EBADMSG &&
948 check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) { 993 check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) {
949 /* The physical eraseblock is supposedly free */ 994 /* The physical eraseblock is supposedly free */
950
951 /*
952 * The below is just a paranoid check, it has to be
953 * compiled out if paranoid checks are disabled.
954 */
955 err = paranoid_check_empty(ubi, pnum);
956 if (err)
957 return err > 0 ? UBI_IO_BAD_VID_HDR : err;
958
959 if (verbose) 995 if (verbose)
960 ubi_warn("no VID header found at PEB %d, " 996 ubi_warn("no VID header found at PEB %d, "
961 "only 0xFF bytes", pnum); 997 "only 0xFF bytes", pnum);
@@ -1229,7 +1265,7 @@ exit:
1229} 1265}
1230 1266
1231/** 1267/**
1232 * paranoid_check_all_ff - check that a region of flash is empty. 1268 * ubi_dbg_check_all_ff - check that a region of flash is empty.
1233 * @ubi: UBI device description object 1269 * @ubi: UBI device description object
1234 * @pnum: the physical eraseblock number to check 1270 * @pnum: the physical eraseblock number to check
1235 * @offset: the starting offset within the physical eraseblock to check 1271 * @offset: the starting offset within the physical eraseblock to check
@@ -1239,8 +1275,7 @@ exit:
1239 * @offset of the physical eraseblock @pnum, %1 if not, and a negative error 1275 * @offset of the physical eraseblock @pnum, %1 if not, and a negative error
1240 * code if an error occurred. 1276 * code if an error occurred.
1241 */ 1277 */
1242static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset, 1278int ubi_dbg_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
1243 int len)
1244{ 1279{
1245 size_t read; 1280 size_t read;
1246 int err; 1281 int err;
@@ -1276,74 +1311,4 @@ error:
1276 return err; 1311 return err;
1277} 1312}
1278 1313
1279/**
1280 * paranoid_check_empty - whether a PEB is empty.
1281 * @ubi: UBI device description object
1282 * @pnum: the physical eraseblock number to check
1283 *
1284 * This function makes sure PEB @pnum is empty, which means it contains only
1285 * %0xFF data bytes. Returns zero if the PEB is empty, %1 if not, and a
1286 * negative error code in case of failure.
1287 *
1288 * Empty PEBs have the EC header, and do not have the VID header. The caller of
1289 * this function should have already made sure the PEB does not have the VID
1290 * header. However, this function re-checks that, because it is possible that
1291 * the header and data has already been written to the PEB.
1292 *
1293 * Let's consider a possible scenario. Suppose there are 2 tasks - A and B.
1294 * Task A is in 'wear_leveling_worker()'. It is reading VID header of PEB X to
1295 * find which LEB it corresponds to. PEB X is currently unmapped, and has no
1296 * VID header. Task B is trying to write to PEB X.
1297 *
1298 * Task A: in 'ubi_io_read_vid_hdr()': reads the VID header from PEB X. The
1299 * read data contain all 0xFF bytes;
1300 * Task B: writes VID header and some data to PEB X;
1301 * Task A: assumes PEB X is empty, calls 'paranoid_check_empty()'. And if we
1302 * do not re-read the VID header, and do not cancel the checking if it
1303 * is there, we fail.
1304 */
1305static int paranoid_check_empty(struct ubi_device *ubi, int pnum)
1306{
1307 int err, offs = ubi->vid_hdr_aloffset, len = ubi->vid_hdr_alsize;
1308 size_t read;
1309 uint32_t magic;
1310 const struct ubi_vid_hdr *vid_hdr;
1311
1312 mutex_lock(&ubi->dbg_buf_mutex);
1313 err = ubi->mtd->read(ubi->mtd, offs, len, &read, ubi->dbg_peb_buf);
1314 if (err && err != -EUCLEAN) {
1315 ubi_err("error %d while reading %d bytes from PEB %d:%d, "
1316 "read %zd bytes", err, len, pnum, offs, read);
1317 goto error;
1318 }
1319
1320 vid_hdr = ubi->dbg_peb_buf;
1321 magic = be32_to_cpu(vid_hdr->magic);
1322 if (magic == UBI_VID_HDR_MAGIC)
1323 /* The PEB contains VID header, so it is not empty */
1324 goto out;
1325
1326 err = check_pattern(ubi->dbg_peb_buf, 0xFF, len);
1327 if (err == 0) {
1328 ubi_err("flash region at PEB %d:%d, length %d does not "
1329 "contain all 0xFF bytes", pnum, offs, len);
1330 goto fail;
1331 }
1332
1333out:
1334 mutex_unlock(&ubi->dbg_buf_mutex);
1335 return 0;
1336
1337fail:
1338 ubi_err("paranoid check failed for PEB %d", pnum);
1339 ubi_msg("hex dump of the %d-%d region", offs, offs + len);
1340 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
1341 ubi->dbg_peb_buf, len, 1);
1342 err = 1;
1343error:
1344 ubi_dbg_dump_stack();
1345 mutex_unlock(&ubi->dbg_buf_mutex);
1346 return err;
1347}
1348
1349#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */ 1314#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index c3d653ba5ca0..f60895ee0aeb 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -757,6 +757,8 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
757 si->is_empty = 0; 757 si->is_empty = 0;
758 758
759 if (!ec_corr) { 759 if (!ec_corr) {
760 int image_seq;
761
760 /* Make sure UBI version is OK */ 762 /* Make sure UBI version is OK */
761 if (ech->version != UBI_VERSION) { 763 if (ech->version != UBI_VERSION) {
762 ubi_err("this UBI version is %d, image version is %d", 764 ubi_err("this UBI version is %d, image version is %d",
@@ -778,6 +780,18 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
778 ubi_dbg_dump_ec_hdr(ech); 780 ubi_dbg_dump_ec_hdr(ech);
779 return -EINVAL; 781 return -EINVAL;
780 } 782 }
783
784 image_seq = be32_to_cpu(ech->ec);
785 if (!si->image_seq_set) {
786 ubi->image_seq = image_seq;
787 si->image_seq_set = 1;
788 } else if (ubi->image_seq != image_seq) {
789 ubi_err("bad image sequence number %d in PEB %d, "
790 "expected %d", image_seq, pnum, ubi->image_seq);
791 ubi_dbg_dump_ec_hdr(ech);
792 return -EINVAL;
793 }
794
781 } 795 }
782 796
783 /* OK, we've done with the EC header, let's look at the VID header */ 797 /* OK, we've done with the EC header, let's look at the VID header */
diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h
index 61df208e2f20..1017cf12def5 100644
--- a/drivers/mtd/ubi/scan.h
+++ b/drivers/mtd/ubi/scan.h
@@ -102,6 +102,7 @@ struct ubi_scan_volume {
102 * @mean_ec: mean erase counter value 102 * @mean_ec: mean erase counter value
103 * @ec_sum: a temporary variable used when calculating @mean_ec 103 * @ec_sum: a temporary variable used when calculating @mean_ec
104 * @ec_count: a temporary variable used when calculating @mean_ec 104 * @ec_count: a temporary variable used when calculating @mean_ec
105 * @image_seq_set: indicates @ubi->image_seq is known
105 * 106 *
106 * This data structure contains the result of scanning and may be used by other 107 * This data structure contains the result of scanning and may be used by other
107 * UBI sub-systems to build final UBI data structures, further error-recovery 108 * UBI sub-systems to build final UBI data structures, further error-recovery
@@ -124,6 +125,7 @@ struct ubi_scan_info {
124 int mean_ec; 125 int mean_ec;
125 uint64_t ec_sum; 126 uint64_t ec_sum;
126 int ec_count; 127 int ec_count;
128 int image_seq_set;
127}; 129};
128 130
129struct ubi_device; 131struct ubi_device;
diff --git a/drivers/mtd/ubi/ubi-media.h b/drivers/mtd/ubi/ubi-media.h
index 8419fdccc79c..503ea9b27309 100644
--- a/drivers/mtd/ubi/ubi-media.h
+++ b/drivers/mtd/ubi/ubi-media.h
@@ -129,6 +129,7 @@ enum {
129 * @ec: the erase counter 129 * @ec: the erase counter
130 * @vid_hdr_offset: where the VID header starts 130 * @vid_hdr_offset: where the VID header starts
131 * @data_offset: where the user data start 131 * @data_offset: where the user data start
132 * @image_seq: image sequence number
132 * @padding2: reserved for future, zeroes 133 * @padding2: reserved for future, zeroes
133 * @hdr_crc: erase counter header CRC checksum 134 * @hdr_crc: erase counter header CRC checksum
134 * 135 *
@@ -144,6 +145,14 @@ enum {
144 * volume identifier header and user data, relative to the beginning of the 145 * volume identifier header and user data, relative to the beginning of the
145 * physical eraseblock. These values have to be the same for all physical 146 * physical eraseblock. These values have to be the same for all physical
146 * eraseblocks. 147 * eraseblocks.
148 *
149 * The @image_seq field is used to validate a UBI image that has been prepared
150 * for a UBI device. The @image_seq value can be any value, but it must be the
151 * same on all eraseblocks. UBI will ensure that all new erase counter headers
152 * also contain this value, and will check the value when scanning at start-up.
153 * One way to make use of @image_seq is to increase its value by one every time
154 * an image is flashed over an existing image, then, if the flashing does not
155 * complete, UBI will detect the error when scanning.
147 */ 156 */
148struct ubi_ec_hdr { 157struct ubi_ec_hdr {
149 __be32 magic; 158 __be32 magic;
@@ -152,7 +161,8 @@ struct ubi_ec_hdr {
152 __be64 ec; /* Warning: the current limit is 31-bit anyway! */ 161 __be64 ec; /* Warning: the current limit is 31-bit anyway! */
153 __be32 vid_hdr_offset; 162 __be32 vid_hdr_offset;
154 __be32 data_offset; 163 __be32 data_offset;
155 __u8 padding2[36]; 164 __be32 image_seq;
165 __u8 padding2[32];
156 __be32 hdr_crc; 166 __be32 hdr_crc;
157} __attribute__ ((packed)); 167} __attribute__ ((packed));
158 168
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 28acd133c997..6a5fe9633783 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -301,6 +301,7 @@ struct ubi_wl_entry;
301 * @vol->readers, @vol->writers, @vol->exclusive, 301 * @vol->readers, @vol->writers, @vol->exclusive,
302 * @vol->ref_count, @vol->mapping and @vol->eba_tbl. 302 * @vol->ref_count, @vol->mapping and @vol->eba_tbl.
303 * @ref_count: count of references on the UBI device 303 * @ref_count: count of references on the UBI device
304 * @image_seq: image sequence number recorded on EC headers
304 * 305 *
305 * @rsvd_pebs: count of reserved physical eraseblocks 306 * @rsvd_pebs: count of reserved physical eraseblocks
306 * @avail_pebs: count of available physical eraseblocks 307 * @avail_pebs: count of available physical eraseblocks
@@ -372,6 +373,7 @@ struct ubi_wl_entry;
372 * @vid_hdr_shift: contains @vid_hdr_offset - @vid_hdr_aloffset 373 * @vid_hdr_shift: contains @vid_hdr_offset - @vid_hdr_aloffset
373 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or 374 * @bad_allowed: whether the MTD device admits of bad physical eraseblocks or
374 * not 375 * not
376 * @nor_flash: non-zero if working on top of NOR flash
375 * @mtd: MTD device descriptor 377 * @mtd: MTD device descriptor
376 * 378 *
377 * @peb_buf1: a buffer of PEB size used for different purposes 379 * @peb_buf1: a buffer of PEB size used for different purposes
@@ -390,6 +392,7 @@ struct ubi_device {
390 struct ubi_volume *volumes[UBI_MAX_VOLUMES+UBI_INT_VOL_COUNT]; 392 struct ubi_volume *volumes[UBI_MAX_VOLUMES+UBI_INT_VOL_COUNT];
391 spinlock_t volumes_lock; 393 spinlock_t volumes_lock;
392 int ref_count; 394 int ref_count;
395 int image_seq;
393 396
394 int rsvd_pebs; 397 int rsvd_pebs;
395 int avail_pebs; 398 int avail_pebs;
@@ -452,7 +455,8 @@ struct ubi_device {
452 int vid_hdr_offset; 455 int vid_hdr_offset;
453 int vid_hdr_aloffset; 456 int vid_hdr_aloffset;
454 int vid_hdr_shift; 457 int vid_hdr_shift;
455 int bad_allowed; 458 unsigned int bad_allowed:1;
459 unsigned int nor_flash:1;
456 struct mtd_info *mtd; 460 struct mtd_info *mtd;
457 461
458 void *peb_buf1; 462 void *peb_buf1;
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 2b2472300610..600c7229d5cf 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -459,6 +459,14 @@ retry:
459 dbg_wl("PEB %d EC %d", e->pnum, e->ec); 459 dbg_wl("PEB %d EC %d", e->pnum, e->ec);
460 prot_queue_add(ubi, e); 460 prot_queue_add(ubi, e);
461 spin_unlock(&ubi->wl_lock); 461 spin_unlock(&ubi->wl_lock);
462
463 err = ubi_dbg_check_all_ff(ubi, e->pnum, ubi->vid_hdr_aloffset,
464 ubi->peb_size - ubi->vid_hdr_aloffset);
465 if (err) {
466 ubi_err("new PEB %d does not contain all 0xFF bytes", e->pnum);
467 return err > 0 ? -EINVAL : err;
468 }
469
462 return e->pnum; 470 return e->pnum;
463} 471}
464 472
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index 85a18175730b..08787f5a22a3 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -569,16 +569,8 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
569 569
570#ifdef DEBUG_DRIVER 570#ifdef DEBUG_DRIVER
571 /* dump the packet */ 571 /* dump the packet */
572 { 572 print_hex_dump(KERN_DEBUG, "skb->data: ", DUMP_PREFIX_NONE,
573 int i; 573 16, 1, skb->data, 64, true);
574
575 for (i = 0; i < 64; i++) {
576 if ((i % 16) == 0)
577 printk("\n" KERN_DEBUG);
578 printk ("%2.2x ", skb->data [i]);
579 }
580 printk("\n");
581 }
582#endif 574#endif
583 entry = lp->tx_new & lp->tx_ring_mod_mask; 575 entry = lp->tx_new & lp->tx_ring_mod_mask;
584 ib->btx_ring [entry].length = (-skblen) | 0xf000; 576 ib->btx_ring [entry].length = (-skblen) | 0xf000;
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index d6d4ab3b430c..7d227cdab9f8 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -158,15 +158,12 @@ module_exit(arcnet_exit);
158void arcnet_dump_skb(struct net_device *dev, 158void arcnet_dump_skb(struct net_device *dev,
159 struct sk_buff *skb, char *desc) 159 struct sk_buff *skb, char *desc)
160{ 160{
161 int i; 161 char hdr[32];
162 162
163 printk(KERN_DEBUG "%6s: skb dump (%s) follows:", dev->name, desc); 163 /* dump the packet */
164 for (i = 0; i < skb->len; i++) { 164 snprintf(hdr, sizeof(hdr), "%6s:%s skb->data:", dev->name, desc);
165 if (i % 16 == 0) 165 print_hex_dump(KERN_DEBUG, hdr, DUMP_PREFIX_OFFSET,
166 printk("\n" KERN_DEBUG "[%04X] ", i); 166 16, 1, skb->data, skb->len, true);
167 printk("%02X ", ((u_char *) skb->data)[i]);
168 }
169 printk("\n");
170} 167}
171 168
172EXPORT_SYMBOL(arcnet_dump_skb); 169EXPORT_SYMBOL(arcnet_dump_skb);
@@ -184,6 +181,7 @@ static void arcnet_dump_packet(struct net_device *dev, int bufnum,
184 int i, length; 181 int i, length;
185 unsigned long flags = 0; 182 unsigned long flags = 0;
186 static uint8_t buf[512]; 183 static uint8_t buf[512];
184 char hdr[32];
187 185
188 /* hw.copy_from_card expects IRQ context so take the IRQ lock 186 /* hw.copy_from_card expects IRQ context so take the IRQ lock
189 to keep it single threaded */ 187 to keep it single threaded */
@@ -197,14 +195,10 @@ static void arcnet_dump_packet(struct net_device *dev, int bufnum,
197 /* if the offset[0] byte is nonzero, this is a 256-byte packet */ 195 /* if the offset[0] byte is nonzero, this is a 256-byte packet */
198 length = (buf[2] ? 256 : 512); 196 length = (buf[2] ? 256 : 512);
199 197
200 printk(KERN_DEBUG "%6s: packet dump (%s) follows:", dev->name, desc); 198 /* dump the packet */
201 for (i = 0; i < length; i++) { 199 snprintf(hdr, sizeof(hdr), "%6s:%s packet dump:", dev->name, desc);
202 if (i % 16 == 0) 200 print_hex_dump(KERN_DEBUG, hdr, DUMP_PREFIX_OFFSET,
203 printk("\n" KERN_DEBUG "[%04X] ", i); 201 16, 1, buf, length, true);
204 printk("%02X ", buf[i]);
205 }
206 printk("\n");
207
208} 202}
209 203
210#else 204#else
diff --git a/drivers/net/atl1c/atl1c_ethtool.c b/drivers/net/atl1c/atl1c_ethtool.c
index e4afbd628c23..607007d75b6f 100644
--- a/drivers/net/atl1c/atl1c_ethtool.c
+++ b/drivers/net/atl1c/atl1c_ethtool.c
@@ -281,6 +281,8 @@ static int atl1c_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
281 if (wol->wolopts & WAKE_PHY) 281 if (wol->wolopts & WAKE_PHY)
282 adapter->wol |= AT_WUFC_LNKC; 282 adapter->wol |= AT_WUFC_LNKC;
283 283
284 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
285
284 return 0; 286 return 0;
285} 287}
286 288
diff --git a/drivers/net/atl1e/atl1e_ethtool.c b/drivers/net/atl1e/atl1e_ethtool.c
index 619c6583e1aa..4003955d7a96 100644
--- a/drivers/net/atl1e/atl1e_ethtool.c
+++ b/drivers/net/atl1e/atl1e_ethtool.c
@@ -365,6 +365,8 @@ static int atl1e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
365 if (wol->wolopts & WAKE_PHY) 365 if (wol->wolopts & WAKE_PHY)
366 adapter->wol |= AT_WUFC_LNKC; 366 adapter->wol |= AT_WUFC_LNKC;
367 367
368 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
369
368 return 0; 370 return 0;
369} 371}
370 372
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index f703758f0a6e..5b4bf3d2cdc2 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -73,7 +73,7 @@ static inline char *nic_name(struct pci_dev *pdev)
73#define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST) 73#define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST)
74 74
75#define BE_MAX_LRO_DESCRIPTORS 16 75#define BE_MAX_LRO_DESCRIPTORS 16
76#define BE_MAX_FRAGS_PER_FRAME 16 76#define BE_MAX_FRAGS_PER_FRAME (min((u32) 16, (u32) MAX_SKB_FRAGS))
77 77
78struct be_dma_mem { 78struct be_dma_mem {
79 void *va; 79 void *va;
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index 9592f22e4c8c..cccc5419ad72 100644
--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -162,8 +162,8 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
162 return -EINVAL; 162 return -EINVAL;
163 163
164 adapter->max_rx_coal = coalesce->rx_max_coalesced_frames; 164 adapter->max_rx_coal = coalesce->rx_max_coalesced_frames;
165 if (adapter->max_rx_coal > MAX_SKB_FRAGS) 165 if (adapter->max_rx_coal > BE_MAX_FRAGS_PER_FRAME)
166 adapter->max_rx_coal = MAX_SKB_FRAGS - 1; 166 adapter->max_rx_coal = BE_MAX_FRAGS_PER_FRAME;
167 167
168 /* if AIC is being turned on now, start with an EQD of 0 */ 168 /* if AIC is being turned on now, start with an EQD of 0 */
169 if (rx_eq->enable_aic == 0 && 169 if (rx_eq->enable_aic == 0 &&
diff --git a/drivers/net/benet/be_hw.h b/drivers/net/benet/be_hw.h
index b02e805c1db3..29c33c709c6d 100644
--- a/drivers/net/benet/be_hw.h
+++ b/drivers/net/benet/be_hw.h
@@ -55,6 +55,10 @@
55#define MEMBAR_CTRL_INT_CTRL_PFUNC_MASK 0x7 /* bits 26 - 28 */ 55#define MEMBAR_CTRL_INT_CTRL_PFUNC_MASK 0x7 /* bits 26 - 28 */
56#define MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT 26 56#define MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT 26
57 57
58/********* ISR0 Register offset **********/
59#define CEV_ISR0_OFFSET 0xC18
60#define CEV_ISR_SIZE 4
61
58/********* Event Q door bell *************/ 62/********* Event Q door bell *************/
59#define DB_EQ_OFFSET DB_CQ_OFFSET 63#define DB_EQ_OFFSET DB_CQ_OFFSET
60#define DB_EQ_RING_ID_MASK 0x1FF /* bits 0 - 8 */ 64#define DB_EQ_RING_ID_MASK 0x1FF /* bits 0 - 8 */
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 66c10c87f517..c43f6a119295 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -666,7 +666,7 @@ static void skb_fill_rx_data(struct be_adapter *adapter,
666{ 666{
667 struct be_queue_info *rxq = &adapter->rx_obj.q; 667 struct be_queue_info *rxq = &adapter->rx_obj.q;
668 struct be_rx_page_info *page_info; 668 struct be_rx_page_info *page_info;
669 u16 rxq_idx, i, num_rcvd; 669 u16 rxq_idx, i, num_rcvd, j;
670 u32 pktsize, hdr_len, curr_frag_len; 670 u32 pktsize, hdr_len, curr_frag_len;
671 u8 *start; 671 u8 *start;
672 672
@@ -709,22 +709,33 @@ static void skb_fill_rx_data(struct be_adapter *adapter,
709 709
710 /* More frags present for this completion */ 710 /* More frags present for this completion */
711 pktsize -= curr_frag_len; /* account for above copied frag */ 711 pktsize -= curr_frag_len; /* account for above copied frag */
712 for (i = 1; i < num_rcvd; i++) { 712 for (i = 1, j = 0; i < num_rcvd; i++) {
713 index_inc(&rxq_idx, rxq->len); 713 index_inc(&rxq_idx, rxq->len);
714 page_info = get_rx_page_info(adapter, rxq_idx); 714 page_info = get_rx_page_info(adapter, rxq_idx);
715 715
716 curr_frag_len = min(pktsize, rx_frag_size); 716 curr_frag_len = min(pktsize, rx_frag_size);
717 717
718 skb_shinfo(skb)->frags[i].page = page_info->page; 718 /* Coalesce all frags from the same physical page in one slot */
719 skb_shinfo(skb)->frags[i].page_offset = page_info->page_offset; 719 if (page_info->page_offset == 0) {
720 skb_shinfo(skb)->frags[i].size = curr_frag_len; 720 /* Fresh page */
721 j++;
722 skb_shinfo(skb)->frags[j].page = page_info->page;
723 skb_shinfo(skb)->frags[j].page_offset =
724 page_info->page_offset;
725 skb_shinfo(skb)->frags[j].size = 0;
726 skb_shinfo(skb)->nr_frags++;
727 } else {
728 put_page(page_info->page);
729 }
730
731 skb_shinfo(skb)->frags[j].size += curr_frag_len;
721 skb->len += curr_frag_len; 732 skb->len += curr_frag_len;
722 skb->data_len += curr_frag_len; 733 skb->data_len += curr_frag_len;
723 skb_shinfo(skb)->nr_frags++;
724 pktsize -= curr_frag_len; 734 pktsize -= curr_frag_len;
725 735
726 memset(page_info, 0, sizeof(*page_info)); 736 memset(page_info, 0, sizeof(*page_info));
727 } 737 }
738 BUG_ON(j > MAX_SKB_FRAGS);
728 739
729done: 740done:
730 be_rx_stats_update(adapter, pktsize, num_rcvd); 741 be_rx_stats_update(adapter, pktsize, num_rcvd);
@@ -786,7 +797,7 @@ static void be_rx_compl_process_lro(struct be_adapter *adapter,
786 struct skb_frag_struct rx_frags[BE_MAX_FRAGS_PER_FRAME]; 797 struct skb_frag_struct rx_frags[BE_MAX_FRAGS_PER_FRAME];
787 struct be_queue_info *rxq = &adapter->rx_obj.q; 798 struct be_queue_info *rxq = &adapter->rx_obj.q;
788 u32 num_rcvd, pkt_size, remaining, vlanf, curr_frag_len; 799 u32 num_rcvd, pkt_size, remaining, vlanf, curr_frag_len;
789 u16 i, rxq_idx = 0, vid; 800 u16 i, rxq_idx = 0, vid, j;
790 801
791 num_rcvd = AMAP_GET_BITS(struct amap_eth_rx_compl, numfrags, rxcp); 802 num_rcvd = AMAP_GET_BITS(struct amap_eth_rx_compl, numfrags, rxcp);
792 pkt_size = AMAP_GET_BITS(struct amap_eth_rx_compl, pktsize, rxcp); 803 pkt_size = AMAP_GET_BITS(struct amap_eth_rx_compl, pktsize, rxcp);
@@ -794,20 +805,28 @@ static void be_rx_compl_process_lro(struct be_adapter *adapter,
794 rxq_idx = AMAP_GET_BITS(struct amap_eth_rx_compl, fragndx, rxcp); 805 rxq_idx = AMAP_GET_BITS(struct amap_eth_rx_compl, fragndx, rxcp);
795 806
796 remaining = pkt_size; 807 remaining = pkt_size;
797 for (i = 0; i < num_rcvd; i++) { 808 for (i = 0, j = -1; i < num_rcvd; i++) {
798 page_info = get_rx_page_info(adapter, rxq_idx); 809 page_info = get_rx_page_info(adapter, rxq_idx);
799 810
800 curr_frag_len = min(remaining, rx_frag_size); 811 curr_frag_len = min(remaining, rx_frag_size);
801 812
802 rx_frags[i].page = page_info->page; 813 /* Coalesce all frags from the same physical page in one slot */
803 rx_frags[i].page_offset = page_info->page_offset; 814 if (i == 0 || page_info->page_offset == 0) {
804 rx_frags[i].size = curr_frag_len; 815 /* First frag or Fresh page */
805 remaining -= curr_frag_len; 816 j++;
817 rx_frags[j].page = page_info->page;
818 rx_frags[j].page_offset = page_info->page_offset;
819 rx_frags[j].size = 0;
820 } else {
821 put_page(page_info->page);
822 }
823 rx_frags[j].size += curr_frag_len;
806 824
825 remaining -= curr_frag_len;
807 index_inc(&rxq_idx, rxq->len); 826 index_inc(&rxq_idx, rxq->len);
808
809 memset(page_info, 0, sizeof(*page_info)); 827 memset(page_info, 0, sizeof(*page_info));
810 } 828 }
829 BUG_ON(j > MAX_SKB_FRAGS);
811 830
812 if (likely(!vlanf)) { 831 if (likely(!vlanf)) {
813 lro_receive_frags(&adapter->rx_obj.lro_mgr, rx_frags, pkt_size, 832 lro_receive_frags(&adapter->rx_obj.lro_mgr, rx_frags, pkt_size,
@@ -1255,15 +1274,17 @@ static irqreturn_t be_intx(int irq, void *dev)
1255{ 1274{
1256 struct be_adapter *adapter = dev; 1275 struct be_adapter *adapter = dev;
1257 struct be_ctrl_info *ctrl = &adapter->ctrl; 1276 struct be_ctrl_info *ctrl = &adapter->ctrl;
1258 int rx, tx; 1277 int isr;
1259 1278
1260 tx = event_handle(ctrl, &adapter->tx_eq); 1279 isr = ioread32(ctrl->csr + CEV_ISR0_OFFSET +
1261 rx = event_handle(ctrl, &adapter->rx_eq); 1280 ctrl->pci_func * CEV_ISR_SIZE);
1281 if (!isr)
1282 return IRQ_NONE;
1262 1283
1263 if (rx || tx) 1284 event_handle(ctrl, &adapter->tx_eq);
1264 return IRQ_HANDLED; 1285 event_handle(ctrl, &adapter->rx_eq);
1265 else 1286
1266 return IRQ_NONE; 1287 return IRQ_HANDLED;
1267} 1288}
1268 1289
1269static irqreturn_t be_msix_rx(int irq, void *dev) 1290static irqreturn_t be_msix_rx(int irq, void *dev)
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 9578a3dfac01..206144f2470f 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -428,10 +428,11 @@ bmac_init_phy(struct net_device *dev)
428 printk(KERN_DEBUG "phy registers:"); 428 printk(KERN_DEBUG "phy registers:");
429 for (addr = 0; addr < 32; ++addr) { 429 for (addr = 0; addr < 32; ++addr) {
430 if ((addr & 7) == 0) 430 if ((addr & 7) == 0)
431 printk("\n" KERN_DEBUG); 431 printk(KERN_DEBUG);
432 printk(" %.4x", bmac_mif_read(dev, addr)); 432 printk(KERN_CONT " %.4x", bmac_mif_read(dev, addr));
433 } 433 }
434 printk("\n"); 434 printk(KERN_CONT "\n");
435
435 if (bp->is_bmac_plus) { 436 if (bp->is_bmac_plus) {
436 unsigned int capable, ctrl; 437 unsigned int capable, ctrl;
437 438
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index 8678457849f9..85a737c5c23f 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -902,6 +902,8 @@ struct bnx2x {
902 u16 rx_quick_cons_trip; 902 u16 rx_quick_cons_trip;
903 u16 rx_ticks_int; 903 u16 rx_ticks_int;
904 u16 rx_ticks; 904 u16 rx_ticks;
905/* Maximal coalescing timeout in us */
906#define BNX2X_MAX_COALESCE_TOUT (0xf0*12)
905 907
906 u32 lin_cnt; 908 u32 lin_cnt;
907 909
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index fbf1352e9c1c..c36a5f33739f 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -484,8 +484,9 @@ static void bnx2x_fw_dump(struct bnx2x *bp)
484 484
485 mark = REG_RD(bp, MCP_REG_MCPR_SCRATCH + 0xf104); 485 mark = REG_RD(bp, MCP_REG_MCPR_SCRATCH + 0xf104);
486 mark = ((mark + 0x3) & ~0x3); 486 mark = ((mark + 0x3) & ~0x3);
487 printk(KERN_ERR PFX "begin fw dump (mark 0x%x)\n" KERN_ERR, mark); 487 printk(KERN_ERR PFX "begin fw dump (mark 0x%x)\n", mark);
488 488
489 printk(KERN_ERR PFX);
489 for (offset = mark - 0x08000000; offset <= 0xF900; offset += 0x8*4) { 490 for (offset = mark - 0x08000000; offset <= 0xF900; offset += 0x8*4) {
490 for (word = 0; word < 8; word++) 491 for (word = 0; word < 8; word++)
491 data[word] = htonl(REG_RD(bp, MCP_REG_MCPR_SCRATCH + 492 data[word] = htonl(REG_RD(bp, MCP_REG_MCPR_SCRATCH +
@@ -500,7 +501,7 @@ static void bnx2x_fw_dump(struct bnx2x *bp)
500 data[8] = 0x0; 501 data[8] = 0x0;
501 printk(KERN_CONT "%s", (char *)data); 502 printk(KERN_CONT "%s", (char *)data);
502 } 503 }
503 printk("\n" KERN_ERR PFX "end of fw dump\n"); 504 printk(KERN_ERR PFX "end of fw dump\n");
504} 505}
505 506
506static void bnx2x_panic_dump(struct bnx2x *bp) 507static void bnx2x_panic_dump(struct bnx2x *bp)
@@ -4434,7 +4435,7 @@ static void bnx2x_update_coalesce(struct bnx2x *bp)
4434 REG_WR16(bp, BAR_USTRORM_INTMEM + 4435 REG_WR16(bp, BAR_USTRORM_INTMEM +
4435 USTORM_SB_HC_DISABLE_OFFSET(port, sb_id, 4436 USTORM_SB_HC_DISABLE_OFFSET(port, sb_id,
4436 U_SB_ETH_RX_CQ_INDEX), 4437 U_SB_ETH_RX_CQ_INDEX),
4437 bp->rx_ticks ? 0 : 1); 4438 (bp->rx_ticks/12) ? 0 : 1);
4438 4439
4439 /* HC_INDEX_C_ETH_TX_CQ_CONS */ 4440 /* HC_INDEX_C_ETH_TX_CQ_CONS */
4440 REG_WR8(bp, BAR_CSTRORM_INTMEM + 4441 REG_WR8(bp, BAR_CSTRORM_INTMEM +
@@ -4444,7 +4445,7 @@ static void bnx2x_update_coalesce(struct bnx2x *bp)
4444 REG_WR16(bp, BAR_CSTRORM_INTMEM + 4445 REG_WR16(bp, BAR_CSTRORM_INTMEM +
4445 CSTORM_SB_HC_DISABLE_OFFSET(port, sb_id, 4446 CSTORM_SB_HC_DISABLE_OFFSET(port, sb_id,
4446 C_SB_ETH_TX_CQ_INDEX), 4447 C_SB_ETH_TX_CQ_INDEX),
4447 bp->tx_ticks ? 0 : 1); 4448 (bp->tx_ticks/12) ? 0 : 1);
4448 } 4449 }
4449} 4450}
4450 4451
@@ -7354,7 +7355,7 @@ static void bnx2x_reset_task(struct work_struct *work)
7354#ifdef BNX2X_STOP_ON_ERROR 7355#ifdef BNX2X_STOP_ON_ERROR
7355 BNX2X_ERR("reset task called but STOP_ON_ERROR defined" 7356 BNX2X_ERR("reset task called but STOP_ON_ERROR defined"
7356 " so reset not done to allow debug dump,\n" 7357 " so reset not done to allow debug dump,\n"
7357 KERN_ERR " you will need to reboot when done\n"); 7358 " you will need to reboot when done\n");
7358 return; 7359 return;
7359#endif 7360#endif
7360 7361
@@ -8637,6 +8638,14 @@ static int bnx2x_nway_reset(struct net_device *dev)
8637 return 0; 8638 return 0;
8638} 8639}
8639 8640
8641static u32
8642bnx2x_get_link(struct net_device *dev)
8643{
8644 struct bnx2x *bp = netdev_priv(dev);
8645
8646 return bp->link_vars.link_up;
8647}
8648
8640static int bnx2x_get_eeprom_len(struct net_device *dev) 8649static int bnx2x_get_eeprom_len(struct net_device *dev)
8641{ 8650{
8642 struct bnx2x *bp = netdev_priv(dev); 8651 struct bnx2x *bp = netdev_priv(dev);
@@ -9061,12 +9070,12 @@ static int bnx2x_set_coalesce(struct net_device *dev,
9061 struct bnx2x *bp = netdev_priv(dev); 9070 struct bnx2x *bp = netdev_priv(dev);
9062 9071
9063 bp->rx_ticks = (u16) coal->rx_coalesce_usecs; 9072 bp->rx_ticks = (u16) coal->rx_coalesce_usecs;
9064 if (bp->rx_ticks > 3000) 9073 if (bp->rx_ticks > BNX2X_MAX_COALESCE_TOUT)
9065 bp->rx_ticks = 3000; 9074 bp->rx_ticks = BNX2X_MAX_COALESCE_TOUT;
9066 9075
9067 bp->tx_ticks = (u16) coal->tx_coalesce_usecs; 9076 bp->tx_ticks = (u16) coal->tx_coalesce_usecs;
9068 if (bp->tx_ticks > 0x3000) 9077 if (bp->tx_ticks > BNX2X_MAX_COALESCE_TOUT)
9069 bp->tx_ticks = 0x3000; 9078 bp->tx_ticks = BNX2X_MAX_COALESCE_TOUT;
9070 9079
9071 if (netif_running(dev)) 9080 if (netif_running(dev))
9072 bnx2x_update_coalesce(bp); 9081 bnx2x_update_coalesce(bp);
@@ -10034,7 +10043,7 @@ static struct ethtool_ops bnx2x_ethtool_ops = {
10034 .get_msglevel = bnx2x_get_msglevel, 10043 .get_msglevel = bnx2x_get_msglevel,
10035 .set_msglevel = bnx2x_set_msglevel, 10044 .set_msglevel = bnx2x_set_msglevel,
10036 .nway_reset = bnx2x_nway_reset, 10045 .nway_reset = bnx2x_nway_reset,
10037 .get_link = ethtool_op_get_link, 10046 .get_link = bnx2x_get_link,
10038 .get_eeprom_len = bnx2x_get_eeprom_len, 10047 .get_eeprom_len = bnx2x_get_eeprom_len,
10039 .get_eeprom = bnx2x_get_eeprom, 10048 .get_eeprom = bnx2x_get_eeprom,
10040 .set_eeprom = bnx2x_set_eeprom, 10049 .set_eeprom = bnx2x_set_eeprom,
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 58afafbd3b9c..fd5e32cbcb87 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -1097,7 +1097,7 @@ static const struct net_device_ops cpmac_netdev_ops = {
1097 .ndo_start_xmit = cpmac_start_xmit, 1097 .ndo_start_xmit = cpmac_start_xmit,
1098 .ndo_tx_timeout = cpmac_tx_timeout, 1098 .ndo_tx_timeout = cpmac_tx_timeout,
1099 .ndo_set_multicast_list = cpmac_set_multicast_list, 1099 .ndo_set_multicast_list = cpmac_set_multicast_list,
1100 .ndo_so_ioctl = cpmac_ioctl, 1100 .ndo_do_ioctl = cpmac_ioctl,
1101 .ndo_set_config = cpmac_config, 1101 .ndo_set_config = cpmac_config,
1102 .ndo_change_mtu = eth_change_mtu, 1102 .ndo_change_mtu = eth_change_mtu,
1103 .ndo_validate_addr = eth_validate_addr, 1103 .ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 538dda4422dc..fb5df5c6203e 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -642,8 +642,7 @@ static int setup_sge_qsets(struct adapter *adap)
642 struct port_info *pi = netdev_priv(dev); 642 struct port_info *pi = netdev_priv(dev);
643 643
644 pi->qs = &adap->sge.qs[pi->first_qset]; 644 pi->qs = &adap->sge.qs[pi->first_qset];
645 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets; 645 for (j = 0; j < pi->nqsets; ++j, ++qset_idx) {
646 ++j, ++qset_idx) {
647 set_qset_lro(dev, qset_idx, pi->rx_offload & T3_LRO); 646 set_qset_lro(dev, qset_idx, pi->rx_offload & T3_LRO);
648 err = t3_sge_alloc_qset(adap, qset_idx, 1, 647 err = t3_sge_alloc_qset(adap, qset_idx, 1,
649 (adap->flags & USING_MSIX) ? qset_idx + 1 : 648 (adap->flags & USING_MSIX) ? qset_idx + 1 :
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 2df8fb0af701..12fd446f9895 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -1820,11 +1820,19 @@ static int emac_dev_setmac_addr(struct net_device *ndev, void *addr)
1820 struct device *emac_dev = &priv->ndev->dev; 1820 struct device *emac_dev = &priv->ndev->dev;
1821 struct sockaddr *sa = addr; 1821 struct sockaddr *sa = addr;
1822 1822
1823 if (!is_valid_ether_addr(sa->sa_data))
1824 return -EINVAL;
1825
1823 /* Store mac addr in priv and rx channel and set it in EMAC hw */ 1826 /* Store mac addr in priv and rx channel and set it in EMAC hw */
1824 memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len); 1827 memcpy(priv->mac_addr, sa->sa_data, ndev->addr_len);
1825 memcpy(rxch->mac_addr, sa->sa_data, ndev->addr_len);
1826 memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len); 1828 memcpy(ndev->dev_addr, sa->sa_data, ndev->addr_len);
1827 emac_setmac(priv, EMAC_DEF_RX_CH, rxch->mac_addr); 1829
1830 /* If the interface is down - rxch is NULL. */
1831 /* MAC address is configured only after the interface is enabled. */
1832 if (netif_running(ndev)) {
1833 memcpy(rxch->mac_addr, sa->sa_data, ndev->addr_len);
1834 emac_setmac(priv, EMAC_DEF_RX_CH, rxch->mac_addr);
1835 }
1828 1836
1829 if (netif_msg_drv(priv)) 1837 if (netif_msg_drv(priv))
1830 dev_notice(emac_dev, "DaVinci EMAC: emac_dev_setmac_addr %pM\n", 1838 dev_notice(emac_dev, "DaVinci EMAC: emac_dev_setmac_addr %pM\n",
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index 895d72143ee0..4b6a219fecea 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -268,8 +268,9 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
268 printk(KERN_INFO "tx_coalesce:\t%d packets\n", 268 printk(KERN_INFO "tx_coalesce:\t%d packets\n",
269 tx_coalesce); 269 tx_coalesce);
270 if (np->coalesce) 270 if (np->coalesce)
271 printk(KERN_INFO "rx_coalesce:\t%d packets\n" 271 printk(KERN_INFO
272 KERN_INFO "rx_timeout: \t%d ns\n", 272 "rx_coalesce:\t%d packets\n"
273 "rx_timeout: \t%d ns\n",
273 np->rx_coalesce, np->rx_timeout*640); 274 np->rx_coalesce, np->rx_timeout*640);
274 if (np->vlan) 275 if (np->vlan)
275 printk(KERN_INFO "vlan(id):\t%d\n", np->vlan); 276 printk(KERN_INFO "vlan(id):\t%d\n", np->vlan);
@@ -1522,9 +1523,9 @@ mii_get_media (struct net_device *dev)
1522 printk (KERN_INFO "Operating at 10 Mbps, "); 1523 printk (KERN_INFO "Operating at 10 Mbps, ");
1523 } 1524 }
1524 if (bmcr & MII_BMCR_DUPLEX_MODE) { 1525 if (bmcr & MII_BMCR_DUPLEX_MODE) {
1525 printk ("Full duplex\n"); 1526 printk (KERN_CONT "Full duplex\n");
1526 } else { 1527 } else {
1527 printk ("Half duplex\n"); 1528 printk (KERN_CONT "Half duplex\n");
1528 } 1529 }
1529 } 1530 }
1530 if (np->tx_flow) 1531 if (np->tx_flow)
@@ -1614,9 +1615,9 @@ mii_set_media (struct net_device *dev)
1614 } 1615 }
1615 if (np->full_duplex) { 1616 if (np->full_duplex) {
1616 bmcr |= MII_BMCR_DUPLEX_MODE; 1617 bmcr |= MII_BMCR_DUPLEX_MODE;
1617 printk ("Full duplex\n"); 1618 printk (KERN_CONT "Full duplex\n");
1618 } else { 1619 } else {
1619 printk ("Half duplex\n"); 1620 printk (KERN_CONT "Half duplex\n");
1620 } 1621 }
1621#if 0 1622#if 0
1622 /* Set 1000BaseT Master/Slave setting */ 1623 /* Set 1000BaseT Master/Slave setting */
@@ -1669,9 +1670,9 @@ mii_get_media_pcs (struct net_device *dev)
1669 __u16 bmcr = mii_read (dev, phy_addr, PCS_BMCR); 1670 __u16 bmcr = mii_read (dev, phy_addr, PCS_BMCR);
1670 printk (KERN_INFO "Operating at 1000 Mbps, "); 1671 printk (KERN_INFO "Operating at 1000 Mbps, ");
1671 if (bmcr & MII_BMCR_DUPLEX_MODE) { 1672 if (bmcr & MII_BMCR_DUPLEX_MODE) {
1672 printk ("Full duplex\n"); 1673 printk (KERN_CONT "Full duplex\n");
1673 } else { 1674 } else {
1674 printk ("Half duplex\n"); 1675 printk (KERN_CONT "Half duplex\n");
1675 } 1676 }
1676 } 1677 }
1677 if (np->tx_flow) 1678 if (np->tx_flow)
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 5e3356f8eb5a..5b8cbdb4b520 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2185,12 +2185,16 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
2185 /* Free all the Rx ring sk_buffs */ 2185 /* Free all the Rx ring sk_buffs */
2186 for (i = 0; i < rx_ring->count; i++) { 2186 for (i = 0; i < rx_ring->count; i++) {
2187 buffer_info = &rx_ring->buffer_info[i]; 2187 buffer_info = &rx_ring->buffer_info[i];
2188 if (buffer_info->skb) { 2188 if (buffer_info->dma) {
2189 pci_unmap_single(pdev, 2189 pci_unmap_single(pdev,
2190 buffer_info->dma, 2190 buffer_info->dma,
2191 buffer_info->length, 2191 buffer_info->length,
2192 PCI_DMA_FROMDEVICE); 2192 PCI_DMA_FROMDEVICE);
2193 }
2194
2195 buffer_info->dma = 0;
2193 2196
2197 if (buffer_info->skb) {
2194 dev_kfree_skb(buffer_info->skb); 2198 dev_kfree_skb(buffer_info->skb);
2195 buffer_info->skb = NULL; 2199 buffer_info->skb = NULL;
2196 } 2200 }
@@ -4033,6 +4037,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
4033 buffer_info->dma, 4037 buffer_info->dma,
4034 buffer_info->length, 4038 buffer_info->length,
4035 PCI_DMA_FROMDEVICE); 4039 PCI_DMA_FROMDEVICE);
4040 buffer_info->dma = 0;
4036 4041
4037 length = le16_to_cpu(rx_desc->length); 4042 length = le16_to_cpu(rx_desc->length);
4038 /* !EOP means multiple descriptors were used to store a single 4043 /* !EOP means multiple descriptors were used to store a single
@@ -4222,6 +4227,7 @@ map_skb:
4222 pci_unmap_single(pdev, buffer_info->dma, 4227 pci_unmap_single(pdev, buffer_info->dma,
4223 adapter->rx_buffer_len, 4228 adapter->rx_buffer_len,
4224 PCI_DMA_FROMDEVICE); 4229 PCI_DMA_FROMDEVICE);
4230 buffer_info->dma = 0;
4225 4231
4226 break; /* while !buffer_info->skb */ 4232 break; /* while !buffer_info->skb */
4227 } 4233 }
@@ -4817,6 +4823,9 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
4817 4823
4818 netif_device_detach(netdev); 4824 netif_device_detach(netdev);
4819 4825
4826 if (state == pci_channel_io_perm_failure)
4827 return PCI_ERS_RESULT_DISCONNECT;
4828
4820 if (netif_running(netdev)) 4829 if (netif_running(netdev))
4821 e1000_down(adapter); 4830 e1000_down(adapter);
4822 pci_disable_device(pdev); 4831 pci_disable_device(pdev);
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index 8890c97e1120..c0f185beb8bc 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -238,6 +238,7 @@
238#define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */ 238#define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */
239#define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */ 239#define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */
240#define E1000_STATUS_LAN_INIT_DONE 0x00000200 /* Lan Init Completion by NVM */ 240#define E1000_STATUS_LAN_INIT_DONE 0x00000200 /* Lan Init Completion by NVM */
241#define E1000_STATUS_PHYRA 0x00000400 /* PHY Reset Asserted */
241#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */ 242#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */
242 243
243/* Constants used to interpret the masked PCI-X bus speed. */ 244/* Constants used to interpret the masked PCI-X bus speed. */
@@ -575,6 +576,8 @@
575#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */ 576#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */
576#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */ 577#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */
577 578
579#define PHY_CONTROL_LB 0x4000 /* PHY Loopback bit */
580
578/* NVM Control */ 581/* NVM Control */
579#define E1000_EECD_SK 0x00000001 /* NVM Clock */ 582#define E1000_EECD_SK 0x00000001 /* NVM Clock */
580#define E1000_EECD_CS 0x00000002 /* NVM Chip Select */ 583#define E1000_EECD_CS 0x00000002 /* NVM Chip Select */
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index 163c1c0cfee7..fd44d9f90769 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -215,6 +215,7 @@ enum e1e_registers {
215 E1000_SWSM = 0x05B50, /* SW Semaphore */ 215 E1000_SWSM = 0x05B50, /* SW Semaphore */
216 E1000_FWSM = 0x05B54, /* FW Semaphore */ 216 E1000_FWSM = 0x05B54, /* FW Semaphore */
217 E1000_SWSM2 = 0x05B58, /* Driver-only SW semaphore */ 217 E1000_SWSM2 = 0x05B58, /* Driver-only SW semaphore */
218 E1000_CRC_OFFSET = 0x05F50, /* CRC Offset register */
218 E1000_HICR = 0x08F00, /* Host Interface Control */ 219 E1000_HICR = 0x08F00, /* Host Interface Control */
219}; 220};
220 221
@@ -302,6 +303,9 @@ enum e1e_registers {
302#define E1000_KMRNCTRLSTA_REN 0x00200000 303#define E1000_KMRNCTRLSTA_REN 0x00200000
303#define E1000_KMRNCTRLSTA_DIAG_OFFSET 0x3 /* Kumeran Diagnostic */ 304#define E1000_KMRNCTRLSTA_DIAG_OFFSET 0x3 /* Kumeran Diagnostic */
304#define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */ 305#define E1000_KMRNCTRLSTA_DIAG_NELPBK 0x1000 /* Nearend Loopback mode */
306#define E1000_KMRNCTRLSTA_K1_CONFIG 0x7
307#define E1000_KMRNCTRLSTA_K1_ENABLE 0x140E
308#define E1000_KMRNCTRLSTA_K1_DISABLE 0x1400
305 309
306#define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10 310#define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10
307#define IFE_PHY_SPECIAL_CONTROL 0x11 /* 100BaseTx PHY Special Control */ 311#define IFE_PHY_SPECIAL_CONTROL 0x11 /* 100BaseTx PHY Special Control */
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 9e23f50fb9cd..d56c7473144a 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -338,6 +338,7 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
338{ 338{
339 struct e1000_nvm_info *nvm = &hw->nvm; 339 struct e1000_nvm_info *nvm = &hw->nvm;
340 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 340 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
341 union ich8_hws_flash_status hsfsts;
341 u32 gfpreg; 342 u32 gfpreg;
342 u32 sector_base_addr; 343 u32 sector_base_addr;
343 u32 sector_end_addr; 344 u32 sector_end_addr;
@@ -374,6 +375,20 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
374 /* Adjust to word count */ 375 /* Adjust to word count */
375 nvm->flash_bank_size /= sizeof(u16); 376 nvm->flash_bank_size /= sizeof(u16);
376 377
378 /*
379 * Make sure the flash bank size does not overwrite the 4k
380 * sector ranges. We may have 64k allotted to us but we only care
381 * about the first 2 4k sectors. Therefore, if we have anything less
382 * than 64k set in the HSFSTS register, we will reduce the bank size
383 * down to 4k and let the rest remain unused. If berasesz == 3, then
384 * we are working in 64k mode. Otherwise we are not.
385 */
386 if (nvm->flash_bank_size > E1000_ICH8_SHADOW_RAM_WORDS) {
387 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
388 if (hsfsts.hsf_status.berasesz != 3)
389 nvm->flash_bank_size = E1000_ICH8_SHADOW_RAM_WORDS;
390 }
391
377 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS; 392 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
378 393
379 /* Clear shadow ram */ 394 /* Clear shadow ram */
@@ -446,6 +461,95 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
446 return 0; 461 return 0;
447} 462}
448 463
464/**
465 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
466 * @hw: pointer to the HW structure
467 *
468 * Checks to see of the link status of the hardware has changed. If a
469 * change in link status has been detected, then we read the PHY registers
470 * to get the current speed/duplex if link exists.
471 **/
472static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
473{
474 struct e1000_mac_info *mac = &hw->mac;
475 s32 ret_val;
476 bool link;
477
478 /*
479 * We only want to go out to the PHY registers to see if Auto-Neg
480 * has completed and/or if our link status has changed. The
481 * get_link_status flag is set upon receiving a Link Status
482 * Change or Rx Sequence Error interrupt.
483 */
484 if (!mac->get_link_status) {
485 ret_val = 0;
486 goto out;
487 }
488
489 if (hw->mac.type == e1000_pchlan) {
490 ret_val = e1000e_write_kmrn_reg(hw,
491 E1000_KMRNCTRLSTA_K1_CONFIG,
492 E1000_KMRNCTRLSTA_K1_ENABLE);
493 if (ret_val)
494 goto out;
495 }
496
497 /*
498 * First we want to see if the MII Status Register reports
499 * link. If so, then we want to get the current speed/duplex
500 * of the PHY.
501 */
502 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
503 if (ret_val)
504 goto out;
505
506 if (!link)
507 goto out; /* No link detected */
508
509 mac->get_link_status = false;
510
511 if (hw->phy.type == e1000_phy_82578) {
512 ret_val = e1000_link_stall_workaround_hv(hw);
513 if (ret_val)
514 goto out;
515 }
516
517 /*
518 * Check if there was DownShift, must be checked
519 * immediately after link-up
520 */
521 e1000e_check_downshift(hw);
522
523 /*
524 * If we are forcing speed/duplex, then we simply return since
525 * we have already determined whether we have link or not.
526 */
527 if (!mac->autoneg) {
528 ret_val = -E1000_ERR_CONFIG;
529 goto out;
530 }
531
532 /*
533 * Auto-Neg is enabled. Auto Speed Detection takes care
534 * of MAC speed/duplex configuration. So we only need to
535 * configure Collision Distance in the MAC.
536 */
537 e1000e_config_collision_dist(hw);
538
539 /*
540 * Configure Flow Control now that Auto-Neg has completed.
541 * First, we need to restore the desired flow control
542 * settings because we may have had to re-autoneg with a
543 * different link partner.
544 */
545 ret_val = e1000e_config_fc_after_link_up(hw);
546 if (ret_val)
547 hw_dbg(hw, "Error configuring flow control\n");
548
549out:
550 return ret_val;
551}
552
449static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) 553static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
450{ 554{
451 struct e1000_hw *hw = &adapter->hw; 555 struct e1000_hw *hw = &adapter->hw;
@@ -694,6 +798,38 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
694} 798}
695 799
696/** 800/**
801 * e1000_lan_init_done_ich8lan - Check for PHY config completion
802 * @hw: pointer to the HW structure
803 *
804 * Check the appropriate indication the MAC has finished configuring the
805 * PHY after a software reset.
806 **/
807static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
808{
809 u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
810
811 /* Wait for basic configuration completes before proceeding */
812 do {
813 data = er32(STATUS);
814 data &= E1000_STATUS_LAN_INIT_DONE;
815 udelay(100);
816 } while ((!data) && --loop);
817
818 /*
819 * If basic configuration is incomplete before the above loop
820 * count reaches 0, loading the configuration from NVM will
821 * leave the PHY in a bad state possibly resulting in no link.
822 */
823 if (loop == 0)
824 hw_dbg(hw, "LAN_INIT_DONE not set, increase timeout\n");
825
826 /* Clear the Init Done bit for the next init event */
827 data = er32(STATUS);
828 data &= ~E1000_STATUS_LAN_INIT_DONE;
829 ew32(STATUS, data);
830}
831
832/**
697 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset 833 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
698 * @hw: pointer to the HW structure 834 * @hw: pointer to the HW structure
699 * 835 *
@@ -707,13 +843,15 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
707 u32 i; 843 u32 i;
708 u32 data, cnf_size, cnf_base_addr, sw_cfg_mask; 844 u32 data, cnf_size, cnf_base_addr, sw_cfg_mask;
709 s32 ret_val; 845 s32 ret_val;
710 u16 loop = E1000_ICH8_LAN_INIT_TIMEOUT;
711 u16 word_addr, reg_data, reg_addr, phy_page = 0; 846 u16 word_addr, reg_data, reg_addr, phy_page = 0;
712 847
713 ret_val = e1000e_phy_hw_reset_generic(hw); 848 ret_val = e1000e_phy_hw_reset_generic(hw);
714 if (ret_val) 849 if (ret_val)
715 return ret_val; 850 return ret_val;
716 851
852 /* Allow time for h/w to get to a quiescent state after reset */
853 mdelay(10);
854
717 if (hw->mac.type == e1000_pchlan) { 855 if (hw->mac.type == e1000_pchlan) {
718 ret_val = e1000_hv_phy_workarounds_ich8lan(hw); 856 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
719 if (ret_val) 857 if (ret_val)
@@ -741,26 +879,8 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
741 if (!(data & sw_cfg_mask)) 879 if (!(data & sw_cfg_mask))
742 return 0; 880 return 0;
743 881
744 /* Wait for basic configuration completes before proceeding*/ 882 /* Wait for basic configuration completes before proceeding */
745 do { 883 e1000_lan_init_done_ich8lan(hw);
746 data = er32(STATUS);
747 data &= E1000_STATUS_LAN_INIT_DONE;
748 udelay(100);
749 } while ((!data) && --loop);
750
751 /*
752 * If basic configuration is incomplete before the above loop
753 * count reaches 0, loading the configuration from NVM will
754 * leave the PHY in a bad state possibly resulting in no link.
755 */
756 if (loop == 0) {
757 hw_dbg(hw, "LAN_INIT_DONE not set, increase timeout\n");
758 }
759
760 /* Clear the Init Done bit for the next init event */
761 data = er32(STATUS);
762 data &= ~E1000_STATUS_LAN_INIT_DONE;
763 ew32(STATUS, data);
764 884
765 /* 885 /*
766 * Make sure HW does not configure LCD from PHY 886 * Make sure HW does not configure LCD from PHY
@@ -961,12 +1081,14 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
961 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU; 1081 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
962 ew32(PHY_CTRL, phy_ctrl); 1082 ew32(PHY_CTRL, phy_ctrl);
963 1083
1084 if (phy->type != e1000_phy_igp_3)
1085 return 0;
1086
964 /* 1087 /*
965 * Call gig speed drop workaround on LPLU before accessing 1088 * Call gig speed drop workaround on LPLU before accessing
966 * any PHY registers 1089 * any PHY registers
967 */ 1090 */
968 if ((hw->mac.type == e1000_ich8lan) && 1091 if (hw->mac.type == e1000_ich8lan)
969 (hw->phy.type == e1000_phy_igp_3))
970 e1000e_gig_downshift_workaround_ich8lan(hw); 1092 e1000e_gig_downshift_workaround_ich8lan(hw);
971 1093
972 /* When LPLU is enabled, we should disable SmartSpeed */ 1094 /* When LPLU is enabled, we should disable SmartSpeed */
@@ -979,6 +1101,9 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
979 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU; 1101 phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
980 ew32(PHY_CTRL, phy_ctrl); 1102 ew32(PHY_CTRL, phy_ctrl);
981 1103
1104 if (phy->type != e1000_phy_igp_3)
1105 return 0;
1106
982 /* 1107 /*
983 * LPLU and SmartSpeed are mutually exclusive. LPLU is used 1108 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
984 * during Dx states where the power conservation is most 1109 * during Dx states where the power conservation is most
@@ -1038,6 +1163,10 @@ static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
1038 if (!active) { 1163 if (!active) {
1039 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU; 1164 phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
1040 ew32(PHY_CTRL, phy_ctrl); 1165 ew32(PHY_CTRL, phy_ctrl);
1166
1167 if (phy->type != e1000_phy_igp_3)
1168 return 0;
1169
1041 /* 1170 /*
1042 * LPLU and SmartSpeed are mutually exclusive. LPLU is used 1171 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
1043 * during Dx states where the power conservation is most 1172 * during Dx states where the power conservation is most
@@ -1073,12 +1202,14 @@ static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
1073 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU; 1202 phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
1074 ew32(PHY_CTRL, phy_ctrl); 1203 ew32(PHY_CTRL, phy_ctrl);
1075 1204
1205 if (phy->type != e1000_phy_igp_3)
1206 return 0;
1207
1076 /* 1208 /*
1077 * Call gig speed drop workaround on LPLU before accessing 1209 * Call gig speed drop workaround on LPLU before accessing
1078 * any PHY registers 1210 * any PHY registers
1079 */ 1211 */
1080 if ((hw->mac.type == e1000_ich8lan) && 1212 if (hw->mac.type == e1000_ich8lan)
1081 (hw->phy.type == e1000_phy_igp_3))
1082 e1000e_gig_downshift_workaround_ich8lan(hw); 1213 e1000e_gig_downshift_workaround_ich8lan(hw);
1083 1214
1084 /* When LPLU is enabled, we should disable SmartSpeed */ 1215 /* When LPLU is enabled, we should disable SmartSpeed */
@@ -1905,7 +2036,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
1905 break; 2036 break;
1906 case 1: 2037 case 1:
1907 sector_size = ICH_FLASH_SEG_SIZE_4K; 2038 sector_size = ICH_FLASH_SEG_SIZE_4K;
1908 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_4K; 2039 iteration = 1;
1909 break; 2040 break;
1910 case 2: 2041 case 2:
1911 if (hw->mac.type == e1000_ich9lan) { 2042 if (hw->mac.type == e1000_ich9lan) {
@@ -1917,7 +2048,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
1917 break; 2048 break;
1918 case 3: 2049 case 3:
1919 sector_size = ICH_FLASH_SEG_SIZE_64K; 2050 sector_size = ICH_FLASH_SEG_SIZE_64K;
1920 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_64K; 2051 iteration = 1;
1921 break; 2052 break;
1922 default: 2053 default:
1923 return -E1000_ERR_NVM; 2054 return -E1000_ERR_NVM;
@@ -2143,6 +2274,12 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
2143 ctrl = er32(CTRL); 2274 ctrl = er32(CTRL);
2144 2275
2145 if (!e1000_check_reset_block(hw)) { 2276 if (!e1000_check_reset_block(hw)) {
2277 /* Clear PHY Reset Asserted bit */
2278 if (hw->mac.type >= e1000_pchlan) {
2279 u32 status = er32(STATUS);
2280 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
2281 }
2282
2146 /* 2283 /*
2147 * PHY HW reset requires MAC CORE reset at the same 2284 * PHY HW reset requires MAC CORE reset at the same
2148 * time to make sure the interface between MAC and the 2285 * time to make sure the interface between MAC and the
@@ -2156,23 +2293,34 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
2156 ew32(CTRL, (ctrl | E1000_CTRL_RST)); 2293 ew32(CTRL, (ctrl | E1000_CTRL_RST));
2157 msleep(20); 2294 msleep(20);
2158 2295
2159 if (!ret_val) { 2296 if (!ret_val)
2160 /* release the swflag because it is not reset by
2161 * hardware reset
2162 */
2163 e1000_release_swflag_ich8lan(hw); 2297 e1000_release_swflag_ich8lan(hw);
2164 }
2165 2298
2166 ret_val = e1000e_get_auto_rd_done(hw); 2299 if (ctrl & E1000_CTRL_PHY_RST)
2167 if (ret_val) { 2300 ret_val = hw->phy.ops.get_cfg_done(hw);
2168 /* 2301
2169 * When auto config read does not complete, do not 2302 if (hw->mac.type >= e1000_ich10lan) {
2170 * return with an error. This can happen in situations 2303 e1000_lan_init_done_ich8lan(hw);
2171 * where there is no eeprom and prevents getting link. 2304 } else {
2172 */ 2305 ret_val = e1000e_get_auto_rd_done(hw);
2173 hw_dbg(hw, "Auto Read Done did not complete\n"); 2306 if (ret_val) {
2307 /*
2308 * When auto config read does not complete, do not
2309 * return with an error. This can happen in situations
2310 * where there is no eeprom and prevents getting link.
2311 */
2312 hw_dbg(hw, "Auto Read Done did not complete\n");
2313 }
2174 } 2314 }
2175 2315
2316 /*
2317 * For PCH, this write will make sure that any noise
2318 * will be detected as a CRC error and be dropped rather than show up
2319 * as a bad packet to the DMA engine.
2320 */
2321 if (hw->mac.type == e1000_pchlan)
2322 ew32(CRC_OFFSET, 0x65656565);
2323
2176 ew32(IMC, 0xffffffff); 2324 ew32(IMC, 0xffffffff);
2177 icr = er32(ICR); 2325 icr = er32(ICR);
2178 2326
@@ -2222,6 +2370,18 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
2222 for (i = 0; i < mac->mta_reg_count; i++) 2370 for (i = 0; i < mac->mta_reg_count; i++)
2223 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); 2371 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
2224 2372
2373 /*
2374 * The 82578 Rx buffer will stall if wakeup is enabled in host and
2375 * the ME. Reading the BM_WUC register will clear the host wakeup bit.
2376 * Reset the phy after disabling host wakeup to reset the Rx buffer.
2377 */
2378 if (hw->phy.type == e1000_phy_82578) {
2379 hw->phy.ops.read_phy_reg(hw, BM_WUC, &i);
2380 ret_val = e1000_phy_hw_reset_ich8lan(hw);
2381 if (ret_val)
2382 return ret_val;
2383 }
2384
2225 /* Setup link and flow control */ 2385 /* Setup link and flow control */
2226 ret_val = e1000_setup_link_ich8lan(hw); 2386 ret_val = e1000_setup_link_ich8lan(hw);
2227 2387
@@ -2254,16 +2414,6 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
2254 ew32(CTRL_EXT, ctrl_ext); 2414 ew32(CTRL_EXT, ctrl_ext);
2255 2415
2256 /* 2416 /*
2257 * The 82578 Rx buffer will stall if wakeup is enabled in host and
2258 * the ME. Reading the BM_WUC register will clear the host wakeup bit.
2259 * Reset the phy after disabling host wakeup to reset the Rx buffer.
2260 */
2261 if (hw->phy.type == e1000_phy_82578) {
2262 e1e_rphy(hw, BM_WUC, &i);
2263 e1000e_phy_hw_reset_generic(hw);
2264 }
2265
2266 /*
2267 * Clear all of the statistics registers (clear on read). It is 2417 * Clear all of the statistics registers (clear on read). It is
2268 * important that we do this after we have tried to establish link 2418 * important that we do this after we have tried to establish link
2269 * because the symbol error count will increment wildly if there 2419 * because the symbol error count will increment wildly if there
@@ -2485,6 +2635,14 @@ static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
2485 if (ret_val) 2635 if (ret_val)
2486 return ret_val; 2636 return ret_val;
2487 2637
2638 if ((hw->mac.type == e1000_pchlan) && (*speed == SPEED_1000)) {
2639 ret_val = e1000e_write_kmrn_reg(hw,
2640 E1000_KMRNCTRLSTA_K1_CONFIG,
2641 E1000_KMRNCTRLSTA_K1_DISABLE);
2642 if (ret_val)
2643 return ret_val;
2644 }
2645
2488 if ((hw->mac.type == e1000_ich8lan) && 2646 if ((hw->mac.type == e1000_ich8lan) &&
2489 (hw->phy.type == e1000_phy_igp_3) && 2647 (hw->phy.type == e1000_phy_igp_3) &&
2490 (*speed == SPEED_1000)) { 2648 (*speed == SPEED_1000)) {
@@ -2850,6 +3008,16 @@ static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
2850{ 3008{
2851 u32 bank = 0; 3009 u32 bank = 0;
2852 3010
3011 if (hw->mac.type >= e1000_pchlan) {
3012 u32 status = er32(STATUS);
3013
3014 if (status & E1000_STATUS_PHYRA)
3015 ew32(STATUS, status & ~E1000_STATUS_PHYRA);
3016 else
3017 hw_dbg(hw,
3018 "PHY Reset Asserted not set - needs delay\n");
3019 }
3020
2853 e1000e_get_cfg_done(hw); 3021 e1000e_get_cfg_done(hw);
2854 3022
2855 /* If EEPROM is not marked present, init the IGP 3 PHY manually */ 3023 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
@@ -2921,7 +3089,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
2921static struct e1000_mac_operations ich8_mac_ops = { 3089static struct e1000_mac_operations ich8_mac_ops = {
2922 .id_led_init = e1000e_id_led_init, 3090 .id_led_init = e1000e_id_led_init,
2923 .check_mng_mode = e1000_check_mng_mode_ich8lan, 3091 .check_mng_mode = e1000_check_mng_mode_ich8lan,
2924 .check_for_link = e1000e_check_for_copper_link, 3092 .check_for_link = e1000_check_for_copper_link_ich8lan,
2925 /* cleanup_led dependent on mac type */ 3093 /* cleanup_led dependent on mac type */
2926 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, 3094 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
2927 .get_bus_info = e1000_get_bus_info_ich8lan, 3095 .get_bus_info = e1000_get_bus_info_ich8lan,
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index be6d9e990374..99ba2b8a2a05 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -378,12 +378,6 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
378 378
379 mac->get_link_status = 0; 379 mac->get_link_status = 0;
380 380
381 if (hw->phy.type == e1000_phy_82578) {
382 ret_val = e1000_link_stall_workaround_hv(hw);
383 if (ret_val)
384 return ret_val;
385 }
386
387 /* 381 /*
388 * Check if there was DownShift, must be checked 382 * Check if there was DownShift, must be checked
389 * immediately after link-up 383 * immediately after link-up
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 679885a122b4..63415bb6f48f 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4785,6 +4785,9 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
4785 4785
4786 netif_device_detach(netdev); 4786 netif_device_detach(netdev);
4787 4787
4788 if (state == pci_channel_io_perm_failure)
4789 return PCI_ERS_RESULT_DISCONNECT;
4790
4788 if (netif_running(netdev)) 4791 if (netif_running(netdev))
4789 e1000e_down(adapter); 4792 e1000e_down(adapter);
4790 pci_disable_device(pdev); 4793 pci_disable_device(pdev);
diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c
index e23459cf3d0e..994401fd0664 100644
--- a/drivers/net/e1000e/phy.c
+++ b/drivers/net/e1000e/phy.c
@@ -1531,7 +1531,12 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
1531 */ 1531 */
1532 ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); 1532 ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
1533 if (ret_val) 1533 if (ret_val)
1534 break; 1534 /*
1535 * If the first read fails, another entity may have
1536 * ownership of the resources, wait and try again to
1537 * see if they have relinquished the resources yet.
1538 */
1539 udelay(usec_interval);
1535 ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); 1540 ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
1536 if (ret_val) 1541 if (ret_val)
1537 break; 1542 break;
@@ -2737,6 +2742,11 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw)
2737 if (hw->phy.type != e1000_phy_82578) 2742 if (hw->phy.type != e1000_phy_82578)
2738 goto out; 2743 goto out;
2739 2744
2745 /* Do not apply workaround if in PHY loopback bit 14 set */
2746 hw->phy.ops.read_phy_reg(hw, PHY_CONTROL, &data);
2747 if (data & PHY_CONTROL_LB)
2748 goto out;
2749
2740 /* check if link is up and at 1Gbps */ 2750 /* check if link is up and at 1Gbps */
2741 ret_val = hw->phy.ops.read_phy_reg(hw, BM_CS_STATUS, &data); 2751 ret_val = hw->phy.ops.read_phy_reg(hw, BM_CS_STATUS, &data);
2742 if (ret_val) 2752 if (ret_val)
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index b60e27dfcfa7..88d7ebf31220 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -338,8 +338,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
338#ifndef MODULE 338#ifndef MODULE
339 static int printed_version; 339 static int printed_version;
340 if (!printed_version++) 340 if (!printed_version++)
341 printk (KERN_INFO "%s" KERN_INFO "%s", 341 printk(KERN_INFO "%s%s", version, version2);
342 version, version2);
343#endif 342#endif
344 343
345 card_idx++; 344 card_idx++;
@@ -1600,7 +1599,7 @@ static int __init epic_init (void)
1600{ 1599{
1601/* when a module, this is printed whether or not devices are found in probe */ 1600/* when a module, this is printed whether or not devices are found in probe */
1602#ifdef MODULE 1601#ifdef MODULE
1603 printk (KERN_INFO "%s" KERN_INFO "%s", 1602 printk (KERN_INFO "%s%s",
1604 version, version2); 1603 version, version2);
1605#endif 1604#endif
1606 1605
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 891be28a7d4f..48385c42ab57 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -1209,17 +1209,20 @@ static void fealnx_tx_timeout(struct net_device *dev)
1209 unsigned long flags; 1209 unsigned long flags;
1210 int i; 1210 int i;
1211 1211
1212 printk(KERN_WARNING "%s: Transmit timed out, status %8.8x," 1212 printk(KERN_WARNING
1213 " resetting...\n", dev->name, ioread32(ioaddr + ISR)); 1213 "%s: Transmit timed out, status %8.8x, resetting...\n",
1214 dev->name, ioread32(ioaddr + ISR));
1214 1215
1215 { 1216 {
1216 printk(KERN_DEBUG " Rx ring %p: ", np->rx_ring); 1217 printk(KERN_DEBUG " Rx ring %p: ", np->rx_ring);
1217 for (i = 0; i < RX_RING_SIZE; i++) 1218 for (i = 0; i < RX_RING_SIZE; i++)
1218 printk(" %8.8x", (unsigned int) np->rx_ring[i].status); 1219 printk(KERN_CONT " %8.8x",
1219 printk("\n" KERN_DEBUG " Tx ring %p: ", np->tx_ring); 1220 (unsigned int) np->rx_ring[i].status);
1221 printk(KERN_CONT "\n");
1222 printk(KERN_DEBUG " Tx ring %p: ", np->tx_ring);
1220 for (i = 0; i < TX_RING_SIZE; i++) 1223 for (i = 0; i < TX_RING_SIZE; i++)
1221 printk(" %4.4x", np->tx_ring[i].status); 1224 printk(KERN_CONT " %4.4x", np->tx_ring[i].status);
1222 printk("\n"); 1225 printk(KERN_CONT "\n");
1223 } 1226 }
1224 1227
1225 spin_lock_irqsave(&np->lock, flags); 1228 spin_lock_irqsave(&np->lock, flags);
diff --git a/drivers/net/fec.h b/drivers/net/fec.h
index 30b7dd671336..cc47f3f057c7 100644
--- a/drivers/net/fec.h
+++ b/drivers/net/fec.h
@@ -46,12 +46,12 @@
46 46
47#else 47#else
48 48
49#define FEC_ECNTRL; 0x000 /* Ethernet control reg */ 49#define FEC_ECNTRL 0x000 /* Ethernet control reg */
50#define FEC_IEVENT; 0x004 /* Interrupt even reg */ 50#define FEC_IEVENT 0x004 /* Interrupt even reg */
51#define FEC_IMASK; 0x008 /* Interrupt mask reg */ 51#define FEC_IMASK 0x008 /* Interrupt mask reg */
52#define FEC_IVEC; 0x00c /* Interrupt vec status reg */ 52#define FEC_IVEC 0x00c /* Interrupt vec status reg */
53#define FEC_R_DES_ACTIVE; 0x010 /* Receive descriptor reg */ 53#define FEC_R_DES_ACTIVE 0x010 /* Receive descriptor reg */
54#define FEC_X_DES_ACTIVE; 0x01c /* Transmit descriptor reg */ 54#define FEC_X_DES_ACTIVE 0x014 /* Transmit descriptor reg */
55#define FEC_MII_DATA 0x040 /* MII manage frame reg */ 55#define FEC_MII_DATA 0x040 /* MII manage frame reg */
56#define FEC_MII_SPEED 0x044 /* MII speed control reg */ 56#define FEC_MII_SPEED 0x044 /* MII speed control reg */
57#define FEC_R_BOUND 0x08c /* FIFO receive bound reg */ 57#define FEC_R_BOUND 0x08c /* FIFO receive bound reg */
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 1094d292630f..3b4e0766c7b2 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -3514,11 +3514,13 @@ static irqreturn_t nv_nic_irq(int foo, void *data)
3514 nv_msi_workaround(np); 3514 nv_msi_workaround(np);
3515 3515
3516#ifdef CONFIG_FORCEDETH_NAPI 3516#ifdef CONFIG_FORCEDETH_NAPI
3517 napi_schedule(&np->napi); 3517 if (napi_schedule_prep(&np->napi)) {
3518 3518 /*
3519 /* Disable furthur irq's 3519 * Disable further irq's (msix not enabled with napi)
3520 (msix not enabled with napi) */ 3520 */
3521 writel(0, base + NvRegIrqMask); 3521 writel(0, base + NvRegIrqMask);
3522 __napi_schedule(&np->napi);
3523 }
3522 3524
3523#else 3525#else
3524 do 3526 do
@@ -3615,12 +3617,13 @@ static irqreturn_t nv_nic_irq_optimized(int foo, void *data)
3615 nv_msi_workaround(np); 3617 nv_msi_workaround(np);
3616 3618
3617#ifdef CONFIG_FORCEDETH_NAPI 3619#ifdef CONFIG_FORCEDETH_NAPI
3618 napi_schedule(&np->napi); 3620 if (napi_schedule_prep(&np->napi)) {
3619 3621 /*
3620 /* Disable furthur irq's 3622 * Disable further irq's (msix not enabled with napi)
3621 (msix not enabled with napi) */ 3623 */
3622 writel(0, base + NvRegIrqMask); 3624 writel(0, base + NvRegIrqMask);
3623 3625 __napi_schedule(&np->napi);
3626 }
3624#else 3627#else
3625 do 3628 do
3626 { 3629 {
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index 3af581303ca2..d167090248e2 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -188,7 +188,7 @@ static int fsl_pq_mdio_find_free(struct mii_bus *new_bus)
188} 188}
189 189
190 190
191#ifdef CONFIG_GIANFAR 191#if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE)
192static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs) 192static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs)
193{ 193{
194 struct gfar __iomem *enet_regs; 194 struct gfar __iomem *enet_regs;
@@ -206,7 +206,7 @@ static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs)
206#endif 206#endif
207 207
208 208
209#ifdef CONFIG_UCC_GETH 209#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE)
210static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) 210static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id)
211{ 211{
212 struct device_node *np = NULL; 212 struct device_node *np = NULL;
@@ -291,7 +291,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
291 if (of_device_is_compatible(np, "fsl,gianfar-mdio") || 291 if (of_device_is_compatible(np, "fsl,gianfar-mdio") ||
292 of_device_is_compatible(np, "fsl,gianfar-tbi") || 292 of_device_is_compatible(np, "fsl,gianfar-tbi") ||
293 of_device_is_compatible(np, "gianfar")) { 293 of_device_is_compatible(np, "gianfar")) {
294#ifdef CONFIG_GIANFAR 294#if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE)
295 tbipa = get_gfar_tbipa(regs); 295 tbipa = get_gfar_tbipa(regs);
296#else 296#else
297 err = -ENODEV; 297 err = -ENODEV;
@@ -299,7 +299,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
299#endif 299#endif
300 } else if (of_device_is_compatible(np, "fsl,ucc-mdio") || 300 } else if (of_device_is_compatible(np, "fsl,ucc-mdio") ||
301 of_device_is_compatible(np, "ucc_geth_phy")) { 301 of_device_is_compatible(np, "ucc_geth_phy")) {
302#ifdef CONFIG_UCC_GETH 302#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE)
303 u32 id; 303 u32 id;
304 static u32 mii_mng_master; 304 static u32 mii_mng_master;
305 305
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 9d5b62cb30f7..d62378cbc149 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -173,8 +173,8 @@ static int tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
173 173
174static const char version[] __devinitconst = 174static const char version[] __devinitconst =
175KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Written by Donald Becker\n" 175KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Written by Donald Becker\n"
176KERN_INFO " Some modifications by Eric kasten <kasten@nscl.msu.edu>\n" 176" Some modifications by Eric kasten <kasten@nscl.msu.edu>\n"
177KERN_INFO " Further modifications by Keith Underwood <keithu@parl.clemson.edu>\n"; 177" Further modifications by Keith Underwood <keithu@parl.clemson.edu>\n";
178 178
179 179
180/* IP_MF appears to be only defined in <netinet/ip.h>, however, 180/* IP_MF appears to be only defined in <netinet/ip.h>, however,
@@ -1080,11 +1080,14 @@ static void hamachi_tx_timeout(struct net_device *dev)
1080 { 1080 {
1081 printk(KERN_DEBUG " Rx ring %p: ", hmp->rx_ring); 1081 printk(KERN_DEBUG " Rx ring %p: ", hmp->rx_ring);
1082 for (i = 0; i < RX_RING_SIZE; i++) 1082 for (i = 0; i < RX_RING_SIZE; i++)
1083 printk(" %8.8x", le32_to_cpu(hmp->rx_ring[i].status_n_length)); 1083 printk(KERN_CONT " %8.8x",
1084 printk("\n"KERN_DEBUG" Tx ring %p: ", hmp->tx_ring); 1084 le32_to_cpu(hmp->rx_ring[i].status_n_length));
1085 printk(KERN_CONT "\n");
1086 printk(KERN_DEBUG" Tx ring %p: ", hmp->tx_ring);
1085 for (i = 0; i < TX_RING_SIZE; i++) 1087 for (i = 0; i < TX_RING_SIZE; i++)
1086 printk(" %4.4x", le32_to_cpu(hmp->tx_ring[i].status_n_length)); 1088 printk(KERN_CONT " %4.4x",
1087 printk("\n"); 1089 le32_to_cpu(hmp->tx_ring[i].status_n_length));
1090 printk(KERN_CONT "\n");
1088 } 1091 }
1089 1092
1090 /* Reinit the hardware and make sure the Rx and Tx processes 1093 /* Reinit the hardware and make sure the Rx and Tx processes
@@ -1753,13 +1756,13 @@ static int hamachi_close(struct net_device *dev)
1753 1756
1754#ifdef __i386__ 1757#ifdef __i386__
1755 if (hamachi_debug > 2) { 1758 if (hamachi_debug > 2) {
1756 printk("\n"KERN_DEBUG" Tx ring at %8.8x:\n", 1759 printk(KERN_DEBUG " Tx ring at %8.8x:\n",
1757 (int)hmp->tx_ring_dma); 1760 (int)hmp->tx_ring_dma);
1758 for (i = 0; i < TX_RING_SIZE; i++) 1761 for (i = 0; i < TX_RING_SIZE; i++)
1759 printk(" %c #%d desc. %8.8x %8.8x.\n", 1762 printk(KERN_DEBUG " %c #%d desc. %8.8x %8.8x.\n",
1760 readl(ioaddr + TxCurPtr) == (long)&hmp->tx_ring[i] ? '>' : ' ', 1763 readl(ioaddr + TxCurPtr) == (long)&hmp->tx_ring[i] ? '>' : ' ',
1761 i, hmp->tx_ring[i].status_n_length, hmp->tx_ring[i].addr); 1764 i, hmp->tx_ring[i].status_n_length, hmp->tx_ring[i].addr);
1762 printk("\n"KERN_DEBUG " Rx ring %8.8x:\n", 1765 printk(KERN_DEBUG " Rx ring %8.8x:\n",
1763 (int)hmp->rx_ring_dma); 1766 (int)hmp->rx_ring_dma);
1764 for (i = 0; i < RX_RING_SIZE; i++) { 1767 for (i = 0; i < RX_RING_SIZE; i++) {
1765 printk(KERN_DEBUG " %c #%d desc. %4.4x %8.8x\n", 1768 printk(KERN_DEBUG " %c #%d desc. %4.4x %8.8x\n",
@@ -1770,7 +1773,7 @@ static int hamachi_close(struct net_device *dev)
1770 u16 *addr = (u16 *) 1773 u16 *addr = (u16 *)
1771 hmp->rx_skbuff[i]->data; 1774 hmp->rx_skbuff[i]->data;
1772 int j; 1775 int j;
1773 1776 printk(KERN_DEBUG "Addr: ");
1774 for (j = 0; j < 0x50; j++) 1777 for (j = 0; j < 0x50; j++)
1775 printk(" %4.4x", addr[j]); 1778 printk(" %4.4x", addr[j]);
1776 printk("\n"); 1779 printk("\n");
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 5e4b7afd0683..352703255bba 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -68,7 +68,7 @@ static const char paranoia_str[] = KERN_ERR
68 68
69static const char bc_drvname[] = "baycom_epp"; 69static const char bc_drvname[] = "baycom_epp";
70static const char bc_drvinfo[] = KERN_INFO "baycom_epp: (C) 1998-2000 Thomas Sailer, HB9JNX/AE4WA\n" 70static const char bc_drvinfo[] = KERN_INFO "baycom_epp: (C) 1998-2000 Thomas Sailer, HB9JNX/AE4WA\n"
71KERN_INFO "baycom_epp: version 0.7 compiled " __TIME__ " " __DATE__ "\n"; 71"baycom_epp: version 0.7 compiled " __TIME__ " " __DATE__ "\n";
72 72
73/* --------------------------------------------------------------------- */ 73/* --------------------------------------------------------------------- */
74 74
diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c
index 2e6fc4dc74b1..5f5af9a606f8 100644
--- a/drivers/net/hamradio/baycom_par.c
+++ b/drivers/net/hamradio/baycom_par.c
@@ -102,7 +102,7 @@
102 102
103static const char bc_drvname[] = "baycom_par"; 103static const char bc_drvname[] = "baycom_par";
104static const char bc_drvinfo[] = KERN_INFO "baycom_par: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n" 104static const char bc_drvinfo[] = KERN_INFO "baycom_par: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n"
105KERN_INFO "baycom_par: version 0.9 compiled " __TIME__ " " __DATE__ "\n"; 105"baycom_par: version 0.9 compiled " __TIME__ " " __DATE__ "\n";
106 106
107/* --------------------------------------------------------------------- */ 107/* --------------------------------------------------------------------- */
108 108
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index b6a816e60c0f..aa4488e871b2 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -91,7 +91,7 @@
91 91
92static const char bc_drvname[] = "baycom_ser_fdx"; 92static const char bc_drvname[] = "baycom_ser_fdx";
93static const char bc_drvinfo[] = KERN_INFO "baycom_ser_fdx: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n" 93static const char bc_drvinfo[] = KERN_INFO "baycom_ser_fdx: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n"
94KERN_INFO "baycom_ser_fdx: version 0.10 compiled " __TIME__ " " __DATE__ "\n"; 94"baycom_ser_fdx: version 0.10 compiled " __TIME__ " " __DATE__ "\n";
95 95
96/* --------------------------------------------------------------------- */ 96/* --------------------------------------------------------------------- */
97 97
diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c
index 3bcc57acbe6d..88c593596020 100644
--- a/drivers/net/hamradio/baycom_ser_hdx.c
+++ b/drivers/net/hamradio/baycom_ser_hdx.c
@@ -79,7 +79,7 @@
79 79
80static const char bc_drvname[] = "baycom_ser_hdx"; 80static const char bc_drvname[] = "baycom_ser_hdx";
81static const char bc_drvinfo[] = KERN_INFO "baycom_ser_hdx: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n" 81static const char bc_drvinfo[] = KERN_INFO "baycom_ser_hdx: (C) 1996-2000 Thomas Sailer, HB9JNX/AE4WA\n"
82KERN_INFO "baycom_ser_hdx: version 0.10 compiled " __TIME__ " " __DATE__ "\n"; 82"baycom_ser_hdx: version 0.10 compiled " __TIME__ " " __DATE__ "\n";
83 83
84/* --------------------------------------------------------------------- */ 84/* --------------------------------------------------------------------- */
85 85
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index efd9be214885..ac28dd5a4fd1 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -190,6 +190,10 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
190 phy->ops.write_reg = igb_write_phy_reg_igp; 190 phy->ops.write_reg = igb_write_phy_reg_igp;
191 } 191 }
192 192
193 /* set lan id */
194 hw->bus.func = (rd32(E1000_STATUS) & E1000_STATUS_FUNC_MASK) >>
195 E1000_STATUS_FUNC_SHIFT;
196
193 /* Set phy->phy_addr and phy->id. */ 197 /* Set phy->phy_addr and phy->id. */
194 ret_val = igb_get_phy_id_82575(hw); 198 ret_val = igb_get_phy_id_82575(hw);
195 if (ret_val) 199 if (ret_val)
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index ea17319624aa..be480292aba1 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -4549,11 +4549,12 @@ static bool igb_clean_rx_irq_adv(struct igb_ring *rx_ring,
4549 cleaned = true; 4549 cleaned = true;
4550 cleaned_count++; 4550 cleaned_count++;
4551 4551
4552 /* this is the fast path for the non-packet split case */
4552 if (!adapter->rx_ps_hdr_size) { 4553 if (!adapter->rx_ps_hdr_size) {
4553 pci_unmap_single(pdev, buffer_info->dma, 4554 pci_unmap_single(pdev, buffer_info->dma,
4554 adapter->rx_buffer_len + 4555 adapter->rx_buffer_len,
4555 NET_IP_ALIGN,
4556 PCI_DMA_FROMDEVICE); 4556 PCI_DMA_FROMDEVICE);
4557 buffer_info->dma = 0;
4557 skb_put(skb, length); 4558 skb_put(skb, length);
4558 goto send_up; 4559 goto send_up;
4559 } 4560 }
@@ -4570,8 +4571,9 @@ static bool igb_clean_rx_irq_adv(struct igb_ring *rx_ring,
4570 4571
4571 if (!skb_shinfo(skb)->nr_frags) { 4572 if (!skb_shinfo(skb)->nr_frags) {
4572 pci_unmap_single(pdev, buffer_info->dma, 4573 pci_unmap_single(pdev, buffer_info->dma,
4573 adapter->rx_ps_hdr_size + NET_IP_ALIGN, 4574 adapter->rx_ps_hdr_size,
4574 PCI_DMA_FROMDEVICE); 4575 PCI_DMA_FROMDEVICE);
4576 buffer_info->dma = 0;
4575 skb_put(skb, hlen); 4577 skb_put(skb, hlen);
4576 } 4578 }
4577 4579
@@ -4713,7 +4715,6 @@ static void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring,
4713 bufsz = adapter->rx_ps_hdr_size; 4715 bufsz = adapter->rx_ps_hdr_size;
4714 else 4716 else
4715 bufsz = adapter->rx_buffer_len; 4717 bufsz = adapter->rx_buffer_len;
4716 bufsz += NET_IP_ALIGN;
4717 4718
4718 while (cleaned_count--) { 4719 while (cleaned_count--) {
4719 rx_desc = E1000_RX_DESC_ADV(*rx_ring, i); 4720 rx_desc = E1000_RX_DESC_ADV(*rx_ring, i);
@@ -4737,7 +4738,7 @@ static void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring,
4737 } 4738 }
4738 4739
4739 if (!buffer_info->skb) { 4740 if (!buffer_info->skb) {
4740 skb = netdev_alloc_skb(netdev, bufsz); 4741 skb = netdev_alloc_skb(netdev, bufsz + NET_IP_ALIGN);
4741 if (!skb) { 4742 if (!skb) {
4742 adapter->alloc_rx_buff_failed++; 4743 adapter->alloc_rx_buff_failed++;
4743 goto no_buffers; 4744 goto no_buffers;
@@ -5338,6 +5339,9 @@ static pci_ers_result_t igb_io_error_detected(struct pci_dev *pdev,
5338 5339
5339 netif_device_detach(netdev); 5340 netif_device_detach(netdev);
5340 5341
5342 if (state == pci_channel_io_perm_failure)
5343 return PCI_ERS_RESULT_DISCONNECT;
5344
5341 if (netif_running(netdev)) 5345 if (netif_running(netdev))
5342 igb_down(adapter); 5346 igb_down(adapter);
5343 pci_disable_device(pdev); 5347 pci_disable_device(pdev);
diff --git a/drivers/net/irda/bfin_sir.c b/drivers/net/irda/bfin_sir.c
index f3eed6a8fba5..911c082cee5a 100644
--- a/drivers/net/irda/bfin_sir.c
+++ b/drivers/net/irda/bfin_sir.c
@@ -677,6 +677,14 @@ static int bfin_sir_init_iobuf(iobuff_t *io, int size)
677 return 0; 677 return 0;
678} 678}
679 679
680static const struct net_device_ops bfin_sir_ndo = {
681 .ndo_open = bfin_sir_open,
682 .ndo_stop = bfin_sir_stop,
683 .ndo_start_xmit = bfin_sir_hard_xmit,
684 .ndo_do_ioctl = bfin_sir_ioctl,
685 .ndo_get_stats = bfin_sir_stats,
686};
687
680static int __devinit bfin_sir_probe(struct platform_device *pdev) 688static int __devinit bfin_sir_probe(struct platform_device *pdev)
681{ 689{
682 struct net_device *dev; 690 struct net_device *dev;
@@ -718,12 +726,8 @@ static int __devinit bfin_sir_probe(struct platform_device *pdev)
718 if (err) 726 if (err)
719 goto err_mem_3; 727 goto err_mem_3;
720 728
721 dev->hard_start_xmit = bfin_sir_hard_xmit; 729 dev->netdev_ops = &bfin_sir_ndo;
722 dev->open = bfin_sir_open; 730 dev->irq = sir_port->irq;
723 dev->stop = bfin_sir_stop;
724 dev->do_ioctl = bfin_sir_ioctl;
725 dev->get_stats = bfin_sir_stats;
726 dev->irq = sir_port->irq;
727 731
728 irda_init_max_qos_capabilies(&self->qos); 732 irda_init_max_qos_capabilies(&self->qos);
729 733
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index d53aa9582137..20f9bc626688 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -31,7 +31,6 @@
31#include <linux/tty.h> 31#include <linux/tty.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <asm/uaccess.h> 33#include <asm/uaccess.h>
34#include <linux/smp_lock.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/mutex.h> 35#include <linux/mutex.h>
37 36
diff --git a/drivers/net/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ixgbe/ixgbe_dcb_nl.c
index d56890f5c9d5..7c5978ad929a 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_nl.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_nl.c
@@ -138,6 +138,10 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
138 adapter->hw.fc.requested_mode = ixgbe_fc_none; 138 adapter->hw.fc.requested_mode = ixgbe_fc_none;
139 } 139 }
140 adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED; 140 adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
141 if (adapter->hw.mac.type == ixgbe_mac_82599EB) {
142 adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
143 adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
144 }
141 adapter->flags |= IXGBE_FLAG_DCB_ENABLED; 145 adapter->flags |= IXGBE_FLAG_DCB_ENABLED;
142 ixgbe_init_interrupt_scheme(adapter); 146 ixgbe_init_interrupt_scheme(adapter);
143 if (netif_running(netdev)) 147 if (netif_running(netdev))
@@ -154,6 +158,8 @@ static u8 ixgbe_dcbnl_set_state(struct net_device *netdev, u8 state)
154 adapter->dcb_cfg.pfc_mode_enable = false; 158 adapter->dcb_cfg.pfc_mode_enable = false;
155 adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; 159 adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
156 adapter->flags |= IXGBE_FLAG_RSS_ENABLED; 160 adapter->flags |= IXGBE_FLAG_RSS_ENABLED;
161 if (adapter->hw.mac.type == ixgbe_mac_82599EB)
162 adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
157 ixgbe_init_interrupt_scheme(adapter); 163 ixgbe_init_interrupt_scheme(adapter);
158 if (netif_running(netdev)) 164 if (netif_running(netdev))
159 netdev->netdev_ops->ndo_open(netdev); 165 netdev->netdev_ops->ndo_open(netdev);
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 86f4f3e36f27..2a978008fd6e 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -139,7 +139,7 @@ static int ixgbe_get_settings(struct net_device *netdev,
139 ecmd->autoneg = AUTONEG_ENABLE; 139 ecmd->autoneg = AUTONEG_ENABLE;
140 ecmd->transceiver = XCVR_EXTERNAL; 140 ecmd->transceiver = XCVR_EXTERNAL;
141 if ((hw->phy.media_type == ixgbe_media_type_copper) || 141 if ((hw->phy.media_type == ixgbe_media_type_copper) ||
142 (hw->mac.type == ixgbe_mac_82599EB)) { 142 (hw->phy.multispeed_fiber)) {
143 ecmd->supported |= (SUPPORTED_1000baseT_Full | 143 ecmd->supported |= (SUPPORTED_1000baseT_Full |
144 SUPPORTED_Autoneg); 144 SUPPORTED_Autoneg);
145 145
@@ -217,7 +217,7 @@ static int ixgbe_set_settings(struct net_device *netdev,
217 s32 err = 0; 217 s32 err = 0;
218 218
219 if ((hw->phy.media_type == ixgbe_media_type_copper) || 219 if ((hw->phy.media_type == ixgbe_media_type_copper) ||
220 (hw->mac.type == ixgbe_mac_82599EB)) { 220 (hw->phy.multispeed_fiber)) {
221 /* 10000/copper and 1000/copper must autoneg 221 /* 10000/copper and 1000/copper must autoneg
222 * this function does not support any duplex forcing, but can 222 * this function does not support any duplex forcing, but can
223 * limit the advertising of the adapter to only 10000 or 1000 */ 223 * limit the advertising of the adapter to only 10000 or 1000 */
@@ -245,6 +245,7 @@ static int ixgbe_set_settings(struct net_device *netdev,
245 } else { 245 } else {
246 /* in this case we currently only support 10Gb/FULL */ 246 /* in this case we currently only support 10Gb/FULL */
247 if ((ecmd->autoneg == AUTONEG_ENABLE) || 247 if ((ecmd->autoneg == AUTONEG_ENABLE) ||
248 (ecmd->advertising != ADVERTISED_10000baseT_Full) ||
248 (ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)) 249 (ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL))
249 return -EINVAL; 250 return -EINVAL;
250 } 251 }
@@ -1829,7 +1830,6 @@ static int ixgbe_wol_exclusion(struct ixgbe_adapter *adapter,
1829 break; 1830 break;
1830 default: 1831 default:
1831 wol->supported = 0; 1832 wol->supported = 0;
1832 retval = 0;
1833 } 1833 }
1834 1834
1835 return retval; 1835 return retval;
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index e756e220db32..e3442f47f932 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -563,7 +563,6 @@ static void ixgbe_alloc_rx_buffers(struct ixgbe_adapter *adapter,
563 union ixgbe_adv_rx_desc *rx_desc; 563 union ixgbe_adv_rx_desc *rx_desc;
564 struct ixgbe_rx_buffer *bi; 564 struct ixgbe_rx_buffer *bi;
565 unsigned int i; 565 unsigned int i;
566 unsigned int bufsz = rx_ring->rx_buf_len + NET_IP_ALIGN;
567 566
568 i = rx_ring->next_to_use; 567 i = rx_ring->next_to_use;
569 bi = &rx_ring->rx_buffer_info[i]; 568 bi = &rx_ring->rx_buffer_info[i];
@@ -593,7 +592,9 @@ static void ixgbe_alloc_rx_buffers(struct ixgbe_adapter *adapter,
593 592
594 if (!bi->skb) { 593 if (!bi->skb) {
595 struct sk_buff *skb; 594 struct sk_buff *skb;
596 skb = netdev_alloc_skb(adapter->netdev, bufsz); 595 skb = netdev_alloc_skb(adapter->netdev,
596 (rx_ring->rx_buf_len +
597 NET_IP_ALIGN));
597 598
598 if (!skb) { 599 if (!skb) {
599 adapter->alloc_rx_buff_failed++; 600 adapter->alloc_rx_buff_failed++;
@@ -608,7 +609,8 @@ static void ixgbe_alloc_rx_buffers(struct ixgbe_adapter *adapter,
608 skb_reserve(skb, NET_IP_ALIGN); 609 skb_reserve(skb, NET_IP_ALIGN);
609 610
610 bi->skb = skb; 611 bi->skb = skb;
611 bi->dma = pci_map_single(pdev, skb->data, bufsz, 612 bi->dma = pci_map_single(pdev, skb->data,
613 rx_ring->rx_buf_len,
612 PCI_DMA_FROMDEVICE); 614 PCI_DMA_FROMDEVICE);
613 } 615 }
614 /* Refresh the desc even if buffer_addrs didn't change because 616 /* Refresh the desc even if buffer_addrs didn't change because
@@ -732,6 +734,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
732 pci_unmap_single(pdev, rx_buffer_info->dma, 734 pci_unmap_single(pdev, rx_buffer_info->dma,
733 rx_ring->rx_buf_len, 735 rx_ring->rx_buf_len,
734 PCI_DMA_FROMDEVICE); 736 PCI_DMA_FROMDEVICE);
737 rx_buffer_info->dma = 0;
735 skb_put(skb, len); 738 skb_put(skb, len);
736 } 739 }
737 740
@@ -2694,16 +2697,23 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
2694 2697
2695 /* 2698 /*
2696 * For hot-pluggable SFP+ devices, a new SFP+ module may have 2699 * For hot-pluggable SFP+ devices, a new SFP+ module may have
2697 * arrived before interrupts were enabled. We need to kick off 2700 * arrived before interrupts were enabled but after probe. Such
2698 * the SFP+ module setup first, then try to bring up link. 2701 * devices wouldn't have their type identified yet. We need to
2702 * kick off the SFP+ module setup first, then try to bring up link.
2699 * If we're not hot-pluggable SFP+, we just need to configure link 2703 * If we're not hot-pluggable SFP+, we just need to configure link
2700 * and bring it up. 2704 * and bring it up.
2701 */ 2705 */
2702 err = hw->phy.ops.identify(hw); 2706 if (hw->phy.type == ixgbe_phy_unknown) {
2703 if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { 2707 err = hw->phy.ops.identify(hw);
2704 DPRINTK(PROBE, ERR, "PHY not supported on this NIC %d\n", err); 2708 if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
2705 ixgbe_down(adapter); 2709 /*
2706 return err; 2710 * Take the device down and schedule the sfp tasklet
2711 * which will unregister_netdev and log it.
2712 */
2713 ixgbe_down(adapter);
2714 schedule_work(&adapter->sfp_config_module_task);
2715 return err;
2716 }
2707 } 2717 }
2708 2718
2709 if (ixgbe_is_sfp(hw)) { 2719 if (ixgbe_is_sfp(hw)) {
@@ -2812,9 +2822,11 @@ static void ixgbe_clean_rx_ring(struct ixgbe_adapter *adapter,
2812 } 2822 }
2813 if (!rx_buffer_info->page) 2823 if (!rx_buffer_info->page)
2814 continue; 2824 continue;
2815 pci_unmap_page(pdev, rx_buffer_info->page_dma, PAGE_SIZE / 2, 2825 if (rx_buffer_info->page_dma) {
2816 PCI_DMA_FROMDEVICE); 2826 pci_unmap_page(pdev, rx_buffer_info->page_dma,
2817 rx_buffer_info->page_dma = 0; 2827 PAGE_SIZE / 2, PCI_DMA_FROMDEVICE);
2828 rx_buffer_info->page_dma = 0;
2829 }
2818 put_page(rx_buffer_info->page); 2830 put_page(rx_buffer_info->page);
2819 rx_buffer_info->page = NULL; 2831 rx_buffer_info->page = NULL;
2820 rx_buffer_info->page_offset = 0; 2832 rx_buffer_info->page_offset = 0;
@@ -3118,7 +3130,11 @@ static inline bool ixgbe_set_fcoe_queues(struct ixgbe_adapter *adapter)
3118#endif 3130#endif
3119 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { 3131 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
3120 DPRINTK(PROBE, INFO, "FCOE enabled with RSS \n"); 3132 DPRINTK(PROBE, INFO, "FCOE enabled with RSS \n");
3121 ixgbe_set_rss_queues(adapter); 3133 if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) ||
3134 (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))
3135 ixgbe_set_fdir_queues(adapter);
3136 else
3137 ixgbe_set_rss_queues(adapter);
3122 } 3138 }
3123 /* adding FCoE rx rings to the end */ 3139 /* adding FCoE rx rings to the end */
3124 f->mask = adapter->num_rx_queues; 3140 f->mask = adapter->num_rx_queues;
@@ -3376,7 +3392,12 @@ static inline bool ixgbe_cache_ring_fcoe(struct ixgbe_adapter *adapter)
3376 } 3392 }
3377#endif /* CONFIG_IXGBE_DCB */ 3393#endif /* CONFIG_IXGBE_DCB */
3378 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { 3394 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
3379 ixgbe_cache_ring_rss(adapter); 3395 if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) ||
3396 (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))
3397 ixgbe_cache_ring_fdir(adapter);
3398 else
3399 ixgbe_cache_ring_rss(adapter);
3400
3380 fcoe_i = f->mask; 3401 fcoe_i = f->mask;
3381 } 3402 }
3382 for (i = 0; i < f->indices; i++, fcoe_i++) 3403 for (i = 0; i < f->indices; i++, fcoe_i++)
@@ -3716,14 +3737,15 @@ static void ixgbe_sfp_task(struct work_struct *work)
3716 if ((hw->phy.type == ixgbe_phy_nl) && 3737 if ((hw->phy.type == ixgbe_phy_nl) &&
3717 (hw->phy.sfp_type == ixgbe_sfp_type_not_present)) { 3738 (hw->phy.sfp_type == ixgbe_sfp_type_not_present)) {
3718 s32 ret = hw->phy.ops.identify_sfp(hw); 3739 s32 ret = hw->phy.ops.identify_sfp(hw);
3719 if (ret) 3740 if (ret == IXGBE_ERR_SFP_NOT_PRESENT)
3720 goto reschedule; 3741 goto reschedule;
3721 ret = hw->phy.ops.reset(hw); 3742 ret = hw->phy.ops.reset(hw);
3722 if (ret == IXGBE_ERR_SFP_NOT_SUPPORTED) { 3743 if (ret == IXGBE_ERR_SFP_NOT_SUPPORTED) {
3723 DPRINTK(PROBE, ERR, "failed to initialize because an " 3744 dev_err(&adapter->pdev->dev, "failed to initialize "
3724 "unsupported SFP+ module type was detected.\n" 3745 "because an unsupported SFP+ module type "
3725 "Reload the driver after installing a " 3746 "was detected.\n"
3726 "supported module.\n"); 3747 "Reload the driver after installing a "
3748 "supported module.\n");
3727 unregister_netdev(adapter->netdev); 3749 unregister_netdev(adapter->netdev);
3728 } else { 3750 } else {
3729 DPRINTK(PROBE, INFO, "detected SFP+: %d\n", 3751 DPRINTK(PROBE, INFO, "detected SFP+: %d\n",
@@ -4502,7 +4524,8 @@ static void ixgbe_multispeed_fiber_task(struct work_struct *work)
4502 u32 autoneg; 4524 u32 autoneg;
4503 4525
4504 adapter->flags |= IXGBE_FLAG_IN_SFP_LINK_TASK; 4526 adapter->flags |= IXGBE_FLAG_IN_SFP_LINK_TASK;
4505 if (hw->mac.ops.get_link_capabilities) 4527 autoneg = hw->phy.autoneg_advertised;
4528 if ((!autoneg) && (hw->mac.ops.get_link_capabilities))
4506 hw->mac.ops.get_link_capabilities(hw, &autoneg, 4529 hw->mac.ops.get_link_capabilities(hw, &autoneg,
4507 &hw->mac.autoneg); 4530 &hw->mac.autoneg);
4508 if (hw->mac.ops.setup_link_speed) 4531 if (hw->mac.ops.setup_link_speed)
@@ -4524,10 +4547,17 @@ static void ixgbe_sfp_config_module_task(struct work_struct *work)
4524 u32 err; 4547 u32 err;
4525 4548
4526 adapter->flags |= IXGBE_FLAG_IN_SFP_MOD_TASK; 4549 adapter->flags |= IXGBE_FLAG_IN_SFP_MOD_TASK;
4550
4551 /* Time for electrical oscillations to settle down */
4552 msleep(100);
4527 err = hw->phy.ops.identify_sfp(hw); 4553 err = hw->phy.ops.identify_sfp(hw);
4554
4528 if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { 4555 if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
4529 DPRINTK(PROBE, ERR, "PHY not supported on this NIC %d\n", err); 4556 dev_err(&adapter->pdev->dev, "failed to initialize because "
4530 ixgbe_down(adapter); 4557 "an unsupported SFP+ module type was detected.\n"
4558 "Reload the driver after installing a supported "
4559 "module.\n");
4560 unregister_netdev(adapter->netdev);
4531 return; 4561 return;
4532 } 4562 }
4533 hw->mac.ops.setup_sfp(hw); 4563 hw->mac.ops.setup_sfp(hw);
@@ -5513,8 +5543,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
5513 round_jiffies(jiffies + (2 * HZ))); 5543 round_jiffies(jiffies + (2 * HZ)));
5514 err = 0; 5544 err = 0;
5515 } else if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) { 5545 } else if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
5516 dev_err(&adapter->pdev->dev, "failed to load because an " 5546 dev_err(&adapter->pdev->dev, "failed to initialize because "
5517 "unsupported SFP+ module type was detected.\n"); 5547 "an unsupported SFP+ module type was detected.\n"
5548 "Reload the driver after installing a supported "
5549 "module.\n");
5518 goto err_sw_init; 5550 goto err_sw_init;
5519 } else if (err) { 5551 } else if (err) {
5520 dev_err(&adapter->pdev->dev, "HW Init failed: %d\n", err); 5552 dev_err(&adapter->pdev->dev, "HW Init failed: %d\n", err);
@@ -5555,12 +5587,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
5555 netdev->features |= NETIF_F_FCOE_CRC; 5587 netdev->features |= NETIF_F_FCOE_CRC;
5556 netdev->features |= NETIF_F_FSO; 5588 netdev->features |= NETIF_F_FSO;
5557 netdev->fcoe_ddp_xid = IXGBE_FCOE_DDP_MAX - 1; 5589 netdev->fcoe_ddp_xid = IXGBE_FCOE_DDP_MAX - 1;
5558 DPRINTK(DRV, INFO, "FCoE enabled, "
5559 "disabling Flow Director\n");
5560 adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
5561 adapter->flags &=
5562 ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
5563 adapter->atr_sample_rate = 0;
5564 } else { 5590 } else {
5565 adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; 5591 adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED;
5566 } 5592 }
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c
index 453e966762f0..9ecad17522c3 100644
--- a/drivers/net/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ixgbe/ixgbe_phy.c
@@ -60,6 +60,7 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
60 60
61 if (hw->phy.type == ixgbe_phy_unknown) { 61 if (hw->phy.type == ixgbe_phy_unknown) {
62 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) { 62 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
63 hw->phy.mdio.prtad = phy_addr;
63 if (mdio45_probe(&hw->phy.mdio, phy_addr) == 0) { 64 if (mdio45_probe(&hw->phy.mdio, phy_addr) == 0) {
64 ixgbe_get_phy_id(hw); 65 ixgbe_get_phy_id(hw);
65 hw->phy.type = 66 hw->phy.type =
@@ -68,6 +69,8 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
68 break; 69 break;
69 } 70 }
70 } 71 }
72 /* clear value if nothing found */
73 hw->phy.mdio.prtad = 0;
71 } else { 74 } else {
72 status = 0; 75 status = 0;
73 } 76 }
diff --git a/drivers/net/mdio.c b/drivers/net/mdio.c
index dc45e9856c35..6851bdb2ce29 100644
--- a/drivers/net/mdio.c
+++ b/drivers/net/mdio.c
@@ -14,6 +14,10 @@
14#include <linux/mdio.h> 14#include <linux/mdio.h>
15#include <linux/module.h> 15#include <linux/module.h>
16 16
17MODULE_DESCRIPTION("Generic support for MDIO-compatible transceivers");
18MODULE_AUTHOR("Copyright 2006-2009 Solarflare Communications Inc.");
19MODULE_LICENSE("GPL");
20
17/** 21/**
18 * mdio45_probe - probe for an MDIO (clause 45) device 22 * mdio45_probe - probe for an MDIO (clause 45) device
19 * @mdio: MDIO interface 23 * @mdio: MDIO interface
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index c9bfe4eea189..78c088331f57 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -130,8 +130,8 @@ static int full_duplex[MAX_UNITS];
130static const char version[] __devinitconst = 130static const char version[] __devinitconst =
131 KERN_INFO DRV_NAME " dp8381x driver, version " 131 KERN_INFO DRV_NAME " dp8381x driver, version "
132 DRV_VERSION ", " DRV_RELDATE "\n" 132 DRV_VERSION ", " DRV_RELDATE "\n"
133 KERN_INFO " originally by Donald Becker <becker@scyld.com>\n" 133 " originally by Donald Becker <becker@scyld.com>\n"
134 KERN_INFO " 2.4.x kernel port by Jeff Garzik, Tjeerd Mulder\n"; 134 " 2.4.x kernel port by Jeff Garzik, Tjeerd Mulder\n";
135 135
136MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); 136MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
137MODULE_DESCRIPTION("National Semiconductor DP8381x series PCI Ethernet driver"); 137MODULE_DESCRIPTION("National Semiconductor DP8381x series PCI Ethernet driver");
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index 5c3e242428f1..992dbfffdb05 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -321,7 +321,7 @@ static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr)
321 } 321 }
322 322
323 if (ei_debug && version_printed++ == 0) 323 if (ei_debug && version_printed++ == 0)
324 printk(KERN_INFO "%s" KERN_INFO "%s", version1, version2); 324 printk(KERN_INFO "%s%s", version1, version2);
325 325
326 printk(KERN_INFO "NE*000 ethercard probe at %#3lx:", ioaddr); 326 printk(KERN_INFO "NE*000 ethercard probe at %#3lx:", ioaddr);
327 327
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 970cedeb5f37..e1cdba752e09 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -60,7 +60,18 @@
60#define _NETXEN_NIC_LINUX_SUBVERSION 30 60#define _NETXEN_NIC_LINUX_SUBVERSION 30
61#define NETXEN_NIC_LINUX_VERSIONID "4.0.30" 61#define NETXEN_NIC_LINUX_VERSIONID "4.0.30"
62 62
63#define NETXEN_VERSION_CODE(a, b, c) (((a) << 16) + ((b) << 8) + (c)) 63#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c))
64#define _major(v) (((v) >> 24) & 0xff)
65#define _minor(v) (((v) >> 16) & 0xff)
66#define _build(v) ((v) & 0xffff)
67
68/* version in image has weird encoding:
69 * 7:0 - major
70 * 15:8 - minor
71 * 31:16 - build (little endian)
72 */
73#define NETXEN_DECODE_VERSION(v) \
74 NETXEN_VERSION_CODE(((v) & 0xff), (((v) >> 8) & 0xff), ((v) >> 16))
64 75
65#define NETXEN_NUM_FLASH_SECTORS (64) 76#define NETXEN_NUM_FLASH_SECTORS (64)
66#define NETXEN_FLASH_SECTOR_SIZE (64 * 1024) 77#define NETXEN_FLASH_SECTOR_SIZE (64 * 1024)
@@ -614,6 +625,7 @@ struct netxen_new_user_info {
614#define NX_P2_MN_ROMIMAGE 0 625#define NX_P2_MN_ROMIMAGE 0
615#define NX_P3_CT_ROMIMAGE 1 626#define NX_P3_CT_ROMIMAGE 1
616#define NX_P3_MN_ROMIMAGE 2 627#define NX_P3_MN_ROMIMAGE 2
628#define NX_FLASH_ROMIMAGE 3
617 629
618#define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */ 630#define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */
619 631
@@ -1243,7 +1255,7 @@ struct netxen_adapter {
1243 u32 resv3; 1255 u32 resv3;
1244 1256
1245 u8 has_link_events; 1257 u8 has_link_events;
1246 u8 resv1; 1258 u8 fw_type;
1247 u16 tx_context_id; 1259 u16 tx_context_id;
1248 u16 mtu; 1260 u16 mtu;
1249 u16 is_up; 1261 u16 is_up;
@@ -1387,6 +1399,7 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter);
1387int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); 1399int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
1388int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); 1400int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
1389int netxen_load_firmware(struct netxen_adapter *adapter); 1401int netxen_load_firmware(struct netxen_adapter *adapter);
1402int netxen_need_fw_reset(struct netxen_adapter *adapter);
1390void netxen_request_firmware(struct netxen_adapter *adapter); 1403void netxen_request_firmware(struct netxen_adapter *adapter);
1391void netxen_release_firmware(struct netxen_adapter *adapter); 1404void netxen_release_firmware(struct netxen_adapter *adapter);
1392int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); 1405int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 3cc047844af3..824103675648 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -853,6 +853,7 @@ enum {
853#define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c)) 853#define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c))
854 854
855#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL (0x14) 855#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL (0x14)
856#define NETXEN_PEG_ALIVE_COUNTER (NETXEN_CAM_RAM(0xb0))
856 857
857#define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC))) 858#define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC)))
858#define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200) 859#define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200)
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 055bb61d6e77..b899bd51fcd8 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -684,11 +684,84 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
684} 684}
685 685
686int 686int
687netxen_need_fw_reset(struct netxen_adapter *adapter)
688{
689 u32 count, old_count;
690 u32 val, version, major, minor, build;
691 int i, timeout;
692 u8 fw_type;
693
694 /* NX2031 firmware doesn't support heartbit */
695 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
696 return 1;
697
698 /* last attempt had failed */
699 if (NXRD32(adapter, CRB_CMDPEG_STATE) == PHAN_INITIALIZE_FAILED)
700 return 1;
701
702 old_count = count = NXRD32(adapter, NETXEN_PEG_ALIVE_COUNTER);
703
704 for (i = 0; i < 10; i++) {
705
706 timeout = msleep_interruptible(200);
707 if (timeout) {
708 NXWR32(adapter, CRB_CMDPEG_STATE,
709 PHAN_INITIALIZE_FAILED);
710 return -EINTR;
711 }
712
713 count = NXRD32(adapter, NETXEN_PEG_ALIVE_COUNTER);
714 if (count != old_count)
715 break;
716 }
717
718 /* firmware is dead */
719 if (count == old_count)
720 return 1;
721
722 /* check if we have got newer or different file firmware */
723 if (adapter->fw) {
724
725 const struct firmware *fw = adapter->fw;
726
727 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]);
728 version = NETXEN_DECODE_VERSION(val);
729
730 major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
731 minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
732 build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
733
734 if (version > NETXEN_VERSION_CODE(major, minor, build))
735 return 1;
736
737 if (version == NETXEN_VERSION_CODE(major, minor, build)) {
738
739 val = NXRD32(adapter, NETXEN_MIU_MN_CONTROL);
740 fw_type = (val & 0x4) ?
741 NX_P3_CT_ROMIMAGE : NX_P3_MN_ROMIMAGE;
742
743 if (adapter->fw_type != fw_type)
744 return 1;
745 }
746 }
747
748 return 0;
749}
750
751static char *fw_name[] = {
752 "nxromimg.bin", "nx3fwct.bin", "nx3fwmn.bin", "flash",
753};
754
755int
687netxen_load_firmware(struct netxen_adapter *adapter) 756netxen_load_firmware(struct netxen_adapter *adapter)
688{ 757{
689 u64 *ptr64; 758 u64 *ptr64;
690 u32 i, flashaddr, size; 759 u32 i, flashaddr, size;
691 const struct firmware *fw = adapter->fw; 760 const struct firmware *fw = adapter->fw;
761 struct pci_dev *pdev = adapter->pdev;
762
763 dev_info(&pdev->dev, "loading firmware from %s\n",
764 fw_name[adapter->fw_type]);
692 765
693 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) 766 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
694 NXWR32(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 1); 767 NXWR32(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 1);
@@ -756,7 +829,7 @@ static int
756netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname) 829netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname)
757{ 830{
758 __le32 val; 831 __le32 val;
759 u32 major, minor, build, ver, min_ver, bios; 832 u32 ver, min_ver, bios;
760 struct pci_dev *pdev = adapter->pdev; 833 struct pci_dev *pdev = adapter->pdev;
761 const struct firmware *fw = adapter->fw; 834 const struct firmware *fw = adapter->fw;
762 835
@@ -768,21 +841,18 @@ netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname)
768 return -EINVAL; 841 return -EINVAL;
769 842
770 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]); 843 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]);
771 major = (__force u32)val & 0xff;
772 minor = ((__force u32)val >> 8) & 0xff;
773 build = (__force u32)val >> 16;
774 844
775 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 845 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
776 min_ver = NETXEN_VERSION_CODE(4, 0, 216); 846 min_ver = NETXEN_VERSION_CODE(4, 0, 216);
777 else 847 else
778 min_ver = NETXEN_VERSION_CODE(3, 4, 216); 848 min_ver = NETXEN_VERSION_CODE(3, 4, 216);
779 849
780 ver = NETXEN_VERSION_CODE(major, minor, build); 850 ver = NETXEN_DECODE_VERSION(val);
781 851
782 if ((major > _NETXEN_NIC_LINUX_MAJOR) || (ver < min_ver)) { 852 if ((_major(ver) > _NETXEN_NIC_LINUX_MAJOR) || (ver < min_ver)) {
783 dev_err(&pdev->dev, 853 dev_err(&pdev->dev,
784 "%s: firmware version %d.%d.%d unsupported\n", 854 "%s: firmware version %d.%d.%d unsupported\n",
785 fwname, major, minor, build); 855 fwname, _major(ver), _minor(ver), _build(ver));
786 return -EINVAL; 856 return -EINVAL;
787 } 857 }
788 858
@@ -798,22 +868,21 @@ netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname)
798 if (netxen_rom_fast_read(adapter, 868 if (netxen_rom_fast_read(adapter,
799 NX_FW_VERSION_OFFSET, (int *)&val)) 869 NX_FW_VERSION_OFFSET, (int *)&val))
800 return -EIO; 870 return -EIO;
801 major = (__force u32)val & 0xff; 871 val = NETXEN_DECODE_VERSION(val);
802 minor = ((__force u32)val >> 8) & 0xff; 872 if (val > ver) {
803 build = (__force u32)val >> 16; 873 dev_info(&pdev->dev, "%s: firmware is older than flash\n",
804 if (NETXEN_VERSION_CODE(major, minor, build) > ver) 874 fwname);
805 return -EINVAL; 875 return -EINVAL;
876 }
806 877
807 NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC); 878 NXWR32(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
808 return 0; 879 return 0;
809} 880}
810 881
811static char *fw_name[] = { "nxromimg.bin", "nx3fwct.bin", "nx3fwmn.bin" };
812
813void netxen_request_firmware(struct netxen_adapter *adapter) 882void netxen_request_firmware(struct netxen_adapter *adapter)
814{ 883{
815 u32 capability, flashed_ver; 884 u32 capability, flashed_ver;
816 int fw_type; 885 u8 fw_type;
817 struct pci_dev *pdev = adapter->pdev; 886 struct pci_dev *pdev = adapter->pdev;
818 int rc = 0; 887 int rc = 0;
819 888
@@ -830,6 +899,8 @@ request_mn:
830 899
831 netxen_rom_fast_read(adapter, 900 netxen_rom_fast_read(adapter,
832 NX_FW_VERSION_OFFSET, (int *)&flashed_ver); 901 NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
902 flashed_ver = NETXEN_DECODE_VERSION(flashed_ver);
903
833 if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) { 904 if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) {
834 capability = NXRD32(adapter, NX_PEG_TUNE_CAPABILITY); 905 capability = NXRD32(adapter, NX_PEG_TUNE_CAPABILITY);
835 if (capability & NX_PEG_TUNE_MN_PRESENT) { 906 if (capability & NX_PEG_TUNE_MN_PRESENT) {
@@ -838,6 +909,10 @@ request_mn:
838 } 909 }
839 } 910 }
840 911
912 fw_type = NX_FLASH_ROMIMAGE;
913 adapter->fw = NULL;
914 goto done;
915
841request_fw: 916request_fw:
842 rc = request_firmware(&adapter->fw, fw_name[fw_type], &pdev->dev); 917 rc = request_firmware(&adapter->fw, fw_name[fw_type], &pdev->dev);
843 if (rc != 0) { 918 if (rc != 0) {
@@ -846,6 +921,7 @@ request_fw:
846 goto request_mn; 921 goto request_mn;
847 } 922 }
848 923
924 fw_type = NX_FLASH_ROMIMAGE;
849 adapter->fw = NULL; 925 adapter->fw = NULL;
850 goto done; 926 goto done;
851 } 927 }
@@ -859,16 +935,13 @@ request_fw:
859 goto request_mn; 935 goto request_mn;
860 } 936 }
861 937
938 fw_type = NX_FLASH_ROMIMAGE;
862 adapter->fw = NULL; 939 adapter->fw = NULL;
863 goto done; 940 goto done;
864 } 941 }
865 942
866done: 943done:
867 if (adapter->fw) 944 adapter->fw_type = fw_type;
868 dev_info(&pdev->dev, "loading firmware from file %s\n",
869 fw_name[fw_type]);
870 else
871 dev_info(&pdev->dev, "loading firmware from flash\n");
872} 945}
873 946
874 947
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 2919a2d12bf4..27539ddf94c4 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -718,6 +718,10 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
718 if (request_fw) 718 if (request_fw)
719 netxen_request_firmware(adapter); 719 netxen_request_firmware(adapter);
720 720
721 err = netxen_need_fw_reset(adapter);
722 if (err <= 0)
723 return err;
724
721 if (first_boot != 0x55555555) { 725 if (first_boot != 0x55555555) {
722 NXWR32(adapter, CRB_CMDPEG_STATE, 0); 726 NXWR32(adapter, CRB_CMDPEG_STATE, 0);
723 netxen_pinit_from_rom(adapter, 0); 727 netxen_pinit_from_rom(adapter, 0);
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index 8c1f6988f398..89f7b2ad5231 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -105,7 +105,7 @@ IVc. Errata
105 105
106static char version[] __devinitdata = 106static char version[] __devinitdata =
107KERN_INFO NETDRV_DRIVER_LOAD_MSG "\n" 107KERN_INFO NETDRV_DRIVER_LOAD_MSG "\n"
108KERN_INFO " Support available from http://foo.com/bar/baz.html\n"; 108" Support available from http://foo.com/bar/baz.html\n";
109 109
110/* define to 1 to enable PIO instead of MMIO */ 110/* define to 1 to enable PIO instead of MMIO */
111#undef USE_IO_OPS 111#undef USE_IO_OPS
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index f51944b28cfa..06618af1a468 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -298,14 +298,11 @@ static int __devinit ibmtr_config(struct pcmcia_device *link)
298 298
299 strcpy(info->node.dev_name, dev->name); 299 strcpy(info->node.dev_name, dev->name);
300 300
301 printk(KERN_INFO "%s: port %#3lx, irq %d,", 301 printk(KERN_INFO
302 dev->name, dev->base_addr, dev->irq); 302 "%s: port %#3lx, irq %d, mmio %#5lx, sram %#5lx, hwaddr=%pM\n",
303 printk (" mmio %#5lx,", (u_long)ti->mmio); 303 dev->name, dev->base_addr, dev->irq,
304 printk (" sram %#5lx,", (u_long)ti->sram_base << 12); 304 (u_long)ti->mmio, (u_long)(ti->sram_base << 12),
305 printk ("\n" KERN_INFO " hwaddr="); 305 dev->dev_addr);
306 for (i = 0; i < TR_ALEN; i++)
307 printk("%02X", dev->dev_addr[i]);
308 printk("\n");
309 return 0; 306 return 0;
310 307
311cs_failed: 308cs_failed:
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 02ef63ed1f99..36de91baf238 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -1425,15 +1425,12 @@ static void BuildLAF(int *ladrf, int *adr)
1425 ladrf[byte] |= (1 << (hashcode & 7)); 1425 ladrf[byte] |= (1 << (hashcode & 7));
1426 1426
1427#ifdef PCMCIA_DEBUG 1427#ifdef PCMCIA_DEBUG
1428 if (pc_debug > 2) { 1428 if (pc_debug > 2)
1429 printk(KERN_DEBUG " adr ="); 1429 printk(KERN_DEBUG " adr =%pM\n", adr);
1430 for (i = 0; i < 6; i++) 1430 printk(KERN_DEBUG " hashcode = %d(decimal), ladrf[0:63] =", hashcode);
1431 printk(" %02X", adr[i]); 1431 for (i = 0; i < 8; i++)
1432 printk("\n" KERN_DEBUG " hashcode = %d(decimal), ladrf[0:63]" 1432 printk(KERN_CONT " %02X", ladrf[i]);
1433 " =", hashcode); 1433 printk(KERN_CONT "\n");
1434 for (i = 0; i < 8; i++)
1435 printk(" %02X", ladrf[i]);
1436 printk("\n");
1437 } 1434 }
1438#endif 1435#endif
1439} /* BuildLAF */ 1436} /* BuildLAF */
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 652a36888361..9ef1c1bfa83d 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -1727,6 +1727,7 @@ static struct pcmcia_device_id pcnet_ids[] = {
1727 PCMCIA_DEVICE_PROD_ID12("PRETEC", "Ethernet CompactLAN 10BaseT 3.3V", 0xebf91155, 0x7f5a4f50), 1727 PCMCIA_DEVICE_PROD_ID12("PRETEC", "Ethernet CompactLAN 10BaseT 3.3V", 0xebf91155, 0x7f5a4f50),
1728 PCMCIA_DEVICE_PROD_ID12("Psion Dacom", "Gold Card Ethernet", 0xf5f025c2, 0x3a30e110), 1728 PCMCIA_DEVICE_PROD_ID12("Psion Dacom", "Gold Card Ethernet", 0xf5f025c2, 0x3a30e110),
1729 PCMCIA_DEVICE_PROD_ID12("=RELIA==", "Ethernet", 0xcdd0644a, 0x00b2e941), 1729 PCMCIA_DEVICE_PROD_ID12("=RELIA==", "Ethernet", 0xcdd0644a, 0x00b2e941),
1730 PCMCIA_DEVICE_PROD_ID12("RIOS Systems Co.", "PC CARD3 ETHERNET", 0x7dd33481, 0x10b41826),
1730 PCMCIA_DEVICE_PROD_ID12("RP", "1625B Ethernet NE2000 Compatible", 0xe3e66e22, 0xb96150df), 1731 PCMCIA_DEVICE_PROD_ID12("RP", "1625B Ethernet NE2000 Compatible", 0xe3e66e22, 0xb96150df),
1731 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP400 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4a7e2ae0), 1732 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP400 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4a7e2ae0),
1732 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP401 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4bcbd7fd), 1733 PCMCIA_DEVICE_PROD_ID12("RPTI", "EP401 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4bcbd7fd),
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 1c35e1d637a0..28368157dac4 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -485,7 +485,7 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev,
485 &new_ring_dma_addr); 485 &new_ring_dma_addr);
486 if (new_tx_ring == NULL) { 486 if (new_tx_ring == NULL) {
487 if (netif_msg_drv(lp)) 487 if (netif_msg_drv(lp))
488 printk("\n" KERN_ERR 488 printk(KERN_ERR
489 "%s: Consistent memory allocation failed.\n", 489 "%s: Consistent memory allocation failed.\n",
490 dev->name); 490 dev->name);
491 return; 491 return;
@@ -496,7 +496,7 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev,
496 GFP_ATOMIC); 496 GFP_ATOMIC);
497 if (!new_dma_addr_list) { 497 if (!new_dma_addr_list) {
498 if (netif_msg_drv(lp)) 498 if (netif_msg_drv(lp))
499 printk("\n" KERN_ERR 499 printk(KERN_ERR
500 "%s: Memory allocation failed.\n", dev->name); 500 "%s: Memory allocation failed.\n", dev->name);
501 goto free_new_tx_ring; 501 goto free_new_tx_ring;
502 } 502 }
@@ -505,7 +505,7 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev,
505 GFP_ATOMIC); 505 GFP_ATOMIC);
506 if (!new_skb_list) { 506 if (!new_skb_list) {
507 if (netif_msg_drv(lp)) 507 if (netif_msg_drv(lp))
508 printk("\n" KERN_ERR 508 printk(KERN_ERR
509 "%s: Memory allocation failed.\n", dev->name); 509 "%s: Memory allocation failed.\n", dev->name);
510 goto free_new_lists; 510 goto free_new_lists;
511 } 511 }
@@ -563,7 +563,7 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
563 &new_ring_dma_addr); 563 &new_ring_dma_addr);
564 if (new_rx_ring == NULL) { 564 if (new_rx_ring == NULL) {
565 if (netif_msg_drv(lp)) 565 if (netif_msg_drv(lp))
566 printk("\n" KERN_ERR 566 printk(KERN_ERR
567 "%s: Consistent memory allocation failed.\n", 567 "%s: Consistent memory allocation failed.\n",
568 dev->name); 568 dev->name);
569 return; 569 return;
@@ -574,7 +574,7 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
574 GFP_ATOMIC); 574 GFP_ATOMIC);
575 if (!new_dma_addr_list) { 575 if (!new_dma_addr_list) {
576 if (netif_msg_drv(lp)) 576 if (netif_msg_drv(lp))
577 printk("\n" KERN_ERR 577 printk(KERN_ERR
578 "%s: Memory allocation failed.\n", dev->name); 578 "%s: Memory allocation failed.\n", dev->name);
579 goto free_new_rx_ring; 579 goto free_new_rx_ring;
580 } 580 }
@@ -583,7 +583,7 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
583 GFP_ATOMIC); 583 GFP_ATOMIC);
584 if (!new_skb_list) { 584 if (!new_skb_list) {
585 if (netif_msg_drv(lp)) 585 if (netif_msg_drv(lp))
586 printk("\n" KERN_ERR 586 printk(KERN_ERR
587 "%s: Memory allocation failed.\n", dev->name); 587 "%s: Memory allocation failed.\n", dev->name);
588 goto free_new_lists; 588 goto free_new_lists;
589 } 589 }
@@ -1766,38 +1766,38 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1766 /* Version 0x2623 and 0x2624 */ 1766 /* Version 0x2623 and 0x2624 */
1767 if (((chip_version + 1) & 0xfffe) == 0x2624) { 1767 if (((chip_version + 1) & 0xfffe) == 0x2624) {
1768 i = a->read_csr(ioaddr, 80) & 0x0C00; /* Check tx_start_pt */ 1768 i = a->read_csr(ioaddr, 80) & 0x0C00; /* Check tx_start_pt */
1769 printk("\n" KERN_INFO " tx_start_pt(0x%04x):", i); 1769 printk(KERN_INFO " tx_start_pt(0x%04x):", i);
1770 switch (i >> 10) { 1770 switch (i >> 10) {
1771 case 0: 1771 case 0:
1772 printk(" 20 bytes,"); 1772 printk(KERN_CONT " 20 bytes,");
1773 break; 1773 break;
1774 case 1: 1774 case 1:
1775 printk(" 64 bytes,"); 1775 printk(KERN_CONT " 64 bytes,");
1776 break; 1776 break;
1777 case 2: 1777 case 2:
1778 printk(" 128 bytes,"); 1778 printk(KERN_CONT " 128 bytes,");
1779 break; 1779 break;
1780 case 3: 1780 case 3:
1781 printk("~220 bytes,"); 1781 printk(KERN_CONT "~220 bytes,");
1782 break; 1782 break;
1783 } 1783 }
1784 i = a->read_bcr(ioaddr, 18); /* Check Burst/Bus control */ 1784 i = a->read_bcr(ioaddr, 18); /* Check Burst/Bus control */
1785 printk(" BCR18(%x):", i & 0xffff); 1785 printk(KERN_CONT " BCR18(%x):", i & 0xffff);
1786 if (i & (1 << 5)) 1786 if (i & (1 << 5))
1787 printk("BurstWrEn "); 1787 printk(KERN_CONT "BurstWrEn ");
1788 if (i & (1 << 6)) 1788 if (i & (1 << 6))
1789 printk("BurstRdEn "); 1789 printk(KERN_CONT "BurstRdEn ");
1790 if (i & (1 << 7)) 1790 if (i & (1 << 7))
1791 printk("DWordIO "); 1791 printk(KERN_CONT "DWordIO ");
1792 if (i & (1 << 11)) 1792 if (i & (1 << 11))
1793 printk("NoUFlow "); 1793 printk(KERN_CONT "NoUFlow ");
1794 i = a->read_bcr(ioaddr, 25); 1794 i = a->read_bcr(ioaddr, 25);
1795 printk("\n" KERN_INFO " SRAMSIZE=0x%04x,", i << 8); 1795 printk(KERN_INFO " SRAMSIZE=0x%04x,", i << 8);
1796 i = a->read_bcr(ioaddr, 26); 1796 i = a->read_bcr(ioaddr, 26);
1797 printk(" SRAM_BND=0x%04x,", i << 8); 1797 printk(KERN_CONT " SRAM_BND=0x%04x,", i << 8);
1798 i = a->read_bcr(ioaddr, 27); 1798 i = a->read_bcr(ioaddr, 27);
1799 if (i & (1 << 14)) 1799 if (i & (1 << 14))
1800 printk("LowLatRx"); 1800 printk(KERN_CONT "LowLatRx");
1801 } 1801 }
1802 } 1802 }
1803 1803
@@ -1996,7 +1996,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name)
1996 &lp->tx_ring_dma_addr); 1996 &lp->tx_ring_dma_addr);
1997 if (lp->tx_ring == NULL) { 1997 if (lp->tx_ring == NULL) {
1998 if (netif_msg_drv(lp)) 1998 if (netif_msg_drv(lp))
1999 printk("\n" KERN_ERR PFX 1999 printk(KERN_ERR PFX
2000 "%s: Consistent memory allocation failed.\n", 2000 "%s: Consistent memory allocation failed.\n",
2001 name); 2001 name);
2002 return -ENOMEM; 2002 return -ENOMEM;
@@ -2008,7 +2008,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name)
2008 &lp->rx_ring_dma_addr); 2008 &lp->rx_ring_dma_addr);
2009 if (lp->rx_ring == NULL) { 2009 if (lp->rx_ring == NULL) {
2010 if (netif_msg_drv(lp)) 2010 if (netif_msg_drv(lp))
2011 printk("\n" KERN_ERR PFX 2011 printk(KERN_ERR PFX
2012 "%s: Consistent memory allocation failed.\n", 2012 "%s: Consistent memory allocation failed.\n",
2013 name); 2013 name);
2014 return -ENOMEM; 2014 return -ENOMEM;
@@ -2018,7 +2018,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name)
2018 GFP_ATOMIC); 2018 GFP_ATOMIC);
2019 if (!lp->tx_dma_addr) { 2019 if (!lp->tx_dma_addr) {
2020 if (netif_msg_drv(lp)) 2020 if (netif_msg_drv(lp))
2021 printk("\n" KERN_ERR PFX 2021 printk(KERN_ERR PFX
2022 "%s: Memory allocation failed.\n", name); 2022 "%s: Memory allocation failed.\n", name);
2023 return -ENOMEM; 2023 return -ENOMEM;
2024 } 2024 }
@@ -2027,7 +2027,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name)
2027 GFP_ATOMIC); 2027 GFP_ATOMIC);
2028 if (!lp->rx_dma_addr) { 2028 if (!lp->rx_dma_addr) {
2029 if (netif_msg_drv(lp)) 2029 if (netif_msg_drv(lp))
2030 printk("\n" KERN_ERR PFX 2030 printk(KERN_ERR PFX
2031 "%s: Memory allocation failed.\n", name); 2031 "%s: Memory allocation failed.\n", name);
2032 return -ENOMEM; 2032 return -ENOMEM;
2033 } 2033 }
@@ -2036,7 +2036,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name)
2036 GFP_ATOMIC); 2036 GFP_ATOMIC);
2037 if (!lp->tx_skbuff) { 2037 if (!lp->tx_skbuff) {
2038 if (netif_msg_drv(lp)) 2038 if (netif_msg_drv(lp))
2039 printk("\n" KERN_ERR PFX 2039 printk(KERN_ERR PFX
2040 "%s: Memory allocation failed.\n", name); 2040 "%s: Memory allocation failed.\n", name);
2041 return -ENOMEM; 2041 return -ENOMEM;
2042 } 2042 }
@@ -2045,7 +2045,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name)
2045 GFP_ATOMIC); 2045 GFP_ATOMIC);
2046 if (!lp->rx_skbuff) { 2046 if (!lp->rx_skbuff) {
2047 if (netif_msg_drv(lp)) 2047 if (netif_msg_drv(lp))
2048 printk("\n" KERN_ERR PFX 2048 printk(KERN_ERR PFX
2049 "%s: Memory allocation failed.\n", name); 2049 "%s: Memory allocation failed.\n", name);
2050 return -ENOMEM; 2050 return -ENOMEM;
2051 } 2051 }
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 61755cbd978e..eda94fcd4065 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -928,13 +928,32 @@ static void phy_state_machine(struct work_struct *work)
928 * Otherwise, it's 0, and we're 928 * Otherwise, it's 0, and we're
929 * still waiting for AN */ 929 * still waiting for AN */
930 if (err > 0) { 930 if (err > 0) {
931 phydev->state = PHY_RUNNING; 931 err = phy_read_status(phydev);
932 if (err)
933 break;
934
935 if (phydev->link) {
936 phydev->state = PHY_RUNNING;
937 netif_carrier_on(phydev->attached_dev);
938 } else
939 phydev->state = PHY_NOLINK;
940 phydev->adjust_link(phydev->attached_dev);
932 } else { 941 } else {
933 phydev->state = PHY_AN; 942 phydev->state = PHY_AN;
934 phydev->link_timeout = PHY_AN_TIMEOUT; 943 phydev->link_timeout = PHY_AN_TIMEOUT;
935 } 944 }
936 } else 945 } else {
937 phydev->state = PHY_RUNNING; 946 err = phy_read_status(phydev);
947 if (err)
948 break;
949
950 if (phydev->link) {
951 phydev->state = PHY_RUNNING;
952 netif_carrier_on(phydev->attached_dev);
953 } else
954 phydev->state = PHY_NOLINK;
955 phydev->adjust_link(phydev->attached_dev);
956 }
938 break; 957 break;
939 } 958 }
940 959
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 156e02e8905d..6ed5317ab1c0 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -1607,6 +1607,8 @@ int ql_mb_get_fw_state(struct ql_adapter *qdev);
1607int ql_cam_route_initialize(struct ql_adapter *qdev); 1607int ql_cam_route_initialize(struct ql_adapter *qdev);
1608int ql_read_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 *data); 1608int ql_read_mpi_reg(struct ql_adapter *qdev, u32 reg, u32 *data);
1609int ql_mb_about_fw(struct ql_adapter *qdev); 1609int ql_mb_about_fw(struct ql_adapter *qdev);
1610void ql_link_on(struct ql_adapter *qdev);
1611void ql_link_off(struct ql_adapter *qdev);
1610 1612
1611#if 1 1613#if 1
1612#define QL_ALL_DUMP 1614#define QL_ALL_DUMP
diff --git a/drivers/net/qlge/qlge_ethtool.c b/drivers/net/qlge/qlge_ethtool.c
index 37c99fe79770..eb6a9ee640ed 100644
--- a/drivers/net/qlge/qlge_ethtool.c
+++ b/drivers/net/qlge/qlge_ethtool.c
@@ -59,7 +59,7 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev)
59 cqicb->pkt_delay = 59 cqicb->pkt_delay =
60 cpu_to_le16(qdev->tx_max_coalesced_frames); 60 cpu_to_le16(qdev->tx_max_coalesced_frames);
61 cqicb->flags = FLAGS_LI; 61 cqicb->flags = FLAGS_LI;
62 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb), 62 status = ql_write_cfg(qdev, cqicb, sizeof(*cqicb),
63 CFG_LCQ, rx_ring->cq_id); 63 CFG_LCQ, rx_ring->cq_id);
64 if (status) { 64 if (status) {
65 QPRINTK(qdev, IFUP, ERR, 65 QPRINTK(qdev, IFUP, ERR,
@@ -82,7 +82,7 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev)
82 cqicb->pkt_delay = 82 cqicb->pkt_delay =
83 cpu_to_le16(qdev->rx_max_coalesced_frames); 83 cpu_to_le16(qdev->rx_max_coalesced_frames);
84 cqicb->flags = FLAGS_LI; 84 cqicb->flags = FLAGS_LI;
85 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb), 85 status = ql_write_cfg(qdev, cqicb, sizeof(*cqicb),
86 CFG_LCQ, rx_ring->cq_id); 86 CFG_LCQ, rx_ring->cq_id);
87 if (status) { 87 if (status) {
88 QPRINTK(qdev, IFUP, ERR, 88 QPRINTK(qdev, IFUP, ERR,
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 90d1f76c0e8b..5768af17f168 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -214,6 +214,10 @@ int ql_write_cfg(struct ql_adapter *qdev, void *ptr, int size, u32 bit,
214 return -ENOMEM; 214 return -ENOMEM;
215 } 215 }
216 216
217 status = ql_sem_spinlock(qdev, SEM_ICB_MASK);
218 if (status)
219 return status;
220
217 status = ql_wait_cfg(qdev, bit); 221 status = ql_wait_cfg(qdev, bit);
218 if (status) { 222 if (status) {
219 QPRINTK(qdev, IFUP, ERR, 223 QPRINTK(qdev, IFUP, ERR,
@@ -221,12 +225,8 @@ int ql_write_cfg(struct ql_adapter *qdev, void *ptr, int size, u32 bit,
221 goto exit; 225 goto exit;
222 } 226 }
223 227
224 status = ql_sem_spinlock(qdev, SEM_ICB_MASK);
225 if (status)
226 goto exit;
227 ql_write32(qdev, ICB_L, (u32) map); 228 ql_write32(qdev, ICB_L, (u32) map);
228 ql_write32(qdev, ICB_H, (u32) (map >> 32)); 229 ql_write32(qdev, ICB_H, (u32) (map >> 32));
229 ql_sem_unlock(qdev, SEM_ICB_MASK); /* does flush too */
230 230
231 mask = CFG_Q_MASK | (bit << 16); 231 mask = CFG_Q_MASK | (bit << 16);
232 value = bit | (q_id << CFG_Q_SHIFT); 232 value = bit | (q_id << CFG_Q_SHIFT);
@@ -237,6 +237,7 @@ int ql_write_cfg(struct ql_adapter *qdev, void *ptr, int size, u32 bit,
237 */ 237 */
238 status = ql_wait_cfg(qdev, bit); 238 status = ql_wait_cfg(qdev, bit);
239exit: 239exit:
240 ql_sem_unlock(qdev, SEM_ICB_MASK); /* does flush too */
240 pci_unmap_single(qdev->pdev, map, size, direction); 241 pci_unmap_single(qdev->pdev, map, size, direction);
241 return status; 242 return status;
242} 243}
@@ -412,6 +413,57 @@ exit:
412 return status; 413 return status;
413} 414}
414 415
416/* Set or clear MAC address in hardware. We sometimes
417 * have to clear it to prevent wrong frame routing
418 * especially in a bonding environment.
419 */
420static int ql_set_mac_addr(struct ql_adapter *qdev, int set)
421{
422 int status;
423 char zero_mac_addr[ETH_ALEN];
424 char *addr;
425
426 if (set) {
427 addr = &qdev->ndev->dev_addr[0];
428 QPRINTK(qdev, IFUP, DEBUG,
429 "Set Mac addr %02x:%02x:%02x:%02x:%02x:%02x\n",
430 addr[0], addr[1], addr[2], addr[3],
431 addr[4], addr[5]);
432 } else {
433 memset(zero_mac_addr, 0, ETH_ALEN);
434 addr = &zero_mac_addr[0];
435 QPRINTK(qdev, IFUP, DEBUG,
436 "Clearing MAC address on %s\n",
437 qdev->ndev->name);
438 }
439 status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK);
440 if (status)
441 return status;
442 status = ql_set_mac_addr_reg(qdev, (u8 *) addr,
443 MAC_ADDR_TYPE_CAM_MAC, qdev->func * MAX_CQ);
444 ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK);
445 if (status)
446 QPRINTK(qdev, IFUP, ERR, "Failed to init mac "
447 "address.\n");
448 return status;
449}
450
451void ql_link_on(struct ql_adapter *qdev)
452{
453 QPRINTK(qdev, LINK, ERR, "%s: Link is up.\n",
454 qdev->ndev->name);
455 netif_carrier_on(qdev->ndev);
456 ql_set_mac_addr(qdev, 1);
457}
458
459void ql_link_off(struct ql_adapter *qdev)
460{
461 QPRINTK(qdev, LINK, ERR, "%s: Link is down.\n",
462 qdev->ndev->name);
463 netif_carrier_off(qdev->ndev);
464 ql_set_mac_addr(qdev, 0);
465}
466
415/* Get a specific frame routing value from the CAM. 467/* Get a specific frame routing value from the CAM.
416 * Used for debug and reg dump. 468 * Used for debug and reg dump.
417 */ 469 */
@@ -1628,7 +1680,7 @@ static void ql_process_mac_tx_intr(struct ql_adapter *qdev,
1628 tx_ring = &qdev->tx_ring[mac_rsp->txq_idx]; 1680 tx_ring = &qdev->tx_ring[mac_rsp->txq_idx];
1629 tx_ring_desc = &tx_ring->q[mac_rsp->tid]; 1681 tx_ring_desc = &tx_ring->q[mac_rsp->tid];
1630 ql_unmap_send(qdev, tx_ring_desc, tx_ring_desc->map_cnt); 1682 ql_unmap_send(qdev, tx_ring_desc, tx_ring_desc->map_cnt);
1631 qdev->stats.tx_bytes += tx_ring_desc->map_cnt; 1683 qdev->stats.tx_bytes += (tx_ring_desc->skb)->len;
1632 qdev->stats.tx_packets++; 1684 qdev->stats.tx_packets++;
1633 dev_kfree_skb(tx_ring_desc->skb); 1685 dev_kfree_skb(tx_ring_desc->skb);
1634 tx_ring_desc->skb = NULL; 1686 tx_ring_desc->skb = NULL;
@@ -1660,13 +1712,13 @@ static void ql_process_mac_tx_intr(struct ql_adapter *qdev,
1660/* Fire up a handler to reset the MPI processor. */ 1712/* Fire up a handler to reset the MPI processor. */
1661void ql_queue_fw_error(struct ql_adapter *qdev) 1713void ql_queue_fw_error(struct ql_adapter *qdev)
1662{ 1714{
1663 netif_carrier_off(qdev->ndev); 1715 ql_link_off(qdev);
1664 queue_delayed_work(qdev->workqueue, &qdev->mpi_reset_work, 0); 1716 queue_delayed_work(qdev->workqueue, &qdev->mpi_reset_work, 0);
1665} 1717}
1666 1718
1667void ql_queue_asic_error(struct ql_adapter *qdev) 1719void ql_queue_asic_error(struct ql_adapter *qdev)
1668{ 1720{
1669 netif_carrier_off(qdev->ndev); 1721 ql_link_off(qdev);
1670 ql_disable_interrupts(qdev); 1722 ql_disable_interrupts(qdev);
1671 /* Clear adapter up bit to signal the recovery 1723 /* Clear adapter up bit to signal the recovery
1672 * process that it shouldn't kill the reset worker 1724 * process that it shouldn't kill the reset worker
@@ -2104,7 +2156,7 @@ static int qlge_send(struct sk_buff *skb, struct net_device *ndev)
2104 } 2156 }
2105 tx_ring_desc = &tx_ring->q[tx_ring->prod_idx]; 2157 tx_ring_desc = &tx_ring->q[tx_ring->prod_idx];
2106 mac_iocb_ptr = tx_ring_desc->queue_entry; 2158 mac_iocb_ptr = tx_ring_desc->queue_entry;
2107 memset((void *)mac_iocb_ptr, 0, sizeof(mac_iocb_ptr)); 2159 memset((void *)mac_iocb_ptr, 0, sizeof(*mac_iocb_ptr));
2108 2160
2109 mac_iocb_ptr->opcode = OPCODE_OB_MAC_IOCB; 2161 mac_iocb_ptr->opcode = OPCODE_OB_MAC_IOCB;
2110 mac_iocb_ptr->tid = tx_ring_desc->index; 2162 mac_iocb_ptr->tid = tx_ring_desc->index;
@@ -2743,7 +2795,7 @@ static int ql_start_tx_ring(struct ql_adapter *qdev, struct tx_ring *tx_ring)
2743 2795
2744 ql_init_tx_ring(qdev, tx_ring); 2796 ql_init_tx_ring(qdev, tx_ring);
2745 2797
2746 err = ql_write_cfg(qdev, wqicb, sizeof(wqicb), CFG_LRQ, 2798 err = ql_write_cfg(qdev, wqicb, sizeof(*wqicb), CFG_LRQ,
2747 (u16) tx_ring->wq_id); 2799 (u16) tx_ring->wq_id);
2748 if (err) { 2800 if (err) {
2749 QPRINTK(qdev, IFUP, ERR, "Failed to load tx_ring.\n"); 2801 QPRINTK(qdev, IFUP, ERR, "Failed to load tx_ring.\n");
@@ -3008,7 +3060,7 @@ static int ql_start_rss(struct ql_adapter *qdev)
3008 int i; 3060 int i;
3009 u8 *hash_id = (u8 *) ricb->hash_cq_id; 3061 u8 *hash_id = (u8 *) ricb->hash_cq_id;
3010 3062
3011 memset((void *)ricb, 0, sizeof(ricb)); 3063 memset((void *)ricb, 0, sizeof(*ricb));
3012 3064
3013 ricb->base_cq = qdev->rss_ring_first_cq_id | RSS_L4K; 3065 ricb->base_cq = qdev->rss_ring_first_cq_id | RSS_L4K;
3014 ricb->flags = 3066 ricb->flags =
@@ -3030,7 +3082,7 @@ static int ql_start_rss(struct ql_adapter *qdev)
3030 3082
3031 QPRINTK(qdev, IFUP, DEBUG, "Initializing RSS.\n"); 3083 QPRINTK(qdev, IFUP, DEBUG, "Initializing RSS.\n");
3032 3084
3033 status = ql_write_cfg(qdev, ricb, sizeof(ricb), CFG_LR, 0); 3085 status = ql_write_cfg(qdev, ricb, sizeof(*ricb), CFG_LR, 0);
3034 if (status) { 3086 if (status) {
3035 QPRINTK(qdev, IFUP, ERR, "Failed to load RICB.\n"); 3087 QPRINTK(qdev, IFUP, ERR, "Failed to load RICB.\n");
3036 return status; 3088 return status;
@@ -3039,25 +3091,40 @@ static int ql_start_rss(struct ql_adapter *qdev)
3039 return status; 3091 return status;
3040} 3092}
3041 3093
3042/* Initialize the frame-to-queue routing. */ 3094static int ql_clear_routing_entries(struct ql_adapter *qdev)
3043static int ql_route_initialize(struct ql_adapter *qdev)
3044{ 3095{
3045 int status = 0; 3096 int i, status = 0;
3046 int i;
3047 3097
3048 status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK); 3098 status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK);
3049 if (status) 3099 if (status)
3050 return status; 3100 return status;
3051
3052 /* Clear all the entries in the routing table. */ 3101 /* Clear all the entries in the routing table. */
3053 for (i = 0; i < 16; i++) { 3102 for (i = 0; i < 16; i++) {
3054 status = ql_set_routing_reg(qdev, i, 0, 0); 3103 status = ql_set_routing_reg(qdev, i, 0, 0);
3055 if (status) { 3104 if (status) {
3056 QPRINTK(qdev, IFUP, ERR, 3105 QPRINTK(qdev, IFUP, ERR,
3057 "Failed to init routing register for CAM packets.\n"); 3106 "Failed to init routing register for CAM "
3058 goto exit; 3107 "packets.\n");
3108 break;
3059 } 3109 }
3060 } 3110 }
3111 ql_sem_unlock(qdev, SEM_RT_IDX_MASK);
3112 return status;
3113}
3114
3115/* Initialize the frame-to-queue routing. */
3116static int ql_route_initialize(struct ql_adapter *qdev)
3117{
3118 int status = 0;
3119
3120 status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK);
3121 if (status)
3122 return status;
3123
3124 /* Clear all the entries in the routing table. */
3125 status = ql_clear_routing_entries(qdev);
3126 if (status)
3127 goto exit;
3061 3128
3062 status = ql_set_routing_reg(qdev, RT_IDX_ALL_ERR_SLOT, RT_IDX_ERR, 1); 3129 status = ql_set_routing_reg(qdev, RT_IDX_ALL_ERR_SLOT, RT_IDX_ERR, 1);
3063 if (status) { 3130 if (status) {
@@ -3096,14 +3163,15 @@ exit:
3096 3163
3097int ql_cam_route_initialize(struct ql_adapter *qdev) 3164int ql_cam_route_initialize(struct ql_adapter *qdev)
3098{ 3165{
3099 int status; 3166 int status, set;
3100 3167
3101 status = ql_sem_spinlock(qdev, SEM_MAC_ADDR_MASK); 3168 /* If check if the link is up and use to
3102 if (status) 3169 * determine if we are setting or clearing
3103 return status; 3170 * the MAC address in the CAM.
3104 status = ql_set_mac_addr_reg(qdev, (u8 *) qdev->ndev->perm_addr, 3171 */
3105 MAC_ADDR_TYPE_CAM_MAC, qdev->func * MAX_CQ); 3172 set = ql_read32(qdev, STS);
3106 ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); 3173 set &= qdev->port_link_up;
3174 status = ql_set_mac_addr(qdev, set);
3107 if (status) { 3175 if (status) {
3108 QPRINTK(qdev, IFUP, ERR, "Failed to init mac address.\n"); 3176 QPRINTK(qdev, IFUP, ERR, "Failed to init mac address.\n");
3109 return status; 3177 return status;
@@ -3210,9 +3278,17 @@ static int ql_adapter_reset(struct ql_adapter *qdev)
3210{ 3278{
3211 u32 value; 3279 u32 value;
3212 int status = 0; 3280 int status = 0;
3213 unsigned long end_jiffies = jiffies + 3281 unsigned long end_jiffies;
3214 max((unsigned long)1, usecs_to_jiffies(30));
3215 3282
3283 /* Clear all the entries in the routing table. */
3284 status = ql_clear_routing_entries(qdev);
3285 if (status) {
3286 QPRINTK(qdev, IFUP, ERR, "Failed to clear routing bits.\n");
3287 return status;
3288 }
3289
3290 end_jiffies = jiffies +
3291 max((unsigned long)1, usecs_to_jiffies(30));
3216 ql_write32(qdev, RST_FO, (RST_FO_FR << 16) | RST_FO_FR); 3292 ql_write32(qdev, RST_FO, (RST_FO_FR << 16) | RST_FO_FR);
3217 3293
3218 do { 3294 do {
@@ -3252,7 +3328,7 @@ static int ql_adapter_down(struct ql_adapter *qdev)
3252 int i, status = 0; 3328 int i, status = 0;
3253 struct rx_ring *rx_ring; 3329 struct rx_ring *rx_ring;
3254 3330
3255 netif_carrier_off(qdev->ndev); 3331 ql_link_off(qdev);
3256 3332
3257 /* Don't kill the reset worker thread if we 3333 /* Don't kill the reset worker thread if we
3258 * are in the process of recovery. 3334 * are in the process of recovery.
@@ -3319,8 +3395,12 @@ static int ql_adapter_up(struct ql_adapter *qdev)
3319 } 3395 }
3320 set_bit(QL_ADAPTER_UP, &qdev->flags); 3396 set_bit(QL_ADAPTER_UP, &qdev->flags);
3321 ql_alloc_rx_buffers(qdev); 3397 ql_alloc_rx_buffers(qdev);
3322 if ((ql_read32(qdev, STS) & qdev->port_init)) 3398 /* If the port is initialized and the
3323 netif_carrier_on(qdev->ndev); 3399 * link is up the turn on the carrier.
3400 */
3401 if ((ql_read32(qdev, STS) & qdev->port_init) &&
3402 (ql_read32(qdev, STS) & qdev->port_link_up))
3403 ql_link_on(qdev);
3324 ql_enable_interrupts(qdev); 3404 ql_enable_interrupts(qdev);
3325 ql_enable_all_completion_interrupts(qdev); 3405 ql_enable_all_completion_interrupts(qdev);
3326 netif_tx_start_all_queues(qdev->ndev); 3406 netif_tx_start_all_queues(qdev->ndev);
@@ -3346,11 +3426,6 @@ static int ql_get_adapter_resources(struct ql_adapter *qdev)
3346 return -ENOMEM; 3426 return -ENOMEM;
3347 } 3427 }
3348 status = ql_request_irq(qdev); 3428 status = ql_request_irq(qdev);
3349 if (status)
3350 goto err_irq;
3351 return status;
3352err_irq:
3353 ql_free_mem_resources(qdev);
3354 return status; 3429 return status;
3355} 3430}
3356 3431
@@ -3414,7 +3489,7 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3414 3489
3415 for (i = 0; i < qdev->tx_ring_count; i++) { 3490 for (i = 0; i < qdev->tx_ring_count; i++) {
3416 tx_ring = &qdev->tx_ring[i]; 3491 tx_ring = &qdev->tx_ring[i];
3417 memset((void *)tx_ring, 0, sizeof(tx_ring)); 3492 memset((void *)tx_ring, 0, sizeof(*tx_ring));
3418 tx_ring->qdev = qdev; 3493 tx_ring->qdev = qdev;
3419 tx_ring->wq_id = i; 3494 tx_ring->wq_id = i;
3420 tx_ring->wq_len = qdev->tx_ring_size; 3495 tx_ring->wq_len = qdev->tx_ring_size;
@@ -3430,7 +3505,7 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3430 3505
3431 for (i = 0; i < qdev->rx_ring_count; i++) { 3506 for (i = 0; i < qdev->rx_ring_count; i++) {
3432 rx_ring = &qdev->rx_ring[i]; 3507 rx_ring = &qdev->rx_ring[i];
3433 memset((void *)rx_ring, 0, sizeof(rx_ring)); 3508 memset((void *)rx_ring, 0, sizeof(*rx_ring));
3434 rx_ring->qdev = qdev; 3509 rx_ring->qdev = qdev;
3435 rx_ring->cq_id = i; 3510 rx_ring->cq_id = i;
3436 rx_ring->cpu = i % cpu_cnt; /* CPU to run handler on. */ 3511 rx_ring->cpu = i % cpu_cnt; /* CPU to run handler on. */
@@ -3789,7 +3864,7 @@ static int __devinit ql_init_device(struct pci_dev *pdev,
3789 int pos, err = 0; 3864 int pos, err = 0;
3790 u16 val16; 3865 u16 val16;
3791 3866
3792 memset((void *)qdev, 0, sizeof(qdev)); 3867 memset((void *)qdev, 0, sizeof(*qdev));
3793 err = pci_enable_device(pdev); 3868 err = pci_enable_device(pdev);
3794 if (err) { 3869 if (err) {
3795 dev_err(&pdev->dev, "PCI device enable failed.\n"); 3870 dev_err(&pdev->dev, "PCI device enable failed.\n");
@@ -3976,7 +4051,7 @@ static int __devinit qlge_probe(struct pci_dev *pdev,
3976 pci_disable_device(pdev); 4051 pci_disable_device(pdev);
3977 return err; 4052 return err;
3978 } 4053 }
3979 netif_carrier_off(ndev); 4054 ql_link_off(qdev);
3980 ql_display_dev_info(ndev); 4055 ql_display_dev_info(ndev);
3981 cards_found++; 4056 cards_found++;
3982 return 0; 4057 return 0;
diff --git a/drivers/net/qlge/qlge_mpi.c b/drivers/net/qlge/qlge_mpi.c
index 71afbf8b9c50..6685bd97da91 100644
--- a/drivers/net/qlge/qlge_mpi.c
+++ b/drivers/net/qlge/qlge_mpi.c
@@ -238,7 +238,7 @@ static void ql_link_up(struct ql_adapter *qdev, struct mbox_params *mbcp)
238 &qdev->mpi_port_cfg_work, 0); 238 &qdev->mpi_port_cfg_work, 0);
239 } 239 }
240 240
241 netif_carrier_on(qdev->ndev); 241 ql_link_on(qdev);
242} 242}
243 243
244static void ql_link_down(struct ql_adapter *qdev, struct mbox_params *mbcp) 244static void ql_link_down(struct ql_adapter *qdev, struct mbox_params *mbcp)
@@ -251,7 +251,7 @@ static void ql_link_down(struct ql_adapter *qdev, struct mbox_params *mbcp)
251 if (status) 251 if (status)
252 QPRINTK(qdev, DRV, ERR, "Link down AEN broken!\n"); 252 QPRINTK(qdev, DRV, ERR, "Link down AEN broken!\n");
253 253
254 netif_carrier_off(qdev->ndev); 254 ql_link_off(qdev);
255} 255}
256 256
257static int ql_sfp_in(struct ql_adapter *qdev, struct mbox_params *mbcp) 257static int ql_sfp_in(struct ql_adapter *qdev, struct mbox_params *mbcp)
@@ -849,7 +849,7 @@ void ql_mpi_idc_work(struct work_struct *work)
849 case MB_CMD_PORT_RESET: 849 case MB_CMD_PORT_RESET:
850 case MB_CMD_SET_PORT_CFG: 850 case MB_CMD_SET_PORT_CFG:
851 case MB_CMD_STOP_FW: 851 case MB_CMD_STOP_FW:
852 netif_carrier_off(qdev->ndev); 852 ql_link_off(qdev);
853 /* Signal the resulting link up AEN 853 /* Signal the resulting link up AEN
854 * that the frame routing and mac addr 854 * that the frame routing and mac addr
855 * needs to be set. 855 * needs to be set.
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index ed63d23a6452..961b5397a531 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -49,8 +49,8 @@
49#include <asm/processor.h> 49#include <asm/processor.h>
50 50
51#define DRV_NAME "r6040" 51#define DRV_NAME "r6040"
52#define DRV_VERSION "0.23" 52#define DRV_VERSION "0.24"
53#define DRV_RELDATE "05May2009" 53#define DRV_RELDATE "08Jul2009"
54 54
55/* PHY CHIP Address */ 55/* PHY CHIP Address */
56#define PHY1_ADDR 1 /* For MAC1 */ 56#define PHY1_ADDR 1 /* For MAC1 */
@@ -704,8 +704,11 @@ static irqreturn_t r6040_interrupt(int irq, void *dev_id)
704 /* Read MISR status and clear */ 704 /* Read MISR status and clear */
705 status = ioread16(ioaddr + MISR); 705 status = ioread16(ioaddr + MISR);
706 706
707 if (status == 0x0000 || status == 0xffff) 707 if (status == 0x0000 || status == 0xffff) {
708 /* Restore RDC MAC interrupt */
709 iowrite16(misr, ioaddr + MIER);
708 return IRQ_NONE; 710 return IRQ_NONE;
711 }
709 712
710 /* RX interrupt request */ 713 /* RX interrupt request */
711 if (status & RX_INTS) { 714 if (status & RX_INTS) {
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 341882f959f3..a2d82ddb3b4d 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -865,8 +865,7 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
865 struct sh_eth_private *mdp = netdev_priv(ndev); 865 struct sh_eth_private *mdp = netdev_priv(ndev);
866 struct sh_eth_cpu_data *cd = mdp->cd; 866 struct sh_eth_cpu_data *cd = mdp->cd;
867 irqreturn_t ret = IRQ_NONE; 867 irqreturn_t ret = IRQ_NONE;
868 u32 ioaddr, boguscnt = RX_RING_SIZE; 868 u32 ioaddr, intr_status = 0;
869 u32 intr_status = 0;
870 869
871 ioaddr = ndev->base_addr; 870 ioaddr = ndev->base_addr;
872 spin_lock(&mdp->lock); 871 spin_lock(&mdp->lock);
@@ -901,12 +900,6 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
901 if (intr_status & cd->eesr_err_check) 900 if (intr_status & cd->eesr_err_check)
902 sh_eth_error(ndev, intr_status); 901 sh_eth_error(ndev, intr_status);
903 902
904 if (--boguscnt < 0) {
905 printk(KERN_WARNING
906 "%s: Too much work at interrupt, status=0x%4.4x.\n",
907 ndev->name, intr_status);
908 }
909
910other_irq: 903other_irq:
911 spin_unlock(&mdp->lock); 904 spin_unlock(&mdp->lock);
912 905
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 7681d28c53d7..daf961ab68bc 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -2495,7 +2495,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
2495 if (likely(status >> 16 == (status & 0xffff))) { 2495 if (likely(status >> 16 == (status & 0xffff))) {
2496 skb = sky2->rx_ring[sky2->rx_next].skb; 2496 skb = sky2->rx_ring[sky2->rx_next].skb;
2497 skb->ip_summed = CHECKSUM_COMPLETE; 2497 skb->ip_summed = CHECKSUM_COMPLETE;
2498 skb->csum = status & 0xffff; 2498 skb->csum = le16_to_cpu(status);
2499 } else { 2499 } else {
2500 printk(KERN_NOTICE PFX "%s: hardware receive " 2500 printk(KERN_NOTICE PFX "%s: hardware receive "
2501 "checksum problem (status = %#x)\n", 2501 "checksum problem (status = %#x)\n",
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index b60639bd181b..66067f9d91c0 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -1938,7 +1938,7 @@ static int __devexit smsc911x_drv_remove(struct platform_device *pdev)
1938 if (!res) 1938 if (!res)
1939 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1939 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1940 1940
1941 release_mem_region(res->start, res->end - res->start); 1941 release_mem_region(res->start, resource_size(res));
1942 1942
1943 iounmap(pdata->ioaddr); 1943 iounmap(pdata->ioaddr);
1944 1944
@@ -1976,7 +1976,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
1976 retval = -ENODEV; 1976 retval = -ENODEV;
1977 goto out_0; 1977 goto out_0;
1978 } 1978 }
1979 res_size = res->end - res->start + 1; 1979 res_size = resource_size(res);
1980 1980
1981 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1981 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1982 if (!irq_res) { 1982 if (!irq_res) {
@@ -2104,7 +2104,7 @@ out_unmap_io_3:
2104out_free_netdev_2: 2104out_free_netdev_2:
2105 free_netdev(dev); 2105 free_netdev(dev);
2106out_release_io_1: 2106out_release_io_1:
2107 release_mem_region(res->start, res->end - res->start); 2107 release_mem_region(res->start, resource_size(res));
2108out_0: 2108out_0:
2109 return retval; 2109 return retval;
2110} 2110}
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 838cce8b8fff..669253c7bd41 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -180,7 +180,7 @@ static int full_duplex[MAX_UNITS] = {0, };
180/* These identify the driver base version and may not be removed. */ 180/* These identify the driver base version and may not be removed. */
181static const char version[] __devinitconst = 181static const char version[] __devinitconst =
182KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <becker@scyld.com>\n" 182KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <becker@scyld.com>\n"
183KERN_INFO " (unofficial 2.2/2.4 kernel port, version " DRV_VERSION ", " DRV_RELDATE ")\n"; 183" (unofficial 2.2/2.4 kernel port, version " DRV_VERSION ", " DRV_RELDATE ")\n";
184 184
185MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); 185MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
186MODULE_DESCRIPTION("Adaptec Starfire Ethernet driver"); 186MODULE_DESCRIPTION("Adaptec Starfire Ethernet driver");
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 545f81b34ad7..d1521c3875b2 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -1698,13 +1698,13 @@ static int netdev_close(struct net_device *dev)
1698 1698
1699#ifdef __i386__ 1699#ifdef __i386__
1700 if (netif_msg_hw(np)) { 1700 if (netif_msg_hw(np)) {
1701 printk("\n"KERN_DEBUG" Tx ring at %8.8x:\n", 1701 printk(KERN_DEBUG " Tx ring at %8.8x:\n",
1702 (int)(np->tx_ring_dma)); 1702 (int)(np->tx_ring_dma));
1703 for (i = 0; i < TX_RING_SIZE; i++) 1703 for (i = 0; i < TX_RING_SIZE; i++)
1704 printk(" #%d desc. %4.4x %8.8x %8.8x.\n", 1704 printk(KERN_DEBUG " #%d desc. %4.4x %8.8x %8.8x.\n",
1705 i, np->tx_ring[i].status, np->tx_ring[i].frag[0].addr, 1705 i, np->tx_ring[i].status, np->tx_ring[i].frag[0].addr,
1706 np->tx_ring[i].frag[0].length); 1706 np->tx_ring[i].frag[0].length);
1707 printk("\n"KERN_DEBUG " Rx ring %8.8x:\n", 1707 printk(KERN_DEBUG " Rx ring %8.8x:\n",
1708 (int)(np->rx_ring_dma)); 1708 (int)(np->rx_ring_dma));
1709 for (i = 0; i < /*RX_RING_SIZE*/4 ; i++) { 1709 for (i = 0; i < /*RX_RING_SIZE*/4 ; i++) {
1710 printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x\n", 1710 printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x\n",
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
index 0f78f99f9b20..7030bd5e9848 100644
--- a/drivers/net/tsi108_eth.c
+++ b/drivers/net/tsi108_eth.c
@@ -1132,7 +1132,9 @@ static int tsi108_get_mac(struct net_device *dev)
1132 } 1132 }
1133 1133
1134 if (!is_valid_ether_addr(dev->dev_addr)) { 1134 if (!is_valid_ether_addr(dev->dev_addr)) {
1135 printk("KERN_ERR: word1: %08x, word2: %08x\n", word1, word2); 1135 printk(KERN_ERR
1136 "%s: Invalid MAC address. word1: %08x, word2: %08x\n",
1137 dev->name, word1, word2);
1136 return -EINVAL; 1138 return -EINVAL;
1137 } 1139 }
1138 1140
@@ -1201,8 +1203,8 @@ static void tsi108_set_rx_mode(struct net_device *dev)
1201 __set_bit(hash, &data->mc_hash[0]); 1203 __set_bit(hash, &data->mc_hash[0]);
1202 } else { 1204 } else {
1203 printk(KERN_ERR 1205 printk(KERN_ERR
1204 "%s: got multicast address of length %d " 1206 "%s: got multicast address of length %d instead of 6.\n",
1205 "instead of 6.\n", dev->name, 1207 dev->name,
1206 mc->dmi_addrlen); 1208 mc->dmi_addrlen);
1207 } 1209 }
1208 1210
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 81f054dbb88d..ef49744a5085 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -944,9 +944,10 @@ static void de_set_media (struct de_private *de)
944 macmode &= ~FullDuplex; 944 macmode &= ~FullDuplex;
945 945
946 if (netif_msg_link(de)) { 946 if (netif_msg_link(de)) {
947 printk(KERN_INFO "%s: set link %s\n" 947 printk(KERN_INFO
948 KERN_INFO "%s: mode 0x%x, sia 0x%x,0x%x,0x%x,0x%x\n" 948 "%s: set link %s\n"
949 KERN_INFO "%s: set mode 0x%x, set sia 0x%x,0x%x,0x%x\n", 949 "%s: mode 0x%x, sia 0x%x,0x%x,0x%x,0x%x\n"
950 "%s: set mode 0x%x, set sia 0x%x,0x%x,0x%x\n",
950 de->dev->name, media_name[media], 951 de->dev->name, media_name[media],
951 de->dev->name, dr32(MacMode), dr32(SIAStatus), 952 de->dev->name, dr32(MacMode), dr32(SIAStatus),
952 dr32(CSR13), dr32(CSR14), dr32(CSR15), 953 dr32(CSR13), dr32(CSR14), dr32(CSR15),
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 2abb5d3becc6..99a63649f4fc 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -570,16 +570,18 @@ static void tulip_tx_timeout(struct net_device *dev)
570 (unsigned int)tp->rx_ring[i].buffer2, 570 (unsigned int)tp->rx_ring[i].buffer2,
571 buf[0], buf[1], buf[2]); 571 buf[0], buf[1], buf[2]);
572 for (j = 0; buf[j] != 0xee && j < 1600; j++) 572 for (j = 0; buf[j] != 0xee && j < 1600; j++)
573 if (j < 100) printk(" %2.2x", buf[j]); 573 if (j < 100)
574 printk(" j=%d.\n", j); 574 printk(KERN_CONT " %2.2x", buf[j]);
575 printk(KERN_CONT " j=%d.\n", j);
575 } 576 }
576 printk(KERN_DEBUG " Rx ring %8.8x: ", (int)tp->rx_ring); 577 printk(KERN_DEBUG " Rx ring %8.8x: ", (int)tp->rx_ring);
577 for (i = 0; i < RX_RING_SIZE; i++) 578 for (i = 0; i < RX_RING_SIZE; i++)
578 printk(" %8.8x", (unsigned int)tp->rx_ring[i].status); 579 printk(KERN_CONT " %8.8x",
579 printk("\n" KERN_DEBUG " Tx ring %8.8x: ", (int)tp->tx_ring); 580 (unsigned int)tp->rx_ring[i].status);
581 printk(KERN_DEBUG " Tx ring %8.8x: ", (int)tp->tx_ring);
580 for (i = 0; i < TX_RING_SIZE; i++) 582 for (i = 0; i < TX_RING_SIZE; i++)
581 printk(" %8.8x", (unsigned int)tp->tx_ring[i].status); 583 printk(KERN_CONT " %8.8x", (unsigned int)tp->tx_ring[i].status);
582 printk("\n"); 584 printk(KERN_CONT "\n");
583 } 585 }
584#endif 586#endif
585 587
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 842b1a2c40d4..0f15773dae52 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -142,7 +142,7 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
142static const char version[] __initconst = 142static const char version[] __initconst =
143 KERN_INFO DRV_NAME ".c:v" DRV_VERSION " (2.4 port) " 143 KERN_INFO DRV_NAME ".c:v" DRV_VERSION " (2.4 port) "
144 DRV_RELDATE " Donald Becker <becker@scyld.com>\n" 144 DRV_RELDATE " Donald Becker <becker@scyld.com>\n"
145 KERN_INFO " http://www.scyld.com/network/drivers.html\n"; 145 " http://www.scyld.com/network/drivers.html\n";
146 146
147MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); 147MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
148MODULE_DESCRIPTION("Winbond W89c840 Ethernet driver"); 148MODULE_DESCRIPTION("Winbond W89c840 Ethernet driver");
@@ -939,7 +939,7 @@ static void tx_timeout(struct net_device *dev)
939 printk(KERN_DEBUG " Rx ring %p: ", np->rx_ring); 939 printk(KERN_DEBUG " Rx ring %p: ", np->rx_ring);
940 for (i = 0; i < RX_RING_SIZE; i++) 940 for (i = 0; i < RX_RING_SIZE; i++)
941 printk(" %8.8x", (unsigned int)np->rx_ring[i].status); 941 printk(" %8.8x", (unsigned int)np->rx_ring[i].status);
942 printk("\n"KERN_DEBUG" Tx ring %p: ", np->tx_ring); 942 printk(KERN_DEBUG" Tx ring %p: ", np->tx_ring);
943 for (i = 0; i < TX_RING_SIZE; i++) 943 for (i = 0; i < TX_RING_SIZE; i++)
944 printk(" %8.8x", np->tx_ring[i].status); 944 printk(" %8.8x", np->tx_ring[i].status);
945 printk("\n"); 945 printk("\n");
@@ -1520,7 +1520,7 @@ static int netdev_close(struct net_device *dev)
1520 printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x.\n", 1520 printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x.\n",
1521 i, np->tx_ring[i].length, 1521 i, np->tx_ring[i].length,
1522 np->tx_ring[i].status, np->tx_ring[i].buffer1); 1522 np->tx_ring[i].status, np->tx_ring[i].buffer1);
1523 printk("\n"KERN_DEBUG " Rx ring %8.8x:\n", 1523 printk(KERN_DEBUG " Rx ring %8.8x:\n",
1524 (int)np->rx_ring); 1524 (int)np->rx_ring);
1525 for (i = 0; i < RX_RING_SIZE; i++) { 1525 for (i = 0; i < RX_RING_SIZE; i++) {
1526 printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x\n", 1526 printk(KERN_DEBUG " #%d desc. %4.4x %4.4x %8.8x\n",
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 11a0ba47b677..027f7aba26af 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -486,12 +486,14 @@ static unsigned int tun_chr_poll(struct file *file, poll_table * wait)
486{ 486{
487 struct tun_file *tfile = file->private_data; 487 struct tun_file *tfile = file->private_data;
488 struct tun_struct *tun = __tun_get(tfile); 488 struct tun_struct *tun = __tun_get(tfile);
489 struct sock *sk = tun->sk; 489 struct sock *sk;
490 unsigned int mask = 0; 490 unsigned int mask = 0;
491 491
492 if (!tun) 492 if (!tun)
493 return POLLERR; 493 return POLLERR;
494 494
495 sk = tun->sk;
496
495 DBG(KERN_INFO "%s: tun_chr_poll\n", tun->dev->name); 497 DBG(KERN_INFO "%s: tun_chr_poll\n", tun->dev->name);
496 498
497 poll_wait(file, &tun->socket.wait, wait); 499 poll_wait(file, &tun->socket.wait, wait);
@@ -1324,20 +1326,22 @@ static int tun_chr_close(struct inode *inode, struct file *file)
1324 struct tun_file *tfile = file->private_data; 1326 struct tun_file *tfile = file->private_data;
1325 struct tun_struct *tun; 1327 struct tun_struct *tun;
1326 1328
1327
1328 rtnl_lock();
1329 tun = __tun_get(tfile); 1329 tun = __tun_get(tfile);
1330 if (tun) { 1330 if (tun) {
1331 DBG(KERN_INFO "%s: tun_chr_close\n", tun->dev->name); 1331 struct net_device *dev = tun->dev;
1332
1333 DBG(KERN_INFO "%s: tun_chr_close\n", dev->name);
1332 1334
1333 __tun_detach(tun); 1335 __tun_detach(tun);
1334 1336
1335 /* If desireable, unregister the netdevice. */ 1337 /* If desireable, unregister the netdevice. */
1336 if (!(tun->flags & TUN_PERSIST)) 1338 if (!(tun->flags & TUN_PERSIST)) {
1337 unregister_netdevice(tun->dev); 1339 rtnl_lock();
1338 1340 if (dev->reg_state == NETREG_REGISTERED)
1341 unregister_netdevice(dev);
1342 rtnl_unlock();
1343 }
1339 } 1344 }
1340 rtnl_unlock();
1341 1345
1342 tun = tfile->tun; 1346 tun = tfile->tun;
1343 if (tun) 1347 if (tun)
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index 80e01778dd3b..cd35d50e46d4 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -319,7 +319,7 @@ static int eem_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
319 return crc == crc2; 319 return crc == crc2;
320 320
321 if (unlikely(crc != crc2)) { 321 if (unlikely(crc != crc2)) {
322 dev->stats.rx_errors++; 322 dev->net->stats.rx_errors++;
323 dev_kfree_skb_any(skb2); 323 dev_kfree_skb_any(skb2);
324 } else 324 } else
325 usbnet_skb_return(dev, skb2); 325 usbnet_skb_return(dev, skb2);
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 7ae82446b93a..1d3730d6690f 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -513,11 +513,11 @@ static int dm9601_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
513 len = (skb->data[1] | (skb->data[2] << 8)) - 4; 513 len = (skb->data[1] | (skb->data[2] << 8)) - 4;
514 514
515 if (unlikely(status & 0xbf)) { 515 if (unlikely(status & 0xbf)) {
516 if (status & 0x01) dev->stats.rx_fifo_errors++; 516 if (status & 0x01) dev->net->stats.rx_fifo_errors++;
517 if (status & 0x02) dev->stats.rx_crc_errors++; 517 if (status & 0x02) dev->net->stats.rx_crc_errors++;
518 if (status & 0x04) dev->stats.rx_frame_errors++; 518 if (status & 0x04) dev->net->stats.rx_frame_errors++;
519 if (status & 0x20) dev->stats.rx_missed_errors++; 519 if (status & 0x20) dev->net->stats.rx_missed_errors++;
520 if (status & 0x90) dev->stats.rx_length_errors++; 520 if (status & 0x90) dev->net->stats.rx_length_errors++;
521 return 0; 521 return 0;
522 } 522 }
523 523
diff --git a/drivers/net/usb/net1080.c b/drivers/net/usb/net1080.c
index 034e8a73ca6b..aeb1ab03a9ee 100644
--- a/drivers/net/usb/net1080.c
+++ b/drivers/net/usb/net1080.c
@@ -433,7 +433,7 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
433 dbg("rx framesize %d range %d..%d mtu %d", skb->len, 433 dbg("rx framesize %d range %d..%d mtu %d", skb->len,
434 net->hard_header_len, dev->hard_mtu, net->mtu); 434 net->hard_header_len, dev->hard_mtu, net->mtu);
435#endif 435#endif
436 dev->stats.rx_frame_errors++; 436 dev->net->stats.rx_frame_errors++;
437 nc_ensure_sync(dev); 437 nc_ensure_sync(dev);
438 return 0; 438 return 0;
439 } 439 }
@@ -442,12 +442,12 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
442 hdr_len = le16_to_cpup(&header->hdr_len); 442 hdr_len = le16_to_cpup(&header->hdr_len);
443 packet_len = le16_to_cpup(&header->packet_len); 443 packet_len = le16_to_cpup(&header->packet_len);
444 if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) { 444 if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) {
445 dev->stats.rx_frame_errors++; 445 dev->net->stats.rx_frame_errors++;
446 dbg("packet too big, %d", packet_len); 446 dbg("packet too big, %d", packet_len);
447 nc_ensure_sync(dev); 447 nc_ensure_sync(dev);
448 return 0; 448 return 0;
449 } else if (hdr_len < MIN_HEADER) { 449 } else if (hdr_len < MIN_HEADER) {
450 dev->stats.rx_frame_errors++; 450 dev->net->stats.rx_frame_errors++;
451 dbg("header too short, %d", hdr_len); 451 dbg("header too short, %d", hdr_len);
452 nc_ensure_sync(dev); 452 nc_ensure_sync(dev);
453 return 0; 453 return 0;
@@ -465,21 +465,21 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
465 465
466 if ((packet_len & 0x01) == 0) { 466 if ((packet_len & 0x01) == 0) {
467 if (skb->data [packet_len] != PAD_BYTE) { 467 if (skb->data [packet_len] != PAD_BYTE) {
468 dev->stats.rx_frame_errors++; 468 dev->net->stats.rx_frame_errors++;
469 dbg("bad pad"); 469 dbg("bad pad");
470 return 0; 470 return 0;
471 } 471 }
472 skb_trim(skb, skb->len - 1); 472 skb_trim(skb, skb->len - 1);
473 } 473 }
474 if (skb->len != packet_len) { 474 if (skb->len != packet_len) {
475 dev->stats.rx_frame_errors++; 475 dev->net->stats.rx_frame_errors++;
476 dbg("bad packet len %d (expected %d)", 476 dbg("bad packet len %d (expected %d)",
477 skb->len, packet_len); 477 skb->len, packet_len);
478 nc_ensure_sync(dev); 478 nc_ensure_sync(dev);
479 return 0; 479 return 0;
480 } 480 }
481 if (header->packet_id != get_unaligned(&trailer->packet_id)) { 481 if (header->packet_id != get_unaligned(&trailer->packet_id)) {
482 dev->stats.rx_fifo_errors++; 482 dev->net->stats.rx_fifo_errors++;
483 dbg("(2+ dropped) rx packet_id mismatch 0x%x 0x%x", 483 dbg("(2+ dropped) rx packet_id mismatch 0x%x 0x%x",
484 le16_to_cpu(header->packet_id), 484 le16_to_cpu(header->packet_id),
485 le16_to_cpu(trailer->packet_id)); 485 le16_to_cpu(trailer->packet_id));
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 1bf243ef950e..2232232b7989 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -487,7 +487,7 @@ int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
487 if (unlikely(hdr->msg_type != RNDIS_MSG_PACKET 487 if (unlikely(hdr->msg_type != RNDIS_MSG_PACKET
488 || skb->len < msg_len 488 || skb->len < msg_len
489 || (data_offset + data_len + 8) > msg_len)) { 489 || (data_offset + data_len + 8) > msg_len)) {
490 dev->stats.rx_frame_errors++; 490 dev->net->stats.rx_frame_errors++;
491 devdbg(dev, "bad rndis message %d/%d/%d/%d, len %d", 491 devdbg(dev, "bad rndis message %d/%d/%d/%d, len %d",
492 le32_to_cpu(hdr->msg_type), 492 le32_to_cpu(hdr->msg_type),
493 msg_len, data_offset, data_len, skb->len); 493 msg_len, data_offset, data_len, skb->len);
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 89a91f8c22de..fe045896406b 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1108,18 +1108,18 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
1108 if (unlikely(header & RX_STS_ES_)) { 1108 if (unlikely(header & RX_STS_ES_)) {
1109 if (netif_msg_rx_err(dev)) 1109 if (netif_msg_rx_err(dev))
1110 devdbg(dev, "Error header=0x%08x", header); 1110 devdbg(dev, "Error header=0x%08x", header);
1111 dev->stats.rx_errors++; 1111 dev->net->stats.rx_errors++;
1112 dev->stats.rx_dropped++; 1112 dev->net->stats.rx_dropped++;
1113 1113
1114 if (header & RX_STS_CRC_) { 1114 if (header & RX_STS_CRC_) {
1115 dev->stats.rx_crc_errors++; 1115 dev->net->stats.rx_crc_errors++;
1116 } else { 1116 } else {
1117 if (header & (RX_STS_TL_ | RX_STS_RF_)) 1117 if (header & (RX_STS_TL_ | RX_STS_RF_))
1118 dev->stats.rx_frame_errors++; 1118 dev->net->stats.rx_frame_errors++;
1119 1119
1120 if ((header & RX_STS_LE_) && 1120 if ((header & RX_STS_LE_) &&
1121 (!(header & RX_STS_FT_))) 1121 (!(header & RX_STS_FT_)))
1122 dev->stats.rx_length_errors++; 1122 dev->net->stats.rx_length_errors++;
1123 } 1123 }
1124 } else { 1124 } else {
1125 /* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */ 1125 /* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 22c0585a0319..edfd9e10ceba 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -234,8 +234,8 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
234 int status; 234 int status;
235 235
236 skb->protocol = eth_type_trans (skb, dev->net); 236 skb->protocol = eth_type_trans (skb, dev->net);
237 dev->stats.rx_packets++; 237 dev->net->stats.rx_packets++;
238 dev->stats.rx_bytes += skb->len; 238 dev->net->stats.rx_bytes += skb->len;
239 239
240 if (netif_msg_rx_status (dev)) 240 if (netif_msg_rx_status (dev))
241 devdbg (dev, "< rx, len %zu, type 0x%x", 241 devdbg (dev, "< rx, len %zu, type 0x%x",
@@ -397,7 +397,7 @@ static inline void rx_process (struct usbnet *dev, struct sk_buff *skb)
397 if (netif_msg_rx_err (dev)) 397 if (netif_msg_rx_err (dev))
398 devdbg (dev, "drop"); 398 devdbg (dev, "drop");
399error: 399error:
400 dev->stats.rx_errors++; 400 dev->net->stats.rx_errors++;
401 skb_queue_tail (&dev->done, skb); 401 skb_queue_tail (&dev->done, skb);
402 } 402 }
403} 403}
@@ -420,8 +420,8 @@ static void rx_complete (struct urb *urb)
420 case 0: 420 case 0:
421 if (skb->len < dev->net->hard_header_len) { 421 if (skb->len < dev->net->hard_header_len) {
422 entry->state = rx_cleanup; 422 entry->state = rx_cleanup;
423 dev->stats.rx_errors++; 423 dev->net->stats.rx_errors++;
424 dev->stats.rx_length_errors++; 424 dev->net->stats.rx_length_errors++;
425 if (netif_msg_rx_err (dev)) 425 if (netif_msg_rx_err (dev))
426 devdbg (dev, "rx length %d", skb->len); 426 devdbg (dev, "rx length %d", skb->len);
427 } 427 }
@@ -433,7 +433,7 @@ static void rx_complete (struct urb *urb)
433 * storm, recovering as needed. 433 * storm, recovering as needed.
434 */ 434 */
435 case -EPIPE: 435 case -EPIPE:
436 dev->stats.rx_errors++; 436 dev->net->stats.rx_errors++;
437 usbnet_defer_kevent (dev, EVENT_RX_HALT); 437 usbnet_defer_kevent (dev, EVENT_RX_HALT);
438 // FALLTHROUGH 438 // FALLTHROUGH
439 439
@@ -451,7 +451,7 @@ static void rx_complete (struct urb *urb)
451 case -EPROTO: 451 case -EPROTO:
452 case -ETIME: 452 case -ETIME:
453 case -EILSEQ: 453 case -EILSEQ:
454 dev->stats.rx_errors++; 454 dev->net->stats.rx_errors++;
455 if (!timer_pending (&dev->delay)) { 455 if (!timer_pending (&dev->delay)) {
456 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES); 456 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES);
457 if (netif_msg_link (dev)) 457 if (netif_msg_link (dev))
@@ -465,12 +465,12 @@ block:
465 465
466 /* data overrun ... flush fifo? */ 466 /* data overrun ... flush fifo? */
467 case -EOVERFLOW: 467 case -EOVERFLOW:
468 dev->stats.rx_over_errors++; 468 dev->net->stats.rx_over_errors++;
469 // FALLTHROUGH 469 // FALLTHROUGH
470 470
471 default: 471 default:
472 entry->state = rx_cleanup; 472 entry->state = rx_cleanup;
473 dev->stats.rx_errors++; 473 dev->net->stats.rx_errors++;
474 if (netif_msg_rx_err (dev)) 474 if (netif_msg_rx_err (dev))
475 devdbg (dev, "rx status %d", urb_status); 475 devdbg (dev, "rx status %d", urb_status);
476 break; 476 break;
@@ -583,8 +583,8 @@ int usbnet_stop (struct net_device *net)
583 583
584 if (netif_msg_ifdown (dev)) 584 if (netif_msg_ifdown (dev))
585 devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld", 585 devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld",
586 dev->stats.rx_packets, dev->stats.tx_packets, 586 net->stats.rx_packets, net->stats.tx_packets,
587 dev->stats.rx_errors, dev->stats.tx_errors 587 net->stats.rx_errors, net->stats.tx_errors
588 ); 588 );
589 589
590 // ensure there are no more active urbs 590 // ensure there are no more active urbs
@@ -891,10 +891,10 @@ static void tx_complete (struct urb *urb)
891 struct usbnet *dev = entry->dev; 891 struct usbnet *dev = entry->dev;
892 892
893 if (urb->status == 0) { 893 if (urb->status == 0) {
894 dev->stats.tx_packets++; 894 dev->net->stats.tx_packets++;
895 dev->stats.tx_bytes += entry->length; 895 dev->net->stats.tx_bytes += entry->length;
896 } else { 896 } else {
897 dev->stats.tx_errors++; 897 dev->net->stats.tx_errors++;
898 898
899 switch (urb->status) { 899 switch (urb->status) {
900 case -EPIPE: 900 case -EPIPE:
@@ -1020,7 +1020,7 @@ int usbnet_start_xmit (struct sk_buff *skb, struct net_device *net)
1020 devdbg (dev, "drop, code %d", retval); 1020 devdbg (dev, "drop, code %d", retval);
1021drop: 1021drop:
1022 retval = NET_XMIT_SUCCESS; 1022 retval = NET_XMIT_SUCCESS;
1023 dev->stats.tx_dropped++; 1023 dev->net->stats.tx_dropped++;
1024 if (skb) 1024 if (skb)
1025 dev_kfree_skb_any (skb); 1025 dev_kfree_skb_any (skb);
1026 usb_free_urb (urb); 1026 usb_free_urb (urb);
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 87197dd9c788..1097c72e44d5 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -208,11 +208,14 @@ rx_drop:
208 208
209static struct net_device_stats *veth_get_stats(struct net_device *dev) 209static struct net_device_stats *veth_get_stats(struct net_device *dev)
210{ 210{
211 struct veth_priv *priv = netdev_priv(dev); 211 struct veth_priv *priv;
212 struct net_device_stats *dev_stats = &dev->stats; 212 struct net_device_stats *dev_stats;
213 unsigned int cpu; 213 int cpu;
214 struct veth_net_stats *stats; 214 struct veth_net_stats *stats;
215 215
216 priv = netdev_priv(dev);
217 dev_stats = &dev->stats;
218
216 dev_stats->rx_packets = 0; 219 dev_stats->rx_packets = 0;
217 dev_stats->tx_packets = 0; 220 dev_stats->tx_packets = 0;
218 dev_stats->rx_bytes = 0; 221 dev_stats->rx_bytes = 0;
@@ -220,17 +223,16 @@ static struct net_device_stats *veth_get_stats(struct net_device *dev)
220 dev_stats->tx_dropped = 0; 223 dev_stats->tx_dropped = 0;
221 dev_stats->rx_dropped = 0; 224 dev_stats->rx_dropped = 0;
222 225
223 if (priv->stats) 226 for_each_online_cpu(cpu) {
224 for_each_online_cpu(cpu) { 227 stats = per_cpu_ptr(priv->stats, cpu);
225 stats = per_cpu_ptr(priv->stats, cpu);
226 228
227 dev_stats->rx_packets += stats->rx_packets; 229 dev_stats->rx_packets += stats->rx_packets;
228 dev_stats->tx_packets += stats->tx_packets; 230 dev_stats->tx_packets += stats->tx_packets;
229 dev_stats->rx_bytes += stats->rx_bytes; 231 dev_stats->rx_bytes += stats->rx_bytes;
230 dev_stats->tx_bytes += stats->tx_bytes; 232 dev_stats->tx_bytes += stats->tx_bytes;
231 dev_stats->tx_dropped += stats->tx_dropped; 233 dev_stats->tx_dropped += stats->tx_dropped;
232 dev_stats->rx_dropped += stats->rx_dropped; 234 dev_stats->rx_dropped += stats->rx_dropped;
233 } 235 }
234 236
235 return dev_stats; 237 return dev_stats;
236} 238}
@@ -257,8 +259,6 @@ static int veth_close(struct net_device *dev)
257 netif_carrier_off(dev); 259 netif_carrier_off(dev);
258 netif_carrier_off(priv->peer); 260 netif_carrier_off(priv->peer);
259 261
260 free_percpu(priv->stats);
261 priv->stats = NULL;
262 return 0; 262 return 0;
263} 263}
264 264
@@ -289,6 +289,15 @@ static int veth_dev_init(struct net_device *dev)
289 return 0; 289 return 0;
290} 290}
291 291
292static void veth_dev_free(struct net_device *dev)
293{
294 struct veth_priv *priv;
295
296 priv = netdev_priv(dev);
297 free_percpu(priv->stats);
298 free_netdev(dev);
299}
300
292static const struct net_device_ops veth_netdev_ops = { 301static const struct net_device_ops veth_netdev_ops = {
293 .ndo_init = veth_dev_init, 302 .ndo_init = veth_dev_init,
294 .ndo_open = veth_open, 303 .ndo_open = veth_open,
@@ -306,7 +315,7 @@ static void veth_setup(struct net_device *dev)
306 dev->netdev_ops = &veth_netdev_ops; 315 dev->netdev_ops = &veth_netdev_ops;
307 dev->ethtool_ops = &veth_ethtool_ops; 316 dev->ethtool_ops = &veth_ethtool_ops;
308 dev->features |= NETIF_F_LLTX; 317 dev->features |= NETIF_F_LLTX;
309 dev->destructor = free_netdev; 318 dev->destructor = veth_dev_free;
310} 319}
311 320
312/* 321/*
diff --git a/drivers/net/wan/hd64570.c b/drivers/net/wan/hd64570.c
index 223238de475c..1ea1ef6c3b96 100644
--- a/drivers/net/wan/hd64570.c
+++ b/drivers/net/wan/hd64570.c
@@ -584,8 +584,9 @@ static void sca_dump_rings(struct net_device *dev)
584 sca_in(DSR_RX(phy_node(port)), card) & DSR_DE ? "" : "in"); 584 sca_in(DSR_RX(phy_node(port)), card) & DSR_DE ? "" : "in");
585 for (cnt = 0; cnt < port_to_card(port)->rx_ring_buffers; cnt++) 585 for (cnt = 0; cnt < port_to_card(port)->rx_ring_buffers; cnt++)
586 printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); 586 printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat)));
587 printk(KERN_CONT "\n");
587 588
588 printk("\n" KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u " 589 printk(KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u "
589 "last=%u %sactive", 590 "last=%u %sactive",
590 sca_inw(get_dmac_tx(port) + CDAL, card), 591 sca_inw(get_dmac_tx(port) + CDAL, card),
591 sca_inw(get_dmac_tx(port) + EDAL, card), 592 sca_inw(get_dmac_tx(port) + EDAL, card),
diff --git a/drivers/net/wan/hd64572.c b/drivers/net/wan/hd64572.c
index 497b003d7239..f099c34a3ae2 100644
--- a/drivers/net/wan/hd64572.c
+++ b/drivers/net/wan/hd64572.c
@@ -529,8 +529,9 @@ static void sca_dump_rings(struct net_device *dev)
529 sca_in(DSR_RX(port->chan), card) & DSR_DE ? "" : "in"); 529 sca_in(DSR_RX(port->chan), card) & DSR_DE ? "" : "in");
530 for (cnt = 0; cnt < port->card->rx_ring_buffers; cnt++) 530 for (cnt = 0; cnt < port->card->rx_ring_buffers; cnt++)
531 printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); 531 printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat)));
532 printk(KERN_CONT "\n");
532 533
533 printk("\n" KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u " 534 printk(KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u "
534 "last=%u %sactive", 535 "last=%u %sactive",
535 sca_inl(get_dmac_tx(port) + CDAL, card), 536 sca_inl(get_dmac_tx(port) + CDAL, card),
536 sca_inl(get_dmac_tx(port) + EDAL, card), 537 sca_inl(get_dmac_tx(port) + EDAL, card),
diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index 3fb9dbc88a1a..d14e95a08d66 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -326,11 +326,9 @@ sbni_pci_probe( struct net_device *dev )
326 } 326 }
327 327
328 if (pci_irq_line <= 0 || pci_irq_line >= nr_irqs) 328 if (pci_irq_line <= 0 || pci_irq_line >= nr_irqs)
329 printk( KERN_WARNING " WARNING: The PCI BIOS assigned " 329 printk( KERN_WARNING
330 "this PCI card to IRQ %d, which is unlikely " 330 " WARNING: The PCI BIOS assigned this PCI card to IRQ %d, which is unlikely to work!.\n"
331 "to work!.\n" 331 " You should use the PCI BIOS setup to assign a valid IRQ line.\n",
332 KERN_WARNING " You should use the PCI BIOS "
333 "setup to assign a valid IRQ line.\n",
334 pci_irq_line ); 332 pci_irq_line );
335 333
336 /* avoiding re-enable dual adapters */ 334 /* avoiding re-enable dual adapters */
diff --git a/drivers/net/wireless/ath/Kconfig b/drivers/net/wireless/ath/Kconfig
index d26e7b485315..eb0337c49546 100644
--- a/drivers/net/wireless/ath/Kconfig
+++ b/drivers/net/wireless/ath/Kconfig
@@ -1,5 +1,6 @@
1config ATH_COMMON 1config ATH_COMMON
2 tristate "Atheros Wireless Cards" 2 tristate "Atheros Wireless Cards"
3 depends on WLAN_80211
3 depends on ATH5K || ATH9K || AR9170_USB 4 depends on ATH5K || ATH9K || AR9170_USB
4 5
5source "drivers/net/wireless/ath/ath5k/Kconfig" 6source "drivers/net/wireless/ath/ath5k/Kconfig"
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index b61a071788a5..4ccf48e396df 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -355,7 +355,14 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
355 } 355 }
356 356
357 if (bf_next == NULL) { 357 if (bf_next == NULL) {
358 INIT_LIST_HEAD(&bf_head); 358 /*
359 * Make sure the last desc is reclaimed if it
360 * not a holding desc.
361 */
362 if (!bf_last->bf_stale)
363 list_move_tail(&bf->list, &bf_head);
364 else
365 INIT_LIST_HEAD(&bf_head);
359 } else { 366 } else {
360 ASSERT(!list_empty(bf_q)); 367 ASSERT(!list_empty(bf_q));
361 list_move_tail(&bf->list, &bf_head); 368 list_move_tail(&bf->list, &bf_head);
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index f580c2812d91..40448067e4cc 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -648,6 +648,7 @@ struct b43_wl {
648 u8 nr_devs; 648 u8 nr_devs;
649 649
650 bool radiotap_enabled; 650 bool radiotap_enabled;
651 bool radio_enabled;
651 652
652 /* The beacon we are currently using (AP or IBSS mode). 653 /* The beacon we are currently using (AP or IBSS mode).
653 * This beacon stuff is protected by the irq_lock. */ 654 * This beacon stuff is protected by the irq_lock. */
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 6456afebdba1..e71c8d9cd706 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -3497,8 +3497,8 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
3497 if (phy->ops->set_rx_antenna) 3497 if (phy->ops->set_rx_antenna)
3498 phy->ops->set_rx_antenna(dev, antenna); 3498 phy->ops->set_rx_antenna(dev, antenna);
3499 3499
3500 if (!!conf->radio_enabled != phy->radio_on) { 3500 if (wl->radio_enabled != phy->radio_on) {
3501 if (conf->radio_enabled) { 3501 if (wl->radio_enabled) {
3502 b43_software_rfkill(dev, false); 3502 b43_software_rfkill(dev, false);
3503 b43info(dev->wl, "Radio turned on by software\n"); 3503 b43info(dev->wl, "Radio turned on by software\n");
3504 if (!dev->radio_hw_enable) { 3504 if (!dev->radio_hw_enable) {
@@ -4339,6 +4339,7 @@ static int b43_op_start(struct ieee80211_hw *hw)
4339 wl->beacon0_uploaded = 0; 4339 wl->beacon0_uploaded = 0;
4340 wl->beacon1_uploaded = 0; 4340 wl->beacon1_uploaded = 0;
4341 wl->beacon_templates_virgin = 1; 4341 wl->beacon_templates_virgin = 1;
4342 wl->radio_enabled = 1;
4342 4343
4343 mutex_lock(&wl->mutex); 4344 mutex_lock(&wl->mutex);
4344 4345
@@ -4378,6 +4379,7 @@ static void b43_op_stop(struct ieee80211_hw *hw)
4378 if (b43_status(dev) >= B43_STAT_STARTED) 4379 if (b43_status(dev) >= B43_STAT_STARTED)
4379 b43_wireless_core_stop(dev); 4380 b43_wireless_core_stop(dev);
4380 b43_wireless_core_exit(dev); 4381 b43_wireless_core_exit(dev);
4382 wl->radio_enabled = 0;
4381 mutex_unlock(&wl->mutex); 4383 mutex_unlock(&wl->mutex);
4382 4384
4383 cancel_work_sync(&(wl->txpower_adjust_work)); 4385 cancel_work_sync(&(wl->txpower_adjust_work));
@@ -4560,6 +4562,7 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
4560 B43_WARN_ON(1); 4562 B43_WARN_ON(1);
4561 4563
4562 dev->phy.gmode = have_2ghz_phy; 4564 dev->phy.gmode = have_2ghz_phy;
4565 dev->phy.radio_on = 1;
4563 tmp = dev->phy.gmode ? B43_TMSLOW_GMODE : 0; 4566 tmp = dev->phy.gmode ? B43_TMSLOW_GMODE : 0;
4564 b43_wireless_core_reset(dev, tmp); 4567 b43_wireless_core_reset(dev, tmp);
4565 4568
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c
index 3cfc30307a27..6c3a74964ab8 100644
--- a/drivers/net/wireless/b43/pcmcia.c
+++ b/drivers/net/wireless/b43/pcmcia.c
@@ -35,6 +35,7 @@
35 35
36static /*const */ struct pcmcia_device_id b43_pcmcia_tbl[] = { 36static /*const */ struct pcmcia_device_id b43_pcmcia_tbl[] = {
37 PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448), 37 PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x448),
38 PCMCIA_DEVICE_MANF_CARD(0x2D0, 0x476),
38 PCMCIA_DEVICE_NULL, 39 PCMCIA_DEVICE_NULL,
39}; 40};
40 41
diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h
index 77fda148ac46..038baa8869e2 100644
--- a/drivers/net/wireless/b43legacy/b43legacy.h
+++ b/drivers/net/wireless/b43legacy/b43legacy.h
@@ -607,6 +607,7 @@ struct b43legacy_wl {
607 u8 nr_devs; 607 u8 nr_devs;
608 608
609 bool radiotap_enabled; 609 bool radiotap_enabled;
610 bool radio_enabled;
610 611
611 /* The beacon we are currently using (AP or IBSS mode). 612 /* The beacon we are currently using (AP or IBSS mode).
612 * This beacon stuff is protected by the irq_lock. */ 613 * This beacon stuff is protected by the irq_lock. */
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index e5136fb65ddd..c4973c1942bf 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -2689,8 +2689,8 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
2689 /* Antennas for RX and management frame TX. */ 2689 /* Antennas for RX and management frame TX. */
2690 b43legacy_mgmtframe_txantenna(dev, antenna_tx); 2690 b43legacy_mgmtframe_txantenna(dev, antenna_tx);
2691 2691
2692 if (!!conf->radio_enabled != phy->radio_on) { 2692 if (wl->radio_enabled != phy->radio_on) {
2693 if (conf->radio_enabled) { 2693 if (wl->radio_enabled) {
2694 b43legacy_radio_turn_on(dev); 2694 b43legacy_radio_turn_on(dev);
2695 b43legacyinfo(dev->wl, "Radio turned on by software\n"); 2695 b43legacyinfo(dev->wl, "Radio turned on by software\n");
2696 if (!dev->radio_hw_enable) 2696 if (!dev->radio_hw_enable)
@@ -3441,6 +3441,7 @@ static int b43legacy_op_start(struct ieee80211_hw *hw)
3441 wl->beacon0_uploaded = 0; 3441 wl->beacon0_uploaded = 0;
3442 wl->beacon1_uploaded = 0; 3442 wl->beacon1_uploaded = 0;
3443 wl->beacon_templates_virgin = 1; 3443 wl->beacon_templates_virgin = 1;
3444 wl->radio_enabled = 1;
3444 3445
3445 mutex_lock(&wl->mutex); 3446 mutex_lock(&wl->mutex);
3446 3447
@@ -3479,6 +3480,7 @@ static void b43legacy_op_stop(struct ieee80211_hw *hw)
3479 if (b43legacy_status(dev) >= B43legacy_STAT_STARTED) 3480 if (b43legacy_status(dev) >= B43legacy_STAT_STARTED)
3480 b43legacy_wireless_core_stop(dev); 3481 b43legacy_wireless_core_stop(dev);
3481 b43legacy_wireless_core_exit(dev); 3482 b43legacy_wireless_core_exit(dev);
3483 wl->radio_enabled = 0;
3482 mutex_unlock(&wl->mutex); 3484 mutex_unlock(&wl->mutex);
3483} 3485}
3484 3486
@@ -3620,6 +3622,7 @@ static int b43legacy_wireless_core_attach(struct b43legacy_wldev *dev)
3620 have_bphy = 1; 3622 have_bphy = 1;
3621 3623
3622 dev->phy.gmode = (have_gphy || have_bphy); 3624 dev->phy.gmode = (have_gphy || have_bphy);
3625 dev->phy.radio_on = 1;
3623 tmp = dev->phy.gmode ? B43legacy_TMSLOW_GMODE : 0; 3626 tmp = dev->phy.gmode ? B43legacy_TMSLOW_GMODE : 0;
3624 b43legacy_wireless_core_reset(dev, tmp); 3627 b43legacy_wireless_core_reset(dev, tmp);
3625 3628
diff --git a/drivers/net/wireless/iwmc3200wifi/Kconfig b/drivers/net/wireless/iwmc3200wifi/Kconfig
index 1eccb6df46dd..030401d367d3 100644
--- a/drivers/net/wireless/iwmc3200wifi/Kconfig
+++ b/drivers/net/wireless/iwmc3200wifi/Kconfig
@@ -4,6 +4,15 @@ config IWM
4 depends on CFG80211 4 depends on CFG80211
5 select WIRELESS_EXT 5 select WIRELESS_EXT
6 select FW_LOADER 6 select FW_LOADER
7 help
8 The Intel Wireless Multicomm 3200 hardware is a combo
9 card with GPS, Bluetooth, WiMax and 802.11 radios. It
10 runs over SDIO and is typically found on Moorestown
11 based platform. This driver takes care of the 802.11
12 part, which is a fullmac one.
13
14 If you choose to build it as a module, it'll be called
15 iwmc3200wifi.ko.
7 16
8config IWM_DEBUG 17config IWM_DEBUG
9 bool "Enable full debugging output in iwmc3200wifi" 18 bool "Enable full debugging output in iwmc3200wifi"
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index e789c6e9938c..a111bda392e2 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -418,6 +418,7 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
418 continue; 418 continue;
419 419
420 if (!data2->started || !hwsim_ps_rx_ok(data2, skb) || 420 if (!data2->started || !hwsim_ps_rx_ok(data2, skb) ||
421 !data->channel || !data2->channel ||
421 data->channel->center_freq != data2->channel->center_freq || 422 data->channel->center_freq != data2->channel->center_freq ||
422 !(data->group & data2->group)) 423 !(data->group & data2->group))
423 continue; 424 continue;
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index b618bd14583f..22ca122bd798 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -823,30 +823,30 @@ void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb)
823 struct p54_tx_info *range; 823 struct p54_tx_info *range;
824 unsigned long flags; 824 unsigned long flags;
825 825
826 if (unlikely(!skb || !dev || skb_queue_empty(&priv->tx_queue))) 826 if (unlikely(!skb || !dev || !skb_queue_len(&priv->tx_queue)))
827 return; 827 return;
828 828
829 /* There used to be a check here to see if the SKB was on the 829 /*
830 * TX queue or not. This can never happen because all SKBs we 830 * don't try to free an already unlinked skb
831 * see here successfully went through p54_assign_address()
832 * which means the SKB is on the ->tx_queue.
833 */ 831 */
832 if (unlikely((!skb->next) || (!skb->prev)))
833 return;
834 834
835 spin_lock_irqsave(&priv->tx_queue.lock, flags); 835 spin_lock_irqsave(&priv->tx_queue.lock, flags);
836 info = IEEE80211_SKB_CB(skb); 836 info = IEEE80211_SKB_CB(skb);
837 range = (void *)info->rate_driver_data; 837 range = (void *)info->rate_driver_data;
838 if (!skb_queue_is_first(&priv->tx_queue, skb)) { 838 if (skb->prev != (struct sk_buff *)&priv->tx_queue) {
839 struct ieee80211_tx_info *ni; 839 struct ieee80211_tx_info *ni;
840 struct p54_tx_info *mr; 840 struct p54_tx_info *mr;
841 841
842 ni = IEEE80211_SKB_CB(skb_queue_prev(&priv->tx_queue, skb)); 842 ni = IEEE80211_SKB_CB(skb->prev);
843 mr = (struct p54_tx_info *)ni->rate_driver_data; 843 mr = (struct p54_tx_info *)ni->rate_driver_data;
844 } 844 }
845 if (!skb_queue_is_last(&priv->tx_queue, skb)) { 845 if (skb->next != (struct sk_buff *)&priv->tx_queue) {
846 struct ieee80211_tx_info *ni; 846 struct ieee80211_tx_info *ni;
847 struct p54_tx_info *mr; 847 struct p54_tx_info *mr;
848 848
849 ni = IEEE80211_SKB_CB(skb_queue_next(&priv->tx_queue, skb)); 849 ni = IEEE80211_SKB_CB(skb->next);
850 mr = (struct p54_tx_info *)ni->rate_driver_data; 850 mr = (struct p54_tx_info *)ni->rate_driver_data;
851 } 851 }
852 __skb_unlink(skb, &priv->tx_queue); 852 __skb_unlink(skb, &priv->tx_queue);
@@ -864,13 +864,15 @@ static struct sk_buff *p54_find_tx_entry(struct ieee80211_hw *dev,
864 unsigned long flags; 864 unsigned long flags;
865 865
866 spin_lock_irqsave(&priv->tx_queue.lock, flags); 866 spin_lock_irqsave(&priv->tx_queue.lock, flags);
867 skb_queue_walk(&priv->tx_queue, entry) { 867 entry = priv->tx_queue.next;
868 while (entry != (struct sk_buff *)&priv->tx_queue) {
868 struct p54_hdr *hdr = (struct p54_hdr *) entry->data; 869 struct p54_hdr *hdr = (struct p54_hdr *) entry->data;
869 870
870 if (hdr->req_id == req_id) { 871 if (hdr->req_id == req_id) {
871 spin_unlock_irqrestore(&priv->tx_queue.lock, flags); 872 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
872 return entry; 873 return entry;
873 } 874 }
875 entry = entry->next;
874 } 876 }
875 spin_unlock_irqrestore(&priv->tx_queue.lock, flags); 877 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
876 return NULL; 878 return NULL;
@@ -888,33 +890,36 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
888 int count, idx; 890 int count, idx;
889 891
890 spin_lock_irqsave(&priv->tx_queue.lock, flags); 892 spin_lock_irqsave(&priv->tx_queue.lock, flags);
891 skb_queue_walk(&priv->tx_queue, entry) { 893 entry = (struct sk_buff *) priv->tx_queue.next;
894 while (entry != (struct sk_buff *)&priv->tx_queue) {
892 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); 895 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry);
893 struct p54_hdr *entry_hdr; 896 struct p54_hdr *entry_hdr;
894 struct p54_tx_data *entry_data; 897 struct p54_tx_data *entry_data;
895 unsigned int pad = 0, frame_len; 898 unsigned int pad = 0, frame_len;
896 899
897 range = (void *)info->rate_driver_data; 900 range = (void *)info->rate_driver_data;
898 if (range->start_addr != addr) 901 if (range->start_addr != addr) {
902 entry = entry->next;
899 continue; 903 continue;
904 }
900 905
901 if (!skb_queue_is_last(&priv->tx_queue, entry)) { 906 if (entry->next != (struct sk_buff *)&priv->tx_queue) {
902 struct ieee80211_tx_info *ni; 907 struct ieee80211_tx_info *ni;
903 struct p54_tx_info *mr; 908 struct p54_tx_info *mr;
904 909
905 ni = IEEE80211_SKB_CB(skb_queue_next(&priv->tx_queue, 910 ni = IEEE80211_SKB_CB(entry->next);
906 entry));
907 mr = (struct p54_tx_info *)ni->rate_driver_data; 911 mr = (struct p54_tx_info *)ni->rate_driver_data;
908 } 912 }
909 913
910 __skb_unlink(entry, &priv->tx_queue); 914 __skb_unlink(entry, &priv->tx_queue);
911 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
912 915
913 frame_len = entry->len; 916 frame_len = entry->len;
914 entry_hdr = (struct p54_hdr *) entry->data; 917 entry_hdr = (struct p54_hdr *) entry->data;
915 entry_data = (struct p54_tx_data *) entry_hdr->data; 918 entry_data = (struct p54_tx_data *) entry_hdr->data;
916 priv->tx_stats[entry_data->hw_queue].len--; 919 if (priv->tx_stats[entry_data->hw_queue].len)
920 priv->tx_stats[entry_data->hw_queue].len--;
917 priv->stats.dot11ACKFailureCount += payload->tries - 1; 921 priv->stats.dot11ACKFailureCount += payload->tries - 1;
922 spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
918 923
919 /* 924 /*
920 * Frames in P54_QUEUE_FWSCAN and P54_QUEUE_BEACON are 925 * Frames in P54_QUEUE_FWSCAN and P54_QUEUE_BEACON are
@@ -1164,21 +1169,23 @@ static int p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb,
1164 } 1169 }
1165 } 1170 }
1166 1171
1167 skb_queue_walk(&priv->tx_queue, entry) { 1172 entry = priv->tx_queue.next;
1173 while (left--) {
1168 u32 hole_size; 1174 u32 hole_size;
1169 info = IEEE80211_SKB_CB(entry); 1175 info = IEEE80211_SKB_CB(entry);
1170 range = (void *)info->rate_driver_data; 1176 range = (void *)info->rate_driver_data;
1171 hole_size = range->start_addr - last_addr; 1177 hole_size = range->start_addr - last_addr;
1172 if (!target_skb && hole_size >= len) { 1178 if (!target_skb && hole_size >= len) {
1173 target_skb = skb_queue_prev(&priv->tx_queue, entry); 1179 target_skb = entry->prev;
1174 hole_size -= len; 1180 hole_size -= len;
1175 target_addr = last_addr; 1181 target_addr = last_addr;
1176 } 1182 }
1177 largest_hole = max(largest_hole, hole_size); 1183 largest_hole = max(largest_hole, hole_size);
1178 last_addr = range->end_addr; 1184 last_addr = range->end_addr;
1185 entry = entry->next;
1179 } 1186 }
1180 if (!target_skb && priv->rx_end - last_addr >= len) { 1187 if (!target_skb && priv->rx_end - last_addr >= len) {
1181 target_skb = skb_peek_tail(&priv->tx_queue); 1188 target_skb = priv->tx_queue.prev;
1182 largest_hole = max(largest_hole, priv->rx_end - last_addr - len); 1189 largest_hole = max(largest_hole, priv->rx_end - last_addr - len);
1183 if (!skb_queue_empty(&priv->tx_queue)) { 1190 if (!skb_queue_empty(&priv->tx_queue)) {
1184 info = IEEE80211_SKB_CB(target_skb); 1191 info = IEEE80211_SKB_CB(target_skb);
@@ -2084,6 +2091,7 @@ out:
2084static void p54_stop(struct ieee80211_hw *dev) 2091static void p54_stop(struct ieee80211_hw *dev)
2085{ 2092{
2086 struct p54_common *priv = dev->priv; 2093 struct p54_common *priv = dev->priv;
2094 struct sk_buff *skb;
2087 2095
2088 mutex_lock(&priv->conf_mutex); 2096 mutex_lock(&priv->conf_mutex);
2089 priv->mode = NL80211_IFTYPE_UNSPECIFIED; 2097 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
@@ -2098,7 +2106,8 @@ static void p54_stop(struct ieee80211_hw *dev)
2098 p54_tx_cancel(dev, priv->cached_beacon); 2106 p54_tx_cancel(dev, priv->cached_beacon);
2099 2107
2100 priv->stop(dev); 2108 priv->stop(dev);
2101 skb_queue_purge(&priv->tx_queue); 2109 while ((skb = skb_dequeue(&priv->tx_queue)))
2110 kfree_skb(skb);
2102 priv->cached_beacon = NULL; 2111 priv->cached_beacon = NULL;
2103 priv->tsf_high32 = priv->tsf_low32 = 0; 2112 priv->tsf_high32 = priv->tsf_low32 = 0;
2104 mutex_unlock(&priv->conf_mutex); 2113 mutex_unlock(&priv->conf_mutex);
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index b10b0383dfa5..698b11b1cadb 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -2427,11 +2427,10 @@ static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
2427 2427
2428#ifdef PCMCIA_DEBUG 2428#ifdef PCMCIA_DEBUG
2429 if (pc_debug > 3) { 2429 if (pc_debug > 3) {
2430 int i; 2430 print_hex_dump(KERN_DEBUG, "skb->data before untranslate: ",
2431 printk(KERN_DEBUG "skb->data before untranslate"); 2431 DUMP_PREFIX_NONE, 16, 1,
2432 for (i = 0; i < 64; i++) 2432 skb->data, 64, true);
2433 printk("%02x ", skb->data[i]); 2433 printk(KERN_DEBUG
2434 printk("\n" KERN_DEBUG
2435 "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n", 2434 "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n",
2436 ntohs(type), psnap->dsap, psnap->ssap, psnap->ctrl, 2435 ntohs(type), psnap->dsap, psnap->ssap, psnap->ctrl,
2437 psnap->org[0], psnap->org[1], psnap->org[2]); 2436 psnap->org[0], psnap->org[1], psnap->org[2]);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 6af706408ac0..c6d300666ad8 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -3556,17 +3556,8 @@ wv_82593_config(struct net_device * dev)
3556 cfblk.rcvstop = TRUE; /* Enable Receive Stop Register */ 3556 cfblk.rcvstop = TRUE; /* Enable Receive Stop Register */
3557 3557
3558#ifdef DEBUG_I82593_SHOW 3558#ifdef DEBUG_I82593_SHOW
3559 { 3559 print_hex_dump(KERN_DEBUG, "wavelan_cs: config block: ", DUMP_PREFIX_NONE,
3560 u_char *c = (u_char *) &cfblk; 3560 16, 1, &cfblk, sizeof(struct i82593_conf_block), false);
3561 int i;
3562 printk(KERN_DEBUG "wavelan_cs: config block:");
3563 for(i = 0; i < sizeof(struct i82593_conf_block); i++,c++)
3564 {
3565 if((i % 16) == 0) printk("\n" KERN_DEBUG);
3566 printk("%02x ", *c);
3567 }
3568 printk("\n");
3569 }
3570#endif 3561#endif
3571 3562
3572 /* Copy the config block to the i82593 */ 3563 /* Copy the config block to the i82593 */
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 14a19baff214..0e6e44689cc6 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -38,7 +38,6 @@ static struct usb_device_id usb_ids[] = {
38 /* ZD1211 */ 38 /* ZD1211 */
39 { USB_DEVICE(0x0ace, 0x1211), .driver_info = DEVICE_ZD1211 }, 39 { USB_DEVICE(0x0ace, 0x1211), .driver_info = DEVICE_ZD1211 },
40 { USB_DEVICE(0x0ace, 0xa211), .driver_info = DEVICE_ZD1211 }, 40 { USB_DEVICE(0x0ace, 0xa211), .driver_info = DEVICE_ZD1211 },
41 { USB_DEVICE(0x07b8, 0x6001), .driver_info = DEVICE_ZD1211 },
42 { USB_DEVICE(0x126f, 0xa006), .driver_info = DEVICE_ZD1211 }, 41 { USB_DEVICE(0x126f, 0xa006), .driver_info = DEVICE_ZD1211 },
43 { USB_DEVICE(0x6891, 0xa727), .driver_info = DEVICE_ZD1211 }, 42 { USB_DEVICE(0x6891, 0xa727), .driver_info = DEVICE_ZD1211 },
44 { USB_DEVICE(0x0df6, 0x9071), .driver_info = DEVICE_ZD1211 }, 43 { USB_DEVICE(0x0df6, 0x9071), .driver_info = DEVICE_ZD1211 },
@@ -61,6 +60,7 @@ static struct usb_device_id usb_ids[] = {
61 { USB_DEVICE(0x157e, 0x300a), .driver_info = DEVICE_ZD1211 }, 60 { USB_DEVICE(0x157e, 0x300a), .driver_info = DEVICE_ZD1211 },
62 { USB_DEVICE(0x0105, 0x145f), .driver_info = DEVICE_ZD1211 }, 61 { USB_DEVICE(0x0105, 0x145f), .driver_info = DEVICE_ZD1211 },
63 /* ZD1211B */ 62 /* ZD1211B */
63 { USB_DEVICE(0x054c, 0x0257), .driver_info = DEVICE_ZD1211B },
64 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B }, 64 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B },
65 { USB_DEVICE(0x0ace, 0xb215), .driver_info = DEVICE_ZD1211B }, 65 { USB_DEVICE(0x0ace, 0xb215), .driver_info = DEVICE_ZD1211B },
66 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B }, 66 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B },
@@ -87,6 +87,7 @@ static struct usb_device_id usb_ids[] = {
87 { USB_DEVICE(0x0471, 0x1237), .driver_info = DEVICE_ZD1211B }, 87 { USB_DEVICE(0x0471, 0x1237), .driver_info = DEVICE_ZD1211B },
88 { USB_DEVICE(0x07fa, 0x1196), .driver_info = DEVICE_ZD1211B }, 88 { USB_DEVICE(0x07fa, 0x1196), .driver_info = DEVICE_ZD1211B },
89 { USB_DEVICE(0x0df6, 0x0036), .driver_info = DEVICE_ZD1211B }, 89 { USB_DEVICE(0x0df6, 0x0036), .driver_info = DEVICE_ZD1211B },
90 { USB_DEVICE(0x07b8, 0x6001), .driver_info = DEVICE_ZD1211B },
90 /* "Driverless" devices that need ejecting */ 91 /* "Driverless" devices that need ejecting */
91 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, 92 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER },
92 { USB_DEVICE(0x0ace, 0x20ff), .driver_info = DEVICE_INSTALLER }, 93 { USB_DEVICE(0x0ace, 0x20ff), .driver_info = DEVICE_INSTALLER },
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index 3c7a5053f1da..a07580138e81 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -109,7 +109,7 @@ static int gx_fix;
109/* These identify the driver base version and may not be removed. */ 109/* These identify the driver base version and may not be removed. */
110static const char version[] __devinitconst = 110static const char version[] __devinitconst =
111 KERN_INFO DRV_NAME ".c:v1.05 1/09/2001 Written by Donald Becker <becker@scyld.com>\n" 111 KERN_INFO DRV_NAME ".c:v1.05 1/09/2001 Written by Donald Becker <becker@scyld.com>\n"
112 KERN_INFO " (unofficial 2.4.x port, " DRV_VERSION ", " DRV_RELDATE ")\n"; 112 " (unofficial 2.4.x port, " DRV_VERSION ", " DRV_RELDATE ")\n";
113 113
114MODULE_AUTHOR("Donald Becker <becker@scyld.com>"); 114MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
115MODULE_DESCRIPTION("Packet Engines Yellowfin G-NIC Gigabit Ethernet driver"); 115MODULE_DESCRIPTION("Packet Engines Yellowfin G-NIC Gigabit Ethernet driver");
@@ -700,12 +700,15 @@ static void yellowfin_tx_timeout(struct net_device *dev)
700 int i; 700 int i;
701 printk(KERN_WARNING " Rx ring %p: ", yp->rx_ring); 701 printk(KERN_WARNING " Rx ring %p: ", yp->rx_ring);
702 for (i = 0; i < RX_RING_SIZE; i++) 702 for (i = 0; i < RX_RING_SIZE; i++)
703 printk(" %8.8x", yp->rx_ring[i].result_status); 703 printk(KERN_CONT " %8.8x",
704 printk("\n"KERN_WARNING" Tx ring %p: ", yp->tx_ring); 704 yp->rx_ring[i].result_status);
705 printk(KERN_CONT "\n");
706 printk(KERN_WARNING" Tx ring %p: ", yp->tx_ring);
705 for (i = 0; i < TX_RING_SIZE; i++) 707 for (i = 0; i < TX_RING_SIZE; i++)
706 printk(" %4.4x /%8.8x", yp->tx_status[i].tx_errs, 708 printk(KERN_CONT " %4.4x /%8.8x",
707 yp->tx_ring[i].result_status); 709 yp->tx_status[i].tx_errs,
708 printk("\n"); 710 yp->tx_ring[i].result_status);
711 printk(KERN_CONT "\n");
709 } 712 }
710 713
711 /* If the hardware is found to hang regularly, we will update the code 714 /* If the hardware is found to hang regularly, we will update the code
@@ -1216,20 +1219,20 @@ static int yellowfin_close(struct net_device *dev)
1216 1219
1217#if defined(__i386__) 1220#if defined(__i386__)
1218 if (yellowfin_debug > 2) { 1221 if (yellowfin_debug > 2) {
1219 printk("\n"KERN_DEBUG" Tx ring at %8.8llx:\n", 1222 printk(KERN_DEBUG" Tx ring at %8.8llx:\n",
1220 (unsigned long long)yp->tx_ring_dma); 1223 (unsigned long long)yp->tx_ring_dma);
1221 for (i = 0; i < TX_RING_SIZE*2; i++) 1224 for (i = 0; i < TX_RING_SIZE*2; i++)
1222 printk(" %c #%d desc. %8.8x %8.8x %8.8x %8.8x.\n", 1225 printk(KERN_DEBUG " %c #%d desc. %8.8x %8.8x %8.8x %8.8x.\n",
1223 ioread32(ioaddr + TxPtr) == (long)&yp->tx_ring[i] ? '>' : ' ', 1226 ioread32(ioaddr + TxPtr) == (long)&yp->tx_ring[i] ? '>' : ' ',
1224 i, yp->tx_ring[i].dbdma_cmd, yp->tx_ring[i].addr, 1227 i, yp->tx_ring[i].dbdma_cmd, yp->tx_ring[i].addr,
1225 yp->tx_ring[i].branch_addr, yp->tx_ring[i].result_status); 1228 yp->tx_ring[i].branch_addr, yp->tx_ring[i].result_status);
1226 printk(KERN_DEBUG " Tx status %p:\n", yp->tx_status); 1229 printk(KERN_DEBUG " Tx status %p:\n", yp->tx_status);
1227 for (i = 0; i < TX_RING_SIZE; i++) 1230 for (i = 0; i < TX_RING_SIZE; i++)
1228 printk(" #%d status %4.4x %4.4x %4.4x %4.4x.\n", 1231 printk(KERN_DEBUG " #%d status %4.4x %4.4x %4.4x %4.4x.\n",
1229 i, yp->tx_status[i].tx_cnt, yp->tx_status[i].tx_errs, 1232 i, yp->tx_status[i].tx_cnt, yp->tx_status[i].tx_errs,
1230 yp->tx_status[i].total_tx_cnt, yp->tx_status[i].paused); 1233 yp->tx_status[i].total_tx_cnt, yp->tx_status[i].paused);
1231 1234
1232 printk("\n"KERN_DEBUG " Rx ring %8.8llx:\n", 1235 printk(KERN_DEBUG " Rx ring %8.8llx:\n",
1233 (unsigned long long)yp->rx_ring_dma); 1236 (unsigned long long)yp->rx_ring_dma);
1234 for (i = 0; i < RX_RING_SIZE; i++) { 1237 for (i = 0; i < RX_RING_SIZE; i++) {
1235 printk(KERN_DEBUG " %c #%d desc. %8.8x %8.8x %8.8x\n", 1238 printk(KERN_DEBUG " %c #%d desc. %8.8x %8.8x %8.8x\n",
diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
index e1f6ce03705e..3c2270a8300c 100644
--- a/drivers/oprofile/oprofile_stats.c
+++ b/drivers/oprofile/oprofile_stats.c
@@ -33,6 +33,7 @@ void oprofile_reset_stats(void)
33 atomic_set(&oprofile_stats.sample_lost_no_mm, 0); 33 atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
34 atomic_set(&oprofile_stats.sample_lost_no_mapping, 0); 34 atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
35 atomic_set(&oprofile_stats.event_lost_overflow, 0); 35 atomic_set(&oprofile_stats.event_lost_overflow, 0);
36 atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
36} 37}
37 38
38 39
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 5d610cbcfe80..0f0e0b919ef4 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -1134,7 +1134,7 @@ static const struct file_operations ccio_proc_bitmap_fops = {
1134 .llseek = seq_lseek, 1134 .llseek = seq_lseek,
1135 .release = single_release, 1135 .release = single_release,
1136}; 1136};
1137#endif 1137#endif /* CONFIG_PROC_FS */
1138 1138
1139/** 1139/**
1140 * ccio_find_ioc - Find the ioc in the ioc_list 1140 * ccio_find_ioc - Find the ioc in the ioc_list
@@ -1568,14 +1568,15 @@ static int __init ccio_probe(struct parisc_device *dev)
1568 /* if this fails, no I/O cards will work, so may as well bug */ 1568 /* if this fails, no I/O cards will work, so may as well bug */
1569 BUG_ON(dev->dev.platform_data == NULL); 1569 BUG_ON(dev->dev.platform_data == NULL);
1570 HBA_DATA(dev->dev.platform_data)->iommu = ioc; 1570 HBA_DATA(dev->dev.platform_data)->iommu = ioc;
1571 1571
1572#ifdef CONFIG_PROC_FS
1572 if (ioc_count == 0) { 1573 if (ioc_count == 0) {
1573 proc_create(MODULE_NAME, 0, proc_runway_root, 1574 proc_create(MODULE_NAME, 0, proc_runway_root,
1574 &ccio_proc_info_fops); 1575 &ccio_proc_info_fops);
1575 proc_create(MODULE_NAME"-bitmap", 0, proc_runway_root, 1576 proc_create(MODULE_NAME"-bitmap", 0, proc_runway_root,
1576 &ccio_proc_bitmap_fops); 1577 &ccio_proc_bitmap_fops);
1577 } 1578 }
1578 1579#endif
1579 ioc_count++; 1580 ioc_count++;
1580 1581
1581 parisc_has_iommu(); 1582 parisc_has_iommu();
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 52ae0b1d470c..c590974e9815 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -353,7 +353,7 @@ static unsigned int dino_startup_irq(unsigned int irq)
353 return 0; 353 return 0;
354} 354}
355 355
356static struct hw_interrupt_type dino_interrupt_type = { 356static struct irq_chip dino_interrupt_type = {
357 .typename = "GSC-PCI", 357 .typename = "GSC-PCI",
358 .startup = dino_startup_irq, 358 .startup = dino_startup_irq,
359 .shutdown = dino_disable_irq, 359 .shutdown = dino_disable_irq,
@@ -1019,22 +1019,22 @@ static int __init dino_probe(struct parisc_device *dev)
1019 ** It's not used to avoid chicken/egg problems 1019 ** It's not used to avoid chicken/egg problems
1020 ** with configuration accessor functions. 1020 ** with configuration accessor functions.
1021 */ 1021 */
1022 bus = pci_scan_bus_parented(&dev->dev, dino_current_bus, 1022 dino_dev->hba.hba_bus = bus = pci_scan_bus_parented(&dev->dev,
1023 &dino_cfg_ops, NULL); 1023 dino_current_bus, &dino_cfg_ops, NULL);
1024
1024 if(bus) { 1025 if(bus) {
1025 pci_bus_add_devices(bus);
1026 /* This code *depends* on scanning being single threaded 1026 /* This code *depends* on scanning being single threaded
1027 * if it isn't, this global bus number count will fail 1027 * if it isn't, this global bus number count will fail
1028 */ 1028 */
1029 dino_current_bus = bus->subordinate + 1; 1029 dino_current_bus = bus->subordinate + 1;
1030 pci_bus_assign_resources(bus); 1030 pci_bus_assign_resources(bus);
1031 pci_bus_add_devices(bus);
1031 } else { 1032 } else {
1032 printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (probably duplicate bus number %d)\n", 1033 printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
1033 dev_name(&dev->dev), dino_current_bus); 1034 dev_name(&dev->dev), dino_current_bus);
1034 /* increment the bus number in case of duplicates */ 1035 /* increment the bus number in case of duplicates */
1035 dino_current_bus++; 1036 dino_current_bus++;
1036 } 1037 }
1037 dino_dev->hba.hba_bus = bus;
1038 return 0; 1038 return 0;
1039} 1039}
1040 1040
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c
index 5b89f404e668..51220749cb65 100644
--- a/drivers/parisc/eisa.c
+++ b/drivers/parisc/eisa.c
@@ -188,7 +188,7 @@ static unsigned int eisa_startup_irq(unsigned int irq)
188 return 0; 188 return 0;
189} 189}
190 190
191static struct hw_interrupt_type eisa_interrupt_type = { 191static struct irq_chip eisa_interrupt_type = {
192 .typename = "EISA", 192 .typename = "EISA",
193 .startup = eisa_startup_irq, 193 .startup = eisa_startup_irq,
194 .shutdown = eisa_disable_irq, 194 .shutdown = eisa_disable_irq,
diff --git a/drivers/parisc/eisa_enumerator.c b/drivers/parisc/eisa_enumerator.c
index c709ecc2b7f7..0be1d50645ab 100644
--- a/drivers/parisc/eisa_enumerator.c
+++ b/drivers/parisc/eisa_enumerator.c
@@ -101,7 +101,7 @@ static int configure_memory(const unsigned char *buf,
101 printk("memory %lx-%lx ", (unsigned long)res->start, (unsigned long)res->end); 101 printk("memory %lx-%lx ", (unsigned long)res->start, (unsigned long)res->end);
102 result = request_resource(mem_parent, res); 102 result = request_resource(mem_parent, res);
103 if (result < 0) { 103 if (result < 0) {
104 printk("\n" KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n"); 104 printk(KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n");
105 return result; 105 return result;
106 } 106 }
107 } 107 }
@@ -191,7 +191,7 @@ static int configure_port(const unsigned char *buf, struct resource *io_parent,
191 printk("ioports %lx-%lx ", (unsigned long)res->start, (unsigned long)res->end); 191 printk("ioports %lx-%lx ", (unsigned long)res->start, (unsigned long)res->end);
192 result = request_resource(io_parent, res); 192 result = request_resource(io_parent, res);
193 if (result < 0) { 193 if (result < 0) {
194 printk("\n" KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n"); 194 printk(KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n");
195 return result; 195 return result;
196 } 196 }
197 } 197 }
@@ -224,7 +224,7 @@ static int configure_port_init(const unsigned char *buf)
224 case HPEE_PORT_INIT_WIDTH_BYTE: 224 case HPEE_PORT_INIT_WIDTH_BYTE:
225 s=1; 225 s=1;
226 if (c & HPEE_PORT_INIT_MASK) { 226 if (c & HPEE_PORT_INIT_MASK) {
227 printk("\n" KERN_WARNING "port_init: unverified mask attribute\n"); 227 printk(KERN_WARNING "port_init: unverified mask attribute\n");
228 outb((inb(get_16(buf+len+1) & 228 outb((inb(get_16(buf+len+1) &
229 get_8(buf+len+3)) | 229 get_8(buf+len+3)) |
230 get_8(buf+len+4)), get_16(buf+len+1)); 230 get_8(buf+len+4)), get_16(buf+len+1));
@@ -249,7 +249,7 @@ static int configure_port_init(const unsigned char *buf)
249 case HPEE_PORT_INIT_WIDTH_DWORD: 249 case HPEE_PORT_INIT_WIDTH_DWORD:
250 s=4; 250 s=4;
251 if (c & HPEE_PORT_INIT_MASK) { 251 if (c & HPEE_PORT_INIT_MASK) {
252 printk("\n" KERN_WARNING "port_init: unverified mask attribute\n"); 252 printk(KERN_WARNING "port_init: unverified mask attribute\n");
253 outl((inl(get_16(buf+len+1) & 253 outl((inl(get_16(buf+len+1) &
254 get_32(buf+len+3)) | 254 get_32(buf+len+3)) |
255 get_32(buf+len+7)), get_16(buf+len+1)); 255 get_32(buf+len+7)), get_16(buf+len+1));
@@ -259,7 +259,7 @@ static int configure_port_init(const unsigned char *buf)
259 259
260 break; 260 break;
261 default: 261 default:
262 printk("\n" KERN_ERR "Invalid port init word %02x\n", c); 262 printk(KERN_ERR "Invalid port init word %02x\n", c);
263 return 0; 263 return 0;
264 } 264 }
265 265
@@ -297,7 +297,7 @@ static int configure_type_string(const unsigned char *buf)
297 /* just skip past the type field */ 297 /* just skip past the type field */
298 len = get_8(buf); 298 len = get_8(buf);
299 if (len > 80) { 299 if (len > 80) {
300 printk("\n" KERN_ERR "eisa_enumerator: type info field too long (%d, max is 80)\n", len); 300 printk(KERN_ERR "eisa_enumerator: type info field too long (%d, max is 80)\n", len);
301 } 301 }
302 302
303 return 1+len; 303 return 1+len;
@@ -398,7 +398,7 @@ static int parse_slot_config(int slot,
398 } 398 }
399 399
400 if (p0 + function_len < pos) { 400 if (p0 + function_len < pos) {
401 printk("\n" KERN_ERR "eisa_enumerator: function %d length mis-match " 401 printk(KERN_ERR "eisa_enumerator: function %d length mis-match "
402 "got %d, expected %d\n", 402 "got %d, expected %d\n",
403 num_func, pos-p0, function_len); 403 num_func, pos-p0, function_len);
404 res=-1; 404 res=-1;
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c
index d33632917696..647adc9f85ad 100644
--- a/drivers/parisc/gsc.c
+++ b/drivers/parisc/gsc.c
@@ -148,7 +148,7 @@ static unsigned int gsc_asic_startup_irq(unsigned int irq)
148 return 0; 148 return 0;
149} 149}
150 150
151static struct hw_interrupt_type gsc_asic_interrupt_type = { 151static struct irq_chip gsc_asic_interrupt_type = {
152 .typename = "GSC-ASIC", 152 .typename = "GSC-ASIC",
153 .startup = gsc_asic_startup_irq, 153 .startup = gsc_asic_startup_irq,
154 .shutdown = gsc_asic_disable_irq, 154 .shutdown = gsc_asic_disable_irq,
@@ -158,7 +158,7 @@ static struct hw_interrupt_type gsc_asic_interrupt_type = {
158 .end = no_end_irq, 158 .end = no_end_irq,
159}; 159};
160 160
161int gsc_assign_irq(struct hw_interrupt_type *type, void *data) 161int gsc_assign_irq(struct irq_chip *type, void *data)
162{ 162{
163 static int irq = GSC_IRQ_BASE; 163 static int irq = GSC_IRQ_BASE;
164 struct irq_desc *desc; 164 struct irq_desc *desc;
diff --git a/drivers/parisc/gsc.h b/drivers/parisc/gsc.h
index 762a1babad60..b9d7bfb68e24 100644
--- a/drivers/parisc/gsc.h
+++ b/drivers/parisc/gsc.h
@@ -38,7 +38,7 @@ struct gsc_asic {
38int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic); 38int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic);
39int gsc_alloc_irq(struct gsc_irq *dev); /* dev needs an irq */ 39int gsc_alloc_irq(struct gsc_irq *dev); /* dev needs an irq */
40int gsc_claim_irq(struct gsc_irq *dev, int irq); /* dev needs this irq */ 40int gsc_claim_irq(struct gsc_irq *dev, int irq); /* dev needs this irq */
41int gsc_assign_irq(struct hw_interrupt_type *type, void *data); 41int gsc_assign_irq(struct irq_chip *type, void *data);
42int gsc_find_local_irq(unsigned int irq, int *global_irq, int limit); 42int gsc_find_local_irq(unsigned int irq, int *global_irq, int limit);
43void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl, 43void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl,
44 void (*choose)(struct parisc_device *child, void *ctrl)); 44 void (*choose)(struct parisc_device *child, void *ctrl));
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 4a9cc92d4d18..88e333553212 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -729,7 +729,7 @@ static int iosapic_set_affinity_irq(unsigned int irq,
729} 729}
730#endif 730#endif
731 731
732static struct hw_interrupt_type iosapic_interrupt_type = { 732static struct irq_chip iosapic_interrupt_type = {
733 .typename = "IO-SAPIC-level", 733 .typename = "IO-SAPIC-level",
734 .startup = iosapic_startup_irq, 734 .startup = iosapic_startup_irq,
735 .shutdown = iosapic_disable_irq, 735 .shutdown = iosapic_disable_irq,
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 59fbbf128365..ede614616f8e 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -980,28 +980,38 @@ static void
980lba_pat_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev) 980lba_pat_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev)
981{ 981{
982 unsigned long bytecnt; 982 unsigned long bytecnt;
983 pdc_pat_cell_mod_maddr_block_t pa_pdc_cell; /* PA_VIEW */
984 pdc_pat_cell_mod_maddr_block_t io_pdc_cell; /* IO_VIEW */
985 long io_count; 983 long io_count;
986 long status; /* PDC return status */ 984 long status; /* PDC return status */
987 long pa_count; 985 long pa_count;
986 pdc_pat_cell_mod_maddr_block_t *pa_pdc_cell; /* PA_VIEW */
987 pdc_pat_cell_mod_maddr_block_t *io_pdc_cell; /* IO_VIEW */
988 int i; 988 int i;
989 989
990 pa_pdc_cell = kzalloc(sizeof(pdc_pat_cell_mod_maddr_block_t), GFP_KERNEL);
991 if (!pa_pdc_cell)
992 return;
993
994 io_pdc_cell = kzalloc(sizeof(pdc_pat_cell_mod_maddr_block_t), GFP_KERNEL);
995 if (!pa_pdc_cell) {
996 kfree(pa_pdc_cell);
997 return;
998 }
999
990 /* return cell module (IO view) */ 1000 /* return cell module (IO view) */
991 status = pdc_pat_cell_module(&bytecnt, pa_dev->pcell_loc, pa_dev->mod_index, 1001 status = pdc_pat_cell_module(&bytecnt, pa_dev->pcell_loc, pa_dev->mod_index,
992 PA_VIEW, & pa_pdc_cell); 1002 PA_VIEW, pa_pdc_cell);
993 pa_count = pa_pdc_cell.mod[1]; 1003 pa_count = pa_pdc_cell->mod[1];
994 1004
995 status |= pdc_pat_cell_module(&bytecnt, pa_dev->pcell_loc, pa_dev->mod_index, 1005 status |= pdc_pat_cell_module(&bytecnt, pa_dev->pcell_loc, pa_dev->mod_index,
996 IO_VIEW, &io_pdc_cell); 1006 IO_VIEW, io_pdc_cell);
997 io_count = io_pdc_cell.mod[1]; 1007 io_count = io_pdc_cell->mod[1];
998 1008
999 /* We've already done this once for device discovery...*/ 1009 /* We've already done this once for device discovery...*/
1000 if (status != PDC_OK) { 1010 if (status != PDC_OK) {
1001 panic("pdc_pat_cell_module() call failed for LBA!\n"); 1011 panic("pdc_pat_cell_module() call failed for LBA!\n");
1002 } 1012 }
1003 1013
1004 if (PAT_GET_ENTITY(pa_pdc_cell.mod_info) != PAT_ENTITY_LBA) { 1014 if (PAT_GET_ENTITY(pa_pdc_cell->mod_info) != PAT_ENTITY_LBA) {
1005 panic("pdc_pat_cell_module() entity returned != PAT_ENTITY_LBA!\n"); 1015 panic("pdc_pat_cell_module() entity returned != PAT_ENTITY_LBA!\n");
1006 } 1016 }
1007 1017
@@ -1016,8 +1026,8 @@ lba_pat_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev)
1016 } *p, *io; 1026 } *p, *io;
1017 struct resource *r; 1027 struct resource *r;
1018 1028
1019 p = (void *) &(pa_pdc_cell.mod[2+i*3]); 1029 p = (void *) &(pa_pdc_cell->mod[2+i*3]);
1020 io = (void *) &(io_pdc_cell.mod[2+i*3]); 1030 io = (void *) &(io_pdc_cell->mod[2+i*3]);
1021 1031
1022 /* Convert the PAT range data to PCI "struct resource" */ 1032 /* Convert the PAT range data to PCI "struct resource" */
1023 switch(p->type & 0xff) { 1033 switch(p->type & 0xff) {
@@ -1096,6 +1106,9 @@ lba_pat_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev)
1096 break; 1106 break;
1097 } 1107 }
1098 } 1108 }
1109
1110 kfree(pa_pdc_cell);
1111 kfree(io_pdc_cell);
1099} 1112}
1100#else 1113#else
1101/* keep compiler from complaining about missing declarations */ 1114/* keep compiler from complaining about missing declarations */
@@ -1509,10 +1522,6 @@ lba_driver_probe(struct parisc_device *dev)
1509 lba_bus = lba_dev->hba.hba_bus = 1522 lba_bus = lba_dev->hba.hba_bus =
1510 pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start, 1523 pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start,
1511 cfg_ops, NULL); 1524 cfg_ops, NULL);
1512 if (lba_bus) {
1513 lba_next_bus = lba_bus->subordinate + 1;
1514 pci_bus_add_devices(lba_bus);
1515 }
1516 1525
1517 /* This is in lieu of calling pci_assign_unassigned_resources() */ 1526 /* This is in lieu of calling pci_assign_unassigned_resources() */
1518 if (is_pdc_pat()) { 1527 if (is_pdc_pat()) {
@@ -1533,7 +1542,6 @@ lba_driver_probe(struct parisc_device *dev)
1533 } 1542 }
1534 pci_enable_bridges(lba_bus); 1543 pci_enable_bridges(lba_bus);
1535 1544
1536
1537 /* 1545 /*
1538 ** Once PCI register ops has walked the bus, access to config 1546 ** Once PCI register ops has walked the bus, access to config
1539 ** space is restricted. Avoids master aborts on config cycles. 1547 ** space is restricted. Avoids master aborts on config cycles.
@@ -1543,6 +1551,11 @@ lba_driver_probe(struct parisc_device *dev)
1543 lba_dev->flags |= LBA_FLAG_SKIP_PROBE; 1551 lba_dev->flags |= LBA_FLAG_SKIP_PROBE;
1544 } 1552 }
1545 1553
1554 if (lba_bus) {
1555 lba_next_bus = lba_bus->subordinate + 1;
1556 pci_bus_add_devices(lba_bus);
1557 }
1558
1546 /* Whew! Finally done! Tell services we got this one covered. */ 1559 /* Whew! Finally done! Tell services we got this one covered. */
1547 return 0; 1560 return 0;
1548} 1561}
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index d46dd57450ac..123d8fe3427d 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -2057,6 +2057,7 @@ void sba_directed_lmmio(struct parisc_device *pci_hba, struct resource *r)
2057 r->start = (base & ~1UL) | PCI_F_EXTEND; 2057 r->start = (base & ~1UL) | PCI_F_EXTEND;
2058 size = ~ READ_REG32(reg + LMMIO_DIRECT0_MASK); 2058 size = ~ READ_REG32(reg + LMMIO_DIRECT0_MASK);
2059 r->end = r->start + size; 2059 r->end = r->start + size;
2060 r->flags = IORESOURCE_MEM;
2060 } 2061 }
2061} 2062}
2062 2063
@@ -2093,4 +2094,5 @@ void sba_distributed_lmmio(struct parisc_device *pci_hba, struct resource *r )
2093 size = (~READ_REG32(sba->sba_hpa + LMMIO_DIST_MASK)) / ROPES_PER_IOC; 2094 size = (~READ_REG32(sba->sba_hpa + LMMIO_DIST_MASK)) / ROPES_PER_IOC;
2094 r->start += rope * (size + 1); /* adjust base for this rope */ 2095 r->start += rope * (size + 1); /* adjust base for this rope */
2095 r->end = r->start + size; 2096 r->end = r->start + size;
2097 r->flags = IORESOURCE_MEM;
2096} 2098}
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index 33e5ade774ca..675f04e6597a 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -325,7 +325,7 @@ static unsigned int superio_startup_irq(unsigned int irq)
325 return 0; 325 return 0;
326} 326}
327 327
328static struct hw_interrupt_type superio_interrupt_type = { 328static struct irq_chip superio_interrupt_type = {
329 .typename = SUPERIO, 329 .typename = SUPERIO,
330 .startup = superio_startup_irq, 330 .startup = superio_startup_irq,
331 .shutdown = superio_disable_irq, 331 .shutdown = superio_disable_irq,
@@ -434,8 +434,8 @@ static void __init superio_parport_init(void)
434 0 /*base_hi*/, 434 0 /*base_hi*/,
435 PAR_IRQ, 435 PAR_IRQ,
436 PARPORT_DMA_NONE /* dma */, 436 PARPORT_DMA_NONE /* dma */,
437 NULL /*struct pci_dev* */), 437 NULL /*struct pci_dev* */,
438 0 /* shared irq flags */ ) 438 0 /* shared irq flags */))
439 439
440 printk(KERN_WARNING PFX "Probing parallel port failed.\n"); 440 printk(KERN_WARNING PFX "Probing parallel port failed.\n");
441#endif /* CONFIG_PARPORT_PC */ 441#endif /* CONFIG_PARPORT_PC */
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 1032d5fdbd42..2597145a066e 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -2907,6 +2907,7 @@ enum parport_pc_pci_cards {
2907 netmos_9755, 2907 netmos_9755,
2908 netmos_9805, 2908 netmos_9805,
2909 netmos_9815, 2909 netmos_9815,
2910 netmos_9901,
2910 quatech_sppxp100, 2911 quatech_sppxp100,
2911}; 2912};
2912 2913
@@ -2987,7 +2988,7 @@ static struct parport_pc_pci {
2987 /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} }, 2988 /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} },
2988 /* netmos_9805 */ { 1, { { 0, -1 }, } }, 2989 /* netmos_9805 */ { 1, { { 0, -1 }, } },
2989 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, 2990 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } },
2990 2991 /* netmos_9901 */ { 1, { { 0, -1 }, } },
2991 /* quatech_sppxp100 */ { 1, { { 0, 1 }, } }, 2992 /* quatech_sppxp100 */ { 1, { { 0, 1 }, } },
2992}; 2993};
2993 2994
@@ -3089,6 +3090,8 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
3089 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9805 }, 3090 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9805 },
3090 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9815, 3091 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9815,
3091 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9815 }, 3092 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9815 },
3093 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9901,
3094 0xA000, 0x2000, 0, 0, netmos_9901 },
3092 /* Quatech SPPXP-100 Parallel port PCI ExpressCard */ 3095 /* Quatech SPPXP-100 Parallel port PCI ExpressCard */
3093 { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SPPXP_100, 3096 { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SPPXP_100,
3094 PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 }, 3097 PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 },
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index a5b9f6ae507b..d703e73fffa7 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -32,7 +32,6 @@
32#include <linux/pci_hotplug.h> 32#include <linux/pci_hotplug.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/smp_lock.h>
36#include <asm/atomic.h> 35#include <asm/atomic.h>
37#include <linux/delay.h> 36#include <linux/delay.h>
38#include <linux/kthread.h> 37#include <linux/kthread.h>
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index 2fa47af992a8..0ff689afa757 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -34,7 +34,6 @@
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/wait.h> 36#include <linux/wait.h>
37#include <linux/smp_lock.h>
38#include <linux/pci.h> 37#include <linux/pci.h>
39#include <linux/pci_hotplug.h> 38#include <linux/pci_hotplug.h>
40#include <linux/kthread.h> 39#include <linux/kthread.h>
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index 8450f4a6568a..e6089bdb6e5b 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -33,6 +33,7 @@
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/pci_hotplug.h> 35#include <linux/pci_hotplug.h>
36#include <linux/smp_lock.h>
36#include <linux/debugfs.h> 37#include <linux/debugfs.h>
37#include "cpqphp.h" 38#include "cpqphp.h"
38 39
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 844580489d4d..5c5043f239cf 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -555,6 +555,8 @@ static struct hotplug_slot *get_slot_from_name (const char *name)
555 * @slot: pointer to the &struct hotplug_slot to register 555 * @slot: pointer to the &struct hotplug_slot to register
556 * @devnr: device number 556 * @devnr: device number
557 * @name: name registered with kobject core 557 * @name: name registered with kobject core
558 * @owner: caller module owner
559 * @mod_name: caller module name
558 * 560 *
559 * Registers a hotplug slot with the pci hotplug subsystem, which will allow 561 * Registers a hotplug slot with the pci hotplug subsystem, which will allow
560 * userspace interaction to the slot. 562 * userspace interaction to the slot.
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index ff4034502d24..8aab8edf123e 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -30,7 +30,6 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/smp_lock.h>
34#include <linux/pci.h> 33#include <linux/pci.h>
35#include <linux/workqueue.h> 34#include <linux/workqueue.h>
36#include "../pci.h" 35#include "../pci.h"
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index e53eacd75c8d..ebc9b8dca881 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -39,7 +39,6 @@
39#include <linux/sysdev.h> 39#include <linux/sysdev.h>
40#include <asm/cacheflush.h> 40#include <asm/cacheflush.h>
41#include <asm/iommu.h> 41#include <asm/iommu.h>
42#include <asm/e820.h>
43#include "pci.h" 42#include "pci.h"
44 43
45#define ROOT_SIZE VTD_PAGE_SIZE 44#define ROOT_SIZE VTD_PAGE_SIZE
@@ -57,14 +56,32 @@
57#define MAX_AGAW_WIDTH 64 56#define MAX_AGAW_WIDTH 64
58 57
59#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) 58#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1)
59#define DOMAIN_MAX_PFN(gaw) ((((u64)1) << (gaw-VTD_PAGE_SHIFT)) - 1)
60 60
61#define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT) 61#define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT)
62#define DMA_32BIT_PFN IOVA_PFN(DMA_BIT_MASK(32)) 62#define DMA_32BIT_PFN IOVA_PFN(DMA_BIT_MASK(32))
63#define DMA_64BIT_PFN IOVA_PFN(DMA_BIT_MASK(64)) 63#define DMA_64BIT_PFN IOVA_PFN(DMA_BIT_MASK(64))
64 64
65#ifndef PHYSICAL_PAGE_MASK 65
66#define PHYSICAL_PAGE_MASK PAGE_MASK 66/* VT-d pages must always be _smaller_ than MM pages. Otherwise things
67#endif 67 are never going to work. */
68static inline unsigned long dma_to_mm_pfn(unsigned long dma_pfn)
69{
70 return dma_pfn >> (PAGE_SHIFT - VTD_PAGE_SHIFT);
71}
72
73static inline unsigned long mm_to_dma_pfn(unsigned long mm_pfn)
74{
75 return mm_pfn << (PAGE_SHIFT - VTD_PAGE_SHIFT);
76}
77static inline unsigned long page_to_dma_pfn(struct page *pg)
78{
79 return mm_to_dma_pfn(page_to_pfn(pg));
80}
81static inline unsigned long virt_to_dma_pfn(void *p)
82{
83 return page_to_dma_pfn(virt_to_page(p));
84}
68 85
69/* global iommu list, set NULL for ignored DMAR units */ 86/* global iommu list, set NULL for ignored DMAR units */
70static struct intel_iommu **g_iommus; 87static struct intel_iommu **g_iommus;
@@ -205,12 +222,17 @@ static inline void dma_set_pte_prot(struct dma_pte *pte, unsigned long prot)
205 222
206static inline u64 dma_pte_addr(struct dma_pte *pte) 223static inline u64 dma_pte_addr(struct dma_pte *pte)
207{ 224{
208 return (pte->val & VTD_PAGE_MASK); 225#ifdef CONFIG_64BIT
226 return pte->val & VTD_PAGE_MASK;
227#else
228 /* Must have a full atomic 64-bit read */
229 return __cmpxchg64(pte, 0ULL, 0ULL) & VTD_PAGE_MASK;
230#endif
209} 231}
210 232
211static inline void dma_set_pte_addr(struct dma_pte *pte, u64 addr) 233static inline void dma_set_pte_pfn(struct dma_pte *pte, unsigned long pfn)
212{ 234{
213 pte->val |= (addr & VTD_PAGE_MASK); 235 pte->val |= (uint64_t)pfn << VTD_PAGE_SHIFT;
214} 236}
215 237
216static inline bool dma_pte_present(struct dma_pte *pte) 238static inline bool dma_pte_present(struct dma_pte *pte)
@@ -218,6 +240,11 @@ static inline bool dma_pte_present(struct dma_pte *pte)
218 return (pte->val & 3) != 0; 240 return (pte->val & 3) != 0;
219} 241}
220 242
243static inline int first_pte_in_page(struct dma_pte *pte)
244{
245 return !((unsigned long)pte & ~VTD_PAGE_MASK);
246}
247
221/* 248/*
222 * This domain is a statically identity mapping domain. 249 * This domain is a statically identity mapping domain.
223 * 1. This domain creats a static 1:1 mapping to all usable memory. 250 * 1. This domain creats a static 1:1 mapping to all usable memory.
@@ -245,7 +272,6 @@ struct dmar_domain {
245 struct iova_domain iovad; /* iova's that belong to this domain */ 272 struct iova_domain iovad; /* iova's that belong to this domain */
246 273
247 struct dma_pte *pgd; /* virtual address */ 274 struct dma_pte *pgd; /* virtual address */
248 spinlock_t mapping_lock; /* page table lock */
249 int gaw; /* max guest address width */ 275 int gaw; /* max guest address width */
250 276
251 /* adjusted guest address width, 0 is level 2 30-bit */ 277 /* adjusted guest address width, 0 is level 2 30-bit */
@@ -649,80 +675,78 @@ static inline int width_to_agaw(int width)
649 675
650static inline unsigned int level_to_offset_bits(int level) 676static inline unsigned int level_to_offset_bits(int level)
651{ 677{
652 return (12 + (level - 1) * LEVEL_STRIDE); 678 return (level - 1) * LEVEL_STRIDE;
653} 679}
654 680
655static inline int address_level_offset(u64 addr, int level) 681static inline int pfn_level_offset(unsigned long pfn, int level)
656{ 682{
657 return ((addr >> level_to_offset_bits(level)) & LEVEL_MASK); 683 return (pfn >> level_to_offset_bits(level)) & LEVEL_MASK;
658} 684}
659 685
660static inline u64 level_mask(int level) 686static inline unsigned long level_mask(int level)
661{ 687{
662 return ((u64)-1 << level_to_offset_bits(level)); 688 return -1UL << level_to_offset_bits(level);
663} 689}
664 690
665static inline u64 level_size(int level) 691static inline unsigned long level_size(int level)
666{ 692{
667 return ((u64)1 << level_to_offset_bits(level)); 693 return 1UL << level_to_offset_bits(level);
668} 694}
669 695
670static inline u64 align_to_level(u64 addr, int level) 696static inline unsigned long align_to_level(unsigned long pfn, int level)
671{ 697{
672 return ((addr + level_size(level) - 1) & level_mask(level)); 698 return (pfn + level_size(level) - 1) & level_mask(level);
673} 699}
674 700
675static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr) 701static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
702 unsigned long pfn)
676{ 703{
677 int addr_width = agaw_to_width(domain->agaw); 704 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
678 struct dma_pte *parent, *pte = NULL; 705 struct dma_pte *parent, *pte = NULL;
679 int level = agaw_to_level(domain->agaw); 706 int level = agaw_to_level(domain->agaw);
680 int offset; 707 int offset;
681 unsigned long flags;
682 708
683 BUG_ON(!domain->pgd); 709 BUG_ON(!domain->pgd);
684 710 BUG_ON(addr_width < BITS_PER_LONG && pfn >> addr_width);
685 addr &= (((u64)1) << addr_width) - 1;
686 parent = domain->pgd; 711 parent = domain->pgd;
687 712
688 spin_lock_irqsave(&domain->mapping_lock, flags);
689 while (level > 0) { 713 while (level > 0) {
690 void *tmp_page; 714 void *tmp_page;
691 715
692 offset = address_level_offset(addr, level); 716 offset = pfn_level_offset(pfn, level);
693 pte = &parent[offset]; 717 pte = &parent[offset];
694 if (level == 1) 718 if (level == 1)
695 break; 719 break;
696 720
697 if (!dma_pte_present(pte)) { 721 if (!dma_pte_present(pte)) {
722 uint64_t pteval;
723
698 tmp_page = alloc_pgtable_page(); 724 tmp_page = alloc_pgtable_page();
699 725
700 if (!tmp_page) { 726 if (!tmp_page)
701 spin_unlock_irqrestore(&domain->mapping_lock,
702 flags);
703 return NULL; 727 return NULL;
728
729 domain_flush_cache(domain, tmp_page, VTD_PAGE_SIZE);
730 pteval = (virt_to_dma_pfn(tmp_page) << VTD_PAGE_SHIFT) | DMA_PTE_READ | DMA_PTE_WRITE;
731 if (cmpxchg64(&pte->val, 0ULL, pteval)) {
732 /* Someone else set it while we were thinking; use theirs. */
733 free_pgtable_page(tmp_page);
734 } else {
735 dma_pte_addr(pte);
736 domain_flush_cache(domain, pte, sizeof(*pte));
704 } 737 }
705 domain_flush_cache(domain, tmp_page, PAGE_SIZE);
706 dma_set_pte_addr(pte, virt_to_phys(tmp_page));
707 /*
708 * high level table always sets r/w, last level page
709 * table control read/write
710 */
711 dma_set_pte_readable(pte);
712 dma_set_pte_writable(pte);
713 domain_flush_cache(domain, pte, sizeof(*pte));
714 } 738 }
715 parent = phys_to_virt(dma_pte_addr(pte)); 739 parent = phys_to_virt(dma_pte_addr(pte));
716 level--; 740 level--;
717 } 741 }
718 742
719 spin_unlock_irqrestore(&domain->mapping_lock, flags);
720 return pte; 743 return pte;
721} 744}
722 745
723/* return address's pte at specific level */ 746/* return address's pte at specific level */
724static struct dma_pte *dma_addr_level_pte(struct dmar_domain *domain, u64 addr, 747static struct dma_pte *dma_pfn_level_pte(struct dmar_domain *domain,
725 int level) 748 unsigned long pfn,
749 int level)
726{ 750{
727 struct dma_pte *parent, *pte = NULL; 751 struct dma_pte *parent, *pte = NULL;
728 int total = agaw_to_level(domain->agaw); 752 int total = agaw_to_level(domain->agaw);
@@ -730,7 +754,7 @@ static struct dma_pte *dma_addr_level_pte(struct dmar_domain *domain, u64 addr,
730 754
731 parent = domain->pgd; 755 parent = domain->pgd;
732 while (level <= total) { 756 while (level <= total) {
733 offset = address_level_offset(addr, total); 757 offset = pfn_level_offset(pfn, total);
734 pte = &parent[offset]; 758 pte = &parent[offset];
735 if (level == total) 759 if (level == total)
736 return pte; 760 return pte;
@@ -743,74 +767,82 @@ static struct dma_pte *dma_addr_level_pte(struct dmar_domain *domain, u64 addr,
743 return NULL; 767 return NULL;
744} 768}
745 769
746/* clear one page's page table */
747static void dma_pte_clear_one(struct dmar_domain *domain, u64 addr)
748{
749 struct dma_pte *pte = NULL;
750
751 /* get last level pte */
752 pte = dma_addr_level_pte(domain, addr, 1);
753
754 if (pte) {
755 dma_clear_pte(pte);
756 domain_flush_cache(domain, pte, sizeof(*pte));
757 }
758}
759
760/* clear last level pte, a tlb flush should be followed */ 770/* clear last level pte, a tlb flush should be followed */
761static void dma_pte_clear_range(struct dmar_domain *domain, u64 start, u64 end) 771static void dma_pte_clear_range(struct dmar_domain *domain,
772 unsigned long start_pfn,
773 unsigned long last_pfn)
762{ 774{
763 int addr_width = agaw_to_width(domain->agaw); 775 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
764 int npages; 776 struct dma_pte *first_pte, *pte;
765 777
766 start &= (((u64)1) << addr_width) - 1; 778 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width);
767 end &= (((u64)1) << addr_width) - 1; 779 BUG_ON(addr_width < BITS_PER_LONG && last_pfn >> addr_width);
768 /* in case it's partial page */
769 start &= PAGE_MASK;
770 end = PAGE_ALIGN(end);
771 npages = (end - start) / VTD_PAGE_SIZE;
772 780
773 /* we don't need lock here, nobody else touches the iova range */ 781 /* we don't need lock here; nobody else touches the iova range */
774 while (npages--) { 782 while (start_pfn <= last_pfn) {
775 dma_pte_clear_one(domain, start); 783 first_pte = pte = dma_pfn_level_pte(domain, start_pfn, 1);
776 start += VTD_PAGE_SIZE; 784 if (!pte) {
785 start_pfn = align_to_level(start_pfn + 1, 2);
786 continue;
787 }
788 do {
789 dma_clear_pte(pte);
790 start_pfn++;
791 pte++;
792 } while (start_pfn <= last_pfn && !first_pte_in_page(pte));
793
794 domain_flush_cache(domain, first_pte,
795 (void *)pte - (void *)first_pte);
777 } 796 }
778} 797}
779 798
780/* free page table pages. last level pte should already be cleared */ 799/* free page table pages. last level pte should already be cleared */
781static void dma_pte_free_pagetable(struct dmar_domain *domain, 800static void dma_pte_free_pagetable(struct dmar_domain *domain,
782 u64 start, u64 end) 801 unsigned long start_pfn,
802 unsigned long last_pfn)
783{ 803{
784 int addr_width = agaw_to_width(domain->agaw); 804 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
785 struct dma_pte *pte; 805 struct dma_pte *first_pte, *pte;
786 int total = agaw_to_level(domain->agaw); 806 int total = agaw_to_level(domain->agaw);
787 int level; 807 int level;
788 u64 tmp; 808 unsigned long tmp;
789 809
790 start &= (((u64)1) << addr_width) - 1; 810 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width);
791 end &= (((u64)1) << addr_width) - 1; 811 BUG_ON(addr_width < BITS_PER_LONG && last_pfn >> addr_width);
792 812
793 /* we don't need lock here, nobody else touches the iova range */ 813 /* We don't need lock here; nobody else touches the iova range */
794 level = 2; 814 level = 2;
795 while (level <= total) { 815 while (level <= total) {
796 tmp = align_to_level(start, level); 816 tmp = align_to_level(start_pfn, level);
797 if (tmp >= end || (tmp + level_size(level) > end)) 817
818 /* If we can't even clear one PTE at this level, we're done */
819 if (tmp + level_size(level) - 1 > last_pfn)
798 return; 820 return;
799 821
800 while (tmp < end) { 822 while (tmp + level_size(level) - 1 <= last_pfn) {
801 pte = dma_addr_level_pte(domain, tmp, level); 823 first_pte = pte = dma_pfn_level_pte(domain, tmp, level);
802 if (pte) { 824 if (!pte) {
803 free_pgtable_page( 825 tmp = align_to_level(tmp + 1, level + 1);
804 phys_to_virt(dma_pte_addr(pte))); 826 continue;
805 dma_clear_pte(pte);
806 domain_flush_cache(domain, pte, sizeof(*pte));
807 } 827 }
808 tmp += level_size(level); 828 do {
829 if (dma_pte_present(pte)) {
830 free_pgtable_page(phys_to_virt(dma_pte_addr(pte)));
831 dma_clear_pte(pte);
832 }
833 pte++;
834 tmp += level_size(level);
835 } while (!first_pte_in_page(pte) &&
836 tmp + level_size(level) - 1 <= last_pfn);
837
838 domain_flush_cache(domain, first_pte,
839 (void *)pte - (void *)first_pte);
840
809 } 841 }
810 level++; 842 level++;
811 } 843 }
812 /* free pgd */ 844 /* free pgd */
813 if (start == 0 && end >= ((((u64)1) << addr_width) - 1)) { 845 if (start_pfn == 0 && last_pfn == DOMAIN_MAX_PFN(domain->gaw)) {
814 free_pgtable_page(domain->pgd); 846 free_pgtable_page(domain->pgd);
815 domain->pgd = NULL; 847 domain->pgd = NULL;
816 } 848 }
@@ -1036,11 +1068,11 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
1036} 1068}
1037 1069
1038static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, 1070static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
1039 u64 addr, unsigned int pages) 1071 unsigned long pfn, unsigned int pages)
1040{ 1072{
1041 unsigned int mask = ilog2(__roundup_pow_of_two(pages)); 1073 unsigned int mask = ilog2(__roundup_pow_of_two(pages));
1074 uint64_t addr = (uint64_t)pfn << VTD_PAGE_SHIFT;
1042 1075
1043 BUG_ON(addr & (~VTD_PAGE_MASK));
1044 BUG_ON(pages == 0); 1076 BUG_ON(pages == 0);
1045 1077
1046 /* 1078 /*
@@ -1055,7 +1087,12 @@ static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
1055 else 1087 else
1056 iommu->flush.flush_iotlb(iommu, did, addr, mask, 1088 iommu->flush.flush_iotlb(iommu, did, addr, mask,
1057 DMA_TLB_PSI_FLUSH); 1089 DMA_TLB_PSI_FLUSH);
1058 if (did) 1090
1091 /*
1092 * In caching mode, domain ID 0 is reserved for non-present to present
1093 * mapping flush. Device IOTLB doesn't need to be flushed in this case.
1094 */
1095 if (!cap_caching_mode(iommu->cap) || did)
1059 iommu_flush_dev_iotlb(iommu->domains[did], addr, mask); 1096 iommu_flush_dev_iotlb(iommu->domains[did], addr, mask);
1060} 1097}
1061 1098
@@ -1280,7 +1317,6 @@ static void dmar_init_reserved_ranges(void)
1280 struct pci_dev *pdev = NULL; 1317 struct pci_dev *pdev = NULL;
1281 struct iova *iova; 1318 struct iova *iova;
1282 int i; 1319 int i;
1283 u64 addr, size;
1284 1320
1285 init_iova_domain(&reserved_iova_list, DMA_32BIT_PFN); 1321 init_iova_domain(&reserved_iova_list, DMA_32BIT_PFN);
1286 1322
@@ -1303,12 +1339,9 @@ static void dmar_init_reserved_ranges(void)
1303 r = &pdev->resource[i]; 1339 r = &pdev->resource[i];
1304 if (!r->flags || !(r->flags & IORESOURCE_MEM)) 1340 if (!r->flags || !(r->flags & IORESOURCE_MEM))
1305 continue; 1341 continue;
1306 addr = r->start; 1342 iova = reserve_iova(&reserved_iova_list,
1307 addr &= PHYSICAL_PAGE_MASK; 1343 IOVA_PFN(r->start),
1308 size = r->end - addr; 1344 IOVA_PFN(r->end));
1309 size = PAGE_ALIGN(size);
1310 iova = reserve_iova(&reserved_iova_list, IOVA_PFN(addr),
1311 IOVA_PFN(size + addr) - 1);
1312 if (!iova) 1345 if (!iova)
1313 printk(KERN_ERR "Reserve iova failed\n"); 1346 printk(KERN_ERR "Reserve iova failed\n");
1314 } 1347 }
@@ -1342,7 +1375,6 @@ static int domain_init(struct dmar_domain *domain, int guest_width)
1342 unsigned long sagaw; 1375 unsigned long sagaw;
1343 1376
1344 init_iova_domain(&domain->iovad, DMA_32BIT_PFN); 1377 init_iova_domain(&domain->iovad, DMA_32BIT_PFN);
1345 spin_lock_init(&domain->mapping_lock);
1346 spin_lock_init(&domain->iommu_lock); 1378 spin_lock_init(&domain->iommu_lock);
1347 1379
1348 domain_reserve_special_ranges(domain); 1380 domain_reserve_special_ranges(domain);
@@ -1389,7 +1421,6 @@ static void domain_exit(struct dmar_domain *domain)
1389{ 1421{
1390 struct dmar_drhd_unit *drhd; 1422 struct dmar_drhd_unit *drhd;
1391 struct intel_iommu *iommu; 1423 struct intel_iommu *iommu;
1392 u64 end;
1393 1424
1394 /* Domain 0 is reserved, so dont process it */ 1425 /* Domain 0 is reserved, so dont process it */
1395 if (!domain) 1426 if (!domain)
@@ -1398,14 +1429,12 @@ static void domain_exit(struct dmar_domain *domain)
1398 domain_remove_dev_info(domain); 1429 domain_remove_dev_info(domain);
1399 /* destroy iovas */ 1430 /* destroy iovas */
1400 put_iova_domain(&domain->iovad); 1431 put_iova_domain(&domain->iovad);
1401 end = DOMAIN_MAX_ADDR(domain->gaw);
1402 end = end & (~PAGE_MASK);
1403 1432
1404 /* clear ptes */ 1433 /* clear ptes */
1405 dma_pte_clear_range(domain, 0, end); 1434 dma_pte_clear_range(domain, 0, DOMAIN_MAX_PFN(domain->gaw));
1406 1435
1407 /* free page tables */ 1436 /* free page tables */
1408 dma_pte_free_pagetable(domain, 0, end); 1437 dma_pte_free_pagetable(domain, 0, DOMAIN_MAX_PFN(domain->gaw));
1409 1438
1410 for_each_active_iommu(iommu, drhd) 1439 for_each_active_iommu(iommu, drhd)
1411 if (test_bit(iommu->seq_id, &domain->iommu_bmp)) 1440 if (test_bit(iommu->seq_id, &domain->iommu_bmp))
@@ -1619,42 +1648,86 @@ static int domain_context_mapped(struct pci_dev *pdev)
1619 tmp->devfn); 1648 tmp->devfn);
1620} 1649}
1621 1650
1622static int 1651static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1623domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova, 1652 struct scatterlist *sg, unsigned long phys_pfn,
1624 u64 hpa, size_t size, int prot) 1653 unsigned long nr_pages, int prot)
1625{ 1654{
1626 u64 start_pfn, end_pfn; 1655 struct dma_pte *first_pte = NULL, *pte = NULL;
1627 struct dma_pte *pte; 1656 phys_addr_t uninitialized_var(pteval);
1628 int index; 1657 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
1629 int addr_width = agaw_to_width(domain->agaw); 1658 unsigned long sg_res;
1630 1659
1631 hpa &= (((u64)1) << addr_width) - 1; 1660 BUG_ON(addr_width < BITS_PER_LONG && (iov_pfn + nr_pages - 1) >> addr_width);
1632 1661
1633 if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0) 1662 if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0)
1634 return -EINVAL; 1663 return -EINVAL;
1635 iova &= PAGE_MASK; 1664
1636 start_pfn = ((u64)hpa) >> VTD_PAGE_SHIFT; 1665 prot &= DMA_PTE_READ | DMA_PTE_WRITE | DMA_PTE_SNP;
1637 end_pfn = (VTD_PAGE_ALIGN(((u64)hpa) + size)) >> VTD_PAGE_SHIFT; 1666
1638 index = 0; 1667 if (sg)
1639 while (start_pfn < end_pfn) { 1668 sg_res = 0;
1640 pte = addr_to_dma_pte(domain, iova + VTD_PAGE_SIZE * index); 1669 else {
1641 if (!pte) 1670 sg_res = nr_pages + 1;
1642 return -ENOMEM; 1671 pteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | prot;
1672 }
1673
1674 while (nr_pages--) {
1675 uint64_t tmp;
1676
1677 if (!sg_res) {
1678 sg_res = (sg->offset + sg->length + VTD_PAGE_SIZE - 1) >> VTD_PAGE_SHIFT;
1679 sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset;
1680 sg->dma_length = sg->length;
1681 pteval = page_to_phys(sg_page(sg)) | prot;
1682 }
1683 if (!pte) {
1684 first_pte = pte = pfn_to_dma_pte(domain, iov_pfn);
1685 if (!pte)
1686 return -ENOMEM;
1687 }
1643 /* We don't need lock here, nobody else 1688 /* We don't need lock here, nobody else
1644 * touches the iova range 1689 * touches the iova range
1645 */ 1690 */
1646 BUG_ON(dma_pte_addr(pte)); 1691 tmp = cmpxchg64_local(&pte->val, 0ULL, pteval);
1647 dma_set_pte_addr(pte, start_pfn << VTD_PAGE_SHIFT); 1692 if (tmp) {
1648 dma_set_pte_prot(pte, prot); 1693 static int dumps = 5;
1649 if (prot & DMA_PTE_SNP) 1694 printk(KERN_CRIT "ERROR: DMA PTE for vPFN 0x%lx already set (to %llx not %llx)\n",
1650 dma_set_pte_snp(pte); 1695 iov_pfn, tmp, (unsigned long long)pteval);
1651 domain_flush_cache(domain, pte, sizeof(*pte)); 1696 if (dumps) {
1652 start_pfn++; 1697 dumps--;
1653 index++; 1698 debug_dma_dump_mappings(NULL);
1699 }
1700 WARN_ON(1);
1701 }
1702 pte++;
1703 if (!nr_pages || first_pte_in_page(pte)) {
1704 domain_flush_cache(domain, first_pte,
1705 (void *)pte - (void *)first_pte);
1706 pte = NULL;
1707 }
1708 iov_pfn++;
1709 pteval += VTD_PAGE_SIZE;
1710 sg_res--;
1711 if (!sg_res)
1712 sg = sg_next(sg);
1654 } 1713 }
1655 return 0; 1714 return 0;
1656} 1715}
1657 1716
1717static inline int domain_sg_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1718 struct scatterlist *sg, unsigned long nr_pages,
1719 int prot)
1720{
1721 return __domain_mapping(domain, iov_pfn, sg, 0, nr_pages, prot);
1722}
1723
1724static inline int domain_pfn_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1725 unsigned long phys_pfn, unsigned long nr_pages,
1726 int prot)
1727{
1728 return __domain_mapping(domain, iov_pfn, NULL, phys_pfn, nr_pages, prot);
1729}
1730
1658static void iommu_detach_dev(struct intel_iommu *iommu, u8 bus, u8 devfn) 1731static void iommu_detach_dev(struct intel_iommu *iommu, u8 bus, u8 devfn)
1659{ 1732{
1660 if (!iommu) 1733 if (!iommu)
@@ -1845,58 +1918,61 @@ error:
1845 1918
1846static int iommu_identity_mapping; 1919static int iommu_identity_mapping;
1847 1920
1921static int iommu_domain_identity_map(struct dmar_domain *domain,
1922 unsigned long long start,
1923 unsigned long long end)
1924{
1925 unsigned long first_vpfn = start >> VTD_PAGE_SHIFT;
1926 unsigned long last_vpfn = end >> VTD_PAGE_SHIFT;
1927
1928 if (!reserve_iova(&domain->iovad, dma_to_mm_pfn(first_vpfn),
1929 dma_to_mm_pfn(last_vpfn))) {
1930 printk(KERN_ERR "IOMMU: reserve iova failed\n");
1931 return -ENOMEM;
1932 }
1933
1934 pr_debug("Mapping reserved region %llx-%llx for domain %d\n",
1935 start, end, domain->id);
1936 /*
1937 * RMRR range might have overlap with physical memory range,
1938 * clear it first
1939 */
1940 dma_pte_clear_range(domain, first_vpfn, last_vpfn);
1941
1942 return domain_pfn_mapping(domain, first_vpfn, first_vpfn,
1943 last_vpfn - first_vpfn + 1,
1944 DMA_PTE_READ|DMA_PTE_WRITE);
1945}
1946
1848static int iommu_prepare_identity_map(struct pci_dev *pdev, 1947static int iommu_prepare_identity_map(struct pci_dev *pdev,
1849 unsigned long long start, 1948 unsigned long long start,
1850 unsigned long long end) 1949 unsigned long long end)
1851{ 1950{
1852 struct dmar_domain *domain; 1951 struct dmar_domain *domain;
1853 unsigned long size;
1854 unsigned long long base;
1855 int ret; 1952 int ret;
1856 1953
1857 printk(KERN_INFO 1954 printk(KERN_INFO
1858 "IOMMU: Setting identity map for device %s [0x%Lx - 0x%Lx]\n", 1955 "IOMMU: Setting identity map for device %s [0x%Lx - 0x%Lx]\n",
1859 pci_name(pdev), start, end); 1956 pci_name(pdev), start, end);
1860 if (iommu_identity_mapping) 1957
1861 domain = si_domain; 1958 domain = get_domain_for_dev(pdev, DEFAULT_DOMAIN_ADDRESS_WIDTH);
1862 else
1863 /* page table init */
1864 domain = get_domain_for_dev(pdev, DEFAULT_DOMAIN_ADDRESS_WIDTH);
1865 if (!domain) 1959 if (!domain)
1866 return -ENOMEM; 1960 return -ENOMEM;
1867 1961
1868 /* The address might not be aligned */ 1962 ret = iommu_domain_identity_map(domain, start, end);
1869 base = start & PAGE_MASK;
1870 size = end - base;
1871 size = PAGE_ALIGN(size);
1872 if (!reserve_iova(&domain->iovad, IOVA_PFN(base),
1873 IOVA_PFN(base + size) - 1)) {
1874 printk(KERN_ERR "IOMMU: reserve iova failed\n");
1875 ret = -ENOMEM;
1876 goto error;
1877 }
1878
1879 pr_debug("Mapping reserved region %lx@%llx for %s\n",
1880 size, base, pci_name(pdev));
1881 /*
1882 * RMRR range might have overlap with physical memory range,
1883 * clear it first
1884 */
1885 dma_pte_clear_range(domain, base, base + size);
1886
1887 ret = domain_page_mapping(domain, base, base, size,
1888 DMA_PTE_READ|DMA_PTE_WRITE);
1889 if (ret) 1963 if (ret)
1890 goto error; 1964 goto error;
1891 1965
1892 /* context entry init */ 1966 /* context entry init */
1893 ret = domain_context_mapping(domain, pdev, CONTEXT_TT_MULTI_LEVEL); 1967 ret = domain_context_mapping(domain, pdev, CONTEXT_TT_MULTI_LEVEL);
1894 if (!ret) 1968 if (ret)
1895 return 0; 1969 goto error;
1896error: 1970
1971 return 0;
1972
1973 error:
1897 domain_exit(domain); 1974 domain_exit(domain);
1898 return ret; 1975 return ret;
1899
1900} 1976}
1901 1977
1902static inline int iommu_prepare_rmrr_dev(struct dmar_rmrr_unit *rmrr, 1978static inline int iommu_prepare_rmrr_dev(struct dmar_rmrr_unit *rmrr,
@@ -1908,64 +1984,6 @@ static inline int iommu_prepare_rmrr_dev(struct dmar_rmrr_unit *rmrr,
1908 rmrr->end_address + 1); 1984 rmrr->end_address + 1);
1909} 1985}
1910 1986
1911#ifdef CONFIG_DMAR_GFX_WA
1912struct iommu_prepare_data {
1913 struct pci_dev *pdev;
1914 int ret;
1915};
1916
1917static int __init iommu_prepare_work_fn(unsigned long start_pfn,
1918 unsigned long end_pfn, void *datax)
1919{
1920 struct iommu_prepare_data *data;
1921
1922 data = (struct iommu_prepare_data *)datax;
1923
1924 data->ret = iommu_prepare_identity_map(data->pdev,
1925 start_pfn<<PAGE_SHIFT, end_pfn<<PAGE_SHIFT);
1926 return data->ret;
1927
1928}
1929
1930static int __init iommu_prepare_with_active_regions(struct pci_dev *pdev)
1931{
1932 int nid;
1933 struct iommu_prepare_data data;
1934
1935 data.pdev = pdev;
1936 data.ret = 0;
1937
1938 for_each_online_node(nid) {
1939 work_with_active_regions(nid, iommu_prepare_work_fn, &data);
1940 if (data.ret)
1941 return data.ret;
1942 }
1943 return data.ret;
1944}
1945
1946static void __init iommu_prepare_gfx_mapping(void)
1947{
1948 struct pci_dev *pdev = NULL;
1949 int ret;
1950
1951 for_each_pci_dev(pdev) {
1952 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO ||
1953 !IS_GFX_DEVICE(pdev))
1954 continue;
1955 printk(KERN_INFO "IOMMU: gfx device %s 1-1 mapping\n",
1956 pci_name(pdev));
1957 ret = iommu_prepare_with_active_regions(pdev);
1958 if (ret)
1959 printk(KERN_ERR "IOMMU: mapping reserved region failed\n");
1960 }
1961}
1962#else /* !CONFIG_DMAR_GFX_WA */
1963static inline void iommu_prepare_gfx_mapping(void)
1964{
1965 return;
1966}
1967#endif
1968
1969#ifdef CONFIG_DMAR_FLOPPY_WA 1987#ifdef CONFIG_DMAR_FLOPPY_WA
1970static inline void iommu_prepare_isa(void) 1988static inline void iommu_prepare_isa(void)
1971{ 1989{
@@ -1976,12 +1994,12 @@ static inline void iommu_prepare_isa(void)
1976 if (!pdev) 1994 if (!pdev)
1977 return; 1995 return;
1978 1996
1979 printk(KERN_INFO "IOMMU: Prepare 0-16M unity mapping for LPC\n"); 1997 printk(KERN_INFO "IOMMU: Prepare 0-16MiB unity mapping for LPC\n");
1980 ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024); 1998 ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024);
1981 1999
1982 if (ret) 2000 if (ret)
1983 printk(KERN_ERR "IOMMU: Failed to create 0-64M identity map, " 2001 printk(KERN_ERR "IOMMU: Failed to create 0-16MiB identity map; "
1984 "floppy might not work\n"); 2002 "floppy might not work\n");
1985 2003
1986} 2004}
1987#else 2005#else
@@ -2009,16 +2027,30 @@ static int __init init_context_pass_through(void)
2009} 2027}
2010 2028
2011static int md_domain_init(struct dmar_domain *domain, int guest_width); 2029static int md_domain_init(struct dmar_domain *domain, int guest_width);
2030
2031static int __init si_domain_work_fn(unsigned long start_pfn,
2032 unsigned long end_pfn, void *datax)
2033{
2034 int *ret = datax;
2035
2036 *ret = iommu_domain_identity_map(si_domain,
2037 (uint64_t)start_pfn << PAGE_SHIFT,
2038 (uint64_t)end_pfn << PAGE_SHIFT);
2039 return *ret;
2040
2041}
2042
2012static int si_domain_init(void) 2043static int si_domain_init(void)
2013{ 2044{
2014 struct dmar_drhd_unit *drhd; 2045 struct dmar_drhd_unit *drhd;
2015 struct intel_iommu *iommu; 2046 struct intel_iommu *iommu;
2016 int ret = 0; 2047 int nid, ret = 0;
2017 2048
2018 si_domain = alloc_domain(); 2049 si_domain = alloc_domain();
2019 if (!si_domain) 2050 if (!si_domain)
2020 return -EFAULT; 2051 return -EFAULT;
2021 2052
2053 pr_debug("Identity mapping domain is domain %d\n", si_domain->id);
2022 2054
2023 for_each_active_iommu(iommu, drhd) { 2055 for_each_active_iommu(iommu, drhd) {
2024 ret = iommu_attach_domain(si_domain, iommu); 2056 ret = iommu_attach_domain(si_domain, iommu);
@@ -2035,6 +2067,12 @@ static int si_domain_init(void)
2035 2067
2036 si_domain->flags = DOMAIN_FLAG_STATIC_IDENTITY; 2068 si_domain->flags = DOMAIN_FLAG_STATIC_IDENTITY;
2037 2069
2070 for_each_online_node(nid) {
2071 work_with_active_regions(nid, si_domain_work_fn, &ret);
2072 if (ret)
2073 return ret;
2074 }
2075
2038 return 0; 2076 return 0;
2039} 2077}
2040 2078
@@ -2079,9 +2117,49 @@ static int domain_add_dev_info(struct dmar_domain *domain,
2079 return 0; 2117 return 0;
2080} 2118}
2081 2119
2120static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
2121{
2122 if (iommu_identity_mapping == 2)
2123 return IS_GFX_DEVICE(pdev);
2124
2125 /*
2126 * We want to start off with all devices in the 1:1 domain, and
2127 * take them out later if we find they can't access all of memory.
2128 *
2129 * However, we can't do this for PCI devices behind bridges,
2130 * because all PCI devices behind the same bridge will end up
2131 * with the same source-id on their transactions.
2132 *
2133 * Practically speaking, we can't change things around for these
2134 * devices at run-time, because we can't be sure there'll be no
2135 * DMA transactions in flight for any of their siblings.
2136 *
2137 * So PCI devices (unless they're on the root bus) as well as
2138 * their parent PCI-PCI or PCIe-PCI bridges must be left _out_ of
2139 * the 1:1 domain, just in _case_ one of their siblings turns out
2140 * not to be able to map all of memory.
2141 */
2142 if (!pdev->is_pcie) {
2143 if (!pci_is_root_bus(pdev->bus))
2144 return 0;
2145 if (pdev->class >> 8 == PCI_CLASS_BRIDGE_PCI)
2146 return 0;
2147 } else if (pdev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE)
2148 return 0;
2149
2150 /*
2151 * At boot time, we don't yet know if devices will be 64-bit capable.
2152 * Assume that they will -- if they turn out not to be, then we can
2153 * take them out of the 1:1 domain later.
2154 */
2155 if (!startup)
2156 return pdev->dma_mask > DMA_BIT_MASK(32);
2157
2158 return 1;
2159}
2160
2082static int iommu_prepare_static_identity_mapping(void) 2161static int iommu_prepare_static_identity_mapping(void)
2083{ 2162{
2084 int i;
2085 struct pci_dev *pdev = NULL; 2163 struct pci_dev *pdev = NULL;
2086 int ret; 2164 int ret;
2087 2165
@@ -2089,23 +2167,19 @@ static int iommu_prepare_static_identity_mapping(void)
2089 if (ret) 2167 if (ret)
2090 return -EFAULT; 2168 return -EFAULT;
2091 2169
2092 printk(KERN_INFO "IOMMU: Setting identity map:\n");
2093 for_each_pci_dev(pdev) { 2170 for_each_pci_dev(pdev) {
2094 for (i = 0; i < e820.nr_map; i++) { 2171 if (iommu_should_identity_map(pdev, 1)) {
2095 struct e820entry *ei = &e820.map[i]; 2172 printk(KERN_INFO "IOMMU: identity mapping for device %s\n",
2096 2173 pci_name(pdev));
2097 if (ei->type == E820_RAM) { 2174
2098 ret = iommu_prepare_identity_map(pdev, 2175 ret = domain_context_mapping(si_domain, pdev,
2099 ei->addr, ei->addr + ei->size); 2176 CONTEXT_TT_MULTI_LEVEL);
2100 if (ret) { 2177 if (ret)
2101 printk(KERN_INFO "1:1 mapping to one domain failed.\n"); 2178 return ret;
2102 return -EFAULT; 2179 ret = domain_add_dev_info(si_domain, pdev);
2103 } 2180 if (ret)
2104 } 2181 return ret;
2105 } 2182 }
2106 ret = domain_add_dev_info(si_domain, pdev);
2107 if (ret)
2108 return ret;
2109 } 2183 }
2110 2184
2111 return 0; 2185 return 0;
@@ -2260,6 +2334,10 @@ int __init init_dmars(void)
2260 * identity mapping if iommu_identity_mapping is set. 2334 * identity mapping if iommu_identity_mapping is set.
2261 */ 2335 */
2262 if (!iommu_pass_through) { 2336 if (!iommu_pass_through) {
2337#ifdef CONFIG_DMAR_BROKEN_GFX_WA
2338 if (!iommu_identity_mapping)
2339 iommu_identity_mapping = 2;
2340#endif
2263 if (iommu_identity_mapping) 2341 if (iommu_identity_mapping)
2264 iommu_prepare_static_identity_mapping(); 2342 iommu_prepare_static_identity_mapping();
2265 /* 2343 /*
@@ -2293,8 +2371,6 @@ int __init init_dmars(void)
2293 } 2371 }
2294 } 2372 }
2295 2373
2296 iommu_prepare_gfx_mapping();
2297
2298 iommu_prepare_isa(); 2374 iommu_prepare_isa();
2299 } 2375 }
2300 2376
@@ -2339,50 +2415,40 @@ error:
2339 return ret; 2415 return ret;
2340} 2416}
2341 2417
2342static inline u64 aligned_size(u64 host_addr, size_t size) 2418/* Returns a number of VTD pages, but aligned to MM page size */
2419static inline unsigned long aligned_nrpages(unsigned long host_addr,
2420 size_t size)
2343{ 2421{
2344 u64 addr; 2422 host_addr &= ~PAGE_MASK;
2345 addr = (host_addr & (~PAGE_MASK)) + size; 2423 return PAGE_ALIGN(host_addr + size) >> VTD_PAGE_SHIFT;
2346 return PAGE_ALIGN(addr);
2347}
2348
2349struct iova *
2350iommu_alloc_iova(struct dmar_domain *domain, size_t size, u64 end)
2351{
2352 struct iova *piova;
2353
2354 /* Make sure it's in range */
2355 end = min_t(u64, DOMAIN_MAX_ADDR(domain->gaw), end);
2356 if (!size || (IOVA_START_ADDR + size > end))
2357 return NULL;
2358
2359 piova = alloc_iova(&domain->iovad,
2360 size >> PAGE_SHIFT, IOVA_PFN(end), 1);
2361 return piova;
2362} 2424}
2363 2425
2364static struct iova * 2426/* This takes a number of _MM_ pages, not VTD pages */
2365__intel_alloc_iova(struct device *dev, struct dmar_domain *domain, 2427static struct iova *intel_alloc_iova(struct device *dev,
2366 size_t size, u64 dma_mask) 2428 struct dmar_domain *domain,
2429 unsigned long nrpages, uint64_t dma_mask)
2367{ 2430{
2368 struct pci_dev *pdev = to_pci_dev(dev); 2431 struct pci_dev *pdev = to_pci_dev(dev);
2369 struct iova *iova = NULL; 2432 struct iova *iova = NULL;
2370 2433
2371 if (dma_mask <= DMA_BIT_MASK(32) || dmar_forcedac) 2434 /* Restrict dma_mask to the width that the iommu can handle */
2372 iova = iommu_alloc_iova(domain, size, dma_mask); 2435 dma_mask = min_t(uint64_t, DOMAIN_MAX_ADDR(domain->gaw), dma_mask);
2373 else { 2436
2437 if (!dmar_forcedac && dma_mask > DMA_BIT_MASK(32)) {
2374 /* 2438 /*
2375 * First try to allocate an io virtual address in 2439 * First try to allocate an io virtual address in
2376 * DMA_BIT_MASK(32) and if that fails then try allocating 2440 * DMA_BIT_MASK(32) and if that fails then try allocating
2377 * from higher range 2441 * from higher range
2378 */ 2442 */
2379 iova = iommu_alloc_iova(domain, size, DMA_BIT_MASK(32)); 2443 iova = alloc_iova(&domain->iovad, nrpages,
2380 if (!iova) 2444 IOVA_PFN(DMA_BIT_MASK(32)), 1);
2381 iova = iommu_alloc_iova(domain, size, dma_mask); 2445 if (iova)
2382 } 2446 return iova;
2383 2447 }
2384 if (!iova) { 2448 iova = alloc_iova(&domain->iovad, nrpages, IOVA_PFN(dma_mask), 1);
2385 printk(KERN_ERR"Allocating iova for %s failed", pci_name(pdev)); 2449 if (unlikely(!iova)) {
2450 printk(KERN_ERR "Allocating %ld-page iova for %s failed",
2451 nrpages, pci_name(pdev));
2386 return NULL; 2452 return NULL;
2387 } 2453 }
2388 2454
@@ -2424,16 +2490,24 @@ static int iommu_dummy(struct pci_dev *pdev)
2424} 2490}
2425 2491
2426/* Check if the pdev needs to go through non-identity map and unmap process.*/ 2492/* Check if the pdev needs to go through non-identity map and unmap process.*/
2427static int iommu_no_mapping(struct pci_dev *pdev) 2493static int iommu_no_mapping(struct device *dev)
2428{ 2494{
2495 struct pci_dev *pdev;
2429 int found; 2496 int found;
2430 2497
2498 if (unlikely(dev->bus != &pci_bus_type))
2499 return 1;
2500
2501 pdev = to_pci_dev(dev);
2502 if (iommu_dummy(pdev))
2503 return 1;
2504
2431 if (!iommu_identity_mapping) 2505 if (!iommu_identity_mapping)
2432 return iommu_dummy(pdev); 2506 return 0;
2433 2507
2434 found = identity_mapping(pdev); 2508 found = identity_mapping(pdev);
2435 if (found) { 2509 if (found) {
2436 if (pdev->dma_mask > DMA_BIT_MASK(32)) 2510 if (iommu_should_identity_map(pdev, 0))
2437 return 1; 2511 return 1;
2438 else { 2512 else {
2439 /* 2513 /*
@@ -2450,9 +2524,12 @@ static int iommu_no_mapping(struct pci_dev *pdev)
2450 * In case of a detached 64 bit DMA device from vm, the device 2524 * In case of a detached 64 bit DMA device from vm, the device
2451 * is put into si_domain for identity mapping. 2525 * is put into si_domain for identity mapping.
2452 */ 2526 */
2453 if (pdev->dma_mask > DMA_BIT_MASK(32)) { 2527 if (iommu_should_identity_map(pdev, 0)) {
2454 int ret; 2528 int ret;
2455 ret = domain_add_dev_info(si_domain, pdev); 2529 ret = domain_add_dev_info(si_domain, pdev);
2530 if (ret)
2531 return 0;
2532 ret = domain_context_mapping(si_domain, pdev, CONTEXT_TT_MULTI_LEVEL);
2456 if (!ret) { 2533 if (!ret) {
2457 printk(KERN_INFO "64bit %s uses identity mapping\n", 2534 printk(KERN_INFO "64bit %s uses identity mapping\n",
2458 pci_name(pdev)); 2535 pci_name(pdev));
@@ -2461,7 +2538,7 @@ static int iommu_no_mapping(struct pci_dev *pdev)
2461 } 2538 }
2462 } 2539 }
2463 2540
2464 return iommu_dummy(pdev); 2541 return 0;
2465} 2542}
2466 2543
2467static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr, 2544static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
@@ -2477,7 +2554,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
2477 2554
2478 BUG_ON(dir == DMA_NONE); 2555 BUG_ON(dir == DMA_NONE);
2479 2556
2480 if (iommu_no_mapping(pdev)) 2557 if (iommu_no_mapping(hwdev))
2481 return paddr; 2558 return paddr;
2482 2559
2483 domain = get_valid_domain_for_dev(pdev); 2560 domain = get_valid_domain_for_dev(pdev);
@@ -2485,14 +2562,13 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
2485 return 0; 2562 return 0;
2486 2563
2487 iommu = domain_get_iommu(domain); 2564 iommu = domain_get_iommu(domain);
2488 size = aligned_size((u64)paddr, size); 2565 size = aligned_nrpages(paddr, size);
2489 2566
2490 iova = __intel_alloc_iova(hwdev, domain, size, pdev->dma_mask); 2567 iova = intel_alloc_iova(hwdev, domain, dma_to_mm_pfn(size),
2568 pdev->dma_mask);
2491 if (!iova) 2569 if (!iova)
2492 goto error; 2570 goto error;
2493 2571
2494 start_paddr = (phys_addr_t)iova->pfn_lo << PAGE_SHIFT;
2495
2496 /* 2572 /*
2497 * Check if DMAR supports zero-length reads on write only 2573 * Check if DMAR supports zero-length reads on write only
2498 * mappings.. 2574 * mappings..
@@ -2508,20 +2584,20 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
2508 * might have two guest_addr mapping to the same host paddr, but this 2584 * might have two guest_addr mapping to the same host paddr, but this
2509 * is not a big problem 2585 * is not a big problem
2510 */ 2586 */
2511 ret = domain_page_mapping(domain, start_paddr, 2587 ret = domain_pfn_mapping(domain, mm_to_dma_pfn(iova->pfn_lo),
2512 ((u64)paddr) & PHYSICAL_PAGE_MASK, 2588 paddr >> VTD_PAGE_SHIFT, size, prot);
2513 size, prot);
2514 if (ret) 2589 if (ret)
2515 goto error; 2590 goto error;
2516 2591
2517 /* it's a non-present to present mapping. Only flush if caching mode */ 2592 /* it's a non-present to present mapping. Only flush if caching mode */
2518 if (cap_caching_mode(iommu->cap)) 2593 if (cap_caching_mode(iommu->cap))
2519 iommu_flush_iotlb_psi(iommu, 0, start_paddr, 2594 iommu_flush_iotlb_psi(iommu, 0, mm_to_dma_pfn(iova->pfn_lo), size);
2520 size >> VTD_PAGE_SHIFT);
2521 else 2595 else
2522 iommu_flush_write_buffer(iommu); 2596 iommu_flush_write_buffer(iommu);
2523 2597
2524 return start_paddr + ((u64)paddr & (~PAGE_MASK)); 2598 start_paddr = (phys_addr_t)iova->pfn_lo << PAGE_SHIFT;
2599 start_paddr += paddr & ~PAGE_MASK;
2600 return start_paddr;
2525 2601
2526error: 2602error:
2527 if (iova) 2603 if (iova)
@@ -2614,11 +2690,11 @@ static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr,
2614{ 2690{
2615 struct pci_dev *pdev = to_pci_dev(dev); 2691 struct pci_dev *pdev = to_pci_dev(dev);
2616 struct dmar_domain *domain; 2692 struct dmar_domain *domain;
2617 unsigned long start_addr; 2693 unsigned long start_pfn, last_pfn;
2618 struct iova *iova; 2694 struct iova *iova;
2619 struct intel_iommu *iommu; 2695 struct intel_iommu *iommu;
2620 2696
2621 if (iommu_no_mapping(pdev)) 2697 if (iommu_no_mapping(dev))
2622 return; 2698 return;
2623 2699
2624 domain = find_domain(pdev); 2700 domain = find_domain(pdev);
@@ -2627,22 +2703,25 @@ static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr,
2627 iommu = domain_get_iommu(domain); 2703 iommu = domain_get_iommu(domain);
2628 2704
2629 iova = find_iova(&domain->iovad, IOVA_PFN(dev_addr)); 2705 iova = find_iova(&domain->iovad, IOVA_PFN(dev_addr));
2630 if (!iova) 2706 if (WARN_ONCE(!iova, "Driver unmaps unmatched page at PFN %llx\n",
2707 (unsigned long long)dev_addr))
2631 return; 2708 return;
2632 2709
2633 start_addr = iova->pfn_lo << PAGE_SHIFT; 2710 start_pfn = mm_to_dma_pfn(iova->pfn_lo);
2634 size = aligned_size((u64)dev_addr, size); 2711 last_pfn = mm_to_dma_pfn(iova->pfn_hi + 1) - 1;
2635 2712
2636 pr_debug("Device %s unmapping: %zx@%llx\n", 2713 pr_debug("Device %s unmapping: pfn %lx-%lx\n",
2637 pci_name(pdev), size, (unsigned long long)start_addr); 2714 pci_name(pdev), start_pfn, last_pfn);
2638 2715
2639 /* clear the whole page */ 2716 /* clear the whole page */
2640 dma_pte_clear_range(domain, start_addr, start_addr + size); 2717 dma_pte_clear_range(domain, start_pfn, last_pfn);
2718
2641 /* free page tables */ 2719 /* free page tables */
2642 dma_pte_free_pagetable(domain, start_addr, start_addr + size); 2720 dma_pte_free_pagetable(domain, start_pfn, last_pfn);
2721
2643 if (intel_iommu_strict) { 2722 if (intel_iommu_strict) {
2644 iommu_flush_iotlb_psi(iommu, domain->id, start_addr, 2723 iommu_flush_iotlb_psi(iommu, domain->id, start_pfn,
2645 size >> VTD_PAGE_SHIFT); 2724 last_pfn - start_pfn + 1);
2646 /* free iova */ 2725 /* free iova */
2647 __free_iova(&domain->iovad, iova); 2726 __free_iova(&domain->iovad, iova);
2648 } else { 2727 } else {
@@ -2700,17 +2779,13 @@ static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist,
2700 int nelems, enum dma_data_direction dir, 2779 int nelems, enum dma_data_direction dir,
2701 struct dma_attrs *attrs) 2780 struct dma_attrs *attrs)
2702{ 2781{
2703 int i;
2704 struct pci_dev *pdev = to_pci_dev(hwdev); 2782 struct pci_dev *pdev = to_pci_dev(hwdev);
2705 struct dmar_domain *domain; 2783 struct dmar_domain *domain;
2706 unsigned long start_addr; 2784 unsigned long start_pfn, last_pfn;
2707 struct iova *iova; 2785 struct iova *iova;
2708 size_t size = 0;
2709 phys_addr_t addr;
2710 struct scatterlist *sg;
2711 struct intel_iommu *iommu; 2786 struct intel_iommu *iommu;
2712 2787
2713 if (iommu_no_mapping(pdev)) 2788 if (iommu_no_mapping(hwdev))
2714 return; 2789 return;
2715 2790
2716 domain = find_domain(pdev); 2791 domain = find_domain(pdev);
@@ -2719,22 +2794,21 @@ static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist,
2719 iommu = domain_get_iommu(domain); 2794 iommu = domain_get_iommu(domain);
2720 2795
2721 iova = find_iova(&domain->iovad, IOVA_PFN(sglist[0].dma_address)); 2796 iova = find_iova(&domain->iovad, IOVA_PFN(sglist[0].dma_address));
2722 if (!iova) 2797 if (WARN_ONCE(!iova, "Driver unmaps unmatched sglist at PFN %llx\n",
2798 (unsigned long long)sglist[0].dma_address))
2723 return; 2799 return;
2724 for_each_sg(sglist, sg, nelems, i) {
2725 addr = page_to_phys(sg_page(sg)) + sg->offset;
2726 size += aligned_size((u64)addr, sg->length);
2727 }
2728 2800
2729 start_addr = iova->pfn_lo << PAGE_SHIFT; 2801 start_pfn = mm_to_dma_pfn(iova->pfn_lo);
2802 last_pfn = mm_to_dma_pfn(iova->pfn_hi + 1) - 1;
2730 2803
2731 /* clear the whole page */ 2804 /* clear the whole page */
2732 dma_pte_clear_range(domain, start_addr, start_addr + size); 2805 dma_pte_clear_range(domain, start_pfn, last_pfn);
2806
2733 /* free page tables */ 2807 /* free page tables */
2734 dma_pte_free_pagetable(domain, start_addr, start_addr + size); 2808 dma_pte_free_pagetable(domain, start_pfn, last_pfn);
2735 2809
2736 iommu_flush_iotlb_psi(iommu, domain->id, start_addr, 2810 iommu_flush_iotlb_psi(iommu, domain->id, start_pfn,
2737 size >> VTD_PAGE_SHIFT); 2811 (last_pfn - start_pfn + 1));
2738 2812
2739 /* free iova */ 2813 /* free iova */
2740 __free_iova(&domain->iovad, iova); 2814 __free_iova(&domain->iovad, iova);
@@ -2757,21 +2831,20 @@ static int intel_nontranslate_map_sg(struct device *hddev,
2757static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems, 2831static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems,
2758 enum dma_data_direction dir, struct dma_attrs *attrs) 2832 enum dma_data_direction dir, struct dma_attrs *attrs)
2759{ 2833{
2760 phys_addr_t addr;
2761 int i; 2834 int i;
2762 struct pci_dev *pdev = to_pci_dev(hwdev); 2835 struct pci_dev *pdev = to_pci_dev(hwdev);
2763 struct dmar_domain *domain; 2836 struct dmar_domain *domain;
2764 size_t size = 0; 2837 size_t size = 0;
2765 int prot = 0; 2838 int prot = 0;
2766 size_t offset = 0; 2839 size_t offset_pfn = 0;
2767 struct iova *iova = NULL; 2840 struct iova *iova = NULL;
2768 int ret; 2841 int ret;
2769 struct scatterlist *sg; 2842 struct scatterlist *sg;
2770 unsigned long start_addr; 2843 unsigned long start_vpfn;
2771 struct intel_iommu *iommu; 2844 struct intel_iommu *iommu;
2772 2845
2773 BUG_ON(dir == DMA_NONE); 2846 BUG_ON(dir == DMA_NONE);
2774 if (iommu_no_mapping(pdev)) 2847 if (iommu_no_mapping(hwdev))
2775 return intel_nontranslate_map_sg(hwdev, sglist, nelems, dir); 2848 return intel_nontranslate_map_sg(hwdev, sglist, nelems, dir);
2776 2849
2777 domain = get_valid_domain_for_dev(pdev); 2850 domain = get_valid_domain_for_dev(pdev);
@@ -2780,12 +2853,11 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int ne
2780 2853
2781 iommu = domain_get_iommu(domain); 2854 iommu = domain_get_iommu(domain);
2782 2855
2783 for_each_sg(sglist, sg, nelems, i) { 2856 for_each_sg(sglist, sg, nelems, i)
2784 addr = page_to_phys(sg_page(sg)) + sg->offset; 2857 size += aligned_nrpages(sg->offset, sg->length);
2785 size += aligned_size((u64)addr, sg->length);
2786 }
2787 2858
2788 iova = __intel_alloc_iova(hwdev, domain, size, pdev->dma_mask); 2859 iova = intel_alloc_iova(hwdev, domain, dma_to_mm_pfn(size),
2860 pdev->dma_mask);
2789 if (!iova) { 2861 if (!iova) {
2790 sglist->dma_length = 0; 2862 sglist->dma_length = 0;
2791 return 0; 2863 return 0;
@@ -2801,35 +2873,24 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int ne
2801 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) 2873 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)
2802 prot |= DMA_PTE_WRITE; 2874 prot |= DMA_PTE_WRITE;
2803 2875
2804 start_addr = iova->pfn_lo << PAGE_SHIFT; 2876 start_vpfn = mm_to_dma_pfn(iova->pfn_lo);
2805 offset = 0; 2877
2806 for_each_sg(sglist, sg, nelems, i) { 2878 ret = domain_sg_mapping(domain, start_vpfn, sglist, mm_to_dma_pfn(size), prot);
2807 addr = page_to_phys(sg_page(sg)) + sg->offset; 2879 if (unlikely(ret)) {
2808 size = aligned_size((u64)addr, sg->length); 2880 /* clear the page */
2809 ret = domain_page_mapping(domain, start_addr + offset, 2881 dma_pte_clear_range(domain, start_vpfn,
2810 ((u64)addr) & PHYSICAL_PAGE_MASK, 2882 start_vpfn + size - 1);
2811 size, prot); 2883 /* free page tables */
2812 if (ret) { 2884 dma_pte_free_pagetable(domain, start_vpfn,
2813 /* clear the page */ 2885 start_vpfn + size - 1);
2814 dma_pte_clear_range(domain, start_addr, 2886 /* free iova */
2815 start_addr + offset); 2887 __free_iova(&domain->iovad, iova);
2816 /* free page tables */ 2888 return 0;
2817 dma_pte_free_pagetable(domain, start_addr,
2818 start_addr + offset);
2819 /* free iova */
2820 __free_iova(&domain->iovad, iova);
2821 return 0;
2822 }
2823 sg->dma_address = start_addr + offset +
2824 ((u64)addr & (~PAGE_MASK));
2825 sg->dma_length = sg->length;
2826 offset += size;
2827 } 2889 }
2828 2890
2829 /* it's a non-present to present mapping. Only flush if caching mode */ 2891 /* it's a non-present to present mapping. Only flush if caching mode */
2830 if (cap_caching_mode(iommu->cap)) 2892 if (cap_caching_mode(iommu->cap))
2831 iommu_flush_iotlb_psi(iommu, 0, start_addr, 2893 iommu_flush_iotlb_psi(iommu, 0, start_vpfn, offset_pfn);
2832 offset >> VTD_PAGE_SHIFT);
2833 else 2894 else
2834 iommu_flush_write_buffer(iommu); 2895 iommu_flush_write_buffer(iommu);
2835 2896
@@ -3334,7 +3395,6 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width)
3334 int adjust_width; 3395 int adjust_width;
3335 3396
3336 init_iova_domain(&domain->iovad, DMA_32BIT_PFN); 3397 init_iova_domain(&domain->iovad, DMA_32BIT_PFN);
3337 spin_lock_init(&domain->mapping_lock);
3338 spin_lock_init(&domain->iommu_lock); 3398 spin_lock_init(&domain->iommu_lock);
3339 3399
3340 domain_reserve_special_ranges(domain); 3400 domain_reserve_special_ranges(domain);
@@ -3388,8 +3448,6 @@ static void iommu_free_vm_domain(struct dmar_domain *domain)
3388 3448
3389static void vm_domain_exit(struct dmar_domain *domain) 3449static void vm_domain_exit(struct dmar_domain *domain)
3390{ 3450{
3391 u64 end;
3392
3393 /* Domain 0 is reserved, so dont process it */ 3451 /* Domain 0 is reserved, so dont process it */
3394 if (!domain) 3452 if (!domain)
3395 return; 3453 return;
@@ -3397,14 +3455,12 @@ static void vm_domain_exit(struct dmar_domain *domain)
3397 vm_domain_remove_all_dev_info(domain); 3455 vm_domain_remove_all_dev_info(domain);
3398 /* destroy iovas */ 3456 /* destroy iovas */
3399 put_iova_domain(&domain->iovad); 3457 put_iova_domain(&domain->iovad);
3400 end = DOMAIN_MAX_ADDR(domain->gaw);
3401 end = end & (~VTD_PAGE_MASK);
3402 3458
3403 /* clear ptes */ 3459 /* clear ptes */
3404 dma_pte_clear_range(domain, 0, end); 3460 dma_pte_clear_range(domain, 0, DOMAIN_MAX_PFN(domain->gaw));
3405 3461
3406 /* free page tables */ 3462 /* free page tables */
3407 dma_pte_free_pagetable(domain, 0, end); 3463 dma_pte_free_pagetable(domain, 0, DOMAIN_MAX_PFN(domain->gaw));
3408 3464
3409 iommu_free_vm_domain(domain); 3465 iommu_free_vm_domain(domain);
3410 free_domain_mem(domain); 3466 free_domain_mem(domain);
@@ -3513,7 +3569,7 @@ static int intel_iommu_map_range(struct iommu_domain *domain,
3513 if ((iommu_prot & IOMMU_CACHE) && dmar_domain->iommu_snooping) 3569 if ((iommu_prot & IOMMU_CACHE) && dmar_domain->iommu_snooping)
3514 prot |= DMA_PTE_SNP; 3570 prot |= DMA_PTE_SNP;
3515 3571
3516 max_addr = (iova & VTD_PAGE_MASK) + VTD_PAGE_ALIGN(size); 3572 max_addr = iova + size;
3517 if (dmar_domain->max_addr < max_addr) { 3573 if (dmar_domain->max_addr < max_addr) {
3518 int min_agaw; 3574 int min_agaw;
3519 u64 end; 3575 u64 end;
@@ -3531,8 +3587,11 @@ static int intel_iommu_map_range(struct iommu_domain *domain,
3531 } 3587 }
3532 dmar_domain->max_addr = max_addr; 3588 dmar_domain->max_addr = max_addr;
3533 } 3589 }
3534 3590 /* Round up size to next multiple of PAGE_SIZE, if it and
3535 ret = domain_page_mapping(dmar_domain, iova, hpa, size, prot); 3591 the low bits of hpa would take us onto the next page */
3592 size = aligned_nrpages(hpa, size);
3593 ret = domain_pfn_mapping(dmar_domain, iova >> VTD_PAGE_SHIFT,
3594 hpa >> VTD_PAGE_SHIFT, size, prot);
3536 return ret; 3595 return ret;
3537} 3596}
3538 3597
@@ -3540,15 +3599,15 @@ static void intel_iommu_unmap_range(struct iommu_domain *domain,
3540 unsigned long iova, size_t size) 3599 unsigned long iova, size_t size)
3541{ 3600{
3542 struct dmar_domain *dmar_domain = domain->priv; 3601 struct dmar_domain *dmar_domain = domain->priv;
3543 dma_addr_t base;
3544 3602
3545 /* The address might not be aligned */ 3603 if (!size)
3546 base = iova & VTD_PAGE_MASK; 3604 return;
3547 size = VTD_PAGE_ALIGN(size); 3605
3548 dma_pte_clear_range(dmar_domain, base, base + size); 3606 dma_pte_clear_range(dmar_domain, iova >> VTD_PAGE_SHIFT,
3607 (iova + size - 1) >> VTD_PAGE_SHIFT);
3549 3608
3550 if (dmar_domain->max_addr == base + size) 3609 if (dmar_domain->max_addr == iova + size)
3551 dmar_domain->max_addr = base; 3610 dmar_domain->max_addr = iova;
3552} 3611}
3553 3612
3554static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, 3613static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
@@ -3558,7 +3617,7 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
3558 struct dma_pte *pte; 3617 struct dma_pte *pte;
3559 u64 phys = 0; 3618 u64 phys = 0;
3560 3619
3561 pte = addr_to_dma_pte(dmar_domain, iova); 3620 pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT);
3562 if (pte) 3621 if (pte)
3563 phys = dma_pte_addr(pte); 3622 phys = dma_pte_addr(pte);
3564 3623
diff --git a/drivers/pci/iova.c b/drivers/pci/iova.c
index 2287116e9822..46dd440e2315 100644
--- a/drivers/pci/iova.c
+++ b/drivers/pci/iova.c
@@ -1,9 +1,19 @@
1/* 1/*
2 * Copyright (c) 2006, Intel Corporation. 2 * Copyright © 2006-2009, Intel Corporation.
3 * 3 *
4 * This file is released under the GPLv2. 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
5 * 16 *
6 * Copyright (C) 2006-2008 Intel Corporation
7 * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 17 * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 */ 18 */
9 19
@@ -123,7 +133,15 @@ move_left:
123 /* Insert the new_iova into domain rbtree by holding writer lock */ 133 /* Insert the new_iova into domain rbtree by holding writer lock */
124 /* Add new node and rebalance tree. */ 134 /* Add new node and rebalance tree. */
125 { 135 {
126 struct rb_node **entry = &((prev)), *parent = NULL; 136 struct rb_node **entry, *parent = NULL;
137
138 /* If we have 'prev', it's a valid place to start the
139 insertion. Otherwise, start from the root. */
140 if (prev)
141 entry = &prev;
142 else
143 entry = &iovad->rbroot.rb_node;
144
127 /* Figure out where to put new node */ 145 /* Figure out where to put new node */
128 while (*entry) { 146 while (*entry) {
129 struct iova *this = container_of(*entry, 147 struct iova *this = container_of(*entry,
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index d9f06fbfa0bf..d986afb7032b 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -127,17 +127,23 @@ static inline __attribute_const__ u32 msi_enabled_mask(u16 control)
127 * reliably as devices without an INTx disable bit will then generate a 127 * reliably as devices without an INTx disable bit will then generate a
128 * level IRQ which will never be cleared. 128 * level IRQ which will never be cleared.
129 */ 129 */
130static void msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag) 130static u32 __msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
131{ 131{
132 u32 mask_bits = desc->masked; 132 u32 mask_bits = desc->masked;
133 133
134 if (!desc->msi_attrib.maskbit) 134 if (!desc->msi_attrib.maskbit)
135 return; 135 return 0;
136 136
137 mask_bits &= ~mask; 137 mask_bits &= ~mask;
138 mask_bits |= flag; 138 mask_bits |= flag;
139 pci_write_config_dword(desc->dev, desc->mask_pos, mask_bits); 139 pci_write_config_dword(desc->dev, desc->mask_pos, mask_bits);
140 desc->masked = mask_bits; 140
141 return mask_bits;
142}
143
144static void msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
145{
146 desc->masked = __msi_mask_irq(desc, mask, flag);
141} 147}
142 148
143/* 149/*
@@ -147,15 +153,21 @@ static void msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
147 * file. This saves a few milliseconds when initialising devices with lots 153 * file. This saves a few milliseconds when initialising devices with lots
148 * of MSI-X interrupts. 154 * of MSI-X interrupts.
149 */ 155 */
150static void msix_mask_irq(struct msi_desc *desc, u32 flag) 156static u32 __msix_mask_irq(struct msi_desc *desc, u32 flag)
151{ 157{
152 u32 mask_bits = desc->masked; 158 u32 mask_bits = desc->masked;
153 unsigned offset = desc->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + 159 unsigned offset = desc->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE +
154 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET; 160 PCI_MSIX_ENTRY_VECTOR_CTRL;
155 mask_bits &= ~1; 161 mask_bits &= ~1;
156 mask_bits |= flag; 162 mask_bits |= flag;
157 writel(mask_bits, desc->mask_base + offset); 163 writel(mask_bits, desc->mask_base + offset);
158 desc->masked = mask_bits; 164
165 return mask_bits;
166}
167
168static void msix_mask_irq(struct msi_desc *desc, u32 flag)
169{
170 desc->masked = __msix_mask_irq(desc, flag);
159} 171}
160 172
161static void msi_set_mask_bit(unsigned irq, u32 flag) 173static void msi_set_mask_bit(unsigned irq, u32 flag)
@@ -188,9 +200,9 @@ void read_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg)
188 void __iomem *base = entry->mask_base + 200 void __iomem *base = entry->mask_base +
189 entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE; 201 entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE;
190 202
191 msg->address_lo = readl(base + PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET); 203 msg->address_lo = readl(base + PCI_MSIX_ENTRY_LOWER_ADDR);
192 msg->address_hi = readl(base + PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET); 204 msg->address_hi = readl(base + PCI_MSIX_ENTRY_UPPER_ADDR);
193 msg->data = readl(base + PCI_MSIX_ENTRY_DATA_OFFSET); 205 msg->data = readl(base + PCI_MSIX_ENTRY_DATA);
194 } else { 206 } else {
195 struct pci_dev *dev = entry->dev; 207 struct pci_dev *dev = entry->dev;
196 int pos = entry->msi_attrib.pos; 208 int pos = entry->msi_attrib.pos;
@@ -225,11 +237,9 @@ void write_msi_msg_desc(struct irq_desc *desc, struct msi_msg *msg)
225 base = entry->mask_base + 237 base = entry->mask_base +
226 entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE; 238 entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE;
227 239
228 writel(msg->address_lo, 240 writel(msg->address_lo, base + PCI_MSIX_ENTRY_LOWER_ADDR);
229 base + PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET); 241 writel(msg->address_hi, base + PCI_MSIX_ENTRY_UPPER_ADDR);
230 writel(msg->address_hi, 242 writel(msg->data, base + PCI_MSIX_ENTRY_DATA);
231 base + PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET);
232 writel(msg->data, base + PCI_MSIX_ENTRY_DATA_OFFSET);
233 } else { 243 } else {
234 struct pci_dev *dev = entry->dev; 244 struct pci_dev *dev = entry->dev;
235 int pos = entry->msi_attrib.pos; 245 int pos = entry->msi_attrib.pos;
@@ -385,6 +395,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
385 /* Configure MSI capability structure */ 395 /* Configure MSI capability structure */
386 ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI); 396 ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI);
387 if (ret) { 397 if (ret) {
398 msi_mask_irq(entry, mask, ~mask);
388 msi_free_irqs(dev); 399 msi_free_irqs(dev);
389 return ret; 400 return ret;
390 } 401 }
@@ -439,8 +450,14 @@ static int msix_capability_init(struct pci_dev *dev,
439 450
440 for (i = 0; i < nvec; i++) { 451 for (i = 0; i < nvec; i++) {
441 entry = alloc_msi_entry(dev); 452 entry = alloc_msi_entry(dev);
442 if (!entry) 453 if (!entry) {
443 break; 454 if (!i)
455 iounmap(base);
456 else
457 msi_free_irqs(dev);
458 /* No enough memory. Don't try again */
459 return -ENOMEM;
460 }
444 461
445 j = entries[i].entry; 462 j = entries[i].entry;
446 entry->msi_attrib.is_msix = 1; 463 entry->msi_attrib.is_msix = 1;
@@ -487,7 +504,7 @@ static int msix_capability_init(struct pci_dev *dev,
487 set_irq_msi(entry->irq, entry); 504 set_irq_msi(entry->irq, entry);
488 j = entries[i].entry; 505 j = entries[i].entry;
489 entry->masked = readl(base + j * PCI_MSIX_ENTRY_SIZE + 506 entry->masked = readl(base + j * PCI_MSIX_ENTRY_SIZE +
490 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET); 507 PCI_MSIX_ENTRY_VECTOR_CTRL);
491 msix_mask_irq(entry, 1); 508 msix_mask_irq(entry, 1);
492 i++; 509 i++;
493 } 510 }
@@ -611,9 +628,11 @@ void pci_msi_shutdown(struct pci_dev *dev)
611 pci_intx_for_msi(dev, 1); 628 pci_intx_for_msi(dev, 1);
612 dev->msi_enabled = 0; 629 dev->msi_enabled = 0;
613 630
631 /* Return the device with MSI unmasked as initial states */
614 pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &ctrl); 632 pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &ctrl);
615 mask = msi_capable_mask(ctrl); 633 mask = msi_capable_mask(ctrl);
616 msi_mask_irq(desc, mask, ~mask); 634 /* Keep cached state to be restored */
635 __msi_mask_irq(desc, mask, ~mask);
617 636
618 /* Restore dev->irq to its default pin-assertion irq */ 637 /* Restore dev->irq to its default pin-assertion irq */
619 dev->irq = desc->msi_attrib.default_irq; 638 dev->irq = desc->msi_attrib.default_irq;
@@ -653,7 +672,6 @@ static int msi_free_irqs(struct pci_dev* dev)
653 672
654 list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) { 673 list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
655 if (entry->msi_attrib.is_msix) { 674 if (entry->msi_attrib.is_msix) {
656 msix_mask_irq(entry, 1);
657 if (list_is_last(&entry->list, &dev->msi_list)) 675 if (list_is_last(&entry->list, &dev->msi_list))
658 iounmap(entry->mask_base); 676 iounmap(entry->mask_base);
659 } 677 }
@@ -741,9 +759,17 @@ static void msix_free_all_irqs(struct pci_dev *dev)
741 759
742void pci_msix_shutdown(struct pci_dev* dev) 760void pci_msix_shutdown(struct pci_dev* dev)
743{ 761{
762 struct msi_desc *entry;
763
744 if (!pci_msi_enable || !dev || !dev->msix_enabled) 764 if (!pci_msi_enable || !dev || !dev->msix_enabled)
745 return; 765 return;
746 766
767 /* Return the device with MSI-X masked as initial states */
768 list_for_each_entry(entry, &dev->msi_list, list) {
769 /* Keep cached states to be restored */
770 __msix_mask_irq(entry, 1);
771 }
772
747 msix_set_enable(dev, 0); 773 msix_set_enable(dev, 0);
748 pci_intx_for_msi(dev, 1); 774 pci_intx_for_msi(dev, 1);
749 dev->msix_enabled = 0; 775 dev->msix_enabled = 0;
diff --git a/drivers/pci/msi.h b/drivers/pci/msi.h
index a0662842550b..de27c1cb5a2b 100644
--- a/drivers/pci/msi.h
+++ b/drivers/pci/msi.h
@@ -6,11 +6,11 @@
6#ifndef MSI_H 6#ifndef MSI_H
7#define MSI_H 7#define MSI_H
8 8
9#define PCI_MSIX_ENTRY_SIZE 16 9#define PCI_MSIX_ENTRY_SIZE 16
10#define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0 10#define PCI_MSIX_ENTRY_LOWER_ADDR 0
11#define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4 11#define PCI_MSIX_ENTRY_UPPER_ADDR 4
12#define PCI_MSIX_ENTRY_DATA_OFFSET 8 12#define PCI_MSIX_ENTRY_DATA 8
13#define PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET 12 13#define PCI_MSIX_ENTRY_VECTOR_CTRL 12
14 14
15#define msi_control_reg(base) (base + PCI_MSI_FLAGS) 15#define msi_control_reg(base) (base + PCI_MSI_FLAGS)
16#define msi_lower_address_reg(base) (base + PCI_MSI_ADDRESS_LO) 16#define msi_lower_address_reg(base) (base + PCI_MSI_ADDRESS_LO)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6c93af5ced18..dbd0f947f497 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1517,11 +1517,20 @@ void pci_enable_ari(struct pci_dev *dev)
1517 * 1517 *
1518 * Perform INTx swizzling for a device behind one level of bridge. This is 1518 * Perform INTx swizzling for a device behind one level of bridge. This is
1519 * required by section 9.1 of the PCI-to-PCI bridge specification for devices 1519 * required by section 9.1 of the PCI-to-PCI bridge specification for devices
1520 * behind bridges on add-in cards. 1520 * behind bridges on add-in cards. For devices with ARI enabled, the slot
1521 * number is always 0 (see the Implementation Note in section 2.2.8.1 of
1522 * the PCI Express Base Specification, Revision 2.1)
1521 */ 1523 */
1522u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin) 1524u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin)
1523{ 1525{
1524 return (((pin - 1) + PCI_SLOT(dev->devfn)) % 4) + 1; 1526 int slot;
1527
1528 if (pci_ari_enabled(dev->bus))
1529 slot = 0;
1530 else
1531 slot = PCI_SLOT(dev->devfn);
1532
1533 return (((pin - 1) + slot) % 4) + 1;
1525} 1534}
1526 1535
1527int 1536int
@@ -2171,7 +2180,7 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe)
2171 u16 ctrl; 2180 u16 ctrl;
2172 struct pci_dev *pdev; 2181 struct pci_dev *pdev;
2173 2182
2174 if (dev->subordinate) 2183 if (pci_is_root_bus(dev->bus) || dev->subordinate || !dev->bus->self)
2175 return -ENOTTY; 2184 return -ENOTTY;
2176 2185
2177 list_for_each_entry(pdev, &dev->bus->devices, bus_list) 2186 list_for_each_entry(pdev, &dev->bus->devices, bus_list)
diff --git a/drivers/pci/pcie/aer/ecrc.c b/drivers/pci/pcie/aer/ecrc.c
index ece97df4df6d..a928d8ab6bda 100644
--- a/drivers/pci/pcie/aer/ecrc.c
+++ b/drivers/pci/pcie/aer/ecrc.c
@@ -106,7 +106,7 @@ void pcie_set_ecrc_checking(struct pci_dev *dev)
106 disable_ecrc_checking(dev); 106 disable_ecrc_checking(dev);
107 break; 107 break;
108 case ECRC_POLICY_ON: 108 case ECRC_POLICY_ON:
109 enable_ecrc_checking(dev);; 109 enable_ecrc_checking(dev);
110 break; 110 break;
111 default: 111 default:
112 return; 112 return;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 56552d74abea..06b965623962 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1058,6 +1058,11 @@ static void __devinit quirk_no_ata_d3(struct pci_dev *pdev)
1058} 1058}
1059DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_ANY_ID, quirk_no_ata_d3); 1059DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_ANY_ID, quirk_no_ata_d3);
1060DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATI, PCI_ANY_ID, quirk_no_ata_d3); 1060DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATI, PCI_ANY_ID, quirk_no_ata_d3);
1061/* ALi loses some register settings that we cannot then restore */
1062DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID, quirk_no_ata_d3);
1063/* VIA comes back fine but we need to keep it alive or ACPI GTM failures
1064 occur when mode detecting */
1065DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_no_ata_d3);
1061 1066
1062/* This was originally an Alpha specific thing, but it really fits here. 1067/* This was originally an Alpha specific thing, but it really fits here.
1063 * The i82375 PCI/EISA bridge appears as non-classified. Fix that. 1068 * The i82375 PCI/EISA bridge appears as non-classified. Fix that.
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index eddb0748b0ea..8c02b6c53bdb 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -311,7 +311,7 @@ EXPORT_SYMBOL_GPL(pci_destroy_slot);
311#include <linux/pci_hotplug.h> 311#include <linux/pci_hotplug.h>
312/** 312/**
313 * pci_hp_create_link - create symbolic link to the hotplug driver module. 313 * pci_hp_create_link - create symbolic link to the hotplug driver module.
314 * @slot: struct pci_slot 314 * @pci_slot: struct pci_slot
315 * 315 *
316 * Helper function for pci_hotplug_core.c to create symbolic link to 316 * Helper function for pci_hotplug_core.c to create symbolic link to
317 * the hotplug driver module. 317 * the hotplug driver module.
@@ -334,7 +334,7 @@ EXPORT_SYMBOL_GPL(pci_hp_create_module_link);
334 334
335/** 335/**
336 * pci_hp_remove_link - remove symbolic link to the hotplug driver module. 336 * pci_hp_remove_link - remove symbolic link to the hotplug driver module.
337 * @slot: struct pci_slot 337 * @pci_slot: struct pci_slot
338 * 338 *
339 * Helper function for pci_hotplug_core.c to remove symbolic link to 339 * Helper function for pci_hotplug_core.c to remove symbolic link to
340 * the hotplug driver module. 340 * the hotplug driver module.
diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
index ec22284eed30..e1c1ec540893 100644
--- a/drivers/pci/syscall.c
+++ b/drivers/pci/syscall.c
@@ -9,7 +9,6 @@
9 9
10#include <linux/errno.h> 10#include <linux/errno.h>
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/smp_lock.h>
13#include <linux/syscalls.h> 12#include <linux/syscalls.h>
14#include <asm/uaccess.h> 13#include <asm/uaccess.h>
15#include "pci.h" 14#include "pci.h"
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index 9ad97ea836e8..8eb04230fec7 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -472,7 +472,8 @@ static int __init init_tcic(void)
472 init_timer(&poll_timer); 472 init_timer(&poll_timer);
473 473
474 /* Build interrupt mask */ 474 /* Build interrupt mask */
475 printk(", %d sockets\n" KERN_INFO " irq list (", sockets); 475 printk(KERN_CONT ", %d sockets\n", sockets);
476 printk(KERN_INFO " irq list (");
476 if (irq_list_count == 0) 477 if (irq_list_count == 0)
477 mask = irq_mask; 478 mask = irq_mask;
478 else 479 else
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c
index 659421d0ca46..d4ad50d737b0 100644
--- a/drivers/pcmcia/vrc4171_card.c
+++ b/drivers/pcmcia/vrc4171_card.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vrc4171_card.c, NEC VRC4171 Card Controller driver for Socket Services. 2 * vrc4171_card.c, NEC VRC4171 Card Controller driver for Socket Services.
3 * 3 *
4 * Copyright (C) 2003-2005 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
32#include "i82365.h" 32#include "i82365.h"
33 33
34MODULE_DESCRIPTION("NEC VRC4171 Card Controllers driver for Socket Services"); 34MODULE_DESCRIPTION("NEC VRC4171 Card Controllers driver for Socket Services");
35MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>"); 35MODULE_AUTHOR("Yoichi Yuasa <yuasa@linux-mips.org>");
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37 37
38#define CARD_MAX_SLOTS 2 38#define CARD_MAX_SLOTS 2
diff --git a/drivers/pcmcia/vrc4173_cardu.c b/drivers/pcmcia/vrc4173_cardu.c
index 812f038e9bda..9b3c15827e5c 100644
--- a/drivers/pcmcia/vrc4173_cardu.c
+++ b/drivers/pcmcia/vrc4173_cardu.c
@@ -6,7 +6,7 @@
6 * NEC VRC4173 CARDU driver for Socket Services 6 * NEC VRC4173 CARDU driver for Socket Services
7 * (This device doesn't support CardBus. it is supporting only 16bit PC Card.) 7 * (This device doesn't support CardBus. it is supporting only 16bit PC Card.)
8 * 8 *
9 * Copyright 2002,2003 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 9 * Copyright 2002,2003 Yoichi Yuasa <yuasa@linux-mips.org>
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify it 11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the 12 * under the terms of the GNU General Public License as published by the
@@ -41,7 +41,7 @@
41#include "vrc4173_cardu.h" 41#include "vrc4173_cardu.h"
42 42
43MODULE_DESCRIPTION("NEC VRC4173 CARDU driver for Socket Services"); 43MODULE_DESCRIPTION("NEC VRC4173 CARDU driver for Socket Services");
44MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>"); 44MODULE_AUTHOR("Yoichi Yuasa <yuasa@linux-mips.org>");
45MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
46 46
47static int vrc4173_cardu_slots; 47static int vrc4173_cardu_slots;
diff --git a/drivers/pcmcia/vrc4173_cardu.h b/drivers/pcmcia/vrc4173_cardu.h
index 7d77c74120c1..a7d96018ed8d 100644
--- a/drivers/pcmcia/vrc4173_cardu.h
+++ b/drivers/pcmcia/vrc4173_cardu.h
@@ -5,7 +5,7 @@
5 * BRIEF MODULE DESCRIPTION 5 * BRIEF MODULE DESCRIPTION
6 * Include file for NEC VRC4173 CARDU. 6 * Include file for NEC VRC4173 CARDU.
7 * 7 *
8 * Copyright 2002 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 8 * Copyright 2002 Yoichi Yuasa <yuasa@linux-mips.org>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 11 * under the terms of the GNU General Public License as published by the
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 7232fe7104aa..46dad12f952f 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -355,6 +355,7 @@ config EEEPC_LAPTOP
355 depends on INPUT 355 depends on INPUT
356 depends on EXPERIMENTAL 356 depends on EXPERIMENTAL
357 depends on RFKILL || RFKILL = n 357 depends on RFKILL || RFKILL = n
358 depends on HOTPLUG_PCI
358 select BACKLIGHT_CLASS_DEVICE 359 select BACKLIGHT_CLASS_DEVICE
359 select HWMON 360 select HWMON
360 ---help--- 361 ---help---
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 4207b26ff990..ec560f16d720 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -16,6 +16,8 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 */ 17 */
18 18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
19#include <linux/kernel.h> 21#include <linux/kernel.h>
20#include <linux/module.h> 22#include <linux/module.h>
21#include <linux/init.h> 23#include <linux/init.h>
@@ -31,6 +33,7 @@
31#include <linux/input.h> 33#include <linux/input.h>
32#include <linux/rfkill.h> 34#include <linux/rfkill.h>
33#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/pci_hotplug.h>
34 37
35#define EEEPC_LAPTOP_VERSION "0.1" 38#define EEEPC_LAPTOP_VERSION "0.1"
36 39
@@ -40,11 +43,6 @@
40#define EEEPC_HOTK_DEVICE_NAME "Hotkey" 43#define EEEPC_HOTK_DEVICE_NAME "Hotkey"
41#define EEEPC_HOTK_HID "ASUS010" 44#define EEEPC_HOTK_HID "ASUS010"
42 45
43#define EEEPC_LOG EEEPC_HOTK_FILE ": "
44#define EEEPC_ERR KERN_ERR EEEPC_LOG
45#define EEEPC_WARNING KERN_WARNING EEEPC_LOG
46#define EEEPC_NOTICE KERN_NOTICE EEEPC_LOG
47#define EEEPC_INFO KERN_INFO EEEPC_LOG
48 46
49/* 47/*
50 * Definitions for Asus EeePC 48 * Definitions for Asus EeePC
@@ -141,8 +139,10 @@ struct eeepc_hotk {
141 u16 event_count[128]; /* count for each event */ 139 u16 event_count[128]; /* count for each event */
142 struct input_dev *inputdev; 140 struct input_dev *inputdev;
143 u16 *keycode_map; 141 u16 *keycode_map;
144 struct rfkill *eeepc_wlan_rfkill; 142 struct rfkill *wlan_rfkill;
145 struct rfkill *eeepc_bluetooth_rfkill; 143 struct rfkill *bluetooth_rfkill;
144 struct rfkill *wwan3g_rfkill;
145 struct hotplug_slot *hotplug_slot;
146}; 146};
147 147
148/* The actual device the driver binds to */ 148/* The actual device the driver binds to */
@@ -213,6 +213,15 @@ static struct acpi_driver eeepc_hotk_driver = {
213 }, 213 },
214}; 214};
215 215
216/* PCI hotplug ops */
217static int eeepc_get_adapter_status(struct hotplug_slot *slot, u8 *value);
218
219static struct hotplug_slot_ops eeepc_hotplug_slot_ops = {
220 .owner = THIS_MODULE,
221 .get_adapter_status = eeepc_get_adapter_status,
222 .get_power_status = eeepc_get_adapter_status,
223};
224
216/* The backlight device /sys/class/backlight */ 225/* The backlight device /sys/class/backlight */
217static struct backlight_device *eeepc_backlight_device; 226static struct backlight_device *eeepc_backlight_device;
218 227
@@ -274,20 +283,20 @@ static int set_acpi(int cm, int value)
274 if (method == NULL) 283 if (method == NULL)
275 return -ENODEV; 284 return -ENODEV;
276 if (write_acpi_int(ehotk->handle, method, value, NULL)) 285 if (write_acpi_int(ehotk->handle, method, value, NULL))
277 printk(EEEPC_WARNING "Error writing %s\n", method); 286 pr_warning("Error writing %s\n", method);
278 } 287 }
279 return 0; 288 return 0;
280} 289}
281 290
282static int get_acpi(int cm) 291static int get_acpi(int cm)
283{ 292{
284 int value = -1; 293 int value = -ENODEV;
285 if ((ehotk->cm_supported & (0x1 << cm))) { 294 if ((ehotk->cm_supported & (0x1 << cm))) {
286 const char *method = cm_getv[cm]; 295 const char *method = cm_getv[cm];
287 if (method == NULL) 296 if (method == NULL)
288 return -ENODEV; 297 return -ENODEV;
289 if (read_acpi_int(ehotk->handle, method, &value)) 298 if (read_acpi_int(ehotk->handle, method, &value))
290 printk(EEEPC_WARNING "Error reading %s\n", method); 299 pr_warning("Error reading %s\n", method);
291 } 300 }
292 return value; 301 return value;
293} 302}
@@ -359,13 +368,19 @@ static ssize_t store_sys_acpi(int cm, const char *buf, size_t count)
359 368
360 rv = parse_arg(buf, count, &value); 369 rv = parse_arg(buf, count, &value);
361 if (rv > 0) 370 if (rv > 0)
362 set_acpi(cm, value); 371 value = set_acpi(cm, value);
372 if (value < 0)
373 return value;
363 return rv; 374 return rv;
364} 375}
365 376
366static ssize_t show_sys_acpi(int cm, char *buf) 377static ssize_t show_sys_acpi(int cm, char *buf)
367{ 378{
368 return sprintf(buf, "%d\n", get_acpi(cm)); 379 int value = get_acpi(cm);
380
381 if (value < 0)
382 return value;
383 return sprintf(buf, "%d\n", value);
369} 384}
370 385
371#define EEEPC_CREATE_DEVICE_ATTR(_name, _cm) \ 386#define EEEPC_CREATE_DEVICE_ATTR(_name, _cm) \
@@ -539,6 +554,28 @@ static int eeepc_setkeycode(struct input_dev *dev, int scancode, int keycode)
539 return -EINVAL; 554 return -EINVAL;
540} 555}
541 556
557static void cmsg_quirk(int cm, const char *name)
558{
559 int dummy;
560
561 /* Some BIOSes do not report cm although it is avaliable.
562 Check if cm_getv[cm] works and, if yes, assume cm should be set. */
563 if (!(ehotk->cm_supported & (1 << cm))
564 && !read_acpi_int(ehotk->handle, cm_getv[cm], &dummy)) {
565 pr_info("%s (%x) not reported by BIOS,"
566 " enabling anyway\n", name, 1 << cm);
567 ehotk->cm_supported |= 1 << cm;
568 }
569}
570
571static void cmsg_quirks(void)
572{
573 cmsg_quirk(CM_ASL_LID, "LID");
574 cmsg_quirk(CM_ASL_TYPE, "TYPE");
575 cmsg_quirk(CM_ASL_PANELPOWER, "PANELPOWER");
576 cmsg_quirk(CM_ASL_TPD, "TPD");
577}
578
542static int eeepc_hotk_check(void) 579static int eeepc_hotk_check(void)
543{ 580{
544 const struct key_entry *key; 581 const struct key_entry *key;
@@ -551,26 +588,24 @@ static int eeepc_hotk_check(void)
551 if (ehotk->device->status.present) { 588 if (ehotk->device->status.present) {
552 if (write_acpi_int(ehotk->handle, "INIT", ehotk->init_flag, 589 if (write_acpi_int(ehotk->handle, "INIT", ehotk->init_flag,
553 &buffer)) { 590 &buffer)) {
554 printk(EEEPC_ERR "Hotkey initialization failed\n"); 591 pr_err("Hotkey initialization failed\n");
555 return -ENODEV; 592 return -ENODEV;
556 } else { 593 } else {
557 printk(EEEPC_NOTICE "Hotkey init flags 0x%x\n", 594 pr_notice("Hotkey init flags 0x%x\n", ehotk->init_flag);
558 ehotk->init_flag);
559 } 595 }
560 /* get control methods supported */ 596 /* get control methods supported */
561 if (read_acpi_int(ehotk->handle, "CMSG" 597 if (read_acpi_int(ehotk->handle, "CMSG"
562 , &ehotk->cm_supported)) { 598 , &ehotk->cm_supported)) {
563 printk(EEEPC_ERR 599 pr_err("Get control methods supported failed\n");
564 "Get control methods supported failed\n");
565 return -ENODEV; 600 return -ENODEV;
566 } else { 601 } else {
567 printk(EEEPC_INFO 602 cmsg_quirks();
568 "Get control methods supported: 0x%x\n", 603 pr_info("Get control methods supported: 0x%x\n",
569 ehotk->cm_supported); 604 ehotk->cm_supported);
570 } 605 }
571 ehotk->inputdev = input_allocate_device(); 606 ehotk->inputdev = input_allocate_device();
572 if (!ehotk->inputdev) { 607 if (!ehotk->inputdev) {
573 printk(EEEPC_INFO "Unable to allocate input device\n"); 608 pr_info("Unable to allocate input device\n");
574 return 0; 609 return 0;
575 } 610 }
576 ehotk->inputdev->name = "Asus EeePC extra buttons"; 611 ehotk->inputdev->name = "Asus EeePC extra buttons";
@@ -589,12 +624,12 @@ static int eeepc_hotk_check(void)
589 } 624 }
590 result = input_register_device(ehotk->inputdev); 625 result = input_register_device(ehotk->inputdev);
591 if (result) { 626 if (result) {
592 printk(EEEPC_INFO "Unable to register input device\n"); 627 pr_info("Unable to register input device\n");
593 input_free_device(ehotk->inputdev); 628 input_free_device(ehotk->inputdev);
594 return 0; 629 return 0;
595 } 630 }
596 } else { 631 } else {
597 printk(EEEPC_ERR "Hotkey device not present, aborting\n"); 632 pr_err("Hotkey device not present, aborting\n");
598 return -EINVAL; 633 return -EINVAL;
599 } 634 }
600 return 0; 635 return 0;
@@ -612,6 +647,19 @@ static int notify_brn(void)
612 return -1; 647 return -1;
613} 648}
614 649
650static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
651 u8 *value)
652{
653 int val = get_acpi(CM_ASL_WLAN);
654
655 if (val == 1 || val == 0)
656 *value = val;
657 else
658 return -EINVAL;
659
660 return 0;
661}
662
615static void eeepc_rfkill_hotplug(void) 663static void eeepc_rfkill_hotplug(void)
616{ 664{
617 struct pci_dev *dev; 665 struct pci_dev *dev;
@@ -619,7 +667,7 @@ static void eeepc_rfkill_hotplug(void)
619 bool blocked; 667 bool blocked;
620 668
621 if (!bus) { 669 if (!bus) {
622 printk(EEEPC_WARNING "Unable to find PCI bus 1?\n"); 670 pr_warning("Unable to find PCI bus 1?\n");
623 return; 671 return;
624 } 672 }
625 673
@@ -635,7 +683,7 @@ static void eeepc_rfkill_hotplug(void)
635 if (dev) { 683 if (dev) {
636 pci_bus_assign_resources(bus); 684 pci_bus_assign_resources(bus);
637 if (pci_bus_add_device(dev)) 685 if (pci_bus_add_device(dev))
638 printk(EEEPC_ERR "Unable to hotplug wifi\n"); 686 pr_err("Unable to hotplug wifi\n");
639 } 687 }
640 } else { 688 } else {
641 dev = pci_get_slot(bus, 0); 689 dev = pci_get_slot(bus, 0);
@@ -645,7 +693,7 @@ static void eeepc_rfkill_hotplug(void)
645 } 693 }
646 } 694 }
647 695
648 rfkill_set_sw_state(ehotk->eeepc_wlan_rfkill, blocked); 696 rfkill_set_sw_state(ehotk->wlan_rfkill, blocked);
649} 697}
650 698
651static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) 699static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
@@ -718,8 +766,7 @@ static int eeepc_register_rfkill_notifier(char *node)
718 eeepc_rfkill_notify, 766 eeepc_rfkill_notify,
719 NULL); 767 NULL);
720 if (ACPI_FAILURE(status)) 768 if (ACPI_FAILURE(status))
721 printk(EEEPC_WARNING 769 pr_warning("Failed to register notify on %s\n", node);
722 "Failed to register notify on %s\n", node);
723 } else 770 } else
724 return -ENODEV; 771 return -ENODEV;
725 772
@@ -738,19 +785,66 @@ static void eeepc_unregister_rfkill_notifier(char *node)
738 ACPI_SYSTEM_NOTIFY, 785 ACPI_SYSTEM_NOTIFY,
739 eeepc_rfkill_notify); 786 eeepc_rfkill_notify);
740 if (ACPI_FAILURE(status)) 787 if (ACPI_FAILURE(status))
741 printk(EEEPC_ERR 788 pr_err("Error removing rfkill notify handler %s\n",
742 "Error removing rfkill notify handler %s\n",
743 node); 789 node);
744 } 790 }
745} 791}
746 792
793static void eeepc_cleanup_pci_hotplug(struct hotplug_slot *hotplug_slot)
794{
795 kfree(hotplug_slot->info);
796 kfree(hotplug_slot);
797}
798
799static int eeepc_setup_pci_hotplug(void)
800{
801 int ret = -ENOMEM;
802 struct pci_bus *bus = pci_find_bus(0, 1);
803
804 if (!bus) {
805 pr_err("Unable to find wifi PCI bus\n");
806 return -ENODEV;
807 }
808
809 ehotk->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
810 if (!ehotk->hotplug_slot)
811 goto error_slot;
812
813 ehotk->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
814 GFP_KERNEL);
815 if (!ehotk->hotplug_slot->info)
816 goto error_info;
817
818 ehotk->hotplug_slot->private = ehotk;
819 ehotk->hotplug_slot->release = &eeepc_cleanup_pci_hotplug;
820 ehotk->hotplug_slot->ops = &eeepc_hotplug_slot_ops;
821 eeepc_get_adapter_status(ehotk->hotplug_slot,
822 &ehotk->hotplug_slot->info->adapter_status);
823
824 ret = pci_hp_register(ehotk->hotplug_slot, bus, 0, "eeepc-wifi");
825 if (ret) {
826 pr_err("Unable to register hotplug slot - %d\n", ret);
827 goto error_register;
828 }
829
830 return 0;
831
832error_register:
833 kfree(ehotk->hotplug_slot->info);
834error_info:
835 kfree(ehotk->hotplug_slot);
836 ehotk->hotplug_slot = NULL;
837error_slot:
838 return ret;
839}
840
747static int eeepc_hotk_add(struct acpi_device *device) 841static int eeepc_hotk_add(struct acpi_device *device)
748{ 842{
749 int result; 843 int result;
750 844
751 if (!device) 845 if (!device)
752 return -EINVAL; 846 return -EINVAL;
753 printk(EEEPC_NOTICE EEEPC_HOTK_NAME "\n"); 847 pr_notice(EEEPC_HOTK_NAME "\n");
754 ehotk = kzalloc(sizeof(struct eeepc_hotk), GFP_KERNEL); 848 ehotk = kzalloc(sizeof(struct eeepc_hotk), GFP_KERNEL);
755 if (!ehotk) 849 if (!ehotk)
756 return -ENOMEM; 850 return -ENOMEM;
@@ -764,53 +858,8 @@ static int eeepc_hotk_add(struct acpi_device *device)
764 if (result) 858 if (result)
765 goto ehotk_fail; 859 goto ehotk_fail;
766 860
767 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6");
768 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7");
769
770 if (get_acpi(CM_ASL_WLAN) != -1) {
771 ehotk->eeepc_wlan_rfkill = rfkill_alloc("eeepc-wlan",
772 &device->dev,
773 RFKILL_TYPE_WLAN,
774 &eeepc_rfkill_ops,
775 (void *)CM_ASL_WLAN);
776
777 if (!ehotk->eeepc_wlan_rfkill)
778 goto wlan_fail;
779
780 rfkill_init_sw_state(ehotk->eeepc_wlan_rfkill,
781 get_acpi(CM_ASL_WLAN) != 1);
782 result = rfkill_register(ehotk->eeepc_wlan_rfkill);
783 if (result)
784 goto wlan_fail;
785 }
786
787 if (get_acpi(CM_ASL_BLUETOOTH) != -1) {
788 ehotk->eeepc_bluetooth_rfkill =
789 rfkill_alloc("eeepc-bluetooth",
790 &device->dev,
791 RFKILL_TYPE_BLUETOOTH,
792 &eeepc_rfkill_ops,
793 (void *)CM_ASL_BLUETOOTH);
794
795 if (!ehotk->eeepc_bluetooth_rfkill)
796 goto bluetooth_fail;
797
798 rfkill_init_sw_state(ehotk->eeepc_bluetooth_rfkill,
799 get_acpi(CM_ASL_BLUETOOTH) != 1);
800 result = rfkill_register(ehotk->eeepc_bluetooth_rfkill);
801 if (result)
802 goto bluetooth_fail;
803 }
804
805 return 0; 861 return 0;
806 862
807 bluetooth_fail:
808 rfkill_destroy(ehotk->eeepc_bluetooth_rfkill);
809 rfkill_unregister(ehotk->eeepc_wlan_rfkill);
810 wlan_fail:
811 rfkill_destroy(ehotk->eeepc_wlan_rfkill);
812 eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
813 eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
814 ehotk_fail: 863 ehotk_fail:
815 kfree(ehotk); 864 kfree(ehotk);
816 ehotk = NULL; 865 ehotk = NULL;
@@ -823,16 +872,13 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type)
823 if (!device || !acpi_driver_data(device)) 872 if (!device || !acpi_driver_data(device))
824 return -EINVAL; 873 return -EINVAL;
825 874
826 eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
827 eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
828
829 kfree(ehotk); 875 kfree(ehotk);
830 return 0; 876 return 0;
831} 877}
832 878
833static int eeepc_hotk_resume(struct acpi_device *device) 879static int eeepc_hotk_resume(struct acpi_device *device)
834{ 880{
835 if (ehotk->eeepc_wlan_rfkill) { 881 if (ehotk->wlan_rfkill) {
836 bool wlan; 882 bool wlan;
837 883
838 /* Workaround - it seems that _PTS disables the wireless 884 /* Workaround - it seems that _PTS disables the wireless
@@ -844,14 +890,13 @@ static int eeepc_hotk_resume(struct acpi_device *device)
844 wlan = get_acpi(CM_ASL_WLAN); 890 wlan = get_acpi(CM_ASL_WLAN);
845 set_acpi(CM_ASL_WLAN, wlan); 891 set_acpi(CM_ASL_WLAN, wlan);
846 892
847 rfkill_set_sw_state(ehotk->eeepc_wlan_rfkill, 893 rfkill_set_sw_state(ehotk->wlan_rfkill, wlan != 1);
848 wlan != 1);
849 894
850 eeepc_rfkill_hotplug(); 895 eeepc_rfkill_hotplug();
851 } 896 }
852 897
853 if (ehotk->eeepc_bluetooth_rfkill) 898 if (ehotk->bluetooth_rfkill)
854 rfkill_set_sw_state(ehotk->eeepc_bluetooth_rfkill, 899 rfkill_set_sw_state(ehotk->bluetooth_rfkill,
855 get_acpi(CM_ASL_BLUETOOTH) != 1); 900 get_acpi(CM_ASL_BLUETOOTH) != 1);
856 901
857 return 0; 902 return 0;
@@ -973,10 +1018,16 @@ static void eeepc_backlight_exit(void)
973 1018
974static void eeepc_rfkill_exit(void) 1019static void eeepc_rfkill_exit(void)
975{ 1020{
976 if (ehotk->eeepc_wlan_rfkill) 1021 eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
977 rfkill_unregister(ehotk->eeepc_wlan_rfkill); 1022 eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
978 if (ehotk->eeepc_bluetooth_rfkill) 1023 if (ehotk->wlan_rfkill)
979 rfkill_unregister(ehotk->eeepc_bluetooth_rfkill); 1024 rfkill_unregister(ehotk->wlan_rfkill);
1025 if (ehotk->bluetooth_rfkill)
1026 rfkill_unregister(ehotk->bluetooth_rfkill);
1027 if (ehotk->wwan3g_rfkill)
1028 rfkill_unregister(ehotk->wwan3g_rfkill);
1029 if (ehotk->hotplug_slot)
1030 pci_hp_deregister(ehotk->hotplug_slot);
980} 1031}
981 1032
982static void eeepc_input_exit(void) 1033static void eeepc_input_exit(void)
@@ -1011,6 +1062,75 @@ static void __exit eeepc_laptop_exit(void)
1011 platform_driver_unregister(&platform_driver); 1062 platform_driver_unregister(&platform_driver);
1012} 1063}
1013 1064
1065static int eeepc_new_rfkill(struct rfkill **rfkill,
1066 const char *name, struct device *dev,
1067 enum rfkill_type type, int cm)
1068{
1069 int result;
1070
1071 result = get_acpi(cm);
1072 if (result < 0)
1073 return result;
1074
1075 *rfkill = rfkill_alloc(name, dev, type,
1076 &eeepc_rfkill_ops, (void *)(unsigned long)cm);
1077
1078 if (!*rfkill)
1079 return -EINVAL;
1080
1081 rfkill_init_sw_state(*rfkill, get_acpi(cm) != 1);
1082 result = rfkill_register(*rfkill);
1083 if (result) {
1084 rfkill_destroy(*rfkill);
1085 *rfkill = NULL;
1086 return result;
1087 }
1088 return 0;
1089}
1090
1091
1092static int eeepc_rfkill_init(struct device *dev)
1093{
1094 int result = 0;
1095
1096 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6");
1097 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7");
1098
1099 result = eeepc_new_rfkill(&ehotk->wlan_rfkill,
1100 "eeepc-wlan", dev,
1101 RFKILL_TYPE_WLAN, CM_ASL_WLAN);
1102
1103 if (result && result != -ENODEV)
1104 goto exit;
1105
1106 result = eeepc_new_rfkill(&ehotk->bluetooth_rfkill,
1107 "eeepc-bluetooth", dev,
1108 RFKILL_TYPE_BLUETOOTH, CM_ASL_BLUETOOTH);
1109
1110 if (result && result != -ENODEV)
1111 goto exit;
1112
1113 result = eeepc_new_rfkill(&ehotk->wwan3g_rfkill,
1114 "eeepc-wwan3g", dev,
1115 RFKILL_TYPE_WWAN, CM_ASL_3G);
1116
1117 if (result && result != -ENODEV)
1118 goto exit;
1119
1120 result = eeepc_setup_pci_hotplug();
1121 /*
1122 * If we get -EBUSY then something else is handling the PCI hotplug -
1123 * don't fail in this case
1124 */
1125 if (result == -EBUSY)
1126 result = 0;
1127
1128exit:
1129 if (result && result != -ENODEV)
1130 eeepc_rfkill_exit();
1131 return result;
1132}
1133
1014static int eeepc_backlight_init(struct device *dev) 1134static int eeepc_backlight_init(struct device *dev)
1015{ 1135{
1016 struct backlight_device *bd; 1136 struct backlight_device *bd;
@@ -1018,8 +1138,7 @@ static int eeepc_backlight_init(struct device *dev)
1018 bd = backlight_device_register(EEEPC_HOTK_FILE, dev, 1138 bd = backlight_device_register(EEEPC_HOTK_FILE, dev,
1019 NULL, &eeepcbl_ops); 1139 NULL, &eeepcbl_ops);
1020 if (IS_ERR(bd)) { 1140 if (IS_ERR(bd)) {
1021 printk(EEEPC_ERR 1141 pr_err("Could not register eeepc backlight device\n");
1022 "Could not register eeepc backlight device\n");
1023 eeepc_backlight_device = NULL; 1142 eeepc_backlight_device = NULL;
1024 return PTR_ERR(bd); 1143 return PTR_ERR(bd);
1025 } 1144 }
@@ -1038,8 +1157,7 @@ static int eeepc_hwmon_init(struct device *dev)
1038 1157
1039 hwmon = hwmon_device_register(dev); 1158 hwmon = hwmon_device_register(dev);
1040 if (IS_ERR(hwmon)) { 1159 if (IS_ERR(hwmon)) {
1041 printk(EEEPC_ERR 1160 pr_err("Could not register eeepc hwmon device\n");
1042 "Could not register eeepc hwmon device\n");
1043 eeepc_hwmon_device = NULL; 1161 eeepc_hwmon_device = NULL;
1044 return PTR_ERR(hwmon); 1162 return PTR_ERR(hwmon);
1045 } 1163 }
@@ -1065,19 +1183,6 @@ static int __init eeepc_laptop_init(void)
1065 acpi_bus_unregister_driver(&eeepc_hotk_driver); 1183 acpi_bus_unregister_driver(&eeepc_hotk_driver);
1066 return -ENODEV; 1184 return -ENODEV;
1067 } 1185 }
1068 dev = acpi_get_physical_device(ehotk->device->handle);
1069
1070 if (!acpi_video_backlight_support()) {
1071 result = eeepc_backlight_init(dev);
1072 if (result)
1073 goto fail_backlight;
1074 } else
1075 printk(EEEPC_INFO "Backlight controlled by ACPI video "
1076 "driver\n");
1077
1078 result = eeepc_hwmon_init(dev);
1079 if (result)
1080 goto fail_hwmon;
1081 1186
1082 eeepc_enable_camera(); 1187 eeepc_enable_camera();
1083 1188
@@ -1097,7 +1202,33 @@ static int __init eeepc_laptop_init(void)
1097 &platform_attribute_group); 1202 &platform_attribute_group);
1098 if (result) 1203 if (result)
1099 goto fail_sysfs; 1204 goto fail_sysfs;
1205
1206 dev = &platform_device->dev;
1207
1208 if (!acpi_video_backlight_support()) {
1209 result = eeepc_backlight_init(dev);
1210 if (result)
1211 goto fail_backlight;
1212 } else
1213 pr_info("Backlight controlled by ACPI video "
1214 "driver\n");
1215
1216 result = eeepc_hwmon_init(dev);
1217 if (result)
1218 goto fail_hwmon;
1219
1220 result = eeepc_rfkill_init(dev);
1221 if (result)
1222 goto fail_rfkill;
1223
1100 return 0; 1224 return 0;
1225fail_rfkill:
1226 eeepc_hwmon_exit();
1227fail_hwmon:
1228 eeepc_backlight_exit();
1229fail_backlight:
1230 sysfs_remove_group(&platform_device->dev.kobj,
1231 &platform_attribute_group);
1101fail_sysfs: 1232fail_sysfs:
1102 platform_device_del(platform_device); 1233 platform_device_del(platform_device);
1103fail_platform_device2: 1234fail_platform_device2:
@@ -1105,12 +1236,7 @@ fail_platform_device2:
1105fail_platform_device1: 1236fail_platform_device1:
1106 platform_driver_unregister(&platform_driver); 1237 platform_driver_unregister(&platform_driver);
1107fail_platform_driver: 1238fail_platform_driver:
1108 eeepc_hwmon_exit();
1109fail_hwmon:
1110 eeepc_backlight_exit();
1111fail_backlight:
1112 eeepc_input_exit(); 1239 eeepc_input_exit();
1113 eeepc_rfkill_exit();
1114 return result; 1240 return result;
1115} 1241}
1116 1242
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 4ac2311c00af..ca508564a181 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -171,7 +171,7 @@ static int hp_wmi_tablet_state(void)
171static int hp_wmi_set_block(void *data, bool blocked) 171static int hp_wmi_set_block(void *data, bool blocked)
172{ 172{
173 unsigned long b = (unsigned long) data; 173 unsigned long b = (unsigned long) data;
174 int query = BIT(b + 8) | ((!!blocked) << b); 174 int query = BIT(b + 8) | ((!blocked) << b);
175 175
176 return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query); 176 return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);
177} 177}
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index 8bde92126d34..b787335a8419 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -33,14 +33,14 @@ static enum power_supply_property *prop;
33 33
34static unsigned long wm97xx_read_bat(struct power_supply *bat_ps) 34static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
35{ 35{
36 return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data, 36 return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev->parent),
37 pdata->batt_aux) * pdata->batt_mult / 37 pdata->batt_aux) * pdata->batt_mult /
38 pdata->batt_div; 38 pdata->batt_div;
39} 39}
40 40
41static unsigned long wm97xx_read_temp(struct power_supply *bat_ps) 41static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
42{ 42{
43 return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data, 43 return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev->parent),
44 pdata->temp_aux) * pdata->temp_mult / 44 pdata->temp_aux) * pdata->temp_mult /
45 pdata->temp_div; 45 pdata->temp_div;
46} 46}
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index aafd3e6ebb0d..a118eb0f1e67 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Blackfin On-Chip Real Time Clock Driver 2 * Blackfin On-Chip Real Time Clock Driver
3 * Supports BF52[257]/BF53[123]/BF53[467]/BF54[24789] 3 * Supports BF51x/BF52x/BF53[123]/BF53[467]/BF54x
4 * 4 *
5 * Copyright 2004-2008 Analog Devices Inc. 5 * Copyright 2004-2009 Analog Devices Inc.
6 * 6 *
7 * Enter bugs at http://blackfin.uclinux.org/ 7 * Enter bugs at http://blackfin.uclinux.org/
8 * 8 *
@@ -363,7 +363,7 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev)
363 struct bfin_rtc *rtc; 363 struct bfin_rtc *rtc;
364 struct device *dev = &pdev->dev; 364 struct device *dev = &pdev->dev;
365 int ret = 0; 365 int ret = 0;
366 unsigned long timeout; 366 unsigned long timeout = jiffies + HZ;
367 367
368 dev_dbg_stamp(dev); 368 dev_dbg_stamp(dev);
369 369
@@ -374,32 +374,32 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev)
374 platform_set_drvdata(pdev, rtc); 374 platform_set_drvdata(pdev, rtc);
375 device_init_wakeup(dev, 1); 375 device_init_wakeup(dev, 1);
376 376
377 /* Register our RTC with the RTC framework */
378 rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops,
379 THIS_MODULE);
380 if (unlikely(IS_ERR(rtc->rtc_dev))) {
381 ret = PTR_ERR(rtc->rtc_dev);
382 goto err;
383 }
384
377 /* Grab the IRQ and init the hardware */ 385 /* Grab the IRQ and init the hardware */
378 ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, IRQF_SHARED, pdev->name, dev); 386 ret = request_irq(IRQ_RTC, bfin_rtc_interrupt, IRQF_SHARED, pdev->name, dev);
379 if (unlikely(ret)) 387 if (unlikely(ret))
380 goto err; 388 goto err_reg;
381 /* sometimes the bootloader touched things, but the write complete was not 389 /* sometimes the bootloader touched things, but the write complete was not
382 * enabled, so let's just do a quick timeout here since the IRQ will not fire ... 390 * enabled, so let's just do a quick timeout here since the IRQ will not fire ...
383 */ 391 */
384 timeout = jiffies + HZ;
385 while (bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_PENDING) 392 while (bfin_read_RTC_ISTAT() & RTC_ISTAT_WRITE_PENDING)
386 if (time_after(jiffies, timeout)) 393 if (time_after(jiffies, timeout))
387 break; 394 break;
388 bfin_rtc_reset(dev, RTC_ISTAT_WRITE_COMPLETE); 395 bfin_rtc_reset(dev, RTC_ISTAT_WRITE_COMPLETE);
389 bfin_write_RTC_SWCNT(0); 396 bfin_write_RTC_SWCNT(0);
390 397
391 /* Register our RTC with the RTC framework */
392 rtc->rtc_dev = rtc_device_register(pdev->name, dev, &bfin_rtc_ops, THIS_MODULE);
393 if (unlikely(IS_ERR(rtc->rtc_dev))) {
394 ret = PTR_ERR(rtc->rtc_dev);
395 goto err_irq;
396 }
397
398 return 0; 398 return 0;
399 399
400 err_irq: 400err_reg:
401 free_irq(IRQ_RTC, dev); 401 rtc_device_unregister(rtc->rtc_dev);
402 err: 402err:
403 kfree(rtc); 403 kfree(rtc);
404 return ret; 404 return ret;
405} 405}
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 32b27739ec2a..713f7bf5afb3 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -283,7 +283,7 @@ static void ds1374_work(struct work_struct *work)
283 283
284 stat = i2c_smbus_read_byte_data(client, DS1374_REG_SR); 284 stat = i2c_smbus_read_byte_data(client, DS1374_REG_SR);
285 if (stat < 0) 285 if (stat < 0)
286 return; 286 goto unlock;
287 287
288 if (stat & DS1374_REG_SR_AF) { 288 if (stat & DS1374_REG_SR_AF) {
289 stat &= ~DS1374_REG_SR_AF; 289 stat &= ~DS1374_REG_SR_AF;
@@ -302,7 +302,7 @@ static void ds1374_work(struct work_struct *work)
302out: 302out:
303 if (!ds1374->exiting) 303 if (!ds1374->exiting)
304 enable_irq(client->irq); 304 enable_irq(client->irq);
305 305unlock:
306 mutex_unlock(&ds1374->mutex); 306 mutex_unlock(&ds1374->mutex);
307} 307}
308 308
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c
index f11297aff854..2c839d0d21bd 100644
--- a/drivers/rtc/rtc-vr41xx.c
+++ b/drivers/rtc/rtc-vr41xx.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for NEC VR4100 series Real Time Clock unit. 2 * Driver for NEC VR4100 series Real Time Clock unit.
3 * 3 *
4 * Copyright (C) 2003-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2003-2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
33#include <asm/io.h> 33#include <asm/io.h>
34#include <asm/uaccess.h> 34#include <asm/uaccess.h>
35 35
36MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>"); 36MODULE_AUTHOR("Yoichi Yuasa <yuasa@linux-mips.org>");
37MODULE_DESCRIPTION("NEC VR4100 series RTC driver"); 37MODULE_DESCRIPTION("NEC VR4100 series RTC driver");
38MODULE_LICENSE("GPL v2"); 38MODULE_LICENSE("GPL v2");
39 39
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index f8b1f04f26b8..c11770f5b368 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1696,8 +1696,7 @@ static void dasd_eckd_handle_unsolicited_interrupt(struct dasd_device *device,
1696 DBF_DEV_EVENT(DBF_ERR, device, "%s", 1696 DBF_DEV_EVENT(DBF_ERR, device, "%s",
1697 "unsolicited interrupt received " 1697 "unsolicited interrupt received "
1698 "(sense available)"); 1698 "(sense available)");
1699 device->discipline->dump_sense_dbf(device, NULL, irb, 1699 device->discipline->dump_sense_dbf(device, irb, "unsolicited");
1700 "unsolicited");
1701 } 1700 }
1702 1701
1703 dasd_schedule_device_bh(device); 1702 dasd_schedule_device_bh(device);
@@ -2941,42 +2940,20 @@ dasd_eckd_dump_ccw_range(struct ccw1 *from, struct ccw1 *to, char *page)
2941} 2940}
2942 2941
2943static void 2942static void
2944dasd_eckd_dump_sense_dbf(struct dasd_device *device, struct dasd_ccw_req *req, 2943dasd_eckd_dump_sense_dbf(struct dasd_device *device, struct irb *irb,
2945 struct irb *irb, char *reason) 2944 char *reason)
2946{ 2945{
2947 u64 *sense; 2946 u64 *sense;
2948 int sl;
2949 struct tsb *tsb;
2950 2947
2951 sense = NULL; 2948 sense = (u64 *) dasd_get_sense(irb);
2952 tsb = NULL;
2953 if (req && scsw_is_tm(&req->irb.scsw)) {
2954 if (irb->scsw.tm.tcw)
2955 tsb = tcw_get_tsb(
2956 (struct tcw *)(unsigned long)irb->scsw.tm.tcw);
2957 if (tsb && (irb->scsw.tm.fcxs == 0x01)) {
2958 switch (tsb->flags & 0x07) {
2959 case 1: /* tsa_iostat */
2960 sense = (u64 *)tsb->tsa.iostat.sense;
2961 break;
2962 case 2: /* ts_ddpc */
2963 sense = (u64 *)tsb->tsa.ddpc.sense;
2964 break;
2965 case 3: /* tsa_intrg */
2966 break;
2967 }
2968 }
2969 } else {
2970 if (irb->esw.esw0.erw.cons)
2971 sense = (u64 *)irb->ecw;
2972 }
2973 if (sense) { 2949 if (sense) {
2974 for (sl = 0; sl < 4; sl++) { 2950 DBF_DEV_EVENT(DBF_EMERG, device,
2975 DBF_DEV_EVENT(DBF_EMERG, device, 2951 "%s: %s %02x%02x%02x %016llx %016llx %016llx "
2976 "%s: %016llx %016llx %016llx %016llx", 2952 "%016llx", reason,
2977 reason, sense[0], sense[1], sense[2], 2953 scsw_is_tm(&irb->scsw) ? "t" : "c",
2978 sense[3]); 2954 scsw_cc(&irb->scsw), scsw_cstat(&irb->scsw),
2979 } 2955 scsw_dstat(&irb->scsw), sense[0], sense[1],
2956 sense[2], sense[3]);
2980 } else { 2957 } else {
2981 DBF_DEV_EVENT(DBF_EMERG, device, "%s", 2958 DBF_DEV_EVENT(DBF_EMERG, device, "%s",
2982 "SORRY - NO VALID SENSE AVAILABLE\n"); 2959 "SORRY - NO VALID SENSE AVAILABLE\n");
diff --git a/drivers/s390/block/dasd_erp.c b/drivers/s390/block/dasd_erp.c
index d970ce2814be..cb8f9cef7429 100644
--- a/drivers/s390/block/dasd_erp.c
+++ b/drivers/s390/block/dasd_erp.c
@@ -172,7 +172,7 @@ dasd_log_sense_dbf(struct dasd_ccw_req *cqr, struct irb *irb)
172 device = cqr->startdev; 172 device = cqr->startdev;
173 /* dump sense data to s390 debugfeature*/ 173 /* dump sense data to s390 debugfeature*/
174 if (device->discipline && device->discipline->dump_sense_dbf) 174 if (device->discipline && device->discipline->dump_sense_dbf)
175 device->discipline->dump_sense_dbf(device, cqr, irb, "log"); 175 device->discipline->dump_sense_dbf(device, irb, "log");
176} 176}
177EXPORT_SYMBOL(dasd_log_sense_dbf); 177EXPORT_SYMBOL(dasd_log_sense_dbf);
178 178
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index e21ee735f926..31849ad5e59f 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -241,7 +241,7 @@ static void dasd_fba_handle_unsolicited_interrupt(struct dasd_device *device,
241 /* check for unsolicited interrupts */ 241 /* check for unsolicited interrupts */
242 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 242 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
243 "unsolicited interrupt received"); 243 "unsolicited interrupt received");
244 device->discipline->dump_sense_dbf(device, NULL, irb, "unsolicited"); 244 device->discipline->dump_sense_dbf(device, irb, "unsolicited");
245 dasd_schedule_device_bh(device); 245 dasd_schedule_device_bh(device);
246 return; 246 return;
247}; 247};
@@ -444,17 +444,20 @@ dasd_fba_fill_info(struct dasd_device * device,
444} 444}
445 445
446static void 446static void
447dasd_fba_dump_sense_dbf(struct dasd_device *device, struct dasd_ccw_req *req, 447dasd_fba_dump_sense_dbf(struct dasd_device *device, struct irb *irb,
448 struct irb *irb, char *reason) 448 char *reason)
449{ 449{
450 int sl; 450 u64 *sense;
451 if (irb->esw.esw0.erw.cons) { 451
452 for (sl = 0; sl < 4; sl++) { 452 sense = (u64 *) dasd_get_sense(irb);
453 DBF_DEV_EVENT(DBF_EMERG, device, 453 if (sense) {
454 "%s: %08x %08x %08x %08x", 454 DBF_DEV_EVENT(DBF_EMERG, device,
455 reason, irb->ecw[8 * 0], irb->ecw[8 * 1], 455 "%s: %s %02x%02x%02x %016llx %016llx %016llx "
456 irb->ecw[8 * 2], irb->ecw[8 * 3]); 456 "%016llx", reason,
457 } 457 scsw_is_tm(&irb->scsw) ? "t" : "c",
458 scsw_cc(&irb->scsw), scsw_cstat(&irb->scsw),
459 scsw_dstat(&irb->scsw), sense[0], sense[1],
460 sense[2], sense[3]);
458 } else { 461 } else {
459 DBF_DEV_EVENT(DBF_EMERG, device, "%s", 462 DBF_DEV_EVENT(DBF_EMERG, device, "%s",
460 "SORRY - NO VALID SENSE AVAILABLE\n"); 463 "SORRY - NO VALID SENSE AVAILABLE\n");
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index fd63b2f2bda9..b699ca356ac5 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -284,8 +284,7 @@ struct dasd_discipline {
284 dasd_erp_fn_t(*erp_postaction) (struct dasd_ccw_req *); 284 dasd_erp_fn_t(*erp_postaction) (struct dasd_ccw_req *);
285 void (*dump_sense) (struct dasd_device *, struct dasd_ccw_req *, 285 void (*dump_sense) (struct dasd_device *, struct dasd_ccw_req *,
286 struct irb *); 286 struct irb *);
287 void (*dump_sense_dbf) (struct dasd_device *, struct dasd_ccw_req *, 287 void (*dump_sense_dbf) (struct dasd_device *, struct irb *, char *);
288 struct irb *, char *);
289 288
290 void (*handle_unsolicited_interrupt) (struct dasd_device *, 289 void (*handle_unsolicited_interrupt) (struct dasd_device *,
291 struct irb *); 290 struct irb *);
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 4ce3f72ee1c1..df918ef27965 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -16,6 +16,7 @@
16#include <linux/major.h> 16#include <linux/major.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/blkpg.h> 18#include <linux/blkpg.h>
19#include <linux/smp_lock.h>
19 20
20#include <asm/ccwdev.h> 21#include <asm/ccwdev.h>
21#include <asm/cmb.h> 22#include <asm/cmb.h>
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index 016f9e9d2591..d34617682a62 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -964,7 +964,8 @@ static int dcssblk_freeze(struct device *dev)
964 break; 964 break;
965 } 965 }
966 if (rc) 966 if (rc)
967 pr_err("Suspend failed because device %s is writeable.\n", 967 pr_err("Suspending the system failed because DCSS device %s "
968 "is writable\n",
968 dev_info->segment_name); 969 dev_info->segment_name);
969 return rc; 970 return rc;
970} 971}
@@ -987,8 +988,8 @@ static int dcssblk_restore(struct device *dev)
987 goto out_panic; 988 goto out_panic;
988 } 989 }
989 if (start != entry->start || end != entry->end) { 990 if (start != entry->start || end != entry->end) {
990 pr_err("Mismatch of start / end address after " 991 pr_err("The address range of DCSS %s changed "
991 "resuming device %s\n", 992 "while the system was suspended\n",
992 entry->segment_name); 993 entry->segment_name);
993 goto out_panic; 994 goto out_panic;
994 } 995 }
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
index 2e9e1ecd6d82..db442cd6621e 100644
--- a/drivers/s390/block/xpram.c
+++ b/drivers/s390/block/xpram.c
@@ -443,7 +443,7 @@ fail:
443 */ 443 */
444static void xpram_resume_error(const char *message) 444static void xpram_resume_error(const char *message)
445{ 445{
446 pr_err("Resume error: %s\n", message); 446 pr_err("Resuming the system failed: %s\n", message);
447 panic("xpram resume error\n"); 447 panic("xpram resume error\n");
448} 448}
449 449
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index 7892550d7932..3234e90bd7f9 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -320,7 +320,7 @@ static int mon_open(struct inode *inode, struct file *filp)
320 goto out_path; 320 goto out_path;
321 } 321 }
322 filp->private_data = monpriv; 322 filp->private_data = monpriv;
323 dev_set_drvdata(&monreader_device, monpriv); 323 dev_set_drvdata(monreader_device, monpriv);
324 unlock_kernel(); 324 unlock_kernel();
325 return nonseekable_open(inode, filp); 325 return nonseekable_open(inode, filp);
326 326
@@ -463,7 +463,7 @@ static struct miscdevice mon_dev = {
463 *****************************************************************************/ 463 *****************************************************************************/
464static int monreader_freeze(struct device *dev) 464static int monreader_freeze(struct device *dev)
465{ 465{
466 struct mon_private *monpriv = dev_get_drvdata(&dev); 466 struct mon_private *monpriv = dev_get_drvdata(dev);
467 int rc; 467 int rc;
468 468
469 if (!monpriv) 469 if (!monpriv)
diff --git a/drivers/s390/char/sclp_rw.h b/drivers/s390/char/sclp_rw.h
index 85f491ea929c..7a7bfc947d97 100644
--- a/drivers/s390/char/sclp_rw.h
+++ b/drivers/s390/char/sclp_rw.h
@@ -92,5 +92,10 @@ void sclp_set_columns(struct sclp_buffer *, unsigned short);
92void sclp_set_htab(struct sclp_buffer *, unsigned short); 92void sclp_set_htab(struct sclp_buffer *, unsigned short);
93int sclp_chars_in_buffer(struct sclp_buffer *); 93int sclp_chars_in_buffer(struct sclp_buffer *);
94 94
95#ifdef CONFIG_SCLP_CONSOLE
95void sclp_console_pm_event(enum sclp_pm_event sclp_pm_event); 96void sclp_console_pm_event(enum sclp_pm_event sclp_pm_event);
97#else
98static inline void sclp_console_pm_event(enum sclp_pm_event sclp_pm_event) { }
99#endif
100
96#endif /* __SCLP_RW_H__ */ 101#endif /* __SCLP_RW_H__ */
diff --git a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c
index cb7854c10c04..f2bc287b69e4 100644
--- a/drivers/s390/char/vmwatchdog.c
+++ b/drivers/s390/char/vmwatchdog.c
@@ -250,14 +250,14 @@ static int vmwdt_resume(void)
250static int vmwdt_suspend(void) 250static int vmwdt_suspend(void)
251{ 251{
252 if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open)) { 252 if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open)) {
253 pr_err("The watchdog is in use. " 253 pr_err("The system cannot be suspended while the watchdog"
254 "This prevents hibernation or suspend.\n"); 254 " is in use\n");
255 return NOTIFY_BAD; 255 return NOTIFY_BAD;
256 } 256 }
257 if (test_bit(VMWDT_RUNNING, &vmwdt_is_open)) { 257 if (test_bit(VMWDT_RUNNING, &vmwdt_is_open)) {
258 clear_bit(VMWDT_OPEN, &vmwdt_is_open); 258 clear_bit(VMWDT_OPEN, &vmwdt_is_open);
259 pr_err("The watchdog is running. " 259 pr_err("The system cannot be suspended while the watchdog"
260 "This prevents hibernation or suspend.\n"); 260 " is running\n");
261 return NOTIFY_BAD; 261 return NOTIFY_BAD;
262 } 262 }
263 return NOTIFY_DONE; 263 return NOTIFY_DONE;
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 0471f8800483..4240b05aef6d 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -2826,8 +2826,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
2826 */ 2826 */
2827 2827
2828 local_irq_restore(flags); 2828 local_irq_restore(flags);
2829 printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully\n" 2829 printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO);
2830 KERN_INFO " before abortion\n", HOSTNO);
2831 2830
2832 /* Maybe it is sufficient just to release the ST-DMA lock... (if 2831 /* Maybe it is sufficient just to release the ST-DMA lock... (if
2833 * possible at all) At least, we should check if the lock could be 2832 * possible at all) At least, we should check if the lock could be
diff --git a/drivers/scsi/cxgb3i/Kbuild b/drivers/scsi/cxgb3i/Kbuild
index 25a2032bfa26..70d060b7ff4f 100644
--- a/drivers/scsi/cxgb3i/Kbuild
+++ b/drivers/scsi/cxgb3i/Kbuild
@@ -1,4 +1,4 @@
1EXTRA_CFLAGS += -I$(TOPDIR)/drivers/net/cxgb3 1EXTRA_CFLAGS += -I$(srctree)/drivers/net/cxgb3
2 2
3cxgb3i-y := cxgb3i_init.o cxgb3i_iscsi.o cxgb3i_pdu.o cxgb3i_offload.o cxgb3i_ddp.o 3cxgb3i-y := cxgb3i_init.o cxgb3i_iscsi.o cxgb3i_pdu.o cxgb3i_offload.o cxgb3i_ddp.o
4obj-$(CONFIG_SCSI_CXGB3_ISCSI) += cxgb3i.o 4obj-$(CONFIG_SCSI_CXGB3_ISCSI) += cxgb3i.o
diff --git a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
index 74369a3f963b..c399f485aa7d 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/inet.h> 14#include <linux/inet.h>
15#include <linux/crypto.h> 15#include <linux/crypto.h>
16#include <linux/if_vlan.h>
16#include <net/dst.h> 17#include <net/dst.h>
17#include <net/tcp.h> 18#include <net/tcp.h>
18#include <scsi/scsi_cmnd.h> 19#include <scsi/scsi_cmnd.h>
@@ -184,6 +185,9 @@ static struct cxgb3i_hba *cxgb3i_hba_find_by_netdev(struct net_device *ndev)
184 struct cxgb3i_adapter *snic; 185 struct cxgb3i_adapter *snic;
185 int i; 186 int i;
186 187
188 if (ndev->priv_flags & IFF_802_1Q_VLAN)
189 ndev = vlan_dev_real_dev(ndev);
190
187 read_lock(&cxgb3i_snic_rwlock); 191 read_lock(&cxgb3i_snic_rwlock);
188 list_for_each_entry(snic, &cxgb3i_snic_list, list_head) { 192 list_for_each_entry(snic, &cxgb3i_snic_list, list_head) {
189 for (i = 0; i < snic->hba_cnt; i++) { 193 for (i = 0; i < snic->hba_cnt; i++) {
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index a84072865fc2..2c266c01dc5a 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -473,16 +473,16 @@ static int __devinit fnic_probe(struct pci_dev *pdev,
473 * limitation for the device. Try 40-bit first, and 473 * limitation for the device. Try 40-bit first, and
474 * fail to 32-bit. 474 * fail to 32-bit.
475 */ 475 */
476 err = pci_set_dma_mask(pdev, DMA_40BIT_MASK); 476 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(40));
477 if (err) { 477 if (err) {
478 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 478 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
479 if (err) { 479 if (err) {
480 shost_printk(KERN_ERR, fnic->lport->host, 480 shost_printk(KERN_ERR, fnic->lport->host,
481 "No usable DMA configuration " 481 "No usable DMA configuration "
482 "aborting\n"); 482 "aborting\n");
483 goto err_out_release_regions; 483 goto err_out_release_regions;
484 } 484 }
485 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 485 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
486 if (err) { 486 if (err) {
487 shost_printk(KERN_ERR, fnic->lport->host, 487 shost_printk(KERN_ERR, fnic->lport->host,
488 "Unable to obtain 32-bit DMA " 488 "Unable to obtain 32-bit DMA "
@@ -490,7 +490,7 @@ static int __devinit fnic_probe(struct pci_dev *pdev,
490 goto err_out_release_regions; 490 goto err_out_release_regions;
491 } 491 }
492 } else { 492 } else {
493 err = pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK); 493 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40));
494 if (err) { 494 if (err) {
495 shost_printk(KERN_ERR, fnic->lport->host, 495 shost_printk(KERN_ERR, fnic->lport->host,
496 "Unable to obtain 40-bit DMA " 496 "Unable to obtain 40-bit DMA "
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index eabf36502856..bfc996971b81 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -245,7 +245,7 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
245 struct vnic_wq_copy *wq, 245 struct vnic_wq_copy *wq,
246 struct fnic_io_req *io_req, 246 struct fnic_io_req *io_req,
247 struct scsi_cmnd *sc, 247 struct scsi_cmnd *sc,
248 u32 sg_count) 248 int sg_count)
249{ 249{
250 struct scatterlist *sg; 250 struct scatterlist *sg;
251 struct fc_rport *rport = starget_to_rport(scsi_target(sc->device)); 251 struct fc_rport *rport = starget_to_rport(scsi_target(sc->device));
@@ -260,9 +260,6 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
260 char msg[2]; 260 char msg[2];
261 261
262 if (sg_count) { 262 if (sg_count) {
263 BUG_ON(sg_count < 0);
264 BUG_ON(sg_count > FNIC_MAX_SG_DESC_CNT);
265
266 /* For each SGE, create a device desc entry */ 263 /* For each SGE, create a device desc entry */
267 desc = io_req->sgl_list; 264 desc = io_req->sgl_list;
268 for_each_sg(scsi_sglist(sc), sg, sg_count, i) { 265 for_each_sg(scsi_sglist(sc), sg, sg_count, i) {
@@ -344,7 +341,7 @@ int fnic_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
344 struct fnic *fnic; 341 struct fnic *fnic;
345 struct vnic_wq_copy *wq; 342 struct vnic_wq_copy *wq;
346 int ret; 343 int ret;
347 u32 sg_count; 344 int sg_count;
348 unsigned long flags; 345 unsigned long flags;
349 unsigned long ptr; 346 unsigned long ptr;
350 347
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 869a11bdccbd..9928704e235f 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1095,9 +1095,14 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct)
1095 MAX_INDIRECT_BUFS); 1095 MAX_INDIRECT_BUFS);
1096 hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS; 1096 hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS;
1097 } 1097 }
1098
1099 if (hostdata->madapter_info.os_type == 3) {
1100 enable_fast_fail(hostdata);
1101 return;
1102 }
1098 } 1103 }
1099 1104
1100 enable_fast_fail(hostdata); 1105 send_srp_login(hostdata);
1101} 1106}
1102 1107
1103/** 1108/**
diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
index b12ad7c7c673..18735b39b3d3 100644
--- a/drivers/scsi/mac53c94.c
+++ b/drivers/scsi/mac53c94.c
@@ -75,8 +75,9 @@ static int mac53c94_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *
75 int i; 75 int i;
76 printk(KERN_DEBUG "mac53c94_queue %p: command is", cmd); 76 printk(KERN_DEBUG "mac53c94_queue %p: command is", cmd);
77 for (i = 0; i < cmd->cmd_len; ++i) 77 for (i = 0; i < cmd->cmd_len; ++i)
78 printk(" %.2x", cmd->cmnd[i]); 78 printk(KERN_CONT " %.2x", cmd->cmnd[i]);
79 printk("\n" KERN_DEBUG "use_sg=%d request_bufflen=%d request_buffer=%p\n", 79 printk(KERN_CONT "\n");
80 printk(KERN_DEBUG "use_sg=%d request_bufflen=%d request_buffer=%p\n",
80 scsi_sg_count(cmd), scsi_bufflen(cmd), scsi_sglist(cmd)); 81 scsi_sg_count(cmd), scsi_bufflen(cmd), scsi_sglist(cmd));
81 } 82 }
82#endif 83#endif
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 650bcef08f2a..cd78c501803a 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -9,7 +9,6 @@
9 9
10#include <linux/moduleparam.h> 10#include <linux/moduleparam.h>
11#include <linux/vmalloc.h> 11#include <linux/vmalloc.h>
12#include <linux/smp_lock.h>
13#include <linux/list.h> 12#include <linux/list.h>
14 13
15#include <scsi/scsi_tcq.h> 14#include <scsi/scsi_tcq.h>
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 2eee9e6e4fe8..292c02f810d0 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -3670,13 +3670,14 @@ static void
3670fc_bsg_goose_queue(struct fc_rport *rport) 3670fc_bsg_goose_queue(struct fc_rport *rport)
3671{ 3671{
3672 int flagset; 3672 int flagset;
3673 unsigned long flags;
3673 3674
3674 if (!rport->rqst_q) 3675 if (!rport->rqst_q)
3675 return; 3676 return;
3676 3677
3677 get_device(&rport->dev); 3678 get_device(&rport->dev);
3678 3679
3679 spin_lock(rport->rqst_q->queue_lock); 3680 spin_lock_irqsave(rport->rqst_q->queue_lock, flags);
3680 flagset = test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags) && 3681 flagset = test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags) &&
3681 !test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags); 3682 !test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags);
3682 if (flagset) 3683 if (flagset)
@@ -3684,7 +3685,7 @@ fc_bsg_goose_queue(struct fc_rport *rport)
3684 __blk_run_queue(rport->rqst_q); 3685 __blk_run_queue(rport->rqst_q);
3685 if (flagset) 3686 if (flagset)
3686 queue_flag_clear(QUEUE_FLAG_REENTER, rport->rqst_q); 3687 queue_flag_clear(QUEUE_FLAG_REENTER, rport->rqst_q);
3687 spin_unlock(rport->rqst_q->queue_lock); 3688 spin_unlock_irqrestore(rport->rqst_q->queue_lock, flags);
3688 3689
3689 put_device(&rport->dev); 3690 put_device(&rport->dev);
3690} 3691}
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 8201387b4daa..9230402c45af 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -210,13 +210,11 @@ static void sg_put_dev(Sg_device *sdp);
210static int sg_allow_access(struct file *filp, unsigned char *cmd) 210static int sg_allow_access(struct file *filp, unsigned char *cmd)
211{ 211{
212 struct sg_fd *sfp = (struct sg_fd *)filp->private_data; 212 struct sg_fd *sfp = (struct sg_fd *)filp->private_data;
213 struct request_queue *q = sfp->parentdp->device->request_queue;
214 213
215 if (sfp->parentdp->device->type == TYPE_SCANNER) 214 if (sfp->parentdp->device->type == TYPE_SCANNER)
216 return 0; 215 return 0;
217 216
218 return blk_verify_command(&q->cmd_filter, 217 return blk_verify_command(cmd, filp->f_mode & FMODE_WRITE);
219 cmd, filp->f_mode & FMODE_WRITE);
220} 218}
221 219
222static int 220static int
@@ -621,7 +619,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
621 if (strcmp(current->comm, cmd) && printk_ratelimit()) { 619 if (strcmp(current->comm, cmd) && printk_ratelimit()) {
622 printk(KERN_WARNING 620 printk(KERN_WARNING
623 "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--" 621 "sg_write: data in/out %d/%d bytes for SCSI command 0x%x--"
624 "guessing data in;\n" KERN_WARNING " " 622 "guessing data in;\n "
625 "program %s not setting count and/or reply_len properly\n", 623 "program %s not setting count and/or reply_len properly\n",
626 old_hdr.reply_len - (int)SZ_SG_HEADER, 624 old_hdr.reply_len - (int)SZ_SG_HEADER,
627 input_size, (unsigned int) cmnd[0], 625 input_size, (unsigned int) cmnd[0],
@@ -1658,6 +1656,10 @@ static int sg_start_req(Sg_request *srp, unsigned char *cmd)
1658 md->nr_entries = req_schp->k_use_sg; 1656 md->nr_entries = req_schp->k_use_sg;
1659 md->offset = 0; 1657 md->offset = 0;
1660 md->null_mapped = hp->dxferp ? 0 : 1; 1658 md->null_mapped = hp->dxferp ? 0 : 1;
1659 if (dxfer_dir == SG_DXFER_TO_FROM_DEV)
1660 md->from_user = 1;
1661 else
1662 md->from_user = 0;
1661 } 1663 }
1662 1664
1663 if (iov_count) { 1665 if (iov_count) {
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index bcaba86060ab..75da6e58ce55 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -2860,8 +2860,7 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
2860 */ 2860 */
2861 2861
2862 local_irq_restore(flags); 2862 local_irq_restore(flags);
2863 printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully\n" 2863 printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO);
2864 KERN_INFO " before abortion\n", HOSTNO);
2865 2864
2866 return SCSI_ABORT_NOT_RUNNING; 2865 return SCSI_ABORT_NOT_RUNNING;
2867} 2866}
diff --git a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c
index 97f3158fa7b5..27e84e4b1fa9 100644
--- a/drivers/scsi/zalon.c
+++ b/drivers/scsi/zalon.c
@@ -134,7 +134,7 @@ zalon_probe(struct parisc_device *dev)
134 134
135 host = ncr_attach(&zalon7xx_template, unit, &device); 135 host = ncr_attach(&zalon7xx_template, unit, &device);
136 if (!host) 136 if (!host)
137 goto fail; 137 return -ENODEV;
138 138
139 if (request_irq(dev->irq, ncr53c8xx_intr, IRQF_SHARED, "zalon", host)) { 139 if (request_irq(dev->irq, ncr53c8xx_intr, IRQF_SHARED, "zalon", host)) {
140 dev_printk(KERN_ERR, &dev->dev, "irq problem with %d, detaching\n ", 140 dev_printk(KERN_ERR, &dev->dev, "irq problem with %d, detaching\n ",
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index a07015d646dd..e7108e75653d 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -60,11 +60,12 @@ struct serial_private {
60 60
61static void moan_device(const char *str, struct pci_dev *dev) 61static void moan_device(const char *str, struct pci_dev *dev)
62{ 62{
63 printk(KERN_WARNING "%s: %s\n" 63 printk(KERN_WARNING
64 KERN_WARNING "Please send the output of lspci -vv, this\n" 64 "%s: %s\n"
65 KERN_WARNING "message (0x%04x,0x%04x,0x%04x,0x%04x), the\n" 65 "Please send the output of lspci -vv, this\n"
66 KERN_WARNING "manufacturer and name of serial board or\n" 66 "message (0x%04x,0x%04x,0x%04x,0x%04x), the\n"
67 KERN_WARNING "modem board to rmk+serial@arm.linux.org.uk.\n", 67 "manufacturer and name of serial board or\n"
68 "modem board to rmk+serial@arm.linux.org.uk.\n",
68 pci_name(dev), str, dev->vendor, dev->device, 69 pci_name(dev), str, dev->vendor, dev->device,
69 dev->subsystem_vendor, dev->subsystem_device); 70 dev->subsystem_vendor, dev->subsystem_device);
70} 71}
@@ -759,6 +760,8 @@ static int pci_netmos_init(struct pci_dev *dev)
759 /* subdevice 0x00PS means <P> parallel, <S> serial */ 760 /* subdevice 0x00PS means <P> parallel, <S> serial */
760 unsigned int num_serial = dev->subsystem_device & 0xf; 761 unsigned int num_serial = dev->subsystem_device & 0xf;
761 762
763 if (dev->device == PCI_DEVICE_ID_NETMOS_9901)
764 return 0;
762 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM && 765 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
763 dev->subsystem_device == 0x0299) 766 dev->subsystem_device == 0x0299)
764 return 0; 767 return 0;
@@ -3557,6 +3560,10 @@ static struct pci_device_id serial_pci_tbl[] = {
3557 PCI_VENDOR_ID_IBM, 0x0299, 3560 PCI_VENDOR_ID_IBM, 0x0299,
3558 0, 0, pbn_b0_bt_2_115200 }, 3561 0, 0, pbn_b0_bt_2_115200 },
3559 3562
3563 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9901,
3564 0xA000, 0x1000,
3565 0, 0, pbn_b0_1_115200 },
3566
3560 /* 3567 /*
3561 * These entries match devices with class COMMUNICATION_SERIAL, 3568 * These entries match devices with class COMMUNICATION_SERIAL,
3562 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL 3569 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 66f52674ca0c..8e2feb563347 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -707,24 +707,25 @@ static irqreturn_t sci_br_interrupt(int irq, void *ptr)
707 707
708static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) 708static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
709{ 709{
710 unsigned short ssr_status, scr_status; 710 unsigned short ssr_status, scr_status, err_enabled;
711 struct uart_port *port = ptr; 711 struct uart_port *port = ptr;
712 irqreturn_t ret = IRQ_NONE; 712 irqreturn_t ret = IRQ_NONE;
713 713
714 ssr_status = sci_in(port, SCxSR); 714 ssr_status = sci_in(port, SCxSR);
715 scr_status = sci_in(port, SCSCR); 715 scr_status = sci_in(port, SCSCR);
716 err_enabled = scr_status & (SCI_CTRL_FLAGS_REIE | SCI_CTRL_FLAGS_RIE);
716 717
717 /* Tx Interrupt */ 718 /* Tx Interrupt */
718 if ((ssr_status & 0x0020) && (scr_status & SCI_CTRL_FLAGS_TIE)) 719 if ((ssr_status & SCxSR_TDxE(port)) && (scr_status & SCI_CTRL_FLAGS_TIE))
719 ret = sci_tx_interrupt(irq, ptr); 720 ret = sci_tx_interrupt(irq, ptr);
720 /* Rx Interrupt */ 721 /* Rx Interrupt */
721 if ((ssr_status & 0x0002) && (scr_status & SCI_CTRL_FLAGS_RIE)) 722 if ((ssr_status & SCxSR_RDxF(port)) && (scr_status & SCI_CTRL_FLAGS_RIE))
722 ret = sci_rx_interrupt(irq, ptr); 723 ret = sci_rx_interrupt(irq, ptr);
723 /* Error Interrupt */ 724 /* Error Interrupt */
724 if ((ssr_status & 0x0080) && (scr_status & SCI_CTRL_FLAGS_REIE)) 725 if ((ssr_status & SCxSR_ERRORS(port)) && err_enabled)
725 ret = sci_er_interrupt(irq, ptr); 726 ret = sci_er_interrupt(irq, ptr);
726 /* Break Interrupt */ 727 /* Break Interrupt */
727 if ((ssr_status & 0x0010) && (scr_status & SCI_CTRL_FLAGS_REIE)) 728 if ((ssr_status & SCxSR_BRK(port)) && err_enabled)
728 ret = sci_br_interrupt(irq, ptr); 729 ret = sci_br_interrupt(irq, ptr);
729 730
730 return ret; 731 return ret;
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index 0573f3b5175e..dac550e57c29 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for NEC VR4100 series Serial Interface Unit. 2 * Driver for NEC VR4100 series Serial Interface Unit.
3 * 3 *
4 * Copyright (C) 2004-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2004-2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * Based on drivers/serial/8250.c, by Russell King. 6 * Based on drivers/serial/8250.c, by Russell King.
7 * 7 *
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c
index aa90ddb37066..8980a5640bd9 100644
--- a/drivers/spi/omap_uwire.c
+++ b/drivers/spi/omap_uwire.c
@@ -514,6 +514,8 @@ static int __init uwire_probe(struct platform_device *pdev)
514 /* the spi->mode bits understood by this driver: */ 514 /* the spi->mode bits understood by this driver: */
515 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 515 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
516 516
517 master->flags = SPI_MASTER_HALF_DUPLEX;
518
517 master->bus_num = 2; /* "official" */ 519 master->bus_num = 2; /* "official" */
518 master->num_chipselect = 4; 520 master->num_chipselect = 4;
519 master->setup = uwire_setup; 521 master->setup = uwire_setup;
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index 2a5abc08e857..f1db395dd889 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -258,6 +258,11 @@ static void bitbang_work(struct work_struct *work)
258 struct spi_bitbang *bitbang = 258 struct spi_bitbang *bitbang =
259 container_of(work, struct spi_bitbang, work); 259 container_of(work, struct spi_bitbang, work);
260 unsigned long flags; 260 unsigned long flags;
261 int do_setup = -1;
262 int (*setup_transfer)(struct spi_device *,
263 struct spi_transfer *);
264
265 setup_transfer = bitbang->setup_transfer;
261 266
262 spin_lock_irqsave(&bitbang->lock, flags); 267 spin_lock_irqsave(&bitbang->lock, flags);
263 bitbang->busy = 1; 268 bitbang->busy = 1;
@@ -269,8 +274,6 @@ static void bitbang_work(struct work_struct *work)
269 unsigned tmp; 274 unsigned tmp;
270 unsigned cs_change; 275 unsigned cs_change;
271 int status; 276 int status;
272 int (*setup_transfer)(struct spi_device *,
273 struct spi_transfer *);
274 277
275 m = container_of(bitbang->queue.next, struct spi_message, 278 m = container_of(bitbang->queue.next, struct spi_message,
276 queue); 279 queue);
@@ -287,19 +290,19 @@ static void bitbang_work(struct work_struct *work)
287 tmp = 0; 290 tmp = 0;
288 cs_change = 1; 291 cs_change = 1;
289 status = 0; 292 status = 0;
290 setup_transfer = NULL;
291 293
292 list_for_each_entry (t, &m->transfers, transfer_list) { 294 list_for_each_entry (t, &m->transfers, transfer_list) {
293 295
294 /* override or restore speed and wordsize */ 296 /* override speed or wordsize? */
295 if (t->speed_hz || t->bits_per_word) { 297 if (t->speed_hz || t->bits_per_word)
296 setup_transfer = bitbang->setup_transfer; 298 do_setup = 1;
299
300 /* init (-1) or override (1) transfer params */
301 if (do_setup != 0) {
297 if (!setup_transfer) { 302 if (!setup_transfer) {
298 status = -ENOPROTOOPT; 303 status = -ENOPROTOOPT;
299 break; 304 break;
300 } 305 }
301 }
302 if (setup_transfer) {
303 status = setup_transfer(spi, t); 306 status = setup_transfer(spi, t);
304 if (status < 0) 307 if (status < 0)
305 break; 308 break;
@@ -363,9 +366,10 @@ static void bitbang_work(struct work_struct *work)
363 m->status = status; 366 m->status = status;
364 m->complete(m->context); 367 m->complete(m->context);
365 368
366 /* restore speed and wordsize */ 369 /* restore speed and wordsize if it was overridden */
367 if (setup_transfer) 370 if (do_setup == 1)
368 setup_transfer(spi, NULL); 371 setup_transfer(spi, NULL);
372 do_setup = 0;
369 373
370 /* normally deactivate chipselect ... unless no error and 374 /* normally deactivate chipselect ... unless no error and
371 * cs_change has hinted that the next message will probably 375 * cs_change has hinted that the next message will probably
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 5d869c4d3eb2..606e7a40a8da 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -58,15 +58,20 @@ static unsigned long minors[N_SPI_MINORS / BITS_PER_LONG];
58 58
59 59
60/* Bit masks for spi_device.mode management. Note that incorrect 60/* Bit masks for spi_device.mode management. Note that incorrect
61 * settings for CS_HIGH and 3WIRE can cause *lots* of trouble for other 61 * settings for some settings can cause *lots* of trouble for other
62 * devices on a shared bus: CS_HIGH, because this device will be 62 * devices on a shared bus:
63 * active when it shouldn't be; 3WIRE, because when active it won't
64 * behave as it should.
65 * 63 *
66 * REVISIT should changing those two modes be privileged? 64 * - CS_HIGH ... this device will be active when it shouldn't be
65 * - 3WIRE ... when active, it won't behave as it should
66 * - NO_CS ... there will be no explicit message boundaries; this
67 * is completely incompatible with the shared bus model
68 * - READY ... transfers may proceed when they shouldn't.
69 *
70 * REVISIT should changing those flags be privileged?
67 */ 71 */
68#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH \ 72#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH \
69 | SPI_LSB_FIRST | SPI_3WIRE | SPI_LOOP) 73 | SPI_LSB_FIRST | SPI_3WIRE | SPI_LOOP \
74 | SPI_NO_CS | SPI_READY)
70 75
71struct spidev_data { 76struct spidev_data {
72 dev_t devt; 77 dev_t devt;
diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c
index 3fd3e3b412b6..3c6feed46f6e 100644
--- a/drivers/ssb/driver_mipscore.c
+++ b/drivers/ssb/driver_mipscore.c
@@ -49,29 +49,54 @@ static const u32 ipsflag_irq_shift[] = {
49 49
50static inline u32 ssb_irqflag(struct ssb_device *dev) 50static inline u32 ssb_irqflag(struct ssb_device *dev)
51{ 51{
52 return ssb_read32(dev, SSB_TPSFLAG) & SSB_TPSFLAG_BPFLAG; 52 u32 tpsflag = ssb_read32(dev, SSB_TPSFLAG);
53 if (tpsflag)
54 return ssb_read32(dev, SSB_TPSFLAG) & SSB_TPSFLAG_BPFLAG;
55 else
56 /* not irq supported */
57 return 0x3f;
58}
59
60static struct ssb_device *find_device(struct ssb_device *rdev, int irqflag)
61{
62 struct ssb_bus *bus = rdev->bus;
63 int i;
64 for (i = 0; i < bus->nr_devices; i++) {
65 struct ssb_device *dev;
66 dev = &(bus->devices[i]);
67 if (ssb_irqflag(dev) == irqflag)
68 return dev;
69 }
70 return NULL;
53} 71}
54 72
55/* Get the MIPS IRQ assignment for a specified device. 73/* Get the MIPS IRQ assignment for a specified device.
56 * If unassigned, 0 is returned. 74 * If unassigned, 0 is returned.
75 * If disabled, 5 is returned.
76 * If not supported, 6 is returned.
57 */ 77 */
58unsigned int ssb_mips_irq(struct ssb_device *dev) 78unsigned int ssb_mips_irq(struct ssb_device *dev)
59{ 79{
60 struct ssb_bus *bus = dev->bus; 80 struct ssb_bus *bus = dev->bus;
81 struct ssb_device *mdev = bus->mipscore.dev;
61 u32 irqflag; 82 u32 irqflag;
62 u32 ipsflag; 83 u32 ipsflag;
63 u32 tmp; 84 u32 tmp;
64 unsigned int irq; 85 unsigned int irq;
65 86
66 irqflag = ssb_irqflag(dev); 87 irqflag = ssb_irqflag(dev);
88 if (irqflag == 0x3f)
89 return 6;
67 ipsflag = ssb_read32(bus->mipscore.dev, SSB_IPSFLAG); 90 ipsflag = ssb_read32(bus->mipscore.dev, SSB_IPSFLAG);
68 for (irq = 1; irq <= 4; irq++) { 91 for (irq = 1; irq <= 4; irq++) {
69 tmp = ((ipsflag & ipsflag_irq_mask[irq]) >> ipsflag_irq_shift[irq]); 92 tmp = ((ipsflag & ipsflag_irq_mask[irq]) >> ipsflag_irq_shift[irq]);
70 if (tmp == irqflag) 93 if (tmp == irqflag)
71 break; 94 break;
72 } 95 }
73 if (irq == 5) 96 if (irq == 5) {
74 irq = 0; 97 if ((1 << irqflag) & ssb_read32(mdev, SSB_INTVEC))
98 irq = 0;
99 }
75 100
76 return irq; 101 return irq;
77} 102}
@@ -97,25 +122,56 @@ static void set_irq(struct ssb_device *dev, unsigned int irq)
97 struct ssb_device *mdev = bus->mipscore.dev; 122 struct ssb_device *mdev = bus->mipscore.dev;
98 u32 irqflag = ssb_irqflag(dev); 123 u32 irqflag = ssb_irqflag(dev);
99 124
125 BUG_ON(oldirq == 6);
126
100 dev->irq = irq + 2; 127 dev->irq = irq + 2;
101 128
102 ssb_dprintk(KERN_INFO PFX
103 "set_irq: core 0x%04x, irq %d => %d\n",
104 dev->id.coreid, oldirq, irq);
105 /* clear the old irq */ 129 /* clear the old irq */
106 if (oldirq == 0) 130 if (oldirq == 0)
107 ssb_write32(mdev, SSB_INTVEC, (~(1 << irqflag) & ssb_read32(mdev, SSB_INTVEC))); 131 ssb_write32(mdev, SSB_INTVEC, (~(1 << irqflag) & ssb_read32(mdev, SSB_INTVEC)));
108 else 132 else if (oldirq != 5)
109 clear_irq(bus, oldirq); 133 clear_irq(bus, oldirq);
110 134
111 /* assign the new one */ 135 /* assign the new one */
112 if (irq == 0) { 136 if (irq == 0) {
113 ssb_write32(mdev, SSB_INTVEC, ((1 << irqflag) | ssb_read32(mdev, SSB_INTVEC))); 137 ssb_write32(mdev, SSB_INTVEC, ((1 << irqflag) | ssb_read32(mdev, SSB_INTVEC)));
114 } else { 138 } else {
139 u32 ipsflag = ssb_read32(mdev, SSB_IPSFLAG);
140 if ((ipsflag & ipsflag_irq_mask[irq]) != ipsflag_irq_mask[irq]) {
141 u32 oldipsflag = (ipsflag & ipsflag_irq_mask[irq]) >> ipsflag_irq_shift[irq];
142 struct ssb_device *olddev = find_device(dev, oldipsflag);
143 if (olddev)
144 set_irq(olddev, 0);
145 }
115 irqflag <<= ipsflag_irq_shift[irq]; 146 irqflag <<= ipsflag_irq_shift[irq];
116 irqflag |= (ssb_read32(mdev, SSB_IPSFLAG) & ~ipsflag_irq_mask[irq]); 147 irqflag |= (ipsflag & ~ipsflag_irq_mask[irq]);
117 ssb_write32(mdev, SSB_IPSFLAG, irqflag); 148 ssb_write32(mdev, SSB_IPSFLAG, irqflag);
118 } 149 }
150 ssb_dprintk(KERN_INFO PFX
151 "set_irq: core 0x%04x, irq %d => %d\n",
152 dev->id.coreid, oldirq+2, irq+2);
153}
154
155static void print_irq(struct ssb_device *dev, unsigned int irq)
156{
157 int i;
158 static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
159 ssb_dprintk(KERN_INFO PFX
160 "core 0x%04x, irq :", dev->id.coreid);
161 for (i = 0; i <= 6; i++) {
162 ssb_dprintk(" %s%s", irq_name[i], i==irq?"*":" ");
163 }
164 ssb_dprintk("\n");
165}
166
167static void dump_irq(struct ssb_bus *bus)
168{
169 int i;
170 for (i = 0; i < bus->nr_devices; i++) {
171 struct ssb_device *dev;
172 dev = &(bus->devices[i]);
173 print_irq(dev, ssb_mips_irq(dev));
174 }
119} 175}
120 176
121static void ssb_mips_serial_init(struct ssb_mipscore *mcore) 177static void ssb_mips_serial_init(struct ssb_mipscore *mcore)
@@ -197,16 +253,23 @@ void ssb_mipscore_init(struct ssb_mipscore *mcore)
197 253
198 /* Assign IRQs to all cores on the bus, start with irq line 2, because serial usually takes 1 */ 254 /* Assign IRQs to all cores on the bus, start with irq line 2, because serial usually takes 1 */
199 for (irq = 2, i = 0; i < bus->nr_devices; i++) { 255 for (irq = 2, i = 0; i < bus->nr_devices; i++) {
256 int mips_irq;
200 dev = &(bus->devices[i]); 257 dev = &(bus->devices[i]);
201 dev->irq = ssb_mips_irq(dev) + 2; 258 mips_irq = ssb_mips_irq(dev);
259 if (mips_irq > 4)
260 dev->irq = 0;
261 else
262 dev->irq = mips_irq + 2;
263 if (dev->irq > 5)
264 continue;
202 switch (dev->id.coreid) { 265 switch (dev->id.coreid) {
203 case SSB_DEV_USB11_HOST: 266 case SSB_DEV_USB11_HOST:
204 /* shouldn't need a separate irq line for non-4710, most of them have a proper 267 /* shouldn't need a separate irq line for non-4710, most of them have a proper
205 * external usb controller on the pci */ 268 * external usb controller on the pci */
206 if ((bus->chip_id == 0x4710) && (irq <= 4)) { 269 if ((bus->chip_id == 0x4710) && (irq <= 4)) {
207 set_irq(dev, irq++); 270 set_irq(dev, irq++);
208 break;
209 } 271 }
272 break;
210 /* fallthrough */ 273 /* fallthrough */
211 case SSB_DEV_PCI: 274 case SSB_DEV_PCI:
212 case SSB_DEV_ETHERNET: 275 case SSB_DEV_ETHERNET:
@@ -220,6 +283,8 @@ void ssb_mipscore_init(struct ssb_mipscore *mcore)
220 } 283 }
221 } 284 }
222 } 285 }
286 ssb_dprintk(KERN_INFO PFX "after irq reconfiguration\n");
287 dump_irq(bus);
223 288
224 ssb_mips_serial_init(mcore); 289 ssb_mips_serial_init(mcore);
225 ssb_mips_flash_detect(mcore); 290 ssb_mips_flash_detect(mcore);
diff --git a/drivers/ssb/pcmcia.c b/drivers/ssb/pcmcia.c
index fbfadbac67e8..100e7a5c5ea1 100644
--- a/drivers/ssb/pcmcia.c
+++ b/drivers/ssb/pcmcia.c
@@ -583,7 +583,7 @@ static int ssb_pcmcia_sprom_write_all(struct ssb_bus *bus, const u16 *sprom)
583 ssb_printk("."); 583 ssb_printk(".");
584 err = ssb_pcmcia_sprom_write(bus, i, sprom[i]); 584 err = ssb_pcmcia_sprom_write(bus, i, sprom[i]);
585 if (err) { 585 if (err) {
586 ssb_printk("\n" KERN_NOTICE PFX 586 ssb_printk(KERN_NOTICE PFX
587 "Failed to write to SPROM.\n"); 587 "Failed to write to SPROM.\n");
588 failed = 1; 588 failed = 1;
589 break; 589 break;
@@ -591,7 +591,7 @@ static int ssb_pcmcia_sprom_write_all(struct ssb_bus *bus, const u16 *sprom)
591 } 591 }
592 err = ssb_pcmcia_sprom_command(bus, SSB_PCMCIA_SPROMCTL_WRITEDIS); 592 err = ssb_pcmcia_sprom_command(bus, SSB_PCMCIA_SPROMCTL_WRITEDIS);
593 if (err) { 593 if (err) {
594 ssb_printk("\n" KERN_NOTICE PFX 594 ssb_printk(KERN_NOTICE PFX
595 "Could not disable SPROM write access.\n"); 595 "Could not disable SPROM write access.\n");
596 failed = 1; 596 failed = 1;
597 } 597 }
@@ -678,7 +678,8 @@ int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
678 sprom->board_rev = tuple.TupleData[1]; 678 sprom->board_rev = tuple.TupleData[1];
679 break; 679 break;
680 case SSB_PCMCIA_CIS_PA: 680 case SSB_PCMCIA_CIS_PA:
681 GOTO_ERROR_ON(tuple.TupleDataLen != 9, 681 GOTO_ERROR_ON((tuple.TupleDataLen != 9) &&
682 (tuple.TupleDataLen != 10),
682 "pa tpl size"); 683 "pa tpl size");
683 sprom->pa0b0 = tuple.TupleData[1] | 684 sprom->pa0b0 = tuple.TupleData[1] |
684 ((u16)tuple.TupleData[2] << 8); 685 ((u16)tuple.TupleData[2] << 8);
@@ -718,7 +719,8 @@ int ssb_pcmcia_get_invariants(struct ssb_bus *bus,
718 sprom->antenna_gain.ghz5.a3 = tuple.TupleData[1]; 719 sprom->antenna_gain.ghz5.a3 = tuple.TupleData[1];
719 break; 720 break;
720 case SSB_PCMCIA_CIS_BFLAGS: 721 case SSB_PCMCIA_CIS_BFLAGS:
721 GOTO_ERROR_ON(tuple.TupleDataLen != 3, 722 GOTO_ERROR_ON((tuple.TupleDataLen != 3) &&
723 (tuple.TupleDataLen != 5),
722 "bfl tpl size"); 724 "bfl tpl size");
723 sprom->boardflags_lo = tuple.TupleData[1] | 725 sprom->boardflags_lo = tuple.TupleData[1] |
724 ((u16)tuple.TupleData[2] << 8); 726 ((u16)tuple.TupleData[2] << 8);
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index baf83c6a9412..e3c3adc282e2 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -45,6 +45,8 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
45#include <linux/delay.h> 45#include <linux/delay.h>
46#include <linux/ctype.h> 46#include <linux/ctype.h>
47#include <linux/firmware.h> 47#include <linux/firmware.h>
48#include <linux/jiffies.h>
49#include <linux/timer.h>
48#include "comedi_pci.h" 50#include "comedi_pci.h"
49#include "jr3_pci.h" 51#include "jr3_pci.h"
50 52
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 92121cf8c45c..5d9bab352c1d 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -111,9 +111,13 @@ static const struct s626_board s626_boards[] = {
111#define PCI_VENDOR_ID_S626 0x1131 111#define PCI_VENDOR_ID_S626 0x1131
112#define PCI_DEVICE_ID_S626 0x7146 112#define PCI_DEVICE_ID_S626 0x7146
113 113
114/*
115 * For devices with vendor:device id == 0x1131:0x7146 you must specify
116 * also subvendor:subdevice ids, because otherwise it will conflict with
117 * Philips SAA7146 media/dvb based cards.
118 */
114static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = { 119static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = {
115 {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 120 {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, 0x6000, 0x0272, 0, 0, 0},
116 0},
117 {0} 121 {0}
118}; 122};
119 123
@@ -499,25 +503,26 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
499 resource_size_t resourceStart; 503 resource_size_t resourceStart;
500 dma_addr_t appdma; 504 dma_addr_t appdma;
501 struct comedi_subdevice *s; 505 struct comedi_subdevice *s;
502 struct pci_dev *pdev; 506 const struct pci_device_id *ids;
507 struct pci_dev *pdev = NULL;
503 508
504 if (alloc_private(dev, sizeof(struct s626_private)) < 0) 509 if (alloc_private(dev, sizeof(struct s626_private)) < 0)
505 return -ENOMEM; 510 return -ENOMEM;
506 511
507 for (pdev = pci_get_device(PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, 512 for (i = 0; i < (ARRAY_SIZE(s626_pci_table) - 1) && !pdev; i++) {
508 NULL); pdev != NULL; 513 ids = &s626_pci_table[i];
509 pdev = pci_get_device(PCI_VENDOR_ID_S626, 514 do {
510 PCI_DEVICE_ID_S626, pdev)) { 515 pdev = pci_get_subsys(ids->vendor, ids->device, ids->subvendor,
511 if (it->options[0] || it->options[1]) { 516 ids->subdevice, pdev);
512 if (pdev->bus->number == it->options[0] && 517
513 PCI_SLOT(pdev->devfn) == it->options[1]) { 518 if ((it->options[0] || it->options[1]) && pdev) {
514 /* matches requested bus/slot */ 519 /* matches requested bus/slot */
520 if (pdev->bus->number == it->options[0] &&
521 PCI_SLOT(pdev->devfn) == it->options[1])
522 break;
523 } else
515 break; 524 break;
516 } 525 } while (1);
517 } else {
518 /* no bus/slot specified */
519 break;
520 }
521 } 526 }
522 devpriv->pdev = pdev; 527 devpriv->pdev = pdev;
523 528
diff --git a/drivers/staging/go7007/s2250-loader.c b/drivers/staging/go7007/s2250-loader.c
index a5e4acab089e..bb22347af60e 100644
--- a/drivers/staging/go7007/s2250-loader.c
+++ b/drivers/staging/go7007/s2250-loader.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/smp_lock.h>
20#include <linux/usb.h> 21#include <linux/usb.h>
21#include <dvb-usb.h> 22#include <dvb-usb.h>
22 23
diff --git a/drivers/staging/meilhaus/TODO b/drivers/staging/meilhaus/TODO
index 6ec25203089c..d6ce39823de6 100644
--- a/drivers/staging/meilhaus/TODO
+++ b/drivers/staging/meilhaus/TODO
@@ -7,4 +7,4 @@ TODO:
7 - possible comedi merge 7 - possible comedi merge
8 8
9Please send cleanup patches to Greg Kroah-Hartman <greg@kroah.com> 9Please send cleanup patches to Greg Kroah-Hartman <greg@kroah.com>
10and CC: David Kiliani <mail@davidkiliani.de> 10and CC: David Kiliani <mail@davidkiliani.de> and Meilhaus Support <support@meilhaus.de>
diff --git a/drivers/staging/rspiusb/rspiusb.c b/drivers/staging/rspiusb/rspiusb.c
index 1cdfe69585ea..2f8155c1968b 100644
--- a/drivers/staging/rspiusb/rspiusb.c
+++ b/drivers/staging/rspiusb/rspiusb.c
@@ -444,8 +444,7 @@ static void piusb_write_bulk_callback(struct urb *urb)
444 __func__, status); 444 __func__, status);
445 445
446 pdx->pendingWrite = 0; 446 pdx->pendingWrite = 0;
447 usb_buffer_free(urb->dev, urb->transfer_buffer_length, 447 kfree(urb->transfer_buffer);
448 urb->transfer_buffer, urb->transfer_dma);
449} 448}
450 449
451int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len, 450int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
@@ -457,9 +456,7 @@ int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
457 456
458 urb = usb_alloc_urb(0, GFP_KERNEL); 457 urb = usb_alloc_urb(0, GFP_KERNEL);
459 if (urb != NULL) { 458 if (urb != NULL) {
460 kbuf = 459 kbuf = kmalloc(len, GFP_KERNEL);
461 usb_buffer_alloc(pdx->udev, len, GFP_KERNEL,
462 &urb->transfer_dma);
463 if (!kbuf) { 460 if (!kbuf) {
464 dev_err(&pdx->udev->dev, "buffer_alloc failed\n"); 461 dev_err(&pdx->udev->dev, "buffer_alloc failed\n");
465 return -ENOMEM; 462 return -ENOMEM;
@@ -470,7 +467,6 @@ int piusb_output(struct ioctl_struct *io, unsigned char *uBuf, int len,
470 } 467 }
471 usb_fill_bulk_urb(urb, pdx->udev, pdx->hEP[io->endpoint], kbuf, 468 usb_fill_bulk_urb(urb, pdx->udev, pdx->hEP[io->endpoint], kbuf,
472 len, piusb_write_bulk_callback, pdx); 469 len, piusb_write_bulk_callback, pdx);
473 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
474 err = usb_submit_urb(urb, GFP_KERNEL); 470 err = usb_submit_urb(urb, GFP_KERNEL);
475 if (err) { 471 if (err) {
476 dev_err(&pdx->udev->dev, 472 dev_err(&pdx->udev->dev,
@@ -641,7 +637,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
641 numPagesRequired = 637 numPagesRequired =
642 ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT; 638 ((uaddr & ~PAGE_MASK) + count + ~PAGE_MASK) >> PAGE_SHIFT;
643 dbg("Number of pages needed = %d", numPagesRequired); 639 dbg("Number of pages needed = %d", numPagesRequired);
644 maplist_p = vmalloc(numPagesRequired * sizeof(struct page)); 640 maplist_p = vmalloc(numPagesRequired * sizeof(struct page *));
645 if (!maplist_p) { 641 if (!maplist_p) {
646 dbg("Can't Allocate Memory for maplist_p"); 642 dbg("Can't Allocate Memory for maplist_p");
647 return -ENOMEM; 643 return -ENOMEM;
@@ -712,9 +708,7 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
712 usb_fill_bulk_urb(pdx->PixelUrb[frameInfo][i], 708 usb_fill_bulk_urb(pdx->PixelUrb[frameInfo][i],
713 pdx->udev, 709 pdx->udev,
714 epAddr, 710 epAddr,
715 (dma_addr_t *) sg_dma_address(&pdx-> 711 NULL, // non-DMA HC? buy a better hardware
716 sgl[frameInfo]
717 [i]),
718 sg_dma_len(&pdx->sgl[frameInfo][i]), 712 sg_dma_len(&pdx->sgl[frameInfo][i]),
719 piusb_readPIXEL_callback, (void *)pdx); 713 piusb_readPIXEL_callback, (void *)pdx);
720 pdx->PixelUrb[frameInfo][i]->transfer_dma = 714 pdx->PixelUrb[frameInfo][i]->transfer_dma =
diff --git a/drivers/staging/rt2870/rt2870.h b/drivers/staging/rt2870/rt2870.h
index 5e5b3f2b7eb1..29e3b53e52a1 100644
--- a/drivers/staging/rt2870/rt2870.h
+++ b/drivers/staging/rt2870/rt2870.h
@@ -89,6 +89,7 @@
89 {USB_DEVICE(0x0DF6,0x002C)}, /* Sitecom */ \ 89 {USB_DEVICE(0x0DF6,0x002C)}, /* Sitecom */ \
90 {USB_DEVICE(0x0DF6,0x002D)}, /* Sitecom */ \ 90 {USB_DEVICE(0x0DF6,0x002D)}, /* Sitecom */ \
91 {USB_DEVICE(0x0DF6,0x0039)}, /* Sitecom */ \ 91 {USB_DEVICE(0x0DF6,0x0039)}, /* Sitecom */ \
92 {USB_DEVICE(0x0DF6,0x003F)}, /* Sitecom WL-608 */ \
92 {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \ 93 {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \
93 {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \ 94 {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \
94 {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */ \ 95 {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */ \
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
index 93af37e2d31a..54b4b718f84a 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
@@ -461,19 +461,19 @@ int ieee80211_wx_get_name(struct ieee80211_device *ieee,
461 struct iw_request_info *info, 461 struct iw_request_info *info,
462 union iwreq_data *wrqu, char *extra) 462 union iwreq_data *wrqu, char *extra)
463{ 463{
464 strcpy(wrqu->name, "802.11"); 464 strlcpy(wrqu->name, "802.11", IFNAMSIZ);
465 if(ieee->modulation & IEEE80211_CCK_MODULATION){ 465 if(ieee->modulation & IEEE80211_CCK_MODULATION){
466 strcat(wrqu->name, "b"); 466 strlcat(wrqu->name, "b", IFNAMSIZ);
467 if(ieee->modulation & IEEE80211_OFDM_MODULATION) 467 if(ieee->modulation & IEEE80211_OFDM_MODULATION)
468 strcat(wrqu->name, "/g"); 468 strlcat(wrqu->name, "/g", IFNAMSIZ);
469 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) 469 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
470 strcat(wrqu->name, "g"); 470 strlcat(wrqu->name, "g", IFNAMSIZ);
471 471
472 if((ieee->state == IEEE80211_LINKED) || 472 if((ieee->state == IEEE80211_LINKED) ||
473 (ieee->state == IEEE80211_LINKED_SCANNING)) 473 (ieee->state == IEEE80211_LINKED_SCANNING))
474 strcat(wrqu->name," linked"); 474 strlcat(wrqu->name," link", IFNAMSIZ);
475 else if(ieee->state != IEEE80211_NOLINK) 475 else if(ieee->state != IEEE80211_NOLINK)
476 strcat(wrqu->name," link.."); 476 strlcat(wrqu->name," .....", IFNAMSIZ);
477 477
478 478
479 return 0; 479 return 0;
diff --git a/drivers/staging/rtl8192su/Kconfig b/drivers/staging/rtl8192su/Kconfig
index 4b5552c5926e..770f41280f21 100644
--- a/drivers/staging/rtl8192su/Kconfig
+++ b/drivers/staging/rtl8192su/Kconfig
@@ -1,6 +1,6 @@
1config RTL8192SU 1config RTL8192SU
2 tristate "RealTek RTL8192SU Wireless LAN NIC driver" 2 tristate "RealTek RTL8192SU Wireless LAN NIC driver"
3 depends on PCI 3 depends on PCI
4 depends on WIRELESS_EXT && COMPAT_NET_DEV_OPS 4 depends on WIRELESS_EXT
5 default N 5 default N
6 ---help--- 6 ---help---
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
index f408b4583b82..759032db4a34 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
@@ -118,7 +118,6 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
118#else 118#else
119 ieee = (struct ieee80211_device *)dev->priv; 119 ieee = (struct ieee80211_device *)dev->priv;
120#endif 120#endif
121 dev->hard_start_xmit = ieee80211_xmit;
122 121
123 memset(ieee, 0, sizeof(struct ieee80211_device)+sizeof_priv); 122 memset(ieee, 0, sizeof(struct ieee80211_device)+sizeof_priv);
124 ieee->dev = dev; 123 ieee->dev = dev;
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
index 1f50c46dcb90..191dc3fbbe32 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
@@ -548,21 +548,21 @@ int ieee80211_wx_get_name(struct ieee80211_device *ieee,
548 struct iw_request_info *info, 548 struct iw_request_info *info,
549 union iwreq_data *wrqu, char *extra) 549 union iwreq_data *wrqu, char *extra)
550{ 550{
551 strcpy(wrqu->name, "802.11"); 551 strlcpy(wrqu->name, "802.11", IFNAMSIZ);
552 if(ieee->modulation & IEEE80211_CCK_MODULATION){ 552 if(ieee->modulation & IEEE80211_CCK_MODULATION){
553 strcat(wrqu->name, "b"); 553 strlcat(wrqu->name, "b", IFNAMSIZ);
554 if(ieee->modulation & IEEE80211_OFDM_MODULATION) 554 if(ieee->modulation & IEEE80211_OFDM_MODULATION)
555 strcat(wrqu->name, "/g"); 555 strlcat(wrqu->name, "/g", IFNAMSIZ);
556 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION) 556 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
557 strcat(wrqu->name, "g"); 557 strlcat(wrqu->name, "g", IFNAMSIZ);
558 if (ieee->mode & (IEEE_N_24G | IEEE_N_5G)) 558 if (ieee->mode & (IEEE_N_24G | IEEE_N_5G))
559 strcat(wrqu->name, "/n"); 559 strlcat(wrqu->name, "/n", IFNAMSIZ);
560 560
561 if((ieee->state == IEEE80211_LINKED) || 561 if((ieee->state == IEEE80211_LINKED) ||
562 (ieee->state == IEEE80211_LINKED_SCANNING)) 562 (ieee->state == IEEE80211_LINKED_SCANNING))
563 strcat(wrqu->name," linked"); 563 strlcat(wrqu->name, " link", IFNAMSIZ);
564 else if(ieee->state != IEEE80211_NOLINK) 564 else if(ieee->state != IEEE80211_NOLINK)
565 strcat(wrqu->name," link.."); 565 strlcat(wrqu->name, " .....", IFNAMSIZ);
566 566
567 567
568 return 0; 568 return 0;
diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c
index f1423d714496..4ab250743e81 100644
--- a/drivers/staging/rtl8192su/r8192U_core.c
+++ b/drivers/staging/rtl8192su/r8192U_core.c
@@ -12132,6 +12132,19 @@ static void HalUsbSetQueuePipeMapping8192SUsb(struct usb_interface *intf, struct
12132} 12132}
12133#endif 12133#endif
12134 12134
12135static const struct net_device_ops rtl8192_netdev_ops = {
12136 .ndo_open = rtl8192_open,
12137 .ndo_stop = rtl8192_close,
12138 .ndo_get_stats = rtl8192_stats,
12139 .ndo_tx_timeout = tx_timeout,
12140 .ndo_do_ioctl = rtl8192_ioctl,
12141 .ndo_set_multicast_list = r8192_set_multicast,
12142 .ndo_set_mac_address = r8192_set_mac_adr,
12143 .ndo_validate_addr = eth_validate_addr,
12144 .ndo_change_mtu = eth_change_mtu,
12145 .ndo_start_xmit = ieee80211_xmit,
12146};
12147
12135#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) 12148#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
12136static int __devinit rtl8192_usb_probe(struct usb_interface *intf, 12149static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
12137 const struct usb_device_id *id) 12150 const struct usb_device_id *id)
@@ -12186,15 +12199,7 @@ static void * __devinit rtl8192_usb_probe(struct usb_device *udev,
12186 priv->ops = &rtl8192u_ops; 12199 priv->ops = &rtl8192u_ops;
12187#endif 12200#endif
12188 12201
12189 dev->open = rtl8192_open; 12202 dev->netdev_ops = &rtl8192_netdev_ops;
12190 dev->stop = rtl8192_close;
12191 //dev->hard_start_xmit = rtl8192_8023_hard_start_xmit;
12192 dev->tx_timeout = tx_timeout;
12193 //dev->wireless_handlers = &r8192_wx_handlers_def;
12194 dev->do_ioctl = rtl8192_ioctl;
12195 dev->set_multicast_list = r8192_set_multicast;
12196 dev->set_mac_address = r8192_set_mac_adr;
12197 dev->get_stats = rtl8192_stats;
12198 12203
12199 //DMESG("Oops: i'm coming\n"); 12204 //DMESG("Oops: i'm coming\n");
12200#if WIRELESS_EXT >= 12 12205#if WIRELESS_EXT >= 12
diff --git a/drivers/staging/rtl8192su/r8192U_pm.c b/drivers/staging/rtl8192su/r8192U_pm.c
index 92c95aa36638..b1531a8d0cde 100644
--- a/drivers/staging/rtl8192su/r8192U_pm.c
+++ b/drivers/staging/rtl8192su/r8192U_pm.c
@@ -35,7 +35,9 @@ int rtl8192U_suspend(struct usb_interface *intf, pm_message_t state)
35 return 0; 35 return 0;
36 } 36 }
37 37
38 dev->stop(dev); 38 if (dev->netdev_ops->ndo_stop)
39 dev->netdev_ops->ndo_stop(dev);
40
39 mdelay(10); 41 mdelay(10);
40 42
41 netif_device_detach(dev); 43 netif_device_detach(dev);
@@ -61,7 +63,9 @@ int rtl8192U_resume (struct usb_interface *intf)
61 } 63 }
62 64
63 netif_device_attach(dev); 65 netif_device_attach(dev);
64 dev->open(dev); 66
67 if (dev->netdev_ops->ndo_open)
68 dev->netdev_ops->ndo_open(dev);
65 } 69 }
66 70
67 return 0; 71 return 0;
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index 90b29b564631..a9bd4106beb7 100644
--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -866,7 +866,7 @@ static void qt_release(struct usb_serial *serial)
866 866
867} 867}
868 868
869int qt_open(struct tty_struct *tty, 869static int qt_open(struct tty_struct *tty,
870 struct usb_serial_port *port, struct file *filp) 870 struct usb_serial_port *port, struct file *filp)
871{ 871{
872 struct usb_serial *serial; 872 struct usb_serial *serial;
@@ -1041,17 +1041,19 @@ static void qt_block_until_empty(struct tty_struct *tty,
1041 } 1041 }
1042} 1042}
1043 1043
1044static void qt_close(struct tty_struct *tty, struct usb_serial_port *port, 1044static void qt_close( struct usb_serial_port *port)
1045 struct file *filp)
1046{ 1045{
1047 struct usb_serial *serial = port->serial; 1046 struct usb_serial *serial = port->serial;
1048 struct quatech_port *qt_port; 1047 struct quatech_port *qt_port;
1049 struct quatech_port *port0; 1048 struct quatech_port *port0;
1049 struct tty_struct *tty;
1050 int status; 1050 int status;
1051 unsigned int index; 1051 unsigned int index;
1052 status = 0; 1052 status = 0;
1053 1053
1054 dbg("%s - port %d\n", __func__, port->number); 1054 dbg("%s - port %d\n", __func__, port->number);
1055
1056 tty = tty_port_tty_get(&port->port);
1055 index = tty->index - serial->minor; 1057 index = tty->index - serial->minor;
1056 1058
1057 qt_port = qt_get_port_private(port); 1059 qt_port = qt_get_port_private(port);
diff --git a/drivers/staging/stlc45xx/stlc45xx.c b/drivers/staging/stlc45xx/stlc45xx.c
index cfdaac9b747e..a137c78fac09 100644
--- a/drivers/staging/stlc45xx/stlc45xx.c
+++ b/drivers/staging/stlc45xx/stlc45xx.c
@@ -2235,24 +2235,6 @@ static void stlc45xx_op_remove_interface(struct ieee80211_hw *hw,
2235 stlc45xx_debug(DEBUG_FUNC, "%s", __func__); 2235 stlc45xx_debug(DEBUG_FUNC, "%s", __func__);
2236} 2236}
2237 2237
2238static int stlc45xx_op_config_interface(struct ieee80211_hw *hw,
2239 struct ieee80211_vif *vif,
2240 struct ieee80211_if_conf *conf)
2241{
2242 struct stlc45xx *stlc = hw->priv;
2243
2244 stlc45xx_debug(DEBUG_FUNC, "%s", __func__);
2245
2246 mutex_lock(&stlc->mutex);
2247
2248 memcpy(stlc->bssid, conf->bssid, ETH_ALEN);
2249 stlc45xx_tx_setup(stlc);
2250
2251 mutex_unlock(&stlc->mutex);
2252
2253 return 0;
2254}
2255
2256static int stlc45xx_op_config(struct ieee80211_hw *hw, u32 changed) 2238static int stlc45xx_op_config(struct ieee80211_hw *hw, u32 changed)
2257{ 2239{
2258 struct stlc45xx *stlc = hw->priv; 2240 struct stlc45xx *stlc = hw->priv;
@@ -2295,6 +2277,14 @@ static void stlc45xx_op_bss_info_changed(struct ieee80211_hw *hw,
2295{ 2277{
2296 struct stlc45xx *stlc = hw->priv; 2278 struct stlc45xx *stlc = hw->priv;
2297 2279
2280 stlc45xx_debug(DEBUG_FUNC, "%s", __func__);
2281 mutex_lock(&stlc->mutex);
2282
2283 memcpy(stlc->bssid, info->bssid, ETH_ALEN);
2284 stlc45xx_tx_setup(stlc);
2285
2286 mutex_unlock(&stlc->mutex);
2287
2298 if (changed & BSS_CHANGED_ASSOC) { 2288 if (changed & BSS_CHANGED_ASSOC) {
2299 stlc->associated = info->assoc; 2289 stlc->associated = info->assoc;
2300 if (info->assoc) 2290 if (info->assoc)
@@ -2357,7 +2347,6 @@ static const struct ieee80211_ops stlc45xx_ops = {
2357 .add_interface = stlc45xx_op_add_interface, 2347 .add_interface = stlc45xx_op_add_interface,
2358 .remove_interface = stlc45xx_op_remove_interface, 2348 .remove_interface = stlc45xx_op_remove_interface,
2359 .config = stlc45xx_op_config, 2349 .config = stlc45xx_op_config,
2360 .config_interface = stlc45xx_op_config_interface,
2361 .configure_filter = stlc45xx_op_configure_filter, 2350 .configure_filter = stlc45xx_op_configure_filter,
2362 .tx = stlc45xx_op_tx, 2351 .tx = stlc45xx_op_tx,
2363 .bss_info_changed = stlc45xx_op_bss_info_changed, 2352 .bss_info_changed = stlc45xx_op_bss_info_changed,
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c
index 22f93dd0ba03..251220dc8851 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -18,6 +18,7 @@
18 */ 18 */
19 19
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/smp_lock.h>
21#include <linux/file.h> 22#include <linux/file.h>
22#include <linux/tcp.h> 23#include <linux/tcp.h>
23#include <linux/in.h> 24#include <linux/in.h>
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index a10ed27acbc2..f43ca416e4a8 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -344,7 +344,7 @@ static CHIP_INFO chip_info_table[]= {
344}; 344};
345 345
346static struct pci_device_id device_id_table[] __devinitdata = { 346static struct pci_device_id device_id_table[] __devinitdata = {
347{ 0x1106, 0x3253, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (int)&chip_info_table[0]}, 347{ 0x1106, 0x3253, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long)&chip_info_table[0]},
348{ 0, } 348{ 0, }
349}; 349};
350#endif 350#endif
@@ -369,7 +369,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
369 369
370#ifdef CONFIG_PM 370#ifdef CONFIG_PM
371static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr); 371static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
372static int viawget_suspend(struct pci_dev *pcid, u32 state); 372static int viawget_suspend(struct pci_dev *pcid, pm_message_t state);
373static int viawget_resume(struct pci_dev *pcid); 373static int viawget_resume(struct pci_dev *pcid);
374struct notifier_block device_notifier = { 374struct notifier_block device_notifier = {
375 notifier_call: device_notify_reboot, 375 notifier_call: device_notify_reboot,
@@ -3941,7 +3941,7 @@ device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
3941 while ((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { 3941 while ((pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
3942 if(pci_dev_driver(pdev) == &device_driver) { 3942 if(pci_dev_driver(pdev) == &device_driver) {
3943 if (pci_get_drvdata(pdev)) 3943 if (pci_get_drvdata(pdev))
3944 viawget_suspend(pdev, 3); 3944 viawget_suspend(pdev, PMSG_HIBERNATE);
3945 } 3945 }
3946 } 3946 }
3947 } 3947 }
@@ -3949,7 +3949,7 @@ device_notify_reboot(struct notifier_block *nb, unsigned long event, void *p)
3949} 3949}
3950 3950
3951static int 3951static int
3952viawget_suspend(struct pci_dev *pcid, u32 state) 3952viawget_suspend(struct pci_dev *pcid, pm_message_t state)
3953{ 3953{
3954 int power_status; // to silence the compiler 3954 int power_status; // to silence the compiler
3955 3955
@@ -3971,7 +3971,7 @@ viawget_suspend(struct pci_dev *pcid, u32 state)
3971 memset(pMgmt->abyCurrBSSID, 0, 6); 3971 memset(pMgmt->abyCurrBSSID, 0, 6);
3972 pMgmt->eCurrState = WMAC_STATE_IDLE; 3972 pMgmt->eCurrState = WMAC_STATE_IDLE;
3973 pci_disable_device(pcid); 3973 pci_disable_device(pcid);
3974 power_status = pci_set_power_state(pcid, state); 3974 power_status = pci_set_power_state(pcid, pci_choose_state(pcid, state));
3975 spin_unlock_irq(&pDevice->lock); 3975 spin_unlock_irq(&pDevice->lock);
3976 return 0; 3976 return 0;
3977} 3977}
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index a913efc69669..40de151f2789 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -257,6 +257,7 @@
257#include <linux/fs.h> /* everything... */ 257#include <linux/fs.h> /* everything... */
258#include <linux/errno.h> /* error codes */ 258#include <linux/errno.h> /* error codes */
259#include <linux/slab.h> 259#include <linux/slab.h>
260#include <linux/smp_lock.h>
260#include <linux/mm.h> 261#include <linux/mm.h>
261#include <linux/ioport.h> 262#include <linux/ioport.h>
262#include <linux/interrupt.h> 263#include <linux/interrupt.h>
diff --git a/drivers/telephony/phonedev.c b/drivers/telephony/phonedev.c
index b52cc830c0b4..f3873f650bb4 100644
--- a/drivers/telephony/phonedev.c
+++ b/drivers/telephony/phonedev.c
@@ -23,7 +23,6 @@
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/phonedev.h> 24#include <linux/phonedev.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/smp_lock.h>
27#include <asm/uaccess.h> 26#include <asm/uaccess.h>
28#include <asm/system.h> 27#include <asm/system.h>
29 28
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 38bfdb0f6660..5b15d9d8896b 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -387,6 +387,7 @@ static void acm_rx_tasklet(unsigned long _acm)
387 struct acm_ru *rcv; 387 struct acm_ru *rcv;
388 unsigned long flags; 388 unsigned long flags;
389 unsigned char throttled; 389 unsigned char throttled;
390 struct usb_host_endpoint *ep;
390 391
391 dbg("Entering acm_rx_tasklet"); 392 dbg("Entering acm_rx_tasklet");
392 393
@@ -462,11 +463,20 @@ urbs:
462 463
463 rcv->buffer = buf; 464 rcv->buffer = buf;
464 465
465 usb_fill_bulk_urb(rcv->urb, acm->dev, 466 ep = (usb_pipein(acm->rx_endpoint) ? acm->dev->ep_in : acm->dev->ep_out)
466 acm->rx_endpoint, 467 [usb_pipeendpoint(acm->rx_endpoint)];
467 buf->base, 468 if (usb_endpoint_xfer_int(&ep->desc))
468 acm->readsize, 469 usb_fill_int_urb(rcv->urb, acm->dev,
469 acm_read_bulk, rcv); 470 acm->rx_endpoint,
471 buf->base,
472 acm->readsize,
473 acm_read_bulk, rcv, ep->desc.bInterval);
474 else
475 usb_fill_bulk_urb(rcv->urb, acm->dev,
476 acm->rx_endpoint,
477 buf->base,
478 acm->readsize,
479 acm_read_bulk, rcv);
470 rcv->urb->transfer_dma = buf->dma; 480 rcv->urb->transfer_dma = buf->dma;
471 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 481 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
472 482
@@ -550,7 +560,7 @@ static void acm_waker(struct work_struct *waker)
550static int acm_tty_open(struct tty_struct *tty, struct file *filp) 560static int acm_tty_open(struct tty_struct *tty, struct file *filp)
551{ 561{
552 struct acm *acm; 562 struct acm *acm;
553 int rv = -EINVAL; 563 int rv = -ENODEV;
554 int i; 564 int i;
555 dbg("Entering acm_tty_open."); 565 dbg("Entering acm_tty_open.");
556 566
@@ -677,7 +687,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
677 687
678 /* Perform the closing process and see if we need to do the hardware 688 /* Perform the closing process and see if we need to do the hardware
679 shutdown */ 689 shutdown */
680 if (tty_port_close_start(&acm->port, tty, filp) == 0) 690 if (!acm || tty_port_close_start(&acm->port, tty, filp) == 0)
681 return; 691 return;
682 acm_port_down(acm, 0); 692 acm_port_down(acm, 0);
683 tty_port_close_end(&acm->port, tty); 693 tty_port_close_end(&acm->port, tty);
@@ -1227,9 +1237,14 @@ made_compressed_probe:
1227 goto alloc_fail7; 1237 goto alloc_fail7;
1228 } 1238 }
1229 1239
1230 usb_fill_bulk_urb(snd->urb, usb_dev, 1240 if (usb_endpoint_xfer_int(epwrite))
1231 usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), 1241 usb_fill_int_urb(snd->urb, usb_dev,
1232 NULL, acm->writesize, acm_write_bulk, snd); 1242 usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
1243 NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval);
1244 else
1245 usb_fill_bulk_urb(snd->urb, usb_dev,
1246 usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
1247 NULL, acm->writesize, acm_write_bulk, snd);
1233 snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1248 snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1234 snd->instance = acm; 1249 snd->instance = acm;
1235 } 1250 }
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 0fe434505ac4..ba589d4ca8bc 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -15,7 +15,6 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/smp_lock.h>
19#include <linux/mutex.h> 18#include <linux/mutex.h>
20#include <linux/uaccess.h> 19#include <linux/uaccess.h>
21#include <linux/bitops.h> 20#include <linux/bitops.h>
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 3703789d0d2a..b09a527f7341 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -751,7 +751,7 @@ static int get_capabilities(struct usbtmc_device_data *data)
751{ 751{
752 struct device *dev = &data->usb_dev->dev; 752 struct device *dev = &data->usb_dev->dev;
753 char *buffer; 753 char *buffer;
754 int rv; 754 int rv = 0;
755 755
756 buffer = kmalloc(0x18, GFP_KERNEL); 756 buffer = kmalloc(0x18, GFP_KERNEL);
757 if (!buffer) 757 if (!buffer)
@@ -763,7 +763,7 @@ static int get_capabilities(struct usbtmc_device_data *data)
763 0, 0, buffer, 0x18, USBTMC_TIMEOUT); 763 0, 0, buffer, 0x18, USBTMC_TIMEOUT);
764 if (rv < 0) { 764 if (rv < 0) {
765 dev_err(dev, "usb_control_msg returned %d\n", rv); 765 dev_err(dev, "usb_control_msg returned %d\n", rv);
766 return rv; 766 goto err_out;
767 } 767 }
768 768
769 dev_dbg(dev, "GET_CAPABILITIES returned %x\n", buffer[0]); 769 dev_dbg(dev, "GET_CAPABILITIES returned %x\n", buffer[0]);
@@ -773,7 +773,8 @@ static int get_capabilities(struct usbtmc_device_data *data)
773 dev_dbg(dev, "USB488 device capabilities are %x\n", buffer[15]); 773 dev_dbg(dev, "USB488 device capabilities are %x\n", buffer[15]);
774 if (buffer[0] != USBTMC_STATUS_SUCCESS) { 774 if (buffer[0] != USBTMC_STATUS_SUCCESS) {
775 dev_err(dev, "GET_CAPABILITIES returned %x\n", buffer[0]); 775 dev_err(dev, "GET_CAPABILITIES returned %x\n", buffer[0]);
776 return -EPERM; 776 rv = -EPERM;
777 goto err_out;
777 } 778 }
778 779
779 data->capabilities.interface_capabilities = buffer[4]; 780 data->capabilities.interface_capabilities = buffer[4];
@@ -781,8 +782,9 @@ static int get_capabilities(struct usbtmc_device_data *data)
781 data->capabilities.usb488_interface_capabilities = buffer[14]; 782 data->capabilities.usb488_interface_capabilities = buffer[14];
782 data->capabilities.usb488_device_capabilities = buffer[15]; 783 data->capabilities.usb488_device_capabilities = buffer[15];
783 784
785err_out:
784 kfree(buffer); 786 kfree(buffer);
785 return 0; 787 return rv;
786} 788}
787 789
788#define capability_attribute(name) \ 790#define capability_attribute(name) \
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 69280c35b5cb..ad925946f869 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -28,7 +28,7 @@ comment "Miscellaneous USB options"
28 depends on USB 28 depends on USB
29 29
30config USB_DEVICEFS 30config USB_DEVICEFS
31 bool "USB device filesystem (DEPRECATED)" if EMBEDDED 31 bool "USB device filesystem (DEPRECATED)"
32 depends on USB 32 depends on USB
33 ---help--- 33 ---help---
34 If you say Y here (and to "/proc file system support" in the "File 34 If you say Y here (and to "/proc file system support" in the "File
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 73c108d117b4..96f11715cd26 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -136,17 +136,19 @@ static const struct class_info clas_info[] =
136 {USB_CLASS_AUDIO, "audio"}, 136 {USB_CLASS_AUDIO, "audio"},
137 {USB_CLASS_COMM, "comm."}, 137 {USB_CLASS_COMM, "comm."},
138 {USB_CLASS_HID, "HID"}, 138 {USB_CLASS_HID, "HID"},
139 {USB_CLASS_HUB, "hub"},
140 {USB_CLASS_PHYSICAL, "PID"}, 139 {USB_CLASS_PHYSICAL, "PID"},
140 {USB_CLASS_STILL_IMAGE, "still"},
141 {USB_CLASS_PRINTER, "print"}, 141 {USB_CLASS_PRINTER, "print"},
142 {USB_CLASS_MASS_STORAGE, "stor."}, 142 {USB_CLASS_MASS_STORAGE, "stor."},
143 {USB_CLASS_HUB, "hub"},
143 {USB_CLASS_CDC_DATA, "data"}, 144 {USB_CLASS_CDC_DATA, "data"},
144 {USB_CLASS_APP_SPEC, "app."},
145 {USB_CLASS_VENDOR_SPEC, "vend."},
146 {USB_CLASS_STILL_IMAGE, "still"},
147 {USB_CLASS_CSCID, "scard"}, 145 {USB_CLASS_CSCID, "scard"},
148 {USB_CLASS_CONTENT_SEC, "c-sec"}, 146 {USB_CLASS_CONTENT_SEC, "c-sec"},
149 {USB_CLASS_VIDEO, "video"}, 147 {USB_CLASS_VIDEO, "video"},
148 {USB_CLASS_WIRELESS_CONTROLLER, "wlcon"},
149 {USB_CLASS_MISC, "misc"},
150 {USB_CLASS_APP_SPEC, "app."},
151 {USB_CLASS_VENDOR_SPEC, "vend."},
150 {-1, "unk."} /* leave as last */ 152 {-1, "unk."} /* leave as last */
151}; 153};
152 154
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 308609039c73..38b8bce782d6 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -325,21 +325,34 @@ static void async_completed(struct urb *urb)
325 struct async *as = urb->context; 325 struct async *as = urb->context;
326 struct dev_state *ps = as->ps; 326 struct dev_state *ps = as->ps;
327 struct siginfo sinfo; 327 struct siginfo sinfo;
328 struct pid *pid = NULL;
329 uid_t uid = 0;
330 uid_t euid = 0;
331 u32 secid = 0;
332 int signr;
328 333
329 spin_lock(&ps->lock); 334 spin_lock(&ps->lock);
330 list_move_tail(&as->asynclist, &ps->async_completed); 335 list_move_tail(&as->asynclist, &ps->async_completed);
331 spin_unlock(&ps->lock);
332 as->status = urb->status; 336 as->status = urb->status;
333 if (as->signr) { 337 signr = as->signr;
338 if (signr) {
334 sinfo.si_signo = as->signr; 339 sinfo.si_signo = as->signr;
335 sinfo.si_errno = as->status; 340 sinfo.si_errno = as->status;
336 sinfo.si_code = SI_ASYNCIO; 341 sinfo.si_code = SI_ASYNCIO;
337 sinfo.si_addr = as->userurb; 342 sinfo.si_addr = as->userurb;
338 kill_pid_info_as_uid(as->signr, &sinfo, as->pid, as->uid, 343 pid = as->pid;
339 as->euid, as->secid); 344 uid = as->uid;
345 euid = as->euid;
346 secid = as->secid;
340 } 347 }
341 snoop(&urb->dev->dev, "urb complete\n"); 348 snoop(&urb->dev->dev, "urb complete\n");
342 snoop_urb(urb, as->userurb); 349 snoop_urb(urb, as->userurb);
350 spin_unlock(&ps->lock);
351
352 if (signr)
353 kill_pid_info_as_uid(sinfo.si_signo, &sinfo, pid, uid,
354 euid, secid);
355
343 wake_up(&ps->wait); 356 wake_up(&ps->wait);
344} 357}
345 358
@@ -982,7 +995,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
982 USBDEVFS_URB_ZERO_PACKET | 995 USBDEVFS_URB_ZERO_PACKET |
983 USBDEVFS_URB_NO_INTERRUPT)) 996 USBDEVFS_URB_NO_INTERRUPT))
984 return -EINVAL; 997 return -EINVAL;
985 if (!uurb->buffer) 998 if (uurb->buffer_length > 0 && !uurb->buffer)
986 return -EINVAL; 999 return -EINVAL;
987 if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && 1000 if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL &&
988 (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { 1001 (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) {
@@ -1038,11 +1051,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1038 is_in = 0; 1051 is_in = 0;
1039 uurb->endpoint &= ~USB_DIR_IN; 1052 uurb->endpoint &= ~USB_DIR_IN;
1040 } 1053 }
1041 if (!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
1042 uurb->buffer, uurb->buffer_length)) {
1043 kfree(dr);
1044 return -EFAULT;
1045 }
1046 snoop(&ps->dev->dev, "control urb: bRequest=%02x " 1054 snoop(&ps->dev->dev, "control urb: bRequest=%02x "
1047 "bRrequestType=%02x wValue=%04x " 1055 "bRrequestType=%02x wValue=%04x "
1048 "wIndex=%04x wLength=%04x\n", 1056 "wIndex=%04x wLength=%04x\n",
@@ -1062,9 +1070,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1062 uurb->number_of_packets = 0; 1070 uurb->number_of_packets = 0;
1063 if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) 1071 if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE)
1064 return -EINVAL; 1072 return -EINVAL;
1065 if (!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
1066 uurb->buffer, uurb->buffer_length))
1067 return -EFAULT;
1068 snoop(&ps->dev->dev, "bulk urb\n"); 1073 snoop(&ps->dev->dev, "bulk urb\n");
1069 break; 1074 break;
1070 1075
@@ -1106,28 +1111,35 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1106 return -EINVAL; 1111 return -EINVAL;
1107 if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE) 1112 if (uurb->buffer_length > MAX_USBFS_BUFFER_SIZE)
1108 return -EINVAL; 1113 return -EINVAL;
1109 if (!access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
1110 uurb->buffer, uurb->buffer_length))
1111 return -EFAULT;
1112 snoop(&ps->dev->dev, "interrupt urb\n"); 1114 snoop(&ps->dev->dev, "interrupt urb\n");
1113 break; 1115 break;
1114 1116
1115 default: 1117 default:
1116 return -EINVAL; 1118 return -EINVAL;
1117 } 1119 }
1118 as = alloc_async(uurb->number_of_packets); 1120 if (uurb->buffer_length > 0 &&
1119 if (!as) { 1121 !access_ok(is_in ? VERIFY_WRITE : VERIFY_READ,
1122 uurb->buffer, uurb->buffer_length)) {
1120 kfree(isopkt); 1123 kfree(isopkt);
1121 kfree(dr); 1124 kfree(dr);
1122 return -ENOMEM; 1125 return -EFAULT;
1123 } 1126 }
1124 as->urb->transfer_buffer = kmalloc(uurb->buffer_length, GFP_KERNEL); 1127 as = alloc_async(uurb->number_of_packets);
1125 if (!as->urb->transfer_buffer) { 1128 if (!as) {
1126 kfree(isopkt); 1129 kfree(isopkt);
1127 kfree(dr); 1130 kfree(dr);
1128 free_async(as);
1129 return -ENOMEM; 1131 return -ENOMEM;
1130 } 1132 }
1133 if (uurb->buffer_length > 0) {
1134 as->urb->transfer_buffer = kmalloc(uurb->buffer_length,
1135 GFP_KERNEL);
1136 if (!as->urb->transfer_buffer) {
1137 kfree(isopkt);
1138 kfree(dr);
1139 free_async(as);
1140 return -ENOMEM;
1141 }
1142 }
1131 as->urb->dev = ps->dev; 1143 as->urb->dev = ps->dev;
1132 as->urb->pipe = (uurb->type << 30) | 1144 as->urb->pipe = (uurb->type << 30) |
1133 __create_pipe(ps->dev, uurb->endpoint & 0xf) | 1145 __create_pipe(ps->dev, uurb->endpoint & 0xf) |
@@ -1169,7 +1181,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1169 kfree(isopkt); 1181 kfree(isopkt);
1170 as->ps = ps; 1182 as->ps = ps;
1171 as->userurb = arg; 1183 as->userurb = arg;
1172 if (uurb->endpoint & USB_DIR_IN) 1184 if (is_in && uurb->buffer_length > 0)
1173 as->userbuffer = uurb->buffer; 1185 as->userbuffer = uurb->buffer;
1174 else 1186 else
1175 as->userbuffer = NULL; 1187 as->userbuffer = NULL;
@@ -1179,9 +1191,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1179 as->uid = cred->uid; 1191 as->uid = cred->uid;
1180 as->euid = cred->euid; 1192 as->euid = cred->euid;
1181 security_task_getsecid(current, &as->secid); 1193 security_task_getsecid(current, &as->secid);
1182 if (!is_in) { 1194 if (!is_in && uurb->buffer_length > 0) {
1183 if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, 1195 if (copy_from_user(as->urb->transfer_buffer, uurb->buffer,
1184 as->urb->transfer_buffer_length)) { 1196 uurb->buffer_length)) {
1185 free_async(as); 1197 free_async(as);
1186 return -EFAULT; 1198 return -EFAULT;
1187 } 1199 }
@@ -1231,22 +1243,22 @@ static int processcompl(struct async *as, void __user * __user *arg)
1231 if (as->userbuffer) 1243 if (as->userbuffer)
1232 if (copy_to_user(as->userbuffer, urb->transfer_buffer, 1244 if (copy_to_user(as->userbuffer, urb->transfer_buffer,
1233 urb->transfer_buffer_length)) 1245 urb->transfer_buffer_length))
1234 return -EFAULT; 1246 goto err_out;
1235 if (put_user(as->status, &userurb->status)) 1247 if (put_user(as->status, &userurb->status))
1236 return -EFAULT; 1248 goto err_out;
1237 if (put_user(urb->actual_length, &userurb->actual_length)) 1249 if (put_user(urb->actual_length, &userurb->actual_length))
1238 return -EFAULT; 1250 goto err_out;
1239 if (put_user(urb->error_count, &userurb->error_count)) 1251 if (put_user(urb->error_count, &userurb->error_count))
1240 return -EFAULT; 1252 goto err_out;
1241 1253
1242 if (usb_endpoint_xfer_isoc(&urb->ep->desc)) { 1254 if (usb_endpoint_xfer_isoc(&urb->ep->desc)) {
1243 for (i = 0; i < urb->number_of_packets; i++) { 1255 for (i = 0; i < urb->number_of_packets; i++) {
1244 if (put_user(urb->iso_frame_desc[i].actual_length, 1256 if (put_user(urb->iso_frame_desc[i].actual_length,
1245 &userurb->iso_frame_desc[i].actual_length)) 1257 &userurb->iso_frame_desc[i].actual_length))
1246 return -EFAULT; 1258 goto err_out;
1247 if (put_user(urb->iso_frame_desc[i].status, 1259 if (put_user(urb->iso_frame_desc[i].status,
1248 &userurb->iso_frame_desc[i].status)) 1260 &userurb->iso_frame_desc[i].status))
1249 return -EFAULT; 1261 goto err_out;
1250 } 1262 }
1251 } 1263 }
1252 1264
@@ -1255,6 +1267,10 @@ static int processcompl(struct async *as, void __user * __user *arg)
1255 if (put_user(addr, (void __user * __user *)arg)) 1267 if (put_user(addr, (void __user * __user *)arg))
1256 return -EFAULT; 1268 return -EFAULT;
1257 return 0; 1269 return 0;
1270
1271err_out:
1272 free_async(as);
1273 return -EFAULT;
1258} 1274}
1259 1275
1260static struct async *reap_as(struct dev_state *ps) 1276static struct async *reap_as(struct dev_state *ps)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index ce3f453f02ef..95ccfa0b9fc5 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -648,7 +648,7 @@ void usb_hcd_poll_rh_status(struct usb_hcd *hcd)
648 struct urb *urb; 648 struct urb *urb;
649 int length; 649 int length;
650 unsigned long flags; 650 unsigned long flags;
651 char buffer[4]; /* Any root hubs with > 31 ports? */ 651 char buffer[6]; /* Any root hubs with > 31 ports? */
652 652
653 if (unlikely(!hcd->rh_registered)) 653 if (unlikely(!hcd->rh_registered))
654 return; 654 return;
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index d397ecfd5b17..ec5c67ea07b7 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -227,6 +227,10 @@ struct hc_driver {
227 /* has a port been handed over to a companion? */ 227 /* has a port been handed over to a companion? */
228 int (*port_handed_over)(struct usb_hcd *, int); 228 int (*port_handed_over)(struct usb_hcd *, int);
229 229
230 /* CLEAR_TT_BUFFER completion callback */
231 void (*clear_tt_buffer_complete)(struct usb_hcd *,
232 struct usb_host_endpoint *);
233
230 /* xHCI specific functions */ 234 /* xHCI specific functions */
231 /* Called by usb_alloc_dev to alloc HC device structures */ 235 /* Called by usb_alloc_dev to alloc HC device structures */
232 int (*alloc_dev)(struct usb_hcd *, struct usb_device *); 236 int (*alloc_dev)(struct usb_hcd *, struct usb_device *);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 2af3b4f06054..71f86c60d83c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -450,10 +450,10 @@ hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
450 * talking to TTs must queue control transfers (not just bulk and iso), so 450 * talking to TTs must queue control transfers (not just bulk and iso), so
451 * both can talk to the same hub concurrently. 451 * both can talk to the same hub concurrently.
452 */ 452 */
453static void hub_tt_kevent (struct work_struct *work) 453static void hub_tt_work(struct work_struct *work)
454{ 454{
455 struct usb_hub *hub = 455 struct usb_hub *hub =
456 container_of(work, struct usb_hub, tt.kevent); 456 container_of(work, struct usb_hub, tt.clear_work);
457 unsigned long flags; 457 unsigned long flags;
458 int limit = 100; 458 int limit = 100;
459 459
@@ -462,6 +462,7 @@ static void hub_tt_kevent (struct work_struct *work)
462 struct list_head *next; 462 struct list_head *next;
463 struct usb_tt_clear *clear; 463 struct usb_tt_clear *clear;
464 struct usb_device *hdev = hub->hdev; 464 struct usb_device *hdev = hub->hdev;
465 const struct hc_driver *drv;
465 int status; 466 int status;
466 467
467 next = hub->tt.clear_list.next; 468 next = hub->tt.clear_list.next;
@@ -471,21 +472,25 @@ static void hub_tt_kevent (struct work_struct *work)
471 /* drop lock so HCD can concurrently report other TT errors */ 472 /* drop lock so HCD can concurrently report other TT errors */
472 spin_unlock_irqrestore (&hub->tt.lock, flags); 473 spin_unlock_irqrestore (&hub->tt.lock, flags);
473 status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt); 474 status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt);
474 spin_lock_irqsave (&hub->tt.lock, flags);
475
476 if (status) 475 if (status)
477 dev_err (&hdev->dev, 476 dev_err (&hdev->dev,
478 "clear tt %d (%04x) error %d\n", 477 "clear tt %d (%04x) error %d\n",
479 clear->tt, clear->devinfo, status); 478 clear->tt, clear->devinfo, status);
479
480 /* Tell the HCD, even if the operation failed */
481 drv = clear->hcd->driver;
482 if (drv->clear_tt_buffer_complete)
483 (drv->clear_tt_buffer_complete)(clear->hcd, clear->ep);
484
480 kfree(clear); 485 kfree(clear);
486 spin_lock_irqsave(&hub->tt.lock, flags);
481 } 487 }
482 spin_unlock_irqrestore (&hub->tt.lock, flags); 488 spin_unlock_irqrestore (&hub->tt.lock, flags);
483} 489}
484 490
485/** 491/**
486 * usb_hub_tt_clear_buffer - clear control/bulk TT state in high speed hub 492 * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub
487 * @udev: the device whose split transaction failed 493 * @urb: an URB associated with the failed or incomplete split transaction
488 * @pipe: identifies the endpoint of the failed transaction
489 * 494 *
490 * High speed HCDs use this to tell the hub driver that some split control or 495 * High speed HCDs use this to tell the hub driver that some split control or
491 * bulk transaction failed in a way that requires clearing internal state of 496 * bulk transaction failed in a way that requires clearing internal state of
@@ -495,8 +500,10 @@ static void hub_tt_kevent (struct work_struct *work)
495 * It may not be possible for that hub to handle additional full (or low) 500 * It may not be possible for that hub to handle additional full (or low)
496 * speed transactions until that state is fully cleared out. 501 * speed transactions until that state is fully cleared out.
497 */ 502 */
498void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe) 503int usb_hub_clear_tt_buffer(struct urb *urb)
499{ 504{
505 struct usb_device *udev = urb->dev;
506 int pipe = urb->pipe;
500 struct usb_tt *tt = udev->tt; 507 struct usb_tt *tt = udev->tt;
501 unsigned long flags; 508 unsigned long flags;
502 struct usb_tt_clear *clear; 509 struct usb_tt_clear *clear;
@@ -508,7 +515,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
508 if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) { 515 if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) {
509 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n"); 516 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
510 /* FIXME recover somehow ... RESET_TT? */ 517 /* FIXME recover somehow ... RESET_TT? */
511 return; 518 return -ENOMEM;
512 } 519 }
513 520
514 /* info that CLEAR_TT_BUFFER needs */ 521 /* info that CLEAR_TT_BUFFER needs */
@@ -520,14 +527,19 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
520 : (USB_ENDPOINT_XFER_BULK << 11); 527 : (USB_ENDPOINT_XFER_BULK << 11);
521 if (usb_pipein (pipe)) 528 if (usb_pipein (pipe))
522 clear->devinfo |= 1 << 15; 529 clear->devinfo |= 1 << 15;
523 530
531 /* info for completion callback */
532 clear->hcd = bus_to_hcd(udev->bus);
533 clear->ep = urb->ep;
534
524 /* tell keventd to clear state for this TT */ 535 /* tell keventd to clear state for this TT */
525 spin_lock_irqsave (&tt->lock, flags); 536 spin_lock_irqsave (&tt->lock, flags);
526 list_add_tail (&clear->clear_list, &tt->clear_list); 537 list_add_tail (&clear->clear_list, &tt->clear_list);
527 schedule_work (&tt->kevent); 538 schedule_work(&tt->clear_work);
528 spin_unlock_irqrestore (&tt->lock, flags); 539 spin_unlock_irqrestore (&tt->lock, flags);
540 return 0;
529} 541}
530EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer); 542EXPORT_SYMBOL_GPL(usb_hub_clear_tt_buffer);
531 543
532/* If do_delay is false, return the number of milliseconds the caller 544/* If do_delay is false, return the number of milliseconds the caller
533 * needs to delay. 545 * needs to delay.
@@ -818,7 +830,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
818 if (hub->has_indicators) 830 if (hub->has_indicators)
819 cancel_delayed_work_sync(&hub->leds); 831 cancel_delayed_work_sync(&hub->leds);
820 if (hub->tt.hub) 832 if (hub->tt.hub)
821 cancel_work_sync(&hub->tt.kevent); 833 cancel_work_sync(&hub->tt.clear_work);
822} 834}
823 835
824/* caller has locked the hub device */ 836/* caller has locked the hub device */
@@ -935,7 +947,7 @@ static int hub_configure(struct usb_hub *hub,
935 947
936 spin_lock_init (&hub->tt.lock); 948 spin_lock_init (&hub->tt.lock);
937 INIT_LIST_HEAD (&hub->tt.clear_list); 949 INIT_LIST_HEAD (&hub->tt.clear_list);
938 INIT_WORK (&hub->tt.kevent, hub_tt_kevent); 950 INIT_WORK(&hub->tt.clear_work, hub_tt_work);
939 switch (hdev->descriptor.bDeviceProtocol) { 951 switch (hdev->descriptor.bDeviceProtocol) {
940 case 0: 952 case 0:
941 break; 953 break;
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 889c0f32a40b..de8081f065ed 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -188,16 +188,18 @@ struct usb_tt {
188 /* for control/bulk error recovery (CLEAR_TT_BUFFER) */ 188 /* for control/bulk error recovery (CLEAR_TT_BUFFER) */
189 spinlock_t lock; 189 spinlock_t lock;
190 struct list_head clear_list; /* of usb_tt_clear */ 190 struct list_head clear_list; /* of usb_tt_clear */
191 struct work_struct kevent; 191 struct work_struct clear_work;
192}; 192};
193 193
194struct usb_tt_clear { 194struct usb_tt_clear {
195 struct list_head clear_list; 195 struct list_head clear_list;
196 unsigned tt; 196 unsigned tt;
197 u16 devinfo; 197 u16 devinfo;
198 struct usb_hcd *hcd;
199 struct usb_host_endpoint *ep;
198}; 200};
199 201
200extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe); 202extern int usb_hub_clear_tt_buffer(struct urb *urb);
201extern void usb_ep0_reinit(struct usb_device *); 203extern void usb_ep0_reinit(struct usb_device *);
202 204
203#endif /* __LINUX_HUB_H */ 205#endif /* __LINUX_HUB_H */
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 2bed83caacb1..9720e699f472 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -806,6 +806,48 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid,
806 return rc; 806 return rc;
807} 807}
808 808
809static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)
810{
811 int err;
812
813 if (dev->have_langid)
814 return 0;
815
816 if (dev->string_langid < 0)
817 return -EPIPE;
818
819 err = usb_string_sub(dev, 0, 0, tbuf);
820
821 /* If the string was reported but is malformed, default to english
822 * (0x0409) */
823 if (err == -ENODATA || (err > 0 && err < 4)) {
824 dev->string_langid = 0x0409;
825 dev->have_langid = 1;
826 dev_err(&dev->dev,
827 "string descriptor 0 malformed (err = %d), "
828 "defaulting to 0x%04x\n",
829 err, dev->string_langid);
830 return 0;
831 }
832
833 /* In case of all other errors, we assume the device is not able to
834 * deal with strings at all. Set string_langid to -1 in order to
835 * prevent any string to be retrieved from the device */
836 if (err < 0) {
837 dev_err(&dev->dev, "string descriptor 0 read error: %d\n",
838 err);
839 dev->string_langid = -1;
840 return -EPIPE;
841 }
842
843 /* always use the first langid listed */
844 dev->string_langid = tbuf[2] | (tbuf[3] << 8);
845 dev->have_langid = 1;
846 dev_dbg(&dev->dev, "default language 0x%04x\n",
847 dev->string_langid);
848 return 0;
849}
850
809/** 851/**
810 * usb_string - returns UTF-8 version of a string descriptor 852 * usb_string - returns UTF-8 version of a string descriptor
811 * @dev: the device whose string descriptor is being retrieved 853 * @dev: the device whose string descriptor is being retrieved
@@ -837,24 +879,9 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
837 if (!tbuf) 879 if (!tbuf)
838 return -ENOMEM; 880 return -ENOMEM;
839 881
840 /* get langid for strings if it's not yet known */ 882 err = usb_get_langid(dev, tbuf);
841 if (!dev->have_langid) { 883 if (err < 0)
842 err = usb_string_sub(dev, 0, 0, tbuf); 884 goto errout;
843 if (err < 0) {
844 dev_err(&dev->dev,
845 "string descriptor 0 read error: %d\n",
846 err);
847 } else if (err < 4) {
848 dev_err(&dev->dev, "string descriptor 0 too short\n");
849 } else {
850 dev->string_langid = tbuf[2] | (tbuf[3] << 8);
851 /* always use the first langid listed */
852 dev_dbg(&dev->dev, "default language 0x%04x\n",
853 dev->string_langid);
854 }
855
856 dev->have_langid = 1;
857 }
858 885
859 err = usb_string_sub(dev, dev->string_langid, index, tbuf); 886 err = usb_string_sub(dev, dev->string_langid, index, tbuf);
860 if (err < 0) 887 if (err < 0)
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 5d1ddf485d1e..7f8e83a954ac 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -286,6 +286,27 @@ config USB_S3C_HSOTG
286 default USB_GADGET 286 default USB_GADGET
287 select USB_GADGET_SELECTED 287 select USB_GADGET_SELECTED
288 288
289config USB_GADGET_IMX
290 boolean "Freescale IMX USB Peripheral Controller"
291 depends on ARCH_MX1
292 help
293 Freescale's IMX series include an integrated full speed
294 USB 1.1 device controller. The controller in the IMX series
295 is register-compatible.
296
297 It has Six fixed-function endpoints, as well as endpoint
298 zero (for control transfers).
299
300 Say "y" to link the driver statically, or "m" to build a
301 dynamically linked module called "imx_udc" and force all
302 gadget drivers to also be dynamically linked.
303
304config USB_IMX
305 tristate
306 depends on USB_GADGET_IMX
307 default USB_GADGET
308 select USB_GADGET_SELECTED
309
289config USB_GADGET_S3C2410 310config USB_GADGET_S3C2410
290 boolean "S3C2410 USB Device Controller" 311 boolean "S3C2410 USB Device Controller"
291 depends on ARCH_S3C2410 312 depends on ARCH_S3C2410
@@ -321,27 +342,6 @@ config USB_GADGET_MUSB_HDRC
321 This OTG-capable silicon IP is used in dual designs including 342 This OTG-capable silicon IP is used in dual designs including
322 the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI Blackfin 343 the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI Blackfin
323 344
324config USB_GADGET_IMX
325 boolean "Freescale IMX USB Peripheral Controller"
326 depends on ARCH_MX1
327 help
328 Freescale's IMX series include an integrated full speed
329 USB 1.1 device controller. The controller in the IMX series
330 is register-compatible.
331
332 It has Six fixed-function endpoints, as well as endpoint
333 zero (for control transfers).
334
335 Say "y" to link the driver statically, or "m" to build a
336 dynamically linked module called "imx_udc" and force all
337 gadget drivers to also be dynamically linked.
338
339config USB_IMX
340 tristate
341 depends on USB_GADGET_IMX
342 default USB_GADGET
343 select USB_GADGET_SELECTED
344
345config USB_GADGET_M66592 345config USB_GADGET_M66592
346 boolean "Renesas M66592 USB Peripheral Controller" 346 boolean "Renesas M66592 USB Peripheral Controller"
347 select USB_GADGET_DUALSPEED 347 select USB_GADGET_DUALSPEED
@@ -604,6 +604,7 @@ config USB_ZERO_HNPTEST
604config USB_AUDIO 604config USB_AUDIO
605 tristate "Audio Gadget (EXPERIMENTAL)" 605 tristate "Audio Gadget (EXPERIMENTAL)"
606 depends on SND 606 depends on SND
607 select SND_PCM
607 help 608 help
608 Gadget Audio is compatible with USB Audio Class specification 1.0. 609 Gadget Audio is compatible with USB Audio Class specification 1.0.
609 It will include at least one AudioControl interface, zero or more 610 It will include at least one AudioControl interface, zero or more
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 826f3adde5d8..77352ccc245e 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -48,7 +48,6 @@
48#include <linux/ioport.h> 48#include <linux/ioport.h>
49#include <linux/sched.h> 49#include <linux/sched.h>
50#include <linux/slab.h> 50#include <linux/slab.h>
51#include <linux/smp_lock.h>
52#include <linux/errno.h> 51#include <linux/errno.h>
53#include <linux/init.h> 52#include <linux/init.h>
54#include <linux/timer.h> 53#include <linux/timer.h>
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 94de7e864614..9f80f4e970bd 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -42,9 +42,9 @@
42 * Instead: allocate your own, using normal USB-IF procedures. 42 * Instead: allocate your own, using normal USB-IF procedures.
43 */ 43 */
44 44
45/* Thanks to NetChip Technologies for donating this product ID. */ 45/* Thanks to Linux Foundation for donating this product ID. */
46#define AUDIO_VENDOR_NUM 0x0525 /* NetChip */ 46#define AUDIO_VENDOR_NUM 0x1d6b /* Linux Foundation */
47#define AUDIO_PRODUCT_NUM 0xa4a1 /* Linux-USB Audio Gadget */ 47#define AUDIO_PRODUCT_NUM 0x0101 /* Linux-USB Audio Gadget */
48 48
49/*-------------------------------------------------------------------------*/ 49/*-------------------------------------------------------------------------*/
50 50
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index d006dc652e02..bd102f5052ba 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -293,15 +293,16 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
293 /* CDC Subset */ 293 /* CDC Subset */
294 eth_config_driver.label = "CDC Subset/SAFE"; 294 eth_config_driver.label = "CDC Subset/SAFE";
295 295
296 device_desc.idVendor = cpu_to_le16(SIMPLE_VENDOR_NUM), 296 device_desc.idVendor = cpu_to_le16(SIMPLE_VENDOR_NUM);
297 device_desc.idProduct = cpu_to_le16(SIMPLE_PRODUCT_NUM), 297 device_desc.idProduct = cpu_to_le16(SIMPLE_PRODUCT_NUM);
298 device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC; 298 if (!has_rndis())
299 device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC;
299 } 300 }
300 301
301 if (has_rndis()) { 302 if (has_rndis()) {
302 /* RNDIS plus ECM-or-Subset */ 303 /* RNDIS plus ECM-or-Subset */
303 device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM), 304 device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM);
304 device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM), 305 device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM);
305 device_desc.bNumConfigurations = 2; 306 device_desc.bNumConfigurations = 2;
306 } 307 }
307 308
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c
index 6829d5961359..a3913519fd58 100644
--- a/drivers/usb/gadget/langwell_udc.c
+++ b/drivers/usb/gadget/langwell_udc.c
@@ -34,7 +34,6 @@
34#include <linux/ioport.h> 34#include <linux/ioport.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/smp_lock.h>
38#include <linux/errno.h> 37#include <linux/errno.h>
39#include <linux/init.h> 38#include <linux/init.h>
40#include <linux/timer.h> 39#include <linux/timer.h>
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 0ce4e2819847..ed21e263f832 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -139,7 +139,7 @@ static int is_vbus_present(void)
139{ 139{
140 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 140 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
141 141
142 if (mach->gpio_vbus) { 142 if (gpio_is_valid(mach->gpio_vbus)) {
143 int value = gpio_get_value(mach->gpio_vbus); 143 int value = gpio_get_value(mach->gpio_vbus);
144 144
145 if (mach->gpio_vbus_inverted) 145 if (mach->gpio_vbus_inverted)
@@ -158,7 +158,7 @@ static void pullup_off(void)
158 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 158 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
159 int off_level = mach->gpio_pullup_inverted; 159 int off_level = mach->gpio_pullup_inverted;
160 160
161 if (mach->gpio_pullup) 161 if (gpio_is_valid(mach->gpio_pullup))
162 gpio_set_value(mach->gpio_pullup, off_level); 162 gpio_set_value(mach->gpio_pullup, off_level);
163 else if (mach->udc_command) 163 else if (mach->udc_command)
164 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); 164 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
@@ -169,7 +169,7 @@ static void pullup_on(void)
169 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 169 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
170 int on_level = !mach->gpio_pullup_inverted; 170 int on_level = !mach->gpio_pullup_inverted;
171 171
172 if (mach->gpio_pullup) 172 if (gpio_is_valid(mach->gpio_pullup))
173 gpio_set_value(mach->gpio_pullup, on_level); 173 gpio_set_value(mach->gpio_pullup, on_level);
174 else if (mach->udc_command) 174 else if (mach->udc_command)
175 mach->udc_command(PXA2XX_UDC_CMD_CONNECT); 175 mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
@@ -1000,7 +1000,7 @@ static int pxa25x_udc_pullup(struct usb_gadget *_gadget, int is_active)
1000 udc = container_of(_gadget, struct pxa25x_udc, gadget); 1000 udc = container_of(_gadget, struct pxa25x_udc, gadget);
1001 1001
1002 /* not all boards support pullup control */ 1002 /* not all boards support pullup control */
1003 if (!udc->mach->gpio_pullup && !udc->mach->udc_command) 1003 if (!gpio_is_valid(udc->mach->gpio_pullup) && !udc->mach->udc_command)
1004 return -EOPNOTSUPP; 1004 return -EOPNOTSUPP;
1005 1005
1006 udc->pullup = (is_active != 0); 1006 udc->pullup = (is_active != 0);
@@ -1802,11 +1802,13 @@ pxa25x_udc_irq(int irq, void *_dev)
1802 USIR0 |= tmp; 1802 USIR0 |= tmp;
1803 handled = 1; 1803 handled = 1;
1804 } 1804 }
1805#ifndef CONFIG_USB_PXA25X_SMALL
1805 if (usir1 & tmp) { 1806 if (usir1 & tmp) {
1806 handle_ep(&dev->ep[i+8]); 1807 handle_ep(&dev->ep[i+8]);
1807 USIR1 |= tmp; 1808 USIR1 |= tmp;
1808 handled = 1; 1809 handled = 1;
1809 } 1810 }
1811#endif
1810 } 1812 }
1811 } 1813 }
1812 1814
@@ -2160,7 +2162,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
2160 dev->dev = &pdev->dev; 2162 dev->dev = &pdev->dev;
2161 dev->mach = pdev->dev.platform_data; 2163 dev->mach = pdev->dev.platform_data;
2162 2164
2163 if (dev->mach->gpio_vbus) { 2165 if (gpio_is_valid(dev->mach->gpio_vbus)) {
2164 if ((retval = gpio_request(dev->mach->gpio_vbus, 2166 if ((retval = gpio_request(dev->mach->gpio_vbus,
2165 "pxa25x_udc GPIO VBUS"))) { 2167 "pxa25x_udc GPIO VBUS"))) {
2166 dev_dbg(&pdev->dev, 2168 dev_dbg(&pdev->dev,
@@ -2173,7 +2175,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
2173 } else 2175 } else
2174 vbus_irq = 0; 2176 vbus_irq = 0;
2175 2177
2176 if (dev->mach->gpio_pullup) { 2178 if (gpio_is_valid(dev->mach->gpio_pullup)) {
2177 if ((retval = gpio_request(dev->mach->gpio_pullup, 2179 if ((retval = gpio_request(dev->mach->gpio_pullup,
2178 "pca25x_udc GPIO PULLUP"))) { 2180 "pca25x_udc GPIO PULLUP"))) {
2179 dev_dbg(&pdev->dev, 2181 dev_dbg(&pdev->dev,
@@ -2256,10 +2258,10 @@ lubbock_fail0:
2256#endif 2258#endif
2257 free_irq(irq, dev); 2259 free_irq(irq, dev);
2258 err_irq1: 2260 err_irq1:
2259 if (dev->mach->gpio_pullup) 2261 if (gpio_is_valid(dev->mach->gpio_pullup))
2260 gpio_free(dev->mach->gpio_pullup); 2262 gpio_free(dev->mach->gpio_pullup);
2261 err_gpio_pullup: 2263 err_gpio_pullup:
2262 if (dev->mach->gpio_vbus) 2264 if (gpio_is_valid(dev->mach->gpio_vbus))
2263 gpio_free(dev->mach->gpio_vbus); 2265 gpio_free(dev->mach->gpio_vbus);
2264 err_gpio_vbus: 2266 err_gpio_vbus:
2265 clk_put(dev->clk); 2267 clk_put(dev->clk);
@@ -2294,11 +2296,11 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev)
2294 free_irq(LUBBOCK_USB_IRQ, dev); 2296 free_irq(LUBBOCK_USB_IRQ, dev);
2295 } 2297 }
2296#endif 2298#endif
2297 if (dev->mach->gpio_vbus) { 2299 if (gpio_is_valid(dev->mach->gpio_vbus)) {
2298 free_irq(gpio_to_irq(dev->mach->gpio_vbus), dev); 2300 free_irq(gpio_to_irq(dev->mach->gpio_vbus), dev);
2299 gpio_free(dev->mach->gpio_vbus); 2301 gpio_free(dev->mach->gpio_vbus);
2300 } 2302 }
2301 if (dev->mach->gpio_pullup) 2303 if (gpio_is_valid(dev->mach->gpio_pullup))
2302 gpio_free(dev->mach->gpio_pullup); 2304 gpio_free(dev->mach->gpio_pullup);
2303 2305
2304 clk_put(dev->clk); 2306 clk_put(dev->clk);
@@ -2329,7 +2331,7 @@ static int pxa25x_udc_suspend(struct platform_device *dev, pm_message_t state)
2329 struct pxa25x_udc *udc = platform_get_drvdata(dev); 2331 struct pxa25x_udc *udc = platform_get_drvdata(dev);
2330 unsigned long flags; 2332 unsigned long flags;
2331 2333
2332 if (!udc->mach->gpio_pullup && !udc->mach->udc_command) 2334 if (!gpio_is_valid(udc->mach->gpio_pullup) && !udc->mach->udc_command)
2333 WARNING("USB host won't detect disconnect!\n"); 2335 WARNING("USB host won't detect disconnect!\n");
2334 udc->suspended = 1; 2336 udc->suspended = 1;
2335 2337
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 2b4660e08c4d..ca41b0b5afb3 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -442,6 +442,8 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
442 442
443 case OID_802_3_MAC_OPTIONS: 443 case OID_802_3_MAC_OPTIONS:
444 pr_debug("%s: OID_802_3_MAC_OPTIONS\n", __func__); 444 pr_debug("%s: OID_802_3_MAC_OPTIONS\n", __func__);
445 *outbuf = cpu_to_le32(0);
446 retval = 0;
445 break; 447 break;
446 448
447 /* ieee802.3 statistics OIDs (table 4-4) */ 449 /* ieee802.3 statistics OIDs (table 4-4) */
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index 9a2b8920532d..a9b452fe6221 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -28,7 +28,6 @@
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/smp_lock.h>
32#include <linux/errno.h> 31#include <linux/errno.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/timer.h> 33#include <linux/timer.h>
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 1576a0520adf..1a920c70b5a1 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -181,26 +181,27 @@ config USB_OHCI_HCD_PPC_SOC
181 Enables support for the USB controller on the MPC52xx or 181 Enables support for the USB controller on the MPC52xx or
182 STB03xxx processor chip. If unsure, say Y. 182 STB03xxx processor chip. If unsure, say Y.
183 183
184config USB_OHCI_HCD_PPC_OF
185 bool "OHCI support for PPC USB controller on OF platform bus"
186 depends on USB_OHCI_HCD && PPC_OF
187 default y
188 ---help---
189 Enables support for the USB controller PowerPC present on the
190 OpenFirmware platform bus.
191
192config USB_OHCI_HCD_PPC_OF_BE 184config USB_OHCI_HCD_PPC_OF_BE
193 bool "Support big endian HC" 185 bool "OHCI support for OF platform bus (big endian)"
194 depends on USB_OHCI_HCD_PPC_OF 186 depends on USB_OHCI_HCD && PPC_OF
195 default y
196 select USB_OHCI_BIG_ENDIAN_DESC 187 select USB_OHCI_BIG_ENDIAN_DESC
197 select USB_OHCI_BIG_ENDIAN_MMIO 188 select USB_OHCI_BIG_ENDIAN_MMIO
189 ---help---
190 Enables support for big-endian USB controllers present on the
191 OpenFirmware platform bus.
198 192
199config USB_OHCI_HCD_PPC_OF_LE 193config USB_OHCI_HCD_PPC_OF_LE
200 bool "Support little endian HC" 194 bool "OHCI support for OF platform bus (little endian)"
201 depends on USB_OHCI_HCD_PPC_OF 195 depends on USB_OHCI_HCD && PPC_OF
202 default n
203 select USB_OHCI_LITTLE_ENDIAN 196 select USB_OHCI_LITTLE_ENDIAN
197 ---help---
198 Enables support for little-endian USB controllers present on the
199 OpenFirmware platform bus.
200
201config USB_OHCI_HCD_PPC_OF
202 bool
203 depends on USB_OHCI_HCD && PPC_OF
204 default USB_OHCI_HCD_PPC_OF_BE || USB_OHCI_HCD_PPC_OF_LE
204 205
205config USB_OHCI_HCD_PCI 206config USB_OHCI_HCD_PCI
206 bool "OHCI support for PCI-bus USB controllers" 207 bool "OHCI support for PCI-bus USB controllers"
@@ -337,10 +338,10 @@ config USB_R8A66597_HCD
337 338
338config SUPERH_ON_CHIP_R8A66597 339config SUPERH_ON_CHIP_R8A66597
339 boolean "Enable SuperH on-chip R8A66597 USB" 340 boolean "Enable SuperH on-chip R8A66597 USB"
340 depends on USB_R8A66597_HCD && (CPU_SUBTYPE_SH7366 || CPU_SUBTYPE_SH7723) 341 depends on USB_R8A66597_HCD && (CPU_SUBTYPE_SH7366 || CPU_SUBTYPE_SH7723 || CPU_SUBTYPE_SH7724)
341 help 342 help
342 This driver enables support for the on-chip R8A66597 in the 343 This driver enables support for the on-chip R8A66597 in the
343 SH7366 and SH7723 processors. 344 SH7366, SH7723 and SH7724 processors.
344 345
345config USB_WHCI_HCD 346config USB_WHCI_HCD
346 tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)" 347 tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)"
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index c3a778bd359c..59d208d94d4e 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -113,6 +113,8 @@ static const struct hc_driver ehci_au1xxx_hc_driver = {
113 .bus_resume = ehci_bus_resume, 113 .bus_resume = ehci_bus_resume,
114 .relinquish_port = ehci_relinquish_port, 114 .relinquish_port = ehci_relinquish_port,
115 .port_handed_over = ehci_port_handed_over, 115 .port_handed_over = ehci_port_handed_over,
116
117 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
116}; 118};
117 119
118static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev) 120static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index bf86809c5120..991174937db3 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -325,6 +325,8 @@ static const struct hc_driver ehci_fsl_hc_driver = {
325 .bus_resume = ehci_bus_resume, 325 .bus_resume = ehci_bus_resume,
326 .relinquish_port = ehci_relinquish_port, 326 .relinquish_port = ehci_relinquish_port,
327 .port_handed_over = ehci_port_handed_over, 327 .port_handed_over = ehci_port_handed_over,
328
329 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
328}; 330};
329 331
330static int ehci_fsl_drv_probe(struct platform_device *pdev) 332static int ehci_fsl_drv_probe(struct platform_device *pdev)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2b72473544d3..7d03549c3339 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1003,6 +1003,8 @@ idle_timeout:
1003 schedule_timeout_uninterruptible(1); 1003 schedule_timeout_uninterruptible(1);
1004 goto rescan; 1004 goto rescan;
1005 case QH_STATE_IDLE: /* fully unlinked */ 1005 case QH_STATE_IDLE: /* fully unlinked */
1006 if (qh->clearing_tt)
1007 goto idle_timeout;
1006 if (list_empty (&qh->qtd_list)) { 1008 if (list_empty (&qh->qtd_list)) {
1007 qh_put (qh); 1009 qh_put (qh);
1008 break; 1010 break;
@@ -1030,12 +1032,14 @@ ehci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
1030 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1032 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1031 struct ehci_qh *qh; 1033 struct ehci_qh *qh;
1032 int eptype = usb_endpoint_type(&ep->desc); 1034 int eptype = usb_endpoint_type(&ep->desc);
1035 int epnum = usb_endpoint_num(&ep->desc);
1036 int is_out = usb_endpoint_dir_out(&ep->desc);
1037 unsigned long flags;
1033 1038
1034 if (eptype != USB_ENDPOINT_XFER_BULK && eptype != USB_ENDPOINT_XFER_INT) 1039 if (eptype != USB_ENDPOINT_XFER_BULK && eptype != USB_ENDPOINT_XFER_INT)
1035 return; 1040 return;
1036 1041
1037 rescan: 1042 spin_lock_irqsave(&ehci->lock, flags);
1038 spin_lock_irq(&ehci->lock);
1039 qh = ep->hcpriv; 1043 qh = ep->hcpriv;
1040 1044
1041 /* For Bulk and Interrupt endpoints we maintain the toggle state 1045 /* For Bulk and Interrupt endpoints we maintain the toggle state
@@ -1044,29 +1048,24 @@ ehci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
1044 * the toggle bit in the QH. 1048 * the toggle bit in the QH.
1045 */ 1049 */
1046 if (qh) { 1050 if (qh) {
1051 usb_settoggle(qh->dev, epnum, is_out, 0);
1047 if (!list_empty(&qh->qtd_list)) { 1052 if (!list_empty(&qh->qtd_list)) {
1048 WARN_ONCE(1, "clear_halt for a busy endpoint\n"); 1053 WARN_ONCE(1, "clear_halt for a busy endpoint\n");
1049 } else if (qh->qh_state == QH_STATE_IDLE) { 1054 } else if (qh->qh_state == QH_STATE_LINKED) {
1050 qh->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE); 1055
1051 } else { 1056 /* The toggle value in the QH can't be updated
1052 /* It's not safe to write into the overlay area 1057 * while the QH is active. Unlink it now;
1053 * while the QH is active. Unlink it first and 1058 * re-linking will call qh_refresh().
1054 * wait for the unlink to complete.
1055 */ 1059 */
1056 if (qh->qh_state == QH_STATE_LINKED) { 1060 if (eptype == USB_ENDPOINT_XFER_BULK) {
1057 if (eptype == USB_ENDPOINT_XFER_BULK) { 1061 unlink_async(ehci, qh);
1058 unlink_async(ehci, qh); 1062 } else {
1059 } else { 1063 intr_deschedule(ehci, qh);
1060 intr_deschedule(ehci, qh); 1064 (void) qh_schedule(ehci, qh);
1061 (void) qh_schedule(ehci, qh);
1062 }
1063 } 1065 }
1064 spin_unlock_irq(&ehci->lock);
1065 schedule_timeout_uninterruptible(1);
1066 goto rescan;
1067 } 1066 }
1068 } 1067 }
1069 spin_unlock_irq(&ehci->lock); 1068 spin_unlock_irqrestore(&ehci->lock, flags);
1070} 1069}
1071 1070
1072static int ehci_get_frame (struct usb_hcd *hcd) 1071static int ehci_get_frame (struct usb_hcd *hcd)
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index a44bb4a94954..89b7c70c6ed6 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -61,6 +61,8 @@ static const struct hc_driver ixp4xx_ehci_hc_driver = {
61#endif 61#endif
62 .relinquish_port = ehci_relinquish_port, 62 .relinquish_port = ehci_relinquish_port,
63 .port_handed_over = ehci_port_handed_over, 63 .port_handed_over = ehci_port_handed_over,
64
65 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
64}; 66};
65 67
66static int ixp4xx_ehci_probe(struct platform_device *pdev) 68static int ixp4xx_ehci_probe(struct platform_device *pdev)
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 770dd9aba62a..dc2ac613a9d1 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -165,6 +165,8 @@ static const struct hc_driver ehci_orion_hc_driver = {
165 .bus_resume = ehci_bus_resume, 165 .bus_resume = ehci_bus_resume,
166 .relinquish_port = ehci_relinquish_port, 166 .relinquish_port = ehci_relinquish_port,
167 .port_handed_over = ehci_port_handed_over, 167 .port_handed_over = ehci_port_handed_over,
168
169 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
168}; 170};
169 171
170static void __init 172static void __init
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index f3683e1da161..c2f1b7df918c 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -404,6 +404,8 @@ static const struct hc_driver ehci_pci_hc_driver = {
404 .bus_resume = ehci_bus_resume, 404 .bus_resume = ehci_bus_resume,
405 .relinquish_port = ehci_relinquish_port, 405 .relinquish_port = ehci_relinquish_port,
406 .port_handed_over = ehci_port_handed_over, 406 .port_handed_over = ehci_port_handed_over,
407
408 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
407}; 409};
408 410
409/*-------------------------------------------------------------------------*/ 411/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index fbd272288fc2..36f96da129f5 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -79,6 +79,8 @@ static const struct hc_driver ehci_ppc_of_hc_driver = {
79#endif 79#endif
80 .relinquish_port = ehci_relinquish_port, 80 .relinquish_port = ehci_relinquish_port,
81 .port_handed_over = ehci_port_handed_over, 81 .port_handed_over = ehci_port_handed_over,
82
83 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
82}; 84};
83 85
84 86
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c
index 93f7035d00a1..1dee33b9139e 100644
--- a/drivers/usb/host/ehci-ps3.c
+++ b/drivers/usb/host/ehci-ps3.c
@@ -75,6 +75,8 @@ static const struct hc_driver ps3_ehci_hc_driver = {
75#endif 75#endif
76 .relinquish_port = ehci_relinquish_port, 76 .relinquish_port = ehci_relinquish_port,
77 .port_handed_over = ehci_port_handed_over, 77 .port_handed_over = ehci_port_handed_over,
78
79 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
78}; 80};
79 81
80static int __devinit ps3_ehci_probe(struct ps3_system_bus_device *dev) 82static int __devinit ps3_ehci_probe(struct ps3_system_bus_device *dev)
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 3192f683f807..9a1384747f3b 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -93,6 +93,22 @@ qh_update (struct ehci_hcd *ehci, struct ehci_qh *qh, struct ehci_qtd *qtd)
93 qh->hw_qtd_next = QTD_NEXT(ehci, qtd->qtd_dma); 93 qh->hw_qtd_next = QTD_NEXT(ehci, qtd->qtd_dma);
94 qh->hw_alt_next = EHCI_LIST_END(ehci); 94 qh->hw_alt_next = EHCI_LIST_END(ehci);
95 95
96 /* Except for control endpoints, we make hardware maintain data
97 * toggle (like OHCI) ... here (re)initialize the toggle in the QH,
98 * and set the pseudo-toggle in udev. Only usb_clear_halt() will
99 * ever clear it.
100 */
101 if (!(qh->hw_info1 & cpu_to_hc32(ehci, 1 << 14))) {
102 unsigned is_out, epnum;
103
104 is_out = !(qtd->hw_token & cpu_to_hc32(ehci, 1 << 8));
105 epnum = (hc32_to_cpup(ehci, &qh->hw_info1) >> 8) & 0x0f;
106 if (unlikely (!usb_gettoggle (qh->dev, epnum, is_out))) {
107 qh->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE);
108 usb_settoggle (qh->dev, epnum, is_out, 1);
109 }
110 }
111
96 /* HC must see latest qtd and qh data before we clear ACTIVE+HALT */ 112 /* HC must see latest qtd and qh data before we clear ACTIVE+HALT */
97 wmb (); 113 wmb ();
98 qh->hw_token &= cpu_to_hc32(ehci, QTD_TOGGLE | QTD_STS_PING); 114 qh->hw_token &= cpu_to_hc32(ehci, QTD_TOGGLE | QTD_STS_PING);
@@ -123,6 +139,55 @@ qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
123 139
124/*-------------------------------------------------------------------------*/ 140/*-------------------------------------------------------------------------*/
125 141
142static void qh_link_async(struct ehci_hcd *ehci, struct ehci_qh *qh);
143
144static void ehci_clear_tt_buffer_complete(struct usb_hcd *hcd,
145 struct usb_host_endpoint *ep)
146{
147 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
148 struct ehci_qh *qh = ep->hcpriv;
149 unsigned long flags;
150
151 spin_lock_irqsave(&ehci->lock, flags);
152 qh->clearing_tt = 0;
153 if (qh->qh_state == QH_STATE_IDLE && !list_empty(&qh->qtd_list)
154 && HC_IS_RUNNING(hcd->state))
155 qh_link_async(ehci, qh);
156 spin_unlock_irqrestore(&ehci->lock, flags);
157}
158
159static void ehci_clear_tt_buffer(struct ehci_hcd *ehci, struct ehci_qh *qh,
160 struct urb *urb, u32 token)
161{
162
163 /* If an async split transaction gets an error or is unlinked,
164 * the TT buffer may be left in an indeterminate state. We
165 * have to clear the TT buffer.
166 *
167 * Note: this routine is never called for Isochronous transfers.
168 */
169 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
170#ifdef DEBUG
171 struct usb_device *tt = urb->dev->tt->hub;
172 dev_dbg(&tt->dev,
173 "clear tt buffer port %d, a%d ep%d t%08x\n",
174 urb->dev->ttport, urb->dev->devnum,
175 usb_pipeendpoint(urb->pipe), token);
176#endif /* DEBUG */
177 if (!ehci_is_TDI(ehci)
178 || urb->dev->tt->hub !=
179 ehci_to_hcd(ehci)->self.root_hub) {
180 if (usb_hub_clear_tt_buffer(urb) == 0)
181 qh->clearing_tt = 1;
182 } else {
183
184 /* REVISIT ARC-derived cores don't clear the root
185 * hub TT buffer in this way...
186 */
187 }
188 }
189}
190
126static int qtd_copy_status ( 191static int qtd_copy_status (
127 struct ehci_hcd *ehci, 192 struct ehci_hcd *ehci,
128 struct urb *urb, 193 struct urb *urb,
@@ -149,6 +214,14 @@ static int qtd_copy_status (
149 if (token & QTD_STS_BABBLE) { 214 if (token & QTD_STS_BABBLE) {
150 /* FIXME "must" disable babbling device's port too */ 215 /* FIXME "must" disable babbling device's port too */
151 status = -EOVERFLOW; 216 status = -EOVERFLOW;
217 /* CERR nonzero + halt --> stall */
218 } else if (QTD_CERR(token)) {
219 status = -EPIPE;
220
221 /* In theory, more than one of the following bits can be set
222 * since they are sticky and the transaction is retried.
223 * Which to test first is rather arbitrary.
224 */
152 } else if (token & QTD_STS_MMF) { 225 } else if (token & QTD_STS_MMF) {
153 /* fs/ls interrupt xfer missed the complete-split */ 226 /* fs/ls interrupt xfer missed the complete-split */
154 status = -EPROTO; 227 status = -EPROTO;
@@ -157,21 +230,15 @@ static int qtd_copy_status (
157 ? -ENOSR /* hc couldn't read data */ 230 ? -ENOSR /* hc couldn't read data */
158 : -ECOMM; /* hc couldn't write data */ 231 : -ECOMM; /* hc couldn't write data */
159 } else if (token & QTD_STS_XACT) { 232 } else if (token & QTD_STS_XACT) {
160 /* timeout, bad crc, wrong PID, etc; retried */ 233 /* timeout, bad CRC, wrong PID, etc */
161 if (QTD_CERR (token)) 234 ehci_dbg(ehci, "devpath %s ep%d%s 3strikes\n",
162 status = -EPIPE; 235 urb->dev->devpath,
163 else { 236 usb_pipeendpoint(urb->pipe),
164 ehci_dbg (ehci, "devpath %s ep%d%s 3strikes\n", 237 usb_pipein(urb->pipe) ? "in" : "out");
165 urb->dev->devpath, 238 status = -EPROTO;
166 usb_pipeendpoint (urb->pipe), 239 } else { /* unknown */
167 usb_pipein (urb->pipe) ? "in" : "out");
168 status = -EPROTO;
169 }
170 /* CERR nonzero + no errors + halt --> stall */
171 } else if (QTD_CERR (token))
172 status = -EPIPE;
173 else /* unknown */
174 status = -EPROTO; 240 status = -EPROTO;
241 }
175 242
176 ehci_vdbg (ehci, 243 ehci_vdbg (ehci,
177 "dev%d ep%d%s qtd token %08x --> status %d\n", 244 "dev%d ep%d%s qtd token %08x --> status %d\n",
@@ -179,28 +246,6 @@ static int qtd_copy_status (
179 usb_pipeendpoint (urb->pipe), 246 usb_pipeendpoint (urb->pipe),
180 usb_pipein (urb->pipe) ? "in" : "out", 247 usb_pipein (urb->pipe) ? "in" : "out",
181 token, status); 248 token, status);
182
183 /* if async CSPLIT failed, try cleaning out the TT buffer */
184 if (status != -EPIPE
185 && urb->dev->tt
186 && !usb_pipeint(urb->pipe)
187 && ((token & QTD_STS_MMF) != 0
188 || QTD_CERR(token) == 0)
189 && (!ehci_is_TDI(ehci)
190 || urb->dev->tt->hub !=
191 ehci_to_hcd(ehci)->self.root_hub)) {
192#ifdef DEBUG
193 struct usb_device *tt = urb->dev->tt->hub;
194 dev_dbg (&tt->dev,
195 "clear tt buffer port %d, a%d ep%d t%08x\n",
196 urb->dev->ttport, urb->dev->devnum,
197 usb_pipeendpoint (urb->pipe), token);
198#endif /* DEBUG */
199 /* REVISIT ARC-derived cores don't clear the root
200 * hub TT buffer in this way...
201 */
202 usb_hub_tt_clear_buffer (urb->dev, urb->pipe);
203 }
204 } 249 }
205 250
206 return status; 251 return status;
@@ -391,9 +436,16 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
391 /* qh unlinked; token in overlay may be most current */ 436 /* qh unlinked; token in overlay may be most current */
392 if (state == QH_STATE_IDLE 437 if (state == QH_STATE_IDLE
393 && cpu_to_hc32(ehci, qtd->qtd_dma) 438 && cpu_to_hc32(ehci, qtd->qtd_dma)
394 == qh->hw_current) 439 == qh->hw_current) {
395 token = hc32_to_cpu(ehci, qh->hw_token); 440 token = hc32_to_cpu(ehci, qh->hw_token);
396 441
442 /* An unlink may leave an incomplete
443 * async transaction in the TT buffer.
444 * We have to clear it.
445 */
446 ehci_clear_tt_buffer(ehci, qh, urb, token);
447 }
448
397 /* force halt for unlinked or blocked qh, so we'll 449 /* force halt for unlinked or blocked qh, so we'll
398 * patch the qh later and so that completions can't 450 * patch the qh later and so that completions can't
399 * activate it while we "know" it's stopped. 451 * activate it while we "know" it's stopped.
@@ -419,6 +471,13 @@ halt:
419 && (qtd->hw_alt_next 471 && (qtd->hw_alt_next
420 & EHCI_LIST_END(ehci))) 472 & EHCI_LIST_END(ehci)))
421 last_status = -EINPROGRESS; 473 last_status = -EINPROGRESS;
474
475 /* As part of low/full-speed endpoint-halt processing
476 * we must clear the TT buffer (11.17.5).
477 */
478 if (unlikely(last_status != -EINPROGRESS &&
479 last_status != -EREMOTEIO))
480 ehci_clear_tt_buffer(ehci, qh, urb, token);
422 } 481 }
423 482
424 /* if we're removing something not at the queue head, 483 /* if we're removing something not at the queue head,
@@ -834,6 +893,7 @@ done:
834 qh->qh_state = QH_STATE_IDLE; 893 qh->qh_state = QH_STATE_IDLE;
835 qh->hw_info1 = cpu_to_hc32(ehci, info1); 894 qh->hw_info1 = cpu_to_hc32(ehci, info1);
836 qh->hw_info2 = cpu_to_hc32(ehci, info2); 895 qh->hw_info2 = cpu_to_hc32(ehci, info2);
896 usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1);
837 qh_refresh (ehci, qh); 897 qh_refresh (ehci, qh);
838 return qh; 898 return qh;
839} 899}
@@ -847,6 +907,10 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
847 __hc32 dma = QH_NEXT(ehci, qh->qh_dma); 907 __hc32 dma = QH_NEXT(ehci, qh->qh_dma);
848 struct ehci_qh *head; 908 struct ehci_qh *head;
849 909
910 /* Don't link a QH if there's a Clear-TT-Buffer pending */
911 if (unlikely(qh->clearing_tt))
912 return;
913
850 /* (re)start the async schedule? */ 914 /* (re)start the async schedule? */
851 head = ehci->async; 915 head = ehci->async;
852 timer_action_done (ehci, TIMER_ASYNC_OFF); 916 timer_action_done (ehci, TIMER_ASYNC_OFF);
@@ -864,7 +928,7 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
864 } 928 }
865 } 929 }
866 930
867 /* clear halt and maybe recover from silicon quirk */ 931 /* clear halt and/or toggle; and maybe recover from silicon quirk */
868 if (qh->qh_state == QH_STATE_IDLE) 932 if (qh->qh_state == QH_STATE_IDLE)
869 qh_refresh (ehci, qh); 933 qh_refresh (ehci, qh);
870 934
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 9d1babc7ff65..74f7f83b29ad 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1619,11 +1619,14 @@ itd_complete (
1619 desc->status = -EPROTO; 1619 desc->status = -EPROTO;
1620 1620
1621 /* HC need not update length with this error */ 1621 /* HC need not update length with this error */
1622 if (!(t & EHCI_ISOC_BABBLE)) 1622 if (!(t & EHCI_ISOC_BABBLE)) {
1623 desc->actual_length = EHCI_ITD_LENGTH (t); 1623 desc->actual_length = EHCI_ITD_LENGTH(t);
1624 urb->actual_length += desc->actual_length;
1625 }
1624 } else if (likely ((t & EHCI_ISOC_ACTIVE) == 0)) { 1626 } else if (likely ((t & EHCI_ISOC_ACTIVE) == 0)) {
1625 desc->status = 0; 1627 desc->status = 0;
1626 desc->actual_length = EHCI_ITD_LENGTH (t); 1628 desc->actual_length = EHCI_ITD_LENGTH(t);
1629 urb->actual_length += desc->actual_length;
1627 } else { 1630 } else {
1628 /* URB was too late */ 1631 /* URB was too late */
1629 desc->status = -EXDEV; 1632 desc->status = -EXDEV;
@@ -2014,7 +2017,8 @@ sitd_complete (
2014 desc->status = -EPROTO; 2017 desc->status = -EPROTO;
2015 } else { 2018 } else {
2016 desc->status = 0; 2019 desc->status = 0;
2017 desc->actual_length = desc->length - SITD_LENGTH (t); 2020 desc->actual_length = desc->length - SITD_LENGTH(t);
2021 urb->actual_length += desc->actual_length;
2018 } 2022 }
2019 stream->depth -= stream->interval << 3; 2023 stream->depth -= stream->interval << 3;
2020 2024
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 90ad3395bb21..2bfff30f4704 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -354,7 +354,9 @@ struct ehci_qh {
354 unsigned short period; /* polling interval */ 354 unsigned short period; /* polling interval */
355 unsigned short start; /* where polling starts */ 355 unsigned short start; /* where polling starts */
356#define NO_FRAME ((unsigned short)~0) /* pick new start */ 356#define NO_FRAME ((unsigned short)~0) /* pick new start */
357
357 struct usb_device *dev; /* access to TT */ 358 struct usb_device *dev; /* access to TT */
359 unsigned clearing_tt:1; /* Clear-TT-Buf in progress */
358} __attribute__ ((aligned (32))); 360} __attribute__ ((aligned (32)));
359 361
360/*-------------------------------------------------------------------------*/ 362/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
index bb63b68ddb77..62a226b61670 100644
--- a/drivers/usb/host/fhci-sched.c
+++ b/drivers/usb/host/fhci-sched.c
@@ -576,9 +576,7 @@ irqreturn_t fhci_irq(struct usb_hcd *hcd)
576 out_be16(&usb->fhci->regs->usb_event, 576 out_be16(&usb->fhci->regs->usb_event,
577 usb->saved_msk); 577 usb->saved_msk);
578 } else if (usb->port_status == FHCI_PORT_DISABLED) { 578 } else if (usb->port_status == FHCI_PORT_DISABLED) {
579 if (fhci_ioports_check_bus_state(fhci) == 1 && 579 if (fhci_ioports_check_bus_state(fhci) == 1)
580 usb->port_status != FHCI_PORT_LOW &&
581 usb->port_status != FHCI_PORT_FULL)
582 fhci_device_connected_interrupt(fhci); 580 fhci_device_connected_interrupt(fhci);
583 } 581 }
584 usb_er &= ~USB_E_RESET_MASK; 582 usb_er &= ~USB_E_RESET_MASK;
@@ -605,9 +603,7 @@ irqreturn_t fhci_irq(struct usb_hcd *hcd)
605 } 603 }
606 604
607 if (usb_er & USB_E_IDLE_MASK) { 605 if (usb_er & USB_E_IDLE_MASK) {
608 if (usb->port_status == FHCI_PORT_DISABLED && 606 if (usb->port_status == FHCI_PORT_DISABLED) {
609 usb->port_status != FHCI_PORT_LOW &&
610 usb->port_status != FHCI_PORT_FULL) {
611 usb_er &= ~USB_E_RESET_MASK; 607 usb_er &= ~USB_E_RESET_MASK;
612 fhci_device_connected_interrupt(fhci); 608 fhci_device_connected_interrupt(fhci);
613 } else if (usb->port_status == 609 } else if (usb->port_status ==
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 3fa3a1702796..d4feebfc63bd 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -361,7 +361,7 @@ static int __devexit isp1760_plat_remove(struct platform_device *pdev)
361 361
362static struct platform_driver isp1760_plat_driver = { 362static struct platform_driver isp1760_plat_driver = {
363 .probe = isp1760_plat_probe, 363 .probe = isp1760_plat_probe,
364 .remove = isp1760_plat_remove, 364 .remove = __devexit_p(isp1760_plat_remove),
365 .driver = { 365 .driver = {
366 .name = "isp1760", 366 .name = "isp1760",
367 }, 367 },
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 56976cc0352a..e18f74946e68 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -26,7 +26,6 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/smp_lock.h>
30#include <linux/errno.h> 29#include <linux/errno.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/timer.h> 31#include <linux/timer.h>
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 3c5fe5cee05a..90e1a8dedfa9 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -18,6 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/smp_lock.h>
21#include <linux/poll.h> 22#include <linux/poll.h>
22#include <linux/usb/iowarrior.h> 23#include <linux/usb/iowarrior.h>
23 24
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
index deb95bb49fd1..d645f3899fe1 100644
--- a/drivers/usb/misc/rio500.c
+++ b/drivers/usb/misc/rio500.c
@@ -32,6 +32,7 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/signal.h> 33#include <linux/signal.h>
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/smp_lock.h>
35#include <linux/errno.h> 36#include <linux/errno.h>
36#include <linux/random.h> 37#include <linux/random.h>
37#include <linux/poll.h> 38#include <linux/poll.h>
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index e0ff9ccd866b..29092b8e59ce 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -16,6 +16,7 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/smp_lock.h>
19#include <linux/errno.h> 20#include <linux/errno.h>
20#include <linux/mutex.h> 21#include <linux/mutex.h>
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index f8d9045d668a..0f7a30b7d2d1 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -1261,7 +1261,7 @@ static int mon_alloc_buff(struct mon_pgmap *map, int npages)
1261 return -ENOMEM; 1261 return -ENOMEM;
1262 } 1262 }
1263 map[n].ptr = (unsigned char *) vaddr; 1263 map[n].ptr = (unsigned char *) vaddr;
1264 map[n].pg = virt_to_page(vaddr); 1264 map[n].pg = virt_to_page((void *) vaddr);
1265 } 1265 }
1266 return 0; 1266 return 0;
1267} 1267}
diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h
index 8a39de3e6e47..59bf949e589b 100644
--- a/drivers/usb/musb/cppi_dma.h
+++ b/drivers/usb/musb/cppi_dma.h
@@ -5,7 +5,6 @@
5 5
6#include <linux/slab.h> 6#include <linux/slab.h>
7#include <linux/list.h> 7#include <linux/list.h>
8#include <linux/smp_lock.h>
9#include <linux/errno.h> 8#include <linux/errno.h>
10#include <linux/dmapool.h> 9#include <linux/dmapool.h>
11 10
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 180d7daa4099..e16ff605c458 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -35,13 +35,14 @@
35#include <mach/hardware.h> 35#include <mach/hardware.h>
36#include <mach/memory.h> 36#include <mach/memory.h>
37#include <mach/gpio.h> 37#include <mach/gpio.h>
38#include <mach/cputype.h>
38 39
39#include <asm/mach-types.h> 40#include <asm/mach-types.h>
40 41
41#include "musb_core.h" 42#include "musb_core.h"
42 43
43#ifdef CONFIG_MACH_DAVINCI_EVM 44#ifdef CONFIG_MACH_DAVINCI_EVM
44#define GPIO_nVBUS_DRV 87 45#define GPIO_nVBUS_DRV 144
45#endif 46#endif
46 47
47#include "davinci.h" 48#include "davinci.h"
@@ -329,7 +330,6 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
329 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); 330 mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
330 WARNING("VBUS error workaround (delay coming)\n"); 331 WARNING("VBUS error workaround (delay coming)\n");
331 } else if (is_host_enabled(musb) && drvvbus) { 332 } else if (is_host_enabled(musb) && drvvbus) {
332 musb->is_active = 1;
333 MUSB_HST_MODE(musb); 333 MUSB_HST_MODE(musb);
334 musb->xceiv->default_a = 1; 334 musb->xceiv->default_a = 1;
335 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; 335 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
@@ -343,7 +343,9 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
343 portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); 343 portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
344 } 344 }
345 345
346 /* NOTE: this must complete poweron within 100 msec */ 346 /* NOTE: this must complete poweron within 100 msec
347 * (OTG_TIME_A_WAIT_VRISE) but we don't check for that.
348 */
347 davinci_source_power(musb, drvvbus, 0); 349 davinci_source_power(musb, drvvbus, 0);
348 DBG(2, "VBUS %s (%s)%s, devctl %02x\n", 350 DBG(2, "VBUS %s (%s)%s, devctl %02x\n",
349 drvvbus ? "on" : "off", 351 drvvbus ? "on" : "off",
@@ -411,6 +413,21 @@ int __init musb_platform_init(struct musb *musb)
411 __raw_writel(phy_ctrl, USB_PHY_CTRL); 413 __raw_writel(phy_ctrl, USB_PHY_CTRL);
412 } 414 }
413 415
416 /* On dm355, the default-A state machine needs DRVVBUS control.
417 * If we won't be a host, there's no need to turn it on.
418 */
419 if (cpu_is_davinci_dm355()) {
420 u32 deepsleep = __raw_readl(DM355_DEEPSLEEP);
421
422 if (is_host_enabled(musb)) {
423 deepsleep &= ~DRVVBUS_OVERRIDE;
424 } else {
425 deepsleep &= ~DRVVBUS_FORCE;
426 deepsleep |= DRVVBUS_OVERRIDE;
427 }
428 __raw_writel(deepsleep, DM355_DEEPSLEEP);
429 }
430
414 /* reset the controller */ 431 /* reset the controller */
415 musb_writel(tibase, DAVINCI_USB_CTRL_REG, 0x1); 432 musb_writel(tibase, DAVINCI_USB_CTRL_REG, 0x1);
416 433
@@ -437,6 +454,15 @@ int musb_platform_exit(struct musb *musb)
437 if (is_host_enabled(musb)) 454 if (is_host_enabled(musb))
438 del_timer_sync(&otg_workaround); 455 del_timer_sync(&otg_workaround);
439 456
457 /* force VBUS off */
458 if (cpu_is_davinci_dm355()) {
459 u32 deepsleep = __raw_readl(DM355_DEEPSLEEP);
460
461 deepsleep &= ~DRVVBUS_FORCE;
462 deepsleep |= DRVVBUS_OVERRIDE;
463 __raw_writel(deepsleep, DM355_DEEPSLEEP);
464 }
465
440 davinci_source_power(musb, 0 /*off*/, 1); 466 davinci_source_power(musb, 0 /*off*/, 1);
441 467
442 /* delay, to avoid problems with module reload */ 468 /* delay, to avoid problems with module reload */
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index f3772ca3b2cf..381d648a36b8 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -38,7 +38,6 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/list.h> 39#include <linux/list.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/smp_lock.h>
42#include <linux/errno.h> 41#include <linux/errno.h>
43#include <linux/timer.h> 42#include <linux/timer.h>
44#include <linux/clk.h> 43#include <linux/clk.h>
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 94a2a350a414..cf94511485f2 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -373,7 +373,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
373 musb_save_toggle(qh, is_in, urb); 373 musb_save_toggle(qh, is_in, urb);
374 break; 374 break;
375 case USB_ENDPOINT_XFER_ISOC: 375 case USB_ENDPOINT_XFER_ISOC:
376 if (urb->error_count) 376 if (status == 0 && urb->error_count)
377 status = -EXDEV; 377 status = -EXDEV;
378 break; 378 break;
379 } 379 }
@@ -2235,13 +2235,30 @@ static void musb_h_stop(struct usb_hcd *hcd)
2235static int musb_bus_suspend(struct usb_hcd *hcd) 2235static int musb_bus_suspend(struct usb_hcd *hcd)
2236{ 2236{
2237 struct musb *musb = hcd_to_musb(hcd); 2237 struct musb *musb = hcd_to_musb(hcd);
2238 u8 devctl;
2238 2239
2239 if (musb->xceiv->state == OTG_STATE_A_SUSPEND) 2240 if (!is_host_active(musb))
2240 return 0; 2241 return 0;
2241 2242
2242 if (is_host_active(musb) && musb->is_active) { 2243 switch (musb->xceiv->state) {
2243 WARNING("trying to suspend as %s is_active=%i\n", 2244 case OTG_STATE_A_SUSPEND:
2244 otg_state_string(musb), musb->is_active); 2245 return 0;
2246 case OTG_STATE_A_WAIT_VRISE:
2247 /* ID could be grounded even if there's no device
2248 * on the other end of the cable. NOTE that the
2249 * A_WAIT_VRISE timers are messy with MUSB...
2250 */
2251 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
2252 if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
2253 musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
2254 break;
2255 default:
2256 break;
2257 }
2258
2259 if (musb->is_active) {
2260 WARNING("trying to suspend as %s while active\n",
2261 otg_state_string(musb));
2245 return -EBUSY; 2262 return -EBUSY;
2246 } else 2263 } else
2247 return 0; 2264 return 0;
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 69feeec1628c..aa884d072f0b 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -59,18 +59,4 @@ config NOP_USB_XCEIV
59 built-in with usb ip or which are autonomous and doesn't require any 59 built-in with usb ip or which are autonomous and doesn't require any
60 phy programming such as ISP1x04 etc. 60 phy programming such as ISP1x04 etc.
61 61
62config USB_LANGWELL_OTG
63 tristate "Intel Langwell USB OTG dual-role support"
64 depends on USB && MRST
65 select USB_OTG
66 select USB_OTG_UTILS
67 help
68 Say Y here if you want to build Intel Langwell USB OTG
69 transciever driver in kernel. This driver implements role
70 switch between EHCI host driver and Langwell USB OTG
71 client driver.
72
73 To compile this driver as a module, choose M here: the
74 module will be called langwell_otg.
75
76endif # USB || OTG 62endif # USB || OTG
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index 6d1abdd3c0ac..208167856529 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -9,7 +9,6 @@ obj-$(CONFIG_USB_OTG_UTILS) += otg.o
9obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o 9obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o
10obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 10obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
11obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o 11obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o
12obj-$(CONFIG_USB_LANGWELL_OTG) += langwell_otg.o
13obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o 12obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o
14 13
15ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG 14ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG
diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
deleted file mode 100644
index 6f628d0e9f39..000000000000
--- a/drivers/usb/otg/langwell_otg.c
+++ /dev/null
@@ -1,1915 +0,0 @@
1/*
2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008 - 2009, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19/* This driver helps to switch Langwell OTG controller function between host
20 * and peripheral. It works with EHCI driver and Langwell client controller
21 * driver together.
22 */
23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/pci.h>
26#include <linux/errno.h>
27#include <linux/interrupt.h>
28#include <linux/kernel.h>
29#include <linux/device.h>
30#include <linux/moduleparam.h>
31#include <linux/usb/ch9.h>
32#include <linux/usb/gadget.h>
33#include <linux/usb.h>
34#include <linux/usb/otg.h>
35#include <linux/notifier.h>
36#include <asm/ipc_defs.h>
37#include <linux/delay.h>
38#include "../core/hcd.h"
39
40#include <linux/usb/langwell_otg.h>
41
42#define DRIVER_DESC "Intel Langwell USB OTG transceiver driver"
43#define DRIVER_VERSION "3.0.0.32L.0002"
44
45MODULE_DESCRIPTION(DRIVER_DESC);
46MODULE_AUTHOR("Henry Yuan <hang.yuan@intel.com>, Hao Wu <hao.wu@intel.com>");
47MODULE_VERSION(DRIVER_VERSION);
48MODULE_LICENSE("GPL");
49
50static const char driver_name[] = "langwell_otg";
51
52static int langwell_otg_probe(struct pci_dev *pdev,
53 const struct pci_device_id *id);
54static void langwell_otg_remove(struct pci_dev *pdev);
55static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message);
56static int langwell_otg_resume(struct pci_dev *pdev);
57
58static int langwell_otg_set_host(struct otg_transceiver *otg,
59 struct usb_bus *host);
60static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
61 struct usb_gadget *gadget);
62static int langwell_otg_start_srp(struct otg_transceiver *otg);
63
64static const struct pci_device_id pci_ids[] = {{
65 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
66 .class_mask = ~0,
67 .vendor = 0x8086,
68 .device = 0x0811,
69 .subvendor = PCI_ANY_ID,
70 .subdevice = PCI_ANY_ID,
71}, { /* end: all zeroes */ }
72};
73
74static struct pci_driver otg_pci_driver = {
75 .name = (char *) driver_name,
76 .id_table = pci_ids,
77
78 .probe = langwell_otg_probe,
79 .remove = langwell_otg_remove,
80
81 .suspend = langwell_otg_suspend,
82 .resume = langwell_otg_resume,
83};
84
85static const char *state_string(enum usb_otg_state state)
86{
87 switch (state) {
88 case OTG_STATE_A_IDLE:
89 return "a_idle";
90 case OTG_STATE_A_WAIT_VRISE:
91 return "a_wait_vrise";
92 case OTG_STATE_A_WAIT_BCON:
93 return "a_wait_bcon";
94 case OTG_STATE_A_HOST:
95 return "a_host";
96 case OTG_STATE_A_SUSPEND:
97 return "a_suspend";
98 case OTG_STATE_A_PERIPHERAL:
99 return "a_peripheral";
100 case OTG_STATE_A_WAIT_VFALL:
101 return "a_wait_vfall";
102 case OTG_STATE_A_VBUS_ERR:
103 return "a_vbus_err";
104 case OTG_STATE_B_IDLE:
105 return "b_idle";
106 case OTG_STATE_B_SRP_INIT:
107 return "b_srp_init";
108 case OTG_STATE_B_PERIPHERAL:
109 return "b_peripheral";
110 case OTG_STATE_B_WAIT_ACON:
111 return "b_wait_acon";
112 case OTG_STATE_B_HOST:
113 return "b_host";
114 default:
115 return "UNDEFINED";
116 }
117}
118
119/* HSM timers */
120static inline struct langwell_otg_timer *otg_timer_initializer
121(void (*function)(unsigned long), unsigned long expires, unsigned long data)
122{
123 struct langwell_otg_timer *timer;
124 timer = kmalloc(sizeof(struct langwell_otg_timer), GFP_KERNEL);
125 timer->function = function;
126 timer->expires = expires;
127 timer->data = data;
128 return timer;
129}
130
131static struct langwell_otg_timer *a_wait_vrise_tmr, *a_wait_bcon_tmr,
132 *a_aidl_bdis_tmr, *b_ase0_brst_tmr, *b_se0_srp_tmr, *b_srp_res_tmr,
133 *b_bus_suspend_tmr;
134
135static struct list_head active_timers;
136
137static struct langwell_otg *the_transceiver;
138
139/* host/client notify transceiver when event affects HNP state */
140void langwell_update_transceiver()
141{
142 otg_dbg("transceiver driver is notified\n");
143 queue_work(the_transceiver->qwork, &the_transceiver->work);
144}
145EXPORT_SYMBOL(langwell_update_transceiver);
146
147static int langwell_otg_set_host(struct otg_transceiver *otg,
148 struct usb_bus *host)
149{
150 otg->host = host;
151
152 return 0;
153}
154
155static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
156 struct usb_gadget *gadget)
157{
158 otg->gadget = gadget;
159
160 return 0;
161}
162
163static int langwell_otg_set_power(struct otg_transceiver *otg,
164 unsigned mA)
165{
166 return 0;
167}
168
169/* A-device drives vbus, controlled through PMIC CHRGCNTL register*/
170static void langwell_otg_drv_vbus(int on)
171{
172 struct ipc_pmic_reg_data pmic_data = {0};
173 struct ipc_pmic_reg_data battery_data;
174
175 /* Check if battery is attached or not */
176 battery_data.pmic_reg_data[0].register_address = 0xd2;
177 battery_data.ioc = 0;
178 battery_data.num_entries = 1;
179 if (ipc_pmic_register_read(&battery_data)) {
180 otg_dbg("Failed to read PMIC register 0xd2.\n");
181 return;
182 }
183
184 if ((battery_data.pmic_reg_data[0].value & 0x20) == 0) {
185 otg_dbg("no battery attached\n");
186 return;
187 }
188
189 /* Workaround for battery attachment issue */
190 if (battery_data.pmic_reg_data[0].value == 0x34) {
191 otg_dbg("battery \n");
192 return;
193 }
194
195 otg_dbg("battery attached\n");
196
197 pmic_data.ioc = 0;
198 pmic_data.pmic_reg_data[0].register_address = 0xD4;
199 pmic_data.num_entries = 1;
200 if (on)
201 pmic_data.pmic_reg_data[0].value = 0x20;
202 else
203 pmic_data.pmic_reg_data[0].value = 0xc0;
204
205 if (ipc_pmic_register_write(&pmic_data, TRUE))
206 otg_dbg("Failed to write PMIC.\n");
207
208}
209
210/* charge vbus or discharge vbus through a resistor to ground */
211static void langwell_otg_chrg_vbus(int on)
212{
213
214 u32 val;
215
216 val = readl(the_transceiver->regs + CI_OTGSC);
217
218 if (on)
219 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VC,
220 the_transceiver->regs + CI_OTGSC);
221 else
222 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VD,
223 the_transceiver->regs + CI_OTGSC);
224
225}
226
227/* Start SRP */
228static int langwell_otg_start_srp(struct otg_transceiver *otg)
229{
230 u32 val;
231
232 otg_dbg("Start SRP ->\n");
233
234 val = readl(the_transceiver->regs + CI_OTGSC);
235
236 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HADP,
237 the_transceiver->regs + CI_OTGSC);
238
239 /* Check if the data plus is finished or not */
240 msleep(8);
241 val = readl(the_transceiver->regs + CI_OTGSC);
242 if (val & (OTGSC_HADP | OTGSC_DP))
243 otg_dbg("DataLine SRP Error\n");
244
245 /* FIXME: VBus SRP */
246
247 return 0;
248}
249
250
251/* stop SOF via bus_suspend */
252static void langwell_otg_loc_sof(int on)
253{
254 struct usb_hcd *hcd;
255 int err;
256
257 otg_dbg("loc_sof -> %d\n", on);
258
259 hcd = bus_to_hcd(the_transceiver->otg.host);
260 if (on)
261 err = hcd->driver->bus_resume(hcd);
262 else
263 err = hcd->driver->bus_suspend(hcd);
264
265 if (err)
266 otg_dbg("Failed to resume/suspend bus - %d\n", err);
267}
268
269static void langwell_otg_phy_low_power(int on)
270{
271 u32 val;
272
273 otg_dbg("phy low power mode-> %d\n", on);
274
275 val = readl(the_transceiver->regs + CI_HOSTPC1);
276 if (on)
277 writel(val | HOSTPC1_PHCD, the_transceiver->regs + CI_HOSTPC1);
278 else
279 writel(val & ~HOSTPC1_PHCD, the_transceiver->regs + CI_HOSTPC1);
280}
281
282/* Enable/Disable OTG interrupt */
283static void langwell_otg_intr(int on)
284{
285 u32 val;
286
287 otg_dbg("interrupt -> %d\n", on);
288
289 val = readl(the_transceiver->regs + CI_OTGSC);
290 if (on) {
291 val = val | (OTGSC_INTEN_MASK | OTGSC_IDPU);
292 writel(val, the_transceiver->regs + CI_OTGSC);
293 } else {
294 val = val & ~(OTGSC_INTEN_MASK | OTGSC_IDPU);
295 writel(val, the_transceiver->regs + CI_OTGSC);
296 }
297}
298
299/* set HAAR: Hardware Assist Auto-Reset */
300static void langwell_otg_HAAR(int on)
301{
302 u32 val;
303
304 otg_dbg("HAAR -> %d\n", on);
305
306 val = readl(the_transceiver->regs + CI_OTGSC);
307 if (on)
308 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HAAR,
309 the_transceiver->regs + CI_OTGSC);
310 else
311 writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HAAR,
312 the_transceiver->regs + CI_OTGSC);
313}
314
315/* set HABA: Hardware Assist B-Disconnect to A-Connect */
316static void langwell_otg_HABA(int on)
317{
318 u32 val;
319
320 otg_dbg("HABA -> %d\n", on);
321
322 val = readl(the_transceiver->regs + CI_OTGSC);
323 if (on)
324 writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HABA,
325 the_transceiver->regs + CI_OTGSC);
326 else
327 writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HABA,
328 the_transceiver->regs + CI_OTGSC);
329}
330
331static int langwell_otg_check_se0_srp(int on)
332{
333 u32 val;
334
335 int delay_time = TB_SE0_SRP * 10; /* step is 100us */
336
337 otg_dbg("check_se0_srp -> \n");
338
339 do {
340 udelay(100);
341 if (!delay_time--)
342 break;
343 val = readl(the_transceiver->regs + CI_PORTSC1);
344 val &= PORTSC_LS;
345 } while (!val);
346
347 otg_dbg("check_se0_srp <- \n");
348 return val;
349}
350
351/* The timeout callback function to set time out bit */
352static void set_tmout(unsigned long indicator)
353{
354 *(int *)indicator = 1;
355}
356
357void langwell_otg_nsf_msg(unsigned long indicator)
358{
359 switch (indicator) {
360 case 2:
361 case 4:
362 case 6:
363 case 7:
364 printk(KERN_ERR "OTG:NSF-%lu - deivce not responding\n",
365 indicator);
366 break;
367 case 3:
368 printk(KERN_ERR "OTG:NSF-%lu - deivce not supported\n",
369 indicator);
370 break;
371 default:
372 printk(KERN_ERR "Do not have this kind of NSF\n");
373 break;
374 }
375}
376
377/* Initialize timers */
378static void langwell_otg_init_timers(struct otg_hsm *hsm)
379{
380 /* HSM used timers */
381 a_wait_vrise_tmr = otg_timer_initializer(&set_tmout, TA_WAIT_VRISE,
382 (unsigned long)&hsm->a_wait_vrise_tmout);
383 a_wait_bcon_tmr = otg_timer_initializer(&set_tmout, TA_WAIT_BCON,
384 (unsigned long)&hsm->a_wait_bcon_tmout);
385 a_aidl_bdis_tmr = otg_timer_initializer(&set_tmout, TA_AIDL_BDIS,
386 (unsigned long)&hsm->a_aidl_bdis_tmout);
387 b_ase0_brst_tmr = otg_timer_initializer(&set_tmout, TB_ASE0_BRST,
388 (unsigned long)&hsm->b_ase0_brst_tmout);
389 b_se0_srp_tmr = otg_timer_initializer(&set_tmout, TB_SE0_SRP,
390 (unsigned long)&hsm->b_se0_srp);
391 b_srp_res_tmr = otg_timer_initializer(&set_tmout, TB_SRP_RES,
392 (unsigned long)&hsm->b_srp_res_tmout);
393 b_bus_suspend_tmr = otg_timer_initializer(&set_tmout, TB_BUS_SUSPEND,
394 (unsigned long)&hsm->b_bus_suspend_tmout);
395}
396
397/* Free timers */
398static void langwell_otg_free_timers(void)
399{
400 kfree(a_wait_vrise_tmr);
401 kfree(a_wait_bcon_tmr);
402 kfree(a_aidl_bdis_tmr);
403 kfree(b_ase0_brst_tmr);
404 kfree(b_se0_srp_tmr);
405 kfree(b_srp_res_tmr);
406 kfree(b_bus_suspend_tmr);
407}
408
409/* Add timer to timer list */
410static void langwell_otg_add_timer(void *gtimer)
411{
412 struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
413 struct langwell_otg_timer *tmp_timer;
414 u32 val32;
415
416 /* Check if the timer is already in the active list,
417 * if so update timer count
418 */
419 list_for_each_entry(tmp_timer, &active_timers, list)
420 if (tmp_timer == timer) {
421 timer->count = timer->expires;
422 return;
423 }
424 timer->count = timer->expires;
425
426 if (list_empty(&active_timers)) {
427 val32 = readl(the_transceiver->regs + CI_OTGSC);
428 writel(val32 | OTGSC_1MSE, the_transceiver->regs + CI_OTGSC);
429 }
430
431 list_add_tail(&timer->list, &active_timers);
432}
433
434/* Remove timer from the timer list; clear timeout status */
435static void langwell_otg_del_timer(void *gtimer)
436{
437 struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
438 struct langwell_otg_timer *tmp_timer, *del_tmp;
439 u32 val32;
440
441 list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list)
442 if (tmp_timer == timer)
443 list_del(&timer->list);
444
445 if (list_empty(&active_timers)) {
446 val32 = readl(the_transceiver->regs + CI_OTGSC);
447 writel(val32 & ~OTGSC_1MSE, the_transceiver->regs + CI_OTGSC);
448 }
449}
450
451/* Reduce timer count by 1, and find timeout conditions.*/
452static int langwell_otg_tick_timer(u32 *int_sts)
453{
454 struct langwell_otg_timer *tmp_timer, *del_tmp;
455 int expired = 0;
456
457 list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list) {
458 tmp_timer->count--;
459 /* check if timer expires */
460 if (!tmp_timer->count) {
461 list_del(&tmp_timer->list);
462 tmp_timer->function(tmp_timer->data);
463 expired = 1;
464 }
465 }
466
467 if (list_empty(&active_timers)) {
468 otg_dbg("tick timer: disable 1ms int\n");
469 *int_sts = *int_sts & ~OTGSC_1MSE;
470 }
471 return expired;
472}
473
474static void reset_otg(void)
475{
476 u32 val;
477 int delay_time = 1000;
478
479 otg_dbg("reseting OTG controller ...\n");
480 val = readl(the_transceiver->regs + CI_USBCMD);
481 writel(val | USBCMD_RST, the_transceiver->regs + CI_USBCMD);
482 do {
483 udelay(100);
484 if (!delay_time--)
485 otg_dbg("reset timeout\n");
486 val = readl(the_transceiver->regs + CI_USBCMD);
487 val &= USBCMD_RST;
488 } while (val != 0);
489 otg_dbg("reset done.\n");
490}
491
492static void set_host_mode(void)
493{
494 u32 val;
495
496 reset_otg();
497 val = readl(the_transceiver->regs + CI_USBMODE);
498 val = (val & (~USBMODE_CM)) | USBMODE_HOST;
499 writel(val, the_transceiver->regs + CI_USBMODE);
500}
501
502static void set_client_mode(void)
503{
504 u32 val;
505
506 reset_otg();
507 val = readl(the_transceiver->regs + CI_USBMODE);
508 val = (val & (~USBMODE_CM)) | USBMODE_DEVICE;
509 writel(val, the_transceiver->regs + CI_USBMODE);
510}
511
512static void init_hsm(void)
513{
514 struct langwell_otg *langwell = the_transceiver;
515 u32 val32;
516
517 /* read OTGSC after reset */
518 val32 = readl(langwell->regs + CI_OTGSC);
519 otg_dbg("%s: OTGSC init value = 0x%x\n", __func__, val32);
520
521 /* set init state */
522 if (val32 & OTGSC_ID) {
523 langwell->hsm.id = 1;
524 langwell->otg.default_a = 0;
525 set_client_mode();
526 langwell->otg.state = OTG_STATE_B_IDLE;
527 langwell_otg_drv_vbus(0);
528 } else {
529 langwell->hsm.id = 0;
530 langwell->otg.default_a = 1;
531 set_host_mode();
532 langwell->otg.state = OTG_STATE_A_IDLE;
533 }
534
535 /* set session indicator */
536 if (val32 & OTGSC_BSE)
537 langwell->hsm.b_sess_end = 1;
538 if (val32 & OTGSC_BSV)
539 langwell->hsm.b_sess_vld = 1;
540 if (val32 & OTGSC_ASV)
541 langwell->hsm.a_sess_vld = 1;
542 if (val32 & OTGSC_AVV)
543 langwell->hsm.a_vbus_vld = 1;
544
545 /* defautly power the bus */
546 langwell->hsm.a_bus_req = 1;
547 langwell->hsm.a_bus_drop = 0;
548 /* defautly don't request bus as B device */
549 langwell->hsm.b_bus_req = 0;
550 /* no system error */
551 langwell->hsm.a_clr_err = 0;
552}
553
554static irqreturn_t otg_dummy_irq(int irq, void *_dev)
555{
556 void __iomem *reg_base = _dev;
557 u32 val;
558 u32 int_mask = 0;
559
560 val = readl(reg_base + CI_USBMODE);
561 if ((val & USBMODE_CM) != USBMODE_DEVICE)
562 return IRQ_NONE;
563
564 val = readl(reg_base + CI_USBSTS);
565 int_mask = val & INTR_DUMMY_MASK;
566
567 if (int_mask == 0)
568 return IRQ_NONE;
569
570 /* clear hsm.b_conn here since host driver can't detect it
571 * otg_dummy_irq called means B-disconnect happened.
572 */
573 if (the_transceiver->hsm.b_conn) {
574 the_transceiver->hsm.b_conn = 0;
575 if (spin_trylock(&the_transceiver->wq_lock)) {
576 queue_work(the_transceiver->qwork,
577 &the_transceiver->work);
578 spin_unlock(&the_transceiver->wq_lock);
579 }
580 }
581 /* Clear interrupts */
582 writel(int_mask, reg_base + CI_USBSTS);
583 return IRQ_HANDLED;
584}
585
586static irqreturn_t otg_irq(int irq, void *_dev)
587{
588 struct langwell_otg *langwell = _dev;
589 u32 int_sts, int_en;
590 u32 int_mask = 0;
591 int flag = 0;
592
593 int_sts = readl(langwell->regs + CI_OTGSC);
594 int_en = (int_sts & OTGSC_INTEN_MASK) >> 8;
595 int_mask = int_sts & int_en;
596 if (int_mask == 0)
597 return IRQ_NONE;
598
599 if (int_mask & OTGSC_IDIS) {
600 otg_dbg("%s: id change int\n", __func__);
601 langwell->hsm.id = (int_sts & OTGSC_ID) ? 1 : 0;
602 flag = 1;
603 }
604 if (int_mask & OTGSC_DPIS) {
605 otg_dbg("%s: data pulse int\n", __func__);
606 langwell->hsm.a_srp_det = (int_sts & OTGSC_DPS) ? 1 : 0;
607 flag = 1;
608 }
609 if (int_mask & OTGSC_BSEIS) {
610 otg_dbg("%s: b session end int\n", __func__);
611 langwell->hsm.b_sess_end = (int_sts & OTGSC_BSE) ? 1 : 0;
612 flag = 1;
613 }
614 if (int_mask & OTGSC_BSVIS) {
615 otg_dbg("%s: b session valid int\n", __func__);
616 langwell->hsm.b_sess_vld = (int_sts & OTGSC_BSV) ? 1 : 0;
617 flag = 1;
618 }
619 if (int_mask & OTGSC_ASVIS) {
620 otg_dbg("%s: a session valid int\n", __func__);
621 langwell->hsm.a_sess_vld = (int_sts & OTGSC_ASV) ? 1 : 0;
622 flag = 1;
623 }
624 if (int_mask & OTGSC_AVVIS) {
625 otg_dbg("%s: a vbus valid int\n", __func__);
626 langwell->hsm.a_vbus_vld = (int_sts & OTGSC_AVV) ? 1 : 0;
627 flag = 1;
628 }
629
630 if (int_mask & OTGSC_1MSS) {
631 /* need to schedule otg_work if any timer is expired */
632 if (langwell_otg_tick_timer(&int_sts))
633 flag = 1;
634 }
635
636 writel((int_sts & ~OTGSC_INTSTS_MASK) | int_mask,
637 langwell->regs + CI_OTGSC);
638 if (flag)
639 queue_work(langwell->qwork, &langwell->work);
640
641 return IRQ_HANDLED;
642}
643
644static void langwell_otg_work(struct work_struct *work)
645{
646 struct langwell_otg *langwell = container_of(work,
647 struct langwell_otg, work);
648 int retval;
649
650 otg_dbg("%s: old state = %s\n", __func__,
651 state_string(langwell->otg.state));
652
653 switch (langwell->otg.state) {
654 case OTG_STATE_UNDEFINED:
655 case OTG_STATE_B_IDLE:
656 if (!langwell->hsm.id) {
657 langwell_otg_del_timer(b_srp_res_tmr);
658 langwell->otg.default_a = 1;
659 langwell->hsm.a_srp_det = 0;
660
661 langwell_otg_chrg_vbus(0);
662 langwell_otg_drv_vbus(0);
663
664 set_host_mode();
665 langwell->otg.state = OTG_STATE_A_IDLE;
666 queue_work(langwell->qwork, &langwell->work);
667 } else if (langwell->hsm.b_srp_res_tmout) {
668 langwell->hsm.b_srp_res_tmout = 0;
669 langwell->hsm.b_bus_req = 0;
670 langwell_otg_nsf_msg(6);
671 } else if (langwell->hsm.b_sess_vld) {
672 langwell_otg_del_timer(b_srp_res_tmr);
673 langwell->hsm.b_sess_end = 0;
674 langwell->hsm.a_bus_suspend = 0;
675
676 langwell_otg_chrg_vbus(0);
677 if (langwell->client_ops) {
678 langwell->client_ops->resume(langwell->pdev);
679 langwell->otg.state = OTG_STATE_B_PERIPHERAL;
680 } else
681 otg_dbg("client driver not loaded.\n");
682
683 } else if (langwell->hsm.b_bus_req &&
684 (langwell->hsm.b_sess_end)) {
685 /* workaround for b_se0_srp detection */
686 retval = langwell_otg_check_se0_srp(0);
687 if (retval) {
688 langwell->hsm.b_bus_req = 0;
689 otg_dbg("LS is not SE0, try again later\n");
690 } else {
691 /* Start SRP */
692 langwell_otg_start_srp(&langwell->otg);
693 langwell_otg_add_timer(b_srp_res_tmr);
694 }
695 }
696 break;
697 case OTG_STATE_B_SRP_INIT:
698 if (!langwell->hsm.id) {
699 langwell->otg.default_a = 1;
700 langwell->hsm.a_srp_det = 0;
701
702 langwell_otg_drv_vbus(0);
703 langwell_otg_chrg_vbus(0);
704
705 langwell->otg.state = OTG_STATE_A_IDLE;
706 queue_work(langwell->qwork, &langwell->work);
707 } else if (langwell->hsm.b_sess_vld) {
708 langwell_otg_chrg_vbus(0);
709 if (langwell->client_ops) {
710 langwell->client_ops->resume(langwell->pdev);
711 langwell->otg.state = OTG_STATE_B_PERIPHERAL;
712 } else
713 otg_dbg("client driver not loaded.\n");
714 }
715 break;
716 case OTG_STATE_B_PERIPHERAL:
717 if (!langwell->hsm.id) {
718 langwell->otg.default_a = 1;
719 langwell->hsm.a_srp_det = 0;
720
721 langwell_otg_drv_vbus(0);
722 langwell_otg_chrg_vbus(0);
723 set_host_mode();
724
725 if (langwell->client_ops) {
726 langwell->client_ops->suspend(langwell->pdev,
727 PMSG_FREEZE);
728 } else
729 otg_dbg("client driver has been removed.\n");
730
731 langwell->otg.state = OTG_STATE_A_IDLE;
732 queue_work(langwell->qwork, &langwell->work);
733 } else if (!langwell->hsm.b_sess_vld) {
734 langwell->hsm.b_hnp_enable = 0;
735
736 if (langwell->client_ops) {
737 langwell->client_ops->suspend(langwell->pdev,
738 PMSG_FREEZE);
739 } else
740 otg_dbg("client driver has been removed.\n");
741
742 langwell->otg.state = OTG_STATE_B_IDLE;
743 } else if (langwell->hsm.b_bus_req && langwell->hsm.b_hnp_enable
744 && langwell->hsm.a_bus_suspend) {
745
746 if (langwell->client_ops) {
747 langwell->client_ops->suspend(langwell->pdev,
748 PMSG_FREEZE);
749 } else
750 otg_dbg("client driver has been removed.\n");
751
752 langwell_otg_HAAR(1);
753 langwell->hsm.a_conn = 0;
754
755 if (langwell->host_ops) {
756 langwell->host_ops->probe(langwell->pdev,
757 langwell->host_ops->id_table);
758 langwell->otg.state = OTG_STATE_B_WAIT_ACON;
759 } else
760 otg_dbg("host driver not loaded.\n");
761
762 langwell->hsm.a_bus_resume = 0;
763 langwell->hsm.b_ase0_brst_tmout = 0;
764 langwell_otg_add_timer(b_ase0_brst_tmr);
765 }
766 break;
767
768 case OTG_STATE_B_WAIT_ACON:
769 if (!langwell->hsm.id) {
770 langwell_otg_del_timer(b_ase0_brst_tmr);
771 langwell->otg.default_a = 1;
772 langwell->hsm.a_srp_det = 0;
773
774 langwell_otg_drv_vbus(0);
775 langwell_otg_chrg_vbus(0);
776 set_host_mode();
777
778 langwell_otg_HAAR(0);
779 if (langwell->host_ops)
780 langwell->host_ops->remove(langwell->pdev);
781 else
782 otg_dbg("host driver has been removed.\n");
783 langwell->otg.state = OTG_STATE_A_IDLE;
784 queue_work(langwell->qwork, &langwell->work);
785 } else if (!langwell->hsm.b_sess_vld) {
786 langwell_otg_del_timer(b_ase0_brst_tmr);
787 langwell->hsm.b_hnp_enable = 0;
788 langwell->hsm.b_bus_req = 0;
789 langwell_otg_chrg_vbus(0);
790 langwell_otg_HAAR(0);
791
792 if (langwell->host_ops)
793 langwell->host_ops->remove(langwell->pdev);
794 else
795 otg_dbg("host driver has been removed.\n");
796 langwell->otg.state = OTG_STATE_B_IDLE;
797 } else if (langwell->hsm.a_conn) {
798 langwell_otg_del_timer(b_ase0_brst_tmr);
799 langwell_otg_HAAR(0);
800 langwell->otg.state = OTG_STATE_B_HOST;
801 queue_work(langwell->qwork, &langwell->work);
802 } else if (langwell->hsm.a_bus_resume ||
803 langwell->hsm.b_ase0_brst_tmout) {
804 langwell_otg_del_timer(b_ase0_brst_tmr);
805 langwell_otg_HAAR(0);
806 langwell_otg_nsf_msg(7);
807
808 if (langwell->host_ops)
809 langwell->host_ops->remove(langwell->pdev);
810 else
811 otg_dbg("host driver has been removed.\n");
812
813 langwell->hsm.a_bus_suspend = 0;
814 langwell->hsm.b_bus_req = 0;
815
816 if (langwell->client_ops)
817 langwell->client_ops->resume(langwell->pdev);
818 else
819 otg_dbg("client driver not loaded.\n");
820
821 langwell->otg.state = OTG_STATE_B_PERIPHERAL;
822 }
823 break;
824
825 case OTG_STATE_B_HOST:
826 if (!langwell->hsm.id) {
827 langwell->otg.default_a = 1;
828 langwell->hsm.a_srp_det = 0;
829
830 langwell_otg_drv_vbus(0);
831 langwell_otg_chrg_vbus(0);
832 set_host_mode();
833 if (langwell->host_ops)
834 langwell->host_ops->remove(langwell->pdev);
835 else
836 otg_dbg("host driver has been removed.\n");
837 langwell->otg.state = OTG_STATE_A_IDLE;
838 queue_work(langwell->qwork, &langwell->work);
839 } else if (!langwell->hsm.b_sess_vld) {
840 langwell->hsm.b_hnp_enable = 0;
841 langwell->hsm.b_bus_req = 0;
842 langwell_otg_chrg_vbus(0);
843 if (langwell->host_ops)
844 langwell->host_ops->remove(langwell->pdev);
845 else
846 otg_dbg("host driver has been removed.\n");
847 langwell->otg.state = OTG_STATE_B_IDLE;
848 } else if ((!langwell->hsm.b_bus_req) ||
849 (!langwell->hsm.a_conn)) {
850 langwell->hsm.b_bus_req = 0;
851 langwell_otg_loc_sof(0);
852 if (langwell->host_ops)
853 langwell->host_ops->remove(langwell->pdev);
854 else
855 otg_dbg("host driver has been removed.\n");
856
857 langwell->hsm.a_bus_suspend = 0;
858
859 if (langwell->client_ops)
860 langwell->client_ops->resume(langwell->pdev);
861 else
862 otg_dbg("client driver not loaded.\n");
863
864 langwell->otg.state = OTG_STATE_B_PERIPHERAL;
865 }
866 break;
867
868 case OTG_STATE_A_IDLE:
869 langwell->otg.default_a = 1;
870 if (langwell->hsm.id) {
871 langwell->otg.default_a = 0;
872 langwell->hsm.b_bus_req = 0;
873 langwell_otg_drv_vbus(0);
874 langwell_otg_chrg_vbus(0);
875
876 langwell->otg.state = OTG_STATE_B_IDLE;
877 queue_work(langwell->qwork, &langwell->work);
878 } else if (langwell->hsm.a_sess_vld) {
879 langwell_otg_drv_vbus(1);
880 langwell->hsm.a_srp_det = 1;
881 langwell->hsm.a_wait_vrise_tmout = 0;
882 langwell_otg_add_timer(a_wait_vrise_tmr);
883 langwell->otg.state = OTG_STATE_A_WAIT_VRISE;
884 queue_work(langwell->qwork, &langwell->work);
885 } else if (!langwell->hsm.a_bus_drop &&
886 (langwell->hsm.a_srp_det || langwell->hsm.a_bus_req)) {
887 langwell_otg_drv_vbus(1);
888 langwell->hsm.a_wait_vrise_tmout = 0;
889 langwell_otg_add_timer(a_wait_vrise_tmr);
890 langwell->otg.state = OTG_STATE_A_WAIT_VRISE;
891 queue_work(langwell->qwork, &langwell->work);
892 }
893 break;
894 case OTG_STATE_A_WAIT_VRISE:
895 if (langwell->hsm.id) {
896 langwell_otg_del_timer(a_wait_vrise_tmr);
897 langwell->hsm.b_bus_req = 0;
898 langwell->otg.default_a = 0;
899 langwell_otg_drv_vbus(0);
900 langwell->otg.state = OTG_STATE_B_IDLE;
901 } else if (langwell->hsm.a_vbus_vld) {
902 langwell_otg_del_timer(a_wait_vrise_tmr);
903 if (langwell->host_ops)
904 langwell->host_ops->probe(langwell->pdev,
905 langwell->host_ops->id_table);
906 else
907 otg_dbg("host driver not loaded.\n");
908 langwell->hsm.b_conn = 0;
909 langwell->hsm.a_set_b_hnp_en = 0;
910 langwell->hsm.a_wait_bcon_tmout = 0;
911 langwell_otg_add_timer(a_wait_bcon_tmr);
912 langwell->otg.state = OTG_STATE_A_WAIT_BCON;
913 } else if (langwell->hsm.a_wait_vrise_tmout) {
914 if (langwell->hsm.a_vbus_vld) {
915 if (langwell->host_ops)
916 langwell->host_ops->probe(
917 langwell->pdev,
918 langwell->host_ops->id_table);
919 else
920 otg_dbg("host driver not loaded.\n");
921 langwell->hsm.b_conn = 0;
922 langwell->hsm.a_set_b_hnp_en = 0;
923 langwell->hsm.a_wait_bcon_tmout = 0;
924 langwell_otg_add_timer(a_wait_bcon_tmr);
925 langwell->otg.state = OTG_STATE_A_WAIT_BCON;
926 } else {
927 langwell_otg_drv_vbus(0);
928 langwell->otg.state = OTG_STATE_A_VBUS_ERR;
929 }
930 }
931 break;
932 case OTG_STATE_A_WAIT_BCON:
933 if (langwell->hsm.id) {
934 langwell_otg_del_timer(a_wait_bcon_tmr);
935
936 langwell->otg.default_a = 0;
937 langwell->hsm.b_bus_req = 0;
938 if (langwell->host_ops)
939 langwell->host_ops->remove(langwell->pdev);
940 else
941 otg_dbg("host driver has been removed.\n");
942 langwell_otg_drv_vbus(0);
943 langwell->otg.state = OTG_STATE_B_IDLE;
944 queue_work(langwell->qwork, &langwell->work);
945 } else if (!langwell->hsm.a_vbus_vld) {
946 langwell_otg_del_timer(a_wait_bcon_tmr);
947
948 if (langwell->host_ops)
949 langwell->host_ops->remove(langwell->pdev);
950 else
951 otg_dbg("host driver has been removed.\n");
952 langwell_otg_drv_vbus(0);
953 langwell->otg.state = OTG_STATE_A_VBUS_ERR;
954 } else if (langwell->hsm.a_bus_drop ||
955 (langwell->hsm.a_wait_bcon_tmout &&
956 !langwell->hsm.a_bus_req)) {
957 langwell_otg_del_timer(a_wait_bcon_tmr);
958
959 if (langwell->host_ops)
960 langwell->host_ops->remove(langwell->pdev);
961 else
962 otg_dbg("host driver has been removed.\n");
963 langwell_otg_drv_vbus(0);
964 langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
965 } else if (langwell->hsm.b_conn) {
966 langwell_otg_del_timer(a_wait_bcon_tmr);
967
968 langwell->hsm.a_suspend_req = 0;
969 langwell->otg.state = OTG_STATE_A_HOST;
970 if (!langwell->hsm.a_bus_req &&
971 langwell->hsm.a_set_b_hnp_en) {
972 /* It is not safe enough to do a fast
973 * transistion from A_WAIT_BCON to
974 * A_SUSPEND */
975 msleep(10000);
976 if (langwell->hsm.a_bus_req)
977 break;
978
979 if (request_irq(langwell->pdev->irq,
980 otg_dummy_irq, IRQF_SHARED,
981 driver_name, langwell->regs) != 0) {
982 otg_dbg("request interrupt %d fail\n",
983 langwell->pdev->irq);
984 }
985
986 langwell_otg_HABA(1);
987 langwell->hsm.b_bus_resume = 0;
988 langwell->hsm.a_aidl_bdis_tmout = 0;
989 langwell_otg_add_timer(a_aidl_bdis_tmr);
990
991 langwell_otg_loc_sof(0);
992 langwell->otg.state = OTG_STATE_A_SUSPEND;
993 } else if (!langwell->hsm.a_bus_req &&
994 !langwell->hsm.a_set_b_hnp_en) {
995 struct pci_dev *pdev = langwell->pdev;
996 if (langwell->host_ops)
997 langwell->host_ops->remove(pdev);
998 else
999 otg_dbg("host driver removed.\n");
1000 langwell_otg_drv_vbus(0);
1001 langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
1002 }
1003 }
1004 break;
1005 case OTG_STATE_A_HOST:
1006 if (langwell->hsm.id) {
1007 langwell->otg.default_a = 0;
1008 langwell->hsm.b_bus_req = 0;
1009 if (langwell->host_ops)
1010 langwell->host_ops->remove(langwell->pdev);
1011 else
1012 otg_dbg("host driver has been removed.\n");
1013 langwell_otg_drv_vbus(0);
1014 langwell->otg.state = OTG_STATE_B_IDLE;
1015 queue_work(langwell->qwork, &langwell->work);
1016 } else if (langwell->hsm.a_bus_drop ||
1017 (!langwell->hsm.a_set_b_hnp_en && !langwell->hsm.a_bus_req)) {
1018 if (langwell->host_ops)
1019 langwell->host_ops->remove(langwell->pdev);
1020 else
1021 otg_dbg("host driver has been removed.\n");
1022 langwell_otg_drv_vbus(0);
1023 langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
1024 } else if (!langwell->hsm.a_vbus_vld) {
1025 if (langwell->host_ops)
1026 langwell->host_ops->remove(langwell->pdev);
1027 else
1028 otg_dbg("host driver has been removed.\n");
1029 langwell_otg_drv_vbus(0);
1030 langwell->otg.state = OTG_STATE_A_VBUS_ERR;
1031 } else if (langwell->hsm.a_set_b_hnp_en
1032 && !langwell->hsm.a_bus_req) {
1033 /* Set HABA to enable hardware assistance to signal
1034 * A-connect after receiver B-disconnect. Hardware
1035 * will then set client mode and enable URE, SLE and
1036 * PCE after the assistance. otg_dummy_irq is used to
1037 * clean these ints when client driver is not resumed.
1038 */
1039 if (request_irq(langwell->pdev->irq,
1040 otg_dummy_irq, IRQF_SHARED, driver_name,
1041 langwell->regs) != 0) {
1042 otg_dbg("request interrupt %d failed\n",
1043 langwell->pdev->irq);
1044 }
1045
1046 /* set HABA */
1047 langwell_otg_HABA(1);
1048 langwell->hsm.b_bus_resume = 0;
1049 langwell->hsm.a_aidl_bdis_tmout = 0;
1050 langwell_otg_add_timer(a_aidl_bdis_tmr);
1051 langwell_otg_loc_sof(0);
1052 langwell->otg.state = OTG_STATE_A_SUSPEND;
1053 } else if (!langwell->hsm.b_conn || !langwell->hsm.a_bus_req) {
1054 langwell->hsm.a_wait_bcon_tmout = 0;
1055 langwell->hsm.a_set_b_hnp_en = 0;
1056 langwell_otg_add_timer(a_wait_bcon_tmr);
1057 langwell->otg.state = OTG_STATE_A_WAIT_BCON;
1058 }
1059 break;
1060 case OTG_STATE_A_SUSPEND:
1061 if (langwell->hsm.id) {
1062 langwell_otg_del_timer(a_aidl_bdis_tmr);
1063 langwell_otg_HABA(0);
1064 free_irq(langwell->pdev->irq, langwell->regs);
1065 langwell->otg.default_a = 0;
1066 langwell->hsm.b_bus_req = 0;
1067 if (langwell->host_ops)
1068 langwell->host_ops->remove(langwell->pdev);
1069 else
1070 otg_dbg("host driver has been removed.\n");
1071 langwell_otg_drv_vbus(0);
1072 langwell->otg.state = OTG_STATE_B_IDLE;
1073 queue_work(langwell->qwork, &langwell->work);
1074 } else if (langwell->hsm.a_bus_req ||
1075 langwell->hsm.b_bus_resume) {
1076 langwell_otg_del_timer(a_aidl_bdis_tmr);
1077 langwell_otg_HABA(0);
1078 free_irq(langwell->pdev->irq, langwell->regs);
1079 langwell->hsm.a_suspend_req = 0;
1080 langwell_otg_loc_sof(1);
1081 langwell->otg.state = OTG_STATE_A_HOST;
1082 } else if (langwell->hsm.a_aidl_bdis_tmout ||
1083 langwell->hsm.a_bus_drop) {
1084 langwell_otg_del_timer(a_aidl_bdis_tmr);
1085 langwell_otg_HABA(0);
1086 free_irq(langwell->pdev->irq, langwell->regs);
1087 if (langwell->host_ops)
1088 langwell->host_ops->remove(langwell->pdev);
1089 else
1090 otg_dbg("host driver has been removed.\n");
1091 langwell_otg_drv_vbus(0);
1092 langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
1093 } else if (!langwell->hsm.b_conn &&
1094 langwell->hsm.a_set_b_hnp_en) {
1095 langwell_otg_del_timer(a_aidl_bdis_tmr);
1096 langwell_otg_HABA(0);
1097 free_irq(langwell->pdev->irq, langwell->regs);
1098
1099 if (langwell->host_ops)
1100 langwell->host_ops->remove(langwell->pdev);
1101 else
1102 otg_dbg("host driver has been removed.\n");
1103
1104 langwell->hsm.b_bus_suspend = 0;
1105 langwell->hsm.b_bus_suspend_vld = 0;
1106 langwell->hsm.b_bus_suspend_tmout = 0;
1107
1108 /* msleep(200); */
1109 if (langwell->client_ops)
1110 langwell->client_ops->resume(langwell->pdev);
1111 else
1112 otg_dbg("client driver not loaded.\n");
1113
1114 langwell_otg_add_timer(b_bus_suspend_tmr);
1115 langwell->otg.state = OTG_STATE_A_PERIPHERAL;
1116 break;
1117 } else if (!langwell->hsm.a_vbus_vld) {
1118 langwell_otg_del_timer(a_aidl_bdis_tmr);
1119 langwell_otg_HABA(0);
1120 free_irq(langwell->pdev->irq, langwell->regs);
1121 if (langwell->host_ops)
1122 langwell->host_ops->remove(langwell->pdev);
1123 else
1124 otg_dbg("host driver has been removed.\n");
1125 langwell_otg_drv_vbus(0);
1126 langwell->otg.state = OTG_STATE_A_VBUS_ERR;
1127 }
1128 break;
1129 case OTG_STATE_A_PERIPHERAL:
1130 if (langwell->hsm.id) {
1131 langwell_otg_del_timer(b_bus_suspend_tmr);
1132 langwell->otg.default_a = 0;
1133 langwell->hsm.b_bus_req = 0;
1134 if (langwell->client_ops)
1135 langwell->client_ops->suspend(langwell->pdev,
1136 PMSG_FREEZE);
1137 else
1138 otg_dbg("client driver has been removed.\n");
1139 langwell_otg_drv_vbus(0);
1140 langwell->otg.state = OTG_STATE_B_IDLE;
1141 queue_work(langwell->qwork, &langwell->work);
1142 } else if (!langwell->hsm.a_vbus_vld) {
1143 langwell_otg_del_timer(b_bus_suspend_tmr);
1144 if (langwell->client_ops)
1145 langwell->client_ops->suspend(langwell->pdev,
1146 PMSG_FREEZE);
1147 else
1148 otg_dbg("client driver has been removed.\n");
1149 langwell_otg_drv_vbus(0);
1150 langwell->otg.state = OTG_STATE_A_VBUS_ERR;
1151 } else if (langwell->hsm.a_bus_drop) {
1152 langwell_otg_del_timer(b_bus_suspend_tmr);
1153 if (langwell->client_ops)
1154 langwell->client_ops->suspend(langwell->pdev,
1155 PMSG_FREEZE);
1156 else
1157 otg_dbg("client driver has been removed.\n");
1158 langwell_otg_drv_vbus(0);
1159 langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
1160 } else if (langwell->hsm.b_bus_suspend) {
1161 langwell_otg_del_timer(b_bus_suspend_tmr);
1162 if (langwell->client_ops)
1163 langwell->client_ops->suspend(langwell->pdev,
1164 PMSG_FREEZE);
1165 else
1166 otg_dbg("client driver has been removed.\n");
1167
1168 if (langwell->host_ops)
1169 langwell->host_ops->probe(langwell->pdev,
1170 langwell->host_ops->id_table);
1171 else
1172 otg_dbg("host driver not loaded.\n");
1173 langwell->hsm.a_set_b_hnp_en = 0;
1174 langwell->hsm.a_wait_bcon_tmout = 0;
1175 langwell_otg_add_timer(a_wait_bcon_tmr);
1176 langwell->otg.state = OTG_STATE_A_WAIT_BCON;
1177 } else if (langwell->hsm.b_bus_suspend_tmout) {
1178 u32 val;
1179 val = readl(langwell->regs + CI_PORTSC1);
1180 if (!(val & PORTSC_SUSP))
1181 break;
1182 if (langwell->client_ops)
1183 langwell->client_ops->suspend(langwell->pdev,
1184 PMSG_FREEZE);
1185 else
1186 otg_dbg("client driver has been removed.\n");
1187 if (langwell->host_ops)
1188 langwell->host_ops->probe(langwell->pdev,
1189 langwell->host_ops->id_table);
1190 else
1191 otg_dbg("host driver not loaded.\n");
1192 langwell->hsm.a_set_b_hnp_en = 0;
1193 langwell->hsm.a_wait_bcon_tmout = 0;
1194 langwell_otg_add_timer(a_wait_bcon_tmr);
1195 langwell->otg.state = OTG_STATE_A_WAIT_BCON;
1196 }
1197 break;
1198 case OTG_STATE_A_VBUS_ERR:
1199 if (langwell->hsm.id) {
1200 langwell->otg.default_a = 0;
1201 langwell->hsm.a_clr_err = 0;
1202 langwell->hsm.a_srp_det = 0;
1203 langwell->otg.state = OTG_STATE_B_IDLE;
1204 queue_work(langwell->qwork, &langwell->work);
1205 } else if (langwell->hsm.a_clr_err) {
1206 langwell->hsm.a_clr_err = 0;
1207 langwell->hsm.a_srp_det = 0;
1208 reset_otg();
1209 init_hsm();
1210 if (langwell->otg.state == OTG_STATE_A_IDLE)
1211 queue_work(langwell->qwork, &langwell->work);
1212 }
1213 break;
1214 case OTG_STATE_A_WAIT_VFALL:
1215 if (langwell->hsm.id) {
1216 langwell->otg.default_a = 0;
1217 langwell->otg.state = OTG_STATE_B_IDLE;
1218 queue_work(langwell->qwork, &langwell->work);
1219 } else if (langwell->hsm.a_bus_req) {
1220 langwell_otg_drv_vbus(1);
1221 langwell->hsm.a_wait_vrise_tmout = 0;
1222 langwell_otg_add_timer(a_wait_vrise_tmr);
1223 langwell->otg.state = OTG_STATE_A_WAIT_VRISE;
1224 } else if (!langwell->hsm.a_sess_vld) {
1225 langwell->hsm.a_srp_det = 0;
1226 langwell_otg_drv_vbus(0);
1227 set_host_mode();
1228 langwell->otg.state = OTG_STATE_A_IDLE;
1229 }
1230 break;
1231 default:
1232 ;
1233 }
1234
1235 otg_dbg("%s: new state = %s\n", __func__,
1236 state_string(langwell->otg.state));
1237}
1238
1239 static ssize_t
1240show_registers(struct device *_dev, struct device_attribute *attr, char *buf)
1241{
1242 struct langwell_otg *langwell;
1243 char *next;
1244 unsigned size;
1245 unsigned t;
1246
1247 langwell = the_transceiver;
1248 next = buf;
1249 size = PAGE_SIZE;
1250
1251 t = scnprintf(next, size,
1252 "\n"
1253 "USBCMD = 0x%08x \n"
1254 "USBSTS = 0x%08x \n"
1255 "USBINTR = 0x%08x \n"
1256 "ASYNCLISTADDR = 0x%08x \n"
1257 "PORTSC1 = 0x%08x \n"
1258 "HOSTPC1 = 0x%08x \n"
1259 "OTGSC = 0x%08x \n"
1260 "USBMODE = 0x%08x \n",
1261 readl(langwell->regs + 0x30),
1262 readl(langwell->regs + 0x34),
1263 readl(langwell->regs + 0x38),
1264 readl(langwell->regs + 0x48),
1265 readl(langwell->regs + 0x74),
1266 readl(langwell->regs + 0xb4),
1267 readl(langwell->regs + 0xf4),
1268 readl(langwell->regs + 0xf8)
1269 );
1270 size -= t;
1271 next += t;
1272
1273 return PAGE_SIZE - size;
1274}
1275static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
1276
1277static ssize_t
1278show_hsm(struct device *_dev, struct device_attribute *attr, char *buf)
1279{
1280 struct langwell_otg *langwell;
1281 char *next;
1282 unsigned size;
1283 unsigned t;
1284
1285 langwell = the_transceiver;
1286 next = buf;
1287 size = PAGE_SIZE;
1288
1289 t = scnprintf(next, size,
1290 "\n"
1291 "current state = %s\n"
1292 "a_bus_resume = \t%d\n"
1293 "a_bus_suspend = \t%d\n"
1294 "a_conn = \t%d\n"
1295 "a_sess_vld = \t%d\n"
1296 "a_srp_det = \t%d\n"
1297 "a_vbus_vld = \t%d\n"
1298 "b_bus_resume = \t%d\n"
1299 "b_bus_suspend = \t%d\n"
1300 "b_conn = \t%d\n"
1301 "b_se0_srp = \t%d\n"
1302 "b_sess_end = \t%d\n"
1303 "b_sess_vld = \t%d\n"
1304 "id = \t%d\n"
1305 "a_set_b_hnp_en = \t%d\n"
1306 "b_srp_done = \t%d\n"
1307 "b_hnp_enable = \t%d\n"
1308 "a_wait_vrise_tmout = \t%d\n"
1309 "a_wait_bcon_tmout = \t%d\n"
1310 "a_aidl_bdis_tmout = \t%d\n"
1311 "b_ase0_brst_tmout = \t%d\n"
1312 "a_bus_drop = \t%d\n"
1313 "a_bus_req = \t%d\n"
1314 "a_clr_err = \t%d\n"
1315 "a_suspend_req = \t%d\n"
1316 "b_bus_req = \t%d\n"
1317 "b_bus_suspend_tmout = \t%d\n"
1318 "b_bus_suspend_vld = \t%d\n",
1319 state_string(langwell->otg.state),
1320 langwell->hsm.a_bus_resume,
1321 langwell->hsm.a_bus_suspend,
1322 langwell->hsm.a_conn,
1323 langwell->hsm.a_sess_vld,
1324 langwell->hsm.a_srp_det,
1325 langwell->hsm.a_vbus_vld,
1326 langwell->hsm.b_bus_resume,
1327 langwell->hsm.b_bus_suspend,
1328 langwell->hsm.b_conn,
1329 langwell->hsm.b_se0_srp,
1330 langwell->hsm.b_sess_end,
1331 langwell->hsm.b_sess_vld,
1332 langwell->hsm.id,
1333 langwell->hsm.a_set_b_hnp_en,
1334 langwell->hsm.b_srp_done,
1335 langwell->hsm.b_hnp_enable,
1336 langwell->hsm.a_wait_vrise_tmout,
1337 langwell->hsm.a_wait_bcon_tmout,
1338 langwell->hsm.a_aidl_bdis_tmout,
1339 langwell->hsm.b_ase0_brst_tmout,
1340 langwell->hsm.a_bus_drop,
1341 langwell->hsm.a_bus_req,
1342 langwell->hsm.a_clr_err,
1343 langwell->hsm.a_suspend_req,
1344 langwell->hsm.b_bus_req,
1345 langwell->hsm.b_bus_suspend_tmout,
1346 langwell->hsm.b_bus_suspend_vld
1347 );
1348 size -= t;
1349 next += t;
1350
1351 return PAGE_SIZE - size;
1352}
1353static DEVICE_ATTR(hsm, S_IRUGO, show_hsm, NULL);
1354
1355static ssize_t
1356get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
1357{
1358 struct langwell_otg *langwell;
1359 char *next;
1360 unsigned size;
1361 unsigned t;
1362
1363 langwell = the_transceiver;
1364 next = buf;
1365 size = PAGE_SIZE;
1366
1367 t = scnprintf(next, size, "%d", langwell->hsm.a_bus_req);
1368 size -= t;
1369 next += t;
1370
1371 return PAGE_SIZE - size;
1372}
1373
1374static ssize_t
1375set_a_bus_req(struct device *dev, struct device_attribute *attr,
1376 const char *buf, size_t count)
1377{
1378 struct langwell_otg *langwell;
1379 langwell = the_transceiver;
1380 if (!langwell->otg.default_a)
1381 return -1;
1382 if (count > 2)
1383 return -1;
1384
1385 if (buf[0] == '0') {
1386 langwell->hsm.a_bus_req = 0;
1387 otg_dbg("a_bus_req = 0\n");
1388 } else if (buf[0] == '1') {
1389 /* If a_bus_drop is TRUE, a_bus_req can't be set */
1390 if (langwell->hsm.a_bus_drop)
1391 return -1;
1392 langwell->hsm.a_bus_req = 1;
1393 otg_dbg("a_bus_req = 1\n");
1394 }
1395 if (spin_trylock(&langwell->wq_lock)) {
1396 queue_work(langwell->qwork, &langwell->work);
1397 spin_unlock(&langwell->wq_lock);
1398 }
1399 return count;
1400}
1401static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUGO, get_a_bus_req, set_a_bus_req);
1402
1403static ssize_t
1404get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
1405{
1406 struct langwell_otg *langwell;
1407 char *next;
1408 unsigned size;
1409 unsigned t;
1410
1411 langwell = the_transceiver;
1412 next = buf;
1413 size = PAGE_SIZE;
1414
1415 t = scnprintf(next, size, "%d", langwell->hsm.a_bus_drop);
1416 size -= t;
1417 next += t;
1418
1419 return PAGE_SIZE - size;
1420}
1421
1422static ssize_t
1423set_a_bus_drop(struct device *dev, struct device_attribute *attr,
1424 const char *buf, size_t count)
1425{
1426 struct langwell_otg *langwell;
1427 langwell = the_transceiver;
1428 if (!langwell->otg.default_a)
1429 return -1;
1430 if (count > 2)
1431 return -1;
1432
1433 if (buf[0] == '0') {
1434 langwell->hsm.a_bus_drop = 0;
1435 otg_dbg("a_bus_drop = 0\n");
1436 } else if (buf[0] == '1') {
1437 langwell->hsm.a_bus_drop = 1;
1438 langwell->hsm.a_bus_req = 0;
1439 otg_dbg("a_bus_drop = 1, then a_bus_req = 0\n");
1440 }
1441 if (spin_trylock(&langwell->wq_lock)) {
1442 queue_work(langwell->qwork, &langwell->work);
1443 spin_unlock(&langwell->wq_lock);
1444 }
1445 return count;
1446}
1447static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUGO,
1448 get_a_bus_drop, set_a_bus_drop);
1449
1450static ssize_t
1451get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
1452{
1453 struct langwell_otg *langwell;
1454 char *next;
1455 unsigned size;
1456 unsigned t;
1457
1458 langwell = the_transceiver;
1459 next = buf;
1460 size = PAGE_SIZE;
1461
1462 t = scnprintf(next, size, "%d", langwell->hsm.b_bus_req);
1463 size -= t;
1464 next += t;
1465
1466 return PAGE_SIZE - size;
1467}
1468
1469static ssize_t
1470set_b_bus_req(struct device *dev, struct device_attribute *attr,
1471 const char *buf, size_t count)
1472{
1473 struct langwell_otg *langwell;
1474 langwell = the_transceiver;
1475
1476 if (langwell->otg.default_a)
1477 return -1;
1478
1479 if (count > 2)
1480 return -1;
1481
1482 if (buf[0] == '0') {
1483 langwell->hsm.b_bus_req = 0;
1484 otg_dbg("b_bus_req = 0\n");
1485 } else if (buf[0] == '1') {
1486 langwell->hsm.b_bus_req = 1;
1487 otg_dbg("b_bus_req = 1\n");
1488 }
1489 if (spin_trylock(&langwell->wq_lock)) {
1490 queue_work(langwell->qwork, &langwell->work);
1491 spin_unlock(&langwell->wq_lock);
1492 }
1493 return count;
1494}
1495static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUGO, get_b_bus_req, set_b_bus_req);
1496
1497static ssize_t
1498set_a_clr_err(struct device *dev, struct device_attribute *attr,
1499 const char *buf, size_t count)
1500{
1501 struct langwell_otg *langwell;
1502 langwell = the_transceiver;
1503
1504 if (!langwell->otg.default_a)
1505 return -1;
1506 if (count > 2)
1507 return -1;
1508
1509 if (buf[0] == '1') {
1510 langwell->hsm.a_clr_err = 1;
1511 otg_dbg("a_clr_err = 1\n");
1512 }
1513 if (spin_trylock(&langwell->wq_lock)) {
1514 queue_work(langwell->qwork, &langwell->work);
1515 spin_unlock(&langwell->wq_lock);
1516 }
1517 return count;
1518}
1519static DEVICE_ATTR(a_clr_err, S_IWUGO, NULL, set_a_clr_err);
1520
1521static struct attribute *inputs_attrs[] = {
1522 &dev_attr_a_bus_req.attr,
1523 &dev_attr_a_bus_drop.attr,
1524 &dev_attr_b_bus_req.attr,
1525 &dev_attr_a_clr_err.attr,
1526 NULL,
1527};
1528
1529static struct attribute_group debug_dev_attr_group = {
1530 .name = "inputs",
1531 .attrs = inputs_attrs,
1532};
1533
1534int langwell_register_host(struct pci_driver *host_driver)
1535{
1536 int ret = 0;
1537
1538 the_transceiver->host_ops = host_driver;
1539 queue_work(the_transceiver->qwork, &the_transceiver->work);
1540 otg_dbg("host controller driver is registered\n");
1541
1542 return ret;
1543}
1544EXPORT_SYMBOL(langwell_register_host);
1545
1546void langwell_unregister_host(struct pci_driver *host_driver)
1547{
1548 if (the_transceiver->host_ops)
1549 the_transceiver->host_ops->remove(the_transceiver->pdev);
1550 the_transceiver->host_ops = NULL;
1551 the_transceiver->hsm.a_bus_drop = 1;
1552 queue_work(the_transceiver->qwork, &the_transceiver->work);
1553 otg_dbg("host controller driver is unregistered\n");
1554}
1555EXPORT_SYMBOL(langwell_unregister_host);
1556
1557int langwell_register_peripheral(struct pci_driver *client_driver)
1558{
1559 int ret = 0;
1560
1561 if (client_driver)
1562 ret = client_driver->probe(the_transceiver->pdev,
1563 client_driver->id_table);
1564 if (!ret) {
1565 the_transceiver->client_ops = client_driver;
1566 queue_work(the_transceiver->qwork, &the_transceiver->work);
1567 otg_dbg("client controller driver is registered\n");
1568 }
1569
1570 return ret;
1571}
1572EXPORT_SYMBOL(langwell_register_peripheral);
1573
1574void langwell_unregister_peripheral(struct pci_driver *client_driver)
1575{
1576 if (the_transceiver->client_ops)
1577 the_transceiver->client_ops->remove(the_transceiver->pdev);
1578 the_transceiver->client_ops = NULL;
1579 the_transceiver->hsm.b_bus_req = 0;
1580 queue_work(the_transceiver->qwork, &the_transceiver->work);
1581 otg_dbg("client controller driver is unregistered\n");
1582}
1583EXPORT_SYMBOL(langwell_unregister_peripheral);
1584
1585static int langwell_otg_probe(struct pci_dev *pdev,
1586 const struct pci_device_id *id)
1587{
1588 unsigned long resource, len;
1589 void __iomem *base = NULL;
1590 int retval;
1591 u32 val32;
1592 struct langwell_otg *langwell;
1593 char qname[] = "langwell_otg_queue";
1594
1595 retval = 0;
1596 otg_dbg("\notg controller is detected.\n");
1597 if (pci_enable_device(pdev) < 0) {
1598 retval = -ENODEV;
1599 goto done;
1600 }
1601
1602 langwell = kzalloc(sizeof *langwell, GFP_KERNEL);
1603 if (langwell == NULL) {
1604 retval = -ENOMEM;
1605 goto done;
1606 }
1607 the_transceiver = langwell;
1608
1609 /* control register: BAR 0 */
1610 resource = pci_resource_start(pdev, 0);
1611 len = pci_resource_len(pdev, 0);
1612 if (!request_mem_region(resource, len, driver_name)) {
1613 retval = -EBUSY;
1614 goto err;
1615 }
1616 langwell->region = 1;
1617
1618 base = ioremap_nocache(resource, len);
1619 if (base == NULL) {
1620 retval = -EFAULT;
1621 goto err;
1622 }
1623 langwell->regs = base;
1624
1625 if (!pdev->irq) {
1626 otg_dbg("No IRQ.\n");
1627 retval = -ENODEV;
1628 goto err;
1629 }
1630
1631 langwell->qwork = create_workqueue(qname);
1632 if (!langwell->qwork) {
1633 otg_dbg("cannot create workqueue %s\n", qname);
1634 retval = -ENOMEM;
1635 goto err;
1636 }
1637 INIT_WORK(&langwell->work, langwell_otg_work);
1638
1639 /* OTG common part */
1640 langwell->pdev = pdev;
1641 langwell->otg.dev = &pdev->dev;
1642 langwell->otg.label = driver_name;
1643 langwell->otg.set_host = langwell_otg_set_host;
1644 langwell->otg.set_peripheral = langwell_otg_set_peripheral;
1645 langwell->otg.set_power = langwell_otg_set_power;
1646 langwell->otg.start_srp = langwell_otg_start_srp;
1647 langwell->otg.state = OTG_STATE_UNDEFINED;
1648 if (otg_set_transceiver(&langwell->otg)) {
1649 otg_dbg("can't set transceiver\n");
1650 retval = -EBUSY;
1651 goto err;
1652 }
1653
1654 reset_otg();
1655 init_hsm();
1656
1657 spin_lock_init(&langwell->lock);
1658 spin_lock_init(&langwell->wq_lock);
1659 INIT_LIST_HEAD(&active_timers);
1660 langwell_otg_init_timers(&langwell->hsm);
1661
1662 if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
1663 driver_name, langwell) != 0) {
1664 otg_dbg("request interrupt %d failed\n", pdev->irq);
1665 retval = -EBUSY;
1666 goto err;
1667 }
1668
1669 /* enable OTGSC int */
1670 val32 = OTGSC_DPIE | OTGSC_BSEIE | OTGSC_BSVIE |
1671 OTGSC_ASVIE | OTGSC_AVVIE | OTGSC_IDIE | OTGSC_IDPU;
1672 writel(val32, langwell->regs + CI_OTGSC);
1673
1674 retval = device_create_file(&pdev->dev, &dev_attr_registers);
1675 if (retval < 0) {
1676 otg_dbg("Can't register sysfs attribute: %d\n", retval);
1677 goto err;
1678 }
1679
1680 retval = device_create_file(&pdev->dev, &dev_attr_hsm);
1681 if (retval < 0) {
1682 otg_dbg("Can't hsm sysfs attribute: %d\n", retval);
1683 goto err;
1684 }
1685
1686 retval = sysfs_create_group(&pdev->dev.kobj, &debug_dev_attr_group);
1687 if (retval < 0) {
1688 otg_dbg("Can't register sysfs attr group: %d\n", retval);
1689 goto err;
1690 }
1691
1692 if (langwell->otg.state == OTG_STATE_A_IDLE)
1693 queue_work(langwell->qwork, &langwell->work);
1694
1695 return 0;
1696
1697err:
1698 if (the_transceiver)
1699 langwell_otg_remove(pdev);
1700done:
1701 return retval;
1702}
1703
1704static void langwell_otg_remove(struct pci_dev *pdev)
1705{
1706 struct langwell_otg *langwell;
1707
1708 langwell = the_transceiver;
1709
1710 if (langwell->qwork) {
1711 flush_workqueue(langwell->qwork);
1712 destroy_workqueue(langwell->qwork);
1713 }
1714 langwell_otg_free_timers();
1715
1716 /* disable OTGSC interrupt as OTGSC doesn't change in reset */
1717 writel(0, langwell->regs + CI_OTGSC);
1718
1719 if (pdev->irq)
1720 free_irq(pdev->irq, langwell);
1721 if (langwell->regs)
1722 iounmap(langwell->regs);
1723 if (langwell->region)
1724 release_mem_region(pci_resource_start(pdev, 0),
1725 pci_resource_len(pdev, 0));
1726
1727 otg_set_transceiver(NULL);
1728 pci_disable_device(pdev);
1729 sysfs_remove_group(&pdev->dev.kobj, &debug_dev_attr_group);
1730 device_remove_file(&pdev->dev, &dev_attr_hsm);
1731 device_remove_file(&pdev->dev, &dev_attr_registers);
1732 kfree(langwell);
1733 langwell = NULL;
1734}
1735
1736static void transceiver_suspend(struct pci_dev *pdev)
1737{
1738 pci_save_state(pdev);
1739 pci_set_power_state(pdev, PCI_D3hot);
1740 langwell_otg_phy_low_power(1);
1741}
1742
1743static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
1744{
1745 int ret = 0;
1746 struct langwell_otg *langwell;
1747
1748 langwell = the_transceiver;
1749
1750 /* Disbale OTG interrupts */
1751 langwell_otg_intr(0);
1752
1753 if (pdev->irq)
1754 free_irq(pdev->irq, langwell);
1755
1756 /* Prevent more otg_work */
1757 flush_workqueue(langwell->qwork);
1758 spin_lock(&langwell->wq_lock);
1759
1760 /* start actions */
1761 switch (langwell->otg.state) {
1762 case OTG_STATE_A_IDLE:
1763 case OTG_STATE_B_IDLE:
1764 case OTG_STATE_A_WAIT_VFALL:
1765 case OTG_STATE_A_VBUS_ERR:
1766 transceiver_suspend(pdev);
1767 break;
1768 case OTG_STATE_A_WAIT_VRISE:
1769 langwell_otg_del_timer(a_wait_vrise_tmr);
1770 langwell->hsm.a_srp_det = 0;
1771 langwell_otg_drv_vbus(0);
1772 langwell->otg.state = OTG_STATE_A_IDLE;
1773 transceiver_suspend(pdev);
1774 break;
1775 case OTG_STATE_A_WAIT_BCON:
1776 langwell_otg_del_timer(a_wait_bcon_tmr);
1777 if (langwell->host_ops)
1778 ret = langwell->host_ops->suspend(pdev, message);
1779 langwell_otg_drv_vbus(0);
1780 break;
1781 case OTG_STATE_A_HOST:
1782 if (langwell->host_ops)
1783 ret = langwell->host_ops->suspend(pdev, message);
1784 langwell_otg_drv_vbus(0);
1785 langwell_otg_phy_low_power(1);
1786 break;
1787 case OTG_STATE_A_SUSPEND:
1788 langwell_otg_del_timer(a_aidl_bdis_tmr);
1789 langwell_otg_HABA(0);
1790 if (langwell->host_ops)
1791 langwell->host_ops->remove(pdev);
1792 else
1793 otg_dbg("host driver has been removed.\n");
1794 langwell_otg_drv_vbus(0);
1795 transceiver_suspend(pdev);
1796 langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
1797 break;
1798 case OTG_STATE_A_PERIPHERAL:
1799 if (langwell->client_ops)
1800 ret = langwell->client_ops->suspend(pdev, message);
1801 else
1802 otg_dbg("client driver has been removed.\n");
1803 langwell_otg_drv_vbus(0);
1804 transceiver_suspend(pdev);
1805 langwell->otg.state = OTG_STATE_A_WAIT_VFALL;
1806 break;
1807 case OTG_STATE_B_HOST:
1808 if (langwell->host_ops)
1809 langwell->host_ops->remove(pdev);
1810 else
1811 otg_dbg("host driver has been removed.\n");
1812 langwell->hsm.b_bus_req = 0;
1813 transceiver_suspend(pdev);
1814 langwell->otg.state = OTG_STATE_B_IDLE;
1815 break;
1816 case OTG_STATE_B_PERIPHERAL:
1817 if (langwell->client_ops)
1818 ret = langwell->client_ops->suspend(pdev, message);
1819 else
1820 otg_dbg("client driver has been removed.\n");
1821 break;
1822 case OTG_STATE_B_WAIT_ACON:
1823 langwell_otg_del_timer(b_ase0_brst_tmr);
1824 langwell_otg_HAAR(0);
1825 if (langwell->host_ops)
1826 langwell->host_ops->remove(pdev);
1827 else
1828 otg_dbg("host driver has been removed.\n");
1829 langwell->hsm.b_bus_req = 0;
1830 langwell->otg.state = OTG_STATE_B_IDLE;
1831 transceiver_suspend(pdev);
1832 break;
1833 default:
1834 otg_dbg("error state before suspend\n ");
1835 break;
1836 }
1837 spin_unlock(&langwell->wq_lock);
1838
1839 return ret;
1840}
1841
1842static void transceiver_resume(struct pci_dev *pdev)
1843{
1844 pci_restore_state(pdev);
1845 pci_set_power_state(pdev, PCI_D0);
1846 langwell_otg_phy_low_power(0);
1847}
1848
1849static int langwell_otg_resume(struct pci_dev *pdev)
1850{
1851 int ret = 0;
1852 struct langwell_otg *langwell;
1853
1854 langwell = the_transceiver;
1855
1856 spin_lock(&langwell->wq_lock);
1857
1858 switch (langwell->otg.state) {
1859 case OTG_STATE_A_IDLE:
1860 case OTG_STATE_B_IDLE:
1861 case OTG_STATE_A_WAIT_VFALL:
1862 case OTG_STATE_A_VBUS_ERR:
1863 transceiver_resume(pdev);
1864 break;
1865 case OTG_STATE_A_WAIT_BCON:
1866 langwell_otg_add_timer(a_wait_bcon_tmr);
1867 langwell_otg_drv_vbus(1);
1868 if (langwell->host_ops)
1869 ret = langwell->host_ops->resume(pdev);
1870 break;
1871 case OTG_STATE_A_HOST:
1872 langwell_otg_drv_vbus(1);
1873 langwell_otg_phy_low_power(0);
1874 if (langwell->host_ops)
1875 ret = langwell->host_ops->resume(pdev);
1876 break;
1877 case OTG_STATE_B_PERIPHERAL:
1878 if (langwell->client_ops)
1879 ret = langwell->client_ops->resume(pdev);
1880 else
1881 otg_dbg("client driver not loaded.\n");
1882 break;
1883 default:
1884 otg_dbg("error state before suspend\n ");
1885 break;
1886 }
1887
1888 if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
1889 driver_name, the_transceiver) != 0) {
1890 otg_dbg("request interrupt %d failed\n", pdev->irq);
1891 ret = -EBUSY;
1892 }
1893
1894 /* enable OTG interrupts */
1895 langwell_otg_intr(1);
1896
1897 spin_unlock(&langwell->wq_lock);
1898
1899 queue_work(langwell->qwork, &langwell->work);
1900
1901
1902 return ret;
1903}
1904
1905static int __init langwell_otg_init(void)
1906{
1907 return pci_register_driver(&otg_pci_driver);
1908}
1909module_init(langwell_otg_init);
1910
1911static void __exit langwell_otg_cleanup(void)
1912{
1913 pci_unregister_driver(&otg_pci_driver);
1914}
1915module_exit(langwell_otg_cleanup);
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index 9ed5ea568679..af456b48985f 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -53,6 +53,7 @@ EXPORT_SYMBOL(usb_nop_xceiv_register);
53void usb_nop_xceiv_unregister(void) 53void usb_nop_xceiv_unregister(void)
54{ 54{
55 platform_device_unregister(pd); 55 platform_device_unregister(pd);
56 pd = NULL;
56} 57}
57EXPORT_SYMBOL(usb_nop_xceiv_unregister); 58EXPORT_SYMBOL(usb_nop_xceiv_unregister);
58 59
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 247b61bfb7f4..0e4f2e41ace5 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -169,9 +169,11 @@ static int usb_console_setup(struct console *co, char *options)
169 kfree(tty); 169 kfree(tty);
170 } 170 }
171 } 171 }
172 /* So we know not to kill the hardware on a hangup on this 172 /* Now that any required fake tty operations are completed restore
173 port. We have also bumped the use count by one so it won't go 173 * the tty port count */
174 idle */ 174 --port->port.count;
175 /* The console is special in terms of closing the device so
176 * indicate this port is now acting as a system console. */
175 port->console = 1; 177 port->console = 1;
176 retval = 0; 178 retval = 0;
177 179
@@ -204,7 +206,7 @@ static void usb_console_write(struct console *co,
204 206
205 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 207 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
206 208
207 if (!port->port.count) { 209 if (!port->console) {
208 dbg("%s - port not opened", __func__); 210 dbg("%s - port not opened", __func__);
209 return; 211 return;
210 } 212 }
@@ -300,8 +302,7 @@ void usb_serial_console_exit(void)
300{ 302{
301 if (usbcons_info.port) { 303 if (usbcons_info.port) {
302 unregister_console(&usbcons); 304 unregister_console(&usbcons);
303 if (usbcons_info.port->port.count) 305 usbcons_info.port->console = 0;
304 usbcons_info.port->port.count--;
305 usbcons_info.port = NULL; 306 usbcons_info.port = NULL;
306 } 307 }
307} 308}
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 2b9eeda62bfe..e9a40b820fd4 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -67,6 +67,8 @@ static struct usb_device_id id_table [] = {
67 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ 67 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */
68 { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */ 68 { USB_DEVICE(0x10B5, 0xAC70) }, /* Nokia CA-42 USB */
69 { USB_DEVICE(0x10C4, 0x0F91) }, /* Vstabi */ 69 { USB_DEVICE(0x10C4, 0x0F91) }, /* Vstabi */
70 { USB_DEVICE(0x10C4, 0x1101) }, /* Arkham Technology DS101 Bus Monitor */
71 { USB_DEVICE(0x10C4, 0x1601) }, /* Arkham Technology DS101 Adapter */
70 { USB_DEVICE(0x10C4, 0x800A) }, /* SPORTident BSM7-D-USB main station */ 72 { USB_DEVICE(0x10C4, 0x800A) }, /* SPORTident BSM7-D-USB main station */
71 { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ 73 { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */
72 { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */ 74 { USB_DEVICE(0x10C4, 0x8053) }, /* Enfora EDG1228 */
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 9734085fd2fe..59adfe123110 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1228,8 +1228,8 @@ static void cypress_read_int_callback(struct urb *urb)
1228 /* precursor to disconnect so just go away */ 1228 /* precursor to disconnect so just go away */
1229 return; 1229 return;
1230 case -EPIPE: 1230 case -EPIPE:
1231 usb_clear_halt(port->serial->dev, 0x81); 1231 /* Can't call usb_clear_halt while in_interrupt */
1232 break; 1232 /* FALLS THROUGH */
1233 default: 1233 default:
1234 /* something ugly is going on... */ 1234 /* something ugly is going on... */
1235 dev_err(&urb->dev->dev, 1235 dev_err(&urb->dev->dev,
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 3dc3768ca71c..60c64cc5be2a 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -33,6 +33,7 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/smp_lock.h>
36#include <linux/tty.h> 37#include <linux/tty.h>
37#include <linux/tty_driver.h> 38#include <linux/tty_driver.h>
38#include <linux/tty_flip.h> 39#include <linux/tty_flip.h>
@@ -107,6 +108,7 @@ struct ftdi_sio_quirk {
107 108
108static int ftdi_jtag_probe(struct usb_serial *serial); 109static int ftdi_jtag_probe(struct usb_serial *serial);
109static int ftdi_mtxorb_hack_setup(struct usb_serial *serial); 110static int ftdi_mtxorb_hack_setup(struct usb_serial *serial);
111static int ftdi_NDI_device_setup(struct usb_serial *serial);
110static void ftdi_USB_UIRT_setup(struct ftdi_private *priv); 112static void ftdi_USB_UIRT_setup(struct ftdi_private *priv);
111static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv); 113static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv);
112 114
@@ -118,6 +120,10 @@ static struct ftdi_sio_quirk ftdi_mtxorb_hack_quirk = {
118 .probe = ftdi_mtxorb_hack_setup, 120 .probe = ftdi_mtxorb_hack_setup,
119}; 121};
120 122
123static struct ftdi_sio_quirk ftdi_NDI_device_quirk = {
124 .probe = ftdi_NDI_device_setup,
125};
126
121static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = { 127static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
122 .port_probe = ftdi_USB_UIRT_setup, 128 .port_probe = ftdi_USB_UIRT_setup,
123}; 129};
@@ -191,6 +197,7 @@ static struct usb_device_id id_table_combined [] = {
191 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) }, 197 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
192 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) }, 198 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
193 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, 199 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
200 { USB_DEVICE(FTDI_VID, FTDI_R2000KU_TRUE_RNG) },
194 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) }, 201 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) },
195 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) }, 202 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) },
196 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) }, 203 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) },
@@ -579,6 +586,9 @@ static struct usb_device_id id_table_combined [] = {
579 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) }, 586 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
580 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) }, 587 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
581 { USB_DEVICE(FTDI_VID, FTDI_CCSMACHX_2_PID) }, 588 { USB_DEVICE(FTDI_VID, FTDI_CCSMACHX_2_PID) },
589 { USB_DEVICE(FTDI_VID, FTDI_CCSLOAD_N_GO_3_PID) },
590 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU64_4_PID) },
591 { USB_DEVICE(FTDI_VID, FTDI_CCSPRIME8_5_PID) },
582 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) }, 592 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
583 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) }, 593 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) },
584 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 594 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
@@ -644,6 +654,16 @@ static struct usb_device_id id_table_combined [] = {
644 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, 654 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
645 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 655 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
646 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) }, 656 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
657 { USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID),
658 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
659 { USB_DEVICE(FTDI_VID, FTDI_NDI_SPECTRA_SCU_PID),
660 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
661 { USB_DEVICE(FTDI_VID, FTDI_NDI_FUTURE_2_PID),
662 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
663 { USB_DEVICE(FTDI_VID, FTDI_NDI_FUTURE_3_PID),
664 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
665 { USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID),
666 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
647 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, 667 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
648 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, 668 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) },
649 { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) }, 669 { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) },
@@ -660,6 +680,8 @@ static struct usb_device_id id_table_combined [] = {
660 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 680 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
661 { USB_DEVICE(FTDI_VID, LMI_LM3S_EVAL_BOARD_PID), 681 { USB_DEVICE(FTDI_VID, LMI_LM3S_EVAL_BOARD_PID),
662 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 682 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
683 { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID),
684 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
663 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, 685 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
664 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, 686 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
665 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) }, 687 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
@@ -667,7 +689,6 @@ static struct usb_device_id id_table_combined [] = {
667 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, 689 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
668 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) }, 690 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
669 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) }, 691 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) },
670 { USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID) },
671 { USB_DEVICE(ATMEL_VID, STK541_PID) }, 692 { USB_DEVICE(ATMEL_VID, STK541_PID) },
672 { USB_DEVICE(DE_VID, STB_PID) }, 693 { USB_DEVICE(DE_VID, STB_PID) },
673 { USB_DEVICE(DE_VID, WHT_PID) }, 694 { USB_DEVICE(DE_VID, WHT_PID) },
@@ -1023,6 +1044,16 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1023 case FT2232C: /* FT2232C chip */ 1044 case FT2232C: /* FT2232C chip */
1024 case FT232RL: 1045 case FT232RL:
1025 if (baud <= 3000000) { 1046 if (baud <= 3000000) {
1047 __u16 product_id = le16_to_cpu(
1048 port->serial->dev->descriptor.idProduct);
1049 if (((FTDI_NDI_HUC_PID == product_id) ||
1050 (FTDI_NDI_SPECTRA_SCU_PID == product_id) ||
1051 (FTDI_NDI_FUTURE_2_PID == product_id) ||
1052 (FTDI_NDI_FUTURE_3_PID == product_id) ||
1053 (FTDI_NDI_AURORA_SCU_PID == product_id)) &&
1054 (baud == 19200)) {
1055 baud = 1200000;
1056 }
1026 div_value = ftdi_232bm_baud_to_divisor(baud); 1057 div_value = ftdi_232bm_baud_to_divisor(baud);
1027 } else { 1058 } else {
1028 dbg("%s - Baud rate too high!", __func__); 1059 dbg("%s - Baud rate too high!", __func__);
@@ -1554,6 +1585,39 @@ static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv)
1554} /* ftdi_HE_TIRA1_setup */ 1585} /* ftdi_HE_TIRA1_setup */
1555 1586
1556/* 1587/*
1588 * Module parameter to control latency timer for NDI FTDI-based USB devices.
1589 * If this value is not set in modprobe.conf.local its value will be set to 1ms.
1590 */
1591static int ndi_latency_timer = 1;
1592
1593/* Setup for the NDI FTDI-based USB devices, which requires hardwired
1594 * baudrate (19200 gets mapped to 1200000).
1595 *
1596 * Called from usbserial:serial_probe.
1597 */
1598static int ftdi_NDI_device_setup(struct usb_serial *serial)
1599{
1600 struct usb_device *udev = serial->dev;
1601 int latency = ndi_latency_timer;
1602 int rv = 0;
1603 char buf[1];
1604
1605 if (latency == 0)
1606 latency = 1;
1607 if (latency > 99)
1608 latency = 99;
1609
1610 dbg("%s setting NDI device latency to %d", __func__, latency);
1611 dev_info(&udev->dev, "NDI device with a latency value of %d", latency);
1612
1613 rv = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
1614 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1615 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1616 latency, 0, buf, 0, WDR_TIMEOUT);
1617 return 0;
1618}
1619
1620/*
1557 * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko 1621 * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko
1558 * Neo1973 Debug Board is reserved for JTAG interface and can be accessed from 1622 * Neo1973 Debug Board is reserved for JTAG interface and can be accessed from
1559 * userspace using openocd. 1623 * userspace using openocd.
@@ -2121,7 +2185,7 @@ static void ftdi_process_read(struct work_struct *work)
2121 /* Note that the error flag is duplicated for 2185 /* Note that the error flag is duplicated for
2122 every character received since we don't know 2186 every character received since we don't know
2123 which character it applied to */ 2187 which character it applied to */
2124 if (!usb_serial_handle_sysrq_char(port, 2188 if (!usb_serial_handle_sysrq_char(tty, port,
2125 data[packet_offset + i])) 2189 data[packet_offset + i]))
2126 tty_insert_flip_char(tty, 2190 tty_insert_flip_char(tty,
2127 data[packet_offset + i], 2191 data[packet_offset + i],
@@ -2622,3 +2686,5 @@ MODULE_PARM_DESC(vendor, "User specified vendor ID (default="
2622module_param(product, ushort, 0); 2686module_param(product, ushort, 0);
2623MODULE_PARM_DESC(product, "User specified product ID"); 2687MODULE_PARM_DESC(product, "User specified product ID");
2624 2688
2689module_param(ndi_latency_timer, int, S_IRUGO | S_IWUSR);
2690MODULE_PARM_DESC(ndi_latency_timer, "NDI device latency timer override");
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index f1d440a728a3..c9fbd7415092 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -506,6 +506,7 @@
506 * 506 *
507 * Armin Laeuger originally sent the PID for the UM 100 module. 507 * Armin Laeuger originally sent the PID for the UM 100 module.
508 */ 508 */
509#define FTDI_R2000KU_TRUE_RNG 0xFB80 /* R2000KU TRUE RNG */
509#define FTDI_ELV_UR100_PID 0xFB58 /* USB-RS232-Umsetzer (UR 100) */ 510#define FTDI_ELV_UR100_PID 0xFB58 /* USB-RS232-Umsetzer (UR 100) */
510#define FTDI_ELV_UM100_PID 0xFB5A /* USB-Modul UM 100 */ 511#define FTDI_ELV_UM100_PID 0xFB5A /* USB-Modul UM 100 */
511#define FTDI_ELV_UO100_PID 0xFB5B /* USB-Modul UO 100 */ 512#define FTDI_ELV_UO100_PID 0xFB5B /* USB-Modul UO 100 */
@@ -614,6 +615,9 @@
614#define FTDI_CCSICDU20_0_PID 0xF9D0 615#define FTDI_CCSICDU20_0_PID 0xF9D0
615#define FTDI_CCSICDU40_1_PID 0xF9D1 616#define FTDI_CCSICDU40_1_PID 0xF9D1
616#define FTDI_CCSMACHX_2_PID 0xF9D2 617#define FTDI_CCSMACHX_2_PID 0xF9D2
618#define FTDI_CCSLOAD_N_GO_3_PID 0xF9D3
619#define FTDI_CCSICDU64_4_PID 0xF9D4
620#define FTDI_CCSPRIME8_5_PID 0xF9D5
617 621
618/* Inside Accesso contactless reader (http://www.insidefr.com) */ 622/* Inside Accesso contactless reader (http://www.insidefr.com) */
619#define INSIDE_ACCESSO 0xFAD0 623#define INSIDE_ACCESSO 0xFAD0
@@ -736,6 +740,15 @@
736#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ 740#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */
737 741
738/* 742/*
743 * NDI (www.ndigital.com) product ids
744 */
745#define FTDI_NDI_HUC_PID 0xDA70 /* NDI Host USB Converter */
746#define FTDI_NDI_SPECTRA_SCU_PID 0xDA71 /* NDI Spectra SCU */
747#define FTDI_NDI_FUTURE_2_PID 0xDA72 /* NDI future device #2 */
748#define FTDI_NDI_FUTURE_3_PID 0xDA73 /* NDI future device #3 */
749#define FTDI_NDI_AURORA_SCU_PID 0xDA74 /* NDI Aurora SCU */
750
751/*
739 * Posiflex inc retail equipment (http://www.posiflex.com.tw) 752 * Posiflex inc retail equipment (http://www.posiflex.com.tw)
740 */ 753 */
741#define POSIFLEX_VID 0x0d3a /* Vendor ID */ 754#define POSIFLEX_VID 0x0d3a /* Vendor ID */
@@ -848,9 +861,6 @@
848#define TML_VID 0x1B91 /* Vendor ID */ 861#define TML_VID 0x1B91 /* Vendor ID */
849#define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */ 862#define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */
850 863
851/* NDI Polaris System */
852#define FTDI_NDI_HUC_PID 0xDA70
853
854/* Propox devices */ 864/* Propox devices */
855#define FTDI_PROPOX_JTAGCABLEII_PID 0xD738 865#define FTDI_PROPOX_JTAGCABLEII_PID 0xD738
856 866
@@ -934,6 +944,8 @@
934#define MARVELL_VID 0x9e88 944#define MARVELL_VID 0x9e88
935#define MARVELL_SHEEVAPLUG_PID 0x9e8f 945#define MARVELL_SHEEVAPLUG_PID 0x9e8f
936 946
947#define FTDI_TURTELIZER_PID 0xBDC8 /* JTAG/RS-232 adapter by egnite GmBH */
948
937/* 949/*
938 * BmRequestType: 1100 0000b 950 * BmRequestType: 1100 0000b
939 * bRequest: FTDI_E2_READ 951 * bRequest: FTDI_E2_READ
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 932d6241b787..ce57f6a32bdf 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -424,10 +424,17 @@ static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
424 if (!tty) 424 if (!tty)
425 goto done; 425 goto done;
426 426
427 /* Push data to tty */ 427 /* The per character mucking around with sysrq path it too slow for
428 for (i = 0; i < urb->actual_length; i++, ch++) { 428 stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases
429 if (!usb_serial_handle_sysrq_char(port, *ch)) 429 where the USB serial is not a console anyway */
430 tty_insert_flip_char(tty, *ch, TTY_NORMAL); 430 if (!port->console || !port->sysrq)
431 tty_insert_flip_string(tty, ch, urb->actual_length);
432 else {
433 /* Push data to tty */
434 for (i = 0; i < urb->actual_length; i++, ch++) {
435 if (!usb_serial_handle_sysrq_char(tty, port, *ch))
436 tty_insert_flip_char(tty, *ch, TTY_NORMAL);
437 }
431 } 438 }
432 tty_flip_buffer_push(tty); 439 tty_flip_buffer_push(tty);
433 tty_kref_put(tty); 440 tty_kref_put(tty);
@@ -527,11 +534,12 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)
527 } 534 }
528} 535}
529 536
530int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) 537int usb_serial_handle_sysrq_char(struct tty_struct *tty,
538 struct usb_serial_port *port, unsigned int ch)
531{ 539{
532 if (port->sysrq && port->console) { 540 if (port->sysrq && port->console) {
533 if (ch && time_before(jiffies, port->sysrq)) { 541 if (ch && time_before(jiffies, port->sysrq)) {
534 handle_sysrq(ch, tty_port_tty_get(&port->port)); 542 handle_sysrq(ch, tty);
535 port->sysrq = 0; 543 port->sysrq = 0;
536 return 1; 544 return 1;
537 } 545 }
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index c40f95c1951c..c31940a307f8 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -26,6 +26,7 @@
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/smp_lock.h>
29#include <linux/tty.h> 30#include <linux/tty.h>
30#include <linux/tty_driver.h> 31#include <linux/tty_driver.h>
31#include <linux/tty_flip.h> 32#include <linux/tty_flip.h>
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 575816e6ba37..98262dd552bb 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -206,6 +206,7 @@ static int option_resume(struct usb_serial *serial);
206#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 206#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
207#define NOVATELWIRELESS_PRODUCT_U727 0x5010 207#define NOVATELWIRELESS_PRODUCT_U727 0x5010
208#define NOVATELWIRELESS_PRODUCT_MC760 0x6000 208#define NOVATELWIRELESS_PRODUCT_MC760 0x6000
209#define NOVATELWIRELESS_PRODUCT_OVMC760 0x6002
209 210
210/* FUTURE NOVATEL PRODUCTS */ 211/* FUTURE NOVATEL PRODUCTS */
211#define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0X6001 212#define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0X6001
@@ -307,11 +308,20 @@ static int option_resume(struct usb_serial *serial);
307#define DLINK_VENDOR_ID 0x1186 308#define DLINK_VENDOR_ID 0x1186
308#define DLINK_PRODUCT_DWM_652 0x3e04 309#define DLINK_PRODUCT_DWM_652 0x3e04
309 310
311#define QISDA_VENDOR_ID 0x1da5
312#define QISDA_PRODUCT_H21_4512 0x4512
313#define QISDA_PRODUCT_H21_4523 0x4523
314#define QISDA_PRODUCT_H20_4515 0x4515
315#define QISDA_PRODUCT_H20_4519 0x4519
316
310 317
311/* TOSHIBA PRODUCTS */ 318/* TOSHIBA PRODUCTS */
312#define TOSHIBA_VENDOR_ID 0x0930 319#define TOSHIBA_VENDOR_ID 0x0930
313#define TOSHIBA_PRODUCT_HSDPA_MINICARD 0x1302 320#define TOSHIBA_PRODUCT_HSDPA_MINICARD 0x1302
314 321
322#define ALINK_VENDOR_ID 0x1e0e
323#define ALINK_PRODUCT_3GU 0x9200
324
315static struct usb_device_id option_ids[] = { 325static struct usb_device_id option_ids[] = {
316 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 326 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
317 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 327 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -430,6 +440,7 @@ static struct usb_device_id option_ids[] = {
430 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ 440 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */
431 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel MC727/U727/USB727 */ 441 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel MC727/U727/USB727 */
432 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC760) }, /* Novatel MC760/U760/USB760 */ 442 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC760) }, /* Novatel MC760/U760/USB760 */
443 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_OVMC760) }, /* Novatel Ovation MC760 */
433 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */ 444 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */
434 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */ 445 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */
435 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, /* Novatel HSPA Embedded product */ 446 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, /* Novatel HSPA Embedded product */
@@ -529,8 +540,13 @@ static struct usb_device_id option_ids[] = {
529 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, 540 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) },
530 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 541 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
531 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 542 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
532 { USB_DEVICE(0x1da5, 0x4515) }, /* BenQ H20 */ 543 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
544 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
545 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
546 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4519) },
533 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */ 547 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */
548 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) },
549 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) },
534 { } /* Terminating entry */ 550 { } /* Terminating entry */
535}; 551};
536MODULE_DEVICE_TABLE(usb, option_ids); 552MODULE_DEVICE_TABLE(usb, option_ids);
@@ -732,7 +748,6 @@ static int option_write(struct tty_struct *tty, struct usb_serial_port *port,
732 memcpy(this_urb->transfer_buffer, buf, todo); 748 memcpy(this_urb->transfer_buffer, buf, todo);
733 this_urb->transfer_buffer_length = todo; 749 this_urb->transfer_buffer_length = todo;
734 750
735 this_urb->dev = port->serial->dev;
736 err = usb_submit_urb(this_urb, GFP_ATOMIC); 751 err = usb_submit_urb(this_urb, GFP_ATOMIC);
737 if (err) { 752 if (err) {
738 dbg("usb_submit_urb %p (write bulk) failed " 753 dbg("usb_submit_urb %p (write bulk) failed "
@@ -860,7 +875,6 @@ static void option_instat_callback(struct urb *urb)
860 875
861 /* Resubmit urb so we continue receiving IRQ data */ 876 /* Resubmit urb so we continue receiving IRQ data */
862 if (status != -ESHUTDOWN && status != -ENOENT) { 877 if (status != -ESHUTDOWN && status != -ENOENT) {
863 urb->dev = serial->dev;
864 err = usb_submit_urb(urb, GFP_ATOMIC); 878 err = usb_submit_urb(urb, GFP_ATOMIC);
865 if (err) 879 if (err)
866 dbg("%s: resubmit intr urb failed. (%d)", 880 dbg("%s: resubmit intr urb failed. (%d)",
@@ -921,23 +935,11 @@ static int option_open(struct tty_struct *tty,
921 935
922 dbg("%s", __func__); 936 dbg("%s", __func__);
923 937
924 /* Reset low level data toggle and start reading from endpoints */ 938 /* Start reading from the IN endpoint */
925 for (i = 0; i < N_IN_URB; i++) { 939 for (i = 0; i < N_IN_URB; i++) {
926 urb = portdata->in_urbs[i]; 940 urb = portdata->in_urbs[i];
927 if (!urb) 941 if (!urb)
928 continue; 942 continue;
929 if (urb->dev != serial->dev) {
930 dbg("%s: dev %p != %p", __func__,
931 urb->dev, serial->dev);
932 continue;
933 }
934
935 /*
936 * make sure endpoint data toggle is synchronized with the
937 * device
938 */
939 usb_clear_halt(urb->dev, urb->pipe);
940
941 err = usb_submit_urb(urb, GFP_KERNEL); 943 err = usb_submit_urb(urb, GFP_KERNEL);
942 if (err) { 944 if (err) {
943 dbg("%s: submit urb %d failed (%d) %d", 945 dbg("%s: submit urb %d failed (%d) %d",
@@ -946,16 +948,6 @@ static int option_open(struct tty_struct *tty,
946 } 948 }
947 } 949 }
948 950
949 /* Reset low level data toggle on out endpoints */
950 for (i = 0; i < N_OUT_URB; i++) {
951 urb = portdata->out_urbs[i];
952 if (!urb)
953 continue;
954 urb->dev = serial->dev;
955 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
956 usb_pipeout(urb->pipe), 0); */
957 }
958
959 option_send_setup(port); 951 option_send_setup(port);
960 952
961 return 0; 953 return 0;
@@ -1218,7 +1210,6 @@ static int option_resume(struct usb_serial *serial)
1218 dbg("%s: No interrupt URB for port %d\n", __func__, i); 1210 dbg("%s: No interrupt URB for port %d\n", __func__, i);
1219 continue; 1211 continue;
1220 } 1212 }
1221 port->interrupt_in_urb->dev = serial->dev;
1222 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); 1213 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
1223 dbg("Submitted interrupt URB for port %d (result %d)", i, err); 1214 dbg("Submitted interrupt URB for port %d (result %d)", i, err);
1224 if (err < 0) { 1215 if (err < 0) {
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ec6c132a25b5..7d15bfa7c2db 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -94,6 +94,7 @@ static struct usb_device_id id_table [] = {
94 { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) }, 94 { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) },
95 { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) }, 95 { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) },
96 { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) }, 96 { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) },
97 { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) },
97 { } /* Terminating entry */ 98 { } /* Terminating entry */
98}; 99};
99 100
@@ -971,18 +972,46 @@ exit:
971 __func__, retval); 972 __func__, retval);
972} 973}
973 974
975static void pl2303_push_data(struct tty_struct *tty,
976 struct usb_serial_port *port, struct urb *urb,
977 u8 line_status)
978{
979 unsigned char *data = urb->transfer_buffer;
980 /* get tty_flag from status */
981 char tty_flag = TTY_NORMAL;
982 /* break takes precedence over parity, */
983 /* which takes precedence over framing errors */
984 if (line_status & UART_BREAK_ERROR)
985 tty_flag = TTY_BREAK;
986 else if (line_status & UART_PARITY_ERROR)
987 tty_flag = TTY_PARITY;
988 else if (line_status & UART_FRAME_ERROR)
989 tty_flag = TTY_FRAME;
990 dbg("%s - tty_flag = %d", __func__, tty_flag);
991
992 tty_buffer_request_room(tty, urb->actual_length + 1);
993 /* overrun is special, not associated with a char */
994 if (line_status & UART_OVERRUN_ERROR)
995 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
996 if (port->console && port->sysrq) {
997 int i;
998 for (i = 0; i < urb->actual_length; ++i)
999 if (!usb_serial_handle_sysrq_char(tty, port, data[i]))
1000 tty_insert_flip_char(tty, data[i], tty_flag);
1001 } else
1002 tty_insert_flip_string(tty, data, urb->actual_length);
1003 tty_flip_buffer_push(tty);
1004}
1005
974static void pl2303_read_bulk_callback(struct urb *urb) 1006static void pl2303_read_bulk_callback(struct urb *urb)
975{ 1007{
976 struct usb_serial_port *port = urb->context; 1008 struct usb_serial_port *port = urb->context;
977 struct pl2303_private *priv = usb_get_serial_port_data(port); 1009 struct pl2303_private *priv = usb_get_serial_port_data(port);
978 struct tty_struct *tty; 1010 struct tty_struct *tty;
979 unsigned char *data = urb->transfer_buffer;
980 unsigned long flags; 1011 unsigned long flags;
981 int i;
982 int result; 1012 int result;
983 int status = urb->status; 1013 int status = urb->status;
984 u8 line_status; 1014 u8 line_status;
985 char tty_flag;
986 1015
987 dbg("%s - port %d", __func__, port->number); 1016 dbg("%s - port %d", __func__, port->number);
988 1017
@@ -1010,10 +1039,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1010 } 1039 }
1011 1040
1012 usb_serial_debug_data(debug, &port->dev, __func__, 1041 usb_serial_debug_data(debug, &port->dev, __func__,
1013 urb->actual_length, data); 1042 urb->actual_length, urb->transfer_buffer);
1014
1015 /* get tty_flag from status */
1016 tty_flag = TTY_NORMAL;
1017 1043
1018 spin_lock_irqsave(&priv->lock, flags); 1044 spin_lock_irqsave(&priv->lock, flags);
1019 line_status = priv->line_status; 1045 line_status = priv->line_status;
@@ -1021,26 +1047,9 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1021 spin_unlock_irqrestore(&priv->lock, flags); 1047 spin_unlock_irqrestore(&priv->lock, flags);
1022 wake_up_interruptible(&priv->delta_msr_wait); 1048 wake_up_interruptible(&priv->delta_msr_wait);
1023 1049
1024 /* break takes precedence over parity, */
1025 /* which takes precedence over framing errors */
1026 if (line_status & UART_BREAK_ERROR)
1027 tty_flag = TTY_BREAK;
1028 else if (line_status & UART_PARITY_ERROR)
1029 tty_flag = TTY_PARITY;
1030 else if (line_status & UART_FRAME_ERROR)
1031 tty_flag = TTY_FRAME;
1032 dbg("%s - tty_flag = %d", __func__, tty_flag);
1033
1034 tty = tty_port_tty_get(&port->port); 1050 tty = tty_port_tty_get(&port->port);
1035 if (tty && urb->actual_length) { 1051 if (tty && urb->actual_length) {
1036 tty_buffer_request_room(tty, urb->actual_length + 1); 1052 pl2303_push_data(tty, port, urb, line_status);
1037 /* overrun is special, not associated with a char */
1038 if (line_status & UART_OVERRUN_ERROR)
1039 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
1040 for (i = 0; i < urb->actual_length; ++i)
1041 if (!usb_serial_handle_sysrq_char(port, data[i]))
1042 tty_insert_flip_char(tty, data[i], tty_flag);
1043 tty_flip_buffer_push(tty);
1044 } 1053 }
1045 tty_kref_put(tty); 1054 tty_kref_put(tty);
1046 /* Schedule the next read _if_ we are still open */ 1055 /* Schedule the next read _if_ we are still open */
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 1d7a22e3a9fd..12aac7d2462d 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -122,3 +122,7 @@
122/* Hewlett-Packard LD220-HP POS Pole Display */ 122/* Hewlett-Packard LD220-HP POS Pole Display */
123#define HP_VENDOR_ID 0x03f0 123#define HP_VENDOR_ID 0x03f0
124#define HP_LD220_PRODUCT_ID 0x3524 124#define HP_LD220_PRODUCT_ID 0x3524
125
126/* Cressi Edy (diving computer) PC interface */
127#define CRESSI_VENDOR_ID 0x04b8
128#define CRESSI_EDY_PRODUCT_ID 0x0521
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 032f7aeb40a4..f48d05e0acc1 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -181,35 +181,50 @@ static const struct sierra_iface_info direct_ip_interface_blacklist = {
181}; 181};
182 182
183static struct usb_device_id id_table [] = { 183static struct usb_device_id id_table [] = {
184 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */
185 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */
186 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */
187
184 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 188 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
185 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 189 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
186 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 190 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
187 { USB_DEVICE(0x03f0, 0x1b1d) }, /* HP ev2200 a.k.a MC5720 */
188 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 191 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
189 { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */
190 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ 192 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
193 { USB_DEVICE(0x1199, 0x0022) }, /* Sierra Wireless EM5725 */
194 { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */
195 { USB_DEVICE(0x1199, 0x0224) }, /* Sierra Wireless MC5727 */
191 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 196 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
192 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ 197 { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
198 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
193 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ 199 { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */
194 /* Sierra Wireless C597 */ 200 /* Sierra Wireless C597 */
195 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) }, 201 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) },
196 /* Sierra Wireless Device */ 202 /* Sierra Wireless T598 */
197 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) }, 203 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) },
198 { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */ 204 { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless T11 */
199 { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless Device */ 205 { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless AC402 */
200 { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless Device */ 206 { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless MC5728 */
207 { USB_DEVICE(0x1199, 0x0029) }, /* Sierra Wireless Device */
201 208
202 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 209 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
203 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
204 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 210 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
211 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
212 { USB_DEVICE(0x1199, 0x6805) }, /* Sierra Wireless MC8765 */
213 { USB_DEVICE(0x1199, 0x6808) }, /* Sierra Wireless MC8755 */
214 { USB_DEVICE(0x1199, 0x6809) }, /* Sierra Wireless MC8765 */
205 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ 215 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */
206 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Lenovo) */ 216 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 */
207 { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */ 217 { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */
208 { USB_DEVICE(0x03f0, 0x1e1d) }, /* HP hs2300 a.k.a MC8775 */ 218 { USB_DEVICE(0x1199, 0x6816) }, /* Sierra Wireless MC8775 */
209 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 219 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
210 { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ 220 { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */
221 { USB_DEVICE(0x1199, 0x6822) }, /* Sierra Wireless AirCard 875E */
211 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ 222 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */
212 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ 223 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */
224 { USB_DEVICE(0x1199, 0x6834) }, /* Sierra Wireless MC8780 */
225 { USB_DEVICE(0x1199, 0x6835) }, /* Sierra Wireless MC8781 */
226 { USB_DEVICE(0x1199, 0x6838) }, /* Sierra Wireless MC8780 */
227 { USB_DEVICE(0x1199, 0x6839) }, /* Sierra Wireless MC8781 */
213 { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */ 228 { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */
214 { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ 229 { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */
215 /* Sierra Wireless MC8790, MC8791, MC8792 Composite */ 230 /* Sierra Wireless MC8790, MC8791, MC8792 Composite */
@@ -227,16 +242,13 @@ static struct usb_device_id id_table [] = {
227 { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */ 242 { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */
228 /* Sierra Wireless C885 */ 243 /* Sierra Wireless C885 */
229 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)}, 244 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)},
230 /* Sierra Wireless Device */ 245 /* Sierra Wireless C888, Air Card 501, USB 303, USB 304 */
231 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)}, 246 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)},
232 /* Sierra Wireless Device */ 247 /* Sierra Wireless C22/C33 */
233 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)}, 248 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)},
234 /* Sierra Wireless Device */ 249 /* Sierra Wireless HSPA Non-Composite Device */
235 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, 250 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)},
236 251 { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */
237 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
238 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */
239
240 { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */ 252 { USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless Direct IP modems */
241 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist 253 .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
242 }, 254 },
@@ -814,7 +826,7 @@ static int sierra_startup(struct usb_serial *serial)
814 return 0; 826 return 0;
815} 827}
816 828
817static void sierra_disconnect(struct usb_serial *serial) 829static void sierra_release(struct usb_serial *serial)
818{ 830{
819 int i; 831 int i;
820 struct usb_serial_port *port; 832 struct usb_serial_port *port;
@@ -830,7 +842,6 @@ static void sierra_disconnect(struct usb_serial *serial)
830 if (!portdata) 842 if (!portdata)
831 continue; 843 continue;
832 kfree(portdata); 844 kfree(portdata);
833 usb_set_serial_port_data(port, NULL);
834 } 845 }
835} 846}
836 847
@@ -853,7 +864,7 @@ static struct usb_serial_driver sierra_device = {
853 .tiocmget = sierra_tiocmget, 864 .tiocmget = sierra_tiocmget,
854 .tiocmset = sierra_tiocmset, 865 .tiocmset = sierra_tiocmset,
855 .attach = sierra_startup, 866 .attach = sierra_startup,
856 .disconnect = sierra_disconnect, 867 .release = sierra_release,
857 .read_int_callback = sierra_instat_callback, 868 .read_int_callback = sierra_instat_callback,
858}; 869};
859 870
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 991d8232e376..14971a926990 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -191,7 +191,6 @@ static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
191 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 191 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
192 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 192 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
194 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
195}; 194};
196 195
197static struct usb_device_id ti_id_table_combined[14+2*TI_EXTRA_VID_PID_COUNT+1] = { 196static struct usb_device_id ti_id_table_combined[14+2*TI_EXTRA_VID_PID_COUNT+1] = {
@@ -1658,7 +1657,7 @@ static int ti_do_download(struct usb_device *dev, int pipe,
1658 u8 cs = 0; 1657 u8 cs = 0;
1659 int done; 1658 int done;
1660 struct ti_firmware_header *header; 1659 struct ti_firmware_header *header;
1661 int status; 1660 int status = 0;
1662 int len; 1661 int len;
1663 1662
1664 for (pos = sizeof(struct ti_firmware_header); pos < size; pos++) 1663 for (pos = sizeof(struct ti_firmware_header); pos < size; pos++)
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index d595aa5586a7..bd7581b3a48a 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -21,6 +21,7 @@
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/smp_lock.h>
24#include <linux/tty.h> 25#include <linux/tty.h>
25#include <linux/tty_driver.h> 26#include <linux/tty_driver.h>
26#include <linux/tty_flip.h> 27#include <linux/tty_flip.h>
@@ -220,7 +221,8 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
220 tty->driver_data = port; 221 tty->driver_data = port;
221 tty_port_tty_set(&port->port, tty); 222 tty_port_tty_set(&port->port, tty);
222 223
223 if (port->port.count == 1) { 224 /* If the console is attached, the device is already open */
225 if (port->port.count == 1 && !port->console) {
224 226
225 /* lock this module before we call it 227 /* lock this module before we call it
226 * this may fail, which means we must bail out, 228 * this may fail, which means we must bail out,
@@ -333,6 +335,9 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
333{ 335{
334 struct usb_serial_port *port = tty->driver_data; 336 struct usb_serial_port *port = tty->driver_data;
335 337
338 if (!port)
339 return;
340
336 dbg("%s - port %d", __func__, port->number); 341 dbg("%s - port %d", __func__, port->number);
337 342
338 343
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index d41cc0a970f7..773a5cd38c5a 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -118,6 +118,9 @@ static int option_inquiry(struct us_data *us)
118 118
119 result = memcmp(buffer+8, "Option", 6); 119 result = memcmp(buffer+8, "Option", 6);
120 120
121 if (result != 0)
122 result = memcmp(buffer+8, "ZCOPTION", 8);
123
121 /* Read the CSW */ 124 /* Read the CSW */
122 usb_stor_bulk_transfer_buf(us, 125 usb_stor_bulk_transfer_buf(us,
123 us->recv_bulk_pipe, 126 us->recv_bulk_pipe,
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index d6d65ef85f54..8afcf08eba98 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -616,6 +616,8 @@ config FB_STI
616 select FB_CFB_FILLRECT 616 select FB_CFB_FILLRECT
617 select FB_CFB_COPYAREA 617 select FB_CFB_COPYAREA
618 select FB_CFB_IMAGEBLIT 618 select FB_CFB_IMAGEBLIT
619 select STI_CONSOLE
620 select VT
619 default y 621 default y
620 ---help--- 622 ---help---
621 STI refers to the HP "Standard Text Interface" which is a set of 623 STI refers to the HP "Standard Text Interface" which is a set of
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index fb8163d181ab..a21efcd10b78 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -226,9 +226,10 @@ static int clcdfb_set_par(struct fb_info *info)
226 clcdfb_enable(fb, regs.cntl); 226 clcdfb_enable(fb, regs.cntl);
227 227
228#ifdef DEBUG 228#ifdef DEBUG
229 printk(KERN_INFO "CLCD: Registers set to\n" 229 printk(KERN_INFO
230 KERN_INFO " %08x %08x %08x %08x\n" 230 "CLCD: Registers set to\n"
231 KERN_INFO " %08x %08x %08x %08x\n", 231 " %08x %08x %08x %08x\n"
232 " %08x %08x %08x %08x\n",
232 readl(fb->regs + CLCD_TIM0), readl(fb->regs + CLCD_TIM1), 233 readl(fb->regs + CLCD_TIM0), readl(fb->regs + CLCD_TIM1),
233 readl(fb->regs + CLCD_TIM2), readl(fb->regs + CLCD_TIM3), 234 readl(fb->regs + CLCD_TIM2), readl(fb->regs + CLCD_TIM3),
234 readl(fb->regs + CLCD_UBAS), readl(fb->regs + CLCD_LBAS), 235 readl(fb->regs + CLCD_UBAS), readl(fb->regs + CLCD_LBAS),
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index 018850c116c6..8cd279be74e5 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -2405,6 +2405,9 @@ static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive)
2405 return 0; 2405 return 0;
2406} 2406}
2407 2407
2408/* fbhw->encode_fix() must be called with fb_info->mm_lock held
2409 * if it is called after the register_framebuffer() - not a case here
2410 */
2408static int atafb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info) 2411static int atafb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info)
2409{ 2412{
2410 struct atafb_par par; 2413 struct atafb_par par;
@@ -2414,7 +2417,8 @@ static int atafb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info)
2414 if (err) 2417 if (err)
2415 return err; 2418 return err;
2416 memset(fix, 0, sizeof(struct fb_fix_screeninfo)); 2419 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
2417 return fbhw->encode_fix(fix, &par); 2420 err = fbhw->encode_fix(fix, &par);
2421 return err;
2418} 2422}
2419 2423
2420static int atafb_get_var(struct fb_var_screeninfo *var, struct fb_info *info) 2424static int atafb_get_var(struct fb_var_screeninfo *var, struct fb_info *info)
@@ -2743,7 +2747,9 @@ static int atafb_set_par(struct fb_info *info)
2743 2747
2744 /* Decode wanted screen parameters */ 2748 /* Decode wanted screen parameters */
2745 fbhw->decode_var(&info->var, par); 2749 fbhw->decode_var(&info->var, par);
2750 mutex_lock(&info->mm_lock);
2746 fbhw->encode_fix(&info->fix, par); 2751 fbhw->encode_fix(&info->fix, par);
2752 mutex_unlock(&info->mm_lock);
2747 2753
2748 /* Set new videomode */ 2754 /* Set new videomode */
2749 ata_set_par(par); 2755 ata_set_par(par);
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 5afd64482f55..da05f0801bb7 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -261,6 +261,9 @@ static inline void atmel_lcdfb_free_video_memory(struct atmel_lcdfb_info *sinfo)
261/** 261/**
262 * atmel_lcdfb_alloc_video_memory - Allocate framebuffer memory 262 * atmel_lcdfb_alloc_video_memory - Allocate framebuffer memory
263 * @sinfo: the frame buffer to allocate memory for 263 * @sinfo: the frame buffer to allocate memory for
264 *
265 * This function is called only from the atmel_lcdfb_probe()
266 * so no locking by fb_info->mm_lock around smem_len setting is needed.
264 */ 267 */
265static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo) 268static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo)
266{ 269{
diff --git a/drivers/video/aty/atyfb.h b/drivers/video/aty/atyfb.h
index 7691e73823d3..1f39a62f899b 100644
--- a/drivers/video/aty/atyfb.h
+++ b/drivers/video/aty/atyfb.h
@@ -187,6 +187,8 @@ struct atyfb_par {
187 int mtrr_reg; 187 int mtrr_reg;
188#endif 188#endif
189 u32 mem_cntl; 189 u32 mem_cntl;
190 struct crtc saved_crtc;
191 union aty_pll saved_pll;
190}; 192};
191 193
192 /* 194 /*
@@ -217,6 +219,7 @@ struct atyfb_par {
217#define M64F_XL_DLL 0x00080000 219#define M64F_XL_DLL 0x00080000
218#define M64F_MFB_FORCE_4 0x00100000 220#define M64F_MFB_FORCE_4 0x00100000
219#define M64F_HW_TRIPLE 0x00200000 221#define M64F_HW_TRIPLE 0x00200000
222#define M64F_XL_MEM 0x00400000
220 /* 223 /*
221 * Register access 224 * Register access
222 */ 225 */
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 1207c208a30b..63d3739d43a8 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -66,6 +66,8 @@
66#include <linux/spinlock.h> 66#include <linux/spinlock.h>
67#include <linux/wait.h> 67#include <linux/wait.h>
68#include <linux/backlight.h> 68#include <linux/backlight.h>
69#include <linux/reboot.h>
70#include <linux/dmi.h>
69 71
70#include <asm/io.h> 72#include <asm/io.h>
71#include <linux/uaccess.h> 73#include <linux/uaccess.h>
@@ -249,8 +251,6 @@ static int aty_init(struct fb_info *info);
249static int store_video_par(char *videopar, unsigned char m64_num); 251static int store_video_par(char *videopar, unsigned char m64_num);
250#endif 252#endif
251 253
252static struct crtc saved_crtc;
253static union aty_pll saved_pll;
254static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc); 254static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc);
255 255
256static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc); 256static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc);
@@ -261,6 +261,8 @@ static void set_off_pitch(struct atyfb_par *par, const struct fb_info *info);
261static int read_aty_sense(const struct atyfb_par *par); 261static int read_aty_sense(const struct atyfb_par *par);
262#endif 262#endif
263 263
264static DEFINE_MUTEX(reboot_lock);
265static struct fb_info *reboot_info;
264 266
265 /* 267 /*
266 * Interface used by the world 268 * Interface used by the world
@@ -361,8 +363,8 @@ static unsigned long phys_guiregbase[FB_MAX] __devinitdata = { 0, };
361#define ATI_CHIP_264GTPRO (ATI_MODERN_SET | M64F_SDRAM_MAGIC_PLL | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D) 363#define ATI_CHIP_264GTPRO (ATI_MODERN_SET | M64F_SDRAM_MAGIC_PLL | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D)
362#define ATI_CHIP_264LTPRO (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D) 364#define ATI_CHIP_264LTPRO (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D)
363 365
364#define ATI_CHIP_264XL (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D | M64F_XL_DLL | M64F_MFB_FORCE_4) 366#define ATI_CHIP_264XL (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D | M64F_XL_DLL | M64F_MFB_FORCE_4 | M64F_XL_MEM)
365#define ATI_CHIP_MOBILITY (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D | M64F_XL_DLL | M64F_MFB_FORCE_4 | M64F_MOBIL_BUS) 367#define ATI_CHIP_MOBILITY (ATI_MODERN_SET | M64F_HW_TRIPLE | M64F_FIFO_32 | M64F_RESET_3D | M64F_XL_DLL | M64F_MFB_FORCE_4 | M64F_XL_MEM | M64F_MOBIL_BUS)
366 368
367static struct { 369static struct {
368 u16 pci_id; 370 u16 pci_id;
@@ -539,6 +541,7 @@ static char ram_edo[] __devinitdata = "EDO";
539static char ram_sdram[] __devinitdata = "SDRAM (1:1)"; 541static char ram_sdram[] __devinitdata = "SDRAM (1:1)";
540static char ram_sgram[] __devinitdata = "SGRAM (1:1)"; 542static char ram_sgram[] __devinitdata = "SGRAM (1:1)";
541static char ram_sdram32[] __devinitdata = "SDRAM (2:1) (32-bit)"; 543static char ram_sdram32[] __devinitdata = "SDRAM (2:1) (32-bit)";
544static char ram_wram[] __devinitdata = "WRAM";
542static char ram_off[] __devinitdata = "OFF"; 545static char ram_off[] __devinitdata = "OFF";
543#endif /* CONFIG_FB_ATY_CT */ 546#endif /* CONFIG_FB_ATY_CT */
544 547
@@ -553,6 +556,10 @@ static char *aty_gx_ram[8] __devinitdata = {
553#ifdef CONFIG_FB_ATY_CT 556#ifdef CONFIG_FB_ATY_CT
554static char *aty_ct_ram[8] __devinitdata = { 557static char *aty_ct_ram[8] __devinitdata = {
555 ram_off, ram_dram, ram_edo, ram_edo, 558 ram_off, ram_dram, ram_edo, ram_edo,
559 ram_sdram, ram_sgram, ram_wram, ram_resv
560};
561static char *aty_xl_ram[8] __devinitdata = {
562 ram_off, ram_dram, ram_edo, ram_edo,
556 ram_sdram, ram_sgram, ram_sdram32, ram_resv 563 ram_sdram, ram_sgram, ram_sdram32, ram_resv
557}; 564};
558#endif /* CONFIG_FB_ATY_CT */ 565#endif /* CONFIG_FB_ATY_CT */
@@ -760,6 +767,17 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc)
760#endif /* CONFIG_FB_ATY_GENERIC_LCD */ 767#endif /* CONFIG_FB_ATY_GENERIC_LCD */
761} 768}
762 769
770static u32 calc_line_length(struct atyfb_par *par, u32 vxres, u32 bpp)
771{
772 u32 line_length = vxres * bpp / 8;
773
774 if (par->ram_type == SGRAM ||
775 (!M64_HAS(XL_MEM) && par->ram_type == WRAM))
776 line_length = (line_length + 63) & ~63;
777
778 return line_length;
779}
780
763static int aty_var_to_crtc(const struct fb_info *info, 781static int aty_var_to_crtc(const struct fb_info *info,
764 const struct fb_var_screeninfo *var, struct crtc *crtc) 782 const struct fb_var_screeninfo *var, struct crtc *crtc)
765{ 783{
@@ -769,13 +787,14 @@ static int aty_var_to_crtc(const struct fb_info *info,
769 u32 h_total, h_disp, h_sync_strt, h_sync_end, h_sync_dly, h_sync_wid, h_sync_pol; 787 u32 h_total, h_disp, h_sync_strt, h_sync_end, h_sync_dly, h_sync_wid, h_sync_pol;
770 u32 v_total, v_disp, v_sync_strt, v_sync_end, v_sync_wid, v_sync_pol, c_sync; 788 u32 v_total, v_disp, v_sync_strt, v_sync_end, v_sync_wid, v_sync_pol, c_sync;
771 u32 pix_width, dp_pix_width, dp_chain_mask; 789 u32 pix_width, dp_pix_width, dp_chain_mask;
790 u32 line_length;
772 791
773 /* input */ 792 /* input */
774 xres = var->xres; 793 xres = (var->xres + 7) & ~7;
775 yres = var->yres; 794 yres = var->yres;
776 vxres = var->xres_virtual; 795 vxres = (var->xres_virtual + 7) & ~7;
777 vyres = var->yres_virtual; 796 vyres = var->yres_virtual;
778 xoffset = var->xoffset; 797 xoffset = (var->xoffset + 7) & ~7;
779 yoffset = var->yoffset; 798 yoffset = var->yoffset;
780 bpp = var->bits_per_pixel; 799 bpp = var->bits_per_pixel;
781 if (bpp == 16) 800 if (bpp == 16)
@@ -827,7 +846,9 @@ static int aty_var_to_crtc(const struct fb_info *info,
827 } else 846 } else
828 FAIL("invalid bpp"); 847 FAIL("invalid bpp");
829 848
830 if (vxres * vyres * bpp / 8 > info->fix.smem_len) 849 line_length = calc_line_length(par, vxres, bpp);
850
851 if (vyres * line_length > info->fix.smem_len)
831 FAIL("not enough video RAM"); 852 FAIL("not enough video RAM");
832 853
833 h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1; 854 h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
@@ -969,7 +990,9 @@ static int aty_var_to_crtc(const struct fb_info *info,
969 crtc->xoffset = xoffset; 990 crtc->xoffset = xoffset;
970 crtc->yoffset = yoffset; 991 crtc->yoffset = yoffset;
971 crtc->bpp = bpp; 992 crtc->bpp = bpp;
972 crtc->off_pitch = ((yoffset*vxres+xoffset)*bpp/64) | (vxres<<19); 993 crtc->off_pitch =
994 ((yoffset * line_length + xoffset * bpp / 8) / 8) |
995 ((line_length / bpp) << 22);
973 crtc->vline_crnt_vline = 0; 996 crtc->vline_crnt_vline = 0;
974 997
975 crtc->h_tot_disp = h_total | (h_disp<<16); 998 crtc->h_tot_disp = h_total | (h_disp<<16);
@@ -1394,7 +1417,9 @@ static int atyfb_set_par(struct fb_info *info)
1394 } 1417 }
1395 aty_st_8(DAC_MASK, 0xff, par); 1418 aty_st_8(DAC_MASK, 0xff, par);
1396 1419
1397 info->fix.line_length = var->xres_virtual * var->bits_per_pixel/8; 1420 info->fix.line_length = calc_line_length(par, var->xres_virtual,
1421 var->bits_per_pixel);
1422
1398 info->fix.visual = var->bits_per_pixel <= 8 ? 1423 info->fix.visual = var->bits_per_pixel <= 8 ?
1399 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; 1424 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
1400 1425
@@ -1505,10 +1530,12 @@ static void set_off_pitch(struct atyfb_par *par, const struct fb_info *info)
1505{ 1530{
1506 u32 xoffset = info->var.xoffset; 1531 u32 xoffset = info->var.xoffset;
1507 u32 yoffset = info->var.yoffset; 1532 u32 yoffset = info->var.yoffset;
1508 u32 vxres = par->crtc.vxres; 1533 u32 line_length = info->fix.line_length;
1509 u32 bpp = info->var.bits_per_pixel; 1534 u32 bpp = info->var.bits_per_pixel;
1510 1535
1511 par->crtc.off_pitch = ((yoffset * vxres + xoffset) * bpp / 64) | (vxres << 19); 1536 par->crtc.off_pitch =
1537 ((yoffset * line_length + xoffset * bpp / 8) / 8) |
1538 ((line_length / bpp) << 22);
1512} 1539}
1513 1540
1514 1541
@@ -2201,7 +2228,7 @@ static void __devinit aty_calc_mem_refresh(struct atyfb_par *par, int xclk)
2201 const int *refresh_tbl; 2228 const int *refresh_tbl;
2202 int i, size; 2229 int i, size;
2203 2230
2204 if (IS_XL(par->pci_id) || IS_MOBILITY(par->pci_id)) { 2231 if (M64_HAS(XL_MEM)) {
2205 refresh_tbl = ragexl_tbl; 2232 refresh_tbl = ragexl_tbl;
2206 size = ARRAY_SIZE(ragexl_tbl); 2233 size = ARRAY_SIZE(ragexl_tbl);
2207 } else { 2234 } else {
@@ -2335,7 +2362,10 @@ static int __devinit aty_init(struct fb_info *info)
2335 par->pll_ops = &aty_pll_ct; 2362 par->pll_ops = &aty_pll_ct;
2336 par->bus_type = PCI; 2363 par->bus_type = PCI;
2337 par->ram_type = (aty_ld_le32(CNFG_STAT0, par) & 0x07); 2364 par->ram_type = (aty_ld_le32(CNFG_STAT0, par) & 0x07);
2338 ramname = aty_ct_ram[par->ram_type]; 2365 if (M64_HAS(XL_MEM))
2366 ramname = aty_xl_ram[par->ram_type];
2367 else
2368 ramname = aty_ct_ram[par->ram_type];
2339 /* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz otherwise */ 2369 /* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz otherwise */
2340 if (par->pll_limits.mclk == 67 && par->ram_type < SDRAM) 2370 if (par->pll_limits.mclk == 67 && par->ram_type < SDRAM)
2341 par->pll_limits.mclk = 63; 2371 par->pll_limits.mclk = 63;
@@ -2390,9 +2420,9 @@ static int __devinit aty_init(struct fb_info *info)
2390#endif /* CONFIG_FB_ATY_CT */ 2420#endif /* CONFIG_FB_ATY_CT */
2391 2421
2392 /* save previous video mode */ 2422 /* save previous video mode */
2393 aty_get_crtc(par, &saved_crtc); 2423 aty_get_crtc(par, &par->saved_crtc);
2394 if(par->pll_ops->get_pll) 2424 if(par->pll_ops->get_pll)
2395 par->pll_ops->get_pll(info, &saved_pll); 2425 par->pll_ops->get_pll(info, &par->saved_pll);
2396 2426
2397 par->mem_cntl = aty_ld_le32(MEM_CNTL, par); 2427 par->mem_cntl = aty_ld_le32(MEM_CNTL, par);
2398 gtb_memsize = M64_HAS(GTB_DSP); 2428 gtb_memsize = M64_HAS(GTB_DSP);
@@ -2667,8 +2697,8 @@ static int __devinit aty_init(struct fb_info *info)
2667 2697
2668aty_init_exit: 2698aty_init_exit:
2669 /* restore video mode */ 2699 /* restore video mode */
2670 aty_set_crtc(par, &saved_crtc); 2700 aty_set_crtc(par, &par->saved_crtc);
2671 par->pll_ops->set_pll(info, &saved_pll); 2701 par->pll_ops->set_pll(info, &par->saved_pll);
2672 2702
2673#ifdef CONFIG_MTRR 2703#ifdef CONFIG_MTRR
2674 if (par->mtrr_reg >= 0) { 2704 if (par->mtrr_reg >= 0) {
@@ -3502,6 +3532,11 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi
3502 par->mmap_map[1].prot_flag = _PAGE_E; 3532 par->mmap_map[1].prot_flag = _PAGE_E;
3503#endif /* __sparc__ */ 3533#endif /* __sparc__ */
3504 3534
3535 mutex_lock(&reboot_lock);
3536 if (!reboot_info)
3537 reboot_info = info;
3538 mutex_unlock(&reboot_lock);
3539
3505 return 0; 3540 return 0;
3506 3541
3507err_release_io: 3542err_release_io:
@@ -3614,8 +3649,8 @@ static void __devexit atyfb_remove(struct fb_info *info)
3614 struct atyfb_par *par = (struct atyfb_par *) info->par; 3649 struct atyfb_par *par = (struct atyfb_par *) info->par;
3615 3650
3616 /* restore video mode */ 3651 /* restore video mode */
3617 aty_set_crtc(par, &saved_crtc); 3652 aty_set_crtc(par, &par->saved_crtc);
3618 par->pll_ops->set_pll(info, &saved_pll); 3653 par->pll_ops->set_pll(info, &par->saved_pll);
3619 3654
3620 unregister_framebuffer(info); 3655 unregister_framebuffer(info);
3621 3656
@@ -3661,6 +3696,11 @@ static void __devexit atyfb_pci_remove(struct pci_dev *pdev)
3661{ 3696{
3662 struct fb_info *info = pci_get_drvdata(pdev); 3697 struct fb_info *info = pci_get_drvdata(pdev);
3663 3698
3699 mutex_lock(&reboot_lock);
3700 if (reboot_info == info)
3701 reboot_info = NULL;
3702 mutex_unlock(&reboot_lock);
3703
3664 atyfb_remove(info); 3704 atyfb_remove(info);
3665} 3705}
3666 3706
@@ -3808,6 +3848,56 @@ static int __init atyfb_setup(char *options)
3808} 3848}
3809#endif /* MODULE */ 3849#endif /* MODULE */
3810 3850
3851static int atyfb_reboot_notify(struct notifier_block *nb,
3852 unsigned long code, void *unused)
3853{
3854 struct atyfb_par *par;
3855
3856 if (code != SYS_RESTART)
3857 return NOTIFY_DONE;
3858
3859 mutex_lock(&reboot_lock);
3860
3861 if (!reboot_info)
3862 goto out;
3863
3864 if (!lock_fb_info(reboot_info))
3865 goto out;
3866
3867 par = reboot_info->par;
3868
3869 /*
3870 * HP OmniBook 500's BIOS doesn't like the state of the
3871 * hardware after atyfb has been used. Restore the hardware
3872 * to the original state to allow successful reboots.
3873 */
3874 aty_set_crtc(par, &par->saved_crtc);
3875 par->pll_ops->set_pll(reboot_info, &par->saved_pll);
3876
3877 unlock_fb_info(reboot_info);
3878 out:
3879 mutex_unlock(&reboot_lock);
3880
3881 return NOTIFY_DONE;
3882}
3883
3884static struct notifier_block atyfb_reboot_notifier = {
3885 .notifier_call = atyfb_reboot_notify,
3886};
3887
3888static const struct dmi_system_id atyfb_reboot_ids[] = {
3889 {
3890 .ident = "HP OmniBook 500",
3891 .matches = {
3892 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
3893 DMI_MATCH(DMI_PRODUCT_NAME, "HP OmniBook PC"),
3894 DMI_MATCH(DMI_PRODUCT_VERSION, "HP OmniBook 500 FA"),
3895 },
3896 },
3897
3898 { }
3899};
3900
3811static int __init atyfb_init(void) 3901static int __init atyfb_init(void)
3812{ 3902{
3813 int err1 = 1, err2 = 1; 3903 int err1 = 1, err2 = 1;
@@ -3826,11 +3916,20 @@ static int __init atyfb_init(void)
3826 err2 = atyfb_atari_probe(); 3916 err2 = atyfb_atari_probe();
3827#endif 3917#endif
3828 3918
3829 return (err1 && err2) ? -ENODEV : 0; 3919 if (err1 && err2)
3920 return -ENODEV;
3921
3922 if (dmi_check_system(atyfb_reboot_ids))
3923 register_reboot_notifier(&atyfb_reboot_notifier);
3924
3925 return 0;
3830} 3926}
3831 3927
3832static void __exit atyfb_exit(void) 3928static void __exit atyfb_exit(void)
3833{ 3929{
3930 if (dmi_check_system(atyfb_reboot_ids))
3931 unregister_reboot_notifier(&atyfb_reboot_notifier);
3932
3834#ifdef CONFIG_PCI 3933#ifdef CONFIG_PCI
3835 pci_unregister_driver(&atyfb_driver); 3934 pci_unregister_driver(&atyfb_driver);
3836#endif 3935#endif
diff --git a/drivers/video/aty/mach64_accel.c b/drivers/video/aty/mach64_accel.c
index 0cc9724e61a2..51fcc0a2c94a 100644
--- a/drivers/video/aty/mach64_accel.c
+++ b/drivers/video/aty/mach64_accel.c
@@ -63,14 +63,17 @@ static void reset_GTC_3D_engine(const struct atyfb_par *par)
63void aty_init_engine(struct atyfb_par *par, struct fb_info *info) 63void aty_init_engine(struct atyfb_par *par, struct fb_info *info)
64{ 64{
65 u32 pitch_value; 65 u32 pitch_value;
66 u32 vxres;
66 67
67 /* determine modal information from global mode structure */ 68 /* determine modal information from global mode structure */
68 pitch_value = info->var.xres_virtual; 69 pitch_value = info->fix.line_length / (info->var.bits_per_pixel / 8);
70 vxres = info->var.xres_virtual;
69 71
70 if (info->var.bits_per_pixel == 24) { 72 if (info->var.bits_per_pixel == 24) {
71 /* In 24 bpp, the engine is in 8 bpp - this requires that all */ 73 /* In 24 bpp, the engine is in 8 bpp - this requires that all */
72 /* horizontal coordinates and widths must be adjusted */ 74 /* horizontal coordinates and widths must be adjusted */
73 pitch_value *= 3; 75 pitch_value *= 3;
76 vxres *= 3;
74 } 77 }
75 78
76 /* On GTC (RagePro), we need to reset the 3D engine before */ 79 /* On GTC (RagePro), we need to reset the 3D engine before */
@@ -133,7 +136,7 @@ void aty_init_engine(struct atyfb_par *par, struct fb_info *info)
133 aty_st_le32(SC_LEFT, 0, par); 136 aty_st_le32(SC_LEFT, 0, par);
134 aty_st_le32(SC_TOP, 0, par); 137 aty_st_le32(SC_TOP, 0, par);
135 aty_st_le32(SC_BOTTOM, par->crtc.vyres - 1, par); 138 aty_st_le32(SC_BOTTOM, par->crtc.vyres - 1, par);
136 aty_st_le32(SC_RIGHT, pitch_value - 1, par); 139 aty_st_le32(SC_RIGHT, vxres - 1, par);
137 140
138 /* set background color to minimum value (usually BLACK) */ 141 /* set background color to minimum value (usually BLACK) */
139 aty_st_le32(DP_BKGD_CLR, 0, par); 142 aty_st_le32(DP_BKGD_CLR, 0, par);
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c
index 1dae7f8f3c6b..51422fc4f606 100644
--- a/drivers/video/backlight/tdo24m.c
+++ b/drivers/video/backlight/tdo24m.c
@@ -356,7 +356,7 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
356 lcd->power = FB_BLANK_POWERDOWN; 356 lcd->power = FB_BLANK_POWERDOWN;
357 lcd->mode = MODE_VGA; /* default to VGA */ 357 lcd->mode = MODE_VGA; /* default to VGA */
358 358
359 lcd->buf = kmalloc(TDO24M_SPI_BUFF_SIZE, sizeof(GFP_KERNEL)); 359 lcd->buf = kmalloc(TDO24M_SPI_BUFF_SIZE, GFP_KERNEL);
360 if (lcd->buf == NULL) { 360 if (lcd->buf == NULL) {
361 kfree(lcd); 361 kfree(lcd);
362 return -ENOMEM; 362 return -ENOMEM;
diff --git a/drivers/video/cobalt_lcdfb.c b/drivers/video/cobalt_lcdfb.c
index 7bad24ed04ef..108b89e09a80 100644
--- a/drivers/video/cobalt_lcdfb.c
+++ b/drivers/video/cobalt_lcdfb.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cobalt server LCD frame buffer driver. 2 * Cobalt server LCD frame buffer driver.
3 * 3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index f8a09bf8d0cd..a85c818be945 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -16,7 +16,6 @@
16#include <linux/compat.h> 16#include <linux/compat.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/smp_lock.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/major.h> 20#include <linux/major.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
@@ -1310,8 +1309,6 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd,
1310 1309
1311static int 1310static int
1312fb_mmap(struct file *file, struct vm_area_struct * vma) 1311fb_mmap(struct file *file, struct vm_area_struct * vma)
1313__acquires(&info->lock)
1314__releases(&info->lock)
1315{ 1312{
1316 int fbidx = iminor(file->f_path.dentry->d_inode); 1313 int fbidx = iminor(file->f_path.dentry->d_inode);
1317 struct fb_info *info = registered_fb[fbidx]; 1314 struct fb_info *info = registered_fb[fbidx];
@@ -1325,16 +1322,14 @@ __releases(&info->lock)
1325 off = vma->vm_pgoff << PAGE_SHIFT; 1322 off = vma->vm_pgoff << PAGE_SHIFT;
1326 if (!fb) 1323 if (!fb)
1327 return -ENODEV; 1324 return -ENODEV;
1325 mutex_lock(&info->mm_lock);
1328 if (fb->fb_mmap) { 1326 if (fb->fb_mmap) {
1329 int res; 1327 int res;
1330 mutex_lock(&info->lock);
1331 res = fb->fb_mmap(info, vma); 1328 res = fb->fb_mmap(info, vma);
1332 mutex_unlock(&info->lock); 1329 mutex_unlock(&info->mm_lock);
1333 return res; 1330 return res;
1334 } 1331 }
1335 1332
1336 mutex_lock(&info->lock);
1337
1338 /* frame buffer memory */ 1333 /* frame buffer memory */
1339 start = info->fix.smem_start; 1334 start = info->fix.smem_start;
1340 len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len); 1335 len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len);
@@ -1342,13 +1337,13 @@ __releases(&info->lock)
1342 /* memory mapped io */ 1337 /* memory mapped io */
1343 off -= len; 1338 off -= len;
1344 if (info->var.accel_flags) { 1339 if (info->var.accel_flags) {
1345 mutex_unlock(&info->lock); 1340 mutex_unlock(&info->mm_lock);
1346 return -EINVAL; 1341 return -EINVAL;
1347 } 1342 }
1348 start = info->fix.mmio_start; 1343 start = info->fix.mmio_start;
1349 len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len); 1344 len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len);
1350 } 1345 }
1351 mutex_unlock(&info->lock); 1346 mutex_unlock(&info->mm_lock);
1352 start &= PAGE_MASK; 1347 start &= PAGE_MASK;
1353 if ((vma->vm_end - vma->vm_start + off) > len) 1348 if ((vma->vm_end - vma->vm_start + off) > len)
1354 return -EINVAL; 1349 return -EINVAL;
@@ -1518,6 +1513,7 @@ register_framebuffer(struct fb_info *fb_info)
1518 break; 1513 break;
1519 fb_info->node = i; 1514 fb_info->node = i;
1520 mutex_init(&fb_info->lock); 1515 mutex_init(&fb_info->lock);
1516 mutex_init(&fb_info->mm_lock);
1521 1517
1522 fb_info->dev = device_create(fb_class, fb_info->device, 1518 fb_info->dev = device_create(fb_class, fb_info->device,
1523 MKDEV(FB_MAJOR, i), NULL, "fb%d", i); 1519 MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index f153c581cbd7..72d68b3dc478 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -750,24 +750,26 @@ static void update_lcdc(struct fb_info *info)
750static int map_video_memory(struct fb_info *info) 750static int map_video_memory(struct fb_info *info)
751{ 751{
752 phys_addr_t phys; 752 phys_addr_t phys;
753 u32 smem_len = info->fix.line_length * info->var.yres_virtual;
753 754
754 pr_debug("info->var.xres_virtual = %d\n", info->var.xres_virtual); 755 pr_debug("info->var.xres_virtual = %d\n", info->var.xres_virtual);
755 pr_debug("info->var.yres_virtual = %d\n", info->var.yres_virtual); 756 pr_debug("info->var.yres_virtual = %d\n", info->var.yres_virtual);
756 pr_debug("info->fix.line_length = %d\n", info->fix.line_length); 757 pr_debug("info->fix.line_length = %d\n", info->fix.line_length);
758 pr_debug("MAP_VIDEO_MEMORY: smem_len = %u\n", smem_len);
757 759
758 info->fix.smem_len = info->fix.line_length * info->var.yres_virtual; 760 info->screen_base = fsl_diu_alloc(smem_len, &phys);
759 pr_debug("MAP_VIDEO_MEMORY: smem_len = %d\n", info->fix.smem_len);
760 info->screen_base = fsl_diu_alloc(info->fix.smem_len, &phys);
761 if (info->screen_base == NULL) { 761 if (info->screen_base == NULL) {
762 printk(KERN_ERR "Unable to allocate fb memory\n"); 762 printk(KERN_ERR "Unable to allocate fb memory\n");
763 return -ENOMEM; 763 return -ENOMEM;
764 } 764 }
765 mutex_lock(&info->mm_lock);
765 info->fix.smem_start = (unsigned long) phys; 766 info->fix.smem_start = (unsigned long) phys;
767 info->fix.smem_len = smem_len;
768 mutex_unlock(&info->mm_lock);
766 info->screen_size = info->fix.smem_len; 769 info->screen_size = info->fix.smem_len;
767 770
768 pr_debug("Allocated fb @ paddr=0x%08lx, size=%d.\n", 771 pr_debug("Allocated fb @ paddr=0x%08lx, size=%d.\n",
769 info->fix.smem_start, 772 info->fix.smem_start, info->fix.smem_len);
770 info->fix.smem_len);
771 pr_debug("screen base %p\n", info->screen_base); 773 pr_debug("screen base %p\n", info->screen_base);
772 774
773 return 0; 775 return 0;
@@ -776,9 +778,11 @@ static int map_video_memory(struct fb_info *info)
776static void unmap_video_memory(struct fb_info *info) 778static void unmap_video_memory(struct fb_info *info)
777{ 779{
778 fsl_diu_free(info->screen_base, info->fix.smem_len); 780 fsl_diu_free(info->screen_base, info->fix.smem_len);
781 mutex_lock(&info->mm_lock);
779 info->screen_base = NULL; 782 info->screen_base = NULL;
780 info->fix.smem_start = 0; 783 info->fix.smem_start = 0;
781 info->fix.smem_len = 0; 784 info->fix.smem_len = 0;
785 mutex_unlock(&info->mm_lock);
782} 786}
783 787
784/* 788/*
@@ -1219,12 +1223,6 @@ static int __devinit install_fb(struct fb_info *info)
1219 return -EINVAL; 1223 return -EINVAL;
1220 } 1224 }
1221 1225
1222 if (fsl_diu_set_par(info)) {
1223 printk(KERN_ERR "fb_set_par failed");
1224 fb_dealloc_cmap(&info->cmap);
1225 return -EINVAL;
1226 }
1227
1228 if (register_framebuffer(info) < 0) { 1226 if (register_framebuffer(info) < 0) {
1229 printk(KERN_ERR "register_framebuffer failed"); 1227 printk(KERN_ERR "register_framebuffer failed");
1230 unmap_video_memory(info); 1228 unmap_video_memory(info);
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 020db7fc9153..e7116a6d82d3 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -44,9 +44,6 @@ static struct fb_fix_screeninfo hitfb_fix __initdata = {
44 .accel = FB_ACCEL_NONE, 44 .accel = FB_ACCEL_NONE,
45}; 45};
46 46
47static u32 pseudo_palette[16];
48static struct fb_info fb_info;
49
50static inline void hitfb_accel_wait(void) 47static inline void hitfb_accel_wait(void)
51{ 48{
52 while (fb_readw(HD64461_GRCFGR) & HD64461_GRCFGR_ACCSTATUS) ; 49 while (fb_readw(HD64461_GRCFGR) & HD64461_GRCFGR_ACCSTATUS) ;
@@ -331,6 +328,8 @@ static struct fb_ops hitfb_ops = {
331static int __init hitfb_probe(struct platform_device *dev) 328static int __init hitfb_probe(struct platform_device *dev)
332{ 329{
333 unsigned short lcdclor, ldr3, ldvndr; 330 unsigned short lcdclor, ldr3, ldvndr;
331 struct fb_info *info;
332 int ret;
334 333
335 if (fb_get_options("hitfb", NULL)) 334 if (fb_get_options("hitfb", NULL))
336 return -ENODEV; 335 return -ENODEV;
@@ -384,32 +383,53 @@ static int __init hitfb_probe(struct platform_device *dev)
384 break; 383 break;
385 } 384 }
386 385
387 fb_info.fbops = &hitfb_ops; 386 info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
388 fb_info.var = hitfb_var; 387 if (unlikely(!info))
389 fb_info.fix = hitfb_fix; 388 return -ENOMEM;
390 fb_info.pseudo_palette = pseudo_palette; 389
391 fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN | 390 info->fbops = &hitfb_ops;
391 info->var = hitfb_var;
392 info->fix = hitfb_fix;
393 info->pseudo_palette = info->par;
394 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
392 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA; 395 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
393 396
394 fb_info.screen_base = (void *)hitfb_fix.smem_start; 397 info->screen_base = (void *)hitfb_fix.smem_start;
395 398
396 fb_alloc_cmap(&fb_info.cmap, 256, 0); 399 ret = fb_alloc_cmap(&info->cmap, 256, 0);
400 if (unlikely(ret < 0))
401 goto err_fb;
397 402
398 if (register_framebuffer(&fb_info) < 0) 403 ret = register_framebuffer(info);
399 return -EINVAL; 404 if (unlikely(ret < 0))
405 goto err;
406
407 platform_set_drvdata(dev, info);
400 408
401 printk(KERN_INFO "fb%d: %s frame buffer device\n", 409 printk(KERN_INFO "fb%d: %s frame buffer device\n",
402 fb_info.node, fb_info.fix.id); 410 info->node, info->fix.id);
411
403 return 0; 412 return 0;
413
414err:
415 fb_dealloc_cmap(&info->cmap);
416err_fb:
417 framebuffer_release(info);
418 return ret;
404} 419}
405 420
406static int __exit hitfb_remove(struct platform_device *dev) 421static int __exit hitfb_remove(struct platform_device *dev)
407{ 422{
408 return unregister_framebuffer(&fb_info); 423 struct fb_info *info = platform_get_drvdata(dev);
424
425 unregister_framebuffer(info);
426 fb_dealloc_cmap(&info->cmap);
427 framebuffer_release(info);
428
429 return 0;
409} 430}
410 431
411#ifdef CONFIG_PM 432static int hitfb_suspend(struct device *dev)
412static int hitfb_suspend(struct platform_device *dev, pm_message_t state)
413{ 433{
414 u16 v; 434 u16 v;
415 435
@@ -421,7 +441,7 @@ static int hitfb_suspend(struct platform_device *dev, pm_message_t state)
421 return 0; 441 return 0;
422} 442}
423 443
424static int hitfb_resume(struct platform_device *dev) 444static int hitfb_resume(struct device *dev)
425{ 445{
426 u16 v; 446 u16 v;
427 447
@@ -435,17 +455,19 @@ static int hitfb_resume(struct platform_device *dev)
435 455
436 return 0; 456 return 0;
437} 457}
438#endif 458
459static struct dev_pm_ops hitfb_dev_pm_ops = {
460 .suspend = hitfb_suspend,
461 .resume = hitfb_resume,
462};
439 463
440static struct platform_driver hitfb_driver = { 464static struct platform_driver hitfb_driver = {
441 .probe = hitfb_probe, 465 .probe = hitfb_probe,
442 .remove = __exit_p(hitfb_remove), 466 .remove = __exit_p(hitfb_remove),
443#ifdef CONFIG_PM
444 .suspend = hitfb_suspend,
445 .resume = hitfb_resume,
446#endif
447 .driver = { 467 .driver = {
448 .name = "hitfb", 468 .name = "hitfb",
469 .owner = THIS_MODULE,
470 .pm = &hitfb_dev_pm_ops,
449 }, 471 },
450}; 472};
451 473
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 2e940199fc89..5743ea25e818 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1090,8 +1090,10 @@ static int encode_fix(struct fb_fix_screeninfo *fix, struct fb_info *info)
1090 memset(fix, 0, sizeof(struct fb_fix_screeninfo)); 1090 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
1091 1091
1092 strcpy(fix->id, "I810"); 1092 strcpy(fix->id, "I810");
1093 mutex_lock(&info->mm_lock);
1093 fix->smem_start = par->fb.physical; 1094 fix->smem_start = par->fb.physical;
1094 fix->smem_len = par->fb.size; 1095 fix->smem_len = par->fb.size;
1096 mutex_unlock(&info->mm_lock);
1095 fix->type = FB_TYPE_PACKED_PIXELS; 1097 fix->type = FB_TYPE_PACKED_PIXELS;
1096 fix->type_aux = 0; 1098 fix->type_aux = 0;
1097 fix->xpanstep = 8; 1099 fix->xpanstep = 8;
@@ -2058,8 +2060,7 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev,
2058 2060
2059 fb_var_to_videomode(&mode, &info->var); 2061 fb_var_to_videomode(&mode, &info->var);
2060 fb_add_videomode(&mode, &info->modelist); 2062 fb_add_videomode(&mode, &info->modelist);
2061 encode_fix(&info->fix, info); 2063
2062
2063 i810fb_init_ringbuffer(info); 2064 i810fb_init_ringbuffer(info);
2064 err = register_framebuffer(info); 2065 err = register_framebuffer(info);
2065 2066
diff --git a/drivers/video/matrox/matroxfb_DAC1064.c b/drivers/video/matrox/matroxfb_DAC1064.c
index 0ce3b0a89798..a74e5da17aa0 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.c
+++ b/drivers/video/matrox/matroxfb_DAC1064.c
@@ -454,9 +454,9 @@ static void DAC1064_restore_2(WPMINFO2) {
454 dprintk(KERN_DEBUG "DAC1064regs "); 454 dprintk(KERN_DEBUG "DAC1064regs ");
455 for (i = 0; i < sizeof(MGA1064_DAC_regs); i++) { 455 for (i = 0; i < sizeof(MGA1064_DAC_regs); i++) {
456 dprintk("R%02X=%02X ", MGA1064_DAC_regs[i], ACCESS_FBINFO(hw).DACreg[i]); 456 dprintk("R%02X=%02X ", MGA1064_DAC_regs[i], ACCESS_FBINFO(hw).DACreg[i]);
457 if ((i & 0x7) == 0x7) dprintk("\n" KERN_DEBUG "continuing... "); 457 if ((i & 0x7) == 0x7) dprintk(KERN_DEBUG "continuing... ");
458 } 458 }
459 dprintk("\n" KERN_DEBUG "DAC1064clk "); 459 dprintk(KERN_DEBUG "DAC1064clk ");
460 for (i = 0; i < 6; i++) 460 for (i = 0; i < 6; i++)
461 dprintk("C%02X=%02X ", i, ACCESS_FBINFO(hw).DACclk[i]); 461 dprintk("C%02X=%02X ", i, ACCESS_FBINFO(hw).DACclk[i]);
462 dprintk("\n"); 462 dprintk("\n");
diff --git a/drivers/video/matrox/matroxfb_Ti3026.c b/drivers/video/matrox/matroxfb_Ti3026.c
index 13524821e242..4e825112a601 100644
--- a/drivers/video/matrox/matroxfb_Ti3026.c
+++ b/drivers/video/matrox/matroxfb_Ti3026.c
@@ -651,9 +651,9 @@ static void Ti3026_restore(WPMINFO2) {
651 dprintk(KERN_DEBUG "3026DACregs "); 651 dprintk(KERN_DEBUG "3026DACregs ");
652 for (i = 0; i < 21; i++) { 652 for (i = 0; i < 21; i++) {
653 dprintk("R%02X=%02X ", DACseq[i], hw->DACreg[i]); 653 dprintk("R%02X=%02X ", DACseq[i], hw->DACreg[i]);
654 if ((i & 0x7) == 0x7) dprintk("\n" KERN_DEBUG "continuing... "); 654 if ((i & 0x7) == 0x7) dprintk(KERN_DEBUG "continuing... ");
655 } 655 }
656 dprintk("\n" KERN_DEBUG "DACclk "); 656 dprintk(KERN_DEBUG "DACclk ");
657 for (i = 0; i < 6; i++) 657 for (i = 0; i < 6; i++)
658 dprintk("C%02X=%02X ", i, hw->DACclk[i]); 658 dprintk("C%02X=%02X ", i, hw->DACclk[i]);
659 dprintk("\n"); 659 dprintk("\n");
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 8e7a275df50c..0c1049b308bf 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -724,8 +724,10 @@ static void matroxfb_update_fix(WPMINFO2)
724 struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix; 724 struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix;
725 DBG(__func__) 725 DBG(__func__)
726 726
727 mutex_lock(&ACCESS_FBINFO(fbcon).mm_lock);
727 fix->smem_start = ACCESS_FBINFO(video.base) + ACCESS_FBINFO(curr.ydstorg.bytes); 728 fix->smem_start = ACCESS_FBINFO(video.base) + ACCESS_FBINFO(curr.ydstorg.bytes);
728 fix->smem_len = ACCESS_FBINFO(video.len_usable) - ACCESS_FBINFO(curr.ydstorg.bytes); 729 fix->smem_len = ACCESS_FBINFO(video.len_usable) - ACCESS_FBINFO(curr.ydstorg.bytes);
730 mutex_unlock(&ACCESS_FBINFO(fbcon).mm_lock);
729} 731}
730 732
731static int matroxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 733static int matroxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
@@ -1874,7 +1876,6 @@ static int initMatrox2(WPMINFO struct board* b){
1874 } 1876 }
1875 matroxfb_init_fix(PMINFO2); 1877 matroxfb_init_fix(PMINFO2);
1876 ACCESS_FBINFO(fbcon.screen_base) = vaddr_va(ACCESS_FBINFO(video.vbase)); 1878 ACCESS_FBINFO(fbcon.screen_base) = vaddr_va(ACCESS_FBINFO(video.vbase));
1877 matroxfb_update_fix(PMINFO2);
1878 /* Normalize values (namely yres_virtual) */ 1879 /* Normalize values (namely yres_virtual) */
1879 matroxfb_check_var(&vesafb_defined, &ACCESS_FBINFO(fbcon)); 1880 matroxfb_check_var(&vesafb_defined, &ACCESS_FBINFO(fbcon));
1880 /* And put it into "current" var. Do NOT program hardware yet, or we'll not take over 1881 /* And put it into "current" var. Do NOT program hardware yet, or we'll not take over
@@ -2081,6 +2082,7 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
2081 spin_lock_init(&ACCESS_FBINFO(lock.accel)); 2082 spin_lock_init(&ACCESS_FBINFO(lock.accel));
2082 init_rwsem(&ACCESS_FBINFO(crtc2.lock)); 2083 init_rwsem(&ACCESS_FBINFO(crtc2.lock));
2083 init_rwsem(&ACCESS_FBINFO(altout.lock)); 2084 init_rwsem(&ACCESS_FBINFO(altout.lock));
2085 mutex_init(&ACCESS_FBINFO(fbcon).mm_lock);
2084 ACCESS_FBINFO(irq_flags) = 0; 2086 ACCESS_FBINFO(irq_flags) = 0;
2085 init_waitqueue_head(&ACCESS_FBINFO(crtc1.vsync.wait)); 2087 init_waitqueue_head(&ACCESS_FBINFO(crtc1.vsync.wait));
2086 init_waitqueue_head(&ACCESS_FBINFO(crtc2.vsync.wait)); 2088 init_waitqueue_head(&ACCESS_FBINFO(crtc2.vsync.wait));
diff --git a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c
index 7ac4c5f6145d..ebcb5c6b4962 100644
--- a/drivers/video/matrox/matroxfb_crtc2.c
+++ b/drivers/video/matrox/matroxfb_crtc2.c
@@ -289,7 +289,12 @@ static int matroxfb_dh_release(struct fb_info* info, int user) {
289#undef m2info 289#undef m2info
290} 290}
291 291
292static void matroxfb_dh_init_fix(struct matroxfb_dh_fb_info *m2info) { 292/*
293 * This function is called before the register_framebuffer so
294 * no locking is needed.
295 */
296static void matroxfb_dh_init_fix(struct matroxfb_dh_fb_info *m2info)
297{
293 struct fb_fix_screeninfo *fix = &m2info->fbcon.fix; 298 struct fb_fix_screeninfo *fix = &m2info->fbcon.fix;
294 299
295 strcpy(fix->id, "MATROX DH"); 300 strcpy(fix->id, "MATROX DH");
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index b7af5256e887..f8778cde2183 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -669,7 +669,7 @@ static uint32_t bpp_to_pixfmt(int bpp)
669} 669}
670 670
671static int mx3fb_blank(int blank, struct fb_info *fbi); 671static int mx3fb_blank(int blank, struct fb_info *fbi);
672static int mx3fb_map_video_memory(struct fb_info *fbi); 672static int mx3fb_map_video_memory(struct fb_info *fbi, unsigned int mem_len);
673static int mx3fb_unmap_video_memory(struct fb_info *fbi); 673static int mx3fb_unmap_video_memory(struct fb_info *fbi);
674 674
675/** 675/**
@@ -742,8 +742,7 @@ static int mx3fb_set_par(struct fb_info *fbi)
742 if (fbi->fix.smem_start) 742 if (fbi->fix.smem_start)
743 mx3fb_unmap_video_memory(fbi); 743 mx3fb_unmap_video_memory(fbi);
744 744
745 fbi->fix.smem_len = mem_len; 745 if (mx3fb_map_video_memory(fbi, mem_len) < 0) {
746 if (mx3fb_map_video_memory(fbi) < 0) {
747 mutex_unlock(&mx3_fbi->mutex); 746 mutex_unlock(&mx3_fbi->mutex);
748 return -ENOMEM; 747 return -ENOMEM;
749 } 748 }
@@ -1198,6 +1197,7 @@ static int mx3fb_resume(struct platform_device *pdev)
1198/** 1197/**
1199 * mx3fb_map_video_memory() - allocates the DRAM memory for the frame buffer. 1198 * mx3fb_map_video_memory() - allocates the DRAM memory for the frame buffer.
1200 * @fbi: framebuffer information pointer 1199 * @fbi: framebuffer information pointer
1200 * @mem_len: length of mapped memory
1201 * @return: Error code indicating success or failure 1201 * @return: Error code indicating success or failure
1202 * 1202 *
1203 * This buffer is remapped into a non-cached, non-buffered, memory region to 1203 * This buffer is remapped into a non-cached, non-buffered, memory region to
@@ -1205,23 +1205,26 @@ static int mx3fb_resume(struct platform_device *pdev)
1205 * area is remapped, all virtual memory access to the video memory should occur 1205 * area is remapped, all virtual memory access to the video memory should occur
1206 * at the new region. 1206 * at the new region.
1207 */ 1207 */
1208static int mx3fb_map_video_memory(struct fb_info *fbi) 1208static int mx3fb_map_video_memory(struct fb_info *fbi, unsigned int mem_len)
1209{ 1209{
1210 int retval = 0; 1210 int retval = 0;
1211 dma_addr_t addr; 1211 dma_addr_t addr;
1212 1212
1213 fbi->screen_base = dma_alloc_writecombine(fbi->device, 1213 fbi->screen_base = dma_alloc_writecombine(fbi->device,
1214 fbi->fix.smem_len, 1214 mem_len,
1215 &addr, GFP_DMA); 1215 &addr, GFP_DMA);
1216 1216
1217 if (!fbi->screen_base) { 1217 if (!fbi->screen_base) {
1218 dev_err(fbi->device, "Cannot allocate %u bytes framebuffer memory\n", 1218 dev_err(fbi->device, "Cannot allocate %u bytes framebuffer memory\n",
1219 fbi->fix.smem_len); 1219 mem_len);
1220 retval = -EBUSY; 1220 retval = -EBUSY;
1221 goto err0; 1221 goto err0;
1222 } 1222 }
1223 1223
1224 mutex_lock(&fbi->mm_lock);
1224 fbi->fix.smem_start = addr; 1225 fbi->fix.smem_start = addr;
1226 fbi->fix.smem_len = mem_len;
1227 mutex_unlock(&fbi->mm_lock);
1225 1228
1226 dev_dbg(fbi->device, "allocated fb @ p=0x%08x, v=0x%p, size=%d.\n", 1229 dev_dbg(fbi->device, "allocated fb @ p=0x%08x, v=0x%p, size=%d.\n",
1227 (uint32_t) fbi->fix.smem_start, fbi->screen_base, fbi->fix.smem_len); 1230 (uint32_t) fbi->fix.smem_start, fbi->screen_base, fbi->fix.smem_len);
@@ -1251,8 +1254,10 @@ static int mx3fb_unmap_video_memory(struct fb_info *fbi)
1251 fbi->screen_base, fbi->fix.smem_start); 1254 fbi->screen_base, fbi->fix.smem_start);
1252 1255
1253 fbi->screen_base = 0; 1256 fbi->screen_base = 0;
1257 mutex_lock(&fbi->mm_lock);
1254 fbi->fix.smem_start = 0; 1258 fbi->fix.smem_start = 0;
1255 fbi->fix.smem_len = 0; 1259 fbi->fix.smem_len = 0;
1260 mutex_unlock(&fbi->mm_lock);
1256 return 0; 1261 return 0;
1257} 1262}
1258 1263
@@ -1360,11 +1365,6 @@ static int init_fb_chan(struct mx3fb_data *mx3fb, struct idmac_channel *ichan)
1360 init_completion(&mx3fbi->flip_cmpl); 1365 init_completion(&mx3fbi->flip_cmpl);
1361 disable_irq(ichan->eof_irq); 1366 disable_irq(ichan->eof_irq);
1362 dev_dbg(mx3fb->dev, "disabling irq %d\n", ichan->eof_irq); 1367 dev_dbg(mx3fb->dev, "disabling irq %d\n", ichan->eof_irq);
1363 ret = mx3fb_set_par(fbi);
1364 if (ret < 0)
1365 goto esetpar;
1366
1367 mx3fb_blank(FB_BLANK_UNBLANK, fbi);
1368 1368
1369 dev_info(dev, "registered, using mode %s\n", fb_mode); 1369 dev_info(dev, "registered, using mode %s\n", fb_mode);
1370 1370
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
index 060d72fe57cb..8862233d57b6 100644
--- a/drivers/video/omap/omapfb_main.c
+++ b/drivers/video/omap/omapfb_main.c
@@ -393,8 +393,10 @@ static void set_fb_fix(struct fb_info *fbi)
393 393
394 rg = &plane->fbdev->mem_desc.region[plane->idx]; 394 rg = &plane->fbdev->mem_desc.region[plane->idx];
395 fbi->screen_base = rg->vaddr; 395 fbi->screen_base = rg->vaddr;
396 mutex_lock(&fbi->mm_lock);
396 fix->smem_start = rg->paddr; 397 fix->smem_start = rg->paddr;
397 fix->smem_len = rg->size; 398 fix->smem_len = rg->size;
399 mutex_unlock(&fbi->mm_lock);
398 400
399 fix->type = FB_TYPE_PACKED_PIXELS; 401 fix->type = FB_TYPE_PACKED_PIXELS;
400 bpp = var->bits_per_pixel; 402 bpp = var->bits_per_pixel;
@@ -886,8 +888,10 @@ static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
886 * plane memory is dealloce'd, the other 888 * plane memory is dealloce'd, the other
887 * screen parameters in var / fix are invalid. 889 * screen parameters in var / fix are invalid.
888 */ 890 */
891 mutex_lock(&fbi->mm_lock);
889 fbi->fix.smem_start = 0; 892 fbi->fix.smem_start = 0;
890 fbi->fix.smem_len = 0; 893 fbi->fix.smem_len = 0;
894 mutex_unlock(&fbi->mm_lock);
891 } 895 }
892 } 896 }
893 } 897 }
@@ -1250,7 +1254,7 @@ static struct fb_ops omapfb_ops = {
1250static ssize_t omapfb_show_caps_num(struct device *dev, 1254static ssize_t omapfb_show_caps_num(struct device *dev,
1251 struct device_attribute *attr, char *buf) 1255 struct device_attribute *attr, char *buf)
1252{ 1256{
1253 struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data; 1257 struct omapfb_device *fbdev = dev_get_drvdata(dev);
1254 int plane; 1258 int plane;
1255 size_t size; 1259 size_t size;
1256 struct omapfb_caps caps; 1260 struct omapfb_caps caps;
@@ -1270,7 +1274,7 @@ static ssize_t omapfb_show_caps_num(struct device *dev,
1270static ssize_t omapfb_show_caps_text(struct device *dev, 1274static ssize_t omapfb_show_caps_text(struct device *dev,
1271 struct device_attribute *attr, char *buf) 1275 struct device_attribute *attr, char *buf)
1272{ 1276{
1273 struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data; 1277 struct omapfb_device *fbdev = dev_get_drvdata(dev);
1274 int i; 1278 int i;
1275 struct omapfb_caps caps; 1279 struct omapfb_caps caps;
1276 int plane; 1280 int plane;
@@ -1317,7 +1321,7 @@ static DEVICE_ATTR(caps_text, 0444, omapfb_show_caps_text, NULL);
1317static ssize_t omapfb_show_panel_name(struct device *dev, 1321static ssize_t omapfb_show_panel_name(struct device *dev,
1318 struct device_attribute *attr, char *buf) 1322 struct device_attribute *attr, char *buf)
1319{ 1323{
1320 struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data; 1324 struct omapfb_device *fbdev = dev_get_drvdata(dev);
1321 1325
1322 return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->panel->name); 1326 return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->panel->name);
1323} 1327}
@@ -1326,7 +1330,7 @@ static ssize_t omapfb_show_bklight_level(struct device *dev,
1326 struct device_attribute *attr, 1330 struct device_attribute *attr,
1327 char *buf) 1331 char *buf)
1328{ 1332{
1329 struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data; 1333 struct omapfb_device *fbdev = dev_get_drvdata(dev);
1330 int r; 1334 int r;
1331 1335
1332 if (fbdev->panel->get_bklight_level) { 1336 if (fbdev->panel->get_bklight_level) {
@@ -1341,7 +1345,7 @@ static ssize_t omapfb_store_bklight_level(struct device *dev,
1341 struct device_attribute *attr, 1345 struct device_attribute *attr,
1342 const char *buf, size_t size) 1346 const char *buf, size_t size)
1343{ 1347{
1344 struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data; 1348 struct omapfb_device *fbdev = dev_get_drvdata(dev);
1345 int r; 1349 int r;
1346 1350
1347 if (fbdev->panel->set_bklight_level) { 1351 if (fbdev->panel->set_bklight_level) {
@@ -1360,7 +1364,7 @@ static ssize_t omapfb_store_bklight_level(struct device *dev,
1360static ssize_t omapfb_show_bklight_max(struct device *dev, 1364static ssize_t omapfb_show_bklight_max(struct device *dev,
1361 struct device_attribute *attr, char *buf) 1365 struct device_attribute *attr, char *buf)
1362{ 1366{
1363 struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data; 1367 struct omapfb_device *fbdev = dev_get_drvdata(dev);
1364 int r; 1368 int r;
1365 1369
1366 if (fbdev->panel->get_bklight_level) { 1370 if (fbdev->panel->get_bklight_level) {
@@ -1393,7 +1397,7 @@ static struct attribute_group panel_attr_grp = {
1393static ssize_t omapfb_show_ctrl_name(struct device *dev, 1397static ssize_t omapfb_show_ctrl_name(struct device *dev,
1394 struct device_attribute *attr, char *buf) 1398 struct device_attribute *attr, char *buf)
1395{ 1399{
1396 struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data; 1400 struct omapfb_device *fbdev = dev_get_drvdata(dev);
1397 1401
1398 return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->ctrl->name); 1402 return snprintf(buf, PAGE_SIZE, "%s\n", fbdev->ctrl->name);
1399} 1403}
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 03b3670130a0..bacfabd9ce16 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -141,7 +141,9 @@ static int platinumfb_set_par (struct fb_info *info)
141 offset = 0x10; 141 offset = 0x10;
142 142
143 info->screen_base = pinfo->frame_buffer + init->fb_offset + offset; 143 info->screen_base = pinfo->frame_buffer + init->fb_offset + offset;
144 mutex_lock(&info->mm_lock);
144 info->fix.smem_start = (pinfo->frame_buffer_phys) + init->fb_offset + offset; 145 info->fix.smem_start = (pinfo->frame_buffer_phys) + init->fb_offset + offset;
146 mutex_unlock(&info->mm_lock);
145 info->fix.visual = (pinfo->cmode == CMODE_8) ? 147 info->fix.visual = (pinfo->cmode == CMODE_8) ?
146 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; 148 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
147 info->fix.line_length = vmode_attrs[pinfo->vmode-1].hres * (1<<pinfo->cmode) 149 info->fix.line_length = vmode_attrs[pinfo->vmode-1].hres * (1<<pinfo->cmode)
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 0889d50c3288..6506117c134b 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -815,8 +815,10 @@ static int overlayfb_map_video_memory(struct pxafb_layer *ofb)
815 ofb->video_mem_phys = virt_to_phys(ofb->video_mem); 815 ofb->video_mem_phys = virt_to_phys(ofb->video_mem);
816 ofb->video_mem_size = size; 816 ofb->video_mem_size = size;
817 817
818 mutex_lock(&ofb->fb.mm_lock);
818 ofb->fb.fix.smem_start = ofb->video_mem_phys; 819 ofb->fb.fix.smem_start = ofb->video_mem_phys;
819 ofb->fb.fix.smem_len = ofb->fb.fix.line_length * var->yres_virtual; 820 ofb->fb.fix.smem_len = ofb->fb.fix.line_length * var->yres_virtual;
821 mutex_unlock(&ofb->fb.mm_lock);
820 ofb->fb.screen_base = ofb->video_mem; 822 ofb->fb.screen_base = ofb->video_mem;
821 return 0; 823 return 0;
822} 824}
diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index 43680e545427..bb63c07e13de 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -211,23 +211,21 @@ static int s3c_fb_check_var(struct fb_var_screeninfo *var,
211 211
212/** 212/**
213 * s3c_fb_calc_pixclk() - calculate the divider to create the pixel clock. 213 * s3c_fb_calc_pixclk() - calculate the divider to create the pixel clock.
214 * @id: window id.
214 * @sfb: The hardware state. 215 * @sfb: The hardware state.
215 * @pixclock: The pixel clock wanted, in picoseconds. 216 * @pixclock: The pixel clock wanted, in picoseconds.
216 * 217 *
217 * Given the specified pixel clock, work out the necessary divider to get 218 * Given the specified pixel clock, work out the necessary divider to get
218 * close to the output frequency. 219 * close to the output frequency.
219 */ 220 */
220static int s3c_fb_calc_pixclk(struct s3c_fb *sfb, unsigned int pixclk) 221static int s3c_fb_calc_pixclk(unsigned char id, struct s3c_fb *sfb, unsigned int pixclk)
221{ 222{
223 struct s3c_fb_pd_win *win = sfb->pdata->win[id];
222 unsigned long clk = clk_get_rate(sfb->bus_clk); 224 unsigned long clk = clk_get_rate(sfb->bus_clk);
223 unsigned long long tmp;
224 unsigned int result; 225 unsigned int result;
225 226
226 tmp = (unsigned long long)clk; 227 pixclk *= win->win_mode.refresh;
227 tmp *= pixclk; 228 result = clk / pixclk;
228
229 do_div(tmp, 1000000000UL);
230 result = (unsigned int)tmp / 1000;
231 229
232 dev_dbg(sfb->dev, "pixclk=%u, clk=%lu, div=%d (%lu)\n", 230 dev_dbg(sfb->dev, "pixclk=%u, clk=%lu, div=%d (%lu)\n",
233 pixclk, clk, result, clk / result); 231 pixclk, clk, result, clk / result);
@@ -267,6 +265,7 @@ static int s3c_fb_set_par(struct fb_info *info)
267 struct s3c_fb *sfb = win->parent; 265 struct s3c_fb *sfb = win->parent;
268 void __iomem *regs = sfb->regs; 266 void __iomem *regs = sfb->regs;
269 int win_no = win->index; 267 int win_no = win->index;
268 u32 osdc_data = 0;
270 u32 data; 269 u32 data;
271 u32 pagewidth; 270 u32 pagewidth;
272 int clkdiv; 271 int clkdiv;
@@ -302,7 +301,7 @@ static int s3c_fb_set_par(struct fb_info *info)
302 /* use window 0 as the basis for the lcd output timings */ 301 /* use window 0 as the basis for the lcd output timings */
303 302
304 if (win_no == 0) { 303 if (win_no == 0) {
305 clkdiv = s3c_fb_calc_pixclk(sfb, var->pixclock); 304 clkdiv = s3c_fb_calc_pixclk(win_no, sfb, var->pixclock);
306 305
307 data = sfb->pdata->vidcon0; 306 data = sfb->pdata->vidcon0;
308 data &= ~(VIDCON0_CLKVAL_F_MASK | VIDCON0_CLKDIR); 307 data &= ~(VIDCON0_CLKVAL_F_MASK | VIDCON0_CLKDIR);
@@ -359,8 +358,6 @@ static int s3c_fb_set_par(struct fb_info *info)
359 358
360 data = var->xres * var->yres; 359 data = var->xres * var->yres;
361 360
362 u32 osdc_data = 0;
363
364 osdc_data = VIDISD14C_ALPHA1_R(0xf) | 361 osdc_data = VIDISD14C_ALPHA1_R(0xf) |
365 VIDISD14C_ALPHA1_G(0xf) | 362 VIDISD14C_ALPHA1_G(0xf) |
366 VIDISD14C_ALPHA1_B(0xf); 363 VIDISD14C_ALPHA1_B(0xf);
diff --git a/drivers/video/sh7760fb.c b/drivers/video/sh7760fb.c
index 653bdfee3057..9f6d6e61f0cc 100644
--- a/drivers/video/sh7760fb.c
+++ b/drivers/video/sh7760fb.c
@@ -120,18 +120,6 @@ static int sh7760_setcolreg (u_int regno,
120 return 0; 120 return 0;
121} 121}
122 122
123static void encode_fix(struct fb_fix_screeninfo *fix, struct fb_info *info,
124 unsigned long stride)
125{
126 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
127 strcpy(fix->id, "sh7760-lcdc");
128
129 fix->smem_start = (unsigned long)info->screen_base;
130 fix->smem_len = info->screen_size;
131
132 fix->line_length = stride;
133}
134
135static int sh7760fb_get_color_info(struct device *dev, 123static int sh7760fb_get_color_info(struct device *dev,
136 u16 lddfr, int *bpp, int *gray) 124 u16 lddfr, int *bpp, int *gray)
137{ 125{
@@ -334,7 +322,8 @@ static int sh7760fb_set_par(struct fb_info *info)
334 322
335 iowrite32(ldsarl, par->base + LDSARL); /* mem for lower half of DSTN */ 323 iowrite32(ldsarl, par->base + LDSARL); /* mem for lower half of DSTN */
336 324
337 encode_fix(&info->fix, info, stride); 325 info->fix.line_length = stride;
326
338 sh7760fb_check_var(&info->var, info); 327 sh7760fb_check_var(&info->var, info);
339 328
340 sh7760fb_blank(FB_BLANK_UNBLANK, info); /* panel on! */ 329 sh7760fb_blank(FB_BLANK_UNBLANK, info); /* panel on! */
@@ -435,6 +424,8 @@ static int sh7760fb_alloc_mem(struct fb_info *info)
435 424
436 info->screen_base = fbmem; 425 info->screen_base = fbmem;
437 info->screen_size = vram; 426 info->screen_size = vram;
427 info->fix.smem_start = (unsigned long)info->screen_base;
428 info->fix.smem_len = info->screen_size;
438 429
439 return 0; 430 return 0;
440} 431}
@@ -520,6 +511,8 @@ static int __devinit sh7760fb_probe(struct platform_device *pdev)
520 info->var.transp.length = 0; 511 info->var.transp.length = 0;
521 info->var.transp.msb_right = 0; 512 info->var.transp.msb_right = 0;
522 513
514 strcpy(info->fix.id, "sh7760-lcdc");
515
523 /* set the DON2 bit now, before cmap allocation, as it will randomize 516 /* set the DON2 bit now, before cmap allocation, as it will randomize
524 * palette memory. 517 * palette memory.
525 */ 518 */
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index f10d2fbeda06..8f24564f77b0 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -17,6 +17,7 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/dma-mapping.h> 18#include <linux/dma-mapping.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/vmalloc.h>
20#include <video/sh_mobile_lcdc.h> 21#include <video/sh_mobile_lcdc.h>
21#include <asm/atomic.h> 22#include <asm/atomic.h>
22 23
@@ -30,9 +31,10 @@ struct sh_mobile_lcdc_chan {
30 unsigned long enabled; /* ME and SE in LDCNT2R */ 31 unsigned long enabled; /* ME and SE in LDCNT2R */
31 struct sh_mobile_lcdc_chan_cfg cfg; 32 struct sh_mobile_lcdc_chan_cfg cfg;
32 u32 pseudo_palette[PALETTE_NR]; 33 u32 pseudo_palette[PALETTE_NR];
33 struct fb_info info; 34 struct fb_info *info;
34 dma_addr_t dma_handle; 35 dma_addr_t dma_handle;
35 struct fb_deferred_io defio; 36 struct fb_deferred_io defio;
37 struct scatterlist *sglist;
36 unsigned long frame_end; 38 unsigned long frame_end;
37 wait_queue_head_t frame_end_wait; 39 wait_queue_head_t frame_end_wait;
38}; 40};
@@ -206,16 +208,38 @@ static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv) {}
206static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv) {} 208static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv) {}
207#endif 209#endif
208 210
211static int sh_mobile_lcdc_sginit(struct fb_info *info,
212 struct list_head *pagelist)
213{
214 struct sh_mobile_lcdc_chan *ch = info->par;
215 unsigned int nr_pages_max = info->fix.smem_len >> PAGE_SHIFT;
216 struct page *page;
217 int nr_pages = 0;
218
219 sg_init_table(ch->sglist, nr_pages_max);
220
221 list_for_each_entry(page, pagelist, lru)
222 sg_set_page(&ch->sglist[nr_pages++], page, PAGE_SIZE, 0);
223
224 return nr_pages;
225}
226
209static void sh_mobile_lcdc_deferred_io(struct fb_info *info, 227static void sh_mobile_lcdc_deferred_io(struct fb_info *info,
210 struct list_head *pagelist) 228 struct list_head *pagelist)
211{ 229{
212 struct sh_mobile_lcdc_chan *ch = info->par; 230 struct sh_mobile_lcdc_chan *ch = info->par;
231 unsigned int nr_pages;
213 232
214 /* enable clocks before accessing hardware */ 233 /* enable clocks before accessing hardware */
215 sh_mobile_lcdc_clk_on(ch->lcdc); 234 sh_mobile_lcdc_clk_on(ch->lcdc);
216 235
236 nr_pages = sh_mobile_lcdc_sginit(info, pagelist);
237 dma_map_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE);
238
217 /* trigger panel update */ 239 /* trigger panel update */
218 lcdc_write_chan(ch, LDSM2R, 1); 240 lcdc_write_chan(ch, LDSM2R, 1);
241
242 dma_unmap_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE);
219} 243}
220 244
221static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info) 245static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info)
@@ -418,22 +442,22 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
418 /* set bpp format in PKF[4:0] */ 442 /* set bpp format in PKF[4:0] */
419 tmp = lcdc_read_chan(ch, LDDFR); 443 tmp = lcdc_read_chan(ch, LDDFR);
420 tmp &= ~(0x0001001f); 444 tmp &= ~(0x0001001f);
421 tmp |= (priv->ch[k].info.var.bits_per_pixel == 16) ? 3 : 0; 445 tmp |= (ch->info->var.bits_per_pixel == 16) ? 3 : 0;
422 lcdc_write_chan(ch, LDDFR, tmp); 446 lcdc_write_chan(ch, LDDFR, tmp);
423 447
424 /* point out our frame buffer */ 448 /* point out our frame buffer */
425 lcdc_write_chan(ch, LDSA1R, ch->info.fix.smem_start); 449 lcdc_write_chan(ch, LDSA1R, ch->info->fix.smem_start);
426 450
427 /* set line size */ 451 /* set line size */
428 lcdc_write_chan(ch, LDMLSR, ch->info.fix.line_length); 452 lcdc_write_chan(ch, LDMLSR, ch->info->fix.line_length);
429 453
430 /* setup deferred io if SYS bus */ 454 /* setup deferred io if SYS bus */
431 tmp = ch->cfg.sys_bus_cfg.deferred_io_msec; 455 tmp = ch->cfg.sys_bus_cfg.deferred_io_msec;
432 if (ch->ldmt1r_value & (1 << 12) && tmp) { 456 if (ch->ldmt1r_value & (1 << 12) && tmp) {
433 ch->defio.deferred_io = sh_mobile_lcdc_deferred_io; 457 ch->defio.deferred_io = sh_mobile_lcdc_deferred_io;
434 ch->defio.delay = msecs_to_jiffies(tmp); 458 ch->defio.delay = msecs_to_jiffies(tmp);
435 ch->info.fbdefio = &ch->defio; 459 ch->info->fbdefio = &ch->defio;
436 fb_deferred_io_init(&ch->info); 460 fb_deferred_io_init(ch->info);
437 461
438 /* one-shot mode */ 462 /* one-shot mode */
439 lcdc_write_chan(ch, LDSM1R, 1); 463 lcdc_write_chan(ch, LDSM1R, 1);
@@ -479,12 +503,12 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
479 * flush frame, and wait for frame end interrupt 503 * flush frame, and wait for frame end interrupt
480 * clean up deferred io and enable clock 504 * clean up deferred io and enable clock
481 */ 505 */
482 if (ch->info.fbdefio) { 506 if (ch->info->fbdefio) {
483 ch->frame_end = 0; 507 ch->frame_end = 0;
484 schedule_delayed_work(&ch->info.deferred_work, 0); 508 schedule_delayed_work(&ch->info->deferred_work, 0);
485 wait_event(ch->frame_end_wait, ch->frame_end); 509 wait_event(ch->frame_end_wait, ch->frame_end);
486 fb_deferred_io_cleanup(&ch->info); 510 fb_deferred_io_cleanup(ch->info);
487 ch->info.fbdefio = NULL; 511 ch->info->fbdefio = NULL;
488 sh_mobile_lcdc_clk_on(priv); 512 sh_mobile_lcdc_clk_on(priv);
489 } 513 }
490 514
@@ -793,9 +817,16 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
793 priv->base = ioremap_nocache(res->start, (res->end - res->start) + 1); 817 priv->base = ioremap_nocache(res->start, (res->end - res->start) + 1);
794 818
795 for (i = 0; i < j; i++) { 819 for (i = 0; i < j; i++) {
796 info = &priv->ch[i].info;
797 cfg = &priv->ch[i].cfg; 820 cfg = &priv->ch[i].cfg;
798 821
822 priv->ch[i].info = framebuffer_alloc(0, &pdev->dev);
823 if (!priv->ch[i].info) {
824 dev_err(&pdev->dev, "unable to allocate fb_info\n");
825 error = -ENOMEM;
826 break;
827 }
828
829 info = priv->ch[i].info;
799 info->fbops = &sh_mobile_lcdc_ops; 830 info->fbops = &sh_mobile_lcdc_ops;
800 info->var.xres = info->var.xres_virtual = cfg->lcd_cfg.xres; 831 info->var.xres = info->var.xres_virtual = cfg->lcd_cfg.xres;
801 info->var.yres = info->var.yres_virtual = cfg->lcd_cfg.yres; 832 info->var.yres = info->var.yres_virtual = cfg->lcd_cfg.yres;
@@ -846,21 +877,31 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev)
846 } 877 }
847 878
848 for (i = 0; i < j; i++) { 879 for (i = 0; i < j; i++) {
849 error = register_framebuffer(&priv->ch[i].info); 880 struct sh_mobile_lcdc_chan *ch = priv->ch + i;
881
882 info = ch->info;
883
884 if (info->fbdefio) {
885 priv->ch->sglist = vmalloc(sizeof(struct scatterlist) *
886 info->fix.smem_len >> PAGE_SHIFT);
887 if (!priv->ch->sglist) {
888 dev_err(&pdev->dev, "cannot allocate sglist\n");
889 goto err1;
890 }
891 }
892
893 error = register_framebuffer(info);
850 if (error < 0) 894 if (error < 0)
851 goto err1; 895 goto err1;
852 }
853 896
854 for (i = 0; i < j; i++) {
855 info = &priv->ch[i].info;
856 dev_info(info->dev, 897 dev_info(info->dev,
857 "registered %s/%s as %dx%d %dbpp.\n", 898 "registered %s/%s as %dx%d %dbpp.\n",
858 pdev->name, 899 pdev->name,
859 (priv->ch[i].cfg.chan == LCDC_CHAN_MAINLCD) ? 900 (ch->cfg.chan == LCDC_CHAN_MAINLCD) ?
860 "mainlcd" : "sublcd", 901 "mainlcd" : "sublcd",
861 (int) priv->ch[i].cfg.lcd_cfg.xres, 902 (int) ch->cfg.lcd_cfg.xres,
862 (int) priv->ch[i].cfg.lcd_cfg.yres, 903 (int) ch->cfg.lcd_cfg.yres,
863 priv->ch[i].cfg.bpp); 904 ch->cfg.bpp);
864 905
865 /* deferred io mode: disable clock to save power */ 906 /* deferred io mode: disable clock to save power */
866 if (info->fbdefio) 907 if (info->fbdefio)
@@ -881,20 +922,24 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev)
881 int i; 922 int i;
882 923
883 for (i = 0; i < ARRAY_SIZE(priv->ch); i++) 924 for (i = 0; i < ARRAY_SIZE(priv->ch); i++)
884 if (priv->ch[i].info.dev) 925 if (priv->ch[i].info->dev)
885 unregister_framebuffer(&priv->ch[i].info); 926 unregister_framebuffer(priv->ch[i].info);
886 927
887 sh_mobile_lcdc_stop(priv); 928 sh_mobile_lcdc_stop(priv);
888 929
889 for (i = 0; i < ARRAY_SIZE(priv->ch); i++) { 930 for (i = 0; i < ARRAY_SIZE(priv->ch); i++) {
890 info = &priv->ch[i].info; 931 info = priv->ch[i].info;
891 932
892 if (!info->device) 933 if (!info || !info->device)
893 continue; 934 continue;
894 935
936 if (priv->ch[i].sglist)
937 vfree(priv->ch[i].sglist);
938
895 dma_free_coherent(&pdev->dev, info->fix.smem_len, 939 dma_free_coherent(&pdev->dev, info->fix.smem_len,
896 info->screen_base, priv->ch[i].dma_handle); 940 info->screen_base, priv->ch[i].dma_handle);
897 fb_dealloc_cmap(&info->cmap); 941 fb_dealloc_cmap(&info->cmap);
942 framebuffer_release(info);
898 } 943 }
899 944
900#ifdef CONFIG_HAVE_CLK 945#ifdef CONFIG_HAVE_CLK
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index 7072d19080d5..4a067f0d0ceb 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -1847,8 +1847,10 @@ sisfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
1847 1847
1848 strcpy(fix->id, ivideo->myid); 1848 strcpy(fix->id, ivideo->myid);
1849 1849
1850 mutex_lock(&info->mm_lock);
1850 fix->smem_start = ivideo->video_base + ivideo->video_offset; 1851 fix->smem_start = ivideo->video_base + ivideo->video_offset;
1851 fix->smem_len = ivideo->sisfb_mem; 1852 fix->smem_len = ivideo->sisfb_mem;
1853 mutex_unlock(&info->mm_lock);
1852 fix->type = FB_TYPE_PACKED_PIXELS; 1854 fix->type = FB_TYPE_PACKED_PIXELS;
1853 fix->type_aux = 0; 1855 fix->type_aux = 0;
1854 fix->visual = (ivideo->video_bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; 1856 fix->visual = (ivideo->video_bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
@@ -6365,7 +6367,6 @@ error_3: vfree(ivideo->bios_abase);
6365 sis_fb_info->fix = ivideo->sisfb_fix; 6367 sis_fb_info->fix = ivideo->sisfb_fix;
6366 sis_fb_info->screen_base = ivideo->video_vbase + ivideo->video_offset; 6368 sis_fb_info->screen_base = ivideo->video_vbase + ivideo->video_offset;
6367 sis_fb_info->fbops = &sisfb_ops; 6369 sis_fb_info->fbops = &sisfb_ops;
6368 sisfb_get_fix(&sis_fb_info->fix, -1, sis_fb_info);
6369 sis_fb_info->pseudo_palette = ivideo->pseudo_palette; 6370 sis_fb_info->pseudo_palette = ivideo->pseudo_palette;
6370 6371
6371 fb_alloc_cmap(&sis_fb_info->cmap, 256 , 0); 6372 fb_alloc_cmap(&sis_fb_info->cmap, 256 , 0);
diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c
index eb5d73a06702..924d79462780 100644
--- a/drivers/video/sm501fb.c
+++ b/drivers/video/sm501fb.c
@@ -145,7 +145,7 @@ static inline void sm501fb_sync_regs(struct sm501fb_info *info)
145#define SM501_MEMF_ACCEL (8) 145#define SM501_MEMF_ACCEL (8)
146 146
147static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem, 147static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
148 unsigned int why, size_t size) 148 unsigned int why, size_t size, u32 smem_len)
149{ 149{
150 struct sm501fb_par *par; 150 struct sm501fb_par *par;
151 struct fb_info *fbi; 151 struct fb_info *fbi;
@@ -172,7 +172,7 @@ static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
172 if (ptr > 0) 172 if (ptr > 0)
173 ptr &= ~(PAGE_SIZE - 1); 173 ptr &= ~(PAGE_SIZE - 1);
174 174
175 if (fbi && ptr < fbi->fix.smem_len) 175 if (fbi && ptr < smem_len)
176 return -ENOMEM; 176 return -ENOMEM;
177 177
178 break; 178 break;
@@ -197,7 +197,7 @@ static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
197 197
198 case SM501_MEMF_ACCEL: 198 case SM501_MEMF_ACCEL:
199 fbi = inf->fb[HEAD_CRT]; 199 fbi = inf->fb[HEAD_CRT];
200 ptr = fbi ? fbi->fix.smem_len : 0; 200 ptr = fbi ? smem_len : 0;
201 201
202 fbi = inf->fb[HEAD_PANEL]; 202 fbi = inf->fb[HEAD_PANEL];
203 if (fbi) { 203 if (fbi) {
@@ -413,6 +413,7 @@ static int sm501fb_set_par_common(struct fb_info *info,
413 unsigned int mem_type; 413 unsigned int mem_type;
414 unsigned int clock_type; 414 unsigned int clock_type;
415 unsigned int head_addr; 415 unsigned int head_addr;
416 unsigned int smem_len;
416 417
417 dev_dbg(fbi->dev, "%s: %dx%d, bpp = %d, virtual %dx%d\n", 418 dev_dbg(fbi->dev, "%s: %dx%d, bpp = %d, virtual %dx%d\n",
418 __func__, var->xres, var->yres, var->bits_per_pixel, 419 __func__, var->xres, var->yres, var->bits_per_pixel,
@@ -453,18 +454,20 @@ static int sm501fb_set_par_common(struct fb_info *info,
453 454
454 /* allocate fb memory within 501 */ 455 /* allocate fb memory within 501 */
455 info->fix.line_length = (var->xres_virtual * var->bits_per_pixel)/8; 456 info->fix.line_length = (var->xres_virtual * var->bits_per_pixel)/8;
456 info->fix.smem_len = info->fix.line_length * var->yres_virtual; 457 smem_len = info->fix.line_length * var->yres_virtual;
457 458
458 dev_dbg(fbi->dev, "%s: line length = %u\n", __func__, 459 dev_dbg(fbi->dev, "%s: line length = %u\n", __func__,
459 info->fix.line_length); 460 info->fix.line_length);
460 461
461 if (sm501_alloc_mem(fbi, &par->screen, mem_type, 462 if (sm501_alloc_mem(fbi, &par->screen, mem_type, smem_len, smem_len)) {
462 info->fix.smem_len)) {
463 dev_err(fbi->dev, "no memory available\n"); 463 dev_err(fbi->dev, "no memory available\n");
464 return -ENOMEM; 464 return -ENOMEM;
465 } 465 }
466 466
467 mutex_lock(&info->mm_lock);
467 info->fix.smem_start = fbi->fbmem_res->start + par->screen.sm_addr; 468 info->fix.smem_start = fbi->fbmem_res->start + par->screen.sm_addr;
469 info->fix.smem_len = smem_len;
470 mutex_unlock(&info->mm_lock);
468 471
469 info->screen_base = fbi->fbmem + par->screen.sm_addr; 472 info->screen_base = fbi->fbmem + par->screen.sm_addr;
470 info->screen_size = info->fix.smem_len; 473 info->screen_size = info->fix.smem_len;
@@ -637,7 +640,8 @@ static int sm501fb_set_par_crt(struct fb_info *info)
637 if ((control & SM501_DC_CRT_CONTROL_SEL) == 0) { 640 if ((control & SM501_DC_CRT_CONTROL_SEL) == 0) {
638 /* the head is displaying panel data... */ 641 /* the head is displaying panel data... */
639 642
640 sm501_alloc_mem(fbi, &par->screen, SM501_MEMF_CRT, 0); 643 sm501_alloc_mem(fbi, &par->screen, SM501_MEMF_CRT, 0,
644 info->fix.smem_len);
641 goto out_update; 645 goto out_update;
642 } 646 }
643 647
@@ -1289,7 +1293,8 @@ static int sm501_init_cursor(struct fb_info *fbi, unsigned int reg_base)
1289 1293
1290 par->cursor_regs = info->regs + reg_base; 1294 par->cursor_regs = info->regs + reg_base;
1291 1295
1292 ret = sm501_alloc_mem(info, &par->cursor, SM501_MEMF_CURSOR, 1024); 1296 ret = sm501_alloc_mem(info, &par->cursor, SM501_MEMF_CURSOR, 1024,
1297 fbi->fix.smem_len);
1293 if (ret < 0) 1298 if (ret < 0)
1294 return ret; 1299 return ret;
1295 1300
@@ -1535,9 +1540,6 @@ static int sm501fb_init_fb(struct fb_info *fb,
1535 if (ret) 1540 if (ret)
1536 dev_err(info->dev, "check_var() failed on initial setup?\n"); 1541 dev_err(info->dev, "check_var() failed on initial setup?\n");
1537 1542
1538 /* ensure we've activated our new configuration */
1539 (fb->fbops->fb_set_par)(fb);
1540
1541 return 0; 1543 return 0;
1542} 1544}
1543 1545
@@ -1619,6 +1621,8 @@ static int __devinit sm501fb_start_one(struct sm501fb_info *info,
1619 if (!fbi) 1621 if (!fbi)
1620 return 0; 1622 return 0;
1621 1623
1624 mutex_init(&info->fb[head]->mm_lock);
1625
1622 ret = sm501fb_init_fb(info->fb[head], head, drvname); 1626 ret = sm501fb_init_fb(info->fb[head], head, drvname);
1623 if (ret) { 1627 if (ret) {
1624 dev_err(info->dev, "cannot initialise fb %s\n", drvname); 1628 dev_err(info->dev, "cannot initialise fb %s\n", drvname);
diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c
index eec9dcb7f599..6120f0c526fe 100644
--- a/drivers/video/stifb.c
+++ b/drivers/video/stifb.c
@@ -1115,10 +1115,9 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
1115 if the device name contains the string "DX" and tell the 1115 if the device name contains the string "DX" and tell the
1116 user how to reconfigure the card. */ 1116 user how to reconfigure the card. */
1117 if (strstr(sti->outptr.dev_name, "DX")) { 1117 if (strstr(sti->outptr.dev_name, "DX")) {
1118 printk(KERN_WARNING "WARNING: stifb framebuffer driver does not " 1118 printk(KERN_WARNING
1119 "support '%s' in double-buffer mode.\n" 1119"WARNING: stifb framebuffer driver does not support '%s' in double-buffer mode.\n"
1120 KERN_WARNING "WARNING: Please disable the double-buffer mode " 1120"WARNING: Please disable the double-buffer mode in IPL menu (the PARISC-BIOS).\n",
1121 "in IPL menu (the PARISC-BIOS).\n",
1122 sti->outptr.dev_name); 1121 sti->outptr.dev_name);
1123 goto out_err0; 1122 goto out_err0;
1124 } 1123 }
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index d0674f1e3f10..2376f688ec8b 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -523,6 +523,7 @@ static int w100fb_set_par(struct fb_info *info)
523 info->fix.ywrapstep = 0; 523 info->fix.ywrapstep = 0;
524 info->fix.line_length = par->xres * BITS_PER_PIXEL / 8; 524 info->fix.line_length = par->xres * BITS_PER_PIXEL / 8;
525 525
526 mutex_lock(&info->mm_lock);
526 if ((par->xres*par->yres*BITS_PER_PIXEL/8) > (MEM_INT_SIZE+1)) { 527 if ((par->xres*par->yres*BITS_PER_PIXEL/8) > (MEM_INT_SIZE+1)) {
527 par->extmem_active = 1; 528 par->extmem_active = 1;
528 info->fix.smem_len = par->mach->mem->size+1; 529 info->fix.smem_len = par->mach->mem->size+1;
@@ -530,6 +531,7 @@ static int w100fb_set_par(struct fb_info *info)
530 par->extmem_active = 0; 531 par->extmem_active = 0;
531 info->fix.smem_len = MEM_INT_SIZE+1; 532 info->fix.smem_len = MEM_INT_SIZE+1;
532 } 533 }
534 mutex_unlock(&info->mm_lock);
533 535
534 w100fb_activate_var(par); 536 w100fb_activate_var(par);
535 } 537 }
@@ -746,8 +748,6 @@ int __init w100fb_probe(struct platform_device *pdev)
746 goto out; 748 goto out;
747 } 749 }
748 750
749 w100fb_set_par(info);
750
751 if (register_framebuffer(info) < 0) { 751 if (register_framebuffer(info) < 0) {
752 err = -EINVAL; 752 err = -EINVAL;
753 goto out; 753 goto out;
diff --git a/drivers/vlynq/Kconfig b/drivers/vlynq/Kconfig
index f6542211db48..a9efb1625321 100644
--- a/drivers/vlynq/Kconfig
+++ b/drivers/vlynq/Kconfig
@@ -13,7 +13,7 @@ config VLYNQ
13 13
14config VLYNQ_DEBUG 14config VLYNQ_DEBUG
15 bool "VLYNQ bus debug" 15 bool "VLYNQ bus debug"
16 depends on VLYNQ && KERNEL_DEBUG 16 depends on VLYNQ && DEBUG_KERNEL
17 help 17 help
18 Turn on VLYNQ bus debugging. 18 Turn on VLYNQ bus debugging.
19 19
diff --git a/drivers/vlynq/vlynq.c b/drivers/vlynq/vlynq.c
index 7335433b067b..f05d2a368367 100644
--- a/drivers/vlynq/vlynq.c
+++ b/drivers/vlynq/vlynq.c
@@ -76,7 +76,7 @@ struct vlynq_regs {
76 u32 int_device[8]; 76 u32 int_device[8];
77}; 77};
78 78
79#ifdef VLYNQ_DEBUG 79#ifdef CONFIG_VLYNQ_DEBUG
80static void vlynq_dump_regs(struct vlynq_device *dev) 80static void vlynq_dump_regs(struct vlynq_device *dev)
81{ 81{
82 int i; 82 int i;
diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c
index 5c7011cda6a6..751c003864ad 100644
--- a/drivers/watchdog/bcm47xx_wdt.c
+++ b/drivers/watchdog/bcm47xx_wdt.c
@@ -161,7 +161,7 @@ static long bcm47xx_wdt_ioctl(struct file *file,
161{ 161{
162 void __user *argp = (void __user *)arg; 162 void __user *argp = (void __user *)arg;
163 int __user *p = argp; 163 int __user *p = argp;
164 int new_value, retval = -EINVAL;; 164 int new_value, retval = -EINVAL;
165 165
166 switch (cmd) { 166 switch (cmd) {
167 case WDIOC_GETSUPPORT: 167 case WDIOC_GETSUPPORT:
diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
index ee1caae4d33b..016245419fad 100644
--- a/drivers/watchdog/sa1100_wdt.c
+++ b/drivers/watchdog/sa1100_wdt.c
@@ -38,7 +38,7 @@
38 38
39static unsigned long oscr_freq; 39static unsigned long oscr_freq;
40static unsigned long sa1100wdt_users; 40static unsigned long sa1100wdt_users;
41static int pre_margin; 41static unsigned int pre_margin;
42static int boot_status; 42static int boot_status;
43 43
44/* 44/*
@@ -84,6 +84,7 @@ static const struct watchdog_info ident = {
84 .options = WDIOF_CARDRESET | WDIOF_SETTIMEOUT 84 .options = WDIOF_CARDRESET | WDIOF_SETTIMEOUT
85 | WDIOF_KEEPALIVEPING, 85 | WDIOF_KEEPALIVEPING,
86 .identity = "SA1100/PXA255 Watchdog", 86 .identity = "SA1100/PXA255 Watchdog",
87 .firmware_version = 1,
87}; 88};
88 89
89static long sa1100dog_ioctl(struct file *file, unsigned int cmd, 90static long sa1100dog_ioctl(struct file *file, unsigned int cmd,
@@ -118,7 +119,7 @@ static long sa1100dog_ioctl(struct file *file, unsigned int cmd,
118 if (ret) 119 if (ret)
119 break; 120 break;
120 121
121 if (time <= 0 || time > 255) { 122 if (time <= 0 || (oscr_freq * (long long)time >= 0xffffffff)) {
122 ret = -EINVAL; 123 ret = -EINVAL;
123 break; 124 break;
124 } 125 }
diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c
index 916890abffdd..f201accc4e3d 100644
--- a/drivers/watchdog/w83627hf_wdt.c
+++ b/drivers/watchdog/w83627hf_wdt.c
@@ -89,6 +89,11 @@ static void w83627hf_select_wd_register(void)
89 c = ((inb_p(WDT_EFDR) & 0xf7) | 0x04); /* select WDT0 */ 89 c = ((inb_p(WDT_EFDR) & 0xf7) | 0x04); /* select WDT0 */
90 outb_p(0x2b, WDT_EFER); 90 outb_p(0x2b, WDT_EFER);
91 outb_p(c, WDT_EFDR); /* set GPIO3 to WDT0 */ 91 outb_p(c, WDT_EFDR); /* set GPIO3 to WDT0 */
92 } else if (c == 0x88) { /* W83627EHF */
93 outb_p(0x2d, WDT_EFER); /* select GPIO5 */
94 c = inb_p(WDT_EFDR) & ~0x01; /* PIN77 -> WDT0# */
95 outb_p(0x2d, WDT_EFER);
96 outb_p(c, WDT_EFDR); /* set GPIO5 to WDT0 */
92 } 97 }
93 98
94 outb_p(0x07, WDT_EFER); /* point to logical device number reg */ 99 outb_p(0x07, WDT_EFER); /* point to logical device number reg */
diff --git a/drivers/watchdog/w83697ug_wdt.c b/drivers/watchdog/w83697ug_wdt.c
index 883b5f79673a..a6c12dec91a1 100644
--- a/drivers/watchdog/w83697ug_wdt.c
+++ b/drivers/watchdog/w83697ug_wdt.c
@@ -149,8 +149,10 @@ static void wdt_ctrl(int timeout)
149{ 149{
150 spin_lock(&io_lock); 150 spin_lock(&io_lock);
151 151
152 if (w83697ug_select_wd_register() < 0) 152 if (w83697ug_select_wd_register() < 0) {
153 spin_unlock(&io_lock);
153 return; 154 return;
155 }
154 156
155 outb_p(0xF4, WDT_EFER); /* Select CRF4 */ 157 outb_p(0xF4, WDT_EFER); /* Select CRF4 */
156 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF4 */ 158 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF4 */
diff --git a/drivers/watchdog/wdrtas.c b/drivers/watchdog/wdrtas.c
index a4fe7a38d9b0..3bde56bce63a 100644
--- a/drivers/watchdog/wdrtas.c
+++ b/drivers/watchdog/wdrtas.c
@@ -218,16 +218,14 @@ static void wdrtas_timer_keepalive(void)
218 */ 218 */
219static int wdrtas_get_temperature(void) 219static int wdrtas_get_temperature(void)
220{ 220{
221 long result; 221 int result;
222 int temperature = 0; 222 int temperature = 0;
223 223
224 result = rtas_call(wdrtas_token_get_sensor_state, 2, 2, 224 result = rtas_get_sensor(WDRTAS_THERMAL_SENSOR, 0, &temperature);
225 (void *)__pa(&temperature),
226 WDRTAS_THERMAL_SENSOR, 0);
227 225
228 if (result < 0) 226 if (result < 0)
229 printk(KERN_WARNING "wdrtas: reading the thermal sensor " 227 printk(KERN_WARNING "wdrtas: reading the thermal sensor "
230 "faild: %li\n", result); 228 "failed: %i\n", result);
231 else 229 else
232 temperature = ((temperature * 9) / 5) + 32; /* fahrenheit */ 230 temperature = ((temperature * 9) / 5) + 32; /* fahrenheit */
233 231
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 891d2e90753a..abad71b1632b 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -927,9 +927,9 @@ static struct irq_chip xen_dynamic_chip __read_mostly = {
927void __init xen_init_IRQ(void) 927void __init xen_init_IRQ(void)
928{ 928{
929 int i; 929 int i;
930 size_t size = nr_cpu_ids * sizeof(struct cpu_evtchn_s);
931 930
932 cpu_evtchn_mask_p = alloc_bootmem(size); 931 cpu_evtchn_mask_p = kcalloc(nr_cpu_ids, sizeof(struct cpu_evtchn_s),
932 GFP_KERNEL);
933 BUG_ON(cpu_evtchn_mask_p == NULL); 933 BUG_ON(cpu_evtchn_mask_p == NULL);
934 934
935 init_evtchn_cpu_bindings(); 935 init_evtchn_cpu_bindings();
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index aad92f0a1048..6910a98bd73c 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -13,6 +13,7 @@
13#include <linux/parser.h> 13#include <linux/parser.h>
14#include <linux/mount.h> 14#include <linux/mount.h>
15#include <linux/seq_file.h> 15#include <linux/seq_file.h>
16#include <linux/smp_lock.h>
16#include <linux/statfs.h> 17#include <linux/statfs.h>
17#include "adfs.h" 18#include "adfs.h"
18#include "dir_f.h" 19#include "dir_f.h"
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 9bd757774c9e..88067f36e5e7 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -564,7 +564,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
564static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) 564static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
565{ 565{
566 struct afs_vnode *vnode, *dir; 566 struct afs_vnode *vnode, *dir;
567 struct afs_fid fid; 567 struct afs_fid uninitialized_var(fid);
568 struct dentry *parent; 568 struct dentry *parent;
569 struct key *key; 569 struct key *key;
570 void *dir_version; 570 void *dir_version;
diff --git a/fs/afs/flock.c b/fs/afs/flock.c
index 210acafe4a9b..3ff8bdd18fb3 100644
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -432,7 +432,6 @@ vfs_rejected_lock:
432 list_del_init(&fl->fl_u.afs.link); 432 list_del_init(&fl->fl_u.afs.link);
433 if (list_empty(&vnode->granted_locks)) 433 if (list_empty(&vnode->granted_locks))
434 afs_defer_unlock(vnode, key); 434 afs_defer_unlock(vnode, key);
435 spin_unlock(&vnode->lock);
436 goto abort_attempt; 435 goto abort_attempt;
437} 436}
438 437
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index c52be53f6946..5ffb570cd3a8 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -17,7 +17,6 @@
17#include <linux/pagemap.h> 17#include <linux/pagemap.h>
18#include <linux/mount.h> 18#include <linux/mount.h>
19#include <linux/namei.h> 19#include <linux/namei.h>
20#include <linux/mnt_namespace.h>
21#include "internal.h" 20#include "internal.h"
22 21
23 22
diff --git a/fs/afs/super.c b/fs/afs/super.c
index ad0514d0115f..e1ea1c240b6a 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/smp_lock.h>
21#include <linux/fs.h> 22#include <linux/fs.h>
22#include <linux/pagemap.h> 23#include <linux/pagemap.h>
23#include <linux/parser.h> 24#include <linux/parser.h>
diff --git a/fs/aio.c b/fs/aio.c
index 76da12537956..d065b2c3273e 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -485,6 +485,8 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)
485{ 485{
486 assert_spin_locked(&ctx->ctx_lock); 486 assert_spin_locked(&ctx->ctx_lock);
487 487
488 if (req->ki_eventfd != NULL)
489 eventfd_ctx_put(req->ki_eventfd);
488 if (req->ki_dtor) 490 if (req->ki_dtor)
489 req->ki_dtor(req); 491 req->ki_dtor(req);
490 if (req->ki_iovec != &req->ki_inline_vec) 492 if (req->ki_iovec != &req->ki_inline_vec)
@@ -509,8 +511,6 @@ static void aio_fput_routine(struct work_struct *data)
509 /* Complete the fput(s) */ 511 /* Complete the fput(s) */
510 if (req->ki_filp != NULL) 512 if (req->ki_filp != NULL)
511 __fput(req->ki_filp); 513 __fput(req->ki_filp);
512 if (req->ki_eventfd != NULL)
513 __fput(req->ki_eventfd);
514 514
515 /* Link the iocb into the context's free list */ 515 /* Link the iocb into the context's free list */
516 spin_lock_irq(&ctx->ctx_lock); 516 spin_lock_irq(&ctx->ctx_lock);
@@ -528,8 +528,6 @@ static void aio_fput_routine(struct work_struct *data)
528 */ 528 */
529static int __aio_put_req(struct kioctx *ctx, struct kiocb *req) 529static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
530{ 530{
531 int schedule_putreq = 0;
532
533 dprintk(KERN_DEBUG "aio_put(%p): f_count=%ld\n", 531 dprintk(KERN_DEBUG "aio_put(%p): f_count=%ld\n",
534 req, atomic_long_read(&req->ki_filp->f_count)); 532 req, atomic_long_read(&req->ki_filp->f_count));
535 533
@@ -549,24 +547,16 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
549 * we would not be holding the last reference to the file*, so 547 * we would not be holding the last reference to the file*, so
550 * this function will be executed w/out any aio kthread wakeup. 548 * this function will be executed w/out any aio kthread wakeup.
551 */ 549 */
552 if (unlikely(atomic_long_dec_and_test(&req->ki_filp->f_count))) 550 if (unlikely(atomic_long_dec_and_test(&req->ki_filp->f_count))) {
553 schedule_putreq++;
554 else
555 req->ki_filp = NULL;
556 if (req->ki_eventfd != NULL) {
557 if (unlikely(atomic_long_dec_and_test(&req->ki_eventfd->f_count)))
558 schedule_putreq++;
559 else
560 req->ki_eventfd = NULL;
561 }
562 if (unlikely(schedule_putreq)) {
563 get_ioctx(ctx); 551 get_ioctx(ctx);
564 spin_lock(&fput_lock); 552 spin_lock(&fput_lock);
565 list_add(&req->ki_list, &fput_head); 553 list_add(&req->ki_list, &fput_head);
566 spin_unlock(&fput_lock); 554 spin_unlock(&fput_lock);
567 queue_work(aio_wq, &fput_work); 555 queue_work(aio_wq, &fput_work);
568 } else 556 } else {
557 req->ki_filp = NULL;
569 really_put_req(ctx, req); 558 really_put_req(ctx, req);
559 }
570 return 1; 560 return 1;
571} 561}
572 562
@@ -1622,7 +1612,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1622 * an eventfd() fd, and will be signaled for each completed 1612 * an eventfd() fd, and will be signaled for each completed
1623 * event using the eventfd_signal() function. 1613 * event using the eventfd_signal() function.
1624 */ 1614 */
1625 req->ki_eventfd = eventfd_fget((int) iocb->aio_resfd); 1615 req->ki_eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd);
1626 if (IS_ERR(req->ki_eventfd)) { 1616 if (IS_ERR(req->ki_eventfd)) {
1627 ret = PTR_ERR(req->ki_eventfd); 1617 ret = PTR_ERR(req->ki_eventfd);
1628 req->ki_eventfd = NULL; 1618 req->ki_eventfd = NULL;
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index f3da2eb51f56..00bf8fcb245f 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -19,7 +19,6 @@
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/compat.h> 20#include <linux/compat.h>
21#include <linux/syscalls.h> 21#include <linux/syscalls.h>
22#include <linux/smp_lock.h>
23#include <linux/magic.h> 22#include <linux/magic.h>
24#include <linux/dcache.h> 23#include <linux/dcache.h>
25#include <linux/uaccess.h> 24#include <linux/uaccess.h>
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 54bd07d44e68..1e41aadb1068 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -8,7 +8,6 @@
8#include <linux/time.h> 8#include <linux/time.h>
9#include <linux/string.h> 9#include <linux/string.h>
10#include <linux/fs.h> 10#include <linux/fs.h>
11#include <linux/smp_lock.h>
12#include <linux/buffer_head.h> 11#include <linux/buffer_head.h>
13#include <linux/sched.h> 12#include <linux/sched.h>
14#include "bfs.h" 13#include "bfs.h"
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index 6a021265f018..88b9a3ff44e4 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/buffer_head.h> 13#include <linux/buffer_head.h>
14#include <linux/smp_lock.h>
15#include "bfs.h" 14#include "bfs.h"
16 15
17#undef DEBUG 16#undef DEBUG
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 9fa212b014a5..b7c1603cd4bd 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1522,11 +1522,11 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
1522 info->thread = NULL; 1522 info->thread = NULL;
1523 1523
1524 psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); 1524 psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
1525 fill_note(&info->psinfo, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo);
1526
1527 if (psinfo == NULL) 1525 if (psinfo == NULL)
1528 return 0; 1526 return 0;
1529 1527
1528 fill_note(&info->psinfo, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo);
1529
1530 /* 1530 /*
1531 * Figure out how many notes we're going to need for each thread. 1531 * Figure out how many notes we're going to need for each thread.
1532 */ 1532 */
@@ -1929,7 +1929,10 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
1929 elf = kmalloc(sizeof(*elf), GFP_KERNEL); 1929 elf = kmalloc(sizeof(*elf), GFP_KERNEL);
1930 if (!elf) 1930 if (!elf)
1931 goto out; 1931 goto out;
1932 1932 /*
1933 * The number of segs are recored into ELF header as 16bit value.
1934 * Please check DEFAULT_MAX_MAP_COUNT definition when you modify here.
1935 */
1933 segs = current->mm->map_count; 1936 segs = current->mm->map_count;
1934#ifdef ELF_CORE_EXTRA_PHDRS 1937#ifdef ELF_CORE_EXTRA_PHDRS
1935 segs += ELF_CORE_EXTRA_PHDRS; 1938 segs += ELF_CORE_EXTRA_PHDRS;
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index 31c46a241bac..49a34e7f7306 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * bio-integrity.c - bio data integrity extensions 2 * bio-integrity.c - bio data integrity extensions
3 * 3 *
4 * Copyright (C) 2007, 2008 Oracle Corporation 4 * Copyright (C) 2007, 2008, 2009 Oracle Corporation
5 * Written by: Martin K. Petersen <martin.petersen@oracle.com> 5 * Written by: Martin K. Petersen <martin.petersen@oracle.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
@@ -25,63 +25,121 @@
25#include <linux/bio.h> 25#include <linux/bio.h>
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27 27
28static struct kmem_cache *bio_integrity_slab __read_mostly; 28struct integrity_slab {
29static mempool_t *bio_integrity_pool; 29 struct kmem_cache *slab;
30static struct bio_set *integrity_bio_set; 30 unsigned short nr_vecs;
31 char name[8];
32};
33
34#define IS(x) { .nr_vecs = x, .name = "bip-"__stringify(x) }
35struct integrity_slab bip_slab[BIOVEC_NR_POOLS] __read_mostly = {
36 IS(1), IS(4), IS(16), IS(64), IS(128), IS(BIO_MAX_PAGES),
37};
38#undef IS
39
31static struct workqueue_struct *kintegrityd_wq; 40static struct workqueue_struct *kintegrityd_wq;
32 41
42static inline unsigned int vecs_to_idx(unsigned int nr)
43{
44 switch (nr) {
45 case 1:
46 return 0;
47 case 2 ... 4:
48 return 1;
49 case 5 ... 16:
50 return 2;
51 case 17 ... 64:
52 return 3;
53 case 65 ... 128:
54 return 4;
55 case 129 ... BIO_MAX_PAGES:
56 return 5;
57 default:
58 BUG();
59 }
60}
61
62static inline int use_bip_pool(unsigned int idx)
63{
64 if (idx == BIOVEC_NR_POOLS)
65 return 1;
66
67 return 0;
68}
69
33/** 70/**
34 * bio_integrity_alloc - Allocate integrity payload and attach it to bio 71 * bio_integrity_alloc_bioset - Allocate integrity payload and attach it to bio
35 * @bio: bio to attach integrity metadata to 72 * @bio: bio to attach integrity metadata to
36 * @gfp_mask: Memory allocation mask 73 * @gfp_mask: Memory allocation mask
37 * @nr_vecs: Number of integrity metadata scatter-gather elements 74 * @nr_vecs: Number of integrity metadata scatter-gather elements
75 * @bs: bio_set to allocate from
38 * 76 *
39 * Description: This function prepares a bio for attaching integrity 77 * Description: This function prepares a bio for attaching integrity
40 * metadata. nr_vecs specifies the maximum number of pages containing 78 * metadata. nr_vecs specifies the maximum number of pages containing
41 * integrity metadata that can be attached. 79 * integrity metadata that can be attached.
42 */ 80 */
43struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, 81struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio,
44 gfp_t gfp_mask, 82 gfp_t gfp_mask,
45 unsigned int nr_vecs) 83 unsigned int nr_vecs,
84 struct bio_set *bs)
46{ 85{
47 struct bio_integrity_payload *bip; 86 struct bio_integrity_payload *bip;
48 struct bio_vec *iv; 87 unsigned int idx = vecs_to_idx(nr_vecs);
49 unsigned long idx;
50 88
51 BUG_ON(bio == NULL); 89 BUG_ON(bio == NULL);
90 bip = NULL;
52 91
53 bip = mempool_alloc(bio_integrity_pool, gfp_mask); 92 /* Lower order allocations come straight from slab */
54 if (unlikely(bip == NULL)) { 93 if (!use_bip_pool(idx))
55 printk(KERN_ERR "%s: could not alloc bip\n", __func__); 94 bip = kmem_cache_alloc(bip_slab[idx].slab, gfp_mask);
56 return NULL;
57 }
58 95
59 memset(bip, 0, sizeof(*bip)); 96 /* Use mempool if lower order alloc failed or max vecs were requested */
97 if (bip == NULL) {
98 bip = mempool_alloc(bs->bio_integrity_pool, gfp_mask);
60 99
61 iv = bvec_alloc_bs(gfp_mask, nr_vecs, &idx, integrity_bio_set); 100 if (unlikely(bip == NULL)) {
62 if (unlikely(iv == NULL)) { 101 printk(KERN_ERR "%s: could not alloc bip\n", __func__);
63 printk(KERN_ERR "%s: could not alloc bip_vec\n", __func__); 102 return NULL;
64 mempool_free(bip, bio_integrity_pool); 103 }
65 return NULL;
66 } 104 }
67 105
68 bip->bip_pool = idx; 106 memset(bip, 0, sizeof(*bip));
69 bip->bip_vec = iv; 107
108 bip->bip_slab = idx;
70 bip->bip_bio = bio; 109 bip->bip_bio = bio;
71 bio->bi_integrity = bip; 110 bio->bi_integrity = bip;
72 111
73 return bip; 112 return bip;
74} 113}
114EXPORT_SYMBOL(bio_integrity_alloc_bioset);
115
116/**
117 * bio_integrity_alloc - Allocate integrity payload and attach it to bio
118 * @bio: bio to attach integrity metadata to
119 * @gfp_mask: Memory allocation mask
120 * @nr_vecs: Number of integrity metadata scatter-gather elements
121 *
122 * Description: This function prepares a bio for attaching integrity
123 * metadata. nr_vecs specifies the maximum number of pages containing
124 * integrity metadata that can be attached.
125 */
126struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
127 gfp_t gfp_mask,
128 unsigned int nr_vecs)
129{
130 return bio_integrity_alloc_bioset(bio, gfp_mask, nr_vecs, fs_bio_set);
131}
75EXPORT_SYMBOL(bio_integrity_alloc); 132EXPORT_SYMBOL(bio_integrity_alloc);
76 133
77/** 134/**
78 * bio_integrity_free - Free bio integrity payload 135 * bio_integrity_free - Free bio integrity payload
79 * @bio: bio containing bip to be freed 136 * @bio: bio containing bip to be freed
137 * @bs: bio_set this bio was allocated from
80 * 138 *
81 * Description: Used to free the integrity portion of a bio. Usually 139 * Description: Used to free the integrity portion of a bio. Usually
82 * called from bio_free(). 140 * called from bio_free().
83 */ 141 */
84void bio_integrity_free(struct bio *bio) 142void bio_integrity_free(struct bio *bio, struct bio_set *bs)
85{ 143{
86 struct bio_integrity_payload *bip = bio->bi_integrity; 144 struct bio_integrity_payload *bip = bio->bi_integrity;
87 145
@@ -92,8 +150,10 @@ void bio_integrity_free(struct bio *bio)
92 && bip->bip_buf != NULL) 150 && bip->bip_buf != NULL)
93 kfree(bip->bip_buf); 151 kfree(bip->bip_buf);
94 152
95 bvec_free_bs(integrity_bio_set, bip->bip_vec, bip->bip_pool); 153 if (use_bip_pool(bip->bip_slab))
96 mempool_free(bip, bio_integrity_pool); 154 mempool_free(bip, bs->bio_integrity_pool);
155 else
156 kmem_cache_free(bip_slab[bip->bip_slab].slab, bip);
97 157
98 bio->bi_integrity = NULL; 158 bio->bi_integrity = NULL;
99} 159}
@@ -114,7 +174,7 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
114 struct bio_integrity_payload *bip = bio->bi_integrity; 174 struct bio_integrity_payload *bip = bio->bi_integrity;
115 struct bio_vec *iv; 175 struct bio_vec *iv;
116 176
117 if (bip->bip_vcnt >= bvec_nr_vecs(bip->bip_pool)) { 177 if (bip->bip_vcnt >= bvec_nr_vecs(bip->bip_slab)) {
118 printk(KERN_ERR "%s: bip_vec full\n", __func__); 178 printk(KERN_ERR "%s: bip_vec full\n", __func__);
119 return 0; 179 return 0;
120 } 180 }
@@ -647,8 +707,8 @@ void bio_integrity_split(struct bio *bio, struct bio_pair *bp, int sectors)
647 bp->iv1 = bip->bip_vec[0]; 707 bp->iv1 = bip->bip_vec[0];
648 bp->iv2 = bip->bip_vec[0]; 708 bp->iv2 = bip->bip_vec[0];
649 709
650 bp->bip1.bip_vec = &bp->iv1; 710 bp->bip1.bip_vec[0] = bp->iv1;
651 bp->bip2.bip_vec = &bp->iv2; 711 bp->bip2.bip_vec[0] = bp->iv2;
652 712
653 bp->iv1.bv_len = sectors * bi->tuple_size; 713 bp->iv1.bv_len = sectors * bi->tuple_size;
654 bp->iv2.bv_offset += sectors * bi->tuple_size; 714 bp->iv2.bv_offset += sectors * bi->tuple_size;
@@ -667,17 +727,19 @@ EXPORT_SYMBOL(bio_integrity_split);
667 * @bio: New bio 727 * @bio: New bio
668 * @bio_src: Original bio 728 * @bio_src: Original bio
669 * @gfp_mask: Memory allocation mask 729 * @gfp_mask: Memory allocation mask
730 * @bs: bio_set to allocate bip from
670 * 731 *
671 * Description: Called to allocate a bip when cloning a bio 732 * Description: Called to allocate a bip when cloning a bio
672 */ 733 */
673int bio_integrity_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp_mask) 734int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
735 gfp_t gfp_mask, struct bio_set *bs)
674{ 736{
675 struct bio_integrity_payload *bip_src = bio_src->bi_integrity; 737 struct bio_integrity_payload *bip_src = bio_src->bi_integrity;
676 struct bio_integrity_payload *bip; 738 struct bio_integrity_payload *bip;
677 739
678 BUG_ON(bip_src == NULL); 740 BUG_ON(bip_src == NULL);
679 741
680 bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt); 742 bip = bio_integrity_alloc_bioset(bio, gfp_mask, bip_src->bip_vcnt, bs);
681 743
682 if (bip == NULL) 744 if (bip == NULL)
683 return -EIO; 745 return -EIO;
@@ -693,25 +755,43 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp_mask)
693} 755}
694EXPORT_SYMBOL(bio_integrity_clone); 756EXPORT_SYMBOL(bio_integrity_clone);
695 757
696static int __init bio_integrity_init(void) 758int bioset_integrity_create(struct bio_set *bs, int pool_size)
697{ 759{
698 kintegrityd_wq = create_workqueue("kintegrityd"); 760 unsigned int max_slab = vecs_to_idx(BIO_MAX_PAGES);
761
762 bs->bio_integrity_pool =
763 mempool_create_slab_pool(pool_size, bip_slab[max_slab].slab);
699 764
765 if (!bs->bio_integrity_pool)
766 return -1;
767
768 return 0;
769}
770EXPORT_SYMBOL(bioset_integrity_create);
771
772void bioset_integrity_free(struct bio_set *bs)
773{
774 if (bs->bio_integrity_pool)
775 mempool_destroy(bs->bio_integrity_pool);
776}
777EXPORT_SYMBOL(bioset_integrity_free);
778
779void __init bio_integrity_init(void)
780{
781 unsigned int i;
782
783 kintegrityd_wq = create_workqueue("kintegrityd");
700 if (!kintegrityd_wq) 784 if (!kintegrityd_wq)
701 panic("Failed to create kintegrityd\n"); 785 panic("Failed to create kintegrityd\n");
702 786
703 bio_integrity_slab = KMEM_CACHE(bio_integrity_payload, 787 for (i = 0 ; i < BIOVEC_NR_POOLS ; i++) {
704 SLAB_HWCACHE_ALIGN|SLAB_PANIC); 788 unsigned int size;
705 789
706 bio_integrity_pool = mempool_create_slab_pool(BIO_POOL_SIZE, 790 size = sizeof(struct bio_integrity_payload)
707 bio_integrity_slab); 791 + bip_slab[i].nr_vecs * sizeof(struct bio_vec);
708 if (!bio_integrity_pool)
709 panic("bio_integrity: can't allocate bip pool\n");
710 792
711 integrity_bio_set = bioset_create(BIO_POOL_SIZE, 0); 793 bip_slab[i].slab =
712 if (!integrity_bio_set) 794 kmem_cache_create(bip_slab[i].name, size, 0,
713 panic("bio_integrity: can't allocate bio_set\n"); 795 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
714 796 }
715 return 0;
716} 797}
717subsys_initcall(bio_integrity_init);
diff --git a/fs/bio.c b/fs/bio.c
index 24c914043532..76738005c8e8 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -238,7 +238,7 @@ void bio_free(struct bio *bio, struct bio_set *bs)
238 bvec_free_bs(bs, bio->bi_io_vec, BIO_POOL_IDX(bio)); 238 bvec_free_bs(bs, bio->bi_io_vec, BIO_POOL_IDX(bio));
239 239
240 if (bio_integrity(bio)) 240 if (bio_integrity(bio))
241 bio_integrity_free(bio); 241 bio_integrity_free(bio, bs);
242 242
243 /* 243 /*
244 * If we have front padding, adjust the bio pointer before freeing 244 * If we have front padding, adjust the bio pointer before freeing
@@ -341,7 +341,7 @@ struct bio *bio_alloc(gfp_t gfp_mask, int nr_iovecs)
341static void bio_kmalloc_destructor(struct bio *bio) 341static void bio_kmalloc_destructor(struct bio *bio)
342{ 342{
343 if (bio_integrity(bio)) 343 if (bio_integrity(bio))
344 bio_integrity_free(bio); 344 bio_integrity_free(bio, fs_bio_set);
345 kfree(bio); 345 kfree(bio);
346} 346}
347 347
@@ -472,7 +472,7 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
472 if (bio_integrity(bio)) { 472 if (bio_integrity(bio)) {
473 int ret; 473 int ret;
474 474
475 ret = bio_integrity_clone(b, bio, gfp_mask); 475 ret = bio_integrity_clone(b, bio, gfp_mask, fs_bio_set);
476 476
477 if (ret < 0) { 477 if (ret < 0) {
478 bio_put(b); 478 bio_put(b);
@@ -705,14 +705,13 @@ static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count,
705} 705}
706 706
707static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs, 707static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs,
708 struct sg_iovec *iov, int iov_count, int uncopy, 708 struct sg_iovec *iov, int iov_count,
709 int do_free_page) 709 int to_user, int from_user, int do_free_page)
710{ 710{
711 int ret = 0, i; 711 int ret = 0, i;
712 struct bio_vec *bvec; 712 struct bio_vec *bvec;
713 int iov_idx = 0; 713 int iov_idx = 0;
714 unsigned int iov_off = 0; 714 unsigned int iov_off = 0;
715 int read = bio_data_dir(bio) == READ;
716 715
717 __bio_for_each_segment(bvec, bio, i, 0) { 716 __bio_for_each_segment(bvec, bio, i, 0) {
718 char *bv_addr = page_address(bvec->bv_page); 717 char *bv_addr = page_address(bvec->bv_page);
@@ -727,13 +726,14 @@ static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs,
727 iov_addr = iov[iov_idx].iov_base + iov_off; 726 iov_addr = iov[iov_idx].iov_base + iov_off;
728 727
729 if (!ret) { 728 if (!ret) {
730 if (!read && !uncopy) 729 if (to_user)
731 ret = copy_from_user(bv_addr, iov_addr,
732 bytes);
733 if (read && uncopy)
734 ret = copy_to_user(iov_addr, bv_addr, 730 ret = copy_to_user(iov_addr, bv_addr,
735 bytes); 731 bytes);
736 732
733 if (from_user)
734 ret = copy_from_user(bv_addr, iov_addr,
735 bytes);
736
737 if (ret) 737 if (ret)
738 ret = -EFAULT; 738 ret = -EFAULT;
739 } 739 }
@@ -770,7 +770,8 @@ int bio_uncopy_user(struct bio *bio)
770 770
771 if (!bio_flagged(bio, BIO_NULL_MAPPED)) 771 if (!bio_flagged(bio, BIO_NULL_MAPPED))
772 ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs, 772 ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs,
773 bmd->nr_sgvecs, 1, bmd->is_our_pages); 773 bmd->nr_sgvecs, bio_data_dir(bio) == READ,
774 0, bmd->is_our_pages);
774 bio_free_map_data(bmd); 775 bio_free_map_data(bmd);
775 bio_put(bio); 776 bio_put(bio);
776 return ret; 777 return ret;
@@ -875,8 +876,9 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
875 /* 876 /*
876 * success 877 * success
877 */ 878 */
878 if (!write_to_vm && (!map_data || !map_data->null_mapped)) { 879 if ((!write_to_vm && (!map_data || !map_data->null_mapped)) ||
879 ret = __bio_copy_iov(bio, bio->bi_io_vec, iov, iov_count, 0, 0); 880 (map_data && map_data->from_user)) {
881 ret = __bio_copy_iov(bio, bio->bi_io_vec, iov, iov_count, 0, 1, 0);
880 if (ret) 882 if (ret)
881 goto cleanup; 883 goto cleanup;
882 } 884 }
@@ -1539,6 +1541,7 @@ void bioset_free(struct bio_set *bs)
1539 if (bs->bio_pool) 1541 if (bs->bio_pool)
1540 mempool_destroy(bs->bio_pool); 1542 mempool_destroy(bs->bio_pool);
1541 1543
1544 bioset_integrity_free(bs);
1542 biovec_free_pools(bs); 1545 biovec_free_pools(bs);
1543 bio_put_slab(bs); 1546 bio_put_slab(bs);
1544 1547
@@ -1579,6 +1582,9 @@ struct bio_set *bioset_create(unsigned int pool_size, unsigned int front_pad)
1579 if (!bs->bio_pool) 1582 if (!bs->bio_pool)
1580 goto bad; 1583 goto bad;
1581 1584
1585 if (bioset_integrity_create(bs, pool_size))
1586 goto bad;
1587
1582 if (!biovec_create_pools(bs, pool_size)) 1588 if (!biovec_create_pools(bs, pool_size))
1583 return bs; 1589 return bs;
1584 1590
@@ -1616,6 +1622,7 @@ static int __init init_bio(void)
1616 if (!bio_slabs) 1622 if (!bio_slabs)
1617 panic("bio: can't allocate bios\n"); 1623 panic("bio: can't allocate bios\n");
1618 1624
1625 bio_integrity_init();
1619 biovec_init_slabs(); 1626 biovec_init_slabs();
1620 1627
1621 fs_bio_set = bioset_create(BIO_POOL_SIZE, 0); 1628 fs_bio_set = bioset_create(BIO_POOL_SIZE, 0);
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 7f88628a1a72..6e4f6c50a120 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -299,8 +299,8 @@ int btrfs_start_workers(struct btrfs_workers *workers, int num_workers)
299 "btrfs-%s-%d", workers->name, 299 "btrfs-%s-%d", workers->name,
300 workers->num_workers + i); 300 workers->num_workers + i);
301 if (IS_ERR(worker->task)) { 301 if (IS_ERR(worker->task)) {
302 kfree(worker);
303 ret = PTR_ERR(worker->task); 302 ret = PTR_ERR(worker->task);
303 kfree(worker);
304 goto fail; 304 goto fail;
305 } 305 }
306 306
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index de1e2fd32080..9d8ba4d54a37 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -26,7 +26,6 @@
26#include <linux/time.h> 26#include <linux/time.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/smp_lock.h>
30#include <linux/backing-dev.h> 29#include <linux/backing-dev.h>
31#include <linux/mpage.h> 30#include <linux/mpage.h>
32#include <linux/swap.h> 31#include <linux/swap.h>
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 2779c2f5360a..98a873838717 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2074,8 +2074,7 @@ static inline int btrfs_insert_empty_item(struct btrfs_trans_handle *trans,
2074int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path); 2074int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
2075int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path); 2075int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path);
2076int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf); 2076int btrfs_leaf_free_space(struct btrfs_root *root, struct extent_buffer *leaf);
2077int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root 2077int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref);
2078 *root);
2079int btrfs_drop_subtree(struct btrfs_trans_handle *trans, 2078int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
2080 struct btrfs_root *root, 2079 struct btrfs_root *root,
2081 struct extent_buffer *node, 2080 struct extent_buffer *node,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index edc7d208c5ce..a5aca3997d42 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -990,15 +990,13 @@ static inline int extent_ref_type(u64 parent, u64 owner)
990 return type; 990 return type;
991} 991}
992 992
993static int find_next_key(struct btrfs_path *path, struct btrfs_key *key) 993static int find_next_key(struct btrfs_path *path, int level,
994 struct btrfs_key *key)
994 995
995{ 996{
996 int level; 997 for (; level < BTRFS_MAX_LEVEL; level++) {
997 BUG_ON(!path->keep_locks);
998 for (level = 0; level < BTRFS_MAX_LEVEL; level++) {
999 if (!path->nodes[level]) 998 if (!path->nodes[level])
1000 break; 999 break;
1001 btrfs_assert_tree_locked(path->nodes[level]);
1002 if (path->slots[level] + 1 >= 1000 if (path->slots[level] + 1 >=
1003 btrfs_header_nritems(path->nodes[level])) 1001 btrfs_header_nritems(path->nodes[level]))
1004 continue; 1002 continue;
@@ -1158,7 +1156,8 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
1158 * For simplicity, we just do not add new inline back 1156 * For simplicity, we just do not add new inline back
1159 * ref if there is any kind of item for this block 1157 * ref if there is any kind of item for this block
1160 */ 1158 */
1161 if (find_next_key(path, &key) == 0 && key.objectid == bytenr && 1159 if (find_next_key(path, 0, &key) == 0 &&
1160 key.objectid == bytenr &&
1162 key.type < BTRFS_BLOCK_GROUP_ITEM_KEY) { 1161 key.type < BTRFS_BLOCK_GROUP_ITEM_KEY) {
1163 err = -EAGAIN; 1162 err = -EAGAIN;
1164 goto out; 1163 goto out;
@@ -2697,7 +2696,7 @@ again:
2697 2696
2698 printk(KERN_ERR "no space left, need %llu, %llu delalloc bytes" 2697 printk(KERN_ERR "no space left, need %llu, %llu delalloc bytes"
2699 ", %llu bytes_used, %llu bytes_reserved, " 2698 ", %llu bytes_used, %llu bytes_reserved, "
2700 "%llu bytes_pinned, %llu bytes_readonly, %llu may use" 2699 "%llu bytes_pinned, %llu bytes_readonly, %llu may use "
2701 "%llu total\n", (unsigned long long)bytes, 2700 "%llu total\n", (unsigned long long)bytes,
2702 (unsigned long long)data_sinfo->bytes_delalloc, 2701 (unsigned long long)data_sinfo->bytes_delalloc,
2703 (unsigned long long)data_sinfo->bytes_used, 2702 (unsigned long long)data_sinfo->bytes_used,
@@ -4128,6 +4127,7 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
4128 return buf; 4127 return buf;
4129} 4128}
4130 4129
4130#if 0
4131int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans, 4131int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
4132 struct btrfs_root *root, struct extent_buffer *leaf) 4132 struct btrfs_root *root, struct extent_buffer *leaf)
4133{ 4133{
@@ -4171,8 +4171,6 @@ int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
4171 return 0; 4171 return 0;
4172} 4172}
4173 4173
4174#if 0
4175
4176static noinline int cache_drop_leaf_ref(struct btrfs_trans_handle *trans, 4174static noinline int cache_drop_leaf_ref(struct btrfs_trans_handle *trans,
4177 struct btrfs_root *root, 4175 struct btrfs_root *root,
4178 struct btrfs_leaf_ref *ref) 4176 struct btrfs_leaf_ref *ref)
@@ -4553,262 +4551,471 @@ out:
4553} 4551}
4554#endif 4552#endif
4555 4553
4554struct walk_control {
4555 u64 refs[BTRFS_MAX_LEVEL];
4556 u64 flags[BTRFS_MAX_LEVEL];
4557 struct btrfs_key update_progress;
4558 int stage;
4559 int level;
4560 int shared_level;
4561 int update_ref;
4562 int keep_locks;
4563};
4564
4565#define DROP_REFERENCE 1
4566#define UPDATE_BACKREF 2
4567
4556/* 4568/*
4557 * helper function for drop_subtree, this function is similar to 4569 * hepler to process tree block while walking down the tree.
4558 * walk_down_tree. The main difference is that it checks reference 4570 *
4559 * counts while tree blocks are locked. 4571 * when wc->stage == DROP_REFERENCE, this function checks
4572 * reference count of the block. if the block is shared and
4573 * we need update back refs for the subtree rooted at the
4574 * block, this function changes wc->stage to UPDATE_BACKREF
4575 *
4576 * when wc->stage == UPDATE_BACKREF, this function updates
4577 * back refs for pointers in the block.
4578 *
4579 * NOTE: return value 1 means we should stop walking down.
4560 */ 4580 */
4561static noinline int walk_down_tree(struct btrfs_trans_handle *trans, 4581static noinline int walk_down_proc(struct btrfs_trans_handle *trans,
4562 struct btrfs_root *root, 4582 struct btrfs_root *root,
4563 struct btrfs_path *path, int *level) 4583 struct btrfs_path *path,
4584 struct walk_control *wc)
4564{ 4585{
4565 struct extent_buffer *next; 4586 int level = wc->level;
4566 struct extent_buffer *cur; 4587 struct extent_buffer *eb = path->nodes[level];
4567 struct extent_buffer *parent; 4588 struct btrfs_key key;
4568 u64 bytenr; 4589 u64 flag = BTRFS_BLOCK_FLAG_FULL_BACKREF;
4569 u64 ptr_gen;
4570 u64 refs;
4571 u64 flags;
4572 u32 blocksize;
4573 int ret; 4590 int ret;
4574 4591
4575 cur = path->nodes[*level]; 4592 if (wc->stage == UPDATE_BACKREF &&
4576 ret = btrfs_lookup_extent_info(trans, root, cur->start, cur->len, 4593 btrfs_header_owner(eb) != root->root_key.objectid)
4577 &refs, &flags); 4594 return 1;
4578 BUG_ON(ret);
4579 if (refs > 1)
4580 goto out;
4581 4595
4582 BUG_ON(!(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)); 4596 /*
4597 * when reference count of tree block is 1, it won't increase
4598 * again. once full backref flag is set, we never clear it.
4599 */
4600 if ((wc->stage == DROP_REFERENCE && wc->refs[level] != 1) ||
4601 (wc->stage == UPDATE_BACKREF && !(wc->flags[level] & flag))) {
4602 BUG_ON(!path->locks[level]);
4603 ret = btrfs_lookup_extent_info(trans, root,
4604 eb->start, eb->len,
4605 &wc->refs[level],
4606 &wc->flags[level]);
4607 BUG_ON(ret);
4608 BUG_ON(wc->refs[level] == 0);
4609 }
4583 4610
4584 while (*level >= 0) { 4611 if (wc->stage == DROP_REFERENCE &&
4585 cur = path->nodes[*level]; 4612 wc->update_ref && wc->refs[level] > 1) {
4586 if (*level == 0) { 4613 BUG_ON(eb == root->node);
4587 ret = btrfs_drop_leaf_ref(trans, root, cur); 4614 BUG_ON(path->slots[level] > 0);
4588 BUG_ON(ret); 4615 if (level == 0)
4589 clean_tree_block(trans, root, cur); 4616 btrfs_item_key_to_cpu(eb, &key, path->slots[level]);
4590 break; 4617 else
4591 } 4618 btrfs_node_key_to_cpu(eb, &key, path->slots[level]);
4592 if (path->slots[*level] >= btrfs_header_nritems(cur)) { 4619 if (btrfs_header_owner(eb) == root->root_key.objectid &&
4593 clean_tree_block(trans, root, cur); 4620 btrfs_comp_cpu_keys(&key, &wc->update_progress) >= 0) {
4594 break; 4621 wc->stage = UPDATE_BACKREF;
4622 wc->shared_level = level;
4595 } 4623 }
4624 }
4596 4625
4597 bytenr = btrfs_node_blockptr(cur, path->slots[*level]); 4626 if (wc->stage == DROP_REFERENCE) {
4598 blocksize = btrfs_level_size(root, *level - 1); 4627 if (wc->refs[level] > 1)
4599 ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]); 4628 return 1;
4600 4629
4601 next = read_tree_block(root, bytenr, blocksize, ptr_gen); 4630 if (path->locks[level] && !wc->keep_locks) {
4602 btrfs_tree_lock(next); 4631 btrfs_tree_unlock(eb);
4603 btrfs_set_lock_blocking(next); 4632 path->locks[level] = 0;
4633 }
4634 return 0;
4635 }
4604 4636
4605 ret = btrfs_lookup_extent_info(trans, root, bytenr, blocksize, 4637 /* wc->stage == UPDATE_BACKREF */
4606 &refs, &flags); 4638 if (!(wc->flags[level] & flag)) {
4639 BUG_ON(!path->locks[level]);
4640 ret = btrfs_inc_ref(trans, root, eb, 1);
4607 BUG_ON(ret); 4641 BUG_ON(ret);
4608 if (refs > 1) { 4642 ret = btrfs_dec_ref(trans, root, eb, 0);
4609 parent = path->nodes[*level]; 4643 BUG_ON(ret);
4610 ret = btrfs_free_extent(trans, root, bytenr, 4644 ret = btrfs_set_disk_extent_flags(trans, root, eb->start,
4611 blocksize, parent->start, 4645 eb->len, flag, 0);
4612 btrfs_header_owner(parent), 4646 BUG_ON(ret);
4613 *level - 1, 0); 4647 wc->flags[level] |= flag;
4648 }
4649
4650 /*
4651 * the block is shared by multiple trees, so it's not good to
4652 * keep the tree lock
4653 */
4654 if (path->locks[level] && level > 0) {
4655 btrfs_tree_unlock(eb);
4656 path->locks[level] = 0;
4657 }
4658 return 0;
4659}
4660
4661/*
4662 * hepler to process tree block while walking up the tree.
4663 *
4664 * when wc->stage == DROP_REFERENCE, this function drops
4665 * reference count on the block.
4666 *
4667 * when wc->stage == UPDATE_BACKREF, this function changes
4668 * wc->stage back to DROP_REFERENCE if we changed wc->stage
4669 * to UPDATE_BACKREF previously while processing the block.
4670 *
4671 * NOTE: return value 1 means we should stop walking up.
4672 */
4673static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
4674 struct btrfs_root *root,
4675 struct btrfs_path *path,
4676 struct walk_control *wc)
4677{
4678 int ret = 0;
4679 int level = wc->level;
4680 struct extent_buffer *eb = path->nodes[level];
4681 u64 parent = 0;
4682
4683 if (wc->stage == UPDATE_BACKREF) {
4684 BUG_ON(wc->shared_level < level);
4685 if (level < wc->shared_level)
4686 goto out;
4687
4688 BUG_ON(wc->refs[level] <= 1);
4689 ret = find_next_key(path, level + 1, &wc->update_progress);
4690 if (ret > 0)
4691 wc->update_ref = 0;
4692
4693 wc->stage = DROP_REFERENCE;
4694 wc->shared_level = -1;
4695 path->slots[level] = 0;
4696
4697 /*
4698 * check reference count again if the block isn't locked.
4699 * we should start walking down the tree again if reference
4700 * count is one.
4701 */
4702 if (!path->locks[level]) {
4703 BUG_ON(level == 0);
4704 btrfs_tree_lock(eb);
4705 btrfs_set_lock_blocking(eb);
4706 path->locks[level] = 1;
4707
4708 ret = btrfs_lookup_extent_info(trans, root,
4709 eb->start, eb->len,
4710 &wc->refs[level],
4711 &wc->flags[level]);
4614 BUG_ON(ret); 4712 BUG_ON(ret);
4615 path->slots[*level]++; 4713 BUG_ON(wc->refs[level] == 0);
4616 btrfs_tree_unlock(next); 4714 if (wc->refs[level] == 1) {
4617 free_extent_buffer(next); 4715 btrfs_tree_unlock(eb);
4618 continue; 4716 path->locks[level] = 0;
4717 return 1;
4718 }
4719 } else {
4720 BUG_ON(level != 0);
4619 } 4721 }
4722 }
4620 4723
4621 BUG_ON(!(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)); 4724 /* wc->stage == DROP_REFERENCE */
4725 BUG_ON(wc->refs[level] > 1 && !path->locks[level]);
4622 4726
4623 *level = btrfs_header_level(next); 4727 if (wc->refs[level] == 1) {
4624 path->nodes[*level] = next; 4728 if (level == 0) {
4625 path->slots[*level] = 0; 4729 if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF)
4626 path->locks[*level] = 1; 4730 ret = btrfs_dec_ref(trans, root, eb, 1);
4627 cond_resched(); 4731 else
4732 ret = btrfs_dec_ref(trans, root, eb, 0);
4733 BUG_ON(ret);
4734 }
4735 /* make block locked assertion in clean_tree_block happy */
4736 if (!path->locks[level] &&
4737 btrfs_header_generation(eb) == trans->transid) {
4738 btrfs_tree_lock(eb);
4739 btrfs_set_lock_blocking(eb);
4740 path->locks[level] = 1;
4741 }
4742 clean_tree_block(trans, root, eb);
4743 }
4744
4745 if (eb == root->node) {
4746 if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF)
4747 parent = eb->start;
4748 else
4749 BUG_ON(root->root_key.objectid !=
4750 btrfs_header_owner(eb));
4751 } else {
4752 if (wc->flags[level + 1] & BTRFS_BLOCK_FLAG_FULL_BACKREF)
4753 parent = path->nodes[level + 1]->start;
4754 else
4755 BUG_ON(root->root_key.objectid !=
4756 btrfs_header_owner(path->nodes[level + 1]));
4628 } 4757 }
4629out:
4630 if (path->nodes[*level] == root->node)
4631 parent = path->nodes[*level];
4632 else
4633 parent = path->nodes[*level + 1];
4634 bytenr = path->nodes[*level]->start;
4635 blocksize = path->nodes[*level]->len;
4636 4758
4637 ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent->start, 4759 ret = btrfs_free_extent(trans, root, eb->start, eb->len, parent,
4638 btrfs_header_owner(parent), *level, 0); 4760 root->root_key.objectid, level, 0);
4639 BUG_ON(ret); 4761 BUG_ON(ret);
4762out:
4763 wc->refs[level] = 0;
4764 wc->flags[level] = 0;
4765 return ret;
4766}
4767
4768static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
4769 struct btrfs_root *root,
4770 struct btrfs_path *path,
4771 struct walk_control *wc)
4772{
4773 struct extent_buffer *next;
4774 struct extent_buffer *cur;
4775 u64 bytenr;
4776 u64 ptr_gen;
4777 u32 blocksize;
4778 int level = wc->level;
4779 int ret;
4780
4781 while (level >= 0) {
4782 cur = path->nodes[level];
4783 BUG_ON(path->slots[level] >= btrfs_header_nritems(cur));
4640 4784
4641 if (path->locks[*level]) { 4785 ret = walk_down_proc(trans, root, path, wc);
4642 btrfs_tree_unlock(path->nodes[*level]); 4786 if (ret > 0)
4643 path->locks[*level] = 0; 4787 break;
4788
4789 if (level == 0)
4790 break;
4791
4792 bytenr = btrfs_node_blockptr(cur, path->slots[level]);
4793 blocksize = btrfs_level_size(root, level - 1);
4794 ptr_gen = btrfs_node_ptr_generation(cur, path->slots[level]);
4795
4796 next = read_tree_block(root, bytenr, blocksize, ptr_gen);
4797 btrfs_tree_lock(next);
4798 btrfs_set_lock_blocking(next);
4799
4800 level--;
4801 BUG_ON(level != btrfs_header_level(next));
4802 path->nodes[level] = next;
4803 path->slots[level] = 0;
4804 path->locks[level] = 1;
4805 wc->level = level;
4644 } 4806 }
4645 free_extent_buffer(path->nodes[*level]);
4646 path->nodes[*level] = NULL;
4647 *level += 1;
4648 cond_resched();
4649 return 0; 4807 return 0;
4650} 4808}
4651 4809
4652/*
4653 * helper for dropping snapshots. This walks back up the tree in the path
4654 * to find the first node higher up where we haven't yet gone through
4655 * all the slots
4656 */
4657static noinline int walk_up_tree(struct btrfs_trans_handle *trans, 4810static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
4658 struct btrfs_root *root, 4811 struct btrfs_root *root,
4659 struct btrfs_path *path, 4812 struct btrfs_path *path,
4660 int *level, int max_level) 4813 struct walk_control *wc, int max_level)
4661{ 4814{
4662 struct btrfs_root_item *root_item = &root->root_item; 4815 int level = wc->level;
4663 int i;
4664 int slot;
4665 int ret; 4816 int ret;
4666 4817
4667 for (i = *level; i < max_level && path->nodes[i]; i++) { 4818 path->slots[level] = btrfs_header_nritems(path->nodes[level]);
4668 slot = path->slots[i]; 4819 while (level < max_level && path->nodes[level]) {
4669 if (slot + 1 < btrfs_header_nritems(path->nodes[i])) { 4820 wc->level = level;
4670 /* 4821 if (path->slots[level] + 1 <
4671 * there is more work to do in this level. 4822 btrfs_header_nritems(path->nodes[level])) {
4672 * Update the drop_progress marker to reflect 4823 path->slots[level]++;
4673 * the work we've done so far, and then bump
4674 * the slot number
4675 */
4676 path->slots[i]++;
4677 WARN_ON(*level == 0);
4678 if (max_level == BTRFS_MAX_LEVEL) {
4679 btrfs_node_key(path->nodes[i],
4680 &root_item->drop_progress,
4681 path->slots[i]);
4682 root_item->drop_level = i;
4683 }
4684 *level = i;
4685 return 0; 4824 return 0;
4686 } else { 4825 } else {
4687 struct extent_buffer *parent; 4826 ret = walk_up_proc(trans, root, path, wc);
4688 4827 if (ret > 0)
4689 /* 4828 return 0;
4690 * this whole node is done, free our reference
4691 * on it and go up one level
4692 */
4693 if (path->nodes[*level] == root->node)
4694 parent = path->nodes[*level];
4695 else
4696 parent = path->nodes[*level + 1];
4697 4829
4698 clean_tree_block(trans, root, path->nodes[i]); 4830 if (path->locks[level]) {
4699 ret = btrfs_free_extent(trans, root, 4831 btrfs_tree_unlock(path->nodes[level]);
4700 path->nodes[i]->start, 4832 path->locks[level] = 0;
4701 path->nodes[i]->len,
4702 parent->start,
4703 btrfs_header_owner(parent),
4704 *level, 0);
4705 BUG_ON(ret);
4706 if (path->locks[*level]) {
4707 btrfs_tree_unlock(path->nodes[i]);
4708 path->locks[i] = 0;
4709 } 4833 }
4710 free_extent_buffer(path->nodes[i]); 4834 free_extent_buffer(path->nodes[level]);
4711 path->nodes[i] = NULL; 4835 path->nodes[level] = NULL;
4712 *level = i + 1; 4836 level++;
4713 } 4837 }
4714 } 4838 }
4715 return 1; 4839 return 1;
4716} 4840}
4717 4841
4718/* 4842/*
4719 * drop the reference count on the tree rooted at 'snap'. This traverses 4843 * drop a subvolume tree.
4720 * the tree freeing any blocks that have a ref count of zero after being 4844 *
4721 * decremented. 4845 * this function traverses the tree freeing any blocks that only
4846 * referenced by the tree.
4847 *
4848 * when a shared tree block is found. this function decreases its
4849 * reference count by one. if update_ref is true, this function
4850 * also make sure backrefs for the shared block and all lower level
4851 * blocks are properly updated.
4722 */ 4852 */
4723int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root 4853int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref)
4724 *root)
4725{ 4854{
4726 int ret = 0;
4727 int wret;
4728 int level;
4729 struct btrfs_path *path; 4855 struct btrfs_path *path;
4730 int update_count; 4856 struct btrfs_trans_handle *trans;
4857 struct btrfs_root *tree_root = root->fs_info->tree_root;
4731 struct btrfs_root_item *root_item = &root->root_item; 4858 struct btrfs_root_item *root_item = &root->root_item;
4859 struct walk_control *wc;
4860 struct btrfs_key key;
4861 int err = 0;
4862 int ret;
4863 int level;
4732 4864
4733 path = btrfs_alloc_path(); 4865 path = btrfs_alloc_path();
4734 BUG_ON(!path); 4866 BUG_ON(!path);
4735 4867
4736 level = btrfs_header_level(root->node); 4868 wc = kzalloc(sizeof(*wc), GFP_NOFS);
4869 BUG_ON(!wc);
4870
4871 trans = btrfs_start_transaction(tree_root, 1);
4872
4737 if (btrfs_disk_key_objectid(&root_item->drop_progress) == 0) { 4873 if (btrfs_disk_key_objectid(&root_item->drop_progress) == 0) {
4874 level = btrfs_header_level(root->node);
4738 path->nodes[level] = btrfs_lock_root_node(root); 4875 path->nodes[level] = btrfs_lock_root_node(root);
4739 btrfs_set_lock_blocking(path->nodes[level]); 4876 btrfs_set_lock_blocking(path->nodes[level]);
4740 path->slots[level] = 0; 4877 path->slots[level] = 0;
4741 path->locks[level] = 1; 4878 path->locks[level] = 1;
4879 memset(&wc->update_progress, 0,
4880 sizeof(wc->update_progress));
4742 } else { 4881 } else {
4743 struct btrfs_key key;
4744 struct btrfs_disk_key found_key;
4745 struct extent_buffer *node;
4746
4747 btrfs_disk_key_to_cpu(&key, &root_item->drop_progress); 4882 btrfs_disk_key_to_cpu(&key, &root_item->drop_progress);
4883 memcpy(&wc->update_progress, &key,
4884 sizeof(wc->update_progress));
4885
4748 level = root_item->drop_level; 4886 level = root_item->drop_level;
4887 BUG_ON(level == 0);
4749 path->lowest_level = level; 4888 path->lowest_level = level;
4750 wret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 4889 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
4751 if (wret < 0) { 4890 path->lowest_level = 0;
4752 ret = wret; 4891 if (ret < 0) {
4892 err = ret;
4753 goto out; 4893 goto out;
4754 } 4894 }
4755 node = path->nodes[level]; 4895 btrfs_node_key_to_cpu(path->nodes[level], &key,
4756 btrfs_node_key(node, &found_key, path->slots[level]); 4896 path->slots[level]);
4757 WARN_ON(memcmp(&found_key, &root_item->drop_progress, 4897 WARN_ON(memcmp(&key, &wc->update_progress, sizeof(key)));
4758 sizeof(found_key))); 4898
4759 /* 4899 /*
4760 * unlock our path, this is safe because only this 4900 * unlock our path, this is safe because only this
4761 * function is allowed to delete this snapshot 4901 * function is allowed to delete this snapshot
4762 */ 4902 */
4763 btrfs_unlock_up_safe(path, 0); 4903 btrfs_unlock_up_safe(path, 0);
4904
4905 level = btrfs_header_level(root->node);
4906 while (1) {
4907 btrfs_tree_lock(path->nodes[level]);
4908 btrfs_set_lock_blocking(path->nodes[level]);
4909
4910 ret = btrfs_lookup_extent_info(trans, root,
4911 path->nodes[level]->start,
4912 path->nodes[level]->len,
4913 &wc->refs[level],
4914 &wc->flags[level]);
4915 BUG_ON(ret);
4916 BUG_ON(wc->refs[level] == 0);
4917
4918 if (level == root_item->drop_level)
4919 break;
4920
4921 btrfs_tree_unlock(path->nodes[level]);
4922 WARN_ON(wc->refs[level] != 1);
4923 level--;
4924 }
4764 } 4925 }
4926
4927 wc->level = level;
4928 wc->shared_level = -1;
4929 wc->stage = DROP_REFERENCE;
4930 wc->update_ref = update_ref;
4931 wc->keep_locks = 0;
4932
4765 while (1) { 4933 while (1) {
4766 unsigned long update; 4934 ret = walk_down_tree(trans, root, path, wc);
4767 wret = walk_down_tree(trans, root, path, &level); 4935 if (ret < 0) {
4768 if (wret > 0) 4936 err = ret;
4769 break; 4937 break;
4770 if (wret < 0) 4938 }
4771 ret = wret;
4772 4939
4773 wret = walk_up_tree(trans, root, path, &level, 4940 ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL);
4774 BTRFS_MAX_LEVEL); 4941 if (ret < 0) {
4775 if (wret > 0) 4942 err = ret;
4776 break; 4943 break;
4777 if (wret < 0) 4944 }
4778 ret = wret; 4945
4779 if (trans->transaction->in_commit || 4946 if (ret > 0) {
4780 trans->transaction->delayed_refs.flushing) { 4947 BUG_ON(wc->stage != DROP_REFERENCE);
4781 ret = -EAGAIN;
4782 break; 4948 break;
4783 } 4949 }
4784 for (update_count = 0; update_count < 16; update_count++) { 4950
4951 if (wc->stage == DROP_REFERENCE) {
4952 level = wc->level;
4953 btrfs_node_key(path->nodes[level],
4954 &root_item->drop_progress,
4955 path->slots[level]);
4956 root_item->drop_level = level;
4957 }
4958
4959 BUG_ON(wc->level == 0);
4960 if (trans->transaction->in_commit ||
4961 trans->transaction->delayed_refs.flushing) {
4962 ret = btrfs_update_root(trans, tree_root,
4963 &root->root_key,
4964 root_item);
4965 BUG_ON(ret);
4966
4967 btrfs_end_transaction(trans, tree_root);
4968 trans = btrfs_start_transaction(tree_root, 1);
4969 } else {
4970 unsigned long update;
4785 update = trans->delayed_ref_updates; 4971 update = trans->delayed_ref_updates;
4786 trans->delayed_ref_updates = 0; 4972 trans->delayed_ref_updates = 0;
4787 if (update) 4973 if (update)
4788 btrfs_run_delayed_refs(trans, root, update); 4974 btrfs_run_delayed_refs(trans, tree_root,
4789 else 4975 update);
4790 break;
4791 } 4976 }
4792 } 4977 }
4978 btrfs_release_path(root, path);
4979 BUG_ON(err);
4980
4981 ret = btrfs_del_root(trans, tree_root, &root->root_key);
4982 BUG_ON(ret);
4983
4984 free_extent_buffer(root->node);
4985 free_extent_buffer(root->commit_root);
4986 kfree(root);
4793out: 4987out:
4988 btrfs_end_transaction(trans, tree_root);
4989 kfree(wc);
4794 btrfs_free_path(path); 4990 btrfs_free_path(path);
4795 return ret; 4991 return err;
4796} 4992}
4797 4993
4994/*
4995 * drop subtree rooted at tree block 'node'.
4996 *
4997 * NOTE: this function will unlock and release tree block 'node'
4998 */
4798int btrfs_drop_subtree(struct btrfs_trans_handle *trans, 4999int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
4799 struct btrfs_root *root, 5000 struct btrfs_root *root,
4800 struct extent_buffer *node, 5001 struct extent_buffer *node,
4801 struct extent_buffer *parent) 5002 struct extent_buffer *parent)
4802{ 5003{
4803 struct btrfs_path *path; 5004 struct btrfs_path *path;
5005 struct walk_control *wc;
4804 int level; 5006 int level;
4805 int parent_level; 5007 int parent_level;
4806 int ret = 0; 5008 int ret = 0;
4807 int wret; 5009 int wret;
4808 5010
5011 BUG_ON(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
5012
4809 path = btrfs_alloc_path(); 5013 path = btrfs_alloc_path();
4810 BUG_ON(!path); 5014 BUG_ON(!path);
4811 5015
5016 wc = kzalloc(sizeof(*wc), GFP_NOFS);
5017 BUG_ON(!wc);
5018
4812 btrfs_assert_tree_locked(parent); 5019 btrfs_assert_tree_locked(parent);
4813 parent_level = btrfs_header_level(parent); 5020 parent_level = btrfs_header_level(parent);
4814 extent_buffer_get(parent); 5021 extent_buffer_get(parent);
@@ -4817,24 +5024,33 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
4817 5024
4818 btrfs_assert_tree_locked(node); 5025 btrfs_assert_tree_locked(node);
4819 level = btrfs_header_level(node); 5026 level = btrfs_header_level(node);
4820 extent_buffer_get(node);
4821 path->nodes[level] = node; 5027 path->nodes[level] = node;
4822 path->slots[level] = 0; 5028 path->slots[level] = 0;
5029 path->locks[level] = 1;
5030
5031 wc->refs[parent_level] = 1;
5032 wc->flags[parent_level] = BTRFS_BLOCK_FLAG_FULL_BACKREF;
5033 wc->level = level;
5034 wc->shared_level = -1;
5035 wc->stage = DROP_REFERENCE;
5036 wc->update_ref = 0;
5037 wc->keep_locks = 1;
4823 5038
4824 while (1) { 5039 while (1) {
4825 wret = walk_down_tree(trans, root, path, &level); 5040 wret = walk_down_tree(trans, root, path, wc);
4826 if (wret < 0) 5041 if (wret < 0) {
4827 ret = wret; 5042 ret = wret;
4828 if (wret != 0)
4829 break; 5043 break;
5044 }
4830 5045
4831 wret = walk_up_tree(trans, root, path, &level, parent_level); 5046 wret = walk_up_tree(trans, root, path, wc, parent_level);
4832 if (wret < 0) 5047 if (wret < 0)
4833 ret = wret; 5048 ret = wret;
4834 if (wret != 0) 5049 if (wret != 0)
4835 break; 5050 break;
4836 } 5051 }
4837 5052
5053 kfree(wc);
4838 btrfs_free_path(path); 5054 btrfs_free_path(path);
4839 return ret; 5055 return ret;
4840} 5056}
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 126477eaecf5..4b833972273a 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -22,7 +22,6 @@
22#include <linux/time.h> 22#include <linux/time.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/string.h> 24#include <linux/string.h>
25#include <linux/smp_lock.h>
26#include <linux/backing-dev.h> 25#include <linux/backing-dev.h>
27#include <linux/mpage.h> 26#include <linux/mpage.h>
28#include <linux/swap.h> 27#include <linux/swap.h>
@@ -151,7 +150,10 @@ static noinline int dirty_and_release_pages(struct btrfs_trans_handle *trans,
151 } 150 }
152 if (end_pos > isize) { 151 if (end_pos > isize) {
153 i_size_write(inode, end_pos); 152 i_size_write(inode, end_pos);
154 btrfs_update_inode(trans, root, inode); 153 /* we've only changed i_size in ram, and we haven't updated
154 * the disk i_size. There is no need to log the inode
155 * at this time.
156 */
155 } 157 }
156 err = btrfs_end_transaction(trans, root); 158 err = btrfs_end_transaction(trans, root);
157out_unlock: 159out_unlock:
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index dbe1aabf96cd..791eab19e330 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -26,7 +26,6 @@
26#include <linux/time.h> 26#include <linux/time.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/smp_lock.h>
30#include <linux/backing-dev.h> 29#include <linux/backing-dev.h>
31#include <linux/mpage.h> 30#include <linux/mpage.h>
32#include <linux/swap.h> 31#include <linux/swap.h>
@@ -3580,12 +3579,6 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3580 owner = 1; 3579 owner = 1;
3581 BTRFS_I(inode)->block_group = 3580 BTRFS_I(inode)->block_group =
3582 btrfs_find_block_group(root, 0, alloc_hint, owner); 3581 btrfs_find_block_group(root, 0, alloc_hint, owner);
3583 if ((mode & S_IFREG)) {
3584 if (btrfs_test_opt(root, NODATASUM))
3585 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
3586 if (btrfs_test_opt(root, NODATACOW))
3587 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
3588 }
3589 3582
3590 key[0].objectid = objectid; 3583 key[0].objectid = objectid;
3591 btrfs_set_key_type(&key[0], BTRFS_INODE_ITEM_KEY); 3584 btrfs_set_key_type(&key[0], BTRFS_INODE_ITEM_KEY);
@@ -3640,6 +3633,13 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3640 3633
3641 btrfs_inherit_iflags(inode, dir); 3634 btrfs_inherit_iflags(inode, dir);
3642 3635
3636 if ((mode & S_IFREG)) {
3637 if (btrfs_test_opt(root, NODATASUM))
3638 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
3639 if (btrfs_test_opt(root, NODATACOW))
3640 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
3641 }
3642
3643 insert_inode_hash(inode); 3643 insert_inode_hash(inode);
3644 inode_tree_add(inode); 3644 inode_tree_add(inode);
3645 return inode; 3645 return inode;
@@ -5082,6 +5082,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5082 u64 mask = BTRFS_I(inode)->root->sectorsize - 1; 5082 u64 mask = BTRFS_I(inode)->root->sectorsize - 1;
5083 struct extent_map *em; 5083 struct extent_map *em;
5084 struct btrfs_trans_handle *trans; 5084 struct btrfs_trans_handle *trans;
5085 struct btrfs_root *root;
5085 int ret; 5086 int ret;
5086 5087
5087 alloc_start = offset & ~mask; 5088 alloc_start = offset & ~mask;
@@ -5100,6 +5101,13 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5100 goto out; 5101 goto out;
5101 } 5102 }
5102 5103
5104 root = BTRFS_I(inode)->root;
5105
5106 ret = btrfs_check_data_free_space(root, inode,
5107 alloc_end - alloc_start);
5108 if (ret)
5109 goto out;
5110
5103 locked_end = alloc_end - 1; 5111 locked_end = alloc_end - 1;
5104 while (1) { 5112 while (1) {
5105 struct btrfs_ordered_extent *ordered; 5113 struct btrfs_ordered_extent *ordered;
@@ -5107,7 +5115,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5107 trans = btrfs_start_transaction(BTRFS_I(inode)->root, 1); 5115 trans = btrfs_start_transaction(BTRFS_I(inode)->root, 1);
5108 if (!trans) { 5116 if (!trans) {
5109 ret = -EIO; 5117 ret = -EIO;
5110 goto out; 5118 goto out_free;
5111 } 5119 }
5112 5120
5113 /* the extent lock is ordered inside the running 5121 /* the extent lock is ordered inside the running
@@ -5168,6 +5176,8 @@ static long btrfs_fallocate(struct inode *inode, int mode,
5168 GFP_NOFS); 5176 GFP_NOFS);
5169 5177
5170 btrfs_end_transaction(trans, BTRFS_I(inode)->root); 5178 btrfs_end_transaction(trans, BTRFS_I(inode)->root);
5179out_free:
5180 btrfs_free_reserved_data_space(root, inode, alloc_end - alloc_start);
5171out: 5181out:
5172 mutex_unlock(&inode->i_mutex); 5182 mutex_unlock(&inode->i_mutex);
5173 return ret; 5183 return ret;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index eff18f5b5362..bd88f25889f7 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -27,7 +27,6 @@
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/smp_lock.h>
31#include <linux/backing-dev.h> 30#include <linux/backing-dev.h>
32#include <linux/mount.h> 31#include <linux/mount.h>
33#include <linux/mpage.h> 32#include <linux/mpage.h>
@@ -1028,7 +1027,8 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1028 struct btrfs_file_extent_item); 1027 struct btrfs_file_extent_item);
1029 comp = btrfs_file_extent_compression(leaf, extent); 1028 comp = btrfs_file_extent_compression(leaf, extent);
1030 type = btrfs_file_extent_type(leaf, extent); 1029 type = btrfs_file_extent_type(leaf, extent);
1031 if (type == BTRFS_FILE_EXTENT_REG) { 1030 if (type == BTRFS_FILE_EXTENT_REG ||
1031 type == BTRFS_FILE_EXTENT_PREALLOC) {
1032 disko = btrfs_file_extent_disk_bytenr(leaf, 1032 disko = btrfs_file_extent_disk_bytenr(leaf,
1033 extent); 1033 extent);
1034 diskl = btrfs_file_extent_disk_num_bytes(leaf, 1034 diskl = btrfs_file_extent_disk_num_bytes(leaf,
@@ -1051,7 +1051,8 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1051 new_key.objectid = inode->i_ino; 1051 new_key.objectid = inode->i_ino;
1052 new_key.offset = key.offset + destoff - off; 1052 new_key.offset = key.offset + destoff - off;
1053 1053
1054 if (type == BTRFS_FILE_EXTENT_REG) { 1054 if (type == BTRFS_FILE_EXTENT_REG ||
1055 type == BTRFS_FILE_EXTENT_PREALLOC) {
1055 ret = btrfs_insert_empty_item(trans, root, path, 1056 ret = btrfs_insert_empty_item(trans, root, path,
1056 &new_key, size); 1057 &new_key, size);
1057 if (ret) 1058 if (ret)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index b23dc209ae10..008397934778 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1788,7 +1788,7 @@ static void merge_func(struct btrfs_work *work)
1788 btrfs_end_transaction(trans, root); 1788 btrfs_end_transaction(trans, root);
1789 } 1789 }
1790 1790
1791 btrfs_drop_dead_root(reloc_root); 1791 btrfs_drop_snapshot(reloc_root, 0);
1792 1792
1793 if (atomic_dec_and_test(async->num_pending)) 1793 if (atomic_dec_and_test(async->num_pending))
1794 complete(async->done); 1794 complete(async->done);
@@ -2075,9 +2075,6 @@ static int do_relocation(struct btrfs_trans_handle *trans,
2075 2075
2076 ret = btrfs_drop_subtree(trans, root, eb, upper->eb); 2076 ret = btrfs_drop_subtree(trans, root, eb, upper->eb);
2077 BUG_ON(ret); 2077 BUG_ON(ret);
2078
2079 btrfs_tree_unlock(eb);
2080 free_extent_buffer(eb);
2081 } 2078 }
2082 if (!lowest) { 2079 if (!lowest) {
2083 btrfs_tree_unlock(upper->eb); 2080 btrfs_tree_unlock(upper->eb);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 9f179d4832d5..6d6d06cb6dfc 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -26,7 +26,6 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/smp_lock.h>
30#include <linux/backing-dev.h> 29#include <linux/backing-dev.h>
31#include <linux/mount.h> 30#include <linux/mount.h>
32#include <linux/mpage.h> 31#include <linux/mpage.h>
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 4e83457ea253..2dbf1c1f56ee 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -593,6 +593,7 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly)
593 return 0; 593 return 0;
594} 594}
595 595
596#if 0
596/* 597/*
597 * when dropping snapshots, we generate a ton of delayed refs, and it makes 598 * when dropping snapshots, we generate a ton of delayed refs, and it makes
598 * sense not to join the transaction while it is trying to flush the current 599 * sense not to join the transaction while it is trying to flush the current
@@ -681,6 +682,7 @@ int btrfs_drop_dead_root(struct btrfs_root *root)
681 btrfs_btree_balance_dirty(tree_root, nr); 682 btrfs_btree_balance_dirty(tree_root, nr);
682 return ret; 683 return ret;
683} 684}
685#endif
684 686
685/* 687/*
686 * new snapshots need to be created at a very specific time in the 688 * new snapshots need to be created at a very specific time in the
@@ -1081,7 +1083,7 @@ int btrfs_clean_old_snapshots(struct btrfs_root *root)
1081 while (!list_empty(&list)) { 1083 while (!list_empty(&list)) {
1082 root = list_entry(list.next, struct btrfs_root, root_list); 1084 root = list_entry(list.next, struct btrfs_root, root_list);
1083 list_del_init(&root->root_list); 1085 list_del_init(&root->root_list);
1084 btrfs_drop_dead_root(root); 1086 btrfs_drop_snapshot(root, 0);
1085 } 1087 }
1086 return 0; 1088 return 0;
1087} 1089}
diff --git a/fs/char_dev.c b/fs/char_dev.c
index b7c9d5187a75..a173551e19d7 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -13,7 +13,6 @@
13#include <linux/major.h> 13#include <linux/major.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/smp_lock.h>
17#include <linux/seq_file.h> 16#include <linux/seq_file.h>
18 17
19#include <linux/kobject.h> 18#include <linux/kobject.h>
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index b48689839428..92888aa90749 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -5,7 +5,11 @@ client generated ones by default (mount option "serverino" turned
5on by default if server supports it). Add forceuid and forcegid 5on by default if server supports it). Add forceuid and forcegid
6mount options (so that when negotiating unix extensions specifying 6mount options (so that when negotiating unix extensions specifying
7which uid mounted does not immediately force the server's reported 7which uid mounted does not immediately force the server's reported
8uids to be overridden). 8uids to be overridden). Add support for scope mount parm. Improve
9hard link detection to use same inode for both. Do not set
10read-only dos attribute on directories (for chmod) since Windows
11explorer special cases this attribute bit for directories for
12a different purpose.
9 13
10Version 1.58 14Version 1.58
11------------ 15------------
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
index 1b09f1670061..20692fbfdb24 100644
--- a/fs/cifs/asn1.c
+++ b/fs/cifs/asn1.c
@@ -49,6 +49,7 @@
49#define ASN1_OJI 6 /* Object Identifier */ 49#define ASN1_OJI 6 /* Object Identifier */
50#define ASN1_OJD 7 /* Object Description */ 50#define ASN1_OJD 7 /* Object Description */
51#define ASN1_EXT 8 /* External */ 51#define ASN1_EXT 8 /* External */
52#define ASN1_ENUM 10 /* Enumerated */
52#define ASN1_SEQ 16 /* Sequence */ 53#define ASN1_SEQ 16 /* Sequence */
53#define ASN1_SET 17 /* Set */ 54#define ASN1_SET 17 /* Set */
54#define ASN1_NUMSTR 18 /* Numerical String */ 55#define ASN1_NUMSTR 18 /* Numerical String */
@@ -78,10 +79,12 @@
78#define SPNEGO_OID_LEN 7 79#define SPNEGO_OID_LEN 7
79#define NTLMSSP_OID_LEN 10 80#define NTLMSSP_OID_LEN 10
80#define KRB5_OID_LEN 7 81#define KRB5_OID_LEN 7
82#define KRB5U2U_OID_LEN 8
81#define MSKRB5_OID_LEN 7 83#define MSKRB5_OID_LEN 7
82static unsigned long SPNEGO_OID[7] = { 1, 3, 6, 1, 5, 5, 2 }; 84static unsigned long SPNEGO_OID[7] = { 1, 3, 6, 1, 5, 5, 2 };
83static unsigned long NTLMSSP_OID[10] = { 1, 3, 6, 1, 4, 1, 311, 2, 2, 10 }; 85static unsigned long NTLMSSP_OID[10] = { 1, 3, 6, 1, 4, 1, 311, 2, 2, 10 };
84static unsigned long KRB5_OID[7] = { 1, 2, 840, 113554, 1, 2, 2 }; 86static unsigned long KRB5_OID[7] = { 1, 2, 840, 113554, 1, 2, 2 };
87static unsigned long KRB5U2U_OID[8] = { 1, 2, 840, 113554, 1, 2, 2, 3 };
85static unsigned long MSKRB5_OID[7] = { 1, 2, 840, 48018, 1, 2, 2 }; 88static unsigned long MSKRB5_OID[7] = { 1, 2, 840, 48018, 1, 2, 2 };
86 89
87/* 90/*
@@ -122,6 +125,28 @@ asn1_octet_decode(struct asn1_ctx *ctx, unsigned char *ch)
122 return 1; 125 return 1;
123} 126}
124 127
128#if 0 /* will be needed later by spnego decoding/encoding of ntlmssp */
129static unsigned char
130asn1_enum_decode(struct asn1_ctx *ctx, __le32 *val)
131{
132 unsigned char ch;
133
134 if (ctx->pointer >= ctx->end) {
135 ctx->error = ASN1_ERR_DEC_EMPTY;
136 return 0;
137 }
138
139 ch = *(ctx->pointer)++; /* ch has 0xa, ptr points to lenght octet */
140 if ((ch) == ASN1_ENUM) /* if ch value is ENUM, 0xa */
141 *val = *(++(ctx->pointer)); /* value has enum value */
142 else
143 return 0;
144
145 ctx->pointer++;
146 return 1;
147}
148#endif
149
125static unsigned char 150static unsigned char
126asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag) 151asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag)
127{ 152{
@@ -476,10 +501,9 @@ decode_negTokenInit(unsigned char *security_blob, int length,
476 unsigned int cls, con, tag, oidlen, rc; 501 unsigned int cls, con, tag, oidlen, rc;
477 bool use_ntlmssp = false; 502 bool use_ntlmssp = false;
478 bool use_kerberos = false; 503 bool use_kerberos = false;
504 bool use_kerberosu2u = false;
479 bool use_mskerberos = false; 505 bool use_mskerberos = false;
480 506
481 *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/
482
483 /* cifs_dump_mem(" Received SecBlob ", security_blob, length); */ 507 /* cifs_dump_mem(" Received SecBlob ", security_blob, length); */
484 508
485 asn1_open(&ctx, security_blob, length); 509 asn1_open(&ctx, security_blob, length);
@@ -515,6 +539,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
515 return 0; 539 return 0;
516 } 540 }
517 541
542 /* SPNEGO */
518 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 543 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
519 cFYI(1, ("Error decoding negTokenInit")); 544 cFYI(1, ("Error decoding negTokenInit"));
520 return 0; 545 return 0;
@@ -526,6 +551,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
526 return 0; 551 return 0;
527 } 552 }
528 553
554 /* negTokenInit */
529 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 555 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
530 cFYI(1, ("Error decoding negTokenInit")); 556 cFYI(1, ("Error decoding negTokenInit"));
531 return 0; 557 return 0;
@@ -537,6 +563,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
537 return 0; 563 return 0;
538 } 564 }
539 565
566 /* sequence */
540 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 567 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
541 cFYI(1, ("Error decoding 2nd part of negTokenInit")); 568 cFYI(1, ("Error decoding 2nd part of negTokenInit"));
542 return 0; 569 return 0;
@@ -548,6 +575,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
548 return 0; 575 return 0;
549 } 576 }
550 577
578 /* sequence of */
551 if (asn1_header_decode 579 if (asn1_header_decode
552 (&ctx, &sequence_end, &cls, &con, &tag) == 0) { 580 (&ctx, &sequence_end, &cls, &con, &tag) == 0) {
553 cFYI(1, ("Error decoding 2nd part of negTokenInit")); 581 cFYI(1, ("Error decoding 2nd part of negTokenInit"));
@@ -560,6 +588,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
560 return 0; 588 return 0;
561 } 589 }
562 590
591 /* list of security mechanisms */
563 while (!asn1_eoc_decode(&ctx, sequence_end)) { 592 while (!asn1_eoc_decode(&ctx, sequence_end)) {
564 rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag); 593 rc = asn1_header_decode(&ctx, &end, &cls, &con, &tag);
565 if (!rc) { 594 if (!rc) {
@@ -576,11 +605,15 @@ decode_negTokenInit(unsigned char *security_blob, int length,
576 605
577 if (compare_oid(oid, oidlen, MSKRB5_OID, 606 if (compare_oid(oid, oidlen, MSKRB5_OID,
578 MSKRB5_OID_LEN) && 607 MSKRB5_OID_LEN) &&
579 !use_kerberos) 608 !use_mskerberos)
580 use_mskerberos = true; 609 use_mskerberos = true;
610 else if (compare_oid(oid, oidlen, KRB5U2U_OID,
611 KRB5U2U_OID_LEN) &&
612 !use_kerberosu2u)
613 use_kerberosu2u = true;
581 else if (compare_oid(oid, oidlen, KRB5_OID, 614 else if (compare_oid(oid, oidlen, KRB5_OID,
582 KRB5_OID_LEN) && 615 KRB5_OID_LEN) &&
583 !use_mskerberos) 616 !use_kerberos)
584 use_kerberos = true; 617 use_kerberos = true;
585 else if (compare_oid(oid, oidlen, NTLMSSP_OID, 618 else if (compare_oid(oid, oidlen, NTLMSSP_OID,
586 NTLMSSP_OID_LEN)) 619 NTLMSSP_OID_LEN))
@@ -593,7 +626,12 @@ decode_negTokenInit(unsigned char *security_blob, int length,
593 } 626 }
594 } 627 }
595 628
629 /* mechlistMIC */
596 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 630 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
631 /* Check if we have reached the end of the blob, but with
632 no mechListMic (e.g. NTLMSSP instead of KRB5) */
633 if (ctx.error == ASN1_ERR_DEC_EMPTY)
634 goto decode_negtoken_exit;
597 cFYI(1, ("Error decoding last part negTokenInit exit3")); 635 cFYI(1, ("Error decoding last part negTokenInit exit3"));
598 return 0; 636 return 0;
599 } else if ((cls != ASN1_CTX) || (con != ASN1_CON)) { 637 } else if ((cls != ASN1_CTX) || (con != ASN1_CON)) {
@@ -602,6 +640,8 @@ decode_negTokenInit(unsigned char *security_blob, int length,
602 cls, con, tag, end, *end)); 640 cls, con, tag, end, *end));
603 return 0; 641 return 0;
604 } 642 }
643
644 /* sequence */
605 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 645 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
606 cFYI(1, ("Error decoding last part negTokenInit exit5")); 646 cFYI(1, ("Error decoding last part negTokenInit exit5"));
607 return 0; 647 return 0;
@@ -611,6 +651,7 @@ decode_negTokenInit(unsigned char *security_blob, int length,
611 cls, con, tag, end, *end)); 651 cls, con, tag, end, *end));
612 } 652 }
613 653
654 /* sequence of */
614 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 655 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
615 cFYI(1, ("Error decoding last part negTokenInit exit 7")); 656 cFYI(1, ("Error decoding last part negTokenInit exit 7"));
616 return 0; 657 return 0;
@@ -619,6 +660,8 @@ decode_negTokenInit(unsigned char *security_blob, int length,
619 cls, con, tag, end, *end)); 660 cls, con, tag, end, *end));
620 return 0; 661 return 0;
621 } 662 }
663
664 /* general string */
622 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) { 665 if (asn1_header_decode(&ctx, &end, &cls, &con, &tag) == 0) {
623 cFYI(1, ("Error decoding last part negTokenInit exit9")); 666 cFYI(1, ("Error decoding last part negTokenInit exit9"));
624 return 0; 667 return 0;
@@ -630,13 +673,13 @@ decode_negTokenInit(unsigned char *security_blob, int length,
630 } 673 }
631 cFYI(1, ("Need to call asn1_octets_decode() function for %s", 674 cFYI(1, ("Need to call asn1_octets_decode() function for %s",
632 ctx.pointer)); /* is this UTF-8 or ASCII? */ 675 ctx.pointer)); /* is this UTF-8 or ASCII? */
633 676decode_negtoken_exit:
634 if (use_kerberos) 677 if (use_kerberos)
635 *secType = Kerberos; 678 *secType = Kerberos;
636 else if (use_mskerberos) 679 else if (use_mskerberos)
637 *secType = MSKerberos; 680 *secType = MSKerberos;
638 else if (use_ntlmssp) 681 else if (use_ntlmssp)
639 *secType = NTLMSSP; 682 *secType = RawNTLMSSP;
640 683
641 return 1; 684 return 1;
642} 685}
diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c
index 4a4581cb2b5e..051caecf7d67 100644
--- a/fs/cifs/cifs_spnego.c
+++ b/fs/cifs/cifs_spnego.c
@@ -86,6 +86,9 @@ struct key_type cifs_spnego_key_type = {
86/* strlen of ";user=" */ 86/* strlen of ";user=" */
87#define USER_KEY_LEN 6 87#define USER_KEY_LEN 6
88 88
89/* strlen of ";pid=0x" */
90#define PID_KEY_LEN 7
91
89/* get a key struct with a SPNEGO security blob, suitable for session setup */ 92/* get a key struct with a SPNEGO security blob, suitable for session setup */
90struct key * 93struct key *
91cifs_get_spnego_key(struct cifsSesInfo *sesInfo) 94cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
@@ -103,7 +106,8 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
103 IP_KEY_LEN + INET6_ADDRSTRLEN + 106 IP_KEY_LEN + INET6_ADDRSTRLEN +
104 MAX_MECH_STR_LEN + 107 MAX_MECH_STR_LEN +
105 UID_KEY_LEN + (sizeof(uid_t) * 2) + 108 UID_KEY_LEN + (sizeof(uid_t) * 2) +
106 USER_KEY_LEN + strlen(sesInfo->userName) + 1; 109 USER_KEY_LEN + strlen(sesInfo->userName) +
110 PID_KEY_LEN + (sizeof(pid_t) * 2) + 1;
107 111
108 spnego_key = ERR_PTR(-ENOMEM); 112 spnego_key = ERR_PTR(-ENOMEM);
109 description = kzalloc(desc_len, GFP_KERNEL); 113 description = kzalloc(desc_len, GFP_KERNEL);
@@ -141,6 +145,9 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
141 dp = description + strlen(description); 145 dp = description + strlen(description);
142 sprintf(dp, ";user=%s", sesInfo->userName); 146 sprintf(dp, ";user=%s", sesInfo->userName);
143 147
148 dp = description + strlen(description);
149 sprintf(dp, ";pid=0x%x", current->pid);
150
144 cFYI(1, ("key description = %s", description)); 151 cFYI(1, ("key description = %s", description));
145 spnego_key = request_key(&cifs_spnego_key_type, description, ""); 152 spnego_key = request_key(&cifs_spnego_key_type, description, "");
146 153
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 1403b5d86a73..6941c22398a6 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -327,7 +327,7 @@ static void dump_ace(struct cifs_ace *pace, char *end_of_acl)
327 327
328static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, 328static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
329 struct cifs_sid *pownersid, struct cifs_sid *pgrpsid, 329 struct cifs_sid *pownersid, struct cifs_sid *pgrpsid,
330 struct inode *inode) 330 struct cifs_fattr *fattr)
331{ 331{
332 int i; 332 int i;
333 int num_aces = 0; 333 int num_aces = 0;
@@ -340,7 +340,7 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
340 if (!pdacl) { 340 if (!pdacl) {
341 /* no DACL in the security descriptor, set 341 /* no DACL in the security descriptor, set
342 all the permissions for user/group/other */ 342 all the permissions for user/group/other */
343 inode->i_mode |= S_IRWXUGO; 343 fattr->cf_mode |= S_IRWXUGO;
344 return; 344 return;
345 } 345 }
346 346
@@ -357,7 +357,7 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
357 /* reset rwx permissions for user/group/other. 357 /* reset rwx permissions for user/group/other.
358 Also, if num_aces is 0 i.e. DACL has no ACEs, 358 Also, if num_aces is 0 i.e. DACL has no ACEs,
359 user/group/other have no permissions */ 359 user/group/other have no permissions */
360 inode->i_mode &= ~(S_IRWXUGO); 360 fattr->cf_mode &= ~(S_IRWXUGO);
361 361
362 acl_base = (char *)pdacl; 362 acl_base = (char *)pdacl;
363 acl_size = sizeof(struct cifs_acl); 363 acl_size = sizeof(struct cifs_acl);
@@ -379,17 +379,17 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
379 if (compare_sids(&(ppace[i]->sid), pownersid)) 379 if (compare_sids(&(ppace[i]->sid), pownersid))
380 access_flags_to_mode(ppace[i]->access_req, 380 access_flags_to_mode(ppace[i]->access_req,
381 ppace[i]->type, 381 ppace[i]->type,
382 &(inode->i_mode), 382 &fattr->cf_mode,
383 &user_mask); 383 &user_mask);
384 if (compare_sids(&(ppace[i]->sid), pgrpsid)) 384 if (compare_sids(&(ppace[i]->sid), pgrpsid))
385 access_flags_to_mode(ppace[i]->access_req, 385 access_flags_to_mode(ppace[i]->access_req,
386 ppace[i]->type, 386 ppace[i]->type,
387 &(inode->i_mode), 387 &fattr->cf_mode,
388 &group_mask); 388 &group_mask);
389 if (compare_sids(&(ppace[i]->sid), &sid_everyone)) 389 if (compare_sids(&(ppace[i]->sid), &sid_everyone))
390 access_flags_to_mode(ppace[i]->access_req, 390 access_flags_to_mode(ppace[i]->access_req,
391 ppace[i]->type, 391 ppace[i]->type,
392 &(inode->i_mode), 392 &fattr->cf_mode,
393 &other_mask); 393 &other_mask);
394 394
395/* memcpy((void *)(&(cifscred->aces[i])), 395/* memcpy((void *)(&(cifscred->aces[i])),
@@ -464,7 +464,7 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl)
464 464
465/* Convert CIFS ACL to POSIX form */ 465/* Convert CIFS ACL to POSIX form */
466static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len, 466static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
467 struct inode *inode) 467 struct cifs_fattr *fattr)
468{ 468{
469 int rc; 469 int rc;
470 struct cifs_sid *owner_sid_ptr, *group_sid_ptr; 470 struct cifs_sid *owner_sid_ptr, *group_sid_ptr;
@@ -472,7 +472,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
472 char *end_of_acl = ((char *)pntsd) + acl_len; 472 char *end_of_acl = ((char *)pntsd) + acl_len;
473 __u32 dacloffset; 473 __u32 dacloffset;
474 474
475 if ((inode == NULL) || (pntsd == NULL)) 475 if (pntsd == NULL)
476 return -EIO; 476 return -EIO;
477 477
478 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + 478 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd +
@@ -497,7 +497,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
497 497
498 if (dacloffset) 498 if (dacloffset)
499 parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr, 499 parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr,
500 group_sid_ptr, inode); 500 group_sid_ptr, fattr);
501 else 501 else
502 cFYI(1, ("no ACL")); /* BB grant all or default perms? */ 502 cFYI(1, ("no ACL")); /* BB grant all or default perms? */
503 503
@@ -508,7 +508,6 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,
508 memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr, 508 memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr,
509 sizeof(struct cifs_sid)); */ 509 sizeof(struct cifs_sid)); */
510 510
511
512 return 0; 511 return 0;
513} 512}
514 513
@@ -671,8 +670,9 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
671} 670}
672 671
673/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ 672/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
674void acl_to_uid_mode(struct cifs_sb_info *cifs_sb, struct inode *inode, 673void
675 const char *path, const __u16 *pfid) 674cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
675 struct inode *inode, const char *path, const __u16 *pfid)
676{ 676{
677 struct cifs_ntsd *pntsd = NULL; 677 struct cifs_ntsd *pntsd = NULL;
678 u32 acllen = 0; 678 u32 acllen = 0;
@@ -687,7 +687,7 @@ void acl_to_uid_mode(struct cifs_sb_info *cifs_sb, struct inode *inode,
687 687
688 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ 688 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
689 if (pntsd) 689 if (pntsd)
690 rc = parse_sec_desc(pntsd, acllen, inode); 690 rc = parse_sec_desc(pntsd, acllen, fattr);
691 if (rc) 691 if (rc)
692 cFYI(1, ("parse sec desc failed rc = %d", rc)); 692 cFYI(1, ("parse sec desc failed rc = %d", rc));
693 693
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 0d92114195ab..44f30504b82d 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -308,7 +308,6 @@ cifs_alloc_inode(struct super_block *sb)
308 if (!cifs_inode) 308 if (!cifs_inode)
309 return NULL; 309 return NULL;
310 cifs_inode->cifsAttrs = 0x20; /* default */ 310 cifs_inode->cifsAttrs = 0x20; /* default */
311 atomic_set(&cifs_inode->inUse, 0);
312 cifs_inode->time = 0; 311 cifs_inode->time = 0;
313 cifs_inode->write_behind_rc = 0; 312 cifs_inode->write_behind_rc = 0;
314 /* Until the file is open and we have gotten oplock 313 /* Until the file is open and we have gotten oplock
@@ -333,6 +332,27 @@ cifs_destroy_inode(struct inode *inode)
333 kmem_cache_free(cifs_inode_cachep, CIFS_I(inode)); 332 kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
334} 333}
335 334
335static void
336cifs_show_address(struct seq_file *s, struct TCP_Server_Info *server)
337{
338 seq_printf(s, ",addr=");
339
340 switch (server->addr.sockAddr.sin_family) {
341 case AF_INET:
342 seq_printf(s, "%pI4", &server->addr.sockAddr.sin_addr.s_addr);
343 break;
344 case AF_INET6:
345 seq_printf(s, "%pI6",
346 &server->addr.sockAddr6.sin6_addr.s6_addr);
347 if (server->addr.sockAddr6.sin6_scope_id)
348 seq_printf(s, "%%%u",
349 server->addr.sockAddr6.sin6_scope_id);
350 break;
351 default:
352 seq_printf(s, "(unknown)");
353 }
354}
355
336/* 356/*
337 * cifs_show_options() is for displaying mount options in /proc/mounts. 357 * cifs_show_options() is for displaying mount options in /proc/mounts.
338 * Not all settable options are displayed but most of the important 358 * Not all settable options are displayed but most of the important
@@ -343,83 +363,64 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
343{ 363{
344 struct cifs_sb_info *cifs_sb; 364 struct cifs_sb_info *cifs_sb;
345 struct cifsTconInfo *tcon; 365 struct cifsTconInfo *tcon;
346 struct TCP_Server_Info *server;
347 366
348 cifs_sb = CIFS_SB(m->mnt_sb); 367 cifs_sb = CIFS_SB(m->mnt_sb);
368 tcon = cifs_sb->tcon;
349 369
350 if (cifs_sb) { 370 seq_printf(s, ",unc=%s", cifs_sb->tcon->treeName);
351 tcon = cifs_sb->tcon; 371 if (tcon->ses->userName)
352 if (tcon) { 372 seq_printf(s, ",username=%s", tcon->ses->userName);
353 seq_printf(s, ",unc=%s", cifs_sb->tcon->treeName); 373 if (tcon->ses->domainName)
354 if (tcon->ses) { 374 seq_printf(s, ",domain=%s", tcon->ses->domainName);
355 if (tcon->ses->userName) 375
356 seq_printf(s, ",username=%s", 376 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
357 tcon->ses->userName); 377 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
358 if (tcon->ses->domainName) 378 seq_printf(s, ",forceuid");
359 seq_printf(s, ",domain=%s", 379
360 tcon->ses->domainName); 380 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
361 server = tcon->ses->server; 381 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
362 if (server) { 382 seq_printf(s, ",forcegid");
363 seq_printf(s, ",addr="); 383
364 switch (server->addr.sockAddr6. 384 cifs_show_address(s, tcon->ses->server);
365 sin6_family) { 385
366 case AF_INET6: 386 if (!tcon->unix_ext)
367 seq_printf(s, "%pI6", 387 seq_printf(s, ",file_mode=0%o,dir_mode=0%o",
368 &server->addr.sockAddr6.sin6_addr);
369 break;
370 case AF_INET:
371 seq_printf(s, "%pI4",
372 &server->addr.sockAddr.sin_addr.s_addr);
373 break;
374 }
375 }
376 }
377 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) ||
378 !(tcon->unix_ext))
379 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
380 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
381 !(tcon->unix_ext))
382 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
383 if (!tcon->unix_ext) {
384 seq_printf(s, ",file_mode=0%o,dir_mode=0%o",
385 cifs_sb->mnt_file_mode, 388 cifs_sb->mnt_file_mode,
386 cifs_sb->mnt_dir_mode); 389 cifs_sb->mnt_dir_mode);
387 } 390 if (tcon->seal)
388 if (tcon->seal) 391 seq_printf(s, ",seal");
389 seq_printf(s, ",seal"); 392 if (tcon->nocase)
390 if (tcon->nocase) 393 seq_printf(s, ",nocase");
391 seq_printf(s, ",nocase"); 394 if (tcon->retry)
392 if (tcon->retry) 395 seq_printf(s, ",hard");
393 seq_printf(s, ",hard"); 396 if (cifs_sb->prepath)
394 } 397 seq_printf(s, ",prepath=%s", cifs_sb->prepath);
395 if (cifs_sb->prepath) 398 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
396 seq_printf(s, ",prepath=%s", cifs_sb->prepath); 399 seq_printf(s, ",posixpaths");
397 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 400 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
398 seq_printf(s, ",posixpaths"); 401 seq_printf(s, ",setuids");
399 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) 402 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
400 seq_printf(s, ",setuids"); 403 seq_printf(s, ",serverino");
401 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) 404 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
402 seq_printf(s, ",serverino"); 405 seq_printf(s, ",directio");
403 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) 406 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
404 seq_printf(s, ",directio"); 407 seq_printf(s, ",nouser_xattr");
405 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 408 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
406 seq_printf(s, ",nouser_xattr"); 409 seq_printf(s, ",mapchars");
407 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) 410 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
408 seq_printf(s, ",mapchars"); 411 seq_printf(s, ",sfu");
409 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) 412 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
410 seq_printf(s, ",sfu"); 413 seq_printf(s, ",nobrl");
411 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 414 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
412 seq_printf(s, ",nobrl"); 415 seq_printf(s, ",cifsacl");
413 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) 416 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
414 seq_printf(s, ",cifsacl"); 417 seq_printf(s, ",dynperm");
415 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) 418 if (m->mnt_sb->s_flags & MS_POSIXACL)
416 seq_printf(s, ",dynperm"); 419 seq_printf(s, ",acl");
417 if (m->mnt_sb->s_flags & MS_POSIXACL) 420
418 seq_printf(s, ",acl"); 421 seq_printf(s, ",rsize=%d", cifs_sb->rsize);
419 422 seq_printf(s, ",wsize=%d", cifs_sb->wsize);
420 seq_printf(s, ",rsize=%d", cifs_sb->rsize); 423
421 seq_printf(s, ",wsize=%d", cifs_sb->wsize);
422 }
423 return 0; 424 return 0;
424} 425}
425 426
@@ -535,9 +536,14 @@ static void cifs_umount_begin(struct super_block *sb)
535 if (tcon == NULL) 536 if (tcon == NULL)
536 return; 537 return;
537 538
538 lock_kernel();
539 read_lock(&cifs_tcp_ses_lock); 539 read_lock(&cifs_tcp_ses_lock);
540 if (tcon->tc_count == 1) 540 if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
541 /* we have other mounts to same share or we have
542 already tried to force umount this and woken up
543 all waiting network requests, nothing to do */
544 read_unlock(&cifs_tcp_ses_lock);
545 return;
546 } else if (tcon->tc_count == 1)
541 tcon->tidStatus = CifsExiting; 547 tcon->tidStatus = CifsExiting;
542 read_unlock(&cifs_tcp_ses_lock); 548 read_unlock(&cifs_tcp_ses_lock);
543 549
@@ -552,9 +558,7 @@ static void cifs_umount_begin(struct super_block *sb)
552 wake_up_all(&tcon->ses->server->response_q); 558 wake_up_all(&tcon->ses->server->response_q);
553 msleep(1); 559 msleep(1);
554 } 560 }
555/* BB FIXME - finish add checks for tidStatus BB */
556 561
557 unlock_kernel();
558 return; 562 return;
559} 563}
560 564
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 9570a0e8023f..6c170948300d 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -24,6 +24,19 @@
24 24
25#define ROOT_I 2 25#define ROOT_I 2
26 26
27/*
28 * ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down
29 * so that it will fit.
30 */
31static inline ino_t
32cifs_uniqueid_to_ino_t(u64 fileid)
33{
34 ino_t ino = (ino_t) fileid;
35 if (sizeof(ino_t) < sizeof(u64))
36 ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8;
37 return ino;
38}
39
27extern struct file_system_type cifs_fs_type; 40extern struct file_system_type cifs_fs_type;
28extern const struct address_space_operations cifs_addr_ops; 41extern const struct address_space_operations cifs_addr_ops;
29extern const struct address_space_operations cifs_addr_ops_smallbuf; 42extern const struct address_space_operations cifs_addr_ops_smallbuf;
@@ -100,5 +113,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
100extern const struct export_operations cifs_export_ops; 113extern const struct export_operations cifs_export_ops;
101#endif /* EXPERIMENTAL */ 114#endif /* EXPERIMENTAL */
102 115
103#define CIFS_VERSION "1.59" 116#define CIFS_VERSION "1.60"
104#endif /* _CIFSFS_H */ 117#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index a61ab772c6f6..63f6cdfa5638 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -83,7 +83,7 @@ enum securityEnum {
83 NTLM, /* Legacy NTLM012 auth with NTLM hash */ 83 NTLM, /* Legacy NTLM012 auth with NTLM hash */
84 NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */ 84 NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */
85 RawNTLMSSP, /* NTLMSSP without SPNEGO, NTLMv2 hash */ 85 RawNTLMSSP, /* NTLMSSP without SPNEGO, NTLMv2 hash */
86 NTLMSSP, /* NTLMSSP via SPNEGO, NTLMv2 hash */ 86/* NTLMSSP, */ /* can use rawNTLMSSP instead of NTLMSSP via SPNEGO */
87 Kerberos, /* Kerberos via SPNEGO */ 87 Kerberos, /* Kerberos via SPNEGO */
88 MSKerberos, /* MS Kerberos via SPNEGO */ 88 MSKerberos, /* MS Kerberos via SPNEGO */
89}; 89};
@@ -364,13 +364,13 @@ struct cifsInodeInfo {
364 struct list_head openFileList; 364 struct list_head openFileList;
365 int write_behind_rc; 365 int write_behind_rc;
366 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ 366 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
367 atomic_t inUse; /* num concurrent users (local openers cifs) of file*/
368 unsigned long time; /* jiffies of last update/check of inode */ 367 unsigned long time; /* jiffies of last update/check of inode */
369 bool clientCanCacheRead:1; /* read oplock */ 368 bool clientCanCacheRead:1; /* read oplock */
370 bool clientCanCacheAll:1; /* read and writebehind oplock */ 369 bool clientCanCacheAll:1; /* read and writebehind oplock */
371 bool oplockPending:1; 370 bool oplockPending:1;
372 bool delete_pending:1; /* DELETE_ON_CLOSE is set */ 371 bool delete_pending:1; /* DELETE_ON_CLOSE is set */
373 u64 server_eof; /* current file size on server */ 372 u64 server_eof; /* current file size on server */
373 u64 uniqueid; /* server inode number */
374 struct inode vfs_inode; 374 struct inode vfs_inode;
375}; 375};
376 376
@@ -472,6 +472,32 @@ struct dfs_info3_param {
472 char *node_name; 472 char *node_name;
473}; 473};
474 474
475/*
476 * common struct for holding inode info when searching for or updating an
477 * inode with new info
478 */
479
480#define CIFS_FATTR_DFS_REFERRAL 0x1
481#define CIFS_FATTR_DELETE_PENDING 0x2
482#define CIFS_FATTR_NEED_REVAL 0x4
483
484struct cifs_fattr {
485 u32 cf_flags;
486 u32 cf_cifsattrs;
487 u64 cf_uniqueid;
488 u64 cf_eof;
489 u64 cf_bytes;
490 uid_t cf_uid;
491 gid_t cf_gid;
492 umode_t cf_mode;
493 dev_t cf_rdev;
494 unsigned int cf_nlink;
495 unsigned int cf_dtype;
496 struct timespec cf_atime;
497 struct timespec cf_mtime;
498 struct timespec cf_ctime;
499};
500
475static inline void free_dfs_info_param(struct dfs_info3_param *param) 501static inline void free_dfs_info_param(struct dfs_info3_param *param)
476{ 502{
477 if (param) { 503 if (param) {
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index a785f69dbc9f..2d07f890a842 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -2328,19 +2328,7 @@ struct file_attrib_tag {
2328typedef struct { 2328typedef struct {
2329 __le32 NextEntryOffset; 2329 __le32 NextEntryOffset;
2330 __u32 ResumeKey; /* as with FileIndex - no need to convert */ 2330 __u32 ResumeKey; /* as with FileIndex - no need to convert */
2331 __le64 EndOfFile; 2331 FILE_UNIX_BASIC_INFO basic;
2332 __le64 NumOfBytes;
2333 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2334 __le64 LastAccessTime;
2335 __le64 LastModificationTime;
2336 __le64 Uid;
2337 __le64 Gid;
2338 __le32 Type;
2339 __le64 DevMajor;
2340 __le64 DevMinor;
2341 __le64 UniqueId;
2342 __le64 Permissions;
2343 __le64 Nlinks;
2344 char FileName[1]; 2332 char FileName[1];
2345} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */ 2333} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
2346 2334
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index f9452329bcce..da8fbf565991 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -74,7 +74,7 @@ extern unsigned int smbCalcSize(struct smb_hdr *ptr);
74extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr); 74extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr);
75extern int decode_negTokenInit(unsigned char *security_blob, int length, 75extern int decode_negTokenInit(unsigned char *security_blob, int length,
76 enum securityEnum *secType); 76 enum securityEnum *secType);
77extern int cifs_inet_pton(const int, const char *source, void *dst); 77extern int cifs_convert_address(char *src, void *dst);
78extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr); 78extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr);
79extern void header_assemble(struct smb_hdr *, char /* command */ , 79extern void header_assemble(struct smb_hdr *, char /* command */ ,
80 const struct cifsTconInfo *, int /* length of 80 const struct cifsTconInfo *, int /* length of
@@ -98,9 +98,13 @@ extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
98extern int cifs_posix_open(char *full_path, struct inode **pinode, 98extern int cifs_posix_open(char *full_path, struct inode **pinode,
99 struct super_block *sb, int mode, int oflags, 99 struct super_block *sb, int mode, int oflags,
100 int *poplock, __u16 *pnetfid, int xid); 100 int *poplock, __u16 *pnetfid, int xid);
101extern void posix_fill_in_inode(struct inode *tmp_inode, 101extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,
102 FILE_UNIX_BASIC_INFO *pData, int isNewInode); 102 FILE_UNIX_BASIC_INFO *info,
103extern struct inode *cifs_new_inode(struct super_block *sb, __u64 *inum); 103 struct cifs_sb_info *cifs_sb);
104extern void cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr);
105extern struct inode *cifs_iget(struct super_block *sb,
106 struct cifs_fattr *fattr);
107
104extern int cifs_get_inode_info(struct inode **pinode, 108extern int cifs_get_inode_info(struct inode **pinode,
105 const unsigned char *search_path, 109 const unsigned char *search_path,
106 FILE_ALL_INFO *pfile_info, 110 FILE_ALL_INFO *pfile_info,
@@ -108,8 +112,9 @@ extern int cifs_get_inode_info(struct inode **pinode,
108extern int cifs_get_inode_info_unix(struct inode **pinode, 112extern int cifs_get_inode_info_unix(struct inode **pinode,
109 const unsigned char *search_path, 113 const unsigned char *search_path,
110 struct super_block *sb, int xid); 114 struct super_block *sb, int xid);
111extern void acl_to_uid_mode(struct cifs_sb_info *cifs_sb, struct inode *inode, 115extern void cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
112 const char *path, const __u16 *pfid); 116 struct cifs_fattr *fattr, struct inode *inode,
117 const char *path, const __u16 *pfid);
113extern int mode_to_acl(struct inode *inode, const char *path, __u64); 118extern int mode_to_acl(struct inode *inode, const char *path, __u64);
114 119
115extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *, 120extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
@@ -215,7 +220,11 @@ struct cifs_unix_set_info_args {
215 dev_t device; 220 dev_t device;
216}; 221};
217 222
218extern int CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *pTcon, 223extern int CIFSSMBUnixSetFileInfo(const int xid, struct cifsTconInfo *tcon,
224 const struct cifs_unix_set_info_args *args,
225 u16 fid, u32 pid_of_opener);
226
227extern int CIFSSMBUnixSetPathInfo(const int xid, struct cifsTconInfo *pTcon,
219 char *fileName, 228 char *fileName,
220 const struct cifs_unix_set_info_args *args, 229 const struct cifs_unix_set_info_args *args,
221 const struct nls_table *nls_codepage, 230 const struct nls_table *nls_codepage,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index b84c61d5bca4..922f5fe2084c 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -594,7 +594,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
594 else if (secFlags & CIFSSEC_MAY_KRB5) 594 else if (secFlags & CIFSSEC_MAY_KRB5)
595 server->secType = Kerberos; 595 server->secType = Kerberos;
596 else if (secFlags & CIFSSEC_MAY_NTLMSSP) 596 else if (secFlags & CIFSSEC_MAY_NTLMSSP)
597 server->secType = NTLMSSP; 597 server->secType = RawNTLMSSP;
598 else if (secFlags & CIFSSEC_MAY_LANMAN) 598 else if (secFlags & CIFSSEC_MAY_LANMAN)
599 server->secType = LANMAN; 599 server->secType = LANMAN;
600/* #ifdef CONFIG_CIFS_EXPERIMENTAL 600/* #ifdef CONFIG_CIFS_EXPERIMENTAL
@@ -729,7 +729,7 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
729 * the tcon is no longer on the list, so no need to take lock before 729 * the tcon is no longer on the list, so no need to take lock before
730 * checking this. 730 * checking this.
731 */ 731 */
732 if (tcon->need_reconnect) 732 if ((tcon->need_reconnect) || (tcon->ses->need_reconnect))
733 return 0; 733 return 0;
734 734
735 rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, 735 rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon,
@@ -5074,10 +5074,114 @@ SetAttrLgcyRetry:
5074} 5074}
5075#endif /* temporarily unneeded SetAttr legacy function */ 5075#endif /* temporarily unneeded SetAttr legacy function */
5076 5076
5077static void
5078cifs_fill_unix_set_info(FILE_UNIX_BASIC_INFO *data_offset,
5079 const struct cifs_unix_set_info_args *args)
5080{
5081 u64 mode = args->mode;
5082
5083 /*
5084 * Samba server ignores set of file size to zero due to bugs in some
5085 * older clients, but we should be precise - we use SetFileSize to
5086 * set file size and do not want to truncate file size to zero
5087 * accidently as happened on one Samba server beta by putting
5088 * zero instead of -1 here
5089 */
5090 data_offset->EndOfFile = cpu_to_le64(NO_CHANGE_64);
5091 data_offset->NumOfBytes = cpu_to_le64(NO_CHANGE_64);
5092 data_offset->LastStatusChange = cpu_to_le64(args->ctime);
5093 data_offset->LastAccessTime = cpu_to_le64(args->atime);
5094 data_offset->LastModificationTime = cpu_to_le64(args->mtime);
5095 data_offset->Uid = cpu_to_le64(args->uid);
5096 data_offset->Gid = cpu_to_le64(args->gid);
5097 /* better to leave device as zero when it is */
5098 data_offset->DevMajor = cpu_to_le64(MAJOR(args->device));
5099 data_offset->DevMinor = cpu_to_le64(MINOR(args->device));
5100 data_offset->Permissions = cpu_to_le64(mode);
5101
5102 if (S_ISREG(mode))
5103 data_offset->Type = cpu_to_le32(UNIX_FILE);
5104 else if (S_ISDIR(mode))
5105 data_offset->Type = cpu_to_le32(UNIX_DIR);
5106 else if (S_ISLNK(mode))
5107 data_offset->Type = cpu_to_le32(UNIX_SYMLINK);
5108 else if (S_ISCHR(mode))
5109 data_offset->Type = cpu_to_le32(UNIX_CHARDEV);
5110 else if (S_ISBLK(mode))
5111 data_offset->Type = cpu_to_le32(UNIX_BLOCKDEV);
5112 else if (S_ISFIFO(mode))
5113 data_offset->Type = cpu_to_le32(UNIX_FIFO);
5114 else if (S_ISSOCK(mode))
5115 data_offset->Type = cpu_to_le32(UNIX_SOCKET);
5116}
5117
5077int 5118int
5078CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *tcon, char *fileName, 5119CIFSSMBUnixSetFileInfo(const int xid, struct cifsTconInfo *tcon,
5079 const struct cifs_unix_set_info_args *args, 5120 const struct cifs_unix_set_info_args *args,
5080 const struct nls_table *nls_codepage, int remap) 5121 u16 fid, u32 pid_of_opener)
5122{
5123 struct smb_com_transaction2_sfi_req *pSMB = NULL;
5124 FILE_UNIX_BASIC_INFO *data_offset;
5125 int rc = 0;
5126 u16 params, param_offset, offset, byte_count, count;
5127
5128 cFYI(1, ("Set Unix Info (via SetFileInfo)"));
5129 rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
5130
5131 if (rc)
5132 return rc;
5133
5134 pSMB->hdr.Pid = cpu_to_le16((__u16)pid_of_opener);
5135 pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid_of_opener >> 16));
5136
5137 params = 6;
5138 pSMB->MaxSetupCount = 0;
5139 pSMB->Reserved = 0;
5140 pSMB->Flags = 0;
5141 pSMB->Timeout = 0;
5142 pSMB->Reserved2 = 0;
5143 param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
5144 offset = param_offset + params;
5145
5146 data_offset = (FILE_UNIX_BASIC_INFO *)
5147 ((char *)(&pSMB->hdr.Protocol) + offset);
5148 count = sizeof(FILE_UNIX_BASIC_INFO);
5149
5150 pSMB->MaxParameterCount = cpu_to_le16(2);
5151 /* BB find max SMB PDU from sess */
5152 pSMB->MaxDataCount = cpu_to_le16(1000);
5153 pSMB->SetupCount = 1;
5154 pSMB->Reserved3 = 0;
5155 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_FILE_INFORMATION);
5156 byte_count = 3 /* pad */ + params + count;
5157 pSMB->DataCount = cpu_to_le16(count);
5158 pSMB->ParameterCount = cpu_to_le16(params);
5159 pSMB->TotalDataCount = pSMB->DataCount;
5160 pSMB->TotalParameterCount = pSMB->ParameterCount;
5161 pSMB->ParameterOffset = cpu_to_le16(param_offset);
5162 pSMB->DataOffset = cpu_to_le16(offset);
5163 pSMB->Fid = fid;
5164 pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC);
5165 pSMB->Reserved4 = 0;
5166 pSMB->hdr.smb_buf_length += byte_count;
5167 pSMB->ByteCount = cpu_to_le16(byte_count);
5168
5169 cifs_fill_unix_set_info(data_offset, args);
5170
5171 rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0);
5172 if (rc)
5173 cFYI(1, ("Send error in Set Time (SetFileInfo) = %d", rc));
5174
5175 /* Note: On -EAGAIN error only caller can retry on handle based calls
5176 since file handle passed in no longer valid */
5177
5178 return rc;
5179}
5180
5181int
5182CIFSSMBUnixSetPathInfo(const int xid, struct cifsTconInfo *tcon, char *fileName,
5183 const struct cifs_unix_set_info_args *args,
5184 const struct nls_table *nls_codepage, int remap)
5081{ 5185{
5082 TRANSACTION2_SPI_REQ *pSMB = NULL; 5186 TRANSACTION2_SPI_REQ *pSMB = NULL;
5083 TRANSACTION2_SPI_RSP *pSMBr = NULL; 5187 TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -5086,7 +5190,6 @@ CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *tcon, char *fileName,
5086 int bytes_returned = 0; 5190 int bytes_returned = 0;
5087 FILE_UNIX_BASIC_INFO *data_offset; 5191 FILE_UNIX_BASIC_INFO *data_offset;
5088 __u16 params, param_offset, offset, count, byte_count; 5192 __u16 params, param_offset, offset, count, byte_count;
5089 __u64 mode = args->mode;
5090 5193
5091 cFYI(1, ("In SetUID/GID/Mode")); 5194 cFYI(1, ("In SetUID/GID/Mode"));
5092setPermsRetry: 5195setPermsRetry:
@@ -5137,38 +5240,8 @@ setPermsRetry:
5137 pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC); 5240 pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC);
5138 pSMB->Reserved4 = 0; 5241 pSMB->Reserved4 = 0;
5139 pSMB->hdr.smb_buf_length += byte_count; 5242 pSMB->hdr.smb_buf_length += byte_count;
5140 /* Samba server ignores set of file size to zero due to bugs in some
5141 older clients, but we should be precise - we use SetFileSize to
5142 set file size and do not want to truncate file size to zero
5143 accidently as happened on one Samba server beta by putting
5144 zero instead of -1 here */
5145 data_offset->EndOfFile = cpu_to_le64(NO_CHANGE_64);
5146 data_offset->NumOfBytes = cpu_to_le64(NO_CHANGE_64);
5147 data_offset->LastStatusChange = cpu_to_le64(args->ctime);
5148 data_offset->LastAccessTime = cpu_to_le64(args->atime);
5149 data_offset->LastModificationTime = cpu_to_le64(args->mtime);
5150 data_offset->Uid = cpu_to_le64(args->uid);
5151 data_offset->Gid = cpu_to_le64(args->gid);
5152 /* better to leave device as zero when it is */
5153 data_offset->DevMajor = cpu_to_le64(MAJOR(args->device));
5154 data_offset->DevMinor = cpu_to_le64(MINOR(args->device));
5155 data_offset->Permissions = cpu_to_le64(mode);
5156
5157 if (S_ISREG(mode))
5158 data_offset->Type = cpu_to_le32(UNIX_FILE);
5159 else if (S_ISDIR(mode))
5160 data_offset->Type = cpu_to_le32(UNIX_DIR);
5161 else if (S_ISLNK(mode))
5162 data_offset->Type = cpu_to_le32(UNIX_SYMLINK);
5163 else if (S_ISCHR(mode))
5164 data_offset->Type = cpu_to_le32(UNIX_CHARDEV);
5165 else if (S_ISBLK(mode))
5166 data_offset->Type = cpu_to_le32(UNIX_BLOCKDEV);
5167 else if (S_ISFIFO(mode))
5168 data_offset->Type = cpu_to_le32(UNIX_FIFO);
5169 else if (S_ISSOCK(mode))
5170 data_offset->Type = cpu_to_le32(UNIX_SOCKET);
5171 5243
5244 cifs_fill_unix_set_info(data_offset, args);
5172 5245
5173 pSMB->ByteCount = cpu_to_le16(byte_count); 5246 pSMB->ByteCount = cpu_to_le16(byte_count);
5174 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 5247 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 97f4311b9a8e..e16d7592116a 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -70,7 +70,6 @@ struct smb_vol {
70 mode_t file_mode; 70 mode_t file_mode;
71 mode_t dir_mode; 71 mode_t dir_mode;
72 unsigned secFlg; 72 unsigned secFlg;
73 bool rw:1;
74 bool retry:1; 73 bool retry:1;
75 bool intr:1; 74 bool intr:1;
76 bool setuids:1; 75 bool setuids:1;
@@ -832,7 +831,6 @@ cifs_parse_mount_options(char *options, const char *devname,
832 vol->dir_mode = vol->file_mode = S_IRUGO | S_IXUGO | S_IWUSR; 831 vol->dir_mode = vol->file_mode = S_IRUGO | S_IXUGO | S_IWUSR;
833 832
834 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */ 833 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */
835 vol->rw = true;
836 /* default is always to request posix paths. */ 834 /* default is always to request posix paths. */
837 vol->posix_paths = 1; 835 vol->posix_paths = 1;
838 /* default to using server inode numbers where available */ 836 /* default to using server inode numbers where available */
@@ -1199,7 +1197,9 @@ cifs_parse_mount_options(char *options, const char *devname,
1199 } else if (strnicmp(data, "guest", 5) == 0) { 1197 } else if (strnicmp(data, "guest", 5) == 0) {
1200 /* ignore */ 1198 /* ignore */
1201 } else if (strnicmp(data, "rw", 2) == 0) { 1199 } else if (strnicmp(data, "rw", 2) == 0) {
1202 vol->rw = true; 1200 /* ignore */
1201 } else if (strnicmp(data, "ro", 2) == 0) {
1202 /* ignore */
1203 } else if (strnicmp(data, "noblocksend", 11) == 0) { 1203 } else if (strnicmp(data, "noblocksend", 11) == 0) {
1204 vol->noblocksnd = 1; 1204 vol->noblocksnd = 1;
1205 } else if (strnicmp(data, "noautotune", 10) == 0) { 1205 } else if (strnicmp(data, "noautotune", 10) == 0) {
@@ -1218,8 +1218,6 @@ cifs_parse_mount_options(char *options, const char *devname,
1218 parse these options again and set anything and it 1218 parse these options again and set anything and it
1219 is ok to just ignore them */ 1219 is ok to just ignore them */
1220 continue; 1220 continue;
1221 } else if (strnicmp(data, "ro", 2) == 0) {
1222 vol->rw = false;
1223 } else if (strnicmp(data, "hard", 4) == 0) { 1221 } else if (strnicmp(data, "hard", 4) == 0) {
1224 vol->retry = 1; 1222 vol->retry = 1;
1225 } else if (strnicmp(data, "soft", 4) == 0) { 1223 } else if (strnicmp(data, "soft", 4) == 0) {
@@ -1386,8 +1384,10 @@ cifs_find_tcp_session(struct sockaddr_storage *addr)
1386 server->addr.sockAddr.sin_addr.s_addr)) 1384 server->addr.sockAddr.sin_addr.s_addr))
1387 continue; 1385 continue;
1388 else if (addr->ss_family == AF_INET6 && 1386 else if (addr->ss_family == AF_INET6 &&
1389 !ipv6_addr_equal(&server->addr.sockAddr6.sin6_addr, 1387 (!ipv6_addr_equal(&server->addr.sockAddr6.sin6_addr,
1390 &addr6->sin6_addr)) 1388 &addr6->sin6_addr) ||
1389 server->addr.sockAddr6.sin6_scope_id !=
1390 addr6->sin6_scope_id))
1391 continue; 1391 continue;
1392 1392
1393 ++server->srv_count; 1393 ++server->srv_count;
@@ -1433,28 +1433,15 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1433 1433
1434 memset(&addr, 0, sizeof(struct sockaddr_storage)); 1434 memset(&addr, 0, sizeof(struct sockaddr_storage));
1435 1435
1436 if (volume_info->UNCip && volume_info->UNC) { 1436 cFYI(1, ("UNC: %s ip: %s", volume_info->UNC, volume_info->UNCip));
1437 rc = cifs_inet_pton(AF_INET, volume_info->UNCip,
1438 &sin_server->sin_addr.s_addr);
1439
1440 if (rc <= 0) {
1441 /* not ipv4 address, try ipv6 */
1442 rc = cifs_inet_pton(AF_INET6, volume_info->UNCip,
1443 &sin_server6->sin6_addr.in6_u);
1444 if (rc > 0)
1445 addr.ss_family = AF_INET6;
1446 } else {
1447 addr.ss_family = AF_INET;
1448 }
1449 1437
1450 if (rc <= 0) { 1438 if (volume_info->UNCip && volume_info->UNC) {
1439 rc = cifs_convert_address(volume_info->UNCip, &addr);
1440 if (!rc) {
1451 /* we failed translating address */ 1441 /* we failed translating address */
1452 rc = -EINVAL; 1442 rc = -EINVAL;
1453 goto out_err; 1443 goto out_err;
1454 } 1444 }
1455
1456 cFYI(1, ("UNC: %s ip: %s", volume_info->UNC,
1457 volume_info->UNCip));
1458 } else if (volume_info->UNCip) { 1445 } else if (volume_info->UNCip) {
1459 /* BB using ip addr as tcp_ses name to connect to the 1446 /* BB using ip addr as tcp_ses name to connect to the
1460 DFS root below */ 1447 DFS root below */
@@ -1513,14 +1500,14 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
1513 cFYI(1, ("attempting ipv6 connect")); 1500 cFYI(1, ("attempting ipv6 connect"));
1514 /* BB should we allow ipv6 on port 139? */ 1501 /* BB should we allow ipv6 on port 139? */
1515 /* other OS never observed in Wild doing 139 with v6 */ 1502 /* other OS never observed in Wild doing 139 with v6 */
1503 sin_server6->sin6_port = htons(volume_info->port);
1516 memcpy(&tcp_ses->addr.sockAddr6, sin_server6, 1504 memcpy(&tcp_ses->addr.sockAddr6, sin_server6,
1517 sizeof(struct sockaddr_in6)); 1505 sizeof(struct sockaddr_in6));
1518 sin_server6->sin6_port = htons(volume_info->port);
1519 rc = ipv6_connect(tcp_ses); 1506 rc = ipv6_connect(tcp_ses);
1520 } else { 1507 } else {
1508 sin_server->sin_port = htons(volume_info->port);
1521 memcpy(&tcp_ses->addr.sockAddr, sin_server, 1509 memcpy(&tcp_ses->addr.sockAddr, sin_server,
1522 sizeof(struct sockaddr_in)); 1510 sizeof(struct sockaddr_in));
1523 sin_server->sin_port = htons(volume_info->port);
1524 rc = ipv4_connect(tcp_ses); 1511 rc = ipv4_connect(tcp_ses);
1525 } 1512 }
1526 if (rc < 0) { 1513 if (rc < 0) {
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 3758965d73d5..4326ffd90fa9 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -188,6 +188,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
188 FILE_UNIX_BASIC_INFO *presp_data; 188 FILE_UNIX_BASIC_INFO *presp_data;
189 __u32 posix_flags = 0; 189 __u32 posix_flags = 0;
190 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 190 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
191 struct cifs_fattr fattr;
191 192
192 cFYI(1, ("posix open %s", full_path)); 193 cFYI(1, ("posix open %s", full_path));
193 194
@@ -236,22 +237,21 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
236 if (presp_data->Type == cpu_to_le32(-1)) 237 if (presp_data->Type == cpu_to_le32(-1))
237 goto posix_open_ret; /* open ok, caller does qpathinfo */ 238 goto posix_open_ret; /* open ok, caller does qpathinfo */
238 239
239 /* get new inode and set it up */
240 if (!pinode) 240 if (!pinode)
241 goto posix_open_ret; /* caller does not need info */ 241 goto posix_open_ret; /* caller does not need info */
242 242
243 cifs_unix_basic_to_fattr(&fattr, presp_data, cifs_sb);
244
245 /* get new inode and set it up */
243 if (*pinode == NULL) { 246 if (*pinode == NULL) {
244 __u64 unique_id = le64_to_cpu(presp_data->UniqueId); 247 *pinode = cifs_iget(sb, &fattr);
245 *pinode = cifs_new_inode(sb, &unique_id); 248 if (!*pinode) {
249 rc = -ENOMEM;
250 goto posix_open_ret;
251 }
252 } else {
253 cifs_fattr_to_inode(*pinode, &fattr);
246 } 254 }
247 /* else an inode was passed in. Update its info, don't create one */
248
249 /* We do not need to close the file if new_inode fails since
250 the caller will retry qpathinfo as long as inode is null */
251 if (*pinode == NULL)
252 goto posix_open_ret;
253
254 posix_fill_in_inode(*pinode, presp_data, 1);
255 255
256 cifs_fill_fileinfo(*pinode, *pnetfid, cifs_sb->tcon, write_only); 256 cifs_fill_fileinfo(*pinode, *pnetfid, cifs_sb->tcon, write_only);
257 257
@@ -307,8 +307,9 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
307 307
308 full_path = build_path_from_dentry(direntry); 308 full_path = build_path_from_dentry(direntry);
309 if (full_path == NULL) { 309 if (full_path == NULL) {
310 rc = -ENOMEM;
310 FreeXid(xid); 311 FreeXid(xid);
311 return -ENOMEM; 312 return rc;
312 } 313 }
313 314
314 if (oplockEnabled) 315 if (oplockEnabled)
@@ -424,9 +425,10 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
424 args.uid = NO_CHANGE_64; 425 args.uid = NO_CHANGE_64;
425 args.gid = NO_CHANGE_64; 426 args.gid = NO_CHANGE_64;
426 } 427 }
427 CIFSSMBUnixSetInfo(xid, tcon, full_path, &args, 428 CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
428 cifs_sb->local_nls, 429 cifs_sb->local_nls,
429 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 430 cifs_sb->mnt_cifs_flags &
431 CIFS_MOUNT_MAP_SPECIAL_CHR);
430 } else { 432 } else {
431 /* BB implement mode setting via Windows security 433 /* BB implement mode setting via Windows security
432 descriptors e.g. */ 434 descriptors e.g. */
@@ -514,10 +516,10 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
514 args.uid = NO_CHANGE_64; 516 args.uid = NO_CHANGE_64;
515 args.gid = NO_CHANGE_64; 517 args.gid = NO_CHANGE_64;
516 } 518 }
517 rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path, 519 rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, &args,
518 &args, cifs_sb->local_nls, 520 cifs_sb->local_nls,
519 cifs_sb->mnt_cifs_flags & 521 cifs_sb->mnt_cifs_flags &
520 CIFS_MOUNT_MAP_SPECIAL_CHR); 522 CIFS_MOUNT_MAP_SPECIAL_CHR);
521 523
522 if (!rc) { 524 if (!rc) {
523 rc = cifs_get_inode_info_unix(&newinode, full_path, 525 rc = cifs_get_inode_info_unix(&newinode, full_path,
@@ -540,8 +542,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
540 buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); 542 buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
541 if (buf == NULL) { 543 if (buf == NULL) {
542 kfree(full_path); 544 kfree(full_path);
545 rc = -ENOMEM;
543 FreeXid(xid); 546 FreeXid(xid);
544 return -ENOMEM; 547 return rc;
545 } 548 }
546 549
547 rc = CIFSSMBOpen(xid, pTcon, full_path, 550 rc = CIFSSMBOpen(xid, pTcon, full_path,
@@ -641,6 +644,15 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
641 } 644 }
642 } 645 }
643 646
647 /*
648 * O_EXCL: optimize away the lookup, but don't hash the dentry. Let
649 * the VFS handle the create.
650 */
651 if (nd->flags & LOOKUP_EXCL) {
652 d_instantiate(direntry, NULL);
653 return 0;
654 }
655
644 /* can not grab the rename sem here since it would 656 /* can not grab the rename sem here since it would
645 deadlock in the cases (beginning of sys_rename itself) 657 deadlock in the cases (beginning of sys_rename itself)
646 in which we already have the sb rename sem */ 658 in which we already have the sb rename sem */
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c
index df4a306f697e..87948147d7ec 100644
--- a/fs/cifs/dns_resolve.c
+++ b/fs/cifs/dns_resolve.c
@@ -35,26 +35,11 @@
35 * 0 - name is not IP 35 * 0 - name is not IP
36 */ 36 */
37static int 37static int
38is_ip(const char *name) 38is_ip(char *name)
39{ 39{
40 int rc; 40 struct sockaddr_storage ss;
41 struct sockaddr_in sin_server; 41
42 struct sockaddr_in6 sin_server6; 42 return cifs_convert_address(name, &ss);
43
44 rc = cifs_inet_pton(AF_INET, name,
45 &sin_server.sin_addr.s_addr);
46
47 if (rc <= 0) {
48 /* not ipv4 address, try ipv6 */
49 rc = cifs_inet_pton(AF_INET6, name,
50 &sin_server6.sin6_addr.in6_u);
51 if (rc > 0)
52 return 1;
53 } else {
54 return 1;
55 }
56 /* we failed translating address */
57 return 0;
58} 43}
59 44
60static int 45static int
@@ -72,7 +57,7 @@ dns_resolver_instantiate(struct key *key, const void *data,
72 ip[datalen] = '\0'; 57 ip[datalen] = '\0';
73 58
74 /* make sure this looks like an address */ 59 /* make sure this looks like an address */
75 if (!is_ip((const char *) ip)) { 60 if (!is_ip(ip)) {
76 kfree(ip); 61 kfree(ip);
77 return -EINVAL; 62 return -EINVAL;
78 } 63 }
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 06866841b97f..c34b7f8a217b 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -300,14 +300,16 @@ int cifs_open(struct inode *inode, struct file *file)
300 pCifsInode = CIFS_I(file->f_path.dentry->d_inode); 300 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
301 pCifsFile = cifs_fill_filedata(file); 301 pCifsFile = cifs_fill_filedata(file);
302 if (pCifsFile) { 302 if (pCifsFile) {
303 rc = 0;
303 FreeXid(xid); 304 FreeXid(xid);
304 return 0; 305 return rc;
305 } 306 }
306 307
307 full_path = build_path_from_dentry(file->f_path.dentry); 308 full_path = build_path_from_dentry(file->f_path.dentry);
308 if (full_path == NULL) { 309 if (full_path == NULL) {
310 rc = -ENOMEM;
309 FreeXid(xid); 311 FreeXid(xid);
310 return -ENOMEM; 312 return rc;
311 } 313 }
312 314
313 cFYI(1, ("inode = 0x%p file flags are 0x%x for %s", 315 cFYI(1, ("inode = 0x%p file flags are 0x%x for %s",
@@ -446,9 +448,9 @@ int cifs_open(struct inode *inode, struct file *file)
446 .mtime = NO_CHANGE_64, 448 .mtime = NO_CHANGE_64,
447 .device = 0, 449 .device = 0,
448 }; 450 };
449 CIFSSMBUnixSetInfo(xid, tcon, full_path, &args, 451 CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args,
450 cifs_sb->local_nls, 452 cifs_sb->local_nls,
451 cifs_sb->mnt_cifs_flags & 453 cifs_sb->mnt_cifs_flags &
452 CIFS_MOUNT_MAP_SPECIAL_CHR); 454 CIFS_MOUNT_MAP_SPECIAL_CHR);
453 } 455 }
454 } 456 }
@@ -491,11 +493,12 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
491 return -EBADF; 493 return -EBADF;
492 494
493 xid = GetXid(); 495 xid = GetXid();
494 mutex_unlock(&pCifsFile->fh_mutex); 496 mutex_lock(&pCifsFile->fh_mutex);
495 if (!pCifsFile->invalidHandle) { 497 if (!pCifsFile->invalidHandle) {
496 mutex_lock(&pCifsFile->fh_mutex); 498 mutex_unlock(&pCifsFile->fh_mutex);
499 rc = 0;
497 FreeXid(xid); 500 FreeXid(xid);
498 return 0; 501 return rc;
499 } 502 }
500 503
501 if (file->f_path.dentry == NULL) { 504 if (file->f_path.dentry == NULL) {
@@ -524,7 +527,7 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
524 if (full_path == NULL) { 527 if (full_path == NULL) {
525 rc = -ENOMEM; 528 rc = -ENOMEM;
526reopen_error_exit: 529reopen_error_exit:
527 mutex_lock(&pCifsFile->fh_mutex); 530 mutex_unlock(&pCifsFile->fh_mutex);
528 FreeXid(xid); 531 FreeXid(xid);
529 return rc; 532 return rc;
530 } 533 }
@@ -566,14 +569,14 @@ reopen_error_exit:
566 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 569 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
567 CIFS_MOUNT_MAP_SPECIAL_CHR); 570 CIFS_MOUNT_MAP_SPECIAL_CHR);
568 if (rc) { 571 if (rc) {
569 mutex_lock(&pCifsFile->fh_mutex); 572 mutex_unlock(&pCifsFile->fh_mutex);
570 cFYI(1, ("cifs_open returned 0x%x", rc)); 573 cFYI(1, ("cifs_open returned 0x%x", rc));
571 cFYI(1, ("oplock: %d", oplock)); 574 cFYI(1, ("oplock: %d", oplock));
572 } else { 575 } else {
573reopen_success: 576reopen_success:
574 pCifsFile->netfid = netfid; 577 pCifsFile->netfid = netfid;
575 pCifsFile->invalidHandle = false; 578 pCifsFile->invalidHandle = false;
576 mutex_lock(&pCifsFile->fh_mutex); 579 mutex_unlock(&pCifsFile->fh_mutex);
577 pCifsInode = CIFS_I(inode); 580 pCifsInode = CIFS_I(inode);
578 if (pCifsInode) { 581 if (pCifsInode) {
579 if (can_flush) { 582 if (can_flush) {
@@ -845,8 +848,9 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
845 tcon = cifs_sb->tcon; 848 tcon = cifs_sb->tcon;
846 849
847 if (file->private_data == NULL) { 850 if (file->private_data == NULL) {
851 rc = -EBADF;
848 FreeXid(xid); 852 FreeXid(xid);
849 return -EBADF; 853 return rc;
850 } 854 }
851 netfid = ((struct cifsFileInfo *)file->private_data)->netfid; 855 netfid = ((struct cifsFileInfo *)file->private_data)->netfid;
852 856
@@ -1805,8 +1809,9 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1805 pTcon = cifs_sb->tcon; 1809 pTcon = cifs_sb->tcon;
1806 1810
1807 if (file->private_data == NULL) { 1811 if (file->private_data == NULL) {
1812 rc = -EBADF;
1808 FreeXid(xid); 1813 FreeXid(xid);
1809 return -EBADF; 1814 return rc;
1810 } 1815 }
1811 open_file = (struct cifsFileInfo *)file->private_data; 1816 open_file = (struct cifsFileInfo *)file->private_data;
1812 1817
@@ -1885,8 +1890,9 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1885 pTcon = cifs_sb->tcon; 1890 pTcon = cifs_sb->tcon;
1886 1891
1887 if (file->private_data == NULL) { 1892 if (file->private_data == NULL) {
1893 rc = -EBADF;
1888 FreeXid(xid); 1894 FreeXid(xid);
1889 return -EBADF; 1895 return rc;
1890 } 1896 }
1891 open_file = (struct cifsFileInfo *)file->private_data; 1897 open_file = (struct cifsFileInfo *)file->private_data;
1892 1898
@@ -2019,8 +2025,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
2019 2025
2020 xid = GetXid(); 2026 xid = GetXid();
2021 if (file->private_data == NULL) { 2027 if (file->private_data == NULL) {
2028 rc = -EBADF;
2022 FreeXid(xid); 2029 FreeXid(xid);
2023 return -EBADF; 2030 return rc;
2024 } 2031 }
2025 open_file = (struct cifsFileInfo *)file->private_data; 2032 open_file = (struct cifsFileInfo *)file->private_data;
2026 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 2033 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
@@ -2185,8 +2192,9 @@ static int cifs_readpage(struct file *file, struct page *page)
2185 xid = GetXid(); 2192 xid = GetXid();
2186 2193
2187 if (file->private_data == NULL) { 2194 if (file->private_data == NULL) {
2195 rc = -EBADF;
2188 FreeXid(xid); 2196 FreeXid(xid);
2189 return -EBADF; 2197 return rc;
2190 } 2198 }
2191 2199
2192 cFYI(1, ("readpage %p at offset %d 0x%x\n", 2200 cFYI(1, ("readpage %p at offset %d 0x%x\n",
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index fad882b075ba..18afe57b2461 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -77,239 +77,202 @@ static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral)
77 } 77 }
78} 78}
79 79
80static void cifs_unix_info_to_inode(struct inode *inode, 80/* populate an inode with info from a cifs_fattr struct */
81 FILE_UNIX_BASIC_INFO *info, int force_uid_gid) 81void
82cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
82{ 83{
84 struct cifsInodeInfo *cifs_i = CIFS_I(inode);
83 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 85 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
84 struct cifsInodeInfo *cifsInfo = CIFS_I(inode); 86 unsigned long oldtime = cifs_i->time;
85 __u64 num_of_bytes = le64_to_cpu(info->NumOfBytes); 87
86 __u64 end_of_file = le64_to_cpu(info->EndOfFile); 88 inode->i_atime = fattr->cf_atime;
89 inode->i_mtime = fattr->cf_mtime;
90 inode->i_ctime = fattr->cf_ctime;
91 inode->i_rdev = fattr->cf_rdev;
92 inode->i_nlink = fattr->cf_nlink;
93 inode->i_uid = fattr->cf_uid;
94 inode->i_gid = fattr->cf_gid;
95
96 /* if dynperm is set, don't clobber existing mode */
97 if (inode->i_state & I_NEW ||
98 !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM))
99 inode->i_mode = fattr->cf_mode;
100
101 cifs_i->cifsAttrs = fattr->cf_cifsattrs;
102 cifs_i->uniqueid = fattr->cf_uniqueid;
103
104 if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL)
105 cifs_i->time = 0;
106 else
107 cifs_i->time = jiffies;
108
109 cFYI(1, ("inode 0x%p old_time=%ld new_time=%ld", inode,
110 oldtime, cifs_i->time));
87 111
88 inode->i_atime = cifs_NTtimeToUnix(info->LastAccessTime); 112 cifs_i->delete_pending = fattr->cf_flags & CIFS_FATTR_DELETE_PENDING;
89 inode->i_mtime = 113
90 cifs_NTtimeToUnix(info->LastModificationTime); 114 /*
91 inode->i_ctime = cifs_NTtimeToUnix(info->LastStatusChange); 115 * Can't safely change the file size here if the client is writing to
92 inode->i_mode = le64_to_cpu(info->Permissions); 116 * it due to potential races.
117 */
118 spin_lock(&inode->i_lock);
119 if (is_size_safe_to_change(cifs_i, fattr->cf_eof)) {
120 i_size_write(inode, fattr->cf_eof);
121
122 /*
123 * i_blocks is not related to (i_size / i_blksize),
124 * but instead 512 byte (2**9) size is required for
125 * calculating num blocks.
126 */
127 inode->i_blocks = (512 - 1 + fattr->cf_bytes) >> 9;
128 }
129 spin_unlock(&inode->i_lock);
130
131 cifs_set_ops(inode, fattr->cf_flags & CIFS_FATTR_DFS_REFERRAL);
132}
133
134/* Fill a cifs_fattr struct with info from FILE_UNIX_BASIC_INFO. */
135void
136cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info,
137 struct cifs_sb_info *cifs_sb)
138{
139 memset(fattr, 0, sizeof(*fattr));
140 fattr->cf_uniqueid = le64_to_cpu(info->UniqueId);
141 fattr->cf_bytes = le64_to_cpu(info->NumOfBytes);
142 fattr->cf_eof = le64_to_cpu(info->EndOfFile);
143
144 fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
145 fattr->cf_mtime = cifs_NTtimeToUnix(info->LastModificationTime);
146 fattr->cf_ctime = cifs_NTtimeToUnix(info->LastStatusChange);
147 fattr->cf_mode = le64_to_cpu(info->Permissions);
93 148
94 /* 149 /*
95 * Since we set the inode type below we need to mask off 150 * Since we set the inode type below we need to mask off
96 * to avoid strange results if bits set above. 151 * to avoid strange results if bits set above.
97 */ 152 */
98 inode->i_mode &= ~S_IFMT; 153 fattr->cf_mode &= ~S_IFMT;
99 switch (le32_to_cpu(info->Type)) { 154 switch (le32_to_cpu(info->Type)) {
100 case UNIX_FILE: 155 case UNIX_FILE:
101 inode->i_mode |= S_IFREG; 156 fattr->cf_mode |= S_IFREG;
157 fattr->cf_dtype = DT_REG;
102 break; 158 break;
103 case UNIX_SYMLINK: 159 case UNIX_SYMLINK:
104 inode->i_mode |= S_IFLNK; 160 fattr->cf_mode |= S_IFLNK;
161 fattr->cf_dtype = DT_LNK;
105 break; 162 break;
106 case UNIX_DIR: 163 case UNIX_DIR:
107 inode->i_mode |= S_IFDIR; 164 fattr->cf_mode |= S_IFDIR;
165 fattr->cf_dtype = DT_DIR;
108 break; 166 break;
109 case UNIX_CHARDEV: 167 case UNIX_CHARDEV:
110 inode->i_mode |= S_IFCHR; 168 fattr->cf_mode |= S_IFCHR;
111 inode->i_rdev = MKDEV(le64_to_cpu(info->DevMajor), 169 fattr->cf_dtype = DT_CHR;
112 le64_to_cpu(info->DevMinor) & MINORMASK); 170 fattr->cf_rdev = MKDEV(le64_to_cpu(info->DevMajor),
171 le64_to_cpu(info->DevMinor) & MINORMASK);
113 break; 172 break;
114 case UNIX_BLOCKDEV: 173 case UNIX_BLOCKDEV:
115 inode->i_mode |= S_IFBLK; 174 fattr->cf_mode |= S_IFBLK;
116 inode->i_rdev = MKDEV(le64_to_cpu(info->DevMajor), 175 fattr->cf_dtype = DT_BLK;
117 le64_to_cpu(info->DevMinor) & MINORMASK); 176 fattr->cf_rdev = MKDEV(le64_to_cpu(info->DevMajor),
177 le64_to_cpu(info->DevMinor) & MINORMASK);
118 break; 178 break;
119 case UNIX_FIFO: 179 case UNIX_FIFO:
120 inode->i_mode |= S_IFIFO; 180 fattr->cf_mode |= S_IFIFO;
181 fattr->cf_dtype = DT_FIFO;
121 break; 182 break;
122 case UNIX_SOCKET: 183 case UNIX_SOCKET:
123 inode->i_mode |= S_IFSOCK; 184 fattr->cf_mode |= S_IFSOCK;
185 fattr->cf_dtype = DT_SOCK;
124 break; 186 break;
125 default: 187 default:
126 /* safest to call it a file if we do not know */ 188 /* safest to call it a file if we do not know */
127 inode->i_mode |= S_IFREG; 189 fattr->cf_mode |= S_IFREG;
190 fattr->cf_dtype = DT_REG;
128 cFYI(1, ("unknown type %d", le32_to_cpu(info->Type))); 191 cFYI(1, ("unknown type %d", le32_to_cpu(info->Type)));
129 break; 192 break;
130 } 193 }
131 194
132 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) && 195 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
133 !force_uid_gid) 196 fattr->cf_uid = cifs_sb->mnt_uid;
134 inode->i_uid = cifs_sb->mnt_uid;
135 else 197 else
136 inode->i_uid = le64_to_cpu(info->Uid); 198 fattr->cf_uid = le64_to_cpu(info->Uid);
137 199
138 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) && 200 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
139 !force_uid_gid) 201 fattr->cf_gid = cifs_sb->mnt_gid;
140 inode->i_gid = cifs_sb->mnt_gid;
141 else 202 else
142 inode->i_gid = le64_to_cpu(info->Gid); 203 fattr->cf_gid = le64_to_cpu(info->Gid);
143
144 inode->i_nlink = le64_to_cpu(info->Nlinks);
145
146 cifsInfo->server_eof = end_of_file;
147 spin_lock(&inode->i_lock);
148 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
149 /*
150 * We can not safely change the file size here if the client
151 * is writing to it due to potential races.
152 */
153 i_size_write(inode, end_of_file);
154 204
155 /* 205 fattr->cf_nlink = le64_to_cpu(info->Nlinks);
156 * i_blocks is not related to (i_size / i_blksize),
157 * but instead 512 byte (2**9) size is required for
158 * calculating num blocks.
159 */
160 inode->i_blocks = (512 - 1 + num_of_bytes) >> 9;
161 }
162 spin_unlock(&inode->i_lock);
163} 206}
164 207
165
166/* 208/*
167 * Needed to setup inode data for the directory which is the 209 * Fill a cifs_fattr struct with fake inode info.
168 * junction to the new submount (ie to setup the fake directory
169 * which represents a DFS referral)
170 */
171static void fill_fake_finddataunix(FILE_UNIX_BASIC_INFO *pfnd_dat,
172 struct super_block *sb)
173{
174 struct inode *pinode = NULL;
175
176 memset(pfnd_dat, 0, sizeof(FILE_UNIX_BASIC_INFO));
177
178/* __le64 pfnd_dat->EndOfFile = cpu_to_le64(0);
179 __le64 pfnd_dat->NumOfBytes = cpu_to_le64(0);
180 __u64 UniqueId = 0; */
181 pfnd_dat->LastStatusChange =
182 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
183 pfnd_dat->LastAccessTime =
184 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
185 pfnd_dat->LastModificationTime =
186 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
187 pfnd_dat->Type = cpu_to_le32(UNIX_DIR);
188 pfnd_dat->Permissions = cpu_to_le64(S_IXUGO | S_IRWXU);
189 pfnd_dat->Nlinks = cpu_to_le64(2);
190 if (sb->s_root)
191 pinode = sb->s_root->d_inode;
192 if (pinode == NULL)
193 return;
194
195 /* fill in default values for the remaining based on root
196 inode since we can not query the server for this inode info */
197 pfnd_dat->DevMajor = cpu_to_le64(MAJOR(pinode->i_rdev));
198 pfnd_dat->DevMinor = cpu_to_le64(MINOR(pinode->i_rdev));
199 pfnd_dat->Uid = cpu_to_le64(pinode->i_uid);
200 pfnd_dat->Gid = cpu_to_le64(pinode->i_gid);
201}
202
203/**
204 * cifs_new inode - create new inode, initialize, and hash it
205 * @sb - pointer to superblock
206 * @inum - if valid pointer and serverino is enabled, replace i_ino with val
207 *
208 * Create a new inode, initialize it for CIFS and hash it. Returns the new
209 * inode or NULL if one couldn't be allocated.
210 * 210 *
211 * If the share isn't mounted with "serverino" or inum is a NULL pointer then 211 * Needed to setup cifs_fattr data for the directory which is the
212 * we'll just use the inode number assigned by new_inode(). Note that this can 212 * junction to the new submount (ie to setup the fake directory
213 * mean i_ino collisions since the i_ino assigned by new_inode is not 213 * which represents a DFS referral).
214 * guaranteed to be unique.
215 */ 214 */
216struct inode * 215void
217cifs_new_inode(struct super_block *sb, __u64 *inum) 216cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb)
218{ 217{
219 struct inode *inode; 218 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
220
221 inode = new_inode(sb);
222 if (inode == NULL)
223 return NULL;
224
225 /*
226 * BB: Is i_ino == 0 legal? Here, we assume that it is. If it isn't we
227 * stop passing inum as ptr. Are there sanity checks we can use to
228 * ensure that the server is really filling in that field? Also,
229 * if serverino is disabled, perhaps we should be using iunique()?
230 */
231 if (inum && (CIFS_SB(sb)->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM))
232 inode->i_ino = (unsigned long) *inum;
233
234 /*
235 * must set this here instead of cifs_alloc_inode since VFS will
236 * clobber i_flags
237 */
238 if (sb->s_flags & MS_NOATIME)
239 inode->i_flags |= S_NOATIME | S_NOCMTIME;
240
241 insert_inode_hash(inode);
242 219
243 return inode; 220 cFYI(1, ("creating fake fattr for DFS referral"));
221
222 memset(fattr, 0, sizeof(*fattr));
223 fattr->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU;
224 fattr->cf_uid = cifs_sb->mnt_uid;
225 fattr->cf_gid = cifs_sb->mnt_gid;
226 fattr->cf_atime = CURRENT_TIME;
227 fattr->cf_ctime = CURRENT_TIME;
228 fattr->cf_mtime = CURRENT_TIME;
229 fattr->cf_nlink = 2;
230 fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL;
244} 231}
245 232
246int cifs_get_inode_info_unix(struct inode **pinode, 233int cifs_get_inode_info_unix(struct inode **pinode,
247 const unsigned char *full_path, struct super_block *sb, int xid) 234 const unsigned char *full_path,
235 struct super_block *sb, int xid)
248{ 236{
249 int rc = 0; 237 int rc;
250 FILE_UNIX_BASIC_INFO find_data; 238 FILE_UNIX_BASIC_INFO find_data;
251 struct cifsTconInfo *pTcon; 239 struct cifs_fattr fattr;
252 struct inode *inode; 240 struct cifsTconInfo *tcon;
253 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 241 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
254 bool is_dfs_referral = false;
255 struct cifsInodeInfo *cifsInfo;
256 __u64 num_of_bytes;
257 __u64 end_of_file;
258 242
259 pTcon = cifs_sb->tcon; 243 tcon = cifs_sb->tcon;
260 cFYI(1, ("Getting info on %s", full_path)); 244 cFYI(1, ("Getting info on %s", full_path));
261 245
262 /* could have done a find first instead but this returns more info */ 246 /* could have done a find first instead but this returns more info */
263 rc = CIFSSMBUnixQPathInfo(xid, pTcon, full_path, &find_data, 247 rc = CIFSSMBUnixQPathInfo(xid, tcon, full_path, &find_data,
264 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & 248 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
265 CIFS_MOUNT_MAP_SPECIAL_CHR); 249 CIFS_MOUNT_MAP_SPECIAL_CHR);
266 if (rc == -EREMOTE && !is_dfs_referral) {
267 is_dfs_referral = true;
268 cFYI(DBG2, ("DFS ref"));
269 /* for DFS, server does not give us real inode data */
270 fill_fake_finddataunix(&find_data, sb);
271 rc = 0;
272 } else if (rc)
273 goto cgiiu_exit;
274 250
275 num_of_bytes = le64_to_cpu(find_data.NumOfBytes); 251 if (!rc) {
276 end_of_file = le64_to_cpu(find_data.EndOfFile); 252 cifs_unix_basic_to_fattr(&fattr, &find_data, cifs_sb);
253 } else if (rc == -EREMOTE) {
254 cifs_create_dfs_fattr(&fattr, sb);
255 rc = 0;
256 } else {
257 return rc;
258 }
277 259
278 /* get new inode */
279 if (*pinode == NULL) { 260 if (*pinode == NULL) {
280 __u64 unique_id = le64_to_cpu(find_data.UniqueId); 261 /* get new inode */
281 *pinode = cifs_new_inode(sb, &unique_id); 262 *pinode = cifs_iget(sb, &fattr);
282 if (*pinode == NULL) { 263 if (!*pinode)
283 rc = -ENOMEM; 264 rc = -ENOMEM;
284 goto cgiiu_exit; 265 } else {
285 } 266 /* we already have inode, update it */
267 cifs_fattr_to_inode(*pinode, &fattr);
286 } 268 }
287 269
288 inode = *pinode;
289 cifsInfo = CIFS_I(inode);
290
291 cFYI(1, ("Old time %ld", cifsInfo->time));
292 cifsInfo->time = jiffies;
293 cFYI(1, ("New time %ld", cifsInfo->time));
294 /* this is ok to set on every inode revalidate */
295 atomic_set(&cifsInfo->inUse, 1);
296
297 cifs_unix_info_to_inode(inode, &find_data, 0);
298
299 if (num_of_bytes < end_of_file)
300 cFYI(1, ("allocation size less than end of file"));
301 cFYI(1, ("Size %ld and blocks %llu",
302 (unsigned long) inode->i_size,
303 (unsigned long long)inode->i_blocks));
304
305 cifs_set_ops(inode, is_dfs_referral);
306cgiiu_exit:
307 return rc; 270 return rc;
308} 271}
309 272
310static int decode_sfu_inode(struct inode *inode, __u64 size, 273static int
311 const unsigned char *path, 274cifs_sfu_type(struct cifs_fattr *fattr, const unsigned char *path,
312 struct cifs_sb_info *cifs_sb, int xid) 275 struct cifs_sb_info *cifs_sb, int xid)
313{ 276{
314 int rc; 277 int rc;
315 int oplock = 0; 278 int oplock = 0;
@@ -321,10 +284,15 @@ static int decode_sfu_inode(struct inode *inode, __u64 size,
321 284
322 pbuf = buf; 285 pbuf = buf;
323 286
324 if (size == 0) { 287 fattr->cf_mode &= ~S_IFMT;
325 inode->i_mode |= S_IFIFO; 288
289 if (fattr->cf_eof == 0) {
290 fattr->cf_mode |= S_IFIFO;
291 fattr->cf_dtype = DT_FIFO;
326 return 0; 292 return 0;
327 } else if (size < 8) { 293 } else if (fattr->cf_eof < 8) {
294 fattr->cf_mode |= S_IFREG;
295 fattr->cf_dtype = DT_REG;
328 return -EINVAL; /* EOPNOTSUPP? */ 296 return -EINVAL; /* EOPNOTSUPP? */
329 } 297 }
330 298
@@ -336,42 +304,46 @@ static int decode_sfu_inode(struct inode *inode, __u64 size,
336 if (rc == 0) { 304 if (rc == 0) {
337 int buf_type = CIFS_NO_BUFFER; 305 int buf_type = CIFS_NO_BUFFER;
338 /* Read header */ 306 /* Read header */
339 rc = CIFSSMBRead(xid, pTcon, 307 rc = CIFSSMBRead(xid, pTcon, netfid,
340 netfid,
341 24 /* length */, 0 /* offset */, 308 24 /* length */, 0 /* offset */,
342 &bytes_read, &pbuf, &buf_type); 309 &bytes_read, &pbuf, &buf_type);
343 if ((rc == 0) && (bytes_read >= 8)) { 310 if ((rc == 0) && (bytes_read >= 8)) {
344 if (memcmp("IntxBLK", pbuf, 8) == 0) { 311 if (memcmp("IntxBLK", pbuf, 8) == 0) {
345 cFYI(1, ("Block device")); 312 cFYI(1, ("Block device"));
346 inode->i_mode |= S_IFBLK; 313 fattr->cf_mode |= S_IFBLK;
314 fattr->cf_dtype = DT_BLK;
347 if (bytes_read == 24) { 315 if (bytes_read == 24) {
348 /* we have enough to decode dev num */ 316 /* we have enough to decode dev num */
349 __u64 mjr; /* major */ 317 __u64 mjr; /* major */
350 __u64 mnr; /* minor */ 318 __u64 mnr; /* minor */
351 mjr = le64_to_cpu(*(__le64 *)(pbuf+8)); 319 mjr = le64_to_cpu(*(__le64 *)(pbuf+8));
352 mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); 320 mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
353 inode->i_rdev = MKDEV(mjr, mnr); 321 fattr->cf_rdev = MKDEV(mjr, mnr);
354 } 322 }
355 } else if (memcmp("IntxCHR", pbuf, 8) == 0) { 323 } else if (memcmp("IntxCHR", pbuf, 8) == 0) {
356 cFYI(1, ("Char device")); 324 cFYI(1, ("Char device"));
357 inode->i_mode |= S_IFCHR; 325 fattr->cf_mode |= S_IFCHR;
326 fattr->cf_dtype = DT_CHR;
358 if (bytes_read == 24) { 327 if (bytes_read == 24) {
359 /* we have enough to decode dev num */ 328 /* we have enough to decode dev num */
360 __u64 mjr; /* major */ 329 __u64 mjr; /* major */
361 __u64 mnr; /* minor */ 330 __u64 mnr; /* minor */
362 mjr = le64_to_cpu(*(__le64 *)(pbuf+8)); 331 mjr = le64_to_cpu(*(__le64 *)(pbuf+8));
363 mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); 332 mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
364 inode->i_rdev = MKDEV(mjr, mnr); 333 fattr->cf_rdev = MKDEV(mjr, mnr);
365 } 334 }
366 } else if (memcmp("IntxLNK", pbuf, 7) == 0) { 335 } else if (memcmp("IntxLNK", pbuf, 7) == 0) {
367 cFYI(1, ("Symlink")); 336 cFYI(1, ("Symlink"));
368 inode->i_mode |= S_IFLNK; 337 fattr->cf_mode |= S_IFLNK;
338 fattr->cf_dtype = DT_LNK;
369 } else { 339 } else {
370 inode->i_mode |= S_IFREG; /* file? */ 340 fattr->cf_mode |= S_IFREG; /* file? */
341 fattr->cf_dtype = DT_REG;
371 rc = -EOPNOTSUPP; 342 rc = -EOPNOTSUPP;
372 } 343 }
373 } else { 344 } else {
374 inode->i_mode |= S_IFREG; /* then it is a file */ 345 fattr->cf_mode |= S_IFREG; /* then it is a file */
346 fattr->cf_dtype = DT_REG;
375 rc = -EOPNOTSUPP; /* or some unknown SFU type */ 347 rc = -EOPNOTSUPP; /* or some unknown SFU type */
376 } 348 }
377 CIFSSMBClose(xid, pTcon, netfid); 349 CIFSSMBClose(xid, pTcon, netfid);
@@ -381,9 +353,13 @@ static int decode_sfu_inode(struct inode *inode, __u64 size,
381 353
382#define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */ 354#define SFBITS_MASK (S_ISVTX | S_ISGID | S_ISUID) /* SETFILEBITS valid bits */
383 355
384static int get_sfu_mode(struct inode *inode, 356/*
385 const unsigned char *path, 357 * Fetch mode bits as provided by SFU.
386 struct cifs_sb_info *cifs_sb, int xid) 358 *
359 * FIXME: Doesn't this clobber the type bit we got from cifs_sfu_type ?
360 */
361static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path,
362 struct cifs_sb_info *cifs_sb, int xid)
387{ 363{
388#ifdef CONFIG_CIFS_XATTR 364#ifdef CONFIG_CIFS_XATTR
389 ssize_t rc; 365 ssize_t rc;
@@ -391,68 +367,80 @@ static int get_sfu_mode(struct inode *inode,
391 __u32 mode; 367 __u32 mode;
392 368
393 rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", 369 rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS",
394 ea_value, 4 /* size of buf */, cifs_sb->local_nls, 370 ea_value, 4 /* size of buf */, cifs_sb->local_nls,
395 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 371 cifs_sb->mnt_cifs_flags &
372 CIFS_MOUNT_MAP_SPECIAL_CHR);
396 if (rc < 0) 373 if (rc < 0)
397 return (int)rc; 374 return (int)rc;
398 else if (rc > 3) { 375 else if (rc > 3) {
399 mode = le32_to_cpu(*((__le32 *)ea_value)); 376 mode = le32_to_cpu(*((__le32 *)ea_value));
400 inode->i_mode &= ~SFBITS_MASK; 377 fattr->cf_mode &= ~SFBITS_MASK;
401 cFYI(1, ("special bits 0%o org mode 0%o", mode, inode->i_mode)); 378 cFYI(1, ("special bits 0%o org mode 0%o", mode,
402 inode->i_mode = (mode & SFBITS_MASK) | inode->i_mode; 379 fattr->cf_mode));
380 fattr->cf_mode = (mode & SFBITS_MASK) | fattr->cf_mode;
403 cFYI(1, ("special mode bits 0%o", mode)); 381 cFYI(1, ("special mode bits 0%o", mode));
404 return 0;
405 } else {
406 return 0;
407 } 382 }
383
384 return 0;
408#else 385#else
409 return -EOPNOTSUPP; 386 return -EOPNOTSUPP;
410#endif 387#endif
411} 388}
412 389
413/* 390/* Fill a cifs_fattr struct with info from FILE_ALL_INFO */
414 * Needed to setup inode data for the directory which is the 391void
415 * junction to the new submount (ie to setup the fake directory 392cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
416 * which represents a DFS referral) 393 struct cifs_sb_info *cifs_sb, bool adjust_tz)
417 */
418static void fill_fake_finddata(FILE_ALL_INFO *pfnd_dat,
419 struct super_block *sb)
420{ 394{
421 memset(pfnd_dat, 0, sizeof(FILE_ALL_INFO)); 395 memset(fattr, 0, sizeof(*fattr));
422 396 fattr->cf_cifsattrs = le32_to_cpu(info->Attributes);
423/* __le64 pfnd_dat->AllocationSize = cpu_to_le64(0); 397 if (info->DeletePending)
424 __le64 pfnd_dat->EndOfFile = cpu_to_le64(0); 398 fattr->cf_flags |= CIFS_FATTR_DELETE_PENDING;
425 __u8 pfnd_dat->DeletePending = 0; 399
426 __u8 pfnd_data->Directory = 0; 400 if (info->LastAccessTime)
427 __le32 pfnd_dat->EASize = 0; 401 fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
428 __u64 pfnd_dat->IndexNumber = 0; 402 else
429 __u64 pfnd_dat->IndexNumber1 = 0; */ 403 fattr->cf_atime = CURRENT_TIME;
430 pfnd_dat->CreationTime = 404
431 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME)); 405 fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
432 pfnd_dat->LastAccessTime = 406 fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
433 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME)); 407
434 pfnd_dat->LastWriteTime = 408 if (adjust_tz) {
435 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME)); 409 fattr->cf_ctime.tv_sec += cifs_sb->tcon->ses->server->timeAdj;
436 pfnd_dat->ChangeTime = 410 fattr->cf_mtime.tv_sec += cifs_sb->tcon->ses->server->timeAdj;
437 cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME)); 411 }
438 pfnd_dat->Attributes = cpu_to_le32(ATTR_DIRECTORY); 412
439 pfnd_dat->NumberOfLinks = cpu_to_le32(2); 413 fattr->cf_eof = le64_to_cpu(info->EndOfFile);
414 fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
415
416 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
417 fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode;
418 fattr->cf_dtype = DT_DIR;
419 } else {
420 fattr->cf_mode = S_IFREG | cifs_sb->mnt_file_mode;
421 fattr->cf_dtype = DT_REG;
422
423 /* clear write bits if ATTR_READONLY is set */
424 if (fattr->cf_cifsattrs & ATTR_READONLY)
425 fattr->cf_mode &= ~(S_IWUGO);
426 }
427
428 fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks);
429
430 fattr->cf_uid = cifs_sb->mnt_uid;
431 fattr->cf_gid = cifs_sb->mnt_gid;
440} 432}
441 433
442int cifs_get_inode_info(struct inode **pinode, 434int cifs_get_inode_info(struct inode **pinode,
443 const unsigned char *full_path, FILE_ALL_INFO *pfindData, 435 const unsigned char *full_path, FILE_ALL_INFO *pfindData,
444 struct super_block *sb, int xid, const __u16 *pfid) 436 struct super_block *sb, int xid, const __u16 *pfid)
445{ 437{
446 int rc = 0; 438 int rc = 0, tmprc;
447 __u32 attr;
448 struct cifsInodeInfo *cifsInfo;
449 struct cifsTconInfo *pTcon; 439 struct cifsTconInfo *pTcon;
450 struct inode *inode;
451 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 440 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
452 char *buf = NULL; 441 char *buf = NULL;
453 bool adjustTZ = false; 442 bool adjustTZ = false;
454 bool is_dfs_referral = false; 443 struct cifs_fattr fattr;
455 umode_t default_mode;
456 444
457 pTcon = cifs_sb->tcon; 445 pTcon = cifs_sb->tcon;
458 cFYI(1, ("Getting info on %s", full_path)); 446 cFYI(1, ("Getting info on %s", full_path));
@@ -487,163 +475,82 @@ int cifs_get_inode_info(struct inode **pinode,
487 adjustTZ = true; 475 adjustTZ = true;
488 } 476 }
489 } 477 }
490 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */ 478
491 if (rc == -EREMOTE) { 479 if (!rc) {
492 is_dfs_referral = true; 480 cifs_all_info_to_fattr(&fattr, (FILE_ALL_INFO *) pfindData,
493 fill_fake_finddata(pfindData, sb); 481 cifs_sb, adjustTZ);
482 } else if (rc == -EREMOTE) {
483 cifs_create_dfs_fattr(&fattr, sb);
494 rc = 0; 484 rc = 0;
495 } else if (rc) 485 } else {
496 goto cgii_exit; 486 goto cgii_exit;
487 }
497 488
498 attr = le32_to_cpu(pfindData->Attributes); 489 /*
499 490 * If an inode wasn't passed in, then get the inode number
500 /* get new inode */ 491 *
492 * Is an i_ino of zero legal? Can we use that to check if the server
493 * supports returning inode numbers? Are there other sanity checks we
494 * can use to ensure that the server is really filling in that field?
495 *
496 * We can not use the IndexNumber field by default from Windows or
497 * Samba (in ALL_INFO buf) but we can request it explicitly. The SNIA
498 * CIFS spec claims that this value is unique within the scope of a
499 * share, and the windows docs hint that it's actually unique
500 * per-machine.
501 *
502 * There may be higher info levels that work but are there Windows
503 * server or network appliances for which IndexNumber field is not
504 * guaranteed unique?
505 */
501 if (*pinode == NULL) { 506 if (*pinode == NULL) {
502 __u64 inode_num;
503 __u64 *pinum = &inode_num;
504
505 /* Is an i_ino of zero legal? Can we use that to check
506 if the server supports returning inode numbers? Are
507 there other sanity checks we can use to ensure that
508 the server is really filling in that field? */
509
510 /* We can not use the IndexNumber field by default from
511 Windows or Samba (in ALL_INFO buf) but we can request
512 it explicitly. It may not be unique presumably if
513 the server has multiple devices mounted under one share */
514
515 /* There may be higher info levels that work but are
516 there Windows server or network appliances for which
517 IndexNumber field is not guaranteed unique? */
518
519 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 507 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
520 int rc1 = 0; 508 int rc1 = 0;
521 509
522 rc1 = CIFSGetSrvInodeNumber(xid, pTcon, 510 rc1 = CIFSGetSrvInodeNumber(xid, pTcon,
523 full_path, pinum, 511 full_path, &fattr.cf_uniqueid,
524 cifs_sb->local_nls, 512 cifs_sb->local_nls,
525 cifs_sb->mnt_cifs_flags & 513 cifs_sb->mnt_cifs_flags &
526 CIFS_MOUNT_MAP_SPECIAL_CHR); 514 CIFS_MOUNT_MAP_SPECIAL_CHR);
527 if (rc1) { 515 if (rc1) {
528 cFYI(1, ("GetSrvInodeNum rc %d", rc1));
529 pinum = NULL;
530 /* BB EOPNOSUPP disable SERVER_INUM? */ 516 /* BB EOPNOSUPP disable SERVER_INUM? */
517 cFYI(1, ("GetSrvInodeNum rc %d", rc1));
518 fattr.cf_uniqueid = iunique(sb, ROOT_I);
531 } 519 }
532 } else { 520 } else {
533 pinum = NULL; 521 fattr.cf_uniqueid = iunique(sb, ROOT_I);
534 } 522 }
535
536 *pinode = cifs_new_inode(sb, pinum);
537 if (*pinode == NULL) {
538 rc = -ENOMEM;
539 goto cgii_exit;
540 }
541 }
542 inode = *pinode;
543 cifsInfo = CIFS_I(inode);
544 cifsInfo->cifsAttrs = attr;
545 cifsInfo->delete_pending = pfindData->DeletePending ? true : false;
546 cFYI(1, ("Old time %ld", cifsInfo->time));
547 cifsInfo->time = jiffies;
548 cFYI(1, ("New time %ld", cifsInfo->time));
549
550 /* blksize needs to be multiple of two. So safer to default to
551 blksize and blkbits set in superblock so 2**blkbits and blksize
552 will match rather than setting to:
553 (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
554
555 /* Linux can not store file creation time so ignore it */
556 if (pfindData->LastAccessTime)
557 inode->i_atime = cifs_NTtimeToUnix(pfindData->LastAccessTime);
558 else /* do not need to use current_fs_time - time not stored */
559 inode->i_atime = CURRENT_TIME;
560 inode->i_mtime = cifs_NTtimeToUnix(pfindData->LastWriteTime);
561 inode->i_ctime = cifs_NTtimeToUnix(pfindData->ChangeTime);
562 cFYI(DBG2, ("Attributes came in as 0x%x", attr));
563 if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) {
564 inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj;
565 inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj;
566 }
567
568 /* get default inode mode */
569 if (attr & ATTR_DIRECTORY)
570 default_mode = cifs_sb->mnt_dir_mode;
571 else
572 default_mode = cifs_sb->mnt_file_mode;
573
574 /* set permission bits */
575 if (atomic_read(&cifsInfo->inUse) == 0 ||
576 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0)
577 inode->i_mode = default_mode;
578 else {
579 /* just reenable write bits if !ATTR_READONLY */
580 if ((inode->i_mode & S_IWUGO) == 0 &&
581 (attr & ATTR_READONLY) == 0)
582 inode->i_mode |= (S_IWUGO & default_mode);
583
584 inode->i_mode &= ~S_IFMT;
585 }
586 /* clear write bits if ATTR_READONLY is set */
587 if (attr & ATTR_READONLY)
588 inode->i_mode &= ~S_IWUGO;
589
590 /* set inode type */
591 if ((attr & ATTR_SYSTEM) &&
592 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) {
593 /* no need to fix endianness on 0 */
594 if (pfindData->EndOfFile == 0)
595 inode->i_mode |= S_IFIFO;
596 else if (decode_sfu_inode(inode,
597 le64_to_cpu(pfindData->EndOfFile),
598 full_path, cifs_sb, xid))
599 cFYI(1, ("unknown SFU file type\n"));
600 } else { 523 } else {
601 if (attr & ATTR_DIRECTORY) 524 fattr.cf_uniqueid = CIFS_I(*pinode)->uniqueid;
602 inode->i_mode |= S_IFDIR;
603 else
604 inode->i_mode |= S_IFREG;
605 } 525 }
606 526
607 cifsInfo->server_eof = le64_to_cpu(pfindData->EndOfFile); 527 /* query for SFU type info if supported and needed */
608 spin_lock(&inode->i_lock); 528 if (fattr.cf_cifsattrs & ATTR_SYSTEM &&
609 if (is_size_safe_to_change(cifsInfo, cifsInfo->server_eof)) { 529 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
610 /* can not safely shrink the file size here if the 530 tmprc = cifs_sfu_type(&fattr, full_path, cifs_sb, xid);
611 client is writing to it due to potential races */ 531 if (tmprc)
612 i_size_write(inode, cifsInfo->server_eof); 532 cFYI(1, ("cifs_sfu_type failed: %d", tmprc));
613
614 /* 512 bytes (2**9) is the fake blocksize that must be
615 used for this calculation */
616 inode->i_blocks = (512 - 1 + le64_to_cpu(
617 pfindData->AllocationSize)) >> 9;
618 } 533 }
619 spin_unlock(&inode->i_lock);
620
621 inode->i_nlink = le32_to_cpu(pfindData->NumberOfLinks);
622 534
623 /* BB fill in uid and gid here? with help from winbind?
624 or retrieve from NTFS stream extended attribute */
625#ifdef CONFIG_CIFS_EXPERIMENTAL 535#ifdef CONFIG_CIFS_EXPERIMENTAL
626 /* fill in 0777 bits from ACL */ 536 /* fill in 0777 bits from ACL */
627 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { 537 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
628 cFYI(1, ("Getting mode bits from ACL")); 538 cFYI(1, ("Getting mode bits from ACL"));
629 acl_to_uid_mode(cifs_sb, inode, full_path, pfid); 539 cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path, pfid);
630 } 540 }
631#endif 541#endif
632 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
633 /* fill in remaining high mode bits e.g. SUID, VTX */
634 get_sfu_mode(inode, full_path, cifs_sb, xid);
635 } else if (atomic_read(&cifsInfo->inUse) == 0) {
636 inode->i_uid = cifs_sb->mnt_uid;
637 inode->i_gid = cifs_sb->mnt_gid;
638 /* set so we do not keep refreshing these fields with
639 bad data after user has changed them in memory */
640 atomic_set(&cifsInfo->inUse, 1);
641 }
642
643 cifs_set_ops(inode, is_dfs_referral);
644
645 542
543 /* fill in remaining high mode bits e.g. SUID, VTX */
544 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
545 cifs_sfu_mode(&fattr, full_path, cifs_sb, xid);
646 546
547 if (!*pinode) {
548 *pinode = cifs_iget(sb, &fattr);
549 if (!*pinode)
550 rc = -ENOMEM;
551 } else {
552 cifs_fattr_to_inode(*pinode, &fattr);
553 }
647 554
648cgii_exit: 555cgii_exit:
649 kfree(buf); 556 kfree(buf);
@@ -695,33 +602,78 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)
695 return full_path; 602 return full_path;
696} 603}
697 604
605static int
606cifs_find_inode(struct inode *inode, void *opaque)
607{
608 struct cifs_fattr *fattr = (struct cifs_fattr *) opaque;
609
610 if (CIFS_I(inode)->uniqueid != fattr->cf_uniqueid)
611 return 0;
612
613 return 1;
614}
615
616static int
617cifs_init_inode(struct inode *inode, void *opaque)
618{
619 struct cifs_fattr *fattr = (struct cifs_fattr *) opaque;
620
621 CIFS_I(inode)->uniqueid = fattr->cf_uniqueid;
622 return 0;
623}
624
625/* Given fattrs, get a corresponding inode */
626struct inode *
627cifs_iget(struct super_block *sb, struct cifs_fattr *fattr)
628{
629 unsigned long hash;
630 struct inode *inode;
631
632 cFYI(1, ("looking for uniqueid=%llu", fattr->cf_uniqueid));
633
634 /* hash down to 32-bits on 32-bit arch */
635 hash = cifs_uniqueid_to_ino_t(fattr->cf_uniqueid);
636
637 inode = iget5_locked(sb, hash, cifs_find_inode, cifs_init_inode, fattr);
638
639 /* we have fattrs in hand, update the inode */
640 if (inode) {
641 cifs_fattr_to_inode(inode, fattr);
642 if (sb->s_flags & MS_NOATIME)
643 inode->i_flags |= S_NOATIME | S_NOCMTIME;
644 if (inode->i_state & I_NEW) {
645 inode->i_ino = hash;
646 unlock_new_inode(inode);
647 }
648 }
649
650 return inode;
651}
652
698/* gets root inode */ 653/* gets root inode */
699struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino) 654struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
700{ 655{
701 int xid; 656 int xid;
702 struct cifs_sb_info *cifs_sb; 657 struct cifs_sb_info *cifs_sb;
703 struct inode *inode; 658 struct inode *inode = NULL;
704 long rc; 659 long rc;
705 char *full_path; 660 char *full_path;
706 661
707 inode = iget_locked(sb, ino); 662 cifs_sb = CIFS_SB(sb);
708 if (!inode)
709 return ERR_PTR(-ENOMEM);
710 if (!(inode->i_state & I_NEW))
711 return inode;
712
713 cifs_sb = CIFS_SB(inode->i_sb);
714 full_path = cifs_build_path_to_root(cifs_sb); 663 full_path = cifs_build_path_to_root(cifs_sb);
715 if (full_path == NULL) 664 if (full_path == NULL)
716 return ERR_PTR(-ENOMEM); 665 return ERR_PTR(-ENOMEM);
717 666
718 xid = GetXid(); 667 xid = GetXid();
719 if (cifs_sb->tcon->unix_ext) 668 if (cifs_sb->tcon->unix_ext)
720 rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb, 669 rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
721 xid);
722 else 670 else
723 rc = cifs_get_inode_info(&inode, full_path, NULL, inode->i_sb, 671 rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
724 xid, NULL); 672 xid, NULL);
673
674 if (!inode)
675 return ERR_PTR(-ENOMEM);
676
725 if (rc && cifs_sb->tcon->ipc) { 677 if (rc && cifs_sb->tcon->ipc) {
726 cFYI(1, ("ipc connection - fake read inode")); 678 cFYI(1, ("ipc connection - fake read inode"));
727 inode->i_mode |= S_IFDIR; 679 inode->i_mode |= S_IFDIR;
@@ -737,7 +689,6 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
737 return ERR_PTR(rc); 689 return ERR_PTR(rc);
738 } 690 }
739 691
740 unlock_new_inode(inode);
741 692
742 kfree(full_path); 693 kfree(full_path);
743 /* can not call macro FreeXid here since in a void func 694 /* can not call macro FreeXid here since in a void func
@@ -988,8 +939,9 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
988 * sb->s_vfs_rename_mutex here */ 939 * sb->s_vfs_rename_mutex here */
989 full_path = build_path_from_dentry(dentry); 940 full_path = build_path_from_dentry(dentry);
990 if (full_path == NULL) { 941 if (full_path == NULL) {
942 rc = -ENOMEM;
991 FreeXid(xid); 943 FreeXid(xid);
992 return -ENOMEM; 944 return rc;
993 } 945 }
994 946
995 if ((tcon->ses->capabilities & CAP_UNIX) && 947 if ((tcon->ses->capabilities & CAP_UNIX) &&
@@ -1062,44 +1014,6 @@ out_reval:
1062 return rc; 1014 return rc;
1063} 1015}
1064 1016
1065void posix_fill_in_inode(struct inode *tmp_inode,
1066 FILE_UNIX_BASIC_INFO *pData, int isNewInode)
1067{
1068 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
1069 loff_t local_size;
1070 struct timespec local_mtime;
1071
1072 cifsInfo->time = jiffies;
1073 atomic_inc(&cifsInfo->inUse);
1074
1075 /* save mtime and size */
1076 local_mtime = tmp_inode->i_mtime;
1077 local_size = tmp_inode->i_size;
1078
1079 cifs_unix_info_to_inode(tmp_inode, pData, 1);
1080 cifs_set_ops(tmp_inode, false);
1081
1082 if (!S_ISREG(tmp_inode->i_mode))
1083 return;
1084
1085 /*
1086 * No sense invalidating pages for new inode
1087 * since we we have not started caching
1088 * readahead file data yet.
1089 */
1090 if (isNewInode)
1091 return;
1092
1093 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
1094 (local_size == tmp_inode->i_size)) {
1095 cFYI(1, ("inode exists but unchanged"));
1096 } else {
1097 /* file may have changed on server */
1098 cFYI(1, ("invalidate inode, readdir detected change"));
1099 invalidate_remote_inode(tmp_inode);
1100 }
1101}
1102
1103int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) 1017int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1104{ 1018{
1105 int rc = 0, tmprc; 1019 int rc = 0, tmprc;
@@ -1108,6 +1022,7 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1108 struct cifsTconInfo *pTcon; 1022 struct cifsTconInfo *pTcon;
1109 char *full_path = NULL; 1023 char *full_path = NULL;
1110 struct inode *newinode = NULL; 1024 struct inode *newinode = NULL;
1025 struct cifs_fattr fattr;
1111 1026
1112 cFYI(1, ("In cifs_mkdir, mode = 0x%x inode = 0x%p", mode, inode)); 1027 cFYI(1, ("In cifs_mkdir, mode = 0x%x inode = 0x%p", mode, inode));
1113 1028
@@ -1118,8 +1033,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1118 1033
1119 full_path = build_path_from_dentry(direntry); 1034 full_path = build_path_from_dentry(direntry);
1120 if (full_path == NULL) { 1035 if (full_path == NULL) {
1036 rc = -ENOMEM;
1121 FreeXid(xid); 1037 FreeXid(xid);
1122 return -ENOMEM; 1038 return rc;
1123 } 1039 }
1124 1040
1125 if ((pTcon->ses->capabilities & CAP_UNIX) && 1041 if ((pTcon->ses->capabilities & CAP_UNIX) &&
@@ -1146,7 +1062,6 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1146 cFYI(1, ("posix mkdir returned 0x%x", rc)); 1062 cFYI(1, ("posix mkdir returned 0x%x", rc));
1147 d_drop(direntry); 1063 d_drop(direntry);
1148 } else { 1064 } else {
1149 __u64 unique_id;
1150 if (pInfo->Type == cpu_to_le32(-1)) { 1065 if (pInfo->Type == cpu_to_le32(-1)) {
1151 /* no return info, go query for it */ 1066 /* no return info, go query for it */
1152 kfree(pInfo); 1067 kfree(pInfo);
@@ -1160,20 +1075,15 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1160 else 1075 else
1161 direntry->d_op = &cifs_dentry_ops; 1076 direntry->d_op = &cifs_dentry_ops;
1162 1077
1163 unique_id = le64_to_cpu(pInfo->UniqueId); 1078 cifs_unix_basic_to_fattr(&fattr, pInfo, cifs_sb);
1164 newinode = cifs_new_inode(inode->i_sb, &unique_id); 1079 newinode = cifs_iget(inode->i_sb, &fattr);
1165 if (newinode == NULL) { 1080 if (!newinode) {
1166 kfree(pInfo); 1081 kfree(pInfo);
1167 goto mkdir_get_info; 1082 goto mkdir_get_info;
1168 } 1083 }
1169 1084
1170 newinode->i_nlink = 2;
1171 d_instantiate(direntry, newinode); 1085 d_instantiate(direntry, newinode);
1172 1086
1173 /* we already checked in POSIXCreate whether
1174 frame was long enough */
1175 posix_fill_in_inode(direntry->d_inode,
1176 pInfo, 1 /* NewInode */);
1177#ifdef CONFIG_CIFS_DEBUG2 1087#ifdef CONFIG_CIFS_DEBUG2
1178 cFYI(1, ("instantiated dentry %p %s to inode %p", 1088 cFYI(1, ("instantiated dentry %p %s to inode %p",
1179 direntry, direntry->d_name.name, newinode)); 1089 direntry, direntry->d_name.name, newinode));
@@ -1236,10 +1146,10 @@ mkdir_get_info:
1236 args.uid = NO_CHANGE_64; 1146 args.uid = NO_CHANGE_64;
1237 args.gid = NO_CHANGE_64; 1147 args.gid = NO_CHANGE_64;
1238 } 1148 }
1239 CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args, 1149 CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, &args,
1240 cifs_sb->local_nls, 1150 cifs_sb->local_nls,
1241 cifs_sb->mnt_cifs_flags & 1151 cifs_sb->mnt_cifs_flags &
1242 CIFS_MOUNT_MAP_SPECIAL_CHR); 1152 CIFS_MOUNT_MAP_SPECIAL_CHR);
1243 } else { 1153 } else {
1244 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) && 1154 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
1245 (mode & S_IWUGO) == 0) { 1155 (mode & S_IWUGO) == 0) {
@@ -1303,8 +1213,9 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
1303 1213
1304 full_path = build_path_from_dentry(direntry); 1214 full_path = build_path_from_dentry(direntry);
1305 if (full_path == NULL) { 1215 if (full_path == NULL) {
1216 rc = -ENOMEM;
1306 FreeXid(xid); 1217 FreeXid(xid);
1307 return -ENOMEM; 1218 return rc;
1308 } 1219 }
1309 1220
1310 rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls, 1221 rc = CIFSSMBRmDir(xid, pTcon, full_path, cifs_sb->local_nls,
@@ -1508,8 +1419,9 @@ int cifs_revalidate(struct dentry *direntry)
1508 since that would deadlock */ 1419 since that would deadlock */
1509 full_path = build_path_from_dentry(direntry); 1420 full_path = build_path_from_dentry(direntry);
1510 if (full_path == NULL) { 1421 if (full_path == NULL) {
1422 rc = -ENOMEM;
1511 FreeXid(xid); 1423 FreeXid(xid);
1512 return -ENOMEM; 1424 return rc;
1513 } 1425 }
1514 cFYI(1, ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld " 1426 cFYI(1, ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld "
1515 "jiffies %ld", full_path, direntry->d_inode, 1427 "jiffies %ld", full_path, direntry->d_inode,
@@ -1618,6 +1530,7 @@ int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1618 if (!err) { 1530 if (!err) {
1619 generic_fillattr(dentry->d_inode, stat); 1531 generic_fillattr(dentry->d_inode, stat);
1620 stat->blksize = CIFS_MAX_MSGSIZE; 1532 stat->blksize = CIFS_MAX_MSGSIZE;
1533 stat->ino = CIFS_I(dentry->d_inode)->uniqueid;
1621 } 1534 }
1622 return err; 1535 return err;
1623} 1536}
@@ -1782,6 +1695,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
1782 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1695 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1783 struct cifsTconInfo *pTcon = cifs_sb->tcon; 1696 struct cifsTconInfo *pTcon = cifs_sb->tcon;
1784 struct cifs_unix_set_info_args *args = NULL; 1697 struct cifs_unix_set_info_args *args = NULL;
1698 struct cifsFileInfo *open_file;
1785 1699
1786 cFYI(1, ("setattr_unix on file %s attrs->ia_valid=0x%x", 1700 cFYI(1, ("setattr_unix on file %s attrs->ia_valid=0x%x",
1787 direntry->d_name.name, attrs->ia_valid)); 1701 direntry->d_name.name, attrs->ia_valid));
@@ -1868,10 +1782,18 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
1868 args->ctime = NO_CHANGE_64; 1782 args->ctime = NO_CHANGE_64;
1869 1783
1870 args->device = 0; 1784 args->device = 0;
1871 rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path, args, 1785 open_file = find_writable_file(cifsInode);
1872 cifs_sb->local_nls, 1786 if (open_file) {
1873 cifs_sb->mnt_cifs_flags & 1787 u16 nfid = open_file->netfid;
1874 CIFS_MOUNT_MAP_SPECIAL_CHR); 1788 u32 npid = open_file->pid;
1789 rc = CIFSSMBUnixSetFileInfo(xid, pTcon, args, nfid, npid);
1790 atomic_dec(&open_file->wrtPending);
1791 } else {
1792 rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, args,
1793 cifs_sb->local_nls,
1794 cifs_sb->mnt_cifs_flags &
1795 CIFS_MOUNT_MAP_SPECIAL_CHR);
1796 }
1875 1797
1876 if (!rc) 1798 if (!rc)
1877 rc = inode_setattr(inode, attrs); 1799 rc = inode_setattr(inode, attrs);
@@ -1911,8 +1833,9 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
1911 1833
1912 full_path = build_path_from_dentry(direntry); 1834 full_path = build_path_from_dentry(direntry);
1913 if (full_path == NULL) { 1835 if (full_path == NULL) {
1836 rc = -ENOMEM;
1914 FreeXid(xid); 1837 FreeXid(xid);
1915 return -ENOMEM; 1838 return rc;
1916 } 1839 }
1917 1840
1918 /* 1841 /*
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index cd83c53fcbb5..fc1e0487eaee 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -172,8 +172,9 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
172 full_path = build_path_from_dentry(direntry); 172 full_path = build_path_from_dentry(direntry);
173 173
174 if (full_path == NULL) { 174 if (full_path == NULL) {
175 rc = -ENOMEM;
175 FreeXid(xid); 176 FreeXid(xid);
176 return -ENOMEM; 177 return rc;
177 } 178 }
178 179
179 cFYI(1, ("Full path: %s", full_path)); 180 cFYI(1, ("Full path: %s", full_path));
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index 32d6baa0a54f..bd6d6895730d 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -133,10 +133,12 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
133 {0, 0} 133 {0, 0}
134}; 134};
135 135
136/* Convert string containing dotted ip address to binary form */ 136/*
137/* returns 0 if invalid address */ 137 * Convert a string containing text IPv4 or IPv6 address to binary form.
138 138 *
139int 139 * Returns 0 on failure.
140 */
141static int
140cifs_inet_pton(const int address_family, const char *cp, void *dst) 142cifs_inet_pton(const int address_family, const char *cp, void *dst)
141{ 143{
142 int ret = 0; 144 int ret = 0;
@@ -153,6 +155,52 @@ cifs_inet_pton(const int address_family, const char *cp, void *dst)
153 return ret; 155 return ret;
154} 156}
155 157
158/*
159 * Try to convert a string to an IPv4 address and then attempt to convert
160 * it to an IPv6 address if that fails. Set the family field if either
161 * succeeds. If it's an IPv6 address and it has a '%' sign in it, try to
162 * treat the part following it as a numeric sin6_scope_id.
163 *
164 * Returns 0 on failure.
165 */
166int
167cifs_convert_address(char *src, void *dst)
168{
169 int rc;
170 char *pct, *endp;
171 struct sockaddr_in *s4 = (struct sockaddr_in *) dst;
172 struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) dst;
173
174 /* IPv4 address */
175 if (cifs_inet_pton(AF_INET, src, &s4->sin_addr.s_addr)) {
176 s4->sin_family = AF_INET;
177 return 1;
178 }
179
180 /* temporarily terminate string */
181 pct = strchr(src, '%');
182 if (pct)
183 *pct = '\0';
184
185 rc = cifs_inet_pton(AF_INET6, src, &s6->sin6_addr.s6_addr);
186
187 /* repair temp termination (if any) and make pct point to scopeid */
188 if (pct)
189 *pct++ = '%';
190
191 if (!rc)
192 return rc;
193
194 s6->sin6_family = AF_INET6;
195 if (pct) {
196 s6->sin6_scope_id = (u32) simple_strtoul(pct, &endp, 0);
197 if (!*pct || *endp)
198 return 0;
199 }
200
201 return rc;
202}
203
156/***************************************************************************** 204/*****************************************************************************
157convert a NT status code to a dos class/code 205convert a NT status code to a dos class/code
158 *****************************************************************************/ 206 *****************************************************************************/
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 86d0055dc529..f823a4a208a7 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -63,374 +63,123 @@ static inline void dump_cifs_file_struct(struct file *file, char *label)
63} 63}
64#endif /* DEBUG2 */ 64#endif /* DEBUG2 */
65 65
66/* Returns 1 if new inode created, 2 if both dentry and inode were */ 66/*
67/* Might check in the future if inode number changed so we can rehash inode */ 67 * Find the dentry that matches "name". If there isn't one, create one. If it's
68static int 68 * a negative dentry or the uniqueid changed, then drop it and recreate it.
69construct_dentry(struct qstr *qstring, struct file *file, 69 */
70 struct inode **ptmp_inode, struct dentry **pnew_dentry, 70static struct dentry *
71 __u64 *inum) 71cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
72 struct cifs_fattr *fattr)
72{ 73{
73 struct dentry *tmp_dentry = NULL; 74 struct dentry *dentry, *alias;
74 struct super_block *sb = file->f_path.dentry->d_sb; 75 struct inode *inode;
75 int rc = 0; 76 struct super_block *sb = parent->d_inode->i_sb;
77
78 cFYI(1, ("For %s", name->name));
79
80 dentry = d_lookup(parent, name);
81 if (dentry) {
82 /* FIXME: check for inode number changes? */
83 if (dentry->d_inode != NULL)
84 return dentry;
85 d_drop(dentry);
86 dput(dentry);
87 }
76 88
77 cFYI(1, ("For %s", qstring->name)); 89 dentry = d_alloc(parent, name);
78 90 if (dentry == NULL)
79 qstring->hash = full_name_hash(qstring->name, qstring->len); 91 return NULL;
80 tmp_dentry = d_lookup(file->f_path.dentry, qstring);
81 if (tmp_dentry) {
82 /* BB: overwrite old name? i.e. tmp_dentry->d_name and
83 * tmp_dentry->d_name.len??
84 */
85 cFYI(0, ("existing dentry with inode 0x%p",
86 tmp_dentry->d_inode));
87 *ptmp_inode = tmp_dentry->d_inode;
88 if (*ptmp_inode == NULL) {
89 *ptmp_inode = cifs_new_inode(sb, inum);
90 if (*ptmp_inode == NULL)
91 return rc;
92 rc = 1;
93 }
94 } else {
95 tmp_dentry = d_alloc(file->f_path.dentry, qstring);
96 if (tmp_dentry == NULL) {
97 cERROR(1, ("Failed allocating dentry"));
98 *ptmp_inode = NULL;
99 return rc;
100 }
101 92
102 if (CIFS_SB(sb)->tcon->nocase) 93 inode = cifs_iget(sb, fattr);
103 tmp_dentry->d_op = &cifs_ci_dentry_ops; 94 if (!inode) {
104 else 95 dput(dentry);
105 tmp_dentry->d_op = &cifs_dentry_ops; 96 return NULL;
97 }
106 98
107 *ptmp_inode = cifs_new_inode(sb, inum); 99 if (CIFS_SB(sb)->tcon->nocase)
108 if (*ptmp_inode == NULL) 100 dentry->d_op = &cifs_ci_dentry_ops;
109 return rc; 101 else
110 rc = 2; 102 dentry->d_op = &cifs_dentry_ops;
103
104 alias = d_materialise_unique(dentry, inode);
105 if (alias != NULL) {
106 dput(dentry);
107 if (IS_ERR(alias))
108 return NULL;
109 dentry = alias;
111 } 110 }
112 111
113 tmp_dentry->d_time = jiffies; 112 return dentry;
114 *pnew_dentry = tmp_dentry;
115 return rc;
116} 113}
117 114
118static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, 115static void
119 char *buf, unsigned int *pobject_type, int isNewInode) 116cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
120{ 117{
121 loff_t local_size; 118 fattr->cf_uid = cifs_sb->mnt_uid;
122 struct timespec local_mtime; 119 fattr->cf_gid = cifs_sb->mnt_gid;
123
124 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
125 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb);
126 __u32 attr;
127 __u64 allocation_size;
128 __u64 end_of_file;
129 umode_t default_mode;
130
131 /* save mtime and size */
132 local_mtime = tmp_inode->i_mtime;
133 local_size = tmp_inode->i_size;
134
135 if (new_buf_type) {
136 FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf;
137
138 attr = le32_to_cpu(pfindData->ExtFileAttributes);
139 allocation_size = le64_to_cpu(pfindData->AllocationSize);
140 end_of_file = le64_to_cpu(pfindData->EndOfFile);
141 tmp_inode->i_atime =
142 cifs_NTtimeToUnix(pfindData->LastAccessTime);
143 tmp_inode->i_mtime =
144 cifs_NTtimeToUnix(pfindData->LastWriteTime);
145 tmp_inode->i_ctime =
146 cifs_NTtimeToUnix(pfindData->ChangeTime);
147 } else { /* legacy, OS2 and DOS style */
148 int offset = cifs_sb->tcon->ses->server->timeAdj;
149 FIND_FILE_STANDARD_INFO *pfindData =
150 (FIND_FILE_STANDARD_INFO *)buf;
151
152 tmp_inode->i_mtime = cnvrtDosUnixTm(pfindData->LastWriteDate,
153 pfindData->LastWriteTime,
154 offset);
155 tmp_inode->i_atime = cnvrtDosUnixTm(pfindData->LastAccessDate,
156 pfindData->LastAccessTime,
157 offset);
158 tmp_inode->i_ctime = cnvrtDosUnixTm(pfindData->LastWriteDate,
159 pfindData->LastWriteTime,
160 offset);
161 attr = le16_to_cpu(pfindData->Attributes);
162 allocation_size = le32_to_cpu(pfindData->AllocationSize);
163 end_of_file = le32_to_cpu(pfindData->DataSize);
164 }
165 120
166 /* Linux can not store file creation time unfortunately so ignore it */ 121 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
167 122 fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode;
168 cifsInfo->cifsAttrs = attr; 123 fattr->cf_dtype = DT_DIR;
169#ifdef CONFIG_CIFS_EXPERIMENTAL 124 } else {
170 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { 125 fattr->cf_mode = S_IFREG | cifs_sb->mnt_file_mode;
171 /* get more accurate mode via ACL - so force inode refresh */ 126 fattr->cf_dtype = DT_REG;
172 cifsInfo->time = 0;
173 } else
174#endif /* CONFIG_CIFS_EXPERIMENTAL */
175 cifsInfo->time = jiffies;
176
177 /* treat dos attribute of read-only as read-only mode bit e.g. 555? */
178 /* 2767 perms - indicate mandatory locking */
179 /* BB fill in uid and gid here? with help from winbind?
180 or retrieve from NTFS stream extended attribute */
181 if (atomic_read(&cifsInfo->inUse) == 0) {
182 tmp_inode->i_uid = cifs_sb->mnt_uid;
183 tmp_inode->i_gid = cifs_sb->mnt_gid;
184 }
185
186 if (attr & ATTR_DIRECTORY)
187 default_mode = cifs_sb->mnt_dir_mode;
188 else
189 default_mode = cifs_sb->mnt_file_mode;
190
191 /* set initial permissions */
192 if ((atomic_read(&cifsInfo->inUse) == 0) ||
193 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0)
194 tmp_inode->i_mode = default_mode;
195 else {
196 /* just reenable write bits if !ATTR_READONLY */
197 if ((tmp_inode->i_mode & S_IWUGO) == 0 &&
198 (attr & ATTR_READONLY) == 0)
199 tmp_inode->i_mode |= (S_IWUGO & default_mode);
200
201 tmp_inode->i_mode &= ~S_IFMT;
202 } 127 }
203 128
204 /* clear write bits if ATTR_READONLY is set */ 129 if (fattr->cf_cifsattrs & ATTR_READONLY)
205 if (attr & ATTR_READONLY) 130 fattr->cf_mode &= ~S_IWUGO;
206 tmp_inode->i_mode &= ~S_IWUGO;
207 131
208 /* set inode type */ 132 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL &&
209 if ((attr & ATTR_SYSTEM) && 133 fattr->cf_cifsattrs & ATTR_SYSTEM) {
210 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) { 134 if (fattr->cf_eof == 0) {
211 if (end_of_file == 0) { 135 fattr->cf_mode &= ~S_IFMT;
212 tmp_inode->i_mode |= S_IFIFO; 136 fattr->cf_mode |= S_IFIFO;
213 *pobject_type = DT_FIFO; 137 fattr->cf_dtype = DT_FIFO;
214 } else { 138 } else {
215 /* 139 /*
216 * trying to get the type can be slow, so just call 140 * trying to get the type and mode via SFU can be slow,
217 * this a regular file for now, and mark for reval 141 * so just call those regular files for now, and mark
142 * for reval
218 */ 143 */
219 tmp_inode->i_mode |= S_IFREG; 144 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL;
220 *pobject_type = DT_REG;
221 cifsInfo->time = 0;
222 }
223 } else {
224 if (attr & ATTR_DIRECTORY) {
225 tmp_inode->i_mode |= S_IFDIR;
226 *pobject_type = DT_DIR;
227 } else {
228 tmp_inode->i_mode |= S_IFREG;
229 *pobject_type = DT_REG;
230 } 145 }
231 } 146 }
147}
232 148
233 /* can not fill in nlink here as in qpathinfo version and Unx search */ 149void
234 if (atomic_read(&cifsInfo->inUse) == 0) 150cifs_dir_info_to_fattr(struct cifs_fattr *fattr, FILE_DIRECTORY_INFO *info,
235 atomic_set(&cifsInfo->inUse, 1); 151 struct cifs_sb_info *cifs_sb)
236 152{
237 cifsInfo->server_eof = end_of_file; 153 memset(fattr, 0, sizeof(*fattr));
238 spin_lock(&tmp_inode->i_lock); 154 fattr->cf_cifsattrs = le32_to_cpu(info->ExtFileAttributes);
239 if (is_size_safe_to_change(cifsInfo, end_of_file)) { 155 fattr->cf_eof = le64_to_cpu(info->EndOfFile);
240 /* can not safely change the file size here if the 156 fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
241 client is writing to it due to potential races */ 157 fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
242 i_size_write(tmp_inode, end_of_file); 158 fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
243 159 fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
244 /* 512 bytes (2**9) is the fake blocksize that must be used */ 160
245 /* for this calculation, even though the reported blocksize is larger */ 161 cifs_fill_common_info(fattr, cifs_sb);
246 tmp_inode->i_blocks = (512 - 1 + allocation_size) >> 9;
247 }
248 spin_unlock(&tmp_inode->i_lock);
249
250 if (allocation_size < end_of_file)
251 cFYI(1, ("May be sparse file, allocation less than file size"));
252 cFYI(1, ("File Size %ld and blocks %llu",
253 (unsigned long)tmp_inode->i_size,
254 (unsigned long long)tmp_inode->i_blocks));
255 if (S_ISREG(tmp_inode->i_mode)) {
256 cFYI(1, ("File inode"));
257 tmp_inode->i_op = &cifs_file_inode_ops;
258 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
259 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
260 tmp_inode->i_fop = &cifs_file_direct_nobrl_ops;
261 else
262 tmp_inode->i_fop = &cifs_file_direct_ops;
263 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
264 tmp_inode->i_fop = &cifs_file_nobrl_ops;
265 else
266 tmp_inode->i_fop = &cifs_file_ops;
267
268 if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
269 (cifs_sb->tcon->ses->server->maxBuf <
270 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
271 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
272 else
273 tmp_inode->i_data.a_ops = &cifs_addr_ops;
274
275 if (isNewInode)
276 return; /* No sense invalidating pages for new inode
277 since have not started caching readahead file
278 data yet */
279
280 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
281 (local_size == tmp_inode->i_size)) {
282 cFYI(1, ("inode exists but unchanged"));
283 } else {
284 /* file may have changed on server */
285 cFYI(1, ("invalidate inode, readdir detected change"));
286 invalidate_remote_inode(tmp_inode);
287 }
288 } else if (S_ISDIR(tmp_inode->i_mode)) {
289 cFYI(1, ("Directory inode"));
290 tmp_inode->i_op = &cifs_dir_inode_ops;
291 tmp_inode->i_fop = &cifs_dir_ops;
292 } else if (S_ISLNK(tmp_inode->i_mode)) {
293 cFYI(1, ("Symbolic Link inode"));
294 tmp_inode->i_op = &cifs_symlink_inode_ops;
295 } else {
296 cFYI(1, ("Init special inode"));
297 init_special_inode(tmp_inode, tmp_inode->i_mode,
298 tmp_inode->i_rdev);
299 }
300} 162}
301 163
302static void unix_fill_in_inode(struct inode *tmp_inode, 164void
303 FILE_UNIX_INFO *pfindData, unsigned int *pobject_type, int isNewInode) 165cifs_std_info_to_fattr(struct cifs_fattr *fattr, FIND_FILE_STANDARD_INFO *info,
166 struct cifs_sb_info *cifs_sb)
304{ 167{
305 loff_t local_size; 168 int offset = cifs_sb->tcon->ses->server->timeAdj;
306 struct timespec local_mtime;
307
308 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
309 struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb);
310
311 __u32 type = le32_to_cpu(pfindData->Type);
312 __u64 num_of_bytes = le64_to_cpu(pfindData->NumOfBytes);
313 __u64 end_of_file = le64_to_cpu(pfindData->EndOfFile);
314 cifsInfo->time = jiffies;
315 atomic_inc(&cifsInfo->inUse);
316
317 /* save mtime and size */
318 local_mtime = tmp_inode->i_mtime;
319 local_size = tmp_inode->i_size;
320
321 tmp_inode->i_atime =
322 cifs_NTtimeToUnix(pfindData->LastAccessTime);
323 tmp_inode->i_mtime =
324 cifs_NTtimeToUnix(pfindData->LastModificationTime);
325 tmp_inode->i_ctime =
326 cifs_NTtimeToUnix(pfindData->LastStatusChange);
327
328 tmp_inode->i_mode = le64_to_cpu(pfindData->Permissions);
329 /* since we set the inode type below we need to mask off type
330 to avoid strange results if bits above were corrupt */
331 tmp_inode->i_mode &= ~S_IFMT;
332 if (type == UNIX_FILE) {
333 *pobject_type = DT_REG;
334 tmp_inode->i_mode |= S_IFREG;
335 } else if (type == UNIX_SYMLINK) {
336 *pobject_type = DT_LNK;
337 tmp_inode->i_mode |= S_IFLNK;
338 } else if (type == UNIX_DIR) {
339 *pobject_type = DT_DIR;
340 tmp_inode->i_mode |= S_IFDIR;
341 } else if (type == UNIX_CHARDEV) {
342 *pobject_type = DT_CHR;
343 tmp_inode->i_mode |= S_IFCHR;
344 tmp_inode->i_rdev = MKDEV(le64_to_cpu(pfindData->DevMajor),
345 le64_to_cpu(pfindData->DevMinor) & MINORMASK);
346 } else if (type == UNIX_BLOCKDEV) {
347 *pobject_type = DT_BLK;
348 tmp_inode->i_mode |= S_IFBLK;
349 tmp_inode->i_rdev = MKDEV(le64_to_cpu(pfindData->DevMajor),
350 le64_to_cpu(pfindData->DevMinor) & MINORMASK);
351 } else if (type == UNIX_FIFO) {
352 *pobject_type = DT_FIFO;
353 tmp_inode->i_mode |= S_IFIFO;
354 } else if (type == UNIX_SOCKET) {
355 *pobject_type = DT_SOCK;
356 tmp_inode->i_mode |= S_IFSOCK;
357 } else {
358 /* safest to just call it a file */
359 *pobject_type = DT_REG;
360 tmp_inode->i_mode |= S_IFREG;
361 cFYI(1, ("unknown inode type %d", type));
362 }
363 169
364 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) 170 memset(fattr, 0, sizeof(*fattr));
365 tmp_inode->i_uid = cifs_sb->mnt_uid; 171 fattr->cf_atime = cnvrtDosUnixTm(info->LastAccessDate,
366 else 172 info->LastAccessTime, offset);
367 tmp_inode->i_uid = le64_to_cpu(pfindData->Uid); 173 fattr->cf_ctime = cnvrtDosUnixTm(info->LastWriteDate,
368 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) 174 info->LastWriteTime, offset);
369 tmp_inode->i_gid = cifs_sb->mnt_gid; 175 fattr->cf_mtime = cnvrtDosUnixTm(info->LastWriteDate,
370 else 176 info->LastWriteTime, offset);
371 tmp_inode->i_gid = le64_to_cpu(pfindData->Gid);
372 tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks);
373
374 cifsInfo->server_eof = end_of_file;
375 spin_lock(&tmp_inode->i_lock);
376 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
377 /* can not safely change the file size here if the
378 client is writing to it due to potential races */
379 i_size_write(tmp_inode, end_of_file);
380
381 /* 512 bytes (2**9) is the fake blocksize that must be used */
382 /* for this calculation, not the real blocksize */
383 tmp_inode->i_blocks = (512 - 1 + num_of_bytes) >> 9;
384 }
385 spin_unlock(&tmp_inode->i_lock);
386 177
387 if (S_ISREG(tmp_inode->i_mode)) { 178 fattr->cf_cifsattrs = le16_to_cpu(info->Attributes);
388 cFYI(1, ("File inode")); 179 fattr->cf_bytes = le32_to_cpu(info->AllocationSize);
389 tmp_inode->i_op = &cifs_file_inode_ops; 180 fattr->cf_eof = le32_to_cpu(info->DataSize);
390 181
391 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { 182 cifs_fill_common_info(fattr, cifs_sb);
392 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
393 tmp_inode->i_fop = &cifs_file_direct_nobrl_ops;
394 else
395 tmp_inode->i_fop = &cifs_file_direct_ops;
396 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
397 tmp_inode->i_fop = &cifs_file_nobrl_ops;
398 else
399 tmp_inode->i_fop = &cifs_file_ops;
400
401 if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
402 (cifs_sb->tcon->ses->server->maxBuf <
403 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
404 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
405 else
406 tmp_inode->i_data.a_ops = &cifs_addr_ops;
407
408 if (isNewInode)
409 return; /* No sense invalidating pages for new inode
410 since we have not started caching readahead
411 file data for it yet */
412
413 if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
414 (local_size == tmp_inode->i_size)) {
415 cFYI(1, ("inode exists but unchanged"));
416 } else {
417 /* file may have changed on server */
418 cFYI(1, ("invalidate inode, readdir detected change"));
419 invalidate_remote_inode(tmp_inode);
420 }
421 } else if (S_ISDIR(tmp_inode->i_mode)) {
422 cFYI(1, ("Directory inode"));
423 tmp_inode->i_op = &cifs_dir_inode_ops;
424 tmp_inode->i_fop = &cifs_dir_ops;
425 } else if (S_ISLNK(tmp_inode->i_mode)) {
426 cFYI(1, ("Symbolic Link inode"));
427 tmp_inode->i_op = &cifs_symlink_inode_ops;
428/* tmp_inode->i_fop = *//* do not need to set to anything */
429 } else {
430 cFYI(1, ("Special inode"));
431 init_special_inode(tmp_inode, tmp_inode->i_mode,
432 tmp_inode->i_rdev);
433 }
434} 183}
435 184
436/* BB eventually need to add the following helper function to 185/* BB eventually need to add the following helper function to
@@ -872,7 +621,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
872 len = strnlen(filename, PATH_MAX); 621 len = strnlen(filename, PATH_MAX);
873 } 622 }
874 623
875 *pinum = le64_to_cpu(pFindData->UniqueId); 624 *pinum = le64_to_cpu(pFindData->basic.UniqueId);
876 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) { 625 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
877 FILE_DIRECTORY_INFO *pFindData = 626 FILE_DIRECTORY_INFO *pFindData =
878 (FILE_DIRECTORY_INFO *)current_entry; 627 (FILE_DIRECTORY_INFO *)current_entry;
@@ -932,11 +681,12 @@ static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
932 int rc = 0; 681 int rc = 0;
933 struct qstr qstring; 682 struct qstr qstring;
934 struct cifsFileInfo *pCifsF; 683 struct cifsFileInfo *pCifsF;
935 unsigned int obj_type; 684 u64 inum;
936 __u64 inum; 685 ino_t ino;
686 struct super_block *sb;
937 struct cifs_sb_info *cifs_sb; 687 struct cifs_sb_info *cifs_sb;
938 struct inode *tmp_inode;
939 struct dentry *tmp_dentry; 688 struct dentry *tmp_dentry;
689 struct cifs_fattr fattr;
940 690
941 /* get filename and len into qstring */ 691 /* get filename and len into qstring */
942 /* get dentry */ 692 /* get dentry */
@@ -954,60 +704,53 @@ static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
954 if (rc != 0) 704 if (rc != 0)
955 return 0; 705 return 0;
956 706
957 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 707 sb = file->f_path.dentry->d_sb;
708 cifs_sb = CIFS_SB(sb);
958 709
959 qstring.name = scratch_buf; 710 qstring.name = scratch_buf;
960 rc = cifs_get_name_from_search_buf(&qstring, pfindEntry, 711 rc = cifs_get_name_from_search_buf(&qstring, pfindEntry,
961 pCifsF->srch_inf.info_level, 712 pCifsF->srch_inf.info_level,
962 pCifsF->srch_inf.unicode, cifs_sb, 713 pCifsF->srch_inf.unicode, cifs_sb,
963 max_len, 714 max_len, &inum /* returned */);
964 &inum /* returned */);
965 715
966 if (rc) 716 if (rc)
967 return rc; 717 return rc;
968 718
969 /* only these two infolevels return valid inode numbers */
970 if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX ||
971 pCifsF->srch_inf.info_level == SMB_FIND_FILE_ID_FULL_DIR_INFO)
972 rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry,
973 &inum);
974 else
975 rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry,
976 NULL);
977
978 if ((tmp_inode == NULL) || (tmp_dentry == NULL))
979 return -ENOMEM;
980
981 /* we pass in rc below, indicating whether it is a new inode,
982 so we can figure out whether to invalidate the inode cached
983 data if the file has changed */
984 if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) 719 if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX)
985 unix_fill_in_inode(tmp_inode, 720 cifs_unix_basic_to_fattr(&fattr,
986 (FILE_UNIX_INFO *)pfindEntry, 721 &((FILE_UNIX_INFO *) pfindEntry)->basic,
987 &obj_type, rc); 722 cifs_sb);
988 else if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) 723 else if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD)
989 fill_in_inode(tmp_inode, 0 /* old level 1 buffer type */, 724 cifs_std_info_to_fattr(&fattr, (FIND_FILE_STANDARD_INFO *)
990 pfindEntry, &obj_type, rc); 725 pfindEntry, cifs_sb);
991 else 726 else
992 fill_in_inode(tmp_inode, 1 /* NT */, pfindEntry, &obj_type, rc); 727 cifs_dir_info_to_fattr(&fattr, (FILE_DIRECTORY_INFO *)
728 pfindEntry, cifs_sb);
993 729
994 if (rc) /* new inode - needs to be tied to dentry */ { 730 /* FIXME: make _to_fattr functions fill this out */
995 d_instantiate(tmp_dentry, tmp_inode); 731 if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_ID_FULL_DIR_INFO)
996 if (rc == 2) 732 fattr.cf_uniqueid = inum;
997 d_rehash(tmp_dentry); 733 else
998 } 734 fattr.cf_uniqueid = iunique(sb, ROOT_I);
999 735
736 ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
737 tmp_dentry = cifs_readdir_lookup(file->f_dentry, &qstring, &fattr);
1000 738
1001 rc = filldir(direntry, qstring.name, qstring.len, file->f_pos, 739 rc = filldir(direntry, qstring.name, qstring.len, file->f_pos,
1002 tmp_inode->i_ino, obj_type); 740 ino, fattr.cf_dtype);
741
742 /*
743 * we can not return filldir errors to the caller since they are
744 * "normal" when the stat blocksize is too small - we return remapped
745 * error instead
746 *
747 * FIXME: This looks bogus. filldir returns -EOVERFLOW in the above
748 * case already. Why should we be clobbering other errors from it?
749 */
1003 if (rc) { 750 if (rc) {
1004 cFYI(1, ("filldir rc = %d", rc)); 751 cFYI(1, ("filldir rc = %d", rc));
1005 /* we can not return filldir errors to the caller
1006 since they are "normal" when the stat blocksize
1007 is too small - we return remapped error instead */
1008 rc = -EOVERFLOW; 752 rc = -EOVERFLOW;
1009 } 753 }
1010
1011 dput(tmp_dentry); 754 dput(tmp_dentry);
1012 return rc; 755 return rc;
1013} 756}
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 897a052270f9..7085a6275c4c 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -802,7 +802,7 @@ ssetup_ntlmssp_authenticate:
802#endif /* CONFIG_CIFS_UPCALL */ 802#endif /* CONFIG_CIFS_UPCALL */
803 } else { 803 } else {
804#ifdef CONFIG_CIFS_EXPERIMENTAL 804#ifdef CONFIG_CIFS_EXPERIMENTAL
805 if ((experimEnabled > 1) && (type == RawNTLMSSP)) { 805 if (type == RawNTLMSSP) {
806 if ((pSMB->req.hdr.Flags2 & SMBFLG2_UNICODE) == 0) { 806 if ((pSMB->req.hdr.Flags2 & SMBFLG2_UNICODE) == 0) {
807 cERROR(1, ("NTLMSSP requires Unicode support")); 807 cERROR(1, ("NTLMSSP requires Unicode support"));
808 rc = -ENOSYS; 808 rc = -ENOSYS;
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index e9527eedc639..a75afa3dd9e1 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -64,8 +64,9 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name)
64 64
65 full_path = build_path_from_dentry(direntry); 65 full_path = build_path_from_dentry(direntry);
66 if (full_path == NULL) { 66 if (full_path == NULL) {
67 rc = -ENOMEM;
67 FreeXid(xid); 68 FreeXid(xid);
68 return -ENOMEM; 69 return rc;
69 } 70 }
70 if (ea_name == NULL) { 71 if (ea_name == NULL) {
71 cFYI(1, ("Null xattr names not supported")); 72 cFYI(1, ("Null xattr names not supported"));
@@ -118,8 +119,9 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
118 119
119 full_path = build_path_from_dentry(direntry); 120 full_path = build_path_from_dentry(direntry);
120 if (full_path == NULL) { 121 if (full_path == NULL) {
122 rc = -ENOMEM;
121 FreeXid(xid); 123 FreeXid(xid);
122 return -ENOMEM; 124 return rc;
123 } 125 }
124 /* return dos attributes as pseudo xattr */ 126 /* return dos attributes as pseudo xattr */
125 /* return alt name if available as pseudo attr */ 127 /* return alt name if available as pseudo attr */
@@ -225,8 +227,9 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
225 227
226 full_path = build_path_from_dentry(direntry); 228 full_path = build_path_from_dentry(direntry);
227 if (full_path == NULL) { 229 if (full_path == NULL) {
230 rc = -ENOMEM;
228 FreeXid(xid); 231 FreeXid(xid);
229 return -ENOMEM; 232 return rc;
230 } 233 }
231 /* return dos attributes as pseudo xattr */ 234 /* return dos attributes as pseudo xattr */
232 /* return alt name if available as pseudo attr */ 235 /* return alt name if available as pseudo attr */
@@ -351,8 +354,9 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
351 354
352 full_path = build_path_from_dentry(direntry); 355 full_path = build_path_from_dentry(direntry);
353 if (full_path == NULL) { 356 if (full_path == NULL) {
357 rc = -ENOMEM;
354 FreeXid(xid); 358 FreeXid(xid);
355 return -ENOMEM; 359 return rc;
356 } 360 }
357 /* return dos attributes as pseudo xattr */ 361 /* return dos attributes as pseudo xattr */
358 /* return alt name if available as pseudo attr */ 362 /* return alt name if available as pseudo attr */
diff --git a/fs/compat.c b/fs/compat.c
index cdd51a3a7c53..94502dab972a 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -32,7 +32,6 @@
32#include <linux/smb_mount.h> 32#include <linux/smb_mount.h>
33#include <linux/ncp_mount.h> 33#include <linux/ncp_mount.h>
34#include <linux/nfs4_mount.h> 34#include <linux/nfs4_mount.h>
35#include <linux/smp_lock.h>
36#include <linux/syscalls.h> 35#include <linux/syscalls.h>
37#include <linux/ctype.h> 36#include <linux/ctype.h>
38#include <linux/module.h> 37#include <linux/module.h>
@@ -1486,8 +1485,8 @@ int compat_do_execve(char * filename,
1486 if (!bprm) 1485 if (!bprm)
1487 goto out_files; 1486 goto out_files;
1488 1487
1489 retval = mutex_lock_interruptible(&current->cred_guard_mutex); 1488 retval = -ERESTARTNOINTR;
1490 if (retval < 0) 1489 if (mutex_lock_interruptible(&current->cred_guard_mutex))
1491 goto out_free; 1490 goto out_free;
1492 current->in_execve = 1; 1491 current->in_execve = 1;
1493 1492
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 626c7483b4de..f28f070a60fc 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -19,6 +19,7 @@
19#include <linux/compiler.h> 19#include <linux/compiler.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/smp.h> 21#include <linux/smp.h>
22#include <linux/smp_lock.h>
22#include <linux/ioctl.h> 23#include <linux/ioctl.h>
23#include <linux/if.h> 24#include <linux/if.h>
24#include <linux/if_bridge.h> 25#include <linux/if_bridge.h>
diff --git a/fs/eventfd.c b/fs/eventfd.c
index 3f0e1974abdc..31d12de83a2a 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -14,35 +14,44 @@
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/spinlock.h> 15#include <linux/spinlock.h>
16#include <linux/anon_inodes.h> 16#include <linux/anon_inodes.h>
17#include <linux/eventfd.h>
18#include <linux/syscalls.h> 17#include <linux/syscalls.h>
19#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/kref.h>
20#include <linux/eventfd.h>
20 21
21struct eventfd_ctx { 22struct eventfd_ctx {
23 struct kref kref;
22 wait_queue_head_t wqh; 24 wait_queue_head_t wqh;
23 /* 25 /*
24 * Every time that a write(2) is performed on an eventfd, the 26 * Every time that a write(2) is performed on an eventfd, the
25 * value of the __u64 being written is added to "count" and a 27 * value of the __u64 being written is added to "count" and a
26 * wakeup is performed on "wqh". A read(2) will return the "count" 28 * wakeup is performed on "wqh". A read(2) will return the "count"
27 * value to userspace, and will reset "count" to zero. The kernel 29 * value to userspace, and will reset "count" to zero. The kernel
28 * size eventfd_signal() also, adds to the "count" counter and 30 * side eventfd_signal() also, adds to the "count" counter and
29 * issue a wakeup. 31 * issue a wakeup.
30 */ 32 */
31 __u64 count; 33 __u64 count;
32 unsigned int flags; 34 unsigned int flags;
33}; 35};
34 36
35/* 37/**
36 * Adds "n" to the eventfd counter "count". Returns "n" in case of 38 * eventfd_signal - Adds @n to the eventfd counter.
37 * success, or a value lower then "n" in case of coutner overflow. 39 * @ctx: [in] Pointer to the eventfd context.
38 * This function is supposed to be called by the kernel in paths 40 * @n: [in] Value of the counter to be added to the eventfd internal counter.
39 * that do not allow sleeping. In this function we allow the counter 41 * The value cannot be negative.
40 * to reach the ULLONG_MAX value, and we signal this as overflow 42 *
41 * condition by returining a POLLERR to poll(2). 43 * This function is supposed to be called by the kernel in paths that do not
44 * allow sleeping. In this function we allow the counter to reach the ULLONG_MAX
45 * value, and we signal this as overflow condition by returining a POLLERR
46 * to poll(2).
47 *
48 * Returns @n in case of success, a non-negative number lower than @n in case
49 * of overflow, or the following error codes:
50 *
51 * -EINVAL : The value of @n is negative.
42 */ 52 */
43int eventfd_signal(struct file *file, int n) 53int eventfd_signal(struct eventfd_ctx *ctx, int n)
44{ 54{
45 struct eventfd_ctx *ctx = file->private_data;
46 unsigned long flags; 55 unsigned long flags;
47 56
48 if (n < 0) 57 if (n < 0)
@@ -59,9 +68,45 @@ int eventfd_signal(struct file *file, int n)
59} 68}
60EXPORT_SYMBOL_GPL(eventfd_signal); 69EXPORT_SYMBOL_GPL(eventfd_signal);
61 70
71static void eventfd_free(struct kref *kref)
72{
73 struct eventfd_ctx *ctx = container_of(kref, struct eventfd_ctx, kref);
74
75 kfree(ctx);
76}
77
78/**
79 * eventfd_ctx_get - Acquires a reference to the internal eventfd context.
80 * @ctx: [in] Pointer to the eventfd context.
81 *
82 * Returns: In case of success, returns a pointer to the eventfd context.
83 */
84struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx)
85{
86 kref_get(&ctx->kref);
87 return ctx;
88}
89EXPORT_SYMBOL_GPL(eventfd_ctx_get);
90
91/**
92 * eventfd_ctx_put - Releases a reference to the internal eventfd context.
93 * @ctx: [in] Pointer to eventfd context.
94 *
95 * The eventfd context reference must have been previously acquired either
96 * with eventfd_ctx_get() or eventfd_ctx_fdget()).
97 */
98void eventfd_ctx_put(struct eventfd_ctx *ctx)
99{
100 kref_put(&ctx->kref, eventfd_free);
101}
102EXPORT_SYMBOL_GPL(eventfd_ctx_put);
103
62static int eventfd_release(struct inode *inode, struct file *file) 104static int eventfd_release(struct inode *inode, struct file *file)
63{ 105{
64 kfree(file->private_data); 106 struct eventfd_ctx *ctx = file->private_data;
107
108 wake_up_poll(&ctx->wqh, POLLHUP);
109 eventfd_ctx_put(ctx);
65 return 0; 110 return 0;
66} 111}
67 112
@@ -185,6 +230,16 @@ static const struct file_operations eventfd_fops = {
185 .write = eventfd_write, 230 .write = eventfd_write,
186}; 231};
187 232
233/**
234 * eventfd_fget - Acquire a reference of an eventfd file descriptor.
235 * @fd: [in] Eventfd file descriptor.
236 *
237 * Returns a pointer to the eventfd file structure in case of success, or the
238 * following error pointer:
239 *
240 * -EBADF : Invalid @fd file descriptor.
241 * -EINVAL : The @fd file descriptor is not an eventfd file.
242 */
188struct file *eventfd_fget(int fd) 243struct file *eventfd_fget(int fd)
189{ 244{
190 struct file *file; 245 struct file *file;
@@ -201,6 +256,48 @@ struct file *eventfd_fget(int fd)
201} 256}
202EXPORT_SYMBOL_GPL(eventfd_fget); 257EXPORT_SYMBOL_GPL(eventfd_fget);
203 258
259/**
260 * eventfd_ctx_fdget - Acquires a reference to the internal eventfd context.
261 * @fd: [in] Eventfd file descriptor.
262 *
263 * Returns a pointer to the internal eventfd context, otherwise the error
264 * pointers returned by the following functions:
265 *
266 * eventfd_fget
267 */
268struct eventfd_ctx *eventfd_ctx_fdget(int fd)
269{
270 struct file *file;
271 struct eventfd_ctx *ctx;
272
273 file = eventfd_fget(fd);
274 if (IS_ERR(file))
275 return (struct eventfd_ctx *) file;
276 ctx = eventfd_ctx_get(file->private_data);
277 fput(file);
278
279 return ctx;
280}
281EXPORT_SYMBOL_GPL(eventfd_ctx_fdget);
282
283/**
284 * eventfd_ctx_fileget - Acquires a reference to the internal eventfd context.
285 * @file: [in] Eventfd file pointer.
286 *
287 * Returns a pointer to the internal eventfd context, otherwise the error
288 * pointer:
289 *
290 * -EINVAL : The @fd file descriptor is not an eventfd file.
291 */
292struct eventfd_ctx *eventfd_ctx_fileget(struct file *file)
293{
294 if (file->f_op != &eventfd_fops)
295 return ERR_PTR(-EINVAL);
296
297 return eventfd_ctx_get(file->private_data);
298}
299EXPORT_SYMBOL_GPL(eventfd_ctx_fileget);
300
204SYSCALL_DEFINE2(eventfd2, unsigned int, count, int, flags) 301SYSCALL_DEFINE2(eventfd2, unsigned int, count, int, flags)
205{ 302{
206 int fd; 303 int fd;
@@ -217,6 +314,7 @@ SYSCALL_DEFINE2(eventfd2, unsigned int, count, int, flags)
217 if (!ctx) 314 if (!ctx)
218 return -ENOMEM; 315 return -ENOMEM;
219 316
317 kref_init(&ctx->kref);
220 init_waitqueue_head(&ctx->wqh); 318 init_waitqueue_head(&ctx->wqh);
221 ctx->count = count; 319 ctx->count = count;
222 ctx->flags = flags; 320 ctx->flags = flags;
diff --git a/fs/exec.c b/fs/exec.c
index e639957d7a57..4a8849e45b21 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1277,8 +1277,8 @@ int do_execve(char * filename,
1277 if (!bprm) 1277 if (!bprm)
1278 goto out_files; 1278 goto out_files;
1279 1279
1280 retval = mutex_lock_interruptible(&current->cred_guard_mutex); 1280 retval = -ERESTARTNOINTR;
1281 if (retval < 0) 1281 if (mutex_lock_interruptible(&current->cred_guard_mutex))
1282 goto out_free; 1282 goto out_free;
1283 current->in_execve = 1; 1283 current->in_execve = 1;
1284 1284
diff --git a/fs/exofs/common.h b/fs/exofs/common.h
index 24667eedc023..c6718e4817fe 100644
--- a/fs/exofs/common.h
+++ b/fs/exofs/common.h
@@ -2,9 +2,7 @@
2 * common.h - Common definitions for both Kernel and user-mode utilities 2 * common.h - Common definitions for both Kernel and user-mode utilities
3 * 3 *
4 * Copyright (C) 2005, 2006 4 * Copyright (C) 2005, 2006
5 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 5 * Avishay Traeger (avishay@gmail.com)
6 * Copyright (C) 2005, 2006
7 * International Business Machines
8 * Copyright (C) 2008, 2009 6 * Copyright (C) 2008, 2009
9 * Boaz Harrosh <bharrosh@panasas.com> 7 * Boaz Harrosh <bharrosh@panasas.com>
10 * 8 *
diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c
index 65b0c8c776a1..4cfab1cc75c0 100644
--- a/fs/exofs/dir.c
+++ b/fs/exofs/dir.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright (C) 2005, 2006 2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2005, 2006
5 * International Business Machines
6 * Copyright (C) 2008, 2009 4 * Copyright (C) 2008, 2009
7 * Boaz Harrosh <bharrosh@panasas.com> 5 * Boaz Harrosh <bharrosh@panasas.com>
8 * 6 *
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h
index 0fd4c7859679..5ec72e020b22 100644
--- a/fs/exofs/exofs.h
+++ b/fs/exofs/exofs.h
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright (C) 2005, 2006 2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2005, 2006
5 * International Business Machines
6 * Copyright (C) 2008, 2009 4 * Copyright (C) 2008, 2009
7 * Boaz Harrosh <bharrosh@panasas.com> 5 * Boaz Harrosh <bharrosh@panasas.com>
8 * 6 *
@@ -156,6 +154,9 @@ ino_t exofs_parent_ino(struct dentry *child);
156int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *, 154int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *,
157 struct inode *); 155 struct inode *);
158 156
157/* super.c */
158int exofs_sync_fs(struct super_block *sb, int wait);
159
159/********************* 160/*********************
160 * operation vectors * 161 * operation vectors *
161 *********************/ 162 *********************/
diff --git a/fs/exofs/file.c b/fs/exofs/file.c
index 6ed7fe484752..839b9dc1e70f 100644
--- a/fs/exofs/file.c
+++ b/fs/exofs/file.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright (C) 2005, 2006 2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2005, 2006
5 * International Business Machines
6 * Copyright (C) 2008, 2009 4 * Copyright (C) 2008, 2009
7 * Boaz Harrosh <bharrosh@panasas.com> 5 * Boaz Harrosh <bharrosh@panasas.com>
8 * 6 *
@@ -47,16 +45,23 @@ static int exofs_file_fsync(struct file *filp, struct dentry *dentry,
47{ 45{
48 int ret; 46 int ret;
49 struct address_space *mapping = filp->f_mapping; 47 struct address_space *mapping = filp->f_mapping;
48 struct inode *inode = dentry->d_inode;
49 struct super_block *sb;
50 50
51 ret = filemap_write_and_wait(mapping); 51 ret = filemap_write_and_wait(mapping);
52 if (ret) 52 if (ret)
53 return ret; 53 return ret;
54 54
55 /*Note: file_fsync below also calles sync_blockdev, which is a no-op 55 /* sync the inode attributes */
56 * for exofs, but other then that it does sync_inode and 56 ret = write_inode_now(inode, 1);
57 * sync_superblock which is what we need here. 57
58 */ 58 /* This is a good place to write the sb */
59 return file_fsync(filp, dentry, datasync); 59 /* TODO: Sechedule an sb-sync on create */
60 sb = inode->i_sb;
61 if (sb->s_dirt)
62 exofs_sync_fs(sb, 1);
63
64 return ret;
60} 65}
61 66
62static int exofs_flush(struct file *file, fl_owner_t id) 67static int exofs_flush(struct file *file, fl_owner_t id)
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 77d0a295eb1c..6c10f7476699 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright (C) 2005, 2006 2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2005, 2006
5 * International Business Machines
6 * Copyright (C) 2008, 2009 4 * Copyright (C) 2008, 2009
7 * Boaz Harrosh <bharrosh@panasas.com> 5 * Boaz Harrosh <bharrosh@panasas.com>
8 * 6 *
@@ -295,6 +293,9 @@ static int read_exec(struct page_collect *pcol, bool is_sync)
295err: 293err:
296 if (!is_sync) 294 if (!is_sync)
297 _unlock_pcol_pages(pcol, ret, READ); 295 _unlock_pcol_pages(pcol, ret, READ);
296 else /* Pages unlocked by caller in sync mode only free bio */
297 pcol_free(pcol);
298
298 kfree(pcol_copy); 299 kfree(pcol_copy);
299 if (or) 300 if (or)
300 osd_end_request(or); 301 osd_end_request(or);
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index 77fdd765e76d..b7dd0c236863 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright (C) 2005, 2006 2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2005, 2006
5 * International Business Machines
6 * Copyright (C) 2008, 2009 4 * Copyright (C) 2008, 2009
7 * Boaz Harrosh <bharrosh@panasas.com> 5 * Boaz Harrosh <bharrosh@panasas.com>
8 * 6 *
diff --git a/fs/exofs/osd.c b/fs/exofs/osd.c
index b3d2ccb87aaa..4372542df284 100644
--- a/fs/exofs/osd.c
+++ b/fs/exofs/osd.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright (C) 2005, 2006 2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2005, 2006
5 * International Business Machines
6 * Copyright (C) 2008, 2009 4 * Copyright (C) 2008, 2009
7 * Boaz Harrosh <bharrosh@panasas.com> 5 * Boaz Harrosh <bharrosh@panasas.com>
8 * 6 *
diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index 8216c5b77b53..5ab10c3bbebe 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright (C) 2005, 2006 2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2005, 2006
5 * International Business Machines
6 * Copyright (C) 2008, 2009 4 * Copyright (C) 2008, 2009
7 * Boaz Harrosh <bharrosh@panasas.com> 5 * Boaz Harrosh <bharrosh@panasas.com>
8 * 6 *
@@ -33,6 +31,7 @@
33 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 */ 32 */
35 33
34#include <linux/smp_lock.h>
36#include <linux/string.h> 35#include <linux/string.h>
37#include <linux/parser.h> 36#include <linux/parser.h>
38#include <linux/vfs.h> 37#include <linux/vfs.h>
@@ -200,7 +199,7 @@ static const struct export_operations exofs_export_ops;
200/* 199/*
201 * Write the superblock to the OSD 200 * Write the superblock to the OSD
202 */ 201 */
203static int exofs_sync_fs(struct super_block *sb, int wait) 202int exofs_sync_fs(struct super_block *sb, int wait)
204{ 203{
205 struct exofs_sb_info *sbi; 204 struct exofs_sb_info *sbi;
206 struct exofs_fscb *fscb; 205 struct exofs_fscb *fscb;
diff --git a/fs/exofs/symlink.c b/fs/exofs/symlink.c
index 36e2d7bc7f7b..4dd687c3e747 100644
--- a/fs/exofs/symlink.c
+++ b/fs/exofs/symlink.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * Copyright (C) 2005, 2006 2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com) (avishay@il.ibm.com) 3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2005, 2006
5 * International Business Machines
6 * Copyright (C) 2008, 2009 4 * Copyright (C) 2008, 2009
7 * Boaz Harrosh <bharrosh@panasas.com> 5 * Boaz Harrosh <bharrosh@panasas.com>
8 * 6 *
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 7cb4badef927..e7431309bdca 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -13,7 +13,6 @@
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/compat.h> 14#include <linux/compat.h>
15#include <linux/mount.h> 15#include <linux/mount.h>
16#include <linux/smp_lock.h>
17#include <asm/current.h> 16#include <asm/current.h>
18#include <asm/uaccess.h> 17#include <asm/uaccess.h>
19 18
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 6524ecaebb7a..e1dedb0f7873 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -66,8 +66,16 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
66 inode = NULL; 66 inode = NULL;
67 if (ino) { 67 if (ino) {
68 inode = ext2_iget(dir->i_sb, ino); 68 inode = ext2_iget(dir->i_sb, ino);
69 if (IS_ERR(inode)) 69 if (unlikely(IS_ERR(inode))) {
70 return ERR_CAST(inode); 70 if (PTR_ERR(inode) == -ESTALE) {
71 ext2_error(dir->i_sb, __func__,
72 "deleted inode referenced: %lu",
73 ino);
74 return ERR_PTR(-EIO);
75 } else {
76 return ERR_CAST(inode);
77 }
78 }
71 } 79 }
72 return d_splice_alias(inode, dentry); 80 return d_splice_alias(inode, dentry);
73} 81}
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 0ddf7e55abe1..9714db393efe 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -93,20 +93,20 @@ typedef unsigned int ext4_group_t;
93struct ext4_allocation_request { 93struct ext4_allocation_request {
94 /* target inode for block we're allocating */ 94 /* target inode for block we're allocating */
95 struct inode *inode; 95 struct inode *inode;
96 /* how many blocks we want to allocate */
97 unsigned int len;
96 /* logical block in target inode */ 98 /* logical block in target inode */
97 ext4_lblk_t logical; 99 ext4_lblk_t logical;
98 /* phys. target (a hint) */
99 ext4_fsblk_t goal;
100 /* the closest logical allocated block to the left */ 100 /* the closest logical allocated block to the left */
101 ext4_lblk_t lleft; 101 ext4_lblk_t lleft;
102 /* phys. block for ^^^ */
103 ext4_fsblk_t pleft;
104 /* the closest logical allocated block to the right */ 102 /* the closest logical allocated block to the right */
105 ext4_lblk_t lright; 103 ext4_lblk_t lright;
106 /* phys. block for ^^^ */ 104 /* phys. target (a hint) */
105 ext4_fsblk_t goal;
106 /* phys. block for the closest logical allocated block to the left */
107 ext4_fsblk_t pleft;
108 /* phys. block for the closest logical allocated block to the right */
107 ext4_fsblk_t pright; 109 ext4_fsblk_t pright;
108 /* how many blocks we want to allocate */
109 unsigned int len;
110 /* flags. see above EXT4_MB_HINT_* */ 110 /* flags. see above EXT4_MB_HINT_* */
111 unsigned int flags; 111 unsigned int flags;
112}; 112};
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index ad13a84644e1..eb27fd0f2ee8 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -43,6 +43,8 @@ int __ext4_journal_forget(const char *where, handle_t *handle,
43 ext4_journal_abort_handle(where, __func__, bh, 43 ext4_journal_abort_handle(where, __func__, bh,
44 handle, err); 44 handle, err);
45 } 45 }
46 else
47 brelse(bh);
46 return err; 48 return err;
47} 49}
48 50
@@ -57,6 +59,8 @@ int __ext4_journal_revoke(const char *where, handle_t *handle,
57 ext4_journal_abort_handle(where, __func__, bh, 59 ext4_journal_abort_handle(where, __func__, bh,
58 handle, err); 60 handle, err);
59 } 61 }
62 else
63 brelse(bh);
60 return err; 64 return err;
61} 65}
62 66
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
index be2f426f6805..139fb8cb87e4 100644
--- a/fs/ext4/ext4_jbd2.h
+++ b/fs/ext4/ext4_jbd2.h
@@ -131,9 +131,11 @@ int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
131int __ext4_journal_get_write_access(const char *where, handle_t *handle, 131int __ext4_journal_get_write_access(const char *where, handle_t *handle,
132 struct buffer_head *bh); 132 struct buffer_head *bh);
133 133
134/* When called with an invalid handle, this will still do a put on the BH */
134int __ext4_journal_forget(const char *where, handle_t *handle, 135int __ext4_journal_forget(const char *where, handle_t *handle,
135 struct buffer_head *bh); 136 struct buffer_head *bh);
136 137
138/* When called with an invalid handle, this will still do a put on the BH */
137int __ext4_journal_revoke(const char *where, handle_t *handle, 139int __ext4_journal_revoke(const char *where, handle_t *handle,
138 ext4_fsblk_t blocknr, struct buffer_head *bh); 140 ext4_fsblk_t blocknr, struct buffer_head *bh);
139 141
@@ -281,10 +283,10 @@ static inline int ext4_should_order_data(struct inode *inode)
281 283
282static inline int ext4_should_writeback_data(struct inode *inode) 284static inline int ext4_should_writeback_data(struct inode *inode)
283{ 285{
284 if (EXT4_JOURNAL(inode) == NULL)
285 return 0;
286 if (!S_ISREG(inode->i_mode)) 286 if (!S_ISREG(inode->i_mode))
287 return 0; 287 return 0;
288 if (EXT4_JOURNAL(inode) == NULL)
289 return 1;
288 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL) 290 if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
289 return 0; 291 return 0;
290 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA) 292 if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 50322a09bd01..73ebfb44ad75 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1977,6 +1977,7 @@ int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int nrblocks,
1977 */ 1977 */
1978 /* 1 bitmap, 1 block group descriptor */ 1978 /* 1 bitmap, 1 block group descriptor */
1979 ret = 2 + EXT4_META_TRANS_BLOCKS(inode->i_sb); 1979 ret = 2 + EXT4_META_TRANS_BLOCKS(inode->i_sb);
1980 return ret;
1980 } 1981 }
1981 } 1982 }
1982 1983
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 2f645732e3b7..29e6dc7299b8 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -833,7 +833,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode,
833 if (!goal) 833 if (!goal)
834 goal = sbi->s_inode_goal; 834 goal = sbi->s_inode_goal;
835 835
836 if (goal && goal < le32_to_cpu(sbi->s_es->s_inodes_count)) { 836 if (goal && goal <= le32_to_cpu(sbi->s_es->s_inodes_count)) {
837 group = (goal - 1) / EXT4_INODES_PER_GROUP(sb); 837 group = (goal - 1) / EXT4_INODES_PER_GROUP(sb);
838 ino = (goal - 1) % EXT4_INODES_PER_GROUP(sb); 838 ino = (goal - 1) % EXT4_INODES_PER_GROUP(sb);
839 ret2 = 0; 839 ret2 = 0;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 60a26f3a6f8b..f9c642b22efa 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -78,16 +78,14 @@ static int ext4_inode_is_fast_symlink(struct inode *inode)
78 * but there may still be a record of it in the journal, and that record 78 * but there may still be a record of it in the journal, and that record
79 * still needs to be revoked. 79 * still needs to be revoked.
80 * 80 *
81 * If the handle isn't valid we're not journaling so there's nothing to do. 81 * If the handle isn't valid we're not journaling, but we still need to
82 * call into ext4_journal_revoke() to put the buffer head.
82 */ 83 */
83int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, 84int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
84 struct buffer_head *bh, ext4_fsblk_t blocknr) 85 struct buffer_head *bh, ext4_fsblk_t blocknr)
85{ 86{
86 int err; 87 int err;
87 88
88 if (!ext4_handle_valid(handle))
89 return 0;
90
91 might_sleep(); 89 might_sleep();
92 90
93 BUFFER_TRACE(bh, "enter"); 91 BUFFER_TRACE(bh, "enter");
@@ -1513,14 +1511,14 @@ retry:
1513 * Add inode to orphan list in case we crash before 1511 * Add inode to orphan list in case we crash before
1514 * truncate finishes 1512 * truncate finishes
1515 */ 1513 */
1516 if (pos + len > inode->i_size) 1514 if (pos + len > inode->i_size && ext4_can_truncate(inode))
1517 ext4_orphan_add(handle, inode); 1515 ext4_orphan_add(handle, inode);
1518 1516
1519 ext4_journal_stop(handle); 1517 ext4_journal_stop(handle);
1520 if (pos + len > inode->i_size) { 1518 if (pos + len > inode->i_size) {
1521 vmtruncate(inode, inode->i_size); 1519 ext4_truncate(inode);
1522 /* 1520 /*
1523 * If vmtruncate failed early the inode might 1521 * If truncate failed early the inode might
1524 * still be on the orphan list; we need to 1522 * still be on the orphan list; we need to
1525 * make sure the inode is removed from the 1523 * make sure the inode is removed from the
1526 * orphan list in that case. 1524 * orphan list in that case.
@@ -1614,7 +1612,7 @@ static int ext4_ordered_write_end(struct file *file,
1614 ret2 = ext4_generic_write_end(file, mapping, pos, len, copied, 1612 ret2 = ext4_generic_write_end(file, mapping, pos, len, copied,
1615 page, fsdata); 1613 page, fsdata);
1616 copied = ret2; 1614 copied = ret2;
1617 if (pos + len > inode->i_size) 1615 if (pos + len > inode->i_size && ext4_can_truncate(inode))
1618 /* if we have allocated more blocks and copied 1616 /* if we have allocated more blocks and copied
1619 * less. We will have blocks allocated outside 1617 * less. We will have blocks allocated outside
1620 * inode->i_size. So truncate them 1618 * inode->i_size. So truncate them
@@ -1628,9 +1626,9 @@ static int ext4_ordered_write_end(struct file *file,
1628 ret = ret2; 1626 ret = ret2;
1629 1627
1630 if (pos + len > inode->i_size) { 1628 if (pos + len > inode->i_size) {
1631 vmtruncate(inode, inode->i_size); 1629 ext4_truncate(inode);
1632 /* 1630 /*
1633 * If vmtruncate failed early the inode might still be 1631 * If truncate failed early the inode might still be
1634 * on the orphan list; we need to make sure the inode 1632 * on the orphan list; we need to make sure the inode
1635 * is removed from the orphan list in that case. 1633 * is removed from the orphan list in that case.
1636 */ 1634 */
@@ -1655,7 +1653,7 @@ static int ext4_writeback_write_end(struct file *file,
1655 ret2 = ext4_generic_write_end(file, mapping, pos, len, copied, 1653 ret2 = ext4_generic_write_end(file, mapping, pos, len, copied,
1656 page, fsdata); 1654 page, fsdata);
1657 copied = ret2; 1655 copied = ret2;
1658 if (pos + len > inode->i_size) 1656 if (pos + len > inode->i_size && ext4_can_truncate(inode))
1659 /* if we have allocated more blocks and copied 1657 /* if we have allocated more blocks and copied
1660 * less. We will have blocks allocated outside 1658 * less. We will have blocks allocated outside
1661 * inode->i_size. So truncate them 1659 * inode->i_size. So truncate them
@@ -1670,9 +1668,9 @@ static int ext4_writeback_write_end(struct file *file,
1670 ret = ret2; 1668 ret = ret2;
1671 1669
1672 if (pos + len > inode->i_size) { 1670 if (pos + len > inode->i_size) {
1673 vmtruncate(inode, inode->i_size); 1671 ext4_truncate(inode);
1674 /* 1672 /*
1675 * If vmtruncate failed early the inode might still be 1673 * If truncate failed early the inode might still be
1676 * on the orphan list; we need to make sure the inode 1674 * on the orphan list; we need to make sure the inode
1677 * is removed from the orphan list in that case. 1675 * is removed from the orphan list in that case.
1678 */ 1676 */
@@ -1722,7 +1720,7 @@ static int ext4_journalled_write_end(struct file *file,
1722 1720
1723 unlock_page(page); 1721 unlock_page(page);
1724 page_cache_release(page); 1722 page_cache_release(page);
1725 if (pos + len > inode->i_size) 1723 if (pos + len > inode->i_size && ext4_can_truncate(inode))
1726 /* if we have allocated more blocks and copied 1724 /* if we have allocated more blocks and copied
1727 * less. We will have blocks allocated outside 1725 * less. We will have blocks allocated outside
1728 * inode->i_size. So truncate them 1726 * inode->i_size. So truncate them
@@ -1733,9 +1731,9 @@ static int ext4_journalled_write_end(struct file *file,
1733 if (!ret) 1731 if (!ret)
1734 ret = ret2; 1732 ret = ret2;
1735 if (pos + len > inode->i_size) { 1733 if (pos + len > inode->i_size) {
1736 vmtruncate(inode, inode->i_size); 1734 ext4_truncate(inode);
1737 /* 1735 /*
1738 * If vmtruncate failed early the inode might still be 1736 * If truncate failed early the inode might still be
1739 * on the orphan list; we need to make sure the inode 1737 * on the orphan list; we need to make sure the inode
1740 * is removed from the orphan list in that case. 1738 * is removed from the orphan list in that case.
1741 */ 1739 */
@@ -2305,15 +2303,9 @@ flush_it:
2305 return; 2303 return;
2306} 2304}
2307 2305
2308static int ext4_bh_unmapped_or_delay(handle_t *handle, struct buffer_head *bh) 2306static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh)
2309{ 2307{
2310 /* 2308 return (buffer_delay(bh) || buffer_unwritten(bh)) && buffer_dirty(bh);
2311 * unmapped buffer is possible for holes.
2312 * delay buffer is possible with delayed allocation.
2313 * We also need to consider unwritten buffer as unmapped.
2314 */
2315 return (!buffer_mapped(bh) || buffer_delay(bh) ||
2316 buffer_unwritten(bh)) && buffer_dirty(bh);
2317} 2309}
2318 2310
2319/* 2311/*
@@ -2398,9 +2390,9 @@ static int __mpage_da_writepage(struct page *page,
2398 * We need to try to allocate 2390 * We need to try to allocate
2399 * unmapped blocks in the same page. 2391 * unmapped blocks in the same page.
2400 * Otherwise we won't make progress 2392 * Otherwise we won't make progress
2401 * with the page in ext4_da_writepage 2393 * with the page in ext4_writepage
2402 */ 2394 */
2403 if (ext4_bh_unmapped_or_delay(NULL, bh)) { 2395 if (ext4_bh_delay_or_unwritten(NULL, bh)) {
2404 mpage_add_bh_to_extent(mpd, logical, 2396 mpage_add_bh_to_extent(mpd, logical,
2405 bh->b_size, 2397 bh->b_size,
2406 bh->b_state); 2398 bh->b_state);
@@ -2517,7 +2509,6 @@ static int noalloc_get_block_write(struct inode *inode, sector_t iblock,
2517 * so call get_block_wrap with create = 0 2509 * so call get_block_wrap with create = 0
2518 */ 2510 */
2519 ret = ext4_get_blocks(NULL, inode, iblock, max_blocks, bh_result, 0); 2511 ret = ext4_get_blocks(NULL, inode, iblock, max_blocks, bh_result, 0);
2520 BUG_ON(create && ret == 0);
2521 if (ret > 0) { 2512 if (ret > 0) {
2522 bh_result->b_size = (ret << inode->i_blkbits); 2513 bh_result->b_size = (ret << inode->i_blkbits);
2523 ret = 0; 2514 ret = 0;
@@ -2525,15 +2516,102 @@ static int noalloc_get_block_write(struct inode *inode, sector_t iblock,
2525 return ret; 2516 return ret;
2526} 2517}
2527 2518
2519static int bget_one(handle_t *handle, struct buffer_head *bh)
2520{
2521 get_bh(bh);
2522 return 0;
2523}
2524
2525static int bput_one(handle_t *handle, struct buffer_head *bh)
2526{
2527 put_bh(bh);
2528 return 0;
2529}
2530
2531static int __ext4_journalled_writepage(struct page *page,
2532 struct writeback_control *wbc,
2533 unsigned int len)
2534{
2535 struct address_space *mapping = page->mapping;
2536 struct inode *inode = mapping->host;
2537 struct buffer_head *page_bufs;
2538 handle_t *handle = NULL;
2539 int ret = 0;
2540 int err;
2541
2542 page_bufs = page_buffers(page);
2543 BUG_ON(!page_bufs);
2544 walk_page_buffers(handle, page_bufs, 0, len, NULL, bget_one);
2545 /* As soon as we unlock the page, it can go away, but we have
2546 * references to buffers so we are safe */
2547 unlock_page(page);
2548
2549 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
2550 if (IS_ERR(handle)) {
2551 ret = PTR_ERR(handle);
2552 goto out;
2553 }
2554
2555 ret = walk_page_buffers(handle, page_bufs, 0, len, NULL,
2556 do_journal_get_write_access);
2557
2558 err = walk_page_buffers(handle, page_bufs, 0, len, NULL,
2559 write_end_fn);
2560 if (ret == 0)
2561 ret = err;
2562 err = ext4_journal_stop(handle);
2563 if (!ret)
2564 ret = err;
2565
2566 walk_page_buffers(handle, page_bufs, 0, len, NULL, bput_one);
2567 EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
2568out:
2569 return ret;
2570}
2571
2528/* 2572/*
2573 * Note that we don't need to start a transaction unless we're journaling data
2574 * because we should have holes filled from ext4_page_mkwrite(). We even don't
2575 * need to file the inode to the transaction's list in ordered mode because if
2576 * we are writing back data added by write(), the inode is already there and if
2577 * we are writing back data modified via mmap(), noone guarantees in which
2578 * transaction the data will hit the disk. In case we are journaling data, we
2579 * cannot start transaction directly because transaction start ranks above page
2580 * lock so we have to do some magic.
2581 *
2529 * This function can get called via... 2582 * This function can get called via...
2530 * - ext4_da_writepages after taking page lock (have journal handle) 2583 * - ext4_da_writepages after taking page lock (have journal handle)
2531 * - journal_submit_inode_data_buffers (no journal handle) 2584 * - journal_submit_inode_data_buffers (no journal handle)
2532 * - shrink_page_list via pdflush (no journal handle) 2585 * - shrink_page_list via pdflush (no journal handle)
2533 * - grab_page_cache when doing write_begin (have journal handle) 2586 * - grab_page_cache when doing write_begin (have journal handle)
2587 *
2588 * We don't do any block allocation in this function. If we have page with
2589 * multiple blocks we need to write those buffer_heads that are mapped. This
2590 * is important for mmaped based write. So if we do with blocksize 1K
2591 * truncate(f, 1024);
2592 * a = mmap(f, 0, 4096);
2593 * a[0] = 'a';
2594 * truncate(f, 4096);
2595 * we have in the page first buffer_head mapped via page_mkwrite call back
2596 * but other bufer_heads would be unmapped but dirty(dirty done via the
2597 * do_wp_page). So writepage should write the first block. If we modify
2598 * the mmap area beyond 1024 we will again get a page_fault and the
2599 * page_mkwrite callback will do the block allocation and mark the
2600 * buffer_heads mapped.
2601 *
2602 * We redirty the page if we have any buffer_heads that is either delay or
2603 * unwritten in the page.
2604 *
2605 * We can get recursively called as show below.
2606 *
2607 * ext4_writepage() -> kmalloc() -> __alloc_pages() -> page_launder() ->
2608 * ext4_writepage()
2609 *
2610 * But since we don't do any block allocation we should not deadlock.
2611 * Page also have the dirty flag cleared so we don't get recurive page_lock.
2534 */ 2612 */
2535static int ext4_da_writepage(struct page *page, 2613static int ext4_writepage(struct page *page,
2536 struct writeback_control *wbc) 2614 struct writeback_control *wbc)
2537{ 2615{
2538 int ret = 0; 2616 int ret = 0;
2539 loff_t size; 2617 loff_t size;
@@ -2541,7 +2619,7 @@ static int ext4_da_writepage(struct page *page,
2541 struct buffer_head *page_bufs; 2619 struct buffer_head *page_bufs;
2542 struct inode *inode = page->mapping->host; 2620 struct inode *inode = page->mapping->host;
2543 2621
2544 trace_ext4_da_writepage(inode, page); 2622 trace_ext4_writepage(inode, page);
2545 size = i_size_read(inode); 2623 size = i_size_read(inode);
2546 if (page->index == size >> PAGE_CACHE_SHIFT) 2624 if (page->index == size >> PAGE_CACHE_SHIFT)
2547 len = size & ~PAGE_CACHE_MASK; 2625 len = size & ~PAGE_CACHE_MASK;
@@ -2551,7 +2629,7 @@ static int ext4_da_writepage(struct page *page,
2551 if (page_has_buffers(page)) { 2629 if (page_has_buffers(page)) {
2552 page_bufs = page_buffers(page); 2630 page_bufs = page_buffers(page);
2553 if (walk_page_buffers(NULL, page_bufs, 0, len, NULL, 2631 if (walk_page_buffers(NULL, page_bufs, 0, len, NULL,
2554 ext4_bh_unmapped_or_delay)) { 2632 ext4_bh_delay_or_unwritten)) {
2555 /* 2633 /*
2556 * We don't want to do block allocation 2634 * We don't want to do block allocation
2557 * So redirty the page and return 2635 * So redirty the page and return
@@ -2578,13 +2656,13 @@ static int ext4_da_writepage(struct page *page,
2578 * all are mapped and non delay. We don't want to 2656 * all are mapped and non delay. We don't want to
2579 * do block allocation here. 2657 * do block allocation here.
2580 */ 2658 */
2581 ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, 2659 ret = block_prepare_write(page, 0, len,
2582 noalloc_get_block_write); 2660 noalloc_get_block_write);
2583 if (!ret) { 2661 if (!ret) {
2584 page_bufs = page_buffers(page); 2662 page_bufs = page_buffers(page);
2585 /* check whether all are mapped and non delay */ 2663 /* check whether all are mapped and non delay */
2586 if (walk_page_buffers(NULL, page_bufs, 0, len, NULL, 2664 if (walk_page_buffers(NULL, page_bufs, 0, len, NULL,
2587 ext4_bh_unmapped_or_delay)) { 2665 ext4_bh_delay_or_unwritten)) {
2588 redirty_page_for_writepage(wbc, page); 2666 redirty_page_for_writepage(wbc, page);
2589 unlock_page(page); 2667 unlock_page(page);
2590 return 0; 2668 return 0;
@@ -2600,7 +2678,16 @@ static int ext4_da_writepage(struct page *page,
2600 return 0; 2678 return 0;
2601 } 2679 }
2602 /* now mark the buffer_heads as dirty and uptodate */ 2680 /* now mark the buffer_heads as dirty and uptodate */
2603 block_commit_write(page, 0, PAGE_CACHE_SIZE); 2681 block_commit_write(page, 0, len);
2682 }
2683
2684 if (PageChecked(page) && ext4_should_journal_data(inode)) {
2685 /*
2686 * It's mmapped pagecache. Add buffers and journal it. There
2687 * doesn't seem much point in redirtying the page here.
2688 */
2689 ClearPageChecked(page);
2690 return __ext4_journalled_writepage(page, wbc, len);
2604 } 2691 }
2605 2692
2606 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) 2693 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
@@ -2907,7 +2994,7 @@ retry:
2907 * i_size_read because we hold i_mutex. 2994 * i_size_read because we hold i_mutex.
2908 */ 2995 */
2909 if (pos + len > inode->i_size) 2996 if (pos + len > inode->i_size)
2910 vmtruncate(inode, inode->i_size); 2997 ext4_truncate(inode);
2911 } 2998 }
2912 2999
2913 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 3000 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
@@ -3130,222 +3217,6 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block)
3130 return generic_block_bmap(mapping, block, ext4_get_block); 3217 return generic_block_bmap(mapping, block, ext4_get_block);
3131} 3218}
3132 3219
3133static int bget_one(handle_t *handle, struct buffer_head *bh)
3134{
3135 get_bh(bh);
3136 return 0;
3137}
3138
3139static int bput_one(handle_t *handle, struct buffer_head *bh)
3140{
3141 put_bh(bh);
3142 return 0;
3143}
3144
3145/*
3146 * Note that we don't need to start a transaction unless we're journaling data
3147 * because we should have holes filled from ext4_page_mkwrite(). We even don't
3148 * need to file the inode to the transaction's list in ordered mode because if
3149 * we are writing back data added by write(), the inode is already there and if
3150 * we are writing back data modified via mmap(), noone guarantees in which
3151 * transaction the data will hit the disk. In case we are journaling data, we
3152 * cannot start transaction directly because transaction start ranks above page
3153 * lock so we have to do some magic.
3154 *
3155 * In all journaling modes block_write_full_page() will start the I/O.
3156 *
3157 * Problem:
3158 *
3159 * ext4_writepage() -> kmalloc() -> __alloc_pages() -> page_launder() ->
3160 * ext4_writepage()
3161 *
3162 * Similar for:
3163 *
3164 * ext4_file_write() -> generic_file_write() -> __alloc_pages() -> ...
3165 *
3166 * Same applies to ext4_get_block(). We will deadlock on various things like
3167 * lock_journal and i_data_sem
3168 *
3169 * Setting PF_MEMALLOC here doesn't work - too many internal memory
3170 * allocations fail.
3171 *
3172 * 16May01: If we're reentered then journal_current_handle() will be
3173 * non-zero. We simply *return*.
3174 *
3175 * 1 July 2001: @@@ FIXME:
3176 * In journalled data mode, a data buffer may be metadata against the
3177 * current transaction. But the same file is part of a shared mapping
3178 * and someone does a writepage() on it.
3179 *
3180 * We will move the buffer onto the async_data list, but *after* it has
3181 * been dirtied. So there's a small window where we have dirty data on
3182 * BJ_Metadata.
3183 *
3184 * Note that this only applies to the last partial page in the file. The
3185 * bit which block_write_full_page() uses prepare/commit for. (That's
3186 * broken code anyway: it's wrong for msync()).
3187 *
3188 * It's a rare case: affects the final partial page, for journalled data
3189 * where the file is subject to bith write() and writepage() in the same
3190 * transction. To fix it we'll need a custom block_write_full_page().
3191 * We'll probably need that anyway for journalling writepage() output.
3192 *
3193 * We don't honour synchronous mounts for writepage(). That would be
3194 * disastrous. Any write() or metadata operation will sync the fs for
3195 * us.
3196 *
3197 */
3198static int __ext4_normal_writepage(struct page *page,
3199 struct writeback_control *wbc)
3200{
3201 struct inode *inode = page->mapping->host;
3202
3203 if (test_opt(inode->i_sb, NOBH))
3204 return nobh_writepage(page, noalloc_get_block_write, wbc);
3205 else
3206 return block_write_full_page(page, noalloc_get_block_write,
3207 wbc);
3208}
3209
3210static int ext4_normal_writepage(struct page *page,
3211 struct writeback_control *wbc)
3212{
3213 struct inode *inode = page->mapping->host;
3214 loff_t size = i_size_read(inode);
3215 loff_t len;
3216
3217 trace_ext4_normal_writepage(inode, page);
3218 J_ASSERT(PageLocked(page));
3219 if (page->index == size >> PAGE_CACHE_SHIFT)
3220 len = size & ~PAGE_CACHE_MASK;
3221 else
3222 len = PAGE_CACHE_SIZE;
3223
3224 if (page_has_buffers(page)) {
3225 /* if page has buffers it should all be mapped
3226 * and allocated. If there are not buffers attached
3227 * to the page we know the page is dirty but it lost
3228 * buffers. That means that at some moment in time
3229 * after write_begin() / write_end() has been called
3230 * all buffers have been clean and thus they must have been
3231 * written at least once. So they are all mapped and we can
3232 * happily proceed with mapping them and writing the page.
3233 */
3234 BUG_ON(walk_page_buffers(NULL, page_buffers(page), 0, len, NULL,
3235 ext4_bh_unmapped_or_delay));
3236 }
3237
3238 if (!ext4_journal_current_handle())
3239 return __ext4_normal_writepage(page, wbc);
3240
3241 redirty_page_for_writepage(wbc, page);
3242 unlock_page(page);
3243 return 0;
3244}
3245
3246static int __ext4_journalled_writepage(struct page *page,
3247 struct writeback_control *wbc)
3248{
3249 struct address_space *mapping = page->mapping;
3250 struct inode *inode = mapping->host;
3251 struct buffer_head *page_bufs;
3252 handle_t *handle = NULL;
3253 int ret = 0;
3254 int err;
3255
3256 ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
3257 noalloc_get_block_write);
3258 if (ret != 0)
3259 goto out_unlock;
3260
3261 page_bufs = page_buffers(page);
3262 walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, NULL,
3263 bget_one);
3264 /* As soon as we unlock the page, it can go away, but we have
3265 * references to buffers so we are safe */
3266 unlock_page(page);
3267
3268 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
3269 if (IS_ERR(handle)) {
3270 ret = PTR_ERR(handle);
3271 goto out;
3272 }
3273
3274 ret = walk_page_buffers(handle, page_bufs, 0,
3275 PAGE_CACHE_SIZE, NULL, do_journal_get_write_access);
3276
3277 err = walk_page_buffers(handle, page_bufs, 0,
3278 PAGE_CACHE_SIZE, NULL, write_end_fn);
3279 if (ret == 0)
3280 ret = err;
3281 err = ext4_journal_stop(handle);
3282 if (!ret)
3283 ret = err;
3284
3285 walk_page_buffers(handle, page_bufs, 0,
3286 PAGE_CACHE_SIZE, NULL, bput_one);
3287 EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
3288 goto out;
3289
3290out_unlock:
3291 unlock_page(page);
3292out:
3293 return ret;
3294}
3295
3296static int ext4_journalled_writepage(struct page *page,
3297 struct writeback_control *wbc)
3298{
3299 struct inode *inode = page->mapping->host;
3300 loff_t size = i_size_read(inode);
3301 loff_t len;
3302
3303 trace_ext4_journalled_writepage(inode, page);
3304 J_ASSERT(PageLocked(page));
3305 if (page->index == size >> PAGE_CACHE_SHIFT)
3306 len = size & ~PAGE_CACHE_MASK;
3307 else
3308 len = PAGE_CACHE_SIZE;
3309
3310 if (page_has_buffers(page)) {
3311 /* if page has buffers it should all be mapped
3312 * and allocated. If there are not buffers attached
3313 * to the page we know the page is dirty but it lost
3314 * buffers. That means that at some moment in time
3315 * after write_begin() / write_end() has been called
3316 * all buffers have been clean and thus they must have been
3317 * written at least once. So they are all mapped and we can
3318 * happily proceed with mapping them and writing the page.
3319 */
3320 BUG_ON(walk_page_buffers(NULL, page_buffers(page), 0, len, NULL,
3321 ext4_bh_unmapped_or_delay));
3322 }
3323
3324 if (ext4_journal_current_handle())
3325 goto no_write;
3326
3327 if (PageChecked(page)) {
3328 /*
3329 * It's mmapped pagecache. Add buffers and journal it. There
3330 * doesn't seem much point in redirtying the page here.
3331 */
3332 ClearPageChecked(page);
3333 return __ext4_journalled_writepage(page, wbc);
3334 } else {
3335 /*
3336 * It may be a page full of checkpoint-mode buffers. We don't
3337 * really know unless we go poke around in the buffer_heads.
3338 * But block_write_full_page will do the right thing.
3339 */
3340 return block_write_full_page(page, noalloc_get_block_write,
3341 wbc);
3342 }
3343no_write:
3344 redirty_page_for_writepage(wbc, page);
3345 unlock_page(page);
3346 return 0;
3347}
3348
3349static int ext4_readpage(struct file *file, struct page *page) 3220static int ext4_readpage(struct file *file, struct page *page)
3350{ 3221{
3351 return mpage_readpage(page, ext4_get_block); 3222 return mpage_readpage(page, ext4_get_block);
@@ -3492,7 +3363,7 @@ static int ext4_journalled_set_page_dirty(struct page *page)
3492static const struct address_space_operations ext4_ordered_aops = { 3363static const struct address_space_operations ext4_ordered_aops = {
3493 .readpage = ext4_readpage, 3364 .readpage = ext4_readpage,
3494 .readpages = ext4_readpages, 3365 .readpages = ext4_readpages,
3495 .writepage = ext4_normal_writepage, 3366 .writepage = ext4_writepage,
3496 .sync_page = block_sync_page, 3367 .sync_page = block_sync_page,
3497 .write_begin = ext4_write_begin, 3368 .write_begin = ext4_write_begin,
3498 .write_end = ext4_ordered_write_end, 3369 .write_end = ext4_ordered_write_end,
@@ -3507,7 +3378,7 @@ static const struct address_space_operations ext4_ordered_aops = {
3507static const struct address_space_operations ext4_writeback_aops = { 3378static const struct address_space_operations ext4_writeback_aops = {
3508 .readpage = ext4_readpage, 3379 .readpage = ext4_readpage,
3509 .readpages = ext4_readpages, 3380 .readpages = ext4_readpages,
3510 .writepage = ext4_normal_writepage, 3381 .writepage = ext4_writepage,
3511 .sync_page = block_sync_page, 3382 .sync_page = block_sync_page,
3512 .write_begin = ext4_write_begin, 3383 .write_begin = ext4_write_begin,
3513 .write_end = ext4_writeback_write_end, 3384 .write_end = ext4_writeback_write_end,
@@ -3522,7 +3393,7 @@ static const struct address_space_operations ext4_writeback_aops = {
3522static const struct address_space_operations ext4_journalled_aops = { 3393static const struct address_space_operations ext4_journalled_aops = {
3523 .readpage = ext4_readpage, 3394 .readpage = ext4_readpage,
3524 .readpages = ext4_readpages, 3395 .readpages = ext4_readpages,
3525 .writepage = ext4_journalled_writepage, 3396 .writepage = ext4_writepage,
3526 .sync_page = block_sync_page, 3397 .sync_page = block_sync_page,
3527 .write_begin = ext4_write_begin, 3398 .write_begin = ext4_write_begin,
3528 .write_end = ext4_journalled_write_end, 3399 .write_end = ext4_journalled_write_end,
@@ -3536,7 +3407,7 @@ static const struct address_space_operations ext4_journalled_aops = {
3536static const struct address_space_operations ext4_da_aops = { 3407static const struct address_space_operations ext4_da_aops = {
3537 .readpage = ext4_readpage, 3408 .readpage = ext4_readpage,
3538 .readpages = ext4_readpages, 3409 .readpages = ext4_readpages,
3539 .writepage = ext4_da_writepage, 3410 .writepage = ext4_writepage,
3540 .writepages = ext4_da_writepages, 3411 .writepages = ext4_da_writepages,
3541 .sync_page = block_sync_page, 3412 .sync_page = block_sync_page,
3542 .write_begin = ext4_da_write_begin, 3413 .write_begin = ext4_da_write_begin,
@@ -3583,7 +3454,8 @@ int ext4_block_truncate_page(handle_t *handle,
3583 struct page *page; 3454 struct page *page;
3584 int err = 0; 3455 int err = 0;
3585 3456
3586 page = grab_cache_page(mapping, from >> PAGE_CACHE_SHIFT); 3457 page = find_or_create_page(mapping, from >> PAGE_CACHE_SHIFT,
3458 mapping_gfp_mask(mapping) & ~__GFP_FS);
3587 if (!page) 3459 if (!page)
3588 return -EINVAL; 3460 return -EINVAL;
3589 3461
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index bb415408fdb6..7050a9cd04a4 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -12,7 +12,6 @@
12#include <linux/capability.h> 12#include <linux/capability.h>
13#include <linux/time.h> 13#include <linux/time.h>
14#include <linux/compat.h> 14#include <linux/compat.h>
15#include <linux/smp_lock.h>
16#include <linux/mount.h> 15#include <linux/mount.h>
17#include <linux/file.h> 16#include <linux/file.h>
18#include <asm/uaccess.h> 17#include <asm/uaccess.h>
@@ -192,7 +191,7 @@ setversion_out:
192 case EXT4_IOC_GROUP_EXTEND: { 191 case EXT4_IOC_GROUP_EXTEND: {
193 ext4_fsblk_t n_blocks_count; 192 ext4_fsblk_t n_blocks_count;
194 struct super_block *sb = inode->i_sb; 193 struct super_block *sb = inode->i_sb;
195 int err, err2; 194 int err, err2=0;
196 195
197 if (!capable(CAP_SYS_RESOURCE)) 196 if (!capable(CAP_SYS_RESOURCE))
198 return -EPERM; 197 return -EPERM;
@@ -205,9 +204,11 @@ setversion_out:
205 return err; 204 return err;
206 205
207 err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count); 206 err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count);
208 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); 207 if (EXT4_SB(sb)->s_journal) {
209 err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); 208 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
210 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); 209 err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal);
210 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
211 }
211 if (err == 0) 212 if (err == 0)
212 err = err2; 213 err = err2;
213 mnt_drop_write(filp->f_path.mnt); 214 mnt_drop_write(filp->f_path.mnt);
@@ -252,7 +253,7 @@ setversion_out:
252 case EXT4_IOC_GROUP_ADD: { 253 case EXT4_IOC_GROUP_ADD: {
253 struct ext4_new_group_data input; 254 struct ext4_new_group_data input;
254 struct super_block *sb = inode->i_sb; 255 struct super_block *sb = inode->i_sb;
255 int err, err2; 256 int err, err2=0;
256 257
257 if (!capable(CAP_SYS_RESOURCE)) 258 if (!capable(CAP_SYS_RESOURCE))
258 return -EPERM; 259 return -EPERM;
@@ -266,9 +267,11 @@ setversion_out:
266 return err; 267 return err;
267 268
268 err = ext4_group_add(sb, &input); 269 err = ext4_group_add(sb, &input);
269 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); 270 if (EXT4_SB(sb)->s_journal) {
270 err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); 271 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
271 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); 272 err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal);
273 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
274 }
272 if (err == 0) 275 if (err == 0)
273 err = err2; 276 err = err2;
274 mnt_drop_write(filp->f_path.mnt); 277 mnt_drop_write(filp->f_path.mnt);
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 519a0a686d94..cd258463e2a9 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -657,7 +657,8 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,
657 } 657 }
658} 658}
659 659
660static void ext4_mb_generate_buddy(struct super_block *sb, 660static noinline_for_stack
661void ext4_mb_generate_buddy(struct super_block *sb,
661 void *buddy, void *bitmap, ext4_group_t group) 662 void *buddy, void *bitmap, ext4_group_t group)
662{ 663{
663 struct ext4_group_info *grp = ext4_get_group_info(sb, group); 664 struct ext4_group_info *grp = ext4_get_group_info(sb, group);
@@ -1480,7 +1481,8 @@ static void ext4_mb_measure_extent(struct ext4_allocation_context *ac,
1480 ext4_mb_check_limits(ac, e4b, 0); 1481 ext4_mb_check_limits(ac, e4b, 0);
1481} 1482}
1482 1483
1483static int ext4_mb_try_best_found(struct ext4_allocation_context *ac, 1484static noinline_for_stack
1485int ext4_mb_try_best_found(struct ext4_allocation_context *ac,
1484 struct ext4_buddy *e4b) 1486 struct ext4_buddy *e4b)
1485{ 1487{
1486 struct ext4_free_extent ex = ac->ac_b_ex; 1488 struct ext4_free_extent ex = ac->ac_b_ex;
@@ -1507,7 +1509,8 @@ static int ext4_mb_try_best_found(struct ext4_allocation_context *ac,
1507 return 0; 1509 return 0;
1508} 1510}
1509 1511
1510static int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, 1512static noinline_for_stack
1513int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
1511 struct ext4_buddy *e4b) 1514 struct ext4_buddy *e4b)
1512{ 1515{
1513 ext4_group_t group = ac->ac_g_ex.fe_group; 1516 ext4_group_t group = ac->ac_g_ex.fe_group;
@@ -1566,7 +1569,8 @@ static int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
1566 * The routine scans buddy structures (not bitmap!) from given order 1569 * The routine scans buddy structures (not bitmap!) from given order
1567 * to max order and tries to find big enough chunk to satisfy the req 1570 * to max order and tries to find big enough chunk to satisfy the req
1568 */ 1571 */
1569static void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac, 1572static noinline_for_stack
1573void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
1570 struct ext4_buddy *e4b) 1574 struct ext4_buddy *e4b)
1571{ 1575{
1572 struct super_block *sb = ac->ac_sb; 1576 struct super_block *sb = ac->ac_sb;
@@ -1609,7 +1613,8 @@ static void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
1609 * In order to optimize scanning, caller must pass number of 1613 * In order to optimize scanning, caller must pass number of
1610 * free blocks in the group, so the routine can know upper limit. 1614 * free blocks in the group, so the routine can know upper limit.
1611 */ 1615 */
1612static void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, 1616static noinline_for_stack
1617void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1613 struct ext4_buddy *e4b) 1618 struct ext4_buddy *e4b)
1614{ 1619{
1615 struct super_block *sb = ac->ac_sb; 1620 struct super_block *sb = ac->ac_sb;
@@ -1668,7 +1673,8 @@ static void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1668 * we try to find stripe-aligned chunks for stripe-size requests 1673 * we try to find stripe-aligned chunks for stripe-size requests
1669 * XXX should do so at least for multiples of stripe size as well 1674 * XXX should do so at least for multiples of stripe size as well
1670 */ 1675 */
1671static void ext4_mb_scan_aligned(struct ext4_allocation_context *ac, 1676static noinline_for_stack
1677void ext4_mb_scan_aligned(struct ext4_allocation_context *ac,
1672 struct ext4_buddy *e4b) 1678 struct ext4_buddy *e4b)
1673{ 1679{
1674 struct super_block *sb = ac->ac_sb; 1680 struct super_block *sb = ac->ac_sb;
@@ -1831,7 +1837,8 @@ void ext4_mb_put_buddy_cache_lock(struct super_block *sb,
1831 1837
1832} 1838}
1833 1839
1834static int ext4_mb_init_group(struct super_block *sb, ext4_group_t group) 1840static noinline_for_stack
1841int ext4_mb_init_group(struct super_block *sb, ext4_group_t group)
1835{ 1842{
1836 1843
1837 int ret; 1844 int ret;
@@ -2902,7 +2909,11 @@ int __init init_ext4_mballoc(void)
2902 2909
2903void exit_ext4_mballoc(void) 2910void exit_ext4_mballoc(void)
2904{ 2911{
2905 /* XXX: synchronize_rcu(); */ 2912 /*
2913 * Wait for completion of call_rcu()'s on ext4_pspace_cachep
2914 * before destroying the slab cache.
2915 */
2916 rcu_barrier();
2906 kmem_cache_destroy(ext4_pspace_cachep); 2917 kmem_cache_destroy(ext4_pspace_cachep);
2907 kmem_cache_destroy(ext4_ac_cachep); 2918 kmem_cache_destroy(ext4_ac_cachep);
2908 kmem_cache_destroy(ext4_free_ext_cachep); 2919 kmem_cache_destroy(ext4_free_ext_cachep);
@@ -3457,7 +3468,8 @@ static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap,
3457 * used in in-core bitmap. buddy must be generated from this bitmap 3468 * used in in-core bitmap. buddy must be generated from this bitmap
3458 * Need to be called with ext4 group lock held 3469 * Need to be called with ext4 group lock held
3459 */ 3470 */
3460static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, 3471static noinline_for_stack
3472void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
3461 ext4_group_t group) 3473 ext4_group_t group)
3462{ 3474{
3463 struct ext4_group_info *grp = ext4_get_group_info(sb, group); 3475 struct ext4_group_info *grp = ext4_get_group_info(sb, group);
@@ -4215,14 +4227,9 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
4215 ext4_get_group_no_and_offset(sb, goal, &group, &block); 4227 ext4_get_group_no_and_offset(sb, goal, &group, &block);
4216 4228
4217 /* set up allocation goals */ 4229 /* set up allocation goals */
4230 memset(ac, 0, sizeof(struct ext4_allocation_context));
4218 ac->ac_b_ex.fe_logical = ar->logical; 4231 ac->ac_b_ex.fe_logical = ar->logical;
4219 ac->ac_b_ex.fe_group = 0;
4220 ac->ac_b_ex.fe_start = 0;
4221 ac->ac_b_ex.fe_len = 0;
4222 ac->ac_status = AC_STATUS_CONTINUE; 4232 ac->ac_status = AC_STATUS_CONTINUE;
4223 ac->ac_groups_scanned = 0;
4224 ac->ac_ex_scanned = 0;
4225 ac->ac_found = 0;
4226 ac->ac_sb = sb; 4233 ac->ac_sb = sb;
4227 ac->ac_inode = ar->inode; 4234 ac->ac_inode = ar->inode;
4228 ac->ac_o_ex.fe_logical = ar->logical; 4235 ac->ac_o_ex.fe_logical = ar->logical;
@@ -4233,15 +4240,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
4233 ac->ac_g_ex.fe_group = group; 4240 ac->ac_g_ex.fe_group = group;
4234 ac->ac_g_ex.fe_start = block; 4241 ac->ac_g_ex.fe_start = block;
4235 ac->ac_g_ex.fe_len = len; 4242 ac->ac_g_ex.fe_len = len;
4236 ac->ac_f_ex.fe_len = 0;
4237 ac->ac_flags = ar->flags; 4243 ac->ac_flags = ar->flags;
4238 ac->ac_2order = 0;
4239 ac->ac_criteria = 0;
4240 ac->ac_pa = NULL;
4241 ac->ac_bitmap_page = NULL;
4242 ac->ac_buddy_page = NULL;
4243 ac->alloc_semp = NULL;
4244 ac->ac_lg = NULL;
4245 4244
4246 /* we have to define context: we'll we work with a file or 4245 /* we have to define context: we'll we work with a file or
4247 * locality group. this is a policy, actually */ 4246 * locality group. this is a policy, actually */
@@ -4509,10 +4508,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4509 } 4508 }
4510 4509
4511 ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); 4510 ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);
4512 if (ac) { 4511 if (!ac) {
4513 ac->ac_sb = sb;
4514 ac->ac_inode = ar->inode;
4515 } else {
4516 ar->len = 0; 4512 ar->len = 0;
4517 *errp = -ENOMEM; 4513 *errp = -ENOMEM;
4518 goto out1; 4514 goto out1;
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 38ff75a0fe22..530b4ca01510 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -16,7 +16,6 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/time.h> 18#include <linux/time.h>
19#include <linux/smp_lock.h>
20#include <linux/buffer_head.h> 19#include <linux/buffer_head.h>
21#include <linux/compat.h> 20#include <linux/compat.h>
22#include <asm/uaccess.h> 21#include <asm/uaccess.h>
diff --git a/fs/fat/file.c b/fs/fat/file.c
index b28ea646ff60..f042b965c95c 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -134,7 +134,7 @@ static int fat_file_release(struct inode *inode, struct file *filp)
134 if ((filp->f_mode & FMODE_WRITE) && 134 if ((filp->f_mode & FMODE_WRITE) &&
135 MSDOS_SB(inode->i_sb)->options.flush) { 135 MSDOS_SB(inode->i_sb)->options.flush) {
136 fat_flush_inodes(inode->i_sb, inode, NULL); 136 fat_flush_inodes(inode->i_sb, inode, NULL);
137 congestion_wait(WRITE, HZ/10); 137 congestion_wait(BLK_RW_ASYNC, HZ/10);
138 } 138 }
139 return 0; 139 return 0;
140} 140}
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 82f88733b681..bbc94ae4fd77 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -9,7 +9,6 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/time.h> 10#include <linux/time.h>
11#include <linux/buffer_head.h> 11#include <linux/buffer_head.h>
12#include <linux/smp_lock.h>
13#include "fat.h" 12#include "fat.h"
14 13
15/* Characters that are undesirable in an MS-DOS file name */ 14/* Characters that are undesirable in an MS-DOS file name */
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 73471b7ecc8c..cb6e83557112 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -19,7 +19,6 @@
19#include <linux/jiffies.h> 19#include <linux/jiffies.h>
20#include <linux/ctype.h> 20#include <linux/ctype.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/smp_lock.h>
23#include <linux/buffer_head.h> 22#include <linux/buffer_head.h>
24#include <linux/namei.h> 23#include <linux/namei.h>
25#include "fat.h" 24#include "fat.h"
diff --git a/fs/fcntl.c b/fs/fcntl.c
index a040b764f8e3..ae413086db97 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -19,7 +19,6 @@
19#include <linux/signal.h> 19#include <linux/signal.h>
20#include <linux/rcupdate.h> 20#include <linux/rcupdate.h>
21#include <linux/pid_namespace.h> 21#include <linux/pid_namespace.h>
22#include <linux/smp_lock.h>
23 22
24#include <asm/poll.h> 23#include <asm/poll.h>
25#include <asm/siginfo.h> 24#include <asm/siginfo.h>
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c
index cdbd1654e4cd..1e8af939b3e4 100644
--- a/fs/freevxfs/vxfs_super.c
+++ b/fs/freevxfs/vxfs_super.c
@@ -38,6 +38,7 @@
38#include <linux/buffer_head.h> 38#include <linux/buffer_head.h>
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/smp_lock.h>
41#include <linux/stat.h> 42#include <linux/stat.h>
42#include <linux/vfs.h> 43#include <linux/vfs.h>
43#include <linux/mount.h> 44#include <linux/mount.h>
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 8fed2ed12f38..6484eb75acd6 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -286,8 +286,8 @@ __releases(&fc->lock)
286 } 286 }
287 if (fc->num_background == FUSE_CONGESTION_THRESHOLD && 287 if (fc->num_background == FUSE_CONGESTION_THRESHOLD &&
288 fc->connected && fc->bdi_initialized) { 288 fc->connected && fc->bdi_initialized) {
289 clear_bdi_congested(&fc->bdi, READ); 289 clear_bdi_congested(&fc->bdi, BLK_RW_SYNC);
290 clear_bdi_congested(&fc->bdi, WRITE); 290 clear_bdi_congested(&fc->bdi, BLK_RW_ASYNC);
291 } 291 }
292 fc->num_background--; 292 fc->num_background--;
293 fc->active_background--; 293 fc->active_background--;
@@ -414,8 +414,8 @@ static void fuse_request_send_nowait_locked(struct fuse_conn *fc,
414 fc->blocked = 1; 414 fc->blocked = 1;
415 if (fc->num_background == FUSE_CONGESTION_THRESHOLD && 415 if (fc->num_background == FUSE_CONGESTION_THRESHOLD &&
416 fc->bdi_initialized) { 416 fc->bdi_initialized) {
417 set_bdi_congested(&fc->bdi, READ); 417 set_bdi_congested(&fc->bdi, BLK_RW_SYNC);
418 set_bdi_congested(&fc->bdi, WRITE); 418 set_bdi_congested(&fc->bdi, BLK_RW_ASYNC);
419 } 419 }
420 list_add_tail(&req->list, &fc->bg_queue); 420 list_add_tail(&req->list, &fc->bg_queue);
421 flush_bg_queue(fc); 421 flush_bg_queue(fc);
@@ -849,6 +849,81 @@ err:
849 return err; 849 return err;
850} 850}
851 851
852static int fuse_notify_inval_inode(struct fuse_conn *fc, unsigned int size,
853 struct fuse_copy_state *cs)
854{
855 struct fuse_notify_inval_inode_out outarg;
856 int err = -EINVAL;
857
858 if (size != sizeof(outarg))
859 goto err;
860
861 err = fuse_copy_one(cs, &outarg, sizeof(outarg));
862 if (err)
863 goto err;
864 fuse_copy_finish(cs);
865
866 down_read(&fc->killsb);
867 err = -ENOENT;
868 if (!fc->sb)
869 goto err_unlock;
870
871 err = fuse_reverse_inval_inode(fc->sb, outarg.ino,
872 outarg.off, outarg.len);
873
874err_unlock:
875 up_read(&fc->killsb);
876 return err;
877
878err:
879 fuse_copy_finish(cs);
880 return err;
881}
882
883static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size,
884 struct fuse_copy_state *cs)
885{
886 struct fuse_notify_inval_entry_out outarg;
887 int err = -EINVAL;
888 char buf[FUSE_NAME_MAX+1];
889 struct qstr name;
890
891 if (size < sizeof(outarg))
892 goto err;
893
894 err = fuse_copy_one(cs, &outarg, sizeof(outarg));
895 if (err)
896 goto err;
897
898 err = -ENAMETOOLONG;
899 if (outarg.namelen > FUSE_NAME_MAX)
900 goto err;
901
902 name.name = buf;
903 name.len = outarg.namelen;
904 err = fuse_copy_one(cs, buf, outarg.namelen + 1);
905 if (err)
906 goto err;
907 fuse_copy_finish(cs);
908 buf[outarg.namelen] = 0;
909 name.hash = full_name_hash(name.name, name.len);
910
911 down_read(&fc->killsb);
912 err = -ENOENT;
913 if (!fc->sb)
914 goto err_unlock;
915
916 err = fuse_reverse_inval_entry(fc->sb, outarg.parent, &name);
917
918err_unlock:
919 up_read(&fc->killsb);
920 return err;
921
922err:
923 fuse_copy_finish(cs);
924 return err;
925}
926
852static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code, 927static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code,
853 unsigned int size, struct fuse_copy_state *cs) 928 unsigned int size, struct fuse_copy_state *cs)
854{ 929{
@@ -856,6 +931,12 @@ static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code,
856 case FUSE_NOTIFY_POLL: 931 case FUSE_NOTIFY_POLL:
857 return fuse_notify_poll(fc, size, cs); 932 return fuse_notify_poll(fc, size, cs);
858 933
934 case FUSE_NOTIFY_INVAL_INODE:
935 return fuse_notify_inval_inode(fc, size, cs);
936
937 case FUSE_NOTIFY_INVAL_ENTRY:
938 return fuse_notify_inval_entry(fc, size, cs);
939
859 default: 940 default:
860 fuse_copy_finish(cs); 941 fuse_copy_finish(cs);
861 return -EINVAL; 942 return -EINVAL;
@@ -910,7 +991,7 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
910 unsigned long nr_segs, loff_t pos) 991 unsigned long nr_segs, loff_t pos)
911{ 992{
912 int err; 993 int err;
913 unsigned nbytes = iov_length(iov, nr_segs); 994 size_t nbytes = iov_length(iov, nr_segs);
914 struct fuse_req *req; 995 struct fuse_req *req;
915 struct fuse_out_header oh; 996 struct fuse_out_header oh;
916 struct fuse_copy_state cs; 997 struct fuse_copy_state cs;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index b3089a083d30..e703654e7f40 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -375,7 +375,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
375 struct fuse_conn *fc = get_fuse_conn(dir); 375 struct fuse_conn *fc = get_fuse_conn(dir);
376 struct fuse_req *req; 376 struct fuse_req *req;
377 struct fuse_req *forget_req; 377 struct fuse_req *forget_req;
378 struct fuse_open_in inarg; 378 struct fuse_create_in inarg;
379 struct fuse_open_out outopen; 379 struct fuse_open_out outopen;
380 struct fuse_entry_out outentry; 380 struct fuse_entry_out outentry;
381 struct fuse_file *ff; 381 struct fuse_file *ff;
@@ -399,15 +399,20 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
399 if (!ff) 399 if (!ff)
400 goto out_put_request; 400 goto out_put_request;
401 401
402 if (!fc->dont_mask)
403 mode &= ~current_umask();
404
402 flags &= ~O_NOCTTY; 405 flags &= ~O_NOCTTY;
403 memset(&inarg, 0, sizeof(inarg)); 406 memset(&inarg, 0, sizeof(inarg));
404 memset(&outentry, 0, sizeof(outentry)); 407 memset(&outentry, 0, sizeof(outentry));
405 inarg.flags = flags; 408 inarg.flags = flags;
406 inarg.mode = mode; 409 inarg.mode = mode;
410 inarg.umask = current_umask();
407 req->in.h.opcode = FUSE_CREATE; 411 req->in.h.opcode = FUSE_CREATE;
408 req->in.h.nodeid = get_node_id(dir); 412 req->in.h.nodeid = get_node_id(dir);
409 req->in.numargs = 2; 413 req->in.numargs = 2;
410 req->in.args[0].size = sizeof(inarg); 414 req->in.args[0].size = fc->minor < 12 ? sizeof(struct fuse_open_in) :
415 sizeof(inarg);
411 req->in.args[0].value = &inarg; 416 req->in.args[0].value = &inarg;
412 req->in.args[1].size = entry->d_name.len + 1; 417 req->in.args[1].size = entry->d_name.len + 1;
413 req->in.args[1].value = entry->d_name.name; 418 req->in.args[1].value = entry->d_name.name;
@@ -546,12 +551,17 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode,
546 if (IS_ERR(req)) 551 if (IS_ERR(req))
547 return PTR_ERR(req); 552 return PTR_ERR(req);
548 553
554 if (!fc->dont_mask)
555 mode &= ~current_umask();
556
549 memset(&inarg, 0, sizeof(inarg)); 557 memset(&inarg, 0, sizeof(inarg));
550 inarg.mode = mode; 558 inarg.mode = mode;
551 inarg.rdev = new_encode_dev(rdev); 559 inarg.rdev = new_encode_dev(rdev);
560 inarg.umask = current_umask();
552 req->in.h.opcode = FUSE_MKNOD; 561 req->in.h.opcode = FUSE_MKNOD;
553 req->in.numargs = 2; 562 req->in.numargs = 2;
554 req->in.args[0].size = sizeof(inarg); 563 req->in.args[0].size = fc->minor < 12 ? FUSE_COMPAT_MKNOD_IN_SIZE :
564 sizeof(inarg);
555 req->in.args[0].value = &inarg; 565 req->in.args[0].value = &inarg;
556 req->in.args[1].size = entry->d_name.len + 1; 566 req->in.args[1].size = entry->d_name.len + 1;
557 req->in.args[1].value = entry->d_name.name; 567 req->in.args[1].value = entry->d_name.name;
@@ -578,8 +588,12 @@ static int fuse_mkdir(struct inode *dir, struct dentry *entry, int mode)
578 if (IS_ERR(req)) 588 if (IS_ERR(req))
579 return PTR_ERR(req); 589 return PTR_ERR(req);
580 590
591 if (!fc->dont_mask)
592 mode &= ~current_umask();
593
581 memset(&inarg, 0, sizeof(inarg)); 594 memset(&inarg, 0, sizeof(inarg));
582 inarg.mode = mode; 595 inarg.mode = mode;
596 inarg.umask = current_umask();
583 req->in.h.opcode = FUSE_MKDIR; 597 req->in.h.opcode = FUSE_MKDIR;
584 req->in.numargs = 2; 598 req->in.numargs = 2;
585 req->in.args[0].size = sizeof(inarg); 599 req->in.args[0].size = sizeof(inarg);
@@ -845,6 +859,43 @@ int fuse_update_attributes(struct inode *inode, struct kstat *stat,
845 return err; 859 return err;
846} 860}
847 861
862int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
863 struct qstr *name)
864{
865 int err = -ENOTDIR;
866 struct inode *parent;
867 struct dentry *dir;
868 struct dentry *entry;
869
870 parent = ilookup5(sb, parent_nodeid, fuse_inode_eq, &parent_nodeid);
871 if (!parent)
872 return -ENOENT;
873
874 mutex_lock(&parent->i_mutex);
875 if (!S_ISDIR(parent->i_mode))
876 goto unlock;
877
878 err = -ENOENT;
879 dir = d_find_alias(parent);
880 if (!dir)
881 goto unlock;
882
883 entry = d_lookup(dir, name);
884 dput(dir);
885 if (!entry)
886 goto unlock;
887
888 fuse_invalidate_attr(parent);
889 fuse_invalidate_entry(entry);
890 dput(entry);
891 err = 0;
892
893 unlock:
894 mutex_unlock(&parent->i_mutex);
895 iput(parent);
896 return err;
897}
898
848/* 899/*
849 * Calling into a user-controlled filesystem gives the filesystem 900 * Calling into a user-controlled filesystem gives the filesystem
850 * daemon ptrace-like capabilities over the requester process. This 901 * daemon ptrace-like capabilities over the requester process. This
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index fce6ce694fde..cbc464043b6f 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1922,7 +1922,7 @@ unsigned fuse_file_poll(struct file *file, poll_table *wait)
1922 1922
1923 req = fuse_get_req(fc); 1923 req = fuse_get_req(fc);
1924 if (IS_ERR(req)) 1924 if (IS_ERR(req))
1925 return PTR_ERR(req); 1925 return POLLERR;
1926 1926
1927 req->in.h.opcode = FUSE_POLL; 1927 req->in.h.opcode = FUSE_POLL;
1928 req->in.h.nodeid = ff->nodeid; 1928 req->in.h.nodeid = ff->nodeid;
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index aaf2f9ff970e..52b641fc0faf 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -446,6 +446,9 @@ struct fuse_conn {
446 /** Do multi-page cached writes */ 446 /** Do multi-page cached writes */
447 unsigned big_writes:1; 447 unsigned big_writes:1;
448 448
449 /** Don't apply umask to creation modes */
450 unsigned dont_mask:1;
451
449 /** The number of requests waiting for completion */ 452 /** The number of requests waiting for completion */
450 atomic_t num_waiting; 453 atomic_t num_waiting;
451 454
@@ -481,6 +484,12 @@ struct fuse_conn {
481 484
482 /** Called on final put */ 485 /** Called on final put */
483 void (*release)(struct fuse_conn *); 486 void (*release)(struct fuse_conn *);
487
488 /** Super block for this connection. */
489 struct super_block *sb;
490
491 /** Read/write semaphore to hold when accessing sb. */
492 struct rw_semaphore killsb;
484}; 493};
485 494
486static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) 495static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
@@ -509,6 +518,11 @@ extern const struct file_operations fuse_dev_operations;
509extern const struct dentry_operations fuse_dentry_operations; 518extern const struct dentry_operations fuse_dentry_operations;
510 519
511/** 520/**
521 * Inode to nodeid comparison.
522 */
523int fuse_inode_eq(struct inode *inode, void *_nodeidp);
524
525/**
512 * Get a filled in inode 526 * Get a filled in inode
513 */ 527 */
514struct inode *fuse_iget(struct super_block *sb, u64 nodeid, 528struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
@@ -708,6 +722,19 @@ void fuse_release_nowrite(struct inode *inode);
708 722
709u64 fuse_get_attr_version(struct fuse_conn *fc); 723u64 fuse_get_attr_version(struct fuse_conn *fc);
710 724
725/**
726 * File-system tells the kernel to invalidate cache for the given node id.
727 */
728int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid,
729 loff_t offset, loff_t len);
730
731/**
732 * File-system tells the kernel to invalidate parent attributes and
733 * the dentry matching parent/name.
734 */
735int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
736 struct qstr *name);
737
711int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file, 738int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
712 bool isdir); 739 bool isdir);
713ssize_t fuse_direct_io(struct file *file, const char __user *buf, 740ssize_t fuse_direct_io(struct file *file, const char __user *buf,
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index d8673ccf90b7..f91ccc4a189d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -206,7 +206,7 @@ static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr)
206 BUG(); 206 BUG();
207} 207}
208 208
209static int fuse_inode_eq(struct inode *inode, void *_nodeidp) 209int fuse_inode_eq(struct inode *inode, void *_nodeidp)
210{ 210{
211 u64 nodeid = *(u64 *) _nodeidp; 211 u64 nodeid = *(u64 *) _nodeidp;
212 if (get_node_id(inode) == nodeid) 212 if (get_node_id(inode) == nodeid)
@@ -257,6 +257,31 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
257 return inode; 257 return inode;
258} 258}
259 259
260int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid,
261 loff_t offset, loff_t len)
262{
263 struct inode *inode;
264 pgoff_t pg_start;
265 pgoff_t pg_end;
266
267 inode = ilookup5(sb, nodeid, fuse_inode_eq, &nodeid);
268 if (!inode)
269 return -ENOENT;
270
271 fuse_invalidate_attr(inode);
272 if (offset >= 0) {
273 pg_start = offset >> PAGE_CACHE_SHIFT;
274 if (len <= 0)
275 pg_end = -1;
276 else
277 pg_end = (offset + len - 1) >> PAGE_CACHE_SHIFT;
278 invalidate_inode_pages2_range(inode->i_mapping,
279 pg_start, pg_end);
280 }
281 iput(inode);
282 return 0;
283}
284
260static void fuse_umount_begin(struct super_block *sb) 285static void fuse_umount_begin(struct super_block *sb)
261{ 286{
262 fuse_abort_conn(get_fuse_conn_super(sb)); 287 fuse_abort_conn(get_fuse_conn_super(sb));
@@ -480,6 +505,7 @@ void fuse_conn_init(struct fuse_conn *fc)
480 memset(fc, 0, sizeof(*fc)); 505 memset(fc, 0, sizeof(*fc));
481 spin_lock_init(&fc->lock); 506 spin_lock_init(&fc->lock);
482 mutex_init(&fc->inst_mutex); 507 mutex_init(&fc->inst_mutex);
508 init_rwsem(&fc->killsb);
483 atomic_set(&fc->count, 1); 509 atomic_set(&fc->count, 1);
484 init_waitqueue_head(&fc->waitq); 510 init_waitqueue_head(&fc->waitq);
485 init_waitqueue_head(&fc->blocked_waitq); 511 init_waitqueue_head(&fc->blocked_waitq);
@@ -725,6 +751,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
725 } 751 }
726 if (arg->flags & FUSE_BIG_WRITES) 752 if (arg->flags & FUSE_BIG_WRITES)
727 fc->big_writes = 1; 753 fc->big_writes = 1;
754 if (arg->flags & FUSE_DONT_MASK)
755 fc->dont_mask = 1;
728 } else { 756 } else {
729 ra_pages = fc->max_read / PAGE_CACHE_SIZE; 757 ra_pages = fc->max_read / PAGE_CACHE_SIZE;
730 fc->no_lock = 1; 758 fc->no_lock = 1;
@@ -748,7 +776,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
748 arg->minor = FUSE_KERNEL_MINOR_VERSION; 776 arg->minor = FUSE_KERNEL_MINOR_VERSION;
749 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; 777 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
750 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | 778 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
751 FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES; 779 FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK;
752 req->in.h.opcode = FUSE_INIT; 780 req->in.h.opcode = FUSE_INIT;
753 req->in.numargs = 1; 781 req->in.numargs = 1;
754 req->in.args[0].size = sizeof(*arg); 782 req->in.args[0].size = sizeof(*arg);
@@ -860,10 +888,16 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
860 fuse_conn_init(fc); 888 fuse_conn_init(fc);
861 889
862 fc->dev = sb->s_dev; 890 fc->dev = sb->s_dev;
891 fc->sb = sb;
863 err = fuse_bdi_init(fc, sb); 892 err = fuse_bdi_init(fc, sb);
864 if (err) 893 if (err)
865 goto err_put_conn; 894 goto err_put_conn;
866 895
896 /* Handle umasking inside the fuse code */
897 if (sb->s_flags & MS_POSIXACL)
898 fc->dont_mask = 1;
899 sb->s_flags |= MS_POSIXACL;
900
867 fc->release = fuse_free_conn; 901 fc->release = fuse_free_conn;
868 fc->flags = d.flags; 902 fc->flags = d.flags;
869 fc->user_id = d.user_id; 903 fc->user_id = d.user_id;
@@ -941,12 +975,25 @@ static int fuse_get_sb(struct file_system_type *fs_type,
941 return get_sb_nodev(fs_type, flags, raw_data, fuse_fill_super, mnt); 975 return get_sb_nodev(fs_type, flags, raw_data, fuse_fill_super, mnt);
942} 976}
943 977
978static void fuse_kill_sb_anon(struct super_block *sb)
979{
980 struct fuse_conn *fc = get_fuse_conn_super(sb);
981
982 if (fc) {
983 down_write(&fc->killsb);
984 fc->sb = NULL;
985 up_write(&fc->killsb);
986 }
987
988 kill_anon_super(sb);
989}
990
944static struct file_system_type fuse_fs_type = { 991static struct file_system_type fuse_fs_type = {
945 .owner = THIS_MODULE, 992 .owner = THIS_MODULE,
946 .name = "fuse", 993 .name = "fuse",
947 .fs_flags = FS_HAS_SUBTYPE, 994 .fs_flags = FS_HAS_SUBTYPE,
948 .get_sb = fuse_get_sb, 995 .get_sb = fuse_get_sb,
949 .kill_sb = kill_anon_super, 996 .kill_sb = fuse_kill_sb_anon,
950}; 997};
951 998
952#ifdef CONFIG_BLOCK 999#ifdef CONFIG_BLOCK
@@ -958,11 +1005,24 @@ static int fuse_get_sb_blk(struct file_system_type *fs_type,
958 mnt); 1005 mnt);
959} 1006}
960 1007
1008static void fuse_kill_sb_blk(struct super_block *sb)
1009{
1010 struct fuse_conn *fc = get_fuse_conn_super(sb);
1011
1012 if (fc) {
1013 down_write(&fc->killsb);
1014 fc->sb = NULL;
1015 up_write(&fc->killsb);
1016 }
1017
1018 kill_block_super(sb);
1019}
1020
961static struct file_system_type fuseblk_fs_type = { 1021static struct file_system_type fuseblk_fs_type = {
962 .owner = THIS_MODULE, 1022 .owner = THIS_MODULE,
963 .name = "fuseblk", 1023 .name = "fuseblk",
964 .get_sb = fuse_get_sb_blk, 1024 .get_sb = fuse_get_sb_blk,
965 .kill_sb = kill_block_super, 1025 .kill_sb = fuse_kill_sb_blk,
966 .fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE, 1026 .fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE,
967}; 1027};
968 1028
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 6f833dc8e910..f7fcbe49da72 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -19,6 +19,7 @@
19#include <linux/nls.h> 19#include <linux/nls.h>
20#include <linux/parser.h> 20#include <linux/parser.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/smp_lock.h>
22#include <linux/vfs.h> 23#include <linux/vfs.h>
23 24
24#include "hfs_fs.h" 25#include "hfs_fs.h"
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 9fc3af0c0dab..c0759fe0855b 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -12,6 +12,7 @@
12#include <linux/pagemap.h> 12#include <linux/pagemap.h>
13#include <linux/fs.h> 13#include <linux/fs.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/smp_lock.h>
15#include <linux/vfs.h> 16#include <linux/vfs.h>
16#include <linux/nls.h> 17#include <linux/nls.h>
17 18
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index fe02ad4740e7..032604e5ef2c 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -972,6 +972,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
972 sb->s_blocksize_bits = 10; 972 sb->s_blocksize_bits = 10;
973 sb->s_magic = HOSTFS_SUPER_MAGIC; 973 sb->s_magic = HOSTFS_SUPER_MAGIC;
974 sb->s_op = &hostfs_sbops; 974 sb->s_op = &hostfs_sbops;
975 sb->s_maxbytes = MAX_LFS_FILESIZE;
975 976
976 /* NULL is printed as <NULL> by sprintf: avoid that. */ 977 /* NULL is printed as <NULL> by sprintf: avoid that. */
977 if (req_root == NULL) 978 if (req_root == NULL)
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 6916c41d7017..8865c94f55f6 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -6,6 +6,7 @@
6 * directory VFS functions 6 * directory VFS functions
7 */ 7 */
8 8
9#include <linux/smp_lock.h>
9#include "hpfs_fn.h" 10#include "hpfs_fn.h"
10 11
11static int hpfs_dir_release(struct inode *inode, struct file *filp) 12static int hpfs_dir_release(struct inode *inode, struct file *filp)
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index 64ab52259204..3efabff00367 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -6,6 +6,7 @@
6 * file VFS functions 6 * file VFS functions
7 */ 7 */
8 8
9#include <linux/smp_lock.h>
9#include "hpfs_fn.h" 10#include "hpfs_fn.h"
10 11
11#define BLOCKS(size) (((size) + 511) >> 9) 12#define BLOCKS(size) (((size) + 511) >> 9)
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index c2ea31bae313..701ca54c0867 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -13,7 +13,6 @@
13#include <linux/pagemap.h> 13#include <linux/pagemap.h>
14#include <linux/buffer_head.h> 14#include <linux/buffer_head.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/smp_lock.h>
17 16
18#include "hpfs.h" 17#include "hpfs.h"
19 18
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 39a1bfbea312..fe703ae46bc7 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -6,6 +6,7 @@
6 * inode VFS functions 6 * inode VFS functions
7 */ 7 */
8 8
9#include <linux/smp_lock.h>
9#include "hpfs_fn.h" 10#include "hpfs_fn.h"
10 11
11void hpfs_init_inode(struct inode *i) 12void hpfs_init_inode(struct inode *i)
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index b649232dde97..82b9c4ba9ed0 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -6,6 +6,7 @@
6 * adding & removing files & directories 6 * adding & removing files & directories
7 */ 7 */
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/smp_lock.h>
9#include "hpfs_fn.h" 10#include "hpfs_fn.h"
10 11
11static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) 12static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 58a7963e168a..85f96bc651c7 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -142,6 +142,7 @@ static const struct dentry_operations isofs_dentry_ops[] = {
142 142
143struct iso9660_options{ 143struct iso9660_options{
144 unsigned int rock:1; 144 unsigned int rock:1;
145 unsigned int joliet:1;
145 unsigned int cruft:1; 146 unsigned int cruft:1;
146 unsigned int hide:1; 147 unsigned int hide:1;
147 unsigned int showassoc:1; 148 unsigned int showassoc:1;
@@ -151,7 +152,6 @@ struct iso9660_options{
151 unsigned int gid_set:1; 152 unsigned int gid_set:1;
152 unsigned int utf8:1; 153 unsigned int utf8:1;
153 unsigned char map; 154 unsigned char map;
154 char joliet;
155 unsigned char check; 155 unsigned char check;
156 unsigned int blocksize; 156 unsigned int blocksize;
157 mode_t fmode; 157 mode_t fmode;
@@ -632,7 +632,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
632 else if (isonum_711(vdp->type) == ISO_VD_SUPPLEMENTARY) { 632 else if (isonum_711(vdp->type) == ISO_VD_SUPPLEMENTARY) {
633 sec = (struct iso_supplementary_descriptor *)vdp; 633 sec = (struct iso_supplementary_descriptor *)vdp;
634 if (sec->escape[0] == 0x25 && sec->escape[1] == 0x2f) { 634 if (sec->escape[0] == 0x25 && sec->escape[1] == 0x2f) {
635 if (opt.joliet == 'y') { 635 if (opt.joliet) {
636 if (sec->escape[2] == 0x40) 636 if (sec->escape[2] == 0x40)
637 joliet_level = 1; 637 joliet_level = 1;
638 else if (sec->escape[2] == 0x43) 638 else if (sec->escape[2] == 0x43)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 18bfd5dab642..e378cb383979 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -297,6 +297,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
297 unsigned int new_offset; 297 unsigned int new_offset;
298 struct buffer_head *bh_in = jh2bh(jh_in); 298 struct buffer_head *bh_in = jh2bh(jh_in);
299 struct jbd2_buffer_trigger_type *triggers; 299 struct jbd2_buffer_trigger_type *triggers;
300 journal_t *journal = transaction->t_journal;
300 301
301 /* 302 /*
302 * The buffer really shouldn't be locked: only the current committing 303 * The buffer really shouldn't be locked: only the current committing
@@ -310,6 +311,11 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
310 J_ASSERT_BH(bh_in, buffer_jbddirty(bh_in)); 311 J_ASSERT_BH(bh_in, buffer_jbddirty(bh_in));
311 312
312 new_bh = alloc_buffer_head(GFP_NOFS|__GFP_NOFAIL); 313 new_bh = alloc_buffer_head(GFP_NOFS|__GFP_NOFAIL);
314 /* keep subsequent assertions sane */
315 new_bh->b_state = 0;
316 init_buffer(new_bh, NULL, NULL);
317 atomic_set(&new_bh->b_count, 1);
318 new_jh = jbd2_journal_add_journal_head(new_bh); /* This sleeps */
313 319
314 /* 320 /*
315 * If a new transaction has already done a buffer copy-out, then 321 * If a new transaction has already done a buffer copy-out, then
@@ -388,14 +394,6 @@ repeat:
388 kunmap_atomic(mapped_data, KM_USER0); 394 kunmap_atomic(mapped_data, KM_USER0);
389 } 395 }
390 396
391 /* keep subsequent assertions sane */
392 new_bh->b_state = 0;
393 init_buffer(new_bh, NULL, NULL);
394 atomic_set(&new_bh->b_count, 1);
395 jbd_unlock_bh_state(bh_in);
396
397 new_jh = jbd2_journal_add_journal_head(new_bh); /* This sleeps */
398
399 set_bh_page(new_bh, new_page, new_offset); 397 set_bh_page(new_bh, new_page, new_offset);
400 new_jh->b_transaction = NULL; 398 new_jh->b_transaction = NULL;
401 new_bh->b_size = jh2bh(jh_in)->b_size; 399 new_bh->b_size = jh2bh(jh_in)->b_size;
@@ -412,7 +410,11 @@ repeat:
412 * copying is moved to the transaction's shadow queue. 410 * copying is moved to the transaction's shadow queue.
413 */ 411 */
414 JBUFFER_TRACE(jh_in, "file as BJ_Shadow"); 412 JBUFFER_TRACE(jh_in, "file as BJ_Shadow");
415 jbd2_journal_file_buffer(jh_in, transaction, BJ_Shadow); 413 spin_lock(&journal->j_list_lock);
414 __jbd2_journal_file_buffer(jh_in, transaction, BJ_Shadow);
415 spin_unlock(&journal->j_list_lock);
416 jbd_unlock_bh_state(bh_in);
417
416 JBUFFER_TRACE(new_jh, "file as BJ_IO"); 418 JBUFFER_TRACE(new_jh, "file as BJ_IO");
417 jbd2_journal_file_buffer(new_jh, transaction, BJ_IO); 419 jbd2_journal_file_buffer(new_jh, transaction, BJ_IO);
418 420
@@ -2410,6 +2412,7 @@ const char *jbd2_dev_to_name(dev_t device)
2410 int i = hash_32(device, CACHE_SIZE_BITS); 2412 int i = hash_32(device, CACHE_SIZE_BITS);
2411 char *ret; 2413 char *ret;
2412 struct block_device *bd; 2414 struct block_device *bd;
2415 static struct devname_cache *new_dev;
2413 2416
2414 rcu_read_lock(); 2417 rcu_read_lock();
2415 if (devcache[i] && devcache[i]->device == device) { 2418 if (devcache[i] && devcache[i]->device == device) {
@@ -2419,20 +2422,20 @@ const char *jbd2_dev_to_name(dev_t device)
2419 } 2422 }
2420 rcu_read_unlock(); 2423 rcu_read_unlock();
2421 2424
2425 new_dev = kmalloc(sizeof(struct devname_cache), GFP_KERNEL);
2426 if (!new_dev)
2427 return "NODEV-ALLOCFAILURE"; /* Something non-NULL */
2422 spin_lock(&devname_cache_lock); 2428 spin_lock(&devname_cache_lock);
2423 if (devcache[i]) { 2429 if (devcache[i]) {
2424 if (devcache[i]->device == device) { 2430 if (devcache[i]->device == device) {
2431 kfree(new_dev);
2425 ret = devcache[i]->devname; 2432 ret = devcache[i]->devname;
2426 spin_unlock(&devname_cache_lock); 2433 spin_unlock(&devname_cache_lock);
2427 return ret; 2434 return ret;
2428 } 2435 }
2429 call_rcu(&devcache[i]->rcu, free_devcache); 2436 call_rcu(&devcache[i]->rcu, free_devcache);
2430 } 2437 }
2431 devcache[i] = kmalloc(sizeof(struct devname_cache), GFP_KERNEL); 2438 devcache[i] = new_dev;
2432 if (!devcache[i]) {
2433 spin_unlock(&devname_cache_lock);
2434 return "NODEV-ALLOCFAILURE"; /* Something non-NULL */
2435 }
2436 devcache[i]->device = device; 2439 devcache[i]->device = device;
2437 bd = bdget(device); 2440 bd = bdget(device);
2438 if (bd) { 2441 if (bd) {
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 494501edba6b..6213ac728f30 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -499,34 +499,15 @@ void jbd2_journal_unlock_updates (journal_t *journal)
499 wake_up(&journal->j_wait_transaction_locked); 499 wake_up(&journal->j_wait_transaction_locked);
500} 500}
501 501
502/* 502static void warn_dirty_buffer(struct buffer_head *bh)
503 * Report any unexpected dirty buffers which turn up. Normally those
504 * indicate an error, but they can occur if the user is running (say)
505 * tune2fs to modify the live filesystem, so we need the option of
506 * continuing as gracefully as possible. #
507 *
508 * The caller should already hold the journal lock and
509 * j_list_lock spinlock: most callers will need those anyway
510 * in order to probe the buffer's journaling state safely.
511 */
512static void jbd_unexpected_dirty_buffer(struct journal_head *jh)
513{ 503{
514 int jlist; 504 char b[BDEVNAME_SIZE];
515
516 /* If this buffer is one which might reasonably be dirty
517 * --- ie. data, or not part of this journal --- then
518 * we're OK to leave it alone, but otherwise we need to
519 * move the dirty bit to the journal's own internal
520 * JBDDirty bit. */
521 jlist = jh->b_jlist;
522 505
523 if (jlist == BJ_Metadata || jlist == BJ_Reserved || 506 printk(KERN_WARNING
524 jlist == BJ_Shadow || jlist == BJ_Forget) { 507 "JBD: Spotted dirty metadata buffer (dev = %s, blocknr = %llu). "
525 struct buffer_head *bh = jh2bh(jh); 508 "There's a risk of filesystem corruption in case of system "
526 509 "crash.\n",
527 if (test_clear_buffer_dirty(bh)) 510 bdevname(bh->b_bdev, b), (unsigned long long)bh->b_blocknr);
528 set_buffer_jbddirty(bh);
529 }
530} 511}
531 512
532/* 513/*
@@ -593,14 +574,16 @@ repeat:
593 if (jh->b_next_transaction) 574 if (jh->b_next_transaction)
594 J_ASSERT_JH(jh, jh->b_next_transaction == 575 J_ASSERT_JH(jh, jh->b_next_transaction ==
595 transaction); 576 transaction);
577 warn_dirty_buffer(bh);
596 } 578 }
597 /* 579 /*
598 * In any case we need to clean the dirty flag and we must 580 * In any case we need to clean the dirty flag and we must
599 * do it under the buffer lock to be sure we don't race 581 * do it under the buffer lock to be sure we don't race
600 * with running write-out. 582 * with running write-out.
601 */ 583 */
602 JBUFFER_TRACE(jh, "Unexpected dirty buffer"); 584 JBUFFER_TRACE(jh, "Journalling dirty buffer");
603 jbd_unexpected_dirty_buffer(jh); 585 clear_buffer_dirty(bh);
586 set_buffer_jbddirty(bh);
604 } 587 }
605 588
606 unlock_buffer(bh); 589 unlock_buffer(bh);
@@ -843,6 +826,15 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh)
843 J_ASSERT_JH(jh, buffer_locked(jh2bh(jh))); 826 J_ASSERT_JH(jh, buffer_locked(jh2bh(jh)));
844 827
845 if (jh->b_transaction == NULL) { 828 if (jh->b_transaction == NULL) {
829 /*
830 * Previous jbd2_journal_forget() could have left the buffer
831 * with jbddirty bit set because it was being committed. When
832 * the commit finished, we've filed the buffer for
833 * checkpointing and marked it dirty. Now we are reallocating
834 * the buffer so the transaction freeing it must have
835 * committed and so it's safe to clear the dirty bit.
836 */
837 clear_buffer_dirty(jh2bh(jh));
846 jh->b_transaction = transaction; 838 jh->b_transaction = transaction;
847 839
848 /* first access by this transaction */ 840 /* first access by this transaction */
@@ -1644,8 +1636,13 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1644 1636
1645 if (jh->b_cp_transaction) { 1637 if (jh->b_cp_transaction) {
1646 JBUFFER_TRACE(jh, "on running+cp transaction"); 1638 JBUFFER_TRACE(jh, "on running+cp transaction");
1639 /*
1640 * We don't want to write the buffer anymore, clear the
1641 * bit so that we don't confuse checks in
1642 * __journal_file_buffer
1643 */
1644 clear_buffer_dirty(bh);
1647 __jbd2_journal_file_buffer(jh, transaction, BJ_Forget); 1645 __jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
1648 clear_buffer_jbddirty(bh);
1649 may_free = 0; 1646 may_free = 0;
1650 } else { 1647 } else {
1651 JBUFFER_TRACE(jh, "on running transaction"); 1648 JBUFFER_TRACE(jh, "on running transaction");
@@ -1896,12 +1893,17 @@ void __jbd2_journal_file_buffer(struct journal_head *jh,
1896 if (jh->b_transaction && jh->b_jlist == jlist) 1893 if (jh->b_transaction && jh->b_jlist == jlist)
1897 return; 1894 return;
1898 1895
1899 /* The following list of buffer states needs to be consistent
1900 * with __jbd_unexpected_dirty_buffer()'s handling of dirty
1901 * state. */
1902
1903 if (jlist == BJ_Metadata || jlist == BJ_Reserved || 1896 if (jlist == BJ_Metadata || jlist == BJ_Reserved ||
1904 jlist == BJ_Shadow || jlist == BJ_Forget) { 1897 jlist == BJ_Shadow || jlist == BJ_Forget) {
1898 /*
1899 * For metadata buffers, we track dirty bit in buffer_jbddirty
1900 * instead of buffer_dirty. We should not see a dirty bit set
1901 * here because we clear it in do_get_write_access but e.g.
1902 * tune2fs can modify the sb and set the dirty bit at any time
1903 * so we try to gracefully handle that.
1904 */
1905 if (buffer_dirty(bh))
1906 warn_dirty_buffer(bh);
1905 if (test_clear_buffer_dirty(bh) || 1907 if (test_clear_buffer_dirty(bh) ||
1906 test_clear_buffer_jbddirty(bh)) 1908 test_clear_buffer_jbddirty(bh))
1907 was_dirty = 1; 1909 was_dirty = 1;
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index a0244740b75a..b47679be118a 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -270,19 +270,21 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
270 D2({ 270 D2({
271 int i=0; 271 int i=0;
272 struct jffs2_raw_node_ref *this; 272 struct jffs2_raw_node_ref *this;
273 printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n" KERN_DEBUG); 273 printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n");
274 274
275 this = ic->nodes; 275 this = ic->nodes;
276 276
277 printk(KERN_DEBUG);
277 while(this) { 278 while(this) {
278 printk( "0x%08x(%d)->", ref_offset(this), ref_flags(this)); 279 printk(KERN_CONT "0x%08x(%d)->",
280 ref_offset(this), ref_flags(this));
279 if (++i == 5) { 281 if (++i == 5) {
280 printk("\n" KERN_DEBUG); 282 printk(KERN_DEBUG);
281 i=0; 283 i=0;
282 } 284 }
283 this = this->next_in_ino; 285 this = this->next_in_ino;
284 } 286 }
285 printk("\n"); 287 printk(KERN_CONT "\n");
286 }); 288 });
287 289
288 switch (ic->class) { 290 switch (ic->class) {
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 7515e73e2bfb..696686cc206e 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -130,9 +130,9 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
130 if (jffs2_sum_active()) { 130 if (jffs2_sum_active()) {
131 s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL); 131 s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
132 if (!s) { 132 if (!s) {
133 kfree(flashbuf);
134 JFFS2_WARNING("Can't allocate memory for summary\n"); 133 JFFS2_WARNING("Can't allocate memory for summary\n");
135 return -ENOMEM; 134 ret = -ENOMEM;
135 goto out;
136 } 136 }
137 } 137 }
138 138
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 07a22caf2687..0035c021395a 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/smp_lock.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/list.h> 17#include <linux/list.h>
17#include <linux/fs.h> 18#include <linux/fs.h>
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index f2fdcbce143e..4336adba952a 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/smp_lock.h>
10#include <linux/types.h> 11#include <linux/types.h>
11#include <linux/errno.h> 12#include <linux/errno.h>
12#include <linux/fs.h> 13#include <linux/fs.h>
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index 1725037374c5..bd173a6ca3b1 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -10,6 +10,7 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/time.h> 11#include <linux/time.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/smp_lock.h>
13#include <linux/in.h> 14#include <linux/in.h>
14#include <linux/sunrpc/svc.h> 15#include <linux/sunrpc/svc.h>
15#include <linux/sunrpc/clnt.h> 16#include <linux/sunrpc/clnt.h>
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 3688e55901fc..e1d28ddd2169 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -10,6 +10,7 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/time.h> 11#include <linux/time.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/smp_lock.h>
13#include <linux/in.h> 14#include <linux/in.h>
14#include <linux/sunrpc/svc.h> 15#include <linux/sunrpc/svc.h>
15#include <linux/sunrpc/clnt.h> 16#include <linux/sunrpc/clnt.h>
diff --git a/fs/namei.c b/fs/namei.c
index 5b961eb71cbf..f3c5b278895a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1761,6 +1761,10 @@ do_last:
1761 goto exit; 1761 goto exit;
1762 } 1762 }
1763 filp = nameidata_to_filp(&nd, open_flag); 1763 filp = nameidata_to_filp(&nd, open_flag);
1764 if (IS_ERR(filp))
1765 ima_counts_put(&nd.path,
1766 acc_mode & (MAY_READ | MAY_WRITE |
1767 MAY_EXEC));
1764 mnt_drop_write(nd.path.mnt); 1768 mnt_drop_write(nd.path.mnt);
1765 if (nd.root.mnt) 1769 if (nd.root.mnt)
1766 path_put(&nd.root); 1770 path_put(&nd.root);
@@ -1817,6 +1821,9 @@ ok:
1817 goto exit; 1821 goto exit;
1818 } 1822 }
1819 filp = nameidata_to_filp(&nd, open_flag); 1823 filp = nameidata_to_filp(&nd, open_flag);
1824 if (IS_ERR(filp))
1825 ima_counts_put(&nd.path,
1826 acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC));
1820 /* 1827 /*
1821 * It is now safe to drop the mnt write 1828 * It is now safe to drop the mnt write
1822 * because the filp has had a write taken 1829 * because the filp has had a write taken
diff --git a/fs/namespace.c b/fs/namespace.c
index 3dc283fd4716..277c28a63ead 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -22,6 +22,7 @@
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/mnt_namespace.h> 23#include <linux/mnt_namespace.h>
24#include <linux/namei.h> 24#include <linux/namei.h>
25#include <linux/nsproxy.h>
25#include <linux/security.h> 26#include <linux/security.h>
26#include <linux/mount.h> 27#include <linux/mount.h>
27#include <linux/ramfs.h> 28#include <linux/ramfs.h>
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index af05b918cb5b..6dd48a4405b4 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -10,6 +10,7 @@
10#include <linux/kthread.h> 10#include <linux/kthread.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/smp_lock.h>
13#include <linux/spinlock.h> 14#include <linux/spinlock.h>
14 15
15#include <linux/nfs4.h> 16#include <linux/nfs4.h>
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 89f98e9a024b..38d42c29fb92 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -29,7 +29,6 @@
29#include <linux/nfs_fs.h> 29#include <linux/nfs_fs.h>
30#include <linux/nfs_mount.h> 30#include <linux/nfs_mount.h>
31#include <linux/pagemap.h> 31#include <linux/pagemap.h>
32#include <linux/smp_lock.h>
33#include <linux/pagevec.h> 32#include <linux/pagevec.h>
34#include <linux/namei.h> 33#include <linux/namei.h>
35#include <linux/mount.h> 34#include <linux/mount.h>
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 0055b813ec2c..05062329b678 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -26,7 +26,6 @@
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/pagemap.h> 28#include <linux/pagemap.h>
29#include <linux/smp_lock.h>
30#include <linux/aio.h> 29#include <linux/aio.h>
31 30
32#include <asm/uaccess.h> 31#include <asm/uaccess.h>
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index 46177cb87064..b35d2a616066 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -30,7 +30,6 @@
30#include <linux/nfs_idmap.h> 30#include <linux/nfs_idmap.h>
31#include <linux/vfs.h> 31#include <linux/vfs.h>
32#include <linux/namei.h> 32#include <linux/namei.h>
33#include <linux/mnt_namespace.h>
34#include <linux/security.h> 33#include <linux/security.h>
35 34
36#include <asm/system.h> 35#include <asm/system.h>
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 64f87194d390..bd7938eda6a8 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -30,7 +30,6 @@
30#include <linux/nfs_mount.h> 30#include <linux/nfs_mount.h>
31#include <linux/nfs4_mount.h> 31#include <linux/nfs4_mount.h>
32#include <linux/lockd/bind.h> 32#include <linux/lockd/bind.h>
33#include <linux/smp_lock.h>
34#include <linux/seq_file.h> 33#include <linux/seq_file.h>
35#include <linux/mount.h> 34#include <linux/mount.h>
36#include <linux/nfs_idmap.h> 35#include <linux/nfs_idmap.h>
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 92ce43517814..ff0c080db59b 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -45,7 +45,6 @@
45#include <linux/nfs4.h> 45#include <linux/nfs4.h>
46#include <linux/nfs_fs.h> 46#include <linux/nfs_fs.h>
47#include <linux/nfs_page.h> 47#include <linux/nfs_page.h>
48#include <linux/smp_lock.h>
49#include <linux/namei.h> 48#include <linux/namei.h>
50#include <linux/mount.h> 49#include <linux/mount.h>
51#include <linux/module.h> 50#include <linux/module.h>
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 96c4ebfa46f4..73ea5e8d66ce 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -18,7 +18,6 @@
18#include <linux/sunrpc/clnt.h> 18#include <linux/sunrpc/clnt.h>
19#include <linux/nfs_fs.h> 19#include <linux/nfs_fs.h>
20#include <linux/nfs_page.h> 20#include <linux/nfs_page.h>
21#include <linux/smp_lock.h>
22 21
23#include <asm/system.h> 22#include <asm/system.h>
24 23
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index ce728829f79a..0a0a2ff767c3 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -202,8 +202,10 @@ static int nfs_set_page_writeback(struct page *page)
202 struct nfs_server *nfss = NFS_SERVER(inode); 202 struct nfs_server *nfss = NFS_SERVER(inode);
203 203
204 if (atomic_long_inc_return(&nfss->writeback) > 204 if (atomic_long_inc_return(&nfss->writeback) >
205 NFS_CONGESTION_ON_THRESH) 205 NFS_CONGESTION_ON_THRESH) {
206 set_bdi_congested(&nfss->backing_dev_info, WRITE); 206 set_bdi_congested(&nfss->backing_dev_info,
207 BLK_RW_ASYNC);
208 }
207 } 209 }
208 return ret; 210 return ret;
209} 211}
@@ -215,7 +217,7 @@ static void nfs_end_page_writeback(struct page *page)
215 217
216 end_page_writeback(page); 218 end_page_writeback(page);
217 if (atomic_long_dec_return(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH) 219 if (atomic_long_dec_return(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH)
218 clear_bdi_congested(&nfss->backing_dev_info, WRITE); 220 clear_bdi_congested(&nfss->backing_dev_info, BLK_RW_ASYNC);
219} 221}
220 222
221/* 223/*
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 1250fb978ac1..6d0847562d87 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -25,7 +25,6 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/inet.h> 26#include <linux/inet.h>
27#include <linux/string.h> 27#include <linux/string.h>
28#include <linux/smp_lock.h>
29#include <linux/ctype.h> 28#include <linux/ctype.h>
30 29
31#include <linux/nfs.h> 30#include <linux/nfs.h>
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index d4c9884cd54b..492c79b7800b 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -18,7 +18,6 @@
18#include <linux/unistd.h> 18#include <linux/unistd.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/smp.h> 20#include <linux/smp.h>
21#include <linux/smp_lock.h>
22#include <linux/freezer.h> 21#include <linux/freezer.h>
23#include <linux/fs_struct.h> 22#include <linux/fs_struct.h>
24#include <linux/kthread.h> 23#include <linux/kthread.h>
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 4145083dcf88..23341c1063bc 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -678,7 +678,6 @@ __be32
678nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, 678nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
679 int access, struct file **filp) 679 int access, struct file **filp)
680{ 680{
681 const struct cred *cred = current_cred();
682 struct dentry *dentry; 681 struct dentry *dentry;
683 struct inode *inode; 682 struct inode *inode;
684 int flags = O_RDONLY|O_LARGEFILE; 683 int flags = O_RDONLY|O_LARGEFILE;
@@ -733,7 +732,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
733 vfs_dq_init(inode); 732 vfs_dq_init(inode);
734 } 733 }
735 *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt), 734 *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt),
736 flags, cred); 735 flags, current_cred());
737 if (IS_ERR(*filp)) 736 if (IS_ERR(*filp))
738 host_err = PTR_ERR(*filp); 737 host_err = PTR_ERR(*filp);
739 else 738 else
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 36df60b6d8a4..99d58a028b94 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -568,6 +568,7 @@ void nilfs_bmap_abort_update_v(struct nilfs_bmap *bmap,
568} 568}
569 569
570static struct lock_class_key nilfs_bmap_dat_lock_key; 570static struct lock_class_key nilfs_bmap_dat_lock_key;
571static struct lock_class_key nilfs_bmap_mdt_lock_key;
571 572
572/** 573/**
573 * nilfs_bmap_read - read a bmap from an inode 574 * nilfs_bmap_read - read a bmap from an inode
@@ -603,7 +604,11 @@ int nilfs_bmap_read(struct nilfs_bmap *bmap, struct nilfs_inode *raw_inode)
603 bmap->b_ptr_type = NILFS_BMAP_PTR_VS; 604 bmap->b_ptr_type = NILFS_BMAP_PTR_VS;
604 bmap->b_last_allocated_key = 0; 605 bmap->b_last_allocated_key = 0;
605 bmap->b_last_allocated_ptr = NILFS_BMAP_INVALID_PTR; 606 bmap->b_last_allocated_ptr = NILFS_BMAP_INVALID_PTR;
607 lockdep_set_class(&bmap->b_sem, &nilfs_bmap_mdt_lock_key);
606 break; 608 break;
609 case NILFS_IFILE_INO:
610 lockdep_set_class(&bmap->b_sem, &nilfs_bmap_mdt_lock_key);
611 /* Fall through */
607 default: 612 default:
608 bmap->b_ptr_type = NILFS_BMAP_PTR_VM; 613 bmap->b_ptr_type = NILFS_BMAP_PTR_VM;
609 bmap->b_last_allocated_key = 0; 614 bmap->b_last_allocated_key = 0;
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index 7d49813f66d6..aec942cf79e3 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -307,7 +307,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
307 ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 0, &cp_bh); 307 ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 0, &cp_bh);
308 if (ret < 0) { 308 if (ret < 0) {
309 if (ret != -ENOENT) 309 if (ret != -ENOENT)
310 goto out_header; 310 break;
311 /* skip hole */ 311 /* skip hole */
312 ret = 0; 312 ret = 0;
313 continue; 313 continue;
@@ -340,7 +340,7 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
340 continue; 340 continue;
341 printk(KERN_ERR "%s: cannot delete block\n", 341 printk(KERN_ERR "%s: cannot delete block\n",
342 __func__); 342 __func__);
343 goto out_header; 343 break;
344 } 344 }
345 } 345 }
346 346
@@ -358,7 +358,6 @@ int nilfs_cpfile_delete_checkpoints(struct inode *cpfile,
358 kunmap_atomic(kaddr, KM_USER0); 358 kunmap_atomic(kaddr, KM_USER0);
359 } 359 }
360 360
361 out_header:
362 brelse(header_bh); 361 brelse(header_bh);
363 362
364 out_sem: 363 out_sem:
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
index 0b2710e2d565..8927ca27e6f7 100644
--- a/fs/nilfs2/dat.c
+++ b/fs/nilfs2/dat.c
@@ -134,15 +134,6 @@ void nilfs_dat_commit_start(struct inode *dat, struct nilfs_palloc_req *req,
134 entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr, 134 entry = nilfs_palloc_block_get_entry(dat, req->pr_entry_nr,
135 req->pr_entry_bh, kaddr); 135 req->pr_entry_bh, kaddr);
136 entry->de_start = cpu_to_le64(nilfs_mdt_cno(dat)); 136 entry->de_start = cpu_to_le64(nilfs_mdt_cno(dat));
137 if (entry->de_blocknr != cpu_to_le64(0) ||
138 entry->de_end != cpu_to_le64(NILFS_CNO_MAX)) {
139 printk(KERN_CRIT
140 "%s: vbn = %llu, start = %llu, end = %llu, pbn = %llu\n",
141 __func__, (unsigned long long)req->pr_entry_nr,
142 (unsigned long long)le64_to_cpu(entry->de_start),
143 (unsigned long long)le64_to_cpu(entry->de_end),
144 (unsigned long long)le64_to_cpu(entry->de_blocknr));
145 }
146 entry->de_blocknr = cpu_to_le64(blocknr); 137 entry->de_blocknr = cpu_to_le64(blocknr);
147 kunmap_atomic(kaddr, KM_USER0); 138 kunmap_atomic(kaddr, KM_USER0);
148 139
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index 54100acc1102..1a4fa04cf071 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -43,7 +43,6 @@
43 */ 43 */
44 44
45#include <linux/pagemap.h> 45#include <linux/pagemap.h>
46#include <linux/smp_lock.h>
47#include "nilfs.h" 46#include "nilfs.h"
48#include "page.h" 47#include "page.h"
49 48
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index aa977549919e..8b5e4778cf28 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1829,26 +1829,13 @@ static int nilfs_segctor_write(struct nilfs_sc_info *sci,
1829 err = nilfs_segbuf_write(segbuf, &wi); 1829 err = nilfs_segbuf_write(segbuf, &wi);
1830 1830
1831 res = nilfs_segbuf_wait(segbuf, &wi); 1831 res = nilfs_segbuf_wait(segbuf, &wi);
1832 err = unlikely(err) ? : res; 1832 err = err ? : res;
1833 if (unlikely(err)) 1833 if (err)
1834 return err; 1834 return err;
1835 } 1835 }
1836 return 0; 1836 return 0;
1837} 1837}
1838 1838
1839static int nilfs_page_has_uncleared_buffer(struct page *page)
1840{
1841 struct buffer_head *head, *bh;
1842
1843 head = bh = page_buffers(page);
1844 do {
1845 if (buffer_dirty(bh) && !list_empty(&bh->b_assoc_buffers))
1846 return 1;
1847 bh = bh->b_this_page;
1848 } while (bh != head);
1849 return 0;
1850}
1851
1852static void __nilfs_end_page_io(struct page *page, int err) 1839static void __nilfs_end_page_io(struct page *page, int err)
1853{ 1840{
1854 if (!err) { 1841 if (!err) {
@@ -1872,12 +1859,11 @@ static void nilfs_end_page_io(struct page *page, int err)
1872 if (!page) 1859 if (!page)
1873 return; 1860 return;
1874 1861
1875 if (buffer_nilfs_node(page_buffers(page)) && 1862 if (buffer_nilfs_node(page_buffers(page)) && !PageWriteback(page))
1876 nilfs_page_has_uncleared_buffer(page)) 1863 /*
1877 /* For b-tree node pages, this function may be called twice 1864 * For b-tree node pages, this function may be called twice
1878 or more because they might be split in a segment. 1865 * or more because they might be split in a segment.
1879 This check assures that cleanup has been done for all 1866 */
1880 buffers in a split btnode page. */
1881 return; 1867 return;
1882 1868
1883 __nilfs_end_page_io(page, err); 1869 __nilfs_end_page_io(page, err);
@@ -1940,7 +1926,7 @@ static void nilfs_segctor_abort_write(struct nilfs_sc_info *sci,
1940 } 1926 }
1941 if (bh->b_page != fs_page) { 1927 if (bh->b_page != fs_page) {
1942 nilfs_end_page_io(fs_page, err); 1928 nilfs_end_page_io(fs_page, err);
1943 if (unlikely(fs_page == failed_page)) 1929 if (fs_page && fs_page == failed_page)
1944 goto done; 1930 goto done;
1945 fs_page = bh->b_page; 1931 fs_page = bh->b_page;
1946 } 1932 }
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index ff231ad23895..ff27a2965844 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -296,12 +296,15 @@ static int inotify_fasync(int fd, struct file *file, int on)
296static int inotify_release(struct inode *ignored, struct file *file) 296static int inotify_release(struct inode *ignored, struct file *file)
297{ 297{
298 struct fsnotify_group *group = file->private_data; 298 struct fsnotify_group *group = file->private_data;
299 struct user_struct *user = group->inotify_data.user;
299 300
300 fsnotify_clear_marks_by_group(group); 301 fsnotify_clear_marks_by_group(group);
301 302
302 /* free this group, matching get was inotify_init->fsnotify_obtain_group */ 303 /* free this group, matching get was inotify_init->fsnotify_obtain_group */
303 fsnotify_put_group(group); 304 fsnotify_put_group(group);
304 305
306 atomic_dec(&user->inotify_devs);
307
305 return 0; 308 return 0;
306} 309}
307 310
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 9fcd36dcc9a0..467b413bec21 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -7,7 +7,6 @@
7 7
8#include <linux/fs.h> 8#include <linux/fs.h>
9#include <linux/mount.h> 9#include <linux/mount.h>
10#include <linux/smp_lock.h>
11 10
12#define MLOG_MASK_PREFIX ML_INODE 11#define MLOG_MASK_PREFIX ML_INODE
13#include <cluster/masklog.h> 12#include <cluster/masklog.h>
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 1a9c7878f864..ea4e6cb29e13 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -436,7 +436,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
436 rcu_assign_pointer(ptbl->part[partno], p); 436 rcu_assign_pointer(ptbl->part[partno], p);
437 437
438 /* suppress uevent if the disk supresses it */ 438 /* suppress uevent if the disk supresses it */
439 if (!dev_get_uevent_suppress(pdev)) 439 if (!dev_get_uevent_suppress(ddev))
440 kobject_uevent(&pdev->kobj, KOBJ_ADD); 440 kobject_uevent(&pdev->kobj, KOBJ_ADD);
441 441
442 return p; 442 return p;
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 607c579e5eca..70f36c043d62 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2042,8 +2042,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
2042 * changes */ 2042 * changes */
2043 invalidate_bdev(sb->s_bdev); 2043 invalidate_bdev(sb->s_bdev);
2044 } 2044 }
2045 mutex_lock(&inode->i_mutex);
2046 mutex_lock(&dqopt->dqonoff_mutex); 2045 mutex_lock(&dqopt->dqonoff_mutex);
2046 mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
2047 if (sb_has_quota_loaded(sb, type)) { 2047 if (sb_has_quota_loaded(sb, type)) {
2048 error = -EBUSY; 2048 error = -EBUSY;
2049 goto out_lock; 2049 goto out_lock;
@@ -2094,7 +2094,6 @@ out_file_init:
2094 dqopt->files[type] = NULL; 2094 dqopt->files[type] = NULL;
2095 iput(inode); 2095 iput(inode);
2096out_lock: 2096out_lock:
2097 mutex_unlock(&dqopt->dqonoff_mutex);
2098 if (oldflags != -1) { 2097 if (oldflags != -1) {
2099 down_write(&dqopt->dqptr_sem); 2098 down_write(&dqopt->dqptr_sem);
2100 /* Set the flags back (in the case of accidental quotaon() 2099 /* Set the flags back (in the case of accidental quotaon()
@@ -2104,6 +2103,7 @@ out_lock:
2104 up_write(&dqopt->dqptr_sem); 2103 up_write(&dqopt->dqptr_sem);
2105 } 2104 }
2106 mutex_unlock(&inode->i_mutex); 2105 mutex_unlock(&inode->i_mutex);
2106 mutex_unlock(&dqopt->dqonoff_mutex);
2107out_fmt: 2107out_fmt:
2108 put_quota_format(fmt); 2108 put_quota_format(fmt);
2109 2109
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 77f5bb746bf0..90622200b39c 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -997,7 +997,7 @@ static int reiserfs_async_progress_wait(struct super_block *s)
997 DEFINE_WAIT(wait); 997 DEFINE_WAIT(wait);
998 struct reiserfs_journal *j = SB_JOURNAL(s); 998 struct reiserfs_journal *j = SB_JOURNAL(s);
999 if (atomic_read(&j->j_async_throttle)) 999 if (atomic_read(&j->j_async_throttle))
1000 congestion_wait(WRITE, HZ / 10); 1000 congestion_wait(BLK_RW_ASYNC, HZ / 10);
1001 return 0; 1001 return 0;
1002} 1002}
1003 1003
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index d3aeb061612b..7adea74d6a8a 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -24,7 +24,6 @@
24#include <linux/exportfs.h> 24#include <linux/exportfs.h>
25#include <linux/quotaops.h> 25#include <linux/quotaops.h>
26#include <linux/vfs.h> 26#include <linux/vfs.h>
27#include <linux/mnt_namespace.h>
28#include <linux/mount.h> 27#include <linux/mount.h>
29#include <linux/namei.h> 28#include <linux/namei.h>
30#include <linux/crc32.h> 29#include <linux/crc32.h>
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index f3d47d856848..6925b835a43b 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -46,7 +46,6 @@
46#include <linux/reiserfs_acl.h> 46#include <linux/reiserfs_acl.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <net/checksum.h> 48#include <net/checksum.h>
49#include <linux/smp_lock.h>
50#include <linux/stat.h> 49#include <linux/stat.h>
51#include <linux/quotaops.h> 50#include <linux/quotaops.h>
52 51
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 3b52770f46ff..cb5fc57e370b 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -30,6 +30,7 @@
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/vfs.h> 31#include <linux/vfs.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/smp_lock.h>
33#include <linux/mutex.h> 34#include <linux/mutex.h>
34#include <linux/pagemap.h> 35#include <linux/pagemap.h>
35#include <linux/init.h> 36#include <linux/init.h>
diff --git a/fs/sync.c b/fs/sync.c
index dd200025af85..3422ba61d86d 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -112,8 +112,13 @@ restart:
112 mutex_unlock(&mutex); 112 mutex_unlock(&mutex);
113} 113}
114 114
115/*
116 * sync everything. Start out by waking pdflush, because that writes back
117 * all queues in parallel.
118 */
115SYSCALL_DEFINE0(sync) 119SYSCALL_DEFINE0(sync)
116{ 120{
121 wakeup_pdflush(0);
117 sync_filesystems(0); 122 sync_filesystems(0);
118 sync_filesystems(1); 123 sync_filesystems(1);
119 if (unlikely(laptop_mode)) 124 if (unlikely(laptop_mode))
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 9345806c8853..2524714bece1 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -171,6 +171,7 @@ static ssize_t write(struct file *file, const char __user *userbuf,
171 if (count > 0) 171 if (count > 0)
172 *off = offs + count; 172 *off = offs + count;
173 173
174 kfree(temp);
174 return count; 175 return count;
175} 176}
176 177
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index bc5857199ec2..762a7d6cec73 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -297,6 +297,7 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer)
297{ 297{
298 struct ubifs_wbuf *wbuf = container_of(timer, struct ubifs_wbuf, timer); 298 struct ubifs_wbuf *wbuf = container_of(timer, struct ubifs_wbuf, timer);
299 299
300 dbg_io("jhead %d", wbuf->jhead);
300 wbuf->need_sync = 1; 301 wbuf->need_sync = 1;
301 wbuf->c->need_wbuf_sync = 1; 302 wbuf->c->need_wbuf_sync = 1;
302 ubifs_wake_up_bgt(wbuf->c); 303 ubifs_wake_up_bgt(wbuf->c);
@@ -311,8 +312,12 @@ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
311{ 312{
312 ubifs_assert(!hrtimer_active(&wbuf->timer)); 313 ubifs_assert(!hrtimer_active(&wbuf->timer));
313 314
314 if (!ktime_to_ns(wbuf->softlimit)) 315 if (wbuf->no_timer)
315 return; 316 return;
317 dbg_io("set timer for jhead %d, %llu-%llu millisecs", wbuf->jhead,
318 div_u64(ktime_to_ns(wbuf->softlimit), USEC_PER_SEC),
319 div_u64(ktime_to_ns(wbuf->softlimit) + wbuf->delta,
320 USEC_PER_SEC));
316 hrtimer_start_range_ns(&wbuf->timer, wbuf->softlimit, wbuf->delta, 321 hrtimer_start_range_ns(&wbuf->timer, wbuf->softlimit, wbuf->delta,
317 HRTIMER_MODE_REL); 322 HRTIMER_MODE_REL);
318} 323}
@@ -323,11 +328,8 @@ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
323 */ 328 */
324static void cancel_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) 329static void cancel_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
325{ 330{
326 /* 331 if (wbuf->no_timer)
327 * If the syncer is waiting for the lock (from the background thread's 332 return;
328 * context) and another task is changing write-buffer then the syncing
329 * should be canceled.
330 */
331 wbuf->need_sync = 0; 333 wbuf->need_sync = 0;
332 hrtimer_cancel(&wbuf->timer); 334 hrtimer_cancel(&wbuf->timer);
333} 335}
@@ -349,8 +351,8 @@ int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf)
349 /* Write-buffer is empty or not seeked */ 351 /* Write-buffer is empty or not seeked */
350 return 0; 352 return 0;
351 353
352 dbg_io("LEB %d:%d, %d bytes", 354 dbg_io("LEB %d:%d, %d bytes, jhead %d",
353 wbuf->lnum, wbuf->offs, wbuf->used); 355 wbuf->lnum, wbuf->offs, wbuf->used, wbuf->jhead);
354 ubifs_assert(!(c->vfs_sb->s_flags & MS_RDONLY)); 356 ubifs_assert(!(c->vfs_sb->s_flags & MS_RDONLY));
355 ubifs_assert(!(wbuf->avail & 7)); 357 ubifs_assert(!(wbuf->avail & 7));
356 ubifs_assert(wbuf->offs + c->min_io_size <= c->leb_size); 358 ubifs_assert(wbuf->offs + c->min_io_size <= c->leb_size);
@@ -390,7 +392,7 @@ int ubifs_wbuf_sync_nolock(struct ubifs_wbuf *wbuf)
390 * @offs: logical eraseblock offset to seek to 392 * @offs: logical eraseblock offset to seek to
391 * @dtype: data type 393 * @dtype: data type
392 * 394 *
393 * This function targets the write buffer to logical eraseblock @lnum:@offs. 395 * This function targets the write-buffer to logical eraseblock @lnum:@offs.
394 * The write-buffer is synchronized if it is not empty. Returns zero in case of 396 * The write-buffer is synchronized if it is not empty. Returns zero in case of
395 * success and a negative error code in case of failure. 397 * success and a negative error code in case of failure.
396 */ 398 */
@@ -399,7 +401,7 @@ int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs,
399{ 401{
400 const struct ubifs_info *c = wbuf->c; 402 const struct ubifs_info *c = wbuf->c;
401 403
402 dbg_io("LEB %d:%d", lnum, offs); 404 dbg_io("LEB %d:%d, jhead %d", lnum, offs, wbuf->jhead);
403 ubifs_assert(lnum >= 0 && lnum < c->leb_cnt); 405 ubifs_assert(lnum >= 0 && lnum < c->leb_cnt);
404 ubifs_assert(offs >= 0 && offs <= c->leb_size); 406 ubifs_assert(offs >= 0 && offs <= c->leb_size);
405 ubifs_assert(offs % c->min_io_size == 0 && !(offs & 7)); 407 ubifs_assert(offs % c->min_io_size == 0 && !(offs & 7));
@@ -506,9 +508,9 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len)
506 struct ubifs_info *c = wbuf->c; 508 struct ubifs_info *c = wbuf->c;
507 int err, written, n, aligned_len = ALIGN(len, 8), offs; 509 int err, written, n, aligned_len = ALIGN(len, 8), offs;
508 510
509 dbg_io("%d bytes (%s) to wbuf at LEB %d:%d", len, 511 dbg_io("%d bytes (%s) to jhead %d wbuf at LEB %d:%d", len,
510 dbg_ntype(((struct ubifs_ch *)buf)->node_type), wbuf->lnum, 512 dbg_ntype(((struct ubifs_ch *)buf)->node_type), wbuf->jhead,
511 wbuf->offs + wbuf->used); 513 wbuf->lnum, wbuf->offs + wbuf->used);
512 ubifs_assert(len > 0 && wbuf->lnum >= 0 && wbuf->lnum < c->leb_cnt); 514 ubifs_assert(len > 0 && wbuf->lnum >= 0 && wbuf->lnum < c->leb_cnt);
513 ubifs_assert(wbuf->offs >= 0 && wbuf->offs % c->min_io_size == 0); 515 ubifs_assert(wbuf->offs >= 0 && wbuf->offs % c->min_io_size == 0);
514 ubifs_assert(!(wbuf->offs & 7) && wbuf->offs <= c->leb_size); 516 ubifs_assert(!(wbuf->offs & 7) && wbuf->offs <= c->leb_size);
@@ -533,8 +535,8 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len)
533 memcpy(wbuf->buf + wbuf->used, buf, len); 535 memcpy(wbuf->buf + wbuf->used, buf, len);
534 536
535 if (aligned_len == wbuf->avail) { 537 if (aligned_len == wbuf->avail) {
536 dbg_io("flush wbuf to LEB %d:%d", wbuf->lnum, 538 dbg_io("flush jhead %d wbuf to LEB %d:%d",
537 wbuf->offs); 539 wbuf->jhead, wbuf->lnum, wbuf->offs);
538 err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, 540 err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf,
539 wbuf->offs, c->min_io_size, 541 wbuf->offs, c->min_io_size,
540 wbuf->dtype); 542 wbuf->dtype);
@@ -562,7 +564,8 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len)
562 * minimal I/O unit. We have to fill and flush write-buffer and switch 564 * minimal I/O unit. We have to fill and flush write-buffer and switch
563 * to the next min. I/O unit. 565 * to the next min. I/O unit.
564 */ 566 */
565 dbg_io("flush wbuf to LEB %d:%d", wbuf->lnum, wbuf->offs); 567 dbg_io("flush jhead %d wbuf to LEB %d:%d",
568 wbuf->jhead, wbuf->lnum, wbuf->offs);
566 memcpy(wbuf->buf + wbuf->used, buf, wbuf->avail); 569 memcpy(wbuf->buf + wbuf->used, buf, wbuf->avail);
567 err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, wbuf->offs, 570 err = ubi_leb_write(c->ubi, wbuf->lnum, wbuf->buf, wbuf->offs,
568 c->min_io_size, wbuf->dtype); 571 c->min_io_size, wbuf->dtype);
@@ -695,7 +698,8 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
695 int err, rlen, overlap; 698 int err, rlen, overlap;
696 struct ubifs_ch *ch = buf; 699 struct ubifs_ch *ch = buf;
697 700
698 dbg_io("LEB %d:%d, %s, length %d", lnum, offs, dbg_ntype(type), len); 701 dbg_io("LEB %d:%d, %s, length %d, jhead %d", lnum, offs,
702 dbg_ntype(type), len, wbuf->jhead);
699 ubifs_assert(wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0); 703 ubifs_assert(wbuf && lnum >= 0 && lnum < c->leb_cnt && offs >= 0);
700 ubifs_assert(!(offs & 7) && offs < c->leb_size); 704 ubifs_assert(!(offs & 7) && offs < c->leb_size);
701 ubifs_assert(type >= 0 && type < UBIFS_NODE_TYPES_CNT); 705 ubifs_assert(type >= 0 && type < UBIFS_NODE_TYPES_CNT);
@@ -819,13 +823,12 @@ out:
819 * @c: UBIFS file-system description object 823 * @c: UBIFS file-system description object
820 * @wbuf: write-buffer to initialize 824 * @wbuf: write-buffer to initialize
821 * 825 *
822 * This function initializes write buffer. Returns zero in case of success 826 * This function initializes write-buffer. Returns zero in case of success
823 * %-ENOMEM in case of failure. 827 * %-ENOMEM in case of failure.
824 */ 828 */
825int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf) 829int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf)
826{ 830{
827 size_t size; 831 size_t size;
828 ktime_t hardlimit;
829 832
830 wbuf->buf = kmalloc(c->min_io_size, GFP_KERNEL); 833 wbuf->buf = kmalloc(c->min_io_size, GFP_KERNEL);
831 if (!wbuf->buf) 834 if (!wbuf->buf)
@@ -851,22 +854,16 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf)
851 854
852 hrtimer_init(&wbuf->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 855 hrtimer_init(&wbuf->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
853 wbuf->timer.function = wbuf_timer_callback_nolock; 856 wbuf->timer.function = wbuf_timer_callback_nolock;
854 /* 857 wbuf->softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0);
855 * Make write-buffer soft limit to be 20% of the hard limit. The 858 wbuf->delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT;
856 * write-buffer timer is allowed to expire any time between the soft 859 wbuf->delta *= 1000000000ULL;
857 * and hard limits. 860 ubifs_assert(wbuf->delta <= ULONG_MAX);
858 */
859 hardlimit = ktime_set(DEFAULT_WBUF_TIMEOUT_SECS, 0);
860 wbuf->delta = (DEFAULT_WBUF_TIMEOUT_SECS * NSEC_PER_SEC) * 2 / 10;
861 wbuf->softlimit = ktime_sub_ns(hardlimit, wbuf->delta);
862 hrtimer_set_expires_range_ns(&wbuf->timer, wbuf->softlimit,
863 wbuf->delta);
864 return 0; 861 return 0;
865} 862}
866 863
867/** 864/**
868 * ubifs_wbuf_add_ino_nolock - add an inode number into the wbuf inode array. 865 * ubifs_wbuf_add_ino_nolock - add an inode number into the wbuf inode array.
869 * @wbuf: the write-buffer whereto add 866 * @wbuf: the write-buffer where to add
870 * @inum: the inode number 867 * @inum: the inode number
871 * 868 *
872 * This function adds an inode number to the inode array of the write-buffer. 869 * This function adds an inode number to the inode array of the write-buffer.
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 6db7a6be6c97..8aacd64957a2 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -25,7 +25,6 @@
25/* This file implements EXT2-compatible extended attribute ioctl() calls */ 25/* This file implements EXT2-compatible extended attribute ioctl() calls */
26 26
27#include <linux/compat.h> 27#include <linux/compat.h>
28#include <linux/smp_lock.h>
29#include <linux/mount.h> 28#include <linux/mount.h>
30#include "ubifs.h" 29#include "ubifs.h"
31 30
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
index 805605250f12..e5f6cf8a1155 100644
--- a/fs/ubifs/recovery.c
+++ b/fs/ubifs/recovery.c
@@ -53,6 +53,25 @@ static int is_empty(void *buf, int len)
53} 53}
54 54
55/** 55/**
56 * first_non_ff - find offset of the first non-0xff byte.
57 * @buf: buffer to search in
58 * @len: length of buffer
59 *
60 * This function returns offset of the first non-0xff byte in @buf or %-1 if
61 * the buffer contains only 0xff bytes.
62 */
63static int first_non_ff(void *buf, int len)
64{
65 uint8_t *p = buf;
66 int i;
67
68 for (i = 0; i < len; i++)
69 if (*p++ != 0xff)
70 return i;
71 return -1;
72}
73
74/**
56 * get_master_node - get the last valid master node allowing for corruption. 75 * get_master_node - get the last valid master node allowing for corruption.
57 * @c: UBIFS file-system description object 76 * @c: UBIFS file-system description object
58 * @lnum: LEB number 77 * @lnum: LEB number
@@ -357,11 +376,7 @@ static int is_last_write(const struct ubifs_info *c, void *buf, int offs)
357 empty_offs = ALIGN(offs + 1, c->min_io_size); 376 empty_offs = ALIGN(offs + 1, c->min_io_size);
358 check_len = c->leb_size - empty_offs; 377 check_len = c->leb_size - empty_offs;
359 p = buf + empty_offs - offs; 378 p = buf + empty_offs - offs;
360 379 return is_empty(p, check_len);
361 for (; check_len > 0; check_len--)
362 if (*p++ != 0xff)
363 return 0;
364 return 1;
365} 380}
366 381
367/** 382/**
@@ -543,8 +558,8 @@ static int drop_incomplete_group(struct ubifs_scan_leb *sleb, int *offs)
543 * 558 *
544 * This function does a scan of a LEB, but caters for errors that might have 559 * This function does a scan of a LEB, but caters for errors that might have
545 * been caused by the unclean unmount from which we are attempting to recover. 560 * been caused by the unclean unmount from which we are attempting to recover.
546 * 561 * Returns %0 in case of success, %-EUCLEAN if an unrecoverable corruption is
547 * This function returns %0 on success and a negative error code on failure. 562 * found, and a negative error code in case of failure.
548 */ 563 */
549struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, 564struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
550 int offs, void *sbuf, int grouped) 565 int offs, void *sbuf, int grouped)
@@ -643,7 +658,8 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
643 goto corrupted; 658 goto corrupted;
644 default: 659 default:
645 dbg_err("unknown"); 660 dbg_err("unknown");
646 goto corrupted; 661 err = -EINVAL;
662 goto error;
647 } 663 }
648 } 664 }
649 665
@@ -652,8 +668,13 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
652 clean_buf(c, &buf, lnum, &offs, &len); 668 clean_buf(c, &buf, lnum, &offs, &len);
653 need_clean = 1; 669 need_clean = 1;
654 } else { 670 } else {
655 ubifs_err("corrupt empty space at LEB %d:%d", 671 int corruption = first_non_ff(buf, len);
656 lnum, offs); 672
673 ubifs_err("corrupt empty space LEB %d:%d, corruption "
674 "starts at %d", lnum, offs, corruption);
675 /* Make sure we dump interesting non-0xFF data */
676 offs = corruption;
677 buf += corruption;
657 goto corrupted; 678 goto corrupted;
658 } 679 }
659 } 680 }
@@ -813,7 +834,7 @@ struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum,
813static int recover_head(const struct ubifs_info *c, int lnum, int offs, 834static int recover_head(const struct ubifs_info *c, int lnum, int offs,
814 void *sbuf) 835 void *sbuf)
815{ 836{
816 int len, err, need_clean = 0; 837 int len, err;
817 838
818 if (c->min_io_size > 1) 839 if (c->min_io_size > 1)
819 len = c->min_io_size; 840 len = c->min_io_size;
@@ -827,19 +848,7 @@ static int recover_head(const struct ubifs_info *c, int lnum, int offs,
827 848
828 /* Read at the head location and check it is empty flash */ 849 /* Read at the head location and check it is empty flash */
829 err = ubi_read(c->ubi, lnum, sbuf, offs, len); 850 err = ubi_read(c->ubi, lnum, sbuf, offs, len);
830 if (err) 851 if (err || !is_empty(sbuf, len)) {
831 need_clean = 1;
832 else {
833 uint8_t *p = sbuf;
834
835 while (len--)
836 if (*p++ != 0xff) {
837 need_clean = 1;
838 break;
839 }
840 }
841
842 if (need_clean) {
843 dbg_rcvry("cleaning head at %d:%d", lnum, offs); 852 dbg_rcvry("cleaning head at %d:%d", lnum, offs);
844 if (offs == 0) 853 if (offs == 0)
845 return ubifs_leb_unmap(c, lnum); 854 return ubifs_leb_unmap(c, lnum);
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 11cc80125a49..2970500f32df 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -837,9 +837,10 @@ static int replay_log_leb(struct ubifs_info *c, int lnum, int offs, void *sbuf)
837 837
838 dbg_mnt("replay log LEB %d:%d", lnum, offs); 838 dbg_mnt("replay log LEB %d:%d", lnum, offs);
839 sleb = ubifs_scan(c, lnum, offs, sbuf); 839 sleb = ubifs_scan(c, lnum, offs, sbuf);
840 if (IS_ERR(sleb)) { 840 if (IS_ERR(sleb) ) {
841 if (c->need_recovery) 841 if (PTR_ERR(sleb) != -EUCLEAN || !c->need_recovery)
842 sleb = ubifs_recover_log_leb(c, lnum, offs, sbuf); 842 return PTR_ERR(sleb);
843 sleb = ubifs_recover_log_leb(c, lnum, offs, sbuf);
843 if (IS_ERR(sleb)) 844 if (IS_ERR(sleb))
844 return PTR_ERR(sleb); 845 return PTR_ERR(sleb);
845 } 846 }
@@ -957,7 +958,7 @@ out:
957 return err; 958 return err;
958 959
959out_dump: 960out_dump:
960 ubifs_err("log error detected while replying the log at LEB %d:%d", 961 ubifs_err("log error detected while replaying the log at LEB %d:%d",
961 lnum, offs + snod->offs); 962 lnum, offs + snod->offs);
962 dbg_dump_node(c, snod->node); 963 dbg_dump_node(c, snod->node);
963 ubifs_scan_destroy(sleb); 964 ubifs_scan_destroy(sleb);
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c
index 0ed82479b44b..892ebfee4fe5 100644
--- a/fs/ubifs/scan.c
+++ b/fs/ubifs/scan.c
@@ -238,12 +238,12 @@ void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs,
238{ 238{
239 int len; 239 int len;
240 240
241 ubifs_err("corrupted data at LEB %d:%d", lnum, offs); 241 ubifs_err("corruption at LEB %d:%d", lnum, offs);
242 if (dbg_failure_mode) 242 if (dbg_failure_mode)
243 return; 243 return;
244 len = c->leb_size - offs; 244 len = c->leb_size - offs;
245 if (len > 4096) 245 if (len > 8192)
246 len = 4096; 246 len = 8192;
247 dbg_err("first %d bytes from LEB %d:%d", len, lnum, offs); 247 dbg_err("first %d bytes from LEB %d:%d", len, lnum, offs);
248 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 4, buf, len, 1); 248 print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 4, buf, len, 1);
249} 249}
@@ -256,7 +256,9 @@ void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs,
256 * @sbuf: scan buffer (must be c->leb_size) 256 * @sbuf: scan buffer (must be c->leb_size)
257 * 257 *
258 * This function scans LEB number @lnum and returns complete information about 258 * This function scans LEB number @lnum and returns complete information about
259 * its contents. Returns an error code in case of failure. 259 * its contents. Returns the scaned information in case of success and,
260 * %-EUCLEAN if the LEB neads recovery, and other negative error codes in case
261 * of failure.
260 */ 262 */
261struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, 263struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum,
262 int offs, void *sbuf) 264 int offs, void *sbuf)
@@ -279,7 +281,6 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum,
279 cond_resched(); 281 cond_resched();
280 282
281 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0); 283 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0);
282
283 if (ret > 0) { 284 if (ret > 0) {
284 /* Padding bytes or a valid padding node */ 285 /* Padding bytes or a valid padding node */
285 offs += ret; 286 offs += ret;
@@ -304,7 +305,8 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum,
304 goto corrupted; 305 goto corrupted;
305 default: 306 default:
306 dbg_err("unknown"); 307 dbg_err("unknown");
307 goto corrupted; 308 err = -EINVAL;
309 goto error;
308 } 310 }
309 311
310 err = ubifs_add_snod(c, sleb, buf, offs); 312 err = ubifs_add_snod(c, sleb, buf, offs);
@@ -317,8 +319,10 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum,
317 len -= node_len; 319 len -= node_len;
318 } 320 }
319 321
320 if (offs % c->min_io_size) 322 if (offs % c->min_io_size) {
321 goto corrupted; 323 ubifs_err("empty space starts at non-aligned offset %d", offs);
324 goto corrupted;;
325 }
322 326
323 ubifs_end_scan(c, sleb, lnum, offs); 327 ubifs_end_scan(c, sleb, lnum, offs);
324 328
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 79fad43f3c57..26d2e0d80465 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -797,7 +797,7 @@ static int alloc_wbufs(struct ubifs_info *c)
797 * does not need to be synchronized by timer. 797 * does not need to be synchronized by timer.
798 */ 798 */
799 c->jheads[GCHD].wbuf.dtype = UBI_LONGTERM; 799 c->jheads[GCHD].wbuf.dtype = UBI_LONGTERM;
800 c->jheads[GCHD].wbuf.softlimit = ktime_set(0, 0); 800 c->jheads[GCHD].wbuf.no_timer = 1;
801 801
802 return 0; 802 return 0;
803} 803}
@@ -986,7 +986,7 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
986 switch (token) { 986 switch (token) {
987 /* 987 /*
988 * %Opt_fast_unmount and %Opt_norm_unmount options are ignored. 988 * %Opt_fast_unmount and %Opt_norm_unmount options are ignored.
989 * We accepte them in order to be backware-compatible. But this 989 * We accept them in order to be backward-compatible. But this
990 * should be removed at some point. 990 * should be removed at some point.
991 */ 991 */
992 case Opt_fast_unmount: 992 case Opt_fast_unmount:
@@ -1287,6 +1287,9 @@ static int mount_ubifs(struct ubifs_info *c)
1287 if (err) 1287 if (err)
1288 goto out_journal; 1288 goto out_journal;
1289 1289
1290 /* Calculate 'min_idx_lebs' after journal replay */
1291 c->min_idx_lebs = ubifs_calc_min_idx_lebs(c);
1292
1290 err = ubifs_mount_orphans(c, c->need_recovery, mounted_read_only); 1293 err = ubifs_mount_orphans(c, c->need_recovery, mounted_read_only);
1291 if (err) 1294 if (err)
1292 goto out_orphans; 1295 goto out_orphans;
@@ -1754,10 +1757,8 @@ static void ubifs_put_super(struct super_block *sb)
1754 1757
1755 /* Synchronize write-buffers */ 1758 /* Synchronize write-buffers */
1756 if (c->jheads) 1759 if (c->jheads)
1757 for (i = 0; i < c->jhead_cnt; i++) { 1760 for (i = 0; i < c->jhead_cnt; i++)
1758 ubifs_wbuf_sync(&c->jheads[i].wbuf); 1761 ubifs_wbuf_sync(&c->jheads[i].wbuf);
1759 hrtimer_cancel(&c->jheads[i].wbuf.timer);
1760 }
1761 1762
1762 /* 1763 /*
1763 * On fatal errors c->ro_media is set to 1, in which case we do 1764 * On fatal errors c->ro_media is set to 1, in which case we do
@@ -1975,7 +1976,8 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
1975 err = bdi_init(&c->bdi); 1976 err = bdi_init(&c->bdi);
1976 if (err) 1977 if (err)
1977 goto out_close; 1978 goto out_close;
1978 err = bdi_register(&c->bdi, NULL, "ubifs"); 1979 err = bdi_register(&c->bdi, NULL, "ubifs_%d_%d",
1980 c->vi.ubi_num, c->vi.vol_id);
1979 if (err) 1981 if (err)
1980 goto out_bdi; 1982 goto out_bdi;
1981 1983
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 1bf01d820066..a29349094422 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -95,8 +95,9 @@
95 */ 95 */
96#define BGT_NAME_PATTERN "ubifs_bgt%d_%d" 96#define BGT_NAME_PATTERN "ubifs_bgt%d_%d"
97 97
98/* Default write-buffer synchronization timeout in seconds */ 98/* Write-buffer synchronization timeout interval in seconds */
99#define DEFAULT_WBUF_TIMEOUT_SECS 5 99#define WBUF_TIMEOUT_SOFTLIMIT 3
100#define WBUF_TIMEOUT_HARDLIMIT 5
100 101
101/* Maximum possible inode number (only 32-bit inodes are supported now) */ 102/* Maximum possible inode number (only 32-bit inodes are supported now) */
102#define MAX_INUM 0xFFFFFFFF 103#define MAX_INUM 0xFFFFFFFF
@@ -654,7 +655,8 @@ typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c,
654 * @delta: hard and soft timeouts delta (the timer expire inteval is @softlimit 655 * @delta: hard and soft timeouts delta (the timer expire inteval is @softlimit
655 * and @softlimit + @delta) 656 * and @softlimit + @delta)
656 * @timer: write-buffer timer 657 * @timer: write-buffer timer
657 * @need_sync: it is set if its timer expired and needs sync 658 * @no_timer: non-zero if this write-buffer does not have a timer
659 * @need_sync: non-zero if the timer expired and the wbuf needs sync'ing
658 * @next_ino: points to the next position of the following inode number 660 * @next_ino: points to the next position of the following inode number
659 * @inodes: stores the inode numbers of the nodes which are in wbuf 661 * @inodes: stores the inode numbers of the nodes which are in wbuf
660 * 662 *
@@ -683,7 +685,8 @@ struct ubifs_wbuf {
683 ktime_t softlimit; 685 ktime_t softlimit;
684 unsigned long long delta; 686 unsigned long long delta;
685 struct hrtimer timer; 687 struct hrtimer timer;
686 int need_sync; 688 unsigned int no_timer:1;
689 unsigned int need_sync:1;
687 int next_ino; 690 int next_ino;
688 ino_t *inodes; 691 ino_t *inodes;
689}; 692};
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index 1cd3b55ee3d2..2d3f90afe5f1 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -53,7 +53,7 @@ kmem_alloc(size_t size, unsigned int __nocast flags)
53 printk(KERN_ERR "XFS: possible memory allocation " 53 printk(KERN_ERR "XFS: possible memory allocation "
54 "deadlock in %s (mode:0x%x)\n", 54 "deadlock in %s (mode:0x%x)\n",
55 __func__, lflags); 55 __func__, lflags);
56 congestion_wait(WRITE, HZ/50); 56 congestion_wait(BLK_RW_ASYNC, HZ/50);
57 } while (1); 57 } while (1);
58} 58}
59 59
@@ -130,7 +130,7 @@ kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags)
130 printk(KERN_ERR "XFS: possible memory allocation " 130 printk(KERN_ERR "XFS: possible memory allocation "
131 "deadlock in %s (mode:0x%x)\n", 131 "deadlock in %s (mode:0x%x)\n",
132 __func__, lflags); 132 __func__, lflags);
133 congestion_wait(WRITE, HZ/50); 133 congestion_wait(BLK_RW_ASYNC, HZ/50);
134 } while (1); 134 } while (1);
135} 135}
136 136
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 1418b916fc27..0c93c7ef3d18 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -412,7 +412,7 @@ _xfs_buf_lookup_pages(
412 412
413 XFS_STATS_INC(xb_page_retries); 413 XFS_STATS_INC(xb_page_retries);
414 xfsbufd_wakeup(0, gfp_mask); 414 xfsbufd_wakeup(0, gfp_mask);
415 congestion_wait(WRITE, HZ/50); 415 congestion_wait(BLK_RW_ASYNC, HZ/50);
416 goto retry; 416 goto retry;
417 } 417 }
418 418
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index f4e255441574..0542fd507649 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -41,7 +41,6 @@
41#include "xfs_ioctl.h" 41#include "xfs_ioctl.h"
42 42
43#include <linux/dcache.h> 43#include <linux/dcache.h>
44#include <linux/smp_lock.h>
45 44
46static struct vm_operations_struct xfs_file_vm_ops; 45static struct vm_operations_struct xfs_file_vm_ops;
47 46
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index d7d50d7ee51e..aa00800adacc 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -97,4 +97,8 @@ extern void setup_per_cpu_areas(void);
97#define PER_CPU_ATTRIBUTES 97#define PER_CPU_ATTRIBUTES
98#endif 98#endif
99 99
100#ifndef PER_CPU_DEF_ATTRIBUTES
101#define PER_CPU_DEF_ATTRIBUTES
102#endif
103
100#endif /* _ASM_GENERIC_PERCPU_H_ */ 104#endif /* _ASM_GENERIC_PERCPU_H_ */
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 92b73b6140ff..a553f1041cf1 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -191,7 +191,7 @@
191 . = ALIGN(align); \ 191 . = ALIGN(align); \
192 *(.data.cacheline_aligned) 192 *(.data.cacheline_aligned)
193 193
194#define INIT_TASK(align) \ 194#define INIT_TASK_DATA(align) \
195 . = ALIGN(align); \ 195 . = ALIGN(align); \
196 *(.data.init_task) 196 *(.data.init_task)
197 197
@@ -434,14 +434,15 @@
434/* 434/*
435 * Init task 435 * Init task
436 */ 436 */
437#define INIT_TASK_DATA(align) \ 437#define INIT_TASK_DATA_SECTION(align) \
438 . = ALIGN(align); \ 438 . = ALIGN(align); \
439 .data.init_task : { \ 439 .data.init_task : { \
440 INIT_TASK \ 440 INIT_TASK_DATA(align) \
441 } 441 }
442 442
443#ifdef CONFIG_CONSTRUCTORS 443#ifdef CONFIG_CONSTRUCTORS
444#define KERNEL_CTORS() VMLINUX_SYMBOL(__ctors_start) = .; \ 444#define KERNEL_CTORS() . = ALIGN(8); \
445 VMLINUX_SYMBOL(__ctors_start) = .; \
445 *(.ctors) \ 446 *(.ctors) \
446 VMLINUX_SYMBOL(__ctors_end) = .; 447 VMLINUX_SYMBOL(__ctors_end) = .;
447#else 448#else
@@ -704,15 +705,15 @@
704 * matches the requirment of PAGE_ALIGNED_DATA. 705 * matches the requirment of PAGE_ALIGNED_DATA.
705 * 706 *
706 * use 0 as page_align if page_aligned data is not used */ 707 * use 0 as page_align if page_aligned data is not used */
707#define RW_DATA_SECTION(cacheline, nosave, pagealigned, inittask) \ 708#define RW_DATA_SECTION(cacheline, pagealigned, inittask) \
708 . = ALIGN(PAGE_SIZE); \ 709 . = ALIGN(PAGE_SIZE); \
709 .data : AT(ADDR(.data) - LOAD_OFFSET) { \ 710 .data : AT(ADDR(.data) - LOAD_OFFSET) { \
710 INIT_TASK(inittask) \ 711 INIT_TASK_DATA(inittask) \
711 CACHELINE_ALIGNED_DATA(cacheline) \ 712 CACHELINE_ALIGNED_DATA(cacheline) \
712 READ_MOSTLY_DATA(cacheline) \ 713 READ_MOSTLY_DATA(cacheline) \
713 DATA_DATA \ 714 DATA_DATA \
714 CONSTRUCTORS \ 715 CONSTRUCTORS \
715 NOSAVE_DATA(nosave) \ 716 NOSAVE_DATA \
716 PAGE_ALIGNED_DATA(pagealigned) \ 717 PAGE_ALIGNED_DATA(pagealigned) \
717 } 718 }
718 719
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index c263e4d71754..7d6c9a2dfcbb 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -35,11 +35,11 @@ struct est_timings {
35} __attribute__((packed)); 35} __attribute__((packed));
36 36
37/* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */ 37/* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
38#define EDID_TIMING_ASPECT_SHIFT 0 38#define EDID_TIMING_ASPECT_SHIFT 6
39#define EDID_TIMING_ASPECT_MASK (0x3 << EDID_TIMING_ASPECT_SHIFT) 39#define EDID_TIMING_ASPECT_MASK (0x3 << EDID_TIMING_ASPECT_SHIFT)
40 40
41/* need to add 60 */ 41/* need to add 60 */
42#define EDID_TIMING_VFREQ_SHIFT 2 42#define EDID_TIMING_VFREQ_SHIFT 0
43#define EDID_TIMING_VFREQ_MASK (0x3f << EDID_TIMING_VFREQ_SHIFT) 43#define EDID_TIMING_VFREQ_MASK (0x3f << EDID_TIMING_VFREQ_SHIFT)
44 44
45struct std_timing { 45struct std_timing {
@@ -47,11 +47,11 @@ struct std_timing {
47 u8 vfreq_aspect; 47 u8 vfreq_aspect;
48} __attribute__((packed)); 48} __attribute__((packed));
49 49
50#define DRM_EDID_PT_HSYNC_POSITIVE (1 << 6) 50#define DRM_EDID_PT_HSYNC_POSITIVE (1 << 1)
51#define DRM_EDID_PT_VSYNC_POSITIVE (1 << 5) 51#define DRM_EDID_PT_VSYNC_POSITIVE (1 << 2)
52#define DRM_EDID_PT_SEPARATE_SYNC (3 << 3) 52#define DRM_EDID_PT_SEPARATE_SYNC (3 << 3)
53#define DRM_EDID_PT_STEREO (1 << 2) 53#define DRM_EDID_PT_STEREO (1 << 5)
54#define DRM_EDID_PT_INTERLACED (1 << 1) 54#define DRM_EDID_PT_INTERLACED (1 << 7)
55 55
56/* If detailed data is pixel timing */ 56/* If detailed data is pixel timing */
57struct detailed_pixel_timing { 57struct detailed_pixel_timing {
@@ -93,7 +93,7 @@ struct detailed_data_monitor_range {
93} __attribute__((packed)); 93} __attribute__((packed));
94 94
95struct detailed_data_wpindex { 95struct detailed_data_wpindex {
96 u8 white_xy_lo; /* Upper 2 bits each */ 96 u8 white_yx_lo; /* Lower 2 bits each */
97 u8 white_x_hi; 97 u8 white_x_hi;
98 u8 white_y_hi; 98 u8 white_y_hi;
99 u8 gamma; /* need to divide by 100 then add 1 */ 99 u8 gamma; /* need to divide by 100 then add 1 */
@@ -135,21 +135,21 @@ struct detailed_timing {
135 } data; 135 } data;
136} __attribute__((packed)); 136} __attribute__((packed));
137 137
138#define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 7) 138#define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 0)
139#define DRM_EDID_INPUT_SYNC_ON_GREEN (1 << 5) 139#define DRM_EDID_INPUT_SYNC_ON_GREEN (1 << 1)
140#define DRM_EDID_INPUT_COMPOSITE_SYNC (1 << 4) 140#define DRM_EDID_INPUT_COMPOSITE_SYNC (1 << 2)
141#define DRM_EDID_INPUT_SEPARATE_SYNCS (1 << 3) 141#define DRM_EDID_INPUT_SEPARATE_SYNCS (1 << 3)
142#define DRM_EDID_INPUT_BLANK_TO_BLACK (1 << 2) 142#define DRM_EDID_INPUT_BLANK_TO_BLACK (1 << 4)
143#define DRM_EDID_INPUT_VIDEO_LEVEL (3 << 1) 143#define DRM_EDID_INPUT_VIDEO_LEVEL (3 << 5)
144#define DRM_EDID_INPUT_DIGITAL (1 << 0) /* bits above must be zero if set */ 144#define DRM_EDID_INPUT_DIGITAL (1 << 7) /* bits below must be zero if set */
145 145
146#define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 7) 146#define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 0)
147#define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 6) 147#define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 1)
148#define DRM_EDID_FEATURE_STANDARD_COLOR (1 << 5) 148#define DRM_EDID_FEATURE_STANDARD_COLOR (1 << 2)
149#define DRM_EDID_FEATURE_DISPLAY_TYPE (3 << 3) /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */ 149#define DRM_EDID_FEATURE_DISPLAY_TYPE (3 << 3) /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
150#define DRM_EDID_FEATURE_PM_ACTIVE_OFF (1 << 2) 150#define DRM_EDID_FEATURE_PM_ACTIVE_OFF (1 << 5)
151#define DRM_EDID_FEATURE_PM_SUSPEND (1 << 1) 151#define DRM_EDID_FEATURE_PM_SUSPEND (1 << 6)
152#define DRM_EDID_FEATURE_PM_STANDBY (1 << 0) 152#define DRM_EDID_FEATURE_PM_STANDBY (1 << 7)
153 153
154struct edid { 154struct edid {
155 u8 header[8]; 155 u8 header[8];
diff --git a/include/linux/aio.h b/include/linux/aio.h
index b16a957030f8..47f7d932a01d 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -121,9 +121,9 @@ struct kiocb {
121 121
122 /* 122 /*
123 * If the aio_resfd field of the userspace iocb is not zero, 123 * If the aio_resfd field of the userspace iocb is not zero,
124 * this is the underlying file* to deliver event to. 124 * this is the underlying eventfd context to deliver events to.
125 */ 125 */
126 struct file *ki_eventfd; 126 struct eventfd_ctx *ki_eventfd;
127}; 127};
128 128
129#define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY) 129#define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY)
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 0ec2c594868e..1d52425a6118 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -229,9 +229,14 @@ static inline int bdi_rw_congested(struct backing_dev_info *bdi)
229 (1 << BDI_async_congested)); 229 (1 << BDI_async_congested));
230} 230}
231 231
232void clear_bdi_congested(struct backing_dev_info *bdi, int rw); 232enum {
233void set_bdi_congested(struct backing_dev_info *bdi, int rw); 233 BLK_RW_ASYNC = 0,
234long congestion_wait(int rw, long timeout); 234 BLK_RW_SYNC = 1,
235};
236
237void clear_bdi_congested(struct backing_dev_info *bdi, int sync);
238void set_bdi_congested(struct backing_dev_info *bdi, int sync);
239long congestion_wait(int sync, long timeout);
235 240
236 241
237static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi) 242static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi)
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 2a04eb54c0dd..2892b710771c 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -319,7 +319,6 @@ static inline int bio_has_allocated_vec(struct bio *bio)
319 */ 319 */
320struct bio_integrity_payload { 320struct bio_integrity_payload {
321 struct bio *bip_bio; /* parent bio */ 321 struct bio *bip_bio; /* parent bio */
322 struct bio_vec *bip_vec; /* integrity data vector */
323 322
324 sector_t bip_sector; /* virtual start sector */ 323 sector_t bip_sector; /* virtual start sector */
325 324
@@ -328,11 +327,12 @@ struct bio_integrity_payload {
328 327
329 unsigned int bip_size; 328 unsigned int bip_size;
330 329
331 unsigned short bip_pool; /* pool the ivec came from */ 330 unsigned short bip_slab; /* slab the bip came from */
332 unsigned short bip_vcnt; /* # of integrity bio_vecs */ 331 unsigned short bip_vcnt; /* # of integrity bio_vecs */
333 unsigned short bip_idx; /* current bip_vec index */ 332 unsigned short bip_idx; /* current bip_vec index */
334 333
335 struct work_struct bip_work; /* I/O completion */ 334 struct work_struct bip_work; /* I/O completion */
335 struct bio_vec bip_vec[0]; /* embedded bvec array */
336}; 336};
337#endif /* CONFIG_BLK_DEV_INTEGRITY */ 337#endif /* CONFIG_BLK_DEV_INTEGRITY */
338 338
@@ -430,6 +430,9 @@ struct bio_set {
430 unsigned int front_pad; 430 unsigned int front_pad;
431 431
432 mempool_t *bio_pool; 432 mempool_t *bio_pool;
433#if defined(CONFIG_BLK_DEV_INTEGRITY)
434 mempool_t *bio_integrity_pool;
435#endif
433 mempool_t *bvec_pool; 436 mempool_t *bvec_pool;
434}; 437};
435 438
@@ -634,8 +637,9 @@ static inline struct bio *bio_list_get(struct bio_list *bl)
634 637
635#define bio_integrity(bio) (bio->bi_integrity != NULL) 638#define bio_integrity(bio) (bio->bi_integrity != NULL)
636 639
640extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *);
637extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); 641extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
638extern void bio_integrity_free(struct bio *); 642extern void bio_integrity_free(struct bio *, struct bio_set *);
639extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); 643extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
640extern int bio_integrity_enabled(struct bio *bio); 644extern int bio_integrity_enabled(struct bio *bio);
641extern int bio_integrity_set_tag(struct bio *, void *, unsigned int); 645extern int bio_integrity_set_tag(struct bio *, void *, unsigned int);
@@ -645,21 +649,27 @@ extern void bio_integrity_endio(struct bio *, int);
645extern void bio_integrity_advance(struct bio *, unsigned int); 649extern void bio_integrity_advance(struct bio *, unsigned int);
646extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); 650extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int);
647extern void bio_integrity_split(struct bio *, struct bio_pair *, int); 651extern void bio_integrity_split(struct bio *, struct bio_pair *, int);
648extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t); 652extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t, struct bio_set *);
653extern int bioset_integrity_create(struct bio_set *, int);
654extern void bioset_integrity_free(struct bio_set *);
655extern void bio_integrity_init(void);
649 656
650#else /* CONFIG_BLK_DEV_INTEGRITY */ 657#else /* CONFIG_BLK_DEV_INTEGRITY */
651 658
652#define bio_integrity(a) (0) 659#define bio_integrity(a) (0)
660#define bioset_integrity_create(a, b) (0)
653#define bio_integrity_prep(a) (0) 661#define bio_integrity_prep(a) (0)
654#define bio_integrity_enabled(a) (0) 662#define bio_integrity_enabled(a) (0)
655#define bio_integrity_clone(a, b, c) (0) 663#define bio_integrity_clone(a, b, c, d) (0)
656#define bio_integrity_free(a) do { } while (0) 664#define bioset_integrity_free(a) do { } while (0)
665#define bio_integrity_free(a, b) do { } while (0)
657#define bio_integrity_endio(a, b) do { } while (0) 666#define bio_integrity_endio(a, b) do { } while (0)
658#define bio_integrity_advance(a, b) do { } while (0) 667#define bio_integrity_advance(a, b) do { } while (0)
659#define bio_integrity_trim(a, b, c) do { } while (0) 668#define bio_integrity_trim(a, b, c) do { } while (0)
660#define bio_integrity_split(a, b, c) do { } while (0) 669#define bio_integrity_split(a, b, c) do { } while (0)
661#define bio_integrity_set_tag(a, b, c) do { } while (0) 670#define bio_integrity_set_tag(a, b, c) do { } while (0)
662#define bio_integrity_get_tag(a, b, c) do { } while (0) 671#define bio_integrity_get_tag(a, b, c) do { } while (0)
672#define bio_integrity_init(a) do { } while (0)
663 673
664#endif /* CONFIG_BLK_DEV_INTEGRITY */ 674#endif /* CONFIG_BLK_DEV_INTEGRITY */
665 675
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 8963d9149b5f..e7cb5dbf6c26 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -70,11 +70,6 @@ enum rq_cmd_type_bits {
70 REQ_TYPE_ATA_PC, 70 REQ_TYPE_ATA_PC,
71}; 71};
72 72
73enum {
74 BLK_RW_ASYNC = 0,
75 BLK_RW_SYNC = 1,
76};
77
78/* 73/*
79 * For request of type REQ_TYPE_LINUX_BLOCK, rq->cmd[0] is the opcode being 74 * For request of type REQ_TYPE_LINUX_BLOCK, rq->cmd[0] is the opcode being
80 * sent down (similar to how REQ_TYPE_BLOCK_PC means that ->cmd[] holds a 75 * sent down (similar to how REQ_TYPE_BLOCK_PC means that ->cmd[] holds a
@@ -301,12 +296,6 @@ struct blk_queue_tag {
301#define BLK_SCSI_MAX_CMDS (256) 296#define BLK_SCSI_MAX_CMDS (256)
302#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) 297#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
303 298
304struct blk_cmd_filter {
305 unsigned long read_ok[BLK_SCSI_CMD_PER_LONG];
306 unsigned long write_ok[BLK_SCSI_CMD_PER_LONG];
307 struct kobject kobj;
308};
309
310struct queue_limits { 299struct queue_limits {
311 unsigned long bounce_pfn; 300 unsigned long bounce_pfn;
312 unsigned long seg_boundary_mask; 301 unsigned long seg_boundary_mask;
@@ -445,7 +434,6 @@ struct request_queue
445#if defined(CONFIG_BLK_DEV_BSG) 434#if defined(CONFIG_BLK_DEV_BSG)
446 struct bsg_class_device bsg_dev; 435 struct bsg_class_device bsg_dev;
447#endif 436#endif
448 struct blk_cmd_filter cmd_filter;
449}; 437};
450 438
451#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ 439#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */
@@ -730,6 +718,7 @@ struct rq_map_data {
730 int nr_entries; 718 int nr_entries;
731 unsigned long offset; 719 unsigned long offset;
732 int null_mapped; 720 int null_mapped;
721 int from_user;
733}; 722};
734 723
735struct req_iterator { 724struct req_iterator {
@@ -786,18 +775,18 @@ extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
786 * congested queues, and wake up anyone who was waiting for requests to be 775 * congested queues, and wake up anyone who was waiting for requests to be
787 * put back. 776 * put back.
788 */ 777 */
789static inline void blk_clear_queue_congested(struct request_queue *q, int rw) 778static inline void blk_clear_queue_congested(struct request_queue *q, int sync)
790{ 779{
791 clear_bdi_congested(&q->backing_dev_info, rw); 780 clear_bdi_congested(&q->backing_dev_info, sync);
792} 781}
793 782
794/* 783/*
795 * A queue has just entered congestion. Flag that in the queue's VM-visible 784 * A queue has just entered congestion. Flag that in the queue's VM-visible
796 * state flags and increment the global gounter of congested queues. 785 * state flags and increment the global gounter of congested queues.
797 */ 786 */
798static inline void blk_set_queue_congested(struct request_queue *q, int rw) 787static inline void blk_set_queue_congested(struct request_queue *q, int sync)
799{ 788{
800 set_bdi_congested(&q->backing_dev_info, rw); 789 set_bdi_congested(&q->backing_dev_info, sync);
801} 790}
802 791
803extern void blk_start_queue(struct request_queue *q); 792extern void blk_start_queue(struct request_queue *q);
@@ -998,13 +987,7 @@ static inline int sb_issue_discard(struct super_block *sb,
998 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL); 987 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL);
999} 988}
1000 989
1001/* 990extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm);
1002* command filter functions
1003*/
1004extern int blk_verify_command(struct blk_cmd_filter *filter,
1005 unsigned char *cmd, fmode_t has_write_perm);
1006extern void blk_unregister_filter(struct gendisk *disk);
1007extern void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter);
1008 991
1009#define MAX_PHYS_SEGMENTS 128 992#define MAX_PHYS_SEGMENTS 128
1010#define MAX_HW_SEGMENTS 128 993#define MAX_HW_SEGMENTS 128
diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h
index 2dac064d8359..0026f267da20 100644
--- a/include/linux/crash_dump.h
+++ b/include/linux/crash_dump.h
@@ -3,7 +3,6 @@
3 3
4#ifdef CONFIG_CRASH_DUMP 4#ifdef CONFIG_CRASH_DUMP
5#include <linux/kexec.h> 5#include <linux/kexec.h>
6#include <linux/smp_lock.h>
7#include <linux/device.h> 6#include <linux/device.h>
8#include <linux/proc_fs.h> 7#include <linux/proc_fs.h>
9 8
diff --git a/include/linux/device.h b/include/linux/device.h
index ed4e39f2c423..aebb81036db2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -25,8 +25,6 @@
25#include <asm/atomic.h> 25#include <asm/atomic.h>
26#include <asm/device.h> 26#include <asm/device.h>
27 27
28#define BUS_ID_SIZE 20
29
30struct device; 28struct device;
31struct device_private; 29struct device_private;
32struct device_driver; 30struct device_driver;
diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h
index 7605c5e9589f..00d6a68d0421 100644
--- a/include/linux/elfcore.h
+++ b/include/linux/elfcore.h
@@ -122,9 +122,10 @@ static inline void elf_core_copy_kernel_regs(elf_gregset_t *elfregs, struct pt_r
122 122
123static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) 123static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
124{ 124{
125#ifdef ELF_CORE_COPY_TASK_REGS 125#if defined (ELF_CORE_COPY_TASK_REGS)
126
127 return ELF_CORE_COPY_TASK_REGS(t, elfregs); 126 return ELF_CORE_COPY_TASK_REGS(t, elfregs);
127#elif defined (task_pt_regs)
128 elf_core_copy_regs(elfregs, task_pt_regs(t));
128#endif 129#endif
129 return 0; 130 return 0;
130} 131}
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h
index f45a8ae5f828..3b85ba6479f4 100644
--- a/include/linux/eventfd.h
+++ b/include/linux/eventfd.h
@@ -8,10 +8,8 @@
8#ifndef _LINUX_EVENTFD_H 8#ifndef _LINUX_EVENTFD_H
9#define _LINUX_EVENTFD_H 9#define _LINUX_EVENTFD_H
10 10
11#ifdef CONFIG_EVENTFD
12
13/* For O_CLOEXEC and O_NONBLOCK */
14#include <linux/fcntl.h> 11#include <linux/fcntl.h>
12#include <linux/file.h>
15 13
16/* 14/*
17 * CAREFUL: Check include/asm-generic/fcntl.h when defining 15 * CAREFUL: Check include/asm-generic/fcntl.h when defining
@@ -27,16 +25,37 @@
27#define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK) 25#define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
28#define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE) 26#define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)
29 27
28#ifdef CONFIG_EVENTFD
29
30struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx);
31void eventfd_ctx_put(struct eventfd_ctx *ctx);
30struct file *eventfd_fget(int fd); 32struct file *eventfd_fget(int fd);
31int eventfd_signal(struct file *file, int n); 33struct eventfd_ctx *eventfd_ctx_fdget(int fd);
34struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
35int eventfd_signal(struct eventfd_ctx *ctx, int n);
32 36
33#else /* CONFIG_EVENTFD */ 37#else /* CONFIG_EVENTFD */
34 38
35#define eventfd_fget(fd) ERR_PTR(-ENOSYS) 39/*
36static inline int eventfd_signal(struct file *file, int n) 40 * Ugly ugly ugly error layer to support modules that uses eventfd but
37{ return 0; } 41 * pretend to work in !CONFIG_EVENTFD configurations. Namely, AIO.
42 */
43static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd)
44{
45 return ERR_PTR(-ENOSYS);
46}
47
48static inline int eventfd_signal(struct eventfd_ctx *ctx, int n)
49{
50 return -ENOSYS;
51}
52
53static inline void eventfd_ctx_put(struct eventfd_ctx *ctx)
54{
55
56}
38 57
39#endif /* CONFIG_EVENTFD */ 58#endif
40 59
41#endif /* _LINUX_EVENTFD_H */ 60#endif /* _LINUX_EVENTFD_H */
42 61
diff --git a/include/linux/fb.h b/include/linux/fb.h
index dd68358996b7..f847df9e99b6 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -819,6 +819,7 @@ struct fb_info {
819 int node; 819 int node;
820 int flags; 820 int flags;
821 struct mutex lock; /* Lock for open/release/ioctl funcs */ 821 struct mutex lock; /* Lock for open/release/ioctl funcs */
822 struct mutex mm_lock; /* Lock for fb_mmap and smem_* fields */
822 struct fb_var_screeninfo var; /* Current var */ 823 struct fb_var_screeninfo var; /* Current var */
823 struct fb_fix_screeninfo fix; /* Current fix */ 824 struct fb_fix_screeninfo fix; /* Current fix */
824 struct fb_monspecs monspecs; /* Current Monitor specs */ 825 struct fb_monspecs monspecs; /* Current Monitor specs */
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index 9823946adbc5..192d1e43c43c 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -127,6 +127,7 @@ struct fw_card {
127 struct delayed_work work; 127 struct delayed_work work;
128 int bm_retries; 128 int bm_retries;
129 int bm_generation; 129 int bm_generation;
130 __be32 bm_transaction_data[2];
130 131
131 bool broadcast_channel_allocated; 132 bool broadcast_channel_allocated;
132 u32 broadcast_channel; 133 u32 broadcast_channel;
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 44848aa830dc..6c3de999fb34 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -280,7 +280,7 @@ static inline void __fsnotify_update_dcache_flags(struct dentry *dentry)
280 assert_spin_locked(&dentry->d_lock); 280 assert_spin_locked(&dentry->d_lock);
281 281
282 parent = dentry->d_parent; 282 parent = dentry->d_parent;
283 if (fsnotify_inode_watches_children(parent->d_inode)) 283 if (parent->d_inode && fsnotify_inode_watches_children(parent->d_inode))
284 dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED; 284 dentry->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED;
285 else 285 else
286 dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED; 286 dentry->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED;
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index d41ed593f79f..cf593bf9fd32 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -25,6 +25,11 @@
25 * - add IOCTL message 25 * - add IOCTL message
26 * - add unsolicited notification support 26 * - add unsolicited notification support
27 * - add POLL message and NOTIFY_POLL notification 27 * - add POLL message and NOTIFY_POLL notification
28 *
29 * 7.12
30 * - add umask flag to input argument of open, mknod and mkdir
31 * - add notification messages for invalidation of inodes and
32 * directory entries
28 */ 33 */
29 34
30#ifndef _LINUX_FUSE_H 35#ifndef _LINUX_FUSE_H
@@ -36,7 +41,7 @@
36#define FUSE_KERNEL_VERSION 7 41#define FUSE_KERNEL_VERSION 7
37 42
38/** Minor version number of this interface */ 43/** Minor version number of this interface */
39#define FUSE_KERNEL_MINOR_VERSION 11 44#define FUSE_KERNEL_MINOR_VERSION 12
40 45
41/** The node ID of the root inode */ 46/** The node ID of the root inode */
42#define FUSE_ROOT_ID 1 47#define FUSE_ROOT_ID 1
@@ -112,6 +117,7 @@ struct fuse_file_lock {
112 * INIT request/reply flags 117 * INIT request/reply flags
113 * 118 *
114 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." 119 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
120 * FUSE_DONT_MASK: don't apply umask to file mode on create operations
115 */ 121 */
116#define FUSE_ASYNC_READ (1 << 0) 122#define FUSE_ASYNC_READ (1 << 0)
117#define FUSE_POSIX_LOCKS (1 << 1) 123#define FUSE_POSIX_LOCKS (1 << 1)
@@ -119,6 +125,7 @@ struct fuse_file_lock {
119#define FUSE_ATOMIC_O_TRUNC (1 << 3) 125#define FUSE_ATOMIC_O_TRUNC (1 << 3)
120#define FUSE_EXPORT_SUPPORT (1 << 4) 126#define FUSE_EXPORT_SUPPORT (1 << 4)
121#define FUSE_BIG_WRITES (1 << 5) 127#define FUSE_BIG_WRITES (1 << 5)
128#define FUSE_DONT_MASK (1 << 6)
122 129
123/** 130/**
124 * CUSE INIT request/reply flags 131 * CUSE INIT request/reply flags
@@ -224,6 +231,8 @@ enum fuse_opcode {
224 231
225enum fuse_notify_code { 232enum fuse_notify_code {
226 FUSE_NOTIFY_POLL = 1, 233 FUSE_NOTIFY_POLL = 1,
234 FUSE_NOTIFY_INVAL_INODE = 2,
235 FUSE_NOTIFY_INVAL_ENTRY = 3,
227 FUSE_NOTIFY_CODE_MAX, 236 FUSE_NOTIFY_CODE_MAX,
228}; 237};
229 238
@@ -262,14 +271,18 @@ struct fuse_attr_out {
262 struct fuse_attr attr; 271 struct fuse_attr attr;
263}; 272};
264 273
274#define FUSE_COMPAT_MKNOD_IN_SIZE 8
275
265struct fuse_mknod_in { 276struct fuse_mknod_in {
266 __u32 mode; 277 __u32 mode;
267 __u32 rdev; 278 __u32 rdev;
279 __u32 umask;
280 __u32 padding;
268}; 281};
269 282
270struct fuse_mkdir_in { 283struct fuse_mkdir_in {
271 __u32 mode; 284 __u32 mode;
272 __u32 padding; 285 __u32 umask;
273}; 286};
274 287
275struct fuse_rename_in { 288struct fuse_rename_in {
@@ -301,7 +314,14 @@ struct fuse_setattr_in {
301 314
302struct fuse_open_in { 315struct fuse_open_in {
303 __u32 flags; 316 __u32 flags;
317 __u32 unused;
318};
319
320struct fuse_create_in {
321 __u32 flags;
304 __u32 mode; 322 __u32 mode;
323 __u32 umask;
324 __u32 padding;
305}; 325};
306 326
307struct fuse_open_out { 327struct fuse_open_out {
@@ -508,4 +528,16 @@ struct fuse_dirent {
508#define FUSE_DIRENT_SIZE(d) \ 528#define FUSE_DIRENT_SIZE(d) \
509 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) 529 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
510 530
531struct fuse_notify_inval_inode_out {
532 __u64 ino;
533 __s64 off;
534 __s64 len;
535};
536
537struct fuse_notify_inval_entry_out {
538 __u64 parent;
539 __u32 namelen;
540 __u32 padding;
541};
542
511#endif /* _LINUX_FUSE_H */ 543#endif /* _LINUX_FUSE_H */
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 45257475623c..8246c697863d 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -2,7 +2,9 @@
2#define LINUX_HARDIRQ_H 2#define LINUX_HARDIRQ_H
3 3
4#include <linux/preempt.h> 4#include <linux/preempt.h>
5#ifdef CONFIG_PREEMPT
5#include <linux/smp_lock.h> 6#include <linux/smp_lock.h>
7#endif
6#include <linux/lockdep.h> 8#include <linux/lockdep.h>
7#include <linux/ftrace_irq.h> 9#include <linux/ftrace_irq.h>
8#include <asm/hardirq.h> 10#include <asm/hardirq.h>
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 7400900de94a..54648e625efd 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -21,6 +21,7 @@
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/wait.h> 22#include <linux/wait.h>
23#include <linux/percpu.h> 23#include <linux/percpu.h>
24#include <linux/timer.h>
24 25
25 26
26struct hrtimer_clock_base; 27struct hrtimer_clock_base;
@@ -447,6 +448,8 @@ extern void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
447 448
448static inline void timer_stats_account_hrtimer(struct hrtimer *timer) 449static inline void timer_stats_account_hrtimer(struct hrtimer *timer)
449{ 450{
451 if (likely(!timer->start_pid))
452 return;
450 timer_stats_update_stats(timer, timer->start_pid, timer->start_site, 453 timer_stats_update_stats(timer, timer->start_pid, timer->start_site,
451 timer->function, timer->start_comm, 0); 454 timer->function, timer->start_comm, 0);
452} 455}
@@ -456,6 +459,8 @@ extern void __timer_stats_hrtimer_set_start_info(struct hrtimer *timer,
456 459
457static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer) 460static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer)
458{ 461{
462 if (likely(!timer_stats_active))
463 return;
459 __timer_stats_hrtimer_set_start_info(timer, __builtin_return_address(0)); 464 __timer_stats_hrtimer_set_start_info(timer, __builtin_return_address(0));
460} 465}
461 466
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 95c6e00a72e8..edc93a6d931d 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1062,7 +1062,6 @@ int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned l
1062extern int ide_vlb_clk; 1062extern int ide_vlb_clk;
1063extern int ide_pci_clk; 1063extern int ide_pci_clk;
1064 1064
1065unsigned int ide_rq_bytes(struct request *);
1066int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int); 1065int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int);
1067void ide_kill_rq(ide_drive_t *, struct request *); 1066void ide_kill_rq(ide_drive_t *, struct request *);
1068 1067
@@ -1361,7 +1360,6 @@ int ide_in_drive_list(u16 *, const struct drive_list_entry *);
1361#ifdef CONFIG_BLK_DEV_IDEDMA 1360#ifdef CONFIG_BLK_DEV_IDEDMA
1362int ide_dma_good_drive(ide_drive_t *); 1361int ide_dma_good_drive(ide_drive_t *);
1363int __ide_dma_bad_drive(ide_drive_t *); 1362int __ide_dma_bad_drive(ide_drive_t *);
1364int ide_id_dma_bug(ide_drive_t *);
1365 1363
1366u8 ide_find_dma_mode(ide_drive_t *, u8); 1364u8 ide_find_dma_mode(ide_drive_t *, u8);
1367 1365
@@ -1402,7 +1400,6 @@ void ide_dma_lost_irq(ide_drive_t *);
1402ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int); 1400ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int);
1403 1401
1404#else 1402#else
1405static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; }
1406static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } 1403static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; }
1407static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; } 1404static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; }
1408static inline void ide_dma_off_quietly(ide_drive_t *drive) { ; } 1405static inline void ide_dma_off_quietly(ide_drive_t *drive) { ; }
@@ -1422,6 +1419,7 @@ static inline void ide_dma_unmap_sg(ide_drive_t *drive,
1422 1419
1423#ifdef CONFIG_BLK_DEV_IDEACPI 1420#ifdef CONFIG_BLK_DEV_IDEACPI
1424int ide_acpi_init(void); 1421int ide_acpi_init(void);
1422bool ide_port_acpi(ide_hwif_t *hwif);
1425extern int ide_acpi_exec_tfs(ide_drive_t *drive); 1423extern int ide_acpi_exec_tfs(ide_drive_t *drive);
1426extern void ide_acpi_get_timing(ide_hwif_t *hwif); 1424extern void ide_acpi_get_timing(ide_hwif_t *hwif);
1427extern void ide_acpi_push_timing(ide_hwif_t *hwif); 1425extern void ide_acpi_push_timing(ide_hwif_t *hwif);
@@ -1430,6 +1428,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *);
1430extern void ide_acpi_set_state(ide_hwif_t *hwif, int on); 1428extern void ide_acpi_set_state(ide_hwif_t *hwif, int on);
1431#else 1429#else
1432static inline int ide_acpi_init(void) { return 0; } 1430static inline int ide_acpi_init(void) { return 0; }
1431static inline bool ide_port_acpi(ide_hwif_t *hwif) { return 0; }
1433static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; } 1432static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }
1434static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; } 1433static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }
1435static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; } 1434static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index ae3a1871413d..70fdba2bbf71 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -78,6 +78,7 @@
78#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ 78#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
79#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */ 79#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */
80#define ETH_P_TIPC 0x88CA /* TIPC */ 80#define ETH_P_TIPC 0x88CA /* TIPC */
81#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */
81#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */ 82#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */
82#define ETH_P_FIP 0x8914 /* FCoE Initialization Protocol */ 83#define ETH_P_FIP 0x8914 /* FCoE Initialization Protocol */
83#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ 84#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
diff --git a/include/linux/ima.h b/include/linux/ima.h
index b1b827d091a9..0e3f2a4c25f6 100644
--- a/include/linux/ima.h
+++ b/include/linux/ima.h
@@ -24,6 +24,7 @@ extern int ima_path_check(struct path *path, int mask, int update_counts);
24extern void ima_file_free(struct file *file); 24extern void ima_file_free(struct file *file);
25extern int ima_file_mmap(struct file *file, unsigned long prot); 25extern int ima_file_mmap(struct file *file, unsigned long prot);
26extern void ima_counts_get(struct file *file); 26extern void ima_counts_get(struct file *file);
27extern void ima_counts_put(struct path *path, int mask);
27 28
28#else 29#else
29static inline int ima_bprm_check(struct linux_binprm *bprm) 30static inline int ima_bprm_check(struct linux_binprm *bprm)
@@ -60,5 +61,10 @@ static inline void ima_counts_get(struct file *file)
60{ 61{
61 return; 62 return;
62} 63}
64
65static inline void ima_counts_put(struct path *path, int mask)
66{
67 return;
68}
63#endif /* CONFIG_IMA_H */ 69#endif /* CONFIG_IMA_H */
64#endif /* _LINUX_IMA_H */ 70#endif /* _LINUX_IMA_H */
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 5368fbdc7801..7fc01b13be43 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -183,5 +183,8 @@ extern struct cred init_cred;
183 LIST_HEAD_INIT(cpu_timers[2]), \ 183 LIST_HEAD_INIT(cpu_timers[2]), \
184} 184}
185 185
186/* Attach to the init_task data structure for proper alignment */
187#define __init_task_data __attribute__((__section__(".data.init_task")))
188
186 189
187#endif 190#endif
diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
new file mode 100644
index 000000000000..7964516c6954
--- /dev/null
+++ b/include/linux/input/matrix_keypad.h
@@ -0,0 +1,65 @@
1#ifndef _MATRIX_KEYPAD_H
2#define _MATRIX_KEYPAD_H
3
4#include <linux/types.h>
5#include <linux/input.h>
6
7#define MATRIX_MAX_ROWS 16
8#define MATRIX_MAX_COLS 16
9
10#define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
11 (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
12 (val & 0xffff))
13
14#define KEY_ROW(k) (((k) >> 24) & 0xff)
15#define KEY_COL(k) (((k) >> 16) & 0xff)
16#define KEY_VAL(k) ((k) & 0xffff)
17
18/**
19 * struct matrix_keymap_data - keymap for matrix keyboards
20 * @keymap: pointer to array of uint32 values encoded with KEY() macro
21 * representing keymap
22 * @keymap_size: number of entries (initialized) in this keymap
23 * @max_keymap_size: maximum size of keymap supported by the device
24 *
25 * This structure is supposed to be used by platform code to supply
26 * keymaps to drivers that implement matrix-like keypads/keyboards.
27 */
28struct matrix_keymap_data {
29 const uint32_t *keymap;
30 unsigned int keymap_size;
31 unsigned int max_keymap_size;
32};
33
34/**
35 * struct matrix_keypad_platform_data - platform-dependent keypad data
36 * @keymap_data: pointer to &matrix_keymap_data
37 * @row_gpios: array of gpio numbers reporesenting rows
38 * @col_gpios: array of gpio numbers reporesenting colums
39 * @num_row_gpios: actual number of row gpios used by device
40 * @num_col_gpios: actual number of col gpios used by device
41 * @col_scan_delay_us: delay, measured in microseconds, that is
42 * needed before we can keypad after activating column gpio
43 * @debounce_ms: debounce interval in milliseconds
44 *
45 * This structure represents platform-specific data that use used by
46 * matrix_keypad driver to perform proper initialization.
47 */
48struct matrix_keypad_platform_data {
49 const struct matrix_keymap_data *keymap_data;
50
51 unsigned int row_gpios[MATRIX_MAX_ROWS];
52 unsigned int col_gpios[MATRIX_MAX_COLS];
53 unsigned int num_row_gpios;
54 unsigned int num_col_gpios;
55
56 unsigned int col_scan_delay_us;
57
58 /* key debounce interval in milli-second */
59 unsigned int debounce_ms;
60
61 bool active_low;
62 bool wakeup;
63};
64
65#endif /* _MATRIX_KEYPAD_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fac104e7186a..d6320a3e8def 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -303,6 +303,7 @@ extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in
303extern int panic_timeout; 303extern int panic_timeout;
304extern int panic_on_oops; 304extern int panic_on_oops;
305extern int panic_on_unrecovered_nmi; 305extern int panic_on_unrecovered_nmi;
306extern int panic_on_io_nmi;
306extern const char *print_tainted(void); 307extern const char *print_tainted(void);
307extern void add_taint(unsigned flag); 308extern void add_taint(unsigned flag);
308extern int test_taint(unsigned flag); 309extern int test_taint(unsigned flag);
diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
index 7796aed6cdd5..6a63807f714e 100644
--- a/include/linux/kmemleak.h
+++ b/include/linux/kmemleak.h
@@ -27,6 +27,7 @@ extern void kmemleak_init(void);
27extern void kmemleak_alloc(const void *ptr, size_t size, int min_count, 27extern void kmemleak_alloc(const void *ptr, size_t size, int min_count,
28 gfp_t gfp); 28 gfp_t gfp);
29extern void kmemleak_free(const void *ptr); 29extern void kmemleak_free(const void *ptr);
30extern void kmemleak_free_part(const void *ptr, size_t size);
30extern void kmemleak_padding(const void *ptr, unsigned long offset, 31extern void kmemleak_padding(const void *ptr, unsigned long offset,
31 size_t size); 32 size_t size);
32extern void kmemleak_not_leak(const void *ptr); 33extern void kmemleak_not_leak(const void *ptr);
@@ -71,6 +72,9 @@ static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
71static inline void kmemleak_free(const void *ptr) 72static inline void kmemleak_free(const void *ptr)
72{ 73{
73} 74}
75static inline void kmemleak_free_part(const void *ptr, size_t size)
76{
77}
74static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags) 78static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags)
75{ 79{
76} 80}
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index aacc5449f586..16713dc672e4 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -125,6 +125,7 @@ struct kvm_kernel_irq_routing_entry {
125struct kvm { 125struct kvm {
126 struct mutex lock; /* protects the vcpus array and APIC accesses */ 126 struct mutex lock; /* protects the vcpus array and APIC accesses */
127 spinlock_t mmu_lock; 127 spinlock_t mmu_lock;
128 spinlock_t requests_lock;
128 struct rw_semaphore slots_lock; 129 struct rw_semaphore slots_lock;
129 struct mm_struct *mm; /* userspace tied to this vm */ 130 struct mm_struct *mm; /* userspace tied to this vm */
130 int nmemslots; 131 int nmemslots;
diff --git a/include/linux/leds-lp3944.h b/include/linux/leds-lp3944.h
new file mode 100644
index 000000000000..afc9f9fd70f5
--- /dev/null
+++ b/include/linux/leds-lp3944.h
@@ -0,0 +1,53 @@
1/*
2 * leds-lp3944.h - platform data structure for lp3944 led controller
3 *
4 * Copyright (C) 2009 Antonio Ospite <ospite@studenti.unina.it>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#ifndef __LINUX_LEDS_LP3944_H
13#define __LINUX_LEDS_LP3944_H
14
15#include <linux/leds.h>
16#include <linux/workqueue.h>
17
18#define LP3944_LED0 0
19#define LP3944_LED1 1
20#define LP3944_LED2 2
21#define LP3944_LED3 3
22#define LP3944_LED4 4
23#define LP3944_LED5 5
24#define LP3944_LED6 6
25#define LP3944_LED7 7
26#define LP3944_LEDS_MAX 8
27
28#define LP3944_LED_STATUS_MASK 0x03
29enum lp3944_status {
30 LP3944_LED_STATUS_OFF = 0x0,
31 LP3944_LED_STATUS_ON = 0x1,
32 LP3944_LED_STATUS_DIM0 = 0x2,
33 LP3944_LED_STATUS_DIM1 = 0x3
34};
35
36enum lp3944_type {
37 LP3944_LED_TYPE_NONE,
38 LP3944_LED_TYPE_LED,
39 LP3944_LED_TYPE_LED_INVERTED,
40};
41
42struct lp3944_led {
43 char *name;
44 enum lp3944_type type;
45 enum lp3944_status status;
46};
47
48struct lp3944_platform_data {
49 struct lp3944_led leds[LP3944_LEDS_MAX];
50 u8 leds_size;
51};
52
53#endif /* __LINUX_LEDS_LP3944_H */
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 376fe07732ea..d8bf9665e70c 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -45,7 +45,10 @@ struct led_classdev {
45 /* Get LED brightness level */ 45 /* Get LED brightness level */
46 enum led_brightness (*brightness_get)(struct led_classdev *led_cdev); 46 enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
47 47
48 /* Activate hardware accelerated blink */ 48 /* Activate hardware accelerated blink, delays are in
49 * miliseconds and if none is provided then a sensible default
50 * should be chosen. The call can adjust the timings if it can't
51 * match the values specified exactly. */
49 int (*blink_set)(struct led_classdev *led_cdev, 52 int (*blink_set)(struct led_classdev *led_cdev,
50 unsigned long *delay_on, 53 unsigned long *delay_on,
51 unsigned long *delay_off); 54 unsigned long *delay_off);
@@ -141,9 +144,14 @@ struct gpio_led {
141 const char *name; 144 const char *name;
142 const char *default_trigger; 145 const char *default_trigger;
143 unsigned gpio; 146 unsigned gpio;
144 u8 active_low : 1; 147 unsigned active_low : 1;
145 u8 retain_state_suspended : 1; 148 unsigned retain_state_suspended : 1;
149 unsigned default_state : 2;
150 /* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */
146}; 151};
152#define LEDS_GPIO_DEFSTATE_OFF 0
153#define LEDS_GPIO_DEFSTATE_ON 1
154#define LEDS_GPIO_DEFSTATE_KEEP 2
147 155
148struct gpio_led_platform_data { 156struct gpio_led_platform_data {
149 int num_leds; 157 int num_leds;
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index fee9e59649c1..691f59171c6c 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -22,6 +22,15 @@
22#define __page_aligned_bss __section(.bss.page_aligned) __aligned(PAGE_SIZE) 22#define __page_aligned_bss __section(.bss.page_aligned) __aligned(PAGE_SIZE)
23 23
24/* 24/*
25 * For assembly routines.
26 *
27 * Note when using these that you must specify the appropriate
28 * alignment directives yourself
29 */
30#define __PAGE_ALIGNED_DATA .section ".data.page_aligned", "aw"
31#define __PAGE_ALIGNED_BSS .section ".bss.page_aligned", "aw"
32
33/*
25 * This is used by architectures to keep arguments on the stack 34 * This is used by architectures to keep arguments on the stack
26 * untouched by the compiler by keeping them live until the end. 35 * untouched by the compiler by keeping them live until the end.
27 * The argument stack may be owned by the assembly-language 36 * The argument stack may be owned by the assembly-language
diff --git a/include/linux/mm.h b/include/linux/mm.h
index d006e93d5c93..ba3a7cb1eaa0 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -826,7 +826,7 @@ extern int make_pages_present(unsigned long addr, unsigned long end);
826extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write); 826extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
827 827
828int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 828int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
829 unsigned long start, int len, int write, int force, 829 unsigned long start, int nr_pages, int write, int force,
830 struct page **pages, struct vm_area_struct **vmas); 830 struct page **pages, struct vm_area_struct **vmas);
831int get_user_pages_fast(unsigned long start, int nr_pages, int write, 831int get_user_pages_fast(unsigned long start, int nr_pages, int write,
832 struct page **pages); 832 struct page **pages);
diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h
index 3beb2592b03f..d74785c2393a 100644
--- a/include/linux/mnt_namespace.h
+++ b/include/linux/mnt_namespace.h
@@ -2,10 +2,9 @@
2#define _NAMESPACE_H_ 2#define _NAMESPACE_H_
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/mount.h> 5#include <linux/path.h>
6#include <linux/sched.h>
7#include <linux/nsproxy.h>
8#include <linux/seq_file.h> 6#include <linux/seq_file.h>
7#include <linux/wait.h>
9 8
10struct mnt_namespace { 9struct mnt_namespace {
11 atomic_t count; 10 atomic_t count;
@@ -28,14 +27,6 @@ extern struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt);
28extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, 27extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *,
29 struct fs_struct *); 28 struct fs_struct *);
30extern void put_mnt_ns(struct mnt_namespace *ns); 29extern void put_mnt_ns(struct mnt_namespace *ns);
31
32static inline void exit_mnt_ns(struct task_struct *p)
33{
34 struct mnt_namespace *ns = p->nsproxy->mnt_ns;
35 if (ns)
36 put_mnt_ns(ns);
37}
38
39static inline void get_mnt_ns(struct mnt_namespace *ns) 30static inline void get_mnt_ns(struct mnt_namespace *ns)
40{ 31{
41 atomic_inc(&ns->count); 32 atomic_inc(&ns->count);
diff --git a/include/linux/netfilter/xt_conntrack.h b/include/linux/netfilter/xt_conntrack.h
index 3430c7751948..7ae05338e94c 100644
--- a/include/linux/netfilter/xt_conntrack.h
+++ b/include/linux/netfilter/xt_conntrack.h
@@ -81,4 +81,17 @@ struct xt_conntrack_mtinfo1 {
81 __u8 state_mask, status_mask; 81 __u8 state_mask, status_mask;
82}; 82};
83 83
84struct xt_conntrack_mtinfo2 {
85 union nf_inet_addr origsrc_addr, origsrc_mask;
86 union nf_inet_addr origdst_addr, origdst_mask;
87 union nf_inet_addr replsrc_addr, replsrc_mask;
88 union nf_inet_addr repldst_addr, repldst_mask;
89 __u32 expires_min, expires_max;
90 __u16 l4proto;
91 __be16 origsrc_port, origdst_port;
92 __be16 replsrc_port, repldst_port;
93 __u16 match_flags, invert_flags;
94 __u16 state_mask, status_mask;
95};
96
84#endif /*_XT_CONNTRACK_H*/ 97#endif /*_XT_CONNTRACK_H*/
diff --git a/include/linux/netfilter/xt_osf.h b/include/linux/netfilter/xt_osf.h
index fd2272e0959a..18afa495f973 100644
--- a/include/linux/netfilter/xt_osf.h
+++ b/include/linux/netfilter/xt_osf.h
@@ -20,6 +20,8 @@
20#ifndef _XT_OSF_H 20#ifndef _XT_OSF_H
21#define _XT_OSF_H 21#define _XT_OSF_H
22 22
23#include <linux/types.h>
24
23#define MAXGENRELEN 32 25#define MAXGENRELEN 32
24 26
25#define XT_OSF_GENRE (1<<0) 27#define XT_OSF_GENRE (1<<0)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d304ddf412d0..115fb7ba5089 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1145,7 +1145,7 @@ static inline void pci_set_drvdata(struct pci_dev *pdev, void *data)
1145/* If you want to know what to call your pci_dev, ask this function. 1145/* If you want to know what to call your pci_dev, ask this function.
1146 * Again, it's a wrapper around the generic device. 1146 * Again, it's a wrapper around the generic device.
1147 */ 1147 */
1148static inline const char *pci_name(struct pci_dev *pdev) 1148static inline const char *pci_name(const struct pci_dev *pdev)
1149{ 1149{
1150 return dev_name(&pdev->dev); 1150 return dev_name(&pdev->dev);
1151} 1151}
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index a3b000365795..73b46b6b904f 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2645,6 +2645,7 @@
2645#define PCI_DEVICE_ID_NETMOS_9835 0x9835 2645#define PCI_DEVICE_ID_NETMOS_9835 0x9835
2646#define PCI_DEVICE_ID_NETMOS_9845 0x9845 2646#define PCI_DEVICE_ID_NETMOS_9845 0x9845
2647#define PCI_DEVICE_ID_NETMOS_9855 0x9855 2647#define PCI_DEVICE_ID_NETMOS_9855 0x9855
2648#define PCI_DEVICE_ID_NETMOS_9901 0x9901
2648 2649
2649#define PCI_VENDOR_ID_3COM_2 0xa727 2650#define PCI_VENDOR_ID_3COM_2 0xa727
2650 2651
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index 8f921d74f49f..68438e18fff4 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -24,7 +24,8 @@
24 24
25#define DEFINE_PER_CPU_SECTION(type, name, section) \ 25#define DEFINE_PER_CPU_SECTION(type, name, section) \
26 __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ 26 __attribute__((__section__(PER_CPU_BASE_SECTION section))) \
27 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name 27 PER_CPU_ATTRIBUTES PER_CPU_DEF_ATTRIBUTES \
28 __typeof__(type) per_cpu__##name
28 29
29/* 30/*
30 * Variant on the per-CPU variable declaration/definition theme used for 31 * Variant on the per-CPU variable declaration/definition theme used for
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index 89698d8aba5c..5e970c7d3fd5 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -178,8 +178,10 @@ struct perf_counter_attr {
178 mmap : 1, /* include mmap data */ 178 mmap : 1, /* include mmap data */
179 comm : 1, /* include comm data */ 179 comm : 1, /* include comm data */
180 freq : 1, /* use freq, not period */ 180 freq : 1, /* use freq, not period */
181 inherit_stat : 1, /* per task counts */
182 enable_on_exec : 1, /* next exec enables */
181 183
182 __reserved_1 : 53; 184 __reserved_1 : 51;
183 185
184 __u32 wakeup_events; /* wakeup every n events */ 186 __u32 wakeup_events; /* wakeup every n events */
185 __u32 __reserved_2; 187 __u32 __reserved_2;
@@ -232,6 +234,14 @@ struct perf_counter_mmap_page {
232 __u32 lock; /* seqlock for synchronization */ 234 __u32 lock; /* seqlock for synchronization */
233 __u32 index; /* hardware counter identifier */ 235 __u32 index; /* hardware counter identifier */
234 __s64 offset; /* add to hardware counter value */ 236 __s64 offset; /* add to hardware counter value */
237 __u64 time_enabled; /* time counter active */
238 __u64 time_running; /* time counter on cpu */
239
240 /*
241 * Hole for extension of the self monitor capabilities
242 */
243
244 __u64 __reserved[123]; /* align to 1k */
235 245
236 /* 246 /*
237 * Control data for the mmap() data buffer. 247 * Control data for the mmap() data buffer.
@@ -253,7 +263,6 @@ struct perf_counter_mmap_page {
253#define PERF_EVENT_MISC_KERNEL (1 << 0) 263#define PERF_EVENT_MISC_KERNEL (1 << 0)
254#define PERF_EVENT_MISC_USER (2 << 0) 264#define PERF_EVENT_MISC_USER (2 << 0)
255#define PERF_EVENT_MISC_HYPERVISOR (3 << 0) 265#define PERF_EVENT_MISC_HYPERVISOR (3 << 0)
256#define PERF_EVENT_MISC_OVERFLOW (1 << 2)
257 266
258struct perf_event_header { 267struct perf_event_header {
259 __u32 type; 268 __u32 type;
@@ -327,9 +336,18 @@ enum perf_event_type {
327 PERF_EVENT_FORK = 7, 336 PERF_EVENT_FORK = 7,
328 337
329 /* 338 /*
330 * When header.misc & PERF_EVENT_MISC_OVERFLOW the event_type field 339 * struct {
331 * will be PERF_SAMPLE_* 340 * struct perf_event_header header;
332 * 341 * u32 pid, tid;
342 * u64 value;
343 * { u64 time_enabled; } && PERF_FORMAT_ENABLED
344 * { u64 time_running; } && PERF_FORMAT_RUNNING
345 * { u64 parent_id; } && PERF_FORMAT_ID
346 * };
347 */
348 PERF_EVENT_READ = 8,
349
350 /*
333 * struct { 351 * struct {
334 * struct perf_event_header header; 352 * struct perf_event_header header;
335 * 353 *
@@ -337,8 +355,9 @@ enum perf_event_type {
337 * { u32 pid, tid; } && PERF_SAMPLE_TID 355 * { u32 pid, tid; } && PERF_SAMPLE_TID
338 * { u64 time; } && PERF_SAMPLE_TIME 356 * { u64 time; } && PERF_SAMPLE_TIME
339 * { u64 addr; } && PERF_SAMPLE_ADDR 357 * { u64 addr; } && PERF_SAMPLE_ADDR
340 * { u64 config; } && PERF_SAMPLE_CONFIG 358 * { u64 id; } && PERF_SAMPLE_ID
341 * { u32 cpu, res; } && PERF_SAMPLE_CPU 359 * { u32 cpu, res; } && PERF_SAMPLE_CPU
360 * { u64 period; } && PERF_SAMPLE_PERIOD
342 * 361 *
343 * { u64 nr; 362 * { u64 nr;
344 * { u64 id, val; } cnt[nr]; } && PERF_SAMPLE_GROUP 363 * { u64 id, val; } cnt[nr]; } && PERF_SAMPLE_GROUP
@@ -347,6 +366,9 @@ enum perf_event_type {
347 * u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN 366 * u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN
348 * }; 367 * };
349 */ 368 */
369 PERF_EVENT_SAMPLE = 9,
370
371 PERF_EVENT_MAX, /* non-ABI */
350}; 372};
351 373
352enum perf_callchain_context { 374enum perf_callchain_context {
@@ -582,6 +604,7 @@ struct perf_counter_context {
582 int nr_counters; 604 int nr_counters;
583 int nr_active; 605 int nr_active;
584 int is_active; 606 int is_active;
607 int nr_stat;
585 atomic_t refcount; 608 atomic_t refcount;
586 struct task_struct *task; 609 struct task_struct *task;
587 610
@@ -669,7 +692,16 @@ static inline int is_software_counter(struct perf_counter *counter)
669 (counter->attr.type != PERF_TYPE_HW_CACHE); 692 (counter->attr.type != PERF_TYPE_HW_CACHE);
670} 693}
671 694
672extern void perf_swcounter_event(u32, u64, int, struct pt_regs *, u64); 695extern atomic_t perf_swcounter_enabled[PERF_COUNT_SW_MAX];
696
697extern void __perf_swcounter_event(u32, u64, int, struct pt_regs *, u64);
698
699static inline void
700perf_swcounter_event(u32 event, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
701{
702 if (atomic_read(&perf_swcounter_enabled[event]))
703 __perf_swcounter_event(event, nr, nmi, regs, addr);
704}
673 705
674extern void __perf_counter_mmap(struct vm_area_struct *vma); 706extern void __perf_counter_mmap(struct vm_area_struct *vma);
675 707
diff --git a/include/linux/personality.h b/include/linux/personality.h
index a84e9ff9b27e..126120819a0d 100644
--- a/include/linux/personality.h
+++ b/include/linux/personality.h
@@ -40,7 +40,10 @@ enum {
40 * Security-relevant compatibility flags that must be 40 * Security-relevant compatibility flags that must be
41 * cleared upon setuid or setgid exec: 41 * cleared upon setuid or setgid exec:
42 */ 42 */
43#define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC|ADDR_NO_RANDOMIZE) 43#define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
44 ADDR_NO_RANDOMIZE | \
45 ADDR_COMPAT_LAYOUT | \
46 MMAP_PAGE_ZERO)
44 47
45/* 48/*
46 * Personality types. 49 * Personality types.
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 7bc457593684..26361c4c037a 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -7,7 +7,6 @@
7#ifndef _LINUX_QUOTAOPS_ 7#ifndef _LINUX_QUOTAOPS_
8#define _LINUX_QUOTAOPS_ 8#define _LINUX_QUOTAOPS_
9 9
10#include <linux/smp_lock.h>
11#include <linux/fs.h> 10#include <linux/fs.h>
12 11
13static inline struct quota_info *sb_dqopt(struct super_block *sb) 12static inline struct quota_info *sb_dqopt(struct super_block *sb)
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index e73e2429a1b1..2ce29831feb6 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -99,7 +99,6 @@ enum rfkill_user_states {
99#undef RFKILL_STATE_UNBLOCKED 99#undef RFKILL_STATE_UNBLOCKED
100#undef RFKILL_STATE_HARD_BLOCKED 100#undef RFKILL_STATE_HARD_BLOCKED
101 101
102#include <linux/types.h>
103#include <linux/kernel.h> 102#include <linux/kernel.h>
104#include <linux/list.h> 103#include <linux/list.h>
105#include <linux/mutex.h> 104#include <linux/mutex.h>
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4d0754269884..16a982e389fb 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -349,8 +349,20 @@ extern int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner);
349struct nsproxy; 349struct nsproxy;
350struct user_namespace; 350struct user_namespace;
351 351
352/* Maximum number of active map areas.. This is a random (large) number */ 352/*
353#define DEFAULT_MAX_MAP_COUNT 65536 353 * Default maximum number of active map areas, this limits the number of vmas
354 * per mm struct. Users can overwrite this number by sysctl but there is a
355 * problem.
356 *
357 * When a program's coredump is generated as ELF format, a section is created
358 * per a vma. In ELF, the number of sections is represented in unsigned short.
359 * This means the number of sections should be smaller than 65535 at coredump.
360 * Because the kernel adds some informative sections to a image of program at
361 * generating coredump, we need some margin. The number of extra sections is
362 * 1-3 now and depends on arch. We use "5" as safe margin, here.
363 */
364#define MAPCOUNT_ELF_CORE_MARGIN (5)
365#define DEFAULT_MAX_MAP_COUNT (USHORT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
354 366
355extern int sysctl_max_map_count; 367extern int sysctl_max_map_count;
356 368
@@ -486,6 +498,15 @@ struct task_cputime {
486 .sum_exec_runtime = 0, \ 498 .sum_exec_runtime = 0, \
487 } 499 }
488 500
501/*
502 * Disable preemption until the scheduler is running.
503 * Reset by start_kernel()->sched_init()->init_idle().
504 *
505 * We include PREEMPT_ACTIVE to avoid cond_resched() from working
506 * before the scheduler is active -- see should_resched().
507 */
508#define INIT_PREEMPT_COUNT (1 + PREEMPT_ACTIVE)
509
489/** 510/**
490 * struct thread_group_cputimer - thread group interval timer counts 511 * struct thread_group_cputimer - thread group interval timer counts
491 * @cputime: thread group interval timers. 512 * @cputime: thread group interval timers.
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 4dcbc2c71491..c1c862b1d01a 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -11,6 +11,7 @@
11#include <linux/workqueue.h> 11#include <linux/workqueue.h>
12#include <linux/kobject.h> 12#include <linux/kobject.h>
13#include <linux/kmemtrace.h> 13#include <linux/kmemtrace.h>
14#include <linux/kmemleak.h>
14 15
15enum stat_item { 16enum stat_item {
16 ALLOC_FASTPATH, /* Allocation from cpu slab */ 17 ALLOC_FASTPATH, /* Allocation from cpu slab */
@@ -233,6 +234,7 @@ static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
233 unsigned int order = get_order(size); 234 unsigned int order = get_order(size);
234 void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order); 235 void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
235 236
237 kmemleak_alloc(ret, size, 1, flags);
236 trace_kmalloc(_THIS_IP_, ret, size, PAGE_SIZE << order, flags); 238 trace_kmalloc(_THIS_IP_, ret, size, PAGE_SIZE << order, flags);
237 239
238 return ret; 240 return ret;
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 9c4cd27f4685..c47c4b4da97e 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -80,6 +80,8 @@ struct spi_device {
80#define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */ 80#define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */
81#define SPI_3WIRE 0x10 /* SI/SO signals shared */ 81#define SPI_3WIRE 0x10 /* SI/SO signals shared */
82#define SPI_LOOP 0x20 /* loopback mode */ 82#define SPI_LOOP 0x20 /* loopback mode */
83#define SPI_NO_CS 0x40 /* 1 dev/bus, no chipselect */
84#define SPI_READY 0x80 /* slave pulls low to pause */
83 u8 bits_per_word; 85 u8 bits_per_word;
84 int irq; 86 int irq;
85 void *controller_state; 87 void *controller_state;
@@ -248,6 +250,10 @@ struct spi_master {
248 /* spi_device.mode flags understood by this controller driver */ 250 /* spi_device.mode flags understood by this controller driver */
249 u16 mode_bits; 251 u16 mode_bits;
250 252
253 /* other constraints relevant to this driver */
254 u16 flags;
255#define SPI_MASTER_HALF_DUPLEX BIT(0) /* can't do full duplex */
256
251 /* Setup mode and clock, etc (spi driver may call many times). 257 /* Setup mode and clock, etc (spi driver may call many times).
252 * 258 *
253 * IMPORTANT: this may be called when transfers to another 259 * IMPORTANT: this may be called when transfers to another
diff --git a/include/linux/spi/spidev.h b/include/linux/spi/spidev.h
index 95251ccd5a07..bf0570a84f7a 100644
--- a/include/linux/spi/spidev.h
+++ b/include/linux/spi/spidev.h
@@ -40,6 +40,8 @@
40#define SPI_LSB_FIRST 0x08 40#define SPI_LSB_FIRST 0x08
41#define SPI_3WIRE 0x10 41#define SPI_3WIRE 0x10
42#define SPI_LOOP 0x20 42#define SPI_LOOP 0x20
43#define SPI_NO_CS 0x40
44#define SPI_READY 0x80
43 45
44/*---------------------------------------------------------------------------*/ 46/*---------------------------------------------------------------------------*/
45 47
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 252b245cfcf4..4be57ab03478 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -132,6 +132,11 @@ do { \
132#endif /*__raw_spin_is_contended*/ 132#endif /*__raw_spin_is_contended*/
133#endif 133#endif
134 134
135/* The lock does not imply full memory barrier. */
136#ifndef ARCH_HAS_SMP_MB_AFTER_LOCK
137static inline void smp_mb__after_lock(void) { smp_mb(); }
138#endif
139
135/** 140/**
136 * spin_unlock_wait - wait until the spinlock gets unlocked 141 * spin_unlock_wait - wait until the spinlock gets unlocked
137 * @lock: the spinlock in question. 142 * @lock: the spinlock in question.
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index d8910b68e1bd..b99c625fddfe 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -12,7 +12,6 @@
12#include <linux/uio.h> 12#include <linux/uio.h>
13#include <asm/byteorder.h> 13#include <asm/byteorder.h>
14#include <linux/scatterlist.h> 14#include <linux/scatterlist.h>
15#include <linux/smp_lock.h>
16 15
17/* 16/*
18 * Buffer adjustment 17 * Buffer adjustment
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index fa4242cdade8..80de7003d8c2 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -321,6 +321,8 @@ asmlinkage long sys_rt_sigtimedwait(const sigset_t __user *uthese,
321 siginfo_t __user *uinfo, 321 siginfo_t __user *uinfo,
322 const struct timespec __user *uts, 322 const struct timespec __user *uts,
323 size_t sigsetsize); 323 size_t sigsetsize);
324asmlinkage long sys_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig,
325 siginfo_t __user *uinfo);
324asmlinkage long sys_kill(int pid, int sig); 326asmlinkage long sys_kill(int pid, int sig);
325asmlinkage long sys_tgkill(int tgid, int pid, int sig); 327asmlinkage long sys_tgkill(int tgid, int pid, int sig);
326asmlinkage long sys_tkill(int pid, int sig); 328asmlinkage long sys_tkill(int pid, int sig);
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
index 98a1d8cfb73d..99adcdc0d3ca 100644
--- a/include/linux/sysrq.h
+++ b/include/linux/sysrq.h
@@ -14,6 +14,8 @@
14#ifndef _LINUX_SYSRQ_H 14#ifndef _LINUX_SYSRQ_H
15#define _LINUX_SYSRQ_H 15#define _LINUX_SYSRQ_H
16 16
17#include <linux/errno.h>
18
17struct pt_regs; 19struct pt_regs;
18struct tty_struct; 20struct tty_struct;
19 21
diff --git a/include/linux/timer.h b/include/linux/timer.h
index ccf882eed8f8..be62ec2ebea5 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -190,6 +190,8 @@ extern unsigned long get_next_timer_interrupt(unsigned long now);
190 */ 190 */
191#ifdef CONFIG_TIMER_STATS 191#ifdef CONFIG_TIMER_STATS
192 192
193extern int timer_stats_active;
194
193#define TIMER_STATS_FLAG_DEFERRABLE 0x1 195#define TIMER_STATS_FLAG_DEFERRABLE 0x1
194 196
195extern void init_timer_stats(void); 197extern void init_timer_stats(void);
@@ -203,6 +205,8 @@ extern void __timer_stats_timer_set_start_info(struct timer_list *timer,
203 205
204static inline void timer_stats_timer_set_start_info(struct timer_list *timer) 206static inline void timer_stats_timer_set_start_info(struct timer_list *timer)
205{ 207{
208 if (likely(!timer_stats_active))
209 return;
206 __timer_stats_timer_set_start_info(timer, __builtin_return_address(0)); 210 __timer_stats_timer_set_start_info(timer, __builtin_return_address(0));
207} 211}
208 212
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 84929e914034..b1e3c2fbfe11 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -888,8 +888,6 @@ struct usb_driver {
888 * struct usb_device_driver - identifies USB device driver to usbcore 888 * struct usb_device_driver - identifies USB device driver to usbcore
889 * @name: The driver name should be unique among USB drivers, 889 * @name: The driver name should be unique among USB drivers,
890 * and should normally be the same as the module name. 890 * and should normally be the same as the module name.
891 * @nodename: Callback to provide a naming hint for a possible
892 * device node to create.
893 * @probe: Called to see if the driver is willing to manage a particular 891 * @probe: Called to see if the driver is willing to manage a particular
894 * device. If it is, probe returns zero and uses dev_set_drvdata() 892 * device. If it is, probe returns zero and uses dev_set_drvdata()
895 * to associate driver-specific data with the device. If unwilling 893 * to associate driver-specific data with the device. If unwilling
@@ -924,6 +922,8 @@ extern struct bus_type usb_bus_type;
924/** 922/**
925 * struct usb_class_driver - identifies a USB driver that wants to use the USB major number 923 * struct usb_class_driver - identifies a USB driver that wants to use the USB major number
926 * @name: the usb class device name for this driver. Will show up in sysfs. 924 * @name: the usb class device name for this driver. Will show up in sysfs.
925 * @nodename: Callback to provide a naming hint for a possible
926 * device node to create.
927 * @fops: pointer to the struct file_operations of this driver. 927 * @fops: pointer to the struct file_operations of this driver.
928 * @minor_base: the start of the minor range for this driver. 928 * @minor_base: the start of the minor range for this driver.
929 * 929 *
@@ -1046,6 +1046,8 @@ typedef void (*usb_complete_t)(struct urb *);
1046 * the device driver is saying that it provided this DMA address, 1046 * the device driver is saying that it provided this DMA address,
1047 * which the host controller driver should use in preference to the 1047 * which the host controller driver should use in preference to the
1048 * transfer_buffer. 1048 * transfer_buffer.
1049 * @sg: scatter gather buffer list
1050 * @num_sgs: number of entries in the sg list
1049 * @transfer_buffer_length: How big is transfer_buffer. The transfer may 1051 * @transfer_buffer_length: How big is transfer_buffer. The transfer may
1050 * be broken up into chunks according to the current maximum packet 1052 * be broken up into chunks according to the current maximum packet
1051 * size for the endpoint, which is a function of the configuration 1053 * size for the endpoint, which is a function of the configuration
diff --git a/include/linux/usb/langwell_otg.h b/include/linux/usb/langwell_otg.h
deleted file mode 100644
index e115ae6df1da..000000000000
--- a/include/linux/usb/langwell_otg.h
+++ /dev/null
@@ -1,177 +0,0 @@
1/*
2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#ifndef __LANGWELL_OTG_H__
21#define __LANGWELL_OTG_H__
22
23/* notify transceiver driver about OTG events */
24extern void langwell_update_transceiver(void);
25/* HCD register bus driver */
26extern int langwell_register_host(struct pci_driver *host_driver);
27/* HCD unregister bus driver */
28extern void langwell_unregister_host(struct pci_driver *host_driver);
29/* DCD register bus driver */
30extern int langwell_register_peripheral(struct pci_driver *client_driver);
31/* DCD unregister bus driver */
32extern void langwell_unregister_peripheral(struct pci_driver *client_driver);
33/* No silent failure, output warning message */
34extern void langwell_otg_nsf_msg(unsigned long message);
35
36#define CI_USBCMD 0x30
37# define USBCMD_RST BIT(1)
38# define USBCMD_RS BIT(0)
39#define CI_USBSTS 0x34
40# define USBSTS_SLI BIT(8)
41# define USBSTS_URI BIT(6)
42# define USBSTS_PCI BIT(2)
43#define CI_PORTSC1 0x74
44# define PORTSC_PP BIT(12)
45# define PORTSC_LS (BIT(11) | BIT(10))
46# define PORTSC_SUSP BIT(7)
47# define PORTSC_CCS BIT(0)
48#define CI_HOSTPC1 0xb4
49# define HOSTPC1_PHCD BIT(22)
50#define CI_OTGSC 0xf4
51# define OTGSC_DPIE BIT(30)
52# define OTGSC_1MSE BIT(29)
53# define OTGSC_BSEIE BIT(28)
54# define OTGSC_BSVIE BIT(27)
55# define OTGSC_ASVIE BIT(26)
56# define OTGSC_AVVIE BIT(25)
57# define OTGSC_IDIE BIT(24)
58# define OTGSC_DPIS BIT(22)
59# define OTGSC_1MSS BIT(21)
60# define OTGSC_BSEIS BIT(20)
61# define OTGSC_BSVIS BIT(19)
62# define OTGSC_ASVIS BIT(18)
63# define OTGSC_AVVIS BIT(17)
64# define OTGSC_IDIS BIT(16)
65# define OTGSC_DPS BIT(14)
66# define OTGSC_1MST BIT(13)
67# define OTGSC_BSE BIT(12)
68# define OTGSC_BSV BIT(11)
69# define OTGSC_ASV BIT(10)
70# define OTGSC_AVV BIT(9)
71# define OTGSC_ID BIT(8)
72# define OTGSC_HABA BIT(7)
73# define OTGSC_HADP BIT(6)
74# define OTGSC_IDPU BIT(5)
75# define OTGSC_DP BIT(4)
76# define OTGSC_OT BIT(3)
77# define OTGSC_HAAR BIT(2)
78# define OTGSC_VC BIT(1)
79# define OTGSC_VD BIT(0)
80# define OTGSC_INTEN_MASK (0x7f << 24)
81# define OTGSC_INTSTS_MASK (0x7f << 16)
82#define CI_USBMODE 0xf8
83# define USBMODE_CM (BIT(1) | BIT(0))
84# define USBMODE_IDLE 0
85# define USBMODE_DEVICE 0x2
86# define USBMODE_HOST 0x3
87
88#define INTR_DUMMY_MASK (USBSTS_SLI | USBSTS_URI | USBSTS_PCI)
89
90struct otg_hsm {
91 /* Input */
92 int a_bus_resume;
93 int a_bus_suspend;
94 int a_conn;
95 int a_sess_vld;
96 int a_srp_det;
97 int a_vbus_vld;
98 int b_bus_resume;
99 int b_bus_suspend;
100 int b_conn;
101 int b_se0_srp;
102 int b_sess_end;
103 int b_sess_vld;
104 int id;
105
106 /* Internal variables */
107 int a_set_b_hnp_en;
108 int b_srp_done;
109 int b_hnp_enable;
110
111 /* Timeout indicator for timers */
112 int a_wait_vrise_tmout;
113 int a_wait_bcon_tmout;
114 int a_aidl_bdis_tmout;
115 int b_ase0_brst_tmout;
116 int b_bus_suspend_tmout;
117 int b_srp_res_tmout;
118
119 /* Informative variables */
120 int a_bus_drop;
121 int a_bus_req;
122 int a_clr_err;
123 int a_suspend_req;
124 int b_bus_req;
125
126 /* Output */
127 int drv_vbus;
128 int loc_conn;
129 int loc_sof;
130
131 /* Others */
132 int b_bus_suspend_vld;
133};
134
135#define TA_WAIT_VRISE 100
136#define TA_WAIT_BCON 30000
137#define TA_AIDL_BDIS 15000
138#define TB_ASE0_BRST 5000
139#define TB_SE0_SRP 2
140#define TB_SRP_RES 100
141#define TB_BUS_SUSPEND 500
142
143struct langwell_otg_timer {
144 unsigned long expires; /* Number of count increase to timeout */
145 unsigned long count; /* Tick counter */
146 void (*function)(unsigned long); /* Timeout function */
147 unsigned long data; /* Data passed to function */
148 struct list_head list;
149};
150
151struct langwell_otg {
152 struct otg_transceiver otg;
153 struct otg_hsm hsm;
154 void __iomem *regs;
155 unsigned region;
156 struct pci_driver *host_ops;
157 struct pci_driver *client_ops;
158 struct pci_dev *pdev;
159 struct work_struct work;
160 struct workqueue_struct *qwork;
161 spinlock_t lock;
162 spinlock_t wq_lock;
163};
164
165static inline struct langwell_otg *otg_to_langwell(struct otg_transceiver *otg)
166{
167 return container_of(otg, struct langwell_otg, otg);
168}
169
170#ifdef DEBUG
171#define otg_dbg(fmt, args...) \
172 printk(KERN_DEBUG fmt , ## args)
173#else
174#define otg_dbg(fmt, args...) \
175 do { } while (0)
176#endif /* DEBUG */
177#endif /* __LANGWELL_OTG_H__ */
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 44801d26a37a..0ec50ba62139 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -317,7 +317,8 @@ extern int usb_serial_generic_register(int debug);
317extern void usb_serial_generic_deregister(void); 317extern void usb_serial_generic_deregister(void);
318extern void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, 318extern void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
319 gfp_t mem_flags); 319 gfp_t mem_flags);
320extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port, 320extern int usb_serial_handle_sysrq_char(struct tty_struct *tty,
321 struct usb_serial_port *port,
321 unsigned int ch); 322 unsigned int ch);
322extern int usb_serial_handle_break(struct usb_serial_port *port); 323extern int usb_serial_handle_break(struct usb_serial_port *port);
323 324
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 5d44059f6d63..310e18a880ff 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -42,7 +42,6 @@ struct usbnet {
42 42
43 /* protocol/interface state */ 43 /* protocol/interface state */
44 struct net_device *net; 44 struct net_device *net;
45 struct net_device_stats stats;
46 int msg_enable; 45 int msg_enable;
47 unsigned long data [5]; 46 unsigned long data [5];
48 u32 xid; 47 u32 xid;
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 8a025d510904..95846d988011 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -318,6 +318,8 @@ struct v4l2_pix_format {
318/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ 318/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
319#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */ 319#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
320#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */ 320#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
321#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
322
321/* 323/*
322 * 10bit raw bayer, expanded to 16 bits 324 * 10bit raw bayer, expanded to 16 bits
323 * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb... 325 * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb...
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 4d7e2272c42f..11a4a2d3e364 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -155,6 +155,9 @@ enum {
155 /* module cafe_ccic, just ident 8801 */ 155 /* module cafe_ccic, just ident 8801 */
156 V4L2_IDENT_CAFE = 8801, 156 V4L2_IDENT_CAFE = 8801,
157 157
158 /* module mt9v011, just ident 8243 */
159 V4L2_IDENT_MT9V011 = 8243,
160
158 /* module tw9910: just ident 9910 */ 161 /* module tw9910: just ident 9910 */
159 V4L2_IDENT_TW9910 = 9910, 162 V4L2_IDENT_TW9910 = 9910,
160 163
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index a632689b61b4..cbdd6284996d 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -258,8 +258,8 @@ static inline bool nf_ct_kill(struct nf_conn *ct)
258/* Update TCP window tracking data when NAT mangles the packet */ 258/* Update TCP window tracking data when NAT mangles the packet */
259extern void nf_conntrack_tcp_update(const struct sk_buff *skb, 259extern void nf_conntrack_tcp_update(const struct sk_buff *skb,
260 unsigned int dataoff, 260 unsigned int dataoff,
261 struct nf_conn *ct, 261 struct nf_conn *ct, int dir,
262 int dir); 262 s16 offset);
263 263
264/* Fake conntrack entry for untracked connections */ 264/* Fake conntrack entry for untracked connections */
265extern struct nf_conn nf_conntrack_untracked; 265extern struct nf_conn nf_conntrack_untracked;
diff --git a/include/net/phonet/pn_dev.h b/include/net/phonet/pn_dev.h
index 5054dc5ea2c2..29d126736611 100644
--- a/include/net/phonet/pn_dev.h
+++ b/include/net/phonet/pn_dev.h
@@ -45,6 +45,7 @@ int phonet_address_add(struct net_device *dev, u8 addr);
45int phonet_address_del(struct net_device *dev, u8 addr); 45int phonet_address_del(struct net_device *dev, u8 addr);
46u8 phonet_address_get(struct net_device *dev, u8 addr); 46u8 phonet_address_get(struct net_device *dev, u8 addr);
47int phonet_address_lookup(struct net *net, u8 addr); 47int phonet_address_lookup(struct net *net, u8 addr);
48void phonet_address_notify(int event, struct net_device *dev, u8 addr);
48 49
49#define PN_NO_ADDR 0xff 50#define PN_NO_ADDR 0xff
50 51
diff --git a/include/net/sock.h b/include/net/sock.h
index 352f06bbd7a9..2c0da9239b95 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -54,6 +54,7 @@
54 54
55#include <linux/filter.h> 55#include <linux/filter.h>
56#include <linux/rculist_nulls.h> 56#include <linux/rculist_nulls.h>
57#include <linux/poll.h>
57 58
58#include <asm/atomic.h> 59#include <asm/atomic.h>
59#include <net/dst.h> 60#include <net/dst.h>
@@ -1241,6 +1242,74 @@ static inline int sk_has_allocations(const struct sock *sk)
1241 return sk_wmem_alloc_get(sk) || sk_rmem_alloc_get(sk); 1242 return sk_wmem_alloc_get(sk) || sk_rmem_alloc_get(sk);
1242} 1243}
1243 1244
1245/**
1246 * sk_has_sleeper - check if there are any waiting processes
1247 * @sk: socket
1248 *
1249 * Returns true if socket has waiting processes
1250 *
1251 * The purpose of the sk_has_sleeper and sock_poll_wait is to wrap the memory
1252 * barrier call. They were added due to the race found within the tcp code.
1253 *
1254 * Consider following tcp code paths:
1255 *
1256 * CPU1 CPU2
1257 *
1258 * sys_select receive packet
1259 * ... ...
1260 * __add_wait_queue update tp->rcv_nxt
1261 * ... ...
1262 * tp->rcv_nxt check sock_def_readable
1263 * ... {
1264 * schedule ...
1265 * if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
1266 * wake_up_interruptible(sk->sk_sleep)
1267 * ...
1268 * }
1269 *
1270 * The race for tcp fires when the __add_wait_queue changes done by CPU1 stay
1271 * in its cache, and so does the tp->rcv_nxt update on CPU2 side. The CPU1
1272 * could then endup calling schedule and sleep forever if there are no more
1273 * data on the socket.
1274 *
1275 * The sk_has_sleeper is always called right after a call to read_lock, so we
1276 * can use smp_mb__after_lock barrier.
1277 */
1278static inline int sk_has_sleeper(struct sock *sk)
1279{
1280 /*
1281 * We need to be sure we are in sync with the
1282 * add_wait_queue modifications to the wait queue.
1283 *
1284 * This memory barrier is paired in the sock_poll_wait.
1285 */
1286 smp_mb__after_lock();
1287 return sk->sk_sleep && waitqueue_active(sk->sk_sleep);
1288}
1289
1290/**
1291 * sock_poll_wait - place memory barrier behind the poll_wait call.
1292 * @filp: file
1293 * @wait_address: socket wait queue
1294 * @p: poll_table
1295 *
1296 * See the comments in the sk_has_sleeper function.
1297 */
1298static inline void sock_poll_wait(struct file *filp,
1299 wait_queue_head_t *wait_address, poll_table *p)
1300{
1301 if (p && wait_address) {
1302 poll_wait(filp, wait_address, p);
1303 /*
1304 * We need to be sure we are in sync with the
1305 * socket flags modification.
1306 *
1307 * This memory barrier is paired in the sk_has_sleeper.
1308 */
1309 smp_mb();
1310 }
1311}
1312
1244/* 1313/*
1245 * Queue a received datagram if it will fit. Stream and sequenced 1314 * Queue a received datagram if it will fit. Stream and sequenced
1246 * protocols can't normally use this as they need to fit buffers in 1315 * protocols can't normally use this as they need to fit buffers in
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index acf4cc9cd36d..dfbc9b0edc88 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -34,7 +34,8 @@ TRACE_EVENT(ext4_free_inode,
34 34
35 TP_printk("dev %s ino %lu mode %d uid %u gid %u blocks %llu", 35 TP_printk("dev %s ino %lu mode %d uid %u gid %u blocks %llu",
36 jbd2_dev_to_name(__entry->dev), __entry->ino, __entry->mode, 36 jbd2_dev_to_name(__entry->dev), __entry->ino, __entry->mode,
37 __entry->uid, __entry->gid, __entry->blocks) 37 __entry->uid, __entry->gid,
38 (unsigned long long) __entry->blocks)
38); 39);
39 40
40TRACE_EVENT(ext4_request_inode, 41TRACE_EVENT(ext4_request_inode,
@@ -189,7 +190,7 @@ TRACE_EVENT(ext4_journalled_write_end,
189 __entry->copied) 190 __entry->copied)
190); 191);
191 192
192TRACE_EVENT(ext4_da_writepage, 193TRACE_EVENT(ext4_writepage,
193 TP_PROTO(struct inode *inode, struct page *page), 194 TP_PROTO(struct inode *inode, struct page *page),
194 195
195 TP_ARGS(inode, page), 196 TP_ARGS(inode, page),
@@ -341,49 +342,6 @@ TRACE_EVENT(ext4_da_write_end,
341 __entry->copied) 342 __entry->copied)
342); 343);
343 344
344TRACE_EVENT(ext4_normal_writepage,
345 TP_PROTO(struct inode *inode, struct page *page),
346
347 TP_ARGS(inode, page),
348
349 TP_STRUCT__entry(
350 __field( dev_t, dev )
351 __field( ino_t, ino )
352 __field( pgoff_t, index )
353 ),
354
355 TP_fast_assign(
356 __entry->dev = inode->i_sb->s_dev;
357 __entry->ino = inode->i_ino;
358 __entry->index = page->index;
359 ),
360
361 TP_printk("dev %s ino %lu page_index %lu",
362 jbd2_dev_to_name(__entry->dev), __entry->ino, __entry->index)
363);
364
365TRACE_EVENT(ext4_journalled_writepage,
366 TP_PROTO(struct inode *inode, struct page *page),
367
368 TP_ARGS(inode, page),
369
370 TP_STRUCT__entry(
371 __field( dev_t, dev )
372 __field( ino_t, ino )
373 __field( pgoff_t, index )
374
375 ),
376
377 TP_fast_assign(
378 __entry->dev = inode->i_sb->s_dev;
379 __entry->ino = inode->i_ino;
380 __entry->index = page->index;
381 ),
382
383 TP_printk("dev %s ino %lu page_index %lu",
384 jbd2_dev_to_name(__entry->dev), __entry->ino, __entry->index)
385);
386
387TRACE_EVENT(ext4_discard_blocks, 345TRACE_EVENT(ext4_discard_blocks,
388 TP_PROTO(struct super_block *sb, unsigned long long blk, 346 TP_PROTO(struct super_block *sb, unsigned long long blk,
389 unsigned long long count), 347 unsigned long long count),
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index e35ba2c3a8d7..c5e68adc6732 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -32,6 +32,7 @@
32#include <linux/nsproxy.h> 32#include <linux/nsproxy.h>
33#include <linux/pid.h> 33#include <linux/pid.h>
34#include <linux/ipc_namespace.h> 34#include <linux/ipc_namespace.h>
35#include <linux/ima.h>
35 36
36#include <net/sock.h> 37#include <net/sock.h>
37#include "util.h" 38#include "util.h"
@@ -733,6 +734,7 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode,
733 error = PTR_ERR(filp); 734 error = PTR_ERR(filp);
734 goto out_putfd; 735 goto out_putfd;
735 } 736 }
737 ima_counts_get(filp);
736 738
737 fd_install(fd, filp); 739 fd_install(fd, filp);
738 goto out_upsem; 740 goto out_upsem;
diff --git a/kernel/Makefile b/kernel/Makefile
index 780c8dcf4516..2093a691f1c2 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -96,6 +96,7 @@ obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
96obj-$(CONFIG_FUNCTION_TRACER) += trace/ 96obj-$(CONFIG_FUNCTION_TRACER) += trace/
97obj-$(CONFIG_TRACING) += trace/ 97obj-$(CONFIG_TRACING) += trace/
98obj-$(CONFIG_X86_DS) += trace/ 98obj-$(CONFIG_X86_DS) += trace/
99obj-$(CONFIG_RING_BUFFER) += trace/
99obj-$(CONFIG_SMP) += sched_cpupri.o 100obj-$(CONFIG_SMP) += sched_cpupri.o
100obj-$(CONFIG_SLOW_WORK) += slow-work.o 101obj-$(CONFIG_SLOW_WORK) += slow-work.o
101obj-$(CONFIG_PERF_COUNTERS) += perf_counter.o 102obj-$(CONFIG_PERF_COUNTERS) += perf_counter.o
diff --git a/kernel/acct.c b/kernel/acct.c
index 7afa31564162..9f3391090b3e 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -215,6 +215,7 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file,
215static int acct_on(char *name) 215static int acct_on(char *name)
216{ 216{
217 struct file *file; 217 struct file *file;
218 struct vfsmount *mnt;
218 int error; 219 int error;
219 struct pid_namespace *ns; 220 struct pid_namespace *ns;
220 struct bsd_acct_struct *acct = NULL; 221 struct bsd_acct_struct *acct = NULL;
@@ -256,11 +257,12 @@ static int acct_on(char *name)
256 acct = NULL; 257 acct = NULL;
257 } 258 }
258 259
259 mnt_pin(file->f_path.mnt); 260 mnt = file->f_path.mnt;
261 mnt_pin(mnt);
260 acct_file_reopen(ns->bacct, file, ns); 262 acct_file_reopen(ns->bacct, file, ns);
261 spin_unlock(&acct_lock); 263 spin_unlock(&acct_lock);
262 264
263 mntput(file->f_path.mnt); /* it's pinned, now give up active reference */ 265 mntput(mnt); /* it's pinned, now give up active reference */
264 kfree(acct); 266 kfree(acct);
265 267
266 return 0; 268 return 0;
diff --git a/kernel/exit.c b/kernel/exit.c
index 628d41f0dd54..869dc221733e 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -12,7 +12,6 @@
12#include <linux/completion.h> 12#include <linux/completion.h>
13#include <linux/personality.h> 13#include <linux/personality.h>
14#include <linux/tty.h> 14#include <linux/tty.h>
15#include <linux/mnt_namespace.h>
16#include <linux/iocontext.h> 15#include <linux/iocontext.h>
17#include <linux/key.h> 16#include <linux/key.h>
18#include <linux/security.h> 17#include <linux/security.h>
diff --git a/kernel/fork.c b/kernel/fork.c
index 467746b3f0aa..bd2959228871 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -17,7 +17,6 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
19#include <linux/completion.h> 19#include <linux/completion.h>
20#include <linux/mnt_namespace.h>
21#include <linux/personality.h> 20#include <linux/personality.h>
22#include <linux/mempolicy.h> 21#include <linux/mempolicy.h>
23#include <linux/sem.h> 22#include <linux/sem.h>
diff --git a/kernel/futex.c b/kernel/futex.c
index 1c337112335c..794c862125fe 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -299,7 +299,7 @@ void put_futex_key(int fshared, union futex_key *key)
299static int fault_in_user_writeable(u32 __user *uaddr) 299static int fault_in_user_writeable(u32 __user *uaddr)
300{ 300{
301 int ret = get_user_pages(current, current->mm, (unsigned long)uaddr, 301 int ret = get_user_pages(current, current->mm, (unsigned long)uaddr,
302 sizeof(*uaddr), 1, 0, NULL, NULL); 302 1, 1, 0, NULL, NULL);
303 return ret < 0 ? ret : 0; 303 return ret < 0 ? ret : 0;
304} 304}
305 305
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 7e95bedb2bfc..385c31a1bdbf 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -24,7 +24,6 @@
24#include <linux/unistd.h> 24#include <linux/unistd.h>
25#include <linux/kmod.h> 25#include <linux/kmod.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/mnt_namespace.h>
28#include <linux/completion.h> 27#include <linux/completion.h>
29#include <linux/file.h> 28#include <linux/file.h>
30#include <linux/fdtable.h> 29#include <linux/fdtable.h>
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c0fa54b276d9..16b5739c516a 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -237,13 +237,9 @@ static int __kprobes collect_garbage_slots(void)
237{ 237{
238 struct kprobe_insn_page *kip; 238 struct kprobe_insn_page *kip;
239 struct hlist_node *pos, *next; 239 struct hlist_node *pos, *next;
240 int safety;
241 240
242 /* Ensure no-one is preepmted on the garbages */ 241 /* Ensure no-one is preepmted on the garbages */
243 mutex_unlock(&kprobe_insn_mutex); 242 if (check_safety())
244 safety = check_safety();
245 mutex_lock(&kprobe_insn_mutex);
246 if (safety != 0)
247 return -EAGAIN; 243 return -EAGAIN;
248 244
249 hlist_for_each_entry_safe(kip, pos, next, &kprobe_insn_pages, hlist) { 245 hlist_for_each_entry_safe(kip, pos, next, &kprobe_insn_pages, hlist) {
diff --git a/kernel/module.c b/kernel/module.c
index 38928fcaff2b..0a049837008e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2451,9 +2451,9 @@ SYSCALL_DEFINE3(init_module, void __user *, umod,
2451 return ret; 2451 return ret;
2452 } 2452 }
2453 if (ret > 0) { 2453 if (ret > 0) {
2454 printk(KERN_WARNING "%s: '%s'->init suspiciously returned %d, " 2454 printk(KERN_WARNING
2455 "it should follow 0/-E convention\n" 2455"%s: '%s'->init suspiciously returned %d, it should follow 0/-E convention\n"
2456 KERN_WARNING "%s: loading module anyway...\n", 2456"%s: loading module anyway...\n",
2457 __func__, mod->name, ret, 2457 __func__, mod->name, ret,
2458 __func__); 2458 __func__);
2459 dump_stack(); 2459 dump_stack();
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 1a933a221ea4..a641eb753b8c 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -236,6 +236,8 @@ list_add_counter(struct perf_counter *counter, struct perf_counter_context *ctx)
236 236
237 list_add_rcu(&counter->event_entry, &ctx->event_list); 237 list_add_rcu(&counter->event_entry, &ctx->event_list);
238 ctx->nr_counters++; 238 ctx->nr_counters++;
239 if (counter->attr.inherit_stat)
240 ctx->nr_stat++;
239} 241}
240 242
241/* 243/*
@@ -250,6 +252,8 @@ list_del_counter(struct perf_counter *counter, struct perf_counter_context *ctx)
250 if (list_empty(&counter->list_entry)) 252 if (list_empty(&counter->list_entry))
251 return; 253 return;
252 ctx->nr_counters--; 254 ctx->nr_counters--;
255 if (counter->attr.inherit_stat)
256 ctx->nr_stat--;
253 257
254 list_del_init(&counter->list_entry); 258 list_del_init(&counter->list_entry);
255 list_del_rcu(&counter->event_entry); 259 list_del_rcu(&counter->event_entry);
@@ -1006,6 +1010,81 @@ static int context_equiv(struct perf_counter_context *ctx1,
1006 && !ctx1->pin_count && !ctx2->pin_count; 1010 && !ctx1->pin_count && !ctx2->pin_count;
1007} 1011}
1008 1012
1013static void __perf_counter_read(void *counter);
1014
1015static void __perf_counter_sync_stat(struct perf_counter *counter,
1016 struct perf_counter *next_counter)
1017{
1018 u64 value;
1019
1020 if (!counter->attr.inherit_stat)
1021 return;
1022
1023 /*
1024 * Update the counter value, we cannot use perf_counter_read()
1025 * because we're in the middle of a context switch and have IRQs
1026 * disabled, which upsets smp_call_function_single(), however
1027 * we know the counter must be on the current CPU, therefore we
1028 * don't need to use it.
1029 */
1030 switch (counter->state) {
1031 case PERF_COUNTER_STATE_ACTIVE:
1032 __perf_counter_read(counter);
1033 break;
1034
1035 case PERF_COUNTER_STATE_INACTIVE:
1036 update_counter_times(counter);
1037 break;
1038
1039 default:
1040 break;
1041 }
1042
1043 /*
1044 * In order to keep per-task stats reliable we need to flip the counter
1045 * values when we flip the contexts.
1046 */
1047 value = atomic64_read(&next_counter->count);
1048 value = atomic64_xchg(&counter->count, value);
1049 atomic64_set(&next_counter->count, value);
1050
1051 swap(counter->total_time_enabled, next_counter->total_time_enabled);
1052 swap(counter->total_time_running, next_counter->total_time_running);
1053
1054 /*
1055 * Since we swizzled the values, update the user visible data too.
1056 */
1057 perf_counter_update_userpage(counter);
1058 perf_counter_update_userpage(next_counter);
1059}
1060
1061#define list_next_entry(pos, member) \
1062 list_entry(pos->member.next, typeof(*pos), member)
1063
1064static void perf_counter_sync_stat(struct perf_counter_context *ctx,
1065 struct perf_counter_context *next_ctx)
1066{
1067 struct perf_counter *counter, *next_counter;
1068
1069 if (!ctx->nr_stat)
1070 return;
1071
1072 counter = list_first_entry(&ctx->event_list,
1073 struct perf_counter, event_entry);
1074
1075 next_counter = list_first_entry(&next_ctx->event_list,
1076 struct perf_counter, event_entry);
1077
1078 while (&counter->event_entry != &ctx->event_list &&
1079 &next_counter->event_entry != &next_ctx->event_list) {
1080
1081 __perf_counter_sync_stat(counter, next_counter);
1082
1083 counter = list_next_entry(counter, event_entry);
1084 next_counter = list_next_entry(counter, event_entry);
1085 }
1086}
1087
1009/* 1088/*
1010 * Called from scheduler to remove the counters of the current task, 1089 * Called from scheduler to remove the counters of the current task,
1011 * with interrupts disabled. 1090 * with interrupts disabled.
@@ -1061,6 +1140,8 @@ void perf_counter_task_sched_out(struct task_struct *task,
1061 ctx->task = next; 1140 ctx->task = next;
1062 next_ctx->task = task; 1141 next_ctx->task = task;
1063 do_switch = 0; 1142 do_switch = 0;
1143
1144 perf_counter_sync_stat(ctx, next_ctx);
1064 } 1145 }
1065 spin_unlock(&next_ctx->lock); 1146 spin_unlock(&next_ctx->lock);
1066 spin_unlock(&ctx->lock); 1147 spin_unlock(&ctx->lock);
@@ -1348,9 +1429,56 @@ void perf_counter_task_tick(struct task_struct *curr, int cpu)
1348} 1429}
1349 1430
1350/* 1431/*
1432 * Enable all of a task's counters that have been marked enable-on-exec.
1433 * This expects task == current.
1434 */
1435static void perf_counter_enable_on_exec(struct task_struct *task)
1436{
1437 struct perf_counter_context *ctx;
1438 struct perf_counter *counter;
1439 unsigned long flags;
1440 int enabled = 0;
1441
1442 local_irq_save(flags);
1443 ctx = task->perf_counter_ctxp;
1444 if (!ctx || !ctx->nr_counters)
1445 goto out;
1446
1447 __perf_counter_task_sched_out(ctx);
1448
1449 spin_lock(&ctx->lock);
1450
1451 list_for_each_entry(counter, &ctx->counter_list, list_entry) {
1452 if (!counter->attr.enable_on_exec)
1453 continue;
1454 counter->attr.enable_on_exec = 0;
1455 if (counter->state >= PERF_COUNTER_STATE_INACTIVE)
1456 continue;
1457 counter->state = PERF_COUNTER_STATE_INACTIVE;
1458 counter->tstamp_enabled =
1459 ctx->time - counter->total_time_enabled;
1460 enabled = 1;
1461 }
1462
1463 /*
1464 * Unclone this context if we enabled any counter.
1465 */
1466 if (enabled && ctx->parent_ctx) {
1467 put_ctx(ctx->parent_ctx);
1468 ctx->parent_ctx = NULL;
1469 }
1470
1471 spin_unlock(&ctx->lock);
1472
1473 perf_counter_task_sched_in(task, smp_processor_id());
1474 out:
1475 local_irq_restore(flags);
1476}
1477
1478/*
1351 * Cross CPU call to read the hardware counter 1479 * Cross CPU call to read the hardware counter
1352 */ 1480 */
1353static void __read(void *info) 1481static void __perf_counter_read(void *info)
1354{ 1482{
1355 struct perf_counter *counter = info; 1483 struct perf_counter *counter = info;
1356 struct perf_counter_context *ctx = counter->ctx; 1484 struct perf_counter_context *ctx = counter->ctx;
@@ -1372,7 +1500,7 @@ static u64 perf_counter_read(struct perf_counter *counter)
1372 */ 1500 */
1373 if (counter->state == PERF_COUNTER_STATE_ACTIVE) { 1501 if (counter->state == PERF_COUNTER_STATE_ACTIVE) {
1374 smp_call_function_single(counter->oncpu, 1502 smp_call_function_single(counter->oncpu,
1375 __read, counter, 1); 1503 __perf_counter_read, counter, 1);
1376 } else if (counter->state == PERF_COUNTER_STATE_INACTIVE) { 1504 } else if (counter->state == PERF_COUNTER_STATE_INACTIVE) {
1377 update_counter_times(counter); 1505 update_counter_times(counter);
1378 } 1506 }
@@ -1508,11 +1636,13 @@ static void free_counter(struct perf_counter *counter)
1508{ 1636{
1509 perf_pending_sync(counter); 1637 perf_pending_sync(counter);
1510 1638
1511 atomic_dec(&nr_counters); 1639 if (!counter->parent) {
1512 if (counter->attr.mmap) 1640 atomic_dec(&nr_counters);
1513 atomic_dec(&nr_mmap_counters); 1641 if (counter->attr.mmap)
1514 if (counter->attr.comm) 1642 atomic_dec(&nr_mmap_counters);
1515 atomic_dec(&nr_comm_counters); 1643 if (counter->attr.comm)
1644 atomic_dec(&nr_comm_counters);
1645 }
1516 1646
1517 if (counter->destroy) 1647 if (counter->destroy)
1518 counter->destroy(counter); 1648 counter->destroy(counter);
@@ -1751,6 +1881,14 @@ int perf_counter_task_disable(void)
1751 return 0; 1881 return 0;
1752} 1882}
1753 1883
1884static int perf_counter_index(struct perf_counter *counter)
1885{
1886 if (counter->state != PERF_COUNTER_STATE_ACTIVE)
1887 return 0;
1888
1889 return counter->hw.idx + 1 - PERF_COUNTER_INDEX_OFFSET;
1890}
1891
1754/* 1892/*
1755 * Callers need to ensure there can be no nesting of this function, otherwise 1893 * Callers need to ensure there can be no nesting of this function, otherwise
1756 * the seqlock logic goes bad. We can not serialize this because the arch 1894 * the seqlock logic goes bad. We can not serialize this because the arch
@@ -1775,11 +1913,17 @@ void perf_counter_update_userpage(struct perf_counter *counter)
1775 preempt_disable(); 1913 preempt_disable();
1776 ++userpg->lock; 1914 ++userpg->lock;
1777 barrier(); 1915 barrier();
1778 userpg->index = counter->hw.idx; 1916 userpg->index = perf_counter_index(counter);
1779 userpg->offset = atomic64_read(&counter->count); 1917 userpg->offset = atomic64_read(&counter->count);
1780 if (counter->state == PERF_COUNTER_STATE_ACTIVE) 1918 if (counter->state == PERF_COUNTER_STATE_ACTIVE)
1781 userpg->offset -= atomic64_read(&counter->hw.prev_count); 1919 userpg->offset -= atomic64_read(&counter->hw.prev_count);
1782 1920
1921 userpg->time_enabled = counter->total_time_enabled +
1922 atomic64_read(&counter->child_total_time_enabled);
1923
1924 userpg->time_running = counter->total_time_running +
1925 atomic64_read(&counter->child_total_time_running);
1926
1783 barrier(); 1927 barrier();
1784 ++userpg->lock; 1928 ++userpg->lock;
1785 preempt_enable(); 1929 preempt_enable();
@@ -1876,7 +2020,7 @@ fail:
1876 2020
1877static void perf_mmap_free_page(unsigned long addr) 2021static void perf_mmap_free_page(unsigned long addr)
1878{ 2022{
1879 struct page *page = virt_to_page(addr); 2023 struct page *page = virt_to_page((void *)addr);
1880 2024
1881 page->mapping = NULL; 2025 page->mapping = NULL;
1882 __free_page(page); 2026 __free_page(page);
@@ -2483,15 +2627,14 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2483 u32 cpu, reserved; 2627 u32 cpu, reserved;
2484 } cpu_entry; 2628 } cpu_entry;
2485 2629
2486 header.type = 0; 2630 header.type = PERF_EVENT_SAMPLE;
2487 header.size = sizeof(header); 2631 header.size = sizeof(header);
2488 2632
2489 header.misc = PERF_EVENT_MISC_OVERFLOW; 2633 header.misc = 0;
2490 header.misc |= perf_misc_flags(data->regs); 2634 header.misc |= perf_misc_flags(data->regs);
2491 2635
2492 if (sample_type & PERF_SAMPLE_IP) { 2636 if (sample_type & PERF_SAMPLE_IP) {
2493 ip = perf_instruction_pointer(data->regs); 2637 ip = perf_instruction_pointer(data->regs);
2494 header.type |= PERF_SAMPLE_IP;
2495 header.size += sizeof(ip); 2638 header.size += sizeof(ip);
2496 } 2639 }
2497 2640
@@ -2500,7 +2643,6 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2500 tid_entry.pid = perf_counter_pid(counter, current); 2643 tid_entry.pid = perf_counter_pid(counter, current);
2501 tid_entry.tid = perf_counter_tid(counter, current); 2644 tid_entry.tid = perf_counter_tid(counter, current);
2502 2645
2503 header.type |= PERF_SAMPLE_TID;
2504 header.size += sizeof(tid_entry); 2646 header.size += sizeof(tid_entry);
2505 } 2647 }
2506 2648
@@ -2510,34 +2652,25 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2510 */ 2652 */
2511 time = sched_clock(); 2653 time = sched_clock();
2512 2654
2513 header.type |= PERF_SAMPLE_TIME;
2514 header.size += sizeof(u64); 2655 header.size += sizeof(u64);
2515 } 2656 }
2516 2657
2517 if (sample_type & PERF_SAMPLE_ADDR) { 2658 if (sample_type & PERF_SAMPLE_ADDR)
2518 header.type |= PERF_SAMPLE_ADDR;
2519 header.size += sizeof(u64); 2659 header.size += sizeof(u64);
2520 }
2521 2660
2522 if (sample_type & PERF_SAMPLE_ID) { 2661 if (sample_type & PERF_SAMPLE_ID)
2523 header.type |= PERF_SAMPLE_ID;
2524 header.size += sizeof(u64); 2662 header.size += sizeof(u64);
2525 }
2526 2663
2527 if (sample_type & PERF_SAMPLE_CPU) { 2664 if (sample_type & PERF_SAMPLE_CPU) {
2528 header.type |= PERF_SAMPLE_CPU;
2529 header.size += sizeof(cpu_entry); 2665 header.size += sizeof(cpu_entry);
2530 2666
2531 cpu_entry.cpu = raw_smp_processor_id(); 2667 cpu_entry.cpu = raw_smp_processor_id();
2532 } 2668 }
2533 2669
2534 if (sample_type & PERF_SAMPLE_PERIOD) { 2670 if (sample_type & PERF_SAMPLE_PERIOD)
2535 header.type |= PERF_SAMPLE_PERIOD;
2536 header.size += sizeof(u64); 2671 header.size += sizeof(u64);
2537 }
2538 2672
2539 if (sample_type & PERF_SAMPLE_GROUP) { 2673 if (sample_type & PERF_SAMPLE_GROUP) {
2540 header.type |= PERF_SAMPLE_GROUP;
2541 header.size += sizeof(u64) + 2674 header.size += sizeof(u64) +
2542 counter->nr_siblings * sizeof(group_entry); 2675 counter->nr_siblings * sizeof(group_entry);
2543 } 2676 }
@@ -2547,10 +2680,9 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2547 2680
2548 if (callchain) { 2681 if (callchain) {
2549 callchain_size = (1 + callchain->nr) * sizeof(u64); 2682 callchain_size = (1 + callchain->nr) * sizeof(u64);
2550
2551 header.type |= PERF_SAMPLE_CALLCHAIN;
2552 header.size += callchain_size; 2683 header.size += callchain_size;
2553 } 2684 } else
2685 header.size += sizeof(u64);
2554 } 2686 }
2555 2687
2556 ret = perf_output_begin(&handle, counter, header.size, nmi, 1); 2688 ret = perf_output_begin(&handle, counter, header.size, nmi, 1);
@@ -2601,13 +2733,79 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2601 } 2733 }
2602 } 2734 }
2603 2735
2604 if (callchain) 2736 if (sample_type & PERF_SAMPLE_CALLCHAIN) {
2605 perf_output_copy(&handle, callchain, callchain_size); 2737 if (callchain)
2738 perf_output_copy(&handle, callchain, callchain_size);
2739 else {
2740 u64 nr = 0;
2741 perf_output_put(&handle, nr);
2742 }
2743 }
2606 2744
2607 perf_output_end(&handle); 2745 perf_output_end(&handle);
2608} 2746}
2609 2747
2610/* 2748/*
2749 * read event
2750 */
2751
2752struct perf_read_event {
2753 struct perf_event_header header;
2754
2755 u32 pid;
2756 u32 tid;
2757 u64 value;
2758 u64 format[3];
2759};
2760
2761static void
2762perf_counter_read_event(struct perf_counter *counter,
2763 struct task_struct *task)
2764{
2765 struct perf_output_handle handle;
2766 struct perf_read_event event = {
2767 .header = {
2768 .type = PERF_EVENT_READ,
2769 .misc = 0,
2770 .size = sizeof(event) - sizeof(event.format),
2771 },
2772 .pid = perf_counter_pid(counter, task),
2773 .tid = perf_counter_tid(counter, task),
2774 .value = atomic64_read(&counter->count),
2775 };
2776 int ret, i = 0;
2777
2778 if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
2779 event.header.size += sizeof(u64);
2780 event.format[i++] = counter->total_time_enabled;
2781 }
2782
2783 if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
2784 event.header.size += sizeof(u64);
2785 event.format[i++] = counter->total_time_running;
2786 }
2787
2788 if (counter->attr.read_format & PERF_FORMAT_ID) {
2789 u64 id;
2790
2791 event.header.size += sizeof(u64);
2792 if (counter->parent)
2793 id = counter->parent->id;
2794 else
2795 id = counter->id;
2796
2797 event.format[i++] = id;
2798 }
2799
2800 ret = perf_output_begin(&handle, counter, event.header.size, 0, 0);
2801 if (ret)
2802 return;
2803
2804 perf_output_copy(&handle, &event, event.header.size);
2805 perf_output_end(&handle);
2806}
2807
2808/*
2611 * fork tracking 2809 * fork tracking
2612 */ 2810 */
2613 2811
@@ -2798,6 +2996,9 @@ void perf_counter_comm(struct task_struct *task)
2798{ 2996{
2799 struct perf_comm_event comm_event; 2997 struct perf_comm_event comm_event;
2800 2998
2999 if (task->perf_counter_ctxp)
3000 perf_counter_enable_on_exec(task);
3001
2801 if (!atomic_read(&nr_comm_counters)) 3002 if (!atomic_read(&nr_comm_counters))
2802 return; 3003 return;
2803 3004
@@ -3317,8 +3518,8 @@ out:
3317 put_cpu_var(perf_cpu_context); 3518 put_cpu_var(perf_cpu_context);
3318} 3519}
3319 3520
3320void 3521void __perf_swcounter_event(u32 event, u64 nr, int nmi,
3321perf_swcounter_event(u32 event, u64 nr, int nmi, struct pt_regs *regs, u64 addr) 3522 struct pt_regs *regs, u64 addr)
3322{ 3523{
3323 struct perf_sample_data data = { 3524 struct perf_sample_data data = {
3324 .regs = regs, 3525 .regs = regs,
@@ -3509,9 +3710,21 @@ static const struct pmu *tp_perf_counter_init(struct perf_counter *counter)
3509} 3710}
3510#endif 3711#endif
3511 3712
3713atomic_t perf_swcounter_enabled[PERF_COUNT_SW_MAX];
3714
3715static void sw_perf_counter_destroy(struct perf_counter *counter)
3716{
3717 u64 event = counter->attr.config;
3718
3719 WARN_ON(counter->parent);
3720
3721 atomic_dec(&perf_swcounter_enabled[event]);
3722}
3723
3512static const struct pmu *sw_perf_counter_init(struct perf_counter *counter) 3724static const struct pmu *sw_perf_counter_init(struct perf_counter *counter)
3513{ 3725{
3514 const struct pmu *pmu = NULL; 3726 const struct pmu *pmu = NULL;
3727 u64 event = counter->attr.config;
3515 3728
3516 /* 3729 /*
3517 * Software counters (currently) can't in general distinguish 3730 * Software counters (currently) can't in general distinguish
@@ -3520,7 +3733,7 @@ static const struct pmu *sw_perf_counter_init(struct perf_counter *counter)
3520 * to be kernel events, and page faults are never hypervisor 3733 * to be kernel events, and page faults are never hypervisor
3521 * events. 3734 * events.
3522 */ 3735 */
3523 switch (counter->attr.config) { 3736 switch (event) {
3524 case PERF_COUNT_SW_CPU_CLOCK: 3737 case PERF_COUNT_SW_CPU_CLOCK:
3525 pmu = &perf_ops_cpu_clock; 3738 pmu = &perf_ops_cpu_clock;
3526 3739
@@ -3541,6 +3754,10 @@ static const struct pmu *sw_perf_counter_init(struct perf_counter *counter)
3541 case PERF_COUNT_SW_PAGE_FAULTS_MAJ: 3754 case PERF_COUNT_SW_PAGE_FAULTS_MAJ:
3542 case PERF_COUNT_SW_CONTEXT_SWITCHES: 3755 case PERF_COUNT_SW_CONTEXT_SWITCHES:
3543 case PERF_COUNT_SW_CPU_MIGRATIONS: 3756 case PERF_COUNT_SW_CPU_MIGRATIONS:
3757 if (!counter->parent) {
3758 atomic_inc(&perf_swcounter_enabled[event]);
3759 counter->destroy = sw_perf_counter_destroy;
3760 }
3544 pmu = &perf_ops_generic; 3761 pmu = &perf_ops_generic;
3545 break; 3762 break;
3546 } 3763 }
@@ -3556,6 +3773,7 @@ perf_counter_alloc(struct perf_counter_attr *attr,
3556 int cpu, 3773 int cpu,
3557 struct perf_counter_context *ctx, 3774 struct perf_counter_context *ctx,
3558 struct perf_counter *group_leader, 3775 struct perf_counter *group_leader,
3776 struct perf_counter *parent_counter,
3559 gfp_t gfpflags) 3777 gfp_t gfpflags)
3560{ 3778{
3561 const struct pmu *pmu; 3779 const struct pmu *pmu;
@@ -3591,6 +3809,8 @@ perf_counter_alloc(struct perf_counter_attr *attr,
3591 counter->ctx = ctx; 3809 counter->ctx = ctx;
3592 counter->oncpu = -1; 3810 counter->oncpu = -1;
3593 3811
3812 counter->parent = parent_counter;
3813
3594 counter->ns = get_pid_ns(current->nsproxy->pid_ns); 3814 counter->ns = get_pid_ns(current->nsproxy->pid_ns);
3595 counter->id = atomic64_inc_return(&perf_counter_id); 3815 counter->id = atomic64_inc_return(&perf_counter_id);
3596 3816
@@ -3648,11 +3868,13 @@ done:
3648 3868
3649 counter->pmu = pmu; 3869 counter->pmu = pmu;
3650 3870
3651 atomic_inc(&nr_counters); 3871 if (!counter->parent) {
3652 if (counter->attr.mmap) 3872 atomic_inc(&nr_counters);
3653 atomic_inc(&nr_mmap_counters); 3873 if (counter->attr.mmap)
3654 if (counter->attr.comm) 3874 atomic_inc(&nr_mmap_counters);
3655 atomic_inc(&nr_comm_counters); 3875 if (counter->attr.comm)
3876 atomic_inc(&nr_comm_counters);
3877 }
3656 3878
3657 return counter; 3879 return counter;
3658} 3880}
@@ -3815,7 +4037,7 @@ SYSCALL_DEFINE5(perf_counter_open,
3815 } 4037 }
3816 4038
3817 counter = perf_counter_alloc(&attr, cpu, ctx, group_leader, 4039 counter = perf_counter_alloc(&attr, cpu, ctx, group_leader,
3818 GFP_KERNEL); 4040 NULL, GFP_KERNEL);
3819 ret = PTR_ERR(counter); 4041 ret = PTR_ERR(counter);
3820 if (IS_ERR(counter)) 4042 if (IS_ERR(counter))
3821 goto err_put_context; 4043 goto err_put_context;
@@ -3881,7 +4103,8 @@ inherit_counter(struct perf_counter *parent_counter,
3881 4103
3882 child_counter = perf_counter_alloc(&parent_counter->attr, 4104 child_counter = perf_counter_alloc(&parent_counter->attr,
3883 parent_counter->cpu, child_ctx, 4105 parent_counter->cpu, child_ctx,
3884 group_leader, GFP_KERNEL); 4106 group_leader, parent_counter,
4107 GFP_KERNEL);
3885 if (IS_ERR(child_counter)) 4108 if (IS_ERR(child_counter))
3886 return child_counter; 4109 return child_counter;
3887 get_ctx(child_ctx); 4110 get_ctx(child_ctx);
@@ -3904,12 +4127,6 @@ inherit_counter(struct perf_counter *parent_counter,
3904 */ 4127 */
3905 add_counter_to_ctx(child_counter, child_ctx); 4128 add_counter_to_ctx(child_counter, child_ctx);
3906 4129
3907 child_counter->parent = parent_counter;
3908 /*
3909 * inherit into child's child as well:
3910 */
3911 child_counter->attr.inherit = 1;
3912
3913 /* 4130 /*
3914 * Get a reference to the parent filp - we will fput it 4131 * Get a reference to the parent filp - we will fput it
3915 * when the child counter exits. This is safe to do because 4132 * when the child counter exits. This is safe to do because
@@ -3953,10 +4170,14 @@ static int inherit_group(struct perf_counter *parent_counter,
3953} 4170}
3954 4171
3955static void sync_child_counter(struct perf_counter *child_counter, 4172static void sync_child_counter(struct perf_counter *child_counter,
3956 struct perf_counter *parent_counter) 4173 struct task_struct *child)
3957{ 4174{
4175 struct perf_counter *parent_counter = child_counter->parent;
3958 u64 child_val; 4176 u64 child_val;
3959 4177
4178 if (child_counter->attr.inherit_stat)
4179 perf_counter_read_event(child_counter, child);
4180
3960 child_val = atomic64_read(&child_counter->count); 4181 child_val = atomic64_read(&child_counter->count);
3961 4182
3962 /* 4183 /*
@@ -3985,7 +4206,8 @@ static void sync_child_counter(struct perf_counter *child_counter,
3985 4206
3986static void 4207static void
3987__perf_counter_exit_task(struct perf_counter *child_counter, 4208__perf_counter_exit_task(struct perf_counter *child_counter,
3988 struct perf_counter_context *child_ctx) 4209 struct perf_counter_context *child_ctx,
4210 struct task_struct *child)
3989{ 4211{
3990 struct perf_counter *parent_counter; 4212 struct perf_counter *parent_counter;
3991 4213
@@ -3999,7 +4221,7 @@ __perf_counter_exit_task(struct perf_counter *child_counter,
3999 * counters need to be zapped - but otherwise linger. 4221 * counters need to be zapped - but otherwise linger.
4000 */ 4222 */
4001 if (parent_counter) { 4223 if (parent_counter) {
4002 sync_child_counter(child_counter, parent_counter); 4224 sync_child_counter(child_counter, child);
4003 free_counter(child_counter); 4225 free_counter(child_counter);
4004 } 4226 }
4005} 4227}
@@ -4061,7 +4283,7 @@ void perf_counter_exit_task(struct task_struct *child)
4061again: 4283again:
4062 list_for_each_entry_safe(child_counter, tmp, &child_ctx->counter_list, 4284 list_for_each_entry_safe(child_counter, tmp, &child_ctx->counter_list,
4063 list_entry) 4285 list_entry)
4064 __perf_counter_exit_task(child_counter, child_ctx); 4286 __perf_counter_exit_task(child_counter, child_ctx, child);
4065 4287
4066 /* 4288 /*
4067 * If the last counter was a group counter, it will have appended all 4289 * If the last counter was a group counter, it will have appended all
diff --git a/kernel/power/user.c b/kernel/power/user.c
index ed97375daae9..bf0014d6a5f0 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -23,7 +23,6 @@
23#include <linux/console.h> 23#include <linux/console.h>
24#include <linux/cpu.h> 24#include <linux/cpu.h>
25#include <linux/freezer.h> 25#include <linux/freezer.h>
26#include <linux/smp_lock.h>
27#include <scsi/scsi_scan.h> 26#include <scsi/scsi_scan.h>
28 27
29#include <asm/uaccess.h> 28#include <asm/uaccess.h>
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 61c78b2c07ba..082c320e4dbf 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -181,8 +181,8 @@ int ptrace_attach(struct task_struct *task)
181 * interference; SUID, SGID and LSM creds get determined differently 181 * interference; SUID, SGID and LSM creds get determined differently
182 * under ptrace. 182 * under ptrace.
183 */ 183 */
184 retval = mutex_lock_interruptible(&task->cred_guard_mutex); 184 retval = -ERESTARTNOINTR;
185 if (retval < 0) 185 if (mutex_lock_interruptible(&task->cred_guard_mutex))
186 goto out; 186 goto out;
187 187
188 task_lock(task); 188 task_lock(task);
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 0dccfbba6d26..7717b95c2027 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -1533,7 +1533,7 @@ void __init __rcu_init(void)
1533 int j; 1533 int j;
1534 struct rcu_node *rnp; 1534 struct rcu_node *rnp;
1535 1535
1536 printk(KERN_WARNING "Experimental hierarchical RCU implementation.\n"); 1536 printk(KERN_INFO "Hierarchical RCU implementation.\n");
1537#ifdef CONFIG_RCU_CPU_STALL_DETECTOR 1537#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
1538 printk(KERN_INFO "RCU-based detection of stalled CPUs is enabled.\n"); 1538 printk(KERN_INFO "RCU-based detection of stalled CPUs is enabled.\n");
1539#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ 1539#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
@@ -1546,7 +1546,6 @@ void __init __rcu_init(void)
1546 rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE, (void *)(long)i); 1546 rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE, (void *)(long)i);
1547 /* Register notifier for non-boot CPUs */ 1547 /* Register notifier for non-boot CPUs */
1548 register_cpu_notifier(&rcu_nb); 1548 register_cpu_notifier(&rcu_nb);
1549 printk(KERN_WARNING "Experimental hierarchical RCU init done.\n");
1550} 1549}
1551 1550
1552module_param(blimit, int, 0); 1551module_param(blimit, int, 0);
diff --git a/kernel/resource.c b/kernel/resource.c
index ac5f3a36923f..78b087221c15 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -787,7 +787,7 @@ static int __init reserve_setup(char *str)
787 static struct resource reserve[MAXRESERVE]; 787 static struct resource reserve[MAXRESERVE];
788 788
789 for (;;) { 789 for (;;) {
790 int io_start, io_num; 790 unsigned int io_start, io_num;
791 int x = reserved; 791 int x = reserved;
792 792
793 if (get_option (&str, &io_start) != 2) 793 if (get_option (&str, &io_start) != 2)
diff --git a/kernel/sched.c b/kernel/sched.c
index 7c9098d186e6..01f55ada3598 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6541,6 +6541,11 @@ SYSCALL_DEFINE0(sched_yield)
6541 return 0; 6541 return 0;
6542} 6542}
6543 6543
6544static inline int should_resched(void)
6545{
6546 return need_resched() && !(preempt_count() & PREEMPT_ACTIVE);
6547}
6548
6544static void __cond_resched(void) 6549static void __cond_resched(void)
6545{ 6550{
6546#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP 6551#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
@@ -6560,8 +6565,7 @@ static void __cond_resched(void)
6560 6565
6561int __sched _cond_resched(void) 6566int __sched _cond_resched(void)
6562{ 6567{
6563 if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) && 6568 if (should_resched()) {
6564 system_state == SYSTEM_RUNNING) {
6565 __cond_resched(); 6569 __cond_resched();
6566 return 1; 6570 return 1;
6567 } 6571 }
@@ -6579,12 +6583,12 @@ EXPORT_SYMBOL(_cond_resched);
6579 */ 6583 */
6580int cond_resched_lock(spinlock_t *lock) 6584int cond_resched_lock(spinlock_t *lock)
6581{ 6585{
6582 int resched = need_resched() && system_state == SYSTEM_RUNNING; 6586 int resched = should_resched();
6583 int ret = 0; 6587 int ret = 0;
6584 6588
6585 if (spin_needbreak(lock) || resched) { 6589 if (spin_needbreak(lock) || resched) {
6586 spin_unlock(lock); 6590 spin_unlock(lock);
6587 if (resched && need_resched()) 6591 if (resched)
6588 __cond_resched(); 6592 __cond_resched();
6589 else 6593 else
6590 cpu_relax(); 6594 cpu_relax();
@@ -6599,7 +6603,7 @@ int __sched cond_resched_softirq(void)
6599{ 6603{
6600 BUG_ON(!in_softirq()); 6604 BUG_ON(!in_softirq());
6601 6605
6602 if (need_resched() && system_state == SYSTEM_RUNNING) { 6606 if (should_resched()) {
6603 local_bh_enable(); 6607 local_bh_enable();
6604 __cond_resched(); 6608 __cond_resched();
6605 local_bh_disable(); 6609 local_bh_disable();
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 62e4ff9968b5..98e02328c67d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -335,7 +335,10 @@ static struct ctl_table kern_table[] = {
335 .data = &sysctl_timer_migration, 335 .data = &sysctl_timer_migration,
336 .maxlen = sizeof(unsigned int), 336 .maxlen = sizeof(unsigned int),
337 .mode = 0644, 337 .mode = 0644,
338 .proc_handler = &proc_dointvec, 338 .proc_handler = &proc_dointvec_minmax,
339 .strategy = &sysctl_intvec,
340 .extra1 = &zero,
341 .extra2 = &one,
339 }, 342 },
340#endif 343#endif
341 { 344 {
@@ -744,6 +747,14 @@ static struct ctl_table kern_table[] = {
744 .proc_handler = &proc_dointvec, 747 .proc_handler = &proc_dointvec,
745 }, 748 },
746 { 749 {
750 .ctl_name = CTL_UNNUMBERED,
751 .procname = "panic_on_io_nmi",
752 .data = &panic_on_io_nmi,
753 .maxlen = sizeof(int),
754 .mode = 0644,
755 .proc_handler = &proc_dointvec,
756 },
757 {
747 .ctl_name = KERN_BOOTLOADER_TYPE, 758 .ctl_name = KERN_BOOTLOADER_TYPE,
748 .procname = "bootloader_type", 759 .procname = "bootloader_type",
749 .data = &bootloader_type, 760 .data = &bootloader_type,
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index c994530d166d..4cde8b9c716f 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -96,7 +96,7 @@ static DEFINE_MUTEX(show_mutex);
96/* 96/*
97 * Collection status, active/inactive: 97 * Collection status, active/inactive:
98 */ 98 */
99static int __read_mostly active; 99int __read_mostly timer_stats_active;
100 100
101/* 101/*
102 * Beginning/end timestamps of measurement: 102 * Beginning/end timestamps of measurement:
@@ -242,7 +242,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
242 struct entry *entry, input; 242 struct entry *entry, input;
243 unsigned long flags; 243 unsigned long flags;
244 244
245 if (likely(!active)) 245 if (likely(!timer_stats_active))
246 return; 246 return;
247 247
248 lock = &per_cpu(lookup_lock, raw_smp_processor_id()); 248 lock = &per_cpu(lookup_lock, raw_smp_processor_id());
@@ -254,7 +254,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
254 input.timer_flag = timer_flag; 254 input.timer_flag = timer_flag;
255 255
256 spin_lock_irqsave(lock, flags); 256 spin_lock_irqsave(lock, flags);
257 if (!active) 257 if (!timer_stats_active)
258 goto out_unlock; 258 goto out_unlock;
259 259
260 entry = tstat_lookup(&input, comm); 260 entry = tstat_lookup(&input, comm);
@@ -290,7 +290,7 @@ static int tstats_show(struct seq_file *m, void *v)
290 /* 290 /*
291 * If still active then calculate up to now: 291 * If still active then calculate up to now:
292 */ 292 */
293 if (active) 293 if (timer_stats_active)
294 time_stop = ktime_get(); 294 time_stop = ktime_get();
295 295
296 time = ktime_sub(time_stop, time_start); 296 time = ktime_sub(time_stop, time_start);
@@ -368,18 +368,18 @@ static ssize_t tstats_write(struct file *file, const char __user *buf,
368 mutex_lock(&show_mutex); 368 mutex_lock(&show_mutex);
369 switch (ctl[0]) { 369 switch (ctl[0]) {
370 case '0': 370 case '0':
371 if (active) { 371 if (timer_stats_active) {
372 active = 0; 372 timer_stats_active = 0;
373 time_stop = ktime_get(); 373 time_stop = ktime_get();
374 sync_access(); 374 sync_access();
375 } 375 }
376 break; 376 break;
377 case '1': 377 case '1':
378 if (!active) { 378 if (!timer_stats_active) {
379 reset_entries(); 379 reset_entries();
380 time_start = ktime_get(); 380 time_start = ktime_get();
381 smp_mb(); 381 smp_mb();
382 active = 1; 382 timer_stats_active = 1;
383 } 383 }
384 break; 384 break;
385 default: 385 default:
diff --git a/kernel/timer.c b/kernel/timer.c
index 54d3912f8cad..0b36b9e5cc8b 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -380,6 +380,8 @@ static void timer_stats_account_timer(struct timer_list *timer)
380{ 380{
381 unsigned int flag = 0; 381 unsigned int flag = 0;
382 382
383 if (likely(!timer->start_site))
384 return;
383 if (unlikely(tbase_get_deferrable(timer->base))) 385 if (unlikely(tbase_get_deferrable(timer->base)))
384 flag |= TIMER_STATS_FLAG_DEFERRABLE; 386 flag |= TIMER_STATS_FLAG_DEFERRABLE;
385 387
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 1551f47e7669..019f380fd764 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -226,13 +226,13 @@ config BOOT_TRACER
226 the timings of the initcalls and traces key events and the identity 226 the timings of the initcalls and traces key events and the identity
227 of tasks that can cause boot delays, such as context-switches. 227 of tasks that can cause boot delays, such as context-switches.
228 228
229 Its aim is to be parsed by the /scripts/bootgraph.pl tool to 229 Its aim is to be parsed by the scripts/bootgraph.pl tool to
230 produce pretty graphics about boot inefficiencies, giving a visual 230 produce pretty graphics about boot inefficiencies, giving a visual
231 representation of the delays during initcalls - but the raw 231 representation of the delays during initcalls - but the raw
232 /debug/tracing/trace text output is readable too. 232 /debug/tracing/trace text output is readable too.
233 233
234 You must pass in ftrace=initcall to the kernel command line 234 You must pass in initcall_debug and ftrace=initcall to the kernel
235 to enable this on bootup. 235 command line to enable this on bootup.
236 236
237config TRACE_BRANCH_PROFILING 237config TRACE_BRANCH_PROFILING
238 bool 238 bool
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 39af8af6fc30..1090b0aed9ba 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/debugfs.h> 24#include <linux/debugfs.h>
25#include <linux/smp_lock.h>
25#include <linux/time.h> 26#include <linux/time.h>
26#include <linux/uaccess.h> 27#include <linux/uaccess.h>
27 28
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 3718d55fb4c3..bce9e01a29c8 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -291,7 +291,9 @@ function_stat_next(void *v, int idx)
291 pg = (struct ftrace_profile_page *)((unsigned long)rec & PAGE_MASK); 291 pg = (struct ftrace_profile_page *)((unsigned long)rec & PAGE_MASK);
292 292
293 again: 293 again:
294 rec++; 294 if (idx != 0)
295 rec++;
296
295 if ((void *)rec >= (void *)&pg->records[pg->index]) { 297 if ((void *)rec >= (void *)&pg->records[pg->index]) {
296 pg = pg->next; 298 pg = pg->next;
297 if (!pg) 299 if (!pg)
@@ -1417,10 +1419,20 @@ static void *t_hash_start(struct seq_file *m, loff_t *pos)
1417{ 1419{
1418 struct ftrace_iterator *iter = m->private; 1420 struct ftrace_iterator *iter = m->private;
1419 void *p = NULL; 1421 void *p = NULL;
1422 loff_t l;
1423
1424 if (!(iter->flags & FTRACE_ITER_HASH))
1425 *pos = 0;
1420 1426
1421 iter->flags |= FTRACE_ITER_HASH; 1427 iter->flags |= FTRACE_ITER_HASH;
1422 1428
1423 return t_hash_next(m, p, pos); 1429 iter->hidx = 0;
1430 for (l = 0; l <= *pos; ) {
1431 p = t_hash_next(m, p, &l);
1432 if (!p)
1433 break;
1434 }
1435 return p;
1424} 1436}
1425 1437
1426static int t_hash_show(struct seq_file *m, void *v) 1438static int t_hash_show(struct seq_file *m, void *v)
@@ -1467,8 +1479,6 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
1467 iter->pg = iter->pg->next; 1479 iter->pg = iter->pg->next;
1468 iter->idx = 0; 1480 iter->idx = 0;
1469 goto retry; 1481 goto retry;
1470 } else {
1471 iter->idx = -1;
1472 } 1482 }
1473 } else { 1483 } else {
1474 rec = &iter->pg->records[iter->idx++]; 1484 rec = &iter->pg->records[iter->idx++];
@@ -1497,6 +1507,7 @@ static void *t_start(struct seq_file *m, loff_t *pos)
1497{ 1507{
1498 struct ftrace_iterator *iter = m->private; 1508 struct ftrace_iterator *iter = m->private;
1499 void *p = NULL; 1509 void *p = NULL;
1510 loff_t l;
1500 1511
1501 mutex_lock(&ftrace_lock); 1512 mutex_lock(&ftrace_lock);
1502 /* 1513 /*
@@ -1508,23 +1519,21 @@ static void *t_start(struct seq_file *m, loff_t *pos)
1508 if (*pos > 0) 1519 if (*pos > 0)
1509 return t_hash_start(m, pos); 1520 return t_hash_start(m, pos);
1510 iter->flags |= FTRACE_ITER_PRINTALL; 1521 iter->flags |= FTRACE_ITER_PRINTALL;
1511 (*pos)++;
1512 return iter; 1522 return iter;
1513 } 1523 }
1514 1524
1515 if (iter->flags & FTRACE_ITER_HASH) 1525 if (iter->flags & FTRACE_ITER_HASH)
1516 return t_hash_start(m, pos); 1526 return t_hash_start(m, pos);
1517 1527
1518 if (*pos > 0) { 1528 iter->pg = ftrace_pages_start;
1519 if (iter->idx < 0) 1529 iter->idx = 0;
1520 return p; 1530 for (l = 0; l <= *pos; ) {
1521 (*pos)--; 1531 p = t_next(m, p, &l);
1522 iter->idx--; 1532 if (!p)
1533 break;
1523 } 1534 }
1524 1535
1525 p = t_next(m, p, pos); 1536 if (!p && iter->flags & FTRACE_ITER_FILTER)
1526
1527 if (!p)
1528 return t_hash_start(m, pos); 1537 return t_hash_start(m, pos);
1529 1538
1530 return p; 1539 return p;
@@ -2500,32 +2509,31 @@ int ftrace_graph_count;
2500unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly; 2509unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly;
2501 2510
2502static void * 2511static void *
2503g_next(struct seq_file *m, void *v, loff_t *pos) 2512__g_next(struct seq_file *m, loff_t *pos)
2504{ 2513{
2505 unsigned long *array = m->private; 2514 unsigned long *array = m->private;
2506 int index = *pos;
2507 2515
2508 (*pos)++; 2516 if (*pos >= ftrace_graph_count)
2509
2510 if (index >= ftrace_graph_count)
2511 return NULL; 2517 return NULL;
2518 return &array[*pos];
2519}
2512 2520
2513 return &array[index]; 2521static void *
2522g_next(struct seq_file *m, void *v, loff_t *pos)
2523{
2524 (*pos)++;
2525 return __g_next(m, pos);
2514} 2526}
2515 2527
2516static void *g_start(struct seq_file *m, loff_t *pos) 2528static void *g_start(struct seq_file *m, loff_t *pos)
2517{ 2529{
2518 void *p = NULL;
2519
2520 mutex_lock(&graph_lock); 2530 mutex_lock(&graph_lock);
2521 2531
2522 /* Nothing, tell g_show to print all functions are enabled */ 2532 /* Nothing, tell g_show to print all functions are enabled */
2523 if (!ftrace_graph_count && !*pos) 2533 if (!ftrace_graph_count && !*pos)
2524 return (void *)1; 2534 return (void *)1;
2525 2535
2526 p = g_next(m, p, pos); 2536 return __g_next(m, pos);
2527
2528 return p;
2529} 2537}
2530 2538
2531static void g_stop(struct seq_file *m, void *p) 2539static void g_stop(struct seq_file *m, void *p)
@@ -3152,10 +3160,10 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
3152 3160
3153 ret = proc_dointvec(table, write, file, buffer, lenp, ppos); 3161 ret = proc_dointvec(table, write, file, buffer, lenp, ppos);
3154 3162
3155 if (ret || !write || (last_ftrace_enabled == ftrace_enabled)) 3163 if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled))
3156 goto out; 3164 goto out;
3157 3165
3158 last_ftrace_enabled = ftrace_enabled; 3166 last_ftrace_enabled = !!ftrace_enabled;
3159 3167
3160 if (ftrace_enabled) { 3168 if (ftrace_enabled) {
3161 3169
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 04dac2638258..bf27bb7a63e2 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1563,6 +1563,8 @@ rb_reserve_next_event(struct ring_buffer_per_cpu *cpu_buffer,
1563 return NULL; 1563 return NULL;
1564} 1564}
1565 1565
1566#ifdef CONFIG_TRACING
1567
1566#define TRACE_RECURSIVE_DEPTH 16 1568#define TRACE_RECURSIVE_DEPTH 16
1567 1569
1568static int trace_recursive_lock(void) 1570static int trace_recursive_lock(void)
@@ -1593,6 +1595,13 @@ static void trace_recursive_unlock(void)
1593 current->trace_recursion--; 1595 current->trace_recursion--;
1594} 1596}
1595 1597
1598#else
1599
1600#define trace_recursive_lock() (0)
1601#define trace_recursive_unlock() do { } while (0)
1602
1603#endif
1604
1596static DEFINE_PER_CPU(int, rb_need_resched); 1605static DEFINE_PER_CPU(int, rb_need_resched);
1597 1606
1598/** 1607/**
@@ -3104,6 +3113,7 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
3104} 3113}
3105EXPORT_SYMBOL_GPL(ring_buffer_read_page); 3114EXPORT_SYMBOL_GPL(ring_buffer_read_page);
3106 3115
3116#ifdef CONFIG_TRACING
3107static ssize_t 3117static ssize_t
3108rb_simple_read(struct file *filp, char __user *ubuf, 3118rb_simple_read(struct file *filp, char __user *ubuf,
3109 size_t cnt, loff_t *ppos) 3119 size_t cnt, loff_t *ppos)
@@ -3171,6 +3181,7 @@ static __init int rb_init_debugfs(void)
3171} 3181}
3172 3182
3173fs_initcall(rb_init_debugfs); 3183fs_initcall(rb_init_debugfs);
3184#endif
3174 3185
3175#ifdef CONFIG_HOTPLUG_CPU 3186#ifdef CONFIG_HOTPLUG_CPU
3176static int rb_cpu_notify(struct notifier_block *self, 3187static int rb_cpu_notify(struct notifier_block *self,
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 076fa6f0ee48..8bc8d8afea6a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -17,6 +17,7 @@
17#include <linux/writeback.h> 17#include <linux/writeback.h>
18#include <linux/kallsyms.h> 18#include <linux/kallsyms.h>
19#include <linux/seq_file.h> 19#include <linux/seq_file.h>
20#include <linux/smp_lock.h>
20#include <linux/notifier.h> 21#include <linux/notifier.h>
21#include <linux/irqflags.h> 22#include <linux/irqflags.h>
22#include <linux/debugfs.h> 23#include <linux/debugfs.h>
@@ -284,13 +285,12 @@ void trace_wake_up(void)
284static int __init set_buf_size(char *str) 285static int __init set_buf_size(char *str)
285{ 286{
286 unsigned long buf_size; 287 unsigned long buf_size;
287 int ret;
288 288
289 if (!str) 289 if (!str)
290 return 0; 290 return 0;
291 ret = strict_strtoul(str, 0, &buf_size); 291 buf_size = memparse(str, &str);
292 /* nr_entries can not be zero */ 292 /* nr_entries can not be zero */
293 if (ret < 0 || buf_size == 0) 293 if (buf_size == 0)
294 return 0; 294 return 0;
295 trace_buf_size = buf_size; 295 trace_buf_size = buf_size;
296 return 1; 296 return 1;
@@ -2053,25 +2053,23 @@ static int tracing_open(struct inode *inode, struct file *file)
2053static void * 2053static void *
2054t_next(struct seq_file *m, void *v, loff_t *pos) 2054t_next(struct seq_file *m, void *v, loff_t *pos)
2055{ 2055{
2056 struct tracer *t = m->private; 2056 struct tracer *t = v;
2057 2057
2058 (*pos)++; 2058 (*pos)++;
2059 2059
2060 if (t) 2060 if (t)
2061 t = t->next; 2061 t = t->next;
2062 2062
2063 m->private = t;
2064
2065 return t; 2063 return t;
2066} 2064}
2067 2065
2068static void *t_start(struct seq_file *m, loff_t *pos) 2066static void *t_start(struct seq_file *m, loff_t *pos)
2069{ 2067{
2070 struct tracer *t = m->private; 2068 struct tracer *t;
2071 loff_t l = 0; 2069 loff_t l = 0;
2072 2070
2073 mutex_lock(&trace_types_lock); 2071 mutex_lock(&trace_types_lock);
2074 for (; t && l < *pos; t = t_next(m, t, &l)) 2072 for (t = trace_types; t && l < *pos; t = t_next(m, t, &l))
2075 ; 2073 ;
2076 2074
2077 return t; 2075 return t;
@@ -2107,18 +2105,10 @@ static struct seq_operations show_traces_seq_ops = {
2107 2105
2108static int show_traces_open(struct inode *inode, struct file *file) 2106static int show_traces_open(struct inode *inode, struct file *file)
2109{ 2107{
2110 int ret;
2111
2112 if (tracing_disabled) 2108 if (tracing_disabled)
2113 return -ENODEV; 2109 return -ENODEV;
2114 2110
2115 ret = seq_open(file, &show_traces_seq_ops); 2111 return seq_open(file, &show_traces_seq_ops);
2116 if (!ret) {
2117 struct seq_file *m = file->private_data;
2118 m->private = trace_types;
2119 }
2120
2121 return ret;
2122} 2112}
2123 2113
2124static ssize_t 2114static ssize_t
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 6e735d4771f8..3548ae5cc780 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -597,6 +597,7 @@ print_graph_function(struct trace_iterator *iter)
597 597
598extern struct pid *ftrace_pid_trace; 598extern struct pid *ftrace_pid_trace;
599 599
600#ifdef CONFIG_FUNCTION_TRACER
600static inline int ftrace_trace_task(struct task_struct *task) 601static inline int ftrace_trace_task(struct task_struct *task)
601{ 602{
602 if (!ftrace_pid_trace) 603 if (!ftrace_pid_trace)
@@ -604,6 +605,12 @@ static inline int ftrace_trace_task(struct task_struct *task)
604 605
605 return test_tsk_trace_trace(task); 606 return test_tsk_trace_trace(task);
606} 607}
608#else
609static inline int ftrace_trace_task(struct task_struct *task)
610{
611 return 1;
612}
613#endif
607 614
608/* 615/*
609 * trace_iterator_flags is an enumeration that defines bit 616 * trace_iterator_flags is an enumeration that defines bit
diff --git a/kernel/trace/trace_event_types.h b/kernel/trace/trace_event_types.h
index 5e32e375134d..6db005e12487 100644
--- a/kernel/trace/trace_event_types.h
+++ b/kernel/trace/trace_event_types.h
@@ -26,6 +26,9 @@ TRACE_EVENT_FORMAT(funcgraph_exit, TRACE_GRAPH_RET,
26 ftrace_graph_ret_entry, ignore, 26 ftrace_graph_ret_entry, ignore,
27 TRACE_STRUCT( 27 TRACE_STRUCT(
28 TRACE_FIELD(unsigned long, ret.func, func) 28 TRACE_FIELD(unsigned long, ret.func, func)
29 TRACE_FIELD(unsigned long long, ret.calltime, calltime)
30 TRACE_FIELD(unsigned long long, ret.rettime, rettime)
31 TRACE_FIELD(unsigned long, ret.overrun, overrun)
29 TRACE_FIELD(int, ret.depth, depth) 32 TRACE_FIELD(int, ret.depth, depth)
30 ), 33 ),
31 TP_RAW_FMT("<-- %lx (%d)") 34 TP_RAW_FMT("<-- %lx (%d)")
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index aa08be69a1b6..53c8fd376a88 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -300,10 +300,18 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
300 300
301static void *t_start(struct seq_file *m, loff_t *pos) 301static void *t_start(struct seq_file *m, loff_t *pos)
302{ 302{
303 struct ftrace_event_call *call = NULL;
304 loff_t l;
305
303 mutex_lock(&event_mutex); 306 mutex_lock(&event_mutex);
304 if (*pos == 0) 307
305 m->private = ftrace_events.next; 308 m->private = ftrace_events.next;
306 return t_next(m, NULL, pos); 309 for (l = 0; l <= *pos; ) {
310 call = t_next(m, NULL, &l);
311 if (!call)
312 break;
313 }
314 return call;
307} 315}
308 316
309static void * 317static void *
@@ -332,10 +340,18 @@ s_next(struct seq_file *m, void *v, loff_t *pos)
332 340
333static void *s_start(struct seq_file *m, loff_t *pos) 341static void *s_start(struct seq_file *m, loff_t *pos)
334{ 342{
343 struct ftrace_event_call *call = NULL;
344 loff_t l;
345
335 mutex_lock(&event_mutex); 346 mutex_lock(&event_mutex);
336 if (*pos == 0) 347
337 m->private = ftrace_events.next; 348 m->private = ftrace_events.next;
338 return s_next(m, NULL, pos); 349 for (l = 0; l <= *pos; ) {
350 call = s_next(m, NULL, &l);
351 if (!call)
352 break;
353 }
354 return call;
339} 355}
340 356
341static int t_show(struct seq_file *m, void *v) 357static int t_show(struct seq_file *m, void *v)
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 90f134764837..7402144bff21 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -302,8 +302,7 @@ ftrace_trace_onoff_print(struct seq_file *m, unsigned long ip,
302 if (count == -1) 302 if (count == -1)
303 seq_printf(m, ":unlimited\n"); 303 seq_printf(m, ":unlimited\n");
304 else 304 else
305 seq_printf(m, ":count=%ld", count); 305 seq_printf(m, ":count=%ld\n", count);
306 seq_putc(m, '\n');
307 306
308 return 0; 307 return 0;
309} 308}
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 7938f3ae93e3..e0c2545622e8 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -27,8 +27,7 @@ void trace_print_seq(struct seq_file *m, struct trace_seq *s)
27{ 27{
28 int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len; 28 int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len;
29 29
30 s->buffer[len] = 0; 30 seq_write(m, s->buffer, len);
31 seq_puts(m, s->buffer);
32 31
33 trace_seq_init(s); 32 trace_seq_init(s);
34} 33}
diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
index 9bece9687b62..7b6278110827 100644
--- a/kernel/trace/trace_printk.c
+++ b/kernel/trace/trace_printk.c
@@ -155,25 +155,19 @@ int __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap)
155EXPORT_SYMBOL_GPL(__ftrace_vprintk); 155EXPORT_SYMBOL_GPL(__ftrace_vprintk);
156 156
157static void * 157static void *
158t_next(struct seq_file *m, void *v, loff_t *pos) 158t_start(struct seq_file *m, loff_t *pos)
159{ 159{
160 const char **fmt = m->private; 160 const char **fmt = __start___trace_bprintk_fmt + *pos;
161 const char **next = fmt;
162
163 (*pos)++;
164 161
165 if ((unsigned long)fmt >= (unsigned long)__stop___trace_bprintk_fmt) 162 if ((unsigned long)fmt >= (unsigned long)__stop___trace_bprintk_fmt)
166 return NULL; 163 return NULL;
167
168 next = fmt;
169 m->private = ++next;
170
171 return fmt; 164 return fmt;
172} 165}
173 166
174static void *t_start(struct seq_file *m, loff_t *pos) 167static void *t_next(struct seq_file *m, void * v, loff_t *pos)
175{ 168{
176 return t_next(m, NULL, pos); 169 (*pos)++;
170 return t_start(m, pos);
177} 171}
178 172
179static int t_show(struct seq_file *m, void *v) 173static int t_show(struct seq_file *m, void *v)
@@ -224,15 +218,7 @@ static const struct seq_operations show_format_seq_ops = {
224static int 218static int
225ftrace_formats_open(struct inode *inode, struct file *file) 219ftrace_formats_open(struct inode *inode, struct file *file)
226{ 220{
227 int ret; 221 return seq_open(file, &show_format_seq_ops);
228
229 ret = seq_open(file, &show_format_seq_ops);
230 if (!ret) {
231 struct seq_file *m = file->private_data;
232
233 m->private = __start___trace_bprintk_fmt;
234 }
235 return ret;
236} 222}
237 223
238static const struct file_operations ftrace_formats_fops = { 224static const struct file_operations ftrace_formats_fops = {
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 2d7aebd71dbd..e644af910124 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -326,10 +326,10 @@ stack_trace_sysctl(struct ctl_table *table, int write,
326 ret = proc_dointvec(table, write, file, buffer, lenp, ppos); 326 ret = proc_dointvec(table, write, file, buffer, lenp, ppos);
327 327
328 if (ret || !write || 328 if (ret || !write ||
329 (last_stack_tracer_enabled == stack_tracer_enabled)) 329 (last_stack_tracer_enabled == !!stack_tracer_enabled))
330 goto out; 330 goto out;
331 331
332 last_stack_tracer_enabled = stack_tracer_enabled; 332 last_stack_tracer_enabled = !!stack_tracer_enabled;
333 333
334 if (stack_tracer_enabled) 334 if (stack_tracer_enabled)
335 register_ftrace_function(&trace_ops); 335 register_ftrace_function(&trace_ops);
diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
index c00643733f4c..e66f5e493342 100644
--- a/kernel/trace/trace_stat.c
+++ b/kernel/trace/trace_stat.c
@@ -199,17 +199,13 @@ static void *stat_seq_start(struct seq_file *s, loff_t *pos)
199 mutex_lock(&session->stat_mutex); 199 mutex_lock(&session->stat_mutex);
200 200
201 /* If we are in the beginning of the file, print the headers */ 201 /* If we are in the beginning of the file, print the headers */
202 if (!*pos && session->ts->stat_headers) { 202 if (!*pos && session->ts->stat_headers)
203 (*pos)++;
204 return SEQ_START_TOKEN; 203 return SEQ_START_TOKEN;
205 }
206 204
207 node = rb_first(&session->stat_root); 205 node = rb_first(&session->stat_root);
208 for (i = 0; node && i < *pos; i++) 206 for (i = 0; node && i < *pos; i++)
209 node = rb_next(node); 207 node = rb_next(node);
210 208
211 (*pos)++;
212
213 return node; 209 return node;
214} 210}
215 211
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 4c32b1a1a06e..12327b2bb785 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -359,6 +359,18 @@ config DEBUG_KMEMLEAK
359 In order to access the kmemleak file, debugfs needs to be 359 In order to access the kmemleak file, debugfs needs to be
360 mounted (usually at /sys/kernel/debug). 360 mounted (usually at /sys/kernel/debug).
361 361
362config DEBUG_KMEMLEAK_EARLY_LOG_SIZE
363 int "Maximum kmemleak early log entries"
364 depends on DEBUG_KMEMLEAK
365 range 200 2000
366 default 400
367 help
368 Kmemleak must track all the memory allocations to avoid
369 reporting false positives. Since memory may be allocated or
370 freed before kmemleak is initialised, an early log buffer is
371 used to store these actions. If kmemleak reports "early log
372 buffer exceeded", please increase this value.
373
362config DEBUG_KMEMLEAK_TEST 374config DEBUG_KMEMLEAK_TEST
363 tristate "Simple test for the kernel memory leak detector" 375 tristate "Simple test for the kernel memory leak detector"
364 depends on DEBUG_KMEMLEAK 376 depends on DEBUG_KMEMLEAK
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 3b93129a968c..65b0d99b6d0a 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -716,7 +716,7 @@ void dma_debug_init(u32 num_entries)
716 716
717 for (i = 0; i < HASH_SIZE; ++i) { 717 for (i = 0; i < HASH_SIZE; ++i) {
718 INIT_LIST_HEAD(&dma_entry_hash[i].list); 718 INIT_LIST_HEAD(&dma_entry_hash[i].list);
719 dma_entry_hash[i].lock = SPIN_LOCK_UNLOCKED; 719 spin_lock_init(&dma_entry_hash[i].lock);
720 } 720 }
721 721
722 if (dma_debug_fs_init() != 0) { 722 if (dma_debug_fs_init() != 0) {
@@ -856,22 +856,21 @@ static void check_for_stack(struct device *dev, void *addr)
856 "stack [addr=%p]\n", addr); 856 "stack [addr=%p]\n", addr);
857} 857}
858 858
859static inline bool overlap(void *addr, u64 size, void *start, void *end) 859static inline bool overlap(void *addr, unsigned long len, void *start, void *end)
860{ 860{
861 void *addr2 = (char *)addr + size; 861 unsigned long a1 = (unsigned long)addr;
862 unsigned long b1 = a1 + len;
863 unsigned long a2 = (unsigned long)start;
864 unsigned long b2 = (unsigned long)end;
862 865
863 return ((addr >= start && addr < end) || 866 return !(b1 <= a2 || a1 >= b2);
864 (addr2 >= start && addr2 < end) ||
865 ((addr < start) && (addr2 >= end)));
866} 867}
867 868
868static void check_for_illegal_area(struct device *dev, void *addr, u64 size) 869static void check_for_illegal_area(struct device *dev, void *addr, unsigned long len)
869{ 870{
870 if (overlap(addr, size, _text, _etext) || 871 if (overlap(addr, len, _text, _etext) ||
871 overlap(addr, size, __start_rodata, __end_rodata)) 872 overlap(addr, len, __start_rodata, __end_rodata))
872 err_printk(dev, NULL, "DMA-API: device driver maps " 873 err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
873 "memory from kernel text or rodata "
874 "[addr=%p] [size=%llu]\n", addr, size);
875} 874}
876 875
877static void check_sync(struct device *dev, 876static void check_sync(struct device *dev,
@@ -969,7 +968,8 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
969 entry->type = dma_debug_single; 968 entry->type = dma_debug_single;
970 969
971 if (!PageHighMem(page)) { 970 if (!PageHighMem(page)) {
972 void *addr = ((char *)page_address(page)) + offset; 971 void *addr = page_address(page) + offset;
972
973 check_for_stack(dev, addr); 973 check_for_stack(dev, addr);
974 check_for_illegal_area(dev, addr, size); 974 check_for_illegal_area(dev, addr, size);
975 } 975 }
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 493b468a5035..c86edd244294 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -283,7 +283,6 @@ static wait_queue_head_t congestion_wqh[2] = {
283 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1]) 283 __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
284 }; 284 };
285 285
286
287void clear_bdi_congested(struct backing_dev_info *bdi, int sync) 286void clear_bdi_congested(struct backing_dev_info *bdi, int sync)
288{ 287{
289 enum bdi_state bit; 288 enum bdi_state bit;
@@ -308,18 +307,18 @@ EXPORT_SYMBOL(set_bdi_congested);
308 307
309/** 308/**
310 * congestion_wait - wait for a backing_dev to become uncongested 309 * congestion_wait - wait for a backing_dev to become uncongested
311 * @rw: READ or WRITE 310 * @sync: SYNC or ASYNC IO
312 * @timeout: timeout in jiffies 311 * @timeout: timeout in jiffies
313 * 312 *
314 * Waits for up to @timeout jiffies for a backing_dev (any backing_dev) to exit 313 * Waits for up to @timeout jiffies for a backing_dev (any backing_dev) to exit
315 * write congestion. If no backing_devs are congested then just wait for the 314 * write congestion. If no backing_devs are congested then just wait for the
316 * next write to be completed. 315 * next write to be completed.
317 */ 316 */
318long congestion_wait(int rw, long timeout) 317long congestion_wait(int sync, long timeout)
319{ 318{
320 long ret; 319 long ret;
321 DEFINE_WAIT(wait); 320 DEFINE_WAIT(wait);
322 wait_queue_head_t *wqh = &congestion_wqh[rw]; 321 wait_queue_head_t *wqh = &congestion_wqh[sync];
323 322
324 prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE); 323 prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE);
325 ret = io_schedule_timeout(timeout); 324 ret = io_schedule_timeout(timeout);
diff --git a/mm/bootmem.c b/mm/bootmem.c
index d2a9ce952768..701740c9e81b 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -12,6 +12,7 @@
12#include <linux/pfn.h> 12#include <linux/pfn.h>
13#include <linux/bootmem.h> 13#include <linux/bootmem.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kmemleak.h>
15 16
16#include <asm/bug.h> 17#include <asm/bug.h>
17#include <asm/io.h> 18#include <asm/io.h>
@@ -335,6 +336,8 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
335{ 336{
336 unsigned long start, end; 337 unsigned long start, end;
337 338
339 kmemleak_free_part(__va(physaddr), size);
340
338 start = PFN_UP(physaddr); 341 start = PFN_UP(physaddr);
339 end = PFN_DOWN(physaddr + size); 342 end = PFN_DOWN(physaddr + size);
340 343
@@ -354,6 +357,8 @@ void __init free_bootmem(unsigned long addr, unsigned long size)
354{ 357{
355 unsigned long start, end; 358 unsigned long start, end;
356 359
360 kmemleak_free_part(__va(addr), size);
361
357 start = PFN_UP(addr); 362 start = PFN_UP(addr);
358 end = PFN_DOWN(addr + size); 363 end = PFN_DOWN(addr + size);
359 364
@@ -516,6 +521,7 @@ find_block:
516 region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) + 521 region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) +
517 start_off); 522 start_off);
518 memset(region, 0, size); 523 memset(region, 0, size);
524 kmemleak_alloc(region, size, 1, 0);
519 return region; 525 return region;
520 } 526 }
521 527
diff --git a/mm/dmapool.c b/mm/dmapool.c
index b1f0885dda22..3df063706f53 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -86,10 +86,12 @@ show_pools(struct device *dev, struct device_attribute *attr, char *buf)
86 unsigned pages = 0; 86 unsigned pages = 0;
87 unsigned blocks = 0; 87 unsigned blocks = 0;
88 88
89 spin_lock_irq(&pool->lock);
89 list_for_each_entry(page, &pool->page_list, page_list) { 90 list_for_each_entry(page, &pool->page_list, page_list) {
90 pages++; 91 pages++;
91 blocks += page->in_use; 92 blocks += page->in_use;
92 } 93 }
94 spin_unlock_irq(&pool->lock);
93 95
94 /* per-pool info, no real statistics yet */ 96 /* per-pool info, no real statistics yet */
95 temp = scnprintf(next, size, "%-16s %4u %4Zu %4Zu %2u\n", 97 temp = scnprintf(next, size, "%-16s %4u %4Zu %4Zu %2u\n",
diff --git a/mm/filemap.c b/mm/filemap.c
index 22396713feb9..ccea3b665c12 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2272,6 +2272,7 @@ again:
2272 pagefault_enable(); 2272 pagefault_enable();
2273 flush_dcache_page(page); 2273 flush_dcache_page(page);
2274 2274
2275 mark_page_accessed(page);
2275 status = a_ops->write_end(file, mapping, pos, bytes, copied, 2276 status = a_ops->write_end(file, mapping, pos, bytes, copied,
2276 page, fsdata); 2277 page, fsdata);
2277 if (unlikely(status < 0)) 2278 if (unlikely(status < 0))
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index c96f2c8700aa..5aabd41ffb8f 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -48,10 +48,10 @@
48 * scanned. This list is only modified during a scanning episode when the 48 * scanned. This list is only modified during a scanning episode when the
49 * scan_mutex is held. At the end of a scan, the gray_list is always empty. 49 * scan_mutex is held. At the end of a scan, the gray_list is always empty.
50 * Note that the kmemleak_object.use_count is incremented when an object is 50 * Note that the kmemleak_object.use_count is incremented when an object is
51 * added to the gray_list and therefore cannot be freed 51 * added to the gray_list and therefore cannot be freed. This mutex also
52 * - kmemleak_mutex (mutex): prevents multiple users of the "kmemleak" debugfs 52 * prevents multiple users of the "kmemleak" debugfs file together with
53 * file together with modifications to the memory scanning parameters 53 * modifications to the memory scanning parameters including the scan_thread
54 * including the scan_thread pointer 54 * pointer
55 * 55 *
56 * The kmemleak_object structures have a use_count incremented or decremented 56 * The kmemleak_object structures have a use_count incremented or decremented
57 * using the get_object()/put_object() functions. When the use_count becomes 57 * using the get_object()/put_object() functions. When the use_count becomes
@@ -103,11 +103,10 @@
103 * Kmemleak configuration and common defines. 103 * Kmemleak configuration and common defines.
104 */ 104 */
105#define MAX_TRACE 16 /* stack trace length */ 105#define MAX_TRACE 16 /* stack trace length */
106#define REPORTS_NR 50 /* maximum number of reported leaks */
107#define MSECS_MIN_AGE 5000 /* minimum object age for reporting */ 106#define MSECS_MIN_AGE 5000 /* minimum object age for reporting */
108#define MSECS_SCAN_YIELD 10 /* CPU yielding period */
109#define SECS_FIRST_SCAN 60 /* delay before the first scan */ 107#define SECS_FIRST_SCAN 60 /* delay before the first scan */
110#define SECS_SCAN_WAIT 600 /* subsequent auto scanning delay */ 108#define SECS_SCAN_WAIT 600 /* subsequent auto scanning delay */
109#define GRAY_LIST_PASSES 25 /* maximum number of gray list scans */
111 110
112#define BYTES_PER_POINTER sizeof(void *) 111#define BYTES_PER_POINTER sizeof(void *)
113 112
@@ -159,6 +158,8 @@ struct kmemleak_object {
159#define OBJECT_REPORTED (1 << 1) 158#define OBJECT_REPORTED (1 << 1)
160/* flag set to not scan the object */ 159/* flag set to not scan the object */
161#define OBJECT_NO_SCAN (1 << 2) 160#define OBJECT_NO_SCAN (1 << 2)
161/* flag set on newly allocated objects */
162#define OBJECT_NEW (1 << 3)
162 163
163/* the list of all allocated objects */ 164/* the list of all allocated objects */
164static LIST_HEAD(object_list); 165static LIST_HEAD(object_list);
@@ -186,22 +187,16 @@ static atomic_t kmemleak_error = ATOMIC_INIT(0);
186static unsigned long min_addr = ULONG_MAX; 187static unsigned long min_addr = ULONG_MAX;
187static unsigned long max_addr; 188static unsigned long max_addr;
188 189
189/* used for yielding the CPU to other tasks during scanning */
190static unsigned long next_scan_yield;
191static struct task_struct *scan_thread; 190static struct task_struct *scan_thread;
192static unsigned long jiffies_scan_yield; 191/* used to avoid reporting of recently allocated objects */
193static unsigned long jiffies_min_age; 192static unsigned long jiffies_min_age;
193static unsigned long jiffies_last_scan;
194/* delay between automatic memory scannings */ 194/* delay between automatic memory scannings */
195static signed long jiffies_scan_wait; 195static signed long jiffies_scan_wait;
196/* enables or disables the task stacks scanning */ 196/* enables or disables the task stacks scanning */
197static int kmemleak_stack_scan; 197static int kmemleak_stack_scan = 1;
198/* mutex protecting the memory scanning */ 198/* protects the memory scanning, parameters and debug/kmemleak file access */
199static DEFINE_MUTEX(scan_mutex); 199static DEFINE_MUTEX(scan_mutex);
200/* mutex protecting the access to the /sys/kernel/debug/kmemleak file */
201static DEFINE_MUTEX(kmemleak_mutex);
202
203/* number of leaks reported (for limitation purposes) */
204static int reported_leaks;
205 200
206/* 201/*
207 * Early object allocation/freeing logging. Kmemleak is initialized after the 202 * Early object allocation/freeing logging. Kmemleak is initialized after the
@@ -215,6 +210,7 @@ static int reported_leaks;
215enum { 210enum {
216 KMEMLEAK_ALLOC, 211 KMEMLEAK_ALLOC,
217 KMEMLEAK_FREE, 212 KMEMLEAK_FREE,
213 KMEMLEAK_FREE_PART,
218 KMEMLEAK_NOT_LEAK, 214 KMEMLEAK_NOT_LEAK,
219 KMEMLEAK_IGNORE, 215 KMEMLEAK_IGNORE,
220 KMEMLEAK_SCAN_AREA, 216 KMEMLEAK_SCAN_AREA,
@@ -235,7 +231,7 @@ struct early_log {
235}; 231};
236 232
237/* early logging buffer and current position */ 233/* early logging buffer and current position */
238static struct early_log early_log[200]; 234static struct early_log early_log[CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE];
239static int crt_early_log; 235static int crt_early_log;
240 236
241static void kmemleak_disable(void); 237static void kmemleak_disable(void);
@@ -278,13 +274,9 @@ static int color_gray(const struct kmemleak_object *object)
278 return object->min_count != -1 && object->count >= object->min_count; 274 return object->min_count != -1 && object->count >= object->min_count;
279} 275}
280 276
281/* 277static int color_black(const struct kmemleak_object *object)
282 * Objects are considered referenced if their color is gray and they have not
283 * been deleted.
284 */
285static int referenced_object(struct kmemleak_object *object)
286{ 278{
287 return (object->flags & OBJECT_ALLOCATED) && color_gray(object); 279 return object->min_count == -1;
288} 280}
289 281
290/* 282/*
@@ -295,42 +287,28 @@ static int referenced_object(struct kmemleak_object *object)
295static int unreferenced_object(struct kmemleak_object *object) 287static int unreferenced_object(struct kmemleak_object *object)
296{ 288{
297 return (object->flags & OBJECT_ALLOCATED) && color_white(object) && 289 return (object->flags & OBJECT_ALLOCATED) && color_white(object) &&
298 time_is_before_eq_jiffies(object->jiffies + jiffies_min_age); 290 time_before_eq(object->jiffies + jiffies_min_age,
291 jiffies_last_scan);
299} 292}
300 293
301/* 294/*
302 * Printing of the (un)referenced objects information, either to the seq file 295 * Printing of the unreferenced objects information to the seq file. The
303 * or to the kernel log. The print_referenced/print_unreferenced functions 296 * print_unreferenced function must be called with the object->lock held.
304 * must be called with the object->lock held.
305 */ 297 */
306#define print_helper(seq, x...) do { \
307 struct seq_file *s = (seq); \
308 if (s) \
309 seq_printf(s, x); \
310 else \
311 pr_info(x); \
312} while (0)
313
314static void print_referenced(struct kmemleak_object *object)
315{
316 pr_info("referenced object 0x%08lx (size %zu)\n",
317 object->pointer, object->size);
318}
319
320static void print_unreferenced(struct seq_file *seq, 298static void print_unreferenced(struct seq_file *seq,
321 struct kmemleak_object *object) 299 struct kmemleak_object *object)
322{ 300{
323 int i; 301 int i;
324 302
325 print_helper(seq, "unreferenced object 0x%08lx (size %zu):\n", 303 seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n",
326 object->pointer, object->size); 304 object->pointer, object->size);
327 print_helper(seq, " comm \"%s\", pid %d, jiffies %lu\n", 305 seq_printf(seq, " comm \"%s\", pid %d, jiffies %lu\n",
328 object->comm, object->pid, object->jiffies); 306 object->comm, object->pid, object->jiffies);
329 print_helper(seq, " backtrace:\n"); 307 seq_printf(seq, " backtrace:\n");
330 308
331 for (i = 0; i < object->trace_len; i++) { 309 for (i = 0; i < object->trace_len; i++) {
332 void *ptr = (void *)object->trace[i]; 310 void *ptr = (void *)object->trace[i];
333 print_helper(seq, " [<%p>] %pS\n", ptr, ptr); 311 seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
334 } 312 }
335} 313}
336 314
@@ -478,7 +456,7 @@ static void create_object(unsigned long ptr, size_t size, int min_count,
478 INIT_HLIST_HEAD(&object->area_list); 456 INIT_HLIST_HEAD(&object->area_list);
479 spin_lock_init(&object->lock); 457 spin_lock_init(&object->lock);
480 atomic_set(&object->use_count, 1); 458 atomic_set(&object->use_count, 1);
481 object->flags = OBJECT_ALLOCATED; 459 object->flags = OBJECT_ALLOCATED | OBJECT_NEW;
482 object->pointer = ptr; 460 object->pointer = ptr;
483 object->size = size; 461 object->size = size;
484 object->min_count = min_count; 462 object->min_count = min_count;
@@ -546,39 +524,87 @@ out:
546 * Remove the metadata (struct kmemleak_object) for a memory block from the 524 * Remove the metadata (struct kmemleak_object) for a memory block from the
547 * object_list and object_tree_root and decrement its use_count. 525 * object_list and object_tree_root and decrement its use_count.
548 */ 526 */
549static void delete_object(unsigned long ptr) 527static void __delete_object(struct kmemleak_object *object)
550{ 528{
551 unsigned long flags; 529 unsigned long flags;
552 struct kmemleak_object *object;
553 530
554 write_lock_irqsave(&kmemleak_lock, flags); 531 write_lock_irqsave(&kmemleak_lock, flags);
555 object = lookup_object(ptr, 0);
556 if (!object) {
557 kmemleak_warn("Freeing unknown object at 0x%08lx\n",
558 ptr);
559 write_unlock_irqrestore(&kmemleak_lock, flags);
560 return;
561 }
562 prio_tree_remove(&object_tree_root, &object->tree_node); 532 prio_tree_remove(&object_tree_root, &object->tree_node);
563 list_del_rcu(&object->object_list); 533 list_del_rcu(&object->object_list);
564 write_unlock_irqrestore(&kmemleak_lock, flags); 534 write_unlock_irqrestore(&kmemleak_lock, flags);
565 535
566 WARN_ON(!(object->flags & OBJECT_ALLOCATED)); 536 WARN_ON(!(object->flags & OBJECT_ALLOCATED));
567 WARN_ON(atomic_read(&object->use_count) < 1); 537 WARN_ON(atomic_read(&object->use_count) < 2);
568 538
569 /* 539 /*
570 * Locking here also ensures that the corresponding memory block 540 * Locking here also ensures that the corresponding memory block
571 * cannot be freed when it is being scanned. 541 * cannot be freed when it is being scanned.
572 */ 542 */
573 spin_lock_irqsave(&object->lock, flags); 543 spin_lock_irqsave(&object->lock, flags);
574 if (object->flags & OBJECT_REPORTED)
575 print_referenced(object);
576 object->flags &= ~OBJECT_ALLOCATED; 544 object->flags &= ~OBJECT_ALLOCATED;
577 spin_unlock_irqrestore(&object->lock, flags); 545 spin_unlock_irqrestore(&object->lock, flags);
578 put_object(object); 546 put_object(object);
579} 547}
580 548
581/* 549/*
550 * Look up the metadata (struct kmemleak_object) corresponding to ptr and
551 * delete it.
552 */
553static void delete_object_full(unsigned long ptr)
554{
555 struct kmemleak_object *object;
556
557 object = find_and_get_object(ptr, 0);
558 if (!object) {
559#ifdef DEBUG
560 kmemleak_warn("Freeing unknown object at 0x%08lx\n",
561 ptr);
562#endif
563 return;
564 }
565 __delete_object(object);
566 put_object(object);
567}
568
569/*
570 * Look up the metadata (struct kmemleak_object) corresponding to ptr and
571 * delete it. If the memory block is partially freed, the function may create
572 * additional metadata for the remaining parts of the block.
573 */
574static void delete_object_part(unsigned long ptr, size_t size)
575{
576 struct kmemleak_object *object;
577 unsigned long start, end;
578
579 object = find_and_get_object(ptr, 1);
580 if (!object) {
581#ifdef DEBUG
582 kmemleak_warn("Partially freeing unknown object at 0x%08lx "
583 "(size %zu)\n", ptr, size);
584#endif
585 return;
586 }
587 __delete_object(object);
588
589 /*
590 * Create one or two objects that may result from the memory block
591 * split. Note that partial freeing is only done by free_bootmem() and
592 * this happens before kmemleak_init() is called. The path below is
593 * only executed during early log recording in kmemleak_init(), so
594 * GFP_KERNEL is enough.
595 */
596 start = object->pointer;
597 end = object->pointer + object->size;
598 if (ptr > start)
599 create_object(start, ptr - start, object->min_count,
600 GFP_KERNEL);
601 if (ptr + size < end)
602 create_object(ptr + size, end - ptr - size, object->min_count,
603 GFP_KERNEL);
604
605 put_object(object);
606}
607/*
582 * Make a object permanently as gray-colored so that it can no longer be 608 * Make a object permanently as gray-colored so that it can no longer be
583 * reported as a leak. This is used in general to mark a false positive. 609 * reported as a leak. This is used in general to mark a false positive.
584 */ 610 */
@@ -696,7 +722,8 @@ static void log_early(int op_type, const void *ptr, size_t size,
696 struct early_log *log; 722 struct early_log *log;
697 723
698 if (crt_early_log >= ARRAY_SIZE(early_log)) { 724 if (crt_early_log >= ARRAY_SIZE(early_log)) {
699 kmemleak_stop("Early log buffer exceeded\n"); 725 pr_warning("Early log buffer exceeded\n");
726 kmemleak_disable();
700 return; 727 return;
701 } 728 }
702 729
@@ -741,13 +768,28 @@ void kmemleak_free(const void *ptr)
741 pr_debug("%s(0x%p)\n", __func__, ptr); 768 pr_debug("%s(0x%p)\n", __func__, ptr);
742 769
743 if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) 770 if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
744 delete_object((unsigned long)ptr); 771 delete_object_full((unsigned long)ptr);
745 else if (atomic_read(&kmemleak_early_log)) 772 else if (atomic_read(&kmemleak_early_log))
746 log_early(KMEMLEAK_FREE, ptr, 0, 0, 0, 0); 773 log_early(KMEMLEAK_FREE, ptr, 0, 0, 0, 0);
747} 774}
748EXPORT_SYMBOL_GPL(kmemleak_free); 775EXPORT_SYMBOL_GPL(kmemleak_free);
749 776
750/* 777/*
778 * Partial memory freeing function callback. This function is usually called
779 * from bootmem allocator when (part of) a memory block is freed.
780 */
781void kmemleak_free_part(const void *ptr, size_t size)
782{
783 pr_debug("%s(0x%p)\n", __func__, ptr);
784
785 if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
786 delete_object_part((unsigned long)ptr, size);
787 else if (atomic_read(&kmemleak_early_log))
788 log_early(KMEMLEAK_FREE_PART, ptr, size, 0, 0, 0);
789}
790EXPORT_SYMBOL_GPL(kmemleak_free_part);
791
792/*
751 * Mark an already allocated memory block as a false positive. This will cause 793 * Mark an already allocated memory block as a false positive. This will cause
752 * the block to no longer be reported as leak and always be scanned. 794 * the block to no longer be reported as leak and always be scanned.
753 */ 795 */
@@ -808,21 +850,6 @@ void kmemleak_no_scan(const void *ptr)
808EXPORT_SYMBOL(kmemleak_no_scan); 850EXPORT_SYMBOL(kmemleak_no_scan);
809 851
810/* 852/*
811 * Yield the CPU so that other tasks get a chance to run. The yielding is
812 * rate-limited to avoid excessive number of calls to the schedule() function
813 * during memory scanning.
814 */
815static void scan_yield(void)
816{
817 might_sleep();
818
819 if (time_is_before_eq_jiffies(next_scan_yield)) {
820 schedule();
821 next_scan_yield = jiffies + jiffies_scan_yield;
822 }
823}
824
825/*
826 * Memory scanning is a long process and it needs to be interruptable. This 853 * Memory scanning is a long process and it needs to be interruptable. This
827 * function checks whether such interrupt condition occured. 854 * function checks whether such interrupt condition occured.
828 */ 855 */
@@ -848,7 +875,7 @@ static int scan_should_stop(void)
848 * found to the gray list. 875 * found to the gray list.
849 */ 876 */
850static void scan_block(void *_start, void *_end, 877static void scan_block(void *_start, void *_end,
851 struct kmemleak_object *scanned) 878 struct kmemleak_object *scanned, int allow_resched)
852{ 879{
853 unsigned long *ptr; 880 unsigned long *ptr;
854 unsigned long *start = PTR_ALIGN(_start, BYTES_PER_POINTER); 881 unsigned long *start = PTR_ALIGN(_start, BYTES_PER_POINTER);
@@ -859,18 +886,11 @@ static void scan_block(void *_start, void *_end,
859 unsigned long pointer = *ptr; 886 unsigned long pointer = *ptr;
860 struct kmemleak_object *object; 887 struct kmemleak_object *object;
861 888
889 if (allow_resched)
890 cond_resched();
862 if (scan_should_stop()) 891 if (scan_should_stop())
863 break; 892 break;
864 893
865 /*
866 * When scanning a memory block with a corresponding
867 * kmemleak_object, the CPU yielding is handled in the calling
868 * code since it holds the object->lock to avoid the block
869 * freeing.
870 */
871 if (!scanned)
872 scan_yield();
873
874 object = find_and_get_object(pointer, 1); 894 object = find_and_get_object(pointer, 1);
875 if (!object) 895 if (!object)
876 continue; 896 continue;
@@ -931,12 +951,12 @@ static void scan_object(struct kmemleak_object *object)
931 goto out; 951 goto out;
932 if (hlist_empty(&object->area_list)) 952 if (hlist_empty(&object->area_list))
933 scan_block((void *)object->pointer, 953 scan_block((void *)object->pointer,
934 (void *)(object->pointer + object->size), object); 954 (void *)(object->pointer + object->size), object, 0);
935 else 955 else
936 hlist_for_each_entry(area, elem, &object->area_list, node) 956 hlist_for_each_entry(area, elem, &object->area_list, node)
937 scan_block((void *)(object->pointer + area->offset), 957 scan_block((void *)(object->pointer + area->offset),
938 (void *)(object->pointer + area->offset 958 (void *)(object->pointer + area->offset
939 + area->length), object); 959 + area->length), object, 0);
940out: 960out:
941 spin_unlock_irqrestore(&object->lock, flags); 961 spin_unlock_irqrestore(&object->lock, flags);
942} 962}
@@ -952,6 +972,10 @@ static void kmemleak_scan(void)
952 struct kmemleak_object *object, *tmp; 972 struct kmemleak_object *object, *tmp;
953 struct task_struct *task; 973 struct task_struct *task;
954 int i; 974 int i;
975 int new_leaks = 0;
976 int gray_list_pass = 0;
977
978 jiffies_last_scan = jiffies;
955 979
956 /* prepare the kmemleak_object's */ 980 /* prepare the kmemleak_object's */
957 rcu_read_lock(); 981 rcu_read_lock();
@@ -970,6 +994,7 @@ static void kmemleak_scan(void)
970#endif 994#endif
971 /* reset the reference count (whiten the object) */ 995 /* reset the reference count (whiten the object) */
972 object->count = 0; 996 object->count = 0;
997 object->flags &= ~OBJECT_NEW;
973 if (color_gray(object) && get_object(object)) 998 if (color_gray(object) && get_object(object))
974 list_add_tail(&object->gray_list, &gray_list); 999 list_add_tail(&object->gray_list, &gray_list);
975 1000
@@ -978,14 +1003,14 @@ static void kmemleak_scan(void)
978 rcu_read_unlock(); 1003 rcu_read_unlock();
979 1004
980 /* data/bss scanning */ 1005 /* data/bss scanning */
981 scan_block(_sdata, _edata, NULL); 1006 scan_block(_sdata, _edata, NULL, 1);
982 scan_block(__bss_start, __bss_stop, NULL); 1007 scan_block(__bss_start, __bss_stop, NULL, 1);
983 1008
984#ifdef CONFIG_SMP 1009#ifdef CONFIG_SMP
985 /* per-cpu sections scanning */ 1010 /* per-cpu sections scanning */
986 for_each_possible_cpu(i) 1011 for_each_possible_cpu(i)
987 scan_block(__per_cpu_start + per_cpu_offset(i), 1012 scan_block(__per_cpu_start + per_cpu_offset(i),
988 __per_cpu_end + per_cpu_offset(i), NULL); 1013 __per_cpu_end + per_cpu_offset(i), NULL, 1);
989#endif 1014#endif
990 1015
991 /* 1016 /*
@@ -1007,7 +1032,7 @@ static void kmemleak_scan(void)
1007 /* only scan if page is in use */ 1032 /* only scan if page is in use */
1008 if (page_count(page) == 0) 1033 if (page_count(page) == 0)
1009 continue; 1034 continue;
1010 scan_block(page, page + 1, NULL); 1035 scan_block(page, page + 1, NULL, 1);
1011 } 1036 }
1012 } 1037 }
1013 1038
@@ -1019,7 +1044,8 @@ static void kmemleak_scan(void)
1019 read_lock(&tasklist_lock); 1044 read_lock(&tasklist_lock);
1020 for_each_process(task) 1045 for_each_process(task)
1021 scan_block(task_stack_page(task), 1046 scan_block(task_stack_page(task),
1022 task_stack_page(task) + THREAD_SIZE, NULL); 1047 task_stack_page(task) + THREAD_SIZE,
1048 NULL, 0);
1023 read_unlock(&tasklist_lock); 1049 read_unlock(&tasklist_lock);
1024 } 1050 }
1025 1051
@@ -1031,9 +1057,10 @@ static void kmemleak_scan(void)
1031 * kmemleak objects cannot be freed from outside the loop because their 1057 * kmemleak objects cannot be freed from outside the loop because their
1032 * use_count was increased. 1058 * use_count was increased.
1033 */ 1059 */
1060repeat:
1034 object = list_entry(gray_list.next, typeof(*object), gray_list); 1061 object = list_entry(gray_list.next, typeof(*object), gray_list);
1035 while (&object->gray_list != &gray_list) { 1062 while (&object->gray_list != &gray_list) {
1036 scan_yield(); 1063 cond_resched();
1037 1064
1038 /* may add new objects to the list */ 1065 /* may add new objects to the list */
1039 if (!scan_should_stop()) 1066 if (!scan_should_stop())
@@ -1048,7 +1075,59 @@ static void kmemleak_scan(void)
1048 1075
1049 object = tmp; 1076 object = tmp;
1050 } 1077 }
1078
1079 if (scan_should_stop() || ++gray_list_pass >= GRAY_LIST_PASSES)
1080 goto scan_end;
1081
1082 /*
1083 * Check for new objects allocated during this scanning and add them
1084 * to the gray list.
1085 */
1086 rcu_read_lock();
1087 list_for_each_entry_rcu(object, &object_list, object_list) {
1088 spin_lock_irqsave(&object->lock, flags);
1089 if ((object->flags & OBJECT_NEW) && !color_black(object) &&
1090 get_object(object)) {
1091 object->flags &= ~OBJECT_NEW;
1092 list_add_tail(&object->gray_list, &gray_list);
1093 }
1094 spin_unlock_irqrestore(&object->lock, flags);
1095 }
1096 rcu_read_unlock();
1097
1098 if (!list_empty(&gray_list))
1099 goto repeat;
1100
1101scan_end:
1051 WARN_ON(!list_empty(&gray_list)); 1102 WARN_ON(!list_empty(&gray_list));
1103
1104 /*
1105 * If scanning was stopped or new objects were being allocated at a
1106 * higher rate than gray list scanning, do not report any new
1107 * unreferenced objects.
1108 */
1109 if (scan_should_stop() || gray_list_pass >= GRAY_LIST_PASSES)
1110 return;
1111
1112 /*
1113 * Scanning result reporting.
1114 */
1115 rcu_read_lock();
1116 list_for_each_entry_rcu(object, &object_list, object_list) {
1117 spin_lock_irqsave(&object->lock, flags);
1118 if (unreferenced_object(object) &&
1119 !(object->flags & OBJECT_REPORTED)) {
1120 object->flags |= OBJECT_REPORTED;
1121 new_leaks++;
1122 }
1123 spin_unlock_irqrestore(&object->lock, flags);
1124 }
1125 rcu_read_unlock();
1126
1127 if (new_leaks)
1128 pr_info("%d new suspected memory leaks (see "
1129 "/sys/kernel/debug/kmemleak)\n", new_leaks);
1130
1052} 1131}
1053 1132
1054/* 1133/*
@@ -1060,6 +1139,7 @@ static int kmemleak_scan_thread(void *arg)
1060 static int first_run = 1; 1139 static int first_run = 1;
1061 1140
1062 pr_info("Automatic memory scanning thread started\n"); 1141 pr_info("Automatic memory scanning thread started\n");
1142 set_user_nice(current, 10);
1063 1143
1064 /* 1144 /*
1065 * Wait before the first scan to allow the system to fully initialize. 1145 * Wait before the first scan to allow the system to fully initialize.
@@ -1070,36 +1150,12 @@ static int kmemleak_scan_thread(void *arg)
1070 } 1150 }
1071 1151
1072 while (!kthread_should_stop()) { 1152 while (!kthread_should_stop()) {
1073 struct kmemleak_object *object;
1074 signed long timeout = jiffies_scan_wait; 1153 signed long timeout = jiffies_scan_wait;
1075 1154
1076 mutex_lock(&scan_mutex); 1155 mutex_lock(&scan_mutex);
1077
1078 kmemleak_scan(); 1156 kmemleak_scan();
1079 reported_leaks = 0;
1080
1081 rcu_read_lock();
1082 list_for_each_entry_rcu(object, &object_list, object_list) {
1083 unsigned long flags;
1084
1085 if (reported_leaks >= REPORTS_NR)
1086 break;
1087 spin_lock_irqsave(&object->lock, flags);
1088 if (!(object->flags & OBJECT_REPORTED) &&
1089 unreferenced_object(object)) {
1090 print_unreferenced(NULL, object);
1091 object->flags |= OBJECT_REPORTED;
1092 reported_leaks++;
1093 } else if ((object->flags & OBJECT_REPORTED) &&
1094 referenced_object(object)) {
1095 print_referenced(object);
1096 object->flags &= ~OBJECT_REPORTED;
1097 }
1098 spin_unlock_irqrestore(&object->lock, flags);
1099 }
1100 rcu_read_unlock();
1101
1102 mutex_unlock(&scan_mutex); 1157 mutex_unlock(&scan_mutex);
1158
1103 /* wait before the next scan */ 1159 /* wait before the next scan */
1104 while (timeout && !kthread_should_stop()) 1160 while (timeout && !kthread_should_stop())
1105 timeout = schedule_timeout_interruptible(timeout); 1161 timeout = schedule_timeout_interruptible(timeout);
@@ -1112,7 +1168,7 @@ static int kmemleak_scan_thread(void *arg)
1112 1168
1113/* 1169/*
1114 * Start the automatic memory scanning thread. This function must be called 1170 * Start the automatic memory scanning thread. This function must be called
1115 * with the kmemleak_mutex held. 1171 * with the scan_mutex held.
1116 */ 1172 */
1117void start_scan_thread(void) 1173void start_scan_thread(void)
1118{ 1174{
@@ -1127,7 +1183,7 @@ void start_scan_thread(void)
1127 1183
1128/* 1184/*
1129 * Stop the automatic memory scanning thread. This function must be called 1185 * Stop the automatic memory scanning thread. This function must be called
1130 * with the kmemleak_mutex held. 1186 * with the scan_mutex held.
1131 */ 1187 */
1132void stop_scan_thread(void) 1188void stop_scan_thread(void)
1133{ 1189{
@@ -1146,13 +1202,11 @@ static void *kmemleak_seq_start(struct seq_file *seq, loff_t *pos)
1146{ 1202{
1147 struct kmemleak_object *object; 1203 struct kmemleak_object *object;
1148 loff_t n = *pos; 1204 loff_t n = *pos;
1205 int err;
1149 1206
1150 if (!n) { 1207 err = mutex_lock_interruptible(&scan_mutex);
1151 kmemleak_scan(); 1208 if (err < 0)
1152 reported_leaks = 0; 1209 return ERR_PTR(err);
1153 }
1154 if (reported_leaks >= REPORTS_NR)
1155 return NULL;
1156 1210
1157 rcu_read_lock(); 1211 rcu_read_lock();
1158 list_for_each_entry_rcu(object, &object_list, object_list) { 1212 list_for_each_entry_rcu(object, &object_list, object_list) {
@@ -1178,8 +1232,6 @@ static void *kmemleak_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1178 struct list_head *n = &prev_obj->object_list; 1232 struct list_head *n = &prev_obj->object_list;
1179 1233
1180 ++(*pos); 1234 ++(*pos);
1181 if (reported_leaks >= REPORTS_NR)
1182 goto out;
1183 1235
1184 rcu_read_lock(); 1236 rcu_read_lock();
1185 list_for_each_continue_rcu(n, &object_list) { 1237 list_for_each_continue_rcu(n, &object_list) {
@@ -1188,7 +1240,7 @@ static void *kmemleak_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1188 break; 1240 break;
1189 } 1241 }
1190 rcu_read_unlock(); 1242 rcu_read_unlock();
1191out: 1243
1192 put_object(prev_obj); 1244 put_object(prev_obj);
1193 return next_obj; 1245 return next_obj;
1194} 1246}
@@ -1198,8 +1250,15 @@ out:
1198 */ 1250 */
1199static void kmemleak_seq_stop(struct seq_file *seq, void *v) 1251static void kmemleak_seq_stop(struct seq_file *seq, void *v)
1200{ 1252{
1201 if (v) 1253 if (!IS_ERR(v)) {
1202 put_object(v); 1254 /*
1255 * kmemleak_seq_start may return ERR_PTR if the scan_mutex
1256 * waiting was interrupted, so only release it if !IS_ERR.
1257 */
1258 mutex_unlock(&scan_mutex);
1259 if (v)
1260 put_object(v);
1261 }
1203} 1262}
1204 1263
1205/* 1264/*
@@ -1211,11 +1270,8 @@ static int kmemleak_seq_show(struct seq_file *seq, void *v)
1211 unsigned long flags; 1270 unsigned long flags;
1212 1271
1213 spin_lock_irqsave(&object->lock, flags); 1272 spin_lock_irqsave(&object->lock, flags);
1214 if (!unreferenced_object(object)) 1273 if ((object->flags & OBJECT_REPORTED) && unreferenced_object(object))
1215 goto out; 1274 print_unreferenced(seq, object);
1216 print_unreferenced(seq, object);
1217 reported_leaks++;
1218out:
1219 spin_unlock_irqrestore(&object->lock, flags); 1275 spin_unlock_irqrestore(&object->lock, flags);
1220 return 0; 1276 return 0;
1221} 1277}
@@ -1229,43 +1285,15 @@ static const struct seq_operations kmemleak_seq_ops = {
1229 1285
1230static int kmemleak_open(struct inode *inode, struct file *file) 1286static int kmemleak_open(struct inode *inode, struct file *file)
1231{ 1287{
1232 int ret = 0;
1233
1234 if (!atomic_read(&kmemleak_enabled)) 1288 if (!atomic_read(&kmemleak_enabled))
1235 return -EBUSY; 1289 return -EBUSY;
1236 1290
1237 ret = mutex_lock_interruptible(&kmemleak_mutex); 1291 return seq_open(file, &kmemleak_seq_ops);
1238 if (ret < 0)
1239 goto out;
1240 if (file->f_mode & FMODE_READ) {
1241 ret = mutex_lock_interruptible(&scan_mutex);
1242 if (ret < 0)
1243 goto kmemleak_unlock;
1244 ret = seq_open(file, &kmemleak_seq_ops);
1245 if (ret < 0)
1246 goto scan_unlock;
1247 }
1248 return ret;
1249
1250scan_unlock:
1251 mutex_unlock(&scan_mutex);
1252kmemleak_unlock:
1253 mutex_unlock(&kmemleak_mutex);
1254out:
1255 return ret;
1256} 1292}
1257 1293
1258static int kmemleak_release(struct inode *inode, struct file *file) 1294static int kmemleak_release(struct inode *inode, struct file *file)
1259{ 1295{
1260 int ret = 0; 1296 return seq_release(inode, file);
1261
1262 if (file->f_mode & FMODE_READ) {
1263 seq_release(inode, file);
1264 mutex_unlock(&scan_mutex);
1265 }
1266 mutex_unlock(&kmemleak_mutex);
1267
1268 return ret;
1269} 1297}
1270 1298
1271/* 1299/*
@@ -1278,21 +1306,24 @@ static int kmemleak_release(struct inode *inode, struct file *file)
1278 * scan=off - stop the automatic memory scanning thread 1306 * scan=off - stop the automatic memory scanning thread
1279 * scan=... - set the automatic memory scanning period in seconds (0 to 1307 * scan=... - set the automatic memory scanning period in seconds (0 to
1280 * disable it) 1308 * disable it)
1309 * scan - trigger a memory scan
1281 */ 1310 */
1282static ssize_t kmemleak_write(struct file *file, const char __user *user_buf, 1311static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,
1283 size_t size, loff_t *ppos) 1312 size_t size, loff_t *ppos)
1284{ 1313{
1285 char buf[64]; 1314 char buf[64];
1286 int buf_size; 1315 int buf_size;
1287 1316 int ret;
1288 if (!atomic_read(&kmemleak_enabled))
1289 return -EBUSY;
1290 1317
1291 buf_size = min(size, (sizeof(buf) - 1)); 1318 buf_size = min(size, (sizeof(buf) - 1));
1292 if (strncpy_from_user(buf, user_buf, buf_size) < 0) 1319 if (strncpy_from_user(buf, user_buf, buf_size) < 0)
1293 return -EFAULT; 1320 return -EFAULT;
1294 buf[buf_size] = 0; 1321 buf[buf_size] = 0;
1295 1322
1323 ret = mutex_lock_interruptible(&scan_mutex);
1324 if (ret < 0)
1325 return ret;
1326
1296 if (strncmp(buf, "off", 3) == 0) 1327 if (strncmp(buf, "off", 3) == 0)
1297 kmemleak_disable(); 1328 kmemleak_disable();
1298 else if (strncmp(buf, "stack=on", 8) == 0) 1329 else if (strncmp(buf, "stack=on", 8) == 0)
@@ -1305,18 +1336,24 @@ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,
1305 stop_scan_thread(); 1336 stop_scan_thread();
1306 else if (strncmp(buf, "scan=", 5) == 0) { 1337 else if (strncmp(buf, "scan=", 5) == 0) {
1307 unsigned long secs; 1338 unsigned long secs;
1308 int err;
1309 1339
1310 err = strict_strtoul(buf + 5, 0, &secs); 1340 ret = strict_strtoul(buf + 5, 0, &secs);
1311 if (err < 0) 1341 if (ret < 0)
1312 return err; 1342 goto out;
1313 stop_scan_thread(); 1343 stop_scan_thread();
1314 if (secs) { 1344 if (secs) {
1315 jiffies_scan_wait = msecs_to_jiffies(secs * 1000); 1345 jiffies_scan_wait = msecs_to_jiffies(secs * 1000);
1316 start_scan_thread(); 1346 start_scan_thread();
1317 } 1347 }
1318 } else 1348 } else if (strncmp(buf, "scan", 4) == 0)
1319 return -EINVAL; 1349 kmemleak_scan();
1350 else
1351 ret = -EINVAL;
1352
1353out:
1354 mutex_unlock(&scan_mutex);
1355 if (ret < 0)
1356 return ret;
1320 1357
1321 /* ignore the rest of the buffer, only one command at a time */ 1358 /* ignore the rest of the buffer, only one command at a time */
1322 *ppos += size; 1359 *ppos += size;
@@ -1340,14 +1377,12 @@ static int kmemleak_cleanup_thread(void *arg)
1340{ 1377{
1341 struct kmemleak_object *object; 1378 struct kmemleak_object *object;
1342 1379
1343 mutex_lock(&kmemleak_mutex); 1380 mutex_lock(&scan_mutex);
1344 stop_scan_thread(); 1381 stop_scan_thread();
1345 mutex_unlock(&kmemleak_mutex);
1346 1382
1347 mutex_lock(&scan_mutex);
1348 rcu_read_lock(); 1383 rcu_read_lock();
1349 list_for_each_entry_rcu(object, &object_list, object_list) 1384 list_for_each_entry_rcu(object, &object_list, object_list)
1350 delete_object(object->pointer); 1385 delete_object_full(object->pointer);
1351 rcu_read_unlock(); 1386 rcu_read_unlock();
1352 mutex_unlock(&scan_mutex); 1387 mutex_unlock(&scan_mutex);
1353 1388
@@ -1411,7 +1446,6 @@ void __init kmemleak_init(void)
1411 int i; 1446 int i;
1412 unsigned long flags; 1447 unsigned long flags;
1413 1448
1414 jiffies_scan_yield = msecs_to_jiffies(MSECS_SCAN_YIELD);
1415 jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE); 1449 jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE);
1416 jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000); 1450 jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000);
1417 1451
@@ -1443,6 +1477,9 @@ void __init kmemleak_init(void)
1443 case KMEMLEAK_FREE: 1477 case KMEMLEAK_FREE:
1444 kmemleak_free(log->ptr); 1478 kmemleak_free(log->ptr);
1445 break; 1479 break;
1480 case KMEMLEAK_FREE_PART:
1481 kmemleak_free_part(log->ptr, log->size);
1482 break;
1446 case KMEMLEAK_NOT_LEAK: 1483 case KMEMLEAK_NOT_LEAK:
1447 kmemleak_not_leak(log->ptr); 1484 kmemleak_not_leak(log->ptr);
1448 break; 1485 break;
@@ -1486,9 +1523,9 @@ static int __init kmemleak_late_init(void)
1486 &kmemleak_fops); 1523 &kmemleak_fops);
1487 if (!dentry) 1524 if (!dentry)
1488 pr_warning("Failed to create the debugfs kmemleak file\n"); 1525 pr_warning("Failed to create the debugfs kmemleak file\n");
1489 mutex_lock(&kmemleak_mutex); 1526 mutex_lock(&scan_mutex);
1490 start_scan_thread(); 1527 start_scan_thread();
1491 mutex_unlock(&kmemleak_mutex); 1528 mutex_unlock(&scan_mutex);
1492 1529
1493 pr_info("Kernel memory leak detector initialized\n"); 1530 pr_info("Kernel memory leak detector initialized\n");
1494 1531
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e2fa20dadf40..e717964cb5a0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1973,7 +1973,7 @@ try_to_free:
1973 if (!progress) { 1973 if (!progress) {
1974 nr_retries--; 1974 nr_retries--;
1975 /* maybe some writeback is necessary */ 1975 /* maybe some writeback is necessary */
1976 congestion_wait(WRITE, HZ/10); 1976 congestion_wait(BLK_RW_ASYNC, HZ/10);
1977 } 1977 }
1978 1978
1979 } 1979 }
diff --git a/mm/memory.c b/mm/memory.c
index f46ac18ba231..65216194eb8d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1207,8 +1207,8 @@ static inline int use_zero_page(struct vm_area_struct *vma)
1207 1207
1208 1208
1209int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 1209int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1210 unsigned long start, int len, int flags, 1210 unsigned long start, int nr_pages, int flags,
1211 struct page **pages, struct vm_area_struct **vmas) 1211 struct page **pages, struct vm_area_struct **vmas)
1212{ 1212{
1213 int i; 1213 int i;
1214 unsigned int vm_flags = 0; 1214 unsigned int vm_flags = 0;
@@ -1217,7 +1217,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1217 int ignore = !!(flags & GUP_FLAGS_IGNORE_VMA_PERMISSIONS); 1217 int ignore = !!(flags & GUP_FLAGS_IGNORE_VMA_PERMISSIONS);
1218 int ignore_sigkill = !!(flags & GUP_FLAGS_IGNORE_SIGKILL); 1218 int ignore_sigkill = !!(flags & GUP_FLAGS_IGNORE_SIGKILL);
1219 1219
1220 if (len <= 0) 1220 if (nr_pages <= 0)
1221 return 0; 1221 return 0;
1222 /* 1222 /*
1223 * Require read or write permissions. 1223 * Require read or write permissions.
@@ -1269,7 +1269,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1269 vmas[i] = gate_vma; 1269 vmas[i] = gate_vma;
1270 i++; 1270 i++;
1271 start += PAGE_SIZE; 1271 start += PAGE_SIZE;
1272 len--; 1272 nr_pages--;
1273 continue; 1273 continue;
1274 } 1274 }
1275 1275
@@ -1280,7 +1280,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1280 1280
1281 if (is_vm_hugetlb_page(vma)) { 1281 if (is_vm_hugetlb_page(vma)) {
1282 i = follow_hugetlb_page(mm, vma, pages, vmas, 1282 i = follow_hugetlb_page(mm, vma, pages, vmas,
1283 &start, &len, i, write); 1283 &start, &nr_pages, i, write);
1284 continue; 1284 continue;
1285 } 1285 }
1286 1286
@@ -1357,9 +1357,9 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1357 vmas[i] = vma; 1357 vmas[i] = vma;
1358 i++; 1358 i++;
1359 start += PAGE_SIZE; 1359 start += PAGE_SIZE;
1360 len--; 1360 nr_pages--;
1361 } while (len && start < vma->vm_end); 1361 } while (nr_pages && start < vma->vm_end);
1362 } while (len); 1362 } while (nr_pages);
1363 return i; 1363 return i;
1364} 1364}
1365 1365
@@ -1368,7 +1368,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1368 * @tsk: task_struct of target task 1368 * @tsk: task_struct of target task
1369 * @mm: mm_struct of target mm 1369 * @mm: mm_struct of target mm
1370 * @start: starting user address 1370 * @start: starting user address
1371 * @len: number of pages from start to pin 1371 * @nr_pages: number of pages from start to pin
1372 * @write: whether pages will be written to by the caller 1372 * @write: whether pages will be written to by the caller
1373 * @force: whether to force write access even if user mapping is 1373 * @force: whether to force write access even if user mapping is
1374 * readonly. This will result in the page being COWed even 1374 * readonly. This will result in the page being COWed even
@@ -1380,7 +1380,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1380 * Or NULL if the caller does not require them. 1380 * Or NULL if the caller does not require them.
1381 * 1381 *
1382 * Returns number of pages pinned. This may be fewer than the number 1382 * Returns number of pages pinned. This may be fewer than the number
1383 * requested. If len is 0 or negative, returns 0. If no pages 1383 * requested. If nr_pages is 0 or negative, returns 0. If no pages
1384 * were pinned, returns -errno. Each page returned must be released 1384 * were pinned, returns -errno. Each page returned must be released
1385 * with a put_page() call when it is finished with. vmas will only 1385 * with a put_page() call when it is finished with. vmas will only
1386 * remain valid while mmap_sem is held. 1386 * remain valid while mmap_sem is held.
@@ -1414,7 +1414,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1414 * See also get_user_pages_fast, for performance critical applications. 1414 * See also get_user_pages_fast, for performance critical applications.
1415 */ 1415 */
1416int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 1416int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1417 unsigned long start, int len, int write, int force, 1417 unsigned long start, int nr_pages, int write, int force,
1418 struct page **pages, struct vm_area_struct **vmas) 1418 struct page **pages, struct vm_area_struct **vmas)
1419{ 1419{
1420 int flags = 0; 1420 int flags = 0;
@@ -1424,9 +1424,7 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
1424 if (force) 1424 if (force)
1425 flags |= GUP_FLAGS_FORCE; 1425 flags |= GUP_FLAGS_FORCE;
1426 1426
1427 return __get_user_pages(tsk, mm, 1427 return __get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas);
1428 start, len, flags,
1429 pages, vmas);
1430} 1428}
1431 1429
1432EXPORT_SYMBOL(get_user_pages); 1430EXPORT_SYMBOL(get_user_pages);
diff --git a/mm/nommu.c b/mm/nommu.c
index 2fd2ad5da98e..53cab10fece4 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -173,8 +173,8 @@ unsigned int kobjsize(const void *objp)
173} 173}
174 174
175int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 175int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
176 unsigned long start, int len, int flags, 176 unsigned long start, int nr_pages, int flags,
177 struct page **pages, struct vm_area_struct **vmas) 177 struct page **pages, struct vm_area_struct **vmas)
178{ 178{
179 struct vm_area_struct *vma; 179 struct vm_area_struct *vma;
180 unsigned long vm_flags; 180 unsigned long vm_flags;
@@ -189,7 +189,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
189 vm_flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD); 189 vm_flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);
190 vm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE); 190 vm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
191 191
192 for (i = 0; i < len; i++) { 192 for (i = 0; i < nr_pages; i++) {
193 vma = find_vma(mm, start); 193 vma = find_vma(mm, start);
194 if (!vma) 194 if (!vma)
195 goto finish_or_fault; 195 goto finish_or_fault;
@@ -224,7 +224,7 @@ finish_or_fault:
224 * - don't permit access to VMAs that don't support it, such as I/O mappings 224 * - don't permit access to VMAs that don't support it, such as I/O mappings
225 */ 225 */
226int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 226int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
227 unsigned long start, int len, int write, int force, 227 unsigned long start, int nr_pages, int write, int force,
228 struct page **pages, struct vm_area_struct **vmas) 228 struct page **pages, struct vm_area_struct **vmas)
229{ 229{
230 int flags = 0; 230 int flags = 0;
@@ -234,12 +234,31 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
234 if (force) 234 if (force)
235 flags |= GUP_FLAGS_FORCE; 235 flags |= GUP_FLAGS_FORCE;
236 236
237 return __get_user_pages(tsk, mm, 237 return __get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas);
238 start, len, flags,
239 pages, vmas);
240} 238}
241EXPORT_SYMBOL(get_user_pages); 239EXPORT_SYMBOL(get_user_pages);
242 240
241/**
242 * follow_pfn - look up PFN at a user virtual address
243 * @vma: memory mapping
244 * @address: user virtual address
245 * @pfn: location to store found PFN
246 *
247 * Only IO mappings and raw PFN mappings are allowed.
248 *
249 * Returns zero and the pfn at @pfn on success, -ve otherwise.
250 */
251int follow_pfn(struct vm_area_struct *vma, unsigned long address,
252 unsigned long *pfn)
253{
254 if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
255 return -EINVAL;
256
257 *pfn = address >> PAGE_SHIFT;
258 return 0;
259}
260EXPORT_SYMBOL(follow_pfn);
261
243DEFINE_RWLOCK(vmlist_lock); 262DEFINE_RWLOCK(vmlist_lock);
244struct vm_struct *vmlist; 263struct vm_struct *vmlist;
245 264
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 7b0dcea4935b..81627ebcd313 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -541,8 +541,11 @@ static void balance_dirty_pages(struct address_space *mapping)
541 * filesystems (i.e. NFS) in which data may have been 541 * filesystems (i.e. NFS) in which data may have been
542 * written to the server's write cache, but has not yet 542 * written to the server's write cache, but has not yet
543 * been flushed to permanent storage. 543 * been flushed to permanent storage.
544 * Only move pages to writeback if this bdi is over its
545 * threshold otherwise wait until the disk writes catch
546 * up.
544 */ 547 */
545 if (bdi_nr_reclaimable) { 548 if (bdi_nr_reclaimable > bdi_thresh) {
546 writeback_inodes(&wbc); 549 writeback_inodes(&wbc);
547 pages_written += write_chunk - wbc.nr_to_write; 550 pages_written += write_chunk - wbc.nr_to_write;
548 get_dirty_limits(&background_thresh, &dirty_thresh, 551 get_dirty_limits(&background_thresh, &dirty_thresh,
@@ -572,7 +575,7 @@ static void balance_dirty_pages(struct address_space *mapping)
572 if (pages_written >= write_chunk) 575 if (pages_written >= write_chunk)
573 break; /* We've done our duty */ 576 break; /* We've done our duty */
574 577
575 congestion_wait(WRITE, HZ/10); 578 congestion_wait(BLK_RW_ASYNC, HZ/10);
576 } 579 }
577 580
578 if (bdi_nr_reclaimable + bdi_nr_writeback < bdi_thresh && 581 if (bdi_nr_reclaimable + bdi_nr_writeback < bdi_thresh &&
@@ -666,7 +669,7 @@ void throttle_vm_writeout(gfp_t gfp_mask)
666 if (global_page_state(NR_UNSTABLE_NFS) + 669 if (global_page_state(NR_UNSTABLE_NFS) +
667 global_page_state(NR_WRITEBACK) <= dirty_thresh) 670 global_page_state(NR_WRITEBACK) <= dirty_thresh)
668 break; 671 break;
669 congestion_wait(WRITE, HZ/10); 672 congestion_wait(BLK_RW_ASYNC, HZ/10);
670 673
671 /* 674 /*
672 * The caller might hold locks which can prevent IO completion 675 * The caller might hold locks which can prevent IO completion
@@ -712,7 +715,7 @@ static void background_writeout(unsigned long _min_pages)
712 if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) { 715 if (wbc.nr_to_write > 0 || wbc.pages_skipped > 0) {
713 /* Wrote less than expected */ 716 /* Wrote less than expected */
714 if (wbc.encountered_congestion || wbc.more_io) 717 if (wbc.encountered_congestion || wbc.more_io)
715 congestion_wait(WRITE, HZ/10); 718 congestion_wait(BLK_RW_ASYNC, HZ/10);
716 else 719 else
717 break; 720 break;
718 } 721 }
@@ -784,7 +787,7 @@ static void wb_kupdate(unsigned long arg)
784 writeback_inodes(&wbc); 787 writeback_inodes(&wbc);
785 if (wbc.nr_to_write > 0) { 788 if (wbc.nr_to_write > 0) {
786 if (wbc.encountered_congestion || wbc.more_io) 789 if (wbc.encountered_congestion || wbc.more_io)
787 congestion_wait(WRITE, HZ/10); 790 congestion_wait(BLK_RW_ASYNC, HZ/10);
788 else 791 else
789 break; /* All the old data is written */ 792 break; /* All the old data is written */
790 } 793 }
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5d714f8fb303..caa92689aac9 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1666,7 +1666,7 @@ __alloc_pages_high_priority(gfp_t gfp_mask, unsigned int order,
1666 preferred_zone, migratetype); 1666 preferred_zone, migratetype);
1667 1667
1668 if (!page && gfp_mask & __GFP_NOFAIL) 1668 if (!page && gfp_mask & __GFP_NOFAIL)
1669 congestion_wait(WRITE, HZ/50); 1669 congestion_wait(BLK_RW_ASYNC, HZ/50);
1670 } while (!page && (gfp_mask & __GFP_NOFAIL)); 1670 } while (!page && (gfp_mask & __GFP_NOFAIL));
1671 1671
1672 return page; 1672 return page;
@@ -1831,7 +1831,7 @@ rebalance:
1831 pages_reclaimed += did_some_progress; 1831 pages_reclaimed += did_some_progress;
1832 if (should_alloc_retry(gfp_mask, order, pages_reclaimed)) { 1832 if (should_alloc_retry(gfp_mask, order, pages_reclaimed)) {
1833 /* Wait for some write requests to complete then retry */ 1833 /* Wait for some write requests to complete then retry */
1834 congestion_wait(WRITE, HZ/50); 1834 congestion_wait(BLK_RW_ASYNC, HZ/50);
1835 goto rebalance; 1835 goto rebalance;
1836 } 1836 }
1837 1837
@@ -1983,7 +1983,7 @@ void *alloc_pages_exact(size_t size, gfp_t gfp_mask)
1983 unsigned long alloc_end = addr + (PAGE_SIZE << order); 1983 unsigned long alloc_end = addr + (PAGE_SIZE << order);
1984 unsigned long used = addr + PAGE_ALIGN(size); 1984 unsigned long used = addr + PAGE_ALIGN(size);
1985 1985
1986 split_page(virt_to_page(addr), order); 1986 split_page(virt_to_page((void *)addr), order);
1987 while (used < alloc_end) { 1987 while (used < alloc_end) {
1988 free_page(used); 1988 free_page(used);
1989 used += PAGE_SIZE; 1989 used += PAGE_SIZE;
@@ -4032,6 +4032,8 @@ static void __init find_zone_movable_pfns_for_nodes(unsigned long *movable_pfn)
4032 int i, nid; 4032 int i, nid;
4033 unsigned long usable_startpfn; 4033 unsigned long usable_startpfn;
4034 unsigned long kernelcore_node, kernelcore_remaining; 4034 unsigned long kernelcore_node, kernelcore_remaining;
4035 /* save the state before borrow the nodemask */
4036 nodemask_t saved_node_state = node_states[N_HIGH_MEMORY];
4035 unsigned long totalpages = early_calculate_totalpages(); 4037 unsigned long totalpages = early_calculate_totalpages();
4036 int usable_nodes = nodes_weight(node_states[N_HIGH_MEMORY]); 4038 int usable_nodes = nodes_weight(node_states[N_HIGH_MEMORY]);
4037 4039
@@ -4059,7 +4061,7 @@ static void __init find_zone_movable_pfns_for_nodes(unsigned long *movable_pfn)
4059 4061
4060 /* If kernelcore was not specified, there is no ZONE_MOVABLE */ 4062 /* If kernelcore was not specified, there is no ZONE_MOVABLE */
4061 if (!required_kernelcore) 4063 if (!required_kernelcore)
4062 return; 4064 goto out;
4063 4065
4064 /* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */ 4066 /* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */
4065 find_usable_zone_for_movable(); 4067 find_usable_zone_for_movable();
@@ -4158,6 +4160,10 @@ restart:
4158 for (nid = 0; nid < MAX_NUMNODES; nid++) 4160 for (nid = 0; nid < MAX_NUMNODES; nid++)
4159 zone_movable_pfn[nid] = 4161 zone_movable_pfn[nid] =
4160 roundup(zone_movable_pfn[nid], MAX_ORDER_NR_PAGES); 4162 roundup(zone_movable_pfn[nid], MAX_ORDER_NR_PAGES);
4163
4164out:
4165 /* restore the node_state */
4166 node_states[N_HIGH_MEMORY] = saved_node_state;
4161} 4167}
4162 4168
4163/* Any regular memory on that node ? */ 4169/* Any regular memory on that node ? */
@@ -4242,11 +4248,6 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
4242 early_node_map[i].start_pfn, 4248 early_node_map[i].start_pfn,
4243 early_node_map[i].end_pfn); 4249 early_node_map[i].end_pfn);
4244 4250
4245 /*
4246 * find_zone_movable_pfns_for_nodes/early_calculate_totalpages init
4247 * that node_mask, clear it at first
4248 */
4249 nodes_clear(node_states[N_HIGH_MEMORY]);
4250 /* Initialise every node */ 4251 /* Initialise every node */
4251 mminit_verify_pageflags_layout(); 4252 mminit_verify_pageflags_layout();
4252 setup_nr_node_ids(); 4253 setup_nr_node_ids();
@@ -4744,8 +4745,10 @@ void *__init alloc_large_system_hash(const char *tablename,
4744 * some pages at the end of hash table which 4745 * some pages at the end of hash table which
4745 * alloc_pages_exact() automatically does 4746 * alloc_pages_exact() automatically does
4746 */ 4747 */
4747 if (get_order(size) < MAX_ORDER) 4748 if (get_order(size) < MAX_ORDER) {
4748 table = alloc_pages_exact(size, GFP_ATOMIC); 4749 table = alloc_pages_exact(size, GFP_ATOMIC);
4750 kmemleak_alloc(table, size, 1, GFP_ATOMIC);
4751 }
4749 } 4752 }
4750 } while (!table && size > PAGE_SIZE && --log2qty); 4753 } while (!table && size > PAGE_SIZE && --log2qty);
4751 4754
@@ -4763,16 +4766,6 @@ void *__init alloc_large_system_hash(const char *tablename,
4763 if (_hash_mask) 4766 if (_hash_mask)
4764 *_hash_mask = (1 << log2qty) - 1; 4767 *_hash_mask = (1 << log2qty) - 1;
4765 4768
4766 /*
4767 * If hashdist is set, the table allocation is done with __vmalloc()
4768 * which invokes the kmemleak_alloc() callback. This function may also
4769 * be called before the slab and kmemleak are initialised when
4770 * kmemleak simply buffers the request to be executed later
4771 * (GFP_ATOMIC flag ignored in this case).
4772 */
4773 if (!hashdist)
4774 kmemleak_alloc(table, size, 1, GFP_ATOMIC);
4775
4776 return table; 4769 return table;
4777} 4770}
4778 4771
diff --git a/mm/percpu.c b/mm/percpu.c
index c0b2c1a76e81..b70f2acd8853 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -549,14 +549,14 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int freeme)
549 * @chunk: chunk of interest 549 * @chunk: chunk of interest
550 * @page_start: page index of the first page to unmap 550 * @page_start: page index of the first page to unmap
551 * @page_end: page index of the last page to unmap + 1 551 * @page_end: page index of the last page to unmap + 1
552 * @flush: whether to flush cache and tlb or not 552 * @flush_tlb: whether to flush tlb or not
553 * 553 *
554 * For each cpu, unmap pages [@page_start,@page_end) out of @chunk. 554 * For each cpu, unmap pages [@page_start,@page_end) out of @chunk.
555 * If @flush is true, vcache is flushed before unmapping and tlb 555 * If @flush is true, vcache is flushed before unmapping and tlb
556 * after. 556 * after.
557 */ 557 */
558static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end, 558static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end,
559 bool flush) 559 bool flush_tlb)
560{ 560{
561 unsigned int last = num_possible_cpus() - 1; 561 unsigned int last = num_possible_cpus() - 1;
562 unsigned int cpu; 562 unsigned int cpu;
@@ -569,9 +569,8 @@ static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end,
569 * the whole region at once rather than doing it for each cpu. 569 * the whole region at once rather than doing it for each cpu.
570 * This could be an overkill but is more scalable. 570 * This could be an overkill but is more scalable.
571 */ 571 */
572 if (flush) 572 flush_cache_vunmap(pcpu_chunk_addr(chunk, 0, page_start),
573 flush_cache_vunmap(pcpu_chunk_addr(chunk, 0, page_start), 573 pcpu_chunk_addr(chunk, last, page_end));
574 pcpu_chunk_addr(chunk, last, page_end));
575 574
576 for_each_possible_cpu(cpu) 575 for_each_possible_cpu(cpu)
577 unmap_kernel_range_noflush( 576 unmap_kernel_range_noflush(
@@ -579,7 +578,7 @@ static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end,
579 (page_end - page_start) << PAGE_SHIFT); 578 (page_end - page_start) << PAGE_SHIFT);
580 579
581 /* ditto as flush_cache_vunmap() */ 580 /* ditto as flush_cache_vunmap() */
582 if (flush) 581 if (flush_tlb)
583 flush_tlb_kernel_range(pcpu_chunk_addr(chunk, 0, page_start), 582 flush_tlb_kernel_range(pcpu_chunk_addr(chunk, 0, page_start),
584 pcpu_chunk_addr(chunk, last, page_end)); 583 pcpu_chunk_addr(chunk, last, page_end));
585} 584}
@@ -1234,6 +1233,7 @@ static struct page * __init pcpue_get_page(unsigned int cpu, int pageno)
1234ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size, 1233ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size,
1235 ssize_t dyn_size, ssize_t unit_size) 1234 ssize_t dyn_size, ssize_t unit_size)
1236{ 1235{
1236 size_t chunk_size;
1237 unsigned int cpu; 1237 unsigned int cpu;
1238 1238
1239 /* determine parameters and allocate */ 1239 /* determine parameters and allocate */
@@ -1248,11 +1248,15 @@ ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size,
1248 } else 1248 } else
1249 pcpue_unit_size = max_t(size_t, pcpue_size, PCPU_MIN_UNIT_SIZE); 1249 pcpue_unit_size = max_t(size_t, pcpue_size, PCPU_MIN_UNIT_SIZE);
1250 1250
1251 pcpue_ptr = __alloc_bootmem_nopanic( 1251 chunk_size = pcpue_unit_size * num_possible_cpus();
1252 num_possible_cpus() * pcpue_unit_size, 1252
1253 PAGE_SIZE, __pa(MAX_DMA_ADDRESS)); 1253 pcpue_ptr = __alloc_bootmem_nopanic(chunk_size, PAGE_SIZE,
1254 if (!pcpue_ptr) 1254 __pa(MAX_DMA_ADDRESS));
1255 if (!pcpue_ptr) {
1256 pr_warning("PERCPU: failed to allocate %zu bytes for "
1257 "embedding\n", chunk_size);
1255 return -ENOMEM; 1258 return -ENOMEM;
1259 }
1256 1260
1257 /* return the leftover and copy */ 1261 /* return the leftover and copy */
1258 for_each_possible_cpu(cpu) { 1262 for_each_possible_cpu(cpu) {
diff --git a/mm/slab.c b/mm/slab.c
index e74a16e4ced6..7b5d4deacfcd 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1544,9 +1544,6 @@ void __init kmem_cache_init(void)
1544 } 1544 }
1545 1545
1546 g_cpucache_up = EARLY; 1546 g_cpucache_up = EARLY;
1547
1548 /* Annotate slab for lockdep -- annotate the malloc caches */
1549 init_lock_keys();
1550} 1547}
1551 1548
1552void __init kmem_cache_init_late(void) 1549void __init kmem_cache_init_late(void)
@@ -1563,6 +1560,9 @@ void __init kmem_cache_init_late(void)
1563 /* Done! */ 1560 /* Done! */
1564 g_cpucache_up = FULL; 1561 g_cpucache_up = FULL;
1565 1562
1563 /* Annotate slab for lockdep -- annotate the malloc caches */
1564 init_lock_keys();
1565
1566 /* 1566 /*
1567 * Register a cpu startup notifier callback that initializes 1567 * Register a cpu startup notifier callback that initializes
1568 * cpu_cache_get for all new cpus 1568 * cpu_cache_get for all new cpus
@@ -2547,7 +2547,7 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
2547 } 2547 }
2548 2548
2549 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) 2549 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU))
2550 synchronize_rcu(); 2550 rcu_barrier();
2551 2551
2552 __kmem_cache_destroy(cachep); 2552 __kmem_cache_destroy(cachep);
2553 mutex_unlock(&cache_chain_mutex); 2553 mutex_unlock(&cache_chain_mutex);
diff --git a/mm/slob.c b/mm/slob.c
index c78742defdc6..9641da3d5e58 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -595,6 +595,8 @@ EXPORT_SYMBOL(kmem_cache_create);
595void kmem_cache_destroy(struct kmem_cache *c) 595void kmem_cache_destroy(struct kmem_cache *c)
596{ 596{
597 kmemleak_free(c); 597 kmemleak_free(c);
598 if (c->flags & SLAB_DESTROY_BY_RCU)
599 rcu_barrier();
598 slob_free(c, sizeof(struct kmem_cache)); 600 slob_free(c, sizeof(struct kmem_cache));
599} 601}
600EXPORT_SYMBOL(kmem_cache_destroy); 602EXPORT_SYMBOL(kmem_cache_destroy);
diff --git a/mm/slub.c b/mm/slub.c
index 819f056b39c6..b9f1491a58a1 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -21,7 +21,6 @@
21#include <linux/kmemcheck.h> 21#include <linux/kmemcheck.h>
22#include <linux/cpu.h> 22#include <linux/cpu.h>
23#include <linux/cpuset.h> 23#include <linux/cpuset.h>
24#include <linux/kmemleak.h>
25#include <linux/mempolicy.h> 24#include <linux/mempolicy.h>
26#include <linux/ctype.h> 25#include <linux/ctype.h>
27#include <linux/debugobjects.h> 26#include <linux/debugobjects.h>
@@ -2595,6 +2594,8 @@ static inline int kmem_cache_close(struct kmem_cache *s)
2595 */ 2594 */
2596void kmem_cache_destroy(struct kmem_cache *s) 2595void kmem_cache_destroy(struct kmem_cache *s)
2597{ 2596{
2597 if (s->flags & SLAB_DESTROY_BY_RCU)
2598 rcu_barrier();
2598 down_write(&slub_lock); 2599 down_write(&slub_lock);
2599 s->refcount--; 2600 s->refcount--;
2600 if (!s->refcount) { 2601 if (!s->refcount) {
@@ -2833,13 +2834,15 @@ EXPORT_SYMBOL(__kmalloc);
2833static void *kmalloc_large_node(size_t size, gfp_t flags, int node) 2834static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
2834{ 2835{
2835 struct page *page; 2836 struct page *page;
2837 void *ptr = NULL;
2836 2838
2837 flags |= __GFP_COMP | __GFP_NOTRACK; 2839 flags |= __GFP_COMP | __GFP_NOTRACK;
2838 page = alloc_pages_node(node, flags, get_order(size)); 2840 page = alloc_pages_node(node, flags, get_order(size));
2839 if (page) 2841 if (page)
2840 return page_address(page); 2842 ptr = page_address(page);
2841 else 2843
2842 return NULL; 2844 kmemleak_alloc(ptr, size, 1, flags);
2845 return ptr;
2843} 2846}
2844 2847
2845#ifdef CONFIG_NUMA 2848#ifdef CONFIG_NUMA
@@ -2924,6 +2927,7 @@ void kfree(const void *x)
2924 page = virt_to_head_page(x); 2927 page = virt_to_head_page(x);
2925 if (unlikely(!PageSlab(page))) { 2928 if (unlikely(!PageSlab(page))) {
2926 BUG_ON(!PageCompound(page)); 2929 BUG_ON(!PageCompound(page));
2930 kmemleak_free(x);
2927 put_page(page); 2931 put_page(page);
2928 return; 2932 return;
2929 } 2933 }
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 54155268dfca..dea7abd31098 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1104,7 +1104,7 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
1104 */ 1104 */
1105 if (nr_freed < nr_taken && !current_is_kswapd() && 1105 if (nr_freed < nr_taken && !current_is_kswapd() &&
1106 lumpy_reclaim) { 1106 lumpy_reclaim) {
1107 congestion_wait(WRITE, HZ/10); 1107 congestion_wait(BLK_RW_ASYNC, HZ/10);
1108 1108
1109 /* 1109 /*
1110 * The attempt at page out may have made some 1110 * The attempt at page out may have made some
@@ -1721,7 +1721,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
1721 1721
1722 /* Take a nap, wait for some writeback to complete */ 1722 /* Take a nap, wait for some writeback to complete */
1723 if (sc->nr_scanned && priority < DEF_PRIORITY - 2) 1723 if (sc->nr_scanned && priority < DEF_PRIORITY - 2)
1724 congestion_wait(WRITE, HZ/10); 1724 congestion_wait(BLK_RW_ASYNC, HZ/10);
1725 } 1725 }
1726 /* top priority shrink_zones still had more to do? don't OOM, then */ 1726 /* top priority shrink_zones still had more to do? don't OOM, then */
1727 if (!sc->all_unreclaimable && scanning_global_lru(sc)) 1727 if (!sc->all_unreclaimable && scanning_global_lru(sc))
@@ -1960,7 +1960,7 @@ loop_again:
1960 * another pass across the zones. 1960 * another pass across the zones.
1961 */ 1961 */
1962 if (total_scanned && priority < DEF_PRIORITY - 2) 1962 if (total_scanned && priority < DEF_PRIORITY - 2)
1963 congestion_wait(WRITE, HZ/10); 1963 congestion_wait(BLK_RW_ASYNC, HZ/10);
1964 1964
1965 /* 1965 /*
1966 * We do this so kswapd doesn't build up large priorities for 1966 * We do this so kswapd doesn't build up large priorities for
@@ -2233,7 +2233,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
2233 goto out; 2233 goto out;
2234 2234
2235 if (sc.nr_scanned && prio < DEF_PRIORITY - 2) 2235 if (sc.nr_scanned && prio < DEF_PRIORITY - 2)
2236 congestion_wait(WRITE, HZ / 10); 2236 congestion_wait(BLK_RW_ASYNC, HZ / 10);
2237 } 2237 }
2238 } 2238 }
2239 2239
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index a2a1814c7a8d..8c2588e4edc0 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -735,12 +735,14 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
735 if (!*p) 735 if (!*p)
736 continue; 736 continue;
737 token = match_token(p, tokens, args); 737 token = match_token(p, tokens, args);
738 r = match_int(&args[0], &option); 738 if (token != Opt_err) {
739 if (r < 0) { 739 r = match_int(&args[0], &option);
740 P9_DPRINTK(P9_DEBUG_ERROR, 740 if (r < 0) {
741 "integer field, but no integer?\n"); 741 P9_DPRINTK(P9_DEBUG_ERROR,
742 ret = r; 742 "integer field, but no integer?\n");
743 continue; 743 ret = r;
744 continue;
745 }
744 } 746 }
745 switch (token) { 747 switch (token) {
746 case Opt_port: 748 case Opt_port:
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 590b83963622..bfbe13786bb4 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -54,6 +54,7 @@
54#include <linux/capability.h> 54#include <linux/capability.h>
55#include <linux/module.h> 55#include <linux/module.h>
56#include <linux/if_arp.h> 56#include <linux/if_arp.h>
57#include <linux/smp_lock.h>
57#include <linux/termios.h> /* For TIOCOUTQ/INQ */ 58#include <linux/termios.h> /* For TIOCOUTQ/INQ */
58#include <net/datalink.h> 59#include <net/datalink.h>
59#include <net/psnap.h> 60#include <net/psnap.h>
diff --git a/net/atm/common.c b/net/atm/common.c
index c1c97936192c..8c4d843eb17f 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -92,7 +92,7 @@ static void vcc_sock_destruct(struct sock *sk)
92static void vcc_def_wakeup(struct sock *sk) 92static void vcc_def_wakeup(struct sock *sk)
93{ 93{
94 read_lock(&sk->sk_callback_lock); 94 read_lock(&sk->sk_callback_lock);
95 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 95 if (sk_has_sleeper(sk))
96 wake_up(sk->sk_sleep); 96 wake_up(sk->sk_sleep);
97 read_unlock(&sk->sk_callback_lock); 97 read_unlock(&sk->sk_callback_lock);
98} 98}
@@ -110,7 +110,7 @@ static void vcc_write_space(struct sock *sk)
110 read_lock(&sk->sk_callback_lock); 110 read_lock(&sk->sk_callback_lock);
111 111
112 if (vcc_writable(sk)) { 112 if (vcc_writable(sk)) {
113 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 113 if (sk_has_sleeper(sk))
114 wake_up_interruptible(sk->sk_sleep); 114 wake_up_interruptible(sk->sk_sleep);
115 115
116 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); 116 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
@@ -594,7 +594,7 @@ unsigned int vcc_poll(struct file *file, struct socket *sock, poll_table *wait)
594 struct atm_vcc *vcc; 594 struct atm_vcc *vcc;
595 unsigned int mask; 595 unsigned int mask;
596 596
597 poll_wait(file, sk->sk_sleep, wait); 597 sock_poll_wait(file, sk->sk_sleep, wait);
598 mask = 0; 598 mask = 0;
599 599
600 vcc = ATM_SD(sock); 600 vcc = ATM_SD(sock);
diff --git a/net/bridge/br.c b/net/bridge/br.c
index 9aac5213105a..e1241c76239a 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -93,7 +93,7 @@ static void __exit br_deinit(void)
93 93
94 unregister_pernet_subsys(&br_net_ops); 94 unregister_pernet_subsys(&br_net_ops);
95 95
96 synchronize_net(); 96 rcu_barrier(); /* Wait for completion of call_rcu()'s */
97 97
98 br_netfilter_fini(); 98 br_netfilter_fini();
99#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE) 99#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 58abee1f1df1..b0fe69211eef 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -712,7 +712,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
712 struct sock *sk = sock->sk; 712 struct sock *sk = sock->sk;
713 unsigned int mask; 713 unsigned int mask;
714 714
715 poll_wait(file, sk->sk_sleep, wait); 715 sock_poll_wait(file, sk->sk_sleep, wait);
716 mask = 0; 716 mask = 0;
717 717
718 /* exceptional events? */ 718 /* exceptional events? */
diff --git a/net/core/dev.c b/net/core/dev.c
index 60b572812278..70c27e0c7c32 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2823,9 +2823,11 @@ static void net_rx_action(struct softirq_action *h)
2823 * move the instance around on the list at-will. 2823 * move the instance around on the list at-will.
2824 */ 2824 */
2825 if (unlikely(work == weight)) { 2825 if (unlikely(work == weight)) {
2826 if (unlikely(napi_disable_pending(n))) 2826 if (unlikely(napi_disable_pending(n))) {
2827 __napi_complete(n); 2827 local_irq_enable();
2828 else 2828 napi_complete(n);
2829 local_irq_disable();
2830 } else
2829 list_move_tail(&n->poll_list, list); 2831 list_move_tail(&n->poll_list, list);
2830 } 2832 }
2831 2833
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 9675f312830d..df30feb2fc72 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -740,7 +740,7 @@ int netpoll_setup(struct netpoll *np)
740 np->name); 740 np->name);
741 break; 741 break;
742 } 742 }
743 cond_resched(); 743 msleep(1);
744 } 744 }
745 745
746 /* If carrier appears to come up instantly, we don't 746 /* If carrier appears to come up instantly, we don't
diff --git a/net/core/sock.c b/net/core/sock.c
index b0ba569bc973..6354863b1c68 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1715,7 +1715,7 @@ EXPORT_SYMBOL(sock_no_sendpage);
1715static void sock_def_wakeup(struct sock *sk) 1715static void sock_def_wakeup(struct sock *sk)
1716{ 1716{
1717 read_lock(&sk->sk_callback_lock); 1717 read_lock(&sk->sk_callback_lock);
1718 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 1718 if (sk_has_sleeper(sk))
1719 wake_up_interruptible_all(sk->sk_sleep); 1719 wake_up_interruptible_all(sk->sk_sleep);
1720 read_unlock(&sk->sk_callback_lock); 1720 read_unlock(&sk->sk_callback_lock);
1721} 1721}
@@ -1723,7 +1723,7 @@ static void sock_def_wakeup(struct sock *sk)
1723static void sock_def_error_report(struct sock *sk) 1723static void sock_def_error_report(struct sock *sk)
1724{ 1724{
1725 read_lock(&sk->sk_callback_lock); 1725 read_lock(&sk->sk_callback_lock);
1726 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 1726 if (sk_has_sleeper(sk))
1727 wake_up_interruptible_poll(sk->sk_sleep, POLLERR); 1727 wake_up_interruptible_poll(sk->sk_sleep, POLLERR);
1728 sk_wake_async(sk, SOCK_WAKE_IO, POLL_ERR); 1728 sk_wake_async(sk, SOCK_WAKE_IO, POLL_ERR);
1729 read_unlock(&sk->sk_callback_lock); 1729 read_unlock(&sk->sk_callback_lock);
@@ -1732,7 +1732,7 @@ static void sock_def_error_report(struct sock *sk)
1732static void sock_def_readable(struct sock *sk, int len) 1732static void sock_def_readable(struct sock *sk, int len)
1733{ 1733{
1734 read_lock(&sk->sk_callback_lock); 1734 read_lock(&sk->sk_callback_lock);
1735 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 1735 if (sk_has_sleeper(sk))
1736 wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN | 1736 wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN |
1737 POLLRDNORM | POLLRDBAND); 1737 POLLRDNORM | POLLRDBAND);
1738 sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); 1738 sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
@@ -1747,7 +1747,7 @@ static void sock_def_write_space(struct sock *sk)
1747 * progress. --DaveM 1747 * progress. --DaveM
1748 */ 1748 */
1749 if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) { 1749 if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) {
1750 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 1750 if (sk_has_sleeper(sk))
1751 wake_up_interruptible_sync_poll(sk->sk_sleep, POLLOUT | 1751 wake_up_interruptible_sync_poll(sk->sk_sleep, POLLOUT |
1752 POLLWRNORM | POLLWRBAND); 1752 POLLWRNORM | POLLWRBAND);
1753 1753
diff --git a/net/dccp/output.c b/net/dccp/output.c
index c0e88c16d088..c96119fda688 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -196,7 +196,7 @@ void dccp_write_space(struct sock *sk)
196{ 196{
197 read_lock(&sk->sk_callback_lock); 197 read_lock(&sk->sk_callback_lock);
198 198
199 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 199 if (sk_has_sleeper(sk))
200 wake_up_interruptible(sk->sk_sleep); 200 wake_up_interruptible(sk->sk_sleep);
201 /* Should agree with poll, otherwise some programs break */ 201 /* Should agree with poll, otherwise some programs break */
202 if (sock_writeable(sk)) 202 if (sock_writeable(sk))
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 314a1b5c033c..94ca8eaace7d 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -311,7 +311,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock,
311 unsigned int mask; 311 unsigned int mask;
312 struct sock *sk = sock->sk; 312 struct sock *sk = sock->sk;
313 313
314 poll_wait(file, sk->sk_sleep, wait); 314 sock_poll_wait(file, sk->sk_sleep, wait);
315 if (sk->sk_state == DCCP_LISTEN) 315 if (sk->sk_state == DCCP_LISTEN)
316 return inet_csk_listen_poll(sk); 316 return inet_csk_listen_poll(sk);
317 317
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index d351b8db0df5..77d40289653c 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -2413,6 +2413,8 @@ static void __exit decnet_exit(void)
2413 proc_net_remove(&init_net, "decnet"); 2413 proc_net_remove(&init_net, "decnet");
2414 2414
2415 proto_unregister(&dn_proto); 2415 proto_unregister(&dn_proto);
2416
2417 rcu_barrier_bh(); /* Wait for completion of call_rcu_bh()'s */
2416} 2418}
2417module_exit(decnet_exit); 2419module_exit(decnet_exit);
2418#endif 2420#endif
diff --git a/net/dsa/mv88e6xxx.c b/net/dsa/mv88e6xxx.c
index 4e4d8b5ad03d..efe661a9def4 100644
--- a/net/dsa/mv88e6xxx.c
+++ b/net/dsa/mv88e6xxx.c
@@ -418,7 +418,7 @@ static int mv88e6xxx_stats_wait(struct dsa_switch *ds)
418 int i; 418 int i;
419 419
420 for (i = 0; i < 10; i++) { 420 for (i = 0; i < 10; i++) {
421 ret = REG_READ(REG_GLOBAL2, 0x1d); 421 ret = REG_READ(REG_GLOBAL, 0x1d);
422 if ((ret & 0x8000) == 0) 422 if ((ret & 0x8000) == 0)
423 return 0; 423 return 0;
424 } 424 }
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c
index 105ad10876af..27eda9fdf3c2 100644
--- a/net/ieee802154/netlink.c
+++ b/net/ieee802154/netlink.c
@@ -276,6 +276,9 @@ static struct net_device *ieee802154_nl_get_dev(struct genl_info *info)
276 else 276 else
277 return NULL; 277 return NULL;
278 278
279 if (!dev)
280 return NULL;
281
279 if (dev->type != ARPHRD_IEEE802154) { 282 if (dev->type != ARPHRD_IEEE802154) {
280 dev_put(dev); 283 dev_put(dev);
281 return NULL; 284 return NULL;
@@ -521,3 +524,6 @@ static void __exit ieee802154_nl_exit(void)
521} 524}
522module_exit(ieee802154_nl_exit); 525module_exit(ieee802154_nl_exit);
523 526
527MODULE_LICENSE("GPL v2");
528MODULE_DESCRIPTION("ieee 802.15.4 configuration interface");
529
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 8a3881e28aca..c29d75d8f1b1 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -801,11 +801,8 @@ static int arp_process(struct sk_buff *skb)
801 * cache. 801 * cache.
802 */ 802 */
803 803
804 /* 804 /* Special case: IPv4 duplicate address detection packet (RFC2131) */
805 * Special case: IPv4 duplicate address detection packet (RFC2131) 805 if (sip == 0) {
806 * and Gratuitous ARP/ARP Announce. (RFC3927, Section 2.4)
807 */
808 if (sip == 0 || tip == sip) {
809 if (arp->ar_op == htons(ARPOP_REQUEST) && 806 if (arp->ar_op == htons(ARPOP_REQUEST) &&
810 inet_addr_type(net, tip) == RTN_LOCAL && 807 inet_addr_type(net, tip) == RTN_LOCAL &&
811 !arp_ignore(in_dev, sip, tip)) 808 !arp_ignore(in_dev, sip, tip))
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 012cf5a68581..63c2fa7b68c4 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -316,8 +316,8 @@ static inline void check_tnode(const struct tnode *tn)
316 316
317static const int halve_threshold = 25; 317static const int halve_threshold = 25;
318static const int inflate_threshold = 50; 318static const int inflate_threshold = 50;
319static const int halve_threshold_root = 8; 319static const int halve_threshold_root = 15;
320static const int inflate_threshold_root = 15; 320static const int inflate_threshold_root = 25;
321 321
322 322
323static void __alias_free_mem(struct rcu_head *head) 323static void __alias_free_mem(struct rcu_head *head)
@@ -1021,6 +1021,9 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)
1021 (struct node *)tn, wasfull); 1021 (struct node *)tn, wasfull);
1022 1022
1023 tp = node_parent((struct node *) tn); 1023 tp = node_parent((struct node *) tn);
1024 if (!tp)
1025 rcu_assign_pointer(t->trie, (struct node *)tn);
1026
1024 tnode_free_flush(); 1027 tnode_free_flush();
1025 if (!tp) 1028 if (!tp)
1026 break; 1029 break;
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 490ce20faf38..db46b4b5b2b9 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -440,6 +440,9 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
440 /* Remove any debris in the socket control block */ 440 /* Remove any debris in the socket control block */
441 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); 441 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
442 442
443 /* Must drop socket now because of tproxy. */
444 skb_orphan(skb);
445
443 return NF_HOOK(PF_INET, NF_INET_PRE_ROUTING, skb, dev, NULL, 446 return NF_HOOK(PF_INET, NF_INET_PRE_ROUTING, skb, dev, NULL,
444 ip_rcv_finish); 447 ip_rcv_finish);
445 448
diff --git a/net/ipv4/netfilter/nf_nat_helper.c b/net/ipv4/netfilter/nf_nat_helper.c
index 155c008626c8..09172a65d9b6 100644
--- a/net/ipv4/netfilter/nf_nat_helper.c
+++ b/net/ipv4/netfilter/nf_nat_helper.c
@@ -191,7 +191,8 @@ nf_nat_mangle_tcp_packet(struct sk_buff *skb,
191 ct, ctinfo); 191 ct, ctinfo);
192 /* Tell TCP window tracking about seq change */ 192 /* Tell TCP window tracking about seq change */
193 nf_conntrack_tcp_update(skb, ip_hdrlen(skb), 193 nf_conntrack_tcp_update(skb, ip_hdrlen(skb),
194 ct, CTINFO2DIR(ctinfo)); 194 ct, CTINFO2DIR(ctinfo),
195 (int)rep_len - (int)match_len);
195 196
196 nf_conntrack_event_cache(IPCT_NATSEQADJ, ct); 197 nf_conntrack_event_cache(IPCT_NATSEQADJ, ct);
197 } 198 }
@@ -377,6 +378,7 @@ nf_nat_seq_adjust(struct sk_buff *skb,
377 struct tcphdr *tcph; 378 struct tcphdr *tcph;
378 int dir; 379 int dir;
379 __be32 newseq, newack; 380 __be32 newseq, newack;
381 s16 seqoff, ackoff;
380 struct nf_conn_nat *nat = nfct_nat(ct); 382 struct nf_conn_nat *nat = nfct_nat(ct);
381 struct nf_nat_seq *this_way, *other_way; 383 struct nf_nat_seq *this_way, *other_way;
382 384
@@ -390,15 +392,18 @@ nf_nat_seq_adjust(struct sk_buff *skb,
390 392
391 tcph = (void *)skb->data + ip_hdrlen(skb); 393 tcph = (void *)skb->data + ip_hdrlen(skb);
392 if (after(ntohl(tcph->seq), this_way->correction_pos)) 394 if (after(ntohl(tcph->seq), this_way->correction_pos))
393 newseq = htonl(ntohl(tcph->seq) + this_way->offset_after); 395 seqoff = this_way->offset_after;
394 else 396 else
395 newseq = htonl(ntohl(tcph->seq) + this_way->offset_before); 397 seqoff = this_way->offset_before;
396 398
397 if (after(ntohl(tcph->ack_seq) - other_way->offset_before, 399 if (after(ntohl(tcph->ack_seq) - other_way->offset_before,
398 other_way->correction_pos)) 400 other_way->correction_pos))
399 newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_after); 401 ackoff = other_way->offset_after;
400 else 402 else
401 newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_before); 403 ackoff = other_way->offset_before;
404
405 newseq = htonl(ntohl(tcph->seq) + seqoff);
406 newack = htonl(ntohl(tcph->ack_seq) - ackoff);
402 407
403 inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0); 408 inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0);
404 inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0); 409 inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0);
@@ -413,7 +418,7 @@ nf_nat_seq_adjust(struct sk_buff *skb,
413 if (!nf_nat_sack_adjust(skb, tcph, ct, ctinfo)) 418 if (!nf_nat_sack_adjust(skb, tcph, ct, ctinfo))
414 return 0; 419 return 0;
415 420
416 nf_conntrack_tcp_update(skb, ip_hdrlen(skb), ct, dir); 421 nf_conntrack_tcp_update(skb, ip_hdrlen(skb), ct, dir, seqoff);
417 422
418 return 1; 423 return 1;
419} 424}
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 17b89c523f9d..91145244ea63 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -339,7 +339,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
339 struct sock *sk = sock->sk; 339 struct sock *sk = sock->sk;
340 struct tcp_sock *tp = tcp_sk(sk); 340 struct tcp_sock *tp = tcp_sk(sk);
341 341
342 poll_wait(file, sk->sk_sleep, wait); 342 sock_poll_wait(file, sk->sk_sleep, wait);
343 if (sk->sk_state == TCP_LISTEN) 343 if (sk->sk_state == TCP_LISTEN)
344 return inet_csk_listen_poll(sk); 344 return inet_csk_listen_poll(sk);
345 345
@@ -903,13 +903,17 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
903 iov++; 903 iov++;
904 904
905 while (seglen > 0) { 905 while (seglen > 0) {
906 int copy; 906 int copy = 0;
907 int max = size_goal;
907 908
908 skb = tcp_write_queue_tail(sk); 909 skb = tcp_write_queue_tail(sk);
910 if (tcp_send_head(sk)) {
911 if (skb->ip_summed == CHECKSUM_NONE)
912 max = mss_now;
913 copy = max - skb->len;
914 }
909 915
910 if (!tcp_send_head(sk) || 916 if (copy <= 0) {
911 (copy = size_goal - skb->len) <= 0) {
912
913new_segment: 917new_segment:
914 /* Allocate new segment. If the interface is SG, 918 /* Allocate new segment. If the interface is SG,
915 * allocate skb fitting to single page. 919 * allocate skb fitting to single page.
@@ -930,6 +934,7 @@ new_segment:
930 934
931 skb_entail(sk, skb); 935 skb_entail(sk, skb);
932 copy = size_goal; 936 copy = size_goal;
937 max = size_goal;
933 } 938 }
934 939
935 /* Try to append data to the end of skb. */ 940 /* Try to append data to the end of skb. */
@@ -1028,7 +1033,7 @@ new_segment:
1028 if ((seglen -= copy) == 0 && iovlen == 0) 1033 if ((seglen -= copy) == 0 && iovlen == 0)
1029 goto out; 1034 goto out;
1030 1035
1031 if (skb->len < size_goal || (flags & MSG_OOB)) 1036 if (skb->len < max || (flags & MSG_OOB))
1032 continue; 1037 continue;
1033 1038
1034 if (forced_push(tp)) { 1039 if (forced_push(tp)) {
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 43bbba7926ee..f8d67ccc64f3 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -128,7 +128,8 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
128 goto kill_with_rst; 128 goto kill_with_rst;
129 129
130 /* Dup ACK? */ 130 /* Dup ACK? */
131 if (!after(TCP_SKB_CB(skb)->end_seq, tcptw->tw_rcv_nxt) || 131 if (!th->ack ||
132 !after(TCP_SKB_CB(skb)->end_seq, tcptw->tw_rcv_nxt) ||
132 TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq) { 133 TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq) {
133 inet_twsk_put(tw); 134 inet_twsk_put(tw);
134 return TCP_TW_SUCCESS; 135 return TCP_TW_SUCCESS;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 416fc4c2e7eb..5bdf08d312d9 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -725,7 +725,8 @@ static void tcp_queue_skb(struct sock *sk, struct sk_buff *skb)
725static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, 725static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb,
726 unsigned int mss_now) 726 unsigned int mss_now)
727{ 727{
728 if (skb->len <= mss_now || !sk_can_gso(sk)) { 728 if (skb->len <= mss_now || !sk_can_gso(sk) ||
729 skb->ip_summed == CHECKSUM_NONE) {
729 /* Avoid the costly divide in the normal 730 /* Avoid the costly divide in the normal
730 * non-TSO case. 731 * non-TSO case.
731 */ 732 */
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 60d918c96a4f..0071ee6f441f 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -136,7 +136,8 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
136 case IPPROTO_TCP: 136 case IPPROTO_TCP:
137 case IPPROTO_SCTP: 137 case IPPROTO_SCTP:
138 case IPPROTO_DCCP: 138 case IPPROTO_DCCP:
139 if (pskb_may_pull(skb, xprth + 4 - skb->data)) { 139 if (xprth + 4 < skb->data ||
140 pskb_may_pull(skb, xprth + 4 - skb->data)) {
140 __be16 *ports = (__be16 *)xprth; 141 __be16 *ports = (__be16 *)xprth;
141 142
142 fl->fl_ip_sport = ports[!!reverse]; 143 fl->fl_ip_sport = ports[!!reverse];
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 8c1e86afbbf5..43b3c9f89c12 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1916,8 +1916,32 @@ ok:
1916 update_lft = 1; 1916 update_lft = 1;
1917 else if (stored_lft <= MIN_VALID_LIFETIME) { 1917 else if (stored_lft <= MIN_VALID_LIFETIME) {
1918 /* valid_lft <= stored_lft is always true */ 1918 /* valid_lft <= stored_lft is always true */
1919 /* XXX: IPsec */ 1919 /*
1920 update_lft = 0; 1920 * RFC 4862 Section 5.5.3e:
1921 * "Note that the preferred lifetime of
1922 * the corresponding address is always
1923 * reset to the Preferred Lifetime in
1924 * the received Prefix Information
1925 * option, regardless of whether the
1926 * valid lifetime is also reset or
1927 * ignored."
1928 *
1929 * So if the preferred lifetime in
1930 * this advertisement is different
1931 * than what we have stored, but the
1932 * valid lifetime is invalid, just
1933 * reset prefered_lft.
1934 *
1935 * We must set the valid lifetime
1936 * to the stored lifetime since we'll
1937 * be updating the timestamp below,
1938 * else we'll set it back to the
1939 * minumum.
1940 */
1941 if (prefered_lft != ifp->prefered_lft) {
1942 valid_lft = stored_lft;
1943 update_lft = 1;
1944 }
1921 } else { 1945 } else {
1922 valid_lft = MIN_VALID_LIFETIME; 1946 valid_lft = MIN_VALID_LIFETIME;
1923 if (valid_lft < prefered_lft) 1947 if (valid_lft < prefered_lft)
@@ -3085,7 +3109,7 @@ restart:
3085 spin_unlock(&ifp->lock); 3109 spin_unlock(&ifp->lock);
3086 continue; 3110 continue;
3087 } else if (age >= ifp->prefered_lft) { 3111 } else if (age >= ifp->prefered_lft) {
3088 /* jiffies - ifp->tsamp > age >= ifp->prefered_lft */ 3112 /* jiffies - ifp->tstamp > age >= ifp->prefered_lft */
3089 int deprecate = 0; 3113 int deprecate = 0;
3090 3114
3091 if (!(ifp->flags&IFA_F_DEPRECATED)) { 3115 if (!(ifp->flags&IFA_F_DEPRECATED)) {
@@ -3362,7 +3386,10 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
3362 valid = ifa->valid_lft; 3386 valid = ifa->valid_lft;
3363 if (preferred != INFINITY_LIFE_TIME) { 3387 if (preferred != INFINITY_LIFE_TIME) {
3364 long tval = (jiffies - ifa->tstamp)/HZ; 3388 long tval = (jiffies - ifa->tstamp)/HZ;
3365 preferred -= tval; 3389 if (preferred > tval)
3390 preferred -= tval;
3391 else
3392 preferred = 0;
3366 if (valid != INFINITY_LIFE_TIME) 3393 if (valid != INFINITY_LIFE_TIME)
3367 valid -= tval; 3394 valid -= tval;
3368 } 3395 }
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 85b3d0036afd..caa0278d30a9 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -1284,6 +1284,8 @@ static void __exit inet6_exit(void)
1284 proto_unregister(&udplitev6_prot); 1284 proto_unregister(&udplitev6_prot);
1285 proto_unregister(&udpv6_prot); 1285 proto_unregister(&udpv6_prot);
1286 proto_unregister(&tcpv6_prot); 1286 proto_unregister(&tcpv6_prot);
1287
1288 rcu_barrier(); /* Wait for completion of call_rcu()'s */
1287} 1289}
1288module_exit(inet6_exit); 1290module_exit(inet6_exit);
1289 1291
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index c3a07d75b5f5..6d6a4277c677 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -139,6 +139,9 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
139 139
140 rcu_read_unlock(); 140 rcu_read_unlock();
141 141
142 /* Must drop socket now because of tproxy. */
143 skb_orphan(skb);
144
142 return NF_HOOK(PF_INET6, NF_INET_PRE_ROUTING, skb, dev, NULL, 145 return NF_HOOK(PF_INET6, NF_INET_PRE_ROUTING, skb, dev, NULL,
143 ip6_rcv_finish); 146 ip6_rcv_finish);
144err: 147err:
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index b4b16a43f277..3a3c677bc0f2 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -157,7 +157,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
157 ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr); 157 ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr);
158 ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr); 158 ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr);
159 159
160 while (pskb_may_pull(skb, nh + offset + 1 - skb->data)) { 160 while (nh + offset + 1 < skb->data ||
161 pskb_may_pull(skb, nh + offset + 1 - skb->data)) {
161 nh = skb_network_header(skb); 162 nh = skb_network_header(skb);
162 exthdr = (struct ipv6_opt_hdr *)(nh + offset); 163 exthdr = (struct ipv6_opt_hdr *)(nh + offset);
163 164
@@ -177,7 +178,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
177 case IPPROTO_TCP: 178 case IPPROTO_TCP:
178 case IPPROTO_SCTP: 179 case IPPROTO_SCTP:
179 case IPPROTO_DCCP: 180 case IPPROTO_DCCP:
180 if (!onlyproto && pskb_may_pull(skb, nh + offset + 4 - skb->data)) { 181 if (!onlyproto && (nh + offset + 4 < skb->data ||
182 pskb_may_pull(skb, nh + offset + 4 - skb->data))) {
181 __be16 *ports = (__be16 *)exthdr; 183 __be16 *ports = (__be16 *)exthdr;
182 184
183 fl->fl_ip_sport = ports[!!reverse]; 185 fl->fl_ip_sport = ports[!!reverse];
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index 417b0e309495..f1118d92a191 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -41,6 +41,7 @@
41#include <linux/netdevice.h> 41#include <linux/netdevice.h>
42#include <linux/uio.h> 42#include <linux/uio.h>
43#include <linux/skbuff.h> 43#include <linux/skbuff.h>
44#include <linux/smp_lock.h>
44#include <linux/socket.h> 45#include <linux/socket.h>
45#include <linux/sockios.h> 46#include <linux/sockios.h>
46#include <linux/string.h> 47#include <linux/string.h>
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index cb762c8723ea..80cf29aae096 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -45,6 +45,7 @@
45#include <linux/capability.h> 45#include <linux/capability.h>
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/types.h> 47#include <linux/types.h>
48#include <linux/smp_lock.h>
48#include <linux/socket.h> 49#include <linux/socket.h>
49#include <linux/sockios.h> 50#include <linux/sockios.h>
50#include <linux/init.h> 51#include <linux/init.h>
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h
index bccf4d0059f0..b001c361ad30 100644
--- a/net/irda/irnet/irnet.h
+++ b/net/irda/irnet/irnet.h
@@ -241,7 +241,6 @@
241#include <linux/module.h> 241#include <linux/module.h>
242 242
243#include <linux/kernel.h> 243#include <linux/kernel.h>
244#include <linux/smp_lock.h>
245#include <linux/skbuff.h> 244#include <linux/skbuff.h>
246#include <linux/tty.h> 245#include <linux/tty.h>
247#include <linux/proc_fs.h> 246#include <linux/proc_fs.h>
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c
index 6d8ae03c14f5..68cbcb19cbd8 100644
--- a/net/irda/irnet/irnet_ppp.c
+++ b/net/irda/irnet/irnet_ppp.c
@@ -13,6 +13,7 @@
13 * 2) as a control channel (write commands, read events) 13 * 2) as a control channel (write commands, read events)
14 */ 14 */
15 15
16#include <linux/smp_lock.h>
16#include "irnet_ppp.h" /* Private header */ 17#include "irnet_ppp.h" /* Private header */
17/* Please put other headers in irnet.h - Thanks */ 18/* Please put other headers in irnet.h - Thanks */
18 19
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 6be5f92d1094..49c15b48408e 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -306,7 +306,7 @@ static inline int iucv_below_msglim(struct sock *sk)
306static void iucv_sock_wake_msglim(struct sock *sk) 306static void iucv_sock_wake_msglim(struct sock *sk)
307{ 307{
308 read_lock(&sk->sk_callback_lock); 308 read_lock(&sk->sk_callback_lock);
309 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 309 if (sk_has_sleeper(sk))
310 wake_up_interruptible_all(sk->sk_sleep); 310 wake_up_interruptible_all(sk->sk_sleep);
311 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); 311 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
312 read_unlock(&sk->sk_callback_lock); 312 read_unlock(&sk->sk_callback_lock);
@@ -1256,7 +1256,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
1256 struct sock *sk = sock->sk; 1256 struct sock *sk = sock->sk;
1257 unsigned int mask = 0; 1257 unsigned int mask = 0;
1258 1258
1259 poll_wait(file, sk->sk_sleep, wait); 1259 sock_poll_wait(file, sk->sk_sleep, wait);
1260 1260
1261 if (sk->sk_state == IUCV_LISTEN) 1261 if (sk->sk_state == IUCV_LISTEN)
1262 return iucv_accept_poll(sk); 1262 return iucv_accept_poll(sk);
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index fc712e60705d..11cf45bce38a 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -494,7 +494,7 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
494 * should it be using the interface and enqueuing 494 * should it be using the interface and enqueuing
495 * frames at this very time on another CPU. 495 * frames at this very time on another CPU.
496 */ 496 */
497 synchronize_rcu(); 497 rcu_barrier(); /* Wait for RX path and call_rcu()'s */
498 skb_queue_purge(&sdata->u.mesh.skb_queue); 498 skb_queue_purge(&sdata->u.mesh.skb_queue);
499} 499}
500 500
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 003cb470ac84..f49ef288e2e2 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -637,7 +637,7 @@ static void mesh_queue_preq(struct mesh_path *mpath, u8 flags)
637 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 637 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
638 struct mesh_preq_queue *preq_node; 638 struct mesh_preq_queue *preq_node;
639 639
640 preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_KERNEL); 640 preq_node = kmalloc(sizeof(struct mesh_preq_queue), GFP_ATOMIC);
641 if (!preq_node) { 641 if (!preq_node) {
642 printk(KERN_DEBUG "Mesh HWMP: could not allocate PREQ node\n"); 642 printk(KERN_DEBUG "Mesh HWMP: could not allocate PREQ node\n");
643 return; 643 return;
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index b218b98fba7f..37771abd8f5a 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -66,7 +66,7 @@ rix_to_ndx(struct minstrel_sta_info *mi, int rix)
66 for (i = rix; i >= 0; i--) 66 for (i = rix; i >= 0; i--)
67 if (mi->r[i].rix == rix) 67 if (mi->r[i].rix == rix)
68 break; 68 break;
69 WARN_ON(mi->r[i].rix != rix); 69 WARN_ON(i < 0);
70 return i; 70 return i;
71} 71}
72 72
@@ -181,6 +181,9 @@ minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
181 break; 181 break;
182 182
183 ndx = rix_to_ndx(mi, ar[i].idx); 183 ndx = rix_to_ndx(mi, ar[i].idx);
184 if (ndx < 0)
185 continue;
186
184 mi->r[ndx].attempts += ar[i].count; 187 mi->r[ndx].attempts += ar[i].count;
185 188
186 if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0)) 189 if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0))
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index afde8f991646..2032dfe25ca8 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -617,8 +617,10 @@ err1:
617void nf_conntrack_expect_fini(struct net *net) 617void nf_conntrack_expect_fini(struct net *net)
618{ 618{
619 exp_proc_remove(net); 619 exp_proc_remove(net);
620 if (net_eq(net, &init_net)) 620 if (net_eq(net, &init_net)) {
621 rcu_barrier(); /* Wait for call_rcu() before destroy */
621 kmem_cache_destroy(nf_ct_expect_cachep); 622 kmem_cache_destroy(nf_ct_expect_cachep);
623 }
622 nf_ct_free_hashtable(net->ct.expect_hash, net->ct.expect_vmalloc, 624 nf_ct_free_hashtable(net->ct.expect_hash, net->ct.expect_vmalloc,
623 nf_ct_expect_hsize); 625 nf_ct_expect_hsize);
624} 626}
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c
index 4b2c769d555f..fef95be334bd 100644
--- a/net/netfilter/nf_conntrack_extend.c
+++ b/net/netfilter/nf_conntrack_extend.c
@@ -186,6 +186,6 @@ void nf_ct_extend_unregister(struct nf_ct_ext_type *type)
186 rcu_assign_pointer(nf_ct_ext_types[type->id], NULL); 186 rcu_assign_pointer(nf_ct_ext_types[type->id], NULL);
187 update_alloc_size(type); 187 update_alloc_size(type);
188 mutex_unlock(&nf_ct_ext_type_mutex); 188 mutex_unlock(&nf_ct_ext_type_mutex);
189 synchronize_rcu(); 189 rcu_barrier(); /* Wait for completion of call_rcu()'s */
190} 190}
191EXPORT_SYMBOL_GPL(nf_ct_extend_unregister); 191EXPORT_SYMBOL_GPL(nf_ct_extend_unregister);
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 33fc0a443f3d..97a82ba75376 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -720,8 +720,8 @@ static bool tcp_in_window(const struct nf_conn *ct,
720/* Caller must linearize skb at tcp header. */ 720/* Caller must linearize skb at tcp header. */
721void nf_conntrack_tcp_update(const struct sk_buff *skb, 721void nf_conntrack_tcp_update(const struct sk_buff *skb,
722 unsigned int dataoff, 722 unsigned int dataoff,
723 struct nf_conn *ct, 723 struct nf_conn *ct, int dir,
724 int dir) 724 s16 offset)
725{ 725{
726 const struct tcphdr *tcph = (const void *)skb->data + dataoff; 726 const struct tcphdr *tcph = (const void *)skb->data + dataoff;
727 const struct ip_ct_tcp_state *sender = &ct->proto.tcp.seen[dir]; 727 const struct ip_ct_tcp_state *sender = &ct->proto.tcp.seen[dir];
@@ -734,7 +734,7 @@ void nf_conntrack_tcp_update(const struct sk_buff *skb,
734 /* 734 /*
735 * We have to worry for the ack in the reply packet only... 735 * We have to worry for the ack in the reply packet only...
736 */ 736 */
737 if (after(end, ct->proto.tcp.seen[dir].td_end)) 737 if (ct->proto.tcp.seen[dir].td_end + offset == end)
738 ct->proto.tcp.seen[dir].td_end = end; 738 ct->proto.tcp.seen[dir].td_end = end;
739 ct->proto.tcp.last_end = end; 739 ct->proto.tcp.last_end = end;
740 spin_unlock_bh(&ct->lock); 740 spin_unlock_bh(&ct->lock);
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index 0b7139f3dd78..fc581800698e 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -129,7 +129,7 @@ conntrack_addrcmp(const union nf_inet_addr *kaddr,
129 129
130static inline bool 130static inline bool
131conntrack_mt_origsrc(const struct nf_conn *ct, 131conntrack_mt_origsrc(const struct nf_conn *ct,
132 const struct xt_conntrack_mtinfo1 *info, 132 const struct xt_conntrack_mtinfo2 *info,
133 u_int8_t family) 133 u_int8_t family)
134{ 134{
135 return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3, 135 return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3,
@@ -138,7 +138,7 @@ conntrack_mt_origsrc(const struct nf_conn *ct,
138 138
139static inline bool 139static inline bool
140conntrack_mt_origdst(const struct nf_conn *ct, 140conntrack_mt_origdst(const struct nf_conn *ct,
141 const struct xt_conntrack_mtinfo1 *info, 141 const struct xt_conntrack_mtinfo2 *info,
142 u_int8_t family) 142 u_int8_t family)
143{ 143{
144 return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3, 144 return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3,
@@ -147,7 +147,7 @@ conntrack_mt_origdst(const struct nf_conn *ct,
147 147
148static inline bool 148static inline bool
149conntrack_mt_replsrc(const struct nf_conn *ct, 149conntrack_mt_replsrc(const struct nf_conn *ct,
150 const struct xt_conntrack_mtinfo1 *info, 150 const struct xt_conntrack_mtinfo2 *info,
151 u_int8_t family) 151 u_int8_t family)
152{ 152{
153 return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3, 153 return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3,
@@ -156,7 +156,7 @@ conntrack_mt_replsrc(const struct nf_conn *ct,
156 156
157static inline bool 157static inline bool
158conntrack_mt_repldst(const struct nf_conn *ct, 158conntrack_mt_repldst(const struct nf_conn *ct,
159 const struct xt_conntrack_mtinfo1 *info, 159 const struct xt_conntrack_mtinfo2 *info,
160 u_int8_t family) 160 u_int8_t family)
161{ 161{
162 return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3, 162 return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3,
@@ -164,7 +164,7 @@ conntrack_mt_repldst(const struct nf_conn *ct,
164} 164}
165 165
166static inline bool 166static inline bool
167ct_proto_port_check(const struct xt_conntrack_mtinfo1 *info, 167ct_proto_port_check(const struct xt_conntrack_mtinfo2 *info,
168 const struct nf_conn *ct) 168 const struct nf_conn *ct)
169{ 169{
170 const struct nf_conntrack_tuple *tuple; 170 const struct nf_conntrack_tuple *tuple;
@@ -204,7 +204,7 @@ ct_proto_port_check(const struct xt_conntrack_mtinfo1 *info,
204static bool 204static bool
205conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par) 205conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par)
206{ 206{
207 const struct xt_conntrack_mtinfo1 *info = par->matchinfo; 207 const struct xt_conntrack_mtinfo2 *info = par->matchinfo;
208 enum ip_conntrack_info ctinfo; 208 enum ip_conntrack_info ctinfo;
209 const struct nf_conn *ct; 209 const struct nf_conn *ct;
210 unsigned int statebit; 210 unsigned int statebit;
@@ -278,6 +278,16 @@ conntrack_mt(const struct sk_buff *skb, const struct xt_match_param *par)
278 return true; 278 return true;
279} 279}
280 280
281static bool
282conntrack_mt_v1(const struct sk_buff *skb, const struct xt_match_param *par)
283{
284 const struct xt_conntrack_mtinfo2 *const *info = par->matchinfo;
285 struct xt_match_param newpar = *par;
286
287 newpar.matchinfo = *info;
288 return conntrack_mt(skb, &newpar);
289}
290
281static bool conntrack_mt_check(const struct xt_mtchk_param *par) 291static bool conntrack_mt_check(const struct xt_mtchk_param *par)
282{ 292{
283 if (nf_ct_l3proto_try_module_get(par->family) < 0) { 293 if (nf_ct_l3proto_try_module_get(par->family) < 0) {
@@ -288,11 +298,45 @@ static bool conntrack_mt_check(const struct xt_mtchk_param *par)
288 return true; 298 return true;
289} 299}
290 300
301static bool conntrack_mt_check_v1(const struct xt_mtchk_param *par)
302{
303 struct xt_conntrack_mtinfo1 *info = par->matchinfo;
304 struct xt_conntrack_mtinfo2 *up;
305 int ret = conntrack_mt_check(par);
306
307 if (ret < 0)
308 return ret;
309
310 up = kmalloc(sizeof(*up), GFP_KERNEL);
311 if (up == NULL) {
312 nf_ct_l3proto_module_put(par->family);
313 return -ENOMEM;
314 }
315
316 /*
317 * The strategy here is to minimize the overhead of v1 matching,
318 * by prebuilding a v2 struct and putting the pointer into the
319 * v1 dataspace.
320 */
321 memcpy(up, info, offsetof(typeof(*info), state_mask));
322 up->state_mask = info->state_mask;
323 up->status_mask = info->status_mask;
324 *(void **)info = up;
325 return true;
326}
327
291static void conntrack_mt_destroy(const struct xt_mtdtor_param *par) 328static void conntrack_mt_destroy(const struct xt_mtdtor_param *par)
292{ 329{
293 nf_ct_l3proto_module_put(par->family); 330 nf_ct_l3proto_module_put(par->family);
294} 331}
295 332
333static void conntrack_mt_destroy_v1(const struct xt_mtdtor_param *par)
334{
335 struct xt_conntrack_mtinfo2 **info = par->matchinfo;
336 kfree(*info);
337 conntrack_mt_destroy(par);
338}
339
296#ifdef CONFIG_COMPAT 340#ifdef CONFIG_COMPAT
297struct compat_xt_conntrack_info 341struct compat_xt_conntrack_info
298{ 342{
@@ -363,6 +407,16 @@ static struct xt_match conntrack_mt_reg[] __read_mostly = {
363 .revision = 1, 407 .revision = 1,
364 .family = NFPROTO_UNSPEC, 408 .family = NFPROTO_UNSPEC,
365 .matchsize = sizeof(struct xt_conntrack_mtinfo1), 409 .matchsize = sizeof(struct xt_conntrack_mtinfo1),
410 .match = conntrack_mt_v1,
411 .checkentry = conntrack_mt_check_v1,
412 .destroy = conntrack_mt_destroy_v1,
413 .me = THIS_MODULE,
414 },
415 {
416 .name = "conntrack",
417 .revision = 2,
418 .family = NFPROTO_UNSPEC,
419 .matchsize = sizeof(struct xt_conntrack_mtinfo2),
366 .match = conntrack_mt, 420 .match = conntrack_mt,
367 .checkentry = conntrack_mt_check, 421 .checkentry = conntrack_mt_check,
368 .destroy = conntrack_mt_destroy, 422 .destroy = conntrack_mt_destroy,
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 80a322d77909..b0d6ddd82a9d 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -69,10 +69,27 @@ static struct phonet_device *__phonet_get(struct net_device *dev)
69 return NULL; 69 return NULL;
70} 70}
71 71
72static void __phonet_device_free(struct phonet_device *pnd) 72static void phonet_device_destroy(struct net_device *dev)
73{ 73{
74 list_del(&pnd->list); 74 struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev));
75 kfree(pnd); 75 struct phonet_device *pnd;
76
77 ASSERT_RTNL();
78
79 spin_lock_bh(&pndevs->lock);
80 pnd = __phonet_get(dev);
81 if (pnd)
82 list_del(&pnd->list);
83 spin_unlock_bh(&pndevs->lock);
84
85 if (pnd) {
86 u8 addr;
87
88 for (addr = find_first_bit(pnd->addrs, 64); addr < 64;
89 addr = find_next_bit(pnd->addrs, 64, 1+addr))
90 phonet_address_notify(RTM_DELADDR, dev, addr);
91 kfree(pnd);
92 }
76} 93}
77 94
78struct net_device *phonet_device_get(struct net *net) 95struct net_device *phonet_device_get(struct net *net)
@@ -126,8 +143,10 @@ int phonet_address_del(struct net_device *dev, u8 addr)
126 pnd = __phonet_get(dev); 143 pnd = __phonet_get(dev);
127 if (!pnd || !test_and_clear_bit(addr >> 2, pnd->addrs)) 144 if (!pnd || !test_and_clear_bit(addr >> 2, pnd->addrs))
128 err = -EADDRNOTAVAIL; 145 err = -EADDRNOTAVAIL;
129 else if (bitmap_empty(pnd->addrs, 64)) 146 else if (bitmap_empty(pnd->addrs, 64)) {
130 __phonet_device_free(pnd); 147 list_del(&pnd->list);
148 kfree(pnd);
149 }
131 spin_unlock_bh(&pndevs->lock); 150 spin_unlock_bh(&pndevs->lock);
132 return err; 151 return err;
133} 152}
@@ -181,18 +200,8 @@ static int phonet_device_notify(struct notifier_block *me, unsigned long what,
181{ 200{
182 struct net_device *dev = arg; 201 struct net_device *dev = arg;
183 202
184 if (what == NETDEV_UNREGISTER) { 203 if (what == NETDEV_UNREGISTER)
185 struct phonet_device_list *pndevs; 204 phonet_device_destroy(dev);
186 struct phonet_device *pnd;
187
188 /* Destroy phonet-specific device data */
189 pndevs = phonet_device_list(dev_net(dev));
190 spin_lock_bh(&pndevs->lock);
191 pnd = __phonet_get(dev);
192 if (pnd)
193 __phonet_device_free(pnd);
194 spin_unlock_bh(&pndevs->lock);
195 }
196 return 0; 205 return 0;
197 206
198} 207}
@@ -218,11 +227,12 @@ static int phonet_init_net(struct net *net)
218static void phonet_exit_net(struct net *net) 227static void phonet_exit_net(struct net *net)
219{ 228{
220 struct phonet_net *pnn = net_generic(net, phonet_net_id); 229 struct phonet_net *pnn = net_generic(net, phonet_net_id);
221 struct phonet_device *pnd, *n; 230 struct net_device *dev;
222
223 list_for_each_entry_safe(pnd, n, &pnn->pndevs.list, list)
224 __phonet_device_free(pnd);
225 231
232 rtnl_lock();
233 for_each_netdev(net, dev)
234 phonet_device_destroy(dev);
235 rtnl_unlock();
226 kfree(pnn); 236 kfree(pnn);
227} 237}
228 238
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c
index cec4e5951681..f8b4cee434c2 100644
--- a/net/phonet/pn_netlink.c
+++ b/net/phonet/pn_netlink.c
@@ -32,7 +32,7 @@
32static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr, 32static int fill_addr(struct sk_buff *skb, struct net_device *dev, u8 addr,
33 u32 pid, u32 seq, int event); 33 u32 pid, u32 seq, int event);
34 34
35static void rtmsg_notify(int event, struct net_device *dev, u8 addr) 35void phonet_address_notify(int event, struct net_device *dev, u8 addr)
36{ 36{
37 struct sk_buff *skb; 37 struct sk_buff *skb;
38 int err = -ENOBUFS; 38 int err = -ENOBUFS;
@@ -94,7 +94,7 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *attr)
94 else 94 else
95 err = phonet_address_del(dev, pnaddr); 95 err = phonet_address_del(dev, pnaddr);
96 if (!err) 96 if (!err)
97 rtmsg_notify(nlh->nlmsg_type, dev, pnaddr); 97 phonet_address_notify(nlh->nlmsg_type, dev, pnaddr);
98 return err; 98 return err;
99} 99}
100 100
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index eac5e7bb7365..bfe493ebf27c 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -63,7 +63,7 @@ static void rxrpc_write_space(struct sock *sk)
63 _enter("%p", sk); 63 _enter("%p", sk);
64 read_lock(&sk->sk_callback_lock); 64 read_lock(&sk->sk_callback_lock);
65 if (rxrpc_writable(sk)) { 65 if (rxrpc_writable(sk)) {
66 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 66 if (sk_has_sleeper(sk))
67 wake_up_interruptible(sk->sk_sleep); 67 wake_up_interruptible(sk->sk_sleep);
68 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); 68 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
69 } 69 }
@@ -588,7 +588,7 @@ static unsigned int rxrpc_poll(struct file *file, struct socket *sock,
588 unsigned int mask; 588 unsigned int mask;
589 struct sock *sk = sock->sk; 589 struct sock *sk = sock->sk;
590 590
591 poll_wait(file, sk->sk_sleep, wait); 591 sock_poll_wait(file, sk->sk_sleep, wait);
592 mask = 0; 592 mask = 0;
593 593
594 /* the socket is readable if there are any messages waiting on the Rx 594 /* the socket is readable if there are any messages waiting on the Rx
diff --git a/net/sctp/output.c b/net/sctp/output.c
index b76411444515..b94c21190566 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -407,7 +407,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
407 } 407 }
408 dst = dst_clone(tp->dst); 408 dst = dst_clone(tp->dst);
409 skb_dst_set(nskb, dst); 409 skb_dst_set(nskb, dst);
410 if (dst) 410 if (!dst)
411 goto no_route; 411 goto no_route;
412 412
413 /* Build the SCTP header. */ 413 /* Build the SCTP header. */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 35ba035970a2..971890dbfea0 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -6652,21 +6652,6 @@ static void sctp_wait_for_close(struct sock *sk, long timeout)
6652 finish_wait(sk->sk_sleep, &wait); 6652 finish_wait(sk->sk_sleep, &wait);
6653} 6653}
6654 6654
6655static void sctp_sock_rfree_frag(struct sk_buff *skb)
6656{
6657 struct sk_buff *frag;
6658
6659 if (!skb->data_len)
6660 goto done;
6661
6662 /* Don't forget the fragments. */
6663 skb_walk_frags(skb, frag)
6664 sctp_sock_rfree_frag(frag);
6665
6666done:
6667 sctp_sock_rfree(skb);
6668}
6669
6670static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk) 6655static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk)
6671{ 6656{
6672 struct sk_buff *frag; 6657 struct sk_buff *frag;
@@ -6776,7 +6761,6 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
6776 sctp_skb_for_each(skb, &oldsk->sk_receive_queue, tmp) { 6761 sctp_skb_for_each(skb, &oldsk->sk_receive_queue, tmp) {
6777 event = sctp_skb2event(skb); 6762 event = sctp_skb2event(skb);
6778 if (event->asoc == assoc) { 6763 if (event->asoc == assoc) {
6779 sctp_sock_rfree_frag(skb);
6780 __skb_unlink(skb, &oldsk->sk_receive_queue); 6764 __skb_unlink(skb, &oldsk->sk_receive_queue);
6781 __skb_queue_tail(&newsk->sk_receive_queue, skb); 6765 __skb_queue_tail(&newsk->sk_receive_queue, skb);
6782 sctp_skb_set_owner_r_frag(skb, newsk); 6766 sctp_skb_set_owner_r_frag(skb, newsk);
@@ -6807,7 +6791,6 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
6807 sctp_skb_for_each(skb, &oldsp->pd_lobby, tmp) { 6791 sctp_skb_for_each(skb, &oldsp->pd_lobby, tmp) {
6808 event = sctp_skb2event(skb); 6792 event = sctp_skb2event(skb);
6809 if (event->asoc == assoc) { 6793 if (event->asoc == assoc) {
6810 sctp_sock_rfree_frag(skb);
6811 __skb_unlink(skb, &oldsp->pd_lobby); 6794 __skb_unlink(skb, &oldsp->pd_lobby);
6812 __skb_queue_tail(queue, skb); 6795 __skb_queue_tail(queue, skb);
6813 sctp_skb_set_owner_r_frag(skb, newsk); 6796 sctp_skb_set_owner_r_frag(skb, newsk);
@@ -6822,15 +6805,11 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
6822 6805
6823 } 6806 }
6824 6807
6825 sctp_skb_for_each(skb, &assoc->ulpq.reasm, tmp) { 6808 sctp_skb_for_each(skb, &assoc->ulpq.reasm, tmp)
6826 sctp_sock_rfree_frag(skb);
6827 sctp_skb_set_owner_r_frag(skb, newsk); 6809 sctp_skb_set_owner_r_frag(skb, newsk);
6828 }
6829 6810
6830 sctp_skb_for_each(skb, &assoc->ulpq.lobby, tmp) { 6811 sctp_skb_for_each(skb, &assoc->ulpq.lobby, tmp)
6831 sctp_sock_rfree_frag(skb);
6832 sctp_skb_set_owner_r_frag(skb, newsk); 6812 sctp_skb_set_owner_r_frag(skb, newsk);
6833 }
6834 6813
6835 /* Set the type of socket to indicate that it is peeled off from the 6814 /* Set the type of socket to indicate that it is peeled off from the
6836 * original UDP-style socket or created with the accept() call on a 6815 * original UDP-style socket or created with the accept() call on a
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 5bc2f45bddf0..ebfcf9b89909 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -28,7 +28,6 @@
28#include <linux/kallsyms.h> 28#include <linux/kallsyms.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/smp_lock.h>
32#include <linux/utsname.h> 31#include <linux/utsname.h>
33#include <linux/workqueue.h> 32#include <linux/workqueue.h>
34#include <linux/in6.h> 33#include <linux/in6.h>
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 1102ce1251f7..8f459abe97cf 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -16,7 +16,6 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/mempool.h> 17#include <linux/mempool.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/smp_lock.h>
20#include <linux/spinlock.h> 19#include <linux/spinlock.h>
21#include <linux/mutex.h> 20#include <linux/mutex.h>
22 21
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index 843629f55763..adaa81982f74 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -66,6 +66,7 @@ cleanup_sunrpc(void)
66#ifdef CONFIG_PROC_FS 66#ifdef CONFIG_PROC_FS
67 rpc_proc_exit(); 67 rpc_proc_exit();
68#endif 68#endif
69 rcu_barrier(); /* Wait for completion of call_rcu()'s */
69} 70}
70MODULE_LICENSE("GPL"); 71MODULE_LICENSE("GPL");
71module_init(init_sunrpc); 72module_init(init_sunrpc);
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 6f33d33cc064..27d44332f017 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/smp_lock.h>
8#include <linux/errno.h> 9#include <linux/errno.h>
9#include <linux/freezer.h> 10#include <linux/freezer.h>
10#include <linux/kthread.h> 11#include <linux/kthread.h>
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 36d4e44d6233..fc3ebb906911 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -315,7 +315,7 @@ static void unix_write_space(struct sock *sk)
315{ 315{
316 read_lock(&sk->sk_callback_lock); 316 read_lock(&sk->sk_callback_lock);
317 if (unix_writable(sk)) { 317 if (unix_writable(sk)) {
318 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 318 if (sk_has_sleeper(sk))
319 wake_up_interruptible_sync(sk->sk_sleep); 319 wake_up_interruptible_sync(sk->sk_sleep);
320 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); 320 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT);
321 } 321 }
@@ -1985,7 +1985,7 @@ static unsigned int unix_poll(struct file *file, struct socket *sock, poll_table
1985 struct sock *sk = sock->sk; 1985 struct sock *sk = sock->sk;
1986 unsigned int mask; 1986 unsigned int mask;
1987 1987
1988 poll_wait(file, sk->sk_sleep, wait); 1988 sock_poll_wait(file, sk->sk_sleep, wait);
1989 mask = 0; 1989 mask = 0;
1990 1990
1991 /* exceptional events? */ 1991 /* exceptional events? */
@@ -2022,7 +2022,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
2022 struct sock *sk = sock->sk, *other; 2022 struct sock *sk = sock->sk, *other;
2023 unsigned int mask, writable; 2023 unsigned int mask, writable;
2024 2024
2025 poll_wait(file, sk->sk_sleep, wait); 2025 sock_poll_wait(file, sk->sk_sleep, wait);
2026 mask = 0; 2026 mask = 0;
2027 2027
2028 /* exceptional events? */ 2028 /* exceptional events? */
@@ -2053,7 +2053,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
2053 other = unix_peer_get(sk); 2053 other = unix_peer_get(sk);
2054 if (other) { 2054 if (other) {
2055 if (unix_peer(other) != sk) { 2055 if (unix_peer(other) != sk) {
2056 poll_wait(file, &unix_sk(other)->peer_wait, 2056 sock_poll_wait(file, &unix_sk(other)->peer_wait,
2057 wait); 2057 wait);
2058 if (unix_recvq_full(other)) 2058 if (unix_recvq_full(other))
2059 writable = 0; 2059 writable = 0;
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index 466e2d22d256..258daa80ad92 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -48,6 +48,7 @@
48#include <linux/kernel.h> 48#include <linux/kernel.h>
49#include <linux/module.h> /* support for loadable modules */ 49#include <linux/module.h> /* support for loadable modules */
50#include <linux/slab.h> /* kmalloc(), kfree() */ 50#include <linux/slab.h> /* kmalloc(), kfree() */
51#include <linux/smp_lock.h>
51#include <linux/mm.h> 52#include <linux/mm.h>
52#include <linux/string.h> /* inline mem*, str* functions */ 53#include <linux/string.h> /* inline mem*, str* functions */
53 54
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 241bddd0b4f1..43bdb1372cae 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -447,6 +447,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
447 447
448 rdev = __cfg80211_drv_from_info(info); 448 rdev = __cfg80211_drv_from_info(info);
449 if (IS_ERR(rdev)) { 449 if (IS_ERR(rdev)) {
450 mutex_unlock(&cfg80211_mutex);
450 result = PTR_ERR(rdev); 451 result = PTR_ERR(rdev);
451 goto unlock; 452 goto unlock;
452 } 453 }
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index e95b638b919f..f8e71b300001 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -366,7 +366,6 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev,
366 found = rb_find_bss(dev, res); 366 found = rb_find_bss(dev, res);
367 367
368 if (found) { 368 if (found) {
369 kref_get(&found->ref);
370 found->pub.beacon_interval = res->pub.beacon_interval; 369 found->pub.beacon_interval = res->pub.beacon_interval;
371 found->pub.tsf = res->pub.tsf; 370 found->pub.tsf = res->pub.tsf;
372 found->pub.signal = res->pub.signal; 371 found->pub.signal = res->pub.signal;
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 21cdc872004e..5e6c072c64d3 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -40,6 +40,7 @@
40#include <linux/errno.h> 40#include <linux/errno.h>
41#include <linux/kernel.h> 41#include <linux/kernel.h>
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/smp_lock.h>
43#include <linux/timer.h> 44#include <linux/timer.h>
44#include <linux/string.h> 45#include <linux/string.h>
45#include <linux/net.h> 46#include <linux/net.h>
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index d31ccb487730..faf54c6bf96b 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -292,8 +292,8 @@ static struct xfrm_algo_desc ealg_list[] = {
292 } 292 }
293}, 293},
294{ 294{
295 .name = "cbc(cast128)", 295 .name = "cbc(cast5)",
296 .compat = "cast128", 296 .compat = "cast5",
297 297
298 .uinfo = { 298 .uinfo = {
299 .encr = { 299 .encr = {
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 5f1f86565f16..f2f7c638083e 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -668,22 +668,10 @@ static struct xfrm_state *__xfrm_state_lookup(struct net *net, xfrm_address_t *d
668 hlist_for_each_entry(x, entry, net->xfrm.state_byspi+h, byspi) { 668 hlist_for_each_entry(x, entry, net->xfrm.state_byspi+h, byspi) {
669 if (x->props.family != family || 669 if (x->props.family != family ||
670 x->id.spi != spi || 670 x->id.spi != spi ||
671 x->id.proto != proto) 671 x->id.proto != proto ||
672 xfrm_addr_cmp(&x->id.daddr, daddr, family))
672 continue; 673 continue;
673 674
674 switch (family) {
675 case AF_INET:
676 if (x->id.daddr.a4 != daddr->a4)
677 continue;
678 break;
679 case AF_INET6:
680 if (!ipv6_addr_equal((struct in6_addr *)daddr,
681 (struct in6_addr *)
682 x->id.daddr.a6))
683 continue;
684 break;
685 }
686
687 xfrm_state_hold(x); 675 xfrm_state_hold(x);
688 return x; 676 return x;
689 } 677 }
@@ -699,26 +687,11 @@ static struct xfrm_state *__xfrm_state_lookup_byaddr(struct net *net, xfrm_addre
699 687
700 hlist_for_each_entry(x, entry, net->xfrm.state_bysrc+h, bysrc) { 688 hlist_for_each_entry(x, entry, net->xfrm.state_bysrc+h, bysrc) {
701 if (x->props.family != family || 689 if (x->props.family != family ||
702 x->id.proto != proto) 690 x->id.proto != proto ||
691 xfrm_addr_cmp(&x->id.daddr, daddr, family) ||
692 xfrm_addr_cmp(&x->props.saddr, saddr, family))
703 continue; 693 continue;
704 694
705 switch (family) {
706 case AF_INET:
707 if (x->id.daddr.a4 != daddr->a4 ||
708 x->props.saddr.a4 != saddr->a4)
709 continue;
710 break;
711 case AF_INET6:
712 if (!ipv6_addr_equal((struct in6_addr *)daddr,
713 (struct in6_addr *)
714 x->id.daddr.a6) ||
715 !ipv6_addr_equal((struct in6_addr *)saddr,
716 (struct in6_addr *)
717 x->props.saddr.a6))
718 continue;
719 break;
720 }
721
722 xfrm_state_hold(x); 695 xfrm_state_hold(x);
723 return x; 696 return x;
724 } 697 }
@@ -1001,25 +974,11 @@ static struct xfrm_state *__find_acq_core(struct net *net, unsigned short family
1001 x->props.family != family || 974 x->props.family != family ||
1002 x->km.state != XFRM_STATE_ACQ || 975 x->km.state != XFRM_STATE_ACQ ||
1003 x->id.spi != 0 || 976 x->id.spi != 0 ||
1004 x->id.proto != proto) 977 x->id.proto != proto ||
978 xfrm_addr_cmp(&x->id.daddr, daddr, family) ||
979 xfrm_addr_cmp(&x->props.saddr, saddr, family))
1005 continue; 980 continue;
1006 981
1007 switch (family) {
1008 case AF_INET:
1009 if (x->id.daddr.a4 != daddr->a4 ||
1010 x->props.saddr.a4 != saddr->a4)
1011 continue;
1012 break;
1013 case AF_INET6:
1014 if (!ipv6_addr_equal((struct in6_addr *)x->id.daddr.a6,
1015 (struct in6_addr *)daddr) ||
1016 !ipv6_addr_equal((struct in6_addr *)
1017 x->props.saddr.a6,
1018 (struct in6_addr *)saddr))
1019 continue;
1020 break;
1021 }
1022
1023 xfrm_state_hold(x); 982 xfrm_state_hold(x);
1024 return x; 983 return x;
1025 } 984 }
diff --git a/scripts/.gitignore b/scripts/.gitignore
index b939fbd01195..52cab46ae35a 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -7,3 +7,4 @@ pnmtologo
7bin2c 7bin2c
8unifdef 8unifdef
9binoffset 9binoffset
10ihex2fw
diff --git a/scripts/dtc/.gitignore b/scripts/dtc/.gitignore
new file mode 100644
index 000000000000..095acb49a374
--- /dev/null
+++ b/scripts/dtc/.gitignore
@@ -0,0 +1,5 @@
1dtc
2dtc-lexer.lex.c
3dtc-parser.tab.c
4dtc-parser.tab.h
5
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index ed591e9b7d1d..b52d340d759d 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1426,6 +1426,8 @@ sub dump_struct($$) {
1426 # strip comments: 1426 # strip comments:
1427 $members =~ s/\/\*.*?\*\///gos; 1427 $members =~ s/\/\*.*?\*\///gos;
1428 $nested =~ s/\/\*.*?\*\///gos; 1428 $nested =~ s/\/\*.*?\*\///gos;
1429 # strip kmemcheck_bitfield_{begin,end}.*;
1430 $members =~ s/kmemcheck_bitfield_.*?;//gos;
1429 1431
1430 create_parameterlist($members, ';', $file); 1432 create_parameterlist($members, ';', $file);
1431 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); 1433 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
@@ -1468,8 +1470,6 @@ sub dump_enum($$) {
1468 } 1470 }
1469 1471
1470 } 1472 }
1471 # strip kmemcheck_bitfield_{begin,end}.*;
1472 $members =~ s/kmemcheck_bitfield_.*?;//gos;
1473 1473
1474 output_declaration($declaration_name, 1474 output_declaration($declaration_name,
1475 'enum', 1475 'enum',
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 01c2d13dd020..b19f1f4962e3 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -16,6 +16,8 @@ create_package() {
16 local pname="$1" pdir="$2" 16 local pname="$1" pdir="$2"
17 17
18 cp debian/copyright "$pdir/usr/share/doc/$pname/" 18 cp debian/copyright "$pdir/usr/share/doc/$pname/"
19 cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian"
20 gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
19 21
20 # Fix ownership and permissions 22 # Fix ownership and permissions
21 chown -R root:root "$pdir" 23 chown -R root:root "$pdir"
diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
index 64f5ddb09ea6..5c113123ed9f 100644
--- a/scripts/pnmtologo.c
+++ b/scripts/pnmtologo.c
@@ -237,7 +237,7 @@ static void write_header(void)
237 fprintf(out, " * Linux logo %s\n", logoname); 237 fprintf(out, " * Linux logo %s\n", logoname);
238 fputs(" */\n\n", out); 238 fputs(" */\n\n", out);
239 fputs("#include <linux/linux_logo.h>\n\n", out); 239 fputs("#include <linux/linux_logo.h>\n\n", out);
240 fprintf(out, "static const unsigned char %s_data[] __initconst = {\n", 240 fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
241 logoname); 241 logoname);
242} 242}
243 243
@@ -374,7 +374,7 @@ static void write_logo_clut224(void)
374 fputs("\n};\n\n", out); 374 fputs("\n};\n\n", out);
375 375
376 /* write logo clut */ 376 /* write logo clut */
377 fprintf(out, "static const unsigned char %s_clut[] __initconst = {\n", 377 fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
378 logoname); 378 logoname);
379 write_hex_cnt = 0; 379 write_hex_cnt = 0;
380 for (i = 0; i < logo_clutsize; i++) { 380 for (i = 0; i < logo_clutsize; i++) {
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 6f611874d10e..101c512564ec 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -238,7 +238,34 @@ out:
238} 238}
239 239
240/* 240/*
241 * ima_opens_get - increment file counts 241 * ima_counts_put - decrement file counts
242 *
243 * File counts are incremented in ima_path_check. On file open
244 * error, such as ETXTBSY, decrement the counts to prevent
245 * unnecessary imbalance messages.
246 */
247void ima_counts_put(struct path *path, int mask)
248{
249 struct inode *inode = path->dentry->d_inode;
250 struct ima_iint_cache *iint;
251
252 if (!ima_initialized || !S_ISREG(inode->i_mode))
253 return;
254 iint = ima_iint_find_insert_get(inode);
255 if (!iint)
256 return;
257
258 mutex_lock(&iint->mutex);
259 iint->opencount--;
260 if ((mask & MAY_WRITE) || (mask == 0))
261 iint->writecount--;
262 else if (mask & (MAY_READ | MAY_EXEC))
263 iint->readcount--;
264 mutex_unlock(&iint->mutex);
265}
266
267/*
268 * ima_counts_get - increment file counts
242 * 269 *
243 * - for IPC shm and shmat file. 270 * - for IPC shm and shmat file.
244 * - for nfsd exported files. 271 * - for nfsd exported files.
diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
index 7ec94314ac0c..a0880e9c8e05 100644
--- a/security/integrity/ima/ima_queue.c
+++ b/security/integrity/ima/ima_queue.c
@@ -134,7 +134,8 @@ int ima_add_template_entry(struct ima_template_entry *entry, int violation,
134 } 134 }
135out: 135out:
136 mutex_unlock(&ima_extend_list_mutex); 136 mutex_unlock(&ima_extend_list_mutex);
137 integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode, entry->template_name, 137 integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode,
138 entry->template.file_name,
138 op, audit_cause, result, audit_info); 139 op, audit_cause, result, audit_info);
139 return result; 140 return result;
140} 141}
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c
index 108b643229ba..6205f37d547c 100644
--- a/sound/arm/pxa2xx-pcm-lib.c
+++ b/sound/arm/pxa2xx-pcm-lib.c
@@ -75,7 +75,7 @@ int __pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream)
75{ 75{
76 struct pxa2xx_runtime_data *rtd = substream->runtime->private_data; 76 struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;
77 77
78 if (rtd && rtd->params) 78 if (rtd && rtd->params && rtd->params->drcmr)
79 *rtd->params->drcmr = 0; 79 *rtd->params->drcmr = 0;
80 80
81 snd_pcm_set_runtime_buffer(substream, NULL); 81 snd_pcm_set_runtime_buffer(substream, NULL);
diff --git a/sound/oss/kahlua.c b/sound/oss/kahlua.c
index c180598f1710..89466b056be7 100644
--- a/sound/oss/kahlua.c
+++ b/sound/oss/kahlua.c
@@ -199,7 +199,7 @@ MODULE_LICENSE("GPL");
199 */ 199 */
200 200
201static struct pci_device_id id_tbl[] = { 201static struct pci_device_id id_tbl[] = {
202 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 202 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO), 0 },
203 { } 203 { }
204}; 204};
205 205
diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c
index 6c0a770ed054..1b2316f35b1f 100644
--- a/sound/oss/mpu401.c
+++ b/sound/oss/mpu401.c
@@ -926,31 +926,21 @@ static struct midi_operations mpu401_midi_operations[MAX_MIDI_DEV];
926static void mpu401_chk_version(int n, struct mpu_config *devc) 926static void mpu401_chk_version(int n, struct mpu_config *devc)
927{ 927{
928 int tmp; 928 int tmp;
929 unsigned long flags;
930 929
931 devc->version = devc->revision = 0; 930 devc->version = devc->revision = 0;
932 931
933 spin_lock_irqsave(&devc->lock,flags); 932 tmp = mpu_cmd(n, 0xAC, 0);
934 if ((tmp = mpu_cmd(n, 0xAC, 0)) < 0) 933 if (tmp < 0)
935 {
936 spin_unlock_irqrestore(&devc->lock,flags);
937 return; 934 return;
938 }
939 if ((tmp & 0xf0) > 0x20) /* Why it's larger than 2.x ??? */ 935 if ((tmp & 0xf0) > 0x20) /* Why it's larger than 2.x ??? */
940 {
941 spin_unlock_irqrestore(&devc->lock,flags);
942 return; 936 return;
943 }
944 devc->version = tmp; 937 devc->version = tmp;
945 938
946 if ((tmp = mpu_cmd(n, 0xAD, 0)) < 0) 939 if ((tmp = mpu_cmd(n, 0xAD, 0)) < 0) {
947 {
948 devc->version = 0; 940 devc->version = 0;
949 spin_unlock_irqrestore(&devc->lock,flags);
950 return; 941 return;
951 } 942 }
952 devc->revision = tmp; 943 devc->revision = tmp;
953 spin_unlock_irqrestore(&devc->lock,flags);
954} 944}
955 945
956int attach_mpu401(struct address_info *hw_config, struct module *owner) 946int attach_mpu401(struct address_info *hw_config, struct module *owner)
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 71515ddb4593..d6752dff2a44 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -287,10 +287,10 @@ struct atiixp {
287/* 287/*
288 */ 288 */
289static struct pci_device_id snd_atiixp_ids[] = { 289static struct pci_device_id snd_atiixp_ids[] = {
290 { 0x1002, 0x4341, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB200 */ 290 { PCI_VDEVICE(ATI, 0x4341), 0 }, /* SB200 */
291 { 0x1002, 0x4361, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB300 */ 291 { PCI_VDEVICE(ATI, 0x4361), 0 }, /* SB300 */
292 { 0x1002, 0x4370, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB400 */ 292 { PCI_VDEVICE(ATI, 0x4370), 0 }, /* SB400 */
293 { 0x1002, 0x4382, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB600 */ 293 { PCI_VDEVICE(ATI, 0x4382), 0 }, /* SB600 */
294 { 0, } 294 { 0, }
295}; 295};
296 296
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index c3136cccc559..e7e147bf8eb2 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -262,8 +262,8 @@ struct atiixp_modem {
262/* 262/*
263 */ 263 */
264static struct pci_device_id snd_atiixp_ids[] = { 264static struct pci_device_id snd_atiixp_ids[] = {
265 { 0x1002, 0x434d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB200 */ 265 { PCI_VDEVICE(ATI, 0x434d), 0 }, /* SB200 */
266 { 0x1002, 0x4378, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB400 */ 266 { PCI_VDEVICE(ATI, 0x4378), 0 }, /* SB400 */
267 { 0, } 267 { 0, }
268}; 268};
269 269
diff --git a/sound/pci/au88x0/au8810.c b/sound/pci/au88x0/au8810.c
index fce22c7af0ea..c0e8c6b295cb 100644
--- a/sound/pci/au88x0/au8810.c
+++ b/sound/pci/au88x0/au8810.c
@@ -1,8 +1,7 @@
1#include "au8810.h" 1#include "au8810.h"
2#include "au88x0.h" 2#include "au88x0.h"
3static struct pci_device_id snd_vortex_ids[] = { 3static struct pci_device_id snd_vortex_ids[] = {
4 {PCI_VENDOR_ID_AUREAL, PCI_DEVICE_ID_AUREAL_ADVANTAGE, 4 {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_ADVANTAGE), 1,},
5 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1,},
6 {0,} 5 {0,}
7}; 6};
8 7
diff --git a/sound/pci/au88x0/au8820.c b/sound/pci/au88x0/au8820.c
index d1fbcce07257..a6527330df58 100644
--- a/sound/pci/au88x0/au8820.c
+++ b/sound/pci/au88x0/au8820.c
@@ -1,8 +1,7 @@
1#include "au8820.h" 1#include "au8820.h"
2#include "au88x0.h" 2#include "au88x0.h"
3static struct pci_device_id snd_vortex_ids[] = { 3static struct pci_device_id snd_vortex_ids[] = {
4 {PCI_VENDOR_ID_AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_1, 4 {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_1), 0,},
5 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,},
6 {0,} 5 {0,}
7}; 6};
8 7
diff --git a/sound/pci/au88x0/au8830.c b/sound/pci/au88x0/au8830.c
index d4f2717c14fb..6c702ad4352a 100644
--- a/sound/pci/au88x0/au8830.c
+++ b/sound/pci/au88x0/au8830.c
@@ -1,8 +1,7 @@
1#include "au8830.h" 1#include "au8830.h"
2#include "au88x0.h" 2#include "au88x0.h"
3static struct pci_device_id snd_vortex_ids[] = { 3static struct pci_device_id snd_vortex_ids[] = {
4 {PCI_VENDOR_ID_AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_2, 4 {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_2), 0,},
5 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,},
6 {0,} 5 {0,}
7}; 6};
8 7
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 700f15ea16d4..15e4138bce17 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -1876,7 +1876,7 @@ static int snd_ca0106_resume(struct pci_dev *pci)
1876 1876
1877// PCI IDs 1877// PCI IDs
1878static struct pci_device_id snd_ca0106_ids[] = { 1878static struct pci_device_id snd_ca0106_ids[] = {
1879 { 0x1102, 0x0007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Audigy LS or Live 24bit */ 1879 { PCI_VDEVICE(CREATIVE, 0x0007), 0 }, /* Audigy LS or Live 24bit */
1880 { 0, } 1880 { 0, }
1881}; 1881};
1882MODULE_DEVICE_TABLE(pci, snd_ca0106_ids); 1882MODULE_DEVICE_TABLE(pci, snd_ca0106_ids);
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 449fe02f666e..ddcd4a9fd7e6 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -2797,11 +2797,11 @@ static inline void snd_cmipci_proc_init(struct cmipci *cm) {}
2797 2797
2798 2798
2799static struct pci_device_id snd_cmipci_ids[] = { 2799static struct pci_device_id snd_cmipci_ids[] = {
2800 {PCI_VENDOR_ID_CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2800 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A), 0},
2801 {PCI_VENDOR_ID_CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2801 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B), 0},
2802 {PCI_VENDOR_ID_CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2802 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738), 0},
2803 {PCI_VENDOR_ID_CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2803 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738B), 0},
2804 {PCI_VENDOR_ID_AL, PCI_DEVICE_ID_CMEDIA_CM8738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2804 {PCI_VDEVICE(AL, PCI_DEVICE_ID_CMEDIA_CM8738), 0},
2805 {0,}, 2805 {0,},
2806}; 2806};
2807 2807
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index f6286f84a221..e2e0359bb056 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -495,7 +495,7 @@ struct cs4281 {
495static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id); 495static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id);
496 496
497static struct pci_device_id snd_cs4281_ids[] = { 497static struct pci_device_id snd_cs4281_ids[] = {
498 { 0x1013, 0x6005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4281 */ 498 { PCI_VDEVICE(CIRRUS, 0x6005), 0, }, /* CS4281 */
499 { 0, } 499 { 0, }
500}; 500};
501 501
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
index c9b3e3d48cbc..033aec430117 100644
--- a/sound/pci/cs46xx/cs46xx.c
+++ b/sound/pci/cs46xx/cs46xx.c
@@ -65,9 +65,9 @@ module_param_array(mmap_valid, bool, NULL, 0444);
65MODULE_PARM_DESC(mmap_valid, "Support OSS mmap."); 65MODULE_PARM_DESC(mmap_valid, "Support OSS mmap.");
66 66
67static struct pci_device_id snd_cs46xx_ids[] = { 67static struct pci_device_id snd_cs46xx_ids[] = {
68 { 0x1013, 0x6001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4280 */ 68 { PCI_VDEVICE(CIRRUS, 0x6001), 0, }, /* CS4280 */
69 { 0x1013, 0x6003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4612 */ 69 { PCI_VDEVICE(CIRRUS, 0x6003), 0, }, /* CS4612 */
70 { 0x1013, 0x6004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4615 */ 70 { PCI_VDEVICE(CIRRUS, 0x6004), 0, }, /* CS4615 */
71 { 0, } 71 { 0, }
72}; 72};
73 73
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index 082e35c08c02..deb6cfa73600 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -57,9 +57,9 @@ struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = {
57 57
58struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { 58struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = {
59 [LINEO1] = {.left = 0x40, .right = 0x41}, 59 [LINEO1] = {.left = 0x40, .right = 0x41},
60 [LINEO2] = {.left = 0x70, .right = 0x71}, 60 [LINEO2] = {.left = 0x60, .right = 0x61},
61 [LINEO3] = {.left = 0x50, .right = 0x51}, 61 [LINEO3] = {.left = 0x50, .right = 0x51},
62 [LINEO4] = {.left = 0x60, .right = 0x61}, 62 [LINEO4] = {.left = 0x70, .right = 0x71},
63 [LINEIM] = {.left = 0x45, .right = 0xc5}, 63 [LINEIM] = {.left = 0x45, .right = 0xc5},
64 [SPDIFOO] = {.left = 0x00, .right = 0x01}, 64 [SPDIFOO] = {.left = 0x00, .right = 0x01},
65 [SPDIFIO] = {.left = 0x05, .right = 0x85}, 65 [SPDIFIO] = {.left = 0x05, .right = 0x85},
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index c7f3b994101c..168af67d938e 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -77,9 +77,9 @@ MODULE_PARM_DESC(subsystem, "Force card subsystem model.");
77 * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400 77 * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400
78 */ 78 */
79static struct pci_device_id snd_emu10k1_ids[] = { 79static struct pci_device_id snd_emu10k1_ids[] = {
80 { 0x1102, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* EMU10K1 */ 80 { PCI_VDEVICE(CREATIVE, 0x0002), 0 }, /* EMU10K1 */
81 { 0x1102, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, /* Audigy */ 81 { PCI_VDEVICE(CREATIVE, 0x0004), 1 }, /* Audigy */
82 { 0x1102, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, /* Audigy 2 Value SB0400 */ 82 { PCI_VDEVICE(CREATIVE, 0x0008), 1 }, /* Audigy 2 Value SB0400 */
83 { 0, } 83 { 0, }
84}; 84};
85 85
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 4d3ad793e98f..36e08bd2b3cc 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -1607,7 +1607,7 @@ static void __devexit snd_emu10k1x_remove(struct pci_dev *pci)
1607 1607
1608// PCI IDs 1608// PCI IDs
1609static struct pci_device_id snd_emu10k1x_ids[] = { 1609static struct pci_device_id snd_emu10k1x_ids[] = {
1610 { 0x1102, 0x0006, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Dell OEM version (EMU10K1) */ 1610 { PCI_VDEVICE(CREATIVE, 0x0006), 0 }, /* Dell OEM version (EMU10K1) */
1611 { 0, } 1611 { 0, }
1612}; 1612};
1613MODULE_DEVICE_TABLE(pci, snd_emu10k1x_ids); 1613MODULE_DEVICE_TABLE(pci, snd_emu10k1x_ids);
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index e617acaf10e3..61b8ab39800f 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -644,7 +644,7 @@ int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm *
644 int err; 644 int err;
645 int capture=1; 645 int capture=1;
646 646
647 /* snd_printk("KERN_DEBUG snd_p16v_pcm called. device=%d\n", device); */ 647 /* snd_printk(KERN_DEBUG "snd_p16v_pcm called. device=%d\n", device); */
648 emu->p16v_device_offset = device; 648 emu->p16v_device_offset = device;
649 if (rpcm) 649 if (rpcm)
650 *rpcm = NULL; 650 *rpcm = NULL;
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 18f4d1e98c46..2b82c5c723e1 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -445,12 +445,12 @@ static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id);
445 445
446static struct pci_device_id snd_audiopci_ids[] = { 446static struct pci_device_id snd_audiopci_ids[] = {
447#ifdef CHIP1370 447#ifdef CHIP1370
448 { 0x1274, 0x5000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ES1370 */ 448 { PCI_VDEVICE(ENSONIQ, 0x5000), 0, }, /* ES1370 */
449#endif 449#endif
450#ifdef CHIP1371 450#ifdef CHIP1371
451 { 0x1274, 0x1371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ES1371 */ 451 { PCI_VDEVICE(ENSONIQ, 0x1371), 0, }, /* ES1371 */
452 { 0x1274, 0x5880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ES1373 - CT5880 */ 452 { PCI_VDEVICE(ENSONIQ, 0x5880), 0, }, /* ES1373 - CT5880 */
453 { 0x1102, 0x8938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Ectiva EV1938 */ 453 { PCI_VDEVICE(ECTIVA, 0x8938), 0, }, /* Ectiva EV1938 */
454#endif 454#endif
455 { 0, } 455 { 0, }
456}; 456};
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index fbd2ac09aa34..820318ee62c1 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -244,7 +244,7 @@ struct es1938 {
244static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id); 244static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id);
245 245
246static struct pci_device_id snd_es1938_ids[] = { 246static struct pci_device_id snd_es1938_ids[] = {
247 { 0x125d, 0x1969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Solo-1 */ 247 { PCI_VDEVICE(ESS, 0x1969), 0, }, /* Solo-1 */
248 { 0, } 248 { 0, }
249}; 249};
250 250
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 29272f2e95a0..b0275a050870 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -50,19 +50,22 @@ static void snd_hda_generate_beep(struct work_struct *work)
50 * The tone frequency of beep generator on IDT/STAC codecs is 50 * The tone frequency of beep generator on IDT/STAC codecs is
51 * defined from the 8bit tone parameter, in Hz, 51 * defined from the 8bit tone parameter, in Hz,
52 * freq = 48000 * (257 - tone) / 1024 52 * freq = 48000 * (257 - tone) / 1024
53 * that is from 12kHz to 93.75kHz in step of 46.875 hz 53 * that is from 12kHz to 93.75Hz in steps of 46.875 Hz
54 */ 54 */
55static int beep_linear_tone(struct hda_beep *beep, int hz) 55static int beep_linear_tone(struct hda_beep *beep, int hz)
56{ 56{
57 if (hz <= 0)
58 return 0;
57 hz *= 1000; /* fixed point */ 59 hz *= 1000; /* fixed point */
58 hz = hz - DIGBEEP_HZ_MIN; 60 hz = hz - DIGBEEP_HZ_MIN
61 + DIGBEEP_HZ_STEP / 2; /* round to nearest step */
59 if (hz < 0) 62 if (hz < 0)
60 hz = 0; /* turn off PC beep*/ 63 hz = 0; /* turn off PC beep*/
61 else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) 64 else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN))
62 hz = 0xff; 65 hz = 1; /* max frequency */
63 else { 66 else {
64 hz /= DIGBEEP_HZ_STEP; 67 hz /= DIGBEEP_HZ_STEP;
65 hz++; 68 hz = 255 - hz;
66 } 69 }
67 return hz; 70 return hz;
68} 71}
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 462e2cedaa6a..88480c0c58a0 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -332,6 +332,12 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
332 AC_VERB_GET_CONNECT_LIST, i); 332 AC_VERB_GET_CONNECT_LIST, i);
333 range_val = !!(parm & (1 << (shift-1))); /* ranges */ 333 range_val = !!(parm & (1 << (shift-1))); /* ranges */
334 val = parm & mask; 334 val = parm & mask;
335 if (val == 0) {
336 snd_printk(KERN_WARNING "hda_codec: "
337 "invalid CONNECT_LIST verb %x[%i]:%x\n",
338 nid, i, parm);
339 return 0;
340 }
335 parm >>= shift; 341 parm >>= shift;
336 if (range_val) { 342 if (range_val) {
337 /* ranges between the previous and this one */ 343 /* ranges between the previous and this one */
@@ -3470,10 +3476,16 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec,
3470 } 3476 }
3471 mutex_lock(&codec->spdif_mutex); 3477 mutex_lock(&codec->spdif_mutex);
3472 if (mout->share_spdif) { 3478 if (mout->share_spdif) {
3473 runtime->hw.rates &= mout->spdif_rates; 3479 if ((runtime->hw.rates & mout->spdif_rates) &&
3474 runtime->hw.formats &= mout->spdif_formats; 3480 (runtime->hw.formats & mout->spdif_formats)) {
3475 if (mout->spdif_maxbps < hinfo->maxbps) 3481 runtime->hw.rates &= mout->spdif_rates;
3476 hinfo->maxbps = mout->spdif_maxbps; 3482 runtime->hw.formats &= mout->spdif_formats;
3483 if (mout->spdif_maxbps < hinfo->maxbps)
3484 hinfo->maxbps = mout->spdif_maxbps;
3485 } else {
3486 mout->share_spdif = 0;
3487 /* FIXME: need notify? */
3488 }
3477 } 3489 }
3478 mutex_unlock(&codec->spdif_mutex); 3490 mutex_unlock(&codec->spdif_mutex);
3479 } 3491 }
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 4e9ea7080270..77c1b840ca8b 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1454,6 +1454,18 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1454 mutex_unlock(&chip->open_mutex); 1454 mutex_unlock(&chip->open_mutex);
1455 return err; 1455 return err;
1456 } 1456 }
1457 snd_pcm_limit_hw_rates(runtime);
1458 /* sanity check */
1459 if (snd_BUG_ON(!runtime->hw.channels_min) ||
1460 snd_BUG_ON(!runtime->hw.channels_max) ||
1461 snd_BUG_ON(!runtime->hw.formats) ||
1462 snd_BUG_ON(!runtime->hw.rates)) {
1463 azx_release_device(azx_dev);
1464 hinfo->ops.close(hinfo, apcm->codec, substream);
1465 snd_hda_power_down(apcm->codec);
1466 mutex_unlock(&chip->open_mutex);
1467 return -EINVAL;
1468 }
1457 spin_lock_irqsave(&chip->reg_lock, flags); 1469 spin_lock_irqsave(&chip->reg_lock, flags);
1458 azx_dev->substream = substream; 1470 azx_dev->substream = substream;
1459 azx_dev->running = 0; 1471 azx_dev->running = 0;
@@ -1462,7 +1474,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1462 runtime->private_data = azx_dev; 1474 runtime->private_data = azx_dev;
1463 snd_pcm_set_sync(substream); 1475 snd_pcm_set_sync(substream);
1464 mutex_unlock(&chip->open_mutex); 1476 mutex_unlock(&chip->open_mutex);
1465
1466 return 0; 1477 return 0;
1467} 1478}
1468 1479
@@ -2322,9 +2333,19 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2322 gcap = azx_readw(chip, GCAP); 2333 gcap = azx_readw(chip, GCAP);
2323 snd_printdd(SFX "chipset global capabilities = 0x%x\n", gcap); 2334 snd_printdd(SFX "chipset global capabilities = 0x%x\n", gcap);
2324 2335
2325 /* ATI chips seems buggy about 64bit DMA addresses */ 2336 /* disable SB600 64bit support for safety */
2326 if (chip->driver_type == AZX_DRIVER_ATI) 2337 if ((chip->driver_type == AZX_DRIVER_ATI) ||
2327 gcap &= ~ICH6_GCAP_64OK; 2338 (chip->driver_type == AZX_DRIVER_ATIHDMI)) {
2339 struct pci_dev *p_smbus;
2340 p_smbus = pci_get_device(PCI_VENDOR_ID_ATI,
2341 PCI_DEVICE_ID_ATI_SBX00_SMBUS,
2342 NULL);
2343 if (p_smbus) {
2344 if (p_smbus->revision < 0x30)
2345 gcap &= ~ICH6_GCAP_64OK;
2346 pci_dev_put(p_smbus);
2347 }
2348 }
2328 2349
2329 /* allow 64bit DMA address if supported by H/W */ 2350 /* allow 64bit DMA address if supported by H/W */
2330 if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) 2351 if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64)))
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 84cc49ca9148..be7d25fa7f35 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -72,6 +72,7 @@ struct ad198x_spec {
72 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 72 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
73 73
74 unsigned int jack_present :1; 74 unsigned int jack_present :1;
75 unsigned int inv_jack_detect:1;
75 76
76#ifdef CONFIG_SND_HDA_POWER_SAVE 77#ifdef CONFIG_SND_HDA_POWER_SAVE
77 struct hda_loopback_check loopback; 78 struct hda_loopback_check loopback;
@@ -669,39 +670,13 @@ static struct hda_input_mux ad1986a_automic_capture_source = {
669 }, 670 },
670}; 671};
671 672
672static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { 673static struct snd_kcontrol_new ad1986a_laptop_master_mixers[] = {
673 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), 674 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
674 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), 675 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
675 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
676 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
677 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
678 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
680 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
681 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
682 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
683 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
684 {
685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
686 .name = "Capture Source",
687 .info = ad198x_mux_enum_info,
688 .get = ad198x_mux_enum_get,
689 .put = ad198x_mux_enum_put,
690 },
691 {
692 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
693 .name = "External Amplifier",
694 .info = ad198x_eapd_info,
695 .get = ad198x_eapd_get,
696 .put = ad198x_eapd_put,
697 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
698 },
699 { } /* end */ 676 { } /* end */
700}; 677};
701 678
702static struct snd_kcontrol_new ad1986a_samsung_mixers[] = { 679static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
703 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
704 HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
705 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), 680 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
706 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), 681 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
@@ -727,6 +702,12 @@ static struct snd_kcontrol_new ad1986a_samsung_mixers[] = {
727 { } /* end */ 702 { } /* end */
728}; 703};
729 704
705static struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = {
706 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
707 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
708 { } /* end */
709};
710
730/* re-connect the mic boost input according to the jack sensing */ 711/* re-connect the mic boost input according to the jack sensing */
731static void ad1986a_automic(struct hda_codec *codec) 712static void ad1986a_automic(struct hda_codec *codec)
732{ 713{
@@ -776,8 +757,9 @@ static void ad1986a_hp_automute(struct hda_codec *codec)
776 unsigned int present; 757 unsigned int present;
777 758
778 present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0); 759 present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0);
779 /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */ 760 spec->jack_present = !!(present & 0x80000000);
780 spec->jack_present = !(present & 0x80000000); 761 if (spec->inv_jack_detect)
762 spec->jack_present = !spec->jack_present;
781 ad1986a_update_hp(codec); 763 ad1986a_update_hp(codec);
782} 764}
783 765
@@ -816,7 +798,7 @@ static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol,
816 return change; 798 return change;
817} 799}
818 800
819static struct snd_kcontrol_new ad1986a_laptop_automute_mixers[] = { 801static struct snd_kcontrol_new ad1986a_automute_master_mixers[] = {
820 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), 802 HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
821 { 803 {
822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -826,33 +808,10 @@ static struct snd_kcontrol_new ad1986a_laptop_automute_mixers[] = {
826 .put = ad1986a_hp_master_sw_put, 808 .put = ad1986a_hp_master_sw_put,
827 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), 809 .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
828 }, 810 },
829 HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
830 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
831 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT),
832 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT),
833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
834 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
835 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
836 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
837 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
838 {
839 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
840 .name = "Capture Source",
841 .info = ad198x_mux_enum_info,
842 .get = ad198x_mux_enum_get,
843 .put = ad198x_mux_enum_put,
844 },
845 {
846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
847 .name = "External Amplifier",
848 .info = ad198x_eapd_info,
849 .get = ad198x_eapd_get,
850 .put = ad198x_eapd_put,
851 .private_value = 0x1b | (1 << 8), /* port-D, inversed */
852 },
853 { } /* end */ 811 { } /* end */
854}; 812};
855 813
814
856/* 815/*
857 * initialization verbs 816 * initialization verbs
858 */ 817 */
@@ -981,6 +940,27 @@ static struct hda_verb ad1986a_hp_init_verbs[] = {
981 {} 940 {}
982}; 941};
983 942
943static void ad1986a_samsung_p50_unsol_event(struct hda_codec *codec,
944 unsigned int res)
945{
946 switch (res >> 26) {
947 case AD1986A_HP_EVENT:
948 ad1986a_hp_automute(codec);
949 break;
950 case AD1986A_MIC_EVENT:
951 ad1986a_automic(codec);
952 break;
953 }
954}
955
956static int ad1986a_samsung_p50_init(struct hda_codec *codec)
957{
958 ad198x_init(codec);
959 ad1986a_hp_automute(codec);
960 ad1986a_automic(codec);
961 return 0;
962}
963
984 964
985/* models */ 965/* models */
986enum { 966enum {
@@ -991,6 +971,7 @@ enum {
991 AD1986A_LAPTOP_AUTOMUTE, 971 AD1986A_LAPTOP_AUTOMUTE,
992 AD1986A_ULTRA, 972 AD1986A_ULTRA,
993 AD1986A_SAMSUNG, 973 AD1986A_SAMSUNG,
974 AD1986A_SAMSUNG_P50,
994 AD1986A_MODELS 975 AD1986A_MODELS
995}; 976};
996 977
@@ -1002,6 +983,7 @@ static const char *ad1986a_models[AD1986A_MODELS] = {
1002 [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute", 983 [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
1003 [AD1986A_ULTRA] = "ultra", 984 [AD1986A_ULTRA] = "ultra",
1004 [AD1986A_SAMSUNG] = "samsung", 985 [AD1986A_SAMSUNG] = "samsung",
986 [AD1986A_SAMSUNG_P50] = "samsung-p50",
1005}; 987};
1006 988
1007static struct snd_pci_quirk ad1986a_cfg_tbl[] = { 989static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
@@ -1024,6 +1006,7 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
1024 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD), 1006 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
1025 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), 1007 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
1026 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), 1008 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
1009 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50),
1027 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), 1010 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
1028 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG), 1011 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG),
1029 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), 1012 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
@@ -1111,7 +1094,10 @@ static int patch_ad1986a(struct hda_codec *codec)
1111 spec->multiout.dac_nids = ad1986a_laptop_dac_nids; 1094 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1112 break; 1095 break;
1113 case AD1986A_LAPTOP_EAPD: 1096 case AD1986A_LAPTOP_EAPD:
1114 spec->mixers[0] = ad1986a_laptop_eapd_mixers; 1097 spec->num_mixers = 3;
1098 spec->mixers[0] = ad1986a_laptop_master_mixers;
1099 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1100 spec->mixers[2] = ad1986a_laptop_intmic_mixers;
1115 spec->num_init_verbs = 2; 1101 spec->num_init_verbs = 2;
1116 spec->init_verbs[1] = ad1986a_eapd_init_verbs; 1102 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1117 spec->multiout.max_channels = 2; 1103 spec->multiout.max_channels = 2;
@@ -1122,7 +1108,9 @@ static int patch_ad1986a(struct hda_codec *codec)
1122 spec->input_mux = &ad1986a_laptop_eapd_capture_source; 1108 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1123 break; 1109 break;
1124 case AD1986A_SAMSUNG: 1110 case AD1986A_SAMSUNG:
1125 spec->mixers[0] = ad1986a_samsung_mixers; 1111 spec->num_mixers = 2;
1112 spec->mixers[0] = ad1986a_laptop_master_mixers;
1113 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1126 spec->num_init_verbs = 3; 1114 spec->num_init_verbs = 3;
1127 spec->init_verbs[1] = ad1986a_eapd_init_verbs; 1115 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1128 spec->init_verbs[2] = ad1986a_automic_verbs; 1116 spec->init_verbs[2] = ad1986a_automic_verbs;
@@ -1135,8 +1123,28 @@ static int patch_ad1986a(struct hda_codec *codec)
1135 codec->patch_ops.unsol_event = ad1986a_automic_unsol_event; 1123 codec->patch_ops.unsol_event = ad1986a_automic_unsol_event;
1136 codec->patch_ops.init = ad1986a_automic_init; 1124 codec->patch_ops.init = ad1986a_automic_init;
1137 break; 1125 break;
1126 case AD1986A_SAMSUNG_P50:
1127 spec->num_mixers = 2;
1128 spec->mixers[0] = ad1986a_automute_master_mixers;
1129 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1130 spec->num_init_verbs = 4;
1131 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1132 spec->init_verbs[2] = ad1986a_automic_verbs;
1133 spec->init_verbs[3] = ad1986a_hp_init_verbs;
1134 spec->multiout.max_channels = 2;
1135 spec->multiout.num_dacs = 1;
1136 spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
1137 if (!is_jack_available(codec, 0x25))
1138 spec->multiout.dig_out_nid = 0;
1139 spec->input_mux = &ad1986a_automic_capture_source;
1140 codec->patch_ops.unsol_event = ad1986a_samsung_p50_unsol_event;
1141 codec->patch_ops.init = ad1986a_samsung_p50_init;
1142 break;
1138 case AD1986A_LAPTOP_AUTOMUTE: 1143 case AD1986A_LAPTOP_AUTOMUTE:
1139 spec->mixers[0] = ad1986a_laptop_automute_mixers; 1144 spec->num_mixers = 3;
1145 spec->mixers[0] = ad1986a_automute_master_mixers;
1146 spec->mixers[1] = ad1986a_laptop_eapd_mixers;
1147 spec->mixers[2] = ad1986a_laptop_intmic_mixers;
1140 spec->num_init_verbs = 3; 1148 spec->num_init_verbs = 3;
1141 spec->init_verbs[1] = ad1986a_eapd_init_verbs; 1149 spec->init_verbs[1] = ad1986a_eapd_init_verbs;
1142 spec->init_verbs[2] = ad1986a_hp_init_verbs; 1150 spec->init_verbs[2] = ad1986a_hp_init_verbs;
@@ -1148,6 +1156,10 @@ static int patch_ad1986a(struct hda_codec *codec)
1148 spec->input_mux = &ad1986a_laptop_eapd_capture_source; 1156 spec->input_mux = &ad1986a_laptop_eapd_capture_source;
1149 codec->patch_ops.unsol_event = ad1986a_hp_unsol_event; 1157 codec->patch_ops.unsol_event = ad1986a_hp_unsol_event;
1150 codec->patch_ops.init = ad1986a_hp_init; 1158 codec->patch_ops.init = ad1986a_hp_init;
1159 /* Lenovo N100 seems to report the reversed bit
1160 * for HP jack-sensing
1161 */
1162 spec->inv_jack_detect = 1;
1151 break; 1163 break;
1152 case AD1986A_ULTRA: 1164 case AD1986A_ULTRA:
1153 spec->mixers[0] = ad1986a_laptop_eapd_mixers; 1165 spec->mixers[0] = ad1986a_laptop_eapd_mixers;
@@ -3734,9 +3746,30 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3734 { } /* end */ 3746 { } /* end */
3735}; 3747};
3736 3748
3749static int ad1884a_mobile_master_sw_put(struct snd_kcontrol *kcontrol,
3750 struct snd_ctl_elem_value *ucontrol)
3751{
3752 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3753 int ret = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
3754 int mute = (!ucontrol->value.integer.value[0] &&
3755 !ucontrol->value.integer.value[1]);
3756 /* toggle GPIO1 according to the mute state */
3757 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3758 mute ? 0x02 : 0x0);
3759 return ret;
3760}
3761
3737static struct snd_kcontrol_new ad1884a_mobile_mixers[] = { 3762static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
3738 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), 3763 HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT),
3739 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), 3764 /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
3765 {
3766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3767 .name = "Master Playback Switch",
3768 .info = snd_hda_mixer_amp_switch_info,
3769 .get = snd_hda_mixer_amp_switch_get,
3770 .put = ad1884a_mobile_master_sw_put,
3771 .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
3772 },
3740 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), 3773 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3741 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), 3774 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3742 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT), 3775 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
@@ -3857,6 +3890,10 @@ static struct hda_verb ad1884a_mobile_verbs[] = {
3857 /* unsolicited event for pin-sense */ 3890 /* unsolicited event for pin-sense */
3858 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, 3891 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT},
3859 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, 3892 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT},
3893 /* allow to touch GPIO1 (for mute control) */
3894 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
3895 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
3896 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */
3860 { } /* end */ 3897 { } /* end */
3861}; 3898};
3862 3899
@@ -3966,6 +4003,7 @@ static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3966 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), 4003 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
3967 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), 4004 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
3968 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE), 4005 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE),
4006 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP),
3969 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP), 4007 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP),
3970 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP), 4008 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP),
3971 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), 4009 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c
index 392d108c3558..019ca7cb56d7 100644
--- a/sound/pci/hda/patch_ca0110.c
+++ b/sound/pci/hda/patch_ca0110.c
@@ -510,7 +510,7 @@ static int ca0110_parse_auto_config(struct hda_codec *codec)
510} 510}
511 511
512 512
513int patch_ca0110(struct hda_codec *codec) 513static int patch_ca0110(struct hda_codec *codec)
514{ 514{
515 struct ca0110_spec *spec; 515 struct ca0110_spec *spec;
516 int err; 516 int err;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 334533197425..7e99763ca527 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -945,12 +945,13 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
945static void alc_automute_pin(struct hda_codec *codec) 945static void alc_automute_pin(struct hda_codec *codec)
946{ 946{
947 struct alc_spec *spec = codec->spec; 947 struct alc_spec *spec = codec->spec;
948 unsigned int present; 948 unsigned int present, pincap;
949 unsigned int nid = spec->autocfg.hp_pins[0]; 949 unsigned int nid = spec->autocfg.hp_pins[0];
950 int i; 950 int i;
951 951
952 /* need to execute and sync at first */ 952 pincap = snd_hda_query_pin_caps(codec, nid);
953 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); 953 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
954 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
954 present = snd_hda_codec_read(codec, nid, 0, 955 present = snd_hda_codec_read(codec, nid, 0,
955 AC_VERB_GET_PIN_SENSE, 0); 956 AC_VERB_GET_PIN_SENSE, 0);
956 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; 957 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
@@ -1392,7 +1393,7 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1392static void alc_automute_amp(struct hda_codec *codec) 1393static void alc_automute_amp(struct hda_codec *codec)
1393{ 1394{
1394 struct alc_spec *spec = codec->spec; 1395 struct alc_spec *spec = codec->spec;
1395 unsigned int val, mute; 1396 unsigned int val, mute, pincap;
1396 hda_nid_t nid; 1397 hda_nid_t nid;
1397 int i; 1398 int i;
1398 1399
@@ -1401,6 +1402,10 @@ static void alc_automute_amp(struct hda_codec *codec)
1401 nid = spec->autocfg.hp_pins[i]; 1402 nid = spec->autocfg.hp_pins[i];
1402 if (!nid) 1403 if (!nid)
1403 break; 1404 break;
1405 pincap = snd_hda_query_pin_caps(codec, nid);
1406 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1407 snd_hda_codec_read(codec, nid, 0,
1408 AC_VERB_SET_PIN_SENSE, 0);
1404 val = snd_hda_codec_read(codec, nid, 0, 1409 val = snd_hda_codec_read(codec, nid, 0,
1405 AC_VERB_GET_PIN_SENSE, 0); 1410 AC_VERB_GET_PIN_SENSE, 0);
1406 if (val & AC_PINSENSE_PRESENCE) { 1411 if (val & AC_PINSENSE_PRESENCE) {
@@ -1471,6 +1476,10 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1471static struct hda_verb alc888_acer_aspire_6530g_verbs[] = { 1476static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1472/* Bias voltage on for external mic port */ 1477/* Bias voltage on for external mic port */
1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80}, 1478 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1479/* Front Mic: set to PIN_IN (empty by default) */
1480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1481/* Unselect Front Mic by default in input mixer 3 */
1482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1474/* Enable unsolicited event for HP jack */ 1483/* Enable unsolicited event for HP jack */
1475 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 1484 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1476/* Enable speaker output */ 1485/* Enable speaker output */
@@ -1560,18 +1569,22 @@ static struct hda_input_mux alc888_2_capture_sources[2] = {
1560static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = { 1569static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1561 /* Interal mic only available on one ADC */ 1570 /* Interal mic only available on one ADC */
1562 { 1571 {
1563 .num_items = 3, 1572 .num_items = 5,
1564 .items = { 1573 .items = {
1565 { "Ext Mic", 0x0 }, 1574 { "Ext Mic", 0x0 },
1575 { "Line In", 0x2 },
1566 { "CD", 0x4 }, 1576 { "CD", 0x4 },
1577 { "Input Mix", 0xa },
1567 { "Int Mic", 0xb }, 1578 { "Int Mic", 0xb },
1568 }, 1579 },
1569 }, 1580 },
1570 { 1581 {
1571 .num_items = 2, 1582 .num_items = 4,
1572 .items = { 1583 .items = {
1573 { "Ext Mic", 0x0 }, 1584 { "Ext Mic", 0x0 },
1585 { "Line In", 0x2 },
1574 { "CD", 0x4 }, 1586 { "CD", 0x4 },
1587 { "Input Mix", 0xa },
1575 }, 1588 },
1576 } 1589 }
1577}; 1590};
@@ -1639,6 +1652,17 @@ static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
1639 alc_automute_amp(codec); 1652 alc_automute_amp(codec);
1640} 1653}
1641 1654
1655static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1656{
1657 struct alc_spec *spec = codec->spec;
1658
1659 spec->autocfg.hp_pins[0] = 0x15;
1660 spec->autocfg.speaker_pins[0] = 0x14;
1661 spec->autocfg.speaker_pins[1] = 0x16;
1662 spec->autocfg.speaker_pins[2] = 0x17;
1663 alc_automute_amp(codec);
1664}
1665
1642static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) 1666static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
1643{ 1667{
1644 struct alc_spec *spec = codec->spec; 1668 struct alc_spec *spec = codec->spec;
@@ -4481,6 +4505,12 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4481 &dig_nid, 1); 4505 &dig_nid, 1);
4482 if (err < 0) 4506 if (err < 0)
4483 continue; 4507 continue;
4508 if (dig_nid > 0x7f) {
4509 printk(KERN_ERR "alc880_auto: invalid dig_nid "
4510 "connection 0x%x for NID 0x%x\n", dig_nid,
4511 spec->autocfg.dig_out_pins[i]);
4512 continue;
4513 }
4484 if (!i) 4514 if (!i)
4485 spec->multiout.dig_out_nid = dig_nid; 4515 spec->multiout.dig_out_nid = dig_nid;
4486 else { 4516 else {
@@ -6895,9 +6925,6 @@ static struct hda_verb alc882_targa_verbs[] = {
6895 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 6925 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6896 6926
6897 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 6927 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6898 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6899 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6900 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6901 { } /* end */ 6928 { } /* end */
6902}; 6929};
6903 6930
@@ -7217,7 +7244,8 @@ static struct alc_config_preset alc882_presets[] = {
7217 }, 7244 },
7218 [ALC882_TARGA] = { 7245 [ALC882_TARGA] = {
7219 .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, 7246 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
7220 .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, 7247 .init_verbs = { alc882_init_verbs, alc880_gpio3_init_verbs,
7248 alc882_targa_verbs},
7221 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 7249 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7222 .dac_nids = alc882_dac_nids, 7250 .dac_nids = alc882_dac_nids,
7223 .dig_out_nid = ALC882_DIGOUT_NID, 7251 .dig_out_nid = ALC882_DIGOUT_NID,
@@ -8189,6 +8217,8 @@ static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 8217 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8190 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 8218 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8191 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT), 8219 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8220 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8221 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 8222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 8223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 8224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
@@ -9064,7 +9094,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
9064 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), 9094 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
9065 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), 9095 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
9066 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 9096 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
9067 ALC888_ACER_ASPIRE_4930G), 9097 ALC888_ACER_ASPIRE_6530G),
9068 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", 9098 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
9069 ALC888_ACER_ASPIRE_6530G), 9099 ALC888_ACER_ASPIRE_6530G),
9070 /* default Acer -- disabled as it causes more problems. 9100 /* default Acer -- disabled as it causes more problems.
@@ -9212,7 +9242,8 @@ static struct alc_config_preset alc883_presets[] = {
9212 }, 9242 },
9213 [ALC883_TARGA_DIG] = { 9243 [ALC883_TARGA_DIG] = {
9214 .mixers = { alc883_targa_mixer, alc883_chmode_mixer }, 9244 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9215 .init_verbs = { alc883_init_verbs, alc883_targa_verbs}, 9245 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9246 alc883_targa_verbs},
9216 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 9247 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9217 .dac_nids = alc883_dac_nids, 9248 .dac_nids = alc883_dac_nids,
9218 .dig_out_nid = ALC883_DIGOUT_NID, 9249 .dig_out_nid = ALC883_DIGOUT_NID,
@@ -9225,7 +9256,8 @@ static struct alc_config_preset alc883_presets[] = {
9225 }, 9256 },
9226 [ALC883_TARGA_2ch_DIG] = { 9257 [ALC883_TARGA_2ch_DIG] = {
9227 .mixers = { alc883_targa_2ch_mixer}, 9258 .mixers = { alc883_targa_2ch_mixer},
9228 .init_verbs = { alc883_init_verbs, alc883_targa_verbs}, 9259 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9260 alc883_targa_verbs},
9229 .num_dacs = ARRAY_SIZE(alc883_dac_nids), 9261 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9230 .dac_nids = alc883_dac_nids, 9262 .dac_nids = alc883_dac_nids,
9231 .adc_nids = alc883_adc_nids_alt, 9263 .adc_nids = alc883_adc_nids_alt,
@@ -9317,7 +9349,7 @@ static struct alc_config_preset alc883_presets[] = {
9317 ARRAY_SIZE(alc888_2_capture_sources), 9349 ARRAY_SIZE(alc888_2_capture_sources),
9318 .input_mux = alc888_acer_aspire_6530_sources, 9350 .input_mux = alc888_acer_aspire_6530_sources,
9319 .unsol_event = alc_automute_amp_unsol_event, 9351 .unsol_event = alc_automute_amp_unsol_event,
9320 .init_hook = alc888_acer_aspire_4930g_init_hook, 9352 .init_hook = alc888_acer_aspire_6530g_init_hook,
9321 }, 9353 },
9322 [ALC888_ACER_ASPIRE_8930G] = { 9354 [ALC888_ACER_ASPIRE_8930G] = {
9323 .mixers = { alc888_base_mixer, 9355 .mixers = { alc888_base_mixer,
@@ -12437,6 +12469,8 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
12437 if (err < 0) 12469 if (err < 0)
12438 return err; 12470 return err;
12439 12471
12472 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12473
12440 return 1; 12474 return 1;
12441} 12475}
12442 12476
@@ -12848,20 +12882,11 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12848 { } 12882 { }
12849}; 12883};
12850 12884
12851/* bind volumes of both NID 0x0c and 0x0d */
12852static struct hda_bind_ctls alc269_epc_bind_vol = {
12853 .ops = &snd_hda_bind_vol,
12854 .values = {
12855 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12856 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12857 0
12858 },
12859};
12860
12861static struct snd_kcontrol_new alc269_eeepc_mixer[] = { 12885static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12862 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 12886 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12863 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), 12887 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12864 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), 12888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12865 { } /* end */ 12890 { } /* end */
12866}; 12891};
12867 12892
@@ -12874,12 +12899,7 @@ static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12874}; 12899};
12875 12900
12876/* FSC amilo */ 12901/* FSC amilo */
12877static struct snd_kcontrol_new alc269_fujitsu_mixer[] = { 12902#define alc269_fujitsu_mixer alc269_eeepc_mixer
12878 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12880 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
12881 { } /* end */
12882};
12883 12903
12884static struct hda_verb alc269_quanta_fl1_verbs[] = { 12904static struct hda_verb alc269_quanta_fl1_verbs[] = {
12885 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 12905 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
@@ -13345,6 +13365,8 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
13345 if (!spec->cap_mixer && !spec->no_analog) 13365 if (!spec->cap_mixer && !spec->no_analog)
13346 set_capture_mixer(spec); 13366 set_capture_mixer(spec);
13347 13367
13368 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13369
13348 return 1; 13370 return 1;
13349} 13371}
13350 13372
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 14f3c3e0f62d..da7f9f65c047 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -1590,8 +1590,6 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1590 /* SigmaTel reference board */ 1590 /* SigmaTel reference board */
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1591 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1592 "DFI LanParty", STAC_REF), 1592 "DFI LanParty", STAC_REF),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
1594 "SigmaTel",STAC_9205_REF),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, 1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1596 "DFI LanParty", STAC_REF), 1594 "DFI LanParty", STAC_REF),
1597 /* Dell laptops have BIOS problem */ 1595 /* Dell laptops have BIOS problem */
@@ -2344,6 +2342,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2344 /* SigmaTel reference board */ 2342 /* SigmaTel reference board */
2345 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 2343 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2346 "DFI LanParty", STAC_9205_REF), 2344 "DFI LanParty", STAC_9205_REF),
2345 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2346 "SigmaTel", STAC_9205_REF),
2347 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, 2347 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2348 "DFI LanParty", STAC_9205_REF), 2348 "DFI LanParty", STAC_9205_REF),
2349 /* Dell */ 2349 /* Dell */
@@ -2378,6 +2378,7 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, 2378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2379 "Dell Vostro 1500", STAC_9205_DELL_M42), 2379 "Dell Vostro 1500", STAC_9205_DELL_M42),
2380 /* Gateway */ 2380 /* Gateway */
2381 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2381 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), 2382 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2382 {} /* terminator */ 2383 {} /* terminator */
2383}; 2384};
@@ -5854,6 +5855,8 @@ static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5854}; 5855};
5855 5856
5856static struct snd_pci_quirk stac9872_cfg_tbl[] = { 5857static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5858 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5859 "Sony VAIO F/S", STAC_9872_VAIO),
5857 {} /* terminator */ 5860 {} /* terminator */
5858}; 5861};
5859 5862
@@ -5866,6 +5869,8 @@ static int patch_stac9872(struct hda_codec *codec)
5866 if (spec == NULL) 5869 if (spec == NULL)
5867 return -ENOMEM; 5870 return -ENOMEM;
5868 codec->spec = spec; 5871 codec->spec = spec;
5872 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5873 spec->pin_nids = stac9872_pin_nids;
5869 5874
5870 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, 5875 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5871 stac9872_models, 5876 stac9872_models,
@@ -5877,8 +5882,6 @@ static int patch_stac9872(struct hda_codec *codec)
5877 stac92xx_set_config_regs(codec, 5882 stac92xx_set_config_regs(codec,
5878 stac9872_brd_tbl[spec->board_config]); 5883 stac9872_brd_tbl[spec->board_config]);
5879 5884
5880 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5881 spec->pin_nids = stac9872_pin_nids;
5882 spec->multiout.dac_nids = spec->dac_nids; 5885 spec->multiout.dac_nids = spec->dac_nids;
5883 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); 5886 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5884 spec->adc_nids = stac9872_adc_nids; 5887 spec->adc_nids = stac9872_adc_nids;
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 8e004fb6961a..9008b4b013aa 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -210,7 +210,9 @@ struct via_spec {
210 /* capture */ 210 /* capture */
211 unsigned int num_adc_nids; 211 unsigned int num_adc_nids;
212 hda_nid_t *adc_nids; 212 hda_nid_t *adc_nids;
213 hda_nid_t mux_nids[3];
213 hda_nid_t dig_in_nid; 214 hda_nid_t dig_in_nid;
215 hda_nid_t dig_in_pin;
214 216
215 /* capture source */ 217 /* capture source */
216 const struct hda_input_mux *input_mux; 218 const struct hda_input_mux *input_mux;
@@ -319,6 +321,9 @@ static void via_auto_set_output_and_unmute(struct hda_codec *codec,
319 pin_type); 321 pin_type);
320 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 322 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
321 AMP_OUT_UNMUTE); 323 AMP_OUT_UNMUTE);
324 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
325 snd_hda_codec_write(codec, nid, 0,
326 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
322} 327}
323 328
324 329
@@ -387,27 +392,12 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol,
387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 392 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
388 struct via_spec *spec = codec->spec; 393 struct via_spec *spec = codec->spec;
389 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 394 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
390 unsigned int vendor_id = codec->vendor_id; 395
391 396 if (!spec->mux_nids[adc_idx])
392 /* AIW0 lydia 060801 add for correct sw0 input select */ 397 return -EINVAL;
393 if (IS_VT1708_VENDORID(vendor_id) && (adc_idx == 0)) 398 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
394 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 399 spec->mux_nids[adc_idx],
395 0x18, &spec->cur_mux[adc_idx]); 400 &spec->cur_mux[adc_idx]);
396 else if ((IS_VT1709_10CH_VENDORID(vendor_id) ||
397 IS_VT1709_6CH_VENDORID(vendor_id)) && (adc_idx == 0))
398 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
399 0x19, &spec->cur_mux[adc_idx]);
400 else if ((IS_VT1708B_8CH_VENDORID(vendor_id) ||
401 IS_VT1708B_4CH_VENDORID(vendor_id)) && (adc_idx == 0))
402 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
403 0x17, &spec->cur_mux[adc_idx]);
404 else if (IS_VT1702_VENDORID(vendor_id) && (adc_idx == 0))
405 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
406 0x13, &spec->cur_mux[adc_idx]);
407 else
408 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
409 spec->adc_nids[adc_idx],
410 &spec->cur_mux[adc_idx]);
411} 401}
412 402
413static int via_independent_hp_info(struct snd_kcontrol *kcontrol, 403static int via_independent_hp_info(struct snd_kcontrol *kcontrol,
@@ -998,25 +988,11 @@ static int via_init(struct hda_codec *codec)
998 988
999 /* Lydia Add for EAPD enable */ 989 /* Lydia Add for EAPD enable */
1000 if (!spec->dig_in_nid) { /* No Digital In connection */ 990 if (!spec->dig_in_nid) { /* No Digital In connection */
1001 if (IS_VT1708_VENDORID(codec->vendor_id)) { 991 if (spec->dig_in_pin) {
1002 snd_hda_codec_write(codec, VT1708_DIGIN_PIN, 0, 992 snd_hda_codec_write(codec, spec->dig_in_pin, 0,
1003 AC_VERB_SET_PIN_WIDGET_CONTROL,
1004 PIN_OUT);
1005 snd_hda_codec_write(codec, VT1708_DIGIN_PIN, 0,
1006 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
1007 } else if (IS_VT1709_10CH_VENDORID(codec->vendor_id) ||
1008 IS_VT1709_6CH_VENDORID(codec->vendor_id)) {
1009 snd_hda_codec_write(codec, VT1709_DIGIN_PIN, 0,
1010 AC_VERB_SET_PIN_WIDGET_CONTROL, 993 AC_VERB_SET_PIN_WIDGET_CONTROL,
1011 PIN_OUT); 994 PIN_OUT);
1012 snd_hda_codec_write(codec, VT1709_DIGIN_PIN, 0, 995 snd_hda_codec_write(codec, spec->dig_in_pin, 0,
1013 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
1014 } else if (IS_VT1708B_8CH_VENDORID(codec->vendor_id) ||
1015 IS_VT1708B_4CH_VENDORID(codec->vendor_id)) {
1016 snd_hda_codec_write(codec, VT1708B_DIGIN_PIN, 0,
1017 AC_VERB_SET_PIN_WIDGET_CONTROL,
1018 PIN_OUT);
1019 snd_hda_codec_write(codec, VT1708B_DIGIN_PIN, 0,
1020 AC_VERB_SET_EAPD_BTLENABLE, 0x02); 996 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
1021 } 997 }
1022 } else /* enable SPDIF-input pin */ 998 } else /* enable SPDIF-input pin */
@@ -1326,6 +1302,7 @@ static int vt1708_parse_auto_config(struct hda_codec *codec)
1326 1302
1327 if (spec->autocfg.dig_outs) 1303 if (spec->autocfg.dig_outs)
1328 spec->multiout.dig_out_nid = VT1708_DIGOUT_NID; 1304 spec->multiout.dig_out_nid = VT1708_DIGOUT_NID;
1305 spec->dig_in_pin = VT1708_DIGIN_PIN;
1329 if (spec->autocfg.dig_in_pin) 1306 if (spec->autocfg.dig_in_pin)
1330 spec->dig_in_nid = VT1708_DIGIN_NID; 1307 spec->dig_in_nid = VT1708_DIGIN_NID;
1331 1308
@@ -1352,6 +1329,34 @@ static int via_auto_init(struct hda_codec *codec)
1352 return 0; 1329 return 0;
1353} 1330}
1354 1331
1332static int get_mux_nids(struct hda_codec *codec)
1333{
1334 struct via_spec *spec = codec->spec;
1335 hda_nid_t nid, conn[8];
1336 unsigned int type;
1337 int i, n;
1338
1339 for (i = 0; i < spec->num_adc_nids; i++) {
1340 nid = spec->adc_nids[i];
1341 while (nid) {
1342 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE)
1343 >> AC_WCAP_TYPE_SHIFT;
1344 if (type == AC_WID_PIN)
1345 break;
1346 n = snd_hda_get_connections(codec, nid, conn,
1347 ARRAY_SIZE(conn));
1348 if (n <= 0)
1349 break;
1350 if (n > 1) {
1351 spec->mux_nids[i] = nid;
1352 break;
1353 }
1354 nid = conn[0];
1355 }
1356 }
1357 return 0;
1358}
1359
1355static int patch_vt1708(struct hda_codec *codec) 1360static int patch_vt1708(struct hda_codec *codec)
1356{ 1361{
1357 struct via_spec *spec; 1362 struct via_spec *spec;
@@ -1799,6 +1804,7 @@ static int vt1709_parse_auto_config(struct hda_codec *codec)
1799 1804
1800 if (spec->autocfg.dig_outs) 1805 if (spec->autocfg.dig_outs)
1801 spec->multiout.dig_out_nid = VT1709_DIGOUT_NID; 1806 spec->multiout.dig_out_nid = VT1709_DIGOUT_NID;
1807 spec->dig_in_pin = VT1709_DIGIN_PIN;
1802 if (spec->autocfg.dig_in_pin) 1808 if (spec->autocfg.dig_in_pin)
1803 spec->dig_in_nid = VT1709_DIGIN_NID; 1809 spec->dig_in_nid = VT1709_DIGIN_NID;
1804 1810
@@ -1859,6 +1865,7 @@ static int patch_vt1709_10ch(struct hda_codec *codec)
1859 if (!spec->adc_nids && spec->input_mux) { 1865 if (!spec->adc_nids && spec->input_mux) {
1860 spec->adc_nids = vt1709_adc_nids; 1866 spec->adc_nids = vt1709_adc_nids;
1861 spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); 1867 spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids);
1868 get_mux_nids(codec);
1862 spec->mixers[spec->num_mixers] = vt1709_capture_mixer; 1869 spec->mixers[spec->num_mixers] = vt1709_capture_mixer;
1863 spec->num_mixers++; 1870 spec->num_mixers++;
1864 } 1871 }
@@ -1952,6 +1959,7 @@ static int patch_vt1709_6ch(struct hda_codec *codec)
1952 if (!spec->adc_nids && spec->input_mux) { 1959 if (!spec->adc_nids && spec->input_mux) {
1953 spec->adc_nids = vt1709_adc_nids; 1960 spec->adc_nids = vt1709_adc_nids;
1954 spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); 1961 spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids);
1962 get_mux_nids(codec);
1955 spec->mixers[spec->num_mixers] = vt1709_capture_mixer; 1963 spec->mixers[spec->num_mixers] = vt1709_capture_mixer;
1956 spec->num_mixers++; 1964 spec->num_mixers++;
1957 } 1965 }
@@ -2344,6 +2352,7 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec)
2344 2352
2345 if (spec->autocfg.dig_outs) 2353 if (spec->autocfg.dig_outs)
2346 spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID; 2354 spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID;
2355 spec->dig_in_pin = VT1708B_DIGIN_PIN;
2347 if (spec->autocfg.dig_in_pin) 2356 if (spec->autocfg.dig_in_pin)
2348 spec->dig_in_nid = VT1708B_DIGIN_NID; 2357 spec->dig_in_nid = VT1708B_DIGIN_NID;
2349 2358
@@ -2404,6 +2413,7 @@ static int patch_vt1708B_8ch(struct hda_codec *codec)
2404 if (!spec->adc_nids && spec->input_mux) { 2413 if (!spec->adc_nids && spec->input_mux) {
2405 spec->adc_nids = vt1708B_adc_nids; 2414 spec->adc_nids = vt1708B_adc_nids;
2406 spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids); 2415 spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids);
2416 get_mux_nids(codec);
2407 spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; 2417 spec->mixers[spec->num_mixers] = vt1708B_capture_mixer;
2408 spec->num_mixers++; 2418 spec->num_mixers++;
2409 } 2419 }
@@ -2455,6 +2465,7 @@ static int patch_vt1708B_4ch(struct hda_codec *codec)
2455 if (!spec->adc_nids && spec->input_mux) { 2465 if (!spec->adc_nids && spec->input_mux) {
2456 spec->adc_nids = vt1708B_adc_nids; 2466 spec->adc_nids = vt1708B_adc_nids;
2457 spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids); 2467 spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids);
2468 get_mux_nids(codec);
2458 spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; 2469 spec->mixers[spec->num_mixers] = vt1708B_capture_mixer;
2459 spec->num_mixers++; 2470 spec->num_mixers++;
2460 } 2471 }
@@ -2889,6 +2900,7 @@ static int patch_vt1708S(struct hda_codec *codec)
2889 if (!spec->adc_nids && spec->input_mux) { 2900 if (!spec->adc_nids && spec->input_mux) {
2890 spec->adc_nids = vt1708S_adc_nids; 2901 spec->adc_nids = vt1708S_adc_nids;
2891 spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids); 2902 spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids);
2903 get_mux_nids(codec);
2892 spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; 2904 spec->mixers[spec->num_mixers] = vt1708S_capture_mixer;
2893 spec->num_mixers++; 2905 spec->num_mixers++;
2894 } 2906 }
@@ -3206,6 +3218,7 @@ static int patch_vt1702(struct hda_codec *codec)
3206 if (!spec->adc_nids && spec->input_mux) { 3218 if (!spec->adc_nids && spec->input_mux) {
3207 spec->adc_nids = vt1702_adc_nids; 3219 spec->adc_nids = vt1702_adc_nids;
3208 spec->num_adc_nids = ARRAY_SIZE(vt1702_adc_nids); 3220 spec->num_adc_nids = ARRAY_SIZE(vt1702_adc_nids);
3221 get_mux_nids(codec);
3209 spec->mixers[spec->num_mixers] = vt1702_capture_mixer; 3222 spec->mixers[spec->num_mixers] = vt1702_capture_mixer;
3210 spec->num_mixers++; 3223 spec->num_mixers++;
3211 } 3224 }
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 0d0cdbdb4486..cecf1ffeeaaa 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -107,7 +107,7 @@ MODULE_PARM_DESC(dxr_enable, "Enable DXR support for Terratec DMX6FIRE.");
107 107
108 108
109static const struct pci_device_id snd_ice1712_ids[] = { 109static const struct pci_device_id snd_ice1712_ids[] = {
110 { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICE1712 */ 110 { PCI_VDEVICE(ICE, PCI_DEVICE_ID_ICE_1712), 0 }, /* ICE1712 */
111 { 0, } 111 { 0, }
112}; 112};
113 113
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 36ade77cf371..cc84a831eb21 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -93,7 +93,7 @@ MODULE_PARM_DESC(model, "Use the given board model.");
93 93
94/* Both VT1720 and VT1724 have the same PCI IDs */ 94/* Both VT1720 and VT1724 have the same PCI IDs */
95static const struct pci_device_id snd_vt1724_ids[] = { 95static const struct pci_device_id snd_vt1724_ids[] = {
96 { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_VT1724, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 96 { PCI_VDEVICE(ICE, PCI_DEVICE_ID_VT1724), 0 },
97 { 0, } 97 { 0, }
98}; 98};
99 99
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 8aa5687f392a..171ada535209 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -421,29 +421,29 @@ struct intel8x0 {
421}; 421};
422 422
423static struct pci_device_id snd_intel8x0_ids[] = { 423static struct pci_device_id snd_intel8x0_ids[] = {
424 { 0x8086, 0x2415, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801AA */ 424 { PCI_VDEVICE(INTEL, 0x2415), DEVICE_INTEL }, /* 82801AA */
425 { 0x8086, 0x2425, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82901AB */ 425 { PCI_VDEVICE(INTEL, 0x2425), DEVICE_INTEL }, /* 82901AB */
426 { 0x8086, 0x2445, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801BA */ 426 { PCI_VDEVICE(INTEL, 0x2445), DEVICE_INTEL }, /* 82801BA */
427 { 0x8086, 0x2485, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH3 */ 427 { PCI_VDEVICE(INTEL, 0x2485), DEVICE_INTEL }, /* ICH3 */
428 { 0x8086, 0x24c5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ICH4 */ 428 { PCI_VDEVICE(INTEL, 0x24c5), DEVICE_INTEL_ICH4 }, /* ICH4 */
429 { 0x8086, 0x24d5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ICH5 */ 429 { PCI_VDEVICE(INTEL, 0x24d5), DEVICE_INTEL_ICH4 }, /* ICH5 */
430 { 0x8086, 0x25a6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ESB */ 430 { PCI_VDEVICE(INTEL, 0x25a6), DEVICE_INTEL_ICH4 }, /* ESB */
431 { 0x8086, 0x266e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ICH6 */ 431 { PCI_VDEVICE(INTEL, 0x266e), DEVICE_INTEL_ICH4 }, /* ICH6 */
432 { 0x8086, 0x27de, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ICH7 */ 432 { PCI_VDEVICE(INTEL, 0x27de), DEVICE_INTEL_ICH4 }, /* ICH7 */
433 { 0x8086, 0x2698, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ESB2 */ 433 { PCI_VDEVICE(INTEL, 0x2698), DEVICE_INTEL_ICH4 }, /* ESB2 */
434 { 0x8086, 0x7195, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 440MX */ 434 { PCI_VDEVICE(INTEL, 0x7195), DEVICE_INTEL }, /* 440MX */
435 { 0x1039, 0x7012, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_SIS }, /* SI7012 */ 435 { PCI_VDEVICE(SI, 0x7012), DEVICE_SIS }, /* SI7012 */
436 { 0x10de, 0x01b1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE */ 436 { PCI_VDEVICE(NVIDIA, 0x01b1), DEVICE_NFORCE }, /* NFORCE */
437 { 0x10de, 0x003a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* MCP04 */ 437 { PCI_VDEVICE(NVIDIA, 0x003a), DEVICE_NFORCE }, /* MCP04 */
438 { 0x10de, 0x006a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2 */ 438 { PCI_VDEVICE(NVIDIA, 0x006a), DEVICE_NFORCE }, /* NFORCE2 */
439 { 0x10de, 0x0059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK804 */ 439 { PCI_VDEVICE(NVIDIA, 0x0059), DEVICE_NFORCE }, /* CK804 */
440 { 0x10de, 0x008a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8 */ 440 { PCI_VDEVICE(NVIDIA, 0x008a), DEVICE_NFORCE }, /* CK8 */
441 { 0x10de, 0x00da, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */ 441 { PCI_VDEVICE(NVIDIA, 0x00da), DEVICE_NFORCE }, /* NFORCE3 */
442 { 0x10de, 0x00ea, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8S */ 442 { PCI_VDEVICE(NVIDIA, 0x00ea), DEVICE_NFORCE }, /* CK8S */
443 { 0x10de, 0x026b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* MCP51 */ 443 { PCI_VDEVICE(NVIDIA, 0x026b), DEVICE_NFORCE }, /* MCP51 */
444 { 0x1022, 0x746d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD8111 */ 444 { PCI_VDEVICE(AMD, 0x746d), DEVICE_INTEL }, /* AMD8111 */
445 { 0x1022, 0x7445, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD768 */ 445 { PCI_VDEVICE(AMD, 0x7445), DEVICE_INTEL }, /* AMD768 */
446 { 0x10b9, 0x5455, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALI }, /* Ali5455 */ 446 { PCI_VDEVICE(AL, 0x5455), DEVICE_ALI }, /* Ali5455 */
447 { 0, } 447 { 0, }
448}; 448};
449 449
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 6ec0fc50d6be..9e7d12e7673f 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -220,24 +220,24 @@ struct intel8x0m {
220}; 220};
221 221
222static struct pci_device_id snd_intel8x0m_ids[] = { 222static struct pci_device_id snd_intel8x0m_ids[] = {
223 { 0x8086, 0x2416, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801AA */ 223 { PCI_VDEVICE(INTEL, 0x2416), DEVICE_INTEL }, /* 82801AA */
224 { 0x8086, 0x2426, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82901AB */ 224 { PCI_VDEVICE(INTEL, 0x2426), DEVICE_INTEL }, /* 82901AB */
225 { 0x8086, 0x2446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801BA */ 225 { PCI_VDEVICE(INTEL, 0x2446), DEVICE_INTEL }, /* 82801BA */
226 { 0x8086, 0x2486, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH3 */ 226 { PCI_VDEVICE(INTEL, 0x2486), DEVICE_INTEL }, /* ICH3 */
227 { 0x8086, 0x24c6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH4 */ 227 { PCI_VDEVICE(INTEL, 0x24c6), DEVICE_INTEL }, /* ICH4 */
228 { 0x8086, 0x24d6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH5 */ 228 { PCI_VDEVICE(INTEL, 0x24d6), DEVICE_INTEL }, /* ICH5 */
229 { 0x8086, 0x266d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH6 */ 229 { PCI_VDEVICE(INTEL, 0x266d), DEVICE_INTEL }, /* ICH6 */
230 { 0x8086, 0x27dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH7 */ 230 { PCI_VDEVICE(INTEL, 0x27dd), DEVICE_INTEL }, /* ICH7 */
231 { 0x8086, 0x7196, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 440MX */ 231 { PCI_VDEVICE(INTEL, 0x7196), DEVICE_INTEL }, /* 440MX */
232 { 0x1022, 0x7446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD768 */ 232 { PCI_VDEVICE(AMD, 0x7446), DEVICE_INTEL }, /* AMD768 */
233 { 0x1039, 0x7013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_SIS }, /* SI7013 */ 233 { PCI_VDEVICE(SI, 0x7013), DEVICE_SIS }, /* SI7013 */
234 { 0x10de, 0x01c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE */ 234 { PCI_VDEVICE(NVIDIA, 0x01c1), DEVICE_NFORCE }, /* NFORCE */
235 { 0x10de, 0x0069, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2 */ 235 { PCI_VDEVICE(NVIDIA, 0x0069), DEVICE_NFORCE }, /* NFORCE2 */
236 { 0x10de, 0x0089, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2s */ 236 { PCI_VDEVICE(NVIDIA, 0x0089), DEVICE_NFORCE }, /* NFORCE2s */
237 { 0x10de, 0x00d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */ 237 { PCI_VDEVICE(NVIDIA, 0x00d9), DEVICE_NFORCE }, /* NFORCE3 */
238#if 0 238#if 0
239 { 0x1022, 0x746d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD8111 */ 239 { PCI_VDEVICE(AMD, 0x746d), DEVICE_INTEL }, /* AMD8111 */
240 { 0x10b9, 0x5455, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALI }, /* Ali5455 */ 240 { PCI_VDEVICE(AL, 0x5455), DEVICE_ALI }, /* Ali5455 */
241#endif 241#endif
242 { 0, } 242 { 0, }
243}; 243};
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 18da2ef04d09..11b8c6514b3d 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -654,13 +654,12 @@ static int __devinit lx_init_ethersound_config(struct lx6464es *chip)
654 int i; 654 int i;
655 u32 orig_conf_es = lx_dsp_reg_read(chip, eReg_CONFES); 655 u32 orig_conf_es = lx_dsp_reg_read(chip, eReg_CONFES);
656 656
657 u32 default_conf_es = (64 << IOCR_OUTPUTS_OFFSET) | 657 /* configure 64 io channels */
658 u32 conf_es = (orig_conf_es & CONFES_READ_PART_MASK) |
658 (64 << IOCR_INPUTS_OFFSET) | 659 (64 << IOCR_INPUTS_OFFSET) |
660 (64 << IOCR_OUTPUTS_OFFSET) |
659 (FREQ_RATIO_SINGLE_MODE << FREQ_RATIO_OFFSET); 661 (FREQ_RATIO_SINGLE_MODE << FREQ_RATIO_OFFSET);
660 662
661 u32 conf_es = (orig_conf_es & CONFES_READ_PART_MASK)
662 | (default_conf_es & CONFES_WRITE_PART_MASK);
663
664 snd_printdd("->lx_init_ethersound\n"); 663 snd_printdd("->lx_init_ethersound\n");
665 664
666 chip->freq_ratio = FREQ_RATIO_SINGLE_MODE; 665 chip->freq_ratio = FREQ_RATIO_SINGLE_MODE;
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 82bc5b9e7629..a83d1968a845 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -61,7 +61,7 @@ MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard.");
61 */ 61 */
62 62
63static struct pci_device_id snd_mixart_ids[] = { 63static struct pci_device_id snd_mixart_ids[] = {
64 { 0x1057, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* MC8240 */ 64 { PCI_VDEVICE(MOTOROLA, 0x0003), 0, }, /* MC8240 */
65 { 0, } 65 { 0, }
66}; 66};
67 67
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 522a040855d4..97a0731331a1 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -263,9 +263,9 @@ struct nm256 {
263 * PCI ids 263 * PCI ids
264 */ 264 */
265static struct pci_device_id snd_nm256_ids[] = { 265static struct pci_device_id snd_nm256_ids[] = {
266 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 266 {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO), 0},
267 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 267 {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO), 0},
268 {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 268 {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO), 0},
269 {0,}, 269 {0,},
270}; 270};
271 271
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 304da169bfdc..5401c547c4e3 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -575,8 +575,10 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
575static int ac97_volume_info(struct snd_kcontrol *ctl, 575static int ac97_volume_info(struct snd_kcontrol *ctl,
576 struct snd_ctl_elem_info *info) 576 struct snd_ctl_elem_info *info)
577{ 577{
578 int stereo = (ctl->private_value >> 16) & 1;
579
578 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 580 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
579 info->count = 2; 581 info->count = stereo ? 2 : 1;
580 info->value.integer.min = 0; 582 info->value.integer.min = 0;
581 info->value.integer.max = 0x1f; 583 info->value.integer.max = 0x1f;
582 return 0; 584 return 0;
@@ -587,6 +589,7 @@ static int ac97_volume_get(struct snd_kcontrol *ctl,
587{ 589{
588 struct oxygen *chip = ctl->private_data; 590 struct oxygen *chip = ctl->private_data;
589 unsigned int codec = (ctl->private_value >> 24) & 1; 591 unsigned int codec = (ctl->private_value >> 24) & 1;
592 int stereo = (ctl->private_value >> 16) & 1;
590 unsigned int index = ctl->private_value & 0xff; 593 unsigned int index = ctl->private_value & 0xff;
591 u16 reg; 594 u16 reg;
592 595
@@ -594,7 +597,8 @@ static int ac97_volume_get(struct snd_kcontrol *ctl,
594 reg = oxygen_read_ac97(chip, codec, index); 597 reg = oxygen_read_ac97(chip, codec, index);
595 mutex_unlock(&chip->mutex); 598 mutex_unlock(&chip->mutex);
596 value->value.integer.value[0] = 31 - (reg & 0x1f); 599 value->value.integer.value[0] = 31 - (reg & 0x1f);
597 value->value.integer.value[1] = 31 - ((reg >> 8) & 0x1f); 600 if (stereo)
601 value->value.integer.value[1] = 31 - ((reg >> 8) & 0x1f);
598 return 0; 602 return 0;
599} 603}
600 604
@@ -603,6 +607,7 @@ static int ac97_volume_put(struct snd_kcontrol *ctl,
603{ 607{
604 struct oxygen *chip = ctl->private_data; 608 struct oxygen *chip = ctl->private_data;
605 unsigned int codec = (ctl->private_value >> 24) & 1; 609 unsigned int codec = (ctl->private_value >> 24) & 1;
610 int stereo = (ctl->private_value >> 16) & 1;
606 unsigned int index = ctl->private_value & 0xff; 611 unsigned int index = ctl->private_value & 0xff;
607 u16 oldreg, newreg; 612 u16 oldreg, newreg;
608 int change; 613 int change;
@@ -612,8 +617,11 @@ static int ac97_volume_put(struct snd_kcontrol *ctl,
612 newreg = oldreg; 617 newreg = oldreg;
613 newreg = (newreg & ~0x1f) | 618 newreg = (newreg & ~0x1f) |
614 (31 - (value->value.integer.value[0] & 0x1f)); 619 (31 - (value->value.integer.value[0] & 0x1f));
615 newreg = (newreg & ~0x1f00) | 620 if (stereo)
616 ((31 - (value->value.integer.value[0] & 0x1f)) << 8); 621 newreg = (newreg & ~0x1f00) |
622 ((31 - (value->value.integer.value[1] & 0x1f)) << 8);
623 else
624 newreg = (newreg & ~0x1f00) | ((newreg & 0x1f) << 8);
617 change = newreg != oldreg; 625 change = newreg != oldreg;
618 if (change) 626 if (change)
619 oxygen_write_ac97(chip, codec, index, newreg); 627 oxygen_write_ac97(chip, codec, index, newreg);
@@ -673,7 +681,7 @@ static int ac97_fp_rec_volume_put(struct snd_kcontrol *ctl,
673 .private_value = ((codec) << 24) | ((invert) << 16) | \ 681 .private_value = ((codec) << 24) | ((invert) << 16) | \
674 ((bitnr) << 8) | (index), \ 682 ((bitnr) << 8) | (index), \
675 } 683 }
676#define AC97_VOLUME(xname, codec, index) { \ 684#define AC97_VOLUME(xname, codec, index, stereo) { \
677 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
678 .name = xname, \ 686 .name = xname, \
679 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 687 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
@@ -682,7 +690,7 @@ static int ac97_fp_rec_volume_put(struct snd_kcontrol *ctl,
682 .get = ac97_volume_get, \ 690 .get = ac97_volume_get, \
683 .put = ac97_volume_put, \ 691 .put = ac97_volume_put, \
684 .tlv = { .p = ac97_db_scale, }, \ 692 .tlv = { .p = ac97_db_scale, }, \
685 .private_value = ((codec) << 24) | (index), \ 693 .private_value = ((codec) << 24) | ((stereo) << 16) | (index), \
686 } 694 }
687 695
688static DECLARE_TLV_DB_SCALE(monitor_db_scale, -1000, 1000, 0); 696static DECLARE_TLV_DB_SCALE(monitor_db_scale, -1000, 1000, 0);
@@ -882,18 +890,18 @@ static const struct {
882}; 890};
883 891
884static const struct snd_kcontrol_new ac97_controls[] = { 892static const struct snd_kcontrol_new ac97_controls[] = {
885 AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC), 893 AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC, 0),
886 AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1), 894 AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1),
887 AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0), 895 AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0),
888 AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1), 896 AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1),
889 AC97_VOLUME("CD Capture Volume", 0, AC97_CD), 897 AC97_VOLUME("CD Capture Volume", 0, AC97_CD, 1),
890 AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1), 898 AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1),
891 AC97_VOLUME("Aux Capture Volume", 0, AC97_AUX), 899 AC97_VOLUME("Aux Capture Volume", 0, AC97_AUX, 1),
892 AC97_SWITCH("Aux Capture Switch", 0, AC97_AUX, 15, 1), 900 AC97_SWITCH("Aux Capture Switch", 0, AC97_AUX, 15, 1),
893}; 901};
894 902
895static const struct snd_kcontrol_new ac97_fp_controls[] = { 903static const struct snd_kcontrol_new ac97_fp_controls[] = {
896 AC97_VOLUME("Front Panel Playback Volume", 1, AC97_HEADPHONE), 904 AC97_VOLUME("Front Panel Playback Volume", 1, AC97_HEADPHONE, 1),
897 AC97_SWITCH("Front Panel Playback Switch", 1, AC97_HEADPHONE, 15, 1), 905 AC97_SWITCH("Front Panel Playback Switch", 1, AC97_HEADPHONE, 15, 1),
898 { 906 {
899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index bf971f7cfdc6..6ebcb6bdd712 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -635,6 +635,8 @@ static void xonar_d2_resume(struct oxygen *chip)
635 635
636static void xonar_d1_resume(struct oxygen *chip) 636static void xonar_d1_resume(struct oxygen *chip)
637{ 637{
638 oxygen_set_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC);
639 msleep(1);
638 cs43xx_init(chip); 640 cs43xx_init(chip);
639 xonar_enable_output(chip); 641 xonar_enable_output(chip);
640} 642}
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index d7b966e7c4cf..f977dba7cbd0 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -227,12 +227,9 @@ struct rme32 {
227}; 227};
228 228
229static struct pci_device_id snd_rme32_ids[] = { 229static struct pci_device_id snd_rme32_ids[] = {
230 {PCI_VENDOR_ID_XILINX_RME, PCI_DEVICE_ID_RME_DIGI32, 230 {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32), 0,},
231 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,}, 231 {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_8), 0,},
232 {PCI_VENDOR_ID_XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_8, 232 {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_PRO), 0,},
233 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,},
234 {PCI_VENDOR_ID_XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_PRO,
235 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,},
236 {0,} 233 {0,}
237}; 234};
238 235
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 55fb1c131f58..2ba5c0fd55db 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -232,14 +232,10 @@ struct rme96 {
232}; 232};
233 233
234static struct pci_device_id snd_rme96_ids[] = { 234static struct pci_device_id snd_rme96_ids[] = {
235 { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96, 235 { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96), 0, },
236 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, 236 { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8), 0, },
237 { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8, 237 { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO), 0, },
238 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, 238 { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST), 0, },
239 { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO,
240 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
241 { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST,
242 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
243 { 0, } 239 { 0, }
244}; 240};
245 241
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 7dc60ad4772e..1f6406c4534d 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -243,7 +243,7 @@ struct sonicvibes {
243}; 243};
244 244
245static struct pci_device_id snd_sonic_ids[] = { 245static struct pci_device_id snd_sonic_ids[] = {
246 { 0x5333, 0xca00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, 246 { PCI_VDEVICE(S3, 0xca00), 0, },
247 { 0, } 247 { 0, }
248}; 248};
249 249
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 949fcaf6b70e..acfa4760da49 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -402,9 +402,9 @@ struct via82xx {
402 402
403static struct pci_device_id snd_via82xx_ids[] = { 403static struct pci_device_id snd_via82xx_ids[] = {
404 /* 0x1106, 0x3058 */ 404 /* 0x1106, 0x3058 */
405 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ 405 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C686_5), TYPE_CARD_VIA686, }, /* 686A */
406 /* 0x1106, 0x3059 */ 406 /* 0x1106, 0x3059 */
407 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233_5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ 407 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8233_5), TYPE_CARD_VIA8233, }, /* VT8233 */
408 { 0, } 408 { 0, }
409}; 409};
410 410
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 0d54e3503c1e..47eb61561dfc 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -261,7 +261,7 @@ struct via82xx_modem {
261}; 261};
262 262
263static struct pci_device_id snd_via82xx_modem_ids[] = { 263static struct pci_device_id snd_via82xx_modem_ids[] = {
264 { 0x1106, 0x3068, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA82XX_MODEM, }, 264 { PCI_VDEVICE(VIA, 0x3068), TYPE_CARD_VIA82XX_MODEM, },
265 { 0, } 265 { 0, }
266}; 266};
267 267
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index 4af66661f9b0..e6b18b90d451 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -67,12 +67,12 @@ module_param_array(rear_switch, bool, NULL, 0444);
67MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); 67MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch");
68 68
69static struct pci_device_id snd_ymfpci_ids[] = { 69static struct pci_device_id snd_ymfpci_ids[] = {
70 { 0x1073, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF724 */ 70 { PCI_VDEVICE(YAMAHA, 0x0004), 0, }, /* YMF724 */
71 { 0x1073, 0x000d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF724F */ 71 { PCI_VDEVICE(YAMAHA, 0x000d), 0, }, /* YMF724F */
72 { 0x1073, 0x000a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF740 */ 72 { PCI_VDEVICE(YAMAHA, 0x000a), 0, }, /* YMF740 */
73 { 0x1073, 0x000c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF740C */ 73 { PCI_VDEVICE(YAMAHA, 0x000c), 0, }, /* YMF740C */
74 { 0x1073, 0x0010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF744 */ 74 { PCI_VDEVICE(YAMAHA, 0x0010), 0, }, /* YMF744 */
75 { 0x1073, 0x0012, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF754 */ 75 { PCI_VDEVICE(YAMAHA, 0x0012), 0, }, /* YMF754 */
76 { 0, } 76 { 0, }
77}; 77};
78 78
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index d28eeaceb857..49c4b2898aff 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -79,7 +79,7 @@ static const u16 wm8753_reg[] = {
79 0x0097, 0x0097, 0x0000, 0x0004, 79 0x0097, 0x0097, 0x0000, 0x0004,
80 0x0000, 0x0083, 0x0024, 0x01ba, 80 0x0000, 0x0083, 0x0024, 0x01ba,
81 0x0000, 0x0083, 0x0024, 0x01ba, 81 0x0000, 0x0083, 0x0024, 0x01ba,
82 0x0000, 0x0000 82 0x0000, 0x0000, 0x0000
83}; 83};
84 84
85/* codec private data */ 85/* codec private data */
@@ -1660,11 +1660,11 @@ static int wm8753_register(struct wm8753_priv *wm8753)
1660 codec->set_bias_level = wm8753_set_bias_level; 1660 codec->set_bias_level = wm8753_set_bias_level;
1661 codec->dai = wm8753_dai; 1661 codec->dai = wm8753_dai;
1662 codec->num_dai = 2; 1662 codec->num_dai = 2;
1663 codec->reg_cache_size = ARRAY_SIZE(wm8753->reg_cache); 1663 codec->reg_cache_size = ARRAY_SIZE(wm8753->reg_cache) + 1;
1664 codec->reg_cache = &wm8753->reg_cache; 1664 codec->reg_cache = &wm8753->reg_cache;
1665 codec->private_data = wm8753; 1665 codec->private_data = wm8753;
1666 1666
1667 memcpy(codec->reg_cache, wm8753_reg, sizeof(codec->reg_cache)); 1667 memcpy(codec->reg_cache, wm8753_reg, sizeof(wm8753->reg_cache));
1668 INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work); 1668 INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work);
1669 1669
1670 ret = wm8753_reset(codec); 1670 ret = wm8753_reset(codec);
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c
index c05f71803aa8..8c0fdf84aac3 100644
--- a/sound/soc/codecs/wm8988.c
+++ b/sound/soc/codecs/wm8988.c
@@ -1037,14 +1037,14 @@ static int __devinit wm8988_spi_probe(struct spi_device *spi)
1037 codec->control_data = spi; 1037 codec->control_data = spi;
1038 codec->dev = &spi->dev; 1038 codec->dev = &spi->dev;
1039 1039
1040 spi->dev.driver_data = wm8988; 1040 dev_set_drvdata(&spi->dev, wm8988);
1041 1041
1042 return wm8988_register(wm8988); 1042 return wm8988_register(wm8988);
1043} 1043}
1044 1044
1045static int __devexit wm8988_spi_remove(struct spi_device *spi) 1045static int __devexit wm8988_spi_remove(struct spi_device *spi)
1046{ 1046{
1047 struct wm8988_priv *wm8988 = spi->dev.driver_data; 1047 struct wm8988_priv *wm8988 = dev_get_drvdata(&spi->dev);
1048 1048
1049 wm8988_unregister(wm8988); 1049 wm8988_unregister(wm8988);
1050 1050
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 5dbebf82249c..8cb65ccad35f 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -33,7 +33,7 @@ config SND_SOC_MPC5200_I2S
33config SND_SOC_MPC5200_AC97 33config SND_SOC_MPC5200_AC97
34 tristate "Freescale MPC5200 PSC in AC97 mode driver" 34 tristate "Freescale MPC5200 PSC in AC97 mode driver"
35 depends on PPC_MPC52xx && PPC_BESTCOMM 35 depends on PPC_MPC52xx && PPC_BESTCOMM
36 select AC97_BUS 36 select SND_SOC_AC97_BUS
37 select SND_MPC52xx_DMA 37 select SND_MPC52xx_DMA
38 select PPC_BESTCOMM_GEN_BD 38 select PPC_BESTCOMM_GEN_BD
39 help 39 help
@@ -41,7 +41,7 @@ config SND_SOC_MPC5200_AC97
41 41
42config SND_MPC52xx_SOC_PCM030 42config SND_MPC52xx_SOC_PCM030
43 tristate "SoC AC97 Audio support for Phytec pcm030 and WM9712" 43 tristate "SoC AC97 Audio support for Phytec pcm030 and WM9712"
44 depends on PPC_MPC5200_SIMPLE && BROKEN 44 depends on PPC_MPC5200_SIMPLE
45 select SND_SOC_MPC5200_AC97 45 select SND_SOC_MPC5200_AC97
46 select SND_SOC_WM9712 46 select SND_SOC_WM9712
47 help 47 help
@@ -50,7 +50,7 @@ config SND_MPC52xx_SOC_PCM030
50 50
51config SND_MPC52xx_SOC_EFIKA 51config SND_MPC52xx_SOC_EFIKA
52 tristate "SoC AC97 Audio support for bbplan Efika and STAC9766" 52 tristate "SoC AC97 Audio support for bbplan Efika and STAC9766"
53 depends on PPC_EFIKA && BROKEN 53 depends on PPC_EFIKA
54 select SND_SOC_MPC5200_AC97 54 select SND_SOC_MPC5200_AC97
55 select SND_SOC_STAC9766 55 select SND_SOC_STAC9766
56 help 56 help
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
index efec33a1c5bd..f0a2d4071998 100644
--- a/sound/soc/fsl/mpc5200_dma.c
+++ b/sound/soc/fsl/mpc5200_dma.c
@@ -456,6 +456,7 @@ int mpc5200_audio_dma_create(struct of_device *op)
456 return -ENODEV; 456 return -ENODEV;
457 457
458 spin_lock_init(&psc_dma->lock); 458 spin_lock_init(&psc_dma->lock);
459 mutex_init(&psc_dma->mutex);
459 psc_dma->id = be32_to_cpu(*prop); 460 psc_dma->id = be32_to_cpu(*prop);
460 psc_dma->irq = irq; 461 psc_dma->irq = irq;
461 psc_dma->psc_regs = regs; 462 psc_dma->psc_regs = regs;
diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h
index 2000803f06a7..8d396bb9d9fe 100644
--- a/sound/soc/fsl/mpc5200_dma.h
+++ b/sound/soc/fsl/mpc5200_dma.h
@@ -55,6 +55,7 @@ struct psc_dma {
55 unsigned int irq; 55 unsigned int irq;
56 struct device *dev; 56 struct device *dev;
57 spinlock_t lock; 57 spinlock_t lock;
58 struct mutex mutex;
58 u32 sicr; 59 u32 sicr;
59 uint sysclk; 60 uint sysclk;
60 int imr; 61 int imr;
diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c
index 794a247b3eb5..7eb549985d49 100644
--- a/sound/soc/fsl/mpc5200_psc_ac97.c
+++ b/sound/soc/fsl/mpc5200_psc_ac97.c
@@ -34,13 +34,20 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
34 int status; 34 int status;
35 unsigned int val; 35 unsigned int val;
36 36
37 mutex_lock(&psc_dma->mutex);
38
37 /* Wait for command send status zero = ready */ 39 /* Wait for command send status zero = ready */
38 status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) & 40 status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) &
39 MPC52xx_PSC_SR_CMDSEND), 100, 0); 41 MPC52xx_PSC_SR_CMDSEND), 100, 0);
40 if (status == 0) { 42 if (status == 0) {
41 pr_err("timeout on ac97 bus (rdy)\n"); 43 pr_err("timeout on ac97 bus (rdy)\n");
44 mutex_unlock(&psc_dma->mutex);
42 return -ENODEV; 45 return -ENODEV;
43 } 46 }
47
48 /* Force clear the data valid bit */
49 in_be32(&psc_dma->psc_regs->ac97_data);
50
44 /* Send the read */ 51 /* Send the read */
45 out_be32(&psc_dma->psc_regs->ac97_cmd, (1<<31) | ((reg & 0x7f) << 24)); 52 out_be32(&psc_dma->psc_regs->ac97_cmd, (1<<31) | ((reg & 0x7f) << 24));
46 53
@@ -50,16 +57,19 @@ static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
50 if (status == 0) { 57 if (status == 0) {
51 pr_err("timeout on ac97 read (val) %x\n", 58 pr_err("timeout on ac97 read (val) %x\n",
52 in_be16(&psc_dma->psc_regs->sr_csr.status)); 59 in_be16(&psc_dma->psc_regs->sr_csr.status));
60 mutex_unlock(&psc_dma->mutex);
53 return -ENODEV; 61 return -ENODEV;
54 } 62 }
55 /* Get the data */ 63 /* Get the data */
56 val = in_be32(&psc_dma->psc_regs->ac97_data); 64 val = in_be32(&psc_dma->psc_regs->ac97_data);
57 if (((val >> 24) & 0x7f) != reg) { 65 if (((val >> 24) & 0x7f) != reg) {
58 pr_err("reg echo error on ac97 read\n"); 66 pr_err("reg echo error on ac97 read\n");
67 mutex_unlock(&psc_dma->mutex);
59 return -ENODEV; 68 return -ENODEV;
60 } 69 }
61 val = (val >> 8) & 0xffff; 70 val = (val >> 8) & 0xffff;
62 71
72 mutex_unlock(&psc_dma->mutex);
63 return (unsigned short) val; 73 return (unsigned short) val;
64} 74}
65 75
@@ -68,16 +78,21 @@ static void psc_ac97_write(struct snd_ac97 *ac97,
68{ 78{
69 int status; 79 int status;
70 80
81 mutex_lock(&psc_dma->mutex);
82
71 /* Wait for command status zero = ready */ 83 /* Wait for command status zero = ready */
72 status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) & 84 status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) &
73 MPC52xx_PSC_SR_CMDSEND), 100, 0); 85 MPC52xx_PSC_SR_CMDSEND), 100, 0);
74 if (status == 0) { 86 if (status == 0) {
75 pr_err("timeout on ac97 bus (write)\n"); 87 pr_err("timeout on ac97 bus (write)\n");
76 return; 88 goto out;
77 } 89 }
78 /* Write data */ 90 /* Write data */
79 out_be32(&psc_dma->psc_regs->ac97_cmd, 91 out_be32(&psc_dma->psc_regs->ac97_cmd,
80 ((reg & 0x7f) << 24) | (val << 8)); 92 ((reg & 0x7f) << 24) | (val << 8));
93
94 out:
95 mutex_unlock(&psc_dma->mutex);
81} 96}
82 97
83static void psc_ac97_warm_reset(struct snd_ac97 *ac97) 98static void psc_ac97_warm_reset(struct snd_ac97 *ac97)
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 6454e15f7d28..84a1950880eb 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -216,12 +216,15 @@ static snd_pcm_uframes_t omap_pcm_pointer(struct snd_pcm_substream *substream)
216 dma_addr_t ptr; 216 dma_addr_t ptr;
217 snd_pcm_uframes_t offset; 217 snd_pcm_uframes_t offset;
218 218
219 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 219 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
220 ptr = omap_get_dma_src_pos(prtd->dma_ch);
221 else
222 ptr = omap_get_dma_dst_pos(prtd->dma_ch); 220 ptr = omap_get_dma_dst_pos(prtd->dma_ch);
221 offset = bytes_to_frames(runtime, ptr - runtime->dma_addr);
222 } else if (!(cpu_is_omap1510())) {
223 ptr = omap_get_dma_src_pos(prtd->dma_ch);
224 offset = bytes_to_frames(runtime, ptr - runtime->dma_addr);
225 } else
226 offset = prtd->period_index * runtime->period_size;
223 227
224 offset = bytes_to_frames(runtime, ptr - runtime->dma_addr);
225 if (offset >= runtime->buffer_size) 228 if (offset >= runtime->buffer_size)
226 offset = 0; 229 offset = 0;
227 230
diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c
index 4743e262895d..6b8f655d1ad8 100644
--- a/sound/soc/pxa/pxa2xx-i2s.c
+++ b/sound/soc/pxa/pxa2xx-i2s.c
@@ -167,6 +167,7 @@ static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream,
167 167
168 BUG_ON(IS_ERR(clk_i2s)); 168 BUG_ON(IS_ERR(clk_i2s));
169 clk_enable(clk_i2s); 169 clk_enable(clk_i2s);
170 dai->private_data = dai;
170 pxa_i2s_wait(); 171 pxa_i2s_wait();
171 172
172 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 173 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
@@ -255,7 +256,10 @@ static void pxa2xx_i2s_shutdown(struct snd_pcm_substream *substream,
255 if ((SACR1 & (SACR1_DREC | SACR1_DRPL)) == (SACR1_DREC | SACR1_DRPL)) { 256 if ((SACR1 & (SACR1_DREC | SACR1_DRPL)) == (SACR1_DREC | SACR1_DRPL)) {
256 SACR0 &= ~SACR0_ENB; 257 SACR0 &= ~SACR0_ENB;
257 pxa_i2s_wait(); 258 pxa_i2s_wait();
258 clk_disable(clk_i2s); 259 if (dai->private_data != NULL) {
260 clk_disable(clk_i2s);
261 dai->private_data = NULL;
262 }
259 } 263 }
260} 264}
261 265
@@ -336,6 +340,7 @@ static int pxa2xx_i2s_probe(struct platform_device *dev)
336 return PTR_ERR(clk_i2s); 340 return PTR_ERR(clk_i2s);
337 341
338 pxa_i2s_dai.dev = &dev->dev; 342 pxa_i2s_dai.dev = &dev->dev;
343 pxa_i2s_dai.private_data = NULL;
339 ret = snd_soc_register_dai(&pxa_i2s_dai); 344 ret = snd_soc_register_dai(&pxa_i2s_dai);
340 if (ret != 0) 345 if (ret != 0)
341 clk_put(clk_i2s); 346 clk_put(clk_i2s);
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 12522e6913d9..a41f8b127f49 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -10,6 +10,8 @@
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/kdev_t.h>
14#include <linux/major.h>
13#include <sound/core.h> 15#include <sound/core.h>
14 16
15#ifdef CONFIG_SOUND_OSS_CORE 17#ifdef CONFIG_SOUND_OSS_CORE
@@ -29,6 +31,8 @@ MODULE_LICENSE("GPL");
29 31
30static char *sound_nodename(struct device *dev) 32static char *sound_nodename(struct device *dev)
31{ 33{
34 if (MAJOR(dev->devt) == SOUND_MAJOR)
35 return NULL;
32 return kasprintf(GFP_KERNEL, "snd/%s", dev_name(dev)); 36 return kasprintf(GFP_KERNEL, "snd/%s", dev_name(dev));
33} 37}
34 38
@@ -104,7 +108,6 @@ module_exit(cleanup_soundcore);
104#include <linux/types.h> 108#include <linux/types.h>
105#include <linux/kernel.h> 109#include <linux/kernel.h>
106#include <linux/sound.h> 110#include <linux/sound.h>
107#include <linux/major.h>
108#include <linux/kmod.h> 111#include <linux/kmod.h>
109 112
110#define SOUND_STEP 16 113#define SOUND_STEP 16
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 0e5db719de24..de38108f0b28 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -35,7 +35,7 @@
35#include "input.h" 35#include "input.h"
36 36
37MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 37MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
38MODULE_DESCRIPTION("caiaq USB audio, version 1.3.17"); 38MODULE_DESCRIPTION("caiaq USB audio, version 1.3.18");
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 40MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
41 "{Native Instruments, RigKontrol3}," 41 "{Native Instruments, RigKontrol3},"
@@ -349,7 +349,9 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
349 log("Unable to set up control system (ret=%d)\n", ret); 349 log("Unable to set up control system (ret=%d)\n", ret);
350} 350}
351 351
352static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) 352static int create_card(struct usb_device *usb_dev,
353 struct usb_interface *intf,
354 struct snd_card **cardp)
353{ 355{
354 int devnum; 356 int devnum;
355 int err; 357 int err;
@@ -374,7 +376,7 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
374 dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), 376 dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
375 le16_to_cpu(usb_dev->descriptor.idProduct)); 377 le16_to_cpu(usb_dev->descriptor.idProduct));
376 spin_lock_init(&dev->spinlock); 378 spin_lock_init(&dev->spinlock);
377 snd_card_set_dev(card, &usb_dev->dev); 379 snd_card_set_dev(card, &intf->dev);
378 380
379 *cardp = card; 381 *cardp = card;
380 return 0; 382 return 0;
@@ -461,7 +463,7 @@ static int __devinit snd_probe(struct usb_interface *intf,
461 struct snd_card *card; 463 struct snd_card *card;
462 struct usb_device *device = interface_to_usbdev(intf); 464 struct usb_device *device = interface_to_usbdev(intf);
463 465
464 ret = create_card(device, &card); 466 ret = create_card(device, intf, &card);
465 467
466 if (ret < 0) 468 if (ret < 0)
467 return ret; 469 return ret;
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index c7b902358b7b..44b9cdc8a83b 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2661,7 +2661,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2661 struct usb_interface_descriptor *altsd; 2661 struct usb_interface_descriptor *altsd;
2662 int i, altno, err, stream; 2662 int i, altno, err, stream;
2663 int format; 2663 int format;
2664 struct audioformat *fp; 2664 struct audioformat *fp = NULL;
2665 unsigned char *fmt, *csep; 2665 unsigned char *fmt, *csep;
2666 int num; 2666 int num;
2667 2667
@@ -2734,6 +2734,18 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2734 continue; 2734 continue;
2735 } 2735 }
2736 2736
2737 /*
2738 * Blue Microphones workaround: The last altsetting is identical
2739 * with the previous one, except for a larger packet size, but
2740 * is actually a mislabeled two-channel setting; ignore it.
2741 */
2742 if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 &&
2743 fp && fp->altsetting == 1 && fp->channels == 1 &&
2744 fp->format == SNDRV_PCM_FORMAT_S16_LE &&
2745 le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) ==
2746 fp->maxpacksize * 2)
2747 continue;
2748
2737 csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT); 2749 csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT);
2738 /* Creamware Noah has this descriptor after the 2nd endpoint */ 2750 /* Creamware Noah has this descriptor after the 2nd endpoint */
2739 if (!csep && altsd->bNumEndpoints >= 2) 2751 if (!csep && altsd->bNumEndpoints >= 2)
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index a5aae9d67f31..fd44946ce4b3 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -514,7 +514,6 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
514 US122L(card)->chip.dev->bus->busnum, 514 US122L(card)->chip.dev->bus->busnum,
515 US122L(card)->chip.dev->devnum 515 US122L(card)->chip.dev->devnum
516 ); 516 );
517 snd_card_set_dev(card, &device->dev);
518 *cardp = card; 517 *cardp = card;
519 return 0; 518 return 0;
520} 519}
@@ -531,6 +530,7 @@ static int us122l_usb_probe(struct usb_interface *intf,
531 if (err < 0) 530 if (err < 0)
532 return err; 531 return err;
533 532
533 snd_card_set_dev(card, &intf->dev);
534 if (!us122l_create_card(card)) { 534 if (!us122l_create_card(card)) {
535 snd_card_free(card); 535 snd_card_free(card);
536 return -EINVAL; 536 return -EINVAL;
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index 5ce0da23ee96..cb4bb8373ca2 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -364,7 +364,6 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
364 0,//us428(card)->usbmidi.ifnum, 364 0,//us428(card)->usbmidi.ifnum,
365 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum 365 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum
366 ); 366 );
367 snd_card_set_dev(card, &device->dev);
368 *cardp = card; 367 *cardp = card;
369 return 0; 368 return 0;
370} 369}
@@ -388,6 +387,7 @@ static int usX2Y_usb_probe(struct usb_device *device,
388 err = usX2Y_create_card(device, &card); 387 err = usX2Y_create_card(device, &card);
389 if (err < 0) 388 if (err < 0)
390 return err; 389 return err;
390 snd_card_set_dev(card, &intf->dev);
391 if ((err = usX2Y_hwdep_new(card, device)) < 0 || 391 if ((err = usX2Y_hwdep_new(card, device)) < 0 ||
392 (err = snd_card_register(card)) < 0) { 392 (err = snd_card_register(card)) < 0) {
393 snd_card_free(card); 393 snd_card_free(card);
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index dd1ab6177840..9efd27f6b52f 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -296,9 +296,10 @@ static void usX2Y_error_urb_status(struct usX2Ydev *usX2Y,
296static void usX2Y_error_sequence(struct usX2Ydev *usX2Y, 296static void usX2Y_error_sequence(struct usX2Ydev *usX2Y,
297 struct snd_usX2Y_substream *subs, struct urb *urb) 297 struct snd_usX2Y_substream *subs, struct urb *urb)
298{ 298{
299 snd_printk(KERN_ERR "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" 299 snd_printk(KERN_ERR
300 KERN_ERR "Most propably some urb of usb-frame %i is still missing.\n" 300"Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n"
301 KERN_ERR "Cause could be too long delays in usb-hcd interrupt handling.\n", 301"Most propably some urb of usb-frame %i is still missing.\n"
302"Cause could be too long delays in usb-hcd interrupt handling.\n",
302 usb_get_current_frame_number(usX2Y->chip.dev), 303 usb_get_current_frame_number(usX2Y->chip.dev),
303 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", 304 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out",
304 usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); 305 usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame);
diff --git a/tools/perf/CREDITS b/tools/perf/CREDITS
new file mode 100644
index 000000000000..c2ddcb3acbd0
--- /dev/null
+++ b/tools/perf/CREDITS
@@ -0,0 +1,30 @@
1Most of the infrastructure that 'perf' uses here has been reused
2from the Git project, as of version:
3
4 66996ec: Sync with 1.6.2.4
5
6Here is an (incomplete!) list of main contributors to those files
7in util/* and elsewhere:
8
9 Alex Riesen
10 Christian Couder
11 Dmitry Potapov
12 Jeff King
13 Johannes Schindelin
14 Johannes Sixt
15 Junio C Hamano
16 Linus Torvalds
17 Matthias Kestenholz
18 Michal Ostrowski
19 Miklos Vajna
20 Petr Baudis
21 Pierre Habouzit
22 René Scharfe
23 Samuel Tardieu
24 Shawn O. Pearce
25 Steffen Prohaska
26 Steve Haslam
27
28Thanks guys!
29
30The full history of the files can be found in the upstream Git commits.
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 52d3fc6846a9..8aa3f8c88707 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -13,13 +13,25 @@ SYNOPSIS
13DESCRIPTION 13DESCRIPTION
14----------- 14-----------
15This command displays the performance counter profile information recorded 15This command displays the performance counter profile information recorded
16via perf report. 16via perf record.
17 17
18OPTIONS 18OPTIONS
19------- 19-------
20-i:: 20-i::
21--input=:: 21--input=::
22 Input file name. (default: perf.data) 22 Input file name. (default: perf.data)
23-d::
24--dsos=::
25 Only consider symbols in these dsos. CSV that understands
26 file://filename entries.
27-C::
28--comms=::
29 Only consider symbols in these comms. CSV that understands
30 file://filename entries.
31-S::
32--symbols=::
33 Only consider these symbols. CSV that understands
34 file://filename entries.
23 35
24SEE ALSO 36SEE ALSO
25-------- 37--------
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index c368a72721d7..0d74346d21ab 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -8,8 +8,8 @@ perf-stat - Run a command and gather performance counter statistics
8SYNOPSIS 8SYNOPSIS
9-------- 9--------
10[verse] 10[verse]
11'perf stat' [-e <EVENT> | --event=EVENT] [-l] [-a] <command> 11'perf stat' [-e <EVENT> | --event=EVENT] [-S] [-a] <command>
12'perf stat' [-e <EVENT> | --event=EVENT] [-l] [-a] -- <command> [<options>] 12'perf stat' [-e <EVENT> | --event=EVENT] [-S] [-a] -- <command> [<options>]
13 13
14DESCRIPTION 14DESCRIPTION
15----------- 15-----------
@@ -40,7 +40,7 @@ OPTIONS
40-a:: 40-a::
41 system-wide collection 41 system-wide collection
42 42
43-l:: 43-S::
44 scale counter values 44 scale counter values
45 45
46EXAMPLES 46EXAMPLES
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 36d7eef49913..7822b3d6baca 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -164,7 +164,7 @@ endif
164 164
165# CFLAGS and LDFLAGS are for the users to override from the command line. 165# CFLAGS and LDFLAGS are for the users to override from the command line.
166 166
167CFLAGS = $(M64) -ggdb3 -Wall -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -Werror -O6 167CFLAGS = $(M64) -ggdb3 -Wall -Wextra -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -Werror -O6
168LDFLAGS = -lpthread -lrt -lelf -lm 168LDFLAGS = -lpthread -lrt -lelf -lm
169ALL_CFLAGS = $(CFLAGS) 169ALL_CFLAGS = $(CFLAGS)
170ALL_LDFLAGS = $(LDFLAGS) 170ALL_LDFLAGS = $(LDFLAGS)
@@ -223,7 +223,7 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
223# Those must not be GNU-specific; they are shared with perl/ which may 223# Those must not be GNU-specific; they are shared with perl/ which may
224# be built by a different compiler. (Note that this is an artifact now 224# be built by a different compiler. (Note that this is an artifact now
225# but it still might be nice to keep that distinction.) 225# but it still might be nice to keep that distinction.)
226BASIC_CFLAGS = 226BASIC_CFLAGS = -Iutil/include
227BASIC_LDFLAGS = 227BASIC_LDFLAGS =
228 228
229# Guard against environment variables 229# Guard against environment variables
@@ -289,10 +289,11 @@ export PERL_PATH
289LIB_FILE=libperf.a 289LIB_FILE=libperf.a
290 290
291LIB_H += ../../include/linux/perf_counter.h 291LIB_H += ../../include/linux/perf_counter.h
292LIB_H += ../../include/linux/rbtree.h
293LIB_H += ../../include/linux/list.h
294LIB_H += util/include/linux/list.h
292LIB_H += perf.h 295LIB_H += perf.h
293LIB_H += types.h 296LIB_H += util/types.h
294LIB_H += util/list.h
295LIB_H += util/rbtree.h
296LIB_H += util/levenshtein.h 297LIB_H += util/levenshtein.h
297LIB_H += util/parse-options.h 298LIB_H += util/parse-options.h
298LIB_H += util/parse-events.h 299LIB_H += util/parse-events.h
@@ -301,9 +302,11 @@ LIB_H += util/util.h
301LIB_H += util/help.h 302LIB_H += util/help.h
302LIB_H += util/strbuf.h 303LIB_H += util/strbuf.h
303LIB_H += util/string.h 304LIB_H += util/string.h
305LIB_H += util/strlist.h
304LIB_H += util/run-command.h 306LIB_H += util/run-command.h
305LIB_H += util/sigchain.h 307LIB_H += util/sigchain.h
306LIB_H += util/symbol.h 308LIB_H += util/symbol.h
309LIB_H += util/module.h
307LIB_H += util/color.h 310LIB_H += util/color.h
308 311
309LIB_OBJS += util/abspath.o 312LIB_OBJS += util/abspath.o
@@ -322,12 +325,16 @@ LIB_OBJS += util/run-command.o
322LIB_OBJS += util/quote.o 325LIB_OBJS += util/quote.o
323LIB_OBJS += util/strbuf.o 326LIB_OBJS += util/strbuf.o
324LIB_OBJS += util/string.o 327LIB_OBJS += util/string.o
328LIB_OBJS += util/strlist.o
325LIB_OBJS += util/usage.o 329LIB_OBJS += util/usage.o
326LIB_OBJS += util/wrapper.o 330LIB_OBJS += util/wrapper.o
327LIB_OBJS += util/sigchain.o 331LIB_OBJS += util/sigchain.o
328LIB_OBJS += util/symbol.o 332LIB_OBJS += util/symbol.o
333LIB_OBJS += util/module.o
329LIB_OBJS += util/color.o 334LIB_OBJS += util/color.o
330LIB_OBJS += util/pager.o 335LIB_OBJS += util/pager.o
336LIB_OBJS += util/header.o
337LIB_OBJS += util/callchain.o
331 338
332BUILTIN_OBJS += builtin-annotate.o 339BUILTIN_OBJS += builtin-annotate.o
333BUILTIN_OBJS += builtin-help.o 340BUILTIN_OBJS += builtin-help.o
@@ -377,12 +384,6 @@ ifndef CC_LD_DYNPATH
377 endif 384 endif
378endif 385endif
379 386
380ifdef ZLIB_PATH
381 BASIC_CFLAGS += -I$(ZLIB_PATH)/include
382 EXTLIBS += -L$(ZLIB_PATH)/$(lib) $(CC_LD_DYNPATH)$(ZLIB_PATH)/$(lib)
383endif
384EXTLIBS += -lz
385
386ifdef NEEDS_SOCKET 387ifdef NEEDS_SOCKET
387 EXTLIBS += -lsocket 388 EXTLIBS += -lsocket
388endif 389endif
@@ -693,6 +694,9 @@ builtin-init-db.o: builtin-init-db.c PERF-CFLAGS
693util/config.o: util/config.c PERF-CFLAGS 694util/config.o: util/config.c PERF-CFLAGS
694 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 695 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
695 696
697util/rbtree.o: ../../lib/rbtree.c PERF-CFLAGS
698 $(QUIET_CC)$(CC) -o util/rbtree.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
699
696perf-%$X: %.o $(PERFLIBS) 700perf-%$X: %.o $(PERFLIBS)
697 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) 701 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
698 702
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 7e58e3ad1508..5f9eefecc574 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -10,9 +10,9 @@
10#include "util/util.h" 10#include "util/util.h"
11 11
12#include "util/color.h" 12#include "util/color.h"
13#include "util/list.h" 13#include <linux/list.h>
14#include "util/cache.h" 14#include "util/cache.h"
15#include "util/rbtree.h" 15#include <linux/rbtree.h>
16#include "util/symbol.h" 16#include "util/symbol.h"
17#include "util/string.h" 17#include "util/string.h"
18 18
@@ -25,10 +25,6 @@
25#define SHOW_USER 2 25#define SHOW_USER 2
26#define SHOW_HV 4 26#define SHOW_HV 4
27 27
28#define MIN_GREEN 0.5
29#define MIN_RED 5.0
30
31
32static char const *input_name = "perf.data"; 28static char const *input_name = "perf.data";
33static char *vmlinux = "vmlinux"; 29static char *vmlinux = "vmlinux";
34 30
@@ -43,6 +39,10 @@ static int dump_trace = 0;
43 39
44static int verbose; 40static int verbose;
45 41
42static int modules;
43
44static int full_paths;
45
46static int print_line; 46static int print_line;
47 47
48static unsigned long page_size; 48static unsigned long page_size;
@@ -160,7 +160,7 @@ static void dsos__fprintf(FILE *fp)
160 160
161static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip) 161static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
162{ 162{
163 return dso__find_symbol(kernel_dso, ip); 163 return dso__find_symbol(dso, ip);
164} 164}
165 165
166static int load_kernel(void) 166static int load_kernel(void)
@@ -171,8 +171,8 @@ static int load_kernel(void)
171 if (!kernel_dso) 171 if (!kernel_dso)
172 return -1; 172 return -1;
173 173
174 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose); 174 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
175 if (err) { 175 if (err <= 0) {
176 dso__delete(kernel_dso); 176 dso__delete(kernel_dso);
177 kernel_dso = NULL; 177 kernel_dso = NULL;
178 } else 178 } else
@@ -203,7 +203,7 @@ static u64 map__map_ip(struct map *map, u64 ip)
203 return ip - map->start + map->pgoff; 203 return ip - map->start + map->pgoff;
204} 204}
205 205
206static u64 vdso__map_ip(struct map *map, u64 ip) 206static u64 vdso__map_ip(struct map *map __used, u64 ip)
207{ 207{
208 return ip; 208 return ip;
209} 209}
@@ -600,7 +600,7 @@ static LIST_HEAD(hist_entry__sort_list);
600 600
601static int sort_dimension__add(char *tok) 601static int sort_dimension__add(char *tok)
602{ 602{
603 int i; 603 unsigned int i;
604 604
605 for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) { 605 for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) {
606 struct sort_dimension *sd = &sort_dimensions[i]; 606 struct sort_dimension *sd = &sort_dimensions[i];
@@ -855,7 +855,7 @@ static unsigned long total = 0,
855 total_unknown = 0; 855 total_unknown = 0;
856 856
857static int 857static int
858process_overflow_event(event_t *event, unsigned long offset, unsigned long head) 858process_sample_event(event_t *event, unsigned long offset, unsigned long head)
859{ 859{
860 char level; 860 char level;
861 int show = 0; 861 int show = 0;
@@ -1013,10 +1013,10 @@ process_period_event(event_t *event, unsigned long offset, unsigned long head)
1013static int 1013static int
1014process_event(event_t *event, unsigned long offset, unsigned long head) 1014process_event(event_t *event, unsigned long offset, unsigned long head)
1015{ 1015{
1016 if (event->header.misc & PERF_EVENT_MISC_OVERFLOW)
1017 return process_overflow_event(event, offset, head);
1018
1019 switch (event->header.type) { 1016 switch (event->header.type) {
1017 case PERF_EVENT_SAMPLE:
1018 return process_sample_event(event, offset, head);
1019
1020 case PERF_EVENT_MMAP: 1020 case PERF_EVENT_MMAP:
1021 return process_mmap_event(event, offset, head); 1021 return process_mmap_event(event, offset, head);
1022 1022
@@ -1043,24 +1043,6 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
1043 return 0; 1043 return 0;
1044} 1044}
1045 1045
1046static char *get_color(double percent)
1047{
1048 char *color = PERF_COLOR_NORMAL;
1049
1050 /*
1051 * We color high-overhead entries in red, mid-overhead
1052 * entries in green - and keep the low overhead places
1053 * normal:
1054 */
1055 if (percent >= MIN_RED)
1056 color = PERF_COLOR_RED;
1057 else {
1058 if (percent > MIN_GREEN)
1059 color = PERF_COLOR_GREEN;
1060 }
1061 return color;
1062}
1063
1064static int 1046static int
1065parse_line(FILE *file, struct symbol *sym, u64 start, u64 len) 1047parse_line(FILE *file, struct symbol *sym, u64 start, u64 len)
1066{ 1048{
@@ -1069,7 +1051,7 @@ parse_line(FILE *file, struct symbol *sym, u64 start, u64 len)
1069 static const char *prev_color; 1051 static const char *prev_color;
1070 unsigned int offset; 1052 unsigned int offset;
1071 size_t line_len; 1053 size_t line_len;
1072 u64 line_ip; 1054 s64 line_ip;
1073 int ret; 1055 int ret;
1074 char *c; 1056 char *c;
1075 1057
@@ -1122,7 +1104,7 @@ parse_line(FILE *file, struct symbol *sym, u64 start, u64 len)
1122 } else if (sym->hist_sum) 1104 } else if (sym->hist_sum)
1123 percent = 100.0 * hits / sym->hist_sum; 1105 percent = 100.0 * hits / sym->hist_sum;
1124 1106
1125 color = get_color(percent); 1107 color = get_percent_color(percent);
1126 1108
1127 /* 1109 /*
1128 * Also color the filename and line if needed, with 1110 * Also color the filename and line if needed, with
@@ -1258,7 +1240,7 @@ static void print_summary(char *filename)
1258 1240
1259 sym_ext = rb_entry(node, struct sym_ext, node); 1241 sym_ext = rb_entry(node, struct sym_ext, node);
1260 percent = sym_ext->percent; 1242 percent = sym_ext->percent;
1261 color = get_color(percent); 1243 color = get_percent_color(percent);
1262 path = sym_ext->path; 1244 path = sym_ext->path;
1263 1245
1264 color_fprintf(stdout, color, " %7.2f %s", percent, path); 1246 color_fprintf(stdout, color, " %7.2f %s", percent, path);
@@ -1268,19 +1250,25 @@ static void print_summary(char *filename)
1268 1250
1269static void annotate_sym(struct dso *dso, struct symbol *sym) 1251static void annotate_sym(struct dso *dso, struct symbol *sym)
1270{ 1252{
1271 char *filename = dso->name; 1253 char *filename = dso->name, *d_filename;
1272 u64 start, end, len; 1254 u64 start, end, len;
1273 char command[PATH_MAX*2]; 1255 char command[PATH_MAX*2];
1274 FILE *file; 1256 FILE *file;
1275 1257
1276 if (!filename) 1258 if (!filename)
1277 return; 1259 return;
1278 if (dso == kernel_dso) 1260 if (sym->module)
1261 filename = sym->module->path;
1262 else if (dso == kernel_dso)
1279 filename = vmlinux; 1263 filename = vmlinux;
1280 1264
1281 start = sym->obj_start; 1265 start = sym->obj_start;
1282 if (!start) 1266 if (!start)
1283 start = sym->start; 1267 start = sym->start;
1268 if (full_paths)
1269 d_filename = filename;
1270 else
1271 d_filename = basename(filename);
1284 1272
1285 end = start + sym->end - sym->start + 1; 1273 end = start + sym->end - sym->start + 1;
1286 len = sym->end - sym->start; 1274 len = sym->end - sym->start;
@@ -1291,13 +1279,14 @@ static void annotate_sym(struct dso *dso, struct symbol *sym)
1291 } 1279 }
1292 1280
1293 printf("\n\n------------------------------------------------\n"); 1281 printf("\n\n------------------------------------------------\n");
1294 printf(" Percent | Source code & Disassembly of %s\n", filename); 1282 printf(" Percent | Source code & Disassembly of %s\n", d_filename);
1295 printf("------------------------------------------------\n"); 1283 printf("------------------------------------------------\n");
1296 1284
1297 if (verbose >= 2) 1285 if (verbose >= 2)
1298 printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->name, sym, sym->name); 1286 printf("annotating [%p] %30s : [%p] %30s\n", dso, dso->name, sym, sym->name);
1299 1287
1300 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s", (u64)start, (u64)end, filename); 1288 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s|grep -v %s",
1289 (u64)start, (u64)end, filename, filename);
1301 1290
1302 if (verbose >= 3) 1291 if (verbose >= 3)
1303 printf("doing: %s\n", command); 1292 printf("doing: %s\n", command);
@@ -1428,7 +1417,7 @@ more:
1428 1417
1429 head += size; 1418 head += size;
1430 1419
1431 if (offset + head < stat.st_size) 1420 if (offset + head < (unsigned long)stat.st_size)
1432 goto more; 1421 goto more;
1433 1422
1434 rc = EXIT_SUCCESS; 1423 rc = EXIT_SUCCESS;
@@ -1472,8 +1461,12 @@ static const struct option options[] = {
1472 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 1461 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1473 "dump raw trace in ASCII"), 1462 "dump raw trace in ASCII"),
1474 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), 1463 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
1464 OPT_BOOLEAN('m', "modules", &modules,
1465 "load module symbols - WARNING: use only with -k and LIVE kernel"),
1475 OPT_BOOLEAN('l', "print-line", &print_line, 1466 OPT_BOOLEAN('l', "print-line", &print_line,
1476 "print matching source lines (may be slow)"), 1467 "print matching source lines (may be slow)"),
1468 OPT_BOOLEAN('P', "full-paths", &full_paths,
1469 "Don't shorten the displayed pathnames"),
1477 OPT_END() 1470 OPT_END()
1478}; 1471};
1479 1472
@@ -1492,7 +1485,7 @@ static void setup_sorting(void)
1492 free(str); 1485 free(str);
1493} 1486}
1494 1487
1495int cmd_annotate(int argc, const char **argv, const char *prefix) 1488int cmd_annotate(int argc, const char **argv, const char *prefix __used)
1496{ 1489{
1497 symbol__init(); 1490 symbol__init();
1498 1491
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 0f32dc3f3c4c..2599d86a733b 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Builtin help command 4 * Builtin help command
5 */ 5 */
6#include "perf.h"
6#include "util/cache.h" 7#include "util/cache.h"
7#include "builtin.h" 8#include "builtin.h"
8#include "util/exec_cmd.h" 9#include "util/exec_cmd.h"
@@ -277,7 +278,7 @@ static struct cmdnames main_cmds, other_cmds;
277 278
278void list_common_cmds_help(void) 279void list_common_cmds_help(void)
279{ 280{
280 int i, longest = 0; 281 unsigned int i, longest = 0;
281 282
282 for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { 283 for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
283 if (longest < strlen(common_cmds[i].name)) 284 if (longest < strlen(common_cmds[i].name))
@@ -415,9 +416,10 @@ static void show_html_page(const char *perf_cmd)
415 open_html(page_path.buf); 416 open_html(page_path.buf);
416} 417}
417 418
418int cmd_help(int argc, const char **argv, const char *prefix) 419int cmd_help(int argc, const char **argv, const char *prefix __used)
419{ 420{
420 const char *alias; 421 const char *alias;
422
421 load_command_list("perf-", &main_cmds, &other_cmds); 423 load_command_list("perf-", &main_cmds, &other_cmds);
422 424
423 perf_config(perf_help_config, NULL); 425 perf_config(perf_help_config, NULL);
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index fe60e37c96ef..f990fa8a35c9 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -13,7 +13,7 @@
13#include "util/parse-options.h" 13#include "util/parse-options.h"
14#include "util/parse-events.h" 14#include "util/parse-events.h"
15 15
16int cmd_list(int argc, const char **argv, const char *prefix) 16int cmd_list(int argc __used, const char **argv __used, const char *prefix __used)
17{ 17{
18 print_events(); 18 print_events();
19 return 0; 19 return 0;
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d7ebbd757543..4ef78a5e6f32 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -14,6 +14,8 @@
14#include "util/parse-events.h" 14#include "util/parse-events.h"
15#include "util/string.h" 15#include "util/string.h"
16 16
17#include "util/header.h"
18
17#include <unistd.h> 19#include <unistd.h>
18#include <sched.h> 20#include <sched.h>
19 21
@@ -39,6 +41,8 @@ static int force = 0;
39static int append_file = 0; 41static int append_file = 0;
40static int call_graph = 0; 42static int call_graph = 0;
41static int verbose = 0; 43static int verbose = 0;
44static int inherit_stat = 0;
45static int no_samples = 0;
42 46
43static long samples; 47static long samples;
44static struct timeval last_read; 48static struct timeval last_read;
@@ -52,7 +56,8 @@ static int nr_poll;
52static int nr_cpu; 56static int nr_cpu;
53 57
54static int file_new = 1; 58static int file_new = 1;
55static struct perf_file_header file_header; 59
60struct perf_header *header;
56 61
57struct mmap_event { 62struct mmap_event {
58 struct perf_event_header header; 63 struct perf_event_header header;
@@ -289,7 +294,7 @@ static void pid_synthesize_mmap_samples(pid_t pid)
289 while (1) { 294 while (1) {
290 char bf[BUFSIZ], *pbf = bf; 295 char bf[BUFSIZ], *pbf = bf;
291 struct mmap_event mmap_ev = { 296 struct mmap_event mmap_ev = {
292 .header.type = PERF_EVENT_MMAP, 297 .header = { .type = PERF_EVENT_MMAP },
293 }; 298 };
294 int n; 299 int n;
295 size_t size; 300 size_t size;
@@ -306,12 +311,11 @@ static void pid_synthesize_mmap_samples(pid_t pid)
306 continue; 311 continue;
307 pbf += n + 3; 312 pbf += n + 3;
308 if (*pbf == 'x') { /* vm_exec */ 313 if (*pbf == 'x') { /* vm_exec */
309 char *execname = strrchr(bf, ' '); 314 char *execname = strchr(bf, '/');
310 315
311 if (execname == NULL || execname[1] != '/') 316 if (execname == NULL)
312 continue; 317 continue;
313 318
314 execname += 1;
315 size = strlen(execname); 319 size = strlen(execname);
316 execname[size - 1] = '\0'; /* Remove \n */ 320 execname[size - 1] = '\0'; /* Remove \n */
317 memcpy(mmap_ev.filename, execname, size); 321 memcpy(mmap_ev.filename, execname, size);
@@ -329,7 +333,7 @@ static void pid_synthesize_mmap_samples(pid_t pid)
329 fclose(fp); 333 fclose(fp);
330} 334}
331 335
332static void synthesize_samples(void) 336static void synthesize_all(void)
333{ 337{
334 DIR *proc; 338 DIR *proc;
335 struct dirent dirent, *next; 339 struct dirent dirent, *next;
@@ -353,10 +357,35 @@ static void synthesize_samples(void)
353 357
354static int group_fd; 358static int group_fd;
355 359
360static struct perf_header_attr *get_header_attr(struct perf_counter_attr *a, int nr)
361{
362 struct perf_header_attr *h_attr;
363
364 if (nr < header->attrs) {
365 h_attr = header->attr[nr];
366 } else {
367 h_attr = perf_header_attr__new(a);
368 perf_header__add_attr(header, h_attr);
369 }
370
371 return h_attr;
372}
373
356static void create_counter(int counter, int cpu, pid_t pid) 374static void create_counter(int counter, int cpu, pid_t pid)
357{ 375{
358 struct perf_counter_attr *attr = attrs + counter; 376 struct perf_counter_attr *attr = attrs + counter;
359 int track = 1; 377 struct perf_header_attr *h_attr;
378 int track = !counter; /* only the first counter needs these */
379 struct {
380 u64 count;
381 u64 time_enabled;
382 u64 time_running;
383 u64 id;
384 } read_data;
385
386 attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
387 PERF_FORMAT_TOTAL_TIME_RUNNING |
388 PERF_FORMAT_ID;
360 389
361 attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID; 390 attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
362 391
@@ -366,25 +395,20 @@ static void create_counter(int counter, int cpu, pid_t pid)
366 attr->sample_freq = freq; 395 attr->sample_freq = freq;
367 } 396 }
368 397
398 if (no_samples)
399 attr->sample_freq = 0;
400
401 if (inherit_stat)
402 attr->inherit_stat = 1;
403
369 if (call_graph) 404 if (call_graph)
370 attr->sample_type |= PERF_SAMPLE_CALLCHAIN; 405 attr->sample_type |= PERF_SAMPLE_CALLCHAIN;
371 406
372 if (file_new) {
373 file_header.sample_type = attr->sample_type;
374 } else {
375 if (file_header.sample_type != attr->sample_type) {
376 fprintf(stderr, "incompatible append\n");
377 exit(-1);
378 }
379 }
380
381 attr->mmap = track; 407 attr->mmap = track;
382 attr->comm = track; 408 attr->comm = track;
383 attr->inherit = (cpu < 0) && inherit; 409 attr->inherit = (cpu < 0) && inherit;
384 attr->disabled = 1; 410 attr->disabled = 1;
385 411
386 track = 0; /* only the first counter needs these */
387
388try_again: 412try_again:
389 fd[nr_cpu][counter] = sys_perf_counter_open(attr, pid, cpu, group_fd, 0); 413 fd[nr_cpu][counter] = sys_perf_counter_open(attr, pid, cpu, group_fd, 0);
390 414
@@ -415,6 +439,22 @@ try_again:
415 exit(-1); 439 exit(-1);
416 } 440 }
417 441
442 h_attr = get_header_attr(attr, counter);
443
444 if (!file_new) {
445 if (memcmp(&h_attr->attr, attr, sizeof(*attr))) {
446 fprintf(stderr, "incompatible append\n");
447 exit(-1);
448 }
449 }
450
451 if (read(fd[nr_cpu][counter], &read_data, sizeof(read_data)) == -1) {
452 perror("Unable to read perf file descriptor\n");
453 exit(-1);
454 }
455
456 perf_header_attr__add_id(h_attr, read_data.id);
457
418 assert(fd[nr_cpu][counter] >= 0); 458 assert(fd[nr_cpu][counter] >= 0);
419 fcntl(fd[nr_cpu][counter], F_SETFL, O_NONBLOCK); 459 fcntl(fd[nr_cpu][counter], F_SETFL, O_NONBLOCK);
420 460
@@ -445,11 +485,6 @@ static void open_counters(int cpu, pid_t pid)
445{ 485{
446 int counter; 486 int counter;
447 487
448 if (pid > 0) {
449 pid_synthesize_comm_event(pid, 0);
450 pid_synthesize_mmap_samples(pid);
451 }
452
453 group_fd = -1; 488 group_fd = -1;
454 for (counter = 0; counter < nr_counters; counter++) 489 for (counter = 0; counter < nr_counters; counter++)
455 create_counter(counter, cpu, pid); 490 create_counter(counter, cpu, pid);
@@ -459,17 +494,16 @@ static void open_counters(int cpu, pid_t pid)
459 494
460static void atexit_header(void) 495static void atexit_header(void)
461{ 496{
462 file_header.data_size += bytes_written; 497 header->data_size += bytes_written;
463 498
464 if (pwrite(output, &file_header, sizeof(file_header), 0) == -1) 499 perf_header__write(header, output);
465 perror("failed to write on file headers");
466} 500}
467 501
468static int __cmd_record(int argc, const char **argv) 502static int __cmd_record(int argc, const char **argv)
469{ 503{
470 int i, counter; 504 int i, counter;
471 struct stat st; 505 struct stat st;
472 pid_t pid; 506 pid_t pid = 0;
473 int flags; 507 int flags;
474 int ret; 508 int ret;
475 509
@@ -500,22 +534,31 @@ static int __cmd_record(int argc, const char **argv)
500 exit(-1); 534 exit(-1);
501 } 535 }
502 536
503 if (!file_new) { 537 if (!file_new)
504 if (read(output, &file_header, sizeof(file_header)) == -1) { 538 header = perf_header__read(output);
505 perror("failed to read file headers"); 539 else
506 exit(-1); 540 header = perf_header__new();
507 }
508
509 lseek(output, file_header.data_size, SEEK_CUR);
510 }
511 541
512 atexit(atexit_header); 542 atexit(atexit_header);
513 543
514 if (!system_wide) { 544 if (!system_wide) {
515 open_counters(-1, target_pid != -1 ? target_pid : getpid()); 545 pid = target_pid;
546 if (pid == -1)
547 pid = getpid();
548
549 open_counters(-1, pid);
516 } else for (i = 0; i < nr_cpus; i++) 550 } else for (i = 0; i < nr_cpus; i++)
517 open_counters(i, target_pid); 551 open_counters(i, target_pid);
518 552
553 if (file_new)
554 perf_header__write(header, output);
555
556 if (!system_wide) {
557 pid_synthesize_comm_event(pid, 0);
558 pid_synthesize_mmap_samples(pid);
559 } else
560 synthesize_all();
561
519 if (target_pid == -1 && argc) { 562 if (target_pid == -1 && argc) {
520 pid = fork(); 563 pid = fork();
521 if (pid < 0) 564 if (pid < 0)
@@ -539,10 +582,7 @@ static int __cmd_record(int argc, const char **argv)
539 } 582 }
540 } 583 }
541 584
542 if (system_wide) 585 for (;;) {
543 synthesize_samples();
544
545 while (!done) {
546 int hits = samples; 586 int hits = samples;
547 587
548 for (i = 0; i < nr_cpu; i++) { 588 for (i = 0; i < nr_cpu; i++) {
@@ -550,8 +590,11 @@ static int __cmd_record(int argc, const char **argv)
550 mmap_read(&mmap_array[i][counter]); 590 mmap_read(&mmap_array[i][counter]);
551 } 591 }
552 592
553 if (hits == samples) 593 if (hits == samples) {
594 if (done)
595 break;
554 ret = poll(event_array, nr_poll, 100); 596 ret = poll(event_array, nr_poll, 100);
597 }
555 } 598 }
556 599
557 /* 600 /*
@@ -600,10 +643,14 @@ static const struct option options[] = {
600 "do call-graph (stack chain/backtrace) recording"), 643 "do call-graph (stack chain/backtrace) recording"),
601 OPT_BOOLEAN('v', "verbose", &verbose, 644 OPT_BOOLEAN('v', "verbose", &verbose,
602 "be more verbose (show counter open errors, etc)"), 645 "be more verbose (show counter open errors, etc)"),
646 OPT_BOOLEAN('s', "stat", &inherit_stat,
647 "per thread counts"),
648 OPT_BOOLEAN('n', "no-samples", &no_samples,
649 "don't sample"),
603 OPT_END() 650 OPT_END()
604}; 651};
605 652
606int cmd_record(int argc, const char **argv, const char *prefix) 653int cmd_record(int argc, const char **argv, const char *prefix __used)
607{ 654{
608 int counter; 655 int counter;
609 656
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 5eb5566f0c95..4e5cc266311e 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -10,13 +10,16 @@
10#include "util/util.h" 10#include "util/util.h"
11 11
12#include "util/color.h" 12#include "util/color.h"
13#include "util/list.h" 13#include <linux/list.h>
14#include "util/cache.h" 14#include "util/cache.h"
15#include "util/rbtree.h" 15#include <linux/rbtree.h>
16#include "util/symbol.h" 16#include "util/symbol.h"
17#include "util/string.h" 17#include "util/string.h"
18#include "util/callchain.h"
19#include "util/strlist.h"
18 20
19#include "perf.h" 21#include "perf.h"
22#include "util/header.h"
20 23
21#include "util/parse-options.h" 24#include "util/parse-options.h"
22#include "util/parse-events.h" 25#include "util/parse-events.h"
@@ -30,6 +33,8 @@ static char *vmlinux = NULL;
30 33
31static char default_sort_order[] = "comm,dso"; 34static char default_sort_order[] = "comm,dso";
32static char *sort_order = default_sort_order; 35static char *sort_order = default_sort_order;
36static char *dso_list_str, *comm_list_str, *sym_list_str;
37static struct strlist *dso_list, *comm_list, *sym_list;
33 38
34static int input; 39static int input;
35static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; 40static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
@@ -41,6 +46,8 @@ static int dump_trace = 0;
41static int verbose; 46static int verbose;
42#define eprintf(x...) do { if (verbose) fprintf(stderr, x); } while (0) 47#define eprintf(x...) do { if (verbose) fprintf(stderr, x); } while (0)
43 48
49static int modules;
50
44static int full_paths; 51static int full_paths;
45 52
46static unsigned long page_size; 53static unsigned long page_size;
@@ -52,6 +59,18 @@ static regex_t parent_regex;
52 59
53static int exclude_other = 1; 60static int exclude_other = 1;
54 61
62static char callchain_default_opt[] = "fractal,0.5";
63
64static int callchain;
65
66static
67struct callchain_param callchain_param = {
68 .mode = CHAIN_GRAPH_ABS,
69 .min_percent = 0.5
70};
71
72static u64 sample_type;
73
55struct ip_event { 74struct ip_event {
56 struct perf_event_header header; 75 struct perf_event_header header;
57 u64 ip; 76 u64 ip;
@@ -59,11 +78,6 @@ struct ip_event {
59 unsigned char __more_data[]; 78 unsigned char __more_data[];
60}; 79};
61 80
62struct ip_callchain {
63 u64 nr;
64 u64 ips[0];
65};
66
67struct mmap_event { 81struct mmap_event {
68 struct perf_event_header header; 82 struct perf_event_header header;
69 u32 pid, tid; 83 u32 pid, tid;
@@ -97,6 +111,13 @@ struct lost_event {
97 u64 lost; 111 u64 lost;
98}; 112};
99 113
114struct read_event {
115 struct perf_event_header header;
116 u32 pid,tid;
117 u64 value;
118 u64 format[3];
119};
120
100typedef union event_union { 121typedef union event_union {
101 struct perf_event_header header; 122 struct perf_event_header header;
102 struct ip_event ip; 123 struct ip_event ip;
@@ -105,11 +126,13 @@ typedef union event_union {
105 struct fork_event fork; 126 struct fork_event fork;
106 struct period_event period; 127 struct period_event period;
107 struct lost_event lost; 128 struct lost_event lost;
129 struct read_event read;
108} event_t; 130} event_t;
109 131
110static LIST_HEAD(dsos); 132static LIST_HEAD(dsos);
111static struct dso *kernel_dso; 133static struct dso *kernel_dso;
112static struct dso *vdso; 134static struct dso *vdso;
135static struct dso *hypervisor_dso;
113 136
114static void dsos__add(struct dso *dso) 137static void dsos__add(struct dso *dso)
115{ 138{
@@ -165,7 +188,7 @@ static void dsos__fprintf(FILE *fp)
165 188
166static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip) 189static struct symbol *vdso__find_symbol(struct dso *dso, u64 ip)
167{ 190{
168 return dso__find_symbol(kernel_dso, ip); 191 return dso__find_symbol(dso, ip);
169} 192}
170 193
171static int load_kernel(void) 194static int load_kernel(void)
@@ -176,8 +199,8 @@ static int load_kernel(void)
176 if (!kernel_dso) 199 if (!kernel_dso)
177 return -1; 200 return -1;
178 201
179 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose); 202 err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose, modules);
180 if (err) { 203 if (err <= 0) {
181 dso__delete(kernel_dso); 204 dso__delete(kernel_dso);
182 kernel_dso = NULL; 205 kernel_dso = NULL;
183 } else 206 } else
@@ -191,6 +214,11 @@ static int load_kernel(void)
191 214
192 dsos__add(vdso); 215 dsos__add(vdso);
193 216
217 hypervisor_dso = dso__new("[hypervisor]", 0);
218 if (!hypervisor_dso)
219 return -1;
220 dsos__add(hypervisor_dso);
221
194 return err; 222 return err;
195} 223}
196 224
@@ -222,14 +250,14 @@ static u64 map__map_ip(struct map *map, u64 ip)
222 return ip - map->start + map->pgoff; 250 return ip - map->start + map->pgoff;
223} 251}
224 252
225static u64 vdso__map_ip(struct map *map, u64 ip) 253static u64 vdso__map_ip(struct map *map __used, u64 ip)
226{ 254{
227 return ip; 255 return ip;
228} 256}
229 257
230static inline int is_anon_memory(const char *filename) 258static inline int is_anon_memory(const char *filename)
231{ 259{
232 return strcmp(filename, "//anon") == 0; 260 return strcmp(filename, "//anon") == 0;
233} 261}
234 262
235static struct map *map__new(struct mmap_event *event) 263static struct map *map__new(struct mmap_event *event)
@@ -400,9 +428,27 @@ static void thread__insert_map(struct thread *self, struct map *map)
400 428
401 list_for_each_entry_safe(pos, tmp, &self->maps, node) { 429 list_for_each_entry_safe(pos, tmp, &self->maps, node) {
402 if (map__overlap(pos, map)) { 430 if (map__overlap(pos, map)) {
403 list_del_init(&pos->node); 431 if (verbose >= 2) {
404 /* XXX leaks dsos */ 432 printf("overlapping maps:\n");
405 free(pos); 433 map__fprintf(map, stdout);
434 map__fprintf(pos, stdout);
435 }
436
437 if (map->start <= pos->start && map->end > pos->start)
438 pos->start = map->end;
439
440 if (map->end >= pos->end && map->start < pos->end)
441 pos->end = map->start;
442
443 if (verbose >= 2) {
444 printf("after collision:\n");
445 map__fprintf(pos, stdout);
446 }
447
448 if (pos->start >= pos->end) {
449 list_del_init(&pos->node);
450 free(pos);
451 }
406 } 452 }
407 } 453 }
408 454
@@ -464,17 +510,19 @@ static size_t threads__fprintf(FILE *fp)
464static struct rb_root hist; 510static struct rb_root hist;
465 511
466struct hist_entry { 512struct hist_entry {
467 struct rb_node rb_node; 513 struct rb_node rb_node;
468 514
469 struct thread *thread; 515 struct thread *thread;
470 struct map *map; 516 struct map *map;
471 struct dso *dso; 517 struct dso *dso;
472 struct symbol *sym; 518 struct symbol *sym;
473 struct symbol *parent; 519 struct symbol *parent;
474 u64 ip; 520 u64 ip;
475 char level; 521 char level;
476 522 struct callchain_node callchain;
477 u64 count; 523 struct rb_root sorted_chain;
524
525 u64 count;
478}; 526};
479 527
480/* 528/*
@@ -609,7 +657,11 @@ sort__sym_print(FILE *fp, struct hist_entry *self)
609 657
610 if (self->sym) { 658 if (self->sym) {
611 ret += fprintf(fp, "[%c] %s", 659 ret += fprintf(fp, "[%c] %s",
612 self->dso == kernel_dso ? 'k' : '.', self->sym->name); 660 self->dso == kernel_dso ? 'k' :
661 self->dso == hypervisor_dso ? 'h' : '.', self->sym->name);
662
663 if (self->sym->module)
664 ret += fprintf(fp, "\t[%s]", self->sym->module->name);
613 } else { 665 } else {
614 ret += fprintf(fp, "%#016llx", (u64)self->ip); 666 ret += fprintf(fp, "%#016llx", (u64)self->ip);
615 } 667 }
@@ -674,7 +726,7 @@ static LIST_HEAD(hist_entry__sort_list);
674 726
675static int sort_dimension__add(char *tok) 727static int sort_dimension__add(char *tok)
676{ 728{
677 int i; 729 unsigned int i;
678 730
679 for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) { 731 for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) {
680 struct sort_dimension *sd = &sort_dimensions[i]; 732 struct sort_dimension *sd = &sort_dimensions[i];
@@ -744,34 +796,180 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
744 return cmp; 796 return cmp;
745} 797}
746 798
799static size_t ipchain__fprintf_graph_line(FILE *fp, int depth, int depth_mask)
800{
801 int i;
802 size_t ret = 0;
803
804 ret += fprintf(fp, "%s", " ");
805
806 for (i = 0; i < depth; i++)
807 if (depth_mask & (1 << i))
808 ret += fprintf(fp, "| ");
809 else
810 ret += fprintf(fp, " ");
811
812 ret += fprintf(fp, "\n");
813
814 return ret;
815}
747static size_t 816static size_t
748hist_entry__fprintf(FILE *fp, struct hist_entry *self, u64 total_samples) 817ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain, int depth,
818 int depth_mask, int count, u64 total_samples,
819 int hits)
749{ 820{
750 struct sort_entry *se; 821 int i;
751 size_t ret; 822 size_t ret = 0;
752 823
753 if (exclude_other && !self->parent) 824 ret += fprintf(fp, "%s", " ");
754 return 0; 825 for (i = 0; i < depth; i++) {
826 if (depth_mask & (1 << i))
827 ret += fprintf(fp, "|");
828 else
829 ret += fprintf(fp, " ");
830 if (!count && i == depth - 1) {
831 double percent;
832
833 percent = hits * 100.0 / total_samples;
834 ret += percent_color_fprintf(fp, "--%2.2f%%-- ", percent);
835 } else
836 ret += fprintf(fp, "%s", " ");
837 }
838 if (chain->sym)
839 ret += fprintf(fp, "%s\n", chain->sym->name);
840 else
841 ret += fprintf(fp, "%p\n", (void *)(long)chain->ip);
842
843 return ret;
844}
845
846static size_t
847callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
848 u64 total_samples, int depth, int depth_mask)
849{
850 struct rb_node *node, *next;
851 struct callchain_node *child;
852 struct callchain_list *chain;
853 int new_depth_mask = depth_mask;
854 u64 new_total;
855 size_t ret = 0;
856 int i;
755 857
756 if (total_samples) { 858 if (callchain_param.mode == CHAIN_GRAPH_REL)
757 double percent = self->count * 100.0 / total_samples; 859 new_total = self->cumul_hit;
758 char *color = PERF_COLOR_NORMAL; 860 else
861 new_total = total_samples;
862
863 node = rb_first(&self->rb_root);
864 while (node) {
865 child = rb_entry(node, struct callchain_node, rb_node);
759 866
760 /* 867 /*
761 * We color high-overhead entries in red, mid-overhead 868 * The depth mask manages the output of pipes that show
762 * entries in green - and keep the low overhead places 869 * the depth. We don't want to keep the pipes of the current
763 * normal: 870 * level for the last child of this depth
764 */ 871 */
765 if (percent >= 5.0) { 872 next = rb_next(node);
766 color = PERF_COLOR_RED; 873 if (!next)
767 } else { 874 new_depth_mask &= ~(1 << (depth - 1));
768 if (percent >= 0.5) 875
769 color = PERF_COLOR_GREEN; 876 /*
877 * But we keep the older depth mask for the line seperator
878 * to keep the level link until we reach the last child
879 */
880 ret += ipchain__fprintf_graph_line(fp, depth, depth_mask);
881 i = 0;
882 list_for_each_entry(chain, &child->val, list) {
883 if (chain->ip >= PERF_CONTEXT_MAX)
884 continue;
885 ret += ipchain__fprintf_graph(fp, chain, depth,
886 new_depth_mask, i++,
887 new_total,
888 child->cumul_hit);
889 }
890 ret += callchain__fprintf_graph(fp, child, new_total,
891 depth + 1,
892 new_depth_mask | (1 << depth));
893 node = next;
894 }
895
896 return ret;
897}
898
899static size_t
900callchain__fprintf_flat(FILE *fp, struct callchain_node *self,
901 u64 total_samples)
902{
903 struct callchain_list *chain;
904 size_t ret = 0;
905
906 if (!self)
907 return 0;
908
909 ret += callchain__fprintf_flat(fp, self->parent, total_samples);
910
911
912 list_for_each_entry(chain, &self->val, list) {
913 if (chain->ip >= PERF_CONTEXT_MAX)
914 continue;
915 if (chain->sym)
916 ret += fprintf(fp, " %s\n", chain->sym->name);
917 else
918 ret += fprintf(fp, " %p\n",
919 (void *)(long)chain->ip);
920 }
921
922 return ret;
923}
924
925static size_t
926hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self,
927 u64 total_samples)
928{
929 struct rb_node *rb_node;
930 struct callchain_node *chain;
931 size_t ret = 0;
932
933 rb_node = rb_first(&self->sorted_chain);
934 while (rb_node) {
935 double percent;
936
937 chain = rb_entry(rb_node, struct callchain_node, rb_node);
938 percent = chain->hit * 100.0 / total_samples;
939 switch (callchain_param.mode) {
940 case CHAIN_FLAT:
941 ret += percent_color_fprintf(fp, " %6.2f%%\n",
942 percent);
943 ret += callchain__fprintf_flat(fp, chain, total_samples);
944 break;
945 case CHAIN_GRAPH_ABS: /* Falldown */
946 case CHAIN_GRAPH_REL:
947 ret += callchain__fprintf_graph(fp, chain,
948 total_samples, 1, 1);
949 default:
950 break;
770 } 951 }
952 ret += fprintf(fp, "\n");
953 rb_node = rb_next(rb_node);
954 }
955
956 return ret;
957}
958
771 959
772 ret = color_fprintf(fp, color, " %6.2f%%", 960static size_t
961hist_entry__fprintf(FILE *fp, struct hist_entry *self, u64 total_samples)
962{
963 struct sort_entry *se;
964 size_t ret;
965
966 if (exclude_other && !self->parent)
967 return 0;
968
969 if (total_samples)
970 ret = percent_color_fprintf(fp, " %6.2f%%",
773 (self->count * 100.0) / total_samples); 971 (self->count * 100.0) / total_samples);
774 } else 972 else
775 ret = fprintf(fp, "%12Ld ", self->count); 973 ret = fprintf(fp, "%12Ld ", self->count);
776 974
777 list_for_each_entry(se, &hist_entry__sort_list, list) { 975 list_for_each_entry(se, &hist_entry__sort_list, list) {
@@ -784,6 +982,9 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, u64 total_samples)
784 982
785 ret += fprintf(fp, "\n"); 983 ret += fprintf(fp, "\n");
786 984
985 if (callchain)
986 hist_entry_callchain__fprintf(fp, self, total_samples);
987
787 return ret; 988 return ret;
788} 989}
789 990
@@ -797,7 +998,7 @@ resolve_symbol(struct thread *thread, struct map **mapp,
797{ 998{
798 struct dso *dso = dsop ? *dsop : NULL; 999 struct dso *dso = dsop ? *dsop : NULL;
799 struct map *map = mapp ? *mapp : NULL; 1000 struct map *map = mapp ? *mapp : NULL;
800 uint64_t ip = *ipp; 1001 u64 ip = *ipp;
801 1002
802 if (!thread) 1003 if (!thread)
803 return NULL; 1004 return NULL;
@@ -814,7 +1015,6 @@ resolve_symbol(struct thread *thread, struct map **mapp,
814 *mapp = map; 1015 *mapp = map;
815got_map: 1016got_map:
816 ip = map->map_ip(map, ip); 1017 ip = map->map_ip(map, ip);
817 *ipp = ip;
818 1018
819 dso = map->dso; 1019 dso = map->dso;
820 } else { 1020 } else {
@@ -828,6 +1028,8 @@ got_map:
828 dso = kernel_dso; 1028 dso = kernel_dso;
829 } 1029 }
830 dprintf(" ...... dso: %s\n", dso ? dso->name : "<not found>"); 1030 dprintf(" ...... dso: %s\n", dso ? dso->name : "<not found>");
1031 dprintf(" ...... map: %Lx -> %Lx\n", *ipp, ip);
1032 *ipp = ip;
831 1033
832 if (dsop) 1034 if (dsop)
833 *dsop = dso; 1035 *dsop = dso;
@@ -846,6 +1048,58 @@ static int call__match(struct symbol *sym)
846 return 0; 1048 return 0;
847} 1049}
848 1050
1051static struct symbol **
1052resolve_callchain(struct thread *thread, struct map *map __used,
1053 struct ip_callchain *chain, struct hist_entry *entry)
1054{
1055 u64 context = PERF_CONTEXT_MAX;
1056 struct symbol **syms = NULL;
1057 unsigned int i;
1058
1059 if (callchain) {
1060 syms = calloc(chain->nr, sizeof(*syms));
1061 if (!syms) {
1062 fprintf(stderr, "Can't allocate memory for symbols\n");
1063 exit(-1);
1064 }
1065 }
1066
1067 for (i = 0; i < chain->nr; i++) {
1068 u64 ip = chain->ips[i];
1069 struct dso *dso = NULL;
1070 struct symbol *sym;
1071
1072 if (ip >= PERF_CONTEXT_MAX) {
1073 context = ip;
1074 continue;
1075 }
1076
1077 switch (context) {
1078 case PERF_CONTEXT_HV:
1079 dso = hypervisor_dso;
1080 break;
1081 case PERF_CONTEXT_KERNEL:
1082 dso = kernel_dso;
1083 break;
1084 default:
1085 break;
1086 }
1087
1088 sym = resolve_symbol(thread, NULL, &dso, &ip);
1089
1090 if (sym) {
1091 if (sort__has_parent && call__match(sym) &&
1092 !entry->parent)
1093 entry->parent = sym;
1094 if (!callchain)
1095 break;
1096 syms[i] = sym;
1097 }
1098 }
1099
1100 return syms;
1101}
1102
849/* 1103/*
850 * collect histogram counts 1104 * collect histogram counts
851 */ 1105 */
@@ -858,6 +1112,7 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
858 struct rb_node **p = &hist.rb_node; 1112 struct rb_node **p = &hist.rb_node;
859 struct rb_node *parent = NULL; 1113 struct rb_node *parent = NULL;
860 struct hist_entry *he; 1114 struct hist_entry *he;
1115 struct symbol **syms = NULL;
861 struct hist_entry entry = { 1116 struct hist_entry entry = {
862 .thread = thread, 1117 .thread = thread,
863 .map = map, 1118 .map = map,
@@ -867,39 +1122,12 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
867 .level = level, 1122 .level = level,
868 .count = count, 1123 .count = count,
869 .parent = NULL, 1124 .parent = NULL,
1125 .sorted_chain = RB_ROOT
870 }; 1126 };
871 int cmp; 1127 int cmp;
872 1128
873 if (sort__has_parent && chain) { 1129 if ((sort__has_parent || callchain) && chain)
874 u64 context = PERF_CONTEXT_MAX; 1130 syms = resolve_callchain(thread, map, chain, &entry);
875 int i;
876
877 for (i = 0; i < chain->nr; i++) {
878 u64 ip = chain->ips[i];
879 struct dso *dso = NULL;
880 struct symbol *sym;
881
882 if (ip >= PERF_CONTEXT_MAX) {
883 context = ip;
884 continue;
885 }
886
887 switch (context) {
888 case PERF_CONTEXT_KERNEL:
889 dso = kernel_dso;
890 break;
891 default:
892 break;
893 }
894
895 sym = resolve_symbol(thread, NULL, &dso, &ip);
896
897 if (sym && call__match(sym)) {
898 entry.parent = sym;
899 break;
900 }
901 }
902 }
903 1131
904 while (*p != NULL) { 1132 while (*p != NULL) {
905 parent = *p; 1133 parent = *p;
@@ -909,6 +1137,10 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
909 1137
910 if (!cmp) { 1138 if (!cmp) {
911 he->count += count; 1139 he->count += count;
1140 if (callchain) {
1141 append_chain(&he->callchain, chain, syms);
1142 free(syms);
1143 }
912 return 0; 1144 return 0;
913 } 1145 }
914 1146
@@ -922,6 +1154,11 @@ hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
922 if (!he) 1154 if (!he)
923 return -ENOMEM; 1155 return -ENOMEM;
924 *he = entry; 1156 *he = entry;
1157 if (callchain) {
1158 callchain_init(&he->callchain);
1159 append_chain(&he->callchain, chain, syms);
1160 free(syms);
1161 }
925 rb_link_node(&he->rb_node, parent, p); 1162 rb_link_node(&he->rb_node, parent, p);
926 rb_insert_color(&he->rb_node, &hist); 1163 rb_insert_color(&he->rb_node, &hist);
927 1164
@@ -992,12 +1229,16 @@ static void collapse__resort(void)
992 1229
993static struct rb_root output_hists; 1230static struct rb_root output_hists;
994 1231
995static void output__insert_entry(struct hist_entry *he) 1232static void output__insert_entry(struct hist_entry *he, u64 min_callchain_hits)
996{ 1233{
997 struct rb_node **p = &output_hists.rb_node; 1234 struct rb_node **p = &output_hists.rb_node;
998 struct rb_node *parent = NULL; 1235 struct rb_node *parent = NULL;
999 struct hist_entry *iter; 1236 struct hist_entry *iter;
1000 1237
1238 if (callchain)
1239 callchain_param.sort(&he->sorted_chain, &he->callchain,
1240 min_callchain_hits, &callchain_param);
1241
1001 while (*p != NULL) { 1242 while (*p != NULL) {
1002 parent = *p; 1243 parent = *p;
1003 iter = rb_entry(parent, struct hist_entry, rb_node); 1244 iter = rb_entry(parent, struct hist_entry, rb_node);
@@ -1012,11 +1253,14 @@ static void output__insert_entry(struct hist_entry *he)
1012 rb_insert_color(&he->rb_node, &output_hists); 1253 rb_insert_color(&he->rb_node, &output_hists);
1013} 1254}
1014 1255
1015static void output__resort(void) 1256static void output__resort(u64 total_samples)
1016{ 1257{
1017 struct rb_node *next; 1258 struct rb_node *next;
1018 struct hist_entry *n; 1259 struct hist_entry *n;
1019 struct rb_root *tree = &hist; 1260 struct rb_root *tree = &hist;
1261 u64 min_callchain_hits;
1262
1263 min_callchain_hits = total_samples * (callchain_param.min_percent / 100);
1020 1264
1021 if (sort__need_collapse) 1265 if (sort__need_collapse)
1022 tree = &collapse_hists; 1266 tree = &collapse_hists;
@@ -1028,7 +1272,7 @@ static void output__resort(void)
1028 next = rb_next(&n->rb_node); 1272 next = rb_next(&n->rb_node);
1029 1273
1030 rb_erase(&n->rb_node, tree); 1274 rb_erase(&n->rb_node, tree);
1031 output__insert_entry(n); 1275 output__insert_entry(n, min_callchain_hits);
1032 } 1276 }
1033} 1277}
1034 1278
@@ -1054,7 +1298,7 @@ static size_t output__fprintf(FILE *fp, u64 total_samples)
1054 1298
1055 fprintf(fp, "# ........"); 1299 fprintf(fp, "# ........");
1056 list_for_each_entry(se, &hist_entry__sort_list, list) { 1300 list_for_each_entry(se, &hist_entry__sort_list, list) {
1057 int i; 1301 unsigned int i;
1058 1302
1059 if (exclude_other && (se == &sort_parent)) 1303 if (exclude_other && (se == &sort_parent))
1060 continue; 1304 continue;
@@ -1115,7 +1359,7 @@ static int validate_chain(struct ip_callchain *chain, event_t *event)
1115} 1359}
1116 1360
1117static int 1361static int
1118process_overflow_event(event_t *event, unsigned long offset, unsigned long head) 1362process_sample_event(event_t *event, unsigned long offset, unsigned long head)
1119{ 1363{
1120 char level; 1364 char level;
1121 int show = 0; 1365 int show = 0;
@@ -1126,13 +1370,14 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
1126 struct map *map = NULL; 1370 struct map *map = NULL;
1127 void *more_data = event->ip.__more_data; 1371 void *more_data = event->ip.__more_data;
1128 struct ip_callchain *chain = NULL; 1372 struct ip_callchain *chain = NULL;
1373 int cpumode;
1129 1374
1130 if (event->header.type & PERF_SAMPLE_PERIOD) { 1375 if (sample_type & PERF_SAMPLE_PERIOD) {
1131 period = *(u64 *)more_data; 1376 period = *(u64 *)more_data;
1132 more_data += sizeof(u64); 1377 more_data += sizeof(u64);
1133 } 1378 }
1134 1379
1135 dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p period: %Ld\n", 1380 dprintf("%p [%p]: PERF_EVENT_SAMPLE (IP, %d): %d: %p period: %Ld\n",
1136 (void *)(offset + head), 1381 (void *)(offset + head),
1137 (void *)(long)(event->header.size), 1382 (void *)(long)(event->header.size),
1138 event->header.misc, 1383 event->header.misc,
@@ -1140,8 +1385,8 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
1140 (void *)(long)ip, 1385 (void *)(long)ip,
1141 (long long)period); 1386 (long long)period);
1142 1387
1143 if (event->header.type & PERF_SAMPLE_CALLCHAIN) { 1388 if (sample_type & PERF_SAMPLE_CALLCHAIN) {
1144 int i; 1389 unsigned int i;
1145 1390
1146 chain = (void *)more_data; 1391 chain = (void *)more_data;
1147 1392
@@ -1166,7 +1411,12 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
1166 return -1; 1411 return -1;
1167 } 1412 }
1168 1413
1169 if (event->header.misc & PERF_EVENT_MISC_KERNEL) { 1414 if (comm_list && !strlist__has_entry(comm_list, thread->comm))
1415 return 0;
1416
1417 cpumode = event->header.misc & PERF_EVENT_MISC_CPUMODE_MASK;
1418
1419 if (cpumode == PERF_EVENT_MISC_KERNEL) {
1170 show = SHOW_KERNEL; 1420 show = SHOW_KERNEL;
1171 level = 'k'; 1421 level = 'k';
1172 1422
@@ -1174,7 +1424,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
1174 1424
1175 dprintf(" ...... dso: %s\n", dso->name); 1425 dprintf(" ...... dso: %s\n", dso->name);
1176 1426
1177 } else if (event->header.misc & PERF_EVENT_MISC_USER) { 1427 } else if (cpumode == PERF_EVENT_MISC_USER) {
1178 1428
1179 show = SHOW_USER; 1429 show = SHOW_USER;
1180 level = '.'; 1430 level = '.';
@@ -1182,12 +1432,21 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
1182 } else { 1432 } else {
1183 show = SHOW_HV; 1433 show = SHOW_HV;
1184 level = 'H'; 1434 level = 'H';
1435
1436 dso = hypervisor_dso;
1437
1185 dprintf(" ...... dso: [hypervisor]\n"); 1438 dprintf(" ...... dso: [hypervisor]\n");
1186 } 1439 }
1187 1440
1188 if (show & show_mask) { 1441 if (show & show_mask) {
1189 struct symbol *sym = resolve_symbol(thread, &map, &dso, &ip); 1442 struct symbol *sym = resolve_symbol(thread, &map, &dso, &ip);
1190 1443
1444 if (dso_list && dso && dso->name && !strlist__has_entry(dso_list, dso->name))
1445 return 0;
1446
1447 if (sym_list && sym && !strlist__has_entry(sym_list, sym->name))
1448 return 0;
1449
1191 if (hist_entry__add(thread, map, dso, sym, ip, chain, level, period)) { 1450 if (hist_entry__add(thread, map, dso, sym, ip, chain, level, period)) {
1192 eprintf("problem incrementing symbol count, skipping event\n"); 1451 eprintf("problem incrementing symbol count, skipping event\n");
1193 return -1; 1452 return -1;
@@ -1328,14 +1587,27 @@ static void trace_event(event_t *event)
1328} 1587}
1329 1588
1330static int 1589static int
1590process_read_event(event_t *event, unsigned long offset, unsigned long head)
1591{
1592 dprintf("%p [%p]: PERF_EVENT_READ: %d %d %Lu\n",
1593 (void *)(offset + head),
1594 (void *)(long)(event->header.size),
1595 event->read.pid,
1596 event->read.tid,
1597 event->read.value);
1598
1599 return 0;
1600}
1601
1602static int
1331process_event(event_t *event, unsigned long offset, unsigned long head) 1603process_event(event_t *event, unsigned long offset, unsigned long head)
1332{ 1604{
1333 trace_event(event); 1605 trace_event(event);
1334 1606
1335 if (event->header.misc & PERF_EVENT_MISC_OVERFLOW)
1336 return process_overflow_event(event, offset, head);
1337
1338 switch (event->header.type) { 1607 switch (event->header.type) {
1608 case PERF_EVENT_SAMPLE:
1609 return process_sample_event(event, offset, head);
1610
1339 case PERF_EVENT_MMAP: 1611 case PERF_EVENT_MMAP:
1340 return process_mmap_event(event, offset, head); 1612 return process_mmap_event(event, offset, head);
1341 1613
@@ -1351,6 +1623,9 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
1351 case PERF_EVENT_LOST: 1623 case PERF_EVENT_LOST:
1352 return process_lost_event(event, offset, head); 1624 return process_lost_event(event, offset, head);
1353 1625
1626 case PERF_EVENT_READ:
1627 return process_read_event(event, offset, head);
1628
1354 /* 1629 /*
1355 * We dont process them right now but they are fine: 1630 * We dont process them right now but they are fine:
1356 */ 1631 */
@@ -1366,13 +1641,30 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
1366 return 0; 1641 return 0;
1367} 1642}
1368 1643
1369static struct perf_file_header file_header; 1644static struct perf_header *header;
1645
1646static u64 perf_header__sample_type(void)
1647{
1648 u64 sample_type = 0;
1649 int i;
1650
1651 for (i = 0; i < header->attrs; i++) {
1652 struct perf_header_attr *attr = header->attr[i];
1653
1654 if (!sample_type)
1655 sample_type = attr->attr.sample_type;
1656 else if (sample_type != attr->attr.sample_type)
1657 die("non matching sample_type");
1658 }
1659
1660 return sample_type;
1661}
1370 1662
1371static int __cmd_report(void) 1663static int __cmd_report(void)
1372{ 1664{
1373 int ret, rc = EXIT_FAILURE; 1665 int ret, rc = EXIT_FAILURE;
1374 unsigned long offset = 0; 1666 unsigned long offset = 0;
1375 unsigned long head = sizeof(file_header); 1667 unsigned long head, shift;
1376 struct stat stat; 1668 struct stat stat;
1377 event_t *event; 1669 event_t *event;
1378 uint32_t size; 1670 uint32_t size;
@@ -1400,15 +1692,24 @@ static int __cmd_report(void)
1400 exit(0); 1692 exit(0);
1401 } 1693 }
1402 1694
1403 if (read(input, &file_header, sizeof(file_header)) == -1) { 1695 header = perf_header__read(input);
1404 perror("failed to read file headers"); 1696 head = header->data_offset;
1405 exit(-1);
1406 }
1407 1697
1408 if (sort__has_parent && 1698 sample_type = perf_header__sample_type();
1409 !(file_header.sample_type & PERF_SAMPLE_CALLCHAIN)) { 1699
1410 fprintf(stderr, "selected --sort parent, but no callchain data\n"); 1700 if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) {
1411 exit(-1); 1701 if (sort__has_parent) {
1702 fprintf(stderr, "selected --sort parent, but no"
1703 " callchain data. Did you call"
1704 " perf record without -g?\n");
1705 exit(-1);
1706 }
1707 if (callchain) {
1708 fprintf(stderr, "selected -c but no callchain data."
1709 " Did you call perf record without"
1710 " -g?\n");
1711 exit(-1);
1712 }
1412 } 1713 }
1413 1714
1414 if (load_kernel() < 0) { 1715 if (load_kernel() < 0) {
@@ -1426,6 +1727,11 @@ static int __cmd_report(void)
1426 cwd = NULL; 1727 cwd = NULL;
1427 cwdlen = 0; 1728 cwdlen = 0;
1428 } 1729 }
1730
1731 shift = page_size * (head / page_size);
1732 offset += shift;
1733 head -= shift;
1734
1429remap: 1735remap:
1430 buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ, 1736 buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
1431 MAP_SHARED, input, offset); 1737 MAP_SHARED, input, offset);
@@ -1442,9 +1748,10 @@ more:
1442 size = 8; 1748 size = 8;
1443 1749
1444 if (head + event->header.size >= page_size * mmap_window) { 1750 if (head + event->header.size >= page_size * mmap_window) {
1445 unsigned long shift = page_size * (head / page_size);
1446 int ret; 1751 int ret;
1447 1752
1753 shift = page_size * (head / page_size);
1754
1448 ret = munmap(buf, page_size * mmap_window); 1755 ret = munmap(buf, page_size * mmap_window);
1449 assert(ret == 0); 1756 assert(ret == 0);
1450 1757
@@ -1482,10 +1789,10 @@ more:
1482 1789
1483 head += size; 1790 head += size;
1484 1791
1485 if (offset + head >= sizeof(file_header) + file_header.data_size) 1792 if (offset + head >= header->data_offset + header->data_size)
1486 goto done; 1793 goto done;
1487 1794
1488 if (offset + head < stat.st_size) 1795 if (offset + head < (unsigned long)stat.st_size)
1489 goto more; 1796 goto more;
1490 1797
1491done: 1798done:
@@ -1509,12 +1816,58 @@ done:
1509 dsos__fprintf(stdout); 1816 dsos__fprintf(stdout);
1510 1817
1511 collapse__resort(); 1818 collapse__resort();
1512 output__resort(); 1819 output__resort(total);
1513 output__fprintf(stdout, total); 1820 output__fprintf(stdout, total);
1514 1821
1515 return rc; 1822 return rc;
1516} 1823}
1517 1824
1825static int
1826parse_callchain_opt(const struct option *opt __used, const char *arg,
1827 int unset __used)
1828{
1829 char *tok;
1830 char *endptr;
1831
1832 callchain = 1;
1833
1834 if (!arg)
1835 return 0;
1836
1837 tok = strtok((char *)arg, ",");
1838 if (!tok)
1839 return -1;
1840
1841 /* get the output mode */
1842 if (!strncmp(tok, "graph", strlen(arg)))
1843 callchain_param.mode = CHAIN_GRAPH_ABS;
1844
1845 else if (!strncmp(tok, "flat", strlen(arg)))
1846 callchain_param.mode = CHAIN_FLAT;
1847
1848 else if (!strncmp(tok, "fractal", strlen(arg)))
1849 callchain_param.mode = CHAIN_GRAPH_REL;
1850
1851 else
1852 return -1;
1853
1854 /* get the min percentage */
1855 tok = strtok(NULL, ",");
1856 if (!tok)
1857 goto setup;
1858
1859 callchain_param.min_percent = strtod(tok, &endptr);
1860 if (tok == endptr)
1861 return -1;
1862
1863setup:
1864 if (register_callchain_param(&callchain_param) < 0) {
1865 fprintf(stderr, "Can't register callchain params\n");
1866 return -1;
1867 }
1868 return 0;
1869}
1870
1518static const char * const report_usage[] = { 1871static const char * const report_usage[] = {
1519 "perf report [<options>] <command>", 1872 "perf report [<options>] <command>",
1520 NULL 1873 NULL
@@ -1528,6 +1881,8 @@ static const struct option options[] = {
1528 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 1881 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1529 "dump raw trace in ASCII"), 1882 "dump raw trace in ASCII"),
1530 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), 1883 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
1884 OPT_BOOLEAN('m', "modules", &modules,
1885 "load module symbols - WARNING: use only with -k and LIVE kernel"),
1531 OPT_STRING('s', "sort", &sort_order, "key[,key2...]", 1886 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
1532 "sort by key(s): pid, comm, dso, symbol, parent"), 1887 "sort by key(s): pid, comm, dso, symbol, parent"),
1533 OPT_BOOLEAN('P', "full-paths", &full_paths, 1888 OPT_BOOLEAN('P', "full-paths", &full_paths,
@@ -1536,6 +1891,15 @@ static const struct option options[] = {
1536 "regex filter to identify parent, see: '--sort parent'"), 1891 "regex filter to identify parent, see: '--sort parent'"),
1537 OPT_BOOLEAN('x', "exclude-other", &exclude_other, 1892 OPT_BOOLEAN('x', "exclude-other", &exclude_other,
1538 "Only display entries with parent-match"), 1893 "Only display entries with parent-match"),
1894 OPT_CALLBACK_DEFAULT('c', "callchain", NULL, "output_type,min_percent",
1895 "Display callchains using output_type and min percent threshold. "
1896 "Default: flat,0", &parse_callchain_opt, callchain_default_opt),
1897 OPT_STRING('d', "dsos", &dso_list_str, "dso[,dso...]",
1898 "only consider symbols in these dsos"),
1899 OPT_STRING('C', "comms", &comm_list_str, "comm[,comm...]",
1900 "only consider symbols in these comms"),
1901 OPT_STRING('S', "symbols", &sym_list_str, "symbol[,symbol...]",
1902 "only consider these symbols"),
1539 OPT_END() 1903 OPT_END()
1540}; 1904};
1541 1905
@@ -1554,7 +1918,20 @@ static void setup_sorting(void)
1554 free(str); 1918 free(str);
1555} 1919}
1556 1920
1557int cmd_report(int argc, const char **argv, const char *prefix) 1921static void setup_list(struct strlist **list, const char *list_str,
1922 const char *list_name)
1923{
1924 if (list_str) {
1925 *list = strlist__new(true, list_str);
1926 if (!*list) {
1927 fprintf(stderr, "problems parsing %s list\n",
1928 list_name);
1929 exit(129);
1930 }
1931 }
1932}
1933
1934int cmd_report(int argc, const char **argv, const char *prefix __used)
1558{ 1935{
1559 symbol__init(); 1936 symbol__init();
1560 1937
@@ -1575,6 +1952,10 @@ int cmd_report(int argc, const char **argv, const char *prefix)
1575 if (argc) 1952 if (argc)
1576 usage_with_options(report_usage, options); 1953 usage_with_options(report_usage, options);
1577 1954
1955 setup_list(&dso_list, dso_list_str, "dso");
1956 setup_list(&comm_list, comm_list_str, "comm");
1957 setup_list(&sym_list, sym_list_str, "symbol");
1958
1578 setup_pager(); 1959 setup_pager();
1579 1960
1580 return __cmd_report(); 1961 return __cmd_report();
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 6d3eeac1ea25..27921a8ce1a9 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -32,6 +32,7 @@
32 * Wu Fengguang <fengguang.wu@intel.com> 32 * Wu Fengguang <fengguang.wu@intel.com>
33 * Mike Galbraith <efault@gmx.de> 33 * Mike Galbraith <efault@gmx.de>
34 * Paul Mackerras <paulus@samba.org> 34 * Paul Mackerras <paulus@samba.org>
35 * Jaswinder Singh Rajput <jaswinder@kernel.org>
35 * 36 *
36 * Released under the GPL v2. (and only v2, not any later version) 37 * Released under the GPL v2. (and only v2, not any later version)
37 */ 38 */
@@ -45,7 +46,7 @@
45#include <sys/prctl.h> 46#include <sys/prctl.h>
46#include <math.h> 47#include <math.h>
47 48
48static struct perf_counter_attr default_attrs[MAX_COUNTERS] = { 49static struct perf_counter_attr default_attrs[] = {
49 50
50 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK }, 51 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK },
51 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES}, 52 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES},
@@ -59,42 +60,28 @@ static struct perf_counter_attr default_attrs[MAX_COUNTERS] = {
59 60
60}; 61};
61 62
63#define MAX_RUN 100
64
62static int system_wide = 0; 65static int system_wide = 0;
63static int inherit = 1;
64static int verbose = 0; 66static int verbose = 0;
67static unsigned int nr_cpus = 0;
68static int run_idx = 0;
65 69
66static int fd[MAX_NR_CPUS][MAX_COUNTERS]; 70static int run_count = 1;
67 71static int inherit = 1;
68static int target_pid = -1;
69static int nr_cpus = 0;
70static unsigned int page_size;
71
72static int scale = 1; 72static int scale = 1;
73static int target_pid = -1;
74static int null_run = 0;
73 75
74static const unsigned int default_count[] = { 76static int fd[MAX_NR_CPUS][MAX_COUNTERS];
75 1000000,
76 1000000,
77 10000,
78 10000,
79 1000000,
80 10000,
81};
82
83#define MAX_RUN 100
84
85static int run_count = 1;
86static int run_idx = 0;
87
88static u64 event_res[MAX_RUN][MAX_COUNTERS][3];
89static u64 event_scaled[MAX_RUN][MAX_COUNTERS];
90
91//static u64 event_hist[MAX_RUN][MAX_COUNTERS][3];
92
93 77
94static u64 runtime_nsecs[MAX_RUN]; 78static u64 runtime_nsecs[MAX_RUN];
95static u64 walltime_nsecs[MAX_RUN]; 79static u64 walltime_nsecs[MAX_RUN];
96static u64 runtime_cycles[MAX_RUN]; 80static u64 runtime_cycles[MAX_RUN];
97 81
82static u64 event_res[MAX_RUN][MAX_COUNTERS][3];
83static u64 event_scaled[MAX_RUN][MAX_COUNTERS];
84
98static u64 event_res_avg[MAX_COUNTERS][3]; 85static u64 event_res_avg[MAX_COUNTERS][3];
99static u64 event_res_noise[MAX_COUNTERS][3]; 86static u64 event_res_noise[MAX_COUNTERS][3];
100 87
@@ -109,7 +96,14 @@ static u64 walltime_nsecs_noise;
109static u64 runtime_cycles_avg; 96static u64 runtime_cycles_avg;
110static u64 runtime_cycles_noise; 97static u64 runtime_cycles_noise;
111 98
112static void create_perf_stat_counter(int counter) 99#define MATCH_EVENT(t, c, counter) \
100 (attrs[counter].type == PERF_TYPE_##t && \
101 attrs[counter].config == PERF_COUNT_##c)
102
103#define ERR_PERF_OPEN \
104"Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n"
105
106static void create_perf_stat_counter(int counter, int pid)
113{ 107{
114 struct perf_counter_attr *attr = attrs + counter; 108 struct perf_counter_attr *attr = attrs + counter;
115 109
@@ -118,21 +112,23 @@ static void create_perf_stat_counter(int counter)
118 PERF_FORMAT_TOTAL_TIME_RUNNING; 112 PERF_FORMAT_TOTAL_TIME_RUNNING;
119 113
120 if (system_wide) { 114 if (system_wide) {
121 int cpu; 115 unsigned int cpu;
122 for (cpu = 0; cpu < nr_cpus; cpu ++) { 116
117 for (cpu = 0; cpu < nr_cpus; cpu++) {
123 fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0); 118 fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0);
124 if (fd[cpu][counter] < 0 && verbose) { 119 if (fd[cpu][counter] < 0 && verbose)
125 printf("Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n", counter, fd[cpu][counter], strerror(errno)); 120 fprintf(stderr, ERR_PERF_OPEN, counter,
126 } 121 fd[cpu][counter], strerror(errno));
127 } 122 }
128 } else { 123 } else {
129 attr->inherit = inherit; 124 attr->inherit = inherit;
130 attr->disabled = 1; 125 attr->disabled = 1;
131 126 attr->enable_on_exec = 1;
132 fd[0][counter] = sys_perf_counter_open(attr, 0, -1, -1, 0); 127
133 if (fd[0][counter] < 0 && verbose) { 128 fd[0][counter] = sys_perf_counter_open(attr, pid, -1, -1, 0);
134 printf("Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n", counter, fd[0][counter], strerror(errno)); 129 if (fd[0][counter] < 0 && verbose)
135 } 130 fprintf(stderr, ERR_PERF_OPEN, counter,
131 fd[0][counter], strerror(errno));
136 } 132 }
137} 133}
138 134
@@ -141,13 +137,8 @@ static void create_perf_stat_counter(int counter)
141 */ 137 */
142static inline int nsec_counter(int counter) 138static inline int nsec_counter(int counter)
143{ 139{
144 if (attrs[counter].type != PERF_TYPE_SOFTWARE) 140 if (MATCH_EVENT(SOFTWARE, SW_CPU_CLOCK, counter) ||
145 return 0; 141 MATCH_EVENT(SOFTWARE, SW_TASK_CLOCK, counter))
146
147 if (attrs[counter].config == PERF_COUNT_SW_CPU_CLOCK)
148 return 1;
149
150 if (attrs[counter].config == PERF_COUNT_SW_TASK_CLOCK)
151 return 1; 142 return 1;
152 143
153 return 0; 144 return 0;
@@ -159,8 +150,8 @@ static inline int nsec_counter(int counter)
159static void read_counter(int counter) 150static void read_counter(int counter)
160{ 151{
161 u64 *count, single_count[3]; 152 u64 *count, single_count[3];
162 ssize_t res; 153 unsigned int cpu;
163 int cpu, nv; 154 size_t res, nv;
164 int scaled; 155 int scaled;
165 156
166 count = event_res[run_idx][counter]; 157 count = event_res[run_idx][counter];
@@ -168,12 +159,13 @@ static void read_counter(int counter)
168 count[0] = count[1] = count[2] = 0; 159 count[0] = count[1] = count[2] = 0;
169 160
170 nv = scale ? 3 : 1; 161 nv = scale ? 3 : 1;
171 for (cpu = 0; cpu < nr_cpus; cpu ++) { 162 for (cpu = 0; cpu < nr_cpus; cpu++) {
172 if (fd[cpu][counter] < 0) 163 if (fd[cpu][counter] < 0)
173 continue; 164 continue;
174 165
175 res = read(fd[cpu][counter], single_count, nv * sizeof(u64)); 166 res = read(fd[cpu][counter], single_count, nv * sizeof(u64));
176 assert(res == nv * sizeof(u64)); 167 assert(res == nv * sizeof(u64));
168
177 close(fd[cpu][counter]); 169 close(fd[cpu][counter]);
178 fd[cpu][counter] = -1; 170 fd[cpu][counter] = -1;
179 171
@@ -201,46 +193,81 @@ static void read_counter(int counter)
201 /* 193 /*
202 * Save the full runtime - to allow normalization during printout: 194 * Save the full runtime - to allow normalization during printout:
203 */ 195 */
204 if (attrs[counter].type == PERF_TYPE_SOFTWARE && 196 if (MATCH_EVENT(SOFTWARE, SW_TASK_CLOCK, counter))
205 attrs[counter].config == PERF_COUNT_SW_TASK_CLOCK)
206 runtime_nsecs[run_idx] = count[0]; 197 runtime_nsecs[run_idx] = count[0];
207 if (attrs[counter].type == PERF_TYPE_HARDWARE && 198 if (MATCH_EVENT(HARDWARE, HW_CPU_CYCLES, counter))
208 attrs[counter].config == PERF_COUNT_HW_CPU_CYCLES)
209 runtime_cycles[run_idx] = count[0]; 199 runtime_cycles[run_idx] = count[0];
210} 200}
211 201
212static int run_perf_stat(int argc, const char **argv) 202static int run_perf_stat(int argc __used, const char **argv)
213{ 203{
214 unsigned long long t0, t1; 204 unsigned long long t0, t1;
215 int status = 0; 205 int status = 0;
216 int counter; 206 int counter;
217 int pid; 207 int pid;
208 int child_ready_pipe[2], go_pipe[2];
209 char buf;
218 210
219 if (!system_wide) 211 if (!system_wide)
220 nr_cpus = 1; 212 nr_cpus = 1;
221 213
222 for (counter = 0; counter < nr_counters; counter++) 214 if (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0) {
223 create_perf_stat_counter(counter); 215 perror("failed to create pipes");
224 216 exit(1);
225 /* 217 }
226 * Enable counters and exec the command:
227 */
228 t0 = rdclock();
229 prctl(PR_TASK_PERF_COUNTERS_ENABLE);
230 218
231 if ((pid = fork()) < 0) 219 if ((pid = fork()) < 0)
232 perror("failed to fork"); 220 perror("failed to fork");
233 221
234 if (!pid) { 222 if (!pid) {
235 if (execvp(argv[0], (char **)argv)) { 223 close(child_ready_pipe[0]);
236 perror(argv[0]); 224 close(go_pipe[1]);
237 exit(-1); 225 fcntl(go_pipe[0], F_SETFD, FD_CLOEXEC);
238 } 226
227 /*
228 * Do a dummy execvp to get the PLT entry resolved,
229 * so we avoid the resolver overhead on the real
230 * execvp call.
231 */
232 execvp("", (char **)argv);
233
234 /*
235 * Tell the parent we're ready to go
236 */
237 close(child_ready_pipe[1]);
238
239 /*
240 * Wait until the parent tells us to go.
241 */
242 if (read(go_pipe[0], &buf, 1) == -1)
243 perror("unable to read pipe");
244
245 execvp(argv[0], (char **)argv);
246
247 perror(argv[0]);
248 exit(-1);
239 } 249 }
240 250
251 /*
252 * Wait for the child to be ready to exec.
253 */
254 close(child_ready_pipe[1]);
255 close(go_pipe[0]);
256 if (read(child_ready_pipe[0], &buf, 1) == -1)
257 perror("unable to read pipe");
258 close(child_ready_pipe[0]);
259
260 for (counter = 0; counter < nr_counters; counter++)
261 create_perf_stat_counter(counter, pid);
262
263 /*
264 * Enable counters and exec the command:
265 */
266 t0 = rdclock();
267
268 close(go_pipe[1]);
241 wait(&status); 269 wait(&status);
242 270
243 prctl(PR_TASK_PERF_COUNTERS_DISABLE);
244 t1 = rdclock(); 271 t1 = rdclock();
245 272
246 walltime_nsecs[run_idx] = t1 - t0; 273 walltime_nsecs[run_idx] = t1 - t0;
@@ -262,11 +289,9 @@ static void nsec_printout(int counter, u64 *count, u64 *noise)
262{ 289{
263 double msecs = (double)count[0] / 1000000; 290 double msecs = (double)count[0] / 1000000;
264 291
265 fprintf(stderr, " %14.6f %-20s", msecs, event_name(counter)); 292 fprintf(stderr, " %14.6f %-24s", msecs, event_name(counter));
266
267 if (attrs[counter].type == PERF_TYPE_SOFTWARE &&
268 attrs[counter].config == PERF_COUNT_SW_TASK_CLOCK) {
269 293
294 if (MATCH_EVENT(SOFTWARE, SW_TASK_CLOCK, counter)) {
270 if (walltime_nsecs_avg) 295 if (walltime_nsecs_avg)
271 fprintf(stderr, " # %10.3f CPUs ", 296 fprintf(stderr, " # %10.3f CPUs ",
272 (double)count[0] / (double)walltime_nsecs_avg); 297 (double)count[0] / (double)walltime_nsecs_avg);
@@ -276,12 +301,10 @@ static void nsec_printout(int counter, u64 *count, u64 *noise)
276 301
277static void abs_printout(int counter, u64 *count, u64 *noise) 302static void abs_printout(int counter, u64 *count, u64 *noise)
278{ 303{
279 fprintf(stderr, " %14Ld %-20s", count[0], event_name(counter)); 304 fprintf(stderr, " %14Ld %-24s", count[0], event_name(counter));
280 305
281 if (runtime_cycles_avg && 306 if (runtime_cycles_avg &&
282 attrs[counter].type == PERF_TYPE_HARDWARE && 307 MATCH_EVENT(HARDWARE, HW_INSTRUCTIONS, counter)) {
283 attrs[counter].config == PERF_COUNT_HW_INSTRUCTIONS) {
284
285 fprintf(stderr, " # %10.3f IPC ", 308 fprintf(stderr, " # %10.3f IPC ",
286 (double)count[0] / (double)runtime_cycles_avg); 309 (double)count[0] / (double)runtime_cycles_avg);
287 } else { 310 } else {
@@ -306,7 +329,7 @@ static void print_counter(int counter)
306 scaled = event_scaled_avg[counter]; 329 scaled = event_scaled_avg[counter];
307 330
308 if (scaled == -1) { 331 if (scaled == -1) {
309 fprintf(stderr, " %14s %-20s\n", 332 fprintf(stderr, " %14s %-24s\n",
310 "<not counted>", event_name(counter)); 333 "<not counted>", event_name(counter));
311 return; 334 return;
312 } 335 }
@@ -364,8 +387,11 @@ static void calc_avg(void)
364 event_res_avg[j]+1, event_res[i][j]+1); 387 event_res_avg[j]+1, event_res[i][j]+1);
365 update_avg("counter/2", j, 388 update_avg("counter/2", j,
366 event_res_avg[j]+2, event_res[i][j]+2); 389 event_res_avg[j]+2, event_res[i][j]+2);
367 update_avg("scaled", j, 390 if (event_scaled[i][j] != (u64)-1)
368 event_scaled_avg + j, event_scaled[i]+j); 391 update_avg("scaled", j,
392 event_scaled_avg + j, event_scaled[i]+j);
393 else
394 event_scaled_avg[j] = -1;
369 } 395 }
370 } 396 }
371 runtime_nsecs_avg /= run_count; 397 runtime_nsecs_avg /= run_count;
@@ -429,11 +455,14 @@ static void print_stat(int argc, const char **argv)
429 for (counter = 0; counter < nr_counters; counter++) 455 for (counter = 0; counter < nr_counters; counter++)
430 print_counter(counter); 456 print_counter(counter);
431 457
432
433 fprintf(stderr, "\n"); 458 fprintf(stderr, "\n");
434 fprintf(stderr, " %14.9f seconds time elapsed.\n", 459 fprintf(stderr, " %14.9f seconds time elapsed",
435 (double)walltime_nsecs_avg/1e9); 460 (double)walltime_nsecs_avg/1e9);
436 fprintf(stderr, "\n"); 461 if (run_count > 1) {
462 fprintf(stderr, " ( +- %7.3f%% )",
463 100.0*(double)walltime_nsecs_noise/(double)walltime_nsecs_avg);
464 }
465 fprintf(stderr, "\n\n");
437} 466}
438 467
439static volatile int signr = -1; 468static volatile int signr = -1;
@@ -466,36 +495,37 @@ static const struct option options[] = {
466 OPT_INTEGER('p', "pid", &target_pid, 495 OPT_INTEGER('p', "pid", &target_pid,
467 "stat events on existing pid"), 496 "stat events on existing pid"),
468 OPT_BOOLEAN('a', "all-cpus", &system_wide, 497 OPT_BOOLEAN('a', "all-cpus", &system_wide,
469 "system-wide collection from all CPUs"), 498 "system-wide collection from all CPUs"),
470 OPT_BOOLEAN('S', "scale", &scale, 499 OPT_BOOLEAN('S', "scale", &scale,
471 "scale/normalize counters"), 500 "scale/normalize counters"),
472 OPT_BOOLEAN('v', "verbose", &verbose, 501 OPT_BOOLEAN('v', "verbose", &verbose,
473 "be more verbose (show counter open errors, etc)"), 502 "be more verbose (show counter open errors, etc)"),
474 OPT_INTEGER('r', "repeat", &run_count, 503 OPT_INTEGER('r', "repeat", &run_count,
475 "repeat command and print average + stddev (max: 100)"), 504 "repeat command and print average + stddev (max: 100)"),
505 OPT_BOOLEAN('n', "null", &null_run,
506 "null run - dont start any counters"),
476 OPT_END() 507 OPT_END()
477}; 508};
478 509
479int cmd_stat(int argc, const char **argv, const char *prefix) 510int cmd_stat(int argc, const char **argv, const char *prefix __used)
480{ 511{
481 int status; 512 int status;
482 513
483 page_size = sysconf(_SC_PAGE_SIZE);
484
485 memcpy(attrs, default_attrs, sizeof(attrs));
486
487 argc = parse_options(argc, argv, options, stat_usage, 0); 514 argc = parse_options(argc, argv, options, stat_usage, 0);
488 if (!argc) 515 if (!argc)
489 usage_with_options(stat_usage, options); 516 usage_with_options(stat_usage, options);
490 if (run_count <= 0 || run_count > MAX_RUN) 517 if (run_count <= 0 || run_count > MAX_RUN)
491 usage_with_options(stat_usage, options); 518 usage_with_options(stat_usage, options);
492 519
493 if (!nr_counters) 520 /* Set attrs and nr_counters if no event is selected and !null_run */
494 nr_counters = 8; 521 if (!null_run && !nr_counters) {
522 memcpy(attrs, default_attrs, sizeof(default_attrs));
523 nr_counters = ARRAY_SIZE(default_attrs);
524 }
495 525
496 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); 526 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
497 assert(nr_cpus <= MAX_NR_CPUS); 527 assert(nr_cpus <= MAX_NR_CPUS);
498 assert(nr_cpus >= 0); 528 assert((int)nr_cpus >= 0);
499 529
500 /* 530 /*
501 * We dont want to block the signals - that would cause 531 * We dont want to block the signals - that would cause
@@ -511,7 +541,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
511 status = 0; 541 status = 0;
512 for (run_idx = 0; run_idx < run_count; run_idx++) { 542 for (run_idx = 0; run_idx < run_count; run_idx++) {
513 if (run_count != 1 && verbose) 543 if (run_count != 1 && verbose)
514 fprintf(stderr, "[ perf stat: executing run #%d ... ]\n", run_idx+1); 544 fprintf(stderr, "[ perf stat: executing run #%d ... ]\n", run_idx + 1);
515 status = run_perf_stat(argc, argv); 545 status = run_perf_stat(argc, argv);
516 } 546 }
517 547
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5352b5e352ed..95d5c0ae375a 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -23,7 +23,7 @@
23#include "util/symbol.h" 23#include "util/symbol.h"
24#include "util/color.h" 24#include "util/color.h"
25#include "util/util.h" 25#include "util/util.h"
26#include "util/rbtree.h" 26#include <linux/rbtree.h>
27#include "util/parse-options.h" 27#include "util/parse-options.h"
28#include "util/parse-events.h" 28#include "util/parse-events.h"
29 29
@@ -66,6 +66,7 @@ static unsigned int page_size;
66static unsigned int mmap_pages = 16; 66static unsigned int mmap_pages = 16;
67static int freq = 0; 67static int freq = 0;
68static int verbose = 0; 68static int verbose = 0;
69static char *vmlinux = NULL;
69 70
70static char *sym_filter; 71static char *sym_filter;
71static unsigned long filter_start; 72static unsigned long filter_start;
@@ -238,7 +239,6 @@ static void print_sym_table(void)
238 for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { 239 for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) {
239 struct sym_entry *syme = rb_entry(nd, struct sym_entry, rb_node); 240 struct sym_entry *syme = rb_entry(nd, struct sym_entry, rb_node);
240 struct symbol *sym = (struct symbol *)(syme + 1); 241 struct symbol *sym = (struct symbol *)(syme + 1);
241 char *color = PERF_COLOR_NORMAL;
242 double pcnt; 242 double pcnt;
243 243
244 if (++printed > print_entries || syme->snap_count < count_filter) 244 if (++printed > print_entries || syme->snap_count < count_filter)
@@ -247,29 +247,20 @@ static void print_sym_table(void)
247 pcnt = 100.0 - (100.0 * ((sum_ksamples - syme->snap_count) / 247 pcnt = 100.0 - (100.0 * ((sum_ksamples - syme->snap_count) /
248 sum_ksamples)); 248 sum_ksamples));
249 249
250 /*
251 * We color high-overhead entries in red, mid-overhead
252 * entries in green - and keep the low overhead places
253 * normal:
254 */
255 if (pcnt >= 5.0) {
256 color = PERF_COLOR_RED;
257 } else {
258 if (pcnt >= 0.5)
259 color = PERF_COLOR_GREEN;
260 }
261
262 if (nr_counters == 1) 250 if (nr_counters == 1)
263 printf("%20.2f - ", syme->weight); 251 printf("%20.2f - ", syme->weight);
264 else 252 else
265 printf("%9.1f %10ld - ", syme->weight, syme->snap_count); 253 printf("%9.1f %10ld - ", syme->weight, syme->snap_count);
266 254
267 color_fprintf(stdout, color, "%4.1f%%", pcnt); 255 percent_color_fprintf(stdout, "%4.1f%%", pcnt);
268 printf(" - %016llx : %s\n", sym->start, sym->name); 256 printf(" - %016llx : %s", sym->start, sym->name);
257 if (sym->module)
258 printf("\t[%s]", sym->module->name);
259 printf("\n");
269 } 260 }
270} 261}
271 262
272static void *display_thread(void *arg) 263static void *display_thread(void *arg __used)
273{ 264{
274 struct pollfd stdin_poll = { .fd = 0, .events = POLLIN }; 265 struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
275 int delay_msecs = delay_secs * 1000; 266 int delay_msecs = delay_secs * 1000;
@@ -286,11 +277,31 @@ static void *display_thread(void *arg)
286 return NULL; 277 return NULL;
287} 278}
288 279
280/* Tag samples to be skipped. */
281static const char *skip_symbols[] = {
282 "default_idle",
283 "cpu_idle",
284 "enter_idle",
285 "exit_idle",
286 "mwait_idle",
287 "ppc64_runlatch_off",
288 "pseries_dedicated_idle_sleep",
289 NULL
290};
291
289static int symbol_filter(struct dso *self, struct symbol *sym) 292static int symbol_filter(struct dso *self, struct symbol *sym)
290{ 293{
291 static int filter_match; 294 static int filter_match;
292 struct sym_entry *syme; 295 struct sym_entry *syme;
293 const char *name = sym->name; 296 const char *name = sym->name;
297 int i;
298
299 /*
300 * ppc64 uses function descriptors and appends a '.' to the
301 * start of every instruction address. Remove it.
302 */
303 if (name[0] == '.')
304 name++;
294 305
295 if (!strcmp(name, "_text") || 306 if (!strcmp(name, "_text") ||
296 !strcmp(name, "_etext") || 307 !strcmp(name, "_etext") ||
@@ -302,13 +313,12 @@ static int symbol_filter(struct dso *self, struct symbol *sym)
302 return 1; 313 return 1;
303 314
304 syme = dso__sym_priv(self, sym); 315 syme = dso__sym_priv(self, sym);
305 /* Tag samples to be skipped. */ 316 for (i = 0; skip_symbols[i]; i++) {
306 if (!strcmp("default_idle", name) || 317 if (!strcmp(skip_symbols[i], name)) {
307 !strcmp("cpu_idle", name) || 318 syme->skip = 1;
308 !strcmp("enter_idle", name) || 319 break;
309 !strcmp("exit_idle", name) || 320 }
310 !strcmp("mwait_idle", name)) 321 }
311 syme->skip = 1;
312 322
313 if (filter_match == 1) { 323 if (filter_match == 1) {
314 filter_end = sym->start; 324 filter_end = sym->start;
@@ -340,12 +350,13 @@ static int parse_symbols(void)
340{ 350{
341 struct rb_node *node; 351 struct rb_node *node;
342 struct symbol *sym; 352 struct symbol *sym;
353 int modules = vmlinux ? 1 : 0;
343 354
344 kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry)); 355 kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry));
345 if (kernel_dso == NULL) 356 if (kernel_dso == NULL)
346 return -1; 357 return -1;
347 358
348 if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) != 0) 359 if (dso__load_kernel(kernel_dso, vmlinux, symbol_filter, verbose, modules) <= 0)
349 goto out_delete_dso; 360 goto out_delete_dso;
350 361
351 node = rb_first(&kernel_dso->syms); 362 node = rb_first(&kernel_dso->syms);
@@ -392,11 +403,11 @@ static void record_ip(u64 ip, int counter)
392 samples--; 403 samples--;
393} 404}
394 405
395static void process_event(u64 ip, int counter) 406static void process_event(u64 ip, int counter, int user)
396{ 407{
397 samples++; 408 samples++;
398 409
399 if (ip < min_ip || ip > max_ip) { 410 if (user) {
400 userspace_samples++; 411 userspace_samples++;
401 return; 412 return;
402 } 413 }
@@ -407,7 +418,7 @@ static void process_event(u64 ip, int counter)
407struct mmap_data { 418struct mmap_data {
408 int counter; 419 int counter;
409 void *base; 420 void *base;
410 unsigned int mask; 421 int mask;
411 unsigned int prev; 422 unsigned int prev;
412}; 423};
413 424
@@ -509,9 +520,10 @@ static void mmap_read_counter(struct mmap_data *md)
509 520
510 old += size; 521 old += size;
511 522
512 if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) { 523 if (event->header.type == PERF_EVENT_SAMPLE) {
513 if (event->header.type & PERF_SAMPLE_IP) 524 int user =
514 process_event(event->ip.ip, md->counter); 525 (event->header.misc & PERF_EVENT_MISC_CPUMODE_MASK) == PERF_EVENT_MISC_USER;
526 process_event(event->ip.ip, md->counter, user);
515 } 527 }
516 } 528 }
517 529
@@ -660,6 +672,7 @@ static const struct option options[] = {
660 "system-wide collection from all CPUs"), 672 "system-wide collection from all CPUs"),
661 OPT_INTEGER('C', "CPU", &profile_cpu, 673 OPT_INTEGER('C', "CPU", &profile_cpu,
662 "CPU to profile on"), 674 "CPU to profile on"),
675 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
663 OPT_INTEGER('m', "mmap-pages", &mmap_pages, 676 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
664 "number of mmap data pages"), 677 "number of mmap data pages"),
665 OPT_INTEGER('r', "realtime", &realtime_prio, 678 OPT_INTEGER('r', "realtime", &realtime_prio,
@@ -674,7 +687,7 @@ static const struct option options[] = {
674 "put the counters into a counter group"), 687 "put the counters into a counter group"),
675 OPT_STRING('s', "sym-filter", &sym_filter, "pattern", 688 OPT_STRING('s', "sym-filter", &sym_filter, "pattern",
676 "only display symbols matchig this pattern"), 689 "only display symbols matchig this pattern"),
677 OPT_BOOLEAN('z', "zero", &group, 690 OPT_BOOLEAN('z', "zero", &zero,
678 "zero history across updates"), 691 "zero history across updates"),
679 OPT_INTEGER('F', "freq", &freq, 692 OPT_INTEGER('F', "freq", &freq,
680 "profile at this frequency"), 693 "profile at this frequency"),
@@ -685,10 +698,12 @@ static const struct option options[] = {
685 OPT_END() 698 OPT_END()
686}; 699};
687 700
688int cmd_top(int argc, const char **argv, const char *prefix) 701int cmd_top(int argc, const char **argv, const char *prefix __used)
689{ 702{
690 int counter; 703 int counter;
691 704
705 symbol__init();
706
692 page_size = sysconf(_SC_PAGE_SIZE); 707 page_size = sysconf(_SC_PAGE_SIZE);
693 708
694 argc = parse_options(argc, argv, options, top_usage, 0); 709 argc = parse_options(argc, argv, options, top_usage, 0);
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 4eb725933703..c5656784c61d 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -229,9 +229,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
229 use_pager = 1; 229 use_pager = 1;
230 commit_pager_choice(); 230 commit_pager_choice();
231 231
232 if (p->option & NEED_WORK_TREE)
233 /* setup_work_tree() */;
234
235 status = p->fn(argc, argv, prefix); 232 status = p->fn(argc, argv, prefix);
236 if (status) 233 if (status)
237 return status & 0xff; 234 return status & 0xff;
@@ -266,7 +263,7 @@ static void handle_internal_command(int argc, const char **argv)
266 { "annotate", cmd_annotate, 0 }, 263 { "annotate", cmd_annotate, 0 },
267 { "version", cmd_version, 0 }, 264 { "version", cmd_version, 0 },
268 }; 265 };
269 int i; 266 unsigned int i;
270 static const char ext[] = STRIP_EXTENSION; 267 static const char ext[] = STRIP_EXTENSION;
271 268
272 if (sizeof(ext) > 1) { 269 if (sizeof(ext) > 1) {
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index ceb68aa51f7f..63e67cc5487b 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -19,13 +19,29 @@
19#define cpu_relax() asm volatile("" ::: "memory"); 19#define cpu_relax() asm volatile("" ::: "memory");
20#endif 20#endif
21 21
22#ifdef __sh__
23#include "../../arch/sh/include/asm/unistd.h"
24#if defined(__SH4A__) || defined(__SH5__)
25# define rmb() asm volatile("synco" ::: "memory")
26#else
27# define rmb() asm volatile("" ::: "memory")
28#endif
29#define cpu_relax() asm volatile("" ::: "memory")
30#endif
31
32#ifdef __hppa__
33#include "../../arch/parisc/include/asm/unistd.h"
34#define rmb() asm volatile("" ::: "memory")
35#define cpu_relax() asm volatile("" ::: "memory");
36#endif
37
22#include <time.h> 38#include <time.h>
23#include <unistd.h> 39#include <unistd.h>
24#include <sys/types.h> 40#include <sys/types.h>
25#include <sys/syscall.h> 41#include <sys/syscall.h>
26 42
27#include "../../include/linux/perf_counter.h" 43#include "../../include/linux/perf_counter.h"
28#include "types.h" 44#include "util/types.h"
29 45
30/* 46/*
31 * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all 47 * prctl(PR_TASK_PERF_COUNTERS_DISABLE) will (cheaply) disable all
@@ -52,6 +68,8 @@ static inline unsigned long long rdclock(void)
52#define __user 68#define __user
53#define asmlinkage 69#define asmlinkage
54 70
71#define __used __attribute__((__unused__))
72
55#define unlikely(x) __builtin_expect(!!(x), 0) 73#define unlikely(x) __builtin_expect(!!(x), 0)
56#define min(x, y) ({ \ 74#define min(x, y) ({ \
57 typeof(x) _min1 = (x); \ 75 typeof(x) _min1 = (x); \
@@ -72,10 +90,9 @@ sys_perf_counter_open(struct perf_counter_attr *attr,
72#define MAX_COUNTERS 256 90#define MAX_COUNTERS 256
73#define MAX_NR_CPUS 256 91#define MAX_NR_CPUS 256
74 92
75struct perf_file_header { 93struct ip_callchain {
76 u64 version; 94 u64 nr;
77 u64 sample_type; 95 u64 ips[0];
78 u64 data_size;
79}; 96};
80 97
81#endif 98#endif
diff --git a/tools/perf/util/alias.c b/tools/perf/util/alias.c
index 9b3dd2b428df..b8144e80bb1e 100644
--- a/tools/perf/util/alias.c
+++ b/tools/perf/util/alias.c
@@ -3,7 +3,7 @@
3static const char *alias_key; 3static const char *alias_key;
4static char *alias_val; 4static char *alias_val;
5 5
6static int alias_lookup_cb(const char *k, const char *v, void *cb) 6static int alias_lookup_cb(const char *k, const char *v, void *cb __used)
7{ 7{
8 if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) { 8 if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) {
9 if (!v) 9 if (!v)
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 393d6146d13b..161d5f413e28 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -3,6 +3,7 @@
3 3
4#include "util.h" 4#include "util.h"
5#include "strbuf.h" 5#include "strbuf.h"
6#include "../perf.h"
6 7
7#define PERF_DIR_ENVIRONMENT "PERF_DIR" 8#define PERF_DIR_ENVIRONMENT "PERF_DIR"
8#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE" 9#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
new file mode 100644
index 000000000000..9d3c8141b8c1
--- /dev/null
+++ b/tools/perf/util/callchain.c
@@ -0,0 +1,335 @@
1/*
2 * Copyright (C) 2009, Frederic Weisbecker <fweisbec@gmail.com>
3 *
4 * Handle the callchains from the stream in an ad-hoc radix tree and then
5 * sort them in an rbtree.
6 *
7 * Using a radix for code path provides a fast retrieval and factorizes
8 * memory use. Also that lets us use the paths in a hierarchical graph view.
9 *
10 */
11
12#include <stdlib.h>
13#include <stdio.h>
14#include <stdbool.h>
15#include <errno.h>
16
17#include "callchain.h"
18
19#define chain_for_each_child(child, parent) \
20 list_for_each_entry(child, &parent->children, brothers)
21
22static void
23rb_insert_callchain(struct rb_root *root, struct callchain_node *chain,
24 enum chain_mode mode)
25{
26 struct rb_node **p = &root->rb_node;
27 struct rb_node *parent = NULL;
28 struct callchain_node *rnode;
29
30 while (*p) {
31 parent = *p;
32 rnode = rb_entry(parent, struct callchain_node, rb_node);
33
34 switch (mode) {
35 case CHAIN_FLAT:
36 if (rnode->hit < chain->hit)
37 p = &(*p)->rb_left;
38 else
39 p = &(*p)->rb_right;
40 break;
41 case CHAIN_GRAPH_ABS: /* Falldown */
42 case CHAIN_GRAPH_REL:
43 if (rnode->cumul_hit < chain->cumul_hit)
44 p = &(*p)->rb_left;
45 else
46 p = &(*p)->rb_right;
47 break;
48 default:
49 break;
50 }
51 }
52
53 rb_link_node(&chain->rb_node, parent, p);
54 rb_insert_color(&chain->rb_node, root);
55}
56
57static void
58__sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node,
59 u64 min_hit)
60{
61 struct callchain_node *child;
62
63 chain_for_each_child(child, node)
64 __sort_chain_flat(rb_root, child, min_hit);
65
66 if (node->hit && node->hit >= min_hit)
67 rb_insert_callchain(rb_root, node, CHAIN_FLAT);
68}
69
70/*
71 * Once we get every callchains from the stream, we can now
72 * sort them by hit
73 */
74static void
75sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node,
76 u64 min_hit, struct callchain_param *param __used)
77{
78 __sort_chain_flat(rb_root, node, min_hit);
79}
80
81static void __sort_chain_graph_abs(struct callchain_node *node,
82 u64 min_hit)
83{
84 struct callchain_node *child;
85
86 node->rb_root = RB_ROOT;
87
88 chain_for_each_child(child, node) {
89 __sort_chain_graph_abs(child, min_hit);
90 if (child->cumul_hit >= min_hit)
91 rb_insert_callchain(&node->rb_root, child,
92 CHAIN_GRAPH_ABS);
93 }
94}
95
96static void
97sort_chain_graph_abs(struct rb_root *rb_root, struct callchain_node *chain_root,
98 u64 min_hit, struct callchain_param *param __used)
99{
100 __sort_chain_graph_abs(chain_root, min_hit);
101 rb_root->rb_node = chain_root->rb_root.rb_node;
102}
103
104static void __sort_chain_graph_rel(struct callchain_node *node,
105 double min_percent)
106{
107 struct callchain_node *child;
108 u64 min_hit;
109
110 node->rb_root = RB_ROOT;
111 min_hit = node->cumul_hit * min_percent / 100.0;
112
113 chain_for_each_child(child, node) {
114 __sort_chain_graph_rel(child, min_percent);
115 if (child->cumul_hit >= min_hit)
116 rb_insert_callchain(&node->rb_root, child,
117 CHAIN_GRAPH_REL);
118 }
119}
120
121static void
122sort_chain_graph_rel(struct rb_root *rb_root, struct callchain_node *chain_root,
123 u64 min_hit __used, struct callchain_param *param)
124{
125 __sort_chain_graph_rel(chain_root, param->min_percent);
126 rb_root->rb_node = chain_root->rb_root.rb_node;
127}
128
129int register_callchain_param(struct callchain_param *param)
130{
131 switch (param->mode) {
132 case CHAIN_GRAPH_ABS:
133 param->sort = sort_chain_graph_abs;
134 break;
135 case CHAIN_GRAPH_REL:
136 param->sort = sort_chain_graph_rel;
137 break;
138 case CHAIN_FLAT:
139 param->sort = sort_chain_flat;
140 break;
141 default:
142 return -1;
143 }
144 return 0;
145}
146
147/*
148 * Create a child for a parent. If inherit_children, then the new child
149 * will become the new parent of it's parent children
150 */
151static struct callchain_node *
152create_child(struct callchain_node *parent, bool inherit_children)
153{
154 struct callchain_node *new;
155
156 new = malloc(sizeof(*new));
157 if (!new) {
158 perror("not enough memory to create child for code path tree");
159 return NULL;
160 }
161 new->parent = parent;
162 INIT_LIST_HEAD(&new->children);
163 INIT_LIST_HEAD(&new->val);
164
165 if (inherit_children) {
166 struct callchain_node *next;
167
168 list_splice(&parent->children, &new->children);
169 INIT_LIST_HEAD(&parent->children);
170
171 chain_for_each_child(next, new)
172 next->parent = new;
173 }
174 list_add_tail(&new->brothers, &parent->children);
175
176 return new;
177}
178
179/*
180 * Fill the node with callchain values
181 */
182static void
183fill_node(struct callchain_node *node, struct ip_callchain *chain,
184 int start, struct symbol **syms)
185{
186 unsigned int i;
187
188 for (i = start; i < chain->nr; i++) {
189 struct callchain_list *call;
190
191 call = malloc(sizeof(*call));
192 if (!call) {
193 perror("not enough memory for the code path tree");
194 return;
195 }
196 call->ip = chain->ips[i];
197 call->sym = syms[i];
198 list_add_tail(&call->list, &node->val);
199 }
200 node->val_nr = chain->nr - start;
201 if (!node->val_nr)
202 printf("Warning: empty node in callchain tree\n");
203}
204
205static void
206add_child(struct callchain_node *parent, struct ip_callchain *chain,
207 int start, struct symbol **syms)
208{
209 struct callchain_node *new;
210
211 new = create_child(parent, false);
212 fill_node(new, chain, start, syms);
213
214 new->cumul_hit = new->hit = 1;
215}
216
217/*
218 * Split the parent in two parts (a new child is created) and
219 * give a part of its callchain to the created child.
220 * Then create another child to host the given callchain of new branch
221 */
222static void
223split_add_child(struct callchain_node *parent, struct ip_callchain *chain,
224 struct callchain_list *to_split, int idx_parents, int idx_local,
225 struct symbol **syms)
226{
227 struct callchain_node *new;
228 struct list_head *old_tail;
229 unsigned int idx_total = idx_parents + idx_local;
230
231 /* split */
232 new = create_child(parent, true);
233
234 /* split the callchain and move a part to the new child */
235 old_tail = parent->val.prev;
236 list_del_range(&to_split->list, old_tail);
237 new->val.next = &to_split->list;
238 new->val.prev = old_tail;
239 to_split->list.prev = &new->val;
240 old_tail->next = &new->val;
241
242 /* split the hits */
243 new->hit = parent->hit;
244 new->cumul_hit = parent->cumul_hit;
245 new->val_nr = parent->val_nr - idx_local;
246 parent->val_nr = idx_local;
247
248 /* create a new child for the new branch if any */
249 if (idx_total < chain->nr) {
250 parent->hit = 0;
251 add_child(parent, chain, idx_total, syms);
252 } else {
253 parent->hit = 1;
254 }
255}
256
257static int
258__append_chain(struct callchain_node *root, struct ip_callchain *chain,
259 unsigned int start, struct symbol **syms);
260
261static void
262__append_chain_children(struct callchain_node *root, struct ip_callchain *chain,
263 struct symbol **syms, unsigned int start)
264{
265 struct callchain_node *rnode;
266
267 /* lookup in childrens */
268 chain_for_each_child(rnode, root) {
269 unsigned int ret = __append_chain(rnode, chain, start, syms);
270
271 if (!ret)
272 goto cumul;
273 }
274 /* nothing in children, add to the current node */
275 add_child(root, chain, start, syms);
276
277cumul:
278 root->cumul_hit++;
279}
280
281static int
282__append_chain(struct callchain_node *root, struct ip_callchain *chain,
283 unsigned int start, struct symbol **syms)
284{
285 struct callchain_list *cnode;
286 unsigned int i = start;
287 bool found = false;
288
289 /*
290 * Lookup in the current node
291 * If we have a symbol, then compare the start to match
292 * anywhere inside a function.
293 */
294 list_for_each_entry(cnode, &root->val, list) {
295 if (i == chain->nr)
296 break;
297 if (cnode->sym && syms[i]) {
298 if (cnode->sym->start != syms[i]->start)
299 break;
300 } else if (cnode->ip != chain->ips[i])
301 break;
302 if (!found)
303 found = true;
304 i++;
305 }
306
307 /* matches not, relay on the parent */
308 if (!found)
309 return -1;
310
311 /* we match only a part of the node. Split it and add the new chain */
312 if (i - start < root->val_nr) {
313 split_add_child(root, chain, cnode, start, i - start, syms);
314 return 0;
315 }
316
317 /* we match 100% of the path, increment the hit */
318 if (i - start == root->val_nr && i == chain->nr) {
319 root->hit++;
320 root->cumul_hit++;
321
322 return 0;
323 }
324
325 /* We match the node and still have a part remaining */
326 __append_chain_children(root, chain, syms, i);
327
328 return 0;
329}
330
331void append_chain(struct callchain_node *root, struct ip_callchain *chain,
332 struct symbol **syms)
333{
334 __append_chain_children(root, chain, syms, 0);
335}
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
new file mode 100644
index 000000000000..7812122bea1d
--- /dev/null
+++ b/tools/perf/util/callchain.h
@@ -0,0 +1,54 @@
1#ifndef __PERF_CALLCHAIN_H
2#define __PERF_CALLCHAIN_H
3
4#include "../perf.h"
5#include <linux/list.h>
6#include <linux/rbtree.h>
7#include "symbol.h"
8
9enum chain_mode {
10 CHAIN_FLAT,
11 CHAIN_GRAPH_ABS,
12 CHAIN_GRAPH_REL
13};
14
15struct callchain_node {
16 struct callchain_node *parent;
17 struct list_head brothers;
18 struct list_head children;
19 struct list_head val;
20 struct rb_node rb_node; /* to sort nodes in an rbtree */
21 struct rb_root rb_root; /* sorted tree of children */
22 unsigned int val_nr;
23 u64 hit;
24 u64 cumul_hit; /* hit + hits of children */
25};
26
27struct callchain_param;
28
29typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *,
30 u64, struct callchain_param *);
31
32struct callchain_param {
33 enum chain_mode mode;
34 double min_percent;
35 sort_chain_func_t sort;
36};
37
38struct callchain_list {
39 u64 ip;
40 struct symbol *sym;
41 struct list_head list;
42};
43
44static inline void callchain_init(struct callchain_node *node)
45{
46 INIT_LIST_HEAD(&node->brothers);
47 INIT_LIST_HEAD(&node->children);
48 INIT_LIST_HEAD(&node->val);
49}
50
51int register_callchain_param(struct callchain_param *param);
52void append_chain(struct callchain_node *root, struct ip_callchain *chain,
53 struct symbol **syms);
54#endif
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index 9a8c20ccc53e..90a044d1fe7d 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -11,7 +11,8 @@ static int parse_color(const char *name, int len)
11 }; 11 };
12 char *end; 12 char *end;
13 int i; 13 int i;
14 for (i = 0; i < ARRAY_SIZE(color_names); i++) { 14
15 for (i = 0; i < (int)ARRAY_SIZE(color_names); i++) {
15 const char *str = color_names[i]; 16 const char *str = color_names[i];
16 if (!strncasecmp(name, str, len) && !str[len]) 17 if (!strncasecmp(name, str, len) && !str[len])
17 return i - 1; 18 return i - 1;
@@ -28,7 +29,8 @@ static int parse_attr(const char *name, int len)
28 static const char * const attr_names[] = { 29 static const char * const attr_names[] = {
29 "bold", "dim", "ul", "blink", "reverse" 30 "bold", "dim", "ul", "blink", "reverse"
30 }; 31 };
31 int i; 32 unsigned int i;
33
32 for (i = 0; i < ARRAY_SIZE(attr_names); i++) { 34 for (i = 0; i < ARRAY_SIZE(attr_names); i++) {
33 const char *str = attr_names[i]; 35 const char *str = attr_names[i];
34 if (!strncasecmp(name, str, len) && !str[len]) 36 if (!strncasecmp(name, str, len) && !str[len])
@@ -222,10 +224,12 @@ int color_fwrite_lines(FILE *fp, const char *color,
222{ 224{
223 if (!*color) 225 if (!*color)
224 return fwrite(buf, count, 1, fp) != 1; 226 return fwrite(buf, count, 1, fp) != 1;
227
225 while (count) { 228 while (count) {
226 char *p = memchr(buf, '\n', count); 229 char *p = memchr(buf, '\n', count);
230
227 if (p != buf && (fputs(color, fp) < 0 || 231 if (p != buf && (fputs(color, fp) < 0 ||
228 fwrite(buf, p ? p - buf : count, 1, fp) != 1 || 232 fwrite(buf, p ? (size_t)(p - buf) : count, 1, fp) != 1 ||
229 fputs(PERF_COLOR_RESET, fp) < 0)) 233 fputs(PERF_COLOR_RESET, fp) < 0))
230 return -1; 234 return -1;
231 if (!p) 235 if (!p)
@@ -238,4 +242,31 @@ int color_fwrite_lines(FILE *fp, const char *color,
238 return 0; 242 return 0;
239} 243}
240 244
245char *get_percent_color(double percent)
246{
247 char *color = PERF_COLOR_NORMAL;
241 248
249 /*
250 * We color high-overhead entries in red, mid-overhead
251 * entries in green - and keep the low overhead places
252 * normal:
253 */
254 if (percent >= MIN_RED)
255 color = PERF_COLOR_RED;
256 else {
257 if (percent > MIN_GREEN)
258 color = PERF_COLOR_GREEN;
259 }
260 return color;
261}
262
263int percent_color_fprintf(FILE *fp, const char *fmt, double percent)
264{
265 int r;
266 char *color;
267
268 color = get_percent_color(percent);
269 r = color_fprintf(fp, color, fmt, percent);
270
271 return r;
272}
diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h
index 5abfd379582b..706cec50bd25 100644
--- a/tools/perf/util/color.h
+++ b/tools/perf/util/color.h
@@ -15,6 +15,9 @@
15#define PERF_COLOR_CYAN "\033[36m" 15#define PERF_COLOR_CYAN "\033[36m"
16#define PERF_COLOR_BG_RED "\033[41m" 16#define PERF_COLOR_BG_RED "\033[41m"
17 17
18#define MIN_GREEN 0.5
19#define MIN_RED 5.0
20
18/* 21/*
19 * This variable stores the value of color.ui 22 * This variable stores the value of color.ui
20 */ 23 */
@@ -32,5 +35,7 @@ void color_parse_mem(const char *value, int len, const char *var, char *dst);
32int color_fprintf(FILE *fp, const char *color, const char *fmt, ...); 35int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
33int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...); 36int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
34int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf); 37int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
38int percent_color_fprintf(FILE *fp, const char *fmt, double percent);
39char *get_percent_color(double percent);
35 40
36#endif /* COLOR_H */ 41#endif /* COLOR_H */
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 3dd13faa6a27..780df541006d 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -47,10 +47,12 @@ static int get_next_char(void)
47static char *parse_value(void) 47static char *parse_value(void)
48{ 48{
49 static char value[1024]; 49 static char value[1024];
50 int quote = 0, comment = 0, len = 0, space = 0; 50 int quote = 0, comment = 0, space = 0;
51 size_t len = 0;
51 52
52 for (;;) { 53 for (;;) {
53 int c = get_next_char(); 54 int c = get_next_char();
55
54 if (len >= sizeof(value) - 1) 56 if (len >= sizeof(value) - 1)
55 return NULL; 57 return NULL;
56 if (c == '\n') { 58 if (c == '\n') {
@@ -353,13 +355,13 @@ int perf_config_string(const char **dest, const char *var, const char *value)
353 return 0; 355 return 0;
354} 356}
355 357
356static int perf_default_core_config(const char *var, const char *value) 358static int perf_default_core_config(const char *var __used, const char *value __used)
357{ 359{
358 /* Add other config variables here and to Documentation/config.txt. */ 360 /* Add other config variables here and to Documentation/config.txt. */
359 return 0; 361 return 0;
360} 362}
361 363
362int perf_default_config(const char *var, const char *value, void *dummy) 364int perf_default_config(const char *var, const char *value, void *dummy __used)
363{ 365{
364 if (!prefixcmp(var, "core.")) 366 if (!prefixcmp(var, "core."))
365 return perf_default_core_config(var, value); 367 return perf_default_core_config(var, value);
@@ -471,10 +473,10 @@ static int matches(const char* key, const char* value)
471 !regexec(store.value_regex, value, 0, NULL, 0))); 473 !regexec(store.value_regex, value, 0, NULL, 0)));
472} 474}
473 475
474static int store_aux(const char* key, const char* value, void *cb) 476static int store_aux(const char* key, const char* value, void *cb __used)
475{ 477{
478 int section_len;
476 const char *ep; 479 const char *ep;
477 size_t section_len;
478 480
479 switch (store.state) { 481 switch (store.state) {
480 case KEY_SEEN: 482 case KEY_SEEN:
@@ -551,7 +553,7 @@ static int store_write_section(int fd, const char* key)
551 strbuf_addf(&sb, "[%.*s]\n", store.baselen, key); 553 strbuf_addf(&sb, "[%.*s]\n", store.baselen, key);
552 } 554 }
553 555
554 success = write_in_full(fd, sb.buf, sb.len) == sb.len; 556 success = (write_in_full(fd, sb.buf, sb.len) == (ssize_t)sb.len);
555 strbuf_release(&sb); 557 strbuf_release(&sb);
556 558
557 return success; 559 return success;
@@ -599,7 +601,7 @@ static int store_write_pair(int fd, const char* key, const char* value)
599 } 601 }
600 strbuf_addf(&sb, "%s\n", quote); 602 strbuf_addf(&sb, "%s\n", quote);
601 603
602 success = write_in_full(fd, sb.buf, sb.len) == sb.len; 604 success = (write_in_full(fd, sb.buf, sb.len) == (ssize_t)sb.len);
603 strbuf_release(&sb); 605 strbuf_release(&sb);
604 606
605 return success; 607 return success;
@@ -741,7 +743,7 @@ int perf_config_set_multivar(const char* key, const char* value,
741 } else { 743 } else {
742 struct stat st; 744 struct stat st;
743 char* contents; 745 char* contents;
744 size_t contents_sz, copy_begin, copy_end; 746 ssize_t contents_sz, copy_begin, copy_end;
745 int i, new_line = 0; 747 int i, new_line = 0;
746 748
747 if (value_regex == NULL) 749 if (value_regex == NULL)
diff --git a/tools/perf/util/exec_cmd.c b/tools/perf/util/exec_cmd.c
index d39292263153..34a352867382 100644
--- a/tools/perf/util/exec_cmd.c
+++ b/tools/perf/util/exec_cmd.c
@@ -1,6 +1,9 @@
1#include "cache.h" 1#include "cache.h"
2#include "exec_cmd.h" 2#include "exec_cmd.h"
3#include "quote.h" 3#include "quote.h"
4
5#include <string.h>
6
4#define MAX_ARGS 32 7#define MAX_ARGS 32
5 8
6extern char **environ; 9extern char **environ;
@@ -51,7 +54,7 @@ const char *perf_extract_argv0_path(const char *argv0)
51 slash--; 54 slash--;
52 55
53 if (slash >= argv0) { 56 if (slash >= argv0) {
54 argv0_path = strndup(argv0, slash - argv0); 57 argv0_path = xstrndup(argv0, slash - argv0);
55 return slash + 1; 58 return slash + 1;
56 } 59 }
57 60
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
new file mode 100644
index 000000000000..450384b3bbe5
--- /dev/null
+++ b/tools/perf/util/header.c
@@ -0,0 +1,242 @@
1#include <sys/types.h>
2#include <unistd.h>
3#include <stdio.h>
4#include <stdlib.h>
5
6#include "util.h"
7#include "header.h"
8
9/*
10 *
11 */
12
13struct perf_header_attr *perf_header_attr__new(struct perf_counter_attr *attr)
14{
15 struct perf_header_attr *self = malloc(sizeof(*self));
16
17 if (!self)
18 die("nomem");
19
20 self->attr = *attr;
21 self->ids = 0;
22 self->size = 1;
23 self->id = malloc(sizeof(u64));
24
25 if (!self->id)
26 die("nomem");
27
28 return self;
29}
30
31void perf_header_attr__add_id(struct perf_header_attr *self, u64 id)
32{
33 int pos = self->ids;
34
35 self->ids++;
36 if (self->ids > self->size) {
37 self->size *= 2;
38 self->id = realloc(self->id, self->size * sizeof(u64));
39 if (!self->id)
40 die("nomem");
41 }
42 self->id[pos] = id;
43}
44
45/*
46 *
47 */
48
49struct perf_header *perf_header__new(void)
50{
51 struct perf_header *self = malloc(sizeof(*self));
52
53 if (!self)
54 die("nomem");
55
56 self->frozen = 0;
57
58 self->attrs = 0;
59 self->size = 1;
60 self->attr = malloc(sizeof(void *));
61
62 if (!self->attr)
63 die("nomem");
64
65 self->data_offset = 0;
66 self->data_size = 0;
67
68 return self;
69}
70
71void perf_header__add_attr(struct perf_header *self,
72 struct perf_header_attr *attr)
73{
74 int pos = self->attrs;
75
76 if (self->frozen)
77 die("frozen");
78
79 self->attrs++;
80 if (self->attrs > self->size) {
81 self->size *= 2;
82 self->attr = realloc(self->attr, self->size * sizeof(void *));
83 if (!self->attr)
84 die("nomem");
85 }
86 self->attr[pos] = attr;
87}
88
89static const char *__perf_magic = "PERFFILE";
90
91#define PERF_MAGIC (*(u64 *)__perf_magic)
92
93struct perf_file_section {
94 u64 offset;
95 u64 size;
96};
97
98struct perf_file_attr {
99 struct perf_counter_attr attr;
100 struct perf_file_section ids;
101};
102
103struct perf_file_header {
104 u64 magic;
105 u64 size;
106 u64 attr_size;
107 struct perf_file_section attrs;
108 struct perf_file_section data;
109};
110
111static void do_write(int fd, void *buf, size_t size)
112{
113 while (size) {
114 int ret = write(fd, buf, size);
115
116 if (ret < 0)
117 die("failed to write");
118
119 size -= ret;
120 buf += ret;
121 }
122}
123
124void perf_header__write(struct perf_header *self, int fd)
125{
126 struct perf_file_header f_header;
127 struct perf_file_attr f_attr;
128 struct perf_header_attr *attr;
129 int i;
130
131 lseek(fd, sizeof(f_header), SEEK_SET);
132
133
134 for (i = 0; i < self->attrs; i++) {
135 attr = self->attr[i];
136
137 attr->id_offset = lseek(fd, 0, SEEK_CUR);
138 do_write(fd, attr->id, attr->ids * sizeof(u64));
139 }
140
141
142 self->attr_offset = lseek(fd, 0, SEEK_CUR);
143
144 for (i = 0; i < self->attrs; i++) {
145 attr = self->attr[i];
146
147 f_attr = (struct perf_file_attr){
148 .attr = attr->attr,
149 .ids = {
150 .offset = attr->id_offset,
151 .size = attr->ids * sizeof(u64),
152 }
153 };
154 do_write(fd, &f_attr, sizeof(f_attr));
155 }
156
157
158 self->data_offset = lseek(fd, 0, SEEK_CUR);
159
160 f_header = (struct perf_file_header){
161 .magic = PERF_MAGIC,
162 .size = sizeof(f_header),
163 .attr_size = sizeof(f_attr),
164 .attrs = {
165 .offset = self->attr_offset,
166 .size = self->attrs * sizeof(f_attr),
167 },
168 .data = {
169 .offset = self->data_offset,
170 .size = self->data_size,
171 },
172 };
173
174 lseek(fd, 0, SEEK_SET);
175 do_write(fd, &f_header, sizeof(f_header));
176 lseek(fd, self->data_offset + self->data_size, SEEK_SET);
177
178 self->frozen = 1;
179}
180
181static void do_read(int fd, void *buf, size_t size)
182{
183 while (size) {
184 int ret = read(fd, buf, size);
185
186 if (ret < 0)
187 die("failed to read");
188
189 size -= ret;
190 buf += ret;
191 }
192}
193
194struct perf_header *perf_header__read(int fd)
195{
196 struct perf_header *self = perf_header__new();
197 struct perf_file_header f_header;
198 struct perf_file_attr f_attr;
199 u64 f_id;
200
201 int nr_attrs, nr_ids, i, j;
202
203 lseek(fd, 0, SEEK_SET);
204 do_read(fd, &f_header, sizeof(f_header));
205
206 if (f_header.magic != PERF_MAGIC ||
207 f_header.size != sizeof(f_header) ||
208 f_header.attr_size != sizeof(f_attr))
209 die("incompatible file format");
210
211 nr_attrs = f_header.attrs.size / sizeof(f_attr);
212 lseek(fd, f_header.attrs.offset, SEEK_SET);
213
214 for (i = 0; i < nr_attrs; i++) {
215 struct perf_header_attr *attr;
216 off_t tmp = lseek(fd, 0, SEEK_CUR);
217
218 do_read(fd, &f_attr, sizeof(f_attr));
219
220 attr = perf_header_attr__new(&f_attr.attr);
221
222 nr_ids = f_attr.ids.size / sizeof(u64);
223 lseek(fd, f_attr.ids.offset, SEEK_SET);
224
225 for (j = 0; j < nr_ids; j++) {
226 do_read(fd, &f_id, sizeof(f_id));
227
228 perf_header_attr__add_id(attr, f_id);
229 }
230 perf_header__add_attr(self, attr);
231 lseek(fd, tmp, SEEK_SET);
232 }
233
234 self->data_offset = f_header.data.offset;
235 self->data_size = f_header.data.size;
236
237 lseek(fd, self->data_offset + self->data_size, SEEK_SET);
238
239 self->frozen = 1;
240
241 return self;
242}
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
new file mode 100644
index 000000000000..b5ef53ad4c7a
--- /dev/null
+++ b/tools/perf/util/header.h
@@ -0,0 +1,37 @@
1#ifndef _PERF_HEADER_H
2#define _PERF_HEADER_H
3
4#include "../../../include/linux/perf_counter.h"
5#include <sys/types.h>
6#include "types.h"
7
8struct perf_header_attr {
9 struct perf_counter_attr attr;
10 int ids, size;
11 u64 *id;
12 off_t id_offset;
13};
14
15struct perf_header {
16 int frozen;
17 int attrs, size;
18 struct perf_header_attr **attr;
19 off_t attr_offset;
20 u64 data_offset;
21 u64 data_size;
22};
23
24struct perf_header *perf_header__read(int fd);
25void perf_header__write(struct perf_header *self, int fd);
26
27void perf_header__add_attr(struct perf_header *self,
28 struct perf_header_attr *attr);
29
30struct perf_header_attr *
31perf_header_attr__new(struct perf_counter_attr *attr);
32void perf_header_attr__add_id(struct perf_header_attr *self, u64 id);
33
34
35struct perf_header *perf_header__new(void);
36
37#endif /* _PERF_HEADER_H */
diff --git a/tools/perf/util/help.c b/tools/perf/util/help.c
index 6653f7dd1d78..fbb00978b2e2 100644
--- a/tools/perf/util/help.c
+++ b/tools/perf/util/help.c
@@ -26,7 +26,7 @@ static int term_columns(void)
26 return 80; 26 return 80;
27} 27}
28 28
29void add_cmdname(struct cmdnames *cmds, const char *name, int len) 29void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
30{ 30{
31 struct cmdname *ent = malloc(sizeof(*ent) + len + 1); 31 struct cmdname *ent = malloc(sizeof(*ent) + len + 1);
32 32
@@ -40,7 +40,8 @@ void add_cmdname(struct cmdnames *cmds, const char *name, int len)
40 40
41static void clean_cmdnames(struct cmdnames *cmds) 41static void clean_cmdnames(struct cmdnames *cmds)
42{ 42{
43 int i; 43 unsigned int i;
44
44 for (i = 0; i < cmds->cnt; ++i) 45 for (i = 0; i < cmds->cnt; ++i)
45 free(cmds->names[i]); 46 free(cmds->names[i]);
46 free(cmds->names); 47 free(cmds->names);
@@ -57,7 +58,7 @@ static int cmdname_compare(const void *a_, const void *b_)
57 58
58static void uniq(struct cmdnames *cmds) 59static void uniq(struct cmdnames *cmds)
59{ 60{
60 int i, j; 61 unsigned int i, j;
61 62
62 if (!cmds->cnt) 63 if (!cmds->cnt)
63 return; 64 return;
@@ -71,7 +72,7 @@ static void uniq(struct cmdnames *cmds)
71 72
72void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes) 73void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
73{ 74{
74 int ci, cj, ei; 75 size_t ci, cj, ei;
75 int cmp; 76 int cmp;
76 77
77 ci = cj = ei = 0; 78 ci = cj = ei = 0;
@@ -106,8 +107,9 @@ static void pretty_print_string_list(struct cmdnames *cmds, int longest)
106 printf(" "); 107 printf(" ");
107 108
108 for (j = 0; j < cols; j++) { 109 for (j = 0; j < cols; j++) {
109 int n = j * rows + i; 110 unsigned int n = j * rows + i;
110 int size = space; 111 unsigned int size = space;
112
111 if (n >= cmds->cnt) 113 if (n >= cmds->cnt)
112 break; 114 break;
113 if (j == cols-1 || n + rows >= cmds->cnt) 115 if (j == cols-1 || n + rows >= cmds->cnt)
@@ -126,21 +128,6 @@ static int is_executable(const char *name)
126 !S_ISREG(st.st_mode)) 128 !S_ISREG(st.st_mode))
127 return 0; 129 return 0;
128 130
129#ifdef __MINGW32__
130 /* cannot trust the executable bit, peek into the file instead */
131 char buf[3] = { 0 };
132 int n;
133 int fd = open(name, O_RDONLY);
134 st.st_mode &= ~S_IXUSR;
135 if (fd >= 0) {
136 n = read(fd, buf, 2);
137 if (n == 2)
138 /* DOS executables start with "MZ" */
139 if (!strcmp(buf, "#!") || !strcmp(buf, "MZ"))
140 st.st_mode |= S_IXUSR;
141 close(fd);
142 }
143#endif
144 return st.st_mode & S_IXUSR; 131 return st.st_mode & S_IXUSR;
145} 132}
146 133
@@ -223,7 +210,7 @@ void load_command_list(const char *prefix,
223void list_commands(const char *title, struct cmdnames *main_cmds, 210void list_commands(const char *title, struct cmdnames *main_cmds,
224 struct cmdnames *other_cmds) 211 struct cmdnames *other_cmds)
225{ 212{
226 int i, longest = 0; 213 unsigned int i, longest = 0;
227 214
228 for (i = 0; i < main_cmds->cnt; i++) 215 for (i = 0; i < main_cmds->cnt; i++)
229 if (longest < main_cmds->names[i]->len) 216 if (longest < main_cmds->names[i]->len)
@@ -254,7 +241,8 @@ void list_commands(const char *title, struct cmdnames *main_cmds,
254 241
255int is_in_cmdlist(struct cmdnames *c, const char *s) 242int is_in_cmdlist(struct cmdnames *c, const char *s)
256{ 243{
257 int i; 244 unsigned int i;
245
258 for (i = 0; i < c->cnt; i++) 246 for (i = 0; i < c->cnt; i++)
259 if (!strcmp(s, c->names[i]->name)) 247 if (!strcmp(s, c->names[i]->name))
260 return 1; 248 return 1;
@@ -286,7 +274,8 @@ static int levenshtein_compare(const void *p1, const void *p2)
286 274
287static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old) 275static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old)
288{ 276{
289 int i; 277 unsigned int i;
278
290 ALLOC_GROW(cmds->names, cmds->cnt + old->cnt, cmds->alloc); 279 ALLOC_GROW(cmds->names, cmds->cnt + old->cnt, cmds->alloc);
291 280
292 for (i = 0; i < old->cnt; i++) 281 for (i = 0; i < old->cnt; i++)
@@ -298,7 +287,7 @@ static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old)
298 287
299const char *help_unknown_cmd(const char *cmd) 288const char *help_unknown_cmd(const char *cmd)
300{ 289{
301 int i, n = 0, best_similarity = 0; 290 unsigned int i, n = 0, best_similarity = 0;
302 struct cmdnames main_cmds, other_cmds; 291 struct cmdnames main_cmds, other_cmds;
303 292
304 memset(&main_cmds, 0, sizeof(main_cmds)); 293 memset(&main_cmds, 0, sizeof(main_cmds));
@@ -360,7 +349,7 @@ const char *help_unknown_cmd(const char *cmd)
360 exit(1); 349 exit(1);
361} 350}
362 351
363int cmd_version(int argc, const char **argv, const char *prefix) 352int cmd_version(int argc __used, const char **argv __used, const char *prefix __used)
364{ 353{
365 printf("perf version %s\n", perf_version_string); 354 printf("perf version %s\n", perf_version_string);
366 return 0; 355 return 0;
diff --git a/tools/perf/util/help.h b/tools/perf/util/help.h
index 56bc15406ffc..7128783637b4 100644
--- a/tools/perf/util/help.h
+++ b/tools/perf/util/help.h
@@ -2,8 +2,8 @@
2#define HELP_H 2#define HELP_H
3 3
4struct cmdnames { 4struct cmdnames {
5 int alloc; 5 size_t alloc;
6 int cnt; 6 size_t cnt;
7 struct cmdname { 7 struct cmdname {
8 size_t len; /* also used for similarity index in help.c */ 8 size_t len; /* also used for similarity index in help.c */
9 char name[FLEX_ARRAY]; 9 char name[FLEX_ARRAY];
@@ -19,7 +19,7 @@ static inline void mput_char(char c, unsigned int num)
19void load_command_list(const char *prefix, 19void load_command_list(const char *prefix,
20 struct cmdnames *main_cmds, 20 struct cmdnames *main_cmds,
21 struct cmdnames *other_cmds); 21 struct cmdnames *other_cmds);
22void add_cmdname(struct cmdnames *cmds, const char *name, int len); 22void add_cmdname(struct cmdnames *cmds, const char *name, size_t len);
23/* Here we require that excludes is a sorted list. */ 23/* Here we require that excludes is a sorted list. */
24void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes); 24void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);
25int is_in_cmdlist(struct cmdnames *c, const char *s); 25int is_in_cmdlist(struct cmdnames *c, const char *s);
diff --git a/tools/perf/util/include/asm/system.h b/tools/perf/util/include/asm/system.h
new file mode 100644
index 000000000000..710cecca972d
--- /dev/null
+++ b/tools/perf/util/include/asm/system.h
@@ -0,0 +1 @@
/* Empty */
diff --git a/tools/perf/util/include/linux/kernel.h b/tools/perf/util/include/linux/kernel.h
new file mode 100644
index 000000000000..99c1b3d1edd9
--- /dev/null
+++ b/tools/perf/util/include/linux/kernel.h
@@ -0,0 +1,21 @@
1#ifndef PERF_LINUX_KERNEL_H_
2#define PERF_LINUX_KERNEL_H_
3
4#ifndef offsetof
5#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
6#endif
7
8#ifndef container_of
9/**
10 * container_of - cast a member of a structure out to the containing structure
11 * @ptr: the pointer to the member.
12 * @type: the type of the container struct this is embedded in.
13 * @member: the name of the member within the struct.
14 *
15 */
16#define container_of(ptr, type, member) ({ \
17 const typeof(((type *)0)->member) * __mptr = (ptr); \
18 (type *)((char *)__mptr - offsetof(type, member)); })
19#endif
20
21#endif
diff --git a/tools/perf/util/include/linux/list.h b/tools/perf/util/include/linux/list.h
new file mode 100644
index 000000000000..dbe4b814382a
--- /dev/null
+++ b/tools/perf/util/include/linux/list.h
@@ -0,0 +1,18 @@
1#include "../../../../include/linux/list.h"
2
3#ifndef PERF_LIST_H
4#define PERF_LIST_H
5/**
6 * list_del_range - deletes range of entries from list.
7 * @begin: first element in the range to delete from the list.
8 * @end: last element in the range to delete from the list.
9 * Note: list_empty on the range of entries does not return true after this,
10 * the entries is in an undefined state.
11 */
12static inline void list_del_range(struct list_head *begin,
13 struct list_head *end)
14{
15 begin->prev->next = end->next;
16 end->next->prev = begin->prev;
17}
18#endif
diff --git a/tools/perf/util/include/linux/module.h b/tools/perf/util/include/linux/module.h
new file mode 100644
index 000000000000..b43e2dc21e04
--- /dev/null
+++ b/tools/perf/util/include/linux/module.h
@@ -0,0 +1,6 @@
1#ifndef PERF_LINUX_MODULE_H
2#define PERF_LINUX_MODULE_H
3
4#define EXPORT_SYMBOL(name)
5
6#endif
diff --git a/tools/perf/util/include/linux/poison.h b/tools/perf/util/include/linux/poison.h
new file mode 100644
index 000000000000..fef6dbc9ce13
--- /dev/null
+++ b/tools/perf/util/include/linux/poison.h
@@ -0,0 +1 @@
#include "../../../../include/linux/poison.h"
diff --git a/tools/perf/util/include/linux/prefetch.h b/tools/perf/util/include/linux/prefetch.h
new file mode 100644
index 000000000000..7841e485d8c3
--- /dev/null
+++ b/tools/perf/util/include/linux/prefetch.h
@@ -0,0 +1,6 @@
1#ifndef PERF_LINUX_PREFETCH_H
2#define PERF_LINUX_PREFETCH_H
3
4static inline void prefetch(void *a __attribute__((unused))) { }
5
6#endif
diff --git a/tools/perf/util/include/linux/rbtree.h b/tools/perf/util/include/linux/rbtree.h
new file mode 100644
index 000000000000..7a243a143037
--- /dev/null
+++ b/tools/perf/util/include/linux/rbtree.h
@@ -0,0 +1 @@
#include "../../../../include/linux/rbtree.h"
diff --git a/tools/perf/util/list.h b/tools/perf/util/list.h
deleted file mode 100644
index e2548e8072cf..000000000000
--- a/tools/perf/util/list.h
+++ /dev/null
@@ -1,603 +0,0 @@
1#ifndef _LINUX_LIST_H
2#define _LINUX_LIST_H
3/*
4 Copyright (C) Cast of dozens, comes from the Linux kernel
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of version 2 of the GNU General Public License as
8 published by the Free Software Foundation.
9*/
10
11#include <stddef.h>
12
13/*
14 * These are non-NULL pointers that will result in page faults
15 * under normal circumstances, used to verify that nobody uses
16 * non-initialized list entries.
17 */
18#define LIST_POISON1 ((void *)0x00100100)
19#define LIST_POISON2 ((void *)0x00200200)
20
21/**
22 * container_of - cast a member of a structure out to the containing structure
23 * @ptr: the pointer to the member.
24 * @type: the type of the container struct this is embedded in.
25 * @member: the name of the member within the struct.
26 *
27 */
28#define container_of(ptr, type, member) ({ \
29 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
30 (type *)( (char *)__mptr - offsetof(type,member) );})
31
32/*
33 * Simple doubly linked list implementation.
34 *
35 * Some of the internal functions ("__xxx") are useful when
36 * manipulating whole lists rather than single entries, as
37 * sometimes we already know the next/prev entries and we can
38 * generate better code by using them directly rather than
39 * using the generic single-entry routines.
40 */
41
42struct list_head {
43 struct list_head *next, *prev;
44};
45
46#define LIST_HEAD_INIT(name) { &(name), &(name) }
47
48#define LIST_HEAD(name) \
49 struct list_head name = LIST_HEAD_INIT(name)
50
51static inline void INIT_LIST_HEAD(struct list_head *list)
52{
53 list->next = list;
54 list->prev = list;
55}
56
57/*
58 * Insert a new entry between two known consecutive entries.
59 *
60 * This is only for internal list manipulation where we know
61 * the prev/next entries already!
62 */
63static inline void __list_add(struct list_head *new,
64 struct list_head *prev,
65 struct list_head *next)
66{
67 next->prev = new;
68 new->next = next;
69 new->prev = prev;
70 prev->next = new;
71}
72
73/**
74 * list_add - add a new entry
75 * @new: new entry to be added
76 * @head: list head to add it after
77 *
78 * Insert a new entry after the specified head.
79 * This is good for implementing stacks.
80 */
81static inline void list_add(struct list_head *new, struct list_head *head)
82{
83 __list_add(new, head, head->next);
84}
85
86/**
87 * list_add_tail - add a new entry
88 * @new: new entry to be added
89 * @head: list head to add it before
90 *
91 * Insert a new entry before the specified head.
92 * This is useful for implementing queues.
93 */
94static inline void list_add_tail(struct list_head *new, struct list_head *head)
95{
96 __list_add(new, head->prev, head);
97}
98
99/*
100 * Delete a list entry by making the prev/next entries
101 * point to each other.
102 *
103 * This is only for internal list manipulation where we know
104 * the prev/next entries already!
105 */
106static inline void __list_del(struct list_head * prev, struct list_head * next)
107{
108 next->prev = prev;
109 prev->next = next;
110}
111
112/**
113 * list_del - deletes entry from list.
114 * @entry: the element to delete from the list.
115 * Note: list_empty on entry does not return true after this, the entry is
116 * in an undefined state.
117 */
118static inline void list_del(struct list_head *entry)
119{
120 __list_del(entry->prev, entry->next);
121 entry->next = LIST_POISON1;
122 entry->prev = LIST_POISON2;
123}
124
125/**
126 * list_del_range - deletes range of entries from list.
127 * @beging: first element in the range to delete from the list.
128 * @beging: first element in the range to delete from the list.
129 * Note: list_empty on the range of entries does not return true after this,
130 * the entries is in an undefined state.
131 */
132static inline void list_del_range(struct list_head *begin,
133 struct list_head *end)
134{
135 begin->prev->next = end->next;
136 end->next->prev = begin->prev;
137}
138
139/**
140 * list_replace - replace old entry by new one
141 * @old : the element to be replaced
142 * @new : the new element to insert
143 * Note: if 'old' was empty, it will be overwritten.
144 */
145static inline void list_replace(struct list_head *old,
146 struct list_head *new)
147{
148 new->next = old->next;
149 new->next->prev = new;
150 new->prev = old->prev;
151 new->prev->next = new;
152}
153
154static inline void list_replace_init(struct list_head *old,
155 struct list_head *new)
156{
157 list_replace(old, new);
158 INIT_LIST_HEAD(old);
159}
160
161/**
162 * list_del_init - deletes entry from list and reinitialize it.
163 * @entry: the element to delete from the list.
164 */
165static inline void list_del_init(struct list_head *entry)
166{
167 __list_del(entry->prev, entry->next);
168 INIT_LIST_HEAD(entry);
169}
170
171/**
172 * list_move - delete from one list and add as another's head
173 * @list: the entry to move
174 * @head: the head that will precede our entry
175 */
176static inline void list_move(struct list_head *list, struct list_head *head)
177{
178 __list_del(list->prev, list->next);
179 list_add(list, head);
180}
181
182/**
183 * list_move_tail - delete from one list and add as another's tail
184 * @list: the entry to move
185 * @head: the head that will follow our entry
186 */
187static inline void list_move_tail(struct list_head *list,
188 struct list_head *head)
189{
190 __list_del(list->prev, list->next);
191 list_add_tail(list, head);
192}
193
194/**
195 * list_is_last - tests whether @list is the last entry in list @head
196 * @list: the entry to test
197 * @head: the head of the list
198 */
199static inline int list_is_last(const struct list_head *list,
200 const struct list_head *head)
201{
202 return list->next == head;
203}
204
205/**
206 * list_empty - tests whether a list is empty
207 * @head: the list to test.
208 */
209static inline int list_empty(const struct list_head *head)
210{
211 return head->next == head;
212}
213
214/**
215 * list_empty_careful - tests whether a list is empty and not being modified
216 * @head: the list to test
217 *
218 * Description:
219 * tests whether a list is empty _and_ checks that no other CPU might be
220 * in the process of modifying either member (next or prev)
221 *
222 * NOTE: using list_empty_careful() without synchronization
223 * can only be safe if the only activity that can happen
224 * to the list entry is list_del_init(). Eg. it cannot be used
225 * if another CPU could re-list_add() it.
226 */
227static inline int list_empty_careful(const struct list_head *head)
228{
229 struct list_head *next = head->next;
230 return (next == head) && (next == head->prev);
231}
232
233static inline void __list_splice(struct list_head *list,
234 struct list_head *head)
235{
236 struct list_head *first = list->next;
237 struct list_head *last = list->prev;
238 struct list_head *at = head->next;
239
240 first->prev = head;
241 head->next = first;
242
243 last->next = at;
244 at->prev = last;
245}
246
247/**
248 * list_splice - join two lists
249 * @list: the new list to add.
250 * @head: the place to add it in the first list.
251 */
252static inline void list_splice(struct list_head *list, struct list_head *head)
253{
254 if (!list_empty(list))
255 __list_splice(list, head);
256}
257
258/**
259 * list_splice_init - join two lists and reinitialise the emptied list.
260 * @list: the new list to add.
261 * @head: the place to add it in the first list.
262 *
263 * The list at @list is reinitialised
264 */
265static inline void list_splice_init(struct list_head *list,
266 struct list_head *head)
267{
268 if (!list_empty(list)) {
269 __list_splice(list, head);
270 INIT_LIST_HEAD(list);
271 }
272}
273
274/**
275 * list_entry - get the struct for this entry
276 * @ptr: the &struct list_head pointer.
277 * @type: the type of the struct this is embedded in.
278 * @member: the name of the list_struct within the struct.
279 */
280#define list_entry(ptr, type, member) \
281 container_of(ptr, type, member)
282
283/**
284 * list_first_entry - get the first element from a list
285 * @ptr: the list head to take the element from.
286 * @type: the type of the struct this is embedded in.
287 * @member: the name of the list_struct within the struct.
288 *
289 * Note, that list is expected to be not empty.
290 */
291#define list_first_entry(ptr, type, member) \
292 list_entry((ptr)->next, type, member)
293
294/**
295 * list_for_each - iterate over a list
296 * @pos: the &struct list_head to use as a loop cursor.
297 * @head: the head for your list.
298 */
299#define list_for_each(pos, head) \
300 for (pos = (head)->next; pos != (head); \
301 pos = pos->next)
302
303/**
304 * __list_for_each - iterate over a list
305 * @pos: the &struct list_head to use as a loop cursor.
306 * @head: the head for your list.
307 *
308 * This variant differs from list_for_each() in that it's the
309 * simplest possible list iteration code, no prefetching is done.
310 * Use this for code that knows the list to be very short (empty
311 * or 1 entry) most of the time.
312 */
313#define __list_for_each(pos, head) \
314 for (pos = (head)->next; pos != (head); pos = pos->next)
315
316/**
317 * list_for_each_prev - iterate over a list backwards
318 * @pos: the &struct list_head to use as a loop cursor.
319 * @head: the head for your list.
320 */
321#define list_for_each_prev(pos, head) \
322 for (pos = (head)->prev; pos != (head); \
323 pos = pos->prev)
324
325/**
326 * list_for_each_safe - iterate over a list safe against removal of list entry
327 * @pos: the &struct list_head to use as a loop cursor.
328 * @n: another &struct list_head to use as temporary storage
329 * @head: the head for your list.
330 */
331#define list_for_each_safe(pos, n, head) \
332 for (pos = (head)->next, n = pos->next; pos != (head); \
333 pos = n, n = pos->next)
334
335/**
336 * list_for_each_entry - iterate over list of given type
337 * @pos: the type * to use as a loop cursor.
338 * @head: the head for your list.
339 * @member: the name of the list_struct within the struct.
340 */
341#define list_for_each_entry(pos, head, member) \
342 for (pos = list_entry((head)->next, typeof(*pos), member); \
343 &pos->member != (head); \
344 pos = list_entry(pos->member.next, typeof(*pos), member))
345
346/**
347 * list_for_each_entry_reverse - iterate backwards over list of given type.
348 * @pos: the type * to use as a loop cursor.
349 * @head: the head for your list.
350 * @member: the name of the list_struct within the struct.
351 */
352#define list_for_each_entry_reverse(pos, head, member) \
353 for (pos = list_entry((head)->prev, typeof(*pos), member); \
354 &pos->member != (head); \
355 pos = list_entry(pos->member.prev, typeof(*pos), member))
356
357/**
358 * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue
359 * @pos: the type * to use as a start point
360 * @head: the head of the list
361 * @member: the name of the list_struct within the struct.
362 *
363 * Prepares a pos entry for use as a start point in list_for_each_entry_continue.
364 */
365#define list_prepare_entry(pos, head, member) \
366 ((pos) ? : list_entry(head, typeof(*pos), member))
367
368/**
369 * list_for_each_entry_continue - continue iteration over list of given type
370 * @pos: the type * to use as a loop cursor.
371 * @head: the head for your list.
372 * @member: the name of the list_struct within the struct.
373 *
374 * Continue to iterate over list of given type, continuing after
375 * the current position.
376 */
377#define list_for_each_entry_continue(pos, head, member) \
378 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
379 &pos->member != (head); \
380 pos = list_entry(pos->member.next, typeof(*pos), member))
381
382/**
383 * list_for_each_entry_from - iterate over list of given type from the current point
384 * @pos: the type * to use as a loop cursor.
385 * @head: the head for your list.
386 * @member: the name of the list_struct within the struct.
387 *
388 * Iterate over list of given type, continuing from current position.
389 */
390#define list_for_each_entry_from(pos, head, member) \
391 for (; &pos->member != (head); \
392 pos = list_entry(pos->member.next, typeof(*pos), member))
393
394/**
395 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
396 * @pos: the type * to use as a loop cursor.
397 * @n: another type * to use as temporary storage
398 * @head: the head for your list.
399 * @member: the name of the list_struct within the struct.
400 */
401#define list_for_each_entry_safe(pos, n, head, member) \
402 for (pos = list_entry((head)->next, typeof(*pos), member), \
403 n = list_entry(pos->member.next, typeof(*pos), member); \
404 &pos->member != (head); \
405 pos = n, n = list_entry(n->member.next, typeof(*n), member))
406
407/**
408 * list_for_each_entry_safe_continue
409 * @pos: the type * to use as a loop cursor.
410 * @n: another type * to use as temporary storage
411 * @head: the head for your list.
412 * @member: the name of the list_struct within the struct.
413 *
414 * Iterate over list of given type, continuing after current point,
415 * safe against removal of list entry.
416 */
417#define list_for_each_entry_safe_continue(pos, n, head, member) \
418 for (pos = list_entry(pos->member.next, typeof(*pos), member), \
419 n = list_entry(pos->member.next, typeof(*pos), member); \
420 &pos->member != (head); \
421 pos = n, n = list_entry(n->member.next, typeof(*n), member))
422
423/**
424 * list_for_each_entry_safe_from
425 * @pos: the type * to use as a loop cursor.
426 * @n: another type * to use as temporary storage
427 * @head: the head for your list.
428 * @member: the name of the list_struct within the struct.
429 *
430 * Iterate over list of given type from current point, safe against
431 * removal of list entry.
432 */
433#define list_for_each_entry_safe_from(pos, n, head, member) \
434 for (n = list_entry(pos->member.next, typeof(*pos), member); \
435 &pos->member != (head); \
436 pos = n, n = list_entry(n->member.next, typeof(*n), member))
437
438/**
439 * list_for_each_entry_safe_reverse
440 * @pos: the type * to use as a loop cursor.
441 * @n: another type * to use as temporary storage
442 * @head: the head for your list.
443 * @member: the name of the list_struct within the struct.
444 *
445 * Iterate backwards over list of given type, safe against removal
446 * of list entry.
447 */
448#define list_for_each_entry_safe_reverse(pos, n, head, member) \
449 for (pos = list_entry((head)->prev, typeof(*pos), member), \
450 n = list_entry(pos->member.prev, typeof(*pos), member); \
451 &pos->member != (head); \
452 pos = n, n = list_entry(n->member.prev, typeof(*n), member))
453
454/*
455 * Double linked lists with a single pointer list head.
456 * Mostly useful for hash tables where the two pointer list head is
457 * too wasteful.
458 * You lose the ability to access the tail in O(1).
459 */
460
461struct hlist_head {
462 struct hlist_node *first;
463};
464
465struct hlist_node {
466 struct hlist_node *next, **pprev;
467};
468
469#define HLIST_HEAD_INIT { .first = NULL }
470#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
471#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
472static inline void INIT_HLIST_NODE(struct hlist_node *h)
473{
474 h->next = NULL;
475 h->pprev = NULL;
476}
477
478static inline int hlist_unhashed(const struct hlist_node *h)
479{
480 return !h->pprev;
481}
482
483static inline int hlist_empty(const struct hlist_head *h)
484{
485 return !h->first;
486}
487
488static inline void __hlist_del(struct hlist_node *n)
489{
490 struct hlist_node *next = n->next;
491 struct hlist_node **pprev = n->pprev;
492 *pprev = next;
493 if (next)
494 next->pprev = pprev;
495}
496
497static inline void hlist_del(struct hlist_node *n)
498{
499 __hlist_del(n);
500 n->next = LIST_POISON1;
501 n->pprev = LIST_POISON2;
502}
503
504static inline void hlist_del_init(struct hlist_node *n)
505{
506 if (!hlist_unhashed(n)) {
507 __hlist_del(n);
508 INIT_HLIST_NODE(n);
509 }
510}
511
512static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
513{
514 struct hlist_node *first = h->first;
515 n->next = first;
516 if (first)
517 first->pprev = &n->next;
518 h->first = n;
519 n->pprev = &h->first;
520}
521
522/* next must be != NULL */
523static inline void hlist_add_before(struct hlist_node *n,
524 struct hlist_node *next)
525{
526 n->pprev = next->pprev;
527 n->next = next;
528 next->pprev = &n->next;
529 *(n->pprev) = n;
530}
531
532static inline void hlist_add_after(struct hlist_node *n,
533 struct hlist_node *next)
534{
535 next->next = n->next;
536 n->next = next;
537 next->pprev = &n->next;
538
539 if(next->next)
540 next->next->pprev = &next->next;
541}
542
543#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
544
545#define hlist_for_each(pos, head) \
546 for (pos = (head)->first; pos; \
547 pos = pos->next)
548
549#define hlist_for_each_safe(pos, n, head) \
550 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
551 pos = n)
552
553/**
554 * hlist_for_each_entry - iterate over list of given type
555 * @tpos: the type * to use as a loop cursor.
556 * @pos: the &struct hlist_node to use as a loop cursor.
557 * @head: the head for your list.
558 * @member: the name of the hlist_node within the struct.
559 */
560#define hlist_for_each_entry(tpos, pos, head, member) \
561 for (pos = (head)->first; \
562 pos && \
563 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
564 pos = pos->next)
565
566/**
567 * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
568 * @tpos: the type * to use as a loop cursor.
569 * @pos: the &struct hlist_node to use as a loop cursor.
570 * @member: the name of the hlist_node within the struct.
571 */
572#define hlist_for_each_entry_continue(tpos, pos, member) \
573 for (pos = (pos)->next; \
574 pos && \
575 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
576 pos = pos->next)
577
578/**
579 * hlist_for_each_entry_from - iterate over a hlist continuing from current point
580 * @tpos: the type * to use as a loop cursor.
581 * @pos: the &struct hlist_node to use as a loop cursor.
582 * @member: the name of the hlist_node within the struct.
583 */
584#define hlist_for_each_entry_from(tpos, pos, member) \
585 for (; pos && \
586 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
587 pos = pos->next)
588
589/**
590 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
591 * @tpos: the type * to use as a loop cursor.
592 * @pos: the &struct hlist_node to use as a loop cursor.
593 * @n: another &struct hlist_node to use as temporary storage
594 * @head: the head for your list.
595 * @member: the name of the hlist_node within the struct.
596 */
597#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
598 for (pos = (head)->first; \
599 pos && ({ n = pos->next; 1; }) && \
600 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
601 pos = n)
602
603#endif
diff --git a/tools/perf/util/module.c b/tools/perf/util/module.c
new file mode 100644
index 000000000000..ddabe925d65d
--- /dev/null
+++ b/tools/perf/util/module.c
@@ -0,0 +1,509 @@
1#include "util.h"
2#include "../perf.h"
3#include "string.h"
4#include "module.h"
5
6#include <libelf.h>
7#include <gelf.h>
8#include <elf.h>
9#include <dirent.h>
10#include <sys/utsname.h>
11
12static unsigned int crc32(const char *p, unsigned int len)
13{
14 int i;
15 unsigned int crc = 0;
16
17 while (len--) {
18 crc ^= *p++;
19 for (i = 0; i < 8; i++)
20 crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
21 }
22 return crc;
23}
24
25/* module section methods */
26
27struct sec_dso *sec_dso__new_dso(const char *name)
28{
29 struct sec_dso *self = malloc(sizeof(*self) + strlen(name) + 1);
30
31 if (self != NULL) {
32 strcpy(self->name, name);
33 self->secs = RB_ROOT;
34 self->find_section = sec_dso__find_section;
35 }
36
37 return self;
38}
39
40static void sec_dso__delete_section(struct section *self)
41{
42 free(((void *)self));
43}
44
45void sec_dso__delete_sections(struct sec_dso *self)
46{
47 struct section *pos;
48 struct rb_node *next = rb_first(&self->secs);
49
50 while (next) {
51 pos = rb_entry(next, struct section, rb_node);
52 next = rb_next(&pos->rb_node);
53 rb_erase(&pos->rb_node, &self->secs);
54 sec_dso__delete_section(pos);
55 }
56}
57
58void sec_dso__delete_self(struct sec_dso *self)
59{
60 sec_dso__delete_sections(self);
61 free(self);
62}
63
64static void sec_dso__insert_section(struct sec_dso *self, struct section *sec)
65{
66 struct rb_node **p = &self->secs.rb_node;
67 struct rb_node *parent = NULL;
68 const u64 hash = sec->hash;
69 struct section *s;
70
71 while (*p != NULL) {
72 parent = *p;
73 s = rb_entry(parent, struct section, rb_node);
74 if (hash < s->hash)
75 p = &(*p)->rb_left;
76 else
77 p = &(*p)->rb_right;
78 }
79 rb_link_node(&sec->rb_node, parent, p);
80 rb_insert_color(&sec->rb_node, &self->secs);
81}
82
83struct section *sec_dso__find_section(struct sec_dso *self, const char *name)
84{
85 struct rb_node *n;
86 u64 hash;
87 int len;
88
89 if (self == NULL)
90 return NULL;
91
92 len = strlen(name);
93 hash = crc32(name, len);
94
95 n = self->secs.rb_node;
96
97 while (n) {
98 struct section *s = rb_entry(n, struct section, rb_node);
99
100 if (hash < s->hash)
101 n = n->rb_left;
102 else if (hash > s->hash)
103 n = n->rb_right;
104 else {
105 if (!strcmp(name, s->name))
106 return s;
107 else
108 n = rb_next(&s->rb_node);
109 }
110 }
111
112 return NULL;
113}
114
115static size_t sec_dso__fprintf_section(struct section *self, FILE *fp)
116{
117 return fprintf(fp, "name:%s vma:%llx path:%s\n",
118 self->name, self->vma, self->path);
119}
120
121size_t sec_dso__fprintf(struct sec_dso *self, FILE *fp)
122{
123 size_t ret = fprintf(fp, "dso: %s\n", self->name);
124
125 struct rb_node *nd;
126 for (nd = rb_first(&self->secs); nd; nd = rb_next(nd)) {
127 struct section *pos = rb_entry(nd, struct section, rb_node);
128 ret += sec_dso__fprintf_section(pos, fp);
129 }
130
131 return ret;
132}
133
134static struct section *section__new(const char *name, const char *path)
135{
136 struct section *self = calloc(1, sizeof(*self));
137
138 if (!self)
139 goto out_failure;
140
141 self->name = calloc(1, strlen(name) + 1);
142 if (!self->name)
143 goto out_failure;
144
145 self->path = calloc(1, strlen(path) + 1);
146 if (!self->path)
147 goto out_failure;
148
149 strcpy(self->name, name);
150 strcpy(self->path, path);
151 self->hash = crc32(self->name, strlen(name));
152
153 return self;
154
155out_failure:
156 if (self) {
157 if (self->name)
158 free(self->name);
159 if (self->path)
160 free(self->path);
161 free(self);
162 }
163
164 return NULL;
165}
166
167/* module methods */
168
169struct mod_dso *mod_dso__new_dso(const char *name)
170{
171 struct mod_dso *self = malloc(sizeof(*self) + strlen(name) + 1);
172
173 if (self != NULL) {
174 strcpy(self->name, name);
175 self->mods = RB_ROOT;
176 self->find_module = mod_dso__find_module;
177 }
178
179 return self;
180}
181
182static void mod_dso__delete_module(struct module *self)
183{
184 free(((void *)self));
185}
186
187void mod_dso__delete_modules(struct mod_dso *self)
188{
189 struct module *pos;
190 struct rb_node *next = rb_first(&self->mods);
191
192 while (next) {
193 pos = rb_entry(next, struct module, rb_node);
194 next = rb_next(&pos->rb_node);
195 rb_erase(&pos->rb_node, &self->mods);
196 mod_dso__delete_module(pos);
197 }
198}
199
200void mod_dso__delete_self(struct mod_dso *self)
201{
202 mod_dso__delete_modules(self);
203 free(self);
204}
205
206static void mod_dso__insert_module(struct mod_dso *self, struct module *mod)
207{
208 struct rb_node **p = &self->mods.rb_node;
209 struct rb_node *parent = NULL;
210 const u64 hash = mod->hash;
211 struct module *m;
212
213 while (*p != NULL) {
214 parent = *p;
215 m = rb_entry(parent, struct module, rb_node);
216 if (hash < m->hash)
217 p = &(*p)->rb_left;
218 else
219 p = &(*p)->rb_right;
220 }
221 rb_link_node(&mod->rb_node, parent, p);
222 rb_insert_color(&mod->rb_node, &self->mods);
223}
224
225struct module *mod_dso__find_module(struct mod_dso *self, const char *name)
226{
227 struct rb_node *n;
228 u64 hash;
229 int len;
230
231 if (self == NULL)
232 return NULL;
233
234 len = strlen(name);
235 hash = crc32(name, len);
236
237 n = self->mods.rb_node;
238
239 while (n) {
240 struct module *m = rb_entry(n, struct module, rb_node);
241
242 if (hash < m->hash)
243 n = n->rb_left;
244 else if (hash > m->hash)
245 n = n->rb_right;
246 else {
247 if (!strcmp(name, m->name))
248 return m;
249 else
250 n = rb_next(&m->rb_node);
251 }
252 }
253
254 return NULL;
255}
256
257static size_t mod_dso__fprintf_module(struct module *self, FILE *fp)
258{
259 return fprintf(fp, "name:%s path:%s\n", self->name, self->path);
260}
261
262size_t mod_dso__fprintf(struct mod_dso *self, FILE *fp)
263{
264 struct rb_node *nd;
265 size_t ret;
266
267 ret = fprintf(fp, "dso: %s\n", self->name);
268
269 for (nd = rb_first(&self->mods); nd; nd = rb_next(nd)) {
270 struct module *pos = rb_entry(nd, struct module, rb_node);
271
272 ret += mod_dso__fprintf_module(pos, fp);
273 }
274
275 return ret;
276}
277
278static struct module *module__new(const char *name, const char *path)
279{
280 struct module *self = calloc(1, sizeof(*self));
281
282 if (!self)
283 goto out_failure;
284
285 self->name = calloc(1, strlen(name) + 1);
286 if (!self->name)
287 goto out_failure;
288
289 self->path = calloc(1, strlen(path) + 1);
290 if (!self->path)
291 goto out_failure;
292
293 strcpy(self->name, name);
294 strcpy(self->path, path);
295 self->hash = crc32(self->name, strlen(name));
296
297 return self;
298
299out_failure:
300 if (self) {
301 if (self->name)
302 free(self->name);
303 if (self->path)
304 free(self->path);
305 free(self);
306 }
307
308 return NULL;
309}
310
311static int mod_dso__load_sections(struct module *mod)
312{
313 int count = 0, path_len;
314 struct dirent *entry;
315 char *line = NULL;
316 char *dir_path;
317 DIR *dir;
318 size_t n;
319
320 path_len = strlen("/sys/module/");
321 path_len += strlen(mod->name);
322 path_len += strlen("/sections/");
323
324 dir_path = calloc(1, path_len + 1);
325 if (dir_path == NULL)
326 goto out_failure;
327
328 strcat(dir_path, "/sys/module/");
329 strcat(dir_path, mod->name);
330 strcat(dir_path, "/sections/");
331
332 dir = opendir(dir_path);
333 if (dir == NULL)
334 goto out_free;
335
336 while ((entry = readdir(dir))) {
337 struct section *section;
338 char *path, *vma;
339 int line_len;
340 FILE *file;
341
342 if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name))
343 continue;
344
345 path = calloc(1, path_len + strlen(entry->d_name) + 1);
346 if (path == NULL)
347 break;
348 strcat(path, dir_path);
349 strcat(path, entry->d_name);
350
351 file = fopen(path, "r");
352 if (file == NULL) {
353 free(path);
354 break;
355 }
356
357 line_len = getline(&line, &n, file);
358 if (line_len < 0) {
359 free(path);
360 fclose(file);
361 break;
362 }
363
364 if (!line) {
365 free(path);
366 fclose(file);
367 break;
368 }
369
370 line[--line_len] = '\0'; /* \n */
371
372 vma = strstr(line, "0x");
373 if (!vma) {
374 free(path);
375 fclose(file);
376 break;
377 }
378 vma += 2;
379
380 section = section__new(entry->d_name, path);
381 if (!section) {
382 fprintf(stderr, "load_sections: allocation error\n");
383 free(path);
384 fclose(file);
385 break;
386 }
387
388 hex2u64(vma, &section->vma);
389 sec_dso__insert_section(mod->sections, section);
390
391 free(path);
392 fclose(file);
393 count++;
394 }
395
396 closedir(dir);
397 free(line);
398 free(dir_path);
399
400 return count;
401
402out_free:
403 free(dir_path);
404
405out_failure:
406 return count;
407}
408
409static int mod_dso__load_module_paths(struct mod_dso *self)
410{
411 struct utsname uts;
412 int count = 0, len;
413 char *line = NULL;
414 FILE *file;
415 char *path;
416 size_t n;
417
418 if (uname(&uts) < 0)
419 goto out_failure;
420
421 len = strlen("/lib/modules/");
422 len += strlen(uts.release);
423 len += strlen("/modules.dep");
424
425 path = calloc(1, len);
426 if (path == NULL)
427 goto out_failure;
428
429 strcat(path, "/lib/modules/");
430 strcat(path, uts.release);
431 strcat(path, "/modules.dep");
432
433 file = fopen(path, "r");
434 free(path);
435 if (file == NULL)
436 goto out_failure;
437
438 while (!feof(file)) {
439 char *path, *name, *tmp;
440 struct module *module;
441 int line_len, len;
442
443 line_len = getline(&line, &n, file);
444 if (line_len < 0)
445 break;
446
447 if (!line)
448 goto out_failure;
449
450 line[--line_len] = '\0'; /* \n */
451
452 path = strtok(line, ":");
453 if (!path)
454 goto out_failure;
455
456 name = strdup(path);
457 name = strtok(name, "/");
458
459 tmp = name;
460
461 while (tmp) {
462 tmp = strtok(NULL, "/");
463 if (tmp)
464 name = tmp;
465 }
466 name = strsep(&name, ".");
467
468 /* Quirk: replace '-' with '_' in sound modules */
469 for (len = strlen(name); len; len--) {
470 if (*(name+len) == '-')
471 *(name+len) = '_';
472 }
473
474 module = module__new(name, path);
475 if (!module) {
476 fprintf(stderr, "load_module_paths: allocation error\n");
477 goto out_failure;
478 }
479 mod_dso__insert_module(self, module);
480
481 module->sections = sec_dso__new_dso("sections");
482 if (!module->sections) {
483 fprintf(stderr, "load_module_paths: allocation error\n");
484 goto out_failure;
485 }
486
487 module->active = mod_dso__load_sections(module);
488
489 if (module->active > 0)
490 count++;
491 }
492
493 free(line);
494 fclose(file);
495
496 return count;
497
498out_failure:
499 return -1;
500}
501
502int mod_dso__load_modules(struct mod_dso *dso)
503{
504 int err;
505
506 err = mod_dso__load_module_paths(dso);
507
508 return err;
509}
diff --git a/tools/perf/util/module.h b/tools/perf/util/module.h
new file mode 100644
index 000000000000..8a592ef641ca
--- /dev/null
+++ b/tools/perf/util/module.h
@@ -0,0 +1,53 @@
1#ifndef _PERF_MODULE_
2#define _PERF_MODULE_ 1
3
4#include <linux/types.h>
5#include "../types.h"
6#include <linux/list.h>
7#include <linux/rbtree.h>
8
9struct section {
10 struct rb_node rb_node;
11 u64 hash;
12 u64 vma;
13 char *name;
14 char *path;
15};
16
17struct sec_dso {
18 struct list_head node;
19 struct rb_root secs;
20 struct section *(*find_section)(struct sec_dso *, const char *name);
21 char name[0];
22};
23
24struct module {
25 struct rb_node rb_node;
26 u64 hash;
27 char *name;
28 char *path;
29 struct sec_dso *sections;
30 int active;
31};
32
33struct mod_dso {
34 struct list_head node;
35 struct rb_root mods;
36 struct module *(*find_module)(struct mod_dso *, const char *name);
37 char name[0];
38};
39
40struct sec_dso *sec_dso__new_dso(const char *name);
41void sec_dso__delete_sections(struct sec_dso *self);
42void sec_dso__delete_self(struct sec_dso *self);
43size_t sec_dso__fprintf(struct sec_dso *self, FILE *fp);
44struct section *sec_dso__find_section(struct sec_dso *self, const char *name);
45
46struct mod_dso *mod_dso__new_dso(const char *name);
47void mod_dso__delete_modules(struct mod_dso *self);
48void mod_dso__delete_self(struct mod_dso *self);
49size_t mod_dso__fprintf(struct mod_dso *self, FILE *fp);
50struct module *mod_dso__find_module(struct mod_dso *self, const char *name);
51int mod_dso__load_modules(struct mod_dso *dso);
52
53#endif /* _PERF_MODULE_ */
diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c
index a28bccae5458..1915de20dcac 100644
--- a/tools/perf/util/pager.c
+++ b/tools/perf/util/pager.c
@@ -9,7 +9,6 @@
9 9
10static int spawned_pager; 10static int spawned_pager;
11 11
12#ifndef __MINGW32__
13static void pager_preexec(void) 12static void pager_preexec(void)
14{ 13{
15 /* 14 /*
@@ -24,7 +23,6 @@ static void pager_preexec(void)
24 23
25 setenv("LESS", "FRSX", 0); 24 setenv("LESS", "FRSX", 0);
26} 25}
27#endif
28 26
29static const char *pager_argv[] = { "sh", "-c", NULL, NULL }; 27static const char *pager_argv[] = { "sh", "-c", NULL, NULL };
30static struct child_process pager_process; 28static struct child_process pager_process;
@@ -70,9 +68,8 @@ void setup_pager(void)
70 pager_argv[2] = pager; 68 pager_argv[2] = pager;
71 pager_process.argv = pager_argv; 69 pager_process.argv = pager_argv;
72 pager_process.in = -1; 70 pager_process.in = -1;
73#ifndef __MINGW32__
74 pager_process.preexec_cb = pager_preexec; 71 pager_process.preexec_cb = pager_preexec;
75#endif 72
76 if (start_command(&pager_process)) 73 if (start_command(&pager_process))
77 return; 74 return;
78 75
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 35d04da38d6a..5184959e0615 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -16,32 +16,28 @@ struct event_symbol {
16 u8 type; 16 u8 type;
17 u64 config; 17 u64 config;
18 char *symbol; 18 char *symbol;
19 char *alias;
19}; 20};
20 21
21#define C(x, y) .type = PERF_TYPE_##x, .config = PERF_COUNT_##y 22#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
22#define CR(x, y) .type = PERF_TYPE_##x, .config = y 23#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
23 24
24static struct event_symbol event_symbols[] = { 25static struct event_symbol event_symbols[] = {
25 { C(HARDWARE, HW_CPU_CYCLES), "cpu-cycles", }, 26 { CHW(CPU_CYCLES), "cpu-cycles", "cycles" },
26 { C(HARDWARE, HW_CPU_CYCLES), "cycles", }, 27 { CHW(INSTRUCTIONS), "instructions", "" },
27 { C(HARDWARE, HW_INSTRUCTIONS), "instructions", }, 28 { CHW(CACHE_REFERENCES), "cache-references", "" },
28 { C(HARDWARE, HW_CACHE_REFERENCES), "cache-references", }, 29 { CHW(CACHE_MISSES), "cache-misses", "" },
29 { C(HARDWARE, HW_CACHE_MISSES), "cache-misses", }, 30 { CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" },
30 { C(HARDWARE, HW_BRANCH_INSTRUCTIONS),"branch-instructions", }, 31 { CHW(BRANCH_MISSES), "branch-misses", "" },
31 { C(HARDWARE, HW_BRANCH_INSTRUCTIONS),"branches", }, 32 { CHW(BUS_CYCLES), "bus-cycles", "" },
32 { C(HARDWARE, HW_BRANCH_MISSES), "branch-misses", }, 33
33 { C(HARDWARE, HW_BUS_CYCLES), "bus-cycles", }, 34 { CSW(CPU_CLOCK), "cpu-clock", "" },
34 35 { CSW(TASK_CLOCK), "task-clock", "" },
35 { C(SOFTWARE, SW_CPU_CLOCK), "cpu-clock", }, 36 { CSW(PAGE_FAULTS), "page-faults", "faults" },
36 { C(SOFTWARE, SW_TASK_CLOCK), "task-clock", }, 37 { CSW(PAGE_FAULTS_MIN), "minor-faults", "" },
37 { C(SOFTWARE, SW_PAGE_FAULTS), "page-faults", }, 38 { CSW(PAGE_FAULTS_MAJ), "major-faults", "" },
38 { C(SOFTWARE, SW_PAGE_FAULTS), "faults", }, 39 { CSW(CONTEXT_SWITCHES), "context-switches", "cs" },
39 { C(SOFTWARE, SW_PAGE_FAULTS_MIN), "minor-faults", }, 40 { CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" },
40 { C(SOFTWARE, SW_PAGE_FAULTS_MAJ), "major-faults", },
41 { C(SOFTWARE, SW_CONTEXT_SWITCHES), "context-switches", },
42 { C(SOFTWARE, SW_CONTEXT_SWITCHES), "cs", },
43 { C(SOFTWARE, SW_CPU_MIGRATIONS), "cpu-migrations", },
44 { C(SOFTWARE, SW_CPU_MIGRATIONS), "migrations", },
45}; 41};
46 42
47#define __PERF_COUNTER_FIELD(config, name) \ 43#define __PERF_COUNTER_FIELD(config, name) \
@@ -74,26 +70,70 @@ static char *sw_event_names[] = {
74 70
75#define MAX_ALIASES 8 71#define MAX_ALIASES 8
76 72
77static char *hw_cache [][MAX_ALIASES] = { 73static char *hw_cache[][MAX_ALIASES] = {
78 { "L1-data" , "l1-d", "l1d" }, 74 { "L1-d$", "l1-d", "l1d", "L1-data", },
79 { "L1-instruction" , "l1-i", "l1i" }, 75 { "L1-i$", "l1-i", "l1i", "L1-instruction", },
80 { "L2" , "l2" }, 76 { "LLC", "L2" },
81 { "Data-TLB" , "dtlb", "d-tlb" }, 77 { "dTLB", "d-tlb", "Data-TLB", },
82 { "Instruction-TLB" , "itlb", "i-tlb" }, 78 { "iTLB", "i-tlb", "Instruction-TLB", },
83 { "Branch" , "bpu" , "btb", "bpc" }, 79 { "branch", "branches", "bpu", "btb", "bpc", },
84}; 80};
85 81
86static char *hw_cache_op [][MAX_ALIASES] = { 82static char *hw_cache_op[][MAX_ALIASES] = {
87 { "Load" , "read" }, 83 { "load", "loads", "read", },
88 { "Store" , "write" }, 84 { "store", "stores", "write", },
89 { "Prefetch" , "speculative-read", "speculative-load" }, 85 { "prefetch", "prefetches", "speculative-read", "speculative-load", },
90}; 86};
91 87
92static char *hw_cache_result [][MAX_ALIASES] = { 88static char *hw_cache_result[][MAX_ALIASES] = {
93 { "Reference" , "ops", "access" }, 89 { "refs", "Reference", "ops", "access", },
94 { "Miss" }, 90 { "misses", "miss", },
95}; 91};
96 92
93#define C(x) PERF_COUNT_HW_CACHE_##x
94#define CACHE_READ (1 << C(OP_READ))
95#define CACHE_WRITE (1 << C(OP_WRITE))
96#define CACHE_PREFETCH (1 << C(OP_PREFETCH))
97#define COP(x) (1 << x)
98
99/*
100 * cache operartion stat
101 * L1I : Read and prefetch only
102 * ITLB and BPU : Read-only
103 */
104static unsigned long hw_cache_stat[C(MAX)] = {
105 [C(L1D)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
106 [C(L1I)] = (CACHE_READ | CACHE_PREFETCH),
107 [C(LL)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
108 [C(DTLB)] = (CACHE_READ | CACHE_WRITE | CACHE_PREFETCH),
109 [C(ITLB)] = (CACHE_READ),
110 [C(BPU)] = (CACHE_READ),
111};
112
113static int is_cache_op_valid(u8 cache_type, u8 cache_op)
114{
115 if (hw_cache_stat[cache_type] & COP(cache_op))
116 return 1; /* valid */
117 else
118 return 0; /* invalid */
119}
120
121static char *event_cache_name(u8 cache_type, u8 cache_op, u8 cache_result)
122{
123 static char name[50];
124
125 if (cache_result) {
126 sprintf(name, "%s-%s-%s", hw_cache[cache_type][0],
127 hw_cache_op[cache_op][0],
128 hw_cache_result[cache_result][0]);
129 } else {
130 sprintf(name, "%s-%s", hw_cache[cache_type][0],
131 hw_cache_op[cache_op][1]);
132 }
133
134 return name;
135}
136
97char *event_name(int counter) 137char *event_name(int counter)
98{ 138{
99 u64 config = attrs[counter].config; 139 u64 config = attrs[counter].config;
@@ -113,7 +153,6 @@ char *event_name(int counter)
113 153
114 case PERF_TYPE_HW_CACHE: { 154 case PERF_TYPE_HW_CACHE: {
115 u8 cache_type, cache_op, cache_result; 155 u8 cache_type, cache_op, cache_result;
116 static char name[100];
117 156
118 cache_type = (config >> 0) & 0xff; 157 cache_type = (config >> 0) & 0xff;
119 if (cache_type > PERF_COUNT_HW_CACHE_MAX) 158 if (cache_type > PERF_COUNT_HW_CACHE_MAX)
@@ -127,12 +166,10 @@ char *event_name(int counter)
127 if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX) 166 if (cache_result > PERF_COUNT_HW_CACHE_RESULT_MAX)
128 return "unknown-ext-hardware-cache-result"; 167 return "unknown-ext-hardware-cache-result";
129 168
130 sprintf(name, "%s-Cache-%s-%ses", 169 if (!is_cache_op_valid(cache_type, cache_op))
131 hw_cache[cache_type][0], 170 return "invalid-cache";
132 hw_cache_op[cache_op][0],
133 hw_cache_result[cache_result][0]);
134 171
135 return name; 172 return event_cache_name(cache_type, cache_op, cache_result);
136 } 173 }
137 174
138 case PERF_TYPE_SOFTWARE: 175 case PERF_TYPE_SOFTWARE:
@@ -147,43 +184,74 @@ char *event_name(int counter)
147 return "unknown"; 184 return "unknown";
148} 185}
149 186
150static int parse_aliases(const char *str, char *names[][MAX_ALIASES], int size) 187static int parse_aliases(const char **str, char *names[][MAX_ALIASES], int size)
151{ 188{
152 int i, j; 189 int i, j;
190 int n, longest = -1;
153 191
154 for (i = 0; i < size; i++) { 192 for (i = 0; i < size; i++) {
155 for (j = 0; j < MAX_ALIASES; j++) { 193 for (j = 0; j < MAX_ALIASES && names[i][j]; j++) {
156 if (!names[i][j]) 194 n = strlen(names[i][j]);
157 break; 195 if (n > longest && !strncasecmp(*str, names[i][j], n))
158 if (strcasestr(str, names[i][j])) 196 longest = n;
159 return i; 197 }
198 if (longest > 0) {
199 *str += longest;
200 return i;
160 } 201 }
161 } 202 }
162 203
163 return -1; 204 return -1;
164} 205}
165 206
166static int parse_generic_hw_symbols(const char *str, struct perf_counter_attr *attr) 207static int
208parse_generic_hw_event(const char **str, struct perf_counter_attr *attr)
167{ 209{
168 int cache_type = -1, cache_op = 0, cache_result = 0; 210 const char *s = *str;
211 int cache_type = -1, cache_op = -1, cache_result = -1;
169 212
170 cache_type = parse_aliases(str, hw_cache, PERF_COUNT_HW_CACHE_MAX); 213 cache_type = parse_aliases(&s, hw_cache, PERF_COUNT_HW_CACHE_MAX);
171 /* 214 /*
172 * No fallback - if we cannot get a clear cache type 215 * No fallback - if we cannot get a clear cache type
173 * then bail out: 216 * then bail out:
174 */ 217 */
175 if (cache_type == -1) 218 if (cache_type == -1)
176 return -EINVAL; 219 return 0;
220
221 while ((cache_op == -1 || cache_result == -1) && *s == '-') {
222 ++s;
223
224 if (cache_op == -1) {
225 cache_op = parse_aliases(&s, hw_cache_op,
226 PERF_COUNT_HW_CACHE_OP_MAX);
227 if (cache_op >= 0) {
228 if (!is_cache_op_valid(cache_type, cache_op))
229 return 0;
230 continue;
231 }
232 }
233
234 if (cache_result == -1) {
235 cache_result = parse_aliases(&s, hw_cache_result,
236 PERF_COUNT_HW_CACHE_RESULT_MAX);
237 if (cache_result >= 0)
238 continue;
239 }
240
241 /*
242 * Can't parse this as a cache op or result, so back up
243 * to the '-'.
244 */
245 --s;
246 break;
247 }
177 248
178 cache_op = parse_aliases(str, hw_cache_op, PERF_COUNT_HW_CACHE_OP_MAX);
179 /* 249 /*
180 * Fall back to reads: 250 * Fall back to reads:
181 */ 251 */
182 if (cache_op == -1) 252 if (cache_op == -1)
183 cache_op = PERF_COUNT_HW_CACHE_OP_READ; 253 cache_op = PERF_COUNT_HW_CACHE_OP_READ;
184 254
185 cache_result = parse_aliases(str, hw_cache_result,
186 PERF_COUNT_HW_CACHE_RESULT_MAX);
187 /* 255 /*
188 * Fall back to accesses: 256 * Fall back to accesses:
189 */ 257 */
@@ -193,82 +261,154 @@ static int parse_generic_hw_symbols(const char *str, struct perf_counter_attr *a
193 attr->config = cache_type | (cache_op << 8) | (cache_result << 16); 261 attr->config = cache_type | (cache_op << 8) | (cache_result << 16);
194 attr->type = PERF_TYPE_HW_CACHE; 262 attr->type = PERF_TYPE_HW_CACHE;
195 263
264 *str = s;
265 return 1;
266}
267
268static int check_events(const char *str, unsigned int i)
269{
270 int n;
271
272 n = strlen(event_symbols[i].symbol);
273 if (!strncmp(str, event_symbols[i].symbol, n))
274 return n;
275
276 n = strlen(event_symbols[i].alias);
277 if (n)
278 if (!strncmp(str, event_symbols[i].alias, n))
279 return n;
196 return 0; 280 return 0;
197} 281}
198 282
199/* 283static int
200 * Each event can have multiple symbolic names. 284parse_symbolic_event(const char **strp, struct perf_counter_attr *attr)
201 * Symbolic names are (almost) exactly matched.
202 */
203static int parse_event_symbols(const char *str, struct perf_counter_attr *attr)
204{ 285{
205 u64 config, id; 286 const char *str = *strp;
206 int type;
207 unsigned int i; 287 unsigned int i;
208 const char *sep, *pstr; 288 int n;
209 289
210 if (str[0] == 'r' && hex2u64(str + 1, &config) > 0) { 290 for (i = 0; i < ARRAY_SIZE(event_symbols); i++) {
211 attr->type = PERF_TYPE_RAW; 291 n = check_events(str, i);
212 attr->config = config; 292 if (n > 0) {
293 attr->type = event_symbols[i].type;
294 attr->config = event_symbols[i].config;
295 *strp = str + n;
296 return 1;
297 }
298 }
299 return 0;
300}
301
302static int parse_raw_event(const char **strp, struct perf_counter_attr *attr)
303{
304 const char *str = *strp;
305 u64 config;
306 int n;
213 307
308 if (*str != 'r')
214 return 0; 309 return 0;
310 n = hex2u64(str + 1, &config);
311 if (n > 0) {
312 *strp = str + n + 1;
313 attr->type = PERF_TYPE_RAW;
314 attr->config = config;
315 return 1;
215 } 316 }
317 return 0;
318}
216 319
217 pstr = str; 320static int
218 sep = strchr(pstr, ':'); 321parse_numeric_event(const char **strp, struct perf_counter_attr *attr)
219 if (sep) { 322{
220 type = atoi(pstr); 323 const char *str = *strp;
221 pstr = sep + 1; 324 char *endp;
222 id = atoi(pstr); 325 unsigned long type;
223 sep = strchr(pstr, ':'); 326 u64 config;
224 if (sep) { 327
225 pstr = sep + 1; 328 type = strtoul(str, &endp, 0);
226 if (strchr(pstr, 'k')) 329 if (endp > str && type < PERF_TYPE_MAX && *endp == ':') {
227 attr->exclude_user = 1; 330 str = endp + 1;
228 if (strchr(pstr, 'u')) 331 config = strtoul(str, &endp, 0);
229 attr->exclude_kernel = 1; 332 if (endp > str) {
333 attr->type = type;
334 attr->config = config;
335 *strp = endp;
336 return 1;
230 } 337 }
231 attr->type = type; 338 }
232 attr->config = id; 339 return 0;
340}
341
342static int
343parse_event_modifier(const char **strp, struct perf_counter_attr *attr)
344{
345 const char *str = *strp;
346 int eu = 1, ek = 1, eh = 1;
233 347
348 if (*str++ != ':')
234 return 0; 349 return 0;
350 while (*str) {
351 if (*str == 'u')
352 eu = 0;
353 else if (*str == 'k')
354 ek = 0;
355 else if (*str == 'h')
356 eh = 0;
357 else
358 break;
359 ++str;
235 } 360 }
361 if (str >= *strp + 2) {
362 *strp = str;
363 attr->exclude_user = eu;
364 attr->exclude_kernel = ek;
365 attr->exclude_hv = eh;
366 return 1;
367 }
368 return 0;
369}
236 370
237 for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { 371/*
238 if (!strncmp(str, event_symbols[i].symbol, 372 * Each event can have multiple symbolic names.
239 strlen(event_symbols[i].symbol))) { 373 * Symbolic names are (almost) exactly matched.
240 374 */
241 attr->type = event_symbols[i].type; 375static int parse_event_symbols(const char **str, struct perf_counter_attr *attr)
242 attr->config = event_symbols[i].config; 376{
377 if (!(parse_raw_event(str, attr) ||
378 parse_numeric_event(str, attr) ||
379 parse_symbolic_event(str, attr) ||
380 parse_generic_hw_event(str, attr)))
381 return 0;
243 382
244 return 0; 383 parse_event_modifier(str, attr);
245 }
246 }
247 384
248 return parse_generic_hw_symbols(str, attr); 385 return 1;
249} 386}
250 387
251int parse_events(const struct option *opt, const char *str, int unset) 388int parse_events(const struct option *opt __used, const char *str, int unset __used)
252{ 389{
253 struct perf_counter_attr attr; 390 struct perf_counter_attr attr;
254 int ret;
255 391
256 memset(&attr, 0, sizeof(attr)); 392 for (;;) {
257again: 393 if (nr_counters == MAX_COUNTERS)
258 if (nr_counters == MAX_COUNTERS) 394 return -1;
259 return -1; 395
396 memset(&attr, 0, sizeof(attr));
397 if (!parse_event_symbols(&str, &attr))
398 return -1;
260 399
261 ret = parse_event_symbols(str, &attr); 400 if (!(*str == 0 || *str == ',' || isspace(*str)))
262 if (ret < 0) 401 return -1;
263 return ret;
264 402
265 attrs[nr_counters] = attr; 403 attrs[nr_counters] = attr;
266 nr_counters++; 404 nr_counters++;
267 405
268 str = strstr(str, ","); 406 if (*str == 0)
269 if (str) { 407 break;
270 str++; 408 if (*str == ',')
271 goto again; 409 ++str;
410 while (isspace(*str))
411 ++str;
272 } 412 }
273 413
274 return 0; 414 return 0;
@@ -288,7 +428,8 @@ static const char * const event_type_descriptors[] = {
288void print_events(void) 428void print_events(void)
289{ 429{
290 struct event_symbol *syms = event_symbols; 430 struct event_symbol *syms = event_symbols;
291 unsigned int i, type, prev_type = -1; 431 unsigned int i, type, op, prev_type = -1;
432 char name[40];
292 433
293 fprintf(stderr, "\n"); 434 fprintf(stderr, "\n");
294 fprintf(stderr, "List of pre-defined events (to be used in -e):\n"); 435 fprintf(stderr, "List of pre-defined events (to be used in -e):\n");
@@ -301,14 +442,33 @@ void print_events(void)
301 if (type != prev_type) 442 if (type != prev_type)
302 fprintf(stderr, "\n"); 443 fprintf(stderr, "\n");
303 444
304 fprintf(stderr, " %-30s [%s]\n", syms->symbol, 445 if (strlen(syms->alias))
446 sprintf(name, "%s OR %s", syms->symbol, syms->alias);
447 else
448 strcpy(name, syms->symbol);
449 fprintf(stderr, " %-40s [%s]\n", name,
305 event_type_descriptors[type]); 450 event_type_descriptors[type]);
306 451
307 prev_type = type; 452 prev_type = type;
308 } 453 }
309 454
310 fprintf(stderr, "\n"); 455 fprintf(stderr, "\n");
311 fprintf(stderr, " %-30s [raw hardware event descriptor]\n", 456 for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
457 for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
458 /* skip invalid cache type */
459 if (!is_cache_op_valid(type, op))
460 continue;
461
462 for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
463 fprintf(stderr, " %-40s [%s]\n",
464 event_cache_name(type, op, i),
465 event_type_descriptors[4]);
466 }
467 }
468 }
469
470 fprintf(stderr, "\n");
471 fprintf(stderr, " %-40s [raw hardware event descriptor]\n",
312 "rNNN"); 472 "rNNN");
313 fprintf(stderr, "\n"); 473 fprintf(stderr, "\n");
314 474
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index b3affb1658d2..1bf67190c820 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -20,7 +20,8 @@ static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt,
20 if (p->opt) { 20 if (p->opt) {
21 *arg = p->opt; 21 *arg = p->opt;
22 p->opt = NULL; 22 p->opt = NULL;
23 } else if (p->argc == 1 && (opt->flags & PARSE_OPT_LASTARG_DEFAULT)) { 23 } else if ((opt->flags & PARSE_OPT_LASTARG_DEFAULT) && (p->argc == 1 ||
24 **(p->argv + 1) == '-')) {
24 *arg = (const char *)opt->defval; 25 *arg = (const char *)opt->defval;
25 } else if (p->argc > 1) { 26 } else if (p->argc > 1) {
26 p->argc--; 27 p->argc--;
@@ -485,7 +486,7 @@ int parse_options_usage(const char * const *usagestr,
485} 486}
486 487
487 488
488int parse_opt_verbosity_cb(const struct option *opt, const char *arg, 489int parse_opt_verbosity_cb(const struct option *opt, const char *arg __used,
489 int unset) 490 int unset)
490{ 491{
491 int *target = opt->value; 492 int *target = opt->value;
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h
index a1039a6ce0eb..8aa3464c7090 100644
--- a/tools/perf/util/parse-options.h
+++ b/tools/perf/util/parse-options.h
@@ -90,21 +90,22 @@ struct option {
90 intptr_t defval; 90 intptr_t defval;
91}; 91};
92 92
93#define OPT_END() { OPTION_END } 93#define OPT_END() { .type = OPTION_END }
94#define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, (h) } 94#define OPT_ARGUMENT(l, h) { .type = OPTION_ARGUMENT, .long_name = (l), .help = (h) }
95#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) } 95#define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) }
96#define OPT_BIT(s, l, v, h, b) { OPTION_BIT, (s), (l), (v), NULL, (h), 0, NULL, (b) } 96#define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (b) }
97#define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) } 97#define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
98#define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, (h), 0, NULL, (i) } 98#define OPT_SET_INT(s, l, v, h, i) { .type = OPTION_SET_INT, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (i) }
99#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) } 99#define OPT_SET_PTR(s, l, v, h, p) { .type = OPTION_SET_PTR, .short_name = (s), .long_name = (l), .value = (v), .help = (h), .defval = (p) }
100#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), NULL, (h) } 100#define OPT_INTEGER(s, l, v, h) { .type = OPTION_INTEGER, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
101#define OPT_LONG(s, l, v, h) { OPTION_LONG, (s), (l), (v), NULL, (h) } 101#define OPT_LONG(s, l, v, h) { .type = OPTION_LONG, .short_name = (s), .long_name = (l), .value = (v), .help = (h) }
102#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) } 102#define OPT_STRING(s, l, v, a, h) { .type = OPTION_STRING, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h) }
103#define OPT_DATE(s, l, v, h) \ 103#define OPT_DATE(s, l, v, h) \
104 { OPTION_CALLBACK, (s), (l), (v), "time",(h), 0, \ 104 { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
105 parse_opt_approxidate_cb }
106#define OPT_CALLBACK(s, l, v, a, h, f) \ 105#define OPT_CALLBACK(s, l, v, a, h, f) \
107 { OPTION_CALLBACK, (s), (l), (v), (a), (h), 0, (f) } 106 { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f) }
107#define OPT_CALLBACK_DEFAULT(s, l, v, a, h, f, d) \
108 { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags = PARSE_OPT_LASTARG_DEFAULT }
108 109
109/* parse_options() will filter out the processed options and leave the 110/* parse_options() will filter out the processed options and leave the
110 * non-option argments in argv[]. 111 * non-option argments in argv[].
diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c
index f18c5212bc92..c6e5dc0dc82f 100644
--- a/tools/perf/util/quote.c
+++ b/tools/perf/util/quote.c
@@ -162,12 +162,16 @@ static inline int sq_must_quote(char c)
162 return sq_lookup[(unsigned char)c] + quote_path_fully > 0; 162 return sq_lookup[(unsigned char)c] + quote_path_fully > 0;
163} 163}
164 164
165/* returns the longest prefix not needing a quote up to maxlen if positive. 165/*
166 This stops at the first \0 because it's marked as a character needing an 166 * Returns the longest prefix not needing a quote up to maxlen if
167 escape */ 167 * positive.
168static size_t next_quote_pos(const char *s, ssize_t maxlen) 168 * This stops at the first \0 because it's marked as a character
169 * needing an escape.
170 */
171static ssize_t next_quote_pos(const char *s, ssize_t maxlen)
169{ 172{
170 size_t len; 173 ssize_t len;
174
171 if (maxlen < 0) { 175 if (maxlen < 0) {
172 for (len = 0; !sq_must_quote(s[len]); len++); 176 for (len = 0; !sq_must_quote(s[len]); len++);
173 } else { 177 } else {
@@ -192,22 +196,22 @@ static size_t next_quote_pos(const char *s, ssize_t maxlen)
192static size_t quote_c_style_counted(const char *name, ssize_t maxlen, 196static size_t quote_c_style_counted(const char *name, ssize_t maxlen,
193 struct strbuf *sb, FILE *fp, int no_dq) 197 struct strbuf *sb, FILE *fp, int no_dq)
194{ 198{
195#undef EMIT 199#define EMIT(c) \
196#define EMIT(c) \ 200 do { \
197 do { \ 201 if (sb) strbuf_addch(sb, (c)); \
198 if (sb) strbuf_addch(sb, (c)); \ 202 if (fp) fputc((c), fp); \
199 if (fp) fputc((c), fp); \ 203 count++; \
200 count++; \
201 } while (0) 204 } while (0)
202#define EMITBUF(s, l) \ 205
203 do { \ 206#define EMITBUF(s, l) \
204 int __ret; \ 207 do { \
205 if (sb) strbuf_add(sb, (s), (l)); \ 208 int __ret; \
206 if (fp) __ret = fwrite((s), (l), 1, fp); \ 209 if (sb) strbuf_add(sb, (s), (l)); \
207 count += (l); \ 210 if (fp) __ret = fwrite((s), (l), 1, fp); \
211 count += (l); \
208 } while (0) 212 } while (0)
209 213
210 size_t len, count = 0; 214 ssize_t len, count = 0;
211 const char *p = name; 215 const char *p = name;
212 216
213 for (;;) { 217 for (;;) {
@@ -273,8 +277,8 @@ void write_name_quoted(const char *name, FILE *fp, int terminator)
273 fputc(terminator, fp); 277 fputc(terminator, fp);
274} 278}
275 279
276extern void write_name_quotedpfx(const char *pfx, size_t pfxlen, 280void write_name_quotedpfx(const char *pfx, ssize_t pfxlen,
277 const char *name, FILE *fp, int terminator) 281 const char *name, FILE *fp, int terminator)
278{ 282{
279 int needquote = 0; 283 int needquote = 0;
280 284
@@ -306,7 +310,7 @@ char *quote_path_relative(const char *in, int len,
306 len = strlen(in); 310 len = strlen(in);
307 311
308 /* "../" prefix itself does not need quoting, but "in" might. */ 312 /* "../" prefix itself does not need quoting, but "in" might. */
309 needquote = next_quote_pos(in, len) < len; 313 needquote = (next_quote_pos(in, len) < len);
310 strbuf_setlen(out, 0); 314 strbuf_setlen(out, 0);
311 strbuf_grow(out, len); 315 strbuf_grow(out, len);
312 316
diff --git a/tools/perf/util/quote.h b/tools/perf/util/quote.h
index 5dfad89816db..a5454a1d1c13 100644
--- a/tools/perf/util/quote.h
+++ b/tools/perf/util/quote.h
@@ -53,7 +53,7 @@ extern size_t quote_c_style(const char *name, struct strbuf *, FILE *, int no_dq
53extern void quote_two_c_style(struct strbuf *, const char *, const char *, int); 53extern void quote_two_c_style(struct strbuf *, const char *, const char *, int);
54 54
55extern void write_name_quoted(const char *name, FILE *, int terminator); 55extern void write_name_quoted(const char *name, FILE *, int terminator);
56extern void write_name_quotedpfx(const char *pfx, size_t pfxlen, 56extern void write_name_quotedpfx(const char *pfx, ssize_t pfxlen,
57 const char *name, FILE *, int terminator); 57 const char *name, FILE *, int terminator);
58 58
59/* quote path as relative to the given prefix */ 59/* quote path as relative to the given prefix */
diff --git a/tools/perf/util/rbtree.c b/tools/perf/util/rbtree.c
deleted file mode 100644
index b15ba9c7cb3f..000000000000
--- a/tools/perf/util/rbtree.c
+++ /dev/null
@@ -1,383 +0,0 @@
1/*
2 Red Black Trees
3 (C) 1999 Andrea Arcangeli <andrea@suse.de>
4 (C) 2002 David Woodhouse <dwmw2@infradead.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 linux/lib/rbtree.c
21*/
22
23#include "rbtree.h"
24
25static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
26{
27 struct rb_node *right = node->rb_right;
28 struct rb_node *parent = rb_parent(node);
29
30 if ((node->rb_right = right->rb_left))
31 rb_set_parent(right->rb_left, node);
32 right->rb_left = node;
33
34 rb_set_parent(right, parent);
35
36 if (parent)
37 {
38 if (node == parent->rb_left)
39 parent->rb_left = right;
40 else
41 parent->rb_right = right;
42 }
43 else
44 root->rb_node = right;
45 rb_set_parent(node, right);
46}
47
48static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
49{
50 struct rb_node *left = node->rb_left;
51 struct rb_node *parent = rb_parent(node);
52
53 if ((node->rb_left = left->rb_right))
54 rb_set_parent(left->rb_right, node);
55 left->rb_right = node;
56
57 rb_set_parent(left, parent);
58
59 if (parent)
60 {
61 if (node == parent->rb_right)
62 parent->rb_right = left;
63 else
64 parent->rb_left = left;
65 }
66 else
67 root->rb_node = left;
68 rb_set_parent(node, left);
69}
70
71void rb_insert_color(struct rb_node *node, struct rb_root *root)
72{
73 struct rb_node *parent, *gparent;
74
75 while ((parent = rb_parent(node)) && rb_is_red(parent))
76 {
77 gparent = rb_parent(parent);
78
79 if (parent == gparent->rb_left)
80 {
81 {
82 register struct rb_node *uncle = gparent->rb_right;
83 if (uncle && rb_is_red(uncle))
84 {
85 rb_set_black(uncle);
86 rb_set_black(parent);
87 rb_set_red(gparent);
88 node = gparent;
89 continue;
90 }
91 }
92
93 if (parent->rb_right == node)
94 {
95 register struct rb_node *tmp;
96 __rb_rotate_left(parent, root);
97 tmp = parent;
98 parent = node;
99 node = tmp;
100 }
101
102 rb_set_black(parent);
103 rb_set_red(gparent);
104 __rb_rotate_right(gparent, root);
105 } else {
106 {
107 register struct rb_node *uncle = gparent->rb_left;
108 if (uncle && rb_is_red(uncle))
109 {
110 rb_set_black(uncle);
111 rb_set_black(parent);
112 rb_set_red(gparent);
113 node = gparent;
114 continue;
115 }
116 }
117
118 if (parent->rb_left == node)
119 {
120 register struct rb_node *tmp;
121 __rb_rotate_right(parent, root);
122 tmp = parent;
123 parent = node;
124 node = tmp;
125 }
126
127 rb_set_black(parent);
128 rb_set_red(gparent);
129 __rb_rotate_left(gparent, root);
130 }
131 }
132
133 rb_set_black(root->rb_node);
134}
135
136static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
137 struct rb_root *root)
138{
139 struct rb_node *other;
140
141 while ((!node || rb_is_black(node)) && node != root->rb_node)
142 {
143 if (parent->rb_left == node)
144 {
145 other = parent->rb_right;
146 if (rb_is_red(other))
147 {
148 rb_set_black(other);
149 rb_set_red(parent);
150 __rb_rotate_left(parent, root);
151 other = parent->rb_right;
152 }
153 if ((!other->rb_left || rb_is_black(other->rb_left)) &&
154 (!other->rb_right || rb_is_black(other->rb_right)))
155 {
156 rb_set_red(other);
157 node = parent;
158 parent = rb_parent(node);
159 }
160 else
161 {
162 if (!other->rb_right || rb_is_black(other->rb_right))
163 {
164 rb_set_black(other->rb_left);
165 rb_set_red(other);
166 __rb_rotate_right(other, root);
167 other = parent->rb_right;
168 }
169 rb_set_color(other, rb_color(parent));
170 rb_set_black(parent);
171 rb_set_black(other->rb_right);
172 __rb_rotate_left(parent, root);
173 node = root->rb_node;
174 break;
175 }
176 }
177 else
178 {
179 other = parent->rb_left;
180 if (rb_is_red(other))
181 {
182 rb_set_black(other);
183 rb_set_red(parent);
184 __rb_rotate_right(parent, root);
185 other = parent->rb_left;
186 }
187 if ((!other->rb_left || rb_is_black(other->rb_left)) &&
188 (!other->rb_right || rb_is_black(other->rb_right)))
189 {
190 rb_set_red(other);
191 node = parent;
192 parent = rb_parent(node);
193 }
194 else
195 {
196 if (!other->rb_left || rb_is_black(other->rb_left))
197 {
198 rb_set_black(other->rb_right);
199 rb_set_red(other);
200 __rb_rotate_left(other, root);
201 other = parent->rb_left;
202 }
203 rb_set_color(other, rb_color(parent));
204 rb_set_black(parent);
205 rb_set_black(other->rb_left);
206 __rb_rotate_right(parent, root);
207 node = root->rb_node;
208 break;
209 }
210 }
211 }
212 if (node)
213 rb_set_black(node);
214}
215
216void rb_erase(struct rb_node *node, struct rb_root *root)
217{
218 struct rb_node *child, *parent;
219 int color;
220
221 if (!node->rb_left)
222 child = node->rb_right;
223 else if (!node->rb_right)
224 child = node->rb_left;
225 else
226 {
227 struct rb_node *old = node, *left;
228
229 node = node->rb_right;
230 while ((left = node->rb_left) != NULL)
231 node = left;
232 child = node->rb_right;
233 parent = rb_parent(node);
234 color = rb_color(node);
235
236 if (child)
237 rb_set_parent(child, parent);
238 if (parent == old) {
239 parent->rb_right = child;
240 parent = node;
241 } else
242 parent->rb_left = child;
243
244 node->rb_parent_color = old->rb_parent_color;
245 node->rb_right = old->rb_right;
246 node->rb_left = old->rb_left;
247
248 if (rb_parent(old))
249 {
250 if (rb_parent(old)->rb_left == old)
251 rb_parent(old)->rb_left = node;
252 else
253 rb_parent(old)->rb_right = node;
254 } else
255 root->rb_node = node;
256
257 rb_set_parent(old->rb_left, node);
258 if (old->rb_right)
259 rb_set_parent(old->rb_right, node);
260 goto color;
261 }
262
263 parent = rb_parent(node);
264 color = rb_color(node);
265
266 if (child)
267 rb_set_parent(child, parent);
268 if (parent)
269 {
270 if (parent->rb_left == node)
271 parent->rb_left = child;
272 else
273 parent->rb_right = child;
274 }
275 else
276 root->rb_node = child;
277
278 color:
279 if (color == RB_BLACK)
280 __rb_erase_color(child, parent, root);
281}
282
283/*
284 * This function returns the first node (in sort order) of the tree.
285 */
286struct rb_node *rb_first(const struct rb_root *root)
287{
288 struct rb_node *n;
289
290 n = root->rb_node;
291 if (!n)
292 return NULL;
293 while (n->rb_left)
294 n = n->rb_left;
295 return n;
296}
297
298struct rb_node *rb_last(const struct rb_root *root)
299{
300 struct rb_node *n;
301
302 n = root->rb_node;
303 if (!n)
304 return NULL;
305 while (n->rb_right)
306 n = n->rb_right;
307 return n;
308}
309
310struct rb_node *rb_next(const struct rb_node *node)
311{
312 struct rb_node *parent;
313
314 if (rb_parent(node) == node)
315 return NULL;
316
317 /* If we have a right-hand child, go down and then left as far
318 as we can. */
319 if (node->rb_right) {
320 node = node->rb_right;
321 while (node->rb_left)
322 node=node->rb_left;
323 return (struct rb_node *)node;
324 }
325
326 /* No right-hand children. Everything down and left is
327 smaller than us, so any 'next' node must be in the general
328 direction of our parent. Go up the tree; any time the
329 ancestor is a right-hand child of its parent, keep going
330 up. First time it's a left-hand child of its parent, said
331 parent is our 'next' node. */
332 while ((parent = rb_parent(node)) && node == parent->rb_right)
333 node = parent;
334
335 return parent;
336}
337
338struct rb_node *rb_prev(const struct rb_node *node)
339{
340 struct rb_node *parent;
341
342 if (rb_parent(node) == node)
343 return NULL;
344
345 /* If we have a left-hand child, go down and then right as far
346 as we can. */
347 if (node->rb_left) {
348 node = node->rb_left;
349 while (node->rb_right)
350 node=node->rb_right;
351 return (struct rb_node *)node;
352 }
353
354 /* No left-hand children. Go up till we find an ancestor which
355 is a right-hand child of its parent */
356 while ((parent = rb_parent(node)) && node == parent->rb_left)
357 node = parent;
358
359 return parent;
360}
361
362void rb_replace_node(struct rb_node *victim, struct rb_node *new,
363 struct rb_root *root)
364{
365 struct rb_node *parent = rb_parent(victim);
366
367 /* Set the surrounding nodes to point to the replacement */
368 if (parent) {
369 if (victim == parent->rb_left)
370 parent->rb_left = new;
371 else
372 parent->rb_right = new;
373 } else {
374 root->rb_node = new;
375 }
376 if (victim->rb_left)
377 rb_set_parent(victim->rb_left, new);
378 if (victim->rb_right)
379 rb_set_parent(victim->rb_right, new);
380
381 /* Copy the pointers/colour from the victim to the replacement */
382 *new = *victim;
383}
diff --git a/tools/perf/util/rbtree.h b/tools/perf/util/rbtree.h
deleted file mode 100644
index 6bdc488a47fb..000000000000
--- a/tools/perf/util/rbtree.h
+++ /dev/null
@@ -1,171 +0,0 @@
1/*
2 Red Black Trees
3 (C) 1999 Andrea Arcangeli <andrea@suse.de>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 linux/include/linux/rbtree.h
20
21 To use rbtrees you'll have to implement your own insert and search cores.
22 This will avoid us to use callbacks and to drop drammatically performances.
23 I know it's not the cleaner way, but in C (not in C++) to get
24 performances and genericity...
25
26 Some example of insert and search follows here. The search is a plain
27 normal search over an ordered tree. The insert instead must be implemented
28 int two steps: as first thing the code must insert the element in
29 order as a red leaf in the tree, then the support library function
30 rb_insert_color() must be called. Such function will do the
31 not trivial work to rebalance the rbtree if necessary.
32
33-----------------------------------------------------------------------
34static inline struct page * rb_search_page_cache(struct inode * inode,
35 unsigned long offset)
36{
37 struct rb_node * n = inode->i_rb_page_cache.rb_node;
38 struct page * page;
39
40 while (n)
41 {
42 page = rb_entry(n, struct page, rb_page_cache);
43
44 if (offset < page->offset)
45 n = n->rb_left;
46 else if (offset > page->offset)
47 n = n->rb_right;
48 else
49 return page;
50 }
51 return NULL;
52}
53
54static inline struct page * __rb_insert_page_cache(struct inode * inode,
55 unsigned long offset,
56 struct rb_node * node)
57{
58 struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
59 struct rb_node * parent = NULL;
60 struct page * page;
61
62 while (*p)
63 {
64 parent = *p;
65 page = rb_entry(parent, struct page, rb_page_cache);
66
67 if (offset < page->offset)
68 p = &(*p)->rb_left;
69 else if (offset > page->offset)
70 p = &(*p)->rb_right;
71 else
72 return page;
73 }
74
75 rb_link_node(node, parent, p);
76
77 return NULL;
78}
79
80static inline struct page * rb_insert_page_cache(struct inode * inode,
81 unsigned long offset,
82 struct rb_node * node)
83{
84 struct page * ret;
85 if ((ret = __rb_insert_page_cache(inode, offset, node)))
86 goto out;
87 rb_insert_color(node, &inode->i_rb_page_cache);
88 out:
89 return ret;
90}
91-----------------------------------------------------------------------
92*/
93
94#ifndef _LINUX_RBTREE_H
95#define _LINUX_RBTREE_H
96
97#include <stddef.h>
98
99/**
100 * container_of - cast a member of a structure out to the containing structure
101 * @ptr: the pointer to the member.
102 * @type: the type of the container struct this is embedded in.
103 * @member: the name of the member within the struct.
104 *
105 */
106#define container_of(ptr, type, member) ({ \
107 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
108 (type *)( (char *)__mptr - offsetof(type,member) );})
109
110struct rb_node
111{
112 unsigned long rb_parent_color;
113#define RB_RED 0
114#define RB_BLACK 1
115 struct rb_node *rb_right;
116 struct rb_node *rb_left;
117} __attribute__((aligned(sizeof(long))));
118 /* The alignment might seem pointless, but allegedly CRIS needs it */
119
120struct rb_root
121{
122 struct rb_node *rb_node;
123};
124
125
126#define rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
127#define rb_color(r) ((r)->rb_parent_color & 1)
128#define rb_is_red(r) (!rb_color(r))
129#define rb_is_black(r) rb_color(r)
130#define rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
131#define rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
132
133static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
134{
135 rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
136}
137static inline void rb_set_color(struct rb_node *rb, int color)
138{
139 rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
140}
141
142#define RB_ROOT (struct rb_root) { NULL, }
143#define rb_entry(ptr, type, member) container_of(ptr, type, member)
144
145#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
146#define RB_EMPTY_NODE(node) (rb_parent(node) == node)
147#define RB_CLEAR_NODE(node) (rb_set_parent(node, node))
148
149extern void rb_insert_color(struct rb_node *, struct rb_root *);
150extern void rb_erase(struct rb_node *, struct rb_root *);
151
152/* Find logical next and previous nodes in a tree */
153extern struct rb_node *rb_next(const struct rb_node *);
154extern struct rb_node *rb_prev(const struct rb_node *);
155extern struct rb_node *rb_first(const struct rb_root *);
156extern struct rb_node *rb_last(const struct rb_root *);
157
158/* Fast replacement of a single node without remove/rebalance/add/rebalance */
159extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
160 struct rb_root *root);
161
162static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
163 struct rb_node ** rb_link)
164{
165 node->rb_parent_color = (unsigned long )parent;
166 node->rb_left = node->rb_right = NULL;
167
168 *rb_link = node;
169}
170
171#endif /* _LINUX_RBTREE_H */
diff --git a/tools/perf/util/run-command.c b/tools/perf/util/run-command.c
index b2f5e854f40a..a3935343091a 100644
--- a/tools/perf/util/run-command.c
+++ b/tools/perf/util/run-command.c
@@ -65,7 +65,6 @@ int start_command(struct child_process *cmd)
65 cmd->err = fderr[0]; 65 cmd->err = fderr[0];
66 } 66 }
67 67
68#ifndef __MINGW32__
69 fflush(NULL); 68 fflush(NULL);
70 cmd->pid = fork(); 69 cmd->pid = fork();
71 if (!cmd->pid) { 70 if (!cmd->pid) {
@@ -118,71 +117,6 @@ int start_command(struct child_process *cmd)
118 } 117 }
119 exit(127); 118 exit(127);
120 } 119 }
121#else
122 int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
123 const char **sargv = cmd->argv;
124 char **env = environ;
125
126 if (cmd->no_stdin) {
127 s0 = dup(0);
128 dup_devnull(0);
129 } else if (need_in) {
130 s0 = dup(0);
131 dup2(fdin[0], 0);
132 } else if (cmd->in) {
133 s0 = dup(0);
134 dup2(cmd->in, 0);
135 }
136
137 if (cmd->no_stderr) {
138 s2 = dup(2);
139 dup_devnull(2);
140 } else if (need_err) {
141 s2 = dup(2);
142 dup2(fderr[1], 2);
143 }
144
145 if (cmd->no_stdout) {
146 s1 = dup(1);
147 dup_devnull(1);
148 } else if (cmd->stdout_to_stderr) {
149 s1 = dup(1);
150 dup2(2, 1);
151 } else if (need_out) {
152 s1 = dup(1);
153 dup2(fdout[1], 1);
154 } else if (cmd->out > 1) {
155 s1 = dup(1);
156 dup2(cmd->out, 1);
157 }
158
159 if (cmd->dir)
160 die("chdir in start_command() not implemented");
161 if (cmd->env) {
162 env = copy_environ();
163 for (; *cmd->env; cmd->env++)
164 env = env_setenv(env, *cmd->env);
165 }
166
167 if (cmd->perf_cmd) {
168 cmd->argv = prepare_perf_cmd(cmd->argv);
169 }
170
171 cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env);
172
173 if (cmd->env)
174 free_environ(env);
175 if (cmd->perf_cmd)
176 free(cmd->argv);
177
178 cmd->argv = sargv;
179 if (s0 >= 0)
180 dup2(s0, 0), close(s0);
181 if (s1 >= 0)
182 dup2(s1, 1), close(s1);
183 if (s2 >= 0)
184 dup2(s2, 2), close(s2);
185#endif
186 120
187 if (cmd->pid < 0) { 121 if (cmd->pid < 0) {
188 int err = errno; 122 int err = errno;
@@ -288,14 +222,6 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
288 return run_command(&cmd); 222 return run_command(&cmd);
289} 223}
290 224
291#ifdef __MINGW32__
292static __stdcall unsigned run_thread(void *data)
293{
294 struct async *async = data;
295 return async->proc(async->fd_for_proc, async->data);
296}
297#endif
298
299int start_async(struct async *async) 225int start_async(struct async *async)
300{ 226{
301 int pipe_out[2]; 227 int pipe_out[2];
@@ -304,7 +230,6 @@ int start_async(struct async *async)
304 return error("cannot create pipe: %s", strerror(errno)); 230 return error("cannot create pipe: %s", strerror(errno));
305 async->out = pipe_out[0]; 231 async->out = pipe_out[0];
306 232
307#ifndef __MINGW32__
308 /* Flush stdio before fork() to avoid cloning buffers */ 233 /* Flush stdio before fork() to avoid cloning buffers */
309 fflush(NULL); 234 fflush(NULL);
310 235
@@ -319,33 +244,17 @@ int start_async(struct async *async)
319 exit(!!async->proc(pipe_out[1], async->data)); 244 exit(!!async->proc(pipe_out[1], async->data));
320 } 245 }
321 close(pipe_out[1]); 246 close(pipe_out[1]);
322#else 247
323 async->fd_for_proc = pipe_out[1];
324 async->tid = (HANDLE) _beginthreadex(NULL, 0, run_thread, async, 0, NULL);
325 if (!async->tid) {
326 error("cannot create thread: %s", strerror(errno));
327 close_pair(pipe_out);
328 return -1;
329 }
330#endif
331 return 0; 248 return 0;
332} 249}
333 250
334int finish_async(struct async *async) 251int finish_async(struct async *async)
335{ 252{
336#ifndef __MINGW32__
337 int ret = 0; 253 int ret = 0;
338 254
339 if (wait_or_whine(async->pid)) 255 if (wait_or_whine(async->pid))
340 ret = error("waitpid (async) failed"); 256 ret = error("waitpid (async) failed");
341#else 257
342 DWORD ret = 0;
343 if (WaitForSingleObject(async->tid, INFINITE) != WAIT_OBJECT_0)
344 ret = error("waiting for thread failed: %lu", GetLastError());
345 else if (!GetExitCodeThread(async->tid, &ret))
346 ret = error("cannot get thread exit code: %lu", GetLastError());
347 CloseHandle(async->tid);
348#endif
349 return ret; 258 return ret;
350} 259}
351 260
diff --git a/tools/perf/util/run-command.h b/tools/perf/util/run-command.h
index 328289f23669..cc1837deba88 100644
--- a/tools/perf/util/run-command.h
+++ b/tools/perf/util/run-command.h
@@ -79,12 +79,7 @@ struct async {
79 int (*proc)(int fd, void *data); 79 int (*proc)(int fd, void *data);
80 void *data; 80 void *data;
81 int out; /* caller reads from here and closes it */ 81 int out; /* caller reads from here and closes it */
82#ifndef __MINGW32__
83 pid_t pid; 82 pid_t pid;
84#else
85 HANDLE tid;
86 int fd_for_proc;
87#endif
88}; 83};
89 84
90int start_async(struct async *async); 85int start_async(struct async *async);
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index eaba09306802..5249d5a1b0c2 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -16,7 +16,7 @@ int prefixcmp(const char *str, const char *prefix)
16 */ 16 */
17char strbuf_slopbuf[1]; 17char strbuf_slopbuf[1];
18 18
19void strbuf_init(struct strbuf *sb, size_t hint) 19void strbuf_init(struct strbuf *sb, ssize_t hint)
20{ 20{
21 sb->alloc = sb->len = 0; 21 sb->alloc = sb->len = 0;
22 sb->buf = strbuf_slopbuf; 22 sb->buf = strbuf_slopbuf;
@@ -92,7 +92,8 @@ void strbuf_ltrim(struct strbuf *sb)
92 92
93void strbuf_tolower(struct strbuf *sb) 93void strbuf_tolower(struct strbuf *sb)
94{ 94{
95 int i; 95 unsigned int i;
96
96 for (i = 0; i < sb->len; i++) 97 for (i = 0; i < sb->len; i++)
97 sb->buf[i] = tolower(sb->buf[i]); 98 sb->buf[i] = tolower(sb->buf[i]);
98} 99}
@@ -259,12 +260,12 @@ size_t strbuf_fread(struct strbuf *sb, size_t size, FILE *f)
259 res = fread(sb->buf + sb->len, 1, size, f); 260 res = fread(sb->buf + sb->len, 1, size, f);
260 if (res > 0) 261 if (res > 0)
261 strbuf_setlen(sb, sb->len + res); 262 strbuf_setlen(sb, sb->len + res);
262 else if (res < 0 && oldalloc == 0) 263 else if (oldalloc == 0)
263 strbuf_release(sb); 264 strbuf_release(sb);
264 return res; 265 return res;
265} 266}
266 267
267ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint) 268ssize_t strbuf_read(struct strbuf *sb, int fd, ssize_t hint)
268{ 269{
269 size_t oldlen = sb->len; 270 size_t oldlen = sb->len;
270 size_t oldalloc = sb->alloc; 271 size_t oldalloc = sb->alloc;
@@ -293,7 +294,7 @@ ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint)
293 294
294#define STRBUF_MAXLINK (2*PATH_MAX) 295#define STRBUF_MAXLINK (2*PATH_MAX)
295 296
296int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint) 297int strbuf_readlink(struct strbuf *sb, const char *path, ssize_t hint)
297{ 298{
298 size_t oldalloc = sb->alloc; 299 size_t oldalloc = sb->alloc;
299 300
@@ -301,7 +302,7 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
301 hint = 32; 302 hint = 32;
302 303
303 while (hint < STRBUF_MAXLINK) { 304 while (hint < STRBUF_MAXLINK) {
304 int len; 305 ssize_t len;
305 306
306 strbuf_grow(sb, hint); 307 strbuf_grow(sb, hint);
307 len = readlink(path, sb->buf, hint); 308 len = readlink(path, sb->buf, hint);
@@ -343,7 +344,7 @@ int strbuf_getline(struct strbuf *sb, FILE *fp, int term)
343 return 0; 344 return 0;
344} 345}
345 346
346int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint) 347int strbuf_read_file(struct strbuf *sb, const char *path, ssize_t hint)
347{ 348{
348 int fd, len; 349 int fd, len;
349 350
diff --git a/tools/perf/util/strbuf.h b/tools/perf/util/strbuf.h
index 9ee908a3ec5d..d2aa86c014c1 100644
--- a/tools/perf/util/strbuf.h
+++ b/tools/perf/util/strbuf.h
@@ -50,7 +50,7 @@ struct strbuf {
50#define STRBUF_INIT { 0, 0, strbuf_slopbuf } 50#define STRBUF_INIT { 0, 0, strbuf_slopbuf }
51 51
52/*----- strbuf life cycle -----*/ 52/*----- strbuf life cycle -----*/
53extern void strbuf_init(struct strbuf *, size_t); 53extern void strbuf_init(struct strbuf *buf, ssize_t hint);
54extern void strbuf_release(struct strbuf *); 54extern void strbuf_release(struct strbuf *);
55extern char *strbuf_detach(struct strbuf *, size_t *); 55extern char *strbuf_detach(struct strbuf *, size_t *);
56extern void strbuf_attach(struct strbuf *, void *, size_t, size_t); 56extern void strbuf_attach(struct strbuf *, void *, size_t, size_t);
@@ -61,7 +61,7 @@ static inline void strbuf_swap(struct strbuf *a, struct strbuf *b) {
61} 61}
62 62
63/*----- strbuf size related -----*/ 63/*----- strbuf size related -----*/
64static inline size_t strbuf_avail(const struct strbuf *sb) { 64static inline ssize_t strbuf_avail(const struct strbuf *sb) {
65 return sb->alloc ? sb->alloc - sb->len - 1 : 0; 65 return sb->alloc ? sb->alloc - sb->len - 1 : 0;
66} 66}
67 67
@@ -122,9 +122,9 @@ extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
122 122
123extern size_t strbuf_fread(struct strbuf *, size_t, FILE *); 123extern size_t strbuf_fread(struct strbuf *, size_t, FILE *);
124/* XXX: if read fails, any partial read is undone */ 124/* XXX: if read fails, any partial read is undone */
125extern ssize_t strbuf_read(struct strbuf *, int fd, size_t hint); 125extern ssize_t strbuf_read(struct strbuf *, int fd, ssize_t hint);
126extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint); 126extern int strbuf_read_file(struct strbuf *sb, const char *path, ssize_t hint);
127extern int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint); 127extern int strbuf_readlink(struct strbuf *sb, const char *path, ssize_t hint);
128 128
129extern int strbuf_getline(struct strbuf *, FILE *, int); 129extern int strbuf_getline(struct strbuf *, FILE *, int);
130 130
diff --git a/tools/perf/util/string.h b/tools/perf/util/string.h
index 37b03255b425..3dca2f654cd0 100644
--- a/tools/perf/util/string.h
+++ b/tools/perf/util/string.h
@@ -1,7 +1,7 @@
1#ifndef _PERF_STRING_H_ 1#ifndef _PERF_STRING_H_
2#define _PERF_STRING_H_ 2#define _PERF_STRING_H_
3 3
4#include "../types.h" 4#include "types.h"
5 5
6int hex2u64(const char *ptr, u64 *val); 6int hex2u64(const char *ptr, u64 *val);
7 7
diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
new file mode 100644
index 000000000000..025a78edfffe
--- /dev/null
+++ b/tools/perf/util/strlist.c
@@ -0,0 +1,184 @@
1/*
2 * (c) 2009 Arnaldo Carvalho de Melo <acme@redhat.com>
3 *
4 * Licensed under the GPLv2.
5 */
6
7#include "strlist.h"
8#include <errno.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12
13static struct str_node *str_node__new(const char *s, bool dupstr)
14{
15 struct str_node *self = malloc(sizeof(*self));
16
17 if (self != NULL) {
18 if (dupstr) {
19 s = strdup(s);
20 if (s == NULL)
21 goto out_delete;
22 }
23 self->s = s;
24 }
25
26 return self;
27
28out_delete:
29 free(self);
30 return NULL;
31}
32
33static void str_node__delete(struct str_node *self, bool dupstr)
34{
35 if (dupstr)
36 free((void *)self->s);
37 free(self);
38}
39
40int strlist__add(struct strlist *self, const char *new_entry)
41{
42 struct rb_node **p = &self->entries.rb_node;
43 struct rb_node *parent = NULL;
44 struct str_node *sn;
45
46 while (*p != NULL) {
47 int rc;
48
49 parent = *p;
50 sn = rb_entry(parent, struct str_node, rb_node);
51 rc = strcmp(sn->s, new_entry);
52
53 if (rc > 0)
54 p = &(*p)->rb_left;
55 else if (rc < 0)
56 p = &(*p)->rb_right;
57 else
58 return -EEXIST;
59 }
60
61 sn = str_node__new(new_entry, self->dupstr);
62 if (sn == NULL)
63 return -ENOMEM;
64
65 rb_link_node(&sn->rb_node, parent, p);
66 rb_insert_color(&sn->rb_node, &self->entries);
67
68 return 0;
69}
70
71int strlist__load(struct strlist *self, const char *filename)
72{
73 char entry[1024];
74 int err;
75 FILE *fp = fopen(filename, "r");
76
77 if (fp == NULL)
78 return errno;
79
80 while (fgets(entry, sizeof(entry), fp) != NULL) {
81 const size_t len = strlen(entry);
82
83 if (len == 0)
84 continue;
85 entry[len - 1] = '\0';
86
87 err = strlist__add(self, entry);
88 if (err != 0)
89 goto out;
90 }
91
92 err = 0;
93out:
94 fclose(fp);
95 return err;
96}
97
98void strlist__remove(struct strlist *self, struct str_node *sn)
99{
100 rb_erase(&sn->rb_node, &self->entries);
101 str_node__delete(sn, self->dupstr);
102}
103
104bool strlist__has_entry(struct strlist *self, const char *entry)
105{
106 struct rb_node **p = &self->entries.rb_node;
107 struct rb_node *parent = NULL;
108
109 while (*p != NULL) {
110 struct str_node *sn;
111 int rc;
112
113 parent = *p;
114 sn = rb_entry(parent, struct str_node, rb_node);
115 rc = strcmp(sn->s, entry);
116
117 if (rc > 0)
118 p = &(*p)->rb_left;
119 else if (rc < 0)
120 p = &(*p)->rb_right;
121 else
122 return true;
123 }
124
125 return false;
126}
127
128static int strlist__parse_list_entry(struct strlist *self, const char *s)
129{
130 if (strncmp(s, "file://", 7) == 0)
131 return strlist__load(self, s + 7);
132
133 return strlist__add(self, s);
134}
135
136int strlist__parse_list(struct strlist *self, const char *s)
137{
138 char *sep;
139 int err;
140
141 while ((sep = strchr(s, ',')) != NULL) {
142 *sep = '\0';
143 err = strlist__parse_list_entry(self, s);
144 *sep = ',';
145 if (err != 0)
146 return err;
147 s = sep + 1;
148 }
149
150 return *s ? strlist__parse_list_entry(self, s) : 0;
151}
152
153struct strlist *strlist__new(bool dupstr, const char *slist)
154{
155 struct strlist *self = malloc(sizeof(*self));
156
157 if (self != NULL) {
158 self->entries = RB_ROOT;
159 self->dupstr = dupstr;
160 if (slist && strlist__parse_list(self, slist) != 0)
161 goto out_error;
162 }
163
164 return self;
165out_error:
166 free(self);
167 return NULL;
168}
169
170void strlist__delete(struct strlist *self)
171{
172 if (self != NULL) {
173 struct str_node *pos;
174 struct rb_node *next = rb_first(&self->entries);
175
176 while (next) {
177 pos = rb_entry(next, struct str_node, rb_node);
178 next = rb_next(&pos->rb_node);
179 strlist__remove(self, pos);
180 }
181 self->entries = RB_ROOT;
182 free(self);
183 }
184}
diff --git a/tools/perf/util/strlist.h b/tools/perf/util/strlist.h
new file mode 100644
index 000000000000..2fdcfee87586
--- /dev/null
+++ b/tools/perf/util/strlist.h
@@ -0,0 +1,32 @@
1#ifndef STRLIST_H_
2#define STRLIST_H_
3
4#include <linux/rbtree.h>
5#include <stdbool.h>
6
7struct str_node {
8 struct rb_node rb_node;
9 const char *s;
10};
11
12struct strlist {
13 struct rb_root entries;
14 bool dupstr;
15};
16
17struct strlist *strlist__new(bool dupstr, const char *slist);
18void strlist__delete(struct strlist *self);
19
20void strlist__remove(struct strlist *self, struct str_node *sn);
21int strlist__load(struct strlist *self, const char *filename);
22int strlist__add(struct strlist *self, const char *str);
23
24bool strlist__has_entry(struct strlist *self, const char *entry);
25
26static inline bool strlist__empty(const struct strlist *self)
27{
28 return rb_first(&self->entries) == NULL;
29}
30
31int strlist__parse_list(struct strlist *self, const char *s);
32#endif /* STRLIST_H_ */
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 86e14375e74e..4683b67b5ee4 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -35,7 +35,7 @@ static struct symbol *symbol__new(u64 start, u64 len,
35 self = ((void *)self) + priv_size; 35 self = ((void *)self) + priv_size;
36 } 36 }
37 self->start = start; 37 self->start = start;
38 self->end = start + len - 1; 38 self->end = len ? start + len - 1 : start;
39 memcpy(self->name, name, namelen); 39 memcpy(self->name, name, namelen);
40 40
41 return self; 41 return self;
@@ -48,8 +48,12 @@ static void symbol__delete(struct symbol *self, unsigned int priv_size)
48 48
49static size_t symbol__fprintf(struct symbol *self, FILE *fp) 49static size_t symbol__fprintf(struct symbol *self, FILE *fp)
50{ 50{
51 return fprintf(fp, " %llx-%llx %s\n", 51 if (!self->module)
52 return fprintf(fp, " %llx-%llx %s\n",
52 self->start, self->end, self->name); 53 self->start, self->end, self->name);
54 else
55 return fprintf(fp, " %llx-%llx %s \t[%s]\n",
56 self->start, self->end, self->name, self->module->name);
53} 57}
54 58
55struct dso *dso__new(const char *name, unsigned int sym_priv_size) 59struct dso *dso__new(const char *name, unsigned int sym_priv_size)
@@ -146,6 +150,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
146 char *line = NULL; 150 char *line = NULL;
147 size_t n; 151 size_t n;
148 FILE *file = fopen("/proc/kallsyms", "r"); 152 FILE *file = fopen("/proc/kallsyms", "r");
153 int count = 0;
149 154
150 if (file == NULL) 155 if (file == NULL)
151 goto out_failure; 156 goto out_failure;
@@ -188,8 +193,10 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
188 193
189 if (filter && filter(self, sym)) 194 if (filter && filter(self, sym))
190 symbol__delete(sym, self->sym_priv_size); 195 symbol__delete(sym, self->sym_priv_size);
191 else 196 else {
192 dso__insert_symbol(self, sym); 197 dso__insert_symbol(self, sym);
198 count++;
199 }
193 } 200 }
194 201
195 /* 202 /*
@@ -212,7 +219,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
212 free(line); 219 free(line);
213 fclose(file); 220 fclose(file);
214 221
215 return 0; 222 return count;
216 223
217out_delete_line: 224out_delete_line:
218 free(line); 225 free(line);
@@ -307,6 +314,26 @@ static inline int elf_sym__is_function(const GElf_Sym *sym)
307 sym->st_size != 0; 314 sym->st_size != 0;
308} 315}
309 316
317static inline int elf_sym__is_label(const GElf_Sym *sym)
318{
319 return elf_sym__type(sym) == STT_NOTYPE &&
320 sym->st_name != 0 &&
321 sym->st_shndx != SHN_UNDEF &&
322 sym->st_shndx != SHN_ABS;
323}
324
325static inline const char *elf_sec__name(const GElf_Shdr *shdr,
326 const Elf_Data *secstrs)
327{
328 return secstrs->d_buf + shdr->sh_name;
329}
330
331static inline int elf_sec__is_text(const GElf_Shdr *shdr,
332 const Elf_Data *secstrs)
333{
334 return strstr(elf_sec__name(shdr, secstrs), "text") != NULL;
335}
336
310static inline const char *elf_sym__name(const GElf_Sym *sym, 337static inline const char *elf_sym__name(const GElf_Sym *sym,
311 const Elf_Data *symstrs) 338 const Elf_Data *symstrs)
312{ 339{
@@ -448,9 +475,9 @@ static int dso__synthesize_plt_symbols(struct dso *self, Elf *elf,
448} 475}
449 476
450static int dso__load_sym(struct dso *self, int fd, const char *name, 477static int dso__load_sym(struct dso *self, int fd, const char *name,
451 symbol_filter_t filter, int verbose) 478 symbol_filter_t filter, int verbose, struct module *mod)
452{ 479{
453 Elf_Data *symstrs; 480 Elf_Data *symstrs, *secstrs;
454 uint32_t nr_syms; 481 uint32_t nr_syms;
455 int err = -1; 482 int err = -1;
456 uint32_t index; 483 uint32_t index;
@@ -458,7 +485,7 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
458 GElf_Shdr shdr; 485 GElf_Shdr shdr;
459 Elf_Data *syms; 486 Elf_Data *syms;
460 GElf_Sym sym; 487 GElf_Sym sym;
461 Elf_Scn *sec, *sec_dynsym; 488 Elf_Scn *sec, *sec_dynsym, *sec_strndx;
462 Elf *elf; 489 Elf *elf;
463 size_t dynsym_idx; 490 size_t dynsym_idx;
464 int nr = 0; 491 int nr = 0;
@@ -517,15 +544,29 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
517 if (symstrs == NULL) 544 if (symstrs == NULL)
518 goto out_elf_end; 545 goto out_elf_end;
519 546
547 sec_strndx = elf_getscn(elf, ehdr.e_shstrndx);
548 if (sec_strndx == NULL)
549 goto out_elf_end;
550
551 secstrs = elf_getdata(sec_strndx, NULL);
552 if (symstrs == NULL)
553 goto out_elf_end;
554
520 nr_syms = shdr.sh_size / shdr.sh_entsize; 555 nr_syms = shdr.sh_size / shdr.sh_entsize;
521 556
522 memset(&sym, 0, sizeof(sym)); 557 memset(&sym, 0, sizeof(sym));
523 558 self->adjust_symbols = (ehdr.e_type == ET_EXEC ||
559 elf_section_by_name(elf, &ehdr, &shdr,
560 ".gnu.prelink_undo",
561 NULL) != NULL);
524 elf_symtab__for_each_symbol(syms, nr_syms, index, sym) { 562 elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
525 struct symbol *f; 563 struct symbol *f;
526 u64 obj_start; 564 u64 obj_start;
565 struct section *section = NULL;
566 int is_label = elf_sym__is_label(&sym);
567 const char *section_name;
527 568
528 if (!elf_sym__is_function(&sym)) 569 if (!is_label && !elf_sym__is_function(&sym))
529 continue; 570 continue;
530 571
531 sec = elf_getscn(elf, sym.st_shndx); 572 sec = elf_getscn(elf, sym.st_shndx);
@@ -533,9 +574,31 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
533 goto out_elf_end; 574 goto out_elf_end;
534 575
535 gelf_getshdr(sec, &shdr); 576 gelf_getshdr(sec, &shdr);
577
578 if (is_label && !elf_sec__is_text(&shdr, secstrs))
579 continue;
580
581 section_name = elf_sec__name(&shdr, secstrs);
536 obj_start = sym.st_value; 582 obj_start = sym.st_value;
537 583
538 sym.st_value -= shdr.sh_addr - shdr.sh_offset; 584 if (self->adjust_symbols) {
585 if (verbose >= 2)
586 printf("adjusting symbol: st_value: %Lx sh_addr: %Lx sh_offset: %Lx\n",
587 (u64)sym.st_value, (u64)shdr.sh_addr, (u64)shdr.sh_offset);
588
589 sym.st_value -= shdr.sh_addr - shdr.sh_offset;
590 }
591
592 if (mod) {
593 section = mod->sections->find_section(mod->sections, section_name);
594 if (section)
595 sym.st_value += section->vma;
596 else {
597 fprintf(stderr, "dso__load_sym() module %s lookup of %s failed\n",
598 mod->name, section_name);
599 goto out_elf_end;
600 }
601 }
539 602
540 f = symbol__new(sym.st_value, sym.st_size, 603 f = symbol__new(sym.st_value, sym.st_size,
541 elf_sym__name(&sym, symstrs), 604 elf_sym__name(&sym, symstrs),
@@ -546,6 +609,7 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
546 if (filter && filter(self, f)) 609 if (filter && filter(self, f))
547 symbol__delete(f, self->sym_priv_size); 610 symbol__delete(f, self->sym_priv_size);
548 else { 611 else {
612 f->module = mod;
549 dso__insert_symbol(self, f); 613 dso__insert_symbol(self, f);
550 nr++; 614 nr++;
551 } 615 }
@@ -569,6 +633,8 @@ int dso__load(struct dso *self, symbol_filter_t filter, int verbose)
569 if (!name) 633 if (!name)
570 return -1; 634 return -1;
571 635
636 self->adjust_symbols = 0;
637
572 if (strncmp(self->name, "/tmp/perf-", 10) == 0) 638 if (strncmp(self->name, "/tmp/perf-", 10) == 0)
573 return dso__load_perf_map(self, filter, verbose); 639 return dso__load_perf_map(self, filter, verbose);
574 640
@@ -593,7 +659,7 @@ more:
593 fd = open(name, O_RDONLY); 659 fd = open(name, O_RDONLY);
594 } while (fd < 0); 660 } while (fd < 0);
595 661
596 ret = dso__load_sym(self, fd, name, filter, verbose); 662 ret = dso__load_sym(self, fd, name, filter, verbose, NULL);
597 close(fd); 663 close(fd);
598 664
599 /* 665 /*
@@ -607,6 +673,86 @@ out:
607 return ret; 673 return ret;
608} 674}
609 675
676static int dso__load_module(struct dso *self, struct mod_dso *mods, const char *name,
677 symbol_filter_t filter, int verbose)
678{
679 struct module *mod = mod_dso__find_module(mods, name);
680 int err = 0, fd;
681
682 if (mod == NULL || !mod->active)
683 return err;
684
685 fd = open(mod->path, O_RDONLY);
686
687 if (fd < 0)
688 return err;
689
690 err = dso__load_sym(self, fd, name, filter, verbose, mod);
691 close(fd);
692
693 return err;
694}
695
696int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose)
697{
698 struct mod_dso *mods = mod_dso__new_dso("modules");
699 struct module *pos;
700 struct rb_node *next;
701 int err;
702
703 err = mod_dso__load_modules(mods);
704
705 if (err <= 0)
706 return err;
707
708 /*
709 * Iterate over modules, and load active symbols.
710 */
711 next = rb_first(&mods->mods);
712 while (next) {
713 pos = rb_entry(next, struct module, rb_node);
714 err = dso__load_module(self, mods, pos->name, filter, verbose);
715
716 if (err < 0)
717 break;
718
719 next = rb_next(&pos->rb_node);
720 }
721
722 if (err < 0) {
723 mod_dso__delete_modules(mods);
724 mod_dso__delete_self(mods);
725 }
726
727 return err;
728}
729
730static inline void dso__fill_symbol_holes(struct dso *self)
731{
732 struct symbol *prev = NULL;
733 struct rb_node *nd;
734
735 for (nd = rb_last(&self->syms); nd; nd = rb_prev(nd)) {
736 struct symbol *pos = rb_entry(nd, struct symbol, rb_node);
737
738 if (prev) {
739 u64 hole = 0;
740 int alias = pos->start == prev->start;
741
742 if (!alias)
743 hole = prev->start - pos->end - 1;
744
745 if (hole || alias) {
746 if (alias)
747 pos->end = prev->end;
748 else if (hole)
749 pos->end = prev->start - 1;
750 }
751 }
752 prev = pos;
753 }
754}
755
610static int dso__load_vmlinux(struct dso *self, const char *vmlinux, 756static int dso__load_vmlinux(struct dso *self, const char *vmlinux,
611 symbol_filter_t filter, int verbose) 757 symbol_filter_t filter, int verbose)
612{ 758{
@@ -615,21 +761,28 @@ static int dso__load_vmlinux(struct dso *self, const char *vmlinux,
615 if (fd < 0) 761 if (fd < 0)
616 return -1; 762 return -1;
617 763
618 err = dso__load_sym(self, fd, vmlinux, filter, verbose); 764 err = dso__load_sym(self, fd, vmlinux, filter, verbose, NULL);
765
766 if (err > 0)
767 dso__fill_symbol_holes(self);
768
619 close(fd); 769 close(fd);
620 770
621 return err; 771 return err;
622} 772}
623 773
624int dso__load_kernel(struct dso *self, const char *vmlinux, 774int dso__load_kernel(struct dso *self, const char *vmlinux,
625 symbol_filter_t filter, int verbose) 775 symbol_filter_t filter, int verbose, int modules)
626{ 776{
627 int err = -1; 777 int err = -1;
628 778
629 if (vmlinux) 779 if (vmlinux) {
630 err = dso__load_vmlinux(self, vmlinux, filter, verbose); 780 err = dso__load_vmlinux(self, vmlinux, filter, verbose);
781 if (err > 0 && modules)
782 err = dso__load_modules(self, filter, verbose);
783 }
631 784
632 if (err) 785 if (err <= 0)
633 err = dso__load_kallsyms(self, filter, verbose); 786 err = dso__load_kallsyms(self, filter, verbose);
634 787
635 return err; 788 return err;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index ea332e56e458..7918cffb23cd 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -2,9 +2,10 @@
2#define _PERF_SYMBOL_ 1 2#define _PERF_SYMBOL_ 1
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include "../types.h" 5#include "types.h"
6#include "list.h" 6#include <linux/list.h>
7#include "rbtree.h" 7#include <linux/rbtree.h>
8#include "module.h"
8 9
9struct symbol { 10struct symbol {
10 struct rb_node rb_node; 11 struct rb_node rb_node;
@@ -13,6 +14,7 @@ struct symbol {
13 u64 obj_start; 14 u64 obj_start;
14 u64 hist_sum; 15 u64 hist_sum;
15 u64 *hist; 16 u64 *hist;
17 struct module *module;
16 void *priv; 18 void *priv;
17 char name[0]; 19 char name[0];
18}; 20};
@@ -20,8 +22,9 @@ struct symbol {
20struct dso { 22struct dso {
21 struct list_head node; 23 struct list_head node;
22 struct rb_root syms; 24 struct rb_root syms;
23 unsigned int sym_priv_size;
24 struct symbol *(*find_symbol)(struct dso *, u64 ip); 25 struct symbol *(*find_symbol)(struct dso *, u64 ip);
26 unsigned int sym_priv_size;
27 unsigned char adjust_symbols;
25 char name[0]; 28 char name[0];
26}; 29};
27 30
@@ -40,7 +43,8 @@ static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
40struct symbol *dso__find_symbol(struct dso *self, u64 ip); 43struct symbol *dso__find_symbol(struct dso *self, u64 ip);
41 44
42int dso__load_kernel(struct dso *self, const char *vmlinux, 45int dso__load_kernel(struct dso *self, const char *vmlinux,
43 symbol_filter_t filter, int verbose); 46 symbol_filter_t filter, int verbose, int modules);
47int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose);
44int dso__load(struct dso *self, symbol_filter_t filter, int verbose); 48int dso__load(struct dso *self, symbol_filter_t filter, int verbose);
45 49
46size_t dso__fprintf(struct dso *self, FILE *fp); 50size_t dso__fprintf(struct dso *self, FILE *fp);
diff --git a/tools/perf/types.h b/tools/perf/util/types.h
index 5e75f9005940..5e75f9005940 100644
--- a/tools/perf/types.h
+++ b/tools/perf/util/types.h
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index b8cfed776d81..b4be6071c105 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -67,7 +67,6 @@
67#include <assert.h> 67#include <assert.h>
68#include <regex.h> 68#include <regex.h>
69#include <utime.h> 69#include <utime.h>
70#ifndef __MINGW32__
71#include <sys/wait.h> 70#include <sys/wait.h>
72#include <sys/poll.h> 71#include <sys/poll.h>
73#include <sys/socket.h> 72#include <sys/socket.h>
@@ -81,20 +80,6 @@
81#include <netdb.h> 80#include <netdb.h>
82#include <pwd.h> 81#include <pwd.h>
83#include <inttypes.h> 82#include <inttypes.h>
84#if defined(__CYGWIN__)
85#undef _XOPEN_SOURCE
86#include <grp.h>
87#define _XOPEN_SOURCE 600
88#include "compat/cygwin.h"
89#else
90#undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
91#include <grp.h>
92#define _ALL_SOURCE 1
93#endif
94#else /* __MINGW32__ */
95/* pull in Windows compatibility stuff */
96#include "compat/mingw.h"
97#endif /* __MINGW32__ */
98 83
99#ifndef NO_ICONV 84#ifndef NO_ICONV
100#include <iconv.h> 85#include <iconv.h>
diff --git a/tools/perf/util/wrapper.c b/tools/perf/util/wrapper.c
index 6350d65f6d9e..4574ac28396f 100644
--- a/tools/perf/util/wrapper.c
+++ b/tools/perf/util/wrapper.c
@@ -7,7 +7,7 @@
7 * There's no pack memory to release - but stay close to the Git 7 * There's no pack memory to release - but stay close to the Git
8 * version so wrap this away: 8 * version so wrap this away:
9 */ 9 */
10static inline void release_pack_memory(size_t size, int flag) 10static inline void release_pack_memory(size_t size __used, int flag __used)
11{ 11{
12} 12}
13 13
@@ -59,7 +59,8 @@ void *xmemdupz(const void *data, size_t len)
59char *xstrndup(const char *str, size_t len) 59char *xstrndup(const char *str, size_t len)
60{ 60{
61 char *p = memchr(str, '\0', len); 61 char *p = memchr(str, '\0', len);
62 return xmemdupz(str, p ? p - str : len); 62
63 return xmemdupz(str, p ? (size_t)(p - str) : len);
63} 64}
64 65
65void *xrealloc(void *ptr, size_t size) 66void *xrealloc(void *ptr, size_t size)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 764554350ed8..2884baf1d5f9 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -746,6 +746,7 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req)
746 cpumask_clear(cpus); 746 cpumask_clear(cpus);
747 747
748 me = get_cpu(); 748 me = get_cpu();
749 spin_lock(&kvm->requests_lock);
749 for (i = 0; i < KVM_MAX_VCPUS; ++i) { 750 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
750 vcpu = kvm->vcpus[i]; 751 vcpu = kvm->vcpus[i];
751 if (!vcpu) 752 if (!vcpu)
@@ -762,6 +763,7 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req)
762 smp_call_function_many(cpus, ack_flush, NULL, 1); 763 smp_call_function_many(cpus, ack_flush, NULL, 1);
763 else 764 else
764 called = false; 765 called = false;
766 spin_unlock(&kvm->requests_lock);
765 put_cpu(); 767 put_cpu();
766 free_cpumask_var(cpus); 768 free_cpumask_var(cpus);
767 return called; 769 return called;
@@ -982,6 +984,7 @@ static struct kvm *kvm_create_vm(void)
982 kvm->mm = current->mm; 984 kvm->mm = current->mm;
983 atomic_inc(&kvm->mm->mm_count); 985 atomic_inc(&kvm->mm->mm_count);
984 spin_lock_init(&kvm->mmu_lock); 986 spin_lock_init(&kvm->mmu_lock);
987 spin_lock_init(&kvm->requests_lock);
985 kvm_io_bus_init(&kvm->pio_bus); 988 kvm_io_bus_init(&kvm->pio_bus);
986 mutex_init(&kvm->lock); 989 mutex_init(&kvm->lock);
987 kvm_io_bus_init(&kvm->mmio_bus); 990 kvm_io_bus_init(&kvm->mmio_bus);
@@ -1194,6 +1197,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
1194 if (!new.dirty_bitmap) 1197 if (!new.dirty_bitmap)
1195 goto out_free; 1198 goto out_free;
1196 memset(new.dirty_bitmap, 0, dirty_bytes); 1199 memset(new.dirty_bitmap, 0, dirty_bytes);
1200 if (old.npages)
1201 kvm_arch_flush_shadow(kvm);
1197 } 1202 }
1198#endif /* not defined CONFIG_S390 */ 1203#endif /* not defined CONFIG_S390 */
1199 1204