aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-bus-rbd83
-rw-r--r--Documentation/ABI/testing/sysfs-platform-asus-laptop16
-rw-r--r--Documentation/ABI/testing/sysfs-platform-eeepc-wmi10
-rw-r--r--Documentation/DocBook/sh.tmpl4
-rw-r--r--Documentation/DocBook/uio-howto.tmpl6
-rw-r--r--Documentation/development-process/2.Process33
-rw-r--r--Documentation/driver-model/interface.txt129
-rw-r--r--Documentation/edac.txt8
-rw-r--r--Documentation/fb/00-INDEX32
-rw-r--r--Documentation/filesystems/Locking7
-rw-r--r--Documentation/filesystems/configfs/configfs_example_explicit.c2
-rw-r--r--Documentation/filesystems/vfs.txt16
-rw-r--r--Documentation/gpio.txt10
-rw-r--r--Documentation/hwmon/lm932
-rw-r--r--Documentation/hwmon/max66502
-rw-r--r--Documentation/kernel-parameters.txt10
-rw-r--r--Documentation/networking/ip-sysctl.txt1
-rw-r--r--Documentation/power/opp.txt3
-rw-r--r--Documentation/power/runtime_pm.txt4
-rw-r--r--Documentation/sh/clk.txt32
-rw-r--r--MAINTAINERS40
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig6
-rw-r--r--arch/arm/boot/Makefile5
-rw-r--r--arch/arm/boot/bootp/init.S2
-rw-r--r--arch/arm/boot/compressed/head.S15
-rw-r--r--arch/arm/boot/compressed/vmlinux.lds.in2
-rw-r--r--arch/arm/common/gic.c40
-rw-r--r--arch/arm/configs/at91rm9200_defconfig341
-rw-r--r--arch/arm/configs/at91rm9200dk_defconfig72
-rw-r--r--arch/arm/configs/at91rm9200ek_defconfig73
-rw-r--r--arch/arm/configs/ateb9200_defconfig131
-rw-r--r--arch/arm/configs/carmeva_defconfig47
-rw-r--r--arch/arm/configs/cpuat91_defconfig112
-rw-r--r--arch/arm/configs/csb337_defconfig104
-rw-r--r--arch/arm/configs/csb637_defconfig98
-rw-r--r--arch/arm/configs/ecbat91_defconfig99
-rw-r--r--arch/arm/configs/kafa_defconfig61
-rw-r--r--arch/arm/configs/kb9202_defconfig127
-rw-r--r--arch/arm/configs/onearm_defconfig80
-rw-r--r--arch/arm/configs/picotux200_defconfig242
-rw-r--r--arch/arm/configs/yl9200_defconfig137
-rw-r--r--arch/arm/include/asm/assembler.h2
-rw-r--r--arch/arm/include/asm/mmu.h4
-rw-r--r--arch/arm/include/asm/pgtable.h3
-rw-r--r--arch/arm/kernel/entry-armv.S2
-rw-r--r--arch/arm/kernel/head.S7
-rw-r--r--arch/arm/kernel/relocate_kernel.S2
-rw-r--r--arch/arm/lib/findbit.S6
-rw-r--r--arch/arm/mach-aaec2000/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-at91/Makefile6
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c45
-rw-r--r--arch/arm/mach-at91/board-1arm.c26
-rw-r--r--arch/arm/mach-at91/board-kafa.c21
-rw-r--r--arch/arm/mach-at91/board-pcontrol-g20.c98
-rw-r--r--arch/arm/mach-at91/board-picotux200.c53
-rw-r--r--arch/arm/mach-at91/board-rm9200dk.c (renamed from arch/arm/mach-at91/board-dk.c)4
-rw-r--r--arch/arm/mach-at91/board-rm9200ek.c (renamed from arch/arm/mach-at91/board-ek.c)4
-rw-r--r--arch/arm/mach-at91/board-stamp9g20.c82
-rw-r--r--arch/arm/mach-at91/board-yl-9200.c2
-rw-r--r--arch/arm/mach-at91/clock.c2
-rw-r--r--arch/arm/mach-at91/include/mach/board.h6
-rw-r--r--arch/arm/mach-at91/include/mach/stamp9g20.h7
-rw-r--r--arch/arm/mach-bcmring/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-clps711x/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-cns3xxx/pcie.c2
-rw-r--r--arch/arm/mach-davinci/dm355.c6
-rw-r--r--arch/arm/mach-davinci/dm365.c6
-rw-r--r--arch/arm/mach-davinci/dm644x.c4
-rw-r--r--arch/arm/mach-ebsa110/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-footbridge/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-h720x/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-imx/eukrea_mbimx27-baseboard.c6
-rw-r--r--arch/arm/mach-integrator/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-mmp/mmp2.c1
-rw-r--r--arch/arm/mach-msm/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-mx25/devices-imx25.h4
-rw-r--r--arch/arm/mach-mx3/mach-pcm037_eet.c5
-rw-r--r--arch/arm/mach-netx/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-omap1/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-omap2/board-zoom-peripherals.c2
-rw-r--r--arch/arm/mach-omap2/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-omap2/io.c2
-rw-r--r--arch/arm/mach-omap2/pm-debug.c34
-rw-r--r--arch/arm/mach-omap2/pm24xx.c35
-rw-r--r--arch/arm/mach-omap2/pm34xx.c27
-rw-r--r--arch/arm/mach-omap2/prcm-common.h11
-rw-r--r--arch/arm/mach-omap2/serial.c7
-rw-r--r--arch/arm/mach-pnx4008/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-pxa/palmtx.c3
-rw-r--r--arch/arm/mach-realview/headsmp.S1
-rw-r--r--arch/arm/mach-rpc/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s3c2410/h1940-bluetooth.c8
-rw-r--r--arch/arm/mach-s3c2412/Kconfig9
-rw-r--r--arch/arm/mach-s3c2412/Makefile3
-rw-r--r--arch/arm/mach-s3c2416/Kconfig4
-rw-r--r--arch/arm/mach-s3c2416/irq.c5
-rw-r--r--arch/arm/mach-s3c2440/Kconfig4
-rw-r--r--arch/arm/mach-s3c2440/s3c2440.c11
-rw-r--r--arch/arm/mach-s3c2440/s3c2442.c14
-rw-r--r--arch/arm/mach-s3c2443/Kconfig1
-rw-r--r--arch/arm/mach-s3c2443/irq.c5
-rw-r--r--arch/arm/mach-s3c64xx/mach-mini6410.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-real6410.c2
-rw-r--r--arch/arm/mach-s5pv210/mach-aquila.c6
-rw-r--r--arch/arm/mach-s5pv210/mach-goni.c6
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkc110.c1
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkv210.c1
-rw-r--r--arch/arm/mach-shark/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c211
-rw-r--r--arch/arm/mach-shmobile/clock-sh7372.c52
-rw-r--r--arch/arm/mach-shmobile/include/mach/entry-macro.S30
-rw-r--r--arch/arm/mach-shmobile/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-tegra/include/mach/debug-macro.S4
-rw-r--r--arch/arm/mach-ux500/cpu.c6
-rw-r--r--arch/arm/mach-versatile/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-vexpress/headsmp.S1
-rw-r--r--arch/arm/mm/cache-v6.S28
-rw-r--r--arch/arm/mm/cache-v7.S27
-rw-r--r--arch/arm/mm/ioremap.c4
-rw-r--r--arch/arm/mm/proc-macros.S22
-rw-r--r--arch/arm/mm/proc-v7.S4
-rw-r--r--arch/arm/plat-iop/time.c3
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-dma.c8
-rw-r--r--arch/arm/plat-mxc/devices/platform-spi_imx.c1
-rw-r--r--arch/arm/plat-nomadik/timer.c89
-rw-r--r--arch/arm/plat-omap/counter_32k.c3
-rw-r--r--arch/arm/plat-omap/sram.c2
-rw-r--r--arch/arm/plat-pxa/include/plat/sdhci.h3
-rw-r--r--arch/arm/plat-s3c24xx/Kconfig2
-rw-r--r--arch/arm/plat-s3c24xx/cpu.c8
-rw-r--r--arch/arm/plat-s3c24xx/gpiolib.c2
-rw-r--r--arch/arm/plat-s3c24xx/include/plat/s3c244x.h7
-rw-r--r--arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c6
-rw-r--r--arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c6
-rw-r--r--arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c6
-rw-r--r--arch/arm/plat-samsung/gpio-config.c47
-rw-r--r--arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h11
-rw-r--r--arch/arm/tools/mach-types183
-rw-r--r--arch/arm/vfp/vfphw.S1
-rw-r--r--arch/blackfin/kernel/process.c1
-rw-r--r--arch/frv/kernel/process.c1
-rw-r--r--arch/h8300/kernel/process.c1
-rw-r--r--arch/ia64/hp/sim/simscsi.c4
-rw-r--r--arch/m68k/kernel/process.c1
-rw-r--r--arch/m68knommu/kernel/process.c1
-rw-r--r--arch/mips/Kconfig38
-rw-r--r--arch/mips/alchemy/common/platform.c2
-rw-r--r--arch/mips/alchemy/devboards/prom.c5
-rw-r--r--arch/mips/ar7/clock.c9
-rw-r--r--arch/mips/ar7/time.c3
-rw-r--r--arch/mips/bcm47xx/setup.c153
-rw-r--r--arch/mips/include/asm/cpu.h4
-rw-r--r--arch/mips/include/asm/elf.h8
-rw-r--r--arch/mips/include/asm/io.h12
-rw-r--r--arch/mips/include/asm/mach-ar7/ar7.h3
-rw-r--r--arch/mips/include/asm/mach-bcm47xx/nvram.h7
-rw-r--r--arch/mips/jz4740/board-qi_lb60.c4
-rw-r--r--arch/mips/jz4740/platform.c2
-rw-r--r--arch/mips/jz4740/prom.c2
-rw-r--r--arch/mips/kernel/cevt-r4k.c2
-rw-r--r--arch/mips/kernel/cpu-probe.c7
-rw-r--r--arch/mips/kernel/linux32.c13
-rw-r--r--arch/mips/kernel/process.c1
-rw-r--r--arch/mips/kernel/prom.c2
-rw-r--r--arch/mips/kernel/smp-mt.c2
-rw-r--r--arch/mips/kernel/traps.c44
-rw-r--r--arch/mips/kernel/vpe.c14
-rw-r--r--arch/mips/lib/memset.S4
-rw-r--r--arch/mips/loongson/common/env.c4
-rw-r--r--arch/mips/math-emu/cp1emu.c116
-rw-r--r--arch/mips/mm/dma-default.c4
-rw-r--r--arch/mips/mm/sc-mips.c4
-rw-r--r--arch/mips/pmc-sierra/yosemite/py-console.c12
-rw-r--r--arch/mips/sibyte/swarm/setup.c8
-rw-r--r--arch/mn10300/include/asm/syscall.h117
-rw-r--r--arch/mn10300/kernel/gdb-io-serial.c3
-rw-r--r--arch/mn10300/kernel/gdb-io-ttysm.c3
-rw-r--r--arch/mn10300/kernel/gdb-stub.c3
-rw-r--r--arch/mn10300/kernel/process.c1
-rw-r--r--arch/mn10300/kernel/time.c10
-rw-r--r--arch/parisc/hpux/sys_hpux.c1
-rw-r--r--arch/parisc/kernel/irq.c7
-rw-r--r--arch/parisc/kernel/signal.c9
-rw-r--r--arch/parisc/kernel/sys_parisc32.c1
-rw-r--r--arch/powerpc/Kconfig4
-rw-r--r--arch/powerpc/boot/div64.S3
-rw-r--r--arch/powerpc/kernel/kgdb.c4
-rw-r--r--arch/powerpc/kernel/setup_64.c5
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c1
-rw-r--r--arch/powerpc/mm/hash_utils_64.c2
-rw-r--r--arch/powerpc/mm/pgtable.c2
-rw-r--r--arch/powerpc/mm/tlb_low_64e.S5
-rw-r--r--arch/powerpc/mm/tlb_nohash.c2
-rw-r--r--arch/powerpc/platforms/pseries/Kconfig6
-rw-r--r--arch/powerpc/platforms/pseries/eeh.c2
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c2
-rw-r--r--arch/s390/Kconfig.debug12
-rw-r--r--arch/s390/include/asm/page.h5
-rw-r--r--arch/s390/kernel/compat_linux.c1
-rw-r--r--arch/s390/kernel/kprobes.c70
-rw-r--r--arch/s390/kernel/nmi.c10
-rw-r--r--arch/s390/kernel/vtime.c19
-rw-r--r--arch/s390/lib/delay.c14
-rw-r--r--arch/s390/mm/gup.c7
-rw-r--r--arch/sh/Kconfig3
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c34
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c47
-rw-r--r--arch/sh/include/asm/cacheflush.h2
-rw-r--r--arch/sh/include/asm/processor_32.h7
-rw-r--r--arch/sh/include/asm/unistd_32.h3
-rw-r--r--arch/sh/include/cpu-sh4/cpu/sh7724.h3
-rw-r--r--arch/sh/kernel/cpu/sh4/clock-sh4-202.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7724.c44
-rw-r--r--arch/sh/kernel/sys_sh.c2
-rw-r--r--arch/sh/kernel/syscalls_32.S1
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall-trapa.S2
-rw-r--r--arch/sh/mm/cache-sh4.c4
-rw-r--r--arch/sh/mm/cache-sh7705.c2
-rw-r--r--arch/sh/mm/cache.c14
-rw-r--r--arch/sh/mm/kmap.c2
-rw-r--r--arch/sparc/include/asm/openprom.h2
-rw-r--r--arch/sparc/include/asm/oplib_32.h35
-rw-r--r--arch/sparc/include/asm/oplib_64.h46
-rw-r--r--arch/sparc/kernel/leon_kernel.c4
-rw-r--r--arch/sparc/kernel/leon_smp.c1
-rw-r--r--arch/sparc/kernel/sys_sparc32.c1
-rw-r--r--arch/sparc/kernel/sys_sparc_32.c1
-rw-r--r--arch/sparc/kernel/unaligned_32.c1
-rw-r--r--arch/sparc/kernel/windows.c1
-rw-r--r--arch/sparc/prom/Makefile1
-rw-r--r--arch/sparc/prom/console_32.c65
-rw-r--r--arch/sparc/prom/console_64.c81
-rw-r--r--arch/sparc/prom/devops_32.c87
-rw-r--r--arch/sparc/prom/devops_64.c67
-rw-r--r--arch/sparc/prom/misc_64.c16
-rw-r--r--arch/sparc/prom/printf.c35
-rw-r--r--arch/sparc/prom/tree_32.c16
-rw-r--r--arch/sparc/prom/tree_64.c18
-rw-r--r--arch/tile/Kconfig12
-rw-r--r--arch/tile/include/asm/cacheflush.h52
-rw-r--r--arch/tile/include/asm/io.h15
-rw-r--r--arch/tile/include/asm/pci-bridge.h117
-rw-r--r--arch/tile/include/asm/pci.h107
-rw-r--r--arch/tile/include/asm/processor.h10
-rw-r--r--arch/tile/include/asm/signal.h2
-rw-r--r--arch/tile/include/hv/drv_xgbe_impl.h300
-rw-r--r--arch/tile/include/hv/drv_xgbe_intf.h615
-rw-r--r--arch/tile/include/hv/netio_errors.h122
-rw-r--r--arch/tile/include/hv/netio_intf.h2975
-rw-r--r--arch/tile/kernel/Makefile1
-rw-r--r--arch/tile/kernel/compat.c1
-rw-r--r--arch/tile/kernel/compat_signal.c7
-rw-r--r--arch/tile/kernel/intvec_32.S24
-rw-r--r--arch/tile/kernel/pci.c621
-rw-r--r--arch/tile/kernel/process.c8
-rw-r--r--arch/tile/kernel/setup.c2
-rw-r--r--arch/tile/kernel/signal.c11
-rw-r--r--arch/tile/kernel/smpboot.c1
-rw-r--r--arch/tile/kernel/sys.c1
-rw-r--r--arch/tile/lib/memchr_32.c35
-rw-r--r--arch/tile/lib/spinlock_32.c29
-rw-r--r--arch/tile/mm/fault.c1
-rw-r--r--arch/tile/mm/hugetlbpage.c1
-rw-r--r--arch/um/drivers/line.c5
-rw-r--r--arch/um/kernel/exec.c1
-rw-r--r--arch/x86/Kconfig2
-rw-r--r--arch/x86/boot/compressed/misc.c2
-rw-r--r--arch/x86/crypto/ghash-clmulni-intel_glue.c1
-rw-r--r--arch/x86/ia32/sys_ia32.c1
-rw-r--r--arch/x86/include/asm/e820.h3
-rw-r--r--arch/x86/include/asm/fixmap.h4
-rw-r--r--arch/x86/include/asm/kvm_host.h2
-rw-r--r--arch/x86/include/asm/msr-index.h2
-rw-r--r--arch/x86/include/asm/paravirt.h10
-rw-r--r--arch/x86/include/asm/pvclock.h1
-rw-r--r--arch/x86/include/asm/uv/uv_hub.h4
-rw-r--r--arch/x86/include/asm/uv/uv_mmrs.h19
-rw-r--r--arch/x86/include/asm/xen/interface.h6
-rw-r--r--arch/x86/include/asm/xen/interface_32.h5
-rw-r--r--arch/x86/include/asm/xen/interface_64.h13
-rw-r--r--arch/x86/include/asm/xen/page.h7
-rw-r--r--arch/x86/kernel/Makefile1
-rw-r--r--arch/x86/kernel/apic/apic.c8
-rw-r--r--arch/x86/kernel/apic/hw_nmi.c7
-rw-r--r--arch/x86/kernel/apic/io_apic.c4
-rw-r--r--arch/x86/kernel/apic/probe_64.c7
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c25
-rw-r--r--arch/x86/kernel/cpu/perf_event.c20
-rw-r--r--arch/x86/kernel/cpuid.c1
-rw-r--r--arch/x86/kernel/entry_32.S2
-rw-r--r--arch/x86/kernel/entry_64.S2
-rw-r--r--arch/x86/kernel/head_32.S16
-rw-r--r--arch/x86/kernel/hpet.c26
-rw-r--r--arch/x86/kernel/hw_breakpoint.c4
-rw-r--r--arch/x86/kernel/kgdb.c12
-rw-r--r--arch/x86/kernel/mmconf-fam10h_64.c64
-rw-r--r--arch/x86/kernel/msr.c1
-rw-r--r--arch/x86/kernel/pvclock.c5
-rw-r--r--arch/x86/kernel/resource.c48
-rw-r--r--arch/x86/kernel/setup.c1
-rw-r--r--arch/x86/kernel/xsave.c3
-rw-r--r--arch/x86/kvm/svm.c6
-rw-r--r--arch/x86/kvm/vmx.c24
-rw-r--r--arch/x86/kvm/x86.c11
-rw-r--r--arch/x86/kvm/x86.h5
-rw-r--r--arch/x86/lguest/boot.c16
-rw-r--r--arch/x86/lguest/i386_head.S105
-rw-r--r--arch/x86/mm/tlb.c5
-rw-r--r--arch/x86/pci/i386.c18
-rw-r--r--arch/x86/pci/xen.c27
-rw-r--r--arch/x86/platform/uv/tlb_uv.c2
-rw-r--r--arch/x86/platform/uv/uv_time.c4
-rw-r--r--arch/x86/vdso/Makefile4
-rw-r--r--arch/x86/xen/enlighten.c25
-rw-r--r--arch/x86/xen/mmu.c88
-rw-r--r--arch/x86/xen/platform-pci-unplug.c2
-rw-r--r--arch/x86/xen/setup.c53
-rw-r--r--arch/x86/xen/suspend.c1
-rw-r--r--arch/x86/xen/time.c2
-rw-r--r--arch/x86/xen/xen-ops.h2
-rw-r--r--block/blk-map.c5
-rw-r--r--block/blk-merge.c6
-rw-r--r--block/blk-settings.c51
-rw-r--r--block/blk-sysfs.c2
-rw-r--r--block/blk-throttle.c41
-rw-r--r--block/bsg.c8
-rw-r--r--block/compat_ioctl.c1
-rw-r--r--block/ioctl.c1
-rw-r--r--drivers/acpi/ac.c46
-rw-r--r--drivers/acpi/apei/erst.c34
-rw-r--r--drivers/acpi/apei/hest.c10
-rw-r--r--drivers/acpi/battery.c5
-rw-r--r--drivers/acpi/ec.c3
-rw-r--r--drivers/acpi/osl.c113
-rw-r--r--drivers/acpi/power.c12
-rw-r--r--drivers/acpi/processor_thermal.c9
-rw-r--r--drivers/acpi/sleep.c12
-rw-r--r--drivers/ata/libata-scsi.c19
-rw-r--r--drivers/ata/sata_via.c9
-rw-r--r--drivers/atm/adummy.c2
-rw-r--r--drivers/atm/ambassador.c3
-rw-r--r--drivers/atm/atmtcp.c2
-rw-r--r--drivers/atm/eni.c2
-rw-r--r--drivers/atm/firestream.c2
-rw-r--r--drivers/atm/fore200e.c14
-rw-r--r--drivers/atm/he.c2
-rw-r--r--drivers/atm/horizon.c3
-rw-r--r--drivers/atm/idt77252.c3
-rw-r--r--drivers/atm/iphase.c2
-rw-r--r--drivers/atm/lanai.c2
-rw-r--r--drivers/atm/nicstar.c3
-rw-r--r--drivers/atm/solos-pci.c8
-rw-r--r--drivers/atm/zatm.c2
-rw-r--r--drivers/base/power/main.c34
-rw-r--r--drivers/block/amiflop.c2
-rw-r--r--drivers/block/ataflop.c2
-rw-r--r--drivers/block/cciss.c5
-rw-r--r--drivers/block/cciss_scsi.c8
-rw-r--r--drivers/block/drbd/drbd_receiver.c15
-rw-r--r--drivers/block/drbd/drbd_req.h3
-rw-r--r--drivers/block/drbd/drbd_worker.c11
-rw-r--r--drivers/block/rbd.c748
-rw-r--r--drivers/block/xen-blkfront.c57
-rw-r--r--drivers/bluetooth/ath3k.c4
-rw-r--r--drivers/bluetooth/btusb.c12
-rw-r--r--drivers/char/agp/frontend.c1
-rw-r--r--drivers/char/agp/intel-gtt.c6
-rw-r--r--drivers/char/amiserial.c1
-rw-r--r--drivers/char/briq_panel.c1
-rw-r--r--drivers/char/hpet.c1
-rw-r--r--drivers/char/hw_random/core.c1
-rw-r--r--drivers/char/istallion.c1
-rw-r--r--drivers/char/serial167.c1
-rw-r--r--drivers/char/specialix.c1
-rw-r--r--drivers/char/stallion.c1
-rw-r--r--drivers/char/sx.c1
-rw-r--r--drivers/char/tpm/tpm_tis.c24
-rw-r--r--drivers/char/uv_mmtimer.c1
-rw-r--r--drivers/char/virtio_console.c37
-rw-r--r--drivers/clocksource/sh_cmt.c17
-rw-r--r--drivers/connector/connector.c1
-rw-r--r--drivers/dma/Makefile4
-rw-r--r--drivers/dma/at_hdmac.c2
-rw-r--r--drivers/dma/fsldma.c6
-rw-r--r--drivers/dma/fsldma.h9
-rw-r--r--drivers/dma/imx-dma.c2
-rw-r--r--drivers/dma/imx-sdma.c4
-rw-r--r--drivers/dma/intel_mid_dma.c8
-rw-r--r--drivers/dma/ioat/Makefile2
-rw-r--r--drivers/dma/pch_dma.c15
-rw-r--r--drivers/dma/ppc4xx/adma.c5
-rw-r--r--drivers/dma/shdma.c1
-rw-r--r--drivers/edac/Makefile8
-rw-r--r--drivers/edac/amd64_edac.c2
-rw-r--r--drivers/edac/edac_core.h6
-rw-r--r--drivers/edac/edac_mc.c10
-rw-r--r--drivers/edac/mce_amd_inj.c2
-rw-r--r--drivers/firewire/net.c160
-rw-r--r--drivers/firewire/ohci.c47
-rw-r--r--drivers/firewire/sbp2.c4
-rw-r--r--drivers/gpio/cs5535-gpio.c16
-rw-r--r--drivers/gpu/drm/drm_crtc.c10
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c16
-rw-r--r--drivers/gpu/drm/drm_fops.c1
-rw-r--r--drivers/gpu/drm/drm_irq.c21
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c3
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c3
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c602
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c40
-rw-r--r--drivers/gpu/drm/i915/intel_acpi.c34
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c159
-rw-r--r--drivers/gpu/drm/i915/intel_display.c95
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c171
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h2
-rw-r--r--drivers/gpu/drm/i915/intel_i2c.c11
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c117
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c30
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c84
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_backlight.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c43
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c77
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.h3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h55
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fence.c7
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c36
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_hw.c8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_hw.h19
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_i2c.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_irq.c42
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_mem.c49
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_object.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_pm.c7
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_ramht.c71
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_sgdma.c14
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c17
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_temp.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv04_crtc.c7
-rw-r--r--drivers/gpu/drm/nouveau/nv04_dfp.c13
-rw-r--r--drivers/gpu/drm/nouveau/nv04_pm.c9
-rw-r--r--drivers/gpu/drm/nouveau/nv50_calc.c16
-rw-r--r--drivers/gpu/drm/nouveau/nv50_crtc.c4
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c35
-rw-r--r--drivers/gpu/drm/nouveau/nv50_fifo.c5
-rw-r--r--drivers/gpu/drm/nouveau/nv50_graph.c52
-rw-r--r--drivers/gpu/drm/nouveau/nv50_instmem.c1
-rw-r--r--drivers/gpu/drm/radeon/atom.c1
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c31
-rw-r--r--drivers/gpu/drm/radeon/evergreen_blit_kms.c2
-rw-r--r--drivers/gpu/drm/radeon/r600.c19
-rw-r--r--drivers/gpu/drm/radeon/r600_blit_kms.c2
-rw-r--r--drivers/gpu/drm/radeon/r600_cs.c309
-rw-r--r--drivers/gpu/drm/radeon/r600_reg.h1
-rw-r--r--drivers/gpu/drm/radeon/r600d.h6
-rw-r--r--drivers/gpu/drm/radeon/radeon.h4
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c16
-rw-r--r--drivers/gpu/drm/radeon/radeon_benchmark.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c13
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c15
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c52
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c356
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_encoders.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h5
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c18
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.h7
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_test.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c2
-rw-r--r--drivers/gpu/drm/radeon/rv770.c4
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c11
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_resource.c14
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-egalax.c2
-rw-r--r--drivers/hid/hid-input.c21
-rw-r--r--drivers/hid/hid-tmff.c2
-rw-r--r--drivers/hid/hidraw.c1
-rw-r--r--drivers/hid/usbhid/hiddev.c1
-rw-r--r--drivers/hwmon/adm1026.c20
-rw-r--r--drivers/hwmon/i5k_amb.c2
-rw-r--r--drivers/hwmon/it87.c61
-rw-r--r--drivers/hwmon/lis3lv02d_i2c.c10
-rw-r--r--drivers/hwmon/ltc4215.c4
-rw-r--r--drivers/i2c/Kconfig3
-rw-r--r--drivers/i2c/algos/Kconfig14
-rw-r--r--drivers/i2c/busses/i2c-intel-mid.c2
-rw-r--r--drivers/idle/intel_idle.c12
-rw-r--r--drivers/infiniband/core/ud_header.c30
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c99
-rw-r--r--drivers/infiniband/core/uverbs_marshall.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c1
-rw-r--r--drivers/infiniband/hw/mlx4/main.c4
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c10
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c4
-rw-r--r--drivers/input/evdev.c113
-rw-r--r--drivers/input/input.c3
-rw-r--r--drivers/input/joystick/turbografx.c1
-rw-r--r--drivers/input/keyboard/Kconfig16
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/gpio_keys_polled.c261
-rw-r--r--drivers/input/mouse/synaptics.h3
-rw-r--r--drivers/input/serio/gscps2.c2
-rw-r--r--drivers/input/serio/serio_raw.c1
-rw-r--r--drivers/input/tablet/aiptek.c28
-rw-r--r--drivers/input/tablet/wacom_wac.c12
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c1
-rw-r--r--drivers/isdn/icn/icn.c7
-rw-r--r--drivers/leds/Kconfig50
-rw-r--r--drivers/leds/leds-lp5521.c50
-rw-r--r--drivers/leds/leds-lp5523.c44
-rw-r--r--drivers/leds/leds-ss4200.c1
-rw-r--r--drivers/macintosh/Kconfig1
-rw-r--r--drivers/md/dm-table.c10
-rw-r--r--drivers/md/md.c48
-rw-r--r--drivers/md/raid1.c1
-rw-r--r--drivers/md/raid10.c2
-rw-r--r--drivers/media/common/saa7146_hlp.c8
-rw-r--r--drivers/media/common/saa7146_video.c16
-rw-r--r--drivers/media/common/tuners/Kconfig8
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c1
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c1
-rw-r--r--drivers/media/dvb/frontends/Kconfig5
-rw-r--r--drivers/media/dvb/ngene/ngene-core.c1
-rw-r--r--drivers/media/dvb/ngene/ngene-dvb.c1
-rw-r--r--drivers/media/dvb/ngene/ngene-i2c.c1
-rw-r--r--drivers/media/radio/radio-aimslab.c16
-rw-r--r--drivers/media/radio/radio-aztech.c6
-rw-r--r--drivers/media/radio/radio-cadet.c12
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c6
-rw-r--r--drivers/media/radio/radio-gemtek.c14
-rw-r--r--drivers/media/radio/radio-maestro.c14
-rw-r--r--drivers/media/radio/radio-maxiradio.c2
-rw-r--r--drivers/media/radio/radio-miropcm20.c6
-rw-r--r--drivers/media/radio/radio-mr800.c1
-rw-r--r--drivers/media/radio/radio-rtrack2.c10
-rw-r--r--drivers/media/radio/radio-sf16fmi.c7
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c11
-rw-r--r--drivers/media/radio/radio-si4713.c5
-rw-r--r--drivers/media/radio/radio-tea5764.c49
-rw-r--r--drivers/media/radio/radio-terratec.c8
-rw-r--r--drivers/media/radio/radio-timb.c5
-rw-r--r--drivers/media/radio/radio-trust.c18
-rw-r--r--drivers/media/radio/radio-typhoon.c16
-rw-r--r--drivers/media/radio/radio-zoltrix.c30
-rw-r--r--drivers/media/radio/si470x/radio-si470x.h1
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/arv.c2
-rw-r--r--drivers/media/video/au0828/au0828-cards.c4
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c22
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c118
-rw-r--r--drivers/media/video/bw-qcam.c2
-rw-r--r--drivers/media/video/c-qcam.c2
-rw-r--r--drivers/media/video/cafe_ccic.c5
-rw-r--r--drivers/media/video/cx18/cx18-alsa-pcm.c8
-rw-r--r--drivers/media/video/cx18/cx18-i2c.c8
-rw-r--r--drivers/media/video/cx18/cx18-streams.c2
-rw-r--r--drivers/media/video/cx231xx/cx231xx-cards.c4
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c2
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c4
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c1
-rw-r--r--drivers/media/video/cx88/cx88-cards.c9
-rw-r--r--drivers/media/video/cx88/cx88-video.c8
-rw-r--r--drivers/media/video/davinci/vpfe_capture.c1
-rw-r--r--drivers/media/video/davinci/vpif_capture.c1
-rw-r--r--drivers/media/video/davinci/vpif_display.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c18
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c2
-rw-r--r--drivers/media/video/fsl-viu.c2
-rw-r--r--drivers/media/video/gspca/sonixj.c416
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c22
-rw-r--r--drivers/media/video/meye.c14
-rw-r--r--drivers/media/video/mxb.c12
-rw-r--r--drivers/media/video/pms.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c6
-rw-r--r--drivers/media/video/pwc/pwc-if.c1
-rw-r--r--drivers/media/video/s2255drv.c1
-rw-r--r--drivers/media/video/s5p-fimc/fimc-capture.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c8
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c1
-rw-r--r--drivers/media/video/saa7164/saa7164.h1
-rw-r--r--drivers/media/video/sh_vou.c15
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c2
-rw-r--r--drivers/media/video/soc_camera.c2
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c6
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c1
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c48
-rw-r--r--drivers/media/video/uvc/uvc_queue.c133
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c185
-rw-r--r--drivers/media/video/uvc/uvc_video.c3
-rw-r--r--drivers/media/video/uvc/uvcvideo.h10
-rw-r--r--drivers/media/video/v4l2-common.c15
-rw-r--r--drivers/media/video/v4l2-compat-ioctl32.c1
-rw-r--r--drivers/media/video/v4l2-dev.c69
-rw-r--r--drivers/media/video/v4l2-device.c1
-rw-r--r--drivers/media/video/via-camera.c2
-rw-r--r--drivers/media/video/vino.c4
-rw-r--r--drivers/media/video/w9966.c2
-rw-r--r--drivers/media/video/zoran/zoran_card.c5
-rw-r--r--drivers/message/fusion/mptfc.c7
-rw-r--r--drivers/message/fusion/mptsas.c4
-rw-r--r--drivers/message/fusion/mptspi.c4
-rw-r--r--drivers/message/i2o/i2o_scsi.c6
-rw-r--r--drivers/misc/isl29020.c4
-rw-r--r--drivers/misc/sgi-xp/xpc_partition.c25
-rw-r--r--drivers/mmc/core/core.c2
-rw-r--r--drivers/mmc/core/mmc.c8
-rw-r--r--drivers/mmc/core/sdio.c51
-rw-r--r--drivers/mmc/core/sdio_bus.c33
-rw-r--r--drivers/mmc/host/omap_hsmmc.c2
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c12
-rw-r--r--drivers/mmc/host/sdhci-pci.c31
-rw-r--r--drivers/mmc/host/sdhci-pxa.c4
-rw-r--r--drivers/mmc/host/sdhci.c54
-rw-r--r--drivers/mmc/host/sdhci.h9
-rw-r--r--drivers/mmc/host/ushc.c30
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c2
-rw-r--r--drivers/mtd/nand/omap2.c1
-rw-r--r--drivers/mtd/ubi/io.c37
-rw-r--r--drivers/mtd/ubi/scan.c20
-rw-r--r--drivers/net/3c59x.c6
-rw-r--r--drivers/net/8139cp.c10
-rw-r--r--drivers/net/Kconfig18
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/atl1c/atl1c_hw.c2
-rw-r--r--drivers/net/au1000_eth.c10
-rw-r--r--drivers/net/b44.c11
-rw-r--r--drivers/net/benet/be_cmds.c2
-rw-r--r--drivers/net/benet/be_main.c6
-rw-r--r--drivers/net/bnx2x/bnx2x.h4
-rw-r--r--drivers/net/bnx2x/bnx2x_cmn.c42
-rw-r--r--drivers/net/bnx2x/bnx2x_init_ops.h4
-rw-r--r--drivers/net/bnx2x/bnx2x_main.c2
-rw-r--r--drivers/net/bonding/bond_main.c21
-rw-r--r--drivers/net/bonding/bonding.h12
-rw-r--r--drivers/net/caif/caif_shm_u5500.c2
-rw-r--r--drivers/net/caif/caif_shmcore.c2
-rw-r--r--drivers/net/caif/caif_spi.c4
-rw-r--r--drivers/net/cxgb4/t4_hw.c2
-rw-r--r--drivers/net/cxgb4vf/cxgb4vf_main.c88
-rw-r--r--drivers/net/cxgb4vf/t4vf_hw.c94
-rw-r--r--drivers/net/e1000/e1000_main.c12
-rw-r--r--drivers/net/ehea/ehea_ethtool.c9
-rw-r--r--drivers/net/ehea/ehea_main.c25
-rw-r--r--drivers/net/enic/enic_main.c3
-rw-r--r--drivers/net/gianfar.c7
-rw-r--r--drivers/net/ifb.c2
-rw-r--r--drivers/net/ipg.c6
-rw-r--r--drivers/net/irda/sh_sir.c2
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c3
-rw-r--r--drivers/net/mlx4/fw.c4
-rw-r--r--drivers/net/pch_gbe/pch_gbe_main.c6
-rw-r--r--drivers/net/pch_gbe/pch_gbe_param.c8
-rw-r--r--drivers/net/phy/Kconfig2
-rw-r--r--drivers/net/phy/icplus.c59
-rw-r--r--drivers/net/phy/marvell.c164
-rw-r--r--drivers/net/ppp_generic.c43
-rw-r--r--drivers/net/pppoe.c2
-rw-r--r--drivers/net/qlge/qlge.h1
-rw-r--r--drivers/net/qlge/qlge_main.c7
-rw-r--r--drivers/net/qlge/qlge_mpi.c12
-rw-r--r--drivers/net/r8169.c29
-rw-r--r--drivers/net/sfc/efx.c43
-rw-r--r--drivers/net/sfc/net_driver.h2
-rw-r--r--drivers/net/sfc/nic.c6
-rw-r--r--drivers/net/stmmac/stmmac_main.c4
-rw-r--r--drivers/net/tile/Makefile10
-rw-r--r--drivers/net/tile/tilepro.c2406
-rw-r--r--drivers/net/tulip/dmfe.c6
-rw-r--r--drivers/net/ucc_geth.h3
-rw-r--r--drivers/net/usb/hso.c14
-rw-r--r--drivers/net/wan/hd64572.c5
-rw-r--r--drivers/net/wan/x25_asy.c13
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c13
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c73
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.h9
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h6
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.h27
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_9287.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_def.c23
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c16
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h3
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_txrx.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c28
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c11
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h14
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c22
-rw-r--r--drivers/net/wireless/ath/carl9170/fw.c3
-rw-r--r--drivers/net/wireless/ath/carl9170/main.c5
-rw-r--r--drivers/net/wireless/ath/carl9170/tx.c2
-rw-r--r--drivers/net/wireless/ath/carl9170/usb.c4
-rw-r--r--drivers/net/wireless/b43/sdio.c1
-rw-r--r--drivers/net/wireless/libertas/if_sdio.c1
-rw-r--r--drivers/net/wireless/libertas/if_spi.c1
-rw-r--r--drivers/net/wireless/libertas/main.c2
-rw-r--r--drivers/net/wireless/orinoco/main.c18
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c14
-rw-r--r--drivers/net/wireless/orinoco/orinoco_usb.c1
-rw-r--r--drivers/net/wireless/orinoco/scan.c8
-rw-r--r--drivers/net/wireless/orinoco/scan.h1
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c14
-rw-r--r--drivers/net/wireless/orinoco/wext.c4
-rw-r--r--drivers/net/xen-netfront.c4
-rw-r--r--drivers/parisc/dino.c1
-rw-r--r--drivers/parisc/eisa.c3
-rw-r--r--drivers/parisc/eisa_eeprom.c1
-rw-r--r--drivers/parisc/gsc.c3
-rw-r--r--drivers/parisc/iosapic.c8
-rw-r--r--drivers/parisc/led.c17
-rw-r--r--drivers/parisc/superio.c3
-rw-r--r--drivers/pci/Makefile1
-rw-r--r--drivers/pci/bus.c81
-rw-r--r--drivers/pci/dmar.c5
-rw-r--r--drivers/pci/pci-sysfs.c2
-rw-r--r--drivers/pci/proc.c1
-rw-r--r--drivers/pci/quirks.c44
-rw-r--r--drivers/pcmcia/soc_common.c1
-rw-r--r--drivers/platform/x86/asus-laptop.c97
-rw-r--r--drivers/platform/x86/eeepc-wmi.c4
-rw-r--r--drivers/platform/x86/hp-wmi.c2
-rw-r--r--drivers/platform/x86/ibm_rtl.c34
-rw-r--r--drivers/platform/x86/msi-wmi.c16
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c1
-rw-r--r--drivers/platform/x86/toshiba_acpi.c1
-rw-r--r--drivers/platform/x86/wmi.c2
-rw-r--r--drivers/pnp/isapnp/proc.c1
-rw-r--r--drivers/pnp/pnpacpi/core.c2
-rw-r--r--drivers/regulator/core.c30
-rw-r--r--drivers/regulator/mc13783-regulator.c4
-rw-r--r--drivers/regulator/tps6586x-regulator.c33
-rw-r--r--drivers/regulator/twl-regulator.c6
-rw-r--r--drivers/s390/block/dasd_eer.c1
-rw-r--r--drivers/s390/char/fs3270.c1
-rw-r--r--drivers/s390/char/tape_char.c1
-rw-r--r--drivers/s390/char/tape_core.c68
-rw-r--r--drivers/s390/char/vmlogrdr.c37
-rw-r--r--drivers/s390/char/vmur.c1
-rw-r--r--drivers/s390/cio/css.c2
-rw-r--r--drivers/s390/cio/device.c11
-rw-r--r--drivers/s390/cio/qdio_thinint.c2
-rw-r--r--drivers/s390/crypto/zcrypt_api.c1
-rw-r--r--drivers/s390/scsi/zfcp_erp.c11
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c11
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c5
-rw-r--r--drivers/scsi/3w-9xxx.c4
-rw-r--r--drivers/scsi/3w-sas.c4
-rw-r--r--drivers/scsi/3w-xxxx.c4
-rw-r--r--drivers/scsi/53c700.c8
-rw-r--r--drivers/scsi/BusLogic.c3
-rw-r--r--drivers/scsi/BusLogic.h2
-rw-r--r--drivers/scsi/NCR5380.c3
-rw-r--r--drivers/scsi/NCR5380.h2
-rw-r--r--drivers/scsi/NCR53c406a.c4
-rw-r--r--drivers/scsi/a100u2w.c4
-rw-r--r--drivers/scsi/aacraid/linit.c4
-rw-r--r--drivers/scsi/advansys.c4
-rw-r--r--drivers/scsi/aha152x.c4
-rw-r--r--drivers/scsi/aha1542.c4
-rw-r--r--drivers/scsi/aha1542.h2
-rw-r--r--drivers/scsi/aha1740.c4
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c4
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c4
-rw-r--r--drivers/scsi/aic7xxx_old.c4
-rw-r--r--drivers/scsi/arcmsr/arcmsr_hba.c7
-rw-r--r--drivers/scsi/arm/acornscsi.c4
-rw-r--r--drivers/scsi/arm/fas216.c10
-rw-r--r--drivers/scsi/arm/fas216.h18
-rw-r--r--drivers/scsi/atari_NCR5380.c4
-rw-r--r--drivers/scsi/atari_scsi.c17
-rw-r--r--drivers/scsi/atp870u.c4
-rw-r--r--drivers/scsi/bfa/bfad_im.c7
-rw-r--r--drivers/scsi/dc395x.c3
-rw-r--r--drivers/scsi/dpt_i2o.c4
-rw-r--r--drivers/scsi/dpti.h2
-rw-r--r--drivers/scsi/dtc.h2
-rw-r--r--drivers/scsi/eata.c7
-rw-r--r--drivers/scsi/eata_pio.c4
-rw-r--r--drivers/scsi/esp_scsi.c4
-rw-r--r--drivers/scsi/fd_mcs.c4
-rw-r--r--drivers/scsi/fdomain.c4
-rw-r--r--drivers/scsi/fnic/fnic.h2
-rw-r--r--drivers/scsi/fnic/fnic_scsi.c4
-rw-r--r--drivers/scsi/g_NCR5380.h2
-rw-r--r--drivers/scsi/gdth.c6
-rw-r--r--drivers/scsi/hpsa.c16
-rw-r--r--drivers/scsi/hptiop.c4
-rw-r--r--drivers/scsi/ibmmca.c6
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c4
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c4
-rw-r--r--drivers/scsi/imm.c4
-rw-r--r--drivers/scsi/in2000.c4
-rw-r--r--drivers/scsi/in2000.h2
-rw-r--r--drivers/scsi/initio.c4
-rw-r--r--drivers/scsi/ipr.c4
-rw-r--r--drivers/scsi/ips.c6
-rw-r--r--drivers/scsi/libfc/fc_fcp.c4
-rw-r--r--drivers/scsi/libiscsi.c4
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c4
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c4
-rw-r--r--drivers/scsi/mac53c94.c4
-rw-r--r--drivers/scsi/megaraid.c6
-rw-r--r--drivers/scsi/megaraid.h2
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c7
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c4
-rw-r--r--drivers/scsi/mesh.c4
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c4
-rw-r--r--drivers/scsi/ncr53c8xx.c4
-rw-r--r--drivers/scsi/nsp32.c7
-rw-r--r--drivers/scsi/osd/osd_initiator.c4
-rw-r--r--drivers/scsi/pas16.h2
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c4
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h3
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c4
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.h1
-rw-r--r--drivers/scsi/pmcraid.c8
-rw-r--r--drivers/scsi/pmcraid.h6
-rw-r--r--drivers/scsi/ppa.c4
-rw-r--r--drivers/scsi/ps3rom.c4
-rw-r--r--drivers/scsi/qla1280.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_nx.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c10
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c7
-rw-r--r--drivers/scsi/qlogicfas408.c4
-rw-r--r--drivers/scsi/qlogicfas408.h3
-rw-r--r--drivers/scsi/qlogicpti.c4
-rw-r--r--drivers/scsi/scsi.c18
-rw-r--r--drivers/scsi/scsi_debug.c4
-rw-r--r--drivers/scsi/scsi_error.c32
-rw-r--r--drivers/scsi/scsi_lib.c8
-rw-r--r--drivers/scsi/sd.c1
-rw-r--r--drivers/scsi/stex.c4
-rw-r--r--drivers/scsi/sun3_NCR5380.c4
-rw-r--r--drivers/scsi/sun3_scsi.h3
-rw-r--r--drivers/scsi/sym53c416.c4
-rw-r--r--drivers/scsi/sym53c416.h2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c4
-rw-r--r--drivers/scsi/t128.h3
-rw-r--r--drivers/scsi/tmscsim.c4
-rw-r--r--drivers/scsi/u14-34f.c6
-rw-r--r--drivers/scsi/ultrastor.c4
-rw-r--r--drivers/scsi/ultrastor.h3
-rw-r--r--drivers/scsi/vmw_pvscsi.c4
-rw-r--r--drivers/scsi/wd33c93.c6
-rw-r--r--drivers/scsi/wd33c93.h3
-rw-r--r--drivers/scsi/wd7000.c4
-rw-r--r--drivers/serial/8250.c2
-rw-r--r--drivers/serial/crisv10.c1
-rw-r--r--drivers/serial/kgdboc.c3
-rw-r--r--drivers/serial/mfd.c24
-rw-r--r--drivers/serial/serial_core.c1
-rw-r--r--drivers/sh/clk/core.c16
-rw-r--r--drivers/sh/clk/cpg.c7
-rw-r--r--drivers/spi/atmel_spi.c6
-rw-r--r--drivers/spi/dw_spi.c5
-rw-r--r--drivers/ssb/b43_pci_bridge.c1
-rw-r--r--drivers/staging/asus_oled/asus_oled.c8
-rw-r--r--drivers/staging/batman-adv/hard-interface.c19
-rw-r--r--drivers/staging/batman-adv/soft-interface.c14
-rw-r--r--drivers/staging/brcm80211/README8
-rw-r--r--drivers/staging/brcm80211/TODO2
-rw-r--r--drivers/staging/comedi/drivers/usbdux.c4
-rw-r--r--drivers/staging/cx25821/cx25821-video.c8
-rw-r--r--drivers/staging/cx25821/cx25821-video.h2
-rw-r--r--drivers/staging/easycap/easycap.h2
-rw-r--r--drivers/staging/frontier/tranzport.c2
-rw-r--r--drivers/staging/go7007/go7007-driver.c2
-rw-r--r--drivers/staging/hv/storvsc_drv.c7
-rw-r--r--drivers/staging/iio/accel/adis16220_core.c2
-rw-r--r--drivers/staging/intel_sst/intel_sst_app_interface.c1
-rw-r--r--drivers/staging/intel_sst/intel_sst_stream_encoded.c2
-rw-r--r--drivers/staging/keucr/scsiglue.c4
-rw-r--r--drivers/staging/line6/control.c204
-rw-r--r--drivers/staging/line6/midi.c4
-rw-r--r--drivers/staging/line6/pcm.c4
-rw-r--r--drivers/staging/line6/pod.c32
-rw-r--r--drivers/staging/line6/toneport.c4
-rw-r--r--drivers/staging/line6/variax.c12
-rw-r--r--drivers/staging/quickstart/quickstart.c10
-rw-r--r--drivers/staging/rt2860/usb_main_dev.c1
-rw-r--r--drivers/staging/rtl8187se/r8185b_init.c30
-rw-r--r--drivers/staging/rtl8712/osdep_service.h1
-rw-r--r--drivers/staging/rtl8712/usb_halinit.c2
-rw-r--r--drivers/staging/samsung-laptop/samsung-laptop.c2
-rw-r--r--drivers/staging/speakup/buffers.c1
-rw-r--r--drivers/staging/speakup/fakekey.c1
-rw-r--r--drivers/staging/spectra/ffsport.c2
-rw-r--r--drivers/staging/stradis/Kconfig2
-rw-r--r--drivers/staging/tm6000/tm6000-cards.c4
-rw-r--r--drivers/staging/winbond/sysdef.h3
-rw-r--r--drivers/staging/zram/zram_sysfs.c4
-rw-r--r--drivers/tty/n_gsm.c6
-rw-r--r--drivers/tty/sysrq.c169
-rw-r--r--drivers/tty/tty_io.c13
-rw-r--r--drivers/tty/tty_ldisc.c2
-rw-r--r--drivers/uio/uio.c2
-rw-r--r--drivers/uio/uio_cif.c2
-rw-r--r--drivers/uio/uio_netx.c2
-rw-r--r--drivers/usb/atm/ueagle-atm.c7
-rw-r--r--drivers/usb/atm/usbatm.c15
-rw-r--r--drivers/usb/core/Kconfig12
-rw-r--r--drivers/usb/core/devices.c1
-rw-r--r--drivers/usb/core/devio.c1
-rw-r--r--drivers/usb/core/file.c1
-rw-r--r--drivers/usb/core/hcd.c2
-rw-r--r--drivers/usb/core/inode.c1
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c2
-rw-r--r--drivers/usb/gadget/composite.c18
-rw-r--r--drivers/usb/gadget/f_fs.c1
-rw-r--r--drivers/usb/gadget/f_hid.c1
-rw-r--r--drivers/usb/host/ehci-dbg.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c10
-rw-r--r--drivers/usb/host/ehci-mem.c26
-rw-r--r--drivers/usb/host/ehci-pci.c25
-rw-r--r--drivers/usb/host/ehci-sched.c21
-rw-r--r--drivers/usb/host/ehci.h2
-rw-r--r--drivers/usb/host/isp1362-hcd.c3
-rw-r--r--drivers/usb/host/uhci-debug.c1
-rw-r--r--drivers/usb/host/xhci-hub.c7
-rw-r--r--drivers/usb/host/xhci-mem.c173
-rw-r--r--drivers/usb/host/xhci-ring.c1
-rw-r--r--drivers/usb/host/xhci.c91
-rw-r--r--drivers/usb/host/xhci.h31
-rw-r--r--drivers/usb/image/microtek.c6
-rw-r--r--drivers/usb/misc/cypress_cy7c63.c6
-rw-r--r--drivers/usb/misc/trancevibrator.c2
-rw-r--r--drivers/usb/misc/usbled.c2
-rw-r--r--drivers/usb/misc/usbsevseg.c10
-rw-r--r--drivers/usb/misc/uss720.c4
-rw-r--r--drivers/usb/misc/yurex.c1
-rw-r--r--drivers/usb/mon/mon_bin.c1
-rw-r--r--drivers/usb/mon/mon_stat.c1
-rw-r--r--drivers/usb/musb/musb_core.c3
-rw-r--r--drivers/usb/musb/musb_gadget.c124
-rw-r--r--drivers/usb/otg/langwell_otg.c9
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h9
-rw-r--r--drivers/usb/serial/usb-serial.c4
-rw-r--r--drivers/usb/storage/scsiglue.c4
-rw-r--r--drivers/usb/storage/sierra_ms.c2
-rw-r--r--drivers/usb/storage/uas.c4
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/vhost/net.c5
-rw-r--r--drivers/vhost/vhost.c3
-rw-r--r--drivers/video/Kconfig106
-rw-r--r--drivers/video/Makefile5
-rw-r--r--drivers/video/backlight/backlight.c12
-rw-r--r--drivers/video/bf537-lq035.c914
-rw-r--r--drivers/video/bfin_adv7393fb.c832
-rw-r--r--drivers/video/bfin_adv7393fb.h321
-rw-r--r--drivers/video/carminefb.c6
-rw-r--r--drivers/video/console/vgacon.c1
-rw-r--r--drivers/video/da8xx-fb.c14
-rw-r--r--drivers/video/fbcmap.c69
-rw-r--r--drivers/video/fbmon.c88
-rw-r--r--drivers/video/geode/lxfb.h4
-rw-r--r--drivers/video/geode/lxfb_ops.c24
-rw-r--r--drivers/video/hgafb.c22
-rw-r--r--drivers/video/i810/i810-i2c.c12
-rw-r--r--drivers/video/imxfb.c9
-rw-r--r--drivers/video/modedb.c52
-rw-r--r--drivers/video/mx3fb.c7
-rw-r--r--drivers/video/omap/Kconfig4
-rw-r--r--drivers/video/omap2/vram.c4
-rw-r--r--drivers/video/s1d13xxxfb.c50
-rw-r--r--drivers/video/s3c-fb.c111
-rw-r--r--drivers/video/sh_mipi_dsi.c129
-rw-r--r--drivers/video/sh_mobile_hdmi.c219
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c104
-rw-r--r--drivers/video/sis/init.c719
-rw-r--r--drivers/video/sis/init.h76
-rw-r--r--drivers/video/sis/init301.c475
-rw-r--r--drivers/video/sis/init301.h54
-rw-r--r--drivers/video/sis/initextlfb.c7
-rw-r--r--drivers/video/sis/osdef.h133
-rw-r--r--drivers/video/sis/sis.h66
-rw-r--r--drivers/video/sis/sis_main.c1224
-rw-r--r--drivers/video/sis/vgatypes.h11
-rw-r--r--drivers/video/sis/vstruct.h12
-rw-r--r--drivers/video/udlfb.c2
-rw-r--r--drivers/video/via/via-core.c96
-rw-r--r--drivers/video/via/via-gpio.c29
-rw-r--r--drivers/video/via/viafbdev.c34
-rw-r--r--drivers/video/via/viafbdev.h2
-rw-r--r--drivers/video/vt8500lcdfb.c447
-rw-r--r--drivers/video/vt8500lcdfb.h34
-rw-r--r--drivers/video/wm8505fb.c422
-rw-r--r--drivers/video/wm8505fb_regs.h76
-rw-r--r--drivers/video/wmt_ge_rops.c186
-rw-r--r--drivers/video/wmt_ge_rops.h5
-rw-r--r--drivers/virtio/virtio.c6
-rw-r--r--drivers/virtio/virtio_ring.c3
-rw-r--r--drivers/watchdog/Kconfig3
-rw-r--r--drivers/watchdog/bcm63xx_wdt.c42
-rw-r--r--drivers/watchdog/gef_wdt.c1
-rw-r--r--drivers/watchdog/iTCO_wdt.c8
-rw-r--r--drivers/xen/Makefile5
-rw-r--r--drivers/xen/balloon.c42
-rw-r--r--drivers/xen/events.c122
-rw-r--r--drivers/xen/evtchn.c100
-rw-r--r--drivers/xen/manage.c1
-rw-r--r--drivers/xen/xenfs/privcmd.c14
-rw-r--r--drivers/xen/xenfs/super.c46
-rw-r--r--drivers/zorro/proc.c1
-rw-r--r--fs/autofs4/root.c12
-rw-r--r--fs/block_dev.c1
-rw-r--r--fs/btrfs/compression.c15
-rw-r--r--fs/btrfs/ctree.h6
-rw-r--r--fs/btrfs/disk-io.c41
-rw-r--r--fs/btrfs/export.c78
-rw-r--r--fs/btrfs/extent-tree.c77
-rw-r--r--fs/btrfs/extent_io.c77
-rw-r--r--fs/btrfs/extent_io.h3
-rw-r--r--fs/btrfs/file.c99
-rw-r--r--fs/btrfs/free-space-cache.c12
-rw-r--r--fs/btrfs/inode.c299
-rw-r--r--fs/btrfs/ioctl.c87
-rw-r--r--fs/btrfs/ioctl.h14
-rw-r--r--fs/btrfs/ordered-data.c67
-rw-r--r--fs/btrfs/ordered-data.h3
-rw-r--r--fs/btrfs/orphan.c6
-rw-r--r--fs/btrfs/super.c43
-rw-r--r--fs/btrfs/transaction.c5
-rw-r--r--fs/btrfs/tree-log.c21
-rw-r--r--fs/btrfs/volumes.c20
-rw-r--r--fs/btrfs/volumes.h2
-rw-r--r--fs/ceph/addr.c6
-rw-r--r--fs/ceph/caps.c17
-rw-r--r--fs/ceph/dir.c23
-rw-r--r--fs/ceph/file.c65
-rw-r--r--fs/ceph/inode.c50
-rw-r--r--fs/ceph/ioctl.h2
-rw-r--r--fs/ceph/locks.c94
-rw-r--r--fs/ceph/mds_client.c49
-rw-r--r--fs/ceph/mds_client.h33
-rw-r--r--fs/ceph/super.h4
-rw-r--r--fs/cifs/Kconfig8
-rw-r--r--fs/cifs/Makefile4
-rw-r--r--fs/cifs/README9
-rw-r--r--fs/cifs/cifs_fs_sb.h1
-rw-r--r--fs/cifs/cifsacl.c51
-rw-r--r--fs/cifs/cifsacl.h4
-rw-r--r--fs/cifs/cifsfs.c5
-rw-r--r--fs/cifs/cifsglob.h12
-rw-r--r--fs/cifs/cifsproto.h11
-rw-r--r--fs/cifs/cifssmb.c183
-rw-r--r--fs/cifs/connect.c47
-rw-r--r--fs/cifs/dns_resolve.c2
-rw-r--r--fs/cifs/file.c6
-rw-r--r--fs/cifs/fscache.c12
-rw-r--r--fs/cifs/inode.c57
-rw-r--r--fs/cifs/readdir.c41
-rw-r--r--fs/cifs/xattr.c55
-rw-r--r--fs/compat.c28
-rw-r--r--fs/compat_ioctl.c1
-rw-r--r--fs/ecryptfs/super.c1
-rw-r--r--fs/exec.c41
-rw-r--r--fs/ext3/super.c1
-rw-r--r--fs/ext4/ext4.h1
-rw-r--r--fs/ext4/inode.c5
-rw-r--r--fs/ext4/ioctl.c24
-rw-r--r--fs/ext4/namei.c2
-rw-r--r--fs/ext4/page-io.c4
-rw-r--r--fs/ext4/super.c23
-rw-r--r--fs/fuse/file.c82
-rw-r--r--fs/gfs2/quota.c15
-rw-r--r--fs/ioctl.c40
-rw-r--r--fs/ioprio.c31
-rw-r--r--fs/jbd2/journal.c16
-rw-r--r--fs/lockd/clntlock.c1
-rw-r--r--fs/lockd/clntproc.c1
-rw-r--r--fs/lockd/host.c11
-rw-r--r--fs/lockd/svc4proc.c1
-rw-r--r--fs/lockd/svclock.c1
-rw-r--r--fs/lockd/svcproc.c1
-rw-r--r--fs/locks.c1
-rw-r--r--fs/namei.c3
-rw-r--r--fs/namespace.c1
-rw-r--r--fs/ncpfs/dir.c1
-rw-r--r--fs/ncpfs/file.c1
-rw-r--r--fs/ncpfs/inode.c1
-rw-r--r--fs/ncpfs/ioctl.c1
-rw-r--r--fs/nfs/callback.c1
-rw-r--r--fs/nfs/delegation.c1
-rw-r--r--fs/nfs/dir.c220
-rw-r--r--fs/nfs/direct.c2
-rw-r--r--fs/nfs/file.c2
-rw-r--r--fs/nfs/inode.c1
-rw-r--r--fs/nfs/internal.h9
-rw-r--r--fs/nfs/mount_clnt.c4
-rw-r--r--fs/nfs/nfs2xdr.c8
-rw-r--r--fs/nfs/nfs3xdr.c8
-rw-r--r--fs/nfs/nfs4proc.c13
-rw-r--r--fs/nfs/nfs4xdr.c8
-rw-r--r--fs/nfs/pagelist.c4
-rw-r--r--fs/nfs/read.c1
-rw-r--r--fs/nfs/super.c13
-rw-r--r--fs/nfs/write.c3
-rw-r--r--fs/nfsd/nfs3xdr.c6
-rw-r--r--fs/nfsd/nfs4state.c8
-rw-r--r--fs/nfsd/xdr4.h21
-rw-r--r--fs/nilfs2/dat.c2
-rw-r--r--fs/nilfs2/gcinode.c9
-rw-r--r--fs/nilfs2/ioctl.c16
-rw-r--r--fs/notify/fanotify/fanotify.c6
-rw-r--r--fs/notify/fanotify/fanotify_user.c81
-rw-r--r--fs/notify/inotify/inotify_user.c1
-rw-r--r--fs/ocfs2/cluster/heartbeat.c14
-rw-r--r--fs/ocfs2/dcache.c1
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c2
-rw-r--r--fs/ocfs2/ocfs2.h6
-rw-r--r--fs/ocfs2/stack_user.c2
-rw-r--r--fs/ocfs2/super.c1
-rw-r--r--fs/pipe.c14
-rw-r--r--fs/proc/base.c2
-rw-r--r--fs/proc/inode.c1
-rw-r--r--fs/proc/task_mmu.c3
-rw-r--r--fs/read_write.c1
-rw-r--r--fs/reiserfs/inode.c1
-rw-r--r--fs/reiserfs/ioctl.c8
-rw-r--r--fs/reiserfs/journal.c1
-rw-r--r--fs/reiserfs/super.c1
-rw-r--r--fs/reiserfs/xattr_acl.c6
-rw-r--r--fs/splice.c24
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c94
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c35
-rw-r--r--fs/xfs/xfs_bmap.c85
-rw-r--r--fs/xfs/xfs_bmap.h5
-rw-r--r--fs/xfs/xfs_dfrag.c13
-rw-r--r--fs/xfs/xfs_error.c3
-rw-r--r--fs/xfs/xfs_error.h5
-rw-r--r--fs/xfs/xfs_inode_item.c31
-rw-r--r--fs/xfs/xfs_rename.c1
-rw-r--r--include/acpi/video.h5
-rw-r--r--include/drm/i915_drm.h2
-rw-r--r--include/drm/nouveau_drm.h7
-rw-r--r--include/linux/acpi.h2
-rw-r--r--include/linux/atmdev.h6
-rw-r--r--include/linux/binfmts.h5
-rw-r--r--include/linux/blkdev.h10
-rw-r--r--include/linux/bootmem.h2
-rw-r--r--include/linux/ceph/libceph.h7
-rw-r--r--include/linux/ceph/messenger.h1
-rw-r--r--include/linux/ceph/osd_client.h7
-rw-r--r--include/linux/cnt32_to_63.h20
-rw-r--r--include/linux/cpu.h5
-rw-r--r--include/linux/dmar.h17
-rw-r--r--include/linux/fanotify.h10
-rw-r--r--include/linux/fb.h4
-rw-r--r--include/linux/fs.h8
-rw-r--r--include/linux/fsnotify.h3
-rw-r--r--include/linux/fsnotify_backend.h2
-rw-r--r--include/linux/gfp.h4
-rw-r--r--include/linux/gpio_keys.h2
-rw-r--r--include/linux/hardirq.h6
-rw-r--r--include/linux/hw_breakpoint.h4
-rw-r--r--include/linux/input.h31
-rw-r--r--include/linux/ioport.h2
-rw-r--r--include/linux/libata.h2
-rw-r--r--include/linux/lockd/lockd.h1
-rw-r--r--include/linux/marvell_phy.h1
-rw-r--r--include/linux/memory_hotplug.h6
-rw-r--r--include/linux/mfd/wm8350/audio.h3
-rw-r--r--include/linux/mfd/wm8994/pdata.h2
-rw-r--r--include/linux/mmc/host.h1
-rw-r--r--include/linux/module.h2
-rw-r--r--include/linux/nfs_fs.h7
-rw-r--r--include/linux/nfs_page.h1
-rw-r--r--include/linux/nfs_xdr.h1
-rw-r--r--include/linux/node.h5
-rw-r--r--include/linux/page_cgroup.h7
-rw-r--r--include/linux/pci_ids.h2
-rw-r--r--include/linux/perf_event.h31
-rw-r--r--include/linux/pipe_fs_i.h1
-rw-r--r--include/linux/pm_runtime.h3
-rw-r--r--include/linux/reiserfs_fs.h1
-rw-r--r--include/linux/rtnetlink.h2
-rw-r--r--include/linux/sched.h3
-rw-r--r--include/linux/sh_clk.h34
-rw-r--r--include/linux/smp_lock.h3
-rw-r--r--include/linux/snmp.h1
-rw-r--r--include/linux/ssb/ssb_driver_gige.h17
-rw-r--r--include/linux/tty.h2
-rw-r--r--include/linux/uio_driver.h2
-rw-r--r--include/linux/usb.h4
-rw-r--r--include/linux/via-core.h15
-rw-r--r--include/linux/video_output.h15
-rw-r--r--include/linux/vmalloc.h2
-rw-r--r--include/media/saa7146.h2
-rw-r--r--include/media/v4l2-common.h16
-rw-r--r--include/media/v4l2-device.h2
-rw-r--r--include/net/af_unix.h2
-rw-r--r--include/net/cfg80211.h2
-rw-r--r--include/net/neighbour.h2
-rw-r--r--include/net/sock.h4
-rw-r--r--include/scsi/libfc.h3
-rw-r--r--include/scsi/libiscsi.h3
-rw-r--r--include/scsi/libsas.h3
-rw-r--r--include/scsi/scsi_host.h23
-rw-r--r--include/sound/sh_fsi.h6
-rw-r--r--include/video/da8xx-fb.h1
-rw-r--r--include/video/s1d13xxxfb.h6
-rw-r--r--include/video/sh_mipi_dsi.h6
-rw-r--r--include/video/sh_mobile_hdmi.h3
-rw-r--r--include/xen/events.h7
-rw-r--r--include/xen/interface/io/ring.h11
-rw-r--r--include/xen/interface/memory.h13
-rw-r--r--include/xen/interface/physdev.h10
-rw-r--r--include/xen/page.h7
-rw-r--r--include/xen/privcmd.h5
-rw-r--r--init/Kconfig13
-rw-r--r--init/main.c1
-rw-r--r--kernel/debug/kdb/kdb_main.c21
-rw-r--r--kernel/exit.c9
-rw-r--r--kernel/fork.c1
-rw-r--r--kernel/futex.c3
-rw-r--r--kernel/futex_compat.c3
-rw-r--r--kernel/hw_breakpoint.c3
-rw-r--r--kernel/irq/proc.c2
-rw-r--r--kernel/irq_work.c4
-rw-r--r--kernel/module.c12
-rw-r--r--kernel/perf_event.c130
-rw-r--r--kernel/pm_qos_params.c4
-rw-r--r--kernel/posix-cpu-timers.c12
-rw-r--r--kernel/power/Kconfig4
-rw-r--r--kernel/power/hibernate.c22
-rw-r--r--kernel/power/suspend.c5
-rw-r--r--kernel/power/swap.c55
-rw-r--r--kernel/power/user.c4
-rw-r--r--kernel/printk.c4
-rw-r--r--kernel/resource.c104
-rw-r--r--kernel/sched.c324
-rw-r--r--kernel/sched_fair.c48
-rw-r--r--kernel/sched_stoptask.c4
-rw-r--r--kernel/sysctl.c2
-rw-r--r--kernel/timer.c8
-rw-r--r--kernel/trace/Kconfig2
-rw-r--r--kernel/trace/trace.c30
-rw-r--r--kernel/workqueue.c7
-rw-r--r--lib/debug_locks.c2
-rw-r--r--mm/filemap.c5
-rw-r--r--mm/hugetlb.c3
-rw-r--r--mm/ksm.c7
-rw-r--r--mm/memcontrol.c66
-rw-r--r--mm/memory-failure.c8
-rw-r--r--mm/memory_hotplug.c31
-rw-r--r--mm/mempolicy.c3
-rw-r--r--mm/mmap.c16
-rw-r--r--mm/nommu.c1
-rw-r--r--mm/page_alloc.c33
-rw-r--r--mm/pagewalk.c5
-rw-r--r--mm/slub.c4
-rw-r--r--mm/truncate.c4
-rw-r--r--mm/vmalloc.c28
-rw-r--r--mm/vmscan.c7
-rw-r--r--mm/vmstat.c4
-rw-r--r--net/atm/atm_sysfs.c3
-rw-r--r--net/atm/resources.c7
-rw-r--r--net/atm/resources.h2
-rw-r--r--net/bluetooth/sco.c6
-rw-r--r--net/ceph/Makefile22
-rw-r--r--net/ceph/buffer.c2
-rw-r--r--net/ceph/messenger.c21
-rw-r--r--net/ceph/osd_client.c25
-rw-r--r--net/ceph/pagevec.c16
-rw-r--r--net/core/filter.c19
-rw-r--r--net/core/net-sysfs.c10
-rw-r--r--net/core/request_sock.c4
-rw-r--r--net/core/timestamping.c6
-rw-r--r--net/dccp/input.c3
-rw-r--r--net/decnet/af_decnet.c2
-rw-r--r--net/econet/af_econet.c99
-rw-r--r--net/ipv4/fib_trie.c2
-rw-r--r--net/ipv4/icmp.c3
-rw-r--r--net/ipv4/inet_hashtables.c3
-rw-r--r--net/ipv4/proc.c1
-rw-r--r--net/ipv4/sysctl_net_ipv4.c6
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/ipv4/tcp_minisocks.c2
-rw-r--r--net/ipv4/tcp_output.c42
-rw-r--r--net/ipv6/addrconf.c38
-rw-r--r--net/ipv6/ip6_tunnel.c7
-rw-r--r--net/ipv6/sit.c3
-rw-r--r--net/irda/af_irda.c1
-rw-r--r--net/irda/irnet/irnet_ppp.c1
-rw-r--r--net/irda/irttp.c30
-rw-r--r--net/l2tp/l2tp_ip.c6
-rw-r--r--net/llc/af_llc.c5
-rw-r--r--net/mac80211/Kconfig2
-rw-r--r--net/mac80211/rx.c6
-rw-r--r--net/mac80211/tx.c28
-rw-r--r--net/netfilter/ipvs/Kconfig1
-rw-r--r--net/rds/rdma.c2
-rw-r--r--net/sctp/socket.c8
-rw-r--r--net/socket.c15
-rw-r--r--net/sunrpc/clnt.c24
-rw-r--r--net/sunrpc/stats.c4
-rw-r--r--net/sunrpc/svc_xprt.c10
-rw-r--r--net/unix/af_unix.c37
-rw-r--r--net/unix/garbage.c9
-rw-r--r--net/wireless/chan.c54
-rw-r--r--net/x25/x25_link.c1
-rw-r--r--net/xfrm/xfrm_hash.c2
-rw-r--r--net/xfrm/xfrm_state.c2
-rw-r--r--scripts/gfp-translate7
-rw-r--r--scripts/kconfig/expr.h1
-rw-r--r--scripts/kconfig/lkc.h1
-rw-r--r--scripts/kconfig/menu.c11
-rw-r--r--scripts/kconfig/zconf.gperf1
-rw-r--r--scripts/kconfig/zconf.hash.c_shipped122
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped570
-rw-r--r--scripts/kconfig/zconf.y21
-rwxr-xr-xscripts/kernel-doc12
-rw-r--r--scripts/recordmcount.h2
-rwxr-xr-xscripts/tags.sh4
-rw-r--r--sound/atmel/abdac.c4
-rw-r--r--sound/core/info.c1
-rw-r--r--sound/core/oss/pcm_oss.c19
-rw-r--r--sound/core/pcm_lib.c2
-rw-r--r--sound/core/pcm_native.c1
-rw-r--r--sound/core/sound.c1
-rw-r--r--sound/oss/dev_table.c6
-rw-r--r--sound/oss/midibuf.c4
-rw-r--r--sound/oss/pss.c6
-rw-r--r--sound/oss/sequencer.c4
-rw-r--r--sound/pci/asihpi/hpioctl.c2
-rw-r--r--sound/pci/azt3328.c26
-rw-r--r--sound/pci/ctxfi/ctpcm.c16
-rw-r--r--sound/pci/hda/hda_eld.c24
-rw-r--r--sound/pci/hda/hda_intel.c1
-rw-r--r--sound/pci/hda/patch_conexant.c37
-rw-r--r--sound/pci/hda/patch_hdmi.c1
-rw-r--r--sound/pci/hda/patch_realtek.c110
-rw-r--r--sound/pci/hda/patch_sigmatel.c20
-rw-r--r--sound/pci/intel8x0.c6
-rw-r--r--sound/pci/mixart/mixart_hwdep.h10
-rw-r--r--sound/ppc/pmac.c12
-rw-r--r--sound/soc/atmel/Kconfig5
-rw-r--r--sound/soc/atmel/sam9g20_wm8731.c9
-rw-r--r--sound/soc/atmel/snd-soc-afeb9260.c1
-rw-r--r--sound/soc/codecs/max98088.c14
-rw-r--r--sound/soc/codecs/stac9766.c1
-rw-r--r--sound/soc/codecs/tlv320aic3x.c6
-rw-r--r--sound/soc/codecs/tpa6130a2.c4
-rw-r--r--sound/soc/codecs/uda134x.c1
-rw-r--r--sound/soc/codecs/wm8350.c9
-rw-r--r--sound/soc/codecs/wm8523.c1
-rw-r--r--sound/soc/codecs/wm8580.c10
-rw-r--r--sound/soc/codecs/wm8731.c2
-rw-r--r--sound/soc/codecs/wm8776.c1
-rw-r--r--sound/soc/codecs/wm8904.c5
-rw-r--r--sound/soc/codecs/wm8955.c3
-rw-r--r--sound/soc/codecs/wm8960.c3
-rw-r--r--sound/soc/codecs/wm8961.c4
-rw-r--r--sound/soc/codecs/wm8962.c7
-rw-r--r--sound/soc/codecs/wm8994.c6
-rw-r--r--sound/soc/codecs/wm_hubs.c2
-rw-r--r--sound/soc/davinci/davinci-evm.c40
-rw-r--r--sound/soc/davinci/davinci-i2s.c15
-rw-r--r--sound/soc/davinci/davinci-mcasp.c13
-rw-r--r--sound/soc/davinci/davinci-sffsdr.c2
-rw-r--r--sound/soc/davinci/davinci-vcif.c16
-rw-r--r--sound/soc/ep93xx/simone.c18
-rw-r--r--sound/soc/fsl/efika-audio-fabric.c1
-rw-r--r--sound/soc/fsl/mpc5200_dma.c1
-rw-r--r--sound/soc/fsl/mpc5200_psc_i2s.c2
-rw-r--r--sound/soc/fsl/mpc8610_hpcd.c1
-rw-r--r--sound/soc/fsl/p1022_ds.c1
-rw-r--r--sound/soc/fsl/pcm030-audio-fabric.c1
-rw-r--r--sound/soc/imx/eukrea-tlv320.c8
-rw-r--r--sound/soc/imx/imx-pcm-dma-mx2.c221
-rw-r--r--sound/soc/imx/imx-ssi.c57
-rw-r--r--sound/soc/imx/imx-ssi.h4
-rw-r--r--sound/soc/imx/phycore-ac97.c33
-rw-r--r--sound/soc/nuc900/nuc900-ac97.c17
-rw-r--r--sound/soc/nuc900/nuc900-audio.h2
-rw-r--r--sound/soc/nuc900/nuc900-pcm.c11
-rw-r--r--sound/soc/omap/Kconfig2
-rw-r--r--sound/soc/omap/omap-mcbsp.c8
-rw-r--r--sound/soc/omap/omap3pandora.c1
-rw-r--r--sound/soc/omap/osk5912.c11
-rw-r--r--sound/soc/pxa/Kconfig1
-rw-r--r--sound/soc/pxa/corgi.c5
-rw-r--r--sound/soc/pxa/magician.c4
-rw-r--r--sound/soc/pxa/poodle.c5
-rw-r--r--sound/soc/pxa/spitz.c5
-rw-r--r--sound/soc/pxa/tosa.c5
-rw-r--r--sound/soc/s3c24xx/Kconfig1
-rw-r--r--sound/soc/s3c24xx/rx1950_uda1380.c20
-rw-r--r--sound/soc/s3c24xx/smdk_spdif.c4
-rw-r--r--sound/soc/s6000/s6000-i2s.c2
-rw-r--r--sound/soc/s6000/s6000-pcm.c2
-rw-r--r--sound/soc/s6000/s6105-ipcam.c2
-rw-r--r--sound/soc/sh/fsi.c25
-rw-r--r--sound/soc/sh/ssi.c2
-rw-r--r--sound/soc/soc-core.c23
-rw-r--r--sound/soc/soc-dapm.c7
-rw-r--r--sound/sound_core.c1
-rw-r--r--sound/spi/at73c213.c2
-rw-r--r--tools/perf/builtin-record.c23
-rw-r--r--tools/perf/util/header.c11
-rw-r--r--tools/perf/util/symbol.c63
-rw-r--r--usr/initramfs_data.S5
1420 files changed, 26729 insertions, 12403 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-rbd b/Documentation/ABI/testing/sysfs-bus-rbd
new file mode 100644
index 000000000000..90a87e2a572b
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-rbd
@@ -0,0 +1,83 @@
1What: /sys/bus/rbd/
2Date: November 2010
3Contact: Yehuda Sadeh <yehuda@hq.newdream.net>,
4 Sage Weil <sage@newdream.net>
5Description:
6
7Being used for adding and removing rbd block devices.
8
9Usage: <mon ip addr> <options> <pool name> <rbd image name> [snap name]
10
11 $ echo "192.168.0.1 name=admin rbd foo" > /sys/bus/rbd/add
12
13The snapshot name can be "-" or omitted to map the image read/write. A <dev-id>
14will be assigned for any registered block device. If snapshot is used, it will
15be mapped read-only.
16
17Removal of a device:
18
19 $ echo <dev-id> > /sys/bus/rbd/remove
20
21Entries under /sys/bus/rbd/devices/<dev-id>/
22--------------------------------------------
23
24client_id
25
26 The ceph unique client id that was assigned for this specific session.
27
28major
29
30 The block device major number.
31
32name
33
34 The name of the rbd image.
35
36pool
37
38 The pool where this rbd image resides. The pool-name pair is unique
39 per rados system.
40
41size
42
43 The size (in bytes) of the mapped block device.
44
45refresh
46
47 Writing to this file will reread the image header data and set
48 all relevant datastructures accordingly.
49
50current_snap
51
52 The current snapshot for which the device is mapped.
53
54create_snap
55
56 Create a snapshot:
57
58 $ echo <snap-name> > /sys/bus/rbd/devices/<dev-id>/snap_create
59
60rollback_snap
61
62 Rolls back data to the specified snapshot. This goes over the entire
63 list of rados blocks and sends a rollback command to each.
64
65 $ echo <snap-name> > /sys/bus/rbd/devices/<dev-id>/snap_rollback
66
67snap_*
68
69 A directory per each snapshot
70
71
72Entries under /sys/bus/rbd/devices/<dev-id>/snap_<snap-name>
73-------------------------------------------------------------
74
75id
76
77 The rados internal snapshot id assigned for this snapshot
78
79size
80
81 The size of the image when this snapshot was taken.
82
83
diff --git a/Documentation/ABI/testing/sysfs-platform-asus-laptop b/Documentation/ABI/testing/sysfs-platform-asus-laptop
index 1d775390e856..41ff8ae4dee0 100644
--- a/Documentation/ABI/testing/sysfs-platform-asus-laptop
+++ b/Documentation/ABI/testing/sysfs-platform-asus-laptop
@@ -47,6 +47,20 @@ Date: January 2007
47KernelVersion: 2.6.20 47KernelVersion: 2.6.20
48Contact: "Corentin Chary" <corentincj@iksaif.net> 48Contact: "Corentin Chary" <corentincj@iksaif.net>
49Description: 49Description:
50 Control the bluetooth device. 1 means on, 0 means off. 50 Control the wlan device. 1 means on, 0 means off.
51 This may control the led, the device or both. 51 This may control the led, the device or both.
52Users: Lapsus 52Users: Lapsus
53
54What: /sys/devices/platform/asus_laptop/wimax
55Date: October 2010
56KernelVersion: 2.6.37
57Contact: "Corentin Chary" <corentincj@iksaif.net>
58Description:
59 Control the wimax device. 1 means on, 0 means off.
60
61What: /sys/devices/platform/asus_laptop/wwan
62Date: October 2010
63KernelVersion: 2.6.37
64Contact: "Corentin Chary" <corentincj@iksaif.net>
65Description:
66 Control the wwan (3G) device. 1 means on, 0 means off.
diff --git a/Documentation/ABI/testing/sysfs-platform-eeepc-wmi b/Documentation/ABI/testing/sysfs-platform-eeepc-wmi
new file mode 100644
index 000000000000..e4b5fef5fadd
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-platform-eeepc-wmi
@@ -0,0 +1,10 @@
1What: /sys/devices/platform/eeepc-wmi/cpufv
2Date: Oct 2010
3KernelVersion: 2.6.37
4Contact: "Corentin Chary" <corentincj@iksaif.net>
5Description:
6 Change CPU clock configuration (write-only).
7 There are three available clock configuration:
8 * 0 -> Super Performance Mode
9 * 1 -> High Performance Mode
10 * 2 -> Power Saving Mode
diff --git a/Documentation/DocBook/sh.tmpl b/Documentation/DocBook/sh.tmpl
index d858d92cf6d9..4a38f604fa66 100644
--- a/Documentation/DocBook/sh.tmpl
+++ b/Documentation/DocBook/sh.tmpl
@@ -79,10 +79,6 @@
79 </sect2> 79 </sect2>
80 </sect1> 80 </sect1>
81 </chapter> 81 </chapter>
82 <chapter id="clk">
83 <title>Clock Framework Extensions</title>
84!Iinclude/linux/sh_clk.h
85 </chapter>
86 <chapter id="mach"> 82 <chapter id="mach">
87 <title>Machine Specific Interfaces</title> 83 <title>Machine Specific Interfaces</title>
88 <sect1 id="dreamcast"> 84 <sect1 id="dreamcast">
diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
index 4d4ce0e61e42..b4665b9c40b0 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -16,7 +16,7 @@
16 </orgname> 16 </orgname>
17 17
18 <address> 18 <address>
19 <email>hjk@linutronix.de</email> 19 <email>hjk@hansjkoch.de</email>
20 </address> 20 </address>
21 </affiliation> 21 </affiliation>
22</author> 22</author>
@@ -114,7 +114,7 @@ GPL version 2.
114 114
115<para>If you know of any translations for this document, or you are 115<para>If you know of any translations for this document, or you are
116interested in translating it, please email me 116interested in translating it, please email me
117<email>hjk@linutronix.de</email>. 117<email>hjk@hansjkoch.de</email>.
118</para> 118</para>
119</sect1> 119</sect1>
120 120
@@ -171,7 +171,7 @@ interested in translating it, please email me
171<title>Feedback</title> 171<title>Feedback</title>
172 <para>Find something wrong with this document? (Or perhaps something 172 <para>Find something wrong with this document? (Or perhaps something
173 right?) I would love to hear from you. Please email me at 173 right?) I would love to hear from you. Please email me at
174 <email>hjk@linutronix.de</email>.</para> 174 <email>hjk@hansjkoch.de</email>.</para>
175</sect1> 175</sect1>
176</chapter> 176</chapter>
177 177
diff --git a/Documentation/development-process/2.Process b/Documentation/development-process/2.Process
index 97726eba6102..911a45186340 100644
--- a/Documentation/development-process/2.Process
+++ b/Documentation/development-process/2.Process
@@ -154,7 +154,7 @@ The stages that a patch goes through are, generally:
154 inclusion, it should be accepted by a relevant subsystem maintainer - 154 inclusion, it should be accepted by a relevant subsystem maintainer -
155 though this acceptance is not a guarantee that the patch will make it 155 though this acceptance is not a guarantee that the patch will make it
156 all the way to the mainline. The patch will show up in the maintainer's 156 all the way to the mainline. The patch will show up in the maintainer's
157 subsystem tree and into the staging trees (described below). When the 157 subsystem tree and into the -next trees (described below). When the
158 process works, this step leads to more extensive review of the patch and 158 process works, this step leads to more extensive review of the patch and
159 the discovery of any problems resulting from the integration of this 159 the discovery of any problems resulting from the integration of this
160 patch with work being done by others. 160 patch with work being done by others.
@@ -236,7 +236,7 @@ finding the right maintainer. Sending patches directly to Linus is not
236normally the right way to go. 236normally the right way to go.
237 237
238 238
2392.4: STAGING TREES 2392.4: NEXT TREES
240 240
241The chain of subsystem trees guides the flow of patches into the kernel, 241The chain of subsystem trees guides the flow of patches into the kernel,
242but it also raises an interesting question: what if somebody wants to look 242but it also raises an interesting question: what if somebody wants to look
@@ -250,7 +250,7 @@ changes land in the mainline kernel. One could pull changes from all of
250the interesting subsystem trees, but that would be a big and error-prone 250the interesting subsystem trees, but that would be a big and error-prone
251job. 251job.
252 252
253The answer comes in the form of staging trees, where subsystem trees are 253The answer comes in the form of -next trees, where subsystem trees are
254collected for testing and review. The older of these trees, maintained by 254collected for testing and review. The older of these trees, maintained by
255Andrew Morton, is called "-mm" (for memory management, which is how it got 255Andrew Morton, is called "-mm" (for memory management, which is how it got
256started). The -mm tree integrates patches from a long list of subsystem 256started). The -mm tree integrates patches from a long list of subsystem
@@ -275,7 +275,7 @@ directory at:
275Use of the MMOTM tree is likely to be a frustrating experience, though; 275Use of the MMOTM tree is likely to be a frustrating experience, though;
276there is a definite chance that it will not even compile. 276there is a definite chance that it will not even compile.
277 277
278The other staging tree, started more recently, is linux-next, maintained by 278The other -next tree, started more recently, is linux-next, maintained by
279Stephen Rothwell. The linux-next tree is, by design, a snapshot of what 279Stephen Rothwell. The linux-next tree is, by design, a snapshot of what
280the mainline is expected to look like after the next merge window closes. 280the mainline is expected to look like after the next merge window closes.
281Linux-next trees are announced on the linux-kernel and linux-next mailing 281Linux-next trees are announced on the linux-kernel and linux-next mailing
@@ -303,12 +303,25 @@ volatility of linux-next tends to make it a difficult development target.
303See http://lwn.net/Articles/289013/ for more information on this topic, and 303See http://lwn.net/Articles/289013/ for more information on this topic, and
304stay tuned; much is still in flux where linux-next is involved. 304stay tuned; much is still in flux where linux-next is involved.
305 305
306Besides the mmotm and linux-next trees, the kernel source tree now contains 3062.4.1: STAGING TREES
307the drivers/staging/ directory and many sub-directories for drivers or 307
308filesystems that are on their way to being added to the kernel tree 308The kernel source tree now contains the drivers/staging/ directory, where
309proper, but they remain in drivers/staging/ while they still need more 309many sub-directories for drivers or filesystems that are on their way to
310work. 310being added to the kernel tree live. They remain in drivers/staging while
311 311they still need more work; once complete, they can be moved into the
312kernel proper. This is a way to keep track of drivers that aren't
313up to Linux kernel coding or quality standards, but people may want to use
314them and track development.
315
316Greg Kroah-Hartman currently (as of 2.6.36) maintains the staging tree.
317Drivers that still need work are sent to him, with each driver having
318its own subdirectory in drivers/staging/. Along with the driver source
319files, a TODO file should be present in the directory as well. The TODO
320file lists the pending work that the driver needs for acceptance into
321the kernel proper, as well as a list of people that should be Cc'd for any
322patches to the driver. Staging drivers that don't currently build should
323have their config entries depend upon CONFIG_BROKEN. Once they can
324be successfully built without outside patches, CONFIG_BROKEN can be removed.
312 325
3132.5: TOOLS 3262.5: TOOLS
314 327
diff --git a/Documentation/driver-model/interface.txt b/Documentation/driver-model/interface.txt
deleted file mode 100644
index c66912bfe866..000000000000
--- a/Documentation/driver-model/interface.txt
+++ /dev/null
@@ -1,129 +0,0 @@
1
2Device Interfaces
3
4Introduction
5~~~~~~~~~~~~
6
7Device interfaces are the logical interfaces of device classes that correlate
8directly to userspace interfaces, like device nodes.
9
10Each device class may have multiple interfaces through which you can
11access the same device. An input device may support the mouse interface,
12the 'evdev' interface, and the touchscreen interface. A SCSI disk would
13support the disk interface, the SCSI generic interface, and possibly a raw
14device interface.
15
16Device interfaces are registered with the class they belong to. As devices
17are added to the class, they are added to each interface registered with
18the class. The interface is responsible for determining whether the device
19supports the interface or not.
20
21
22Programming Interface
23~~~~~~~~~~~~~~~~~~~~~
24
25struct device_interface {
26 char * name;
27 rwlock_t lock;
28 u32 devnum;
29 struct device_class * devclass;
30
31 struct list_head node;
32 struct driver_dir_entry dir;
33
34 int (*add_device)(struct device *);
35 int (*add_device)(struct intf_data *);
36};
37
38int interface_register(struct device_interface *);
39void interface_unregister(struct device_interface *);
40
41
42An interface must specify the device class it belongs to. It is added
43to that class's list of interfaces on registration.
44
45
46Interfaces can be added to a device class at any time. Whenever it is
47added, each device in the class is passed to the interface's
48add_device callback. When an interface is removed, each device is
49removed from the interface.
50
51
52Devices
53~~~~~~~
54Once a device is added to a device class, it is added to each
55interface that is registered with the device class. The class
56is expected to place a class-specific data structure in
57struct device::class_data. The interface can use that (along with
58other fields of struct device) to determine whether or not the driver
59and/or device support that particular interface.
60
61
62Data
63~~~~
64
65struct intf_data {
66 struct list_head node;
67 struct device_interface * intf;
68 struct device * dev;
69 u32 intf_num;
70};
71
72int interface_add_data(struct interface_data *);
73
74The interface is responsible for allocating and initializing a struct
75intf_data and calling interface_add_data() to add it to the device's list
76of interfaces it belongs to. This list will be iterated over when the device
77is removed from the class (instead of all possible interfaces for a class).
78This structure should probably be embedded in whatever per-device data
79structure the interface is allocating anyway.
80
81Devices are enumerated within the interface. This happens in interface_add_data()
82and the enumerated value is stored in the struct intf_data for that device.
83
84sysfs
85~~~~~
86Each interface is given a directory in the directory of the device
87class it belongs to:
88
89Interfaces get a directory in the class's directory as well:
90
91 class/
92 `-- input
93 |-- devices
94 |-- drivers
95 |-- mouse
96 `-- evdev
97
98When a device is added to the interface, a symlink is created that points
99to the device's directory in the physical hierarchy:
100
101 class/
102 `-- input
103 |-- devices
104 | `-- 1 -> ../../../root/pci0/00:1f.0/usb_bus/00:1f.2-1:0/
105 |-- drivers
106 | `-- usb:usb_mouse -> ../../../bus/drivers/usb_mouse/
107 |-- mouse
108 | `-- 1 -> ../../../root/pci0/00:1f.0/usb_bus/00:1f.2-1:0/
109 `-- evdev
110 `-- 1 -> ../../../root/pci0/00:1f.0/usb_bus/00:1f.2-1:0/
111
112
113Future Plans
114~~~~~~~~~~~~
115A device interface is correlated directly with a userspace interface
116for a device, specifically a device node. For instance, a SCSI disk
117exposes at least two interfaces to userspace: the standard SCSI disk
118interface and the SCSI generic interface. It might also export a raw
119device interface.
120
121Many interfaces have a major number associated with them and each
122device gets a minor number. Or, multiple interfaces might share one
123major number, and each will receive a range of minor numbers (like in
124the case of input devices).
125
126These major and minor numbers could be stored in the interface
127structure. Major and minor allocations could happen when the interface
128is registered with the class, or via a helper function.
129
diff --git a/Documentation/edac.txt b/Documentation/edac.txt
index 0b875e8da969..9ee774de57cd 100644
--- a/Documentation/edac.txt
+++ b/Documentation/edac.txt
@@ -196,7 +196,7 @@ csrow3.
196The representation of the above is reflected in the directory tree 196The representation of the above is reflected in the directory tree
197in EDAC's sysfs interface. Starting in directory 197in EDAC's sysfs interface. Starting in directory
198/sys/devices/system/edac/mc each memory controller will be represented 198/sys/devices/system/edac/mc each memory controller will be represented
199by its own 'mcX' directory, where 'X" is the index of the MC. 199by its own 'mcX' directory, where 'X' is the index of the MC.
200 200
201 201
202 ..../edac/mc/ 202 ..../edac/mc/
@@ -207,7 +207,7 @@ by its own 'mcX' directory, where 'X" is the index of the MC.
207 .... 207 ....
208 208
209Under each 'mcX' directory each 'csrowX' is again represented by a 209Under each 'mcX' directory each 'csrowX' is again represented by a
210'csrowX', where 'X" is the csrow index: 210'csrowX', where 'X' is the csrow index:
211 211
212 212
213 .../mc/mc0/ 213 .../mc/mc0/
@@ -232,7 +232,7 @@ EDAC control and attribute files.
232 232
233 233
234In 'mcX' directories are EDAC control and attribute files for 234In 'mcX' directories are EDAC control and attribute files for
235this 'X" instance of the memory controllers: 235this 'X' instance of the memory controllers:
236 236
237 237
238Counter reset control file: 238Counter reset control file:
@@ -343,7 +343,7 @@ Sdram memory scrubbing rate:
343'csrowX' DIRECTORIES 343'csrowX' DIRECTORIES
344 344
345In the 'csrowX' directories are EDAC control and attribute files for 345In the 'csrowX' directories are EDAC control and attribute files for
346this 'X" instance of csrow: 346this 'X' instance of csrow:
347 347
348 348
349Total Uncorrectable Errors count attribute file: 349Total Uncorrectable Errors count attribute file:
diff --git a/Documentation/fb/00-INDEX b/Documentation/fb/00-INDEX
index a618fd99c9f0..30a70542e823 100644
--- a/Documentation/fb/00-INDEX
+++ b/Documentation/fb/00-INDEX
@@ -4,33 +4,41 @@ please mail me.
4 Geert Uytterhoeven <geert@linux-m68k.org> 4 Geert Uytterhoeven <geert@linux-m68k.org>
5 5
600-INDEX 600-INDEX
7 - this file 7 - this file.
8arkfb.txt 8arkfb.txt
9 - info on the fbdev driver for ARK Logic chips. 9 - info on the fbdev driver for ARK Logic chips.
10aty128fb.txt 10aty128fb.txt
11 - info on the ATI Rage128 frame buffer driver. 11 - info on the ATI Rage128 frame buffer driver.
12cirrusfb.txt 12cirrusfb.txt
13 - info on the driver for Cirrus Logic chipsets. 13 - info on the driver for Cirrus Logic chipsets.
14cmap_xfbdev.txt
15 - an introduction to fbdev's cmap structures.
14deferred_io.txt 16deferred_io.txt
15 - an introduction to deferred IO. 17 - an introduction to deferred IO.
18efifb.txt
19 - info on the EFI platform driver for Intel based Apple computers.
20ep93xx-fb.txt
21 - info on the driver for EP93xx LCD controller.
16fbcon.txt 22fbcon.txt
17 - intro to and usage guide for the framebuffer console (fbcon). 23 - intro to and usage guide for the framebuffer console (fbcon).
18framebuffer.txt 24framebuffer.txt
19 - introduction to frame buffer devices. 25 - introduction to frame buffer devices.
20imacfb.txt 26gxfb.txt
21 - info on the generic EFI platform driver for Intel based Macs. 27 - info on the framebuffer driver for AMD Geode GX2 based processors.
22intel810.txt 28intel810.txt
23 - documentation for the Intel 810/815 framebuffer driver. 29 - documentation for the Intel 810/815 framebuffer driver.
24intelfb.txt 30intelfb.txt
25 - docs for Intel 830M/845G/852GM/855GM/865G/915G/945G fb driver. 31 - docs for Intel 830M/845G/852GM/855GM/865G/915G/945G fb driver.
26internals.txt 32internals.txt
27 - quick overview of frame buffer device internals. 33 - quick overview of frame buffer device internals.
34lxfb.txt
35 - info on the framebuffer driver for AMD Geode LX based processors.
28matroxfb.txt 36matroxfb.txt
29 - info on the Matrox framebuffer driver for Alpha, Intel and PPC. 37 - info on the Matrox framebuffer driver for Alpha, Intel and PPC.
38metronomefb.txt
39 - info on the driver for the Metronome display controller.
30modedb.txt 40modedb.txt
31 - info on the video mode database. 41 - info on the video mode database.
32matroxfb.txt
33 - info on the Matrox frame buffer driver.
34pvr2fb.txt 42pvr2fb.txt
35 - info on the PowerVR 2 frame buffer driver. 43 - info on the PowerVR 2 frame buffer driver.
36pxafb.txt 44pxafb.txt
@@ -39,13 +47,23 @@ s3fb.txt
39 - info on the fbdev driver for S3 Trio/Virge chips. 47 - info on the fbdev driver for S3 Trio/Virge chips.
40sa1100fb.txt 48sa1100fb.txt
41 - information about the driver for the SA-1100 LCD controller. 49 - information about the driver for the SA-1100 LCD controller.
50sh7760fb.txt
51 - info on the SH7760/SH7763 integrated LCDC Framebuffer driver.
42sisfb.txt 52sisfb.txt
43 - info on the framebuffer device driver for various SiS chips. 53 - info on the framebuffer device driver for various SiS chips.
44sstfb.txt 54sstfb.txt
45 - info on the frame buffer driver for 3dfx' Voodoo Graphics boards. 55 - info on the frame buffer driver for 3dfx' Voodoo Graphics boards.
46tgafb.txt 56tgafb.txt
47 - info on the TGA (DECChip 21030) frame buffer driver 57 - info on the TGA (DECChip 21030) frame buffer driver.
58tridentfb.txt
59 info on the framebuffer driver for some Trident chip based cards.
60uvesafb.txt
61 - info on the userspace VESA (VBE2+ compliant) frame buffer device.
48vesafb.txt 62vesafb.txt
49 - info on the VESA frame buffer device 63 - info on the VESA frame buffer device.
64viafb.modes
65 - list of modes for VIA Integration Graphic Chip.
66viafb.txt
67 - info on the VIA Integration Graphic Chip console framebuffer driver.
50vt8623fb.txt 68vt8623fb.txt
51 - info on the fb driver for the graphics core in VIA VT8623 chipsets. 69 - info on the fb driver for the graphics core in VIA VT8623 chipsets.
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index a91f30890011..b6426f15b4ae 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -173,12 +173,13 @@ prototypes:
173 sector_t (*bmap)(struct address_space *, sector_t); 173 sector_t (*bmap)(struct address_space *, sector_t);
174 int (*invalidatepage) (struct page *, unsigned long); 174 int (*invalidatepage) (struct page *, unsigned long);
175 int (*releasepage) (struct page *, int); 175 int (*releasepage) (struct page *, int);
176 void (*freepage)(struct page *);
176 int (*direct_IO)(int, struct kiocb *, const struct iovec *iov, 177 int (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
177 loff_t offset, unsigned long nr_segs); 178 loff_t offset, unsigned long nr_segs);
178 int (*launder_page) (struct page *); 179 int (*launder_page) (struct page *);
179 180
180locking rules: 181locking rules:
181 All except set_page_dirty may block 182 All except set_page_dirty and freepage may block
182 183
183 BKL PageLocked(page) i_mutex 184 BKL PageLocked(page) i_mutex
184writepage: no yes, unlocks (see below) 185writepage: no yes, unlocks (see below)
@@ -193,6 +194,7 @@ perform_write: no n/a yes
193bmap: no 194bmap: no
194invalidatepage: no yes 195invalidatepage: no yes
195releasepage: no yes 196releasepage: no yes
197freepage: no yes
196direct_IO: no 198direct_IO: no
197launder_page: no yes 199launder_page: no yes
198 200
@@ -288,6 +290,9 @@ buffers from the page in preparation for freeing it. It returns zero to
288indicate that the buffers are (or may be) freeable. If ->releasepage is zero, 290indicate that the buffers are (or may be) freeable. If ->releasepage is zero,
289the kernel assumes that the fs has no private interest in the buffers. 291the kernel assumes that the fs has no private interest in the buffers.
290 292
293 ->freepage() is called when the kernel is done dropping the page
294from the page cache.
295
291 ->launder_page() may be called prior to releasing a page if 296 ->launder_page() may be called prior to releasing a page if
292it is still found to be dirty. It returns zero if the page was successfully 297it is still found to be dirty. It returns zero if the page was successfully
293cleaned, or an error value if not. Note that in order to prevent the page 298cleaned, or an error value if not. Note that in order to prevent the page
diff --git a/Documentation/filesystems/configfs/configfs_example_explicit.c b/Documentation/filesystems/configfs/configfs_example_explicit.c
index d428cc9f07f3..fd53869f5633 100644
--- a/Documentation/filesystems/configfs/configfs_example_explicit.c
+++ b/Documentation/filesystems/configfs/configfs_example_explicit.c
@@ -89,7 +89,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
89 char *p = (char *) page; 89 char *p = (char *) page;
90 90
91 tmp = simple_strtoul(p, &p, 10); 91 tmp = simple_strtoul(p, &p, 10);
92 if (!p || (*p && (*p != '\n'))) 92 if ((*p != '\0') && (*p != '\n'))
93 return -EINVAL; 93 return -EINVAL;
94 94
95 if (tmp > INT_MAX) 95 if (tmp > INT_MAX)
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index ed7e5efc06d8..20899e095e7e 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -534,6 +534,7 @@ struct address_space_operations {
534 sector_t (*bmap)(struct address_space *, sector_t); 534 sector_t (*bmap)(struct address_space *, sector_t);
535 int (*invalidatepage) (struct page *, unsigned long); 535 int (*invalidatepage) (struct page *, unsigned long);
536 int (*releasepage) (struct page *, int); 536 int (*releasepage) (struct page *, int);
537 void (*freepage)(struct page *);
537 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov, 538 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
538 loff_t offset, unsigned long nr_segs); 539 loff_t offset, unsigned long nr_segs);
539 struct page* (*get_xip_page)(struct address_space *, sector_t, 540 struct page* (*get_xip_page)(struct address_space *, sector_t,
@@ -660,11 +661,10 @@ struct address_space_operations {
660 releasepage: releasepage is called on PagePrivate pages to indicate 661 releasepage: releasepage is called on PagePrivate pages to indicate
661 that the page should be freed if possible. ->releasepage 662 that the page should be freed if possible. ->releasepage
662 should remove any private data from the page and clear the 663 should remove any private data from the page and clear the
663 PagePrivate flag. It may also remove the page from the 664 PagePrivate flag. If releasepage() fails for some reason, it must
664 address_space. If this fails for some reason, it may indicate 665 indicate failure with a 0 return value.
665 failure with a 0 return value. 666 releasepage() is used in two distinct though related cases. The
666 This is used in two distinct though related cases. The first 667 first is when the VM finds a clean page with no active users and
667 is when the VM finds a clean page with no active users and
668 wants to make it a free page. If ->releasepage succeeds, the 668 wants to make it a free page. If ->releasepage succeeds, the
669 page will be removed from the address_space and become free. 669 page will be removed from the address_space and become free.
670 670
@@ -679,6 +679,12 @@ struct address_space_operations {
679 need to ensure this. Possibly it can clear the PageUptodate 679 need to ensure this. Possibly it can clear the PageUptodate
680 bit if it cannot free private data yet. 680 bit if it cannot free private data yet.
681 681
682 freepage: freepage is called once the page is no longer visible in
683 the page cache in order to allow the cleanup of any private
684 data. Since it may be called by the memory reclaimer, it
685 should not assume that the original address_space mapping still
686 exists, and it should not block.
687
682 direct_IO: called by the generic read/write routines to perform 688 direct_IO: called by the generic read/write routines to perform
683 direct_IO - that is IO requests which bypass the page cache 689 direct_IO - that is IO requests which bypass the page cache
684 and transfer data directly between the storage and the 690 and transfer data directly between the storage and the
diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
index 9633da01ff46..792faa3c06cf 100644
--- a/Documentation/gpio.txt
+++ b/Documentation/gpio.txt
@@ -617,6 +617,16 @@ and have the following read/write attributes:
617 is configured as an output, this value may be written; 617 is configured as an output, this value may be written;
618 any nonzero value is treated as high. 618 any nonzero value is treated as high.
619 619
620 If the pin can be configured as interrupt-generating interrupt
621 and if it has been configured to generate interrupts (see the
622 description of "edge"), you can poll(2) on that file and
623 poll(2) will return whenever the interrupt was triggered. If
624 you use poll(2), set the events POLLPRI and POLLERR. If you
625 use select(2), set the file descriptor in exceptfds. After
626 poll(2) returns, either lseek(2) to the beginning of the sysfs
627 file and read the new value or close the file and re-open it
628 to read the value.
629
620 "edge" ... reads as either "none", "rising", "falling", or 630 "edge" ... reads as either "none", "rising", "falling", or
621 "both". Write these strings to select the signal edge(s) 631 "both". Write these strings to select the signal edge(s)
622 that will make poll(2) on the "value" file return. 632 that will make poll(2) on the "value" file return.
diff --git a/Documentation/hwmon/lm93 b/Documentation/hwmon/lm93
index ac711f357faf..7a10616d0b44 100644
--- a/Documentation/hwmon/lm93
+++ b/Documentation/hwmon/lm93
@@ -11,7 +11,7 @@ Authors:
11 Mark M. Hoffman <mhoffman@lightlink.com> 11 Mark M. Hoffman <mhoffman@lightlink.com>
12 Ported to 2.6 by Eric J. Bowersox <ericb@aspsys.com> 12 Ported to 2.6 by Eric J. Bowersox <ericb@aspsys.com>
13 Adapted to 2.6.20 by Carsten Emde <ce@osadl.org> 13 Adapted to 2.6.20 by Carsten Emde <ce@osadl.org>
14 Modified for mainline integration by Hans J. Koch <hjk@linutronix.de> 14 Modified for mainline integration by Hans J. Koch <hjk@hansjkoch.de>
15 15
16Module Parameters 16Module Parameters
17----------------- 17-----------------
diff --git a/Documentation/hwmon/max6650 b/Documentation/hwmon/max6650
index 8be7beb9e3e8..c565650fcfc6 100644
--- a/Documentation/hwmon/max6650
+++ b/Documentation/hwmon/max6650
@@ -8,7 +8,7 @@ Supported chips:
8 Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf 8 Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf
9 9
10Authors: 10Authors:
11 Hans J. Koch <hjk@linutronix.de> 11 Hans J. Koch <hjk@hansjkoch.de>
12 John Morris <john.morris@spirentcom.com> 12 John Morris <john.morris@spirentcom.com>
13 Claus Gindhart <claus.gindhart@kontron.com> 13 Claus Gindhart <claus.gindhart@kontron.com>
14 14
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 92e83e53148f..8b61c9360999 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2175,11 +2175,6 @@ and is between 256 and 4096 characters. It is defined in the file
2175 reset_devices [KNL] Force drivers to reset the underlying device 2175 reset_devices [KNL] Force drivers to reset the underlying device
2176 during initialization. 2176 during initialization.
2177 2177
2178 resource_alloc_from_bottom
2179 Allocate new resources from the beginning of available
2180 space, not the end. If you need to use this, please
2181 report a bug.
2182
2183 resume= [SWSUSP] 2178 resume= [SWSUSP]
2184 Specify the partition device for software suspend 2179 Specify the partition device for software suspend
2185 2180
@@ -2385,6 +2380,11 @@ and is between 256 and 4096 characters. It is defined in the file
2385 improve throughput, but will also increase the 2380 improve throughput, but will also increase the
2386 amount of memory reserved for use by the client. 2381 amount of memory reserved for use by the client.
2387 2382
2383 swapaccount[=0|1]
2384 [KNL] Enable accounting of swap in memory resource
2385 controller if no parameter or 1 is given or disable
2386 it if 0 is given (See Documentation/cgroups/memory.txt)
2387
2388 swiotlb= [IA-64] Number of I/O TLB slabs 2388 swiotlb= [IA-64] Number of I/O TLB slabs
2389 2389
2390 switches= [HW,M68k] 2390 switches= [HW,M68k]
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index fe95105992c5..3c5e465296e1 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -144,6 +144,7 @@ tcp_adv_win_scale - INTEGER
144 Count buffering overhead as bytes/2^tcp_adv_win_scale 144 Count buffering overhead as bytes/2^tcp_adv_win_scale
145 (if tcp_adv_win_scale > 0) or bytes-bytes/2^(-tcp_adv_win_scale), 145 (if tcp_adv_win_scale > 0) or bytes-bytes/2^(-tcp_adv_win_scale),
146 if it is <= 0. 146 if it is <= 0.
147 Possible values are [-31, 31], inclusive.
147 Default: 2 148 Default: 2
148 149
149tcp_allowed_congestion_control - STRING 150tcp_allowed_congestion_control - STRING
diff --git a/Documentation/power/opp.txt b/Documentation/power/opp.txt
index 44d87ad3cea9..cd445582d1f8 100644
--- a/Documentation/power/opp.txt
+++ b/Documentation/power/opp.txt
@@ -37,6 +37,9 @@ Typical usage of the OPP library is as follows:
37SoC framework -> modifies on required cases certain OPPs -> OPP layer 37SoC framework -> modifies on required cases certain OPPs -> OPP layer
38 -> queries to search/retrieve information -> 38 -> queries to search/retrieve information ->
39 39
40Architectures that provide a SoC framework for OPP should select ARCH_HAS_OPP
41to make the OPP layer available.
42
40OPP layer expects each domain to be represented by a unique device pointer. SoC 43OPP layer expects each domain to be represented by a unique device pointer. SoC
41framework registers a set of initial OPPs per device with the OPP layer. This 44framework registers a set of initial OPPs per device with the OPP layer. This
42list is expected to be an optimally small number typically around 5 per device. 45list is expected to be an optimally small number typically around 5 per device.
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
index 489e9bacd165..41cc7b30d7dd 100644
--- a/Documentation/power/runtime_pm.txt
+++ b/Documentation/power/runtime_pm.txt
@@ -379,8 +379,8 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
379 zero) 379 zero)
380 380
381 bool pm_runtime_suspended(struct device *dev); 381 bool pm_runtime_suspended(struct device *dev);
382 - return true if the device's runtime PM status is 'suspended', or false 382 - return true if the device's runtime PM status is 'suspended' and its
383 otherwise 383 'power.disable_depth' field is equal to zero, or false otherwise
384 384
385 void pm_runtime_allow(struct device *dev); 385 void pm_runtime_allow(struct device *dev);
386 - set the power.runtime_auto flag for the device and decrease its usage 386 - set the power.runtime_auto flag for the device and decrease its usage
diff --git a/Documentation/sh/clk.txt b/Documentation/sh/clk.txt
deleted file mode 100644
index 114b595cfa97..000000000000
--- a/Documentation/sh/clk.txt
+++ /dev/null
@@ -1,32 +0,0 @@
1Clock framework on SuperH architecture
2
3The framework on SH extends existing API by the function clk_set_rate_ex,
4which prototype is as follows:
5
6 clk_set_rate_ex (struct clk *clk, unsigned long rate, int algo_id)
7
8The algo_id parameter is used to specify algorithm used to recalculate clocks,
9adjanced to clock, specified as first argument. It is assumed that algo_id==0
10means no changes to adjanced clock
11
12Internally, the clk_set_rate_ex forwards request to clk->ops->set_rate method,
13if it is present in ops structure. The method should set the clock rate and adjust
14all needed clocks according to the passed algo_id.
15Exact values for algo_id are machine-dependent. For the sh7722, the following
16values are defined:
17
18 NO_CHANGE = 0,
19 IUS_N1_N1, /* I:U = N:1, U:Sh = N:1 */
20 IUS_322, /* I:U:Sh = 3:2:2 */
21 IUS_522, /* I:U:Sh = 5:2:2 */
22 IUS_N11, /* I:U:Sh = N:1:1 */
23 SB_N1, /* Sh:B = N:1 */
24 SB3_N1, /* Sh:B3 = N:1 */
25 SB3_32, /* Sh:B3 = 3:2 */
26 SB3_43, /* Sh:B3 = 4:3 */
27 SB3_54, /* Sh:B3 = 5:4 */
28 BP_N1, /* B:P = N:1 */
29 IP_N1 /* I:P = N:1 */
30
31Each of these constants means relation between clocks that can be set via the FRQCR
32register
diff --git a/MAINTAINERS b/MAINTAINERS
index 8e6548dbd5db..6a588873cf8d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -559,14 +559,14 @@ W: http://maxim.org.za/at91_26.html
559S: Maintained 559S: Maintained
560 560
561ARM/BCMRING ARM ARCHITECTURE 561ARM/BCMRING ARM ARCHITECTURE
562M: Leo Chen <leochen@broadcom.com> 562M: Jiandong Zheng <jdzheng@broadcom.com>
563M: Scott Branden <sbranden@broadcom.com> 563M: Scott Branden <sbranden@broadcom.com>
564L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 564L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
565S: Maintained 565S: Maintained
566F: arch/arm/mach-bcmring 566F: arch/arm/mach-bcmring
567 567
568ARM/BCMRING MTD NAND DRIVER 568ARM/BCMRING MTD NAND DRIVER
569M: Leo Chen <leochen@broadcom.com> 569M: Jiandong Zheng <jdzheng@broadcom.com>
570M: Scott Branden <sbranden@broadcom.com> 570M: Scott Branden <sbranden@broadcom.com>
571L: linux-mtd@lists.infradead.org 571L: linux-mtd@lists.infradead.org
572S: Maintained 572S: Maintained
@@ -815,7 +815,7 @@ F: drivers/mmc/host/msm_sdcc.c
815F: drivers/mmc/host/msm_sdcc.h 815F: drivers/mmc/host/msm_sdcc.h
816F: drivers/serial/msm_serial.h 816F: drivers/serial/msm_serial.h
817F: drivers/serial/msm_serial.c 817F: drivers/serial/msm_serial.c
818T: git git://codeaurora.org/quic/kernel/dwalker/linux-msm.git 818T: git git://codeaurora.org/quic/kernel/davidb/linux-msm.git
819S: Maintained 819S: Maintained
820 820
821ARM/TOSA MACHINE SUPPORT 821ARM/TOSA MACHINE SUPPORT
@@ -1359,7 +1359,7 @@ F: include/net/bluetooth/
1359 1359
1360BONDING DRIVER 1360BONDING DRIVER
1361M: Jay Vosburgh <fubar@us.ibm.com> 1361M: Jay Vosburgh <fubar@us.ibm.com>
1362L: bonding-devel@lists.sourceforge.net 1362L: netdev@vger.kernel.org
1363W: http://sourceforge.net/projects/bonding/ 1363W: http://sourceforge.net/projects/bonding/
1364S: Supported 1364S: Supported
1365F: drivers/net/bonding/ 1365F: drivers/net/bonding/
@@ -1829,6 +1829,13 @@ W: http://www.chelsio.com
1829S: Supported 1829S: Supported
1830F: drivers/net/cxgb4vf/ 1830F: drivers/net/cxgb4vf/
1831 1831
1832STMMAC ETHERNET DRIVER
1833M: Giuseppe Cavallaro <peppe.cavallaro@st.com>
1834L: netdev@vger.kernel.org
1835W: http://www.stlinux.com
1836S: Supported
1837F: drivers/net/stmmac/
1838
1832CYBERPRO FB DRIVER 1839CYBERPRO FB DRIVER
1833M: Russell King <linux@arm.linux.org.uk> 1840M: Russell King <linux@arm.linux.org.uk>
1834L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1841L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@ -2008,6 +2015,7 @@ F: drivers/hwmon/dme1737.c
2008DOCBOOK FOR DOCUMENTATION 2015DOCBOOK FOR DOCUMENTATION
2009M: Randy Dunlap <rdunlap@xenotime.net> 2016M: Randy Dunlap <rdunlap@xenotime.net>
2010S: Maintained 2017S: Maintained
2018F: scripts/kernel-doc
2011 2019
2012DOCKING STATION DRIVER 2020DOCKING STATION DRIVER
2013M: Shaohua Li <shaohua.li@intel.com> 2021M: Shaohua Li <shaohua.li@intel.com>
@@ -2018,6 +2026,7 @@ F: drivers/acpi/dock.c
2018DOCUMENTATION 2026DOCUMENTATION
2019M: Randy Dunlap <rdunlap@xenotime.net> 2027M: Randy Dunlap <rdunlap@xenotime.net>
2020L: linux-doc@vger.kernel.org 2028L: linux-doc@vger.kernel.org
2029T: quilt oss.oracle.com/~rdunlap/kernel-doc-patches/current/
2021S: Maintained 2030S: Maintained
2022F: Documentation/ 2031F: Documentation/
2023 2032
@@ -2051,7 +2060,7 @@ F: Documentation/blockdev/drbd/
2051 2060
2052DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS 2061DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS
2053M: Greg Kroah-Hartman <gregkh@suse.de> 2062M: Greg Kroah-Hartman <gregkh@suse.de>
2054T: quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/ 2063T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6.git
2055S: Supported 2064S: Supported
2056F: Documentation/kobject.txt 2065F: Documentation/kobject.txt
2057F: drivers/base/ 2066F: drivers/base/
@@ -2071,7 +2080,7 @@ F: include/drm/
2071 2080
2072INTEL DRM DRIVERS (excluding Poulsbo, Moorestown and derivative chipsets) 2081INTEL DRM DRIVERS (excluding Poulsbo, Moorestown and derivative chipsets)
2073M: Chris Wilson <chris@chris-wilson.co.uk> 2082M: Chris Wilson <chris@chris-wilson.co.uk>
2074L: intel-gfx@lists.freedesktop.org 2083L: intel-gfx@lists.freedesktop.org (subscribers-only)
2075L: dri-devel@lists.freedesktop.org 2084L: dri-devel@lists.freedesktop.org
2076T: git git://git.kernel.org/pub/scm/linux/kernel/git/ickle/drm-intel.git 2085T: git git://git.kernel.org/pub/scm/linux/kernel/git/ickle/drm-intel.git
2077S: Supported 2086S: Supported
@@ -2435,10 +2444,12 @@ F: drivers/net/wan/sdla.c
2435FRAMEBUFFER LAYER 2444FRAMEBUFFER LAYER
2436L: linux-fbdev@vger.kernel.org 2445L: linux-fbdev@vger.kernel.org
2437W: http://linux-fbdev.sourceforge.net/ 2446W: http://linux-fbdev.sourceforge.net/
2447Q: http://patchwork.kernel.org/project/linux-fbdev/list/
2438T: git git://git.kernel.org/pub/scm/linux/kernel/git/lethal/fbdev-2.6.git 2448T: git git://git.kernel.org/pub/scm/linux/kernel/git/lethal/fbdev-2.6.git
2439S: Orphan 2449S: Orphan
2440F: Documentation/fb/ 2450F: Documentation/fb/
2441F: drivers/video/fb* 2451F: drivers/video/
2452F: include/video/
2442F: include/linux/fb.h 2453F: include/linux/fb.h
2443 2454
2444FREESCALE DMA DRIVER 2455FREESCALE DMA DRIVER
@@ -4053,9 +4064,8 @@ F: drivers/scsi/NCR_D700.*
4053 4064
4054NETEFFECT IWARP RNIC DRIVER (IW_NES) 4065NETEFFECT IWARP RNIC DRIVER (IW_NES)
4055M: Faisal Latif <faisal.latif@intel.com> 4066M: Faisal Latif <faisal.latif@intel.com>
4056M: Chien Tung <chien.tin.tung@intel.com>
4057L: linux-rdma@vger.kernel.org 4067L: linux-rdma@vger.kernel.org
4058W: http://www.neteffect.com 4068W: http://www.intel.com/Products/Server/Adapters/Server-Cluster/Server-Cluster-overview.htm
4059S: Supported 4069S: Supported
4060F: drivers/infiniband/hw/nes/ 4070F: drivers/infiniband/hw/nes/
4061 4071
@@ -5828,6 +5838,8 @@ M: Chris Metcalf <cmetcalf@tilera.com>
5828W: http://www.tilera.com/scm/ 5838W: http://www.tilera.com/scm/
5829S: Supported 5839S: Supported
5830F: arch/tile/ 5840F: arch/tile/
5841F: drivers/char/hvc_tile.c
5842F: drivers/net/tile/
5831 5843
5832TLAN NETWORK DRIVER 5844TLAN NETWORK DRIVER
5833M: Samuel Chessman <chessman@tux.org> 5845M: Samuel Chessman <chessman@tux.org>
@@ -5920,7 +5932,6 @@ F: include/linux/tty.h
5920 5932
5921TULIP NETWORK DRIVERS 5933TULIP NETWORK DRIVERS
5922M: Grant Grundler <grundler@parisc-linux.org> 5934M: Grant Grundler <grundler@parisc-linux.org>
5923M: Kyle McMartin <kyle@mcmartin.ca>
5924L: netdev@vger.kernel.org 5935L: netdev@vger.kernel.org
5925S: Maintained 5936S: Maintained
5926F: drivers/net/tulip/ 5937F: drivers/net/tulip/
@@ -6572,6 +6583,15 @@ F: include/linux/mfd/wm8400*
6572F: include/sound/wm????.h 6583F: include/sound/wm????.h
6573F: sound/soc/codecs/wm* 6584F: sound/soc/codecs/wm*
6574 6585
6586WORKQUEUE
6587M: Tejun Heo <tj@kernel.org>
6588L: linux-kernel@vger.kernel.org
6589T: git git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git
6590S: Maintained
6591F: include/linux/workqueue.h
6592F: kernel/workqueue.c
6593F: Documentation/workqueue.txt
6594
6575X.25 NETWORK LAYER 6595X.25 NETWORK LAYER
6576M: Andrew Hendry <andrew.hendry@gmail.com> 6596M: Andrew Hendry <andrew.hendry@gmail.com>
6577L: linux-x25@vger.kernel.org 6597L: linux-x25@vger.kernel.org
diff --git a/Makefile b/Makefile
index ab5359db3d17..77044b7918a5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 37 3SUBLEVEL = 37
4EXTRAVERSION = -rc2 4EXTRAVERSION = -rc7
5NAME = Flesh-Eating Bats with Fangs 5NAME = Flesh-Eating Bats with Fangs
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index db524e75c4a2..d56d21c0573b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -9,7 +9,7 @@ config ARM
9 select GENERIC_ATOMIC64 if (!CPU_32v6K || !AEABI) 9 select GENERIC_ATOMIC64 if (!CPU_32v6K || !AEABI)
10 select HAVE_OPROFILE if (HAVE_PERF_EVENTS) 10 select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
11 select HAVE_ARCH_KGDB 11 select HAVE_ARCH_KGDB
12 select HAVE_KPROBES if (!XIP_KERNEL) 12 select HAVE_KPROBES if (!XIP_KERNEL && !THUMB2_KERNEL)
13 select HAVE_KRETPROBES if (HAVE_KPROBES) 13 select HAVE_KRETPROBES if (HAVE_KPROBES)
14 select HAVE_FUNCTION_TRACER if (!XIP_KERNEL) 14 select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
15 select HAVE_FTRACE_MCOUNT_RECORD if (!XIP_KERNEL) 15 select HAVE_FTRACE_MCOUNT_RECORD if (!XIP_KERNEL)
@@ -1311,7 +1311,7 @@ config HZ
1311 1311
1312config THUMB2_KERNEL 1312config THUMB2_KERNEL
1313 bool "Compile the kernel in Thumb-2 mode" 1313 bool "Compile the kernel in Thumb-2 mode"
1314 depends on CPU_V7 && EXPERIMENTAL 1314 depends on CPU_V7 && !CPU_V6 && EXPERIMENTAL
1315 select AEABI 1315 select AEABI
1316 select ARM_ASM_UNIFIED 1316 select ARM_ASM_UNIFIED
1317 help 1317 help
@@ -1759,7 +1759,7 @@ comment "At least one emulation must be selected"
1759 1759
1760config FPE_NWFPE 1760config FPE_NWFPE
1761 bool "NWFPE math emulation" 1761 bool "NWFPE math emulation"
1762 depends on !AEABI || OABI_COMPAT 1762 depends on (!AEABI || OABI_COMPAT) && !THUMB2_KERNEL
1763 ---help--- 1763 ---help---
1764 Say Y to include the NWFPE floating point emulator in the kernel. 1764 Say Y to include the NWFPE floating point emulator in the kernel.
1765 This is necessary to run most binaries. Linux does not currently 1765 This is necessary to run most binaries. Linux does not currently
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index 4a590f4113e2..4d26f2c52a75 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -70,12 +70,7 @@ else
70$(obj)/uImage: LOADADDR=$(ZRELADDR) 70$(obj)/uImage: LOADADDR=$(ZRELADDR)
71endif 71endif
72 72
73ifeq ($(CONFIG_THUMB2_KERNEL),y)
74# Set bit 0 to 1 so that "mov pc, rx" switches to Thumb-2 mode
75$(obj)/uImage: STARTADDR=$(shell echo $(LOADADDR) | sed -e "s/.$$/1/")
76else
77$(obj)/uImage: STARTADDR=$(LOADADDR) 73$(obj)/uImage: STARTADDR=$(LOADADDR)
78endif
79 74
80$(obj)/uImage: $(obj)/zImage FORCE 75$(obj)/uImage: $(obj)/zImage FORCE
81 $(call if_changed,uimage) 76 $(call if_changed,uimage)
diff --git a/arch/arm/boot/bootp/init.S b/arch/arm/boot/bootp/init.S
index 8b0de41c3dcb..78b508075161 100644
--- a/arch/arm/boot/bootp/init.S
+++ b/arch/arm/boot/bootp/init.S
@@ -73,6 +73,8 @@ move: ldmia r4!, {r7 - r10} @ move 32-bytes at a time
73 73
74 .size _start, . - _start 74 .size _start, . - _start
75 75
76 .align
77
76 .type data,#object 78 .type data,#object
77data: .word initrd_start @ source initrd address 79data: .word initrd_start @ source initrd address
78 .word initrd_phys @ destination initrd address 80 .word initrd_phys @ destination initrd address
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 6825c34646d4..7193884ed8b0 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -125,9 +125,13 @@ wait: mrc p14, 0, pc, c0, c1, 0
125 * sort out different calling conventions 125 * sort out different calling conventions
126 */ 126 */
127 .align 127 .align
128 .arm @ Always enter in ARM state
128start: 129start:
129 .type start,#function 130 .type start,#function
130 .rept 8 131 THUMB( adr r12, BSYM(1f) )
132 THUMB( bx r12 )
133 THUMB( .rept 6 )
134 ARM( .rept 8 )
131 mov r0, r0 135 mov r0, r0
132 .endr 136 .endr
133 137
@@ -135,6 +139,7 @@ start:
135 .word 0x016f2818 @ Magic numbers to help the loader 139 .word 0x016f2818 @ Magic numbers to help the loader
136 .word start @ absolute load/run zImage address 140 .word start @ absolute load/run zImage address
137 .word _edata @ zImage end address 141 .word _edata @ zImage end address
142 THUMB( .thumb )
1381: mov r7, r1 @ save architecture ID 1431: mov r7, r1 @ save architecture ID
139 mov r8, r2 @ save atags pointer 144 mov r8, r2 @ save atags pointer
140 145
@@ -174,7 +179,8 @@ not_angel:
174 ldr sp, [r0, #28] 179 ldr sp, [r0, #28]
175#ifdef CONFIG_AUTO_ZRELADDR 180#ifdef CONFIG_AUTO_ZRELADDR
176 @ determine final kernel image address 181 @ determine final kernel image address
177 and r4, pc, #0xf8000000 182 mov r4, pc
183 and r4, r4, #0xf8000000
178 add r4, r4, #TEXT_OFFSET 184 add r4, r4, #TEXT_OFFSET
179#else 185#else
180 ldr r4, =zreladdr 186 ldr r4, =zreladdr
@@ -445,7 +451,8 @@ __setup_mmu: sub r3, r4, #16384 @ Page directory size
445 */ 451 */
446 mov r1, #0x1e 452 mov r1, #0x1e
447 orr r1, r1, #3 << 10 453 orr r1, r1, #3 << 10
448 mov r2, pc, lsr #20 454 mov r2, pc
455 mov r2, r2, lsr #20
449 orr r1, r1, r2, lsl #20 456 orr r1, r1, r2, lsl #20
450 add r0, r3, r2, lsl #2 457 add r0, r3, r2, lsl #2
451 str r1, [r0], #4 458 str r1, [r0], #4
@@ -1084,6 +1091,6 @@ memdump: mov r12, r0
1084reloc_end: 1091reloc_end:
1085 1092
1086 .align 1093 .align
1087 .section ".stack", "w" 1094 .section ".stack", "aw", %nobits
1088user_stack: .space 4096 1095user_stack: .space 4096
1089user_stack_end: 1096user_stack_end:
diff --git a/arch/arm/boot/compressed/vmlinux.lds.in b/arch/arm/boot/compressed/vmlinux.lds.in
index d08168941bd6..366a924019ac 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.in
+++ b/arch/arm/boot/compressed/vmlinux.lds.in
@@ -57,7 +57,7 @@ SECTIONS
57 .bss : { *(.bss) } 57 .bss : { *(.bss) }
58 _end = .; 58 _end = .;
59 59
60 .stack (NOLOAD) : { *(.stack) } 60 .stack : { *(.stack) }
61 61
62 .stab 0 : { *(.stab) } 62 .stab 0 : { *(.stab) }
63 .stabstr 0 : { *(.stabstr) } 63 .stabstr 0 : { *(.stabstr) }
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index 772f95f1aecd..e6388dcd8cfa 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -146,9 +146,15 @@ static int gic_set_cpu(unsigned int irq, const struct cpumask *mask_val)
146 unsigned int shift = (irq % 4) * 8; 146 unsigned int shift = (irq % 4) * 8;
147 unsigned int cpu = cpumask_first(mask_val); 147 unsigned int cpu = cpumask_first(mask_val);
148 u32 val; 148 u32 val;
149 struct irq_desc *desc;
149 150
150 spin_lock(&irq_controller_lock); 151 spin_lock(&irq_controller_lock);
151 irq_desc[irq].node = cpu; 152 desc = irq_to_desc(irq);
153 if (desc == NULL) {
154 spin_unlock(&irq_controller_lock);
155 return -EINVAL;
156 }
157 desc->node = cpu;
152 val = readl(reg) & ~(0xff << shift); 158 val = readl(reg) & ~(0xff << shift);
153 val |= 1 << (cpu + shift); 159 val |= 1 << (cpu + shift);
154 writel(val, reg); 160 writel(val, reg);
@@ -210,7 +216,7 @@ void __init gic_cascade_irq(unsigned int gic_nr, unsigned int irq)
210void __init gic_dist_init(unsigned int gic_nr, void __iomem *base, 216void __init gic_dist_init(unsigned int gic_nr, void __iomem *base,
211 unsigned int irq_start) 217 unsigned int irq_start)
212{ 218{
213 unsigned int max_irq, i; 219 unsigned int gic_irqs, irq_limit, i;
214 u32 cpumask = 1 << smp_processor_id(); 220 u32 cpumask = 1 << smp_processor_id();
215 221
216 if (gic_nr >= MAX_GIC_NR) 222 if (gic_nr >= MAX_GIC_NR)
@@ -226,47 +232,49 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base,
226 232
227 /* 233 /*
228 * Find out how many interrupts are supported. 234 * Find out how many interrupts are supported.
229 */
230 max_irq = readl(base + GIC_DIST_CTR) & 0x1f;
231 max_irq = (max_irq + 1) * 32;
232
233 /*
234 * The GIC only supports up to 1020 interrupt sources. 235 * The GIC only supports up to 1020 interrupt sources.
235 * Limit this to either the architected maximum, or the
236 * platform maximum.
237 */ 236 */
238 if (max_irq > max(1020, NR_IRQS)) 237 gic_irqs = readl(base + GIC_DIST_CTR) & 0x1f;
239 max_irq = max(1020, NR_IRQS); 238 gic_irqs = (gic_irqs + 1) * 32;
239 if (gic_irqs > 1020)
240 gic_irqs = 1020;
240 241
241 /* 242 /*
242 * Set all global interrupts to be level triggered, active low. 243 * Set all global interrupts to be level triggered, active low.
243 */ 244 */
244 for (i = 32; i < max_irq; i += 16) 245 for (i = 32; i < gic_irqs; i += 16)
245 writel(0, base + GIC_DIST_CONFIG + i * 4 / 16); 246 writel(0, base + GIC_DIST_CONFIG + i * 4 / 16);
246 247
247 /* 248 /*
248 * Set all global interrupts to this CPU only. 249 * Set all global interrupts to this CPU only.
249 */ 250 */
250 for (i = 32; i < max_irq; i += 4) 251 for (i = 32; i < gic_irqs; i += 4)
251 writel(cpumask, base + GIC_DIST_TARGET + i * 4 / 4); 252 writel(cpumask, base + GIC_DIST_TARGET + i * 4 / 4);
252 253
253 /* 254 /*
254 * Set priority on all global interrupts. 255 * Set priority on all global interrupts.
255 */ 256 */
256 for (i = 32; i < max_irq; i += 4) 257 for (i = 32; i < gic_irqs; i += 4)
257 writel(0xa0a0a0a0, base + GIC_DIST_PRI + i * 4 / 4); 258 writel(0xa0a0a0a0, base + GIC_DIST_PRI + i * 4 / 4);
258 259
259 /* 260 /*
260 * Disable all interrupts. Leave the PPI and SGIs alone 261 * Disable all interrupts. Leave the PPI and SGIs alone
261 * as these enables are banked registers. 262 * as these enables are banked registers.
262 */ 263 */
263 for (i = 32; i < max_irq; i += 32) 264 for (i = 32; i < gic_irqs; i += 32)
264 writel(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i * 4 / 32); 265 writel(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i * 4 / 32);
265 266
266 /* 267 /*
268 * Limit number of interrupts registered to the platform maximum
269 */
270 irq_limit = gic_data[gic_nr].irq_offset + gic_irqs;
271 if (WARN_ON(irq_limit > NR_IRQS))
272 irq_limit = NR_IRQS;
273
274 /*
267 * Setup the Linux IRQ subsystem. 275 * Setup the Linux IRQ subsystem.
268 */ 276 */
269 for (i = irq_start; i < gic_data[gic_nr].irq_offset + max_irq; i++) { 277 for (i = irq_start; i < irq_limit; i++) {
270 set_irq_chip(i, &gic_chip); 278 set_irq_chip(i, &gic_chip);
271 set_irq_chip_data(i, &gic_data[gic_nr]); 279 set_irq_chip_data(i, &gic_data[gic_nr]);
272 set_irq_handler(i, handle_level_irq); 280 set_irq_handler(i, handle_level_irq);
diff --git a/arch/arm/configs/at91rm9200_defconfig b/arch/arm/configs/at91rm9200_defconfig
new file mode 100644
index 000000000000..38cb7c985426
--- /dev/null
+++ b/arch/arm/configs/at91rm9200_defconfig
@@ -0,0 +1,341 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set
3# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y
5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y
7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y
10CONFIG_MODULES=y
11CONFIG_MODULE_FORCE_LOAD=y
12CONFIG_MODULE_UNLOAD=y
13CONFIG_MODVERSIONS=y
14CONFIG_MODULE_SRCVERSION_ALL=y
15# CONFIG_BLK_DEV_BSG is not set
16# CONFIG_IOSCHED_CFQ is not set
17CONFIG_ARCH_AT91=y
18CONFIG_MACH_ONEARM=y
19CONFIG_ARCH_AT91RM9200DK=y
20CONFIG_MACH_AT91RM9200EK=y
21CONFIG_MACH_CSB337=y
22CONFIG_MACH_CSB637=y
23CONFIG_MACH_CARMEVA=y
24CONFIG_MACH_ATEB9200=y
25CONFIG_MACH_KB9200=y
26CONFIG_MACH_PICOTUX2XX=y
27CONFIG_MACH_KAFA=y
28CONFIG_MACH_ECBAT91=y
29CONFIG_MACH_YL9200=y
30CONFIG_MACH_CPUAT91=y
31CONFIG_MACH_ECO920=y
32CONFIG_MTD_AT91_DATAFLASH_CARD=y
33CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
34CONFIG_AT91_TIMER_HZ=100
35# CONFIG_ARM_THUMB is not set
36CONFIG_PCCARD=y
37CONFIG_AT91_CF=y
38CONFIG_NO_HZ=y
39CONFIG_HIGH_RES_TIMERS=y
40CONFIG_PREEMPT=y
41CONFIG_AEABI=y
42CONFIG_LEDS=y
43CONFIG_LEDS_CPU=y
44CONFIG_ZBOOT_ROM_TEXT=0x10000000
45CONFIG_ZBOOT_ROM_BSS=0x20040000
46CONFIG_KEXEC=y
47CONFIG_FPE_NWFPE=y
48CONFIG_BINFMT_MISC=y
49CONFIG_NET=y
50CONFIG_PACKET=y
51CONFIG_UNIX=y
52CONFIG_XFRM_USER=m
53CONFIG_INET=y
54CONFIG_IP_MULTICAST=y
55CONFIG_IP_PNP=y
56CONFIG_IP_PNP_DHCP=y
57CONFIG_IP_PNP_BOOTP=y
58CONFIG_NET_IPIP=m
59CONFIG_NET_IPGRE=m
60CONFIG_INET_AH=m
61CONFIG_INET_ESP=m
62CONFIG_INET_IPCOMP=m
63CONFIG_INET_XFRM_MODE_TRANSPORT=m
64CONFIG_INET_XFRM_MODE_TUNNEL=m
65CONFIG_INET_XFRM_MODE_BEET=m
66CONFIG_IPV6_PRIVACY=y
67CONFIG_IPV6_ROUTER_PREF=y
68CONFIG_IPV6_ROUTE_INFO=y
69CONFIG_INET6_AH=m
70CONFIG_INET6_ESP=m
71CONFIG_INET6_IPCOMP=m
72CONFIG_IPV6_MIP6=m
73CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
74CONFIG_IPV6_TUNNEL=m
75CONFIG_BRIDGE=m
76CONFIG_VLAN_8021Q=m
77CONFIG_BT=m
78CONFIG_BT_L2CAP=m
79CONFIG_BT_SCO=m
80CONFIG_BT_RFCOMM=m
81CONFIG_BT_RFCOMM_TTY=y
82CONFIG_BT_BNEP=m
83CONFIG_BT_BNEP_MC_FILTER=y
84CONFIG_BT_BNEP_PROTO_FILTER=y
85CONFIG_BT_HIDP=m
86CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
87CONFIG_MTD=y
88CONFIG_MTD_CONCAT=y
89CONFIG_MTD_PARTITIONS=y
90CONFIG_MTD_CMDLINE_PARTS=y
91CONFIG_MTD_AFS_PARTS=y
92CONFIG_MTD_CHAR=y
93CONFIG_MTD_BLOCK=y
94CONFIG_MTD_CFI=y
95CONFIG_MTD_JEDECPROBE=y
96CONFIG_MTD_CFI_INTELEXT=y
97CONFIG_MTD_CFI_AMDSTD=y
98CONFIG_MTD_COMPLEX_MAPPINGS=y
99CONFIG_MTD_PHYSMAP=y
100CONFIG_MTD_PLATRAM=y
101CONFIG_MTD_DATAFLASH=y
102CONFIG_MTD_NAND=y
103CONFIG_MTD_NAND_ATMEL=y
104CONFIG_MTD_NAND_PLATFORM=y
105CONFIG_MTD_UBI=y
106CONFIG_MTD_UBI_GLUEBI=y
107CONFIG_BLK_DEV_LOOP=y
108CONFIG_BLK_DEV_NBD=y
109CONFIG_BLK_DEV_RAM=y
110CONFIG_BLK_DEV_RAM_SIZE=8192
111CONFIG_ATMEL_TCLIB=y
112CONFIG_EEPROM_LEGACY=m
113CONFIG_SCSI=y
114CONFIG_BLK_DEV_SD=y
115CONFIG_BLK_DEV_SR=m
116CONFIG_BLK_DEV_SR_VENDOR=y
117CONFIG_CHR_DEV_SG=m
118CONFIG_SCSI_MULTI_LUN=y
119# CONFIG_SCSI_LOWLEVEL is not set
120CONFIG_NETDEVICES=y
121CONFIG_TUN=m
122CONFIG_PHYLIB=y
123CONFIG_DAVICOM_PHY=y
124CONFIG_SMSC_PHY=y
125CONFIG_MICREL_PHY=y
126CONFIG_NET_ETHERNET=y
127CONFIG_ARM_AT91_ETHER=y
128# CONFIG_NETDEV_1000 is not set
129# CONFIG_NETDEV_10000 is not set
130CONFIG_USB_CATC=m
131CONFIG_USB_KAWETH=m
132CONFIG_USB_PEGASUS=m
133CONFIG_USB_RTL8150=m
134CONFIG_USB_USBNET=m
135CONFIG_USB_NET_DM9601=m
136CONFIG_USB_NET_GL620A=m
137CONFIG_USB_NET_PLUSB=m
138CONFIG_USB_NET_RNDIS_HOST=m
139CONFIG_USB_ALI_M5632=y
140CONFIG_USB_AN2720=y
141CONFIG_USB_EPSON2888=y
142CONFIG_PPP=y
143CONFIG_PPP_MULTILINK=y
144CONFIG_PPP_FILTER=y
145CONFIG_PPP_ASYNC=y
146CONFIG_PPP_DEFLATE=y
147CONFIG_PPP_BSDCOMP=y
148CONFIG_PPP_MPPE=m
149CONFIG_PPPOE=m
150CONFIG_SLIP=m
151CONFIG_SLIP_COMPRESSED=y
152CONFIG_SLIP_SMART=y
153CONFIG_SLIP_MODE_SLIP6=y
154# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
155CONFIG_INPUT_MOUSEDEV_SCREEN_X=640
156CONFIG_INPUT_MOUSEDEV_SCREEN_Y=480
157CONFIG_INPUT_EVDEV=y
158CONFIG_KEYBOARD_GPIO=y
159# CONFIG_INPUT_MOUSE is not set
160CONFIG_INPUT_TOUCHSCREEN=y
161CONFIG_SERIAL_ATMEL=y
162CONFIG_SERIAL_ATMEL_CONSOLE=y
163CONFIG_LEGACY_PTY_COUNT=32
164CONFIG_HW_RANDOM=y
165CONFIG_I2C=y
166CONFIG_I2C_CHARDEV=y
167CONFIG_I2C_GPIO=y
168CONFIG_SPI=y
169CONFIG_SPI_ATMEL=y
170CONFIG_SPI_BITBANG=y
171CONFIG_GPIO_SYSFS=y
172CONFIG_HWMON=m
173CONFIG_SENSORS_ADM1021=m
174CONFIG_SENSORS_ADM1025=m
175CONFIG_SENSORS_ADM1026=m
176CONFIG_SENSORS_ADM1029=m
177CONFIG_SENSORS_ADM1031=m
178CONFIG_SENSORS_ADM9240=m
179CONFIG_SENSORS_DS1621=m
180CONFIG_SENSORS_GL518SM=m
181CONFIG_SENSORS_GL520SM=m
182CONFIG_SENSORS_IT87=m
183CONFIG_SENSORS_LM63=m
184CONFIG_SENSORS_LM73=m
185CONFIG_SENSORS_LM75=m
186CONFIG_SENSORS_LM77=m
187CONFIG_SENSORS_LM78=m
188CONFIG_SENSORS_LM80=m
189CONFIG_SENSORS_LM83=m
190CONFIG_SENSORS_LM85=m
191CONFIG_SENSORS_LM87=m
192CONFIG_SENSORS_LM90=m
193CONFIG_SENSORS_LM92=m
194CONFIG_SENSORS_MAX1619=m
195CONFIG_SENSORS_PCF8591=m
196CONFIG_SENSORS_SMSC47B397=m
197CONFIG_SENSORS_W83781D=m
198CONFIG_SENSORS_W83791D=m
199CONFIG_SENSORS_W83792D=m
200CONFIG_SENSORS_W83793=m
201CONFIG_SENSORS_W83L785TS=m
202CONFIG_WATCHDOG=y
203CONFIG_WATCHDOG_NOWAYOUT=y
204CONFIG_AT91RM9200_WATCHDOG=y
205CONFIG_FB=y
206CONFIG_FB_MODE_HELPERS=y
207CONFIG_FB_TILEBLITTING=y
208CONFIG_FB_S1D13XXX=y
209CONFIG_BACKLIGHT_LCD_SUPPORT=y
210CONFIG_LCD_CLASS_DEVICE=y
211CONFIG_BACKLIGHT_CLASS_DEVICE=y
212# CONFIG_BACKLIGHT_GENERIC is not set
213CONFIG_DISPLAY_SUPPORT=y
214CONFIG_FRAMEBUFFER_CONSOLE=y
215CONFIG_FONTS=y
216CONFIG_FONT_MINI_4x6=y
217CONFIG_LOGO=y
218# CONFIG_LOGO_LINUX_MONO is not set
219# CONFIG_LOGO_LINUX_VGA16 is not set
220CONFIG_USB=y
221CONFIG_USB_DEVICEFS=y
222# CONFIG_USB_DEVICE_CLASS is not set
223CONFIG_USB_MON=y
224CONFIG_USB_OHCI_HCD=y
225CONFIG_USB_ACM=m
226CONFIG_USB_PRINTER=m
227CONFIG_USB_STORAGE=y
228CONFIG_USB_SERIAL=y
229CONFIG_USB_SERIAL_CONSOLE=y
230CONFIG_USB_SERIAL_GENERIC=y
231CONFIG_USB_SERIAL_FTDI_SIO=y
232CONFIG_USB_SERIAL_KEYSPAN=y
233CONFIG_USB_SERIAL_KEYSPAN_MPR=y
234CONFIG_USB_SERIAL_KEYSPAN_USA28=y
235CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
236CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
237CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
238CONFIG_USB_SERIAL_KEYSPAN_USA19=y
239CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
240CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
241CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
242CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
243CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
244CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
245CONFIG_USB_SERIAL_MCT_U232=y
246CONFIG_USB_SERIAL_PL2303=y
247CONFIG_USB_GADGET=y
248CONFIG_USB_ETH=m
249CONFIG_USB_MASS_STORAGE=m
250CONFIG_MMC=y
251CONFIG_MMC_AT91=y
252CONFIG_NEW_LEDS=y
253CONFIG_LEDS_CLASS=y
254CONFIG_LEDS_GPIO=y
255CONFIG_LEDS_TRIGGERS=y
256CONFIG_LEDS_TRIGGER_TIMER=y
257CONFIG_LEDS_TRIGGER_HEARTBEAT=y
258CONFIG_LEDS_TRIGGER_GPIO=y
259CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
260CONFIG_RTC_CLASS=y
261# CONFIG_RTC_HCTOSYS is not set
262CONFIG_RTC_DRV_DS1307=y
263CONFIG_RTC_DRV_PCF8563=y
264CONFIG_RTC_DRV_AT91RM9200=y
265CONFIG_EXT2_FS=y
266CONFIG_EXT2_FS_XATTR=y
267CONFIG_EXT3_FS=y
268# CONFIG_EXT3_FS_XATTR is not set
269CONFIG_REISERFS_FS=y
270CONFIG_AUTOFS4_FS=y
271CONFIG_ISO9660_FS=y
272CONFIG_JOLIET=y
273CONFIG_ZISOFS=y
274CONFIG_UDF_FS=y
275CONFIG_MSDOS_FS=y
276CONFIG_VFAT_FS=y
277CONFIG_NTFS_FS=m
278CONFIG_TMPFS=y
279CONFIG_CONFIGFS_FS=y
280CONFIG_JFFS2_FS=y
281CONFIG_JFFS2_SUMMARY=y
282CONFIG_JFFS2_COMPRESSION_OPTIONS=y
283CONFIG_JFFS2_LZO=y
284CONFIG_JFFS2_RUBIN=y
285CONFIG_CRAMFS=y
286CONFIG_MINIX_FS=y
287CONFIG_NFS_FS=y
288CONFIG_NFS_V3=y
289CONFIG_NFS_V3_ACL=y
290CONFIG_NFS_V4=y
291CONFIG_ROOT_NFS=y
292CONFIG_NFSD=y
293CONFIG_SMB_FS=m
294CONFIG_CIFS=m
295CONFIG_PARTITION_ADVANCED=y
296CONFIG_MAC_PARTITION=y
297CONFIG_NLS_CODEPAGE_437=y
298CONFIG_NLS_CODEPAGE_737=m
299CONFIG_NLS_CODEPAGE_775=m
300CONFIG_NLS_CODEPAGE_850=m
301CONFIG_NLS_CODEPAGE_852=m
302CONFIG_NLS_CODEPAGE_855=m
303CONFIG_NLS_CODEPAGE_857=m
304CONFIG_NLS_CODEPAGE_860=m
305CONFIG_NLS_CODEPAGE_861=m
306CONFIG_NLS_CODEPAGE_862=m
307CONFIG_NLS_CODEPAGE_863=m
308CONFIG_NLS_CODEPAGE_864=m
309CONFIG_NLS_CODEPAGE_865=m
310CONFIG_NLS_CODEPAGE_866=m
311CONFIG_NLS_CODEPAGE_869=m
312CONFIG_NLS_CODEPAGE_936=m
313CONFIG_NLS_CODEPAGE_950=m
314CONFIG_NLS_CODEPAGE_932=m
315CONFIG_NLS_CODEPAGE_949=m
316CONFIG_NLS_CODEPAGE_874=m
317CONFIG_NLS_ISO8859_8=m
318CONFIG_NLS_CODEPAGE_1250=m
319CONFIG_NLS_CODEPAGE_1251=m
320CONFIG_NLS_ASCII=m
321CONFIG_NLS_ISO8859_1=y
322CONFIG_NLS_ISO8859_2=m
323CONFIG_NLS_ISO8859_3=m
324CONFIG_NLS_ISO8859_4=m
325CONFIG_NLS_ISO8859_5=m
326CONFIG_NLS_ISO8859_6=m
327CONFIG_NLS_ISO8859_7=m
328CONFIG_NLS_ISO8859_9=m
329CONFIG_NLS_ISO8859_13=m
330CONFIG_NLS_ISO8859_14=m
331CONFIG_NLS_ISO8859_15=m
332CONFIG_NLS_KOI8_R=m
333CONFIG_NLS_KOI8_U=m
334CONFIG_NLS_UTF8=y
335CONFIG_MAGIC_SYSRQ=y
336CONFIG_DEBUG_FS=y
337CONFIG_DEBUG_KERNEL=y
338# CONFIG_RCU_CPU_STALL_DETECTOR is not set
339# CONFIG_FTRACE is not set
340CONFIG_CRYPTO_PCBC=y
341CONFIG_CRYPTO_SHA1=y
diff --git a/arch/arm/configs/at91rm9200dk_defconfig b/arch/arm/configs/at91rm9200dk_defconfig
deleted file mode 100644
index 4438e64f3bfb..000000000000
--- a/arch/arm/configs/at91rm9200dk_defconfig
+++ /dev/null
@@ -1,72 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y
4CONFIG_LOG_BUF_SHIFT=14
5CONFIG_BLK_DEV_INITRD=y
6CONFIG_MODULES=y
7CONFIG_MODULE_UNLOAD=y
8# CONFIG_IOSCHED_DEADLINE is not set
9# CONFIG_IOSCHED_CFQ is not set
10CONFIG_ARCH_AT91=y
11CONFIG_ARCH_AT91RM9200DK=y
12CONFIG_MACH_ECO920=y
13CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
14# CONFIG_ARM_THUMB is not set
15CONFIG_PCCARD=y
16CONFIG_AT91_CF=y
17CONFIG_LEDS=y
18CONFIG_ZBOOT_ROM_TEXT=0x0
19CONFIG_ZBOOT_ROM_BSS=0x0
20CONFIG_CMDLINE="mem=32M console=ttyS0,115200 initrd=0x20410000,3145728 root=/dev/ram0 rw"
21CONFIG_FPE_NWFPE=y
22CONFIG_NET=y
23CONFIG_PACKET=y
24CONFIG_UNIX=y
25CONFIG_INET=y
26CONFIG_IP_PNP=y
27CONFIG_IP_PNP_BOOTP=y
28# CONFIG_IPV6 is not set
29CONFIG_MTD=y
30CONFIG_MTD_PARTITIONS=y
31CONFIG_MTD_CMDLINE_PARTS=y
32CONFIG_MTD_CHAR=y
33CONFIG_MTD_BLOCK=y
34CONFIG_MTD_CFI=y
35CONFIG_MTD_JEDECPROBE=y
36CONFIG_MTD_CFI_AMDSTD=y
37CONFIG_MTD_PHYSMAP=y
38CONFIG_BLK_DEV_RAM=y
39CONFIG_BLK_DEV_RAM_SIZE=8192
40CONFIG_NETDEVICES=y
41CONFIG_NET_ETHERNET=y
42CONFIG_ARM_AT91_ETHER=y
43# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
44# CONFIG_INPUT_KEYBOARD is not set
45# CONFIG_INPUT_MOUSE is not set
46# CONFIG_SERIO is not set
47CONFIG_SERIAL_ATMEL=y
48CONFIG_SERIAL_ATMEL_CONSOLE=y
49CONFIG_I2C=y
50CONFIG_I2C_CHARDEV=y
51CONFIG_I2C_GPIO=y
52CONFIG_WATCHDOG=y
53CONFIG_WATCHDOG_NOWAYOUT=y
54CONFIG_AT91RM9200_WATCHDOG=y
55# CONFIG_VGA_CONSOLE is not set
56# CONFIG_USB_HID is not set
57CONFIG_USB=y
58CONFIG_USB_DEBUG=y
59CONFIG_USB_DEVICEFS=y
60CONFIG_USB_MON=y
61CONFIG_USB_OHCI_HCD=y
62CONFIG_USB_GADGET=y
63CONFIG_MMC=y
64CONFIG_RTC_CLASS=y
65CONFIG_RTC_DRV_AT91RM9200=y
66CONFIG_EXT2_FS=y
67CONFIG_INOTIFY=y
68CONFIG_TMPFS=y
69CONFIG_CRAMFS=y
70CONFIG_DEBUG_KERNEL=y
71CONFIG_DEBUG_USER=y
72CONFIG_DEBUG_LL=y
diff --git a/arch/arm/configs/at91rm9200ek_defconfig b/arch/arm/configs/at91rm9200ek_defconfig
deleted file mode 100644
index ccd517c64bc7..000000000000
--- a/arch/arm/configs/at91rm9200ek_defconfig
+++ /dev/null
@@ -1,73 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set
3# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_BLK_DEV_INITRD=y
7CONFIG_MODULES=y
8CONFIG_MODULE_UNLOAD=y
9# CONFIG_IOSCHED_DEADLINE is not set
10# CONFIG_IOSCHED_CFQ is not set
11CONFIG_ARCH_AT91=y
12CONFIG_MACH_AT91RM9200EK=y
13CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
14# CONFIG_ARM_THUMB is not set
15CONFIG_LEDS=y
16CONFIG_LEDS_CPU=y
17CONFIG_ZBOOT_ROM_TEXT=0x0
18CONFIG_ZBOOT_ROM_BSS=0x0
19CONFIG_CMDLINE="mem=32M console=ttyS0,115200 initrd=0x20410000,3145728 root=/dev/ram0 rw"
20CONFIG_FPE_NWFPE=y
21CONFIG_NET=y
22CONFIG_PACKET=y
23CONFIG_UNIX=y
24CONFIG_INET=y
25CONFIG_IP_PNP=y
26CONFIG_IP_PNP_BOOTP=y
27# CONFIG_IPV6 is not set
28CONFIG_MTD=y
29CONFIG_MTD_PARTITIONS=y
30CONFIG_MTD_CMDLINE_PARTS=y
31CONFIG_MTD_CHAR=y
32CONFIG_MTD_BLOCK=y
33CONFIG_MTD_CFI=y
34CONFIG_MTD_JEDECPROBE=y
35CONFIG_MTD_CFI_AMDSTD=y
36CONFIG_MTD_PHYSMAP=y
37CONFIG_BLK_DEV_RAM=y
38CONFIG_BLK_DEV_RAM_SIZE=8192
39CONFIG_NETDEVICES=y
40CONFIG_NET_ETHERNET=y
41CONFIG_ARM_AT91_ETHER=y
42# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
43# CONFIG_INPUT_KEYBOARD is not set
44# CONFIG_INPUT_MOUSE is not set
45# CONFIG_SERIO is not set
46CONFIG_SERIAL_ATMEL=y
47CONFIG_SERIAL_ATMEL_CONSOLE=y
48CONFIG_I2C=y
49CONFIG_I2C_CHARDEV=y
50CONFIG_I2C_GPIO=y
51CONFIG_WATCHDOG=y
52CONFIG_WATCHDOG_NOWAYOUT=y
53CONFIG_AT91RM9200_WATCHDOG=y
54CONFIG_FB=y
55CONFIG_FB_S1D13XXX=y
56# CONFIG_VGA_CONSOLE is not set
57# CONFIG_USB_HID is not set
58CONFIG_USB=y
59CONFIG_USB_DEBUG=y
60CONFIG_USB_DEVICEFS=y
61CONFIG_USB_MON=y
62CONFIG_USB_OHCI_HCD=y
63CONFIG_USB_GADGET=y
64CONFIG_MMC=y
65CONFIG_RTC_CLASS=y
66CONFIG_RTC_DRV_AT91RM9200=y
67CONFIG_EXT2_FS=y
68CONFIG_INOTIFY=y
69CONFIG_TMPFS=y
70CONFIG_CRAMFS=y
71CONFIG_DEBUG_KERNEL=y
72CONFIG_DEBUG_USER=y
73CONFIG_DEBUG_LL=y
diff --git a/arch/arm/configs/ateb9200_defconfig b/arch/arm/configs/ateb9200_defconfig
deleted file mode 100644
index 1b0e9a1689bb..000000000000
--- a/arch/arm/configs/ateb9200_defconfig
+++ /dev/null
@@ -1,131 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_EMBEDDED=y
5CONFIG_SLAB=y
6CONFIG_PROFILING=y
7CONFIG_OPROFILE=m
8CONFIG_MODULES=y
9CONFIG_MODULE_UNLOAD=y
10CONFIG_ARCH_AT91=y
11CONFIG_MACH_ATEB9200=y
12CONFIG_PCCARD=m
13CONFIG_AT91_CF=m
14CONFIG_PREEMPT=y
15CONFIG_ZBOOT_ROM_TEXT=0x0
16CONFIG_ZBOOT_ROM_BSS=0x0
17CONFIG_FPE_NWFPE=y
18CONFIG_PM=y
19CONFIG_NET=y
20CONFIG_PACKET=y
21CONFIG_UNIX=y
22CONFIG_NET_KEY=y
23CONFIG_INET=y
24# CONFIG_IPV6 is not set
25CONFIG_BRIDGE=m
26CONFIG_VLAN_8021Q=m
27CONFIG_MTD=y
28CONFIG_MTD_PARTITIONS=y
29CONFIG_MTD_CMDLINE_PARTS=y
30CONFIG_MTD_CHAR=y
31CONFIG_MTD_BLOCK_RO=y
32CONFIG_BLK_DEV_LOOP=m
33CONFIG_BLK_DEV_NBD=m
34CONFIG_SCSI=m
35CONFIG_BLK_DEV_SD=m
36CONFIG_BLK_DEV_SR=m
37CONFIG_BLK_DEV_SR_VENDOR=y
38CONFIG_CHR_DEV_SG=m
39CONFIG_SCSI_MULTI_LUN=y
40CONFIG_NETDEVICES=y
41CONFIG_DUMMY=m
42CONFIG_TUN=m
43CONFIG_PHYLIB=y
44CONFIG_DAVICOM_PHY=y
45CONFIG_NET_ETHERNET=y
46CONFIG_ARM_AT91_ETHER=y
47CONFIG_USB_USBNET=y
48CONFIG_USB_NET_GL620A=y
49CONFIG_USB_NET_PLUSB=y
50CONFIG_USB_NET_RNDIS_HOST=y
51CONFIG_USB_ALI_M5632=y
52CONFIG_USB_AN2720=y
53CONFIG_USB_EPSON2888=y
54CONFIG_PPP=m
55CONFIG_PPP_ASYNC=m
56CONFIG_PPP_SYNC_TTY=m
57CONFIG_PPP_DEFLATE=m
58CONFIG_PPP_BSDCOMP=m
59CONFIG_PPPOE=m
60CONFIG_SERIAL_ATMEL=y
61CONFIG_SERIAL_ATMEL_CONSOLE=y
62CONFIG_I2C=m
63CONFIG_I2C_CHARDEV=m
64CONFIG_I2C_GPIO=m
65# CONFIG_VGA_CONSOLE is not set
66CONFIG_SOUND=y
67CONFIG_USB_HID=m
68CONFIG_HID_PID=y
69CONFIG_USB_HIDDEV=y
70CONFIG_USB=y
71CONFIG_USB_DEVICEFS=y
72CONFIG_USB_MON=y
73CONFIG_USB_OHCI_HCD=y
74CONFIG_USB_ACM=m
75CONFIG_USB_PRINTER=m
76CONFIG_USB_STORAGE=m
77CONFIG_USB_STORAGE_DATAFAB=m
78CONFIG_USB_STORAGE_FREECOM=m
79CONFIG_USB_STORAGE_USBAT=m
80CONFIG_USB_STORAGE_SDDR09=m
81CONFIG_USB_STORAGE_SDDR55=m
82CONFIG_USB_STORAGE_JUMPSHOT=m
83CONFIG_USB_SERIAL=m
84CONFIG_USB_SERIAL_GENERIC=y
85CONFIG_USB_SERIAL_FTDI_SIO=m
86CONFIG_USB_SERIAL_PL2303=m
87CONFIG_USB_GADGET=m
88CONFIG_USB_ETH=m
89CONFIG_USB_GADGETFS=m
90CONFIG_USB_FILE_STORAGE=m
91CONFIG_USB_G_SERIAL=m
92CONFIG_MMC=m
93CONFIG_MMC_DEBUG=y
94CONFIG_RTC_CLASS=y
95# CONFIG_RTC_HCTOSYS is not set
96CONFIG_RTC_DRV_AT91RM9200=y
97CONFIG_EXT2_FS=m
98CONFIG_EXT3_FS=m
99CONFIG_REISERFS_FS=m
100CONFIG_INOTIFY=y
101CONFIG_ISO9660_FS=m
102CONFIG_JOLIET=y
103CONFIG_ZISOFS=y
104CONFIG_UDF_FS=m
105CONFIG_MSDOS_FS=m
106CONFIG_VFAT_FS=m
107CONFIG_NTFS_FS=m
108CONFIG_NTFS_RW=y
109CONFIG_TMPFS=y
110CONFIG_CRAMFS=y
111CONFIG_NFS_FS=m
112CONFIG_NFS_V3=y
113CONFIG_NFS_V3_ACL=y
114CONFIG_NFS_V4=y
115CONFIG_NFSD=m
116CONFIG_NFSD_V4=y
117CONFIG_PARTITION_ADVANCED=y
118CONFIG_MAC_PARTITION=y
119CONFIG_BSD_DISKLABEL=y
120CONFIG_MINIX_SUBPARTITION=y
121CONFIG_SOLARIS_X86_PARTITION=y
122CONFIG_UNIXWARE_DISKLABEL=y
123CONFIG_NLS_CODEPAGE_932=m
124CONFIG_NLS_ASCII=m
125CONFIG_NLS_ISO8859_15=m
126CONFIG_NLS_UTF8=m
127CONFIG_CRYPTO_MD5=y
128CONFIG_CRYPTO_MICHAEL_MIC=m
129CONFIG_CRYPTO_ARC4=m
130CONFIG_CRC16=m
131CONFIG_LIBCRC32C=m
diff --git a/arch/arm/configs/carmeva_defconfig b/arch/arm/configs/carmeva_defconfig
deleted file mode 100644
index ac64dbd8a49c..000000000000
--- a/arch/arm/configs/carmeva_defconfig
+++ /dev/null
@@ -1,47 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_LOG_BUF_SHIFT=14
3CONFIG_BLK_DEV_INITRD=y
4CONFIG_EMBEDDED=y
5# CONFIG_HOTPLUG is not set
6CONFIG_MODULES=y
7CONFIG_MODULE_UNLOAD=y
8CONFIG_MODULE_FORCE_UNLOAD=y
9CONFIG_ARCH_AT91=y
10CONFIG_MACH_CARMEVA=y
11CONFIG_ZBOOT_ROM_TEXT=0x0
12CONFIG_ZBOOT_ROM_BSS=0x0
13CONFIG_FPE_NWFPE=y
14CONFIG_NET=y
15CONFIG_UNIX=y
16CONFIG_INET=y
17CONFIG_IP_MULTICAST=y
18CONFIG_IP_PNP=y
19# CONFIG_IPV6 is not set
20CONFIG_MTD=y
21CONFIG_MTD_PARTITIONS=y
22CONFIG_MTD_CMDLINE_PARTS=y
23CONFIG_MTD_CHAR=y
24CONFIG_MTD_BLOCK=y
25CONFIG_BLK_DEV_RAM=y
26CONFIG_NETDEVICES=y
27CONFIG_NET_ETHERNET=y
28CONFIG_ARM_AT91_ETHER=y
29# CONFIG_INPUT_MOUSEDEV is not set
30# CONFIG_INPUT_KEYBOARD is not set
31# CONFIG_INPUT_MOUSE is not set
32CONFIG_SERIO=m
33CONFIG_SERIAL_ATMEL=y
34CONFIG_SERIAL_ATMEL_CONSOLE=y
35# CONFIG_VGA_CONSOLE is not set
36CONFIG_MMC=m
37CONFIG_MMC_DEBUG=y
38CONFIG_EXT2_FS=y
39CONFIG_EXT2_FS_XATTR=y
40# CONFIG_DNOTIFY is not set
41CONFIG_JFFS2_FS=y
42CONFIG_JFFS2_COMPRESSION_OPTIONS=y
43CONFIG_NFS_FS=y
44CONFIG_NFS_V3=y
45CONFIG_NFS_V4=y
46CONFIG_ROOT_NFS=y
47CONFIG_NFSD=y
diff --git a/arch/arm/configs/cpuat91_defconfig b/arch/arm/configs/cpuat91_defconfig
deleted file mode 100644
index 022aeb55b676..000000000000
--- a/arch/arm/configs/cpuat91_defconfig
+++ /dev/null
@@ -1,112 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set
3# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7CONFIG_MODULES=y
8CONFIG_MODULE_UNLOAD=y
9# CONFIG_BLK_DEV_BSG is not set
10# CONFIG_IOSCHED_CFQ is not set
11CONFIG_ARCH_AT91=y
12CONFIG_MACH_CPUAT91=y
13CONFIG_AT91_TIMER_HZ=100
14# CONFIG_ARM_THUMB is not set
15CONFIG_PREEMPT=y
16CONFIG_ZBOOT_ROM_TEXT=0x0
17CONFIG_ZBOOT_ROM_BSS=0x0
18CONFIG_NET=y
19CONFIG_PACKET=y
20CONFIG_UNIX=y
21CONFIG_INET=y
22CONFIG_IP_PNP=y
23# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
24# CONFIG_INET_XFRM_MODE_TUNNEL is not set
25# CONFIG_INET_XFRM_MODE_BEET is not set
26# CONFIG_IPV6 is not set
27CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
28CONFIG_MTD=y
29CONFIG_MTD_PARTITIONS=y
30CONFIG_MTD_CMDLINE_PARTS=y
31CONFIG_MTD_CHAR=y
32CONFIG_MTD_BLOCK=y
33CONFIG_MTD_CFI=y
34CONFIG_MTD_CFI_INTELEXT=y
35CONFIG_MTD_PHYSMAP=y
36CONFIG_MTD_PLATRAM=y
37CONFIG_BLK_DEV_LOOP=y
38CONFIG_BLK_DEV_NBD=y
39CONFIG_BLK_DEV_RAM=y
40# CONFIG_MISC_DEVICES is not set
41CONFIG_SCSI=y
42CONFIG_BLK_DEV_SD=y
43CONFIG_SCSI_MULTI_LUN=y
44# CONFIG_SCSI_LOWLEVEL is not set
45CONFIG_NETDEVICES=y
46CONFIG_PHYLIB=y
47CONFIG_NET_ETHERNET=y
48CONFIG_ARM_AT91_ETHER=y
49# CONFIG_NETDEV_1000 is not set
50# CONFIG_NETDEV_10000 is not set
51CONFIG_PPP=y
52CONFIG_PPP_ASYNC=y
53CONFIG_PPP_DEFLATE=y
54CONFIG_PPP_BSDCOMP=y
55# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
56# CONFIG_INPUT_KEYBOARD is not set
57# CONFIG_INPUT_MOUSE is not set
58# CONFIG_SERIO is not set
59CONFIG_SERIAL_ATMEL=y
60CONFIG_SERIAL_ATMEL_CONSOLE=y
61CONFIG_LEGACY_PTY_COUNT=32
62# CONFIG_HW_RANDOM is not set
63CONFIG_I2C=y
64CONFIG_I2C_CHARDEV=y
65CONFIG_I2C_GPIO=y
66CONFIG_GPIO_SYSFS=y
67# CONFIG_HWMON is not set
68CONFIG_WATCHDOG=y
69CONFIG_WATCHDOG_NOWAYOUT=y
70CONFIG_AT91RM9200_WATCHDOG=y
71# CONFIG_VGA_CONSOLE is not set
72# CONFIG_HID_SUPPORT is not set
73CONFIG_USB=y
74# CONFIG_USB_DEVICE_CLASS is not set
75CONFIG_USB_OHCI_HCD=y
76CONFIG_USB_STORAGE=y
77CONFIG_USB_GADGET=y
78CONFIG_USB_ETH=m
79CONFIG_MMC=y
80CONFIG_MMC_AT91=m
81CONFIG_NEW_LEDS=y
82CONFIG_LEDS_CLASS=y
83CONFIG_LEDS_GPIO=y
84CONFIG_LEDS_TRIGGERS=y
85CONFIG_LEDS_TRIGGER_TIMER=y
86CONFIG_LEDS_TRIGGER_HEARTBEAT=y
87CONFIG_LEDS_TRIGGER_GPIO=y
88CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
89CONFIG_RTC_CLASS=y
90# CONFIG_RTC_HCTOSYS is not set
91CONFIG_RTC_DRV_DS1307=y
92CONFIG_RTC_DRV_PCF8563=y
93CONFIG_EXT2_FS=y
94CONFIG_EXT3_FS=y
95# CONFIG_EXT3_FS_XATTR is not set
96CONFIG_INOTIFY=y
97CONFIG_AUTOFS4_FS=y
98CONFIG_MSDOS_FS=y
99CONFIG_VFAT_FS=y
100CONFIG_TMPFS=y
101CONFIG_JFFS2_FS=y
102CONFIG_JFFS2_SUMMARY=y
103CONFIG_CRAMFS=y
104CONFIG_MINIX_FS=y
105CONFIG_NFS_FS=y
106CONFIG_NFS_V3=y
107CONFIG_ROOT_NFS=y
108CONFIG_PARTITION_ADVANCED=y
109CONFIG_NLS_CODEPAGE_437=y
110CONFIG_NLS_ISO8859_1=y
111CONFIG_NLS_UTF8=y
112# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/arm/configs/csb337_defconfig b/arch/arm/configs/csb337_defconfig
deleted file mode 100644
index a24c448840c4..000000000000
--- a/arch/arm/configs/csb337_defconfig
+++ /dev/null
@@ -1,104 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y
4CONFIG_LOG_BUF_SHIFT=14
5CONFIG_BLK_DEV_INITRD=y
6CONFIG_MODULES=y
7CONFIG_MODULE_UNLOAD=y
8# CONFIG_BLK_DEV_BSG is not set
9CONFIG_ARCH_AT91=y
10CONFIG_MACH_CSB337=y
11CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
12# CONFIG_ARM_THUMB is not set
13CONFIG_PCCARD=y
14CONFIG_AT91_CF=y
15CONFIG_LEDS=y
16CONFIG_LEDS_CPU=y
17CONFIG_ZBOOT_ROM_TEXT=0x0
18CONFIG_ZBOOT_ROM_BSS=0x0
19CONFIG_CMDLINE="mem=32M console=ttyS0,38400 initrd=0x20410000,3145728 root=/dev/ram0 rw"
20CONFIG_FPE_NWFPE=y
21CONFIG_NET=y
22CONFIG_PACKET=y
23CONFIG_UNIX=y
24CONFIG_INET=y
25CONFIG_IP_PNP=y
26CONFIG_IP_PNP_DHCP=y
27CONFIG_IP_PNP_BOOTP=y
28# CONFIG_INET_LRO is not set
29# CONFIG_IPV6 is not set
30CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
31CONFIG_MTD=y
32CONFIG_MTD_PARTITIONS=y
33CONFIG_MTD_CMDLINE_PARTS=y
34CONFIG_MTD_CHAR=y
35CONFIG_MTD_BLOCK=y
36CONFIG_MTD_CFI=y
37CONFIG_MTD_CFI_INTELEXT=y
38CONFIG_MTD_PHYSMAP=y
39CONFIG_BLK_DEV_LOOP=y
40CONFIG_BLK_DEV_RAM=y
41CONFIG_BLK_DEV_RAM_SIZE=8192
42CONFIG_ATMEL_SSC=y
43CONFIG_SCSI=y
44CONFIG_NETDEVICES=y
45CONFIG_NET_ETHERNET=y
46CONFIG_ARM_AT91_ETHER=y
47# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
48# CONFIG_INPUT_KEYBOARD is not set
49# CONFIG_INPUT_MOUSE is not set
50# CONFIG_SERIO is not set
51CONFIG_SERIAL_ATMEL=y
52CONFIG_SERIAL_ATMEL_CONSOLE=y
53# CONFIG_HW_RANDOM is not set
54CONFIG_I2C=y
55CONFIG_I2C_CHARDEV=y
56CONFIG_I2C_GPIO=y
57# CONFIG_HWMON is not set
58CONFIG_WATCHDOG=y
59CONFIG_WATCHDOG_NOWAYOUT=y
60CONFIG_AT91RM9200_WATCHDOG=y
61# CONFIG_VGA_CONSOLE is not set
62# CONFIG_USB_HID is not set
63CONFIG_USB=y
64CONFIG_USB_DEBUG=y
65CONFIG_USB_DEVICEFS=y
66CONFIG_USB_MON=y
67CONFIG_USB_OHCI_HCD=y
68CONFIG_USB_STORAGE=y
69CONFIG_USB_SERIAL=y
70CONFIG_USB_SERIAL_CONSOLE=y
71CONFIG_USB_SERIAL_GENERIC=y
72CONFIG_USB_SERIAL_FTDI_SIO=y
73CONFIG_USB_SERIAL_KEYSPAN=y
74CONFIG_USB_SERIAL_KEYSPAN_MPR=y
75CONFIG_USB_SERIAL_KEYSPAN_USA28=y
76CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
77CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
78CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
79CONFIG_USB_SERIAL_KEYSPAN_USA19=y
80CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
81CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
82CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
83CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
84CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
85CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
86CONFIG_USB_SERIAL_MCT_U232=y
87CONFIG_USB_GADGET=y
88CONFIG_MMC=y
89CONFIG_RTC_CLASS=y
90CONFIG_RTC_HCTOSYS_DEVICE="rtc1"
91# CONFIG_RTC_INTF_SYSFS is not set
92CONFIG_RTC_DRV_DS1307=y
93CONFIG_RTC_DRV_AT91RM9200=y
94CONFIG_EXT2_FS=y
95CONFIG_INOTIFY=y
96CONFIG_TMPFS=y
97CONFIG_CRAMFS=y
98CONFIG_NFS_FS=y
99CONFIG_NFS_V3=y
100CONFIG_NFS_V4=y
101CONFIG_ROOT_NFS=y
102CONFIG_DEBUG_KERNEL=y
103CONFIG_DEBUG_USER=y
104CONFIG_DEBUG_LL=y
diff --git a/arch/arm/configs/csb637_defconfig b/arch/arm/configs/csb637_defconfig
deleted file mode 100644
index 98552adac5fb..000000000000
--- a/arch/arm/configs/csb637_defconfig
+++ /dev/null
@@ -1,98 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y
4CONFIG_LOG_BUF_SHIFT=14
5CONFIG_SYSFS_DEPRECATED_V2=y
6CONFIG_BLK_DEV_INITRD=y
7CONFIG_MODULES=y
8CONFIG_MODULE_UNLOAD=y
9# CONFIG_BLK_DEV_BSG is not set
10CONFIG_ARCH_AT91=y
11CONFIG_MACH_CSB637=y
12CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
13# CONFIG_ARM_THUMB is not set
14CONFIG_PCCARD=y
15CONFIG_AT91_CF=y
16CONFIG_LEDS=y
17CONFIG_LEDS_CPU=y
18CONFIG_ZBOOT_ROM_TEXT=0x0
19CONFIG_ZBOOT_ROM_BSS=0x0
20CONFIG_CMDLINE="mem=32M console=ttyS0,38400 initrd=0x20410000,3145728 root=/dev/ram0 rw"
21CONFIG_FPE_NWFPE=y
22CONFIG_NET=y
23CONFIG_PACKET=y
24CONFIG_UNIX=y
25CONFIG_INET=y
26CONFIG_IP_PNP=y
27CONFIG_IP_PNP_DHCP=y
28CONFIG_IP_PNP_BOOTP=y
29# CONFIG_INET_LRO is not set
30# CONFIG_IPV6 is not set
31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
32CONFIG_MTD=y
33CONFIG_MTD_PARTITIONS=y
34CONFIG_MTD_CMDLINE_PARTS=y
35CONFIG_MTD_CHAR=y
36CONFIG_MTD_BLOCK=y
37CONFIG_MTD_CFI=y
38CONFIG_MTD_CFI_INTELEXT=y
39CONFIG_MTD_PHYSMAP=y
40CONFIG_BLK_DEV_LOOP=y
41CONFIG_BLK_DEV_RAM=y
42CONFIG_BLK_DEV_RAM_SIZE=8192
43CONFIG_SCSI=y
44CONFIG_NETDEVICES=y
45CONFIG_NET_ETHERNET=y
46CONFIG_ARM_AT91_ETHER=y
47# CONFIG_INPUT_KEYBOARD is not set
48# CONFIG_INPUT_MOUSE is not set
49# CONFIG_SERIO is not set
50CONFIG_SERIAL_ATMEL=y
51CONFIG_SERIAL_ATMEL_CONSOLE=y
52CONFIG_I2C=y
53CONFIG_I2C_CHARDEV=y
54CONFIG_WATCHDOG=y
55CONFIG_WATCHDOG_NOWAYOUT=y
56CONFIG_AT91RM9200_WATCHDOG=y
57# CONFIG_VGA_CONSOLE is not set
58# CONFIG_USB_HID is not set
59CONFIG_USB=y
60CONFIG_USB_DEBUG=y
61CONFIG_USB_DEVICEFS=y
62CONFIG_USB_MON=y
63CONFIG_USB_OHCI_HCD=y
64CONFIG_USB_STORAGE=y
65CONFIG_USB_SERIAL=y
66CONFIG_USB_SERIAL_CONSOLE=y
67CONFIG_USB_SERIAL_GENERIC=y
68CONFIG_USB_SERIAL_FTDI_SIO=y
69CONFIG_USB_SERIAL_KEYSPAN=y
70CONFIG_USB_SERIAL_KEYSPAN_MPR=y
71CONFIG_USB_SERIAL_KEYSPAN_USA28=y
72CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
73CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
74CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
75CONFIG_USB_SERIAL_KEYSPAN_USA19=y
76CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
77CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
78CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
79CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
80CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
81CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
82CONFIG_USB_SERIAL_MCT_U232=y
83CONFIG_NEW_LEDS=y
84CONFIG_LEDS_CLASS=y
85CONFIG_LEDS_GPIO=y
86CONFIG_LEDS_TRIGGERS=y
87CONFIG_LEDS_TRIGGER_HEARTBEAT=y
88CONFIG_EXT2_FS=y
89CONFIG_INOTIFY=y
90CONFIG_TMPFS=y
91CONFIG_CRAMFS=y
92CONFIG_NFS_FS=y
93CONFIG_NFS_V3=y
94CONFIG_NFS_V4=y
95CONFIG_ROOT_NFS=y
96CONFIG_DEBUG_KERNEL=y
97CONFIG_DEBUG_USER=y
98CONFIG_DEBUG_LL=y
diff --git a/arch/arm/configs/ecbat91_defconfig b/arch/arm/configs/ecbat91_defconfig
deleted file mode 100644
index 6bb6abdcea8c..000000000000
--- a/arch/arm/configs/ecbat91_defconfig
+++ /dev/null
@@ -1,99 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SLAB=y
7CONFIG_MODULES=y
8CONFIG_MODULE_UNLOAD=y
9# CONFIG_IOSCHED_DEADLINE is not set
10# CONFIG_IOSCHED_CFQ is not set
11CONFIG_ARCH_AT91=y
12CONFIG_MACH_ECBAT91=y
13CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
14CONFIG_PCCARD=y
15CONFIG_AT91_CF=y
16CONFIG_PREEMPT=y
17CONFIG_LEDS=y
18CONFIG_LEDS_CPU=y
19CONFIG_ZBOOT_ROM_TEXT=0x0
20CONFIG_ZBOOT_ROM_BSS=0x0
21CONFIG_CMDLINE="rootfstype=reiserfs root=/dev/mmcblk0p1 console=ttyS0,115200n8 rootdelay=1"
22CONFIG_FPE_NWFPE=y
23CONFIG_NET=y
24CONFIG_PACKET=y
25CONFIG_UNIX=y
26CONFIG_INET=y
27CONFIG_IP_PNP=y
28CONFIG_IP_PNP_DHCP=y
29# CONFIG_IPV6 is not set
30CONFIG_CFG80211=y
31CONFIG_MAC80211=y
32# CONFIG_STANDALONE is not set
33# CONFIG_PREVENT_FIRMWARE_BUILD is not set
34CONFIG_MTD=y
35CONFIG_MTD_PARTITIONS=y
36CONFIG_MTD_CMDLINE_PARTS=y
37CONFIG_MTD_AFS_PARTS=y
38CONFIG_MTD_CHAR=y
39CONFIG_MTD_BLOCK=y
40CONFIG_MTD_DATAFLASH=y
41CONFIG_BLK_DEV_LOOP=y
42CONFIG_SCSI=y
43CONFIG_BLK_DEV_SD=y
44CONFIG_CHR_DEV_SG=y
45CONFIG_NETDEVICES=y
46CONFIG_NET_ETHERNET=y
47CONFIG_ARM_AT91_ETHER=y
48# CONFIG_NETDEV_1000 is not set
49# CONFIG_NETDEV_10000 is not set
50CONFIG_PPP=y
51CONFIG_PPP_MULTILINK=y
52CONFIG_PPP_FILTER=y
53CONFIG_PPP_ASYNC=y
54# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
55# CONFIG_INPUT_KEYBOARD is not set
56# CONFIG_INPUT_MOUSE is not set
57# CONFIG_SERIO is not set
58CONFIG_SERIAL_ATMEL=y
59CONFIG_SERIAL_ATMEL_CONSOLE=y
60CONFIG_HW_RANDOM=y
61CONFIG_I2C=y
62CONFIG_I2C_CHARDEV=y
63CONFIG_SPI=y
64CONFIG_SPI_BITBANG=y
65CONFIG_WATCHDOG=y
66CONFIG_WATCHDOG_NOWAYOUT=y
67# CONFIG_VGA_CONSOLE is not set
68# CONFIG_USB_HID is not set
69CONFIG_USB=y
70CONFIG_USB_DEVICEFS=y
71# CONFIG_USB_DEVICE_CLASS is not set
72CONFIG_USB_OHCI_HCD=y
73CONFIG_USB_PRINTER=y
74CONFIG_USB_STORAGE=y
75CONFIG_USB_GADGET=y
76CONFIG_MMC=y
77CONFIG_MMC_DEBUG=y
78CONFIG_MMC_AT91=m
79CONFIG_NEW_LEDS=y
80CONFIG_LEDS_CLASS=y
81CONFIG_RTC_CLASS=y
82# CONFIG_RTC_HCTOSYS is not set
83CONFIG_RTC_DRV_AT91RM9200=y
84CONFIG_EXT2_FS=y
85CONFIG_EXT3_FS=y
86CONFIG_REISERFS_FS=y
87CONFIG_INOTIFY=y
88CONFIG_TMPFS=y
89CONFIG_CONFIGFS_FS=y
90CONFIG_CRAMFS=y
91CONFIG_NFS_FS=y
92CONFIG_NFS_V3=y
93CONFIG_NFS_V3_ACL=y
94CONFIG_NFS_V4=y
95CONFIG_ROOT_NFS=y
96CONFIG_PARTITION_ADVANCED=y
97CONFIG_DEBUG_USER=y
98CONFIG_CRYPTO_PCBC=y
99CONFIG_CRYPTO_SHA1=y
diff --git a/arch/arm/configs/kafa_defconfig b/arch/arm/configs/kafa_defconfig
deleted file mode 100644
index 896dbe00dc6e..000000000000
--- a/arch/arm/configs/kafa_defconfig
+++ /dev/null
@@ -1,61 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set
3# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SLAB=y
7CONFIG_MODULES=y
8CONFIG_MODULE_UNLOAD=y
9# CONFIG_IOSCHED_CFQ is not set
10CONFIG_ARCH_AT91=y
11CONFIG_MACH_KAFA=y
12# CONFIG_ARM_THUMB is not set
13CONFIG_PREEMPT=y
14CONFIG_LEDS=y
15CONFIG_LEDS_CPU=y
16CONFIG_ZBOOT_ROM_TEXT=0x0
17CONFIG_ZBOOT_ROM_BSS=0x0
18CONFIG_CMDLINE="mem=32M console=ttyS0,115200 initrd=0x20800000,10M root=/dev/ram0 rw"
19CONFIG_FPE_NWFPE=y
20CONFIG_BINFMT_MISC=y
21CONFIG_NET=y
22CONFIG_PACKET=y
23CONFIG_UNIX=y
24CONFIG_INET=y
25# CONFIG_INET_DIAG is not set
26# CONFIG_IPV6 is not set
27CONFIG_MTD=y
28CONFIG_MTD_PARTITIONS=y
29CONFIG_MTD_CHAR=y
30CONFIG_MTD_BLOCK_RO=y
31CONFIG_NETDEVICES=y
32CONFIG_PHYLIB=y
33CONFIG_DAVICOM_PHY=y
34CONFIG_NET_ETHERNET=y
35CONFIG_ARM_AT91_ETHER=y
36# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
37# CONFIG_INPUT_KEYBOARD is not set
38# CONFIG_INPUT_MOUSE is not set
39# CONFIG_SERIO is not set
40CONFIG_SERIAL_ATMEL=y
41CONFIG_SERIAL_ATMEL_CONSOLE=y
42CONFIG_LEGACY_PTY_COUNT=32
43CONFIG_I2C=y
44CONFIG_I2C_CHARDEV=y
45CONFIG_I2C_GPIO=y
46# CONFIG_HWMON is not set
47CONFIG_WATCHDOG=y
48CONFIG_WATCHDOG_NOWAYOUT=y
49CONFIG_AT91RM9200_WATCHDOG=y
50# CONFIG_VGA_CONSOLE is not set
51CONFIG_RTC_CLASS=y
52# CONFIG_RTC_HCTOSYS is not set
53CONFIG_RTC_DRV_AT91RM9200=y
54CONFIG_EXT3_FS=y
55# CONFIG_EXT3_FS_XATTR is not set
56CONFIG_TMPFS=y
57CONFIG_CRAMFS=y
58CONFIG_NFS_FS=m
59CONFIG_NFS_V3=y
60CONFIG_CRYPTO_MD5=y
61CONFIG_CRYPTO_DES=y
diff --git a/arch/arm/configs/kb9202_defconfig b/arch/arm/configs/kb9202_defconfig
deleted file mode 100644
index 9f906a85f5c2..000000000000
--- a/arch/arm/configs/kb9202_defconfig
+++ /dev/null
@@ -1,127 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y
5CONFIG_BSD_PROCESS_ACCT=y
6CONFIG_AUDIT=y
7CONFIG_IKCONFIG=y
8CONFIG_IKCONFIG_PROC=y
9CONFIG_BLK_DEV_INITRD=y
10CONFIG_KALLSYMS_EXTRA_PASS=y
11CONFIG_MODULES=y
12CONFIG_MODULE_UNLOAD=y
13CONFIG_MODVERSIONS=y
14CONFIG_MODULE_SRCVERSION_ALL=y
15# CONFIG_BLK_DEV_BSG is not set
16# CONFIG_IOSCHED_DEADLINE is not set
17CONFIG_ARCH_AT91=y
18CONFIG_MACH_KB9200=y
19CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
20CONFIG_NO_HZ=y
21CONFIG_HIGH_RES_TIMERS=y
22CONFIG_PREEMPT=y
23CONFIG_AEABI=y
24CONFIG_ZBOOT_ROM_TEXT=0x10000000
25CONFIG_ZBOOT_ROM_BSS=0x20040000
26CONFIG_CMDLINE="noinitrd root=/dev/mtdblock0 rootfstype=jffs2 mem=64M"
27CONFIG_KEXEC=y
28CONFIG_FPE_NWFPE=y
29CONFIG_BINFMT_MISC=y
30CONFIG_NET=y
31CONFIG_PACKET=y
32CONFIG_UNIX=y
33CONFIG_INET=y
34CONFIG_IP_PNP=y
35CONFIG_IP_PNP_DHCP=y
36CONFIG_IP_PNP_BOOTP=y
37# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
38# CONFIG_INET_XFRM_MODE_TUNNEL is not set
39# CONFIG_INET_XFRM_MODE_BEET is not set
40# CONFIG_INET_LRO is not set
41# CONFIG_INET_DIAG is not set
42# CONFIG_IPV6 is not set
43CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
44# CONFIG_FIRMWARE_IN_KERNEL is not set
45CONFIG_MTD=y
46CONFIG_MTD_CONCAT=y
47CONFIG_MTD_PARTITIONS=y
48CONFIG_MTD_CMDLINE_PARTS=y
49CONFIG_MTD_CHAR=y
50CONFIG_MTD_BLOCK=y
51CONFIG_MTD_CFI=y
52CONFIG_MTD_CFI_INTELEXT=y
53CONFIG_MTD_COMPLEX_MAPPINGS=y
54CONFIG_MTD_PHYSMAP=y
55CONFIG_MTD_NAND=y
56CONFIG_MTD_NAND_ATMEL=y
57CONFIG_MTD_UBI=y
58CONFIG_MTD_UBI_GLUEBI=y
59CONFIG_BLK_DEV_LOOP=y
60CONFIG_BLK_DEV_RAM=y
61CONFIG_BLK_DEV_RAM_SIZE=16384
62CONFIG_ATMEL_TCLIB=y
63CONFIG_ATMEL_SSC=y
64CONFIG_SCSI=y
65CONFIG_BLK_DEV_SD=y
66CONFIG_CHR_DEV_SG=y
67CONFIG_SCSI_MULTI_LUN=y
68CONFIG_SCSI_CONSTANTS=y
69CONFIG_SCSI_LOGGING=y
70CONFIG_SCSI_SPI_ATTRS=m
71# CONFIG_SCSI_LOWLEVEL is not set
72CONFIG_NETDEVICES=y
73CONFIG_NET_ETHERNET=y
74CONFIG_ARM_AT91_ETHER=y
75# CONFIG_NETDEV_1000 is not set
76# CONFIG_NETDEV_10000 is not set
77# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
78# CONFIG_INPUT_KEYBOARD is not set
79# CONFIG_INPUT_MOUSE is not set
80# CONFIG_SERIO is not set
81CONFIG_SERIAL_ATMEL=y
82CONFIG_SERIAL_ATMEL_CONSOLE=y
83# CONFIG_LEGACY_PTYS is not set
84# CONFIG_HW_RANDOM is not set
85# CONFIG_HWMON is not set
86CONFIG_WATCHDOG=y
87CONFIG_AT91RM9200_WATCHDOG=y
88CONFIG_FB=y
89CONFIG_FB_MODE_HELPERS=y
90CONFIG_FB_TILEBLITTING=y
91CONFIG_BACKLIGHT_LCD_SUPPORT=y
92# CONFIG_LCD_CLASS_DEVICE is not set
93CONFIG_BACKLIGHT_CLASS_DEVICE=y
94# CONFIG_BACKLIGHT_GENERIC is not set
95# CONFIG_VGA_CONSOLE is not set
96CONFIG_FRAMEBUFFER_CONSOLE=y
97CONFIG_FONTS=y
98CONFIG_FONT_MINI_4x6=y
99# CONFIG_HID_SUPPORT is not set
100CONFIG_USB=y
101CONFIG_USB_DEVICEFS=y
102CONFIG_USB_OHCI_HCD=y
103CONFIG_USB_STORAGE=y
104CONFIG_USB_LIBUSUAL=y
105CONFIG_MMC=y
106CONFIG_MMC_AT91=m
107CONFIG_RTC_CLASS=y
108CONFIG_RTC_DRV_AT91RM9200=y
109CONFIG_EXT2_FS=y
110CONFIG_EXT3_FS=y
111# CONFIG_DNOTIFY is not set
112CONFIG_INOTIFY=y
113CONFIG_VFAT_FS=y
114CONFIG_TMPFS=y
115CONFIG_CONFIGFS_FS=y
116CONFIG_JFFS2_FS=y
117CONFIG_NFS_FS=y
118CONFIG_NFS_V3=y
119CONFIG_ROOT_NFS=y
120CONFIG_NLS_CODEPAGE_437=y
121CONFIG_NLS_UTF8=y
122CONFIG_MAGIC_SYSRQ=y
123CONFIG_DEBUG_FS=y
124CONFIG_DEBUG_KERNEL=y
125# CONFIG_SCHED_DEBUG is not set
126# CONFIG_DEBUG_PREEMPT is not set
127# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/arm/configs/onearm_defconfig b/arch/arm/configs/onearm_defconfig
deleted file mode 100644
index 1579857aeeaa..000000000000
--- a/arch/arm/configs/onearm_defconfig
+++ /dev/null
@@ -1,80 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y
4CONFIG_LOG_BUF_SHIFT=14
5CONFIG_BLK_DEV_INITRD=y
6CONFIG_EMBEDDED=y
7CONFIG_SLAB=y
8CONFIG_MODULES=y
9CONFIG_MODULE_UNLOAD=y
10# CONFIG_IOSCHED_DEADLINE is not set
11# CONFIG_IOSCHED_CFQ is not set
12CONFIG_ARCH_AT91=y
13CONFIG_MACH_ONEARM=y
14CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
15# CONFIG_ARM_THUMB is not set
16CONFIG_PCCARD=y
17CONFIG_AT91_CF=y
18CONFIG_LEDS=y
19CONFIG_ZBOOT_ROM_TEXT=0x0
20CONFIG_ZBOOT_ROM_BSS=0x0
21CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs ip=bootp mem=64M"
22CONFIG_FPE_NWFPE=y
23CONFIG_NET=y
24CONFIG_PACKET=y
25CONFIG_UNIX=y
26CONFIG_INET=y
27CONFIG_IP_PNP=y
28CONFIG_IP_PNP_BOOTP=y
29CONFIG_IPV6=y
30# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
31# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
32# CONFIG_INET6_XFRM_MODE_BEET is not set
33# CONFIG_IPV6_SIT is not set
34CONFIG_MTD=y
35CONFIG_MTD_PARTITIONS=y
36CONFIG_MTD_CMDLINE_PARTS=y
37CONFIG_MTD_CHAR=y
38CONFIG_MTD_BLOCK=y
39CONFIG_MTD_CFI=y
40CONFIG_MTD_JEDECPROBE=y
41CONFIG_MTD_CFI_AMDSTD=y
42CONFIG_MTD_PHYSMAP=y
43CONFIG_BLK_DEV_NBD=y
44CONFIG_BLK_DEV_RAM=y
45CONFIG_BLK_DEV_RAM_SIZE=8192
46CONFIG_NETDEVICES=y
47CONFIG_NET_ETHERNET=y
48CONFIG_ARM_AT91_ETHER=y
49# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
50# CONFIG_INPUT_KEYBOARD is not set
51# CONFIG_INPUT_MOUSE is not set
52# CONFIG_SERIO is not set
53# CONFIG_VT is not set
54CONFIG_SERIAL_ATMEL=y
55CONFIG_SERIAL_ATMEL_CONSOLE=y
56# CONFIG_HW_RANDOM is not set
57CONFIG_I2C=y
58CONFIG_I2C_CHARDEV=y
59CONFIG_WATCHDOG=y
60CONFIG_WATCHDOG_NOWAYOUT=y
61CONFIG_AT91RM9200_WATCHDOG=y
62# CONFIG_USB_HID is not set
63CONFIG_USB=y
64CONFIG_USB_DEBUG=y
65CONFIG_USB_DEVICEFS=y
66CONFIG_USB_MON=y
67CONFIG_USB_OHCI_HCD=y
68CONFIG_USB_GADGET=y
69CONFIG_MMC=y
70CONFIG_EXT2_FS=y
71CONFIG_INOTIFY=y
72CONFIG_TMPFS=y
73CONFIG_CRAMFS=y
74CONFIG_NFS_FS=y
75CONFIG_NFS_V3=y
76CONFIG_NFS_V3_ACL=y
77CONFIG_ROOT_NFS=y
78CONFIG_DEBUG_KERNEL=y
79CONFIG_DEBUG_USER=y
80CONFIG_DEBUG_LL=y
diff --git a/arch/arm/configs/picotux200_defconfig b/arch/arm/configs/picotux200_defconfig
deleted file mode 100644
index 4c9afa478d57..000000000000
--- a/arch/arm/configs/picotux200_defconfig
+++ /dev/null
@@ -1,242 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=m
4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_EMBEDDED=y
7# CONFIG_KALLSYMS is not set
8CONFIG_SLAB=y
9CONFIG_MODULES=y
10CONFIG_MODULE_UNLOAD=y
11# CONFIG_IOSCHED_DEADLINE is not set
12# CONFIG_IOSCHED_CFQ is not set
13CONFIG_ARCH_AT91=y
14CONFIG_MACH_PICOTUX2XX=y
15CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
16CONFIG_AEABI=y
17CONFIG_ZBOOT_ROM_TEXT=0x0
18CONFIG_ZBOOT_ROM_BSS=0x0
19CONFIG_KEXEC=y
20CONFIG_FPE_NWFPE=y
21CONFIG_BINFMT_MISC=m
22CONFIG_NET=y
23CONFIG_PACKET=m
24CONFIG_UNIX=y
25CONFIG_XFRM_USER=m
26CONFIG_INET=y
27CONFIG_IP_PNP=y
28CONFIG_IP_PNP_BOOTP=y
29CONFIG_NET_IPIP=m
30CONFIG_NET_IPGRE=m
31CONFIG_INET_AH=m
32CONFIG_INET_ESP=m
33CONFIG_INET_IPCOMP=m
34CONFIG_INET_XFRM_MODE_TRANSPORT=m
35CONFIG_INET_XFRM_MODE_TUNNEL=m
36CONFIG_INET_XFRM_MODE_BEET=m
37CONFIG_INET_DIAG=m
38CONFIG_IPV6_PRIVACY=y
39CONFIG_IPV6_ROUTER_PREF=y
40CONFIG_IPV6_ROUTE_INFO=y
41CONFIG_INET6_AH=m
42CONFIG_INET6_ESP=m
43CONFIG_INET6_IPCOMP=m
44CONFIG_IPV6_MIP6=m
45CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
46CONFIG_IPV6_TUNNEL=m
47CONFIG_BRIDGE=m
48CONFIG_VLAN_8021Q=m
49CONFIG_BT=m
50CONFIG_BT_L2CAP=m
51CONFIG_BT_SCO=m
52CONFIG_BT_RFCOMM=m
53CONFIG_BT_RFCOMM_TTY=y
54CONFIG_BT_BNEP=m
55CONFIG_BT_BNEP_MC_FILTER=y
56CONFIG_BT_BNEP_PROTO_FILTER=y
57CONFIG_BT_HIDP=m
58CONFIG_FW_LOADER=m
59CONFIG_MTD=y
60CONFIG_MTD_PARTITIONS=y
61CONFIG_MTD_CMDLINE_PARTS=y
62CONFIG_MTD_CHAR=y
63CONFIG_MTD_BLOCK=y
64CONFIG_MTD_CFI=y
65CONFIG_MTD_CFI_AMDSTD=y
66CONFIG_MTD_PHYSMAP=y
67CONFIG_BLK_DEV_LOOP=m
68CONFIG_EEPROM_LEGACY=m
69CONFIG_SCSI=m
70CONFIG_BLK_DEV_SD=m
71CONFIG_BLK_DEV_SR=m
72CONFIG_BLK_DEV_SR_VENDOR=y
73CONFIG_CHR_DEV_SG=m
74CONFIG_NETDEVICES=y
75CONFIG_TUN=m
76CONFIG_NET_ETHERNET=y
77CONFIG_ARM_AT91_ETHER=y
78CONFIG_USB_CATC=m
79CONFIG_USB_KAWETH=m
80CONFIG_USB_PEGASUS=m
81CONFIG_USB_RTL8150=m
82CONFIG_USB_USBNET=m
83CONFIG_USB_NET_DM9601=m
84CONFIG_USB_NET_GL620A=m
85CONFIG_USB_NET_PLUSB=m
86CONFIG_USB_NET_MCS7830=m
87CONFIG_USB_NET_RNDIS_HOST=m
88CONFIG_USB_ALI_M5632=y
89CONFIG_USB_AN2720=y
90CONFIG_USB_EPSON2888=y
91CONFIG_USB_KC2190=y
92CONFIG_PPP=m
93CONFIG_PPP_FILTER=y
94CONFIG_PPP_ASYNC=m
95CONFIG_PPP_DEFLATE=m
96CONFIG_PPP_BSDCOMP=m
97CONFIG_PPP_MPPE=m
98CONFIG_PPPOE=m
99CONFIG_SLIP=m
100CONFIG_SLIP_COMPRESSED=y
101CONFIG_SLIP_SMART=y
102CONFIG_SLIP_MODE_SLIP6=y
103# CONFIG_INPUT_MOUSEDEV is not set
104# CONFIG_INPUT_KEYBOARD is not set
105# CONFIG_INPUT_MOUSE is not set
106# CONFIG_SERIO is not set
107# CONFIG_VT is not set
108CONFIG_SERIAL_ATMEL=y
109CONFIG_SERIAL_ATMEL_CONSOLE=y
110# CONFIG_LEGACY_PTYS is not set
111CONFIG_I2C=m
112CONFIG_I2C_CHARDEV=m
113CONFIG_I2C_GPIO=m
114CONFIG_HWMON=m
115CONFIG_SENSORS_ADM1021=m
116CONFIG_SENSORS_ADM1025=m
117CONFIG_SENSORS_ADM1026=m
118CONFIG_SENSORS_ADM1029=m
119CONFIG_SENSORS_ADM1031=m
120CONFIG_SENSORS_ADM9240=m
121CONFIG_SENSORS_DS1621=m
122CONFIG_SENSORS_GL518SM=m
123CONFIG_SENSORS_GL520SM=m
124CONFIG_SENSORS_IT87=m
125CONFIG_SENSORS_LM63=m
126CONFIG_SENSORS_LM75=m
127CONFIG_SENSORS_LM77=m
128CONFIG_SENSORS_LM78=m
129CONFIG_SENSORS_LM80=m
130CONFIG_SENSORS_LM83=m
131CONFIG_SENSORS_LM85=m
132CONFIG_SENSORS_LM87=m
133CONFIG_SENSORS_LM90=m
134CONFIG_SENSORS_LM92=m
135CONFIG_SENSORS_MAX1619=m
136CONFIG_SENSORS_PCF8591=m
137CONFIG_SENSORS_SMSC47B397=m
138CONFIG_SENSORS_W83781D=m
139CONFIG_SENSORS_W83791D=m
140CONFIG_SENSORS_W83792D=m
141CONFIG_SENSORS_W83793=m
142CONFIG_SENSORS_W83L785TS=m
143CONFIG_WATCHDOG=y
144CONFIG_WATCHDOG_NOWAYOUT=y
145CONFIG_AT91RM9200_WATCHDOG=m
146CONFIG_HID=m
147CONFIG_USB=m
148CONFIG_USB_DEVICEFS=y
149CONFIG_USB_OHCI_HCD=m
150CONFIG_USB_ACM=m
151CONFIG_USB_PRINTER=m
152CONFIG_USB_STORAGE=m
153CONFIG_USB_SERIAL=m
154CONFIG_USB_SERIAL_GENERIC=y
155CONFIG_USB_SERIAL_PL2303=m
156CONFIG_MMC=m
157CONFIG_MMC_AT91=m
158CONFIG_RTC_CLASS=m
159CONFIG_RTC_DRV_AT91RM9200=m
160CONFIG_EXT2_FS=m
161CONFIG_EXT3_FS=m
162# CONFIG_EXT3_FS_XATTR is not set
163CONFIG_INOTIFY=y
164CONFIG_ISO9660_FS=m
165CONFIG_JOLIET=y
166CONFIG_UDF_FS=m
167CONFIG_MSDOS_FS=m
168CONFIG_VFAT_FS=m
169CONFIG_NTFS_FS=m
170CONFIG_TMPFS=y
171CONFIG_JFFS2_FS=y
172CONFIG_JFFS2_SUMMARY=y
173CONFIG_JFFS2_COMPRESSION_OPTIONS=y
174CONFIG_NFS_FS=m
175CONFIG_SMB_FS=m
176CONFIG_CIFS=m
177CONFIG_PARTITION_ADVANCED=y
178CONFIG_AMIGA_PARTITION=y
179CONFIG_NLS_DEFAULT="utf-8"
180CONFIG_NLS_CODEPAGE_437=m
181CONFIG_NLS_CODEPAGE_737=m
182CONFIG_NLS_CODEPAGE_775=m
183CONFIG_NLS_CODEPAGE_850=m
184CONFIG_NLS_CODEPAGE_852=m
185CONFIG_NLS_CODEPAGE_855=m
186CONFIG_NLS_CODEPAGE_857=m
187CONFIG_NLS_CODEPAGE_860=m
188CONFIG_NLS_CODEPAGE_861=m
189CONFIG_NLS_CODEPAGE_862=m
190CONFIG_NLS_CODEPAGE_863=m
191CONFIG_NLS_CODEPAGE_864=m
192CONFIG_NLS_CODEPAGE_865=m
193CONFIG_NLS_CODEPAGE_866=m
194CONFIG_NLS_CODEPAGE_869=m
195CONFIG_NLS_CODEPAGE_936=m
196CONFIG_NLS_CODEPAGE_950=m
197CONFIG_NLS_CODEPAGE_932=m
198CONFIG_NLS_CODEPAGE_949=m
199CONFIG_NLS_CODEPAGE_874=m
200CONFIG_NLS_ISO8859_8=m
201CONFIG_NLS_CODEPAGE_1250=m
202CONFIG_NLS_CODEPAGE_1251=m
203CONFIG_NLS_ASCII=m
204CONFIG_NLS_ISO8859_1=m
205CONFIG_NLS_ISO8859_2=m
206CONFIG_NLS_ISO8859_3=m
207CONFIG_NLS_ISO8859_4=m
208CONFIG_NLS_ISO8859_5=m
209CONFIG_NLS_ISO8859_6=m
210CONFIG_NLS_ISO8859_7=m
211CONFIG_NLS_ISO8859_9=m
212CONFIG_NLS_ISO8859_13=m
213CONFIG_NLS_ISO8859_14=m
214CONFIG_NLS_ISO8859_15=m
215CONFIG_NLS_KOI8_R=m
216CONFIG_NLS_KOI8_U=m
217CONFIG_NLS_UTF8=m
218CONFIG_DEBUG_KERNEL=y
219# CONFIG_DEBUG_BUGVERBOSE is not set
220CONFIG_DEBUG_LL=y
221CONFIG_CRYPTO_NULL=m
222CONFIG_CRYPTO_TEST=m
223CONFIG_CRYPTO_LRW=m
224CONFIG_CRYPTO_PCBC=m
225CONFIG_CRYPTO_XCBC=m
226CONFIG_CRYPTO_MD4=m
227CONFIG_CRYPTO_MICHAEL_MIC=m
228CONFIG_CRYPTO_SHA256=m
229CONFIG_CRYPTO_SHA512=m
230CONFIG_CRYPTO_TGR192=m
231CONFIG_CRYPTO_WP512=m
232CONFIG_CRYPTO_ANUBIS=m
233CONFIG_CRYPTO_BLOWFISH=m
234CONFIG_CRYPTO_CAMELLIA=m
235CONFIG_CRYPTO_CAST5=m
236CONFIG_CRYPTO_CAST6=m
237CONFIG_CRYPTO_FCRYPT=m
238CONFIG_CRYPTO_KHAZAD=m
239CONFIG_CRYPTO_SERPENT=m
240CONFIG_CRYPTO_TEA=m
241CONFIG_CRYPTO_TWOFISH=m
242CONFIG_LIBCRC32C=m
diff --git a/arch/arm/configs/yl9200_defconfig b/arch/arm/configs/yl9200_defconfig
deleted file mode 100644
index 30c537f61089..000000000000
--- a/arch/arm/configs/yl9200_defconfig
+++ /dev/null
@@ -1,137 +0,0 @@
1# CONFIG_SWAP is not set
2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_BLK_DEV_INITRD=y
5# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
6CONFIG_MODULES=y
7CONFIG_MODULE_UNLOAD=y
8# CONFIG_IOSCHED_DEADLINE is not set
9# CONFIG_IOSCHED_CFQ is not set
10CONFIG_ARCH_AT91=y
11CONFIG_ARCH_AT91RM9200DK=y
12CONFIG_MACH_YL9200=y
13# CONFIG_ARM_THUMB is not set
14CONFIG_ZBOOT_ROM_TEXT=0x0
15CONFIG_ZBOOT_ROM_BSS=0x0
16CONFIG_CMDLINE="mem=32M console=ttyS0,115200 initrd=0x20410000,3145728 root=/dev/ram0 rw"
17CONFIG_FPE_NWFPE=y
18CONFIG_NET=y
19CONFIG_PACKET=y
20CONFIG_UNIX=y
21CONFIG_INET=y
22CONFIG_IP_PNP=y
23CONFIG_IP_PNP_DHCP=y
24# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
25# CONFIG_INET_XFRM_MODE_TUNNEL is not set
26# CONFIG_INET_XFRM_MODE_BEET is not set
27# CONFIG_INET_LRO is not set
28# CONFIG_INET_DIAG is not set
29# CONFIG_IPV6 is not set
30CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
31CONFIG_MTD=y
32CONFIG_MTD_CONCAT=y
33CONFIG_MTD_PARTITIONS=y
34CONFIG_MTD_CMDLINE_PARTS=y
35CONFIG_MTD_CHAR=y
36CONFIG_MTD_BLOCK=y
37CONFIG_MTD_CFI=y
38CONFIG_MTD_JEDECPROBE=y
39CONFIG_MTD_CFI_INTELEXT=y
40CONFIG_MTD_COMPLEX_MAPPINGS=y
41CONFIG_MTD_PHYSMAP=y
42CONFIG_MTD_PLATRAM=y
43CONFIG_MTD_NAND=y
44CONFIG_MTD_NAND_ATMEL=y
45CONFIG_MTD_NAND_PLATFORM=y
46CONFIG_BLK_DEV_LOOP=y
47CONFIG_BLK_DEV_RAM=y
48CONFIG_BLK_DEV_RAM_COUNT=3
49CONFIG_BLK_DEV_RAM_SIZE=8192
50# CONFIG_MISC_DEVICES is not set
51CONFIG_BLK_DEV_SD=y
52CONFIG_ATA=y
53CONFIG_NETDEVICES=y
54CONFIG_PHYLIB=y
55CONFIG_DAVICOM_PHY=y
56CONFIG_NET_ETHERNET=y
57CONFIG_ARM_AT91_ETHER=y
58# CONFIG_NETDEV_1000 is not set
59# CONFIG_NETDEV_10000 is not set
60# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
61CONFIG_INPUT_MOUSEDEV_SCREEN_X=640
62CONFIG_INPUT_MOUSEDEV_SCREEN_Y=480
63CONFIG_INPUT_EVDEV=y
64# CONFIG_KEYBOARD_ATKBD is not set
65CONFIG_KEYBOARD_GPIO=y
66CONFIG_INPUT_TOUCHSCREEN=y
67CONFIG_TOUCHSCREEN_ADS7846=y
68# CONFIG_SERIO_SERPORT is not set
69CONFIG_SERIAL_ATMEL=y
70CONFIG_SERIAL_ATMEL_CONSOLE=y
71# CONFIG_HW_RANDOM is not set
72CONFIG_I2C=y
73CONFIG_SPI=y
74CONFIG_SPI_DEBUG=y
75CONFIG_SPI_ATMEL=y
76CONFIG_FB=y
77CONFIG_BACKLIGHT_LCD_SUPPORT=y
78CONFIG_LCD_CLASS_DEVICE=y
79CONFIG_BACKLIGHT_CLASS_DEVICE=y
80CONFIG_DISPLAY_SUPPORT=y
81# CONFIG_VGA_CONSOLE is not set
82CONFIG_LOGO=y
83# CONFIG_LOGO_LINUX_MONO is not set
84# CONFIG_LOGO_LINUX_VGA16 is not set
85CONFIG_USB=y
86CONFIG_USB_DEBUG=y
87CONFIG_USB_DEVICEFS=y
88# CONFIG_USB_DEVICE_CLASS is not set
89CONFIG_USB_MON=y
90CONFIG_USB_OHCI_HCD=y
91CONFIG_USB_STORAGE=y
92CONFIG_USB_GADGET=y
93CONFIG_USB_GADGET_M66592=y
94CONFIG_USB_FILE_STORAGE=m
95CONFIG_MMC=y
96CONFIG_MMC_DEBUG=y
97# CONFIG_MMC_BLOCK_BOUNCE is not set
98CONFIG_MMC_AT91=m
99CONFIG_NEW_LEDS=y
100CONFIG_LEDS_CLASS=y
101CONFIG_LEDS_GPIO=y
102CONFIG_LEDS_TRIGGERS=y
103CONFIG_LEDS_TRIGGER_TIMER=y
104CONFIG_LEDS_TRIGGER_HEARTBEAT=y
105CONFIG_RTC_CLASS=y
106CONFIG_RTC_DRV_AT91RM9200=y
107CONFIG_EXT2_FS=y
108CONFIG_EXT2_FS_XATTR=y
109CONFIG_EXT3_FS=y
110CONFIG_REISERFS_FS=y
111CONFIG_INOTIFY=y
112CONFIG_ISO9660_FS=y
113CONFIG_JOLIET=y
114CONFIG_ZISOFS=y
115CONFIG_UDF_FS=y
116CONFIG_MSDOS_FS=y
117CONFIG_VFAT_FS=y
118CONFIG_TMPFS=y
119CONFIG_JFFS2_FS=y
120CONFIG_JFFS2_FS_DEBUG=1
121CONFIG_JFFS2_COMPRESSION_OPTIONS=y
122CONFIG_JFFS2_RUBIN=y
123CONFIG_CRAMFS=y
124CONFIG_PARTITION_ADVANCED=y
125CONFIG_MAC_PARTITION=y
126CONFIG_NLS_CODEPAGE_437=y
127CONFIG_NLS_ISO8859_1=y
128# CONFIG_ENABLE_MUST_CHECK is not set
129CONFIG_DEBUG_FS=y
130CONFIG_DEBUG_KERNEL=y
131CONFIG_SLUB_DEBUG_ON=y
132CONFIG_DEBUG_KOBJECT=y
133CONFIG_DEBUG_INFO=y
134CONFIG_DEBUG_LIST=y
135CONFIG_DEBUG_USER=y
136CONFIG_DEBUG_ERRORS=y
137CONFIG_DEBUG_LL=y
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 062b58c029ab..749bb6622404 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -238,7 +238,7 @@
238 @ Slightly optimised to avoid incrementing the pointer twice 238 @ Slightly optimised to avoid incrementing the pointer twice
239 usraccoff \instr, \reg, \ptr, \inc, 0, \cond, \abort 239 usraccoff \instr, \reg, \ptr, \inc, 0, \cond, \abort
240 .if \rept == 2 240 .if \rept == 2
241 usraccoff \instr, \reg, \ptr, \inc, 4, \cond, \abort 241 usraccoff \instr, \reg, \ptr, \inc, \inc, \cond, \abort
242 .endif 242 .endif
243 243
244 add\cond \ptr, #\rept * \inc 244 add\cond \ptr, #\rept * \inc
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 68870c776671..b4ffe9d5b526 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -13,6 +13,10 @@ typedef struct {
13 13
14#ifdef CONFIG_CPU_HAS_ASID 14#ifdef CONFIG_CPU_HAS_ASID
15#define ASID(mm) ((mm)->context.id & 255) 15#define ASID(mm) ((mm)->context.id & 255)
16
17/* init_mm.context.id_lock should be initialized. */
18#define INIT_MM_CONTEXT(name) \
19 .context.id_lock = __SPIN_LOCK_UNLOCKED(name.context.id_lock),
16#else 20#else
17#define ASID(mm) (0) 21#define ASID(mm) (0)
18#endif 22#endif
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index b155414192da..53d1d5deb111 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -374,6 +374,9 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
374 374
375#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd))) 375#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd)))
376 376
377/* we don't need complex calculations here as the pmd is folded into the pgd */
378#define pmd_addr_end(addr,end) (end)
379
377/* 380/*
378 * Conversion functions: convert a page and protection to a page entry, 381 * Conversion functions: convert a page and protection to a page entry,
379 * and a page entry and page directory to the page they refer to. 382 * and a page entry and page directory to the page they refer to.
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index c09e3573c5de..bb96a7d4bbf5 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -911,7 +911,7 @@ __kuser_cmpxchg: @ 0xffff0fc0
911 * A special ghost syscall is used for that (see traps.c). 911 * A special ghost syscall is used for that (see traps.c).
912 */ 912 */
913 stmfd sp!, {r7, lr} 913 stmfd sp!, {r7, lr}
914 ldr r7, =1f @ it's 20 bits 914 ldr r7, 1f @ it's 20 bits
915 swi __ARM_NR_cmpxchg 915 swi __ARM_NR_cmpxchg
916 ldmfd sp!, {r7, pc} 916 ldmfd sp!, {r7, pc}
9171: .word __ARM_NR_cmpxchg 9171: .word __ARM_NR_cmpxchg
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index dd6b369ac69c..6bd82d25683c 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -85,9 +85,11 @@ ENTRY(stext)
85 mrc p15, 0, r9, c0, c0 @ get processor id 85 mrc p15, 0, r9, c0, c0 @ get processor id
86 bl __lookup_processor_type @ r5=procinfo r9=cpuid 86 bl __lookup_processor_type @ r5=procinfo r9=cpuid
87 movs r10, r5 @ invalid processor (r5=0)? 87 movs r10, r5 @ invalid processor (r5=0)?
88 THUMB( it eq ) @ force fixup-able long branch encoding
88 beq __error_p @ yes, error 'p' 89 beq __error_p @ yes, error 'p'
89 bl __lookup_machine_type @ r5=machinfo 90 bl __lookup_machine_type @ r5=machinfo
90 movs r8, r5 @ invalid machine (r5=0)? 91 movs r8, r5 @ invalid machine (r5=0)?
92 THUMB( it eq ) @ force fixup-able long branch encoding
91 beq __error_a @ yes, error 'a' 93 beq __error_a @ yes, error 'a'
92 bl __vet_atags 94 bl __vet_atags
93#ifdef CONFIG_SMP_ON_UP 95#ifdef CONFIG_SMP_ON_UP
@@ -262,6 +264,7 @@ __create_page_tables:
262 mov pc, lr 264 mov pc, lr
263ENDPROC(__create_page_tables) 265ENDPROC(__create_page_tables)
264 .ltorg 266 .ltorg
267 .align
265__enable_mmu_loc: 268__enable_mmu_loc:
266 .long . 269 .long .
267 .long __enable_mmu 270 .long __enable_mmu
@@ -282,6 +285,7 @@ ENTRY(secondary_startup)
282 bl __lookup_processor_type 285 bl __lookup_processor_type
283 movs r10, r5 @ invalid processor? 286 movs r10, r5 @ invalid processor?
284 moveq r0, #'p' @ yes, error 'p' 287 moveq r0, #'p' @ yes, error 'p'
288 THUMB( it eq ) @ force fixup-able long branch encoding
285 beq __error_p 289 beq __error_p
286 290
287 /* 291 /*
@@ -308,6 +312,8 @@ ENTRY(__secondary_switched)
308 b secondary_start_kernel 312 b secondary_start_kernel
309ENDPROC(__secondary_switched) 313ENDPROC(__secondary_switched)
310 314
315 .align
316
311 .type __secondary_data, %object 317 .type __secondary_data, %object
312__secondary_data: 318__secondary_data:
313 .long . 319 .long .
@@ -413,6 +419,7 @@ __fixup_smp_on_up:
413 mov pc, lr 419 mov pc, lr
414ENDPROC(__fixup_smp) 420ENDPROC(__fixup_smp)
415 421
422 .align
4161: .word . 4231: .word .
417 .word __smpalt_begin 424 .word __smpalt_begin
418 .word __smpalt_end 425 .word __smpalt_end
diff --git a/arch/arm/kernel/relocate_kernel.S b/arch/arm/kernel/relocate_kernel.S
index fd26f8d65151..9cf4cbf8f95b 100644
--- a/arch/arm/kernel/relocate_kernel.S
+++ b/arch/arm/kernel/relocate_kernel.S
@@ -59,6 +59,8 @@ relocate_new_kernel:
59 ldr r2,kexec_boot_atags 59 ldr r2,kexec_boot_atags
60 mov pc,lr 60 mov pc,lr
61 61
62 .align
63
62 .globl kexec_start_address 64 .globl kexec_start_address
63kexec_start_address: 65kexec_start_address:
64 .long 0x0 66 .long 0x0
diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S
index 1e4cbd4e7be9..64f6bc1a9132 100644
--- a/arch/arm/lib/findbit.S
+++ b/arch/arm/lib/findbit.S
@@ -174,8 +174,8 @@ ENDPROC(_find_next_bit_be)
174 */ 174 */
175.L_found: 175.L_found:
176#if __LINUX_ARM_ARCH__ >= 5 176#if __LINUX_ARM_ARCH__ >= 5
177 rsb r1, r3, #0 177 rsb r0, r3, #0
178 and r3, r3, r1 178 and r3, r3, r0
179 clz r3, r3 179 clz r3, r3
180 rsb r3, r3, #31 180 rsb r3, r3, #31
181 add r0, r2, r3 181 add r0, r2, r3
@@ -190,5 +190,7 @@ ENDPROC(_find_next_bit_be)
190 addeq r2, r2, #1 190 addeq r2, r2, #1
191 mov r0, r2 191 mov r0, r2
192#endif 192#endif
193 cmp r1, r0 @ Clamp to maxbit
194 movlo r0, r1
193 mov pc, lr 195 mov pc, lr
194 196
diff --git a/arch/arm/mach-aaec2000/include/mach/vmalloc.h b/arch/arm/mach-aaec2000/include/mach/vmalloc.h
index cff4e0a996ce..a6299e8321bd 100644
--- a/arch/arm/mach-aaec2000/include/mach/vmalloc.h
+++ b/arch/arm/mach-aaec2000/include/mach/vmalloc.h
@@ -11,6 +11,6 @@
11#ifndef __ASM_ARCH_VMALLOC_H 11#ifndef __ASM_ARCH_VMALLOC_H
12#define __ASM_ARCH_VMALLOC_H 12#define __ASM_ARCH_VMALLOC_H
13 13
14#define VMALLOC_END 0xd0000000 14#define VMALLOC_END 0xd0000000UL
15 15
16#endif /* __ASM_ARCH_VMALLOC_H */ 16#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 821eb842795f..d13add71f72a 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -24,8 +24,8 @@ obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o
24 24
25# AT91RM9200 board-specific support 25# AT91RM9200 board-specific support
26obj-$(CONFIG_MACH_ONEARM) += board-1arm.o 26obj-$(CONFIG_MACH_ONEARM) += board-1arm.o
27obj-$(CONFIG_ARCH_AT91RM9200DK) += board-dk.o 27obj-$(CONFIG_ARCH_AT91RM9200DK) += board-rm9200dk.o
28obj-$(CONFIG_MACH_AT91RM9200EK) += board-ek.o 28obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o
29obj-$(CONFIG_MACH_CSB337) += board-csb337.o 29obj-$(CONFIG_MACH_CSB337) += board-csb337.o
30obj-$(CONFIG_MACH_CSB637) += board-csb637.o 30obj-$(CONFIG_MACH_CSB637) += board-csb637.o
31obj-$(CONFIG_MACH_CARMEVA) += board-carmeva.o 31obj-$(CONFIG_MACH_CARMEVA) += board-carmeva.o
@@ -65,7 +65,7 @@ obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.o
65obj-$(CONFIG_MACH_CPU9G20) += board-cpu9krea.o 65obj-$(CONFIG_MACH_CPU9G20) += board-cpu9krea.o
66obj-$(CONFIG_MACH_STAMP9G20) += board-stamp9g20.o 66obj-$(CONFIG_MACH_STAMP9G20) += board-stamp9g20.o
67obj-$(CONFIG_MACH_PORTUXG20) += board-stamp9g20.o 67obj-$(CONFIG_MACH_PORTUXG20) += board-stamp9g20.o
68obj-$(CONFIG_MACH_PCONTROL_G20) += board-pcontrol-g20.o 68obj-$(CONFIG_MACH_PCONTROL_G20) += board-pcontrol-g20.o board-stamp9g20.o
69 69
70# AT91SAM9260/AT91SAM9G20 board-specific support 70# AT91SAM9260/AT91SAM9G20 board-specific support
71obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o 71obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 9338825cfcd7..7b539228e0ef 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -1106,51 +1106,6 @@ static inline void configure_usart3_pins(unsigned pins)
1106static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1106static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1107struct platform_device *atmel_default_console_device; /* the serial console device */ 1107struct platform_device *atmel_default_console_device; /* the serial console device */
1108 1108
1109void __init __deprecated at91_init_serial(struct at91_uart_config *config)
1110{
1111 int i;
1112
1113 /* Fill in list of supported UARTs */
1114 for (i = 0; i < config->nr_tty; i++) {
1115 switch (config->tty_map[i]) {
1116 case 0:
1117 configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
1118 at91_uarts[i] = &at91rm9200_uart0_device;
1119 at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart");
1120 break;
1121 case 1:
1122 configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DSR | ATMEL_UART_DTR | ATMEL_UART_DCD | ATMEL_UART_RI);
1123 at91_uarts[i] = &at91rm9200_uart1_device;
1124 at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart");
1125 break;
1126 case 2:
1127 configure_usart2_pins(0);
1128 at91_uarts[i] = &at91rm9200_uart2_device;
1129 at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart");
1130 break;
1131 case 3:
1132 configure_usart3_pins(0);
1133 at91_uarts[i] = &at91rm9200_uart3_device;
1134 at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart");
1135 break;
1136 case 4:
1137 configure_dbgu_pins();
1138 at91_uarts[i] = &at91rm9200_dbgu_device;
1139 at91_clock_associate("mck", &at91rm9200_dbgu_device.dev, "usart");
1140 break;
1141 default:
1142 continue;
1143 }
1144 at91_uarts[i]->id = i; /* update ID number to mapped ID */
1145 }
1146
1147 /* Set serial console device */
1148 if (config->console_tty < ATMEL_MAX_UART)
1149 atmel_default_console_device = at91_uarts[config->console_tty];
1150 if (!atmel_default_console_device)
1151 printk(KERN_INFO "AT91: No default serial console defined.\n");
1152}
1153
1154void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1109void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1155{ 1110{
1156 struct platform_device *pdev; 1111 struct platform_device *pdev;
diff --git a/arch/arm/mach-at91/board-1arm.c b/arch/arm/mach-at91/board-1arm.c
index 46bdc82d3fbf..8a3fc84847c1 100644
--- a/arch/arm/mach-at91/board-1arm.c
+++ b/arch/arm/mach-at91/board-1arm.c
@@ -39,24 +39,24 @@
39#include "generic.h" 39#include "generic.h"
40 40
41 41
42/*
43 * Serial port configuration.
44 * 0 .. 3 = USART0 .. USART3
45 * 4 = DBGU
46 */
47static struct at91_uart_config __initdata onearm_uart_config = {
48 .console_tty = 0, /* ttyS0 */
49 .nr_tty = 3,
50 .tty_map = { 4, 0, 1, -1, -1 }, /* ttyS0, ..., ttyS4 */
51};
52
53static void __init onearm_map_io(void) 42static void __init onearm_map_io(void)
54{ 43{
55 /* Initialize processor: 18.432 MHz crystal */ 44 /* Initialize processor: 18.432 MHz crystal */
56 at91rm9200_initialize(18432000, AT91RM9200_PQFP); 45 at91rm9200_initialize(18432000, AT91RM9200_PQFP);
57 46
58 /* Setup the serial ports and console */ 47 /* DBGU on ttyS0. (Rx & Tx only) */
59 at91_init_serial(&onearm_uart_config); 48 at91_register_uart(0, 0, 0);
49
50 /* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */
51 at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
52
53 /* USART1 on ttyS2 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
54 at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS
55 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
56 | ATMEL_UART_RI);
57
58 /* set serial console to ttyS0 (ie, DBGU) */
59 at91_set_serial_console(0);
60} 60}
61 61
62static void __init onearm_init_irq(void) 62static void __init onearm_init_irq(void)
diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c
index c0ce79d431a0..d2e1f4ec1fcc 100644
--- a/arch/arm/mach-at91/board-kafa.c
+++ b/arch/arm/mach-at91/board-kafa.c
@@ -39,17 +39,6 @@
39#include "generic.h" 39#include "generic.h"
40 40
41 41
42/*
43 * Serial port configuration.
44 * 0 .. 3 = USART0 .. USART3
45 * 4 = DBGU
46 */
47static struct at91_uart_config __initdata kafa_uart_config = {
48 .console_tty = 0, /* ttyS0 */
49 .nr_tty = 2,
50 .tty_map = { 4, 0, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
51};
52
53static void __init kafa_map_io(void) 42static void __init kafa_map_io(void)
54{ 43{
55 /* Initialize processor: 18.432 MHz crystal */ 44 /* Initialize processor: 18.432 MHz crystal */
@@ -58,8 +47,14 @@ static void __init kafa_map_io(void)
58 /* Set up the LEDs */ 47 /* Set up the LEDs */
59 at91_init_leds(AT91_PIN_PB4, AT91_PIN_PB4); 48 at91_init_leds(AT91_PIN_PB4, AT91_PIN_PB4);
60 49
61 /* Setup the serial ports and console */ 50 /* DBGU on ttyS0. (Rx & Tx only) */
62 at91_init_serial(&kafa_uart_config); 51 at91_register_uart(0, 0, 0);
52
53 /* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */
54 at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
55
56 /* set serial console to ttyS0 (ie, DBGU) */
57 at91_set_serial_console(0);
63} 58}
64 59
65static void __init kafa_init_irq(void) 60static void __init kafa_init_irq(void)
diff --git a/arch/arm/mach-at91/board-pcontrol-g20.c b/arch/arm/mach-at91/board-pcontrol-g20.c
index bba5a560e02b..feb65787c30b 100644
--- a/arch/arm/mach-at91/board-pcontrol-g20.c
+++ b/arch/arm/mach-at91/board-pcontrol-g20.c
@@ -31,6 +31,7 @@
31 31
32#include <mach/board.h> 32#include <mach/board.h>
33#include <mach/at91sam9_smc.h> 33#include <mach/at91sam9_smc.h>
34#include <mach/stamp9g20.h>
34 35
35#include "sam9_smc.h" 36#include "sam9_smc.h"
36#include "generic.h" 37#include "generic.h"
@@ -38,11 +39,7 @@
38 39
39static void __init pcontrol_g20_map_io(void) 40static void __init pcontrol_g20_map_io(void)
40{ 41{
41 /* Initialize processor: 18.432 MHz crystal */ 42 stamp9g20_map_io();
42 at91sam9260_initialize(18432000);
43
44 /* DGBU on ttyS0. (Rx, Tx) only TTL -> JTAG connector X7 17,19 ) */
45 at91_register_uart(0, 0, 0);
46 43
47 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback A2 */ 44 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback A2 */
48 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS 45 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS
@@ -54,9 +51,6 @@ static void __init pcontrol_g20_map_io(void)
54 51
55 /* USART2 on ttyS3. (Rx, Tx) 9bit-Bus Multidrop-mode X4 */ 52 /* USART2 on ttyS3. (Rx, Tx) 9bit-Bus Multidrop-mode X4 */
56 at91_register_uart(AT91SAM9260_ID_US4, 3, 0); 53 at91_register_uart(AT91SAM9260_ID_US4, 3, 0);
57
58 /* set serial console to ttyS0 (ie, DBGU) */
59 at91_set_serial_console(0);
60} 54}
61 55
62 56
@@ -66,38 +60,6 @@ static void __init init_irq(void)
66} 60}
67 61
68 62
69/*
70 * NAND flash 512MiB 1,8V 8-bit, sector size 128 KiB
71 */
72static struct atmel_nand_data __initdata nand_data = {
73 .ale = 21,
74 .cle = 22,
75 .rdy_pin = AT91_PIN_PC13,
76 .enable_pin = AT91_PIN_PC14,
77};
78
79/*
80 * Bus timings; unit = 7.57ns
81 */
82static struct sam9_smc_config __initdata nand_smc_config = {
83 .ncs_read_setup = 0,
84 .nrd_setup = 2,
85 .ncs_write_setup = 0,
86 .nwe_setup = 2,
87
88 .ncs_read_pulse = 4,
89 .nrd_pulse = 4,
90 .ncs_write_pulse = 4,
91 .nwe_pulse = 4,
92
93 .read_cycle = 7,
94 .write_cycle = 7,
95
96 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
97 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
98 .tdf_cycles = 3,
99};
100
101static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { { 63static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {
102 .ncs_read_setup = 16, 64 .ncs_read_setup = 16,
103 .nrd_setup = 18, 65 .nrd_setup = 18,
@@ -138,14 +100,6 @@ static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {
138 .tdf_cycles = 1, 100 .tdf_cycles = 1,
139} }; 101} };
140 102
141static void __init add_device_nand(void)
142{
143 /* configure chip-select 3 (NAND) */
144 sam9_smc_configure(3, &nand_smc_config);
145 at91_add_device_nand(&nand_data);
146}
147
148
149static void __init add_device_pcontrol(void) 103static void __init add_device_pcontrol(void)
150{ 104{
151 /* configure chip-select 4 (IO compatible to 8051 X4 ) */ 105 /* configure chip-select 4 (IO compatible to 8051 X4 ) */
@@ -156,23 +110,6 @@ static void __init add_device_pcontrol(void)
156 110
157 111
158/* 112/*
159 * MCI (SD/MMC)
160 * det_pin, wp_pin and vcc_pin are not connected
161 */
162#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
163static struct mci_platform_data __initdata mmc_data = {
164 .slot[0] = {
165 .bus_width = 4,
166 },
167};
168#else
169static struct at91_mmc_data __initdata mmc_data = {
170 .wire4 = 1,
171};
172#endif
173
174
175/*
176 * USB Host port 113 * USB Host port
177 */ 114 */
178static struct at91_usbh_data __initdata usbh_data = { 115static struct at91_usbh_data __initdata usbh_data = {
@@ -265,42 +202,13 @@ static struct spi_board_info pcontrol_g20_spi_devices[] = {
265}; 202};
266 203
267 204
268/*
269 * Dallas 1-Wire DS2431
270 */
271static struct w1_gpio_platform_data w1_gpio_pdata = {
272 .pin = AT91_PIN_PA29,
273 .is_open_drain = 1,
274};
275
276static struct platform_device w1_device = {
277 .name = "w1-gpio",
278 .id = -1,
279 .dev.platform_data = &w1_gpio_pdata,
280};
281
282static void add_wire1(void)
283{
284 at91_set_GPIO_periph(w1_gpio_pdata.pin, 1);
285 at91_set_multi_drive(w1_gpio_pdata.pin, 1);
286 platform_device_register(&w1_device);
287}
288
289
290static void __init pcontrol_g20_board_init(void) 205static void __init pcontrol_g20_board_init(void)
291{ 206{
292 at91_add_device_serial(); 207 stamp9g20_board_init();
293 add_device_nand();
294#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
295 at91_add_device_mci(0, &mmc_data);
296#else
297 at91_add_device_mmc(0, &mmc_data);
298#endif
299 at91_add_device_usbh(&usbh_data); 208 at91_add_device_usbh(&usbh_data);
300 at91_add_device_eth(&macb_data); 209 at91_add_device_eth(&macb_data);
301 at91_add_device_i2c(pcontrol_g20_i2c_devices, 210 at91_add_device_i2c(pcontrol_g20_i2c_devices,
302 ARRAY_SIZE(pcontrol_g20_i2c_devices)); 211 ARRAY_SIZE(pcontrol_g20_i2c_devices));
303 add_wire1();
304 add_device_pcontrol(); 212 add_device_pcontrol();
305 at91_add_device_spi(pcontrol_g20_spi_devices, 213 at91_add_device_spi(pcontrol_g20_spi_devices,
306 ARRAY_SIZE(pcontrol_g20_spi_devices)); 214 ARRAY_SIZE(pcontrol_g20_spi_devices));
diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c
index 9d833bbc592d..55dad3a46547 100644
--- a/arch/arm/mach-at91/board-picotux200.c
+++ b/arch/arm/mach-at91/board-picotux200.c
@@ -43,24 +43,21 @@
43#include "generic.h" 43#include "generic.h"
44 44
45 45
46/*
47 * Serial port configuration.
48 * 0 .. 3 = USART0 .. USART3
49 * 4 = DBGU
50 */
51static struct at91_uart_config __initdata picotux200_uart_config = {
52 .console_tty = 0, /* ttyS0 */
53 .nr_tty = 2,
54 .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
55};
56
57static void __init picotux200_map_io(void) 46static void __init picotux200_map_io(void)
58{ 47{
59 /* Initialize processor: 18.432 MHz crystal */ 48 /* Initialize processor: 18.432 MHz crystal */
60 at91rm9200_initialize(18432000, AT91RM9200_BGA); 49 at91rm9200_initialize(18432000, AT91RM9200_BGA);
61 50
62 /* Setup the serial ports and console */ 51 /* DBGU on ttyS0. (Rx & Tx only) */
63 at91_init_serial(&picotux200_uart_config); 52 at91_register_uart(0, 0, 0);
53
54 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
55 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
56 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
57 | ATMEL_UART_RI);
58
59 /* set serial console to ttyS0 (ie, DBGU) */
60 at91_set_serial_console(0);
64} 61}
65 62
66static void __init picotux200_init_irq(void) 63static void __init picotux200_init_irq(void)
@@ -77,11 +74,6 @@ static struct at91_usbh_data __initdata picotux200_usbh_data = {
77 .ports = 1, 74 .ports = 1,
78}; 75};
79 76
80// static struct at91_udc_data __initdata picotux200_udc_data = {
81// .vbus_pin = AT91_PIN_PD4,
82// .pullup_pin = AT91_PIN_PD5,
83// };
84
85static struct at91_mmc_data __initdata picotux200_mmc_data = { 77static struct at91_mmc_data __initdata picotux200_mmc_data = {
86 .det_pin = AT91_PIN_PB27, 78 .det_pin = AT91_PIN_PB27,
87 .slot_b = 0, 79 .slot_b = 0,
@@ -89,21 +81,6 @@ static struct at91_mmc_data __initdata picotux200_mmc_data = {
89 .wp_pin = AT91_PIN_PA17, 81 .wp_pin = AT91_PIN_PA17,
90}; 82};
91 83
92// static struct spi_board_info picotux200_spi_devices[] = {
93// { /* DataFlash chip */
94// .modalias = "mtd_dataflash",
95// .chip_select = 0,
96// .max_speed_hz = 15 * 1000 * 1000,
97// },
98// #ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
99// { /* DataFlash card */
100// .modalias = "mtd_dataflash",
101// .chip_select = 3,
102// .max_speed_hz = 15 * 1000 * 1000,
103// },
104// #endif
105// };
106
107#define PICOTUX200_FLASH_BASE AT91_CHIPSELECT_0 84#define PICOTUX200_FLASH_BASE AT91_CHIPSELECT_0
108#define PICOTUX200_FLASH_SIZE SZ_4M 85#define PICOTUX200_FLASH_SIZE SZ_4M
109 86
@@ -135,21 +112,11 @@ static void __init picotux200_board_init(void)
135 at91_add_device_eth(&picotux200_eth_data); 112 at91_add_device_eth(&picotux200_eth_data);
136 /* USB Host */ 113 /* USB Host */
137 at91_add_device_usbh(&picotux200_usbh_data); 114 at91_add_device_usbh(&picotux200_usbh_data);
138 /* USB Device */
139 // at91_add_device_udc(&picotux200_udc_data);
140 // at91_set_multi_drive(picotux200_udc_data.pullup_pin, 1); /* pullup_pin is connected to reset */
141 /* I2C */ 115 /* I2C */
142 at91_add_device_i2c(NULL, 0); 116 at91_add_device_i2c(NULL, 0);
143 /* SPI */
144 // at91_add_device_spi(picotux200_spi_devices, ARRAY_SIZE(picotux200_spi_devices));
145#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
146 /* DataFlash card */
147 at91_set_gpio_output(AT91_PIN_PB22, 0);
148#else
149 /* MMC */ 117 /* MMC */
150 at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */ 118 at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
151 at91_add_device_mmc(0, &picotux200_mmc_data); 119 at91_add_device_mmc(0, &picotux200_mmc_data);
152#endif
153 /* NOR Flash */ 120 /* NOR Flash */
154 platform_device_register(&picotux200_flash); 121 platform_device_register(&picotux200_flash);
155} 122}
diff --git a/arch/arm/mach-at91/board-dk.c b/arch/arm/mach-at91/board-rm9200dk.c
index e14f0e165680..4c1047c8200d 100644
--- a/arch/arm/mach-at91/board-dk.c
+++ b/arch/arm/mach-at91/board-rm9200dk.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/arm/mach-at91/board-dk.c 2 * linux/arch/arm/mach-at91/board-rm9200dk.c
3 * 3 *
4 * Copyright (C) 2005 SAN People 4 * Copyright (C) 2005 SAN People
5 * 5 *
@@ -91,10 +91,12 @@ static struct at91_cf_data __initdata dk_cf_data = {
91 // .vcc_pin = ... always powered 91 // .vcc_pin = ... always powered
92}; 92};
93 93
94#ifndef CONFIG_MTD_AT91_DATAFLASH_CARD
94static struct at91_mmc_data __initdata dk_mmc_data = { 95static struct at91_mmc_data __initdata dk_mmc_data = {
95 .slot_b = 0, 96 .slot_b = 0,
96 .wire4 = 1, 97 .wire4 = 1,
97}; 98};
99#endif
98 100
99static struct spi_board_info dk_spi_devices[] = { 101static struct spi_board_info dk_spi_devices[] = {
100 { /* DataFlash chip */ 102 { /* DataFlash chip */
diff --git a/arch/arm/mach-at91/board-ek.c b/arch/arm/mach-at91/board-rm9200ek.c
index 56e92c4bbc2a..9df1be8818c0 100644
--- a/arch/arm/mach-at91/board-ek.c
+++ b/arch/arm/mach-at91/board-rm9200ek.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/arm/mach-at91/board-ek.c 2 * linux/arch/arm/mach-at91/board-rm9200ek.c
3 * 3 *
4 * Copyright (C) 2005 SAN People 4 * Copyright (C) 2005 SAN People
5 * 5 *
@@ -84,12 +84,14 @@ static struct at91_udc_data __initdata ek_udc_data = {
84 .pullup_pin = AT91_PIN_PD5, 84 .pullup_pin = AT91_PIN_PD5,
85}; 85};
86 86
87#ifndef CONFIG_MTD_AT91_DATAFLASH_CARD
87static struct at91_mmc_data __initdata ek_mmc_data = { 88static struct at91_mmc_data __initdata ek_mmc_data = {
88 .det_pin = AT91_PIN_PB27, 89 .det_pin = AT91_PIN_PB27,
89 .slot_b = 0, 90 .slot_b = 0,
90 .wire4 = 1, 91 .wire4 = 1,
91 .wp_pin = AT91_PIN_PA17, 92 .wp_pin = AT91_PIN_PA17,
92}; 93};
94#endif
93 95
94static struct spi_board_info ek_spi_devices[] = { 96static struct spi_board_info ek_spi_devices[] = {
95 { /* DataFlash chip */ 97 { /* DataFlash chip */
diff --git a/arch/arm/mach-at91/board-stamp9g20.c b/arch/arm/mach-at91/board-stamp9g20.c
index 5206eef4a67e..f8902b118960 100644
--- a/arch/arm/mach-at91/board-stamp9g20.c
+++ b/arch/arm/mach-at91/board-stamp9g20.c
@@ -32,7 +32,7 @@
32#include "generic.h" 32#include "generic.h"
33 33
34 34
35static void __init portuxg20_map_io(void) 35void __init stamp9g20_map_io(void)
36{ 36{
37 /* Initialize processor: 18.432 MHz crystal */ 37 /* Initialize processor: 18.432 MHz crystal */
38 at91sam9260_initialize(18432000); 38 at91sam9260_initialize(18432000);
@@ -40,6 +40,24 @@ static void __init portuxg20_map_io(void)
40 /* DGBU on ttyS0. (Rx & Tx only) */ 40 /* DGBU on ttyS0. (Rx & Tx only) */
41 at91_register_uart(0, 0, 0); 41 at91_register_uart(0, 0, 0);
42 42
43 /* set serial console to ttyS0 (ie, DBGU) */
44 at91_set_serial_console(0);
45}
46
47static void __init stamp9g20evb_map_io(void)
48{
49 stamp9g20_map_io();
50
51 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
52 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
53 | ATMEL_UART_DTR | ATMEL_UART_DSR
54 | ATMEL_UART_DCD | ATMEL_UART_RI);
55}
56
57static void __init portuxg20_map_io(void)
58{
59 stamp9g20_map_io();
60
43 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ 61 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
44 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS 62 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
45 | ATMEL_UART_DTR | ATMEL_UART_DSR 63 | ATMEL_UART_DTR | ATMEL_UART_DSR
@@ -56,26 +74,6 @@ static void __init portuxg20_map_io(void)
56 74
57 /* USART5 on ttyS6. (Rx, Tx only) */ 75 /* USART5 on ttyS6. (Rx, Tx only) */
58 at91_register_uart(AT91SAM9260_ID_US5, 6, 0); 76 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
59
60 /* set serial console to ttyS0 (ie, DBGU) */
61 at91_set_serial_console(0);
62}
63
64static void __init stamp9g20_map_io(void)
65{
66 /* Initialize processor: 18.432 MHz crystal */
67 at91sam9260_initialize(18432000);
68
69 /* DGBU on ttyS0. (Rx & Tx only) */
70 at91_register_uart(0, 0, 0);
71
72 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
73 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
74 | ATMEL_UART_DTR | ATMEL_UART_DSR
75 | ATMEL_UART_DCD | ATMEL_UART_RI);
76
77 /* set serial console to ttyS0 (ie, DBGU) */
78 at91_set_serial_console(0);
79} 77}
80 78
81static void __init init_irq(void) 79static void __init init_irq(void)
@@ -156,7 +154,7 @@ static struct at91_udc_data __initdata portuxg20_udc_data = {
156 .pullup_pin = 0, /* pull-up driven by UDC */ 154 .pullup_pin = 0, /* pull-up driven by UDC */
157}; 155};
158 156
159static struct at91_udc_data __initdata stamp9g20_udc_data = { 157static struct at91_udc_data __initdata stamp9g20evb_udc_data = {
160 .vbus_pin = AT91_PIN_PA22, 158 .vbus_pin = AT91_PIN_PA22,
161 .pullup_pin = 0, /* pull-up driven by UDC */ 159 .pullup_pin = 0, /* pull-up driven by UDC */
162}; 160};
@@ -190,7 +188,7 @@ static struct gpio_led portuxg20_leds[] = {
190 } 188 }
191}; 189};
192 190
193static struct gpio_led stamp9g20_leds[] = { 191static struct gpio_led stamp9g20evb_leds[] = {
194 { 192 {
195 .name = "D8", 193 .name = "D8",
196 .gpio = AT91_PIN_PB18, 194 .gpio = AT91_PIN_PB18,
@@ -250,7 +248,7 @@ void add_w1(void)
250} 248}
251 249
252 250
253static void __init generic_board_init(void) 251void __init stamp9g20_board_init(void)
254{ 252{
255 /* Serial */ 253 /* Serial */
256 at91_add_device_serial(); 254 at91_add_device_serial();
@@ -262,34 +260,40 @@ static void __init generic_board_init(void)
262#else 260#else
263 at91_add_device_mmc(0, &mmc_data); 261 at91_add_device_mmc(0, &mmc_data);
264#endif 262#endif
265 /* USB Host */
266 at91_add_device_usbh(&usbh_data);
267 /* Ethernet */
268 at91_add_device_eth(&macb_data);
269 /* I2C */
270 at91_add_device_i2c(NULL, 0);
271 /* W1 */ 263 /* W1 */
272 add_w1(); 264 add_w1();
273} 265}
274 266
275static void __init portuxg20_board_init(void) 267static void __init portuxg20_board_init(void)
276{ 268{
277 generic_board_init(); 269 stamp9g20_board_init();
278 /* SPI */ 270 /* USB Host */
279 at91_add_device_spi(portuxg20_spi_devices, ARRAY_SIZE(portuxg20_spi_devices)); 271 at91_add_device_usbh(&usbh_data);
280 /* USB Device */ 272 /* USB Device */
281 at91_add_device_udc(&portuxg20_udc_data); 273 at91_add_device_udc(&portuxg20_udc_data);
274 /* Ethernet */
275 at91_add_device_eth(&macb_data);
276 /* I2C */
277 at91_add_device_i2c(NULL, 0);
278 /* SPI */
279 at91_add_device_spi(portuxg20_spi_devices, ARRAY_SIZE(portuxg20_spi_devices));
282 /* LEDs */ 280 /* LEDs */
283 at91_gpio_leds(portuxg20_leds, ARRAY_SIZE(portuxg20_leds)); 281 at91_gpio_leds(portuxg20_leds, ARRAY_SIZE(portuxg20_leds));
284} 282}
285 283
286static void __init stamp9g20_board_init(void) 284static void __init stamp9g20evb_board_init(void)
287{ 285{
288 generic_board_init(); 286 stamp9g20_board_init();
287 /* USB Host */
288 at91_add_device_usbh(&usbh_data);
289 /* USB Device */ 289 /* USB Device */
290 at91_add_device_udc(&stamp9g20_udc_data); 290 at91_add_device_udc(&stamp9g20evb_udc_data);
291 /* Ethernet */
292 at91_add_device_eth(&macb_data);
293 /* I2C */
294 at91_add_device_i2c(NULL, 0);
291 /* LEDs */ 295 /* LEDs */
292 at91_gpio_leds(stamp9g20_leds, ARRAY_SIZE(stamp9g20_leds)); 296 at91_gpio_leds(stamp9g20evb_leds, ARRAY_SIZE(stamp9g20evb_leds));
293} 297}
294 298
295MACHINE_START(PORTUXG20, "taskit PortuxG20") 299MACHINE_START(PORTUXG20, "taskit PortuxG20")
@@ -305,7 +309,7 @@ MACHINE_START(STAMP9G20, "taskit Stamp9G20")
305 /* Maintainer: taskit GmbH */ 309 /* Maintainer: taskit GmbH */
306 .boot_params = AT91_SDRAM_BASE + 0x100, 310 .boot_params = AT91_SDRAM_BASE + 0x100,
307 .timer = &at91sam926x_timer, 311 .timer = &at91sam926x_timer,
308 .map_io = stamp9g20_map_io, 312 .map_io = stamp9g20evb_map_io,
309 .init_irq = init_irq, 313 .init_irq = init_irq,
310 .init_machine = stamp9g20_board_init, 314 .init_machine = stamp9g20evb_board_init,
311MACHINE_END 315MACHINE_END
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index 89df00a9d2f7..e0f0080eb639 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -387,7 +387,7 @@ static struct spi_board_info yl9200_spi_devices[] = {
387 * EPSON S1D13806 FB (discontinued chip) 387 * EPSON S1D13806 FB (discontinued chip)
388 * EPSON S1D13506 FB 388 * EPSON S1D13506 FB
389 */ 389 */
390#if defined(CONFIG_FB_S1D135XX) || defined(CONFIG_FB_S1D13XXX_MODULE) 390#if defined(CONFIG_FB_S1D13XXX) || defined(CONFIG_FB_S1D13XXX_MODULE)
391#include <video/s1d13xxxfb.h> 391#include <video/s1d13xxxfb.h>
392 392
393 393
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index 7525cee3983f..9113da6845f1 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -658,7 +658,7 @@ static void __init at91_upll_usbfs_clock_init(unsigned long main_clock)
658 /* Now set uhpck values */ 658 /* Now set uhpck values */
659 uhpck.parent = &utmi_clk; 659 uhpck.parent = &utmi_clk;
660 uhpck.pmc_mask = AT91SAM926x_PMC_UHP; 660 uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
661 uhpck.rate_hz = utmi_clk.parent->rate_hz; 661 uhpck.rate_hz = utmi_clk.rate_hz;
662 uhpck.rate_hz /= 1 + ((at91_sys_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8); 662 uhpck.rate_hz /= 1 + ((at91_sys_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8);
663} 663}
664 664
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index 58528aa9c8a8..2b499eb343a1 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -137,13 +137,7 @@ extern void __init at91_add_device_spi(struct spi_board_info *devices, int nr_de
137extern void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins); 137extern void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins);
138extern void __init at91_set_serial_console(unsigned portnr); 138extern void __init at91_set_serial_console(unsigned portnr);
139 139
140struct at91_uart_config {
141 unsigned short console_tty; /* tty number of serial console */
142 unsigned short nr_tty; /* number of serial tty's */
143 short tty_map[]; /* map UART to tty number */
144};
145extern struct platform_device *atmel_default_console_device; 140extern struct platform_device *atmel_default_console_device;
146extern void __init __deprecated at91_init_serial(struct at91_uart_config *config);
147 141
148struct atmel_uart_data { 142struct atmel_uart_data {
149 short use_dma_tx; /* use transmit DMA? */ 143 short use_dma_tx; /* use transmit DMA? */
diff --git a/arch/arm/mach-at91/include/mach/stamp9g20.h b/arch/arm/mach-at91/include/mach/stamp9g20.h
new file mode 100644
index 000000000000..6120f9c46d59
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/stamp9g20.h
@@ -0,0 +1,7 @@
1#ifndef __MACH_STAMP9G20_H
2#define __MACH_STAMP9G20_H
3
4void stamp9g20_map_io(void);
5void stamp9g20_board_init(void);
6
7#endif
diff --git a/arch/arm/mach-bcmring/include/mach/vmalloc.h b/arch/arm/mach-bcmring/include/mach/vmalloc.h
index 3db3a09fd398..7397bd7817d9 100644
--- a/arch/arm/mach-bcmring/include/mach/vmalloc.h
+++ b/arch/arm/mach-bcmring/include/mach/vmalloc.h
@@ -22,4 +22,4 @@
22 * 0xe0000000 to 0xefffffff. This gives us 256 MB of vm space and handles 22 * 0xe0000000 to 0xefffffff. This gives us 256 MB of vm space and handles
23 * larger physical memory designs better. 23 * larger physical memory designs better.
24 */ 24 */
25#define VMALLOC_END 0xf0000000 25#define VMALLOC_END 0xf0000000UL
diff --git a/arch/arm/mach-clps711x/include/mach/vmalloc.h b/arch/arm/mach-clps711x/include/mach/vmalloc.h
index 30b3a287ed88..467b96137e47 100644
--- a/arch/arm/mach-clps711x/include/mach/vmalloc.h
+++ b/arch/arm/mach-clps711x/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * along with this program; if not, write to the Free Software 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 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#define VMALLOC_END 0xd0000000 20#define VMALLOC_END 0xd0000000UL
diff --git a/arch/arm/mach-cns3xxx/pcie.c b/arch/arm/mach-cns3xxx/pcie.c
index 38088c36936c..78defd71a829 100644
--- a/arch/arm/mach-cns3xxx/pcie.c
+++ b/arch/arm/mach-cns3xxx/pcie.c
@@ -369,7 +369,7 @@ static int __init cns3xxx_pcie_init(void)
369{ 369{
370 int i; 370 int i;
371 371
372 hook_fault_code(16 + 6, cns3xxx_pcie_abort_handler, SIGBUS, 372 hook_fault_code(16 + 6, cns3xxx_pcie_abort_handler, SIGBUS, 0,
373 "imprecise external abort"); 373 "imprecise external abort");
374 374
375 for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) { 375 for (i = 0; i < ARRAY_SIZE(cns3xxx_pcie); i++) {
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 9be261beae7d..2652af124acd 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -359,8 +359,8 @@ static struct clk_lookup dm355_clks[] = {
359 CLK(NULL, "uart1", &uart1_clk), 359 CLK(NULL, "uart1", &uart1_clk),
360 CLK(NULL, "uart2", &uart2_clk), 360 CLK(NULL, "uart2", &uart2_clk),
361 CLK("i2c_davinci.1", NULL, &i2c_clk), 361 CLK("i2c_davinci.1", NULL, &i2c_clk),
362 CLK("davinci-asp.0", NULL, &asp0_clk), 362 CLK("davinci-mcbsp.0", NULL, &asp0_clk),
363 CLK("davinci-asp.1", NULL, &asp1_clk), 363 CLK("davinci-mcbsp.1", NULL, &asp1_clk),
364 CLK("davinci_mmc.0", NULL, &mmcsd0_clk), 364 CLK("davinci_mmc.0", NULL, &mmcsd0_clk),
365 CLK("davinci_mmc.1", NULL, &mmcsd1_clk), 365 CLK("davinci_mmc.1", NULL, &mmcsd1_clk),
366 CLK("spi_davinci.0", NULL, &spi0_clk), 366 CLK("spi_davinci.0", NULL, &spi0_clk),
@@ -664,7 +664,7 @@ static struct resource dm355_asp1_resources[] = {
664}; 664};
665 665
666static struct platform_device dm355_asp1_device = { 666static struct platform_device dm355_asp1_device = {
667 .name = "davinci-asp", 667 .name = "davinci-mcbsp",
668 .id = 1, 668 .id = 1,
669 .num_resources = ARRAY_SIZE(dm355_asp1_resources), 669 .num_resources = ARRAY_SIZE(dm355_asp1_resources),
670 .resource = dm355_asp1_resources, 670 .resource = dm355_asp1_resources,
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index a12065e87266..c466d710d3c1 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -459,7 +459,7 @@ static struct clk_lookup dm365_clks[] = {
459 CLK(NULL, "usb", &usb_clk), 459 CLK(NULL, "usb", &usb_clk),
460 CLK("davinci_emac.1", NULL, &emac_clk), 460 CLK("davinci_emac.1", NULL, &emac_clk),
461 CLK("davinci_voicecodec", NULL, &voicecodec_clk), 461 CLK("davinci_voicecodec", NULL, &voicecodec_clk),
462 CLK("davinci-asp.0", NULL, &asp0_clk), 462 CLK("davinci-mcbsp", NULL, &asp0_clk),
463 CLK(NULL, "rto", &rto_clk), 463 CLK(NULL, "rto", &rto_clk),
464 CLK(NULL, "mjcp", &mjcp_clk), 464 CLK(NULL, "mjcp", &mjcp_clk),
465 CLK(NULL, NULL, NULL), 465 CLK(NULL, NULL, NULL),
@@ -922,8 +922,8 @@ static struct resource dm365_asp_resources[] = {
922}; 922};
923 923
924static struct platform_device dm365_asp_device = { 924static struct platform_device dm365_asp_device = {
925 .name = "davinci-asp", 925 .name = "davinci-mcbsp",
926 .id = 0, 926 .id = -1,
927 .num_resources = ARRAY_SIZE(dm365_asp_resources), 927 .num_resources = ARRAY_SIZE(dm365_asp_resources),
928 .resource = dm365_asp_resources, 928 .resource = dm365_asp_resources,
929}; 929};
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 0608dd776a16..9a2376b3137c 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -302,7 +302,7 @@ static struct clk_lookup dm644x_clks[] = {
302 CLK("davinci_emac.1", NULL, &emac_clk), 302 CLK("davinci_emac.1", NULL, &emac_clk),
303 CLK("i2c_davinci.1", NULL, &i2c_clk), 303 CLK("i2c_davinci.1", NULL, &i2c_clk),
304 CLK("palm_bk3710", NULL, &ide_clk), 304 CLK("palm_bk3710", NULL, &ide_clk),
305 CLK("davinci-asp", NULL, &asp_clk), 305 CLK("davinci-mcbsp", NULL, &asp_clk),
306 CLK("davinci_mmc.0", NULL, &mmcsd_clk), 306 CLK("davinci_mmc.0", NULL, &mmcsd_clk),
307 CLK(NULL, "spi", &spi_clk), 307 CLK(NULL, "spi", &spi_clk),
308 CLK(NULL, "gpio", &gpio_clk), 308 CLK(NULL, "gpio", &gpio_clk),
@@ -580,7 +580,7 @@ static struct resource dm644x_asp_resources[] = {
580}; 580};
581 581
582static struct platform_device dm644x_asp_device = { 582static struct platform_device dm644x_asp_device = {
583 .name = "davinci-asp", 583 .name = "davinci-mcbsp",
584 .id = -1, 584 .id = -1,
585 .num_resources = ARRAY_SIZE(dm644x_asp_resources), 585 .num_resources = ARRAY_SIZE(dm644x_asp_resources),
586 .resource = dm644x_asp_resources, 586 .resource = dm644x_asp_resources,
diff --git a/arch/arm/mach-ebsa110/include/mach/vmalloc.h b/arch/arm/mach-ebsa110/include/mach/vmalloc.h
index 60bde56fba4c..ea141b7a3e03 100644
--- a/arch/arm/mach-ebsa110/include/mach/vmalloc.h
+++ b/arch/arm/mach-ebsa110/include/mach/vmalloc.h
@@ -7,4 +7,4 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#define VMALLOC_END 0xdf000000 10#define VMALLOC_END 0xdf000000UL
diff --git a/arch/arm/mach-footbridge/include/mach/vmalloc.h b/arch/arm/mach-footbridge/include/mach/vmalloc.h
index 0ffbb7c85e59..40ba78e5782b 100644
--- a/arch/arm/mach-footbridge/include/mach/vmalloc.h
+++ b/arch/arm/mach-footbridge/include/mach/vmalloc.h
@@ -7,4 +7,4 @@
7 */ 7 */
8 8
9 9
10#define VMALLOC_END 0xf0000000 10#define VMALLOC_END 0xf0000000UL
diff --git a/arch/arm/mach-h720x/include/mach/vmalloc.h b/arch/arm/mach-h720x/include/mach/vmalloc.h
index a45915b88756..8520b4a4d4e6 100644
--- a/arch/arm/mach-h720x/include/mach/vmalloc.h
+++ b/arch/arm/mach-h720x/include/mach/vmalloc.h
@@ -5,6 +5,6 @@
5#ifndef __ARCH_ARM_VMALLOC_H 5#ifndef __ARCH_ARM_VMALLOC_H
6#define __ARCH_ARM_VMALLOC_H 6#define __ARCH_ARM_VMALLOC_H
7 7
8#define VMALLOC_END 0xd0000000 8#define VMALLOC_END 0xd0000000UL
9 9
10#endif 10#endif
diff --git a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
index 026263c665ca..7e1e9dc2c8fc 100644
--- a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
+++ b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
@@ -250,9 +250,6 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
250 .flags = IMXUART_HAVE_RTSCTS, 250 .flags = IMXUART_HAVE_RTSCTS,
251}; 251};
252 252
253#if defined(CONFIG_TOUCHSCREEN_ADS7846) \
254 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
255
256#define ADS7846_PENDOWN (GPIO_PORTD | 25) 253#define ADS7846_PENDOWN (GPIO_PORTD | 25)
257 254
258static void ads7846_dev_init(void) 255static void ads7846_dev_init(void)
@@ -273,9 +270,7 @@ static struct ads7846_platform_data ads7846_config __initdata = {
273 .get_pendown_state = ads7846_get_pendown_state, 270 .get_pendown_state = ads7846_get_pendown_state,
274 .keep_vref_on = 1, 271 .keep_vref_on = 1,
275}; 272};
276#endif
277 273
278#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
279static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = { 274static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
280 [0] = { 275 [0] = {
281 .modalias = "ads7846", 276 .modalias = "ads7846",
@@ -294,7 +289,6 @@ static const struct spi_imx_master eukrea_mbimx27_spi0_data __initconst = {
294 .chipselect = eukrea_mbimx27_spi_cs, 289 .chipselect = eukrea_mbimx27_spi_cs,
295 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs), 290 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
296}; 291};
297#endif
298 292
299static struct i2c_board_info eukrea_mbimx27_i2c_devices[] = { 293static struct i2c_board_info eukrea_mbimx27_i2c_devices[] = {
300 { 294 {
diff --git a/arch/arm/mach-integrator/include/mach/vmalloc.h b/arch/arm/mach-integrator/include/mach/vmalloc.h
index e056e7cf5645..2f5a2bafb11f 100644
--- a/arch/arm/mach-integrator/include/mach/vmalloc.h
+++ b/arch/arm/mach-integrator/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * along with this program; if not, write to the Free Software 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 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#define VMALLOC_END 0xd0000000 20#define VMALLOC_END 0xd0000000UL
diff --git a/arch/arm/mach-mmp/mmp2.c b/arch/arm/mach-mmp/mmp2.c
index daf3993349f8..2e3dd08ccc3f 100644
--- a/arch/arm/mach-mmp/mmp2.c
+++ b/arch/arm/mach-mmp/mmp2.c
@@ -126,7 +126,6 @@ static APBC_CLK(twsi3, MMP2_TWSI3, 0, 26000000);
126static APBC_CLK(twsi4, MMP2_TWSI4, 0, 26000000); 126static APBC_CLK(twsi4, MMP2_TWSI4, 0, 26000000);
127static APBC_CLK(twsi5, MMP2_TWSI5, 0, 26000000); 127static APBC_CLK(twsi5, MMP2_TWSI5, 0, 26000000);
128static APBC_CLK(twsi6, MMP2_TWSI6, 0, 26000000); 128static APBC_CLK(twsi6, MMP2_TWSI6, 0, 26000000);
129static APBC_CLK(rtc, MMP2_RTC, 0, 32768);
130 129
131static APMU_CLK(nand, NAND, 0xbf, 100000000); 130static APMU_CLK(nand, NAND, 0xbf, 100000000);
132 131
diff --git a/arch/arm/mach-msm/include/mach/vmalloc.h b/arch/arm/mach-msm/include/mach/vmalloc.h
index 31a32ad062dc..d138448eff16 100644
--- a/arch/arm/mach-msm/include/mach/vmalloc.h
+++ b/arch/arm/mach-msm/include/mach/vmalloc.h
@@ -16,7 +16,7 @@
16#ifndef __ASM_ARCH_MSM_VMALLOC_H 16#ifndef __ASM_ARCH_MSM_VMALLOC_H
17#define __ASM_ARCH_MSM_VMALLOC_H 17#define __ASM_ARCH_MSM_VMALLOC_H
18 18
19#define VMALLOC_END 0xd0000000 19#define VMALLOC_END 0xd0000000UL
20 20
21#endif 21#endif
22 22
diff --git a/arch/arm/mach-mx25/devices-imx25.h b/arch/arm/mach-mx25/devices-imx25.h
index 93afa10b13cf..d94d282fa676 100644
--- a/arch/arm/mach-mx25/devices-imx25.h
+++ b/arch/arm/mach-mx25/devices-imx25.h
@@ -42,9 +42,9 @@ extern const struct imx_mxc_nand_data imx25_mxc_nand_data __initconst;
42#define imx25_add_mxc_nand(pdata) \ 42#define imx25_add_mxc_nand(pdata) \
43 imx_add_mxc_nand(&imx25_mxc_nand_data, pdata) 43 imx_add_mxc_nand(&imx25_mxc_nand_data, pdata)
44 44
45extern const struct imx_spi_imx_data imx25_spi_imx_data[] __initconst; 45extern const struct imx_spi_imx_data imx25_cspi_data[] __initconst;
46#define imx25_add_spi_imx(id, pdata) \ 46#define imx25_add_spi_imx(id, pdata) \
47 imx_add_spi_imx(&imx25_spi_imx_data[id], pdata) 47 imx_add_spi_imx(&imx25_cspi_data[id], pdata)
48#define imx25_add_spi_imx0(pdata) imx25_add_spi_imx(0, pdata) 48#define imx25_add_spi_imx0(pdata) imx25_add_spi_imx(0, pdata)
49#define imx25_add_spi_imx1(pdata) imx25_add_spi_imx(1, pdata) 49#define imx25_add_spi_imx1(pdata) imx25_add_spi_imx(1, pdata)
50#define imx25_add_spi_imx2(pdata) imx25_add_spi_imx(2, pdata) 50#define imx25_add_spi_imx2(pdata) imx25_add_spi_imx(2, pdata)
diff --git a/arch/arm/mach-mx3/mach-pcm037_eet.c b/arch/arm/mach-mx3/mach-pcm037_eet.c
index 99e0894e07db..fda56545d2fd 100644
--- a/arch/arm/mach-mx3/mach-pcm037_eet.c
+++ b/arch/arm/mach-mx3/mach-pcm037_eet.c
@@ -14,6 +14,7 @@
14 14
15#include <mach/common.h> 15#include <mach/common.h>
16#include <mach/iomux-mx3.h> 16#include <mach/iomux-mx3.h>
17#include <mach/spi.h>
17 18
18#include <asm/mach-types.h> 19#include <asm/mach-types.h>
19 20
@@ -59,14 +60,12 @@ static struct spi_board_info pcm037_spi_dev[] = {
59}; 60};
60 61
61/* Platform Data for MXC CSPI */ 62/* Platform Data for MXC CSPI */
62#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
63static int pcm037_spi1_cs[] = {MXC_SPI_CS(1), IOMUX_TO_GPIO(MX31_PIN_KEY_COL7)}; 63static int pcm037_spi1_cs[] = {MXC_SPI_CS(1), IOMUX_TO_GPIO(MX31_PIN_KEY_COL7)};
64 64
65static const struct spi_imx_master pcm037_spi1_pdata __initconst = { 65static const struct spi_imx_master pcm037_spi1_pdata __initconst = {
66 .chipselect = pcm037_spi1_cs, 66 .chipselect = pcm037_spi1_cs,
67 .num_chipselect = ARRAY_SIZE(pcm037_spi1_cs), 67 .num_chipselect = ARRAY_SIZE(pcm037_spi1_cs),
68}; 68};
69#endif
70 69
71/* GPIO-keys input device */ 70/* GPIO-keys input device */
72static struct gpio_keys_button pcm037_gpio_keys[] = { 71static struct gpio_keys_button pcm037_gpio_keys[] = {
@@ -171,7 +170,7 @@ static struct platform_device pcm037_gpio_keys_device = {
171 }, 170 },
172}; 171};
173 172
174static int eet_init_devices(void) 173static int __init eet_init_devices(void)
175{ 174{
176 if (!machine_is_pcm037() || pcm037_variant() != PCM037_EET) 175 if (!machine_is_pcm037() || pcm037_variant() != PCM037_EET)
177 return 0; 176 return 0;
diff --git a/arch/arm/mach-netx/include/mach/vmalloc.h b/arch/arm/mach-netx/include/mach/vmalloc.h
index 7cca3574308f..871f1ef7bff5 100644
--- a/arch/arm/mach-netx/include/mach/vmalloc.h
+++ b/arch/arm/mach-netx/include/mach/vmalloc.h
@@ -16,4 +16,4 @@
16 * along with this program; if not, write to the Free Software 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 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19#define VMALLOC_END 0xd0000000 19#define VMALLOC_END 0xd0000000UL
diff --git a/arch/arm/mach-omap1/include/mach/vmalloc.h b/arch/arm/mach-omap1/include/mach/vmalloc.h
index b001f67d695b..22ec4a479577 100644
--- a/arch/arm/mach-omap1/include/mach/vmalloc.h
+++ b/arch/arm/mach-omap1/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * along with this program; if not, write to the Free Software 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 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#define VMALLOC_END 0xd8000000 20#define VMALLOC_END 0xd8000000UL
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index 86c9b2102952..9db9203667df 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -216,7 +216,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
216 { 216 {
217 .name = "wl1271", 217 .name = "wl1271",
218 .mmc = 3, 218 .mmc = 3,
219 .caps = MMC_CAP_4_BIT_DATA, 219 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
220 .gpio_wp = -EINVAL, 220 .gpio_wp = -EINVAL,
221 .gpio_cd = -EINVAL, 221 .gpio_cd = -EINVAL,
222 .nonremovable = true, 222 .nonremovable = true,
diff --git a/arch/arm/mach-omap2/include/mach/vmalloc.h b/arch/arm/mach-omap2/include/mach/vmalloc.h
index 4da31e997efe..866319947760 100644
--- a/arch/arm/mach-omap2/include/mach/vmalloc.h
+++ b/arch/arm/mach-omap2/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * along with this program; if not, write to the Free Software 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 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#define VMALLOC_END 0xf8000000 20#define VMALLOC_END 0xf8000000UL
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 40562ddd3ee4..a1939b1e6f82 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -297,7 +297,7 @@ static int __init _omap2_init_reprogram_sdrc(void)
297 return 0; 297 return 0;
298 298
299 dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck"); 299 dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck");
300 if (!dpll3_m2_ck) 300 if (IS_ERR(dpll3_m2_ck))
301 return -EINVAL; 301 return -EINVAL;
302 302
303 rate = clk_get_rate(dpll3_m2_ck); 303 rate = clk_get_rate(dpll3_m2_ck);
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 5e81517a7af2..a8afb610c7d8 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -161,6 +161,23 @@ void omap2_pm_dump(int mode, int resume, unsigned int us)
161 printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val); 161 printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val);
162} 162}
163 163
164void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
165{
166 u32 tick_rate, cycles;
167
168 if (!seconds && !milliseconds)
169 return;
170
171 tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
172 cycles = tick_rate * seconds + tick_rate * milliseconds / 1000;
173 omap_dm_timer_stop(gptimer_wakeup);
174 omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
175
176 pr_info("PM: Resume timer in %u.%03u secs"
177 " (%d ticks at %d ticks/sec.)\n",
178 seconds, milliseconds, cycles, tick_rate);
179}
180
164#ifdef CONFIG_DEBUG_FS 181#ifdef CONFIG_DEBUG_FS
165#include <linux/debugfs.h> 182#include <linux/debugfs.h>
166#include <linux/seq_file.h> 183#include <linux/seq_file.h>
@@ -354,23 +371,6 @@ void pm_dbg_update_time(struct powerdomain *pwrdm, int prev)
354 pwrdm->timer = t; 371 pwrdm->timer = t;
355} 372}
356 373
357void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
358{
359 u32 tick_rate, cycles;
360
361 if (!seconds && !milliseconds)
362 return;
363
364 tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
365 cycles = tick_rate * seconds + tick_rate * milliseconds / 1000;
366 omap_dm_timer_stop(gptimer_wakeup);
367 omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
368
369 pr_info("PM: Resume timer in %u.%03u secs"
370 " (%d ticks at %d ticks/sec.)\n",
371 seconds, milliseconds, cycles, tick_rate);
372}
373
374static int clkdm_dbg_show_counter(struct clockdomain *clkdm, void *user) 374static int clkdm_dbg_show_counter(struct clockdomain *clkdm, void *user)
375{ 375{
376 struct seq_file *s = (struct seq_file *)user; 376 struct seq_file *s = (struct seq_file *)user;
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index a40457d81927..aaeea49b9bdd 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -30,6 +30,7 @@
30#include <linux/irq.h> 30#include <linux/irq.h>
31#include <linux/time.h> 31#include <linux/time.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/console.h>
33 34
34#include <asm/mach/time.h> 35#include <asm/mach/time.h>
35#include <asm/mach/irq.h> 36#include <asm/mach/irq.h>
@@ -52,6 +53,19 @@
52#include <plat/powerdomain.h> 53#include <plat/powerdomain.h>
53#include <plat/clockdomain.h> 54#include <plat/clockdomain.h>
54 55
56#ifdef CONFIG_SUSPEND
57static suspend_state_t suspend_state = PM_SUSPEND_ON;
58static inline bool is_suspending(void)
59{
60 return (suspend_state != PM_SUSPEND_ON);
61}
62#else
63static inline bool is_suspending(void)
64{
65 return false;
66}
67#endif
68
55static void (*omap2_sram_idle)(void); 69static void (*omap2_sram_idle)(void);
56static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl, 70static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl,
57 void __iomem *sdrc_power); 71 void __iomem *sdrc_power);
@@ -118,6 +132,11 @@ static void omap2_enter_full_retention(void)
118 if (omap_irq_pending()) 132 if (omap_irq_pending())
119 goto no_sleep; 133 goto no_sleep;
120 134
135 /* Block console output in case it is on one of the OMAP UARTs */
136 if (!is_suspending())
137 if (try_acquire_console_sem())
138 goto no_sleep;
139
121 omap_uart_prepare_idle(0); 140 omap_uart_prepare_idle(0);
122 omap_uart_prepare_idle(1); 141 omap_uart_prepare_idle(1);
123 omap_uart_prepare_idle(2); 142 omap_uart_prepare_idle(2);
@@ -131,6 +150,9 @@ static void omap2_enter_full_retention(void)
131 omap_uart_resume_idle(1); 150 omap_uart_resume_idle(1);
132 omap_uart_resume_idle(0); 151 omap_uart_resume_idle(0);
133 152
153 if (!is_suspending())
154 release_console_sem();
155
134no_sleep: 156no_sleep:
135 if (omap2_pm_debug) { 157 if (omap2_pm_debug) {
136 unsigned long long tmp; 158 unsigned long long tmp;
@@ -277,6 +299,12 @@ out:
277 local_irq_enable(); 299 local_irq_enable();
278} 300}
279 301
302static int omap2_pm_begin(suspend_state_t state)
303{
304 suspend_state = state;
305 return 0;
306}
307
280static int omap2_pm_prepare(void) 308static int omap2_pm_prepare(void)
281{ 309{
282 /* We cannot sleep in idle until we have resumed */ 310 /* We cannot sleep in idle until we have resumed */
@@ -326,10 +354,17 @@ static void omap2_pm_finish(void)
326 enable_hlt(); 354 enable_hlt();
327} 355}
328 356
357static void omap2_pm_end(void)
358{
359 suspend_state = PM_SUSPEND_ON;
360}
361
329static struct platform_suspend_ops omap_pm_ops = { 362static struct platform_suspend_ops omap_pm_ops = {
363 .begin = omap2_pm_begin,
330 .prepare = omap2_pm_prepare, 364 .prepare = omap2_pm_prepare,
331 .enter = omap2_pm_enter, 365 .enter = omap2_pm_enter,
332 .finish = omap2_pm_finish, 366 .finish = omap2_pm_finish,
367 .end = omap2_pm_end,
333 .valid = suspend_valid_only_mem, 368 .valid = suspend_valid_only_mem,
334}; 369};
335 370
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 75c0cd13ad8e..648b8c50d024 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -28,6 +28,7 @@
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/console.h>
31 32
32#include <plat/sram.h> 33#include <plat/sram.h>
33#include <plat/clockdomain.h> 34#include <plat/clockdomain.h>
@@ -49,6 +50,19 @@
49#include "sdrc.h" 50#include "sdrc.h"
50#include "control.h" 51#include "control.h"
51 52
53#ifdef CONFIG_SUSPEND
54static suspend_state_t suspend_state = PM_SUSPEND_ON;
55static inline bool is_suspending(void)
56{
57 return (suspend_state != PM_SUSPEND_ON);
58}
59#else
60static inline bool is_suspending(void)
61{
62 return false;
63}
64#endif
65
52/* Scratchpad offsets */ 66/* Scratchpad offsets */
53#define OMAP343X_TABLE_ADDRESS_OFFSET 0xc4 67#define OMAP343X_TABLE_ADDRESS_OFFSET 0xc4
54#define OMAP343X_TABLE_VALUE_OFFSET 0xc0 68#define OMAP343X_TABLE_VALUE_OFFSET 0xc0
@@ -385,6 +399,13 @@ void omap_sram_idle(void)
385 omap3_enable_io_chain(); 399 omap3_enable_io_chain();
386 } 400 }
387 401
402 /* Block console output in case it is on one of the OMAP UARTs */
403 if (!is_suspending())
404 if (per_next_state < PWRDM_POWER_ON ||
405 core_next_state < PWRDM_POWER_ON)
406 if (try_acquire_console_sem())
407 goto console_still_active;
408
388 /* PER */ 409 /* PER */
389 if (per_next_state < PWRDM_POWER_ON) { 410 if (per_next_state < PWRDM_POWER_ON) {
390 omap_uart_prepare_idle(2); 411 omap_uart_prepare_idle(2);
@@ -463,6 +484,10 @@ void omap_sram_idle(void)
463 omap_uart_resume_idle(3); 484 omap_uart_resume_idle(3);
464 } 485 }
465 486
487 if (!is_suspending())
488 release_console_sem();
489
490console_still_active:
466 /* Disable IO-PAD and IO-CHAIN wakeup */ 491 /* Disable IO-PAD and IO-CHAIN wakeup */
467 if (omap3_has_io_wakeup() && 492 if (omap3_has_io_wakeup() &&
468 (per_next_state < PWRDM_POWER_ON || 493 (per_next_state < PWRDM_POWER_ON ||
@@ -504,8 +529,6 @@ out:
504} 529}
505 530
506#ifdef CONFIG_SUSPEND 531#ifdef CONFIG_SUSPEND
507static suspend_state_t suspend_state;
508
509static int omap3_pm_prepare(void) 532static int omap3_pm_prepare(void)
510{ 533{
511 disable_hlt(); 534 disable_hlt();
diff --git a/arch/arm/mach-omap2/prcm-common.h b/arch/arm/mach-omap2/prcm-common.h
index 298a22a754e2..f81acee4738d 100644
--- a/arch/arm/mach-omap2/prcm-common.h
+++ b/arch/arm/mach-omap2/prcm-common.h
@@ -243,13 +243,14 @@
243#define OMAP24XX_EN_GPT1_MASK (1 << 0) 243#define OMAP24XX_EN_GPT1_MASK (1 << 0)
244 244
245/* PM_WKST_WKUP, CM_IDLEST_WKUP shared bits */ 245/* PM_WKST_WKUP, CM_IDLEST_WKUP shared bits */
246#define OMAP24XX_ST_GPIOS_SHIFT (1 << 2) 246#define OMAP24XX_ST_GPIOS_SHIFT 2
247#define OMAP24XX_ST_GPIOS_MASK 2 247#define OMAP24XX_ST_GPIOS_MASK (1 << 2)
248#define OMAP24XX_ST_GPT1_SHIFT (1 << 0) 248#define OMAP24XX_ST_GPT1_SHIFT 0
249#define OMAP24XX_ST_GPT1_MASK 0 249#define OMAP24XX_ST_GPT1_MASK (1 << 0)
250 250
251/* CM_IDLEST_MDM and PM_WKST_MDM shared bits */ 251/* CM_IDLEST_MDM and PM_WKST_MDM shared bits */
252#define OMAP2430_ST_MDM_SHIFT (1 << 0) 252#define OMAP2430_ST_MDM_SHIFT 0
253#define OMAP2430_ST_MDM_MASK (1 << 0)
253 254
254 255
255/* 3430 register bits shared between CM & PRM registers */ 256/* 3430 register bits shared between CM & PRM registers */
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index becf0e38ef7e..d17960a1be25 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -27,6 +27,7 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/serial_8250.h> 28#include <linux/serial_8250.h>
29#include <linux/pm_runtime.h> 29#include <linux/pm_runtime.h>
30#include <linux/console.h>
30 31
31#ifdef CONFIG_SERIAL_OMAP 32#ifdef CONFIG_SERIAL_OMAP
32#include <plat/omap-serial.h> 33#include <plat/omap-serial.h>
@@ -406,7 +407,7 @@ void omap_uart_resume_idle(int num)
406 struct omap_uart_state *uart; 407 struct omap_uart_state *uart;
407 408
408 list_for_each_entry(uart, &uart_list, node) { 409 list_for_each_entry(uart, &uart_list, node) {
409 if (num == uart->num) { 410 if (num == uart->num && uart->can_sleep) {
410 omap_uart_enable_clocks(uart); 411 omap_uart_enable_clocks(uart);
411 412
412 /* Check for IO pad wakeup */ 413 /* Check for IO pad wakeup */
@@ -807,6 +808,8 @@ void __init omap_serial_init_port(int port)
807 808
808 oh->dev_attr = uart; 809 oh->dev_attr = uart;
809 810
811 acquire_console_sem(); /* in case the earlycon is on the UART */
812
810 /* 813 /*
811 * Because of early UART probing, UART did not get idled 814 * Because of early UART probing, UART did not get idled
812 * on init. Now that omap_device is ready, ensure full idle 815 * on init. Now that omap_device is ready, ensure full idle
@@ -831,6 +834,8 @@ void __init omap_serial_init_port(int port)
831 omap_uart_block_sleep(uart); 834 omap_uart_block_sleep(uart);
832 uart->timeout = DEFAULT_TIMEOUT; 835 uart->timeout = DEFAULT_TIMEOUT;
833 836
837 release_console_sem();
838
834 if ((cpu_is_omap34xx() && uart->padconf) || 839 if ((cpu_is_omap34xx() && uart->padconf) ||
835 (uart->wk_en && uart->wk_mask)) { 840 (uart->wk_en && uart->wk_mask)) {
836 device_init_wakeup(&od->pdev.dev, true); 841 device_init_wakeup(&od->pdev.dev, true);
diff --git a/arch/arm/mach-pnx4008/include/mach/vmalloc.h b/arch/arm/mach-pnx4008/include/mach/vmalloc.h
index 31b65ee07b0b..184913c71141 100644
--- a/arch/arm/mach-pnx4008/include/mach/vmalloc.h
+++ b/arch/arm/mach-pnx4008/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
18 * area for the same reason. ;) 18 * area for the same reason. ;)
19 */ 19 */
20#define VMALLOC_END 0xd0000000 20#define VMALLOC_END 0xd0000000UL
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index d2060a1d1d68..e5c9932b7588 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -241,7 +241,8 @@ static inline void palmtx_keys_init(void) {}
241/****************************************************************************** 241/******************************************************************************
242 * NAND Flash 242 * NAND Flash
243 ******************************************************************************/ 243 ******************************************************************************/
244#if defined(CONFIG_MTD_NAND_GPIO) || defined(CONFIG_MTD_NAND_GPIO_MODULE) 244#if defined(CONFIG_MTD_NAND_PLATFORM) || \
245 defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
245static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd, 246static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
246 unsigned int ctrl) 247 unsigned int ctrl)
247{ 248{
diff --git a/arch/arm/mach-realview/headsmp.S b/arch/arm/mach-realview/headsmp.S
index 4075473cf68a..b34be4554d40 100644
--- a/arch/arm/mach-realview/headsmp.S
+++ b/arch/arm/mach-realview/headsmp.S
@@ -35,5 +35,6 @@ pen: ldr r7, [r6]
35 */ 35 */
36 b secondary_startup 36 b secondary_startup
37 37
38 .align
381: .long . 391: .long .
39 .long pen_release 40 .long pen_release
diff --git a/arch/arm/mach-rpc/include/mach/vmalloc.h b/arch/arm/mach-rpc/include/mach/vmalloc.h
index 3bcd86fadb81..fb700228637a 100644
--- a/arch/arm/mach-rpc/include/mach/vmalloc.h
+++ b/arch/arm/mach-rpc/include/mach/vmalloc.h
@@ -7,4 +7,4 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#define VMALLOC_END 0xdc000000 10#define VMALLOC_END 0xdc000000UL
diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c
index 8aa2f1902a94..6b86a722a7db 100644
--- a/arch/arm/mach-s3c2410/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c
@@ -77,13 +77,13 @@ static int __devinit h1940bt_probe(struct platform_device *pdev)
77 77
78 /* Configures BT serial port GPIOs */ 78 /* Configures BT serial port GPIOs */
79 s3c_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0); 79 s3c_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0);
80 s3c_gpio_cfgpull(S3C2410_GPH(0), S3C_GPIO_PULL_NONE); 80 s3c_gpio_setpull(S3C2410_GPH(0), S3C_GPIO_PULL_NONE);
81 s3c_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT); 81 s3c_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT);
82 s3c_gpio_cfgpull(S3C2410_GPH(1), S3C_GPIO_PULL_NONE); 82 s3c_gpio_setpull(S3C2410_GPH(1), S3C_GPIO_PULL_NONE);
83 s3c_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0); 83 s3c_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0);
84 s3c_gpio_cfgpull(S3C2410_GPH(2), S3C_GPIO_PULL_NONE); 84 s3c_gpio_setpull(S3C2410_GPH(2), S3C_GPIO_PULL_NONE);
85 s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0); 85 s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0);
86 s3c_gpio_cfgpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE); 86 s3c_gpio_setpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE);
87 87
88 88
89 rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH, 89 rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
diff --git a/arch/arm/mach-s3c2412/Kconfig b/arch/arm/mach-s3c2412/Kconfig
index cef6a65637bd..6983cb4d4cae 100644
--- a/arch/arm/mach-s3c2412/Kconfig
+++ b/arch/arm/mach-s3c2412/Kconfig
@@ -16,7 +16,7 @@ config CPU_S3C2412
16config CPU_S3C2412_ONLY 16config CPU_S3C2412_ONLY
17 bool 17 bool
18 depends on ARCH_S3C2410 && !CPU_S3C2400 && !CPU_S3C2410 && \ 18 depends on ARCH_S3C2410 && !CPU_S3C2400 && !CPU_S3C2410 && \
19 !CPU_2416 && !CPU_S3C2440 && !CPU_S3C2442 && \ 19 !CPU_S3C2416 && !CPU_S3C2440 && !CPU_S3C2442 && \
20 !CPU_S3C2443 && CPU_S3C2412 20 !CPU_S3C2443 && CPU_S3C2412
21 default y if CPU_S3C2412 21 default y if CPU_S3C2412
22 22
@@ -28,9 +28,16 @@ config S3C2412_DMA
28 28
29config S3C2412_PM 29config S3C2412_PM
30 bool 30 bool
31 select S3C2412_PM_SLEEP
31 help 32 help
32 Internal config node to apply S3C2412 power management 33 Internal config node to apply S3C2412 power management
33 34
35config S3C2412_PM_SLEEP
36 bool
37 help
38 Internal config node to apply sleep for S3C2412 power management.
39 Can be selected by another SoCs with similar sleep procedure.
40
34# Note, the S3C2412 IOtiming support is in plat-s3c24xx 41# Note, the S3C2412 IOtiming support is in plat-s3c24xx
35 42
36config S3C2412_CPUFREQ 43config S3C2412_CPUFREQ
diff --git a/arch/arm/mach-s3c2412/Makefile b/arch/arm/mach-s3c2412/Makefile
index 530ec46cbaea..6c48a91ea39e 100644
--- a/arch/arm/mach-s3c2412/Makefile
+++ b/arch/arm/mach-s3c2412/Makefile
@@ -14,7 +14,8 @@ obj-$(CONFIG_CPU_S3C2412) += irq.o
14obj-$(CONFIG_CPU_S3C2412) += clock.o 14obj-$(CONFIG_CPU_S3C2412) += clock.o
15obj-$(CONFIG_CPU_S3C2412) += gpio.o 15obj-$(CONFIG_CPU_S3C2412) += gpio.o
16obj-$(CONFIG_S3C2412_DMA) += dma.o 16obj-$(CONFIG_S3C2412_DMA) += dma.o
17obj-$(CONFIG_S3C2412_PM) += pm.o sleep.o 17obj-$(CONFIG_S3C2412_PM) += pm.o
18obj-$(CONFIG_S3C2412_PM_SLEEP) += sleep.o
18obj-$(CONFIG_S3C2412_CPUFREQ) += cpu-freq.o 19obj-$(CONFIG_S3C2412_CPUFREQ) += cpu-freq.o
19 20
20# Machine support 21# Machine support
diff --git a/arch/arm/mach-s3c2416/Kconfig b/arch/arm/mach-s3c2416/Kconfig
index 87b9c9f003bd..df8d14974c90 100644
--- a/arch/arm/mach-s3c2416/Kconfig
+++ b/arch/arm/mach-s3c2416/Kconfig
@@ -27,6 +27,7 @@ config S3C2416_DMA
27 27
28config S3C2416_PM 28config S3C2416_PM
29 bool 29 bool
30 select S3C2412_PM_SLEEP
30 help 31 help
31 Internal config node to apply S3C2416 power management 32 Internal config node to apply S3C2416 power management
32 33
@@ -35,9 +36,12 @@ menu "S3C2416 Machines"
35config MACH_SMDK2416 36config MACH_SMDK2416
36 bool "SMDK2416" 37 bool "SMDK2416"
37 select CPU_S3C2416 38 select CPU_S3C2416
39 select MACH_SMDK
38 select S3C_DEV_FB 40 select S3C_DEV_FB
39 select S3C_DEV_HSMMC 41 select S3C_DEV_HSMMC
40 select S3C_DEV_HSMMC1 42 select S3C_DEV_HSMMC1
43 select S3C_DEV_NAND
44 select S3C_DEV_USB_HOST
41 select S3C2416_PM if PM 45 select S3C2416_PM if PM
42 help 46 help
43 Say Y here if you are using an SMDK2416 47 Say Y here if you are using an SMDK2416
diff --git a/arch/arm/mach-s3c2416/irq.c b/arch/arm/mach-s3c2416/irq.c
index 084d121f368c..00174daf1526 100644
--- a/arch/arm/mach-s3c2416/irq.c
+++ b/arch/arm/mach-s3c2416/irq.c
@@ -168,12 +168,11 @@ static struct irq_chip s3c2416_irq_dma = {
168 168
169static void s3c2416_irq_demux_uart3(unsigned int irq, struct irq_desc *desc) 169static void s3c2416_irq_demux_uart3(unsigned int irq, struct irq_desc *desc)
170{ 170{
171 s3c2416_irq_demux(IRQ_S3C2443_UART3, 3); 171 s3c2416_irq_demux(IRQ_S3C2443_RX3, 3);
172} 172}
173 173
174#define INTMSK_UART3 (1UL << (IRQ_S3C2443_UART3 - IRQ_EINT0)) 174#define INTMSK_UART3 (1UL << (IRQ_S3C2443_UART3 - IRQ_EINT0))
175#define SUBMSK_UART3 (0xf << (IRQ_S3C2443_RX3 - S3C2410_IRQSUB(0))) 175#define SUBMSK_UART3 (0x7 << (IRQ_S3C2443_RX3 - S3C2410_IRQSUB(0)))
176
177 176
178static void s3c2416_irq_uart3_mask(unsigned int irqno) 177static void s3c2416_irq_uart3_mask(unsigned int irqno)
179{ 178{
diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig
index ff024a6c0f85..a0cb2581894f 100644
--- a/arch/arm/mach-s3c2440/Kconfig
+++ b/arch/arm/mach-s3c2440/Kconfig
@@ -18,6 +18,7 @@ config CPU_S3C2440
18config CPU_S3C2442 18config CPU_S3C2442
19 bool 19 bool
20 select CPU_ARM920T 20 select CPU_ARM920T
21 select S3C_GPIO_PULL_DOWN
21 select S3C2410_CLOCK 22 select S3C2410_CLOCK
22 select S3C2410_GPIO 23 select S3C2410_GPIO
23 select S3C2410_PM if PM 24 select S3C2410_PM if PM
@@ -178,6 +179,9 @@ config MACH_MINI2440
178 bool "MINI2440 development board" 179 bool "MINI2440 development board"
179 select CPU_S3C2440 180 select CPU_S3C2440
180 select EEPROM_AT24 181 select EEPROM_AT24
182 select NEW_LEDS
183 select LEDS_CLASS
184 select LEDS_TRIGGER
181 select LEDS_TRIGGER_BACKLIGHT 185 select LEDS_TRIGGER_BACKLIGHT
182 select S3C_DEV_NAND 186 select S3C_DEV_NAND
183 select S3C_DEV_USB_HOST 187 select S3C_DEV_USB_HOST
diff --git a/arch/arm/mach-s3c2440/s3c2440.c b/arch/arm/mach-s3c2440/s3c2440.c
index d50f3ae6173d..f7663f731ea0 100644
--- a/arch/arm/mach-s3c2440/s3c2440.c
+++ b/arch/arm/mach-s3c2440/s3c2440.c
@@ -46,9 +46,6 @@ int __init s3c2440_init(void)
46{ 46{
47 printk("S3C2440: Initialising architecture\n"); 47 printk("S3C2440: Initialising architecture\n");
48 48
49 s3c24xx_gpiocfg_default.set_pull = s3c_gpio_setpull_1up;
50 s3c24xx_gpiocfg_default.get_pull = s3c_gpio_getpull_1up;
51
52 /* change irq for watchdog */ 49 /* change irq for watchdog */
53 50
54 s3c_device_wdt.resource[1].start = IRQ_S3C2440_WDT; 51 s3c_device_wdt.resource[1].start = IRQ_S3C2440_WDT;
@@ -58,3 +55,11 @@ int __init s3c2440_init(void)
58 55
59 return sysdev_register(&s3c2440_sysdev); 56 return sysdev_register(&s3c2440_sysdev);
60} 57}
58
59void __init s3c2440_map_io(void)
60{
61 s3c244x_map_io();
62
63 s3c24xx_gpiocfg_default.set_pull = s3c_gpio_setpull_1up;
64 s3c24xx_gpiocfg_default.get_pull = s3c_gpio_getpull_1up;
65}
diff --git a/arch/arm/mach-s3c2440/s3c2442.c b/arch/arm/mach-s3c2440/s3c2442.c
index 188ad1e57dc0..ecf813546554 100644
--- a/arch/arm/mach-s3c2440/s3c2442.c
+++ b/arch/arm/mach-s3c2440/s3c2442.c
@@ -32,6 +32,7 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/ioport.h> 33#include <linux/ioport.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/gpio.h>
35#include <linux/clk.h> 36#include <linux/clk.h>
36#include <linux/io.h> 37#include <linux/io.h>
37 38
@@ -43,6 +44,11 @@
43 44
44#include <plat/clock.h> 45#include <plat/clock.h>
45#include <plat/cpu.h> 46#include <plat/cpu.h>
47#include <plat/s3c244x.h>
48
49#include <plat/gpio-core.h>
50#include <plat/gpio-cfg.h>
51#include <plat/gpio-cfg-helpers.h>
46 52
47/* S3C2442 extended clock support */ 53/* S3C2442 extended clock support */
48 54
@@ -163,3 +169,11 @@ int __init s3c2442_init(void)
163 169
164 return sysdev_register(&s3c2442_sysdev); 170 return sysdev_register(&s3c2442_sysdev);
165} 171}
172
173void __init s3c2442_map_io(void)
174{
175 s3c244x_map_io();
176
177 s3c24xx_gpiocfg_default.set_pull = s3c_gpio_setpull_1down;
178 s3c24xx_gpiocfg_default.get_pull = s3c_gpio_getpull_1down;
179}
diff --git a/arch/arm/mach-s3c2443/Kconfig b/arch/arm/mach-s3c2443/Kconfig
index 4fef723126fa..31babec90cec 100644
--- a/arch/arm/mach-s3c2443/Kconfig
+++ b/arch/arm/mach-s3c2443/Kconfig
@@ -5,6 +5,7 @@
5config CPU_S3C2443 5config CPU_S3C2443
6 bool 6 bool
7 depends on ARCH_S3C2410 7 depends on ARCH_S3C2410
8 select CPU_ARM920T
8 select S3C2443_DMA if S3C2410_DMA 9 select S3C2443_DMA if S3C2410_DMA
9 select CPU_LLSERIAL_S3C2440 10 select CPU_LLSERIAL_S3C2440
10 select SAMSUNG_CLKSRC 11 select SAMSUNG_CLKSRC
diff --git a/arch/arm/mach-s3c2443/irq.c b/arch/arm/mach-s3c2443/irq.c
index 0e0d693f3974..893424767ce1 100644
--- a/arch/arm/mach-s3c2443/irq.c
+++ b/arch/arm/mach-s3c2443/irq.c
@@ -166,12 +166,11 @@ static struct irq_chip s3c2443_irq_dma = {
166 166
167static void s3c2443_irq_demux_uart3(unsigned int irq, struct irq_desc *desc) 167static void s3c2443_irq_demux_uart3(unsigned int irq, struct irq_desc *desc)
168{ 168{
169 s3c2443_irq_demux(IRQ_S3C2443_UART3, 3); 169 s3c2443_irq_demux(IRQ_S3C2443_RX3, 3);
170} 170}
171 171
172#define INTMSK_UART3 (1UL << (IRQ_S3C2443_UART3 - IRQ_EINT0)) 172#define INTMSK_UART3 (1UL << (IRQ_S3C2443_UART3 - IRQ_EINT0))
173#define SUBMSK_UART3 (0xf << (IRQ_S3C2443_RX3 - S3C2410_IRQSUB(0))) 173#define SUBMSK_UART3 (0x7 << (IRQ_S3C2443_RX3 - S3C2410_IRQSUB(0)))
174
175 174
176static void s3c2443_irq_uart3_mask(unsigned int irqno) 175static void s3c2443_irq_uart3_mask(unsigned int irqno)
177{ 176{
diff --git a/arch/arm/mach-s3c64xx/mach-mini6410.c b/arch/arm/mach-s3c64xx/mach-mini6410.c
index 249c62956471..89f35e02e883 100644
--- a/arch/arm/mach-s3c64xx/mach-mini6410.c
+++ b/arch/arm/mach-s3c64xx/mach-mini6410.c
@@ -45,7 +45,7 @@
45 45
46#include <video/platform_lcd.h> 46#include <video/platform_lcd.h>
47 47
48#define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK) 48#define UCON S3C2410_UCON_DEFAULT
49#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB) 49#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
50#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE) 50#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
51 51
diff --git a/arch/arm/mach-s3c64xx/mach-real6410.c b/arch/arm/mach-s3c64xx/mach-real6410.c
index f9ef9b5c5f5a..4957ab0a0d4a 100644
--- a/arch/arm/mach-s3c64xx/mach-real6410.c
+++ b/arch/arm/mach-s3c64xx/mach-real6410.c
@@ -46,7 +46,7 @@
46 46
47#include <video/platform_lcd.h> 47#include <video/platform_lcd.h>
48 48
49#define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK) 49#define UCON S3C2410_UCON_DEFAULT
50#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB) 50#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
51#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE) 51#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
52 52
diff --git a/arch/arm/mach-s5pv210/mach-aquila.c b/arch/arm/mach-s5pv210/mach-aquila.c
index 28677caf3613..461aa035afc0 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -378,6 +378,12 @@ static struct max8998_regulator_data aquila_regulators[] = {
378static struct max8998_platform_data aquila_max8998_pdata = { 378static struct max8998_platform_data aquila_max8998_pdata = {
379 .num_regulators = ARRAY_SIZE(aquila_regulators), 379 .num_regulators = ARRAY_SIZE(aquila_regulators),
380 .regulators = aquila_regulators, 380 .regulators = aquila_regulators,
381 .buck1_set1 = S5PV210_GPH0(3),
382 .buck1_set2 = S5PV210_GPH0(4),
383 .buck2_set3 = S5PV210_GPH0(5),
384 .buck1_max_voltage1 = 1200000,
385 .buck1_max_voltage2 = 1200000,
386 .buck2_max_voltage = 1200000,
381}; 387};
382#endif 388#endif
383 389
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index b1dcf964a768..e22d5112fd44 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -518,6 +518,12 @@ static struct max8998_regulator_data goni_regulators[] = {
518static struct max8998_platform_data goni_max8998_pdata = { 518static struct max8998_platform_data goni_max8998_pdata = {
519 .num_regulators = ARRAY_SIZE(goni_regulators), 519 .num_regulators = ARRAY_SIZE(goni_regulators),
520 .regulators = goni_regulators, 520 .regulators = goni_regulators,
521 .buck1_set1 = S5PV210_GPH0(3),
522 .buck1_set2 = S5PV210_GPH0(4),
523 .buck2_set3 = S5PV210_GPH0(5),
524 .buck1_max_voltage1 = 1200000,
525 .buck1_max_voltage2 = 1200000,
526 .buck2_max_voltage = 1200000,
521}; 527};
522#endif 528#endif
523 529
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c b/arch/arm/mach-s5pv210/mach-smdkc110.c
index 0ad7924fe62e..5dd1681c069e 100644
--- a/arch/arm/mach-s5pv210/mach-smdkc110.c
+++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/serial_core.h> 14#include <linux/serial_core.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/sysdev.h>
16 17
17#include <asm/mach/arch.h> 18#include <asm/mach/arch.h>
18#include <asm/mach/map.h> 19#include <asm/mach/map.h>
diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c
index bcd7a5d53401..1fbc45b2a432 100644
--- a/arch/arm/mach-s5pv210/mach-smdkv210.c
+++ b/arch/arm/mach-s5pv210/mach-smdkv210.c
@@ -13,6 +13,7 @@
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/serial_core.h> 15#include <linux/serial_core.h>
16#include <linux/sysdev.h>
16 17
17#include <asm/mach/arch.h> 18#include <asm/mach/arch.h>
18#include <asm/mach/map.h> 19#include <asm/mach/map.h>
diff --git a/arch/arm/mach-shark/include/mach/vmalloc.h b/arch/arm/mach-shark/include/mach/vmalloc.h
index 8e845b6a7cb5..b10df988526d 100644
--- a/arch/arm/mach-shark/include/mach/vmalloc.h
+++ b/arch/arm/mach-shark/include/mach/vmalloc.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * arch/arm/mach-shark/include/mach/vmalloc.h 2 * arch/arm/mach-shark/include/mach/vmalloc.h
3 */ 3 */
4#define VMALLOC_END 0xd0000000 4#define VMALLOC_END 0xd0000000UL
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index d3260542b943..b1222dc43380 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -501,7 +501,12 @@ static struct platform_device keysc_device = {
501static struct resource mipidsi0_resources[] = { 501static struct resource mipidsi0_resources[] = {
502 [0] = { 502 [0] = {
503 .start = 0xffc60000, 503 .start = 0xffc60000,
504 .end = 0xffc68fff, 504 .end = 0xffc63073,
505 .flags = IORESOURCE_MEM,
506 },
507 [1] = {
508 .start = 0xffc68000,
509 .end = 0xffc680ef,
505 .flags = IORESOURCE_MEM, 510 .flags = IORESOURCE_MEM,
506 }, 511 },
507}; 512};
@@ -509,6 +514,7 @@ static struct resource mipidsi0_resources[] = {
509static struct sh_mipi_dsi_info mipidsi0_info = { 514static struct sh_mipi_dsi_info mipidsi0_info = {
510 .data_format = MIPI_RGB888, 515 .data_format = MIPI_RGB888,
511 .lcd_chan = &lcdc_info.ch[0], 516 .lcd_chan = &lcdc_info.ch[0],
517 .vsynw_offset = 17,
512}; 518};
513 519
514static struct platform_device mipidsi0_device = { 520static struct platform_device mipidsi0_device = {
@@ -521,84 +527,135 @@ static struct platform_device mipidsi0_device = {
521 }, 527 },
522}; 528};
523 529
524/* This function will disappear when we switch to (runtime) PM */ 530static struct platform_device *qhd_devices[] __initdata = {
525static int __init ap4evb_init_display_clk(void) 531 &mipidsi0_device,
532 &keysc_device,
533};
534#endif /* CONFIG_AP4EVB_QHD */
535
536/* FSI */
537#define IRQ_FSI evt2irq(0x1840)
538static int __fsi_set_rate(struct clk *clk, long rate, int enable)
526{ 539{
527 struct clk *lcdc_clk; 540 int ret = 0;
528 struct clk *dsitx_clk;
529 int ret;
530 541
531 lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0"); 542 if (rate <= 0)
532 if (IS_ERR(lcdc_clk)) 543 return ret;
533 return PTR_ERR(lcdc_clk);
534 544
535 dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0"); 545 if (enable) {
536 if (IS_ERR(dsitx_clk)) { 546 ret = clk_set_rate(clk, rate);
537 ret = PTR_ERR(dsitx_clk); 547 if (0 == ret)
538 goto eclkdsitxget; 548 ret = clk_enable(clk);
549 } else {
550 clk_disable(clk);
539 } 551 }
540 552
541 ret = clk_enable(lcdc_clk); 553 return ret;
542 if (ret < 0) 554}
543 goto eclklcdcon;
544 555
545 ret = clk_enable(dsitx_clk); 556static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
546 if (ret < 0) 557{
547 goto eclkdsitxon; 558 return __fsi_set_rate(clk, clk_round_rate(clk, rate), enable);
559}
548 560
549 return 0; 561static int fsi_ak4642_set_rate(struct device *dev, int rate, int enable)
562{
563 struct clk *fsia_ick;
564 struct clk *fsiack;
565 int ret = -EIO;
550 566
551eclkdsitxon: 567 fsia_ick = clk_get(dev, "icka");
552 clk_disable(lcdc_clk); 568 if (IS_ERR(fsia_ick))
553eclklcdcon: 569 return PTR_ERR(fsia_ick);
554 clk_put(dsitx_clk);
555eclkdsitxget:
556 clk_put(lcdc_clk);
557 570
558 return ret; 571 /*
559} 572 * FSIACK is connected to AK4642,
560device_initcall(ap4evb_init_display_clk); 573 * and use external clock pin from it.
574 * it is parent of fsia_ick now.
575 */
576 fsiack = clk_get_parent(fsia_ick);
577 if (!fsiack)
578 goto fsia_ick_out;
561 579
562static struct platform_device *qhd_devices[] __initdata = { 580 /*
563 &mipidsi0_device, 581 * we get 1/1 divided clock by setting same rate to fsiack and fsia_ick
564 &keysc_device, 582 *
565}; 583 ** FIXME **
566#endif /* CONFIG_AP4EVB_QHD */ 584 * Because the freq_table of external clk (fsiack) are all 0,
585 * the return value of clk_round_rate became 0.
586 * So, it use __fsi_set_rate here.
587 */
588 ret = __fsi_set_rate(fsiack, rate, enable);
589 if (ret < 0)
590 goto fsiack_out;
567 591
568/* FSI */ 592 ret = __fsi_set_round_rate(fsia_ick, rate, enable);
569#define IRQ_FSI evt2irq(0x1840) 593 if ((ret < 0) && enable)
594 __fsi_set_round_rate(fsiack, rate, 0); /* disable FSI ACK */
570 595
571static int fsi_set_rate(int is_porta, int rate) 596fsiack_out:
597 clk_put(fsiack);
598
599fsia_ick_out:
600 clk_put(fsia_ick);
601
602 return 0;
603}
604
605static int fsi_hdmi_set_rate(struct device *dev, int rate, int enable)
572{ 606{
573 struct clk *fsib_clk; 607 struct clk *fsib_clk;
574 struct clk *fdiv_clk = &sh7372_fsidivb_clk; 608 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
609 long fsib_rate = 0;
610 long fdiv_rate = 0;
611 int ackmd_bpfmd;
575 int ret; 612 int ret;
576 613
577 /* set_rate is not needed if port A */
578 if (is_porta)
579 return 0;
580
581 fsib_clk = clk_get(NULL, "fsib_clk");
582 if (IS_ERR(fsib_clk))
583 return -EINVAL;
584
585 switch (rate) { 614 switch (rate) {
586 case 44100: 615 case 44100:
587 clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000)); 616 fsib_rate = rate * 256;
588 ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64; 617 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
589 break; 618 break;
590 case 48000: 619 case 48000:
591 clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 85428000)); 620 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
592 clk_set_rate(fdiv_clk, clk_round_rate(fdiv_clk, 12204000)); 621 fdiv_rate = rate * 256;
593 ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64; 622 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
594 break; 623 break;
595 default: 624 default:
596 pr_err("unsupported rate in FSI2 port B\n"); 625 pr_err("unsupported rate in FSI2 port B\n");
597 ret = -EINVAL; 626 return -EINVAL;
598 break;
599 } 627 }
600 628
629 /* FSI B setting */
630 fsib_clk = clk_get(dev, "ickb");
631 if (IS_ERR(fsib_clk))
632 return -EIO;
633
634 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
601 clk_put(fsib_clk); 635 clk_put(fsib_clk);
636 if (ret < 0)
637 return ret;
638
639 /* FSI DIV setting */
640 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
641 if (ret < 0) {
642 /* disable FSI B */
643 if (enable)
644 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
645 return ret;
646 }
647
648 return ackmd_bpfmd;
649}
650
651static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
652{
653 int ret;
654
655 if (is_porta)
656 ret = fsi_ak4642_set_rate(dev, rate, enable);
657 else
658 ret = fsi_hdmi_set_rate(dev, rate, enable);
602 659
603 return ret; 660 return ret;
604} 661}
@@ -675,10 +732,15 @@ static struct platform_device lcdc1_device = {
675 }, 732 },
676}; 733};
677 734
735static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq,
736 unsigned long *parent_freq);
737
738
678static struct sh_mobile_hdmi_info hdmi_info = { 739static struct sh_mobile_hdmi_info hdmi_info = {
679 .lcd_chan = &sh_mobile_lcdc1_info.ch[0], 740 .lcd_chan = &sh_mobile_lcdc1_info.ch[0],
680 .lcd_dev = &lcdc1_device.dev, 741 .lcd_dev = &lcdc1_device.dev,
681 .flags = HDMI_SND_SRC_SPDIF, 742 .flags = HDMI_SND_SRC_SPDIF,
743 .clk_optimize_parent = ap4evb_clk_optimize,
682}; 744};
683 745
684static struct resource hdmi_resources[] = { 746static struct resource hdmi_resources[] = {
@@ -705,6 +767,25 @@ static struct platform_device hdmi_device = {
705 }, 767 },
706}; 768};
707 769
770static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq,
771 unsigned long *parent_freq)
772{
773 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
774 long error;
775
776 if (IS_ERR(hdmi_ick)) {
777 int ret = PTR_ERR(hdmi_ick);
778 pr_err("Cannot get HDMI ICK: %d\n", ret);
779 return ret;
780 }
781
782 error = clk_round_parent(hdmi_ick, target, best_freq, parent_freq, 1, 64);
783
784 clk_put(hdmi_ick);
785
786 return error;
787}
788
708static struct gpio_led ap4evb_leds[] = { 789static struct gpio_led ap4evb_leds[] = {
709 { 790 {
710 .name = "led4", 791 .name = "led4",
@@ -880,6 +961,11 @@ static int __init hdmi_init_pm_clock(void)
880 goto out; 961 goto out;
881 } 962 }
882 963
964 ret = clk_enable(&sh7372_pllc2_clk);
965 if (ret < 0) {
966 pr_err("Cannot enable pllc2 clock\n");
967 goto out;
968 }
883 pr_debug("PLLC2 set frequency %lu\n", rate); 969 pr_debug("PLLC2 set frequency %lu\n", rate);
884 970
885 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk); 971 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
@@ -896,23 +982,11 @@ out:
896 982
897device_initcall(hdmi_init_pm_clock); 983device_initcall(hdmi_init_pm_clock);
898 984
899#define FSIACK_DUMMY_RATE 48000
900static int __init fsi_init_pm_clock(void) 985static int __init fsi_init_pm_clock(void)
901{ 986{
902 struct clk *fsia_ick; 987 struct clk *fsia_ick;
903 int ret; 988 int ret;
904 989
905 /*
906 * FSIACK is connected to AK4642,
907 * and the rate is depend on playing sound rate.
908 * So, set dummy rate (= 48k) here
909 */
910 ret = clk_set_rate(&sh7372_fsiack_clk, FSIACK_DUMMY_RATE);
911 if (ret < 0) {
912 pr_err("Cannot set FSIACK dummy rate: %d\n", ret);
913 return ret;
914 }
915
916 fsia_ick = clk_get(&fsi_device.dev, "icka"); 990 fsia_ick = clk_get(&fsi_device.dev, "icka");
917 if (IS_ERR(fsia_ick)) { 991 if (IS_ERR(fsia_ick)) {
918 ret = PTR_ERR(fsia_ick); 992 ret = PTR_ERR(fsia_ick);
@@ -921,16 +995,9 @@ static int __init fsi_init_pm_clock(void)
921 } 995 }
922 996
923 ret = clk_set_parent(fsia_ick, &sh7372_fsiack_clk); 997 ret = clk_set_parent(fsia_ick, &sh7372_fsiack_clk);
924 if (ret < 0) {
925 pr_err("Cannot set FSI-A parent: %d\n", ret);
926 goto out;
927 }
928
929 ret = clk_set_rate(fsia_ick, FSIACK_DUMMY_RATE);
930 if (ret < 0) 998 if (ret < 0)
931 pr_err("Cannot set FSI-A rate: %d\n", ret); 999 pr_err("Cannot set FSI-A parent: %d\n", ret);
932 1000
933out:
934 clk_put(fsia_ick); 1001 clk_put(fsia_ick);
935 1002
936 return ret; 1003 return ret;
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index 7db31e6c6bf2..66663adb21f8 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -220,8 +220,7 @@ static void pllc2_disable(struct clk *clk)
220 __raw_writel(__raw_readl(PLLC2CR) & ~0x80000000, PLLC2CR); 220 __raw_writel(__raw_readl(PLLC2CR) & ~0x80000000, PLLC2CR);
221} 221}
222 222
223static int pllc2_set_rate(struct clk *clk, 223static int pllc2_set_rate(struct clk *clk, unsigned long rate)
224 unsigned long rate, int algo_id)
225{ 224{
226 unsigned long value; 225 unsigned long value;
227 int idx; 226 int idx;
@@ -230,21 +229,13 @@ static int pllc2_set_rate(struct clk *clk,
230 if (idx < 0) 229 if (idx < 0)
231 return idx; 230 return idx;
232 231
233 if (rate == clk->parent->rate) { 232 if (rate == clk->parent->rate)
234 pllc2_disable(clk); 233 return -EINVAL;
235 return 0;
236 }
237 234
238 value = __raw_readl(PLLC2CR) & ~(0x3f << 24); 235 value = __raw_readl(PLLC2CR) & ~(0x3f << 24);
239 236
240 if (value & 0x80000000)
241 pllc2_disable(clk);
242
243 __raw_writel((value & ~0x80000000) | ((idx + 19) << 24), PLLC2CR); 237 __raw_writel((value & ~0x80000000) | ((idx + 19) << 24), PLLC2CR);
244 238
245 if (value & 0x80000000)
246 return pllc2_enable(clk);
247
248 return 0; 239 return 0;
249} 240}
250 241
@@ -453,32 +444,24 @@ static int fsidiv_enable(struct clk *clk)
453 unsigned long value; 444 unsigned long value;
454 445
455 value = __raw_readl(clk->mapping->base) >> 16; 446 value = __raw_readl(clk->mapping->base) >> 16;
456 if (value < 2) { 447 if (value < 2)
457 fsidiv_disable(clk); 448 return -EIO;
458 return -ENOENT;
459 }
460 449
461 __raw_writel((value << 16) | 0x3, clk->mapping->base); 450 __raw_writel((value << 16) | 0x3, clk->mapping->base);
462 451
463 return 0; 452 return 0;
464} 453}
465 454
466static int fsidiv_set_rate(struct clk *clk, 455static int fsidiv_set_rate(struct clk *clk, unsigned long rate)
467 unsigned long rate, int algo_id)
468{ 456{
469 int idx; 457 int idx;
470 458
471 if (clk->parent->rate == rate) {
472 fsidiv_disable(clk);
473 return 0;
474 }
475
476 idx = (clk->parent->rate / rate) & 0xffff; 459 idx = (clk->parent->rate / rate) & 0xffff;
477 if (idx < 2) 460 if (idx < 2)
478 return -ENOENT; 461 return -EINVAL;
479 462
480 __raw_writel(idx << 16, clk->mapping->base); 463 __raw_writel(idx << 16, clk->mapping->base);
481 return fsidiv_enable(clk); 464 return 0;
482} 465}
483 466
484static struct clk_ops fsidiv_clk_ops = { 467static struct clk_ops fsidiv_clk_ops = {
@@ -524,7 +507,7 @@ enum { MSTP001,
524 MSTP223, 507 MSTP223,
525 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 508 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
526 MSTP329, MSTP328, MSTP323, MSTP322, MSTP314, MSTP313, MSTP312, 509 MSTP329, MSTP328, MSTP323, MSTP322, MSTP314, MSTP313, MSTP312,
527 MSTP415, MSTP413, MSTP411, MSTP410, MSTP406, MSTP403, 510 MSTP423, MSTP415, MSTP413, MSTP411, MSTP410, MSTP406, MSTP403,
528 MSTP_NR }; 511 MSTP_NR };
529 512
530#define MSTP(_parent, _reg, _bit, _flags) \ 513#define MSTP(_parent, _reg, _bit, _flags) \
@@ -560,6 +543,7 @@ static struct clk mstp_clks[MSTP_NR] = {
560 [MSTP314] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 14, 0), /* SDHI0 */ 543 [MSTP314] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 14, 0), /* SDHI0 */
561 [MSTP313] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 13, 0), /* SDHI1 */ 544 [MSTP313] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 13, 0), /* SDHI1 */
562 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMC */ 545 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMC */
546 [MSTP423] = MSTP(&div4_clks[DIV4_B], SMSTPCR4, 23, 0), /* DSITX1 */
563 [MSTP415] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 15, 0), /* SDHI2 */ 547 [MSTP415] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 15, 0), /* SDHI2 */
564 [MSTP413] = MSTP(&pllc1_div2_clk, SMSTPCR4, 13, 0), /* HDMI */ 548 [MSTP413] = MSTP(&pllc1_div2_clk, SMSTPCR4, 13, 0), /* HDMI */
565 [MSTP411] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR4, 11, 0), /* IIC3 */ 549 [MSTP411] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR4, 11, 0), /* IIC3 */
@@ -609,15 +593,14 @@ static struct clk_lookup lookups[] = {
609 CLKDEV_CON_ID("vck3_clk", &div6_clks[DIV6_VCK3]), 593 CLKDEV_CON_ID("vck3_clk", &div6_clks[DIV6_VCK3]),
610 CLKDEV_CON_ID("fmsi_clk", &div6_clks[DIV6_FMSI]), 594 CLKDEV_CON_ID("fmsi_clk", &div6_clks[DIV6_FMSI]),
611 CLKDEV_CON_ID("fmso_clk", &div6_clks[DIV6_FMSO]), 595 CLKDEV_CON_ID("fmso_clk", &div6_clks[DIV6_FMSO]),
612 CLKDEV_CON_ID("fsia_clk", &div6_reparent_clks[DIV6_FSIA]),
613 CLKDEV_CON_ID("fsib_clk", &div6_reparent_clks[DIV6_FSIB]),
614 CLKDEV_CON_ID("sub_clk", &div6_clks[DIV6_SUB]), 596 CLKDEV_CON_ID("sub_clk", &div6_clks[DIV6_SUB]),
615 CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_SPU]), 597 CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_SPU]),
616 CLKDEV_CON_ID("vou_clk", &div6_clks[DIV6_VOU]), 598 CLKDEV_CON_ID("vou_clk", &div6_clks[DIV6_VOU]),
617 CLKDEV_CON_ID("hdmi_clk", &div6_reparent_clks[DIV6_HDMI]), 599 CLKDEV_CON_ID("hdmi_clk", &div6_reparent_clks[DIV6_HDMI]),
618 CLKDEV_CON_ID("dsit_clk", &div6_clks[DIV6_DSIT]), 600 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSIT]),
619 CLKDEV_CON_ID("dsi0p_clk", &div6_clks[DIV6_DSI0P]), 601 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSIT]),
620 CLKDEV_CON_ID("dsi1p_clk", &div6_clks[DIV6_DSI1P]), 602 CLKDEV_ICK_ID("dsi0p_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSI0P]),
603 CLKDEV_ICK_ID("dsi1p_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]),
621 604
622 /* MSTP32 clocks */ 605 /* MSTP32 clocks */
623 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* IIC2 */ 606 CLKDEV_DEV_ID("i2c-sh_mobile.2", &mstp_clks[MSTP001]), /* IIC2 */
@@ -629,7 +612,7 @@ static struct clk_lookup lookups[] = {
629 CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */ 612 CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */
630 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */ 613 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */
631 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */ 614 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */
632 CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX */ 615 CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX0 */
633 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */ 616 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */
634 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */ 617 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */
635 CLKDEV_DEV_ID("uio_pdrv_genirq.5", &mstp_clks[MSTP106]), /* JPU */ 618 CLKDEV_DEV_ID("uio_pdrv_genirq.5", &mstp_clks[MSTP106]), /* JPU */
@@ -647,11 +630,12 @@ static struct clk_lookup lookups[] = {
647 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */ 630 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
648 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI2 */ 631 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI2 */
649 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* IIC1 */ 632 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* IIC1 */
650 CLKDEV_DEV_ID("r8a66597_hcd.0", &mstp_clks[MSTP323]), /* USB0 */ 633 CLKDEV_DEV_ID("r8a66597_hcd.0", &mstp_clks[MSTP322]), /* USB0 */
651 CLKDEV_DEV_ID("r8a66597_udc.0", &mstp_clks[MSTP323]), /* USB0 */ 634 CLKDEV_DEV_ID("r8a66597_udc.0", &mstp_clks[MSTP322]), /* USB0 */
652 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */ 635 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */
653 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */ 636 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */
654 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMC */ 637 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMC */
638 CLKDEV_DEV_ID("sh-mipi-dsi.1", &mstp_clks[MSTP423]), /* DSITX1 */
655 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP415]), /* SDHI2 */ 639 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP415]), /* SDHI2 */
656 CLKDEV_DEV_ID("sh-mobile-hdmi", &mstp_clks[MSTP413]), /* HDMI */ 640 CLKDEV_DEV_ID("sh-mobile-hdmi", &mstp_clks[MSTP413]), /* HDMI */
657 CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* IIC3 */ 641 CLKDEV_DEV_ID("i2c-sh_mobile.3", &mstp_clks[MSTP411]), /* IIC3 */
diff --git a/arch/arm/mach-shmobile/include/mach/entry-macro.S b/arch/arm/mach-shmobile/include/mach/entry-macro.S
index a285d13c7416..f428c4db2b60 100644
--- a/arch/arm/mach-shmobile/include/mach/entry-macro.S
+++ b/arch/arm/mach-shmobile/include/mach/entry-macro.S
@@ -1,4 +1,5 @@
1/* 1/*
2 * Copyright (C) 2010 Magnus Damm
2 * Copyright (C) 2008 Renesas Solutions Corp. 3 * Copyright (C) 2008 Renesas Solutions Corp.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
@@ -14,24 +15,45 @@
14 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */ 17 */
17#include <mach/hardware.h>
18#include <mach/irqs.h> 18#include <mach/irqs.h>
19 19
20#define INTCA_BASE 0xe6980000
21#define INTFLGA_OFFS 0x00000018 /* accept pending interrupt */
22#define INTEVTA_OFFS 0x00000020 /* vector number of accepted interrupt */
23#define INTLVLA_OFFS 0x00000030 /* priority level of accepted interrupt */
24#define INTLVLB_OFFS 0x00000034 /* previous priority level */
25
20 .macro disable_fiq 26 .macro disable_fiq
21 .endm 27 .endm
22 28
23 .macro get_irqnr_preamble, base, tmp 29 .macro get_irqnr_preamble, base, tmp
24 ldr \base, =INTFLGA 30 ldr \base, =INTCA_BASE
25 .endm 31 .endm
26 32
27 .macro arch_ret_to_user, tmp1, tmp2 33 .macro arch_ret_to_user, tmp1, tmp2
28 .endm 34 .endm
29 35
30 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 36 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
31 ldr \irqnr, [\base] 37 /* The single INTFLGA read access below results in the following:
38 *
39 * 1. INTLVLB is updated with old priority value from INTLVLA
40 * 2. Highest priority interrupt is accepted
41 * 3. INTLVLA is updated to contain priority of accepted interrupt
42 * 4. Accepted interrupt vector is stored in INTFLGA and INTEVTA
43 */
44 ldr \irqnr, [\base, #INTFLGA_OFFS]
45
46 /* Restore INTLVLA with the value saved in INTLVLB.
47 * This is required to support interrupt priorities properly.
48 */
49 ldrb \tmp, [\base, #INTLVLB_OFFS]
50 strb \tmp, [\base, #INTLVLA_OFFS]
51
52 /* Handle invalid vector number case */
32 cmp \irqnr, #0 53 cmp \irqnr, #0
33 beq 1000f 54 beq 1000f
34 /* intevt to irq number */ 55
56 /* Convert vector to irq number, same as the evt2irq() macro */
35 lsr \irqnr, \irqnr, #0x5 57 lsr \irqnr, \irqnr, #0x5
36 subs \irqnr, \irqnr, #16 58 subs \irqnr, \irqnr, #16
37 59
diff --git a/arch/arm/mach-shmobile/include/mach/vmalloc.h b/arch/arm/mach-shmobile/include/mach/vmalloc.h
index 4aecf6e3a859..2b8fd8b942fe 100644
--- a/arch/arm/mach-shmobile/include/mach/vmalloc.h
+++ b/arch/arm/mach-shmobile/include/mach/vmalloc.h
@@ -2,6 +2,6 @@
2#define __ASM_MACH_VMALLOC_H 2#define __ASM_MACH_VMALLOC_H
3 3
4/* Vmalloc at ... - 0xe5ffffff */ 4/* Vmalloc at ... - 0xe5ffffff */
5#define VMALLOC_END 0xe6000000 5#define VMALLOC_END 0xe6000000UL
6 6
7#endif /* __ASM_MACH_VMALLOC_H */ 7#endif /* __ASM_MACH_VMALLOC_H */
diff --git a/arch/arm/mach-tegra/include/mach/debug-macro.S b/arch/arm/mach-tegra/include/mach/debug-macro.S
index 8ea3bffb4e00..a0e7c12868bd 100644
--- a/arch/arm/mach-tegra/include/mach/debug-macro.S
+++ b/arch/arm/mach-tegra/include/mach/debug-macro.S
@@ -21,8 +21,8 @@
21#include <mach/io.h> 21#include <mach/io.h>
22 22
23 .macro addruart, rp, rv 23 .macro addruart, rp, rv
24 ldreq \rp, =IO_APB_PHYS @ physical 24 ldr \rp, =IO_APB_PHYS @ physical
25 ldrne \rv, =IO_APB_VIRT @ virtual 25 ldr \rv, =IO_APB_VIRT @ virtual
26#if defined(CONFIG_TEGRA_DEBUG_UART_NONE) 26#if defined(CONFIG_TEGRA_DEBUG_UART_NONE)
27#error "A debug UART must be selected in the kernel config to use DEBUG_LL" 27#error "A debug UART must be selected in the kernel config to use DEBUG_LL"
28#elif defined(CONFIG_TEGRA_DEBUG_UARTA) 28#elif defined(CONFIG_TEGRA_DEBUG_UARTA)
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
index 73fb1a551ec6..608a1372b172 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -75,14 +75,14 @@ void __init ux500_init_irq(void)
75static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask) 75static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask)
76{ 76{
77 /* wait for the operation to complete */ 77 /* wait for the operation to complete */
78 while (readl(reg) & mask) 78 while (readl_relaxed(reg) & mask)
79 ; 79 ;
80} 80}
81 81
82static inline void ux500_cache_sync(void) 82static inline void ux500_cache_sync(void)
83{ 83{
84 void __iomem *base = __io_address(UX500_L2CC_BASE); 84 void __iomem *base = __io_address(UX500_L2CC_BASE);
85 writel(0, base + L2X0_CACHE_SYNC); 85 writel_relaxed(0, base + L2X0_CACHE_SYNC);
86 ux500_cache_wait(base + L2X0_CACHE_SYNC, 1); 86 ux500_cache_wait(base + L2X0_CACHE_SYNC, 1);
87} 87}
88 88
@@ -107,7 +107,7 @@ static void ux500_l2x0_inv_all(void)
107 uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */ 107 uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */
108 108
109 /* invalidate all ways */ 109 /* invalidate all ways */
110 writel(l2x0_way_mask, l2x0_base + L2X0_INV_WAY); 110 writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_INV_WAY);
111 ux500_cache_wait(l2x0_base + L2X0_INV_WAY, l2x0_way_mask); 111 ux500_cache_wait(l2x0_base + L2X0_INV_WAY, l2x0_way_mask);
112 ux500_cache_sync(); 112 ux500_cache_sync();
113} 113}
diff --git a/arch/arm/mach-versatile/include/mach/vmalloc.h b/arch/arm/mach-versatile/include/mach/vmalloc.h
index ebd8a2543d3b..7d8e069ad51b 100644
--- a/arch/arm/mach-versatile/include/mach/vmalloc.h
+++ b/arch/arm/mach-versatile/include/mach/vmalloc.h
@@ -18,4 +18,4 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21#define VMALLOC_END 0xd8000000 21#define VMALLOC_END 0xd8000000UL
diff --git a/arch/arm/mach-vexpress/headsmp.S b/arch/arm/mach-vexpress/headsmp.S
index 8a78ff68e1ee..7a3f0632947c 100644
--- a/arch/arm/mach-vexpress/headsmp.S
+++ b/arch/arm/mach-vexpress/headsmp.S
@@ -35,5 +35,6 @@ pen: ldr r7, [r6]
35 */ 35 */
36 b secondary_startup 36 b secondary_startup
37 37
38 .align
381: .long . 391: .long .
39 .long pen_release 40 .long pen_release
diff --git a/arch/arm/mm/cache-v6.S b/arch/arm/mm/cache-v6.S
index 99fa688dfadd..c96fa1b3f49f 100644
--- a/arch/arm/mm/cache-v6.S
+++ b/arch/arm/mm/cache-v6.S
@@ -203,6 +203,10 @@ ENTRY(v6_flush_kern_dcache_area)
203 * - end - virtual end address of region 203 * - end - virtual end address of region
204 */ 204 */
205v6_dma_inv_range: 205v6_dma_inv_range:
206#ifdef CONFIG_DMA_CACHE_RWFO
207 ldrb r2, [r0] @ read for ownership
208 strb r2, [r0] @ write for ownership
209#endif
206 tst r0, #D_CACHE_LINE_SIZE - 1 210 tst r0, #D_CACHE_LINE_SIZE - 1
207 bic r0, r0, #D_CACHE_LINE_SIZE - 1 211 bic r0, r0, #D_CACHE_LINE_SIZE - 1
208#ifdef HARVARD_CACHE 212#ifdef HARVARD_CACHE
@@ -211,6 +215,10 @@ v6_dma_inv_range:
211 mcrne p15, 0, r0, c7, c11, 1 @ clean unified line 215 mcrne p15, 0, r0, c7, c11, 1 @ clean unified line
212#endif 216#endif
213 tst r1, #D_CACHE_LINE_SIZE - 1 217 tst r1, #D_CACHE_LINE_SIZE - 1
218#ifdef CONFIG_DMA_CACHE_RWFO
219 ldrneb r2, [r1, #-1] @ read for ownership
220 strneb r2, [r1, #-1] @ write for ownership
221#endif
214 bic r1, r1, #D_CACHE_LINE_SIZE - 1 222 bic r1, r1, #D_CACHE_LINE_SIZE - 1
215#ifdef HARVARD_CACHE 223#ifdef HARVARD_CACHE
216 mcrne p15, 0, r1, c7, c14, 1 @ clean & invalidate D line 224 mcrne p15, 0, r1, c7, c14, 1 @ clean & invalidate D line
@@ -218,10 +226,6 @@ v6_dma_inv_range:
218 mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line 226 mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line
219#endif 227#endif
2201: 2281:
221#ifdef CONFIG_DMA_CACHE_RWFO
222 ldr r2, [r0] @ read for ownership
223 str r2, [r0] @ write for ownership
224#endif
225#ifdef HARVARD_CACHE 229#ifdef HARVARD_CACHE
226 mcr p15, 0, r0, c7, c6, 1 @ invalidate D line 230 mcr p15, 0, r0, c7, c6, 1 @ invalidate D line
227#else 231#else
@@ -229,6 +233,10 @@ v6_dma_inv_range:
229#endif 233#endif
230 add r0, r0, #D_CACHE_LINE_SIZE 234 add r0, r0, #D_CACHE_LINE_SIZE
231 cmp r0, r1 235 cmp r0, r1
236#ifdef CONFIG_DMA_CACHE_RWFO
237 ldrlo r2, [r0] @ read for ownership
238 strlo r2, [r0] @ write for ownership
239#endif
232 blo 1b 240 blo 1b
233 mov r0, #0 241 mov r0, #0
234 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer 242 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
@@ -263,12 +271,12 @@ v6_dma_clean_range:
263 * - end - virtual end address of region 271 * - end - virtual end address of region
264 */ 272 */
265ENTRY(v6_dma_flush_range) 273ENTRY(v6_dma_flush_range)
266 bic r0, r0, #D_CACHE_LINE_SIZE - 1
2671:
268#ifdef CONFIG_DMA_CACHE_RWFO 274#ifdef CONFIG_DMA_CACHE_RWFO
269 ldr r2, [r0] @ read for ownership 275 ldrb r2, [r0] @ read for ownership
270 str r2, [r0] @ write for ownership 276 strb r2, [r0] @ write for ownership
271#endif 277#endif
278 bic r0, r0, #D_CACHE_LINE_SIZE - 1
2791:
272#ifdef HARVARD_CACHE 280#ifdef HARVARD_CACHE
273 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line 281 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
274#else 282#else
@@ -276,6 +284,10 @@ ENTRY(v6_dma_flush_range)
276#endif 284#endif
277 add r0, r0, #D_CACHE_LINE_SIZE 285 add r0, r0, #D_CACHE_LINE_SIZE
278 cmp r0, r1 286 cmp r0, r1
287#ifdef CONFIG_DMA_CACHE_RWFO
288 ldrlob r2, [r0] @ read for ownership
289 strlob r2, [r0] @ write for ownership
290#endif
279 blo 1b 291 blo 1b
280 mov r0, #0 292 mov r0, #0
281 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer 293 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
index a3ebf7a4f49b..6136e68ce953 100644
--- a/arch/arm/mm/cache-v7.S
+++ b/arch/arm/mm/cache-v7.S
@@ -173,15 +173,22 @@ ENTRY(v7_coherent_user_range)
173 UNWIND(.fnstart ) 173 UNWIND(.fnstart )
174 dcache_line_size r2, r3 174 dcache_line_size r2, r3
175 sub r3, r2, #1 175 sub r3, r2, #1
176 bic r0, r0, r3 176 bic r12, r0, r3
1771: 1771:
178 USER( mcr p15, 0, r0, c7, c11, 1 ) @ clean D line to the point of unification 178 USER( mcr p15, 0, r12, c7, c11, 1 ) @ clean D line to the point of unification
179 add r12, r12, r2
180 cmp r12, r1
181 blo 1b
179 dsb 182 dsb
180 USER( mcr p15, 0, r0, c7, c5, 1 ) @ invalidate I line 183 icache_line_size r2, r3
181 add r0, r0, r2 184 sub r3, r2, #1
185 bic r12, r0, r3
1822: 1862:
183 cmp r0, r1 187 USER( mcr p15, 0, r12, c7, c5, 1 ) @ invalidate I line
184 blo 1b 188 add r12, r12, r2
189 cmp r12, r1
190 blo 2b
1913:
185 mov r0, #0 192 mov r0, #0
186 ALT_SMP(mcr p15, 0, r0, c7, c1, 6) @ invalidate BTB Inner Shareable 193 ALT_SMP(mcr p15, 0, r0, c7, c1, 6) @ invalidate BTB Inner Shareable
187 ALT_UP(mcr p15, 0, r0, c7, c5, 6) @ invalidate BTB 194 ALT_UP(mcr p15, 0, r0, c7, c5, 6) @ invalidate BTB
@@ -194,10 +201,10 @@ ENTRY(v7_coherent_user_range)
194 * isn't mapped, just try the next page. 201 * isn't mapped, just try the next page.
195 */ 202 */
1969001: 2039001:
197 mov r0, r0, lsr #12 204 mov r12, r12, lsr #12
198 mov r0, r0, lsl #12 205 mov r12, r12, lsl #12
199 add r0, r0, #4096 206 add r12, r12, #4096
200 b 2b 207 b 3b
201 UNWIND(.fnend ) 208 UNWIND(.fnend )
202ENDPROC(v7_coherent_kern_range) 209ENDPROC(v7_coherent_kern_range)
203ENDPROC(v7_coherent_user_range) 210ENDPROC(v7_coherent_user_range)
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 17e7b0b57e49..55c17a6fb22f 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -206,8 +206,8 @@ void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn,
206 */ 206 */
207 if (pfn_valid(pfn)) { 207 if (pfn_valid(pfn)) {
208 printk(KERN_WARNING "BUG: Your driver calls ioremap() on system memory. This leads\n" 208 printk(KERN_WARNING "BUG: Your driver calls ioremap() on system memory. This leads\n"
209 KERN_WARNING "to architecturally unpredictable behaviour on ARMv6+, and ioremap()\n" 209 "to architecturally unpredictable behaviour on ARMv6+, and ioremap()\n"
210 KERN_WARNING "will fail in the next kernel release. Please fix your driver.\n"); 210 "will fail in the next kernel release. Please fix your driver.\n");
211 WARN_ON(1); 211 WARN_ON(1);
212 } 212 }
213 213
diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
index 7d63beaf9745..b795afd0a2c6 100644
--- a/arch/arm/mm/proc-macros.S
+++ b/arch/arm/mm/proc-macros.S
@@ -61,17 +61,27 @@
61 .endm 61 .endm
62 62
63/* 63/*
64 * cache_line_size - get the cache line size from the CSIDR register 64 * dcache_line_size - get the minimum D-cache line size from the CTR register
65 * (available on ARMv7+). It assumes that the CSSR register was configured 65 * on ARMv7.
66 * to access the L1 data cache CSIDR.
67 */ 66 */
68 .macro dcache_line_size, reg, tmp 67 .macro dcache_line_size, reg, tmp
69 mrc p15, 1, \tmp, c0, c0, 0 @ read CSIDR 68 mrc p15, 0, \tmp, c0, c0, 1 @ read ctr
70 and \tmp, \tmp, #7 @ cache line size encoding 69 lsr \tmp, \tmp, #16
71 mov \reg, #16 @ size offset 70 and \tmp, \tmp, #0xf @ cache line size encoding
71 mov \reg, #4 @ bytes per word
72 mov \reg, \reg, lsl \tmp @ actual cache line size 72 mov \reg, \reg, lsl \tmp @ actual cache line size
73 .endm 73 .endm
74 74
75/*
76 * icache_line_size - get the minimum I-cache line size from the CTR register
77 * on ARMv7.
78 */
79 .macro icache_line_size, reg, tmp
80 mrc p15, 0, \tmp, c0, c0, 1 @ read ctr
81 and \tmp, \tmp, #0xf @ cache line size encoding
82 mov \reg, #4 @ bytes per word
83 mov \reg, \reg, lsl \tmp @ actual cache line size
84 .endm
75 85
76/* 86/*
77 * Sanity check the PTE configuration for the code below - which makes 87 * Sanity check the PTE configuration for the code below - which makes
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 53cbe2225153..9b9ff5d949fd 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -381,7 +381,7 @@ __v7_ca9mp_proc_info:
381 PMD_SECT_XN | \ 381 PMD_SECT_XN | \
382 PMD_SECT_AP_WRITE | \ 382 PMD_SECT_AP_WRITE | \
383 PMD_SECT_AP_READ 383 PMD_SECT_AP_READ
384 b __v7_ca9mp_setup 384 W(b) __v7_ca9mp_setup
385 .long cpu_arch_name 385 .long cpu_arch_name
386 .long cpu_elf_name 386 .long cpu_elf_name
387 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_TLS 387 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_TLS
@@ -413,7 +413,7 @@ __v7_proc_info:
413 PMD_SECT_XN | \ 413 PMD_SECT_XN | \
414 PMD_SECT_AP_WRITE | \ 414 PMD_SECT_AP_WRITE | \
415 PMD_SECT_AP_READ 415 PMD_SECT_AP_READ
416 b __v7_setup 416 W(b) __v7_setup
417 .long cpu_arch_name 417 .long cpu_arch_name
418 .long cpu_elf_name 418 .long cpu_elf_name
419 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_TLS 419 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_TLS
diff --git a/arch/arm/plat-iop/time.c b/arch/arm/plat-iop/time.c
index 85d3e55ca4a9..558cdfaf76b6 100644
--- a/arch/arm/plat-iop/time.c
+++ b/arch/arm/plat-iop/time.c
@@ -18,6 +18,7 @@
18#include <linux/time.h> 18#include <linux/time.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/timex.h> 20#include <linux/timex.h>
21#include <linux/sched.h>
21#include <linux/io.h> 22#include <linux/io.h>
22#include <linux/clocksource.h> 23#include <linux/clocksource.h>
23#include <linux/clockchips.h> 24#include <linux/clockchips.h>
@@ -36,7 +37,7 @@
36/* 37/*
37 * IOP clocksource (free-running timer 1). 38 * IOP clocksource (free-running timer 1).
38 */ 39 */
39static cycle_t iop_clocksource_read(struct clocksource *unused) 40static cycle_t notrace iop_clocksource_read(struct clocksource *unused)
40{ 41{
41 return 0xffffffffu - read_tcr1(); 42 return 0xffffffffu - read_tcr1();
42} 43}
diff --git a/arch/arm/plat-mxc/devices/platform-imx-dma.c b/arch/arm/plat-mxc/devices/platform-imx-dma.c
index 02d989018059..3a705c7877dd 100644
--- a/arch/arm/plat-mxc/devices/platform-imx-dma.c
+++ b/arch/arm/plat-mxc/devices/platform-imx-dma.c
@@ -12,15 +12,7 @@
12 12
13#include <mach/hardware.h> 13#include <mach/hardware.h>
14#include <mach/devices-common.h> 14#include <mach/devices-common.h>
15#ifdef SDMA_IS_MERGED
16#include <mach/sdma.h> 15#include <mach/sdma.h>
17#else
18struct sdma_platform_data {
19 int sdma_version;
20 char *cpu_name;
21 int to_version;
22};
23#endif
24 16
25struct imx_imx_sdma_data { 17struct imx_imx_sdma_data {
26 resource_size_t iobase; 18 resource_size_t iobase;
diff --git a/arch/arm/plat-mxc/devices/platform-spi_imx.c b/arch/arm/plat-mxc/devices/platform-spi_imx.c
index e48340ec331e..17f724c9452d 100644
--- a/arch/arm/plat-mxc/devices/platform-spi_imx.c
+++ b/arch/arm/plat-mxc/devices/platform-spi_imx.c
@@ -27,6 +27,7 @@ const struct imx_spi_imx_data imx21_cspi_data[] __initconst = {
27 imx_spi_imx_data_entry(MX21, CSPI, "imx21-cspi", _id, _hwid, SZ_4K) 27 imx_spi_imx_data_entry(MX21, CSPI, "imx21-cspi", _id, _hwid, SZ_4K)
28 imx21_cspi_data_entry(0, 1), 28 imx21_cspi_data_entry(0, 1),
29 imx21_cspi_data_entry(1, 2), 29 imx21_cspi_data_entry(1, 2),
30};
30#endif 31#endif
31 32
32#ifdef CONFIG_ARCH_MX25 33#ifdef CONFIG_ARCH_MX25
diff --git a/arch/arm/plat-nomadik/timer.c b/arch/arm/plat-nomadik/timer.c
index aedf9c1d645e..63cdc6025bd7 100644
--- a/arch/arm/plat-nomadik/timer.c
+++ b/arch/arm/plat-nomadik/timer.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2008 STMicroelectronics 4 * Copyright (C) 2008 STMicroelectronics
5 * Copyright (C) 2010 Alessandro Rubini 5 * Copyright (C) 2010 Alessandro Rubini
6 * Copyright (C) 2010 Linus Walleij for ST-Ericsson
6 * 7 *
7 * 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
8 * it under the terms of the GNU General Public License version 2, as 9 * it under the terms of the GNU General Public License version 2, as
@@ -16,11 +17,13 @@
16#include <linux/clk.h> 17#include <linux/clk.h>
17#include <linux/jiffies.h> 18#include <linux/jiffies.h>
18#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/cnt32_to_63.h>
21#include <linux/timer.h>
19#include <asm/mach/time.h> 22#include <asm/mach/time.h>
20 23
21#include <plat/mtu.h> 24#include <plat/mtu.h>
22 25
23void __iomem *mtu_base; /* ssigned by machine code */ 26void __iomem *mtu_base; /* Assigned by machine code */
24 27
25/* 28/*
26 * Kernel assumes that sched_clock can be called early 29 * Kernel assumes that sched_clock can be called early
@@ -48,16 +51,82 @@ static struct clocksource nmdk_clksrc = {
48/* 51/*
49 * Override the global weak sched_clock symbol with this 52 * Override the global weak sched_clock symbol with this
50 * local implementation which uses the clocksource to get some 53 * local implementation which uses the clocksource to get some
51 * better resolution when scheduling the kernel. We accept that 54 * better resolution when scheduling the kernel.
52 * this wraps around for now, since it is just a relative time 55 *
53 * stamp. (Inspired by OMAP implementation.) 56 * Because the hardware timer period may be quite short
57 * (32.3 secs on the 133 MHz MTU timer selection on ux500)
58 * and because cnt32_to_63() needs to be called at least once per
59 * half period to work properly, a kernel keepwarm() timer is set up
60 * to ensure this requirement is always met.
61 *
62 * Also the sched_clock timer will wrap around at some point,
63 * here we set it to run continously for a year.
54 */ 64 */
65#define SCHED_CLOCK_MIN_WRAP 3600*24*365
66static struct timer_list cnt32_to_63_keepwarm_timer;
67static u32 sched_mult;
68static u32 sched_shift;
69
55unsigned long long notrace sched_clock(void) 70unsigned long long notrace sched_clock(void)
56{ 71{
57 return clocksource_cyc2ns(nmdk_clksrc.read( 72 u64 cycles;
58 &nmdk_clksrc), 73
59 nmdk_clksrc.mult, 74 if (unlikely(!mtu_base))
60 nmdk_clksrc.shift); 75 return 0;
76
77 cycles = cnt32_to_63(-readl(mtu_base + MTU_VAL(0)));
78 /*
79 * sched_mult is guaranteed to be even so will
80 * shift out bit 63
81 */
82 return (cycles * sched_mult) >> sched_shift;
83}
84
85/* Just kick sched_clock every so often */
86static void cnt32_to_63_keepwarm(unsigned long data)
87{
88 mod_timer(&cnt32_to_63_keepwarm_timer, round_jiffies(jiffies + data));
89 (void) sched_clock();
90}
91
92/*
93 * Set up a timer to keep sched_clock():s 32_to_63 algorithm warm
94 * once in half a 32bit timer wrap interval.
95 */
96static void __init nmdk_sched_clock_init(unsigned long rate)
97{
98 u32 v;
99 unsigned long delta;
100 u64 days;
101
102 /* Find the apropriate mult and shift factors */
103 clocks_calc_mult_shift(&sched_mult, &sched_shift,
104 rate, NSEC_PER_SEC, SCHED_CLOCK_MIN_WRAP);
105 /* We need to multiply by an even number to get rid of bit 63 */
106 if (sched_mult & 1)
107 sched_mult++;
108
109 /* Let's see what we get, take max counter and scale it */
110 days = (0xFFFFFFFFFFFFFFFFLLU * sched_mult) >> sched_shift;
111 do_div(days, NSEC_PER_SEC);
112 do_div(days, (3600*24));
113
114 pr_info("sched_clock: using %d bits @ %lu Hz wrap in %lu days\n",
115 (64 - sched_shift), rate, (unsigned long) days);
116
117 /*
118 * Program a timer to kick us at half 32bit wraparound
119 * Formula: seconds per wrap = (2^32) / f
120 */
121 v = 0xFFFFFFFFUL / rate;
122 /* We want half of the wrap time to keep cnt32_to_63 warm */
123 v /= 2;
124 pr_debug("sched_clock: prescaled timer rate: %lu Hz, "
125 "initialize keepwarm timer every %d seconds\n", rate, v);
126 /* Convert seconds to jiffies */
127 delta = msecs_to_jiffies(v*1000);
128 setup_timer(&cnt32_to_63_keepwarm_timer, cnt32_to_63_keepwarm, delta);
129 mod_timer(&cnt32_to_63_keepwarm_timer, round_jiffies(jiffies + delta));
61} 130}
62 131
63/* Clockevent device: use one-shot mode */ 132/* Clockevent device: use one-shot mode */
@@ -161,13 +230,15 @@ void __init nmdk_timer_init(void)
161 writel(0, mtu_base + MTU_BGLR(0)); 230 writel(0, mtu_base + MTU_BGLR(0));
162 writel(cr | MTU_CRn_ENA, mtu_base + MTU_CR(0)); 231 writel(cr | MTU_CRn_ENA, mtu_base + MTU_CR(0));
163 232
164 /* Now the scheduling clock is ready */ 233 /* Now the clock source is ready */
165 nmdk_clksrc.read = nmdk_read_timer; 234 nmdk_clksrc.read = nmdk_read_timer;
166 235
167 if (clocksource_register(&nmdk_clksrc)) 236 if (clocksource_register(&nmdk_clksrc))
168 pr_err("timer: failed to initialize clock source %s\n", 237 pr_err("timer: failed to initialize clock source %s\n",
169 nmdk_clksrc.name); 238 nmdk_clksrc.name);
170 239
240 nmdk_sched_clock_init(rate);
241
171 /* Timer 1 is used for events */ 242 /* Timer 1 is used for events */
172 243
173 clockevents_calc_mult_shift(&nmdk_clkevt, rate, MTU_MIN_RANGE); 244 clockevents_calc_mult_shift(&nmdk_clkevt, rate, MTU_MIN_RANGE);
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index 155fe43a672b..8722a136f3a5 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/clk.h> 17#include <linux/clk.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/err.h>
19 20
20#include <plat/common.h> 21#include <plat/common.h>
21#include <plat/board.h> 22#include <plat/board.h>
@@ -164,7 +165,7 @@ static int __init omap_init_clocksource_32k(void)
164 return -ENODEV; 165 return -ENODEV;
165 166
166 sync_32k_ick = clk_get(NULL, "omap_32ksync_ick"); 167 sync_32k_ick = clk_get(NULL, "omap_32ksync_ick");
167 if (sync_32k_ick) 168 if (!IS_ERR(sync_32k_ick))
168 clk_enable(sync_32k_ick); 169 clk_enable(sync_32k_ick);
169 170
170 clocksource_32k.mult = clocksource_hz2mult(32768, 171 clocksource_32k.mult = clocksource_hz2mult(32768,
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index e2c8eebe6b3a..74dac419d328 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -166,7 +166,7 @@ static void __init omap_detect_sram(void)
166 cpu_is_omap1710()) 166 cpu_is_omap1710())
167 omap_sram_size = 0x4000; /* 16K */ 167 omap_sram_size = 0x4000; /* 16K */
168 else if (cpu_is_omap1611()) 168 else if (cpu_is_omap1611())
169 omap_sram_size = 0x3e800; /* 250K */ 169 omap_sram_size = SZ_256K;
170 else { 170 else {
171 printk(KERN_ERR "Could not detect SRAM size\n"); 171 printk(KERN_ERR "Could not detect SRAM size\n");
172 omap_sram_size = 0x4000; 172 omap_sram_size = 0x4000;
diff --git a/arch/arm/plat-pxa/include/plat/sdhci.h b/arch/arm/plat-pxa/include/plat/sdhci.h
index e49c5b6fc4e2..1ab332e37d7d 100644
--- a/arch/arm/plat-pxa/include/plat/sdhci.h
+++ b/arch/arm/plat-pxa/include/plat/sdhci.h
@@ -17,6 +17,9 @@
17/* Require clock free running */ 17/* Require clock free running */
18#define PXA_FLAG_DISABLE_CLOCK_GATING (1<<0) 18#define PXA_FLAG_DISABLE_CLOCK_GATING (1<<0)
19 19
20/* Board design supports 8-bit data on SD/SDIO BUS */
21#define PXA_FLAG_SD_8_BIT_CAPABLE_SLOT (1<<2)
22
20/* 23/*
21 * struct pxa_sdhci_platdata() - Platform device data for PXA SDHCI 24 * struct pxa_sdhci_platdata() - Platform device data for PXA SDHCI
22 * @max_speed: the maximum speed supported 25 * @max_speed: the maximum speed supported
diff --git a/arch/arm/plat-s3c24xx/Kconfig b/arch/arm/plat-s3c24xx/Kconfig
index 5a27b1b538f2..eb105e61c746 100644
--- a/arch/arm/plat-s3c24xx/Kconfig
+++ b/arch/arm/plat-s3c24xx/Kconfig
@@ -8,7 +8,7 @@ config PLAT_S3C24XX
8 default y 8 default y
9 select NO_IOPORT 9 select NO_IOPORT
10 select ARCH_REQUIRE_GPIOLIB 10 select ARCH_REQUIRE_GPIOLIB
11 select S3C_DEVICE_NAND 11 select S3C_DEV_NAND
12 select S3C_GPIO_CFG_S3C24XX 12 select S3C_GPIO_CFG_S3C24XX
13 help 13 help
14 Base platform code for any Samsung S3C24XX device 14 Base platform code for any Samsung S3C24XX device
diff --git a/arch/arm/plat-s3c24xx/cpu.c b/arch/arm/plat-s3c24xx/cpu.c
index 76d0858c3cbb..4a10c0f684b2 100644
--- a/arch/arm/plat-s3c24xx/cpu.c
+++ b/arch/arm/plat-s3c24xx/cpu.c
@@ -88,7 +88,7 @@ static struct cpu_table cpu_ids[] __initdata = {
88 { 88 {
89 .idcode = 0x32440000, 89 .idcode = 0x32440000,
90 .idmask = 0xffffffff, 90 .idmask = 0xffffffff,
91 .map_io = s3c244x_map_io, 91 .map_io = s3c2440_map_io,
92 .init_clocks = s3c244x_init_clocks, 92 .init_clocks = s3c244x_init_clocks,
93 .init_uarts = s3c244x_init_uarts, 93 .init_uarts = s3c244x_init_uarts,
94 .init = s3c2440_init, 94 .init = s3c2440_init,
@@ -97,7 +97,7 @@ static struct cpu_table cpu_ids[] __initdata = {
97 { 97 {
98 .idcode = 0x32440001, 98 .idcode = 0x32440001,
99 .idmask = 0xffffffff, 99 .idmask = 0xffffffff,
100 .map_io = s3c244x_map_io, 100 .map_io = s3c2440_map_io,
101 .init_clocks = s3c244x_init_clocks, 101 .init_clocks = s3c244x_init_clocks,
102 .init_uarts = s3c244x_init_uarts, 102 .init_uarts = s3c244x_init_uarts,
103 .init = s3c2440_init, 103 .init = s3c2440_init,
@@ -106,7 +106,7 @@ static struct cpu_table cpu_ids[] __initdata = {
106 { 106 {
107 .idcode = 0x32440aaa, 107 .idcode = 0x32440aaa,
108 .idmask = 0xffffffff, 108 .idmask = 0xffffffff,
109 .map_io = s3c244x_map_io, 109 .map_io = s3c2442_map_io,
110 .init_clocks = s3c244x_init_clocks, 110 .init_clocks = s3c244x_init_clocks,
111 .init_uarts = s3c244x_init_uarts, 111 .init_uarts = s3c244x_init_uarts,
112 .init = s3c2442_init, 112 .init = s3c2442_init,
@@ -115,7 +115,7 @@ static struct cpu_table cpu_ids[] __initdata = {
115 { 115 {
116 .idcode = 0x32440aab, 116 .idcode = 0x32440aab,
117 .idmask = 0xffffffff, 117 .idmask = 0xffffffff,
118 .map_io = s3c244x_map_io, 118 .map_io = s3c2442_map_io,
119 .init_clocks = s3c244x_init_clocks, 119 .init_clocks = s3c244x_init_clocks,
120 .init_uarts = s3c244x_init_uarts, 120 .init_uarts = s3c244x_init_uarts,
121 .init = s3c2442_init, 121 .init = s3c2442_init,
diff --git a/arch/arm/plat-s3c24xx/gpiolib.c b/arch/arm/plat-s3c24xx/gpiolib.c
index 24c6f5a30596..243b6411050d 100644
--- a/arch/arm/plat-s3c24xx/gpiolib.c
+++ b/arch/arm/plat-s3c24xx/gpiolib.c
@@ -82,8 +82,6 @@ static struct s3c_gpio_cfg s3c24xx_gpiocfg_banka = {
82struct s3c_gpio_cfg s3c24xx_gpiocfg_default = { 82struct s3c_gpio_cfg s3c24xx_gpiocfg_default = {
83 .set_config = s3c_gpio_setcfg_s3c24xx, 83 .set_config = s3c_gpio_setcfg_s3c24xx,
84 .get_config = s3c_gpio_getcfg_s3c24xx, 84 .get_config = s3c_gpio_getcfg_s3c24xx,
85 .set_pull = s3c_gpio_setpull_1up,
86 .get_pull = s3c_gpio_getpull_1up,
87}; 85};
88 86
89struct s3c_gpio_chip s3c24xx_gpios[] = { 87struct s3c_gpio_chip s3c24xx_gpios[] = {
diff --git a/arch/arm/plat-s3c24xx/include/plat/s3c244x.h b/arch/arm/plat-s3c24xx/include/plat/s3c244x.h
index 307248d1ccbb..89e8d0a25f87 100644
--- a/arch/arm/plat-s3c24xx/include/plat/s3c244x.h
+++ b/arch/arm/plat-s3c24xx/include/plat/s3c244x.h
@@ -21,17 +21,22 @@ extern void s3c244x_init_clocks(int xtal);
21#else 21#else
22#define s3c244x_init_clocks NULL 22#define s3c244x_init_clocks NULL
23#define s3c244x_init_uarts NULL 23#define s3c244x_init_uarts NULL
24#define s3c244x_map_io NULL
25#endif 24#endif
26 25
27#ifdef CONFIG_CPU_S3C2440 26#ifdef CONFIG_CPU_S3C2440
28extern int s3c2440_init(void); 27extern int s3c2440_init(void);
28
29extern void s3c2440_map_io(void);
29#else 30#else
30#define s3c2440_init NULL 31#define s3c2440_init NULL
32#define s3c2440_map_io NULL
31#endif 33#endif
32 34
33#ifdef CONFIG_CPU_S3C2442 35#ifdef CONFIG_CPU_S3C2442
34extern int s3c2442_init(void); 36extern int s3c2442_init(void);
37
38extern void s3c2442_map_io(void);
35#else 39#else
36#define s3c2442_init NULL 40#define s3c2442_init NULL
41#define s3c2442_map_io NULL
37#endif 42#endif
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 9793544a6ace..704175b0573f 100644
--- a/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c
+++ b/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c
@@ -29,8 +29,8 @@ void s3c24xx_spi_gpiocfg_bus0_gpe11_12_13(struct s3c2410_spi_info *spi,
29 } else { 29 } else {
30 s3c_gpio_cfgpin(S3C2410_GPE(13), S3C2410_GPIO_INPUT); 30 s3c_gpio_cfgpin(S3C2410_GPE(13), S3C2410_GPIO_INPUT);
31 s3c_gpio_cfgpin(S3C2410_GPE(11), S3C2410_GPIO_INPUT); 31 s3c_gpio_cfgpin(S3C2410_GPE(11), S3C2410_GPIO_INPUT);
32 s3c_gpio_cfgpull(S3C2410_GPE(11), S3C_GPIO_PULL_NONE); 32 s3c_gpio_setpull(S3C2410_GPE(11), S3C_GPIO_PULL_NONE);
33 s3c_gpio_cfgpull(S3C2410_GPE(12), S3C_GPIO_PULL_NONE); 33 s3c_gpio_setpull(S3C2410_GPE(12), S3C_GPIO_PULL_NONE);
34 s3c_gpio_cfgpull(S3C2410_GPE(13), S3C_GPIO_PULL_NONE); 34 s3c_gpio_setpull(S3C2410_GPE(13), S3C_GPIO_PULL_NONE);
35 } 35 }
36} 36}
diff --git a/arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c b/arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c
index db9e9e477ec1..72457afd6255 100644
--- a/arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c
+++ b/arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c
@@ -31,8 +31,8 @@ void s3c24xx_spi_gpiocfg_bus1_gpd8_9_10(struct s3c2410_spi_info *spi,
31 } else { 31 } else {
32 s3c_gpio_cfgpin(S3C2410_GPD(8), S3C2410_GPIO_INPUT); 32 s3c_gpio_cfgpin(S3C2410_GPD(8), S3C2410_GPIO_INPUT);
33 s3c_gpio_cfgpin(S3C2410_GPD(9), S3C2410_GPIO_INPUT); 33 s3c_gpio_cfgpin(S3C2410_GPD(9), S3C2410_GPIO_INPUT);
34 s3c_gpio_cfgpull(S3C2410_GPD(10), S3C_GPIO_PULL_NONE); 34 s3c_gpio_setpull(S3C2410_GPD(10), S3C_GPIO_PULL_NONE);
35 s3c_gpio_cfgpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE); 35 s3c_gpio_setpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE);
36 s3c_gpio_cfgpull(S3C2410_GPD(8), S3C_GPIO_PULL_NONE); 36 s3c_gpio_setpull(S3C2410_GPD(8), S3C_GPIO_PULL_NONE);
37 } 37 }
38} 38}
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 8ea663a438bb..c3972b645d13 100644
--- a/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c
+++ b/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c
@@ -29,8 +29,8 @@ void s3c24xx_spi_gpiocfg_bus1_gpg5_6_7(struct s3c2410_spi_info *spi,
29 } else { 29 } else {
30 s3c_gpio_cfgpin(S3C2410_GPG(7), S3C2410_GPIO_INPUT); 30 s3c_gpio_cfgpin(S3C2410_GPG(7), S3C2410_GPIO_INPUT);
31 s3c_gpio_cfgpin(S3C2410_GPG(5), S3C2410_GPIO_INPUT); 31 s3c_gpio_cfgpin(S3C2410_GPG(5), S3C2410_GPIO_INPUT);
32 s3c_gpio_cfgpull(S3C2410_GPG(5), S3C_GPIO_PULL_NONE); 32 s3c_gpio_setpull(S3C2410_GPG(5), S3C_GPIO_PULL_NONE);
33 s3c_gpio_cfgpull(S3C2410_GPG(6), S3C_GPIO_PULL_NONE); 33 s3c_gpio_setpull(S3C2410_GPG(6), S3C_GPIO_PULL_NONE);
34 s3c_gpio_cfgpull(S3C2410_GPG(7), S3C_GPIO_PULL_NONE); 34 s3c_gpio_setpull(S3C2410_GPG(7), S3C_GPIO_PULL_NONE);
35 } 35 }
36} 36}
diff --git a/arch/arm/plat-samsung/gpio-config.c b/arch/arm/plat-samsung/gpio-config.c
index b732b773b9af..0aa32f242ee4 100644
--- a/arch/arm/plat-samsung/gpio-config.c
+++ b/arch/arm/plat-samsung/gpio-config.c
@@ -280,18 +280,17 @@ s3c_gpio_pull_t s3c_gpio_getpull_updown(struct s3c_gpio_chip *chip,
280} 280}
281#endif 281#endif
282 282
283#ifdef CONFIG_S3C_GPIO_PULL_UP 283#if defined(CONFIG_S3C_GPIO_PULL_UP) || defined(CONFIG_S3C_GPIO_PULL_DOWN)
284int s3c_gpio_setpull_1up(struct s3c_gpio_chip *chip, 284static int s3c_gpio_setpull_1(struct s3c_gpio_chip *chip,
285 unsigned int off, s3c_gpio_pull_t pull) 285 unsigned int off, s3c_gpio_pull_t pull,
286 s3c_gpio_pull_t updown)
286{ 287{
287 void __iomem *reg = chip->base + 0x08; 288 void __iomem *reg = chip->base + 0x08;
288 u32 pup = __raw_readl(reg); 289 u32 pup = __raw_readl(reg);
289 290
290 pup = __raw_readl(reg); 291 if (pull == updown)
291
292 if (pup == S3C_GPIO_PULL_UP)
293 pup &= ~(1 << off); 292 pup &= ~(1 << off);
294 else if (pup == S3C_GPIO_PULL_NONE) 293 else if (pull == S3C_GPIO_PULL_NONE)
295 pup |= (1 << off); 294 pup |= (1 << off);
296 else 295 else
297 return -EINVAL; 296 return -EINVAL;
@@ -300,17 +299,45 @@ int s3c_gpio_setpull_1up(struct s3c_gpio_chip *chip,
300 return 0; 299 return 0;
301} 300}
302 301
303s3c_gpio_pull_t s3c_gpio_getpull_1up(struct s3c_gpio_chip *chip, 302static s3c_gpio_pull_t s3c_gpio_getpull_1(struct s3c_gpio_chip *chip,
304 unsigned int off) 303 unsigned int off, s3c_gpio_pull_t updown)
305{ 304{
306 void __iomem *reg = chip->base + 0x08; 305 void __iomem *reg = chip->base + 0x08;
307 u32 pup = __raw_readl(reg); 306 u32 pup = __raw_readl(reg);
308 307
309 pup &= (1 << off); 308 pup &= (1 << off);
310 return pup ? S3C_GPIO_PULL_NONE : S3C_GPIO_PULL_UP; 309 return pup ? S3C_GPIO_PULL_NONE : updown;
310}
311#endif /* CONFIG_S3C_GPIO_PULL_UP || CONFIG_S3C_GPIO_PULL_DOWN */
312
313#ifdef CONFIG_S3C_GPIO_PULL_UP
314s3c_gpio_pull_t s3c_gpio_getpull_1up(struct s3c_gpio_chip *chip,
315 unsigned int off)
316{
317 return s3c_gpio_getpull_1(chip, off, S3C_GPIO_PULL_UP);
318}
319
320int s3c_gpio_setpull_1up(struct s3c_gpio_chip *chip,
321 unsigned int off, s3c_gpio_pull_t pull)
322{
323 return s3c_gpio_setpull_1(chip, off, pull, S3C_GPIO_PULL_UP);
311} 324}
312#endif /* CONFIG_S3C_GPIO_PULL_UP */ 325#endif /* CONFIG_S3C_GPIO_PULL_UP */
313 326
327#ifdef CONFIG_S3C_GPIO_PULL_DOWN
328s3c_gpio_pull_t s3c_gpio_getpull_1down(struct s3c_gpio_chip *chip,
329 unsigned int off)
330{
331 return s3c_gpio_getpull_1(chip, off, S3C_GPIO_PULL_DOWN);
332}
333
334int s3c_gpio_setpull_1down(struct s3c_gpio_chip *chip,
335 unsigned int off, s3c_gpio_pull_t pull)
336{
337 return s3c_gpio_setpull_1(chip, off, pull, S3C_GPIO_PULL_DOWN);
338}
339#endif /* CONFIG_S3C_GPIO_PULL_DOWN */
340
314#ifdef CONFIG_S5P_GPIO_DRVSTR 341#ifdef CONFIG_S5P_GPIO_DRVSTR
315s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin) 342s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin)
316{ 343{
diff --git a/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h b/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h
index 8fd65d8b5863..0d2c5703f1ee 100644
--- a/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h
+++ b/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h
@@ -210,6 +210,17 @@ extern s3c_gpio_pull_t s3c_gpio_getpull_1up(struct s3c_gpio_chip *chip,
210 unsigned int off); 210 unsigned int off);
211 211
212/** 212/**
213 * s3c_gpio_getpull_1down() - Get configuration for choice of down or none
214 * @chip: The gpio chip that the GPIO pin belongs to
215 * @off: The offset to the pin to get the configuration of.
216 *
217 * This helper function reads the state of the pull-down resistor for the
218 * given GPIO in the same case as s3c_gpio_setpull_1down.
219*/
220extern s3c_gpio_pull_t s3c_gpio_getpull_1down(struct s3c_gpio_chip *chip,
221 unsigned int off);
222
223/**
213 * s3c_gpio_setpull_s3c2443() - Pull configuration for s3c2443. 224 * s3c_gpio_setpull_s3c2443() - Pull configuration for s3c2443.
214 * @chip: The gpio chip that is being configured. 225 * @chip: The gpio chip that is being configured.
215 * @off: The offset for the GPIO being configured. 226 * @off: The offset for the GPIO being configured.
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index 55590a4d87c9..2fea897ebeb1 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -12,7 +12,7 @@
12# 12#
13# http://www.arm.linux.org.uk/developer/machines/?action=new 13# http://www.arm.linux.org.uk/developer/machines/?action=new
14# 14#
15# Last update: Thu Sep 9 22:43:01 2010 15# Last update: Sun Dec 12 23:24:27 2010
16# 16#
17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number 17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number
18# 18#
@@ -2321,7 +2321,7 @@ mx31txtr MACH_MX31TXTR MX31TXTR 2332
2321u380 MACH_U380 U380 2333 2321u380 MACH_U380 U380 2333
2322oamp3_hualu MACH_HUALU_BOARD HUALU_BOARD 2334 2322oamp3_hualu MACH_HUALU_BOARD HUALU_BOARD 2334
2323npcmx50 MACH_NPCMX50 NPCMX50 2335 2323npcmx50 MACH_NPCMX50 NPCMX50 2335
2324mx51_lange51 MACH_MX51_LANGE51 MX51_LANGE51 2336 2324mx51_efikamx MACH_MX51_EFIKAMX MX51_EFIKAMX 2336
2325mx51_lange52 MACH_MX51_LANGE52 MX51_LANGE52 2337 2325mx51_lange52 MACH_MX51_LANGE52 MX51_LANGE52 2337
2326riom MACH_RIOM RIOM 2338 2326riom MACH_RIOM RIOM 2338
2327comcas MACH_COMCAS COMCAS 2339 2327comcas MACH_COMCAS COMCAS 2339
@@ -2355,7 +2355,7 @@ at91sam9263cs MACH_AT91SAM9263CS AT91SAM9263CS 2366
2355csb732 MACH_CSB732 CSB732 2367 2355csb732 MACH_CSB732 CSB732 2367
2356u8500 MACH_U8500 U8500 2368 2356u8500 MACH_U8500 U8500 2368
2357huqiu MACH_HUQIU HUQIU 2369 2357huqiu MACH_HUQIU HUQIU 2369
2358mx51_kunlun MACH_MX51_KUNLUN MX51_KUNLUN 2370 2358mx51_efikasb MACH_MX51_EFIKASB MX51_EFIKASB 2370
2359pmt1g MACH_PMT1G PMT1G 2371 2359pmt1g MACH_PMT1G PMT1G 2371
2360htcelf MACH_HTCELF HTCELF 2372 2360htcelf MACH_HTCELF HTCELF 2372
2361armadillo420 MACH_ARMADILLO420 ARMADILLO420 2373 2361armadillo420 MACH_ARMADILLO420 ARMADILLO420 2373
@@ -2971,7 +2971,7 @@ premierwave_en MACH_PREMIERWAVE_EN PREMIERWAVE_EN 2985
2971wasabi MACH_WASABI WASABI 2986 2971wasabi MACH_WASABI WASABI 2986
2972vivow MACH_VIVOW VIVOW 2987 2972vivow MACH_VIVOW VIVOW 2987
2973mx50_rdp MACH_MX50_RDP MX50_RDP 2988 2973mx50_rdp MACH_MX50_RDP MX50_RDP 2988
2974universal MACH_UNIVERSAL UNIVERSAL 2989 2974universal_c210 MACH_UNIVERSAL_C210 UNIVERSAL_C210 2989
2975real6410 MACH_REAL6410 REAL6410 2990 2975real6410 MACH_REAL6410 REAL6410 2990
2976spx_sakura MACH_SPX_SAKURA SPX_SAKURA 2991 2976spx_sakura MACH_SPX_SAKURA SPX_SAKURA 2991
2977ij3k_2440 MACH_IJ3K_2440 IJ3K_2440 2992 2977ij3k_2440 MACH_IJ3K_2440 IJ3K_2440 2992
@@ -3044,3 +3044,178 @@ harvest_desoto MACH_HARVEST_DESOTO HARVEST_DESOTO 3059
3044msm8x60_qrdc MACH_MSM8X60_QRDC MSM8X60_QRDC 3060 3044msm8x60_qrdc MACH_MSM8X60_QRDC MSM8X60_QRDC 3060
3045spear900 MACH_SPEAR900 SPEAR900 3061 3045spear900 MACH_SPEAR900 SPEAR900 3061
3046pcontrol_g20 MACH_PCONTROL_G20 PCONTROL_G20 3062 3046pcontrol_g20 MACH_PCONTROL_G20 PCONTROL_G20 3062
3047rdstor MACH_RDSTOR RDSTOR 3063
3048usdloader MACH_USDLOADER USDLOADER 3064
3049tsoploader MACH_TSOPLOADER TSOPLOADER 3065
3050kronos MACH_KRONOS KRONOS 3066
3051ffcore MACH_FFCORE FFCORE 3067
3052mone MACH_MONE MONE 3068
3053unit2s MACH_UNIT2S UNIT2S 3069
3054acer_a5 MACH_ACER_A5 ACER_A5 3070
3055etherpro_isp MACH_ETHERPRO_ISP ETHERPRO_ISP 3071
3056stretchs7000 MACH_STRETCHS7000 STRETCHS7000 3072
3057p87_smartsim MACH_P87_SMARTSIM P87_SMARTSIM 3073
3058tulip MACH_TULIP TULIP 3074
3059sunflower MACH_SUNFLOWER SUNFLOWER 3075
3060rib MACH_RIB RIB 3076
3061clod MACH_CLOD CLOD 3077
3062rump MACH_RUMP RUMP 3078
3063tenderloin MACH_TENDERLOIN TENDERLOIN 3079
3064shortloin MACH_SHORTLOIN SHORTLOIN 3080
3065crespo MACH_CRESPO CRESPO 3081
3066antares MACH_ANTARES ANTARES 3082
3067wb40n MACH_WB40N WB40N 3083
3068herring MACH_HERRING HERRING 3084
3069naxy400 MACH_NAXY400 NAXY400 3085
3070naxy1200 MACH_NAXY1200 NAXY1200 3086
3071vpr200 MACH_VPR200 VPR200 3087
3072bug20 MACH_BUG20 BUG20 3088
3073goflexnet MACH_GOFLEXNET GOFLEXNET 3089
3074torbreck MACH_TORBRECK TORBRECK 3090
3075saarb_mg1 MACH_SAARB_MG1 SAARB_MG1 3091
3076callisto MACH_CALLISTO CALLISTO 3092
3077multhsu MACH_MULTHSU MULTHSU 3093
3078saluda MACH_SALUDA SALUDA 3094
3079pemp_omap3_apollo MACH_PEMP_OMAP3_APOLLO PEMP_OMAP3_APOLLO 3095
3080vc0718 MACH_VC0718 VC0718 3096
3081mvblx MACH_MVBLX MVBLX 3097
3082inhand_apeiron MACH_INHAND_APEIRON INHAND_APEIRON 3098
3083inhand_fury MACH_INHAND_FURY INHAND_FURY 3099
3084inhand_siren MACH_INHAND_SIREN INHAND_SIREN 3100
3085hdnvp MACH_HDNVP HDNVP 3101
3086softwinner MACH_SOFTWINNER SOFTWINNER 3102
3087prima2_evb MACH_PRIMA2_EVB PRIMA2_EVB 3103
3088nas6210 MACH_NAS6210 NAS6210 3104
3089unisdev MACH_UNISDEV UNISDEV 3105
3090sbca11 MACH_SBCA11 SBCA11 3106
3091saga MACH_SAGA SAGA 3107
3092ns_k330 MACH_NS_K330 NS_K330 3108
3093tanna MACH_TANNA TANNA 3109
3094imate8502 MACH_IMATE8502 IMATE8502 3110
3095aspen MACH_ASPEN ASPEN 3111
3096daintree_cwac MACH_DAINTREE_CWAC DAINTREE_CWAC 3112
3097zmx25 MACH_ZMX25 ZMX25 3113
3098maple1 MACH_MAPLE1 MAPLE1 3114
3099qsd8x72_surf MACH_QSD8X72_SURF QSD8X72_SURF 3115
3100qsd8x72_ffa MACH_QSD8X72_FFA QSD8X72_FFA 3116
3101abilene MACH_ABILENE ABILENE 3117
3102eigen_ttr MACH_EIGEN_TTR EIGEN_TTR 3118
3103iomega_ix2_200 MACH_IOMEGA_IX2_200 IOMEGA_IX2_200 3119
3104coretec_vcx7400 MACH_CORETEC_VCX7400 CORETEC_VCX7400 3120
3105santiago MACH_SANTIAGO SANTIAGO 3121
3106mx257sol MACH_MX257SOL MX257SOL 3122
3107strasbourg MACH_STRASBOURG STRASBOURG 3123
3108msm8x60_fluid MACH_MSM8X60_FLUID MSM8X60_FLUID 3124
3109smartqv5 MACH_SMARTQV5 SMARTQV5 3125
3110smartqv3 MACH_SMARTQV3 SMARTQV3 3126
3111smartqv7 MACH_SMARTQV7 SMARTQV7 3127
3112paz00 MACH_PAZ00 PAZ00 3128
3113acmenetusfoxg20 MACH_ACMENETUSFOXG20 ACMENETUSFOXG20 3129
3114htcwillow MACH_HTCWILLOW HTCWILLOW 3130
3115fwbd_0404 MACH_FWBD_0404 FWBD_0404 3131
3116hdgu MACH_HDGU HDGU 3132
3117pyramid MACH_PYRAMID PYRAMID 3133
3118epiphan MACH_EPIPHAN EPIPHAN 3134
3119omap_bender MACH_OMAP_BENDER OMAP_BENDER 3135
3120gurnard MACH_GURNARD GURNARD 3136
3121gtl_it5100 MACH_GTL_IT5100 GTL_IT5100 3137
3122bcm2708 MACH_BCM2708 BCM2708 3138
3123mx51_ggc MACH_MX51_GGC MX51_GGC 3139
3124sharespace MACH_SHARESPACE SHARESPACE 3140
3125haba_knx_explorer MACH_HABA_KNX_EXPLORER HABA_KNX_EXPLORER 3141
3126simtec_kirkmod MACH_SIMTEC_KIRKMOD SIMTEC_KIRKMOD 3142
3127crux MACH_CRUX CRUX 3143
3128mx51_bravo MACH_MX51_BRAVO MX51_BRAVO 3144
3129charon MACH_CHARON CHARON 3145
3130picocom3 MACH_PICOCOM3 PICOCOM3 3146
3131picocom4 MACH_PICOCOM4 PICOCOM4 3147
3132serrano MACH_SERRANO SERRANO 3148
3133doubleshot MACH_DOUBLESHOT DOUBLESHOT 3149
3134evsy MACH_EVSY EVSY 3150
3135huashan MACH_HUASHAN HUASHAN 3151
3136lausanne MACH_LAUSANNE LAUSANNE 3152
3137emerald MACH_EMERALD EMERALD 3153
3138tqma35 MACH_TQMA35 TQMA35 3154
3139marvel MACH_MARVEL MARVEL 3155
3140manuae MACH_MANUAE MANUAE 3156
3141chacha MACH_CHACHA CHACHA 3157
3142lemon MACH_LEMON LEMON 3158
3143csc MACH_CSC CSC 3159
3144gira_knxip_router MACH_GIRA_KNXIP_ROUTER GIRA_KNXIP_ROUTER 3160
3145t20 MACH_T20 T20 3161
3146hdmini MACH_HDMINI HDMINI 3162
3147sciphone_g2 MACH_SCIPHONE_G2 SCIPHONE_G2 3163
3148express MACH_EXPRESS EXPRESS 3164
3149express_kt MACH_EXPRESS_KT EXPRESS_KT 3165
3150maximasp MACH_MAXIMASP MAXIMASP 3166
3151nitrogen_imx51 MACH_NITROGEN_IMX51 NITROGEN_IMX51 3167
3152nitrogen_imx53 MACH_NITROGEN_IMX53 NITROGEN_IMX53 3168
3153sunfire MACH_SUNFIRE SUNFIRE 3169
3154arowana MACH_AROWANA AROWANA 3170
3155tegra_daytona MACH_TEGRA_DAYTONA TEGRA_DAYTONA 3171
3156tegra_swordfish MACH_TEGRA_SWORDFISH TEGRA_SWORDFISH 3172
3157edison MACH_EDISON EDISON 3173
3158svp8500v1 MACH_SVP8500V1 SVP8500V1 3174
3159svp8500v2 MACH_SVP8500V2 SVP8500V2 3175
3160svp5500 MACH_SVP5500 SVP5500 3176
3161b5500 MACH_B5500 B5500 3177
3162s5500 MACH_S5500 S5500 3178
3163icon MACH_ICON ICON 3179
3164elephant MACH_ELEPHANT ELEPHANT 3180
3165msm8x60_fusion MACH_MSM8X60_FUSION MSM8X60_FUSION 3181
3166shooter MACH_SHOOTER SHOOTER 3182
3167spade_lte MACH_SPADE_LTE SPADE_LTE 3183
3168philhwani MACH_PHILHWANI PHILHWANI 3184
3169gsncomm MACH_GSNCOMM GSNCOMM 3185
3170strasbourg_a2 MACH_STRASBOURG_A2 STRASBOURG_A2 3186
3171mmm MACH_MMM MMM 3187
3172davinci_dm365_bv MACH_DAVINCI_DM365_BV DAVINCI_DM365_BV 3188
3173ag5evm MACH_AG5EVM AG5EVM 3189
3174sc575plc MACH_SC575PLC SC575PLC 3190
3175sc575hmi MACH_SC575IPC SC575IPC 3191
3176omap3_tdm3730 MACH_OMAP3_TDM3730 OMAP3_TDM3730 3192
3177g7 MACH_G7 G7 3193
3178top9000_eval MACH_TOP9000_EVAL TOP9000_EVAL 3194
3179top9000_su MACH_TOP9000_SU TOP9000_SU 3195
3180utm300 MACH_UTM300 UTM300 3196
3181tsunagi MACH_TSUNAGI TSUNAGI 3197
3182ts75xx MACH_TS75XX TS75XX 3198
3183msm8x60_fusn_ffa MACH_MSM8X60_FUSN_FFA MSM8X60_FUSN_FFA 3199
3184ts47xx MACH_TS47XX TS47XX 3200
3185da850_k5 MACH_DA850_K5 DA850_K5 3201
3186ax502 MACH_AX502 AX502 3202
3187igep0032 MACH_IGEP0032 IGEP0032 3203
3188antero MACH_ANTERO ANTERO 3204
3189synergy MACH_SYNERGY SYNERGY 3205
3190ics_if_voip MACH_ICS_IF_VOIP ICS_IF_VOIP 3206
3191wlf_cragg_6410 MACH_WLF_CRAGG_6410 WLF_CRAGG_6410 3207
3192punica MACH_PUNICA PUNICA 3208
3193sbc_nt250 MACH_SBC_NT250 SBC_NT250 3209
3194mx27_wmultra MACH_MX27_WMULTRA MX27_WMULTRA 3210
3195mackerel MACH_MACKEREL MACKEREL 3211
3196fa9x27 MACH_FA9X27 FA9X27 3213
3197ns2816tb MACH_NS2816TB NS2816TB 3214
3198ns2816_ntpad MACH_NS2816_NTPAD NS2816_NTPAD 3215
3199ns2816_ntnb MACH_NS2816_NTNB NS2816_NTNB 3216
3200kaen MACH_KAEN KAEN 3217
3201nv1000 MACH_NV1000 NV1000 3218
3202nuc950ts MACH_NUC950TS NUC950TS 3219
3203nokia_rm680 MACH_NOKIA_RM680 NOKIA_RM680 3220
3204ast2200 MACH_AST2200 AST2200 3221
3205lead MACH_LEAD LEAD 3222
3206unino1 MACH_UNINO1 UNINO1 3223
3207greeco MACH_GREECO GREECO 3224
3208verdi MACH_VERDI VERDI 3225
3209dm6446_adbox MACH_DM6446_ADBOX DM6446_ADBOX 3226
3210quad_salsa MACH_QUAD_SALSA QUAD_SALSA 3227
3211abb_gma_1_1 MACH_ABB_GMA_1_1 ABB_GMA_1_1 3228
3212svcid MACH_SVCID SVCID 3229
3213msm8960_sim MACH_MSM8960_SIM MSM8960_SIM 3230
3214msm8960_rumi3 MACH_MSM8960_RUMI3 MSM8960_RUMI3 3231
3215icon_g MACH_ICON_G ICON_G 3232
3216mb3 MACH_MB3 MB3 3233
3217gsia18s MACH_GSIA18S GSIA18S 3234
3218pivicc MACH_PIVICC PIVICC 3235
3219pcm048 MACH_PCM048 PCM048 3236
3220dds MACH_DDS DDS 3237
3221chalten_xa1 MACH_CHALTEN_XA1 CHALTEN_XA1 3238
diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
index d66cead97d28..9897dcfc16d6 100644
--- a/arch/arm/vfp/vfphw.S
+++ b/arch/arm/vfp/vfphw.S
@@ -206,6 +206,7 @@ ENTRY(vfp_save_state)
206 mov pc, lr 206 mov pc, lr
207ENDPROC(vfp_save_state) 207ENDPROC(vfp_save_state)
208 208
209 .align
209last_VFP_context_address: 210last_VFP_context_address:
210 .word last_VFP_context 211 .word last_VFP_context
211 212
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index cd0c090ebc54..b407bc8ad918 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/smp_lock.h>
11#include <linux/unistd.h> 10#include <linux/unistd.h>
12#include <linux/user.h> 11#include <linux/user.h>
13#include <linux/uaccess.h> 12#include <linux/uaccess.h>
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
index 2b63b0191f52..efad12071c2e 100644
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -16,7 +16,6 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/smp_lock.h>
20#include <linux/stddef.h> 19#include <linux/stddef.h>
21#include <linux/unistd.h> 20#include <linux/unistd.h>
22#include <linux/ptrace.h> 21#include <linux/ptrace.h>
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
index 97478138e361..933bd388efb2 100644
--- a/arch/h8300/kernel/process.c
+++ b/arch/h8300/kernel/process.c
@@ -28,7 +28,6 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/smp.h> 30#include <linux/smp.h>
31#include <linux/smp_lock.h>
32#include <linux/stddef.h> 31#include <linux/stddef.h>
33#include <linux/unistd.h> 32#include <linux/unistd.h>
34#include <linux/ptrace.h> 33#include <linux/ptrace.h>
diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c
index 3a078ad3aa44..331de723c676 100644
--- a/arch/ia64/hp/sim/simscsi.c
+++ b/arch/ia64/hp/sim/simscsi.c
@@ -202,7 +202,7 @@ simscsi_readwrite10 (struct scsi_cmnd *sc, int mode)
202} 202}
203 203
204static int 204static int
205simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) 205simscsi_queuecommand_lck (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
206{ 206{
207 unsigned int target_id = sc->device->id; 207 unsigned int target_id = sc->device->id;
208 char fname[MAX_ROOT_LEN+16]; 208 char fname[MAX_ROOT_LEN+16];
@@ -326,6 +326,8 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
326 return 0; 326 return 0;
327} 327}
328 328
329static DEF_SCSI_QCMD(simscsi_queuecommand)
330
329static int 331static int
330simscsi_host_reset (struct scsi_cmnd *sc) 332simscsi_host_reset (struct scsi_cmnd *sc)
331{ 333{
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index 18732ab23292..c2a1fc23dd75 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -18,7 +18,6 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/smp.h> 20#include <linux/smp.h>
21#include <linux/smp_lock.h>
22#include <linux/stddef.h> 21#include <linux/stddef.h>
23#include <linux/unistd.h> 22#include <linux/unistd.h>
24#include <linux/ptrace.h> 23#include <linux/ptrace.h>
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c
index 6d3390590e5b..e2a63af5d517 100644
--- a/arch/m68knommu/kernel/process.c
+++ b/arch/m68knommu/kernel/process.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/smp.h> 21#include <linux/smp.h>
22#include <linux/smp_lock.h>
23#include <linux/stddef.h> 22#include <linux/stddef.h>
24#include <linux/unistd.h> 23#include <linux/unistd.h>
25#include <linux/ptrace.h> 24#include <linux/ptrace.h>
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 67a2fa2caa49..0a9b5b8b2a19 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -19,6 +19,8 @@ config MIPS
19 select GENERIC_ATOMIC64 if !64BIT 19 select GENERIC_ATOMIC64 if !64BIT
20 select HAVE_DMA_ATTRS 20 select HAVE_DMA_ATTRS
21 select HAVE_DMA_API_DEBUG 21 select HAVE_DMA_API_DEBUG
22 select HAVE_GENERIC_HARDIRQS
23 select GENERIC_IRQ_PROBE
22 24
23menu "Machine selection" 25menu "Machine selection"
24 26
@@ -1664,6 +1666,28 @@ config PAGE_SIZE_64KB
1664 1666
1665endchoice 1667endchoice
1666 1668
1669config FORCE_MAX_ZONEORDER
1670 int "Maximum zone order"
1671 range 13 64 if SYS_SUPPORTS_HUGETLBFS && PAGE_SIZE_32KB
1672 default "13" if SYS_SUPPORTS_HUGETLBFS && PAGE_SIZE_32KB
1673 range 12 64 if SYS_SUPPORTS_HUGETLBFS && PAGE_SIZE_16KB
1674 default "12" if SYS_SUPPORTS_HUGETLBFS && PAGE_SIZE_16KB
1675 range 11 64
1676 default "11"
1677 help
1678 The kernel memory allocator divides physically contiguous memory
1679 blocks into "zones", where each zone is a power of two number of
1680 pages. This option selects the largest power of two that the kernel
1681 keeps in the memory allocator. If you need to allocate very large
1682 blocks of physically contiguous memory, then you may need to
1683 increase this value.
1684
1685 This config option is actually maximum order plus one. For example,
1686 a value of 11 means that the largest free memory block is 2^10 pages.
1687
1688 The page size is not necessarily 4KB. Keep this in mind
1689 when choosing a value for this option.
1690
1667config BOARD_SCACHE 1691config BOARD_SCACHE
1668 bool 1692 bool
1669 1693
@@ -1922,20 +1946,6 @@ config CPU_R4400_WORKAROUNDS
1922 bool 1946 bool
1923 1947
1924# 1948#
1925# Use the generic interrupt handling code in kernel/irq/:
1926#
1927config GENERIC_HARDIRQS
1928 bool
1929 default y
1930
1931config GENERIC_IRQ_PROBE
1932 bool
1933 default y
1934
1935config IRQ_PER_CPU
1936 bool
1937
1938#
1939# - Highmem only makes sense for the 32-bit kernel. 1949# - Highmem only makes sense for the 32-bit kernel.
1940# - The current highmem code will only work properly on physically indexed 1950# - The current highmem code will only work properly on physically indexed
1941# caches such as R3000, SB1, R7000 or those that look like they're virtually 1951# caches such as R3000, SB1, R7000 or those that look like they're virtually
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index 3691630931d6..9e7814db3d03 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -27,6 +27,7 @@
27static void alchemy_8250_pm(struct uart_port *port, unsigned int state, 27static void alchemy_8250_pm(struct uart_port *port, unsigned int state,
28 unsigned int old_state) 28 unsigned int old_state)
29{ 29{
30#ifdef CONFIG_SERIAL_8250
30 switch (state) { 31 switch (state) {
31 case 0: 32 case 0:
32 if ((__raw_readl(port->membase + UART_MOD_CNTRL) & 3) != 3) { 33 if ((__raw_readl(port->membase + UART_MOD_CNTRL) & 3) != 3) {
@@ -49,6 +50,7 @@ static void alchemy_8250_pm(struct uart_port *port, unsigned int state,
49 serial8250_do_pm(port, state, old_state); 50 serial8250_do_pm(port, state, old_state);
50 break; 51 break;
51 } 52 }
53#endif
52} 54}
53 55
54#define PORT(_base, _irq) \ 56#define PORT(_base, _irq) \
diff --git a/arch/mips/alchemy/devboards/prom.c b/arch/mips/alchemy/devboards/prom.c
index b30df5c97ad3..baeb21385058 100644
--- a/arch/mips/alchemy/devboards/prom.c
+++ b/arch/mips/alchemy/devboards/prom.c
@@ -54,10 +54,9 @@ void __init prom_init(void)
54 54
55 prom_init_cmdline(); 55 prom_init_cmdline();
56 memsize_str = prom_getenv("memsize"); 56 memsize_str = prom_getenv("memsize");
57 if (!memsize_str) 57 if (!memsize_str || strict_strtoul(memsize_str, 0, &memsize))
58 memsize = ALCHEMY_BOARD_DEFAULT_MEMSIZE; 58 memsize = ALCHEMY_BOARD_DEFAULT_MEMSIZE;
59 else 59
60 strict_strtoul(memsize_str, 0, &memsize);
61 add_memory_region(0, memsize, BOOT_MEM_RAM); 60 add_memory_region(0, memsize, BOOT_MEM_RAM);
62} 61}
63 62
diff --git a/arch/mips/ar7/clock.c b/arch/mips/ar7/clock.c
index fc0e7154e8d6..2ca4ada1c291 100644
--- a/arch/mips/ar7/clock.c
+++ b/arch/mips/ar7/clock.c
@@ -239,12 +239,12 @@ static void tnetd7300_set_clock(u32 shift, struct tnetd7300_clock *clock,
239 calculate(base_clock, frequency, &prediv, &postdiv, &mul); 239 calculate(base_clock, frequency, &prediv, &postdiv, &mul);
240 240
241 writel(((prediv - 1) << PREDIV_SHIFT) | (postdiv - 1), &clock->ctrl); 241 writel(((prediv - 1) << PREDIV_SHIFT) | (postdiv - 1), &clock->ctrl);
242 msleep(1); 242 mdelay(1);
243 writel(4, &clock->pll); 243 writel(4, &clock->pll);
244 while (readl(&clock->pll) & PLL_STATUS) 244 while (readl(&clock->pll) & PLL_STATUS)
245 ; 245 ;
246 writel(((mul - 1) << MUL_SHIFT) | (0xff << 3) | 0x0e, &clock->pll); 246 writel(((mul - 1) << MUL_SHIFT) | (0xff << 3) | 0x0e, &clock->pll);
247 msleep(75); 247 mdelay(75);
248} 248}
249 249
250static void __init tnetd7300_init_clocks(void) 250static void __init tnetd7300_init_clocks(void)
@@ -456,7 +456,7 @@ void clk_put(struct clk *clk)
456} 456}
457EXPORT_SYMBOL(clk_put); 457EXPORT_SYMBOL(clk_put);
458 458
459int __init ar7_init_clocks(void) 459void __init ar7_init_clocks(void)
460{ 460{
461 switch (ar7_chip_id()) { 461 switch (ar7_chip_id()) {
462 case AR7_CHIP_7100: 462 case AR7_CHIP_7100:
@@ -472,7 +472,4 @@ int __init ar7_init_clocks(void)
472 } 472 }
473 /* adjust vbus clock rate */ 473 /* adjust vbus clock rate */
474 vbus_clk.rate = bus_clk.rate / 2; 474 vbus_clk.rate = bus_clk.rate / 2;
475
476 return 0;
477} 475}
478arch_initcall(ar7_init_clocks);
diff --git a/arch/mips/ar7/time.c b/arch/mips/ar7/time.c
index 5fb8a0134085..22c93213b233 100644
--- a/arch/mips/ar7/time.c
+++ b/arch/mips/ar7/time.c
@@ -30,6 +30,9 @@ void __init plat_time_init(void)
30{ 30{
31 struct clk *cpu_clk; 31 struct clk *cpu_clk;
32 32
33 /* Initialize ar7 clocks so the CPU clock frequency is correct */
34 ar7_init_clocks();
35
33 cpu_clk = clk_get(NULL, "cpu"); 36 cpu_clk = clk_get(NULL, "cpu");
34 if (IS_ERR(cpu_clk)) { 37 if (IS_ERR(cpu_clk)) {
35 printk(KERN_ERR "unable to get cpu clock\n"); 38 printk(KERN_ERR "unable to get cpu clock\n");
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index b1aee33efd11..c95f90bf734c 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -32,7 +32,6 @@
32#include <asm/reboot.h> 32#include <asm/reboot.h>
33#include <asm/time.h> 33#include <asm/time.h>
34#include <bcm47xx.h> 34#include <bcm47xx.h>
35#include <asm/fw/cfe/cfe_api.h>
36#include <asm/mach-bcm47xx/nvram.h> 35#include <asm/mach-bcm47xx/nvram.h>
37 36
38struct ssb_bus ssb_bcm47xx; 37struct ssb_bus ssb_bcm47xx;
@@ -57,68 +56,112 @@ static void bcm47xx_machine_halt(void)
57 cpu_relax(); 56 cpu_relax();
58} 57}
59 58
60static void str2eaddr(char *str, char *dest) 59#define READ_FROM_NVRAM(_outvar, name, buf) \
61{ 60 if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\
62 int i = 0; 61 sprom->_outvar = simple_strtoul(buf, NULL, 0);
63 62
64 if (str == NULL) { 63static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
65 memset(dest, 0, 6); 64{
66 return; 65 char buf[100];
66 u32 boardflags;
67
68 memset(sprom, 0, sizeof(struct ssb_sprom));
69
70 sprom->revision = 1; /* Fallback: Old hardware does not define this. */
71 READ_FROM_NVRAM(revision, "sromrev", buf);
72 if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
73 nvram_parse_macaddr(buf, sprom->il0mac);
74 if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
75 nvram_parse_macaddr(buf, sprom->et0mac);
76 if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
77 nvram_parse_macaddr(buf, sprom->et1mac);
78 READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
79 READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
80 READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
81 READ_FROM_NVRAM(et1mdcport, "et1mdcport", buf);
82 READ_FROM_NVRAM(board_rev, "boardrev", buf);
83 READ_FROM_NVRAM(country_code, "ccode", buf);
84 READ_FROM_NVRAM(ant_available_a, "aa5g", buf);
85 READ_FROM_NVRAM(ant_available_bg, "aa2g", buf);
86 READ_FROM_NVRAM(pa0b0, "pa0b0", buf);
87 READ_FROM_NVRAM(pa0b1, "pa0b1", buf);
88 READ_FROM_NVRAM(pa0b2, "pa0b2", buf);
89 READ_FROM_NVRAM(pa1b0, "pa1b0", buf);
90 READ_FROM_NVRAM(pa1b1, "pa1b1", buf);
91 READ_FROM_NVRAM(pa1b2, "pa1b2", buf);
92 READ_FROM_NVRAM(pa1lob0, "pa1lob0", buf);
93 READ_FROM_NVRAM(pa1lob2, "pa1lob1", buf);
94 READ_FROM_NVRAM(pa1lob1, "pa1lob2", buf);
95 READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf);
96 READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf);
97 READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf);
98 READ_FROM_NVRAM(gpio0, "wl0gpio0", buf);
99 READ_FROM_NVRAM(gpio1, "wl0gpio1", buf);
100 READ_FROM_NVRAM(gpio2, "wl0gpio2", buf);
101 READ_FROM_NVRAM(gpio3, "wl0gpio3", buf);
102 READ_FROM_NVRAM(maxpwr_bg, "pa0maxpwr", buf);
103 READ_FROM_NVRAM(maxpwr_al, "pa1lomaxpwr", buf);
104 READ_FROM_NVRAM(maxpwr_a, "pa1maxpwr", buf);
105 READ_FROM_NVRAM(maxpwr_ah, "pa1himaxpwr", buf);
106 READ_FROM_NVRAM(itssi_a, "pa1itssit", buf);
107 READ_FROM_NVRAM(itssi_bg, "pa0itssit", buf);
108 READ_FROM_NVRAM(tri2g, "tri2g", buf);
109 READ_FROM_NVRAM(tri5gl, "tri5gl", buf);
110 READ_FROM_NVRAM(tri5g, "tri5g", buf);
111 READ_FROM_NVRAM(tri5gh, "tri5gh", buf);
112 READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf);
113 READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf);
114 READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf);
115 READ_FROM_NVRAM(rssismc2g, "rssismc2g", buf);
116 READ_FROM_NVRAM(rssismf2g, "rssismf2g", buf);
117 READ_FROM_NVRAM(bxa2g, "bxa2g", buf);
118 READ_FROM_NVRAM(rssisav5g, "rssisav5g", buf);
119 READ_FROM_NVRAM(rssismc5g, "rssismc5g", buf);
120 READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf);
121 READ_FROM_NVRAM(bxa5g, "bxa5g", buf);
122 READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf);
123 READ_FROM_NVRAM(ofdm2gpo, "ofdm2gpo", buf);
124 READ_FROM_NVRAM(ofdm5glpo, "ofdm5glpo", buf);
125 READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf);
126 READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf);
127
128 if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0) {
129 boardflags = simple_strtoul(buf, NULL, 0);
130 if (boardflags) {
131 sprom->boardflags_lo = (boardflags & 0x0000FFFFU);
132 sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16;
133 }
67 } 134 }
68 135 if (nvram_getenv("boardflags2", buf, sizeof(buf)) >= 0) {
69 for (;;) { 136 boardflags = simple_strtoul(buf, NULL, 0);
70 dest[i++] = (char) simple_strtoul(str, NULL, 16); 137 if (boardflags) {
71 str += 2; 138 sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
72 if (!*str++ || i == 6) 139 sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16;
73 break; 140 }
74 } 141 }
75} 142}
76 143
77static int bcm47xx_get_invariants(struct ssb_bus *bus, 144static int bcm47xx_get_invariants(struct ssb_bus *bus,
78 struct ssb_init_invariants *iv) 145 struct ssb_init_invariants *iv)
79{ 146{
80 char buf[100]; 147 char buf[20];
81 148
82 /* Fill boardinfo structure */ 149 /* Fill boardinfo structure */
83 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo)); 150 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
84 151
85 if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 || 152 if (nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
86 nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0) 153 iv->boardinfo.vendor = (u16)simple_strtoul(buf, NULL, 0);
87 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); 154 else
88 if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 || 155 iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
89 nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) 156 if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
90 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); 157 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
91 if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 || 158 if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
92 nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
93 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); 159 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
94 160
95 /* Fill sprom structure */ 161 bcm47xx_fill_sprom(&iv->sprom);
96 memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
97 iv->sprom.revision = 3;
98
99 if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
100 nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
101 str2eaddr(buf, iv->sprom.et0mac);
102 162
103 if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 || 163 if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
104 nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0) 164 iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
105 str2eaddr(buf, iv->sprom.et1mac);
106
107 if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
108 nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
109 iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
110
111 if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
112 nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
113 iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
114
115 if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
116 nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
117 iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
118
119 if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
120 nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
121 iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
122 165
123 return 0; 166 return 0;
124} 167}
@@ -126,12 +169,28 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus,
126void __init plat_mem_setup(void) 169void __init plat_mem_setup(void)
127{ 170{
128 int err; 171 int err;
172 char buf[100];
173 struct ssb_mipscore *mcore;
129 174
130 err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE, 175 err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
131 bcm47xx_get_invariants); 176 bcm47xx_get_invariants);
132 if (err) 177 if (err)
133 panic("Failed to initialize SSB bus (err %d)\n", err); 178 panic("Failed to initialize SSB bus (err %d)\n", err);
134 179
180 mcore = &ssb_bcm47xx.mipscore;
181 if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
182 if (strstr(buf, "console=ttyS1")) {
183 struct ssb_serial_port port;
184
185 printk(KERN_DEBUG "Swapping serial ports!\n");
186 /* swap serial ports */
187 memcpy(&port, &mcore->serial_ports[0], sizeof(port));
188 memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1],
189 sizeof(port));
190 memcpy(&mcore->serial_ports[1], &port, sizeof(port));
191 }
192 }
193
135 _machine_restart = bcm47xx_machine_restart; 194 _machine_restart = bcm47xx_machine_restart;
136 _machine_halt = bcm47xx_machine_halt; 195 _machine_halt = bcm47xx_machine_halt;
137 pm_power_off = bcm47xx_machine_halt; 196 pm_power_off = bcm47xx_machine_halt;
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index 06d59dcbe243..86877539c6e8 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -111,8 +111,8 @@
111 * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM 111 * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM
112 */ 112 */
113 113
114#define PRID_IMP_BMIPS4KC 0x4000 114#define PRID_IMP_BMIPS32_REV4 0x4000
115#define PRID_IMP_BMIPS32 0x8000 115#define PRID_IMP_BMIPS32_REV8 0x8000
116#define PRID_IMP_BMIPS3300 0x9000 116#define PRID_IMP_BMIPS3300 0x9000
117#define PRID_IMP_BMIPS3300_ALT 0x9100 117#define PRID_IMP_BMIPS3300_ALT 0x9100
118#define PRID_IMP_BMIPS3300_BUG 0x0000 118#define PRID_IMP_BMIPS3300_BUG 0x0000
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index fd1d39eb7431..455c0ac7d4ea 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -249,7 +249,8 @@ extern struct mips_abi mips_abi_n32;
249 249
250#define SET_PERSONALITY(ex) \ 250#define SET_PERSONALITY(ex) \
251do { \ 251do { \
252 set_personality(PER_LINUX); \ 252 if (personality(current->personality) != PER_LINUX) \
253 set_personality(PER_LINUX); \
253 \ 254 \
254 current->thread.abi = &mips_abi; \ 255 current->thread.abi = &mips_abi; \
255} while (0) 256} while (0)
@@ -296,6 +297,8 @@ do { \
296 297
297#define SET_PERSONALITY(ex) \ 298#define SET_PERSONALITY(ex) \
298do { \ 299do { \
300 unsigned int p; \
301 \
299 clear_thread_flag(TIF_32BIT_REGS); \ 302 clear_thread_flag(TIF_32BIT_REGS); \
300 clear_thread_flag(TIF_32BIT_ADDR); \ 303 clear_thread_flag(TIF_32BIT_ADDR); \
301 \ 304 \
@@ -304,7 +307,8 @@ do { \
304 else \ 307 else \
305 current->thread.abi = &mips_abi; \ 308 current->thread.abi = &mips_abi; \
306 \ 309 \
307 if (current->personality != PER_LINUX32) \ 310 p = personality(current->personality); \
311 if (p != PER_LINUX32 && p != PER_LINUX) \
308 set_personality(PER_LINUX); \ 312 set_personality(PER_LINUX); \
309} while (0) 313} while (0)
310 314
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index c98bf514ec7d..5b017f23e243 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -329,10 +329,14 @@ static inline void pfx##write##bwlq(type val, \
329 "dsrl32 %L0, %L0, 0" "\n\t" \ 329 "dsrl32 %L0, %L0, 0" "\n\t" \
330 "dsll32 %M0, %M0, 0" "\n\t" \ 330 "dsll32 %M0, %M0, 0" "\n\t" \
331 "or %L0, %L0, %M0" "\n\t" \ 331 "or %L0, %L0, %M0" "\n\t" \
332 ".set push" "\n\t" \
333 ".set noreorder" "\n\t" \
334 ".set nomacro" "\n\t" \
332 "sd %L0, %2" "\n\t" \ 335 "sd %L0, %2" "\n\t" \
336 ".set pop" "\n\t" \
333 ".set mips0" "\n" \ 337 ".set mips0" "\n" \
334 : "=r" (__tmp) \ 338 : "=r" (__tmp) \
335 : "0" (__val), "m" (*__mem)); \ 339 : "0" (__val), "R" (*__mem)); \
336 if (irq) \ 340 if (irq) \
337 local_irq_restore(__flags); \ 341 local_irq_restore(__flags); \
338 } else \ 342 } else \
@@ -355,12 +359,16 @@ static inline type pfx##read##bwlq(const volatile void __iomem *mem) \
355 local_irq_save(__flags); \ 359 local_irq_save(__flags); \
356 __asm__ __volatile__( \ 360 __asm__ __volatile__( \
357 ".set mips3" "\t\t# __readq" "\n\t" \ 361 ".set mips3" "\t\t# __readq" "\n\t" \
362 ".set push" "\n\t" \
363 ".set noreorder" "\n\t" \
364 ".set nomacro" "\n\t" \
358 "ld %L0, %1" "\n\t" \ 365 "ld %L0, %1" "\n\t" \
366 ".set pop" "\n\t" \
359 "dsra32 %M0, %L0, 0" "\n\t" \ 367 "dsra32 %M0, %L0, 0" "\n\t" \
360 "sll %L0, %L0, 0" "\n\t" \ 368 "sll %L0, %L0, 0" "\n\t" \
361 ".set mips0" "\n" \ 369 ".set mips0" "\n" \
362 : "=r" (__val) \ 370 : "=r" (__val) \
363 : "m" (*__mem)); \ 371 : "R" (*__mem)); \
364 if (irq) \ 372 if (irq) \
365 local_irq_restore(__flags); \ 373 local_irq_restore(__flags); \
366 } else { \ 374 } else { \
diff --git a/arch/mips/include/asm/mach-ar7/ar7.h b/arch/mips/include/asm/mach-ar7/ar7.h
index 7919d76186bf..07d3fadb2443 100644
--- a/arch/mips/include/asm/mach-ar7/ar7.h
+++ b/arch/mips/include/asm/mach-ar7/ar7.h
@@ -201,7 +201,6 @@ static inline void ar7_device_off(u32 bit)
201} 201}
202 202
203int __init ar7_gpio_init(void); 203int __init ar7_gpio_init(void);
204 204void __init ar7_init_clocks(void);
205int __init ar7_gpio_init(void);
206 205
207#endif /* __AR7_H__ */ 206#endif /* __AR7_H__ */
diff --git a/arch/mips/include/asm/mach-bcm47xx/nvram.h b/arch/mips/include/asm/mach-bcm47xx/nvram.h
index c58ebd8bc155..9759588ba3cf 100644
--- a/arch/mips/include/asm/mach-bcm47xx/nvram.h
+++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h
@@ -12,6 +12,7 @@
12#define __NVRAM_H 12#define __NVRAM_H
13 13
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/kernel.h>
15 16
16struct nvram_header { 17struct nvram_header {
17 u32 magic; 18 u32 magic;
@@ -36,4 +37,10 @@ struct nvram_header {
36 37
37extern int nvram_getenv(char *name, char *val, size_t val_len); 38extern int nvram_getenv(char *name, char *val, size_t val_len);
38 39
40static inline void nvram_parse_macaddr(char *buf, u8 *macaddr)
41{
42 sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], &macaddr[1],
43 &macaddr[2], &macaddr[3], &macaddr[4], &macaddr[5]);
44}
45
39#endif 46#endif
diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 5742bb4d78f4..5c0a3575877c 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (c) 2009 Qi Hardware inc., 6 * Copyright (c) 2009 Qi Hardware inc.,
7 * Author: Xiangfu Liu <xiangfu@qi-hardware.com> 7 * Author: Xiangfu Liu <xiangfu@qi-hardware.com>
8 * Copyright 2010, Lars-Petrer Clausen <lars@metafoo.de> 8 * Copyright 2010, Lars-Peter Clausen <lars@metafoo.de>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 or later 11 * it under the terms of the GNU General Public License version 2 or later
@@ -235,7 +235,7 @@ static const unsigned int qi_lb60_keypad_rows[] = {
235 QI_LB60_GPIO_KEYIN(3), 235 QI_LB60_GPIO_KEYIN(3),
236 QI_LB60_GPIO_KEYIN(4), 236 QI_LB60_GPIO_KEYIN(4),
237 QI_LB60_GPIO_KEYIN(5), 237 QI_LB60_GPIO_KEYIN(5),
238 QI_LB60_GPIO_KEYIN(7), 238 QI_LB60_GPIO_KEYIN(6),
239 QI_LB60_GPIO_KEYIN8, 239 QI_LB60_GPIO_KEYIN8,
240}; 240};
241 241
diff --git a/arch/mips/jz4740/platform.c b/arch/mips/jz4740/platform.c
index 95bc2b5b14f1..1cc9e544d16b 100644
--- a/arch/mips/jz4740/platform.c
+++ b/arch/mips/jz4740/platform.c
@@ -208,7 +208,7 @@ struct platform_device jz4740_i2s_device = {
208 208
209/* PCM */ 209/* PCM */
210struct platform_device jz4740_pcm_device = { 210struct platform_device jz4740_pcm_device = {
211 .name = "jz4740-pcm", 211 .name = "jz4740-pcm-audio",
212 .id = -1, 212 .id = -1,
213}; 213};
214 214
diff --git a/arch/mips/jz4740/prom.c b/arch/mips/jz4740/prom.c
index cfeac15eb2e4..4a70407f55bb 100644
--- a/arch/mips/jz4740/prom.c
+++ b/arch/mips/jz4740/prom.c
@@ -23,7 +23,7 @@
23#include <asm/bootinfo.h> 23#include <asm/bootinfo.h>
24#include <asm/mach-jz4740/base.h> 24#include <asm/mach-jz4740/base.h>
25 25
26void jz4740_init_cmdline(int argc, char *argv[]) 26static __init void jz4740_init_cmdline(int argc, char *argv[])
27{ 27{
28 unsigned int count = COMMAND_LINE_SIZE - 1; 28 unsigned int count = COMMAND_LINE_SIZE - 1;
29 int i; 29 int i;
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 2f4d7a99bcc2..98c5a9737c14 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -32,7 +32,7 @@ static int mips_next_event(unsigned long delta,
32 cnt = read_c0_count(); 32 cnt = read_c0_count();
33 cnt += delta; 33 cnt += delta;
34 write_c0_compare(cnt); 34 write_c0_compare(cnt);
35 res = ((int)(read_c0_count() - cnt) > 0) ? -ETIME : 0; 35 res = ((int)(read_c0_count() - cnt) >= 0) ? -ETIME : 0;
36 return res; 36 return res;
37} 37}
38 38
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 71620e19827a..68dae7b6b5db 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -905,7 +905,8 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
905{ 905{
906 decode_configs(c); 906 decode_configs(c);
907 switch (c->processor_id & 0xff00) { 907 switch (c->processor_id & 0xff00) {
908 case PRID_IMP_BMIPS32: 908 case PRID_IMP_BMIPS32_REV4:
909 case PRID_IMP_BMIPS32_REV8:
909 c->cputype = CPU_BMIPS32; 910 c->cputype = CPU_BMIPS32;
910 __cpu_name[cpu] = "Broadcom BMIPS32"; 911 __cpu_name[cpu] = "Broadcom BMIPS32";
911 break; 912 break;
@@ -933,10 +934,6 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
933 __cpu_name[cpu] = "Broadcom BMIPS5000"; 934 __cpu_name[cpu] = "Broadcom BMIPS5000";
934 c->options |= MIPS_CPU_ULRI; 935 c->options |= MIPS_CPU_ULRI;
935 break; 936 break;
936 case PRID_IMP_BMIPS4KC:
937 c->cputype = CPU_4KC;
938 __cpu_name[cpu] = "MIPS 4Kc";
939 break;
940 } 937 }
941} 938}
942 939
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 6343b4a5b835..876a75cc376f 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -251,14 +251,15 @@ SYSCALL_DEFINE5(n32_msgrcv, int, msqid, u32, msgp, size_t, msgsz,
251 251
252SYSCALL_DEFINE1(32_personality, unsigned long, personality) 252SYSCALL_DEFINE1(32_personality, unsigned long, personality)
253{ 253{
254 unsigned int p = personality & 0xffffffff;
254 int ret; 255 int ret;
255 personality &= 0xffffffff; 256
256 if (personality(current->personality) == PER_LINUX32 && 257 if (personality(current->personality) == PER_LINUX32 &&
257 personality == PER_LINUX) 258 personality(p) == PER_LINUX)
258 personality = PER_LINUX32; 259 p = (p & ~PER_MASK) | PER_LINUX32;
259 ret = sys_personality(personality); 260 ret = sys_personality(p);
260 if (ret == PER_LINUX32) 261 if (ret != -1 && personality(ret) == PER_LINUX32)
261 ret = PER_LINUX; 262 ret = (ret & ~PER_MASK) | PER_LINUX;
262 return ret; 263 return ret;
263} 264}
264 265
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 99960940d4a4..ae167df73ddd 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -142,7 +142,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
142 childregs->regs[7] = 0; /* Clear error flag */ 142 childregs->regs[7] = 0; /* Clear error flag */
143 143
144 childregs->regs[2] = 0; /* Child gets zero as return value */ 144 childregs->regs[2] = 0; /* Child gets zero as return value */
145 regs->regs[2] = p->pid;
146 145
147 if (childregs->cp0_status & ST0_CU0) { 146 if (childregs->cp0_status & ST0_CU0) {
148 childregs->regs[28] = (unsigned long) ti; 147 childregs->regs[28] = (unsigned long) ti;
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
index e000b278f024..9dbe58368953 100644
--- a/arch/mips/kernel/prom.c
+++ b/arch/mips/kernel/prom.c
@@ -100,7 +100,7 @@ void __init device_tree_init(void)
100 return; 100 return;
101 101
102 base = virt_to_phys((void *)initial_boot_params); 102 base = virt_to_phys((void *)initial_boot_params);
103 size = initial_boot_params->totalsize; 103 size = be32_to_cpu(initial_boot_params->totalsize);
104 104
105 /* Before we do anything, lets reserve the dt blob */ 105 /* Before we do anything, lets reserve the dt blob */
106 reserve_mem_mach(base, size); 106 reserve_mem_mach(base, size);
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c
index 43e7cdc5ded2..c0e81418ba21 100644
--- a/arch/mips/kernel/smp-mt.c
+++ b/arch/mips/kernel/smp-mt.c
@@ -153,7 +153,7 @@ static void __cpuinit vsmp_init_secondary(void)
153{ 153{
154 extern int gic_present; 154 extern int gic_present;
155 155
156 /* This is Malta specific: IPI,performance and timer inetrrupts */ 156 /* This is Malta specific: IPI,performance and timer interrupts */
157 if (gic_present) 157 if (gic_present)
158 change_c0_status(ST0_IM, STATUSF_IP3 | STATUSF_IP4 | 158 change_c0_status(ST0_IM, STATUSF_IP3 | STATUSF_IP4 |
159 STATUSF_IP6 | STATUSF_IP7); 159 STATUSF_IP6 | STATUSF_IP7);
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 8e9fbe75894e..e97104302541 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -83,7 +83,8 @@ extern asmlinkage void handle_mcheck(void);
83extern asmlinkage void handle_reserved(void); 83extern asmlinkage void handle_reserved(void);
84 84
85extern int fpu_emulator_cop1Handler(struct pt_regs *xcp, 85extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
86 struct mips_fpu_struct *ctx, int has_fpu); 86 struct mips_fpu_struct *ctx, int has_fpu,
87 void *__user *fault_addr);
87 88
88void (*board_be_init)(void); 89void (*board_be_init)(void);
89int (*board_be_handler)(struct pt_regs *regs, int is_fixup); 90int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
@@ -661,12 +662,36 @@ asmlinkage void do_ov(struct pt_regs *regs)
661 force_sig_info(SIGFPE, &info, current); 662 force_sig_info(SIGFPE, &info, current);
662} 663}
663 664
665static int process_fpemu_return(int sig, void __user *fault_addr)
666{
667 if (sig == SIGSEGV || sig == SIGBUS) {
668 struct siginfo si = {0};
669 si.si_addr = fault_addr;
670 si.si_signo = sig;
671 if (sig == SIGSEGV) {
672 if (find_vma(current->mm, (unsigned long)fault_addr))
673 si.si_code = SEGV_ACCERR;
674 else
675 si.si_code = SEGV_MAPERR;
676 } else {
677 si.si_code = BUS_ADRERR;
678 }
679 force_sig_info(sig, &si, current);
680 return 1;
681 } else if (sig) {
682 force_sig(sig, current);
683 return 1;
684 } else {
685 return 0;
686 }
687}
688
664/* 689/*
665 * XXX Delayed fp exceptions when doing a lazy ctx switch XXX 690 * XXX Delayed fp exceptions when doing a lazy ctx switch XXX
666 */ 691 */
667asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31) 692asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
668{ 693{
669 siginfo_t info; 694 siginfo_t info = {0};
670 695
671 if (notify_die(DIE_FP, "FP exception", regs, 0, regs_to_trapnr(regs), SIGFPE) 696 if (notify_die(DIE_FP, "FP exception", regs, 0, regs_to_trapnr(regs), SIGFPE)
672 == NOTIFY_STOP) 697 == NOTIFY_STOP)
@@ -675,6 +700,7 @@ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
675 700
676 if (fcr31 & FPU_CSR_UNI_X) { 701 if (fcr31 & FPU_CSR_UNI_X) {
677 int sig; 702 int sig;
703 void __user *fault_addr = NULL;
678 704
679 /* 705 /*
680 * Unimplemented operation exception. If we've got the full 706 * Unimplemented operation exception. If we've got the full
@@ -690,7 +716,8 @@ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
690 lose_fpu(1); 716 lose_fpu(1);
691 717
692 /* Run the emulator */ 718 /* Run the emulator */
693 sig = fpu_emulator_cop1Handler(regs, &current->thread.fpu, 1); 719 sig = fpu_emulator_cop1Handler(regs, &current->thread.fpu, 1,
720 &fault_addr);
694 721
695 /* 722 /*
696 * We can't allow the emulated instruction to leave any of 723 * We can't allow the emulated instruction to leave any of
@@ -702,8 +729,7 @@ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
702 own_fpu(1); /* Using the FPU again. */ 729 own_fpu(1); /* Using the FPU again. */
703 730
704 /* If something went wrong, signal */ 731 /* If something went wrong, signal */
705 if (sig) 732 process_fpemu_return(sig, fault_addr);
706 force_sig(sig, current);
707 733
708 return; 734 return;
709 } else if (fcr31 & FPU_CSR_INV_X) 735 } else if (fcr31 & FPU_CSR_INV_X)
@@ -996,11 +1022,11 @@ asmlinkage void do_cpu(struct pt_regs *regs)
996 1022
997 if (!raw_cpu_has_fpu) { 1023 if (!raw_cpu_has_fpu) {
998 int sig; 1024 int sig;
1025 void __user *fault_addr = NULL;
999 sig = fpu_emulator_cop1Handler(regs, 1026 sig = fpu_emulator_cop1Handler(regs,
1000 &current->thread.fpu, 0); 1027 &current->thread.fpu,
1001 if (sig) 1028 0, &fault_addr);
1002 force_sig(sig, current); 1029 if (!process_fpemu_return(sig, fault_addr))
1003 else
1004 mt_ase_fp_affinity(); 1030 mt_ase_fp_affinity();
1005 } 1031 }
1006 1032
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 3eb3cde2f661..6a1fdfef8fde 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -1092,6 +1092,10 @@ static int vpe_open(struct inode *inode, struct file *filp)
1092 1092
1093 /* this of-course trashes what was there before... */ 1093 /* this of-course trashes what was there before... */
1094 v->pbuffer = vmalloc(P_SIZE); 1094 v->pbuffer = vmalloc(P_SIZE);
1095 if (!v->pbuffer) {
1096 pr_warning("VPE loader: unable to allocate memory\n");
1097 return -ENOMEM;
1098 }
1095 v->plen = P_SIZE; 1099 v->plen = P_SIZE;
1096 v->load_addr = NULL; 1100 v->load_addr = NULL;
1097 v->len = 0; 1101 v->len = 0;
@@ -1149,10 +1153,9 @@ static int vpe_release(struct inode *inode, struct file *filp)
1149 if (ret < 0) 1153 if (ret < 0)
1150 v->shared_ptr = NULL; 1154 v->shared_ptr = NULL;
1151 1155
1152 // cleanup any temp buffers 1156 vfree(v->pbuffer);
1153 if (v->pbuffer)
1154 vfree(v->pbuffer);
1155 v->plen = 0; 1157 v->plen = 0;
1158
1156 return ret; 1159 return ret;
1157} 1160}
1158 1161
@@ -1169,11 +1172,6 @@ static ssize_t vpe_write(struct file *file, const char __user * buffer,
1169 if (v == NULL) 1172 if (v == NULL)
1170 return -ENODEV; 1173 return -ENODEV;
1171 1174
1172 if (v->pbuffer == NULL) {
1173 printk(KERN_ERR "VPE loader: no buffer for program\n");
1174 return -ENOMEM;
1175 }
1176
1177 if ((count + v->len) > v->plen) { 1175 if ((count + v->len) > v->plen) {
1178 printk(KERN_WARNING 1176 printk(KERN_WARNING
1179 "VPE loader: elf size too big. Perhaps strip uneeded symbols\n"); 1177 "VPE loader: elf size too big. Perhaps strip uneeded symbols\n");
diff --git a/arch/mips/lib/memset.S b/arch/mips/lib/memset.S
index 77dc3b20110a..606c8a9efe3b 100644
--- a/arch/mips/lib/memset.S
+++ b/arch/mips/lib/memset.S
@@ -161,16 +161,16 @@ FEXPORT(__bzero)
161 161
162.Lfwd_fixup: 162.Lfwd_fixup:
163 PTR_L t0, TI_TASK($28) 163 PTR_L t0, TI_TASK($28)
164 LONG_L t0, THREAD_BUADDR(t0)
165 andi a2, 0x3f 164 andi a2, 0x3f
165 LONG_L t0, THREAD_BUADDR(t0)
166 LONG_ADDU a2, t1 166 LONG_ADDU a2, t1
167 jr ra 167 jr ra
168 LONG_SUBU a2, t0 168 LONG_SUBU a2, t0
169 169
170.Lpartial_fixup: 170.Lpartial_fixup:
171 PTR_L t0, TI_TASK($28) 171 PTR_L t0, TI_TASK($28)
172 LONG_L t0, THREAD_BUADDR(t0)
173 andi a2, LONGMASK 172 andi a2, LONGMASK
173 LONG_L t0, THREAD_BUADDR(t0)
174 LONG_ADDU a2, t1 174 LONG_ADDU a2, t1
175 jr ra 175 jr ra
176 LONG_SUBU a2, t0 176 LONG_SUBU a2, t0
diff --git a/arch/mips/loongson/common/env.c b/arch/mips/loongson/common/env.c
index ae4cff97a56c..11b193f848f8 100644
--- a/arch/mips/loongson/common/env.c
+++ b/arch/mips/loongson/common/env.c
@@ -29,9 +29,9 @@ unsigned long memsize, highmemsize;
29 29
30#define parse_even_earlier(res, option, p) \ 30#define parse_even_earlier(res, option, p) \
31do { \ 31do { \
32 int ret; \
32 if (strncmp(option, (char *)p, strlen(option)) == 0) \ 33 if (strncmp(option, (char *)p, strlen(option)) == 0) \
33 strict_strtol((char *)p + strlen(option"="), \ 34 ret = strict_strtol((char *)p + strlen(option"="), 10, &res); \
34 10, &res); \
35} while (0) 35} while (0)
36 36
37void __init prom_init_env(void) 37void __init prom_init_env(void)
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index b2ad1b0910ff..d32cb0503110 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -64,7 +64,7 @@ static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
64 64
65#if __mips >= 4 && __mips != 32 65#if __mips >= 4 && __mips != 32
66static int fpux_emu(struct pt_regs *, 66static int fpux_emu(struct pt_regs *,
67 struct mips_fpu_struct *, mips_instruction); 67 struct mips_fpu_struct *, mips_instruction, void *__user *);
68#endif 68#endif
69 69
70/* Further private data for which no space exists in mips_fpu_struct */ 70/* Further private data for which no space exists in mips_fpu_struct */
@@ -208,16 +208,23 @@ static inline int cop1_64bit(struct pt_regs *xcp)
208 * Two instructions if the instruction is in a branch delay slot. 208 * Two instructions if the instruction is in a branch delay slot.
209 */ 209 */
210 210
211static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx) 211static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
212 void *__user *fault_addr)
212{ 213{
213 mips_instruction ir; 214 mips_instruction ir;
214 unsigned long emulpc, contpc; 215 unsigned long emulpc, contpc;
215 unsigned int cond; 216 unsigned int cond;
216 217
217 if (get_user(ir, (mips_instruction __user *) xcp->cp0_epc)) { 218 if (!access_ok(VERIFY_READ, xcp->cp0_epc, sizeof(mips_instruction))) {
218 MIPS_FPU_EMU_INC_STATS(errors); 219 MIPS_FPU_EMU_INC_STATS(errors);
220 *fault_addr = (mips_instruction __user *)xcp->cp0_epc;
219 return SIGBUS; 221 return SIGBUS;
220 } 222 }
223 if (__get_user(ir, (mips_instruction __user *) xcp->cp0_epc)) {
224 MIPS_FPU_EMU_INC_STATS(errors);
225 *fault_addr = (mips_instruction __user *)xcp->cp0_epc;
226 return SIGSEGV;
227 }
221 228
222 /* XXX NEC Vr54xx bug workaround */ 229 /* XXX NEC Vr54xx bug workaround */
223 if ((xcp->cp0_cause & CAUSEF_BD) && !isBranchInstr(&ir)) 230 if ((xcp->cp0_cause & CAUSEF_BD) && !isBranchInstr(&ir))
@@ -245,10 +252,16 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
245#endif 252#endif
246 return SIGILL; 253 return SIGILL;
247 } 254 }
248 if (get_user(ir, (mips_instruction __user *) emulpc)) { 255 if (!access_ok(VERIFY_READ, emulpc, sizeof(mips_instruction))) {
249 MIPS_FPU_EMU_INC_STATS(errors); 256 MIPS_FPU_EMU_INC_STATS(errors);
257 *fault_addr = (mips_instruction __user *)emulpc;
250 return SIGBUS; 258 return SIGBUS;
251 } 259 }
260 if (__get_user(ir, (mips_instruction __user *) emulpc)) {
261 MIPS_FPU_EMU_INC_STATS(errors);
262 *fault_addr = (mips_instruction __user *)emulpc;
263 return SIGSEGV;
264 }
252 /* __compute_return_epc() will have updated cp0_epc */ 265 /* __compute_return_epc() will have updated cp0_epc */
253 contpc = xcp->cp0_epc; 266 contpc = xcp->cp0_epc;
254 /* In order not to confuse ptrace() et al, tweak context */ 267 /* In order not to confuse ptrace() et al, tweak context */
@@ -269,10 +282,17 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
269 u64 val; 282 u64 val;
270 283
271 MIPS_FPU_EMU_INC_STATS(loads); 284 MIPS_FPU_EMU_INC_STATS(loads);
272 if (get_user(val, va)) { 285
286 if (!access_ok(VERIFY_READ, va, sizeof(u64))) {
273 MIPS_FPU_EMU_INC_STATS(errors); 287 MIPS_FPU_EMU_INC_STATS(errors);
288 *fault_addr = va;
274 return SIGBUS; 289 return SIGBUS;
275 } 290 }
291 if (__get_user(val, va)) {
292 MIPS_FPU_EMU_INC_STATS(errors);
293 *fault_addr = va;
294 return SIGSEGV;
295 }
276 DITOREG(val, MIPSInst_RT(ir)); 296 DITOREG(val, MIPSInst_RT(ir));
277 break; 297 break;
278 } 298 }
@@ -284,10 +304,16 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
284 304
285 MIPS_FPU_EMU_INC_STATS(stores); 305 MIPS_FPU_EMU_INC_STATS(stores);
286 DIFROMREG(val, MIPSInst_RT(ir)); 306 DIFROMREG(val, MIPSInst_RT(ir));
287 if (put_user(val, va)) { 307 if (!access_ok(VERIFY_WRITE, va, sizeof(u64))) {
288 MIPS_FPU_EMU_INC_STATS(errors); 308 MIPS_FPU_EMU_INC_STATS(errors);
309 *fault_addr = va;
289 return SIGBUS; 310 return SIGBUS;
290 } 311 }
312 if (__put_user(val, va)) {
313 MIPS_FPU_EMU_INC_STATS(errors);
314 *fault_addr = va;
315 return SIGSEGV;
316 }
291 break; 317 break;
292 } 318 }
293 319
@@ -297,10 +323,16 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
297 u32 val; 323 u32 val;
298 324
299 MIPS_FPU_EMU_INC_STATS(loads); 325 MIPS_FPU_EMU_INC_STATS(loads);
300 if (get_user(val, va)) { 326 if (!access_ok(VERIFY_READ, va, sizeof(u32))) {
301 MIPS_FPU_EMU_INC_STATS(errors); 327 MIPS_FPU_EMU_INC_STATS(errors);
328 *fault_addr = va;
302 return SIGBUS; 329 return SIGBUS;
303 } 330 }
331 if (__get_user(val, va)) {
332 MIPS_FPU_EMU_INC_STATS(errors);
333 *fault_addr = va;
334 return SIGSEGV;
335 }
304 SITOREG(val, MIPSInst_RT(ir)); 336 SITOREG(val, MIPSInst_RT(ir));
305 break; 337 break;
306 } 338 }
@@ -312,10 +344,16 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
312 344
313 MIPS_FPU_EMU_INC_STATS(stores); 345 MIPS_FPU_EMU_INC_STATS(stores);
314 SIFROMREG(val, MIPSInst_RT(ir)); 346 SIFROMREG(val, MIPSInst_RT(ir));
315 if (put_user(val, va)) { 347 if (!access_ok(VERIFY_WRITE, va, sizeof(u32))) {
316 MIPS_FPU_EMU_INC_STATS(errors); 348 MIPS_FPU_EMU_INC_STATS(errors);
349 *fault_addr = va;
317 return SIGBUS; 350 return SIGBUS;
318 } 351 }
352 if (__put_user(val, va)) {
353 MIPS_FPU_EMU_INC_STATS(errors);
354 *fault_addr = va;
355 return SIGSEGV;
356 }
319 break; 357 break;
320 } 358 }
321 359
@@ -440,11 +478,18 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
440 contpc = (xcp->cp0_epc + 478 contpc = (xcp->cp0_epc +
441 (MIPSInst_SIMM(ir) << 2)); 479 (MIPSInst_SIMM(ir) << 2));
442 480
443 if (get_user(ir, 481 if (!access_ok(VERIFY_READ, xcp->cp0_epc,
444 (mips_instruction __user *) xcp->cp0_epc)) { 482 sizeof(mips_instruction))) {
445 MIPS_FPU_EMU_INC_STATS(errors); 483 MIPS_FPU_EMU_INC_STATS(errors);
484 *fault_addr = (mips_instruction __user *)xcp->cp0_epc;
446 return SIGBUS; 485 return SIGBUS;
447 } 486 }
487 if (__get_user(ir,
488 (mips_instruction __user *) xcp->cp0_epc)) {
489 MIPS_FPU_EMU_INC_STATS(errors);
490 *fault_addr = (mips_instruction __user *)xcp->cp0_epc;
491 return SIGSEGV;
492 }
448 493
449 switch (MIPSInst_OPCODE(ir)) { 494 switch (MIPSInst_OPCODE(ir)) {
450 case lwc1_op: 495 case lwc1_op:
@@ -506,9 +551,8 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
506 551
507#if __mips >= 4 && __mips != 32 552#if __mips >= 4 && __mips != 32
508 case cop1x_op:{ 553 case cop1x_op:{
509 int sig; 554 int sig = fpux_emu(xcp, ctx, ir, fault_addr);
510 555 if (sig)
511 if ((sig = fpux_emu(xcp, ctx, ir)))
512 return sig; 556 return sig;
513 break; 557 break;
514 } 558 }
@@ -604,7 +648,7 @@ DEF3OP(nmadd, dp, ieee754dp_mul, ieee754dp_add, ieee754dp_neg);
604DEF3OP(nmsub, dp, ieee754dp_mul, ieee754dp_sub, ieee754dp_neg); 648DEF3OP(nmsub, dp, ieee754dp_mul, ieee754dp_sub, ieee754dp_neg);
605 649
606static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx, 650static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
607 mips_instruction ir) 651 mips_instruction ir, void *__user *fault_addr)
608{ 652{
609 unsigned rcsr = 0; /* resulting csr */ 653 unsigned rcsr = 0; /* resulting csr */
610 654
@@ -624,10 +668,16 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
624 xcp->regs[MIPSInst_FT(ir)]); 668 xcp->regs[MIPSInst_FT(ir)]);
625 669
626 MIPS_FPU_EMU_INC_STATS(loads); 670 MIPS_FPU_EMU_INC_STATS(loads);
627 if (get_user(val, va)) { 671 if (!access_ok(VERIFY_READ, va, sizeof(u32))) {
628 MIPS_FPU_EMU_INC_STATS(errors); 672 MIPS_FPU_EMU_INC_STATS(errors);
673 *fault_addr = va;
629 return SIGBUS; 674 return SIGBUS;
630 } 675 }
676 if (__get_user(val, va)) {
677 MIPS_FPU_EMU_INC_STATS(errors);
678 *fault_addr = va;
679 return SIGSEGV;
680 }
631 SITOREG(val, MIPSInst_FD(ir)); 681 SITOREG(val, MIPSInst_FD(ir));
632 break; 682 break;
633 683
@@ -638,10 +688,16 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
638 MIPS_FPU_EMU_INC_STATS(stores); 688 MIPS_FPU_EMU_INC_STATS(stores);
639 689
640 SIFROMREG(val, MIPSInst_FS(ir)); 690 SIFROMREG(val, MIPSInst_FS(ir));
641 if (put_user(val, va)) { 691 if (!access_ok(VERIFY_WRITE, va, sizeof(u32))) {
642 MIPS_FPU_EMU_INC_STATS(errors); 692 MIPS_FPU_EMU_INC_STATS(errors);
693 *fault_addr = va;
643 return SIGBUS; 694 return SIGBUS;
644 } 695 }
696 if (put_user(val, va)) {
697 MIPS_FPU_EMU_INC_STATS(errors);
698 *fault_addr = va;
699 return SIGSEGV;
700 }
645 break; 701 break;
646 702
647 case madd_s_op: 703 case madd_s_op:
@@ -701,10 +757,16 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
701 xcp->regs[MIPSInst_FT(ir)]); 757 xcp->regs[MIPSInst_FT(ir)]);
702 758
703 MIPS_FPU_EMU_INC_STATS(loads); 759 MIPS_FPU_EMU_INC_STATS(loads);
704 if (get_user(val, va)) { 760 if (!access_ok(VERIFY_READ, va, sizeof(u64))) {
705 MIPS_FPU_EMU_INC_STATS(errors); 761 MIPS_FPU_EMU_INC_STATS(errors);
762 *fault_addr = va;
706 return SIGBUS; 763 return SIGBUS;
707 } 764 }
765 if (__get_user(val, va)) {
766 MIPS_FPU_EMU_INC_STATS(errors);
767 *fault_addr = va;
768 return SIGSEGV;
769 }
708 DITOREG(val, MIPSInst_FD(ir)); 770 DITOREG(val, MIPSInst_FD(ir));
709 break; 771 break;
710 772
@@ -714,10 +776,16 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
714 776
715 MIPS_FPU_EMU_INC_STATS(stores); 777 MIPS_FPU_EMU_INC_STATS(stores);
716 DIFROMREG(val, MIPSInst_FS(ir)); 778 DIFROMREG(val, MIPSInst_FS(ir));
717 if (put_user(val, va)) { 779 if (!access_ok(VERIFY_WRITE, va, sizeof(u64))) {
718 MIPS_FPU_EMU_INC_STATS(errors); 780 MIPS_FPU_EMU_INC_STATS(errors);
781 *fault_addr = va;
719 return SIGBUS; 782 return SIGBUS;
720 } 783 }
784 if (__put_user(val, va)) {
785 MIPS_FPU_EMU_INC_STATS(errors);
786 *fault_addr = va;
787 return SIGSEGV;
788 }
721 break; 789 break;
722 790
723 case madd_d_op: 791 case madd_d_op:
@@ -1242,7 +1310,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1242} 1310}
1243 1311
1244int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx, 1312int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1245 int has_fpu) 1313 int has_fpu, void *__user *fault_addr)
1246{ 1314{
1247 unsigned long oldepc, prevepc; 1315 unsigned long oldepc, prevepc;
1248 mips_instruction insn; 1316 mips_instruction insn;
@@ -1252,10 +1320,16 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1252 do { 1320 do {
1253 prevepc = xcp->cp0_epc; 1321 prevepc = xcp->cp0_epc;
1254 1322
1255 if (get_user(insn, (mips_instruction __user *) xcp->cp0_epc)) { 1323 if (!access_ok(VERIFY_READ, xcp->cp0_epc, sizeof(mips_instruction))) {
1256 MIPS_FPU_EMU_INC_STATS(errors); 1324 MIPS_FPU_EMU_INC_STATS(errors);
1325 *fault_addr = (mips_instruction __user *)xcp->cp0_epc;
1257 return SIGBUS; 1326 return SIGBUS;
1258 } 1327 }
1328 if (__get_user(insn, (mips_instruction __user *) xcp->cp0_epc)) {
1329 MIPS_FPU_EMU_INC_STATS(errors);
1330 *fault_addr = (mips_instruction __user *)xcp->cp0_epc;
1331 return SIGSEGV;
1332 }
1259 if (insn == 0) 1333 if (insn == 0)
1260 xcp->cp0_epc += 4; /* skip nops */ 1334 xcp->cp0_epc += 4; /* skip nops */
1261 else { 1335 else {
@@ -1267,7 +1341,7 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1267 */ 1341 */
1268 /* convert to ieee library modes */ 1342 /* convert to ieee library modes */
1269 ieee754_csr.rm = ieee_rm[ieee754_csr.rm]; 1343 ieee754_csr.rm = ieee_rm[ieee754_csr.rm];
1270 sig = cop1Emulate(xcp, ctx); 1344 sig = cop1Emulate(xcp, ctx, fault_addr);
1271 /* revert to mips rounding mode */ 1345 /* revert to mips rounding mode */
1272 ieee754_csr.rm = mips_rm[ieee754_csr.rm]; 1346 ieee754_csr.rm = mips_rm[ieee754_csr.rm];
1273 } 1347 }
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 4fc1a0fbe007..21ea14efb837 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -288,7 +288,7 @@ int mips_dma_supported(struct device *dev, u64 mask)
288 return plat_dma_supported(dev, mask); 288 return plat_dma_supported(dev, mask);
289} 289}
290 290
291void mips_dma_cache_sync(struct device *dev, void *vaddr, size_t size, 291void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
292 enum dma_data_direction direction) 292 enum dma_data_direction direction)
293{ 293{
294 BUG_ON(direction == DMA_NONE); 294 BUG_ON(direction == DMA_NONE);
@@ -298,6 +298,8 @@ void mips_dma_cache_sync(struct device *dev, void *vaddr, size_t size,
298 __dma_sync((unsigned long)vaddr, size, direction); 298 __dma_sync((unsigned long)vaddr, size, direction);
299} 299}
300 300
301EXPORT_SYMBOL(dma_cache_sync);
302
301static struct dma_map_ops mips_default_dma_map_ops = { 303static struct dma_map_ops mips_default_dma_map_ops = {
302 .alloc_coherent = mips_dma_alloc_coherent, 304 .alloc_coherent = mips_dma_alloc_coherent,
303 .free_coherent = mips_dma_free_coherent, 305 .free_coherent = mips_dma_free_coherent,
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index 505fecad4684..9cca8de00545 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -68,6 +68,9 @@ static struct bcache_ops mips_sc_ops = {
68 */ 68 */
69static inline int mips_sc_is_activated(struct cpuinfo_mips *c) 69static inline int mips_sc_is_activated(struct cpuinfo_mips *c)
70{ 70{
71 unsigned int config2 = read_c0_config2();
72 unsigned int tmp;
73
71 /* Check the bypass bit (L2B) */ 74 /* Check the bypass bit (L2B) */
72 switch (c->cputype) { 75 switch (c->cputype) {
73 case CPU_34K: 76 case CPU_34K:
@@ -83,6 +86,7 @@ static inline int mips_sc_is_activated(struct cpuinfo_mips *c)
83 c->scache.linesz = 2 << tmp; 86 c->scache.linesz = 2 << tmp;
84 else 87 else
85 return 0; 88 return 0;
89 return 1;
86} 90}
87 91
88static inline int __init mips_sc_probe(void) 92static inline int __init mips_sc_probe(void)
diff --git a/arch/mips/pmc-sierra/yosemite/py-console.c b/arch/mips/pmc-sierra/yosemite/py-console.c
index b7f1d9c4a8a3..434d7b1a8c6a 100644
--- a/arch/mips/pmc-sierra/yosemite/py-console.c
+++ b/arch/mips/pmc-sierra/yosemite/py-console.c
@@ -65,11 +65,15 @@ static unsigned char readb_outer_space(unsigned long long phys)
65 65
66 __asm__ __volatile__ ( 66 __asm__ __volatile__ (
67 " .set mips3 \n" 67 " .set mips3 \n"
68 " .set push \n"
69 " .set noreorder \n"
70 " .set nomacro \n"
68 " ld %0, %1 \n" 71 " ld %0, %1 \n"
72 " .set pop \n"
69 " lbu %0, (%0) \n" 73 " lbu %0, (%0) \n"
70 " .set mips0 \n" 74 " .set mips0 \n"
71 : "=r" (res) 75 : "=r" (res)
72 : "m" (vaddr)); 76 : "R" (vaddr));
73 77
74 write_c0_status(sr); 78 write_c0_status(sr);
75 ssnop_4(); 79 ssnop_4();
@@ -89,11 +93,15 @@ static void writeb_outer_space(unsigned long long phys, unsigned char c)
89 93
90 __asm__ __volatile__ ( 94 __asm__ __volatile__ (
91 " .set mips3 \n" 95 " .set mips3 \n"
96 " .set push \n"
97 " .set noreorder \n"
98 " .set nomacro \n"
92 " ld %0, %1 \n" 99 " ld %0, %1 \n"
100 " .set pop \n"
93 " sb %2, (%0) \n" 101 " sb %2, (%0) \n"
94 " .set mips0 \n" 102 " .set mips0 \n"
95 : "=&r" (tmp) 103 : "=&r" (tmp)
96 : "m" (vaddr), "r" (c)); 104 : "R" (vaddr), "r" (c));
97 105
98 write_c0_status(sr); 106 write_c0_status(sr);
99 ssnop_4(); 107 ssnop_4();
diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c
index c308989fc464..41707a245dea 100644
--- a/arch/mips/sibyte/swarm/setup.c
+++ b/arch/mips/sibyte/swarm/setup.c
@@ -82,7 +82,7 @@ int swarm_be_handler(struct pt_regs *regs, int is_fixup)
82enum swarm_rtc_type { 82enum swarm_rtc_type {
83 RTC_NONE, 83 RTC_NONE,
84 RTC_XICOR, 84 RTC_XICOR,
85 RTC_M4LT81 85 RTC_M41T81,
86}; 86};
87 87
88enum swarm_rtc_type swarm_rtc_type; 88enum swarm_rtc_type swarm_rtc_type;
@@ -96,7 +96,7 @@ void read_persistent_clock(struct timespec *ts)
96 sec = xicor_get_time(); 96 sec = xicor_get_time();
97 break; 97 break;
98 98
99 case RTC_M4LT81: 99 case RTC_M41T81:
100 sec = m41t81_get_time(); 100 sec = m41t81_get_time();
101 break; 101 break;
102 102
@@ -115,7 +115,7 @@ int rtc_mips_set_time(unsigned long sec)
115 case RTC_XICOR: 115 case RTC_XICOR:
116 return xicor_set_time(sec); 116 return xicor_set_time(sec);
117 117
118 case RTC_M4LT81: 118 case RTC_M41T81:
119 return m41t81_set_time(sec); 119 return m41t81_set_time(sec);
120 120
121 case RTC_NONE: 121 case RTC_NONE:
@@ -141,7 +141,7 @@ void __init plat_mem_setup(void)
141 if (xicor_probe()) 141 if (xicor_probe())
142 swarm_rtc_type = RTC_XICOR; 142 swarm_rtc_type = RTC_XICOR;
143 if (m41t81_probe()) 143 if (m41t81_probe())
144 swarm_rtc_type = RTC_M4LT81; 144 swarm_rtc_type = RTC_M41T81;
145 145
146#ifdef CONFIG_VT 146#ifdef CONFIG_VT
147 screen_info = (struct screen_info) { 147 screen_info = (struct screen_info) {
diff --git a/arch/mn10300/include/asm/syscall.h b/arch/mn10300/include/asm/syscall.h
new file mode 100644
index 000000000000..b44b0bb75a01
--- /dev/null
+++ b/arch/mn10300/include/asm/syscall.h
@@ -0,0 +1,117 @@
1/* Access to user system call parameters and results
2 *
3 * See asm-generic/syscall.h for function descriptions.
4 *
5 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
6 * Written by David Howells (dhowells@redhat.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public Licence
10 * as published by the Free Software Foundation; either version
11 * 2 of the Licence, or (at your option) any later version.
12 */
13
14#ifndef _ASM_SYSCALL_H
15#define _ASM_SYSCALL_H
16
17#include <linux/sched.h>
18#include <linux/err.h>
19
20extern const unsigned long sys_call_table[];
21
22static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
23{
24 return regs->orig_d0;
25}
26
27static inline void syscall_rollback(struct task_struct *task,
28 struct pt_regs *regs)
29{
30 regs->d0 = regs->orig_d0;
31}
32
33static inline long syscall_get_error(struct task_struct *task,
34 struct pt_regs *regs)
35{
36 unsigned long error = regs->d0;
37 return IS_ERR_VALUE(error) ? error : 0;
38}
39
40static inline long syscall_get_return_value(struct task_struct *task,
41 struct pt_regs *regs)
42{
43 return regs->d0;
44}
45
46static inline void syscall_set_return_value(struct task_struct *task,
47 struct pt_regs *regs,
48 int error, long val)
49{
50 regs->d0 = (long) error ?: val;
51}
52
53static inline void syscall_get_arguments(struct task_struct *task,
54 struct pt_regs *regs,
55 unsigned int i, unsigned int n,
56 unsigned long *args)
57{
58 switch (i) {
59 case 0:
60 if (!n--) break;
61 *args++ = regs->a0;
62 case 1:
63 if (!n--) break;
64 *args++ = regs->d1;
65 case 2:
66 if (!n--) break;
67 *args++ = regs->a3;
68 case 3:
69 if (!n--) break;
70 *args++ = regs->a2;
71 case 4:
72 if (!n--) break;
73 *args++ = regs->d3;
74 case 5:
75 if (!n--) break;
76 *args++ = regs->d2;
77 case 6:
78 if (!n--) break;
79 default:
80 BUG();
81 break;
82 }
83}
84
85static inline void syscall_set_arguments(struct task_struct *task,
86 struct pt_regs *regs,
87 unsigned int i, unsigned int n,
88 const unsigned long *args)
89{
90 switch (i) {
91 case 0:
92 if (!n--) break;
93 regs->a0 = *args++;
94 case 1:
95 if (!n--) break;
96 regs->d1 = *args++;
97 case 2:
98 if (!n--) break;
99 regs->a3 = *args++;
100 case 3:
101 if (!n--) break;
102 regs->a2 = *args++;
103 case 4:
104 if (!n--) break;
105 regs->d3 = *args++;
106 case 5:
107 if (!n--) break;
108 regs->d2 = *args++;
109 case 6:
110 if (!n--) break;
111 default:
112 BUG();
113 break;
114 }
115}
116
117#endif /* _ASM_SYSCALL_H */
diff --git a/arch/mn10300/kernel/gdb-io-serial.c b/arch/mn10300/kernel/gdb-io-serial.c
index 0d5d63c91dc3..f28dc99c6f72 100644
--- a/arch/mn10300/kernel/gdb-io-serial.c
+++ b/arch/mn10300/kernel/gdb-io-serial.c
@@ -73,7 +73,8 @@ void gdbstub_io_init(void)
73 GDBPORT_SERIAL_IER = UART_IER_RDI | UART_IER_RLSI; 73 GDBPORT_SERIAL_IER = UART_IER_RDI | UART_IER_RLSI;
74 74
75 /* permit level 0 IRQs to take place */ 75 /* permit level 0 IRQs to take place */
76 local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1)); 76 arch_local_change_intr_mask_level(
77 NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
77} 78}
78 79
79/* 80/*
diff --git a/arch/mn10300/kernel/gdb-io-ttysm.c b/arch/mn10300/kernel/gdb-io-ttysm.c
index 97dfda23342c..abdeea153c89 100644
--- a/arch/mn10300/kernel/gdb-io-ttysm.c
+++ b/arch/mn10300/kernel/gdb-io-ttysm.c
@@ -87,7 +87,8 @@ void __init gdbstub_io_init(void)
87 tmp = *gdbstub_port->_control; 87 tmp = *gdbstub_port->_control;
88 88
89 /* permit level 0 IRQs only */ 89 /* permit level 0 IRQs only */
90 local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1)); 90 arch_local_change_intr_mask_level(
91 NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
91} 92}
92 93
93/* 94/*
diff --git a/arch/mn10300/kernel/gdb-stub.c b/arch/mn10300/kernel/gdb-stub.c
index a5fc3f05309b..b169d99d9f20 100644
--- a/arch/mn10300/kernel/gdb-stub.c
+++ b/arch/mn10300/kernel/gdb-stub.c
@@ -1194,7 +1194,8 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1194 1194
1195 asm volatile("mov mdr,%0" : "=d"(mdr)); 1195 asm volatile("mov mdr,%0" : "=d"(mdr));
1196 local_save_flags(epsw); 1196 local_save_flags(epsw);
1197 local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1)); 1197 arch_local_change_intr_mask_level(
1198 NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
1198 1199
1199 gdbstub_store_fpu(); 1200 gdbstub_store_fpu();
1200 1201
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
index 0d0f8049a17b..e1b14a6ed544 100644
--- a/arch/mn10300/kernel/process.c
+++ b/arch/mn10300/kernel/process.c
@@ -14,7 +14,6 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/smp.h> 16#include <linux/smp.h>
17#include <linux/smp_lock.h>
18#include <linux/stddef.h> 17#include <linux/stddef.h>
19#include <linux/unistd.h> 18#include <linux/unistd.h>
20#include <linux/ptrace.h> 19#include <linux/ptrace.h>
diff --git a/arch/mn10300/kernel/time.c b/arch/mn10300/kernel/time.c
index f860a340acc9..75da468090b9 100644
--- a/arch/mn10300/kernel/time.c
+++ b/arch/mn10300/kernel/time.c
@@ -40,21 +40,17 @@ unsigned long long sched_clock(void)
40 unsigned long long ll; 40 unsigned long long ll;
41 unsigned l[2]; 41 unsigned l[2];
42 } tsc64, result; 42 } tsc64, result;
43 unsigned long tsc, tmp; 43 unsigned long tmp;
44 unsigned product[3]; /* 96-bit intermediate value */ 44 unsigned product[3]; /* 96-bit intermediate value */
45 45
46 /* cnt32_to_63() is not safe with preemption */ 46 /* cnt32_to_63() is not safe with preemption */
47 preempt_disable(); 47 preempt_disable();
48 48
49 /* read the TSC value 49 /* expand the tsc to 64-bits.
50 */
51 tsc = get_cycles();
52
53 /* expand to 64-bits.
54 * - sched_clock() must be called once a minute or better or the 50 * - sched_clock() must be called once a minute or better or the
55 * following will go horribly wrong - see cnt32_to_63() 51 * following will go horribly wrong - see cnt32_to_63()
56 */ 52 */
57 tsc64.ll = cnt32_to_63(tsc) & 0x7fffffffffffffffULL; 53 tsc64.ll = cnt32_to_63(get_cycles()) & 0x7fffffffffffffffULL;
58 54
59 preempt_enable(); 55 preempt_enable();
60 56
diff --git a/arch/parisc/hpux/sys_hpux.c b/arch/parisc/hpux/sys_hpux.c
index ba430a03bc7a..30394081d9b6 100644
--- a/arch/parisc/hpux/sys_hpux.c
+++ b/arch/parisc/hpux/sys_hpux.c
@@ -28,7 +28,6 @@
28#include <linux/namei.h> 28#include <linux/namei.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/syscalls.h> 31#include <linux/syscalls.h>
33#include <linux/utsname.h> 32#include <linux/utsname.h>
34#include <linux/vfs.h> 33#include <linux/vfs.h>
diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c
index 5024f643b3b1..d7d94b845dc2 100644
--- a/arch/parisc/kernel/irq.c
+++ b/arch/parisc/kernel/irq.c
@@ -75,9 +75,6 @@ static void cpu_unmask_irq(unsigned int irq)
75 smp_send_all_nop(); 75 smp_send_all_nop();
76} 76}
77 77
78void no_ack_irq(unsigned int irq) { }
79void no_end_irq(unsigned int irq) { }
80
81void cpu_ack_irq(unsigned int irq) 78void cpu_ack_irq(unsigned int irq)
82{ 79{
83 unsigned long mask = EIEM_MASK(irq); 80 unsigned long mask = EIEM_MASK(irq);
@@ -241,7 +238,7 @@ int cpu_claim_irq(unsigned int irq, struct irq_chip *type, void *data)
241 238
242 /* for iosapic interrupts */ 239 /* for iosapic interrupts */
243 if (type) { 240 if (type) {
244 set_irq_chip_and_handler(irq, type, handle_level_irq); 241 set_irq_chip_and_handler(irq, type, handle_percpu_irq);
245 set_irq_chip_data(irq, data); 242 set_irq_chip_data(irq, data);
246 cpu_unmask_irq(irq); 243 cpu_unmask_irq(irq);
247 } 244 }
@@ -392,7 +389,7 @@ static void claim_cpu_irqs(void)
392 int i; 389 int i;
393 for (i = CPU_IRQ_BASE; i <= CPU_IRQ_MAX; i++) { 390 for (i = CPU_IRQ_BASE; i <= CPU_IRQ_MAX; i++) {
394 set_irq_chip_and_handler(i, &cpu_interrupt_type, 391 set_irq_chip_and_handler(i, &cpu_interrupt_type,
395 handle_level_irq); 392 handle_percpu_irq);
396 } 393 }
397 394
398 set_irq_handler(TIMER_IRQ, handle_percpu_irq); 395 set_irq_handler(TIMER_IRQ, handle_percpu_irq);
diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
index 35c827e94e31..609a331878e7 100644
--- a/arch/parisc/kernel/signal.c
+++ b/arch/parisc/kernel/signal.c
@@ -98,7 +98,6 @@ void
98sys_rt_sigreturn(struct pt_regs *regs, int in_syscall) 98sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
99{ 99{
100 struct rt_sigframe __user *frame; 100 struct rt_sigframe __user *frame;
101 struct siginfo si;
102 sigset_t set; 101 sigset_t set;
103 unsigned long usp = (regs->gr[30] & ~(0x01UL)); 102 unsigned long usp = (regs->gr[30] & ~(0x01UL));
104 unsigned long sigframe_size = PARISC_RT_SIGFRAME_SIZE; 103 unsigned long sigframe_size = PARISC_RT_SIGFRAME_SIZE;
@@ -178,13 +177,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
178 177
179give_sigsegv: 178give_sigsegv:
180 DBG(1,"sys_rt_sigreturn: Sending SIGSEGV\n"); 179 DBG(1,"sys_rt_sigreturn: Sending SIGSEGV\n");
181 si.si_signo = SIGSEGV; 180 force_sig(SIGSEGV, current);
182 si.si_errno = 0;
183 si.si_code = SI_KERNEL;
184 si.si_pid = task_pid_vnr(current);
185 si.si_uid = current_uid();
186 si.si_addr = &frame->uc;
187 force_sig_info(SIGSEGV, &si, current);
188 return; 181 return;
189} 182}
190 183
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
index 9779ece2b070..88a0ad14a9c9 100644
--- a/arch/parisc/kernel/sys_parisc32.c
+++ b/arch/parisc/kernel/sys_parisc32.c
@@ -20,7 +20,6 @@
20#include <linux/times.h> 20#include <linux/times.h>
21#include <linux/time.h> 21#include <linux/time.h>
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <linux/smp_lock.h>
24#include <linux/sem.h> 23#include <linux/sem.h>
25#include <linux/msg.h> 24#include <linux/msg.h>
26#include <linux/shm.h> 25#include <linux/shm.h>
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b6447190e1a2..e625e9e034ae 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -4,6 +4,10 @@ config PPC32
4 bool 4 bool
5 default y if !PPC64 5 default y if !PPC64
6 6
7config 32BIT
8 bool
9 default y if PPC32
10
7config 64BIT 11config 64BIT
8 bool 12 bool
9 default y if PPC64 13 default y if PPC64
diff --git a/arch/powerpc/boot/div64.S b/arch/powerpc/boot/div64.S
index 722f360a32a9..d271ab542673 100644
--- a/arch/powerpc/boot/div64.S
+++ b/arch/powerpc/boot/div64.S
@@ -33,9 +33,10 @@ __div64_32:
33 cntlzw r0,r5 # we are shifting the dividend right 33 cntlzw r0,r5 # we are shifting the dividend right
34 li r10,-1 # to make it < 2^32, and shifting 34 li r10,-1 # to make it < 2^32, and shifting
35 srw r10,r10,r0 # the divisor right the same amount, 35 srw r10,r10,r0 # the divisor right the same amount,
36 add r9,r4,r10 # rounding up (so the estimate cannot 36 addc r9,r4,r10 # rounding up (so the estimate cannot
37 andc r11,r6,r10 # ever be too large, only too small) 37 andc r11,r6,r10 # ever be too large, only too small)
38 andc r9,r9,r10 38 andc r9,r9,r10
39 addze r9,r9
39 or r11,r5,r11 40 or r11,r5,r11
40 rotlw r9,r9,r0 41 rotlw r9,r9,r0
41 rotlw r11,r11,r0 42 rotlw r11,r11,r0
diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
index 7a9db64f3f04..42850ee00ada 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
337 /* FP registers 32 -> 63 */ 337 /* FP registers 32 -> 63 */
338#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE) 338#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
339 if (current) 339 if (current)
340 memcpy(mem, current->thread.evr[regno-32], 340 memcpy(mem, &current->thread.evr[regno-32],
341 dbg_reg_def[regno].size); 341 dbg_reg_def[regno].size);
342#else 342#else
343 /* fp registers not used by kernel, leave zero */ 343 /* fp registers not used by kernel, leave zero */
@@ -362,7 +362,7 @@ int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
362 if (regno >= 32 && regno < 64) { 362 if (regno >= 32 && regno < 64) {
363 /* FP registers 32 -> 63 */ 363 /* FP registers 32 -> 63 */
364#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE) 364#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
365 memcpy(current->thread.evr[regno-32], mem, 365 memcpy(&current->thread.evr[regno-32], mem,
366 dbg_reg_def[regno].size); 366 dbg_reg_def[regno].size);
367#else 367#else
368 /* fp registers not used by kernel, leave zero */ 368 /* fp registers not used by kernel, leave zero */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 2a178b0ebcdf..ce6f61c6f871 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -497,9 +497,8 @@ static void __init emergency_stack_init(void)
497} 497}
498 498
499/* 499/*
500 * Called into from start_kernel, after lock_kernel has been called. 500 * Called into from start_kernel this initializes bootmem, which is used
501 * Initializes bootmem, which is unsed to manage page allocation until 501 * to manage page allocation until mem_init is called.
502 * mem_init is called.
503 */ 502 */
504void __init setup_arch(char **cmdline_p) 503void __init setup_arch(char **cmdline_p)
505{ 504{
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index b1b6043a56c4..4e5bf1edc0f2 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -23,7 +23,6 @@
23#include <linux/resource.h> 23#include <linux/resource.h>
24#include <linux/times.h> 24#include <linux/times.h>
25#include <linux/smp.h> 25#include <linux/smp.h>
26#include <linux/smp_lock.h>
27#include <linux/sem.h> 26#include <linux/sem.h>
28#include <linux/msg.h> 27#include <linux/msg.h>
29#include <linux/shm.h> 28#include <linux/shm.h>
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 83f534d862db..5e9584405c45 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -1123,7 +1123,7 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
1123 else 1123 else
1124#endif /* CONFIG_PPC_HAS_HASH_64K */ 1124#endif /* CONFIG_PPC_HAS_HASH_64K */
1125 rc = __hash_page_4K(ea, access, vsid, ptep, trap, local, ssize, 1125 rc = __hash_page_4K(ea, access, vsid, ptep, trap, local, ssize,
1126 subpage_protection(pgdir, ea)); 1126 subpage_protection(mm, ea));
1127 1127
1128 /* Dump some info in case of hash insertion failure, they should 1128 /* Dump some info in case of hash insertion failure, they should
1129 * never happen so it is really useful to know if/when they do 1129 * never happen so it is really useful to know if/when they do
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index 2c7e801ab20b..6a3997f98dfb 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -92,7 +92,7 @@ static void pte_free_rcu_callback(struct rcu_head *head)
92 92
93static void pte_free_submit(struct pte_freelist_batch *batch) 93static void pte_free_submit(struct pte_freelist_batch *batch)
94{ 94{
95 call_rcu(&batch->rcu, pte_free_rcu_callback); 95 call_rcu_sched(&batch->rcu, pte_free_rcu_callback);
96} 96}
97 97
98void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift) 98void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift)
diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S
index 8b04c54e596f..8526bd9d2aa3 100644
--- a/arch/powerpc/mm/tlb_low_64e.S
+++ b/arch/powerpc/mm/tlb_low_64e.S
@@ -138,8 +138,11 @@
138 cmpldi cr0,r15,0 /* Check for user region */ 138 cmpldi cr0,r15,0 /* Check for user region */
139 std r14,EX_TLB_ESR(r12) /* write crazy -1 to frame */ 139 std r14,EX_TLB_ESR(r12) /* write crazy -1 to frame */
140 beq normal_tlb_miss 140 beq normal_tlb_miss
141
142 li r11,_PAGE_PRESENT|_PAGE_BAP_SX /* Base perm */
143 oris r11,r11,_PAGE_ACCESSED@h
141 /* XXX replace the RMW cycles with immediate loads + writes */ 144 /* XXX replace the RMW cycles with immediate loads + writes */
1421: mfspr r10,SPRN_MAS1 145 mfspr r10,SPRN_MAS1
143 cmpldi cr0,r15,8 /* Check for vmalloc region */ 146 cmpldi cr0,r15,8 /* Check for vmalloc region */
144 rlwinm r10,r10,0,16,1 /* Clear TID */ 147 rlwinm r10,r10,0,16,1 /* Clear TID */
145 mtspr SPRN_MAS1,r10 148 mtspr SPRN_MAS1,r10
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
index 36c0c449a899..2a030d89bbc6 100644
--- a/arch/powerpc/mm/tlb_nohash.c
+++ b/arch/powerpc/mm/tlb_nohash.c
@@ -585,6 +585,6 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,
585 ppc64_rma_size = min_t(u64, first_memblock_size, 0x40000000); 585 ppc64_rma_size = min_t(u64, first_memblock_size, 0x40000000);
586 586
587 /* Finally limit subsequent allocations */ 587 /* Finally limit subsequent allocations */
588 memblock_set_current_limit(ppc64_memblock_base + ppc64_rma_size); 588 memblock_set_current_limit(first_memblock_base + ppc64_rma_size);
589} 589}
590#endif /* CONFIG_PPC64 */ 590#endif /* CONFIG_PPC64 */
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
index c667f0f02c34..3139814f6439 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -47,6 +47,12 @@ config LPARCFG
47config PPC_PSERIES_DEBUG 47config PPC_PSERIES_DEBUG
48 depends on PPC_PSERIES && PPC_EARLY_DEBUG 48 depends on PPC_PSERIES && PPC_EARLY_DEBUG
49 bool "Enable extra debug logging in platforms/pseries" 49 bool "Enable extra debug logging in platforms/pseries"
50 help
51 Say Y here if you want the pseries core to produce a bunch of
52 debug messages to the system log. Select this if you are having a
53 problem with the pseries core and want to see more of what is
54 going on. This does not enable debugging in lpar.c, which must
55 be manually done due to its verbosity.
50 default y 56 default y
51 57
52config PPC_SMLPAR 58config PPC_SMLPAR
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
index 34b7dc12e731..17a11c82e6f8 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -21,8 +21,6 @@
21 * Please address comments and feedback to Linas Vepstas <linas@austin.ibm.com> 21 * Please address comments and feedback to Linas Vepstas <linas@austin.ibm.com>
22 */ 22 */
23 23
24#undef DEBUG
25
26#include <linux/delay.h> 24#include <linux/delay.h>
27#include <linux/init.h> 25#include <linux/init.h>
28#include <linux/list.h> 26#include <linux/list.h>
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index 4b7a062dee15..5fcc92a12d3e 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -25,8 +25,6 @@
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 26 */
27 27
28#undef DEBUG
29
30#include <linux/pci.h> 28#include <linux/pci.h>
31#include <asm/pci-bridge.h> 29#include <asm/pci-bridge.h>
32#include <asm/ppc-pci.h> 30#include <asm/ppc-pci.h>
diff --git a/arch/s390/Kconfig.debug b/arch/s390/Kconfig.debug
index 45e0c6199f36..05221b13ffb1 100644
--- a/arch/s390/Kconfig.debug
+++ b/arch/s390/Kconfig.debug
@@ -6,6 +6,18 @@ config TRACE_IRQFLAGS_SUPPORT
6 6
7source "lib/Kconfig.debug" 7source "lib/Kconfig.debug"
8 8
9config STRICT_DEVMEM
10 def_bool y
11 prompt "Filter access to /dev/mem"
12 ---help---
13 This option restricts access to /dev/mem. If this option is
14 disabled, you allow userspace access to all memory, including
15 kernel and userspace memory. Accidental memory access is likely
16 to be disastrous.
17 Memory access is required for experts who want to debug the kernel.
18
19 If you are unsure, say Y.
20
9config DEBUG_STRICT_USER_COPY_CHECKS 21config DEBUG_STRICT_USER_COPY_CHECKS
10 bool "Strict user copy size checks" 22 bool "Strict user copy size checks"
11 ---help--- 23 ---help---
diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h
index a8729ea7e9ac..3c987e9ec8d6 100644
--- a/arch/s390/include/asm/page.h
+++ b/arch/s390/include/asm/page.h
@@ -130,6 +130,11 @@ struct page;
130void arch_free_page(struct page *page, int order); 130void arch_free_page(struct page *page, int order);
131void arch_alloc_page(struct page *page, int order); 131void arch_alloc_page(struct page *page, int order);
132 132
133static inline int devmem_is_allowed(unsigned long pfn)
134{
135 return 0;
136}
137
133#define HAVE_ARCH_FREE_PAGE 138#define HAVE_ARCH_FREE_PAGE
134#define HAVE_ARCH_ALLOC_PAGE 139#define HAVE_ARCH_ALLOC_PAGE
135 140
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 1e6449c79ab6..53acaa86dd94 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -25,7 +25,6 @@
25#include <linux/resource.h> 25#include <linux/resource.h>
26#include <linux/times.h> 26#include <linux/times.h>
27#include <linux/smp.h> 27#include <linux/smp.h>
28#include <linux/smp_lock.h>
29#include <linux/sem.h> 28#include <linux/sem.h>
30#include <linux/msg.h> 29#include <linux/msg.h>
31#include <linux/shm.h> 30#include <linux/shm.h>
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index d60fc4398516..2564793ec2b6 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -30,6 +30,7 @@
30#include <asm/sections.h> 30#include <asm/sections.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/hardirq.h>
33 34
34DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 35DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
35DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 36DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
@@ -212,7 +213,7 @@ static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
212 /* Set the PER control regs, turns on single step for this address */ 213 /* Set the PER control regs, turns on single step for this address */
213 __ctl_load(kprobe_per_regs, 9, 11); 214 __ctl_load(kprobe_per_regs, 9, 11);
214 regs->psw.mask |= PSW_MASK_PER; 215 regs->psw.mask |= PSW_MASK_PER;
215 regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK); 216 regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT);
216} 217}
217 218
218static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) 219static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)
@@ -239,7 +240,7 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
239 __get_cpu_var(current_kprobe) = p; 240 __get_cpu_var(current_kprobe) = p;
240 /* Save the interrupt and per flags */ 241 /* Save the interrupt and per flags */
241 kcb->kprobe_saved_imask = regs->psw.mask & 242 kcb->kprobe_saved_imask = regs->psw.mask &
242 (PSW_MASK_PER | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK); 243 (PSW_MASK_PER | PSW_MASK_IO | PSW_MASK_EXT);
243 /* Save the control regs that govern PER */ 244 /* Save the control regs that govern PER */
244 __ctl_store(kcb->kprobe_saved_ctl, 9, 11); 245 __ctl_store(kcb->kprobe_saved_ctl, 9, 11);
245} 246}
@@ -316,8 +317,6 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
316 return 1; 317 return 1;
317 318
318ss_probe: 319ss_probe:
319 if (regs->psw.mask & (PSW_MASK_PER | PSW_MASK_IO))
320 local_irq_disable();
321 prepare_singlestep(p, regs); 320 prepare_singlestep(p, regs);
322 kcb->kprobe_status = KPROBE_HIT_SS; 321 kcb->kprobe_status = KPROBE_HIT_SS;
323 return 1; 322 return 1;
@@ -350,6 +349,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
350 struct hlist_node *node, *tmp; 349 struct hlist_node *node, *tmp;
351 unsigned long flags, orig_ret_address = 0; 350 unsigned long flags, orig_ret_address = 0;
352 unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline; 351 unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline;
352 kprobe_opcode_t *correct_ret_addr = NULL;
353 353
354 INIT_HLIST_HEAD(&empty_rp); 354 INIT_HLIST_HEAD(&empty_rp);
355 kretprobe_hash_lock(current, &head, &flags); 355 kretprobe_hash_lock(current, &head, &flags);
@@ -372,10 +372,32 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
372 /* another task is sharing our hash bucket */ 372 /* another task is sharing our hash bucket */
373 continue; 373 continue;
374 374
375 if (ri->rp && ri->rp->handler) 375 orig_ret_address = (unsigned long)ri->ret_addr;
376 ri->rp->handler(ri, regs); 376
377 if (orig_ret_address != trampoline_address)
378 /*
379 * This is the real return address. Any other
380 * instances associated with this task are for
381 * other calls deeper on the call stack
382 */
383 break;
384 }
385
386 kretprobe_assert(ri, orig_ret_address, trampoline_address);
387
388 correct_ret_addr = ri->ret_addr;
389 hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
390 if (ri->task != current)
391 /* another task is sharing our hash bucket */
392 continue;
377 393
378 orig_ret_address = (unsigned long)ri->ret_addr; 394 orig_ret_address = (unsigned long)ri->ret_addr;
395
396 if (ri->rp && ri->rp->handler) {
397 ri->ret_addr = correct_ret_addr;
398 ri->rp->handler(ri, regs);
399 }
400
379 recycle_rp_inst(ri, &empty_rp); 401 recycle_rp_inst(ri, &empty_rp);
380 402
381 if (orig_ret_address != trampoline_address) { 403 if (orig_ret_address != trampoline_address) {
@@ -387,7 +409,7 @@ static int __kprobes trampoline_probe_handler(struct kprobe *p,
387 break; 409 break;
388 } 410 }
389 } 411 }
390 kretprobe_assert(ri, orig_ret_address, trampoline_address); 412
391 regs->psw.addr = orig_ret_address | PSW_ADDR_AMODE; 413 regs->psw.addr = orig_ret_address | PSW_ADDR_AMODE;
392 414
393 reset_current_kprobe(); 415 reset_current_kprobe();
@@ -465,8 +487,6 @@ static int __kprobes post_kprobe_handler(struct pt_regs *regs)
465 goto out; 487 goto out;
466 } 488 }
467 reset_current_kprobe(); 489 reset_current_kprobe();
468 if (regs->psw.mask & (PSW_MASK_PER | PSW_MASK_IO))
469 local_irq_enable();
470out: 490out:
471 preempt_enable_no_resched(); 491 preempt_enable_no_resched();
472 492
@@ -482,7 +502,7 @@ out:
482 return 1; 502 return 1;
483} 503}
484 504
485int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) 505static int __kprobes kprobe_trap_handler(struct pt_regs *regs, int trapnr)
486{ 506{
487 struct kprobe *cur = kprobe_running(); 507 struct kprobe *cur = kprobe_running();
488 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); 508 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
@@ -508,8 +528,6 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
508 restore_previous_kprobe(kcb); 528 restore_previous_kprobe(kcb);
509 else { 529 else {
510 reset_current_kprobe(); 530 reset_current_kprobe();
511 if (regs->psw.mask & (PSW_MASK_PER | PSW_MASK_IO))
512 local_irq_enable();
513 } 531 }
514 preempt_enable_no_resched(); 532 preempt_enable_no_resched();
515 break; 533 break;
@@ -553,6 +571,18 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
553 return 0; 571 return 0;
554} 572}
555 573
574int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
575{
576 int ret;
577
578 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT))
579 local_irq_disable();
580 ret = kprobe_trap_handler(regs, trapnr);
581 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT))
582 local_irq_restore(regs->psw.mask & ~PSW_MASK_PER);
583 return ret;
584}
585
556/* 586/*
557 * Wrapper routine to for handling exceptions. 587 * Wrapper routine to for handling exceptions.
558 */ 588 */
@@ -560,8 +590,12 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
560 unsigned long val, void *data) 590 unsigned long val, void *data)
561{ 591{
562 struct die_args *args = (struct die_args *)data; 592 struct die_args *args = (struct die_args *)data;
593 struct pt_regs *regs = args->regs;
563 int ret = NOTIFY_DONE; 594 int ret = NOTIFY_DONE;
564 595
596 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT))
597 local_irq_disable();
598
565 switch (val) { 599 switch (val) {
566 case DIE_BPT: 600 case DIE_BPT:
567 if (kprobe_handler(args->regs)) 601 if (kprobe_handler(args->regs))
@@ -572,16 +606,17 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
572 ret = NOTIFY_STOP; 606 ret = NOTIFY_STOP;
573 break; 607 break;
574 case DIE_TRAP: 608 case DIE_TRAP:
575 /* kprobe_running() needs smp_processor_id() */ 609 if (!preemptible() && kprobe_running() &&
576 preempt_disable(); 610 kprobe_trap_handler(args->regs, args->trapnr))
577 if (kprobe_running() &&
578 kprobe_fault_handler(args->regs, args->trapnr))
579 ret = NOTIFY_STOP; 611 ret = NOTIFY_STOP;
580 preempt_enable();
581 break; 612 break;
582 default: 613 default:
583 break; 614 break;
584 } 615 }
616
617 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT))
618 local_irq_restore(regs->psw.mask & ~PSW_MASK_PER);
619
585 return ret; 620 return ret;
586} 621}
587 622
@@ -595,6 +630,7 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
595 630
596 /* setup return addr to the jprobe handler routine */ 631 /* setup return addr to the jprobe handler routine */
597 regs->psw.addr = (unsigned long)(jp->entry) | PSW_ADDR_AMODE; 632 regs->psw.addr = (unsigned long)(jp->entry) | PSW_ADDR_AMODE;
633 regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT);
598 634
599 /* r14 is the function return address */ 635 /* r14 is the function return address */
600 kcb->jprobe_saved_r14 = (unsigned long)regs->gprs[14]; 636 kcb->jprobe_saved_r14 = (unsigned long)regs->gprs[14];
diff --git a/arch/s390/kernel/nmi.c b/arch/s390/kernel/nmi.c
index ac151399ef34..1995c1712fc8 100644
--- a/arch/s390/kernel/nmi.c
+++ b/arch/s390/kernel/nmi.c
@@ -95,7 +95,6 @@ EXPORT_SYMBOL_GPL(s390_handle_mcck);
95static int notrace s390_revalidate_registers(struct mci *mci) 95static int notrace s390_revalidate_registers(struct mci *mci)
96{ 96{
97 int kill_task; 97 int kill_task;
98 u64 tmpclock;
99 u64 zero; 98 u64 zero;
100 void *fpt_save_area, *fpt_creg_save_area; 99 void *fpt_save_area, *fpt_creg_save_area;
101 100
@@ -214,11 +213,10 @@ static int notrace s390_revalidate_registers(struct mci *mci)
214 : "0", "cc"); 213 : "0", "cc");
215#endif 214#endif
216 /* Revalidate clock comparator register */ 215 /* Revalidate clock comparator register */
217 asm volatile( 216 if (S390_lowcore.clock_comparator == -1)
218 " stck 0(%1)\n" 217 set_clock_comparator(S390_lowcore.mcck_clock);
219 " sckc 0(%1)" 218 else
220 : "=m" (tmpclock) : "a" (&(tmpclock)) : "cc", "memory"); 219 set_clock_comparator(S390_lowcore.clock_comparator);
221
222 /* Check if old PSW is valid */ 220 /* Check if old PSW is valid */
223 if (!mci->wp) 221 if (!mci->wp)
224 /* 222 /*
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 56c8687b29b3..7eff9b7347c0 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -19,6 +19,7 @@
19#include <linux/kernel_stat.h> 19#include <linux/kernel_stat.h>
20#include <linux/rcupdate.h> 20#include <linux/rcupdate.h>
21#include <linux/posix-timers.h> 21#include <linux/posix-timers.h>
22#include <linux/cpu.h>
22 23
23#include <asm/s390_ext.h> 24#include <asm/s390_ext.h>
24#include <asm/timer.h> 25#include <asm/timer.h>
@@ -566,6 +567,23 @@ void init_cpu_vtimer(void)
566 __ctl_set_bit(0,10); 567 __ctl_set_bit(0,10);
567} 568}
568 569
570static int __cpuinit s390_nohz_notify(struct notifier_block *self,
571 unsigned long action, void *hcpu)
572{
573 struct s390_idle_data *idle;
574 long cpu = (long) hcpu;
575
576 idle = &per_cpu(s390_idle, cpu);
577 switch (action) {
578 case CPU_DYING:
579 case CPU_DYING_FROZEN:
580 idle->nohz_delay = 0;
581 default:
582 break;
583 }
584 return NOTIFY_OK;
585}
586
569void __init vtime_init(void) 587void __init vtime_init(void)
570{ 588{
571 /* request the cpu timer external interrupt */ 589 /* request the cpu timer external interrupt */
@@ -574,5 +592,6 @@ void __init vtime_init(void)
574 592
575 /* Enable cpu timer interrupts on the boot cpu. */ 593 /* Enable cpu timer interrupts on the boot cpu. */
576 init_cpu_vtimer(); 594 init_cpu_vtimer();
595 cpu_notifier(s390_nohz_notify, 0);
577} 596}
578 597
diff --git a/arch/s390/lib/delay.c b/arch/s390/lib/delay.c
index 752b362bf651..7c37ec359ec2 100644
--- a/arch/s390/lib/delay.c
+++ b/arch/s390/lib/delay.c
@@ -29,17 +29,21 @@ static void __udelay_disabled(unsigned long long usecs)
29{ 29{
30 unsigned long mask, cr0, cr0_saved; 30 unsigned long mask, cr0, cr0_saved;
31 u64 clock_saved; 31 u64 clock_saved;
32 u64 end;
32 33
34 mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT;
35 end = get_clock() + (usecs << 12);
33 clock_saved = local_tick_disable(); 36 clock_saved = local_tick_disable();
34 set_clock_comparator(get_clock() + (usecs << 12));
35 __ctl_store(cr0_saved, 0, 0); 37 __ctl_store(cr0_saved, 0, 0);
36 cr0 = (cr0_saved & 0xffff00e0) | 0x00000800; 38 cr0 = (cr0_saved & 0xffff00e0) | 0x00000800;
37 __ctl_load(cr0 , 0, 0); 39 __ctl_load(cr0 , 0, 0);
38 mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT;
39 lockdep_off(); 40 lockdep_off();
40 trace_hardirqs_on(); 41 do {
41 __load_psw_mask(mask); 42 set_clock_comparator(end);
42 local_irq_disable(); 43 trace_hardirqs_on();
44 __load_psw_mask(mask);
45 local_irq_disable();
46 } while (get_clock() < end);
43 lockdep_on(); 47 lockdep_on();
44 __ctl_load(cr0_saved, 0, 0); 48 __ctl_load(cr0_saved, 0, 0);
45 local_tick_enable(clock_saved); 49 local_tick_enable(clock_saved);
diff --git a/arch/s390/mm/gup.c b/arch/s390/mm/gup.c
index 38e641cdd977..45b405ca2567 100644
--- a/arch/s390/mm/gup.c
+++ b/arch/s390/mm/gup.c
@@ -20,18 +20,17 @@
20static inline int gup_pte_range(pmd_t *pmdp, pmd_t pmd, unsigned long addr, 20static inline int gup_pte_range(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
21 unsigned long end, int write, struct page **pages, int *nr) 21 unsigned long end, int write, struct page **pages, int *nr)
22{ 22{
23 unsigned long mask, result; 23 unsigned long mask;
24 pte_t *ptep, pte; 24 pte_t *ptep, pte;
25 struct page *page; 25 struct page *page;
26 26
27 result = write ? 0 : _PAGE_RO; 27 mask = (write ? _PAGE_RO : 0) | _PAGE_INVALID | _PAGE_SPECIAL;
28 mask = result | _PAGE_INVALID | _PAGE_SPECIAL;
29 28
30 ptep = ((pte_t *) pmd_deref(pmd)) + pte_index(addr); 29 ptep = ((pte_t *) pmd_deref(pmd)) + pte_index(addr);
31 do { 30 do {
32 pte = *ptep; 31 pte = *ptep;
33 barrier(); 32 barrier();
34 if ((pte_val(pte) & mask) != result) 33 if ((pte_val(pte) & mask) != 0)
35 return 0; 34 return 0;
36 VM_BUG_ON(!pfn_valid(pte_pfn(pte))); 35 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
37 page = pte_page(pte); 36 page = pte_page(pte);
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 7f217b3a50a8..2e9d78d21fd3 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -22,7 +22,8 @@ config SUPERH
22 select HAVE_SPARSE_IRQ 22 select HAVE_SPARSE_IRQ
23 select RTC_LIB 23 select RTC_LIB
24 select GENERIC_ATOMIC64 24 select GENERIC_ATOMIC64
25 select GENERIC_HARDIRQS_NO_DEPRECATED 25 # Support the deprecated APIs until MFD and GPIOLIB catch up.
26 select GENERIC_HARDIRQS_NO_DEPRECATED if !MFD_SUPPORT && !GPIOLIB
26 help 27 help
27 The SuperH is a RISC processor targeted for use in embedded systems 28 The SuperH is a RISC processor targeted for use in embedded systems
28 and consumer electronics; it was also used in the Sega Dreamcast 29 and consumer electronics; it was also used in the Sega Dreamcast
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 2eaeb9e59585..f48c492a68d3 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -720,32 +720,6 @@ static struct platform_device camera_devices[] = {
720}; 720};
721 721
722/* FSI */ 722/* FSI */
723/*
724 * FSI-B use external clock which came from da7210.
725 * So, we should change parent of fsi
726 */
727#define FCLKBCR 0xa415000c
728static void fsimck_init(struct clk *clk)
729{
730 u32 status = __raw_readl(clk->enable_reg);
731
732 /* use external clock */
733 status &= ~0x000000ff;
734 status |= 0x00000080;
735
736 __raw_writel(status, clk->enable_reg);
737}
738
739static struct clk_ops fsimck_clk_ops = {
740 .init = fsimck_init,
741};
742
743static struct clk fsimckb_clk = {
744 .ops = &fsimck_clk_ops,
745 .enable_reg = (void __iomem *)FCLKBCR,
746 .rate = 0, /* unknown */
747};
748
749static struct sh_fsi_platform_info fsi_info = { 723static struct sh_fsi_platform_info fsi_info = {
750 .portb_flags = SH_FSI_BRS_INV | 724 .portb_flags = SH_FSI_BRS_INV |
751 SH_FSI_OUT_SLAVE_MODE | 725 SH_FSI_OUT_SLAVE_MODE |
@@ -1264,10 +1238,10 @@ static int __init arch_setup(void)
1264 /* change parent of FSI B */ 1238 /* change parent of FSI B */
1265 clk = clk_get(NULL, "fsib_clk"); 1239 clk = clk_get(NULL, "fsib_clk");
1266 if (!IS_ERR(clk)) { 1240 if (!IS_ERR(clk)) {
1267 clk_register(&fsimckb_clk); 1241 /* 48kHz dummy clock was used to make sure 1/1 divide */
1268 clk_set_parent(clk, &fsimckb_clk); 1242 clk_set_rate(&sh7724_fsimckb_clk, 48000);
1269 clk_set_rate(clk, 11000); 1243 clk_set_parent(clk, &sh7724_fsimckb_clk);
1270 clk_set_rate(&fsimckb_clk, 11000); 1244 clk_set_rate(clk, 48000);
1271 clk_put(clk); 1245 clk_put(clk);
1272 } 1246 }
1273 1247
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index c31d228fdfc6..527a0cd956b5 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -283,31 +283,6 @@ static struct platform_device ceu1_device = {
283}; 283};
284 284
285/* FSI */ 285/* FSI */
286/*
287 * FSI-A use external clock which came from ak464x.
288 * So, we should change parent of fsi
289 */
290#define FCLKACR 0xa4150008
291static void fsimck_init(struct clk *clk)
292{
293 u32 status = __raw_readl(clk->enable_reg);
294
295 /* use external clock */
296 status &= ~0x000000ff;
297 status |= 0x00000080;
298 __raw_writel(status, clk->enable_reg);
299}
300
301static struct clk_ops fsimck_clk_ops = {
302 .init = fsimck_init,
303};
304
305static struct clk fsimcka_clk = {
306 .ops = &fsimck_clk_ops,
307 .enable_reg = (void __iomem *)FCLKACR,
308 .rate = 0, /* unknown */
309};
310
311/* change J20, J21, J22 pin to 1-2 connection to use slave mode */ 286/* change J20, J21, J22 pin to 1-2 connection to use slave mode */
312static struct sh_fsi_platform_info fsi_info = { 287static struct sh_fsi_platform_info fsi_info = {
313 .porta_flags = SH_FSI_BRS_INV | 288 .porta_flags = SH_FSI_BRS_INV |
@@ -852,37 +827,29 @@ static int __init devices_setup(void)
852 gpio_request(GPIO_FN_KEYOUT0, NULL); 827 gpio_request(GPIO_FN_KEYOUT0, NULL);
853 828
854 /* enable FSI */ 829 /* enable FSI */
855 gpio_request(GPIO_FN_FSIMCKB, NULL);
856 gpio_request(GPIO_FN_FSIMCKA, NULL); 830 gpio_request(GPIO_FN_FSIMCKA, NULL);
831 gpio_request(GPIO_FN_FSIIASD, NULL);
857 gpio_request(GPIO_FN_FSIOASD, NULL); 832 gpio_request(GPIO_FN_FSIOASD, NULL);
858 gpio_request(GPIO_FN_FSIIABCK, NULL); 833 gpio_request(GPIO_FN_FSIIABCK, NULL);
859 gpio_request(GPIO_FN_FSIIALRCK, NULL); 834 gpio_request(GPIO_FN_FSIIALRCK, NULL);
860 gpio_request(GPIO_FN_FSIOABCK, NULL); 835 gpio_request(GPIO_FN_FSIOABCK, NULL);
861 gpio_request(GPIO_FN_FSIOALRCK, NULL); 836 gpio_request(GPIO_FN_FSIOALRCK, NULL);
862 gpio_request(GPIO_FN_CLKAUDIOAO, NULL); 837 gpio_request(GPIO_FN_CLKAUDIOAO, NULL);
863 gpio_request(GPIO_FN_FSIIBSD, NULL);
864 gpio_request(GPIO_FN_FSIOBSD, NULL);
865 gpio_request(GPIO_FN_FSIIBBCK, NULL);
866 gpio_request(GPIO_FN_FSIIBLRCK, NULL);
867 gpio_request(GPIO_FN_FSIOBBCK, NULL);
868 gpio_request(GPIO_FN_FSIOBLRCK, NULL);
869 gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
870 gpio_request(GPIO_FN_FSIIASD, NULL);
871 838
872 /* set SPU2 clock to 83.4 MHz */ 839 /* set SPU2 clock to 83.4 MHz */
873 clk = clk_get(NULL, "spu_clk"); 840 clk = clk_get(NULL, "spu_clk");
874 if (clk) { 841 if (!IS_ERR(clk)) {
875 clk_set_rate(clk, clk_round_rate(clk, 83333333)); 842 clk_set_rate(clk, clk_round_rate(clk, 83333333));
876 clk_put(clk); 843 clk_put(clk);
877 } 844 }
878 845
879 /* change parent of FSI A */ 846 /* change parent of FSI A */
880 clk = clk_get(NULL, "fsia_clk"); 847 clk = clk_get(NULL, "fsia_clk");
881 if (clk) { 848 if (!IS_ERR(clk)) {
882 clk_register(&fsimcka_clk); 849 /* 48kHz dummy clock was used to make sure 1/1 divide */
883 clk_set_parent(clk, &fsimcka_clk); 850 clk_set_rate(&sh7724_fsimcka_clk, 48000);
884 clk_set_rate(clk, 11000); 851 clk_set_parent(clk, &sh7724_fsimcka_clk);
885 clk_set_rate(&fsimcka_clk, 11000); 852 clk_set_rate(clk, 48000);
886 clk_put(clk); 853 clk_put(clk);
887 } 854 }
888 855
diff --git a/arch/sh/include/asm/cacheflush.h b/arch/sh/include/asm/cacheflush.h
index 1f4e562c5e8c..82e1eabeac98 100644
--- a/arch/sh/include/asm/cacheflush.h
+++ b/arch/sh/include/asm/cacheflush.h
@@ -96,7 +96,7 @@ void kmap_coherent_init(void);
96void *kmap_coherent(struct page *page, unsigned long addr); 96void *kmap_coherent(struct page *page, unsigned long addr);
97void kunmap_coherent(void *kvaddr); 97void kunmap_coherent(void *kvaddr);
98 98
99#define PG_dcache_dirty PG_arch_1 99#define PG_dcache_clean PG_arch_1
100 100
101void cpu_cache_init(void); 101void cpu_cache_init(void);
102 102
diff --git a/arch/sh/include/asm/processor_32.h b/arch/sh/include/asm/processor_32.h
index 46d5179c9f49..e3c73cdd8c90 100644
--- a/arch/sh/include/asm/processor_32.h
+++ b/arch/sh/include/asm/processor_32.h
@@ -199,10 +199,13 @@ extern unsigned long get_wchan(struct task_struct *p);
199#define ARCH_HAS_PREFETCHW 199#define ARCH_HAS_PREFETCHW
200static inline void prefetch(void *x) 200static inline void prefetch(void *x)
201{ 201{
202 __asm__ __volatile__ ("pref @%0\n\t" : : "r" (x) : "memory"); 202 __builtin_prefetch(x, 0, 3);
203} 203}
204 204
205#define prefetchw(x) prefetch(x) 205static inline void prefetchw(void *x)
206{
207 __builtin_prefetch(x, 1, 3);
208}
206#endif 209#endif
207 210
208#endif /* __KERNEL__ */ 211#endif /* __KERNEL__ */
diff --git a/arch/sh/include/asm/unistd_32.h b/arch/sh/include/asm/unistd_32.h
index 903cd618eb74..d6741fca89a4 100644
--- a/arch/sh/include/asm/unistd_32.h
+++ b/arch/sh/include/asm/unistd_32.h
@@ -368,8 +368,9 @@
368#define __NR_sendmsg 355 368#define __NR_sendmsg 355
369#define __NR_recvmsg 356 369#define __NR_recvmsg 356
370#define __NR_recvmmsg 357 370#define __NR_recvmmsg 357
371#define __NR_accept4 358
371 372
372#define NR_syscalls 358 373#define NR_syscalls 359
373 374
374#ifdef __KERNEL__ 375#ifdef __KERNEL__
375 376
diff --git a/arch/sh/include/cpu-sh4/cpu/sh7724.h b/arch/sh/include/cpu-sh4/cpu/sh7724.h
index 4c27b68789b3..7eb435999426 100644
--- a/arch/sh/include/cpu-sh4/cpu/sh7724.h
+++ b/arch/sh/include/cpu-sh4/cpu/sh7724.h
@@ -303,4 +303,7 @@ enum {
303 SHDMA_SLAVE_SDHI1_RX, 303 SHDMA_SLAVE_SDHI1_RX,
304}; 304};
305 305
306extern struct clk sh7724_fsimcka_clk;
307extern struct clk sh7724_fsimckb_clk;
308
306#endif /* __ASM_SH7724_H__ */ 309#endif /* __ASM_SH7724_H__ */
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index 4eabc68cd753..b601fa3978d1 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -110,7 +110,7 @@ static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate)
110 return 0; 110 return 0;
111} 111}
112 112
113static int shoc_clk_set_rate(struct clk *clk, unsigned long rate, int algo_id) 113static int shoc_clk_set_rate(struct clk *clk, unsigned long rate)
114{ 114{
115 unsigned long frqcr3; 115 unsigned long frqcr3;
116 unsigned int tmp; 116 unsigned int tmp;
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index 0fe2e9329cb2..271c0b325a9a 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -111,12 +111,21 @@ static struct clk div3_clk = {
111 .parent = &pll_clk, 111 .parent = &pll_clk,
112}; 112};
113 113
114/* External input clock (pin name: FSIMCKA/FSIMCKB ) */
115struct clk sh7724_fsimcka_clk = {
116};
117
118struct clk sh7724_fsimckb_clk = {
119};
120
114static struct clk *main_clks[] = { 121static struct clk *main_clks[] = {
115 &r_clk, 122 &r_clk,
116 &extal_clk, 123 &extal_clk,
117 &fll_clk, 124 &fll_clk,
118 &pll_clk, 125 &pll_clk,
119 &div3_clk, 126 &div3_clk,
127 &sh7724_fsimcka_clk,
128 &sh7724_fsimckb_clk,
120}; 129};
121 130
122static void div4_kick(struct clk *clk) 131static void div4_kick(struct clk *clk)
@@ -154,16 +163,38 @@ struct clk div4_clks[DIV4_NR] = {
154 [DIV4_M1] = DIV4(FRQCRB, 4, 0x2f7c, CLK_ENABLE_ON_INIT), 163 [DIV4_M1] = DIV4(FRQCRB, 4, 0x2f7c, CLK_ENABLE_ON_INIT),
155}; 164};
156 165
157enum { DIV6_V, DIV6_FA, DIV6_FB, DIV6_I, DIV6_S, DIV6_NR }; 166enum { DIV6_V, DIV6_I, DIV6_S, DIV6_NR };
158 167
159static struct clk div6_clks[DIV6_NR] = { 168static struct clk div6_clks[DIV6_NR] = {
160 [DIV6_V] = SH_CLK_DIV6(&div3_clk, VCLKCR, 0), 169 [DIV6_V] = SH_CLK_DIV6(&div3_clk, VCLKCR, 0),
161 [DIV6_FA] = SH_CLK_DIV6(&div3_clk, FCLKACR, 0),
162 [DIV6_FB] = SH_CLK_DIV6(&div3_clk, FCLKBCR, 0),
163 [DIV6_I] = SH_CLK_DIV6(&div3_clk, IRDACLKCR, 0), 170 [DIV6_I] = SH_CLK_DIV6(&div3_clk, IRDACLKCR, 0),
164 [DIV6_S] = SH_CLK_DIV6(&div3_clk, SPUCLKCR, CLK_ENABLE_ON_INIT), 171 [DIV6_S] = SH_CLK_DIV6(&div3_clk, SPUCLKCR, CLK_ENABLE_ON_INIT),
165}; 172};
166 173
174enum { DIV6_FA, DIV6_FB, DIV6_REPARENT_NR };
175
176/* Indices are important - they are the actual src selecting values */
177static struct clk *fclkacr_parent[] = {
178 [0] = &div3_clk,
179 [1] = NULL,
180 [2] = &sh7724_fsimcka_clk,
181 [3] = NULL,
182};
183
184static struct clk *fclkbcr_parent[] = {
185 [0] = &div3_clk,
186 [1] = NULL,
187 [2] = &sh7724_fsimckb_clk,
188 [3] = NULL,
189};
190
191static struct clk div6_reparent_clks[DIV6_REPARENT_NR] = {
192 [DIV6_FA] = SH_CLK_DIV6_EXT(&div3_clk, FCLKACR, 0,
193 fclkacr_parent, ARRAY_SIZE(fclkacr_parent), 6, 2),
194 [DIV6_FB] = SH_CLK_DIV6_EXT(&div3_clk, FCLKBCR, 0,
195 fclkbcr_parent, ARRAY_SIZE(fclkbcr_parent), 6, 2),
196};
197
167static struct clk mstp_clks[HWBLK_NR] = { 198static struct clk mstp_clks[HWBLK_NR] = {
168 SH_HWBLK_CLK(HWBLK_TLB, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT), 199 SH_HWBLK_CLK(HWBLK_TLB, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT),
169 SH_HWBLK_CLK(HWBLK_IC, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT), 200 SH_HWBLK_CLK(HWBLK_IC, &div4_clks[DIV4_I], CLK_ENABLE_ON_INIT),
@@ -240,8 +271,8 @@ static struct clk_lookup lookups[] = {
240 271
241 /* DIV6 clocks */ 272 /* DIV6 clocks */
242 CLKDEV_CON_ID("video_clk", &div6_clks[DIV6_V]), 273 CLKDEV_CON_ID("video_clk", &div6_clks[DIV6_V]),
243 CLKDEV_CON_ID("fsia_clk", &div6_clks[DIV6_FA]), 274 CLKDEV_CON_ID("fsia_clk", &div6_reparent_clks[DIV6_FA]),
244 CLKDEV_CON_ID("fsib_clk", &div6_clks[DIV6_FB]), 275 CLKDEV_CON_ID("fsib_clk", &div6_reparent_clks[DIV6_FB]),
245 CLKDEV_CON_ID("irda_clk", &div6_clks[DIV6_I]), 276 CLKDEV_CON_ID("irda_clk", &div6_clks[DIV6_I]),
246 CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_S]), 277 CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_S]),
247 278
@@ -376,6 +407,9 @@ int __init arch_clk_init(void)
376 ret = sh_clk_div6_register(div6_clks, DIV6_NR); 407 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
377 408
378 if (!ret) 409 if (!ret)
410 ret = sh_clk_div6_reparent_register(div6_reparent_clks, DIV6_REPARENT_NR);
411
412 if (!ret)
379 ret = sh_hwblk_clk_register(mstp_clks, HWBLK_NR); 413 ret = sh_hwblk_clk_register(mstp_clks, HWBLK_NR);
380 414
381 return ret; 415 return ret;
diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c
index 81f58371613d..8c6a350df751 100644
--- a/arch/sh/kernel/sys_sh.c
+++ b/arch/sh/kernel/sys_sh.c
@@ -88,7 +88,7 @@ asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op)
88 } 88 }
89 89
90 if (op & CACHEFLUSH_I) 90 if (op & CACHEFLUSH_I)
91 flush_cache_all(); 91 flush_icache_range(addr, addr+len);
92 92
93 up_read(&current->mm->mmap_sem); 93 up_read(&current->mm->mmap_sem);
94 return 0; 94 return 0;
diff --git a/arch/sh/kernel/syscalls_32.S b/arch/sh/kernel/syscalls_32.S
index e872e81add8a..6fc347ebe59d 100644
--- a/arch/sh/kernel/syscalls_32.S
+++ b/arch/sh/kernel/syscalls_32.S
@@ -375,3 +375,4 @@ ENTRY(sys_call_table)
375 .long sys_sendmsg /* 355 */ 375 .long sys_sendmsg /* 355 */
376 .long sys_recvmsg 376 .long sys_recvmsg
377 .long sys_recvmmsg 377 .long sys_recvmmsg
378 .long sys_accept4
diff --git a/arch/sh/kernel/vsyscall/vsyscall-trapa.S b/arch/sh/kernel/vsyscall/vsyscall-trapa.S
index 3b6eb34c43fa..3e70f851cdc6 100644
--- a/arch/sh/kernel/vsyscall/vsyscall-trapa.S
+++ b/arch/sh/kernel/vsyscall/vsyscall-trapa.S
@@ -8,9 +8,9 @@ __kernel_vsyscall:
8 * fill out .eh_frame -- PFM. */ 8 * fill out .eh_frame -- PFM. */
9.LEND_vsyscall: 9.LEND_vsyscall:
10 .size __kernel_vsyscall,.-.LSTART_vsyscall 10 .size __kernel_vsyscall,.-.LSTART_vsyscall
11 .previous
12 11
13 .section .eh_frame,"a",@progbits 12 .section .eh_frame,"a",@progbits
13 .previous
14.LCIE: 14.LCIE:
15 .ualong .LCIE_end - .LCIE_start 15 .ualong .LCIE_end - .LCIE_start
16.LCIE_start: 16.LCIE_start:
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 2cfae81914aa..92eb98633ab0 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -114,7 +114,7 @@ static void sh4_flush_dcache_page(void *arg)
114 struct address_space *mapping = page_mapping(page); 114 struct address_space *mapping = page_mapping(page);
115 115
116 if (mapping && !mapping_mapped(mapping)) 116 if (mapping && !mapping_mapped(mapping))
117 set_bit(PG_dcache_dirty, &page->flags); 117 clear_bit(PG_dcache_clean, &page->flags);
118 else 118 else
119#endif 119#endif
120 flush_cache_one(CACHE_OC_ADDRESS_ARRAY | 120 flush_cache_one(CACHE_OC_ADDRESS_ARRAY |
@@ -239,7 +239,7 @@ static void sh4_flush_cache_page(void *args)
239 * another ASID than the current one. 239 * another ASID than the current one.
240 */ 240 */
241 map_coherent = (current_cpu_data.dcache.n_aliases && 241 map_coherent = (current_cpu_data.dcache.n_aliases &&
242 !test_bit(PG_dcache_dirty, &page->flags) && 242 test_bit(PG_dcache_clean, &page->flags) &&
243 page_mapped(page)); 243 page_mapped(page));
244 if (map_coherent) 244 if (map_coherent)
245 vaddr = kmap_coherent(page, address); 245 vaddr = kmap_coherent(page, address);
diff --git a/arch/sh/mm/cache-sh7705.c b/arch/sh/mm/cache-sh7705.c
index f498da1cce7a..7729cca727eb 100644
--- a/arch/sh/mm/cache-sh7705.c
+++ b/arch/sh/mm/cache-sh7705.c
@@ -139,7 +139,7 @@ static void sh7705_flush_dcache_page(void *arg)
139 struct address_space *mapping = page_mapping(page); 139 struct address_space *mapping = page_mapping(page);
140 140
141 if (mapping && !mapping_mapped(mapping)) 141 if (mapping && !mapping_mapped(mapping))
142 set_bit(PG_dcache_dirty, &page->flags); 142 clear_bit(PG_dcache_clean, &page->flags);
143 else 143 else
144 __flush_dcache_page(__pa(page_address(page))); 144 __flush_dcache_page(__pa(page_address(page)));
145} 145}
diff --git a/arch/sh/mm/cache.c b/arch/sh/mm/cache.c
index ba401d137bb9..88d3dc3d30d5 100644
--- a/arch/sh/mm/cache.c
+++ b/arch/sh/mm/cache.c
@@ -60,14 +60,14 @@ void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
60 unsigned long len) 60 unsigned long len)
61{ 61{
62 if (boot_cpu_data.dcache.n_aliases && page_mapped(page) && 62 if (boot_cpu_data.dcache.n_aliases && page_mapped(page) &&
63 !test_bit(PG_dcache_dirty, &page->flags)) { 63 test_bit(PG_dcache_clean, &page->flags)) {
64 void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); 64 void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
65 memcpy(vto, src, len); 65 memcpy(vto, src, len);
66 kunmap_coherent(vto); 66 kunmap_coherent(vto);
67 } else { 67 } else {
68 memcpy(dst, src, len); 68 memcpy(dst, src, len);
69 if (boot_cpu_data.dcache.n_aliases) 69 if (boot_cpu_data.dcache.n_aliases)
70 set_bit(PG_dcache_dirty, &page->flags); 70 clear_bit(PG_dcache_clean, &page->flags);
71 } 71 }
72 72
73 if (vma->vm_flags & VM_EXEC) 73 if (vma->vm_flags & VM_EXEC)
@@ -79,14 +79,14 @@ void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
79 unsigned long len) 79 unsigned long len)
80{ 80{
81 if (boot_cpu_data.dcache.n_aliases && page_mapped(page) && 81 if (boot_cpu_data.dcache.n_aliases && page_mapped(page) &&
82 !test_bit(PG_dcache_dirty, &page->flags)) { 82 test_bit(PG_dcache_clean, &page->flags)) {
83 void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK); 83 void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
84 memcpy(dst, vfrom, len); 84 memcpy(dst, vfrom, len);
85 kunmap_coherent(vfrom); 85 kunmap_coherent(vfrom);
86 } else { 86 } else {
87 memcpy(dst, src, len); 87 memcpy(dst, src, len);
88 if (boot_cpu_data.dcache.n_aliases) 88 if (boot_cpu_data.dcache.n_aliases)
89 set_bit(PG_dcache_dirty, &page->flags); 89 clear_bit(PG_dcache_clean, &page->flags);
90 } 90 }
91} 91}
92 92
@@ -98,7 +98,7 @@ void copy_user_highpage(struct page *to, struct page *from,
98 vto = kmap_atomic(to, KM_USER1); 98 vto = kmap_atomic(to, KM_USER1);
99 99
100 if (boot_cpu_data.dcache.n_aliases && page_mapped(from) && 100 if (boot_cpu_data.dcache.n_aliases && page_mapped(from) &&
101 !test_bit(PG_dcache_dirty, &from->flags)) { 101 test_bit(PG_dcache_clean, &from->flags)) {
102 vfrom = kmap_coherent(from, vaddr); 102 vfrom = kmap_coherent(from, vaddr);
103 copy_page(vto, vfrom); 103 copy_page(vto, vfrom);
104 kunmap_coherent(vfrom); 104 kunmap_coherent(vfrom);
@@ -141,7 +141,7 @@ void __update_cache(struct vm_area_struct *vma,
141 141
142 page = pfn_to_page(pfn); 142 page = pfn_to_page(pfn);
143 if (pfn_valid(pfn)) { 143 if (pfn_valid(pfn)) {
144 int dirty = test_and_clear_bit(PG_dcache_dirty, &page->flags); 144 int dirty = !test_and_set_bit(PG_dcache_clean, &page->flags);
145 if (dirty) 145 if (dirty)
146 __flush_purge_region(page_address(page), PAGE_SIZE); 146 __flush_purge_region(page_address(page), PAGE_SIZE);
147 } 147 }
@@ -153,7 +153,7 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr)
153 153
154 if (pages_do_alias(addr, vmaddr)) { 154 if (pages_do_alias(addr, vmaddr)) {
155 if (boot_cpu_data.dcache.n_aliases && page_mapped(page) && 155 if (boot_cpu_data.dcache.n_aliases && page_mapped(page) &&
156 !test_bit(PG_dcache_dirty, &page->flags)) { 156 test_bit(PG_dcache_clean, &page->flags)) {
157 void *kaddr; 157 void *kaddr;
158 158
159 kaddr = kmap_coherent(page, vmaddr); 159 kaddr = kmap_coherent(page, vmaddr);
diff --git a/arch/sh/mm/kmap.c b/arch/sh/mm/kmap.c
index 15d74ea42094..ec29e14ec5a8 100644
--- a/arch/sh/mm/kmap.c
+++ b/arch/sh/mm/kmap.c
@@ -34,7 +34,7 @@ void *kmap_coherent(struct page *page, unsigned long addr)
34 enum fixed_addresses idx; 34 enum fixed_addresses idx;
35 unsigned long vaddr; 35 unsigned long vaddr;
36 36
37 BUG_ON(test_bit(PG_dcache_dirty, &page->flags)); 37 BUG_ON(!test_bit(PG_dcache_clean, &page->flags));
38 38
39 pagefault_disable(); 39 pagefault_disable();
40 40
diff --git a/arch/sparc/include/asm/openprom.h b/arch/sparc/include/asm/openprom.h
index 81cd43432dc0..47eaafad15ce 100644
--- a/arch/sparc/include/asm/openprom.h
+++ b/arch/sparc/include/asm/openprom.h
@@ -39,7 +39,7 @@ struct linux_dev_v2_funcs {
39 int (*v2_dev_open)(char *devpath); 39 int (*v2_dev_open)(char *devpath);
40 void (*v2_dev_close)(int d); 40 void (*v2_dev_close)(int d);
41 int (*v2_dev_read)(int d, char *buf, int nbytes); 41 int (*v2_dev_read)(int d, char *buf, int nbytes);
42 int (*v2_dev_write)(int d, char *buf, int nbytes); 42 int (*v2_dev_write)(int d, const char *buf, int nbytes);
43 int (*v2_dev_seek)(int d, int hi, int lo); 43 int (*v2_dev_seek)(int d, int hi, int lo);
44 44
45 /* Never issued (multistage load support) */ 45 /* Never issued (multistage load support) */
diff --git a/arch/sparc/include/asm/oplib_32.h b/arch/sparc/include/asm/oplib_32.h
index 51296a6f5005..9e5c64084b86 100644
--- a/arch/sparc/include/asm/oplib_32.h
+++ b/arch/sparc/include/asm/oplib_32.h
@@ -60,25 +60,6 @@ extern char *prom_getbootargs(void);
60extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes); 60extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes);
61extern void prom_unmapio(char *virt_addr, unsigned int num_bytes); 61extern void prom_unmapio(char *virt_addr, unsigned int num_bytes);
62 62
63/* Device operations. */
64
65/* Open the device described by the passed string. Note, that the format
66 * of the string is different on V0 vs. V2->higher proms. The caller must
67 * know what he/she is doing! Returns the device descriptor, an int.
68 */
69extern int prom_devopen(char *device_string);
70
71/* Close a previously opened device described by the passed integer
72 * descriptor.
73 */
74extern int prom_devclose(int device_handle);
75
76/* Do a seek operation on the device described by the passed integer
77 * descriptor.
78 */
79extern void prom_seek(int device_handle, unsigned int seek_hival,
80 unsigned int seek_lowval);
81
82/* Miscellaneous routines, don't really fit in any category per se. */ 63/* Miscellaneous routines, don't really fit in any category per se. */
83 64
84/* Reboot the machine with the command line passed. */ 65/* Reboot the machine with the command line passed. */
@@ -121,19 +102,8 @@ extern int prom_getrev(void);
121/* Get the prom firmware revision. */ 102/* Get the prom firmware revision. */
122extern int prom_getprev(void); 103extern int prom_getprev(void);
123 104
124/* Character operations to/from the console.... */ 105/* Write a buffer of characters to the console. */
125 106extern void prom_console_write_buf(const char *buf, int len);
126/* Non-blocking get character from console. */
127extern int prom_nbgetchar(void);
128
129/* Non-blocking put character to console. */
130extern int prom_nbputchar(char character);
131
132/* Blocking get character from console. */
133extern char prom_getchar(void);
134
135/* Blocking put character to console. */
136extern void prom_putchar(char character);
137 107
138/* Prom's internal routines, don't use in kernel/boot code. */ 108/* Prom's internal routines, don't use in kernel/boot code. */
139extern void prom_printf(const char *fmt, ...); 109extern void prom_printf(const char *fmt, ...);
@@ -238,7 +208,6 @@ extern int prom_node_has_property(phandle node, char *property);
238extern int prom_setprop(phandle node, const char *prop_name, char *prop_value, 208extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,
239 int value_size); 209 int value_size);
240 210
241extern phandle prom_pathtoinode(char *path);
242extern phandle prom_inst2pkg(int); 211extern phandle prom_inst2pkg(int);
243 212
244/* Dorking with Bus ranges... */ 213/* Dorking with Bus ranges... */
diff --git a/arch/sparc/include/asm/oplib_64.h b/arch/sparc/include/asm/oplib_64.h
index c9cc078e3e31..8cd0df34e82b 100644
--- a/arch/sparc/include/asm/oplib_64.h
+++ b/arch/sparc/include/asm/oplib_64.h
@@ -67,27 +67,6 @@ extern void prom_init(void *cif_handler, void *cif_stack);
67/* Boot argument acquisition, returns the boot command line string. */ 67/* Boot argument acquisition, returns the boot command line string. */
68extern char *prom_getbootargs(void); 68extern char *prom_getbootargs(void);
69 69
70/* Device utilities. */
71
72/* Device operations. */
73
74/* Open the device described by the passed string. Note, that the format
75 * of the string is different on V0 vs. V2->higher proms. The caller must
76 * know what he/she is doing! Returns the device descriptor, an int.
77 */
78extern int prom_devopen(const char *device_string);
79
80/* Close a previously opened device described by the passed integer
81 * descriptor.
82 */
83extern int prom_devclose(int device_handle);
84
85/* Do a seek operation on the device described by the passed integer
86 * descriptor.
87 */
88extern void prom_seek(int device_handle, unsigned int seek_hival,
89 unsigned int seek_lowval);
90
91/* Miscellaneous routines, don't really fit in any category per se. */ 70/* Miscellaneous routines, don't really fit in any category per se. */
92 71
93/* Reboot the machine with the command line passed. */ 72/* Reboot the machine with the command line passed. */
@@ -109,33 +88,14 @@ extern void prom_halt(void) __attribute__ ((noreturn));
109/* Halt and power-off the machine. */ 88/* Halt and power-off the machine. */
110extern void prom_halt_power_off(void) __attribute__ ((noreturn)); 89extern void prom_halt_power_off(void) __attribute__ ((noreturn));
111 90
112/* Set the PROM 'sync' callback function to the passed function pointer.
113 * When the user gives the 'sync' command at the prom prompt while the
114 * kernel is still active, the prom will call this routine.
115 *
116 */
117typedef int (*callback_func_t)(long *cmd);
118extern void prom_setcallback(callback_func_t func_ptr);
119
120/* Acquire the IDPROM of the root node in the prom device tree. This 91/* Acquire the IDPROM of the root node in the prom device tree. This
121 * gets passed a buffer where you would like it stuffed. The return value 92 * gets passed a buffer where you would like it stuffed. The return value
122 * is the format type of this idprom or 0xff on error. 93 * is the format type of this idprom or 0xff on error.
123 */ 94 */
124extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size); 95extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
125 96
126/* Character operations to/from the console.... */ 97/* Write a buffer of characters to the console. */
127 98extern void prom_console_write_buf(const char *buf, int len);
128/* Non-blocking get character from console. */
129extern int prom_nbgetchar(void);
130
131/* Non-blocking put character to console. */
132extern int prom_nbputchar(char character);
133
134/* Blocking get character from console. */
135extern char prom_getchar(void);
136
137/* Blocking put character to console. */
138extern void prom_putchar(char character);
139 99
140/* Prom's internal routines, don't use in kernel/boot code. */ 100/* Prom's internal routines, don't use in kernel/boot code. */
141extern void prom_printf(const char *fmt, ...); 101extern void prom_printf(const char *fmt, ...);
@@ -279,9 +239,7 @@ extern phandle prom_finddevice(const char *name);
279extern int prom_setprop(phandle node, const char *prop_name, char *prop_value, 239extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,
280 int value_size); 240 int value_size);
281 241
282extern phandle prom_pathtoinode(const char *path);
283extern phandle prom_inst2pkg(int); 242extern phandle prom_inst2pkg(int);
284extern int prom_service_exists(const char *service_name);
285extern void prom_sun4v_guest_soft_state(void); 243extern void prom_sun4v_guest_soft_state(void);
286 244
287extern int prom_ihandle2path(int handle, char *buffer, int bufsize); 245extern int prom_ihandle2path(int handle, char *buffer, int bufsize);
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index 2d51527d810f..f01c42661ee5 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -114,7 +114,7 @@ void __init leon_init_timers(irq_handler_t counter_fn)
114 if (leon3_gptimer_regs && leon3_irqctrl_regs) { 114 if (leon3_gptimer_regs && leon3_irqctrl_regs) {
115 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].val, 0); 115 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].val, 0);
116 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].rld, 116 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].rld,
117 (((1000000 / 100) - 1))); 117 (((1000000 / HZ) - 1)));
118 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, 0); 118 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, 0);
119 119
120#ifdef CONFIG_SMP 120#ifdef CONFIG_SMP
@@ -128,7 +128,7 @@ void __init leon_init_timers(irq_handler_t counter_fn)
128 } 128 }
129 129
130 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].val, 0); 130 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].val, 0);
131 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].rld, (((1000000/100) - 1))); 131 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].rld, (((1000000/HZ) - 1)));
132 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0); 132 LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0);
133# endif 133# endif
134 134
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 7524689b03d2..16582d85368a 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -12,7 +12,6 @@
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/threads.h> 13#include <linux/threads.h>
14#include <linux/smp.h> 14#include <linux/smp.h>
15#include <linux/smp_lock.h>
16#include <linux/interrupt.h> 15#include <linux/interrupt.h>
17#include <linux/kernel_stat.h> 16#include <linux/kernel_stat.h>
18#include <linux/init.h> 17#include <linux/init.h>
diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c
index e6375a750d9a..6db18c6927fb 100644
--- a/arch/sparc/kernel/sys_sparc32.c
+++ b/arch/sparc/kernel/sys_sparc32.c
@@ -17,7 +17,6 @@
17#include <linux/resource.h> 17#include <linux/resource.h>
18#include <linux/times.h> 18#include <linux/times.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/smp_lock.h>
21#include <linux/sem.h> 20#include <linux/sem.h>
22#include <linux/msg.h> 21#include <linux/msg.h>
23#include <linux/shm.h> 22#include <linux/shm.h>
diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
index 675c9e11ada5..42b282fa6112 100644
--- a/arch/sparc/kernel/sys_sparc_32.c
+++ b/arch/sparc/kernel/sys_sparc_32.c
@@ -19,7 +19,6 @@
19#include <linux/mman.h> 19#include <linux/mman.h>
20#include <linux/utsname.h> 20#include <linux/utsname.h>
21#include <linux/smp.h> 21#include <linux/smp.h>
22#include <linux/smp_lock.h>
23#include <linux/ipc.h> 22#include <linux/ipc.h>
24 23
25#include <asm/uaccess.h> 24#include <asm/uaccess.h>
diff --git a/arch/sparc/kernel/unaligned_32.c b/arch/sparc/kernel/unaligned_32.c
index 12b9f352595f..4491f4cb2695 100644
--- a/arch/sparc/kernel/unaligned_32.c
+++ b/arch/sparc/kernel/unaligned_32.c
@@ -16,7 +16,6 @@
16#include <asm/system.h> 16#include <asm/system.h>
17#include <asm/uaccess.h> 17#include <asm/uaccess.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/smp_lock.h>
20#include <linux/perf_event.h> 19#include <linux/perf_event.h>
21 20
22enum direction { 21enum direction {
diff --git a/arch/sparc/kernel/windows.c b/arch/sparc/kernel/windows.c
index b351770cbdd6..3107381e576d 100644
--- a/arch/sparc/kernel/windows.c
+++ b/arch/sparc/kernel/windows.c
@@ -9,7 +9,6 @@
9#include <linux/string.h> 9#include <linux/string.h>
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/smp.h> 11#include <linux/smp.h>
12#include <linux/smp_lock.h>
13 12
14#include <asm/uaccess.h> 13#include <asm/uaccess.h>
15 14
diff --git a/arch/sparc/prom/Makefile b/arch/sparc/prom/Makefile
index 1b8c073adb44..816c0fa12dc0 100644
--- a/arch/sparc/prom/Makefile
+++ b/arch/sparc/prom/Makefile
@@ -6,7 +6,6 @@ ccflags := -Werror
6 6
7lib-y := bootstr_$(BITS).o 7lib-y := bootstr_$(BITS).o
8lib-$(CONFIG_SPARC32) += devmap.o 8lib-$(CONFIG_SPARC32) += devmap.o
9lib-y += devops_$(BITS).o
10lib-y += init_$(BITS).o 9lib-y += init_$(BITS).o
11lib-$(CONFIG_SPARC32) += memory.o 10lib-$(CONFIG_SPARC32) += memory.o
12lib-y += misc_$(BITS).o 11lib-y += misc_$(BITS).o
diff --git a/arch/sparc/prom/console_32.c b/arch/sparc/prom/console_32.c
index 5340264b78f5..48863108a44c 100644
--- a/arch/sparc/prom/console_32.c
+++ b/arch/sparc/prom/console_32.c
@@ -16,63 +16,26 @@
16 16
17extern void restore_current(void); 17extern void restore_current(void);
18 18
19/* Non blocking get character from console input device, returns -1
20 * if no input was taken. This can be used for polling.
21 */
22int
23prom_nbgetchar(void)
24{
25 static char inc;
26 int i = -1;
27 unsigned long flags;
28
29 spin_lock_irqsave(&prom_lock, flags);
30 switch(prom_vers) {
31 case PROM_V0:
32 i = (*(romvec->pv_nbgetchar))();
33 break;
34 case PROM_V2:
35 case PROM_V3:
36 if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1) {
37 i = inc;
38 } else {
39 i = -1;
40 }
41 break;
42 default:
43 i = -1;
44 break;
45 };
46 restore_current();
47 spin_unlock_irqrestore(&prom_lock, flags);
48 return i; /* Ugh, we could spin forever on unsupported proms ;( */
49}
50
51/* Non blocking put character to console device, returns -1 if 19/* Non blocking put character to console device, returns -1 if
52 * unsuccessful. 20 * unsuccessful.
53 */ 21 */
54int 22static int prom_nbputchar(const char *buf)
55prom_nbputchar(char c)
56{ 23{
57 static char outc;
58 unsigned long flags; 24 unsigned long flags;
59 int i = -1; 25 int i = -1;
60 26
61 spin_lock_irqsave(&prom_lock, flags); 27 spin_lock_irqsave(&prom_lock, flags);
62 switch(prom_vers) { 28 switch(prom_vers) {
63 case PROM_V0: 29 case PROM_V0:
64 i = (*(romvec->pv_nbputchar))(c); 30 i = (*(romvec->pv_nbputchar))(*buf);
65 break; 31 break;
66 case PROM_V2: 32 case PROM_V2:
67 case PROM_V3: 33 case PROM_V3:
68 outc = c; 34 if ((*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout,
69 if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1) 35 buf, 0x1) == 1)
70 i = 0; 36 i = 0;
71 else
72 i = -1;
73 break; 37 break;
74 default: 38 default:
75 i = -1;
76 break; 39 break;
77 }; 40 };
78 restore_current(); 41 restore_current();
@@ -80,18 +43,14 @@ prom_nbputchar(char c)
80 return i; /* Ugh, we could spin forever on unsupported proms ;( */ 43 return i; /* Ugh, we could spin forever on unsupported proms ;( */
81} 44}
82 45
83/* Blocking version of get character routine above. */ 46void prom_console_write_buf(const char *buf, int len)
84char
85prom_getchar(void)
86{ 47{
87 int character; 48 while (len) {
88 while((character = prom_nbgetchar()) == -1) ; 49 int n = prom_nbputchar(buf);
89 return (char) character; 50 if (n)
51 continue;
52 len--;
53 buf++;
54 }
90} 55}
91 56
92/* Blocking version of put character routine above. */
93void
94prom_putchar(char c)
95{
96 while(prom_nbputchar(c) == -1) ;
97}
diff --git a/arch/sparc/prom/console_64.c b/arch/sparc/prom/console_64.c
index 10322dc2f557..ed39e75828bd 100644
--- a/arch/sparc/prom/console_64.c
+++ b/arch/sparc/prom/console_64.c
@@ -15,85 +15,34 @@
15 15
16extern int prom_stdin, prom_stdout; 16extern int prom_stdin, prom_stdout;
17 17
18/* Non blocking get character from console input device, returns -1 18static int __prom_console_write_buf(const char *buf, int len)
19 * if no input was taken. This can be used for polling.
20 */
21inline int
22prom_nbgetchar(void)
23{
24 unsigned long args[7];
25 char inc;
26
27 args[0] = (unsigned long) "read";
28 args[1] = 3;
29 args[2] = 1;
30 args[3] = (unsigned int) prom_stdin;
31 args[4] = (unsigned long) &inc;
32 args[5] = 1;
33 args[6] = (unsigned long) -1;
34
35 p1275_cmd_direct(args);
36
37 if (args[6] == 1)
38 return inc;
39 return -1;
40}
41
42/* Non blocking put character to console device, returns -1 if
43 * unsuccessful.
44 */
45inline int
46prom_nbputchar(char c)
47{ 19{
48 unsigned long args[7]; 20 unsigned long args[7];
49 char outc; 21 int ret;
50
51 outc = c;
52 22
53 args[0] = (unsigned long) "write"; 23 args[0] = (unsigned long) "write";
54 args[1] = 3; 24 args[1] = 3;
55 args[2] = 1; 25 args[2] = 1;
56 args[3] = (unsigned int) prom_stdout; 26 args[3] = (unsigned int) prom_stdout;
57 args[4] = (unsigned long) &outc; 27 args[4] = (unsigned long) buf;
58 args[5] = 1; 28 args[5] = (unsigned int) len;
59 args[6] = (unsigned long) -1; 29 args[6] = (unsigned long) -1;
60 30
61 p1275_cmd_direct(args); 31 p1275_cmd_direct(args);
62 32
63 if (args[6] == 1) 33 ret = (int) args[6];
64 return 0; 34 if (ret < 0)
65 else
66 return -1; 35 return -1;
36 return ret;
67} 37}
68 38
69/* Blocking version of get character routine above. */ 39void prom_console_write_buf(const char *buf, int len)
70char
71prom_getchar(void)
72{
73 int character;
74 while((character = prom_nbgetchar()) == -1) ;
75 return (char) character;
76}
77
78/* Blocking version of put character routine above. */
79void
80prom_putchar(char c)
81{ 40{
82 prom_nbputchar(c); 41 while (len) {
83} 42 int n = __prom_console_write_buf(buf, len);
84 43 if (n < 0)
85void 44 continue;
86prom_puts(const char *s, int len) 45 len -= n;
87{ 46 buf += len;
88 unsigned long args[7]; 47 }
89
90 args[0] = (unsigned long) "write";
91 args[1] = 3;
92 args[2] = 1;
93 args[3] = (unsigned int) prom_stdout;
94 args[4] = (unsigned long) s;
95 args[5] = len;
96 args[6] = (unsigned long) -1;
97
98 p1275_cmd_direct(args);
99} 48}
diff --git a/arch/sparc/prom/devops_32.c b/arch/sparc/prom/devops_32.c
deleted file mode 100644
index 9c5d4687242a..000000000000
--- a/arch/sparc/prom/devops_32.c
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 * devops.c: Device operations using the PROM.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 */
6#include <linux/types.h>
7#include <linux/kernel.h>
8#include <linux/sched.h>
9
10#include <asm/openprom.h>
11#include <asm/oplib.h>
12
13extern void restore_current(void);
14
15/* Open the device described by the string 'dstr'. Returns the handle
16 * to that device used for subsequent operations on that device.
17 * Returns -1 on failure.
18 */
19int
20prom_devopen(char *dstr)
21{
22 int handle;
23 unsigned long flags;
24 spin_lock_irqsave(&prom_lock, flags);
25 switch(prom_vers) {
26 case PROM_V0:
27 handle = (*(romvec->pv_v0devops.v0_devopen))(dstr);
28 if(handle == 0) handle = -1;
29 break;
30 case PROM_V2:
31 case PROM_V3:
32 handle = (*(romvec->pv_v2devops.v2_dev_open))(dstr);
33 break;
34 default:
35 handle = -1;
36 break;
37 };
38 restore_current();
39 spin_unlock_irqrestore(&prom_lock, flags);
40
41 return handle;
42}
43
44/* Close the device described by device handle 'dhandle'. */
45int
46prom_devclose(int dhandle)
47{
48 unsigned long flags;
49 spin_lock_irqsave(&prom_lock, flags);
50 switch(prom_vers) {
51 case PROM_V0:
52 (*(romvec->pv_v0devops.v0_devclose))(dhandle);
53 break;
54 case PROM_V2:
55 case PROM_V3:
56 (*(romvec->pv_v2devops.v2_dev_close))(dhandle);
57 break;
58 default:
59 break;
60 };
61 restore_current();
62 spin_unlock_irqrestore(&prom_lock, flags);
63 return 0;
64}
65
66/* Seek to specified location described by 'seekhi' and 'seeklo'
67 * for device 'dhandle'.
68 */
69void
70prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
71{
72 unsigned long flags;
73 spin_lock_irqsave(&prom_lock, flags);
74 switch(prom_vers) {
75 case PROM_V0:
76 (*(romvec->pv_v0devops.v0_seekdev))(dhandle, seekhi, seeklo);
77 break;
78 case PROM_V2:
79 case PROM_V3:
80 (*(romvec->pv_v2devops.v2_dev_seek))(dhandle, seekhi, seeklo);
81 break;
82 default:
83 break;
84 };
85 restore_current();
86 spin_unlock_irqrestore(&prom_lock, flags);
87}
diff --git a/arch/sparc/prom/devops_64.c b/arch/sparc/prom/devops_64.c
deleted file mode 100644
index a017119e7ef1..000000000000
--- a/arch/sparc/prom/devops_64.c
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * devops.c: Device operations using the PROM.
3 *
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 */
7#include <linux/types.h>
8#include <linux/kernel.h>
9#include <linux/sched.h>
10
11#include <asm/openprom.h>
12#include <asm/oplib.h>
13
14/* Open the device described by the string 'dstr'. Returns the handle
15 * to that device used for subsequent operations on that device.
16 * Returns 0 on failure.
17 */
18int
19prom_devopen(const char *dstr)
20{
21 unsigned long args[5];
22
23 args[0] = (unsigned long) "open";
24 args[1] = 1;
25 args[2] = 1;
26 args[3] = (unsigned long) dstr;
27 args[4] = (unsigned long) -1;
28
29 p1275_cmd_direct(args);
30
31 return (int) args[4];
32}
33
34/* Close the device described by device handle 'dhandle'. */
35int
36prom_devclose(int dhandle)
37{
38 unsigned long args[4];
39
40 args[0] = (unsigned long) "close";
41 args[1] = 1;
42 args[2] = 0;
43 args[3] = (unsigned int) dhandle;
44
45 p1275_cmd_direct(args);
46
47 return 0;
48}
49
50/* Seek to specified location described by 'seekhi' and 'seeklo'
51 * for device 'dhandle'.
52 */
53void
54prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
55{
56 unsigned long args[7];
57
58 args[0] = (unsigned long) "seek";
59 args[1] = 3;
60 args[2] = 1;
61 args[3] = (unsigned int) dhandle;
62 args[4] = seekhi;
63 args[5] = seeklo;
64 args[6] = (unsigned long) -1;
65
66 p1275_cmd_direct(args);
67}
diff --git a/arch/sparc/prom/misc_64.c b/arch/sparc/prom/misc_64.c
index d24bc44e361e..e4f31d4d3715 100644
--- a/arch/sparc/prom/misc_64.c
+++ b/arch/sparc/prom/misc_64.c
@@ -18,7 +18,7 @@
18#include <asm/system.h> 18#include <asm/system.h>
19#include <asm/ldc.h> 19#include <asm/ldc.h>
20 20
21int prom_service_exists(const char *service_name) 21static int prom_service_exists(const char *service_name)
22{ 22{
23 unsigned long args[5]; 23 unsigned long args[5];
24 24
@@ -150,20 +150,6 @@ void prom_halt_power_off(void)
150 prom_halt(); 150 prom_halt();
151} 151}
152 152
153/* Set prom sync handler to call function 'funcp'. */
154void prom_setcallback(callback_func_t funcp)
155{
156 unsigned long args[5];
157 if (!funcp)
158 return;
159 args[0] = (unsigned long) "set-callback";
160 args[1] = 1;
161 args[2] = 1;
162 args[3] = (unsigned long) funcp;
163 args[4] = (unsigned long) -1;
164 p1275_cmd_direct(args);
165}
166
167/* Get the idprom and stuff it into buffer 'idbuf'. Returns the 153/* Get the idprom and stuff it into buffer 'idbuf'. Returns the
168 * format type. 'num_bytes' is the number of bytes that your idbuf 154 * format type. 'num_bytes' is the number of bytes that your idbuf
169 * has space for. Returns 0xff on error. 155 * has space for. Returns 0xff on error.
diff --git a/arch/sparc/prom/printf.c b/arch/sparc/prom/printf.c
index ca869266b9f3..d9682f06b3b0 100644
--- a/arch/sparc/prom/printf.c
+++ b/arch/sparc/prom/printf.c
@@ -15,22 +15,45 @@
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/compiler.h> 17#include <linux/compiler.h>
18#include <linux/spinlock.h>
18 19
19#include <asm/openprom.h> 20#include <asm/openprom.h>
20#include <asm/oplib.h> 21#include <asm/oplib.h>
21 22
23#define CONSOLE_WRITE_BUF_SIZE 1024
24
22static char ppbuf[1024]; 25static char ppbuf[1024];
26static char console_write_buf[CONSOLE_WRITE_BUF_SIZE];
27static DEFINE_RAW_SPINLOCK(console_write_lock);
23 28
24void notrace prom_write(const char *buf, unsigned int n) 29void notrace prom_write(const char *buf, unsigned int n)
25{ 30{
26 char ch; 31 unsigned int dest_len;
32 unsigned long flags;
33 char *dest;
34
35 dest = console_write_buf;
36 raw_spin_lock_irqsave(&console_write_lock, flags);
27 37
28 while (n != 0) { 38 dest_len = 0;
29 --n; 39 while (n-- != 0) {
30 if ((ch = *buf++) == '\n') 40 char ch = *buf++;
31 prom_putchar('\r'); 41 if (ch == '\n') {
32 prom_putchar(ch); 42 *dest++ = '\r';
43 dest_len++;
44 }
45 *dest++ = ch;
46 dest_len++;
47 if (dest_len >= CONSOLE_WRITE_BUF_SIZE - 1) {
48 prom_console_write_buf(console_write_buf, dest_len);
49 dest = console_write_buf;
50 dest_len = 0;
51 }
33 } 52 }
53 if (dest_len)
54 prom_console_write_buf(console_write_buf, dest_len);
55
56 raw_spin_unlock_irqrestore(&console_write_lock, flags);
34} 57}
35 58
36void notrace prom_printf(const char *fmt, ...) 59void notrace prom_printf(const char *fmt, ...)
diff --git a/arch/sparc/prom/tree_32.c b/arch/sparc/prom/tree_32.c
index 63e08e149774..535e2e69ac1d 100644
--- a/arch/sparc/prom/tree_32.c
+++ b/arch/sparc/prom/tree_32.c
@@ -342,19 +342,3 @@ phandle prom_inst2pkg(int inst)
342 if (node == -1) return 0; 342 if (node == -1) return 0;
343 return node; 343 return node;
344} 344}
345
346/* Return 'node' assigned to a particular prom 'path'
347 * FIXME: Should work for v0 as well
348 */
349phandle prom_pathtoinode(char *path)
350{
351 phandle node;
352 int inst;
353
354 inst = prom_devopen (path);
355 if (inst == -1) return 0;
356 node = prom_inst2pkg (inst);
357 prom_devclose (inst);
358 if (node == -1) return 0;
359 return node;
360}
diff --git a/arch/sparc/prom/tree_64.c b/arch/sparc/prom/tree_64.c
index 691be68932f8..d93660048376 100644
--- a/arch/sparc/prom/tree_64.c
+++ b/arch/sparc/prom/tree_64.c
@@ -374,24 +374,6 @@ inline phandle prom_inst2pkg(int inst)
374 return node; 374 return node;
375} 375}
376 376
377/* Return 'node' assigned to a particular prom 'path'
378 * FIXME: Should work for v0 as well
379 */
380phandle prom_pathtoinode(const char *path)
381{
382 phandle node;
383 int inst;
384
385 inst = prom_devopen (path);
386 if (inst == 0)
387 return 0;
388 node = prom_inst2pkg(inst);
389 prom_devclose(inst);
390 if (node == -1)
391 return 0;
392 return node;
393}
394
395int prom_ihandle2path(int handle, char *buffer, int bufsize) 377int prom_ihandle2path(int handle, char *buffer, int bufsize)
396{ 378{
397 unsigned long args[7]; 379 unsigned long args[7];
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 07ec8a865c1d..e11b5fcb70eb 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -329,6 +329,18 @@ endmenu # Tilera-specific configuration
329 329
330menu "Bus options" 330menu "Bus options"
331 331
332config PCI
333 bool "PCI support"
334 default y
335 select PCI_DOMAINS
336 ---help---
337 Enable PCI root complex support, so PCIe endpoint devices can
338 be attached to the Tile chip. Many, but not all, PCI devices
339 are supported under Tilera's root complex driver.
340
341config PCI_DOMAINS
342 bool
343
332config NO_IOMEM 344config NO_IOMEM
333 def_bool !PCI 345 def_bool !PCI
334 346
diff --git a/arch/tile/include/asm/cacheflush.h b/arch/tile/include/asm/cacheflush.h
index c5741da4eeac..14a3f8556ace 100644
--- a/arch/tile/include/asm/cacheflush.h
+++ b/arch/tile/include/asm/cacheflush.h
@@ -137,4 +137,56 @@ static inline void finv_buffer(void *buffer, size_t size)
137 mb_incoherent(); 137 mb_incoherent();
138} 138}
139 139
140/*
141 * Flush & invalidate a VA range that is homed remotely on a single core,
142 * waiting until the memory controller holds the flushed values.
143 */
144static inline void finv_buffer_remote(void *buffer, size_t size)
145{
146 char *p;
147 int i;
148
149 /*
150 * Flush and invalidate the buffer out of the local L1/L2
151 * and request the home cache to flush and invalidate as well.
152 */
153 __finv_buffer(buffer, size);
154
155 /*
156 * Wait for the home cache to acknowledge that it has processed
157 * all the flush-and-invalidate requests. This does not mean
158 * that the flushed data has reached the memory controller yet,
159 * but it does mean the home cache is processing the flushes.
160 */
161 __insn_mf();
162
163 /*
164 * Issue a load to the last cache line, which can't complete
165 * until all the previously-issued flushes to the same memory
166 * controller have also completed. If we weren't striping
167 * memory, that one load would be sufficient, but since we may
168 * be, we also need to back up to the last load issued to
169 * another memory controller, which would be the point where
170 * we crossed an 8KB boundary (the granularity of striping
171 * across memory controllers). Keep backing up and doing this
172 * until we are before the beginning of the buffer, or have
173 * hit all the controllers.
174 */
175 for (i = 0, p = (char *)buffer + size - 1;
176 i < (1 << CHIP_LOG_NUM_MSHIMS()) && p >= (char *)buffer;
177 ++i) {
178 const unsigned long STRIPE_WIDTH = 8192;
179
180 /* Force a load instruction to issue. */
181 *(volatile char *)p;
182
183 /* Jump to end of previous stripe. */
184 p -= STRIPE_WIDTH;
185 p = (char *)((unsigned long)p | (STRIPE_WIDTH - 1));
186 }
187
188 /* Wait for the loads (and thus flushes) to have completed. */
189 __insn_mf();
190}
191
140#endif /* _ASM_TILE_CACHEFLUSH_H */ 192#endif /* _ASM_TILE_CACHEFLUSH_H */
diff --git a/arch/tile/include/asm/io.h b/arch/tile/include/asm/io.h
index ee43328713ab..d3cbb9b14cbe 100644
--- a/arch/tile/include/asm/io.h
+++ b/arch/tile/include/asm/io.h
@@ -55,9 +55,6 @@ extern void iounmap(volatile void __iomem *addr);
55#define ioremap_writethrough(physaddr, size) ioremap(physaddr, size) 55#define ioremap_writethrough(physaddr, size) ioremap(physaddr, size)
56#define ioremap_fullcache(physaddr, size) ioremap(physaddr, size) 56#define ioremap_fullcache(physaddr, size) ioremap(physaddr, size)
57 57
58void __iomem *ioport_map(unsigned long port, unsigned int len);
59extern inline void ioport_unmap(void __iomem *addr) {}
60
61#define mmiowb() 58#define mmiowb()
62 59
63/* Conversion between virtual and physical mappings. */ 60/* Conversion between virtual and physical mappings. */
@@ -189,12 +186,22 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src,
189 * we never run, uses them unconditionally. 186 * we never run, uses them unconditionally.
190 */ 187 */
191 188
192static inline int ioport_panic(void) 189static inline long ioport_panic(void)
193{ 190{
194 panic("inb/outb and friends do not exist on tile"); 191 panic("inb/outb and friends do not exist on tile");
195 return 0; 192 return 0;
196} 193}
197 194
195static inline void __iomem *ioport_map(unsigned long port, unsigned int len)
196{
197 return (void __iomem *) ioport_panic();
198}
199
200static inline void ioport_unmap(void __iomem *addr)
201{
202 ioport_panic();
203}
204
198static inline u8 inb(unsigned long addr) 205static inline u8 inb(unsigned long addr)
199{ 206{
200 return ioport_panic(); 207 return ioport_panic();
diff --git a/arch/tile/include/asm/pci-bridge.h b/arch/tile/include/asm/pci-bridge.h
deleted file mode 100644
index e853b0e2793b..000000000000
--- a/arch/tile/include/asm/pci-bridge.h
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15#ifndef _ASM_TILE_PCI_BRIDGE_H
16#define _ASM_TILE_PCI_BRIDGE_H
17
18#include <linux/ioport.h>
19#include <linux/pci.h>
20
21struct device_node;
22struct pci_controller;
23
24/*
25 * pci_io_base returns the memory address at which you can access
26 * the I/O space for PCI bus number `bus' (or NULL on error).
27 */
28extern void __iomem *pci_bus_io_base(unsigned int bus);
29extern unsigned long pci_bus_io_base_phys(unsigned int bus);
30extern unsigned long pci_bus_mem_base_phys(unsigned int bus);
31
32/* Allocate a new PCI host bridge structure */
33extern struct pci_controller *pcibios_alloc_controller(void);
34
35/* Helper function for setting up resources */
36extern void pci_init_resource(struct resource *res, unsigned long start,
37 unsigned long end, int flags, char *name);
38
39/* Get the PCI host controller for a bus */
40extern struct pci_controller *pci_bus_to_hose(int bus);
41
42/*
43 * Structure of a PCI controller (host bridge)
44 */
45struct pci_controller {
46 int index; /* PCI domain number */
47 struct pci_bus *root_bus;
48
49 int first_busno;
50 int last_busno;
51
52 int hv_cfg_fd[2]; /* config{0,1} fds for this PCIe controller */
53 int hv_mem_fd; /* fd to Hypervisor for MMIO operations */
54
55 struct pci_ops *ops;
56
57 int irq_base; /* Base IRQ from the Hypervisor */
58 int plx_gen1; /* flag for PLX Gen 1 configuration */
59
60 /* Address ranges that are routed to this controller/bridge. */
61 struct resource mem_resources[3];
62};
63
64static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
65{
66 return bus->sysdata;
67}
68
69extern void setup_indirect_pci_nomap(struct pci_controller *hose,
70 void __iomem *cfg_addr, void __iomem *cfg_data);
71extern void setup_indirect_pci(struct pci_controller *hose,
72 u32 cfg_addr, u32 cfg_data);
73extern void setup_grackle(struct pci_controller *hose);
74
75extern unsigned char common_swizzle(struct pci_dev *, unsigned char *);
76
77/*
78 * The following code swizzles for exactly one bridge. The routine
79 * common_swizzle below handles multiple bridges. But there are a
80 * some boards that don't follow the PCI spec's suggestion so we
81 * break this piece out separately.
82 */
83static inline unsigned char bridge_swizzle(unsigned char pin,
84 unsigned char idsel)
85{
86 return (((pin-1) + idsel) % 4) + 1;
87}
88
89/*
90 * The following macro is used to lookup irqs in a standard table
91 * format for those PPC systems that do not already have PCI
92 * interrupts properly routed.
93 */
94/* FIXME - double check this */
95#define PCI_IRQ_TABLE_LOOKUP ({ \
96 long _ctl_ = -1; \
97 if (idsel >= min_idsel && idsel <= max_idsel && pin <= irqs_per_slot) \
98 _ctl_ = pci_irq_table[idsel - min_idsel][pin-1]; \
99 _ctl_; \
100})
101
102/*
103 * Scan the buses below a given PCI host bridge and assign suitable
104 * resources to all devices found.
105 */
106extern int pciauto_bus_scan(struct pci_controller *, int);
107
108#ifdef CONFIG_PCI
109extern unsigned long pci_address_to_pio(phys_addr_t address);
110#else
111static inline unsigned long pci_address_to_pio(phys_addr_t address)
112{
113 return (unsigned long)-1;
114}
115#endif
116
117#endif /* _ASM_TILE_PCI_BRIDGE_H */
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index b0c15da2d5d5..c3fc458a0d32 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -15,7 +15,29 @@
15#ifndef _ASM_TILE_PCI_H 15#ifndef _ASM_TILE_PCI_H
16#define _ASM_TILE_PCI_H 16#define _ASM_TILE_PCI_H
17 17
18#include <asm/pci-bridge.h> 18#include <linux/pci.h>
19
20/*
21 * Structure of a PCI controller (host bridge)
22 */
23struct pci_controller {
24 int index; /* PCI domain number */
25 struct pci_bus *root_bus;
26
27 int first_busno;
28 int last_busno;
29
30 int hv_cfg_fd[2]; /* config{0,1} fds for this PCIe controller */
31 int hv_mem_fd; /* fd to Hypervisor for MMIO operations */
32
33 struct pci_ops *ops;
34
35 int irq_base; /* Base IRQ from the Hypervisor */
36 int plx_gen1; /* flag for PLX Gen 1 configuration */
37
38 /* Address ranges that are routed to this controller/bridge. */
39 struct resource mem_resources[3];
40};
19 41
20/* 42/*
21 * The hypervisor maps the entirety of CPA-space as bus addresses, so 43 * The hypervisor maps the entirety of CPA-space as bus addresses, so
@@ -24,56 +46,12 @@
24 */ 46 */
25#define PCI_DMA_BUS_IS_PHYS 1 47#define PCI_DMA_BUS_IS_PHYS 1
26 48
27struct pci_controller *pci_bus_to_hose(int bus);
28unsigned char __init common_swizzle(struct pci_dev *dev, unsigned char *pinp);
29int __init tile_pci_init(void); 49int __init tile_pci_init(void);
30void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
31void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
32void __devinit pcibios_fixup_bus(struct pci_bus *bus);
33 50
34int __devinit _tile_cfg_read(struct pci_controller *hose, 51void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
35 int bus, 52static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
36 int slot,
37 int function,
38 int offset,
39 int size,
40 u32 *val);
41int __devinit _tile_cfg_write(struct pci_controller *hose,
42 int bus,
43 int slot,
44 int function,
45 int offset,
46 int size,
47 u32 val);
48 53
49/* 54void __devinit pcibios_fixup_bus(struct pci_bus *bus);
50 * These are used to to config reads and writes in the early stages of
51 * setup before the driver infrastructure has been set up enough to be
52 * able to do config reads and writes.
53 */
54#define early_cfg_read(where, size, value) \
55 _tile_cfg_read(controller, \
56 current_bus, \
57 pci_slot, \
58 pci_fn, \
59 where, \
60 size, \
61 value)
62
63#define early_cfg_write(where, size, value) \
64 _tile_cfg_write(controller, \
65 current_bus, \
66 pci_slot, \
67 pci_fn, \
68 where, \
69 size, \
70 value)
71
72
73
74#define PCICFG_BYTE 1
75#define PCICFG_WORD 2
76#define PCICFG_DWORD 4
77 55
78#define TILE_NUM_PCIE 2 56#define TILE_NUM_PCIE 2
79 57
@@ -88,33 +66,33 @@ static inline int pci_proc_domain(struct pci_bus *bus)
88} 66}
89 67
90/* 68/*
91 * I/O space is currently not supported. 69 * pcibios_assign_all_busses() tells whether or not the bus numbers
70 * should be reassigned, in case the BIOS didn't do it correctly, or
71 * in case we don't have a BIOS and we want to let Linux do it.
92 */ 72 */
73static inline int pcibios_assign_all_busses(void)
74{
75 return 1;
76}
93 77
94#define TILE_PCIE_LOWER_IO 0x0 78/*
95#define TILE_PCIE_UPPER_IO 0x10000 79 * No special bus mastering setup handling.
96#define TILE_PCIE_PCIE_IO_SIZE 0x0000FFFF 80 */
97
98#define _PAGE_NO_CACHE 0
99#define _PAGE_GUARDED 0
100
101
102#define pcibios_assign_all_busses() pci_assign_all_buses
103extern int pci_assign_all_buses;
104
105static inline void pcibios_set_master(struct pci_dev *dev) 81static inline void pcibios_set_master(struct pci_dev *dev)
106{ 82{
107 /* No special bus mastering setup handling */
108} 83}
109 84
110#define PCIBIOS_MIN_MEM 0 85#define PCIBIOS_MIN_MEM 0
111#define PCIBIOS_MIN_IO TILE_PCIE_LOWER_IO 86#define PCIBIOS_MIN_IO 0
112 87
113/* 88/*
114 * This flag tells if the platform is TILEmpower that needs 89 * This flag tells if the platform is TILEmpower that needs
115 * special configuration for the PLX switch chip. 90 * special configuration for the PLX switch chip.
116 */ 91 */
117extern int blade_pci; 92extern int tile_plx_gen1;
93
94/* Use any cpu for PCI. */
95#define cpumask_of_pcibus(bus) cpu_online_mask
118 96
119/* implement the pci_ DMA API in terms of the generic device dma_ one */ 97/* implement the pci_ DMA API in terms of the generic device dma_ one */
120#include <asm-generic/pci-dma-compat.h> 98#include <asm-generic/pci-dma-compat.h>
@@ -122,7 +100,4 @@ extern int blade_pci;
122/* generic pci stuff */ 100/* generic pci stuff */
123#include <asm-generic/pci.h> 101#include <asm-generic/pci.h>
124 102
125/* Use any cpu for PCI. */
126#define cpumask_of_pcibus(bus) cpu_online_mask
127
128#endif /* _ASM_TILE_PCI_H */ 103#endif /* _ASM_TILE_PCI_H */
diff --git a/arch/tile/include/asm/processor.h b/arch/tile/include/asm/processor.h
index 1747ff3946b2..a9e7c8760334 100644
--- a/arch/tile/include/asm/processor.h
+++ b/arch/tile/include/asm/processor.h
@@ -292,8 +292,18 @@ extern int kstack_hash;
292/* Are we using huge pages in the TLB for kernel data? */ 292/* Are we using huge pages in the TLB for kernel data? */
293extern int kdata_huge; 293extern int kdata_huge;
294 294
295/* Support standard Linux prefetching. */
296#define ARCH_HAS_PREFETCH
297#define prefetch(x) __builtin_prefetch(x)
295#define PREFETCH_STRIDE CHIP_L2_LINE_SIZE() 298#define PREFETCH_STRIDE CHIP_L2_LINE_SIZE()
296 299
300/* Bring a value into the L1D, faulting the TLB if necessary. */
301#ifdef __tilegx__
302#define prefetch_L1(x) __insn_prefetch_l1_fault((void *)(x))
303#else
304#define prefetch_L1(x) __insn_prefetch_L1((void *)(x))
305#endif
306
297#else /* __ASSEMBLY__ */ 307#else /* __ASSEMBLY__ */
298 308
299/* Do some slow action (e.g. read a slow SPR). */ 309/* Do some slow action (e.g. read a slow SPR). */
diff --git a/arch/tile/include/asm/signal.h b/arch/tile/include/asm/signal.h
index c1ee1d61d44c..81d92a45cd4b 100644
--- a/arch/tile/include/asm/signal.h
+++ b/arch/tile/include/asm/signal.h
@@ -25,7 +25,7 @@
25 25
26#if defined(__KERNEL__) && !defined(__ASSEMBLY__) 26#if defined(__KERNEL__) && !defined(__ASSEMBLY__)
27struct pt_regs; 27struct pt_regs;
28int restore_sigcontext(struct pt_regs *, struct sigcontext __user *, long *); 28int restore_sigcontext(struct pt_regs *, struct sigcontext __user *);
29int setup_sigcontext(struct sigcontext __user *, struct pt_regs *); 29int setup_sigcontext(struct sigcontext __user *, struct pt_regs *);
30void do_signal(struct pt_regs *regs); 30void do_signal(struct pt_regs *regs);
31#endif 31#endif
diff --git a/arch/tile/include/hv/drv_xgbe_impl.h b/arch/tile/include/hv/drv_xgbe_impl.h
new file mode 100644
index 000000000000..3a73b2b44913
--- /dev/null
+++ b/arch/tile/include/hv/drv_xgbe_impl.h
@@ -0,0 +1,300 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15/**
16 * @file drivers/xgbe/impl.h
17 * Implementation details for the NetIO library.
18 */
19
20#ifndef __DRV_XGBE_IMPL_H__
21#define __DRV_XGBE_IMPL_H__
22
23#include <hv/netio_errors.h>
24#include <hv/netio_intf.h>
25#include <hv/drv_xgbe_intf.h>
26
27
28/** How many groups we have (log2). */
29#define LOG2_NUM_GROUPS (12)
30/** How many groups we have. */
31#define NUM_GROUPS (1 << LOG2_NUM_GROUPS)
32
33/** Number of output requests we'll buffer per tile. */
34#define EPP_REQS_PER_TILE (32)
35
36/** Words used in an eDMA command without checksum acceleration. */
37#define EDMA_WDS_NO_CSUM 8
38/** Words used in an eDMA command with checksum acceleration. */
39#define EDMA_WDS_CSUM 10
40/** Total available words in the eDMA command FIFO. */
41#define EDMA_WDS_TOTAL 128
42
43
44/*
45 * FIXME: These definitions are internal and should have underscores!
46 * NOTE: The actual numeric values here are intentional and allow us to
47 * optimize the concept "if small ... else if large ... else ...", by
48 * checking for the low bit being set, and then for non-zero.
49 * These are used as array indices, so they must have the values (0, 1, 2)
50 * in some order.
51 */
52#define SIZE_SMALL (1) /**< Small packet queue. */
53#define SIZE_LARGE (2) /**< Large packet queue. */
54#define SIZE_JUMBO (0) /**< Jumbo packet queue. */
55
56/** The number of "SIZE_xxx" values. */
57#define NETIO_NUM_SIZES 3
58
59
60/*
61 * Default numbers of packets for IPP drivers. These values are chosen
62 * such that CIPP1 will not overflow its L2 cache.
63 */
64
65/** The default number of small packets. */
66#define NETIO_DEFAULT_SMALL_PACKETS 2750
67/** The default number of large packets. */
68#define NETIO_DEFAULT_LARGE_PACKETS 2500
69/** The default number of jumbo packets. */
70#define NETIO_DEFAULT_JUMBO_PACKETS 250
71
72
73/** Log2 of the size of a memory arena. */
74#define NETIO_ARENA_SHIFT 24 /* 16 MB */
75/** Size of a memory arena. */
76#define NETIO_ARENA_SIZE (1 << NETIO_ARENA_SHIFT)
77
78
79/** A queue of packets.
80 *
81 * This structure partially defines a queue of packets waiting to be
82 * processed. The queue as a whole is written to by an interrupt handler and
83 * read by non-interrupt code; this data structure is what's touched by the
84 * interrupt handler. The other part of the queue state, the read offset, is
85 * kept in user space, not in hypervisor space, so it is in a separate data
86 * structure.
87 *
88 * The read offset (__packet_receive_read in the user part of the queue
89 * structure) points to the next packet to be read. When the read offset is
90 * equal to the write offset, the queue is empty; therefore the queue must
91 * contain one more slot than the required maximum queue size.
92 *
93 * Here's an example of all 3 state variables and what they mean. All
94 * pointers move left to right.
95 *
96 * @code
97 * I I V V V V I I I I
98 * 0 1 2 3 4 5 6 7 8 9 10
99 * ^ ^ ^ ^
100 * | | |
101 * | | __last_packet_plus_one
102 * | __buffer_write
103 * __packet_receive_read
104 * @endcode
105 *
106 * This queue has 10 slots, and thus can hold 9 packets (_last_packet_plus_one
107 * = 10). The read pointer is at 2, and the write pointer is at 6; thus,
108 * there are valid, unread packets in slots 2, 3, 4, and 5. The remaining
109 * slots are invalid (do not contain a packet).
110 */
111typedef struct {
112 /** Byte offset of the next notify packet to be written: zero for the first
113 * packet on the queue, sizeof (netio_pkt_t) for the second packet on the
114 * queue, etc. */
115 volatile uint32_t __packet_write;
116
117 /** Offset of the packet after the last valid packet (i.e., when any
118 * pointer is incremented to this value, it wraps back to zero). */
119 uint32_t __last_packet_plus_one;
120}
121__netio_packet_queue_t;
122
123
124/** A queue of buffers.
125 *
126 * This structure partially defines a queue of empty buffers which have been
127 * obtained via requests to the IPP. (The elements of the queue are packet
128 * handles, which are transformed into a full netio_pkt_t when the buffer is
129 * retrieved.) The queue as a whole is written to by an interrupt handler and
130 * read by non-interrupt code; this data structure is what's touched by the
131 * interrupt handler. The other parts of the queue state, the read offset and
132 * requested write offset, are kept in user space, not in hypervisor space, so
133 * they are in a separate data structure.
134 *
135 * The read offset (__buffer_read in the user part of the queue structure)
136 * points to the next buffer to be read. When the read offset is equal to the
137 * write offset, the queue is empty; therefore the queue must contain one more
138 * slot than the required maximum queue size.
139 *
140 * The requested write offset (__buffer_requested_write in the user part of
141 * the queue structure) points to the slot which will hold the next buffer we
142 * request from the IPP, once we get around to sending such a request. When
143 * the requested write offset is equal to the write offset, no requests for
144 * new buffers are outstanding; when the requested write offset is one greater
145 * than the read offset, no more requests may be sent.
146 *
147 * Note that, unlike the packet_queue, the buffer_queue places incoming
148 * buffers at decreasing addresses. This makes the check for "is it time to
149 * wrap the buffer pointer" cheaper in the assembly code which receives new
150 * buffers, and means that the value which defines the queue size,
151 * __last_buffer, is different than in the packet queue. Also, the offset
152 * used in the packet_queue is already scaled by the size of a packet; here we
153 * use unscaled slot indices for the offsets. (These differences are
154 * historical, and in the future it's possible that the packet_queue will look
155 * more like this queue.)
156 *
157 * @code
158 * Here's an example of all 4 state variables and what they mean. Remember:
159 * all pointers move right to left.
160 *
161 * V V V I I R R V V V
162 * 0 1 2 3 4 5 6 7 8 9
163 * ^ ^ ^ ^
164 * | | | |
165 * | | | __last_buffer
166 * | | __buffer_write
167 * | __buffer_requested_write
168 * __buffer_read
169 * @endcode
170 *
171 * This queue has 10 slots, and thus can hold 9 buffers (_last_buffer = 9).
172 * The read pointer is at 2, and the write pointer is at 6; thus, there are
173 * valid, unread buffers in slots 2, 1, 0, 9, 8, and 7. The requested write
174 * pointer is at 4; thus, requests have been made to the IPP for buffers which
175 * will be placed in slots 6 and 5 when they arrive. Finally, the remaining
176 * slots are invalid (do not contain a buffer).
177 */
178typedef struct
179{
180 /** Ordinal number of the next buffer to be written: 0 for the first slot in
181 * the queue, 1 for the second slot in the queue, etc. */
182 volatile uint32_t __buffer_write;
183
184 /** Ordinal number of the last buffer (i.e., when any pointer is decremented
185 * below zero, it is reloaded with this value). */
186 uint32_t __last_buffer;
187}
188__netio_buffer_queue_t;
189
190
191/**
192 * An object for providing Ethernet packets to a process.
193 */
194typedef struct __netio_queue_impl_t
195{
196 /** The queue of packets waiting to be received. */
197 __netio_packet_queue_t __packet_receive_queue;
198 /** The intr bit mask that IDs this device. */
199 unsigned int __intr_id;
200 /** Offset to queues of empty buffers, one per size. */
201 uint32_t __buffer_queue[NETIO_NUM_SIZES];
202 /** The address of the first EPP tile, or -1 if no EPP. */
203 /* ISSUE: Actually this is always "0" or "~0". */
204 uint32_t __epp_location;
205 /** The queue ID that this queue represents. */
206 unsigned int __queue_id;
207 /** Number of acknowledgements received. */
208 volatile uint32_t __acks_received;
209 /** Last completion number received for packet_sendv. */
210 volatile uint32_t __last_completion_rcv;
211 /** Number of packets allowed to be outstanding. */
212 uint32_t __max_outstanding;
213 /** First VA available for packets. */
214 void* __va_0;
215 /** First VA in second range available for packets. */
216 void* __va_1;
217 /** Padding to align the "__packets" field to the size of a netio_pkt_t. */
218 uint32_t __padding[3];
219 /** The packets themselves. */
220 netio_pkt_t __packets[0];
221}
222netio_queue_impl_t;
223
224
225/**
226 * An object for managing the user end of a NetIO queue.
227 */
228typedef struct __netio_queue_user_impl_t
229{
230 /** The next incoming packet to be read. */
231 uint32_t __packet_receive_read;
232 /** The next empty buffers to be read, one index per size. */
233 uint8_t __buffer_read[NETIO_NUM_SIZES];
234 /** Where the empty buffer we next request from the IPP will go, one index
235 * per size. */
236 uint8_t __buffer_requested_write[NETIO_NUM_SIZES];
237 /** PCIe interface flag. */
238 uint8_t __pcie;
239 /** Number of packets left to be received before we send a credit update. */
240 uint32_t __receive_credit_remaining;
241 /** Value placed in __receive_credit_remaining when it reaches zero. */
242 uint32_t __receive_credit_interval;
243 /** First fast I/O routine index. */
244 uint32_t __fastio_index;
245 /** Number of acknowledgements expected. */
246 uint32_t __acks_outstanding;
247 /** Last completion number requested. */
248 uint32_t __last_completion_req;
249 /** File descriptor for driver. */
250 int __fd;
251}
252netio_queue_user_impl_t;
253
254
255#define NETIO_GROUP_CHUNK_SIZE 64 /**< Max # groups in one IPP request */
256#define NETIO_BUCKET_CHUNK_SIZE 64 /**< Max # buckets in one IPP request */
257
258
259/** Internal structure used to convey packet send information to the
260 * hypervisor. FIXME: Actually, it's not used for that anymore, but
261 * netio_packet_send() still uses it internally.
262 */
263typedef struct
264{
265 uint16_t flags; /**< Packet flags (__NETIO_SEND_FLG_xxx) */
266 uint16_t transfer_size; /**< Size of packet */
267 uint32_t va; /**< VA of start of packet */
268 __netio_pkt_handle_t handle; /**< Packet handle */
269 uint32_t csum0; /**< First checksum word */
270 uint32_t csum1; /**< Second checksum word */
271}
272__netio_send_cmd_t;
273
274
275/** Flags used in two contexts:
276 * - As the "flags" member in the __netio_send_cmd_t, above; used only
277 * for netio_pkt_send_{prepare,commit}.
278 * - As part of the flags passed to the various send packet fast I/O calls.
279 */
280
281/** Need acknowledgement on this packet. Note that some code in the
282 * normal send_pkt fast I/O handler assumes that this is equal to 1. */
283#define __NETIO_SEND_FLG_ACK 0x1
284
285/** Do checksum on this packet. (Only used with the __netio_send_cmd_t;
286 * normal packet sends use a special fast I/O index to denote checksumming,
287 * and multi-segment sends test the checksum descriptor.) */
288#define __NETIO_SEND_FLG_CSUM 0x2
289
290/** Get a completion on this packet. Only used with multi-segment sends. */
291#define __NETIO_SEND_FLG_COMPLETION 0x4
292
293/** Position of the number-of-extra-segments value in the flags word.
294 Only used with multi-segment sends. */
295#define __NETIO_SEND_FLG_XSEG_SHIFT 3
296
297/** Width of the number-of-extra-segments value in the flags word. */
298#define __NETIO_SEND_FLG_XSEG_WIDTH 2
299
300#endif /* __DRV_XGBE_IMPL_H__ */
diff --git a/arch/tile/include/hv/drv_xgbe_intf.h b/arch/tile/include/hv/drv_xgbe_intf.h
new file mode 100644
index 000000000000..146e47d5334b
--- /dev/null
+++ b/arch/tile/include/hv/drv_xgbe_intf.h
@@ -0,0 +1,615 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15/**
16 * @file drv_xgbe_intf.h
17 * Interface to the hypervisor XGBE driver.
18 */
19
20#ifndef __DRV_XGBE_INTF_H__
21#define __DRV_XGBE_INTF_H__
22
23/**
24 * An object for forwarding VAs and PAs to the hypervisor.
25 * @ingroup types
26 *
27 * This allows the supervisor to specify a number of areas of memory to
28 * store packet buffers.
29 */
30typedef struct
31{
32 /** The physical address of the memory. */
33 HV_PhysAddr pa;
34 /** Page table entry for the memory. This is only used to derive the
35 * memory's caching mode; the PA bits are ignored. */
36 HV_PTE pte;
37 /** The virtual address of the memory. */
38 HV_VirtAddr va;
39 /** Size (in bytes) of the memory area. */
40 int size;
41
42}
43netio_ipp_address_t;
44
45/** The various pread/pwrite offsets into the hypervisor-level driver.
46 * @ingroup types
47 */
48typedef enum
49{
50 /** Inform the Linux driver of the address of the NetIO arena memory.
51 * This offset is actually only used to convey information from netio
52 * to the Linux driver; it never makes it from there to the hypervisor.
53 * Write-only; takes a uint32_t specifying the VA address. */
54 NETIO_FIXED_ADDR = 0x5000000000000000ULL,
55
56 /** Inform the Linux driver of the size of the NetIO arena memory.
57 * This offset is actually only used to convey information from netio
58 * to the Linux driver; it never makes it from there to the hypervisor.
59 * Write-only; takes a uint32_t specifying the VA size. */
60 NETIO_FIXED_SIZE = 0x5100000000000000ULL,
61
62 /** Register current tile with IPP. Write then read: write, takes a
63 * netio_input_config_t, read returns a pointer to a netio_queue_impl_t. */
64 NETIO_IPP_INPUT_REGISTER_OFF = 0x6000000000000000ULL,
65
66 /** Unregister current tile from IPP. Write-only, takes a dummy argument. */
67 NETIO_IPP_INPUT_UNREGISTER_OFF = 0x6100000000000000ULL,
68
69 /** Start packets flowing. Write-only, takes a dummy argument. */
70 NETIO_IPP_INPUT_INIT_OFF = 0x6200000000000000ULL,
71
72 /** Stop packets flowing. Write-only, takes a dummy argument. */
73 NETIO_IPP_INPUT_UNINIT_OFF = 0x6300000000000000ULL,
74
75 /** Configure group (typically we group on VLAN). Write-only: takes an
76 * array of netio_group_t's, low 24 bits of the offset is the base group
77 * number times the size of a netio_group_t. */
78 NETIO_IPP_INPUT_GROUP_CFG_OFF = 0x6400000000000000ULL,
79
80 /** Configure bucket. Write-only: takes an array of netio_bucket_t's, low
81 * 24 bits of the offset is the base bucket number times the size of a
82 * netio_bucket_t. */
83 NETIO_IPP_INPUT_BUCKET_CFG_OFF = 0x6500000000000000ULL,
84
85 /** Get/set a parameter. Read or write: read or write data is the parameter
86 * value, low 32 bits of the offset is a __netio_getset_offset_t. */
87 NETIO_IPP_PARAM_OFF = 0x6600000000000000ULL,
88
89 /** Get fast I/O index. Read-only; returns a 4-byte base index value. */
90 NETIO_IPP_GET_FASTIO_OFF = 0x6700000000000000ULL,
91
92 /** Configure hijack IP address. Packets with this IPv4 dest address
93 * go to bucket NETIO_NUM_BUCKETS - 1. Write-only: takes an IP address
94 * in some standard form. FIXME: Define the form! */
95 NETIO_IPP_INPUT_HIJACK_CFG_OFF = 0x6800000000000000ULL,
96
97 /**
98 * Offsets beyond this point are reserved for the supervisor (although that
99 * enforcement must be done by the supervisor driver itself).
100 */
101 NETIO_IPP_USER_MAX_OFF = 0x6FFFFFFFFFFFFFFFULL,
102
103 /** Register I/O memory. Write-only, takes a netio_ipp_address_t. */
104 NETIO_IPP_IOMEM_REGISTER_OFF = 0x7000000000000000ULL,
105
106 /** Unregister I/O memory. Write-only, takes a netio_ipp_address_t. */
107 NETIO_IPP_IOMEM_UNREGISTER_OFF = 0x7100000000000000ULL,
108
109 /* Offsets greater than 0x7FFFFFFF can't be used directly from Linux
110 * userspace code due to limitations in the pread/pwrite syscalls. */
111
112 /** Drain LIPP buffers. */
113 NETIO_IPP_DRAIN_OFF = 0xFA00000000000000ULL,
114
115 /** Supply a netio_ipp_address_t to be used as shared memory for the
116 * LEPP command queue. */
117 NETIO_EPP_SHM_OFF = 0xFB00000000000000ULL,
118
119 /* 0xFC... is currently unused. */
120
121 /** Stop IPP/EPP tiles. Write-only, takes a dummy argument. */
122 NETIO_IPP_STOP_SHIM_OFF = 0xFD00000000000000ULL,
123
124 /** Start IPP/EPP tiles. Write-only, takes a dummy argument. */
125 NETIO_IPP_START_SHIM_OFF = 0xFE00000000000000ULL,
126
127 /** Supply packet arena. Write-only, takes an array of
128 * netio_ipp_address_t values. */
129 NETIO_IPP_ADDRESS_OFF = 0xFF00000000000000ULL,
130} netio_hv_offset_t;
131
132/** Extract the base offset from an offset */
133#define NETIO_BASE_OFFSET(off) ((off) & 0xFF00000000000000ULL)
134/** Extract the local offset from an offset */
135#define NETIO_LOCAL_OFFSET(off) ((off) & 0x00FFFFFFFFFFFFFFULL)
136
137
138/**
139 * Get/set offset.
140 */
141typedef union
142{
143 struct
144 {
145 uint64_t addr:48; /**< Class-specific address */
146 unsigned int class:8; /**< Class (e.g., NETIO_PARAM) */
147 unsigned int opcode:8; /**< High 8 bits of NETIO_IPP_PARAM_OFF */
148 }
149 bits; /**< Bitfields */
150 uint64_t word; /**< Aggregated value to use as the offset */
151}
152__netio_getset_offset_t;
153
154/**
155 * Fast I/O index offsets (must be contiguous).
156 */
157typedef enum
158{
159 NETIO_FASTIO_ALLOCATE = 0, /**< Get empty packet buffer */
160 NETIO_FASTIO_FREE_BUFFER = 1, /**< Give buffer back to IPP */
161 NETIO_FASTIO_RETURN_CREDITS = 2, /**< Give credits to IPP */
162 NETIO_FASTIO_SEND_PKT_NOCK = 3, /**< Send a packet, no checksum */
163 NETIO_FASTIO_SEND_PKT_CK = 4, /**< Send a packet, with checksum */
164 NETIO_FASTIO_SEND_PKT_VEC = 5, /**< Send a vector of packets */
165 NETIO_FASTIO_SENDV_PKT = 6, /**< Sendv one packet */
166 NETIO_FASTIO_NUM_INDEX = 7, /**< Total number of fast I/O indices */
167} netio_fastio_index_t;
168
169/** 3-word return type for Fast I/O call. */
170typedef struct
171{
172 int err; /**< Error code. */
173 uint32_t val0; /**< Value. Meaning depends upon the specific call. */
174 uint32_t val1; /**< Value. Meaning depends upon the specific call. */
175} netio_fastio_rv3_t;
176
177/** 0-argument fast I/O call */
178int __netio_fastio0(uint32_t fastio_index);
179/** 1-argument fast I/O call */
180int __netio_fastio1(uint32_t fastio_index, uint32_t arg0);
181/** 3-argument fast I/O call, 2-word return value */
182netio_fastio_rv3_t __netio_fastio3_rv3(uint32_t fastio_index, uint32_t arg0,
183 uint32_t arg1, uint32_t arg2);
184/** 4-argument fast I/O call */
185int __netio_fastio4(uint32_t fastio_index, uint32_t arg0, uint32_t arg1,
186 uint32_t arg2, uint32_t arg3);
187/** 6-argument fast I/O call */
188int __netio_fastio6(uint32_t fastio_index, uint32_t arg0, uint32_t arg1,
189 uint32_t arg2, uint32_t arg3, uint32_t arg4, uint32_t arg5);
190/** 9-argument fast I/O call */
191int __netio_fastio9(uint32_t fastio_index, uint32_t arg0, uint32_t arg1,
192 uint32_t arg2, uint32_t arg3, uint32_t arg4, uint32_t arg5,
193 uint32_t arg6, uint32_t arg7, uint32_t arg8);
194
195/** Allocate an empty packet.
196 * @param fastio_index Fast I/O index.
197 * @param size Size of the packet to allocate.
198 */
199#define __netio_fastio_allocate(fastio_index, size) \
200 __netio_fastio1((fastio_index) + NETIO_FASTIO_ALLOCATE, size)
201
202/** Free a buffer.
203 * @param fastio_index Fast I/O index.
204 * @param handle Handle for the packet to free.
205 */
206#define __netio_fastio_free_buffer(fastio_index, handle) \
207 __netio_fastio1((fastio_index) + NETIO_FASTIO_FREE_BUFFER, handle)
208
209/** Increment our receive credits.
210 * @param fastio_index Fast I/O index.
211 * @param credits Number of credits to add.
212 */
213#define __netio_fastio_return_credits(fastio_index, credits) \
214 __netio_fastio1((fastio_index) + NETIO_FASTIO_RETURN_CREDITS, credits)
215
216/** Send packet, no checksum.
217 * @param fastio_index Fast I/O index.
218 * @param ackflag Nonzero if we want an ack.
219 * @param size Size of the packet.
220 * @param va Virtual address of start of packet.
221 * @param handle Packet handle.
222 */
223#define __netio_fastio_send_pkt_nock(fastio_index, ackflag, size, va, handle) \
224 __netio_fastio4((fastio_index) + NETIO_FASTIO_SEND_PKT_NOCK, ackflag, \
225 size, va, handle)
226
227/** Send packet, calculate checksum.
228 * @param fastio_index Fast I/O index.
229 * @param ackflag Nonzero if we want an ack.
230 * @param size Size of the packet.
231 * @param va Virtual address of start of packet.
232 * @param handle Packet handle.
233 * @param csum0 Shim checksum header.
234 * @param csum1 Checksum seed.
235 */
236#define __netio_fastio_send_pkt_ck(fastio_index, ackflag, size, va, handle, \
237 csum0, csum1) \
238 __netio_fastio6((fastio_index) + NETIO_FASTIO_SEND_PKT_CK, ackflag, \
239 size, va, handle, csum0, csum1)
240
241
242/** Format for the "csum0" argument to the __netio_fastio_send routines
243 * and LEPP. Note that this is currently exactly identical to the
244 * ShimProtocolOffloadHeader.
245 */
246typedef union
247{
248 struct
249 {
250 unsigned int start_byte:7; /**< The first byte to be checksummed */
251 unsigned int count:14; /**< Number of bytes to be checksummed. */
252 unsigned int destination_byte:7; /**< The byte to write the checksum to. */
253 unsigned int reserved:4; /**< Reserved. */
254 } bits; /**< Decomposed method of access. */
255 unsigned int word; /**< To send out the IDN. */
256} __netio_checksum_header_t;
257
258
259/** Sendv packet with 1 or 2 segments.
260 * @param fastio_index Fast I/O index.
261 * @param flags Ack/csum/notify flags in low 3 bits; number of segments minus
262 * 1 in next 2 bits; expected checksum in high 16 bits.
263 * @param confno Confirmation number to request, if notify flag set.
264 * @param csum0 Checksum descriptor; if zero, no checksum.
265 * @param va_F Virtual address of first segment.
266 * @param va_L Virtual address of last segment, if 2 segments.
267 * @param len_F_L Length of first segment in low 16 bits; length of last
268 * segment, if 2 segments, in high 16 bits.
269 */
270#define __netio_fastio_sendv_pkt_1_2(fastio_index, flags, confno, csum0, \
271 va_F, va_L, len_F_L) \
272 __netio_fastio6((fastio_index) + NETIO_FASTIO_SENDV_PKT, flags, confno, \
273 csum0, va_F, va_L, len_F_L)
274
275/** Send packet on PCIe interface.
276 * @param fastio_index Fast I/O index.
277 * @param flags Ack/csum/notify flags in low 3 bits.
278 * @param confno Confirmation number to request, if notify flag set.
279 * @param csum0 Checksum descriptor; Hard wired 0, not needed for PCIe.
280 * @param va_F Virtual address of the packet buffer.
281 * @param va_L Virtual address of last segment, if 2 segments. Hard wired 0.
282 * @param len_F_L Length of the packet buffer in low 16 bits.
283 */
284#define __netio_fastio_send_pcie_pkt(fastio_index, flags, confno, csum0, \
285 va_F, va_L, len_F_L) \
286 __netio_fastio6((fastio_index) + PCIE_FASTIO_SENDV_PKT, flags, confno, \
287 csum0, va_F, va_L, len_F_L)
288
289/** Sendv packet with 3 or 4 segments.
290 * @param fastio_index Fast I/O index.
291 * @param flags Ack/csum/notify flags in low 3 bits; number of segments minus
292 * 1 in next 2 bits; expected checksum in high 16 bits.
293 * @param confno Confirmation number to request, if notify flag set.
294 * @param csum0 Checksum descriptor; if zero, no checksum.
295 * @param va_F Virtual address of first segment.
296 * @param va_L Virtual address of last segment (third segment if 3 segments,
297 * fourth segment if 4 segments).
298 * @param len_F_L Length of first segment in low 16 bits; length of last
299 * segment in high 16 bits.
300 * @param va_M0 Virtual address of "middle 0" segment; this segment is sent
301 * second when there are three segments, and third if there are four.
302 * @param va_M1 Virtual address of "middle 1" segment; this segment is sent
303 * second when there are four segments.
304 * @param len_M0_M1 Length of middle 0 segment in low 16 bits; length of middle
305 * 1 segment, if 4 segments, in high 16 bits.
306 */
307#define __netio_fastio_sendv_pkt_3_4(fastio_index, flags, confno, csum0, va_F, \
308 va_L, len_F_L, va_M0, va_M1, len_M0_M1) \
309 __netio_fastio9((fastio_index) + NETIO_FASTIO_SENDV_PKT, flags, confno, \
310 csum0, va_F, va_L, len_F_L, va_M0, va_M1, len_M0_M1)
311
312/** Send vector of packets.
313 * @param fastio_index Fast I/O index.
314 * @param seqno Number of packets transmitted so far on this interface;
315 * used to decide which packets should be acknowledged.
316 * @param nentries Number of entries in vector.
317 * @param va Virtual address of start of vector entry array.
318 * @return 3-word netio_fastio_rv3_t structure. The structure's err member
319 * is an error code, or zero if no error. The val0 member is the
320 * updated value of seqno; it has been incremented by 1 for each
321 * packet sent. That increment may be less than nentries if an
322 * error occured, or if some of the entries in the vector contain
323 * handles equal to NETIO_PKT_HANDLE_NONE. The val1 member is the
324 * updated value of nentries; it has been decremented by 1 for each
325 * vector entry processed. Again, that decrement may be less than
326 * nentries (leaving the returned value positive) if an error
327 * occurred.
328 */
329#define __netio_fastio_send_pkt_vec(fastio_index, seqno, nentries, va) \
330 __netio_fastio3_rv3((fastio_index) + NETIO_FASTIO_SEND_PKT_VEC, seqno, \
331 nentries, va)
332
333
334/** An egress DMA command for LEPP. */
335typedef struct
336{
337 /** Is this a TSO transfer?
338 *
339 * NOTE: This field is always 0, to distinguish it from
340 * lepp_tso_cmd_t. It must come first!
341 */
342 uint8_t tso : 1;
343
344 /** Unused padding bits. */
345 uint8_t _unused : 3;
346
347 /** Should this packet be sent directly from caches instead of DRAM,
348 * using hash-for-home to locate the packet data?
349 */
350 uint8_t hash_for_home : 1;
351
352 /** Should we compute a checksum? */
353 uint8_t compute_checksum : 1;
354
355 /** Is this the final buffer for this packet?
356 *
357 * A single packet can be split over several input buffers (a "gather"
358 * operation). This flag indicates that this is the last buffer
359 * in a packet.
360 */
361 uint8_t end_of_packet : 1;
362
363 /** Should LEPP advance 'comp_busy' when this DMA is fully finished? */
364 uint8_t send_completion : 1;
365
366 /** High bits of Client Physical Address of the start of the buffer
367 * to be egressed.
368 *
369 * NOTE: Only 6 bits are actually needed here, as CPAs are
370 * currently 38 bits. So two bits could be scavenged from this.
371 */
372 uint8_t cpa_hi;
373
374 /** The number of bytes to be egressed. */
375 uint16_t length;
376
377 /** Low 32 bits of Client Physical Address of the start of the buffer
378 * to be egressed.
379 */
380 uint32_t cpa_lo;
381
382 /** Checksum information (only used if 'compute_checksum'). */
383 __netio_checksum_header_t checksum_data;
384
385} lepp_cmd_t;
386
387
388/** A chunk of physical memory for a TSO egress. */
389typedef struct
390{
391 /** The low bits of the CPA. */
392 uint32_t cpa_lo;
393 /** The high bits of the CPA. */
394 uint16_t cpa_hi : 15;
395 /** Should this packet be sent directly from caches instead of DRAM,
396 * using hash-for-home to locate the packet data?
397 */
398 uint16_t hash_for_home : 1;
399 /** The length in bytes. */
400 uint16_t length;
401} lepp_frag_t;
402
403
404/** An LEPP command that handles TSO. */
405typedef struct
406{
407 /** Is this a TSO transfer?
408 *
409 * NOTE: This field is always 1, to distinguish it from
410 * lepp_cmd_t. It must come first!
411 */
412 uint8_t tso : 1;
413
414 /** Unused padding bits. */
415 uint8_t _unused : 7;
416
417 /** Size of the header[] array in bytes. It must be in the range
418 * [40, 127], which are the smallest header for a TCP packet over
419 * Ethernet and the maximum possible prepend size supported by
420 * hardware, respectively. Note that the array storage must be
421 * padded out to a multiple of four bytes so that the following
422 * LEPP command is aligned properly.
423 */
424 uint8_t header_size;
425
426 /** Byte offset of the IP header in header[]. */
427 uint8_t ip_offset;
428
429 /** Byte offset of the TCP header in header[]. */
430 uint8_t tcp_offset;
431
432 /** The number of bytes to use for the payload of each packet,
433 * except of course the last one, which may not have enough bytes.
434 * This means that each Ethernet packet except the last will have a
435 * size of header_size + payload_size.
436 */
437 uint16_t payload_size;
438
439 /** The length of the 'frags' array that follows this struct. */
440 uint16_t num_frags;
441
442 /** The actual frags. */
443 lepp_frag_t frags[0 /* Variable-sized; num_frags entries. */];
444
445 /*
446 * The packet header template logically follows frags[],
447 * but you can't declare that in C.
448 *
449 * uint32_t header[header_size_in_words_rounded_up];
450 */
451
452} lepp_tso_cmd_t;
453
454
455/** An LEPP completion ring entry. */
456typedef void* lepp_comp_t;
457
458
459/** Maximum number of frags for one TSO command. This is adapted from
460 * linux's "MAX_SKB_FRAGS", and presumably over-estimates by one, for
461 * our page size of exactly 65536. We add one for a "body" fragment.
462 */
463#define LEPP_MAX_FRAGS (65536 / HV_PAGE_SIZE_SMALL + 2 + 1)
464
465/** Total number of bytes needed for an lepp_tso_cmd_t. */
466#define LEPP_TSO_CMD_SIZE(num_frags, header_size) \
467 (sizeof(lepp_tso_cmd_t) + \
468 (num_frags) * sizeof(lepp_frag_t) + \
469 (((header_size) + 3) & -4))
470
471/** The size of the lepp "cmd" queue. */
472#define LEPP_CMD_QUEUE_BYTES \
473 (((CHIP_L2_CACHE_SIZE() - 2 * CHIP_L2_LINE_SIZE()) / \
474 (sizeof(lepp_cmd_t) + sizeof(lepp_comp_t))) * sizeof(lepp_cmd_t))
475
476/** The largest possible command that can go in lepp_queue_t::cmds[]. */
477#define LEPP_MAX_CMD_SIZE LEPP_TSO_CMD_SIZE(LEPP_MAX_FRAGS, 128)
478
479/** The largest possible value of lepp_queue_t::cmd_{head, tail} (inclusive).
480 */
481#define LEPP_CMD_LIMIT \
482 (LEPP_CMD_QUEUE_BYTES - LEPP_MAX_CMD_SIZE)
483
484/** The maximum number of completions in an LEPP queue. */
485#define LEPP_COMP_QUEUE_SIZE \
486 ((LEPP_CMD_LIMIT + sizeof(lepp_cmd_t) - 1) / sizeof(lepp_cmd_t))
487
488/** Increment an index modulo the queue size. */
489#define LEPP_QINC(var) \
490 (var = __insn_mnz(var - (LEPP_COMP_QUEUE_SIZE - 1), var + 1))
491
492/** A queue used to convey egress commands from the client to LEPP. */
493typedef struct
494{
495 /** Index of first completion not yet processed by user code.
496 * If this is equal to comp_busy, there are no such completions.
497 *
498 * NOTE: This is only read/written by the user.
499 */
500 unsigned int comp_head;
501
502 /** Index of first completion record not yet completed.
503 * If this is equal to comp_tail, there are no such completions.
504 * This index gets advanced (modulo LEPP_QUEUE_SIZE) whenever
505 * a command with the 'completion' bit set is finished.
506 *
507 * NOTE: This is only written by LEPP, only read by the user.
508 */
509 volatile unsigned int comp_busy;
510
511 /** Index of the first empty slot in the completion ring.
512 * Entries from this up to but not including comp_head (in ring order)
513 * can be filled in with completion data.
514 *
515 * NOTE: This is only read/written by the user.
516 */
517 unsigned int comp_tail;
518
519 /** Byte index of first command enqueued for LEPP but not yet processed.
520 *
521 * This is always divisible by sizeof(void*) and always <= LEPP_CMD_LIMIT.
522 *
523 * NOTE: LEPP advances this counter as soon as it no longer needs
524 * the cmds[] storage for this entry, but the transfer is not actually
525 * complete (i.e. the buffer pointed to by the command is no longer
526 * needed) until comp_busy advances.
527 *
528 * If this is equal to cmd_tail, the ring is empty.
529 *
530 * NOTE: This is only written by LEPP, only read by the user.
531 */
532 volatile unsigned int cmd_head;
533
534 /** Byte index of first empty slot in the command ring. This field can
535 * be incremented up to but not equal to cmd_head (because that would
536 * mean the ring is empty).
537 *
538 * This is always divisible by sizeof(void*) and always <= LEPP_CMD_LIMIT.
539 *
540 * NOTE: This is read/written by the user, only read by LEPP.
541 */
542 volatile unsigned int cmd_tail;
543
544 /** A ring of variable-sized egress DMA commands.
545 *
546 * NOTE: Only written by the user, only read by LEPP.
547 */
548 char cmds[LEPP_CMD_QUEUE_BYTES]
549 __attribute__((aligned(CHIP_L2_LINE_SIZE())));
550
551 /** A ring of user completion data.
552 * NOTE: Only read/written by the user.
553 */
554 lepp_comp_t comps[LEPP_COMP_QUEUE_SIZE]
555 __attribute__((aligned(CHIP_L2_LINE_SIZE())));
556} lepp_queue_t;
557
558
559/** An internal helper function for determining the number of entries
560 * available in a ring buffer, given that there is one sentinel.
561 */
562static inline unsigned int
563_lepp_num_free_slots(unsigned int head, unsigned int tail)
564{
565 /*
566 * One entry is reserved for use as a sentinel, to distinguish
567 * "empty" from "full". So we compute
568 * (head - tail - 1) % LEPP_QUEUE_SIZE, but without using a slow % operation.
569 */
570 return (head - tail - 1) + ((head <= tail) ? LEPP_COMP_QUEUE_SIZE : 0);
571}
572
573
574/** Returns how many new comp entries can be enqueued. */
575static inline unsigned int
576lepp_num_free_comp_slots(const lepp_queue_t* q)
577{
578 return _lepp_num_free_slots(q->comp_head, q->comp_tail);
579}
580
581static inline int
582lepp_qsub(int v1, int v2)
583{
584 int delta = v1 - v2;
585 return delta + ((delta >> 31) & LEPP_COMP_QUEUE_SIZE);
586}
587
588
589/** FIXME: Check this from linux, via a new "pwrite()" call. */
590#define LIPP_VERSION 1
591
592
593/** We use exactly two bytes of alignment padding. */
594#define LIPP_PACKET_PADDING 2
595
596/** The minimum size of a "small" buffer (including the padding). */
597#define LIPP_SMALL_PACKET_SIZE 128
598
599/*
600 * NOTE: The following two values should total to less than around
601 * 13582, to keep the total size used for "lipp_state_t" below 64K.
602 */
603
604/** The maximum number of "small" buffers.
605 * This is enough for 53 network cpus with 128 credits. Note that
606 * if these are exhausted, we will fall back to using large buffers.
607 */
608#define LIPP_SMALL_BUFFERS 6785
609
610/** The maximum number of "large" buffers.
611 * This is enough for 53 network cpus with 128 credits.
612 */
613#define LIPP_LARGE_BUFFERS 6785
614
615#endif /* __DRV_XGBE_INTF_H__ */
diff --git a/arch/tile/include/hv/netio_errors.h b/arch/tile/include/hv/netio_errors.h
new file mode 100644
index 000000000000..e1591bff61b5
--- /dev/null
+++ b/arch/tile/include/hv/netio_errors.h
@@ -0,0 +1,122 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15/**
16 * Error codes returned from NetIO routines.
17 */
18
19#ifndef __NETIO_ERRORS_H__
20#define __NETIO_ERRORS_H__
21
22/**
23 * @addtogroup error
24 *
25 * @brief The error codes returned by NetIO functions.
26 *
27 * NetIO functions return 0 (defined as ::NETIO_NO_ERROR) on success, and
28 * a negative value if an error occurs.
29 *
30 * In cases where a NetIO function failed due to a error reported by
31 * system libraries, the error code will be the negation of the
32 * system errno at the time of failure. The @ref netio_strerror()
33 * function will deliver error strings for both NetIO and system error
34 * codes.
35 *
36 * @{
37 */
38
39/** The set of all NetIO errors. */
40typedef enum
41{
42 /** Operation successfully completed. */
43 NETIO_NO_ERROR = 0,
44
45 /** A packet was successfully retrieved from an input queue. */
46 NETIO_PKT = 0,
47
48 /** Largest NetIO error number. */
49 NETIO_ERR_MAX = -701,
50
51 /** The tile is not registered with the IPP. */
52 NETIO_NOT_REGISTERED = -701,
53
54 /** No packet was available to retrieve from the input queue. */
55 NETIO_NOPKT = -702,
56
57 /** The requested function is not implemented. */
58 NETIO_NOT_IMPLEMENTED = -703,
59
60 /** On a registration operation, the target queue already has the maximum
61 * number of tiles registered for it, and no more may be added. On a
62 * packet send operation, the output queue is full and nothing more can
63 * be queued until some of the queued packets are actually transmitted. */
64 NETIO_QUEUE_FULL = -704,
65
66 /** The calling process or thread is not bound to exactly one CPU. */
67 NETIO_BAD_AFFINITY = -705,
68
69 /** Cannot allocate memory on requested controllers. */
70 NETIO_CANNOT_HOME = -706,
71
72 /** On a registration operation, the IPP specified is not configured
73 * to support the options requested; for instance, the application
74 * wants a specific type of tagged headers which the configured IPP
75 * doesn't support. Or, the supplied configuration information is
76 * not self-consistent, or is out of range; for instance, specifying
77 * both NETIO_RECV and NETIO_NO_RECV, or asking for more than
78 * NETIO_MAX_SEND_BUFFERS to be preallocated. On a VLAN or bucket
79 * configure operation, the number of items, or the base item, was
80 * out of range.
81 */
82 NETIO_BAD_CONFIG = -707,
83
84 /** Too many tiles have registered to transmit packets. */
85 NETIO_TOOMANY_XMIT = -708,
86
87 /** Packet transmission was attempted on a queue which was registered
88 with transmit disabled. */
89 NETIO_UNREG_XMIT = -709,
90
91 /** This tile is already registered with the IPP. */
92 NETIO_ALREADY_REGISTERED = -710,
93
94 /** The Ethernet link is down. The application should try again later. */
95 NETIO_LINK_DOWN = -711,
96
97 /** An invalid memory buffer has been specified. This may be an unmapped
98 * virtual address, or one which does not meet alignment requirements.
99 * For netio_input_register(), this error may be returned when multiple
100 * processes specify different memory regions to be used for NetIO
101 * buffers. That can happen if these processes specify explicit memory
102 * regions with the ::NETIO_FIXED_BUFFER_VA flag, or if tmc_cmem_init()
103 * has not been called by a common ancestor of the processes.
104 */
105 NETIO_FAULT = -712,
106
107 /** Cannot combine user-managed shared memory and cache coherence. */
108 NETIO_BAD_CACHE_CONFIG = -713,
109
110 /** Smallest NetIO error number. */
111 NETIO_ERR_MIN = -713,
112
113#ifndef __DOXYGEN__
114 /** Used internally to mean that no response is needed; never returned to
115 * an application. */
116 NETIO_NO_RESPONSE = 1
117#endif
118} netio_error_t;
119
120/** @} */
121
122#endif /* __NETIO_ERRORS_H__ */
diff --git a/arch/tile/include/hv/netio_intf.h b/arch/tile/include/hv/netio_intf.h
new file mode 100644
index 000000000000..8d20972aba2c
--- /dev/null
+++ b/arch/tile/include/hv/netio_intf.h
@@ -0,0 +1,2975 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15/**
16 * NetIO interface structures and macros.
17 */
18
19#ifndef __NETIO_INTF_H__
20#define __NETIO_INTF_H__
21
22#include <hv/netio_errors.h>
23
24#ifdef __KERNEL__
25#include <linux/types.h>
26#else
27#include <stdint.h>
28#endif
29
30#if !defined(__HV__) && !defined(__BOGUX__) && !defined(__KERNEL__)
31#include <assert.h>
32#define netio_assert assert /**< Enable assertions from macros */
33#else
34#define netio_assert(...) ((void)(0)) /**< Disable assertions from macros */
35#endif
36
37/*
38 * If none of these symbols are defined, we're building libnetio in an
39 * environment where we have pthreads, so we'll enable locking.
40 */
41#if !defined(__HV__) && !defined(__BOGUX__) && !defined(__KERNEL__) && \
42 !defined(__NEWLIB__)
43#define _NETIO_PTHREAD /**< Include a mutex in netio_queue_t below */
44
45/*
46 * If NETIO_UNLOCKED is defined, we don't do use per-cpu locks on
47 * per-packet NetIO operations. We still do pthread locking on things
48 * like netio_input_register, though. This is used for building
49 * libnetio_unlocked.
50 */
51#ifndef NETIO_UNLOCKED
52
53/* Avoid PLT overhead by using our own inlined per-cpu lock. */
54#include <sched.h>
55typedef int _netio_percpu_mutex_t;
56
57static __inline int
58_netio_percpu_mutex_init(_netio_percpu_mutex_t* lock)
59{
60 *lock = 0;
61 return 0;
62}
63
64static __inline int
65_netio_percpu_mutex_lock(_netio_percpu_mutex_t* lock)
66{
67 while (__builtin_expect(__insn_tns(lock), 0))
68 sched_yield();
69 return 0;
70}
71
72static __inline int
73_netio_percpu_mutex_unlock(_netio_percpu_mutex_t* lock)
74{
75 *lock = 0;
76 return 0;
77}
78
79#else /* NETIO_UNLOCKED */
80
81/* Don't do any locking for per-packet NetIO operations. */
82typedef int _netio_percpu_mutex_t;
83#define _netio_percpu_mutex_init(L)
84#define _netio_percpu_mutex_lock(L)
85#define _netio_percpu_mutex_unlock(L)
86
87#endif /* NETIO_UNLOCKED */
88#endif /* !__HV__, !__BOGUX, !__KERNEL__, !__NEWLIB__ */
89
90/** How many tiles can register for a given queue.
91 * @ingroup setup */
92#define NETIO_MAX_TILES_PER_QUEUE 64
93
94
95/** Largest permissible queue identifier.
96 * @ingroup setup */
97#define NETIO_MAX_QUEUE_ID 255
98
99
100#ifndef __DOXYGEN__
101
102/* Metadata packet checksum/ethertype flags. */
103
104/** The L4 checksum has not been calculated. */
105#define _NETIO_PKT_NO_L4_CSUM_SHIFT 0
106#define _NETIO_PKT_NO_L4_CSUM_RMASK 1
107#define _NETIO_PKT_NO_L4_CSUM_MASK \
108 (_NETIO_PKT_NO_L4_CSUM_RMASK << _NETIO_PKT_NO_L4_CSUM_SHIFT)
109
110/** The L3 checksum has not been calculated. */
111#define _NETIO_PKT_NO_L3_CSUM_SHIFT 1
112#define _NETIO_PKT_NO_L3_CSUM_RMASK 1
113#define _NETIO_PKT_NO_L3_CSUM_MASK \
114 (_NETIO_PKT_NO_L3_CSUM_RMASK << _NETIO_PKT_NO_L3_CSUM_SHIFT)
115
116/** The L3 checksum is incorrect (or perhaps has not been calculated). */
117#define _NETIO_PKT_BAD_L3_CSUM_SHIFT 2
118#define _NETIO_PKT_BAD_L3_CSUM_RMASK 1
119#define _NETIO_PKT_BAD_L3_CSUM_MASK \
120 (_NETIO_PKT_BAD_L3_CSUM_RMASK << _NETIO_PKT_BAD_L3_CSUM_SHIFT)
121
122/** The Ethernet packet type is unrecognized. */
123#define _NETIO_PKT_TYPE_UNRECOGNIZED_SHIFT 3
124#define _NETIO_PKT_TYPE_UNRECOGNIZED_RMASK 1
125#define _NETIO_PKT_TYPE_UNRECOGNIZED_MASK \
126 (_NETIO_PKT_TYPE_UNRECOGNIZED_RMASK << \
127 _NETIO_PKT_TYPE_UNRECOGNIZED_SHIFT)
128
129/* Metadata packet type flags. */
130
131/** Where the packet type bits are; this field is the index into
132 * _netio_pkt_info. */
133#define _NETIO_PKT_TYPE_SHIFT 4
134#define _NETIO_PKT_TYPE_RMASK 0x3F
135
136/** How many VLAN tags the packet has, and, if we have two, which one we
137 * actually grouped on. A VLAN within a proprietary (Marvell or Broadcom)
138 * tag is counted here. */
139#define _NETIO_PKT_VLAN_SHIFT 4
140#define _NETIO_PKT_VLAN_RMASK 0x3
141#define _NETIO_PKT_VLAN_MASK \
142 (_NETIO_PKT_VLAN_RMASK << _NETIO_PKT_VLAN_SHIFT)
143#define _NETIO_PKT_VLAN_NONE 0 /* No VLAN tag. */
144#define _NETIO_PKT_VLAN_ONE 1 /* One VLAN tag. */
145#define _NETIO_PKT_VLAN_TWO_OUTER 2 /* Two VLAN tags, outer one used. */
146#define _NETIO_PKT_VLAN_TWO_INNER 3 /* Two VLAN tags, inner one used. */
147
148/** Which proprietary tags the packet has. */
149#define _NETIO_PKT_TAG_SHIFT 6
150#define _NETIO_PKT_TAG_RMASK 0x3
151#define _NETIO_PKT_TAG_MASK \
152 (_NETIO_PKT_TAG_RMASK << _NETIO_PKT_TAG_SHIFT)
153#define _NETIO_PKT_TAG_NONE 0 /* No proprietary tags. */
154#define _NETIO_PKT_TAG_MRVL 1 /* Marvell HyperG.Stack tags. */
155#define _NETIO_PKT_TAG_MRVL_EXT 2 /* HyperG.Stack extended tags. */
156#define _NETIO_PKT_TAG_BRCM 3 /* Broadcom HiGig tags. */
157
158/** Whether a packet has an LLC + SNAP header. */
159#define _NETIO_PKT_SNAP_SHIFT 8
160#define _NETIO_PKT_SNAP_RMASK 0x1
161#define _NETIO_PKT_SNAP_MASK \
162 (_NETIO_PKT_SNAP_RMASK << _NETIO_PKT_SNAP_SHIFT)
163
164/* NOTE: Bits 9 and 10 are unused. */
165
166/** Length of any custom data before the L2 header, in words. */
167#define _NETIO_PKT_CUSTOM_LEN_SHIFT 11
168#define _NETIO_PKT_CUSTOM_LEN_RMASK 0x1F
169#define _NETIO_PKT_CUSTOM_LEN_MASK \
170 (_NETIO_PKT_CUSTOM_LEN_RMASK << _NETIO_PKT_CUSTOM_LEN_SHIFT)
171
172/** The L4 checksum is incorrect (or perhaps has not been calculated). */
173#define _NETIO_PKT_BAD_L4_CSUM_SHIFT 16
174#define _NETIO_PKT_BAD_L4_CSUM_RMASK 0x1
175#define _NETIO_PKT_BAD_L4_CSUM_MASK \
176 (_NETIO_PKT_BAD_L4_CSUM_RMASK << _NETIO_PKT_BAD_L4_CSUM_SHIFT)
177
178/** Length of the L2 header, in words. */
179#define _NETIO_PKT_L2_LEN_SHIFT 17
180#define _NETIO_PKT_L2_LEN_RMASK 0x1F
181#define _NETIO_PKT_L2_LEN_MASK \
182 (_NETIO_PKT_L2_LEN_RMASK << _NETIO_PKT_L2_LEN_SHIFT)
183
184
185/* Flags in minimal packet metadata. */
186
187/** We need an eDMA checksum on this packet. */
188#define _NETIO_PKT_NEED_EDMA_CSUM_SHIFT 0
189#define _NETIO_PKT_NEED_EDMA_CSUM_RMASK 1
190#define _NETIO_PKT_NEED_EDMA_CSUM_MASK \
191 (_NETIO_PKT_NEED_EDMA_CSUM_RMASK << _NETIO_PKT_NEED_EDMA_CSUM_SHIFT)
192
193/* Data within the packet information table. */
194
195/* Note that, for efficiency, code which uses these fields assumes that none
196 * of the shift values below are zero. See uses below for an explanation. */
197
198/** Offset within the L2 header of the innermost ethertype (in halfwords). */
199#define _NETIO_PKT_INFO_ETYPE_SHIFT 6
200#define _NETIO_PKT_INFO_ETYPE_RMASK 0x1F
201
202/** Offset within the L2 header of the VLAN tag (in halfwords). */
203#define _NETIO_PKT_INFO_VLAN_SHIFT 11
204#define _NETIO_PKT_INFO_VLAN_RMASK 0x1F
205
206#endif
207
208
209/** The size of a memory buffer representing a small packet.
210 * @ingroup egress */
211#define SMALL_PACKET_SIZE 256
212
213/** The size of a memory buffer representing a large packet.
214 * @ingroup egress */
215#define LARGE_PACKET_SIZE 2048
216
217/** The size of a memory buffer representing a jumbo packet.
218 * @ingroup egress */
219#define JUMBO_PACKET_SIZE (12 * 1024)
220
221
222/* Common ethertypes.
223 * @ingroup ingress */
224/** @{ */
225/** The ethertype of IPv4. */
226#define ETHERTYPE_IPv4 (0x0800)
227/** The ethertype of ARP. */
228#define ETHERTYPE_ARP (0x0806)
229/** The ethertype of VLANs. */
230#define ETHERTYPE_VLAN (0x8100)
231/** The ethertype of a Q-in-Q header. */
232#define ETHERTYPE_Q_IN_Q (0x9100)
233/** The ethertype of IPv6. */
234#define ETHERTYPE_IPv6 (0x86DD)
235/** The ethertype of MPLS. */
236#define ETHERTYPE_MPLS (0x8847)
237/** @} */
238
239
240/** The possible return values of NETIO_PKT_STATUS.
241 * @ingroup ingress
242 */
243typedef enum
244{
245 /** No problems were detected with this packet. */
246 NETIO_PKT_STATUS_OK,
247 /** The packet is undersized; this is expected behavior if the packet's
248 * ethertype is unrecognized, but otherwise the packet is likely corrupt. */
249 NETIO_PKT_STATUS_UNDERSIZE,
250 /** The packet is oversized and some trailing bytes have been discarded.
251 This is expected behavior for short packets, since it's impossible to
252 precisely determine the amount of padding which may have been added to
253 them to make them meet the minimum Ethernet packet size. */
254 NETIO_PKT_STATUS_OVERSIZE,
255 /** The packet was judged to be corrupt by hardware (for instance, it had
256 a bad CRC, or part of it was discarded due to lack of buffer space in
257 the I/O shim) and should be discarded. */
258 NETIO_PKT_STATUS_BAD
259} netio_pkt_status_t;
260
261
262/** Log2 of how many buckets we have. */
263#define NETIO_LOG2_NUM_BUCKETS (10)
264
265/** How many buckets we have.
266 * @ingroup ingress */
267#define NETIO_NUM_BUCKETS (1 << NETIO_LOG2_NUM_BUCKETS)
268
269
270/**
271 * @brief A group-to-bucket identifier.
272 *
273 * @ingroup setup
274 *
275 * This tells us what to do with a given group.
276 */
277typedef union {
278 /** The header broken down into bits. */
279 struct {
280 /** Whether we should balance on L4, if available */
281 unsigned int __balance_on_l4:1;
282 /** Whether we should balance on L3, if available */
283 unsigned int __balance_on_l3:1;
284 /** Whether we should balance on L2, if available */
285 unsigned int __balance_on_l2:1;
286 /** Reserved for future use */
287 unsigned int __reserved:1;
288 /** The base bucket to use to send traffic */
289 unsigned int __bucket_base:NETIO_LOG2_NUM_BUCKETS;
290 /** The mask to apply to the balancing value. This must be one less
291 * than a power of two, e.g. 0x3 or 0xFF.
292 */
293 unsigned int __bucket_mask:NETIO_LOG2_NUM_BUCKETS;
294 /** Pad to 32 bits */
295 unsigned int __padding:(32 - 4 - 2 * NETIO_LOG2_NUM_BUCKETS);
296 } bits;
297 /** To send out the IDN. */
298 unsigned int word;
299}
300netio_group_t;
301
302
303/**
304 * @brief A VLAN-to-bucket identifier.
305 *
306 * @ingroup setup
307 *
308 * This tells us what to do with a given VLAN.
309 */
310typedef netio_group_t netio_vlan_t;
311
312
313/**
314 * A bucket-to-queue mapping.
315 * @ingroup setup
316 */
317typedef unsigned char netio_bucket_t;
318
319
320/**
321 * A packet size can always fit in a netio_size_t.
322 * @ingroup setup
323 */
324typedef unsigned int netio_size_t;
325
326
327/**
328 * @brief Ethernet standard (ingress) packet metadata.
329 *
330 * @ingroup ingress
331 *
332 * This is additional data associated with each packet.
333 * This structure is opaque and accessed through the @ref ingress.
334 *
335 * Also, the buffer population operation currently assumes that standard
336 * metadata is at least as large as minimal metadata, and will need to be
337 * modified if that is no longer the case.
338 */
339typedef struct
340{
341#ifdef __DOXYGEN__
342 /** This structure is opaque. */
343 unsigned char opaque[24];
344#else
345 /** The overall ordinal of the packet */
346 unsigned int __packet_ordinal;
347 /** The ordinal of the packet within the group */
348 unsigned int __group_ordinal;
349 /** The best flow hash IPP could compute. */
350 unsigned int __flow_hash;
351 /** Flags pertaining to checksum calculation, packet type, etc. */
352 unsigned int __flags;
353 /** The first word of "user data". */
354 unsigned int __user_data_0;
355 /** The second word of "user data". */
356 unsigned int __user_data_1;
357#endif
358}
359netio_pkt_metadata_t;
360
361
362/** To ensure that the L3 header is aligned mod 4, the L2 header should be
363 * aligned mod 4 plus 2, since every supported L2 header is 4n + 2 bytes
364 * long. The standard way to do this is to simply add 2 bytes of padding
365 * before the L2 header.
366 */
367#define NETIO_PACKET_PADDING 2
368
369
370
371/**
372 * @brief Ethernet minimal (egress) packet metadata.
373 *
374 * @ingroup egress
375 *
376 * This structure represents information about packets which have
377 * been processed by @ref netio_populate_buffer() or
378 * @ref netio_populate_prepend_buffer(). This structure is opaque
379 * and accessed through the @ref egress.
380 *
381 * @internal This structure is actually copied into the memory used by
382 * standard metadata, which is assumed to be large enough.
383 */
384typedef struct
385{
386#ifdef __DOXYGEN__
387 /** This structure is opaque. */
388 unsigned char opaque[14];
389#else
390 /** The offset of the L2 header from the start of the packet data. */
391 unsigned short l2_offset;
392 /** The offset of the L3 header from the start of the packet data. */
393 unsigned short l3_offset;
394 /** Where to write the checksum. */
395 unsigned char csum_location;
396 /** Where to start checksumming from. */
397 unsigned char csum_start;
398 /** Flags pertaining to checksum calculation etc. */
399 unsigned short flags;
400 /** The L2 length of the packet. */
401 unsigned short l2_length;
402 /** The checksum with which to seed the checksum generator. */
403 unsigned short csum_seed;
404 /** How much to checksum. */
405 unsigned short csum_length;
406#endif
407}
408netio_pkt_minimal_metadata_t;
409
410
411#ifndef __DOXYGEN__
412
413/**
414 * @brief An I/O notification header.
415 *
416 * This is the first word of data received from an I/O shim in a notification
417 * packet. It contains framing and status information.
418 */
419typedef union
420{
421 unsigned int word; /**< The whole word. */
422 /** The various fields. */
423 struct
424 {
425 unsigned int __channel:7; /**< Resource channel. */
426 unsigned int __type:4; /**< Type. */
427 unsigned int __ack:1; /**< Whether an acknowledgement is needed. */
428 unsigned int __reserved:1; /**< Reserved. */
429 unsigned int __protocol:1; /**< A protocol-specific word is added. */
430 unsigned int __status:2; /**< Status of the transfer. */
431 unsigned int __framing:2; /**< Framing of the transfer. */
432 unsigned int __transfer_size:14; /**< Transfer size in bytes (total). */
433 } bits;
434}
435__netio_pkt_notif_t;
436
437
438/**
439 * Returns the base address of the packet.
440 */
441#define _NETIO_PKT_HANDLE_BASE(p) \
442 ((unsigned char*)((p).word & 0xFFFFFFC0))
443
444/**
445 * Returns the base address of the packet.
446 */
447#define _NETIO_PKT_BASE(p) \
448 _NETIO_PKT_HANDLE_BASE(p->__packet)
449
450/**
451 * @brief An I/O notification packet (second word)
452 *
453 * This is the second word of data received from an I/O shim in a notification
454 * packet. This is the virtual address of the packet buffer, plus some flag
455 * bits. (The virtual address of the packet is always 256-byte aligned so we
456 * have room for 8 bits' worth of flags in the low 8 bits.)
457 *
458 * @internal
459 * NOTE: The low two bits must contain "__queue", so the "packet size"
460 * (SIZE_SMALL, SIZE_LARGE, or SIZE_JUMBO) can be determined quickly.
461 *
462 * If __addr or __offset are moved, _NETIO_PKT_BASE
463 * (defined right below this) must be changed.
464 */
465typedef union
466{
467 unsigned int word; /**< The whole word. */
468 /** The various fields. */
469 struct
470 {
471 /** Which queue the packet will be returned to once it is sent back to
472 the IPP. This is one of the SIZE_xxx values. */
473 unsigned int __queue:2;
474
475 /** The IPP handle of the sending IPP. */
476 unsigned int __ipp_handle:2;
477
478 /** Reserved for future use. */
479 unsigned int __reserved:1;
480
481 /** If 1, this packet has minimal (egress) metadata; otherwise, it
482 has standard (ingress) metadata. */
483 unsigned int __minimal:1;
484
485 /** Offset of the metadata within the packet. This value is multiplied
486 * by 64 and added to the base packet address to get the metadata
487 * address. Note that this field is aligned within the word such that
488 * you can easily extract the metadata address with a 26-bit mask. */
489 unsigned int __offset:2;
490
491 /** The top 24 bits of the packet's virtual address. */
492 unsigned int __addr:24;
493 } bits;
494}
495__netio_pkt_handle_t;
496
497#endif /* !__DOXYGEN__ */
498
499
500/**
501 * @brief A handle for an I/O packet's storage.
502 * @ingroup ingress
503 *
504 * netio_pkt_handle_t encodes the concept of a ::netio_pkt_t with its
505 * packet metadata removed. It is a much smaller type that exists to
506 * facilitate applications where the full ::netio_pkt_t type is too
507 * large, such as those that cache enormous numbers of packets or wish
508 * to transmit packet descriptors over the UDN.
509 *
510 * Because there is no metadata, most ::netio_pkt_t operations cannot be
511 * performed on a netio_pkt_handle_t. It supports only
512 * netio_free_handle() (to free the buffer) and
513 * NETIO_PKT_CUSTOM_DATA_H() (to access a pointer to its contents).
514 * The application must acquire any additional metadata it wants from the
515 * original ::netio_pkt_t and record it separately.
516 *
517 * A netio_pkt_handle_t can be extracted from a ::netio_pkt_t by calling
518 * NETIO_PKT_HANDLE(). An invalid handle (analogous to NULL) can be
519 * created by assigning the value ::NETIO_PKT_HANDLE_NONE. A handle can
520 * be tested for validity with NETIO_PKT_HANDLE_IS_VALID().
521 */
522typedef struct
523{
524 unsigned int word; /**< Opaque bits. */
525} netio_pkt_handle_t;
526
527/**
528 * @brief A packet descriptor.
529 *
530 * @ingroup ingress
531 * @ingroup egress
532 *
533 * This data structure represents a packet. The structure is manipulated
534 * through the @ref ingress and the @ref egress.
535 *
536 * While the contents of a netio_pkt_t are opaque, the structure itself is
537 * portable. This means that it may be shared between all tiles which have
538 * done a netio_input_register() call for the interface on which the pkt_t
539 * was initially received (via netio_get_packet()) or retrieved (via
540 * netio_get_buffer()). The contents of a netio_pkt_t can be transmitted to
541 * another tile via shared memory, or via a UDN message, or by other means.
542 * The destination tile may then use the pkt_t as if it had originally been
543 * received locally; it may read or write the packet's data, read its
544 * metadata, free the packet, send the packet, transfer the netio_pkt_t to
545 * yet another tile, and so forth.
546 *
547 * Once a netio_pkt_t has been transferred to a second tile, the first tile
548 * should not reference the original copy; in particular, if more than one
549 * tile frees or sends the same netio_pkt_t, the IPP's packet free lists will
550 * become corrupted. Note also that each tile which reads or modifies
551 * packet data must obey the memory coherency rules outlined in @ref input.
552 */
553typedef struct
554{
555#ifdef __DOXYGEN__
556 /** This structure is opaque. */
557 unsigned char opaque[32];
558#else
559 /** For an ingress packet (one with standard metadata), this is the
560 * notification header we got from the I/O shim. For an egress packet
561 * (one with minimal metadata), this word is zero if the packet has not
562 * been populated, and nonzero if it has. */
563 __netio_pkt_notif_t __notif_header;
564
565 /** Virtual address of the packet buffer, plus state flags. */
566 __netio_pkt_handle_t __packet;
567
568 /** Metadata associated with the packet. */
569 netio_pkt_metadata_t __metadata;
570#endif
571}
572netio_pkt_t;
573
574
575#ifndef __DOXYGEN__
576
577#define __NETIO_PKT_NOTIF_HEADER(pkt) ((pkt)->__notif_header)
578#define __NETIO_PKT_IPP_HANDLE(pkt) ((pkt)->__packet.bits.__ipp_handle)
579#define __NETIO_PKT_QUEUE(pkt) ((pkt)->__packet.bits.__queue)
580#define __NETIO_PKT_NOTIF_HEADER_M(mda, pkt) ((pkt)->__notif_header)
581#define __NETIO_PKT_IPP_HANDLE_M(mda, pkt) ((pkt)->__packet.bits.__ipp_handle)
582#define __NETIO_PKT_MINIMAL(pkt) ((pkt)->__packet.bits.__minimal)
583#define __NETIO_PKT_QUEUE_M(mda, pkt) ((pkt)->__packet.bits.__queue)
584#define __NETIO_PKT_FLAGS_M(mda, pkt) ((mda)->__flags)
585
586/* Packet information table, used by the attribute access functions below. */
587extern const uint16_t _netio_pkt_info[];
588
589#endif /* __DOXYGEN__ */
590
591
592#ifndef __DOXYGEN__
593/* These macros are deprecated and will disappear in a future MDE release. */
594#define NETIO_PKT_GOOD_CHECKSUM(pkt) \
595 NETIO_PKT_L4_CSUM_CORRECT(pkt)
596#define NETIO_PKT_GOOD_CHECKSUM_M(mda, pkt) \
597 NETIO_PKT_L4_CSUM_CORRECT_M(mda, pkt)
598#endif /* __DOXYGEN__ */
599
600
601/* Packet attribute access functions. */
602
603/** Return a pointer to the metadata for a packet.
604 * @ingroup ingress
605 *
606 * Calling this function once and passing the result to other retrieval
607 * functions with a "_M" suffix usually improves performance. This
608 * function must be called on an 'ingress' packet (i.e. one retrieved
609 * by @ref netio_get_packet(), on which @ref netio_populate_buffer() or
610 * @ref netio_populate_prepend_buffer have not been called). Use of this
611 * function on an 'egress' packet will cause an assertion failure.
612 *
613 * @param[in] pkt Packet on which to operate.
614 * @return A pointer to the packet's standard metadata.
615 */
616static __inline netio_pkt_metadata_t*
617NETIO_PKT_METADATA(netio_pkt_t* pkt)
618{
619 netio_assert(!pkt->__packet.bits.__minimal);
620 return &pkt->__metadata;
621}
622
623
624/** Return a pointer to the minimal metadata for a packet.
625 * @ingroup egress
626 *
627 * Calling this function once and passing the result to other retrieval
628 * functions with a "_MM" suffix usually improves performance. This
629 * function must be called on an 'egress' packet (i.e. one on which
630 * @ref netio_populate_buffer() or @ref netio_populate_prepend_buffer()
631 * have been called, or one retrieved by @ref netio_get_buffer()). Use of
632 * this function on an 'ingress' packet will cause an assertion failure.
633 *
634 * @param[in] pkt Packet on which to operate.
635 * @return A pointer to the packet's standard metadata.
636 */
637static __inline netio_pkt_minimal_metadata_t*
638NETIO_PKT_MINIMAL_METADATA(netio_pkt_t* pkt)
639{
640 netio_assert(pkt->__packet.bits.__minimal);
641 return (netio_pkt_minimal_metadata_t*) &pkt->__metadata;
642}
643
644
645/** Determine whether a packet has 'minimal' metadata.
646 * @ingroup pktfuncs
647 *
648 * This function will return nonzero if the packet is an 'egress'
649 * packet (i.e. one on which @ref netio_populate_buffer() or
650 * @ref netio_populate_prepend_buffer() have been called, or one
651 * retrieved by @ref netio_get_buffer()), and zero if the packet
652 * is an 'ingress' packet (i.e. one retrieved by @ref netio_get_packet(),
653 * which has not been converted into an 'egress' packet).
654 *
655 * @param[in] pkt Packet on which to operate.
656 * @return Nonzero if the packet has minimal metadata.
657 */
658static __inline unsigned int
659NETIO_PKT_IS_MINIMAL(netio_pkt_t* pkt)
660{
661 return pkt->__packet.bits.__minimal;
662}
663
664
665/** Return a handle for a packet's storage.
666 * @ingroup pktfuncs
667 *
668 * @param[in] pkt Packet on which to operate.
669 * @return A handle for the packet's storage.
670 */
671static __inline netio_pkt_handle_t
672NETIO_PKT_HANDLE(netio_pkt_t* pkt)
673{
674 netio_pkt_handle_t h;
675 h.word = pkt->__packet.word;
676 return h;
677}
678
679
680/** A special reserved value indicating the absence of a packet handle.
681 *
682 * @ingroup pktfuncs
683 */
684#define NETIO_PKT_HANDLE_NONE ((netio_pkt_handle_t) { 0 })
685
686
687/** Test whether a packet handle is valid.
688 *
689 * Applications may wish to use the reserved value NETIO_PKT_HANDLE_NONE
690 * to indicate no packet at all. This function tests to see if a packet
691 * handle is a real handle, not this special reserved value.
692 *
693 * @ingroup pktfuncs
694 *
695 * @param[in] handle Handle on which to operate.
696 * @return One if the packet handle is valid, else zero.
697 */
698static __inline unsigned int
699NETIO_PKT_HANDLE_IS_VALID(netio_pkt_handle_t handle)
700{
701 return handle.word != 0;
702}
703
704
705
706/** Return a pointer to the start of the packet's custom header.
707 * A custom header may or may not be present, depending upon the IPP; its
708 * contents and alignment are also IPP-dependent. Currently, none of the
709 * standard IPPs supplied by Tilera produce a custom header. If present,
710 * the custom header precedes the L2 header in the packet buffer.
711 * @ingroup ingress
712 *
713 * @param[in] handle Handle on which to operate.
714 * @return A pointer to start of the packet.
715 */
716static __inline unsigned char*
717NETIO_PKT_CUSTOM_DATA_H(netio_pkt_handle_t handle)
718{
719 return _NETIO_PKT_HANDLE_BASE(handle) + NETIO_PACKET_PADDING;
720}
721
722
723/** Return the length of the packet's custom header.
724 * A custom header may or may not be present, depending upon the IPP; its
725 * contents and alignment are also IPP-dependent. Currently, none of the
726 * standard IPPs supplied by Tilera produce a custom header. If present,
727 * the custom header precedes the L2 header in the packet buffer.
728 *
729 * @ingroup ingress
730 *
731 * @param[in] mda Pointer to packet's standard metadata.
732 * @param[in] pkt Packet on which to operate.
733 * @return The length of the packet's custom header, in bytes.
734 */
735static __inline netio_size_t
736NETIO_PKT_CUSTOM_HEADER_LENGTH_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
737{
738 /*
739 * Note that we effectively need to extract a quantity from the flags word
740 * which is measured in words, and then turn it into bytes by shifting
741 * it left by 2. We do this all at once by just shifting right two less
742 * bits, and shifting the mask up two bits.
743 */
744 return ((mda->__flags >> (_NETIO_PKT_CUSTOM_LEN_SHIFT - 2)) &
745 (_NETIO_PKT_CUSTOM_LEN_RMASK << 2));
746}
747
748
749/** Return the length of the packet, starting with the custom header.
750 * A custom header may or may not be present, depending upon the IPP; its
751 * contents and alignment are also IPP-dependent. Currently, none of the
752 * standard IPPs supplied by Tilera produce a custom header. If present,
753 * the custom header precedes the L2 header in the packet buffer.
754 * @ingroup ingress
755 *
756 * @param[in] mda Pointer to packet's standard metadata.
757 * @param[in] pkt Packet on which to operate.
758 * @return The length of the packet, in bytes.
759 */
760static __inline netio_size_t
761NETIO_PKT_CUSTOM_LENGTH_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
762{
763 return (__NETIO_PKT_NOTIF_HEADER(pkt).bits.__transfer_size -
764 NETIO_PACKET_PADDING);
765}
766
767
768/** Return a pointer to the start of the packet's custom header.
769 * A custom header may or may not be present, depending upon the IPP; its
770 * contents and alignment are also IPP-dependent. Currently, none of the
771 * standard IPPs supplied by Tilera produce a custom header. If present,
772 * the custom header precedes the L2 header in the packet buffer.
773 * @ingroup ingress
774 *
775 * @param[in] mda Pointer to packet's standard metadata.
776 * @param[in] pkt Packet on which to operate.
777 * @return A pointer to start of the packet.
778 */
779static __inline unsigned char*
780NETIO_PKT_CUSTOM_DATA_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
781{
782 return NETIO_PKT_CUSTOM_DATA_H(NETIO_PKT_HANDLE(pkt));
783}
784
785
786/** Return the length of the packet's L2 (Ethernet plus VLAN or SNAP) header.
787 * @ingroup ingress
788 *
789 * @param[in] mda Pointer to packet's standard metadata.
790 * @param[in] pkt Packet on which to operate.
791 * @return The length of the packet's L2 header, in bytes.
792 */
793static __inline netio_size_t
794NETIO_PKT_L2_HEADER_LENGTH_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
795{
796 /*
797 * Note that we effectively need to extract a quantity from the flags word
798 * which is measured in words, and then turn it into bytes by shifting
799 * it left by 2. We do this all at once by just shifting right two less
800 * bits, and shifting the mask up two bits. We then add two bytes.
801 */
802 return ((mda->__flags >> (_NETIO_PKT_L2_LEN_SHIFT - 2)) &
803 (_NETIO_PKT_L2_LEN_RMASK << 2)) + 2;
804}
805
806
807/** Return the length of the packet, starting with the L2 (Ethernet) header.
808 * @ingroup ingress
809 *
810 * @param[in] mda Pointer to packet's standard metadata.
811 * @param[in] pkt Packet on which to operate.
812 * @return The length of the packet, in bytes.
813 */
814static __inline netio_size_t
815NETIO_PKT_L2_LENGTH_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
816{
817 return (NETIO_PKT_CUSTOM_LENGTH_M(mda, pkt) -
818 NETIO_PKT_CUSTOM_HEADER_LENGTH_M(mda,pkt));
819}
820
821
822/** Return a pointer to the start of the packet's L2 (Ethernet) header.
823 * @ingroup ingress
824 *
825 * @param[in] mda Pointer to packet's standard metadata.
826 * @param[in] pkt Packet on which to operate.
827 * @return A pointer to start of the packet.
828 */
829static __inline unsigned char*
830NETIO_PKT_L2_DATA_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
831{
832 return (NETIO_PKT_CUSTOM_DATA_M(mda, pkt) +
833 NETIO_PKT_CUSTOM_HEADER_LENGTH_M(mda, pkt));
834}
835
836
837/** Retrieve the length of the packet, starting with the L3 (generally,
838 * the IP) header.
839 * @ingroup ingress
840 *
841 * @param[in] mda Pointer to packet's standard metadata.
842 * @param[in] pkt Packet on which to operate.
843 * @return Length of the packet's L3 header and data, in bytes.
844 */
845static __inline netio_size_t
846NETIO_PKT_L3_LENGTH_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
847{
848 return (NETIO_PKT_L2_LENGTH_M(mda, pkt) -
849 NETIO_PKT_L2_HEADER_LENGTH_M(mda,pkt));
850}
851
852
853/** Return a pointer to the packet's L3 (generally, the IP) header.
854 * @ingroup ingress
855 *
856 * Note that we guarantee word alignment of the L3 header.
857 *
858 * @param[in] mda Pointer to packet's standard metadata.
859 * @param[in] pkt Packet on which to operate.
860 * @return A pointer to the packet's L3 header.
861 */
862static __inline unsigned char*
863NETIO_PKT_L3_DATA_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
864{
865 return (NETIO_PKT_L2_DATA_M(mda, pkt) +
866 NETIO_PKT_L2_HEADER_LENGTH_M(mda, pkt));
867}
868
869
870/** Return the ordinal of the packet.
871 * @ingroup ingress
872 *
873 * Each packet is given an ordinal number when it is delivered by the IPP.
874 * In the medium term, the ordinal is unique and monotonically increasing,
875 * being incremented by 1 for each packet; the ordinal of the first packet
876 * delivered after the IPP starts is zero. (Since the ordinal is of finite
877 * size, given enough input packets, it will eventually wrap around to zero;
878 * in the long term, therefore, ordinals are not unique.) The ordinals
879 * handed out by different IPPs are not disjoint, so two packets from
880 * different IPPs may have identical ordinals. Packets dropped by the
881 * IPP or by the I/O shim are not assigned ordinals.
882 *
883 * @param[in] mda Pointer to packet's standard metadata.
884 * @param[in] pkt Packet on which to operate.
885 * @return The packet's per-IPP packet ordinal.
886 */
887static __inline unsigned int
888NETIO_PKT_ORDINAL_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
889{
890 return mda->__packet_ordinal;
891}
892
893
894/** Return the per-group ordinal of the packet.
895 * @ingroup ingress
896 *
897 * Each packet is given a per-group ordinal number when it is
898 * delivered by the IPP. By default, the group is the packet's VLAN,
899 * although IPP can be recompiled to use different values. In
900 * the medium term, the ordinal is unique and monotonically
901 * increasing, being incremented by 1 for each packet; the ordinal of
902 * the first packet distributed to a particular group is zero.
903 * (Since the ordinal is of finite size, given enough input packets,
904 * it will eventually wrap around to zero; in the long term,
905 * therefore, ordinals are not unique.) The ordinals handed out by
906 * different IPPs are not disjoint, so two packets from different IPPs
907 * may have identical ordinals; similarly, packets distributed to
908 * different groups may have identical ordinals. Packets dropped by
909 * the IPP or by the I/O shim are not assigned ordinals.
910 *
911 * @param[in] mda Pointer to packet's standard metadata.
912 * @param[in] pkt Packet on which to operate.
913 * @return The packet's per-IPP, per-group ordinal.
914 */
915static __inline unsigned int
916NETIO_PKT_GROUP_ORDINAL_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
917{
918 return mda->__group_ordinal;
919}
920
921
922/** Return the VLAN ID assigned to the packet.
923 * @ingroup ingress
924 *
925 * This value is usually contained within the packet header.
926 *
927 * This value will be zero if the packet does not have a VLAN tag, or if
928 * this value was not extracted from the packet.
929 *
930 * @param[in] mda Pointer to packet's standard metadata.
931 * @param[in] pkt Packet on which to operate.
932 * @return The packet's VLAN ID.
933 */
934static __inline unsigned short
935NETIO_PKT_VLAN_ID_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
936{
937 int vl = (mda->__flags >> _NETIO_PKT_VLAN_SHIFT) & _NETIO_PKT_VLAN_RMASK;
938 unsigned short* pkt_p;
939 int index;
940 unsigned short val;
941
942 if (vl == _NETIO_PKT_VLAN_NONE)
943 return 0;
944
945 pkt_p = (unsigned short*) NETIO_PKT_L2_DATA_M(mda, pkt);
946 index = (mda->__flags >> _NETIO_PKT_TYPE_SHIFT) & _NETIO_PKT_TYPE_RMASK;
947
948 val = pkt_p[(_netio_pkt_info[index] >> _NETIO_PKT_INFO_VLAN_SHIFT) &
949 _NETIO_PKT_INFO_VLAN_RMASK];
950
951#ifdef __TILECC__
952 return (__insn_bytex(val) >> 16) & 0xFFF;
953#else
954 return (__builtin_bswap32(val) >> 16) & 0xFFF;
955#endif
956}
957
958
959/** Return the ethertype of the packet.
960 * @ingroup ingress
961 *
962 * This value is usually contained within the packet header.
963 *
964 * This value is reliable if @ref NETIO_PKT_ETHERTYPE_RECOGNIZED_M()
965 * returns true, and otherwise, may not be well defined.
966 *
967 * @param[in] mda Pointer to packet's standard metadata.
968 * @param[in] pkt Packet on which to operate.
969 * @return The packet's ethertype.
970 */
971static __inline unsigned short
972NETIO_PKT_ETHERTYPE_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
973{
974 unsigned short* pkt_p = (unsigned short*) NETIO_PKT_L2_DATA_M(mda, pkt);
975 int index = (mda->__flags >> _NETIO_PKT_TYPE_SHIFT) & _NETIO_PKT_TYPE_RMASK;
976
977 unsigned short val =
978 pkt_p[(_netio_pkt_info[index] >> _NETIO_PKT_INFO_ETYPE_SHIFT) &
979 _NETIO_PKT_INFO_ETYPE_RMASK];
980
981 return __builtin_bswap32(val) >> 16;
982}
983
984
985/** Return the flow hash computed on the packet.
986 * @ingroup ingress
987 *
988 * For TCP and UDP packets, this hash is calculated by hashing together
989 * the "5-tuple" values, specifically the source IP address, destination
990 * IP address, protocol type, source port and destination port.
991 * The hash value is intended to be helpful for millions of distinct
992 * flows.
993 *
994 * For IPv4 or IPv6 packets which are neither TCP nor UDP, the flow hash is
995 * derived by hashing together the source and destination IP addresses.
996 *
997 * For MPLS-encapsulated packets, the flow hash is derived by hashing
998 * the first MPLS label.
999 *
1000 * For all other packets the flow hash is computed from the source
1001 * and destination Ethernet addresses.
1002 *
1003 * The hash is symmetric, meaning it produces the same value if the
1004 * source and destination are swapped. The only exceptions are
1005 * tunneling protocols 0x04 (IP in IP Encapsulation), 0x29 (Simple
1006 * Internet Protocol), 0x2F (General Routing Encapsulation) and 0x32
1007 * (Encap Security Payload), which use only the destination address
1008 * since the source address is not meaningful.
1009 *
1010 * @param[in] mda Pointer to packet's standard metadata.
1011 * @param[in] pkt Packet on which to operate.
1012 * @return The packet's 32-bit flow hash.
1013 */
1014static __inline unsigned int
1015NETIO_PKT_FLOW_HASH_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1016{
1017 return mda->__flow_hash;
1018}
1019
1020
1021/** Return the first word of "user data" for the packet.
1022 *
1023 * The contents of the user data words depend on the IPP.
1024 *
1025 * When using the standard ipp1, ipp2, or ipp4 sub-drivers, the first
1026 * word of user data contains the least significant bits of the 64-bit
1027 * arrival cycle count (see @c get_cycle_count_low()).
1028 *
1029 * See the <em>System Programmer's Guide</em> for details.
1030 *
1031 * @ingroup ingress
1032 *
1033 * @param[in] mda Pointer to packet's standard metadata.
1034 * @param[in] pkt Packet on which to operate.
1035 * @return The packet's first word of "user data".
1036 */
1037static __inline unsigned int
1038NETIO_PKT_USER_DATA_0_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1039{
1040 return mda->__user_data_0;
1041}
1042
1043
1044/** Return the second word of "user data" for the packet.
1045 *
1046 * The contents of the user data words depend on the IPP.
1047 *
1048 * When using the standard ipp1, ipp2, or ipp4 sub-drivers, the second
1049 * word of user data contains the most significant bits of the 64-bit
1050 * arrival cycle count (see @c get_cycle_count_high()).
1051 *
1052 * See the <em>System Programmer's Guide</em> for details.
1053 *
1054 * @ingroup ingress
1055 *
1056 * @param[in] mda Pointer to packet's standard metadata.
1057 * @param[in] pkt Packet on which to operate.
1058 * @return The packet's second word of "user data".
1059 */
1060static __inline unsigned int
1061NETIO_PKT_USER_DATA_1_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1062{
1063 return mda->__user_data_1;
1064}
1065
1066
1067/** Determine whether the L4 (TCP/UDP) checksum was calculated.
1068 * @ingroup ingress
1069 *
1070 * @param[in] mda Pointer to packet's standard metadata.
1071 * @param[in] pkt Packet on which to operate.
1072 * @return Nonzero if the L4 checksum was calculated.
1073 */
1074static __inline unsigned int
1075NETIO_PKT_L4_CSUM_CALCULATED_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1076{
1077 return !(mda->__flags & _NETIO_PKT_NO_L4_CSUM_MASK);
1078}
1079
1080
1081/** Determine whether the L4 (TCP/UDP) checksum was calculated and found to
1082 * be correct.
1083 * @ingroup ingress
1084 *
1085 * @param[in] mda Pointer to packet's standard metadata.
1086 * @param[in] pkt Packet on which to operate.
1087 * @return Nonzero if the checksum was calculated and is correct.
1088 */
1089static __inline unsigned int
1090NETIO_PKT_L4_CSUM_CORRECT_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1091{
1092 return !(mda->__flags &
1093 (_NETIO_PKT_BAD_L4_CSUM_MASK | _NETIO_PKT_NO_L4_CSUM_MASK));
1094}
1095
1096
1097/** Determine whether the L3 (IP) checksum was calculated.
1098 * @ingroup ingress
1099 *
1100 * @param[in] mda Pointer to packet's standard metadata.
1101 * @param[in] pkt Packet on which to operate.
1102 * @return Nonzero if the L3 (IP) checksum was calculated.
1103*/
1104static __inline unsigned int
1105NETIO_PKT_L3_CSUM_CALCULATED_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1106{
1107 return !(mda->__flags & _NETIO_PKT_NO_L3_CSUM_MASK);
1108}
1109
1110
1111/** Determine whether the L3 (IP) checksum was calculated and found to be
1112 * correct.
1113 * @ingroup ingress
1114 *
1115 * @param[in] mda Pointer to packet's standard metadata.
1116 * @param[in] pkt Packet on which to operate.
1117 * @return Nonzero if the checksum was calculated and is correct.
1118 */
1119static __inline unsigned int
1120NETIO_PKT_L3_CSUM_CORRECT_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1121{
1122 return !(mda->__flags &
1123 (_NETIO_PKT_BAD_L3_CSUM_MASK | _NETIO_PKT_NO_L3_CSUM_MASK));
1124}
1125
1126
1127/** Determine whether the ethertype was recognized and L3 packet data was
1128 * processed.
1129 * @ingroup ingress
1130 *
1131 * @param[in] mda Pointer to packet's standard metadata.
1132 * @param[in] pkt Packet on which to operate.
1133 * @return Nonzero if the ethertype was recognized and L3 packet data was
1134 * processed.
1135 */
1136static __inline unsigned int
1137NETIO_PKT_ETHERTYPE_RECOGNIZED_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1138{
1139 return !(mda->__flags & _NETIO_PKT_TYPE_UNRECOGNIZED_MASK);
1140}
1141
1142
1143/** Retrieve the status of a packet and any errors that may have occurred
1144 * during ingress processing (length mismatches, CRC errors, etc.).
1145 * @ingroup ingress
1146 *
1147 * Note that packets for which @ref NETIO_PKT_ETHERTYPE_RECOGNIZED()
1148 * returns zero are always reported as underlength, as there is no a priori
1149 * means to determine their length. Normally, applications should use
1150 * @ref NETIO_PKT_BAD_M() instead of explicitly checking status with this
1151 * function.
1152 *
1153 * @param[in] mda Pointer to packet's standard metadata.
1154 * @param[in] pkt Packet on which to operate.
1155 * @return The packet's status.
1156 */
1157static __inline netio_pkt_status_t
1158NETIO_PKT_STATUS_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1159{
1160 return (netio_pkt_status_t) __NETIO_PKT_NOTIF_HEADER(pkt).bits.__status;
1161}
1162
1163
1164/** Report whether a packet is bad (i.e., was shorter than expected based on
1165 * its headers, or had a bad CRC).
1166 * @ingroup ingress
1167 *
1168 * Note that this function does not verify L3 or L4 checksums.
1169 *
1170 * @param[in] mda Pointer to packet's standard metadata.
1171 * @param[in] pkt Packet on which to operate.
1172 * @return Nonzero if the packet is bad and should be discarded.
1173 */
1174static __inline unsigned int
1175NETIO_PKT_BAD_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1176{
1177 return ((NETIO_PKT_STATUS_M(mda, pkt) & 1) &&
1178 (NETIO_PKT_ETHERTYPE_RECOGNIZED_M(mda, pkt) ||
1179 NETIO_PKT_STATUS_M(mda, pkt) == NETIO_PKT_STATUS_BAD));
1180}
1181
1182
1183/** Return the length of the packet, starting with the L2 (Ethernet) header.
1184 * @ingroup egress
1185 *
1186 * @param[in] mmd Pointer to packet's minimal metadata.
1187 * @param[in] pkt Packet on which to operate.
1188 * @return The length of the packet, in bytes.
1189 */
1190static __inline netio_size_t
1191NETIO_PKT_L2_LENGTH_MM(netio_pkt_minimal_metadata_t* mmd, netio_pkt_t* pkt)
1192{
1193 return mmd->l2_length;
1194}
1195
1196
1197/** Return the length of the L2 (Ethernet) header.
1198 * @ingroup egress
1199 *
1200 * @param[in] mmd Pointer to packet's minimal metadata.
1201 * @param[in] pkt Packet on which to operate.
1202 * @return The length of the packet's L2 header, in bytes.
1203 */
1204static __inline netio_size_t
1205NETIO_PKT_L2_HEADER_LENGTH_MM(netio_pkt_minimal_metadata_t* mmd,
1206 netio_pkt_t* pkt)
1207{
1208 return mmd->l3_offset - mmd->l2_offset;
1209}
1210
1211
1212/** Return the length of the packet, starting with the L3 (IP) header.
1213 * @ingroup egress
1214 *
1215 * @param[in] mmd Pointer to packet's minimal metadata.
1216 * @param[in] pkt Packet on which to operate.
1217 * @return Length of the packet's L3 header and data, in bytes.
1218 */
1219static __inline netio_size_t
1220NETIO_PKT_L3_LENGTH_MM(netio_pkt_minimal_metadata_t* mmd, netio_pkt_t* pkt)
1221{
1222 return (NETIO_PKT_L2_LENGTH_MM(mmd, pkt) -
1223 NETIO_PKT_L2_HEADER_LENGTH_MM(mmd, pkt));
1224}
1225
1226
1227/** Return a pointer to the packet's L3 (generally, the IP) header.
1228 * @ingroup egress
1229 *
1230 * Note that we guarantee word alignment of the L3 header.
1231 *
1232 * @param[in] mmd Pointer to packet's minimal metadata.
1233 * @param[in] pkt Packet on which to operate.
1234 * @return A pointer to the packet's L3 header.
1235 */
1236static __inline unsigned char*
1237NETIO_PKT_L3_DATA_MM(netio_pkt_minimal_metadata_t* mmd, netio_pkt_t* pkt)
1238{
1239 return _NETIO_PKT_BASE(pkt) + mmd->l3_offset;
1240}
1241
1242
1243/** Return a pointer to the packet's L2 (Ethernet) header.
1244 * @ingroup egress
1245 *
1246 * @param[in] mmd Pointer to packet's minimal metadata.
1247 * @param[in] pkt Packet on which to operate.
1248 * @return A pointer to start of the packet.
1249 */
1250static __inline unsigned char*
1251NETIO_PKT_L2_DATA_MM(netio_pkt_minimal_metadata_t* mmd, netio_pkt_t* pkt)
1252{
1253 return _NETIO_PKT_BASE(pkt) + mmd->l2_offset;
1254}
1255
1256
1257/** Retrieve the status of a packet and any errors that may have occurred
1258 * during ingress processing (length mismatches, CRC errors, etc.).
1259 * @ingroup ingress
1260 *
1261 * Note that packets for which @ref NETIO_PKT_ETHERTYPE_RECOGNIZED()
1262 * returns zero are always reported as underlength, as there is no a priori
1263 * means to determine their length. Normally, applications should use
1264 * @ref NETIO_PKT_BAD() instead of explicitly checking status with this
1265 * function.
1266 *
1267 * @param[in] pkt Packet on which to operate.
1268 * @return The packet's status.
1269 */
1270static __inline netio_pkt_status_t
1271NETIO_PKT_STATUS(netio_pkt_t* pkt)
1272{
1273 netio_assert(!pkt->__packet.bits.__minimal);
1274
1275 return (netio_pkt_status_t) __NETIO_PKT_NOTIF_HEADER(pkt).bits.__status;
1276}
1277
1278
1279/** Report whether a packet is bad (i.e., was shorter than expected based on
1280 * its headers, or had a bad CRC).
1281 * @ingroup ingress
1282 *
1283 * Note that this function does not verify L3 or L4 checksums.
1284 *
1285 * @param[in] pkt Packet on which to operate.
1286 * @return Nonzero if the packet is bad and should be discarded.
1287 */
1288static __inline unsigned int
1289NETIO_PKT_BAD(netio_pkt_t* pkt)
1290{
1291 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1292
1293 return NETIO_PKT_BAD_M(mda, pkt);
1294}
1295
1296
1297/** Return the length of the packet's custom header.
1298 * A custom header may or may not be present, depending upon the IPP; its
1299 * contents and alignment are also IPP-dependent. Currently, none of the
1300 * standard IPPs supplied by Tilera produce a custom header. If present,
1301 * the custom header precedes the L2 header in the packet buffer.
1302 * @ingroup pktfuncs
1303 *
1304 * @param[in] pkt Packet on which to operate.
1305 * @return The length of the packet's custom header, in bytes.
1306 */
1307static __inline netio_size_t
1308NETIO_PKT_CUSTOM_HEADER_LENGTH(netio_pkt_t* pkt)
1309{
1310 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1311
1312 return NETIO_PKT_CUSTOM_HEADER_LENGTH_M(mda, pkt);
1313}
1314
1315
1316/** Return the length of the packet, starting with the custom header.
1317 * A custom header may or may not be present, depending upon the IPP; its
1318 * contents and alignment are also IPP-dependent. Currently, none of the
1319 * standard IPPs supplied by Tilera produce a custom header. If present,
1320 * the custom header precedes the L2 header in the packet buffer.
1321 * @ingroup pktfuncs
1322 *
1323 * @param[in] pkt Packet on which to operate.
1324 * @return The length of the packet, in bytes.
1325 */
1326static __inline netio_size_t
1327NETIO_PKT_CUSTOM_LENGTH(netio_pkt_t* pkt)
1328{
1329 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1330
1331 return NETIO_PKT_CUSTOM_LENGTH_M(mda, pkt);
1332}
1333
1334
1335/** Return a pointer to the packet's custom header.
1336 * A custom header may or may not be present, depending upon the IPP; its
1337 * contents and alignment are also IPP-dependent. Currently, none of the
1338 * standard IPPs supplied by Tilera produce a custom header. If present,
1339 * the custom header precedes the L2 header in the packet buffer.
1340 * @ingroup pktfuncs
1341 *
1342 * @param[in] pkt Packet on which to operate.
1343 * @return A pointer to start of the packet.
1344 */
1345static __inline unsigned char*
1346NETIO_PKT_CUSTOM_DATA(netio_pkt_t* pkt)
1347{
1348 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1349
1350 return NETIO_PKT_CUSTOM_DATA_M(mda, pkt);
1351}
1352
1353
1354/** Return the length of the packet's L2 (Ethernet plus VLAN or SNAP) header.
1355 * @ingroup pktfuncs
1356 *
1357 * @param[in] pkt Packet on which to operate.
1358 * @return The length of the packet's L2 header, in bytes.
1359 */
1360static __inline netio_size_t
1361NETIO_PKT_L2_HEADER_LENGTH(netio_pkt_t* pkt)
1362{
1363 if (NETIO_PKT_IS_MINIMAL(pkt))
1364 {
1365 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1366
1367 return NETIO_PKT_L2_HEADER_LENGTH_MM(mmd, pkt);
1368 }
1369 else
1370 {
1371 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1372
1373 return NETIO_PKT_L2_HEADER_LENGTH_M(mda, pkt);
1374 }
1375}
1376
1377
1378/** Return the length of the packet, starting with the L2 (Ethernet) header.
1379 * @ingroup pktfuncs
1380 *
1381 * @param[in] pkt Packet on which to operate.
1382 * @return The length of the packet, in bytes.
1383 */
1384static __inline netio_size_t
1385NETIO_PKT_L2_LENGTH(netio_pkt_t* pkt)
1386{
1387 if (NETIO_PKT_IS_MINIMAL(pkt))
1388 {
1389 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1390
1391 return NETIO_PKT_L2_LENGTH_MM(mmd, pkt);
1392 }
1393 else
1394 {
1395 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1396
1397 return NETIO_PKT_L2_LENGTH_M(mda, pkt);
1398 }
1399}
1400
1401
1402/** Return a pointer to the packet's L2 (Ethernet) header.
1403 * @ingroup pktfuncs
1404 *
1405 * @param[in] pkt Packet on which to operate.
1406 * @return A pointer to start of the packet.
1407 */
1408static __inline unsigned char*
1409NETIO_PKT_L2_DATA(netio_pkt_t* pkt)
1410{
1411 if (NETIO_PKT_IS_MINIMAL(pkt))
1412 {
1413 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1414
1415 return NETIO_PKT_L2_DATA_MM(mmd, pkt);
1416 }
1417 else
1418 {
1419 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1420
1421 return NETIO_PKT_L2_DATA_M(mda, pkt);
1422 }
1423}
1424
1425
1426/** Retrieve the length of the packet, starting with the L3 (generally, the IP)
1427 * header.
1428 * @ingroup pktfuncs
1429 *
1430 * @param[in] pkt Packet on which to operate.
1431 * @return Length of the packet's L3 header and data, in bytes.
1432 */
1433static __inline netio_size_t
1434NETIO_PKT_L3_LENGTH(netio_pkt_t* pkt)
1435{
1436 if (NETIO_PKT_IS_MINIMAL(pkt))
1437 {
1438 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1439
1440 return NETIO_PKT_L3_LENGTH_MM(mmd, pkt);
1441 }
1442 else
1443 {
1444 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1445
1446 return NETIO_PKT_L3_LENGTH_M(mda, pkt);
1447 }
1448}
1449
1450
1451/** Return a pointer to the packet's L3 (generally, the IP) header.
1452 * @ingroup pktfuncs
1453 *
1454 * Note that we guarantee word alignment of the L3 header.
1455 *
1456 * @param[in] pkt Packet on which to operate.
1457 * @return A pointer to the packet's L3 header.
1458 */
1459static __inline unsigned char*
1460NETIO_PKT_L3_DATA(netio_pkt_t* pkt)
1461{
1462 if (NETIO_PKT_IS_MINIMAL(pkt))
1463 {
1464 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1465
1466 return NETIO_PKT_L3_DATA_MM(mmd, pkt);
1467 }
1468 else
1469 {
1470 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1471
1472 return NETIO_PKT_L3_DATA_M(mda, pkt);
1473 }
1474}
1475
1476
1477/** Return the ordinal of the packet.
1478 * @ingroup ingress
1479 *
1480 * Each packet is given an ordinal number when it is delivered by the IPP.
1481 * In the medium term, the ordinal is unique and monotonically increasing,
1482 * being incremented by 1 for each packet; the ordinal of the first packet
1483 * delivered after the IPP starts is zero. (Since the ordinal is of finite
1484 * size, given enough input packets, it will eventually wrap around to zero;
1485 * in the long term, therefore, ordinals are not unique.) The ordinals
1486 * handed out by different IPPs are not disjoint, so two packets from
1487 * different IPPs may have identical ordinals. Packets dropped by the
1488 * IPP or by the I/O shim are not assigned ordinals.
1489 *
1490 *
1491 * @param[in] pkt Packet on which to operate.
1492 * @return The packet's per-IPP packet ordinal.
1493 */
1494static __inline unsigned int
1495NETIO_PKT_ORDINAL(netio_pkt_t* pkt)
1496{
1497 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1498
1499 return NETIO_PKT_ORDINAL_M(mda, pkt);
1500}
1501
1502
1503/** Return the per-group ordinal of the packet.
1504 * @ingroup ingress
1505 *
1506 * Each packet is given a per-group ordinal number when it is
1507 * delivered by the IPP. By default, the group is the packet's VLAN,
1508 * although IPP can be recompiled to use different values. In
1509 * the medium term, the ordinal is unique and monotonically
1510 * increasing, being incremented by 1 for each packet; the ordinal of
1511 * the first packet distributed to a particular group is zero.
1512 * (Since the ordinal is of finite size, given enough input packets,
1513 * it will eventually wrap around to zero; in the long term,
1514 * therefore, ordinals are not unique.) The ordinals handed out by
1515 * different IPPs are not disjoint, so two packets from different IPPs
1516 * may have identical ordinals; similarly, packets distributed to
1517 * different groups may have identical ordinals. Packets dropped by
1518 * the IPP or by the I/O shim are not assigned ordinals.
1519 *
1520 * @param[in] pkt Packet on which to operate.
1521 * @return The packet's per-IPP, per-group ordinal.
1522 */
1523static __inline unsigned int
1524NETIO_PKT_GROUP_ORDINAL(netio_pkt_t* pkt)
1525{
1526 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1527
1528 return NETIO_PKT_GROUP_ORDINAL_M(mda, pkt);
1529}
1530
1531
1532/** Return the VLAN ID assigned to the packet.
1533 * @ingroup ingress
1534 *
1535 * This is usually also contained within the packet header. If the packet
1536 * does not have a VLAN tag, the VLAN ID returned by this function is zero.
1537 *
1538 * @param[in] pkt Packet on which to operate.
1539 * @return The packet's VLAN ID.
1540 */
1541static __inline unsigned short
1542NETIO_PKT_VLAN_ID(netio_pkt_t* pkt)
1543{
1544 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1545
1546 return NETIO_PKT_VLAN_ID_M(mda, pkt);
1547}
1548
1549
1550/** Return the ethertype of the packet.
1551 * @ingroup ingress
1552 *
1553 * This value is reliable if @ref NETIO_PKT_ETHERTYPE_RECOGNIZED()
1554 * returns true, and otherwise, may not be well defined.
1555 *
1556 * @param[in] pkt Packet on which to operate.
1557 * @return The packet's ethertype.
1558 */
1559static __inline unsigned short
1560NETIO_PKT_ETHERTYPE(netio_pkt_t* pkt)
1561{
1562 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1563
1564 return NETIO_PKT_ETHERTYPE_M(mda, pkt);
1565}
1566
1567
1568/** Return the flow hash computed on the packet.
1569 * @ingroup ingress
1570 *
1571 * For TCP and UDP packets, this hash is calculated by hashing together
1572 * the "5-tuple" values, specifically the source IP address, destination
1573 * IP address, protocol type, source port and destination port.
1574 * The hash value is intended to be helpful for millions of distinct
1575 * flows.
1576 *
1577 * For IPv4 or IPv6 packets which are neither TCP nor UDP, the flow hash is
1578 * derived by hashing together the source and destination IP addresses.
1579 *
1580 * For MPLS-encapsulated packets, the flow hash is derived by hashing
1581 * the first MPLS label.
1582 *
1583 * For all other packets the flow hash is computed from the source
1584 * and destination Ethernet addresses.
1585 *
1586 * The hash is symmetric, meaning it produces the same value if the
1587 * source and destination are swapped. The only exceptions are
1588 * tunneling protocols 0x04 (IP in IP Encapsulation), 0x29 (Simple
1589 * Internet Protocol), 0x2F (General Routing Encapsulation) and 0x32
1590 * (Encap Security Payload), which use only the destination address
1591 * since the source address is not meaningful.
1592 *
1593 * @param[in] pkt Packet on which to operate.
1594 * @return The packet's 32-bit flow hash.
1595 */
1596static __inline unsigned int
1597NETIO_PKT_FLOW_HASH(netio_pkt_t* pkt)
1598{
1599 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1600
1601 return NETIO_PKT_FLOW_HASH_M(mda, pkt);
1602}
1603
1604
1605/** Return the first word of "user data" for the packet.
1606 *
1607 * The contents of the user data words depend on the IPP.
1608 *
1609 * When using the standard ipp1, ipp2, or ipp4 sub-drivers, the first
1610 * word of user data contains the least significant bits of the 64-bit
1611 * arrival cycle count (see @c get_cycle_count_low()).
1612 *
1613 * See the <em>System Programmer's Guide</em> for details.
1614 *
1615 * @ingroup ingress
1616 *
1617 * @param[in] pkt Packet on which to operate.
1618 * @return The packet's first word of "user data".
1619 */
1620static __inline unsigned int
1621NETIO_PKT_USER_DATA_0(netio_pkt_t* pkt)
1622{
1623 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1624
1625 return NETIO_PKT_USER_DATA_0_M(mda, pkt);
1626}
1627
1628
1629/** Return the second word of "user data" for the packet.
1630 *
1631 * The contents of the user data words depend on the IPP.
1632 *
1633 * When using the standard ipp1, ipp2, or ipp4 sub-drivers, the second
1634 * word of user data contains the most significant bits of the 64-bit
1635 * arrival cycle count (see @c get_cycle_count_high()).
1636 *
1637 * See the <em>System Programmer's Guide</em> for details.
1638 *
1639 * @ingroup ingress
1640 *
1641 * @param[in] pkt Packet on which to operate.
1642 * @return The packet's second word of "user data".
1643 */
1644static __inline unsigned int
1645NETIO_PKT_USER_DATA_1(netio_pkt_t* pkt)
1646{
1647 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1648
1649 return NETIO_PKT_USER_DATA_1_M(mda, pkt);
1650}
1651
1652
1653/** Determine whether the L4 (TCP/UDP) checksum was calculated.
1654 * @ingroup ingress
1655 *
1656 * @param[in] pkt Packet on which to operate.
1657 * @return Nonzero if the L4 checksum was calculated.
1658 */
1659static __inline unsigned int
1660NETIO_PKT_L4_CSUM_CALCULATED(netio_pkt_t* pkt)
1661{
1662 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1663
1664 return NETIO_PKT_L4_CSUM_CALCULATED_M(mda, pkt);
1665}
1666
1667
1668/** Determine whether the L4 (TCP/UDP) checksum was calculated and found to
1669 * be correct.
1670 * @ingroup ingress
1671 *
1672 * @param[in] pkt Packet on which to operate.
1673 * @return Nonzero if the checksum was calculated and is correct.
1674 */
1675static __inline unsigned int
1676NETIO_PKT_L4_CSUM_CORRECT(netio_pkt_t* pkt)
1677{
1678 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1679
1680 return NETIO_PKT_L4_CSUM_CORRECT_M(mda, pkt);
1681}
1682
1683
1684/** Determine whether the L3 (IP) checksum was calculated.
1685 * @ingroup ingress
1686 *
1687 * @param[in] pkt Packet on which to operate.
1688 * @return Nonzero if the L3 (IP) checksum was calculated.
1689*/
1690static __inline unsigned int
1691NETIO_PKT_L3_CSUM_CALCULATED(netio_pkt_t* pkt)
1692{
1693 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1694
1695 return NETIO_PKT_L3_CSUM_CALCULATED_M(mda, pkt);
1696}
1697
1698
1699/** Determine whether the L3 (IP) checksum was calculated and found to be
1700 * correct.
1701 * @ingroup ingress
1702 *
1703 * @param[in] pkt Packet on which to operate.
1704 * @return Nonzero if the checksum was calculated and is correct.
1705 */
1706static __inline unsigned int
1707NETIO_PKT_L3_CSUM_CORRECT(netio_pkt_t* pkt)
1708{
1709 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1710
1711 return NETIO_PKT_L3_CSUM_CORRECT_M(mda, pkt);
1712}
1713
1714
1715/** Determine whether the Ethertype was recognized and L3 packet data was
1716 * processed.
1717 * @ingroup ingress
1718 *
1719 * @param[in] pkt Packet on which to operate.
1720 * @return Nonzero if the Ethertype was recognized and L3 packet data was
1721 * processed.
1722 */
1723static __inline unsigned int
1724NETIO_PKT_ETHERTYPE_RECOGNIZED(netio_pkt_t* pkt)
1725{
1726 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1727
1728 return NETIO_PKT_ETHERTYPE_RECOGNIZED_M(mda, pkt);
1729}
1730
1731
1732/** Set an egress packet's L2 length, using a metadata pointer to speed the
1733 * computation.
1734 * @ingroup egress
1735 *
1736 * @param[in,out] mmd Pointer to packet's minimal metadata.
1737 * @param[in] pkt Packet on which to operate.
1738 * @param[in] len Packet L2 length, in bytes.
1739 */
1740static __inline void
1741NETIO_PKT_SET_L2_LENGTH_MM(netio_pkt_minimal_metadata_t* mmd, netio_pkt_t* pkt,
1742 int len)
1743{
1744 mmd->l2_length = len;
1745}
1746
1747
1748/** Set an egress packet's L2 length.
1749 * @ingroup egress
1750 *
1751 * @param[in,out] pkt Packet on which to operate.
1752 * @param[in] len Packet L2 length, in bytes.
1753 */
1754static __inline void
1755NETIO_PKT_SET_L2_LENGTH(netio_pkt_t* pkt, int len)
1756{
1757 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1758
1759 NETIO_PKT_SET_L2_LENGTH_MM(mmd, pkt, len);
1760}
1761
1762
1763/** Set an egress packet's L2 header length, using a metadata pointer to
1764 * speed the computation.
1765 * @ingroup egress
1766 *
1767 * It is not normally necessary to call this routine; only the L2 length,
1768 * not the header length, is needed to transmit a packet. It may be useful if
1769 * the egress packet will later be processed by code which expects to use
1770 * functions like @ref NETIO_PKT_L3_DATA() to get a pointer to the L3 payload.
1771 *
1772 * @param[in,out] mmd Pointer to packet's minimal metadata.
1773 * @param[in] pkt Packet on which to operate.
1774 * @param[in] len Packet L2 header length, in bytes.
1775 */
1776static __inline void
1777NETIO_PKT_SET_L2_HEADER_LENGTH_MM(netio_pkt_minimal_metadata_t* mmd,
1778 netio_pkt_t* pkt, int len)
1779{
1780 mmd->l3_offset = mmd->l2_offset + len;
1781}
1782
1783
1784/** Set an egress packet's L2 header length.
1785 * @ingroup egress
1786 *
1787 * It is not normally necessary to call this routine; only the L2 length,
1788 * not the header length, is needed to transmit a packet. It may be useful if
1789 * the egress packet will later be processed by code which expects to use
1790 * functions like @ref NETIO_PKT_L3_DATA() to get a pointer to the L3 payload.
1791 *
1792 * @param[in,out] pkt Packet on which to operate.
1793 * @param[in] len Packet L2 header length, in bytes.
1794 */
1795static __inline void
1796NETIO_PKT_SET_L2_HEADER_LENGTH(netio_pkt_t* pkt, int len)
1797{
1798 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1799
1800 NETIO_PKT_SET_L2_HEADER_LENGTH_MM(mmd, pkt, len);
1801}
1802
1803
1804/** Set up an egress packet for hardware checksum computation, using a
1805 * metadata pointer to speed the operation.
1806 * @ingroup egress
1807 *
1808 * NetIO provides the ability to automatically calculate a standard
1809 * 16-bit Internet checksum on transmitted packets. The application
1810 * may specify the point in the packet where the checksum starts, the
1811 * number of bytes to be checksummed, and the two bytes in the packet
1812 * which will be replaced with the completed checksum. (If the range
1813 * of bytes to be checksummed includes the bytes to be replaced, the
1814 * initial values of those bytes will be included in the checksum.)
1815 *
1816 * For some protocols, the packet checksum covers data which is not present
1817 * in the packet, or is at least not contiguous to the main data payload.
1818 * For instance, the TCP checksum includes a "pseudo-header" which includes
1819 * the source and destination IP addresses of the packet. To accommodate
1820 * this, the checksum engine may be "seeded" with an initial value, which
1821 * the application would need to compute based on the specific protocol's
1822 * requirements. Note that the seed is given in host byte order (little-
1823 * endian), not network byte order (big-endian); code written to compute a
1824 * pseudo-header checksum in network byte order will need to byte-swap it
1825 * before use as the seed.
1826 *
1827 * Note that the checksum is computed as part of the transmission process,
1828 * so it will not be present in the packet upon completion of this routine.
1829 *
1830 * @param[in,out] mmd Pointer to packet's minimal metadata.
1831 * @param[in] pkt Packet on which to operate.
1832 * @param[in] start Offset within L2 packet of the first byte to include in
1833 * the checksum.
1834 * @param[in] length Number of bytes to include in the checksum.
1835 * the checksum.
1836 * @param[in] location Offset within L2 packet of the first of the two bytes
1837 * to be replaced with the calculated checksum.
1838 * @param[in] seed Initial value of the running checksum before any of the
1839 * packet data is added.
1840 */
1841static __inline void
1842NETIO_PKT_DO_EGRESS_CSUM_MM(netio_pkt_minimal_metadata_t* mmd,
1843 netio_pkt_t* pkt, int start, int length,
1844 int location, uint16_t seed)
1845{
1846 mmd->csum_start = start;
1847 mmd->csum_length = length;
1848 mmd->csum_location = location;
1849 mmd->csum_seed = seed;
1850 mmd->flags |= _NETIO_PKT_NEED_EDMA_CSUM_MASK;
1851}
1852
1853
1854/** Set up an egress packet for hardware checksum computation.
1855 * @ingroup egress
1856 *
1857 * NetIO provides the ability to automatically calculate a standard
1858 * 16-bit Internet checksum on transmitted packets. The application
1859 * may specify the point in the packet where the checksum starts, the
1860 * number of bytes to be checksummed, and the two bytes in the packet
1861 * which will be replaced with the completed checksum. (If the range
1862 * of bytes to be checksummed includes the bytes to be replaced, the
1863 * initial values of those bytes will be included in the checksum.)
1864 *
1865 * For some protocols, the packet checksum covers data which is not present
1866 * in the packet, or is at least not contiguous to the main data payload.
1867 * For instance, the TCP checksum includes a "pseudo-header" which includes
1868 * the source and destination IP addresses of the packet. To accommodate
1869 * this, the checksum engine may be "seeded" with an initial value, which
1870 * the application would need to compute based on the specific protocol's
1871 * requirements. Note that the seed is given in host byte order (little-
1872 * endian), not network byte order (big-endian); code written to compute a
1873 * pseudo-header checksum in network byte order will need to byte-swap it
1874 * before use as the seed.
1875 *
1876 * Note that the checksum is computed as part of the transmission process,
1877 * so it will not be present in the packet upon completion of this routine.
1878 *
1879 * @param[in,out] pkt Packet on which to operate.
1880 * @param[in] start Offset within L2 packet of the first byte to include in
1881 * the checksum.
1882 * @param[in] length Number of bytes to include in the checksum.
1883 * the checksum.
1884 * @param[in] location Offset within L2 packet of the first of the two bytes
1885 * to be replaced with the calculated checksum.
1886 * @param[in] seed Initial value of the running checksum before any of the
1887 * packet data is added.
1888 */
1889static __inline void
1890NETIO_PKT_DO_EGRESS_CSUM(netio_pkt_t* pkt, int start, int length,
1891 int location, uint16_t seed)
1892{
1893 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1894
1895 NETIO_PKT_DO_EGRESS_CSUM_MM(mmd, pkt, start, length, location, seed);
1896}
1897
1898
1899/** Return the number of bytes which could be prepended to a packet, using a
1900 * metadata pointer to speed the operation.
1901 * See @ref netio_populate_prepend_buffer() to get a full description of
1902 * prepending.
1903 *
1904 * @param[in,out] mda Pointer to packet's standard metadata.
1905 * @param[in] pkt Packet on which to operate.
1906 */
1907static __inline int
1908NETIO_PKT_PREPEND_AVAIL_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
1909{
1910 return (pkt->__packet.bits.__offset << 6) +
1911 NETIO_PKT_CUSTOM_HEADER_LENGTH_M(mda, pkt);
1912}
1913
1914
1915/** Return the number of bytes which could be prepended to a packet, using a
1916 * metadata pointer to speed the operation.
1917 * See @ref netio_populate_prepend_buffer() to get a full description of
1918 * prepending.
1919 * @ingroup egress
1920 *
1921 * @param[in,out] mmd Pointer to packet's minimal metadata.
1922 * @param[in] pkt Packet on which to operate.
1923 */
1924static __inline int
1925NETIO_PKT_PREPEND_AVAIL_MM(netio_pkt_minimal_metadata_t* mmd, netio_pkt_t* pkt)
1926{
1927 return (pkt->__packet.bits.__offset << 6) + mmd->l2_offset;
1928}
1929
1930
1931/** Return the number of bytes which could be prepended to a packet.
1932 * See @ref netio_populate_prepend_buffer() to get a full description of
1933 * prepending.
1934 * @ingroup egress
1935 *
1936 * @param[in] pkt Packet on which to operate.
1937 */
1938static __inline int
1939NETIO_PKT_PREPEND_AVAIL(netio_pkt_t* pkt)
1940{
1941 if (NETIO_PKT_IS_MINIMAL(pkt))
1942 {
1943 netio_pkt_minimal_metadata_t* mmd = NETIO_PKT_MINIMAL_METADATA(pkt);
1944
1945 return NETIO_PKT_PREPEND_AVAIL_MM(mmd, pkt);
1946 }
1947 else
1948 {
1949 netio_pkt_metadata_t* mda = NETIO_PKT_METADATA(pkt);
1950
1951 return NETIO_PKT_PREPEND_AVAIL_M(mda, pkt);
1952 }
1953}
1954
1955
1956/** Flush a packet's minimal metadata from the cache, using a metadata pointer
1957 * to speed the operation.
1958 * @ingroup egress
1959 *
1960 * @param[in] mmd Pointer to packet's minimal metadata.
1961 * @param[in] pkt Packet on which to operate.
1962 */
1963static __inline void
1964NETIO_PKT_FLUSH_MINIMAL_METADATA_MM(netio_pkt_minimal_metadata_t* mmd,
1965 netio_pkt_t* pkt)
1966{
1967}
1968
1969
1970/** Invalidate a packet's minimal metadata from the cache, using a metadata
1971 * pointer to speed the operation.
1972 * @ingroup egress
1973 *
1974 * @param[in] mmd Pointer to packet's minimal metadata.
1975 * @param[in] pkt Packet on which to operate.
1976 */
1977static __inline void
1978NETIO_PKT_INV_MINIMAL_METADATA_MM(netio_pkt_minimal_metadata_t* mmd,
1979 netio_pkt_t* pkt)
1980{
1981}
1982
1983
1984/** Flush and then invalidate a packet's minimal metadata from the cache,
1985 * using a metadata pointer to speed the operation.
1986 * @ingroup egress
1987 *
1988 * @param[in] mmd Pointer to packet's minimal metadata.
1989 * @param[in] pkt Packet on which to operate.
1990 */
1991static __inline void
1992NETIO_PKT_FLUSH_INV_MINIMAL_METADATA_MM(netio_pkt_minimal_metadata_t* mmd,
1993 netio_pkt_t* pkt)
1994{
1995}
1996
1997
1998/** Flush a packet's metadata from the cache, using a metadata pointer
1999 * to speed the operation.
2000 * @ingroup ingress
2001 *
2002 * @param[in] mda Pointer to packet's minimal metadata.
2003 * @param[in] pkt Packet on which to operate.
2004 */
2005static __inline void
2006NETIO_PKT_FLUSH_METADATA_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
2007{
2008}
2009
2010
2011/** Invalidate a packet's metadata from the cache, using a metadata
2012 * pointer to speed the operation.
2013 * @ingroup ingress
2014 *
2015 * @param[in] mda Pointer to packet's metadata.
2016 * @param[in] pkt Packet on which to operate.
2017 */
2018static __inline void
2019NETIO_PKT_INV_METADATA_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
2020{
2021}
2022
2023
2024/** Flush and then invalidate a packet's metadata from the cache,
2025 * using a metadata pointer to speed the operation.
2026 * @ingroup ingress
2027 *
2028 * @param[in] mda Pointer to packet's metadata.
2029 * @param[in] pkt Packet on which to operate.
2030 */
2031static __inline void
2032NETIO_PKT_FLUSH_INV_METADATA_M(netio_pkt_metadata_t* mda, netio_pkt_t* pkt)
2033{
2034}
2035
2036
2037/** Flush a packet's minimal metadata from the cache.
2038 * @ingroup egress
2039 *
2040 * @param[in] pkt Packet on which to operate.
2041 */
2042static __inline void
2043NETIO_PKT_FLUSH_MINIMAL_METADATA(netio_pkt_t* pkt)
2044{
2045}
2046
2047
2048/** Invalidate a packet's minimal metadata from the cache.
2049 * @ingroup egress
2050 *
2051 * @param[in] pkt Packet on which to operate.
2052 */
2053static __inline void
2054NETIO_PKT_INV_MINIMAL_METADATA(netio_pkt_t* pkt)
2055{
2056}
2057
2058
2059/** Flush and then invalidate a packet's minimal metadata from the cache.
2060 * @ingroup egress
2061 *
2062 * @param[in] pkt Packet on which to operate.
2063 */
2064static __inline void
2065NETIO_PKT_FLUSH_INV_MINIMAL_METADATA(netio_pkt_t* pkt)
2066{
2067}
2068
2069
2070/** Flush a packet's metadata from the cache.
2071 * @ingroup ingress
2072 *
2073 * @param[in] pkt Packet on which to operate.
2074 */
2075static __inline void
2076NETIO_PKT_FLUSH_METADATA(netio_pkt_t* pkt)
2077{
2078}
2079
2080
2081/** Invalidate a packet's metadata from the cache.
2082 * @ingroup ingress
2083 *
2084 * @param[in] pkt Packet on which to operate.
2085 */
2086static __inline void
2087NETIO_PKT_INV_METADATA(netio_pkt_t* pkt)
2088{
2089}
2090
2091
2092/** Flush and then invalidate a packet's metadata from the cache.
2093 * @ingroup ingress
2094 *
2095 * @param[in] pkt Packet on which to operate.
2096 */
2097static __inline void
2098NETIO_PKT_FLUSH_INV_METADATA(netio_pkt_t* pkt)
2099{
2100}
2101
2102/** Number of NUMA nodes we can distribute buffers to.
2103 * @ingroup setup */
2104#define NETIO_NUM_NODE_WEIGHTS 16
2105
2106/**
2107 * @brief An object for specifying the characteristics of NetIO communication
2108 * endpoint.
2109 *
2110 * @ingroup setup
2111 *
2112 * The @ref netio_input_register() function uses this structure to define
2113 * how an application tile will communicate with an IPP.
2114 *
2115 *
2116 * Future updates to NetIO may add new members to this structure,
2117 * which can affect the success of the registration operation. Thus,
2118 * if dynamically initializing the structure, applications are urged to
2119 * zero it out first, for example:
2120 *
2121 * @code
2122 * netio_input_config_t config;
2123 * memset(&config, 0, sizeof (config));
2124 * config.flags = NETIO_RECV | NETIO_XMIT_CSUM | NETIO_TAG_NONE;
2125 * config.num_receive_packets = NETIO_MAX_RECEIVE_PKTS;
2126 * config.queue_id = 0;
2127 * .
2128 * .
2129 * .
2130 * @endcode
2131 *
2132 * since that guarantees that any unused structure members, including
2133 * members which did not exist when the application was first developed,
2134 * will not have unexpected values.
2135 *
2136 * If statically initializing the structure, we strongly recommend use of
2137 * C99-style named initializers, for example:
2138 *
2139 * @code
2140 * netio_input_config_t config = {
2141 * .flags = NETIO_RECV | NETIO_XMIT_CSUM | NETIO_TAG_NONE,
2142 * .num_receive_packets = NETIO_MAX_RECEIVE_PKTS,
2143 * .queue_id = 0,
2144 * },
2145 * @endcode
2146 *
2147 * instead of the old-style structure initialization:
2148 *
2149 * @code
2150 * // Bad example! Currently equivalent to the above, but don't do this.
2151 * netio_input_config_t config = {
2152 * NETIO_RECV | NETIO_XMIT_CSUM | NETIO_TAG_NONE, NETIO_MAX_RECEIVE_PKTS, 0
2153 * },
2154 * @endcode
2155 *
2156 * since the C99 style requires no changes to the code if elements of the
2157 * config structure are rearranged. (It also makes the initialization much
2158 * easier to understand.)
2159 *
2160 * Except for items which address a particular tile's transmit or receive
2161 * characteristics, such as the ::NETIO_RECV flag, applications are advised
2162 * to specify the same set of configuration data on all registrations.
2163 * This prevents differing results if multiple tiles happen to do their
2164 * registration operations in a different order on different invocations of
2165 * the application. This is particularly important for things like link
2166 * management flags, and buffer size and homing specifications.
2167 *
2168 * Unless the ::NETIO_FIXED_BUFFER_VA flag is specified in flags, the NetIO
2169 * buffer pool is automatically created and mapped into the application's
2170 * virtual address space at an address chosen by the operating system,
2171 * using the common memory (cmem) facility in the Tilera Multicore
2172 * Components library. The cmem facility allows multiple processes to gain
2173 * access to shared memory which is mapped into each process at an
2174 * identical virtual address. In order for this to work, the processes
2175 * must have a common ancestor, which must create the common memory using
2176 * tmc_cmem_init().
2177 *
2178 * In programs using the iLib process creation API, or in programs which use
2179 * only one process (which include programs using the pthreads library),
2180 * tmc_cmem_init() is called automatically. All other applications
2181 * must call it explicitly, before any child processes which might call
2182 * netio_input_register() are created.
2183 */
2184typedef struct
2185{
2186 /** Registration characteristics.
2187
2188 This value determines several characteristics of the registration;
2189 flags for different types of behavior are ORed together to make the
2190 final flag value. Generally applications should specify exactly
2191 one flag from each of the following categories:
2192
2193 - Whether the application will be receiving packets on this queue
2194 (::NETIO_RECV or ::NETIO_NO_RECV).
2195
2196 - Whether the application will be transmitting packets on this queue,
2197 and if so, whether it will request egress checksum calculation
2198 (::NETIO_XMIT, ::NETIO_XMIT_CSUM, or ::NETIO_NO_XMIT). It is
2199 legal to call netio_get_buffer() without one of the XMIT flags,
2200 as long as ::NETIO_RECV is specified; in this case, the retrieved
2201 buffers must be passed to another tile for transmission.
2202
2203 - Whether the application expects any vendor-specific tags in
2204 its packets' L2 headers (::NETIO_TAG_NONE, ::NETIO_TAG_BRCM,
2205 or ::NETIO_TAG_MRVL). This must match the configuration of the
2206 target IPP.
2207
2208 To accommodate applications written to previous versions of the NetIO
2209 interface, none of the flags above are currently required; if omitted,
2210 NetIO behaves more or less as if ::NETIO_RECV | ::NETIO_XMIT_CSUM |
2211 ::NETIO_TAG_NONE were used. However, explicit specification of
2212 the relevant flags allows NetIO to do a better job of resource
2213 allocation, allows earlier detection of certain configuration errors,
2214 and may enable advanced features or higher performance in the future,
2215 so their use is strongly recommended.
2216
2217 Note that specifying ::NETIO_NO_RECV along with ::NETIO_NO_XMIT
2218 is a special case, intended primarily for use by programs which
2219 retrieve network statistics or do link management operations.
2220 When these flags are both specified, the resulting queue may not
2221 be used with NetIO routines other than netio_get(), netio_set(),
2222 and netio_input_unregister(). See @ref link for more information
2223 on link management.
2224
2225 Other flags are optional; their use is described below.
2226 */
2227 int flags;
2228
2229 /** Interface name. This is a string which identifies the specific
2230 Ethernet controller hardware to be used. The format of the string
2231 is a device type and a device index, separated by a slash; so,
2232 the first 10 Gigabit Ethernet controller is named "xgbe/0", while
2233 the second 10/100/1000 Megabit Ethernet controller is named "gbe/1".
2234 */
2235 const char* interface;
2236
2237 /** Receive packet queue size. This specifies the maximum number
2238 of ingress packets that can be received on this queue without
2239 being retrieved by @ref netio_get_packet(). If the IPP's distribution
2240 algorithm calls for a packet to be sent to this queue, and this
2241 number of packets are already pending there, the new packet
2242 will either be discarded, or sent to another tile registered
2243 for the same queue_id (see @ref drops). This value must
2244 be at least ::NETIO_MIN_RECEIVE_PKTS, can always be at least
2245 ::NETIO_MAX_RECEIVE_PKTS, and may be larger than that on certain
2246 interfaces.
2247 */
2248 int num_receive_packets;
2249
2250 /** The queue ID being requested. Legal values for this range from 0
2251 to ::NETIO_MAX_QUEUE_ID, inclusive. ::NETIO_MAX_QUEUE_ID is always
2252 greater than or equal to the number of tiles; this allows one queue
2253 for each tile, plus at least one additional queue. Some applications
2254 may wish to use the additional queue as a destination for unwanted
2255 packets, since packets delivered to queues for which no tiles have
2256 registered are discarded.
2257 */
2258 unsigned int queue_id;
2259
2260 /** Maximum number of small send buffers to be held in the local empty
2261 buffer cache. This specifies the size of the area which holds
2262 empty small egress buffers requested from the IPP but not yet
2263 retrieved via @ref netio_get_buffer(). This value must be greater
2264 than zero if the application will ever use @ref netio_get_buffer()
2265 to allocate empty small egress buffers; it may be no larger than
2266 ::NETIO_MAX_SEND_BUFFERS. See @ref epp for more details on empty
2267 buffer caching.
2268 */
2269 int num_send_buffers_small_total;
2270
2271 /** Number of small send buffers to be preallocated at registration.
2272 If this value is nonzero, the specified number of empty small egress
2273 buffers will be requested from the IPP during the netio_input_register
2274 operation; this may speed the execution of @ref netio_get_buffer().
2275 This may be no larger than @ref num_send_buffers_small_total. See @ref
2276 epp for more details on empty buffer caching.
2277 */
2278 int num_send_buffers_small_prealloc;
2279
2280 /** Maximum number of large send buffers to be held in the local empty
2281 buffer cache. This specifies the size of the area which holds empty
2282 large egress buffers requested from the IPP but not yet retrieved via
2283 @ref netio_get_buffer(). This value must be greater than zero if the
2284 application will ever use @ref netio_get_buffer() to allocate empty
2285 large egress buffers; it may be no larger than ::NETIO_MAX_SEND_BUFFERS.
2286 See @ref epp for more details on empty buffer caching.
2287 */
2288 int num_send_buffers_large_total;
2289
2290 /** Number of large send buffers to be preallocated at registration.
2291 If this value is nonzero, the specified number of empty large egress
2292 buffers will be requested from the IPP during the netio_input_register
2293 operation; this may speed the execution of @ref netio_get_buffer().
2294 This may be no larger than @ref num_send_buffers_large_total. See @ref
2295 epp for more details on empty buffer caching.
2296 */
2297 int num_send_buffers_large_prealloc;
2298
2299 /** Maximum number of jumbo send buffers to be held in the local empty
2300 buffer cache. This specifies the size of the area which holds empty
2301 jumbo egress buffers requested from the IPP but not yet retrieved via
2302 @ref netio_get_buffer(). This value must be greater than zero if the
2303 application will ever use @ref netio_get_buffer() to allocate empty
2304 jumbo egress buffers; it may be no larger than ::NETIO_MAX_SEND_BUFFERS.
2305 See @ref epp for more details on empty buffer caching.
2306 */
2307 int num_send_buffers_jumbo_total;
2308
2309 /** Number of jumbo send buffers to be preallocated at registration.
2310 If this value is nonzero, the specified number of empty jumbo egress
2311 buffers will be requested from the IPP during the netio_input_register
2312 operation; this may speed the execution of @ref netio_get_buffer().
2313 This may be no larger than @ref num_send_buffers_jumbo_total. See @ref
2314 epp for more details on empty buffer caching.
2315 */
2316 int num_send_buffers_jumbo_prealloc;
2317
2318 /** Total packet buffer size. This determines the total size, in bytes,
2319 of the NetIO buffer pool. Note that the maximum number of available
2320 buffers of each size is determined during hypervisor configuration
2321 (see the <em>System Programmer's Guide</em> for details); this just
2322 influences how much host memory is allocated for those buffers.
2323
2324 The buffer pool is allocated from common memory, which will be
2325 automatically initialized if needed. If your buffer pool is larger
2326 than 240 MB, you might need to explicitly call @c tmc_cmem_init(),
2327 as described in the Application Libraries Reference Manual (UG227).
2328
2329 Packet buffers are currently allocated in chunks of 16 MB; this
2330 value will be rounded up to the next larger multiple of 16 MB.
2331 If this value is zero, a default of 32 MB will be used; this was
2332 the value used by previous versions of NetIO. Note that taking this
2333 default also affects the placement of buffers on Linux NUMA nodes.
2334 See @ref buffer_node_weights for an explanation of buffer placement.
2335
2336 In order to successfully allocate packet buffers, Linux must have
2337 available huge pages on the relevant Linux NUMA nodes. See the
2338 <em>System Programmer's Guide</em> for information on configuring
2339 huge page support in Linux.
2340 */
2341 uint64_t total_buffer_size;
2342
2343 /** Buffer placement weighting factors.
2344
2345 This array specifies the relative amount of buffering to place
2346 on each of the available Linux NUMA nodes. This array is
2347 indexed by the NUMA node, and the values in the array are
2348 proportional to the amount of buffer space to allocate on that
2349 node.
2350
2351 If memory striping is enabled in the Hypervisor, then there is
2352 only one logical NUMA node (node 0). In that case, NetIO will by
2353 default ignore the suggested buffer node weights, and buffers
2354 will be striped across the physical memory controllers. See
2355 UG209 System Programmer's Guide for a description of the
2356 hypervisor option that controls memory striping.
2357
2358 If memory striping is disabled, then there are up to four NUMA
2359 nodes, corresponding to the four DDRAM controllers in the TILE
2360 processor architecture. See UG100 Tile Processor Architecture
2361 Overview for a diagram showing the location of each of the DDRAM
2362 controllers relative to the tile array.
2363
2364 For instance, if memory striping is disabled, the following
2365 configuration strucure:
2366
2367 @code
2368 netio_input_config_t config = {
2369 .
2370 .
2371 .
2372 .total_buffer_size = 4 * 16 * 1024 * 1024;
2373 .buffer_node_weights = { 1, 0, 1, 0 },
2374 },
2375 @endcode
2376
2377 would result in 32 MB of buffers being placed on controller 0, and
2378 32 MB on controller 2. (Since buffers are allocated in units of
2379 16 MB, some sets of weights will not be able to be matched exactly.)
2380
2381 For the weights to be effective, @ref total_buffer_size must be
2382 nonzero. If @ref total_buffer_size is zero, causing the default
2383 32 MB of buffer space to be used, then any specified weights will
2384 be ignored, and buffers will positioned as they were in previous
2385 versions of NetIO:
2386
2387 - For xgbe/0 and gbe/0, 16 MB of buffers will be placed on controller 1,
2388 and the other 16 MB will be placed on controller 2.
2389
2390 - For xgbe/1 and gbe/1, 16 MB of buffers will be placed on controller 2,
2391 and the other 16 MB will be placed on controller 3.
2392
2393 If @ref total_buffer_size is nonzero, but all weights are zero,
2394 then all buffer space will be allocated on Linux NUMA node zero.
2395
2396 By default, the specified buffer placement is treated as a hint;
2397 if sufficient free memory is not available on the specified
2398 controllers, the buffers will be allocated elsewhere. However,
2399 if the ::NETIO_STRICT_HOMING flag is specified in @ref flags, then a
2400 failure to allocate buffer space exactly as requested will cause the
2401 registration operation to fail with an error of ::NETIO_CANNOT_HOME.
2402
2403 Note that maximal network performance cannot be achieved with
2404 only one memory controller.
2405 */
2406 uint8_t buffer_node_weights[NETIO_NUM_NODE_WEIGHTS];
2407
2408 /** Fixed virtual address for packet buffers. Only valid when
2409 ::NETIO_FIXED_BUFFER_VA is specified in @ref flags; see the
2410 description of that flag for details.
2411 */
2412 void* fixed_buffer_va;
2413
2414 /**
2415 Maximum number of outstanding send packet requests. This value is
2416 only relevant when an EPP is in use; it determines the number of
2417 slots in the EPP's outgoing packet queue which this tile is allowed
2418 to consume, and thus the number of packets which may be sent before
2419 the sending tile must wait for an acknowledgment from the EPP.
2420 Modifying this value is generally only helpful when using @ref
2421 netio_send_packet_vector(), where it can help improve performance by
2422 allowing a single vector send operation to process more packets.
2423 Typically it is not specified, and the default, which divides the
2424 outgoing packet slots evenly between all tiles on the chip, is used.
2425
2426 If a registration asks for more outgoing packet queue slots than are
2427 available, ::NETIO_TOOMANY_XMIT will be returned. The total number
2428 of packet queue slots which are available for all tiles for each EPP
2429 is subject to change, but is currently ::NETIO_TOTAL_SENDS_OUTSTANDING.
2430
2431
2432 This value is ignored if ::NETIO_XMIT is not specified in flags.
2433 If you want to specify a large value here for a specific tile, you are
2434 advised to specify NETIO_NO_XMIT on other, non-transmitting tiles so
2435 that they do not consume a default number of packet slots. Any tile
2436 transmitting is required to have at least ::NETIO_MIN_SENDS_OUTSTANDING
2437 slots allocated to it; values less than that will be silently
2438 increased by the NetIO library.
2439 */
2440 int num_sends_outstanding;
2441}
2442netio_input_config_t;
2443
2444
2445/** Registration flags; used in the @ref netio_input_config_t structure.
2446 * @addtogroup setup
2447 */
2448/** @{ */
2449
2450/** Fail a registration request if we can't put packet buffers
2451 on the specified memory controllers. */
2452#define NETIO_STRICT_HOMING 0x00000002
2453
2454/** This application expects no tags on its L2 headers. */
2455#define NETIO_TAG_NONE 0x00000004
2456
2457/** This application expects Marvell extended tags on its L2 headers. */
2458#define NETIO_TAG_MRVL 0x00000008
2459
2460/** This application expects Broadcom tags on its L2 headers. */
2461#define NETIO_TAG_BRCM 0x00000010
2462
2463/** This registration may call routines which receive packets. */
2464#define NETIO_RECV 0x00000020
2465
2466/** This registration may not call routines which receive packets. */
2467#define NETIO_NO_RECV 0x00000040
2468
2469/** This registration may call routines which transmit packets. */
2470#define NETIO_XMIT 0x00000080
2471
2472/** This registration may call routines which transmit packets with
2473 checksum acceleration. */
2474#define NETIO_XMIT_CSUM 0x00000100
2475
2476/** This registration may not call routines which transmit packets. */
2477#define NETIO_NO_XMIT 0x00000200
2478
2479/** This registration wants NetIO buffers mapped at an application-specified
2480 virtual address.
2481
2482 NetIO buffers are by default created by the TMC common memory facility,
2483 which must be configured by a common ancestor of all processes sharing
2484 a network interface. When this flag is specified, NetIO buffers are
2485 instead mapped at an address chosen by the application (and specified
2486 in @ref netio_input_config_t::fixed_buffer_va). This allows multiple
2487 unrelated but cooperating processes to share a NetIO interface.
2488 All processes sharing the same interface must specify this flag,
2489 and all must specify the same fixed virtual address.
2490
2491 @ref netio_input_config_t::fixed_buffer_va must be a
2492 multiple of 16 MB, and the packet buffers will occupy @ref
2493 netio_input_config_t::total_buffer_size bytes of virtual address
2494 space, beginning at that address. If any of those virtual addresses
2495 are currently occupied by other memory objects, like application or
2496 shared library code or data, @ref netio_input_register() will return
2497 ::NETIO_FAULT. While it is impossible to provide a fixed_buffer_va
2498 which will work for all applications, a good first guess might be to
2499 use 0xb0000000 minus @ref netio_input_config_t::total_buffer_size.
2500 If that fails, it might be helpful to consult the running application's
2501 virtual address description file (/proc/<em>pid</em>/maps) to see
2502 which regions of virtual address space are available.
2503 */
2504#define NETIO_FIXED_BUFFER_VA 0x00000400
2505
2506/** This registration call will not complete unless the network link
2507 is up. The process will wait several seconds for this to happen (the
2508 precise interval is link-dependent), but if the link does not come up,
2509 ::NETIO_LINK_DOWN will be returned. This flag is the default if
2510 ::NETIO_NOREQUIRE_LINK_UP is not specified. Note that this flag by
2511 itself does not request that the link be brought up; that can be done
2512 with the ::NETIO_AUTO_LINK_UPDN or ::NETIO_AUTO_LINK_UP flags (the
2513 latter is the default if no NETIO_AUTO_LINK_xxx flags are specified),
2514 or by explicitly setting the link's desired state via netio_set().
2515 If the link is not brought up by one of those methods, and this flag
2516 is specified, the registration operation will return ::NETIO_LINK_DOWN.
2517 This flag is ignored if it is specified along with ::NETIO_NO_XMIT and
2518 ::NETIO_NO_RECV. See @ref link for more information on link
2519 management.
2520 */
2521#define NETIO_REQUIRE_LINK_UP 0x00000800
2522
2523/** This registration call will complete even if the network link is not up.
2524 Whenever the link is not up, packets will not be sent or received:
2525 netio_get_packet() will return ::NETIO_NOPKT once all queued packets
2526 have been drained, and netio_send_packet() and similar routines will
2527 return NETIO_QUEUE_FULL once the outgoing packet queue in the EPP
2528 or the I/O shim is full. See @ref link for more information on link
2529 management.
2530 */
2531#define NETIO_NOREQUIRE_LINK_UP 0x00001000
2532
2533#ifndef __DOXYGEN__
2534/*
2535 * These are part of the implementation of the NETIO_AUTO_LINK_xxx flags,
2536 * but should not be used directly by applications, and are thus not
2537 * documented.
2538 */
2539#define _NETIO_AUTO_UP 0x00002000
2540#define _NETIO_AUTO_DN 0x00004000
2541#define _NETIO_AUTO_PRESENT 0x00008000
2542#endif
2543
2544/** Set the desired state of the link to up, allowing any speeds which are
2545 supported by the link hardware, as part of this registration operation.
2546 Do not take down the link automatically. This is the default if
2547 no other NETIO_AUTO_LINK_xxx flags are specified. This flag is ignored
2548 if it is specified along with ::NETIO_NO_XMIT and ::NETIO_NO_RECV.
2549 See @ref link for more information on link management.
2550 */
2551#define NETIO_AUTO_LINK_UP (_NETIO_AUTO_PRESENT | _NETIO_AUTO_UP)
2552
2553/** Set the desired state of the link to up, allowing any speeds which are
2554 supported by the link hardware, as part of this registration operation.
2555 Set the desired state of the link to down the next time no tiles are
2556 registered for packet reception or transmission. This flag is ignored
2557 if it is specified along with ::NETIO_NO_XMIT and ::NETIO_NO_RECV.
2558 See @ref link for more information on link management.
2559 */
2560#define NETIO_AUTO_LINK_UPDN (_NETIO_AUTO_PRESENT | _NETIO_AUTO_UP | \
2561 _NETIO_AUTO_DN)
2562
2563/** Set the desired state of the link to down the next time no tiles are
2564 registered for packet reception or transmission. This flag is ignored
2565 if it is specified along with ::NETIO_NO_XMIT and ::NETIO_NO_RECV.
2566 See @ref link for more information on link management.
2567 */
2568#define NETIO_AUTO_LINK_DN (_NETIO_AUTO_PRESENT | _NETIO_AUTO_DN)
2569
2570/** Do not bring up the link automatically as part of this registration
2571 operation. Do not take down the link automatically. This flag
2572 is ignored if it is specified along with ::NETIO_NO_XMIT and
2573 ::NETIO_NO_RECV. See @ref link for more information on link management.
2574 */
2575#define NETIO_AUTO_LINK_NONE _NETIO_AUTO_PRESENT
2576
2577
2578/** Minimum number of receive packets. */
2579#define NETIO_MIN_RECEIVE_PKTS 16
2580
2581/** Lower bound on the maximum number of receive packets; may be higher
2582 than this on some interfaces. */
2583#define NETIO_MAX_RECEIVE_PKTS 128
2584
2585/** Maximum number of send buffers, per packet size. */
2586#define NETIO_MAX_SEND_BUFFERS 16
2587
2588/** Number of EPP queue slots, and thus outstanding sends, per EPP. */
2589#define NETIO_TOTAL_SENDS_OUTSTANDING 2015
2590
2591/** Minimum number of EPP queue slots, and thus outstanding sends, per
2592 * transmitting tile. */
2593#define NETIO_MIN_SENDS_OUTSTANDING 16
2594
2595
2596/**@}*/
2597
2598#ifndef __DOXYGEN__
2599
2600/**
2601 * An object for providing Ethernet packets to a process.
2602 */
2603struct __netio_queue_impl_t;
2604
2605/**
2606 * An object for managing the user end of a NetIO queue.
2607 */
2608struct __netio_queue_user_impl_t;
2609
2610#endif /* !__DOXYGEN__ */
2611
2612
2613/** A netio_queue_t describes a NetIO communications endpoint.
2614 * @ingroup setup
2615 */
2616typedef struct
2617{
2618#ifdef __DOXYGEN__
2619 uint8_t opaque[8]; /**< This is an opaque structure. */
2620#else
2621 struct __netio_queue_impl_t* __system_part; /**< The system part. */
2622 struct __netio_queue_user_impl_t* __user_part; /**< The user part. */
2623#ifdef _NETIO_PTHREAD
2624 _netio_percpu_mutex_t lock; /**< Queue lock. */
2625#endif
2626#endif
2627}
2628netio_queue_t;
2629
2630
2631/**
2632 * @brief Packet send context.
2633 *
2634 * @ingroup egress
2635 *
2636 * Packet send context for use with netio_send_packet_prepare and _commit.
2637 */
2638typedef struct
2639{
2640#ifdef __DOXYGEN__
2641 uint8_t opaque[44]; /**< This is an opaque structure. */
2642#else
2643 uint8_t flags; /**< Defined below */
2644 uint8_t datalen; /**< Number of valid words pointed to by data. */
2645 uint32_t request[9]; /**< Request to be sent to the EPP or shim. Note
2646 that this is smaller than the 11-word maximum
2647 request size, since some constant values are
2648 not saved in the context. */
2649 uint32_t *data; /**< Data to be sent to the EPP or shim via IDN. */
2650#endif
2651}
2652netio_send_pkt_context_t;
2653
2654
2655#ifndef __DOXYGEN__
2656#define SEND_PKT_CTX_USE_EPP 1 /**< We're sending to an EPP. */
2657#define SEND_PKT_CTX_SEND_CSUM 2 /**< Request includes a checksum. */
2658#endif
2659
2660/**
2661 * @brief Packet vector entry.
2662 *
2663 * @ingroup egress
2664 *
2665 * This data structure is used with netio_send_packet_vector() to send multiple
2666 * packets with one NetIO call. The structure should be initialized by
2667 * calling netio_pkt_vector_set(), rather than by setting the fields
2668 * directly.
2669 *
2670 * This structure is guaranteed to be a power of two in size, no
2671 * bigger than one L2 cache line, and to be aligned modulo its size.
2672 */
2673typedef struct
2674#ifndef __DOXYGEN__
2675__attribute__((aligned(8)))
2676#endif
2677{
2678 /** Reserved for use by the user application. When initialized with
2679 * the netio_set_pkt_vector_entry() function, this field is guaranteed
2680 * to be visible to readers only after all other fields are already
2681 * visible. This way it can be used as a valid flag or generation
2682 * counter. */
2683 uint8_t user_data;
2684
2685 /* Structure members below this point should not be accessed directly by
2686 * applications, as they may change in the future. */
2687
2688 /** Low 8 bits of the packet address to send. The high bits are
2689 * acquired from the 'handle' field. */
2690 uint8_t buffer_address_low;
2691
2692 /** Number of bytes to transmit. */
2693 uint16_t size;
2694
2695 /** The raw handle from a netio_pkt_t. If this is NETIO_PKT_HANDLE_NONE,
2696 * this vector entry will be skipped and no packet will be transmitted. */
2697 netio_pkt_handle_t handle;
2698}
2699netio_pkt_vector_entry_t;
2700
2701
2702/**
2703 * @brief Initialize fields in a packet vector entry.
2704 *
2705 * @ingroup egress
2706 *
2707 * @param[out] v Pointer to the vector entry to be initialized.
2708 * @param[in] pkt Packet to be transmitted when the vector entry is passed to
2709 * netio_send_packet_vector(). Note that the packet's attributes
2710 * (e.g., its L2 offset and length) are captured at the time this
2711 * routine is called; subsequent changes in those attributes will not
2712 * be reflected in the packet which is actually transmitted.
2713 * Changes in the packet's contents, however, will be so reflected.
2714 * If this is NULL, no packet will be transmitted.
2715 * @param[in] user_data User data to be set in the vector entry.
2716 * This function guarantees that the "user_data" field will become
2717 * visible to a reader only after all other fields have become visible.
2718 * This allows a structure in a ring buffer to be written and read
2719 * by a polling reader without any locks or other synchronization.
2720 */
2721static __inline void
2722netio_pkt_vector_set(volatile netio_pkt_vector_entry_t* v, netio_pkt_t* pkt,
2723 uint8_t user_data)
2724{
2725 if (pkt)
2726 {
2727 if (NETIO_PKT_IS_MINIMAL(pkt))
2728 {
2729 netio_pkt_minimal_metadata_t* mmd =
2730 (netio_pkt_minimal_metadata_t*) &pkt->__metadata;
2731 v->buffer_address_low = (uintptr_t) NETIO_PKT_L2_DATA_MM(mmd, pkt) & 0xFF;
2732 v->size = NETIO_PKT_L2_LENGTH_MM(mmd, pkt);
2733 }
2734 else
2735 {
2736 netio_pkt_metadata_t* mda = &pkt->__metadata;
2737 v->buffer_address_low = (uintptr_t) NETIO_PKT_L2_DATA_M(mda, pkt) & 0xFF;
2738 v->size = NETIO_PKT_L2_LENGTH_M(mda, pkt);
2739 }
2740 v->handle.word = pkt->__packet.word;
2741 }
2742 else
2743 {
2744 v->handle.word = 0; /* Set handle to NETIO_PKT_HANDLE_NONE. */
2745 }
2746
2747 __asm__("" : : : "memory");
2748
2749 v->user_data = user_data;
2750}
2751
2752
2753/**
2754 * Flags and structures for @ref netio_get() and @ref netio_set().
2755 * @ingroup config
2756 */
2757
2758/** @{ */
2759/** Parameter class; addr is a NETIO_PARAM_xxx value. */
2760#define NETIO_PARAM 0
2761/** Interface MAC address. This address is only valid with @ref netio_get().
2762 * The value is a 6-byte MAC address. Depending upon the overall system
2763 * design, a MAC address may or may not be available for each interface. */
2764#define NETIO_PARAM_MAC 0
2765
2766/** Determine whether to suspend output on the receipt of pause frames.
2767 * If the value is nonzero, the I/O shim will suspend output when a pause
2768 * frame is received. If the value is zero, pause frames will be ignored. */
2769#define NETIO_PARAM_PAUSE_IN 1
2770
2771/** Determine whether to send pause frames if the I/O shim packet FIFOs are
2772 * nearly full. If the value is zero, pause frames are not sent. If
2773 * the value is nonzero, it is the delay value which will be sent in any
2774 * pause frames which are output, in units of 512 bit times. */
2775#define NETIO_PARAM_PAUSE_OUT 2
2776
2777/** Jumbo frame support. The value is a 4-byte integer. If the value is
2778 * nonzero, the MAC will accept frames of up to 10240 bytes. If the value
2779 * is zero, the MAC will only accept frames of up to 1544 bytes. */
2780#define NETIO_PARAM_JUMBO 3
2781
2782/** I/O shim's overflow statistics register. The value is two 16-bit integers.
2783 * The first 16-bit value (or the low 16 bits, if the value is treated as a
2784 * 32-bit number) is the count of packets which were completely dropped and
2785 * not delivered by the shim. The second 16-bit value (or the high 16 bits,
2786 * if the value is treated as a 32-bit number) is the count of packets
2787 * which were truncated and thus only partially delivered by the shim. This
2788 * register is automatically reset to zero after it has been read.
2789 */
2790#define NETIO_PARAM_OVERFLOW 4
2791
2792/** IPP statistics. This address is only valid with @ref netio_get(). The
2793 * value is a netio_stat_t structure. Unlike the I/O shim statistics, the
2794 * IPP statistics are not all reset to zero on read; see the description
2795 * of the netio_stat_t for details. */
2796#define NETIO_PARAM_STAT 5
2797
2798/** Possible link state. The value is a combination of "NETIO_LINK_xxx"
2799 * flags. With @ref netio_get(), this will indicate which flags are
2800 * actually supported by the hardware.
2801 *
2802 * For historical reasons, specifying this value to netio_set() will have
2803 * the same behavior as using ::NETIO_PARAM_LINK_CONFIG, but this usage is
2804 * discouraged.
2805 */
2806#define NETIO_PARAM_LINK_POSSIBLE_STATE 6
2807
2808/** Link configuration. The value is a combination of "NETIO_LINK_xxx" flags.
2809 * With @ref netio_set(), this will attempt to immediately bring up the
2810 * link using whichever of the requested flags are supported by the
2811 * hardware, or take down the link if the flags are zero; if this is
2812 * not possible, an error will be returned. Many programs will want
2813 * to use ::NETIO_PARAM_LINK_DESIRED_STATE instead.
2814 *
2815 * For historical reasons, specifying this value to netio_get() will
2816 * have the same behavior as using ::NETIO_PARAM_LINK_POSSIBLE_STATE,
2817 * but this usage is discouraged.
2818 */
2819#define NETIO_PARAM_LINK_CONFIG NETIO_PARAM_LINK_POSSIBLE_STATE
2820
2821/** Current link state. This address is only valid with @ref netio_get().
2822 * The value is zero or more of the "NETIO_LINK_xxx" flags, ORed together.
2823 * If the link is down, the value ANDed with NETIO_LINK_SPEED will be
2824 * zero; if the link is up, the value ANDed with NETIO_LINK_SPEED will
2825 * result in exactly one of the NETIO_LINK_xxx values, indicating the
2826 * current speed. */
2827#define NETIO_PARAM_LINK_CURRENT_STATE 7
2828
2829/** Variant symbol for current state, retained for compatibility with
2830 * pre-MDE-2.1 programs. */
2831#define NETIO_PARAM_LINK_STATUS NETIO_PARAM_LINK_CURRENT_STATE
2832
2833/** Packet Coherence protocol. This address is only valid with @ref netio_get().
2834 * The value is nonzero if the interface is configured for cache-coherent DMA.
2835 */
2836#define NETIO_PARAM_COHERENT 8
2837
2838/** Desired link state. The value is a conbination of "NETIO_LINK_xxx"
2839 * flags, which specify the desired state for the link. With @ref
2840 * netio_set(), this will, in the background, attempt to bring up the link
2841 * using whichever of the requested flags are reasonable, or take down the
2842 * link if the flags are zero. The actual link up or down operation may
2843 * happen after this call completes. If the link state changes in the
2844 * future, the system will continue to try to get back to the desired link
2845 * state; for instance, if the link is brought up successfully, and then
2846 * the network cable is disconnected, the link will go down. However, the
2847 * desired state of the link is still up, so if the cable is reconnected,
2848 * the link will be brought up again.
2849 *
2850 * With @ref netio_get(), this will indicate the desired state for the
2851 * link, as set with a previous netio_set() call, or implicitly by a
2852 * netio_input_register() or netio_input_unregister() operation. This may
2853 * not reflect the current state of the link; to get that, use
2854 * ::NETIO_PARAM_LINK_CURRENT_STATE. */
2855#define NETIO_PARAM_LINK_DESIRED_STATE 9
2856
2857/** NetIO statistics structure. Retrieved using the ::NETIO_PARAM_STAT
2858 * address passed to @ref netio_get(). */
2859typedef struct
2860{
2861 /** Number of packets which have been received by the IPP and forwarded
2862 * to a tile's receive queue for processing. This value wraps at its
2863 * maximum, and is not cleared upon read. */
2864 uint32_t packets_received;
2865
2866 /** Number of packets which have been dropped by the IPP, because they could
2867 * not be received, or could not be forwarded to a tile. The former happens
2868 * when the IPP does not have a free packet buffer of suitable size for an
2869 * incoming frame. The latter happens when all potential destination tiles
2870 * for a packet, as defined by the group, bucket, and queue configuration,
2871 * have full receive queues. This value wraps at its maximum, and is not
2872 * cleared upon read. */
2873 uint32_t packets_dropped;
2874
2875 /*
2876 * Note: the #defines after each of the following four one-byte values
2877 * denote their location within the third word of the netio_stat_t. They
2878 * are intended for use only by the IPP implementation and are thus omitted
2879 * from the Doxygen output.
2880 */
2881
2882 /** Number of packets dropped because no worker was able to accept a new
2883 * packet. This value saturates at its maximum, and is cleared upon
2884 * read. */
2885 uint8_t drops_no_worker;
2886#ifndef __DOXYGEN__
2887#define NETIO_STAT_DROPS_NO_WORKER 0
2888#endif
2889
2890 /** Number of packets dropped because no small buffers were available.
2891 * This value saturates at its maximum, and is cleared upon read. */
2892 uint8_t drops_no_smallbuf;
2893#ifndef __DOXYGEN__
2894#define NETIO_STAT_DROPS_NO_SMALLBUF 1
2895#endif
2896
2897 /** Number of packets dropped because no large buffers were available.
2898 * This value saturates at its maximum, and is cleared upon read. */
2899 uint8_t drops_no_largebuf;
2900#ifndef __DOXYGEN__
2901#define NETIO_STAT_DROPS_NO_LARGEBUF 2
2902#endif
2903
2904 /** Number of packets dropped because no jumbo buffers were available.
2905 * This value saturates at its maximum, and is cleared upon read. */
2906 uint8_t drops_no_jumbobuf;
2907#ifndef __DOXYGEN__
2908#define NETIO_STAT_DROPS_NO_JUMBOBUF 3
2909#endif
2910}
2911netio_stat_t;
2912
2913
2914/** Link can run, should run, or is running at 10 Mbps. */
2915#define NETIO_LINK_10M 0x01
2916
2917/** Link can run, should run, or is running at 100 Mbps. */
2918#define NETIO_LINK_100M 0x02
2919
2920/** Link can run, should run, or is running at 1 Gbps. */
2921#define NETIO_LINK_1G 0x04
2922
2923/** Link can run, should run, or is running at 10 Gbps. */
2924#define NETIO_LINK_10G 0x08
2925
2926/** Link should run at the highest speed supported by the link and by
2927 * the device connected to the link. Only usable as a value for
2928 * the link's desired state; never returned as a value for the current
2929 * or possible states. */
2930#define NETIO_LINK_ANYSPEED 0x10
2931
2932/** All legal link speeds. */
2933#define NETIO_LINK_SPEED (NETIO_LINK_10M | \
2934 NETIO_LINK_100M | \
2935 NETIO_LINK_1G | \
2936 NETIO_LINK_10G | \
2937 NETIO_LINK_ANYSPEED)
2938
2939
2940/** MAC register class. Addr is a register offset within the MAC.
2941 * Registers within the XGbE and GbE MACs are documented in the Tile
2942 * Processor I/O Device Guide (UG104). MAC registers start at address
2943 * 0x4000, and do not include the MAC_INTERFACE registers. */
2944#define NETIO_MAC 1
2945
2946/** MDIO register class (IEEE 802.3 clause 22 format). Addr is the "addr"
2947 * member of a netio_mdio_addr_t structure. */
2948#define NETIO_MDIO 2
2949
2950/** MDIO register class (IEEE 802.3 clause 45 format). Addr is the "addr"
2951 * member of a netio_mdio_addr_t structure. */
2952#define NETIO_MDIO_CLAUSE45 3
2953
2954/** NetIO MDIO address type. Retrieved or provided using the ::NETIO_MDIO
2955 * address passed to @ref netio_get() or @ref netio_set(). */
2956typedef union
2957{
2958 struct
2959 {
2960 unsigned int reg:16; /**< MDIO register offset. For clause 22 access,
2961 must be less than 32. */
2962 unsigned int phy:5; /**< Which MDIO PHY to access. */
2963 unsigned int dev:5; /**< Which MDIO device to access within that PHY.
2964 Applicable for clause 45 access only; ignored
2965 for clause 22 access. */
2966 }
2967 bits; /**< Container for bitfields. */
2968 uint64_t addr; /**< Value to pass to @ref netio_get() or
2969 * @ref netio_set(). */
2970}
2971netio_mdio_addr_t;
2972
2973/** @} */
2974
2975#endif /* __NETIO_INTF_H__ */
diff --git a/arch/tile/kernel/Makefile b/arch/tile/kernel/Makefile
index 112b1e248f05..b4c8e8ec45dc 100644
--- a/arch/tile/kernel/Makefile
+++ b/arch/tile/kernel/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_SMP) += smpboot.o smp.o tlb.o
15obj-$(CONFIG_MODULES) += module.o 15obj-$(CONFIG_MODULES) += module.o
16obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 16obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
17obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o 17obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
18obj-$(CONFIG_PCI) += pci.o
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c
index 67617a05e602..dbc213adf5e1 100644
--- a/arch/tile/kernel/compat.c
+++ b/arch/tile/kernel/compat.c
@@ -21,7 +21,6 @@
21#include <linux/kdev_t.h> 21#include <linux/kdev_t.h>
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/fcntl.h> 23#include <linux/fcntl.h>
24#include <linux/smp_lock.h>
25#include <linux/uaccess.h> 24#include <linux/uaccess.h>
26#include <linux/signal.h> 25#include <linux/signal.h>
27#include <asm/syscalls.h> 26#include <asm/syscalls.h>
diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c
index fb64b99959d4..dbb0dfc7bece 100644
--- a/arch/tile/kernel/compat_signal.c
+++ b/arch/tile/kernel/compat_signal.c
@@ -15,7 +15,6 @@
15#include <linux/sched.h> 15#include <linux/sched.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/kernel.h> 18#include <linux/kernel.h>
20#include <linux/signal.h> 19#include <linux/signal.h>
21#include <linux/errno.h> 20#include <linux/errno.h>
@@ -291,12 +290,12 @@ long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
291 return ret; 290 return ret;
292} 291}
293 292
293/* The assembly shim for this function arranges to ignore the return value. */
294long compat_sys_rt_sigreturn(struct pt_regs *regs) 294long compat_sys_rt_sigreturn(struct pt_regs *regs)
295{ 295{
296 struct compat_rt_sigframe __user *frame = 296 struct compat_rt_sigframe __user *frame =
297 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp); 297 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp);
298 sigset_t set; 298 sigset_t set;
299 long r0;
300 299
301 if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) 300 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
302 goto badframe; 301 goto badframe;
@@ -309,13 +308,13 @@ long compat_sys_rt_sigreturn(struct pt_regs *regs)
309 recalc_sigpending(); 308 recalc_sigpending();
310 spin_unlock_irq(&current->sighand->siglock); 309 spin_unlock_irq(&current->sighand->siglock);
311 310
312 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0)) 311 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
313 goto badframe; 312 goto badframe;
314 313
315 if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0) 314 if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0)
316 goto badframe; 315 goto badframe;
317 316
318 return r0; 317 return 0;
319 318
320badframe: 319badframe:
321 force_sig(SIGSEGV, current); 320 force_sig(SIGSEGV, current);
diff --git a/arch/tile/kernel/intvec_32.S b/arch/tile/kernel/intvec_32.S
index f5821626247f..5eed4a02bf62 100644
--- a/arch/tile/kernel/intvec_32.S
+++ b/arch/tile/kernel/intvec_32.S
@@ -1342,8 +1342,8 @@ handle_syscall:
1342 lw r20, r20 1342 lw r20, r20
1343 1343
1344 /* Jump to syscall handler. */ 1344 /* Jump to syscall handler. */
1345 jalr r20; .Lhandle_syscall_link: 1345 jalr r20
1346 FEEDBACK_REENTER(handle_syscall) 1346.Lhandle_syscall_link: /* value of "lr" after "jalr r20" above */
1347 1347
1348 /* 1348 /*
1349 * Write our r0 onto the stack so it gets restored instead 1349 * Write our r0 onto the stack so it gets restored instead
@@ -1352,6 +1352,9 @@ handle_syscall:
1352 PTREGS_PTR(r29, PTREGS_OFFSET_REG(0)) 1352 PTREGS_PTR(r29, PTREGS_OFFSET_REG(0))
1353 sw r29, r0 1353 sw r29, r0
1354 1354
1355.Lsyscall_sigreturn_skip:
1356 FEEDBACK_REENTER(handle_syscall)
1357
1355 /* Do syscall trace again, if requested. */ 1358 /* Do syscall trace again, if requested. */
1356 lw r30, r31 1359 lw r30, r31
1357 andi r30, r30, _TIF_SYSCALL_TRACE 1360 andi r30, r30, _TIF_SYSCALL_TRACE
@@ -1536,9 +1539,24 @@ STD_ENTRY_LOCAL(bad_intr)
1536 }; \ 1539 }; \
1537 STD_ENDPROC(_##x) 1540 STD_ENDPROC(_##x)
1538 1541
1542/*
1543 * Special-case sigreturn to not write r0 to the stack on return.
1544 * This is technically more efficient, but it also avoids difficulties
1545 * in the 64-bit OS when handling 32-bit compat code, since we must not
1546 * sign-extend r0 for the sigreturn return-value case.
1547 */
1548#define PTREGS_SYSCALL_SIGRETURN(x, reg) \
1549 STD_ENTRY(_##x); \
1550 addli lr, lr, .Lsyscall_sigreturn_skip - .Lhandle_syscall_link; \
1551 { \
1552 PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \
1553 j x \
1554 }; \
1555 STD_ENDPROC(_##x)
1556
1539PTREGS_SYSCALL(sys_execve, r3) 1557PTREGS_SYSCALL(sys_execve, r3)
1540PTREGS_SYSCALL(sys_sigaltstack, r2) 1558PTREGS_SYSCALL(sys_sigaltstack, r2)
1541PTREGS_SYSCALL(sys_rt_sigreturn, r0) 1559PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0)
1542PTREGS_SYSCALL(sys_cmpxchg_badaddr, r1) 1560PTREGS_SYSCALL(sys_cmpxchg_badaddr, r1)
1543 1561
1544/* Save additional callee-saves to pt_regs, put address in r4 and jump. */ 1562/* Save additional callee-saves to pt_regs, put address in r4 and jump. */
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
new file mode 100644
index 000000000000..a1ee25be9ad9
--- /dev/null
+++ b/arch/tile/kernel/pci.c
@@ -0,0 +1,621 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15#include <linux/kernel.h>
16#include <linux/pci.h>
17#include <linux/delay.h>
18#include <linux/string.h>
19#include <linux/init.h>
20#include <linux/capability.h>
21#include <linux/sched.h>
22#include <linux/errno.h>
23#include <linux/bootmem.h>
24#include <linux/irq.h>
25#include <linux/io.h>
26#include <linux/uaccess.h>
27
28#include <asm/processor.h>
29#include <asm/sections.h>
30#include <asm/byteorder.h>
31#include <asm/hv_driver.h>
32#include <hv/drv_pcie_rc_intf.h>
33
34
35/*
36 * Initialization flow and process
37 * -------------------------------
38 *
39 * This files containes the routines to search for PCI buses,
40 * enumerate the buses, and configure any attached devices.
41 *
42 * There are two entry points here:
43 * 1) tile_pci_init
44 * This sets up the pci_controller structs, and opens the
45 * FDs to the hypervisor. This is called from setup_arch() early
46 * in the boot process.
47 * 2) pcibios_init
48 * This probes the PCI bus(es) for any attached hardware. It's
49 * called by subsys_initcall. All of the real work is done by the
50 * generic Linux PCI layer.
51 *
52 */
53
54/*
55 * This flag tells if the platform is TILEmpower that needs
56 * special configuration for the PLX switch chip.
57 */
58int __write_once tile_plx_gen1;
59
60static struct pci_controller controllers[TILE_NUM_PCIE];
61static int num_controllers;
62
63static struct pci_ops tile_cfg_ops;
64
65
66/*
67 * We don't need to worry about the alignment of resources.
68 */
69resource_size_t pcibios_align_resource(void *data, const struct resource *res,
70 resource_size_t size, resource_size_t align)
71{
72 return res->start;
73}
74EXPORT_SYMBOL(pcibios_align_resource);
75
76/*
77 * Open a FD to the hypervisor PCI device.
78 *
79 * controller_id is the controller number, config type is 0 or 1 for
80 * config0 or config1 operations.
81 */
82static int __init tile_pcie_open(int controller_id, int config_type)
83{
84 char filename[32];
85 int fd;
86
87 sprintf(filename, "pcie/%d/config%d", controller_id, config_type);
88
89 fd = hv_dev_open((HV_VirtAddr)filename, 0);
90
91 return fd;
92}
93
94
95/*
96 * Get the IRQ numbers from the HV and set up the handlers for them.
97 */
98static int __init tile_init_irqs(int controller_id,
99 struct pci_controller *controller)
100{
101 char filename[32];
102 int fd;
103 int ret;
104 int x;
105 struct pcie_rc_config rc_config;
106
107 sprintf(filename, "pcie/%d/ctl", controller_id);
108 fd = hv_dev_open((HV_VirtAddr)filename, 0);
109 if (fd < 0) {
110 pr_err("PCI: hv_dev_open(%s) failed\n", filename);
111 return -1;
112 }
113 ret = hv_dev_pread(fd, 0, (HV_VirtAddr)(&rc_config),
114 sizeof(rc_config), PCIE_RC_CONFIG_MASK_OFF);
115 hv_dev_close(fd);
116 if (ret != sizeof(rc_config)) {
117 pr_err("PCI: wanted %zd bytes, got %d\n",
118 sizeof(rc_config), ret);
119 return -1;
120 }
121 /* Record irq_base so that we can map INTx to IRQ # later. */
122 controller->irq_base = rc_config.intr;
123
124 for (x = 0; x < 4; x++)
125 tile_irq_activate(rc_config.intr + x,
126 TILE_IRQ_HW_CLEAR);
127
128 if (rc_config.plx_gen1)
129 controller->plx_gen1 = 1;
130
131 return 0;
132}
133
134/*
135 * First initialization entry point, called from setup_arch().
136 *
137 * Find valid controllers and fill in pci_controller structs for each
138 * of them.
139 *
140 * Returns the number of controllers discovered.
141 */
142int __init tile_pci_init(void)
143{
144 int i;
145
146 pr_info("PCI: Searching for controllers...\n");
147
148 /* Do any configuration we need before using the PCIe */
149
150 for (i = 0; i < TILE_NUM_PCIE; i++) {
151 int hv_cfg_fd0 = -1;
152 int hv_cfg_fd1 = -1;
153 int hv_mem_fd = -1;
154 char name[32];
155 struct pci_controller *controller;
156
157 /*
158 * Open the fd to the HV. If it fails then this
159 * device doesn't exist.
160 */
161 hv_cfg_fd0 = tile_pcie_open(i, 0);
162 if (hv_cfg_fd0 < 0)
163 continue;
164 hv_cfg_fd1 = tile_pcie_open(i, 1);
165 if (hv_cfg_fd1 < 0) {
166 pr_err("PCI: Couldn't open config fd to HV "
167 "for controller %d\n", i);
168 goto err_cont;
169 }
170
171 sprintf(name, "pcie/%d/mem", i);
172 hv_mem_fd = hv_dev_open((HV_VirtAddr)name, 0);
173 if (hv_mem_fd < 0) {
174 pr_err("PCI: Could not open mem fd to HV!\n");
175 goto err_cont;
176 }
177
178 pr_info("PCI: Found PCI controller #%d\n", i);
179
180 controller = &controllers[num_controllers];
181
182 if (tile_init_irqs(i, controller)) {
183 pr_err("PCI: Could not initialize "
184 "IRQs, aborting.\n");
185 goto err_cont;
186 }
187
188 controller->index = num_controllers;
189 controller->hv_cfg_fd[0] = hv_cfg_fd0;
190 controller->hv_cfg_fd[1] = hv_cfg_fd1;
191 controller->hv_mem_fd = hv_mem_fd;
192 controller->first_busno = 0;
193 controller->last_busno = 0xff;
194 controller->ops = &tile_cfg_ops;
195
196 num_controllers++;
197 continue;
198
199err_cont:
200 if (hv_cfg_fd0 >= 0)
201 hv_dev_close(hv_cfg_fd0);
202 if (hv_cfg_fd1 >= 0)
203 hv_dev_close(hv_cfg_fd1);
204 if (hv_mem_fd >= 0)
205 hv_dev_close(hv_mem_fd);
206 continue;
207 }
208
209 /*
210 * Before using the PCIe, see if we need to do any platform-specific
211 * configuration, such as the PLX switch Gen 1 issue on TILEmpower.
212 */
213 for (i = 0; i < num_controllers; i++) {
214 struct pci_controller *controller = &controllers[i];
215
216 if (controller->plx_gen1)
217 tile_plx_gen1 = 1;
218 }
219
220 return num_controllers;
221}
222
223/*
224 * (pin - 1) converts from the PCI standard's [1:4] convention to
225 * a normal [0:3] range.
226 */
227static int tile_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
228{
229 struct pci_controller *controller =
230 (struct pci_controller *)dev->sysdata;
231 return (pin - 1) + controller->irq_base;
232}
233
234
235static void __init fixup_read_and_payload_sizes(void)
236{
237 struct pci_dev *dev = NULL;
238 int smallest_max_payload = 0x1; /* Tile maxes out at 256 bytes. */
239 int max_read_size = 0x2; /* Limit to 512 byte reads. */
240 u16 new_values;
241
242 /* Scan for the smallest maximum payload size. */
243 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
244 int pcie_caps_offset;
245 u32 devcap;
246 int max_payload;
247
248 pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP);
249 if (pcie_caps_offset == 0)
250 continue;
251
252 pci_read_config_dword(dev, pcie_caps_offset + PCI_EXP_DEVCAP,
253 &devcap);
254 max_payload = devcap & PCI_EXP_DEVCAP_PAYLOAD;
255 if (max_payload < smallest_max_payload)
256 smallest_max_payload = max_payload;
257 }
258
259 /* Now, set the max_payload_size for all devices to that value. */
260 new_values = (max_read_size << 12) | (smallest_max_payload << 5);
261 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
262 int pcie_caps_offset;
263 u16 devctl;
264
265 pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP);
266 if (pcie_caps_offset == 0)
267 continue;
268
269 pci_read_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL,
270 &devctl);
271 devctl &= ~(PCI_EXP_DEVCTL_PAYLOAD | PCI_EXP_DEVCTL_READRQ);
272 devctl |= new_values;
273 pci_write_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL,
274 devctl);
275 }
276}
277
278
279/*
280 * Second PCI initialization entry point, called by subsys_initcall.
281 *
282 * The controllers have been set up by the time we get here, by a call to
283 * tile_pci_init.
284 */
285static int __init pcibios_init(void)
286{
287 int i;
288
289 pr_info("PCI: Probing PCI hardware\n");
290
291 /*
292 * Delay a bit in case devices aren't ready. Some devices are
293 * known to require at least 20ms here, but we use a more
294 * conservative value.
295 */
296 mdelay(250);
297
298 /* Scan all of the recorded PCI controllers. */
299 for (i = 0; i < num_controllers; i++) {
300 struct pci_controller *controller = &controllers[i];
301 struct pci_bus *bus;
302
303 pr_info("PCI: initializing controller #%d\n", i);
304
305 /*
306 * This comes from the generic Linux PCI driver.
307 *
308 * It reads the PCI tree for this bus into the Linux
309 * data structures.
310 *
311 * This is inlined in linux/pci.h and calls into
312 * pci_scan_bus_parented() in probe.c.
313 */
314 bus = pci_scan_bus(0, controller->ops, controller);
315 controller->root_bus = bus;
316 controller->last_busno = bus->subordinate;
317
318 }
319
320 /* Do machine dependent PCI interrupt routing */
321 pci_fixup_irqs(pci_common_swizzle, tile_map_irq);
322
323 /*
324 * This comes from the generic Linux PCI driver.
325 *
326 * It allocates all of the resources (I/O memory, etc)
327 * associated with the devices read in above.
328 */
329
330 pci_assign_unassigned_resources();
331
332 /* Configure the max_read_size and max_payload_size values. */
333 fixup_read_and_payload_sizes();
334
335 /* Record the I/O resources in the PCI controller structure. */
336 for (i = 0; i < num_controllers; i++) {
337 struct pci_bus *root_bus = controllers[i].root_bus;
338 struct pci_bus *next_bus;
339 struct pci_dev *dev;
340
341 list_for_each_entry(dev, &root_bus->devices, bus_list) {
342 /* Find the PCI host controller, ie. the 1st bridge. */
343 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI &&
344 (PCI_SLOT(dev->devfn) == 0)) {
345 next_bus = dev->subordinate;
346 controllers[i].mem_resources[0] =
347 *next_bus->resource[0];
348 controllers[i].mem_resources[1] =
349 *next_bus->resource[1];
350 controllers[i].mem_resources[2] =
351 *next_bus->resource[2];
352
353 break;
354 }
355 }
356
357 }
358
359 return 0;
360}
361subsys_initcall(pcibios_init);
362
363/*
364 * No bus fixups needed.
365 */
366void __devinit pcibios_fixup_bus(struct pci_bus *bus)
367{
368 /* Nothing needs to be done. */
369}
370
371/*
372 * This can be called from the generic PCI layer, but doesn't need to
373 * do anything.
374 */
375char __devinit *pcibios_setup(char *str)
376{
377 /* Nothing needs to be done. */
378 return str;
379}
380
381/*
382 * This is called from the generic Linux layer.
383 */
384void __init pcibios_update_irq(struct pci_dev *dev, int irq)
385{
386 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
387}
388
389/*
390 * Enable memory and/or address decoding, as appropriate, for the
391 * device described by the 'dev' struct.
392 *
393 * This is called from the generic PCI layer, and can be called
394 * for bridges or endpoints.
395 */
396int pcibios_enable_device(struct pci_dev *dev, int mask)
397{
398 u16 cmd, old_cmd;
399 u8 header_type;
400 int i;
401 struct resource *r;
402
403 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
404
405 pci_read_config_word(dev, PCI_COMMAND, &cmd);
406 old_cmd = cmd;
407 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
408 /*
409 * For bridges, we enable both memory and I/O decoding
410 * in call cases.
411 */
412 cmd |= PCI_COMMAND_IO;
413 cmd |= PCI_COMMAND_MEMORY;
414 } else {
415 /*
416 * For endpoints, we enable memory and/or I/O decoding
417 * only if they have a memory resource of that type.
418 */
419 for (i = 0; i < 6; i++) {
420 r = &dev->resource[i];
421 if (r->flags & IORESOURCE_UNSET) {
422 pr_err("PCI: Device %s not available "
423 "because of resource collisions\n",
424 pci_name(dev));
425 return -EINVAL;
426 }
427 if (r->flags & IORESOURCE_IO)
428 cmd |= PCI_COMMAND_IO;
429 if (r->flags & IORESOURCE_MEM)
430 cmd |= PCI_COMMAND_MEMORY;
431 }
432 }
433
434 /*
435 * We only write the command if it changed.
436 */
437 if (cmd != old_cmd)
438 pci_write_config_word(dev, PCI_COMMAND, cmd);
439 return 0;
440}
441
442void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
443{
444 unsigned long start = pci_resource_start(dev, bar);
445 unsigned long len = pci_resource_len(dev, bar);
446 unsigned long flags = pci_resource_flags(dev, bar);
447
448 if (!len)
449 return NULL;
450 if (max && len > max)
451 len = max;
452
453 if (!(flags & IORESOURCE_MEM)) {
454 pr_info("PCI: Trying to map invalid resource %#lx\n", flags);
455 start = 0;
456 }
457
458 return (void __iomem *)start;
459}
460EXPORT_SYMBOL(pci_iomap);
461
462
463/****************************************************************
464 *
465 * Tile PCI config space read/write routines
466 *
467 ****************************************************************/
468
469/*
470 * These are the normal read and write ops
471 * These are expanded with macros from pci_bus_read_config_byte() etc.
472 *
473 * devfn is the combined PCI slot & function.
474 *
475 * offset is in bytes, from the start of config space for the
476 * specified bus & slot.
477 */
478
479static int __devinit tile_cfg_read(struct pci_bus *bus,
480 unsigned int devfn,
481 int offset,
482 int size,
483 u32 *val)
484{
485 struct pci_controller *controller = bus->sysdata;
486 int busnum = bus->number & 0xff;
487 int slot = (devfn >> 3) & 0x1f;
488 int function = devfn & 0x7;
489 u32 addr;
490 int config_mode = 1;
491
492 /*
493 * There is no bridge between the Tile and bus 0, so we
494 * use config0 to talk to bus 0.
495 *
496 * If we're talking to a bus other than zero then we
497 * must have found a bridge.
498 */
499 if (busnum == 0) {
500 /*
501 * We fake an empty slot for (busnum == 0) && (slot > 0),
502 * since there is only one slot on bus 0.
503 */
504 if (slot) {
505 *val = 0xFFFFFFFF;
506 return 0;
507 }
508 config_mode = 0;
509 }
510
511 addr = busnum << 20; /* Bus in 27:20 */
512 addr |= slot << 15; /* Slot (device) in 19:15 */
513 addr |= function << 12; /* Function is in 14:12 */
514 addr |= (offset & 0xFFF); /* byte address in 0:11 */
515
516 return hv_dev_pread(controller->hv_cfg_fd[config_mode], 0,
517 (HV_VirtAddr)(val), size, addr);
518}
519
520
521/*
522 * See tile_cfg_read() for relevent comments.
523 * Note that "val" is the value to write, not a pointer to that value.
524 */
525static int __devinit tile_cfg_write(struct pci_bus *bus,
526 unsigned int devfn,
527 int offset,
528 int size,
529 u32 val)
530{
531 struct pci_controller *controller = bus->sysdata;
532 int busnum = bus->number & 0xff;
533 int slot = (devfn >> 3) & 0x1f;
534 int function = devfn & 0x7;
535 u32 addr;
536 int config_mode = 1;
537 HV_VirtAddr valp = (HV_VirtAddr)&val;
538
539 /*
540 * For bus 0 slot 0 we use config 0 accesses.
541 */
542 if (busnum == 0) {
543 /*
544 * We fake an empty slot for (busnum == 0) && (slot > 0),
545 * since there is only one slot on bus 0.
546 */
547 if (slot)
548 return 0;
549 config_mode = 0;
550 }
551
552 addr = busnum << 20; /* Bus in 27:20 */
553 addr |= slot << 15; /* Slot (device) in 19:15 */
554 addr |= function << 12; /* Function is in 14:12 */
555 addr |= (offset & 0xFFF); /* byte address in 0:11 */
556
557#ifdef __BIG_ENDIAN
558 /* Point to the correct part of the 32-bit "val". */
559 valp += 4 - size;
560#endif
561
562 return hv_dev_pwrite(controller->hv_cfg_fd[config_mode], 0,
563 valp, size, addr);
564}
565
566
567static struct pci_ops tile_cfg_ops = {
568 .read = tile_cfg_read,
569 .write = tile_cfg_write,
570};
571
572
573/*
574 * In the following, each PCI controller's mem_resources[1]
575 * represents its (non-prefetchable) PCI memory resource.
576 * mem_resources[0] and mem_resources[2] refer to its PCI I/O and
577 * prefetchable PCI memory resources, respectively.
578 * For more details, see pci_setup_bridge() in setup-bus.c.
579 * By comparing the target PCI memory address against the
580 * end address of controller 0, we can determine the controller
581 * that should accept the PCI memory access.
582 */
583#define TILE_READ(size, type) \
584type _tile_read##size(unsigned long addr) \
585{ \
586 type val; \
587 int idx = 0; \
588 if (addr > controllers[0].mem_resources[1].end && \
589 addr > controllers[0].mem_resources[2].end) \
590 idx = 1; \
591 if (hv_dev_pread(controllers[idx].hv_mem_fd, 0, \
592 (HV_VirtAddr)(&val), sizeof(type), addr)) \
593 pr_err("PCI: read %zd bytes at 0x%lX failed\n", \
594 sizeof(type), addr); \
595 return val; \
596} \
597EXPORT_SYMBOL(_tile_read##size)
598
599TILE_READ(b, u8);
600TILE_READ(w, u16);
601TILE_READ(l, u32);
602TILE_READ(q, u64);
603
604#define TILE_WRITE(size, type) \
605void _tile_write##size(type val, unsigned long addr) \
606{ \
607 int idx = 0; \
608 if (addr > controllers[0].mem_resources[1].end && \
609 addr > controllers[0].mem_resources[2].end) \
610 idx = 1; \
611 if (hv_dev_pwrite(controllers[idx].hv_mem_fd, 0, \
612 (HV_VirtAddr)(&val), sizeof(type), addr)) \
613 pr_err("PCI: write %zd bytes at 0x%lX failed\n", \
614 sizeof(type), addr); \
615} \
616EXPORT_SYMBOL(_tile_write##size)
617
618TILE_WRITE(b, u8);
619TILE_WRITE(w, u16);
620TILE_WRITE(l, u32);
621TILE_WRITE(q, u64);
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index 8430f45daea6..e90eb53173b0 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -212,6 +212,13 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
212 childregs->sp = sp; /* override with new user stack pointer */ 212 childregs->sp = sp; /* override with new user stack pointer */
213 213
214 /* 214 /*
215 * If CLONE_SETTLS is set, set "tp" in the new task to "r4",
216 * which is passed in as arg #5 to sys_clone().
217 */
218 if (clone_flags & CLONE_SETTLS)
219 childregs->tp = regs->regs[4];
220
221 /*
215 * Copy the callee-saved registers from the passed pt_regs struct 222 * Copy the callee-saved registers from the passed pt_regs struct
216 * into the context-switch callee-saved registers area. 223 * into the context-switch callee-saved registers area.
217 * This way when we start the interrupt-return sequence, the 224 * This way when we start the interrupt-return sequence, the
@@ -539,6 +546,7 @@ struct task_struct *__sched _switch_to(struct task_struct *prev,
539 return __switch_to(prev, next, next_current_ksp0(next)); 546 return __switch_to(prev, next, next_current_ksp0(next));
540} 547}
541 548
549/* Note there is an implicit fifth argument if (clone_flags & CLONE_SETTLS). */
542SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp, 550SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
543 void __user *, parent_tidptr, void __user *, child_tidptr, 551 void __user *, parent_tidptr, void __user *, child_tidptr,
544 struct pt_regs *, regs) 552 struct pt_regs *, regs)
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index fb0b3cbeae14..f18573643ed1 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -840,7 +840,7 @@ static int __init topology_init(void)
840 for_each_online_node(i) 840 for_each_online_node(i)
841 register_one_node(i); 841 register_one_node(i);
842 842
843 for_each_present_cpu(i) 843 for (i = 0; i < smp_height * smp_width; ++i)
844 register_cpu(&cpu_devices[i], i); 844 register_cpu(&cpu_devices[i], i);
845 845
846 return 0; 846 return 0;
diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c
index 687719d4abd1..1260321155f1 100644
--- a/arch/tile/kernel/signal.c
+++ b/arch/tile/kernel/signal.c
@@ -16,7 +16,6 @@
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/smp_lock.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/signal.h> 20#include <linux/signal.h>
22#include <linux/errno.h> 21#include <linux/errno.h>
@@ -53,7 +52,7 @@ SYSCALL_DEFINE3(sigaltstack, const stack_t __user *, uss,
53 */ 52 */
54 53
55int restore_sigcontext(struct pt_regs *regs, 54int restore_sigcontext(struct pt_regs *regs,
56 struct sigcontext __user *sc, long *pr0) 55 struct sigcontext __user *sc)
57{ 56{
58 int err = 0; 57 int err = 0;
59 int i; 58 int i;
@@ -76,17 +75,15 @@ int restore_sigcontext(struct pt_regs *regs,
76 75
77 regs->faultnum = INT_SWINT_1_SIGRETURN; 76 regs->faultnum = INT_SWINT_1_SIGRETURN;
78 77
79 err |= __get_user(*pr0, &sc->gregs[0]);
80 return err; 78 return err;
81} 79}
82 80
83/* sigreturn() returns long since it restores r0 in the interrupted code. */ 81/* The assembly shim for this function arranges to ignore the return value. */
84SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs) 82SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs)
85{ 83{
86 struct rt_sigframe __user *frame = 84 struct rt_sigframe __user *frame =
87 (struct rt_sigframe __user *)(regs->sp); 85 (struct rt_sigframe __user *)(regs->sp);
88 sigset_t set; 86 sigset_t set;
89 long r0;
90 87
91 if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) 88 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
92 goto badframe; 89 goto badframe;
@@ -99,13 +96,13 @@ SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs)
99 recalc_sigpending(); 96 recalc_sigpending();
100 spin_unlock_irq(&current->sighand->siglock); 97 spin_unlock_irq(&current->sighand->siglock);
101 98
102 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0)) 99 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
103 goto badframe; 100 goto badframe;
104 101
105 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT) 102 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
106 goto badframe; 103 goto badframe;
107 104
108 return r0; 105 return 0;
109 106
110badframe: 107badframe:
111 force_sig(SIGSEGV, current); 108 force_sig(SIGSEGV, current);
diff --git a/arch/tile/kernel/smpboot.c b/arch/tile/kernel/smpboot.c
index 74d62d098edf..b949edcec200 100644
--- a/arch/tile/kernel/smpboot.c
+++ b/arch/tile/kernel/smpboot.c
@@ -18,7 +18,6 @@
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/kernel_stat.h> 20#include <linux/kernel_stat.h>
21#include <linux/smp_lock.h>
22#include <linux/bootmem.h> 21#include <linux/bootmem.h>
23#include <linux/notifier.h> 22#include <linux/notifier.h>
24#include <linux/cpu.h> 23#include <linux/cpu.h>
diff --git a/arch/tile/kernel/sys.c b/arch/tile/kernel/sys.c
index 7e764669a022..e2187d24a9b4 100644
--- a/arch/tile/kernel/sys.c
+++ b/arch/tile/kernel/sys.c
@@ -20,7 +20,6 @@
20#include <linux/sched.h> 20#include <linux/sched.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/syscalls.h> 23#include <linux/syscalls.h>
25#include <linux/mman.h> 24#include <linux/mman.h>
26#include <linux/file.h> 25#include <linux/file.h>
diff --git a/arch/tile/lib/memchr_32.c b/arch/tile/lib/memchr_32.c
index 6235283b4859..cc3d9badf030 100644
--- a/arch/tile/lib/memchr_32.c
+++ b/arch/tile/lib/memchr_32.c
@@ -18,12 +18,24 @@
18 18
19void *memchr(const void *s, int c, size_t n) 19void *memchr(const void *s, int c, size_t n)
20{ 20{
21 const uint32_t *last_word_ptr;
22 const uint32_t *p;
23 const char *last_byte_ptr;
24 uintptr_t s_int;
25 uint32_t goal, before_mask, v, bits;
26 char *ret;
27
28 if (__builtin_expect(n == 0, 0)) {
29 /* Don't dereference any memory if the array is empty. */
30 return NULL;
31 }
32
21 /* Get an aligned pointer. */ 33 /* Get an aligned pointer. */
22 const uintptr_t s_int = (uintptr_t) s; 34 s_int = (uintptr_t) s;
23 const uint32_t *p = (const uint32_t *)(s_int & -4); 35 p = (const uint32_t *)(s_int & -4);
24 36
25 /* Create four copies of the byte for which we are looking. */ 37 /* Create four copies of the byte for which we are looking. */
26 const uint32_t goal = 0x01010101 * (uint8_t) c; 38 goal = 0x01010101 * (uint8_t) c;
27 39
28 /* Read the first word, but munge it so that bytes before the array 40 /* Read the first word, but munge it so that bytes before the array
29 * will not match goal. 41 * will not match goal.
@@ -31,23 +43,14 @@ void *memchr(const void *s, int c, size_t n)
31 * Note that this shift count expression works because we know 43 * Note that this shift count expression works because we know
32 * shift counts are taken mod 32. 44 * shift counts are taken mod 32.
33 */ 45 */
34 const uint32_t before_mask = (1 << (s_int << 3)) - 1; 46 before_mask = (1 << (s_int << 3)) - 1;
35 uint32_t v = (*p | before_mask) ^ (goal & before_mask); 47 v = (*p | before_mask) ^ (goal & before_mask);
36 48
37 /* Compute the address of the last byte. */ 49 /* Compute the address of the last byte. */
38 const char *const last_byte_ptr = (const char *)s + n - 1; 50 last_byte_ptr = (const char *)s + n - 1;
39 51
40 /* Compute the address of the word containing the last byte. */ 52 /* Compute the address of the word containing the last byte. */
41 const uint32_t *const last_word_ptr = 53 last_word_ptr = (const uint32_t *)((uintptr_t) last_byte_ptr & -4);
42 (const uint32_t *)((uintptr_t) last_byte_ptr & -4);
43
44 uint32_t bits;
45 char *ret;
46
47 if (__builtin_expect(n == 0, 0)) {
48 /* Don't dereference any memory if the array is empty. */
49 return NULL;
50 }
51 54
52 while ((bits = __insn_seqb(v, goal)) == 0) { 55 while ((bits = __insn_seqb(v, goal)) == 0) {
53 if (__builtin_expect(p == last_word_ptr, 0)) { 56 if (__builtin_expect(p == last_word_ptr, 0)) {
diff --git a/arch/tile/lib/spinlock_32.c b/arch/tile/lib/spinlock_32.c
index 485e24d62c6b..5cd1c4004eca 100644
--- a/arch/tile/lib/spinlock_32.c
+++ b/arch/tile/lib/spinlock_32.c
@@ -167,23 +167,30 @@ void arch_write_lock_slow(arch_rwlock_t *rwlock, u32 val)
167 * when we compare them. 167 * when we compare them.
168 */ 168 */
169 u32 my_ticket_; 169 u32 my_ticket_;
170 u32 iterations = 0;
170 171
171 /* Take out the next ticket; this will also stop would-be readers. */ 172 /*
172 if (val & 1) 173 * Wait until there are no readers, then bump up the next
173 val = get_rwlock(rwlock); 174 * field and capture the ticket value.
174 rwlock->lock = __insn_addb(val, 1 << WR_NEXT_SHIFT); 175 */
176 for (;;) {
177 if (!(val & 1)) {
178 if ((val >> RD_COUNT_SHIFT) == 0)
179 break;
180 rwlock->lock = val;
181 }
182 delay_backoff(iterations++);
183 val = __insn_tns((int *)&rwlock->lock);
184 }
175 185
176 /* Extract my ticket value from the original word. */ 186 /* Take out the next ticket and extract my ticket value. */
187 rwlock->lock = __insn_addb(val, 1 << WR_NEXT_SHIFT);
177 my_ticket_ = val >> WR_NEXT_SHIFT; 188 my_ticket_ = val >> WR_NEXT_SHIFT;
178 189
179 /* 190 /* Wait until the "current" field matches our ticket. */
180 * Wait until the "current" field matches our ticket, and
181 * there are no remaining readers.
182 */
183 for (;;) { 191 for (;;) {
184 u32 curr_ = val >> WR_CURR_SHIFT; 192 u32 curr_ = val >> WR_CURR_SHIFT;
185 u32 readers = val >> RD_COUNT_SHIFT; 193 u32 delta = ((my_ticket_ - curr_) & WR_MASK);
186 u32 delta = ((my_ticket_ - curr_) & WR_MASK) + !!readers;
187 if (likely(delta == 0)) 194 if (likely(delta == 0))
188 break; 195 break;
189 196
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index f295b4ac941d..dcebfc831cd6 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -24,7 +24,6 @@
24#include <linux/mman.h> 24#include <linux/mman.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/smp.h> 26#include <linux/smp.h>
27#include <linux/smp_lock.h>
28#include <linux/interrupt.h> 27#include <linux/interrupt.h>
29#include <linux/init.h> 28#include <linux/init.h>
30#include <linux/tty.h> 29#include <linux/tty.h>
diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
index 24688b697a8d..201a582c4137 100644
--- a/arch/tile/mm/hugetlbpage.c
+++ b/arch/tile/mm/hugetlbpage.c
@@ -21,7 +21,6 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/hugetlb.h> 22#include <linux/hugetlb.h>
23#include <linux/pagemap.h> 23#include <linux/pagemap.h>
24#include <linux/smp_lock.h>
25#include <linux/slab.h> 24#include <linux/slab.h>
26#include <linux/err.h> 25#include <linux/err.h>
27#include <linux/sysctl.h> 26#include <linux/sysctl.h>
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 7f7338c90784..1664cce7b0ac 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -727,6 +727,9 @@ struct winch {
727 727
728static void free_winch(struct winch *winch, int free_irq_ok) 728static void free_winch(struct winch *winch, int free_irq_ok)
729{ 729{
730 if (free_irq_ok)
731 free_irq(WINCH_IRQ, winch);
732
730 list_del(&winch->list); 733 list_del(&winch->list);
731 734
732 if (winch->pid != -1) 735 if (winch->pid != -1)
@@ -735,8 +738,6 @@ static void free_winch(struct winch *winch, int free_irq_ok)
735 os_close_file(winch->fd); 738 os_close_file(winch->fd);
736 if (winch->stack != 0) 739 if (winch->stack != 0)
737 free_stack(winch->stack, 0); 740 free_stack(winch->stack, 0);
738 if (free_irq_ok)
739 free_irq(WINCH_IRQ, winch);
740 kfree(winch); 741 kfree(winch);
741} 742}
742 743
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 340268be00b5..09bd7b585726 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -5,7 +5,6 @@
5 5
6#include "linux/stddef.h" 6#include "linux/stddef.h"
7#include "linux/fs.h" 7#include "linux/fs.h"
8#include "linux/smp_lock.h"
9#include "linux/ptrace.h" 8#include "linux/ptrace.h"
10#include "linux/sched.h" 9#include "linux/sched.h"
11#include "linux/slab.h" 10#include "linux/slab.h"
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e8327686d3c5..e330da21b84f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -21,7 +21,7 @@ config X86
21 select HAVE_UNSTABLE_SCHED_CLOCK 21 select HAVE_UNSTABLE_SCHED_CLOCK
22 select HAVE_IDE 22 select HAVE_IDE
23 select HAVE_OPROFILE 23 select HAVE_OPROFILE
24 select HAVE_PERF_EVENTS if (!M386 && !M486) 24 select HAVE_PERF_EVENTS
25 select HAVE_IRQ_WORK 25 select HAVE_IRQ_WORK
26 select HAVE_IOREMAP_PROT 26 select HAVE_IOREMAP_PROT
27 select HAVE_KPROBES 27 select HAVE_KPROBES
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 23f315c9f215..325c05294fc4 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -355,7 +355,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
355 if (heap > 0x3fffffffffffUL) 355 if (heap > 0x3fffffffffffUL)
356 error("Destination address too large"); 356 error("Destination address too large");
357#else 357#else
358 if (heap > ((-__PAGE_OFFSET-(512<<20)-1) & 0x7fffffff)) 358 if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff))
359 error("Destination address too large"); 359 error("Destination address too large");
360#endif 360#endif
361#ifndef CONFIG_RELOCATABLE 361#ifndef CONFIG_RELOCATABLE
diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c
index cbcc8d8ea93a..7a6e68e4f748 100644
--- a/arch/x86/crypto/ghash-clmulni-intel_glue.c
+++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c
@@ -10,6 +10,7 @@
10 * by the Free Software Foundation. 10 * by the Free Software Foundation.
11 */ 11 */
12 12
13#include <linux/err.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index 849813f398e7..5852519b2d0f 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -28,7 +28,6 @@
28#include <linux/syscalls.h> 28#include <linux/syscalls.h>
29#include <linux/times.h> 29#include <linux/times.h>
30#include <linux/utsname.h> 30#include <linux/utsname.h>
31#include <linux/smp_lock.h>
32#include <linux/mm.h> 31#include <linux/mm.h>
33#include <linux/uio.h> 32#include <linux/uio.h>
34#include <linux/poll.h> 33#include <linux/poll.h>
diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index 5be1542fbfaf..e99d55d74df5 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -72,6 +72,9 @@ struct e820map {
72#define BIOS_BEGIN 0x000a0000 72#define BIOS_BEGIN 0x000a0000
73#define BIOS_END 0x00100000 73#define BIOS_END 0x00100000
74 74
75#define BIOS_ROM_BASE 0xffe00000
76#define BIOS_ROM_END 0xffffffff
77
75#ifdef __KERNEL__ 78#ifdef __KERNEL__
76/* see comment in arch/x86/kernel/e820.c */ 79/* see comment in arch/x86/kernel/e820.c */
77extern struct e820map e820; 80extern struct e820map e820;
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 4d293dced62f..9479a037419f 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -216,8 +216,8 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
216} 216}
217 217
218/* Return an pointer with offset calculated */ 218/* Return an pointer with offset calculated */
219static inline unsigned long __set_fixmap_offset(enum fixed_addresses idx, 219static __always_inline unsigned long
220 phys_addr_t phys, pgprot_t flags) 220__set_fixmap_offset(enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags)
221{ 221{
222 __set_fixmap(idx, phys, flags); 222 __set_fixmap(idx, phys, flags);
223 return fix_to_virt(idx) + (phys & (PAGE_SIZE - 1)); 223 return fix_to_virt(idx) + (phys & (PAGE_SIZE - 1));
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 9e6fe391094e..f702f82aa1eb 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -79,7 +79,7 @@
79#define KVM_NUM_MMU_PAGES (1 << KVM_MMU_HASH_SHIFT) 79#define KVM_NUM_MMU_PAGES (1 << KVM_MMU_HASH_SHIFT)
80#define KVM_MIN_FREE_MMU_PAGES 5 80#define KVM_MIN_FREE_MMU_PAGES 5
81#define KVM_REFILL_PAGES 25 81#define KVM_REFILL_PAGES 25
82#define KVM_MAX_CPUID_ENTRIES 40 82#define KVM_MAX_CPUID_ENTRIES 80
83#define KVM_NR_FIXED_MTRR_REGION 88 83#define KVM_NR_FIXED_MTRR_REGION 88
84#define KVM_NR_VAR_MTRR 8 84#define KVM_NR_VAR_MTRR 8
85 85
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 3ea3dc487047..6b89f5e86021 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -128,7 +128,7 @@
128#define FAM10H_MMIO_CONF_ENABLE (1<<0) 128#define FAM10H_MMIO_CONF_ENABLE (1<<0)
129#define FAM10H_MMIO_CONF_BUSRANGE_MASK 0xf 129#define FAM10H_MMIO_CONF_BUSRANGE_MASK 0xf
130#define FAM10H_MMIO_CONF_BUSRANGE_SHIFT 2 130#define FAM10H_MMIO_CONF_BUSRANGE_SHIFT 2
131#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffff 131#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffffULL
132#define FAM10H_MMIO_CONF_BASE_SHIFT 20 132#define FAM10H_MMIO_CONF_BASE_SHIFT 20
133#define MSR_FAM10H_NODE_ID 0xc001100c 133#define MSR_FAM10H_NODE_ID 0xc001100c
134 134
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 18e3b8a8709f..ef9975812c77 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -824,27 +824,27 @@ static __always_inline void arch_spin_unlock(struct arch_spinlock *lock)
824#define __PV_IS_CALLEE_SAVE(func) \ 824#define __PV_IS_CALLEE_SAVE(func) \
825 ((struct paravirt_callee_save) { func }) 825 ((struct paravirt_callee_save) { func })
826 826
827static inline unsigned long arch_local_save_flags(void) 827static inline notrace unsigned long arch_local_save_flags(void)
828{ 828{
829 return PVOP_CALLEE0(unsigned long, pv_irq_ops.save_fl); 829 return PVOP_CALLEE0(unsigned long, pv_irq_ops.save_fl);
830} 830}
831 831
832static inline void arch_local_irq_restore(unsigned long f) 832static inline notrace void arch_local_irq_restore(unsigned long f)
833{ 833{
834 PVOP_VCALLEE1(pv_irq_ops.restore_fl, f); 834 PVOP_VCALLEE1(pv_irq_ops.restore_fl, f);
835} 835}
836 836
837static inline void arch_local_irq_disable(void) 837static inline notrace void arch_local_irq_disable(void)
838{ 838{
839 PVOP_VCALLEE0(pv_irq_ops.irq_disable); 839 PVOP_VCALLEE0(pv_irq_ops.irq_disable);
840} 840}
841 841
842static inline void arch_local_irq_enable(void) 842static inline notrace void arch_local_irq_enable(void)
843{ 843{
844 PVOP_VCALLEE0(pv_irq_ops.irq_enable); 844 PVOP_VCALLEE0(pv_irq_ops.irq_enable);
845} 845}
846 846
847static inline unsigned long arch_local_irq_save(void) 847static inline notrace unsigned long arch_local_irq_save(void)
848{ 848{
849 unsigned long f; 849 unsigned long f;
850 850
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index 7f7e577a0e39..31d84acc1512 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -11,6 +11,7 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src);
11void pvclock_read_wallclock(struct pvclock_wall_clock *wall, 11void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
12 struct pvclock_vcpu_time_info *vcpu, 12 struct pvclock_vcpu_time_info *vcpu,
13 struct timespec *ts); 13 struct timespec *ts);
14void pvclock_resume(void);
14 15
15/* 16/*
16 * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction, 17 * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
index e969f691cbfd..a501741c2335 100644
--- a/arch/x86/include/asm/uv/uv_hub.h
+++ b/arch/x86/include/asm/uv/uv_hub.h
@@ -199,6 +199,8 @@ union uvh_apicid {
199#define UVH_APICID 0x002D0E00L 199#define UVH_APICID 0x002D0E00L
200#define UV_APIC_PNODE_SHIFT 6 200#define UV_APIC_PNODE_SHIFT 6
201 201
202#define UV_APICID_HIBIT_MASK 0xffff0000
203
202/* Local Bus from cpu's perspective */ 204/* Local Bus from cpu's perspective */
203#define LOCAL_BUS_BASE 0x1c00000 205#define LOCAL_BUS_BASE 0x1c00000
204#define LOCAL_BUS_SIZE (4 * 1024 * 1024) 206#define LOCAL_BUS_SIZE (4 * 1024 * 1024)
@@ -491,8 +493,10 @@ static inline void uv_set_cpu_scir_bits(int cpu, unsigned char value)
491 } 493 }
492} 494}
493 495
496extern unsigned int uv_apicid_hibits;
494static unsigned long uv_hub_ipi_value(int apicid, int vector, int mode) 497static unsigned long uv_hub_ipi_value(int apicid, int vector, int mode)
495{ 498{
499 apicid |= uv_apicid_hibits;
496 return (1UL << UVH_IPI_INT_SEND_SHFT) | 500 return (1UL << UVH_IPI_INT_SEND_SHFT) |
497 ((apicid) << UVH_IPI_INT_APIC_ID_SHFT) | 501 ((apicid) << UVH_IPI_INT_APIC_ID_SHFT) |
498 (mode << UVH_IPI_INT_DELIVERY_MODE_SHFT) | 502 (mode << UVH_IPI_INT_DELIVERY_MODE_SHFT) |
diff --git a/arch/x86/include/asm/uv/uv_mmrs.h b/arch/x86/include/asm/uv/uv_mmrs.h
index 6d90adf4428a..20cafeac7455 100644
--- a/arch/x86/include/asm/uv/uv_mmrs.h
+++ b/arch/x86/include/asm/uv/uv_mmrs.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * SGI UV MMR definitions 6 * SGI UV MMR definitions
7 * 7 *
8 * Copyright (C) 2007-2008 Silicon Graphics, Inc. All rights reserved. 8 * Copyright (C) 2007-2010 Silicon Graphics, Inc. All rights reserved.
9 */ 9 */
10 10
11#ifndef _ASM_X86_UV_UV_MMRS_H 11#ifndef _ASM_X86_UV_UV_MMRS_H
@@ -754,6 +754,23 @@ union uvh_lb_bau_sb_descriptor_base_u {
754}; 754};
755 755
756/* ========================================================================= */ 756/* ========================================================================= */
757/* UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK */
758/* ========================================================================= */
759#define UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK 0x320130UL
760#define UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK_32 0x009f0
761
762#define UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK_BIT_ENABLES_SHFT 0
763#define UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK_BIT_ENABLES_MASK 0x00000000ffffffffUL
764
765union uvh_lb_target_physical_apic_id_mask_u {
766 unsigned long v;
767 struct uvh_lb_target_physical_apic_id_mask_s {
768 unsigned long bit_enables : 32; /* RW */
769 unsigned long rsvd_32_63 : 32; /* */
770 } s;
771};
772
773/* ========================================================================= */
757/* UVH_NODE_ID */ 774/* UVH_NODE_ID */
758/* ========================================================================= */ 775/* ========================================================================= */
759#define UVH_NODE_ID 0x0UL 776#define UVH_NODE_ID 0x0UL
diff --git a/arch/x86/include/asm/xen/interface.h b/arch/x86/include/asm/xen/interface.h
index e8506c1f0c55..1c10c88ee4e1 100644
--- a/arch/x86/include/asm/xen/interface.h
+++ b/arch/x86/include/asm/xen/interface.h
@@ -61,9 +61,9 @@ DEFINE_GUEST_HANDLE(void);
61#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) 61#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
62#endif 62#endif
63 63
64#ifndef machine_to_phys_mapping 64#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
65#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) 65#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
66#endif 66#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>__MACH2PHYS_SHIFT)
67 67
68/* Maximum number of virtual CPUs in multi-processor guests. */ 68/* Maximum number of virtual CPUs in multi-processor guests. */
69#define MAX_VIRT_CPUS 32 69#define MAX_VIRT_CPUS 32
diff --git a/arch/x86/include/asm/xen/interface_32.h b/arch/x86/include/asm/xen/interface_32.h
index 42a7e004ae5c..8413688b2571 100644
--- a/arch/x86/include/asm/xen/interface_32.h
+++ b/arch/x86/include/asm/xen/interface_32.h
@@ -32,6 +32,11 @@
32/* And the trap vector is... */ 32/* And the trap vector is... */
33#define TRAP_INSTR "int $0x82" 33#define TRAP_INSTR "int $0x82"
34 34
35#define __MACH2PHYS_VIRT_START 0xF5800000
36#define __MACH2PHYS_VIRT_END 0xF6800000
37
38#define __MACH2PHYS_SHIFT 2
39
35/* 40/*
36 * Virtual addresses beyond this are not modifiable by guest OSes. The 41 * Virtual addresses beyond this are not modifiable by guest OSes. The
37 * machine->physical mapping table starts at this address, read-only. 42 * machine->physical mapping table starts at this address, read-only.
diff --git a/arch/x86/include/asm/xen/interface_64.h b/arch/x86/include/asm/xen/interface_64.h
index 100d2662b97c..839a4811cf98 100644
--- a/arch/x86/include/asm/xen/interface_64.h
+++ b/arch/x86/include/asm/xen/interface_64.h
@@ -39,18 +39,7 @@
39#define __HYPERVISOR_VIRT_END 0xFFFF880000000000 39#define __HYPERVISOR_VIRT_END 0xFFFF880000000000
40#define __MACH2PHYS_VIRT_START 0xFFFF800000000000 40#define __MACH2PHYS_VIRT_START 0xFFFF800000000000
41#define __MACH2PHYS_VIRT_END 0xFFFF804000000000 41#define __MACH2PHYS_VIRT_END 0xFFFF804000000000
42 42#define __MACH2PHYS_SHIFT 3
43#ifndef HYPERVISOR_VIRT_START
44#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
45#define HYPERVISOR_VIRT_END mk_unsigned_long(__HYPERVISOR_VIRT_END)
46#endif
47
48#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
49#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
50#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3)
51#ifndef machine_to_phys_mapping
52#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
53#endif
54 43
55/* 44/*
56 * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base) 45 * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index dd8c1414b3d5..8760cc60a21c 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -5,6 +5,7 @@
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/spinlock.h> 6#include <linux/spinlock.h>
7#include <linux/pfn.h> 7#include <linux/pfn.h>
8#include <linux/mm.h>
8 9
9#include <asm/uaccess.h> 10#include <asm/uaccess.h>
10#include <asm/page.h> 11#include <asm/page.h>
@@ -35,6 +36,8 @@ typedef struct xpaddr {
35#define MAX_DOMAIN_PAGES \ 36#define MAX_DOMAIN_PAGES \
36 ((unsigned long)((u64)CONFIG_XEN_MAX_DOMAIN_MEMORY * 1024 * 1024 * 1024 / PAGE_SIZE)) 37 ((unsigned long)((u64)CONFIG_XEN_MAX_DOMAIN_MEMORY * 1024 * 1024 * 1024 / PAGE_SIZE))
37 38
39extern unsigned long *machine_to_phys_mapping;
40extern unsigned int machine_to_phys_order;
38 41
39extern unsigned long get_phys_to_machine(unsigned long pfn); 42extern unsigned long get_phys_to_machine(unsigned long pfn);
40extern bool set_phys_to_machine(unsigned long pfn, unsigned long mfn); 43extern bool set_phys_to_machine(unsigned long pfn, unsigned long mfn);
@@ -69,10 +72,8 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
69 if (xen_feature(XENFEAT_auto_translated_physmap)) 72 if (xen_feature(XENFEAT_auto_translated_physmap))
70 return mfn; 73 return mfn;
71 74
72#if 0
73 if (unlikely((mfn >> machine_to_phys_order) != 0)) 75 if (unlikely((mfn >> machine_to_phys_order) != 0))
74 return max_mapnr; 76 return ~0;
75#endif
76 77
77 pfn = 0; 78 pfn = 0;
78 /* 79 /*
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 9e13763b6092..1e994754d323 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -45,6 +45,7 @@ obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o
45obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o 45obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o
46obj-y += tsc.o io_delay.o rtc.o 46obj-y += tsc.o io_delay.o rtc.o
47obj-y += pci-iommu_table.o 47obj-y += pci-iommu_table.o
48obj-y += resource.o
48 49
49obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o 50obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o
50obj-y += process.o 51obj-y += process.o
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 3f838d537392..78218135b48e 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1389,6 +1389,14 @@ void __cpuinit end_local_APIC_setup(void)
1389 1389
1390 setup_apic_nmi_watchdog(NULL); 1390 setup_apic_nmi_watchdog(NULL);
1391 apic_pm_activate(); 1391 apic_pm_activate();
1392
1393 /*
1394 * Now that local APIC setup is completed for BP, configure the fault
1395 * handling for interrupt remapping.
1396 */
1397 if (!smp_processor_id() && intr_remapping_enabled)
1398 enable_drhd_fault_handling();
1399
1392} 1400}
1393 1401
1394#ifdef CONFIG_X86_X2APIC 1402#ifdef CONFIG_X86_X2APIC
diff --git a/arch/x86/kernel/apic/hw_nmi.c b/arch/x86/kernel/apic/hw_nmi.c
index cefd6942f0e9..62f6e1e55b90 100644
--- a/arch/x86/kernel/apic/hw_nmi.c
+++ b/arch/x86/kernel/apic/hw_nmi.c
@@ -17,15 +17,16 @@
17#include <linux/nmi.h> 17#include <linux/nmi.h>
18#include <linux/module.h> 18#include <linux/module.h>
19 19
20/* For reliability, we're prepared to waste bits here. */
21static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly;
22
23u64 hw_nmi_get_sample_period(void) 20u64 hw_nmi_get_sample_period(void)
24{ 21{
25 return (u64)(cpu_khz) * 1000 * 60; 22 return (u64)(cpu_khz) * 1000 * 60;
26} 23}
27 24
28#ifdef ARCH_HAS_NMI_WATCHDOG 25#ifdef ARCH_HAS_NMI_WATCHDOG
26
27/* For reliability, we're prepared to waste bits here. */
28static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly;
29
29void arch_trigger_all_cpu_backtrace(void) 30void arch_trigger_all_cpu_backtrace(void)
30{ 31{
31 int i; 32 int i;
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 7cc0a721f628..fadcd743a74f 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2430,13 +2430,12 @@ static void ack_apic_level(struct irq_data *data)
2430{ 2430{
2431 struct irq_cfg *cfg = data->chip_data; 2431 struct irq_cfg *cfg = data->chip_data;
2432 int i, do_unmask_irq = 0, irq = data->irq; 2432 int i, do_unmask_irq = 0, irq = data->irq;
2433 struct irq_desc *desc = irq_to_desc(irq);
2434 unsigned long v; 2433 unsigned long v;
2435 2434
2436 irq_complete_move(cfg); 2435 irq_complete_move(cfg);
2437#ifdef CONFIG_GENERIC_PENDING_IRQ 2436#ifdef CONFIG_GENERIC_PENDING_IRQ
2438 /* If we are moving the irq we need to mask it */ 2437 /* If we are moving the irq we need to mask it */
2439 if (unlikely(desc->status & IRQ_MOVE_PENDING)) { 2438 if (unlikely(irq_to_desc(irq)->status & IRQ_MOVE_PENDING)) {
2440 do_unmask_irq = 1; 2439 do_unmask_irq = 1;
2441 mask_ioapic(cfg); 2440 mask_ioapic(cfg);
2442 } 2441 }
@@ -3413,6 +3412,7 @@ dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask,
3413 msg.data |= MSI_DATA_VECTOR(cfg->vector); 3412 msg.data |= MSI_DATA_VECTOR(cfg->vector);
3414 msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; 3413 msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
3415 msg.address_lo |= MSI_ADDR_DEST_ID(dest); 3414 msg.address_lo |= MSI_ADDR_DEST_ID(dest);
3415 msg.address_hi = MSI_ADDR_BASE_HI | MSI_ADDR_EXT_DEST_ID(dest);
3416 3416
3417 dmar_msi_write(irq, &msg); 3417 dmar_msi_write(irq, &msg);
3418 3418
diff --git a/arch/x86/kernel/apic/probe_64.c b/arch/x86/kernel/apic/probe_64.c
index f9e4e6a54073..d8c4a6feb286 100644
--- a/arch/x86/kernel/apic/probe_64.c
+++ b/arch/x86/kernel/apic/probe_64.c
@@ -79,13 +79,6 @@ void __init default_setup_apic_routing(void)
79 /* need to update phys_pkg_id */ 79 /* need to update phys_pkg_id */
80 apic->phys_pkg_id = apicid_phys_pkg_id; 80 apic->phys_pkg_id = apicid_phys_pkg_id;
81 } 81 }
82
83 /*
84 * Now that apic routing model is selected, configure the
85 * fault handling for intr remapping.
86 */
87 if (intr_remapping_enabled)
88 enable_drhd_fault_handling();
89} 82}
90 83
91/* Same for both flat and physical. */ 84/* Same for both flat and physical. */
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 194539aea175..c1c52c341f40 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -44,6 +44,8 @@ static u64 gru_start_paddr, gru_end_paddr;
44static union uvh_apicid uvh_apicid; 44static union uvh_apicid uvh_apicid;
45int uv_min_hub_revision_id; 45int uv_min_hub_revision_id;
46EXPORT_SYMBOL_GPL(uv_min_hub_revision_id); 46EXPORT_SYMBOL_GPL(uv_min_hub_revision_id);
47unsigned int uv_apicid_hibits;
48EXPORT_SYMBOL_GPL(uv_apicid_hibits);
47static DEFINE_SPINLOCK(uv_nmi_lock); 49static DEFINE_SPINLOCK(uv_nmi_lock);
48 50
49static inline bool is_GRU_range(u64 start, u64 end) 51static inline bool is_GRU_range(u64 start, u64 end)
@@ -85,6 +87,23 @@ static void __init early_get_apic_pnode_shift(void)
85 uvh_apicid.s.pnode_shift = UV_APIC_PNODE_SHIFT; 87 uvh_apicid.s.pnode_shift = UV_APIC_PNODE_SHIFT;
86} 88}
87 89
90/*
91 * Add an extra bit as dictated by bios to the destination apicid of
92 * interrupts potentially passing through the UV HUB. This prevents
93 * a deadlock between interrupts and IO port operations.
94 */
95static void __init uv_set_apicid_hibit(void)
96{
97 union uvh_lb_target_physical_apic_id_mask_u apicid_mask;
98 unsigned long *mmr;
99
100 mmr = early_ioremap(UV_LOCAL_MMR_BASE |
101 UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK, sizeof(*mmr));
102 apicid_mask.v = *mmr;
103 early_iounmap(mmr, sizeof(*mmr));
104 uv_apicid_hibits = apicid_mask.s.bit_enables & UV_APICID_HIBIT_MASK;
105}
106
88static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id) 107static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
89{ 108{
90 int nodeid; 109 int nodeid;
@@ -102,6 +121,7 @@ static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
102 __get_cpu_var(x2apic_extra_bits) = 121 __get_cpu_var(x2apic_extra_bits) =
103 nodeid << (uvh_apicid.s.pnode_shift - 1); 122 nodeid << (uvh_apicid.s.pnode_shift - 1);
104 uv_system_type = UV_NON_UNIQUE_APIC; 123 uv_system_type = UV_NON_UNIQUE_APIC;
124 uv_set_apicid_hibit();
105 return 1; 125 return 1;
106 } 126 }
107 } 127 }
@@ -155,6 +175,7 @@ static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_ri
155 int pnode; 175 int pnode;
156 176
157 pnode = uv_apicid_to_pnode(phys_apicid); 177 pnode = uv_apicid_to_pnode(phys_apicid);
178 phys_apicid |= uv_apicid_hibits;
158 val = (1UL << UVH_IPI_INT_SEND_SHFT) | 179 val = (1UL << UVH_IPI_INT_SEND_SHFT) |
159 (phys_apicid << UVH_IPI_INT_APIC_ID_SHFT) | 180 (phys_apicid << UVH_IPI_INT_APIC_ID_SHFT) |
160 ((start_rip << UVH_IPI_INT_VECTOR_SHFT) >> 12) | 181 ((start_rip << UVH_IPI_INT_VECTOR_SHFT) >> 12) |
@@ -236,7 +257,7 @@ static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask)
236 int cpu = cpumask_first(cpumask); 257 int cpu = cpumask_first(cpumask);
237 258
238 if ((unsigned)cpu < nr_cpu_ids) 259 if ((unsigned)cpu < nr_cpu_ids)
239 return per_cpu(x86_cpu_to_apicid, cpu); 260 return per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits;
240 else 261 else
241 return BAD_APICID; 262 return BAD_APICID;
242} 263}
@@ -255,7 +276,7 @@ uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
255 if (cpumask_test_cpu(cpu, cpu_online_mask)) 276 if (cpumask_test_cpu(cpu, cpu_online_mask))
256 break; 277 break;
257 } 278 }
258 return per_cpu(x86_cpu_to_apicid, cpu); 279 return per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits;
259} 280}
260 281
261static unsigned int x2apic_get_apic_id(unsigned long x) 282static unsigned int x2apic_get_apic_id(unsigned long x)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index ed6310183efb..6d75b9145b13 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -381,6 +381,20 @@ static void release_pmc_hardware(void) {}
381 381
382#endif 382#endif
383 383
384static bool check_hw_exists(void)
385{
386 u64 val, val_new = 0;
387 int ret = 0;
388
389 val = 0xabcdUL;
390 ret |= checking_wrmsrl(x86_pmu.perfctr, val);
391 ret |= rdmsrl_safe(x86_pmu.perfctr, &val_new);
392 if (ret || val != val_new)
393 return false;
394
395 return true;
396}
397
384static void reserve_ds_buffers(void); 398static void reserve_ds_buffers(void);
385static void release_ds_buffers(void); 399static void release_ds_buffers(void);
386 400
@@ -1372,6 +1386,12 @@ void __init init_hw_perf_events(void)
1372 1386
1373 pmu_check_apic(); 1387 pmu_check_apic();
1374 1388
1389 /* sanity check that the hardware exists or is emulated */
1390 if (!check_hw_exists()) {
1391 pr_cont("Broken PMU hardware detected, software events only.\n");
1392 return;
1393 }
1394
1375 pr_cont("%s PMU driver.\n", x86_pmu.name); 1395 pr_cont("%s PMU driver.\n", x86_pmu.name);
1376 1396
1377 if (x86_pmu.quirks) 1397 if (x86_pmu.quirks)
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 1b7b31ab7d86..212a6a42527c 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -33,7 +33,6 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/poll.h> 34#include <linux/poll.h>
35#include <linux/smp.h> 35#include <linux/smp.h>
36#include <linux/smp_lock.h>
37#include <linux/major.h> 36#include <linux/major.h>
38#include <linux/fs.h> 37#include <linux/fs.h>
39#include <linux/device.h> 38#include <linux/device.h>
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 59e175e89599..591e60104278 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -395,7 +395,7 @@ sysenter_past_esp:
395 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words 395 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
396 * pushed above; +8 corresponds to copy_thread's esp0 setting. 396 * pushed above; +8 corresponds to copy_thread's esp0 setting.
397 */ 397 */
398 pushl_cfi (TI_sysenter_return-THREAD_SIZE_asm+8+4*4)(%esp) 398 pushl_cfi ((TI_sysenter_return)-THREAD_SIZE_asm+8+4*4)(%esp)
399 CFI_REL_OFFSET eip, 0 399 CFI_REL_OFFSET eip, 0
400 400
401 pushl_cfi %eax 401 pushl_cfi %eax
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index fe2690d71c0c..e3ba417e8697 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -295,6 +295,7 @@ ENDPROC(native_usergs_sysret64)
295 .endm 295 .endm
296 296
297/* save partial stack frame */ 297/* save partial stack frame */
298 .pushsection .kprobes.text, "ax"
298ENTRY(save_args) 299ENTRY(save_args)
299 XCPT_FRAME 300 XCPT_FRAME
300 cld 301 cld
@@ -334,6 +335,7 @@ ENTRY(save_args)
334 ret 335 ret
335 CFI_ENDPROC 336 CFI_ENDPROC
336END(save_args) 337END(save_args)
338 .popsection
337 339
338ENTRY(save_rest) 340ENTRY(save_rest)
339 PARTIAL_FRAME 1 REST_SKIP+8 341 PARTIAL_FRAME 1 REST_SKIP+8
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index bcece91dd311..c0dbd9ac24f0 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -60,16 +60,18 @@
60#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD) 60#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
61#endif 61#endif
62 62
63/* Number of possible pages in the lowmem region */
64LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
65
63/* Enough space to fit pagetables for the low memory linear map */ 66/* Enough space to fit pagetables for the low memory linear map */
64MAPPING_BEYOND_END = \ 67MAPPING_BEYOND_END = PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT
65 PAGE_TABLE_SIZE(((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT) << PAGE_SHIFT
66 68
67/* 69/*
68 * Worst-case size of the kernel mapping we need to make: 70 * Worst-case size of the kernel mapping we need to make:
69 * the worst-case size of the kernel itself, plus the extra we need 71 * a relocatable kernel can live anywhere in lowmem, so we need to be able
70 * to map for the linear map. 72 * to map all of lowmem.
71 */ 73 */
72KERNEL_PAGES = (KERNEL_IMAGE_SIZE + MAPPING_BEYOND_END)>>PAGE_SHIFT 74KERNEL_PAGES = LOWMEM_PAGES
73 75
74INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE_asm 76INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE_asm
75RESERVE_BRK(pagetables, INIT_MAP_SIZE) 77RESERVE_BRK(pagetables, INIT_MAP_SIZE)
@@ -620,13 +622,13 @@ ENTRY(initial_code)
620__PAGE_ALIGNED_BSS 622__PAGE_ALIGNED_BSS
621 .align PAGE_SIZE_asm 623 .align PAGE_SIZE_asm
622#ifdef CONFIG_X86_PAE 624#ifdef CONFIG_X86_PAE
623initial_pg_pmd: 625ENTRY(initial_pg_pmd)
624 .fill 1024*KPMDS,4,0 626 .fill 1024*KPMDS,4,0
625#else 627#else
626ENTRY(initial_page_table) 628ENTRY(initial_page_table)
627 .fill 1024,4,0 629 .fill 1024,4,0
628#endif 630#endif
629initial_pg_fixmap: 631ENTRY(initial_pg_fixmap)
630 .fill 1024,4,0 632 .fill 1024,4,0
631ENTRY(empty_zero_page) 633ENTRY(empty_zero_page)
632 .fill 4096,1,0 634 .fill 4096,1,0
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index ae03cab4352e..4ff5968f12d2 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -27,6 +27,9 @@
27#define HPET_DEV_FSB_CAP 0x1000 27#define HPET_DEV_FSB_CAP 0x1000
28#define HPET_DEV_PERI_CAP 0x2000 28#define HPET_DEV_PERI_CAP 0x2000
29 29
30#define HPET_MIN_CYCLES 128
31#define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES + (HPET_MIN_CYCLES >> 1))
32
30#define EVT_TO_HPET_DEV(evt) container_of(evt, struct hpet_dev, evt) 33#define EVT_TO_HPET_DEV(evt) container_of(evt, struct hpet_dev, evt)
31 34
32/* 35/*
@@ -299,8 +302,9 @@ static void hpet_legacy_clockevent_register(void)
299 /* Calculate the min / max delta */ 302 /* Calculate the min / max delta */
300 hpet_clockevent.max_delta_ns = clockevent_delta2ns(0x7FFFFFFF, 303 hpet_clockevent.max_delta_ns = clockevent_delta2ns(0x7FFFFFFF,
301 &hpet_clockevent); 304 &hpet_clockevent);
302 /* 5 usec minimum reprogramming delta. */ 305 /* Setup minimum reprogramming delta. */
303 hpet_clockevent.min_delta_ns = 5000; 306 hpet_clockevent.min_delta_ns = clockevent_delta2ns(HPET_MIN_PROG_DELTA,
307 &hpet_clockevent);
304 308
305 /* 309 /*
306 * Start hpet with the boot cpu mask and make it 310 * Start hpet with the boot cpu mask and make it
@@ -393,22 +397,24 @@ static int hpet_next_event(unsigned long delta,
393 * the wraparound into account) nor a simple count down event 397 * the wraparound into account) nor a simple count down event
394 * mode. Further the write to the comparator register is 398 * mode. Further the write to the comparator register is
395 * delayed internally up to two HPET clock cycles in certain 399 * delayed internally up to two HPET clock cycles in certain
396 * chipsets (ATI, ICH9,10). We worked around that by reading 400 * chipsets (ATI, ICH9,10). Some newer AMD chipsets have even
397 * back the compare register, but that required another 401 * longer delays. We worked around that by reading back the
398 * workaround for ICH9,10 chips where the first readout after 402 * compare register, but that required another workaround for
399 * write can return the old stale value. We already have a 403 * ICH9,10 chips where the first readout after write can
400 * minimum delta of 5us enforced, but a NMI or SMI hitting 404 * return the old stale value. We already had a minimum
405 * programming delta of 5us enforced, but a NMI or SMI hitting
401 * between the counter readout and the comparator write can 406 * between the counter readout and the comparator write can
402 * move us behind that point easily. Now instead of reading 407 * move us behind that point easily. Now instead of reading
403 * the compare register back several times, we make the ETIME 408 * the compare register back several times, we make the ETIME
404 * decision based on the following: Return ETIME if the 409 * decision based on the following: Return ETIME if the
405 * counter value after the write is less than 8 HPET cycles 410 * counter value after the write is less than HPET_MIN_CYCLES
406 * away from the event or if the counter is already ahead of 411 * away from the event or if the counter is already ahead of
407 * the event. 412 * the event. The minimum programming delta for the generic
413 * clockevents code is set to 1.5 * HPET_MIN_CYCLES.
408 */ 414 */
409 res = (s32)(cnt - hpet_readl(HPET_COUNTER)); 415 res = (s32)(cnt - hpet_readl(HPET_COUNTER));
410 416
411 return res < 8 ? -ETIME : 0; 417 return res < HPET_MIN_CYCLES ? -ETIME : 0;
412} 418}
413 419
414static void hpet_legacy_set_mode(enum clock_event_mode mode, 420static void hpet_legacy_set_mode(enum clock_event_mode mode,
diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
index ff15c9dcc25d..42c594254507 100644
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -433,6 +433,10 @@ static int __kprobes hw_breakpoint_handler(struct die_args *args)
433 dr6_p = (unsigned long *)ERR_PTR(args->err); 433 dr6_p = (unsigned long *)ERR_PTR(args->err);
434 dr6 = *dr6_p; 434 dr6 = *dr6_p;
435 435
436 /* If it's a single step, TRAP bits are random */
437 if (dr6 & DR_STEP)
438 return NOTIFY_DONE;
439
436 /* Do an early return if no trap bits are set in DR6 */ 440 /* Do an early return if no trap bits are set in DR6 */
437 if ((dr6 & DR_TRAP_BITS) == 0) 441 if ((dr6 & DR_TRAP_BITS) == 0)
438 return NOTIFY_DONE; 442 return NOTIFY_DONE;
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index ec592caac4b4..cd21b654dec6 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -315,14 +315,18 @@ static void kgdb_remove_all_hw_break(void)
315 if (!breakinfo[i].enabled) 315 if (!breakinfo[i].enabled)
316 continue; 316 continue;
317 bp = *per_cpu_ptr(breakinfo[i].pev, cpu); 317 bp = *per_cpu_ptr(breakinfo[i].pev, cpu);
318 if (bp->attr.disabled == 1) 318 if (!bp->attr.disabled) {
319 arch_uninstall_hw_breakpoint(bp);
320 bp->attr.disabled = 1;
319 continue; 321 continue;
322 }
320 if (dbg_is_early) 323 if (dbg_is_early)
321 early_dr7 &= ~encode_dr7(i, breakinfo[i].len, 324 early_dr7 &= ~encode_dr7(i, breakinfo[i].len,
322 breakinfo[i].type); 325 breakinfo[i].type);
323 else 326 else if (hw_break_release_slot(i))
324 arch_uninstall_hw_breakpoint(bp); 327 printk(KERN_ERR "KGDB: hw bpt remove failed %lx\n",
325 bp->attr.disabled = 1; 328 breakinfo[i].addr);
329 breakinfo[i].enabled = 0;
326 } 330 }
327} 331}
328 332
diff --git a/arch/x86/kernel/mmconf-fam10h_64.c b/arch/x86/kernel/mmconf-fam10h_64.c
index 6da143c2a6b8..ac861b8348e2 100644
--- a/arch/x86/kernel/mmconf-fam10h_64.c
+++ b/arch/x86/kernel/mmconf-fam10h_64.c
@@ -25,7 +25,6 @@ struct pci_hostbridge_probe {
25}; 25};
26 26
27static u64 __cpuinitdata fam10h_pci_mmconf_base; 27static u64 __cpuinitdata fam10h_pci_mmconf_base;
28static int __cpuinitdata fam10h_pci_mmconf_base_status;
29 28
30static struct pci_hostbridge_probe pci_probes[] __cpuinitdata = { 29static struct pci_hostbridge_probe pci_probes[] __cpuinitdata = {
31 { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 }, 30 { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 },
@@ -44,10 +43,12 @@ static int __cpuinit cmp_range(const void *x1, const void *x2)
44 return start1 - start2; 43 return start1 - start2;
45} 44}
46 45
47/*[47:0] */ 46#define MMCONF_UNIT (1ULL << FAM10H_MMIO_CONF_BASE_SHIFT)
48/* need to avoid (0xfd<<32) and (0xfe<<32), ht used space */ 47#define MMCONF_MASK (~(MMCONF_UNIT - 1))
48#define MMCONF_SIZE (MMCONF_UNIT << 8)
49/* need to avoid (0xfd<<32), (0xfe<<32), and (0xff<<32), ht used space */
49#define FAM10H_PCI_MMCONF_BASE (0xfcULL<<32) 50#define FAM10H_PCI_MMCONF_BASE (0xfcULL<<32)
50#define BASE_VALID(b) ((b != (0xfdULL << 32)) && (b != (0xfeULL << 32))) 51#define BASE_VALID(b) ((b) + MMCONF_SIZE <= (0xfdULL<<32) || (b) >= (1ULL<<40))
51static void __cpuinit get_fam10h_pci_mmconf_base(void) 52static void __cpuinit get_fam10h_pci_mmconf_base(void)
52{ 53{
53 int i; 54 int i;
@@ -64,12 +65,11 @@ static void __cpuinit get_fam10h_pci_mmconf_base(void)
64 struct range range[8]; 65 struct range range[8];
65 66
66 /* only try to get setting from BSP */ 67 /* only try to get setting from BSP */
67 /* -1 or 1 */ 68 if (fam10h_pci_mmconf_base)
68 if (fam10h_pci_mmconf_base_status)
69 return; 69 return;
70 70
71 if (!early_pci_allowed()) 71 if (!early_pci_allowed())
72 goto fail; 72 return;
73 73
74 found = 0; 74 found = 0;
75 for (i = 0; i < ARRAY_SIZE(pci_probes); i++) { 75 for (i = 0; i < ARRAY_SIZE(pci_probes); i++) {
@@ -91,7 +91,7 @@ static void __cpuinit get_fam10h_pci_mmconf_base(void)
91 } 91 }
92 92
93 if (!found) 93 if (!found)
94 goto fail; 94 return;
95 95
96 /* SYS_CFG */ 96 /* SYS_CFG */
97 address = MSR_K8_SYSCFG; 97 address = MSR_K8_SYSCFG;
@@ -99,16 +99,16 @@ static void __cpuinit get_fam10h_pci_mmconf_base(void)
99 99
100 /* TOP_MEM2 is not enabled? */ 100 /* TOP_MEM2 is not enabled? */
101 if (!(val & (1<<21))) { 101 if (!(val & (1<<21))) {
102 tom2 = 0; 102 tom2 = 1ULL << 32;
103 } else { 103 } else {
104 /* TOP_MEM2 */ 104 /* TOP_MEM2 */
105 address = MSR_K8_TOP_MEM2; 105 address = MSR_K8_TOP_MEM2;
106 rdmsrl(address, val); 106 rdmsrl(address, val);
107 tom2 = val & (0xffffULL<<32); 107 tom2 = max(val & 0xffffff800000ULL, 1ULL << 32);
108 } 108 }
109 109
110 if (base <= tom2) 110 if (base <= tom2)
111 base = tom2 + (1ULL<<32); 111 base = (tom2 + 2 * MMCONF_UNIT - 1) & MMCONF_MASK;
112 112
113 /* 113 /*
114 * need to check if the range is in the high mmio range that is 114 * need to check if the range is in the high mmio range that is
@@ -123,11 +123,11 @@ static void __cpuinit get_fam10h_pci_mmconf_base(void)
123 if (!(reg & 3)) 123 if (!(reg & 3))
124 continue; 124 continue;
125 125
126 start = (((u64)reg) << 8) & (0xffULL << 32); /* 39:16 on 31:8*/ 126 start = (u64)(reg & 0xffffff00) << 8; /* 39:16 on 31:8*/
127 reg = read_pci_config(bus, slot, 1, 0x84 + (i << 3)); 127 reg = read_pci_config(bus, slot, 1, 0x84 + (i << 3));
128 end = (((u64)reg) << 8) & (0xffULL << 32); /* 39:16 on 31:8*/ 128 end = ((u64)(reg & 0xffffff00) << 8) | 0xffff; /* 39:16 on 31:8*/
129 129
130 if (!end) 130 if (end < tom2)
131 continue; 131 continue;
132 132
133 range[hi_mmio_num].start = start; 133 range[hi_mmio_num].start = start;
@@ -143,32 +143,27 @@ static void __cpuinit get_fam10h_pci_mmconf_base(void)
143 143
144 if (range[hi_mmio_num - 1].end < base) 144 if (range[hi_mmio_num - 1].end < base)
145 goto out; 145 goto out;
146 if (range[0].start > base) 146 if (range[0].start > base + MMCONF_SIZE)
147 goto out; 147 goto out;
148 148
149 /* need to find one window */ 149 /* need to find one window */
150 base = range[0].start - (1ULL << 32); 150 base = (range[0].start & MMCONF_MASK) - MMCONF_UNIT;
151 if ((base > tom2) && BASE_VALID(base)) 151 if ((base > tom2) && BASE_VALID(base))
152 goto out; 152 goto out;
153 base = range[hi_mmio_num - 1].end + (1ULL << 32); 153 base = (range[hi_mmio_num - 1].end + MMCONF_UNIT) & MMCONF_MASK;
154 if ((base > tom2) && BASE_VALID(base)) 154 if (BASE_VALID(base))
155 goto out; 155 goto out;
156 /* need to find window between ranges */ 156 /* need to find window between ranges */
157 if (hi_mmio_num > 1) 157 for (i = 1; i < hi_mmio_num; i++) {
158 for (i = 0; i < hi_mmio_num - 1; i++) { 158 base = (range[i - 1].end + MMCONF_UNIT) & MMCONF_MASK;
159 if (range[i + 1].start > (range[i].end + (1ULL << 32))) { 159 val = range[i].start & MMCONF_MASK;
160 base = range[i].end + (1ULL << 32); 160 if (val >= base + MMCONF_SIZE && BASE_VALID(base))
161 if ((base > tom2) && BASE_VALID(base)) 161 goto out;
162 goto out;
163 }
164 } 162 }
165
166fail:
167 fam10h_pci_mmconf_base_status = -1;
168 return; 163 return;
164
169out: 165out:
170 fam10h_pci_mmconf_base = base; 166 fam10h_pci_mmconf_base = base;
171 fam10h_pci_mmconf_base_status = 1;
172} 167}
173 168
174void __cpuinit fam10h_check_enable_mmcfg(void) 169void __cpuinit fam10h_check_enable_mmcfg(void)
@@ -190,11 +185,10 @@ void __cpuinit fam10h_check_enable_mmcfg(void)
190 185
191 /* only trust the one handle 256 buses, if acpi=off */ 186 /* only trust the one handle 256 buses, if acpi=off */
192 if (!acpi_pci_disabled || busnbits >= 8) { 187 if (!acpi_pci_disabled || busnbits >= 8) {
193 u64 base; 188 u64 base = val & MMCONF_MASK;
194 base = val & (0xffffULL << 32); 189
195 if (fam10h_pci_mmconf_base_status <= 0) { 190 if (!fam10h_pci_mmconf_base) {
196 fam10h_pci_mmconf_base = base; 191 fam10h_pci_mmconf_base = base;
197 fam10h_pci_mmconf_base_status = 1;
198 return; 192 return;
199 } else if (fam10h_pci_mmconf_base == base) 193 } else if (fam10h_pci_mmconf_base == base)
200 return; 194 return;
@@ -206,8 +200,10 @@ void __cpuinit fam10h_check_enable_mmcfg(void)
206 * with 256 buses 200 * with 256 buses
207 */ 201 */
208 get_fam10h_pci_mmconf_base(); 202 get_fam10h_pci_mmconf_base();
209 if (fam10h_pci_mmconf_base_status <= 0) 203 if (!fam10h_pci_mmconf_base) {
204 pci_probe &= ~PCI_CHECK_ENABLE_AMD_MMCONF;
210 return; 205 return;
206 }
211 207
212 printk(KERN_INFO "Enable MMCONFIG on AMD Family 10h\n"); 208 printk(KERN_INFO "Enable MMCONFIG on AMD Family 10h\n");
213 val &= ~((FAM10H_MMIO_CONF_BASE_MASK<<FAM10H_MMIO_CONF_BASE_SHIFT) | 209 val &= ~((FAM10H_MMIO_CONF_BASE_MASK<<FAM10H_MMIO_CONF_BASE_SHIFT) |
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 7bf2dc4c8f70..12fcbe2c143e 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -30,7 +30,6 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/poll.h> 31#include <linux/poll.h>
32#include <linux/smp.h> 32#include <linux/smp.h>
33#include <linux/smp_lock.h>
34#include <linux/major.h> 33#include <linux/major.h>
35#include <linux/fs.h> 34#include <linux/fs.h>
36#include <linux/device.h> 35#include <linux/device.h>
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 008b91eefa18..42eb3300dfc6 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -83,6 +83,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
83 83
84static atomic64_t last_value = ATOMIC64_INIT(0); 84static atomic64_t last_value = ATOMIC64_INIT(0);
85 85
86void pvclock_resume(void)
87{
88 atomic64_set(&last_value, 0);
89}
90
86cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src) 91cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
87{ 92{
88 struct pvclock_shadow_time shadow; 93 struct pvclock_shadow_time shadow;
diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c
new file mode 100644
index 000000000000..2a26819bb6a8
--- /dev/null
+++ b/arch/x86/kernel/resource.c
@@ -0,0 +1,48 @@
1#include <linux/ioport.h>
2#include <asm/e820.h>
3
4static void resource_clip(struct resource *res, resource_size_t start,
5 resource_size_t end)
6{
7 resource_size_t low = 0, high = 0;
8
9 if (res->end < start || res->start > end)
10 return; /* no conflict */
11
12 if (res->start < start)
13 low = start - res->start;
14
15 if (res->end > end)
16 high = res->end - end;
17
18 /* Keep the area above or below the conflict, whichever is larger */
19 if (low > high)
20 res->end = start - 1;
21 else
22 res->start = end + 1;
23}
24
25static void remove_e820_regions(struct resource *avail)
26{
27 int i;
28 struct e820entry *entry;
29
30 for (i = 0; i < e820.nr_map; i++) {
31 entry = &e820.map[i];
32
33 resource_clip(avail, entry->addr,
34 entry->addr + entry->size - 1);
35 }
36}
37
38void arch_remove_reservations(struct resource *avail)
39{
40 /* Trim out BIOS areas (low 1MB and high 2MB) and E820 regions */
41 if (avail->flags & IORESOURCE_MEM) {
42 if (avail->start < BIOS_END)
43 avail->start = BIOS_END;
44 resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);
45
46 remove_e820_regions(avail);
47 }
48}
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 21c6746338af..85268f8eadf6 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -769,7 +769,6 @@ void __init setup_arch(char **cmdline_p)
769 769
770 x86_init.oem.arch_setup(); 770 x86_init.oem.arch_setup();
771 771
772 resource_alloc_from_bottom = 0;
773 iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1; 772 iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
774 setup_memory_map(); 773 setup_memory_map();
775 parse_setup_data(); 774 parse_setup_data();
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index 9c253bd65e24..547128546cc3 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -394,7 +394,8 @@ static void __init setup_xstate_init(void)
394 * Setup init_xstate_buf to represent the init state of 394 * Setup init_xstate_buf to represent the init state of
395 * all the features managed by the xsave 395 * all the features managed by the xsave
396 */ 396 */
397 init_xstate_buf = alloc_bootmem(xstate_size); 397 init_xstate_buf = alloc_bootmem_align(xstate_size,
398 __alignof__(struct xsave_struct));
398 init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT; 399 init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;
399 400
400 clts(); 401 clts();
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 82e144a4e514..b81a9b7c2ca4 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3395,6 +3395,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
3395 vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip; 3395 vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip;
3396 3396
3397 load_host_msrs(vcpu); 3397 load_host_msrs(vcpu);
3398 kvm_load_ldt(ldt_selector);
3398 loadsegment(fs, fs_selector); 3399 loadsegment(fs, fs_selector);
3399#ifdef CONFIG_X86_64 3400#ifdef CONFIG_X86_64
3400 load_gs_index(gs_selector); 3401 load_gs_index(gs_selector);
@@ -3402,7 +3403,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
3402#else 3403#else
3403 loadsegment(gs, gs_selector); 3404 loadsegment(gs, gs_selector);
3404#endif 3405#endif
3405 kvm_load_ldt(ldt_selector);
3406 3406
3407 reload_tss(vcpu); 3407 reload_tss(vcpu);
3408 3408
@@ -3494,6 +3494,10 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu)
3494static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) 3494static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
3495{ 3495{
3496 switch (func) { 3496 switch (func) {
3497 case 0x00000001:
3498 /* Mask out xsave bit as long as it is not supported by SVM */
3499 entry->ecx &= ~(bit(X86_FEATURE_XSAVE));
3500 break;
3497 case 0x80000001: 3501 case 0x80000001:
3498 if (nested) 3502 if (nested)
3499 entry->ecx |= (1 << 2); /* Set SVM bit */ 3503 entry->ecx |= (1 << 2); /* Set SVM bit */
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 8da0e45ff7c9..81fcbe9515c5 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -821,10 +821,9 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
821#endif 821#endif
822 822
823#ifdef CONFIG_X86_64 823#ifdef CONFIG_X86_64
824 if (is_long_mode(&vmx->vcpu)) { 824 rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_host_kernel_gs_base);
825 rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_host_kernel_gs_base); 825 if (is_long_mode(&vmx->vcpu))
826 wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); 826 wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base);
827 }
828#endif 827#endif
829 for (i = 0; i < vmx->save_nmsrs; ++i) 828 for (i = 0; i < vmx->save_nmsrs; ++i)
830 kvm_set_shared_msr(vmx->guest_msrs[i].index, 829 kvm_set_shared_msr(vmx->guest_msrs[i].index,
@@ -839,23 +838,23 @@ static void __vmx_load_host_state(struct vcpu_vmx *vmx)
839 838
840 ++vmx->vcpu.stat.host_state_reload; 839 ++vmx->vcpu.stat.host_state_reload;
841 vmx->host_state.loaded = 0; 840 vmx->host_state.loaded = 0;
842 if (vmx->host_state.fs_reload_needed) 841#ifdef CONFIG_X86_64
843 loadsegment(fs, vmx->host_state.fs_sel); 842 if (is_long_mode(&vmx->vcpu))
843 rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base);
844#endif
844 if (vmx->host_state.gs_ldt_reload_needed) { 845 if (vmx->host_state.gs_ldt_reload_needed) {
845 kvm_load_ldt(vmx->host_state.ldt_sel); 846 kvm_load_ldt(vmx->host_state.ldt_sel);
846#ifdef CONFIG_X86_64 847#ifdef CONFIG_X86_64
847 load_gs_index(vmx->host_state.gs_sel); 848 load_gs_index(vmx->host_state.gs_sel);
848 wrmsrl(MSR_KERNEL_GS_BASE, current->thread.gs);
849#else 849#else
850 loadsegment(gs, vmx->host_state.gs_sel); 850 loadsegment(gs, vmx->host_state.gs_sel);
851#endif 851#endif
852 } 852 }
853 if (vmx->host_state.fs_reload_needed)
854 loadsegment(fs, vmx->host_state.fs_sel);
853 reload_tss(); 855 reload_tss();
854#ifdef CONFIG_X86_64 856#ifdef CONFIG_X86_64
855 if (is_long_mode(&vmx->vcpu)) { 857 wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_host_kernel_gs_base);
856 rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base);
857 wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_host_kernel_gs_base);
858 }
859#endif 858#endif
860 if (current_thread_info()->status & TS_USEDFPU) 859 if (current_thread_info()->status & TS_USEDFPU)
861 clts(); 860 clts();
@@ -4228,11 +4227,6 @@ static int vmx_get_lpage_level(void)
4228 return PT_PDPE_LEVEL; 4227 return PT_PDPE_LEVEL;
4229} 4228}
4230 4229
4231static inline u32 bit(int bitno)
4232{
4233 return 1 << (bitno & 31);
4234}
4235
4236static void vmx_cpuid_update(struct kvm_vcpu *vcpu) 4230static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
4237{ 4231{
4238 struct kvm_cpuid_entry2 *best; 4232 struct kvm_cpuid_entry2 *best;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cdac9e592aa5..b989e1f1e5d3 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -155,11 +155,6 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
155 155
156u64 __read_mostly host_xcr0; 156u64 __read_mostly host_xcr0;
157 157
158static inline u32 bit(int bitno)
159{
160 return 1 << (bitno & 31);
161}
162
163static void kvm_on_user_return(struct user_return_notifier *urn) 158static void kvm_on_user_return(struct user_return_notifier *urn)
164{ 159{
165 unsigned slot; 160 unsigned slot;
@@ -4569,9 +4564,11 @@ static void kvm_timer_init(void)
4569#ifdef CONFIG_CPU_FREQ 4564#ifdef CONFIG_CPU_FREQ
4570 struct cpufreq_policy policy; 4565 struct cpufreq_policy policy;
4571 memset(&policy, 0, sizeof(policy)); 4566 memset(&policy, 0, sizeof(policy));
4572 cpufreq_get_policy(&policy, get_cpu()); 4567 cpu = get_cpu();
4568 cpufreq_get_policy(&policy, cpu);
4573 if (policy.cpuinfo.max_freq) 4569 if (policy.cpuinfo.max_freq)
4574 max_tsc_khz = policy.cpuinfo.max_freq; 4570 max_tsc_khz = policy.cpuinfo.max_freq;
4571 put_cpu();
4575#endif 4572#endif
4576 cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block, 4573 cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block,
4577 CPUFREQ_TRANSITION_NOTIFIER); 4574 CPUFREQ_TRANSITION_NOTIFIER);
@@ -5522,6 +5519,8 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
5522 5519
5523 mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4; 5520 mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4;
5524 kvm_x86_ops->set_cr4(vcpu, sregs->cr4); 5521 kvm_x86_ops->set_cr4(vcpu, sregs->cr4);
5522 if (sregs->cr4 & X86_CR4_OSXSAVE)
5523 update_cpuid(vcpu);
5525 if (!is_long_mode(vcpu) && is_pae(vcpu)) { 5524 if (!is_long_mode(vcpu) && is_pae(vcpu)) {
5526 load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3); 5525 load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3);
5527 mmu_reset_needed = 1; 5526 mmu_reset_needed = 1;
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 2cea414489f3..c600da830ce0 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -70,6 +70,11 @@ static inline int is_paging(struct kvm_vcpu *vcpu)
70 return kvm_read_cr0_bits(vcpu, X86_CR0_PG); 70 return kvm_read_cr0_bits(vcpu, X86_CR0_PG);
71} 71}
72 72
73static inline u32 bit(int bitno)
74{
75 return 1 << (bitno & 31);
76}
77
73void kvm_before_handle_nmi(struct kvm_vcpu *vcpu); 78void kvm_before_handle_nmi(struct kvm_vcpu *vcpu);
74void kvm_after_handle_nmi(struct kvm_vcpu *vcpu); 79void kvm_after_handle_nmi(struct kvm_vcpu *vcpu);
75int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq); 80int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq);
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 73b1e1a1f489..4996cf5f73a0 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -531,7 +531,10 @@ static void lguest_write_cr3(unsigned long cr3)
531{ 531{
532 lguest_data.pgdir = cr3; 532 lguest_data.pgdir = cr3;
533 lazy_hcall1(LHCALL_NEW_PGTABLE, cr3); 533 lazy_hcall1(LHCALL_NEW_PGTABLE, cr3);
534 cr3_changed = true; 534
535 /* These two page tables are simple, linear, and used during boot */
536 if (cr3 != __pa(swapper_pg_dir) && cr3 != __pa(initial_page_table))
537 cr3_changed = true;
535} 538}
536 539
537static unsigned long lguest_read_cr3(void) 540static unsigned long lguest_read_cr3(void)
@@ -703,9 +706,9 @@ static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval)
703 * to forget all of them. Fortunately, this is very rare. 706 * to forget all of them. Fortunately, this is very rare.
704 * 707 *
705 * ... except in early boot when the kernel sets up the initial pagetables, 708 * ... except in early boot when the kernel sets up the initial pagetables,
706 * which makes booting astonishingly slow: 1.83 seconds! So we don't even tell 709 * which makes booting astonishingly slow: 48 seconds! So we don't even tell
707 * the Host anything changed until we've done the first page table switch, 710 * the Host anything changed until we've done the first real page table switch,
708 * which brings boot back to 0.25 seconds. 711 * which brings boot back to 4.3 seconds.
709 */ 712 */
710static void lguest_set_pte(pte_t *ptep, pte_t pteval) 713static void lguest_set_pte(pte_t *ptep, pte_t pteval)
711{ 714{
@@ -1002,7 +1005,7 @@ static void lguest_time_init(void)
1002 clockevents_register_device(&lguest_clockevent); 1005 clockevents_register_device(&lguest_clockevent);
1003 1006
1004 /* Finally, we unblock the timer interrupt. */ 1007 /* Finally, we unblock the timer interrupt. */
1005 enable_lguest_irq(0); 1008 clear_bit(0, lguest_data.blocked_interrupts);
1006} 1009}
1007 1010
1008/* 1011/*
@@ -1349,9 +1352,6 @@ __init void lguest_init(void)
1349 */ 1352 */
1350 switch_to_new_gdt(0); 1353 switch_to_new_gdt(0);
1351 1354
1352 /* We actually boot with all memory mapped, but let's say 128MB. */
1353 max_pfn_mapped = (128*1024*1024) >> PAGE_SHIFT;
1354
1355 /* 1355 /*
1356 * The Host<->Guest Switcher lives at the top of our address space, and 1356 * The Host<->Guest Switcher lives at the top of our address space, and
1357 * the Host told us how big it is when we made LGUEST_INIT hypercall: 1357 * the Host told us how big it is when we made LGUEST_INIT hypercall:
diff --git a/arch/x86/lguest/i386_head.S b/arch/x86/lguest/i386_head.S
index 4f420c2f2d55..e7d5382ef263 100644
--- a/arch/x86/lguest/i386_head.S
+++ b/arch/x86/lguest/i386_head.S
@@ -4,6 +4,7 @@
4#include <asm/asm-offsets.h> 4#include <asm/asm-offsets.h>
5#include <asm/thread_info.h> 5#include <asm/thread_info.h>
6#include <asm/processor-flags.h> 6#include <asm/processor-flags.h>
7#include <asm/pgtable.h>
7 8
8/*G:020 9/*G:020
9 * Our story starts with the kernel booting into startup_32 in 10 * Our story starts with the kernel booting into startup_32 in
@@ -37,9 +38,113 @@ ENTRY(lguest_entry)
37 /* Set up the initial stack so we can run C code. */ 38 /* Set up the initial stack so we can run C code. */
38 movl $(init_thread_union+THREAD_SIZE),%esp 39 movl $(init_thread_union+THREAD_SIZE),%esp
39 40
41 call init_pagetables
42
40 /* Jumps are relative: we're running __PAGE_OFFSET too low. */ 43 /* Jumps are relative: we're running __PAGE_OFFSET too low. */
41 jmp lguest_init+__PAGE_OFFSET 44 jmp lguest_init+__PAGE_OFFSET
42 45
46/*
47 * Initialize page tables. This creates a PDE and a set of page
48 * tables, which are located immediately beyond __brk_base. The variable
49 * _brk_end is set up to point to the first "safe" location.
50 * Mappings are created both at virtual address 0 (identity mapping)
51 * and PAGE_OFFSET for up to _end.
52 *
53 * FIXME: This code is taken verbatim from arch/x86/kernel/head_32.S: they
54 * don't have a stack at this point, so we can't just use call and ret.
55 */
56init_pagetables:
57#if PTRS_PER_PMD > 1
58#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
59#else
60#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
61#endif
62#define pa(X) ((X) - __PAGE_OFFSET)
63
64/* Enough space to fit pagetables for the low memory linear map */
65MAPPING_BEYOND_END = \
66 PAGE_TABLE_SIZE(((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT) << PAGE_SHIFT
67#ifdef CONFIG_X86_PAE
68
69 /*
70 * In PAE mode initial_page_table is statically defined to contain
71 * enough entries to cover the VMSPLIT option (that is the top 1, 2 or 3
72 * entries). The identity mapping is handled by pointing two PGD entries
73 * to the first kernel PMD.
74 *
75 * Note the upper half of each PMD or PTE are always zero at this stage.
76 */
77
78#define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */
79
80 xorl %ebx,%ebx /* %ebx is kept at zero */
81
82 movl $pa(__brk_base), %edi
83 movl $pa(initial_pg_pmd), %edx
84 movl $PTE_IDENT_ATTR, %eax
8510:
86 leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */
87 movl %ecx,(%edx) /* Store PMD entry */
88 /* Upper half already zero */
89 addl $8,%edx
90 movl $512,%ecx
9111:
92 stosl
93 xchgl %eax,%ebx
94 stosl
95 xchgl %eax,%ebx
96 addl $0x1000,%eax
97 loop 11b
98
99 /*
100 * End condition: we must map up to the end + MAPPING_BEYOND_END.
101 */
102 movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %ebp
103 cmpl %ebp,%eax
104 jb 10b
1051:
106 addl $__PAGE_OFFSET, %edi
107 movl %edi, pa(_brk_end)
108 shrl $12, %eax
109 movl %eax, pa(max_pfn_mapped)
110
111 /* Do early initialization of the fixmap area */
112 movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
113 movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
114#else /* Not PAE */
115
116page_pde_offset = (__PAGE_OFFSET >> 20);
117
118 movl $pa(__brk_base), %edi
119 movl $pa(initial_page_table), %edx
120 movl $PTE_IDENT_ATTR, %eax
12110:
122 leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */
123 movl %ecx,(%edx) /* Store identity PDE entry */
124 movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */
125 addl $4,%edx
126 movl $1024, %ecx
12711:
128 stosl
129 addl $0x1000,%eax
130 loop 11b
131 /*
132 * End condition: we must map up to the end + MAPPING_BEYOND_END.
133 */
134 movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %ebp
135 cmpl %ebp,%eax
136 jb 10b
137 addl $__PAGE_OFFSET, %edi
138 movl %edi, pa(_brk_end)
139 shrl $12, %eax
140 movl %eax, pa(max_pfn_mapped)
141
142 /* Do early initialization of the fixmap area */
143 movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
144 movl %eax,pa(initial_page_table+0xffc)
145#endif
146 ret
147
43/*G:055 148/*G:055
44 * We create a macro which puts the assembler code between lgstart_ and lgend_ 149 * We create a macro which puts the assembler code between lgstart_ and lgend_
45 * markers. These templates are put in the .text section: they can't be 150 * markers. These templates are put in the .text section: they can't be
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 12cdbb17ad18..6acc724d5d8f 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -223,7 +223,7 @@ void native_flush_tlb_others(const struct cpumask *cpumask,
223 223
224static void __cpuinit calculate_tlb_offset(void) 224static void __cpuinit calculate_tlb_offset(void)
225{ 225{
226 int cpu, node, nr_node_vecs; 226 int cpu, node, nr_node_vecs, idx = 0;
227 /* 227 /*
228 * we are changing tlb_vector_offset for each CPU in runtime, but this 228 * we are changing tlb_vector_offset for each CPU in runtime, but this
229 * will not cause inconsistency, as the write is atomic under X86. we 229 * will not cause inconsistency, as the write is atomic under X86. we
@@ -239,7 +239,7 @@ static void __cpuinit calculate_tlb_offset(void)
239 nr_node_vecs = NUM_INVALIDATE_TLB_VECTORS/nr_online_nodes; 239 nr_node_vecs = NUM_INVALIDATE_TLB_VECTORS/nr_online_nodes;
240 240
241 for_each_online_node(node) { 241 for_each_online_node(node) {
242 int node_offset = (node % NUM_INVALIDATE_TLB_VECTORS) * 242 int node_offset = (idx % NUM_INVALIDATE_TLB_VECTORS) *
243 nr_node_vecs; 243 nr_node_vecs;
244 int cpu_offset = 0; 244 int cpu_offset = 0;
245 for_each_cpu(cpu, cpumask_of_node(node)) { 245 for_each_cpu(cpu, cpumask_of_node(node)) {
@@ -248,6 +248,7 @@ static void __cpuinit calculate_tlb_offset(void)
248 cpu_offset++; 248 cpu_offset++;
249 cpu_offset = cpu_offset % nr_node_vecs; 249 cpu_offset = cpu_offset % nr_node_vecs;
250 } 250 }
251 idx++;
251 } 252 }
252} 253}
253 254
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index c4bb261c106e..b1805b78842f 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -65,21 +65,13 @@ pcibios_align_resource(void *data, const struct resource *res,
65 resource_size_t size, resource_size_t align) 65 resource_size_t size, resource_size_t align)
66{ 66{
67 struct pci_dev *dev = data; 67 struct pci_dev *dev = data;
68 resource_size_t start = round_down(res->end - size + 1, align); 68 resource_size_t start = res->start;
69 69
70 if (res->flags & IORESOURCE_IO) { 70 if (res->flags & IORESOURCE_IO) {
71 71 if (skip_isa_ioresource_align(dev))
72 /* 72 return start;
73 * If we're avoiding ISA aliases, the largest contiguous I/O 73 if (start & 0x300)
74 * port space is 256 bytes. Clearing bits 9 and 10 preserves 74 start = (start + 0x3ff) & ~0x3ff;
75 * all 256-byte and smaller alignments, so the result will
76 * still be correctly aligned.
77 */
78 if (!skip_isa_ioresource_align(dev))
79 start &= ~0x300;
80 } else if (res->flags & IORESOURCE_MEM) {
81 if (start < BIOS_END)
82 start = res->end; /* fail; no space */
83 } 75 }
84 return start; 76 return start;
85} 77}
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index d7b5109f7a9c..25cd4a07d09f 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -70,6 +70,9 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
70struct xen_pci_frontend_ops *xen_pci_frontend; 70struct xen_pci_frontend_ops *xen_pci_frontend;
71EXPORT_SYMBOL_GPL(xen_pci_frontend); 71EXPORT_SYMBOL_GPL(xen_pci_frontend);
72 72
73#define XEN_PIRQ_MSI_DATA (MSI_DATA_TRIGGER_EDGE | \
74 MSI_DATA_LEVEL_ASSERT | (3 << 8) | MSI_DATA_VECTOR(0))
75
73static void xen_msi_compose_msg(struct pci_dev *pdev, unsigned int pirq, 76static void xen_msi_compose_msg(struct pci_dev *pdev, unsigned int pirq,
74 struct msi_msg *msg) 77 struct msi_msg *msg)
75{ 78{
@@ -83,12 +86,7 @@ static void xen_msi_compose_msg(struct pci_dev *pdev, unsigned int pirq,
83 MSI_ADDR_REDIRECTION_CPU | 86 MSI_ADDR_REDIRECTION_CPU |
84 MSI_ADDR_DEST_ID(pirq); 87 MSI_ADDR_DEST_ID(pirq);
85 88
86 msg->data = 89 msg->data = XEN_PIRQ_MSI_DATA;
87 MSI_DATA_TRIGGER_EDGE |
88 MSI_DATA_LEVEL_ASSERT |
89 /* delivery mode reserved */
90 (3 << 8) |
91 MSI_DATA_VECTOR(0);
92} 90}
93 91
94static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) 92static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
@@ -98,8 +96,23 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
98 struct msi_msg msg; 96 struct msi_msg msg;
99 97
100 list_for_each_entry(msidesc, &dev->msi_list, list) { 98 list_for_each_entry(msidesc, &dev->msi_list, list) {
99 __read_msi_msg(msidesc, &msg);
100 pirq = MSI_ADDR_EXT_DEST_ID(msg.address_hi) |
101 ((msg.address_lo >> MSI_ADDR_DEST_ID_SHIFT) & 0xff);
102 if (xen_irq_from_pirq(pirq) >= 0 && msg.data == XEN_PIRQ_MSI_DATA) {
103 xen_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ?
104 "msi-x" : "msi", &irq, &pirq, XEN_ALLOC_IRQ);
105 if (irq < 0)
106 goto error;
107 ret = set_irq_msi(irq, msidesc);
108 if (ret < 0)
109 goto error_while;
110 printk(KERN_DEBUG "xen: msi already setup: msi --> irq=%d"
111 " pirq=%d\n", irq, pirq);
112 return 0;
113 }
101 xen_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ? 114 xen_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ?
102 "msi-x" : "msi", &irq, &pirq); 115 "msi-x" : "msi", &irq, &pirq, (XEN_ALLOC_IRQ | XEN_ALLOC_PIRQ));
103 if (irq < 0 || pirq < 0) 116 if (irq < 0 || pirq < 0)
104 goto error; 117 goto error;
105 printk(KERN_DEBUG "xen: msi --> irq=%d, pirq=%d\n", irq, pirq); 118 printk(KERN_DEBUG "xen: msi --> irq=%d, pirq=%d\n", irq, pirq);
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index a318194002b5..ba9caa808a9c 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1455,7 +1455,7 @@ static void __init uv_init_uvhub(int uvhub, int vector)
1455 * the below initialization can't be in firmware because the 1455 * the below initialization can't be in firmware because the
1456 * messaging IRQ will be determined by the OS 1456 * messaging IRQ will be determined by the OS
1457 */ 1457 */
1458 apicid = uvhub_to_first_apicid(uvhub); 1458 apicid = uvhub_to_first_apicid(uvhub) | uv_apicid_hibits;
1459 uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG, 1459 uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG,
1460 ((apicid << 32) | vector)); 1460 ((apicid << 32) | vector));
1461} 1461}
diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c
index 56e421bc379b..9daf5d1af9f1 100644
--- a/arch/x86/platform/uv/uv_time.c
+++ b/arch/x86/platform/uv/uv_time.c
@@ -89,6 +89,7 @@ static void uv_rtc_send_IPI(int cpu)
89 89
90 apicid = cpu_physical_id(cpu); 90 apicid = cpu_physical_id(cpu);
91 pnode = uv_apicid_to_pnode(apicid); 91 pnode = uv_apicid_to_pnode(apicid);
92 apicid |= uv_apicid_hibits;
92 val = (1UL << UVH_IPI_INT_SEND_SHFT) | 93 val = (1UL << UVH_IPI_INT_SEND_SHFT) |
93 (apicid << UVH_IPI_INT_APIC_ID_SHFT) | 94 (apicid << UVH_IPI_INT_APIC_ID_SHFT) |
94 (X86_PLATFORM_IPI_VECTOR << UVH_IPI_INT_VECTOR_SHFT); 95 (X86_PLATFORM_IPI_VECTOR << UVH_IPI_INT_VECTOR_SHFT);
@@ -107,6 +108,7 @@ static int uv_intr_pending(int pnode)
107static int uv_setup_intr(int cpu, u64 expires) 108static int uv_setup_intr(int cpu, u64 expires)
108{ 109{
109 u64 val; 110 u64 val;
111 unsigned long apicid = cpu_physical_id(cpu) | uv_apicid_hibits;
110 int pnode = uv_cpu_to_pnode(cpu); 112 int pnode = uv_cpu_to_pnode(cpu);
111 113
112 uv_write_global_mmr64(pnode, UVH_RTC1_INT_CONFIG, 114 uv_write_global_mmr64(pnode, UVH_RTC1_INT_CONFIG,
@@ -117,7 +119,7 @@ static int uv_setup_intr(int cpu, u64 expires)
117 UVH_EVENT_OCCURRED0_RTC1_MASK); 119 UVH_EVENT_OCCURRED0_RTC1_MASK);
118 120
119 val = (X86_PLATFORM_IPI_VECTOR << UVH_RTC1_INT_CONFIG_VECTOR_SHFT) | 121 val = (X86_PLATFORM_IPI_VECTOR << UVH_RTC1_INT_CONFIG_VECTOR_SHFT) |
120 ((u64)cpu_physical_id(cpu) << UVH_RTC1_INT_CONFIG_APIC_ID_SHFT); 122 ((u64)apicid << UVH_RTC1_INT_CONFIG_APIC_ID_SHFT);
121 123
122 /* Set configuration */ 124 /* Set configuration */
123 uv_write_global_mmr64(pnode, UVH_RTC1_INT_CONFIG, val); 125 uv_write_global_mmr64(pnode, UVH_RTC1_INT_CONFIG, val);
diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index 4a2afa1bac51..b6552b189bcd 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -25,7 +25,7 @@ targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
25 25
26export CPPFLAGS_vdso.lds += -P -C 26export CPPFLAGS_vdso.lds += -P -C
27 27
28VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -Wl,-soname=linux-vdso.so.1 \ 28VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
29 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 29 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
30 30
31$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so 31$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
@@ -69,7 +69,7 @@ vdso32.so-$(VDSO32-y) += sysenter
69vdso32-images = $(vdso32.so-y:%=vdso32-%.so) 69vdso32-images = $(vdso32.so-y:%=vdso32-%.so)
70 70
71CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) 71CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
72VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1 72VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1
73 73
74# This makes sure the $(obj) subdirectory exists even though vdso32/ 74# This makes sure the $(obj) subdirectory exists even though vdso32/
75# is not a kbuild sub-make subdirectory. 75# is not a kbuild sub-make subdirectory.
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 235c0f4d3861..44dcad43989d 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -75,6 +75,11 @@ DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
75enum xen_domain_type xen_domain_type = XEN_NATIVE; 75enum xen_domain_type xen_domain_type = XEN_NATIVE;
76EXPORT_SYMBOL_GPL(xen_domain_type); 76EXPORT_SYMBOL_GPL(xen_domain_type);
77 77
78unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START;
79EXPORT_SYMBOL(machine_to_phys_mapping);
80unsigned int machine_to_phys_order;
81EXPORT_SYMBOL(machine_to_phys_order);
82
78struct start_info *xen_start_info; 83struct start_info *xen_start_info;
79EXPORT_SYMBOL_GPL(xen_start_info); 84EXPORT_SYMBOL_GPL(xen_start_info);
80 85
@@ -1016,10 +1021,6 @@ static void xen_reboot(int reason)
1016{ 1021{
1017 struct sched_shutdown r = { .reason = reason }; 1022 struct sched_shutdown r = { .reason = reason };
1018 1023
1019#ifdef CONFIG_SMP
1020 stop_other_cpus();
1021#endif
1022
1023 if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r)) 1024 if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
1024 BUG(); 1025 BUG();
1025} 1026}
@@ -1090,6 +1091,8 @@ static void __init xen_setup_stackprotector(void)
1090/* First C function to be called on Xen boot */ 1091/* First C function to be called on Xen boot */
1091asmlinkage void __init xen_start_kernel(void) 1092asmlinkage void __init xen_start_kernel(void)
1092{ 1093{
1094 struct physdev_set_iopl set_iopl;
1095 int rc;
1093 pgd_t *pgd; 1096 pgd_t *pgd;
1094 1097
1095 if (!xen_start_info) 1098 if (!xen_start_info)
@@ -1097,6 +1100,8 @@ asmlinkage void __init xen_start_kernel(void)
1097 1100
1098 xen_domain_type = XEN_PV_DOMAIN; 1101 xen_domain_type = XEN_PV_DOMAIN;
1099 1102
1103 xen_setup_machphys_mapping();
1104
1100 /* Install Xen paravirt ops */ 1105 /* Install Xen paravirt ops */
1101 pv_info = xen_info; 1106 pv_info = xen_info;
1102 pv_init_ops = xen_init_ops; 1107 pv_init_ops = xen_init_ops;
@@ -1191,8 +1196,6 @@ asmlinkage void __init xen_start_kernel(void)
1191 /* Allocate and initialize top and mid mfn levels for p2m structure */ 1196 /* Allocate and initialize top and mid mfn levels for p2m structure */
1192 xen_build_mfn_list_list(); 1197 xen_build_mfn_list_list();
1193 1198
1194 init_mm.pgd = pgd;
1195
1196 /* keep using Xen gdt for now; no urgent need to change it */ 1199 /* keep using Xen gdt for now; no urgent need to change it */
1197 1200
1198#ifdef CONFIG_X86_32 1201#ifdef CONFIG_X86_32
@@ -1202,10 +1205,18 @@ asmlinkage void __init xen_start_kernel(void)
1202#else 1205#else
1203 pv_info.kernel_rpl = 0; 1206 pv_info.kernel_rpl = 0;
1204#endif 1207#endif
1205
1206 /* set the limit of our address space */ 1208 /* set the limit of our address space */
1207 xen_reserve_top(); 1209 xen_reserve_top();
1208 1210
1211 /* We used to do this in xen_arch_setup, but that is too late on AMD
1212 * were early_cpu_init (run before ->arch_setup()) calls early_amd_init
1213 * which pokes 0xcf8 port.
1214 */
1215 set_iopl.iopl = 1;
1216 rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
1217 if (rc != 0)
1218 xen_raw_printk("physdev_op failed %d\n", rc);
1219
1209#ifdef CONFIG_X86_32 1220#ifdef CONFIG_X86_32
1210 /* set up basic CPUID stuff */ 1221 /* set up basic CPUID stuff */
1211 cpu_detect(&new_cpu_data); 1222 cpu_detect(&new_cpu_data);
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 21ed8d7f75a5..44924e551fde 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2034,6 +2034,20 @@ static __init void xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
2034 set_page_prot(pmd, PAGE_KERNEL_RO); 2034 set_page_prot(pmd, PAGE_KERNEL_RO);
2035} 2035}
2036 2036
2037void __init xen_setup_machphys_mapping(void)
2038{
2039 struct xen_machphys_mapping mapping;
2040 unsigned long machine_to_phys_nr_ents;
2041
2042 if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) {
2043 machine_to_phys_mapping = (unsigned long *)mapping.v_start;
2044 machine_to_phys_nr_ents = mapping.max_mfn + 1;
2045 } else {
2046 machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES;
2047 }
2048 machine_to_phys_order = fls(machine_to_phys_nr_ents - 1);
2049}
2050
2037#ifdef CONFIG_X86_64 2051#ifdef CONFIG_X86_64
2038static void convert_pfn_mfn(void *v) 2052static void convert_pfn_mfn(void *v)
2039{ 2053{
@@ -2119,44 +2133,83 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
2119 return pgd; 2133 return pgd;
2120} 2134}
2121#else /* !CONFIG_X86_64 */ 2135#else /* !CONFIG_X86_64 */
2122static RESERVE_BRK_ARRAY(pmd_t, level2_kernel_pgt, PTRS_PER_PMD); 2136static RESERVE_BRK_ARRAY(pmd_t, initial_kernel_pmd, PTRS_PER_PMD);
2137static RESERVE_BRK_ARRAY(pmd_t, swapper_kernel_pmd, PTRS_PER_PMD);
2138
2139static __init void xen_write_cr3_init(unsigned long cr3)
2140{
2141 unsigned long pfn = PFN_DOWN(__pa(swapper_pg_dir));
2142
2143 BUG_ON(read_cr3() != __pa(initial_page_table));
2144 BUG_ON(cr3 != __pa(swapper_pg_dir));
2145
2146 /*
2147 * We are switching to swapper_pg_dir for the first time (from
2148 * initial_page_table) and therefore need to mark that page
2149 * read-only and then pin it.
2150 *
2151 * Xen disallows sharing of kernel PMDs for PAE
2152 * guests. Therefore we must copy the kernel PMD from
2153 * initial_page_table into a new kernel PMD to be used in
2154 * swapper_pg_dir.
2155 */
2156 swapper_kernel_pmd =
2157 extend_brk(sizeof(pmd_t) * PTRS_PER_PMD, PAGE_SIZE);
2158 memcpy(swapper_kernel_pmd, initial_kernel_pmd,
2159 sizeof(pmd_t) * PTRS_PER_PMD);
2160 swapper_pg_dir[KERNEL_PGD_BOUNDARY] =
2161 __pgd(__pa(swapper_kernel_pmd) | _PAGE_PRESENT);
2162 set_page_prot(swapper_kernel_pmd, PAGE_KERNEL_RO);
2163
2164 set_page_prot(swapper_pg_dir, PAGE_KERNEL_RO);
2165 xen_write_cr3(cr3);
2166 pin_pagetable_pfn(MMUEXT_PIN_L3_TABLE, pfn);
2167
2168 pin_pagetable_pfn(MMUEXT_UNPIN_TABLE,
2169 PFN_DOWN(__pa(initial_page_table)));
2170 set_page_prot(initial_page_table, PAGE_KERNEL);
2171 set_page_prot(initial_kernel_pmd, PAGE_KERNEL);
2172
2173 pv_mmu_ops.write_cr3 = &xen_write_cr3;
2174}
2123 2175
2124__init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd, 2176__init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
2125 unsigned long max_pfn) 2177 unsigned long max_pfn)
2126{ 2178{
2127 pmd_t *kernel_pmd; 2179 pmd_t *kernel_pmd;
2128 2180
2129 level2_kernel_pgt = extend_brk(sizeof(pmd_t) * PTRS_PER_PMD, PAGE_SIZE); 2181 initial_kernel_pmd =
2182 extend_brk(sizeof(pmd_t) * PTRS_PER_PMD, PAGE_SIZE);
2130 2183
2131 max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->pt_base) + 2184 max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->pt_base) +
2132 xen_start_info->nr_pt_frames * PAGE_SIZE + 2185 xen_start_info->nr_pt_frames * PAGE_SIZE +
2133 512*1024); 2186 512*1024);
2134 2187
2135 kernel_pmd = m2v(pgd[KERNEL_PGD_BOUNDARY].pgd); 2188 kernel_pmd = m2v(pgd[KERNEL_PGD_BOUNDARY].pgd);
2136 memcpy(level2_kernel_pgt, kernel_pmd, sizeof(pmd_t) * PTRS_PER_PMD); 2189 memcpy(initial_kernel_pmd, kernel_pmd, sizeof(pmd_t) * PTRS_PER_PMD);
2137 2190
2138 xen_map_identity_early(level2_kernel_pgt, max_pfn); 2191 xen_map_identity_early(initial_kernel_pmd, max_pfn);
2139 2192
2140 memcpy(swapper_pg_dir, pgd, sizeof(pgd_t) * PTRS_PER_PGD); 2193 memcpy(initial_page_table, pgd, sizeof(pgd_t) * PTRS_PER_PGD);
2141 set_pgd(&swapper_pg_dir[KERNEL_PGD_BOUNDARY], 2194 initial_page_table[KERNEL_PGD_BOUNDARY] =
2142 __pgd(__pa(level2_kernel_pgt) | _PAGE_PRESENT)); 2195 __pgd(__pa(initial_kernel_pmd) | _PAGE_PRESENT);
2143 2196
2144 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO); 2197 set_page_prot(initial_kernel_pmd, PAGE_KERNEL_RO);
2145 set_page_prot(swapper_pg_dir, PAGE_KERNEL_RO); 2198 set_page_prot(initial_page_table, PAGE_KERNEL_RO);
2146 set_page_prot(empty_zero_page, PAGE_KERNEL_RO); 2199 set_page_prot(empty_zero_page, PAGE_KERNEL_RO);
2147 2200
2148 pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd))); 2201 pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd)));
2149 2202
2150 xen_write_cr3(__pa(swapper_pg_dir)); 2203 pin_pagetable_pfn(MMUEXT_PIN_L3_TABLE,
2151 2204 PFN_DOWN(__pa(initial_page_table)));
2152 pin_pagetable_pfn(MMUEXT_PIN_L3_TABLE, PFN_DOWN(__pa(swapper_pg_dir))); 2205 xen_write_cr3(__pa(initial_page_table));
2153 2206
2154 memblock_x86_reserve_range(__pa(xen_start_info->pt_base), 2207 memblock_x86_reserve_range(__pa(xen_start_info->pt_base),
2155 __pa(xen_start_info->pt_base + 2208 __pa(xen_start_info->pt_base +
2156 xen_start_info->nr_pt_frames * PAGE_SIZE), 2209 xen_start_info->nr_pt_frames * PAGE_SIZE),
2157 "XEN PAGETABLES"); 2210 "XEN PAGETABLES");
2158 2211
2159 return swapper_pg_dir; 2212 return initial_page_table;
2160} 2213}
2161#endif /* CONFIG_X86_64 */ 2214#endif /* CONFIG_X86_64 */
2162 2215
@@ -2290,7 +2343,11 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
2290 .write_cr2 = xen_write_cr2, 2343 .write_cr2 = xen_write_cr2,
2291 2344
2292 .read_cr3 = xen_read_cr3, 2345 .read_cr3 = xen_read_cr3,
2346#ifdef CONFIG_X86_32
2347 .write_cr3 = xen_write_cr3_init,
2348#else
2293 .write_cr3 = xen_write_cr3, 2349 .write_cr3 = xen_write_cr3,
2350#endif
2294 2351
2295 .flush_tlb_user = xen_flush_tlb, 2352 .flush_tlb_user = xen_flush_tlb,
2296 .flush_tlb_kernel = xen_flush_tlb, 2353 .flush_tlb_kernel = xen_flush_tlb,
@@ -2358,8 +2415,6 @@ void __init xen_init_mmu_ops(void)
2358 x86_init.paging.pagetable_setup_done = xen_pagetable_setup_done; 2415 x86_init.paging.pagetable_setup_done = xen_pagetable_setup_done;
2359 pv_mmu_ops = xen_mmu_ops; 2416 pv_mmu_ops = xen_mmu_ops;
2360 2417
2361 vmap_lazy_unmap = false;
2362
2363 memset(dummy_mapping, 0xff, PAGE_SIZE); 2418 memset(dummy_mapping, 0xff, PAGE_SIZE);
2364} 2419}
2365 2420
@@ -2627,7 +2682,8 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
2627 2682
2628 prot = __pgprot(pgprot_val(prot) | _PAGE_IOMAP); 2683 prot = __pgprot(pgprot_val(prot) | _PAGE_IOMAP);
2629 2684
2630 vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP; 2685 BUG_ON(!((vma->vm_flags & (VM_PFNMAP | VM_RESERVED | VM_IO)) ==
2686 (VM_PFNMAP | VM_RESERVED | VM_IO)));
2631 2687
2632 rmd.mfn = mfn; 2688 rmd.mfn = mfn;
2633 rmd.prot = prot; 2689 rmd.prot = prot;
diff --git a/arch/x86/xen/platform-pci-unplug.c b/arch/x86/xen/platform-pci-unplug.c
index 0f456386cce5..25c52f94a27c 100644
--- a/arch/x86/xen/platform-pci-unplug.c
+++ b/arch/x86/xen/platform-pci-unplug.c
@@ -68,7 +68,7 @@ static int __init check_platform_magic(void)
68 return 0; 68 return 0;
69} 69}
70 70
71void __init xen_unplug_emulated_devices(void) 71void xen_unplug_emulated_devices(void)
72{ 72{
73 int r; 73 int r;
74 74
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 769c4b01fa32..b5a7f928234b 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -23,7 +23,6 @@
23#include <xen/interface/callback.h> 23#include <xen/interface/callback.h>
24#include <xen/interface/memory.h> 24#include <xen/interface/memory.h>
25#include <xen/interface/physdev.h> 25#include <xen/interface/physdev.h>
26#include <xen/interface/memory.h>
27#include <xen/features.h> 26#include <xen/features.h>
28 27
29#include "xen-ops.h" 28#include "xen-ops.h"
@@ -182,24 +181,21 @@ char * __init xen_memory_setup(void)
182 for (i = 0; i < memmap.nr_entries; i++) { 181 for (i = 0; i < memmap.nr_entries; i++) {
183 unsigned long long end = map[i].addr + map[i].size; 182 unsigned long long end = map[i].addr + map[i].size;
184 183
185 if (map[i].type == E820_RAM) { 184 if (map[i].type == E820_RAM && end > mem_end) {
186 if (map[i].addr < mem_end && end > mem_end) { 185 /* RAM off the end - may be partially included */
187 /* Truncate region to max_mem. */ 186 u64 delta = min(map[i].size, end - mem_end);
188 u64 delta = end - mem_end;
189 187
190 map[i].size -= delta; 188 map[i].size -= delta;
191 extra_pages += PFN_DOWN(delta); 189 end -= delta;
192 190
193 end = mem_end; 191 extra_pages += PFN_DOWN(delta);
194 }
195 } 192 }
196 193
197 if (end > xen_extra_mem_start) 194 if (map[i].size > 0 && end > xen_extra_mem_start)
198 xen_extra_mem_start = end; 195 xen_extra_mem_start = end;
199 196
200 /* If region is non-RAM or below mem_end, add what remains */ 197 /* Add region if any remains */
201 if ((map[i].type != E820_RAM || map[i].addr < mem_end) && 198 if (map[i].size > 0)
202 map[i].size > 0)
203 e820_add_region(map[i].addr, map[i].size, map[i].type); 199 e820_add_region(map[i].addr, map[i].size, map[i].type);
204 } 200 }
205 201
@@ -248,26 +244,11 @@ char * __init xen_memory_setup(void)
248 else 244 else
249 extra_pages = 0; 245 extra_pages = 0;
250 246
251 if (!xen_initial_domain()) 247 xen_add_extra_mem(extra_pages);
252 xen_add_extra_mem(extra_pages);
253 248
254 return "Xen"; 249 return "Xen";
255} 250}
256 251
257static void xen_idle(void)
258{
259 local_irq_disable();
260
261 if (need_resched())
262 local_irq_enable();
263 else {
264 current_thread_info()->status &= ~TS_POLLING;
265 smp_mb__after_clear_bit();
266 safe_halt();
267 current_thread_info()->status |= TS_POLLING;
268 }
269}
270
271/* 252/*
272 * Set the bit indicating "nosegneg" library variants should be used. 253 * Set the bit indicating "nosegneg" library variants should be used.
273 * We only need to bother in pure 32-bit mode; compat 32-bit processes 254 * We only need to bother in pure 32-bit mode; compat 32-bit processes
@@ -337,9 +318,6 @@ void __cpuinit xen_enable_syscall(void)
337 318
338void __init xen_arch_setup(void) 319void __init xen_arch_setup(void)
339{ 320{
340 struct physdev_set_iopl set_iopl;
341 int rc;
342
343 xen_panic_handler_init(); 321 xen_panic_handler_init();
344 322
345 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments); 323 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
@@ -356,11 +334,6 @@ void __init xen_arch_setup(void)
356 xen_enable_sysenter(); 334 xen_enable_sysenter();
357 xen_enable_syscall(); 335 xen_enable_syscall();
358 336
359 set_iopl.iopl = 1;
360 rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
361 if (rc != 0)
362 printk(KERN_INFO "physdev_op failed %d\n", rc);
363
364#ifdef CONFIG_ACPI 337#ifdef CONFIG_ACPI
365 if (!(xen_start_info->flags & SIF_INITDOMAIN)) { 338 if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
366 printk(KERN_INFO "ACPI in unprivileged domain disabled\n"); 339 printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
@@ -372,7 +345,11 @@ void __init xen_arch_setup(void)
372 MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ? 345 MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
373 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE); 346 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
374 347
375 pm_idle = xen_idle; 348 /* Set up idle, making sure it calls safe_halt() pvop */
349#ifdef CONFIG_X86_32
350 boot_cpu_data.hlt_works_ok = 1;
351#endif
352 pm_idle = default_idle;
376 353
377 fiddle_vdso(); 354 fiddle_vdso();
378} 355}
diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c
index 1d789d56877c..9bbd63a129b5 100644
--- a/arch/x86/xen/suspend.c
+++ b/arch/x86/xen/suspend.c
@@ -31,6 +31,7 @@ void xen_hvm_post_suspend(int suspend_cancelled)
31 int cpu; 31 int cpu;
32 xen_hvm_init_shared_info(); 32 xen_hvm_init_shared_info();
33 xen_callback_vector(); 33 xen_callback_vector();
34 xen_unplug_emulated_devices();
34 if (xen_feature(XENFEAT_hvm_safe_pvclock)) { 35 if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
35 for_each_online_cpu(cpu) { 36 for_each_online_cpu(cpu) {
36 xen_setup_runstate_info(cpu); 37 xen_setup_runstate_info(cpu);
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index b2bb5aa3b054..5da5e53fb94c 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -426,6 +426,8 @@ void xen_timer_resume(void)
426{ 426{
427 int cpu; 427 int cpu;
428 428
429 pvclock_resume();
430
429 if (xen_clockevent != &xen_vcpuop_clockevent) 431 if (xen_clockevent != &xen_vcpuop_clockevent)
430 return; 432 return;
431 433
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 64044747348e..9d41bf985757 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -43,7 +43,7 @@ void xen_vcpu_restore(void);
43 43
44void xen_callback_vector(void); 44void xen_callback_vector(void);
45void xen_hvm_init_shared_info(void); 45void xen_hvm_init_shared_info(void);
46void __init xen_unplug_emulated_devices(void); 46void xen_unplug_emulated_devices(void);
47 47
48void __init xen_build_dynamic_phys_to_machine(void); 48void __init xen_build_dynamic_phys_to_machine(void);
49 49
diff --git a/block/blk-map.c b/block/blk-map.c
index 5d5dbe47c228..e663ac2d8e68 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -201,12 +201,13 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
201 for (i = 0; i < iov_count; i++) { 201 for (i = 0; i < iov_count; i++) {
202 unsigned long uaddr = (unsigned long)iov[i].iov_base; 202 unsigned long uaddr = (unsigned long)iov[i].iov_base;
203 203
204 if (!iov[i].iov_len)
205 return -EINVAL;
206
204 if (uaddr & queue_dma_alignment(q)) { 207 if (uaddr & queue_dma_alignment(q)) {
205 unaligned = 1; 208 unaligned = 1;
206 break; 209 break;
207 } 210 }
208 if (!iov[i].iov_len)
209 return -EINVAL;
210 } 211 }
211 212
212 if (unaligned || (q->dma_pad_mask & len) || map_data) 213 if (unaligned || (q->dma_pad_mask & len) || map_data)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 77b7c26df6b5..74bc4a768f32 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -21,7 +21,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
21 return 0; 21 return 0;
22 22
23 fbio = bio; 23 fbio = bio;
24 cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 24 cluster = blk_queue_cluster(q);
25 seg_size = 0; 25 seg_size = 0;
26 nr_phys_segs = 0; 26 nr_phys_segs = 0;
27 for_each_bio(bio) { 27 for_each_bio(bio) {
@@ -87,7 +87,7 @@ EXPORT_SYMBOL(blk_recount_segments);
87static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, 87static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
88 struct bio *nxt) 88 struct bio *nxt)
89{ 89{
90 if (!test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags)) 90 if (!blk_queue_cluster(q))
91 return 0; 91 return 0;
92 92
93 if (bio->bi_seg_back_size + nxt->bi_seg_front_size > 93 if (bio->bi_seg_back_size + nxt->bi_seg_front_size >
@@ -123,7 +123,7 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
123 int nsegs, cluster; 123 int nsegs, cluster;
124 124
125 nsegs = 0; 125 nsegs = 0;
126 cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 126 cluster = blk_queue_cluster(q);
127 127
128 /* 128 /*
129 * for each bio in rq 129 * for each bio in rq
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 701859fb9647..36c8c1f2af18 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -126,7 +126,7 @@ void blk_set_default_limits(struct queue_limits *lim)
126 lim->alignment_offset = 0; 126 lim->alignment_offset = 0;
127 lim->io_opt = 0; 127 lim->io_opt = 0;
128 lim->misaligned = 0; 128 lim->misaligned = 0;
129 lim->no_cluster = 0; 129 lim->cluster = 1;
130} 130}
131EXPORT_SYMBOL(blk_set_default_limits); 131EXPORT_SYMBOL(blk_set_default_limits);
132 132
@@ -229,8 +229,8 @@ void blk_queue_bounce_limit(struct request_queue *q, u64 dma_mask)
229EXPORT_SYMBOL(blk_queue_bounce_limit); 229EXPORT_SYMBOL(blk_queue_bounce_limit);
230 230
231/** 231/**
232 * blk_queue_max_hw_sectors - set max sectors for a request for this queue 232 * blk_limits_max_hw_sectors - set hard and soft limit of max sectors for request
233 * @q: the request queue for the device 233 * @limits: the queue limits
234 * @max_hw_sectors: max hardware sectors in the usual 512b unit 234 * @max_hw_sectors: max hardware sectors in the usual 512b unit
235 * 235 *
236 * Description: 236 * Description:
@@ -244,7 +244,7 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
244 * per-device basis in /sys/block/<device>/queue/max_sectors_kb. 244 * per-device basis in /sys/block/<device>/queue/max_sectors_kb.
245 * The soft limit can not exceed max_hw_sectors. 245 * The soft limit can not exceed max_hw_sectors.
246 **/ 246 **/
247void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors) 247void blk_limits_max_hw_sectors(struct queue_limits *limits, unsigned int max_hw_sectors)
248{ 248{
249 if ((max_hw_sectors << 9) < PAGE_CACHE_SIZE) { 249 if ((max_hw_sectors << 9) < PAGE_CACHE_SIZE) {
250 max_hw_sectors = 1 << (PAGE_CACHE_SHIFT - 9); 250 max_hw_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
@@ -252,9 +252,23 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_secto
252 __func__, max_hw_sectors); 252 __func__, max_hw_sectors);
253 } 253 }
254 254
255 q->limits.max_hw_sectors = max_hw_sectors; 255 limits->max_hw_sectors = max_hw_sectors;
256 q->limits.max_sectors = min_t(unsigned int, max_hw_sectors, 256 limits->max_sectors = min_t(unsigned int, max_hw_sectors,
257 BLK_DEF_MAX_SECTORS); 257 BLK_DEF_MAX_SECTORS);
258}
259EXPORT_SYMBOL(blk_limits_max_hw_sectors);
260
261/**
262 * blk_queue_max_hw_sectors - set max sectors for a request for this queue
263 * @q: the request queue for the device
264 * @max_hw_sectors: max hardware sectors in the usual 512b unit
265 *
266 * Description:
267 * See description for blk_limits_max_hw_sectors().
268 **/
269void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)
270{
271 blk_limits_max_hw_sectors(&q->limits, max_hw_sectors);
258} 272}
259EXPORT_SYMBOL(blk_queue_max_hw_sectors); 273EXPORT_SYMBOL(blk_queue_max_hw_sectors);
260 274
@@ -464,15 +478,6 @@ EXPORT_SYMBOL(blk_queue_io_opt);
464void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b) 478void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
465{ 479{
466 blk_stack_limits(&t->limits, &b->limits, 0); 480 blk_stack_limits(&t->limits, &b->limits, 0);
467
468 if (!t->queue_lock)
469 WARN_ON_ONCE(1);
470 else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {
471 unsigned long flags;
472 spin_lock_irqsave(t->queue_lock, flags);
473 queue_flag_clear(QUEUE_FLAG_CLUSTER, t);
474 spin_unlock_irqrestore(t->queue_lock, flags);
475 }
476} 481}
477EXPORT_SYMBOL(blk_queue_stack_limits); 482EXPORT_SYMBOL(blk_queue_stack_limits);
478 483
@@ -545,7 +550,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
545 t->io_min = max(t->io_min, b->io_min); 550 t->io_min = max(t->io_min, b->io_min);
546 t->io_opt = lcm(t->io_opt, b->io_opt); 551 t->io_opt = lcm(t->io_opt, b->io_opt);
547 552
548 t->no_cluster |= b->no_cluster; 553 t->cluster &= b->cluster;
549 t->discard_zeroes_data &= b->discard_zeroes_data; 554 t->discard_zeroes_data &= b->discard_zeroes_data;
550 555
551 /* Physical block size a multiple of the logical block size? */ 556 /* Physical block size a multiple of the logical block size? */
@@ -641,7 +646,6 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
641 sector_t offset) 646 sector_t offset)
642{ 647{
643 struct request_queue *t = disk->queue; 648 struct request_queue *t = disk->queue;
644 struct request_queue *b = bdev_get_queue(bdev);
645 649
646 if (bdev_stack_limits(&t->limits, bdev, offset >> 9) < 0) { 650 if (bdev_stack_limits(&t->limits, bdev, offset >> 9) < 0) {
647 char top[BDEVNAME_SIZE], bottom[BDEVNAME_SIZE]; 651 char top[BDEVNAME_SIZE], bottom[BDEVNAME_SIZE];
@@ -652,17 +656,6 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
652 printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n", 656 printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n",
653 top, bottom); 657 top, bottom);
654 } 658 }
655
656 if (!t->queue_lock)
657 WARN_ON_ONCE(1);
658 else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {
659 unsigned long flags;
660
661 spin_lock_irqsave(t->queue_lock, flags);
662 if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags))
663 queue_flag_clear(QUEUE_FLAG_CLUSTER, t);
664 spin_unlock_irqrestore(t->queue_lock, flags);
665 }
666} 659}
667EXPORT_SYMBOL(disk_stack_limits); 660EXPORT_SYMBOL(disk_stack_limits);
668 661
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 013457f47fdc..41fb69150b4d 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -119,7 +119,7 @@ static ssize_t queue_max_integrity_segments_show(struct request_queue *q, char *
119 119
120static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page) 120static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page)
121{ 121{
122 if (test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags)) 122 if (blk_queue_cluster(q))
123 return queue_var_show(queue_max_segment_size(q), (page)); 123 return queue_var_show(queue_max_segment_size(q), (page));
124 124
125 return queue_var_show(PAGE_CACHE_SIZE, (page)); 125 return queue_var_show(PAGE_CACHE_SIZE, (page));
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 56ad4531b412..381b09bb562b 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -355,6 +355,12 @@ throtl_start_new_slice(struct throtl_data *td, struct throtl_grp *tg, bool rw)
355 tg->slice_end[rw], jiffies); 355 tg->slice_end[rw], jiffies);
356} 356}
357 357
358static inline void throtl_set_slice_end(struct throtl_data *td,
359 struct throtl_grp *tg, bool rw, unsigned long jiffy_end)
360{
361 tg->slice_end[rw] = roundup(jiffy_end, throtl_slice);
362}
363
358static inline void throtl_extend_slice(struct throtl_data *td, 364static inline void throtl_extend_slice(struct throtl_data *td,
359 struct throtl_grp *tg, bool rw, unsigned long jiffy_end) 365 struct throtl_grp *tg, bool rw, unsigned long jiffy_end)
360{ 366{
@@ -391,6 +397,16 @@ throtl_trim_slice(struct throtl_data *td, struct throtl_grp *tg, bool rw)
391 if (throtl_slice_used(td, tg, rw)) 397 if (throtl_slice_used(td, tg, rw))
392 return; 398 return;
393 399
400 /*
401 * A bio has been dispatched. Also adjust slice_end. It might happen
402 * that initially cgroup limit was very low resulting in high
403 * slice_end, but later limit was bumped up and bio was dispached
404 * sooner, then we need to reduce slice_end. A high bogus slice_end
405 * is bad because it does not allow new slice to start.
406 */
407
408 throtl_set_slice_end(td, tg, rw, jiffies + throtl_slice);
409
394 time_elapsed = jiffies - tg->slice_start[rw]; 410 time_elapsed = jiffies - tg->slice_start[rw];
395 411
396 nr_slices = time_elapsed / throtl_slice; 412 nr_slices = time_elapsed / throtl_slice;
@@ -645,7 +661,7 @@ static int throtl_dispatch_tg(struct throtl_data *td, struct throtl_grp *tg,
645{ 661{
646 unsigned int nr_reads = 0, nr_writes = 0; 662 unsigned int nr_reads = 0, nr_writes = 0;
647 unsigned int max_nr_reads = throtl_grp_quantum*3/4; 663 unsigned int max_nr_reads = throtl_grp_quantum*3/4;
648 unsigned int max_nr_writes = throtl_grp_quantum - nr_reads; 664 unsigned int max_nr_writes = throtl_grp_quantum - max_nr_reads;
649 struct bio *bio; 665 struct bio *bio;
650 666
651 /* Try to dispatch 75% READS and 25% WRITES */ 667 /* Try to dispatch 75% READS and 25% WRITES */
@@ -709,26 +725,21 @@ static void throtl_process_limit_change(struct throtl_data *td)
709 struct throtl_grp *tg; 725 struct throtl_grp *tg;
710 struct hlist_node *pos, *n; 726 struct hlist_node *pos, *n;
711 727
712 /*
713 * Make sure atomic_inc() effects from
714 * throtl_update_blkio_group_read_bps(), group of functions are
715 * visible.
716 * Is this required or smp_mb__after_atomic_inc() was suffcient
717 * after the atomic_inc().
718 */
719 smp_rmb();
720 if (!atomic_read(&td->limits_changed)) 728 if (!atomic_read(&td->limits_changed))
721 return; 729 return;
722 730
723 throtl_log(td, "limit changed =%d", atomic_read(&td->limits_changed)); 731 throtl_log(td, "limit changed =%d", atomic_read(&td->limits_changed));
724 732
725 hlist_for_each_entry_safe(tg, pos, n, &td->tg_list, tg_node) { 733 /*
726 /* 734 * Make sure updates from throtl_update_blkio_group_read_bps() group
727 * Do I need an smp_rmb() here to make sure tg->limits_changed 735 * of functions to tg->limits_changed are visible. We do not
728 * update is visible. I am relying on smp_rmb() at the 736 * want update td->limits_changed to be visible but update to
729 * beginning of function and not putting a new one here. 737 * tg->limits_changed not being visible yet on this cpu. Hence
730 */ 738 * the read barrier.
739 */
740 smp_rmb();
731 741
742 hlist_for_each_entry_safe(tg, pos, n, &td->tg_list, tg_node) {
732 if (throtl_tg_on_rr(tg) && tg->limits_changed) { 743 if (throtl_tg_on_rr(tg) && tg->limits_changed) {
733 throtl_log_tg(td, tg, "limit change rbps=%llu wbps=%llu" 744 throtl_log_tg(td, tg, "limit change rbps=%llu wbps=%llu"
734 " riops=%u wiops=%u", tg->bps[READ], 745 " riops=%u wiops=%u", tg->bps[READ],
diff --git a/block/bsg.c b/block/bsg.c
index f20d6a789d48..0c8b64a16484 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -250,6 +250,14 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
250 int ret, rw; 250 int ret, rw;
251 unsigned int dxfer_len; 251 unsigned int dxfer_len;
252 void *dxferp = NULL; 252 void *dxferp = NULL;
253 struct bsg_class_device *bcd = &q->bsg_dev;
254
255 /* if the LLD has been removed then the bsg_unregister_queue will
256 * eventually be called and the class_dev was freed, so we can no
257 * longer use this request_queue. Return no such address.
258 */
259 if (!bcd->class_dev)
260 return ERR_PTR(-ENXIO);
253 261
254 dprintk("map hdr %llx/%u %llx/%u\n", (unsigned long long) hdr->dout_xferp, 262 dprintk("map hdr %llx/%u %llx/%u\n", (unsigned long long) hdr->dout_xferp,
255 hdr->dout_xfer_len, (unsigned long long) hdr->din_xferp, 263 hdr->dout_xfer_len, (unsigned long long) hdr->din_xferp,
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
index 58c6ee5b010c..cc3eb78e333a 100644
--- a/block/compat_ioctl.c
+++ b/block/compat_ioctl.c
@@ -8,7 +8,6 @@
8#include <linux/hdreg.h> 8#include <linux/hdreg.h>
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/syscalls.h> 10#include <linux/syscalls.h>
11#include <linux/smp_lock.h>
12#include <linux/types.h> 11#include <linux/types.h>
13#include <linux/uaccess.h> 12#include <linux/uaccess.h>
14 13
diff --git a/block/ioctl.c b/block/ioctl.c
index 3d866d0037f2..a9a302eba01e 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -5,7 +5,6 @@
5#include <linux/hdreg.h> 5#include <linux/hdreg.h>
6#include <linux/backing-dev.h> 6#include <linux/backing-dev.h>
7#include <linux/buffer_head.h> 7#include <linux/buffer_head.h>
8#include <linux/smp_lock.h>
9#include <linux/blktrace_api.h> 8#include <linux/blktrace_api.h>
10#include <asm/uaccess.h> 9#include <asm/uaccess.h>
11 10
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index ba9afeaa23ac..25d3aaebc10d 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -100,24 +100,7 @@ static const struct file_operations acpi_ac_fops = {
100 .release = single_release, 100 .release = single_release,
101}; 101};
102#endif 102#endif
103static int get_ac_property(struct power_supply *psy,
104 enum power_supply_property psp,
105 union power_supply_propval *val)
106{
107 struct acpi_ac *ac = to_acpi_ac(psy);
108 switch (psp) {
109 case POWER_SUPPLY_PROP_ONLINE:
110 val->intval = ac->state;
111 break;
112 default:
113 return -EINVAL;
114 }
115 return 0;
116}
117 103
118static enum power_supply_property ac_props[] = {
119 POWER_SUPPLY_PROP_ONLINE,
120};
121/* -------------------------------------------------------------------------- 104/* --------------------------------------------------------------------------
122 AC Adapter Management 105 AC Adapter Management
123 -------------------------------------------------------------------------- */ 106 -------------------------------------------------------------------------- */
@@ -140,6 +123,35 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
140 return 0; 123 return 0;
141} 124}
142 125
126/* --------------------------------------------------------------------------
127 sysfs I/F
128 -------------------------------------------------------------------------- */
129static int get_ac_property(struct power_supply *psy,
130 enum power_supply_property psp,
131 union power_supply_propval *val)
132{
133 struct acpi_ac *ac = to_acpi_ac(psy);
134
135 if (!ac)
136 return -ENODEV;
137
138 if (acpi_ac_get_state(ac))
139 return -ENODEV;
140
141 switch (psp) {
142 case POWER_SUPPLY_PROP_ONLINE:
143 val->intval = ac->state;
144 break;
145 default:
146 return -EINVAL;
147 }
148 return 0;
149}
150
151static enum power_supply_property ac_props[] = {
152 POWER_SUPPLY_PROP_ONLINE,
153};
154
143#ifdef CONFIG_ACPI_PROCFS_POWER 155#ifdef CONFIG_ACPI_PROCFS_POWER
144/* -------------------------------------------------------------------------- 156/* --------------------------------------------------------------------------
145 FS Interface (/proc) 157 FS Interface (/proc)
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
index 1211c03149e8..5850d320404c 100644
--- a/drivers/acpi/apei/erst.c
+++ b/drivers/acpi/apei/erst.c
@@ -86,7 +86,7 @@ static struct erst_erange {
86 * It is used to provide exclusive accessing for ERST Error Log 86 * It is used to provide exclusive accessing for ERST Error Log
87 * Address Range too. 87 * Address Range too.
88 */ 88 */
89static DEFINE_SPINLOCK(erst_lock); 89static DEFINE_RAW_SPINLOCK(erst_lock);
90 90
91static inline int erst_errno(int command_status) 91static inline int erst_errno(int command_status)
92{ 92{
@@ -421,9 +421,9 @@ ssize_t erst_get_record_count(void)
421 if (erst_disable) 421 if (erst_disable)
422 return -ENODEV; 422 return -ENODEV;
423 423
424 spin_lock_irqsave(&erst_lock, flags); 424 raw_spin_lock_irqsave(&erst_lock, flags);
425 count = __erst_get_record_count(); 425 count = __erst_get_record_count();
426 spin_unlock_irqrestore(&erst_lock, flags); 426 raw_spin_unlock_irqrestore(&erst_lock, flags);
427 427
428 return count; 428 return count;
429} 429}
@@ -456,9 +456,9 @@ int erst_get_next_record_id(u64 *record_id)
456 if (erst_disable) 456 if (erst_disable)
457 return -ENODEV; 457 return -ENODEV;
458 458
459 spin_lock_irqsave(&erst_lock, flags); 459 raw_spin_lock_irqsave(&erst_lock, flags);
460 rc = __erst_get_next_record_id(record_id); 460 rc = __erst_get_next_record_id(record_id);
461 spin_unlock_irqrestore(&erst_lock, flags); 461 raw_spin_unlock_irqrestore(&erst_lock, flags);
462 462
463 return rc; 463 return rc;
464} 464}
@@ -624,17 +624,17 @@ int erst_write(const struct cper_record_header *record)
624 return -EINVAL; 624 return -EINVAL;
625 625
626 if (erst_erange.attr & ERST_RANGE_NVRAM) { 626 if (erst_erange.attr & ERST_RANGE_NVRAM) {
627 if (!spin_trylock_irqsave(&erst_lock, flags)) 627 if (!raw_spin_trylock_irqsave(&erst_lock, flags))
628 return -EBUSY; 628 return -EBUSY;
629 rc = __erst_write_to_nvram(record); 629 rc = __erst_write_to_nvram(record);
630 spin_unlock_irqrestore(&erst_lock, flags); 630 raw_spin_unlock_irqrestore(&erst_lock, flags);
631 return rc; 631 return rc;
632 } 632 }
633 633
634 if (record->record_length > erst_erange.size) 634 if (record->record_length > erst_erange.size)
635 return -EINVAL; 635 return -EINVAL;
636 636
637 if (!spin_trylock_irqsave(&erst_lock, flags)) 637 if (!raw_spin_trylock_irqsave(&erst_lock, flags))
638 return -EBUSY; 638 return -EBUSY;
639 memcpy(erst_erange.vaddr, record, record->record_length); 639 memcpy(erst_erange.vaddr, record, record->record_length);
640 rcd_erange = erst_erange.vaddr; 640 rcd_erange = erst_erange.vaddr;
@@ -642,7 +642,7 @@ int erst_write(const struct cper_record_header *record)
642 memcpy(&rcd_erange->persistence_information, "ER", 2); 642 memcpy(&rcd_erange->persistence_information, "ER", 2);
643 643
644 rc = __erst_write_to_storage(0); 644 rc = __erst_write_to_storage(0);
645 spin_unlock_irqrestore(&erst_lock, flags); 645 raw_spin_unlock_irqrestore(&erst_lock, flags);
646 646
647 return rc; 647 return rc;
648} 648}
@@ -696,9 +696,9 @@ ssize_t erst_read(u64 record_id, struct cper_record_header *record,
696 if (erst_disable) 696 if (erst_disable)
697 return -ENODEV; 697 return -ENODEV;
698 698
699 spin_lock_irqsave(&erst_lock, flags); 699 raw_spin_lock_irqsave(&erst_lock, flags);
700 len = __erst_read(record_id, record, buflen); 700 len = __erst_read(record_id, record, buflen);
701 spin_unlock_irqrestore(&erst_lock, flags); 701 raw_spin_unlock_irqrestore(&erst_lock, flags);
702 return len; 702 return len;
703} 703}
704EXPORT_SYMBOL_GPL(erst_read); 704EXPORT_SYMBOL_GPL(erst_read);
@@ -719,20 +719,20 @@ ssize_t erst_read_next(struct cper_record_header *record, size_t buflen)
719 if (erst_disable) 719 if (erst_disable)
720 return -ENODEV; 720 return -ENODEV;
721 721
722 spin_lock_irqsave(&erst_lock, flags); 722 raw_spin_lock_irqsave(&erst_lock, flags);
723 rc = __erst_get_next_record_id(&record_id); 723 rc = __erst_get_next_record_id(&record_id);
724 if (rc) { 724 if (rc) {
725 spin_unlock_irqrestore(&erst_lock, flags); 725 raw_spin_unlock_irqrestore(&erst_lock, flags);
726 return rc; 726 return rc;
727 } 727 }
728 /* no more record */ 728 /* no more record */
729 if (record_id == APEI_ERST_INVALID_RECORD_ID) { 729 if (record_id == APEI_ERST_INVALID_RECORD_ID) {
730 spin_unlock_irqrestore(&erst_lock, flags); 730 raw_spin_unlock_irqrestore(&erst_lock, flags);
731 return 0; 731 return 0;
732 } 732 }
733 733
734 len = __erst_read(record_id, record, buflen); 734 len = __erst_read(record_id, record, buflen);
735 spin_unlock_irqrestore(&erst_lock, flags); 735 raw_spin_unlock_irqrestore(&erst_lock, flags);
736 736
737 return len; 737 return len;
738} 738}
@@ -746,12 +746,12 @@ int erst_clear(u64 record_id)
746 if (erst_disable) 746 if (erst_disable)
747 return -ENODEV; 747 return -ENODEV;
748 748
749 spin_lock_irqsave(&erst_lock, flags); 749 raw_spin_lock_irqsave(&erst_lock, flags);
750 if (erst_erange.attr & ERST_RANGE_NVRAM) 750 if (erst_erange.attr & ERST_RANGE_NVRAM)
751 rc = __erst_clear_from_nvram(record_id); 751 rc = __erst_clear_from_nvram(record_id);
752 else 752 else
753 rc = __erst_clear_from_storage(record_id); 753 rc = __erst_clear_from_storage(record_id);
754 spin_unlock_irqrestore(&erst_lock, flags); 754 raw_spin_unlock_irqrestore(&erst_lock, flags);
755 755
756 return rc; 756 return rc;
757} 757}
diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index 1a3508a7fe03..daa7bc63f1d4 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -46,9 +46,9 @@ EXPORT_SYMBOL_GPL(hest_disable);
46 46
47/* HEST table parsing */ 47/* HEST table parsing */
48 48
49static struct acpi_table_hest *hest_tab; 49static struct acpi_table_hest *__read_mostly hest_tab;
50 50
51static int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = { 51static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
52 [ACPI_HEST_TYPE_IA32_CHECK] = -1, /* need further calculation */ 52 [ACPI_HEST_TYPE_IA32_CHECK] = -1, /* need further calculation */
53 [ACPI_HEST_TYPE_IA32_CORRECTED_CHECK] = -1, 53 [ACPI_HEST_TYPE_IA32_CORRECTED_CHECK] = -1,
54 [ACPI_HEST_TYPE_IA32_NMI] = sizeof(struct acpi_hest_ia_nmi), 54 [ACPI_HEST_TYPE_IA32_NMI] = sizeof(struct acpi_hest_ia_nmi),
@@ -126,7 +126,7 @@ struct ghes_arr {
126 unsigned int count; 126 unsigned int count;
127}; 127};
128 128
129static int hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data) 129static int __init hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data)
130{ 130{
131 int *count = data; 131 int *count = data;
132 132
@@ -135,7 +135,7 @@ static int hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data)
135 return 0; 135 return 0;
136} 136}
137 137
138static int hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data) 138static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)
139{ 139{
140 struct platform_device *ghes_dev; 140 struct platform_device *ghes_dev;
141 struct ghes_arr *ghes_arr = data; 141 struct ghes_arr *ghes_arr = data;
@@ -165,7 +165,7 @@ err:
165 return rc; 165 return rc;
166} 166}
167 167
168static int hest_ghes_dev_register(unsigned int ghes_count) 168static int __init hest_ghes_dev_register(unsigned int ghes_count)
169{ 169{
170 int rc, i; 170 int rc, i;
171 struct ghes_arr ghes_arr; 171 struct ghes_arr ghes_arr;
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 95649d373071..9fb9d5ac939d 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -130,6 +130,8 @@ struct acpi_battery {
130 unsigned long flags; 130 unsigned long flags;
131}; 131};
132 132
133static int acpi_battery_update(struct acpi_battery *battery);
134
133#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); 135#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat);
134 136
135inline int acpi_battery_present(struct acpi_battery *battery) 137inline int acpi_battery_present(struct acpi_battery *battery)
@@ -184,6 +186,9 @@ static int acpi_battery_get_property(struct power_supply *psy,
184 int ret = 0; 186 int ret = 0;
185 struct acpi_battery *battery = to_acpi_battery(psy); 187 struct acpi_battery *battery = to_acpi_battery(psy);
186 188
189 if (acpi_battery_update(battery))
190 return -ENODEV;
191
187 if (acpi_battery_present(battery)) { 192 if (acpi_battery_present(battery)) {
188 /* run battery update only if it is present */ 193 /* run battery update only if it is present */
189 acpi_battery_get_state(battery); 194 acpi_battery_get_state(battery);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 372ff80b7b0c..302b31ed31f1 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -934,6 +934,9 @@ static struct dmi_system_id __initdata ec_dmi_table[] = {
934 ec_flag_msi, "MSI hardware", { 934 ec_flag_msi, "MSI hardware", {
935 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-Star")}, NULL}, 935 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-Star")}, NULL},
936 { 936 {
937 ec_flag_msi, "MSI hardware", {
938 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-STAR")}, NULL},
939 {
937 ec_validate_ecdt, "ASUS hardware", { 940 ec_validate_ecdt, "ASUS hardware", {
938 DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL}, 941 DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL},
939 {}, 942 {},
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 966feddf6b1b..055d7b701fff 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -110,9 +110,6 @@ struct acpi_ioremap {
110static LIST_HEAD(acpi_ioremaps); 110static LIST_HEAD(acpi_ioremaps);
111static DEFINE_SPINLOCK(acpi_ioremap_lock); 111static DEFINE_SPINLOCK(acpi_ioremap_lock);
112 112
113#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */
114static char osi_setup_string[OSI_STRING_LENGTH_MAX];
115
116static void __init acpi_osi_setup_late(void); 113static void __init acpi_osi_setup_late(void);
117 114
118/* 115/*
@@ -152,8 +149,7 @@ static struct osi_linux {
152 unsigned int enable:1; 149 unsigned int enable:1;
153 unsigned int dmi:1; 150 unsigned int dmi:1;
154 unsigned int cmdline:1; 151 unsigned int cmdline:1;
155 unsigned int known:1; 152} osi_linux = {0, 0, 0};
156} osi_linux = { 0, 0, 0, 0};
157 153
158static u32 acpi_osi_handler(acpi_string interface, u32 supported) 154static u32 acpi_osi_handler(acpi_string interface, u32 supported)
159{ 155{
@@ -1055,13 +1051,53 @@ static int __init acpi_os_name_setup(char *str)
1055 1051
1056__setup("acpi_os_name=", acpi_os_name_setup); 1052__setup("acpi_os_name=", acpi_os_name_setup);
1057 1053
1054#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */
1055#define OSI_STRING_ENTRIES_MAX 16 /* arbitrary */
1056
1057struct osi_setup_entry {
1058 char string[OSI_STRING_LENGTH_MAX];
1059 bool enable;
1060};
1061
1062static struct osi_setup_entry __initdata osi_setup_entries[OSI_STRING_ENTRIES_MAX];
1063
1064void __init acpi_osi_setup(char *str)
1065{
1066 struct osi_setup_entry *osi;
1067 bool enable = true;
1068 int i;
1069
1070 if (!acpi_gbl_create_osi_method)
1071 return;
1072
1073 if (str == NULL || *str == '\0') {
1074 printk(KERN_INFO PREFIX "_OSI method disabled\n");
1075 acpi_gbl_create_osi_method = FALSE;
1076 return;
1077 }
1078
1079 if (*str == '!') {
1080 str++;
1081 enable = false;
1082 }
1083
1084 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1085 osi = &osi_setup_entries[i];
1086 if (!strcmp(osi->string, str)) {
1087 osi->enable = enable;
1088 break;
1089 } else if (osi->string[0] == '\0') {
1090 osi->enable = enable;
1091 strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);
1092 break;
1093 }
1094 }
1095}
1096
1058static void __init set_osi_linux(unsigned int enable) 1097static void __init set_osi_linux(unsigned int enable)
1059{ 1098{
1060 if (osi_linux.enable != enable) { 1099 if (osi_linux.enable != enable)
1061 osi_linux.enable = enable; 1100 osi_linux.enable = enable;
1062 printk(KERN_NOTICE PREFIX "%sed _OSI(Linux)\n",
1063 enable ? "Add": "Delet");
1064 }
1065 1101
1066 if (osi_linux.enable) 1102 if (osi_linux.enable)
1067 acpi_osi_setup("Linux"); 1103 acpi_osi_setup("Linux");
@@ -1073,7 +1109,8 @@ static void __init set_osi_linux(unsigned int enable)
1073 1109
1074static void __init acpi_cmdline_osi_linux(unsigned int enable) 1110static void __init acpi_cmdline_osi_linux(unsigned int enable)
1075{ 1111{
1076 osi_linux.cmdline = 1; /* cmdline set the default */ 1112 osi_linux.cmdline = 1; /* cmdline set the default and override DMI */
1113 osi_linux.dmi = 0;
1077 set_osi_linux(enable); 1114 set_osi_linux(enable);
1078 1115
1079 return; 1116 return;
@@ -1081,15 +1118,12 @@ static void __init acpi_cmdline_osi_linux(unsigned int enable)
1081 1118
1082void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d) 1119void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
1083{ 1120{
1084 osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */
1085
1086 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident); 1121 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
1087 1122
1088 if (enable == -1) 1123 if (enable == -1)
1089 return; 1124 return;
1090 1125
1091 osi_linux.known = 1; /* DMI knows which OSI(Linux) default needed */ 1126 osi_linux.dmi = 1; /* DMI knows that this box asks OSI(Linux) */
1092
1093 set_osi_linux(enable); 1127 set_osi_linux(enable);
1094 1128
1095 return; 1129 return;
@@ -1104,37 +1138,44 @@ void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
1104 */ 1138 */
1105static void __init acpi_osi_setup_late(void) 1139static void __init acpi_osi_setup_late(void)
1106{ 1140{
1107 char *str = osi_setup_string; 1141 struct osi_setup_entry *osi;
1142 char *str;
1143 int i;
1144 acpi_status status;
1108 1145
1109 if (*str == '\0') 1146 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1110 return; 1147 osi = &osi_setup_entries[i];
1148 str = osi->string;
1111 1149
1112 if (!strcmp("!Linux", str)) { 1150 if (*str == '\0')
1113 acpi_cmdline_osi_linux(0); /* !enable */ 1151 break;
1114 } else if (*str == '!') { 1152 if (osi->enable) {
1115 if (acpi_remove_interface(++str) == AE_OK) 1153 status = acpi_install_interface(str);
1116 printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str); 1154
1117 } else if (!strcmp("Linux", str)) { 1155 if (ACPI_SUCCESS(status))
1118 acpi_cmdline_osi_linux(1); /* enable */ 1156 printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
1119 } else { 1157 } else {
1120 if (acpi_install_interface(str) == AE_OK) 1158 status = acpi_remove_interface(str);
1121 printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str); 1159
1160 if (ACPI_SUCCESS(status))
1161 printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
1162 }
1122 } 1163 }
1123} 1164}
1124 1165
1125int __init acpi_osi_setup(char *str) 1166static int __init osi_setup(char *str)
1126{ 1167{
1127 if (str == NULL || *str == '\0') { 1168 if (str && !strcmp("Linux", str))
1128 printk(KERN_INFO PREFIX "_OSI method disabled\n"); 1169 acpi_cmdline_osi_linux(1);
1129 acpi_gbl_create_osi_method = FALSE; 1170 else if (str && !strcmp("!Linux", str))
1130 } else { 1171 acpi_cmdline_osi_linux(0);
1131 strncpy(osi_setup_string, str, OSI_STRING_LENGTH_MAX); 1172 else
1132 } 1173 acpi_osi_setup(str);
1133 1174
1134 return 1; 1175 return 1;
1135} 1176}
1136 1177
1137__setup("acpi_osi=", acpi_osi_setup); 1178__setup("acpi_osi=", osi_setup);
1138 1179
1139/* enable serialization to combat AE_ALREADY_EXISTS errors */ 1180/* enable serialization to combat AE_ALREADY_EXISTS errors */
1140static int __init acpi_serialize_setup(char *str) 1181static int __init acpi_serialize_setup(char *str)
@@ -1530,7 +1571,7 @@ acpi_status __init acpi_os_initialize(void)
1530 return AE_OK; 1571 return AE_OK;
1531} 1572}
1532 1573
1533acpi_status acpi_os_initialize1(void) 1574acpi_status __init acpi_os_initialize1(void)
1534{ 1575{
1535 kacpid_wq = create_workqueue("kacpid"); 1576 kacpid_wq = create_workqueue("kacpid");
1536 kacpi_notify_wq = create_workqueue("kacpi_notify"); 1577 kacpi_notify_wq = create_workqueue("kacpi_notify");
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 67dedeed144c..4c9c2fb5d98f 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -213,11 +213,13 @@ static int acpi_power_on(acpi_handle handle)
213 resource->name)); 213 resource->name));
214 } else { 214 } else {
215 result = __acpi_power_on(resource); 215 result = __acpi_power_on(resource);
216 if (result)
217 resource->ref_count--;
216 } 218 }
217 219
218 mutex_unlock(&resource->resource_lock); 220 mutex_unlock(&resource->resource_lock);
219 221
220 return 0; 222 return result;
221} 223}
222 224
223static int acpi_power_off_device(acpi_handle handle) 225static int acpi_power_off_device(acpi_handle handle)
@@ -465,10 +467,12 @@ int acpi_power_transition(struct acpi_device *device, int state)
465 struct acpi_handle_list *tl = NULL; /* Target Resources */ 467 struct acpi_handle_list *tl = NULL; /* Target Resources */
466 int i = 0; 468 int i = 0;
467 469
468
469 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 470 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
470 return -EINVAL; 471 return -EINVAL;
471 472
473 if (device->power.state == state)
474 return 0;
475
472 if ((device->power.state < ACPI_STATE_D0) 476 if ((device->power.state < ACPI_STATE_D0)
473 || (device->power.state > ACPI_STATE_D3)) 477 || (device->power.state > ACPI_STATE_D3))
474 return -ENODEV; 478 return -ENODEV;
@@ -488,10 +492,6 @@ int acpi_power_transition(struct acpi_device *device, int state)
488 goto end; 492 goto end;
489 } 493 }
490 494
491 if (device->power.state == state) {
492 goto end;
493 }
494
495 /* 495 /*
496 * Then we dereference all power resources used in the current list. 496 * Then we dereference all power resources used in the current list.
497 */ 497 */
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index fde49b9b1d99..79cb65332894 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -156,15 +156,6 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
156 return 0; 156 return 0;
157} 157}
158 158
159static int acpi_thermal_cpufreq_increase(unsigned int cpu)
160{
161 return -ENODEV;
162}
163static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
164{
165 return -ENODEV;
166}
167
168#endif 159#endif
169 160
170int acpi_processor_get_limit_info(struct acpi_processor *pr) 161int acpi_processor_get_limit_info(struct acpi_processor *pr)
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 721d93b3ceee..febb153b5a68 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -27,8 +27,6 @@
27 27
28static u8 sleep_states[ACPI_S_STATE_COUNT]; 28static u8 sleep_states[ACPI_S_STATE_COUNT];
29 29
30static u32 acpi_target_sleep_state = ACPI_STATE_S0;
31
32static void acpi_sleep_tts_switch(u32 acpi_state) 30static void acpi_sleep_tts_switch(u32 acpi_state)
33{ 31{
34 union acpi_object in_arg = { ACPI_TYPE_INTEGER }; 32 union acpi_object in_arg = { ACPI_TYPE_INTEGER };
@@ -81,6 +79,8 @@ static int acpi_sleep_prepare(u32 acpi_state)
81} 79}
82 80
83#ifdef CONFIG_ACPI_SLEEP 81#ifdef CONFIG_ACPI_SLEEP
82static u32 acpi_target_sleep_state = ACPI_STATE_S0;
83
84/* 84/*
85 * The ACPI specification wants us to save NVS memory regions during hibernation 85 * The ACPI specification wants us to save NVS memory regions during hibernation
86 * and to restore them during the subsequent resume. Windows does that also for 86 * and to restore them during the subsequent resume. Windows does that also for
@@ -427,6 +427,14 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
427 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"), 427 DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"),
428 }, 428 },
429 }, 429 },
430 {
431 .callback = init_nvs_nosave,
432 .ident = "Sony Vaio VGN-NW130D",
433 .matches = {
434 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
435 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"),
436 },
437 },
430 {}, 438 {},
431}; 439};
432#endif /* CONFIG_SUSPEND */ 440#endif /* CONFIG_SUSPEND */
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 3f91c01c217f..66aa4bee80a6 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3166,8 +3166,8 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
3166 3166
3167/** 3167/**
3168 * ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device 3168 * ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device
3169 * @shost: SCSI host of command to be sent
3169 * @cmd: SCSI command to be sent 3170 * @cmd: SCSI command to be sent
3170 * @done: Completion function, called when command is complete
3171 * 3171 *
3172 * In some cases, this function translates SCSI commands into 3172 * In some cases, this function translates SCSI commands into
3173 * ATA taskfiles, and queues the taskfiles to be sent to 3173 * ATA taskfiles, and queues the taskfiles to be sent to
@@ -3177,37 +3177,36 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
3177 * ATA and ATAPI devices appearing as SCSI devices. 3177 * ATA and ATAPI devices appearing as SCSI devices.
3178 * 3178 *
3179 * LOCKING: 3179 * LOCKING:
3180 * Releases scsi-layer-held lock, and obtains host lock. 3180 * ATA host lock
3181 * 3181 *
3182 * RETURNS: 3182 * RETURNS:
3183 * Return value from __ata_scsi_queuecmd() if @cmd can be queued, 3183 * Return value from __ata_scsi_queuecmd() if @cmd can be queued,
3184 * 0 otherwise. 3184 * 0 otherwise.
3185 */ 3185 */
3186int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 3186int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
3187{ 3187{
3188 struct ata_port *ap; 3188 struct ata_port *ap;
3189 struct ata_device *dev; 3189 struct ata_device *dev;
3190 struct scsi_device *scsidev = cmd->device; 3190 struct scsi_device *scsidev = cmd->device;
3191 struct Scsi_Host *shost = scsidev->host;
3192 int rc = 0; 3191 int rc = 0;
3192 unsigned long irq_flags;
3193 3193
3194 ap = ata_shost_to_port(shost); 3194 ap = ata_shost_to_port(shost);
3195 3195
3196 spin_unlock(shost->host_lock); 3196 spin_lock_irqsave(ap->lock, irq_flags);
3197 spin_lock(ap->lock);
3198 3197
3199 ata_scsi_dump_cdb(ap, cmd); 3198 ata_scsi_dump_cdb(ap, cmd);
3200 3199
3201 dev = ata_scsi_find_dev(ap, scsidev); 3200 dev = ata_scsi_find_dev(ap, scsidev);
3202 if (likely(dev)) 3201 if (likely(dev))
3203 rc = __ata_scsi_queuecmd(cmd, done, dev); 3202 rc = __ata_scsi_queuecmd(cmd, cmd->scsi_done, dev);
3204 else { 3203 else {
3205 cmd->result = (DID_BAD_TARGET << 16); 3204 cmd->result = (DID_BAD_TARGET << 16);
3206 done(cmd); 3205 cmd->scsi_done(cmd);
3207 } 3206 }
3208 3207
3209 spin_unlock(ap->lock); 3208 spin_unlock_irqrestore(ap->lock, irq_flags);
3210 spin_lock(shost->host_lock); 3209
3211 return rc; 3210 return rc;
3212} 3211}
3213 3212
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index c21589986c69..8b677bbf2d37 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -538,7 +538,7 @@ static int vt8251_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)
538 return 0; 538 return 0;
539} 539}
540 540
541static void svia_configure(struct pci_dev *pdev) 541static void svia_configure(struct pci_dev *pdev, int board_id)
542{ 542{
543 u8 tmp8; 543 u8 tmp8;
544 544
@@ -577,7 +577,7 @@ static void svia_configure(struct pci_dev *pdev)
577 } 577 }
578 578
579 /* 579 /*
580 * vt6421 has problems talking to some drives. The following 580 * vt6420/1 has problems talking to some drives. The following
581 * is the fix from Joseph Chan <JosephChan@via.com.tw>. 581 * is the fix from Joseph Chan <JosephChan@via.com.tw>.
582 * 582 *
583 * When host issues HOLD, device may send up to 20DW of data 583 * When host issues HOLD, device may send up to 20DW of data
@@ -596,8 +596,9 @@ static void svia_configure(struct pci_dev *pdev)
596 * 596 *
597 * https://bugzilla.kernel.org/show_bug.cgi?id=15173 597 * https://bugzilla.kernel.org/show_bug.cgi?id=15173
598 * http://article.gmane.org/gmane.linux.ide/46352 598 * http://article.gmane.org/gmane.linux.ide/46352
599 * http://thread.gmane.org/gmane.linux.kernel/1062139
599 */ 600 */
600 if (pdev->device == 0x3249) { 601 if (board_id == vt6420 || board_id == vt6421) {
601 pci_read_config_byte(pdev, 0x52, &tmp8); 602 pci_read_config_byte(pdev, 0x52, &tmp8);
602 tmp8 |= 1 << 2; 603 tmp8 |= 1 << 2;
603 pci_write_config_byte(pdev, 0x52, tmp8); 604 pci_write_config_byte(pdev, 0x52, tmp8);
@@ -652,7 +653,7 @@ static int svia_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
652 if (rc) 653 if (rc)
653 return rc; 654 return rc;
654 655
655 svia_configure(pdev); 656 svia_configure(pdev, board_id);
656 657
657 pci_set_master(pdev); 658 pci_set_master(pdev);
658 return ata_host_activate(host, pdev->irq, ata_bmdma_interrupt, 659 return ata_host_activate(host, pdev->irq, ata_bmdma_interrupt,
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 46b94762125b..f9b983ae6877 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -154,7 +154,7 @@ static int __init adummy_init(void)
154 err = -ENOMEM; 154 err = -ENOMEM;
155 goto out; 155 goto out;
156 } 156 }
157 atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL); 157 atm_dev = atm_dev_register(DEV_LABEL, NULL, &adummy_ops, -1, NULL);
158 if (!atm_dev) { 158 if (!atm_dev) {
159 printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n"); 159 printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
160 err = -ENODEV; 160 err = -ENODEV;
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index a33896a482e6..ffe9b655292e 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -2244,7 +2244,8 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
2244 goto out_reset; 2244 goto out_reset;
2245 } 2245 }
2246 2246
2247 dev->atm_dev = atm_dev_register (DEV_LABEL, &amb_ops, -1, NULL); 2247 dev->atm_dev = atm_dev_register (DEV_LABEL, &pci_dev->dev, &amb_ops, -1,
2248 NULL);
2248 if (!dev->atm_dev) { 2249 if (!dev->atm_dev) {
2249 PRINTD (DBG_ERR, "failed to register Madge ATM adapter"); 2250 PRINTD (DBG_ERR, "failed to register Madge ATM adapter");
2250 err = -EINVAL; 2251 err = -EINVAL;
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
index b9101818b47b..2b464b631f22 100644
--- a/drivers/atm/atmtcp.c
+++ b/drivers/atm/atmtcp.c
@@ -366,7 +366,7 @@ static int atmtcp_create(int itf,int persist,struct atm_dev **result)
366 if (!dev_data) 366 if (!dev_data)
367 return -ENOMEM; 367 return -ENOMEM;
368 368
369 dev = atm_dev_register(DEV_LABEL,&atmtcp_v_dev_ops,itf,NULL); 369 dev = atm_dev_register(DEV_LABEL,NULL,&atmtcp_v_dev_ops,itf,NULL);
370 if (!dev) { 370 if (!dev) {
371 kfree(dev_data); 371 kfree(dev_data);
372 return itf == -1 ? -ENOMEM : -EBUSY; 372 return itf == -1 ? -ENOMEM : -EBUSY;
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index 97c5898cd76e..c495fae74200 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -2244,7 +2244,7 @@ static int __devinit eni_init_one(struct pci_dev *pci_dev,
2244 &zeroes); 2244 &zeroes);
2245 if (!cpu_zeroes) goto out1; 2245 if (!cpu_zeroes) goto out1;
2246 } 2246 }
2247 dev = atm_dev_register(DEV_LABEL,&ops,-1,NULL); 2247 dev = atm_dev_register(DEV_LABEL, &pci_dev->dev, &ops, -1, NULL);
2248 if (!dev) goto out2; 2248 if (!dev) goto out2;
2249 pci_set_drvdata(pci_dev, dev); 2249 pci_set_drvdata(pci_dev, dev);
2250 eni_dev->pci_dev = pci_dev; 2250 eni_dev->pci_dev = pci_dev;
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 5d86bb803e94..7d912baf01d4 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1911,7 +1911,7 @@ static int __devinit firestream_init_one (struct pci_dev *pci_dev,
1911 fs_dev, sizeof (struct fs_dev)); 1911 fs_dev, sizeof (struct fs_dev));
1912 if (!fs_dev) 1912 if (!fs_dev)
1913 goto err_out; 1913 goto err_out;
1914 atm_dev = atm_dev_register("fs", &ops, -1, NULL); 1914 atm_dev = atm_dev_register("fs", &pci_dev->dev, &ops, -1, NULL);
1915 if (!atm_dev) 1915 if (!atm_dev)
1916 goto err_out_free_fs_dev; 1916 goto err_out_free_fs_dev;
1917 1917
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index c8fc69c85a06..962c309b40c0 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -2567,14 +2567,14 @@ release:
2567 2567
2568 2568
2569static int __devinit 2569static int __devinit
2570fore200e_register(struct fore200e* fore200e) 2570fore200e_register(struct fore200e* fore200e, struct device *parent)
2571{ 2571{
2572 struct atm_dev* atm_dev; 2572 struct atm_dev* atm_dev;
2573 2573
2574 DPRINTK(2, "device %s being registered\n", fore200e->name); 2574 DPRINTK(2, "device %s being registered\n", fore200e->name);
2575 2575
2576 atm_dev = atm_dev_register(fore200e->bus->proc_name, &fore200e_ops, -1, 2576 atm_dev = atm_dev_register(fore200e->bus->proc_name, parent, &fore200e_ops,
2577 NULL); 2577 -1, NULL);
2578 if (atm_dev == NULL) { 2578 if (atm_dev == NULL) {
2579 printk(FORE200E "unable to register device %s\n", fore200e->name); 2579 printk(FORE200E "unable to register device %s\n", fore200e->name);
2580 return -ENODEV; 2580 return -ENODEV;
@@ -2594,9 +2594,9 @@ fore200e_register(struct fore200e* fore200e)
2594 2594
2595 2595
2596static int __devinit 2596static int __devinit
2597fore200e_init(struct fore200e* fore200e) 2597fore200e_init(struct fore200e* fore200e, struct device *parent)
2598{ 2598{
2599 if (fore200e_register(fore200e) < 0) 2599 if (fore200e_register(fore200e, parent) < 0)
2600 return -ENODEV; 2600 return -ENODEV;
2601 2601
2602 if (fore200e->bus->configure(fore200e) < 0) 2602 if (fore200e->bus->configure(fore200e) < 0)
@@ -2662,7 +2662,7 @@ static int __devinit fore200e_sba_probe(struct platform_device *op,
2662 2662
2663 sprintf(fore200e->name, "%s-%d", bus->model_name, index); 2663 sprintf(fore200e->name, "%s-%d", bus->model_name, index);
2664 2664
2665 err = fore200e_init(fore200e); 2665 err = fore200e_init(fore200e, &op->dev);
2666 if (err < 0) { 2666 if (err < 0) {
2667 fore200e_shutdown(fore200e); 2667 fore200e_shutdown(fore200e);
2668 kfree(fore200e); 2668 kfree(fore200e);
@@ -2740,7 +2740,7 @@ fore200e_pca_detect(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent
2740 2740
2741 sprintf(fore200e->name, "%s-%d", bus->model_name, index); 2741 sprintf(fore200e->name, "%s-%d", bus->model_name, index);
2742 2742
2743 err = fore200e_init(fore200e); 2743 err = fore200e_init(fore200e, &pci_dev->dev);
2744 if (err < 0) { 2744 if (err < 0) {
2745 fore200e_shutdown(fore200e); 2745 fore200e_shutdown(fore200e);
2746 goto out_free; 2746 goto out_free;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 801e8b6e9d1f..6cf59bf281dc 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -366,7 +366,7 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
366 goto init_one_failure; 366 goto init_one_failure;
367 } 367 }
368 368
369 atm_dev = atm_dev_register(DEV_LABEL, &he_ops, -1, NULL); 369 atm_dev = atm_dev_register(DEV_LABEL, &pci_dev->dev, &he_ops, -1, NULL);
370 if (!atm_dev) { 370 if (!atm_dev) {
371 err = -ENODEV; 371 err = -ENODEV;
372 goto init_one_failure; 372 goto init_one_failure;
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index a95790452a68..24761e1d6642 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -2733,7 +2733,8 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
2733 PRINTD(DBG_INFO, "found Madge ATM adapter (hrz) at: IO %x, IRQ %u, MEM %p", 2733 PRINTD(DBG_INFO, "found Madge ATM adapter (hrz) at: IO %x, IRQ %u, MEM %p",
2734 iobase, irq, membase); 2734 iobase, irq, membase);
2735 2735
2736 dev->atm_dev = atm_dev_register(DEV_LABEL, &hrz_ops, -1, NULL); 2736 dev->atm_dev = atm_dev_register(DEV_LABEL, &pci_dev->dev, &hrz_ops, -1,
2737 NULL);
2737 if (!(dev->atm_dev)) { 2738 if (!(dev->atm_dev)) {
2738 PRINTD(DBG_ERR, "failed to register Madge ATM adapter"); 2739 PRINTD(DBG_ERR, "failed to register Madge ATM adapter");
2739 err = -EINVAL; 2740 err = -EINVAL;
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index bce57328ddde..bfb7feee0400 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -3698,7 +3698,8 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
3698 goto err_out_iounmap; 3698 goto err_out_iounmap;
3699 } 3699 }
3700 3700
3701 dev = atm_dev_register("idt77252", &idt77252_ops, -1, NULL); 3701 dev = atm_dev_register("idt77252", &pcidev->dev, &idt77252_ops, -1,
3702 NULL);
3702 if (!dev) { 3703 if (!dev) {
3703 printk("%s: can't register atm device\n", card->name); 3704 printk("%s: can't register atm device\n", card->name);
3704 err = -EIO; 3705 err = -EIO;
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 9309d4724e13..729254053758 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -3172,7 +3172,7 @@ static int __devinit ia_init_one(struct pci_dev *pdev,
3172 ret = -ENODEV; 3172 ret = -ENODEV;
3173 goto err_out_free_iadev; 3173 goto err_out_free_iadev;
3174 } 3174 }
3175 dev = atm_dev_register(DEV_LABEL, &ops, -1, NULL); 3175 dev = atm_dev_register(DEV_LABEL, &pdev->dev, &ops, -1, NULL);
3176 if (!dev) { 3176 if (!dev) {
3177 ret = -ENOMEM; 3177 ret = -ENOMEM;
3178 goto err_out_disable_dev; 3178 goto err_out_disable_dev;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index cbe15a86c669..a395c9aab146 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -2591,7 +2591,7 @@ static int __devinit lanai_init_one(struct pci_dev *pci,
2591 return -ENOMEM; 2591 return -ENOMEM;
2592 } 2592 }
2593 2593
2594 atmdev = atm_dev_register(DEV_LABEL, &ops, -1, NULL); 2594 atmdev = atm_dev_register(DEV_LABEL, &pci->dev, &ops, -1, NULL);
2595 if (atmdev == NULL) { 2595 if (atmdev == NULL) {
2596 printk(KERN_ERR DEV_LABEL 2596 printk(KERN_ERR DEV_LABEL
2597 ": couldn't register atm device!\n"); 2597 ": couldn't register atm device!\n");
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 2f3516b7f118..6b313ee9231b 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -771,7 +771,8 @@ static int __devinit ns_init_card(int i, struct pci_dev *pcidev)
771 } 771 }
772 772
773 /* Register device */ 773 /* Register device */
774 card->atmdev = atm_dev_register("nicstar", &atm_ops, -1, NULL); 774 card->atmdev = atm_dev_register("nicstar", &card->pcidev->dev, &atm_ops,
775 -1, NULL);
775 if (card->atmdev == NULL) { 776 if (card->atmdev == NULL) {
776 printk("nicstar%d: can't register device.\n", i); 777 printk("nicstar%d: can't register device.\n", i);
777 error = 17; 778 error = 17;
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 2e08c996fd30..73fb1c4f4cd4 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -166,7 +166,7 @@ static irqreturn_t solos_irq(int irq, void *dev_id);
166static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci); 166static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci);
167static int list_vccs(int vci); 167static int list_vccs(int vci);
168static void release_vccs(struct atm_dev *dev); 168static void release_vccs(struct atm_dev *dev);
169static int atm_init(struct solos_card *); 169static int atm_init(struct solos_card *, struct device *);
170static void atm_remove(struct solos_card *); 170static void atm_remove(struct solos_card *);
171static int send_command(struct solos_card *card, int dev, const char *buf, size_t size); 171static int send_command(struct solos_card *card, int dev, const char *buf, size_t size);
172static void solos_bh(unsigned long); 172static void solos_bh(unsigned long);
@@ -1210,7 +1210,7 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1210 if (db_firmware_upgrade) 1210 if (db_firmware_upgrade)
1211 flash_upgrade(card, 3); 1211 flash_upgrade(card, 3);
1212 1212
1213 err = atm_init(card); 1213 err = atm_init(card, &dev->dev);
1214 if (err) 1214 if (err)
1215 goto out_free_irq; 1215 goto out_free_irq;
1216 1216
@@ -1233,7 +1233,7 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1233 return err; 1233 return err;
1234} 1234}
1235 1235
1236static int atm_init(struct solos_card *card) 1236static int atm_init(struct solos_card *card, struct device *parent)
1237{ 1237{
1238 int i; 1238 int i;
1239 1239
@@ -1244,7 +1244,7 @@ static int atm_init(struct solos_card *card)
1244 skb_queue_head_init(&card->tx_queue[i]); 1244 skb_queue_head_init(&card->tx_queue[i]);
1245 skb_queue_head_init(&card->cli_queue[i]); 1245 skb_queue_head_init(&card->cli_queue[i]);
1246 1246
1247 card->atmdev[i] = atm_dev_register("solos-pci", &fpga_ops, -1, NULL); 1247 card->atmdev[i] = atm_dev_register("solos-pci", parent, &fpga_ops, -1, NULL);
1248 if (!card->atmdev[i]) { 1248 if (!card->atmdev[i]) {
1249 dev_err(&card->dev->dev, "Could not register ATM device %d\n", i); 1249 dev_err(&card->dev->dev, "Could not register ATM device %d\n", i);
1250 atm_remove(card); 1250 atm_remove(card);
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 4e885d2da49c..624917902b65 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -1597,7 +1597,7 @@ static int __devinit zatm_init_one(struct pci_dev *pci_dev,
1597 goto out; 1597 goto out;
1598 } 1598 }
1599 1599
1600 dev = atm_dev_register(DEV_LABEL, &ops, -1, NULL); 1600 dev = atm_dev_register(DEV_LABEL, &pci_dev->dev, &ops, -1, NULL);
1601 if (!dev) 1601 if (!dev)
1602 goto out_free; 1602 goto out_free;
1603 1603
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 31b526661ec4..ead3e79d6fcf 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -475,20 +475,33 @@ End:
475 */ 475 */
476void dpm_resume_noirq(pm_message_t state) 476void dpm_resume_noirq(pm_message_t state)
477{ 477{
478 struct device *dev; 478 struct list_head list;
479 ktime_t starttime = ktime_get(); 479 ktime_t starttime = ktime_get();
480 480
481 INIT_LIST_HEAD(&list);
481 mutex_lock(&dpm_list_mtx); 482 mutex_lock(&dpm_list_mtx);
482 transition_started = false; 483 transition_started = false;
483 list_for_each_entry(dev, &dpm_list, power.entry) 484 while (!list_empty(&dpm_list)) {
485 struct device *dev = to_device(dpm_list.next);
486
487 get_device(dev);
484 if (dev->power.status > DPM_OFF) { 488 if (dev->power.status > DPM_OFF) {
485 int error; 489 int error;
486 490
487 dev->power.status = DPM_OFF; 491 dev->power.status = DPM_OFF;
492 mutex_unlock(&dpm_list_mtx);
493
488 error = device_resume_noirq(dev, state); 494 error = device_resume_noirq(dev, state);
495
496 mutex_lock(&dpm_list_mtx);
489 if (error) 497 if (error)
490 pm_dev_err(dev, state, " early", error); 498 pm_dev_err(dev, state, " early", error);
491 } 499 }
500 if (!list_empty(&dev->power.entry))
501 list_move_tail(&dev->power.entry, &list);
502 put_device(dev);
503 }
504 list_splice(&list, &dpm_list);
492 mutex_unlock(&dpm_list_mtx); 505 mutex_unlock(&dpm_list_mtx);
493 dpm_show_time(starttime, state, "early"); 506 dpm_show_time(starttime, state, "early");
494 resume_device_irqs(); 507 resume_device_irqs();
@@ -789,20 +802,33 @@ End:
789 */ 802 */
790int dpm_suspend_noirq(pm_message_t state) 803int dpm_suspend_noirq(pm_message_t state)
791{ 804{
792 struct device *dev; 805 struct list_head list;
793 ktime_t starttime = ktime_get(); 806 ktime_t starttime = ktime_get();
794 int error = 0; 807 int error = 0;
795 808
809 INIT_LIST_HEAD(&list);
796 suspend_device_irqs(); 810 suspend_device_irqs();
797 mutex_lock(&dpm_list_mtx); 811 mutex_lock(&dpm_list_mtx);
798 list_for_each_entry_reverse(dev, &dpm_list, power.entry) { 812 while (!list_empty(&dpm_list)) {
813 struct device *dev = to_device(dpm_list.prev);
814
815 get_device(dev);
816 mutex_unlock(&dpm_list_mtx);
817
799 error = device_suspend_noirq(dev, state); 818 error = device_suspend_noirq(dev, state);
819
820 mutex_lock(&dpm_list_mtx);
800 if (error) { 821 if (error) {
801 pm_dev_err(dev, state, " late", error); 822 pm_dev_err(dev, state, " late", error);
823 put_device(dev);
802 break; 824 break;
803 } 825 }
804 dev->power.status = DPM_OFF_IRQ; 826 dev->power.status = DPM_OFF_IRQ;
827 if (!list_empty(&dev->power.entry))
828 list_move(&dev->power.entry, &list);
829 put_device(dev);
805 } 830 }
831 list_splice_tail(&list, &dpm_list);
806 mutex_unlock(&dpm_list_mtx); 832 mutex_unlock(&dpm_list_mtx);
807 if (error) 833 if (error)
808 dpm_resume_noirq(resume_event(state)); 834 dpm_resume_noirq(resume_event(state));
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index a1725e6488d3..7888501ad9ee 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1341,7 +1341,7 @@ static struct request *set_next_request(void)
1341{ 1341{
1342 struct request_queue *q; 1342 struct request_queue *q;
1343 int cnt = FD_MAX_UNITS; 1343 int cnt = FD_MAX_UNITS;
1344 struct request *rq; 1344 struct request *rq = NULL;
1345 1345
1346 /* Find next queue we can dispatch from */ 1346 /* Find next queue we can dispatch from */
1347 fdc_queue = fdc_queue + 1; 1347 fdc_queue = fdc_queue + 1;
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 4e4cc6c828cb..605a67e40bbf 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1399,7 +1399,7 @@ static struct request *set_next_request(void)
1399{ 1399{
1400 struct request_queue *q; 1400 struct request_queue *q;
1401 int old_pos = fdc_queue; 1401 int old_pos = fdc_queue;
1402 struct request *rq; 1402 struct request *rq = NULL;
1403 1403
1404 do { 1404 do {
1405 q = unit[fdc_queue].disk->queue; 1405 q = unit[fdc_queue].disk->queue;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index a67d0a611a8a..8e0f9256eb58 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -66,6 +66,7 @@ MODULE_VERSION("3.6.26");
66MODULE_LICENSE("GPL"); 66MODULE_LICENSE("GPL");
67 67
68static DEFINE_MUTEX(cciss_mutex); 68static DEFINE_MUTEX(cciss_mutex);
69static struct proc_dir_entry *proc_cciss;
69 70
70#include "cciss_cmd.h" 71#include "cciss_cmd.h"
71#include "cciss.h" 72#include "cciss.h"
@@ -363,8 +364,6 @@ static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG",
363#define ENG_GIG_FACTOR (ENG_GIG/512) 364#define ENG_GIG_FACTOR (ENG_GIG/512)
364#define ENGAGE_SCSI "engage scsi" 365#define ENGAGE_SCSI "engage scsi"
365 366
366static struct proc_dir_entry *proc_cciss;
367
368static void cciss_seq_show_header(struct seq_file *seq) 367static void cciss_seq_show_header(struct seq_file *seq)
369{ 368{
370 ctlr_info_t *h = seq->private; 369 ctlr_info_t *h = seq->private;
@@ -2835,6 +2834,8 @@ static int cciss_revalidate(struct gendisk *disk)
2835 InquiryData_struct *inq_buff = NULL; 2834 InquiryData_struct *inq_buff = NULL;
2836 2835
2837 for (logvol = 0; logvol < CISS_MAX_LUN; logvol++) { 2836 for (logvol = 0; logvol < CISS_MAX_LUN; logvol++) {
2837 if (!h->drv[logvol])
2838 continue;
2838 if (memcmp(h->drv[logvol]->LunID, drv->LunID, 2839 if (memcmp(h->drv[logvol]->LunID, drv->LunID,
2839 sizeof(drv->LunID)) == 0) { 2840 sizeof(drv->LunID)) == 0) {
2840 FOUND = 1; 2841 FOUND = 1;
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 575495f3c4b8..727d0225b7d0 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -62,8 +62,8 @@ static int cciss_scsi_proc_info(
62 int length, /* length of data in buffer */ 62 int length, /* length of data in buffer */
63 int func); /* 0 == read, 1 == write */ 63 int func); /* 0 == read, 1 == write */
64 64
65static int cciss_scsi_queue_command (struct scsi_cmnd *cmd, 65static int cciss_scsi_queue_command (struct Scsi_Host *h,
66 void (* done)(struct scsi_cmnd *)); 66 struct scsi_cmnd *cmd);
67static int cciss_eh_device_reset_handler(struct scsi_cmnd *); 67static int cciss_eh_device_reset_handler(struct scsi_cmnd *);
68static int cciss_eh_abort_handler(struct scsi_cmnd *); 68static int cciss_eh_abort_handler(struct scsi_cmnd *);
69 69
@@ -1406,7 +1406,7 @@ static void cciss_scatter_gather(ctlr_info_t *h, CommandList_struct *c,
1406 1406
1407 1407
1408static int 1408static int
1409cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) 1409cciss_scsi_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
1410{ 1410{
1411 ctlr_info_t *h; 1411 ctlr_info_t *h;
1412 int rc; 1412 int rc;
@@ -1504,6 +1504,8 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd
1504 return 0; 1504 return 0;
1505} 1505}
1506 1506
1507static DEF_SCSI_QCMD(cciss_scsi_queue_command)
1508
1507static void cciss_unregister_scsi(ctlr_info_t *h) 1509static void cciss_unregister_scsi(ctlr_info_t *h)
1508{ 1510{
1509 struct cciss_scsi_adapter_data_t *sa; 1511 struct cciss_scsi_adapter_data_t *sa;
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index d299fe9e78c8..24487d4fb202 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -36,7 +36,6 @@
36#include <linux/memcontrol.h> 36#include <linux/memcontrol.h>
37#include <linux/mm_inline.h> 37#include <linux/mm_inline.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/smp_lock.h>
40#include <linux/pkt_sched.h> 39#include <linux/pkt_sched.h>
41#define __KERNEL_SYSCALLS__ 40#define __KERNEL_SYSCALLS__
42#include <linux/unistd.h> 41#include <linux/unistd.h>
@@ -3628,17 +3627,19 @@ static void drbdd(struct drbd_conf *mdev)
3628 } 3627 }
3629 3628
3630 shs = drbd_cmd_handler[cmd].pkt_size - sizeof(union p_header); 3629 shs = drbd_cmd_handler[cmd].pkt_size - sizeof(union p_header);
3631 rv = drbd_recv(mdev, &header->h80.payload, shs);
3632 if (unlikely(rv != shs)) {
3633 dev_err(DEV, "short read while reading sub header: rv=%d\n", rv);
3634 goto err_out;
3635 }
3636
3637 if (packet_size - shs > 0 && !drbd_cmd_handler[cmd].expect_payload) { 3630 if (packet_size - shs > 0 && !drbd_cmd_handler[cmd].expect_payload) {
3638 dev_err(DEV, "No payload expected %s l:%d\n", cmdname(cmd), packet_size); 3631 dev_err(DEV, "No payload expected %s l:%d\n", cmdname(cmd), packet_size);
3639 goto err_out; 3632 goto err_out;
3640 } 3633 }
3641 3634
3635 if (shs) {
3636 rv = drbd_recv(mdev, &header->h80.payload, shs);
3637 if (unlikely(rv != shs)) {
3638 dev_err(DEV, "short read while reading sub header: rv=%d\n", rv);
3639 goto err_out;
3640 }
3641 }
3642
3642 rv = drbd_cmd_handler[cmd].function(mdev, cmd, packet_size - shs); 3643 rv = drbd_cmd_handler[cmd].function(mdev, cmd, packet_size - shs);
3643 3644
3644 if (unlikely(!rv)) { 3645 if (unlikely(!rv)) {
diff --git a/drivers/block/drbd/drbd_req.h b/drivers/block/drbd/drbd_req.h
index 181ea0364822..ab2bd09d54b4 100644
--- a/drivers/block/drbd/drbd_req.h
+++ b/drivers/block/drbd/drbd_req.h
@@ -339,7 +339,8 @@ static inline int _req_mod(struct drbd_request *req, enum drbd_req_event what)
339} 339}
340 340
341/* completion of master bio is outside of spinlock. 341/* completion of master bio is outside of spinlock.
342 * If you need it irqsave, do it your self! */ 342 * If you need it irqsave, do it your self!
343 * Which means: don't use from bio endio callback. */
343static inline int req_mod(struct drbd_request *req, 344static inline int req_mod(struct drbd_request *req,
344 enum drbd_req_event what) 345 enum drbd_req_event what)
345{ 346{
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index b0551ba7ad0c..34f224b018b3 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -26,7 +26,6 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/drbd.h> 27#include <linux/drbd.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/smp_lock.h>
30#include <linux/wait.h> 29#include <linux/wait.h>
31#include <linux/mm.h> 30#include <linux/mm.h>
32#include <linux/memcontrol.h> 31#include <linux/memcontrol.h>
@@ -194,8 +193,10 @@ void drbd_endio_sec(struct bio *bio, int error)
194 */ 193 */
195void drbd_endio_pri(struct bio *bio, int error) 194void drbd_endio_pri(struct bio *bio, int error)
196{ 195{
196 unsigned long flags;
197 struct drbd_request *req = bio->bi_private; 197 struct drbd_request *req = bio->bi_private;
198 struct drbd_conf *mdev = req->mdev; 198 struct drbd_conf *mdev = req->mdev;
199 struct bio_and_error m;
199 enum drbd_req_event what; 200 enum drbd_req_event what;
200 int uptodate = bio_flagged(bio, BIO_UPTODATE); 201 int uptodate = bio_flagged(bio, BIO_UPTODATE);
201 202
@@ -221,7 +222,13 @@ void drbd_endio_pri(struct bio *bio, int error)
221 bio_put(req->private_bio); 222 bio_put(req->private_bio);
222 req->private_bio = ERR_PTR(error); 223 req->private_bio = ERR_PTR(error);
223 224
224 req_mod(req, what); 225 /* not req_mod(), we need irqsave here! */
226 spin_lock_irqsave(&mdev->req_lock, flags);
227 __req_mod(req, what, &m);
228 spin_unlock_irqrestore(&mdev->req_lock, flags);
229
230 if (m.bio)
231 complete_master_bio(mdev, &m);
225} 232}
226 233
227int w_read_retry_remote(struct drbd_conf *mdev, struct drbd_work *w, int cancel) 234int w_read_retry_remote(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 6ec9d53806c5..008d4a00b50d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -21,80 +21,9 @@
21 21
22 22
23 23
24 Instructions for use 24 For usage instructions, please refer to:
25 --------------------
26 25
27 1) Map a Linux block device to an existing rbd image. 26 Documentation/ABI/testing/sysfs-bus-rbd
28
29 Usage: <mon ip addr> <options> <pool name> <rbd image name> [snap name]
30
31 $ echo "192.168.0.1 name=admin rbd foo" > /sys/class/rbd/add
32
33 The snapshot name can be "-" or omitted to map the image read/write.
34
35 2) List all active blkdev<->object mappings.
36
37 In this example, we have performed step #1 twice, creating two blkdevs,
38 mapped to two separate rados objects in the rados rbd pool
39
40 $ cat /sys/class/rbd/list
41 #id major client_name pool name snap KB
42 0 254 client4143 rbd foo - 1024000
43
44 The columns, in order, are:
45 - blkdev unique id
46 - blkdev assigned major
47 - rados client id
48 - rados pool name
49 - rados block device name
50 - mapped snapshot ("-" if none)
51 - device size in KB
52
53
54 3) Create a snapshot.
55
56 Usage: <blkdev id> <snapname>
57
58 $ echo "0 mysnap" > /sys/class/rbd/snap_create
59
60
61 4) Listing a snapshot.
62
63 $ cat /sys/class/rbd/snaps_list
64 #id snap KB
65 0 - 1024000 (*)
66 0 foo 1024000
67
68 The columns, in order, are:
69 - blkdev unique id
70 - snapshot name, '-' means none (active read/write version)
71 - size of device at time of snapshot
72 - the (*) indicates this is the active version
73
74 5) Rollback to snapshot.
75
76 Usage: <blkdev id> <snapname>
77
78 $ echo "0 mysnap" > /sys/class/rbd/snap_rollback
79
80
81 6) Mapping an image using snapshot.
82
83 A snapshot mapping is read-only. This is being done by passing
84 snap=<snapname> to the options when adding a device.
85
86 $ echo "192.168.0.1 name=admin,snap=mysnap rbd foo" > /sys/class/rbd/add
87
88
89 7) Remove an active blkdev<->rbd image mapping.
90
91 In this example, we remove the mapping with blkdev unique id 1.
92
93 $ echo 1 > /sys/class/rbd/remove
94
95
96 NOTE: The actual creation and deletion of rados objects is outside the scope
97 of this driver.
98 27
99 */ 28 */
100 29
@@ -163,6 +92,14 @@ struct rbd_request {
163 u64 len; 92 u64 len;
164}; 93};
165 94
95struct rbd_snap {
96 struct device dev;
97 const char *name;
98 size_t size;
99 struct list_head node;
100 u64 id;
101};
102
166/* 103/*
167 * a single device 104 * a single device
168 */ 105 */
@@ -193,21 +130,60 @@ struct rbd_device {
193 int read_only; 130 int read_only;
194 131
195 struct list_head node; 132 struct list_head node;
133
134 /* list of snapshots */
135 struct list_head snaps;
136
137 /* sysfs related */
138 struct device dev;
139};
140
141static struct bus_type rbd_bus_type = {
142 .name = "rbd",
196}; 143};
197 144
198static spinlock_t node_lock; /* protects client get/put */ 145static spinlock_t node_lock; /* protects client get/put */
199 146
200static struct class *class_rbd; /* /sys/class/rbd */
201static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */ 147static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */
202static LIST_HEAD(rbd_dev_list); /* devices */ 148static LIST_HEAD(rbd_dev_list); /* devices */
203static LIST_HEAD(rbd_client_list); /* clients */ 149static LIST_HEAD(rbd_client_list); /* clients */
204 150
151static int __rbd_init_snaps_header(struct rbd_device *rbd_dev);
152static void rbd_dev_release(struct device *dev);
153static ssize_t rbd_snap_rollback(struct device *dev,
154 struct device_attribute *attr,
155 const char *buf,
156 size_t size);
157static ssize_t rbd_snap_add(struct device *dev,
158 struct device_attribute *attr,
159 const char *buf,
160 size_t count);
161static void __rbd_remove_snap_dev(struct rbd_device *rbd_dev,
162 struct rbd_snap *snap);;
163
164
165static struct rbd_device *dev_to_rbd(struct device *dev)
166{
167 return container_of(dev, struct rbd_device, dev);
168}
169
170static struct device *rbd_get_dev(struct rbd_device *rbd_dev)
171{
172 return get_device(&rbd_dev->dev);
173}
174
175static void rbd_put_dev(struct rbd_device *rbd_dev)
176{
177 put_device(&rbd_dev->dev);
178}
205 179
206static int rbd_open(struct block_device *bdev, fmode_t mode) 180static int rbd_open(struct block_device *bdev, fmode_t mode)
207{ 181{
208 struct gendisk *disk = bdev->bd_disk; 182 struct gendisk *disk = bdev->bd_disk;
209 struct rbd_device *rbd_dev = disk->private_data; 183 struct rbd_device *rbd_dev = disk->private_data;
210 184
185 rbd_get_dev(rbd_dev);
186
211 set_device_ro(bdev, rbd_dev->read_only); 187 set_device_ro(bdev, rbd_dev->read_only);
212 188
213 if ((mode & FMODE_WRITE) && rbd_dev->read_only) 189 if ((mode & FMODE_WRITE) && rbd_dev->read_only)
@@ -216,9 +192,19 @@ static int rbd_open(struct block_device *bdev, fmode_t mode)
216 return 0; 192 return 0;
217} 193}
218 194
195static int rbd_release(struct gendisk *disk, fmode_t mode)
196{
197 struct rbd_device *rbd_dev = disk->private_data;
198
199 rbd_put_dev(rbd_dev);
200
201 return 0;
202}
203
219static const struct block_device_operations rbd_bd_ops = { 204static const struct block_device_operations rbd_bd_ops = {
220 .owner = THIS_MODULE, 205 .owner = THIS_MODULE,
221 .open = rbd_open, 206 .open = rbd_open,
207 .release = rbd_release,
222}; 208};
223 209
224/* 210/*
@@ -361,7 +347,6 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
361 int ret = -ENOMEM; 347 int ret = -ENOMEM;
362 348
363 init_rwsem(&header->snap_rwsem); 349 init_rwsem(&header->snap_rwsem);
364
365 header->snap_names_len = le64_to_cpu(ondisk->snap_names_len); 350 header->snap_names_len = le64_to_cpu(ondisk->snap_names_len);
366 header->snapc = kmalloc(sizeof(struct ceph_snap_context) + 351 header->snapc = kmalloc(sizeof(struct ceph_snap_context) +
367 snap_count * 352 snap_count *
@@ -1256,10 +1241,20 @@ bad:
1256 return -ERANGE; 1241 return -ERANGE;
1257} 1242}
1258 1243
1244static void __rbd_remove_all_snaps(struct rbd_device *rbd_dev)
1245{
1246 struct rbd_snap *snap;
1247
1248 while (!list_empty(&rbd_dev->snaps)) {
1249 snap = list_first_entry(&rbd_dev->snaps, struct rbd_snap, node);
1250 __rbd_remove_snap_dev(rbd_dev, snap);
1251 }
1252}
1253
1259/* 1254/*
1260 * only read the first part of the ondisk header, without the snaps info 1255 * only read the first part of the ondisk header, without the snaps info
1261 */ 1256 */
1262static int rbd_update_snaps(struct rbd_device *rbd_dev) 1257static int __rbd_update_snaps(struct rbd_device *rbd_dev)
1263{ 1258{
1264 int ret; 1259 int ret;
1265 struct rbd_image_header h; 1260 struct rbd_image_header h;
@@ -1280,12 +1275,15 @@ static int rbd_update_snaps(struct rbd_device *rbd_dev)
1280 rbd_dev->header.total_snaps = h.total_snaps; 1275 rbd_dev->header.total_snaps = h.total_snaps;
1281 rbd_dev->header.snapc = h.snapc; 1276 rbd_dev->header.snapc = h.snapc;
1282 rbd_dev->header.snap_names = h.snap_names; 1277 rbd_dev->header.snap_names = h.snap_names;
1278 rbd_dev->header.snap_names_len = h.snap_names_len;
1283 rbd_dev->header.snap_sizes = h.snap_sizes; 1279 rbd_dev->header.snap_sizes = h.snap_sizes;
1284 rbd_dev->header.snapc->seq = snap_seq; 1280 rbd_dev->header.snapc->seq = snap_seq;
1285 1281
1282 ret = __rbd_init_snaps_header(rbd_dev);
1283
1286 up_write(&rbd_dev->header.snap_rwsem); 1284 up_write(&rbd_dev->header.snap_rwsem);
1287 1285
1288 return 0; 1286 return ret;
1289} 1287}
1290 1288
1291static int rbd_init_disk(struct rbd_device *rbd_dev) 1289static int rbd_init_disk(struct rbd_device *rbd_dev)
@@ -1300,6 +1298,11 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
1300 if (rc) 1298 if (rc)
1301 return rc; 1299 return rc;
1302 1300
1301 /* no need to lock here, as rbd_dev is not registered yet */
1302 rc = __rbd_init_snaps_header(rbd_dev);
1303 if (rc)
1304 return rc;
1305
1303 rc = rbd_header_set_snap(rbd_dev, rbd_dev->snap_name, &total_size); 1306 rc = rbd_header_set_snap(rbd_dev, rbd_dev->snap_name, &total_size);
1304 if (rc) 1307 if (rc)
1305 return rc; 1308 return rc;
@@ -1343,54 +1346,360 @@ out:
1343 return rc; 1346 return rc;
1344} 1347}
1345 1348
1346/******************************************************************** 1349/*
1347 * /sys/class/rbd/ 1350 sysfs
1348 * add map rados objects to blkdev 1351*/
1349 * remove unmap rados objects 1352
1350 * list show mappings 1353static ssize_t rbd_size_show(struct device *dev,
1351 *******************************************************************/ 1354 struct device_attribute *attr, char *buf)
1355{
1356 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1357
1358 return sprintf(buf, "%llu\n", (unsigned long long)rbd_dev->header.image_size);
1359}
1360
1361static ssize_t rbd_major_show(struct device *dev,
1362 struct device_attribute *attr, char *buf)
1363{
1364 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1352 1365
1353static void class_rbd_release(struct class *cls) 1366 return sprintf(buf, "%d\n", rbd_dev->major);
1367}
1368
1369static ssize_t rbd_client_id_show(struct device *dev,
1370 struct device_attribute *attr, char *buf)
1354{ 1371{
1355 kfree(cls); 1372 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1373
1374 return sprintf(buf, "client%lld\n", ceph_client_id(rbd_dev->client));
1356} 1375}
1357 1376
1358static ssize_t class_rbd_list(struct class *c, 1377static ssize_t rbd_pool_show(struct device *dev,
1359 struct class_attribute *attr, 1378 struct device_attribute *attr, char *buf)
1360 char *data)
1361{ 1379{
1362 int n = 0; 1380 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1363 struct list_head *tmp; 1381
1364 int max = PAGE_SIZE; 1382 return sprintf(buf, "%s\n", rbd_dev->pool_name);
1383}
1384
1385static ssize_t rbd_name_show(struct device *dev,
1386 struct device_attribute *attr, char *buf)
1387{
1388 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1389
1390 return sprintf(buf, "%s\n", rbd_dev->obj);
1391}
1392
1393static ssize_t rbd_snap_show(struct device *dev,
1394 struct device_attribute *attr,
1395 char *buf)
1396{
1397 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1398
1399 return sprintf(buf, "%s\n", rbd_dev->snap_name);
1400}
1401
1402static ssize_t rbd_image_refresh(struct device *dev,
1403 struct device_attribute *attr,
1404 const char *buf,
1405 size_t size)
1406{
1407 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1408 int rc;
1409 int ret = size;
1365 1410
1366 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 1411 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1367 1412
1368 n += snprintf(data, max, 1413 rc = __rbd_update_snaps(rbd_dev);
1369 "#id\tmajor\tclient_name\tpool\tname\tsnap\tKB\n"); 1414 if (rc < 0)
1415 ret = rc;
1370 1416
1371 list_for_each(tmp, &rbd_dev_list) { 1417 mutex_unlock(&ctl_mutex);
1372 struct rbd_device *rbd_dev; 1418 return ret;
1419}
1373 1420
1374 rbd_dev = list_entry(tmp, struct rbd_device, node); 1421static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL);
1375 n += snprintf(data+n, max-n, 1422static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL);
1376 "%d\t%d\tclient%lld\t%s\t%s\t%s\t%lld\n", 1423static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL);
1377 rbd_dev->id, 1424static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL);
1378 rbd_dev->major, 1425static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL);
1379 ceph_client_id(rbd_dev->client), 1426static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
1380 rbd_dev->pool_name, 1427static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
1381 rbd_dev->obj, rbd_dev->snap_name, 1428static DEVICE_ATTR(create_snap, S_IWUSR, NULL, rbd_snap_add);
1382 rbd_dev->header.image_size >> 10); 1429static DEVICE_ATTR(rollback_snap, S_IWUSR, NULL, rbd_snap_rollback);
1383 if (n == max) 1430
1431static struct attribute *rbd_attrs[] = {
1432 &dev_attr_size.attr,
1433 &dev_attr_major.attr,
1434 &dev_attr_client_id.attr,
1435 &dev_attr_pool.attr,
1436 &dev_attr_name.attr,
1437 &dev_attr_current_snap.attr,
1438 &dev_attr_refresh.attr,
1439 &dev_attr_create_snap.attr,
1440 &dev_attr_rollback_snap.attr,
1441 NULL
1442};
1443
1444static struct attribute_group rbd_attr_group = {
1445 .attrs = rbd_attrs,
1446};
1447
1448static const struct attribute_group *rbd_attr_groups[] = {
1449 &rbd_attr_group,
1450 NULL
1451};
1452
1453static void rbd_sysfs_dev_release(struct device *dev)
1454{
1455}
1456
1457static struct device_type rbd_device_type = {
1458 .name = "rbd",
1459 .groups = rbd_attr_groups,
1460 .release = rbd_sysfs_dev_release,
1461};
1462
1463
1464/*
1465 sysfs - snapshots
1466*/
1467
1468static ssize_t rbd_snap_size_show(struct device *dev,
1469 struct device_attribute *attr,
1470 char *buf)
1471{
1472 struct rbd_snap *snap = container_of(dev, struct rbd_snap, dev);
1473
1474 return sprintf(buf, "%lld\n", (long long)snap->size);
1475}
1476
1477static ssize_t rbd_snap_id_show(struct device *dev,
1478 struct device_attribute *attr,
1479 char *buf)
1480{
1481 struct rbd_snap *snap = container_of(dev, struct rbd_snap, dev);
1482
1483 return sprintf(buf, "%lld\n", (long long)snap->id);
1484}
1485
1486static DEVICE_ATTR(snap_size, S_IRUGO, rbd_snap_size_show, NULL);
1487static DEVICE_ATTR(snap_id, S_IRUGO, rbd_snap_id_show, NULL);
1488
1489static struct attribute *rbd_snap_attrs[] = {
1490 &dev_attr_snap_size.attr,
1491 &dev_attr_snap_id.attr,
1492 NULL,
1493};
1494
1495static struct attribute_group rbd_snap_attr_group = {
1496 .attrs = rbd_snap_attrs,
1497};
1498
1499static void rbd_snap_dev_release(struct device *dev)
1500{
1501 struct rbd_snap *snap = container_of(dev, struct rbd_snap, dev);
1502 kfree(snap->name);
1503 kfree(snap);
1504}
1505
1506static const struct attribute_group *rbd_snap_attr_groups[] = {
1507 &rbd_snap_attr_group,
1508 NULL
1509};
1510
1511static struct device_type rbd_snap_device_type = {
1512 .groups = rbd_snap_attr_groups,
1513 .release = rbd_snap_dev_release,
1514};
1515
1516static void __rbd_remove_snap_dev(struct rbd_device *rbd_dev,
1517 struct rbd_snap *snap)
1518{
1519 list_del(&snap->node);
1520 device_unregister(&snap->dev);
1521}
1522
1523static int rbd_register_snap_dev(struct rbd_device *rbd_dev,
1524 struct rbd_snap *snap,
1525 struct device *parent)
1526{
1527 struct device *dev = &snap->dev;
1528 int ret;
1529
1530 dev->type = &rbd_snap_device_type;
1531 dev->parent = parent;
1532 dev->release = rbd_snap_dev_release;
1533 dev_set_name(dev, "snap_%s", snap->name);
1534 ret = device_register(dev);
1535
1536 return ret;
1537}
1538
1539static int __rbd_add_snap_dev(struct rbd_device *rbd_dev,
1540 int i, const char *name,
1541 struct rbd_snap **snapp)
1542{
1543 int ret;
1544 struct rbd_snap *snap = kzalloc(sizeof(*snap), GFP_KERNEL);
1545 if (!snap)
1546 return -ENOMEM;
1547 snap->name = kstrdup(name, GFP_KERNEL);
1548 snap->size = rbd_dev->header.snap_sizes[i];
1549 snap->id = rbd_dev->header.snapc->snaps[i];
1550 if (device_is_registered(&rbd_dev->dev)) {
1551 ret = rbd_register_snap_dev(rbd_dev, snap,
1552 &rbd_dev->dev);
1553 if (ret < 0)
1554 goto err;
1555 }
1556 *snapp = snap;
1557 return 0;
1558err:
1559 kfree(snap->name);
1560 kfree(snap);
1561 return ret;
1562}
1563
1564/*
1565 * search for the previous snap in a null delimited string list
1566 */
1567const char *rbd_prev_snap_name(const char *name, const char *start)
1568{
1569 if (name < start + 2)
1570 return NULL;
1571
1572 name -= 2;
1573 while (*name) {
1574 if (name == start)
1575 return start;
1576 name--;
1577 }
1578 return name + 1;
1579}
1580
1581/*
1582 * compare the old list of snapshots that we have to what's in the header
1583 * and update it accordingly. Note that the header holds the snapshots
1584 * in a reverse order (from newest to oldest) and we need to go from
1585 * older to new so that we don't get a duplicate snap name when
1586 * doing the process (e.g., removed snapshot and recreated a new
1587 * one with the same name.
1588 */
1589static int __rbd_init_snaps_header(struct rbd_device *rbd_dev)
1590{
1591 const char *name, *first_name;
1592 int i = rbd_dev->header.total_snaps;
1593 struct rbd_snap *snap, *old_snap = NULL;
1594 int ret;
1595 struct list_head *p, *n;
1596
1597 first_name = rbd_dev->header.snap_names;
1598 name = first_name + rbd_dev->header.snap_names_len;
1599
1600 list_for_each_prev_safe(p, n, &rbd_dev->snaps) {
1601 u64 cur_id;
1602
1603 old_snap = list_entry(p, struct rbd_snap, node);
1604
1605 if (i)
1606 cur_id = rbd_dev->header.snapc->snaps[i - 1];
1607
1608 if (!i || old_snap->id < cur_id) {
1609 /* old_snap->id was skipped, thus was removed */
1610 __rbd_remove_snap_dev(rbd_dev, old_snap);
1611 continue;
1612 }
1613 if (old_snap->id == cur_id) {
1614 /* we have this snapshot already */
1615 i--;
1616 name = rbd_prev_snap_name(name, first_name);
1617 continue;
1618 }
1619 for (; i > 0;
1620 i--, name = rbd_prev_snap_name(name, first_name)) {
1621 if (!name) {
1622 WARN_ON(1);
1623 return -EINVAL;
1624 }
1625 cur_id = rbd_dev->header.snapc->snaps[i];
1626 /* snapshot removal? handle it above */
1627 if (cur_id >= old_snap->id)
1628 break;
1629 /* a new snapshot */
1630 ret = __rbd_add_snap_dev(rbd_dev, i - 1, name, &snap);
1631 if (ret < 0)
1632 return ret;
1633
1634 /* note that we add it backward so using n and not p */
1635 list_add(&snap->node, n);
1636 p = &snap->node;
1637 }
1638 }
1639 /* we're done going over the old snap list, just add what's left */
1640 for (; i > 0; i--) {
1641 name = rbd_prev_snap_name(name, first_name);
1642 if (!name) {
1643 WARN_ON(1);
1644 return -EINVAL;
1645 }
1646 ret = __rbd_add_snap_dev(rbd_dev, i - 1, name, &snap);
1647 if (ret < 0)
1648 return ret;
1649 list_add(&snap->node, &rbd_dev->snaps);
1650 }
1651
1652 return 0;
1653}
1654
1655
1656static void rbd_root_dev_release(struct device *dev)
1657{
1658}
1659
1660static struct device rbd_root_dev = {
1661 .init_name = "rbd",
1662 .release = rbd_root_dev_release,
1663};
1664
1665static int rbd_bus_add_dev(struct rbd_device *rbd_dev)
1666{
1667 int ret = -ENOMEM;
1668 struct device *dev;
1669 struct rbd_snap *snap;
1670
1671 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1672 dev = &rbd_dev->dev;
1673
1674 dev->bus = &rbd_bus_type;
1675 dev->type = &rbd_device_type;
1676 dev->parent = &rbd_root_dev;
1677 dev->release = rbd_dev_release;
1678 dev_set_name(dev, "%d", rbd_dev->id);
1679 ret = device_register(dev);
1680 if (ret < 0)
1681 goto done_free;
1682
1683 list_for_each_entry(snap, &rbd_dev->snaps, node) {
1684 ret = rbd_register_snap_dev(rbd_dev, snap,
1685 &rbd_dev->dev);
1686 if (ret < 0)
1384 break; 1687 break;
1385 } 1688 }
1386 1689
1387 mutex_unlock(&ctl_mutex); 1690 mutex_unlock(&ctl_mutex);
1388 return n; 1691 return 0;
1692done_free:
1693 mutex_unlock(&ctl_mutex);
1694 return ret;
1389} 1695}
1390 1696
1391static ssize_t class_rbd_add(struct class *c, 1697static void rbd_bus_del_dev(struct rbd_device *rbd_dev)
1392 struct class_attribute *attr, 1698{
1393 const char *buf, size_t count) 1699 device_unregister(&rbd_dev->dev);
1700}
1701
1702static ssize_t rbd_add(struct bus_type *bus, const char *buf, size_t count)
1394{ 1703{
1395 struct ceph_osd_client *osdc; 1704 struct ceph_osd_client *osdc;
1396 struct rbd_device *rbd_dev; 1705 struct rbd_device *rbd_dev;
@@ -1419,6 +1728,7 @@ static ssize_t class_rbd_add(struct class *c,
1419 /* static rbd_device initialization */ 1728 /* static rbd_device initialization */
1420 spin_lock_init(&rbd_dev->lock); 1729 spin_lock_init(&rbd_dev->lock);
1421 INIT_LIST_HEAD(&rbd_dev->node); 1730 INIT_LIST_HEAD(&rbd_dev->node);
1731 INIT_LIST_HEAD(&rbd_dev->snaps);
1422 1732
1423 /* generate unique id: find highest unique id, add one */ 1733 /* generate unique id: find highest unique id, add one */
1424 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 1734 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
@@ -1478,6 +1788,9 @@ static ssize_t class_rbd_add(struct class *c,
1478 } 1788 }
1479 rbd_dev->major = irc; 1789 rbd_dev->major = irc;
1480 1790
1791 rc = rbd_bus_add_dev(rbd_dev);
1792 if (rc)
1793 goto err_out_disk;
1481 /* set up and announce blkdev mapping */ 1794 /* set up and announce blkdev mapping */
1482 rc = rbd_init_disk(rbd_dev); 1795 rc = rbd_init_disk(rbd_dev);
1483 if (rc) 1796 if (rc)
@@ -1487,6 +1800,8 @@ static ssize_t class_rbd_add(struct class *c,
1487 1800
1488err_out_blkdev: 1801err_out_blkdev:
1489 unregister_blkdev(rbd_dev->major, rbd_dev->name); 1802 unregister_blkdev(rbd_dev->major, rbd_dev->name);
1803err_out_disk:
1804 rbd_free_disk(rbd_dev);
1490err_out_client: 1805err_out_client:
1491 rbd_put_client(rbd_dev); 1806 rbd_put_client(rbd_dev);
1492 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 1807 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
@@ -1518,35 +1833,10 @@ static struct rbd_device *__rbd_get_dev(unsigned long id)
1518 return NULL; 1833 return NULL;
1519} 1834}
1520 1835
1521static ssize_t class_rbd_remove(struct class *c, 1836static void rbd_dev_release(struct device *dev)
1522 struct class_attribute *attr,
1523 const char *buf,
1524 size_t count)
1525{ 1837{
1526 struct rbd_device *rbd_dev = NULL; 1838 struct rbd_device *rbd_dev =
1527 int target_id, rc; 1839 container_of(dev, struct rbd_device, dev);
1528 unsigned long ul;
1529
1530 rc = strict_strtoul(buf, 10, &ul);
1531 if (rc)
1532 return rc;
1533
1534 /* convert to int; abort if we lost anything in the conversion */
1535 target_id = (int) ul;
1536 if (target_id != ul)
1537 return -EINVAL;
1538
1539 /* remove object from list immediately */
1540 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1541
1542 rbd_dev = __rbd_get_dev(target_id);
1543 if (rbd_dev)
1544 list_del_init(&rbd_dev->node);
1545
1546 mutex_unlock(&ctl_mutex);
1547
1548 if (!rbd_dev)
1549 return -ENOENT;
1550 1840
1551 rbd_put_client(rbd_dev); 1841 rbd_put_client(rbd_dev);
1552 1842
@@ -1557,67 +1847,11 @@ static ssize_t class_rbd_remove(struct class *c,
1557 1847
1558 /* release module ref */ 1848 /* release module ref */
1559 module_put(THIS_MODULE); 1849 module_put(THIS_MODULE);
1560
1561 return count;
1562} 1850}
1563 1851
1564static ssize_t class_rbd_snaps_list(struct class *c, 1852static ssize_t rbd_remove(struct bus_type *bus,
1565 struct class_attribute *attr, 1853 const char *buf,
1566 char *data) 1854 size_t count)
1567{
1568 struct rbd_device *rbd_dev = NULL;
1569 struct list_head *tmp;
1570 struct rbd_image_header *header;
1571 int i, n = 0, max = PAGE_SIZE;
1572 int ret;
1573
1574 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1575
1576 n += snprintf(data, max, "#id\tsnap\tKB\n");
1577
1578 list_for_each(tmp, &rbd_dev_list) {
1579 char *names, *p;
1580 struct ceph_snap_context *snapc;
1581
1582 rbd_dev = list_entry(tmp, struct rbd_device, node);
1583 header = &rbd_dev->header;
1584
1585 down_read(&header->snap_rwsem);
1586
1587 names = header->snap_names;
1588 snapc = header->snapc;
1589
1590 n += snprintf(data + n, max - n, "%d\t%s\t%lld%s\n",
1591 rbd_dev->id, RBD_SNAP_HEAD_NAME,
1592 header->image_size >> 10,
1593 (!rbd_dev->cur_snap ? " (*)" : ""));
1594 if (n == max)
1595 break;
1596
1597 p = names;
1598 for (i = 0; i < header->total_snaps; i++, p += strlen(p) + 1) {
1599 n += snprintf(data + n, max - n, "%d\t%s\t%lld%s\n",
1600 rbd_dev->id, p, header->snap_sizes[i] >> 10,
1601 (rbd_dev->cur_snap &&
1602 (snap_index(header, i) == rbd_dev->cur_snap) ?
1603 " (*)" : ""));
1604 if (n == max)
1605 break;
1606 }
1607
1608 up_read(&header->snap_rwsem);
1609 }
1610
1611
1612 ret = n;
1613 mutex_unlock(&ctl_mutex);
1614 return ret;
1615}
1616
1617static ssize_t class_rbd_snaps_refresh(struct class *c,
1618 struct class_attribute *attr,
1619 const char *buf,
1620 size_t count)
1621{ 1855{
1622 struct rbd_device *rbd_dev = NULL; 1856 struct rbd_device *rbd_dev = NULL;
1623 int target_id, rc; 1857 int target_id, rc;
@@ -1641,95 +1875,70 @@ static ssize_t class_rbd_snaps_refresh(struct class *c,
1641 goto done; 1875 goto done;
1642 } 1876 }
1643 1877
1644 rc = rbd_update_snaps(rbd_dev); 1878 list_del_init(&rbd_dev->node);
1645 if (rc < 0) 1879
1646 ret = rc; 1880 __rbd_remove_all_snaps(rbd_dev);
1881 rbd_bus_del_dev(rbd_dev);
1647 1882
1648done: 1883done:
1649 mutex_unlock(&ctl_mutex); 1884 mutex_unlock(&ctl_mutex);
1650 return ret; 1885 return ret;
1651} 1886}
1652 1887
1653static ssize_t class_rbd_snap_create(struct class *c, 1888static ssize_t rbd_snap_add(struct device *dev,
1654 struct class_attribute *attr, 1889 struct device_attribute *attr,
1655 const char *buf, 1890 const char *buf,
1656 size_t count) 1891 size_t count)
1657{ 1892{
1658 struct rbd_device *rbd_dev = NULL; 1893 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1659 int target_id, ret; 1894 int ret;
1660 char *name; 1895 char *name = kmalloc(count + 1, GFP_KERNEL);
1661
1662 name = kmalloc(RBD_MAX_SNAP_NAME_LEN + 1, GFP_KERNEL);
1663 if (!name) 1896 if (!name)
1664 return -ENOMEM; 1897 return -ENOMEM;
1665 1898
1666 /* parse snaps add command */ 1899 snprintf(name, count, "%s", buf);
1667 if (sscanf(buf, "%d "
1668 "%" __stringify(RBD_MAX_SNAP_NAME_LEN) "s",
1669 &target_id,
1670 name) != 2) {
1671 ret = -EINVAL;
1672 goto done;
1673 }
1674 1900
1675 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 1901 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1676 1902
1677 rbd_dev = __rbd_get_dev(target_id);
1678 if (!rbd_dev) {
1679 ret = -ENOENT;
1680 goto done_unlock;
1681 }
1682
1683 ret = rbd_header_add_snap(rbd_dev, 1903 ret = rbd_header_add_snap(rbd_dev,
1684 name, GFP_KERNEL); 1904 name, GFP_KERNEL);
1685 if (ret < 0) 1905 if (ret < 0)
1686 goto done_unlock; 1906 goto done_unlock;
1687 1907
1688 ret = rbd_update_snaps(rbd_dev); 1908 ret = __rbd_update_snaps(rbd_dev);
1689 if (ret < 0) 1909 if (ret < 0)
1690 goto done_unlock; 1910 goto done_unlock;
1691 1911
1692 ret = count; 1912 ret = count;
1693done_unlock: 1913done_unlock:
1694 mutex_unlock(&ctl_mutex); 1914 mutex_unlock(&ctl_mutex);
1695done:
1696 kfree(name); 1915 kfree(name);
1697 return ret; 1916 return ret;
1698} 1917}
1699 1918
1700static ssize_t class_rbd_rollback(struct class *c, 1919static ssize_t rbd_snap_rollback(struct device *dev,
1701 struct class_attribute *attr, 1920 struct device_attribute *attr,
1702 const char *buf, 1921 const char *buf,
1703 size_t count) 1922 size_t count)
1704{ 1923{
1705 struct rbd_device *rbd_dev = NULL; 1924 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1706 int target_id, ret; 1925 int ret;
1707 u64 snapid; 1926 u64 snapid;
1708 char snap_name[RBD_MAX_SNAP_NAME_LEN];
1709 u64 cur_ofs; 1927 u64 cur_ofs;
1710 char *seg_name; 1928 char *seg_name = NULL;
1929 char *snap_name = kmalloc(count + 1, GFP_KERNEL);
1930 ret = -ENOMEM;
1931 if (!snap_name)
1932 return ret;
1711 1933
1712 /* parse snaps add command */ 1934 /* parse snaps add command */
1713 if (sscanf(buf, "%d " 1935 snprintf(snap_name, count, "%s", buf);
1714 "%" __stringify(RBD_MAX_SNAP_NAME_LEN) "s",
1715 &target_id,
1716 snap_name) != 2) {
1717 return -EINVAL;
1718 }
1719
1720 ret = -ENOMEM;
1721 seg_name = kmalloc(RBD_MAX_SEG_NAME_LEN + 1, GFP_NOIO); 1936 seg_name = kmalloc(RBD_MAX_SEG_NAME_LEN + 1, GFP_NOIO);
1722 if (!seg_name) 1937 if (!seg_name)
1723 return ret; 1938 goto done;
1724 1939
1725 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 1940 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1726 1941
1727 rbd_dev = __rbd_get_dev(target_id);
1728 if (!rbd_dev) {
1729 ret = -ENOENT;
1730 goto done_unlock;
1731 }
1732
1733 ret = snap_by_name(&rbd_dev->header, snap_name, &snapid, NULL); 1942 ret = snap_by_name(&rbd_dev->header, snap_name, &snapid, NULL);
1734 if (ret < 0) 1943 if (ret < 0)
1735 goto done_unlock; 1944 goto done_unlock;
@@ -1750,7 +1959,7 @@ static ssize_t class_rbd_rollback(struct class *c,
1750 seg_name, ret); 1959 seg_name, ret);
1751 } 1960 }
1752 1961
1753 ret = rbd_update_snaps(rbd_dev); 1962 ret = __rbd_update_snaps(rbd_dev);
1754 if (ret < 0) 1963 if (ret < 0)
1755 goto done_unlock; 1964 goto done_unlock;
1756 1965
@@ -1758,57 +1967,42 @@ static ssize_t class_rbd_rollback(struct class *c,
1758 1967
1759done_unlock: 1968done_unlock:
1760 mutex_unlock(&ctl_mutex); 1969 mutex_unlock(&ctl_mutex);
1970done:
1761 kfree(seg_name); 1971 kfree(seg_name);
1972 kfree(snap_name);
1762 1973
1763 return ret; 1974 return ret;
1764} 1975}
1765 1976
1766static struct class_attribute class_rbd_attrs[] = { 1977static struct bus_attribute rbd_bus_attrs[] = {
1767 __ATTR(add, 0200, NULL, class_rbd_add), 1978 __ATTR(add, S_IWUSR, NULL, rbd_add),
1768 __ATTR(remove, 0200, NULL, class_rbd_remove), 1979 __ATTR(remove, S_IWUSR, NULL, rbd_remove),
1769 __ATTR(list, 0444, class_rbd_list, NULL),
1770 __ATTR(snaps_refresh, 0200, NULL, class_rbd_snaps_refresh),
1771 __ATTR(snap_create, 0200, NULL, class_rbd_snap_create),
1772 __ATTR(snaps_list, 0444, class_rbd_snaps_list, NULL),
1773 __ATTR(snap_rollback, 0200, NULL, class_rbd_rollback),
1774 __ATTR_NULL 1980 __ATTR_NULL
1775}; 1981};
1776 1982
1777/* 1983/*
1778 * create control files in sysfs 1984 * create control files in sysfs
1779 * /sys/class/rbd/... 1985 * /sys/bus/rbd/...
1780 */ 1986 */
1781static int rbd_sysfs_init(void) 1987static int rbd_sysfs_init(void)
1782{ 1988{
1783 int ret = -ENOMEM; 1989 int ret;
1784 1990
1785 class_rbd = kzalloc(sizeof(*class_rbd), GFP_KERNEL); 1991 rbd_bus_type.bus_attrs = rbd_bus_attrs;
1786 if (!class_rbd)
1787 goto out;
1788 1992
1789 class_rbd->name = DRV_NAME; 1993 ret = bus_register(&rbd_bus_type);
1790 class_rbd->owner = THIS_MODULE; 1994 if (ret < 0)
1791 class_rbd->class_release = class_rbd_release; 1995 return ret;
1792 class_rbd->class_attrs = class_rbd_attrs;
1793 1996
1794 ret = class_register(class_rbd); 1997 ret = device_register(&rbd_root_dev);
1795 if (ret)
1796 goto out_class;
1797 return 0;
1798 1998
1799out_class:
1800 kfree(class_rbd);
1801 class_rbd = NULL;
1802 pr_err(DRV_NAME ": failed to create class rbd\n");
1803out:
1804 return ret; 1999 return ret;
1805} 2000}
1806 2001
1807static void rbd_sysfs_cleanup(void) 2002static void rbd_sysfs_cleanup(void)
1808{ 2003{
1809 if (class_rbd) 2004 device_unregister(&rbd_root_dev);
1810 class_destroy(class_rbd); 2005 bus_unregister(&rbd_bus_type);
1811 class_rbd = NULL;
1812} 2006}
1813 2007
1814int __init rbd_init(void) 2008int __init rbd_init(void)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 255035cfc88a..657873e4328d 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -65,14 +65,14 @@ enum blkif_state {
65 65
66struct blk_shadow { 66struct blk_shadow {
67 struct blkif_request req; 67 struct blkif_request req;
68 unsigned long request; 68 struct request *request;
69 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 69 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST];
70}; 70};
71 71
72static DEFINE_MUTEX(blkfront_mutex); 72static DEFINE_MUTEX(blkfront_mutex);
73static const struct block_device_operations xlvbd_block_fops; 73static const struct block_device_operations xlvbd_block_fops;
74 74
75#define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE) 75#define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE)
76 76
77/* 77/*
78 * We have one of these per vbd, whether ide, scsi or 'other'. They 78 * We have one of these per vbd, whether ide, scsi or 'other'. They
@@ -136,7 +136,7 @@ static void add_id_to_freelist(struct blkfront_info *info,
136 unsigned long id) 136 unsigned long id)
137{ 137{
138 info->shadow[id].req.id = info->shadow_free; 138 info->shadow[id].req.id = info->shadow_free;
139 info->shadow[id].request = 0; 139 info->shadow[id].request = NULL;
140 info->shadow_free = id; 140 info->shadow_free = id;
141} 141}
142 142
@@ -245,14 +245,11 @@ static int blkif_ioctl(struct block_device *bdev, fmode_t mode,
245} 245}
246 246
247/* 247/*
248 * blkif_queue_request 248 * Generate a Xen blkfront IO request from a blk layer request. Reads
249 * and writes are handled as expected. Since we lack a loose flush
250 * request, we map flushes into a full ordered barrier.
249 * 251 *
250 * request block io 252 * @req: a request struct
251 *
252 * id: for guest use only.
253 * operation: BLKIF_OP_{READ,WRITE,PROBE}
254 * buffer: buffer to read/write into. this should be a
255 * virtual address in the guest os.
256 */ 253 */
257static int blkif_queue_request(struct request *req) 254static int blkif_queue_request(struct request *req)
258{ 255{
@@ -281,7 +278,7 @@ static int blkif_queue_request(struct request *req)
281 /* Fill out a communications ring structure. */ 278 /* Fill out a communications ring structure. */
282 ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt); 279 ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);
283 id = get_id_from_freelist(info); 280 id = get_id_from_freelist(info);
284 info->shadow[id].request = (unsigned long)req; 281 info->shadow[id].request = req;
285 282
286 ring_req->id = id; 283 ring_req->id = id;
287 ring_req->sector_number = (blkif_sector_t)blk_rq_pos(req); 284 ring_req->sector_number = (blkif_sector_t)blk_rq_pos(req);
@@ -290,6 +287,18 @@ static int blkif_queue_request(struct request *req)
290 ring_req->operation = rq_data_dir(req) ? 287 ring_req->operation = rq_data_dir(req) ?
291 BLKIF_OP_WRITE : BLKIF_OP_READ; 288 BLKIF_OP_WRITE : BLKIF_OP_READ;
292 289
290 if (req->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
291 /*
292 * Ideally we could just do an unordered
293 * flush-to-disk, but all we have is a full write
294 * barrier at the moment. However, a barrier write is
295 * a superset of FUA, so we can implement it the same
296 * way. (It's also a FLUSH+FUA, since it is
297 * guaranteed ordered WRT previous writes.)
298 */
299 ring_req->operation = BLKIF_OP_WRITE_BARRIER;
300 }
301
293 ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg); 302 ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg);
294 BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST); 303 BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
295 304
@@ -634,7 +643,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
634 643
635 bret = RING_GET_RESPONSE(&info->ring, i); 644 bret = RING_GET_RESPONSE(&info->ring, i);
636 id = bret->id; 645 id = bret->id;
637 req = (struct request *)info->shadow[id].request; 646 req = info->shadow[id].request;
638 647
639 blkif_completion(&info->shadow[id]); 648 blkif_completion(&info->shadow[id]);
640 649
@@ -647,6 +656,16 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
647 printk(KERN_WARNING "blkfront: %s: write barrier op failed\n", 656 printk(KERN_WARNING "blkfront: %s: write barrier op failed\n",
648 info->gd->disk_name); 657 info->gd->disk_name);
649 error = -EOPNOTSUPP; 658 error = -EOPNOTSUPP;
659 }
660 if (unlikely(bret->status == BLKIF_RSP_ERROR &&
661 info->shadow[id].req.nr_segments == 0)) {
662 printk(KERN_WARNING "blkfront: %s: empty write barrier op failed\n",
663 info->gd->disk_name);
664 error = -EOPNOTSUPP;
665 }
666 if (unlikely(error)) {
667 if (error == -EOPNOTSUPP)
668 error = 0;
650 info->feature_flush = 0; 669 info->feature_flush = 0;
651 xlvbd_flush(info); 670 xlvbd_flush(info);
652 } 671 }
@@ -899,7 +918,7 @@ static int blkif_recover(struct blkfront_info *info)
899 /* Stage 3: Find pending requests and requeue them. */ 918 /* Stage 3: Find pending requests and requeue them. */
900 for (i = 0; i < BLK_RING_SIZE; i++) { 919 for (i = 0; i < BLK_RING_SIZE; i++) {
901 /* Not in use? */ 920 /* Not in use? */
902 if (copy[i].request == 0) 921 if (!copy[i].request)
903 continue; 922 continue;
904 923
905 /* Grab a request slot and copy shadow state into it. */ 924 /* Grab a request slot and copy shadow state into it. */
@@ -916,9 +935,7 @@ static int blkif_recover(struct blkfront_info *info)
916 req->seg[j].gref, 935 req->seg[j].gref,
917 info->xbdev->otherend_id, 936 info->xbdev->otherend_id,
918 pfn_to_mfn(info->shadow[req->id].frame[j]), 937 pfn_to_mfn(info->shadow[req->id].frame[j]),
919 rq_data_dir( 938 rq_data_dir(info->shadow[req->id].request));
920 (struct request *)
921 info->shadow[req->id].request));
922 info->shadow[req->id].req = *req; 939 info->shadow[req->id].req = *req;
923 940
924 info->ring.req_prod_pvt++; 941 info->ring.req_prod_pvt++;
@@ -1067,14 +1084,8 @@ static void blkfront_connect(struct blkfront_info *info)
1067 */ 1084 */
1068 info->feature_flush = 0; 1085 info->feature_flush = 0;
1069 1086
1070 /*
1071 * The driver doesn't properly handled empty flushes, so
1072 * lets disable barrier support for now.
1073 */
1074#if 0
1075 if (!err && barrier) 1087 if (!err && barrier)
1076 info->feature_flush = REQ_FLUSH; 1088 info->feature_flush = REQ_FLUSH | REQ_FUA;
1077#endif
1078 1089
1079 err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size); 1090 err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size);
1080 if (err) { 1091 if (err) {
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 128cae4e8629..949ed09c6361 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -35,6 +35,10 @@
35static struct usb_device_id ath3k_table[] = { 35static struct usb_device_id ath3k_table[] = {
36 /* Atheros AR3011 */ 36 /* Atheros AR3011 */
37 { USB_DEVICE(0x0CF3, 0x3000) }, 37 { USB_DEVICE(0x0CF3, 0x3000) },
38
39 /* Atheros AR3011 with sflash firmware*/
40 { USB_DEVICE(0x0CF3, 0x3002) },
41
38 { } /* Terminating entry */ 42 { } /* Terminating entry */
39}; 43};
40 44
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index ab3894f742c3..1da773f899a2 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -99,6 +99,9 @@ static struct usb_device_id blacklist_table[] = {
99 /* Broadcom BCM2033 without firmware */ 99 /* Broadcom BCM2033 without firmware */
100 { USB_DEVICE(0x0a5c, 0x2033), .driver_info = BTUSB_IGNORE }, 100 { USB_DEVICE(0x0a5c, 0x2033), .driver_info = BTUSB_IGNORE },
101 101
102 /* Atheros 3011 with sflash firmware */
103 { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
104
102 /* Broadcom BCM2035 */ 105 /* Broadcom BCM2035 */
103 { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU }, 106 { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
104 { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, 107 { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
@@ -239,7 +242,8 @@ static void btusb_intr_complete(struct urb *urb)
239 242
240 err = usb_submit_urb(urb, GFP_ATOMIC); 243 err = usb_submit_urb(urb, GFP_ATOMIC);
241 if (err < 0) { 244 if (err < 0) {
242 BT_ERR("%s urb %p failed to resubmit (%d)", 245 if (err != -EPERM)
246 BT_ERR("%s urb %p failed to resubmit (%d)",
243 hdev->name, urb, -err); 247 hdev->name, urb, -err);
244 usb_unanchor_urb(urb); 248 usb_unanchor_urb(urb);
245 } 249 }
@@ -323,7 +327,8 @@ static void btusb_bulk_complete(struct urb *urb)
323 327
324 err = usb_submit_urb(urb, GFP_ATOMIC); 328 err = usb_submit_urb(urb, GFP_ATOMIC);
325 if (err < 0) { 329 if (err < 0) {
326 BT_ERR("%s urb %p failed to resubmit (%d)", 330 if (err != -EPERM)
331 BT_ERR("%s urb %p failed to resubmit (%d)",
327 hdev->name, urb, -err); 332 hdev->name, urb, -err);
328 usb_unanchor_urb(urb); 333 usb_unanchor_urb(urb);
329 } 334 }
@@ -412,7 +417,8 @@ static void btusb_isoc_complete(struct urb *urb)
412 417
413 err = usb_submit_urb(urb, GFP_ATOMIC); 418 err = usb_submit_urb(urb, GFP_ATOMIC);
414 if (err < 0) { 419 if (err < 0) {
415 BT_ERR("%s urb %p failed to resubmit (%d)", 420 if (err != -EPERM)
421 BT_ERR("%s urb %p failed to resubmit (%d)",
416 hdev->name, urb, -err); 422 hdev->name, urb, -err);
417 usb_unanchor_urb(urb); 423 usb_unanchor_urb(urb);
418 } 424 }
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 43412c03969e..3cb4539a98b2 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -39,7 +39,6 @@
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/fs.h> 40#include <linux/fs.h>
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/smp_lock.h>
43#include <asm/uaccess.h> 42#include <asm/uaccess.h>
44#include <asm/pgtable.h> 43#include <asm/pgtable.h>
45#include "agp.h" 44#include "agp.h"
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 9272c38dd3c6..16a2847b7cdb 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -812,8 +812,10 @@ static int intel_fake_agp_fetch_size(void)
812 812
813static void i830_cleanup(void) 813static void i830_cleanup(void)
814{ 814{
815 kunmap(intel_private.i8xx_page); 815 if (intel_private.i8xx_flush_page) {
816 intel_private.i8xx_flush_page = NULL; 816 kunmap(intel_private.i8xx_flush_page);
817 intel_private.i8xx_flush_page = NULL;
818 }
817 819
818 __free_page(intel_private.i8xx_page); 820 __free_page(intel_private.i8xx_page);
819 intel_private.i8xx_page = NULL; 821 intel_private.i8xx_page = NULL;
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index c0bd6f472c52..6ee3348bc3e4 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -81,7 +81,6 @@ 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>
85#include <linux/init.h> 84#include <linux/init.h>
86#include <linux/bitops.h> 85#include <linux/bitops.h>
87#include <linux/platform_device.h> 86#include <linux/platform_device.h>
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
index f6718f05dad4..095ab90535ce 100644
--- a/drivers/char/briq_panel.c
+++ b/drivers/char/briq_panel.c
@@ -6,7 +6,6 @@
6 6
7#include <linux/module.h> 7#include <linux/module.h>
8 8
9#include <linux/smp_lock.h>
10#include <linux/types.h> 9#include <linux/types.h>
11#include <linux/errno.h> 10#include <linux/errno.h>
12#include <linux/tty.h> 11#include <linux/tty.h>
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 55b8667f739f..7066e801b9d3 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -14,7 +14,6 @@
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/smp_lock.h>
18#include <linux/types.h> 17#include <linux/types.h>
19#include <linux/miscdevice.h> 18#include <linux/miscdevice.h>
20#include <linux/major.h> 19#include <linux/major.h>
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 788da05190cc..2016aad85203 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -37,7 +37,6 @@
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/fs.h> 38#include <linux/fs.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <linux/smp_lock.h>
41#include <linux/init.h> 40#include <linux/init.h>
42#include <linux/miscdevice.h> 41#include <linux/miscdevice.h>
43#include <linux/delay.h> 42#include <linux/delay.h>
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 667abd23ad6a..7c6de4c92458 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -21,7 +21,6 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/smp_lock.h>
25#include <linux/interrupt.h> 24#include <linux/interrupt.h>
26#include <linux/tty.h> 25#include <linux/tty.h>
27#include <linux/tty_flip.h> 26#include <linux/tty_flip.h>
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index f646725bd567..748c3b0ecd89 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -52,7 +52,6 @@
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>
56#include <linux/string.h> 55#include <linux/string.h>
57#include <linux/fcntl.h> 56#include <linux/fcntl.h>
58#include <linux/ptrace.h> 57#include <linux/ptrace.h>
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 9f8495b4fc8f..a7616d226a49 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -87,7 +87,6 @@
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>
91#include <linux/fcntl.h> 90#include <linux/fcntl.h>
92#include <linux/major.h> 91#include <linux/major.h>
93#include <linux/delay.h> 92#include <linux/delay.h>
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 4bef6ab83622..461a5a045517 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -40,7 +40,6 @@
40#include <linux/stallion.h> 40#include <linux/stallion.h>
41#include <linux/ioport.h> 41#include <linux/ioport.h>
42#include <linux/init.h> 42#include <linux/init.h>
43#include <linux/smp_lock.h>
44#include <linux/device.h> 43#include <linux/device.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
46#include <linux/ctype.h> 45#include <linux/ctype.h>
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index e53f16865397..a786326cea2f 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -216,7 +216,6 @@
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>
220#include <linux/init.h> 219#include <linux/init.h>
221#include <linux/miscdevice.h> 220#include <linux/miscdevice.h>
222#include <linux/bitops.h> 221#include <linux/bitops.h>
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 1030f8420137..c17a305ecb28 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -25,6 +25,7 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/wait.h> 27#include <linux/wait.h>
28#include <linux/acpi.h>
28#include "tpm.h" 29#include "tpm.h"
29 30
30#define TPM_HEADER_SIZE 10 31#define TPM_HEADER_SIZE 10
@@ -78,6 +79,26 @@ enum tis_defaults {
78static LIST_HEAD(tis_chips); 79static LIST_HEAD(tis_chips);
79static DEFINE_SPINLOCK(tis_lock); 80static DEFINE_SPINLOCK(tis_lock);
80 81
82#ifdef CONFIG_ACPI
83static int is_itpm(struct pnp_dev *dev)
84{
85 struct acpi_device *acpi = pnp_acpi_device(dev);
86 struct acpi_hardware_id *id;
87
88 list_for_each_entry(id, &acpi->pnp.ids, list) {
89 if (!strcmp("INTC0102", id->id))
90 return 1;
91 }
92
93 return 0;
94}
95#else
96static int is_itpm(struct pnp_dev *dev)
97{
98 return 0;
99}
100#endif
101
81static int check_locality(struct tpm_chip *chip, int l) 102static int check_locality(struct tpm_chip *chip, int l)
82{ 103{
83 if ((ioread8(chip->vendor.iobase + TPM_ACCESS(l)) & 104 if ((ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
@@ -472,6 +493,9 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
472 "1.2 TPM (device-id 0x%X, rev-id %d)\n", 493 "1.2 TPM (device-id 0x%X, rev-id %d)\n",
473 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0))); 494 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
474 495
496 if (is_itpm(to_pnp_dev(dev)))
497 itpm = 1;
498
475 if (itpm) 499 if (itpm)
476 dev_info(dev, "Intel iTPM workaround enabled\n"); 500 dev_info(dev, "Intel iTPM workaround enabled\n");
477 501
diff --git a/drivers/char/uv_mmtimer.c b/drivers/char/uv_mmtimer.c
index 493b47a0d511..956ebe2080a5 100644
--- a/drivers/char/uv_mmtimer.c
+++ b/drivers/char/uv_mmtimer.c
@@ -23,7 +23,6 @@
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/time.h> 24#include <linux/time.h>
25#include <linux/math64.h> 25#include <linux/math64.h>
26#include <linux/smp_lock.h>
27 26
28#include <asm/genapic.h> 27#include <asm/genapic.h>
29#include <asm/uv/uv_hub.h> 28#include <asm/uv/uv_hub.h>
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 6c1b676643a9..896a2ced1d27 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1547,31 +1547,16 @@ static int init_vqs(struct ports_device *portdev)
1547 nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2; 1547 nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
1548 1548
1549 vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL); 1549 vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL);
1550 if (!vqs) {
1551 err = -ENOMEM;
1552 goto fail;
1553 }
1554 io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL); 1550 io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL);
1555 if (!io_callbacks) {
1556 err = -ENOMEM;
1557 goto free_vqs;
1558 }
1559 io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL); 1551 io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL);
1560 if (!io_names) {
1561 err = -ENOMEM;
1562 goto free_callbacks;
1563 }
1564 portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), 1552 portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
1565 GFP_KERNEL); 1553 GFP_KERNEL);
1566 if (!portdev->in_vqs) {
1567 err = -ENOMEM;
1568 goto free_names;
1569 }
1570 portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), 1554 portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
1571 GFP_KERNEL); 1555 GFP_KERNEL);
1572 if (!portdev->out_vqs) { 1556 if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
1557 !portdev->out_vqs) {
1573 err = -ENOMEM; 1558 err = -ENOMEM;
1574 goto free_invqs; 1559 goto free;
1575 } 1560 }
1576 1561
1577 /* 1562 /*
@@ -1605,7 +1590,7 @@ static int init_vqs(struct ports_device *portdev)
1605 io_callbacks, 1590 io_callbacks,
1606 (const char **)io_names); 1591 (const char **)io_names);
1607 if (err) 1592 if (err)
1608 goto free_outvqs; 1593 goto free;
1609 1594
1610 j = 0; 1595 j = 0;
1611 portdev->in_vqs[0] = vqs[0]; 1596 portdev->in_vqs[0] = vqs[0];
@@ -1621,23 +1606,19 @@ static int init_vqs(struct ports_device *portdev)
1621 portdev->out_vqs[i] = vqs[j + 1]; 1606 portdev->out_vqs[i] = vqs[j + 1];
1622 } 1607 }
1623 } 1608 }
1624 kfree(io_callbacks);
1625 kfree(io_names); 1609 kfree(io_names);
1610 kfree(io_callbacks);
1626 kfree(vqs); 1611 kfree(vqs);
1627 1612
1628 return 0; 1613 return 0;
1629 1614
1630free_names: 1615free:
1631 kfree(io_names);
1632free_callbacks:
1633 kfree(io_callbacks);
1634free_outvqs:
1635 kfree(portdev->out_vqs); 1616 kfree(portdev->out_vqs);
1636free_invqs:
1637 kfree(portdev->in_vqs); 1617 kfree(portdev->in_vqs);
1638free_vqs: 1618 kfree(io_names);
1619 kfree(io_callbacks);
1639 kfree(vqs); 1620 kfree(vqs);
1640fail: 1621
1641 return err; 1622 return err;
1642} 1623}
1643 1624
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index d68d3aa1814b..f975d24890fa 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -283,16 +283,21 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p,
283 } while (delay); 283 } while (delay);
284} 284}
285 285
286static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) 286static void __sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
287{ 287{
288 unsigned long flags;
289
290 if (delta > p->max_match_value) 288 if (delta > p->max_match_value)
291 dev_warn(&p->pdev->dev, "delta out of range\n"); 289 dev_warn(&p->pdev->dev, "delta out of range\n");
292 290
293 spin_lock_irqsave(&p->lock, flags);
294 p->next_match_value = delta; 291 p->next_match_value = delta;
295 sh_cmt_clock_event_program_verify(p, 0); 292 sh_cmt_clock_event_program_verify(p, 0);
293}
294
295static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
296{
297 unsigned long flags;
298
299 spin_lock_irqsave(&p->lock, flags);
300 __sh_cmt_set_next(p, delta);
296 spin_unlock_irqrestore(&p->lock, flags); 301 spin_unlock_irqrestore(&p->lock, flags);
297} 302}
298 303
@@ -359,7 +364,7 @@ static int sh_cmt_start(struct sh_cmt_priv *p, unsigned long flag)
359 364
360 /* setup timeout if no clockevent */ 365 /* setup timeout if no clockevent */
361 if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT))) 366 if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT)))
362 sh_cmt_set_next(p, p->max_match_value); 367 __sh_cmt_set_next(p, p->max_match_value);
363 out: 368 out:
364 spin_unlock_irqrestore(&p->lock, flags); 369 spin_unlock_irqrestore(&p->lock, flags);
365 370
@@ -381,7 +386,7 @@ static void sh_cmt_stop(struct sh_cmt_priv *p, unsigned long flag)
381 386
382 /* adjust the timeout to maximum if only clocksource left */ 387 /* adjust the timeout to maximum if only clocksource left */
383 if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE)) 388 if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE))
384 sh_cmt_set_next(p, p->max_match_value); 389 __sh_cmt_set_next(p, p->max_match_value);
385 390
386 spin_unlock_irqrestore(&p->lock, flags); 391 spin_unlock_irqrestore(&p->lock, flags);
387} 392}
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index e16c3fa8d2e3..05117f1ad867 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -36,6 +36,7 @@
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>"); 37MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
38MODULE_DESCRIPTION("Generic userspace <-> kernelspace connector."); 38MODULE_DESCRIPTION("Generic userspace <-> kernelspace connector.");
39MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_CONNECTOR);
39 40
40static struct cn_dev cdev; 41static struct cn_dev cdev;
41 42
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index a8a84f4587f2..64b21f5cd740 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -1,8 +1,8 @@
1ifeq ($(CONFIG_DMADEVICES_DEBUG),y) 1ifeq ($(CONFIG_DMADEVICES_DEBUG),y)
2 EXTRA_CFLAGS += -DDEBUG 2 ccflags-y += -DDEBUG
3endif 3endif
4ifeq ($(CONFIG_DMADEVICES_VDEBUG),y) 4ifeq ($(CONFIG_DMADEVICES_VDEBUG),y)
5 EXTRA_CFLAGS += -DVERBOSE_DEBUG 5 ccflags-y += -DVERBOSE_DEBUG
6endif 6endif
7 7
8obj-$(CONFIG_DMA_ENGINE) += dmaengine.o 8obj-$(CONFIG_DMA_ENGINE) += dmaengine.o
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index a0f3e6a06e06..ea0ee81cff53 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -722,7 +722,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
722 desc->lli.daddr = mem; 722 desc->lli.daddr = mem;
723 desc->lli.ctrla = ctrla 723 desc->lli.ctrla = ctrla
724 | ATC_DST_WIDTH(mem_width) 724 | ATC_DST_WIDTH(mem_width)
725 | len >> mem_width; 725 | len >> reg_width;
726 desc->lli.ctrlb = ctrlb; 726 desc->lli.ctrlb = ctrlb;
727 727
728 if (!first) { 728 if (!first) {
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 286c3ac6bdcc..e5e172d21692 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -50,9 +50,11 @@ static void dma_init(struct fsldma_chan *chan)
50 * EIE - Error interrupt enable 50 * EIE - Error interrupt enable
51 * EOSIE - End of segments interrupt enable (basic mode) 51 * EOSIE - End of segments interrupt enable (basic mode)
52 * EOLNIE - End of links interrupt enable 52 * EOLNIE - End of links interrupt enable
53 * BWC - Bandwidth sharing among channels
53 */ 54 */
54 DMA_OUT(chan, &chan->regs->mr, FSL_DMA_MR_EIE 55 DMA_OUT(chan, &chan->regs->mr, FSL_DMA_MR_BWC
55 | FSL_DMA_MR_EOLNIE | FSL_DMA_MR_EOSIE, 32); 56 | FSL_DMA_MR_EIE | FSL_DMA_MR_EOLNIE
57 | FSL_DMA_MR_EOSIE, 32);
56 break; 58 break;
57 case FSL_DMA_IP_83XX: 59 case FSL_DMA_IP_83XX:
58 /* Set the channel to below modes: 60 /* Set the channel to below modes:
diff --git a/drivers/dma/fsldma.h b/drivers/dma/fsldma.h
index cb4d6ff51597..ba9f403c0fbe 100644
--- a/drivers/dma/fsldma.h
+++ b/drivers/dma/fsldma.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved. 2 * Copyright (C) 2007-2010 Freescale Semiconductor, Inc. All rights reserved.
3 * 3 *
4 * Author: 4 * Author:
5 * Zhang Wei <wei.zhang@freescale.com>, Jul 2007 5 * Zhang Wei <wei.zhang@freescale.com>, Jul 2007
@@ -36,6 +36,13 @@
36#define FSL_DMA_MR_DAHE 0x00002000 36#define FSL_DMA_MR_DAHE 0x00002000
37#define FSL_DMA_MR_SAHE 0x00001000 37#define FSL_DMA_MR_SAHE 0x00001000
38 38
39/*
40 * Bandwidth/pause control determines how many bytes a given
41 * channel is allowed to transfer before the DMA engine pauses
42 * the current channel and switches to the next channel
43 */
44#define FSL_DMA_MR_BWC 0x08000000
45
39/* Special MR definition for MPC8349 */ 46/* Special MR definition for MPC8349 */
40#define FSL_DMA_MR_EOTIE 0x00000080 47#define FSL_DMA_MR_EOTIE 0x00000080
41#define FSL_DMA_MR_PRC_RM 0x00000800 48#define FSL_DMA_MR_PRC_RM 0x00000800
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index f629e4961af5..e53d438142bb 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -379,7 +379,7 @@ static int __init imxdma_probe(struct platform_device *pdev)
379 return 0; 379 return 0;
380 380
381err_init: 381err_init:
382 while (i-- >= 0) { 382 while (--i >= 0) {
383 struct imxdma_channel *imxdmac = &imxdma->channel[i]; 383 struct imxdma_channel *imxdmac = &imxdma->channel[i];
384 imx_dma_free(imxdmac->imxdma_channel); 384 imx_dma_free(imxdmac->imxdma_channel);
385 } 385 }
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 0834323a0599..d0602dd5d1b2 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -951,7 +951,7 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
951 struct sdma_buffer_descriptor *bd = &sdmac->bd[i]; 951 struct sdma_buffer_descriptor *bd = &sdmac->bd[i];
952 int param; 952 int param;
953 953
954 bd->buffer_addr = sgl->dma_address; 954 bd->buffer_addr = sg->dma_address;
955 955
956 count = sg->length; 956 count = sg->length;
957 957
@@ -1385,7 +1385,7 @@ static int __init sdma_module_init(void)
1385{ 1385{
1386 return platform_driver_probe(&sdma_driver, sdma_probe); 1386 return platform_driver_probe(&sdma_driver, sdma_probe);
1387} 1387}
1388subsys_initcall(sdma_module_init); 1388module_init(sdma_module_init);
1389 1389
1390MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>"); 1390MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>");
1391MODULE_DESCRIPTION("i.MX SDMA driver"); 1391MODULE_DESCRIPTION("i.MX SDMA driver");
diff --git a/drivers/dma/intel_mid_dma.c b/drivers/dma/intel_mid_dma.c
index 338bc4eed1f3..3109bd94bc4f 100644
--- a/drivers/dma/intel_mid_dma.c
+++ b/drivers/dma/intel_mid_dma.c
@@ -1075,7 +1075,6 @@ static int mid_setup_dma(struct pci_dev *pdev)
1075 if (NULL == dma->dma_pool) { 1075 if (NULL == dma->dma_pool) {
1076 pr_err("ERR_MDMA:pci_pool_create failed\n"); 1076 pr_err("ERR_MDMA:pci_pool_create failed\n");
1077 err = -ENOMEM; 1077 err = -ENOMEM;
1078 kfree(dma);
1079 goto err_dma_pool; 1078 goto err_dma_pool;
1080 } 1079 }
1081 1080
@@ -1186,7 +1185,6 @@ err_engine:
1186 free_irq(pdev->irq, dma); 1185 free_irq(pdev->irq, dma);
1187err_irq: 1186err_irq:
1188 pci_pool_destroy(dma->dma_pool); 1187 pci_pool_destroy(dma->dma_pool);
1189 kfree(dma);
1190err_dma_pool: 1188err_dma_pool:
1191 pr_err("ERR_MDMA:setup_dma failed: %d\n", err); 1189 pr_err("ERR_MDMA:setup_dma failed: %d\n", err);
1192 return err; 1190 return err;
@@ -1413,7 +1411,7 @@ static const struct dev_pm_ops intel_mid_dma_pm = {
1413 .runtime_idle = dma_runtime_idle, 1411 .runtime_idle = dma_runtime_idle,
1414}; 1412};
1415 1413
1416static struct pci_driver intel_mid_dma_pci = { 1414static struct pci_driver intel_mid_dma_pci_driver = {
1417 .name = "Intel MID DMA", 1415 .name = "Intel MID DMA",
1418 .id_table = intel_mid_dma_ids, 1416 .id_table = intel_mid_dma_ids,
1419 .probe = intel_mid_dma_probe, 1417 .probe = intel_mid_dma_probe,
@@ -1431,13 +1429,13 @@ static int __init intel_mid_dma_init(void)
1431{ 1429{
1432 pr_debug("INFO_MDMA: LNW DMA Driver Version %s\n", 1430 pr_debug("INFO_MDMA: LNW DMA Driver Version %s\n",
1433 INTEL_MID_DMA_DRIVER_VERSION); 1431 INTEL_MID_DMA_DRIVER_VERSION);
1434 return pci_register_driver(&intel_mid_dma_pci); 1432 return pci_register_driver(&intel_mid_dma_pci_driver);
1435} 1433}
1436fs_initcall(intel_mid_dma_init); 1434fs_initcall(intel_mid_dma_init);
1437 1435
1438static void __exit intel_mid_dma_exit(void) 1436static void __exit intel_mid_dma_exit(void)
1439{ 1437{
1440 pci_unregister_driver(&intel_mid_dma_pci); 1438 pci_unregister_driver(&intel_mid_dma_pci_driver);
1441} 1439}
1442module_exit(intel_mid_dma_exit); 1440module_exit(intel_mid_dma_exit);
1443 1441
diff --git a/drivers/dma/ioat/Makefile b/drivers/dma/ioat/Makefile
index 8997d3fb9051..0ff7270af25b 100644
--- a/drivers/dma/ioat/Makefile
+++ b/drivers/dma/ioat/Makefile
@@ -1,2 +1,2 @@
1obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o 1obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
2ioatdma-objs := pci.o dma.o dma_v2.o dma_v3.o dca.o 2ioatdma-y := pci.o dma.o dma_v2.o dma_v3.o dca.o
diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index 92b679024fed..c064c89420d0 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -259,11 +259,6 @@ static void pdc_dostart(struct pch_dma_chan *pd_chan, struct pch_dma_desc* desc)
259 return; 259 return;
260 } 260 }
261 261
262 channel_writel(pd_chan, DEV_ADDR, desc->regs.dev_addr);
263 channel_writel(pd_chan, MEM_ADDR, desc->regs.mem_addr);
264 channel_writel(pd_chan, SIZE, desc->regs.size);
265 channel_writel(pd_chan, NEXT, desc->regs.next);
266
267 dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> dev_addr: %x\n", 262 dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> dev_addr: %x\n",
268 pd_chan->chan.chan_id, desc->regs.dev_addr); 263 pd_chan->chan.chan_id, desc->regs.dev_addr);
269 dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> mem_addr: %x\n", 264 dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> mem_addr: %x\n",
@@ -273,10 +268,16 @@ static void pdc_dostart(struct pch_dma_chan *pd_chan, struct pch_dma_desc* desc)
273 dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> next: %x\n", 268 dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> next: %x\n",
274 pd_chan->chan.chan_id, desc->regs.next); 269 pd_chan->chan.chan_id, desc->regs.next);
275 270
276 if (list_empty(&desc->tx_list)) 271 if (list_empty(&desc->tx_list)) {
272 channel_writel(pd_chan, DEV_ADDR, desc->regs.dev_addr);
273 channel_writel(pd_chan, MEM_ADDR, desc->regs.mem_addr);
274 channel_writel(pd_chan, SIZE, desc->regs.size);
275 channel_writel(pd_chan, NEXT, desc->regs.next);
277 pdc_set_mode(&pd_chan->chan, DMA_CTL0_ONESHOT); 276 pdc_set_mode(&pd_chan->chan, DMA_CTL0_ONESHOT);
278 else 277 } else {
278 channel_writel(pd_chan, NEXT, desc->txd.phys);
279 pdc_set_mode(&pd_chan->chan, DMA_CTL0_SG); 279 pdc_set_mode(&pd_chan->chan, DMA_CTL0_SG);
280 }
280 281
281 val = dma_readl(pd, CTL2); 282 val = dma_readl(pd, CTL2);
282 val |= 1 << (DMA_CTL2_START_SHIFT_BITS + pd_chan->chan.chan_id); 283 val |= 1 << (DMA_CTL2_START_SHIFT_BITS + pd_chan->chan.chan_id);
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index 0d58a4a4487f..cef584533ee8 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -4449,9 +4449,8 @@ static int __devinit ppc440spe_adma_probe(struct platform_device *ofdev,
4449 4449
4450 if (!request_mem_region(res.start, resource_size(&res), 4450 if (!request_mem_region(res.start, resource_size(&res),
4451 dev_driver_string(&ofdev->dev))) { 4451 dev_driver_string(&ofdev->dev))) {
4452 dev_err(&ofdev->dev, "failed to request memory region " 4452 dev_err(&ofdev->dev, "failed to request memory region %pR\n",
4453 "(0x%016llx-0x%016llx)\n", 4453 &res);
4454 (u64)res.start, (u64)res.end);
4455 initcode = PPC_ADMA_INIT_MEMREG; 4454 initcode = PPC_ADMA_INIT_MEMREG;
4456 ret = -EBUSY; 4455 ret = -EBUSY;
4457 goto out; 4456 goto out;
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index eb6b54dbb806..85ffd5e38c50 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -1213,3 +1213,4 @@ module_exit(sh_dmae_exit);
1213MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>"); 1213MODULE_AUTHOR("Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>");
1214MODULE_DESCRIPTION("Renesas SH DMA Engine driver"); 1214MODULE_DESCRIPTION("Renesas SH DMA Engine driver");
1215MODULE_LICENSE("GPL"); 1215MODULE_LICENSE("GPL");
1216MODULE_ALIAS("platform:sh-dma-engine");
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index b3781399b38a..ba2898b3639b 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -10,16 +10,16 @@ obj-$(CONFIG_EDAC) := edac_stub.o
10obj-$(CONFIG_EDAC_MM_EDAC) += edac_core.o 10obj-$(CONFIG_EDAC_MM_EDAC) += edac_core.o
11obj-$(CONFIG_EDAC_MCE) += edac_mce.o 11obj-$(CONFIG_EDAC_MCE) += edac_mce.o
12 12
13edac_core-objs := edac_mc.o edac_device.o edac_mc_sysfs.o edac_pci_sysfs.o 13edac_core-y := edac_mc.o edac_device.o edac_mc_sysfs.o edac_pci_sysfs.o
14edac_core-objs += edac_module.o edac_device_sysfs.o 14edac_core-y += edac_module.o edac_device_sysfs.o
15 15
16ifdef CONFIG_PCI 16ifdef CONFIG_PCI
17edac_core-objs += edac_pci.o edac_pci_sysfs.o 17edac_core-y += edac_pci.o edac_pci_sysfs.o
18endif 18endif
19 19
20obj-$(CONFIG_EDAC_MCE_INJ) += mce_amd_inj.o 20obj-$(CONFIG_EDAC_MCE_INJ) += mce_amd_inj.o
21 21
22edac_mce_amd-objs := mce_amd.o 22edac_mce_amd-y := mce_amd.o
23obj-$(CONFIG_EDAC_DECODE_MCE) += edac_mce_amd.o 23obj-$(CONFIG_EDAC_DECODE_MCE) += edac_mce_amd.o
24 24
25obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o 25obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 8521401bbd75..eca9ba193e94 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1572,7 +1572,7 @@ static int f10_match_to_this_node(struct amd64_pvt *pvt, int dram_range,
1572 debugf1(" HoleOffset=0x%x HoleValid=0x%x IntlvSel=0x%x\n", 1572 debugf1(" HoleOffset=0x%x HoleValid=0x%x IntlvSel=0x%x\n",
1573 hole_off, hole_valid, intlv_sel); 1573 hole_off, hole_valid, intlv_sel);
1574 1574
1575 if (intlv_en || 1575 if (intlv_en &&
1576 (intlv_sel != ((sys_addr >> 12) & intlv_en))) 1576 (intlv_sel != ((sys_addr >> 12) & intlv_en)))
1577 return -EINVAL; 1577 return -EINVAL;
1578 1578
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index d7ca43a828bd..251440cd50a3 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -41,10 +41,10 @@
41#define MC_PROC_NAME_MAX_LEN 7 41#define MC_PROC_NAME_MAX_LEN 7
42 42
43#if PAGE_SHIFT < 20 43#if PAGE_SHIFT < 20
44#define PAGES_TO_MiB( pages ) ( ( pages ) >> ( 20 - PAGE_SHIFT ) ) 44#define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
45#define MiB_TO_PAGES(mb) ((mb) >> (20 - PAGE_SHIFT)) 45#define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
46#else /* PAGE_SHIFT > 20 */ 46#else /* PAGE_SHIFT > 20 */
47#define PAGES_TO_MiB( pages ) ( ( pages ) << ( PAGE_SHIFT - 20 ) ) 47#define PAGES_TO_MiB(pages) ((pages) << (PAGE_SHIFT - 20))
48#define MiB_TO_PAGES(mb) ((mb) >> (PAGE_SHIFT - 20)) 48#define MiB_TO_PAGES(mb) ((mb) >> (PAGE_SHIFT - 20))
49#endif 49#endif
50 50
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index ba6586a69ccc..795ea69c4d8f 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -586,14 +586,16 @@ struct mem_ctl_info *edac_mc_del_mc(struct device *dev)
586 return NULL; 586 return NULL;
587 } 587 }
588 588
589 /* marking MCI offline */
590 mci->op_state = OP_OFFLINE;
591
592 del_mc_from_global_list(mci); 589 del_mc_from_global_list(mci);
593 mutex_unlock(&mem_ctls_mutex); 590 mutex_unlock(&mem_ctls_mutex);
594 591
595 /* flush workq processes and remove sysfs */ 592 /* flush workq processes */
596 edac_mc_workq_teardown(mci); 593 edac_mc_workq_teardown(mci);
594
595 /* marking MCI offline */
596 mci->op_state = OP_OFFLINE;
597
598 /* remove from sysfs */
597 edac_remove_sysfs_mci_device(mci); 599 edac_remove_sysfs_mci_device(mci);
598 600
599 edac_printk(KERN_INFO, EDAC_MC, 601 edac_printk(KERN_INFO, EDAC_MC,
diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c
index 8d0688f36d4c..39faded3cadd 100644
--- a/drivers/edac/mce_amd_inj.c
+++ b/drivers/edac/mce_amd_inj.c
@@ -139,7 +139,7 @@ static int __init edac_init_mce_inject(void)
139 return 0; 139 return 0;
140 140
141err_sysfs_create: 141err_sysfs_create:
142 while (i-- >= 0) 142 while (--i >= 0)
143 sysfs_remove_file(mce_kobj, &sysfs_attrs[i]->attr); 143 sysfs_remove_file(mce_kobj, &sysfs_attrs[i]->attr);
144 144
145 kobject_del(mce_kobj); 145 kobject_del(mce_kobj);
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 18fdd9703b48..1a467a91fb0b 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/bug.h> 9#include <linux/bug.h>
10#include <linux/delay.h>
10#include <linux/device.h> 11#include <linux/device.h>
11#include <linux/firewire.h> 12#include <linux/firewire.h>
12#include <linux/firewire-constants.h> 13#include <linux/firewire-constants.h>
@@ -26,8 +27,14 @@
26#include <asm/unaligned.h> 27#include <asm/unaligned.h>
27#include <net/arp.h> 28#include <net/arp.h>
28 29
29#define FWNET_MAX_FRAGMENTS 25 /* arbitrary limit */ 30/* rx limits */
30#define FWNET_ISO_PAGE_COUNT (PAGE_SIZE < 16 * 1024 ? 4 : 2) 31#define FWNET_MAX_FRAGMENTS 30 /* arbitrary, > TX queue depth */
32#define FWNET_ISO_PAGE_COUNT (PAGE_SIZE < 16*1024 ? 4 : 2)
33
34/* tx limits */
35#define FWNET_MAX_QUEUED_DATAGRAMS 20 /* < 64 = number of tlabels */
36#define FWNET_MIN_QUEUED_DATAGRAMS 10 /* should keep AT DMA busy enough */
37#define FWNET_TX_QUEUE_LEN FWNET_MAX_QUEUED_DATAGRAMS /* ? */
31 38
32#define IEEE1394_BROADCAST_CHANNEL 31 39#define IEEE1394_BROADCAST_CHANNEL 31
33#define IEEE1394_ALL_NODES (0xffc0 | 0x003f) 40#define IEEE1394_ALL_NODES (0xffc0 | 0x003f)
@@ -169,15 +176,8 @@ struct fwnet_device {
169 struct fw_address_handler handler; 176 struct fw_address_handler handler;
170 u64 local_fifo; 177 u64 local_fifo;
171 178
172 /* List of packets to be sent */ 179 /* Number of tx datagrams that have been queued but not yet acked */
173 struct list_head packet_list; 180 int queued_datagrams;
174 /*
175 * List of packets that were broadcasted. When we get an ISO interrupt
176 * one of them has been sent
177 */
178 struct list_head broadcasted_list;
179 /* List of packets that have been sent but not yet acked */
180 struct list_head sent_list;
181 181
182 struct list_head peer_list; 182 struct list_head peer_list;
183 struct fw_card *card; 183 struct fw_card *card;
@@ -195,7 +195,7 @@ struct fwnet_peer {
195 unsigned pdg_size; /* pd_list size */ 195 unsigned pdg_size; /* pd_list size */
196 196
197 u16 datagram_label; /* outgoing datagram label */ 197 u16 datagram_label; /* outgoing datagram label */
198 unsigned max_payload; /* includes RFC2374_FRAG_HDR_SIZE overhead */ 198 u16 max_payload; /* includes RFC2374_FRAG_HDR_SIZE overhead */
199 int node_id; 199 int node_id;
200 int generation; 200 int generation;
201 unsigned speed; 201 unsigned speed;
@@ -203,22 +203,18 @@ struct fwnet_peer {
203 203
204/* This is our task struct. It's used for the packet complete callback. */ 204/* This is our task struct. It's used for the packet complete callback. */
205struct fwnet_packet_task { 205struct fwnet_packet_task {
206 /*
207 * ptask can actually be on dev->packet_list, dev->broadcasted_list,
208 * or dev->sent_list depending on its current state.
209 */
210 struct list_head pt_link;
211 struct fw_transaction transaction; 206 struct fw_transaction transaction;
212 struct rfc2734_header hdr; 207 struct rfc2734_header hdr;
213 struct sk_buff *skb; 208 struct sk_buff *skb;
214 struct fwnet_device *dev; 209 struct fwnet_device *dev;
215 210
216 int outstanding_pkts; 211 int outstanding_pkts;
217 unsigned max_payload;
218 u64 fifo_addr; 212 u64 fifo_addr;
219 u16 dest_node; 213 u16 dest_node;
214 u16 max_payload;
220 u8 generation; 215 u8 generation;
221 u8 speed; 216 u8 speed;
217 u8 enqueued;
222}; 218};
223 219
224/* 220/*
@@ -650,8 +646,6 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
650 net->stats.rx_packets++; 646 net->stats.rx_packets++;
651 net->stats.rx_bytes += skb->len; 647 net->stats.rx_bytes += skb->len;
652 } 648 }
653 if (netif_queue_stopped(net))
654 netif_wake_queue(net);
655 649
656 return 0; 650 return 0;
657 651
@@ -660,8 +654,6 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
660 net->stats.rx_dropped++; 654 net->stats.rx_dropped++;
661 655
662 dev_kfree_skb_any(skb); 656 dev_kfree_skb_any(skb);
663 if (netif_queue_stopped(net))
664 netif_wake_queue(net);
665 657
666 return -ENOENT; 658 return -ENOENT;
667} 659}
@@ -793,15 +785,10 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
793 * Datagram is not complete, we're done for the 785 * Datagram is not complete, we're done for the
794 * moment. 786 * moment.
795 */ 787 */
796 spin_unlock_irqrestore(&dev->lock, flags); 788 retval = 0;
797
798 return 0;
799 fail: 789 fail:
800 spin_unlock_irqrestore(&dev->lock, flags); 790 spin_unlock_irqrestore(&dev->lock, flags);
801 791
802 if (netif_queue_stopped(net))
803 netif_wake_queue(net);
804
805 return retval; 792 return retval;
806} 793}
807 794
@@ -901,11 +888,19 @@ static void fwnet_free_ptask(struct fwnet_packet_task *ptask)
901 kmem_cache_free(fwnet_packet_task_cache, ptask); 888 kmem_cache_free(fwnet_packet_task_cache, ptask);
902} 889}
903 890
891/* Caller must hold dev->lock. */
892static void dec_queued_datagrams(struct fwnet_device *dev)
893{
894 if (--dev->queued_datagrams == FWNET_MIN_QUEUED_DATAGRAMS)
895 netif_wake_queue(dev->netdev);
896}
897
904static int fwnet_send_packet(struct fwnet_packet_task *ptask); 898static int fwnet_send_packet(struct fwnet_packet_task *ptask);
905 899
906static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask) 900static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
907{ 901{
908 struct fwnet_device *dev = ptask->dev; 902 struct fwnet_device *dev = ptask->dev;
903 struct sk_buff *skb = ptask->skb;
909 unsigned long flags; 904 unsigned long flags;
910 bool free; 905 bool free;
911 906
@@ -914,10 +909,14 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
914 ptask->outstanding_pkts--; 909 ptask->outstanding_pkts--;
915 910
916 /* Check whether we or the networking TX soft-IRQ is last user. */ 911 /* Check whether we or the networking TX soft-IRQ is last user. */
917 free = (ptask->outstanding_pkts == 0 && !list_empty(&ptask->pt_link)); 912 free = (ptask->outstanding_pkts == 0 && ptask->enqueued);
913 if (free)
914 dec_queued_datagrams(dev);
918 915
919 if (ptask->outstanding_pkts == 0) 916 if (ptask->outstanding_pkts == 0) {
920 list_del(&ptask->pt_link); 917 dev->netdev->stats.tx_packets++;
918 dev->netdev->stats.tx_bytes += skb->len;
919 }
921 920
922 spin_unlock_irqrestore(&dev->lock, flags); 921 spin_unlock_irqrestore(&dev->lock, flags);
923 922
@@ -926,7 +925,6 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
926 u16 fg_off; 925 u16 fg_off;
927 u16 datagram_label; 926 u16 datagram_label;
928 u16 lf; 927 u16 lf;
929 struct sk_buff *skb;
930 928
931 /* Update the ptask to point to the next fragment and send it */ 929 /* Update the ptask to point to the next fragment and send it */
932 lf = fwnet_get_hdr_lf(&ptask->hdr); 930 lf = fwnet_get_hdr_lf(&ptask->hdr);
@@ -953,7 +951,7 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
953 datagram_label = fwnet_get_hdr_dgl(&ptask->hdr); 951 datagram_label = fwnet_get_hdr_dgl(&ptask->hdr);
954 break; 952 break;
955 } 953 }
956 skb = ptask->skb; 954
957 skb_pull(skb, ptask->max_payload); 955 skb_pull(skb, ptask->max_payload);
958 if (ptask->outstanding_pkts > 1) { 956 if (ptask->outstanding_pkts > 1) {
959 fwnet_make_sf_hdr(&ptask->hdr, RFC2374_HDR_INTFRAG, 957 fwnet_make_sf_hdr(&ptask->hdr, RFC2374_HDR_INTFRAG,
@@ -970,6 +968,31 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
970 fwnet_free_ptask(ptask); 968 fwnet_free_ptask(ptask);
971} 969}
972 970
971static void fwnet_transmit_packet_failed(struct fwnet_packet_task *ptask)
972{
973 struct fwnet_device *dev = ptask->dev;
974 unsigned long flags;
975 bool free;
976
977 spin_lock_irqsave(&dev->lock, flags);
978
979 /* One fragment failed; don't try to send remaining fragments. */
980 ptask->outstanding_pkts = 0;
981
982 /* Check whether we or the networking TX soft-IRQ is last user. */
983 free = ptask->enqueued;
984 if (free)
985 dec_queued_datagrams(dev);
986
987 dev->netdev->stats.tx_dropped++;
988 dev->netdev->stats.tx_errors++;
989
990 spin_unlock_irqrestore(&dev->lock, flags);
991
992 if (free)
993 fwnet_free_ptask(ptask);
994}
995
973static void fwnet_write_complete(struct fw_card *card, int rcode, 996static void fwnet_write_complete(struct fw_card *card, int rcode,
974 void *payload, size_t length, void *data) 997 void *payload, size_t length, void *data)
975{ 998{
@@ -977,11 +1000,12 @@ static void fwnet_write_complete(struct fw_card *card, int rcode,
977 1000
978 ptask = data; 1001 ptask = data;
979 1002
980 if (rcode == RCODE_COMPLETE) 1003 if (rcode == RCODE_COMPLETE) {
981 fwnet_transmit_packet_done(ptask); 1004 fwnet_transmit_packet_done(ptask);
982 else 1005 } else {
983 fw_error("fwnet_write_complete: failed: %x\n", rcode); 1006 fw_error("fwnet_write_complete: failed: %x\n", rcode);
984 /* ??? error recovery */ 1007 fwnet_transmit_packet_failed(ptask);
1008 }
985} 1009}
986 1010
987static int fwnet_send_packet(struct fwnet_packet_task *ptask) 1011static int fwnet_send_packet(struct fwnet_packet_task *ptask)
@@ -1039,9 +1063,11 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask)
1039 spin_lock_irqsave(&dev->lock, flags); 1063 spin_lock_irqsave(&dev->lock, flags);
1040 1064
1041 /* If the AT tasklet already ran, we may be last user. */ 1065 /* If the AT tasklet already ran, we may be last user. */
1042 free = (ptask->outstanding_pkts == 0 && list_empty(&ptask->pt_link)); 1066 free = (ptask->outstanding_pkts == 0 && !ptask->enqueued);
1043 if (!free) 1067 if (!free)
1044 list_add_tail(&ptask->pt_link, &dev->broadcasted_list); 1068 ptask->enqueued = true;
1069 else
1070 dec_queued_datagrams(dev);
1045 1071
1046 spin_unlock_irqrestore(&dev->lock, flags); 1072 spin_unlock_irqrestore(&dev->lock, flags);
1047 1073
@@ -1056,9 +1082,11 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask)
1056 spin_lock_irqsave(&dev->lock, flags); 1082 spin_lock_irqsave(&dev->lock, flags);
1057 1083
1058 /* If the AT tasklet already ran, we may be last user. */ 1084 /* If the AT tasklet already ran, we may be last user. */
1059 free = (ptask->outstanding_pkts == 0 && list_empty(&ptask->pt_link)); 1085 free = (ptask->outstanding_pkts == 0 && !ptask->enqueued);
1060 if (!free) 1086 if (!free)
1061 list_add_tail(&ptask->pt_link, &dev->sent_list); 1087 ptask->enqueued = true;
1088 else
1089 dec_queued_datagrams(dev);
1062 1090
1063 spin_unlock_irqrestore(&dev->lock, flags); 1091 spin_unlock_irqrestore(&dev->lock, flags);
1064 1092
@@ -1224,6 +1252,15 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
1224 struct fwnet_peer *peer; 1252 struct fwnet_peer *peer;
1225 unsigned long flags; 1253 unsigned long flags;
1226 1254
1255 spin_lock_irqsave(&dev->lock, flags);
1256
1257 /* Can this happen? */
1258 if (netif_queue_stopped(dev->netdev)) {
1259 spin_unlock_irqrestore(&dev->lock, flags);
1260
1261 return NETDEV_TX_BUSY;
1262 }
1263
1227 ptask = kmem_cache_alloc(fwnet_packet_task_cache, GFP_ATOMIC); 1264 ptask = kmem_cache_alloc(fwnet_packet_task_cache, GFP_ATOMIC);
1228 if (ptask == NULL) 1265 if (ptask == NULL)
1229 goto fail; 1266 goto fail;
@@ -1242,9 +1279,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
1242 proto = hdr_buf.h_proto; 1279 proto = hdr_buf.h_proto;
1243 dg_size = skb->len; 1280 dg_size = skb->len;
1244 1281
1245 /* serialize access to peer, including peer->datagram_label */
1246 spin_lock_irqsave(&dev->lock, flags);
1247
1248 /* 1282 /*
1249 * Set the transmission type for the packet. ARP packets and IP 1283 * Set the transmission type for the packet. ARP packets and IP
1250 * broadcast packets are sent via GASP. 1284 * broadcast packets are sent via GASP.
@@ -1266,7 +1300,7 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
1266 1300
1267 peer = fwnet_peer_find_by_guid(dev, be64_to_cpu(guid)); 1301 peer = fwnet_peer_find_by_guid(dev, be64_to_cpu(guid));
1268 if (!peer || peer->fifo == FWNET_NO_FIFO_ADDR) 1302 if (!peer || peer->fifo == FWNET_NO_FIFO_ADDR)
1269 goto fail_unlock; 1303 goto fail;
1270 1304
1271 generation = peer->generation; 1305 generation = peer->generation;
1272 dest_node = peer->node_id; 1306 dest_node = peer->node_id;
@@ -1320,18 +1354,21 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
1320 max_payload += RFC2374_FRAG_HDR_SIZE; 1354 max_payload += RFC2374_FRAG_HDR_SIZE;
1321 } 1355 }
1322 1356
1357 if (++dev->queued_datagrams == FWNET_MAX_QUEUED_DATAGRAMS)
1358 netif_stop_queue(dev->netdev);
1359
1323 spin_unlock_irqrestore(&dev->lock, flags); 1360 spin_unlock_irqrestore(&dev->lock, flags);
1324 1361
1325 ptask->max_payload = max_payload; 1362 ptask->max_payload = max_payload;
1326 INIT_LIST_HEAD(&ptask->pt_link); 1363 ptask->enqueued = 0;
1327 1364
1328 fwnet_send_packet(ptask); 1365 fwnet_send_packet(ptask);
1329 1366
1330 return NETDEV_TX_OK; 1367 return NETDEV_TX_OK;
1331 1368
1332 fail_unlock:
1333 spin_unlock_irqrestore(&dev->lock, flags);
1334 fail: 1369 fail:
1370 spin_unlock_irqrestore(&dev->lock, flags);
1371
1335 if (ptask) 1372 if (ptask)
1336 kmem_cache_free(fwnet_packet_task_cache, ptask); 1373 kmem_cache_free(fwnet_packet_task_cache, ptask);
1337 1374
@@ -1377,7 +1414,7 @@ static void fwnet_init_dev(struct net_device *net)
1377 net->addr_len = FWNET_ALEN; 1414 net->addr_len = FWNET_ALEN;
1378 net->hard_header_len = FWNET_HLEN; 1415 net->hard_header_len = FWNET_HLEN;
1379 net->type = ARPHRD_IEEE1394; 1416 net->type = ARPHRD_IEEE1394;
1380 net->tx_queue_len = 10; 1417 net->tx_queue_len = FWNET_TX_QUEUE_LEN;
1381} 1418}
1382 1419
1383/* caller must hold fwnet_device_mutex */ 1420/* caller must hold fwnet_device_mutex */
@@ -1457,14 +1494,9 @@ static int fwnet_probe(struct device *_dev)
1457 dev->broadcast_rcv_context = NULL; 1494 dev->broadcast_rcv_context = NULL;
1458 dev->broadcast_xmt_max_payload = 0; 1495 dev->broadcast_xmt_max_payload = 0;
1459 dev->broadcast_xmt_datagramlabel = 0; 1496 dev->broadcast_xmt_datagramlabel = 0;
1460
1461 dev->local_fifo = FWNET_NO_FIFO_ADDR; 1497 dev->local_fifo = FWNET_NO_FIFO_ADDR;
1462 1498 dev->queued_datagrams = 0;
1463 INIT_LIST_HEAD(&dev->packet_list);
1464 INIT_LIST_HEAD(&dev->broadcasted_list);
1465 INIT_LIST_HEAD(&dev->sent_list);
1466 INIT_LIST_HEAD(&dev->peer_list); 1499 INIT_LIST_HEAD(&dev->peer_list);
1467
1468 dev->card = card; 1500 dev->card = card;
1469 dev->netdev = net; 1501 dev->netdev = net;
1470 1502
@@ -1522,7 +1554,7 @@ static int fwnet_remove(struct device *_dev)
1522 struct fwnet_peer *peer = dev_get_drvdata(_dev); 1554 struct fwnet_peer *peer = dev_get_drvdata(_dev);
1523 struct fwnet_device *dev = peer->dev; 1555 struct fwnet_device *dev = peer->dev;
1524 struct net_device *net; 1556 struct net_device *net;
1525 struct fwnet_packet_task *ptask, *pt_next; 1557 int i;
1526 1558
1527 mutex_lock(&fwnet_device_mutex); 1559 mutex_lock(&fwnet_device_mutex);
1528 1560
@@ -1540,21 +1572,9 @@ static int fwnet_remove(struct device *_dev)
1540 dev->card); 1572 dev->card);
1541 fw_iso_context_destroy(dev->broadcast_rcv_context); 1573 fw_iso_context_destroy(dev->broadcast_rcv_context);
1542 } 1574 }
1543 list_for_each_entry_safe(ptask, pt_next, 1575 for (i = 0; dev->queued_datagrams && i < 5; i++)
1544 &dev->packet_list, pt_link) { 1576 ssleep(1);
1545 dev_kfree_skb_any(ptask->skb); 1577 WARN_ON(dev->queued_datagrams);
1546 kmem_cache_free(fwnet_packet_task_cache, ptask);
1547 }
1548 list_for_each_entry_safe(ptask, pt_next,
1549 &dev->broadcasted_list, pt_link) {
1550 dev_kfree_skb_any(ptask->skb);
1551 kmem_cache_free(fwnet_packet_task_cache, ptask);
1552 }
1553 list_for_each_entry_safe(ptask, pt_next,
1554 &dev->sent_list, pt_link) {
1555 dev_kfree_skb_any(ptask->skb);
1556 kmem_cache_free(fwnet_packet_task_cache, ptask);
1557 }
1558 list_del(&dev->dev_link); 1578 list_del(&dev->dev_link);
1559 1579
1560 free_netdev(net); 1580 free_netdev(net);
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 84eb607d6c03..e3c8b60bd86b 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -242,6 +242,7 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
242 242
243static char ohci_driver_name[] = KBUILD_MODNAME; 243static char ohci_driver_name[] = KBUILD_MODNAME;
244 244
245#define PCI_DEVICE_ID_AGERE_FW643 0x5901
245#define PCI_DEVICE_ID_JMICRON_JMB38X_FW 0x2380 246#define PCI_DEVICE_ID_JMICRON_JMB38X_FW 0x2380
246#define PCI_DEVICE_ID_TI_TSB12LV22 0x8009 247#define PCI_DEVICE_ID_TI_TSB12LV22 0x8009
247 248
@@ -253,18 +254,34 @@ static char ohci_driver_name[] = KBUILD_MODNAME;
253 254
254/* In case of multiple matches in ohci_quirks[], only the first one is used. */ 255/* In case of multiple matches in ohci_quirks[], only the first one is used. */
255static const struct { 256static const struct {
256 unsigned short vendor, device, flags; 257 unsigned short vendor, device, revision, flags;
257} ohci_quirks[] = { 258} ohci_quirks[] = {
258 {PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TSB12LV22, QUIRK_CYCLE_TIMER | 259 {PCI_VENDOR_ID_AL, PCI_ANY_ID, PCI_ANY_ID,
259 QUIRK_RESET_PACKET | 260 QUIRK_CYCLE_TIMER},
260 QUIRK_NO_1394A}, 261
261 {PCI_VENDOR_ID_TI, PCI_ANY_ID, QUIRK_RESET_PACKET}, 262 {PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_FW, PCI_ANY_ID,
262 {PCI_VENDOR_ID_AL, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, 263 QUIRK_BE_HEADERS},
263 {PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB38X_FW, QUIRK_NO_MSI}, 264
264 {PCI_VENDOR_ID_NEC, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, 265 {PCI_VENDOR_ID_ATT, PCI_DEVICE_ID_AGERE_FW643, 6,
265 {PCI_VENDOR_ID_VIA, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, 266 QUIRK_NO_MSI},
266 {PCI_VENDOR_ID_RICOH, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, 267
267 {PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_FW, QUIRK_BE_HEADERS}, 268 {PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB38X_FW, PCI_ANY_ID,
269 QUIRK_NO_MSI},
270
271 {PCI_VENDOR_ID_NEC, PCI_ANY_ID, PCI_ANY_ID,
272 QUIRK_CYCLE_TIMER},
273
274 {PCI_VENDOR_ID_RICOH, PCI_ANY_ID, PCI_ANY_ID,
275 QUIRK_CYCLE_TIMER},
276
277 {PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TSB12LV22, PCI_ANY_ID,
278 QUIRK_CYCLE_TIMER | QUIRK_RESET_PACKET | QUIRK_NO_1394A},
279
280 {PCI_VENDOR_ID_TI, PCI_ANY_ID, PCI_ANY_ID,
281 QUIRK_RESET_PACKET},
282
283 {PCI_VENDOR_ID_VIA, PCI_ANY_ID, PCI_ANY_ID,
284 QUIRK_CYCLE_TIMER | QUIRK_NO_MSI},
268}; 285};
269 286
270/* This overrides anything that was found in ohci_quirks[]. */ 287/* This overrides anything that was found in ohci_quirks[]. */
@@ -2927,9 +2944,11 @@ static int __devinit pci_probe(struct pci_dev *dev,
2927 } 2944 }
2928 2945
2929 for (i = 0; i < ARRAY_SIZE(ohci_quirks); i++) 2946 for (i = 0; i < ARRAY_SIZE(ohci_quirks); i++)
2930 if (ohci_quirks[i].vendor == dev->vendor && 2947 if ((ohci_quirks[i].vendor == dev->vendor) &&
2931 (ohci_quirks[i].device == dev->device || 2948 (ohci_quirks[i].device == (unsigned short)PCI_ANY_ID ||
2932 ohci_quirks[i].device == (unsigned short)PCI_ANY_ID)) { 2949 ohci_quirks[i].device == dev->device) &&
2950 (ohci_quirks[i].revision == (unsigned short)PCI_ANY_ID ||
2951 ohci_quirks[i].revision >= dev->revision)) {
2933 ohci->quirks = ohci_quirks[i].flags; 2952 ohci->quirks = ohci_quirks[i].flags;
2934 break; 2953 break;
2935 } 2954 }
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index bfae4b309791..afa576a75a8e 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1468,7 +1468,7 @@ static int sbp2_map_scatterlist(struct sbp2_command_orb *orb,
1468 1468
1469/* SCSI stack integration */ 1469/* SCSI stack integration */
1470 1470
1471static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) 1471static int sbp2_scsi_queuecommand_lck(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1472{ 1472{
1473 struct sbp2_logical_unit *lu = cmd->device->hostdata; 1473 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1474 struct fw_device *device = target_device(lu->tgt); 1474 struct fw_device *device = target_device(lu->tgt);
@@ -1534,6 +1534,8 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1534 return retval; 1534 return retval;
1535} 1535}
1536 1536
1537static DEF_SCSI_QCMD(sbp2_scsi_queuecommand)
1538
1537static int sbp2_scsi_slave_alloc(struct scsi_device *sdev) 1539static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
1538{ 1540{
1539 struct sbp2_logical_unit *lu = sdev->hostdata; 1541 struct sbp2_logical_unit *lu = sdev->hostdata;
diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c
index e23c06893d19..599f6c9e0fbf 100644
--- a/drivers/gpio/cs5535-gpio.c
+++ b/drivers/gpio/cs5535-gpio.c
@@ -56,6 +56,18 @@ static struct cs5535_gpio_chip {
56 * registers, see include/linux/cs5535.h. 56 * registers, see include/linux/cs5535.h.
57 */ 57 */
58 58
59static void errata_outl(u32 val, unsigned long addr)
60{
61 /*
62 * According to the CS5536 errata (#36), after suspend
63 * a write to the high bank GPIO register will clear all
64 * non-selected bits; the recommended workaround is a
65 * read-modify-write operation.
66 */
67 val |= inl(addr);
68 outl(val, addr);
69}
70
59static void __cs5535_gpio_set(struct cs5535_gpio_chip *chip, unsigned offset, 71static void __cs5535_gpio_set(struct cs5535_gpio_chip *chip, unsigned offset,
60 unsigned int reg) 72 unsigned int reg)
61{ 73{
@@ -64,7 +76,7 @@ static void __cs5535_gpio_set(struct cs5535_gpio_chip *chip, unsigned offset,
64 outl(1 << offset, chip->base + reg); 76 outl(1 << offset, chip->base + reg);
65 else 77 else
66 /* high bank register */ 78 /* high bank register */
67 outl(1 << (offset - 16), chip->base + 0x80 + reg); 79 errata_outl(1 << (offset - 16), chip->base + 0x80 + reg);
68} 80}
69 81
70void cs5535_gpio_set(unsigned offset, unsigned int reg) 82void cs5535_gpio_set(unsigned offset, unsigned int reg)
@@ -86,7 +98,7 @@ static void __cs5535_gpio_clear(struct cs5535_gpio_chip *chip, unsigned offset,
86 outl(1 << (offset + 16), chip->base + reg); 98 outl(1 << (offset + 16), chip->base + reg);
87 else 99 else
88 /* high bank register */ 100 /* high bank register */
89 outl(1 << offset, chip->base + 0x80 + reg); 101 errata_outl(1 << offset, chip->base + 0x80 + reg);
90} 102}
91 103
92void cs5535_gpio_clear(unsigned offset, unsigned int reg) 104void cs5535_gpio_clear(unsigned offset, unsigned int reg)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 6985cb1da72c..2baa6708e44c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -156,12 +156,12 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
156 { DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO", 0 }, 156 { DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO", 0 },
157 { DRM_MODE_CONNECTOR_LVDS, "LVDS", 0 }, 157 { DRM_MODE_CONNECTOR_LVDS, "LVDS", 0 },
158 { DRM_MODE_CONNECTOR_Component, "Component", 0 }, 158 { DRM_MODE_CONNECTOR_Component, "Component", 0 },
159 { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN", 0 }, 159 { DRM_MODE_CONNECTOR_9PinDIN, "DIN", 0 },
160 { DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort", 0 }, 160 { DRM_MODE_CONNECTOR_DisplayPort, "DP", 0 },
161 { DRM_MODE_CONNECTOR_HDMIA, "HDMI Type A", 0 }, 161 { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A", 0 },
162 { DRM_MODE_CONNECTOR_HDMIB, "HDMI Type B", 0 }, 162 { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B", 0 },
163 { DRM_MODE_CONNECTOR_TV, "TV", 0 }, 163 { DRM_MODE_CONNECTOR_TV, "TV", 0 },
164 { DRM_MODE_CONNECTOR_eDP, "Embedded DisplayPort", 0 }, 164 { DRM_MODE_CONNECTOR_eDP, "eDP", 0 },
165}; 165};
166 166
167static struct drm_prop_enum_list drm_encoder_enum_list[] = 167static struct drm_prop_enum_list drm_encoder_enum_list[] =
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index f7af91cb273d..bede10a03407 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -241,7 +241,7 @@ void drm_helper_disable_unused_functions(struct drm_device *dev)
241 } 241 }
242 242
243 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 243 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
244 if (!drm_helper_encoder_in_use(encoder)) { 244 if (encoder->crtc && !drm_helper_encoder_in_use(encoder)) {
245 drm_encoder_disable(encoder); 245 drm_encoder_disable(encoder);
246 /* disconnector encoder from any connector */ 246 /* disconnector encoder from any connector */
247 encoder->crtc = NULL; 247 encoder->crtc = NULL;
@@ -471,6 +471,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
471 int count = 0, ro, fail = 0; 471 int count = 0, ro, fail = 0;
472 struct drm_crtc_helper_funcs *crtc_funcs; 472 struct drm_crtc_helper_funcs *crtc_funcs;
473 int ret = 0; 473 int ret = 0;
474 int i;
474 475
475 DRM_DEBUG_KMS("\n"); 476 DRM_DEBUG_KMS("\n");
476 477
@@ -666,6 +667,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
666 if (ret != 0) 667 if (ret != 0)
667 goto fail; 668 goto fail;
668 } 669 }
670 DRM_DEBUG_KMS("Setting connector DPMS state to on\n");
671 for (i = 0; i < set->num_connectors; i++) {
672 DRM_DEBUG_KMS("\t[CONNECTOR:%d:%s] set DPMS on\n", set->connectors[i]->base.id,
673 drm_get_connector_name(set->connectors[i]));
674 set->connectors[i]->dpms = DRM_MODE_DPMS_ON;
675 }
669 676
670 kfree(save_connectors); 677 kfree(save_connectors);
671 kfree(save_encoders); 678 kfree(save_encoders);
@@ -841,7 +848,7 @@ static void output_poll_execute(struct work_struct *work)
841 struct delayed_work *delayed_work = to_delayed_work(work); 848 struct delayed_work *delayed_work = to_delayed_work(work);
842 struct drm_device *dev = container_of(delayed_work, struct drm_device, mode_config.output_poll_work); 849 struct drm_device *dev = container_of(delayed_work, struct drm_device, mode_config.output_poll_work);
843 struct drm_connector *connector; 850 struct drm_connector *connector;
844 enum drm_connector_status old_status, status; 851 enum drm_connector_status old_status;
845 bool repoll = false, changed = false; 852 bool repoll = false, changed = false;
846 853
847 if (!drm_kms_helper_poll) 854 if (!drm_kms_helper_poll)
@@ -866,8 +873,9 @@ static void output_poll_execute(struct work_struct *work)
866 !(connector->polled & DRM_CONNECTOR_POLL_HPD)) 873 !(connector->polled & DRM_CONNECTOR_POLL_HPD))
867 continue; 874 continue;
868 875
869 status = connector->funcs->detect(connector, false); 876 connector->status = connector->funcs->detect(connector, false);
870 if (old_status != status) 877 DRM_DEBUG_KMS("connector status updated to %d\n", connector->status);
878 if (old_status != connector->status)
871 changed = true; 879 changed = true;
872 } 880 }
873 881
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index b744dad5c237..a39794bac04b 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -37,7 +37,6 @@
37#include "drmP.h" 37#include "drmP.h"
38#include <linux/poll.h> 38#include <linux/poll.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/smp_lock.h>
41 40
42/* from BKL pushdown: note that nothing else serializes idr_find() */ 41/* from BKL pushdown: note that nothing else serializes idr_find() */
43DEFINE_MUTEX(drm_global_mutex); 42DEFINE_MUTEX(drm_global_mutex);
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 9d3a5030b6e1..16d5155edad1 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -585,10 +585,13 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
585 struct timeval now; 585 struct timeval now;
586 unsigned long flags; 586 unsigned long flags;
587 unsigned int seq; 587 unsigned int seq;
588 int ret;
588 589
589 e = kzalloc(sizeof *e, GFP_KERNEL); 590 e = kzalloc(sizeof *e, GFP_KERNEL);
590 if (e == NULL) 591 if (e == NULL) {
591 return -ENOMEM; 592 ret = -ENOMEM;
593 goto err_put;
594 }
592 595
593 e->pipe = pipe; 596 e->pipe = pipe;
594 e->base.pid = current->pid; 597 e->base.pid = current->pid;
@@ -603,9 +606,8 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
603 spin_lock_irqsave(&dev->event_lock, flags); 606 spin_lock_irqsave(&dev->event_lock, flags);
604 607
605 if (file_priv->event_space < sizeof e->event) { 608 if (file_priv->event_space < sizeof e->event) {
606 spin_unlock_irqrestore(&dev->event_lock, flags); 609 ret = -EBUSY;
607 kfree(e); 610 goto err_unlock;
608 return -ENOMEM;
609 } 611 }
610 612
611 file_priv->event_space -= sizeof e->event; 613 file_priv->event_space -= sizeof e->event;
@@ -626,7 +628,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
626 if ((seq - vblwait->request.sequence) <= (1 << 23)) { 628 if ((seq - vblwait->request.sequence) <= (1 << 23)) {
627 e->event.tv_sec = now.tv_sec; 629 e->event.tv_sec = now.tv_sec;
628 e->event.tv_usec = now.tv_usec; 630 e->event.tv_usec = now.tv_usec;
629 drm_vblank_put(dev, e->pipe); 631 drm_vblank_put(dev, pipe);
630 list_add_tail(&e->base.link, &e->base.file_priv->event_list); 632 list_add_tail(&e->base.link, &e->base.file_priv->event_list);
631 wake_up_interruptible(&e->base.file_priv->event_wait); 633 wake_up_interruptible(&e->base.file_priv->event_wait);
632 trace_drm_vblank_event_delivered(current->pid, pipe, 634 trace_drm_vblank_event_delivered(current->pid, pipe,
@@ -638,6 +640,13 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
638 spin_unlock_irqrestore(&dev->event_lock, flags); 640 spin_unlock_irqrestore(&dev->event_lock, flags);
639 641
640 return 0; 642 return 0;
643
644err_unlock:
645 spin_unlock_irqrestore(&dev->event_lock, flags);
646 kfree(e);
647err_put:
648 drm_vblank_put(dev, pipe);
649 return ret;
641} 650}
642 651
643/** 652/**
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 7a26f4dd21ae..e6800819bca8 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -767,6 +767,9 @@ static int i915_getparam(struct drm_device *dev, void *data,
767 case I915_PARAM_HAS_BLT: 767 case I915_PARAM_HAS_BLT:
768 value = HAS_BLT(dev); 768 value = HAS_BLT(dev);
769 break; 769 break;
770 case I915_PARAM_HAS_COHERENT_RINGS:
771 value = 1;
772 break;
770 default: 773 default:
771 DRM_DEBUG_DRIVER("Unknown parameter %d\n", 774 DRM_DEBUG_DRIVER("Unknown parameter %d\n",
772 param->param); 775 param->param);
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 80745f85902c..f737960712e6 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -150,7 +150,8 @@ static const struct intel_device_info intel_ironlake_d_info = {
150 150
151static const struct intel_device_info intel_ironlake_m_info = { 151static const struct intel_device_info intel_ironlake_m_info = {
152 .gen = 5, .is_mobile = 1, 152 .gen = 5, .is_mobile = 1,
153 .need_gfx_hws = 1, .has_fbc = 1, .has_rc6 = 1, .has_hotplug = 1, 153 .need_gfx_hws = 1, .has_rc6 = 1, .has_hotplug = 1,
154 .has_fbc = 0, /* disabled due to buggy hardware */
154 .has_bsd_ring = 1, 155 .has_bsd_ring = 1,
155}; 156};
156 157
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 90414ae86afc..409826da3099 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1045,6 +1045,8 @@ void i915_gem_clflush_object(struct drm_gem_object *obj);
1045int i915_gem_object_set_domain(struct drm_gem_object *obj, 1045int i915_gem_object_set_domain(struct drm_gem_object *obj,
1046 uint32_t read_domains, 1046 uint32_t read_domains,
1047 uint32_t write_domain); 1047 uint32_t write_domain);
1048int i915_gem_object_flush_gpu(struct drm_i915_gem_object *obj,
1049 bool interruptible);
1048int i915_gem_init_ringbuffer(struct drm_device *dev); 1050int i915_gem_init_ringbuffer(struct drm_device *dev);
1049void i915_gem_cleanup_ringbuffer(struct drm_device *dev); 1051void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
1050int i915_gem_do_init(struct drm_device *dev, unsigned long start, 1052int i915_gem_do_init(struct drm_device *dev, unsigned long start,
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index ef188e391406..275ec6ed43ae 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -38,8 +38,7 @@
38 38
39static uint32_t i915_gem_get_gtt_alignment(struct drm_gem_object *obj); 39static uint32_t i915_gem_get_gtt_alignment(struct drm_gem_object *obj);
40 40
41static int i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj, 41static int i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj);
42 bool pipelined);
43static void i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj); 42static void i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj);
44static void i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj); 43static void i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj);
45static int i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, 44static int i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj,
@@ -547,6 +546,19 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
547 struct drm_i915_gem_object *obj_priv; 546 struct drm_i915_gem_object *obj_priv;
548 int ret = 0; 547 int ret = 0;
549 548
549 if (args->size == 0)
550 return 0;
551
552 if (!access_ok(VERIFY_WRITE,
553 (char __user *)(uintptr_t)args->data_ptr,
554 args->size))
555 return -EFAULT;
556
557 ret = fault_in_pages_writeable((char __user *)(uintptr_t)args->data_ptr,
558 args->size);
559 if (ret)
560 return -EFAULT;
561
550 ret = i915_mutex_lock_interruptible(dev); 562 ret = i915_mutex_lock_interruptible(dev);
551 if (ret) 563 if (ret)
552 return ret; 564 return ret;
@@ -564,23 +576,6 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
564 goto out; 576 goto out;
565 } 577 }
566 578
567 if (args->size == 0)
568 goto out;
569
570 if (!access_ok(VERIFY_WRITE,
571 (char __user *)(uintptr_t)args->data_ptr,
572 args->size)) {
573 ret = -EFAULT;
574 goto out;
575 }
576
577 ret = fault_in_pages_writeable((char __user *)(uintptr_t)args->data_ptr,
578 args->size);
579 if (ret) {
580 ret = -EFAULT;
581 goto out;
582 }
583
584 ret = i915_gem_object_get_pages_or_evict(obj); 579 ret = i915_gem_object_get_pages_or_evict(obj);
585 if (ret) 580 if (ret)
586 goto out; 581 goto out;
@@ -981,7 +976,20 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
981 struct drm_i915_gem_pwrite *args = data; 976 struct drm_i915_gem_pwrite *args = data;
982 struct drm_gem_object *obj; 977 struct drm_gem_object *obj;
983 struct drm_i915_gem_object *obj_priv; 978 struct drm_i915_gem_object *obj_priv;
984 int ret = 0; 979 int ret;
980
981 if (args->size == 0)
982 return 0;
983
984 if (!access_ok(VERIFY_READ,
985 (char __user *)(uintptr_t)args->data_ptr,
986 args->size))
987 return -EFAULT;
988
989 ret = fault_in_pages_readable((char __user *)(uintptr_t)args->data_ptr,
990 args->size);
991 if (ret)
992 return -EFAULT;
985 993
986 ret = i915_mutex_lock_interruptible(dev); 994 ret = i915_mutex_lock_interruptible(dev);
987 if (ret) 995 if (ret)
@@ -994,30 +1002,12 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
994 } 1002 }
995 obj_priv = to_intel_bo(obj); 1003 obj_priv = to_intel_bo(obj);
996 1004
997
998 /* Bounds check destination. */ 1005 /* Bounds check destination. */
999 if (args->offset > obj->size || args->size > obj->size - args->offset) { 1006 if (args->offset > obj->size || args->size > obj->size - args->offset) {
1000 ret = -EINVAL; 1007 ret = -EINVAL;
1001 goto out; 1008 goto out;
1002 } 1009 }
1003 1010
1004 if (args->size == 0)
1005 goto out;
1006
1007 if (!access_ok(VERIFY_READ,
1008 (char __user *)(uintptr_t)args->data_ptr,
1009 args->size)) {
1010 ret = -EFAULT;
1011 goto out;
1012 }
1013
1014 ret = fault_in_pages_readable((char __user *)(uintptr_t)args->data_ptr,
1015 args->size);
1016 if (ret) {
1017 ret = -EFAULT;
1018 goto out;
1019 }
1020
1021 /* We can only do the GTT pwrite on untiled buffers, as otherwise 1011 /* We can only do the GTT pwrite on untiled buffers, as otherwise
1022 * it would end up going through the fenced access, and we'll get 1012 * it would end up going through the fenced access, and we'll get
1023 * different detiling behavior between reading and writing. 1013 * different detiling behavior between reading and writing.
@@ -2603,7 +2593,7 @@ i915_gem_object_put_fence_reg(struct drm_gem_object *obj,
2603 if (reg->gpu) { 2593 if (reg->gpu) {
2604 int ret; 2594 int ret;
2605 2595
2606 ret = i915_gem_object_flush_gpu_write_domain(obj, true); 2596 ret = i915_gem_object_flush_gpu_write_domain(obj);
2607 if (ret) 2597 if (ret)
2608 return ret; 2598 return ret;
2609 2599
@@ -2751,8 +2741,7 @@ i915_gem_clflush_object(struct drm_gem_object *obj)
2751 2741
2752/** Flushes any GPU write domain for the object if it's dirty. */ 2742/** Flushes any GPU write domain for the object if it's dirty. */
2753static int 2743static int
2754i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj, 2744i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj)
2755 bool pipelined)
2756{ 2745{
2757 struct drm_device *dev = obj->dev; 2746 struct drm_device *dev = obj->dev;
2758 uint32_t old_write_domain; 2747 uint32_t old_write_domain;
@@ -2771,10 +2760,7 @@ i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj,
2771 obj->read_domains, 2760 obj->read_domains,
2772 old_write_domain); 2761 old_write_domain);
2773 2762
2774 if (pipelined) 2763 return 0;
2775 return 0;
2776
2777 return i915_gem_object_wait_rendering(obj, true);
2778} 2764}
2779 2765
2780/** Flushes the GTT write domain for the object if it's dirty. */ 2766/** Flushes the GTT write domain for the object if it's dirty. */
@@ -2835,18 +2821,15 @@ i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int write)
2835 if (obj_priv->gtt_space == NULL) 2821 if (obj_priv->gtt_space == NULL)
2836 return -EINVAL; 2822 return -EINVAL;
2837 2823
2838 ret = i915_gem_object_flush_gpu_write_domain(obj, false); 2824 ret = i915_gem_object_flush_gpu_write_domain(obj);
2839 if (ret != 0) 2825 if (ret != 0)
2840 return ret; 2826 return ret;
2827 ret = i915_gem_object_wait_rendering(obj, true);
2828 if (ret)
2829 return ret;
2841 2830
2842 i915_gem_object_flush_cpu_write_domain(obj); 2831 i915_gem_object_flush_cpu_write_domain(obj);
2843 2832
2844 if (write) {
2845 ret = i915_gem_object_wait_rendering(obj, true);
2846 if (ret)
2847 return ret;
2848 }
2849
2850 old_write_domain = obj->write_domain; 2833 old_write_domain = obj->write_domain;
2851 old_read_domains = obj->read_domains; 2834 old_read_domains = obj->read_domains;
2852 2835
@@ -2884,7 +2867,7 @@ i915_gem_object_set_to_display_plane(struct drm_gem_object *obj,
2884 if (obj_priv->gtt_space == NULL) 2867 if (obj_priv->gtt_space == NULL)
2885 return -EINVAL; 2868 return -EINVAL;
2886 2869
2887 ret = i915_gem_object_flush_gpu_write_domain(obj, true); 2870 ret = i915_gem_object_flush_gpu_write_domain(obj);
2888 if (ret) 2871 if (ret)
2889 return ret; 2872 return ret;
2890 2873
@@ -2907,6 +2890,20 @@ i915_gem_object_set_to_display_plane(struct drm_gem_object *obj,
2907 return 0; 2890 return 0;
2908} 2891}
2909 2892
2893int
2894i915_gem_object_flush_gpu(struct drm_i915_gem_object *obj,
2895 bool interruptible)
2896{
2897 if (!obj->active)
2898 return 0;
2899
2900 if (obj->base.write_domain & I915_GEM_GPU_DOMAINS)
2901 i915_gem_flush_ring(obj->base.dev, NULL, obj->ring,
2902 0, obj->base.write_domain);
2903
2904 return i915_gem_object_wait_rendering(&obj->base, interruptible);
2905}
2906
2910/** 2907/**
2911 * Moves a single object to the CPU read, and possibly write domain. 2908 * Moves a single object to the CPU read, and possibly write domain.
2912 * 2909 *
@@ -2919,9 +2916,12 @@ i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write)
2919 uint32_t old_write_domain, old_read_domains; 2916 uint32_t old_write_domain, old_read_domains;
2920 int ret; 2917 int ret;
2921 2918
2922 ret = i915_gem_object_flush_gpu_write_domain(obj, false); 2919 ret = i915_gem_object_flush_gpu_write_domain(obj);
2923 if (ret != 0) 2920 if (ret != 0)
2924 return ret; 2921 return ret;
2922 ret = i915_gem_object_wait_rendering(obj, true);
2923 if (ret)
2924 return ret;
2925 2925
2926 i915_gem_object_flush_gtt_write_domain(obj); 2926 i915_gem_object_flush_gtt_write_domain(obj);
2927 2927
@@ -2930,12 +2930,6 @@ i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write)
2930 */ 2930 */
2931 i915_gem_object_set_to_full_cpu_read_domain(obj); 2931 i915_gem_object_set_to_full_cpu_read_domain(obj);
2932 2932
2933 if (write) {
2934 ret = i915_gem_object_wait_rendering(obj, true);
2935 if (ret)
2936 return ret;
2937 }
2938
2939 old_write_domain = obj->write_domain; 2933 old_write_domain = obj->write_domain;
2940 old_read_domains = obj->read_domains; 2934 old_read_domains = obj->read_domains;
2941 2935
@@ -3200,9 +3194,13 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
3200 if (offset == 0 && size == obj->size) 3194 if (offset == 0 && size == obj->size)
3201 return i915_gem_object_set_to_cpu_domain(obj, 0); 3195 return i915_gem_object_set_to_cpu_domain(obj, 0);
3202 3196
3203 ret = i915_gem_object_flush_gpu_write_domain(obj, false); 3197 ret = i915_gem_object_flush_gpu_write_domain(obj);
3204 if (ret != 0) 3198 if (ret != 0)
3205 return ret; 3199 return ret;
3200 ret = i915_gem_object_wait_rendering(obj, true);
3201 if (ret)
3202 return ret;
3203
3206 i915_gem_object_flush_gtt_write_domain(obj); 3204 i915_gem_object_flush_gtt_write_domain(obj);
3207 3205
3208 /* If we're already fully in the CPU read domain, we're done. */ 3206 /* If we're already fully in the CPU read domain, we're done. */
@@ -3249,192 +3247,230 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
3249 return 0; 3247 return 0;
3250} 3248}
3251 3249
3252/**
3253 * Pin an object to the GTT and evaluate the relocations landing in it.
3254 */
3255static int 3250static int
3256i915_gem_execbuffer_relocate(struct drm_i915_gem_object *obj, 3251i915_gem_execbuffer_relocate_entry(struct drm_i915_gem_object *obj,
3257 struct drm_file *file_priv, 3252 struct drm_file *file_priv,
3258 struct drm_i915_gem_exec_object2 *entry) 3253 struct drm_i915_gem_exec_object2 *entry,
3254 struct drm_i915_gem_relocation_entry *reloc)
3259{ 3255{
3260 struct drm_device *dev = obj->base.dev; 3256 struct drm_device *dev = obj->base.dev;
3261 drm_i915_private_t *dev_priv = dev->dev_private; 3257 struct drm_gem_object *target_obj;
3262 struct drm_i915_gem_relocation_entry __user *user_relocs; 3258 uint32_t target_offset;
3263 struct drm_gem_object *target_obj = NULL; 3259 int ret = -EINVAL;
3264 uint32_t target_handle = 0;
3265 int i, ret = 0;
3266 3260
3267 user_relocs = (void __user *)(uintptr_t)entry->relocs_ptr; 3261 target_obj = drm_gem_object_lookup(dev, file_priv,
3268 for (i = 0; i < entry->relocation_count; i++) { 3262 reloc->target_handle);
3269 struct drm_i915_gem_relocation_entry reloc; 3263 if (target_obj == NULL)
3270 uint32_t target_offset; 3264 return -ENOENT;
3271 3265
3272 if (__copy_from_user_inatomic(&reloc, 3266 target_offset = to_intel_bo(target_obj)->gtt_offset;
3273 user_relocs+i,
3274 sizeof(reloc))) {
3275 ret = -EFAULT;
3276 break;
3277 }
3278 3267
3279 if (reloc.target_handle != target_handle) { 3268#if WATCH_RELOC
3280 drm_gem_object_unreference(target_obj); 3269 DRM_INFO("%s: obj %p offset %08x target %d "
3270 "read %08x write %08x gtt %08x "
3271 "presumed %08x delta %08x\n",
3272 __func__,
3273 obj,
3274 (int) reloc->offset,
3275 (int) reloc->target_handle,
3276 (int) reloc->read_domains,
3277 (int) reloc->write_domain,
3278 (int) target_offset,
3279 (int) reloc->presumed_offset,
3280 reloc->delta);
3281#endif
3281 3282
3282 target_obj = drm_gem_object_lookup(dev, file_priv, 3283 /* The target buffer should have appeared before us in the
3283 reloc.target_handle); 3284 * exec_object list, so it should have a GTT space bound by now.
3284 if (target_obj == NULL) { 3285 */
3285 ret = -ENOENT; 3286 if (target_offset == 0) {
3286 break; 3287 DRM_ERROR("No GTT space found for object %d\n",
3287 } 3288 reloc->target_handle);
3289 goto err;
3290 }
3288 3291
3289 target_handle = reloc.target_handle; 3292 /* Validate that the target is in a valid r/w GPU domain */
3290 } 3293 if (reloc->write_domain & (reloc->write_domain - 1)) {
3291 target_offset = to_intel_bo(target_obj)->gtt_offset; 3294 DRM_ERROR("reloc with multiple write domains: "
3295 "obj %p target %d offset %d "
3296 "read %08x write %08x",
3297 obj, reloc->target_handle,
3298 (int) reloc->offset,
3299 reloc->read_domains,
3300 reloc->write_domain);
3301 goto err;
3302 }
3303 if (reloc->write_domain & I915_GEM_DOMAIN_CPU ||
3304 reloc->read_domains & I915_GEM_DOMAIN_CPU) {
3305 DRM_ERROR("reloc with read/write CPU domains: "
3306 "obj %p target %d offset %d "
3307 "read %08x write %08x",
3308 obj, reloc->target_handle,
3309 (int) reloc->offset,
3310 reloc->read_domains,
3311 reloc->write_domain);
3312 goto err;
3313 }
3314 if (reloc->write_domain && target_obj->pending_write_domain &&
3315 reloc->write_domain != target_obj->pending_write_domain) {
3316 DRM_ERROR("Write domain conflict: "
3317 "obj %p target %d offset %d "
3318 "new %08x old %08x\n",
3319 obj, reloc->target_handle,
3320 (int) reloc->offset,
3321 reloc->write_domain,
3322 target_obj->pending_write_domain);
3323 goto err;
3324 }
3292 3325
3293#if WATCH_RELOC 3326 target_obj->pending_read_domains |= reloc->read_domains;
3294 DRM_INFO("%s: obj %p offset %08x target %d " 3327 target_obj->pending_write_domain |= reloc->write_domain;
3295 "read %08x write %08x gtt %08x "
3296 "presumed %08x delta %08x\n",
3297 __func__,
3298 obj,
3299 (int) reloc.offset,
3300 (int) reloc.target_handle,
3301 (int) reloc.read_domains,
3302 (int) reloc.write_domain,
3303 (int) target_offset,
3304 (int) reloc.presumed_offset,
3305 reloc.delta);
3306#endif
3307 3328
3308 /* The target buffer should have appeared before us in the 3329 /* If the relocation already has the right value in it, no
3309 * exec_object list, so it should have a GTT space bound by now. 3330 * more work needs to be done.
3310 */ 3331 */
3311 if (target_offset == 0) { 3332 if (target_offset == reloc->presumed_offset)
3312 DRM_ERROR("No GTT space found for object %d\n", 3333 goto out;
3313 reloc.target_handle);
3314 ret = -EINVAL;
3315 break;
3316 }
3317 3334
3318 /* Validate that the target is in a valid r/w GPU domain */ 3335 /* Check that the relocation address is valid... */
3319 if (reloc.write_domain & (reloc.write_domain - 1)) { 3336 if (reloc->offset > obj->base.size - 4) {
3320 DRM_ERROR("reloc with multiple write domains: " 3337 DRM_ERROR("Relocation beyond object bounds: "
3321 "obj %p target %d offset %d " 3338 "obj %p target %d offset %d size %d.\n",
3322 "read %08x write %08x", 3339 obj, reloc->target_handle,
3323 obj, reloc.target_handle, 3340 (int) reloc->offset,
3324 (int) reloc.offset, 3341 (int) obj->base.size);
3325 reloc.read_domains, 3342 goto err;
3326 reloc.write_domain); 3343 }
3327 ret = -EINVAL; 3344 if (reloc->offset & 3) {
3328 break; 3345 DRM_ERROR("Relocation not 4-byte aligned: "
3329 } 3346 "obj %p target %d offset %d.\n",
3330 if (reloc.write_domain & I915_GEM_DOMAIN_CPU || 3347 obj, reloc->target_handle,
3331 reloc.read_domains & I915_GEM_DOMAIN_CPU) { 3348 (int) reloc->offset);
3332 DRM_ERROR("reloc with read/write CPU domains: " 3349 goto err;
3333 "obj %p target %d offset %d " 3350 }
3334 "read %08x write %08x",
3335 obj, reloc.target_handle,
3336 (int) reloc.offset,
3337 reloc.read_domains,
3338 reloc.write_domain);
3339 ret = -EINVAL;
3340 break;
3341 }
3342 if (reloc.write_domain && target_obj->pending_write_domain &&
3343 reloc.write_domain != target_obj->pending_write_domain) {
3344 DRM_ERROR("Write domain conflict: "
3345 "obj %p target %d offset %d "
3346 "new %08x old %08x\n",
3347 obj, reloc.target_handle,
3348 (int) reloc.offset,
3349 reloc.write_domain,
3350 target_obj->pending_write_domain);
3351 ret = -EINVAL;
3352 break;
3353 }
3354 3351
3355 target_obj->pending_read_domains |= reloc.read_domains; 3352 /* and points to somewhere within the target object. */
3356 target_obj->pending_write_domain |= reloc.write_domain; 3353 if (reloc->delta >= target_obj->size) {
3354 DRM_ERROR("Relocation beyond target object bounds: "
3355 "obj %p target %d delta %d size %d.\n",
3356 obj, reloc->target_handle,
3357 (int) reloc->delta,
3358 (int) target_obj->size);
3359 goto err;
3360 }
3357 3361
3358 /* If the relocation already has the right value in it, no 3362 reloc->delta += target_offset;
3359 * more work needs to be done. 3363 if (obj->base.write_domain == I915_GEM_DOMAIN_CPU) {
3360 */ 3364 uint32_t page_offset = reloc->offset & ~PAGE_MASK;
3361 if (target_offset == reloc.presumed_offset) 3365 char *vaddr;
3362 continue;
3363 3366
3364 /* Check that the relocation address is valid... */ 3367 vaddr = kmap_atomic(obj->pages[reloc->offset >> PAGE_SHIFT]);
3365 if (reloc.offset > obj->base.size - 4) { 3368 *(uint32_t *)(vaddr + page_offset) = reloc->delta;
3366 DRM_ERROR("Relocation beyond object bounds: " 3369 kunmap_atomic(vaddr);
3367 "obj %p target %d offset %d size %d.\n", 3370 } else {
3368 obj, reloc.target_handle, 3371 struct drm_i915_private *dev_priv = dev->dev_private;
3369 (int) reloc.offset, (int) obj->base.size); 3372 uint32_t __iomem *reloc_entry;
3370 ret = -EINVAL; 3373 void __iomem *reloc_page;
3371 break;
3372 }
3373 if (reloc.offset & 3) {
3374 DRM_ERROR("Relocation not 4-byte aligned: "
3375 "obj %p target %d offset %d.\n",
3376 obj, reloc.target_handle,
3377 (int) reloc.offset);
3378 ret = -EINVAL;
3379 break;
3380 }
3381 3374
3382 /* and points to somewhere within the target object. */ 3375 ret = i915_gem_object_set_to_gtt_domain(&obj->base, 1);
3383 if (reloc.delta >= target_obj->size) { 3376 if (ret)
3384 DRM_ERROR("Relocation beyond target object bounds: " 3377 goto err;
3385 "obj %p target %d delta %d size %d.\n",
3386 obj, reloc.target_handle,
3387 (int) reloc.delta, (int) target_obj->size);
3388 ret = -EINVAL;
3389 break;
3390 }
3391 3378
3392 reloc.delta += target_offset; 3379 /* Map the page containing the relocation we're going to perform. */
3393 if (obj->base.write_domain == I915_GEM_DOMAIN_CPU) { 3380 reloc->offset += obj->gtt_offset;
3394 uint32_t page_offset = reloc.offset & ~PAGE_MASK; 3381 reloc_page = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,
3395 char *vaddr; 3382 reloc->offset & PAGE_MASK);
3383 reloc_entry = (uint32_t __iomem *)
3384 (reloc_page + (reloc->offset & ~PAGE_MASK));
3385 iowrite32(reloc->delta, reloc_entry);
3386 io_mapping_unmap_atomic(reloc_page);
3387 }
3396 3388
3397 vaddr = kmap_atomic(obj->pages[reloc.offset >> PAGE_SHIFT]); 3389 /* and update the user's relocation entry */
3398 *(uint32_t *)(vaddr + page_offset) = reloc.delta; 3390 reloc->presumed_offset = target_offset;
3399 kunmap_atomic(vaddr);
3400 } else {
3401 uint32_t __iomem *reloc_entry;
3402 void __iomem *reloc_page;
3403 3391
3404 ret = i915_gem_object_set_to_gtt_domain(&obj->base, 1); 3392out:
3405 if (ret) 3393 ret = 0;
3406 break; 3394err:
3395 drm_gem_object_unreference(target_obj);
3396 return ret;
3397}
3407 3398
3408 /* Map the page containing the relocation we're going to perform. */ 3399static int
3409 reloc.offset += obj->gtt_offset; 3400i915_gem_execbuffer_relocate_object(struct drm_i915_gem_object *obj,
3410 reloc_page = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping, 3401 struct drm_file *file_priv,
3411 reloc.offset & PAGE_MASK); 3402 struct drm_i915_gem_exec_object2 *entry)
3412 reloc_entry = (uint32_t __iomem *) 3403{
3413 (reloc_page + (reloc.offset & ~PAGE_MASK)); 3404 struct drm_i915_gem_relocation_entry __user *user_relocs;
3414 iowrite32(reloc.delta, reloc_entry); 3405 int i, ret;
3415 io_mapping_unmap_atomic(reloc_page); 3406
3416 } 3407 user_relocs = (void __user *)(uintptr_t)entry->relocs_ptr;
3408 for (i = 0; i < entry->relocation_count; i++) {
3409 struct drm_i915_gem_relocation_entry reloc;
3410
3411 if (__copy_from_user_inatomic(&reloc,
3412 user_relocs+i,
3413 sizeof(reloc)))
3414 return -EFAULT;
3415
3416 ret = i915_gem_execbuffer_relocate_entry(obj, file_priv, entry, &reloc);
3417 if (ret)
3418 return ret;
3417 3419
3418 /* and update the user's relocation entry */
3419 reloc.presumed_offset = target_offset;
3420 if (__copy_to_user_inatomic(&user_relocs[i].presumed_offset, 3420 if (__copy_to_user_inatomic(&user_relocs[i].presumed_offset,
3421 &reloc.presumed_offset, 3421 &reloc.presumed_offset,
3422 sizeof(reloc.presumed_offset))) { 3422 sizeof(reloc.presumed_offset)))
3423 ret = -EFAULT; 3423 return -EFAULT;
3424 break;
3425 }
3426 } 3424 }
3427 3425
3428 drm_gem_object_unreference(target_obj); 3426 return 0;
3429 return ret;
3430} 3427}
3431 3428
3432static int 3429static int
3433i915_gem_execbuffer_pin(struct drm_device *dev, 3430i915_gem_execbuffer_relocate_object_slow(struct drm_i915_gem_object *obj,
3434 struct drm_file *file, 3431 struct drm_file *file_priv,
3435 struct drm_gem_object **object_list, 3432 struct drm_i915_gem_exec_object2 *entry,
3436 struct drm_i915_gem_exec_object2 *exec_list, 3433 struct drm_i915_gem_relocation_entry *relocs)
3437 int count) 3434{
3435 int i, ret;
3436
3437 for (i = 0; i < entry->relocation_count; i++) {
3438 ret = i915_gem_execbuffer_relocate_entry(obj, file_priv, entry, &relocs[i]);
3439 if (ret)
3440 return ret;
3441 }
3442
3443 return 0;
3444}
3445
3446static int
3447i915_gem_execbuffer_relocate(struct drm_device *dev,
3448 struct drm_file *file,
3449 struct drm_gem_object **object_list,
3450 struct drm_i915_gem_exec_object2 *exec_list,
3451 int count)
3452{
3453 int i, ret;
3454
3455 for (i = 0; i < count; i++) {
3456 struct drm_i915_gem_object *obj = to_intel_bo(object_list[i]);
3457 obj->base.pending_read_domains = 0;
3458 obj->base.pending_write_domain = 0;
3459 ret = i915_gem_execbuffer_relocate_object(obj, file,
3460 &exec_list[i]);
3461 if (ret)
3462 return ret;
3463 }
3464
3465 return 0;
3466}
3467
3468static int
3469i915_gem_execbuffer_reserve(struct drm_device *dev,
3470 struct drm_file *file,
3471 struct drm_gem_object **object_list,
3472 struct drm_i915_gem_exec_object2 *exec_list,
3473 int count)
3438{ 3474{
3439 struct drm_i915_private *dev_priv = dev->dev_private; 3475 struct drm_i915_private *dev_priv = dev->dev_private;
3440 int ret, i, retry; 3476 int ret, i, retry;
@@ -3497,6 +3533,87 @@ i915_gem_execbuffer_pin(struct drm_device *dev,
3497} 3533}
3498 3534
3499static int 3535static int
3536i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
3537 struct drm_file *file,
3538 struct drm_gem_object **object_list,
3539 struct drm_i915_gem_exec_object2 *exec_list,
3540 int count)
3541{
3542 struct drm_i915_gem_relocation_entry *reloc;
3543 int i, total, ret;
3544
3545 for (i = 0; i < count; i++) {
3546 struct drm_i915_gem_object *obj = to_intel_bo(object_list[i]);
3547 obj->in_execbuffer = false;
3548 }
3549
3550 mutex_unlock(&dev->struct_mutex);
3551
3552 total = 0;
3553 for (i = 0; i < count; i++)
3554 total += exec_list[i].relocation_count;
3555
3556 reloc = drm_malloc_ab(total, sizeof(*reloc));
3557 if (reloc == NULL) {
3558 mutex_lock(&dev->struct_mutex);
3559 return -ENOMEM;
3560 }
3561
3562 total = 0;
3563 for (i = 0; i < count; i++) {
3564 struct drm_i915_gem_relocation_entry __user *user_relocs;
3565
3566 user_relocs = (void __user *)(uintptr_t)exec_list[i].relocs_ptr;
3567
3568 if (copy_from_user(reloc+total, user_relocs,
3569 exec_list[i].relocation_count *
3570 sizeof(*reloc))) {
3571 ret = -EFAULT;
3572 mutex_lock(&dev->struct_mutex);
3573 goto err;
3574 }
3575
3576 total += exec_list[i].relocation_count;
3577 }
3578
3579 ret = i915_mutex_lock_interruptible(dev);
3580 if (ret) {
3581 mutex_lock(&dev->struct_mutex);
3582 goto err;
3583 }
3584
3585 ret = i915_gem_execbuffer_reserve(dev, file,
3586 object_list, exec_list,
3587 count);
3588 if (ret)
3589 goto err;
3590
3591 total = 0;
3592 for (i = 0; i < count; i++) {
3593 struct drm_i915_gem_object *obj = to_intel_bo(object_list[i]);
3594 obj->base.pending_read_domains = 0;
3595 obj->base.pending_write_domain = 0;
3596 ret = i915_gem_execbuffer_relocate_object_slow(obj, file,
3597 &exec_list[i],
3598 reloc + total);
3599 if (ret)
3600 goto err;
3601
3602 total += exec_list[i].relocation_count;
3603 }
3604
3605 /* Leave the user relocations as are, this is the painfully slow path,
3606 * and we want to avoid the complication of dropping the lock whilst
3607 * having buffers reserved in the aperture and so causing spurious
3608 * ENOSPC for random operations.
3609 */
3610
3611err:
3612 drm_free_large(reloc);
3613 return ret;
3614}
3615
3616static int
3500i915_gem_execbuffer_move_to_gpu(struct drm_device *dev, 3617i915_gem_execbuffer_move_to_gpu(struct drm_device *dev,
3501 struct drm_file *file, 3618 struct drm_file *file,
3502 struct intel_ring_buffer *ring, 3619 struct intel_ring_buffer *ring,
@@ -3625,8 +3742,15 @@ validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
3625 3742
3626 for (i = 0; i < count; i++) { 3743 for (i = 0; i < count; i++) {
3627 char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr; 3744 char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr;
3628 size_t length = exec[i].relocation_count * sizeof(struct drm_i915_gem_relocation_entry); 3745 int length; /* limited by fault_in_pages_readable() */
3746
3747 /* First check for malicious input causing overflow */
3748 if (exec[i].relocation_count >
3749 INT_MAX / sizeof(struct drm_i915_gem_relocation_entry))
3750 return -EINVAL;
3629 3751
3752 length = exec[i].relocation_count *
3753 sizeof(struct drm_i915_gem_relocation_entry);
3630 if (!access_ok(VERIFY_READ, ptr, length)) 3754 if (!access_ok(VERIFY_READ, ptr, length))
3631 return -EFAULT; 3755 return -EFAULT;
3632 3756
@@ -3769,18 +3893,24 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
3769 } 3893 }
3770 3894
3771 /* Move the objects en-masse into the GTT, evicting if necessary. */ 3895 /* Move the objects en-masse into the GTT, evicting if necessary. */
3772 ret = i915_gem_execbuffer_pin(dev, file, 3896 ret = i915_gem_execbuffer_reserve(dev, file,
3773 object_list, exec_list, 3897 object_list, exec_list,
3774 args->buffer_count); 3898 args->buffer_count);
3775 if (ret) 3899 if (ret)
3776 goto err; 3900 goto err;
3777 3901
3778 /* The objects are in their final locations, apply the relocations. */ 3902 /* The objects are in their final locations, apply the relocations. */
3779 for (i = 0; i < args->buffer_count; i++) { 3903 ret = i915_gem_execbuffer_relocate(dev, file,
3780 struct drm_i915_gem_object *obj = to_intel_bo(object_list[i]); 3904 object_list, exec_list,
3781 obj->base.pending_read_domains = 0; 3905 args->buffer_count);
3782 obj->base.pending_write_domain = 0; 3906 if (ret) {
3783 ret = i915_gem_execbuffer_relocate(obj, file, &exec_list[i]); 3907 if (ret == -EFAULT) {
3908 ret = i915_gem_execbuffer_relocate_slow(dev, file,
3909 object_list,
3910 exec_list,
3911 args->buffer_count);
3912 BUG_ON(!mutex_is_locked(&dev->struct_mutex));
3913 }
3784 if (ret) 3914 if (ret)
3785 goto err; 3915 goto err;
3786 } 3916 }
@@ -4244,10 +4374,20 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
4244 * use this buffer rather sooner than later, so issuing the required 4374 * use this buffer rather sooner than later, so issuing the required
4245 * flush earlier is beneficial. 4375 * flush earlier is beneficial.
4246 */ 4376 */
4247 if (obj->write_domain & I915_GEM_GPU_DOMAINS) 4377 if (obj->write_domain & I915_GEM_GPU_DOMAINS) {
4248 i915_gem_flush_ring(dev, file_priv, 4378 i915_gem_flush_ring(dev, file_priv,
4249 obj_priv->ring, 4379 obj_priv->ring,
4250 0, obj->write_domain); 4380 0, obj->write_domain);
4381 } else if (obj_priv->ring->outstanding_lazy_request) {
4382 /* This ring is not being cleared by active usage,
4383 * so emit a request to do so.
4384 */
4385 u32 seqno = i915_add_request(dev,
4386 NULL, NULL,
4387 obj_priv->ring);
4388 if (seqno == 0)
4389 ret = -ENOMEM;
4390 }
4251 4391
4252 /* Update the active list for the hardware's current position. 4392 /* Update the active list for the hardware's current position.
4253 * Otherwise this only updates on a delayed timer or when irqs 4393 * Otherwise this only updates on a delayed timer or when irqs
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 25ed911a3112..878fc766a12c 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3033,6 +3033,7 @@
3033#define TRANS_DP_10BPC (1<<9) 3033#define TRANS_DP_10BPC (1<<9)
3034#define TRANS_DP_6BPC (2<<9) 3034#define TRANS_DP_6BPC (2<<9)
3035#define TRANS_DP_12BPC (3<<9) 3035#define TRANS_DP_12BPC (3<<9)
3036#define TRANS_DP_BPC_MASK (3<<9)
3036#define TRANS_DP_VSYNC_ACTIVE_HIGH (1<<4) 3037#define TRANS_DP_VSYNC_ACTIVE_HIGH (1<<4)
3037#define TRANS_DP_VSYNC_ACTIVE_LOW 0 3038#define TRANS_DP_VSYNC_ACTIVE_LOW 0
3038#define TRANS_DP_HSYNC_ACTIVE_HIGH (1<<3) 3039#define TRANS_DP_HSYNC_ACTIVE_HIGH (1<<3)
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index 454c064f8ef7..42729d25da58 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -239,6 +239,16 @@ static void i915_save_modeset_reg(struct drm_device *dev)
239 if (drm_core_check_feature(dev, DRIVER_MODESET)) 239 if (drm_core_check_feature(dev, DRIVER_MODESET))
240 return; 240 return;
241 241
242 /* Cursor state */
243 dev_priv->saveCURACNTR = I915_READ(CURACNTR);
244 dev_priv->saveCURAPOS = I915_READ(CURAPOS);
245 dev_priv->saveCURABASE = I915_READ(CURABASE);
246 dev_priv->saveCURBCNTR = I915_READ(CURBCNTR);
247 dev_priv->saveCURBPOS = I915_READ(CURBPOS);
248 dev_priv->saveCURBBASE = I915_READ(CURBBASE);
249 if (IS_GEN2(dev))
250 dev_priv->saveCURSIZE = I915_READ(CURSIZE);
251
242 if (HAS_PCH_SPLIT(dev)) { 252 if (HAS_PCH_SPLIT(dev)) {
243 dev_priv->savePCH_DREF_CONTROL = I915_READ(PCH_DREF_CONTROL); 253 dev_priv->savePCH_DREF_CONTROL = I915_READ(PCH_DREF_CONTROL);
244 dev_priv->saveDISP_ARB_CTL = I915_READ(DISP_ARB_CTL); 254 dev_priv->saveDISP_ARB_CTL = I915_READ(DISP_ARB_CTL);
@@ -529,6 +539,16 @@ static void i915_restore_modeset_reg(struct drm_device *dev)
529 I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR); 539 I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR);
530 I915_WRITE(DSPBADDR, I915_READ(DSPBADDR)); 540 I915_WRITE(DSPBADDR, I915_READ(DSPBADDR));
531 541
542 /* Cursor state */
543 I915_WRITE(CURAPOS, dev_priv->saveCURAPOS);
544 I915_WRITE(CURACNTR, dev_priv->saveCURACNTR);
545 I915_WRITE(CURABASE, dev_priv->saveCURABASE);
546 I915_WRITE(CURBPOS, dev_priv->saveCURBPOS);
547 I915_WRITE(CURBCNTR, dev_priv->saveCURBCNTR);
548 I915_WRITE(CURBBASE, dev_priv->saveCURBBASE);
549 if (IS_GEN2(dev))
550 I915_WRITE(CURSIZE, dev_priv->saveCURSIZE);
551
532 return; 552 return;
533} 553}
534 554
@@ -543,16 +563,6 @@ void i915_save_display(struct drm_device *dev)
543 /* Don't save them in KMS mode */ 563 /* Don't save them in KMS mode */
544 i915_save_modeset_reg(dev); 564 i915_save_modeset_reg(dev);
545 565
546 /* Cursor state */
547 dev_priv->saveCURACNTR = I915_READ(CURACNTR);
548 dev_priv->saveCURAPOS = I915_READ(CURAPOS);
549 dev_priv->saveCURABASE = I915_READ(CURABASE);
550 dev_priv->saveCURBCNTR = I915_READ(CURBCNTR);
551 dev_priv->saveCURBPOS = I915_READ(CURBPOS);
552 dev_priv->saveCURBBASE = I915_READ(CURBBASE);
553 if (IS_GEN2(dev))
554 dev_priv->saveCURSIZE = I915_READ(CURSIZE);
555
556 /* CRT state */ 566 /* CRT state */
557 if (HAS_PCH_SPLIT(dev)) { 567 if (HAS_PCH_SPLIT(dev)) {
558 dev_priv->saveADPA = I915_READ(PCH_ADPA); 568 dev_priv->saveADPA = I915_READ(PCH_ADPA);
@@ -657,16 +667,6 @@ void i915_restore_display(struct drm_device *dev)
657 /* Don't restore them in KMS mode */ 667 /* Don't restore them in KMS mode */
658 i915_restore_modeset_reg(dev); 668 i915_restore_modeset_reg(dev);
659 669
660 /* Cursor state */
661 I915_WRITE(CURAPOS, dev_priv->saveCURAPOS);
662 I915_WRITE(CURACNTR, dev_priv->saveCURACNTR);
663 I915_WRITE(CURABASE, dev_priv->saveCURABASE);
664 I915_WRITE(CURBPOS, dev_priv->saveCURBPOS);
665 I915_WRITE(CURBCNTR, dev_priv->saveCURBCNTR);
666 I915_WRITE(CURBBASE, dev_priv->saveCURBBASE);
667 if (IS_GEN2(dev))
668 I915_WRITE(CURSIZE, dev_priv->saveCURSIZE);
669
670 /* CRT state */ 670 /* CRT state */
671 if (HAS_PCH_SPLIT(dev)) 671 if (HAS_PCH_SPLIT(dev))
672 I915_WRITE(PCH_ADPA, dev_priv->saveADPA); 672 I915_WRITE(PCH_ADPA, dev_priv->saveADPA);
diff --git a/drivers/gpu/drm/i915/intel_acpi.c b/drivers/gpu/drm/i915/intel_acpi.c
index 65c88f9ba12c..2cb8e0b9f1ee 100644
--- a/drivers/gpu/drm/i915/intel_acpi.c
+++ b/drivers/gpu/drm/i915/intel_acpi.c
@@ -190,37 +190,6 @@ out:
190 kfree(output.pointer); 190 kfree(output.pointer);
191} 191}
192 192
193static int intel_dsm_switchto(enum vga_switcheroo_client_id id)
194{
195 return 0;
196}
197
198static int intel_dsm_power_state(enum vga_switcheroo_client_id id,
199 enum vga_switcheroo_state state)
200{
201 return 0;
202}
203
204static int intel_dsm_init(void)
205{
206 return 0;
207}
208
209static int intel_dsm_get_client_id(struct pci_dev *pdev)
210{
211 if (intel_dsm_priv.dhandle == DEVICE_ACPI_HANDLE(&pdev->dev))
212 return VGA_SWITCHEROO_IGD;
213 else
214 return VGA_SWITCHEROO_DIS;
215}
216
217static struct vga_switcheroo_handler intel_dsm_handler = {
218 .switchto = intel_dsm_switchto,
219 .power_state = intel_dsm_power_state,
220 .init = intel_dsm_init,
221 .get_client_id = intel_dsm_get_client_id,
222};
223
224static bool intel_dsm_pci_probe(struct pci_dev *pdev) 193static bool intel_dsm_pci_probe(struct pci_dev *pdev)
225{ 194{
226 acpi_handle dhandle, intel_handle; 195 acpi_handle dhandle, intel_handle;
@@ -276,11 +245,8 @@ void intel_register_dsm_handler(void)
276{ 245{
277 if (!intel_dsm_detect()) 246 if (!intel_dsm_detect())
278 return; 247 return;
279
280 vga_switcheroo_register_handler(&intel_dsm_handler);
281} 248}
282 249
283void intel_unregister_dsm_handler(void) 250void intel_unregister_dsm_handler(void)
284{ 251{
285 vga_switcheroo_unregister_handler();
286} 252}
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index c55c77043357..8df574316063 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -34,6 +34,25 @@
34#include "i915_drm.h" 34#include "i915_drm.h"
35#include "i915_drv.h" 35#include "i915_drv.h"
36 36
37/* Here's the desired hotplug mode */
38#define ADPA_HOTPLUG_BITS (ADPA_CRT_HOTPLUG_PERIOD_128 | \
39 ADPA_CRT_HOTPLUG_WARMUP_10MS | \
40 ADPA_CRT_HOTPLUG_SAMPLE_4S | \
41 ADPA_CRT_HOTPLUG_VOLTAGE_50 | \
42 ADPA_CRT_HOTPLUG_VOLREF_325MV | \
43 ADPA_CRT_HOTPLUG_ENABLE)
44
45struct intel_crt {
46 struct intel_encoder base;
47 bool force_hotplug_required;
48};
49
50static struct intel_crt *intel_attached_crt(struct drm_connector *connector)
51{
52 return container_of(intel_attached_encoder(connector),
53 struct intel_crt, base);
54}
55
37static void intel_crt_dpms(struct drm_encoder *encoder, int mode) 56static void intel_crt_dpms(struct drm_encoder *encoder, int mode)
38{ 57{
39 struct drm_device *dev = encoder->dev; 58 struct drm_device *dev = encoder->dev;
@@ -129,7 +148,7 @@ static void intel_crt_mode_set(struct drm_encoder *encoder,
129 dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK); 148 dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK);
130 } 149 }
131 150
132 adpa = 0; 151 adpa = ADPA_HOTPLUG_BITS;
133 if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) 152 if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
134 adpa |= ADPA_HSYNC_ACTIVE_HIGH; 153 adpa |= ADPA_HSYNC_ACTIVE_HIGH;
135 if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) 154 if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
@@ -157,53 +176,44 @@ static void intel_crt_mode_set(struct drm_encoder *encoder,
157static bool intel_ironlake_crt_detect_hotplug(struct drm_connector *connector) 176static bool intel_ironlake_crt_detect_hotplug(struct drm_connector *connector)
158{ 177{
159 struct drm_device *dev = connector->dev; 178 struct drm_device *dev = connector->dev;
179 struct intel_crt *crt = intel_attached_crt(connector);
160 struct drm_i915_private *dev_priv = dev->dev_private; 180 struct drm_i915_private *dev_priv = dev->dev_private;
161 u32 adpa, temp; 181 u32 adpa;
162 bool ret; 182 bool ret;
163 bool turn_off_dac = false;
164 183
165 temp = adpa = I915_READ(PCH_ADPA); 184 /* The first time through, trigger an explicit detection cycle */
185 if (crt->force_hotplug_required) {
186 bool turn_off_dac = HAS_PCH_SPLIT(dev);
187 u32 save_adpa;
166 188
167 if (HAS_PCH_SPLIT(dev)) 189 crt->force_hotplug_required = 0;
168 turn_off_dac = true; 190
169 191 save_adpa = adpa = I915_READ(PCH_ADPA);
170 adpa &= ~ADPA_CRT_HOTPLUG_MASK; 192 DRM_DEBUG_KMS("trigger hotplug detect cycle: adpa=0x%x\n", adpa);
171 if (turn_off_dac) 193
172 adpa &= ~ADPA_DAC_ENABLE; 194 adpa |= ADPA_CRT_HOTPLUG_FORCE_TRIGGER;
173 195 if (turn_off_dac)
174 /* disable HPD first */ 196 adpa &= ~ADPA_DAC_ENABLE;
175 I915_WRITE(PCH_ADPA, adpa); 197
176 (void)I915_READ(PCH_ADPA); 198 I915_WRITE(PCH_ADPA, adpa);
177 199
178 adpa |= (ADPA_CRT_HOTPLUG_PERIOD_128 | 200 if (wait_for((I915_READ(PCH_ADPA) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) == 0,
179 ADPA_CRT_HOTPLUG_WARMUP_10MS | 201 1000))
180 ADPA_CRT_HOTPLUG_SAMPLE_4S | 202 DRM_DEBUG_KMS("timed out waiting for FORCE_TRIGGER");
181 ADPA_CRT_HOTPLUG_VOLTAGE_50 | /* default */ 203
182 ADPA_CRT_HOTPLUG_VOLREF_325MV | 204 if (turn_off_dac) {
183 ADPA_CRT_HOTPLUG_ENABLE | 205 I915_WRITE(PCH_ADPA, save_adpa);
184 ADPA_CRT_HOTPLUG_FORCE_TRIGGER); 206 POSTING_READ(PCH_ADPA);
185 207 }
186 DRM_DEBUG_KMS("pch crt adpa 0x%x", adpa);
187 I915_WRITE(PCH_ADPA, adpa);
188
189 if (wait_for((I915_READ(PCH_ADPA) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) == 0,
190 1000))
191 DRM_DEBUG_KMS("timed out waiting for FORCE_TRIGGER");
192
193 if (turn_off_dac) {
194 /* Make sure hotplug is enabled */
195 I915_WRITE(PCH_ADPA, temp | ADPA_CRT_HOTPLUG_ENABLE);
196 (void)I915_READ(PCH_ADPA);
197 } 208 }
198 209
199 /* Check the status to see if both blue and green are on now */ 210 /* Check the status to see if both blue and green are on now */
200 adpa = I915_READ(PCH_ADPA); 211 adpa = I915_READ(PCH_ADPA);
201 adpa &= ADPA_CRT_HOTPLUG_MONITOR_MASK; 212 if ((adpa & ADPA_CRT_HOTPLUG_MONITOR_MASK) != 0)
202 if ((adpa == ADPA_CRT_HOTPLUG_MONITOR_COLOR) ||
203 (adpa == ADPA_CRT_HOTPLUG_MONITOR_MONO))
204 ret = true; 213 ret = true;
205 else 214 else
206 ret = false; 215 ret = false;
216 DRM_DEBUG_KMS("ironlake hotplug adpa=0x%x, result %d\n", adpa, ret);
207 217
208 return ret; 218 return ret;
209} 219}
@@ -277,13 +287,12 @@ static bool intel_crt_ddc_probe(struct drm_i915_private *dev_priv, int ddc_bus)
277 return i2c_transfer(&dev_priv->gmbus[ddc_bus].adapter, msgs, 1) == 1; 287 return i2c_transfer(&dev_priv->gmbus[ddc_bus].adapter, msgs, 1) == 1;
278} 288}
279 289
280static bool intel_crt_detect_ddc(struct drm_encoder *encoder) 290static bool intel_crt_detect_ddc(struct intel_crt *crt)
281{ 291{
282 struct intel_encoder *intel_encoder = to_intel_encoder(encoder); 292 struct drm_i915_private *dev_priv = crt->base.base.dev->dev_private;
283 struct drm_i915_private *dev_priv = encoder->dev->dev_private;
284 293
285 /* CRT should always be at 0, but check anyway */ 294 /* CRT should always be at 0, but check anyway */
286 if (intel_encoder->type != INTEL_OUTPUT_ANALOG) 295 if (crt->base.type != INTEL_OUTPUT_ANALOG)
287 return false; 296 return false;
288 297
289 if (intel_crt_ddc_probe(dev_priv, dev_priv->crt_ddc_pin)) { 298 if (intel_crt_ddc_probe(dev_priv, dev_priv->crt_ddc_pin)) {
@@ -291,7 +300,7 @@ static bool intel_crt_detect_ddc(struct drm_encoder *encoder)
291 return true; 300 return true;
292 } 301 }
293 302
294 if (intel_ddc_probe(intel_encoder, dev_priv->crt_ddc_pin)) { 303 if (intel_ddc_probe(&crt->base, dev_priv->crt_ddc_pin)) {
295 DRM_DEBUG_KMS("CRT detected via DDC:0x50 [EDID]\n"); 304 DRM_DEBUG_KMS("CRT detected via DDC:0x50 [EDID]\n");
296 return true; 305 return true;
297 } 306 }
@@ -300,9 +309,9 @@ static bool intel_crt_detect_ddc(struct drm_encoder *encoder)
300} 309}
301 310
302static enum drm_connector_status 311static enum drm_connector_status
303intel_crt_load_detect(struct drm_crtc *crtc, struct intel_encoder *intel_encoder) 312intel_crt_load_detect(struct drm_crtc *crtc, struct intel_crt *crt)
304{ 313{
305 struct drm_encoder *encoder = &intel_encoder->base; 314 struct drm_encoder *encoder = &crt->base.base;
306 struct drm_device *dev = encoder->dev; 315 struct drm_device *dev = encoder->dev;
307 struct drm_i915_private *dev_priv = dev->dev_private; 316 struct drm_i915_private *dev_priv = dev->dev_private;
308 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 317 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
@@ -434,7 +443,7 @@ static enum drm_connector_status
434intel_crt_detect(struct drm_connector *connector, bool force) 443intel_crt_detect(struct drm_connector *connector, bool force)
435{ 444{
436 struct drm_device *dev = connector->dev; 445 struct drm_device *dev = connector->dev;
437 struct intel_encoder *encoder = intel_attached_encoder(connector); 446 struct intel_crt *crt = intel_attached_crt(connector);
438 struct drm_crtc *crtc; 447 struct drm_crtc *crtc;
439 int dpms_mode; 448 int dpms_mode;
440 enum drm_connector_status status; 449 enum drm_connector_status status;
@@ -443,28 +452,31 @@ intel_crt_detect(struct drm_connector *connector, bool force)
443 if (intel_crt_detect_hotplug(connector)) { 452 if (intel_crt_detect_hotplug(connector)) {
444 DRM_DEBUG_KMS("CRT detected via hotplug\n"); 453 DRM_DEBUG_KMS("CRT detected via hotplug\n");
445 return connector_status_connected; 454 return connector_status_connected;
446 } else 455 } else {
456 DRM_DEBUG_KMS("CRT not detected via hotplug\n");
447 return connector_status_disconnected; 457 return connector_status_disconnected;
458 }
448 } 459 }
449 460
450 if (intel_crt_detect_ddc(&encoder->base)) 461 if (intel_crt_detect_ddc(crt))
451 return connector_status_connected; 462 return connector_status_connected;
452 463
453 if (!force) 464 if (!force)
454 return connector->status; 465 return connector->status;
455 466
456 /* for pre-945g platforms use load detect */ 467 /* for pre-945g platforms use load detect */
457 if (encoder->base.crtc && encoder->base.crtc->enabled) { 468 crtc = crt->base.base.crtc;
458 status = intel_crt_load_detect(encoder->base.crtc, encoder); 469 if (crtc && crtc->enabled) {
470 status = intel_crt_load_detect(crtc, crt);
459 } else { 471 } else {
460 crtc = intel_get_load_detect_pipe(encoder, connector, 472 crtc = intel_get_load_detect_pipe(&crt->base, connector,
461 NULL, &dpms_mode); 473 NULL, &dpms_mode);
462 if (crtc) { 474 if (crtc) {
463 if (intel_crt_detect_ddc(&encoder->base)) 475 if (intel_crt_detect_ddc(crt))
464 status = connector_status_connected; 476 status = connector_status_connected;
465 else 477 else
466 status = intel_crt_load_detect(crtc, encoder); 478 status = intel_crt_load_detect(crtc, crt);
467 intel_release_load_detect_pipe(encoder, 479 intel_release_load_detect_pipe(&crt->base,
468 connector, dpms_mode); 480 connector, dpms_mode);
469 } else 481 } else
470 status = connector_status_unknown; 482 status = connector_status_unknown;
@@ -536,17 +548,17 @@ static const struct drm_encoder_funcs intel_crt_enc_funcs = {
536void intel_crt_init(struct drm_device *dev) 548void intel_crt_init(struct drm_device *dev)
537{ 549{
538 struct drm_connector *connector; 550 struct drm_connector *connector;
539 struct intel_encoder *intel_encoder; 551 struct intel_crt *crt;
540 struct intel_connector *intel_connector; 552 struct intel_connector *intel_connector;
541 struct drm_i915_private *dev_priv = dev->dev_private; 553 struct drm_i915_private *dev_priv = dev->dev_private;
542 554
543 intel_encoder = kzalloc(sizeof(struct intel_encoder), GFP_KERNEL); 555 crt = kzalloc(sizeof(struct intel_crt), GFP_KERNEL);
544 if (!intel_encoder) 556 if (!crt)
545 return; 557 return;
546 558
547 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); 559 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
548 if (!intel_connector) { 560 if (!intel_connector) {
549 kfree(intel_encoder); 561 kfree(crt);
550 return; 562 return;
551 } 563 }
552 564
@@ -554,20 +566,20 @@ void intel_crt_init(struct drm_device *dev)
554 drm_connector_init(dev, &intel_connector->base, 566 drm_connector_init(dev, &intel_connector->base,
555 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); 567 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
556 568
557 drm_encoder_init(dev, &intel_encoder->base, &intel_crt_enc_funcs, 569 drm_encoder_init(dev, &crt->base.base, &intel_crt_enc_funcs,
558 DRM_MODE_ENCODER_DAC); 570 DRM_MODE_ENCODER_DAC);
559 571
560 intel_connector_attach_encoder(intel_connector, intel_encoder); 572 intel_connector_attach_encoder(intel_connector, &crt->base);
561 573
562 intel_encoder->type = INTEL_OUTPUT_ANALOG; 574 crt->base.type = INTEL_OUTPUT_ANALOG;
563 intel_encoder->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 575 crt->base.clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT |
564 (1 << INTEL_ANALOG_CLONE_BIT) | 576 1 << INTEL_ANALOG_CLONE_BIT |
565 (1 << INTEL_SDVO_LVDS_CLONE_BIT); 577 1 << INTEL_SDVO_LVDS_CLONE_BIT);
566 intel_encoder->crtc_mask = (1 << 0) | (1 << 1); 578 crt->base.crtc_mask = (1 << 0) | (1 << 1);
567 connector->interlace_allowed = 1; 579 connector->interlace_allowed = 1;
568 connector->doublescan_allowed = 0; 580 connector->doublescan_allowed = 0;
569 581
570 drm_encoder_helper_add(&intel_encoder->base, &intel_crt_helper_funcs); 582 drm_encoder_helper_add(&crt->base.base, &intel_crt_helper_funcs);
571 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); 583 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
572 584
573 drm_sysfs_connector_add(connector); 585 drm_sysfs_connector_add(connector);
@@ -577,5 +589,22 @@ void intel_crt_init(struct drm_device *dev)
577 else 589 else
578 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 590 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
579 591
592 /*
593 * Configure the automatic hotplug detection stuff
594 */
595 crt->force_hotplug_required = 0;
596 if (HAS_PCH_SPLIT(dev)) {
597 u32 adpa;
598
599 adpa = I915_READ(PCH_ADPA);
600 adpa &= ~ADPA_CRT_HOTPLUG_MASK;
601 adpa |= ADPA_HOTPLUG_BITS;
602 I915_WRITE(PCH_ADPA, adpa);
603 POSTING_READ(PCH_ADPA);
604
605 DRM_DEBUG_KMS("pch crt adpa set to 0x%x\n", adpa);
606 crt->force_hotplug_required = 1;
607 }
608
580 dev_priv->hotplug_supported_mask |= CRT_HOTPLUG_INT_STATUS; 609 dev_priv->hotplug_supported_mask |= CRT_HOTPLUG_INT_STATUS;
581} 610}
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 48d8fd686ea9..d9b7092439ef 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1611,6 +1611,18 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
1611 1611
1612 wait_event(dev_priv->pending_flip_queue, 1612 wait_event(dev_priv->pending_flip_queue,
1613 atomic_read(&obj_priv->pending_flip) == 0); 1613 atomic_read(&obj_priv->pending_flip) == 0);
1614
1615 /* Big Hammer, we also need to ensure that any pending
1616 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
1617 * current scanout is retired before unpinning the old
1618 * framebuffer.
1619 */
1620 ret = i915_gem_object_flush_gpu(obj_priv, false);
1621 if (ret) {
1622 i915_gem_object_unpin(to_intel_framebuffer(crtc->fb)->obj);
1623 mutex_unlock(&dev->struct_mutex);
1624 return ret;
1625 }
1614 } 1626 }
1615 1627
1616 ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y, 1628 ret = intel_pipe_set_base_atomic(crtc, crtc->fb, x, y,
@@ -2108,9 +2120,11 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
2108 reg = TRANS_DP_CTL(pipe); 2120 reg = TRANS_DP_CTL(pipe);
2109 temp = I915_READ(reg); 2121 temp = I915_READ(reg);
2110 temp &= ~(TRANS_DP_PORT_SEL_MASK | 2122 temp &= ~(TRANS_DP_PORT_SEL_MASK |
2111 TRANS_DP_SYNC_MASK); 2123 TRANS_DP_SYNC_MASK |
2124 TRANS_DP_BPC_MASK);
2112 temp |= (TRANS_DP_OUTPUT_ENABLE | 2125 temp |= (TRANS_DP_OUTPUT_ENABLE |
2113 TRANS_DP_ENH_FRAMING); 2126 TRANS_DP_ENH_FRAMING);
2127 temp |= TRANS_DP_8BPC;
2114 2128
2115 if (crtc->mode.flags & DRM_MODE_FLAG_PHSYNC) 2129 if (crtc->mode.flags & DRM_MODE_FLAG_PHSYNC)
2116 temp |= TRANS_DP_HSYNC_ACTIVE_HIGH; 2130 temp |= TRANS_DP_HSYNC_ACTIVE_HIGH;
@@ -2700,27 +2714,19 @@ fdi_reduce_ratio(u32 *num, u32 *den)
2700 } 2714 }
2701} 2715}
2702 2716
2703#define DATA_N 0x800000
2704#define LINK_N 0x80000
2705
2706static void 2717static void
2707ironlake_compute_m_n(int bits_per_pixel, int nlanes, int pixel_clock, 2718ironlake_compute_m_n(int bits_per_pixel, int nlanes, int pixel_clock,
2708 int link_clock, struct fdi_m_n *m_n) 2719 int link_clock, struct fdi_m_n *m_n)
2709{ 2720{
2710 u64 temp;
2711
2712 m_n->tu = 64; /* default size */ 2721 m_n->tu = 64; /* default size */
2713 2722
2714 temp = (u64) DATA_N * pixel_clock; 2723 /* BUG_ON(pixel_clock > INT_MAX / 36); */
2715 temp = div_u64(temp, link_clock); 2724 m_n->gmch_m = bits_per_pixel * pixel_clock;
2716 m_n->gmch_m = div_u64(temp * bits_per_pixel, nlanes); 2725 m_n->gmch_n = link_clock * nlanes * 8;
2717 m_n->gmch_m >>= 3; /* convert to bytes_per_pixel */
2718 m_n->gmch_n = DATA_N;
2719 fdi_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n); 2726 fdi_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n);
2720 2727
2721 temp = (u64) LINK_N * pixel_clock; 2728 m_n->link_m = pixel_clock;
2722 m_n->link_m = div_u64(temp, link_clock); 2729 m_n->link_n = link_clock;
2723 m_n->link_n = LINK_N;
2724 fdi_reduce_ratio(&m_n->link_m, &m_n->link_n); 2730 fdi_reduce_ratio(&m_n->link_m, &m_n->link_n);
2725} 2731}
2726 2732
@@ -3704,6 +3710,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3704 3710
3705 /* FDI link */ 3711 /* FDI link */
3706 if (HAS_PCH_SPLIT(dev)) { 3712 if (HAS_PCH_SPLIT(dev)) {
3713 int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode);
3707 int lane = 0, link_bw, bpp; 3714 int lane = 0, link_bw, bpp;
3708 /* CPU eDP doesn't require FDI link, so just set DP M/N 3715 /* CPU eDP doesn't require FDI link, so just set DP M/N
3709 according to current link config */ 3716 according to current link config */
@@ -3787,6 +3794,8 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3787 3794
3788 intel_crtc->fdi_lanes = lane; 3795 intel_crtc->fdi_lanes = lane;
3789 3796
3797 if (pixel_multiplier > 1)
3798 link_bw *= pixel_multiplier;
3790 ironlake_compute_m_n(bpp, lane, target_clock, link_bw, &m_n); 3799 ironlake_compute_m_n(bpp, lane, target_clock, link_bw, &m_n);
3791 } 3800 }
3792 3801
@@ -5224,6 +5233,55 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
5224 .page_flip = intel_crtc_page_flip, 5233 .page_flip = intel_crtc_page_flip,
5225}; 5234};
5226 5235
5236static void intel_sanitize_modesetting(struct drm_device *dev,
5237 int pipe, int plane)
5238{
5239 struct drm_i915_private *dev_priv = dev->dev_private;
5240 u32 reg, val;
5241
5242 if (HAS_PCH_SPLIT(dev))
5243 return;
5244
5245 /* Who knows what state these registers were left in by the BIOS or
5246 * grub?
5247 *
5248 * If we leave the registers in a conflicting state (e.g. with the
5249 * display plane reading from the other pipe than the one we intend
5250 * to use) then when we attempt to teardown the active mode, we will
5251 * not disable the pipes and planes in the correct order -- leaving
5252 * a plane reading from a disabled pipe and possibly leading to
5253 * undefined behaviour.
5254 */
5255
5256 reg = DSPCNTR(plane);
5257 val = I915_READ(reg);
5258
5259 if ((val & DISPLAY_PLANE_ENABLE) == 0)
5260 return;
5261 if (!!(val & DISPPLANE_SEL_PIPE_MASK) == pipe)
5262 return;
5263
5264 /* This display plane is active and attached to the other CPU pipe. */
5265 pipe = !pipe;
5266
5267 /* Disable the plane and wait for it to stop reading from the pipe. */
5268 I915_WRITE(reg, val & ~DISPLAY_PLANE_ENABLE);
5269 intel_flush_display_plane(dev, plane);
5270
5271 if (IS_GEN2(dev))
5272 intel_wait_for_vblank(dev, pipe);
5273
5274 if (pipe == 0 && (dev_priv->quirks & QUIRK_PIPEA_FORCE))
5275 return;
5276
5277 /* Switch off the pipe. */
5278 reg = PIPECONF(pipe);
5279 val = I915_READ(reg);
5280 if (val & PIPECONF_ENABLE) {
5281 I915_WRITE(reg, val & ~PIPECONF_ENABLE);
5282 intel_wait_for_pipe_off(dev, pipe);
5283 }
5284}
5227 5285
5228static void intel_crtc_init(struct drm_device *dev, int pipe) 5286static void intel_crtc_init(struct drm_device *dev, int pipe)
5229{ 5287{
@@ -5275,6 +5333,8 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
5275 5333
5276 setup_timer(&intel_crtc->idle_timer, intel_crtc_idle_timer, 5334 setup_timer(&intel_crtc->idle_timer, intel_crtc_idle_timer,
5277 (unsigned long)intel_crtc); 5335 (unsigned long)intel_crtc);
5336
5337 intel_sanitize_modesetting(dev, intel_crtc->pipe, intel_crtc->plane);
5278} 5338}
5279 5339
5280int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, 5340int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
@@ -5324,9 +5384,14 @@ static void intel_setup_outputs(struct drm_device *dev)
5324 struct drm_i915_private *dev_priv = dev->dev_private; 5384 struct drm_i915_private *dev_priv = dev->dev_private;
5325 struct intel_encoder *encoder; 5385 struct intel_encoder *encoder;
5326 bool dpd_is_edp = false; 5386 bool dpd_is_edp = false;
5387 bool has_lvds = false;
5327 5388
5328 if (IS_MOBILE(dev) && !IS_I830(dev)) 5389 if (IS_MOBILE(dev) && !IS_I830(dev))
5329 intel_lvds_init(dev); 5390 has_lvds = intel_lvds_init(dev);
5391 if (!has_lvds && !HAS_PCH_SPLIT(dev)) {
5392 /* disable the panel fitter on everything but LVDS */
5393 I915_WRITE(PFIT_CONTROL, 0);
5394 }
5330 5395
5331 if (HAS_PCH_SPLIT(dev)) { 5396 if (HAS_PCH_SPLIT(dev)) {
5332 dpd_is_edp = intel_dpd_is_edp(dev); 5397 dpd_is_edp = intel_dpd_is_edp(dev);
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index c8e005553310..df648cb4c296 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -584,17 +584,6 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
584 mode->clock = dev_priv->panel_fixed_mode->clock; 584 mode->clock = dev_priv->panel_fixed_mode->clock;
585 } 585 }
586 586
587 /* Just use VBT values for eDP */
588 if (is_edp(intel_dp)) {
589 intel_dp->lane_count = dev_priv->edp.lanes;
590 intel_dp->link_bw = dev_priv->edp.rate;
591 adjusted_mode->clock = intel_dp_link_clock(intel_dp->link_bw);
592 DRM_DEBUG_KMS("eDP link bw %02x lane count %d clock %d\n",
593 intel_dp->link_bw, intel_dp->lane_count,
594 adjusted_mode->clock);
595 return true;
596 }
597
598 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { 587 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
599 for (clock = 0; clock <= max_clock; clock++) { 588 for (clock = 0; clock <= max_clock; clock++) {
600 int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count); 589 int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count);
@@ -613,6 +602,19 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
613 } 602 }
614 } 603 }
615 604
605 if (is_edp(intel_dp)) {
606 /* okay we failed just pick the highest */
607 intel_dp->lane_count = max_lane_count;
608 intel_dp->link_bw = bws[max_clock];
609 adjusted_mode->clock = intel_dp_link_clock(intel_dp->link_bw);
610 DRM_DEBUG_KMS("Force picking display port link bw %02x lane "
611 "count %d clock %d\n",
612 intel_dp->link_bw, intel_dp->lane_count,
613 adjusted_mode->clock);
614
615 return true;
616 }
617
616 return false; 618 return false;
617} 619}
618 620
@@ -1087,21 +1089,11 @@ intel_get_adjust_train(struct intel_dp *intel_dp)
1087} 1089}
1088 1090
1089static uint32_t 1091static uint32_t
1090intel_dp_signal_levels(struct intel_dp *intel_dp) 1092intel_dp_signal_levels(uint8_t train_set, int lane_count)
1091{ 1093{
1092 struct drm_device *dev = intel_dp->base.base.dev; 1094 uint32_t signal_levels = 0;
1093 struct drm_i915_private *dev_priv = dev->dev_private;
1094 uint32_t signal_levels = 0;
1095 u8 train_set = intel_dp->train_set[0];
1096 u32 vswing = train_set & DP_TRAIN_VOLTAGE_SWING_MASK;
1097 u32 preemphasis = train_set & DP_TRAIN_PRE_EMPHASIS_MASK;
1098 1095
1099 if (is_edp(intel_dp)) { 1096 switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) {
1100 vswing = dev_priv->edp.vswing;
1101 preemphasis = dev_priv->edp.preemphasis;
1102 }
1103
1104 switch (vswing) {
1105 case DP_TRAIN_VOLTAGE_SWING_400: 1097 case DP_TRAIN_VOLTAGE_SWING_400:
1106 default: 1098 default:
1107 signal_levels |= DP_VOLTAGE_0_4; 1099 signal_levels |= DP_VOLTAGE_0_4;
@@ -1116,7 +1108,7 @@ intel_dp_signal_levels(struct intel_dp *intel_dp)
1116 signal_levels |= DP_VOLTAGE_1_2; 1108 signal_levels |= DP_VOLTAGE_1_2;
1117 break; 1109 break;
1118 } 1110 }
1119 switch (preemphasis) { 1111 switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) {
1120 case DP_TRAIN_PRE_EMPHASIS_0: 1112 case DP_TRAIN_PRE_EMPHASIS_0:
1121 default: 1113 default:
1122 signal_levels |= DP_PRE_EMPHASIS_0; 1114 signal_levels |= DP_PRE_EMPHASIS_0;
@@ -1203,18 +1195,6 @@ intel_channel_eq_ok(struct intel_dp *intel_dp)
1203} 1195}
1204 1196
1205static bool 1197static bool
1206intel_dp_aux_handshake_required(struct intel_dp *intel_dp)
1207{
1208 struct drm_device *dev = intel_dp->base.base.dev;
1209 struct drm_i915_private *dev_priv = dev->dev_private;
1210
1211 if (is_edp(intel_dp) && dev_priv->no_aux_handshake)
1212 return false;
1213
1214 return true;
1215}
1216
1217static bool
1218intel_dp_set_link_train(struct intel_dp *intel_dp, 1198intel_dp_set_link_train(struct intel_dp *intel_dp,
1219 uint32_t dp_reg_value, 1199 uint32_t dp_reg_value,
1220 uint8_t dp_train_pat) 1200 uint8_t dp_train_pat)
@@ -1226,9 +1206,6 @@ intel_dp_set_link_train(struct intel_dp *intel_dp,
1226 I915_WRITE(intel_dp->output_reg, dp_reg_value); 1206 I915_WRITE(intel_dp->output_reg, dp_reg_value);
1227 POSTING_READ(intel_dp->output_reg); 1207 POSTING_READ(intel_dp->output_reg);
1228 1208
1229 if (!intel_dp_aux_handshake_required(intel_dp))
1230 return true;
1231
1232 intel_dp_aux_native_write_1(intel_dp, 1209 intel_dp_aux_native_write_1(intel_dp,
1233 DP_TRAINING_PATTERN_SET, 1210 DP_TRAINING_PATTERN_SET,
1234 dp_train_pat); 1211 dp_train_pat);
@@ -1261,11 +1238,10 @@ intel_dp_start_link_train(struct intel_dp *intel_dp)
1261 POSTING_READ(intel_dp->output_reg); 1238 POSTING_READ(intel_dp->output_reg);
1262 intel_wait_for_vblank(dev, intel_crtc->pipe); 1239 intel_wait_for_vblank(dev, intel_crtc->pipe);
1263 1240
1264 if (intel_dp_aux_handshake_required(intel_dp)) 1241 /* Write the link configuration data */
1265 /* Write the link configuration data */ 1242 intel_dp_aux_native_write(intel_dp, DP_LINK_BW_SET,
1266 intel_dp_aux_native_write(intel_dp, DP_LINK_BW_SET, 1243 intel_dp->link_configuration,
1267 intel_dp->link_configuration, 1244 DP_LINK_CONFIGURATION_SIZE);
1268 DP_LINK_CONFIGURATION_SIZE);
1269 1245
1270 DP |= DP_PORT_EN; 1246 DP |= DP_PORT_EN;
1271 if (HAS_PCH_CPT(dev) && !is_edp(intel_dp)) 1247 if (HAS_PCH_CPT(dev) && !is_edp(intel_dp))
@@ -1283,7 +1259,7 @@ intel_dp_start_link_train(struct intel_dp *intel_dp)
1283 signal_levels = intel_gen6_edp_signal_levels(intel_dp->train_set[0]); 1259 signal_levels = intel_gen6_edp_signal_levels(intel_dp->train_set[0]);
1284 DP = (DP & ~EDP_LINK_TRAIN_VOL_EMP_MASK_SNB) | signal_levels; 1260 DP = (DP & ~EDP_LINK_TRAIN_VOL_EMP_MASK_SNB) | signal_levels;
1285 } else { 1261 } else {
1286 signal_levels = intel_dp_signal_levels(intel_dp); 1262 signal_levels = intel_dp_signal_levels(intel_dp->train_set[0], intel_dp->lane_count);
1287 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels; 1263 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels;
1288 } 1264 }
1289 1265
@@ -1297,37 +1273,33 @@ intel_dp_start_link_train(struct intel_dp *intel_dp)
1297 break; 1273 break;
1298 /* Set training pattern 1 */ 1274 /* Set training pattern 1 */
1299 1275
1300 udelay(500); 1276 udelay(100);
1301 if (intel_dp_aux_handshake_required(intel_dp)) { 1277 if (!intel_dp_get_link_status(intel_dp))
1278 break;
1279
1280 if (intel_clock_recovery_ok(intel_dp->link_status, intel_dp->lane_count)) {
1281 clock_recovery = true;
1302 break; 1282 break;
1303 } else { 1283 }
1304 if (!intel_dp_get_link_status(intel_dp))
1305 break;
1306 1284
1307 if (intel_clock_recovery_ok(intel_dp->link_status, intel_dp->lane_count)) { 1285 /* Check to see if we've tried the max voltage */
1308 clock_recovery = true; 1286 for (i = 0; i < intel_dp->lane_count; i++)
1287 if ((intel_dp->train_set[i] & DP_TRAIN_MAX_SWING_REACHED) == 0)
1309 break; 1288 break;
1310 } 1289 if (i == intel_dp->lane_count)
1290 break;
1311 1291
1312 /* Check to see if we've tried the max voltage */ 1292 /* Check to see if we've tried the same voltage 5 times */
1313 for (i = 0; i < intel_dp->lane_count; i++) 1293 if ((intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK) == voltage) {
1314 if ((intel_dp->train_set[i] & DP_TRAIN_MAX_SWING_REACHED) == 0) 1294 ++tries;
1315 break; 1295 if (tries == 5)
1316 if (i == intel_dp->lane_count)
1317 break; 1296 break;
1297 } else
1298 tries = 0;
1299 voltage = intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
1318 1300
1319 /* Check to see if we've tried the same voltage 5 times */ 1301 /* Compute new intel_dp->train_set as requested by target */
1320 if ((intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK) == voltage) { 1302 intel_get_adjust_train(intel_dp);
1321 ++tries;
1322 if (tries == 5)
1323 break;
1324 } else
1325 tries = 0;
1326 voltage = intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
1327
1328 /* Compute new intel_dp->train_set as requested by target */
1329 intel_get_adjust_train(intel_dp);
1330 }
1331 } 1303 }
1332 1304
1333 intel_dp->DP = DP; 1305 intel_dp->DP = DP;
@@ -1354,7 +1326,7 @@ intel_dp_complete_link_train(struct intel_dp *intel_dp)
1354 signal_levels = intel_gen6_edp_signal_levels(intel_dp->train_set[0]); 1326 signal_levels = intel_gen6_edp_signal_levels(intel_dp->train_set[0]);
1355 DP = (DP & ~EDP_LINK_TRAIN_VOL_EMP_MASK_SNB) | signal_levels; 1327 DP = (DP & ~EDP_LINK_TRAIN_VOL_EMP_MASK_SNB) | signal_levels;
1356 } else { 1328 } else {
1357 signal_levels = intel_dp_signal_levels(intel_dp); 1329 signal_levels = intel_dp_signal_levels(intel_dp->train_set[0], intel_dp->lane_count);
1358 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels; 1330 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels;
1359 } 1331 }
1360 1332
@@ -1368,28 +1340,24 @@ intel_dp_complete_link_train(struct intel_dp *intel_dp)
1368 DP_TRAINING_PATTERN_2)) 1340 DP_TRAINING_PATTERN_2))
1369 break; 1341 break;
1370 1342
1371 udelay(500); 1343 udelay(400);
1372 1344 if (!intel_dp_get_link_status(intel_dp))
1373 if (!intel_dp_aux_handshake_required(intel_dp)) {
1374 break; 1345 break;
1375 } else {
1376 if (!intel_dp_get_link_status(intel_dp))
1377 break;
1378 1346
1379 if (intel_channel_eq_ok(intel_dp)) { 1347 if (intel_channel_eq_ok(intel_dp)) {
1380 channel_eq = true; 1348 channel_eq = true;
1381 break; 1349 break;
1382 } 1350 }
1383 1351
1384 /* Try 5 times */ 1352 /* Try 5 times */
1385 if (tries > 5) 1353 if (tries > 5)
1386 break; 1354 break;
1387 1355
1388 /* Compute new intel_dp->train_set as requested by target */ 1356 /* Compute new intel_dp->train_set as requested by target */
1389 intel_get_adjust_train(intel_dp); 1357 intel_get_adjust_train(intel_dp);
1390 ++tries; 1358 ++tries;
1391 }
1392 } 1359 }
1360
1393 if (HAS_PCH_CPT(dev) && !is_edp(intel_dp)) 1361 if (HAS_PCH_CPT(dev) && !is_edp(intel_dp))
1394 reg = DP | DP_LINK_TRAIN_OFF_CPT; 1362 reg = DP | DP_LINK_TRAIN_OFF_CPT;
1395 else 1363 else
@@ -1408,6 +1376,9 @@ intel_dp_link_down(struct intel_dp *intel_dp)
1408 struct drm_i915_private *dev_priv = dev->dev_private; 1376 struct drm_i915_private *dev_priv = dev->dev_private;
1409 uint32_t DP = intel_dp->DP; 1377 uint32_t DP = intel_dp->DP;
1410 1378
1379 if ((I915_READ(intel_dp->output_reg) & DP_PORT_EN) == 0)
1380 return;
1381
1411 DRM_DEBUG_KMS("\n"); 1382 DRM_DEBUG_KMS("\n");
1412 1383
1413 if (is_edp(intel_dp)) { 1384 if (is_edp(intel_dp)) {
@@ -1430,6 +1401,28 @@ intel_dp_link_down(struct intel_dp *intel_dp)
1430 1401
1431 if (is_edp(intel_dp)) 1402 if (is_edp(intel_dp))
1432 DP |= DP_LINK_TRAIN_OFF; 1403 DP |= DP_LINK_TRAIN_OFF;
1404
1405 if (!HAS_PCH_CPT(dev) &&
1406 I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) {
1407 struct intel_crtc *intel_crtc = to_intel_crtc(intel_dp->base.base.crtc);
1408 /* Hardware workaround: leaving our transcoder select
1409 * set to transcoder B while it's off will prevent the
1410 * corresponding HDMI output on transcoder A.
1411 *
1412 * Combine this with another hardware workaround:
1413 * transcoder select bit can only be cleared while the
1414 * port is enabled.
1415 */
1416 DP &= ~DP_PIPEB_SELECT;
1417 I915_WRITE(intel_dp->output_reg, DP);
1418
1419 /* Changes to enable or select take place the vblank
1420 * after being written.
1421 */
1422 intel_wait_for_vblank(intel_dp->base.base.dev,
1423 intel_crtc->pipe);
1424 }
1425
1433 I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); 1426 I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN);
1434 POSTING_READ(intel_dp->output_reg); 1427 POSTING_READ(intel_dp->output_reg);
1435} 1428}
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 21551fe74541..e52c6125bb1f 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -237,7 +237,7 @@ extern bool intel_sdvo_init(struct drm_device *dev, int output_device);
237extern void intel_dvo_init(struct drm_device *dev); 237extern void intel_dvo_init(struct drm_device *dev);
238extern void intel_tv_init(struct drm_device *dev); 238extern void intel_tv_init(struct drm_device *dev);
239extern void intel_mark_busy(struct drm_device *dev, struct drm_gem_object *obj); 239extern void intel_mark_busy(struct drm_device *dev, struct drm_gem_object *obj);
240extern void intel_lvds_init(struct drm_device *dev); 240extern bool intel_lvds_init(struct drm_device *dev);
241extern void intel_dp_init(struct drm_device *dev, int dp_reg); 241extern void intel_dp_init(struct drm_device *dev, int dp_reg);
242void 242void
243intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, 243intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index 2be4f728ed0c..3dba086e7eea 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -160,7 +160,7 @@ intel_gpio_create(struct drm_i915_private *dev_priv, u32 pin)
160 }; 160 };
161 struct intel_gpio *gpio; 161 struct intel_gpio *gpio;
162 162
163 if (pin < 1 || pin > 7) 163 if (pin >= ARRAY_SIZE(map_pin_to_reg) || !map_pin_to_reg[pin])
164 return NULL; 164 return NULL;
165 165
166 gpio = kzalloc(sizeof(struct intel_gpio), GFP_KERNEL); 166 gpio = kzalloc(sizeof(struct intel_gpio), GFP_KERNEL);
@@ -172,7 +172,8 @@ intel_gpio_create(struct drm_i915_private *dev_priv, u32 pin)
172 gpio->reg += PCH_GPIOA - GPIOA; 172 gpio->reg += PCH_GPIOA - GPIOA;
173 gpio->dev_priv = dev_priv; 173 gpio->dev_priv = dev_priv;
174 174
175 snprintf(gpio->adapter.name, I2C_NAME_SIZE, "GPIO%c", "?BACDEF?"[pin]); 175 snprintf(gpio->adapter.name, sizeof(gpio->adapter.name),
176 "i915 GPIO%c", "?BACDE?F"[pin]);
176 gpio->adapter.owner = THIS_MODULE; 177 gpio->adapter.owner = THIS_MODULE;
177 gpio->adapter.algo_data = &gpio->algo; 178 gpio->adapter.algo_data = &gpio->algo;
178 gpio->adapter.dev.parent = &dev_priv->dev->pdev->dev; 179 gpio->adapter.dev.parent = &dev_priv->dev->pdev->dev;
@@ -349,7 +350,7 @@ int intel_setup_gmbus(struct drm_device *dev)
349 "panel", 350 "panel",
350 "dpc", 351 "dpc",
351 "dpb", 352 "dpb",
352 "reserved" 353 "reserved",
353 "dpd", 354 "dpd",
354 }; 355 };
355 struct drm_i915_private *dev_priv = dev->dev_private; 356 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -366,8 +367,8 @@ int intel_setup_gmbus(struct drm_device *dev)
366 bus->adapter.owner = THIS_MODULE; 367 bus->adapter.owner = THIS_MODULE;
367 bus->adapter.class = I2C_CLASS_DDC; 368 bus->adapter.class = I2C_CLASS_DDC;
368 snprintf(bus->adapter.name, 369 snprintf(bus->adapter.name,
369 I2C_NAME_SIZE, 370 sizeof(bus->adapter.name),
370 "gmbus %s", 371 "i915 gmbus %s",
371 names[i]); 372 names[i]);
372 373
373 bus->adapter.dev.parent = &dev->pdev->dev; 374 bus->adapter.dev.parent = &dev->pdev->dev;
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 4324a326f98e..25bcedf386fd 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -68,7 +68,7 @@ static struct intel_lvds *intel_attached_lvds(struct drm_connector *connector)
68/** 68/**
69 * Sets the power state for the panel. 69 * Sets the power state for the panel.
70 */ 70 */
71static void intel_lvds_set_power(struct intel_lvds *intel_lvds, bool on) 71static void intel_lvds_enable(struct intel_lvds *intel_lvds)
72{ 72{
73 struct drm_device *dev = intel_lvds->base.base.dev; 73 struct drm_device *dev = intel_lvds->base.base.dev;
74 struct drm_i915_private *dev_priv = dev->dev_private; 74 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -82,26 +82,61 @@ static void intel_lvds_set_power(struct intel_lvds *intel_lvds, bool on)
82 lvds_reg = LVDS; 82 lvds_reg = LVDS;
83 } 83 }
84 84
85 if (on) { 85 I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN);
86 I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN);
87 I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON);
88 intel_panel_set_backlight(dev, dev_priv->backlight_level);
89 } else {
90 dev_priv->backlight_level = intel_panel_get_backlight(dev);
91
92 intel_panel_set_backlight(dev, 0);
93 I915_WRITE(ctl_reg, I915_READ(ctl_reg) & ~POWER_TARGET_ON);
94 86
95 if (intel_lvds->pfit_control) { 87 if (intel_lvds->pfit_dirty) {
96 if (wait_for((I915_READ(PP_STATUS) & PP_ON) == 0, 1000)) 88 /*
97 DRM_ERROR("timed out waiting for panel to power off\n"); 89 * Enable automatic panel scaling so that non-native modes
98 I915_WRITE(PFIT_CONTROL, 0); 90 * fill the screen. The panel fitter should only be
99 intel_lvds->pfit_control = 0; 91 * adjusted whilst the pipe is disabled, according to
92 * register description and PRM.
93 */
94 DRM_DEBUG_KMS("applying panel-fitter: %x, %x\n",
95 intel_lvds->pfit_control,
96 intel_lvds->pfit_pgm_ratios);
97 if (wait_for((I915_READ(PP_STATUS) & PP_ON) == 0, 1000)) {
98 DRM_ERROR("timed out waiting for panel to power off\n");
99 } else {
100 I915_WRITE(PFIT_PGM_RATIOS, intel_lvds->pfit_pgm_ratios);
101 I915_WRITE(PFIT_CONTROL, intel_lvds->pfit_control);
100 intel_lvds->pfit_dirty = false; 102 intel_lvds->pfit_dirty = false;
101 } 103 }
104 }
105
106 I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON);
107 POSTING_READ(lvds_reg);
108
109 intel_panel_set_backlight(dev, dev_priv->backlight_level);
110}
111
112static void intel_lvds_disable(struct intel_lvds *intel_lvds)
113{
114 struct drm_device *dev = intel_lvds->base.base.dev;
115 struct drm_i915_private *dev_priv = dev->dev_private;
116 u32 ctl_reg, lvds_reg;
117
118 if (HAS_PCH_SPLIT(dev)) {
119 ctl_reg = PCH_PP_CONTROL;
120 lvds_reg = PCH_LVDS;
121 } else {
122 ctl_reg = PP_CONTROL;
123 lvds_reg = LVDS;
124 }
125
126 dev_priv->backlight_level = intel_panel_get_backlight(dev);
127 intel_panel_set_backlight(dev, 0);
128
129 I915_WRITE(ctl_reg, I915_READ(ctl_reg) & ~POWER_TARGET_ON);
130
131 if (intel_lvds->pfit_control) {
132 if (wait_for((I915_READ(PP_STATUS) & PP_ON) == 0, 1000))
133 DRM_ERROR("timed out waiting for panel to power off\n");
102 134
103 I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN); 135 I915_WRITE(PFIT_CONTROL, 0);
136 intel_lvds->pfit_dirty = true;
104 } 137 }
138
139 I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN);
105 POSTING_READ(lvds_reg); 140 POSTING_READ(lvds_reg);
106} 141}
107 142
@@ -110,9 +145,9 @@ static void intel_lvds_dpms(struct drm_encoder *encoder, int mode)
110 struct intel_lvds *intel_lvds = to_intel_lvds(encoder); 145 struct intel_lvds *intel_lvds = to_intel_lvds(encoder);
111 146
112 if (mode == DRM_MODE_DPMS_ON) 147 if (mode == DRM_MODE_DPMS_ON)
113 intel_lvds_set_power(intel_lvds, true); 148 intel_lvds_enable(intel_lvds);
114 else 149 else
115 intel_lvds_set_power(intel_lvds, false); 150 intel_lvds_disable(intel_lvds);
116 151
117 /* XXX: We never power down the LVDS pairs. */ 152 /* XXX: We never power down the LVDS pairs. */
118} 153}
@@ -411,43 +446,18 @@ static void intel_lvds_commit(struct drm_encoder *encoder)
411 /* Always do a full power on as we do not know what state 446 /* Always do a full power on as we do not know what state
412 * we were left in. 447 * we were left in.
413 */ 448 */
414 intel_lvds_set_power(intel_lvds, true); 449 intel_lvds_enable(intel_lvds);
415} 450}
416 451
417static void intel_lvds_mode_set(struct drm_encoder *encoder, 452static void intel_lvds_mode_set(struct drm_encoder *encoder,
418 struct drm_display_mode *mode, 453 struct drm_display_mode *mode,
419 struct drm_display_mode *adjusted_mode) 454 struct drm_display_mode *adjusted_mode)
420{ 455{
421 struct drm_device *dev = encoder->dev;
422 struct drm_i915_private *dev_priv = dev->dev_private;
423 struct intel_lvds *intel_lvds = to_intel_lvds(encoder);
424
425 /* 456 /*
426 * The LVDS pin pair will already have been turned on in the 457 * The LVDS pin pair will already have been turned on in the
427 * intel_crtc_mode_set since it has a large impact on the DPLL 458 * intel_crtc_mode_set since it has a large impact on the DPLL
428 * settings. 459 * settings.
429 */ 460 */
430
431 if (HAS_PCH_SPLIT(dev))
432 return;
433
434 if (!intel_lvds->pfit_dirty)
435 return;
436
437 /*
438 * Enable automatic panel scaling so that non-native modes fill the
439 * screen. Should be enabled before the pipe is enabled, according to
440 * register description and PRM.
441 */
442 DRM_DEBUG_KMS("applying panel-fitter: %x, %x\n",
443 intel_lvds->pfit_control,
444 intel_lvds->pfit_pgm_ratios);
445 if (wait_for((I915_READ(PP_STATUS) & PP_ON) == 0, 1000))
446 DRM_ERROR("timed out waiting for panel to power off\n");
447
448 I915_WRITE(PFIT_PGM_RATIOS, intel_lvds->pfit_pgm_ratios);
449 I915_WRITE(PFIT_CONTROL, intel_lvds->pfit_control);
450 intel_lvds->pfit_dirty = false;
451} 461}
452 462
453/** 463/**
@@ -837,7 +847,7 @@ static bool intel_lvds_ddc_probe(struct drm_device *dev, u8 pin)
837 * Create the connector, register the LVDS DDC bus, and try to figure out what 847 * Create the connector, register the LVDS DDC bus, and try to figure out what
838 * modes we can display on the LVDS panel (if present). 848 * modes we can display on the LVDS panel (if present).
839 */ 849 */
840void intel_lvds_init(struct drm_device *dev) 850bool intel_lvds_init(struct drm_device *dev)
841{ 851{
842 struct drm_i915_private *dev_priv = dev->dev_private; 852 struct drm_i915_private *dev_priv = dev->dev_private;
843 struct intel_lvds *intel_lvds; 853 struct intel_lvds *intel_lvds;
@@ -853,37 +863,37 @@ void intel_lvds_init(struct drm_device *dev)
853 863
854 /* Skip init on machines we know falsely report LVDS */ 864 /* Skip init on machines we know falsely report LVDS */
855 if (dmi_check_system(intel_no_lvds)) 865 if (dmi_check_system(intel_no_lvds))
856 return; 866 return false;
857 867
858 pin = GMBUS_PORT_PANEL; 868 pin = GMBUS_PORT_PANEL;
859 if (!lvds_is_present_in_vbt(dev, &pin)) { 869 if (!lvds_is_present_in_vbt(dev, &pin)) {
860 DRM_DEBUG_KMS("LVDS is not present in VBT\n"); 870 DRM_DEBUG_KMS("LVDS is not present in VBT\n");
861 return; 871 return false;
862 } 872 }
863 873
864 if (HAS_PCH_SPLIT(dev)) { 874 if (HAS_PCH_SPLIT(dev)) {
865 if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0) 875 if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0)
866 return; 876 return false;
867 if (dev_priv->edp.support) { 877 if (dev_priv->edp.support) {
868 DRM_DEBUG_KMS("disable LVDS for eDP support\n"); 878 DRM_DEBUG_KMS("disable LVDS for eDP support\n");
869 return; 879 return false;
870 } 880 }
871 } 881 }
872 882
873 if (!intel_lvds_ddc_probe(dev, pin)) { 883 if (!intel_lvds_ddc_probe(dev, pin)) {
874 DRM_DEBUG_KMS("LVDS did not respond to DDC probe\n"); 884 DRM_DEBUG_KMS("LVDS did not respond to DDC probe\n");
875 return; 885 return false;
876 } 886 }
877 887
878 intel_lvds = kzalloc(sizeof(struct intel_lvds), GFP_KERNEL); 888 intel_lvds = kzalloc(sizeof(struct intel_lvds), GFP_KERNEL);
879 if (!intel_lvds) { 889 if (!intel_lvds) {
880 return; 890 return false;
881 } 891 }
882 892
883 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); 893 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
884 if (!intel_connector) { 894 if (!intel_connector) {
885 kfree(intel_lvds); 895 kfree(intel_lvds);
886 return; 896 return false;
887 } 897 }
888 898
889 if (!HAS_PCH_SPLIT(dev)) { 899 if (!HAS_PCH_SPLIT(dev)) {
@@ -1026,7 +1036,7 @@ out:
1026 /* keep the LVDS connector */ 1036 /* keep the LVDS connector */
1027 dev_priv->int_lvds_connector = connector; 1037 dev_priv->int_lvds_connector = connector;
1028 drm_sysfs_connector_add(connector); 1038 drm_sysfs_connector_add(connector);
1029 return; 1039 return true;
1030 1040
1031failed: 1041failed:
1032 DRM_DEBUG_KMS("No LVDS modes found, disabling.\n"); 1042 DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
@@ -1034,4 +1044,5 @@ failed:
1034 drm_encoder_cleanup(encoder); 1044 drm_encoder_cleanup(encoder);
1035 kfree(intel_lvds); 1045 kfree(intel_lvds);
1036 kfree(intel_connector); 1046 kfree(intel_connector);
1047 return false;
1037} 1048}
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index b83306f9244b..89a65be8a3f3 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -156,23 +156,25 @@ static int init_ring_common(struct drm_device *dev,
156 156
157 /* G45 ring initialization fails to reset head to zero */ 157 /* G45 ring initialization fails to reset head to zero */
158 if (head != 0) { 158 if (head != 0) {
159 DRM_ERROR("%s head not reset to zero " 159 DRM_DEBUG_KMS("%s head not reset to zero "
160 "ctl %08x head %08x tail %08x start %08x\n", 160 "ctl %08x head %08x tail %08x start %08x\n",
161 ring->name, 161 ring->name,
162 I915_READ_CTL(ring), 162 I915_READ_CTL(ring),
163 I915_READ_HEAD(ring), 163 I915_READ_HEAD(ring),
164 I915_READ_TAIL(ring), 164 I915_READ_TAIL(ring),
165 I915_READ_START(ring)); 165 I915_READ_START(ring));
166 166
167 I915_WRITE_HEAD(ring, 0); 167 I915_WRITE_HEAD(ring, 0);
168 168
169 DRM_ERROR("%s head forced to zero " 169 if (I915_READ_HEAD(ring) & HEAD_ADDR) {
170 "ctl %08x head %08x tail %08x start %08x\n", 170 DRM_ERROR("failed to set %s head to zero "
171 ring->name, 171 "ctl %08x head %08x tail %08x start %08x\n",
172 I915_READ_CTL(ring), 172 ring->name,
173 I915_READ_HEAD(ring), 173 I915_READ_CTL(ring),
174 I915_READ_TAIL(ring), 174 I915_READ_HEAD(ring),
175 I915_READ_START(ring)); 175 I915_READ_TAIL(ring),
176 I915_READ_START(ring));
177 }
176 } 178 }
177 179
178 I915_WRITE_CTL(ring, 180 I915_WRITE_CTL(ring,
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index de158b76bcd5..d97e6cb52d34 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -107,7 +107,8 @@ struct intel_sdvo {
107 * This is set if we treat the device as HDMI, instead of DVI. 107 * This is set if we treat the device as HDMI, instead of DVI.
108 */ 108 */
109 bool is_hdmi; 109 bool is_hdmi;
110 bool has_audio; 110 bool has_hdmi_monitor;
111 bool has_hdmi_audio;
111 112
112 /** 113 /**
113 * This is set if we detect output of sdvo device as LVDS and 114 * This is set if we detect output of sdvo device as LVDS and
@@ -1023,7 +1024,7 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1023 if (!intel_sdvo_set_target_input(intel_sdvo)) 1024 if (!intel_sdvo_set_target_input(intel_sdvo))
1024 return; 1025 return;
1025 1026
1026 if (intel_sdvo->is_hdmi && 1027 if (intel_sdvo->has_hdmi_monitor &&
1027 !intel_sdvo_set_avi_infoframe(intel_sdvo)) 1028 !intel_sdvo_set_avi_infoframe(intel_sdvo))
1028 return; 1029 return;
1029 1030
@@ -1063,7 +1064,7 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1063 } 1064 }
1064 if (intel_crtc->pipe == 1) 1065 if (intel_crtc->pipe == 1)
1065 sdvox |= SDVO_PIPE_B_SELECT; 1066 sdvox |= SDVO_PIPE_B_SELECT;
1066 if (intel_sdvo->has_audio) 1067 if (intel_sdvo->has_hdmi_audio)
1067 sdvox |= SDVO_AUDIO_ENABLE; 1068 sdvox |= SDVO_AUDIO_ENABLE;
1068 1069
1069 if (INTEL_INFO(dev)->gen >= 4) { 1070 if (INTEL_INFO(dev)->gen >= 4) {
@@ -1295,55 +1296,14 @@ intel_sdvo_get_edid(struct drm_connector *connector)
1295 return drm_get_edid(connector, &sdvo->ddc); 1296 return drm_get_edid(connector, &sdvo->ddc);
1296} 1297}
1297 1298
1298static struct drm_connector *
1299intel_find_analog_connector(struct drm_device *dev)
1300{
1301 struct drm_connector *connector;
1302 struct intel_sdvo *encoder;
1303
1304 list_for_each_entry(encoder,
1305 &dev->mode_config.encoder_list,
1306 base.base.head) {
1307 if (encoder->base.type == INTEL_OUTPUT_ANALOG) {
1308 list_for_each_entry(connector,
1309 &dev->mode_config.connector_list,
1310 head) {
1311 if (&encoder->base ==
1312 intel_attached_encoder(connector))
1313 return connector;
1314 }
1315 }
1316 }
1317
1318 return NULL;
1319}
1320
1321static int
1322intel_analog_is_connected(struct drm_device *dev)
1323{
1324 struct drm_connector *analog_connector;
1325
1326 analog_connector = intel_find_analog_connector(dev);
1327 if (!analog_connector)
1328 return false;
1329
1330 if (analog_connector->funcs->detect(analog_connector, false) ==
1331 connector_status_disconnected)
1332 return false;
1333
1334 return true;
1335}
1336
1337/* Mac mini hack -- use the same DDC as the analog connector */ 1299/* Mac mini hack -- use the same DDC as the analog connector */
1338static struct edid * 1300static struct edid *
1339intel_sdvo_get_analog_edid(struct drm_connector *connector) 1301intel_sdvo_get_analog_edid(struct drm_connector *connector)
1340{ 1302{
1341 struct drm_i915_private *dev_priv = connector->dev->dev_private; 1303 struct drm_i915_private *dev_priv = connector->dev->dev_private;
1342 1304
1343 if (!intel_analog_is_connected(connector->dev)) 1305 return drm_get_edid(connector,
1344 return NULL; 1306 &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter);
1345
1346 return drm_get_edid(connector, &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter);
1347} 1307}
1348 1308
1349enum drm_connector_status 1309enum drm_connector_status
@@ -1388,8 +1348,10 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1388 /* DDC bus is shared, match EDID to connector type */ 1348 /* DDC bus is shared, match EDID to connector type */
1389 if (edid->input & DRM_EDID_INPUT_DIGITAL) { 1349 if (edid->input & DRM_EDID_INPUT_DIGITAL) {
1390 status = connector_status_connected; 1350 status = connector_status_connected;
1391 intel_sdvo->is_hdmi = drm_detect_hdmi_monitor(edid); 1351 if (intel_sdvo->is_hdmi) {
1392 intel_sdvo->has_audio = drm_detect_monitor_audio(edid); 1352 intel_sdvo->has_hdmi_monitor = drm_detect_hdmi_monitor(edid);
1353 intel_sdvo->has_hdmi_audio = drm_detect_monitor_audio(edid);
1354 }
1393 } 1355 }
1394 connector->display_info.raw_edid = NULL; 1356 connector->display_info.raw_edid = NULL;
1395 kfree(edid); 1357 kfree(edid);
@@ -1398,7 +1360,7 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1398 if (status == connector_status_connected) { 1360 if (status == connector_status_connected) {
1399 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); 1361 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1400 if (intel_sdvo_connector->force_audio) 1362 if (intel_sdvo_connector->force_audio)
1401 intel_sdvo->has_audio = intel_sdvo_connector->force_audio > 0; 1363 intel_sdvo->has_hdmi_audio = intel_sdvo_connector->force_audio > 0;
1402 } 1364 }
1403 1365
1404 return status; 1366 return status;
@@ -1415,10 +1377,12 @@ intel_sdvo_detect(struct drm_connector *connector, bool force)
1415 if (!intel_sdvo_write_cmd(intel_sdvo, 1377 if (!intel_sdvo_write_cmd(intel_sdvo,
1416 SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0)) 1378 SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0))
1417 return connector_status_unknown; 1379 return connector_status_unknown;
1418 if (intel_sdvo->is_tv) { 1380
1419 /* add 30ms delay when the output type is SDVO-TV */ 1381 /* add 30ms delay when the output type might be TV */
1382 if (intel_sdvo->caps.output_flags &
1383 (SDVO_OUTPUT_SVID0 | SDVO_OUTPUT_CVBS0))
1420 mdelay(30); 1384 mdelay(30);
1421 } 1385
1422 if (!intel_sdvo_read_response(intel_sdvo, &response, 2)) 1386 if (!intel_sdvo_read_response(intel_sdvo, &response, 2))
1423 return connector_status_unknown; 1387 return connector_status_unknown;
1424 1388
@@ -1472,8 +1436,10 @@ static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
1472 edid = intel_sdvo_get_analog_edid(connector); 1436 edid = intel_sdvo_get_analog_edid(connector);
1473 1437
1474 if (edid != NULL) { 1438 if (edid != NULL) {
1475 drm_mode_connector_update_edid_property(connector, edid); 1439 if (edid->input & DRM_EDID_INPUT_DIGITAL) {
1476 drm_add_edid_modes(connector, edid); 1440 drm_mode_connector_update_edid_property(connector, edid);
1441 drm_add_edid_modes(connector, edid);
1442 }
1477 connector->display_info.raw_edid = NULL; 1443 connector->display_info.raw_edid = NULL;
1478 kfree(edid); 1444 kfree(edid);
1479 } 1445 }
@@ -1713,12 +1679,12 @@ intel_sdvo_set_property(struct drm_connector *connector,
1713 1679
1714 intel_sdvo_connector->force_audio = val; 1680 intel_sdvo_connector->force_audio = val;
1715 1681
1716 if (val > 0 && intel_sdvo->has_audio) 1682 if (val > 0 && intel_sdvo->has_hdmi_audio)
1717 return 0; 1683 return 0;
1718 if (val < 0 && !intel_sdvo->has_audio) 1684 if (val < 0 && !intel_sdvo->has_hdmi_audio)
1719 return 0; 1685 return 0;
1720 1686
1721 intel_sdvo->has_audio = val > 0; 1687 intel_sdvo->has_hdmi_audio = val > 0;
1722 goto done; 1688 goto done;
1723 } 1689 }
1724 1690
@@ -2070,6 +2036,8 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2070 intel_sdvo_set_colorimetry(intel_sdvo, 2036 intel_sdvo_set_colorimetry(intel_sdvo,
2071 SDVO_COLORIMETRY_RGB256); 2037 SDVO_COLORIMETRY_RGB256);
2072 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA; 2038 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA;
2039
2040 intel_sdvo_add_hdmi_properties(intel_sdvo_connector);
2073 intel_sdvo->is_hdmi = true; 2041 intel_sdvo->is_hdmi = true;
2074 } 2042 }
2075 intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 2043 intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
@@ -2077,8 +2045,6 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2077 2045
2078 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); 2046 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo);
2079 2047
2080 intel_sdvo_add_hdmi_properties(intel_sdvo_connector);
2081
2082 return true; 2048 return true;
2083} 2049}
2084 2050
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index 406228f4a2a0..b14c81110575 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -31,6 +31,7 @@
31 */ 31 */
32 32
33#include <linux/backlight.h> 33#include <linux/backlight.h>
34#include <linux/acpi.h>
34 35
35#include "drmP.h" 36#include "drmP.h"
36#include "nouveau_drv.h" 37#include "nouveau_drv.h"
@@ -136,6 +137,14 @@ int nouveau_backlight_init(struct drm_device *dev)
136{ 137{
137 struct drm_nouveau_private *dev_priv = dev->dev_private; 138 struct drm_nouveau_private *dev_priv = dev->dev_private;
138 139
140#ifdef CONFIG_ACPI
141 if (acpi_video_backlight_support()) {
142 NV_INFO(dev, "ACPI backlight interface available, "
143 "not registering our own\n");
144 return 0;
145 }
146#endif
147
139 switch (dev_priv->card_type) { 148 switch (dev_priv->card_type) {
140 case NV_40: 149 case NV_40:
141 return nouveau_nv40_backlight_init(dev); 150 return nouveau_nv40_backlight_init(dev);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 5f21030a293b..b2293576f278 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -6829,7 +6829,7 @@ nouveau_bios_posted(struct drm_device *dev)
6829 struct drm_nouveau_private *dev_priv = dev->dev_private; 6829 struct drm_nouveau_private *dev_priv = dev->dev_private;
6830 unsigned htotal; 6830 unsigned htotal;
6831 6831
6832 if (dev_priv->chipset >= NV_50) { 6832 if (dev_priv->card_type >= NV_50) {
6833 if (NVReadVgaCrtc(dev, 0, 0x00) == 0 && 6833 if (NVReadVgaCrtc(dev, 0, 0x00) == 0 &&
6834 NVReadVgaCrtc(dev, 0, 0x1a) == 0) 6834 NVReadVgaCrtc(dev, 0, 0x1a) == 0)
6835 return false; 6835 return false;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 80353e2b8409..c41e1c200ef5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -143,8 +143,10 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
143 nvbo->no_vm = no_vm; 143 nvbo->no_vm = no_vm;
144 nvbo->tile_mode = tile_mode; 144 nvbo->tile_mode = tile_mode;
145 nvbo->tile_flags = tile_flags; 145 nvbo->tile_flags = tile_flags;
146 nvbo->bo.bdev = &dev_priv->ttm.bdev;
146 147
147 nouveau_bo_fixup_align(dev, tile_mode, tile_flags, &align, &size); 148 nouveau_bo_fixup_align(dev, tile_mode, nouveau_bo_tile_layout(nvbo),
149 &align, &size);
148 align >>= PAGE_SHIFT; 150 align >>= PAGE_SHIFT;
149 151
150 nouveau_bo_placement_set(nvbo, flags, 0); 152 nouveau_bo_placement_set(nvbo, flags, 0);
@@ -176,6 +178,31 @@ set_placement_list(uint32_t *pl, unsigned *n, uint32_t type, uint32_t flags)
176 pl[(*n)++] = TTM_PL_FLAG_SYSTEM | flags; 178 pl[(*n)++] = TTM_PL_FLAG_SYSTEM | flags;
177} 179}
178 180
181static void
182set_placement_range(struct nouveau_bo *nvbo, uint32_t type)
183{
184 struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev);
185
186 if (dev_priv->card_type == NV_10 &&
187 nvbo->tile_mode && (type & TTM_PL_FLAG_VRAM)) {
188 /*
189 * Make sure that the color and depth buffers are handled
190 * by independent memory controller units. Up to a 9x
191 * speed up when alpha-blending and depth-test are enabled
192 * at the same time.
193 */
194 int vram_pages = dev_priv->vram_size >> PAGE_SHIFT;
195
196 if (nvbo->tile_flags & NOUVEAU_GEM_TILE_ZETA) {
197 nvbo->placement.fpfn = vram_pages / 2;
198 nvbo->placement.lpfn = ~0;
199 } else {
200 nvbo->placement.fpfn = 0;
201 nvbo->placement.lpfn = vram_pages / 2;
202 }
203 }
204}
205
179void 206void
180nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t type, uint32_t busy) 207nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t type, uint32_t busy)
181{ 208{
@@ -190,6 +217,8 @@ nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t type, uint32_t busy)
190 pl->busy_placement = nvbo->busy_placements; 217 pl->busy_placement = nvbo->busy_placements;
191 set_placement_list(nvbo->busy_placements, &pl->num_busy_placement, 218 set_placement_list(nvbo->busy_placements, &pl->num_busy_placement,
192 type | busy, flags); 219 type | busy, flags);
220
221 set_placement_range(nvbo, type);
193} 222}
194 223
195int 224int
@@ -525,7 +554,8 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
525 stride = 16 * 4; 554 stride = 16 * 4;
526 height = amount / stride; 555 height = amount / stride;
527 556
528 if (new_mem->mem_type == TTM_PL_VRAM && nvbo->tile_flags) { 557 if (new_mem->mem_type == TTM_PL_VRAM &&
558 nouveau_bo_tile_layout(nvbo)) {
529 ret = RING_SPACE(chan, 8); 559 ret = RING_SPACE(chan, 8);
530 if (ret) 560 if (ret)
531 return ret; 561 return ret;
@@ -546,7 +576,8 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
546 BEGIN_RING(chan, NvSubM2MF, 0x0200, 1); 576 BEGIN_RING(chan, NvSubM2MF, 0x0200, 1);
547 OUT_RING (chan, 1); 577 OUT_RING (chan, 1);
548 } 578 }
549 if (old_mem->mem_type == TTM_PL_VRAM && nvbo->tile_flags) { 579 if (old_mem->mem_type == TTM_PL_VRAM &&
580 nouveau_bo_tile_layout(nvbo)) {
550 ret = RING_SPACE(chan, 8); 581 ret = RING_SPACE(chan, 8);
551 if (ret) 582 if (ret)
552 return ret; 583 return ret;
@@ -753,7 +784,8 @@ nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem,
753 if (dev_priv->card_type == NV_50) { 784 if (dev_priv->card_type == NV_50) {
754 ret = nv50_mem_vm_bind_linear(dev, 785 ret = nv50_mem_vm_bind_linear(dev,
755 offset + dev_priv->vm_vram_base, 786 offset + dev_priv->vm_vram_base,
756 new_mem->size, nvbo->tile_flags, 787 new_mem->size,
788 nouveau_bo_tile_layout(nvbo),
757 offset); 789 offset);
758 if (ret) 790 if (ret)
759 return ret; 791 return ret;
@@ -894,7 +926,8 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
894 * nothing to do here. 926 * nothing to do here.
895 */ 927 */
896 if (bo->mem.mem_type != TTM_PL_VRAM) { 928 if (bo->mem.mem_type != TTM_PL_VRAM) {
897 if (dev_priv->card_type < NV_50 || !nvbo->tile_flags) 929 if (dev_priv->card_type < NV_50 ||
930 !nouveau_bo_tile_layout(nvbo))
898 return 0; 931 return 0;
899 } 932 }
900 933
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 0871495096fa..52c356e9a3d1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -281,7 +281,7 @@ detect_analog:
281 nv_encoder = find_encoder_by_type(connector, OUTPUT_ANALOG); 281 nv_encoder = find_encoder_by_type(connector, OUTPUT_ANALOG);
282 if (!nv_encoder && !nouveau_tv_disable) 282 if (!nv_encoder && !nouveau_tv_disable)
283 nv_encoder = find_encoder_by_type(connector, OUTPUT_TV); 283 nv_encoder = find_encoder_by_type(connector, OUTPUT_TV);
284 if (nv_encoder) { 284 if (nv_encoder && force) {
285 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); 285 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
286 struct drm_encoder_helper_funcs *helper = 286 struct drm_encoder_helper_funcs *helper =
287 encoder->helper_private; 287 encoder->helper_private;
@@ -641,11 +641,28 @@ nouveau_connector_get_modes(struct drm_connector *connector)
641 return ret; 641 return ret;
642} 642}
643 643
644static unsigned
645get_tmds_link_bandwidth(struct drm_connector *connector)
646{
647 struct nouveau_connector *nv_connector = nouveau_connector(connector);
648 struct drm_nouveau_private *dev_priv = connector->dev->dev_private;
649 struct dcb_entry *dcb = nv_connector->detected_encoder->dcb;
650
651 if (dcb->location != DCB_LOC_ON_CHIP ||
652 dev_priv->chipset >= 0x46)
653 return 165000;
654 else if (dev_priv->chipset >= 0x40)
655 return 155000;
656 else if (dev_priv->chipset >= 0x18)
657 return 135000;
658 else
659 return 112000;
660}
661
644static int 662static int
645nouveau_connector_mode_valid(struct drm_connector *connector, 663nouveau_connector_mode_valid(struct drm_connector *connector,
646 struct drm_display_mode *mode) 664 struct drm_display_mode *mode)
647{ 665{
648 struct drm_nouveau_private *dev_priv = connector->dev->dev_private;
649 struct nouveau_connector *nv_connector = nouveau_connector(connector); 666 struct nouveau_connector *nv_connector = nouveau_connector(connector);
650 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder; 667 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
651 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); 668 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
@@ -663,11 +680,9 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
663 max_clock = 400000; 680 max_clock = 400000;
664 break; 681 break;
665 case OUTPUT_TMDS: 682 case OUTPUT_TMDS:
666 if ((dev_priv->card_type >= NV_50 && !nouveau_duallink) || 683 max_clock = get_tmds_link_bandwidth(connector);
667 !nv_encoder->dcb->duallink_possible) 684 if (nouveau_duallink && nv_encoder->dcb->duallink_possible)
668 max_clock = 165000; 685 max_clock *= 2;
669 else
670 max_clock = 330000;
671 break; 686 break;
672 case OUTPUT_ANALOG: 687 case OUTPUT_ANALOG:
673 max_clock = nv_encoder->dcb->crtconf.maxfreq; 688 max_clock = nv_encoder->dcb->crtconf.maxfreq;
@@ -709,44 +724,6 @@ nouveau_connector_best_encoder(struct drm_connector *connector)
709 return NULL; 724 return NULL;
710} 725}
711 726
712void
713nouveau_connector_set_polling(struct drm_connector *connector)
714{
715 struct drm_device *dev = connector->dev;
716 struct drm_nouveau_private *dev_priv = dev->dev_private;
717 struct drm_crtc *crtc;
718 bool spare_crtc = false;
719
720 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
721 spare_crtc |= !crtc->enabled;
722
723 connector->polled = 0;
724
725 switch (connector->connector_type) {
726 case DRM_MODE_CONNECTOR_VGA:
727 case DRM_MODE_CONNECTOR_TV:
728 if (dev_priv->card_type >= NV_50 ||
729 (nv_gf4_disp_arch(dev) && spare_crtc))
730 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
731 break;
732
733 case DRM_MODE_CONNECTOR_DVII:
734 case DRM_MODE_CONNECTOR_DVID:
735 case DRM_MODE_CONNECTOR_HDMIA:
736 case DRM_MODE_CONNECTOR_DisplayPort:
737 case DRM_MODE_CONNECTOR_eDP:
738 if (dev_priv->card_type >= NV_50)
739 connector->polled = DRM_CONNECTOR_POLL_HPD;
740 else if (connector->connector_type == DRM_MODE_CONNECTOR_DVID ||
741 spare_crtc)
742 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
743 break;
744
745 default:
746 break;
747 }
748}
749
750static const struct drm_connector_helper_funcs 727static const struct drm_connector_helper_funcs
751nouveau_connector_helper_funcs = { 728nouveau_connector_helper_funcs = {
752 .get_modes = nouveau_connector_get_modes, 729 .get_modes = nouveau_connector_get_modes,
@@ -872,6 +849,7 @@ nouveau_connector_create(struct drm_device *dev, int index)
872 dev->mode_config.scaling_mode_property, 849 dev->mode_config.scaling_mode_property,
873 nv_connector->scaling_mode); 850 nv_connector->scaling_mode);
874 } 851 }
852 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
875 /* fall-through */ 853 /* fall-through */
876 case DCB_CONNECTOR_TV_0: 854 case DCB_CONNECTOR_TV_0:
877 case DCB_CONNECTOR_TV_1: 855 case DCB_CONNECTOR_TV_1:
@@ -888,11 +866,16 @@ nouveau_connector_create(struct drm_device *dev, int index)
888 dev->mode_config.dithering_mode_property, 866 dev->mode_config.dithering_mode_property,
889 nv_connector->use_dithering ? 867 nv_connector->use_dithering ?
890 DRM_MODE_DITHERING_ON : DRM_MODE_DITHERING_OFF); 868 DRM_MODE_DITHERING_ON : DRM_MODE_DITHERING_OFF);
869
870 if (dcb->type != DCB_CONNECTOR_LVDS) {
871 if (dev_priv->card_type >= NV_50)
872 connector->polled = DRM_CONNECTOR_POLL_HPD;
873 else
874 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
875 }
891 break; 876 break;
892 } 877 }
893 878
894 nouveau_connector_set_polling(connector);
895
896 drm_sysfs_connector_add(connector); 879 drm_sysfs_connector_add(connector);
897 dcb->drm = connector; 880 dcb->drm = connector;
898 return dcb->drm; 881 return dcb->drm;
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.h b/drivers/gpu/drm/nouveau/nouveau_connector.h
index c21ed6b16f88..711b1e9203af 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.h
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.h
@@ -52,9 +52,6 @@ static inline struct nouveau_connector *nouveau_connector(
52struct drm_connector * 52struct drm_connector *
53nouveau_connector_create(struct drm_device *, int index); 53nouveau_connector_create(struct drm_device *, int index);
54 54
55void
56nouveau_connector_set_polling(struct drm_connector *);
57
58int 55int
59nouveau_connector_bpp(struct drm_connector *); 56nouveau_connector_bpp(struct drm_connector *);
60 57
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 3a07e580d27a..1c7db64c03bf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -100,6 +100,9 @@ struct nouveau_bo {
100 int pin_refcnt; 100 int pin_refcnt;
101}; 101};
102 102
103#define nouveau_bo_tile_layout(nvbo) \
104 ((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)
105
103static inline struct nouveau_bo * 106static inline struct nouveau_bo *
104nouveau_bo(struct ttm_buffer_object *bo) 107nouveau_bo(struct ttm_buffer_object *bo)
105{ 108{
@@ -304,6 +307,7 @@ struct nouveau_fifo_engine {
304 void (*destroy_context)(struct nouveau_channel *); 307 void (*destroy_context)(struct nouveau_channel *);
305 int (*load_context)(struct nouveau_channel *); 308 int (*load_context)(struct nouveau_channel *);
306 int (*unload_context)(struct drm_device *); 309 int (*unload_context)(struct drm_device *);
310 void (*tlb_flush)(struct drm_device *dev);
307}; 311};
308 312
309struct nouveau_pgraph_object_method { 313struct nouveau_pgraph_object_method {
@@ -336,6 +340,7 @@ struct nouveau_pgraph_engine {
336 void (*destroy_context)(struct nouveau_channel *); 340 void (*destroy_context)(struct nouveau_channel *);
337 int (*load_context)(struct nouveau_channel *); 341 int (*load_context)(struct nouveau_channel *);
338 int (*unload_context)(struct drm_device *); 342 int (*unload_context)(struct drm_device *);
343 void (*tlb_flush)(struct drm_device *dev);
339 344
340 void (*set_region_tiling)(struct drm_device *dev, int i, uint32_t addr, 345 void (*set_region_tiling)(struct drm_device *dev, int i, uint32_t addr,
341 uint32_t size, uint32_t pitch); 346 uint32_t size, uint32_t pitch);
@@ -485,13 +490,13 @@ enum nv04_fp_display_regs {
485}; 490};
486 491
487struct nv04_crtc_reg { 492struct nv04_crtc_reg {
488 unsigned char MiscOutReg; /* */ 493 unsigned char MiscOutReg;
489 uint8_t CRTC[0xa0]; 494 uint8_t CRTC[0xa0];
490 uint8_t CR58[0x10]; 495 uint8_t CR58[0x10];
491 uint8_t Sequencer[5]; 496 uint8_t Sequencer[5];
492 uint8_t Graphics[9]; 497 uint8_t Graphics[9];
493 uint8_t Attribute[21]; 498 uint8_t Attribute[21];
494 unsigned char DAC[768]; /* Internal Colorlookuptable */ 499 unsigned char DAC[768];
495 500
496 /* PCRTC regs */ 501 /* PCRTC regs */
497 uint32_t fb_start; 502 uint32_t fb_start;
@@ -539,43 +544,9 @@ struct nv04_output_reg {
539}; 544};
540 545
541struct nv04_mode_state { 546struct nv04_mode_state {
542 uint32_t bpp; 547 struct nv04_crtc_reg crtc_reg[2];
543 uint32_t width;
544 uint32_t height;
545 uint32_t interlace;
546 uint32_t repaint0;
547 uint32_t repaint1;
548 uint32_t screen;
549 uint32_t scale;
550 uint32_t dither;
551 uint32_t extra;
552 uint32_t fifo;
553 uint32_t pixel;
554 uint32_t horiz;
555 int arbitration0;
556 int arbitration1;
557 uint32_t pll;
558 uint32_t pllB;
559 uint32_t vpll;
560 uint32_t vpll2;
561 uint32_t vpllB;
562 uint32_t vpll2B;
563 uint32_t pllsel; 548 uint32_t pllsel;
564 uint32_t sel_clk; 549 uint32_t sel_clk;
565 uint32_t general;
566 uint32_t crtcOwner;
567 uint32_t head;
568 uint32_t head2;
569 uint32_t cursorConfig;
570 uint32_t cursor0;
571 uint32_t cursor1;
572 uint32_t cursor2;
573 uint32_t timingH;
574 uint32_t timingV;
575 uint32_t displayV;
576 uint32_t crtcSync;
577
578 struct nv04_crtc_reg crtc_reg[2];
579}; 550};
580 551
581enum nouveau_card_type { 552enum nouveau_card_type {
@@ -613,6 +584,12 @@ struct drm_nouveau_private {
613 struct work_struct irq_work; 584 struct work_struct irq_work;
614 struct work_struct hpd_work; 585 struct work_struct hpd_work;
615 586
587 struct {
588 spinlock_t lock;
589 uint32_t hpd0_bits;
590 uint32_t hpd1_bits;
591 } hpd_state;
592
616 struct list_head vbl_waiting; 593 struct list_head vbl_waiting;
617 594
618 struct { 595 struct {
@@ -1045,6 +1022,7 @@ extern int nv50_fifo_create_context(struct nouveau_channel *);
1045extern void nv50_fifo_destroy_context(struct nouveau_channel *); 1022extern void nv50_fifo_destroy_context(struct nouveau_channel *);
1046extern int nv50_fifo_load_context(struct nouveau_channel *); 1023extern int nv50_fifo_load_context(struct nouveau_channel *);
1047extern int nv50_fifo_unload_context(struct drm_device *); 1024extern int nv50_fifo_unload_context(struct drm_device *);
1025extern void nv50_fifo_tlb_flush(struct drm_device *dev);
1048 1026
1049/* nvc0_fifo.c */ 1027/* nvc0_fifo.c */
1050extern int nvc0_fifo_init(struct drm_device *); 1028extern int nvc0_fifo_init(struct drm_device *);
@@ -1122,6 +1100,8 @@ extern int nv50_graph_load_context(struct nouveau_channel *);
1122extern int nv50_graph_unload_context(struct drm_device *); 1100extern int nv50_graph_unload_context(struct drm_device *);
1123extern void nv50_graph_context_switch(struct drm_device *); 1101extern void nv50_graph_context_switch(struct drm_device *);
1124extern int nv50_grctx_init(struct nouveau_grctx *); 1102extern int nv50_grctx_init(struct nouveau_grctx *);
1103extern void nv50_graph_tlb_flush(struct drm_device *dev);
1104extern void nv86_graph_tlb_flush(struct drm_device *dev);
1125 1105
1126/* nvc0_graph.c */ 1106/* nvc0_graph.c */
1127extern int nvc0_graph_init(struct drm_device *); 1107extern int nvc0_graph_init(struct drm_device *);
@@ -1239,7 +1219,6 @@ extern u16 nouveau_bo_rd16(struct nouveau_bo *nvbo, unsigned index);
1239extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val); 1219extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val);
1240extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index); 1220extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index);
1241extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val); 1221extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val);
1242extern int nouveau_bo_sync_gpu(struct nouveau_bo *, struct nouveau_channel *);
1243 1222
1244/* nouveau_fence.c */ 1223/* nouveau_fence.c */
1245struct nouveau_fence; 1224struct nouveau_fence;
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 441b12420bb1..ab1bbfbf266e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -249,6 +249,7 @@ alloc_semaphore(struct drm_device *dev)
249{ 249{
250 struct drm_nouveau_private *dev_priv = dev->dev_private; 250 struct drm_nouveau_private *dev_priv = dev->dev_private;
251 struct nouveau_semaphore *sema; 251 struct nouveau_semaphore *sema;
252 int ret;
252 253
253 if (!USE_SEMA(dev)) 254 if (!USE_SEMA(dev))
254 return NULL; 255 return NULL;
@@ -257,10 +258,14 @@ alloc_semaphore(struct drm_device *dev)
257 if (!sema) 258 if (!sema)
258 goto fail; 259 goto fail;
259 260
261 ret = drm_mm_pre_get(&dev_priv->fence.heap);
262 if (ret)
263 goto fail;
264
260 spin_lock(&dev_priv->fence.lock); 265 spin_lock(&dev_priv->fence.lock);
261 sema->mem = drm_mm_search_free(&dev_priv->fence.heap, 4, 0, 0); 266 sema->mem = drm_mm_search_free(&dev_priv->fence.heap, 4, 0, 0);
262 if (sema->mem) 267 if (sema->mem)
263 sema->mem = drm_mm_get_block(sema->mem, 4, 0); 268 sema->mem = drm_mm_get_block_atomic(sema->mem, 4, 0);
264 spin_unlock(&dev_priv->fence.lock); 269 spin_unlock(&dev_priv->fence.lock);
265 270
266 if (!sema->mem) 271 if (!sema->mem)
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 5c4c929d7f74..9a1fdcf400c2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -107,23 +107,29 @@ nouveau_gem_info(struct drm_gem_object *gem, struct drm_nouveau_gem_info *rep)
107} 107}
108 108
109static bool 109static bool
110nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) { 110nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags)
111 switch (tile_flags) { 111{
112 case 0x0000: 112 struct drm_nouveau_private *dev_priv = dev->dev_private;
113 case 0x1800: 113
114 case 0x2800: 114 if (dev_priv->card_type >= NV_50) {
115 case 0x4800: 115 switch (tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) {
116 case 0x7000: 116 case 0x0000:
117 case 0x7400: 117 case 0x1800:
118 case 0x7a00: 118 case 0x2800:
119 case 0xe000: 119 case 0x4800:
120 break; 120 case 0x7000:
121 default: 121 case 0x7400:
122 NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags); 122 case 0x7a00:
123 return false; 123 case 0xe000:
124 return true;
125 }
126 } else {
127 if (!(tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK))
128 return true;
124 } 129 }
125 130
126 return true; 131 NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags);
132 return false;
127} 133}
128 134
129int 135int
diff --git a/drivers/gpu/drm/nouveau/nouveau_hw.c b/drivers/gpu/drm/nouveau/nouveau_hw.c
index bed669a54a2d..b9672a05c411 100644
--- a/drivers/gpu/drm/nouveau/nouveau_hw.c
+++ b/drivers/gpu/drm/nouveau/nouveau_hw.c
@@ -519,11 +519,11 @@ nouveau_hw_fix_bad_vpll(struct drm_device *dev, int head)
519 519
520 struct pll_lims pll_lim; 520 struct pll_lims pll_lim;
521 struct nouveau_pll_vals pv; 521 struct nouveau_pll_vals pv;
522 uint32_t pllreg = head ? NV_RAMDAC_VPLL2 : NV_PRAMDAC_VPLL_COEFF; 522 enum pll_types pll = head ? PLL_VPLL1 : PLL_VPLL0;
523 523
524 if (get_pll_limits(dev, pllreg, &pll_lim)) 524 if (get_pll_limits(dev, pll, &pll_lim))
525 return; 525 return;
526 nouveau_hw_get_pllvals(dev, pllreg, &pv); 526 nouveau_hw_get_pllvals(dev, pll, &pv);
527 527
528 if (pv.M1 >= pll_lim.vco1.min_m && pv.M1 <= pll_lim.vco1.max_m && 528 if (pv.M1 >= pll_lim.vco1.min_m && pv.M1 <= pll_lim.vco1.max_m &&
529 pv.N1 >= pll_lim.vco1.min_n && pv.N1 <= pll_lim.vco1.max_n && 529 pv.N1 >= pll_lim.vco1.min_n && pv.N1 <= pll_lim.vco1.max_n &&
@@ -536,7 +536,7 @@ nouveau_hw_fix_bad_vpll(struct drm_device *dev, int head)
536 pv.M1 = pll_lim.vco1.max_m; 536 pv.M1 = pll_lim.vco1.max_m;
537 pv.N1 = pll_lim.vco1.min_n; 537 pv.N1 = pll_lim.vco1.min_n;
538 pv.log2P = pll_lim.max_usable_log2p; 538 pv.log2P = pll_lim.max_usable_log2p;
539 nouveau_hw_setpll(dev, pllreg, &pv); 539 nouveau_hw_setpll(dev, pll_lim.reg, &pv);
540} 540}
541 541
542/* 542/*
diff --git a/drivers/gpu/drm/nouveau/nouveau_hw.h b/drivers/gpu/drm/nouveau/nouveau_hw.h
index 869130f83602..2989090b9434 100644
--- a/drivers/gpu/drm/nouveau/nouveau_hw.h
+++ b/drivers/gpu/drm/nouveau/nouveau_hw.h
@@ -416,6 +416,25 @@ nv_fix_nv40_hw_cursor(struct drm_device *dev, int head)
416} 416}
417 417
418static inline void 418static inline void
419nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset)
420{
421 struct drm_nouveau_private *dev_priv = dev->dev_private;
422
423 NVWriteCRTC(dev, head, NV_PCRTC_START, offset);
424
425 if (dev_priv->card_type == NV_04) {
426 /*
427 * Hilarious, the 24th bit doesn't want to stick to
428 * PCRTC_START...
429 */
430 int cre_heb = NVReadVgaCrtc(dev, head, NV_CIO_CRE_HEB__INDEX);
431
432 NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HEB__INDEX,
433 (cre_heb & ~0x40) | ((offset >> 18) & 0x40));
434 }
435}
436
437static inline void
419nv_show_cursor(struct drm_device *dev, int head, bool show) 438nv_show_cursor(struct drm_device *dev, int head, bool show)
420{ 439{
421 struct drm_nouveau_private *dev_priv = dev->dev_private; 440 struct drm_nouveau_private *dev_priv = dev->dev_private;
diff --git a/drivers/gpu/drm/nouveau/nouveau_i2c.c b/drivers/gpu/drm/nouveau/nouveau_i2c.c
index fdd7e3de79c8..cb389d014326 100644
--- a/drivers/gpu/drm/nouveau/nouveau_i2c.c
+++ b/drivers/gpu/drm/nouveau/nouveau_i2c.c
@@ -256,7 +256,7 @@ nouveau_i2c_find(struct drm_device *dev, int index)
256 if (index >= DCB_MAX_NUM_I2C_ENTRIES) 256 if (index >= DCB_MAX_NUM_I2C_ENTRIES)
257 return NULL; 257 return NULL;
258 258
259 if (dev_priv->chipset >= NV_50 && (i2c->entry & 0x00000100)) { 259 if (dev_priv->card_type >= NV_50 && (i2c->entry & 0x00000100)) {
260 uint32_t reg = 0xe500, val; 260 uint32_t reg = 0xe500, val;
261 261
262 if (i2c->port_type == 6) { 262 if (i2c->port_type == 6) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_irq.c b/drivers/gpu/drm/nouveau/nouveau_irq.c
index 6fd51a51c608..7bfd9e6c9d67 100644
--- a/drivers/gpu/drm/nouveau/nouveau_irq.c
+++ b/drivers/gpu/drm/nouveau/nouveau_irq.c
@@ -42,6 +42,13 @@
42#include "nouveau_connector.h" 42#include "nouveau_connector.h"
43#include "nv50_display.h" 43#include "nv50_display.h"
44 44
45static DEFINE_RATELIMIT_STATE(nouveau_ratelimit_state, 3 * HZ, 20);
46
47static int nouveau_ratelimit(void)
48{
49 return __ratelimit(&nouveau_ratelimit_state);
50}
51
45void 52void
46nouveau_irq_preinstall(struct drm_device *dev) 53nouveau_irq_preinstall(struct drm_device *dev)
47{ 54{
@@ -53,6 +60,7 @@ nouveau_irq_preinstall(struct drm_device *dev)
53 if (dev_priv->card_type >= NV_50) { 60 if (dev_priv->card_type >= NV_50) {
54 INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh); 61 INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh);
55 INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh); 62 INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh);
63 spin_lock_init(&dev_priv->hpd_state.lock);
56 INIT_LIST_HEAD(&dev_priv->vbl_waiting); 64 INIT_LIST_HEAD(&dev_priv->vbl_waiting);
57 } 65 }
58} 66}
@@ -202,8 +210,8 @@ nouveau_fifo_irq_handler(struct drm_device *dev)
202 } 210 }
203 211
204 if (status & NV_PFIFO_INTR_DMA_PUSHER) { 212 if (status & NV_PFIFO_INTR_DMA_PUSHER) {
205 u32 get = nv_rd32(dev, 0x003244); 213 u32 dma_get = nv_rd32(dev, 0x003244);
206 u32 put = nv_rd32(dev, 0x003240); 214 u32 dma_put = nv_rd32(dev, 0x003240);
207 u32 push = nv_rd32(dev, 0x003220); 215 u32 push = nv_rd32(dev, 0x003220);
208 u32 state = nv_rd32(dev, 0x003228); 216 u32 state = nv_rd32(dev, 0x003228);
209 217
@@ -213,16 +221,18 @@ nouveau_fifo_irq_handler(struct drm_device *dev)
213 u32 ib_get = nv_rd32(dev, 0x003334); 221 u32 ib_get = nv_rd32(dev, 0x003334);
214 u32 ib_put = nv_rd32(dev, 0x003330); 222 u32 ib_put = nv_rd32(dev, 0x003330);
215 223
216 NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%02x%08x " 224 if (nouveau_ratelimit())
225 NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%02x%08x "
217 "Put 0x%02x%08x IbGet 0x%08x IbPut 0x%08x " 226 "Put 0x%02x%08x IbGet 0x%08x IbPut 0x%08x "
218 "State 0x%08x Push 0x%08x\n", 227 "State 0x%08x Push 0x%08x\n",
219 chid, ho_get, get, ho_put, put, ib_get, ib_put, 228 chid, ho_get, dma_get, ho_put,
220 state, push); 229 dma_put, ib_get, ib_put, state,
230 push);
221 231
222 /* METHOD_COUNT, in DMA_STATE on earlier chipsets */ 232 /* METHOD_COUNT, in DMA_STATE on earlier chipsets */
223 nv_wr32(dev, 0x003364, 0x00000000); 233 nv_wr32(dev, 0x003364, 0x00000000);
224 if (get != put || ho_get != ho_put) { 234 if (dma_get != dma_put || ho_get != ho_put) {
225 nv_wr32(dev, 0x003244, put); 235 nv_wr32(dev, 0x003244, dma_put);
226 nv_wr32(dev, 0x003328, ho_put); 236 nv_wr32(dev, 0x003328, ho_put);
227 } else 237 } else
228 if (ib_get != ib_put) { 238 if (ib_get != ib_put) {
@@ -231,10 +241,10 @@ nouveau_fifo_irq_handler(struct drm_device *dev)
231 } else { 241 } else {
232 NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%08x " 242 NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%08x "
233 "Put 0x%08x State 0x%08x Push 0x%08x\n", 243 "Put 0x%08x State 0x%08x Push 0x%08x\n",
234 chid, get, put, state, push); 244 chid, dma_get, dma_put, state, push);
235 245
236 if (get != put) 246 if (dma_get != dma_put)
237 nv_wr32(dev, 0x003244, put); 247 nv_wr32(dev, 0x003244, dma_put);
238 } 248 }
239 249
240 nv_wr32(dev, 0x003228, 0x00000000); 250 nv_wr32(dev, 0x003228, 0x00000000);
@@ -266,8 +276,9 @@ nouveau_fifo_irq_handler(struct drm_device *dev)
266 } 276 }
267 277
268 if (status) { 278 if (status) {
269 NV_INFO(dev, "PFIFO_INTR 0x%08x - Ch %d\n", 279 if (nouveau_ratelimit())
270 status, chid); 280 NV_INFO(dev, "PFIFO_INTR 0x%08x - Ch %d\n",
281 status, chid);
271 nv_wr32(dev, NV03_PFIFO_INTR_0, status); 282 nv_wr32(dev, NV03_PFIFO_INTR_0, status);
272 status = 0; 283 status = 0;
273 } 284 }
@@ -544,13 +555,6 @@ nouveau_pgraph_intr_notify(struct drm_device *dev, uint32_t nsource)
544 nouveau_graph_dump_trap_info(dev, "PGRAPH_NOTIFY", &trap); 555 nouveau_graph_dump_trap_info(dev, "PGRAPH_NOTIFY", &trap);
545} 556}
546 557
547static DEFINE_RATELIMIT_STATE(nouveau_ratelimit_state, 3 * HZ, 20);
548
549static int nouveau_ratelimit(void)
550{
551 return __ratelimit(&nouveau_ratelimit_state);
552}
553
554 558
555static inline void 559static inline void
556nouveau_pgraph_intr_error(struct drm_device *dev, uint32_t nsource) 560nouveau_pgraph_intr_error(struct drm_device *dev, uint32_t nsource)
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index a163c7c612e7..fe4a30dc4b42 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -33,9 +33,9 @@
33#include "drmP.h" 33#include "drmP.h"
34#include "drm.h" 34#include "drm.h"
35#include "drm_sarea.h" 35#include "drm_sarea.h"
36#include "nouveau_drv.h"
37 36
38#define MIN(a,b) a < b ? a : b 37#include "nouveau_drv.h"
38#include "nouveau_pm.h"
39 39
40/* 40/*
41 * NV10-NV40 tiling helpers 41 * NV10-NV40 tiling helpers
@@ -175,11 +175,10 @@ nv50_mem_vm_bind_linear(struct drm_device *dev, uint64_t virt, uint32_t size,
175 } 175 }
176 } 176 }
177 } 177 }
178 dev_priv->engine.instmem.flush(dev);
179 178
180 nv50_vm_flush(dev, 5); 179 dev_priv->engine.instmem.flush(dev);
181 nv50_vm_flush(dev, 0); 180 dev_priv->engine.fifo.tlb_flush(dev);
182 nv50_vm_flush(dev, 4); 181 dev_priv->engine.graph.tlb_flush(dev);
183 nv50_vm_flush(dev, 6); 182 nv50_vm_flush(dev, 6);
184 return 0; 183 return 0;
185} 184}
@@ -209,11 +208,10 @@ nv50_mem_vm_unbind(struct drm_device *dev, uint64_t virt, uint32_t size)
209 pte++; 208 pte++;
210 } 209 }
211 } 210 }
212 dev_priv->engine.instmem.flush(dev);
213 211
214 nv50_vm_flush(dev, 5); 212 dev_priv->engine.instmem.flush(dev);
215 nv50_vm_flush(dev, 0); 213 dev_priv->engine.fifo.tlb_flush(dev);
216 nv50_vm_flush(dev, 4); 214 dev_priv->engine.graph.tlb_flush(dev);
217 nv50_vm_flush(dev, 6); 215 nv50_vm_flush(dev, 6);
218} 216}
219 217
@@ -653,6 +651,7 @@ nouveau_mem_gart_init(struct drm_device *dev)
653void 651void
654nouveau_mem_timing_init(struct drm_device *dev) 652nouveau_mem_timing_init(struct drm_device *dev)
655{ 653{
654 /* cards < NVC0 only */
656 struct drm_nouveau_private *dev_priv = dev->dev_private; 655 struct drm_nouveau_private *dev_priv = dev->dev_private;
657 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 656 struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
658 struct nouveau_pm_memtimings *memtimings = &pm->memtimings; 657 struct nouveau_pm_memtimings *memtimings = &pm->memtimings;
@@ -719,14 +718,14 @@ nouveau_mem_timing_init(struct drm_device *dev)
719 tUNK_19 = 1; 718 tUNK_19 = 1;
720 tUNK_20 = 0; 719 tUNK_20 = 0;
721 tUNK_21 = 0; 720 tUNK_21 = 0;
722 switch (MIN(recordlen,21)) { 721 switch (min(recordlen, 22)) {
723 case 21: 722 case 22:
724 tUNK_21 = entry[21]; 723 tUNK_21 = entry[21];
725 case 20: 724 case 21:
726 tUNK_20 = entry[20]; 725 tUNK_20 = entry[20];
727 case 19: 726 case 20:
728 tUNK_19 = entry[19]; 727 tUNK_19 = entry[19];
729 case 18: 728 case 19:
730 tUNK_18 = entry[18]; 729 tUNK_18 = entry[18];
731 default: 730 default:
732 tUNK_0 = entry[0]; 731 tUNK_0 = entry[0];
@@ -756,24 +755,30 @@ nouveau_mem_timing_init(struct drm_device *dev)
756 timing->reg_100228 = (tUNK_12 << 16 | tUNK_11 << 8 | tUNK_10); 755 timing->reg_100228 = (tUNK_12 << 16 | tUNK_11 << 8 | tUNK_10);
757 if(recordlen > 19) { 756 if(recordlen > 19) {
758 timing->reg_100228 += (tUNK_19 - 1) << 24; 757 timing->reg_100228 += (tUNK_19 - 1) << 24;
759 } else { 758 }/* I cannot back-up this else-statement right now
759 else {
760 timing->reg_100228 += tUNK_12 << 24; 760 timing->reg_100228 += tUNK_12 << 24;
761 } 761 }*/
762 762
763 /* XXX: reg_10022c */ 763 /* XXX: reg_10022c */
764 timing->reg_10022c = tUNK_2 - 1;
764 765
765 timing->reg_100230 = (tUNK_20 << 24 | tUNK_21 << 16 | 766 timing->reg_100230 = (tUNK_20 << 24 | tUNK_21 << 16 |
766 tUNK_13 << 8 | tUNK_13); 767 tUNK_13 << 8 | tUNK_13);
767 768
768 /* XXX: +6? */ 769 /* XXX: +6? */
769 timing->reg_100234 = (tRAS << 24 | (tUNK_19 + 6) << 8 | tRC); 770 timing->reg_100234 = (tRAS << 24 | (tUNK_19 + 6) << 8 | tRC);
770 if(tUNK_10 > tUNK_11) { 771 timing->reg_100234 += max(tUNK_10,tUNK_11) << 16;
771 timing->reg_100234 += tUNK_10 << 16; 772
772 } else { 773 /* XXX; reg_100238, reg_10023c
773 timing->reg_100234 += tUNK_11 << 16; 774 * reg: 0x00??????
775 * reg_10023c:
776 * 0 for pre-NV50 cards
777 * 0x????0202 for NV50+ cards (empirical evidence) */
778 if(dev_priv->card_type >= NV_50) {
779 timing->reg_10023c = 0x202;
774 } 780 }
775 781
776 /* XXX; reg_100238, reg_10023c */
777 NV_DEBUG(dev, "Entry %d: 220: %08x %08x %08x %08x\n", i, 782 NV_DEBUG(dev, "Entry %d: 220: %08x %08x %08x %08x\n", i,
778 timing->reg_100220, timing->reg_100224, 783 timing->reg_100220, timing->reg_100224,
779 timing->reg_100228, timing->reg_10022c); 784 timing->reg_100228, timing->reg_10022c);
diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c
index 896cf8634144..dd572adca02a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_object.c
+++ b/drivers/gpu/drm/nouveau/nouveau_object.c
@@ -129,7 +129,7 @@ nouveau_gpuobj_new(struct drm_device *dev, struct nouveau_channel *chan,
129 if (ramin == NULL) { 129 if (ramin == NULL) {
130 spin_unlock(&dev_priv->ramin_lock); 130 spin_unlock(&dev_priv->ramin_lock);
131 nouveau_gpuobj_ref(NULL, &gpuobj); 131 nouveau_gpuobj_ref(NULL, &gpuobj);
132 return ret; 132 return -ENOMEM;
133 } 133 }
134 134
135 ramin = drm_mm_get_block_atomic(ramin, size, align); 135 ramin = drm_mm_get_block_atomic(ramin, size, align);
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c
index 1c99c55d6d46..9f7b158f5825 100644
--- a/drivers/gpu/drm/nouveau/nouveau_pm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_pm.c
@@ -284,6 +284,7 @@ nouveau_sysfs_fini(struct drm_device *dev)
284 } 284 }
285} 285}
286 286
287#ifdef CONFIG_HWMON
287static ssize_t 288static ssize_t
288nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf) 289nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf)
289{ 290{
@@ -395,10 +396,12 @@ static struct attribute *hwmon_attributes[] = {
395static const struct attribute_group hwmon_attrgroup = { 396static const struct attribute_group hwmon_attrgroup = {
396 .attrs = hwmon_attributes, 397 .attrs = hwmon_attributes,
397}; 398};
399#endif
398 400
399static int 401static int
400nouveau_hwmon_init(struct drm_device *dev) 402nouveau_hwmon_init(struct drm_device *dev)
401{ 403{
404#ifdef CONFIG_HWMON
402 struct drm_nouveau_private *dev_priv = dev->dev_private; 405 struct drm_nouveau_private *dev_priv = dev->dev_private;
403 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 406 struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
404 struct device *hwmon_dev; 407 struct device *hwmon_dev;
@@ -425,13 +428,14 @@ nouveau_hwmon_init(struct drm_device *dev)
425 } 428 }
426 429
427 pm->hwmon = hwmon_dev; 430 pm->hwmon = hwmon_dev;
428 431#endif
429 return 0; 432 return 0;
430} 433}
431 434
432static void 435static void
433nouveau_hwmon_fini(struct drm_device *dev) 436nouveau_hwmon_fini(struct drm_device *dev)
434{ 437{
438#ifdef CONFIG_HWMON
435 struct drm_nouveau_private *dev_priv = dev->dev_private; 439 struct drm_nouveau_private *dev_priv = dev->dev_private;
436 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 440 struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
437 441
@@ -439,6 +443,7 @@ nouveau_hwmon_fini(struct drm_device *dev)
439 sysfs_remove_group(&pm->hwmon->kobj, &hwmon_attrgroup); 443 sysfs_remove_group(&pm->hwmon->kobj, &hwmon_attrgroup);
440 hwmon_device_unregister(pm->hwmon); 444 hwmon_device_unregister(pm->hwmon);
441 } 445 }
446#endif
442} 447}
443 448
444int 449int
diff --git a/drivers/gpu/drm/nouveau/nouveau_ramht.c b/drivers/gpu/drm/nouveau/nouveau_ramht.c
index 7f16697cc96c..2d8580927ca4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ramht.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ramht.c
@@ -153,26 +153,42 @@ nouveau_ramht_insert(struct nouveau_channel *chan, u32 handle,
153 return -ENOMEM; 153 return -ENOMEM;
154} 154}
155 155
156static struct nouveau_ramht_entry *
157nouveau_ramht_remove_entry(struct nouveau_channel *chan, u32 handle)
158{
159 struct nouveau_ramht *ramht = chan ? chan->ramht : NULL;
160 struct nouveau_ramht_entry *entry;
161 unsigned long flags;
162
163 if (!ramht)
164 return NULL;
165
166 spin_lock_irqsave(&ramht->lock, flags);
167 list_for_each_entry(entry, &ramht->entries, head) {
168 if (entry->channel == chan &&
169 (!handle || entry->handle == handle)) {
170 list_del(&entry->head);
171 spin_unlock_irqrestore(&ramht->lock, flags);
172
173 return entry;
174 }
175 }
176 spin_unlock_irqrestore(&ramht->lock, flags);
177
178 return NULL;
179}
180
156static void 181static void
157nouveau_ramht_remove_locked(struct nouveau_channel *chan, u32 handle) 182nouveau_ramht_remove_hash(struct nouveau_channel *chan, u32 handle)
158{ 183{
159 struct drm_device *dev = chan->dev; 184 struct drm_device *dev = chan->dev;
160 struct drm_nouveau_private *dev_priv = dev->dev_private; 185 struct drm_nouveau_private *dev_priv = dev->dev_private;
161 struct nouveau_instmem_engine *instmem = &dev_priv->engine.instmem; 186 struct nouveau_instmem_engine *instmem = &dev_priv->engine.instmem;
162 struct nouveau_gpuobj *ramht = chan->ramht->gpuobj; 187 struct nouveau_gpuobj *ramht = chan->ramht->gpuobj;
163 struct nouveau_ramht_entry *entry, *tmp; 188 unsigned long flags;
164 u32 co, ho; 189 u32 co, ho;
165 190
166 list_for_each_entry_safe(entry, tmp, &chan->ramht->entries, head) { 191 spin_lock_irqsave(&chan->ramht->lock, flags);
167 if (entry->channel != chan || entry->handle != handle)
168 continue;
169
170 nouveau_gpuobj_ref(NULL, &entry->gpuobj);
171 list_del(&entry->head);
172 kfree(entry);
173 break;
174 }
175
176 co = ho = nouveau_ramht_hash_handle(chan, handle); 192 co = ho = nouveau_ramht_hash_handle(chan, handle);
177 do { 193 do {
178 if (nouveau_ramht_entry_valid(dev, ramht, co) && 194 if (nouveau_ramht_entry_valid(dev, ramht, co) &&
@@ -184,7 +200,7 @@ nouveau_ramht_remove_locked(struct nouveau_channel *chan, u32 handle)
184 nv_wo32(ramht, co + 0, 0x00000000); 200 nv_wo32(ramht, co + 0, 0x00000000);
185 nv_wo32(ramht, co + 4, 0x00000000); 201 nv_wo32(ramht, co + 4, 0x00000000);
186 instmem->flush(dev); 202 instmem->flush(dev);
187 return; 203 goto out;
188 } 204 }
189 205
190 co += 8; 206 co += 8;
@@ -194,17 +210,22 @@ nouveau_ramht_remove_locked(struct nouveau_channel *chan, u32 handle)
194 210
195 NV_ERROR(dev, "RAMHT entry not found. ch=%d, handle=0x%08x\n", 211 NV_ERROR(dev, "RAMHT entry not found. ch=%d, handle=0x%08x\n",
196 chan->id, handle); 212 chan->id, handle);
213out:
214 spin_unlock_irqrestore(&chan->ramht->lock, flags);
197} 215}
198 216
199void 217void
200nouveau_ramht_remove(struct nouveau_channel *chan, u32 handle) 218nouveau_ramht_remove(struct nouveau_channel *chan, u32 handle)
201{ 219{
202 struct nouveau_ramht *ramht = chan->ramht; 220 struct nouveau_ramht_entry *entry;
203 unsigned long flags;
204 221
205 spin_lock_irqsave(&ramht->lock, flags); 222 entry = nouveau_ramht_remove_entry(chan, handle);
206 nouveau_ramht_remove_locked(chan, handle); 223 if (!entry)
207 spin_unlock_irqrestore(&ramht->lock, flags); 224 return;
225
226 nouveau_ramht_remove_hash(chan, entry->handle);
227 nouveau_gpuobj_ref(NULL, &entry->gpuobj);
228 kfree(entry);
208} 229}
209 230
210struct nouveau_gpuobj * 231struct nouveau_gpuobj *
@@ -265,23 +286,19 @@ void
265nouveau_ramht_ref(struct nouveau_ramht *ref, struct nouveau_ramht **ptr, 286nouveau_ramht_ref(struct nouveau_ramht *ref, struct nouveau_ramht **ptr,
266 struct nouveau_channel *chan) 287 struct nouveau_channel *chan)
267{ 288{
268 struct nouveau_ramht_entry *entry, *tmp; 289 struct nouveau_ramht_entry *entry;
269 struct nouveau_ramht *ramht; 290 struct nouveau_ramht *ramht;
270 unsigned long flags;
271 291
272 if (ref) 292 if (ref)
273 kref_get(&ref->refcount); 293 kref_get(&ref->refcount);
274 294
275 ramht = *ptr; 295 ramht = *ptr;
276 if (ramht) { 296 if (ramht) {
277 spin_lock_irqsave(&ramht->lock, flags); 297 while ((entry = nouveau_ramht_remove_entry(chan, 0))) {
278 list_for_each_entry_safe(entry, tmp, &ramht->entries, head) { 298 nouveau_ramht_remove_hash(chan, entry->handle);
279 if (entry->channel != chan) 299 nouveau_gpuobj_ref(NULL, &entry->gpuobj);
280 continue; 300 kfree(entry);
281
282 nouveau_ramht_remove_locked(chan, entry->handle);
283 } 301 }
284 spin_unlock_irqrestore(&ramht->lock, flags);
285 302
286 kref_put(&ramht->refcount, nouveau_ramht_del); 303 kref_put(&ramht->refcount, nouveau_ramht_del);
287 } 304 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index 288bacac7e5a..d4ac97007038 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -120,8 +120,8 @@ nouveau_sgdma_bind(struct ttm_backend *be, struct ttm_mem_reg *mem)
120 dev_priv->engine.instmem.flush(nvbe->dev); 120 dev_priv->engine.instmem.flush(nvbe->dev);
121 121
122 if (dev_priv->card_type == NV_50) { 122 if (dev_priv->card_type == NV_50) {
123 nv50_vm_flush(dev, 5); /* PGRAPH */ 123 dev_priv->engine.fifo.tlb_flush(dev);
124 nv50_vm_flush(dev, 0); /* PFIFO */ 124 dev_priv->engine.graph.tlb_flush(dev);
125 } 125 }
126 126
127 nvbe->bound = true; 127 nvbe->bound = true;
@@ -162,8 +162,8 @@ nouveau_sgdma_unbind(struct ttm_backend *be)
162 dev_priv->engine.instmem.flush(nvbe->dev); 162 dev_priv->engine.instmem.flush(nvbe->dev);
163 163
164 if (dev_priv->card_type == NV_50) { 164 if (dev_priv->card_type == NV_50) {
165 nv50_vm_flush(dev, 5); 165 dev_priv->engine.fifo.tlb_flush(dev);
166 nv50_vm_flush(dev, 0); 166 dev_priv->engine.graph.tlb_flush(dev);
167 } 167 }
168 168
169 nvbe->bound = false; 169 nvbe->bound = false;
@@ -224,7 +224,11 @@ nouveau_sgdma_init(struct drm_device *dev)
224 int i, ret; 224 int i, ret;
225 225
226 if (dev_priv->card_type < NV_50) { 226 if (dev_priv->card_type < NV_50) {
227 aper_size = (64 * 1024 * 1024); 227 if(dev_priv->ramin_rsvd_vram < 2 * 1024 * 1024)
228 aper_size = 64 * 1024 * 1024;
229 else
230 aper_size = 512 * 1024 * 1024;
231
228 obj_size = (aper_size >> NV_CTXDMA_PAGE_SHIFT) * 4; 232 obj_size = (aper_size >> NV_CTXDMA_PAGE_SHIFT) * 4;
229 obj_size += 8; /* ctxdma header */ 233 obj_size += 8; /* ctxdma header */
230 } else { 234 } else {
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index ed7757f14083..049f755567e5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -354,6 +354,15 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
354 engine->graph.destroy_context = nv50_graph_destroy_context; 354 engine->graph.destroy_context = nv50_graph_destroy_context;
355 engine->graph.load_context = nv50_graph_load_context; 355 engine->graph.load_context = nv50_graph_load_context;
356 engine->graph.unload_context = nv50_graph_unload_context; 356 engine->graph.unload_context = nv50_graph_unload_context;
357 if (dev_priv->chipset != 0x86)
358 engine->graph.tlb_flush = nv50_graph_tlb_flush;
359 else {
360 /* from what i can see nvidia do this on every
361 * pre-NVA3 board except NVAC, but, we've only
362 * ever seen problems on NV86
363 */
364 engine->graph.tlb_flush = nv86_graph_tlb_flush;
365 }
357 engine->fifo.channels = 128; 366 engine->fifo.channels = 128;
358 engine->fifo.init = nv50_fifo_init; 367 engine->fifo.init = nv50_fifo_init;
359 engine->fifo.takedown = nv50_fifo_takedown; 368 engine->fifo.takedown = nv50_fifo_takedown;
@@ -365,6 +374,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
365 engine->fifo.destroy_context = nv50_fifo_destroy_context; 374 engine->fifo.destroy_context = nv50_fifo_destroy_context;
366 engine->fifo.load_context = nv50_fifo_load_context; 375 engine->fifo.load_context = nv50_fifo_load_context;
367 engine->fifo.unload_context = nv50_fifo_unload_context; 376 engine->fifo.unload_context = nv50_fifo_unload_context;
377 engine->fifo.tlb_flush = nv50_fifo_tlb_flush;
368 engine->display.early_init = nv50_display_early_init; 378 engine->display.early_init = nv50_display_early_init;
369 engine->display.late_takedown = nv50_display_late_takedown; 379 engine->display.late_takedown = nv50_display_late_takedown;
370 engine->display.create = nv50_display_create; 380 engine->display.create = nv50_display_create;
@@ -1041,6 +1051,9 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data,
1041 case NOUVEAU_GETPARAM_PTIMER_TIME: 1051 case NOUVEAU_GETPARAM_PTIMER_TIME:
1042 getparam->value = dev_priv->engine.timer.read(dev); 1052 getparam->value = dev_priv->engine.timer.read(dev);
1043 break; 1053 break;
1054 case NOUVEAU_GETPARAM_HAS_BO_USAGE:
1055 getparam->value = 1;
1056 break;
1044 case NOUVEAU_GETPARAM_GRAPH_UNITS: 1057 case NOUVEAU_GETPARAM_GRAPH_UNITS:
1045 /* NV40 and NV50 versions are quite different, but register 1058 /* NV40 and NV50 versions are quite different, but register
1046 * address is the same. User is supposed to know the card 1059 * address is the same. User is supposed to know the card
@@ -1051,7 +1064,7 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data,
1051 } 1064 }
1052 /* FALLTHRU */ 1065 /* FALLTHRU */
1053 default: 1066 default:
1054 NV_ERROR(dev, "unknown parameter %lld\n", getparam->param); 1067 NV_DEBUG(dev, "unknown parameter %lld\n", getparam->param);
1055 return -EINVAL; 1068 return -EINVAL;
1056 } 1069 }
1057 1070
@@ -1066,7 +1079,7 @@ nouveau_ioctl_setparam(struct drm_device *dev, void *data,
1066 1079
1067 switch (setparam->param) { 1080 switch (setparam->param) {
1068 default: 1081 default:
1069 NV_ERROR(dev, "unknown parameter %lld\n", setparam->param); 1082 NV_DEBUG(dev, "unknown parameter %lld\n", setparam->param);
1070 return -EINVAL; 1083 return -EINVAL;
1071 } 1084 }
1072 1085
diff --git a/drivers/gpu/drm/nouveau/nouveau_temp.c b/drivers/gpu/drm/nouveau/nouveau_temp.c
index 16bbbf1eff63..7ecc4adc1e45 100644
--- a/drivers/gpu/drm/nouveau/nouveau_temp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_temp.c
@@ -191,7 +191,7 @@ nv40_temp_get(struct drm_device *dev)
191 int offset = sensor->offset_mult / sensor->offset_div; 191 int offset = sensor->offset_mult / sensor->offset_div;
192 int core_temp; 192 int core_temp;
193 193
194 if (dev_priv->chipset >= 0x50) { 194 if (dev_priv->card_type >= NV_50) {
195 core_temp = nv_rd32(dev, 0x20008); 195 core_temp = nv_rd32(dev, 0x20008);
196 } else { 196 } else {
197 core_temp = nv_rd32(dev, 0x0015b4) & 0x1fff; 197 core_temp = nv_rd32(dev, 0x0015b4) & 0x1fff;
diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c
index c71abc2a34d5..40e180741629 100644
--- a/drivers/gpu/drm/nouveau/nv04_crtc.c
+++ b/drivers/gpu/drm/nouveau/nv04_crtc.c
@@ -158,7 +158,6 @@ nv_crtc_dpms(struct drm_crtc *crtc, int mode)
158{ 158{
159 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 159 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
160 struct drm_device *dev = crtc->dev; 160 struct drm_device *dev = crtc->dev;
161 struct drm_connector *connector;
162 unsigned char seq1 = 0, crtc17 = 0; 161 unsigned char seq1 = 0, crtc17 = 0;
163 unsigned char crtc1A; 162 unsigned char crtc1A;
164 163
@@ -213,10 +212,6 @@ nv_crtc_dpms(struct drm_crtc *crtc, int mode)
213 NVVgaSeqReset(dev, nv_crtc->index, false); 212 NVVgaSeqReset(dev, nv_crtc->index, false);
214 213
215 NVWriteVgaCrtc(dev, nv_crtc->index, NV_CIO_CRE_RPC1_INDEX, crtc1A); 214 NVWriteVgaCrtc(dev, nv_crtc->index, NV_CIO_CRE_RPC1_INDEX, crtc1A);
216
217 /* Update connector polling modes */
218 list_for_each_entry(connector, &dev->mode_config.connector_list, head)
219 nouveau_connector_set_polling(connector);
220} 215}
221 216
222static bool 217static bool
@@ -831,7 +826,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
831 /* Update the framebuffer location. */ 826 /* Update the framebuffer location. */
832 regp->fb_start = nv_crtc->fb.offset & ~3; 827 regp->fb_start = nv_crtc->fb.offset & ~3;
833 regp->fb_start += (y * drm_fb->pitch) + (x * drm_fb->bits_per_pixel / 8); 828 regp->fb_start += (y * drm_fb->pitch) + (x * drm_fb->bits_per_pixel / 8);
834 NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_START, regp->fb_start); 829 nv_set_crtc_base(dev, nv_crtc->index, regp->fb_start);
835 830
836 /* Update the arbitration parameters. */ 831 /* Update the arbitration parameters. */
837 nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->bits_per_pixel, 832 nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->bits_per_pixel,
diff --git a/drivers/gpu/drm/nouveau/nv04_dfp.c b/drivers/gpu/drm/nouveau/nv04_dfp.c
index c936403b26e2..ef23550407b5 100644
--- a/drivers/gpu/drm/nouveau/nv04_dfp.c
+++ b/drivers/gpu/drm/nouveau/nv04_dfp.c
@@ -185,14 +185,15 @@ static bool nv04_dfp_mode_fixup(struct drm_encoder *encoder,
185 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 185 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
186 struct nouveau_connector *nv_connector = nouveau_encoder_connector_get(nv_encoder); 186 struct nouveau_connector *nv_connector = nouveau_encoder_connector_get(nv_encoder);
187 187
188 /* For internal panels and gpu scaling on DVI we need the native mode */ 188 if (!nv_connector->native_mode ||
189 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) { 189 nv_connector->scaling_mode == DRM_MODE_SCALE_NONE ||
190 if (!nv_connector->native_mode) 190 mode->hdisplay > nv_connector->native_mode->hdisplay ||
191 return false; 191 mode->vdisplay > nv_connector->native_mode->vdisplay) {
192 nv_encoder->mode = *adjusted_mode;
193
194 } else {
192 nv_encoder->mode = *nv_connector->native_mode; 195 nv_encoder->mode = *nv_connector->native_mode;
193 adjusted_mode->clock = nv_connector->native_mode->clock; 196 adjusted_mode->clock = nv_connector->native_mode->clock;
194 } else {
195 nv_encoder->mode = *adjusted_mode;
196 } 197 }
197 198
198 return true; 199 return true;
diff --git a/drivers/gpu/drm/nouveau/nv04_pm.c b/drivers/gpu/drm/nouveau/nv04_pm.c
index 6a6eb697d38e..eb1c70dd82ed 100644
--- a/drivers/gpu/drm/nouveau/nv04_pm.c
+++ b/drivers/gpu/drm/nouveau/nv04_pm.c
@@ -76,6 +76,15 @@ nv04_pm_clock_set(struct drm_device *dev, void *pre_state)
76 reg += 4; 76 reg += 4;
77 77
78 nouveau_hw_setpll(dev, reg, &state->calc); 78 nouveau_hw_setpll(dev, reg, &state->calc);
79
80 if (dev_priv->card_type < NV_30 && reg == NV_PRAMDAC_MPLL_COEFF) {
81 if (dev_priv->card_type == NV_20)
82 nv_mask(dev, 0x1002c4, 0, 1 << 20);
83
84 /* Reset the DLLs */
85 nv_mask(dev, 0x1002c0, 0, 1 << 8);
86 }
87
79 kfree(state); 88 kfree(state);
80} 89}
81 90
diff --git a/drivers/gpu/drm/nouveau/nv50_calc.c b/drivers/gpu/drm/nouveau/nv50_calc.c
index 2cdc2bfe7179..de81151648f8 100644
--- a/drivers/gpu/drm/nouveau/nv50_calc.c
+++ b/drivers/gpu/drm/nouveau/nv50_calc.c
@@ -51,24 +51,28 @@ nv50_calc_pll2(struct drm_device *dev, struct pll_lims *pll, int clk,
51 int *N, int *fN, int *M, int *P) 51 int *N, int *fN, int *M, int *P)
52{ 52{
53 fixed20_12 fb_div, a, b; 53 fixed20_12 fb_div, a, b;
54 u32 refclk = pll->refclk / 10;
55 u32 max_vco_freq = pll->vco1.maxfreq / 10;
56 u32 max_vco_inputfreq = pll->vco1.max_inputfreq / 10;
57 clk /= 10;
54 58
55 *P = pll->vco1.maxfreq / clk; 59 *P = max_vco_freq / clk;
56 if (*P > pll->max_p) 60 if (*P > pll->max_p)
57 *P = pll->max_p; 61 *P = pll->max_p;
58 if (*P < pll->min_p) 62 if (*P < pll->min_p)
59 *P = pll->min_p; 63 *P = pll->min_p;
60 64
61 /* *M = ceil(refclk / pll->vco.max_inputfreq); */ 65 /* *M = floor((refclk + max_vco_inputfreq) / max_vco_inputfreq); */
62 a.full = dfixed_const(pll->refclk); 66 a.full = dfixed_const(refclk + max_vco_inputfreq);
63 b.full = dfixed_const(pll->vco1.max_inputfreq); 67 b.full = dfixed_const(max_vco_inputfreq);
64 a.full = dfixed_div(a, b); 68 a.full = dfixed_div(a, b);
65 a.full = dfixed_ceil(a); 69 a.full = dfixed_floor(a);
66 *M = dfixed_trunc(a); 70 *M = dfixed_trunc(a);
67 71
68 /* fb_div = (vco * *M) / refclk; */ 72 /* fb_div = (vco * *M) / refclk; */
69 fb_div.full = dfixed_const(clk * *P); 73 fb_div.full = dfixed_const(clk * *P);
70 fb_div.full = dfixed_mul(fb_div, a); 74 fb_div.full = dfixed_mul(fb_div, a);
71 a.full = dfixed_const(pll->refclk); 75 a.full = dfixed_const(refclk);
72 fb_div.full = dfixed_div(fb_div, a); 76 fb_div.full = dfixed_div(fb_div, a);
73 77
74 /* *N = floor(fb_div); */ 78 /* *N = floor(fb_div); */
diff --git a/drivers/gpu/drm/nouveau/nv50_crtc.c b/drivers/gpu/drm/nouveau/nv50_crtc.c
index 16380d52cd88..56476d0c6de8 100644
--- a/drivers/gpu/drm/nouveau/nv50_crtc.c
+++ b/drivers/gpu/drm/nouveau/nv50_crtc.c
@@ -546,7 +546,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc,
546 } 546 }
547 547
548 nv_crtc->fb.offset = fb->nvbo->bo.offset - dev_priv->vm_vram_base; 548 nv_crtc->fb.offset = fb->nvbo->bo.offset - dev_priv->vm_vram_base;
549 nv_crtc->fb.tile_flags = fb->nvbo->tile_flags; 549 nv_crtc->fb.tile_flags = nouveau_bo_tile_layout(fb->nvbo);
550 nv_crtc->fb.cpp = drm_fb->bits_per_pixel / 8; 550 nv_crtc->fb.cpp = drm_fb->bits_per_pixel / 8;
551 if (!nv_crtc->fb.blanked && dev_priv->chipset != 0x50) { 551 if (!nv_crtc->fb.blanked && dev_priv->chipset != 0x50) {
552 ret = RING_SPACE(evo, 2); 552 ret = RING_SPACE(evo, 2);
@@ -578,7 +578,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc,
578 fb->nvbo->tile_mode); 578 fb->nvbo->tile_mode);
579 } 579 }
580 if (dev_priv->chipset == 0x50) 580 if (dev_priv->chipset == 0x50)
581 OUT_RING(evo, (fb->nvbo->tile_flags << 8) | format); 581 OUT_RING(evo, (nv_crtc->fb.tile_flags << 8) | format);
582 else 582 else
583 OUT_RING(evo, format); 583 OUT_RING(evo, format);
584 584
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 55c9663ef2bf..f624c611ddea 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -1032,11 +1032,18 @@ nv50_display_irq_hotplug_bh(struct work_struct *work)
1032 struct drm_connector *connector; 1032 struct drm_connector *connector;
1033 const uint32_t gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 }; 1033 const uint32_t gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 };
1034 uint32_t unplug_mask, plug_mask, change_mask; 1034 uint32_t unplug_mask, plug_mask, change_mask;
1035 uint32_t hpd0, hpd1 = 0; 1035 uint32_t hpd0, hpd1;
1036 1036
1037 hpd0 = nv_rd32(dev, 0xe054) & nv_rd32(dev, 0xe050); 1037 spin_lock_irq(&dev_priv->hpd_state.lock);
1038 hpd0 = dev_priv->hpd_state.hpd0_bits;
1039 dev_priv->hpd_state.hpd0_bits = 0;
1040 hpd1 = dev_priv->hpd_state.hpd1_bits;
1041 dev_priv->hpd_state.hpd1_bits = 0;
1042 spin_unlock_irq(&dev_priv->hpd_state.lock);
1043
1044 hpd0 &= nv_rd32(dev, 0xe050);
1038 if (dev_priv->chipset >= 0x90) 1045 if (dev_priv->chipset >= 0x90)
1039 hpd1 = nv_rd32(dev, 0xe074) & nv_rd32(dev, 0xe070); 1046 hpd1 &= nv_rd32(dev, 0xe070);
1040 1047
1041 plug_mask = (hpd0 & 0x0000ffff) | (hpd1 << 16); 1048 plug_mask = (hpd0 & 0x0000ffff) | (hpd1 << 16);
1042 unplug_mask = (hpd0 >> 16) | (hpd1 & 0xffff0000); 1049 unplug_mask = (hpd0 >> 16) | (hpd1 & 0xffff0000);
@@ -1078,10 +1085,6 @@ nv50_display_irq_hotplug_bh(struct work_struct *work)
1078 helper->dpms(connector->encoder, DRM_MODE_DPMS_OFF); 1085 helper->dpms(connector->encoder, DRM_MODE_DPMS_OFF);
1079 } 1086 }
1080 1087
1081 nv_wr32(dev, 0xe054, nv_rd32(dev, 0xe054));
1082 if (dev_priv->chipset >= 0x90)
1083 nv_wr32(dev, 0xe074, nv_rd32(dev, 0xe074));
1084
1085 drm_helper_hpd_irq_event(dev); 1088 drm_helper_hpd_irq_event(dev);
1086} 1089}
1087 1090
@@ -1092,8 +1095,22 @@ nv50_display_irq_handler(struct drm_device *dev)
1092 uint32_t delayed = 0; 1095 uint32_t delayed = 0;
1093 1096
1094 if (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_HOTPLUG) { 1097 if (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_HOTPLUG) {
1095 if (!work_pending(&dev_priv->hpd_work)) 1098 uint32_t hpd0_bits, hpd1_bits = 0;
1096 queue_work(dev_priv->wq, &dev_priv->hpd_work); 1099
1100 hpd0_bits = nv_rd32(dev, 0xe054);
1101 nv_wr32(dev, 0xe054, hpd0_bits);
1102
1103 if (dev_priv->chipset >= 0x90) {
1104 hpd1_bits = nv_rd32(dev, 0xe074);
1105 nv_wr32(dev, 0xe074, hpd1_bits);
1106 }
1107
1108 spin_lock(&dev_priv->hpd_state.lock);
1109 dev_priv->hpd_state.hpd0_bits |= hpd0_bits;
1110 dev_priv->hpd_state.hpd1_bits |= hpd1_bits;
1111 spin_unlock(&dev_priv->hpd_state.lock);
1112
1113 queue_work(dev_priv->wq, &dev_priv->hpd_work);
1097 } 1114 }
1098 1115
1099 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) { 1116 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
diff --git a/drivers/gpu/drm/nouveau/nv50_fifo.c b/drivers/gpu/drm/nouveau/nv50_fifo.c
index a46a961102f3..1da65bd60c10 100644
--- a/drivers/gpu/drm/nouveau/nv50_fifo.c
+++ b/drivers/gpu/drm/nouveau/nv50_fifo.c
@@ -464,3 +464,8 @@ nv50_fifo_unload_context(struct drm_device *dev)
464 return 0; 464 return 0;
465} 465}
466 466
467void
468nv50_fifo_tlb_flush(struct drm_device *dev)
469{
470 nv50_vm_flush(dev, 5);
471}
diff --git a/drivers/gpu/drm/nouveau/nv50_graph.c b/drivers/gpu/drm/nouveau/nv50_graph.c
index cbf5ae2f67d4..8b669d0af610 100644
--- a/drivers/gpu/drm/nouveau/nv50_graph.c
+++ b/drivers/gpu/drm/nouveau/nv50_graph.c
@@ -402,3 +402,55 @@ struct nouveau_pgraph_object_class nv50_graph_grclass[] = {
402 { 0x8597, false, NULL }, /* tesla (nva3, nva5, nva8) */ 402 { 0x8597, false, NULL }, /* tesla (nva3, nva5, nva8) */
403 {} 403 {}
404}; 404};
405
406void
407nv50_graph_tlb_flush(struct drm_device *dev)
408{
409 nv50_vm_flush(dev, 0);
410}
411
412void
413nv86_graph_tlb_flush(struct drm_device *dev)
414{
415 struct drm_nouveau_private *dev_priv = dev->dev_private;
416 struct nouveau_timer_engine *ptimer = &dev_priv->engine.timer;
417 bool idle, timeout = false;
418 unsigned long flags;
419 u64 start;
420 u32 tmp;
421
422 spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
423 nv_mask(dev, 0x400500, 0x00000001, 0x00000000);
424
425 start = ptimer->read(dev);
426 do {
427 idle = true;
428
429 for (tmp = nv_rd32(dev, 0x400380); tmp && idle; tmp >>= 3) {
430 if ((tmp & 7) == 1)
431 idle = false;
432 }
433
434 for (tmp = nv_rd32(dev, 0x400384); tmp && idle; tmp >>= 3) {
435 if ((tmp & 7) == 1)
436 idle = false;
437 }
438
439 for (tmp = nv_rd32(dev, 0x400388); tmp && idle; tmp >>= 3) {
440 if ((tmp & 7) == 1)
441 idle = false;
442 }
443 } while (!idle && !(timeout = ptimer->read(dev) - start > 2000000000));
444
445 if (timeout) {
446 NV_ERROR(dev, "PGRAPH TLB flush idle timeout fail: "
447 "0x%08x 0x%08x 0x%08x 0x%08x\n",
448 nv_rd32(dev, 0x400700), nv_rd32(dev, 0x400380),
449 nv_rd32(dev, 0x400384), nv_rd32(dev, 0x400388));
450 }
451
452 nv50_vm_flush(dev, 0);
453
454 nv_mask(dev, 0x400500, 0x00000001, 0x00000001);
455 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
456}
diff --git a/drivers/gpu/drm/nouveau/nv50_instmem.c b/drivers/gpu/drm/nouveau/nv50_instmem.c
index a53fc974332b..b773229b7647 100644
--- a/drivers/gpu/drm/nouveau/nv50_instmem.c
+++ b/drivers/gpu/drm/nouveau/nv50_instmem.c
@@ -402,7 +402,6 @@ nv50_instmem_bind(struct drm_device *dev, struct nouveau_gpuobj *gpuobj)
402 } 402 }
403 dev_priv->engine.instmem.flush(dev); 403 dev_priv->engine.instmem.flush(dev);
404 404
405 nv50_vm_flush(dev, 4);
406 nv50_vm_flush(dev, 6); 405 nv50_vm_flush(dev, 6);
407 406
408 gpuobj->im_bound = 1; 407 gpuobj->im_bound = 1;
diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
index 8e421f644a54..05efb5b9f13e 100644
--- a/drivers/gpu/drm/radeon/atom.c
+++ b/drivers/gpu/drm/radeon/atom.c
@@ -112,6 +112,7 @@ static uint32_t atom_iio_execute(struct atom_context *ctx, int base,
112 base += 3; 112 base += 3;
113 break; 113 break;
114 case ATOM_IIO_WRITE: 114 case ATOM_IIO_WRITE:
115 (void)ctx->card->ioreg_read(ctx->card, CU16(base + 1));
115 ctx->card->ioreg_write(ctx->card, CU16(base + 1), temp); 116 ctx->card->ioreg_write(ctx->card, CU16(base + 1), temp);
116 base += 3; 117 base += 3;
117 break; 118 break;
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 488c36c8f5e6..4dc5b4714c5a 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1650,7 +1650,36 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
1650 } 1650 }
1651 } 1651 }
1652 1652
1653 rdev->config.evergreen.tile_config = gb_addr_config; 1653 /* setup tiling info dword. gb_addr_config is not adequate since it does
1654 * not have bank info, so create a custom tiling dword.
1655 * bits 3:0 num_pipes
1656 * bits 7:4 num_banks
1657 * bits 11:8 group_size
1658 * bits 15:12 row_size
1659 */
1660 rdev->config.evergreen.tile_config = 0;
1661 switch (rdev->config.evergreen.max_tile_pipes) {
1662 case 1:
1663 default:
1664 rdev->config.evergreen.tile_config |= (0 << 0);
1665 break;
1666 case 2:
1667 rdev->config.evergreen.tile_config |= (1 << 0);
1668 break;
1669 case 4:
1670 rdev->config.evergreen.tile_config |= (2 << 0);
1671 break;
1672 case 8:
1673 rdev->config.evergreen.tile_config |= (3 << 0);
1674 break;
1675 }
1676 rdev->config.evergreen.tile_config |=
1677 ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4;
1678 rdev->config.evergreen.tile_config |=
1679 ((mc_arb_ramcfg & BURSTLENGTH_MASK) >> BURSTLENGTH_SHIFT) << 8;
1680 rdev->config.evergreen.tile_config |=
1681 ((gb_addr_config & 0x30000000) >> 28) << 12;
1682
1654 WREG32(GB_BACKEND_MAP, gb_backend_map); 1683 WREG32(GB_BACKEND_MAP, gb_backend_map);
1655 WREG32(GB_ADDR_CONFIG, gb_addr_config); 1684 WREG32(GB_ADDR_CONFIG, gb_addr_config);
1656 WREG32(DMIF_ADDR_CONFIG, gb_addr_config); 1685 WREG32(DMIF_ADDR_CONFIG, gb_addr_config);
diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
index ac3b6dde23db..e0e590110dd4 100644
--- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
+++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
@@ -459,7 +459,7 @@ int evergreen_blit_init(struct radeon_device *rdev)
459 obj_size += evergreen_ps_size * 4; 459 obj_size += evergreen_ps_size * 4;
460 obj_size = ALIGN(obj_size, 256); 460 obj_size = ALIGN(obj_size, 256);
461 461
462 r = radeon_bo_create(rdev, NULL, obj_size, true, RADEON_GEM_DOMAIN_VRAM, 462 r = radeon_bo_create(rdev, NULL, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
463 &rdev->r600_blit.shader_obj); 463 &rdev->r600_blit.shader_obj);
464 if (r) { 464 if (r) {
465 DRM_ERROR("evergreen failed to allocate shader\n"); 465 DRM_ERROR("evergreen failed to allocate shader\n");
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 0f806cc7dc75..4d7a2e1bdb90 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -878,12 +878,15 @@ void r600_pcie_gart_tlb_flush(struct radeon_device *rdev)
878 u32 tmp; 878 u32 tmp;
879 879
880 /* flush hdp cache so updates hit vram */ 880 /* flush hdp cache so updates hit vram */
881 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740)) { 881 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) &&
882 !(rdev->flags & RADEON_IS_AGP)) {
882 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr; 883 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;
883 u32 tmp; 884 u32 tmp;
884 885
885 /* r7xx hw bug. write to HDP_DEBUG1 followed by fb read 886 /* r7xx hw bug. write to HDP_DEBUG1 followed by fb read
886 * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL 887 * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL
888 * This seems to cause problems on some AGP cards. Just use the old
889 * method for them.
887 */ 890 */
888 WREG32(HDP_DEBUG1, 0); 891 WREG32(HDP_DEBUG1, 0);
889 tmp = readl((void __iomem *)ptr); 892 tmp = readl((void __iomem *)ptr);
@@ -1195,8 +1198,10 @@ void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
1195 mc->vram_end, mc->real_vram_size >> 20); 1198 mc->vram_end, mc->real_vram_size >> 20);
1196 } else { 1199 } else {
1197 u64 base = 0; 1200 u64 base = 0;
1198 if (rdev->flags & RADEON_IS_IGP) 1201 if (rdev->flags & RADEON_IS_IGP) {
1199 base = (RREG32(MC_VM_FB_LOCATION) & 0xFFFF) << 24; 1202 base = RREG32(MC_VM_FB_LOCATION) & 0xFFFF;
1203 base <<= 24;
1204 }
1200 radeon_vram_location(rdev, &rdev->mc, base); 1205 radeon_vram_location(rdev, &rdev->mc, base);
1201 rdev->mc.gtt_base_align = 0; 1206 rdev->mc.gtt_base_align = 0;
1202 radeon_gtt_location(rdev, mc); 1207 radeon_gtt_location(rdev, mc);
@@ -2718,7 +2723,7 @@ static int r600_ih_ring_alloc(struct radeon_device *rdev)
2718 /* Allocate ring buffer */ 2723 /* Allocate ring buffer */
2719 if (rdev->ih.ring_obj == NULL) { 2724 if (rdev->ih.ring_obj == NULL) {
2720 r = radeon_bo_create(rdev, NULL, rdev->ih.ring_size, 2725 r = radeon_bo_create(rdev, NULL, rdev->ih.ring_size,
2721 true, 2726 PAGE_SIZE, true,
2722 RADEON_GEM_DOMAIN_GTT, 2727 RADEON_GEM_DOMAIN_GTT,
2723 &rdev->ih.ring_obj); 2728 &rdev->ih.ring_obj);
2724 if (r) { 2729 if (r) {
@@ -3483,10 +3488,12 @@ int r600_debugfs_mc_info_init(struct radeon_device *rdev)
3483void r600_ioctl_wait_idle(struct radeon_device *rdev, struct radeon_bo *bo) 3488void r600_ioctl_wait_idle(struct radeon_device *rdev, struct radeon_bo *bo)
3484{ 3489{
3485 /* r7xx hw bug. write to HDP_DEBUG1 followed by fb read 3490 /* r7xx hw bug. write to HDP_DEBUG1 followed by fb read
3486 * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL 3491 * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL.
3492 * This seems to cause problems on some AGP cards. Just use the old
3493 * method for them.
3487 */ 3494 */
3488 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) && 3495 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) &&
3489 rdev->vram_scratch.ptr) { 3496 rdev->vram_scratch.ptr && !(rdev->flags & RADEON_IS_AGP)) {
3490 void __iomem *ptr = (void *)rdev->vram_scratch.ptr; 3497 void __iomem *ptr = (void *)rdev->vram_scratch.ptr;
3491 u32 tmp; 3498 u32 tmp;
3492 3499
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c
index 8362974ef41a..86e5aa07f0db 100644
--- a/drivers/gpu/drm/radeon/r600_blit_kms.c
+++ b/drivers/gpu/drm/radeon/r600_blit_kms.c
@@ -501,7 +501,7 @@ int r600_blit_init(struct radeon_device *rdev)
501 obj_size += r6xx_ps_size * 4; 501 obj_size += r6xx_ps_size * 4;
502 obj_size = ALIGN(obj_size, 256); 502 obj_size = ALIGN(obj_size, 256);
503 503
504 r = radeon_bo_create(rdev, NULL, obj_size, true, RADEON_GEM_DOMAIN_VRAM, 504 r = radeon_bo_create(rdev, NULL, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
505 &rdev->r600_blit.shader_obj); 505 &rdev->r600_blit.shader_obj);
506 if (r) { 506 if (r) {
507 DRM_ERROR("r600 failed to allocate shader\n"); 507 DRM_ERROR("r600 failed to allocate shader\n");
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index 37cc2aa9f923..0f90fc3482ce 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -50,6 +50,7 @@ struct r600_cs_track {
50 u32 nsamples; 50 u32 nsamples;
51 u32 cb_color_base_last[8]; 51 u32 cb_color_base_last[8];
52 struct radeon_bo *cb_color_bo[8]; 52 struct radeon_bo *cb_color_bo[8];
53 u64 cb_color_bo_mc[8];
53 u32 cb_color_bo_offset[8]; 54 u32 cb_color_bo_offset[8];
54 struct radeon_bo *cb_color_frag_bo[8]; 55 struct radeon_bo *cb_color_frag_bo[8];
55 struct radeon_bo *cb_color_tile_bo[8]; 56 struct radeon_bo *cb_color_tile_bo[8];
@@ -67,6 +68,7 @@ struct r600_cs_track {
67 u32 db_depth_size; 68 u32 db_depth_size;
68 u32 db_offset; 69 u32 db_offset;
69 struct radeon_bo *db_bo; 70 struct radeon_bo *db_bo;
71 u64 db_bo_mc;
70}; 72};
71 73
72static inline int r600_bpe_from_format(u32 *bpe, u32 format) 74static inline int r600_bpe_from_format(u32 *bpe, u32 format)
@@ -140,6 +142,68 @@ static inline int r600_bpe_from_format(u32 *bpe, u32 format)
140 return 0; 142 return 0;
141} 143}
142 144
145struct array_mode_checker {
146 int array_mode;
147 u32 group_size;
148 u32 nbanks;
149 u32 npipes;
150 u32 nsamples;
151 u32 bpe;
152};
153
154/* returns alignment in pixels for pitch/height/depth and bytes for base */
155static inline int r600_get_array_mode_alignment(struct array_mode_checker *values,
156 u32 *pitch_align,
157 u32 *height_align,
158 u32 *depth_align,
159 u64 *base_align)
160{
161 u32 tile_width = 8;
162 u32 tile_height = 8;
163 u32 macro_tile_width = values->nbanks;
164 u32 macro_tile_height = values->npipes;
165 u32 tile_bytes = tile_width * tile_height * values->bpe * values->nsamples;
166 u32 macro_tile_bytes = macro_tile_width * macro_tile_height * tile_bytes;
167
168 switch (values->array_mode) {
169 case ARRAY_LINEAR_GENERAL:
170 /* technically tile_width/_height for pitch/height */
171 *pitch_align = 1; /* tile_width */
172 *height_align = 1; /* tile_height */
173 *depth_align = 1;
174 *base_align = 1;
175 break;
176 case ARRAY_LINEAR_ALIGNED:
177 *pitch_align = max((u32)64, (u32)(values->group_size / values->bpe));
178 *height_align = tile_height;
179 *depth_align = 1;
180 *base_align = values->group_size;
181 break;
182 case ARRAY_1D_TILED_THIN1:
183 *pitch_align = max((u32)tile_width,
184 (u32)(values->group_size /
185 (tile_height * values->bpe * values->nsamples)));
186 *height_align = tile_height;
187 *depth_align = 1;
188 *base_align = values->group_size;
189 break;
190 case ARRAY_2D_TILED_THIN1:
191 *pitch_align = max((u32)macro_tile_width,
192 (u32)(((values->group_size / tile_height) /
193 (values->bpe * values->nsamples)) *
194 values->nbanks)) * tile_width;
195 *height_align = macro_tile_height * tile_height;
196 *depth_align = 1;
197 *base_align = max(macro_tile_bytes,
198 (*pitch_align) * values->bpe * (*height_align) * values->nsamples);
199 break;
200 default:
201 return -EINVAL;
202 }
203
204 return 0;
205}
206
143static void r600_cs_track_init(struct r600_cs_track *track) 207static void r600_cs_track_init(struct r600_cs_track *track)
144{ 208{
145 int i; 209 int i;
@@ -153,10 +217,12 @@ static void r600_cs_track_init(struct r600_cs_track *track)
153 track->cb_color_info[i] = 0; 217 track->cb_color_info[i] = 0;
154 track->cb_color_bo[i] = NULL; 218 track->cb_color_bo[i] = NULL;
155 track->cb_color_bo_offset[i] = 0xFFFFFFFF; 219 track->cb_color_bo_offset[i] = 0xFFFFFFFF;
220 track->cb_color_bo_mc[i] = 0xFFFFFFFF;
156 } 221 }
157 track->cb_target_mask = 0xFFFFFFFF; 222 track->cb_target_mask = 0xFFFFFFFF;
158 track->cb_shader_mask = 0xFFFFFFFF; 223 track->cb_shader_mask = 0xFFFFFFFF;
159 track->db_bo = NULL; 224 track->db_bo = NULL;
225 track->db_bo_mc = 0xFFFFFFFF;
160 /* assume the biggest format and that htile is enabled */ 226 /* assume the biggest format and that htile is enabled */
161 track->db_depth_info = 7 | (1 << 25); 227 track->db_depth_info = 7 | (1 << 25);
162 track->db_depth_view = 0xFFFFC000; 228 track->db_depth_view = 0xFFFFC000;
@@ -168,7 +234,10 @@ static void r600_cs_track_init(struct r600_cs_track *track)
168static inline int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i) 234static inline int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i)
169{ 235{
170 struct r600_cs_track *track = p->track; 236 struct r600_cs_track *track = p->track;
171 u32 bpe = 0, pitch, slice_tile_max, size, tmp, height, pitch_align; 237 u32 bpe = 0, slice_tile_max, size, tmp;
238 u32 height, height_align, pitch, pitch_align, depth_align;
239 u64 base_offset, base_align;
240 struct array_mode_checker array_check;
172 volatile u32 *ib = p->ib->ptr; 241 volatile u32 *ib = p->ib->ptr;
173 unsigned array_mode; 242 unsigned array_mode;
174 243
@@ -183,60 +252,40 @@ static inline int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i)
183 i, track->cb_color_info[i]); 252 i, track->cb_color_info[i]);
184 return -EINVAL; 253 return -EINVAL;
185 } 254 }
186 /* pitch is the number of 8x8 tiles per row */ 255 /* pitch in pixels */
187 pitch = G_028060_PITCH_TILE_MAX(track->cb_color_size[i]) + 1; 256 pitch = (G_028060_PITCH_TILE_MAX(track->cb_color_size[i]) + 1) * 8;
188 slice_tile_max = G_028060_SLICE_TILE_MAX(track->cb_color_size[i]) + 1; 257 slice_tile_max = G_028060_SLICE_TILE_MAX(track->cb_color_size[i]) + 1;
189 slice_tile_max *= 64; 258 slice_tile_max *= 64;
190 height = slice_tile_max / (pitch * 8); 259 height = slice_tile_max / pitch;
191 if (height > 8192) 260 if (height > 8192)
192 height = 8192; 261 height = 8192;
193 array_mode = G_0280A0_ARRAY_MODE(track->cb_color_info[i]); 262 array_mode = G_0280A0_ARRAY_MODE(track->cb_color_info[i]);
263
264 base_offset = track->cb_color_bo_mc[i] + track->cb_color_bo_offset[i];
265 array_check.array_mode = array_mode;
266 array_check.group_size = track->group_size;
267 array_check.nbanks = track->nbanks;
268 array_check.npipes = track->npipes;
269 array_check.nsamples = track->nsamples;
270 array_check.bpe = bpe;
271 if (r600_get_array_mode_alignment(&array_check,
272 &pitch_align, &height_align, &depth_align, &base_align)) {
273 dev_warn(p->dev, "%s invalid tiling %d for %d (0x%08X)\n", __func__,
274 G_0280A0_ARRAY_MODE(track->cb_color_info[i]), i,
275 track->cb_color_info[i]);
276 return -EINVAL;
277 }
194 switch (array_mode) { 278 switch (array_mode) {
195 case V_0280A0_ARRAY_LINEAR_GENERAL: 279 case V_0280A0_ARRAY_LINEAR_GENERAL:
196 /* technically height & 0x7 */
197 break; 280 break;
198 case V_0280A0_ARRAY_LINEAR_ALIGNED: 281 case V_0280A0_ARRAY_LINEAR_ALIGNED:
199 pitch_align = max((u32)64, (u32)(track->group_size / bpe)) / 8;
200 if (!IS_ALIGNED(pitch, pitch_align)) {
201 dev_warn(p->dev, "%s:%d cb pitch (%d) invalid\n",
202 __func__, __LINE__, pitch);
203 return -EINVAL;
204 }
205 if (!IS_ALIGNED(height, 8)) {
206 dev_warn(p->dev, "%s:%d cb height (%d) invalid\n",
207 __func__, __LINE__, height);
208 return -EINVAL;
209 }
210 break; 282 break;
211 case V_0280A0_ARRAY_1D_TILED_THIN1: 283 case V_0280A0_ARRAY_1D_TILED_THIN1:
212 pitch_align = max((u32)8, (u32)(track->group_size / (8 * bpe * track->nsamples))) / 8;
213 if (!IS_ALIGNED(pitch, pitch_align)) {
214 dev_warn(p->dev, "%s:%d cb pitch (%d) invalid\n",
215 __func__, __LINE__, pitch);
216 return -EINVAL;
217 }
218 /* avoid breaking userspace */ 284 /* avoid breaking userspace */
219 if (height > 7) 285 if (height > 7)
220 height &= ~0x7; 286 height &= ~0x7;
221 if (!IS_ALIGNED(height, 8)) {
222 dev_warn(p->dev, "%s:%d cb height (%d) invalid\n",
223 __func__, __LINE__, height);
224 return -EINVAL;
225 }
226 break; 287 break;
227 case V_0280A0_ARRAY_2D_TILED_THIN1: 288 case V_0280A0_ARRAY_2D_TILED_THIN1:
228 pitch_align = max((u32)track->nbanks,
229 (u32)(((track->group_size / 8) / (bpe * track->nsamples)) * track->nbanks)) / 8;
230 if (!IS_ALIGNED(pitch, pitch_align)) {
231 dev_warn(p->dev, "%s:%d cb pitch (%d) invalid\n",
232 __func__, __LINE__, pitch);
233 return -EINVAL;
234 }
235 if (!IS_ALIGNED((height / 8), track->npipes)) {
236 dev_warn(p->dev, "%s:%d cb height (%d) invalid\n",
237 __func__, __LINE__, height);
238 return -EINVAL;
239 }
240 break; 289 break;
241 default: 290 default:
242 dev_warn(p->dev, "%s invalid tiling %d for %d (0x%08X)\n", __func__, 291 dev_warn(p->dev, "%s invalid tiling %d for %d (0x%08X)\n", __func__,
@@ -244,8 +293,24 @@ static inline int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i)
244 track->cb_color_info[i]); 293 track->cb_color_info[i]);
245 return -EINVAL; 294 return -EINVAL;
246 } 295 }
296
297 if (!IS_ALIGNED(pitch, pitch_align)) {
298 dev_warn(p->dev, "%s:%d cb pitch (%d) invalid\n",
299 __func__, __LINE__, pitch);
300 return -EINVAL;
301 }
302 if (!IS_ALIGNED(height, height_align)) {
303 dev_warn(p->dev, "%s:%d cb height (%d) invalid\n",
304 __func__, __LINE__, height);
305 return -EINVAL;
306 }
307 if (!IS_ALIGNED(base_offset, base_align)) {
308 dev_warn(p->dev, "%s offset[%d] 0x%llx not aligned\n", __func__, i, base_offset);
309 return -EINVAL;
310 }
311
247 /* check offset */ 312 /* check offset */
248 tmp = height * pitch * 8 * bpe; 313 tmp = height * pitch * bpe;
249 if ((tmp + track->cb_color_bo_offset[i]) > radeon_bo_size(track->cb_color_bo[i])) { 314 if ((tmp + track->cb_color_bo_offset[i]) > radeon_bo_size(track->cb_color_bo[i])) {
250 if (array_mode == V_0280A0_ARRAY_LINEAR_GENERAL) { 315 if (array_mode == V_0280A0_ARRAY_LINEAR_GENERAL) {
251 /* the initial DDX does bad things with the CB size occasionally */ 316 /* the initial DDX does bad things with the CB size occasionally */
@@ -260,15 +325,11 @@ static inline int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i)
260 return -EINVAL; 325 return -EINVAL;
261 } 326 }
262 } 327 }
263 if (!IS_ALIGNED(track->cb_color_bo_offset[i], track->group_size)) {
264 dev_warn(p->dev, "%s offset[%d] %d not aligned\n", __func__, i, track->cb_color_bo_offset[i]);
265 return -EINVAL;
266 }
267 /* limit max tile */ 328 /* limit max tile */
268 tmp = (height * pitch * 8) >> 6; 329 tmp = (height * pitch) >> 6;
269 if (tmp < slice_tile_max) 330 if (tmp < slice_tile_max)
270 slice_tile_max = tmp; 331 slice_tile_max = tmp;
271 tmp = S_028060_PITCH_TILE_MAX(pitch - 1) | 332 tmp = S_028060_PITCH_TILE_MAX((pitch / 8) - 1) |
272 S_028060_SLICE_TILE_MAX(slice_tile_max - 1); 333 S_028060_SLICE_TILE_MAX(slice_tile_max - 1);
273 ib[track->cb_color_size_idx[i]] = tmp; 334 ib[track->cb_color_size_idx[i]] = tmp;
274 return 0; 335 return 0;
@@ -310,7 +371,12 @@ static int r600_cs_track_check(struct radeon_cs_parser *p)
310 /* Check depth buffer */ 371 /* Check depth buffer */
311 if (G_028800_STENCIL_ENABLE(track->db_depth_control) || 372 if (G_028800_STENCIL_ENABLE(track->db_depth_control) ||
312 G_028800_Z_ENABLE(track->db_depth_control)) { 373 G_028800_Z_ENABLE(track->db_depth_control)) {
313 u32 nviews, bpe, ntiles, pitch, pitch_align, height, size, slice_tile_max; 374 u32 nviews, bpe, ntiles, size, slice_tile_max;
375 u32 height, height_align, pitch, pitch_align, depth_align;
376 u64 base_offset, base_align;
377 struct array_mode_checker array_check;
378 int array_mode;
379
314 if (track->db_bo == NULL) { 380 if (track->db_bo == NULL) {
315 dev_warn(p->dev, "z/stencil with no depth buffer\n"); 381 dev_warn(p->dev, "z/stencil with no depth buffer\n");
316 return -EINVAL; 382 return -EINVAL;
@@ -353,41 +419,34 @@ static int r600_cs_track_check(struct radeon_cs_parser *p)
353 ib[track->db_depth_size_idx] = S_028000_SLICE_TILE_MAX(tmp - 1) | (track->db_depth_size & 0x3FF); 419 ib[track->db_depth_size_idx] = S_028000_SLICE_TILE_MAX(tmp - 1) | (track->db_depth_size & 0x3FF);
354 } else { 420 } else {
355 size = radeon_bo_size(track->db_bo); 421 size = radeon_bo_size(track->db_bo);
356 pitch = G_028000_PITCH_TILE_MAX(track->db_depth_size) + 1; 422 /* pitch in pixels */
423 pitch = (G_028000_PITCH_TILE_MAX(track->db_depth_size) + 1) * 8;
357 slice_tile_max = G_028000_SLICE_TILE_MAX(track->db_depth_size) + 1; 424 slice_tile_max = G_028000_SLICE_TILE_MAX(track->db_depth_size) + 1;
358 slice_tile_max *= 64; 425 slice_tile_max *= 64;
359 height = slice_tile_max / (pitch * 8); 426 height = slice_tile_max / pitch;
360 if (height > 8192) 427 if (height > 8192)
361 height = 8192; 428 height = 8192;
362 switch (G_028010_ARRAY_MODE(track->db_depth_info)) { 429 base_offset = track->db_bo_mc + track->db_offset;
430 array_mode = G_028010_ARRAY_MODE(track->db_depth_info);
431 array_check.array_mode = array_mode;
432 array_check.group_size = track->group_size;
433 array_check.nbanks = track->nbanks;
434 array_check.npipes = track->npipes;
435 array_check.nsamples = track->nsamples;
436 array_check.bpe = bpe;
437 if (r600_get_array_mode_alignment(&array_check,
438 &pitch_align, &height_align, &depth_align, &base_align)) {
439 dev_warn(p->dev, "%s invalid tiling %d (0x%08X)\n", __func__,
440 G_028010_ARRAY_MODE(track->db_depth_info),
441 track->db_depth_info);
442 return -EINVAL;
443 }
444 switch (array_mode) {
363 case V_028010_ARRAY_1D_TILED_THIN1: 445 case V_028010_ARRAY_1D_TILED_THIN1:
364 pitch_align = (max((u32)8, (u32)(track->group_size / (8 * bpe))) / 8);
365 if (!IS_ALIGNED(pitch, pitch_align)) {
366 dev_warn(p->dev, "%s:%d db pitch (%d) invalid\n",
367 __func__, __LINE__, pitch);
368 return -EINVAL;
369 }
370 /* don't break userspace */ 446 /* don't break userspace */
371 height &= ~0x7; 447 height &= ~0x7;
372 if (!IS_ALIGNED(height, 8)) {
373 dev_warn(p->dev, "%s:%d db height (%d) invalid\n",
374 __func__, __LINE__, height);
375 return -EINVAL;
376 }
377 break; 448 break;
378 case V_028010_ARRAY_2D_TILED_THIN1: 449 case V_028010_ARRAY_2D_TILED_THIN1:
379 pitch_align = max((u32)track->nbanks,
380 (u32)(((track->group_size / 8) / bpe) * track->nbanks)) / 8;
381 if (!IS_ALIGNED(pitch, pitch_align)) {
382 dev_warn(p->dev, "%s:%d db pitch (%d) invalid\n",
383 __func__, __LINE__, pitch);
384 return -EINVAL;
385 }
386 if (!IS_ALIGNED((height / 8), track->npipes)) {
387 dev_warn(p->dev, "%s:%d db height (%d) invalid\n",
388 __func__, __LINE__, height);
389 return -EINVAL;
390 }
391 break; 450 break;
392 default: 451 default:
393 dev_warn(p->dev, "%s invalid tiling %d (0x%08X)\n", __func__, 452 dev_warn(p->dev, "%s invalid tiling %d (0x%08X)\n", __func__,
@@ -395,15 +454,27 @@ static int r600_cs_track_check(struct radeon_cs_parser *p)
395 track->db_depth_info); 454 track->db_depth_info);
396 return -EINVAL; 455 return -EINVAL;
397 } 456 }
398 if (!IS_ALIGNED(track->db_offset, track->group_size)) { 457
399 dev_warn(p->dev, "%s offset[%d] %d not aligned\n", __func__, i, track->db_offset); 458 if (!IS_ALIGNED(pitch, pitch_align)) {
459 dev_warn(p->dev, "%s:%d db pitch (%d) invalid\n",
460 __func__, __LINE__, pitch);
461 return -EINVAL;
462 }
463 if (!IS_ALIGNED(height, height_align)) {
464 dev_warn(p->dev, "%s:%d db height (%d) invalid\n",
465 __func__, __LINE__, height);
400 return -EINVAL; 466 return -EINVAL;
401 } 467 }
468 if (!IS_ALIGNED(base_offset, base_align)) {
469 dev_warn(p->dev, "%s offset[%d] 0x%llx not aligned\n", __func__, i, base_offset);
470 return -EINVAL;
471 }
472
402 ntiles = G_028000_SLICE_TILE_MAX(track->db_depth_size) + 1; 473 ntiles = G_028000_SLICE_TILE_MAX(track->db_depth_size) + 1;
403 nviews = G_028004_SLICE_MAX(track->db_depth_view) + 1; 474 nviews = G_028004_SLICE_MAX(track->db_depth_view) + 1;
404 tmp = ntiles * bpe * 64 * nviews; 475 tmp = ntiles * bpe * 64 * nviews;
405 if ((tmp + track->db_offset) > radeon_bo_size(track->db_bo)) { 476 if ((tmp + track->db_offset) > radeon_bo_size(track->db_bo)) {
406 dev_warn(p->dev, "z/stencil buffer too small (0x%08X %d %d %d -> %d have %ld)\n", 477 dev_warn(p->dev, "z/stencil buffer too small (0x%08X %d %d %d -> %u have %lu)\n",
407 track->db_depth_size, ntiles, nviews, bpe, tmp + track->db_offset, 478 track->db_depth_size, ntiles, nviews, bpe, tmp + track->db_offset,
408 radeon_bo_size(track->db_bo)); 479 radeon_bo_size(track->db_bo));
409 return -EINVAL; 480 return -EINVAL;
@@ -954,6 +1025,7 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx
954 ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); 1025 ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
955 track->cb_color_base_last[tmp] = ib[idx]; 1026 track->cb_color_base_last[tmp] = ib[idx];
956 track->cb_color_bo[tmp] = reloc->robj; 1027 track->cb_color_bo[tmp] = reloc->robj;
1028 track->cb_color_bo_mc[tmp] = reloc->lobj.gpu_offset;
957 break; 1029 break;
958 case DB_DEPTH_BASE: 1030 case DB_DEPTH_BASE:
959 r = r600_cs_packet_next_reloc(p, &reloc); 1031 r = r600_cs_packet_next_reloc(p, &reloc);
@@ -965,6 +1037,7 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx
965 track->db_offset = radeon_get_ib_value(p, idx) << 8; 1037 track->db_offset = radeon_get_ib_value(p, idx) << 8;
966 ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); 1038 ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
967 track->db_bo = reloc->robj; 1039 track->db_bo = reloc->robj;
1040 track->db_bo_mc = reloc->lobj.gpu_offset;
968 break; 1041 break;
969 case DB_HTILE_DATA_BASE: 1042 case DB_HTILE_DATA_BASE:
970 case SQ_PGM_START_FS: 1043 case SQ_PGM_START_FS:
@@ -1086,16 +1159,25 @@ static void r600_texture_size(unsigned nfaces, unsigned blevel, unsigned nlevels
1086static inline int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx, 1159static inline int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx,
1087 struct radeon_bo *texture, 1160 struct radeon_bo *texture,
1088 struct radeon_bo *mipmap, 1161 struct radeon_bo *mipmap,
1162 u64 base_offset,
1163 u64 mip_offset,
1089 u32 tiling_flags) 1164 u32 tiling_flags)
1090{ 1165{
1091 struct r600_cs_track *track = p->track; 1166 struct r600_cs_track *track = p->track;
1092 u32 nfaces, nlevels, blevel, w0, h0, d0, bpe = 0; 1167 u32 nfaces, nlevels, blevel, w0, h0, d0, bpe = 0;
1093 u32 word0, word1, l0_size, mipmap_size, pitch, pitch_align; 1168 u32 word0, word1, l0_size, mipmap_size;
1169 u32 height_align, pitch, pitch_align, depth_align;
1170 u64 base_align;
1171 struct array_mode_checker array_check;
1094 1172
1095 /* on legacy kernel we don't perform advanced check */ 1173 /* on legacy kernel we don't perform advanced check */
1096 if (p->rdev == NULL) 1174 if (p->rdev == NULL)
1097 return 0; 1175 return 0;
1098 1176
1177 /* convert to bytes */
1178 base_offset <<= 8;
1179 mip_offset <<= 8;
1180
1099 word0 = radeon_get_ib_value(p, idx + 0); 1181 word0 = radeon_get_ib_value(p, idx + 0);
1100 if (tiling_flags & RADEON_TILING_MACRO) 1182 if (tiling_flags & RADEON_TILING_MACRO)
1101 word0 |= S_038000_TILE_MODE(V_038000_ARRAY_2D_TILED_THIN1); 1183 word0 |= S_038000_TILE_MODE(V_038000_ARRAY_2D_TILED_THIN1);
@@ -1128,46 +1210,38 @@ static inline int r600_check_texture_resource(struct radeon_cs_parser *p, u32 i
1128 return -EINVAL; 1210 return -EINVAL;
1129 } 1211 }
1130 1212
1131 pitch = G_038000_PITCH(word0) + 1; 1213 /* pitch in texels */
1132 switch (G_038000_TILE_MODE(word0)) { 1214 pitch = (G_038000_PITCH(word0) + 1) * 8;
1133 case V_038000_ARRAY_LINEAR_GENERAL: 1215 array_check.array_mode = G_038000_TILE_MODE(word0);
1134 pitch_align = 1; 1216 array_check.group_size = track->group_size;
1135 /* XXX check height align */ 1217 array_check.nbanks = track->nbanks;
1136 break; 1218 array_check.npipes = track->npipes;
1137 case V_038000_ARRAY_LINEAR_ALIGNED: 1219 array_check.nsamples = 1;
1138 pitch_align = max((u32)64, (u32)(track->group_size / bpe)) / 8; 1220 array_check.bpe = bpe;
1139 if (!IS_ALIGNED(pitch, pitch_align)) { 1221 if (r600_get_array_mode_alignment(&array_check,
1140 dev_warn(p->dev, "%s:%d tex pitch (%d) invalid\n", 1222 &pitch_align, &height_align, &depth_align, &base_align)) {
1141 __func__, __LINE__, pitch); 1223 dev_warn(p->dev, "%s:%d tex array mode (%d) invalid\n",
1142 return -EINVAL; 1224 __func__, __LINE__, G_038000_TILE_MODE(word0));
1143 } 1225 return -EINVAL;
1144 /* XXX check height align */ 1226 }
1145 break; 1227
1146 case V_038000_ARRAY_1D_TILED_THIN1: 1228 /* XXX check height as well... */
1147 pitch_align = max((u32)8, (u32)(track->group_size / (8 * bpe))) / 8; 1229
1148 if (!IS_ALIGNED(pitch, pitch_align)) { 1230 if (!IS_ALIGNED(pitch, pitch_align)) {
1149 dev_warn(p->dev, "%s:%d tex pitch (%d) invalid\n", 1231 dev_warn(p->dev, "%s:%d tex pitch (%d) invalid\n",
1150 __func__, __LINE__, pitch); 1232 __func__, __LINE__, pitch);
1151 return -EINVAL; 1233 return -EINVAL;
1152 } 1234 }
1153 /* XXX check height align */ 1235 if (!IS_ALIGNED(base_offset, base_align)) {
1154 break; 1236 dev_warn(p->dev, "%s:%d tex base offset (0x%llx) invalid\n",
1155 case V_038000_ARRAY_2D_TILED_THIN1: 1237 __func__, __LINE__, base_offset);
1156 pitch_align = max((u32)track->nbanks, 1238 return -EINVAL;
1157 (u32)(((track->group_size / 8) / bpe) * track->nbanks)) / 8; 1239 }
1158 if (!IS_ALIGNED(pitch, pitch_align)) { 1240 if (!IS_ALIGNED(mip_offset, base_align)) {
1159 dev_warn(p->dev, "%s:%d tex pitch (%d) invalid\n", 1241 dev_warn(p->dev, "%s:%d tex mip offset (0x%llx) invalid\n",
1160 __func__, __LINE__, pitch); 1242 __func__, __LINE__, mip_offset);
1161 return -EINVAL;
1162 }
1163 /* XXX check height align */
1164 break;
1165 default:
1166 dev_warn(p->dev, "%s invalid tiling %d (0x%08X)\n", __func__,
1167 G_038000_TILE_MODE(word0), word0);
1168 return -EINVAL; 1243 return -EINVAL;
1169 } 1244 }
1170 /* XXX check offset align */
1171 1245
1172 word0 = radeon_get_ib_value(p, idx + 4); 1246 word0 = radeon_get_ib_value(p, idx + 4);
1173 word1 = radeon_get_ib_value(p, idx + 5); 1247 word1 = radeon_get_ib_value(p, idx + 5);
@@ -1402,7 +1476,10 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
1402 mip_offset = (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff); 1476 mip_offset = (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
1403 mipmap = reloc->robj; 1477 mipmap = reloc->robj;
1404 r = r600_check_texture_resource(p, idx+(i*7)+1, 1478 r = r600_check_texture_resource(p, idx+(i*7)+1,
1405 texture, mipmap, reloc->lobj.tiling_flags); 1479 texture, mipmap,
1480 base_offset + radeon_get_ib_value(p, idx+1+(i*7)+2),
1481 mip_offset + radeon_get_ib_value(p, idx+1+(i*7)+3),
1482 reloc->lobj.tiling_flags);
1406 if (r) 1483 if (r)
1407 return r; 1484 return r;
1408 ib[idx+1+(i*7)+2] += base_offset; 1485 ib[idx+1+(i*7)+2] += base_offset;
diff --git a/drivers/gpu/drm/radeon/r600_reg.h b/drivers/gpu/drm/radeon/r600_reg.h
index d84612ae47e0..33cda016b083 100644
--- a/drivers/gpu/drm/radeon/r600_reg.h
+++ b/drivers/gpu/drm/radeon/r600_reg.h
@@ -86,6 +86,7 @@
86#define R600_HDP_NONSURFACE_BASE 0x2c04 86#define R600_HDP_NONSURFACE_BASE 0x2c04
87 87
88#define R600_BUS_CNTL 0x5420 88#define R600_BUS_CNTL 0x5420
89# define R600_BIOS_ROM_DIS (1 << 1)
89#define R600_CONFIG_CNTL 0x5424 90#define R600_CONFIG_CNTL 0x5424
90#define R600_CONFIG_MEMSIZE 0x5428 91#define R600_CONFIG_MEMSIZE 0x5428
91#define R600_CONFIG_F0_BASE 0x542C 92#define R600_CONFIG_F0_BASE 0x542C
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index 966a793e225b..bff4dc4f410f 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -51,6 +51,12 @@
51#define PTE_READABLE (1 << 5) 51#define PTE_READABLE (1 << 5)
52#define PTE_WRITEABLE (1 << 6) 52#define PTE_WRITEABLE (1 << 6)
53 53
54/* tiling bits */
55#define ARRAY_LINEAR_GENERAL 0x00000000
56#define ARRAY_LINEAR_ALIGNED 0x00000001
57#define ARRAY_1D_TILED_THIN1 0x00000002
58#define ARRAY_2D_TILED_THIN1 0x00000004
59
54/* Registers */ 60/* Registers */
55#define ARB_POP 0x2418 61#define ARB_POP 0x2418
56#define ENABLE_TC128 (1 << 30) 62#define ENABLE_TC128 (1 << 30)
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 73f600d39ad4..3a7095743d44 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1262,6 +1262,10 @@ void r100_pll_errata_after_index(struct radeon_device *rdev);
1262 (rdev->family == CHIP_RS400) || \ 1262 (rdev->family == CHIP_RS400) || \
1263 (rdev->family == CHIP_RS480)) 1263 (rdev->family == CHIP_RS480))
1264#define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600)) 1264#define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
1265#define ASIC_IS_DCE2(rdev) ((rdev->family == CHIP_RS600) || \
1266 (rdev->family == CHIP_RS690) || \
1267 (rdev->family == CHIP_RS740) || \
1268 (rdev->family >= CHIP_R600))
1265#define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620)) 1269#define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
1266#define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730)) 1270#define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
1267#define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR)) 1271#define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 87ead090c7d5..bc5a2c3382d9 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -98,6 +98,14 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_dev
98 } 98 }
99 } 99 }
100 100
101 /* some DCE3 boards have bad data for this entry */
102 if (ASIC_IS_DCE3(rdev)) {
103 if ((i == 4) &&
104 (gpio->usClkMaskRegisterIndex == 0x1fda) &&
105 (gpio->sucI2cId.ucAccess == 0x94))
106 gpio->sucI2cId.ucAccess = 0x14;
107 }
108
101 if (gpio->sucI2cId.ucAccess == id) { 109 if (gpio->sucI2cId.ucAccess == id) {
102 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4; 110 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
103 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4; 111 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
@@ -174,6 +182,14 @@ void radeon_atombios_i2c_init(struct radeon_device *rdev)
174 } 182 }
175 } 183 }
176 184
185 /* some DCE3 boards have bad data for this entry */
186 if (ASIC_IS_DCE3(rdev)) {
187 if ((i == 4) &&
188 (gpio->usClkMaskRegisterIndex == 0x1fda) &&
189 (gpio->sucI2cId.ucAccess == 0x94))
190 gpio->sucI2cId.ucAccess = 0x14;
191 }
192
177 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4; 193 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
178 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4; 194 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
179 i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4; 195 i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4;
diff --git a/drivers/gpu/drm/radeon/radeon_benchmark.c b/drivers/gpu/drm/radeon/radeon_benchmark.c
index 7932dc4d6b90..c558685cc637 100644
--- a/drivers/gpu/drm/radeon/radeon_benchmark.c
+++ b/drivers/gpu/drm/radeon/radeon_benchmark.c
@@ -41,7 +41,7 @@ void radeon_benchmark_move(struct radeon_device *rdev, unsigned bsize,
41 41
42 size = bsize; 42 size = bsize;
43 n = 1024; 43 n = 1024;
44 r = radeon_bo_create(rdev, NULL, size, true, sdomain, &sobj); 44 r = radeon_bo_create(rdev, NULL, size, PAGE_SIZE, true, sdomain, &sobj);
45 if (r) { 45 if (r) {
46 goto out_cleanup; 46 goto out_cleanup;
47 } 47 }
@@ -53,7 +53,7 @@ void radeon_benchmark_move(struct radeon_device *rdev, unsigned bsize,
53 if (r) { 53 if (r) {
54 goto out_cleanup; 54 goto out_cleanup;
55 } 55 }
56 r = radeon_bo_create(rdev, NULL, size, true, ddomain, &dobj); 56 r = radeon_bo_create(rdev, NULL, size, PAGE_SIZE, true, ddomain, &dobj);
57 if (r) { 57 if (r) {
58 goto out_cleanup; 58 goto out_cleanup;
59 } 59 }
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 654787ec43f4..8f2c7b50dcf5 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -130,6 +130,7 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev)
130 } 130 }
131 return true; 131 return true;
132} 132}
133
133static bool r700_read_disabled_bios(struct radeon_device *rdev) 134static bool r700_read_disabled_bios(struct radeon_device *rdev)
134{ 135{
135 uint32_t viph_control; 136 uint32_t viph_control;
@@ -143,7 +144,7 @@ static bool r700_read_disabled_bios(struct radeon_device *rdev)
143 bool r; 144 bool r;
144 145
145 viph_control = RREG32(RADEON_VIPH_CONTROL); 146 viph_control = RREG32(RADEON_VIPH_CONTROL);
146 bus_cntl = RREG32(RADEON_BUS_CNTL); 147 bus_cntl = RREG32(R600_BUS_CNTL);
147 d1vga_control = RREG32(AVIVO_D1VGA_CONTROL); 148 d1vga_control = RREG32(AVIVO_D1VGA_CONTROL);
148 d2vga_control = RREG32(AVIVO_D2VGA_CONTROL); 149 d2vga_control = RREG32(AVIVO_D2VGA_CONTROL);
149 vga_render_control = RREG32(AVIVO_VGA_RENDER_CONTROL); 150 vga_render_control = RREG32(AVIVO_VGA_RENDER_CONTROL);
@@ -152,7 +153,7 @@ static bool r700_read_disabled_bios(struct radeon_device *rdev)
152 /* disable VIP */ 153 /* disable VIP */
153 WREG32(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN)); 154 WREG32(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN));
154 /* enable the rom */ 155 /* enable the rom */
155 WREG32(RADEON_BUS_CNTL, (bus_cntl & ~RADEON_BUS_BIOS_DIS_ROM)); 156 WREG32(R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS));
156 /* Disable VGA mode */ 157 /* Disable VGA mode */
157 WREG32(AVIVO_D1VGA_CONTROL, 158 WREG32(AVIVO_D1VGA_CONTROL,
158 (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 159 (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE |
@@ -191,7 +192,7 @@ static bool r700_read_disabled_bios(struct radeon_device *rdev)
191 cg_spll_status = RREG32(R600_CG_SPLL_STATUS); 192 cg_spll_status = RREG32(R600_CG_SPLL_STATUS);
192 } 193 }
193 WREG32(RADEON_VIPH_CONTROL, viph_control); 194 WREG32(RADEON_VIPH_CONTROL, viph_control);
194 WREG32(RADEON_BUS_CNTL, bus_cntl); 195 WREG32(R600_BUS_CNTL, bus_cntl);
195 WREG32(AVIVO_D1VGA_CONTROL, d1vga_control); 196 WREG32(AVIVO_D1VGA_CONTROL, d1vga_control);
196 WREG32(AVIVO_D2VGA_CONTROL, d2vga_control); 197 WREG32(AVIVO_D2VGA_CONTROL, d2vga_control);
197 WREG32(AVIVO_VGA_RENDER_CONTROL, vga_render_control); 198 WREG32(AVIVO_VGA_RENDER_CONTROL, vga_render_control);
@@ -216,7 +217,7 @@ static bool r600_read_disabled_bios(struct radeon_device *rdev)
216 bool r; 217 bool r;
217 218
218 viph_control = RREG32(RADEON_VIPH_CONTROL); 219 viph_control = RREG32(RADEON_VIPH_CONTROL);
219 bus_cntl = RREG32(RADEON_BUS_CNTL); 220 bus_cntl = RREG32(R600_BUS_CNTL);
220 d1vga_control = RREG32(AVIVO_D1VGA_CONTROL); 221 d1vga_control = RREG32(AVIVO_D1VGA_CONTROL);
221 d2vga_control = RREG32(AVIVO_D2VGA_CONTROL); 222 d2vga_control = RREG32(AVIVO_D2VGA_CONTROL);
222 vga_render_control = RREG32(AVIVO_VGA_RENDER_CONTROL); 223 vga_render_control = RREG32(AVIVO_VGA_RENDER_CONTROL);
@@ -231,7 +232,7 @@ static bool r600_read_disabled_bios(struct radeon_device *rdev)
231 /* disable VIP */ 232 /* disable VIP */
232 WREG32(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN)); 233 WREG32(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN));
233 /* enable the rom */ 234 /* enable the rom */
234 WREG32(RADEON_BUS_CNTL, (bus_cntl & ~RADEON_BUS_BIOS_DIS_ROM)); 235 WREG32(R600_BUS_CNTL, (bus_cntl & ~R600_BIOS_ROM_DIS));
235 /* Disable VGA mode */ 236 /* Disable VGA mode */
236 WREG32(AVIVO_D1VGA_CONTROL, 237 WREG32(AVIVO_D1VGA_CONTROL,
237 (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE | 238 (d1vga_control & ~(AVIVO_DVGA_CONTROL_MODE_ENABLE |
@@ -262,7 +263,7 @@ static bool r600_read_disabled_bios(struct radeon_device *rdev)
262 263
263 /* restore regs */ 264 /* restore regs */
264 WREG32(RADEON_VIPH_CONTROL, viph_control); 265 WREG32(RADEON_VIPH_CONTROL, viph_control);
265 WREG32(RADEON_BUS_CNTL, bus_cntl); 266 WREG32(R600_BUS_CNTL, bus_cntl);
266 WREG32(AVIVO_D1VGA_CONTROL, d1vga_control); 267 WREG32(AVIVO_D1VGA_CONTROL, d1vga_control);
267 WREG32(AVIVO_D2VGA_CONTROL, d2vga_control); 268 WREG32(AVIVO_D2VGA_CONTROL, d2vga_control);
268 WREG32(AVIVO_VGA_RENDER_CONTROL, vga_render_control); 269 WREG32(AVIVO_VGA_RENDER_CONTROL, vga_render_control);
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 7b7ea269549c..137b8075f6e7 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -571,6 +571,7 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde
571 } 571 }
572 572
573 if (clk_mask && data_mask) { 573 if (clk_mask && data_mask) {
574 /* system specific masks */
574 i2c.mask_clk_mask = clk_mask; 575 i2c.mask_clk_mask = clk_mask;
575 i2c.mask_data_mask = data_mask; 576 i2c.mask_data_mask = data_mask;
576 i2c.a_clk_mask = clk_mask; 577 i2c.a_clk_mask = clk_mask;
@@ -579,7 +580,19 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde
579 i2c.en_data_mask = data_mask; 580 i2c.en_data_mask = data_mask;
580 i2c.y_clk_mask = clk_mask; 581 i2c.y_clk_mask = clk_mask;
581 i2c.y_data_mask = data_mask; 582 i2c.y_data_mask = data_mask;
583 } else if ((ddc_line == RADEON_GPIOPAD_MASK) ||
584 (ddc_line == RADEON_MDGPIO_MASK)) {
585 /* default gpiopad masks */
586 i2c.mask_clk_mask = (0x20 << 8);
587 i2c.mask_data_mask = 0x80;
588 i2c.a_clk_mask = (0x20 << 8);
589 i2c.a_data_mask = 0x80;
590 i2c.en_clk_mask = (0x20 << 8);
591 i2c.en_data_mask = 0x80;
592 i2c.y_clk_mask = (0x20 << 8);
593 i2c.y_data_mask = 0x80;
582 } else { 594 } else {
595 /* default masks for ddc pads */
583 i2c.mask_clk_mask = RADEON_GPIO_EN_1; 596 i2c.mask_clk_mask = RADEON_GPIO_EN_1;
584 i2c.mask_data_mask = RADEON_GPIO_EN_0; 597 i2c.mask_data_mask = RADEON_GPIO_EN_0;
585 i2c.a_clk_mask = RADEON_GPIO_A_1; 598 i2c.a_clk_mask = RADEON_GPIO_A_1;
@@ -716,7 +729,7 @@ void radeon_combios_i2c_init(struct radeon_device *rdev)
716 clk = RBIOS8(offset + 3 + (i * 5) + 3); 729 clk = RBIOS8(offset + 3 + (i * 5) + 3);
717 data = RBIOS8(offset + 3 + (i * 5) + 4); 730 data = RBIOS8(offset + 3 + (i * 5) + 4);
718 i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 731 i2c = combios_setup_i2c_bus(rdev, DDC_MONID,
719 clk, data); 732 (1 << clk), (1 << data));
720 rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK"); 733 rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "GPIOPAD_MASK");
721 break; 734 break;
722 } 735 }
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index fe6c74780f18..8afaf7a7459e 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1008,9 +1008,21 @@ static void radeon_dp_connector_destroy(struct drm_connector *connector)
1008static int radeon_dp_get_modes(struct drm_connector *connector) 1008static int radeon_dp_get_modes(struct drm_connector *connector)
1009{ 1009{
1010 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1010 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1011 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1011 int ret; 1012 int ret;
1012 1013
1014 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
1015 if (!radeon_dig_connector->edp_on)
1016 atombios_set_edp_panel_power(connector,
1017 ATOM_TRANSMITTER_ACTION_POWER_ON);
1018 }
1013 ret = radeon_ddc_get_modes(radeon_connector); 1019 ret = radeon_ddc_get_modes(radeon_connector);
1020 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
1021 if (!radeon_dig_connector->edp_on)
1022 atombios_set_edp_panel_power(connector,
1023 ATOM_TRANSMITTER_ACTION_POWER_OFF);
1024 }
1025
1014 return ret; 1026 return ret;
1015} 1027}
1016 1028
@@ -1029,8 +1041,14 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1029 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { 1041 if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
1030 /* eDP is always DP */ 1042 /* eDP is always DP */
1031 radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; 1043 radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT;
1044 if (!radeon_dig_connector->edp_on)
1045 atombios_set_edp_panel_power(connector,
1046 ATOM_TRANSMITTER_ACTION_POWER_ON);
1032 if (radeon_dp_getdpcd(radeon_connector)) 1047 if (radeon_dp_getdpcd(radeon_connector))
1033 ret = connector_status_connected; 1048 ret = connector_status_connected;
1049 if (!radeon_dig_connector->edp_on)
1050 atombios_set_edp_panel_power(connector,
1051 ATOM_TRANSMITTER_ACTION_POWER_OFF);
1034 } else { 1052 } else {
1035 radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); 1053 radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector);
1036 if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { 1054 if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) {
@@ -1157,6 +1175,8 @@ radeon_add_atom_connector(struct drm_device *dev,
1157 /* no HPD on analog connectors */ 1175 /* no HPD on analog connectors */
1158 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1176 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1159 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 1177 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1178 connector->interlace_allowed = true;
1179 connector->doublescan_allowed = true;
1160 break; 1180 break;
1161 case DRM_MODE_CONNECTOR_DVIA: 1181 case DRM_MODE_CONNECTOR_DVIA:
1162 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 1182 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
@@ -1172,6 +1192,8 @@ radeon_add_atom_connector(struct drm_device *dev,
1172 1); 1192 1);
1173 /* no HPD on analog connectors */ 1193 /* no HPD on analog connectors */
1174 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1194 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1195 connector->interlace_allowed = true;
1196 connector->doublescan_allowed = true;
1175 break; 1197 break;
1176 case DRM_MODE_CONNECTOR_DVII: 1198 case DRM_MODE_CONNECTOR_DVII:
1177 case DRM_MODE_CONNECTOR_DVID: 1199 case DRM_MODE_CONNECTOR_DVID:
@@ -1208,6 +1230,11 @@ radeon_add_atom_connector(struct drm_device *dev,
1208 rdev->mode_info.load_detect_property, 1230 rdev->mode_info.load_detect_property,
1209 1); 1231 1);
1210 } 1232 }
1233 connector->interlace_allowed = true;
1234 if (connector_type == DRM_MODE_CONNECTOR_DVII)
1235 connector->doublescan_allowed = true;
1236 else
1237 connector->doublescan_allowed = false;
1211 break; 1238 break;
1212 case DRM_MODE_CONNECTOR_HDMIA: 1239 case DRM_MODE_CONNECTOR_HDMIA:
1213 case DRM_MODE_CONNECTOR_HDMIB: 1240 case DRM_MODE_CONNECTOR_HDMIB:
@@ -1238,6 +1265,11 @@ radeon_add_atom_connector(struct drm_device *dev,
1238 0); 1265 0);
1239 } 1266 }
1240 subpixel_order = SubPixelHorizontalRGB; 1267 subpixel_order = SubPixelHorizontalRGB;
1268 connector->interlace_allowed = true;
1269 if (connector_type == DRM_MODE_CONNECTOR_HDMIB)
1270 connector->doublescan_allowed = true;
1271 else
1272 connector->doublescan_allowed = false;
1241 break; 1273 break;
1242 case DRM_MODE_CONNECTOR_DisplayPort: 1274 case DRM_MODE_CONNECTOR_DisplayPort:
1243 case DRM_MODE_CONNECTOR_eDP: 1275 case DRM_MODE_CONNECTOR_eDP:
@@ -1275,6 +1307,9 @@ radeon_add_atom_connector(struct drm_device *dev,
1275 rdev->mode_info.underscan_vborder_property, 1307 rdev->mode_info.underscan_vborder_property,
1276 0); 1308 0);
1277 } 1309 }
1310 connector->interlace_allowed = true;
1311 /* in theory with a DP to VGA converter... */
1312 connector->doublescan_allowed = false;
1278 break; 1313 break;
1279 case DRM_MODE_CONNECTOR_SVIDEO: 1314 case DRM_MODE_CONNECTOR_SVIDEO:
1280 case DRM_MODE_CONNECTOR_Composite: 1315 case DRM_MODE_CONNECTOR_Composite:
@@ -1290,6 +1325,8 @@ radeon_add_atom_connector(struct drm_device *dev,
1290 radeon_atombios_get_tv_info(rdev)); 1325 radeon_atombios_get_tv_info(rdev));
1291 /* no HPD on analog connectors */ 1326 /* no HPD on analog connectors */
1292 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1327 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1328 connector->interlace_allowed = false;
1329 connector->doublescan_allowed = false;
1293 break; 1330 break;
1294 case DRM_MODE_CONNECTOR_LVDS: 1331 case DRM_MODE_CONNECTOR_LVDS:
1295 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); 1332 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
@@ -1308,6 +1345,8 @@ radeon_add_atom_connector(struct drm_device *dev,
1308 dev->mode_config.scaling_mode_property, 1345 dev->mode_config.scaling_mode_property,
1309 DRM_MODE_SCALE_FULLSCREEN); 1346 DRM_MODE_SCALE_FULLSCREEN);
1310 subpixel_order = SubPixelHorizontalRGB; 1347 subpixel_order = SubPixelHorizontalRGB;
1348 connector->interlace_allowed = false;
1349 connector->doublescan_allowed = false;
1311 break; 1350 break;
1312 } 1351 }
1313 1352
@@ -1385,6 +1424,8 @@ radeon_add_legacy_connector(struct drm_device *dev,
1385 /* no HPD on analog connectors */ 1424 /* no HPD on analog connectors */
1386 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1425 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1387 connector->polled = DRM_CONNECTOR_POLL_CONNECT; 1426 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1427 connector->interlace_allowed = true;
1428 connector->doublescan_allowed = true;
1388 break; 1429 break;
1389 case DRM_MODE_CONNECTOR_DVIA: 1430 case DRM_MODE_CONNECTOR_DVIA:
1390 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); 1431 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
@@ -1400,6 +1441,8 @@ radeon_add_legacy_connector(struct drm_device *dev,
1400 1); 1441 1);
1401 /* no HPD on analog connectors */ 1442 /* no HPD on analog connectors */
1402 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1443 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1444 connector->interlace_allowed = true;
1445 connector->doublescan_allowed = true;
1403 break; 1446 break;
1404 case DRM_MODE_CONNECTOR_DVII: 1447 case DRM_MODE_CONNECTOR_DVII:
1405 case DRM_MODE_CONNECTOR_DVID: 1448 case DRM_MODE_CONNECTOR_DVID:
@@ -1417,6 +1460,11 @@ radeon_add_legacy_connector(struct drm_device *dev,
1417 1); 1460 1);
1418 } 1461 }
1419 subpixel_order = SubPixelHorizontalRGB; 1462 subpixel_order = SubPixelHorizontalRGB;
1463 connector->interlace_allowed = true;
1464 if (connector_type == DRM_MODE_CONNECTOR_DVII)
1465 connector->doublescan_allowed = true;
1466 else
1467 connector->doublescan_allowed = false;
1420 break; 1468 break;
1421 case DRM_MODE_CONNECTOR_SVIDEO: 1469 case DRM_MODE_CONNECTOR_SVIDEO:
1422 case DRM_MODE_CONNECTOR_Composite: 1470 case DRM_MODE_CONNECTOR_Composite:
@@ -1439,6 +1487,8 @@ radeon_add_legacy_connector(struct drm_device *dev,
1439 radeon_combios_get_tv_info(rdev)); 1487 radeon_combios_get_tv_info(rdev));
1440 /* no HPD on analog connectors */ 1488 /* no HPD on analog connectors */
1441 radeon_connector->hpd.hpd = RADEON_HPD_NONE; 1489 radeon_connector->hpd.hpd = RADEON_HPD_NONE;
1490 connector->interlace_allowed = false;
1491 connector->doublescan_allowed = false;
1442 break; 1492 break;
1443 case DRM_MODE_CONNECTOR_LVDS: 1493 case DRM_MODE_CONNECTOR_LVDS:
1444 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); 1494 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type);
@@ -1452,6 +1502,8 @@ radeon_add_legacy_connector(struct drm_device *dev,
1452 dev->mode_config.scaling_mode_property, 1502 dev->mode_config.scaling_mode_property,
1453 DRM_MODE_SCALE_FULLSCREEN); 1503 DRM_MODE_SCALE_FULLSCREEN);
1454 subpixel_order = SubPixelHorizontalRGB; 1504 subpixel_order = SubPixelHorizontalRGB;
1505 connector->interlace_allowed = false;
1506 connector->doublescan_allowed = false;
1455 break; 1507 break;
1456 } 1508 }
1457 1509
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 8adfedfe547f..e12e79326cb1 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -180,7 +180,7 @@ int radeon_wb_init(struct radeon_device *rdev)
180 int r; 180 int r;
181 181
182 if (rdev->wb.wb_obj == NULL) { 182 if (rdev->wb.wb_obj == NULL) {
183 r = radeon_bo_create(rdev, NULL, RADEON_GPU_PAGE_SIZE, true, 183 r = radeon_bo_create(rdev, NULL, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true,
184 RADEON_GEM_DOMAIN_GTT, &rdev->wb.wb_obj); 184 RADEON_GEM_DOMAIN_GTT, &rdev->wb.wb_obj);
185 if (r) { 185 if (r) {
186 dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); 186 dev_warn(rdev->dev, "(%d) create WB bo failed\n", r);
@@ -286,7 +286,7 @@ void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64
286 mc->mc_vram_size = mc->aper_size; 286 mc->mc_vram_size = mc->aper_size;
287 } 287 }
288 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; 288 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
289 dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n", 289 dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n",
290 mc->mc_vram_size >> 20, mc->vram_start, 290 mc->mc_vram_size >> 20, mc->vram_start,
291 mc->vram_end, mc->real_vram_size >> 20); 291 mc->vram_end, mc->real_vram_size >> 20);
292} 292}
@@ -323,7 +323,7 @@ void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
323 mc->gtt_start = (mc->vram_end + 1 + mc->gtt_base_align) & ~mc->gtt_base_align; 323 mc->gtt_start = (mc->vram_end + 1 + mc->gtt_base_align) & ~mc->gtt_base_align;
324 } 324 }
325 mc->gtt_end = mc->gtt_start + mc->gtt_size - 1; 325 mc->gtt_end = mc->gtt_start + mc->gtt_size - 1;
326 dev_info(rdev->dev, "GTT: %lluM 0x%08llX - 0x%08llX\n", 326 dev_info(rdev->dev, "GTT: %lluM 0x%016llX - 0x%016llX\n",
327 mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end); 327 mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end);
328} 328}
329 329
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index f678257c42e6..041943df966b 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -176,6 +176,7 @@ static inline bool radeon_encoder_is_digital(struct drm_encoder *encoder)
176 return false; 176 return false;
177 } 177 }
178} 178}
179
179void 180void
180radeon_link_encoder_connector(struct drm_device *dev) 181radeon_link_encoder_connector(struct drm_device *dev)
181{ 182{
@@ -228,6 +229,27 @@ radeon_get_connector_for_encoder(struct drm_encoder *encoder)
228 return NULL; 229 return NULL;
229} 230}
230 231
232struct drm_encoder *radeon_atom_get_external_encoder(struct drm_encoder *encoder)
233{
234 struct drm_device *dev = encoder->dev;
235 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
236 struct drm_encoder *other_encoder;
237 struct radeon_encoder *other_radeon_encoder;
238
239 if (radeon_encoder->is_ext_encoder)
240 return NULL;
241
242 list_for_each_entry(other_encoder, &dev->mode_config.encoder_list, head) {
243 if (other_encoder == encoder)
244 continue;
245 other_radeon_encoder = to_radeon_encoder(other_encoder);
246 if (other_radeon_encoder->is_ext_encoder &&
247 (radeon_encoder->devices & other_radeon_encoder->devices))
248 return other_encoder;
249 }
250 return NULL;
251}
252
231void radeon_panel_mode_fixup(struct drm_encoder *encoder, 253void radeon_panel_mode_fixup(struct drm_encoder *encoder,
232 struct drm_display_mode *adjusted_mode) 254 struct drm_display_mode *adjusted_mode)
233{ 255{
@@ -426,52 +448,49 @@ atombios_tv_setup(struct drm_encoder *encoder, int action)
426 448
427} 449}
428 450
429void 451union dvo_encoder_control {
430atombios_external_tmds_setup(struct drm_encoder *encoder, int action) 452 ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION ext_tmds;
431{ 453 DVO_ENCODER_CONTROL_PS_ALLOCATION dvo;
432 struct drm_device *dev = encoder->dev; 454 DVO_ENCODER_CONTROL_PS_ALLOCATION_V3 dvo_v3;
433 struct radeon_device *rdev = dev->dev_private; 455};
434 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
435 ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION args;
436 int index = 0;
437
438 memset(&args, 0, sizeof(args));
439
440 index = GetIndexIntoMasterTable(COMMAND, DVOEncoderControl);
441
442 args.sXTmdsEncoder.ucEnable = action;
443
444 if (radeon_encoder->pixel_clock > 165000)
445 args.sXTmdsEncoder.ucMisc = PANEL_ENCODER_MISC_DUAL;
446
447 /*if (pScrn->rgbBits == 8)*/
448 args.sXTmdsEncoder.ucMisc |= (1 << 1);
449
450 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
451
452}
453 456
454static void 457void
455atombios_ddia_setup(struct drm_encoder *encoder, int action) 458atombios_dvo_setup(struct drm_encoder *encoder, int action)
456{ 459{
457 struct drm_device *dev = encoder->dev; 460 struct drm_device *dev = encoder->dev;
458 struct radeon_device *rdev = dev->dev_private; 461 struct radeon_device *rdev = dev->dev_private;
459 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 462 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
460 DVO_ENCODER_CONTROL_PS_ALLOCATION args; 463 union dvo_encoder_control args;
461 int index = 0; 464 int index = GetIndexIntoMasterTable(COMMAND, DVOEncoderControl);
462 465
463 memset(&args, 0, sizeof(args)); 466 memset(&args, 0, sizeof(args));
464 467
465 index = GetIndexIntoMasterTable(COMMAND, DVOEncoderControl); 468 if (ASIC_IS_DCE3(rdev)) {
469 /* DCE3+ */
470 args.dvo_v3.ucAction = action;
471 args.dvo_v3.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
472 args.dvo_v3.ucDVOConfig = 0; /* XXX */
473 } else if (ASIC_IS_DCE2(rdev)) {
474 /* DCE2 (pre-DCE3 R6xx, RS600/690/740 */
475 args.dvo.sDVOEncoder.ucAction = action;
476 args.dvo.sDVOEncoder.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
477 /* DFP1, CRT1, TV1 depending on the type of port */
478 args.dvo.sDVOEncoder.ucDeviceType = ATOM_DEVICE_DFP1_INDEX;
479
480 if (radeon_encoder->pixel_clock > 165000)
481 args.dvo.sDVOEncoder.usDevAttr.sDigAttrib.ucAttribute |= PANEL_ENCODER_MISC_DUAL;
482 } else {
483 /* R4xx, R5xx */
484 args.ext_tmds.sXTmdsEncoder.ucEnable = action;
466 485
467 args.sDVOEncoder.ucAction = action; 486 if (radeon_encoder->pixel_clock > 165000)
468 args.sDVOEncoder.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); 487 args.ext_tmds.sXTmdsEncoder.ucMisc |= PANEL_ENCODER_MISC_DUAL;
469 488
470 if (radeon_encoder->pixel_clock > 165000) 489 /*if (pScrn->rgbBits == 8)*/
471 args.sDVOEncoder.usDevAttr.sDigAttrib.ucAttribute = PANEL_ENCODER_MISC_DUAL; 490 args.ext_tmds.sXTmdsEncoder.ucMisc |= ATOM_PANEL_MISC_888RGB;
491 }
472 492
473 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 493 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
474
475} 494}
476 495
477union lvds_encoder_control { 496union lvds_encoder_control {
@@ -532,14 +551,14 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
532 if (dig->lcd_misc & ATOM_PANEL_MISC_DUAL) 551 if (dig->lcd_misc & ATOM_PANEL_MISC_DUAL)
533 args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL; 552 args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL;
534 if (dig->lcd_misc & ATOM_PANEL_MISC_888RGB) 553 if (dig->lcd_misc & ATOM_PANEL_MISC_888RGB)
535 args.v1.ucMisc |= (1 << 1); 554 args.v1.ucMisc |= ATOM_PANEL_MISC_888RGB;
536 } else { 555 } else {
537 if (dig->linkb) 556 if (dig->linkb)
538 args.v1.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB; 557 args.v1.ucMisc |= PANEL_ENCODER_MISC_TMDS_LINKB;
539 if (radeon_encoder->pixel_clock > 165000) 558 if (radeon_encoder->pixel_clock > 165000)
540 args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL; 559 args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL;
541 /*if (pScrn->rgbBits == 8) */ 560 /*if (pScrn->rgbBits == 8) */
542 args.v1.ucMisc |= (1 << 1); 561 args.v1.ucMisc |= ATOM_PANEL_MISC_888RGB;
543 } 562 }
544 break; 563 break;
545 case 2: 564 case 2:
@@ -595,6 +614,7 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
595int 614int
596atombios_get_encoder_mode(struct drm_encoder *encoder) 615atombios_get_encoder_mode(struct drm_encoder *encoder)
597{ 616{
617 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
598 struct drm_device *dev = encoder->dev; 618 struct drm_device *dev = encoder->dev;
599 struct radeon_device *rdev = dev->dev_private; 619 struct radeon_device *rdev = dev->dev_private;
600 struct drm_connector *connector; 620 struct drm_connector *connector;
@@ -602,9 +622,20 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
602 struct radeon_connector_atom_dig *dig_connector; 622 struct radeon_connector_atom_dig *dig_connector;
603 623
604 connector = radeon_get_connector_for_encoder(encoder); 624 connector = radeon_get_connector_for_encoder(encoder);
605 if (!connector) 625 if (!connector) {
606 return 0; 626 switch (radeon_encoder->encoder_id) {
607 627 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
628 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
629 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
630 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
631 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
632 return ATOM_ENCODER_MODE_DVI;
633 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
634 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
635 default:
636 return ATOM_ENCODER_MODE_CRT;
637 }
638 }
608 radeon_connector = to_radeon_connector(connector); 639 radeon_connector = to_radeon_connector(connector);
609 640
610 switch (connector->connector_type) { 641 switch (connector->connector_type) {
@@ -834,6 +865,9 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
834 memset(&args, 0, sizeof(args)); 865 memset(&args, 0, sizeof(args));
835 866
836 switch (radeon_encoder->encoder_id) { 867 switch (radeon_encoder->encoder_id) {
868 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
869 index = GetIndexIntoMasterTable(COMMAND, DVOOutputControl);
870 break;
837 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: 871 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
838 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: 872 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
839 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: 873 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
@@ -978,6 +1012,105 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
978 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 1012 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
979} 1013}
980 1014
1015void
1016atombios_set_edp_panel_power(struct drm_connector *connector, int action)
1017{
1018 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1019 struct drm_device *dev = radeon_connector->base.dev;
1020 struct radeon_device *rdev = dev->dev_private;
1021 union dig_transmitter_control args;
1022 int index = GetIndexIntoMasterTable(COMMAND, UNIPHYTransmitterControl);
1023 uint8_t frev, crev;
1024
1025 if (connector->connector_type != DRM_MODE_CONNECTOR_eDP)
1026 return;
1027
1028 if (!ASIC_IS_DCE4(rdev))
1029 return;
1030
1031 if ((action != ATOM_TRANSMITTER_ACTION_POWER_ON) ||
1032 (action != ATOM_TRANSMITTER_ACTION_POWER_OFF))
1033 return;
1034
1035 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
1036 return;
1037
1038 memset(&args, 0, sizeof(args));
1039
1040 args.v1.ucAction = action;
1041
1042 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1043}
1044
1045union external_encoder_control {
1046 EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION v1;
1047};
1048
1049static void
1050atombios_external_encoder_setup(struct drm_encoder *encoder,
1051 struct drm_encoder *ext_encoder,
1052 int action)
1053{
1054 struct drm_device *dev = encoder->dev;
1055 struct radeon_device *rdev = dev->dev_private;
1056 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1057 union external_encoder_control args;
1058 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1059 int index = GetIndexIntoMasterTable(COMMAND, ExternalEncoderControl);
1060 u8 frev, crev;
1061 int dp_clock = 0;
1062 int dp_lane_count = 0;
1063 int connector_object_id = 0;
1064
1065 if (connector) {
1066 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1067 struct radeon_connector_atom_dig *dig_connector =
1068 radeon_connector->con_priv;
1069
1070 dp_clock = dig_connector->dp_clock;
1071 dp_lane_count = dig_connector->dp_lane_count;
1072 connector_object_id =
1073 (radeon_connector->connector_object_id & OBJECT_ID_MASK) >> OBJECT_ID_SHIFT;
1074 }
1075
1076 memset(&args, 0, sizeof(args));
1077
1078 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
1079 return;
1080
1081 switch (frev) {
1082 case 1:
1083 /* no params on frev 1 */
1084 break;
1085 case 2:
1086 switch (crev) {
1087 case 1:
1088 case 2:
1089 args.v1.sDigEncoder.ucAction = action;
1090 args.v1.sDigEncoder.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
1091 args.v1.sDigEncoder.ucEncoderMode = atombios_get_encoder_mode(encoder);
1092
1093 if (args.v1.sDigEncoder.ucEncoderMode == ATOM_ENCODER_MODE_DP) {
1094 if (dp_clock == 270000)
1095 args.v1.sDigEncoder.ucConfig |= ATOM_ENCODER_CONFIG_DPLINKRATE_2_70GHZ;
1096 args.v1.sDigEncoder.ucLaneNum = dp_lane_count;
1097 } else if (radeon_encoder->pixel_clock > 165000)
1098 args.v1.sDigEncoder.ucLaneNum = 8;
1099 else
1100 args.v1.sDigEncoder.ucLaneNum = 4;
1101 break;
1102 default:
1103 DRM_ERROR("Unknown table version: %d, %d\n", frev, crev);
1104 return;
1105 }
1106 break;
1107 default:
1108 DRM_ERROR("Unknown table version: %d, %d\n", frev, crev);
1109 return;
1110 }
1111 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1112}
1113
981static void 1114static void
982atombios_yuv_setup(struct drm_encoder *encoder, bool enable) 1115atombios_yuv_setup(struct drm_encoder *encoder, bool enable)
983{ 1116{
@@ -1021,6 +1154,7 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1021 struct drm_device *dev = encoder->dev; 1154 struct drm_device *dev = encoder->dev;
1022 struct radeon_device *rdev = dev->dev_private; 1155 struct radeon_device *rdev = dev->dev_private;
1023 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1156 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1157 struct drm_encoder *ext_encoder = radeon_atom_get_external_encoder(encoder);
1024 DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION args; 1158 DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION args;
1025 int index = 0; 1159 int index = 0;
1026 bool is_dig = false; 1160 bool is_dig = false;
@@ -1043,9 +1177,14 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1043 break; 1177 break;
1044 case ENCODER_OBJECT_ID_INTERNAL_DVO1: 1178 case ENCODER_OBJECT_ID_INTERNAL_DVO1:
1045 case ENCODER_OBJECT_ID_INTERNAL_DDI: 1179 case ENCODER_OBJECT_ID_INTERNAL_DDI:
1046 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1047 index = GetIndexIntoMasterTable(COMMAND, DVOOutputControl); 1180 index = GetIndexIntoMasterTable(COMMAND, DVOOutputControl);
1048 break; 1181 break;
1182 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1183 if (ASIC_IS_DCE3(rdev))
1184 is_dig = true;
1185 else
1186 index = GetIndexIntoMasterTable(COMMAND, DVOOutputControl);
1187 break;
1049 case ENCODER_OBJECT_ID_INTERNAL_LVDS: 1188 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1050 index = GetIndexIntoMasterTable(COMMAND, LCD1OutputControl); 1189 index = GetIndexIntoMasterTable(COMMAND, LCD1OutputControl);
1051 break; 1190 break;
@@ -1082,34 +1221,85 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1082 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) { 1221 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
1083 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); 1222 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1084 1223
1224 if (connector &&
1225 (connector->connector_type == DRM_MODE_CONNECTOR_eDP)) {
1226 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1227 struct radeon_connector_atom_dig *radeon_dig_connector =
1228 radeon_connector->con_priv;
1229 atombios_set_edp_panel_power(connector,
1230 ATOM_TRANSMITTER_ACTION_POWER_ON);
1231 radeon_dig_connector->edp_on = true;
1232 }
1085 dp_link_train(encoder, connector); 1233 dp_link_train(encoder, connector);
1086 if (ASIC_IS_DCE4(rdev)) 1234 if (ASIC_IS_DCE4(rdev))
1087 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON); 1235 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON);
1088 } 1236 }
1237 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
1238 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_LCD_BLON, 0, 0);
1089 break; 1239 break;
1090 case DRM_MODE_DPMS_STANDBY: 1240 case DRM_MODE_DPMS_STANDBY:
1091 case DRM_MODE_DPMS_SUSPEND: 1241 case DRM_MODE_DPMS_SUSPEND:
1092 case DRM_MODE_DPMS_OFF: 1242 case DRM_MODE_DPMS_OFF:
1093 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0); 1243 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0);
1094 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) { 1244 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
1245 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1246
1095 if (ASIC_IS_DCE4(rdev)) 1247 if (ASIC_IS_DCE4(rdev))
1096 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_OFF); 1248 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_OFF);
1249 if (connector &&
1250 (connector->connector_type == DRM_MODE_CONNECTOR_eDP)) {
1251 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1252 struct radeon_connector_atom_dig *radeon_dig_connector =
1253 radeon_connector->con_priv;
1254 atombios_set_edp_panel_power(connector,
1255 ATOM_TRANSMITTER_ACTION_POWER_OFF);
1256 radeon_dig_connector->edp_on = false;
1257 }
1097 } 1258 }
1259 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
1260 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_LCD_BLOFF, 0, 0);
1098 break; 1261 break;
1099 } 1262 }
1100 } else { 1263 } else {
1101 switch (mode) { 1264 switch (mode) {
1102 case DRM_MODE_DPMS_ON: 1265 case DRM_MODE_DPMS_ON:
1103 args.ucAction = ATOM_ENABLE; 1266 args.ucAction = ATOM_ENABLE;
1267 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1268 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
1269 args.ucAction = ATOM_LCD_BLON;
1270 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1271 }
1104 break; 1272 break;
1105 case DRM_MODE_DPMS_STANDBY: 1273 case DRM_MODE_DPMS_STANDBY:
1106 case DRM_MODE_DPMS_SUSPEND: 1274 case DRM_MODE_DPMS_SUSPEND:
1107 case DRM_MODE_DPMS_OFF: 1275 case DRM_MODE_DPMS_OFF:
1108 args.ucAction = ATOM_DISABLE; 1276 args.ucAction = ATOM_DISABLE;
1277 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1278 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
1279 args.ucAction = ATOM_LCD_BLOFF;
1280 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1281 }
1109 break; 1282 break;
1110 } 1283 }
1111 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1112 } 1284 }
1285
1286 if (ext_encoder) {
1287 int action;
1288
1289 switch (mode) {
1290 case DRM_MODE_DPMS_ON:
1291 default:
1292 action = ATOM_ENABLE;
1293 break;
1294 case DRM_MODE_DPMS_STANDBY:
1295 case DRM_MODE_DPMS_SUSPEND:
1296 case DRM_MODE_DPMS_OFF:
1297 action = ATOM_DISABLE;
1298 break;
1299 }
1300 atombios_external_encoder_setup(encoder, ext_encoder, action);
1301 }
1302
1113 radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false); 1303 radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
1114 1304
1115} 1305}
@@ -1242,7 +1432,7 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
1242 break; 1432 break;
1243 default: 1433 default:
1244 DRM_ERROR("Unknown table version: %d, %d\n", frev, crev); 1434 DRM_ERROR("Unknown table version: %d, %d\n", frev, crev);
1245 break; 1435 return;
1246 } 1436 }
1247 1437
1248 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 1438 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
@@ -1357,6 +1547,7 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
1357 struct drm_device *dev = encoder->dev; 1547 struct drm_device *dev = encoder->dev;
1358 struct radeon_device *rdev = dev->dev_private; 1548 struct radeon_device *rdev = dev->dev_private;
1359 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1549 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1550 struct drm_encoder *ext_encoder = radeon_atom_get_external_encoder(encoder);
1360 1551
1361 radeon_encoder->pixel_clock = adjusted_mode->clock; 1552 radeon_encoder->pixel_clock = adjusted_mode->clock;
1362 1553
@@ -1400,11 +1591,9 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
1400 } 1591 }
1401 break; 1592 break;
1402 case ENCODER_OBJECT_ID_INTERNAL_DDI: 1593 case ENCODER_OBJECT_ID_INTERNAL_DDI:
1403 atombios_ddia_setup(encoder, ATOM_ENABLE);
1404 break;
1405 case ENCODER_OBJECT_ID_INTERNAL_DVO1: 1594 case ENCODER_OBJECT_ID_INTERNAL_DVO1:
1406 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: 1595 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1407 atombios_external_tmds_setup(encoder, ATOM_ENABLE); 1596 atombios_dvo_setup(encoder, ATOM_ENABLE);
1408 break; 1597 break;
1409 case ENCODER_OBJECT_ID_INTERNAL_DAC1: 1598 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1410 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: 1599 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
@@ -1419,6 +1608,11 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
1419 } 1608 }
1420 break; 1609 break;
1421 } 1610 }
1611
1612 if (ext_encoder) {
1613 atombios_external_encoder_setup(encoder, ext_encoder, ATOM_ENABLE);
1614 }
1615
1422 atombios_apply_encoder_quirks(encoder, adjusted_mode); 1616 atombios_apply_encoder_quirks(encoder, adjusted_mode);
1423 1617
1424 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) { 1618 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) {
@@ -1595,11 +1789,9 @@ static void radeon_atom_encoder_disable(struct drm_encoder *encoder)
1595 } 1789 }
1596 break; 1790 break;
1597 case ENCODER_OBJECT_ID_INTERNAL_DDI: 1791 case ENCODER_OBJECT_ID_INTERNAL_DDI:
1598 atombios_ddia_setup(encoder, ATOM_DISABLE);
1599 break;
1600 case ENCODER_OBJECT_ID_INTERNAL_DVO1: 1792 case ENCODER_OBJECT_ID_INTERNAL_DVO1:
1601 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1: 1793 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
1602 atombios_external_tmds_setup(encoder, ATOM_DISABLE); 1794 atombios_dvo_setup(encoder, ATOM_DISABLE);
1603 break; 1795 break;
1604 case ENCODER_OBJECT_ID_INTERNAL_DAC1: 1796 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1605 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: 1797 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
@@ -1621,6 +1813,53 @@ disable_done:
1621 radeon_encoder->active_device = 0; 1813 radeon_encoder->active_device = 0;
1622} 1814}
1623 1815
1816/* these are handled by the primary encoders */
1817static void radeon_atom_ext_prepare(struct drm_encoder *encoder)
1818{
1819
1820}
1821
1822static void radeon_atom_ext_commit(struct drm_encoder *encoder)
1823{
1824
1825}
1826
1827static void
1828radeon_atom_ext_mode_set(struct drm_encoder *encoder,
1829 struct drm_display_mode *mode,
1830 struct drm_display_mode *adjusted_mode)
1831{
1832
1833}
1834
1835static void radeon_atom_ext_disable(struct drm_encoder *encoder)
1836{
1837
1838}
1839
1840static void
1841radeon_atom_ext_dpms(struct drm_encoder *encoder, int mode)
1842{
1843
1844}
1845
1846static bool radeon_atom_ext_mode_fixup(struct drm_encoder *encoder,
1847 struct drm_display_mode *mode,
1848 struct drm_display_mode *adjusted_mode)
1849{
1850 return true;
1851}
1852
1853static const struct drm_encoder_helper_funcs radeon_atom_ext_helper_funcs = {
1854 .dpms = radeon_atom_ext_dpms,
1855 .mode_fixup = radeon_atom_ext_mode_fixup,
1856 .prepare = radeon_atom_ext_prepare,
1857 .mode_set = radeon_atom_ext_mode_set,
1858 .commit = radeon_atom_ext_commit,
1859 .disable = radeon_atom_ext_disable,
1860 /* no detect for TMDS/LVDS yet */
1861};
1862
1624static const struct drm_encoder_helper_funcs radeon_atom_dig_helper_funcs = { 1863static const struct drm_encoder_helper_funcs radeon_atom_dig_helper_funcs = {
1625 .dpms = radeon_atom_encoder_dpms, 1864 .dpms = radeon_atom_encoder_dpms,
1626 .mode_fixup = radeon_atom_mode_fixup, 1865 .mode_fixup = radeon_atom_mode_fixup,
@@ -1730,6 +1969,7 @@ radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_enum, uint32_t
1730 radeon_encoder->devices = supported_device; 1969 radeon_encoder->devices = supported_device;
1731 radeon_encoder->rmx_type = RMX_OFF; 1970 radeon_encoder->rmx_type = RMX_OFF;
1732 radeon_encoder->underscan_type = UNDERSCAN_OFF; 1971 radeon_encoder->underscan_type = UNDERSCAN_OFF;
1972 radeon_encoder->is_ext_encoder = false;
1733 1973
1734 switch (radeon_encoder->encoder_id) { 1974 switch (radeon_encoder->encoder_id) {
1735 case ENCODER_OBJECT_ID_INTERNAL_LVDS: 1975 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
@@ -1771,6 +2011,9 @@ radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_enum, uint32_t
1771 radeon_encoder->rmx_type = RMX_FULL; 2011 radeon_encoder->rmx_type = RMX_FULL;
1772 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_LVDS); 2012 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_LVDS);
1773 radeon_encoder->enc_priv = radeon_atombios_get_lvds_info(radeon_encoder); 2013 radeon_encoder->enc_priv = radeon_atombios_get_lvds_info(radeon_encoder);
2014 } else if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) {
2015 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_DAC);
2016 radeon_encoder->enc_priv = radeon_atombios_set_dig_info(radeon_encoder);
1774 } else { 2017 } else {
1775 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TMDS); 2018 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TMDS);
1776 radeon_encoder->enc_priv = radeon_atombios_set_dig_info(radeon_encoder); 2019 radeon_encoder->enc_priv = radeon_atombios_set_dig_info(radeon_encoder);
@@ -1779,5 +2022,22 @@ radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_enum, uint32_t
1779 } 2022 }
1780 drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs); 2023 drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs);
1781 break; 2024 break;
2025 case ENCODER_OBJECT_ID_SI170B:
2026 case ENCODER_OBJECT_ID_CH7303:
2027 case ENCODER_OBJECT_ID_EXTERNAL_SDVOA:
2028 case ENCODER_OBJECT_ID_EXTERNAL_SDVOB:
2029 case ENCODER_OBJECT_ID_TITFP513:
2030 case ENCODER_OBJECT_ID_VT1623:
2031 case ENCODER_OBJECT_ID_HDMI_SI1930:
2032 /* these are handled by the primary encoders */
2033 radeon_encoder->is_ext_encoder = true;
2034 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
2035 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_LVDS);
2036 else if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT))
2037 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_DAC);
2038 else
2039 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_TMDS);
2040 drm_encoder_helper_add(encoder, &radeon_atom_ext_helper_funcs);
2041 break;
1782 } 2042 }
1783} 2043}
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index e65b90317fab..65016117d95f 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -79,8 +79,8 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev)
79 79
80 if (rdev->gart.table.vram.robj == NULL) { 80 if (rdev->gart.table.vram.robj == NULL) {
81 r = radeon_bo_create(rdev, NULL, rdev->gart.table_size, 81 r = radeon_bo_create(rdev, NULL, rdev->gart.table_size,
82 true, RADEON_GEM_DOMAIN_VRAM, 82 PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
83 &rdev->gart.table.vram.robj); 83 &rdev->gart.table.vram.robj);
84 if (r) { 84 if (r) {
85 return r; 85 return r;
86 } 86 }
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index d1e595d91723..df95eb83dac6 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -67,7 +67,7 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size,
67 if (alignment < PAGE_SIZE) { 67 if (alignment < PAGE_SIZE) {
68 alignment = PAGE_SIZE; 68 alignment = PAGE_SIZE;
69 } 69 }
70 r = radeon_bo_create(rdev, gobj, size, kernel, initial_domain, &robj); 70 r = radeon_bo_create(rdev, gobj, size, alignment, kernel, initial_domain, &robj);
71 if (r) { 71 if (r) {
72 if (r != -ERESTARTSYS) 72 if (r != -ERESTARTSYS)
73 DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n", 73 DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n",
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 0cfbba02c4d0..ded2a45bc95c 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -896,7 +896,8 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
896 ((rdev->family <= CHIP_RS480) || 896 ((rdev->family <= CHIP_RS480) ||
897 ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) { 897 ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) {
898 /* set the radeon hw i2c adapter */ 898 /* set the radeon hw i2c adapter */
899 sprintf(i2c->adapter.name, "Radeon i2c hw bus %s", name); 899 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
900 "Radeon i2c hw bus %s", name);
900 i2c->adapter.algo = &radeon_i2c_algo; 901 i2c->adapter.algo = &radeon_i2c_algo;
901 ret = i2c_add_adapter(&i2c->adapter); 902 ret = i2c_add_adapter(&i2c->adapter);
902 if (ret) { 903 if (ret) {
@@ -905,7 +906,8 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
905 } 906 }
906 } else { 907 } else {
907 /* set the radeon bit adapter */ 908 /* set the radeon bit adapter */
908 sprintf(i2c->adapter.name, "Radeon i2c bit bus %s", name); 909 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
910 "Radeon i2c bit bus %s", name);
909 i2c->adapter.algo_data = &i2c->algo.bit; 911 i2c->adapter.algo_data = &i2c->algo.bit;
910 i2c->algo.bit.pre_xfer = pre_xfer; 912 i2c->algo.bit.pre_xfer = pre_xfer;
911 i2c->algo.bit.post_xfer = post_xfer; 913 i2c->algo.bit.post_xfer = post_xfer;
@@ -946,6 +948,8 @@ struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
946 i2c->rec = *rec; 948 i2c->rec = *rec;
947 i2c->adapter.owner = THIS_MODULE; 949 i2c->adapter.owner = THIS_MODULE;
948 i2c->dev = dev; 950 i2c->dev = dev;
951 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
952 "Radeon aux bus %s", name);
949 i2c_set_adapdata(&i2c->adapter, i2c); 953 i2c_set_adapdata(&i2c->adapter, i2c);
950 i2c->adapter.algo_data = &i2c->algo.dp; 954 i2c->adapter.algo_data = &i2c->algo.dp;
951 i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch; 955 i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch;
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index 2f349a300195..465746bd51b7 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -76,7 +76,7 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
76 default: 76 default:
77 DRM_ERROR("tried to enable vblank on non-existent crtc %d\n", 77 DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
78 crtc); 78 crtc);
79 return EINVAL; 79 return -EINVAL;
80 } 80 }
81 } else { 81 } else {
82 switch (crtc) { 82 switch (crtc) {
@@ -89,7 +89,7 @@ int radeon_enable_vblank(struct drm_device *dev, int crtc)
89 default: 89 default:
90 DRM_ERROR("tried to enable vblank on non-existent crtc %d\n", 90 DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
91 crtc); 91 crtc);
92 return EINVAL; 92 return -EINVAL;
93 } 93 }
94 } 94 }
95 95
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index 0b8397000f4c..59f834ba283d 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -670,7 +670,7 @@ static void radeon_legacy_tmds_ext_mode_set(struct drm_encoder *encoder,
670 670
671 if (rdev->is_atom_bios) { 671 if (rdev->is_atom_bios) {
672 radeon_encoder->pixel_clock = adjusted_mode->clock; 672 radeon_encoder->pixel_clock = adjusted_mode->clock;
673 atombios_external_tmds_setup(encoder, ATOM_ENABLE); 673 atombios_dvo_setup(encoder, ATOM_ENABLE);
674 fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL); 674 fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
675 } else { 675 } else {
676 fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL); 676 fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 680f57644e86..e301c6f9e059 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -375,6 +375,7 @@ struct radeon_encoder {
375 int hdmi_config_offset; 375 int hdmi_config_offset;
376 int hdmi_audio_workaround; 376 int hdmi_audio_workaround;
377 int hdmi_buffer_status; 377 int hdmi_buffer_status;
378 bool is_ext_encoder;
378}; 379};
379 380
380struct radeon_connector_atom_dig { 381struct radeon_connector_atom_dig {
@@ -385,6 +386,7 @@ struct radeon_connector_atom_dig {
385 u8 dp_sink_type; 386 u8 dp_sink_type;
386 int dp_clock; 387 int dp_clock;
387 int dp_lane_count; 388 int dp_lane_count;
389 bool edp_on;
388}; 390};
389 391
390struct radeon_gpio_rec { 392struct radeon_gpio_rec {
@@ -523,9 +525,10 @@ struct drm_encoder *radeon_encoder_legacy_primary_dac_add(struct drm_device *dev
523struct drm_encoder *radeon_encoder_legacy_tv_dac_add(struct drm_device *dev, int bios_index, int with_tv); 525struct drm_encoder *radeon_encoder_legacy_tv_dac_add(struct drm_device *dev, int bios_index, int with_tv);
524struct drm_encoder *radeon_encoder_legacy_tmds_int_add(struct drm_device *dev, int bios_index); 526struct drm_encoder *radeon_encoder_legacy_tmds_int_add(struct drm_device *dev, int bios_index);
525struct drm_encoder *radeon_encoder_legacy_tmds_ext_add(struct drm_device *dev, int bios_index); 527struct drm_encoder *radeon_encoder_legacy_tmds_ext_add(struct drm_device *dev, int bios_index);
526extern void atombios_external_tmds_setup(struct drm_encoder *encoder, int action); 528extern void atombios_dvo_setup(struct drm_encoder *encoder, int action);
527extern void atombios_digital_setup(struct drm_encoder *encoder, int action); 529extern void atombios_digital_setup(struct drm_encoder *encoder, int action);
528extern int atombios_get_encoder_mode(struct drm_encoder *encoder); 530extern int atombios_get_encoder_mode(struct drm_encoder *encoder);
531extern void atombios_set_edp_panel_power(struct drm_connector *connector, int action);
529extern void radeon_encoder_set_active_device(struct drm_encoder *encoder); 532extern void radeon_encoder_set_active_device(struct drm_encoder *encoder);
530 533
531extern void radeon_crtc_load_lut(struct drm_crtc *crtc); 534extern void radeon_crtc_load_lut(struct drm_crtc *crtc);
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 8eb183466015..a598d0049aa5 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -69,7 +69,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
69 u32 c = 0; 69 u32 c = 0;
70 70
71 rbo->placement.fpfn = 0; 71 rbo->placement.fpfn = 0;
72 rbo->placement.lpfn = rbo->rdev->mc.active_vram_size >> PAGE_SHIFT; 72 rbo->placement.lpfn = 0;
73 rbo->placement.placement = rbo->placements; 73 rbo->placement.placement = rbo->placements;
74 rbo->placement.busy_placement = rbo->placements; 74 rbo->placement.busy_placement = rbo->placements;
75 if (domain & RADEON_GEM_DOMAIN_VRAM) 75 if (domain & RADEON_GEM_DOMAIN_VRAM)
@@ -86,11 +86,13 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
86} 86}
87 87
88int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj, 88int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj,
89 unsigned long size, bool kernel, u32 domain, 89 unsigned long size, int byte_align, bool kernel, u32 domain,
90 struct radeon_bo **bo_ptr) 90 struct radeon_bo **bo_ptr)
91{ 91{
92 struct radeon_bo *bo; 92 struct radeon_bo *bo;
93 enum ttm_bo_type type; 93 enum ttm_bo_type type;
94 unsigned long page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT;
95 unsigned long max_size = 0;
94 int r; 96 int r;
95 97
96 if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) { 98 if (unlikely(rdev->mman.bdev.dev_mapping == NULL)) {
@@ -103,6 +105,14 @@ int radeon_bo_create(struct radeon_device *rdev, struct drm_gem_object *gobj,
103 } 105 }
104 *bo_ptr = NULL; 106 *bo_ptr = NULL;
105 107
108 /* maximun bo size is the minimun btw visible vram and gtt size */
109 max_size = min(rdev->mc.visible_vram_size, rdev->mc.gtt_size);
110 if ((page_align << PAGE_SHIFT) >= max_size) {
111 printk(KERN_WARNING "%s:%d alloc size %ldM bigger than %ldMb limit\n",
112 __func__, __LINE__, page_align >> (20 - PAGE_SHIFT), max_size >> 20);
113 return -ENOMEM;
114 }
115
106retry: 116retry:
107 bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL); 117 bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL);
108 if (bo == NULL) 118 if (bo == NULL)
@@ -115,7 +125,7 @@ retry:
115 /* Kernel allocation are uninterruptible */ 125 /* Kernel allocation are uninterruptible */
116 mutex_lock(&rdev->vram_mutex); 126 mutex_lock(&rdev->vram_mutex);
117 r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type, 127 r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
118 &bo->placement, 0, 0, !kernel, NULL, size, 128 &bo->placement, page_align, 0, !kernel, NULL, size,
119 &radeon_ttm_bo_destroy); 129 &radeon_ttm_bo_destroy);
120 mutex_unlock(&rdev->vram_mutex); 130 mutex_unlock(&rdev->vram_mutex);
121 if (unlikely(r != 0)) { 131 if (unlikely(r != 0)) {
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
index 3481bc7f6f58..d143702b244a 100644
--- a/drivers/gpu/drm/radeon/radeon_object.h
+++ b/drivers/gpu/drm/radeon/radeon_object.h
@@ -137,9 +137,10 @@ static inline int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type,
137} 137}
138 138
139extern int radeon_bo_create(struct radeon_device *rdev, 139extern int radeon_bo_create(struct radeon_device *rdev,
140 struct drm_gem_object *gobj, unsigned long size, 140 struct drm_gem_object *gobj, unsigned long size,
141 bool kernel, u32 domain, 141 int byte_align,
142 struct radeon_bo **bo_ptr); 142 bool kernel, u32 domain,
143 struct radeon_bo **bo_ptr);
143extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr); 144extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr);
144extern void radeon_bo_kunmap(struct radeon_bo *bo); 145extern void radeon_bo_kunmap(struct radeon_bo *bo);
145extern void radeon_bo_unref(struct radeon_bo **bo); 146extern void radeon_bo_unref(struct radeon_bo **bo);
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 6ea798ce8218..06e79822a2bf 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -176,8 +176,8 @@ int radeon_ib_pool_init(struct radeon_device *rdev)
176 INIT_LIST_HEAD(&rdev->ib_pool.bogus_ib); 176 INIT_LIST_HEAD(&rdev->ib_pool.bogus_ib);
177 /* Allocate 1M object buffer */ 177 /* Allocate 1M object buffer */
178 r = radeon_bo_create(rdev, NULL, RADEON_IB_POOL_SIZE*64*1024, 178 r = radeon_bo_create(rdev, NULL, RADEON_IB_POOL_SIZE*64*1024,
179 true, RADEON_GEM_DOMAIN_GTT, 179 PAGE_SIZE, true, RADEON_GEM_DOMAIN_GTT,
180 &rdev->ib_pool.robj); 180 &rdev->ib_pool.robj);
181 if (r) { 181 if (r) {
182 DRM_ERROR("radeon: failed to ib pool (%d).\n", r); 182 DRM_ERROR("radeon: failed to ib pool (%d).\n", r);
183 return r; 183 return r;
@@ -332,7 +332,7 @@ int radeon_ring_init(struct radeon_device *rdev, unsigned ring_size)
332 rdev->cp.ring_size = ring_size; 332 rdev->cp.ring_size = ring_size;
333 /* Allocate ring buffer */ 333 /* Allocate ring buffer */
334 if (rdev->cp.ring_obj == NULL) { 334 if (rdev->cp.ring_obj == NULL) {
335 r = radeon_bo_create(rdev, NULL, rdev->cp.ring_size, true, 335 r = radeon_bo_create(rdev, NULL, rdev->cp.ring_size, PAGE_SIZE, true,
336 RADEON_GEM_DOMAIN_GTT, 336 RADEON_GEM_DOMAIN_GTT,
337 &rdev->cp.ring_obj); 337 &rdev->cp.ring_obj);
338 if (r) { 338 if (r) {
diff --git a/drivers/gpu/drm/radeon/radeon_test.c b/drivers/gpu/drm/radeon/radeon_test.c
index 313c96bc09da..5b44f652145c 100644
--- a/drivers/gpu/drm/radeon/radeon_test.c
+++ b/drivers/gpu/drm/radeon/radeon_test.c
@@ -52,7 +52,7 @@ void radeon_test_moves(struct radeon_device *rdev)
52 goto out_cleanup; 52 goto out_cleanup;
53 } 53 }
54 54
55 r = radeon_bo_create(rdev, NULL, size, true, RADEON_GEM_DOMAIN_VRAM, 55 r = radeon_bo_create(rdev, NULL, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
56 &vram_obj); 56 &vram_obj);
57 if (r) { 57 if (r) {
58 DRM_ERROR("Failed to create VRAM object\n"); 58 DRM_ERROR("Failed to create VRAM object\n");
@@ -71,7 +71,7 @@ void radeon_test_moves(struct radeon_device *rdev)
71 void **gtt_start, **gtt_end; 71 void **gtt_start, **gtt_end;
72 void **vram_start, **vram_end; 72 void **vram_start, **vram_end;
73 73
74 r = radeon_bo_create(rdev, NULL, size, true, 74 r = radeon_bo_create(rdev, NULL, size, PAGE_SIZE, true,
75 RADEON_GEM_DOMAIN_GTT, gtt_obj + i); 75 RADEON_GEM_DOMAIN_GTT, gtt_obj + i);
76 if (r) { 76 if (r) {
77 DRM_ERROR("Failed to create GTT object %d\n", i); 77 DRM_ERROR("Failed to create GTT object %d\n", i);
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 01c2c736a1da..1272e4b6a1d4 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -529,7 +529,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
529 DRM_ERROR("Failed initializing VRAM heap.\n"); 529 DRM_ERROR("Failed initializing VRAM heap.\n");
530 return r; 530 return r;
531 } 531 }
532 r = radeon_bo_create(rdev, NULL, 256 * 1024, true, 532 r = radeon_bo_create(rdev, NULL, 256 * 1024, PAGE_SIZE, true,
533 RADEON_GEM_DOMAIN_VRAM, 533 RADEON_GEM_DOMAIN_VRAM,
534 &rdev->stollen_vga_memory); 534 &rdev->stollen_vga_memory);
535 if (r) { 535 if (r) {
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 245374e2b778..4dfead8cee33 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -915,8 +915,8 @@ static int rv770_vram_scratch_init(struct radeon_device *rdev)
915 915
916 if (rdev->vram_scratch.robj == NULL) { 916 if (rdev->vram_scratch.robj == NULL) {
917 r = radeon_bo_create(rdev, NULL, RADEON_GPU_PAGE_SIZE, 917 r = radeon_bo_create(rdev, NULL, RADEON_GPU_PAGE_SIZE,
918 true, RADEON_GEM_DOMAIN_VRAM, 918 PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
919 &rdev->vram_scratch.robj); 919 &rdev->vram_scratch.robj);
920 if (r) { 920 if (r) {
921 return r; 921 return r;
922 } 922 }
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3ca77dc03915..148a322d8f5d 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -224,6 +224,9 @@ int ttm_bo_reserve_locked(struct ttm_buffer_object *bo,
224 int ret; 224 int ret;
225 225
226 while (unlikely(atomic_cmpxchg(&bo->reserved, 0, 1) != 0)) { 226 while (unlikely(atomic_cmpxchg(&bo->reserved, 0, 1) != 0)) {
227 /**
228 * Deadlock avoidance for multi-bo reserving.
229 */
227 if (use_sequence && bo->seq_valid && 230 if (use_sequence && bo->seq_valid &&
228 (sequence - bo->val_seq < (1 << 31))) { 231 (sequence - bo->val_seq < (1 << 31))) {
229 return -EAGAIN; 232 return -EAGAIN;
@@ -241,6 +244,14 @@ int ttm_bo_reserve_locked(struct ttm_buffer_object *bo,
241 } 244 }
242 245
243 if (use_sequence) { 246 if (use_sequence) {
247 /**
248 * Wake up waiters that may need to recheck for deadlock,
249 * if we decreased the sequence number.
250 */
251 if (unlikely((bo->val_seq - sequence < (1 << 31))
252 || !bo->seq_valid))
253 wake_up_all(&bo->event_queue);
254
244 bo->val_seq = sequence; 255 bo->val_seq = sequence;
245 bo->seq_valid = true; 256 bo->seq_valid = true;
246 } else { 257 } else {
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 36e129f0023f..5408b1b7996f 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -862,7 +862,7 @@ int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
862 &vmw_vram_sys_placement, true, 862 &vmw_vram_sys_placement, true,
863 &vmw_user_dmabuf_destroy); 863 &vmw_user_dmabuf_destroy);
864 if (unlikely(ret != 0)) 864 if (unlikely(ret != 0))
865 return ret; 865 goto out_no_dmabuf;
866 866
867 tmp = ttm_bo_reference(&vmw_user_bo->dma.base); 867 tmp = ttm_bo_reference(&vmw_user_bo->dma.base);
868 ret = ttm_base_object_init(vmw_fpriv(file_priv)->tfile, 868 ret = ttm_base_object_init(vmw_fpriv(file_priv)->tfile,
@@ -870,19 +870,21 @@ int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
870 false, 870 false,
871 ttm_buffer_type, 871 ttm_buffer_type,
872 &vmw_user_dmabuf_release, NULL); 872 &vmw_user_dmabuf_release, NULL);
873 if (unlikely(ret != 0)) { 873 if (unlikely(ret != 0))
874 ttm_bo_unref(&tmp); 874 goto out_no_base_object;
875 } else { 875 else {
876 rep->handle = vmw_user_bo->base.hash.key; 876 rep->handle = vmw_user_bo->base.hash.key;
877 rep->map_handle = vmw_user_bo->dma.base.addr_space_offset; 877 rep->map_handle = vmw_user_bo->dma.base.addr_space_offset;
878 rep->cur_gmr_id = vmw_user_bo->base.hash.key; 878 rep->cur_gmr_id = vmw_user_bo->base.hash.key;
879 rep->cur_gmr_offset = 0; 879 rep->cur_gmr_offset = 0;
880 } 880 }
881 ttm_bo_unref(&tmp);
882 881
882out_no_base_object:
883 ttm_bo_unref(&tmp);
884out_no_dmabuf:
883 ttm_read_unlock(&vmaster->lock); 885 ttm_read_unlock(&vmaster->lock);
884 886
885 return 0; 887 return ret;
886} 888}
887 889
888int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, 890int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data,
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 515345b11ac9..88cb04e7962b 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1386,6 +1386,7 @@ static const struct hid_device_id hid_blacklist[] = {
1386 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 1386 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
1387 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, 1387 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) },
1388 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, 1388 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
1389 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a) },
1389 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 1390 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
1390 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, 1391 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) },
1391 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, 1392 { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
diff --git a/drivers/hid/hid-egalax.c b/drivers/hid/hid-egalax.c
index 54b017ad258d..5a1b52e0eb85 100644
--- a/drivers/hid/hid-egalax.c
+++ b/drivers/hid/hid-egalax.c
@@ -221,7 +221,7 @@ static int egalax_probe(struct hid_device *hdev, const struct hid_device_id *id)
221 struct egalax_data *td; 221 struct egalax_data *td;
222 struct hid_report *report; 222 struct hid_report *report;
223 223
224 td = kmalloc(sizeof(struct egalax_data), GFP_KERNEL); 224 td = kzalloc(sizeof(struct egalax_data), GFP_KERNEL);
225 if (!td) { 225 if (!td) {
226 dev_err(&hdev->dev, "cannot allocate eGalax data\n"); 226 dev_err(&hdev->dev, "cannot allocate eGalax data\n");
227 return -ENOMEM; 227 return -ENOMEM;
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index bb0b3659437b..d8d372bae3cc 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -174,7 +174,7 @@ static int hidinput_setkeycode(struct input_dev *dev,
174 174
175 clear_bit(*old_keycode, dev->keybit); 175 clear_bit(*old_keycode, dev->keybit);
176 set_bit(usage->code, dev->keybit); 176 set_bit(usage->code, dev->keybit);
177 dbg_hid(KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", 177 dbg_hid("Assigned keycode %d to HID usage code %x\n",
178 usage->code, usage->hid); 178 usage->code, usage->hid);
179 179
180 /* 180 /*
@@ -203,8 +203,8 @@ static int hidinput_setkeycode(struct input_dev *dev,
203 * 203 *
204 * as seen in the HID specification v1.11 6.2.2.7 Global Items. 204 * as seen in the HID specification v1.11 6.2.2.7 Global Items.
205 * 205 *
206 * Only exponent 1 length units are processed. Centimeters are converted to 206 * Only exponent 1 length units are processed. Centimeters and inches are
207 * inches. Degrees are converted to radians. 207 * converted to millimeters. Degrees are converted to radians.
208 */ 208 */
209static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) 209static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
210{ 210{
@@ -225,13 +225,16 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
225 */ 225 */
226 if (code == ABS_X || code == ABS_Y || code == ABS_Z) { 226 if (code == ABS_X || code == ABS_Y || code == ABS_Z) {
227 if (field->unit == 0x11) { /* If centimeters */ 227 if (field->unit == 0x11) { /* If centimeters */
228 /* Convert to inches */ 228 /* Convert to millimeters */
229 prev = logical_extents; 229 unit_exponent += 1;
230 logical_extents *= 254; 230 } else if (field->unit == 0x13) { /* If inches */
231 if (logical_extents < prev) 231 /* Convert to millimeters */
232 prev = physical_extents;
233 physical_extents *= 254;
234 if (physical_extents < prev)
232 return 0; 235 return 0;
233 unit_exponent += 2; 236 unit_exponent -= 1;
234 } else if (field->unit != 0x13) { /* If not inches */ 237 } else {
235 return 0; 238 return 0;
236 } 239 }
237 } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) { 240 } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) {
diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c
index 15434c814793..25be4e1461bd 100644
--- a/drivers/hid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -256,6 +256,8 @@ static const struct hid_device_id tm_devices[] = {
256 .driver_data = (unsigned long)ff_joystick }, 256 .driver_data = (unsigned long)ff_joystick },
257 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654), /* FGT Force Feedback Wheel */ 257 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654), /* FGT Force Feedback Wheel */
258 .driver_data = (unsigned long)ff_joystick }, 258 .driver_data = (unsigned long)ff_joystick },
259 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb65a), /* F430 Force Feedback Wheel */
260 .driver_data = (unsigned long)ff_joystick },
259 { } 261 { }
260}; 262};
261MODULE_DEVICE_TABLE(hid, tm_devices); 263MODULE_DEVICE_TABLE(hid, tm_devices);
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 8a4b32dca9f7..e1f07483691f 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -32,7 +32,6 @@
32#include <linux/hid.h> 32#include <linux/hid.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/smp_lock.h>
36 35
37#include <linux/hidraw.h> 36#include <linux/hidraw.h>
38 37
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index fedd88df9a18..984feb351a5a 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -29,7 +29,6 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/smp_lock.h>
33#include <linux/input.h> 32#include <linux/input.h>
34#include <linux/usb.h> 33#include <linux/usb.h>
35#include <linux/hid.h> 34#include <linux/hid.h>
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index 4bf969c0a32b..be0fdd58aa29 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -916,27 +916,27 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
916 int nr = sensor_attr->index; 916 int nr = sensor_attr->index;
917 struct i2c_client *client = to_i2c_client(dev); 917 struct i2c_client *client = to_i2c_client(dev);
918 struct adm1026_data *data = i2c_get_clientdata(client); 918 struct adm1026_data *data = i2c_get_clientdata(client);
919 int val, orig_div, new_div, shift; 919 int val, orig_div, new_div;
920 920
921 val = simple_strtol(buf, NULL, 10); 921 val = simple_strtol(buf, NULL, 10);
922 new_div = DIV_TO_REG(val); 922 new_div = DIV_TO_REG(val);
923 if (new_div == 0) { 923
924 return -EINVAL;
925 }
926 mutex_lock(&data->update_lock); 924 mutex_lock(&data->update_lock);
927 orig_div = data->fan_div[nr]; 925 orig_div = data->fan_div[nr];
928 data->fan_div[nr] = DIV_FROM_REG(new_div); 926 data->fan_div[nr] = DIV_FROM_REG(new_div);
929 927
930 if (nr < 4) { /* 0 <= nr < 4 */ 928 if (nr < 4) { /* 0 <= nr < 4 */
931 shift = 2 * nr;
932 adm1026_write_value(client, ADM1026_REG_FAN_DIV_0_3, 929 adm1026_write_value(client, ADM1026_REG_FAN_DIV_0_3,
933 ((DIV_TO_REG(orig_div) & (~(0x03 << shift))) | 930 (DIV_TO_REG(data->fan_div[0]) << 0) |
934 (new_div << shift))); 931 (DIV_TO_REG(data->fan_div[1]) << 2) |
932 (DIV_TO_REG(data->fan_div[2]) << 4) |
933 (DIV_TO_REG(data->fan_div[3]) << 6));
935 } else { /* 3 < nr < 8 */ 934 } else { /* 3 < nr < 8 */
936 shift = 2 * (nr - 4);
937 adm1026_write_value(client, ADM1026_REG_FAN_DIV_4_7, 935 adm1026_write_value(client, ADM1026_REG_FAN_DIV_4_7,
938 ((DIV_TO_REG(orig_div) & (~(0x03 << (2 * shift)))) | 936 (DIV_TO_REG(data->fan_div[4]) << 0) |
939 (new_div << shift))); 937 (DIV_TO_REG(data->fan_div[5]) << 2) |
938 (DIV_TO_REG(data->fan_div[6]) << 4) |
939 (DIV_TO_REG(data->fan_div[7]) << 6));
940 } 940 }
941 941
942 if (data->fan_div[nr] != orig_div) { 942 if (data->fan_div[nr] != orig_div) {
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
index 937983407e2a..c4c40be0edbf 100644
--- a/drivers/hwmon/i5k_amb.c
+++ b/drivers/hwmon/i5k_amb.c
@@ -497,12 +497,14 @@ static unsigned long chipset_ids[] = {
497 0 497 0
498}; 498};
499 499
500#ifdef MODULE
500static struct pci_device_id i5k_amb_ids[] __devinitdata = { 501static struct pci_device_id i5k_amb_ids[] __devinitdata = {
501 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) }, 502 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
502 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) }, 503 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) },
503 { 0, } 504 { 0, }
504}; 505};
505MODULE_DEVICE_TABLE(pci, i5k_amb_ids); 506MODULE_DEVICE_TABLE(pci, i5k_amb_ids);
507#endif
506 508
507static int __devinit i5k_amb_probe(struct platform_device *pdev) 509static int __devinit i5k_amb_probe(struct platform_device *pdev)
508{ 510{
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 14a5d981be7d..a428a9264195 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -187,6 +187,7 @@ static const u8 IT87_REG_FANX_MIN[] = { 0x1b, 0x1c, 0x1d, 0x85, 0x87 };
187#define IT87_REG_FAN_MAIN_CTRL 0x13 187#define IT87_REG_FAN_MAIN_CTRL 0x13
188#define IT87_REG_FAN_CTL 0x14 188#define IT87_REG_FAN_CTL 0x14
189#define IT87_REG_PWM(nr) (0x15 + (nr)) 189#define IT87_REG_PWM(nr) (0x15 + (nr))
190#define IT87_REG_PWM_DUTY(nr) (0x63 + (nr) * 8)
190 191
191#define IT87_REG_VIN(nr) (0x20 + (nr)) 192#define IT87_REG_VIN(nr) (0x20 + (nr))
192#define IT87_REG_TEMP(nr) (0x29 + (nr)) 193#define IT87_REG_TEMP(nr) (0x29 + (nr))
@@ -251,12 +252,16 @@ struct it87_data {
251 u8 fan_main_ctrl; /* Register value */ 252 u8 fan_main_ctrl; /* Register value */
252 u8 fan_ctl; /* Register value */ 253 u8 fan_ctl; /* Register value */
253 254
254 /* The following 3 arrays correspond to the same registers. The 255 /* The following 3 arrays correspond to the same registers up to
255 * meaning of bits 6-0 depends on the value of bit 7, and we want 256 * the IT8720F. The meaning of bits 6-0 depends on the value of bit
256 * to preserve settings on mode changes, so we have to track all 257 * 7, and we want to preserve settings on mode changes, so we have
257 * values separately. */ 258 * to track all values separately.
259 * Starting with the IT8721F, the manual PWM duty cycles are stored
260 * in separate registers (8-bit values), so the separate tracking
261 * is no longer needed, but it is still done to keep the driver
262 * simple. */
258 u8 pwm_ctrl[3]; /* Register value */ 263 u8 pwm_ctrl[3]; /* Register value */
259 u8 pwm_duty[3]; /* Manual PWM value set by user (bit 6-0) */ 264 u8 pwm_duty[3]; /* Manual PWM value set by user */
260 u8 pwm_temp_map[3]; /* PWM to temp. chan. mapping (bits 1-0) */ 265 u8 pwm_temp_map[3]; /* PWM to temp. chan. mapping (bits 1-0) */
261 266
262 /* Automatic fan speed control registers */ 267 /* Automatic fan speed control registers */
@@ -832,7 +837,9 @@ static ssize_t set_pwm_enable(struct device *dev,
832 data->fan_main_ctrl); 837 data->fan_main_ctrl);
833 } else { 838 } else {
834 if (val == 1) /* Manual mode */ 839 if (val == 1) /* Manual mode */
835 data->pwm_ctrl[nr] = data->pwm_duty[nr]; 840 data->pwm_ctrl[nr] = data->type == it8721 ?
841 data->pwm_temp_map[nr] :
842 data->pwm_duty[nr];
836 else /* Automatic mode */ 843 else /* Automatic mode */
837 data->pwm_ctrl[nr] = 0x80 | data->pwm_temp_map[nr]; 844 data->pwm_ctrl[nr] = 0x80 | data->pwm_temp_map[nr];
838 it87_write_value(data, IT87_REG_PWM(nr), data->pwm_ctrl[nr]); 845 it87_write_value(data, IT87_REG_PWM(nr), data->pwm_ctrl[nr]);
@@ -858,12 +865,25 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
858 return -EINVAL; 865 return -EINVAL;
859 866
860 mutex_lock(&data->update_lock); 867 mutex_lock(&data->update_lock);
861 data->pwm_duty[nr] = pwm_to_reg(data, val); 868 if (data->type == it8721) {
862 /* If we are in manual mode, write the duty cycle immediately; 869 /* If we are in automatic mode, the PWM duty cycle register
863 * otherwise, just store it for later use. */ 870 * is read-only so we can't write the value */
864 if (!(data->pwm_ctrl[nr] & 0x80)) { 871 if (data->pwm_ctrl[nr] & 0x80) {
865 data->pwm_ctrl[nr] = data->pwm_duty[nr]; 872 mutex_unlock(&data->update_lock);
866 it87_write_value(data, IT87_REG_PWM(nr), data->pwm_ctrl[nr]); 873 return -EBUSY;
874 }
875 data->pwm_duty[nr] = pwm_to_reg(data, val);
876 it87_write_value(data, IT87_REG_PWM_DUTY(nr),
877 data->pwm_duty[nr]);
878 } else {
879 data->pwm_duty[nr] = pwm_to_reg(data, val);
880 /* If we are in manual mode, write the duty cycle immediately;
881 * otherwise, just store it for later use. */
882 if (!(data->pwm_ctrl[nr] & 0x80)) {
883 data->pwm_ctrl[nr] = data->pwm_duty[nr];
884 it87_write_value(data, IT87_REG_PWM(nr),
885 data->pwm_ctrl[nr]);
886 }
867 } 887 }
868 mutex_unlock(&data->update_lock); 888 mutex_unlock(&data->update_lock);
869 return count; 889 return count;
@@ -1958,7 +1978,10 @@ static void __devinit it87_init_device(struct platform_device *pdev)
1958 * channels to use when later setting to automatic mode later. 1978 * channels to use when later setting to automatic mode later.
1959 * Use a 1:1 mapping by default (we are clueless.) 1979 * Use a 1:1 mapping by default (we are clueless.)
1960 * In both cases, the value can (and should) be changed by the user 1980 * In both cases, the value can (and should) be changed by the user
1961 * prior to switching to a different mode. */ 1981 * prior to switching to a different mode.
1982 * Note that this is no longer needed for the IT8721F and later, as
1983 * these have separate registers for the temperature mapping and the
1984 * manual duty cycle. */
1962 for (i = 0; i < 3; i++) { 1985 for (i = 0; i < 3; i++) {
1963 data->pwm_temp_map[i] = i; 1986 data->pwm_temp_map[i] = i;
1964 data->pwm_duty[i] = 0x7f; /* Full speed */ 1987 data->pwm_duty[i] = 0x7f; /* Full speed */
@@ -2034,10 +2057,16 @@ static void __devinit it87_init_device(struct platform_device *pdev)
2034static void it87_update_pwm_ctrl(struct it87_data *data, int nr) 2057static void it87_update_pwm_ctrl(struct it87_data *data, int nr)
2035{ 2058{
2036 data->pwm_ctrl[nr] = it87_read_value(data, IT87_REG_PWM(nr)); 2059 data->pwm_ctrl[nr] = it87_read_value(data, IT87_REG_PWM(nr));
2037 if (data->pwm_ctrl[nr] & 0x80) /* Automatic mode */ 2060 if (data->type == it8721) {
2038 data->pwm_temp_map[nr] = data->pwm_ctrl[nr] & 0x03; 2061 data->pwm_temp_map[nr] = data->pwm_ctrl[nr] & 0x03;
2039 else /* Manual mode */ 2062 data->pwm_duty[nr] = it87_read_value(data,
2040 data->pwm_duty[nr] = data->pwm_ctrl[nr] & 0x7f; 2063 IT87_REG_PWM_DUTY(nr));
2064 } else {
2065 if (data->pwm_ctrl[nr] & 0x80) /* Automatic mode */
2066 data->pwm_temp_map[nr] = data->pwm_ctrl[nr] & 0x03;
2067 else /* Manual mode */
2068 data->pwm_duty[nr] = data->pwm_ctrl[nr] & 0x7f;
2069 }
2041 2070
2042 if (has_old_autopwm(data)) { 2071 if (has_old_autopwm(data)) {
2043 int i; 2072 int i;
diff --git a/drivers/hwmon/lis3lv02d_i2c.c b/drivers/hwmon/lis3lv02d_i2c.c
index 9f4bae07f719..8853afce85ce 100644
--- a/drivers/hwmon/lis3lv02d_i2c.c
+++ b/drivers/hwmon/lis3lv02d_i2c.c
@@ -186,7 +186,7 @@ static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client)
186 return 0; 186 return 0;
187} 187}
188 188
189#ifdef CONFIG_PM 189#ifdef CONFIG_PM_SLEEP
190static int lis3lv02d_i2c_suspend(struct device *dev) 190static int lis3lv02d_i2c_suspend(struct device *dev)
191{ 191{
192 struct i2c_client *client = container_of(dev, struct i2c_client, dev); 192 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
@@ -213,12 +213,9 @@ static int lis3lv02d_i2c_resume(struct device *dev)
213 213
214 return 0; 214 return 0;
215} 215}
216#else 216#endif /* CONFIG_PM_SLEEP */
217#define lis3lv02d_i2c_suspend NULL
218#define lis3lv02d_i2c_resume NULL
219#define lis3lv02d_i2c_shutdown NULL
220#endif
221 217
218#ifdef CONFIG_PM_RUNTIME
222static int lis3_i2c_runtime_suspend(struct device *dev) 219static int lis3_i2c_runtime_suspend(struct device *dev)
223{ 220{
224 struct i2c_client *client = container_of(dev, struct i2c_client, dev); 221 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
@@ -236,6 +233,7 @@ static int lis3_i2c_runtime_resume(struct device *dev)
236 lis3lv02d_poweron(lis3); 233 lis3lv02d_poweron(lis3);
237 return 0; 234 return 0;
238} 235}
236#endif /* CONFIG_PM_RUNTIME */
239 237
240static const struct i2c_device_id lis3lv02d_id[] = { 238static const struct i2c_device_id lis3lv02d_id[] = {
241 {"lis3lv02d", 0 }, 239 {"lis3lv02d", 0 },
diff --git a/drivers/hwmon/ltc4215.c b/drivers/hwmon/ltc4215.c
index 00d975eb5b83..c7e6d8e81656 100644
--- a/drivers/hwmon/ltc4215.c
+++ b/drivers/hwmon/ltc4215.c
@@ -205,7 +205,6 @@ LTC4215_ALARM(curr1_max_alarm, (1 << 2), LTC4215_STATUS);
205 205
206/* Power (virtual) */ 206/* Power (virtual) */
207LTC4215_POWER(power1_input); 207LTC4215_POWER(power1_input);
208LTC4215_ALARM(power1_alarm, (1 << 3), LTC4215_STATUS);
209 208
210/* Input Voltage */ 209/* Input Voltage */
211LTC4215_VOLTAGE(in1_input, LTC4215_ADIN); 210LTC4215_VOLTAGE(in1_input, LTC4215_ADIN);
@@ -214,6 +213,7 @@ LTC4215_ALARM(in1_min_alarm, (1 << 1), LTC4215_STATUS);
214 213
215/* Output Voltage */ 214/* Output Voltage */
216LTC4215_VOLTAGE(in2_input, LTC4215_SOURCE); 215LTC4215_VOLTAGE(in2_input, LTC4215_SOURCE);
216LTC4215_ALARM(in2_min_alarm, (1 << 3), LTC4215_STATUS);
217 217
218/* Finally, construct an array of pointers to members of the above objects, 218/* Finally, construct an array of pointers to members of the above objects,
219 * as required for sysfs_create_group() 219 * as required for sysfs_create_group()
@@ -223,13 +223,13 @@ static struct attribute *ltc4215_attributes[] = {
223 &sensor_dev_attr_curr1_max_alarm.dev_attr.attr, 223 &sensor_dev_attr_curr1_max_alarm.dev_attr.attr,
224 224
225 &sensor_dev_attr_power1_input.dev_attr.attr, 225 &sensor_dev_attr_power1_input.dev_attr.attr,
226 &sensor_dev_attr_power1_alarm.dev_attr.attr,
227 226
228 &sensor_dev_attr_in1_input.dev_attr.attr, 227 &sensor_dev_attr_in1_input.dev_attr.attr,
229 &sensor_dev_attr_in1_max_alarm.dev_attr.attr, 228 &sensor_dev_attr_in1_max_alarm.dev_attr.attr,
230 &sensor_dev_attr_in1_min_alarm.dev_attr.attr, 229 &sensor_dev_attr_in1_min_alarm.dev_attr.attr,
231 230
232 &sensor_dev_attr_in2_input.dev_attr.attr, 231 &sensor_dev_attr_in2_input.dev_attr.attr,
232 &sensor_dev_attr_in2_min_alarm.dev_attr.attr,
233 233
234 NULL, 234 NULL,
235}; 235};
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index b923074b2cbe..30f06e956bfb 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -75,8 +75,7 @@ config I2C_HELPER_AUTO
75 In doubt, say Y. 75 In doubt, say Y.
76 76
77config I2C_SMBUS 77config I2C_SMBUS
78 tristate 78 tristate "SMBus-specific protocols" if !I2C_HELPER_AUTO
79 prompt "SMBus-specific protocols" if !I2C_HELPER_AUTO
80 help 79 help
81 Say Y here if you want support for SMBus extensions to the I2C 80 Say Y here if you want support for SMBus extensions to the I2C
82 specification. At the moment, the only supported extension is 81 specification. At the moment, the only supported extension is
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig
index 3998dd620a03..f1cfe7e5508b 100644
--- a/drivers/i2c/algos/Kconfig
+++ b/drivers/i2c/algos/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4 4
5menu "I2C Algorithms" 5menu "I2C Algorithms"
6 depends on !I2C_HELPER_AUTO 6 visible if !I2C_HELPER_AUTO
7 7
8config I2C_ALGOBIT 8config I2C_ALGOBIT
9 tristate "I2C bit-banging interfaces" 9 tristate "I2C bit-banging interfaces"
@@ -15,15 +15,3 @@ config I2C_ALGOPCA
15 tristate "I2C PCA 9564 interfaces" 15 tristate "I2C PCA 9564 interfaces"
16 16
17endmenu 17endmenu
18
19# In automatic configuration mode, we still have to define the
20# symbols to avoid unmet dependencies.
21
22if I2C_HELPER_AUTO
23config I2C_ALGOBIT
24 tristate
25config I2C_ALGOPCF
26 tristate
27config I2C_ALGOPCA
28 tristate
29endif
diff --git a/drivers/i2c/busses/i2c-intel-mid.c b/drivers/i2c/busses/i2c-intel-mid.c
index 80f70d3a744d..c71492782bbd 100644
--- a/drivers/i2c/busses/i2c-intel-mid.c
+++ b/drivers/i2c/busses/i2c-intel-mid.c
@@ -999,7 +999,7 @@ static int __devinit intel_mid_i2c_probe(struct pci_dev *dev,
999 999
1000 /* Initialize struct members */ 1000 /* Initialize struct members */
1001 snprintf(mrst->adap.name, sizeof(mrst->adap.name), 1001 snprintf(mrst->adap.name, sizeof(mrst->adap.name),
1002 "MRST/Medfield I2C at %lx", start); 1002 "Intel MID I2C at %lx", start);
1003 mrst->adap.owner = THIS_MODULE; 1003 mrst->adap.owner = THIS_MODULE;
1004 mrst->adap.algo = &intel_mid_i2c_algorithm; 1004 mrst->adap.algo = &intel_mid_i2c_algorithm;
1005 mrst->adap.dev.parent = &dev->dev; 1005 mrst->adap.dev.parent = &dev->dev;
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 41665d2f9f93..c131d58bcb50 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -273,8 +273,6 @@ static int intel_idle_probe(void)
273 273
274 pr_debug(PREFIX "MWAIT substates: 0x%x\n", mwait_substates); 274 pr_debug(PREFIX "MWAIT substates: 0x%x\n", mwait_substates);
275 275
276 if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */
277 lapic_timer_reliable_states = 0xFFFFFFFF;
278 276
279 if (boot_cpu_data.x86 != 6) /* family 6 */ 277 if (boot_cpu_data.x86 != 6) /* family 6 */
280 return -ENODEV; 278 return -ENODEV;
@@ -286,8 +284,6 @@ static int intel_idle_probe(void)
286 case 0x1F: /* Core i7 and i5 Processor - Nehalem */ 284 case 0x1F: /* Core i7 and i5 Processor - Nehalem */
287 case 0x2E: /* Nehalem-EX Xeon */ 285 case 0x2E: /* Nehalem-EX Xeon */
288 case 0x2F: /* Westmere-EX Xeon */ 286 case 0x2F: /* Westmere-EX Xeon */
289 lapic_timer_reliable_states = (1 << 1); /* C1 */
290
291 case 0x25: /* Westmere */ 287 case 0x25: /* Westmere */
292 case 0x2C: /* Westmere */ 288 case 0x2C: /* Westmere */
293 cpuidle_state_table = nehalem_cstates; 289 cpuidle_state_table = nehalem_cstates;
@@ -295,7 +291,6 @@ static int intel_idle_probe(void)
295 291
296 case 0x1C: /* 28 - Atom Processor */ 292 case 0x1C: /* 28 - Atom Processor */
297 case 0x26: /* 38 - Lincroft Atom Processor */ 293 case 0x26: /* 38 - Lincroft Atom Processor */
298 lapic_timer_reliable_states = (1 << 1); /* C1 */
299 cpuidle_state_table = atom_cstates; 294 cpuidle_state_table = atom_cstates;
300 break; 295 break;
301 296
@@ -303,10 +298,6 @@ static int intel_idle_probe(void)
303 case 0x2D: /* SNB Xeon */ 298 case 0x2D: /* SNB Xeon */
304 cpuidle_state_table = snb_cstates; 299 cpuidle_state_table = snb_cstates;
305 break; 300 break;
306#ifdef FUTURE_USE
307 case 0x17: /* 23 - Core 2 Duo */
308 lapic_timer_reliable_states = (1 << 2) | (1 << 1); /* C2, C1 */
309#endif
310 301
311 default: 302 default:
312 pr_debug(PREFIX "does not run on family %d model %d\n", 303 pr_debug(PREFIX "does not run on family %d model %d\n",
@@ -314,6 +305,9 @@ static int intel_idle_probe(void)
314 return -ENODEV; 305 return -ENODEV;
315 } 306 }
316 307
308 if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */
309 lapic_timer_reliable_states = 0xFFFFFFFF;
310
317 pr_debug(PREFIX "v" INTEL_IDLE_VERSION 311 pr_debug(PREFIX "v" INTEL_IDLE_VERSION
318 " model 0x%X\n", boot_cpu_data.x86_model); 312 " model 0x%X\n", boot_cpu_data.x86_model);
319 313
diff --git a/drivers/infiniband/core/ud_header.c b/drivers/infiniband/core/ud_header.c
index bb7e19280821..9b737ff133e2 100644
--- a/drivers/infiniband/core/ud_header.c
+++ b/drivers/infiniband/core/ud_header.c
@@ -278,36 +278,6 @@ void ib_ud_header_init(int payload_bytes,
278EXPORT_SYMBOL(ib_ud_header_init); 278EXPORT_SYMBOL(ib_ud_header_init);
279 279
280/** 280/**
281 * ib_lrh_header_pack - Pack LRH header struct into wire format
282 * @lrh:unpacked LRH header struct
283 * @buf:Buffer to pack into
284 *
285 * ib_lrh_header_pack() packs the LRH header structure @lrh into
286 * wire format in the buffer @buf.
287 */
288int ib_lrh_header_pack(struct ib_unpacked_lrh *lrh, void *buf)
289{
290 ib_pack(lrh_table, ARRAY_SIZE(lrh_table), lrh, buf);
291 return 0;
292}
293EXPORT_SYMBOL(ib_lrh_header_pack);
294
295/**
296 * ib_lrh_header_unpack - Unpack LRH structure from wire format
297 * @lrh:unpacked LRH header struct
298 * @buf:Buffer to pack into
299 *
300 * ib_lrh_header_unpack() unpacks the LRH header structure from
301 * wire format (in buf) into @lrh.
302 */
303int ib_lrh_header_unpack(void *buf, struct ib_unpacked_lrh *lrh)
304{
305 ib_unpack(lrh_table, ARRAY_SIZE(lrh_table), buf, lrh);
306 return 0;
307}
308EXPORT_SYMBOL(ib_lrh_header_unpack);
309
310/**
311 * ib_ud_header_pack - Pack UD header struct into wire format 281 * ib_ud_header_pack - Pack UD header struct into wire format
312 * @header:UD header struct 282 * @header:UD header struct
313 * @buf:Buffer to pack into 283 * @buf:Buffer to pack into
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index b342248aec05..c42699285f8e 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -893,68 +893,81 @@ out:
893 return ret ? ret : in_len; 893 return ret ? ret : in_len;
894} 894}
895 895
896static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)
897{
898 struct ib_uverbs_wc tmp;
899
900 tmp.wr_id = wc->wr_id;
901 tmp.status = wc->status;
902 tmp.opcode = wc->opcode;
903 tmp.vendor_err = wc->vendor_err;
904 tmp.byte_len = wc->byte_len;
905 tmp.ex.imm_data = (__u32 __force) wc->ex.imm_data;
906 tmp.qp_num = wc->qp->qp_num;
907 tmp.src_qp = wc->src_qp;
908 tmp.wc_flags = wc->wc_flags;
909 tmp.pkey_index = wc->pkey_index;
910 tmp.slid = wc->slid;
911 tmp.sl = wc->sl;
912 tmp.dlid_path_bits = wc->dlid_path_bits;
913 tmp.port_num = wc->port_num;
914 tmp.reserved = 0;
915
916 if (copy_to_user(dest, &tmp, sizeof tmp))
917 return -EFAULT;
918
919 return 0;
920}
921
896ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file, 922ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
897 const char __user *buf, int in_len, 923 const char __user *buf, int in_len,
898 int out_len) 924 int out_len)
899{ 925{
900 struct ib_uverbs_poll_cq cmd; 926 struct ib_uverbs_poll_cq cmd;
901 struct ib_uverbs_poll_cq_resp *resp; 927 struct ib_uverbs_poll_cq_resp resp;
928 u8 __user *header_ptr;
929 u8 __user *data_ptr;
902 struct ib_cq *cq; 930 struct ib_cq *cq;
903 struct ib_wc *wc; 931 struct ib_wc wc;
904 int ret = 0; 932 int ret;
905 int i;
906 int rsize;
907 933
908 if (copy_from_user(&cmd, buf, sizeof cmd)) 934 if (copy_from_user(&cmd, buf, sizeof cmd))
909 return -EFAULT; 935 return -EFAULT;
910 936
911 wc = kmalloc(cmd.ne * sizeof *wc, GFP_KERNEL);
912 if (!wc)
913 return -ENOMEM;
914
915 rsize = sizeof *resp + cmd.ne * sizeof(struct ib_uverbs_wc);
916 resp = kmalloc(rsize, GFP_KERNEL);
917 if (!resp) {
918 ret = -ENOMEM;
919 goto out_wc;
920 }
921
922 cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0); 937 cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
923 if (!cq) { 938 if (!cq)
924 ret = -EINVAL; 939 return -EINVAL;
925 goto out;
926 }
927 940
928 resp->count = ib_poll_cq(cq, cmd.ne, wc); 941 /* we copy a struct ib_uverbs_poll_cq_resp to user space */
942 header_ptr = (void __user *)(unsigned long) cmd.response;
943 data_ptr = header_ptr + sizeof resp;
929 944
930 put_cq_read(cq); 945 memset(&resp, 0, sizeof resp);
946 while (resp.count < cmd.ne) {
947 ret = ib_poll_cq(cq, 1, &wc);
948 if (ret < 0)
949 goto out_put;
950 if (!ret)
951 break;
952
953 ret = copy_wc_to_user(data_ptr, &wc);
954 if (ret)
955 goto out_put;
931 956
932 for (i = 0; i < resp->count; i++) { 957 data_ptr += sizeof(struct ib_uverbs_wc);
933 resp->wc[i].wr_id = wc[i].wr_id; 958 ++resp.count;
934 resp->wc[i].status = wc[i].status;
935 resp->wc[i].opcode = wc[i].opcode;
936 resp->wc[i].vendor_err = wc[i].vendor_err;
937 resp->wc[i].byte_len = wc[i].byte_len;
938 resp->wc[i].ex.imm_data = (__u32 __force) wc[i].ex.imm_data;
939 resp->wc[i].qp_num = wc[i].qp->qp_num;
940 resp->wc[i].src_qp = wc[i].src_qp;
941 resp->wc[i].wc_flags = wc[i].wc_flags;
942 resp->wc[i].pkey_index = wc[i].pkey_index;
943 resp->wc[i].slid = wc[i].slid;
944 resp->wc[i].sl = wc[i].sl;
945 resp->wc[i].dlid_path_bits = wc[i].dlid_path_bits;
946 resp->wc[i].port_num = wc[i].port_num;
947 } 959 }
948 960
949 if (copy_to_user((void __user *) (unsigned long) cmd.response, resp, rsize)) 961 if (copy_to_user(header_ptr, &resp, sizeof resp)) {
950 ret = -EFAULT; 962 ret = -EFAULT;
963 goto out_put;
964 }
951 965
952out: 966 ret = in_len;
953 kfree(resp);
954 967
955out_wc: 968out_put:
956 kfree(wc); 969 put_cq_read(cq);
957 return ret ? ret : in_len; 970 return ret;
958} 971}
959 972
960ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file, 973ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
diff --git a/drivers/infiniband/core/uverbs_marshall.c b/drivers/infiniband/core/uverbs_marshall.c
index 5440da0e59b4..1b1146f87124 100644
--- a/drivers/infiniband/core/uverbs_marshall.c
+++ b/drivers/infiniband/core/uverbs_marshall.c
@@ -40,18 +40,21 @@ void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
40 dst->grh.sgid_index = src->grh.sgid_index; 40 dst->grh.sgid_index = src->grh.sgid_index;
41 dst->grh.hop_limit = src->grh.hop_limit; 41 dst->grh.hop_limit = src->grh.hop_limit;
42 dst->grh.traffic_class = src->grh.traffic_class; 42 dst->grh.traffic_class = src->grh.traffic_class;
43 memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));
43 dst->dlid = src->dlid; 44 dst->dlid = src->dlid;
44 dst->sl = src->sl; 45 dst->sl = src->sl;
45 dst->src_path_bits = src->src_path_bits; 46 dst->src_path_bits = src->src_path_bits;
46 dst->static_rate = src->static_rate; 47 dst->static_rate = src->static_rate;
47 dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0; 48 dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0;
48 dst->port_num = src->port_num; 49 dst->port_num = src->port_num;
50 dst->reserved = 0;
49} 51}
50EXPORT_SYMBOL(ib_copy_ah_attr_to_user); 52EXPORT_SYMBOL(ib_copy_ah_attr_to_user);
51 53
52void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst, 54void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
53 struct ib_qp_attr *src) 55 struct ib_qp_attr *src)
54{ 56{
57 dst->qp_state = src->qp_state;
55 dst->cur_qp_state = src->cur_qp_state; 58 dst->cur_qp_state = src->cur_qp_state;
56 dst->path_mtu = src->path_mtu; 59 dst->path_mtu = src->path_mtu;
57 dst->path_mig_state = src->path_mig_state; 60 dst->path_mig_state = src->path_mig_state;
@@ -83,6 +86,7 @@ void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
83 dst->rnr_retry = src->rnr_retry; 86 dst->rnr_retry = src->rnr_retry;
84 dst->alt_port_num = src->alt_port_num; 87 dst->alt_port_num = src->alt_port_num;
85 dst->alt_timeout = src->alt_timeout; 88 dst->alt_timeout = src->alt_timeout;
89 memset(dst->reserved, 0, sizeof(dst->reserved));
86} 90}
87EXPORT_SYMBOL(ib_copy_qp_attr_to_user); 91EXPORT_SYMBOL(ib_copy_qp_attr_to_user);
88 92
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 6078992da3f0..9292a15ad7c4 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -40,7 +40,6 @@
40#include <linux/highmem.h> 40#include <linux/highmem.h>
41#include <linux/io.h> 41#include <linux/io.h>
42#include <linux/jiffies.h> 42#include <linux/jiffies.h>
43#include <linux/smp_lock.h>
44#include <asm/pgtable.h> 43#include <asm/pgtable.h>
45 44
46#include "ipath_kernel.h" 45#include "ipath_kernel.h"
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index bf3e20cd0298..30e09caf0da9 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -219,7 +219,7 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
219 struct net_device *ndev; 219 struct net_device *ndev;
220 enum ib_mtu tmp; 220 enum ib_mtu tmp;
221 221
222 props->active_width = IB_WIDTH_4X; 222 props->active_width = IB_WIDTH_1X;
223 props->active_speed = 4; 223 props->active_speed = 4;
224 props->port_cap_flags = IB_PORT_CM_SUP; 224 props->port_cap_flags = IB_PORT_CM_SUP;
225 props->gid_tbl_len = to_mdev(ibdev)->dev->caps.gid_table_len[port]; 225 props->gid_tbl_len = to_mdev(ibdev)->dev->caps.gid_table_len[port];
@@ -242,7 +242,7 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
242 tmp = iboe_get_mtu(ndev->mtu); 242 tmp = iboe_get_mtu(ndev->mtu);
243 props->active_mtu = tmp ? min(props->max_mtu, tmp) : IB_MTU_256; 243 props->active_mtu = tmp ? min(props->max_mtu, tmp) : IB_MTU_256;
244 244
245 props->state = netif_running(ndev) && netif_oper_up(ndev) ? 245 props->state = (netif_running(ndev) && netif_carrier_ok(ndev)) ?
246 IB_PORT_ACTIVE : IB_PORT_DOWN; 246 IB_PORT_ACTIVE : IB_PORT_DOWN;
247 props->phys_state = state_to_phys_state(props->state); 247 props->phys_state = state_to_phys_state(props->state);
248 248
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 9a7794ac34c1..2001f20a4361 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1816,6 +1816,11 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1816 ctrl->fence_size = (wr->send_flags & IB_SEND_FENCE ? 1816 ctrl->fence_size = (wr->send_flags & IB_SEND_FENCE ?
1817 MLX4_WQE_CTRL_FENCE : 0) | size; 1817 MLX4_WQE_CTRL_FENCE : 0) | size;
1818 1818
1819 if (be16_to_cpu(vlan) < 0x1000) {
1820 ctrl->ins_vlan = 1 << 6;
1821 ctrl->vlan_tag = vlan;
1822 }
1823
1819 /* 1824 /*
1820 * Make sure descriptor is fully written before 1825 * Make sure descriptor is fully written before
1821 * setting ownership bit (because HW can start 1826 * setting ownership bit (because HW can start
@@ -1831,11 +1836,6 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1831 ctrl->owner_opcode = mlx4_ib_opcode[wr->opcode] | 1836 ctrl->owner_opcode = mlx4_ib_opcode[wr->opcode] |
1832 (ind & qp->sq.wqe_cnt ? cpu_to_be32(1 << 31) : 0) | blh; 1837 (ind & qp->sq.wqe_cnt ? cpu_to_be32(1 << 31) : 0) | blh;
1833 1838
1834 if (be16_to_cpu(vlan) < 0x1000) {
1835 ctrl->ins_vlan = 1 << 6;
1836 ctrl->vlan_tag = vlan;
1837 }
1838
1839 stamp = ind + qp->sq_spare_wqes; 1839 stamp = ind + qp->sq_spare_wqes;
1840 ind += DIV_ROUND_UP(size * 16, 1U << qp->sq.wqe_shift); 1840 ind += DIV_ROUND_UP(size * 16, 1U << qp->sq.wqe_shift);
1841 1841
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index cfc1d65c4577..1e1e347a7715 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1123,7 +1123,7 @@ static void srp_send_completion(struct ib_cq *cq, void *target_ptr)
1123 } 1123 }
1124} 1124}
1125 1125
1126static int srp_queuecommand(struct scsi_cmnd *scmnd, 1126static int srp_queuecommand_lck(struct scsi_cmnd *scmnd,
1127 void (*done)(struct scsi_cmnd *)) 1127 void (*done)(struct scsi_cmnd *))
1128{ 1128{
1129 struct srp_target_port *target = host_to_target(scmnd->device->host); 1129 struct srp_target_port *target = host_to_target(scmnd->device->host);
@@ -1196,6 +1196,8 @@ err:
1196 return SCSI_MLQUEUE_HOST_BUSY; 1196 return SCSI_MLQUEUE_HOST_BUSY;
1197} 1197}
1198 1198
1199static DEF_SCSI_QCMD(srp_queuecommand)
1200
1199static int srp_alloc_iu_bufs(struct srp_target_port *target) 1201static int srp_alloc_iu_bufs(struct srp_target_port *target)
1200{ 1202{
1201 int i; 1203 int i;
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index e3f7fc6f9565..68f09a868434 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -534,76 +534,73 @@ static int handle_eviocgbit(struct input_dev *dev,
534} 534}
535#undef OLD_KEY_MAX 535#undef OLD_KEY_MAX
536 536
537static int evdev_handle_get_keycode(struct input_dev *dev, 537static int evdev_handle_get_keycode(struct input_dev *dev, void __user *p)
538 void __user *p, size_t size)
539{ 538{
540 struct input_keymap_entry ke; 539 struct input_keymap_entry ke = {
540 .len = sizeof(unsigned int),
541 .flags = 0,
542 };
543 int __user *ip = (int __user *)p;
541 int error; 544 int error;
542 545
543 memset(&ke, 0, sizeof(ke)); 546 /* legacy case */
544 547 if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))
545 if (size == sizeof(unsigned int[2])) { 548 return -EFAULT;
546 /* legacy case */
547 int __user *ip = (int __user *)p;
548 549
549 if (copy_from_user(ke.scancode, p, sizeof(unsigned int))) 550 error = input_get_keycode(dev, &ke);
550 return -EFAULT; 551 if (error)
552 return error;
551 553
552 ke.len = sizeof(unsigned int); 554 if (put_user(ke.keycode, ip + 1))
553 ke.flags = 0; 555 return -EFAULT;
554 556
555 error = input_get_keycode(dev, &ke); 557 return 0;
556 if (error) 558}
557 return error;
558 559
559 if (put_user(ke.keycode, ip + 1)) 560static int evdev_handle_get_keycode_v2(struct input_dev *dev, void __user *p)
560 return -EFAULT; 561{
562 struct input_keymap_entry ke;
563 int error;
561 564
562 } else { 565 if (copy_from_user(&ke, p, sizeof(ke)))
563 size = min(size, sizeof(ke)); 566 return -EFAULT;
564 567
565 if (copy_from_user(&ke, p, size)) 568 error = input_get_keycode(dev, &ke);
566 return -EFAULT; 569 if (error)
570 return error;
567 571
568 error = input_get_keycode(dev, &ke); 572 if (copy_to_user(p, &ke, sizeof(ke)))
569 if (error) 573 return -EFAULT;
570 return error;
571 574
572 if (copy_to_user(p, &ke, size))
573 return -EFAULT;
574 }
575 return 0; 575 return 0;
576} 576}
577 577
578static int evdev_handle_set_keycode(struct input_dev *dev, 578static int evdev_handle_set_keycode(struct input_dev *dev, void __user *p)
579 void __user *p, size_t size)
580{ 579{
581 struct input_keymap_entry ke; 580 struct input_keymap_entry ke = {
582 581 .len = sizeof(unsigned int),
583 memset(&ke, 0, sizeof(ke)); 582 .flags = 0,
583 };
584 int __user *ip = (int __user *)p;
584 585
585 if (size == sizeof(unsigned int[2])) { 586 if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))
586 /* legacy case */ 587 return -EFAULT;
587 int __user *ip = (int __user *)p;
588 588
589 if (copy_from_user(ke.scancode, p, sizeof(unsigned int))) 589 if (get_user(ke.keycode, ip + 1))
590 return -EFAULT; 590 return -EFAULT;
591 591
592 if (get_user(ke.keycode, ip + 1)) 592 return input_set_keycode(dev, &ke);
593 return -EFAULT; 593}
594 594
595 ke.len = sizeof(unsigned int); 595static int evdev_handle_set_keycode_v2(struct input_dev *dev, void __user *p)
596 ke.flags = 0; 596{
597 struct input_keymap_entry ke;
597 598
598 } else { 599 if (copy_from_user(&ke, p, sizeof(ke)))
599 size = min(size, sizeof(ke)); 600 return -EFAULT;
600 601
601 if (copy_from_user(&ke, p, size)) 602 if (ke.len > sizeof(ke.scancode))
602 return -EFAULT; 603 return -EINVAL;
603
604 if (ke.len > sizeof(ke.scancode))
605 return -EINVAL;
606 }
607 604
608 return input_set_keycode(dev, &ke); 605 return input_set_keycode(dev, &ke);
609} 606}
@@ -669,6 +666,18 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
669 return evdev_grab(evdev, client); 666 return evdev_grab(evdev, client);
670 else 667 else
671 return evdev_ungrab(evdev, client); 668 return evdev_ungrab(evdev, client);
669
670 case EVIOCGKEYCODE:
671 return evdev_handle_get_keycode(dev, p);
672
673 case EVIOCSKEYCODE:
674 return evdev_handle_set_keycode(dev, p);
675
676 case EVIOCGKEYCODE_V2:
677 return evdev_handle_get_keycode_v2(dev, p);
678
679 case EVIOCSKEYCODE_V2:
680 return evdev_handle_set_keycode_v2(dev, p);
672 } 681 }
673 682
674 size = _IOC_SIZE(cmd); 683 size = _IOC_SIZE(cmd);
@@ -708,12 +717,6 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
708 return -EFAULT; 717 return -EFAULT;
709 718
710 return error; 719 return error;
711
712 case EVIOC_MASK_SIZE(EVIOCGKEYCODE):
713 return evdev_handle_get_keycode(dev, p, size);
714
715 case EVIOC_MASK_SIZE(EVIOCSKEYCODE):
716 return evdev_handle_set_keycode(dev, p, size);
717 } 720 }
718 721
719 /* Multi-number variable-length handlers */ 722 /* Multi-number variable-length handlers */
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7f26ca6ecf75..db409d6bd5d2 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -24,7 +24,6 @@
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/rcupdate.h> 26#include <linux/rcupdate.h>
27#include <linux/smp_lock.h>
28#include "input-compat.h" 27#include "input-compat.h"
29 28
30MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 29MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
@@ -753,7 +752,7 @@ static int input_default_setkeycode(struct input_dev *dev,
753 if (index >= dev->keycodemax) 752 if (index >= dev->keycodemax)
754 return -EINVAL; 753 return -EINVAL;
755 754
756 if (dev->keycodesize < sizeof(dev->keycode) && 755 if (dev->keycodesize < sizeof(ke->keycode) &&
757 (ke->keycode >> (dev->keycodesize * 8))) 756 (ke->keycode >> (dev->keycodesize * 8)))
758 return -EINVAL; 757 return -EINVAL;
759 758
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index d53b9e900234..27b6a3ce18ca 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -245,6 +245,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
245 goto err_free_tgfx; 245 goto err_free_tgfx;
246 } 246 }
247 247
248 parport_put_port(pp);
248 return tgfx; 249 return tgfx;
249 250
250 err_free_dev: 251 err_free_dev:
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index b8c51b9781db..3a87f3ba5f75 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -179,6 +179,22 @@ config KEYBOARD_GPIO
179 To compile this driver as a module, choose M here: the 179 To compile this driver as a module, choose M here: the
180 module will be called gpio_keys. 180 module will be called gpio_keys.
181 181
182config KEYBOARD_GPIO_POLLED
183 tristate "Polled GPIO buttons"
184 depends on GENERIC_GPIO
185 select INPUT_POLLDEV
186 help
187 This driver implements support for buttons connected
188 to GPIO pins that are not capable of generating interrupts.
189
190 Say Y here if your device has buttons connected
191 directly to such GPIO pins. Your board-specific
192 setup logic must also provide a platform device,
193 with configuration data saying which GPIOs are used.
194
195 To compile this driver as a module, choose M here: the
196 module will be called gpio_keys_polled.
197
182config KEYBOARD_TCA6416 198config KEYBOARD_TCA6416
183 tristate "TCA6416 Keypad Support" 199 tristate "TCA6416 Keypad Support"
184 depends on I2C 200 depends on I2C
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index a34452e8ebe2..622de73a445d 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
14obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o 14obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o
15obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o 15obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o
16obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 16obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
17obj-$(CONFIG_KEYBOARD_GPIO_POLLED) += gpio_keys_polled.o
17obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o 18obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o
18obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 19obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
19obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 20obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
new file mode 100644
index 000000000000..4c17aff20657
--- /dev/null
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -0,0 +1,261 @@
1/*
2 * Driver for buttons on GPIO lines not capable of generating interrupts
3 *
4 * Copyright (C) 2007-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2010 Nuno Goncalves <nunojpg@gmail.com>
6 *
7 * This file was based on: /drivers/input/misc/cobalt_btns.c
8 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
9 *
10 * also was based on: /drivers/input/keyboard/gpio_keys.c
11 * Copyright 2005 Phil Blundell
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/slab.h>
22#include <linux/input.h>
23#include <linux/input-polldev.h>
24#include <linux/ioport.h>
25#include <linux/platform_device.h>
26#include <linux/gpio.h>
27#include <linux/gpio_keys.h>
28
29#define DRV_NAME "gpio-keys-polled"
30
31struct gpio_keys_button_data {
32 int last_state;
33 int count;
34 int threshold;
35 int can_sleep;
36};
37
38struct gpio_keys_polled_dev {
39 struct input_polled_dev *poll_dev;
40 struct device *dev;
41 struct gpio_keys_platform_data *pdata;
42 struct gpio_keys_button_data data[0];
43};
44
45static void gpio_keys_polled_check_state(struct input_dev *input,
46 struct gpio_keys_button *button,
47 struct gpio_keys_button_data *bdata)
48{
49 int state;
50
51 if (bdata->can_sleep)
52 state = !!gpio_get_value_cansleep(button->gpio);
53 else
54 state = !!gpio_get_value(button->gpio);
55
56 if (state != bdata->last_state) {
57 unsigned int type = button->type ?: EV_KEY;
58
59 input_event(input, type, button->code,
60 !!(state ^ button->active_low));
61 input_sync(input);
62 bdata->count = 0;
63 bdata->last_state = state;
64 }
65}
66
67static void gpio_keys_polled_poll(struct input_polled_dev *dev)
68{
69 struct gpio_keys_polled_dev *bdev = dev->private;
70 struct gpio_keys_platform_data *pdata = bdev->pdata;
71 struct input_dev *input = dev->input;
72 int i;
73
74 for (i = 0; i < bdev->pdata->nbuttons; i++) {
75 struct gpio_keys_button_data *bdata = &bdev->data[i];
76
77 if (bdata->count < bdata->threshold)
78 bdata->count++;
79 else
80 gpio_keys_polled_check_state(input, &pdata->buttons[i],
81 bdata);
82 }
83}
84
85static void gpio_keys_polled_open(struct input_polled_dev *dev)
86{
87 struct gpio_keys_polled_dev *bdev = dev->private;
88 struct gpio_keys_platform_data *pdata = bdev->pdata;
89
90 if (pdata->enable)
91 pdata->enable(bdev->dev);
92}
93
94static void gpio_keys_polled_close(struct input_polled_dev *dev)
95{
96 struct gpio_keys_polled_dev *bdev = dev->private;
97 struct gpio_keys_platform_data *pdata = bdev->pdata;
98
99 if (pdata->disable)
100 pdata->disable(bdev->dev);
101}
102
103static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
104{
105 struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
106 struct device *dev = &pdev->dev;
107 struct gpio_keys_polled_dev *bdev;
108 struct input_polled_dev *poll_dev;
109 struct input_dev *input;
110 int error;
111 int i;
112
113 if (!pdata || !pdata->poll_interval)
114 return -EINVAL;
115
116 bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
117 pdata->nbuttons * sizeof(struct gpio_keys_button_data),
118 GFP_KERNEL);
119 if (!bdev) {
120 dev_err(dev, "no memory for private data\n");
121 return -ENOMEM;
122 }
123
124 poll_dev = input_allocate_polled_device();
125 if (!poll_dev) {
126 dev_err(dev, "no memory for polled device\n");
127 error = -ENOMEM;
128 goto err_free_bdev;
129 }
130
131 poll_dev->private = bdev;
132 poll_dev->poll = gpio_keys_polled_poll;
133 poll_dev->poll_interval = pdata->poll_interval;
134 poll_dev->open = gpio_keys_polled_open;
135 poll_dev->close = gpio_keys_polled_close;
136
137 input = poll_dev->input;
138
139 input->evbit[0] = BIT(EV_KEY);
140 input->name = pdev->name;
141 input->phys = DRV_NAME"/input0";
142 input->dev.parent = &pdev->dev;
143
144 input->id.bustype = BUS_HOST;
145 input->id.vendor = 0x0001;
146 input->id.product = 0x0001;
147 input->id.version = 0x0100;
148
149 for (i = 0; i < pdata->nbuttons; i++) {
150 struct gpio_keys_button *button = &pdata->buttons[i];
151 struct gpio_keys_button_data *bdata = &bdev->data[i];
152 unsigned int gpio = button->gpio;
153 unsigned int type = button->type ?: EV_KEY;
154
155 if (button->wakeup) {
156 dev_err(dev, DRV_NAME " does not support wakeup\n");
157 error = -EINVAL;
158 goto err_free_gpio;
159 }
160
161 error = gpio_request(gpio,
162 button->desc ? button->desc : DRV_NAME);
163 if (error) {
164 dev_err(dev, "unable to claim gpio %u, err=%d\n",
165 gpio, error);
166 goto err_free_gpio;
167 }
168
169 error = gpio_direction_input(gpio);
170 if (error) {
171 dev_err(dev,
172 "unable to set direction on gpio %u, err=%d\n",
173 gpio, error);
174 goto err_free_gpio;
175 }
176
177 bdata->can_sleep = gpio_cansleep(gpio);
178 bdata->last_state = -1;
179 bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
180 pdata->poll_interval);
181
182 input_set_capability(input, type, button->code);
183 }
184
185 bdev->poll_dev = poll_dev;
186 bdev->dev = dev;
187 bdev->pdata = pdata;
188 platform_set_drvdata(pdev, bdev);
189
190 error = input_register_polled_device(poll_dev);
191 if (error) {
192 dev_err(dev, "unable to register polled device, err=%d\n",
193 error);
194 goto err_free_gpio;
195 }
196
197 /* report initial state of the buttons */
198 for (i = 0; i < pdata->nbuttons; i++)
199 gpio_keys_polled_check_state(input, &pdata->buttons[i],
200 &bdev->data[i]);
201
202 return 0;
203
204err_free_gpio:
205 while (--i >= 0)
206 gpio_free(pdata->buttons[i].gpio);
207
208 input_free_polled_device(poll_dev);
209
210err_free_bdev:
211 kfree(bdev);
212
213 platform_set_drvdata(pdev, NULL);
214 return error;
215}
216
217static int __devexit gpio_keys_polled_remove(struct platform_device *pdev)
218{
219 struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
220 struct gpio_keys_platform_data *pdata = bdev->pdata;
221 int i;
222
223 input_unregister_polled_device(bdev->poll_dev);
224
225 for (i = 0; i < pdata->nbuttons; i++)
226 gpio_free(pdata->buttons[i].gpio);
227
228 input_free_polled_device(bdev->poll_dev);
229
230 kfree(bdev);
231 platform_set_drvdata(pdev, NULL);
232
233 return 0;
234}
235
236static struct platform_driver gpio_keys_polled_driver = {
237 .probe = gpio_keys_polled_probe,
238 .remove = __devexit_p(gpio_keys_polled_remove),
239 .driver = {
240 .name = DRV_NAME,
241 .owner = THIS_MODULE,
242 },
243};
244
245static int __init gpio_keys_polled_init(void)
246{
247 return platform_driver_register(&gpio_keys_polled_driver);
248}
249
250static void __exit gpio_keys_polled_exit(void)
251{
252 platform_driver_unregister(&gpio_keys_polled_driver);
253}
254
255module_init(gpio_keys_polled_init);
256module_exit(gpio_keys_polled_exit);
257
258MODULE_LICENSE("GPL v2");
259MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
260MODULE_DESCRIPTION("Polled GPIO Buttons driver");
261MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 613a3652f98f..0aefaa885871 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -51,7 +51,8 @@
51#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20) 51#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
52#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12) 52#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
53#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16) 53#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
54#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100) 54#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100000) /* 1-button ClickPad */
55#define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100) /* 2-button ClickPad */
55#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000) 56#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000)
56 57
57/* synaptics modes query bits */ 58/* synaptics modes query bits */
diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
index 3c287dd879d3..4225f5d6b15f 100644
--- a/drivers/input/serio/gscps2.c
+++ b/drivers/input/serio/gscps2.c
@@ -358,7 +358,7 @@ static int __devinit gscps2_probe(struct parisc_device *dev)
358 gscps2_reset(ps2port); 358 gscps2_reset(ps2port);
359 ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f; 359 ps2port->id = readb(ps2port->addr + GSC_ID) & 0x0f;
360 360
361 snprintf(serio->name, sizeof(serio->name), "GSC PS/2 %s", 361 snprintf(serio->name, sizeof(serio->name), "gsc-ps2-%s",
362 (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse"); 362 (ps2port->id == GSC_ID_KEYBOARD) ? "keyboard" : "mouse");
363 strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys)); 363 strlcpy(serio->phys, dev_name(&dev->dev), sizeof(serio->phys));
364 serio->id.type = SERIO_8042; 364 serio->id.type = SERIO_8042;
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index cd82bb125915..b7ba4597f7f0 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/smp_lock.h>
15#include <linux/poll.h> 14#include <linux/poll.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/serio.h> 16#include <linux/serio.h>
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index 57b25b84d1fc..0a619c558bfb 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -1097,7 +1097,7 @@ store_tabletPointerMode(struct device *dev, struct device_attribute *attr, const
1097} 1097}
1098 1098
1099static DEVICE_ATTR(pointer_mode, 1099static DEVICE_ATTR(pointer_mode,
1100 S_IRUGO | S_IWUGO, 1100 S_IRUGO | S_IWUSR,
1101 show_tabletPointerMode, store_tabletPointerMode); 1101 show_tabletPointerMode, store_tabletPointerMode);
1102 1102
1103/*********************************************************************** 1103/***********************************************************************
@@ -1134,7 +1134,7 @@ store_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, co
1134} 1134}
1135 1135
1136static DEVICE_ATTR(coordinate_mode, 1136static DEVICE_ATTR(coordinate_mode,
1137 S_IRUGO | S_IWUGO, 1137 S_IRUGO | S_IWUSR,
1138 show_tabletCoordinateMode, store_tabletCoordinateMode); 1138 show_tabletCoordinateMode, store_tabletCoordinateMode);
1139 1139
1140/*********************************************************************** 1140/***********************************************************************
@@ -1176,7 +1176,7 @@ store_tabletToolMode(struct device *dev, struct device_attribute *attr, const ch
1176} 1176}
1177 1177
1178static DEVICE_ATTR(tool_mode, 1178static DEVICE_ATTR(tool_mode,
1179 S_IRUGO | S_IWUGO, 1179 S_IRUGO | S_IWUSR,
1180 show_tabletToolMode, store_tabletToolMode); 1180 show_tabletToolMode, store_tabletToolMode);
1181 1181
1182/*********************************************************************** 1182/***********************************************************************
@@ -1219,7 +1219,7 @@ store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char
1219} 1219}
1220 1220
1221static DEVICE_ATTR(xtilt, 1221static DEVICE_ATTR(xtilt,
1222 S_IRUGO | S_IWUGO, show_tabletXtilt, store_tabletXtilt); 1222 S_IRUGO | S_IWUSR, show_tabletXtilt, store_tabletXtilt);
1223 1223
1224/*********************************************************************** 1224/***********************************************************************
1225 * support routines for the 'ytilt' file. Note that this file 1225 * support routines for the 'ytilt' file. Note that this file
@@ -1261,7 +1261,7 @@ store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char
1261} 1261}
1262 1262
1263static DEVICE_ATTR(ytilt, 1263static DEVICE_ATTR(ytilt,
1264 S_IRUGO | S_IWUGO, show_tabletYtilt, store_tabletYtilt); 1264 S_IRUGO | S_IWUSR, show_tabletYtilt, store_tabletYtilt);
1265 1265
1266/*********************************************************************** 1266/***********************************************************************
1267 * support routines for the 'jitter' file. Note that this file 1267 * support routines for the 'jitter' file. Note that this file
@@ -1288,7 +1288,7 @@ store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const
1288} 1288}
1289 1289
1290static DEVICE_ATTR(jitter, 1290static DEVICE_ATTR(jitter,
1291 S_IRUGO | S_IWUGO, 1291 S_IRUGO | S_IWUSR,
1292 show_tabletJitterDelay, store_tabletJitterDelay); 1292 show_tabletJitterDelay, store_tabletJitterDelay);
1293 1293
1294/*********************************************************************** 1294/***********************************************************************
@@ -1317,7 +1317,7 @@ store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr,
1317} 1317}
1318 1318
1319static DEVICE_ATTR(delay, 1319static DEVICE_ATTR(delay,
1320 S_IRUGO | S_IWUGO, 1320 S_IRUGO | S_IWUSR,
1321 show_tabletProgrammableDelay, store_tabletProgrammableDelay); 1321 show_tabletProgrammableDelay, store_tabletProgrammableDelay);
1322 1322
1323/*********************************************************************** 1323/***********************************************************************
@@ -1406,7 +1406,7 @@ store_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const
1406} 1406}
1407 1407
1408static DEVICE_ATTR(stylus_upper, 1408static DEVICE_ATTR(stylus_upper,
1409 S_IRUGO | S_IWUGO, 1409 S_IRUGO | S_IWUSR,
1410 show_tabletStylusUpper, store_tabletStylusUpper); 1410 show_tabletStylusUpper, store_tabletStylusUpper);
1411 1411
1412/*********************************************************************** 1412/***********************************************************************
@@ -1437,7 +1437,7 @@ store_tabletStylusLower(struct device *dev, struct device_attribute *attr, const
1437} 1437}
1438 1438
1439static DEVICE_ATTR(stylus_lower, 1439static DEVICE_ATTR(stylus_lower,
1440 S_IRUGO | S_IWUGO, 1440 S_IRUGO | S_IWUSR,
1441 show_tabletStylusLower, store_tabletStylusLower); 1441 show_tabletStylusLower, store_tabletStylusLower);
1442 1442
1443/*********************************************************************** 1443/***********************************************************************
@@ -1475,7 +1475,7 @@ store_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const c
1475} 1475}
1476 1476
1477static DEVICE_ATTR(mouse_left, 1477static DEVICE_ATTR(mouse_left,
1478 S_IRUGO | S_IWUGO, 1478 S_IRUGO | S_IWUSR,
1479 show_tabletMouseLeft, store_tabletMouseLeft); 1479 show_tabletMouseLeft, store_tabletMouseLeft);
1480 1480
1481/*********************************************************************** 1481/***********************************************************************
@@ -1505,7 +1505,7 @@ store_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const
1505} 1505}
1506 1506
1507static DEVICE_ATTR(mouse_middle, 1507static DEVICE_ATTR(mouse_middle,
1508 S_IRUGO | S_IWUGO, 1508 S_IRUGO | S_IWUSR,
1509 show_tabletMouseMiddle, store_tabletMouseMiddle); 1509 show_tabletMouseMiddle, store_tabletMouseMiddle);
1510 1510
1511/*********************************************************************** 1511/***********************************************************************
@@ -1535,7 +1535,7 @@ store_tabletMouseRight(struct device *dev, struct device_attribute *attr, const
1535} 1535}
1536 1536
1537static DEVICE_ATTR(mouse_right, 1537static DEVICE_ATTR(mouse_right,
1538 S_IRUGO | S_IWUGO, 1538 S_IRUGO | S_IWUSR,
1539 show_tabletMouseRight, store_tabletMouseRight); 1539 show_tabletMouseRight, store_tabletMouseRight);
1540 1540
1541/*********************************************************************** 1541/***********************************************************************
@@ -1567,7 +1567,7 @@ store_tabletWheel(struct device *dev, struct device_attribute *attr, const char
1567} 1567}
1568 1568
1569static DEVICE_ATTR(wheel, 1569static DEVICE_ATTR(wheel,
1570 S_IRUGO | S_IWUGO, show_tabletWheel, store_tabletWheel); 1570 S_IRUGO | S_IWUSR, show_tabletWheel, store_tabletWheel);
1571 1571
1572/*********************************************************************** 1572/***********************************************************************
1573 * support routines for the 'execute' file. Note that this file 1573 * support routines for the 'execute' file. Note that this file
@@ -1600,7 +1600,7 @@ store_tabletExecute(struct device *dev, struct device_attribute *attr, const cha
1600} 1600}
1601 1601
1602static DEVICE_ATTR(execute, 1602static DEVICE_ATTR(execute,
1603 S_IRUGO | S_IWUGO, show_tabletExecute, store_tabletExecute); 1603 S_IRUGO | S_IWUSR, show_tabletExecute, store_tabletExecute);
1604 1604
1605/*********************************************************************** 1605/***********************************************************************
1606 * support routines for the 'odm_code' file. Note that this file 1606 * support routines for the 'odm_code' file. Note that this file
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index b3252ef1e279..435b0af401e4 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1436,6 +1436,14 @@ static struct wacom_features wacom_features_0xD2 =
1436 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1436 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1437static struct wacom_features wacom_features_0xD3 = 1437static struct wacom_features wacom_features_0xD3 =
1438 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1438 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1439static const struct wacom_features wacom_features_0xD4 =
1440 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT };
1441static struct wacom_features wacom_features_0xD8 =
1442 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1443static struct wacom_features wacom_features_0xDA =
1444 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1445static struct wacom_features wacom_features_0xDB =
1446 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1439 1447
1440#define USB_DEVICE_WACOM(prod) \ 1448#define USB_DEVICE_WACOM(prod) \
1441 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ 1449 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
@@ -1504,6 +1512,10 @@ const struct usb_device_id wacom_ids[] = {
1504 { USB_DEVICE_WACOM(0xD1) }, 1512 { USB_DEVICE_WACOM(0xD1) },
1505 { USB_DEVICE_WACOM(0xD2) }, 1513 { USB_DEVICE_WACOM(0xD2) },
1506 { USB_DEVICE_WACOM(0xD3) }, 1514 { USB_DEVICE_WACOM(0xD3) },
1515 { USB_DEVICE_WACOM(0xD4) },
1516 { USB_DEVICE_WACOM(0xD8) },
1517 { USB_DEVICE_WACOM(0xDA) },
1518 { USB_DEVICE_WACOM(0xDB) },
1507 { USB_DEVICE_WACOM(0xF0) }, 1519 { USB_DEVICE_WACOM(0xF0) },
1508 { USB_DEVICE_WACOM(0xCC) }, 1520 { USB_DEVICE_WACOM(0xCC) },
1509 { USB_DEVICE_WACOM(0x90) }, 1521 { USB_DEVICE_WACOM(0x90) },
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index f45f80f6d336..73fd6642b681 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -178,6 +178,7 @@ static const struct usb_device_id usbtouch_devices[] = {
178 178
179#ifdef CONFIG_TOUCHSCREEN_USB_ITM 179#ifdef CONFIG_TOUCHSCREEN_USB_ITM
180 {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM}, 180 {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM},
181 {USB_DEVICE(0x16e3, 0xf9e9), .driver_info = DEVTYPE_ITM},
181#endif 182#endif
182 183
183#ifdef CONFIG_TOUCHSCREEN_USB_ETURBO 184#ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
index 2e847a90bad0..f2b5bab5e6a1 100644
--- a/drivers/isdn/icn/icn.c
+++ b/drivers/isdn/icn/icn.c
@@ -1627,7 +1627,7 @@ __setup("icn=", icn_setup);
1627static int __init icn_init(void) 1627static int __init icn_init(void)
1628{ 1628{
1629 char *p; 1629 char *p;
1630 char rev[10]; 1630 char rev[20];
1631 1631
1632 memset(&dev, 0, sizeof(icn_dev)); 1632 memset(&dev, 0, sizeof(icn_dev));
1633 dev.memaddr = (membase & 0x0ffc000); 1633 dev.memaddr = (membase & 0x0ffc000);
@@ -1637,9 +1637,10 @@ static int __init icn_init(void)
1637 spin_lock_init(&dev.devlock); 1637 spin_lock_init(&dev.devlock);
1638 1638
1639 if ((p = strchr(revision, ':'))) { 1639 if ((p = strchr(revision, ':'))) {
1640 strcpy(rev, p + 1); 1640 strncpy(rev, p + 1, 20);
1641 p = strchr(rev, '$'); 1641 p = strchr(rev, '$');
1642 *p = 0; 1642 if (p)
1643 *p = 0;
1643 } else 1644 } else
1644 strcpy(rev, " ??? "); 1645 strcpy(rev, " ??? ");
1645 printk(KERN_NOTICE "ICN-ISDN-driver Rev%smem=0x%08lx\n", rev, 1646 printk(KERN_NOTICE "ICN-ISDN-driver Rev%smem=0x%08lx\n", rev,
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 77b8fd20cd90..6f190f4cdbc0 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -7,20 +7,20 @@ menuconfig NEW_LEDS
7 This is not related to standard keyboard LEDs which are controlled 7 This is not related to standard keyboard LEDs which are controlled
8 via the input system. 8 via the input system.
9 9
10if NEW_LEDS
11
12config LEDS_CLASS 10config LEDS_CLASS
13 bool "LED Class Support" 11 bool "LED Class Support"
12 depends on NEW_LEDS
14 help 13 help
15 This option enables the led sysfs class in /sys/class/leds. You'll 14 This option enables the led sysfs class in /sys/class/leds. You'll
16 need this to do anything useful with LEDs. If unsure, say N. 15 need this to do anything useful with LEDs. If unsure, say N.
17 16
18if LEDS_CLASS 17if NEW_LEDS
19 18
20comment "LED drivers" 19comment "LED drivers"
21 20
22config LEDS_88PM860X 21config LEDS_88PM860X
23 tristate "LED Support for Marvell 88PM860x PMIC" 22 tristate "LED Support for Marvell 88PM860x PMIC"
23 depends on LEDS_CLASS
24 depends on MFD_88PM860X 24 depends on MFD_88PM860X
25 help 25 help
26 This option enables support for on-chip LED drivers found on Marvell 26 This option enables support for on-chip LED drivers found on Marvell
@@ -28,6 +28,7 @@ config LEDS_88PM860X
28 28
29config LEDS_ATMEL_PWM 29config LEDS_ATMEL_PWM
30 tristate "LED Support using Atmel PWM outputs" 30 tristate "LED Support using Atmel PWM outputs"
31 depends on LEDS_CLASS
31 depends on ATMEL_PWM 32 depends on ATMEL_PWM
32 help 33 help
33 This option enables support for LEDs driven using outputs 34 This option enables support for LEDs driven using outputs
@@ -35,6 +36,7 @@ config LEDS_ATMEL_PWM
35 36
36config LEDS_LOCOMO 37config LEDS_LOCOMO
37 tristate "LED Support for Locomo device" 38 tristate "LED Support for Locomo device"
39 depends on LEDS_CLASS
38 depends on SHARP_LOCOMO 40 depends on SHARP_LOCOMO
39 help 41 help
40 This option enables support for the LEDs on Sharp Locomo. 42 This option enables support for the LEDs on Sharp Locomo.
@@ -42,6 +44,7 @@ config LEDS_LOCOMO
42 44
43config LEDS_MIKROTIK_RB532 45config LEDS_MIKROTIK_RB532
44 tristate "LED Support for Mikrotik Routerboard 532" 46 tristate "LED Support for Mikrotik Routerboard 532"
47 depends on LEDS_CLASS
45 depends on MIKROTIK_RB532 48 depends on MIKROTIK_RB532
46 help 49 help
47 This option enables support for the so called "User LED" of 50 This option enables support for the so called "User LED" of
@@ -49,6 +52,7 @@ config LEDS_MIKROTIK_RB532
49 52
50config LEDS_S3C24XX 53config LEDS_S3C24XX
51 tristate "LED Support for Samsung S3C24XX GPIO LEDs" 54 tristate "LED Support for Samsung S3C24XX GPIO LEDs"
55 depends on LEDS_CLASS
52 depends on ARCH_S3C2410 56 depends on ARCH_S3C2410
53 help 57 help
54 This option enables support for LEDs connected to GPIO lines 58 This option enables support for LEDs connected to GPIO lines
@@ -56,12 +60,14 @@ config LEDS_S3C24XX
56 60
57config LEDS_AMS_DELTA 61config LEDS_AMS_DELTA
58 tristate "LED Support for the Amstrad Delta (E3)" 62 tristate "LED Support for the Amstrad Delta (E3)"
63 depends on LEDS_CLASS
59 depends on MACH_AMS_DELTA 64 depends on MACH_AMS_DELTA
60 help 65 help
61 This option enables support for the LEDs on Amstrad Delta (E3). 66 This option enables support for the LEDs on Amstrad Delta (E3).
62 67
63config LEDS_NET48XX 68config LEDS_NET48XX
64 tristate "LED Support for Soekris net48xx series Error LED" 69 tristate "LED Support for Soekris net48xx series Error LED"
70 depends on LEDS_CLASS
65 depends on SCx200_GPIO 71 depends on SCx200_GPIO
66 help 72 help
67 This option enables support for the Soekris net4801 and net4826 error 73 This option enables support for the Soekris net4801 and net4826 error
@@ -79,18 +85,21 @@ config LEDS_NET5501
79 85
80config LEDS_FSG 86config LEDS_FSG
81 tristate "LED Support for the Freecom FSG-3" 87 tristate "LED Support for the Freecom FSG-3"
88 depends on LEDS_CLASS
82 depends on MACH_FSG 89 depends on MACH_FSG
83 help 90 help
84 This option enables support for the LEDs on the Freecom FSG-3. 91 This option enables support for the LEDs on the Freecom FSG-3.
85 92
86config LEDS_WRAP 93config LEDS_WRAP
87 tristate "LED Support for the WRAP series LEDs" 94 tristate "LED Support for the WRAP series LEDs"
95 depends on LEDS_CLASS
88 depends on SCx200_GPIO 96 depends on SCx200_GPIO
89 help 97 help
90 This option enables support for the PCEngines WRAP programmable LEDs. 98 This option enables support for the PCEngines WRAP programmable LEDs.
91 99
92config LEDS_ALIX2 100config LEDS_ALIX2
93 tristate "LED Support for ALIX.2 and ALIX.3 series" 101 tristate "LED Support for ALIX.2 and ALIX.3 series"
102 depends on LEDS_CLASS
94 depends on X86 && !GPIO_CS5535 && !CS5535_GPIO 103 depends on X86 && !GPIO_CS5535 && !CS5535_GPIO
95 help 104 help
96 This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs. 105 This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs.
@@ -98,12 +107,14 @@ config LEDS_ALIX2
98 107
99config LEDS_H1940 108config LEDS_H1940
100 tristate "LED Support for iPAQ H1940 device" 109 tristate "LED Support for iPAQ H1940 device"
110 depends on LEDS_CLASS
101 depends on ARCH_H1940 111 depends on ARCH_H1940
102 help 112 help
103 This option enables support for the LEDs on the h1940. 113 This option enables support for the LEDs on the h1940.
104 114
105config LEDS_COBALT_QUBE 115config LEDS_COBALT_QUBE
106 tristate "LED Support for the Cobalt Qube series front LED" 116 tristate "LED Support for the Cobalt Qube series front LED"
117 depends on LEDS_CLASS
107 depends on MIPS_COBALT 118 depends on MIPS_COBALT
108 help 119 help
109 This option enables support for the front LED on Cobalt Qube series 120 This option enables support for the front LED on Cobalt Qube series
@@ -117,6 +128,7 @@ config LEDS_COBALT_RAQ
117 128
118config LEDS_SUNFIRE 129config LEDS_SUNFIRE
119 tristate "LED support for SunFire servers." 130 tristate "LED support for SunFire servers."
131 depends on LEDS_CLASS
120 depends on SPARC64 132 depends on SPARC64
121 select LEDS_TRIGGERS 133 select LEDS_TRIGGERS
122 help 134 help
@@ -125,6 +137,7 @@ config LEDS_SUNFIRE
125 137
126config LEDS_HP6XX 138config LEDS_HP6XX
127 tristate "LED Support for the HP Jornada 6xx" 139 tristate "LED Support for the HP Jornada 6xx"
140 depends on LEDS_CLASS
128 depends on SH_HP6XX 141 depends on SH_HP6XX
129 help 142 help
130 This option enables LED support for the handheld 143 This option enables LED support for the handheld
@@ -132,6 +145,7 @@ config LEDS_HP6XX
132 145
133config LEDS_PCA9532 146config LEDS_PCA9532
134 tristate "LED driver for PCA9532 dimmer" 147 tristate "LED driver for PCA9532 dimmer"
148 depends on LEDS_CLASS
135 depends on I2C && INPUT && EXPERIMENTAL 149 depends on I2C && INPUT && EXPERIMENTAL
136 help 150 help
137 This option enables support for NXP pca9532 151 This option enables support for NXP pca9532
@@ -140,6 +154,7 @@ config LEDS_PCA9532
140 154
141config LEDS_GPIO 155config LEDS_GPIO
142 tristate "LED Support for GPIO connected LEDs" 156 tristate "LED Support for GPIO connected LEDs"
157 depends on LEDS_CLASS
143 depends on GENERIC_GPIO 158 depends on GENERIC_GPIO
144 help 159 help
145 This option enables support for the LEDs connected to GPIO 160 This option enables support for the LEDs connected to GPIO
@@ -167,6 +182,7 @@ config LEDS_GPIO_OF
167 182
168config LEDS_LP3944 183config LEDS_LP3944
169 tristate "LED Support for N.S. LP3944 (Fun Light) I2C chip" 184 tristate "LED Support for N.S. LP3944 (Fun Light) I2C chip"
185 depends on LEDS_CLASS
170 depends on I2C 186 depends on I2C
171 help 187 help
172 This option enables support for LEDs connected to the National 188 This option enables support for LEDs connected to the National
@@ -196,6 +212,7 @@ config LEDS_LP5523
196 212
197config LEDS_CLEVO_MAIL 213config LEDS_CLEVO_MAIL
198 tristate "Mail LED on Clevo notebook" 214 tristate "Mail LED on Clevo notebook"
215 depends on LEDS_CLASS
199 depends on X86 && SERIO_I8042 && DMI 216 depends on X86 && SERIO_I8042 && DMI
200 help 217 help
201 This driver makes the mail LED accessible from userspace 218 This driver makes the mail LED accessible from userspace
@@ -226,6 +243,7 @@ config LEDS_CLEVO_MAIL
226 243
227config LEDS_PCA955X 244config LEDS_PCA955X
228 tristate "LED Support for PCA955x I2C chips" 245 tristate "LED Support for PCA955x I2C chips"
246 depends on LEDS_CLASS
229 depends on I2C 247 depends on I2C
230 help 248 help
231 This option enables support for LEDs connected to PCA955x 249 This option enables support for LEDs connected to PCA955x
@@ -234,6 +252,7 @@ config LEDS_PCA955X
234 252
235config LEDS_WM831X_STATUS 253config LEDS_WM831X_STATUS
236 tristate "LED support for status LEDs on WM831x PMICs" 254 tristate "LED support for status LEDs on WM831x PMICs"
255 depends on LEDS_CLASS
237 depends on MFD_WM831X 256 depends on MFD_WM831X
238 help 257 help
239 This option enables support for the status LEDs of the WM831x 258 This option enables support for the status LEDs of the WM831x
@@ -241,6 +260,7 @@ config LEDS_WM831X_STATUS
241 260
242config LEDS_WM8350 261config LEDS_WM8350
243 tristate "LED Support for WM8350 AudioPlus PMIC" 262 tristate "LED Support for WM8350 AudioPlus PMIC"
263 depends on LEDS_CLASS
244 depends on MFD_WM8350 264 depends on MFD_WM8350
245 help 265 help
246 This option enables support for LEDs driven by the Wolfson 266 This option enables support for LEDs driven by the Wolfson
@@ -248,6 +268,7 @@ config LEDS_WM8350
248 268
249config LEDS_DA903X 269config LEDS_DA903X
250 tristate "LED Support for DA9030/DA9034 PMIC" 270 tristate "LED Support for DA9030/DA9034 PMIC"
271 depends on LEDS_CLASS
251 depends on PMIC_DA903X 272 depends on PMIC_DA903X
252 help 273 help
253 This option enables support for on-chip LED drivers found 274 This option enables support for on-chip LED drivers found
@@ -255,6 +276,7 @@ config LEDS_DA903X
255 276
256config LEDS_DAC124S085 277config LEDS_DAC124S085
257 tristate "LED Support for DAC124S085 SPI DAC" 278 tristate "LED Support for DAC124S085 SPI DAC"
279 depends on LEDS_CLASS
258 depends on SPI 280 depends on SPI
259 help 281 help
260 This option enables support for DAC124S085 SPI DAC from NatSemi, 282 This option enables support for DAC124S085 SPI DAC from NatSemi,
@@ -262,18 +284,21 @@ config LEDS_DAC124S085
262 284
263config LEDS_PWM 285config LEDS_PWM
264 tristate "PWM driven LED Support" 286 tristate "PWM driven LED Support"
287 depends on LEDS_CLASS
265 depends on HAVE_PWM 288 depends on HAVE_PWM
266 help 289 help
267 This option enables support for pwm driven LEDs 290 This option enables support for pwm driven LEDs
268 291
269config LEDS_REGULATOR 292config LEDS_REGULATOR
270 tristate "REGULATOR driven LED support" 293 tristate "REGULATOR driven LED support"
294 depends on LEDS_CLASS
271 depends on REGULATOR 295 depends on REGULATOR
272 help 296 help
273 This option enables support for regulator driven LEDs. 297 This option enables support for regulator driven LEDs.
274 298
275config LEDS_BD2802 299config LEDS_BD2802
276 tristate "LED driver for BD2802 RGB LED" 300 tristate "LED driver for BD2802 RGB LED"
301 depends on LEDS_CLASS
277 depends on I2C 302 depends on I2C
278 help 303 help
279 This option enables support for BD2802GU RGB LED driver chips 304 This option enables support for BD2802GU RGB LED driver chips
@@ -281,6 +306,7 @@ config LEDS_BD2802
281 306
282config LEDS_INTEL_SS4200 307config LEDS_INTEL_SS4200
283 tristate "LED driver for Intel NAS SS4200 series" 308 tristate "LED driver for Intel NAS SS4200 series"
309 depends on LEDS_CLASS
284 depends on PCI && DMI 310 depends on PCI && DMI
285 help 311 help
286 This option enables support for the Intel SS4200 series of 312 This option enables support for the Intel SS4200 series of
@@ -290,6 +316,7 @@ config LEDS_INTEL_SS4200
290 316
291config LEDS_LT3593 317config LEDS_LT3593
292 tristate "LED driver for LT3593 controllers" 318 tristate "LED driver for LT3593 controllers"
319 depends on LEDS_CLASS
293 depends on GENERIC_GPIO 320 depends on GENERIC_GPIO
294 help 321 help
295 This option enables support for LEDs driven by a Linear Technology 322 This option enables support for LEDs driven by a Linear Technology
@@ -298,6 +325,7 @@ config LEDS_LT3593
298 325
299config LEDS_ADP5520 326config LEDS_ADP5520
300 tristate "LED Support for ADP5520/ADP5501 PMIC" 327 tristate "LED Support for ADP5520/ADP5501 PMIC"
328 depends on LEDS_CLASS
301 depends on PMIC_ADP5520 329 depends on PMIC_ADP5520
302 help 330 help
303 This option enables support for on-chip LED drivers found 331 This option enables support for on-chip LED drivers found
@@ -308,6 +336,7 @@ config LEDS_ADP5520
308 336
309config LEDS_DELL_NETBOOKS 337config LEDS_DELL_NETBOOKS
310 tristate "External LED on Dell Business Netbooks" 338 tristate "External LED on Dell Business Netbooks"
339 depends on LEDS_CLASS
311 depends on X86 && ACPI_WMI 340 depends on X86 && ACPI_WMI
312 help 341 help
313 This adds support for the Latitude 2100 and similar 342 This adds support for the Latitude 2100 and similar
@@ -315,6 +344,7 @@ config LEDS_DELL_NETBOOKS
315 344
316config LEDS_MC13783 345config LEDS_MC13783
317 tristate "LED Support for MC13783 PMIC" 346 tristate "LED Support for MC13783 PMIC"
347 depends on LEDS_CLASS
318 depends on MFD_MC13783 348 depends on MFD_MC13783
319 help 349 help
320 This option enable support for on-chip LED drivers found 350 This option enable support for on-chip LED drivers found
@@ -322,6 +352,7 @@ config LEDS_MC13783
322 352
323config LEDS_NS2 353config LEDS_NS2
324 tristate "LED support for Network Space v2 GPIO LEDs" 354 tristate "LED support for Network Space v2 GPIO LEDs"
355 depends on LEDS_CLASS
325 depends on MACH_NETSPACE_V2 || MACH_INETSPACE_V2 || MACH_NETSPACE_MAX_V2 || D2NET_V2 356 depends on MACH_NETSPACE_V2 || MACH_INETSPACE_V2 || MACH_NETSPACE_MAX_V2 || D2NET_V2
326 default y 357 default y
327 help 358 help
@@ -340,17 +371,17 @@ config LEDS_NETXBIG
340 371
341config LEDS_TRIGGERS 372config LEDS_TRIGGERS
342 bool "LED Trigger support" 373 bool "LED Trigger support"
374 depends on LEDS_CLASS
343 help 375 help
344 This option enables trigger support for the leds class. 376 This option enables trigger support for the leds class.
345 These triggers allow kernel events to drive the LEDs and can 377 These triggers allow kernel events to drive the LEDs and can
346 be configured via sysfs. If unsure, say Y. 378 be configured via sysfs. If unsure, say Y.
347 379
348if LEDS_TRIGGERS
349
350comment "LED Triggers" 380comment "LED Triggers"
351 381
352config LEDS_TRIGGER_TIMER 382config LEDS_TRIGGER_TIMER
353 tristate "LED Timer Trigger" 383 tristate "LED Timer Trigger"
384 depends on LEDS_TRIGGERS
354 help 385 help
355 This allows LEDs to be controlled by a programmable timer 386 This allows LEDs to be controlled by a programmable timer
356 via sysfs. Some LED hardware can be programmed to start 387 via sysfs. Some LED hardware can be programmed to start
@@ -362,12 +393,14 @@ config LEDS_TRIGGER_TIMER
362config LEDS_TRIGGER_IDE_DISK 393config LEDS_TRIGGER_IDE_DISK
363 bool "LED IDE Disk Trigger" 394 bool "LED IDE Disk Trigger"
364 depends on IDE_GD_ATA 395 depends on IDE_GD_ATA
396 depends on LEDS_TRIGGERS
365 help 397 help
366 This allows LEDs to be controlled by IDE disk activity. 398 This allows LEDs to be controlled by IDE disk activity.
367 If unsure, say Y. 399 If unsure, say Y.
368 400
369config LEDS_TRIGGER_HEARTBEAT 401config LEDS_TRIGGER_HEARTBEAT
370 tristate "LED Heartbeat Trigger" 402 tristate "LED Heartbeat Trigger"
403 depends on LEDS_TRIGGERS
371 help 404 help
372 This allows LEDs to be controlled by a CPU load average. 405 This allows LEDs to be controlled by a CPU load average.
373 The flash frequency is a hyperbolic function of the 1-minute 406 The flash frequency is a hyperbolic function of the 1-minute
@@ -376,6 +409,7 @@ config LEDS_TRIGGER_HEARTBEAT
376 409
377config LEDS_TRIGGER_BACKLIGHT 410config LEDS_TRIGGER_BACKLIGHT
378 tristate "LED backlight Trigger" 411 tristate "LED backlight Trigger"
412 depends on LEDS_TRIGGERS
379 help 413 help
380 This allows LEDs to be controlled as a backlight device: they 414 This allows LEDs to be controlled as a backlight device: they
381 turn off and on when the display is blanked and unblanked. 415 turn off and on when the display is blanked and unblanked.
@@ -384,6 +418,7 @@ config LEDS_TRIGGER_BACKLIGHT
384 418
385config LEDS_TRIGGER_GPIO 419config LEDS_TRIGGER_GPIO
386 tristate "LED GPIO Trigger" 420 tristate "LED GPIO Trigger"
421 depends on LEDS_TRIGGERS
387 depends on GPIOLIB 422 depends on GPIOLIB
388 help 423 help
389 This allows LEDs to be controlled by gpio events. It's good 424 This allows LEDs to be controlled by gpio events. It's good
@@ -396,6 +431,7 @@ config LEDS_TRIGGER_GPIO
396 431
397config LEDS_TRIGGER_DEFAULT_ON 432config LEDS_TRIGGER_DEFAULT_ON
398 tristate "LED Default ON Trigger" 433 tristate "LED Default ON Trigger"
434 depends on LEDS_TRIGGERS
399 help 435 help
400 This allows LEDs to be initialised in the ON state. 436 This allows LEDs to be initialised in the ON state.
401 If unsure, say Y. 437 If unsure, say Y.
@@ -403,8 +439,4 @@ config LEDS_TRIGGER_DEFAULT_ON
403comment "iptables trigger is under Netfilter config (LED target)" 439comment "iptables trigger is under Netfilter config (LED target)"
404 depends on LEDS_TRIGGERS 440 depends on LEDS_TRIGGERS
405 441
406endif # LEDS_TRIGGERS
407
408endif # LEDS_CLASS
409
410endif # NEW_LEDS 442endif # NEW_LEDS
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 3782f31f06d2..33facd0c45d1 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -125,11 +125,22 @@ struct lp5521_chip {
125 u8 num_leds; 125 u8 num_leds;
126}; 126};
127 127
128#define cdev_to_led(c) container_of(c, struct lp5521_led, cdev) 128static inline struct lp5521_led *cdev_to_led(struct led_classdev *cdev)
129#define engine_to_lp5521(eng) container_of((eng), struct lp5521_chip, \ 129{
130 engines[(eng)->id - 1]) 130 return container_of(cdev, struct lp5521_led, cdev);
131#define led_to_lp5521(led) container_of((led), struct lp5521_chip, \ 131}
132 leds[(led)->id]) 132
133static inline struct lp5521_chip *engine_to_lp5521(struct lp5521_engine *engine)
134{
135 return container_of(engine, struct lp5521_chip,
136 engines[engine->id - 1]);
137}
138
139static inline struct lp5521_chip *led_to_lp5521(struct lp5521_led *led)
140{
141 return container_of(led, struct lp5521_chip,
142 leds[led->id]);
143}
133 144
134static void lp5521_led_brightness_work(struct work_struct *work); 145static void lp5521_led_brightness_work(struct work_struct *work);
135 146
@@ -185,14 +196,17 @@ static int lp5521_load_program(struct lp5521_engine *eng, const u8 *pattern)
185 196
186 /* move current engine to direct mode and remember the state */ 197 /* move current engine to direct mode and remember the state */
187 ret = lp5521_set_engine_mode(eng, LP5521_CMD_DIRECT); 198 ret = lp5521_set_engine_mode(eng, LP5521_CMD_DIRECT);
188 usleep_range(1000, 10000); 199 /* Mode change requires min 500 us delay. 1 - 2 ms with margin */
200 usleep_range(1000, 2000);
189 ret |= lp5521_read(client, LP5521_REG_OP_MODE, &mode); 201 ret |= lp5521_read(client, LP5521_REG_OP_MODE, &mode);
190 202
191 /* For loading, all the engines to load mode */ 203 /* For loading, all the engines to load mode */
192 lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); 204 lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
193 usleep_range(1000, 10000); 205 /* Mode change requires min 500 us delay. 1 - 2 ms with margin */
206 usleep_range(1000, 2000);
194 lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_LOAD); 207 lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_LOAD);
195 usleep_range(1000, 10000); 208 /* Mode change requires min 500 us delay. 1 - 2 ms with margin */
209 usleep_range(1000, 2000);
196 210
197 addr = LP5521_PROG_MEM_BASE + eng->prog_page * LP5521_PROG_MEM_SIZE; 211 addr = LP5521_PROG_MEM_BASE + eng->prog_page * LP5521_PROG_MEM_SIZE;
198 i2c_smbus_write_i2c_block_data(client, 212 i2c_smbus_write_i2c_block_data(client,
@@ -231,10 +245,6 @@ static int lp5521_configure(struct i2c_client *client,
231 245
232 lp5521_init_engine(chip, attr_group); 246 lp5521_init_engine(chip, attr_group);
233 247
234 lp5521_write(client, LP5521_REG_RESET, 0xff);
235
236 usleep_range(10000, 20000);
237
238 /* Set all PWMs to direct control mode */ 248 /* Set all PWMs to direct control mode */
239 ret = lp5521_write(client, LP5521_REG_OP_MODE, 0x3F); 249 ret = lp5521_write(client, LP5521_REG_OP_MODE, 0x3F);
240 250
@@ -251,8 +261,8 @@ static int lp5521_configure(struct i2c_client *client,
251 ret |= lp5521_write(client, LP5521_REG_ENABLE, 261 ret |= lp5521_write(client, LP5521_REG_ENABLE,
252 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM | 262 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM |
253 LP5521_EXEC_RUN); 263 LP5521_EXEC_RUN);
254 /* enable takes 500us */ 264 /* enable takes 500us. 1 - 2 ms leaves some margin */
255 usleep_range(500, 20000); 265 usleep_range(1000, 2000);
256 266
257 return ret; 267 return ret;
258} 268}
@@ -305,7 +315,8 @@ static int lp5521_detect(struct i2c_client *client)
305 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM); 315 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
306 if (ret) 316 if (ret)
307 return ret; 317 return ret;
308 usleep_range(1000, 10000); 318 /* enable takes 500us. 1 - 2 ms leaves some margin */
319 usleep_range(1000, 2000);
309 ret = lp5521_read(client, LP5521_REG_ENABLE, &buf); 320 ret = lp5521_read(client, LP5521_REG_ENABLE, &buf);
310 if (ret) 321 if (ret)
311 return ret; 322 return ret;
@@ -693,11 +704,16 @@ static int lp5521_probe(struct i2c_client *client,
693 704
694 if (pdata->enable) { 705 if (pdata->enable) {
695 pdata->enable(0); 706 pdata->enable(0);
696 usleep_range(1000, 10000); 707 usleep_range(1000, 2000); /* Keep enable down at least 1ms */
697 pdata->enable(1); 708 pdata->enable(1);
698 usleep_range(1000, 10000); /* Spec says min 500us */ 709 usleep_range(1000, 2000); /* 500us abs min. */
699 } 710 }
700 711
712 lp5521_write(client, LP5521_REG_RESET, 0xff);
713 usleep_range(10000, 20000); /*
714 * Exact value is not available. 10 - 20ms
715 * appears to be enough for reset.
716 */
701 ret = lp5521_detect(client); 717 ret = lp5521_detect(client);
702 718
703 if (ret) { 719 if (ret) {
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 1e11fcc08b28..0cc4ead2fd8b 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -134,15 +134,18 @@ struct lp5523_chip {
134 u8 num_leds; 134 u8 num_leds;
135}; 135};
136 136
137#define cdev_to_led(c) container_of(c, struct lp5523_led, cdev) 137static inline struct lp5523_led *cdev_to_led(struct led_classdev *cdev)
138{
139 return container_of(cdev, struct lp5523_led, cdev);
140}
138 141
139static struct lp5523_chip *engine_to_lp5523(struct lp5523_engine *engine) 142static inline struct lp5523_chip *engine_to_lp5523(struct lp5523_engine *engine)
140{ 143{
141 return container_of(engine, struct lp5523_chip, 144 return container_of(engine, struct lp5523_chip,
142 engines[engine->id - 1]); 145 engines[engine->id - 1]);
143} 146}
144 147
145static struct lp5523_chip *led_to_lp5523(struct lp5523_led *led) 148static inline struct lp5523_chip *led_to_lp5523(struct lp5523_led *led)
146{ 149{
147 return container_of(led, struct lp5523_chip, 150 return container_of(led, struct lp5523_chip,
148 leds[led->id]); 151 leds[led->id]);
@@ -200,13 +203,9 @@ static int lp5523_configure(struct i2c_client *client)
200 { 0x9c, 0x50, 0x9c, 0xd0, 0x9d, 0x80, 0xd8, 0x00, 0}, 203 { 0x9c, 0x50, 0x9c, 0xd0, 0x9d, 0x80, 0xd8, 0x00, 0},
201 }; 204 };
202 205
203 lp5523_write(client, LP5523_REG_RESET, 0xff);
204
205 usleep_range(10000, 100000);
206
207 ret |= lp5523_write(client, LP5523_REG_ENABLE, LP5523_ENABLE); 206 ret |= lp5523_write(client, LP5523_REG_ENABLE, LP5523_ENABLE);
208 /* Chip startup time after reset is 500 us */ 207 /* Chip startup time is 500 us, 1 - 2 ms gives some margin */
209 usleep_range(1000, 10000); 208 usleep_range(1000, 2000);
210 209
211 ret |= lp5523_write(client, LP5523_REG_CONFIG, 210 ret |= lp5523_write(client, LP5523_REG_CONFIG,
212 LP5523_AUTO_INC | LP5523_PWR_SAVE | 211 LP5523_AUTO_INC | LP5523_PWR_SAVE |
@@ -243,8 +242,8 @@ static int lp5523_configure(struct i2c_client *client)
243 return -1; 242 return -1;
244 } 243 }
245 244
246 /* Wait 3ms and check the engine status */ 245 /* Let the programs run for couple of ms and check the engine status */
247 usleep_range(3000, 20000); 246 usleep_range(3000, 6000);
248 lp5523_read(client, LP5523_REG_STATUS, &status); 247 lp5523_read(client, LP5523_REG_STATUS, &status);
249 status &= LP5523_ENG_STATUS_MASK; 248 status &= LP5523_ENG_STATUS_MASK;
250 249
@@ -449,10 +448,10 @@ static ssize_t lp5523_selftest(struct device *dev,
449 /* Measure VDD (i.e. VBAT) first (channel 16 corresponds to VDD) */ 448 /* Measure VDD (i.e. VBAT) first (channel 16 corresponds to VDD) */
450 lp5523_write(chip->client, LP5523_REG_LED_TEST_CTRL, 449 lp5523_write(chip->client, LP5523_REG_LED_TEST_CTRL,
451 LP5523_EN_LEDTEST | 16); 450 LP5523_EN_LEDTEST | 16);
452 usleep_range(3000, 10000); 451 usleep_range(3000, 6000); /* ADC conversion time is typically 2.7 ms */
453 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); 452 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status);
454 if (!(status & LP5523_LEDTEST_DONE)) 453 if (!(status & LP5523_LEDTEST_DONE))
455 usleep_range(3000, 10000); 454 usleep_range(3000, 6000); /* Was not ready. Wait little bit */
456 455
457 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd); 456 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd);
458 vdd--; /* There may be some fluctuation in measurement */ 457 vdd--; /* There may be some fluctuation in measurement */
@@ -468,16 +467,16 @@ static ssize_t lp5523_selftest(struct device *dev,
468 chip->pdata->led_config[i].led_current); 467 chip->pdata->led_config[i].led_current);
469 468
470 lp5523_write(chip->client, LP5523_REG_LED_PWM_BASE + i, 0xff); 469 lp5523_write(chip->client, LP5523_REG_LED_PWM_BASE + i, 0xff);
471 /* let current stabilize 2ms before measurements start */ 470 /* let current stabilize 2 - 4ms before measurements start */
472 usleep_range(2000, 10000); 471 usleep_range(2000, 4000);
473 lp5523_write(chip->client, 472 lp5523_write(chip->client,
474 LP5523_REG_LED_TEST_CTRL, 473 LP5523_REG_LED_TEST_CTRL,
475 LP5523_EN_LEDTEST | i); 474 LP5523_EN_LEDTEST | i);
476 /* ledtest takes 2.7ms */ 475 /* ADC conversion time is 2.7 ms typically */
477 usleep_range(3000, 10000); 476 usleep_range(3000, 6000);
478 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); 477 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status);
479 if (!(status & LP5523_LEDTEST_DONE)) 478 if (!(status & LP5523_LEDTEST_DONE))
480 usleep_range(3000, 10000); 479 usleep_range(3000, 6000);/* Was not ready. Wait. */
481 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc); 480 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc);
482 481
483 if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM) 482 if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM)
@@ -930,11 +929,16 @@ static int lp5523_probe(struct i2c_client *client,
930 929
931 if (pdata->enable) { 930 if (pdata->enable) {
932 pdata->enable(0); 931 pdata->enable(0);
933 usleep_range(1000, 10000); 932 usleep_range(1000, 2000); /* Keep enable down at least 1ms */
934 pdata->enable(1); 933 pdata->enable(1);
935 usleep_range(1000, 10000); /* Spec says min 500us */ 934 usleep_range(1000, 2000); /* 500us abs min. */
936 } 935 }
937 936
937 lp5523_write(client, LP5523_REG_RESET, 0xff);
938 usleep_range(10000, 20000); /*
939 * Exact value is not available. 10 - 20ms
940 * appears to be enough for reset.
941 */
938 ret = lp5523_detect(client); 942 ret = lp5523_detect(client);
939 if (ret) 943 if (ret)
940 goto fail2; 944 goto fail2;
diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
index a688293abd0b..614ebebaaa28 100644
--- a/drivers/leds/leds-ss4200.c
+++ b/drivers/leds/leds-ss4200.c
@@ -102,6 +102,7 @@ static struct dmi_system_id __initdata nas_led_whitelist[] = {
102 DMI_MATCH(DMI_PRODUCT_VERSION, "1.00.00") 102 DMI_MATCH(DMI_PRODUCT_VERSION, "1.00.00")
103 } 103 }
104 }, 104 },
105 {}
105}; 106};
106 107
107/* 108/*
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 3d7355ff7308..fa51af11c6f1 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -102,6 +102,7 @@ config ADB_PMU_LED
102config ADB_PMU_LED_IDE 102config ADB_PMU_LED_IDE
103 bool "Use front LED as IDE LED by default" 103 bool "Use front LED as IDE LED by default"
104 depends on ADB_PMU_LED 104 depends on ADB_PMU_LED
105 depends on LEDS_CLASS
105 select LEDS_TRIGGERS 106 select LEDS_TRIGGERS
106 select LEDS_TRIGGER_IDE_DISK 107 select LEDS_TRIGGER_IDE_DISK
107 help 108 help
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 90267f8d64ee..4d705cea0f8c 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -517,9 +517,8 @@ int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
517 */ 517 */
518 518
519 if (q->merge_bvec_fn && !ti->type->merge) 519 if (q->merge_bvec_fn && !ti->type->merge)
520 limits->max_sectors = 520 blk_limits_max_hw_sectors(limits,
521 min_not_zero(limits->max_sectors, 521 (unsigned int) (PAGE_SIZE >> 9));
522 (unsigned int) (PAGE_SIZE >> 9));
523 return 0; 522 return 0;
524} 523}
525EXPORT_SYMBOL_GPL(dm_set_device_limits); 524EXPORT_SYMBOL_GPL(dm_set_device_limits);
@@ -1131,11 +1130,6 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
1131 */ 1130 */
1132 q->limits = *limits; 1131 q->limits = *limits;
1133 1132
1134 if (limits->no_cluster)
1135 queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q);
1136 else
1137 queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, q);
1138
1139 if (!dm_table_supports_discards(t)) 1133 if (!dm_table_supports_discards(t))
1140 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); 1134 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q);
1141 else 1135 else
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 324a3663fcda..175c424f201f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -371,10 +371,15 @@ static void md_end_flush(struct bio *bio, int err)
371 bio_put(bio); 371 bio_put(bio);
372} 372}
373 373
374static void submit_flushes(mddev_t *mddev) 374static void md_submit_flush_data(struct work_struct *ws);
375
376static void submit_flushes(struct work_struct *ws)
375{ 377{
378 mddev_t *mddev = container_of(ws, mddev_t, flush_work);
376 mdk_rdev_t *rdev; 379 mdk_rdev_t *rdev;
377 380
381 INIT_WORK(&mddev->flush_work, md_submit_flush_data);
382 atomic_set(&mddev->flush_pending, 1);
378 rcu_read_lock(); 383 rcu_read_lock();
379 list_for_each_entry_rcu(rdev, &mddev->disks, same_set) 384 list_for_each_entry_rcu(rdev, &mddev->disks, same_set)
380 if (rdev->raid_disk >= 0 && 385 if (rdev->raid_disk >= 0 &&
@@ -397,6 +402,8 @@ static void submit_flushes(mddev_t *mddev)
397 rdev_dec_pending(rdev, mddev); 402 rdev_dec_pending(rdev, mddev);
398 } 403 }
399 rcu_read_unlock(); 404 rcu_read_unlock();
405 if (atomic_dec_and_test(&mddev->flush_pending))
406 queue_work(md_wq, &mddev->flush_work);
400} 407}
401 408
402static void md_submit_flush_data(struct work_struct *ws) 409static void md_submit_flush_data(struct work_struct *ws)
@@ -404,8 +411,6 @@ static void md_submit_flush_data(struct work_struct *ws)
404 mddev_t *mddev = container_of(ws, mddev_t, flush_work); 411 mddev_t *mddev = container_of(ws, mddev_t, flush_work);
405 struct bio *bio = mddev->flush_bio; 412 struct bio *bio = mddev->flush_bio;
406 413
407 atomic_set(&mddev->flush_pending, 1);
408
409 if (bio->bi_size == 0) 414 if (bio->bi_size == 0)
410 /* an empty barrier - all done */ 415 /* an empty barrier - all done */
411 bio_endio(bio, 0); 416 bio_endio(bio, 0);
@@ -414,10 +419,9 @@ static void md_submit_flush_data(struct work_struct *ws)
414 if (mddev->pers->make_request(mddev, bio)) 419 if (mddev->pers->make_request(mddev, bio))
415 generic_make_request(bio); 420 generic_make_request(bio);
416 } 421 }
417 if (atomic_dec_and_test(&mddev->flush_pending)) { 422
418 mddev->flush_bio = NULL; 423 mddev->flush_bio = NULL;
419 wake_up(&mddev->sb_wait); 424 wake_up(&mddev->sb_wait);
420 }
421} 425}
422 426
423void md_flush_request(mddev_t *mddev, struct bio *bio) 427void md_flush_request(mddev_t *mddev, struct bio *bio)
@@ -429,13 +433,8 @@ void md_flush_request(mddev_t *mddev, struct bio *bio)
429 mddev->flush_bio = bio; 433 mddev->flush_bio = bio;
430 spin_unlock_irq(&mddev->write_lock); 434 spin_unlock_irq(&mddev->write_lock);
431 435
432 atomic_set(&mddev->flush_pending, 1); 436 INIT_WORK(&mddev->flush_work, submit_flushes);
433 INIT_WORK(&mddev->flush_work, md_submit_flush_data); 437 queue_work(md_wq, &mddev->flush_work);
434
435 submit_flushes(mddev);
436
437 if (atomic_dec_and_test(&mddev->flush_pending))
438 queue_work(md_wq, &mddev->flush_work);
439} 438}
440EXPORT_SYMBOL(md_flush_request); 439EXPORT_SYMBOL(md_flush_request);
441 440
@@ -1337,7 +1336,7 @@ super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
1337 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, 1336 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
1338 rdev->sb_page); 1337 rdev->sb_page);
1339 md_super_wait(rdev->mddev); 1338 md_super_wait(rdev->mddev);
1340 return num_sectors / 2; /* kB for sysfs */ 1339 return num_sectors;
1341} 1340}
1342 1341
1343 1342
@@ -1704,7 +1703,7 @@ super_1_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
1704 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size, 1703 md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
1705 rdev->sb_page); 1704 rdev->sb_page);
1706 md_super_wait(rdev->mddev); 1705 md_super_wait(rdev->mddev);
1707 return num_sectors / 2; /* kB for sysfs */ 1706 return num_sectors;
1708} 1707}
1709 1708
1710static struct super_type super_types[] = { 1709static struct super_type super_types[] = {
@@ -4296,9 +4295,6 @@ static int md_alloc(dev_t dev, char *name)
4296 goto abort; 4295 goto abort;
4297 mddev->queue->queuedata = mddev; 4296 mddev->queue->queuedata = mddev;
4298 4297
4299 /* Can be unlocked because the queue is new: no concurrency */
4300 queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, mddev->queue);
4301
4302 blk_queue_make_request(mddev->queue, md_make_request); 4298 blk_queue_make_request(mddev->queue, md_make_request);
4303 4299
4304 disk = alloc_disk(1 << shift); 4300 disk = alloc_disk(1 << shift);
@@ -4338,6 +4334,8 @@ static int md_alloc(dev_t dev, char *name)
4338 if (mddev->kobj.sd && 4334 if (mddev->kobj.sd &&
4339 sysfs_create_group(&mddev->kobj, &md_bitmap_group)) 4335 sysfs_create_group(&mddev->kobj, &md_bitmap_group))
4340 printk(KERN_DEBUG "pointless warning\n"); 4336 printk(KERN_DEBUG "pointless warning\n");
4337
4338 blk_queue_flush(mddev->queue, REQ_FLUSH | REQ_FUA);
4341 abort: 4339 abort:
4342 mutex_unlock(&disks_mutex); 4340 mutex_unlock(&disks_mutex);
4343 if (!error && mddev->kobj.sd) { 4341 if (!error && mddev->kobj.sd) {
@@ -5158,7 +5156,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
5158 PTR_ERR(rdev)); 5156 PTR_ERR(rdev));
5159 return PTR_ERR(rdev); 5157 return PTR_ERR(rdev);
5160 } 5158 }
5161 /* set save_raid_disk if appropriate */ 5159 /* set saved_raid_disk if appropriate */
5162 if (!mddev->persistent) { 5160 if (!mddev->persistent) {
5163 if (info->state & (1<<MD_DISK_SYNC) && 5161 if (info->state & (1<<MD_DISK_SYNC) &&
5164 info->raid_disk < mddev->raid_disks) 5162 info->raid_disk < mddev->raid_disks)
@@ -5168,7 +5166,10 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
5168 } else 5166 } else
5169 super_types[mddev->major_version]. 5167 super_types[mddev->major_version].
5170 validate_super(mddev, rdev); 5168 validate_super(mddev, rdev);
5171 rdev->saved_raid_disk = rdev->raid_disk; 5169 if (test_bit(In_sync, &rdev->flags))
5170 rdev->saved_raid_disk = rdev->raid_disk;
5171 else
5172 rdev->saved_raid_disk = -1;
5172 5173
5173 clear_bit(In_sync, &rdev->flags); /* just to be sure */ 5174 clear_bit(In_sync, &rdev->flags); /* just to be sure */
5174 if (info->state & (1<<MD_DISK_WRITEMOSTLY)) 5175 if (info->state & (1<<MD_DISK_WRITEMOSTLY))
@@ -6040,9 +6041,8 @@ static int md_thread(void * arg)
6040 || kthread_should_stop(), 6041 || kthread_should_stop(),
6041 thread->timeout); 6042 thread->timeout);
6042 6043
6043 clear_bit(THREAD_WAKEUP, &thread->flags); 6044 if (test_and_clear_bit(THREAD_WAKEUP, &thread->flags))
6044 6045 thread->run(thread->mddev);
6045 thread->run(thread->mddev);
6046 } 6046 }
6047 6047
6048 return 0; 6048 return 0;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 45f8324196ec..845cf95b612c 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1161,6 +1161,7 @@ static int raid1_remove_disk(mddev_t *mddev, int number)
1161 * is not possible. 1161 * is not possible.
1162 */ 1162 */
1163 if (!test_bit(Faulty, &rdev->flags) && 1163 if (!test_bit(Faulty, &rdev->flags) &&
1164 !mddev->recovery_disabled &&
1164 mddev->degraded < conf->raid_disks) { 1165 mddev->degraded < conf->raid_disks) {
1165 err = -EBUSY; 1166 err = -EBUSY;
1166 goto abort; 1167 goto abort;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index c67aa54694ae..0641674827f0 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2397,13 +2397,13 @@ static int run(mddev_t *mddev)
2397 return 0; 2397 return 0;
2398 2398
2399out_free_conf: 2399out_free_conf:
2400 md_unregister_thread(mddev->thread);
2400 if (conf->r10bio_pool) 2401 if (conf->r10bio_pool)
2401 mempool_destroy(conf->r10bio_pool); 2402 mempool_destroy(conf->r10bio_pool);
2402 safe_put_page(conf->tmppage); 2403 safe_put_page(conf->tmppage);
2403 kfree(conf->mirrors); 2404 kfree(conf->mirrors);
2404 kfree(conf); 2405 kfree(conf);
2405 mddev->private = NULL; 2406 mddev->private = NULL;
2406 md_unregister_thread(mddev->thread);
2407out: 2407out:
2408 return -EIO; 2408 return -EIO;
2409} 2409}
diff --git a/drivers/media/common/saa7146_hlp.c b/drivers/media/common/saa7146_hlp.c
index 05bde9ccb770..1d1d8d200755 100644
--- a/drivers/media/common/saa7146_hlp.c
+++ b/drivers/media/common/saa7146_hlp.c
@@ -558,7 +558,7 @@ static void saa7146_set_window(struct saa7146_dev *dev, int width, int height, e
558static void saa7146_set_position(struct saa7146_dev *dev, int w_x, int w_y, int w_height, enum v4l2_field field, u32 pixelformat) 558static void saa7146_set_position(struct saa7146_dev *dev, int w_x, int w_y, int w_height, enum v4l2_field field, u32 pixelformat)
559{ 559{
560 struct saa7146_vv *vv = dev->vv_data; 560 struct saa7146_vv *vv = dev->vv_data;
561 struct saa7146_format *sfmt = format_by_fourcc(dev, pixelformat); 561 struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev, pixelformat);
562 562
563 int b_depth = vv->ov_fmt->depth; 563 int b_depth = vv->ov_fmt->depth;
564 int b_bpl = vv->ov_fb.fmt.bytesperline; 564 int b_bpl = vv->ov_fb.fmt.bytesperline;
@@ -702,7 +702,7 @@ static int calculate_video_dma_grab_packed(struct saa7146_dev* dev, struct saa71
702 struct saa7146_vv *vv = dev->vv_data; 702 struct saa7146_vv *vv = dev->vv_data;
703 struct saa7146_video_dma vdma1; 703 struct saa7146_video_dma vdma1;
704 704
705 struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat); 705 struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);
706 706
707 int width = buf->fmt->width; 707 int width = buf->fmt->width;
708 int height = buf->fmt->height; 708 int height = buf->fmt->height;
@@ -827,7 +827,7 @@ static int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa71
827 struct saa7146_video_dma vdma2; 827 struct saa7146_video_dma vdma2;
828 struct saa7146_video_dma vdma3; 828 struct saa7146_video_dma vdma3;
829 829
830 struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat); 830 struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);
831 831
832 int width = buf->fmt->width; 832 int width = buf->fmt->width;
833 int height = buf->fmt->height; 833 int height = buf->fmt->height;
@@ -994,7 +994,7 @@ static void program_capture_engine(struct saa7146_dev *dev, int planar)
994 994
995void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next) 995void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next)
996{ 996{
997 struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat); 997 struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);
998 struct saa7146_vv *vv = dev->vv_data; 998 struct saa7146_vv *vv = dev->vv_data;
999 u32 vdma1_prot_addr; 999 u32 vdma1_prot_addr;
1000 1000
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 741c5732b430..d246910129e8 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -84,7 +84,7 @@ static struct saa7146_format formats[] = {
84 84
85static int NUM_FORMATS = sizeof(formats)/sizeof(struct saa7146_format); 85static int NUM_FORMATS = sizeof(formats)/sizeof(struct saa7146_format);
86 86
87struct saa7146_format* format_by_fourcc(struct saa7146_dev *dev, int fourcc) 87struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fourcc)
88{ 88{
89 int i, j = NUM_FORMATS; 89 int i, j = NUM_FORMATS;
90 90
@@ -266,7 +266,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
266 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); 266 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
267 struct scatterlist *list = dma->sglist; 267 struct scatterlist *list = dma->sglist;
268 int length = dma->sglen; 268 int length = dma->sglen;
269 struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat); 269 struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);
270 270
271 DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length)); 271 DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length));
272 272
@@ -408,7 +408,7 @@ static int video_begin(struct saa7146_fh *fh)
408 } 408 }
409 } 409 }
410 410
411 fmt = format_by_fourcc(dev,fh->video_fmt.pixelformat); 411 fmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat);
412 /* we need to have a valid format set here */ 412 /* we need to have a valid format set here */
413 BUG_ON(NULL == fmt); 413 BUG_ON(NULL == fmt);
414 414
@@ -460,7 +460,7 @@ static int video_end(struct saa7146_fh *fh, struct file *file)
460 return -EBUSY; 460 return -EBUSY;
461 } 461 }
462 462
463 fmt = format_by_fourcc(dev,fh->video_fmt.pixelformat); 463 fmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat);
464 /* we need to have a valid format set here */ 464 /* we need to have a valid format set here */
465 BUG_ON(NULL == fmt); 465 BUG_ON(NULL == fmt);
466 466
@@ -536,7 +536,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
536 return -EPERM; 536 return -EPERM;
537 537
538 /* check args */ 538 /* check args */
539 fmt = format_by_fourcc(dev, fb->fmt.pixelformat); 539 fmt = saa7146_format_by_fourcc(dev, fb->fmt.pixelformat);
540 if (NULL == fmt) 540 if (NULL == fmt)
541 return -EINVAL; 541 return -EINVAL;
542 542
@@ -760,7 +760,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma
760 760
761 DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh)); 761 DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh));
762 762
763 fmt = format_by_fourcc(dev, f->fmt.pix.pixelformat); 763 fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat);
764 if (NULL == fmt) 764 if (NULL == fmt)
765 return -EINVAL; 765 return -EINVAL;
766 766
@@ -1264,7 +1264,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1264 buf->fmt = &fh->video_fmt; 1264 buf->fmt = &fh->video_fmt;
1265 buf->vb.field = fh->video_fmt.field; 1265 buf->vb.field = fh->video_fmt.field;
1266 1266
1267 sfmt = format_by_fourcc(dev,buf->fmt->pixelformat); 1267 sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);
1268 1268
1269 release_all_pagetables(dev, buf); 1269 release_all_pagetables(dev, buf);
1270 if( 0 != IS_PLANAR(sfmt->trans)) { 1270 if( 0 != IS_PLANAR(sfmt->trans)) {
@@ -1378,7 +1378,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
1378 fh->video_fmt.pixelformat = V4L2_PIX_FMT_BGR24; 1378 fh->video_fmt.pixelformat = V4L2_PIX_FMT_BGR24;
1379 fh->video_fmt.bytesperline = 0; 1379 fh->video_fmt.bytesperline = 0;
1380 fh->video_fmt.field = V4L2_FIELD_ANY; 1380 fh->video_fmt.field = V4L2_FIELD_ANY;
1381 sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat); 1381 sfmt = saa7146_format_by_fourcc(dev,fh->video_fmt.pixelformat);
1382 fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8; 1382 fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8;
1383 1383
1384 videobuf_queue_sg_init(&fh->video_q, &video_qops, 1384 videobuf_queue_sg_init(&fh->video_q, &video_qops,
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig
index 2385e6cca635..78b089526e02 100644
--- a/drivers/media/common/tuners/Kconfig
+++ b/drivers/media/common/tuners/Kconfig
@@ -31,7 +31,7 @@ config MEDIA_TUNER
31 select MEDIA_TUNER_TDA9887 if !MEDIA_TUNER_CUSTOMISE 31 select MEDIA_TUNER_TDA9887 if !MEDIA_TUNER_CUSTOMISE
32 select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE 32 select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE
33 33
34menuconfig MEDIA_TUNER_CUSTOMISE 34config MEDIA_TUNER_CUSTOMISE
35 bool "Customize analog and hybrid tuner modules to build" 35 bool "Customize analog and hybrid tuner modules to build"
36 depends on MEDIA_TUNER 36 depends on MEDIA_TUNER
37 default y if EMBEDDED 37 default y if EMBEDDED
@@ -44,7 +44,8 @@ menuconfig MEDIA_TUNER_CUSTOMISE
44 44
45 If unsure say N. 45 If unsure say N.
46 46
47if MEDIA_TUNER_CUSTOMISE 47menu "Customize TV tuners"
48 visible if MEDIA_TUNER_CUSTOMISE
48 49
49config MEDIA_TUNER_SIMPLE 50config MEDIA_TUNER_SIMPLE
50 tristate "Simple tuner support" 51 tristate "Simple tuner support"
@@ -185,5 +186,4 @@ config MEDIA_TUNER_TDA18218
185 default m if MEDIA_TUNER_CUSTOMISE 186 default m if MEDIA_TUNER_CUSTOMISE
186 help 187 help
187 NXP TDA18218 silicon tuner driver. 188 NXP TDA18218 silicon tuner driver.
188 189endmenu
189endif # MEDIA_TUNER_CUSTOMISE
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 4d0646da6087..7ea517b7e186 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -36,7 +36,6 @@
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/smp_lock.h>
40#include <linux/kthread.h> 39#include <linux/kthread.h>
41 40
42#include "dvb_ca_en50221.h" 41#include "dvb_ca_en50221.h"
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 1589d5a5cb46..cad6634610ea 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -36,7 +36,6 @@
36#include <linux/list.h> 36#include <linux/list.h>
37#include <linux/freezer.h> 37#include <linux/freezer.h>
38#include <linux/jiffies.h> 38#include <linux/jiffies.h>
39#include <linux/smp_lock.h>
40#include <linux/kthread.h> 39#include <linux/kthread.h>
41#include <asm/processor.h> 40#include <asm/processor.h>
42 41
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index e9062b08a485..96b27016670e 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -12,9 +12,8 @@ config DVB_FE_CUSTOMISE
12 12
13 If unsure say N. 13 If unsure say N.
14 14
15if DVB_FE_CUSTOMISE
16
17menu "Customise DVB Frontends" 15menu "Customise DVB Frontends"
16 visible if DVB_FE_CUSTOMISE
18 17
19comment "Multistandard (satellite) frontends" 18comment "Multistandard (satellite) frontends"
20 depends on DVB_CORE 19 depends on DVB_CORE
@@ -619,5 +618,3 @@ config DVB_DUMMY_FE
619 tristate "Dummy frontend driver" 618 tristate "Dummy frontend driver"
620 default n 619 default n
621endmenu 620endmenu
622
623endif
diff --git a/drivers/media/dvb/ngene/ngene-core.c b/drivers/media/dvb/ngene/ngene-core.c
index 4caeb163a666..3a7ef71087be 100644
--- a/drivers/media/dvb/ngene/ngene-core.c
+++ b/drivers/media/dvb/ngene/ngene-core.c
@@ -34,7 +34,6 @@
34#include <linux/io.h> 34#include <linux/io.h>
35#include <asm/div64.h> 35#include <asm/div64.h>
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/smp_lock.h>
38#include <linux/timer.h> 37#include <linux/timer.h>
39#include <linux/byteorder/generic.h> 38#include <linux/byteorder/generic.h>
40#include <linux/firmware.h> 39#include <linux/firmware.h>
diff --git a/drivers/media/dvb/ngene/ngene-dvb.c b/drivers/media/dvb/ngene/ngene-dvb.c
index 48f980b21d66..3832e5983c19 100644
--- a/drivers/media/dvb/ngene/ngene-dvb.c
+++ b/drivers/media/dvb/ngene/ngene-dvb.c
@@ -35,7 +35,6 @@
35#include <linux/io.h> 35#include <linux/io.h>
36#include <asm/div64.h> 36#include <asm/div64.h>
37#include <linux/pci.h> 37#include <linux/pci.h>
38#include <linux/smp_lock.h>
39#include <linux/timer.h> 38#include <linux/timer.h>
40#include <linux/byteorder/generic.h> 39#include <linux/byteorder/generic.h>
41#include <linux/firmware.h> 40#include <linux/firmware.h>
diff --git a/drivers/media/dvb/ngene/ngene-i2c.c b/drivers/media/dvb/ngene/ngene-i2c.c
index c3ae956714e7..d28554f8ce99 100644
--- a/drivers/media/dvb/ngene/ngene-i2c.c
+++ b/drivers/media/dvb/ngene/ngene-i2c.c
@@ -37,7 +37,6 @@
37#include <asm/div64.h> 37#include <asm/div64.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/pci_ids.h> 39#include <linux/pci_ids.h>
40#include <linux/smp_lock.h>
41#include <linux/timer.h> 40#include <linux/timer.h>
42#include <linux/byteorder/generic.h> 41#include <linux/byteorder/generic.h>
43#include <linux/firmware.h> 42#include <linux/firmware.h>
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 5bf4985daede..05e832f61c3e 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -361,7 +361,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
361 361
362static const struct v4l2_file_operations rtrack_fops = { 362static const struct v4l2_file_operations rtrack_fops = {
363 .owner = THIS_MODULE, 363 .owner = THIS_MODULE,
364 .ioctl = video_ioctl2, 364 .unlocked_ioctl = video_ioctl2,
365}; 365};
366 366
367static const struct v4l2_ioctl_ops rtrack_ioctl_ops = { 367static const struct v4l2_ioctl_ops rtrack_ioctl_ops = {
@@ -412,13 +412,6 @@ static int __init rtrack_init(void)
412 rt->vdev.release = video_device_release_empty; 412 rt->vdev.release = video_device_release_empty;
413 video_set_drvdata(&rt->vdev, rt); 413 video_set_drvdata(&rt->vdev, rt);
414 414
415 if (video_register_device(&rt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
416 v4l2_device_unregister(&rt->v4l2_dev);
417 release_region(rt->io, 2);
418 return -EINVAL;
419 }
420 v4l2_info(v4l2_dev, "AIMSlab RadioTrack/RadioReveal card driver.\n");
421
422 /* Set up the I/O locking */ 415 /* Set up the I/O locking */
423 416
424 mutex_init(&rt->lock); 417 mutex_init(&rt->lock);
@@ -430,6 +423,13 @@ static int __init rtrack_init(void)
430 sleep_delay(2000000); /* make sure it's totally down */ 423 sleep_delay(2000000); /* make sure it's totally down */
431 outb(0xc0, rt->io); /* steady volume, mute card */ 424 outb(0xc0, rt->io); /* steady volume, mute card */
432 425
426 if (video_register_device(&rt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
427 v4l2_device_unregister(&rt->v4l2_dev);
428 release_region(rt->io, 2);
429 return -EINVAL;
430 }
431 v4l2_info(v4l2_dev, "AIMSlab RadioTrack/RadioReveal card driver.\n");
432
433 return 0; 433 return 0;
434} 434}
435 435
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index c22311393624..dd8a6ab0d437 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -324,7 +324,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
324 324
325static const struct v4l2_file_operations aztech_fops = { 325static const struct v4l2_file_operations aztech_fops = {
326 .owner = THIS_MODULE, 326 .owner = THIS_MODULE,
327 .ioctl = video_ioctl2, 327 .unlocked_ioctl = video_ioctl2,
328}; 328};
329 329
330static const struct v4l2_ioctl_ops aztech_ioctl_ops = { 330static const struct v4l2_ioctl_ops aztech_ioctl_ops = {
@@ -375,6 +375,8 @@ static int __init aztech_init(void)
375 az->vdev.ioctl_ops = &aztech_ioctl_ops; 375 az->vdev.ioctl_ops = &aztech_ioctl_ops;
376 az->vdev.release = video_device_release_empty; 376 az->vdev.release = video_device_release_empty;
377 video_set_drvdata(&az->vdev, az); 377 video_set_drvdata(&az->vdev, az);
378 /* mute card - prevents noisy bootups */
379 outb(0, az->io);
378 380
379 if (video_register_device(&az->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 381 if (video_register_device(&az->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
380 v4l2_device_unregister(v4l2_dev); 382 v4l2_device_unregister(v4l2_dev);
@@ -383,8 +385,6 @@ static int __init aztech_init(void)
383 } 385 }
384 386
385 v4l2_info(v4l2_dev, "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n"); 387 v4l2_info(v4l2_dev, "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n");
386 /* mute card - prevents noisy bootups */
387 outb(0, az->io);
388 return 0; 388 return 0;
389} 389}
390 390
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index b701ea6e7c73..bc9ad0897c55 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -328,11 +328,10 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
328 unsigned char readbuf[RDS_BUFFER]; 328 unsigned char readbuf[RDS_BUFFER];
329 int i = 0; 329 int i = 0;
330 330
331 mutex_lock(&dev->lock);
331 if (dev->rdsstat == 0) { 332 if (dev->rdsstat == 0) {
332 mutex_lock(&dev->lock);
333 dev->rdsstat = 1; 333 dev->rdsstat = 1;
334 outb(0x80, dev->io); /* Select RDS fifo */ 334 outb(0x80, dev->io); /* Select RDS fifo */
335 mutex_unlock(&dev->lock);
336 init_timer(&dev->readtimer); 335 init_timer(&dev->readtimer);
337 dev->readtimer.function = cadet_handler; 336 dev->readtimer.function = cadet_handler;
338 dev->readtimer.data = (unsigned long)dev; 337 dev->readtimer.data = (unsigned long)dev;
@@ -340,12 +339,15 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
340 add_timer(&dev->readtimer); 339 add_timer(&dev->readtimer);
341 } 340 }
342 if (dev->rdsin == dev->rdsout) { 341 if (dev->rdsin == dev->rdsout) {
342 mutex_unlock(&dev->lock);
343 if (file->f_flags & O_NONBLOCK) 343 if (file->f_flags & O_NONBLOCK)
344 return -EWOULDBLOCK; 344 return -EWOULDBLOCK;
345 interruptible_sleep_on(&dev->read_queue); 345 interruptible_sleep_on(&dev->read_queue);
346 mutex_lock(&dev->lock);
346 } 347 }
347 while (i < count && dev->rdsin != dev->rdsout) 348 while (i < count && dev->rdsin != dev->rdsout)
348 readbuf[i++] = dev->rdsbuf[dev->rdsout++]; 349 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
350 mutex_unlock(&dev->lock);
349 351
350 if (copy_to_user(data, readbuf, i)) 352 if (copy_to_user(data, readbuf, i))
351 return -EFAULT; 353 return -EFAULT;
@@ -525,9 +527,11 @@ static int cadet_open(struct file *file)
525{ 527{
526 struct cadet *dev = video_drvdata(file); 528 struct cadet *dev = video_drvdata(file);
527 529
530 mutex_lock(&dev->lock);
528 dev->users++; 531 dev->users++;
529 if (1 == dev->users) 532 if (1 == dev->users)
530 init_waitqueue_head(&dev->read_queue); 533 init_waitqueue_head(&dev->read_queue);
534 mutex_unlock(&dev->lock);
531 return 0; 535 return 0;
532} 536}
533 537
@@ -535,11 +539,13 @@ static int cadet_release(struct file *file)
535{ 539{
536 struct cadet *dev = video_drvdata(file); 540 struct cadet *dev = video_drvdata(file);
537 541
542 mutex_lock(&dev->lock);
538 dev->users--; 543 dev->users--;
539 if (0 == dev->users) { 544 if (0 == dev->users) {
540 del_timer_sync(&dev->readtimer); 545 del_timer_sync(&dev->readtimer);
541 dev->rdsstat = 0; 546 dev->rdsstat = 0;
542 } 547 }
548 mutex_unlock(&dev->lock);
543 return 0; 549 return 0;
544} 550}
545 551
@@ -559,7 +565,7 @@ static const struct v4l2_file_operations cadet_fops = {
559 .open = cadet_open, 565 .open = cadet_open,
560 .release = cadet_release, 566 .release = cadet_release,
561 .read = cadet_read, 567 .read = cadet_read,
562 .ioctl = video_ioctl2, 568 .unlocked_ioctl = video_ioctl2,
563 .poll = cadet_poll, 569 .poll = cadet_poll,
564}; 570};
565 571
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 79039674a0e0..28fa85ba2087 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -361,7 +361,7 @@ MODULE_DEVICE_TABLE(pci, gemtek_pci_id);
361 361
362static const struct v4l2_file_operations gemtek_pci_fops = { 362static const struct v4l2_file_operations gemtek_pci_fops = {
363 .owner = THIS_MODULE, 363 .owner = THIS_MODULE,
364 .ioctl = video_ioctl2, 364 .unlocked_ioctl = video_ioctl2,
365}; 365};
366 366
367static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = { 367static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
@@ -422,11 +422,11 @@ static int __devinit gemtek_pci_probe(struct pci_dev *pdev, const struct pci_dev
422 card->vdev.release = video_device_release_empty; 422 card->vdev.release = video_device_release_empty;
423 video_set_drvdata(&card->vdev, card); 423 video_set_drvdata(&card->vdev, card);
424 424
425 gemtek_pci_mute(card);
426
425 if (video_register_device(&card->vdev, VFL_TYPE_RADIO, nr_radio) < 0) 427 if (video_register_device(&card->vdev, VFL_TYPE_RADIO, nr_radio) < 0)
426 goto err_video; 428 goto err_video;
427 429
428 gemtek_pci_mute(card);
429
430 v4l2_info(v4l2_dev, "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n", 430 v4l2_info(v4l2_dev, "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n",
431 pdev->revision, card->iobase, card->iobase + card->length - 1); 431 pdev->revision, card->iobase, card->iobase + card->length - 1);
432 432
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 73985f641f07..259936422e49 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -378,7 +378,7 @@ static int gemtek_probe(struct gemtek *gt)
378 378
379static const struct v4l2_file_operations gemtek_fops = { 379static const struct v4l2_file_operations gemtek_fops = {
380 .owner = THIS_MODULE, 380 .owner = THIS_MODULE,
381 .ioctl = video_ioctl2, 381 .unlocked_ioctl = video_ioctl2,
382}; 382};
383 383
384static int vidioc_querycap(struct file *file, void *priv, 384static int vidioc_querycap(struct file *file, void *priv,
@@ -577,12 +577,6 @@ static int __init gemtek_init(void)
577 gt->vdev.release = video_device_release_empty; 577 gt->vdev.release = video_device_release_empty;
578 video_set_drvdata(&gt->vdev, gt); 578 video_set_drvdata(&gt->vdev, gt);
579 579
580 if (video_register_device(&gt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
581 v4l2_device_unregister(v4l2_dev);
582 release_region(gt->io, 1);
583 return -EBUSY;
584 }
585
586 /* Set defaults */ 580 /* Set defaults */
587 gt->lastfreq = GEMTEK_LOWFREQ; 581 gt->lastfreq = GEMTEK_LOWFREQ;
588 gt->bu2614data = 0; 582 gt->bu2614data = 0;
@@ -590,6 +584,12 @@ static int __init gemtek_init(void)
590 if (initmute) 584 if (initmute)
591 gemtek_mute(gt); 585 gemtek_mute(gt);
592 586
587 if (video_register_device(&gt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
588 v4l2_device_unregister(v4l2_dev);
589 release_region(gt->io, 1);
590 return -EBUSY;
591 }
592
593 return 0; 593 return 0;
594} 594}
595 595
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 08f1051979ca..6af61bfeb178 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -299,7 +299,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
299 299
300static const struct v4l2_file_operations maestro_fops = { 300static const struct v4l2_file_operations maestro_fops = {
301 .owner = THIS_MODULE, 301 .owner = THIS_MODULE,
302 .ioctl = video_ioctl2, 302 .unlocked_ioctl = video_ioctl2,
303}; 303};
304 304
305static const struct v4l2_ioctl_ops maestro_ioctl_ops = { 305static const struct v4l2_ioctl_ops maestro_ioctl_ops = {
@@ -383,22 +383,20 @@ static int __devinit maestro_probe(struct pci_dev *pdev,
383 dev->vdev.release = video_device_release_empty; 383 dev->vdev.release = video_device_release_empty;
384 video_set_drvdata(&dev->vdev, dev); 384 video_set_drvdata(&dev->vdev, dev);
385 385
386 if (!radio_power_on(dev)) {
387 retval = -EIO;
388 goto errfr1;
389 }
390
386 retval = video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr); 391 retval = video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr);
387 if (retval) { 392 if (retval) {
388 v4l2_err(v4l2_dev, "can't register video device!\n"); 393 v4l2_err(v4l2_dev, "can't register video device!\n");
389 goto errfr1; 394 goto errfr1;
390 } 395 }
391 396
392 if (!radio_power_on(dev)) {
393 retval = -EIO;
394 goto errunr;
395 }
396
397 v4l2_info(v4l2_dev, "version " DRIVER_VERSION "\n"); 397 v4l2_info(v4l2_dev, "version " DRIVER_VERSION "\n");
398 398
399 return 0; 399 return 0;
400errunr:
401 video_unregister_device(&dev->vdev);
402errfr1: 400errfr1:
403 v4l2_device_unregister(v4l2_dev); 401 v4l2_device_unregister(v4l2_dev);
404errfr: 402errfr:
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 255d40df4b46..6459a220b0dd 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -346,7 +346,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
346 346
347static const struct v4l2_file_operations maxiradio_fops = { 347static const struct v4l2_file_operations maxiradio_fops = {
348 .owner = THIS_MODULE, 348 .owner = THIS_MODULE,
349 .ioctl = video_ioctl2, 349 .unlocked_ioctl = video_ioctl2,
350}; 350};
351 351
352static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = { 352static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
diff --git a/drivers/media/radio/radio-miropcm20.c b/drivers/media/radio/radio-miropcm20.c
index 4ff885445fd4..3fb76e3834c9 100644
--- a/drivers/media/radio/radio-miropcm20.c
+++ b/drivers/media/radio/radio-miropcm20.c
@@ -33,6 +33,7 @@ struct pcm20 {
33 unsigned long freq; 33 unsigned long freq;
34 int muted; 34 int muted;
35 struct snd_miro_aci *aci; 35 struct snd_miro_aci *aci;
36 struct mutex lock;
36}; 37};
37 38
38static struct pcm20 pcm20_card = { 39static struct pcm20 pcm20_card = {
@@ -72,7 +73,7 @@ static int pcm20_setfreq(struct pcm20 *dev, unsigned long freq)
72 73
73static const struct v4l2_file_operations pcm20_fops = { 74static const struct v4l2_file_operations pcm20_fops = {
74 .owner = THIS_MODULE, 75 .owner = THIS_MODULE,
75 .ioctl = video_ioctl2, 76 .unlocked_ioctl = video_ioctl2,
76}; 77};
77 78
78static int vidioc_querycap(struct file *file, void *priv, 79static int vidioc_querycap(struct file *file, void *priv,
@@ -229,7 +230,7 @@ static int __init pcm20_init(void)
229 return -ENODEV; 230 return -ENODEV;
230 } 231 }
231 strlcpy(v4l2_dev->name, "miropcm20", sizeof(v4l2_dev->name)); 232 strlcpy(v4l2_dev->name, "miropcm20", sizeof(v4l2_dev->name));
232 233 mutex_init(&dev->lock);
233 234
234 res = v4l2_device_register(NULL, v4l2_dev); 235 res = v4l2_device_register(NULL, v4l2_dev);
235 if (res < 0) { 236 if (res < 0) {
@@ -242,6 +243,7 @@ static int __init pcm20_init(void)
242 dev->vdev.fops = &pcm20_fops; 243 dev->vdev.fops = &pcm20_fops;
243 dev->vdev.ioctl_ops = &pcm20_ioctl_ops; 244 dev->vdev.ioctl_ops = &pcm20_ioctl_ops;
244 dev->vdev.release = video_device_release_empty; 245 dev->vdev.release = video_device_release_empty;
246 dev->vdev.lock = &dev->lock;
245 video_set_drvdata(&dev->vdev, dev); 247 video_set_drvdata(&dev->vdev, dev);
246 248
247 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) 249 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0)
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index b540e8072e92..e6b2d085a449 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -58,7 +58,6 @@
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>
62#include <linux/input.h> 61#include <linux/input.h>
63#include <linux/videodev2.h> 62#include <linux/videodev2.h>
64#include <media/v4l2-device.h> 63#include <media/v4l2-device.h>
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index a79296aac9a9..8d6ea591bd18 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -266,7 +266,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
266 266
267static const struct v4l2_file_operations rtrack2_fops = { 267static const struct v4l2_file_operations rtrack2_fops = {
268 .owner = THIS_MODULE, 268 .owner = THIS_MODULE,
269 .ioctl = video_ioctl2, 269 .unlocked_ioctl = video_ioctl2,
270}; 270};
271 271
272static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = { 272static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = {
@@ -315,6 +315,10 @@ static int __init rtrack2_init(void)
315 dev->vdev.release = video_device_release_empty; 315 dev->vdev.release = video_device_release_empty;
316 video_set_drvdata(&dev->vdev, dev); 316 video_set_drvdata(&dev->vdev, dev);
317 317
318 /* mute card - prevents noisy bootups */
319 outb(1, dev->io);
320 dev->muted = 1;
321
318 mutex_init(&dev->lock); 322 mutex_init(&dev->lock);
319 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 323 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
320 v4l2_device_unregister(v4l2_dev); 324 v4l2_device_unregister(v4l2_dev);
@@ -324,10 +328,6 @@ static int __init rtrack2_init(void)
324 328
325 v4l2_info(v4l2_dev, "AIMSlab Radiotrack II card driver.\n"); 329 v4l2_info(v4l2_dev, "AIMSlab Radiotrack II card driver.\n");
326 330
327 /* mute card - prevents noisy bootups */
328 outb(1, dev->io);
329 dev->muted = 1;
330
331 return 0; 331 return 0;
332} 332}
333 333
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 985359d18aa5..b5a5f89e238a 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -260,7 +260,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
260 260
261static const struct v4l2_file_operations fmi_fops = { 261static const struct v4l2_file_operations fmi_fops = {
262 .owner = THIS_MODULE, 262 .owner = THIS_MODULE,
263 .ioctl = video_ioctl2, 263 .unlocked_ioctl = video_ioctl2,
264}; 264};
265 265
266static const struct v4l2_ioctl_ops fmi_ioctl_ops = { 266static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
@@ -382,6 +382,9 @@ static int __init fmi_init(void)
382 382
383 mutex_init(&fmi->lock); 383 mutex_init(&fmi->lock);
384 384
385 /* mute card - prevents noisy bootups */
386 fmi_mute(fmi);
387
385 if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 388 if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
386 v4l2_device_unregister(v4l2_dev); 389 v4l2_device_unregister(v4l2_dev);
387 release_region(fmi->io, 2); 390 release_region(fmi->io, 2);
@@ -391,8 +394,6 @@ static int __init fmi_init(void)
391 } 394 }
392 395
393 v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io); 396 v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io);
394 /* mute card - prevents noisy bootups */
395 fmi_mute(fmi);
396 return 0; 397 return 0;
397} 398}
398 399
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 52c7bbb32b8b..dc3f04c52d5e 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -376,7 +376,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
376 376
377static const struct v4l2_file_operations fmr2_fops = { 377static const struct v4l2_file_operations fmr2_fops = {
378 .owner = THIS_MODULE, 378 .owner = THIS_MODULE,
379 .ioctl = video_ioctl2, 379 .unlocked_ioctl = video_ioctl2,
380}; 380};
381 381
382static const struct v4l2_ioctl_ops fmr2_ioctl_ops = { 382static const struct v4l2_ioctl_ops fmr2_ioctl_ops = {
@@ -424,6 +424,10 @@ static int __init fmr2_init(void)
424 fmr2->vdev.release = video_device_release_empty; 424 fmr2->vdev.release = video_device_release_empty;
425 video_set_drvdata(&fmr2->vdev, fmr2); 425 video_set_drvdata(&fmr2->vdev, fmr2);
426 426
427 /* mute card - prevents noisy bootups */
428 fmr2_mute(fmr2->io);
429 fmr2_product_info(fmr2);
430
427 if (video_register_device(&fmr2->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 431 if (video_register_device(&fmr2->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
428 v4l2_device_unregister(v4l2_dev); 432 v4l2_device_unregister(v4l2_dev);
429 release_region(fmr2->io, 2); 433 release_region(fmr2->io, 2);
@@ -431,11 +435,6 @@ static int __init fmr2_init(void)
431 } 435 }
432 436
433 v4l2_info(v4l2_dev, "SF16FMR2 radio card driver at 0x%x.\n", fmr2->io); 437 v4l2_info(v4l2_dev, "SF16FMR2 radio card driver at 0x%x.\n", fmr2->io);
434 /* mute card - prevents noisy bootups */
435 mutex_lock(&fmr2->lock);
436 fmr2_mute(fmr2->io);
437 fmr2_product_info(fmr2);
438 mutex_unlock(&fmr2->lock);
439 debug_print((KERN_DEBUG "card_type %d\n", fmr2->card_type)); 438 debug_print((KERN_DEBUG "card_type %d\n", fmr2->card_type));
440 return 0; 439 return 0;
441} 440}
diff --git a/drivers/media/radio/radio-si4713.c b/drivers/media/radio/radio-si4713.c
index 6a435786b63d..726d367ad8d0 100644
--- a/drivers/media/radio/radio-si4713.c
+++ b/drivers/media/radio/radio-si4713.c
@@ -53,7 +53,8 @@ struct radio_si4713_device {
53/* radio_si4713_fops - file operations interface */ 53/* radio_si4713_fops - file operations interface */
54static const struct v4l2_file_operations radio_si4713_fops = { 54static const struct v4l2_file_operations radio_si4713_fops = {
55 .owner = THIS_MODULE, 55 .owner = THIS_MODULE,
56 .ioctl = video_ioctl2, 56 /* Note: locking is done at the subdev level in the i2c driver. */
57 .unlocked_ioctl = video_ioctl2,
57}; 58};
58 59
59/* Video4Linux Interface */ 60/* Video4Linux Interface */
@@ -291,7 +292,7 @@ static int radio_si4713_pdriver_probe(struct platform_device *pdev)
291 goto unregister_v4l2_dev; 292 goto unregister_v4l2_dev;
292 } 293 }
293 294
294 sd = v4l2_i2c_new_subdev_board(&rsdev->v4l2_dev, adapter, NULL, 295 sd = v4l2_i2c_new_subdev_board(&rsdev->v4l2_dev, adapter,
295 pdata->subdev_board_info, NULL); 296 pdata->subdev_board_info, NULL);
296 if (!sd) { 297 if (!sd) {
297 dev_err(&pdev->dev, "Cannot get v4l2 subdevice\n"); 298 dev_err(&pdev->dev, "Cannot get v4l2 subdevice\n");
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 789d2ec66e19..0e71d816c725 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -142,7 +142,6 @@ struct tea5764_device {
142 struct video_device *videodev; 142 struct video_device *videodev;
143 struct tea5764_regs regs; 143 struct tea5764_regs regs;
144 struct mutex mutex; 144 struct mutex mutex;
145 int users;
146}; 145};
147 146
148/* I2C code related */ 147/* I2C code related */
@@ -458,41 +457,10 @@ static int vidioc_s_audio(struct file *file, void *priv,
458 return 0; 457 return 0;
459} 458}
460 459
461static int tea5764_open(struct file *file)
462{
463 /* Currently we support only one device */
464 struct tea5764_device *radio = video_drvdata(file);
465
466 mutex_lock(&radio->mutex);
467 /* Only exclusive access */
468 if (radio->users) {
469 mutex_unlock(&radio->mutex);
470 return -EBUSY;
471 }
472 radio->users++;
473 mutex_unlock(&radio->mutex);
474 file->private_data = radio;
475 return 0;
476}
477
478static int tea5764_close(struct file *file)
479{
480 struct tea5764_device *radio = video_drvdata(file);
481
482 if (!radio)
483 return -ENODEV;
484 mutex_lock(&radio->mutex);
485 radio->users--;
486 mutex_unlock(&radio->mutex);
487 return 0;
488}
489
490/* File system interface */ 460/* File system interface */
491static const struct v4l2_file_operations tea5764_fops = { 461static const struct v4l2_file_operations tea5764_fops = {
492 .owner = THIS_MODULE, 462 .owner = THIS_MODULE,
493 .open = tea5764_open, 463 .unlocked_ioctl = video_ioctl2,
494 .release = tea5764_close,
495 .ioctl = video_ioctl2,
496}; 464};
497 465
498static const struct v4l2_ioctl_ops tea5764_ioctl_ops = { 466static const struct v4l2_ioctl_ops tea5764_ioctl_ops = {
@@ -527,7 +495,7 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
527 int ret; 495 int ret;
528 496
529 PDEBUG("probe"); 497 PDEBUG("probe");
530 radio = kmalloc(sizeof(struct tea5764_device), GFP_KERNEL); 498 radio = kzalloc(sizeof(struct tea5764_device), GFP_KERNEL);
531 if (!radio) 499 if (!radio)
532 return -ENOMEM; 500 return -ENOMEM;
533 501
@@ -555,12 +523,7 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
555 523
556 i2c_set_clientdata(client, radio); 524 i2c_set_clientdata(client, radio);
557 video_set_drvdata(radio->videodev, radio); 525 video_set_drvdata(radio->videodev, radio);
558 526 radio->videodev->lock = &radio->mutex;
559 ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
560 if (ret < 0) {
561 PWARN("Could not register video device!");
562 goto errrel;
563 }
564 527
565 /* initialize and power off the chip */ 528 /* initialize and power off the chip */
566 tea5764_i2c_read(radio); 529 tea5764_i2c_read(radio);
@@ -568,6 +531,12 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
568 tea5764_mute(radio, 1); 531 tea5764_mute(radio, 1);
569 tea5764_power_down(radio); 532 tea5764_power_down(radio);
570 533
534 ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
535 if (ret < 0) {
536 PWARN("Could not register video device!");
537 goto errrel;
538 }
539
571 PINFO("registered."); 540 PINFO("registered.");
572 return 0; 541 return 0;
573errrel: 542errrel:
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index fc1c860fd438..a32663917059 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -338,7 +338,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
338 338
339static const struct v4l2_file_operations terratec_fops = { 339static const struct v4l2_file_operations terratec_fops = {
340 .owner = THIS_MODULE, 340 .owner = THIS_MODULE,
341 .ioctl = video_ioctl2, 341 .unlocked_ioctl = video_ioctl2,
342}; 342};
343 343
344static const struct v4l2_ioctl_ops terratec_ioctl_ops = { 344static const struct v4l2_ioctl_ops terratec_ioctl_ops = {
@@ -389,6 +389,9 @@ static int __init terratec_init(void)
389 389
390 mutex_init(&tt->lock); 390 mutex_init(&tt->lock);
391 391
392 /* mute card - prevents noisy bootups */
393 tt_write_vol(tt, 0);
394
392 if (video_register_device(&tt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 395 if (video_register_device(&tt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
393 v4l2_device_unregister(&tt->v4l2_dev); 396 v4l2_device_unregister(&tt->v4l2_dev);
394 release_region(tt->io, 2); 397 release_region(tt->io, 2);
@@ -396,9 +399,6 @@ static int __init terratec_init(void)
396 } 399 }
397 400
398 v4l2_info(v4l2_dev, "TERRATEC ActivRadio Standalone card driver.\n"); 401 v4l2_info(v4l2_dev, "TERRATEC ActivRadio Standalone card driver.\n");
399
400 /* mute card - prevents noisy bootups */
401 tt_write_vol(tt, 0);
402 return 0; 402 return 0;
403} 403}
404 404
diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
index b8bb3ef47df5..a185610b376b 100644
--- a/drivers/media/radio/radio-timb.c
+++ b/drivers/media/radio/radio-timb.c
@@ -34,6 +34,7 @@ struct timbradio {
34 struct v4l2_subdev *sd_dsp; 34 struct v4l2_subdev *sd_dsp;
35 struct video_device video_dev; 35 struct video_device video_dev;
36 struct v4l2_device v4l2_dev; 36 struct v4l2_device v4l2_dev;
37 struct mutex lock;
37}; 38};
38 39
39 40
@@ -142,7 +143,7 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = {
142 143
143static const struct v4l2_file_operations timbradio_fops = { 144static const struct v4l2_file_operations timbradio_fops = {
144 .owner = THIS_MODULE, 145 .owner = THIS_MODULE,
145 .ioctl = video_ioctl2, 146 .unlocked_ioctl = video_ioctl2,
146}; 147};
147 148
148static int __devinit timbradio_probe(struct platform_device *pdev) 149static int __devinit timbradio_probe(struct platform_device *pdev)
@@ -164,6 +165,7 @@ static int __devinit timbradio_probe(struct platform_device *pdev)
164 } 165 }
165 166
166 tr->pdata = *pdata; 167 tr->pdata = *pdata;
168 mutex_init(&tr->lock);
167 169
168 strlcpy(tr->video_dev.name, "Timberdale Radio", 170 strlcpy(tr->video_dev.name, "Timberdale Radio",
169 sizeof(tr->video_dev.name)); 171 sizeof(tr->video_dev.name));
@@ -171,6 +173,7 @@ static int __devinit timbradio_probe(struct platform_device *pdev)
171 tr->video_dev.ioctl_ops = &timbradio_ioctl_ops; 173 tr->video_dev.ioctl_ops = &timbradio_ioctl_ops;
172 tr->video_dev.release = video_device_release_empty; 174 tr->video_dev.release = video_device_release_empty;
173 tr->video_dev.minor = -1; 175 tr->video_dev.minor = -1;
176 tr->video_dev.lock = &tr->lock;
174 177
175 strlcpy(tr->v4l2_dev.name, DRIVER_NAME, sizeof(tr->v4l2_dev.name)); 178 strlcpy(tr->v4l2_dev.name, DRIVER_NAME, sizeof(tr->v4l2_dev.name));
176 err = v4l2_device_register(NULL, &tr->v4l2_dev); 179 err = v4l2_device_register(NULL, &tr->v4l2_dev);
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index 9d6dcf8af5b0..22fa9cc28abe 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -344,7 +344,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
344 344
345static const struct v4l2_file_operations trust_fops = { 345static const struct v4l2_file_operations trust_fops = {
346 .owner = THIS_MODULE, 346 .owner = THIS_MODULE,
347 .ioctl = video_ioctl2, 347 .unlocked_ioctl = video_ioctl2,
348}; 348};
349 349
350static const struct v4l2_ioctl_ops trust_ioctl_ops = { 350static const struct v4l2_ioctl_ops trust_ioctl_ops = {
@@ -396,14 +396,6 @@ static int __init trust_init(void)
396 tr->vdev.release = video_device_release_empty; 396 tr->vdev.release = video_device_release_empty;
397 video_set_drvdata(&tr->vdev, tr); 397 video_set_drvdata(&tr->vdev, tr);
398 398
399 if (video_register_device(&tr->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
400 v4l2_device_unregister(v4l2_dev);
401 release_region(tr->io, 2);
402 return -EINVAL;
403 }
404
405 v4l2_info(v4l2_dev, "Trust FM Radio card driver v1.0.\n");
406
407 write_i2c(tr, 2, TDA7318_ADDR, 0x80); /* speaker att. LF = 0 dB */ 399 write_i2c(tr, 2, TDA7318_ADDR, 0x80); /* speaker att. LF = 0 dB */
408 write_i2c(tr, 2, TDA7318_ADDR, 0xa0); /* speaker att. RF = 0 dB */ 400 write_i2c(tr, 2, TDA7318_ADDR, 0xa0); /* speaker att. RF = 0 dB */
409 write_i2c(tr, 2, TDA7318_ADDR, 0xc0); /* speaker att. LR = 0 dB */ 401 write_i2c(tr, 2, TDA7318_ADDR, 0xc0); /* speaker att. LR = 0 dB */
@@ -418,6 +410,14 @@ static int __init trust_init(void)
418 /* mute card - prevents noisy bootups */ 410 /* mute card - prevents noisy bootups */
419 tr_setmute(tr, 1); 411 tr_setmute(tr, 1);
420 412
413 if (video_register_device(&tr->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
414 v4l2_device_unregister(v4l2_dev);
415 release_region(tr->io, 2);
416 return -EINVAL;
417 }
418
419 v4l2_info(v4l2_dev, "Trust FM Radio card driver v1.0.\n");
420
421 return 0; 421 return 0;
422} 422}
423 423
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index b1f630527dc1..8dbbf08f2207 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -317,7 +317,7 @@ static int vidioc_log_status(struct file *file, void *priv)
317 317
318static const struct v4l2_file_operations typhoon_fops = { 318static const struct v4l2_file_operations typhoon_fops = {
319 .owner = THIS_MODULE, 319 .owner = THIS_MODULE,
320 .ioctl = video_ioctl2, 320 .unlocked_ioctl = video_ioctl2,
321}; 321};
322 322
323static const struct v4l2_ioctl_ops typhoon_ioctl_ops = { 323static const struct v4l2_ioctl_ops typhoon_ioctl_ops = {
@@ -344,18 +344,18 @@ static int __init typhoon_init(void)
344 344
345 strlcpy(v4l2_dev->name, "typhoon", sizeof(v4l2_dev->name)); 345 strlcpy(v4l2_dev->name, "typhoon", sizeof(v4l2_dev->name));
346 dev->io = io; 346 dev->io = io;
347 dev->curfreq = dev->mutefreq = mutefreq;
348 347
349 if (dev->io == -1) { 348 if (dev->io == -1) {
350 v4l2_err(v4l2_dev, "You must set an I/O address with io=0x316 or io=0x336\n"); 349 v4l2_err(v4l2_dev, "You must set an I/O address with io=0x316 or io=0x336\n");
351 return -EINVAL; 350 return -EINVAL;
352 } 351 }
353 352
354 if (dev->mutefreq < 87000 || dev->mutefreq > 108500) { 353 if (mutefreq < 87000 || mutefreq > 108500) {
355 v4l2_err(v4l2_dev, "You must set a frequency (in kHz) used when muting the card,\n"); 354 v4l2_err(v4l2_dev, "You must set a frequency (in kHz) used when muting the card,\n");
356 v4l2_err(v4l2_dev, "e.g. with \"mutefreq=87500\" (87000 <= mutefreq <= 108500)\n"); 355 v4l2_err(v4l2_dev, "e.g. with \"mutefreq=87500\" (87000 <= mutefreq <= 108500)\n");
357 return -EINVAL; 356 return -EINVAL;
358 } 357 }
358 dev->curfreq = dev->mutefreq = mutefreq << 4;
359 359
360 mutex_init(&dev->lock); 360 mutex_init(&dev->lock);
361 if (!request_region(dev->io, 8, "typhoon")) { 361 if (!request_region(dev->io, 8, "typhoon")) {
@@ -378,17 +378,17 @@ static int __init typhoon_init(void)
378 dev->vdev.ioctl_ops = &typhoon_ioctl_ops; 378 dev->vdev.ioctl_ops = &typhoon_ioctl_ops;
379 dev->vdev.release = video_device_release_empty; 379 dev->vdev.release = video_device_release_empty;
380 video_set_drvdata(&dev->vdev, dev); 380 video_set_drvdata(&dev->vdev, dev);
381
382 /* mute card - prevents noisy bootups */
383 typhoon_mute(dev);
384
381 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 385 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
382 v4l2_device_unregister(&dev->v4l2_dev); 386 v4l2_device_unregister(&dev->v4l2_dev);
383 release_region(dev->io, 8); 387 release_region(dev->io, 8);
384 return -EINVAL; 388 return -EINVAL;
385 } 389 }
386 v4l2_info(v4l2_dev, "port 0x%x.\n", dev->io); 390 v4l2_info(v4l2_dev, "port 0x%x.\n", dev->io);
387 v4l2_info(v4l2_dev, "mute frequency is %lu kHz.\n", dev->mutefreq); 391 v4l2_info(v4l2_dev, "mute frequency is %lu kHz.\n", mutefreq);
388 dev->mutefreq <<= 4;
389
390 /* mute card - prevents noisy bootups */
391 typhoon_mute(dev);
392 392
393 return 0; 393 return 0;
394} 394}
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index f31eab99c943..af99c5bd88c1 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -377,7 +377,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
377static const struct v4l2_file_operations zoltrix_fops = 377static const struct v4l2_file_operations zoltrix_fops =
378{ 378{
379 .owner = THIS_MODULE, 379 .owner = THIS_MODULE,
380 .ioctl = video_ioctl2, 380 .unlocked_ioctl = video_ioctl2,
381}; 381};
382 382
383static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = { 383static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = {
@@ -424,20 +424,6 @@ static int __init zoltrix_init(void)
424 return res; 424 return res;
425 } 425 }
426 426
427 strlcpy(zol->vdev.name, v4l2_dev->name, sizeof(zol->vdev.name));
428 zol->vdev.v4l2_dev = v4l2_dev;
429 zol->vdev.fops = &zoltrix_fops;
430 zol->vdev.ioctl_ops = &zoltrix_ioctl_ops;
431 zol->vdev.release = video_device_release_empty;
432 video_set_drvdata(&zol->vdev, zol);
433
434 if (video_register_device(&zol->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
435 v4l2_device_unregister(v4l2_dev);
436 release_region(zol->io, 2);
437 return -EINVAL;
438 }
439 v4l2_info(v4l2_dev, "Zoltrix Radio Plus card driver.\n");
440
441 mutex_init(&zol->lock); 427 mutex_init(&zol->lock);
442 428
443 /* mute card - prevents noisy bootups */ 429 /* mute card - prevents noisy bootups */
@@ -452,6 +438,20 @@ static int __init zoltrix_init(void)
452 zol->curvol = 0; 438 zol->curvol = 0;
453 zol->stereo = 1; 439 zol->stereo = 1;
454 440
441 strlcpy(zol->vdev.name, v4l2_dev->name, sizeof(zol->vdev.name));
442 zol->vdev.v4l2_dev = v4l2_dev;
443 zol->vdev.fops = &zoltrix_fops;
444 zol->vdev.ioctl_ops = &zoltrix_ioctl_ops;
445 zol->vdev.release = video_device_release_empty;
446 video_set_drvdata(&zol->vdev, zol);
447
448 if (video_register_device(&zol->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
449 v4l2_device_unregister(v4l2_dev);
450 release_region(zol->io, 2);
451 return -EINVAL;
452 }
453 v4l2_info(v4l2_dev, "Zoltrix Radio Plus card driver.\n");
454
455 return 0; 455 return 0;
456} 456}
457 457
diff --git a/drivers/media/radio/si470x/radio-si470x.h b/drivers/media/radio/si470x/radio-si470x.h
index ea12782359a0..b9914d7a0c9f 100644
--- a/drivers/media/radio/si470x/radio-si470x.h
+++ b/drivers/media/radio/si470x/radio-si470x.h
@@ -31,7 +31,6 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/smp_lock.h>
35#include <linux/input.h> 34#include <linux/input.h>
36#include <linux/version.h> 35#include <linux/version.h>
37#include <linux/videodev2.h> 36#include <linux/videodev2.h>
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index ac16e815e275..6830d2848bd7 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -112,7 +112,7 @@ config VIDEO_IR_I2C
112# 112#
113 113
114menu "Encoders/decoders and other helper chips" 114menu "Encoders/decoders and other helper chips"
115 depends on !VIDEO_HELPER_CHIPS_AUTO 115 visible if !VIDEO_HELPER_CHIPS_AUTO
116 116
117comment "Audio decoders" 117comment "Audio decoders"
118 118
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 31e7a123d19a..f989f2820d88 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -712,7 +712,7 @@ static int ar_initialize(struct ar *ar)
712static const struct v4l2_file_operations ar_fops = { 712static const struct v4l2_file_operations ar_fops = {
713 .owner = THIS_MODULE, 713 .owner = THIS_MODULE,
714 .read = ar_read, 714 .read = ar_read,
715 .ioctl = video_ioctl2, 715 .unlocked_ioctl = video_ioctl2,
716}; 716};
717 717
718static const struct v4l2_ioctl_ops ar_ioctl_ops = { 718static const struct v4l2_ioctl_ops ar_ioctl_ops = {
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c
index 0453816d4ec3..01be89fa5c78 100644
--- a/drivers/media/video/au0828/au0828-cards.c
+++ b/drivers/media/video/au0828/au0828-cards.c
@@ -212,7 +212,7 @@ void au0828_card_setup(struct au0828_dev *dev)
212 be abstracted out if we ever need to support a different 212 be abstracted out if we ever need to support a different
213 demod) */ 213 demod) */
214 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 214 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
215 NULL, "au8522", 0x8e >> 1, NULL); 215 "au8522", 0x8e >> 1, NULL);
216 if (sd == NULL) 216 if (sd == NULL)
217 printk(KERN_ERR "analog subdev registration failed\n"); 217 printk(KERN_ERR "analog subdev registration failed\n");
218 } 218 }
@@ -221,7 +221,7 @@ void au0828_card_setup(struct au0828_dev *dev)
221 if (dev->board.tuner_type != TUNER_ABSENT) { 221 if (dev->board.tuner_type != TUNER_ABSENT) {
222 /* Load the tuner module, which does the attach */ 222 /* Load the tuner module, which does the attach */
223 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 223 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
224 NULL, "tuner", dev->board.tuner_addr, NULL); 224 "tuner", dev->board.tuner_addr, NULL);
225 if (sd == NULL) 225 if (sd == NULL)
226 printk(KERN_ERR "tuner subdev registration fail\n"); 226 printk(KERN_ERR "tuner subdev registration fail\n");
227 227
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index 87d8b006ef77..49efcf660ba6 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -3529,7 +3529,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
3529 struct v4l2_subdev *sd; 3529 struct v4l2_subdev *sd;
3530 3530
3531 sd = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3531 sd = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3532 &btv->c.i2c_adap, NULL, "saa6588", 0, addrs); 3532 &btv->c.i2c_adap, "saa6588", 0, addrs);
3533 btv->has_saa6588 = (sd != NULL); 3533 btv->has_saa6588 = (sd != NULL);
3534 } 3534 }
3535 3535
@@ -3554,7 +3554,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
3554 }; 3554 };
3555 3555
3556 btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3556 btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3557 &btv->c.i2c_adap, NULL, "msp3400", 0, addrs); 3557 &btv->c.i2c_adap, "msp3400", 0, addrs);
3558 if (btv->sd_msp34xx) 3558 if (btv->sd_msp34xx)
3559 return; 3559 return;
3560 goto no_audio; 3560 goto no_audio;
@@ -3568,7 +3568,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
3568 }; 3568 };
3569 3569
3570 if (v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3570 if (v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3571 &btv->c.i2c_adap, NULL, "tda7432", 0, addrs)) 3571 &btv->c.i2c_adap, "tda7432", 0, addrs))
3572 return; 3572 return;
3573 goto no_audio; 3573 goto no_audio;
3574 } 3574 }
@@ -3576,7 +3576,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
3576 case 3: { 3576 case 3: {
3577 /* The user specified that we should probe for tvaudio */ 3577 /* The user specified that we should probe for tvaudio */
3578 btv->sd_tvaudio = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3578 btv->sd_tvaudio = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3579 &btv->c.i2c_adap, NULL, "tvaudio", 0, tvaudio_addrs()); 3579 &btv->c.i2c_adap, "tvaudio", 0, tvaudio_addrs());
3580 if (btv->sd_tvaudio) 3580 if (btv->sd_tvaudio)
3581 return; 3581 return;
3582 goto no_audio; 3582 goto no_audio;
@@ -3596,11 +3596,11 @@ void __devinit bttv_init_card2(struct bttv *btv)
3596 found is really something else (e.g. a tea6300). */ 3596 found is really something else (e.g. a tea6300). */
3597 if (!bttv_tvcards[btv->c.type].no_msp34xx) { 3597 if (!bttv_tvcards[btv->c.type].no_msp34xx) {
3598 btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3598 btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3599 &btv->c.i2c_adap, NULL, "msp3400", 3599 &btv->c.i2c_adap, "msp3400",
3600 0, I2C_ADDRS(I2C_ADDR_MSP3400 >> 1)); 3600 0, I2C_ADDRS(I2C_ADDR_MSP3400 >> 1));
3601 } else if (bttv_tvcards[btv->c.type].msp34xx_alt) { 3601 } else if (bttv_tvcards[btv->c.type].msp34xx_alt) {
3602 btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3602 btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3603 &btv->c.i2c_adap, NULL, "msp3400", 3603 &btv->c.i2c_adap, "msp3400",
3604 0, I2C_ADDRS(I2C_ADDR_MSP3400_ALT >> 1)); 3604 0, I2C_ADDRS(I2C_ADDR_MSP3400_ALT >> 1));
3605 } 3605 }
3606 3606
@@ -3616,13 +3616,13 @@ void __devinit bttv_init_card2(struct bttv *btv)
3616 }; 3616 };
3617 3617
3618 if (v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3618 if (v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3619 &btv->c.i2c_adap, NULL, "tda7432", 0, addrs)) 3619 &btv->c.i2c_adap, "tda7432", 0, addrs))
3620 return; 3620 return;
3621 } 3621 }
3622 3622
3623 /* Now see if we can find one of the tvaudio devices. */ 3623 /* Now see if we can find one of the tvaudio devices. */
3624 btv->sd_tvaudio = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3624 btv->sd_tvaudio = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3625 &btv->c.i2c_adap, NULL, "tvaudio", 0, tvaudio_addrs()); 3625 &btv->c.i2c_adap, "tvaudio", 0, tvaudio_addrs());
3626 if (btv->sd_tvaudio) 3626 if (btv->sd_tvaudio)
3627 return; 3627 return;
3628 3628
@@ -3646,13 +3646,13 @@ void __devinit bttv_init_tuner(struct bttv *btv)
3646 /* Load tuner module before issuing tuner config call! */ 3646 /* Load tuner module before issuing tuner config call! */
3647 if (bttv_tvcards[btv->c.type].has_radio) 3647 if (bttv_tvcards[btv->c.type].has_radio)
3648 v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3648 v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3649 &btv->c.i2c_adap, NULL, "tuner", 3649 &btv->c.i2c_adap, "tuner",
3650 0, v4l2_i2c_tuner_addrs(ADDRS_RADIO)); 3650 0, v4l2_i2c_tuner_addrs(ADDRS_RADIO));
3651 v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3651 v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3652 &btv->c.i2c_adap, NULL, "tuner", 3652 &btv->c.i2c_adap, "tuner",
3653 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); 3653 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
3654 v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3654 v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3655 &btv->c.i2c_adap, NULL, "tuner", 3655 &btv->c.i2c_adap, "tuner",
3656 0, v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD)); 3656 0, v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD));
3657 3657
3658 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; 3658 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 3da6e80e1041..0902ec041c7a 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -42,7 +42,6 @@
42#include <linux/fs.h> 42#include <linux/fs.h>
43#include <linux/kernel.h> 43#include <linux/kernel.h>
44#include <linux/sched.h> 44#include <linux/sched.h>
45#include <linux/smp_lock.h>
46#include <linux/interrupt.h> 45#include <linux/interrupt.h>
47#include <linux/kdev_t.h> 46#include <linux/kdev_t.h>
48#include "bttvp.h" 47#include "bttvp.h"
@@ -855,7 +854,6 @@ int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)
855 xbits |= RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM; 854 xbits |= RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM;
856 855
857 /* is it free? */ 856 /* is it free? */
858 mutex_lock(&btv->lock);
859 if (btv->resources & xbits) { 857 if (btv->resources & xbits) {
860 /* no, someone else uses it */ 858 /* no, someone else uses it */
861 goto fail; 859 goto fail;
@@ -885,11 +883,9 @@ int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit)
885 /* it's free, grab it */ 883 /* it's free, grab it */
886 fh->resources |= bit; 884 fh->resources |= bit;
887 btv->resources |= bit; 885 btv->resources |= bit;
888 mutex_unlock(&btv->lock);
889 return 1; 886 return 1;
890 887
891 fail: 888 fail:
892 mutex_unlock(&btv->lock);
893 return 0; 889 return 0;
894} 890}
895 891
@@ -941,7 +937,6 @@ void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits)
941 /* trying to free ressources not allocated by us ... */ 937 /* trying to free ressources not allocated by us ... */
942 printk("bttv: BUG! (btres)\n"); 938 printk("bttv: BUG! (btres)\n");
943 } 939 }
944 mutex_lock(&btv->lock);
945 fh->resources &= ~bits; 940 fh->resources &= ~bits;
946 btv->resources &= ~bits; 941 btv->resources &= ~bits;
947 942
@@ -952,8 +947,6 @@ void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits)
952 947
953 if (0 == (bits & VBI_RESOURCES)) 948 if (0 == (bits & VBI_RESOURCES))
954 disclaim_vbi_lines(btv); 949 disclaim_vbi_lines(btv);
955
956 mutex_unlock(&btv->lock);
957} 950}
958 951
959/* ----------------------------------------------------------------------- */ 952/* ----------------------------------------------------------------------- */
@@ -1714,28 +1707,20 @@ static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
1714 1707
1715 /* Make sure tvnorm and vbi_end remain consistent 1708 /* Make sure tvnorm and vbi_end remain consistent
1716 until we're done. */ 1709 until we're done. */
1717 mutex_lock(&btv->lock);
1718 1710
1719 norm = btv->tvnorm; 1711 norm = btv->tvnorm;
1720 1712
1721 /* In this mode capturing always starts at defrect.top 1713 /* In this mode capturing always starts at defrect.top
1722 (default VDELAY), ignoring cropping parameters. */ 1714 (default VDELAY), ignoring cropping parameters. */
1723 if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) { 1715 if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) {
1724 mutex_unlock(&btv->lock);
1725 return -EINVAL; 1716 return -EINVAL;
1726 } 1717 }
1727 1718
1728 mutex_unlock(&btv->lock);
1729
1730 c.rect = bttv_tvnorms[norm].cropcap.defrect; 1719 c.rect = bttv_tvnorms[norm].cropcap.defrect;
1731 } else { 1720 } else {
1732 mutex_lock(&btv->lock);
1733
1734 norm = btv->tvnorm; 1721 norm = btv->tvnorm;
1735 c = btv->crop[!!fh->do_crop]; 1722 c = btv->crop[!!fh->do_crop];
1736 1723
1737 mutex_unlock(&btv->lock);
1738
1739 if (width < c.min_scaled_width || 1724 if (width < c.min_scaled_width ||
1740 width > c.max_scaled_width || 1725 width > c.max_scaled_width ||
1741 height < c.min_scaled_height) 1726 height < c.min_scaled_height)
@@ -1859,7 +1844,6 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id)
1859 unsigned int i; 1844 unsigned int i;
1860 int err; 1845 int err;
1861 1846
1862 mutex_lock(&btv->lock);
1863 err = v4l2_prio_check(&btv->prio, fh->prio); 1847 err = v4l2_prio_check(&btv->prio, fh->prio);
1864 if (err) 1848 if (err)
1865 goto err; 1849 goto err;
@@ -1875,7 +1859,6 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id)
1875 set_tvnorm(btv, i); 1859 set_tvnorm(btv, i);
1876 1860
1877err: 1861err:
1878 mutex_unlock(&btv->lock);
1879 1862
1880 return err; 1863 return err;
1881} 1864}
@@ -1899,7 +1882,6 @@ static int bttv_enum_input(struct file *file, void *priv,
1899 struct bttv *btv = fh->btv; 1882 struct bttv *btv = fh->btv;
1900 int rc = 0; 1883 int rc = 0;
1901 1884
1902 mutex_lock(&btv->lock);
1903 if (i->index >= bttv_tvcards[btv->c.type].video_inputs) { 1885 if (i->index >= bttv_tvcards[btv->c.type].video_inputs) {
1904 rc = -EINVAL; 1886 rc = -EINVAL;
1905 goto err; 1887 goto err;
@@ -1929,7 +1911,6 @@ static int bttv_enum_input(struct file *file, void *priv,
1929 i->std = BTTV_NORMS; 1911 i->std = BTTV_NORMS;
1930 1912
1931err: 1913err:
1932 mutex_unlock(&btv->lock);
1933 1914
1934 return rc; 1915 return rc;
1935} 1916}
@@ -1939,9 +1920,7 @@ static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
1939 struct bttv_fh *fh = priv; 1920 struct bttv_fh *fh = priv;
1940 struct bttv *btv = fh->btv; 1921 struct bttv *btv = fh->btv;
1941 1922
1942 mutex_lock(&btv->lock);
1943 *i = btv->input; 1923 *i = btv->input;
1944 mutex_unlock(&btv->lock);
1945 1924
1946 return 0; 1925 return 0;
1947} 1926}
@@ -1953,7 +1932,6 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i)
1953 1932
1954 int err; 1933 int err;
1955 1934
1956 mutex_lock(&btv->lock);
1957 err = v4l2_prio_check(&btv->prio, fh->prio); 1935 err = v4l2_prio_check(&btv->prio, fh->prio);
1958 if (unlikely(err)) 1936 if (unlikely(err))
1959 goto err; 1937 goto err;
@@ -1966,7 +1944,6 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i)
1966 set_input(btv, i, btv->tvnorm); 1944 set_input(btv, i, btv->tvnorm);
1967 1945
1968err: 1946err:
1969 mutex_unlock(&btv->lock);
1970 return 0; 1947 return 0;
1971} 1948}
1972 1949
@@ -1980,7 +1957,6 @@ static int bttv_s_tuner(struct file *file, void *priv,
1980 if (unlikely(0 != t->index)) 1957 if (unlikely(0 != t->index))
1981 return -EINVAL; 1958 return -EINVAL;
1982 1959
1983 mutex_lock(&btv->lock);
1984 if (unlikely(btv->tuner_type == TUNER_ABSENT)) { 1960 if (unlikely(btv->tuner_type == TUNER_ABSENT)) {
1985 err = -EINVAL; 1961 err = -EINVAL;
1986 goto err; 1962 goto err;
@@ -1996,7 +1972,6 @@ static int bttv_s_tuner(struct file *file, void *priv,
1996 btv->audio_mode_gpio(btv, t, 1); 1972 btv->audio_mode_gpio(btv, t, 1);
1997 1973
1998err: 1974err:
1999 mutex_unlock(&btv->lock);
2000 1975
2001 return 0; 1976 return 0;
2002} 1977}
@@ -2007,10 +1982,8 @@ static int bttv_g_frequency(struct file *file, void *priv,
2007 struct bttv_fh *fh = priv; 1982 struct bttv_fh *fh = priv;
2008 struct bttv *btv = fh->btv; 1983 struct bttv *btv = fh->btv;
2009 1984
2010 mutex_lock(&btv->lock);
2011 f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1985 f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
2012 f->frequency = btv->freq; 1986 f->frequency = btv->freq;
2013 mutex_unlock(&btv->lock);
2014 1987
2015 return 0; 1988 return 0;
2016} 1989}
@@ -2025,7 +1998,6 @@ static int bttv_s_frequency(struct file *file, void *priv,
2025 if (unlikely(f->tuner != 0)) 1998 if (unlikely(f->tuner != 0))
2026 return -EINVAL; 1999 return -EINVAL;
2027 2000
2028 mutex_lock(&btv->lock);
2029 err = v4l2_prio_check(&btv->prio, fh->prio); 2001 err = v4l2_prio_check(&btv->prio, fh->prio);
2030 if (unlikely(err)) 2002 if (unlikely(err))
2031 goto err; 2003 goto err;
@@ -2040,7 +2012,6 @@ static int bttv_s_frequency(struct file *file, void *priv,
2040 if (btv->has_matchbox && btv->radio_user) 2012 if (btv->has_matchbox && btv->radio_user)
2041 tea5757_set_freq(btv, btv->freq); 2013 tea5757_set_freq(btv, btv->freq);
2042err: 2014err:
2043 mutex_unlock(&btv->lock);
2044 2015
2045 return 0; 2016 return 0;
2046} 2017}
@@ -2173,7 +2144,6 @@ limit_scaled_size_lock (struct bttv_fh * fh,
2173 2144
2174 /* Make sure tvnorm, vbi_end and the current cropping parameters 2145 /* Make sure tvnorm, vbi_end and the current cropping parameters
2175 remain consistent until we're done. */ 2146 remain consistent until we're done. */
2176 mutex_lock(&btv->lock);
2177 2147
2178 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; 2148 b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds;
2179 2149
@@ -2251,7 +2221,6 @@ limit_scaled_size_lock (struct bttv_fh * fh,
2251 rc = 0; /* success */ 2221 rc = 0; /* success */
2252 2222
2253 fail: 2223 fail:
2254 mutex_unlock(&btv->lock);
2255 2224
2256 return rc; 2225 return rc;
2257} 2226}
@@ -2283,9 +2252,7 @@ verify_window_lock (struct bttv_fh * fh,
2283 if (V4L2_FIELD_ANY == field) { 2252 if (V4L2_FIELD_ANY == field) {
2284 __s32 height2; 2253 __s32 height2;
2285 2254
2286 mutex_lock(&fh->btv->lock);
2287 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; 2255 height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1;
2288 mutex_unlock(&fh->btv->lock);
2289 field = (win->w.height > height2) 2256 field = (win->w.height > height2)
2290 ? V4L2_FIELD_INTERLACED 2257 ? V4L2_FIELD_INTERLACED
2291 : V4L2_FIELD_TOP; 2258 : V4L2_FIELD_TOP;
@@ -2361,7 +2328,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
2361 } 2328 }
2362 } 2329 }
2363 2330
2364 mutex_lock(&fh->cap.vb_lock);
2365 /* clip against screen */ 2331 /* clip against screen */
2366 if (NULL != btv->fbuf.base) 2332 if (NULL != btv->fbuf.base)
2367 n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height, 2333 n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height,
@@ -2392,13 +2358,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
2392 fh->ov.field = win->field; 2358 fh->ov.field = win->field;
2393 fh->ov.setup_ok = 1; 2359 fh->ov.setup_ok = 1;
2394 2360
2395 /*
2396 * FIXME: btv is protected by btv->lock mutex, while btv->init
2397 * is protected by fh->cap.vb_lock. This seems to open the
2398 * possibility for some race situations. Maybe the better would
2399 * be to unify those locks or to use another way to store the
2400 * init values that will be consumed by videobuf callbacks
2401 */
2402 btv->init.ov.w.width = win->w.width; 2361 btv->init.ov.w.width = win->w.width;
2403 btv->init.ov.w.height = win->w.height; 2362 btv->init.ov.w.height = win->w.height;
2404 btv->init.ov.field = win->field; 2363 btv->init.ov.field = win->field;
@@ -2413,7 +2372,6 @@ static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv,
2413 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); 2372 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
2414 retval = bttv_switch_overlay(btv,fh,new); 2373 retval = bttv_switch_overlay(btv,fh,new);
2415 } 2374 }
2416 mutex_unlock(&fh->cap.vb_lock);
2417 return retval; 2375 return retval;
2418} 2376}
2419 2377
@@ -2527,9 +2485,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
2527 if (V4L2_FIELD_ANY == field) { 2485 if (V4L2_FIELD_ANY == field) {
2528 __s32 height2; 2486 __s32 height2;
2529 2487
2530 mutex_lock(&btv->lock);
2531 height2 = btv->crop[!!fh->do_crop].rect.height >> 1; 2488 height2 = btv->crop[!!fh->do_crop].rect.height >> 1;
2532 mutex_unlock(&btv->lock);
2533 field = (f->fmt.pix.height > height2) 2489 field = (f->fmt.pix.height > height2)
2534 ? V4L2_FIELD_INTERLACED 2490 ? V4L2_FIELD_INTERLACED
2535 : V4L2_FIELD_BOTTOM; 2491 : V4L2_FIELD_BOTTOM;
@@ -2615,7 +2571,6 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
2615 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 2571 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
2616 2572
2617 /* update our state informations */ 2573 /* update our state informations */
2618 mutex_lock(&fh->cap.vb_lock);
2619 fh->fmt = fmt; 2574 fh->fmt = fmt;
2620 fh->cap.field = f->fmt.pix.field; 2575 fh->cap.field = f->fmt.pix.field;
2621 fh->cap.last = V4L2_FIELD_NONE; 2576 fh->cap.last = V4L2_FIELD_NONE;
@@ -2624,7 +2579,6 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
2624 btv->init.fmt = fmt; 2579 btv->init.fmt = fmt;
2625 btv->init.width = f->fmt.pix.width; 2580 btv->init.width = f->fmt.pix.width;
2626 btv->init.height = f->fmt.pix.height; 2581 btv->init.height = f->fmt.pix.height;
2627 mutex_unlock(&fh->cap.vb_lock);
2628 2582
2629 return 0; 2583 return 0;
2630} 2584}
@@ -2650,11 +2604,9 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2650 unsigned int i; 2604 unsigned int i;
2651 struct bttv_fh *fh = priv; 2605 struct bttv_fh *fh = priv;
2652 2606
2653 mutex_lock(&fh->cap.vb_lock);
2654 retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, 2607 retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
2655 V4L2_MEMORY_MMAP); 2608 V4L2_MEMORY_MMAP);
2656 if (retval < 0) { 2609 if (retval < 0) {
2657 mutex_unlock(&fh->cap.vb_lock);
2658 return retval; 2610 return retval;
2659 } 2611 }
2660 2612
@@ -2666,7 +2618,6 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2666 for (i = 0; i < gbuffers; i++) 2618 for (i = 0; i < gbuffers; i++)
2667 mbuf->offsets[i] = i * gbufsize; 2619 mbuf->offsets[i] = i * gbufsize;
2668 2620
2669 mutex_unlock(&fh->cap.vb_lock);
2670 return 0; 2621 return 0;
2671} 2622}
2672#endif 2623#endif
@@ -2776,10 +2727,8 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
2776 int retval = 0; 2727 int retval = 0;
2777 2728
2778 if (on) { 2729 if (on) {
2779 mutex_lock(&fh->cap.vb_lock);
2780 /* verify args */ 2730 /* verify args */
2781 if (unlikely(!btv->fbuf.base)) { 2731 if (unlikely(!btv->fbuf.base)) {
2782 mutex_unlock(&fh->cap.vb_lock);
2783 return -EINVAL; 2732 return -EINVAL;
2784 } 2733 }
2785 if (unlikely(!fh->ov.setup_ok)) { 2734 if (unlikely(!fh->ov.setup_ok)) {
@@ -2788,13 +2737,11 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
2788 } 2737 }
2789 if (retval) 2738 if (retval)
2790 return retval; 2739 return retval;
2791 mutex_unlock(&fh->cap.vb_lock);
2792 } 2740 }
2793 2741
2794 if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) 2742 if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY))
2795 return -EBUSY; 2743 return -EBUSY;
2796 2744
2797 mutex_lock(&fh->cap.vb_lock);
2798 if (on) { 2745 if (on) {
2799 fh->ov.tvnorm = btv->tvnorm; 2746 fh->ov.tvnorm = btv->tvnorm;
2800 new = videobuf_sg_alloc(sizeof(*new)); 2747 new = videobuf_sg_alloc(sizeof(*new));
@@ -2806,7 +2753,6 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
2806 2753
2807 /* switch over */ 2754 /* switch over */
2808 retval = bttv_switch_overlay(btv, fh, new); 2755 retval = bttv_switch_overlay(btv, fh, new);
2809 mutex_unlock(&fh->cap.vb_lock);
2810 return retval; 2756 return retval;
2811} 2757}
2812 2758
@@ -2845,7 +2791,6 @@ static int bttv_s_fbuf(struct file *file, void *f,
2845 } 2791 }
2846 2792
2847 /* ok, accept it */ 2793 /* ok, accept it */
2848 mutex_lock(&fh->cap.vb_lock);
2849 btv->fbuf.base = fb->base; 2794 btv->fbuf.base = fb->base;
2850 btv->fbuf.fmt.width = fb->fmt.width; 2795 btv->fbuf.fmt.width = fb->fmt.width;
2851 btv->fbuf.fmt.height = fb->fmt.height; 2796 btv->fbuf.fmt.height = fb->fmt.height;
@@ -2877,7 +2822,6 @@ static int bttv_s_fbuf(struct file *file, void *f,
2877 retval = bttv_switch_overlay(btv, fh, new); 2822 retval = bttv_switch_overlay(btv, fh, new);
2878 } 2823 }
2879 } 2824 }
2880 mutex_unlock(&fh->cap.vb_lock);
2881 return retval; 2825 return retval;
2882} 2826}
2883 2827
@@ -2956,7 +2900,6 @@ static int bttv_queryctrl(struct file *file, void *priv,
2956 c->id >= V4L2_CID_PRIVATE_LASTP1)) 2900 c->id >= V4L2_CID_PRIVATE_LASTP1))
2957 return -EINVAL; 2901 return -EINVAL;
2958 2902
2959 mutex_lock(&btv->lock);
2960 if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME)) 2903 if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME))
2961 *c = no_ctl; 2904 *c = no_ctl;
2962 else { 2905 else {
@@ -2964,7 +2907,6 @@ static int bttv_queryctrl(struct file *file, void *priv,
2964 2907
2965 *c = (NULL != ctrl) ? *ctrl : no_ctl; 2908 *c = (NULL != ctrl) ? *ctrl : no_ctl;
2966 } 2909 }
2967 mutex_unlock(&btv->lock);
2968 2910
2969 return 0; 2911 return 0;
2970} 2912}
@@ -2975,10 +2917,8 @@ static int bttv_g_parm(struct file *file, void *f,
2975 struct bttv_fh *fh = f; 2917 struct bttv_fh *fh = f;
2976 struct bttv *btv = fh->btv; 2918 struct bttv *btv = fh->btv;
2977 2919
2978 mutex_lock(&btv->lock);
2979 v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, 2920 v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id,
2980 &parm->parm.capture.timeperframe); 2921 &parm->parm.capture.timeperframe);
2981 mutex_unlock(&btv->lock);
2982 2922
2983 return 0; 2923 return 0;
2984} 2924}
@@ -2994,7 +2934,6 @@ static int bttv_g_tuner(struct file *file, void *priv,
2994 if (0 != t->index) 2934 if (0 != t->index)
2995 return -EINVAL; 2935 return -EINVAL;
2996 2936
2997 mutex_lock(&btv->lock);
2998 t->rxsubchans = V4L2_TUNER_SUB_MONO; 2937 t->rxsubchans = V4L2_TUNER_SUB_MONO;
2999 bttv_call_all(btv, tuner, g_tuner, t); 2938 bttv_call_all(btv, tuner, g_tuner, t);
3000 strcpy(t->name, "Television"); 2939 strcpy(t->name, "Television");
@@ -3006,7 +2945,6 @@ static int bttv_g_tuner(struct file *file, void *priv,
3006 if (btv->audio_mode_gpio) 2945 if (btv->audio_mode_gpio)
3007 btv->audio_mode_gpio(btv, t, 0); 2946 btv->audio_mode_gpio(btv, t, 0);
3008 2947
3009 mutex_unlock(&btv->lock);
3010 return 0; 2948 return 0;
3011} 2949}
3012 2950
@@ -3015,9 +2953,7 @@ static int bttv_g_priority(struct file *file, void *f, enum v4l2_priority *p)
3015 struct bttv_fh *fh = f; 2953 struct bttv_fh *fh = f;
3016 struct bttv *btv = fh->btv; 2954 struct bttv *btv = fh->btv;
3017 2955
3018 mutex_lock(&btv->lock);
3019 *p = v4l2_prio_max(&btv->prio); 2956 *p = v4l2_prio_max(&btv->prio);
3020 mutex_unlock(&btv->lock);
3021 2957
3022 return 0; 2958 return 0;
3023} 2959}
@@ -3029,9 +2965,7 @@ static int bttv_s_priority(struct file *file, void *f,
3029 struct bttv *btv = fh->btv; 2965 struct bttv *btv = fh->btv;
3030 int rc; 2966 int rc;
3031 2967
3032 mutex_lock(&btv->lock);
3033 rc = v4l2_prio_change(&btv->prio, &fh->prio, prio); 2968 rc = v4l2_prio_change(&btv->prio, &fh->prio, prio);
3034 mutex_unlock(&btv->lock);
3035 2969
3036 return rc; 2970 return rc;
3037} 2971}
@@ -3046,9 +2980,7 @@ static int bttv_cropcap(struct file *file, void *priv,
3046 cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) 2980 cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
3047 return -EINVAL; 2981 return -EINVAL;
3048 2982
3049 mutex_lock(&btv->lock);
3050 *cap = bttv_tvnorms[btv->tvnorm].cropcap; 2983 *cap = bttv_tvnorms[btv->tvnorm].cropcap;
3051 mutex_unlock(&btv->lock);
3052 2984
3053 return 0; 2985 return 0;
3054} 2986}
@@ -3066,9 +2998,7 @@ static int bttv_g_crop(struct file *file, void *f, struct v4l2_crop *crop)
3066 inconsistent with fh->width or fh->height and apps 2998 inconsistent with fh->width or fh->height and apps
3067 do not expect a change here. */ 2999 do not expect a change here. */
3068 3000
3069 mutex_lock(&btv->lock);
3070 crop->c = btv->crop[!!fh->do_crop].rect; 3001 crop->c = btv->crop[!!fh->do_crop].rect;
3071 mutex_unlock(&btv->lock);
3072 3002
3073 return 0; 3003 return 0;
3074} 3004}
@@ -3092,17 +3022,14 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3092 /* Make sure tvnorm, vbi_end and the current cropping 3022 /* Make sure tvnorm, vbi_end and the current cropping
3093 parameters remain consistent until we're done. Note 3023 parameters remain consistent until we're done. Note
3094 read() may change vbi_end in check_alloc_btres_lock(). */ 3024 read() may change vbi_end in check_alloc_btres_lock(). */
3095 mutex_lock(&btv->lock);
3096 retval = v4l2_prio_check(&btv->prio, fh->prio); 3025 retval = v4l2_prio_check(&btv->prio, fh->prio);
3097 if (0 != retval) { 3026 if (0 != retval) {
3098 mutex_unlock(&btv->lock);
3099 return retval; 3027 return retval;
3100 } 3028 }
3101 3029
3102 retval = -EBUSY; 3030 retval = -EBUSY;
3103 3031
3104 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { 3032 if (locked_btres(fh->btv, VIDEO_RESOURCES)) {
3105 mutex_unlock(&btv->lock);
3106 return retval; 3033 return retval;
3107 } 3034 }
3108 3035
@@ -3114,7 +3041,6 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3114 3041
3115 b_top = max(b->top, btv->vbi_end); 3042 b_top = max(b->top, btv->vbi_end);
3116 if (b_top + 32 >= b_bottom) { 3043 if (b_top + 32 >= b_bottom) {
3117 mutex_unlock(&btv->lock);
3118 return retval; 3044 return retval;
3119 } 3045 }
3120 3046
@@ -3137,12 +3063,8 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3137 3063
3138 btv->crop[1] = c; 3064 btv->crop[1] = c;
3139 3065
3140 mutex_unlock(&btv->lock);
3141
3142 fh->do_crop = 1; 3066 fh->do_crop = 1;
3143 3067
3144 mutex_lock(&fh->cap.vb_lock);
3145
3146 if (fh->width < c.min_scaled_width) { 3068 if (fh->width < c.min_scaled_width) {
3147 fh->width = c.min_scaled_width; 3069 fh->width = c.min_scaled_width;
3148 btv->init.width = c.min_scaled_width; 3070 btv->init.width = c.min_scaled_width;
@@ -3159,8 +3081,6 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
3159 btv->init.height = c.max_scaled_height; 3081 btv->init.height = c.max_scaled_height;
3160 } 3082 }
3161 3083
3162 mutex_unlock(&fh->cap.vb_lock);
3163
3164 return 0; 3084 return 0;
3165} 3085}
3166 3086
@@ -3228,7 +3148,6 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3228 return videobuf_poll_stream(file, &fh->vbi, wait); 3148 return videobuf_poll_stream(file, &fh->vbi, wait);
3229 } 3149 }
3230 3150
3231 mutex_lock(&fh->cap.vb_lock);
3232 if (check_btres(fh,RESOURCE_VIDEO_STREAM)) { 3151 if (check_btres(fh,RESOURCE_VIDEO_STREAM)) {
3233 /* streaming capture */ 3152 /* streaming capture */
3234 if (list_empty(&fh->cap.stream)) 3153 if (list_empty(&fh->cap.stream))
@@ -3263,7 +3182,6 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3263 else 3182 else
3264 rc = 0; 3183 rc = 0;
3265err: 3184err:
3266 mutex_unlock(&fh->cap.vb_lock);
3267 return rc; 3185 return rc;
3268} 3186}
3269 3187
@@ -3294,23 +3212,11 @@ static int bttv_open(struct file *file)
3294 return -ENOMEM; 3212 return -ENOMEM;
3295 file->private_data = fh; 3213 file->private_data = fh;
3296 3214
3297 /*
3298 * btv is protected by btv->lock mutex, while btv->init and other
3299 * streaming vars are protected by fh->cap.vb_lock. We need to take
3300 * care of both locks to avoid troubles. However, vb_lock is used also
3301 * inside videobuf, without calling buf->lock. So, it is a very bad
3302 * idea to hold both locks at the same time.
3303 * Let's first copy btv->init at fh, holding cap.vb_lock, and then work
3304 * with the rest of init, holding btv->lock.
3305 */
3306 mutex_lock(&fh->cap.vb_lock);
3307 *fh = btv->init; 3215 *fh = btv->init;
3308 mutex_unlock(&fh->cap.vb_lock);
3309 3216
3310 fh->type = type; 3217 fh->type = type;
3311 fh->ov.setup_ok = 0; 3218 fh->ov.setup_ok = 0;
3312 3219
3313 mutex_lock(&btv->lock);
3314 v4l2_prio_open(&btv->prio, &fh->prio); 3220 v4l2_prio_open(&btv->prio, &fh->prio);
3315 3221
3316 videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, 3222 videobuf_queue_sg_init(&fh->cap, &bttv_video_qops,
@@ -3318,13 +3224,13 @@ static int bttv_open(struct file *file)
3318 V4L2_BUF_TYPE_VIDEO_CAPTURE, 3224 V4L2_BUF_TYPE_VIDEO_CAPTURE,
3319 V4L2_FIELD_INTERLACED, 3225 V4L2_FIELD_INTERLACED,
3320 sizeof(struct bttv_buffer), 3226 sizeof(struct bttv_buffer),
3321 fh, NULL); 3227 fh, &btv->lock);
3322 videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, 3228 videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops,
3323 &btv->c.pci->dev, &btv->s_lock, 3229 &btv->c.pci->dev, &btv->s_lock,
3324 V4L2_BUF_TYPE_VBI_CAPTURE, 3230 V4L2_BUF_TYPE_VBI_CAPTURE,
3325 V4L2_FIELD_SEQ_TB, 3231 V4L2_FIELD_SEQ_TB,
3326 sizeof(struct bttv_buffer), 3232 sizeof(struct bttv_buffer),
3327 fh, NULL); 3233 fh, &btv->lock);
3328 set_tvnorm(btv,btv->tvnorm); 3234 set_tvnorm(btv,btv->tvnorm);
3329 set_input(btv, btv->input, btv->tvnorm); 3235 set_input(btv, btv->input, btv->tvnorm);
3330 3236
@@ -3347,7 +3253,6 @@ static int bttv_open(struct file *file)
3347 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); 3253 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm);
3348 3254
3349 bttv_field_count(btv); 3255 bttv_field_count(btv);
3350 mutex_unlock(&btv->lock);
3351 return 0; 3256 return 0;
3352} 3257}
3353 3258
@@ -3356,7 +3261,6 @@ static int bttv_release(struct file *file)
3356 struct bttv_fh *fh = file->private_data; 3261 struct bttv_fh *fh = file->private_data;
3357 struct bttv *btv = fh->btv; 3262 struct bttv *btv = fh->btv;
3358 3263
3359 mutex_lock(&btv->lock);
3360 /* turn off overlay */ 3264 /* turn off overlay */
3361 if (check_btres(fh, RESOURCE_OVERLAY)) 3265 if (check_btres(fh, RESOURCE_OVERLAY))
3362 bttv_switch_overlay(btv,fh,NULL); 3266 bttv_switch_overlay(btv,fh,NULL);
@@ -3382,14 +3286,8 @@ static int bttv_release(struct file *file)
3382 3286
3383 /* free stuff */ 3287 /* free stuff */
3384 3288
3385 /*
3386 * videobuf uses cap.vb_lock - we should avoid holding btv->lock,
3387 * otherwise we may have dead lock conditions
3388 */
3389 mutex_unlock(&btv->lock);
3390 videobuf_mmap_free(&fh->cap); 3289 videobuf_mmap_free(&fh->cap);
3391 videobuf_mmap_free(&fh->vbi); 3290 videobuf_mmap_free(&fh->vbi);
3392 mutex_lock(&btv->lock);
3393 v4l2_prio_close(&btv->prio, fh->prio); 3291 v4l2_prio_close(&btv->prio, fh->prio);
3394 file->private_data = NULL; 3292 file->private_data = NULL;
3395 kfree(fh); 3293 kfree(fh);
@@ -3399,7 +3297,6 @@ static int bttv_release(struct file *file)
3399 3297
3400 if (!btv->users) 3298 if (!btv->users)
3401 audio_mute(btv, 1); 3299 audio_mute(btv, 1);
3402 mutex_unlock(&btv->lock);
3403 3300
3404 return 0; 3301 return 0;
3405} 3302}
@@ -3503,11 +3400,8 @@ static int radio_open(struct file *file)
3503 if (unlikely(!fh)) 3400 if (unlikely(!fh))
3504 return -ENOMEM; 3401 return -ENOMEM;
3505 file->private_data = fh; 3402 file->private_data = fh;
3506 mutex_lock(&fh->cap.vb_lock);
3507 *fh = btv->init; 3403 *fh = btv->init;
3508 mutex_unlock(&fh->cap.vb_lock);
3509 3404
3510 mutex_lock(&btv->lock);
3511 v4l2_prio_open(&btv->prio, &fh->prio); 3405 v4l2_prio_open(&btv->prio, &fh->prio);
3512 3406
3513 btv->radio_user++; 3407 btv->radio_user++;
@@ -3515,7 +3409,6 @@ static int radio_open(struct file *file)
3515 bttv_call_all(btv, tuner, s_radio); 3409 bttv_call_all(btv, tuner, s_radio);
3516 audio_input(btv,TVAUDIO_INPUT_RADIO); 3410 audio_input(btv,TVAUDIO_INPUT_RADIO);
3517 3411
3518 mutex_unlock(&btv->lock);
3519 return 0; 3412 return 0;
3520} 3413}
3521 3414
@@ -3525,7 +3418,6 @@ static int radio_release(struct file *file)
3525 struct bttv *btv = fh->btv; 3418 struct bttv *btv = fh->btv;
3526 struct rds_command cmd; 3419 struct rds_command cmd;
3527 3420
3528 mutex_lock(&btv->lock);
3529 v4l2_prio_close(&btv->prio, fh->prio); 3421 v4l2_prio_close(&btv->prio, fh->prio);
3530 file->private_data = NULL; 3422 file->private_data = NULL;
3531 kfree(fh); 3423 kfree(fh);
@@ -3533,7 +3425,6 @@ static int radio_release(struct file *file)
3533 btv->radio_user--; 3425 btv->radio_user--;
3534 3426
3535 bttv_call_all(btv, core, ioctl, RDS_CMD_CLOSE, &cmd); 3427 bttv_call_all(btv, core, ioctl, RDS_CMD_CLOSE, &cmd);
3536 mutex_unlock(&btv->lock);
3537 3428
3538 return 0; 3429 return 0;
3539} 3430}
@@ -3562,7 +3453,6 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
3562 return -EINVAL; 3453 return -EINVAL;
3563 if (0 != t->index) 3454 if (0 != t->index)
3564 return -EINVAL; 3455 return -EINVAL;
3565 mutex_lock(&btv->lock);
3566 strcpy(t->name, "Radio"); 3456 strcpy(t->name, "Radio");
3567 t->type = V4L2_TUNER_RADIO; 3457 t->type = V4L2_TUNER_RADIO;
3568 3458
@@ -3571,8 +3461,6 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
3571 if (btv->audio_mode_gpio) 3461 if (btv->audio_mode_gpio)
3572 btv->audio_mode_gpio(btv, t, 0); 3462 btv->audio_mode_gpio(btv, t, 0);
3573 3463
3574 mutex_unlock(&btv->lock);
3575
3576 return 0; 3464 return 0;
3577} 3465}
3578 3466
@@ -3693,7 +3581,7 @@ static const struct v4l2_file_operations radio_fops =
3693 .open = radio_open, 3581 .open = radio_open,
3694 .read = radio_read, 3582 .read = radio_read,
3695 .release = radio_release, 3583 .release = radio_release,
3696 .ioctl = video_ioctl2, 3584 .unlocked_ioctl = video_ioctl2,
3697 .poll = radio_poll, 3585 .poll = radio_poll,
3698}; 3586};
3699 3587
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 935e0c9a9674..c1193506131c 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -860,7 +860,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
860 860
861static const struct v4l2_file_operations qcam_fops = { 861static const struct v4l2_file_operations qcam_fops = {
862 .owner = THIS_MODULE, 862 .owner = THIS_MODULE,
863 .ioctl = video_ioctl2, 863 .unlocked_ioctl = video_ioctl2,
864 .read = qcam_read, 864 .read = qcam_read,
865}; 865};
866 866
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 6e4b19698c13..24fc00965a12 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -718,7 +718,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
718 718
719static const struct v4l2_file_operations qcam_fops = { 719static const struct v4l2_file_operations qcam_fops = {
720 .owner = THIS_MODULE, 720 .owner = THIS_MODULE,
721 .ioctl = video_ioctl2, 721 .unlocked_ioctl = video_ioctl2,
722 .read = qcam_read, 722 .read = qcam_read,
723}; 723};
724 724
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 7bc36670071a..0dfff50891e4 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -1775,7 +1775,7 @@ static const struct v4l2_file_operations cafe_v4l_fops = {
1775 .read = cafe_v4l_read, 1775 .read = cafe_v4l_read,
1776 .poll = cafe_v4l_poll, 1776 .poll = cafe_v4l_poll,
1777 .mmap = cafe_v4l_mmap, 1777 .mmap = cafe_v4l_mmap,
1778 .ioctl = video_ioctl2, 1778 .unlocked_ioctl = video_ioctl2,
1779}; 1779};
1780 1780
1781static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = { 1781static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = {
@@ -2066,8 +2066,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
2066 2066
2067 cam->sensor_addr = 0x42; 2067 cam->sensor_addr = 0x42;
2068 cam->sensor = v4l2_i2c_new_subdev_cfg(&cam->v4l2_dev, &cam->i2c_adapter, 2068 cam->sensor = v4l2_i2c_new_subdev_cfg(&cam->v4l2_dev, &cam->i2c_adapter,
2069 "ov7670", "ov7670", 0, &sensor_cfg, cam->sensor_addr, 2069 "ov7670", 0, &sensor_cfg, cam->sensor_addr, NULL);
2070 NULL);
2071 if (cam->sensor == NULL) { 2070 if (cam->sensor == NULL) {
2072 ret = -ENODEV; 2071 ret = -ENODEV;
2073 goto out_smbus; 2072 goto out_smbus;
diff --git a/drivers/media/video/cx18/cx18-alsa-pcm.c b/drivers/media/video/cx18/cx18-alsa-pcm.c
index 8f55692db36d..82d195be9197 100644
--- a/drivers/media/video/cx18/cx18-alsa-pcm.c
+++ b/drivers/media/video/cx18/cx18-alsa-pcm.c
@@ -218,7 +218,13 @@ static int snd_cx18_pcm_capture_close(struct snd_pcm_substream *substream)
218static int snd_cx18_pcm_ioctl(struct snd_pcm_substream *substream, 218static int snd_cx18_pcm_ioctl(struct snd_pcm_substream *substream,
219 unsigned int cmd, void *arg) 219 unsigned int cmd, void *arg)
220{ 220{
221 return snd_pcm_lib_ioctl(substream, cmd, arg); 221 struct snd_cx18_card *cxsc = snd_pcm_substream_chip(substream);
222 int ret;
223
224 snd_cx18_lock(cxsc);
225 ret = snd_pcm_lib_ioctl(substream, cmd, arg);
226 snd_cx18_unlock(cxsc);
227 return ret;
222} 228}
223 229
224 230
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c
index a09caf883170..e71a026f3419 100644
--- a/drivers/media/video/cx18/cx18-i2c.c
+++ b/drivers/media/video/cx18/cx18-i2c.c
@@ -122,15 +122,15 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)
122 if (hw == CX18_HW_TUNER) { 122 if (hw == CX18_HW_TUNER) {
123 /* special tuner group handling */ 123 /* special tuner group handling */
124 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, 124 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev,
125 adap, NULL, type, 0, cx->card_i2c->radio); 125 adap, type, 0, cx->card_i2c->radio);
126 if (sd != NULL) 126 if (sd != NULL)
127 sd->grp_id = hw; 127 sd->grp_id = hw;
128 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, 128 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev,
129 adap, NULL, type, 0, cx->card_i2c->demod); 129 adap, type, 0, cx->card_i2c->demod);
130 if (sd != NULL) 130 if (sd != NULL)
131 sd->grp_id = hw; 131 sd->grp_id = hw;
132 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, 132 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev,
133 adap, NULL, type, 0, cx->card_i2c->tv); 133 adap, type, 0, cx->card_i2c->tv);
134 if (sd != NULL) 134 if (sd != NULL)
135 sd->grp_id = hw; 135 sd->grp_id = hw;
136 return sd != NULL ? 0 : -1; 136 return sd != NULL ? 0 : -1;
@@ -144,7 +144,7 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)
144 return -1; 144 return -1;
145 145
146 /* It's an I2C device other than an analog tuner or IR chip */ 146 /* It's an I2C device other than an analog tuner or IR chip */
147 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, adap, NULL, type, hw_addrs[idx], 147 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, adap, type, hw_addrs[idx],
148 NULL); 148 NULL);
149 if (sd != NULL) 149 if (sd != NULL)
150 sd->grp_id = hw; 150 sd->grp_id = hw;
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 9045f1ece0eb..ab461e27d9dd 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -41,7 +41,7 @@ static struct v4l2_file_operations cx18_v4l2_enc_fops = {
41 .read = cx18_v4l2_read, 41 .read = cx18_v4l2_read,
42 .open = cx18_v4l2_open, 42 .open = cx18_v4l2_open,
43 /* FIXME change to video_ioctl2 if serialization lock can be removed */ 43 /* FIXME change to video_ioctl2 if serialization lock can be removed */
44 .ioctl = cx18_v4l2_ioctl, 44 .unlocked_ioctl = cx18_v4l2_ioctl,
45 .release = cx18_v4l2_close, 45 .release = cx18_v4l2_close,
46 .poll = cx18_v4l2_enc_poll, 46 .poll = cx18_v4l2_enc_poll,
47}; 47};
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c
index 56c2d8195ac6..2c78d188bb06 100644
--- a/drivers/media/video/cx231xx/cx231xx-cards.c
+++ b/drivers/media/video/cx231xx/cx231xx-cards.c
@@ -560,7 +560,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
560 if (dev->board.decoder == CX231XX_AVDECODER) { 560 if (dev->board.decoder == CX231XX_AVDECODER) {
561 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, 561 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
562 &dev->i2c_bus[0].i2c_adap, 562 &dev->i2c_bus[0].i2c_adap,
563 NULL, "cx25840", 0x88 >> 1, NULL); 563 "cx25840", 0x88 >> 1, NULL);
564 if (dev->sd_cx25840 == NULL) 564 if (dev->sd_cx25840 == NULL)
565 cx231xx_info("cx25840 subdev registration failure\n"); 565 cx231xx_info("cx25840 subdev registration failure\n");
566 cx25840_call(dev, core, load_fw); 566 cx25840_call(dev, core, load_fw);
@@ -571,7 +571,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
571 if (dev->board.tuner_type != TUNER_ABSENT) { 571 if (dev->board.tuner_type != TUNER_ABSENT) {
572 dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, 572 dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev,
573 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 573 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
574 NULL, "tuner", 574 "tuner",
575 dev->tuner_addr, NULL); 575 dev->tuner_addr, NULL);
576 if (dev->sd_tuner == NULL) 576 if (dev->sd_tuner == NULL)
577 cx231xx_info("tuner subdev registration failure\n"); 577 cx231xx_info("tuner subdev registration failure\n");
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index db054004e462..8861309268b1 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -1247,7 +1247,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1247 case CX23885_BOARD_LEADTEK_WINFAST_PXTV1200: 1247 case CX23885_BOARD_LEADTEK_WINFAST_PXTV1200:
1248 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, 1248 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1249 &dev->i2c_bus[2].i2c_adap, 1249 &dev->i2c_bus[2].i2c_adap,
1250 NULL, "cx25840", 0x88 >> 1, NULL); 1250 "cx25840", 0x88 >> 1, NULL);
1251 if (dev->sd_cx25840) { 1251 if (dev->sd_cx25840) {
1252 dev->sd_cx25840->grp_id = CX23885_HW_AV_CORE; 1252 dev->sd_cx25840->grp_id = CX23885_HW_AV_CORE;
1253 v4l2_subdev_call(dev->sd_cx25840, core, load_fw); 1253 v4l2_subdev_call(dev->sd_cx25840, core, load_fw);
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 3cc9f462d08d..8b2fb8a4375c 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -1507,10 +1507,10 @@ int cx23885_video_register(struct cx23885_dev *dev)
1507 if (dev->tuner_addr) 1507 if (dev->tuner_addr)
1508 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, 1508 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1509 &dev->i2c_bus[1].i2c_adap, 1509 &dev->i2c_bus[1].i2c_adap,
1510 NULL, "tuner", dev->tuner_addr, NULL); 1510 "tuner", dev->tuner_addr, NULL);
1511 else 1511 else
1512 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, 1512 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1513 &dev->i2c_bus[1].i2c_adap, NULL, 1513 &dev->i2c_bus[1].i2c_adap,
1514 "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_TV)); 1514 "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_TV));
1515 if (sd) { 1515 if (sd) {
1516 struct tuner_setup tun_setup; 1516 struct tuner_setup tun_setup;
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 417d1d5c73c4..d7c94848249e 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -33,7 +33,6 @@
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/firmware.h> 35#include <linux/firmware.h>
36#include <linux/smp_lock.h>
37#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
38#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
39#include <media/cx2341x.h> 38#include <media/cx2341x.h>
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index b26fcba8600c..9b9e169cce90 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -3515,19 +3515,18 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3515 later code configures a tea5767. 3515 later code configures a tea5767.
3516 */ 3516 */
3517 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, 3517 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
3518 NULL, "tuner", 3518 "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_RADIO));
3519 0, v4l2_i2c_tuner_addrs(ADDRS_RADIO));
3520 if (has_demod) 3519 if (has_demod)
3521 v4l2_i2c_new_subdev(&core->v4l2_dev, 3520 v4l2_i2c_new_subdev(&core->v4l2_dev,
3522 &core->i2c_adap, NULL, "tuner", 3521 &core->i2c_adap, "tuner",
3523 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); 3522 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
3524 if (core->board.tuner_addr == ADDR_UNSET) { 3523 if (core->board.tuner_addr == ADDR_UNSET) {
3525 v4l2_i2c_new_subdev(&core->v4l2_dev, 3524 v4l2_i2c_new_subdev(&core->v4l2_dev,
3526 &core->i2c_adap, NULL, "tuner", 3525 &core->i2c_adap, "tuner",
3527 0, has_demod ? tv_addrs + 4 : tv_addrs); 3526 0, has_demod ? tv_addrs + 4 : tv_addrs);
3528 } else { 3527 } else {
3529 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, 3528 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
3530 NULL, "tuner", core->board.tuner_addr, NULL); 3529 "tuner", core->board.tuner_addr, NULL);
3531 } 3530 }
3532 } 3531 }
3533 3532
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index d2f159daa8b5..62cea9549404 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -31,7 +31,6 @@
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>
35#include <linux/interrupt.h> 34#include <linux/interrupt.h>
36#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
37#include <linux/delay.h> 36#include <linux/delay.h>
@@ -1896,14 +1895,13 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1896 1895
1897 if (core->board.audio_chip == V4L2_IDENT_WM8775) 1896 if (core->board.audio_chip == V4L2_IDENT_WM8775)
1898 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, 1897 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
1899 NULL, "wm8775", 0x36 >> 1, NULL); 1898 "wm8775", 0x36 >> 1, NULL);
1900 1899
1901 if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) { 1900 if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) {
1902 /* This probes for a tda9874 as is used on some 1901 /* This probes for a tda9874 as is used on some
1903 Pixelview Ultra boards. */ 1902 Pixelview Ultra boards. */
1904 v4l2_i2c_new_subdev(&core->v4l2_dev, 1903 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
1905 &core->i2c_adap, 1904 "tvaudio", 0, I2C_ADDRS(0xb0 >> 1));
1906 NULL, "tvaudio", 0, I2C_ADDRS(0xb0 >> 1));
1907 } 1905 }
1908 1906
1909 switch (core->boardnr) { 1907 switch (core->boardnr) {
diff --git a/drivers/media/video/davinci/vpfe_capture.c b/drivers/media/video/davinci/vpfe_capture.c
index d8e38cc4ec40..7333a9bb2549 100644
--- a/drivers/media/video/davinci/vpfe_capture.c
+++ b/drivers/media/video/davinci/vpfe_capture.c
@@ -1986,7 +1986,6 @@ static __init int vpfe_probe(struct platform_device *pdev)
1986 vpfe_dev->sd[i] = 1986 vpfe_dev->sd[i] =
1987 v4l2_i2c_new_subdev_board(&vpfe_dev->v4l2_dev, 1987 v4l2_i2c_new_subdev_board(&vpfe_dev->v4l2_dev,
1988 i2c_adap, 1988 i2c_adap,
1989 NULL,
1990 &sdinfo->board_info, 1989 &sdinfo->board_info,
1991 NULL); 1990 NULL);
1992 if (vpfe_dev->sd[i]) { 1991 if (vpfe_dev->sd[i]) {
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index 6ac6acd16352..193abab6b355 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -2013,7 +2013,6 @@ static __init int vpif_probe(struct platform_device *pdev)
2013 vpif_obj.sd[i] = 2013 vpif_obj.sd[i] =
2014 v4l2_i2c_new_subdev_board(&vpif_obj.v4l2_dev, 2014 v4l2_i2c_new_subdev_board(&vpif_obj.v4l2_dev,
2015 i2c_adap, 2015 i2c_adap,
2016 NULL,
2017 &subdevdata->board_info, 2016 &subdevdata->board_info,
2018 NULL); 2017 NULL);
2019 2018
diff --git a/drivers/media/video/davinci/vpif_display.c b/drivers/media/video/davinci/vpif_display.c
index 685f6a6ee603..412c65d54fe1 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -1553,7 +1553,7 @@ static __init int vpif_probe(struct platform_device *pdev)
1553 1553
1554 for (i = 0; i < subdev_count; i++) { 1554 for (i = 0; i < subdev_count; i++) {
1555 vpif_obj.sd[i] = v4l2_i2c_new_subdev_board(&vpif_obj.v4l2_dev, 1555 vpif_obj.sd[i] = v4l2_i2c_new_subdev_board(&vpif_obj.v4l2_dev,
1556 i2c_adap, NULL, 1556 i2c_adap,
1557 &subdevdata[i].board_info, 1557 &subdevdata[i].board_info,
1558 NULL); 1558 NULL);
1559 if (!vpif_obj.sd[i]) { 1559 if (!vpif_obj.sd[i]) {
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 54859233f311..f7e9168157a5 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -2554,39 +2554,39 @@ void em28xx_card_setup(struct em28xx *dev)
2554 /* request some modules */ 2554 /* request some modules */
2555 if (dev->board.has_msp34xx) 2555 if (dev->board.has_msp34xx)
2556 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 2556 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2557 NULL, "msp3400", 0, msp3400_addrs); 2557 "msp3400", 0, msp3400_addrs);
2558 2558
2559 if (dev->board.decoder == EM28XX_SAA711X) 2559 if (dev->board.decoder == EM28XX_SAA711X)
2560 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 2560 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2561 NULL, "saa7115_auto", 0, saa711x_addrs); 2561 "saa7115_auto", 0, saa711x_addrs);
2562 2562
2563 if (dev->board.decoder == EM28XX_TVP5150) 2563 if (dev->board.decoder == EM28XX_TVP5150)
2564 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 2564 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2565 NULL, "tvp5150", 0, tvp5150_addrs); 2565 "tvp5150", 0, tvp5150_addrs);
2566 2566
2567 if (dev->em28xx_sensor == EM28XX_MT9V011) { 2567 if (dev->em28xx_sensor == EM28XX_MT9V011) {
2568 struct v4l2_subdev *sd; 2568 struct v4l2_subdev *sd;
2569 2569
2570 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, 2570 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
2571 &dev->i2c_adap, NULL, "mt9v011", 0, mt9v011_addrs); 2571 &dev->i2c_adap, "mt9v011", 0, mt9v011_addrs);
2572 v4l2_subdev_call(sd, core, s_config, 0, &dev->sensor_xtal); 2572 v4l2_subdev_call(sd, core, s_config, 0, &dev->sensor_xtal);
2573 } 2573 }
2574 2574
2575 2575
2576 if (dev->board.adecoder == EM28XX_TVAUDIO) 2576 if (dev->board.adecoder == EM28XX_TVAUDIO)
2577 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 2577 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2578 NULL, "tvaudio", dev->board.tvaudio_addr, NULL); 2578 "tvaudio", dev->board.tvaudio_addr, NULL);
2579 2579
2580 if (dev->board.tuner_type != TUNER_ABSENT) { 2580 if (dev->board.tuner_type != TUNER_ABSENT) {
2581 int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); 2581 int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);
2582 2582
2583 if (dev->board.radio.type) 2583 if (dev->board.radio.type)
2584 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 2584 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2585 NULL, "tuner", dev->board.radio_addr, NULL); 2585 "tuner", dev->board.radio_addr, NULL);
2586 2586
2587 if (has_demod) 2587 if (has_demod)
2588 v4l2_i2c_new_subdev(&dev->v4l2_dev, 2588 v4l2_i2c_new_subdev(&dev->v4l2_dev,
2589 &dev->i2c_adap, NULL, "tuner", 2589 &dev->i2c_adap, "tuner",
2590 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); 2590 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
2591 if (dev->tuner_addr == 0) { 2591 if (dev->tuner_addr == 0) {
2592 enum v4l2_i2c_tuner_type type = 2592 enum v4l2_i2c_tuner_type type =
@@ -2594,14 +2594,14 @@ void em28xx_card_setup(struct em28xx *dev)
2594 struct v4l2_subdev *sd; 2594 struct v4l2_subdev *sd;
2595 2595
2596 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, 2596 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
2597 &dev->i2c_adap, NULL, "tuner", 2597 &dev->i2c_adap, "tuner",
2598 0, v4l2_i2c_tuner_addrs(type)); 2598 0, v4l2_i2c_tuner_addrs(type));
2599 2599
2600 if (sd) 2600 if (sd)
2601 dev->tuner_addr = v4l2_i2c_subdev_addr(sd); 2601 dev->tuner_addr = v4l2_i2c_subdev_addr(sd);
2602 } else { 2602 } else {
2603 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 2603 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2604 NULL, "tuner", dev->tuner_addr, NULL); 2604 "tuner", dev->tuner_addr, NULL);
2605 } 2605 }
2606 } 2606 }
2607 2607
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index a5cfc76b40b7..bb164099ea2c 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -2530,7 +2530,7 @@ static const struct v4l2_file_operations et61x251_fops = {
2530 .owner = THIS_MODULE, 2530 .owner = THIS_MODULE,
2531 .open = et61x251_open, 2531 .open = et61x251_open,
2532 .release = et61x251_release, 2532 .release = et61x251_release,
2533 .ioctl = et61x251_ioctl, 2533 .unlocked_ioctl = et61x251_ioctl,
2534 .read = et61x251_read, 2534 .read = et61x251_read,
2535 .poll = et61x251_poll, 2535 .poll = et61x251_poll,
2536 .mmap = et61x251_mmap, 2536 .mmap = et61x251_mmap,
diff --git a/drivers/media/video/fsl-viu.c b/drivers/media/video/fsl-viu.c
index 9a075d83dd1f..b8faff2dd711 100644
--- a/drivers/media/video/fsl-viu.c
+++ b/drivers/media/video/fsl-viu.c
@@ -1486,7 +1486,7 @@ static int __devinit viu_of_probe(struct platform_device *op,
1486 1486
1487 ad = i2c_get_adapter(0); 1487 ad = i2c_get_adapter(0);
1488 viu_dev->decoder = v4l2_i2c_new_subdev(&viu_dev->v4l2_dev, ad, 1488 viu_dev->decoder = v4l2_i2c_new_subdev(&viu_dev->v4l2_dev, ad,
1489 NULL, "saa7113", VIU_VIDEO_DECODER_ADDR, NULL); 1489 "saa7113", VIU_VIDEO_DECODER_ADDR, NULL);
1490 1490
1491 viu_dev->vidq.timeout.function = viu_vid_timeout; 1491 viu_dev->vidq.timeout.function = viu_vid_timeout;
1492 viu_dev->vidq.timeout.data = (unsigned long)viu_dev; 1492 viu_dev->vidq.timeout.data = (unsigned long)viu_dev;
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 330dadc00106..e23de57e2c73 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -63,7 +63,10 @@ struct sd {
63#define QUALITY_DEF 80 63#define QUALITY_DEF 80
64 u8 jpegqual; /* webcam quality */ 64 u8 jpegqual; /* webcam quality */
65 65
66 u8 reg01;
67 u8 reg17;
66 u8 reg18; 68 u8 reg18;
69 u8 flags;
67 70
68 s8 ag_cnt; 71 s8 ag_cnt;
69#define AG_CNT_START 13 72#define AG_CNT_START 13
@@ -96,6 +99,22 @@ enum sensors {
96 SENSOR_SP80708, 99 SENSOR_SP80708,
97}; 100};
98 101
102/* device flags */
103#define PDN_INV 1 /* inverse pin S_PWR_DN / sn_xxx tables */
104
105/* sn9c1xx definitions */
106/* register 0x01 */
107#define S_PWR_DN 0x01 /* sensor power down */
108#define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */
109#define V_TX_EN 0x04 /* video transfer enable */
110#define LED 0x08 /* output to pin LED */
111#define SCL_SEL_OD 0x20 /* open-drain mode */
112#define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */
113/* register 0x17 */
114#define MCK_SIZE_MASK 0x1f /* sensor master clock */
115#define SEN_CLK_EN 0x20 /* enable sensor clock */
116#define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */
117
99/* V4L2 controls supported by the driver */ 118/* V4L2 controls supported by the driver */
100static void setbrightness(struct gspca_dev *gspca_dev); 119static void setbrightness(struct gspca_dev *gspca_dev);
101static void setcontrast(struct gspca_dev *gspca_dev); 120static void setcontrast(struct gspca_dev *gspca_dev);
@@ -1755,141 +1774,6 @@ static void po2030n_probe(struct gspca_dev *gspca_dev)
1755 } 1774 }
1756} 1775}
1757 1776
1758static void bridge_init(struct gspca_dev *gspca_dev,
1759 const u8 *sn9c1xx)
1760{
1761 struct sd *sd = (struct sd *) gspca_dev;
1762 u8 reg0102[2];
1763 const u8 *reg9a;
1764 static const u8 reg9a_def[] =
1765 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1766 static const u8 reg9a_spec[] =
1767 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1768 static const u8 regd4[] = {0x60, 0x00, 0x00};
1769
1770 /* sensor clock already enabled in sd_init */
1771 /* reg_w1(gspca_dev, 0xf1, 0x00); */
1772 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1773
1774 /* configure gpio */
1775 reg0102[0] = sn9c1xx[1];
1776 reg0102[1] = sn9c1xx[2];
1777 if (gspca_dev->audio)
1778 reg0102[1] |= 0x04; /* keep the audio connection */
1779 reg_w(gspca_dev, 0x01, reg0102, 2);
1780 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
1781 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
1782 switch (sd->sensor) {
1783 case SENSOR_GC0307:
1784 case SENSOR_OV7660:
1785 case SENSOR_PO1030:
1786 case SENSOR_PO2030N:
1787 case SENSOR_SOI768:
1788 case SENSOR_SP80708:
1789 reg9a = reg9a_spec;
1790 break;
1791 default:
1792 reg9a = reg9a_def;
1793 break;
1794 }
1795 reg_w(gspca_dev, 0x9a, reg9a, 6);
1796
1797 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
1798
1799 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
1800
1801 switch (sd->sensor) {
1802 case SENSOR_ADCM1700:
1803 reg_w1(gspca_dev, 0x01, 0x43);
1804 reg_w1(gspca_dev, 0x17, 0x62);
1805 reg_w1(gspca_dev, 0x01, 0x42);
1806 reg_w1(gspca_dev, 0x01, 0x42);
1807 break;
1808 case SENSOR_GC0307:
1809 msleep(50);
1810 reg_w1(gspca_dev, 0x01, 0x61);
1811 reg_w1(gspca_dev, 0x17, 0x22);
1812 reg_w1(gspca_dev, 0x01, 0x60);
1813 reg_w1(gspca_dev, 0x01, 0x40);
1814 msleep(50);
1815 break;
1816 case SENSOR_MI0360B:
1817 reg_w1(gspca_dev, 0x01, 0x61);
1818 reg_w1(gspca_dev, 0x17, 0x60);
1819 reg_w1(gspca_dev, 0x01, 0x60);
1820 reg_w1(gspca_dev, 0x01, 0x40);
1821 break;
1822 case SENSOR_MT9V111:
1823 reg_w1(gspca_dev, 0x01, 0x61);
1824 reg_w1(gspca_dev, 0x17, 0x61);
1825 reg_w1(gspca_dev, 0x01, 0x60);
1826 reg_w1(gspca_dev, 0x01, 0x40);
1827 break;
1828 case SENSOR_OM6802:
1829 msleep(10);
1830 reg_w1(gspca_dev, 0x02, 0x73);
1831 reg_w1(gspca_dev, 0x17, 0x60);
1832 reg_w1(gspca_dev, 0x01, 0x22);
1833 msleep(100);
1834 reg_w1(gspca_dev, 0x01, 0x62);
1835 reg_w1(gspca_dev, 0x17, 0x64);
1836 reg_w1(gspca_dev, 0x17, 0x64);
1837 reg_w1(gspca_dev, 0x01, 0x42);
1838 msleep(10);
1839 reg_w1(gspca_dev, 0x01, 0x42);
1840 i2c_w8(gspca_dev, om6802_init0[0]);
1841 i2c_w8(gspca_dev, om6802_init0[1]);
1842 msleep(15);
1843 reg_w1(gspca_dev, 0x02, 0x71);
1844 msleep(150);
1845 break;
1846 case SENSOR_OV7630:
1847 reg_w1(gspca_dev, 0x01, 0x61);
1848 reg_w1(gspca_dev, 0x17, 0xe2);
1849 reg_w1(gspca_dev, 0x01, 0x60);
1850 reg_w1(gspca_dev, 0x01, 0x40);
1851 break;
1852 case SENSOR_OV7648:
1853 reg_w1(gspca_dev, 0x01, 0x63);
1854 reg_w1(gspca_dev, 0x17, 0x20);
1855 reg_w1(gspca_dev, 0x01, 0x62);
1856 reg_w1(gspca_dev, 0x01, 0x42);
1857 break;
1858 case SENSOR_PO1030:
1859 case SENSOR_SOI768:
1860 reg_w1(gspca_dev, 0x01, 0x61);
1861 reg_w1(gspca_dev, 0x17, 0x20);
1862 reg_w1(gspca_dev, 0x01, 0x60);
1863 reg_w1(gspca_dev, 0x01, 0x40);
1864 break;
1865 case SENSOR_PO2030N:
1866 case SENSOR_OV7660:
1867 reg_w1(gspca_dev, 0x01, 0x63);
1868 reg_w1(gspca_dev, 0x17, 0x20);
1869 reg_w1(gspca_dev, 0x01, 0x62);
1870 reg_w1(gspca_dev, 0x01, 0x42);
1871 break;
1872 case SENSOR_SP80708:
1873 reg_w1(gspca_dev, 0x01, 0x63);
1874 reg_w1(gspca_dev, 0x17, 0x20);
1875 reg_w1(gspca_dev, 0x01, 0x62);
1876 reg_w1(gspca_dev, 0x01, 0x42);
1877 msleep(100);
1878 reg_w1(gspca_dev, 0x02, 0x62);
1879 break;
1880 default:
1881/* case SENSOR_HV7131R: */
1882/* case SENSOR_MI0360: */
1883/* case SENSOR_MO4000: */
1884 reg_w1(gspca_dev, 0x01, 0x43);
1885 reg_w1(gspca_dev, 0x17, 0x61);
1886 reg_w1(gspca_dev, 0x01, 0x42);
1887 if (sd->sensor == SENSOR_HV7131R)
1888 hv7131r_probe(gspca_dev);
1889 break;
1890 }
1891}
1892
1893/* this function is called at probe time */ 1777/* this function is called at probe time */
1894static int sd_config(struct gspca_dev *gspca_dev, 1778static int sd_config(struct gspca_dev *gspca_dev,
1895 const struct usb_device_id *id) 1779 const struct usb_device_id *id)
@@ -1898,7 +1782,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
1898 struct cam *cam; 1782 struct cam *cam;
1899 1783
1900 sd->bridge = id->driver_info >> 16; 1784 sd->bridge = id->driver_info >> 16;
1901 sd->sensor = id->driver_info; 1785 sd->sensor = id->driver_info >> 8;
1786 sd->flags = id->driver_info;
1902 1787
1903 cam = &gspca_dev->cam; 1788 cam = &gspca_dev->cam;
1904 if (sd->sensor == SENSOR_ADCM1700) { 1789 if (sd->sensor == SENSOR_ADCM1700) {
@@ -1929,7 +1814,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
1929 /* setup a selector by bridge */ 1814 /* setup a selector by bridge */
1930 reg_w1(gspca_dev, 0xf1, 0x01); 1815 reg_w1(gspca_dev, 0xf1, 0x01);
1931 reg_r(gspca_dev, 0x00, 1); 1816 reg_r(gspca_dev, 0x00, 1);
1932 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]); 1817 reg_w1(gspca_dev, 0xf1, 0x00);
1933 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ 1818 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
1934 regF1 = gspca_dev->usb_buf[0]; 1819 regF1 = gspca_dev->usb_buf[0];
1935 if (gspca_dev->usb_err < 0) 1820 if (gspca_dev->usb_err < 0)
@@ -2423,10 +2308,17 @@ static int sd_start(struct gspca_dev *gspca_dev)
2423{ 2308{
2424 struct sd *sd = (struct sd *) gspca_dev; 2309 struct sd *sd = (struct sd *) gspca_dev;
2425 int i; 2310 int i;
2426 u8 reg1, reg17; 2311 u8 reg01, reg17;
2312 u8 reg0102[2];
2427 const u8 *sn9c1xx; 2313 const u8 *sn9c1xx;
2428 const u8 (*init)[8]; 2314 const u8 (*init)[8];
2315 const u8 *reg9a;
2429 int mode; 2316 int mode;
2317 static const u8 reg9a_def[] =
2318 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
2319 static const u8 reg9a_spec[] =
2320 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
2321 static const u8 regd4[] = {0x60, 0x00, 0x00};
2430 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; 2322 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2431 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; 2323 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
2432 static const u8 CA_adcm1700[] = 2324 static const u8 CA_adcm1700[] =
@@ -2448,7 +2340,85 @@ static int sd_start(struct gspca_dev *gspca_dev)
2448 2340
2449 /* initialize the bridge */ 2341 /* initialize the bridge */
2450 sn9c1xx = sn_tb[sd->sensor]; 2342 sn9c1xx = sn_tb[sd->sensor];
2451 bridge_init(gspca_dev, sn9c1xx); 2343
2344 /* sensor clock already enabled in sd_init */
2345 /* reg_w1(gspca_dev, 0xf1, 0x00); */
2346 reg01 = sn9c1xx[1];
2347 if (sd->flags & PDN_INV)
2348 reg01 ^= S_PDN_INV; /* power down inverted */
2349 reg_w1(gspca_dev, 0x01, reg01);
2350
2351 /* configure gpio */
2352 reg0102[0] = reg01;
2353 reg0102[1] = sn9c1xx[2];
2354 if (gspca_dev->audio)
2355 reg0102[1] |= 0x04; /* keep the audio connection */
2356 reg_w(gspca_dev, 0x01, reg0102, 2);
2357 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
2358 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
2359 switch (sd->sensor) {
2360 case SENSOR_GC0307:
2361 case SENSOR_OV7660:
2362 case SENSOR_PO1030:
2363 case SENSOR_PO2030N:
2364 case SENSOR_SOI768:
2365 case SENSOR_SP80708:
2366 reg9a = reg9a_spec;
2367 break;
2368 default:
2369 reg9a = reg9a_def;
2370 break;
2371 }
2372 reg_w(gspca_dev, 0x9a, reg9a, 6);
2373
2374 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
2375
2376 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
2377
2378 reg17 = sn9c1xx[0x17];
2379 switch (sd->sensor) {
2380 case SENSOR_GC0307:
2381 msleep(50); /*fixme: is it useful? */
2382 break;
2383 case SENSOR_OM6802:
2384 msleep(10);
2385 reg_w1(gspca_dev, 0x02, 0x73);
2386 reg17 |= SEN_CLK_EN;
2387 reg_w1(gspca_dev, 0x17, reg17);
2388 reg_w1(gspca_dev, 0x01, 0x22);
2389 msleep(100);
2390 reg01 = SCL_SEL_OD | S_PDN_INV;
2391 reg17 &= MCK_SIZE_MASK;
2392 reg17 |= 0x04; /* clock / 4 */
2393 break;
2394 }
2395 reg01 |= SYS_SEL_48M;
2396 reg_w1(gspca_dev, 0x01, reg01);
2397 reg17 |= SEN_CLK_EN;
2398 reg_w1(gspca_dev, 0x17, reg17);
2399 reg01 &= ~S_PWR_DN; /* sensor power on */
2400 reg_w1(gspca_dev, 0x01, reg01);
2401 reg01 &= ~SYS_SEL_48M;
2402 reg_w1(gspca_dev, 0x01, reg01);
2403
2404 switch (sd->sensor) {
2405 case SENSOR_HV7131R:
2406 hv7131r_probe(gspca_dev); /*fixme: is it useful? */
2407 break;
2408 case SENSOR_OM6802:
2409 msleep(10);
2410 reg_w1(gspca_dev, 0x01, reg01);
2411 i2c_w8(gspca_dev, om6802_init0[0]);
2412 i2c_w8(gspca_dev, om6802_init0[1]);
2413 msleep(15);
2414 reg_w1(gspca_dev, 0x02, 0x71);
2415 msleep(150);
2416 break;
2417 case SENSOR_SP80708:
2418 msleep(100);
2419 reg_w1(gspca_dev, 0x02, 0x62);
2420 break;
2421 }
2452 2422
2453 /* initialize the sensor */ 2423 /* initialize the sensor */
2454 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); 2424 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
@@ -2476,30 +2446,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
2476 } 2446 }
2477 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); 2447 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
2478 switch (sd->sensor) { 2448 switch (sd->sensor) {
2479 case SENSOR_GC0307: 2449 case SENSOR_OM6802:
2480 reg17 = 0xa2; 2450/* case SENSOR_OV7648: * fixme: sometimes */
2481 break;
2482 case SENSOR_MT9V111:
2483 case SENSOR_MI0360B:
2484 reg17 = 0xe0;
2485 break;
2486 case SENSOR_ADCM1700:
2487 case SENSOR_OV7630:
2488 reg17 = 0xe2;
2489 break;
2490 case SENSOR_OV7648:
2491 reg17 = 0x20;
2492 break;
2493 case SENSOR_OV7660:
2494 case SENSOR_SOI768:
2495 reg17 = 0xa0;
2496 break;
2497 case SENSOR_PO1030:
2498 case SENSOR_PO2030N:
2499 reg17 = 0xa0;
2500 break; 2451 break;
2501 default: 2452 default:
2502 reg17 = 0x60; 2453 reg17 |= DEF_EN;
2503 break; 2454 break;
2504 } 2455 }
2505 reg_w1(gspca_dev, 0x17, reg17); 2456 reg_w1(gspca_dev, 0x17, reg17);
@@ -2546,95 +2497,67 @@ static int sd_start(struct gspca_dev *gspca_dev)
2546 2497
2547 init = NULL; 2498 init = NULL;
2548 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; 2499 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
2549 if (mode) 2500 reg01 |= SYS_SEL_48M | V_TX_EN;
2550 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */ 2501 reg17 &= ~MCK_SIZE_MASK;
2551 else 2502 reg17 |= 0x02; /* clock / 2 */
2552 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2553 reg17 = 0x61; /* 0x:20: enable sensor clock */
2554 switch (sd->sensor) { 2503 switch (sd->sensor) {
2555 case SENSOR_ADCM1700: 2504 case SENSOR_ADCM1700:
2556 init = adcm1700_sensor_param1; 2505 init = adcm1700_sensor_param1;
2557 reg1 = 0x46;
2558 reg17 = 0xe2;
2559 break; 2506 break;
2560 case SENSOR_GC0307: 2507 case SENSOR_GC0307:
2561 init = gc0307_sensor_param1; 2508 init = gc0307_sensor_param1;
2562 reg17 = 0xa2; 2509 break;
2563 reg1 = 0x44; 2510 case SENSOR_HV7131R:
2511 case SENSOR_MI0360:
2512 if (mode)
2513 reg01 |= SYS_SEL_48M; /* 320x240: clk 48Mhz */
2514 else
2515 reg01 &= ~SYS_SEL_48M; /* 640x480: clk 24Mhz */
2516 reg17 &= ~MCK_SIZE_MASK;
2517 reg17 |= 0x01; /* clock / 1 */
2564 break; 2518 break;
2565 case SENSOR_MI0360B: 2519 case SENSOR_MI0360B:
2566 init = mi0360b_sensor_param1; 2520 init = mi0360b_sensor_param1;
2567 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2568 reg17 = 0xe2;
2569 break; 2521 break;
2570 case SENSOR_MO4000: 2522 case SENSOR_MO4000:
2571 if (mode) { 2523 if (mode) { /* if 320x240 */
2572/* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ 2524 reg01 &= ~SYS_SEL_48M; /* clk 24Mz */
2573 reg1 = 0x06; /* clk 24Mz */ 2525 reg17 &= ~MCK_SIZE_MASK;
2574 } else { 2526 reg17 |= 0x01; /* clock / 1 */
2575 reg17 = 0x22; /* 640 MCKSIZE */
2576/* reg1 = 0x06; * 640 clk 24Mz (done) */
2577 } 2527 }
2578 break; 2528 break;
2579 case SENSOR_MT9V111: 2529 case SENSOR_MT9V111:
2580 init = mt9v111_sensor_param1; 2530 init = mt9v111_sensor_param1;
2581 if (mode) {
2582 reg1 = 0x04; /* 320 clk 48Mhz */
2583 } else {
2584/* reg1 = 0x06; * 640 clk 24Mz (done) */
2585 reg17 = 0xc2;
2586 }
2587 break; 2531 break;
2588 case SENSOR_OM6802: 2532 case SENSOR_OM6802:
2589 init = om6802_sensor_param1; 2533 init = om6802_sensor_param1;
2590 reg17 = 0x64; /* 640 MCKSIZE */ 2534 if (!mode) { /* if 640x480 */
2535 reg17 &= ~MCK_SIZE_MASK;
2536 reg17 |= 0x01; /* clock / 4 */
2537 }
2591 break; 2538 break;
2592 case SENSOR_OV7630: 2539 case SENSOR_OV7630:
2593 init = ov7630_sensor_param1; 2540 init = ov7630_sensor_param1;
2594 reg17 = 0xe2;
2595 reg1 = 0x44;
2596 break; 2541 break;
2597 case SENSOR_OV7648: 2542 case SENSOR_OV7648:
2598 init = ov7648_sensor_param1; 2543 init = ov7648_sensor_param1;
2599 reg17 = 0x21; 2544 reg17 &= ~MCK_SIZE_MASK;
2600/* reg1 = 0x42; * 42 - 46? */ 2545 reg17 |= 0x01; /* clock / 1 */
2601 break; 2546 break;
2602 case SENSOR_OV7660: 2547 case SENSOR_OV7660:
2603 init = ov7660_sensor_param1; 2548 init = ov7660_sensor_param1;
2604 if (sd->bridge == BRIDGE_SN9C120) {
2605 if (mode) { /* 320x240 - 160x120 */
2606 reg17 = 0xa2;
2607 reg1 = 0x44; /* 48 Mhz, video trf eneble */
2608 }
2609 } else {
2610 reg17 = 0x22;
2611 reg1 = 0x06; /* 24 Mhz, video trf eneble
2612 * inverse power down */
2613 }
2614 break; 2549 break;
2615 case SENSOR_PO1030: 2550 case SENSOR_PO1030:
2616 init = po1030_sensor_param1; 2551 init = po1030_sensor_param1;
2617 reg17 = 0xa2;
2618 reg1 = 0x44;
2619 break; 2552 break;
2620 case SENSOR_PO2030N: 2553 case SENSOR_PO2030N:
2621 init = po2030n_sensor_param1; 2554 init = po2030n_sensor_param1;
2622 reg1 = 0x46;
2623 reg17 = 0xa2;
2624 break; 2555 break;
2625 case SENSOR_SOI768: 2556 case SENSOR_SOI768:
2626 init = soi768_sensor_param1; 2557 init = soi768_sensor_param1;
2627 reg1 = 0x44;
2628 reg17 = 0xa2;
2629 break; 2558 break;
2630 case SENSOR_SP80708: 2559 case SENSOR_SP80708:
2631 init = sp80708_sensor_param1; 2560 init = sp80708_sensor_param1;
2632 if (mode) {
2633/*?? reg1 = 0x04; * 320 clk 48Mhz */
2634 } else {
2635 reg1 = 0x46; /* 640 clk 48Mz */
2636 reg17 = 0xa2;
2637 }
2638 break; 2561 break;
2639 } 2562 }
2640 2563
@@ -2684,7 +2607,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
2684 setjpegqual(gspca_dev); 2607 setjpegqual(gspca_dev);
2685 2608
2686 reg_w1(gspca_dev, 0x17, reg17); 2609 reg_w1(gspca_dev, 0x17, reg17);
2687 reg_w1(gspca_dev, 0x01, reg1); 2610 reg_w1(gspca_dev, 0x01, reg01);
2611 sd->reg01 = reg01;
2612 sd->reg17 = reg17;
2688 2613
2689 sethvflip(gspca_dev); 2614 sethvflip(gspca_dev);
2690 setbrightness(gspca_dev); 2615 setbrightness(gspca_dev);
@@ -2706,41 +2631,64 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2706 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; 2631 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
2707 static const u8 stopsoi768[] = 2632 static const u8 stopsoi768[] =
2708 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 }; 2633 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
2709 u8 data; 2634 u8 reg01;
2710 const u8 *sn9c1xx; 2635 u8 reg17;
2711 2636
2712 data = 0x0b; 2637 reg01 = sd->reg01;
2638 reg17 = sd->reg17 & ~SEN_CLK_EN;
2713 switch (sd->sensor) { 2639 switch (sd->sensor) {
2640 case SENSOR_ADCM1700:
2714 case SENSOR_GC0307: 2641 case SENSOR_GC0307:
2715 data = 0x29; 2642 case SENSOR_PO2030N:
2643 case SENSOR_SP80708:
2644 reg01 |= LED;
2645 reg_w1(gspca_dev, 0x01, reg01);
2646 reg01 &= ~(LED | V_TX_EN);
2647 reg_w1(gspca_dev, 0x01, reg01);
2648/* reg_w1(gspca_dev, 0x02, 0x??); * LED off ? */
2716 break; 2649 break;
2717 case SENSOR_HV7131R: 2650 case SENSOR_HV7131R:
2651 reg01 &= ~V_TX_EN;
2652 reg_w1(gspca_dev, 0x01, reg01);
2718 i2c_w8(gspca_dev, stophv7131); 2653 i2c_w8(gspca_dev, stophv7131);
2719 data = 0x2b;
2720 break; 2654 break;
2721 case SENSOR_MI0360: 2655 case SENSOR_MI0360:
2722 case SENSOR_MI0360B: 2656 case SENSOR_MI0360B:
2657 reg01 &= ~V_TX_EN;
2658 reg_w1(gspca_dev, 0x01, reg01);
2659/* reg_w1(gspca_dev, 0x02, 0x40); * LED off ? */
2723 i2c_w8(gspca_dev, stopmi0360); 2660 i2c_w8(gspca_dev, stopmi0360);
2724 data = 0x29;
2725 break; 2661 break;
2726 case SENSOR_OV7648:
2727 i2c_w8(gspca_dev, stopov7648);
2728 /* fall thru */
2729 case SENSOR_MT9V111: 2662 case SENSOR_MT9V111:
2730 case SENSOR_OV7630: 2663 case SENSOR_OM6802:
2731 case SENSOR_PO1030: 2664 case SENSOR_PO1030:
2732 data = 0x29; 2665 reg01 &= ~V_TX_EN;
2666 reg_w1(gspca_dev, 0x01, reg01);
2667 break;
2668 case SENSOR_OV7630:
2669 case SENSOR_OV7648:
2670 reg01 &= ~V_TX_EN;
2671 reg_w1(gspca_dev, 0x01, reg01);
2672 i2c_w8(gspca_dev, stopov7648);
2673 break;
2674 case SENSOR_OV7660:
2675 reg01 &= ~V_TX_EN;
2676 reg_w1(gspca_dev, 0x01, reg01);
2733 break; 2677 break;
2734 case SENSOR_SOI768: 2678 case SENSOR_SOI768:
2735 i2c_w8(gspca_dev, stopsoi768); 2679 i2c_w8(gspca_dev, stopsoi768);
2736 data = 0x29;
2737 break; 2680 break;
2738 } 2681 }
2739 sn9c1xx = sn_tb[sd->sensor]; 2682
2740 reg_w1(gspca_dev, 0x01, sn9c1xx[1]); 2683 reg01 |= SCL_SEL_OD;
2741 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); 2684 reg_w1(gspca_dev, 0x01, reg01);
2742 reg_w1(gspca_dev, 0x01, sn9c1xx[1]); 2685 reg01 |= S_PWR_DN; /* sensor power down */
2743 reg_w1(gspca_dev, 0x01, data); 2686 reg_w1(gspca_dev, 0x01, reg01);
2687 reg_w1(gspca_dev, 0x17, reg17);
2688 reg01 &= ~SYS_SEL_48M; /* clock 24MHz */
2689 reg_w1(gspca_dev, 0x01, reg01);
2690 reg01 |= LED;
2691 reg_w1(gspca_dev, 0x01, reg01);
2744 /* Don't disable sensor clock as that disables the button on the cam */ 2692 /* Don't disable sensor clock as that disables the button on the cam */
2745 /* reg_w1(gspca_dev, 0xf1, 0x01); */ 2693 /* reg_w1(gspca_dev, 0xf1, 0x01); */
2746} 2694}
@@ -2954,14 +2902,18 @@ static const struct sd_desc sd_desc = {
2954/* -- module initialisation -- */ 2902/* -- module initialisation -- */
2955#define BS(bridge, sensor) \ 2903#define BS(bridge, sensor) \
2956 .driver_info = (BRIDGE_ ## bridge << 16) \ 2904 .driver_info = (BRIDGE_ ## bridge << 16) \
2957 | SENSOR_ ## sensor 2905 | (SENSOR_ ## sensor << 8)
2906#define BSF(bridge, sensor, flags) \
2907 .driver_info = (BRIDGE_ ## bridge << 16) \
2908 | (SENSOR_ ## sensor << 8) \
2909 | (flags)
2958static const __devinitdata struct usb_device_id device_table[] = { 2910static const __devinitdata struct usb_device_id device_table[] = {
2959#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 2911#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2960 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, 2912 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2961 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, 2913 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
2962#endif 2914#endif
2963 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)}, 2915 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)},
2964 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)}, 2916 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)},
2965 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, 2917 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2966 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, 2918 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2967 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, 2919 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 9e8039ac909e..665191c9b407 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -239,19 +239,16 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
239 return -1; 239 return -1;
240 if (hw == IVTV_HW_TUNER) { 240 if (hw == IVTV_HW_TUNER) {
241 /* special tuner handling */ 241 /* special tuner handling */
242 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, 242 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0,
243 adap, NULL, type, 243 itv->card_i2c->radio);
244 0, itv->card_i2c->radio);
245 if (sd) 244 if (sd)
246 sd->grp_id = 1 << idx; 245 sd->grp_id = 1 << idx;
247 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, 246 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0,
248 adap, NULL, type, 247 itv->card_i2c->demod);
249 0, itv->card_i2c->demod);
250 if (sd) 248 if (sd)
251 sd->grp_id = 1 << idx; 249 sd->grp_id = 1 << idx;
252 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, 250 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, adap, type, 0,
253 adap, NULL, type, 251 itv->card_i2c->tv);
254 0, itv->card_i2c->tv);
255 if (sd) 252 if (sd)
256 sd->grp_id = 1 << idx; 253 sd->grp_id = 1 << idx;
257 return sd ? 0 : -1; 254 return sd ? 0 : -1;
@@ -267,17 +264,16 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
267 /* It's an I2C device other than an analog tuner or IR chip */ 264 /* It's an I2C device other than an analog tuner or IR chip */
268 if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) { 265 if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) {
269 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, 266 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
270 adap, NULL, type, 0, I2C_ADDRS(hw_addrs[idx])); 267 adap, type, 0, I2C_ADDRS(hw_addrs[idx]));
271 } else if (hw == IVTV_HW_CX25840) { 268 } else if (hw == IVTV_HW_CX25840) {
272 struct cx25840_platform_data pdata; 269 struct cx25840_platform_data pdata;
273 270
274 pdata.pvr150_workaround = itv->pvr150_workaround; 271 pdata.pvr150_workaround = itv->pvr150_workaround;
275 sd = v4l2_i2c_new_subdev_cfg(&itv->v4l2_dev, 272 sd = v4l2_i2c_new_subdev_cfg(&itv->v4l2_dev,
276 adap, NULL, type, 0, &pdata, hw_addrs[idx], 273 adap, type, 0, &pdata, hw_addrs[idx], NULL);
277 NULL);
278 } else { 274 } else {
279 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, 275 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
280 adap, NULL, type, hw_addrs[idx], NULL); 276 adap, type, hw_addrs[idx], NULL);
281 } 277 }
282 if (sd) 278 if (sd)
283 sd->grp_id = 1 << idx; 279 sd->grp_id = 1 << idx;
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 2be23bccd3c8..48d2c2419c13 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -1659,7 +1659,7 @@ static const struct v4l2_file_operations meye_fops = {
1659 .open = meye_open, 1659 .open = meye_open,
1660 .release = meye_release, 1660 .release = meye_release,
1661 .mmap = meye_mmap, 1661 .mmap = meye_mmap,
1662 .ioctl = video_ioctl2, 1662 .unlocked_ioctl = video_ioctl2,
1663 .poll = meye_poll, 1663 .poll = meye_poll,
1664}; 1664};
1665 1665
@@ -1831,12 +1831,6 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1831 msleep(1); 1831 msleep(1);
1832 mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK); 1832 mchip_set(MCHIP_MM_INTA, MCHIP_MM_INTA_HIC_1_MASK);
1833 1833
1834 if (video_register_device(meye.vdev, VFL_TYPE_GRABBER,
1835 video_nr) < 0) {
1836 v4l2_err(v4l2_dev, "video_register_device failed\n");
1837 goto outvideoreg;
1838 }
1839
1840 mutex_init(&meye.lock); 1834 mutex_init(&meye.lock);
1841 init_waitqueue_head(&meye.proc_list); 1835 init_waitqueue_head(&meye.proc_list);
1842 meye.brightness = 32 << 10; 1836 meye.brightness = 32 << 10;
@@ -1858,6 +1852,12 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
1858 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, 0); 1852 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, 0);
1859 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC, 48); 1853 sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC, 48);
1860 1854
1855 if (video_register_device(meye.vdev, VFL_TYPE_GRABBER,
1856 video_nr) < 0) {
1857 v4l2_err(v4l2_dev, "video_register_device failed\n");
1858 goto outvideoreg;
1859 }
1860
1861 v4l2_info(v4l2_dev, "Motion Eye Camera Driver v%s.\n", 1861 v4l2_info(v4l2_dev, "Motion Eye Camera Driver v%s.\n",
1862 MEYE_DRIVER_VERSION); 1862 MEYE_DRIVER_VERSION);
1863 v4l2_info(v4l2_dev, "mchip KL5A72002 rev. %d, base %lx, irq %d\n", 1863 v4l2_info(v4l2_dev, "mchip KL5A72002 rev. %d, base %lx, irq %d\n",
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 94ba698d0ad4..4e8fd965f151 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -185,17 +185,17 @@ static int mxb_probe(struct saa7146_dev *dev)
185 } 185 }
186 186
187 mxb->saa7111a = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, 187 mxb->saa7111a = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
188 NULL, "saa7111", I2C_SAA7111A, NULL); 188 "saa7111", I2C_SAA7111A, NULL);
189 mxb->tea6420_1 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, 189 mxb->tea6420_1 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
190 NULL, "tea6420", I2C_TEA6420_1, NULL); 190 "tea6420", I2C_TEA6420_1, NULL);
191 mxb->tea6420_2 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, 191 mxb->tea6420_2 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
192 NULL, "tea6420", I2C_TEA6420_2, NULL); 192 "tea6420", I2C_TEA6420_2, NULL);
193 mxb->tea6415c = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, 193 mxb->tea6415c = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
194 NULL, "tea6415c", I2C_TEA6415C, NULL); 194 "tea6415c", I2C_TEA6415C, NULL);
195 mxb->tda9840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, 195 mxb->tda9840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
196 NULL, "tda9840", I2C_TDA9840, NULL); 196 "tda9840", I2C_TDA9840, NULL);
197 mxb->tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter, 197 mxb->tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
198 NULL, "tuner", I2C_TUNER, NULL); 198 "tuner", I2C_TUNER, NULL);
199 199
200 /* check if all devices are present */ 200 /* check if all devices are present */
201 if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c || 201 if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c ||
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 7129b50757db..7551907f8c28 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -932,7 +932,7 @@ static ssize_t pms_read(struct file *file, char __user *buf,
932 932
933static const struct v4l2_file_operations pms_fops = { 933static const struct v4l2_file_operations pms_fops = {
934 .owner = THIS_MODULE, 934 .owner = THIS_MODULE,
935 .ioctl = video_ioctl2, 935 .unlocked_ioctl = video_ioctl2,
936 .read = pms_read, 936 .read = pms_read,
937}; 937};
938 938
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index bef202752cc8..66ad516bdfd9 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -2088,16 +2088,14 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
2088 " Setting up with specified i2c address 0x%x", 2088 " Setting up with specified i2c address 0x%x",
2089 mid, i2caddr[0]); 2089 mid, i2caddr[0]);
2090 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, 2090 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap,
2091 NULL, fname, 2091 fname, i2caddr[0], NULL);
2092 i2caddr[0], NULL);
2093 } else { 2092 } else {
2094 pvr2_trace(PVR2_TRACE_INIT, 2093 pvr2_trace(PVR2_TRACE_INIT,
2095 "Module ID %u:" 2094 "Module ID %u:"
2096 " Setting up with address probe list", 2095 " Setting up with address probe list",
2097 mid); 2096 mid);
2098 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap, 2097 sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap,
2099 NULL, fname, 2098 fname, 0, i2caddr);
2100 0, i2caddr);
2101 } 2099 }
2102 2100
2103 if (!sd) { 2101 if (!sd) {
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index e62beb4efdb4..f3dc89da4c4e 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -62,7 +62,6 @@
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>
66#ifdef CONFIG_USB_PWC_INPUT_EVDEV 65#ifdef CONFIG_USB_PWC_INPUT_EVDEV
67#include <linux/usb/input.h> 66#include <linux/usb/input.h>
68#endif 67#endif
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index f5a46c458717..a845753665c1 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -49,7 +49,6 @@
49#include <linux/videodev2.h> 49#include <linux/videodev2.h>
50#include <linux/version.h> 50#include <linux/version.h>
51#include <linux/mm.h> 51#include <linux/mm.h>
52#include <linux/smp_lock.h>
53#include <media/videobuf-vmalloc.h> 52#include <media/videobuf-vmalloc.h>
54#include <media/v4l2-common.h> 53#include <media/v4l2-common.h>
55#include <media/v4l2-device.h> 54#include <media/v4l2-device.h>
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
index e8f13d3e2df1..1b93207c89e8 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -44,7 +44,7 @@ static struct v4l2_subdev *fimc_subdev_register(struct fimc_dev *fimc,
44 return ERR_PTR(-ENOMEM); 44 return ERR_PTR(-ENOMEM);
45 45
46 sd = v4l2_i2c_new_subdev_board(&vid_cap->v4l2_dev, i2c_adap, 46 sd = v4l2_i2c_new_subdev_board(&vid_cap->v4l2_dev, i2c_adap,
47 MODULE_NAME, isp_info->board_info, NULL); 47 isp_info->board_info, NULL);
48 if (!sd) { 48 if (!sd) {
49 v4l2_err(&vid_cap->v4l2_dev, "failed to acquire subdev\n"); 49 v4l2_err(&vid_cap->v4l2_dev, "failed to acquire subdev\n");
50 return NULL; 50 return NULL;
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 0911cb580e18..1d4d0a49ea52 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -7551,22 +7551,22 @@ int saa7134_board_init2(struct saa7134_dev *dev)
7551 so we do not need to probe for a radio tuner device. */ 7551 so we do not need to probe for a radio tuner device. */
7552 if (dev->radio_type != UNSET) 7552 if (dev->radio_type != UNSET)
7553 v4l2_i2c_new_subdev(&dev->v4l2_dev, 7553 v4l2_i2c_new_subdev(&dev->v4l2_dev,
7554 &dev->i2c_adap, NULL, "tuner", 7554 &dev->i2c_adap, "tuner",
7555 dev->radio_addr, NULL); 7555 dev->radio_addr, NULL);
7556 if (has_demod) 7556 if (has_demod)
7557 v4l2_i2c_new_subdev(&dev->v4l2_dev, 7557 v4l2_i2c_new_subdev(&dev->v4l2_dev,
7558 &dev->i2c_adap, NULL, "tuner", 7558 &dev->i2c_adap, "tuner",
7559 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); 7559 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
7560 if (dev->tuner_addr == ADDR_UNSET) { 7560 if (dev->tuner_addr == ADDR_UNSET) {
7561 enum v4l2_i2c_tuner_type type = 7561 enum v4l2_i2c_tuner_type type =
7562 has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; 7562 has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
7563 7563
7564 v4l2_i2c_new_subdev(&dev->v4l2_dev, 7564 v4l2_i2c_new_subdev(&dev->v4l2_dev,
7565 &dev->i2c_adap, NULL, "tuner", 7565 &dev->i2c_adap, "tuner",
7566 0, v4l2_i2c_tuner_addrs(type)); 7566 0, v4l2_i2c_tuner_addrs(type));
7567 } else { 7567 } else {
7568 v4l2_i2c_new_subdev(&dev->v4l2_dev, 7568 v4l2_i2c_new_subdev(&dev->v4l2_dev,
7569 &dev->i2c_adap, NULL, "tuner", 7569 &dev->i2c_adap, "tuner",
7570 dev->tuner_addr, NULL); 7570 dev->tuner_addr, NULL);
7571 } 7571 }
7572 } 7572 }
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 764d7d219fed..756a27812260 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -991,7 +991,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
991 if (card_is_empress(dev)) { 991 if (card_is_empress(dev)) {
992 struct v4l2_subdev *sd = 992 struct v4l2_subdev *sd =
993 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 993 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
994 NULL, "saa6752hs", 994 "saa6752hs",
995 saa7134_boards[dev->board].empress_addr, NULL); 995 saa7134_boards[dev->board].empress_addr, NULL);
996 996
997 if (sd) 997 if (sd)
@@ -1002,7 +1002,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1002 struct v4l2_subdev *sd; 1002 struct v4l2_subdev *sd;
1003 1003
1004 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, 1004 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1005 &dev->i2c_adap, NULL, "saa6588", 1005 &dev->i2c_adap, "saa6588",
1006 0, I2C_ADDRS(saa7134_boards[dev->board].rds_addr)); 1006 0, I2C_ADDRS(saa7134_boards[dev->board].rds_addr));
1007 if (sd) { 1007 if (sd) {
1008 printk(KERN_INFO "%s: found RDS decoder\n", dev->name); 1008 printk(KERN_INFO "%s: found RDS decoder\n", dev->name);
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 1467a30a434f..b890aafe7d64 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -21,7 +21,6 @@
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/smp_lock.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26 25
27#include "saa7134-reg.h" 26#include "saa7134-reg.h"
diff --git a/drivers/media/video/saa7164/saa7164.h b/drivers/media/video/saa7164/saa7164.h
index 1d9c5cbbbc52..041ae8e20f68 100644
--- a/drivers/media/video/saa7164/saa7164.h
+++ b/drivers/media/video/saa7164/saa7164.h
@@ -58,7 +58,6 @@
58#include <media/tveeprom.h> 58#include <media/tveeprom.h>
59#include <media/videobuf-dma-sg.h> 59#include <media/videobuf-dma-sg.h>
60#include <media/videobuf-dvb.h> 60#include <media/videobuf-dvb.h>
61#include <linux/smp_lock.h>
62#include <dvb_demux.h> 61#include <dvb_demux.h>
63#include <dvb_frontend.h> 62#include <dvb_frontend.h>
64#include <dvb_net.h> 63#include <dvb_net.h>
diff --git a/drivers/media/video/sh_vou.c b/drivers/media/video/sh_vou.c
index 0f4906136b8f..07cf0c6c7c1f 100644
--- a/drivers/media/video/sh_vou.c
+++ b/drivers/media/video/sh_vou.c
@@ -75,6 +75,7 @@ struct sh_vou_device {
75 int pix_idx; 75 int pix_idx;
76 struct videobuf_buffer *active; 76 struct videobuf_buffer *active;
77 enum sh_vou_status status; 77 enum sh_vou_status status;
78 struct mutex fop_lock;
78}; 79};
79 80
80struct sh_vou_file { 81struct sh_vou_file {
@@ -235,7 +236,7 @@ static void free_buffer(struct videobuf_queue *vq, struct videobuf_buffer *vb)
235 vb->state = VIDEOBUF_NEEDS_INIT; 236 vb->state = VIDEOBUF_NEEDS_INIT;
236} 237}
237 238
238/* Locking: caller holds vq->vb_lock mutex */ 239/* Locking: caller holds fop_lock mutex */
239static int sh_vou_buf_setup(struct videobuf_queue *vq, unsigned int *count, 240static int sh_vou_buf_setup(struct videobuf_queue *vq, unsigned int *count,
240 unsigned int *size) 241 unsigned int *size)
241{ 242{
@@ -257,7 +258,7 @@ static int sh_vou_buf_setup(struct videobuf_queue *vq, unsigned int *count,
257 return 0; 258 return 0;
258} 259}
259 260
260/* Locking: caller holds vq->vb_lock mutex */ 261/* Locking: caller holds fop_lock mutex */
261static int sh_vou_buf_prepare(struct videobuf_queue *vq, 262static int sh_vou_buf_prepare(struct videobuf_queue *vq,
262 struct videobuf_buffer *vb, 263 struct videobuf_buffer *vb,
263 enum v4l2_field field) 264 enum v4l2_field field)
@@ -306,7 +307,7 @@ static int sh_vou_buf_prepare(struct videobuf_queue *vq,
306 return 0; 307 return 0;
307} 308}
308 309
309/* Locking: caller holds vq->vb_lock mutex and vq->irqlock spinlock */ 310/* Locking: caller holds fop_lock mutex and vq->irqlock spinlock */
310static void sh_vou_buf_queue(struct videobuf_queue *vq, 311static void sh_vou_buf_queue(struct videobuf_queue *vq,
311 struct videobuf_buffer *vb) 312 struct videobuf_buffer *vb)
312{ 313{
@@ -1190,7 +1191,7 @@ static int sh_vou_open(struct file *file)
1190 V4L2_BUF_TYPE_VIDEO_OUTPUT, 1191 V4L2_BUF_TYPE_VIDEO_OUTPUT,
1191 V4L2_FIELD_NONE, 1192 V4L2_FIELD_NONE,
1192 sizeof(struct videobuf_buffer), vdev, 1193 sizeof(struct videobuf_buffer), vdev,
1193 NULL); 1194 &vou_dev->fop_lock);
1194 1195
1195 return 0; 1196 return 0;
1196} 1197}
@@ -1292,7 +1293,7 @@ static const struct v4l2_file_operations sh_vou_fops = {
1292 .owner = THIS_MODULE, 1293 .owner = THIS_MODULE,
1293 .open = sh_vou_open, 1294 .open = sh_vou_open,
1294 .release = sh_vou_release, 1295 .release = sh_vou_release,
1295 .ioctl = video_ioctl2, 1296 .unlocked_ioctl = video_ioctl2,
1296 .mmap = sh_vou_mmap, 1297 .mmap = sh_vou_mmap,
1297 .poll = sh_vou_poll, 1298 .poll = sh_vou_poll,
1298}; 1299};
@@ -1331,6 +1332,7 @@ static int __devinit sh_vou_probe(struct platform_device *pdev)
1331 1332
1332 INIT_LIST_HEAD(&vou_dev->queue); 1333 INIT_LIST_HEAD(&vou_dev->queue);
1333 spin_lock_init(&vou_dev->lock); 1334 spin_lock_init(&vou_dev->lock);
1335 mutex_init(&vou_dev->fop_lock);
1334 atomic_set(&vou_dev->use_count, 0); 1336 atomic_set(&vou_dev->use_count, 0);
1335 vou_dev->pdata = vou_pdata; 1337 vou_dev->pdata = vou_pdata;
1336 vou_dev->status = SH_VOU_IDLE; 1338 vou_dev->status = SH_VOU_IDLE;
@@ -1388,6 +1390,7 @@ static int __devinit sh_vou_probe(struct platform_device *pdev)
1388 vdev->tvnorms |= V4L2_STD_PAL; 1390 vdev->tvnorms |= V4L2_STD_PAL;
1389 vdev->v4l2_dev = &vou_dev->v4l2_dev; 1391 vdev->v4l2_dev = &vou_dev->v4l2_dev;
1390 vdev->release = video_device_release; 1392 vdev->release = video_device_release;
1393 vdev->lock = &vou_dev->fop_lock;
1391 1394
1392 vou_dev->vdev = vdev; 1395 vou_dev->vdev = vdev;
1393 video_set_drvdata(vdev, vou_dev); 1396 video_set_drvdata(vdev, vou_dev);
@@ -1406,7 +1409,7 @@ static int __devinit sh_vou_probe(struct platform_device *pdev)
1406 goto ereset; 1409 goto ereset;
1407 1410
1408 subdev = v4l2_i2c_new_subdev_board(&vou_dev->v4l2_dev, i2c_adap, 1411 subdev = v4l2_i2c_new_subdev_board(&vou_dev->v4l2_dev, i2c_adap,
1409 NULL, vou_pdata->board_info, NULL); 1412 vou_pdata->board_info, NULL);
1410 if (!subdev) { 1413 if (!subdev) {
1411 ret = -ENOMEM; 1414 ret = -ENOMEM;
1412 goto ei2cnd; 1415 goto ei2cnd;
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 28e19daadec9..f49fbfb7dc13 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -3238,7 +3238,7 @@ static const struct v4l2_file_operations sn9c102_fops = {
3238 .owner = THIS_MODULE, 3238 .owner = THIS_MODULE,
3239 .open = sn9c102_open, 3239 .open = sn9c102_open,
3240 .release = sn9c102_release, 3240 .release = sn9c102_release,
3241 .ioctl = sn9c102_ioctl, 3241 .unlocked_ioctl = sn9c102_ioctl,
3242 .read = sn9c102_read, 3242 .read = sn9c102_read,
3243 .poll = sn9c102_poll, 3243 .poll = sn9c102_poll,
3244 .mmap = sn9c102_mmap, 3244 .mmap = sn9c102_mmap,
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 43848a751d11..335120c2021b 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -896,7 +896,7 @@ static int soc_camera_init_i2c(struct soc_camera_device *icd,
896 icl->board_info->platform_data = icd; 896 icl->board_info->platform_data = icd;
897 897
898 subdev = v4l2_i2c_new_subdev_board(&ici->v4l2_dev, adap, 898 subdev = v4l2_i2c_new_subdev_board(&ici->v4l2_dev, adap,
899 NULL, icl->board_info, NULL); 899 icl->board_info, NULL);
900 if (!subdev) 900 if (!subdev)
901 goto ei2cnd; 901 goto ei2cnd;
902 902
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index e3bbae26e3ce..81dd53bb5267 100644
--- a/drivers/media/video/usbvision/usbvision-i2c.c
+++ b/drivers/media/video/usbvision/usbvision-i2c.c
@@ -251,7 +251,7 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
251 hit-and-miss. */ 251 hit-and-miss. */
252 mdelay(10); 252 mdelay(10);
253 v4l2_i2c_new_subdev(&usbvision->v4l2_dev, 253 v4l2_i2c_new_subdev(&usbvision->v4l2_dev,
254 &usbvision->i2c_adap, NULL, 254 &usbvision->i2c_adap,
255 "saa7115_auto", 0, saa711x_addrs); 255 "saa7115_auto", 0, saa711x_addrs);
256 break; 256 break;
257 } 257 }
@@ -261,14 +261,14 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
261 struct tuner_setup tun_setup; 261 struct tuner_setup tun_setup;
262 262
263 sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev, 263 sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev,
264 &usbvision->i2c_adap, NULL, 264 &usbvision->i2c_adap,
265 "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); 265 "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
266 /* depending on whether we found a demod or not, select 266 /* depending on whether we found a demod or not, select
267 the tuner type. */ 267 the tuner type. */
268 type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; 268 type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
269 269
270 sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev, 270 sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev,
271 &usbvision->i2c_adap, NULL, 271 &usbvision->i2c_adap,
272 "tuner", 0, v4l2_i2c_tuner_addrs(type)); 272 "tuner", 0, v4l2_i2c_tuner_addrs(type));
273 273
274 if (sd == NULL) 274 if (sd == NULL)
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index db6b828594f5..011c0c386995 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -50,7 +50,6 @@
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>
54#include <linux/mm.h> 53#include <linux/mm.h>
55#include <linux/highmem.h> 54#include <linux/highmem.h>
56#include <linux/vmalloc.h> 55#include <linux/vmalloc.h>
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index f169f7736677..59f8a9ad3796 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -785,7 +785,7 @@ static void __uvc_find_control(struct uvc_entity *entity, __u32 v4l2_id,
785 } 785 }
786} 786}
787 787
788struct uvc_control *uvc_find_control(struct uvc_video_chain *chain, 788static struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
789 __u32 v4l2_id, struct uvc_control_mapping **mapping) 789 __u32 v4l2_id, struct uvc_control_mapping **mapping)
790{ 790{
791 struct uvc_control *ctrl = NULL; 791 struct uvc_control *ctrl = NULL;
@@ -944,6 +944,52 @@ done:
944 return ret; 944 return ret;
945} 945}
946 946
947/*
948 * Mapping V4L2 controls to UVC controls can be straighforward if done well.
949 * Most of the UVC controls exist in V4L2, and can be mapped directly. Some
950 * must be grouped (for instance the Red Balance, Blue Balance and Do White
951 * Balance V4L2 controls use the White Balance Component UVC control) or
952 * otherwise translated. The approach we take here is to use a translation
953 * table for the controls that can be mapped directly, and handle the others
954 * manually.
955 */
956int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
957 struct v4l2_querymenu *query_menu)
958{
959 struct uvc_menu_info *menu_info;
960 struct uvc_control_mapping *mapping;
961 struct uvc_control *ctrl;
962 u32 index = query_menu->index;
963 u32 id = query_menu->id;
964 int ret;
965
966 memset(query_menu, 0, sizeof(*query_menu));
967 query_menu->id = id;
968 query_menu->index = index;
969
970 ret = mutex_lock_interruptible(&chain->ctrl_mutex);
971 if (ret < 0)
972 return -ERESTARTSYS;
973
974 ctrl = uvc_find_control(chain, query_menu->id, &mapping);
975 if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU) {
976 ret = -EINVAL;
977 goto done;
978 }
979
980 if (query_menu->index >= mapping->menu_count) {
981 ret = -EINVAL;
982 goto done;
983 }
984
985 menu_info = &mapping->menu_info[query_menu->index];
986 strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name);
987
988done:
989 mutex_unlock(&chain->ctrl_mutex);
990 return ret;
991}
992
947 993
948/* -------------------------------------------------------------------------- 994/* --------------------------------------------------------------------------
949 * Control transactions 995 * Control transactions
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c
index ed6d5449741c..f14581bd707f 100644
--- a/drivers/media/video/uvc/uvc_queue.c
+++ b/drivers/media/video/uvc/uvc_queue.c
@@ -90,6 +90,39 @@ void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
90} 90}
91 91
92/* 92/*
93 * Free the video buffers.
94 *
95 * This function must be called with the queue lock held.
96 */
97static int __uvc_free_buffers(struct uvc_video_queue *queue)
98{
99 unsigned int i;
100
101 for (i = 0; i < queue->count; ++i) {
102 if (queue->buffer[i].vma_use_count != 0)
103 return -EBUSY;
104 }
105
106 if (queue->count) {
107 vfree(queue->mem);
108 queue->count = 0;
109 }
110
111 return 0;
112}
113
114int uvc_free_buffers(struct uvc_video_queue *queue)
115{
116 int ret;
117
118 mutex_lock(&queue->mutex);
119 ret = __uvc_free_buffers(queue);
120 mutex_unlock(&queue->mutex);
121
122 return ret;
123}
124
125/*
93 * Allocate the video buffers. 126 * Allocate the video buffers.
94 * 127 *
95 * Pages are reserved to make sure they will not be swapped, as they will be 128 * Pages are reserved to make sure they will not be swapped, as they will be
@@ -110,7 +143,7 @@ int uvc_alloc_buffers(struct uvc_video_queue *queue, unsigned int nbuffers,
110 143
111 mutex_lock(&queue->mutex); 144 mutex_lock(&queue->mutex);
112 145
113 if ((ret = uvc_free_buffers(queue)) < 0) 146 if ((ret = __uvc_free_buffers(queue)) < 0)
114 goto done; 147 goto done;
115 148
116 /* Bail out if no buffers should be allocated. */ 149 /* Bail out if no buffers should be allocated. */
@@ -152,28 +185,6 @@ done:
152} 185}
153 186
154/* 187/*
155 * Free the video buffers.
156 *
157 * This function must be called with the queue lock held.
158 */
159int uvc_free_buffers(struct uvc_video_queue *queue)
160{
161 unsigned int i;
162
163 for (i = 0; i < queue->count; ++i) {
164 if (queue->buffer[i].vma_use_count != 0)
165 return -EBUSY;
166 }
167
168 if (queue->count) {
169 vfree(queue->mem);
170 queue->count = 0;
171 }
172
173 return 0;
174}
175
176/*
177 * Check if buffers have been allocated. 188 * Check if buffers have been allocated.
178 */ 189 */
179int uvc_queue_allocated(struct uvc_video_queue *queue) 190int uvc_queue_allocated(struct uvc_video_queue *queue)
@@ -369,6 +380,82 @@ done:
369} 380}
370 381
371/* 382/*
383 * VMA operations.
384 */
385static void uvc_vm_open(struct vm_area_struct *vma)
386{
387 struct uvc_buffer *buffer = vma->vm_private_data;
388 buffer->vma_use_count++;
389}
390
391static void uvc_vm_close(struct vm_area_struct *vma)
392{
393 struct uvc_buffer *buffer = vma->vm_private_data;
394 buffer->vma_use_count--;
395}
396
397static const struct vm_operations_struct uvc_vm_ops = {
398 .open = uvc_vm_open,
399 .close = uvc_vm_close,
400};
401
402/*
403 * Memory-map a video buffer.
404 *
405 * This function implements video buffers memory mapping and is intended to be
406 * used by the device mmap handler.
407 */
408int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
409{
410 struct uvc_buffer *uninitialized_var(buffer);
411 struct page *page;
412 unsigned long addr, start, size;
413 unsigned int i;
414 int ret = 0;
415
416 start = vma->vm_start;
417 size = vma->vm_end - vma->vm_start;
418
419 mutex_lock(&queue->mutex);
420
421 for (i = 0; i < queue->count; ++i) {
422 buffer = &queue->buffer[i];
423 if ((buffer->buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff)
424 break;
425 }
426
427 if (i == queue->count || size != queue->buf_size) {
428 ret = -EINVAL;
429 goto done;
430 }
431
432 /*
433 * VM_IO marks the area as being an mmaped region for I/O to a
434 * device. It also prevents the region from being core dumped.
435 */
436 vma->vm_flags |= VM_IO;
437
438 addr = (unsigned long)queue->mem + buffer->buf.m.offset;
439 while (size > 0) {
440 page = vmalloc_to_page((void *)addr);
441 if ((ret = vm_insert_page(vma, start, page)) < 0)
442 goto done;
443
444 start += PAGE_SIZE;
445 addr += PAGE_SIZE;
446 size -= PAGE_SIZE;
447 }
448
449 vma->vm_ops = &uvc_vm_ops;
450 vma->vm_private_data = buffer;
451 uvc_vm_open(vma);
452
453done:
454 mutex_unlock(&queue->mutex);
455 return ret;
456}
457
458/*
372 * Poll the video queue. 459 * Poll the video queue.
373 * 460 *
374 * This function implements video queue polling and is intended to be used by 461 * This function implements video queue polling and is intended to be used by
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index 6d15de9b5204..8cf61e8a634f 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -101,40 +101,6 @@ done:
101 */ 101 */
102 102
103/* 103/*
104 * Mapping V4L2 controls to UVC controls can be straighforward if done well.
105 * Most of the UVC controls exist in V4L2, and can be mapped directly. Some
106 * must be grouped (for instance the Red Balance, Blue Balance and Do White
107 * Balance V4L2 controls use the White Balance Component UVC control) or
108 * otherwise translated. The approach we take here is to use a translation
109 * table for the controls that can be mapped directly, and handle the others
110 * manually.
111 */
112static int uvc_v4l2_query_menu(struct uvc_video_chain *chain,
113 struct v4l2_querymenu *query_menu)
114{
115 struct uvc_menu_info *menu_info;
116 struct uvc_control_mapping *mapping;
117 struct uvc_control *ctrl;
118 u32 index = query_menu->index;
119 u32 id = query_menu->id;
120
121 ctrl = uvc_find_control(chain, query_menu->id, &mapping);
122 if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU)
123 return -EINVAL;
124
125 if (query_menu->index >= mapping->menu_count)
126 return -EINVAL;
127
128 memset(query_menu, 0, sizeof(*query_menu));
129 query_menu->id = id;
130 query_menu->index = index;
131
132 menu_info = &mapping->menu_info[query_menu->index];
133 strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name);
134 return 0;
135}
136
137/*
138 * Find the frame interval closest to the requested frame interval for the 104 * Find the frame interval closest to the requested frame interval for the
139 * given frame format and size. This should be done by the device as part of 105 * given frame format and size. This should be done by the device as part of
140 * the Video Probe and Commit negotiation, but some hardware don't implement 106 * the Video Probe and Commit negotiation, but some hardware don't implement
@@ -260,12 +226,14 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
260 * developers test their webcams with the Linux driver as well as with 226 * developers test their webcams with the Linux driver as well as with
261 * the Windows driver). 227 * the Windows driver).
262 */ 228 */
229 mutex_lock(&stream->mutex);
263 if (stream->dev->quirks & UVC_QUIRK_PROBE_EXTRAFIELDS) 230 if (stream->dev->quirks & UVC_QUIRK_PROBE_EXTRAFIELDS)
264 probe->dwMaxVideoFrameSize = 231 probe->dwMaxVideoFrameSize =
265 stream->ctrl.dwMaxVideoFrameSize; 232 stream->ctrl.dwMaxVideoFrameSize;
266 233
267 /* Probe the device. */ 234 /* Probe the device. */
268 ret = uvc_probe_video(stream, probe); 235 ret = uvc_probe_video(stream, probe);
236 mutex_unlock(&stream->mutex);
269 if (ret < 0) 237 if (ret < 0)
270 goto done; 238 goto done;
271 239
@@ -289,14 +257,21 @@ done:
289static int uvc_v4l2_get_format(struct uvc_streaming *stream, 257static int uvc_v4l2_get_format(struct uvc_streaming *stream,
290 struct v4l2_format *fmt) 258 struct v4l2_format *fmt)
291{ 259{
292 struct uvc_format *format = stream->cur_format; 260 struct uvc_format *format;
293 struct uvc_frame *frame = stream->cur_frame; 261 struct uvc_frame *frame;
262 int ret = 0;
294 263
295 if (fmt->type != stream->type) 264 if (fmt->type != stream->type)
296 return -EINVAL; 265 return -EINVAL;
297 266
298 if (format == NULL || frame == NULL) 267 mutex_lock(&stream->mutex);
299 return -EINVAL; 268 format = stream->cur_format;
269 frame = stream->cur_frame;
270
271 if (format == NULL || frame == NULL) {
272 ret = -EINVAL;
273 goto done;
274 }
300 275
301 fmt->fmt.pix.pixelformat = format->fcc; 276 fmt->fmt.pix.pixelformat = format->fcc;
302 fmt->fmt.pix.width = frame->wWidth; 277 fmt->fmt.pix.width = frame->wWidth;
@@ -307,7 +282,9 @@ static int uvc_v4l2_get_format(struct uvc_streaming *stream,
307 fmt->fmt.pix.colorspace = format->colorspace; 282 fmt->fmt.pix.colorspace = format->colorspace;
308 fmt->fmt.pix.priv = 0; 283 fmt->fmt.pix.priv = 0;
309 284
310 return 0; 285done:
286 mutex_unlock(&stream->mutex);
287 return ret;
311} 288}
312 289
313static int uvc_v4l2_set_format(struct uvc_streaming *stream, 290static int uvc_v4l2_set_format(struct uvc_streaming *stream,
@@ -321,18 +298,24 @@ static int uvc_v4l2_set_format(struct uvc_streaming *stream,
321 if (fmt->type != stream->type) 298 if (fmt->type != stream->type)
322 return -EINVAL; 299 return -EINVAL;
323 300
324 if (uvc_queue_allocated(&stream->queue))
325 return -EBUSY;
326
327 ret = uvc_v4l2_try_format(stream, fmt, &probe, &format, &frame); 301 ret = uvc_v4l2_try_format(stream, fmt, &probe, &format, &frame);
328 if (ret < 0) 302 if (ret < 0)
329 return ret; 303 return ret;
330 304
305 mutex_lock(&stream->mutex);
306
307 if (uvc_queue_allocated(&stream->queue)) {
308 ret = -EBUSY;
309 goto done;
310 }
311
331 memcpy(&stream->ctrl, &probe, sizeof probe); 312 memcpy(&stream->ctrl, &probe, sizeof probe);
332 stream->cur_format = format; 313 stream->cur_format = format;
333 stream->cur_frame = frame; 314 stream->cur_frame = frame;
334 315
335 return 0; 316done:
317 mutex_unlock(&stream->mutex);
318 return ret;
336} 319}
337 320
338static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream, 321static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,
@@ -343,7 +326,10 @@ static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,
343 if (parm->type != stream->type) 326 if (parm->type != stream->type)
344 return -EINVAL; 327 return -EINVAL;
345 328
329 mutex_lock(&stream->mutex);
346 numerator = stream->ctrl.dwFrameInterval; 330 numerator = stream->ctrl.dwFrameInterval;
331 mutex_unlock(&stream->mutex);
332
347 denominator = 10000000; 333 denominator = 10000000;
348 uvc_simplify_fraction(&numerator, &denominator, 8, 333); 334 uvc_simplify_fraction(&numerator, &denominator, 8, 333);
349 335
@@ -370,7 +356,6 @@ static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,
370static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream, 356static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
371 struct v4l2_streamparm *parm) 357 struct v4l2_streamparm *parm)
372{ 358{
373 struct uvc_frame *frame = stream->cur_frame;
374 struct uvc_streaming_control probe; 359 struct uvc_streaming_control probe;
375 struct v4l2_fract timeperframe; 360 struct v4l2_fract timeperframe;
376 uint32_t interval; 361 uint32_t interval;
@@ -379,28 +364,36 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
379 if (parm->type != stream->type) 364 if (parm->type != stream->type)
380 return -EINVAL; 365 return -EINVAL;
381 366
382 if (uvc_queue_streaming(&stream->queue))
383 return -EBUSY;
384
385 if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 367 if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
386 timeperframe = parm->parm.capture.timeperframe; 368 timeperframe = parm->parm.capture.timeperframe;
387 else 369 else
388 timeperframe = parm->parm.output.timeperframe; 370 timeperframe = parm->parm.output.timeperframe;
389 371
390 memcpy(&probe, &stream->ctrl, sizeof probe);
391 interval = uvc_fraction_to_interval(timeperframe.numerator, 372 interval = uvc_fraction_to_interval(timeperframe.numerator,
392 timeperframe.denominator); 373 timeperframe.denominator);
393
394 uvc_trace(UVC_TRACE_FORMAT, "Setting frame interval to %u/%u (%u).\n", 374 uvc_trace(UVC_TRACE_FORMAT, "Setting frame interval to %u/%u (%u).\n",
395 timeperframe.numerator, timeperframe.denominator, interval); 375 timeperframe.numerator, timeperframe.denominator, interval);
396 probe.dwFrameInterval = uvc_try_frame_interval(frame, interval); 376
377 mutex_lock(&stream->mutex);
378
379 if (uvc_queue_streaming(&stream->queue)) {
380 mutex_unlock(&stream->mutex);
381 return -EBUSY;
382 }
383
384 memcpy(&probe, &stream->ctrl, sizeof probe);
385 probe.dwFrameInterval =
386 uvc_try_frame_interval(stream->cur_frame, interval);
397 387
398 /* Probe the device with the new settings. */ 388 /* Probe the device with the new settings. */
399 ret = uvc_probe_video(stream, &probe); 389 ret = uvc_probe_video(stream, &probe);
400 if (ret < 0) 390 if (ret < 0) {
391 mutex_unlock(&stream->mutex);
401 return ret; 392 return ret;
393 }
402 394
403 memcpy(&stream->ctrl, &probe, sizeof probe); 395 memcpy(&stream->ctrl, &probe, sizeof probe);
396 mutex_unlock(&stream->mutex);
404 397
405 /* Return the actual frame period. */ 398 /* Return the actual frame period. */
406 timeperframe.numerator = probe.dwFrameInterval; 399 timeperframe.numerator = probe.dwFrameInterval;
@@ -528,11 +521,9 @@ static int uvc_v4l2_release(struct file *file)
528 if (uvc_has_privileges(handle)) { 521 if (uvc_has_privileges(handle)) {
529 uvc_video_enable(stream, 0); 522 uvc_video_enable(stream, 0);
530 523
531 mutex_lock(&stream->queue.mutex);
532 if (uvc_free_buffers(&stream->queue) < 0) 524 if (uvc_free_buffers(&stream->queue) < 0)
533 uvc_printk(KERN_ERR, "uvc_v4l2_release: Unable to " 525 uvc_printk(KERN_ERR, "uvc_v4l2_release: Unable to "
534 "free buffers.\n"); 526 "free buffers.\n");
535 mutex_unlock(&stream->queue.mutex);
536 } 527 }
537 528
538 /* Release the file handle. */ 529 /* Release the file handle. */
@@ -624,7 +615,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
624 } 615 }
625 616
626 case VIDIOC_QUERYMENU: 617 case VIDIOC_QUERYMENU:
627 return uvc_v4l2_query_menu(chain, arg); 618 return uvc_query_v4l2_menu(chain, arg);
628 619
629 case VIDIOC_G_EXT_CTRLS: 620 case VIDIOC_G_EXT_CTRLS:
630 { 621 {
@@ -905,15 +896,17 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
905 case VIDIOC_CROPCAP: 896 case VIDIOC_CROPCAP:
906 { 897 {
907 struct v4l2_cropcap *ccap = arg; 898 struct v4l2_cropcap *ccap = arg;
908 struct uvc_frame *frame = stream->cur_frame;
909 899
910 if (ccap->type != stream->type) 900 if (ccap->type != stream->type)
911 return -EINVAL; 901 return -EINVAL;
912 902
913 ccap->bounds.left = 0; 903 ccap->bounds.left = 0;
914 ccap->bounds.top = 0; 904 ccap->bounds.top = 0;
915 ccap->bounds.width = frame->wWidth; 905
916 ccap->bounds.height = frame->wHeight; 906 mutex_lock(&stream->mutex);
907 ccap->bounds.width = stream->cur_frame->wWidth;
908 ccap->bounds.height = stream->cur_frame->wHeight;
909 mutex_unlock(&stream->mutex);
917 910
918 ccap->defrect = ccap->bounds; 911 ccap->defrect = ccap->bounds;
919 912
@@ -930,8 +923,6 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
930 case VIDIOC_REQBUFS: 923 case VIDIOC_REQBUFS:
931 { 924 {
932 struct v4l2_requestbuffers *rb = arg; 925 struct v4l2_requestbuffers *rb = arg;
933 unsigned int bufsize =
934 stream->ctrl.dwMaxVideoFrameSize;
935 926
936 if (rb->type != stream->type || 927 if (rb->type != stream->type ||
937 rb->memory != V4L2_MEMORY_MMAP) 928 rb->memory != V4L2_MEMORY_MMAP)
@@ -940,7 +931,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
940 if ((ret = uvc_acquire_privileges(handle)) < 0) 931 if ((ret = uvc_acquire_privileges(handle)) < 0)
941 return ret; 932 return ret;
942 933
943 ret = uvc_alloc_buffers(&stream->queue, rb->count, bufsize); 934 mutex_lock(&stream->mutex);
935 ret = uvc_alloc_buffers(&stream->queue, rb->count,
936 stream->ctrl.dwMaxVideoFrameSize);
937 mutex_unlock(&stream->mutex);
944 if (ret < 0) 938 if (ret < 0)
945 return ret; 939 return ret;
946 940
@@ -988,7 +982,9 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
988 if (!uvc_has_privileges(handle)) 982 if (!uvc_has_privileges(handle))
989 return -EBUSY; 983 return -EBUSY;
990 984
985 mutex_lock(&stream->mutex);
991 ret = uvc_video_enable(stream, 1); 986 ret = uvc_video_enable(stream, 1);
987 mutex_unlock(&stream->mutex);
992 if (ret < 0) 988 if (ret < 0)
993 return ret; 989 return ret;
994 break; 990 break;
@@ -1068,79 +1064,14 @@ static ssize_t uvc_v4l2_read(struct file *file, char __user *data,
1068 return -EINVAL; 1064 return -EINVAL;
1069} 1065}
1070 1066
1071/*
1072 * VMA operations.
1073 */
1074static void uvc_vm_open(struct vm_area_struct *vma)
1075{
1076 struct uvc_buffer *buffer = vma->vm_private_data;
1077 buffer->vma_use_count++;
1078}
1079
1080static void uvc_vm_close(struct vm_area_struct *vma)
1081{
1082 struct uvc_buffer *buffer = vma->vm_private_data;
1083 buffer->vma_use_count--;
1084}
1085
1086static const struct vm_operations_struct uvc_vm_ops = {
1087 .open = uvc_vm_open,
1088 .close = uvc_vm_close,
1089};
1090
1091static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma) 1067static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1092{ 1068{
1093 struct uvc_fh *handle = file->private_data; 1069 struct uvc_fh *handle = file->private_data;
1094 struct uvc_streaming *stream = handle->stream; 1070 struct uvc_streaming *stream = handle->stream;
1095 struct uvc_video_queue *queue = &stream->queue;
1096 struct uvc_buffer *uninitialized_var(buffer);
1097 struct page *page;
1098 unsigned long addr, start, size;
1099 unsigned int i;
1100 int ret = 0;
1101 1071
1102 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_mmap\n"); 1072 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_mmap\n");
1103 1073
1104 start = vma->vm_start; 1074 return uvc_queue_mmap(&stream->queue, vma);
1105 size = vma->vm_end - vma->vm_start;
1106
1107 mutex_lock(&queue->mutex);
1108
1109 for (i = 0; i < queue->count; ++i) {
1110 buffer = &queue->buffer[i];
1111 if ((buffer->buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff)
1112 break;
1113 }
1114
1115 if (i == queue->count || size != queue->buf_size) {
1116 ret = -EINVAL;
1117 goto done;
1118 }
1119
1120 /*
1121 * VM_IO marks the area as being an mmaped region for I/O to a
1122 * device. It also prevents the region from being core dumped.
1123 */
1124 vma->vm_flags |= VM_IO;
1125
1126 addr = (unsigned long)queue->mem + buffer->buf.m.offset;
1127 while (size > 0) {
1128 page = vmalloc_to_page((void *)addr);
1129 if ((ret = vm_insert_page(vma, start, page)) < 0)
1130 goto done;
1131
1132 start += PAGE_SIZE;
1133 addr += PAGE_SIZE;
1134 size -= PAGE_SIZE;
1135 }
1136
1137 vma->vm_ops = &uvc_vm_ops;
1138 vma->vm_private_data = buffer;
1139 uvc_vm_open(vma);
1140
1141done:
1142 mutex_unlock(&queue->mutex);
1143 return ret;
1144} 1075}
1145 1076
1146static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait) 1077static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait)
@@ -1157,7 +1088,7 @@ const struct v4l2_file_operations uvc_fops = {
1157 .owner = THIS_MODULE, 1088 .owner = THIS_MODULE,
1158 .open = uvc_v4l2_open, 1089 .open = uvc_v4l2_open,
1159 .release = uvc_v4l2_release, 1090 .release = uvc_v4l2_release,
1160 .ioctl = uvc_v4l2_ioctl, 1091 .unlocked_ioctl = uvc_v4l2_ioctl,
1161 .read = uvc_v4l2_read, 1092 .read = uvc_v4l2_read,
1162 .mmap = uvc_v4l2_mmap, 1093 .mmap = uvc_v4l2_mmap,
1163 .poll = uvc_v4l2_poll, 1094 .poll = uvc_v4l2_poll,
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index 5555f0102838..5673d673504b 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -293,8 +293,6 @@ int uvc_probe_video(struct uvc_streaming *stream,
293 unsigned int i; 293 unsigned int i;
294 int ret; 294 int ret;
295 295
296 mutex_lock(&stream->mutex);
297
298 /* Perform probing. The device should adjust the requested values 296 /* Perform probing. The device should adjust the requested values
299 * according to its capabilities. However, some devices, namely the 297 * according to its capabilities. However, some devices, namely the
300 * first generation UVC Logitech webcams, don't implement the Video 298 * first generation UVC Logitech webcams, don't implement the Video
@@ -346,7 +344,6 @@ int uvc_probe_video(struct uvc_streaming *stream,
346 } 344 }
347 345
348done: 346done:
349 mutex_unlock(&stream->mutex);
350 return ret; 347 return ret;
351} 348}
352 349
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index d97cf6d6a4f9..45f01e7e13d2 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -436,7 +436,9 @@ struct uvc_streaming {
436 struct uvc_streaming_control ctrl; 436 struct uvc_streaming_control ctrl;
437 struct uvc_format *cur_format; 437 struct uvc_format *cur_format;
438 struct uvc_frame *cur_frame; 438 struct uvc_frame *cur_frame;
439 439 /* Protect access to ctrl, cur_format, cur_frame and hardware video
440 * probe control.
441 */
440 struct mutex mutex; 442 struct mutex mutex;
441 443
442 unsigned int frozen : 1; 444 unsigned int frozen : 1;
@@ -574,6 +576,8 @@ extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable);
574extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); 576extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect);
575extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, 577extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
576 struct uvc_buffer *buf); 578 struct uvc_buffer *buf);
579extern int uvc_queue_mmap(struct uvc_video_queue *queue,
580 struct vm_area_struct *vma);
577extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue, 581extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
578 struct file *file, poll_table *wait); 582 struct file *file, poll_table *wait);
579extern int uvc_queue_allocated(struct uvc_video_queue *queue); 583extern int uvc_queue_allocated(struct uvc_video_queue *queue);
@@ -606,10 +610,10 @@ extern int uvc_status_suspend(struct uvc_device *dev);
606extern int uvc_status_resume(struct uvc_device *dev); 610extern int uvc_status_resume(struct uvc_device *dev);
607 611
608/* Controls */ 612/* Controls */
609extern struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
610 __u32 v4l2_id, struct uvc_control_mapping **mapping);
611extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, 613extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
612 struct v4l2_queryctrl *v4l2_ctrl); 614 struct v4l2_queryctrl *v4l2_ctrl);
615extern int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
616 struct v4l2_querymenu *query_menu);
613 617
614extern int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, 618extern int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
615 const struct uvc_control_mapping *mapping); 619 const struct uvc_control_mapping *mapping);
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 9294282b5add..b5eb1f3950b1 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -368,18 +368,15 @@ EXPORT_SYMBOL_GPL(v4l2_i2c_subdev_init);
368 368
369/* Load an i2c sub-device. */ 369/* Load an i2c sub-device. */
370struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, 370struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
371 struct i2c_adapter *adapter, const char *module_name, 371 struct i2c_adapter *adapter, struct i2c_board_info *info,
372 struct i2c_board_info *info, const unsigned short *probe_addrs) 372 const unsigned short *probe_addrs)
373{ 373{
374 struct v4l2_subdev *sd = NULL; 374 struct v4l2_subdev *sd = NULL;
375 struct i2c_client *client; 375 struct i2c_client *client;
376 376
377 BUG_ON(!v4l2_dev); 377 BUG_ON(!v4l2_dev);
378 378
379 if (module_name) 379 request_module(I2C_MODULE_PREFIX "%s", info->type);
380 request_module(module_name);
381 else
382 request_module(I2C_MODULE_PREFIX "%s", info->type);
383 380
384 /* Create the i2c client */ 381 /* Create the i2c client */
385 if (info->addr == 0 && probe_addrs) 382 if (info->addr == 0 && probe_addrs)
@@ -432,8 +429,7 @@ error:
432EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board); 429EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board);
433 430
434struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, 431struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev,
435 struct i2c_adapter *adapter, 432 struct i2c_adapter *adapter, const char *client_type,
436 const char *module_name, const char *client_type,
437 int irq, void *platform_data, 433 int irq, void *platform_data,
438 u8 addr, const unsigned short *probe_addrs) 434 u8 addr, const unsigned short *probe_addrs)
439{ 435{
@@ -447,8 +443,7 @@ struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev,
447 info.irq = irq; 443 info.irq = irq;
448 info.platform_data = platform_data; 444 info.platform_data = platform_data;
449 445
450 return v4l2_i2c_new_subdev_board(v4l2_dev, adapter, module_name, 446 return v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, probe_addrs);
451 &info, probe_addrs);
452} 447}
453EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_cfg); 448EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_cfg);
454 449
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c
index 86294ed35c9b..e30e8dfb6205 100644
--- a/drivers/media/video/v4l2-compat-ioctl32.c
+++ b/drivers/media/video/v4l2-compat-ioctl32.c
@@ -18,7 +18,6 @@
18#include <linux/videodev.h> 18#include <linux/videodev.h>
19#include <linux/videodev2.h> 19#include <linux/videodev2.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/smp_lock.h>
22#include <media/v4l2-ioctl.h> 21#include <media/v4l2-ioctl.h>
23 22
24#ifdef CONFIG_COMPAT 23#ifdef CONFIG_COMPAT
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 03f7f4670e9b..359e23290a7e 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -186,12 +186,12 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf,
186 size_t sz, loff_t *off) 186 size_t sz, loff_t *off)
187{ 187{
188 struct video_device *vdev = video_devdata(filp); 188 struct video_device *vdev = video_devdata(filp);
189 int ret = -EIO; 189 int ret = -ENODEV;
190 190
191 if (!vdev->fops->read) 191 if (!vdev->fops->read)
192 return -EINVAL; 192 return -EINVAL;
193 if (vdev->lock) 193 if (vdev->lock && mutex_lock_interruptible(vdev->lock))
194 mutex_lock(vdev->lock); 194 return -ERESTARTSYS;
195 if (video_is_registered(vdev)) 195 if (video_is_registered(vdev))
196 ret = vdev->fops->read(filp, buf, sz, off); 196 ret = vdev->fops->read(filp, buf, sz, off);
197 if (vdev->lock) 197 if (vdev->lock)
@@ -203,12 +203,12 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
203 size_t sz, loff_t *off) 203 size_t sz, loff_t *off)
204{ 204{
205 struct video_device *vdev = video_devdata(filp); 205 struct video_device *vdev = video_devdata(filp);
206 int ret = -EIO; 206 int ret = -ENODEV;
207 207
208 if (!vdev->fops->write) 208 if (!vdev->fops->write)
209 return -EINVAL; 209 return -EINVAL;
210 if (vdev->lock) 210 if (vdev->lock && mutex_lock_interruptible(vdev->lock))
211 mutex_lock(vdev->lock); 211 return -ERESTARTSYS;
212 if (video_is_registered(vdev)) 212 if (video_is_registered(vdev))
213 ret = vdev->fops->write(filp, buf, sz, off); 213 ret = vdev->fops->write(filp, buf, sz, off);
214 if (vdev->lock) 214 if (vdev->lock)
@@ -219,10 +219,10 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
219static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll) 219static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
220{ 220{
221 struct video_device *vdev = video_devdata(filp); 221 struct video_device *vdev = video_devdata(filp);
222 int ret = DEFAULT_POLLMASK; 222 int ret = POLLERR | POLLHUP;
223 223
224 if (!vdev->fops->poll) 224 if (!vdev->fops->poll)
225 return ret; 225 return DEFAULT_POLLMASK;
226 if (vdev->lock) 226 if (vdev->lock)
227 mutex_lock(vdev->lock); 227 mutex_lock(vdev->lock);
228 if (video_is_registered(vdev)) 228 if (video_is_registered(vdev))
@@ -238,20 +238,45 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
238 int ret = -ENODEV; 238 int ret = -ENODEV;
239 239
240 if (vdev->fops->unlocked_ioctl) { 240 if (vdev->fops->unlocked_ioctl) {
241 if (vdev->lock) 241 if (vdev->lock && mutex_lock_interruptible(vdev->lock))
242 mutex_lock(vdev->lock); 242 return -ERESTARTSYS;
243 if (video_is_registered(vdev)) 243 if (video_is_registered(vdev))
244 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); 244 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
245 if (vdev->lock) 245 if (vdev->lock)
246 mutex_unlock(vdev->lock); 246 mutex_unlock(vdev->lock);
247 } else if (vdev->fops->ioctl) { 247 } else if (vdev->fops->ioctl) {
248 /* TODO: convert all drivers to unlocked_ioctl */ 248 /* This code path is a replacement for the BKL. It is a major
249 * hack but it will have to do for those drivers that are not
250 * yet converted to use unlocked_ioctl.
251 *
252 * There are two options: if the driver implements struct
253 * v4l2_device, then the lock defined there is used to
254 * serialize the ioctls. Otherwise the v4l2 core lock defined
255 * below is used. This lock is really bad since it serializes
256 * completely independent devices.
257 *
258 * Both variants suffer from the same problem: if the driver
259 * sleeps, then it blocks all ioctls since the lock is still
260 * held. This is very common for VIDIOC_DQBUF since that
261 * normally waits for a frame to arrive. As a result any other
262 * ioctl calls will proceed very, very slowly since each call
263 * will have to wait for the VIDIOC_QBUF to finish. Things that
264 * should take 0.01s may now take 10-20 seconds.
265 *
266 * The workaround is to *not* take the lock for VIDIOC_DQBUF.
267 * This actually works OK for videobuf-based drivers, since
268 * videobuf will take its own internal lock.
269 */
249 static DEFINE_MUTEX(v4l2_ioctl_mutex); 270 static DEFINE_MUTEX(v4l2_ioctl_mutex);
271 struct mutex *m = vdev->v4l2_dev ?
272 &vdev->v4l2_dev->ioctl_lock : &v4l2_ioctl_mutex;
250 273
251 mutex_lock(&v4l2_ioctl_mutex); 274 if (cmd != VIDIOC_DQBUF && mutex_lock_interruptible(m))
275 return -ERESTARTSYS;
252 if (video_is_registered(vdev)) 276 if (video_is_registered(vdev))
253 ret = vdev->fops->ioctl(filp, cmd, arg); 277 ret = vdev->fops->ioctl(filp, cmd, arg);
254 mutex_unlock(&v4l2_ioctl_mutex); 278 if (cmd != VIDIOC_DQBUF)
279 mutex_unlock(m);
255 } else 280 } else
256 ret = -ENOTTY; 281 ret = -ENOTTY;
257 282
@@ -265,8 +290,8 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
265 290
266 if (!vdev->fops->mmap) 291 if (!vdev->fops->mmap)
267 return ret; 292 return ret;
268 if (vdev->lock) 293 if (vdev->lock && mutex_lock_interruptible(vdev->lock))
269 mutex_lock(vdev->lock); 294 return -ERESTARTSYS;
270 if (video_is_registered(vdev)) 295 if (video_is_registered(vdev))
271 ret = vdev->fops->mmap(filp, vm); 296 ret = vdev->fops->mmap(filp, vm);
272 if (vdev->lock) 297 if (vdev->lock)
@@ -284,7 +309,7 @@ static int v4l2_open(struct inode *inode, struct file *filp)
284 mutex_lock(&videodev_lock); 309 mutex_lock(&videodev_lock);
285 vdev = video_devdata(filp); 310 vdev = video_devdata(filp);
286 /* return ENODEV if the video device has already been removed. */ 311 /* return ENODEV if the video device has already been removed. */
287 if (vdev == NULL) { 312 if (vdev == NULL || !video_is_registered(vdev)) {
288 mutex_unlock(&videodev_lock); 313 mutex_unlock(&videodev_lock);
289 return -ENODEV; 314 return -ENODEV;
290 } 315 }
@@ -292,8 +317,10 @@ static int v4l2_open(struct inode *inode, struct file *filp)
292 video_get(vdev); 317 video_get(vdev);
293 mutex_unlock(&videodev_lock); 318 mutex_unlock(&videodev_lock);
294 if (vdev->fops->open) { 319 if (vdev->fops->open) {
295 if (vdev->lock) 320 if (vdev->lock && mutex_lock_interruptible(vdev->lock)) {
296 mutex_lock(vdev->lock); 321 ret = -ERESTARTSYS;
322 goto err;
323 }
297 if (video_is_registered(vdev)) 324 if (video_is_registered(vdev))
298 ret = vdev->fops->open(filp); 325 ret = vdev->fops->open(filp);
299 else 326 else
@@ -302,6 +329,7 @@ static int v4l2_open(struct inode *inode, struct file *filp)
302 mutex_unlock(vdev->lock); 329 mutex_unlock(vdev->lock);
303 } 330 }
304 331
332err:
305 /* decrease the refcount in case of an error */ 333 /* decrease the refcount in case of an error */
306 if (ret) 334 if (ret)
307 video_put(vdev); 335 video_put(vdev);
@@ -596,7 +624,12 @@ void video_unregister_device(struct video_device *vdev)
596 if (!vdev || !video_is_registered(vdev)) 624 if (!vdev || !video_is_registered(vdev))
597 return; 625 return;
598 626
627 mutex_lock(&videodev_lock);
628 /* This must be in a critical section to prevent a race with v4l2_open.
629 * Once this bit has been cleared video_get may never be called again.
630 */
599 clear_bit(V4L2_FL_REGISTERED, &vdev->flags); 631 clear_bit(V4L2_FL_REGISTERED, &vdev->flags);
632 mutex_unlock(&videodev_lock);
600 device_unregister(&vdev->dev); 633 device_unregister(&vdev->dev);
601} 634}
602EXPORT_SYMBOL(video_unregister_device); 635EXPORT_SYMBOL(video_unregister_device);
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 0b08f96b74a5..7fe6f92af480 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -35,6 +35,7 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
35 35
36 INIT_LIST_HEAD(&v4l2_dev->subdevs); 36 INIT_LIST_HEAD(&v4l2_dev->subdevs);
37 spin_lock_init(&v4l2_dev->lock); 37 spin_lock_init(&v4l2_dev->lock);
38 mutex_init(&v4l2_dev->ioctl_lock);
38 v4l2_dev->dev = dev; 39 v4l2_dev->dev = dev;
39 if (dev == NULL) { 40 if (dev == NULL) {
40 /* If dev == NULL, then name must be filled in by the caller */ 41 /* If dev == NULL, then name must be filled in by the caller */
diff --git a/drivers/media/video/via-camera.c b/drivers/media/video/via-camera.c
index 02a21bccae18..9eda7cc03121 100644
--- a/drivers/media/video/via-camera.c
+++ b/drivers/media/video/via-camera.c
@@ -1360,7 +1360,7 @@ static __devinit int viacam_probe(struct platform_device *pdev)
1360 */ 1360 */
1361 sensor_adapter = viafb_find_i2c_adapter(VIA_PORT_31); 1361 sensor_adapter = viafb_find_i2c_adapter(VIA_PORT_31);
1362 cam->sensor = v4l2_i2c_new_subdev(&cam->v4l2_dev, sensor_adapter, 1362 cam->sensor = v4l2_i2c_new_subdev(&cam->v4l2_dev, sensor_adapter,
1363 "ov7670", "ov7670", 0x42 >> 1, NULL); 1363 "ov7670", 0x42 >> 1, NULL);
1364 if (cam->sensor == NULL) { 1364 if (cam->sensor == NULL) {
1365 dev_err(&pdev->dev, "Unable to find the sensor!\n"); 1365 dev_err(&pdev->dev, "Unable to find the sensor!\n");
1366 ret = -ENODEV; 1366 ret = -ENODEV;
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index e5e005dc1554..7e7eec48f8b1 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -4334,10 +4334,10 @@ static int __init vino_module_init(void)
4334 4334
4335 vino_drvdata->decoder = 4335 vino_drvdata->decoder =
4336 v4l2_i2c_new_subdev(&vino_drvdata->v4l2_dev, &vino_i2c_adapter, 4336 v4l2_i2c_new_subdev(&vino_drvdata->v4l2_dev, &vino_i2c_adapter,
4337 NULL, "saa7191", 0, I2C_ADDRS(0x45)); 4337 "saa7191", 0, I2C_ADDRS(0x45));
4338 vino_drvdata->camera = 4338 vino_drvdata->camera =
4339 v4l2_i2c_new_subdev(&vino_drvdata->v4l2_dev, &vino_i2c_adapter, 4339 v4l2_i2c_new_subdev(&vino_drvdata->v4l2_dev, &vino_i2c_adapter,
4340 NULL, "indycam", 0, I2C_ADDRS(0x2b)); 4340 "indycam", 0, I2C_ADDRS(0x2b));
4341 4341
4342 dprintk("init complete!\n"); 4342 dprintk("init complete!\n");
4343 4343
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 635420d8d84a..019ee206cbee 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -815,7 +815,7 @@ out:
815 815
816static const struct v4l2_file_operations w9966_fops = { 816static const struct v4l2_file_operations w9966_fops = {
817 .owner = THIS_MODULE, 817 .owner = THIS_MODULE,
818 .ioctl = video_ioctl2, 818 .unlocked_ioctl = video_ioctl2,
819 .read = w9966_v4l_read, 819 .read = w9966_v4l_read,
820}; 820};
821 821
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c
index 7e6d62467eaa..e520abf9f4c3 100644
--- a/drivers/media/video/zoran/zoran_card.c
+++ b/drivers/media/video/zoran/zoran_card.c
@@ -1343,13 +1343,12 @@ static int __devinit zoran_probe(struct pci_dev *pdev,
1343 } 1343 }
1344 1344
1345 zr->decoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, 1345 zr->decoder = v4l2_i2c_new_subdev(&zr->v4l2_dev,
1346 &zr->i2c_adapter, NULL, zr->card.i2c_decoder, 1346 &zr->i2c_adapter, zr->card.i2c_decoder,
1347 0, zr->card.addrs_decoder); 1347 0, zr->card.addrs_decoder);
1348 1348
1349 if (zr->card.i2c_encoder) 1349 if (zr->card.i2c_encoder)
1350 zr->encoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, 1350 zr->encoder = v4l2_i2c_new_subdev(&zr->v4l2_dev,
1351 &zr->i2c_adapter, 1351 &zr->i2c_adapter, zr->card.i2c_encoder,
1352 NULL, zr->card.i2c_encoder,
1353 0, zr->card.addrs_encoder); 1352 0, zr->card.addrs_encoder);
1354 1353
1355 dprintk(2, 1354 dprintk(2,
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index e15220ff52fc..d784c36707c0 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -97,8 +97,7 @@ static u8 mptfcInternalCtx = MPT_MAX_PROTOCOL_DRIVERS;
97 97
98static int mptfc_target_alloc(struct scsi_target *starget); 98static int mptfc_target_alloc(struct scsi_target *starget);
99static int mptfc_slave_alloc(struct scsi_device *sdev); 99static int mptfc_slave_alloc(struct scsi_device *sdev);
100static int mptfc_qcmd(struct scsi_cmnd *SCpnt, 100static int mptfc_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt);
101 void (*done)(struct scsi_cmnd *));
102static void mptfc_target_destroy(struct scsi_target *starget); 101static void mptfc_target_destroy(struct scsi_target *starget);
103static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout); 102static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
104static void __devexit mptfc_remove(struct pci_dev *pdev); 103static void __devexit mptfc_remove(struct pci_dev *pdev);
@@ -650,7 +649,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
650} 649}
651 650
652static int 651static int
653mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 652mptfc_qcmd_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
654{ 653{
655 struct mptfc_rport_info *ri; 654 struct mptfc_rport_info *ri;
656 struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device)); 655 struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device));
@@ -681,6 +680,8 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
681 return mptscsih_qcmd(SCpnt,done); 680 return mptscsih_qcmd(SCpnt,done);
682} 681}
683 682
683static DEF_SCSI_QCMD(mptfc_qcmd)
684
684/* 685/*
685 * mptfc_display_port_link_speed - displaying link speed 686 * mptfc_display_port_link_speed - displaying link speed
686 * @ioc: Pointer to MPT_ADAPTER structure 687 * @ioc: Pointer to MPT_ADAPTER structure
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 83a5115f0251..d48c2c6058e1 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1889,7 +1889,7 @@ mptsas_slave_alloc(struct scsi_device *sdev)
1889} 1889}
1890 1890
1891static int 1891static int
1892mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 1892mptsas_qcmd_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1893{ 1893{
1894 MPT_SCSI_HOST *hd; 1894 MPT_SCSI_HOST *hd;
1895 MPT_ADAPTER *ioc; 1895 MPT_ADAPTER *ioc;
@@ -1913,6 +1913,8 @@ mptsas_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1913 return mptscsih_qcmd(SCpnt,done); 1913 return mptscsih_qcmd(SCpnt,done);
1914} 1914}
1915 1915
1916static DEF_SCSI_QCMD(mptsas_qcmd)
1917
1916/** 1918/**
1917 * mptsas_mptsas_eh_timed_out - resets the scsi_cmnd timeout 1919 * mptsas_mptsas_eh_timed_out - resets the scsi_cmnd timeout
1918 * if the device under question is currently in the 1920 * if the device under question is currently in the
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 0e2803155ae2..6d9568d2ec59 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -780,7 +780,7 @@ static int mptspi_slave_configure(struct scsi_device *sdev)
780} 780}
781 781
782static int 782static int
783mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 783mptspi_qcmd_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
784{ 784{
785 struct _MPT_SCSI_HOST *hd = shost_priv(SCpnt->device->host); 785 struct _MPT_SCSI_HOST *hd = shost_priv(SCpnt->device->host);
786 VirtDevice *vdevice = SCpnt->device->hostdata; 786 VirtDevice *vdevice = SCpnt->device->hostdata;
@@ -805,6 +805,8 @@ mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
805 return mptscsih_qcmd(SCpnt,done); 805 return mptscsih_qcmd(SCpnt,done);
806} 806}
807 807
808static DEF_SCSI_QCMD(mptspi_qcmd)
809
808static void mptspi_slave_destroy(struct scsi_device *sdev) 810static void mptspi_slave_destroy(struct scsi_device *sdev)
809{ 811{
810 struct scsi_target *starget = scsi_target(sdev); 812 struct scsi_target *starget = scsi_target(sdev);
diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
index ea6b2197da8a..97bdf82ec905 100644
--- a/drivers/message/i2o/i2o_scsi.c
+++ b/drivers/message/i2o/i2o_scsi.c
@@ -506,7 +506,7 @@ static struct i2o_driver i2o_scsi_driver = {
506 * Locks: takes the controller lock on error path only 506 * Locks: takes the controller lock on error path only
507 */ 507 */
508 508
509static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, 509static int i2o_scsi_queuecommand_lck(struct scsi_cmnd *SCpnt,
510 void (*done) (struct scsi_cmnd *)) 510 void (*done) (struct scsi_cmnd *))
511{ 511{
512 struct i2o_controller *c; 512 struct i2o_controller *c;
@@ -688,7 +688,9 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
688 688
689 exit: 689 exit:
690 return rc; 690 return rc;
691}; 691}
692
693static DEF_SCSI_QCMD(i2o_scsi_queuecommand)
692 694
693/** 695/**
694 * i2o_scsi_abort - abort a running command 696 * i2o_scsi_abort - abort a running command
diff --git a/drivers/misc/isl29020.c b/drivers/misc/isl29020.c
index ca47e6285075..307aada5fffe 100644
--- a/drivers/misc/isl29020.c
+++ b/drivers/misc/isl29020.c
@@ -183,9 +183,7 @@ static int isl29020_probe(struct i2c_client *client,
183 183
184static int isl29020_remove(struct i2c_client *client) 184static int isl29020_remove(struct i2c_client *client)
185{ 185{
186 struct als_data *data = i2c_get_clientdata(client);
187 sysfs_remove_group(&client->dev.kobj, &m_als_gr); 186 sysfs_remove_group(&client->dev.kobj, &m_als_gr);
188 kfree(data);
189 return 0; 187 return 0;
190} 188}
191 189
@@ -245,6 +243,6 @@ static void __exit sensor_isl29020_exit(void)
245module_init(sensor_isl29020_init); 243module_init(sensor_isl29020_init);
246module_exit(sensor_isl29020_exit); 244module_exit(sensor_isl29020_exit);
247 245
248MODULE_AUTHOR("Kalhan Trisal <kalhan.trisal@intel.com"); 246MODULE_AUTHOR("Kalhan Trisal <kalhan.trisal@intel.com>");
249MODULE_DESCRIPTION("Intersil isl29020 ALS Driver"); 247MODULE_DESCRIPTION("Intersil isl29020 ALS Driver");
250MODULE_LICENSE("GPL v2"); 248MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
index d551f09ccb79..6956f7e7d439 100644
--- a/drivers/misc/sgi-xp/xpc_partition.c
+++ b/drivers/misc/sgi-xp/xpc_partition.c
@@ -439,18 +439,23 @@ xpc_discovery(void)
439 * nodes that can comprise an access protection grouping. The access 439 * nodes that can comprise an access protection grouping. The access
440 * protection is in regards to memory, IOI and IPI. 440 * protection is in regards to memory, IOI and IPI.
441 */ 441 */
442 max_regions = 64;
443 region_size = xp_region_size; 442 region_size = xp_region_size;
444 443
445 switch (region_size) { 444 if (is_uv())
446 case 128: 445 max_regions = 256;
447 max_regions *= 2; 446 else {
448 case 64: 447 max_regions = 64;
449 max_regions *= 2; 448
450 case 32: 449 switch (region_size) {
451 max_regions *= 2; 450 case 128:
452 region_size = 16; 451 max_regions *= 2;
453 DBUG_ON(!is_shub2()); 452 case 64:
453 max_regions *= 2;
454 case 32:
455 max_regions *= 2;
456 region_size = 16;
457 DBUG_ON(!is_shub2());
458 }
454 } 459 }
455 460
456 for (region = 0; region < max_regions; region++) { 461 for (region = 0; region < max_regions; region++) {
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 8f86d702e46e..31ae07a36576 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1559,7 +1559,7 @@ void mmc_stop_host(struct mmc_host *host)
1559 1559
1560 if (host->caps & MMC_CAP_DISABLE) 1560 if (host->caps & MMC_CAP_DISABLE)
1561 cancel_delayed_work(&host->disable); 1561 cancel_delayed_work(&host->disable);
1562 cancel_delayed_work(&host->detect); 1562 cancel_delayed_work_sync(&host->detect);
1563 mmc_flush_scheduled_work(); 1563 mmc_flush_scheduled_work();
1564 1564
1565 /* clear pm flags now and let card drivers set them as needed */ 1565 /* clear pm flags now and let card drivers set them as needed */
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 995261f7fd70..77f93c3b8808 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -375,7 +375,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
375 struct mmc_card *oldcard) 375 struct mmc_card *oldcard)
376{ 376{
377 struct mmc_card *card; 377 struct mmc_card *card;
378 int err, ddr = MMC_SDR_MODE; 378 int err, ddr = 0;
379 u32 cid[4]; 379 u32 cid[4];
380 unsigned int max_dtr; 380 unsigned int max_dtr;
381 381
@@ -562,7 +562,11 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
562 1 << bus_width, ddr); 562 1 << bus_width, ddr);
563 err = 0; 563 err = 0;
564 } else { 564 } else {
565 mmc_card_set_ddr_mode(card); 565 if (ddr)
566 mmc_card_set_ddr_mode(card);
567 else
568 ddr = MMC_SDR_MODE;
569
566 mmc_set_bus_width_ddr(card->host, bus_width, ddr); 570 mmc_set_bus_width_ddr(card->host, bus_width, ddr);
567 } 571 }
568 } 572 }
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index c3ad1058cd31..efef5f94ac42 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -547,9 +547,11 @@ static void mmc_sdio_detect(struct mmc_host *host)
547 BUG_ON(!host->card); 547 BUG_ON(!host->card);
548 548
549 /* Make sure card is powered before detecting it */ 549 /* Make sure card is powered before detecting it */
550 err = pm_runtime_get_sync(&host->card->dev); 550 if (host->caps & MMC_CAP_POWER_OFF_CARD) {
551 if (err < 0) 551 err = pm_runtime_get_sync(&host->card->dev);
552 goto out; 552 if (err < 0)
553 goto out;
554 }
553 555
554 mmc_claim_host(host); 556 mmc_claim_host(host);
555 557
@@ -560,6 +562,20 @@ static void mmc_sdio_detect(struct mmc_host *host)
560 562
561 mmc_release_host(host); 563 mmc_release_host(host);
562 564
565 /*
566 * Tell PM core it's OK to power off the card now.
567 *
568 * The _sync variant is used in order to ensure that the card
569 * is left powered off in case an error occurred, and the card
570 * is going to be removed.
571 *
572 * Since there is no specific reason to believe a new user
573 * is about to show up at this point, the _sync variant is
574 * desirable anyway.
575 */
576 if (host->caps & MMC_CAP_POWER_OFF_CARD)
577 pm_runtime_put_sync(&host->card->dev);
578
563out: 579out:
564 if (err) { 580 if (err) {
565 mmc_sdio_remove(host); 581 mmc_sdio_remove(host);
@@ -568,9 +584,6 @@ out:
568 mmc_detach_bus(host); 584 mmc_detach_bus(host);
569 mmc_release_host(host); 585 mmc_release_host(host);
570 } 586 }
571
572 /* Tell PM core that we're done */
573 pm_runtime_put(&host->card->dev);
574} 587}
575 588
576/* 589/*
@@ -718,16 +731,21 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr)
718 card = host->card; 731 card = host->card;
719 732
720 /* 733 /*
721 * Let runtime PM core know our card is active 734 * Enable runtime PM only if supported by host+card+board
722 */ 735 */
723 err = pm_runtime_set_active(&card->dev); 736 if (host->caps & MMC_CAP_POWER_OFF_CARD) {
724 if (err) 737 /*
725 goto remove; 738 * Let runtime PM core know our card is active
739 */
740 err = pm_runtime_set_active(&card->dev);
741 if (err)
742 goto remove;
726 743
727 /* 744 /*
728 * Enable runtime PM for this card 745 * Enable runtime PM for this card
729 */ 746 */
730 pm_runtime_enable(&card->dev); 747 pm_runtime_enable(&card->dev);
748 }
731 749
732 /* 750 /*
733 * The number of functions on the card is encoded inside 751 * The number of functions on the card is encoded inside
@@ -745,9 +763,10 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr)
745 goto remove; 763 goto remove;
746 764
747 /* 765 /*
748 * Enable Runtime PM for this func 766 * Enable Runtime PM for this func (if supported)
749 */ 767 */
750 pm_runtime_enable(&card->sdio_func[i]->dev); 768 if (host->caps & MMC_CAP_POWER_OFF_CARD)
769 pm_runtime_enable(&card->sdio_func[i]->dev);
751 } 770 }
752 771
753 mmc_release_host(host); 772 mmc_release_host(host);
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 2716c7ab6bbf..203da443e339 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -17,6 +17,7 @@
17#include <linux/pm_runtime.h> 17#include <linux/pm_runtime.h>
18 18
19#include <linux/mmc/card.h> 19#include <linux/mmc/card.h>
20#include <linux/mmc/host.h>
20#include <linux/mmc/sdio_func.h> 21#include <linux/mmc/sdio_func.h>
21 22
22#include "sdio_cis.h" 23#include "sdio_cis.h"
@@ -132,9 +133,11 @@ static int sdio_bus_probe(struct device *dev)
132 * it should call pm_runtime_put_noidle() in its probe routine and 133 * it should call pm_runtime_put_noidle() in its probe routine and
133 * pm_runtime_get_noresume() in its remove routine. 134 * pm_runtime_get_noresume() in its remove routine.
134 */ 135 */
135 ret = pm_runtime_get_sync(dev); 136 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) {
136 if (ret < 0) 137 ret = pm_runtime_get_sync(dev);
137 goto out; 138 if (ret < 0)
139 goto out;
140 }
138 141
139 /* Set the default block size so the driver is sure it's something 142 /* Set the default block size so the driver is sure it's something
140 * sensible. */ 143 * sensible. */
@@ -151,7 +154,8 @@ static int sdio_bus_probe(struct device *dev)
151 return 0; 154 return 0;
152 155
153disable_runtimepm: 156disable_runtimepm:
154 pm_runtime_put_noidle(dev); 157 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
158 pm_runtime_put_noidle(dev);
155out: 159out:
156 return ret; 160 return ret;
157} 161}
@@ -160,12 +164,14 @@ static int sdio_bus_remove(struct device *dev)
160{ 164{
161 struct sdio_driver *drv = to_sdio_driver(dev->driver); 165 struct sdio_driver *drv = to_sdio_driver(dev->driver);
162 struct sdio_func *func = dev_to_sdio_func(dev); 166 struct sdio_func *func = dev_to_sdio_func(dev);
163 int ret; 167 int ret = 0;
164 168
165 /* Make sure card is powered before invoking ->remove() */ 169 /* Make sure card is powered before invoking ->remove() */
166 ret = pm_runtime_get_sync(dev); 170 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) {
167 if (ret < 0) 171 ret = pm_runtime_get_sync(dev);
168 goto out; 172 if (ret < 0)
173 goto out;
174 }
169 175
170 drv->remove(func); 176 drv->remove(func);
171 177
@@ -178,10 +184,12 @@ static int sdio_bus_remove(struct device *dev)
178 } 184 }
179 185
180 /* First, undo the increment made directly above */ 186 /* First, undo the increment made directly above */
181 pm_runtime_put_noidle(dev); 187 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
188 pm_runtime_put_noidle(dev);
182 189
183 /* Then undo the runtime PM settings in sdio_bus_probe() */ 190 /* Then undo the runtime PM settings in sdio_bus_probe() */
184 pm_runtime_put_noidle(dev); 191 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
192 pm_runtime_put_noidle(dev);
185 193
186out: 194out:
187 return ret; 195 return ret;
@@ -191,6 +199,8 @@ out:
191 199
192static int sdio_bus_pm_prepare(struct device *dev) 200static int sdio_bus_pm_prepare(struct device *dev)
193{ 201{
202 struct sdio_func *func = dev_to_sdio_func(dev);
203
194 /* 204 /*
195 * Resume an SDIO device which was suspended at run time at this 205 * Resume an SDIO device which was suspended at run time at this
196 * point, in order to allow standard SDIO suspend/resume paths 206 * point, in order to allow standard SDIO suspend/resume paths
@@ -212,7 +222,8 @@ static int sdio_bus_pm_prepare(struct device *dev)
212 * since there is little point in failing system suspend if a 222 * since there is little point in failing system suspend if a
213 * device can't be resumed. 223 * device can't be resumed.
214 */ 224 */
215 pm_runtime_resume(dev); 225 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
226 pm_runtime_resume(dev);
216 227
217 return 0; 228 return 0;
218} 229}
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 82a1079bbdc7..5d46021cbb57 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1002,7 +1002,7 @@ static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host,
1002 * Monitor a 0->1 transition first 1002 * Monitor a 0->1 transition first
1003 */ 1003 */
1004 if (mmc_slot(host).features & HSMMC_HAS_UPDATED_RESET) { 1004 if (mmc_slot(host).features & HSMMC_HAS_UPDATED_RESET) {
1005 while ((!(OMAP_HSMMC_READ(host, SYSCTL) & bit)) 1005 while ((!(OMAP_HSMMC_READ(host->base, SYSCTL) & bit))
1006 && (i++ < limit)) 1006 && (i++ < limit))
1007 cpu_relax(); 1007 cpu_relax();
1008 } 1008 }
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 2e9cca19c90b..9b82910b9dbb 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -17,6 +17,7 @@
17#include <linux/clk.h> 17#include <linux/clk.h>
18#include <linux/mmc/host.h> 18#include <linux/mmc/host.h>
19#include <linux/mmc/sdhci-pltfm.h> 19#include <linux/mmc/sdhci-pltfm.h>
20#include <mach/hardware.h>
20#include "sdhci.h" 21#include "sdhci.h"
21#include "sdhci-pltfm.h" 22#include "sdhci-pltfm.h"
22#include "sdhci-esdhc.h" 23#include "sdhci-esdhc.h"
@@ -112,6 +113,13 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd
112 clk_enable(clk); 113 clk_enable(clk);
113 pltfm_host->clk = clk; 114 pltfm_host->clk = clk;
114 115
116 if (cpu_is_mx35() || cpu_is_mx51())
117 host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
118
119 /* Fix errata ENGcm07207 which is present on i.MX25 and i.MX35 */
120 if (cpu_is_mx25() || cpu_is_mx35())
121 host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK;
122
115 return 0; 123 return 0;
116} 124}
117 125
@@ -133,10 +141,8 @@ static struct sdhci_ops sdhci_esdhc_ops = {
133}; 141};
134 142
135struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { 143struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
136 .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_MULTIBLOCK 144 .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_ADMA,
137 | SDHCI_QUIRK_BROKEN_ADMA,
138 /* ADMA has issues. Might be fixable */ 145 /* ADMA has issues. Might be fixable */
139 /* NO_MULTIBLOCK might be MX35 only (Errata: ENGcm07207) */
140 .ops = &sdhci_esdhc_ops, 146 .ops = &sdhci_esdhc_ops,
141 .init = esdhc_pltfm_init, 147 .init = esdhc_pltfm_init,
142 .exit = esdhc_pltfm_exit, 148 .exit = esdhc_pltfm_exit,
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 55746bac2f44..3d9c2460d437 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -149,11 +149,11 @@ static const struct sdhci_pci_fixes sdhci_cafe = {
149 * ADMA operation is disabled for Moorestown platform due to 149 * ADMA operation is disabled for Moorestown platform due to
150 * hardware bugs. 150 * hardware bugs.
151 */ 151 */
152static int mrst_hc1_probe(struct sdhci_pci_chip *chip) 152static int mrst_hc_probe(struct sdhci_pci_chip *chip)
153{ 153{
154 /* 154 /*
155 * slots number is fixed here for MRST as SDIO3 is never used and has 155 * slots number is fixed here for MRST as SDIO3/5 are never used and
156 * hardware bugs. 156 * have hardware bugs.
157 */ 157 */
158 chip->num_slots = 1; 158 chip->num_slots = 1;
159 return 0; 159 return 0;
@@ -163,9 +163,9 @@ static const struct sdhci_pci_fixes sdhci_intel_mrst_hc0 = {
163 .quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT, 163 .quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT,
164}; 164};
165 165
166static const struct sdhci_pci_fixes sdhci_intel_mrst_hc1 = { 166static const struct sdhci_pci_fixes sdhci_intel_mrst_hc1_hc2 = {
167 .quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT, 167 .quirks = SDHCI_QUIRK_BROKEN_ADMA | SDHCI_QUIRK_NO_HISPD_BIT,
168 .probe = mrst_hc1_probe, 168 .probe = mrst_hc_probe,
169}; 169};
170 170
171static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = { 171static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = {
@@ -538,7 +538,15 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
538 .device = PCI_DEVICE_ID_INTEL_MRST_SD1, 538 .device = PCI_DEVICE_ID_INTEL_MRST_SD1,
539 .subvendor = PCI_ANY_ID, 539 .subvendor = PCI_ANY_ID,
540 .subdevice = PCI_ANY_ID, 540 .subdevice = PCI_ANY_ID,
541 .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc1, 541 .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc1_hc2,
542 },
543
544 {
545 .vendor = PCI_VENDOR_ID_INTEL,
546 .device = PCI_DEVICE_ID_INTEL_MRST_SD2,
547 .subvendor = PCI_ANY_ID,
548 .subdevice = PCI_ANY_ID,
549 .driver_data = (kernel_ulong_t)&sdhci_intel_mrst_hc1_hc2,
542 }, 550 },
543 551
544 { 552 {
@@ -637,6 +645,7 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state)
637{ 645{
638 struct sdhci_pci_chip *chip; 646 struct sdhci_pci_chip *chip;
639 struct sdhci_pci_slot *slot; 647 struct sdhci_pci_slot *slot;
648 mmc_pm_flag_t slot_pm_flags;
640 mmc_pm_flag_t pm_flags = 0; 649 mmc_pm_flag_t pm_flags = 0;
641 int i, ret; 650 int i, ret;
642 651
@@ -657,7 +666,11 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state)
657 return ret; 666 return ret;
658 } 667 }
659 668
660 pm_flags |= slot->host->mmc->pm_flags; 669 slot_pm_flags = slot->host->mmc->pm_flags;
670 if (slot_pm_flags & MMC_PM_WAKE_SDIO_IRQ)
671 sdhci_enable_irq_wakeups(slot->host);
672
673 pm_flags |= slot_pm_flags;
661 } 674 }
662 675
663 if (chip->fixes && chip->fixes->suspend) { 676 if (chip->fixes && chip->fixes->suspend) {
@@ -671,8 +684,10 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state)
671 684
672 pci_save_state(pdev); 685 pci_save_state(pdev);
673 if (pm_flags & MMC_PM_KEEP_POWER) { 686 if (pm_flags & MMC_PM_KEEP_POWER) {
674 if (pm_flags & MMC_PM_WAKE_SDIO_IRQ) 687 if (pm_flags & MMC_PM_WAKE_SDIO_IRQ) {
688 pci_pme_active(pdev, true);
675 pci_enable_wake(pdev, PCI_D3hot, 1); 689 pci_enable_wake(pdev, PCI_D3hot, 1);
690 }
676 pci_set_power_state(pdev, PCI_D3hot); 691 pci_set_power_state(pdev, PCI_D3hot);
677 } else { 692 } else {
678 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); 693 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
index fc406ac5d193..5a61208cbc66 100644
--- a/drivers/mmc/host/sdhci-pxa.c
+++ b/drivers/mmc/host/sdhci-pxa.c
@@ -141,6 +141,10 @@ static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
141 if (pdata->quirks) 141 if (pdata->quirks)
142 host->quirks |= pdata->quirks; 142 host->quirks |= pdata->quirks;
143 143
144 /* If slot design supports 8 bit data, indicate this to MMC. */
145 if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
146 host->mmc->caps |= MMC_CAP_8_BIT_DATA;
147
144 ret = sdhci_add_host(host); 148 ret = sdhci_add_host(host);
145 if (ret) { 149 if (ret) {
146 dev_err(&pdev->dev, "failed to add host\n"); 150 dev_err(&pdev->dev, "failed to add host\n");
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 782c0ee3c925..a25db426c910 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1185,17 +1185,31 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1185 if (host->ops->platform_send_init_74_clocks) 1185 if (host->ops->platform_send_init_74_clocks)
1186 host->ops->platform_send_init_74_clocks(host, ios->power_mode); 1186 host->ops->platform_send_init_74_clocks(host, ios->power_mode);
1187 1187
1188 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); 1188 /*
1189 1189 * If your platform has 8-bit width support but is not a v3 controller,
1190 if (ios->bus_width == MMC_BUS_WIDTH_8) 1190 * or if it requires special setup code, you should implement that in
1191 ctrl |= SDHCI_CTRL_8BITBUS; 1191 * platform_8bit_width().
1192 else 1192 */
1193 ctrl &= ~SDHCI_CTRL_8BITBUS; 1193 if (host->ops->platform_8bit_width)
1194 host->ops->platform_8bit_width(host, ios->bus_width);
1195 else {
1196 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
1197 if (ios->bus_width == MMC_BUS_WIDTH_8) {
1198 ctrl &= ~SDHCI_CTRL_4BITBUS;
1199 if (host->version >= SDHCI_SPEC_300)
1200 ctrl |= SDHCI_CTRL_8BITBUS;
1201 } else {
1202 if (host->version >= SDHCI_SPEC_300)
1203 ctrl &= ~SDHCI_CTRL_8BITBUS;
1204 if (ios->bus_width == MMC_BUS_WIDTH_4)
1205 ctrl |= SDHCI_CTRL_4BITBUS;
1206 else
1207 ctrl &= ~SDHCI_CTRL_4BITBUS;
1208 }
1209 sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
1210 }
1194 1211
1195 if (ios->bus_width == MMC_BUS_WIDTH_4) 1212 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
1196 ctrl |= SDHCI_CTRL_4BITBUS;
1197 else
1198 ctrl &= ~SDHCI_CTRL_4BITBUS;
1199 1213
1200 if ((ios->timing == MMC_TIMING_SD_HS || 1214 if ((ios->timing == MMC_TIMING_SD_HS ||
1201 ios->timing == MMC_TIMING_MMC_HS) 1215 ios->timing == MMC_TIMING_MMC_HS)
@@ -1681,6 +1695,16 @@ int sdhci_resume_host(struct sdhci_host *host)
1681 1695
1682EXPORT_SYMBOL_GPL(sdhci_resume_host); 1696EXPORT_SYMBOL_GPL(sdhci_resume_host);
1683 1697
1698void sdhci_enable_irq_wakeups(struct sdhci_host *host)
1699{
1700 u8 val;
1701 val = sdhci_readb(host, SDHCI_WAKE_UP_CONTROL);
1702 val |= SDHCI_WAKE_ON_INT;
1703 sdhci_writeb(host, val, SDHCI_WAKE_UP_CONTROL);
1704}
1705
1706EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups);
1707
1684#endif /* CONFIG_PM */ 1708#endif /* CONFIG_PM */
1685 1709
1686/*****************************************************************************\ 1710/*****************************************************************************\
@@ -1845,11 +1869,19 @@ int sdhci_add_host(struct sdhci_host *host)
1845 mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; 1869 mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
1846 else 1870 else
1847 mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; 1871 mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
1872
1848 mmc->f_max = host->max_clk; 1873 mmc->f_max = host->max_clk;
1849 mmc->caps |= MMC_CAP_SDIO_IRQ; 1874 mmc->caps |= MMC_CAP_SDIO_IRQ;
1850 1875
1876 /*
1877 * A controller may support 8-bit width, but the board itself
1878 * might not have the pins brought out. Boards that support
1879 * 8-bit width must set "mmc->caps |= MMC_CAP_8_BIT_DATA;" in
1880 * their platform code before calling sdhci_add_host(), and we
1881 * won't assume 8-bit width for hosts without that CAP.
1882 */
1851 if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA)) 1883 if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
1852 mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; 1884 mmc->caps |= MMC_CAP_4_BIT_DATA;
1853 1885
1854 if (caps & SDHCI_CAN_DO_HISPD) 1886 if (caps & SDHCI_CAN_DO_HISPD)
1855 mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; 1887 mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index b7b8a3b28b01..e42d7f00c060 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -76,7 +76,7 @@
76#define SDHCI_CTRL_ADMA1 0x08 76#define SDHCI_CTRL_ADMA1 0x08
77#define SDHCI_CTRL_ADMA32 0x10 77#define SDHCI_CTRL_ADMA32 0x10
78#define SDHCI_CTRL_ADMA64 0x18 78#define SDHCI_CTRL_ADMA64 0x18
79#define SDHCI_CTRL_8BITBUS 0x20 79#define SDHCI_CTRL_8BITBUS 0x20
80 80
81#define SDHCI_POWER_CONTROL 0x29 81#define SDHCI_POWER_CONTROL 0x29
82#define SDHCI_POWER_ON 0x01 82#define SDHCI_POWER_ON 0x01
@@ -87,6 +87,9 @@
87#define SDHCI_BLOCK_GAP_CONTROL 0x2A 87#define SDHCI_BLOCK_GAP_CONTROL 0x2A
88 88
89#define SDHCI_WAKE_UP_CONTROL 0x2B 89#define SDHCI_WAKE_UP_CONTROL 0x2B
90#define SDHCI_WAKE_ON_INT 0x01
91#define SDHCI_WAKE_ON_INSERT 0x02
92#define SDHCI_WAKE_ON_REMOVE 0x04
90 93
91#define SDHCI_CLOCK_CONTROL 0x2C 94#define SDHCI_CLOCK_CONTROL 0x2C
92#define SDHCI_DIVIDER_SHIFT 8 95#define SDHCI_DIVIDER_SHIFT 8
@@ -152,6 +155,7 @@
152#define SDHCI_CLOCK_BASE_SHIFT 8 155#define SDHCI_CLOCK_BASE_SHIFT 8
153#define SDHCI_MAX_BLOCK_MASK 0x00030000 156#define SDHCI_MAX_BLOCK_MASK 0x00030000
154#define SDHCI_MAX_BLOCK_SHIFT 16 157#define SDHCI_MAX_BLOCK_SHIFT 16
158#define SDHCI_CAN_DO_8BIT 0x00040000
155#define SDHCI_CAN_DO_ADMA2 0x00080000 159#define SDHCI_CAN_DO_ADMA2 0x00080000
156#define SDHCI_CAN_DO_ADMA1 0x00100000 160#define SDHCI_CAN_DO_ADMA1 0x00100000
157#define SDHCI_CAN_DO_HISPD 0x00200000 161#define SDHCI_CAN_DO_HISPD 0x00200000
@@ -212,6 +216,8 @@ struct sdhci_ops {
212 unsigned int (*get_max_clock)(struct sdhci_host *host); 216 unsigned int (*get_max_clock)(struct sdhci_host *host);
213 unsigned int (*get_min_clock)(struct sdhci_host *host); 217 unsigned int (*get_min_clock)(struct sdhci_host *host);
214 unsigned int (*get_timeout_clock)(struct sdhci_host *host); 218 unsigned int (*get_timeout_clock)(struct sdhci_host *host);
219 int (*platform_8bit_width)(struct sdhci_host *host,
220 int width);
215 void (*platform_send_init_74_clocks)(struct sdhci_host *host, 221 void (*platform_send_init_74_clocks)(struct sdhci_host *host,
216 u8 power_mode); 222 u8 power_mode);
217 unsigned int (*get_ro)(struct sdhci_host *host); 223 unsigned int (*get_ro)(struct sdhci_host *host);
@@ -317,6 +323,7 @@ extern void sdhci_remove_host(struct sdhci_host *host, int dead);
317#ifdef CONFIG_PM 323#ifdef CONFIG_PM
318extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state); 324extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state);
319extern int sdhci_resume_host(struct sdhci_host *host); 325extern int sdhci_resume_host(struct sdhci_host *host);
326extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
320#endif 327#endif
321 328
322#endif /* __SDHCI_HW_H */ 329#endif /* __SDHCI_HW_H */
diff --git a/drivers/mmc/host/ushc.c b/drivers/mmc/host/ushc.c
index b4ead4a13c98..f8f65df9b017 100644
--- a/drivers/mmc/host/ushc.c
+++ b/drivers/mmc/host/ushc.c
@@ -425,7 +425,7 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
425 struct usb_device *usb_dev = interface_to_usbdev(intf); 425 struct usb_device *usb_dev = interface_to_usbdev(intf);
426 struct mmc_host *mmc; 426 struct mmc_host *mmc;
427 struct ushc_data *ushc; 427 struct ushc_data *ushc;
428 int ret = -ENOMEM; 428 int ret;
429 429
430 mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev); 430 mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev);
431 if (mmc == NULL) 431 if (mmc == NULL)
@@ -462,11 +462,15 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
462 mmc->max_blk_count = 511; 462 mmc->max_blk_count = 511;
463 463
464 ushc->int_urb = usb_alloc_urb(0, GFP_KERNEL); 464 ushc->int_urb = usb_alloc_urb(0, GFP_KERNEL);
465 if (ushc->int_urb == NULL) 465 if (ushc->int_urb == NULL) {
466 ret = -ENOMEM;
466 goto err; 467 goto err;
468 }
467 ushc->int_data = kzalloc(sizeof(struct ushc_int_data), GFP_KERNEL); 469 ushc->int_data = kzalloc(sizeof(struct ushc_int_data), GFP_KERNEL);
468 if (ushc->int_data == NULL) 470 if (ushc->int_data == NULL) {
471 ret = -ENOMEM;
469 goto err; 472 goto err;
473 }
470 usb_fill_int_urb(ushc->int_urb, ushc->usb_dev, 474 usb_fill_int_urb(ushc->int_urb, ushc->usb_dev,
471 usb_rcvintpipe(usb_dev, 475 usb_rcvintpipe(usb_dev,
472 intf->cur_altsetting->endpoint[0].desc.bEndpointAddress), 476 intf->cur_altsetting->endpoint[0].desc.bEndpointAddress),
@@ -475,11 +479,15 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
475 intf->cur_altsetting->endpoint[0].desc.bInterval); 479 intf->cur_altsetting->endpoint[0].desc.bInterval);
476 480
477 ushc->cbw_urb = usb_alloc_urb(0, GFP_KERNEL); 481 ushc->cbw_urb = usb_alloc_urb(0, GFP_KERNEL);
478 if (ushc->cbw_urb == NULL) 482 if (ushc->cbw_urb == NULL) {
483 ret = -ENOMEM;
479 goto err; 484 goto err;
485 }
480 ushc->cbw = kzalloc(sizeof(struct ushc_cbw), GFP_KERNEL); 486 ushc->cbw = kzalloc(sizeof(struct ushc_cbw), GFP_KERNEL);
481 if (ushc->cbw == NULL) 487 if (ushc->cbw == NULL) {
488 ret = -ENOMEM;
482 goto err; 489 goto err;
490 }
483 ushc->cbw->signature = USHC_CBW_SIGNATURE; 491 ushc->cbw->signature = USHC_CBW_SIGNATURE;
484 492
485 usb_fill_bulk_urb(ushc->cbw_urb, ushc->usb_dev, usb_sndbulkpipe(usb_dev, 2), 493 usb_fill_bulk_urb(ushc->cbw_urb, ushc->usb_dev, usb_sndbulkpipe(usb_dev, 2),
@@ -487,15 +495,21 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
487 cbw_callback, ushc); 495 cbw_callback, ushc);
488 496
489 ushc->data_urb = usb_alloc_urb(0, GFP_KERNEL); 497 ushc->data_urb = usb_alloc_urb(0, GFP_KERNEL);
490 if (ushc->data_urb == NULL) 498 if (ushc->data_urb == NULL) {
499 ret = -ENOMEM;
491 goto err; 500 goto err;
501 }
492 502
493 ushc->csw_urb = usb_alloc_urb(0, GFP_KERNEL); 503 ushc->csw_urb = usb_alloc_urb(0, GFP_KERNEL);
494 if (ushc->csw_urb == NULL) 504 if (ushc->csw_urb == NULL) {
505 ret = -ENOMEM;
495 goto err; 506 goto err;
507 }
496 ushc->csw = kzalloc(sizeof(struct ushc_cbw), GFP_KERNEL); 508 ushc->csw = kzalloc(sizeof(struct ushc_cbw), GFP_KERNEL);
497 if (ushc->csw == NULL) 509 if (ushc->csw == NULL) {
510 ret = -ENOMEM;
498 goto err; 511 goto err;
512 }
499 usb_fill_bulk_urb(ushc->csw_urb, ushc->usb_dev, usb_rcvbulkpipe(usb_dev, 6), 513 usb_fill_bulk_urb(ushc->csw_urb, ushc->usb_dev, usb_rcvbulkpipe(usb_dev, 6),
500 ushc->csw, sizeof(struct ushc_csw), 514 ushc->csw, sizeof(struct ushc_csw),
501 csw_callback, ushc); 515 csw_callback, ushc);
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index dd90880048cf..d8ae634d347e 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -51,7 +51,7 @@ struct pxa2xx_flash_info {
51static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 51static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
52 52
53 53
54static int __init pxa2xx_flash_probe(struct platform_device *pdev) 54static int __devinit pxa2xx_flash_probe(struct platform_device *pdev)
55{ 55{
56 struct flash_platform_data *flash = pdev->dev.platform_data; 56 struct flash_platform_data *flash = pdev->dev.platform_data;
57 struct pxa2xx_flash_info *info; 57 struct pxa2xx_flash_info *info;
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index cd41c58b5bbd..15682ec8530e 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -7,7 +7,6 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#define CONFIG_MTD_NAND_OMAP_HWECC
11 10
12#include <linux/platform_device.h> 11#include <linux/platform_device.h>
13#include <linux/dma-mapping.h> 12#include <linux/dma-mapping.h>
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index c2960ac9f39c..811775aa8ee8 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -482,10 +482,17 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
482 uint32_t data = 0; 482 uint32_t data = 0;
483 struct ubi_vid_hdr vid_hdr; 483 struct ubi_vid_hdr vid_hdr;
484 484
485 addr = (loff_t)pnum * ubi->peb_size + ubi->vid_hdr_aloffset; 485 /*
486 * It is important to first invalidate the EC header, and then the VID
487 * header. Otherwise a power cut may lead to valid EC header and
488 * invalid VID header, in which case UBI will treat this PEB as
489 * corrupted and will try to preserve it, and print scary warnings (see
490 * the header comment in scan.c for more information).
491 */
492 addr = (loff_t)pnum * ubi->peb_size;
486 err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); 493 err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data);
487 if (!err) { 494 if (!err) {
488 addr -= ubi->vid_hdr_aloffset; 495 addr += ubi->vid_hdr_aloffset;
489 err = ubi->mtd->write(ubi->mtd, addr, 4, &written, 496 err = ubi->mtd->write(ubi->mtd, addr, 4, &written,
490 (void *)&data); 497 (void *)&data);
491 if (!err) 498 if (!err)
@@ -494,18 +501,24 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
494 501
495 /* 502 /*
496 * We failed to write to the media. This was observed with Spansion 503 * We failed to write to the media. This was observed with Spansion
497 * S29GL512N NOR flash. Most probably the eraseblock erasure was 504 * S29GL512N NOR flash. Most probably the previously eraseblock erasure
498 * interrupted at a very inappropriate moment, so it became unwritable. 505 * was interrupted at a very inappropriate moment, so it became
499 * In this case we probably anyway have garbage in this PEB. 506 * unwritable. In this case we probably anyway have garbage in this
507 * PEB.
500 */ 508 */
501 err1 = ubi_io_read_vid_hdr(ubi, pnum, &vid_hdr, 0); 509 err1 = ubi_io_read_vid_hdr(ubi, pnum, &vid_hdr, 0);
502 if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR) 510 if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR) {
503 /* 511 struct ubi_ec_hdr ec_hdr;
504 * The VID header is corrupted, so we can safely erase this 512
505 * PEB and not afraid that it will be treated as a valid PEB in 513 err1 = ubi_io_read_ec_hdr(ubi, pnum, &ec_hdr, 0);
506 * case of an unclean reboot. 514 if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR)
507 */ 515 /*
508 return 0; 516 * Both VID and EC headers are corrupted, so we can
517 * safely erase this PEB and not afraid that it will be
518 * treated as a valid PEB in case of an unclean reboot.
519 */
520 return 0;
521 }
509 522
510 /* 523 /*
511 * The PEB contains a valid VID header, but we cannot invalidate it. 524 * The PEB contains a valid VID header, but we cannot invalidate it.
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 3c631863bf40..79ca304fc4db 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -787,16 +787,15 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr,
787 * erased, so it became unstable and corrupted, and should be 787 * erased, so it became unstable and corrupted, and should be
788 * erased. 788 * erased.
789 */ 789 */
790 return 0; 790 err = 0;
791 goto out_unlock;
791 } 792 }
792 793
793 if (err) 794 if (err)
794 return err; 795 goto out_unlock;
795 796
796 if (ubi_check_pattern(ubi->peb_buf1, 0xFF, ubi->leb_size)) { 797 if (ubi_check_pattern(ubi->peb_buf1, 0xFF, ubi->leb_size))
797 mutex_unlock(&ubi->buf_mutex); 798 goto out_unlock;
798 return 0;
799 }
800 799
801 ubi_err("PEB %d contains corrupted VID header, and the data does not " 800 ubi_err("PEB %d contains corrupted VID header, and the data does not "
802 "contain all 0xFF, this may be a non-UBI PEB or a severe VID " 801 "contain all 0xFF, this may be a non-UBI PEB or a severe VID "
@@ -806,8 +805,11 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr,
806 pnum, ubi->leb_start, ubi->leb_size); 805 pnum, ubi->leb_start, ubi->leb_size);
807 ubi_dbg_print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, 806 ubi_dbg_print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
808 ubi->peb_buf1, ubi->leb_size, 1); 807 ubi->peb_buf1, ubi->leb_size, 1);
808 err = 1;
809
810out_unlock:
809 mutex_unlock(&ubi->buf_mutex); 811 mutex_unlock(&ubi->buf_mutex);
810 return 1; 812 return err;
811} 813}
812 814
813/** 815/**
@@ -951,6 +953,10 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
951 * impossible to distinguish it from a PEB which just 953 * impossible to distinguish it from a PEB which just
952 * contains garbage because of a power cut during erase 954 * contains garbage because of a power cut during erase
953 * operation. So we just schedule this PEB for erasure. 955 * operation. So we just schedule this PEB for erasure.
956 *
957 * Besides, in case of NOR flash, we deliberatly
958 * corrupt both headers because NOR flash erasure is
959 * slow and can start from the end.
954 */ 960 */
955 err = 0; 961 err = 0;
956 else 962 else
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index e1da258bbfb7..0a92436f0538 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -699,7 +699,8 @@ DEFINE_WINDOW_IO(32)
699#define DEVICE_PCI(dev) NULL 699#define DEVICE_PCI(dev) NULL
700#endif 700#endif
701 701
702#define VORTEX_PCI(vp) (((vp)->gendev) ? DEVICE_PCI((vp)->gendev) : NULL) 702#define VORTEX_PCI(vp) \
703 ((struct pci_dev *) (((vp)->gendev) ? DEVICE_PCI((vp)->gendev) : NULL))
703 704
704#ifdef CONFIG_EISA 705#ifdef CONFIG_EISA
705#define DEVICE_EISA(dev) (((dev)->bus == &eisa_bus_type) ? to_eisa_device((dev)) : NULL) 706#define DEVICE_EISA(dev) (((dev)->bus == &eisa_bus_type) ? to_eisa_device((dev)) : NULL)
@@ -707,7 +708,8 @@ DEFINE_WINDOW_IO(32)
707#define DEVICE_EISA(dev) NULL 708#define DEVICE_EISA(dev) NULL
708#endif 709#endif
709 710
710#define VORTEX_EISA(vp) (((vp)->gendev) ? DEVICE_EISA((vp)->gendev) : NULL) 711#define VORTEX_EISA(vp) \
712 ((struct eisa_device *) (((vp)->gendev) ? DEVICE_EISA((vp)->gendev) : NULL))
711 713
712/* The action to take with a media selection timer tick. 714/* The action to take with a media selection timer tick.
713 Note that we deviate from the 3Com order by checking 10base2 before AUI. 715 Note that we deviate from the 3Com order by checking 10base2 before AUI.
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index ac422cd332ea..dd16e83933a2 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -490,13 +490,11 @@ static inline unsigned int cp_rx_csum_ok (u32 status)
490{ 490{
491 unsigned int protocol = (status >> 16) & 0x3; 491 unsigned int protocol = (status >> 16) & 0x3;
492 492
493 if (likely((protocol == RxProtoTCP) && (!(status & TCPFail)))) 493 if (((protocol == RxProtoTCP) && !(status & TCPFail)) ||
494 ((protocol == RxProtoUDP) && !(status & UDPFail)))
494 return 1; 495 return 1;
495 else if ((protocol == RxProtoUDP) && (!(status & UDPFail))) 496 else
496 return 1; 497 return 0;
497 else if ((protocol == RxProtoIP) && (!(status & IPFail)))
498 return 1;
499 return 0;
500} 498}
501 499
502static int cp_rx_poll(struct napi_struct *napi, int budget) 500static int cp_rx_poll(struct napi_struct *napi, int budget)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index f6668cdaac85..4f1755bddf6b 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2543,10 +2543,10 @@ config PCH_GBE
2543 depends on PCI 2543 depends on PCI
2544 select MII 2544 select MII
2545 ---help--- 2545 ---help---
2546 This is a gigabit ethernet driver for Topcliff PCH. 2546 This is a gigabit ethernet driver for EG20T PCH.
2547 Topcliff PCH is the platform controller hub that is used in Intel's 2547 EG20T PCH is the platform controller hub that is used in Intel's
2548 general embedded platform. 2548 general embedded platform.
2549 Topcliff PCH has Gigabit Ethernet interface. 2549 EG20T PCH has Gigabit Ethernet interface.
2550 Using this interface, it is able to access system devices connected 2550 Using this interface, it is able to access system devices connected
2551 to Gigabit Ethernet. 2551 to Gigabit Ethernet.
2552 This driver enables Gigabit Ethernet function. 2552 This driver enables Gigabit Ethernet function.
@@ -2945,6 +2945,18 @@ source "drivers/s390/net/Kconfig"
2945 2945
2946source "drivers/net/caif/Kconfig" 2946source "drivers/net/caif/Kconfig"
2947 2947
2948config TILE_NET
2949 tristate "Tilera GBE/XGBE network driver support"
2950 depends on TILE
2951 default y
2952 select CRC32
2953 help
2954 This is a standard Linux network device driver for the
2955 on-chip Tilera Gigabit Ethernet and XAUI interfaces.
2956
2957 To compile this driver as a module, choose M here: the module
2958 will be called tile_net.
2959
2948config XEN_NETDEV_FRONTEND 2960config XEN_NETDEV_FRONTEND
2949 tristate "Xen network device frontend driver" 2961 tristate "Xen network device frontend driver"
2950 depends on XEN 2962 depends on XEN
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 652fc6b98039..b90738d13994 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -301,3 +301,4 @@ obj-$(CONFIG_CAIF) += caif/
301 301
302obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/ 302obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/
303obj-$(CONFIG_PCH_GBE) += pch_gbe/ 303obj-$(CONFIG_PCH_GBE) += pch_gbe/
304obj-$(CONFIG_TILE_NET) += tile/
diff --git a/drivers/net/atl1c/atl1c_hw.c b/drivers/net/atl1c/atl1c_hw.c
index 919080b2c3a5..1bf672009948 100644
--- a/drivers/net/atl1c/atl1c_hw.c
+++ b/drivers/net/atl1c/atl1c_hw.c
@@ -82,7 +82,7 @@ static int atl1c_get_permanent_address(struct atl1c_hw *hw)
82 addr[0] = addr[1] = 0; 82 addr[0] = addr[1] = 0;
83 AT_READ_REG(hw, REG_OTP_CTRL, &otp_ctrl_data); 83 AT_READ_REG(hw, REG_OTP_CTRL, &otp_ctrl_data);
84 if (atl1c_check_eeprom_exist(hw)) { 84 if (atl1c_check_eeprom_exist(hw)) {
85 if (hw->nic_type == athr_l1c || hw->nic_type == athr_l2c_b) { 85 if (hw->nic_type == athr_l1c || hw->nic_type == athr_l2c) {
86 /* Enable OTP CLK */ 86 /* Enable OTP CLK */
87 if (!(otp_ctrl_data & OTP_CTRL_CLK_EN)) { 87 if (!(otp_ctrl_data & OTP_CTRL_CLK_EN)) {
88 otp_ctrl_data |= OTP_CTRL_CLK_EN; 88 otp_ctrl_data |= OTP_CTRL_CLK_EN;
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 43489f89c142..53eff9ba6e95 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -155,10 +155,10 @@ static void au1000_enable_mac(struct net_device *dev, int force_reset)
155 spin_lock_irqsave(&aup->lock, flags); 155 spin_lock_irqsave(&aup->lock, flags);
156 156
157 if (force_reset || (!aup->mac_enabled)) { 157 if (force_reset || (!aup->mac_enabled)) {
158 writel(MAC_EN_CLOCK_ENABLE, &aup->enable); 158 writel(MAC_EN_CLOCK_ENABLE, aup->enable);
159 au_sync_delay(2); 159 au_sync_delay(2);
160 writel((MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2 160 writel((MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2
161 | MAC_EN_CLOCK_ENABLE), &aup->enable); 161 | MAC_EN_CLOCK_ENABLE), aup->enable);
162 au_sync_delay(2); 162 au_sync_delay(2);
163 163
164 aup->mac_enabled = 1; 164 aup->mac_enabled = 1;
@@ -503,9 +503,9 @@ static void au1000_reset_mac_unlocked(struct net_device *dev)
503 503
504 au1000_hard_stop(dev); 504 au1000_hard_stop(dev);
505 505
506 writel(MAC_EN_CLOCK_ENABLE, &aup->enable); 506 writel(MAC_EN_CLOCK_ENABLE, aup->enable);
507 au_sync_delay(2); 507 au_sync_delay(2);
508 writel(0, &aup->enable); 508 writel(0, aup->enable);
509 au_sync_delay(2); 509 au_sync_delay(2);
510 510
511 aup->tx_full = 0; 511 aup->tx_full = 0;
@@ -1119,7 +1119,7 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1119 /* set a random MAC now in case platform_data doesn't provide one */ 1119 /* set a random MAC now in case platform_data doesn't provide one */
1120 random_ether_addr(dev->dev_addr); 1120 random_ether_addr(dev->dev_addr);
1121 1121
1122 writel(0, &aup->enable); 1122 writel(0, aup->enable);
1123 aup->mac_enabled = 0; 1123 aup->mac_enabled = 0;
1124 1124
1125 pd = pdev->dev.platform_data; 1125 pd = pdev->dev.platform_data;
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index c6e86315b3f8..2e2b76258ab4 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -381,11 +381,11 @@ static void b44_set_flow_ctrl(struct b44 *bp, u32 local, u32 remote)
381 __b44_set_flow_ctrl(bp, pause_enab); 381 __b44_set_flow_ctrl(bp, pause_enab);
382} 382}
383 383
384#ifdef SSB_DRIVER_MIPS 384#ifdef CONFIG_BCM47XX
385extern char *nvram_get(char *name); 385#include <asm/mach-bcm47xx/nvram.h>
386static void b44_wap54g10_workaround(struct b44 *bp) 386static void b44_wap54g10_workaround(struct b44 *bp)
387{ 387{
388 const char *str; 388 char buf[20];
389 u32 val; 389 u32 val;
390 int err; 390 int err;
391 391
@@ -394,10 +394,9 @@ static void b44_wap54g10_workaround(struct b44 *bp)
394 * see https://dev.openwrt.org/ticket/146 394 * see https://dev.openwrt.org/ticket/146
395 * check and reset bit "isolate" 395 * check and reset bit "isolate"
396 */ 396 */
397 str = nvram_get("boardnum"); 397 if (nvram_getenv("boardnum", buf, sizeof(buf)) < 0)
398 if (!str)
399 return; 398 return;
400 if (simple_strtoul(str, NULL, 0) == 2) { 399 if (simple_strtoul(buf, NULL, 0) == 2) {
401 err = __b44_readphy(bp, 0, MII_BMCR, &val); 400 err = __b44_readphy(bp, 0, MII_BMCR, &val);
402 if (err) 401 if (err)
403 goto error; 402 goto error;
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 36eca1ce75d4..e4465d222a7d 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -1235,7 +1235,7 @@ int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id,
1235 1235
1236 i = 0; 1236 i = 0;
1237 netdev_for_each_mc_addr(ha, netdev) 1237 netdev_for_each_mc_addr(ha, netdev)
1238 memcpy(req->mac[i].byte, ha->addr, ETH_ALEN); 1238 memcpy(req->mac[i++].byte, ha->addr, ETH_ALEN);
1239 } else { 1239 } else {
1240 req->promiscuous = 1; 1240 req->promiscuous = 1;
1241 } 1241 }
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index c36cd2ffbadc..93354eee2cfd 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -2458,6 +2458,12 @@ int be_load_fw(struct be_adapter *adapter, u8 *func)
2458 int status, i = 0, num_imgs = 0; 2458 int status, i = 0, num_imgs = 0;
2459 const u8 *p; 2459 const u8 *p;
2460 2460
2461 if (!netif_running(adapter->netdev)) {
2462 dev_err(&adapter->pdev->dev,
2463 "Firmware load not allowed (interface is down)\n");
2464 return -EPERM;
2465 }
2466
2461 strcpy(fw_file, func); 2467 strcpy(fw_file, func);
2462 2468
2463 status = request_firmware(&fw, fw_file, &adapter->pdev->dev); 2469 status = request_firmware(&fw, fw_file, &adapter->pdev->dev);
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 863e73a85fbe..d255428122fc 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -20,8 +20,8 @@
20 * (you will need to reboot afterwards) */ 20 * (you will need to reboot afterwards) */
21/* #define BNX2X_STOP_ON_ERROR */ 21/* #define BNX2X_STOP_ON_ERROR */
22 22
23#define DRV_MODULE_VERSION "1.60.00-4" 23#define DRV_MODULE_VERSION "1.60.01-0"
24#define DRV_MODULE_RELDATE "2010/11/01" 24#define DRV_MODULE_RELDATE "2010/11/12"
25#define BNX2X_BC_VER 0x040200 25#define BNX2X_BC_VER 0x040200
26 26
27#define BNX2X_MULTI_QUEUE 27#define BNX2X_MULTI_QUEUE
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index 94d5f59d5a6f..0af361e4e3d1 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -1782,15 +1782,15 @@ exit_lbl:
1782} 1782}
1783#endif 1783#endif
1784 1784
1785static inline void bnx2x_set_pbd_gso_e2(struct sk_buff *skb, 1785static inline void bnx2x_set_pbd_gso_e2(struct sk_buff *skb, u32 *parsing_data,
1786 struct eth_tx_parse_bd_e2 *pbd, 1786 u32 xmit_type)
1787 u32 xmit_type)
1788{ 1787{
1789 pbd->parsing_data |= cpu_to_le16(skb_shinfo(skb)->gso_size) << 1788 *parsing_data |= (skb_shinfo(skb)->gso_size <<
1790 ETH_TX_PARSE_BD_E2_LSO_MSS_SHIFT; 1789 ETH_TX_PARSE_BD_E2_LSO_MSS_SHIFT) &
1790 ETH_TX_PARSE_BD_E2_LSO_MSS;
1791 if ((xmit_type & XMIT_GSO_V6) && 1791 if ((xmit_type & XMIT_GSO_V6) &&
1792 (ipv6_hdr(skb)->nexthdr == NEXTHDR_IPV6)) 1792 (ipv6_hdr(skb)->nexthdr == NEXTHDR_IPV6))
1793 pbd->parsing_data |= ETH_TX_PARSE_BD_E2_IPV6_WITH_EXT_HDR; 1793 *parsing_data |= ETH_TX_PARSE_BD_E2_IPV6_WITH_EXT_HDR;
1794} 1794}
1795 1795
1796/** 1796/**
@@ -1835,15 +1835,15 @@ static inline void bnx2x_set_pbd_gso(struct sk_buff *skb,
1835 * @return header len 1835 * @return header len
1836 */ 1836 */
1837static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb, 1837static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb,
1838 struct eth_tx_parse_bd_e2 *pbd, 1838 u32 *parsing_data, u32 xmit_type)
1839 u32 xmit_type)
1840{ 1839{
1841 pbd->parsing_data |= cpu_to_le16(tcp_hdrlen(skb)/4) << 1840 *parsing_data |= ((tcp_hdrlen(skb)/4) <<
1842 ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT; 1841 ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT) &
1842 ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW;
1843 1843
1844 pbd->parsing_data |= cpu_to_le16(((unsigned char *)tcp_hdr(skb) - 1844 *parsing_data |= ((((u8 *)tcp_hdr(skb) - skb->data) / 2) <<
1845 skb->data) / 2) << 1845 ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT) &
1846 ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT; 1846 ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W;
1847 1847
1848 return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data; 1848 return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data;
1849} 1849}
@@ -1912,6 +1912,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
1912 struct eth_tx_bd *tx_data_bd, *total_pkt_bd = NULL; 1912 struct eth_tx_bd *tx_data_bd, *total_pkt_bd = NULL;
1913 struct eth_tx_parse_bd_e1x *pbd_e1x = NULL; 1913 struct eth_tx_parse_bd_e1x *pbd_e1x = NULL;
1914 struct eth_tx_parse_bd_e2 *pbd_e2 = NULL; 1914 struct eth_tx_parse_bd_e2 *pbd_e2 = NULL;
1915 u32 pbd_e2_parsing_data = 0;
1915 u16 pkt_prod, bd_prod; 1916 u16 pkt_prod, bd_prod;
1916 int nbd, fp_index; 1917 int nbd, fp_index;
1917 dma_addr_t mapping; 1918 dma_addr_t mapping;
@@ -2033,8 +2034,9 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
2033 memset(pbd_e2, 0, sizeof(struct eth_tx_parse_bd_e2)); 2034 memset(pbd_e2, 0, sizeof(struct eth_tx_parse_bd_e2));
2034 /* Set PBD in checksum offload case */ 2035 /* Set PBD in checksum offload case */
2035 if (xmit_type & XMIT_CSUM) 2036 if (xmit_type & XMIT_CSUM)
2036 hlen = bnx2x_set_pbd_csum_e2(bp, 2037 hlen = bnx2x_set_pbd_csum_e2(bp, skb,
2037 skb, pbd_e2, xmit_type); 2038 &pbd_e2_parsing_data,
2039 xmit_type);
2038 } else { 2040 } else {
2039 pbd_e1x = &fp->tx_desc_ring[bd_prod].parse_bd_e1x; 2041 pbd_e1x = &fp->tx_desc_ring[bd_prod].parse_bd_e1x;
2040 memset(pbd_e1x, 0, sizeof(struct eth_tx_parse_bd_e1x)); 2042 memset(pbd_e1x, 0, sizeof(struct eth_tx_parse_bd_e1x));
@@ -2076,10 +2078,18 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
2076 bd_prod = bnx2x_tx_split(bp, fp, tx_buf, &tx_start_bd, 2078 bd_prod = bnx2x_tx_split(bp, fp, tx_buf, &tx_start_bd,
2077 hlen, bd_prod, ++nbd); 2079 hlen, bd_prod, ++nbd);
2078 if (CHIP_IS_E2(bp)) 2080 if (CHIP_IS_E2(bp))
2079 bnx2x_set_pbd_gso_e2(skb, pbd_e2, xmit_type); 2081 bnx2x_set_pbd_gso_e2(skb, &pbd_e2_parsing_data,
2082 xmit_type);
2080 else 2083 else
2081 bnx2x_set_pbd_gso(skb, pbd_e1x, xmit_type); 2084 bnx2x_set_pbd_gso(skb, pbd_e1x, xmit_type);
2082 } 2085 }
2086
2087 /* Set the PBD's parsing_data field if not zero
2088 * (for the chips newer than 57711).
2089 */
2090 if (pbd_e2_parsing_data)
2091 pbd_e2->parsing_data = cpu_to_le32(pbd_e2_parsing_data);
2092
2083 tx_data_bd = (struct eth_tx_bd *)tx_start_bd; 2093 tx_data_bd = (struct eth_tx_bd *)tx_start_bd;
2084 2094
2085 /* Handle fragmented skb */ 2095 /* Handle fragmented skb */
diff --git a/drivers/net/bnx2x/bnx2x_init_ops.h b/drivers/net/bnx2x/bnx2x_init_ops.h
index a306b0e46b61..66df29fcf751 100644
--- a/drivers/net/bnx2x/bnx2x_init_ops.h
+++ b/drivers/net/bnx2x/bnx2x_init_ops.h
@@ -838,7 +838,7 @@ static void bnx2x_qm_init_ptr_table(struct bnx2x *bp, int qm_cid_count,
838/**************************************************************************** 838/****************************************************************************
839* SRC initializations 839* SRC initializations
840****************************************************************************/ 840****************************************************************************/
841 841#ifdef BCM_CNIC
842/* called during init func stage */ 842/* called during init func stage */
843static void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2, 843static void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2,
844 dma_addr_t t2_mapping, int src_cid_count) 844 dma_addr_t t2_mapping, int src_cid_count)
@@ -862,5 +862,5 @@ static void bnx2x_src_init_t2(struct bnx2x *bp, struct src_ent *t2,
862 U64_HI((u64)t2_mapping + 862 U64_HI((u64)t2_mapping +
863 (src_cid_count-1) * sizeof(struct src_ent))); 863 (src_cid_count-1) * sizeof(struct src_ent)));
864} 864}
865 865#endif
866#endif /* BNX2X_INIT_OPS_H */ 866#endif /* BNX2X_INIT_OPS_H */
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index e9ad16f00b56..9709b8569666 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -9064,7 +9064,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
9064 default: 9064 default:
9065 pr_err("Unknown board_type (%ld), aborting\n", 9065 pr_err("Unknown board_type (%ld), aborting\n",
9066 ent->driver_data); 9066 ent->driver_data);
9067 return ENODEV; 9067 return -ENODEV;
9068 } 9068 }
9069 9069
9070 cid_count += CNIC_CONTEXT_USE; 9070 cid_count += CNIC_CONTEXT_USE;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index bdb68a600382..d0ea760ce419 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -171,7 +171,7 @@ MODULE_PARM_DESC(resend_igmp, "Number of IGMP membership reports to send on link
171/*----------------------------- Global variables ----------------------------*/ 171/*----------------------------- Global variables ----------------------------*/
172 172
173#ifdef CONFIG_NET_POLL_CONTROLLER 173#ifdef CONFIG_NET_POLL_CONTROLLER
174cpumask_var_t netpoll_block_tx; 174atomic_t netpoll_block_tx = ATOMIC_INIT(0);
175#endif 175#endif
176 176
177static const char * const version = 177static const char * const version =
@@ -878,8 +878,10 @@ static void __bond_resend_igmp_join_requests(struct net_device *dev)
878 rcu_read_lock(); 878 rcu_read_lock();
879 in_dev = __in_dev_get_rcu(dev); 879 in_dev = __in_dev_get_rcu(dev);
880 if (in_dev) { 880 if (in_dev) {
881 read_lock(&in_dev->mc_list_lock);
881 for (im = in_dev->mc_list; im; im = im->next) 882 for (im = in_dev->mc_list; im; im = im->next)
882 ip_mc_rejoin_group(im); 883 ip_mc_rejoin_group(im);
884 read_unlock(&in_dev->mc_list_lock);
883 } 885 }
884 886
885 rcu_read_unlock(); 887 rcu_read_unlock();
@@ -1574,7 +1576,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1574 1576
1575 /* If this is the first slave, then we need to set the master's hardware 1577 /* If this is the first slave, then we need to set the master's hardware
1576 * address to be the same as the slave's. */ 1578 * address to be the same as the slave's. */
1577 if (bond->slave_cnt == 0) 1579 if (is_zero_ether_addr(bond->dev->dev_addr))
1578 memcpy(bond->dev->dev_addr, slave_dev->dev_addr, 1580 memcpy(bond->dev->dev_addr, slave_dev->dev_addr,
1579 slave_dev->addr_len); 1581 slave_dev->addr_len);
1580 1582
@@ -5297,13 +5299,6 @@ static int __init bonding_init(void)
5297 if (res) 5299 if (res)
5298 goto out; 5300 goto out;
5299 5301
5300#ifdef CONFIG_NET_POLL_CONTROLLER
5301 if (!alloc_cpumask_var(&netpoll_block_tx, GFP_KERNEL)) {
5302 res = -ENOMEM;
5303 goto out;
5304 }
5305#endif
5306
5307 res = register_pernet_subsys(&bond_net_ops); 5302 res = register_pernet_subsys(&bond_net_ops);
5308 if (res) 5303 if (res)
5309 goto out; 5304 goto out;
@@ -5332,9 +5327,6 @@ err:
5332 rtnl_link_unregister(&bond_link_ops); 5327 rtnl_link_unregister(&bond_link_ops);
5333err_link: 5328err_link:
5334 unregister_pernet_subsys(&bond_net_ops); 5329 unregister_pernet_subsys(&bond_net_ops);
5335#ifdef CONFIG_NET_POLL_CONTROLLER
5336 free_cpumask_var(netpoll_block_tx);
5337#endif
5338 goto out; 5330 goto out;
5339 5331
5340} 5332}
@@ -5351,7 +5343,10 @@ static void __exit bonding_exit(void)
5351 unregister_pernet_subsys(&bond_net_ops); 5343 unregister_pernet_subsys(&bond_net_ops);
5352 5344
5353#ifdef CONFIG_NET_POLL_CONTROLLER 5345#ifdef CONFIG_NET_POLL_CONTROLLER
5354 free_cpumask_var(netpoll_block_tx); 5346 /*
5347 * Make sure we don't have an imbalance on our netpoll blocking
5348 */
5349 WARN_ON(atomic_read(&netpoll_block_tx));
5355#endif 5350#endif
5356} 5351}
5357 5352
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 4eedb12df6ca..c2f081352a03 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -119,26 +119,22 @@
119 119
120 120
121#ifdef CONFIG_NET_POLL_CONTROLLER 121#ifdef CONFIG_NET_POLL_CONTROLLER
122extern cpumask_var_t netpoll_block_tx; 122extern atomic_t netpoll_block_tx;
123 123
124static inline void block_netpoll_tx(void) 124static inline void block_netpoll_tx(void)
125{ 125{
126 preempt_disable(); 126 atomic_inc(&netpoll_block_tx);
127 BUG_ON(cpumask_test_and_set_cpu(smp_processor_id(),
128 netpoll_block_tx));
129} 127}
130 128
131static inline void unblock_netpoll_tx(void) 129static inline void unblock_netpoll_tx(void)
132{ 130{
133 BUG_ON(!cpumask_test_and_clear_cpu(smp_processor_id(), 131 atomic_dec(&netpoll_block_tx);
134 netpoll_block_tx));
135 preempt_enable();
136} 132}
137 133
138static inline int is_netpoll_tx_blocked(struct net_device *dev) 134static inline int is_netpoll_tx_blocked(struct net_device *dev)
139{ 135{
140 if (unlikely(dev->priv_flags & IFF_IN_NETPOLL)) 136 if (unlikely(dev->priv_flags & IFF_IN_NETPOLL))
141 return cpumask_test_cpu(smp_processor_id(), netpoll_block_tx); 137 return atomic_read(&netpoll_block_tx);
142 return 0; 138 return 0;
143} 139}
144#else 140#else
diff --git a/drivers/net/caif/caif_shm_u5500.c b/drivers/net/caif/caif_shm_u5500.c
index 1cd90da86f13..32b1c6fb2de1 100644
--- a/drivers/net/caif/caif_shm_u5500.c
+++ b/drivers/net/caif/caif_shm_u5500.c
@@ -5,7 +5,7 @@
5 * License terms: GNU General Public License (GPL) version 2 5 * License terms: GNU General Public License (GPL) version 2
6 */ 6 */
7 7
8#define pr_fmt(fmt) KBUILD_MODNAME ":" __func__ "():" fmt 8#define pr_fmt(fmt) KBUILD_MODNAME ":" fmt
9 9
10#include <linux/version.h> 10#include <linux/version.h>
11#include <linux/init.h> 11#include <linux/init.h>
diff --git a/drivers/net/caif/caif_shmcore.c b/drivers/net/caif/caif_shmcore.c
index 19f9c0656667..80511167f35b 100644
--- a/drivers/net/caif/caif_shmcore.c
+++ b/drivers/net/caif/caif_shmcore.c
@@ -6,7 +6,7 @@
6 * License terms: GNU General Public License (GPL) version 2 6 * License terms: GNU General Public License (GPL) version 2
7 */ 7 */
8 8
9#define pr_fmt(fmt) KBUILD_MODNAME ":" __func__ "():" fmt 9#define pr_fmt(fmt) KBUILD_MODNAME ":" fmt
10 10
11#include <linux/spinlock.h> 11#include <linux/spinlock.h>
12#include <linux/sched.h> 12#include <linux/sched.h>
diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index 8b4cea57a6c5..20da1996d354 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -635,8 +635,8 @@ int cfspi_spi_probe(struct platform_device *pdev)
635 635
636 ndev = alloc_netdev(sizeof(struct cfspi), 636 ndev = alloc_netdev(sizeof(struct cfspi),
637 "cfspi%d", cfspi_setup); 637 "cfspi%d", cfspi_setup);
638 if (!dev) 638 if (!ndev)
639 return -ENODEV; 639 return -ENOMEM;
640 640
641 cfspi = netdev_priv(ndev); 641 cfspi = netdev_priv(ndev);
642 netif_stop_queue(ndev); 642 netif_stop_queue(ndev);
diff --git a/drivers/net/cxgb4/t4_hw.c b/drivers/net/cxgb4/t4_hw.c
index bb813d94aea8..e97521c801ea 100644
--- a/drivers/net/cxgb4/t4_hw.c
+++ b/drivers/net/cxgb4/t4_hw.c
@@ -2408,7 +2408,7 @@ int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
2408 if (index < NEXACT_MAC) 2408 if (index < NEXACT_MAC)
2409 ret++; 2409 ret++;
2410 else if (hash) 2410 else if (hash)
2411 *hash |= (1 << hash_mac_addr(addr[i])); 2411 *hash |= (1ULL << hash_mac_addr(addr[i]));
2412 } 2412 }
2413 return ret; 2413 return ret;
2414} 2414}
diff --git a/drivers/net/cxgb4vf/cxgb4vf_main.c b/drivers/net/cxgb4vf/cxgb4vf_main.c
index c3449bbc585a..6bf464afa90e 100644
--- a/drivers/net/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/cxgb4vf/cxgb4vf_main.c
@@ -816,40 +816,48 @@ static struct net_device_stats *cxgb4vf_get_stats(struct net_device *dev)
816} 816}
817 817
818/* 818/*
819 * Collect up to maxaddrs worth of a netdevice's unicast addresses into an 819 * Collect up to maxaddrs worth of a netdevice's unicast addresses, starting
820 * array of addrss pointers and return the number collected. 820 * at a specified offset within the list, into an array of addrss pointers and
821 * return the number collected.
821 */ 822 */
822static inline int collect_netdev_uc_list_addrs(const struct net_device *dev, 823static inline unsigned int collect_netdev_uc_list_addrs(const struct net_device *dev,
823 const u8 **addr, 824 const u8 **addr,
824 unsigned int maxaddrs) 825 unsigned int offset,
826 unsigned int maxaddrs)
825{ 827{
828 unsigned int index = 0;
826 unsigned int naddr = 0; 829 unsigned int naddr = 0;
827 const struct netdev_hw_addr *ha; 830 const struct netdev_hw_addr *ha;
828 831
829 for_each_dev_addr(dev, ha) { 832 for_each_dev_addr(dev, ha)
830 addr[naddr++] = ha->addr; 833 if (index++ >= offset) {
831 if (naddr >= maxaddrs) 834 addr[naddr++] = ha->addr;
832 break; 835 if (naddr >= maxaddrs)
833 } 836 break;
837 }
834 return naddr; 838 return naddr;
835} 839}
836 840
837/* 841/*
838 * Collect up to maxaddrs worth of a netdevice's multicast addresses into an 842 * Collect up to maxaddrs worth of a netdevice's multicast addresses, starting
839 * array of addrss pointers and return the number collected. 843 * at a specified offset within the list, into an array of addrss pointers and
844 * return the number collected.
840 */ 845 */
841static inline int collect_netdev_mc_list_addrs(const struct net_device *dev, 846static inline unsigned int collect_netdev_mc_list_addrs(const struct net_device *dev,
842 const u8 **addr, 847 const u8 **addr,
843 unsigned int maxaddrs) 848 unsigned int offset,
849 unsigned int maxaddrs)
844{ 850{
851 unsigned int index = 0;
845 unsigned int naddr = 0; 852 unsigned int naddr = 0;
846 const struct netdev_hw_addr *ha; 853 const struct netdev_hw_addr *ha;
847 854
848 netdev_for_each_mc_addr(ha, dev) { 855 netdev_for_each_mc_addr(ha, dev)
849 addr[naddr++] = ha->addr; 856 if (index++ >= offset) {
850 if (naddr >= maxaddrs) 857 addr[naddr++] = ha->addr;
851 break; 858 if (naddr >= maxaddrs)
852 } 859 break;
860 }
853 return naddr; 861 return naddr;
854} 862}
855 863
@@ -862,16 +870,20 @@ static int set_addr_filters(const struct net_device *dev, bool sleep)
862 u64 mhash = 0; 870 u64 mhash = 0;
863 u64 uhash = 0; 871 u64 uhash = 0;
864 bool free = true; 872 bool free = true;
865 u16 filt_idx[7]; 873 unsigned int offset, naddr;
866 const u8 *addr[7]; 874 const u8 *addr[7];
867 int ret, naddr = 0; 875 int ret;
868 const struct port_info *pi = netdev_priv(dev); 876 const struct port_info *pi = netdev_priv(dev);
869 877
870 /* first do the secondary unicast addresses */ 878 /* first do the secondary unicast addresses */
871 naddr = collect_netdev_uc_list_addrs(dev, addr, ARRAY_SIZE(addr)); 879 for (offset = 0; ; offset += naddr) {
872 if (naddr > 0) { 880 naddr = collect_netdev_uc_list_addrs(dev, addr, offset,
881 ARRAY_SIZE(addr));
882 if (naddr == 0)
883 break;
884
873 ret = t4vf_alloc_mac_filt(pi->adapter, pi->viid, free, 885 ret = t4vf_alloc_mac_filt(pi->adapter, pi->viid, free,
874 naddr, addr, filt_idx, &uhash, sleep); 886 naddr, addr, NULL, &uhash, sleep);
875 if (ret < 0) 887 if (ret < 0)
876 return ret; 888 return ret;
877 889
@@ -879,12 +891,17 @@ static int set_addr_filters(const struct net_device *dev, bool sleep)
879 } 891 }
880 892
881 /* next set up the multicast addresses */ 893 /* next set up the multicast addresses */
882 naddr = collect_netdev_mc_list_addrs(dev, addr, ARRAY_SIZE(addr)); 894 for (offset = 0; ; offset += naddr) {
883 if (naddr > 0) { 895 naddr = collect_netdev_mc_list_addrs(dev, addr, offset,
896 ARRAY_SIZE(addr));
897 if (naddr == 0)
898 break;
899
884 ret = t4vf_alloc_mac_filt(pi->adapter, pi->viid, free, 900 ret = t4vf_alloc_mac_filt(pi->adapter, pi->viid, free,
885 naddr, addr, filt_idx, &mhash, sleep); 901 naddr, addr, NULL, &mhash, sleep);
886 if (ret < 0) 902 if (ret < 0)
887 return ret; 903 return ret;
904 free = false;
888 } 905 }
889 906
890 return t4vf_set_addr_hash(pi->adapter, pi->viid, uhash != 0, 907 return t4vf_set_addr_hash(pi->adapter, pi->viid, uhash != 0,
@@ -2252,6 +2269,7 @@ static void __devinit cfg_queues(struct adapter *adapter)
2252{ 2269{
2253 struct sge *s = &adapter->sge; 2270 struct sge *s = &adapter->sge;
2254 int q10g, n10g, qidx, pidx, qs; 2271 int q10g, n10g, qidx, pidx, qs;
2272 size_t iqe_size;
2255 2273
2256 /* 2274 /*
2257 * We should not be called till we know how many Queue Sets we can 2275 * We should not be called till we know how many Queue Sets we can
@@ -2296,6 +2314,13 @@ static void __devinit cfg_queues(struct adapter *adapter)
2296 s->ethqsets = qidx; 2314 s->ethqsets = qidx;
2297 2315
2298 /* 2316 /*
2317 * The Ingress Queue Entry Size for our various Response Queues needs
2318 * to be big enough to accommodate the largest message we can receive
2319 * from the chip/firmware; which is 64 bytes ...
2320 */
2321 iqe_size = 64;
2322
2323 /*
2299 * Set up default Queue Set parameters ... Start off with the 2324 * Set up default Queue Set parameters ... Start off with the
2300 * shortest interrupt holdoff timer. 2325 * shortest interrupt holdoff timer.
2301 */ 2326 */
@@ -2303,7 +2328,7 @@ static void __devinit cfg_queues(struct adapter *adapter)
2303 struct sge_eth_rxq *rxq = &s->ethrxq[qs]; 2328 struct sge_eth_rxq *rxq = &s->ethrxq[qs];
2304 struct sge_eth_txq *txq = &s->ethtxq[qs]; 2329 struct sge_eth_txq *txq = &s->ethtxq[qs];
2305 2330
2306 init_rspq(&rxq->rspq, 0, 0, 1024, L1_CACHE_BYTES); 2331 init_rspq(&rxq->rspq, 0, 0, 1024, iqe_size);
2307 rxq->fl.size = 72; 2332 rxq->fl.size = 72;
2308 txq->q.size = 1024; 2333 txq->q.size = 1024;
2309 } 2334 }
@@ -2312,8 +2337,7 @@ static void __devinit cfg_queues(struct adapter *adapter)
2312 * The firmware event queue is used for link state changes and 2337 * The firmware event queue is used for link state changes and
2313 * notifications of TX DMA completions. 2338 * notifications of TX DMA completions.
2314 */ 2339 */
2315 init_rspq(&s->fw_evtq, SGE_TIMER_RSTRT_CNTR, 0, 512, 2340 init_rspq(&s->fw_evtq, SGE_TIMER_RSTRT_CNTR, 0, 512, iqe_size);
2316 L1_CACHE_BYTES);
2317 2341
2318 /* 2342 /*
2319 * The forwarded interrupt queue is used when we're in MSI interrupt 2343 * The forwarded interrupt queue is used when we're in MSI interrupt
@@ -2329,7 +2353,7 @@ static void __devinit cfg_queues(struct adapter *adapter)
2329 * any time ... 2353 * any time ...
2330 */ 2354 */
2331 init_rspq(&s->intrq, SGE_TIMER_RSTRT_CNTR, 0, MSIX_ENTRIES + 1, 2355 init_rspq(&s->intrq, SGE_TIMER_RSTRT_CNTR, 0, MSIX_ENTRIES + 1,
2332 L1_CACHE_BYTES); 2356 iqe_size);
2333} 2357}
2334 2358
2335/* 2359/*
diff --git a/drivers/net/cxgb4vf/t4vf_hw.c b/drivers/net/cxgb4vf/t4vf_hw.c
index e306c20dfaee..19520afe1a12 100644
--- a/drivers/net/cxgb4vf/t4vf_hw.c
+++ b/drivers/net/cxgb4vf/t4vf_hw.c
@@ -1014,48 +1014,72 @@ int t4vf_alloc_mac_filt(struct adapter *adapter, unsigned int viid, bool free,
1014 unsigned int naddr, const u8 **addr, u16 *idx, 1014 unsigned int naddr, const u8 **addr, u16 *idx,
1015 u64 *hash, bool sleep_ok) 1015 u64 *hash, bool sleep_ok)
1016{ 1016{
1017 int i, ret; 1017 int offset, ret = 0;
1018 unsigned nfilters = 0;
1019 unsigned int rem = naddr;
1018 struct fw_vi_mac_cmd cmd, rpl; 1020 struct fw_vi_mac_cmd cmd, rpl;
1019 struct fw_vi_mac_exact *p;
1020 size_t len16;
1021 1021
1022 if (naddr > ARRAY_SIZE(cmd.u.exact)) 1022 if (naddr > FW_CLS_TCAM_NUM_ENTRIES)
1023 return -EINVAL; 1023 return -EINVAL;
1024 len16 = DIV_ROUND_UP(offsetof(struct fw_vi_mac_cmd,
1025 u.exact[naddr]), 16);
1026 1024
1027 memset(&cmd, 0, sizeof(cmd)); 1025 for (offset = 0; offset < naddr; /**/) {
1028 cmd.op_to_viid = cpu_to_be32(FW_CMD_OP(FW_VI_MAC_CMD) | 1026 unsigned int fw_naddr = (rem < ARRAY_SIZE(cmd.u.exact)
1029 FW_CMD_REQUEST | 1027 ? rem
1030 FW_CMD_WRITE | 1028 : ARRAY_SIZE(cmd.u.exact));
1031 (free ? FW_CMD_EXEC : 0) | 1029 size_t len16 = DIV_ROUND_UP(offsetof(struct fw_vi_mac_cmd,
1032 FW_VI_MAC_CMD_VIID(viid)); 1030 u.exact[fw_naddr]), 16);
1033 cmd.freemacs_to_len16 = cpu_to_be32(FW_VI_MAC_CMD_FREEMACS(free) | 1031 struct fw_vi_mac_exact *p;
1034 FW_CMD_LEN16(len16)); 1032 int i;
1035 1033
1036 for (i = 0, p = cmd.u.exact; i < naddr; i++, p++) { 1034 memset(&cmd, 0, sizeof(cmd));
1037 p->valid_to_idx = 1035 cmd.op_to_viid = cpu_to_be32(FW_CMD_OP(FW_VI_MAC_CMD) |
1038 cpu_to_be16(FW_VI_MAC_CMD_VALID | 1036 FW_CMD_REQUEST |
1039 FW_VI_MAC_CMD_IDX(FW_VI_MAC_ADD_MAC)); 1037 FW_CMD_WRITE |
1040 memcpy(p->macaddr, addr[i], sizeof(p->macaddr)); 1038 (free ? FW_CMD_EXEC : 0) |
1041 } 1039 FW_VI_MAC_CMD_VIID(viid));
1040 cmd.freemacs_to_len16 =
1041 cpu_to_be32(FW_VI_MAC_CMD_FREEMACS(free) |
1042 FW_CMD_LEN16(len16));
1043
1044 for (i = 0, p = cmd.u.exact; i < fw_naddr; i++, p++) {
1045 p->valid_to_idx = cpu_to_be16(
1046 FW_VI_MAC_CMD_VALID |
1047 FW_VI_MAC_CMD_IDX(FW_VI_MAC_ADD_MAC));
1048 memcpy(p->macaddr, addr[offset+i], sizeof(p->macaddr));
1049 }
1050
1051
1052 ret = t4vf_wr_mbox_core(adapter, &cmd, sizeof(cmd), &rpl,
1053 sleep_ok);
1054 if (ret && ret != -ENOMEM)
1055 break;
1042 1056
1043 ret = t4vf_wr_mbox_core(adapter, &cmd, sizeof(cmd), &rpl, sleep_ok); 1057 for (i = 0, p = rpl.u.exact; i < fw_naddr; i++, p++) {
1044 if (ret) 1058 u16 index = FW_VI_MAC_CMD_IDX_GET(
1045 return ret; 1059 be16_to_cpu(p->valid_to_idx));
1046 1060
1047 for (i = 0, p = rpl.u.exact; i < naddr; i++, p++) { 1061 if (idx)
1048 u16 index = FW_VI_MAC_CMD_IDX_GET(be16_to_cpu(p->valid_to_idx)); 1062 idx[offset+i] =
1049 1063 (index >= FW_CLS_TCAM_NUM_ENTRIES
1050 if (idx) 1064 ? 0xffff
1051 idx[i] = (index >= FW_CLS_TCAM_NUM_ENTRIES 1065 : index);
1052 ? 0xffff 1066 if (index < FW_CLS_TCAM_NUM_ENTRIES)
1053 : index); 1067 nfilters++;
1054 if (index < FW_CLS_TCAM_NUM_ENTRIES) 1068 else if (hash)
1055 ret++; 1069 *hash |= (1ULL << hash_mac_addr(addr[offset+i]));
1056 else if (hash) 1070 }
1057 *hash |= (1 << hash_mac_addr(addr[i])); 1071
1072 free = false;
1073 offset += fw_naddr;
1074 rem -= fw_naddr;
1058 } 1075 }
1076
1077 /*
1078 * If there were no errors or we merely ran out of room in our MAC
1079 * address arena, return the number of filters actually written.
1080 */
1081 if (ret == 0 || ret == -ENOMEM)
1082 ret = nfilters;
1059 return ret; 1083 return ret;
1060} 1084}
1061 1085
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 4686c3983fc3..4d62f7bfa036 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -31,7 +31,7 @@
31 31
32char e1000_driver_name[] = "e1000"; 32char e1000_driver_name[] = "e1000";
33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; 33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
34#define DRV_VERSION "7.3.21-k6-NAPI" 34#define DRV_VERSION "7.3.21-k8-NAPI"
35const char e1000_driver_version[] = DRV_VERSION; 35const char e1000_driver_version[] = DRV_VERSION;
36static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 36static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
37 37
@@ -485,9 +485,6 @@ void e1000_down(struct e1000_adapter *adapter)
485 struct net_device *netdev = adapter->netdev; 485 struct net_device *netdev = adapter->netdev;
486 u32 rctl, tctl; 486 u32 rctl, tctl;
487 487
488 /* signal that we're down so the interrupt handler does not
489 * reschedule our watchdog timer */
490 set_bit(__E1000_DOWN, &adapter->flags);
491 488
492 /* disable receives in the hardware */ 489 /* disable receives in the hardware */
493 rctl = er32(RCTL); 490 rctl = er32(RCTL);
@@ -508,6 +505,13 @@ void e1000_down(struct e1000_adapter *adapter)
508 505
509 e1000_irq_disable(adapter); 506 e1000_irq_disable(adapter);
510 507
508 /*
509 * Setting DOWN must be after irq_disable to prevent
510 * a screaming interrupt. Setting DOWN also prevents
511 * timers and tasks from rescheduling.
512 */
513 set_bit(__E1000_DOWN, &adapter->flags);
514
511 del_timer_sync(&adapter->tx_fifo_stall_timer); 515 del_timer_sync(&adapter->tx_fifo_stall_timer);
512 del_timer_sync(&adapter->watchdog_timer); 516 del_timer_sync(&adapter->watchdog_timer);
513 del_timer_sync(&adapter->phy_info_timer); 517 del_timer_sync(&adapter->phy_info_timer);
diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
index 75b099ce49c9..1f37ee6b2a26 100644
--- a/drivers/net/ehea/ehea_ethtool.c
+++ b/drivers/net/ehea/ehea_ethtool.c
@@ -261,6 +261,13 @@ static void ehea_get_ethtool_stats(struct net_device *dev,
261 261
262} 262}
263 263
264static int ehea_set_flags(struct net_device *dev, u32 data)
265{
266 return ethtool_op_set_flags(dev, data, ETH_FLAG_LRO
267 | ETH_FLAG_TXVLAN
268 | ETH_FLAG_RXVLAN);
269}
270
264const struct ethtool_ops ehea_ethtool_ops = { 271const struct ethtool_ops ehea_ethtool_ops = {
265 .get_settings = ehea_get_settings, 272 .get_settings = ehea_get_settings,
266 .get_drvinfo = ehea_get_drvinfo, 273 .get_drvinfo = ehea_get_drvinfo,
@@ -273,6 +280,8 @@ const struct ethtool_ops ehea_ethtool_ops = {
273 .get_ethtool_stats = ehea_get_ethtool_stats, 280 .get_ethtool_stats = ehea_get_ethtool_stats,
274 .get_rx_csum = ehea_get_rx_csum, 281 .get_rx_csum = ehea_get_rx_csum,
275 .set_settings = ehea_set_settings, 282 .set_settings = ehea_set_settings,
283 .get_flags = ethtool_op_get_flags,
284 .set_flags = ehea_set_flags,
276 .nway_reset = ehea_nway_reset, /* Restart autonegotiation */ 285 .nway_reset = ehea_nway_reset, /* Restart autonegotiation */
277}; 286};
278 287
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 182b2a7be8dc..b95f087cd5a9 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -400,6 +400,7 @@ static void ehea_refill_rq1(struct ehea_port_res *pr, int index, int nr_of_wqes)
400 skb_arr_rq1[index] = netdev_alloc_skb(dev, 400 skb_arr_rq1[index] = netdev_alloc_skb(dev,
401 EHEA_L_PKT_SIZE); 401 EHEA_L_PKT_SIZE);
402 if (!skb_arr_rq1[index]) { 402 if (!skb_arr_rq1[index]) {
403 ehea_info("Unable to allocate enough skb in the array\n");
403 pr->rq1_skba.os_skbs = fill_wqes - i; 404 pr->rq1_skba.os_skbs = fill_wqes - i;
404 break; 405 break;
405 } 406 }
@@ -422,13 +423,20 @@ static void ehea_init_fill_rq1(struct ehea_port_res *pr, int nr_rq1a)
422 struct net_device *dev = pr->port->netdev; 423 struct net_device *dev = pr->port->netdev;
423 int i; 424 int i;
424 425
425 for (i = 0; i < pr->rq1_skba.len; i++) { 426 if (nr_rq1a > pr->rq1_skba.len) {
427 ehea_error("NR_RQ1A bigger than skb array len\n");
428 return;
429 }
430
431 for (i = 0; i < nr_rq1a; i++) {
426 skb_arr_rq1[i] = netdev_alloc_skb(dev, EHEA_L_PKT_SIZE); 432 skb_arr_rq1[i] = netdev_alloc_skb(dev, EHEA_L_PKT_SIZE);
427 if (!skb_arr_rq1[i]) 433 if (!skb_arr_rq1[i]) {
434 ehea_info("No enough memory to allocate skb array\n");
428 break; 435 break;
436 }
429 } 437 }
430 /* Ring doorbell */ 438 /* Ring doorbell */
431 ehea_update_rq1a(pr->qp, nr_rq1a); 439 ehea_update_rq1a(pr->qp, i);
432} 440}
433 441
434static int ehea_refill_rq_def(struct ehea_port_res *pr, 442static int ehea_refill_rq_def(struct ehea_port_res *pr,
@@ -675,7 +683,7 @@ static void ehea_proc_skb(struct ehea_port_res *pr, struct ehea_cqe *cqe,
675 int vlan_extracted = ((cqe->status & EHEA_CQE_VLAN_TAG_XTRACT) && 683 int vlan_extracted = ((cqe->status & EHEA_CQE_VLAN_TAG_XTRACT) &&
676 pr->port->vgrp); 684 pr->port->vgrp);
677 685
678 if (use_lro) { 686 if (skb->dev->features & NETIF_F_LRO) {
679 if (vlan_extracted) 687 if (vlan_extracted)
680 lro_vlan_hwaccel_receive_skb(&pr->lro_mgr, skb, 688 lro_vlan_hwaccel_receive_skb(&pr->lro_mgr, skb,
681 pr->port->vgrp, 689 pr->port->vgrp,
@@ -735,8 +743,10 @@ static int ehea_proc_rwqes(struct net_device *dev,
735 743
736 skb = netdev_alloc_skb(dev, 744 skb = netdev_alloc_skb(dev,
737 EHEA_L_PKT_SIZE); 745 EHEA_L_PKT_SIZE);
738 if (!skb) 746 if (!skb) {
747 ehea_info("Not enough memory to allocate skb\n");
739 break; 748 break;
749 }
740 } 750 }
741 skb_copy_to_linear_data(skb, ((char *)cqe) + 64, 751 skb_copy_to_linear_data(skb, ((char *)cqe) + 64,
742 cqe->num_bytes_transfered - 4); 752 cqe->num_bytes_transfered - 4);
@@ -777,7 +787,7 @@ static int ehea_proc_rwqes(struct net_device *dev,
777 } 787 }
778 cqe = ehea_poll_rq1(qp, &wqe_index); 788 cqe = ehea_poll_rq1(qp, &wqe_index);
779 } 789 }
780 if (use_lro) 790 if (dev->features & NETIF_F_LRO)
781 lro_flush_all(&pr->lro_mgr); 791 lro_flush_all(&pr->lro_mgr);
782 792
783 pr->rx_packets += processed; 793 pr->rx_packets += processed;
@@ -3268,6 +3278,9 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
3268 | NETIF_F_LLTX; 3278 | NETIF_F_LLTX;
3269 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT; 3279 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT;
3270 3280
3281 if (use_lro)
3282 dev->features |= NETIF_F_LRO;
3283
3271 INIT_WORK(&port->reset_task, ehea_reset_port); 3284 INIT_WORK(&port->reset_task, ehea_reset_port);
3272 3285
3273 ret = register_netdev(dev); 3286 ret = register_netdev(dev);
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index a466ef91dd43..aa28b270c045 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1962,7 +1962,8 @@ static void enic_poll_controller(struct net_device *netdev)
1962 case VNIC_DEV_INTR_MODE_MSIX: 1962 case VNIC_DEV_INTR_MODE_MSIX:
1963 for (i = 0; i < enic->rq_count; i++) { 1963 for (i = 0; i < enic->rq_count; i++) {
1964 intr = enic_msix_rq_intr(enic, i); 1964 intr = enic_msix_rq_intr(enic, i);
1965 enic_isr_msix_rq(enic->msix_entry[intr].vector, enic); 1965 enic_isr_msix_rq(enic->msix_entry[intr].vector,
1966 &enic->napi[i]);
1966 } 1967 }
1967 intr = enic_msix_wq_intr(enic, i); 1968 intr = enic_msix_wq_intr(enic, i);
1968 enic_isr_msix_wq(enic->msix_entry[intr].vector, enic); 1969 enic_isr_msix_wq(enic->msix_entry[intr].vector, enic);
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 49e4ce1246a7..d1bec6269173 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -577,11 +577,10 @@ static int gfar_parse_group(struct device_node *np,
577 irq_of_parse_and_map(np, 1); 577 irq_of_parse_and_map(np, 1);
578 priv->gfargrp[priv->num_grps].interruptError = 578 priv->gfargrp[priv->num_grps].interruptError =
579 irq_of_parse_and_map(np,2); 579 irq_of_parse_and_map(np,2);
580 if (priv->gfargrp[priv->num_grps].interruptTransmit < 0 || 580 if (priv->gfargrp[priv->num_grps].interruptTransmit == NO_IRQ ||
581 priv->gfargrp[priv->num_grps].interruptReceive < 0 || 581 priv->gfargrp[priv->num_grps].interruptReceive == NO_IRQ ||
582 priv->gfargrp[priv->num_grps].interruptError < 0) { 582 priv->gfargrp[priv->num_grps].interruptError == NO_IRQ)
583 return -EINVAL; 583 return -EINVAL;
584 }
585 } 584 }
586 585
587 priv->gfargrp[priv->num_grps].grp_id = priv->num_grps; 586 priv->gfargrp[priv->num_grps].grp_id = priv->num_grps;
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index ab9f675c5b8b..fe337bd121aa 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -104,6 +104,8 @@ static void ri_tasklet(unsigned long dev)
104 rcu_read_unlock(); 104 rcu_read_unlock();
105 dev_kfree_skb(skb); 105 dev_kfree_skb(skb);
106 stats->tx_dropped++; 106 stats->tx_dropped++;
107 if (skb_queue_len(&dp->tq) != 0)
108 goto resched;
107 break; 109 break;
108 } 110 }
109 rcu_read_unlock(); 111 rcu_read_unlock();
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index dc0198092343..aa93655c3aa7 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -88,16 +88,14 @@ static const char *ipg_brand_name[] = {
88 "IC PLUS IP1000 1000/100/10 based NIC", 88 "IC PLUS IP1000 1000/100/10 based NIC",
89 "Sundance Technology ST2021 based NIC", 89 "Sundance Technology ST2021 based NIC",
90 "Tamarack Microelectronics TC9020/9021 based NIC", 90 "Tamarack Microelectronics TC9020/9021 based NIC",
91 "Tamarack Microelectronics TC9020/9021 based NIC",
92 "D-Link NIC IP1000A" 91 "D-Link NIC IP1000A"
93}; 92};
94 93
95static DEFINE_PCI_DEVICE_TABLE(ipg_pci_tbl) = { 94static DEFINE_PCI_DEVICE_TABLE(ipg_pci_tbl) = {
96 { PCI_VDEVICE(SUNDANCE, 0x1023), 0 }, 95 { PCI_VDEVICE(SUNDANCE, 0x1023), 0 },
97 { PCI_VDEVICE(SUNDANCE, 0x2021), 1 }, 96 { PCI_VDEVICE(SUNDANCE, 0x2021), 1 },
98 { PCI_VDEVICE(SUNDANCE, 0x1021), 2 }, 97 { PCI_VDEVICE(DLINK, 0x9021), 2 },
99 { PCI_VDEVICE(DLINK, 0x9021), 3 }, 98 { PCI_VDEVICE(DLINK, 0x4020), 3 },
100 { PCI_VDEVICE(DLINK, 0x4020), 4 },
101 { 0, } 99 { 0, }
102}; 100};
103 101
diff --git a/drivers/net/irda/sh_sir.c b/drivers/net/irda/sh_sir.c
index 00b38bccd6d0..52a7c86af663 100644
--- a/drivers/net/irda/sh_sir.c
+++ b/drivers/net/irda/sh_sir.c
@@ -258,7 +258,7 @@ static int sh_sir_set_baudrate(struct sh_sir_self *self, u32 baudrate)
258 258
259 /* Baud Rate Error Correction x 10000 */ 259 /* Baud Rate Error Correction x 10000 */
260 u32 rate_err_array[] = { 260 u32 rate_err_array[] = {
261 0000, 0625, 1250, 1875, 261 0, 625, 1250, 1875,
262 2500, 3125, 3750, 4375, 262 2500, 3125, 3750, 4375,
263 5000, 5625, 6250, 6875, 263 5000, 5625, 6250, 6875,
264 7500, 8125, 8750, 9375, 264 7500, 8125, 8750, 9375,
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index fbad4d819608..eee0b298bd36 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -4771,6 +4771,9 @@ void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter)
4771 adapter->rx_ring[i] = NULL; 4771 adapter->rx_ring[i] = NULL;
4772 } 4772 }
4773 4773
4774 adapter->num_tx_queues = 0;
4775 adapter->num_rx_queues = 0;
4776
4774 ixgbe_free_q_vectors(adapter); 4777 ixgbe_free_q_vectors(adapter);
4775 ixgbe_reset_interrupt_capability(adapter); 4778 ixgbe_reset_interrupt_capability(adapter);
4776} 4779}
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c
index b68eee2414c2..7a7e18ba278a 100644
--- a/drivers/net/mlx4/fw.c
+++ b/drivers/net/mlx4/fw.c
@@ -289,6 +289,10 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
289 MLX4_GET(field, outbox, QUERY_DEV_CAP_LOG_BF_REG_SZ_OFFSET); 289 MLX4_GET(field, outbox, QUERY_DEV_CAP_LOG_BF_REG_SZ_OFFSET);
290 dev_cap->bf_reg_size = 1 << (field & 0x1f); 290 dev_cap->bf_reg_size = 1 << (field & 0x1f);
291 MLX4_GET(field, outbox, QUERY_DEV_CAP_LOG_MAX_BF_REGS_PER_PAGE_OFFSET); 291 MLX4_GET(field, outbox, QUERY_DEV_CAP_LOG_MAX_BF_REGS_PER_PAGE_OFFSET);
292 if ((1 << (field & 0x3f)) > (PAGE_SIZE / dev_cap->bf_reg_size)) {
293 mlx4_warn(dev, "firmware bug: log2 # of blue flame regs is invalid (%d), forcing 3\n", field & 0x1f);
294 field = 3;
295 }
292 dev_cap->bf_regs_per_page = 1 << (field & 0x3f); 296 dev_cap->bf_regs_per_page = 1 << (field & 0x3f);
293 mlx4_dbg(dev, "BlueFlame available (reg size %d, regs/page %d)\n", 297 mlx4_dbg(dev, "BlueFlame available (reg size %d, regs/page %d)\n",
294 dev_cap->bf_reg_size, dev_cap->bf_regs_per_page); 298 dev_cap->bf_reg_size, dev_cap->bf_regs_per_page);
diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c
index 472056b47440..03a1d280105f 100644
--- a/drivers/net/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/pch_gbe/pch_gbe_main.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 1999 - 2010 Intel Corporation. 2 * Copyright (C) 1999 - 2010 Intel Corporation.
3 * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. 3 * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD.
4 * 4 *
5 * This code was derived from the Intel e1000e Linux driver. 5 * This code was derived from the Intel e1000e Linux driver.
6 * 6 *
@@ -2464,8 +2464,8 @@ static void __exit pch_gbe_exit_module(void)
2464module_init(pch_gbe_init_module); 2464module_init(pch_gbe_init_module);
2465module_exit(pch_gbe_exit_module); 2465module_exit(pch_gbe_exit_module);
2466 2466
2467MODULE_DESCRIPTION("OKI semiconductor PCH Gigabit ethernet Driver"); 2467MODULE_DESCRIPTION("EG20T PCH Gigabit ethernet Driver");
2468MODULE_AUTHOR("OKI semiconductor, <masa-korg@dsn.okisemi.com>"); 2468MODULE_AUTHOR("OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>");
2469MODULE_LICENSE("GPL"); 2469MODULE_LICENSE("GPL");
2470MODULE_VERSION(DRV_VERSION); 2470MODULE_VERSION(DRV_VERSION);
2471MODULE_DEVICE_TABLE(pci, pch_gbe_pcidev_id); 2471MODULE_DEVICE_TABLE(pci, pch_gbe_pcidev_id);
diff --git a/drivers/net/pch_gbe/pch_gbe_param.c b/drivers/net/pch_gbe/pch_gbe_param.c
index 2510146fc560..ef0996a0eaaa 100644
--- a/drivers/net/pch_gbe/pch_gbe_param.c
+++ b/drivers/net/pch_gbe/pch_gbe_param.c
@@ -434,8 +434,8 @@ void pch_gbe_check_options(struct pch_gbe_adapter *adapter)
434 .err = "using default of " 434 .err = "using default of "
435 __MODULE_STRING(PCH_GBE_DEFAULT_TXD), 435 __MODULE_STRING(PCH_GBE_DEFAULT_TXD),
436 .def = PCH_GBE_DEFAULT_TXD, 436 .def = PCH_GBE_DEFAULT_TXD,
437 .arg = { .r = { .min = PCH_GBE_MIN_TXD } }, 437 .arg = { .r = { .min = PCH_GBE_MIN_TXD,
438 .arg = { .r = { .max = PCH_GBE_MAX_TXD } } 438 .max = PCH_GBE_MAX_TXD } }
439 }; 439 };
440 struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring; 440 struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
441 tx_ring->count = TxDescriptors; 441 tx_ring->count = TxDescriptors;
@@ -450,8 +450,8 @@ void pch_gbe_check_options(struct pch_gbe_adapter *adapter)
450 .err = "using default of " 450 .err = "using default of "
451 __MODULE_STRING(PCH_GBE_DEFAULT_RXD), 451 __MODULE_STRING(PCH_GBE_DEFAULT_RXD),
452 .def = PCH_GBE_DEFAULT_RXD, 452 .def = PCH_GBE_DEFAULT_RXD,
453 .arg = { .r = { .min = PCH_GBE_MIN_RXD } }, 453 .arg = { .r = { .min = PCH_GBE_MIN_RXD,
454 .arg = { .r = { .max = PCH_GBE_MAX_RXD } } 454 .max = PCH_GBE_MAX_RXD } }
455 }; 455 };
456 struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring; 456 struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
457 rx_ring->count = RxDescriptors; 457 rx_ring->count = RxDescriptors;
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index cb3d13e4e074..35fda5ac8120 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -64,7 +64,7 @@ config BCM63XX_PHY
64config ICPLUS_PHY 64config ICPLUS_PHY
65 tristate "Drivers for ICPlus PHYs" 65 tristate "Drivers for ICPlus PHYs"
66 ---help--- 66 ---help---
67 Currently supports the IP175C PHY. 67 Currently supports the IP175C and IP1001 PHYs.
68 68
69config REALTEK_PHY 69config REALTEK_PHY
70 tristate "Drivers for Realtek PHYs" 70 tristate "Drivers for Realtek PHYs"
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index c1d2d251fe8b..9a09e24c30bc 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -30,7 +30,7 @@
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32 32
33MODULE_DESCRIPTION("ICPlus IP175C PHY driver"); 33MODULE_DESCRIPTION("ICPlus IP175C/IC1001 PHY drivers");
34MODULE_AUTHOR("Michael Barkowski"); 34MODULE_AUTHOR("Michael Barkowski");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
36 36
@@ -89,6 +89,33 @@ static int ip175c_config_init(struct phy_device *phydev)
89 return 0; 89 return 0;
90} 90}
91 91
92static int ip1001_config_init(struct phy_device *phydev)
93{
94 int err, value;
95
96 /* Software Reset PHY */
97 value = phy_read(phydev, MII_BMCR);
98 value |= BMCR_RESET;
99 err = phy_write(phydev, MII_BMCR, value);
100 if (err < 0)
101 return err;
102
103 do {
104 value = phy_read(phydev, MII_BMCR);
105 } while (value & BMCR_RESET);
106
107 /* Additional delay (2ns) used to adjust RX clock phase
108 * at GMII/ RGMII interface */
109 value = phy_read(phydev, 16);
110 value |= 0x3;
111
112 err = phy_write(phydev, 16, value);
113 if (err < 0)
114 return err;
115
116 return err;
117}
118
92static int ip175c_read_status(struct phy_device *phydev) 119static int ip175c_read_status(struct phy_device *phydev)
93{ 120{
94 if (phydev->addr == 4) /* WAN port */ 121 if (phydev->addr == 4) /* WAN port */
@@ -121,21 +148,43 @@ static struct phy_driver ip175c_driver = {
121 .driver = { .owner = THIS_MODULE,}, 148 .driver = { .owner = THIS_MODULE,},
122}; 149};
123 150
124static int __init ip175c_init(void) 151static struct phy_driver ip1001_driver = {
152 .phy_id = 0x02430d90,
153 .name = "ICPlus IP1001",
154 .phy_id_mask = 0x0ffffff0,
155 .features = PHY_GBIT_FEATURES | SUPPORTED_Pause |
156 SUPPORTED_Asym_Pause,
157 .config_init = &ip1001_config_init,
158 .config_aneg = &genphy_config_aneg,
159 .read_status = &genphy_read_status,
160 .suspend = genphy_suspend,
161 .resume = genphy_resume,
162 .driver = { .owner = THIS_MODULE,},
163};
164
165static int __init icplus_init(void)
125{ 166{
167 int ret = 0;
168
169 ret = phy_driver_register(&ip1001_driver);
170 if (ret < 0)
171 return -ENODEV;
172
126 return phy_driver_register(&ip175c_driver); 173 return phy_driver_register(&ip175c_driver);
127} 174}
128 175
129static void __exit ip175c_exit(void) 176static void __exit icplus_exit(void)
130{ 177{
178 phy_driver_unregister(&ip1001_driver);
131 phy_driver_unregister(&ip175c_driver); 179 phy_driver_unregister(&ip175c_driver);
132} 180}
133 181
134module_init(ip175c_init); 182module_init(icplus_init);
135module_exit(ip175c_exit); 183module_exit(icplus_exit);
136 184
137static struct mdio_device_id __maybe_unused icplus_tbl[] = { 185static struct mdio_device_id __maybe_unused icplus_tbl[] = {
138 { 0x02430d80, 0x0ffffff0 }, 186 { 0x02430d80, 0x0ffffff0 },
187 { 0x02430d90, 0x0ffffff0 },
139 { } 188 { }
140}; 189};
141 190
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index f0bd1a1aba3a..e8b9c53c304b 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -30,11 +30,14 @@
30#include <linux/ethtool.h> 30#include <linux/ethtool.h>
31#include <linux/phy.h> 31#include <linux/phy.h>
32#include <linux/marvell_phy.h> 32#include <linux/marvell_phy.h>
33#include <linux/of.h>
33 34
34#include <asm/io.h> 35#include <asm/io.h>
35#include <asm/irq.h> 36#include <asm/irq.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
37 38
39#define MII_MARVELL_PHY_PAGE 22
40
38#define MII_M1011_IEVENT 0x13 41#define MII_M1011_IEVENT 0x13
39#define MII_M1011_IEVENT_CLEAR 0x0000 42#define MII_M1011_IEVENT_CLEAR 0x0000
40 43
@@ -80,7 +83,6 @@
80#define MII_88E1121_PHY_LED_CTRL 16 83#define MII_88E1121_PHY_LED_CTRL 16
81#define MII_88E1121_PHY_LED_PAGE 3 84#define MII_88E1121_PHY_LED_PAGE 3
82#define MII_88E1121_PHY_LED_DEF 0x0030 85#define MII_88E1121_PHY_LED_DEF 0x0030
83#define MII_88E1121_PHY_PAGE 22
84 86
85#define MII_M1011_PHY_STATUS 0x11 87#define MII_M1011_PHY_STATUS 0x11
86#define MII_M1011_PHY_STATUS_1000 0x8000 88#define MII_M1011_PHY_STATUS_1000 0x8000
@@ -186,13 +188,94 @@ static int marvell_config_aneg(struct phy_device *phydev)
186 return 0; 188 return 0;
187} 189}
188 190
191#ifdef CONFIG_OF_MDIO
192/*
193 * Set and/or override some configuration registers based on the
194 * marvell,reg-init property stored in the of_node for the phydev.
195 *
196 * marvell,reg-init = <reg-page reg mask value>,...;
197 *
198 * There may be one or more sets of <reg-page reg mask value>:
199 *
200 * reg-page: which register bank to use.
201 * reg: the register.
202 * mask: if non-zero, ANDed with existing register value.
203 * value: ORed with the masked value and written to the regiser.
204 *
205 */
206static int marvell_of_reg_init(struct phy_device *phydev)
207{
208 const __be32 *paddr;
209 int len, i, saved_page, current_page, page_changed, ret;
210
211 if (!phydev->dev.of_node)
212 return 0;
213
214 paddr = of_get_property(phydev->dev.of_node, "marvell,reg-init", &len);
215 if (!paddr || len < (4 * sizeof(*paddr)))
216 return 0;
217
218 saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
219 if (saved_page < 0)
220 return saved_page;
221 page_changed = 0;
222 current_page = saved_page;
223
224 ret = 0;
225 len /= sizeof(*paddr);
226 for (i = 0; i < len - 3; i += 4) {
227 u16 reg_page = be32_to_cpup(paddr + i);
228 u16 reg = be32_to_cpup(paddr + i + 1);
229 u16 mask = be32_to_cpup(paddr + i + 2);
230 u16 val_bits = be32_to_cpup(paddr + i + 3);
231 int val;
232
233 if (reg_page != current_page) {
234 current_page = reg_page;
235 page_changed = 1;
236 ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
237 if (ret < 0)
238 goto err;
239 }
240
241 val = 0;
242 if (mask) {
243 val = phy_read(phydev, reg);
244 if (val < 0) {
245 ret = val;
246 goto err;
247 }
248 val &= mask;
249 }
250 val |= val_bits;
251
252 ret = phy_write(phydev, reg, val);
253 if (ret < 0)
254 goto err;
255
256 }
257err:
258 if (page_changed) {
259 i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
260 if (ret == 0)
261 ret = i;
262 }
263 return ret;
264}
265#else
266static int marvell_of_reg_init(struct phy_device *phydev)
267{
268 return 0;
269}
270#endif /* CONFIG_OF_MDIO */
271
189static int m88e1121_config_aneg(struct phy_device *phydev) 272static int m88e1121_config_aneg(struct phy_device *phydev)
190{ 273{
191 int err, oldpage, mscr; 274 int err, oldpage, mscr;
192 275
193 oldpage = phy_read(phydev, MII_88E1121_PHY_PAGE); 276 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
194 277
195 err = phy_write(phydev, MII_88E1121_PHY_PAGE, 278 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
196 MII_88E1121_PHY_MSCR_PAGE); 279 MII_88E1121_PHY_MSCR_PAGE);
197 if (err < 0) 280 if (err < 0)
198 return err; 281 return err;
@@ -218,7 +301,7 @@ static int m88e1121_config_aneg(struct phy_device *phydev)
218 return err; 301 return err;
219 } 302 }
220 303
221 phy_write(phydev, MII_88E1121_PHY_PAGE, oldpage); 304 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
222 305
223 err = phy_write(phydev, MII_BMCR, BMCR_RESET); 306 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
224 if (err < 0) 307 if (err < 0)
@@ -229,11 +312,11 @@ static int m88e1121_config_aneg(struct phy_device *phydev)
229 if (err < 0) 312 if (err < 0)
230 return err; 313 return err;
231 314
232 oldpage = phy_read(phydev, MII_88E1121_PHY_PAGE); 315 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
233 316
234 phy_write(phydev, MII_88E1121_PHY_PAGE, MII_88E1121_PHY_LED_PAGE); 317 phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_88E1121_PHY_LED_PAGE);
235 phy_write(phydev, MII_88E1121_PHY_LED_CTRL, MII_88E1121_PHY_LED_DEF); 318 phy_write(phydev, MII_88E1121_PHY_LED_CTRL, MII_88E1121_PHY_LED_DEF);
236 phy_write(phydev, MII_88E1121_PHY_PAGE, oldpage); 319 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
237 320
238 err = genphy_config_aneg(phydev); 321 err = genphy_config_aneg(phydev);
239 322
@@ -244,9 +327,9 @@ static int m88e1318_config_aneg(struct phy_device *phydev)
244{ 327{
245 int err, oldpage, mscr; 328 int err, oldpage, mscr;
246 329
247 oldpage = phy_read(phydev, MII_88E1121_PHY_PAGE); 330 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
248 331
249 err = phy_write(phydev, MII_88E1121_PHY_PAGE, 332 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
250 MII_88E1121_PHY_MSCR_PAGE); 333 MII_88E1121_PHY_MSCR_PAGE);
251 if (err < 0) 334 if (err < 0)
252 return err; 335 return err;
@@ -258,7 +341,7 @@ static int m88e1318_config_aneg(struct phy_device *phydev)
258 if (err < 0) 341 if (err < 0)
259 return err; 342 return err;
260 343
261 err = phy_write(phydev, MII_88E1121_PHY_PAGE, oldpage); 344 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
262 if (err < 0) 345 if (err < 0)
263 return err; 346 return err;
264 347
@@ -368,6 +451,9 @@ static int m88e1111_config_init(struct phy_device *phydev)
368 return err; 451 return err;
369 } 452 }
370 453
454 err = marvell_of_reg_init(phydev);
455 if (err < 0)
456 return err;
371 457
372 err = phy_write(phydev, MII_BMCR, BMCR_RESET); 458 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
373 if (err < 0) 459 if (err < 0)
@@ -398,7 +484,7 @@ static int m88e1118_config_init(struct phy_device *phydev)
398 int err; 484 int err;
399 485
400 /* Change address */ 486 /* Change address */
401 err = phy_write(phydev, 0x16, 0x0002); 487 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
402 if (err < 0) 488 if (err < 0)
403 return err; 489 return err;
404 490
@@ -408,7 +494,7 @@ static int m88e1118_config_init(struct phy_device *phydev)
408 return err; 494 return err;
409 495
410 /* Change address */ 496 /* Change address */
411 err = phy_write(phydev, 0x16, 0x0003); 497 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0003);
412 if (err < 0) 498 if (err < 0)
413 return err; 499 return err;
414 500
@@ -420,8 +506,42 @@ static int m88e1118_config_init(struct phy_device *phydev)
420 if (err < 0) 506 if (err < 0)
421 return err; 507 return err;
422 508
509 err = marvell_of_reg_init(phydev);
510 if (err < 0)
511 return err;
512
423 /* Reset address */ 513 /* Reset address */
424 err = phy_write(phydev, 0x16, 0x0); 514 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
515 if (err < 0)
516 return err;
517
518 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
519 if (err < 0)
520 return err;
521
522 return 0;
523}
524
525static int m88e1149_config_init(struct phy_device *phydev)
526{
527 int err;
528
529 /* Change address */
530 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
531 if (err < 0)
532 return err;
533
534 /* Enable 1000 Mbit */
535 err = phy_write(phydev, 0x15, 0x1048);
536 if (err < 0)
537 return err;
538
539 err = marvell_of_reg_init(phydev);
540 if (err < 0)
541 return err;
542
543 /* Reset address */
544 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
425 if (err < 0) 545 if (err < 0)
426 return err; 546 return err;
427 547
@@ -491,6 +611,10 @@ static int m88e1145_config_init(struct phy_device *phydev)
491 } 611 }
492 } 612 }
493 613
614 err = marvell_of_reg_init(phydev);
615 if (err < 0)
616 return err;
617
494 return 0; 618 return 0;
495} 619}
496 620
@@ -685,6 +809,19 @@ static struct phy_driver marvell_drivers[] = {
685 .driver = { .owner = THIS_MODULE }, 809 .driver = { .owner = THIS_MODULE },
686 }, 810 },
687 { 811 {
812 .phy_id = MARVELL_PHY_ID_88E1149R,
813 .phy_id_mask = MARVELL_PHY_ID_MASK,
814 .name = "Marvell 88E1149R",
815 .features = PHY_GBIT_FEATURES,
816 .flags = PHY_HAS_INTERRUPT,
817 .config_init = &m88e1149_config_init,
818 .config_aneg = &m88e1118_config_aneg,
819 .read_status = &genphy_read_status,
820 .ack_interrupt = &marvell_ack_interrupt,
821 .config_intr = &marvell_config_intr,
822 .driver = { .owner = THIS_MODULE },
823 },
824 {
688 .phy_id = MARVELL_PHY_ID_88E1240, 825 .phy_id = MARVELL_PHY_ID_88E1240,
689 .phy_id_mask = MARVELL_PHY_ID_MASK, 826 .phy_id_mask = MARVELL_PHY_ID_MASK,
690 .name = "Marvell 88E1240", 827 .name = "Marvell 88E1240",
@@ -735,6 +872,7 @@ static struct mdio_device_id __maybe_unused marvell_tbl[] = {
735 { 0x01410e10, 0xfffffff0 }, 872 { 0x01410e10, 0xfffffff0 },
736 { 0x01410cb0, 0xfffffff0 }, 873 { 0x01410cb0, 0xfffffff0 },
737 { 0x01410cd0, 0xfffffff0 }, 874 { 0x01410cd0, 0xfffffff0 },
875 { 0x01410e50, 0xfffffff0 },
738 { 0x01410e30, 0xfffffff0 }, 876 { 0x01410e30, 0xfffffff0 },
739 { 0x01410e90, 0xfffffff0 }, 877 { 0x01410e90, 0xfffffff0 },
740 { } 878 { }
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 09cf56d0416a..39659976a1ac 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -2584,16 +2584,16 @@ ppp_create_interface(struct net *net, int unit, int *retp)
2584 */ 2584 */
2585 dev_net_set(dev, net); 2585 dev_net_set(dev, net);
2586 2586
2587 ret = -EEXIST;
2588 mutex_lock(&pn->all_ppp_mutex); 2587 mutex_lock(&pn->all_ppp_mutex);
2589 2588
2590 if (unit < 0) { 2589 if (unit < 0) {
2591 unit = unit_get(&pn->units_idr, ppp); 2590 unit = unit_get(&pn->units_idr, ppp);
2592 if (unit < 0) { 2591 if (unit < 0) {
2593 *retp = unit; 2592 ret = unit;
2594 goto out2; 2593 goto out2;
2595 } 2594 }
2596 } else { 2595 } else {
2596 ret = -EEXIST;
2597 if (unit_find(&pn->units_idr, unit)) 2597 if (unit_find(&pn->units_idr, unit))
2598 goto out2; /* unit already exists */ 2598 goto out2; /* unit already exists */
2599 /* 2599 /*
@@ -2668,10 +2668,10 @@ static void ppp_shutdown_interface(struct ppp *ppp)
2668 ppp->closing = 1; 2668 ppp->closing = 1;
2669 ppp_unlock(ppp); 2669 ppp_unlock(ppp);
2670 unregister_netdev(ppp->dev); 2670 unregister_netdev(ppp->dev);
2671 unit_put(&pn->units_idr, ppp->file.index);
2671 } else 2672 } else
2672 ppp_unlock(ppp); 2673 ppp_unlock(ppp);
2673 2674
2674 unit_put(&pn->units_idr, ppp->file.index);
2675 ppp->file.dead = 1; 2675 ppp->file.dead = 1;
2676 ppp->owner = NULL; 2676 ppp->owner = NULL;
2677 wake_up_interruptible(&ppp->file.rwait); 2677 wake_up_interruptible(&ppp->file.rwait);
@@ -2859,8 +2859,7 @@ static void __exit ppp_cleanup(void)
2859 * by holding all_ppp_mutex 2859 * by holding all_ppp_mutex
2860 */ 2860 */
2861 2861
2862/* associate pointer with specified number */ 2862static int __unit_alloc(struct idr *p, void *ptr, int n)
2863static int unit_set(struct idr *p, void *ptr, int n)
2864{ 2863{
2865 int unit, err; 2864 int unit, err;
2866 2865
@@ -2871,10 +2870,24 @@ again:
2871 } 2870 }
2872 2871
2873 err = idr_get_new_above(p, ptr, n, &unit); 2872 err = idr_get_new_above(p, ptr, n, &unit);
2874 if (err == -EAGAIN) 2873 if (err < 0) {
2875 goto again; 2874 if (err == -EAGAIN)
2875 goto again;
2876 return err;
2877 }
2878
2879 return unit;
2880}
2881
2882/* associate pointer with specified number */
2883static int unit_set(struct idr *p, void *ptr, int n)
2884{
2885 int unit;
2876 2886
2877 if (unit != n) { 2887 unit = __unit_alloc(p, ptr, n);
2888 if (unit < 0)
2889 return unit;
2890 else if (unit != n) {
2878 idr_remove(p, unit); 2891 idr_remove(p, unit);
2879 return -EINVAL; 2892 return -EINVAL;
2880 } 2893 }
@@ -2885,19 +2898,7 @@ again:
2885/* get new free unit number and associate pointer with it */ 2898/* get new free unit number and associate pointer with it */
2886static int unit_get(struct idr *p, void *ptr) 2899static int unit_get(struct idr *p, void *ptr)
2887{ 2900{
2888 int unit, err; 2901 return __unit_alloc(p, ptr, 0);
2889
2890again:
2891 if (!idr_pre_get(p, GFP_KERNEL)) {
2892 printk(KERN_ERR "PPP: No free memory for idr\n");
2893 return -ENOMEM;
2894 }
2895
2896 err = idr_get_new_above(p, ptr, 0, &unit);
2897 if (err == -EAGAIN)
2898 goto again;
2899
2900 return unit;
2901} 2902}
2902 2903
2903/* put unit number back to a pool */ 2904/* put unit number back to a pool */
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index d72fb0519a2a..78c0e3c9b2b5 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -948,7 +948,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
948 948
949abort: 949abort:
950 kfree_skb(skb); 950 kfree_skb(skb);
951 return 0; 951 return 1;
952} 952}
953 953
954/************************************************************************ 954/************************************************************************
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 22821398fc63..9787dff90d3f 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -2083,6 +2083,7 @@ struct ql_adapter {
2083 u32 mailbox_in; 2083 u32 mailbox_in;
2084 u32 mailbox_out; 2084 u32 mailbox_out;
2085 struct mbox_params idc_mbc; 2085 struct mbox_params idc_mbc;
2086 struct mutex mpi_mutex;
2086 2087
2087 int tx_ring_size; 2088 int tx_ring_size;
2088 int rx_ring_size; 2089 int rx_ring_size;
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index c30e0fe55a31..2555b1d34f34 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -62,15 +62,15 @@ static const u32 default_msg =
62/* NETIF_MSG_PKTDATA | */ 62/* NETIF_MSG_PKTDATA | */
63 NETIF_MSG_HW | NETIF_MSG_WOL | 0; 63 NETIF_MSG_HW | NETIF_MSG_WOL | 0;
64 64
65static int debug = 0x00007fff; /* defaults above */ 65static int debug = -1; /* defaults above */
66module_param(debug, int, 0); 66module_param(debug, int, 0664);
67MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 67MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
68 68
69#define MSIX_IRQ 0 69#define MSIX_IRQ 0
70#define MSI_IRQ 1 70#define MSI_IRQ 1
71#define LEG_IRQ 2 71#define LEG_IRQ 2
72static int qlge_irq_type = MSIX_IRQ; 72static int qlge_irq_type = MSIX_IRQ;
73module_param(qlge_irq_type, int, MSIX_IRQ); 73module_param(qlge_irq_type, int, 0664);
74MODULE_PARM_DESC(qlge_irq_type, "0 = MSI-X, 1 = MSI, 2 = Legacy."); 74MODULE_PARM_DESC(qlge_irq_type, "0 = MSI-X, 1 = MSI, 2 = Legacy.");
75 75
76static int qlge_mpi_coredump; 76static int qlge_mpi_coredump;
@@ -4629,6 +4629,7 @@ static int __devinit ql_init_device(struct pci_dev *pdev,
4629 INIT_DELAYED_WORK(&qdev->mpi_idc_work, ql_mpi_idc_work); 4629 INIT_DELAYED_WORK(&qdev->mpi_idc_work, ql_mpi_idc_work);
4630 INIT_DELAYED_WORK(&qdev->mpi_core_to_log, ql_mpi_core_to_log); 4630 INIT_DELAYED_WORK(&qdev->mpi_core_to_log, ql_mpi_core_to_log);
4631 init_completion(&qdev->ide_completion); 4631 init_completion(&qdev->ide_completion);
4632 mutex_init(&qdev->mpi_mutex);
4632 4633
4633 if (!cards_found) { 4634 if (!cards_found) {
4634 dev_info(&pdev->dev, "%s\n", DRV_STRING); 4635 dev_info(&pdev->dev, "%s\n", DRV_STRING);
diff --git a/drivers/net/qlge/qlge_mpi.c b/drivers/net/qlge/qlge_mpi.c
index 0e7c7c7ee164..a2e919bcb3c6 100644
--- a/drivers/net/qlge/qlge_mpi.c
+++ b/drivers/net/qlge/qlge_mpi.c
@@ -534,6 +534,7 @@ static int ql_mailbox_command(struct ql_adapter *qdev, struct mbox_params *mbcp)
534 int status; 534 int status;
535 unsigned long count; 535 unsigned long count;
536 536
537 mutex_lock(&qdev->mpi_mutex);
537 538
538 /* Begin polled mode for MPI */ 539 /* Begin polled mode for MPI */
539 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); 540 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16));
@@ -603,6 +604,7 @@ done:
603end: 604end:
604 /* End polled mode for MPI */ 605 /* End polled mode for MPI */
605 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI); 606 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI);
607 mutex_unlock(&qdev->mpi_mutex);
606 return status; 608 return status;
607} 609}
608 610
@@ -1099,9 +1101,7 @@ int ql_wait_fifo_empty(struct ql_adapter *qdev)
1099static int ql_set_port_cfg(struct ql_adapter *qdev) 1101static int ql_set_port_cfg(struct ql_adapter *qdev)
1100{ 1102{
1101 int status; 1103 int status;
1102 rtnl_lock();
1103 status = ql_mb_set_port_cfg(qdev); 1104 status = ql_mb_set_port_cfg(qdev);
1104 rtnl_unlock();
1105 if (status) 1105 if (status)
1106 return status; 1106 return status;
1107 status = ql_idc_wait(qdev); 1107 status = ql_idc_wait(qdev);
@@ -1122,9 +1122,7 @@ void ql_mpi_port_cfg_work(struct work_struct *work)
1122 container_of(work, struct ql_adapter, mpi_port_cfg_work.work); 1122 container_of(work, struct ql_adapter, mpi_port_cfg_work.work);
1123 int status; 1123 int status;
1124 1124
1125 rtnl_lock();
1126 status = ql_mb_get_port_cfg(qdev); 1125 status = ql_mb_get_port_cfg(qdev);
1127 rtnl_unlock();
1128 if (status) { 1126 if (status) {
1129 netif_err(qdev, drv, qdev->ndev, 1127 netif_err(qdev, drv, qdev->ndev,
1130 "Bug: Failed to get port config data.\n"); 1128 "Bug: Failed to get port config data.\n");
@@ -1167,7 +1165,6 @@ void ql_mpi_idc_work(struct work_struct *work)
1167 u32 aen; 1165 u32 aen;
1168 int timeout; 1166 int timeout;
1169 1167
1170 rtnl_lock();
1171 aen = mbcp->mbox_out[1] >> 16; 1168 aen = mbcp->mbox_out[1] >> 16;
1172 timeout = (mbcp->mbox_out[1] >> 8) & 0xf; 1169 timeout = (mbcp->mbox_out[1] >> 8) & 0xf;
1173 1170
@@ -1231,7 +1228,6 @@ void ql_mpi_idc_work(struct work_struct *work)
1231 } 1228 }
1232 break; 1229 break;
1233 } 1230 }
1234 rtnl_unlock();
1235} 1231}
1236 1232
1237void ql_mpi_work(struct work_struct *work) 1233void ql_mpi_work(struct work_struct *work)
@@ -1242,7 +1238,7 @@ void ql_mpi_work(struct work_struct *work)
1242 struct mbox_params *mbcp = &mbc; 1238 struct mbox_params *mbcp = &mbc;
1243 int err = 0; 1239 int err = 0;
1244 1240
1245 rtnl_lock(); 1241 mutex_lock(&qdev->mpi_mutex);
1246 /* Begin polled mode for MPI */ 1242 /* Begin polled mode for MPI */
1247 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); 1243 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16));
1248 1244
@@ -1259,7 +1255,7 @@ void ql_mpi_work(struct work_struct *work)
1259 1255
1260 /* End polled mode for MPI */ 1256 /* End polled mode for MPI */
1261 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI); 1257 ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI);
1262 rtnl_unlock(); 1258 mutex_unlock(&qdev->mpi_mutex);
1263 ql_enable_completion_interrupt(qdev, 0); 1259 ql_enable_completion_interrupt(qdev, 0);
1264} 1260}
1265 1261
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 4c4d16905efb..53b13deade95 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -744,26 +744,36 @@ static void rtl8169_xmii_reset_enable(void __iomem *ioaddr)
744 mdio_write(ioaddr, MII_BMCR, val & 0xffff); 744 mdio_write(ioaddr, MII_BMCR, val & 0xffff);
745} 745}
746 746
747static void rtl8169_check_link_status(struct net_device *dev, 747static void __rtl8169_check_link_status(struct net_device *dev,
748 struct rtl8169_private *tp, 748 struct rtl8169_private *tp,
749 void __iomem *ioaddr) 749 void __iomem *ioaddr,
750 bool pm)
750{ 751{
751 unsigned long flags; 752 unsigned long flags;
752 753
753 spin_lock_irqsave(&tp->lock, flags); 754 spin_lock_irqsave(&tp->lock, flags);
754 if (tp->link_ok(ioaddr)) { 755 if (tp->link_ok(ioaddr)) {
755 /* This is to cancel a scheduled suspend if there's one. */ 756 /* This is to cancel a scheduled suspend if there's one. */
756 pm_request_resume(&tp->pci_dev->dev); 757 if (pm)
758 pm_request_resume(&tp->pci_dev->dev);
757 netif_carrier_on(dev); 759 netif_carrier_on(dev);
758 netif_info(tp, ifup, dev, "link up\n"); 760 netif_info(tp, ifup, dev, "link up\n");
759 } else { 761 } else {
760 netif_carrier_off(dev); 762 netif_carrier_off(dev);
761 netif_info(tp, ifdown, dev, "link down\n"); 763 netif_info(tp, ifdown, dev, "link down\n");
762 pm_schedule_suspend(&tp->pci_dev->dev, 100); 764 if (pm)
765 pm_schedule_suspend(&tp->pci_dev->dev, 100);
763 } 766 }
764 spin_unlock_irqrestore(&tp->lock, flags); 767 spin_unlock_irqrestore(&tp->lock, flags);
765} 768}
766 769
770static void rtl8169_check_link_status(struct net_device *dev,
771 struct rtl8169_private *tp,
772 void __iomem *ioaddr)
773{
774 __rtl8169_check_link_status(dev, tp, ioaddr, false);
775}
776
767#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) 777#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
768 778
769static u32 __rtl8169_get_wol(struct rtl8169_private *tp) 779static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
@@ -4440,8 +4450,7 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
4440 u32 status = opts1 & RxProtoMask; 4450 u32 status = opts1 & RxProtoMask;
4441 4451
4442 if (((status == RxProtoTCP) && !(opts1 & TCPFail)) || 4452 if (((status == RxProtoTCP) && !(opts1 & TCPFail)) ||
4443 ((status == RxProtoUDP) && !(opts1 & UDPFail)) || 4453 ((status == RxProtoUDP) && !(opts1 & UDPFail)))
4444 ((status == RxProtoIP) && !(opts1 & IPFail)))
4445 skb->ip_summed = CHECKSUM_UNNECESSARY; 4454 skb->ip_summed = CHECKSUM_UNNECESSARY;
4446 else 4455 else
4447 skb_checksum_none_assert(skb); 4456 skb_checksum_none_assert(skb);
@@ -4601,7 +4610,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
4601 } 4610 }
4602 4611
4603 if (status & LinkChg) 4612 if (status & LinkChg)
4604 rtl8169_check_link_status(dev, tp, ioaddr); 4613 __rtl8169_check_link_status(dev, tp, ioaddr, true);
4605 4614
4606 /* We need to see the lastest version of tp->intr_mask to 4615 /* We need to see the lastest version of tp->intr_mask to
4607 * avoid ignoring an MSI interrupt and having to wait for 4616 * avoid ignoring an MSI interrupt and having to wait for
@@ -4891,11 +4900,7 @@ static int rtl8169_runtime_idle(struct device *device)
4891 struct net_device *dev = pci_get_drvdata(pdev); 4900 struct net_device *dev = pci_get_drvdata(pdev);
4892 struct rtl8169_private *tp = netdev_priv(dev); 4901 struct rtl8169_private *tp = netdev_priv(dev);
4893 4902
4894 if (!tp->TxDescArray) 4903 return tp->TxDescArray ? -EBUSY : 0;
4895 return 0;
4896
4897 rtl8169_check_link_status(dev, tp, tp->mmio_addr);
4898 return -EBUSY;
4899} 4904}
4900 4905
4901static const struct dev_pm_ops rtl8169_pm_ops = { 4906static const struct dev_pm_ops rtl8169_pm_ops = {
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 05df20e47976..fb83cdd94643 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -197,7 +197,9 @@ MODULE_PARM_DESC(debug, "Bitmapped debugging message enable value");
197 197
198static void efx_remove_channels(struct efx_nic *efx); 198static void efx_remove_channels(struct efx_nic *efx);
199static void efx_remove_port(struct efx_nic *efx); 199static void efx_remove_port(struct efx_nic *efx);
200static void efx_init_napi(struct efx_nic *efx);
200static void efx_fini_napi(struct efx_nic *efx); 201static void efx_fini_napi(struct efx_nic *efx);
202static void efx_fini_napi_channel(struct efx_channel *channel);
201static void efx_fini_struct(struct efx_nic *efx); 203static void efx_fini_struct(struct efx_nic *efx);
202static void efx_start_all(struct efx_nic *efx); 204static void efx_start_all(struct efx_nic *efx);
203static void efx_stop_all(struct efx_nic *efx); 205static void efx_stop_all(struct efx_nic *efx);
@@ -335,8 +337,10 @@ void efx_process_channel_now(struct efx_channel *channel)
335 337
336 /* Disable interrupts and wait for ISRs to complete */ 338 /* Disable interrupts and wait for ISRs to complete */
337 efx_nic_disable_interrupts(efx); 339 efx_nic_disable_interrupts(efx);
338 if (efx->legacy_irq) 340 if (efx->legacy_irq) {
339 synchronize_irq(efx->legacy_irq); 341 synchronize_irq(efx->legacy_irq);
342 efx->legacy_irq_enabled = false;
343 }
340 if (channel->irq) 344 if (channel->irq)
341 synchronize_irq(channel->irq); 345 synchronize_irq(channel->irq);
342 346
@@ -351,6 +355,8 @@ void efx_process_channel_now(struct efx_channel *channel)
351 efx_channel_processed(channel); 355 efx_channel_processed(channel);
352 356
353 napi_enable(&channel->napi_str); 357 napi_enable(&channel->napi_str);
358 if (efx->legacy_irq)
359 efx->legacy_irq_enabled = true;
354 efx_nic_enable_interrupts(efx); 360 efx_nic_enable_interrupts(efx);
355} 361}
356 362
@@ -426,6 +432,7 @@ efx_alloc_channel(struct efx_nic *efx, int i, struct efx_channel *old_channel)
426 432
427 *channel = *old_channel; 433 *channel = *old_channel;
428 434
435 channel->napi_dev = NULL;
429 memset(&channel->eventq, 0, sizeof(channel->eventq)); 436 memset(&channel->eventq, 0, sizeof(channel->eventq));
430 437
431 rx_queue = &channel->rx_queue; 438 rx_queue = &channel->rx_queue;
@@ -736,9 +743,13 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries)
736 if (rc) 743 if (rc)
737 goto rollback; 744 goto rollback;
738 745
746 efx_init_napi(efx);
747
739 /* Destroy old channels */ 748 /* Destroy old channels */
740 for (i = 0; i < efx->n_channels; i++) 749 for (i = 0; i < efx->n_channels; i++) {
750 efx_fini_napi_channel(other_channel[i]);
741 efx_remove_channel(other_channel[i]); 751 efx_remove_channel(other_channel[i]);
752 }
742out: 753out:
743 /* Free unused channel structures */ 754 /* Free unused channel structures */
744 for (i = 0; i < efx->n_channels; i++) 755 for (i = 0; i < efx->n_channels; i++)
@@ -1400,6 +1411,8 @@ static void efx_start_all(struct efx_nic *efx)
1400 efx_start_channel(channel); 1411 efx_start_channel(channel);
1401 } 1412 }
1402 1413
1414 if (efx->legacy_irq)
1415 efx->legacy_irq_enabled = true;
1403 efx_nic_enable_interrupts(efx); 1416 efx_nic_enable_interrupts(efx);
1404 1417
1405 /* Switch to event based MCDI completions after enabling interrupts. 1418 /* Switch to event based MCDI completions after enabling interrupts.
@@ -1460,8 +1473,10 @@ static void efx_stop_all(struct efx_nic *efx)
1460 1473
1461 /* Disable interrupts and wait for ISR to complete */ 1474 /* Disable interrupts and wait for ISR to complete */
1462 efx_nic_disable_interrupts(efx); 1475 efx_nic_disable_interrupts(efx);
1463 if (efx->legacy_irq) 1476 if (efx->legacy_irq) {
1464 synchronize_irq(efx->legacy_irq); 1477 synchronize_irq(efx->legacy_irq);
1478 efx->legacy_irq_enabled = false;
1479 }
1465 efx_for_each_channel(channel, efx) { 1480 efx_for_each_channel(channel, efx) {
1466 if (channel->irq) 1481 if (channel->irq)
1467 synchronize_irq(channel->irq); 1482 synchronize_irq(channel->irq);
@@ -1593,7 +1608,7 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
1593 * 1608 *
1594 **************************************************************************/ 1609 **************************************************************************/
1595 1610
1596static int efx_init_napi(struct efx_nic *efx) 1611static void efx_init_napi(struct efx_nic *efx)
1597{ 1612{
1598 struct efx_channel *channel; 1613 struct efx_channel *channel;
1599 1614
@@ -1602,18 +1617,21 @@ static int efx_init_napi(struct efx_nic *efx)
1602 netif_napi_add(channel->napi_dev, &channel->napi_str, 1617 netif_napi_add(channel->napi_dev, &channel->napi_str,
1603 efx_poll, napi_weight); 1618 efx_poll, napi_weight);
1604 } 1619 }
1605 return 0; 1620}
1621
1622static void efx_fini_napi_channel(struct efx_channel *channel)
1623{
1624 if (channel->napi_dev)
1625 netif_napi_del(&channel->napi_str);
1626 channel->napi_dev = NULL;
1606} 1627}
1607 1628
1608static void efx_fini_napi(struct efx_nic *efx) 1629static void efx_fini_napi(struct efx_nic *efx)
1609{ 1630{
1610 struct efx_channel *channel; 1631 struct efx_channel *channel;
1611 1632
1612 efx_for_each_channel(channel, efx) { 1633 efx_for_each_channel(channel, efx)
1613 if (channel->napi_dev) 1634 efx_fini_napi_channel(channel);
1614 netif_napi_del(&channel->napi_str);
1615 channel->napi_dev = NULL;
1616 }
1617} 1635}
1618 1636
1619/************************************************************************** 1637/**************************************************************************
@@ -2335,9 +2353,7 @@ static int efx_pci_probe_main(struct efx_nic *efx)
2335 if (rc) 2353 if (rc)
2336 goto fail1; 2354 goto fail1;
2337 2355
2338 rc = efx_init_napi(efx); 2356 efx_init_napi(efx);
2339 if (rc)
2340 goto fail2;
2341 2357
2342 rc = efx->type->init(efx); 2358 rc = efx->type->init(efx);
2343 if (rc) { 2359 if (rc) {
@@ -2368,7 +2384,6 @@ static int efx_pci_probe_main(struct efx_nic *efx)
2368 efx->type->fini(efx); 2384 efx->type->fini(efx);
2369 fail3: 2385 fail3:
2370 efx_fini_napi(efx); 2386 efx_fini_napi(efx);
2371 fail2:
2372 efx_remove_all(efx); 2387 efx_remove_all(efx);
2373 fail1: 2388 fail1:
2374 return rc; 2389 return rc;
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 0a7e26d73b52..b137c889152b 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -621,6 +621,7 @@ struct efx_filter_state;
621 * @pci_dev: The PCI device 621 * @pci_dev: The PCI device
622 * @type: Controller type attributes 622 * @type: Controller type attributes
623 * @legacy_irq: IRQ number 623 * @legacy_irq: IRQ number
624 * @legacy_irq_enabled: Are IRQs enabled on NIC (INT_EN_KER register)?
624 * @workqueue: Workqueue for port reconfigures and the HW monitor. 625 * @workqueue: Workqueue for port reconfigures and the HW monitor.
625 * Work items do not hold and must not acquire RTNL. 626 * Work items do not hold and must not acquire RTNL.
626 * @workqueue_name: Name of workqueue 627 * @workqueue_name: Name of workqueue
@@ -709,6 +710,7 @@ struct efx_nic {
709 struct pci_dev *pci_dev; 710 struct pci_dev *pci_dev;
710 const struct efx_nic_type *type; 711 const struct efx_nic_type *type;
711 int legacy_irq; 712 int legacy_irq;
713 bool legacy_irq_enabled;
712 struct workqueue_struct *workqueue; 714 struct workqueue_struct *workqueue;
713 char workqueue_name[16]; 715 char workqueue_name[16];
714 struct work_struct reset_work; 716 struct work_struct reset_work;
diff --git a/drivers/net/sfc/nic.c b/drivers/net/sfc/nic.c
index 41c36b9a4244..67cb0c96838c 100644
--- a/drivers/net/sfc/nic.c
+++ b/drivers/net/sfc/nic.c
@@ -1418,6 +1418,12 @@ static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id)
1418 u32 queues; 1418 u32 queues;
1419 int syserr; 1419 int syserr;
1420 1420
1421 /* Could this be ours? If interrupts are disabled then the
1422 * channel state may not be valid.
1423 */
1424 if (!efx->legacy_irq_enabled)
1425 return result;
1426
1421 /* Read the ISR which also ACKs the interrupts */ 1427 /* Read the ISR which also ACKs the interrupts */
1422 efx_readd(efx, &reg, FR_BZ_INT_ISR0); 1428 efx_readd(efx, &reg, FR_BZ_INT_ISR0);
1423 queues = EFX_EXTRACT_DWORD(reg, 0, 31); 1429 queues = EFX_EXTRACT_DWORD(reg, 0, 31);
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index 06bc6034ce81..2114837809e7 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1509,6 +1509,8 @@ static int stmmac_probe(struct net_device *dev)
1509 pr_warning("\tno valid MAC address;" 1509 pr_warning("\tno valid MAC address;"
1510 "please, use ifconfig or nwhwconfig!\n"); 1510 "please, use ifconfig or nwhwconfig!\n");
1511 1511
1512 spin_lock_init(&priv->lock);
1513
1512 ret = register_netdev(dev); 1514 ret = register_netdev(dev);
1513 if (ret) { 1515 if (ret) {
1514 pr_err("%s: ERROR %i registering the device\n", 1516 pr_err("%s: ERROR %i registering the device\n",
@@ -1520,8 +1522,6 @@ static int stmmac_probe(struct net_device *dev)
1520 dev->name, (dev->features & NETIF_F_SG) ? "on" : "off", 1522 dev->name, (dev->features & NETIF_F_SG) ? "on" : "off",
1521 (dev->features & NETIF_F_HW_CSUM) ? "on" : "off"); 1523 (dev->features & NETIF_F_HW_CSUM) ? "on" : "off");
1522 1524
1523 spin_lock_init(&priv->lock);
1524
1525 return ret; 1525 return ret;
1526} 1526}
1527 1527
diff --git a/drivers/net/tile/Makefile b/drivers/net/tile/Makefile
new file mode 100644
index 000000000000..f634f142cab4
--- /dev/null
+++ b/drivers/net/tile/Makefile
@@ -0,0 +1,10 @@
1#
2# Makefile for the TILE on-chip networking support.
3#
4
5obj-$(CONFIG_TILE_NET) += tile_net.o
6ifdef CONFIG_TILEGX
7tile_net-objs := tilegx.o mpipe.o iorpc_mpipe.o dma_queue.o
8else
9tile_net-objs := tilepro.o
10endif
diff --git a/drivers/net/tile/tilepro.c b/drivers/net/tile/tilepro.c
new file mode 100644
index 000000000000..0e6bac5ec65b
--- /dev/null
+++ b/drivers/net/tile/tilepro.c
@@ -0,0 +1,2406 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/moduleparam.h>
18#include <linux/sched.h>
19#include <linux/kernel.h> /* printk() */
20#include <linux/slab.h> /* kmalloc() */
21#include <linux/errno.h> /* error codes */
22#include <linux/types.h> /* size_t */
23#include <linux/interrupt.h>
24#include <linux/in.h>
25#include <linux/netdevice.h> /* struct device, and other headers */
26#include <linux/etherdevice.h> /* eth_type_trans */
27#include <linux/skbuff.h>
28#include <linux/ioctl.h>
29#include <linux/cdev.h>
30#include <linux/hugetlb.h>
31#include <linux/in6.h>
32#include <linux/timer.h>
33#include <linux/io.h>
34#include <asm/checksum.h>
35#include <asm/homecache.h>
36
37#include <hv/drv_xgbe_intf.h>
38#include <hv/drv_xgbe_impl.h>
39#include <hv/hypervisor.h>
40#include <hv/netio_intf.h>
41
42/* For TSO */
43#include <linux/ip.h>
44#include <linux/tcp.h>
45
46
47/* There is no singlethread_cpu, so schedule work on the current cpu. */
48#define singlethread_cpu -1
49
50
51/*
52 * First, "tile_net_init_module()" initializes all four "devices" which
53 * can be used by linux.
54 *
55 * Then, "ifconfig DEVICE up" calls "tile_net_open()", which analyzes
56 * the network cpus, then uses "tile_net_open_aux()" to initialize
57 * LIPP/LEPP, and then uses "tile_net_open_inner()" to register all
58 * the tiles, provide buffers to LIPP, allow ingress to start, and
59 * turn on hypervisor interrupt handling (and NAPI) on all tiles.
60 *
61 * If registration fails due to the link being down, then "retry_work"
62 * is used to keep calling "tile_net_open_inner()" until it succeeds.
63 *
64 * If "ifconfig DEVICE down" is called, it uses "tile_net_stop()" to
65 * stop egress, drain the LIPP buffers, unregister all the tiles, stop
66 * LIPP/LEPP, and wipe the LEPP queue.
67 *
68 * We start out with the ingress interrupt enabled on each CPU. When
69 * this interrupt fires, we disable it, and call "napi_schedule()".
70 * This will cause "tile_net_poll()" to be called, which will pull
71 * packets from the netio queue, filtering them out, or passing them
72 * to "netif_receive_skb()". If our budget is exhausted, we will
73 * return, knowing we will be called again later. Otherwise, we
74 * reenable the ingress interrupt, and call "napi_complete()".
75 *
76 *
77 * NOTE: The use of "native_driver" ensures that EPP exists, and that
78 * "epp_sendv" is legal, and that "LIPP" is being used.
79 *
80 * NOTE: Failing to free completions for an arbitrarily long time
81 * (which is defined to be illegal) does in fact cause bizarre
82 * problems. The "egress_timer" helps prevent this from happening.
83 *
84 * NOTE: The egress code can be interrupted by the interrupt handler.
85 */
86
87
88/* HACK: Allow use of "jumbo" packets. */
89/* This should be 1500 if "jumbo" is not set in LIPP. */
90/* This should be at most 10226 (10240 - 14) if "jumbo" is set in LIPP. */
91/* ISSUE: This has not been thoroughly tested (except at 1500). */
92#define TILE_NET_MTU 1500
93
94/* HACK: Define to support GSO. */
95/* ISSUE: This may actually hurt performance of the TCP blaster. */
96/* #define TILE_NET_GSO */
97
98/* Define this to collapse "duplicate" acks. */
99/* #define IGNORE_DUP_ACKS */
100
101/* HACK: Define this to verify incoming packets. */
102/* #define TILE_NET_VERIFY_INGRESS */
103
104/* Use 3000 to enable the Linux Traffic Control (QoS) layer, else 0. */
105#define TILE_NET_TX_QUEUE_LEN 0
106
107/* Define to dump packets (prints out the whole packet on tx and rx). */
108/* #define TILE_NET_DUMP_PACKETS */
109
110/* Define to enable debug spew (all PDEBUG's are enabled). */
111/* #define TILE_NET_DEBUG */
112
113
114/* Define to activate paranoia checks. */
115/* #define TILE_NET_PARANOIA */
116
117/* Default transmit lockup timeout period, in jiffies. */
118#define TILE_NET_TIMEOUT (5 * HZ)
119
120/* Default retry interval for bringing up the NetIO interface, in jiffies. */
121#define TILE_NET_RETRY_INTERVAL (5 * HZ)
122
123/* Number of ports (xgbe0, xgbe1, gbe0, gbe1). */
124#define TILE_NET_DEVS 4
125
126
127
128/* Paranoia. */
129#if NET_IP_ALIGN != LIPP_PACKET_PADDING
130#error "NET_IP_ALIGN must match LIPP_PACKET_PADDING."
131#endif
132
133
134/* Debug print. */
135#ifdef TILE_NET_DEBUG
136#define PDEBUG(fmt, args...) net_printk(fmt, ## args)
137#else
138#define PDEBUG(fmt, args...)
139#endif
140
141
142MODULE_AUTHOR("Tilera");
143MODULE_LICENSE("GPL");
144
145
146#define IS_MULTICAST(mac_addr) \
147 (((u8 *)(mac_addr))[0] & 0x01)
148
149#define IS_BROADCAST(mac_addr) \
150 (((u16 *)(mac_addr))[0] == 0xffff)
151
152
153/*
154 * Queue of incoming packets for a specific cpu and device.
155 *
156 * Includes a pointer to the "system" data, and the actual "user" data.
157 */
158struct tile_netio_queue {
159 netio_queue_impl_t *__system_part;
160 netio_queue_user_impl_t __user_part;
161
162};
163
164
165/*
166 * Statistics counters for a specific cpu and device.
167 */
168struct tile_net_stats_t {
169 u32 rx_packets;
170 u32 rx_bytes;
171 u32 tx_packets;
172 u32 tx_bytes;
173};
174
175
176/*
177 * Info for a specific cpu and device.
178 *
179 * ISSUE: There is a "dev" pointer in "napi" as well.
180 */
181struct tile_net_cpu {
182 /* The NAPI struct. */
183 struct napi_struct napi;
184 /* Packet queue. */
185 struct tile_netio_queue queue;
186 /* Statistics. */
187 struct tile_net_stats_t stats;
188 /* ISSUE: Is this needed? */
189 bool napi_enabled;
190 /* True if this tile has succcessfully registered with the IPP. */
191 bool registered;
192 /* True if the link was down last time we tried to register. */
193 bool link_down;
194 /* True if "egress_timer" is scheduled. */
195 bool egress_timer_scheduled;
196 /* Number of small sk_buffs which must still be provided. */
197 unsigned int num_needed_small_buffers;
198 /* Number of large sk_buffs which must still be provided. */
199 unsigned int num_needed_large_buffers;
200 /* A timer for handling egress completions. */
201 struct timer_list egress_timer;
202};
203
204
205/*
206 * Info for a specific device.
207 */
208struct tile_net_priv {
209 /* Our network device. */
210 struct net_device *dev;
211 /* The actual egress queue. */
212 lepp_queue_t *epp_queue;
213 /* Protects "epp_queue->cmd_tail" and "epp_queue->comp_tail" */
214 spinlock_t cmd_lock;
215 /* Protects "epp_queue->comp_head". */
216 spinlock_t comp_lock;
217 /* The hypervisor handle for this interface. */
218 int hv_devhdl;
219 /* The intr bit mask that IDs this device. */
220 u32 intr_id;
221 /* True iff "tile_net_open_aux()" has succeeded. */
222 int partly_opened;
223 /* True iff "tile_net_open_inner()" has succeeded. */
224 int fully_opened;
225 /* Effective network cpus. */
226 struct cpumask network_cpus_map;
227 /* Number of network cpus. */
228 int network_cpus_count;
229 /* Credits per network cpu. */
230 int network_cpus_credits;
231 /* Network stats. */
232 struct net_device_stats stats;
233 /* For NetIO bringup retries. */
234 struct delayed_work retry_work;
235 /* Quick access to per cpu data. */
236 struct tile_net_cpu *cpu[NR_CPUS];
237};
238
239
240/*
241 * The actual devices (xgbe0, xgbe1, gbe0, gbe1).
242 */
243static struct net_device *tile_net_devs[TILE_NET_DEVS];
244
245/*
246 * The "tile_net_cpu" structures for each device.
247 */
248static DEFINE_PER_CPU(struct tile_net_cpu, hv_xgbe0);
249static DEFINE_PER_CPU(struct tile_net_cpu, hv_xgbe1);
250static DEFINE_PER_CPU(struct tile_net_cpu, hv_gbe0);
251static DEFINE_PER_CPU(struct tile_net_cpu, hv_gbe1);
252
253
254/*
255 * True if "network_cpus" was specified.
256 */
257static bool network_cpus_used;
258
259/*
260 * The actual cpus in "network_cpus".
261 */
262static struct cpumask network_cpus_map;
263
264
265
266#ifdef TILE_NET_DEBUG
267/*
268 * printk with extra stuff.
269 *
270 * We print the CPU we're running in brackets.
271 */
272static void net_printk(char *fmt, ...)
273{
274 int i;
275 int len;
276 va_list args;
277 static char buf[256];
278
279 len = sprintf(buf, "tile_net[%2.2d]: ", smp_processor_id());
280 va_start(args, fmt);
281 i = vscnprintf(buf + len, sizeof(buf) - len - 1, fmt, args);
282 va_end(args);
283 buf[255] = '\0';
284 pr_notice(buf);
285}
286#endif
287
288
289#ifdef TILE_NET_DUMP_PACKETS
290/*
291 * Dump a packet.
292 */
293static void dump_packet(unsigned char *data, unsigned long length, char *s)
294{
295 unsigned long i;
296 static unsigned int count;
297
298 pr_info("dump_packet(data %p, length 0x%lx s %s count 0x%x)\n",
299 data, length, s, count++);
300
301 pr_info("\n");
302
303 for (i = 0; i < length; i++) {
304 if ((i & 0xf) == 0)
305 sprintf(buf, "%8.8lx:", i);
306 sprintf(buf + strlen(buf), " %2.2x", data[i]);
307 if ((i & 0xf) == 0xf || i == length - 1)
308 pr_info("%s\n", buf);
309 }
310}
311#endif
312
313
314/*
315 * Provide support for the __netio_fastio1() swint
316 * (see <hv/drv_xgbe_intf.h> for how it is used).
317 *
318 * The fastio swint2 call may clobber all the caller-saved registers.
319 * It rarely clobbers memory, but we allow for the possibility in
320 * the signature just to be on the safe side.
321 *
322 * Also, gcc doesn't seem to allow an input operand to be
323 * clobbered, so we fake it with dummy outputs.
324 *
325 * This function can't be static because of the way it is declared
326 * in the netio header.
327 */
328inline int __netio_fastio1(u32 fastio_index, u32 arg0)
329{
330 long result, clobber_r1, clobber_r10;
331 asm volatile("swint2"
332 : "=R00" (result),
333 "=R01" (clobber_r1), "=R10" (clobber_r10)
334 : "R10" (fastio_index), "R01" (arg0)
335 : "memory", "r2", "r3", "r4",
336 "r5", "r6", "r7", "r8", "r9",
337 "r11", "r12", "r13", "r14",
338 "r15", "r16", "r17", "r18", "r19",
339 "r20", "r21", "r22", "r23", "r24",
340 "r25", "r26", "r27", "r28", "r29");
341 return result;
342}
343
344
345/*
346 * Provide a linux buffer to LIPP.
347 */
348static void tile_net_provide_linux_buffer(struct tile_net_cpu *info,
349 void *va, bool small)
350{
351 struct tile_netio_queue *queue = &info->queue;
352
353 /* Convert "va" and "small" to "linux_buffer_t". */
354 unsigned int buffer = ((unsigned int)(__pa(va) >> 7) << 1) + small;
355
356 __netio_fastio_free_buffer(queue->__user_part.__fastio_index, buffer);
357}
358
359
360/*
361 * Provide a linux buffer for LIPP.
362 */
363static bool tile_net_provide_needed_buffer(struct tile_net_cpu *info,
364 bool small)
365{
366 /* ISSUE: What should we use here? */
367 unsigned int large_size = NET_IP_ALIGN + TILE_NET_MTU + 100;
368
369 /* Round up to ensure to avoid "false sharing" with last cache line. */
370 unsigned int buffer_size =
371 (((small ? LIPP_SMALL_PACKET_SIZE : large_size) +
372 CHIP_L2_LINE_SIZE() - 1) & -CHIP_L2_LINE_SIZE());
373
374 /*
375 * ISSUE: Since CPAs are 38 bits, and we can only encode the
376 * high 31 bits in a "linux_buffer_t", the low 7 bits must be
377 * zero, and thus, we must align the actual "va" mod 128.
378 */
379 const unsigned long align = 128;
380
381 struct sk_buff *skb;
382 void *va;
383
384 struct sk_buff **skb_ptr;
385
386 /* Note that "dev_alloc_skb()" adds NET_SKB_PAD more bytes, */
387 /* and also "reserves" that many bytes. */
388 /* ISSUE: Can we "share" the NET_SKB_PAD bytes with "skb_ptr"? */
389 int len = sizeof(*skb_ptr) + align + buffer_size;
390
391 while (1) {
392
393 /* Allocate (or fail). */
394 skb = dev_alloc_skb(len);
395 if (skb == NULL)
396 return false;
397
398 /* Make room for a back-pointer to 'skb'. */
399 skb_reserve(skb, sizeof(*skb_ptr));
400
401 /* Make sure we are aligned. */
402 skb_reserve(skb, -(long)skb->data & (align - 1));
403
404 /* This address is given to IPP. */
405 va = skb->data;
406
407 if (small)
408 break;
409
410 /* ISSUE: This has never been observed! */
411 /* Large buffers must not span a huge page. */
412 if (((((long)va & ~HPAGE_MASK) + 1535) & HPAGE_MASK) == 0)
413 break;
414 pr_err("Leaking unaligned linux buffer at %p.\n", va);
415 }
416
417 /* Skip two bytes to satisfy LIPP assumptions. */
418 /* Note that this aligns IP on a 16 byte boundary. */
419 /* ISSUE: Do this when the packet arrives? */
420 skb_reserve(skb, NET_IP_ALIGN);
421
422 /* Save a back-pointer to 'skb'. */
423 skb_ptr = va - sizeof(*skb_ptr);
424 *skb_ptr = skb;
425
426 /* Invalidate the packet buffer. */
427 if (!hash_default)
428 __inv_buffer(skb->data, buffer_size);
429
430 /* Make sure "skb_ptr" has been flushed. */
431 __insn_mf();
432
433#ifdef TILE_NET_PARANOIA
434#if CHIP_HAS_CBOX_HOME_MAP()
435 if (hash_default) {
436 HV_PTE pte = *virt_to_pte(current->mm, (unsigned long)va);
437 if (hv_pte_get_mode(pte) != HV_PTE_MODE_CACHE_HASH_L3)
438 panic("Non-coherent ingress buffer!");
439 }
440#endif
441#endif
442
443 /* Provide the new buffer. */
444 tile_net_provide_linux_buffer(info, va, small);
445
446 return true;
447}
448
449
450/*
451 * Provide linux buffers for LIPP.
452 */
453static void tile_net_provide_needed_buffers(struct tile_net_cpu *info)
454{
455 while (info->num_needed_small_buffers != 0) {
456 if (!tile_net_provide_needed_buffer(info, true))
457 goto oops;
458 info->num_needed_small_buffers--;
459 }
460
461 while (info->num_needed_large_buffers != 0) {
462 if (!tile_net_provide_needed_buffer(info, false))
463 goto oops;
464 info->num_needed_large_buffers--;
465 }
466
467 return;
468
469oops:
470
471 /* Add a description to the page allocation failure dump. */
472 pr_notice("Could not provide a linux buffer to LIPP.\n");
473}
474
475
476/*
477 * Grab some LEPP completions, and store them in "comps", of size
478 * "comps_size", and return the number of completions which were
479 * stored, so the caller can free them.
480 *
481 * If "pending" is not NULL, it will be set to true if there might
482 * still be some pending completions caused by this tile, else false.
483 */
484static unsigned int tile_net_lepp_grab_comps(struct net_device *dev,
485 struct sk_buff *comps[],
486 unsigned int comps_size,
487 bool *pending)
488{
489 struct tile_net_priv *priv = netdev_priv(dev);
490
491 lepp_queue_t *eq = priv->epp_queue;
492
493 unsigned int n = 0;
494
495 unsigned int comp_head;
496 unsigned int comp_busy;
497 unsigned int comp_tail;
498
499 spin_lock(&priv->comp_lock);
500
501 comp_head = eq->comp_head;
502 comp_busy = eq->comp_busy;
503 comp_tail = eq->comp_tail;
504
505 while (comp_head != comp_busy && n < comps_size) {
506 comps[n++] = eq->comps[comp_head];
507 LEPP_QINC(comp_head);
508 }
509
510 if (pending != NULL)
511 *pending = (comp_head != comp_tail);
512
513 eq->comp_head = comp_head;
514
515 spin_unlock(&priv->comp_lock);
516
517 return n;
518}
519
520
521/*
522 * Make sure the egress timer is scheduled.
523 *
524 * Note that we use "schedule if not scheduled" logic instead of the more
525 * obvious "reschedule" logic, because "reschedule" is fairly expensive.
526 */
527static void tile_net_schedule_egress_timer(struct tile_net_cpu *info)
528{
529 if (!info->egress_timer_scheduled) {
530 mod_timer_pinned(&info->egress_timer, jiffies + 1);
531 info->egress_timer_scheduled = true;
532 }
533}
534
535
536/*
537 * The "function" for "info->egress_timer".
538 *
539 * This timer will reschedule itself as long as there are any pending
540 * completions expected (on behalf of any tile).
541 *
542 * ISSUE: Realistically, will the timer ever stop scheduling itself?
543 *
544 * ISSUE: This timer is almost never actually needed, so just use a global
545 * timer that can run on any tile.
546 *
547 * ISSUE: Maybe instead track number of expected completions, and free
548 * only that many, resetting to zero if "pending" is ever false.
549 */
550static void tile_net_handle_egress_timer(unsigned long arg)
551{
552 struct tile_net_cpu *info = (struct tile_net_cpu *)arg;
553 struct net_device *dev = info->napi.dev;
554
555 struct sk_buff *olds[32];
556 unsigned int wanted = 32;
557 unsigned int i, nolds = 0;
558 bool pending;
559
560 /* The timer is no longer scheduled. */
561 info->egress_timer_scheduled = false;
562
563 nolds = tile_net_lepp_grab_comps(dev, olds, wanted, &pending);
564
565 for (i = 0; i < nolds; i++)
566 kfree_skb(olds[i]);
567
568 /* Reschedule timer if needed. */
569 if (pending)
570 tile_net_schedule_egress_timer(info);
571}
572
573
574#ifdef IGNORE_DUP_ACKS
575
576/*
577 * Help detect "duplicate" ACKs. These are sequential packets (for a
578 * given flow) which are exactly 66 bytes long, sharing everything but
579 * ID=2@0x12, Hsum=2@0x18, Ack=4@0x2a, WinSize=2@0x30, Csum=2@0x32,
580 * Tstamps=10@0x38. The ID's are +1, the Hsum's are -1, the Ack's are
581 * +N, and the Tstamps are usually identical.
582 *
583 * NOTE: Apparently truly duplicate acks (with identical "ack" values),
584 * should not be collapsed, as they are used for some kind of flow control.
585 */
586static bool is_dup_ack(char *s1, char *s2, unsigned int len)
587{
588 int i;
589
590 unsigned long long ignorable = 0;
591
592 /* Identification. */
593 ignorable |= (1ULL << 0x12);
594 ignorable |= (1ULL << 0x13);
595
596 /* Header checksum. */
597 ignorable |= (1ULL << 0x18);
598 ignorable |= (1ULL << 0x19);
599
600 /* ACK. */
601 ignorable |= (1ULL << 0x2a);
602 ignorable |= (1ULL << 0x2b);
603 ignorable |= (1ULL << 0x2c);
604 ignorable |= (1ULL << 0x2d);
605
606 /* WinSize. */
607 ignorable |= (1ULL << 0x30);
608 ignorable |= (1ULL << 0x31);
609
610 /* Checksum. */
611 ignorable |= (1ULL << 0x32);
612 ignorable |= (1ULL << 0x33);
613
614 for (i = 0; i < len; i++, ignorable >>= 1) {
615
616 if ((ignorable & 1) || (s1[i] == s2[i]))
617 continue;
618
619#ifdef TILE_NET_DEBUG
620 /* HACK: Mention non-timestamp diffs. */
621 if (i < 0x38 && i != 0x2f &&
622 net_ratelimit())
623 pr_info("Diff at 0x%x\n", i);
624#endif
625
626 return false;
627 }
628
629#ifdef TILE_NET_NO_SUPPRESS_DUP_ACKS
630 /* HACK: Do not suppress truly duplicate ACKs. */
631 /* ISSUE: Is this actually necessary or helpful? */
632 if (s1[0x2a] == s2[0x2a] &&
633 s1[0x2b] == s2[0x2b] &&
634 s1[0x2c] == s2[0x2c] &&
635 s1[0x2d] == s2[0x2d]) {
636 return false;
637 }
638#endif
639
640 return true;
641}
642
643#endif
644
645
646
647/*
648 * Like "tile_net_handle_packets()", but just discard packets.
649 */
650static void tile_net_discard_packets(struct net_device *dev)
651{
652 struct tile_net_priv *priv = netdev_priv(dev);
653 int my_cpu = smp_processor_id();
654 struct tile_net_cpu *info = priv->cpu[my_cpu];
655 struct tile_netio_queue *queue = &info->queue;
656 netio_queue_impl_t *qsp = queue->__system_part;
657 netio_queue_user_impl_t *qup = &queue->__user_part;
658
659 while (qup->__packet_receive_read !=
660 qsp->__packet_receive_queue.__packet_write) {
661
662 int index = qup->__packet_receive_read;
663
664 int index2_aux = index + sizeof(netio_pkt_t);
665 int index2 =
666 ((index2_aux ==
667 qsp->__packet_receive_queue.__last_packet_plus_one) ?
668 0 : index2_aux);
669
670 netio_pkt_t *pkt = (netio_pkt_t *)
671 ((unsigned long) &qsp[1] + index);
672
673 /* Extract the "linux_buffer_t". */
674 unsigned int buffer = pkt->__packet.word;
675
676 /* Convert "linux_buffer_t" to "va". */
677 void *va = __va((phys_addr_t)(buffer >> 1) << 7);
678
679 /* Acquire the associated "skb". */
680 struct sk_buff **skb_ptr = va - sizeof(*skb_ptr);
681 struct sk_buff *skb = *skb_ptr;
682
683 kfree_skb(skb);
684
685 /* Consume this packet. */
686 qup->__packet_receive_read = index2;
687 }
688}
689
690
691/*
692 * Handle the next packet. Return true if "processed", false if "filtered".
693 */
694static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
695{
696 struct net_device *dev = info->napi.dev;
697
698 struct tile_netio_queue *queue = &info->queue;
699 netio_queue_impl_t *qsp = queue->__system_part;
700 netio_queue_user_impl_t *qup = &queue->__user_part;
701 struct tile_net_stats_t *stats = &info->stats;
702
703 int filter;
704
705 int index2_aux = index + sizeof(netio_pkt_t);
706 int index2 =
707 ((index2_aux ==
708 qsp->__packet_receive_queue.__last_packet_plus_one) ?
709 0 : index2_aux);
710
711 netio_pkt_t *pkt = (netio_pkt_t *)((unsigned long) &qsp[1] + index);
712
713 netio_pkt_metadata_t *metadata = NETIO_PKT_METADATA(pkt);
714
715 /* Extract the packet size. */
716 unsigned long len =
717 (NETIO_PKT_CUSTOM_LENGTH(pkt) +
718 NET_IP_ALIGN - NETIO_PACKET_PADDING);
719
720 /* Extract the "linux_buffer_t". */
721 unsigned int buffer = pkt->__packet.word;
722
723 /* Extract "small" (vs "large"). */
724 bool small = ((buffer & 1) != 0);
725
726 /* Convert "linux_buffer_t" to "va". */
727 void *va = __va((phys_addr_t)(buffer >> 1) << 7);
728
729 /* Extract the packet data pointer. */
730 /* Compare to "NETIO_PKT_CUSTOM_DATA(pkt)". */
731 unsigned char *buf = va + NET_IP_ALIGN;
732
733#ifdef IGNORE_DUP_ACKS
734
735 static int other;
736 static int final;
737 static int keep;
738 static int skip;
739
740#endif
741
742 /* Invalidate the packet buffer. */
743 if (!hash_default)
744 __inv_buffer(buf, len);
745
746 /* ISSUE: Is this needed? */
747 dev->last_rx = jiffies;
748
749#ifdef TILE_NET_DUMP_PACKETS
750 dump_packet(buf, len, "rx");
751#endif /* TILE_NET_DUMP_PACKETS */
752
753#ifdef TILE_NET_VERIFY_INGRESS
754 if (!NETIO_PKT_L4_CSUM_CORRECT_M(metadata, pkt) &&
755 NETIO_PKT_L4_CSUM_CALCULATED_M(metadata, pkt)) {
756 /*
757 * FIXME: This complains about UDP packets
758 * with a "zero" checksum (bug 6624).
759 */
760#ifdef TILE_NET_PANIC_ON_BAD
761 dump_packet(buf, len, "rx");
762 panic("Bad L4 checksum.");
763#else
764 pr_warning("Bad L4 checksum on %d byte packet.\n", len);
765#endif
766 }
767 if (!NETIO_PKT_L3_CSUM_CORRECT_M(metadata, pkt) &&
768 NETIO_PKT_L3_CSUM_CALCULATED_M(metadata, pkt)) {
769 dump_packet(buf, len, "rx");
770 panic("Bad L3 checksum.");
771 }
772 switch (NETIO_PKT_STATUS_M(metadata, pkt)) {
773 case NETIO_PKT_STATUS_OVERSIZE:
774 if (len >= 64) {
775 dump_packet(buf, len, "rx");
776 panic("Unexpected OVERSIZE.");
777 }
778 break;
779 case NETIO_PKT_STATUS_BAD:
780#ifdef TILE_NET_PANIC_ON_BAD
781 dump_packet(buf, len, "rx");
782 panic("Unexpected BAD packet.");
783#else
784 pr_warning("Unexpected BAD %d byte packet.\n", len);
785#endif
786 }
787#endif
788
789 filter = 0;
790
791 if (!(dev->flags & IFF_UP)) {
792 /* Filter packets received before we're up. */
793 filter = 1;
794 } else if (!(dev->flags & IFF_PROMISC)) {
795 /*
796 * FIXME: Implement HW multicast filter.
797 */
798 if (!IS_MULTICAST(buf) && !IS_BROADCAST(buf)) {
799 /* Filter packets not for our address. */
800 const u8 *mine = dev->dev_addr;
801 filter = compare_ether_addr(mine, buf);
802 }
803 }
804
805#ifdef IGNORE_DUP_ACKS
806
807 if (len != 66) {
808 /* FIXME: Must check "is_tcp_ack(buf, len)" somehow. */
809
810 other++;
811
812 } else if (index2 ==
813 qsp->__packet_receive_queue.__packet_write) {
814
815 final++;
816
817 } else {
818
819 netio_pkt_t *pkt2 = (netio_pkt_t *)
820 ((unsigned long) &qsp[1] + index2);
821
822 netio_pkt_metadata_t *metadata2 =
823 NETIO_PKT_METADATA(pkt2);
824
825 /* Extract the packet size. */
826 unsigned long len2 =
827 (NETIO_PKT_CUSTOM_LENGTH(pkt2) +
828 NET_IP_ALIGN - NETIO_PACKET_PADDING);
829
830 if (len2 == 66 &&
831 NETIO_PKT_FLOW_HASH_M(metadata, pkt) ==
832 NETIO_PKT_FLOW_HASH_M(metadata2, pkt2)) {
833
834 /* Extract the "linux_buffer_t". */
835 unsigned int buffer2 = pkt2->__packet.word;
836
837 /* Convert "linux_buffer_t" to "va". */
838 void *va2 =
839 __va((phys_addr_t)(buffer2 >> 1) << 7);
840
841 /* Extract the packet data pointer. */
842 /* Compare to "NETIO_PKT_CUSTOM_DATA(pkt)". */
843 unsigned char *buf2 = va2 + NET_IP_ALIGN;
844
845 /* Invalidate the packet buffer. */
846 if (!hash_default)
847 __inv_buffer(buf2, len2);
848
849 if (is_dup_ack(buf, buf2, len)) {
850 skip++;
851 filter = 1;
852 } else {
853 keep++;
854 }
855 }
856 }
857
858 if (net_ratelimit())
859 pr_info("Other %d Final %d Keep %d Skip %d.\n",
860 other, final, keep, skip);
861
862#endif
863
864 if (filter) {
865
866 /* ISSUE: Update "drop" statistics? */
867
868 tile_net_provide_linux_buffer(info, va, small);
869
870 } else {
871
872 /* Acquire the associated "skb". */
873 struct sk_buff **skb_ptr = va - sizeof(*skb_ptr);
874 struct sk_buff *skb = *skb_ptr;
875
876 /* Paranoia. */
877 if (skb->data != buf)
878 panic("Corrupt linux buffer from LIPP! "
879 "VA=%p, skb=%p, skb->data=%p\n",
880 va, skb, skb->data);
881
882 /* Encode the actual packet length. */
883 skb_put(skb, len);
884
885 /* NOTE: This call also sets "skb->dev = dev". */
886 skb->protocol = eth_type_trans(skb, dev);
887
888 /* ISSUE: Discard corrupt packets? */
889 /* ISSUE: Discard packets with bad checksums? */
890
891 /* Avoid recomputing TCP/UDP checksums. */
892 if (NETIO_PKT_L4_CSUM_CORRECT_M(metadata, pkt))
893 skb->ip_summed = CHECKSUM_UNNECESSARY;
894
895 netif_receive_skb(skb);
896
897 stats->rx_packets++;
898 stats->rx_bytes += len;
899
900 if (small)
901 info->num_needed_small_buffers++;
902 else
903 info->num_needed_large_buffers++;
904 }
905
906 /* Return four credits after every fourth packet. */
907 if (--qup->__receive_credit_remaining == 0) {
908 u32 interval = qup->__receive_credit_interval;
909 qup->__receive_credit_remaining = interval;
910 __netio_fastio_return_credits(qup->__fastio_index, interval);
911 }
912
913 /* Consume this packet. */
914 qup->__packet_receive_read = index2;
915
916 return !filter;
917}
918
919
920/*
921 * Handle some packets for the given device on the current CPU.
922 *
923 * ISSUE: The "rotting packet" race condition occurs if a packet
924 * arrives after the queue appears to be empty, and before the
925 * hypervisor interrupt is re-enabled.
926 */
927static int tile_net_poll(struct napi_struct *napi, int budget)
928{
929 struct net_device *dev = napi->dev;
930 struct tile_net_priv *priv = netdev_priv(dev);
931 int my_cpu = smp_processor_id();
932 struct tile_net_cpu *info = priv->cpu[my_cpu];
933 struct tile_netio_queue *queue = &info->queue;
934 netio_queue_impl_t *qsp = queue->__system_part;
935 netio_queue_user_impl_t *qup = &queue->__user_part;
936
937 unsigned int work = 0;
938
939 while (1) {
940 int index = qup->__packet_receive_read;
941 if (index == qsp->__packet_receive_queue.__packet_write)
942 break;
943
944 if (tile_net_poll_aux(info, index)) {
945 if (++work >= budget)
946 goto done;
947 }
948 }
949
950 napi_complete(&info->napi);
951
952 /* Re-enable hypervisor interrupts. */
953 enable_percpu_irq(priv->intr_id);
954
955 /* HACK: Avoid the "rotting packet" problem. */
956 if (qup->__packet_receive_read !=
957 qsp->__packet_receive_queue.__packet_write)
958 napi_schedule(&info->napi);
959
960 /* ISSUE: Handle completions? */
961
962done:
963
964 tile_net_provide_needed_buffers(info);
965
966 return work;
967}
968
969
970/*
971 * Handle an ingress interrupt for the given device on the current cpu.
972 */
973static irqreturn_t tile_net_handle_ingress_interrupt(int irq, void *dev_ptr)
974{
975 struct net_device *dev = (struct net_device *)dev_ptr;
976 struct tile_net_priv *priv = netdev_priv(dev);
977 int my_cpu = smp_processor_id();
978 struct tile_net_cpu *info = priv->cpu[my_cpu];
979
980 /* Disable hypervisor interrupt. */
981 disable_percpu_irq(priv->intr_id);
982
983 napi_schedule(&info->napi);
984
985 return IRQ_HANDLED;
986}
987
988
989/*
990 * One time initialization per interface.
991 */
992static int tile_net_open_aux(struct net_device *dev)
993{
994 struct tile_net_priv *priv = netdev_priv(dev);
995
996 int ret;
997 int dummy;
998 unsigned int epp_lotar;
999
1000 /*
1001 * Find out where EPP memory should be homed.
1002 */
1003 ret = hv_dev_pread(priv->hv_devhdl, 0,
1004 (HV_VirtAddr)&epp_lotar, sizeof(epp_lotar),
1005 NETIO_EPP_SHM_OFF);
1006 if (ret < 0) {
1007 pr_err("could not read epp_shm_queue lotar.\n");
1008 return -EIO;
1009 }
1010
1011 /*
1012 * Home the page on the EPP.
1013 */
1014 {
1015 int epp_home = hv_lotar_to_cpu(epp_lotar);
1016 struct page *page = virt_to_page(priv->epp_queue);
1017 homecache_change_page_home(page, 0, epp_home);
1018 }
1019
1020 /*
1021 * Register the EPP shared memory queue.
1022 */
1023 {
1024 netio_ipp_address_t ea = {
1025 .va = 0,
1026 .pa = __pa(priv->epp_queue),
1027 .pte = hv_pte(0),
1028 .size = PAGE_SIZE,
1029 };
1030 ea.pte = hv_pte_set_lotar(ea.pte, epp_lotar);
1031 ea.pte = hv_pte_set_mode(ea.pte, HV_PTE_MODE_CACHE_TILE_L3);
1032 ret = hv_dev_pwrite(priv->hv_devhdl, 0,
1033 (HV_VirtAddr)&ea,
1034 sizeof(ea),
1035 NETIO_EPP_SHM_OFF);
1036 if (ret < 0)
1037 return -EIO;
1038 }
1039
1040 /*
1041 * Start LIPP/LEPP.
1042 */
1043 if (hv_dev_pwrite(priv->hv_devhdl, 0, (HV_VirtAddr)&dummy,
1044 sizeof(dummy), NETIO_IPP_START_SHIM_OFF) < 0) {
1045 pr_warning("Failed to start LIPP/LEPP.\n");
1046 return -EIO;
1047 }
1048
1049 return 0;
1050}
1051
1052
1053/*
1054 * Register with hypervisor on each CPU.
1055 *
1056 * Strangely, this function does important things even if it "fails",
1057 * which is especially common if the link is not up yet. Hopefully
1058 * these things are all "harmless" if done twice!
1059 */
1060static void tile_net_register(void *dev_ptr)
1061{
1062 struct net_device *dev = (struct net_device *)dev_ptr;
1063 struct tile_net_priv *priv = netdev_priv(dev);
1064 int my_cpu = smp_processor_id();
1065 struct tile_net_cpu *info;
1066
1067 struct tile_netio_queue *queue;
1068
1069 /* Only network cpus can receive packets. */
1070 int queue_id =
1071 cpumask_test_cpu(my_cpu, &priv->network_cpus_map) ? 0 : 255;
1072
1073 netio_input_config_t config = {
1074 .flags = 0,
1075 .num_receive_packets = priv->network_cpus_credits,
1076 .queue_id = queue_id
1077 };
1078
1079 int ret = 0;
1080 netio_queue_impl_t *queuep;
1081
1082 PDEBUG("tile_net_register(queue_id %d)\n", queue_id);
1083
1084 if (!strcmp(dev->name, "xgbe0"))
1085 info = &__get_cpu_var(hv_xgbe0);
1086 else if (!strcmp(dev->name, "xgbe1"))
1087 info = &__get_cpu_var(hv_xgbe1);
1088 else if (!strcmp(dev->name, "gbe0"))
1089 info = &__get_cpu_var(hv_gbe0);
1090 else if (!strcmp(dev->name, "gbe1"))
1091 info = &__get_cpu_var(hv_gbe1);
1092 else
1093 BUG();
1094
1095 /* Initialize the egress timer. */
1096 init_timer(&info->egress_timer);
1097 info->egress_timer.data = (long)info;
1098 info->egress_timer.function = tile_net_handle_egress_timer;
1099
1100 priv->cpu[my_cpu] = info;
1101
1102 /*
1103 * Register ourselves with the IPP.
1104 */
1105 ret = hv_dev_pwrite(priv->hv_devhdl, 0,
1106 (HV_VirtAddr)&config,
1107 sizeof(netio_input_config_t),
1108 NETIO_IPP_INPUT_REGISTER_OFF);
1109 PDEBUG("hv_dev_pwrite(NETIO_IPP_INPUT_REGISTER_OFF) returned %d\n",
1110 ret);
1111 if (ret < 0) {
1112 printk(KERN_DEBUG "hv_dev_pwrite NETIO_IPP_INPUT_REGISTER_OFF"
1113 " failure %d\n", ret);
1114 info->link_down = (ret == NETIO_LINK_DOWN);
1115 return;
1116 }
1117
1118 /*
1119 * Get the pointer to our queue's system part.
1120 */
1121
1122 ret = hv_dev_pread(priv->hv_devhdl, 0,
1123 (HV_VirtAddr)&queuep,
1124 sizeof(netio_queue_impl_t *),
1125 NETIO_IPP_INPUT_REGISTER_OFF);
1126 PDEBUG("hv_dev_pread(NETIO_IPP_INPUT_REGISTER_OFF) returned %d\n",
1127 ret);
1128 PDEBUG("queuep %p\n", queuep);
1129 if (ret <= 0) {
1130 /* ISSUE: Shouldn't this be a fatal error? */
1131 pr_err("hv_dev_pread NETIO_IPP_INPUT_REGISTER_OFF failure\n");
1132 return;
1133 }
1134
1135 queue = &info->queue;
1136
1137 queue->__system_part = queuep;
1138
1139 memset(&queue->__user_part, 0, sizeof(netio_queue_user_impl_t));
1140
1141 /* This is traditionally "config.num_receive_packets / 2". */
1142 queue->__user_part.__receive_credit_interval = 4;
1143 queue->__user_part.__receive_credit_remaining =
1144 queue->__user_part.__receive_credit_interval;
1145
1146 /*
1147 * Get a fastio index from the hypervisor.
1148 * ISSUE: Shouldn't this check the result?
1149 */
1150 ret = hv_dev_pread(priv->hv_devhdl, 0,
1151 (HV_VirtAddr)&queue->__user_part.__fastio_index,
1152 sizeof(queue->__user_part.__fastio_index),
1153 NETIO_IPP_GET_FASTIO_OFF);
1154 PDEBUG("hv_dev_pread(NETIO_IPP_GET_FASTIO_OFF) returned %d\n", ret);
1155
1156 netif_napi_add(dev, &info->napi, tile_net_poll, 64);
1157
1158 /* Now we are registered. */
1159 info->registered = true;
1160}
1161
1162
1163/*
1164 * Unregister with hypervisor on each CPU.
1165 */
1166static void tile_net_unregister(void *dev_ptr)
1167{
1168 struct net_device *dev = (struct net_device *)dev_ptr;
1169 struct tile_net_priv *priv = netdev_priv(dev);
1170 int my_cpu = smp_processor_id();
1171 struct tile_net_cpu *info = priv->cpu[my_cpu];
1172
1173 int ret = 0;
1174 int dummy = 0;
1175
1176 /* Do nothing if never registered. */
1177 if (info == NULL)
1178 return;
1179
1180 /* Do nothing if already unregistered. */
1181 if (!info->registered)
1182 return;
1183
1184 /*
1185 * Unregister ourselves with LIPP.
1186 */
1187 ret = hv_dev_pwrite(priv->hv_devhdl, 0, (HV_VirtAddr)&dummy,
1188 sizeof(dummy), NETIO_IPP_INPUT_UNREGISTER_OFF);
1189 PDEBUG("hv_dev_pwrite(NETIO_IPP_INPUT_UNREGISTER_OFF) returned %d\n",
1190 ret);
1191 if (ret < 0) {
1192 /* FIXME: Just panic? */
1193 pr_err("hv_dev_pwrite NETIO_IPP_INPUT_UNREGISTER_OFF"
1194 " failure %d\n", ret);
1195 }
1196
1197 /*
1198 * Discard all packets still in our NetIO queue. Hopefully,
1199 * once the unregister call is complete, there will be no
1200 * packets still in flight on the IDN.
1201 */
1202 tile_net_discard_packets(dev);
1203
1204 /* Reset state. */
1205 info->num_needed_small_buffers = 0;
1206 info->num_needed_large_buffers = 0;
1207
1208 /* Cancel egress timer. */
1209 del_timer(&info->egress_timer);
1210 info->egress_timer_scheduled = false;
1211
1212 netif_napi_del(&info->napi);
1213
1214 /* Now we are unregistered. */
1215 info->registered = false;
1216}
1217
1218
1219/*
1220 * Helper function for "tile_net_stop()".
1221 *
1222 * Also used to handle registration failure in "tile_net_open_inner()",
1223 * when "fully_opened" is known to be false, and the various extra
1224 * steps in "tile_net_stop()" are not necessary. ISSUE: It might be
1225 * simpler if we could just call "tile_net_stop()" anyway.
1226 */
1227static void tile_net_stop_aux(struct net_device *dev)
1228{
1229 struct tile_net_priv *priv = netdev_priv(dev);
1230
1231 int dummy = 0;
1232
1233 /* Unregister all tiles, so LIPP will stop delivering packets. */
1234 on_each_cpu(tile_net_unregister, (void *)dev, 1);
1235
1236 /* Stop LIPP/LEPP. */
1237 if (hv_dev_pwrite(priv->hv_devhdl, 0, (HV_VirtAddr)&dummy,
1238 sizeof(dummy), NETIO_IPP_STOP_SHIM_OFF) < 0)
1239 panic("Failed to stop LIPP/LEPP!\n");
1240
1241 priv->partly_opened = 0;
1242}
1243
1244
1245/*
1246 * Disable ingress interrupts for the given device on the current cpu.
1247 */
1248static void tile_net_disable_intr(void *dev_ptr)
1249{
1250 struct net_device *dev = (struct net_device *)dev_ptr;
1251 struct tile_net_priv *priv = netdev_priv(dev);
1252 int my_cpu = smp_processor_id();
1253 struct tile_net_cpu *info = priv->cpu[my_cpu];
1254
1255 /* Disable hypervisor interrupt. */
1256 disable_percpu_irq(priv->intr_id);
1257
1258 /* Disable NAPI if needed. */
1259 if (info != NULL && info->napi_enabled) {
1260 napi_disable(&info->napi);
1261 info->napi_enabled = false;
1262 }
1263}
1264
1265
1266/*
1267 * Enable ingress interrupts for the given device on the current cpu.
1268 */
1269static void tile_net_enable_intr(void *dev_ptr)
1270{
1271 struct net_device *dev = (struct net_device *)dev_ptr;
1272 struct tile_net_priv *priv = netdev_priv(dev);
1273 int my_cpu = smp_processor_id();
1274 struct tile_net_cpu *info = priv->cpu[my_cpu];
1275
1276 /* Enable hypervisor interrupt. */
1277 enable_percpu_irq(priv->intr_id);
1278
1279 /* Enable NAPI. */
1280 napi_enable(&info->napi);
1281 info->napi_enabled = true;
1282}
1283
1284
1285/*
1286 * tile_net_open_inner does most of the work of bringing up the interface.
1287 * It's called from tile_net_open(), and also from tile_net_retry_open().
1288 * The return value is 0 if the interface was brought up, < 0 if
1289 * tile_net_open() should return the return value as an error, and > 0 if
1290 * tile_net_open() should return success and schedule a work item to
1291 * periodically retry the bringup.
1292 */
1293static int tile_net_open_inner(struct net_device *dev)
1294{
1295 struct tile_net_priv *priv = netdev_priv(dev);
1296 int my_cpu = smp_processor_id();
1297 struct tile_net_cpu *info;
1298 struct tile_netio_queue *queue;
1299 unsigned int irq;
1300 int i;
1301
1302 /*
1303 * First try to register just on the local CPU, and handle any
1304 * semi-expected "link down" failure specially. Note that we
1305 * do NOT call "tile_net_stop_aux()", unlike below.
1306 */
1307 tile_net_register(dev);
1308 info = priv->cpu[my_cpu];
1309 if (!info->registered) {
1310 if (info->link_down)
1311 return 1;
1312 return -EAGAIN;
1313 }
1314
1315 /*
1316 * Now register everywhere else. If any registration fails,
1317 * even for "link down" (which might not be possible), we
1318 * clean up using "tile_net_stop_aux()".
1319 */
1320 smp_call_function(tile_net_register, (void *)dev, 1);
1321 for_each_online_cpu(i) {
1322 if (!priv->cpu[i]->registered) {
1323 tile_net_stop_aux(dev);
1324 return -EAGAIN;
1325 }
1326 }
1327
1328 queue = &info->queue;
1329
1330 /*
1331 * Set the device intr bit mask.
1332 * The tile_net_register above sets per tile __intr_id.
1333 */
1334 priv->intr_id = queue->__system_part->__intr_id;
1335 BUG_ON(!priv->intr_id);
1336
1337 /*
1338 * Register the device interrupt handler.
1339 * The __ffs() function returns the index into the interrupt handler
1340 * table from the interrupt bit mask which should have one bit
1341 * and one bit only set.
1342 */
1343 irq = __ffs(priv->intr_id);
1344 tile_irq_activate(irq, TILE_IRQ_PERCPU);
1345 BUG_ON(request_irq(irq, tile_net_handle_ingress_interrupt,
1346 0, dev->name, (void *)dev) != 0);
1347
1348 /* ISSUE: How could "priv->fully_opened" ever be "true" here? */
1349
1350 if (!priv->fully_opened) {
1351
1352 int dummy = 0;
1353
1354 /* Allocate initial buffers. */
1355
1356 int max_buffers =
1357 priv->network_cpus_count * priv->network_cpus_credits;
1358
1359 info->num_needed_small_buffers =
1360 min(LIPP_SMALL_BUFFERS, max_buffers);
1361
1362 info->num_needed_large_buffers =
1363 min(LIPP_LARGE_BUFFERS, max_buffers);
1364
1365 tile_net_provide_needed_buffers(info);
1366
1367 if (info->num_needed_small_buffers != 0 ||
1368 info->num_needed_large_buffers != 0)
1369 panic("Insufficient memory for buffer stack!");
1370
1371 /* Start LIPP/LEPP and activate "ingress" at the shim. */
1372 if (hv_dev_pwrite(priv->hv_devhdl, 0, (HV_VirtAddr)&dummy,
1373 sizeof(dummy), NETIO_IPP_INPUT_INIT_OFF) < 0)
1374 panic("Failed to activate the LIPP Shim!\n");
1375
1376 priv->fully_opened = 1;
1377 }
1378
1379 /* On each tile, enable the hypervisor to trigger interrupts. */
1380 /* ISSUE: Do this before starting LIPP/LEPP? */
1381 on_each_cpu(tile_net_enable_intr, (void *)dev, 1);
1382
1383 /* Start our transmit queue. */
1384 netif_start_queue(dev);
1385
1386 return 0;
1387}
1388
1389
1390/*
1391 * Called periodically to retry bringing up the NetIO interface,
1392 * if it doesn't come up cleanly during tile_net_open().
1393 */
1394static void tile_net_open_retry(struct work_struct *w)
1395{
1396 struct delayed_work *dw =
1397 container_of(w, struct delayed_work, work);
1398
1399 struct tile_net_priv *priv =
1400 container_of(dw, struct tile_net_priv, retry_work);
1401
1402 /*
1403 * Try to bring the NetIO interface up. If it fails, reschedule
1404 * ourselves to try again later; otherwise, tell Linux we now have
1405 * a working link. ISSUE: What if the return value is negative?
1406 */
1407 if (tile_net_open_inner(priv->dev))
1408 schedule_delayed_work_on(singlethread_cpu, &priv->retry_work,
1409 TILE_NET_RETRY_INTERVAL);
1410 else
1411 netif_carrier_on(priv->dev);
1412}
1413
1414
1415/*
1416 * Called when a network interface is made active.
1417 *
1418 * Returns 0 on success, negative value on failure.
1419 *
1420 * The open entry point is called when a network interface is made
1421 * active by the system (IFF_UP). At this point all resources needed
1422 * for transmit and receive operations are allocated, the interrupt
1423 * handler is registered with the OS, the watchdog timer is started,
1424 * and the stack is notified that the interface is ready.
1425 *
1426 * If the actual link is not available yet, then we tell Linux that
1427 * we have no carrier, and we keep checking until the link comes up.
1428 */
1429static int tile_net_open(struct net_device *dev)
1430{
1431 int ret = 0;
1432 struct tile_net_priv *priv = netdev_priv(dev);
1433
1434 /*
1435 * We rely on priv->partly_opened to tell us if this is the
1436 * first time this interface is being brought up. If it is
1437 * set, the IPP was already initialized and should not be
1438 * initialized again.
1439 */
1440 if (!priv->partly_opened) {
1441
1442 int count;
1443 int credits;
1444
1445 /* Initialize LIPP/LEPP, and start the Shim. */
1446 ret = tile_net_open_aux(dev);
1447 if (ret < 0) {
1448 pr_err("tile_net_open_aux failed: %d\n", ret);
1449 return ret;
1450 }
1451
1452 /* Analyze the network cpus. */
1453
1454 if (network_cpus_used)
1455 cpumask_copy(&priv->network_cpus_map,
1456 &network_cpus_map);
1457 else
1458 cpumask_copy(&priv->network_cpus_map, cpu_online_mask);
1459
1460
1461 count = cpumask_weight(&priv->network_cpus_map);
1462
1463 /* Limit credits to available buffers, and apply min. */
1464 credits = max(16, (LIPP_LARGE_BUFFERS / count) & ~1);
1465
1466 /* Apply "GBE" max limit. */
1467 /* ISSUE: Use higher limit for XGBE? */
1468 credits = min(NETIO_MAX_RECEIVE_PKTS, credits);
1469
1470 priv->network_cpus_count = count;
1471 priv->network_cpus_credits = credits;
1472
1473#ifdef TILE_NET_DEBUG
1474 pr_info("Using %d network cpus, with %d credits each\n",
1475 priv->network_cpus_count, priv->network_cpus_credits);
1476#endif
1477
1478 priv->partly_opened = 1;
1479 }
1480
1481 /*
1482 * Attempt to bring up the link.
1483 */
1484 ret = tile_net_open_inner(dev);
1485 if (ret <= 0) {
1486 if (ret == 0)
1487 netif_carrier_on(dev);
1488 return ret;
1489 }
1490
1491 /*
1492 * We were unable to bring up the NetIO interface, but we want to
1493 * try again in a little bit. Tell Linux that we have no carrier
1494 * so it doesn't try to use the interface before the link comes up
1495 * and then remember to try again later.
1496 */
1497 netif_carrier_off(dev);
1498 schedule_delayed_work_on(singlethread_cpu, &priv->retry_work,
1499 TILE_NET_RETRY_INTERVAL);
1500
1501 return 0;
1502}
1503
1504
1505/*
1506 * Disables a network interface.
1507 *
1508 * Returns 0, this is not allowed to fail.
1509 *
1510 * The close entry point is called when an interface is de-activated
1511 * by the OS. The hardware is still under the drivers control, but
1512 * needs to be disabled. A global MAC reset is issued to stop the
1513 * hardware, and all transmit and receive resources are freed.
1514 *
1515 * ISSUE: Can this can be called while "tile_net_poll()" is running?
1516 */
1517static int tile_net_stop(struct net_device *dev)
1518{
1519 struct tile_net_priv *priv = netdev_priv(dev);
1520
1521 bool pending = true;
1522
1523 PDEBUG("tile_net_stop()\n");
1524
1525 /* ISSUE: Only needed if not yet fully open. */
1526 cancel_delayed_work_sync(&priv->retry_work);
1527
1528 /* Can't transmit any more. */
1529 netif_stop_queue(dev);
1530
1531 /*
1532 * Disable hypervisor interrupts on each tile.
1533 */
1534 on_each_cpu(tile_net_disable_intr, (void *)dev, 1);
1535
1536 /*
1537 * Unregister the interrupt handler.
1538 * The __ffs() function returns the index into the interrupt handler
1539 * table from the interrupt bit mask which should have one bit
1540 * and one bit only set.
1541 */
1542 if (priv->intr_id)
1543 free_irq(__ffs(priv->intr_id), dev);
1544
1545 /*
1546 * Drain all the LIPP buffers.
1547 */
1548
1549 while (true) {
1550 int buffer;
1551
1552 /* NOTE: This should never fail. */
1553 if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&buffer,
1554 sizeof(buffer), NETIO_IPP_DRAIN_OFF) < 0)
1555 break;
1556
1557 /* Stop when done. */
1558 if (buffer == 0)
1559 break;
1560
1561 {
1562 /* Convert "linux_buffer_t" to "va". */
1563 void *va = __va((phys_addr_t)(buffer >> 1) << 7);
1564
1565 /* Acquire the associated "skb". */
1566 struct sk_buff **skb_ptr = va - sizeof(*skb_ptr);
1567 struct sk_buff *skb = *skb_ptr;
1568
1569 kfree_skb(skb);
1570 }
1571 }
1572
1573 /* Stop LIPP/LEPP. */
1574 tile_net_stop_aux(dev);
1575
1576
1577 priv->fully_opened = 0;
1578
1579
1580 /*
1581 * XXX: ISSUE: It appears that, in practice anyway, by the
1582 * time we get here, there are no pending completions.
1583 */
1584 while (pending) {
1585
1586 struct sk_buff *olds[32];
1587 unsigned int wanted = 32;
1588 unsigned int i, nolds = 0;
1589
1590 nolds = tile_net_lepp_grab_comps(dev, olds,
1591 wanted, &pending);
1592
1593 /* ISSUE: We have never actually seen this debug spew. */
1594 if (nolds != 0)
1595 pr_info("During tile_net_stop(), grabbed %d comps.\n",
1596 nolds);
1597
1598 for (i = 0; i < nolds; i++)
1599 kfree_skb(olds[i]);
1600 }
1601
1602
1603 /* Wipe the EPP queue. */
1604 memset(priv->epp_queue, 0, sizeof(lepp_queue_t));
1605
1606 /* Evict the EPP queue. */
1607 finv_buffer(priv->epp_queue, PAGE_SIZE);
1608
1609 return 0;
1610}
1611
1612
1613/*
1614 * Prepare the "frags" info for the resulting LEPP command.
1615 *
1616 * If needed, flush the memory used by the frags.
1617 */
1618static unsigned int tile_net_tx_frags(lepp_frag_t *frags,
1619 struct sk_buff *skb,
1620 void *b_data, unsigned int b_len)
1621{
1622 unsigned int i, n = 0;
1623
1624 struct skb_shared_info *sh = skb_shinfo(skb);
1625
1626 phys_addr_t cpa;
1627
1628 if (b_len != 0) {
1629
1630 if (!hash_default)
1631 finv_buffer_remote(b_data, b_len);
1632
1633 cpa = __pa(b_data);
1634 frags[n].cpa_lo = cpa;
1635 frags[n].cpa_hi = cpa >> 32;
1636 frags[n].length = b_len;
1637 frags[n].hash_for_home = hash_default;
1638 n++;
1639 }
1640
1641 for (i = 0; i < sh->nr_frags; i++) {
1642
1643 skb_frag_t *f = &sh->frags[i];
1644 unsigned long pfn = page_to_pfn(f->page);
1645
1646 /* FIXME: Compute "hash_for_home" properly. */
1647 /* ISSUE: The hypervisor checks CHIP_HAS_REV1_DMA_PACKETS(). */
1648 int hash_for_home = hash_default;
1649
1650 /* FIXME: Hmmm. */
1651 if (!hash_default) {
1652 void *va = pfn_to_kaddr(pfn) + f->page_offset;
1653 BUG_ON(PageHighMem(f->page));
1654 finv_buffer_remote(va, f->size);
1655 }
1656
1657 cpa = ((phys_addr_t)pfn << PAGE_SHIFT) + f->page_offset;
1658 frags[n].cpa_lo = cpa;
1659 frags[n].cpa_hi = cpa >> 32;
1660 frags[n].length = f->size;
1661 frags[n].hash_for_home = hash_for_home;
1662 n++;
1663 }
1664
1665 return n;
1666}
1667
1668
1669/*
1670 * This function takes "skb", consisting of a header template and a
1671 * payload, and hands it to LEPP, to emit as one or more segments,
1672 * each consisting of a possibly modified header, plus a piece of the
1673 * payload, via a process known as "tcp segmentation offload".
1674 *
1675 * Usually, "data" will contain the header template, of size "sh_len",
1676 * and "sh->frags" will contain "skb->data_len" bytes of payload, and
1677 * there will be "sh->gso_segs" segments.
1678 *
1679 * Sometimes, if "sendfile()" requires copying, we will be called with
1680 * "data" containing the header and payload, with "frags" being empty.
1681 *
1682 * In theory, "sh->nr_frags" could be 3, but in practice, it seems
1683 * that this will never actually happen.
1684 *
1685 * See "emulate_large_send_offload()" for some reference code, which
1686 * does not handle checksumming.
1687 *
1688 * ISSUE: How do we make sure that high memory DMA does not migrate?
1689 */
1690static int tile_net_tx_tso(struct sk_buff *skb, struct net_device *dev)
1691{
1692 struct tile_net_priv *priv = netdev_priv(dev);
1693 int my_cpu = smp_processor_id();
1694 struct tile_net_cpu *info = priv->cpu[my_cpu];
1695 struct tile_net_stats_t *stats = &info->stats;
1696
1697 struct skb_shared_info *sh = skb_shinfo(skb);
1698
1699 unsigned char *data = skb->data;
1700
1701 /* The ip header follows the ethernet header. */
1702 struct iphdr *ih = ip_hdr(skb);
1703 unsigned int ih_len = ih->ihl * 4;
1704
1705 /* Note that "nh == ih", by definition. */
1706 unsigned char *nh = skb_network_header(skb);
1707 unsigned int eh_len = nh - data;
1708
1709 /* The tcp header follows the ip header. */
1710 struct tcphdr *th = (struct tcphdr *)(nh + ih_len);
1711 unsigned int th_len = th->doff * 4;
1712
1713 /* The total number of header bytes. */
1714 /* NOTE: This may be less than skb_headlen(skb). */
1715 unsigned int sh_len = eh_len + ih_len + th_len;
1716
1717 /* The number of payload bytes at "skb->data + sh_len". */
1718 /* This is non-zero for sendfile() without HIGHDMA. */
1719 unsigned int b_len = skb_headlen(skb) - sh_len;
1720
1721 /* The total number of payload bytes. */
1722 unsigned int d_len = b_len + skb->data_len;
1723
1724 /* The maximum payload size. */
1725 unsigned int p_len = sh->gso_size;
1726
1727 /* The total number of segments. */
1728 unsigned int num_segs = sh->gso_segs;
1729
1730 /* The temporary copy of the command. */
1731 u32 cmd_body[(LEPP_MAX_CMD_SIZE + 3) / 4];
1732 lepp_tso_cmd_t *cmd = (lepp_tso_cmd_t *)cmd_body;
1733
1734 /* Analyze the "frags". */
1735 unsigned int num_frags =
1736 tile_net_tx_frags(cmd->frags, skb, data + sh_len, b_len);
1737
1738 /* The size of the command, including frags and header. */
1739 size_t cmd_size = LEPP_TSO_CMD_SIZE(num_frags, sh_len);
1740
1741 /* The command header. */
1742 lepp_tso_cmd_t cmd_init = {
1743 .tso = true,
1744 .header_size = sh_len,
1745 .ip_offset = eh_len,
1746 .tcp_offset = eh_len + ih_len,
1747 .payload_size = p_len,
1748 .num_frags = num_frags,
1749 };
1750
1751 unsigned long irqflags;
1752
1753 lepp_queue_t *eq = priv->epp_queue;
1754
1755 struct sk_buff *olds[4];
1756 unsigned int wanted = 4;
1757 unsigned int i, nolds = 0;
1758
1759 unsigned int cmd_head, cmd_tail, cmd_next;
1760 unsigned int comp_tail;
1761
1762 unsigned int free_slots;
1763
1764
1765 /* Paranoia. */
1766 BUG_ON(skb->protocol != htons(ETH_P_IP));
1767 BUG_ON(ih->protocol != IPPROTO_TCP);
1768 BUG_ON(skb->ip_summed != CHECKSUM_PARTIAL);
1769 BUG_ON(num_frags > LEPP_MAX_FRAGS);
1770 /*--BUG_ON(num_segs != (d_len + (p_len - 1)) / p_len); */
1771 BUG_ON(num_segs <= 1);
1772
1773
1774 /* Finish preparing the command. */
1775
1776 /* Copy the command header. */
1777 *cmd = cmd_init;
1778
1779 /* Copy the "header". */
1780 memcpy(&cmd->frags[num_frags], data, sh_len);
1781
1782
1783 /* Prefetch and wait, to minimize time spent holding the spinlock. */
1784 prefetch_L1(&eq->comp_tail);
1785 prefetch_L1(&eq->cmd_tail);
1786 mb();
1787
1788
1789 /* Enqueue the command. */
1790
1791 spin_lock_irqsave(&priv->cmd_lock, irqflags);
1792
1793 /*
1794 * Handle completions if needed to make room.
1795 * HACK: Spin until there is sufficient room.
1796 */
1797 free_slots = lepp_num_free_comp_slots(eq);
1798 if (free_slots < 1) {
1799spin:
1800 nolds += tile_net_lepp_grab_comps(dev, olds + nolds,
1801 wanted - nolds, NULL);
1802 if (lepp_num_free_comp_slots(eq) < 1)
1803 goto spin;
1804 }
1805
1806 cmd_head = eq->cmd_head;
1807 cmd_tail = eq->cmd_tail;
1808
1809 /* NOTE: The "gotos" below are untested. */
1810
1811 /* Prepare to advance, detecting full queue. */
1812 cmd_next = cmd_tail + cmd_size;
1813 if (cmd_tail < cmd_head && cmd_next >= cmd_head)
1814 goto spin;
1815 if (cmd_next > LEPP_CMD_LIMIT) {
1816 cmd_next = 0;
1817 if (cmd_next == cmd_head)
1818 goto spin;
1819 }
1820
1821 /* Copy the command. */
1822 memcpy(&eq->cmds[cmd_tail], cmd, cmd_size);
1823
1824 /* Advance. */
1825 cmd_tail = cmd_next;
1826
1827 /* Record "skb" for eventual freeing. */
1828 comp_tail = eq->comp_tail;
1829 eq->comps[comp_tail] = skb;
1830 LEPP_QINC(comp_tail);
1831 eq->comp_tail = comp_tail;
1832
1833 /* Flush before allowing LEPP to handle the command. */
1834 __insn_mf();
1835
1836 eq->cmd_tail = cmd_tail;
1837
1838 spin_unlock_irqrestore(&priv->cmd_lock, irqflags);
1839
1840 if (nolds == 0)
1841 nolds = tile_net_lepp_grab_comps(dev, olds, wanted, NULL);
1842
1843 /* Handle completions. */
1844 for (i = 0; i < nolds; i++)
1845 kfree_skb(olds[i]);
1846
1847 /* Update stats. */
1848 stats->tx_packets += num_segs;
1849 stats->tx_bytes += (num_segs * sh_len) + d_len;
1850
1851 /* Make sure the egress timer is scheduled. */
1852 tile_net_schedule_egress_timer(info);
1853
1854 return NETDEV_TX_OK;
1855}
1856
1857
1858/*
1859 * Transmit a packet (called by the kernel via "hard_start_xmit" hook).
1860 */
1861static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
1862{
1863 struct tile_net_priv *priv = netdev_priv(dev);
1864 int my_cpu = smp_processor_id();
1865 struct tile_net_cpu *info = priv->cpu[my_cpu];
1866 struct tile_net_stats_t *stats = &info->stats;
1867
1868 unsigned long irqflags;
1869
1870 struct skb_shared_info *sh = skb_shinfo(skb);
1871
1872 unsigned int len = skb->len;
1873 unsigned char *data = skb->data;
1874
1875 unsigned int csum_start = skb->csum_start - skb_headroom(skb);
1876
1877 lepp_frag_t frags[LEPP_MAX_FRAGS];
1878
1879 unsigned int num_frags;
1880
1881 lepp_queue_t *eq = priv->epp_queue;
1882
1883 struct sk_buff *olds[4];
1884 unsigned int wanted = 4;
1885 unsigned int i, nolds = 0;
1886
1887 unsigned int cmd_size = sizeof(lepp_cmd_t);
1888
1889 unsigned int cmd_head, cmd_tail, cmd_next;
1890 unsigned int comp_tail;
1891
1892 lepp_cmd_t cmds[LEPP_MAX_FRAGS];
1893
1894 unsigned int free_slots;
1895
1896
1897 /*
1898 * This is paranoia, since we think that if the link doesn't come
1899 * up, telling Linux we have no carrier will keep it from trying
1900 * to transmit. If it does, though, we can't execute this routine,
1901 * since data structures we depend on aren't set up yet.
1902 */
1903 if (!info->registered)
1904 return NETDEV_TX_BUSY;
1905
1906
1907 /* Save the timestamp. */
1908 dev->trans_start = jiffies;
1909
1910
1911#ifdef TILE_NET_PARANOIA
1912#if CHIP_HAS_CBOX_HOME_MAP()
1913 if (hash_default) {
1914 HV_PTE pte = *virt_to_pte(current->mm, (unsigned long)data);
1915 if (hv_pte_get_mode(pte) != HV_PTE_MODE_CACHE_HASH_L3)
1916 panic("Non-coherent egress buffer!");
1917 }
1918#endif
1919#endif
1920
1921
1922#ifdef TILE_NET_DUMP_PACKETS
1923 /* ISSUE: Does not dump the "frags". */
1924 dump_packet(data, skb_headlen(skb), "tx");
1925#endif /* TILE_NET_DUMP_PACKETS */
1926
1927
1928 if (sh->gso_size != 0)
1929 return tile_net_tx_tso(skb, dev);
1930
1931
1932 /* Prepare the commands. */
1933
1934 num_frags = tile_net_tx_frags(frags, skb, data, skb_headlen(skb));
1935
1936 for (i = 0; i < num_frags; i++) {
1937
1938 bool final = (i == num_frags - 1);
1939
1940 lepp_cmd_t cmd = {
1941 .cpa_lo = frags[i].cpa_lo,
1942 .cpa_hi = frags[i].cpa_hi,
1943 .length = frags[i].length,
1944 .hash_for_home = frags[i].hash_for_home,
1945 .send_completion = final,
1946 .end_of_packet = final
1947 };
1948
1949 if (i == 0 && skb->ip_summed == CHECKSUM_PARTIAL) {
1950 cmd.compute_checksum = 1;
1951 cmd.checksum_data.bits.start_byte = csum_start;
1952 cmd.checksum_data.bits.count = len - csum_start;
1953 cmd.checksum_data.bits.destination_byte =
1954 csum_start + skb->csum_offset;
1955 }
1956
1957 cmds[i] = cmd;
1958 }
1959
1960
1961 /* Prefetch and wait, to minimize time spent holding the spinlock. */
1962 prefetch_L1(&eq->comp_tail);
1963 prefetch_L1(&eq->cmd_tail);
1964 mb();
1965
1966
1967 /* Enqueue the commands. */
1968
1969 spin_lock_irqsave(&priv->cmd_lock, irqflags);
1970
1971 /*
1972 * Handle completions if needed to make room.
1973 * HACK: Spin until there is sufficient room.
1974 */
1975 free_slots = lepp_num_free_comp_slots(eq);
1976 if (free_slots < 1) {
1977spin:
1978 nolds += tile_net_lepp_grab_comps(dev, olds + nolds,
1979 wanted - nolds, NULL);
1980 if (lepp_num_free_comp_slots(eq) < 1)
1981 goto spin;
1982 }
1983
1984 cmd_head = eq->cmd_head;
1985 cmd_tail = eq->cmd_tail;
1986
1987 /* NOTE: The "gotos" below are untested. */
1988
1989 /* Copy the commands, or fail. */
1990 for (i = 0; i < num_frags; i++) {
1991
1992 /* Prepare to advance, detecting full queue. */
1993 cmd_next = cmd_tail + cmd_size;
1994 if (cmd_tail < cmd_head && cmd_next >= cmd_head)
1995 goto spin;
1996 if (cmd_next > LEPP_CMD_LIMIT) {
1997 cmd_next = 0;
1998 if (cmd_next == cmd_head)
1999 goto spin;
2000 }
2001
2002 /* Copy the command. */
2003 *(lepp_cmd_t *)&eq->cmds[cmd_tail] = cmds[i];
2004
2005 /* Advance. */
2006 cmd_tail = cmd_next;
2007 }
2008
2009 /* Record "skb" for eventual freeing. */
2010 comp_tail = eq->comp_tail;
2011 eq->comps[comp_tail] = skb;
2012 LEPP_QINC(comp_tail);
2013 eq->comp_tail = comp_tail;
2014
2015 /* Flush before allowing LEPP to handle the command. */
2016 __insn_mf();
2017
2018 eq->cmd_tail = cmd_tail;
2019
2020 spin_unlock_irqrestore(&priv->cmd_lock, irqflags);
2021
2022 if (nolds == 0)
2023 nolds = tile_net_lepp_grab_comps(dev, olds, wanted, NULL);
2024
2025 /* Handle completions. */
2026 for (i = 0; i < nolds; i++)
2027 kfree_skb(olds[i]);
2028
2029 /* HACK: Track "expanded" size for short packets (e.g. 42 < 60). */
2030 stats->tx_packets++;
2031 stats->tx_bytes += ((len >= ETH_ZLEN) ? len : ETH_ZLEN);
2032
2033 /* Make sure the egress timer is scheduled. */
2034 tile_net_schedule_egress_timer(info);
2035
2036 return NETDEV_TX_OK;
2037}
2038
2039
2040/*
2041 * Deal with a transmit timeout.
2042 */
2043static void tile_net_tx_timeout(struct net_device *dev)
2044{
2045 PDEBUG("tile_net_tx_timeout()\n");
2046 PDEBUG("Transmit timeout at %ld, latency %ld\n", jiffies,
2047 jiffies - dev->trans_start);
2048
2049 /* XXX: ISSUE: This doesn't seem useful for us. */
2050 netif_wake_queue(dev);
2051}
2052
2053
2054/*
2055 * Ioctl commands.
2056 */
2057static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2058{
2059 return -EOPNOTSUPP;
2060}
2061
2062
2063/*
2064 * Get System Network Statistics.
2065 *
2066 * Returns the address of the device statistics structure.
2067 */
2068static struct net_device_stats *tile_net_get_stats(struct net_device *dev)
2069{
2070 struct tile_net_priv *priv = netdev_priv(dev);
2071 u32 rx_packets = 0;
2072 u32 tx_packets = 0;
2073 u32 rx_bytes = 0;
2074 u32 tx_bytes = 0;
2075 int i;
2076
2077 for_each_online_cpu(i) {
2078 if (priv->cpu[i]) {
2079 rx_packets += priv->cpu[i]->stats.rx_packets;
2080 rx_bytes += priv->cpu[i]->stats.rx_bytes;
2081 tx_packets += priv->cpu[i]->stats.tx_packets;
2082 tx_bytes += priv->cpu[i]->stats.tx_bytes;
2083 }
2084 }
2085
2086 priv->stats.rx_packets = rx_packets;
2087 priv->stats.rx_bytes = rx_bytes;
2088 priv->stats.tx_packets = tx_packets;
2089 priv->stats.tx_bytes = tx_bytes;
2090
2091 return &priv->stats;
2092}
2093
2094
2095/*
2096 * Change the "mtu".
2097 *
2098 * The "change_mtu" method is usually not needed.
2099 * If you need it, it must be like this.
2100 */
2101static int tile_net_change_mtu(struct net_device *dev, int new_mtu)
2102{
2103 PDEBUG("tile_net_change_mtu()\n");
2104
2105 /* Check ranges. */
2106 if ((new_mtu < 68) || (new_mtu > 1500))
2107 return -EINVAL;
2108
2109 /* Accept the value. */
2110 dev->mtu = new_mtu;
2111
2112 return 0;
2113}
2114
2115
2116/*
2117 * Change the Ethernet Address of the NIC.
2118 *
2119 * The hypervisor driver does not support changing MAC address. However,
2120 * the IPP does not do anything with the MAC address, so the address which
2121 * gets used on outgoing packets, and which is accepted on incoming packets,
2122 * is completely up to the NetIO program or kernel driver which is actually
2123 * handling them.
2124 *
2125 * Returns 0 on success, negative on failure.
2126 */
2127static int tile_net_set_mac_address(struct net_device *dev, void *p)
2128{
2129 struct sockaddr *addr = p;
2130
2131 if (!is_valid_ether_addr(addr->sa_data))
2132 return -EINVAL;
2133
2134 /* ISSUE: Note that "dev_addr" is now a pointer. */
2135 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
2136
2137 return 0;
2138}
2139
2140
2141/*
2142 * Obtain the MAC address from the hypervisor.
2143 * This must be done before opening the device.
2144 */
2145static int tile_net_get_mac(struct net_device *dev)
2146{
2147 struct tile_net_priv *priv = netdev_priv(dev);
2148
2149 char hv_dev_name[32];
2150 int len;
2151
2152 __netio_getset_offset_t offset = { .word = NETIO_IPP_PARAM_OFF };
2153
2154 int ret;
2155
2156 /* For example, "xgbe0". */
2157 strcpy(hv_dev_name, dev->name);
2158 len = strlen(hv_dev_name);
2159
2160 /* For example, "xgbe/0". */
2161 hv_dev_name[len] = hv_dev_name[len - 1];
2162 hv_dev_name[len - 1] = '/';
2163 len++;
2164
2165 /* For example, "xgbe/0/native_hash". */
2166 strcpy(hv_dev_name + len, hash_default ? "/native_hash" : "/native");
2167
2168 /* Get the hypervisor handle for this device. */
2169 priv->hv_devhdl = hv_dev_open((HV_VirtAddr)hv_dev_name, 0);
2170 PDEBUG("hv_dev_open(%s) returned %d %p\n",
2171 hv_dev_name, priv->hv_devhdl, &priv->hv_devhdl);
2172 if (priv->hv_devhdl < 0) {
2173 if (priv->hv_devhdl == HV_ENODEV)
2174 printk(KERN_DEBUG "Ignoring unconfigured device %s\n",
2175 hv_dev_name);
2176 else
2177 printk(KERN_DEBUG "hv_dev_open(%s) returned %d\n",
2178 hv_dev_name, priv->hv_devhdl);
2179 return -1;
2180 }
2181
2182 /*
2183 * Read the hardware address from the hypervisor.
2184 * ISSUE: Note that "dev_addr" is now a pointer.
2185 */
2186 offset.bits.class = NETIO_PARAM;
2187 offset.bits.addr = NETIO_PARAM_MAC;
2188 ret = hv_dev_pread(priv->hv_devhdl, 0,
2189 (HV_VirtAddr)dev->dev_addr, dev->addr_len,
2190 offset.word);
2191 PDEBUG("hv_dev_pread(NETIO_PARAM_MAC) returned %d\n", ret);
2192 if (ret <= 0) {
2193 printk(KERN_DEBUG "hv_dev_pread(NETIO_PARAM_MAC) %s failed\n",
2194 dev->name);
2195 /*
2196 * Since the device is configured by the hypervisor but we
2197 * can't get its MAC address, we are most likely running
2198 * the simulator, so let's generate a random MAC address.
2199 */
2200 random_ether_addr(dev->dev_addr);
2201 }
2202
2203 return 0;
2204}
2205
2206
2207static struct net_device_ops tile_net_ops = {
2208 .ndo_open = tile_net_open,
2209 .ndo_stop = tile_net_stop,
2210 .ndo_start_xmit = tile_net_tx,
2211 .ndo_do_ioctl = tile_net_ioctl,
2212 .ndo_get_stats = tile_net_get_stats,
2213 .ndo_change_mtu = tile_net_change_mtu,
2214 .ndo_tx_timeout = tile_net_tx_timeout,
2215 .ndo_set_mac_address = tile_net_set_mac_address
2216};
2217
2218
2219/*
2220 * The setup function.
2221 *
2222 * This uses ether_setup() to assign various fields in dev, including
2223 * setting IFF_BROADCAST and IFF_MULTICAST, then sets some extra fields.
2224 */
2225static void tile_net_setup(struct net_device *dev)
2226{
2227 PDEBUG("tile_net_setup()\n");
2228
2229 ether_setup(dev);
2230
2231 dev->netdev_ops = &tile_net_ops;
2232
2233 dev->watchdog_timeo = TILE_NET_TIMEOUT;
2234
2235 /* We want lockless xmit. */
2236 dev->features |= NETIF_F_LLTX;
2237
2238 /* We support hardware tx checksums. */
2239 dev->features |= NETIF_F_HW_CSUM;
2240
2241 /* We support scatter/gather. */
2242 dev->features |= NETIF_F_SG;
2243
2244 /* We support TSO. */
2245 dev->features |= NETIF_F_TSO;
2246
2247#ifdef TILE_NET_GSO
2248 /* We support GSO. */
2249 dev->features |= NETIF_F_GSO;
2250#endif
2251
2252 if (hash_default)
2253 dev->features |= NETIF_F_HIGHDMA;
2254
2255 /* ISSUE: We should support NETIF_F_UFO. */
2256
2257 dev->tx_queue_len = TILE_NET_TX_QUEUE_LEN;
2258
2259 dev->mtu = TILE_NET_MTU;
2260}
2261
2262
2263/*
2264 * Allocate the device structure, register the device, and obtain the
2265 * MAC address from the hypervisor.
2266 */
2267static struct net_device *tile_net_dev_init(const char *name)
2268{
2269 int ret;
2270 struct net_device *dev;
2271 struct tile_net_priv *priv;
2272 struct page *page;
2273
2274 /*
2275 * Allocate the device structure. This allocates "priv", calls
2276 * tile_net_setup(), and saves "name". Normally, "name" is a
2277 * template, instantiated by register_netdev(), but not for us.
2278 */
2279 dev = alloc_netdev(sizeof(*priv), name, tile_net_setup);
2280 if (!dev) {
2281 pr_err("alloc_netdev(%s) failed\n", name);
2282 return NULL;
2283 }
2284
2285 priv = netdev_priv(dev);
2286
2287 /* Initialize "priv". */
2288
2289 memset(priv, 0, sizeof(*priv));
2290
2291 /* Save "dev" for "tile_net_open_retry()". */
2292 priv->dev = dev;
2293
2294 INIT_DELAYED_WORK(&priv->retry_work, tile_net_open_retry);
2295
2296 spin_lock_init(&priv->cmd_lock);
2297 spin_lock_init(&priv->comp_lock);
2298
2299 /* Allocate "epp_queue". */
2300 BUG_ON(get_order(sizeof(lepp_queue_t)) != 0);
2301 page = alloc_pages(GFP_KERNEL | __GFP_ZERO, 0);
2302 if (!page) {
2303 free_netdev(dev);
2304 return NULL;
2305 }
2306 priv->epp_queue = page_address(page);
2307
2308 /* Register the network device. */
2309 ret = register_netdev(dev);
2310 if (ret) {
2311 pr_err("register_netdev %s failed %d\n", dev->name, ret);
2312 free_page((unsigned long)priv->epp_queue);
2313 free_netdev(dev);
2314 return NULL;
2315 }
2316
2317 /* Get the MAC address. */
2318 ret = tile_net_get_mac(dev);
2319 if (ret < 0) {
2320 unregister_netdev(dev);
2321 free_page((unsigned long)priv->epp_queue);
2322 free_netdev(dev);
2323 return NULL;
2324 }
2325
2326 return dev;
2327}
2328
2329
2330/*
2331 * Module cleanup.
2332 */
2333static void tile_net_cleanup(void)
2334{
2335 int i;
2336
2337 for (i = 0; i < TILE_NET_DEVS; i++) {
2338 if (tile_net_devs[i]) {
2339 struct net_device *dev = tile_net_devs[i];
2340 struct tile_net_priv *priv = netdev_priv(dev);
2341 unregister_netdev(dev);
2342 finv_buffer(priv->epp_queue, PAGE_SIZE);
2343 free_page((unsigned long)priv->epp_queue);
2344 free_netdev(dev);
2345 }
2346 }
2347}
2348
2349
2350/*
2351 * Module initialization.
2352 */
2353static int tile_net_init_module(void)
2354{
2355 pr_info("Tilera IPP Net Driver\n");
2356
2357 tile_net_devs[0] = tile_net_dev_init("xgbe0");
2358 tile_net_devs[1] = tile_net_dev_init("xgbe1");
2359 tile_net_devs[2] = tile_net_dev_init("gbe0");
2360 tile_net_devs[3] = tile_net_dev_init("gbe1");
2361
2362 return 0;
2363}
2364
2365
2366#ifndef MODULE
2367/*
2368 * The "network_cpus" boot argument specifies the cpus that are dedicated
2369 * to handle ingress packets.
2370 *
2371 * The parameter should be in the form "network_cpus=m-n[,x-y]", where
2372 * m, n, x, y are integer numbers that represent the cpus that can be
2373 * neither a dedicated cpu nor a dataplane cpu.
2374 */
2375static int __init network_cpus_setup(char *str)
2376{
2377 int rc = cpulist_parse_crop(str, &network_cpus_map);
2378 if (rc != 0) {
2379 pr_warning("network_cpus=%s: malformed cpu list\n",
2380 str);
2381 } else {
2382
2383 /* Remove dedicated cpus. */
2384 cpumask_and(&network_cpus_map, &network_cpus_map,
2385 cpu_possible_mask);
2386
2387
2388 if (cpumask_empty(&network_cpus_map)) {
2389 pr_warning("Ignoring network_cpus='%s'.\n",
2390 str);
2391 } else {
2392 char buf[1024];
2393 cpulist_scnprintf(buf, sizeof(buf), &network_cpus_map);
2394 pr_info("Linux network CPUs: %s\n", buf);
2395 network_cpus_used = true;
2396 }
2397 }
2398
2399 return 0;
2400}
2401__setup("network_cpus=", network_cpus_setup);
2402#endif
2403
2404
2405module_init(tile_net_init_module);
2406module_exit(tile_net_cleanup);
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index a9f7d5d1a269..7064e035757a 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -688,9 +688,6 @@ static netdev_tx_t dmfe_start_xmit(struct sk_buff *skb,
688 688
689 DMFE_DBUG(0, "dmfe_start_xmit", 0); 689 DMFE_DBUG(0, "dmfe_start_xmit", 0);
690 690
691 /* Resource flag check */
692 netif_stop_queue(dev);
693
694 /* Too large packet check */ 691 /* Too large packet check */
695 if (skb->len > MAX_PACKET_SIZE) { 692 if (skb->len > MAX_PACKET_SIZE) {
696 pr_err("big packet = %d\n", (u16)skb->len); 693 pr_err("big packet = %d\n", (u16)skb->len);
@@ -698,6 +695,9 @@ static netdev_tx_t dmfe_start_xmit(struct sk_buff *skb,
698 return NETDEV_TX_OK; 695 return NETDEV_TX_OK;
699 } 696 }
700 697
698 /* Resource flag check */
699 netif_stop_queue(dev);
700
701 spin_lock_irqsave(&db->lock, flags); 701 spin_lock_irqsave(&db->lock, flags);
702 702
703 /* No Tx resource check, it never happen nromally */ 703 /* No Tx resource check, it never happen nromally */
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index 05a95586f3c5..055b87ab4f07 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -899,7 +899,8 @@ struct ucc_geth_hardware_statistics {
899#define UCC_GETH_UTFS_INIT 512 /* Tx virtual FIFO size 899#define UCC_GETH_UTFS_INIT 512 /* Tx virtual FIFO size
900 */ 900 */
901#define UCC_GETH_UTFET_INIT 256 /* 1/2 utfs */ 901#define UCC_GETH_UTFET_INIT 256 /* 1/2 utfs */
902#define UCC_GETH_UTFTT_INIT 512 902#define UCC_GETH_UTFTT_INIT 256 /* 1/2 utfs
903 due to errata */
903/* Gigabit Ethernet (1000 Mbps) */ 904/* Gigabit Ethernet (1000 Mbps) */
904#define UCC_GETH_URFS_GIGA_INIT 4096/*2048*/ /* Rx virtual 905#define UCC_GETH_URFS_GIGA_INIT 4096/*2048*/ /* Rx virtual
905 FIFO size */ 906 FIFO size */
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index b154a94de03e..812edf85d6d3 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -958,10 +958,6 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt,
958 /* Packet is complete. Inject into stack. */ 958 /* Packet is complete. Inject into stack. */
959 /* We have IP packet here */ 959 /* We have IP packet here */
960 odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); 960 odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP);
961 /* don't check it */
962 odev->skb_rx_buf->ip_summed =
963 CHECKSUM_UNNECESSARY;
964
965 skb_reset_mac_header(odev->skb_rx_buf); 961 skb_reset_mac_header(odev->skb_rx_buf);
966 962
967 /* Ship it off to the kernel */ 963 /* Ship it off to the kernel */
@@ -2994,12 +2990,14 @@ static int hso_probe(struct usb_interface *interface,
2994 2990
2995 case HSO_INTF_BULK: 2991 case HSO_INTF_BULK:
2996 /* It's a regular bulk interface */ 2992 /* It's a regular bulk interface */
2997 if (((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) && 2993 if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) {
2998 !disable_net) 2994 if (!disable_net)
2999 hso_dev = hso_create_net_device(interface, port_spec); 2995 hso_dev =
3000 else 2996 hso_create_net_device(interface, port_spec);
2997 } else {
3001 hso_dev = 2998 hso_dev =
3002 hso_create_bulk_serial_device(interface, port_spec); 2999 hso_create_bulk_serial_device(interface, port_spec);
3000 }
3003 if (!hso_dev) 3001 if (!hso_dev)
3004 goto exit; 3002 goto exit;
3005 break; 3003 break;
diff --git a/drivers/net/wan/hd64572.c b/drivers/net/wan/hd64572.c
index ea476cbd38b5..e305274f83fb 100644
--- a/drivers/net/wan/hd64572.c
+++ b/drivers/net/wan/hd64572.c
@@ -293,6 +293,7 @@ static inline void sca_tx_done(port_t *port)
293 struct net_device *dev = port->netdev; 293 struct net_device *dev = port->netdev;
294 card_t* card = port->card; 294 card_t* card = port->card;
295 u8 stat; 295 u8 stat;
296 unsigned count = 0;
296 297
297 spin_lock(&port->lock); 298 spin_lock(&port->lock);
298 299
@@ -316,10 +317,12 @@ static inline void sca_tx_done(port_t *port)
316 dev->stats.tx_bytes += readw(&desc->len); 317 dev->stats.tx_bytes += readw(&desc->len);
317 } 318 }
318 writeb(0, &desc->stat); /* Free descriptor */ 319 writeb(0, &desc->stat); /* Free descriptor */
320 count++;
319 port->txlast = (port->txlast + 1) % card->tx_ring_buffers; 321 port->txlast = (port->txlast + 1) % card->tx_ring_buffers;
320 } 322 }
321 323
322 netif_wake_queue(dev); 324 if (count)
325 netif_wake_queue(dev);
323 spin_unlock(&port->lock); 326 spin_unlock(&port->lock);
324} 327}
325 328
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index d81ad8397885..24297b274cd4 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -498,7 +498,6 @@ norbuff:
498static int x25_asy_close(struct net_device *dev) 498static int x25_asy_close(struct net_device *dev)
499{ 499{
500 struct x25_asy *sl = netdev_priv(dev); 500 struct x25_asy *sl = netdev_priv(dev);
501 int err;
502 501
503 spin_lock(&sl->lock); 502 spin_lock(&sl->lock);
504 if (sl->tty) 503 if (sl->tty)
@@ -507,10 +506,6 @@ static int x25_asy_close(struct net_device *dev)
507 netif_stop_queue(dev); 506 netif_stop_queue(dev);
508 sl->rcount = 0; 507 sl->rcount = 0;
509 sl->xleft = 0; 508 sl->xleft = 0;
510 err = lapb_unregister(dev);
511 if (err != LAPB_OK)
512 printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n",
513 err);
514 spin_unlock(&sl->lock); 509 spin_unlock(&sl->lock);
515 return 0; 510 return 0;
516} 511}
@@ -582,7 +577,7 @@ static int x25_asy_open_tty(struct tty_struct *tty)
582 if (err) 577 if (err)
583 return err; 578 return err;
584 /* Done. We have linked the TTY line to a channel. */ 579 /* Done. We have linked the TTY line to a channel. */
585 return sl->dev->base_addr; 580 return 0;
586} 581}
587 582
588 583
@@ -595,6 +590,7 @@ static int x25_asy_open_tty(struct tty_struct *tty)
595static void x25_asy_close_tty(struct tty_struct *tty) 590static void x25_asy_close_tty(struct tty_struct *tty)
596{ 591{
597 struct x25_asy *sl = tty->disc_data; 592 struct x25_asy *sl = tty->disc_data;
593 int err;
598 594
599 /* First make sure we're connected. */ 595 /* First make sure we're connected. */
600 if (!sl || sl->magic != X25_ASY_MAGIC) 596 if (!sl || sl->magic != X25_ASY_MAGIC)
@@ -605,6 +601,11 @@ static void x25_asy_close_tty(struct tty_struct *tty)
605 dev_close(sl->dev); 601 dev_close(sl->dev);
606 rtnl_unlock(); 602 rtnl_unlock();
607 603
604 err = lapb_unregister(sl->dev);
605 if (err != LAPB_OK)
606 printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n",
607 err);
608
608 tty->disc_data = NULL; 609 tty->disc_data = NULL;
609 sl->tty = NULL; 610 sl->tty = NULL;
610 x25_asy_free(sl); 611 x25_asy_free(sl);
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 8251946842e6..42ed923cdb1a 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -1917,7 +1917,8 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1917 sc->bmisscount = 0; 1917 sc->bmisscount = 0;
1918 } 1918 }
1919 1919
1920 if (sc->opmode == NL80211_IFTYPE_AP && sc->num_ap_vifs > 1) { 1920 if ((sc->opmode == NL80211_IFTYPE_AP && sc->num_ap_vifs > 1) ||
1921 sc->opmode == NL80211_IFTYPE_MESH_POINT) {
1921 u64 tsf = ath5k_hw_get_tsf64(ah); 1922 u64 tsf = ath5k_hw_get_tsf64(ah);
1922 u32 tsftu = TSF_TO_TU(tsf); 1923 u32 tsftu = TSF_TO_TU(tsf);
1923 int slot = ((tsftu % sc->bintval) * ATH_BCBUF) / sc->bintval; 1924 int slot = ((tsftu % sc->bintval) * ATH_BCBUF) / sc->bintval;
@@ -1949,8 +1950,9 @@ ath5k_beacon_send(struct ath5k_softc *sc)
1949 /* NB: hw still stops DMA, so proceed */ 1950 /* NB: hw still stops DMA, so proceed */
1950 } 1951 }
1951 1952
1952 /* refresh the beacon for AP mode */ 1953 /* refresh the beacon for AP or MESH mode */
1953 if (sc->opmode == NL80211_IFTYPE_AP) 1954 if (sc->opmode == NL80211_IFTYPE_AP ||
1955 sc->opmode == NL80211_IFTYPE_MESH_POINT)
1954 ath5k_beacon_update(sc->hw, vif); 1956 ath5k_beacon_update(sc->hw, vif);
1955 1957
1956 ath5k_hw_set_txdp(ah, sc->bhalq, bf->daddr); 1958 ath5k_hw_set_txdp(ah, sc->bhalq, bf->daddr);
@@ -2851,7 +2853,8 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
2851 2853
2852 /* Assign the vap/adhoc to a beacon xmit slot. */ 2854 /* Assign the vap/adhoc to a beacon xmit slot. */
2853 if ((avf->opmode == NL80211_IFTYPE_AP) || 2855 if ((avf->opmode == NL80211_IFTYPE_AP) ||
2854 (avf->opmode == NL80211_IFTYPE_ADHOC)) { 2856 (avf->opmode == NL80211_IFTYPE_ADHOC) ||
2857 (avf->opmode == NL80211_IFTYPE_MESH_POINT)) {
2855 int slot; 2858 int slot;
2856 2859
2857 WARN_ON(list_empty(&sc->bcbuf)); 2860 WARN_ON(list_empty(&sc->bcbuf));
@@ -2870,7 +2873,7 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
2870 sc->bslot[avf->bslot] = vif; 2873 sc->bslot[avf->bslot] = vif;
2871 if (avf->opmode == NL80211_IFTYPE_AP) 2874 if (avf->opmode == NL80211_IFTYPE_AP)
2872 sc->num_ap_vifs++; 2875 sc->num_ap_vifs++;
2873 else 2876 else if (avf->opmode == NL80211_IFTYPE_ADHOC)
2874 sc->num_adhoc_vifs++; 2877 sc->num_adhoc_vifs++;
2875 } 2878 }
2876 2879
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index c4182359bee4..a7b82f0085d2 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -55,6 +55,8 @@
55#define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */ 55#define SUB_NUM_CTL_MODES_AT_5G_40 2 /* excluding HT40, EXT-OFDM */
56#define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */ 56#define SUB_NUM_CTL_MODES_AT_2G_40 3 /* excluding HT40, EXT-OFDM, EXT-CCK */
57 57
58#define CTL(_tpower, _flag) ((_tpower) | ((_flag) << 6))
59
58static const struct ar9300_eeprom ar9300_default = { 60static const struct ar9300_eeprom ar9300_default = {
59 .eepromVersion = 2, 61 .eepromVersion = 2,
60 .templateVersion = 2, 62 .templateVersion = 2,
@@ -290,20 +292,21 @@ static const struct ar9300_eeprom ar9300_default = {
290 } 292 }
291 }, 293 },
292 .ctlPowerData_2G = { 294 .ctlPowerData_2G = {
293 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 295 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
294 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 296 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
295 { { {60, 1}, {60, 0}, {60, 0}, {60, 1} } }, 297 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
296 298
297 { { {60, 1}, {60, 0}, {0, 0}, {0, 0} } }, 299 { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } },
298 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 300 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
299 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 301 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
300 302
301 { { {60, 0}, {60, 1}, {60, 1}, {60, 0} } }, 303 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
302 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 304 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
303 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 305 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
304 306
305 { { {60, 0}, {60, 1}, {60, 0}, {60, 0} } }, 307 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
306 { { {60, 0}, {60, 1}, {60, 1}, {60, 1} } }, 308 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
309 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
307 }, 310 },
308 .modalHeader5G = { 311 .modalHeader5G = {
309 /* 4 idle,t1,t2,b (4 bits per setting) */ 312 /* 4 idle,t1,t2,b (4 bits per setting) */
@@ -568,56 +571,56 @@ static const struct ar9300_eeprom ar9300_default = {
568 .ctlPowerData_5G = { 571 .ctlPowerData_5G = {
569 { 572 {
570 { 573 {
571 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 574 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
572 {60, 1}, {60, 1}, {60, 1}, {60, 0}, 575 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
573 } 576 }
574 }, 577 },
575 { 578 {
576 { 579 {
577 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 580 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
578 {60, 1}, {60, 1}, {60, 1}, {60, 0}, 581 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
579 } 582 }
580 }, 583 },
581 { 584 {
582 { 585 {
583 {60, 0}, {60, 1}, {60, 0}, {60, 1}, 586 CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
584 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 587 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
585 } 588 }
586 }, 589 },
587 { 590 {
588 { 591 {
589 {60, 0}, {60, 1}, {60, 1}, {60, 0}, 592 CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
590 {60, 1}, {60, 0}, {60, 0}, {60, 0}, 593 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
591 } 594 }
592 }, 595 },
593 { 596 {
594 { 597 {
595 {60, 1}, {60, 1}, {60, 1}, {60, 0}, 598 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
596 {60, 0}, {60, 0}, {60, 0}, {60, 0}, 599 CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
597 } 600 }
598 }, 601 },
599 { 602 {
600 { 603 {
601 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 604 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
602 {60, 1}, {60, 0}, {60, 0}, {60, 0}, 605 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
603 } 606 }
604 }, 607 },
605 { 608 {
606 { 609 {
607 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 610 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
608 {60, 1}, {60, 1}, {60, 1}, {60, 1}, 611 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
609 } 612 }
610 }, 613 },
611 { 614 {
612 { 615 {
613 {60, 1}, {60, 1}, {60, 0}, {60, 1}, 616 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
614 {60, 1}, {60, 1}, {60, 1}, {60, 0}, 617 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
615 } 618 }
616 }, 619 },
617 { 620 {
618 { 621 {
619 {60, 1}, {60, 0}, {60, 1}, {60, 1}, 622 CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
620 {60, 1}, {60, 1}, {60, 0}, {60, 1}, 623 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
621 } 624 }
622 }, 625 },
623 } 626 }
@@ -1827,9 +1830,9 @@ static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep,
1827 struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G; 1830 struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
1828 1831
1829 if (is2GHz) 1832 if (is2GHz)
1830 return ctl_2g[idx].ctlEdges[edge].tPower; 1833 return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge]);
1831 else 1834 else
1832 return ctl_5g[idx].ctlEdges[edge].tPower; 1835 return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge]);
1833} 1836}
1834 1837
1835static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep, 1838static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
@@ -1847,12 +1850,12 @@ static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
1847 1850
1848 if (is2GHz) { 1851 if (is2GHz) {
1849 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq && 1852 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
1850 ctl_2g[idx].ctlEdges[edge - 1].flag) 1853 CTL_EDGE_FLAGS(ctl_2g[idx].ctlEdges[edge - 1]))
1851 return ctl_2g[idx].ctlEdges[edge - 1].tPower; 1854 return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge - 1]);
1852 } else { 1855 } else {
1853 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq && 1856 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
1854 ctl_5g[idx].ctlEdges[edge - 1].flag) 1857 CTL_EDGE_FLAGS(ctl_5g[idx].ctlEdges[edge - 1]))
1855 return ctl_5g[idx].ctlEdges[edge - 1].tPower; 1858 return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]);
1856 } 1859 }
1857 1860
1858 return AR9300_MAX_RATE_POWER; 1861 return AR9300_MAX_RATE_POWER;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
index 3c533bb983c7..655b3033396c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
@@ -261,17 +261,12 @@ struct cal_tgt_pow_ht {
261 u8 tPow2x[14]; 261 u8 tPow2x[14];
262} __packed; 262} __packed;
263 263
264struct cal_ctl_edge_pwr {
265 u8 tPower:6,
266 flag:2;
267} __packed;
268
269struct cal_ctl_data_2g { 264struct cal_ctl_data_2g {
270 struct cal_ctl_edge_pwr ctlEdges[AR9300_NUM_BAND_EDGES_2G]; 265 u8 ctlEdges[AR9300_NUM_BAND_EDGES_2G];
271} __packed; 266} __packed;
272 267
273struct cal_ctl_data_5g { 268struct cal_ctl_data_5g {
274 struct cal_ctl_edge_pwr ctlEdges[AR9300_NUM_BAND_EDGES_5G]; 269 u8 ctlEdges[AR9300_NUM_BAND_EDGES_5G];
275} __packed; 270} __packed;
276 271
277struct ar9300_eeprom { 272struct ar9300_eeprom {
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 170d44a35ccb..0963071e8f90 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -21,6 +21,7 @@
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/leds.h> 22#include <linux/leds.h>
23#include <linux/completion.h> 23#include <linux/completion.h>
24#include <linux/pm_qos_params.h>
24 25
25#include "debug.h" 26#include "debug.h"
26#include "common.h" 27#include "common.h"
@@ -328,7 +329,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp);
328struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype); 329struct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype);
329void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq); 330void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq);
330int ath_tx_setup(struct ath_softc *sc, int haltype); 331int ath_tx_setup(struct ath_softc *sc, int haltype);
331void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx); 332bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx);
332void ath_draintxq(struct ath_softc *sc, 333void ath_draintxq(struct ath_softc *sc,
333 struct ath_txq *txq, bool retry_tx); 334 struct ath_txq *txq, bool retry_tx);
334void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an); 335void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
@@ -646,6 +647,8 @@ struct ath_softc {
646 struct ath_descdma txsdma; 647 struct ath_descdma txsdma;
647 648
648 struct ath_ant_comb ant_comb; 649 struct ath_ant_comb ant_comb;
650
651 struct pm_qos_request_list pm_qos_req;
649}; 652};
650 653
651struct ath_wiphy { 654struct ath_wiphy {
@@ -675,7 +678,6 @@ static inline void ath_read_cachesize(struct ath_common *common, int *csz)
675} 678}
676 679
677extern struct ieee80211_ops ath9k_ops; 680extern struct ieee80211_ops ath9k_ops;
678extern struct pm_qos_request_list ath9k_pm_qos_req;
679extern int modparam_nohwcrypt; 681extern int modparam_nohwcrypt;
680extern int led_blink; 682extern int led_blink;
681 683
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index 1266333f586d..2bbf94d0191e 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -240,16 +240,16 @@ u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower,
240 for (i = 0; (i < num_band_edges) && 240 for (i = 0; (i < num_band_edges) &&
241 (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) { 241 (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
242 if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) { 242 if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) {
243 twiceMaxEdgePower = pRdEdgesPower[i].tPower; 243 twiceMaxEdgePower = CTL_EDGE_TPOWER(pRdEdgesPower[i].ctl);
244 break; 244 break;
245 } else if ((i > 0) && 245 } else if ((i > 0) &&
246 (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, 246 (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel,
247 is2GHz))) { 247 is2GHz))) {
248 if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel, 248 if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel,
249 is2GHz) < freq && 249 is2GHz) < freq &&
250 pRdEdgesPower[i - 1].flag) { 250 CTL_EDGE_FLAGS(pRdEdgesPower[i - 1].ctl)) {
251 twiceMaxEdgePower = 251 twiceMaxEdgePower =
252 pRdEdgesPower[i - 1].tPower; 252 CTL_EDGE_TPOWER(pRdEdgesPower[i - 1].ctl);
253 } 253 }
254 break; 254 break;
255 } 255 }
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
index dacb45e1b906..dd59f09441a3 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
@@ -233,6 +233,18 @@
233 233
234#define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1) 234#define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1)
235 235
236#define CTL_EDGE_TPOWER(_ctl) ((_ctl) & 0x3f)
237#define CTL_EDGE_FLAGS(_ctl) (((_ctl) >> 6) & 0x03)
238
239#define LNA_CTL_BUF_MODE BIT(0)
240#define LNA_CTL_ISEL_LO BIT(1)
241#define LNA_CTL_ISEL_HI BIT(2)
242#define LNA_CTL_BUF_IN BIT(3)
243#define LNA_CTL_FEM_BAND BIT(4)
244#define LNA_CTL_LOCAL_BIAS BIT(5)
245#define LNA_CTL_FORCE_XPA BIT(6)
246#define LNA_CTL_USE_ANT1 BIT(7)
247
236enum eeprom_param { 248enum eeprom_param {
237 EEP_NFTHRESH_5, 249 EEP_NFTHRESH_5,
238 EEP_NFTHRESH_2, 250 EEP_NFTHRESH_2,
@@ -378,10 +390,7 @@ struct modal_eep_header {
378 u8 xatten2Margin[AR5416_MAX_CHAINS]; 390 u8 xatten2Margin[AR5416_MAX_CHAINS];
379 u8 ob_ch1; 391 u8 ob_ch1;
380 u8 db_ch1; 392 u8 db_ch1;
381 u8 useAnt1:1, 393 u8 lna_ctl;
382 force_xpaon:1,
383 local_bias:1,
384 femBandSelectUsed:1, xlnabufin:1, xlnaisel:2, xlnabufmode:1;
385 u8 miscBits; 394 u8 miscBits;
386 u16 xpaBiasLvlFreq[3]; 395 u16 xpaBiasLvlFreq[3];
387 u8 futureModal[6]; 396 u8 futureModal[6];
@@ -535,18 +544,10 @@ struct cal_target_power_ht {
535 u8 tPow2x[8]; 544 u8 tPow2x[8];
536} __packed; 545} __packed;
537 546
538
539#ifdef __BIG_ENDIAN_BITFIELD
540struct cal_ctl_edges {
541 u8 bChannel;
542 u8 flag:2, tPower:6;
543} __packed;
544#else
545struct cal_ctl_edges { 547struct cal_ctl_edges {
546 u8 bChannel; 548 u8 bChannel;
547 u8 tPower:6, flag:2; 549 u8 ctl;
548} __packed; 550} __packed;
549#endif
550 551
551struct cal_data_op_loop_ar9287 { 552struct cal_data_op_loop_ar9287 {
552 u8 pwrPdg[2][5]; 553 u8 pwrPdg[2][5];
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index 966b9496a9dd..195406db3bd8 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -37,7 +37,7 @@ static bool ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)
37 int addr, eep_start_loc; 37 int addr, eep_start_loc;
38 eep_data = (u16 *)eep; 38 eep_data = (u16 *)eep;
39 39
40 if (ah->hw_version.devid == 0x7015) 40 if (AR9287_HTC_DEVID(ah))
41 eep_start_loc = AR9287_HTC_EEP_START_LOC; 41 eep_start_loc = AR9287_HTC_EEP_START_LOC;
42 else 42 else
43 eep_start_loc = AR9287_EEP_START_LOC; 43 eep_start_loc = AR9287_EEP_START_LOC;
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c
index 76b4d65472dd..a3ccb1b9638d 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
@@ -451,9 +451,10 @@ static void ath9k_hw_def_set_board_values(struct ath_hw *ah,
451 ath9k_hw_analog_shift_rmw(ah, AR_AN_TOP2, 451 ath9k_hw_analog_shift_rmw(ah, AR_AN_TOP2,
452 AR_AN_TOP2_LOCALBIAS, 452 AR_AN_TOP2_LOCALBIAS,
453 AR_AN_TOP2_LOCALBIAS_S, 453 AR_AN_TOP2_LOCALBIAS_S,
454 pModal->local_bias); 454 !!(pModal->lna_ctl &
455 LNA_CTL_LOCAL_BIAS));
455 REG_RMW_FIELD(ah, AR_PHY_XPA_CFG, AR_PHY_FORCE_XPA_CFG, 456 REG_RMW_FIELD(ah, AR_PHY_XPA_CFG, AR_PHY_FORCE_XPA_CFG,
456 pModal->force_xpaon); 457 !!(pModal->lna_ctl & LNA_CTL_FORCE_XPA));
457 } 458 }
458 459
459 REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH, 460 REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH,
@@ -1062,15 +1063,19 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
1062 case 1: 1063 case 1:
1063 break; 1064 break;
1064 case 2: 1065 case 2:
1065 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; 1066 if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
1067 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
1068 else
1069 scaledPower = 0;
1066 break; 1070 break;
1067 case 3: 1071 case 3:
1068 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; 1072 if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
1073 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
1074 else
1075 scaledPower = 0;
1069 break; 1076 break;
1070 } 1077 }
1071 1078
1072 scaledPower = max((u16)0, scaledPower);
1073
1074 if (IS_CHAN_2GHZ(chan)) { 1079 if (IS_CHAN_2GHZ(chan)) {
1075 numCtlModes = ARRAY_SIZE(ctlModesFor11g) - 1080 numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
1076 SUB_NUM_CTL_MODES_AT_2G_40; 1081 SUB_NUM_CTL_MODES_AT_2G_40;
@@ -1428,9 +1433,9 @@ static u8 ath9k_hw_def_get_num_ant_config(struct ath_hw *ah,
1428 1433
1429 num_ant_config = 1; 1434 num_ant_config = 1;
1430 1435
1431 if (pBase->version >= 0x0E0D) 1436 if (pBase->version >= 0x0E0D &&
1432 if (pModal->useAnt1) 1437 (pModal->lna_ctl & LNA_CTL_USE_ANT1))
1433 num_ant_config += 1; 1438 num_ant_config += 1;
1434 1439
1435 return num_ant_config; 1440 return num_ant_config;
1436} 1441}
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index f7ec31b4ddd3..0de3c3d3c245 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -36,8 +36,13 @@ static struct usb_device_id ath9k_hif_usb_ids[] = {
36 { USB_DEVICE(0x13D3, 0x3327) }, /* Azurewave */ 36 { USB_DEVICE(0x13D3, 0x3327) }, /* Azurewave */
37 { USB_DEVICE(0x13D3, 0x3328) }, /* Azurewave */ 37 { USB_DEVICE(0x13D3, 0x3328) }, /* Azurewave */
38 { USB_DEVICE(0x13D3, 0x3346) }, /* IMC Networks */ 38 { USB_DEVICE(0x13D3, 0x3346) }, /* IMC Networks */
39 { USB_DEVICE(0x13D3, 0x3348) }, /* Azurewave */
40 { USB_DEVICE(0x13D3, 0x3349) }, /* Azurewave */
41 { USB_DEVICE(0x13D3, 0x3350) }, /* Azurewave */
39 { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */ 42 { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */
40 { USB_DEVICE(0x083A, 0xA704) }, /* SMC Networks */ 43 { USB_DEVICE(0x083A, 0xA704) }, /* SMC Networks */
44 { USB_DEVICE(0x040D, 0x3801) }, /* VIA */
45 { USB_DEVICE(0x1668, 0x1200) }, /* Verizon */
41 { }, 46 { },
42}; 47};
43 48
@@ -806,6 +811,8 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
806 case 0x7010: 811 case 0x7010:
807 case 0x7015: 812 case 0x7015:
808 case 0x9018: 813 case 0x9018:
814 case 0xA704:
815 case 0x1200:
809 firm_offset = AR7010_FIRMWARE_TEXT; 816 firm_offset = AR7010_FIRMWARE_TEXT;
810 break; 817 break;
811 default: 818 default:
@@ -928,6 +935,8 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
928 case 0x7010: 935 case 0x7010:
929 case 0x7015: 936 case 0x7015:
930 case 0x9018: 937 case 0x9018:
938 case 0xA704:
939 case 0x1200:
931 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x0202) 940 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x0202)
932 hif_dev->fw_name = FIRMWARE_AR7010_1_1; 941 hif_dev->fw_name = FIRMWARE_AR7010_1_1;
933 else 942 else
@@ -1015,6 +1024,13 @@ static int ath9k_hif_usb_suspend(struct usb_interface *interface,
1015 struct hif_device_usb *hif_dev = 1024 struct hif_device_usb *hif_dev =
1016 (struct hif_device_usb *) usb_get_intfdata(interface); 1025 (struct hif_device_usb *) usb_get_intfdata(interface);
1017 1026
1027 /*
1028 * The device has to be set to FULLSLEEP mode in case no
1029 * interface is up.
1030 */
1031 if (!(hif_dev->flags & HIF_USB_START))
1032 ath9k_htc_suspend(hif_dev->htc_handle);
1033
1018 ath9k_hif_usb_dealloc_urbs(hif_dev); 1034 ath9k_hif_usb_dealloc_urbs(hif_dev);
1019 1035
1020 return 0; 1036 return 0;
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 75ecf6a30d25..c3b561daa6c1 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -455,6 +455,8 @@ u32 ath9k_htc_calcrxfilter(struct ath9k_htc_priv *priv);
455void ath9k_htc_ps_wakeup(struct ath9k_htc_priv *priv); 455void ath9k_htc_ps_wakeup(struct ath9k_htc_priv *priv);
456void ath9k_htc_ps_restore(struct ath9k_htc_priv *priv); 456void ath9k_htc_ps_restore(struct ath9k_htc_priv *priv);
457void ath9k_ps_work(struct work_struct *work); 457void ath9k_ps_work(struct work_struct *work);
458bool ath9k_htc_setpower(struct ath9k_htc_priv *priv,
459 enum ath9k_power_mode mode);
458 460
459void ath9k_start_rfkill_poll(struct ath9k_htc_priv *priv); 461void ath9k_start_rfkill_poll(struct ath9k_htc_priv *priv);
460void ath9k_init_leds(struct ath9k_htc_priv *priv); 462void ath9k_init_leds(struct ath9k_htc_priv *priv);
@@ -464,6 +466,7 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev,
464 u16 devid, char *product); 466 u16 devid, char *product);
465void ath9k_htc_disconnect_device(struct htc_target *htc_handle, bool hotunplug); 467void ath9k_htc_disconnect_device(struct htc_target *htc_handle, bool hotunplug);
466#ifdef CONFIG_PM 468#ifdef CONFIG_PM
469void ath9k_htc_suspend(struct htc_target *htc_handle);
467int ath9k_htc_resume(struct htc_target *htc_handle); 470int ath9k_htc_resume(struct htc_target *htc_handle);
468#endif 471#endif
469#ifdef CONFIG_ATH9K_HTC_DEBUGFS 472#ifdef CONFIG_ATH9K_HTC_DEBUGFS
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 3d7b97f1b3ae..8776f49ffd41 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -249,6 +249,8 @@ static int ath9k_init_htc_services(struct ath9k_htc_priv *priv, u16 devid)
249 case 0x7010: 249 case 0x7010:
250 case 0x7015: 250 case 0x7015:
251 case 0x9018: 251 case 0x9018:
252 case 0xA704:
253 case 0x1200:
252 priv->htc->credits = 45; 254 priv->htc->credits = 45;
253 break; 255 break;
254 default: 256 default:
@@ -889,6 +891,12 @@ void ath9k_htc_disconnect_device(struct htc_target *htc_handle, bool hotunplug)
889} 891}
890 892
891#ifdef CONFIG_PM 893#ifdef CONFIG_PM
894
895void ath9k_htc_suspend(struct htc_target *htc_handle)
896{
897 ath9k_htc_setpower(htc_handle->drv_priv, ATH9K_PM_FULL_SLEEP);
898}
899
892int ath9k_htc_resume(struct htc_target *htc_handle) 900int ath9k_htc_resume(struct htc_target *htc_handle)
893{ 901{
894 int ret; 902 int ret;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 9a3be8da755d..51977caca47f 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -63,8 +63,8 @@ static enum htc_phymode ath9k_htc_get_curmode(struct ath9k_htc_priv *priv,
63 return mode; 63 return mode;
64} 64}
65 65
66static bool ath9k_htc_setpower(struct ath9k_htc_priv *priv, 66bool ath9k_htc_setpower(struct ath9k_htc_priv *priv,
67 enum ath9k_power_mode mode) 67 enum ath9k_power_mode mode)
68{ 68{
69 bool ret; 69 bool ret;
70 70
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index 3d19b5bc937f..29d80ca78393 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -121,7 +121,7 @@ int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb)
121 tx_hdr.data_type = ATH9K_HTC_NORMAL; 121 tx_hdr.data_type = ATH9K_HTC_NORMAL;
122 } 122 }
123 123
124 if (ieee80211_is_data(fc)) { 124 if (ieee80211_is_data_qos(fc)) {
125 qc = ieee80211_get_qos_ctl(hdr); 125 qc = ieee80211_get_qos_ctl(hdr);
126 tx_hdr.tidno = qc[0] & IEEE80211_QOS_CTL_TID_MASK; 126 tx_hdr.tidno = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
127 } 127 }
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 6ebc68bca91f..c7fbe25cc128 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2044,7 +2044,8 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio)
2044 val = REG_READ(ah, AR7010_GPIO_IN); 2044 val = REG_READ(ah, AR7010_GPIO_IN);
2045 return (MS(val, AR7010_GPIO_IN_VAL) & AR_GPIO_BIT(gpio)) == 0; 2045 return (MS(val, AR7010_GPIO_IN_VAL) & AR_GPIO_BIT(gpio)) == 0;
2046 } else if (AR_SREV_9300_20_OR_LATER(ah)) 2046 } else if (AR_SREV_9300_20_OR_LATER(ah))
2047 return MS_REG_READ(AR9300, gpio) != 0; 2047 return (MS(REG_READ(ah, AR_GPIO_IN), AR9300_GPIO_IN_VAL) &
2048 AR_GPIO_BIT(gpio)) != 0;
2048 else if (AR_SREV_9271(ah)) 2049 else if (AR_SREV_9271(ah))
2049 return MS_REG_READ(AR9271, gpio) != 0; 2050 return MS_REG_READ(AR9271, gpio) != 0;
2050 else if (AR_SREV_9287_11_OR_LATER(ah)) 2051 else if (AR_SREV_9287_11_OR_LATER(ah))
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 6a0d99eff404..14b8ab386daf 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -15,7 +15,6 @@
15 */ 15 */
16 16
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/pm_qos_params.h>
19 18
20#include "ath9k.h" 19#include "ath9k.h"
21 20
@@ -180,8 +179,6 @@ static const struct ath_ops ath9k_common_ops = {
180 .write = ath9k_iowrite32, 179 .write = ath9k_iowrite32,
181}; 180};
182 181
183struct pm_qos_request_list ath9k_pm_qos_req;
184
185/**************************/ 182/**************************/
186/* Initialization */ 183/* Initialization */
187/**************************/ 184/**************************/
@@ -664,6 +661,8 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
664 hw->flags |= IEEE80211_HW_MFP_CAPABLE; 661 hw->flags |= IEEE80211_HW_MFP_CAPABLE;
665 662
666 hw->wiphy->interface_modes = 663 hw->wiphy->interface_modes =
664 BIT(NL80211_IFTYPE_P2P_GO) |
665 BIT(NL80211_IFTYPE_P2P_CLIENT) |
667 BIT(NL80211_IFTYPE_AP) | 666 BIT(NL80211_IFTYPE_AP) |
668 BIT(NL80211_IFTYPE_WDS) | 667 BIT(NL80211_IFTYPE_WDS) |
669 BIT(NL80211_IFTYPE_STATION) | 668 BIT(NL80211_IFTYPE_STATION) |
@@ -759,7 +758,7 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc, u16 subsysid,
759 ath_init_leds(sc); 758 ath_init_leds(sc);
760 ath_start_rfkill_poll(sc); 759 ath_start_rfkill_poll(sc);
761 760
762 pm_qos_add_request(&ath9k_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, 761 pm_qos_add_request(&sc->pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
763 PM_QOS_DEFAULT_VALUE); 762 PM_QOS_DEFAULT_VALUE);
764 763
765 return 0; 764 return 0;
@@ -817,8 +816,6 @@ void ath9k_deinit_device(struct ath_softc *sc)
817 816
818 ath9k_ps_wakeup(sc); 817 ath9k_ps_wakeup(sc);
819 818
820 pm_qos_remove_request(&ath9k_pm_qos_req);
821
822 wiphy_rfkill_stop_polling(sc->hw->wiphy); 819 wiphy_rfkill_stop_polling(sc->hw->wiphy);
823 ath_deinit_leds(sc); 820 ath_deinit_leds(sc);
824 821
@@ -832,6 +829,7 @@ void ath9k_deinit_device(struct ath_softc *sc)
832 } 829 }
833 830
834 ieee80211_unregister_hw(hw); 831 ieee80211_unregister_hw(hw);
832 pm_qos_remove_request(&sc->pm_qos_req);
835 ath_rx_cleanup(sc); 833 ath_rx_cleanup(sc);
836 ath_tx_cleanup(sc); 834 ath_tx_cleanup(sc);
837 ath9k_deinit_softc(sc); 835 ath9k_deinit_softc(sc);
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index 8c13479b17cd..c996963ab339 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -703,8 +703,7 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
703 rs->rs_phyerr = phyerr; 703 rs->rs_phyerr = phyerr;
704 } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr) 704 } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
705 rs->rs_status |= ATH9K_RXERR_DECRYPT; 705 rs->rs_status |= ATH9K_RXERR_DECRYPT;
706 else if ((ads.ds_rxstatus8 & AR_MichaelErr) && 706 else if (ads.ds_rxstatus8 & AR_MichaelErr)
707 rs->rs_keyix != ATH9K_RXKEYIX_INVALID)
708 rs->rs_status |= ATH9K_RXERR_MIC; 707 rs->rs_status |= ATH9K_RXERR_MIC;
709 else if (ads.ds_rxstatus8 & AR_KeyMiss) 708 else if (ads.ds_rxstatus8 & AR_KeyMiss)
710 rs->rs_status |= ATH9K_RXERR_DECRYPT; 709 rs->rs_status |= ATH9K_RXERR_DECRYPT;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 25d3ef4c338e..c0c3464d3a86 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -15,7 +15,6 @@
15 */ 15 */
16 16
17#include <linux/nl80211.h> 17#include <linux/nl80211.h>
18#include <linux/pm_qos_params.h>
19#include "ath9k.h" 18#include "ath9k.h"
20#include "btcoex.h" 19#include "btcoex.h"
21 20
@@ -245,11 +244,12 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
245 * the relevant bits of the h/w. 244 * the relevant bits of the h/w.
246 */ 245 */
247 ath9k_hw_set_interrupts(ah, 0); 246 ath9k_hw_set_interrupts(ah, 0);
248 ath_drain_all_txq(sc, false); 247 stopped = ath_drain_all_txq(sc, false);
249 248
250 spin_lock_bh(&sc->rx.pcu_lock); 249 spin_lock_bh(&sc->rx.pcu_lock);
251 250
252 stopped = ath_stoprecv(sc); 251 if (!ath_stoprecv(sc))
252 stopped = false;
253 253
254 /* XXX: do not flush receive queue here. We don't want 254 /* XXX: do not flush receive queue here. We don't want
255 * to flush data frames already in queue because of 255 * to flush data frames already in queue because of
@@ -1244,7 +1244,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
1244 ath9k_btcoex_timer_resume(sc); 1244 ath9k_btcoex_timer_resume(sc);
1245 } 1245 }
1246 1246
1247 pm_qos_update_request(&ath9k_pm_qos_req, 55); 1247 pm_qos_update_request(&sc->pm_qos_req, 55);
1248 1248
1249mutex_unlock: 1249mutex_unlock:
1250 mutex_unlock(&sc->mutex); 1250 mutex_unlock(&sc->mutex);
@@ -1423,7 +1423,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
1423 1423
1424 sc->sc_flags |= SC_OP_INVALID; 1424 sc->sc_flags |= SC_OP_INVALID;
1425 1425
1426 pm_qos_update_request(&ath9k_pm_qos_req, PM_QOS_DEFAULT_VALUE); 1426 pm_qos_update_request(&sc->pm_qos_req, PM_QOS_DEFAULT_VALUE);
1427 1427
1428 mutex_unlock(&sc->mutex); 1428 mutex_unlock(&sc->mutex);
1429 1429
@@ -1520,7 +1520,6 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1520 struct ath_softc *sc = aphy->sc; 1520 struct ath_softc *sc = aphy->sc;
1521 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1521 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1522 struct ath_vif *avp = (void *)vif->drv_priv; 1522 struct ath_vif *avp = (void *)vif->drv_priv;
1523 int i;
1524 1523
1525 ath_print(common, ATH_DBG_CONFIG, "Detach Interface\n"); 1524 ath_print(common, ATH_DBG_CONFIG, "Detach Interface\n");
1526 1525
@@ -1534,21 +1533,24 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1534 if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) || 1533 if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
1535 (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) || 1534 (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) ||
1536 (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) { 1535 (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) {
1536 /* Disable SWBA interrupt */
1537 sc->sc_ah->imask &= ~ATH9K_INT_SWBA;
1537 ath9k_ps_wakeup(sc); 1538 ath9k_ps_wakeup(sc);
1539 ath9k_hw_set_interrupts(sc->sc_ah, sc->sc_ah->imask);
1538 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); 1540 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
1539 ath9k_ps_restore(sc); 1541 ath9k_ps_restore(sc);
1542 tasklet_kill(&sc->bcon_tasklet);
1540 } 1543 }
1541 1544
1542 ath_beacon_return(sc, avp); 1545 ath_beacon_return(sc, avp);
1543 sc->sc_flags &= ~SC_OP_BEACONS; 1546 sc->sc_flags &= ~SC_OP_BEACONS;
1544 1547
1545 for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) { 1548 if (sc->nbcnvifs) {
1546 if (sc->beacon.bslot[i] == vif) { 1549 /* Re-enable SWBA interrupt */
1547 printk(KERN_DEBUG "%s: vif had allocated beacon " 1550 sc->sc_ah->imask |= ATH9K_INT_SWBA;
1548 "slot\n", __func__); 1551 ath9k_ps_wakeup(sc);
1549 sc->beacon.bslot[i] = NULL; 1552 ath9k_hw_set_interrupts(sc->sc_ah, sc->sc_ah->imask);
1550 sc->beacon.bslot_aphy[i] = NULL; 1553 ath9k_ps_restore(sc);
1551 }
1552 } 1554 }
1553 1555
1554 sc->nvifs--; 1556 sc->nvifs--;
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index c76ea53c20ce..fdc2ec52b42f 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -518,7 +518,7 @@ bool ath_stoprecv(struct ath_softc *sc)
518 bool stopped; 518 bool stopped;
519 519
520 spin_lock_bh(&sc->rx.rxbuflock); 520 spin_lock_bh(&sc->rx.rxbuflock);
521 ath9k_hw_stoppcurecv(ah); 521 ath9k_hw_abortpcurecv(ah);
522 ath9k_hw_setrxfilter(ah, 0); 522 ath9k_hw_setrxfilter(ah, 0);
523 stopped = ath9k_hw_stopdmarecv(ah); 523 stopped = ath9k_hw_stopdmarecv(ah);
524 524
@@ -838,6 +838,10 @@ static bool ath9k_rx_accept(struct ath_common *common,
838 struct ath_rx_status *rx_stats, 838 struct ath_rx_status *rx_stats,
839 bool *decrypt_error) 839 bool *decrypt_error)
840{ 840{
841#define is_mc_or_valid_tkip_keyix ((is_mc || \
842 (rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID && \
843 test_bit(rx_stats->rs_keyix, common->tkip_keymap))))
844
841 struct ath_hw *ah = common->ah; 845 struct ath_hw *ah = common->ah;
842 __le16 fc; 846 __le16 fc;
843 u8 rx_status_len = ah->caps.rx_status_len; 847 u8 rx_status_len = ah->caps.rx_status_len;
@@ -879,15 +883,18 @@ static bool ath9k_rx_accept(struct ath_common *common,
879 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) { 883 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
880 *decrypt_error = true; 884 *decrypt_error = true;
881 } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) { 885 } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
886 bool is_mc;
882 /* 887 /*
883 * The MIC error bit is only valid if the frame 888 * The MIC error bit is only valid if the frame
884 * is not a control frame or fragment, and it was 889 * is not a control frame or fragment, and it was
885 * decrypted using a valid TKIP key. 890 * decrypted using a valid TKIP key.
886 */ 891 */
892 is_mc = !!is_multicast_ether_addr(hdr->addr1);
893
887 if (!ieee80211_is_ctl(fc) && 894 if (!ieee80211_is_ctl(fc) &&
888 !ieee80211_has_morefrags(fc) && 895 !ieee80211_has_morefrags(fc) &&
889 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) && 896 !(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
890 test_bit(rx_stats->rs_keyix, common->tkip_keymap)) 897 is_mc_or_valid_tkip_keyix)
891 rxs->flag |= RX_FLAG_MMIC_ERROR; 898 rxs->flag |= RX_FLAG_MMIC_ERROR;
892 else 899 else
893 rx_stats->rs_status &= ~ATH9K_RXERR_MIC; 900 rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index fa05b711e5cd..2c6a22fbb0f0 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -866,7 +866,13 @@
866#define AR_DEVID_7010(_ah) \ 866#define AR_DEVID_7010(_ah) \
867 (((_ah)->hw_version.devid == 0x7010) || \ 867 (((_ah)->hw_version.devid == 0x7010) || \
868 ((_ah)->hw_version.devid == 0x7015) || \ 868 ((_ah)->hw_version.devid == 0x7015) || \
869 ((_ah)->hw_version.devid == 0x9018)) 869 ((_ah)->hw_version.devid == 0x9018) || \
870 ((_ah)->hw_version.devid == 0xA704) || \
871 ((_ah)->hw_version.devid == 0x1200))
872
873#define AR9287_HTC_DEVID(_ah) \
874 (((_ah)->hw_version.devid == 0x7015) || \
875 ((_ah)->hw_version.devid == 0x1200))
870 876
871#define AR_RADIO_SREV_MAJOR 0xf0 877#define AR_RADIO_SREV_MAJOR 0xf0
872#define AR_RAD5133_SREV_MAJOR 0xc0 878#define AR_RAD5133_SREV_MAJOR 0xc0
@@ -978,11 +984,13 @@ enum {
978#define AR9287_GPIO_IN_VAL_S 11 984#define AR9287_GPIO_IN_VAL_S 11
979#define AR9271_GPIO_IN_VAL 0xFFFF0000 985#define AR9271_GPIO_IN_VAL 0xFFFF0000
980#define AR9271_GPIO_IN_VAL_S 16 986#define AR9271_GPIO_IN_VAL_S 16
981#define AR9300_GPIO_IN_VAL 0x0001FFFF
982#define AR9300_GPIO_IN_VAL_S 0
983#define AR7010_GPIO_IN_VAL 0x0000FFFF 987#define AR7010_GPIO_IN_VAL 0x0000FFFF
984#define AR7010_GPIO_IN_VAL_S 0 988#define AR7010_GPIO_IN_VAL_S 0
985 989
990#define AR_GPIO_IN 0x404c
991#define AR9300_GPIO_IN_VAL 0x0001FFFF
992#define AR9300_GPIO_IN_VAL_S 0
993
986#define AR_GPIO_OE_OUT (AR_SREV_9300_20_OR_LATER(ah) ? 0x4050 : 0x404c) 994#define AR_GPIO_OE_OUT (AR_SREV_9300_20_OR_LATER(ah) ? 0x4050 : 0x404c)
987#define AR_GPIO_OE_OUT_DRV 0x3 995#define AR_GPIO_OE_OUT_DRV 0x3
988#define AR_GPIO_OE_OUT_DRV_NO 0x0 996#define AR_GPIO_OE_OUT_DRV_NO 0x0
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index f2ade2402ce2..aff04789f794 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1120,7 +1120,7 @@ void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
1120 } 1120 }
1121} 1121}
1122 1122
1123void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx) 1123bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
1124{ 1124{
1125 struct ath_hw *ah = sc->sc_ah; 1125 struct ath_hw *ah = sc->sc_ah;
1126 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1126 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -1128,7 +1128,7 @@ void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
1128 int i, npend = 0; 1128 int i, npend = 0;
1129 1129
1130 if (sc->sc_flags & SC_OP_INVALID) 1130 if (sc->sc_flags & SC_OP_INVALID)
1131 return; 1131 return true;
1132 1132
1133 /* Stop beacon queue */ 1133 /* Stop beacon queue */
1134 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); 1134 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
@@ -1142,25 +1142,15 @@ void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
1142 } 1142 }
1143 } 1143 }
1144 1144
1145 if (npend) { 1145 if (npend)
1146 int r; 1146 ath_print(common, ATH_DBG_FATAL, "Failed to stop TX DMA!\n");
1147
1148 ath_print(common, ATH_DBG_FATAL,
1149 "Failed to stop TX DMA. Resetting hardware!\n");
1150
1151 spin_lock_bh(&sc->sc_resetlock);
1152 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
1153 if (r)
1154 ath_print(common, ATH_DBG_FATAL,
1155 "Unable to reset hardware; reset status %d\n",
1156 r);
1157 spin_unlock_bh(&sc->sc_resetlock);
1158 }
1159 1147
1160 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { 1148 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1161 if (ATH_TXQ_SETUP(sc, i)) 1149 if (ATH_TXQ_SETUP(sc, i))
1162 ath_draintxq(sc, &sc->tx.txq[i], retry_tx); 1150 ath_draintxq(sc, &sc->tx.txq[i], retry_tx);
1163 } 1151 }
1152
1153 return !npend;
1164} 1154}
1165 1155
1166void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq) 1156void ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq)
diff --git a/drivers/net/wireless/ath/carl9170/fw.c b/drivers/net/wireless/ath/carl9170/fw.c
index ae6c006bbc56..546b4e4ec5ea 100644
--- a/drivers/net/wireless/ath/carl9170/fw.c
+++ b/drivers/net/wireless/ath/carl9170/fw.c
@@ -291,7 +291,8 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len)
291 291
292 if (SUPP(CARL9170FW_WLANTX_CAB)) { 292 if (SUPP(CARL9170FW_WLANTX_CAB)) {
293 ar->hw->wiphy->interface_modes |= 293 ar->hw->wiphy->interface_modes |=
294 BIT(NL80211_IFTYPE_AP); 294 BIT(NL80211_IFTYPE_AP) |
295 BIT(NL80211_IFTYPE_P2P_GO);
295 } 296 }
296 } 297 }
297 298
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index 980ae70ea424..dc7b30b170d0 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -647,7 +647,7 @@ init:
647 } 647 }
648 648
649unlock: 649unlock:
650 if (err && (vif_id != -1)) { 650 if (err && (vif_id >= 0)) {
651 vif_priv->active = false; 651 vif_priv->active = false;
652 bitmap_release_region(&ar->vif_bitmap, vif_id, 0); 652 bitmap_release_region(&ar->vif_bitmap, vif_id, 0);
653 ar->vifs--; 653 ar->vifs--;
@@ -1631,7 +1631,8 @@ void *carl9170_alloc(size_t priv_size)
1631 * supports these modes. The code which will add the 1631 * supports these modes. The code which will add the
1632 * additional interface_modes is in fw.c. 1632 * additional interface_modes is in fw.c.
1633 */ 1633 */
1634 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 1634 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
1635 BIT(NL80211_IFTYPE_P2P_CLIENT);
1635 1636
1636 hw->flags |= IEEE80211_HW_RX_INCLUDES_FCS | 1637 hw->flags |= IEEE80211_HW_RX_INCLUDES_FCS |
1637 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 1638 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c
index b575c865142d..7e6506a77bbb 100644
--- a/drivers/net/wireless/ath/carl9170/tx.c
+++ b/drivers/net/wireless/ath/carl9170/tx.c
@@ -810,7 +810,7 @@ static int carl9170_tx_prepare(struct ar9170 *ar, struct sk_buff *skb)
810 810
811 mac_tmp = cpu_to_le16(AR9170_TX_MAC_HW_DURATION | 811 mac_tmp = cpu_to_le16(AR9170_TX_MAC_HW_DURATION |
812 AR9170_TX_MAC_BACKOFF); 812 AR9170_TX_MAC_BACKOFF);
813 mac_tmp |= cpu_to_le16((hw_queue << AR9170_TX_MAC_QOS_S) && 813 mac_tmp |= cpu_to_le16((hw_queue << AR9170_TX_MAC_QOS_S) &
814 AR9170_TX_MAC_QOS); 814 AR9170_TX_MAC_QOS);
815 815
816 no_ack = !!(info->flags & IEEE80211_TX_CTL_NO_ACK); 816 no_ack = !!(info->flags & IEEE80211_TX_CTL_NO_ACK);
diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c
index 3317039cd28f..7504ed14c725 100644
--- a/drivers/net/wireless/ath/carl9170/usb.c
+++ b/drivers/net/wireless/ath/carl9170/usb.c
@@ -553,12 +553,12 @@ static int carl9170_usb_flush(struct ar9170 *ar)
553 usb_free_urb(urb); 553 usb_free_urb(urb);
554 } 554 }
555 555
556 ret = usb_wait_anchor_empty_timeout(&ar->tx_cmd, HZ); 556 ret = usb_wait_anchor_empty_timeout(&ar->tx_cmd, 1000);
557 if (ret == 0) 557 if (ret == 0)
558 err = -ETIMEDOUT; 558 err = -ETIMEDOUT;
559 559
560 /* lets wait a while until the tx - queues are dried out */ 560 /* lets wait a while until the tx - queues are dried out */
561 ret = usb_wait_anchor_empty_timeout(&ar->tx_anch, HZ); 561 ret = usb_wait_anchor_empty_timeout(&ar->tx_anch, 1000);
562 if (ret == 0) 562 if (ret == 0)
563 err = -ETIMEDOUT; 563 err = -ETIMEDOUT;
564 564
diff --git a/drivers/net/wireless/b43/sdio.c b/drivers/net/wireless/b43/sdio.c
index 9a55338d957f..09e2dfd7b175 100644
--- a/drivers/net/wireless/b43/sdio.c
+++ b/drivers/net/wireless/b43/sdio.c
@@ -163,6 +163,7 @@ static int b43_sdio_probe(struct sdio_func *func,
163err_free_ssb: 163err_free_ssb:
164 kfree(sdio); 164 kfree(sdio);
165err_disable_func: 165err_disable_func:
166 sdio_claim_host(func);
166 sdio_disable_func(func); 167 sdio_disable_func(func);
167err_release_host: 168err_release_host:
168 sdio_release_host(func); 169 sdio_release_host(func);
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index e5685dc317a8..b4de0ca10feb 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -1170,7 +1170,6 @@ static void if_sdio_remove(struct sdio_func *func)
1170 lbs_deb_sdio("call remove card\n"); 1170 lbs_deb_sdio("call remove card\n");
1171 lbs_stop_card(card->priv); 1171 lbs_stop_card(card->priv);
1172 lbs_remove_card(card->priv); 1172 lbs_remove_card(card->priv);
1173 card->priv->surpriseremoved = 1;
1174 1173
1175 flush_workqueue(card->workqueue); 1174 flush_workqueue(card->workqueue);
1176 destroy_workqueue(card->workqueue); 1175 destroy_workqueue(card->workqueue);
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
index 79bcb4e5d2ca..ecd4d04b2c3c 100644
--- a/drivers/net/wireless/libertas/if_spi.c
+++ b/drivers/net/wireless/libertas/if_spi.c
@@ -1055,7 +1055,6 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
1055 lbs_stop_card(priv); 1055 lbs_stop_card(priv);
1056 lbs_remove_card(priv); /* will call free_netdev */ 1056 lbs_remove_card(priv); /* will call free_netdev */
1057 1057
1058 priv->surpriseremoved = 1;
1059 free_irq(spi->irq, card); 1058 free_irq(spi->irq, card);
1060 if_spi_terminate_spi_thread(card); 1059 if_spi_terminate_spi_thread(card);
1061 if (card->pdata->teardown) 1060 if (card->pdata->teardown)
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 46b88b118c99..fcd1bbfc632d 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -915,8 +915,6 @@ void lbs_remove_card(struct lbs_private *priv)
915 915
916 lbs_free_adapter(priv); 916 lbs_free_adapter(priv);
917 lbs_cfg_free(priv); 917 lbs_cfg_free(priv);
918
919 priv->dev = NULL;
920 free_netdev(dev); 918 free_netdev(dev);
921 919
922 lbs_deb_leave(LBS_DEB_MAIN); 920 lbs_deb_leave(LBS_DEB_MAIN);
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index e8e2d0f4763d..f3d396e7544b 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -1392,10 +1392,9 @@ static void orinoco_process_scan_results(struct work_struct *work)
1392 orinoco_add_hostscan_results(priv, buf, len); 1392 orinoco_add_hostscan_results(priv, buf, len);
1393 1393
1394 kfree(buf); 1394 kfree(buf);
1395 } else if (priv->scan_request) { 1395 } else {
1396 /* Either abort or complete the scan */ 1396 /* Either abort or complete the scan */
1397 cfg80211_scan_done(priv->scan_request, (len < 0)); 1397 orinoco_scan_done(priv, (len < 0));
1398 priv->scan_request = NULL;
1399 } 1398 }
1400 1399
1401 spin_lock_irqsave(&priv->scan_lock, flags); 1400 spin_lock_irqsave(&priv->scan_lock, flags);
@@ -1684,6 +1683,8 @@ static int __orinoco_down(struct orinoco_private *priv)
1684 hermes_write_regn(hw, EVACK, 0xffff); 1683 hermes_write_regn(hw, EVACK, 0xffff);
1685 } 1684 }
1686 1685
1686 orinoco_scan_done(priv, true);
1687
1687 /* firmware will have to reassociate */ 1688 /* firmware will have to reassociate */
1688 netif_carrier_off(dev); 1689 netif_carrier_off(dev);
1689 priv->last_linkstatus = 0xffff; 1690 priv->last_linkstatus = 0xffff;
@@ -1762,10 +1763,7 @@ void orinoco_reset(struct work_struct *work)
1762 orinoco_unlock(priv, &flags); 1763 orinoco_unlock(priv, &flags);
1763 1764
1764 /* Scanning support: Notify scan cancellation */ 1765 /* Scanning support: Notify scan cancellation */
1765 if (priv->scan_request) { 1766 orinoco_scan_done(priv, true);
1766 cfg80211_scan_done(priv->scan_request, 1);
1767 priv->scan_request = NULL;
1768 }
1769 1767
1770 if (priv->hard_reset) { 1768 if (priv->hard_reset) {
1771 err = (*priv->hard_reset)(priv); 1769 err = (*priv->hard_reset)(priv);
@@ -1813,6 +1811,12 @@ static int __orinoco_commit(struct orinoco_private *priv)
1813 struct net_device *dev = priv->ndev; 1811 struct net_device *dev = priv->ndev;
1814 int err = 0; 1812 int err = 0;
1815 1813
1814 /* If we've called commit, we are reconfiguring or bringing the
1815 * interface up. Maintaining countermeasures across this would
1816 * be confusing, so note that we've disabled them. The port will
1817 * be enabled later in orinoco_commit or __orinoco_up. */
1818 priv->tkip_cm_active = 0;
1819
1816 err = orinoco_hw_program_rids(priv); 1820 err = orinoco_hw_program_rids(priv);
1817 1821
1818 /* FIXME: what about netif_tx_lock */ 1822 /* FIXME: what about netif_tx_lock */
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index 71b3d68b9403..32954c4b243a 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -151,20 +151,20 @@ orinoco_cs_config(struct pcmcia_device *link)
151 goto failed; 151 goto failed;
152 } 152 }
153 153
154 ret = pcmcia_request_irq(link, orinoco_interrupt);
155 if (ret)
156 goto failed;
157
158 /* We initialize the hermes structure before completing PCMCIA
159 * configuration just in case the interrupt handler gets
160 * called. */
161 mem = ioport_map(link->resource[0]->start, 154 mem = ioport_map(link->resource[0]->start,
162 resource_size(link->resource[0])); 155 resource_size(link->resource[0]));
163 if (!mem) 156 if (!mem)
164 goto failed; 157 goto failed;
165 158
159 /* We initialize the hermes structure before completing PCMCIA
160 * configuration just in case the interrupt handler gets
161 * called. */
166 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); 162 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
167 163
164 ret = pcmcia_request_irq(link, orinoco_interrupt);
165 if (ret)
166 goto failed;
167
168 ret = pcmcia_enable_device(link); 168 ret = pcmcia_enable_device(link);
169 if (ret) 169 if (ret)
170 goto failed; 170 goto failed;
diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c
index a38a7bd25f19..b9aedf18a046 100644
--- a/drivers/net/wireless/orinoco/orinoco_usb.c
+++ b/drivers/net/wireless/orinoco/orinoco_usb.c
@@ -57,7 +57,6 @@
57#include <linux/fcntl.h> 57#include <linux/fcntl.h>
58#include <linux/spinlock.h> 58#include <linux/spinlock.h>
59#include <linux/list.h> 59#include <linux/list.h>
60#include <linux/smp_lock.h>
61#include <linux/usb.h> 60#include <linux/usb.h>
62#include <linux/timer.h> 61#include <linux/timer.h>
63 62
diff --git a/drivers/net/wireless/orinoco/scan.c b/drivers/net/wireless/orinoco/scan.c
index 4300d9db7d8c..86cb54c842e7 100644
--- a/drivers/net/wireless/orinoco/scan.c
+++ b/drivers/net/wireless/orinoco/scan.c
@@ -229,3 +229,11 @@ void orinoco_add_hostscan_results(struct orinoco_private *priv,
229 priv->scan_request = NULL; 229 priv->scan_request = NULL;
230 } 230 }
231} 231}
232
233void orinoco_scan_done(struct orinoco_private *priv, bool abort)
234{
235 if (priv->scan_request) {
236 cfg80211_scan_done(priv->scan_request, abort);
237 priv->scan_request = NULL;
238 }
239}
diff --git a/drivers/net/wireless/orinoco/scan.h b/drivers/net/wireless/orinoco/scan.h
index 2dc4e046dbdb..27281fb0a6dc 100644
--- a/drivers/net/wireless/orinoco/scan.h
+++ b/drivers/net/wireless/orinoco/scan.h
@@ -16,5 +16,6 @@ void orinoco_add_extscan_result(struct orinoco_private *priv,
16void orinoco_add_hostscan_results(struct orinoco_private *dev, 16void orinoco_add_hostscan_results(struct orinoco_private *dev,
17 unsigned char *buf, 17 unsigned char *buf,
18 size_t len); 18 size_t len);
19void orinoco_scan_done(struct orinoco_private *priv, bool abort);
19 20
20#endif /* _ORINOCO_SCAN_H_ */ 21#endif /* _ORINOCO_SCAN_H_ */
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index fb859a5ad2eb..db34c282e59b 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -214,21 +214,21 @@ spectrum_cs_config(struct pcmcia_device *link)
214 goto failed; 214 goto failed;
215 } 215 }
216 216
217 ret = pcmcia_request_irq(link, orinoco_interrupt);
218 if (ret)
219 goto failed;
220
221 /* We initialize the hermes structure before completing PCMCIA
222 * configuration just in case the interrupt handler gets
223 * called. */
224 mem = ioport_map(link->resource[0]->start, 217 mem = ioport_map(link->resource[0]->start,
225 resource_size(link->resource[0])); 218 resource_size(link->resource[0]));
226 if (!mem) 219 if (!mem)
227 goto failed; 220 goto failed;
228 221
222 /* We initialize the hermes structure before completing PCMCIA
223 * configuration just in case the interrupt handler gets
224 * called. */
229 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); 225 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
230 hw->eeprom_pda = true; 226 hw->eeprom_pda = true;
231 227
228 ret = pcmcia_request_irq(link, orinoco_interrupt);
229 if (ret)
230 goto failed;
231
232 ret = pcmcia_enable_device(link); 232 ret = pcmcia_enable_device(link);
233 if (ret) 233 if (ret)
234 goto failed; 234 goto failed;
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index 93505f93bf97..e5afabee60d1 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -911,10 +911,10 @@ static int orinoco_ioctl_set_auth(struct net_device *dev,
911 */ 911 */
912 if (param->value) { 912 if (param->value) {
913 priv->tkip_cm_active = 1; 913 priv->tkip_cm_active = 1;
914 ret = hermes_enable_port(hw, 0); 914 ret = hermes_disable_port(hw, 0);
915 } else { 915 } else {
916 priv->tkip_cm_active = 0; 916 priv->tkip_cm_active = 0;
917 ret = hermes_disable_port(hw, 0); 917 ret = hermes_enable_port(hw, 0);
918 } 918 }
919 break; 919 break;
920 920
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 458bb57914a3..cdbeec9f83ea 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -66,8 +66,8 @@ struct netfront_cb {
66 66
67#define GRANT_INVALID_REF 0 67#define GRANT_INVALID_REF 0
68 68
69#define NET_TX_RING_SIZE __RING_SIZE((struct xen_netif_tx_sring *)0, PAGE_SIZE) 69#define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE)
70#define NET_RX_RING_SIZE __RING_SIZE((struct xen_netif_rx_sring *)0, PAGE_SIZE) 70#define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE)
71#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256) 71#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
72 72
73struct netfront_info { 73struct netfront_info {
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index d9f51485beee..9383063d2b16 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -349,7 +349,6 @@ static struct irq_chip dino_interrupt_type = {
349 .name = "GSC-PCI", 349 .name = "GSC-PCI",
350 .unmask = dino_unmask_irq, 350 .unmask = dino_unmask_irq,
351 .mask = dino_mask_irq, 351 .mask = dino_mask_irq,
352 .ack = no_ack_irq,
353}; 352};
354 353
355 354
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c
index 1211974f55aa..e860038b0b84 100644
--- a/drivers/parisc/eisa.c
+++ b/drivers/parisc/eisa.c
@@ -186,7 +186,6 @@ static struct irq_chip eisa_interrupt_type = {
186 .name = "EISA", 186 .name = "EISA",
187 .unmask = eisa_unmask_irq, 187 .unmask = eisa_unmask_irq,
188 .mask = eisa_mask_irq, 188 .mask = eisa_mask_irq,
189 .ack = no_ack_irq,
190}; 189};
191 190
192static irqreturn_t eisa_irq(int wax_irq, void *intr_dev) 191static irqreturn_t eisa_irq(int wax_irq, void *intr_dev)
@@ -340,7 +339,7 @@ static int __init eisa_probe(struct parisc_device *dev)
340 setup_irq(2, &irq2_action); 339 setup_irq(2, &irq2_action);
341 for (i = 0; i < 16; i++) { 340 for (i = 0; i < 16; i++) {
342 set_irq_chip_and_handler(i, &eisa_interrupt_type, 341 set_irq_chip_and_handler(i, &eisa_interrupt_type,
343 handle_level_irq); 342 handle_simple_irq);
344 } 343 }
345 344
346 EISA_bus = 1; 345 EISA_bus = 1;
diff --git a/drivers/parisc/eisa_eeprom.c b/drivers/parisc/eisa_eeprom.c
index cce00ed81f37..af212c6a6158 100644
--- a/drivers/parisc/eisa_eeprom.c
+++ b/drivers/parisc/eisa_eeprom.c
@@ -24,7 +24,6 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/miscdevice.h> 25#include <linux/miscdevice.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/smp_lock.h>
28#include <linux/fs.h> 27#include <linux/fs.h>
29#include <asm/io.h> 28#include <asm/io.h>
30#include <asm/uaccess.h> 29#include <asm/uaccess.h>
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c
index e605298e3aee..772b1939ac21 100644
--- a/drivers/parisc/gsc.c
+++ b/drivers/parisc/gsc.c
@@ -143,7 +143,6 @@ static struct irq_chip gsc_asic_interrupt_type = {
143 .name = "GSC-ASIC", 143 .name = "GSC-ASIC",
144 .unmask = gsc_asic_unmask_irq, 144 .unmask = gsc_asic_unmask_irq,
145 .mask = gsc_asic_mask_irq, 145 .mask = gsc_asic_mask_irq,
146 .ack = no_ack_irq,
147}; 146};
148 147
149int gsc_assign_irq(struct irq_chip *type, void *data) 148int gsc_assign_irq(struct irq_chip *type, void *data)
@@ -153,7 +152,7 @@ int gsc_assign_irq(struct irq_chip *type, void *data)
153 if (irq > GSC_IRQ_MAX) 152 if (irq > GSC_IRQ_MAX)
154 return NO_IRQ; 153 return NO_IRQ;
155 154
156 set_irq_chip_and_handler(irq, type, handle_level_irq); 155 set_irq_chip_and_handler(irq, type, handle_simple_irq);
157 set_irq_chip_data(irq, data); 156 set_irq_chip_data(irq, data);
158 157
159 return irq++; 158 return irq++;
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index a3120a09c43d..0327894bf235 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -669,6 +669,13 @@ printk("\n");
669 DBG(KERN_DEBUG "enable_irq(%d): eoi(%p, 0x%x)\n", irq, 669 DBG(KERN_DEBUG "enable_irq(%d): eoi(%p, 0x%x)\n", irq,
670 vi->eoi_addr, vi->eoi_data); 670 vi->eoi_addr, vi->eoi_data);
671 iosapic_eoi(vi->eoi_addr, vi->eoi_data); 671 iosapic_eoi(vi->eoi_addr, vi->eoi_data);
672}
673
674static void iosapic_eoi_irq(unsigned int irq)
675{
676 struct vector_info *vi = get_irq_chip_data(irq);
677
678 iosapic_eoi(vi->eoi_addr, vi->eoi_data);
672 cpu_eoi_irq(irq); 679 cpu_eoi_irq(irq);
673} 680}
674 681
@@ -705,6 +712,7 @@ static struct irq_chip iosapic_interrupt_type = {
705 .unmask = iosapic_unmask_irq, 712 .unmask = iosapic_unmask_irq,
706 .mask = iosapic_mask_irq, 713 .mask = iosapic_mask_irq,
707 .ack = cpu_ack_irq, 714 .ack = cpu_ack_irq,
715 .eoi = iosapic_eoi_irq,
708#ifdef CONFIG_SMP 716#ifdef CONFIG_SMP
709 .set_affinity = iosapic_set_affinity_irq, 717 .set_affinity = iosapic_set_affinity_irq,
710#endif 718#endif
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index 2350e8a86eef..f2f501e5b6a0 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -64,6 +64,7 @@ static unsigned int led_diskio __read_mostly = 1;
64static unsigned int led_lanrxtx __read_mostly = 1; 64static unsigned int led_lanrxtx __read_mostly = 1;
65static char lcd_text[32] __read_mostly; 65static char lcd_text[32] __read_mostly;
66static char lcd_text_default[32] __read_mostly; 66static char lcd_text_default[32] __read_mostly;
67static int lcd_no_led_support __read_mostly = 0; /* KittyHawk doesn't support LED on its LCD */
67 68
68 69
69static struct workqueue_struct *led_wq; 70static struct workqueue_struct *led_wq;
@@ -115,7 +116,7 @@ lcd_info __attribute__((aligned(8))) __read_mostly =
115 .lcd_width = 16, 116 .lcd_width = 16,
116 .lcd_cmd_reg_addr = KITTYHAWK_LCD_CMD, 117 .lcd_cmd_reg_addr = KITTYHAWK_LCD_CMD,
117 .lcd_data_reg_addr = KITTYHAWK_LCD_DATA, 118 .lcd_data_reg_addr = KITTYHAWK_LCD_DATA,
118 .min_cmd_delay = 40, 119 .min_cmd_delay = 80,
119 .reset_cmd1 = 0x80, 120 .reset_cmd1 = 0x80,
120 .reset_cmd2 = 0xc0, 121 .reset_cmd2 = 0xc0,
121}; 122};
@@ -135,6 +136,9 @@ static int start_task(void)
135 /* Display the default text now */ 136 /* Display the default text now */
136 if (led_type == LED_HASLCD) lcd_print( lcd_text_default ); 137 if (led_type == LED_HASLCD) lcd_print( lcd_text_default );
137 138
139 /* KittyHawk has no LED support on its LCD */
140 if (lcd_no_led_support) return 0;
141
138 /* Create the work queue and queue the LED task */ 142 /* Create the work queue and queue the LED task */
139 led_wq = create_singlethread_workqueue("led_wq"); 143 led_wq = create_singlethread_workqueue("led_wq");
140 queue_delayed_work(led_wq, &led_task, 0); 144 queue_delayed_work(led_wq, &led_task, 0);
@@ -248,9 +252,13 @@ static int __init led_create_procfs(void)
248 252
249 proc_pdc_root = proc_mkdir("pdc", 0); 253 proc_pdc_root = proc_mkdir("pdc", 0);
250 if (!proc_pdc_root) return -1; 254 if (!proc_pdc_root) return -1;
251 ent = proc_create_data("led", S_IRUGO|S_IWUSR, proc_pdc_root, 255
252 &led_proc_fops, (void *)LED_NOLCD); /* LED */ 256 if (!lcd_no_led_support)
253 if (!ent) return -1; 257 {
258 ent = proc_create_data("led", S_IRUGO|S_IWUSR, proc_pdc_root,
259 &led_proc_fops, (void *)LED_NOLCD); /* LED */
260 if (!ent) return -1;
261 }
254 262
255 if (led_type == LED_HASLCD) 263 if (led_type == LED_HASLCD)
256 { 264 {
@@ -692,6 +700,7 @@ int __init led_init(void)
692 case 0x58B: /* KittyHawk DC2 100 (K200) */ 700 case 0x58B: /* KittyHawk DC2 100 (K200) */
693 printk(KERN_INFO "%s: KittyHawk-Machine (hversion 0x%x) found, " 701 printk(KERN_INFO "%s: KittyHawk-Machine (hversion 0x%x) found, "
694 "LED detection skipped.\n", __FILE__, CPU_HVERSION); 702 "LED detection skipped.\n", __FILE__, CPU_HVERSION);
703 lcd_no_led_support = 1;
695 goto found; /* use the preinitialized values of lcd_info */ 704 goto found; /* use the preinitialized values of lcd_info */
696 } 705 }
697 706
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index 0846dafdfff1..28241532c0fd 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -323,7 +323,6 @@ static struct irq_chip superio_interrupt_type = {
323 .name = SUPERIO, 323 .name = SUPERIO,
324 .unmask = superio_unmask_irq, 324 .unmask = superio_unmask_irq,
325 .mask = superio_mask_irq, 325 .mask = superio_mask_irq,
326 .ack = no_ack_irq,
327}; 326};
328 327
329#ifdef DEBUG_SUPERIO_INIT 328#ifdef DEBUG_SUPERIO_INIT
@@ -354,7 +353,7 @@ int superio_fixup_irq(struct pci_dev *pcidev)
354#endif 353#endif
355 354
356 for (i = 0; i < 16; i++) { 355 for (i = 0; i < 16; i++) {
357 set_irq_chip_and_handler(i, &superio_interrupt_type, handle_level_irq); 356 set_irq_chip_and_handler(i, &superio_interrupt_type, handle_simple_irq);
358 } 357 }
359 358
360 /* 359 /*
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index f01e344cf4bd..98e6fdf34d30 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -49,6 +49,7 @@ obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o
49obj-$(CONFIG_X86_VISWS) += setup-irq.o 49obj-$(CONFIG_X86_VISWS) += setup-irq.o
50obj-$(CONFIG_MN10300) += setup-bus.o 50obj-$(CONFIG_MN10300) += setup-bus.o
51obj-$(CONFIG_MICROBLAZE) += setup-bus.o 51obj-$(CONFIG_MICROBLAZE) += setup-bus.o
52obj-$(CONFIG_TILE) += setup-bus.o setup-irq.o
52 53
53# 54#
54# ACPI Related PCI FW Functions 55# ACPI Related PCI FW Functions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 003170ea2e39..69546e9213dd 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -64,77 +64,6 @@ void pci_bus_remove_resources(struct pci_bus *bus)
64 } 64 }
65} 65}
66 66
67static bool pci_bus_resource_better(struct resource *res1, bool pos1,
68 struct resource *res2, bool pos2)
69{
70 /* If exactly one is positive decode, always prefer that one */
71 if (pos1 != pos2)
72 return pos1 ? true : false;
73
74 /* Prefer the one that contains the highest address */
75 if (res1->end != res2->end)
76 return (res1->end > res2->end) ? true : false;
77
78 /* Otherwise, prefer the one with highest "center of gravity" */
79 if (res1->start != res2->start)
80 return (res1->start > res2->start) ? true : false;
81
82 /* Otherwise, choose one arbitrarily (but consistently) */
83 return (res1 > res2) ? true : false;
84}
85
86static bool pci_bus_resource_positive(struct pci_bus *bus, struct resource *res)
87{
88 struct pci_bus_resource *bus_res;
89
90 /*
91 * This relies on the fact that pci_bus.resource[] refers to P2P or
92 * CardBus bridge base/limit registers, which are always positively
93 * decoded. The pci_bus.resources list contains host bridge or
94 * subtractively decoded resources.
95 */
96 list_for_each_entry(bus_res, &bus->resources, list) {
97 if (bus_res->res == res)
98 return (bus_res->flags & PCI_SUBTRACTIVE_DECODE) ?
99 false : true;
100 }
101 return true;
102}
103
104/*
105 * Find the next-best bus resource after the cursor "res". If the cursor is
106 * NULL, return the best resource. "Best" means that we prefer positive
107 * decode regions over subtractive decode, then those at higher addresses.
108 */
109static struct resource *pci_bus_find_resource_prev(struct pci_bus *bus,
110 unsigned int type,
111 struct resource *res)
112{
113 bool res_pos, r_pos, prev_pos = false;
114 struct resource *r, *prev = NULL;
115 int i;
116
117 res_pos = pci_bus_resource_positive(bus, res);
118 pci_bus_for_each_resource(bus, r, i) {
119 if (!r)
120 continue;
121
122 if ((r->flags & IORESOURCE_TYPE_BITS) != type)
123 continue;
124
125 r_pos = pci_bus_resource_positive(bus, r);
126 if (!res || pci_bus_resource_better(res, res_pos, r, r_pos)) {
127 if (!prev || pci_bus_resource_better(r, r_pos,
128 prev, prev_pos)) {
129 prev = r;
130 prev_pos = r_pos;
131 }
132 }
133 }
134
135 return prev;
136}
137
138/** 67/**
139 * pci_bus_alloc_resource - allocate a resource from a parent bus 68 * pci_bus_alloc_resource - allocate a resource from a parent bus
140 * @bus: PCI bus 69 * @bus: PCI bus
@@ -160,10 +89,9 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
160 resource_size_t), 89 resource_size_t),
161 void *alignf_data) 90 void *alignf_data)
162{ 91{
163 int ret = -ENOMEM; 92 int i, ret = -ENOMEM;
164 struct resource *r; 93 struct resource *r;
165 resource_size_t max = -1; 94 resource_size_t max = -1;
166 unsigned int type = res->flags & IORESOURCE_TYPE_BITS;
167 95
168 type_mask |= IORESOURCE_IO | IORESOURCE_MEM; 96 type_mask |= IORESOURCE_IO | IORESOURCE_MEM;
169 97
@@ -171,9 +99,10 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
171 if (!(res->flags & IORESOURCE_MEM_64)) 99 if (!(res->flags & IORESOURCE_MEM_64))
172 max = PCIBIOS_MAX_MEM_32; 100 max = PCIBIOS_MAX_MEM_32;
173 101
174 /* Look for space at highest addresses first */ 102 pci_bus_for_each_resource(bus, r, i) {
175 r = pci_bus_find_resource_prev(bus, type, NULL); 103 if (!r)
176 for ( ; r; r = pci_bus_find_resource_prev(bus, type, r)) { 104 continue;
105
177 /* type_mask must match */ 106 /* type_mask must match */
178 if ((res->flags ^ r->flags) & type_mask) 107 if ((res->flags ^ r->flags) & type_mask)
179 continue; 108 continue;
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 0157708d474d..09933eb9126b 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -1417,6 +1417,11 @@ int __init enable_drhd_fault_handling(void)
1417 (unsigned long long)drhd->reg_base_addr, ret); 1417 (unsigned long long)drhd->reg_base_addr, ret);
1418 return -1; 1418 return -1;
1419 } 1419 }
1420
1421 /*
1422 * Clear any previous faults.
1423 */
1424 dmar_fault(iommu->irq, iommu);
1420 } 1425 }
1421 1426
1422 return 0; 1427 return 0;
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 95712a375cd5..63d5042f2079 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -715,7 +715,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma,
715 nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; 715 nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
716 start = vma->vm_pgoff; 716 start = vma->vm_pgoff;
717 size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1; 717 size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1;
718 pci_start = (mmap_api == PCI_MMAP_SYSFS) ? 718 pci_start = (mmap_api == PCI_MMAP_PROCFS) ?
719 pci_resource_start(pdev, resno) >> PAGE_SHIFT : 0; 719 pci_resource_start(pdev, resno) >> PAGE_SHIFT : 0;
720 if (start >= pci_start && start < pci_start + size && 720 if (start >= pci_start && start < pci_start + size &&
721 start + nr <= pci_start + size) 721 start + nr <= pci_start + size)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index ea00647f4732..27911b55c2a5 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -10,7 +10,6 @@
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/proc_fs.h> 11#include <linux/proc_fs.h>
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
13#include <linux/smp_lock.h>
14#include <linux/capability.h> 13#include <linux/capability.h>
15#include <asm/uaccess.h> 14#include <asm/uaccess.h>
16#include <asm/byteorder.h> 15#include <asm/byteorder.h>
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index f5c63fe9db5c..53a786fd0d40 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2136,6 +2136,24 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82865_HB,
2136DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82875_HB, 2136DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82875_HB,
2137 quirk_unhide_mch_dev6); 2137 quirk_unhide_mch_dev6);
2138 2138
2139#ifdef CONFIG_TILE
2140/*
2141 * The Tilera TILEmpower platform needs to set the link speed
2142 * to 2.5GT(Giga-Transfers)/s (Gen 1). The default link speed
2143 * setting is 5GT/s (Gen 2). 0x98 is the Link Control2 PCIe
2144 * capability register of the PEX8624 PCIe switch. The switch
2145 * supports link speed auto negotiation, but falsely sets
2146 * the link speed to 5GT/s.
2147 */
2148static void __devinit quirk_tile_plx_gen1(struct pci_dev *dev)
2149{
2150 if (tile_plx_gen1) {
2151 pci_write_config_dword(dev, 0x98, 0x1);
2152 mdelay(50);
2153 }
2154}
2155DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_PLX, 0x8624, quirk_tile_plx_gen1);
2156#endif /* CONFIG_TILE */
2139 2157
2140#ifdef CONFIG_PCI_MSI 2158#ifdef CONFIG_PCI_MSI
2141/* Some chipsets do not support MSI. We cannot easily rely on setting 2159/* Some chipsets do not support MSI. We cannot easily rely on setting
@@ -2311,6 +2329,9 @@ static void __devinit nvbridge_check_legacy_irq_routing(struct pci_dev *dev)
2311{ 2329{
2312 u32 cfg; 2330 u32 cfg;
2313 2331
2332 if (!pci_find_capability(dev, PCI_CAP_ID_HT))
2333 return;
2334
2314 pci_read_config_dword(dev, 0x74, &cfg); 2335 pci_read_config_dword(dev, 0x74, &cfg);
2315 2336
2316 if (cfg & ((1 << 2) | (1 << 15))) { 2337 if (cfg & ((1 << 2) | (1 << 15))) {
@@ -2746,6 +2767,29 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_m
2746DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); 2767DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
2747#endif /*CONFIG_MMC_RICOH_MMC*/ 2768#endif /*CONFIG_MMC_RICOH_MMC*/
2748 2769
2770#if defined(CONFIG_DMAR) || defined(CONFIG_INTR_REMAP)
2771#define VTUNCERRMSK_REG 0x1ac
2772#define VTD_MSK_SPEC_ERRORS (1 << 31)
2773/*
2774 * This is a quirk for masking vt-d spec defined errors to platform error
2775 * handling logic. With out this, platforms using Intel 7500, 5500 chipsets
2776 * (and the derivative chipsets like X58 etc) seem to generate NMI/SMI (based
2777 * on the RAS config settings of the platform) when a vt-d fault happens.
2778 * The resulting SMI caused the system to hang.
2779 *
2780 * VT-d spec related errors are already handled by the VT-d OS code, so no
2781 * need to report the same error through other channels.
2782 */
2783static void vtd_mask_spec_errors(struct pci_dev *dev)
2784{
2785 u32 word;
2786
2787 pci_read_config_dword(dev, VTUNCERRMSK_REG, &word);
2788 pci_write_config_dword(dev, VTUNCERRMSK_REG, word | VTD_MSK_SPEC_ERRORS);
2789}
2790DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x342e, vtd_mask_spec_errors);
2791DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x3c28, vtd_mask_spec_errors);
2792#endif
2749 2793
2750static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, 2794static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
2751 struct pci_fixup *end) 2795 struct pci_fixup *end)
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 3753fd0722e7..2fe8cb8e95cd 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -70,6 +70,7 @@ void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func,
70 va_end(args); 70 va_end(args);
71 } 71 }
72} 72}
73EXPORT_SYMBOL(soc_pcmcia_debug);
73 74
74#endif 75#endif
75 76
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 60a5a5c6b50a..d235f44fd7a3 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -81,6 +81,8 @@ MODULE_PARM_DESC(wapf, "WAPF value");
81 81
82static int wlan_status = 1; 82static int wlan_status = 1;
83static int bluetooth_status = 1; 83static int bluetooth_status = 1;
84static int wimax_status = -1;
85static int wwan_status = -1;
84 86
85module_param(wlan_status, int, 0444); 87module_param(wlan_status, int, 0444);
86MODULE_PARM_DESC(wlan_status, "Set the wireless status on boot " 88MODULE_PARM_DESC(wlan_status, "Set the wireless status on boot "
@@ -92,6 +94,16 @@ MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot "
92 "(0 = disabled, 1 = enabled, -1 = don't do anything). " 94 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
93 "default is 1"); 95 "default is 1");
94 96
97module_param(wimax_status, int, 0444);
98MODULE_PARM_DESC(wimax_status, "Set the wireless status on boot "
99 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
100 "default is 1");
101
102module_param(wwan_status, int, 0444);
103MODULE_PARM_DESC(wwan_status, "Set the wireless status on boot "
104 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
105 "default is 1");
106
95/* 107/*
96 * Some events we use, same for all Asus 108 * Some events we use, same for all Asus
97 */ 109 */
@@ -114,6 +126,8 @@ MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot "
114 */ 126 */
115#define WL_RSTS 0x01 /* internal Wifi */ 127#define WL_RSTS 0x01 /* internal Wifi */
116#define BT_RSTS 0x02 /* internal Bluetooth */ 128#define BT_RSTS 0x02 /* internal Bluetooth */
129#define WM_RSTS 0x08 /* internal wimax */
130#define WW_RSTS 0x20 /* internal wwan */
117 131
118/* LED */ 132/* LED */
119#define METHOD_MLED "MLED" 133#define METHOD_MLED "MLED"
@@ -132,6 +146,11 @@ MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot "
132 */ 146 */
133#define METHOD_WLAN "WLED" 147#define METHOD_WLAN "WLED"
134#define METHOD_BLUETOOTH "BLED" 148#define METHOD_BLUETOOTH "BLED"
149
150/* WWAN and WIMAX */
151#define METHOD_WWAN "GSMC"
152#define METHOD_WIMAX "WMXC"
153
135#define METHOD_WL_STATUS "RSTS" 154#define METHOD_WL_STATUS "RSTS"
136 155
137/* Brightness */ 156/* Brightness */
@@ -883,6 +902,64 @@ static ssize_t store_bluetooth(struct device *dev,
883} 902}
884 903
885/* 904/*
905 * Wimax
906 */
907static int asus_wimax_set(struct asus_laptop *asus, int status)
908{
909 if (write_acpi_int(asus->handle, METHOD_WIMAX, !!status)) {
910 pr_warning("Error setting wimax status to %d", status);
911 return -EIO;
912 }
913 return 0;
914}
915
916static ssize_t show_wimax(struct device *dev,
917 struct device_attribute *attr, char *buf)
918{
919 struct asus_laptop *asus = dev_get_drvdata(dev);
920
921 return sprintf(buf, "%d\n", asus_wireless_status(asus, WM_RSTS));
922}
923
924static ssize_t store_wimax(struct device *dev,
925 struct device_attribute *attr, const char *buf,
926 size_t count)
927{
928 struct asus_laptop *asus = dev_get_drvdata(dev);
929
930 return sysfs_acpi_set(asus, buf, count, METHOD_WIMAX);
931}
932
933/*
934 * Wwan
935 */
936static int asus_wwan_set(struct asus_laptop *asus, int status)
937{
938 if (write_acpi_int(asus->handle, METHOD_WWAN, !!status)) {
939 pr_warning("Error setting wwan status to %d", status);
940 return -EIO;
941 }
942 return 0;
943}
944
945static ssize_t show_wwan(struct device *dev,
946 struct device_attribute *attr, char *buf)
947{
948 struct asus_laptop *asus = dev_get_drvdata(dev);
949
950 return sprintf(buf, "%d\n", asus_wireless_status(asus, WW_RSTS));
951}
952
953static ssize_t store_wwan(struct device *dev,
954 struct device_attribute *attr, const char *buf,
955 size_t count)
956{
957 struct asus_laptop *asus = dev_get_drvdata(dev);
958
959 return sysfs_acpi_set(asus, buf, count, METHOD_WWAN);
960}
961
962/*
886 * Display 963 * Display
887 */ 964 */
888static void asus_set_display(struct asus_laptop *asus, int value) 965static void asus_set_display(struct asus_laptop *asus, int value)
@@ -1202,6 +1279,8 @@ static DEVICE_ATTR(infos, S_IRUGO, show_infos, NULL);
1202static DEVICE_ATTR(wlan, S_IRUGO | S_IWUSR, show_wlan, store_wlan); 1279static DEVICE_ATTR(wlan, S_IRUGO | S_IWUSR, show_wlan, store_wlan);
1203static DEVICE_ATTR(bluetooth, S_IRUGO | S_IWUSR, 1280static DEVICE_ATTR(bluetooth, S_IRUGO | S_IWUSR,
1204 show_bluetooth, store_bluetooth); 1281 show_bluetooth, store_bluetooth);
1282static DEVICE_ATTR(wimax, S_IRUGO | S_IWUSR, show_wimax, store_wimax);
1283static DEVICE_ATTR(wwan, S_IRUGO | S_IWUSR, show_wwan, store_wwan);
1205static DEVICE_ATTR(display, S_IRUGO | S_IWUSR, show_disp, store_disp); 1284static DEVICE_ATTR(display, S_IRUGO | S_IWUSR, show_disp, store_disp);
1206static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd); 1285static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd);
1207static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl); 1286static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl);
@@ -1212,6 +1291,8 @@ static struct attribute *asus_attributes[] = {
1212 &dev_attr_infos.attr, 1291 &dev_attr_infos.attr,
1213 &dev_attr_wlan.attr, 1292 &dev_attr_wlan.attr,
1214 &dev_attr_bluetooth.attr, 1293 &dev_attr_bluetooth.attr,
1294 &dev_attr_wimax.attr,
1295 &dev_attr_wwan.attr,
1215 &dev_attr_display.attr, 1296 &dev_attr_display.attr,
1216 &dev_attr_ledd.attr, 1297 &dev_attr_ledd.attr,
1217 &dev_attr_ls_level.attr, 1298 &dev_attr_ls_level.attr,
@@ -1239,6 +1320,13 @@ static mode_t asus_sysfs_is_visible(struct kobject *kobj,
1239 } else if (attr == &dev_attr_display.attr) { 1320 } else if (attr == &dev_attr_display.attr) {
1240 supported = !acpi_check_handle(handle, METHOD_SWITCH_DISPLAY, NULL); 1321 supported = !acpi_check_handle(handle, METHOD_SWITCH_DISPLAY, NULL);
1241 1322
1323 } else if (attr == &dev_attr_wimax.attr) {
1324 supported =
1325 !acpi_check_handle(asus->handle, METHOD_WIMAX, NULL);
1326
1327 } else if (attr == &dev_attr_wwan.attr) {
1328 supported = !acpi_check_handle(asus->handle, METHOD_WWAN, NULL);
1329
1242 } else if (attr == &dev_attr_ledd.attr) { 1330 } else if (attr == &dev_attr_ledd.attr) {
1243 supported = !acpi_check_handle(handle, METHOD_LEDD, NULL); 1331 supported = !acpi_check_handle(handle, METHOD_LEDD, NULL);
1244 1332
@@ -1397,7 +1485,8 @@ static int asus_laptop_get_info(struct asus_laptop *asus)
1397 1485
1398 /* 1486 /*
1399 * The HWRS method return informations about the hardware. 1487 * The HWRS method return informations about the hardware.
1400 * 0x80 bit is for WLAN, 0x100 for Bluetooth. 1488 * 0x80 bit is for WLAN, 0x100 for Bluetooth,
1489 * 0x40 for WWAN, 0x10 for WIMAX.
1401 * The significance of others is yet to be found. 1490 * The significance of others is yet to be found.
1402 */ 1491 */
1403 status = 1492 status =
@@ -1440,6 +1529,12 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus)
1440 if (wlan_status >= 0) 1529 if (wlan_status >= 0)
1441 asus_wlan_set(asus, !!wlan_status); 1530 asus_wlan_set(asus, !!wlan_status);
1442 1531
1532 if (wimax_status >= 0)
1533 asus_wimax_set(asus, !!wimax_status);
1534
1535 if (wwan_status >= 0)
1536 asus_wwan_set(asus, !!wwan_status);
1537
1443 /* Keyboard Backlight is on by default */ 1538 /* Keyboard Backlight is on by default */
1444 if (!acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_SET, NULL)) 1539 if (!acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_SET, NULL))
1445 asus_kled_set(asus, 1); 1540 asus_kled_set(asus, 1);
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
index 462ceab93f87..0d50fbbe2478 100644
--- a/drivers/platform/x86/eeepc-wmi.c
+++ b/drivers/platform/x86/eeepc-wmi.c
@@ -298,8 +298,8 @@ static void eeepc_wmi_notify(u32 value, void *context)
298 kfree(obj); 298 kfree(obj);
299} 299}
300 300
301static int store_cpufv(struct device *dev, struct device_attribute *attr, 301static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
302 const char *buf, size_t count) 302 const char *buf, size_t count)
303{ 303{
304 int value; 304 int value;
305 struct acpi_buffer input = { (acpi_size)sizeof(value), &value }; 305 struct acpi_buffer input = { (acpi_size)sizeof(value), &value };
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 1dac659b5e0c..9e05af9c41cb 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -172,6 +172,8 @@ static int hp_wmi_perform_query(int query, int write, u32 *buffer,
172 bios_return = *((struct bios_return *)obj->buffer.pointer); 172 bios_return = *((struct bios_return *)obj->buffer.pointer);
173 173
174 memcpy(buffer, &bios_return.value, sizeof(bios_return.value)); 174 memcpy(buffer, &bios_return.value, sizeof(bios_return.value));
175
176 kfree(obj);
175 return 0; 177 return 0;
176} 178}
177 179
diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
index 3c2c6b91ecb3..94a114aa8e28 100644
--- a/drivers/platform/x86/ibm_rtl.c
+++ b/drivers/platform/x86/ibm_rtl.c
@@ -28,6 +28,7 @@
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/sysdev.h> 29#include <linux/sysdev.h>
30#include <linux/dmi.h> 30#include <linux/dmi.h>
31#include <linux/efi.h>
31#include <linux/mutex.h> 32#include <linux/mutex.h>
32#include <asm/bios_ebda.h> 33#include <asm/bios_ebda.h>
33 34
@@ -220,32 +221,13 @@ static void rtl_teardown_sysfs(void) {
220 sysdev_class_unregister(&class_rtl); 221 sysdev_class_unregister(&class_rtl);
221} 222}
222 223
223static int dmi_check_cb(const struct dmi_system_id *id)
224{
225 RTL_DEBUG("found IBM server '%s'\n", id->ident);
226 return 0;
227}
228
229#define ibm_dmi_entry(NAME, TYPE) \
230{ \
231 .ident = NAME, \
232 .matches = { \
233 DMI_MATCH(DMI_SYS_VENDOR, "IBM"), \
234 DMI_MATCH(DMI_PRODUCT_NAME, TYPE), \
235 }, \
236 .callback = dmi_check_cb \
237}
238 224
239static struct dmi_system_id __initdata ibm_rtl_dmi_table[] = { 225static struct dmi_system_id __initdata ibm_rtl_dmi_table[] = {
240 ibm_dmi_entry("BladeCenter LS21", "7971"), 226 { \
241 ibm_dmi_entry("BladeCenter LS22", "7901"), 227 .matches = { \
242 ibm_dmi_entry("BladeCenter HS21 XM", "7995"), 228 DMI_MATCH(DMI_SYS_VENDOR, "IBM"), \
243 ibm_dmi_entry("BladeCenter HS22", "7870"), 229 }, \
244 ibm_dmi_entry("BladeCenter HS22V", "7871"), 230 },
245 ibm_dmi_entry("System x3550 M2", "7946"),
246 ibm_dmi_entry("System x3650 M2", "7947"),
247 ibm_dmi_entry("System x3550 M3", "7944"),
248 ibm_dmi_entry("System x3650 M3", "7945"),
249 { } 231 { }
250}; 232};
251 233
@@ -257,7 +239,7 @@ static int __init ibm_rtl_init(void) {
257 if (force) 239 if (force)
258 pr_warning("ibm-rtl: module loaded by force\n"); 240 pr_warning("ibm-rtl: module loaded by force\n");
259 /* first ensure that we are running on IBM HW */ 241 /* first ensure that we are running on IBM HW */
260 else if (!dmi_check_system(ibm_rtl_dmi_table)) 242 else if (efi_enabled || !dmi_check_system(ibm_rtl_dmi_table))
261 return -ENODEV; 243 return -ENODEV;
262 244
263 /* Get the address for the Extended BIOS Data Area */ 245 /* Get the address for the Extended BIOS Data Area */
@@ -302,7 +284,7 @@ static int __init ibm_rtl_init(void) {
302 RTL_DEBUG("rtl_cmd_width = %u, rtl_cmd_type = %u\n", 284 RTL_DEBUG("rtl_cmd_width = %u, rtl_cmd_type = %u\n",
303 rtl_cmd_width, rtl_cmd_type); 285 rtl_cmd_width, rtl_cmd_type);
304 addr = ioread32(&rtl_table->cmd_port_address); 286 addr = ioread32(&rtl_table->cmd_port_address);
305 RTL_DEBUG("addr = %#llx\n", addr); 287 RTL_DEBUG("addr = %#llx\n", (unsigned long long)addr);
306 plen = rtl_cmd_width/sizeof(char); 288 plen = rtl_cmd_width/sizeof(char);
307 rtl_cmd_addr = rtl_port_map(addr, plen); 289 rtl_cmd_addr = rtl_port_map(addr, plen);
308 RTL_DEBUG("rtl_cmd_addr = %#llx\n", (u64)rtl_cmd_addr); 290 RTL_DEBUG("rtl_cmd_addr = %#llx\n", (u64)rtl_cmd_addr);
diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
index 42a5469a2459..35278ad7e628 100644
--- a/drivers/platform/x86/msi-wmi.c
+++ b/drivers/platform/x86/msi-wmi.c
@@ -43,16 +43,18 @@ MODULE_ALIAS("wmi:B6F3EEF2-3D2F-49DC-9DE3-85BCE18C62F2");
43 43
44#define dprintk(msg...) pr_debug(DRV_PFX msg) 44#define dprintk(msg...) pr_debug(DRV_PFX msg)
45 45
46#define KEYCODE_BASE 0xD0 46#define SCANCODE_BASE 0xD0
47#define MSI_WMI_BRIGHTNESSUP KEYCODE_BASE 47#define MSI_WMI_BRIGHTNESSUP SCANCODE_BASE
48#define MSI_WMI_BRIGHTNESSDOWN (KEYCODE_BASE + 1) 48#define MSI_WMI_BRIGHTNESSDOWN (SCANCODE_BASE + 1)
49#define MSI_WMI_VOLUMEUP (KEYCODE_BASE + 2) 49#define MSI_WMI_VOLUMEUP (SCANCODE_BASE + 2)
50#define MSI_WMI_VOLUMEDOWN (KEYCODE_BASE + 3) 50#define MSI_WMI_VOLUMEDOWN (SCANCODE_BASE + 3)
51#define MSI_WMI_MUTE (SCANCODE_BASE + 4)
51static struct key_entry msi_wmi_keymap[] = { 52static struct key_entry msi_wmi_keymap[] = {
52 { KE_KEY, MSI_WMI_BRIGHTNESSUP, {KEY_BRIGHTNESSUP} }, 53 { KE_KEY, MSI_WMI_BRIGHTNESSUP, {KEY_BRIGHTNESSUP} },
53 { KE_KEY, MSI_WMI_BRIGHTNESSDOWN, {KEY_BRIGHTNESSDOWN} }, 54 { KE_KEY, MSI_WMI_BRIGHTNESSDOWN, {KEY_BRIGHTNESSDOWN} },
54 { KE_KEY, MSI_WMI_VOLUMEUP, {KEY_VOLUMEUP} }, 55 { KE_KEY, MSI_WMI_VOLUMEUP, {KEY_VOLUMEUP} },
55 { KE_KEY, MSI_WMI_VOLUMEDOWN, {KEY_VOLUMEDOWN} }, 56 { KE_KEY, MSI_WMI_VOLUMEDOWN, {KEY_VOLUMEDOWN} },
57 { KE_KEY, MSI_WMI_MUTE, {KEY_MUTE} },
56 { KE_END, 0} 58 { KE_END, 0}
57}; 59};
58static ktime_t last_pressed[ARRAY_SIZE(msi_wmi_keymap) - 1]; 60static ktime_t last_pressed[ARRAY_SIZE(msi_wmi_keymap) - 1];
@@ -169,7 +171,7 @@ static void msi_wmi_notify(u32 value, void *context)
169 ktime_t diff; 171 ktime_t diff;
170 cur = ktime_get_real(); 172 cur = ktime_get_real();
171 diff = ktime_sub(cur, last_pressed[key->code - 173 diff = ktime_sub(cur, last_pressed[key->code -
172 KEYCODE_BASE]); 174 SCANCODE_BASE]);
173 /* Ignore event if the same event happened in a 50 ms 175 /* Ignore event if the same event happened in a 50 ms
174 timeframe -> Key press may result in 10-20 GPEs */ 176 timeframe -> Key press may result in 10-20 GPEs */
175 if (ktime_to_us(diff) < 1000 * 50) { 177 if (ktime_to_us(diff) < 1000 * 50) {
@@ -178,7 +180,7 @@ static void msi_wmi_notify(u32 value, void *context)
178 key->code, ktime_to_us(diff)); 180 key->code, ktime_to_us(diff));
179 return; 181 return;
180 } 182 }
181 last_pressed[key->code - KEYCODE_BASE] = cur; 183 last_pressed[key->code - SCANCODE_BASE] = cur;
182 184
183 if (key->type == KE_KEY && 185 if (key->type == KE_KEY &&
184 /* Brightness is served via acpi video driver */ 186 /* Brightness is served via acpi video driver */
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 2d61186ad5a2..e8c21994b36d 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -8497,7 +8497,6 @@ static void ibm_exit(struct ibm_struct *ibm)
8497 ibm->acpi->type, 8497 ibm->acpi->type,
8498 dispatch_acpi_notify); 8498 dispatch_acpi_notify);
8499 ibm->flags.acpi_notify_installed = 0; 8499 ibm->flags.acpi_notify_installed = 0;
8500 ibm->flags.acpi_notify_installed = 0;
8501 } 8500 }
8502 8501
8503 if (ibm->flags.proc_created) { 8502 if (ibm->flags.proc_created) {
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 06f304f46e02..4276da7291b8 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -135,6 +135,7 @@ static const struct key_entry toshiba_acpi_keymap[] __initconst = {
135 { KE_KEY, 0x141, { KEY_BRIGHTNESSUP } }, 135 { KE_KEY, 0x141, { KEY_BRIGHTNESSUP } },
136 { KE_KEY, 0x142, { KEY_WLAN } }, 136 { KE_KEY, 0x142, { KEY_WLAN } },
137 { KE_KEY, 0x143, { KEY_PROG1 } }, 137 { KE_KEY, 0x143, { KEY_PROG1 } },
138 { KE_KEY, 0x17f, { KEY_FN } },
138 { KE_KEY, 0xb05, { KEY_PROG2 } }, 139 { KE_KEY, 0xb05, { KEY_PROG2 } },
139 { KE_KEY, 0xb06, { KEY_WWW } }, 140 { KE_KEY, 0xb06, { KEY_WWW } },
140 { KE_KEY, 0xb07, { KEY_MAIL } }, 141 { KE_KEY, 0xb07, { KEY_MAIL } },
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 104b77c87ef5..aecd9a9b549f 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -755,7 +755,7 @@ static bool guid_already_parsed(const char *guid_string)
755 struct wmi_block *wblock; 755 struct wmi_block *wblock;
756 756
757 list_for_each_entry(wblock, &wmi_block_list, list) 757 list_for_each_entry(wblock, &wmi_block_list, list)
758 if (strncmp(wblock->gblock.guid, guid_string, 16) == 0) 758 if (memcmp(wblock->gblock.guid, guid_string, 16) == 0)
759 return true; 759 return true;
760 760
761 return false; 761 return false;
diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
index e73ebefdf3e0..315b3112aca8 100644
--- a/drivers/pnp/isapnp/proc.c
+++ b/drivers/pnp/isapnp/proc.c
@@ -21,7 +21,6 @@
21#include <linux/isapnp.h> 21#include <linux/isapnp.h>
22#include <linux/proc_fs.h> 22#include <linux/proc_fs.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/smp_lock.h>
25#include <asm/uaccess.h> 24#include <asm/uaccess.h>
26 25
27extern struct pnp_protocol isapnp_protocol; 26extern struct pnp_protocol isapnp_protocol;
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 2d73dfcecdbb..57313f4658bc 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -180,7 +180,7 @@ struct pnp_protocol pnpacpi_protocol = {
180}; 180};
181EXPORT_SYMBOL(pnpacpi_protocol); 181EXPORT_SYMBOL(pnpacpi_protocol);
182 182
183static char *pnpacpi_get_id(struct acpi_device *device) 183static char *__init pnpacpi_get_id(struct acpi_device *device)
184{ 184{
185 struct acpi_hardware_id *id; 185 struct acpi_hardware_id *id;
186 186
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f1d10c974cd4..ba521f0f0fac 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -911,7 +911,7 @@ out:
911} 911}
912 912
913/** 913/**
914 * set_consumer_device_supply: Bind a regulator to a symbolic supply 914 * set_consumer_device_supply - Bind a regulator to a symbolic supply
915 * @rdev: regulator source 915 * @rdev: regulator source
916 * @consumer_dev: device the supply applies to 916 * @consumer_dev: device the supply applies to
917 * @consumer_dev_name: dev_name() string for device supply applies to 917 * @consumer_dev_name: dev_name() string for device supply applies to
@@ -1052,7 +1052,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1052 printk(KERN_WARNING 1052 printk(KERN_WARNING
1053 "%s: could not add device link %s err %d\n", 1053 "%s: could not add device link %s err %d\n",
1054 __func__, dev->kobj.name, err); 1054 __func__, dev->kobj.name, err);
1055 device_remove_file(dev, &regulator->dev_attr);
1056 goto link_name_err; 1055 goto link_name_err;
1057 } 1056 }
1058 } 1057 }
@@ -1268,13 +1267,17 @@ static int _regulator_enable(struct regulator_dev *rdev)
1268{ 1267{
1269 int ret, delay; 1268 int ret, delay;
1270 1269
1271 /* do we need to enable the supply regulator first */ 1270 if (rdev->use_count == 0) {
1272 if (rdev->supply) { 1271 /* do we need to enable the supply regulator first */
1273 ret = _regulator_enable(rdev->supply); 1272 if (rdev->supply) {
1274 if (ret < 0) { 1273 mutex_lock(&rdev->supply->mutex);
1275 printk(KERN_ERR "%s: failed to enable %s: %d\n", 1274 ret = _regulator_enable(rdev->supply);
1276 __func__, rdev_get_name(rdev), ret); 1275 mutex_unlock(&rdev->supply->mutex);
1277 return ret; 1276 if (ret < 0) {
1277 printk(KERN_ERR "%s: failed to enable %s: %d\n",
1278 __func__, rdev_get_name(rdev), ret);
1279 return ret;
1280 }
1278 } 1281 }
1279 } 1282 }
1280 1283
@@ -1313,10 +1316,12 @@ static int _regulator_enable(struct regulator_dev *rdev)
1313 if (ret < 0) 1316 if (ret < 0)
1314 return ret; 1317 return ret;
1315 1318
1316 if (delay >= 1000) 1319 if (delay >= 1000) {
1317 mdelay(delay / 1000); 1320 mdelay(delay / 1000);
1318 else if (delay) 1321 udelay(delay % 1000);
1322 } else if (delay) {
1319 udelay(delay); 1323 udelay(delay);
1324 }
1320 1325
1321 } else if (ret < 0) { 1326 } else if (ret < 0) {
1322 printk(KERN_ERR "%s: is_enabled() failed for %s: %d\n", 1327 printk(KERN_ERR "%s: is_enabled() failed for %s: %d\n",
@@ -1359,6 +1364,7 @@ static int _regulator_disable(struct regulator_dev *rdev,
1359 struct regulator_dev **supply_rdev_ptr) 1364 struct regulator_dev **supply_rdev_ptr)
1360{ 1365{
1361 int ret = 0; 1366 int ret = 0;
1367 *supply_rdev_ptr = NULL;
1362 1368
1363 if (WARN(rdev->use_count <= 0, 1369 if (WARN(rdev->use_count <= 0,
1364 "unbalanced disables for %s\n", 1370 "unbalanced disables for %s\n",
@@ -2346,6 +2352,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
2346 if (init_data->supply_regulator && init_data->supply_regulator_dev) { 2352 if (init_data->supply_regulator && init_data->supply_regulator_dev) {
2347 dev_err(dev, 2353 dev_err(dev,
2348 "Supply regulator specified by both name and dev\n"); 2354 "Supply regulator specified by both name and dev\n");
2355 ret = -EINVAL;
2349 goto scrub; 2356 goto scrub;
2350 } 2357 }
2351 2358
@@ -2364,6 +2371,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
2364 if (!found) { 2371 if (!found) {
2365 dev_err(dev, "Failed to find supply %s\n", 2372 dev_err(dev, "Failed to find supply %s\n",
2366 init_data->supply_regulator); 2373 init_data->supply_regulator);
2374 ret = -ENODEV;
2367 goto scrub; 2375 goto scrub;
2368 } 2376 }
2369 2377
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c
index 4597d508a229..ecd99f59dba8 100644
--- a/drivers/regulator/mc13783-regulator.c
+++ b/drivers/regulator/mc13783-regulator.c
@@ -465,8 +465,8 @@ static struct regulator_ops mc13783_fixed_regulator_ops = {
465 .get_voltage = mc13783_fixed_regulator_get_voltage, 465 .get_voltage = mc13783_fixed_regulator_get_voltage,
466}; 466};
467 467
468int mc13783_powermisc_rmw(struct mc13783_regulator_priv *priv, u32 mask, 468static int mc13783_powermisc_rmw(struct mc13783_regulator_priv *priv, u32 mask,
469 u32 val) 469 u32 val)
470{ 470{
471 struct mc13783 *mc13783 = priv->mc13783; 471 struct mc13783 *mc13783 = priv->mc13783;
472 int ret; 472 int ret;
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 51237fbb1bbb..6d20b0454a1d 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -231,8 +231,7 @@ static int tps6586x_dvm_voltages[] = {
231}; 231};
232 232
233#define TPS6586X_REGULATOR(_id, vdata, _ops, vreg, shift, nbits, \ 233#define TPS6586X_REGULATOR(_id, vdata, _ops, vreg, shift, nbits, \
234 ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ 234 ereg0, ebit0, ereg1, ebit1) \
235{ \
236 .desc = { \ 235 .desc = { \
237 .name = "REG-" #_id, \ 236 .name = "REG-" #_id, \
238 .ops = &tps6586x_regulator_##_ops, \ 237 .ops = &tps6586x_regulator_##_ops, \
@@ -248,18 +247,26 @@ static int tps6586x_dvm_voltages[] = {
248 .enable_bit[0] = (ebit0), \ 247 .enable_bit[0] = (ebit0), \
249 .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \ 248 .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \
250 .enable_bit[1] = (ebit1), \ 249 .enable_bit[1] = (ebit1), \
251 .voltages = tps6586x_##vdata##_voltages, \ 250 .voltages = tps6586x_##vdata##_voltages,
252} 251
252#define TPS6586X_REGULATOR_DVM_GOREG(goreg, gobit) \
253 .go_reg = TPS6586X_##goreg, \
254 .go_bit = (gobit),
253 255
254#define TPS6586X_LDO(_id, vdata, vreg, shift, nbits, \ 256#define TPS6586X_LDO(_id, vdata, vreg, shift, nbits, \
255 ereg0, ebit0, ereg1, ebit1) \ 257 ereg0, ebit0, ereg1, ebit1) \
258{ \
256 TPS6586X_REGULATOR(_id, vdata, ldo_ops, vreg, shift, nbits, \ 259 TPS6586X_REGULATOR(_id, vdata, ldo_ops, vreg, shift, nbits, \
257 ereg0, ebit0, ereg1, ebit1, 0, 0) 260 ereg0, ebit0, ereg1, ebit1) \
261}
258 262
259#define TPS6586X_DVM(_id, vdata, vreg, shift, nbits, \ 263#define TPS6586X_DVM(_id, vdata, vreg, shift, nbits, \
260 ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ 264 ereg0, ebit0, ereg1, ebit1, goreg, gobit) \
265{ \
261 TPS6586X_REGULATOR(_id, vdata, dvm_ops, vreg, shift, nbits, \ 266 TPS6586X_REGULATOR(_id, vdata, dvm_ops, vreg, shift, nbits, \
262 ereg0, ebit0, ereg1, ebit1, goreg, gobit) 267 ereg0, ebit0, ereg1, ebit1) \
268 TPS6586X_REGULATOR_DVM_GOREG(goreg, gobit) \
269}
263 270
264static struct tps6586x_regulator tps6586x_regulator[] = { 271static struct tps6586x_regulator tps6586x_regulator[] = {
265 TPS6586X_LDO(LDO_0, ldo, SUPPLYV1, 5, 3, ENC, 0, END, 0), 272 TPS6586X_LDO(LDO_0, ldo, SUPPLYV1, 5, 3, ENC, 0, END, 0),
@@ -267,11 +274,11 @@ static struct tps6586x_regulator tps6586x_regulator[] = {
267 TPS6586X_LDO(LDO_5, ldo, SUPPLYV6, 0, 3, ENE, 6, ENE, 6), 274 TPS6586X_LDO(LDO_5, ldo, SUPPLYV6, 0, 3, ENE, 6, ENE, 6),
268 TPS6586X_LDO(LDO_6, ldo, SUPPLYV3, 0, 3, ENC, 4, END, 4), 275 TPS6586X_LDO(LDO_6, ldo, SUPPLYV3, 0, 3, ENC, 4, END, 4),
269 TPS6586X_LDO(LDO_7, ldo, SUPPLYV3, 3, 3, ENC, 5, END, 5), 276 TPS6586X_LDO(LDO_7, ldo, SUPPLYV3, 3, 3, ENC, 5, END, 5),
270 TPS6586X_LDO(LDO_8, ldo, SUPPLYV1, 5, 3, ENC, 6, END, 6), 277 TPS6586X_LDO(LDO_8, ldo, SUPPLYV2, 5, 3, ENC, 6, END, 6),
271 TPS6586X_LDO(LDO_9, ldo, SUPPLYV6, 3, 3, ENE, 7, ENE, 7), 278 TPS6586X_LDO(LDO_9, ldo, SUPPLYV6, 3, 3, ENE, 7, ENE, 7),
272 TPS6586X_LDO(LDO_RTC, ldo, SUPPLYV4, 3, 3, ENE, 7, ENE, 7), 279 TPS6586X_LDO(LDO_RTC, ldo, SUPPLYV4, 3, 3, V4, 7, V4, 7),
273 TPS6586X_LDO(LDO_1, dvm, SUPPLYV1, 0, 5, ENC, 1, END, 1), 280 TPS6586X_LDO(LDO_1, dvm, SUPPLYV1, 0, 5, ENC, 1, END, 1),
274 TPS6586X_LDO(SM_2, sm2, SUPPLYV2, 0, 5, ENC, 1, END, 1), 281 TPS6586X_LDO(SM_2, sm2, SUPPLYV2, 0, 5, ENC, 7, END, 7),
275 282
276 TPS6586X_DVM(LDO_2, dvm, LDO2BV1, 0, 5, ENA, 3, ENB, 3, VCC2, 6), 283 TPS6586X_DVM(LDO_2, dvm, LDO2BV1, 0, 5, ENA, 3, ENB, 3, VCC2, 6),
277 TPS6586X_DVM(LDO_4, ldo4, LDO4V1, 0, 5, ENC, 3, END, 3, VCC1, 6), 284 TPS6586X_DVM(LDO_4, ldo4, LDO4V1, 0, 5, ENC, 3, END, 3, VCC1, 6),
@@ -290,6 +297,10 @@ static inline int tps6586x_regulator_preinit(struct device *parent,
290 uint8_t val1, val2; 297 uint8_t val1, val2;
291 int ret; 298 int ret;
292 299
300 if (ri->enable_reg[0] == ri->enable_reg[1] &&
301 ri->enable_bit[0] == ri->enable_bit[1])
302 return 0;
303
293 ret = tps6586x_read(parent, ri->enable_reg[0], &val1); 304 ret = tps6586x_read(parent, ri->enable_reg[0], &val1);
294 if (ret) 305 if (ret)
295 return ret; 306 return ret;
@@ -298,14 +309,14 @@ static inline int tps6586x_regulator_preinit(struct device *parent,
298 if (ret) 309 if (ret)
299 return ret; 310 return ret;
300 311
301 if (!(val2 & ri->enable_bit[1])) 312 if (!(val2 & (1 << ri->enable_bit[1])))
302 return 0; 313 return 0;
303 314
304 /* 315 /*
305 * The regulator is on, but it's enabled with the bit we don't 316 * The regulator is on, but it's enabled with the bit we don't
306 * want to use, so we switch the enable bits 317 * want to use, so we switch the enable bits
307 */ 318 */
308 if (!(val1 & ri->enable_bit[0])) { 319 if (!(val1 & (1 << ri->enable_bit[0]))) {
309 ret = tps6586x_set_bits(parent, ri->enable_reg[0], 320 ret = tps6586x_set_bits(parent, ri->enable_reg[0],
310 1 << ri->enable_bit[0]); 321 1 << ri->enable_bit[0]);
311 if (ret) 322 if (ret)
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 7e5892efc437..a57262a4fa6c 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -219,12 +219,12 @@ static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode)
219 return -EACCES; 219 return -EACCES;
220 220
221 status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 221 status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
222 message >> 8, 0x15 /* PB_WORD_MSB */ ); 222 message >> 8, TWL4030_PM_MASTER_PB_WORD_MSB);
223 if (status >= 0) 223 if (status < 0)
224 return status; 224 return status;
225 225
226 return twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 226 return twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
227 message, 0x16 /* PB_WORD_LSB */ ); 227 message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB);
228} 228}
229 229
230/*----------------------------------------------------------------------*/ 230/*----------------------------------------------------------------------*/
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index c71d89dba302..83b4615a3b62 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -17,7 +17,6 @@
17#include <linux/device.h> 17#include <linux/device.h>
18#include <linux/poll.h> 18#include <linux/poll.h>
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/smp_lock.h>
21#include <linux/err.h> 20#include <linux/err.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23 22
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index eb28fb01a38a..f6489eb7e976 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -14,7 +14,6 @@
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/smp_lock.h>
18 17
19#include <asm/compat.h> 18#include <asm/compat.h>
20#include <asm/ccwdev.h> 19#include <asm/ccwdev.h>
diff --git a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c
index 883e2db02bd3..e090a307fdee 100644
--- a/drivers/s390/char/tape_char.c
+++ b/drivers/s390/char/tape_char.c
@@ -17,7 +17,6 @@
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/proc_fs.h> 18#include <linux/proc_fs.h>
19#include <linux/mtio.h> 19#include <linux/mtio.h>
20#include <linux/smp_lock.h>
21#include <linux/compat.h> 20#include <linux/compat.h>
22 21
23#include <asm/uaccess.h> 22#include <asm/uaccess.h>
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 6c408670e08d..b3a3e8e8656e 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -209,29 +209,79 @@ tape_state_set(struct tape_device *device, enum tape_state newstate)
209 wake_up(&device->state_change_wq); 209 wake_up(&device->state_change_wq);
210} 210}
211 211
212struct tape_med_state_work_data {
213 struct tape_device *device;
214 enum tape_medium_state state;
215 struct work_struct work;
216};
217
218static void
219tape_med_state_work_handler(struct work_struct *work)
220{
221 static char env_state_loaded[] = "MEDIUM_STATE=LOADED";
222 static char env_state_unloaded[] = "MEDIUM_STATE=UNLOADED";
223 struct tape_med_state_work_data *p =
224 container_of(work, struct tape_med_state_work_data, work);
225 struct tape_device *device = p->device;
226 char *envp[] = { NULL, NULL };
227
228 switch (p->state) {
229 case MS_UNLOADED:
230 pr_info("%s: The tape cartridge has been successfully "
231 "unloaded\n", dev_name(&device->cdev->dev));
232 envp[0] = env_state_unloaded;
233 kobject_uevent_env(&device->cdev->dev.kobj, KOBJ_CHANGE, envp);
234 break;
235 case MS_LOADED:
236 pr_info("%s: A tape cartridge has been mounted\n",
237 dev_name(&device->cdev->dev));
238 envp[0] = env_state_loaded;
239 kobject_uevent_env(&device->cdev->dev.kobj, KOBJ_CHANGE, envp);
240 break;
241 default:
242 break;
243 }
244 tape_put_device(device);
245 kfree(p);
246}
247
248static void
249tape_med_state_work(struct tape_device *device, enum tape_medium_state state)
250{
251 struct tape_med_state_work_data *p;
252
253 p = kzalloc(sizeof(*p), GFP_ATOMIC);
254 if (p) {
255 INIT_WORK(&p->work, tape_med_state_work_handler);
256 p->device = tape_get_device(device);
257 p->state = state;
258 schedule_work(&p->work);
259 }
260}
261
212void 262void
213tape_med_state_set(struct tape_device *device, enum tape_medium_state newstate) 263tape_med_state_set(struct tape_device *device, enum tape_medium_state newstate)
214{ 264{
215 if (device->medium_state == newstate) 265 enum tape_medium_state oldstate;
266
267 oldstate = device->medium_state;
268 if (oldstate == newstate)
216 return; 269 return;
270 device->medium_state = newstate;
217 switch(newstate){ 271 switch(newstate){
218 case MS_UNLOADED: 272 case MS_UNLOADED:
219 device->tape_generic_status |= GMT_DR_OPEN(~0); 273 device->tape_generic_status |= GMT_DR_OPEN(~0);
220 if (device->medium_state == MS_LOADED) 274 if (oldstate == MS_LOADED)
221 pr_info("%s: The tape cartridge has been successfully " 275 tape_med_state_work(device, MS_UNLOADED);
222 "unloaded\n", dev_name(&device->cdev->dev));
223 break; 276 break;
224 case MS_LOADED: 277 case MS_LOADED:
225 device->tape_generic_status &= ~GMT_DR_OPEN(~0); 278 device->tape_generic_status &= ~GMT_DR_OPEN(~0);
226 if (device->medium_state == MS_UNLOADED) 279 if (oldstate == MS_UNLOADED)
227 pr_info("%s: A tape cartridge has been mounted\n", 280 tape_med_state_work(device, MS_LOADED);
228 dev_name(&device->cdev->dev));
229 break; 281 break;
230 default: 282 default:
231 // print nothing
232 break; 283 break;
233 } 284 }
234 device->medium_state = newstate;
235 wake_up(&device->state_change_wq); 285 wake_up(&device->state_change_wq);
236} 286}
237 287
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index 9f661426e4a1..c837d7419a6a 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -30,7 +30,6 @@
30#include <linux/kmod.h> 30#include <linux/kmod.h>
31#include <linux/cdev.h> 31#include <linux/cdev.h>
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/smp_lock.h>
34#include <linux/string.h> 33#include <linux/string.h>
35 34
36MODULE_AUTHOR 35MODULE_AUTHOR
@@ -249,27 +248,25 @@ static int vmlogrdr_recording(struct vmlogrdr_priv_t * logptr,
249 char cp_command[80]; 248 char cp_command[80];
250 char cp_response[160]; 249 char cp_response[160];
251 char *onoff, *qid_string; 250 char *onoff, *qid_string;
251 int rc;
252 252
253 memset(cp_command, 0x00, sizeof(cp_command)); 253 onoff = ((action == 1) ? "ON" : "OFF");
254 memset(cp_response, 0x00, sizeof(cp_response));
255
256 onoff = ((action == 1) ? "ON" : "OFF");
257 qid_string = ((recording_class_AB == 1) ? " QID * " : ""); 254 qid_string = ((recording_class_AB == 1) ? " QID * " : "");
258 255
259 /* 256 /*
260 * The recording commands needs to be called with option QID 257 * The recording commands needs to be called with option QID
261 * for guests that have previlege classes A or B. 258 * for guests that have previlege classes A or B.
262 * Purging has to be done as separate step, because recording 259 * Purging has to be done as separate step, because recording
263 * can't be switched on as long as records are on the queue. 260 * can't be switched on as long as records are on the queue.
264 * Doing both at the same time doesn't work. 261 * Doing both at the same time doesn't work.
265 */ 262 */
266 263 if (purge && (action == 1)) {
267 if (purge) { 264 memset(cp_command, 0x00, sizeof(cp_command));
265 memset(cp_response, 0x00, sizeof(cp_response));
268 snprintf(cp_command, sizeof(cp_command), 266 snprintf(cp_command, sizeof(cp_command),
269 "RECORDING %s PURGE %s", 267 "RECORDING %s PURGE %s",
270 logptr->recording_name, 268 logptr->recording_name,
271 qid_string); 269 qid_string);
272
273 cpcmd(cp_command, cp_response, sizeof(cp_response), NULL); 270 cpcmd(cp_command, cp_response, sizeof(cp_response), NULL);
274 } 271 }
275 272
@@ -279,19 +276,33 @@ static int vmlogrdr_recording(struct vmlogrdr_priv_t * logptr,
279 logptr->recording_name, 276 logptr->recording_name,
280 onoff, 277 onoff,
281 qid_string); 278 qid_string);
282
283 cpcmd(cp_command, cp_response, sizeof(cp_response), NULL); 279 cpcmd(cp_command, cp_response, sizeof(cp_response), NULL);
284 /* The recording command will usually answer with 'Command complete' 280 /* The recording command will usually answer with 'Command complete'
285 * on success, but when the specific service was never connected 281 * on success, but when the specific service was never connected
286 * before then there might be an additional informational message 282 * before then there might be an additional informational message
287 * 'HCPCRC8072I Recording entry not found' before the 283 * 'HCPCRC8072I Recording entry not found' before the
288 * 'Command complete'. So I use strstr rather then the strncmp. 284 * 'Command complete'. So I use strstr rather then the strncmp.
289 */ 285 */
290 if (strstr(cp_response,"Command complete")) 286 if (strstr(cp_response,"Command complete"))
291 return 0; 287 rc = 0;
292 else 288 else
293 return -EIO; 289 rc = -EIO;
290 /*
291 * If we turn recording off, we have to purge any remaining records
292 * afterwards, as a large number of queued records may impact z/VM
293 * performance.
294 */
295 if (purge && (action == 0)) {
296 memset(cp_command, 0x00, sizeof(cp_command));
297 memset(cp_response, 0x00, sizeof(cp_response));
298 snprintf(cp_command, sizeof(cp_command),
299 "RECORDING %s PURGE %s",
300 logptr->recording_name,
301 qid_string);
302 cpcmd(cp_command, cp_response, sizeof(cp_response), NULL);
303 }
294 304
305 return rc;
295} 306}
296 307
297 308
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index 1de672f21037..f7e4ae6bf15a 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -13,7 +13,6 @@
13 13
14#include <linux/cdev.h> 14#include <linux/cdev.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/smp_lock.h>
17 16
18#include <asm/uaccess.h> 17#include <asm/uaccess.h>
19#include <asm/cio.h> 18#include <asm/cio.h>
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index a5050e217150..825951b6b83f 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -635,7 +635,7 @@ static void css_process_crw(struct crw *crw0, struct crw *crw1, int overflow)
635 init_subchannel_id(&mchk_schid); 635 init_subchannel_id(&mchk_schid);
636 mchk_schid.sch_no = crw0->rsid; 636 mchk_schid.sch_no = crw0->rsid;
637 if (crw1) 637 if (crw1)
638 mchk_schid.ssid = (crw1->rsid >> 8) & 3; 638 mchk_schid.ssid = (crw1->rsid >> 4) & 3;
639 639
640 /* 640 /*
641 * Since we are always presented with IPI in the CRW, we have to 641 * Since we are always presented with IPI in the CRW, we have to
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 2ff8a22d4257..e8391b89eff4 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1455,7 +1455,16 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process)
1455 break; 1455 break;
1456 case IO_SCH_UNREG_ATTACH: 1456 case IO_SCH_UNREG_ATTACH:
1457 case IO_SCH_UNREG: 1457 case IO_SCH_UNREG:
1458 if (cdev) 1458 if (!cdev)
1459 break;
1460 if (cdev->private->state == DEV_STATE_SENSE_ID) {
1461 /*
1462 * Note: delayed work triggered by this event
1463 * and repeated calls to sch_event are synchronized
1464 * by the above check for work_pending(cdev).
1465 */
1466 dev_fsm_event(cdev, DEV_EVENT_NOTOPER);
1467 } else
1459 ccw_device_set_notoper(cdev); 1468 ccw_device_set_notoper(cdev);
1460 break; 1469 break;
1461 case IO_SCH_NOP: 1470 case IO_SCH_NOP:
diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c
index 752dbee06af5..5d9c66627b6e 100644
--- a/drivers/s390/cio/qdio_thinint.c
+++ b/drivers/s390/cio/qdio_thinint.c
@@ -292,8 +292,8 @@ void qdio_shutdown_thinint(struct qdio_irq *irq_ptr)
292 return; 292 return;
293 293
294 /* reset adapter interrupt indicators */ 294 /* reset adapter interrupt indicators */
295 put_indicator(irq_ptr->dsci);
296 set_subchannel_ind(irq_ptr, 1); 295 set_subchannel_ind(irq_ptr, 1);
296 put_indicator(irq_ptr->dsci);
297} 297}
298 298
299void __exit tiqdio_unregister_thinints(void) 299void __exit tiqdio_unregister_thinints(void)
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index f5221749d180..7fca9c10ffcf 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -35,7 +35,6 @@
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/seq_file.h> 36#include <linux/seq_file.h>
37#include <linux/compat.h> 37#include <linux/compat.h>
38#include <linux/smp_lock.h>
39#include <linux/slab.h> 38#include <linux/slab.h>
40#include <asm/atomic.h> 39#include <asm/atomic.h>
41#include <asm/uaccess.h> 40#include <asm/uaccess.h>
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index d37c7331f244..0bcd5806bd9a 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -156,6 +156,8 @@ static int zfcp_erp_required_act(int want, struct zfcp_adapter *adapter,
156 if (!(a_status & ZFCP_STATUS_COMMON_RUNNING) || 156 if (!(a_status & ZFCP_STATUS_COMMON_RUNNING) ||
157 a_status & ZFCP_STATUS_COMMON_ERP_FAILED) 157 a_status & ZFCP_STATUS_COMMON_ERP_FAILED)
158 return 0; 158 return 0;
159 if (p_status & ZFCP_STATUS_COMMON_NOESC)
160 return need;
159 if (!(a_status & ZFCP_STATUS_COMMON_UNBLOCKED)) 161 if (!(a_status & ZFCP_STATUS_COMMON_UNBLOCKED))
160 need = ZFCP_ERP_ACTION_REOPEN_ADAPTER; 162 need = ZFCP_ERP_ACTION_REOPEN_ADAPTER;
161 /* fall through */ 163 /* fall through */
@@ -188,6 +190,9 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
188 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, 190 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE,
189 &zfcp_sdev->status); 191 &zfcp_sdev->status);
190 erp_action = &zfcp_sdev->erp_action; 192 erp_action = &zfcp_sdev->erp_action;
193 memset(erp_action, 0, sizeof(struct zfcp_erp_action));
194 erp_action->port = port;
195 erp_action->sdev = sdev;
191 if (!(atomic_read(&zfcp_sdev->status) & 196 if (!(atomic_read(&zfcp_sdev->status) &
192 ZFCP_STATUS_COMMON_RUNNING)) 197 ZFCP_STATUS_COMMON_RUNNING))
193 act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY; 198 act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
@@ -200,6 +205,8 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
200 zfcp_erp_action_dismiss_port(port); 205 zfcp_erp_action_dismiss_port(port);
201 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status); 206 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
202 erp_action = &port->erp_action; 207 erp_action = &port->erp_action;
208 memset(erp_action, 0, sizeof(struct zfcp_erp_action));
209 erp_action->port = port;
203 if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_RUNNING)) 210 if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_RUNNING))
204 act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY; 211 act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
205 break; 212 break;
@@ -209,6 +216,7 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
209 zfcp_erp_action_dismiss_adapter(adapter); 216 zfcp_erp_action_dismiss_adapter(adapter);
210 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status); 217 atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);
211 erp_action = &adapter->erp_action; 218 erp_action = &adapter->erp_action;
219 memset(erp_action, 0, sizeof(struct zfcp_erp_action));
212 if (!(atomic_read(&adapter->status) & 220 if (!(atomic_read(&adapter->status) &
213 ZFCP_STATUS_COMMON_RUNNING)) 221 ZFCP_STATUS_COMMON_RUNNING))
214 act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY; 222 act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
@@ -218,10 +226,7 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
218 return NULL; 226 return NULL;
219 } 227 }
220 228
221 memset(erp_action, 0, sizeof(struct zfcp_erp_action));
222 erp_action->adapter = adapter; 229 erp_action->adapter = adapter;
223 erp_action->port = port;
224 erp_action->sdev = sdev;
225 erp_action->action = need; 230 erp_action->action = need;
226 erp_action->status = act_status; 231 erp_action->status = act_status;
227 232
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index be0317457147..2eb7dd56ab80 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -851,7 +851,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_cmnd(struct scsi_cmnd *scmnd)
851 851
852 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); 852 zfcp_qdio_set_sbale_last(qdio, &req->qdio_req);
853 853
854 req->data = zfcp_sdev; 854 req->data = sdev;
855 req->handler = zfcp_fsf_abort_fcp_command_handler; 855 req->handler = zfcp_fsf_abort_fcp_command_handler;
856 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle; 856 req->qtcb->header.lun_handle = zfcp_sdev->lun_handle;
857 req->qtcb->header.port_handle = zfcp_sdev->port->handle; 857 req->qtcb->header.port_handle = zfcp_sdev->port->handle;
@@ -2069,8 +2069,6 @@ static void zfcp_fsf_fcp_cmnd_handler(struct zfcp_fsf_req *req)
2069 struct fcp_resp_with_ext *fcp_rsp; 2069 struct fcp_resp_with_ext *fcp_rsp;
2070 unsigned long flags; 2070 unsigned long flags;
2071 2071
2072 zfcp_fsf_fcp_handler_common(req);
2073
2074 read_lock_irqsave(&req->adapter->abort_lock, flags); 2072 read_lock_irqsave(&req->adapter->abort_lock, flags);
2075 2073
2076 scpnt = req->data; 2074 scpnt = req->data;
@@ -2079,6 +2077,8 @@ static void zfcp_fsf_fcp_cmnd_handler(struct zfcp_fsf_req *req)
2079 return; 2077 return;
2080 } 2078 }
2081 2079
2080 zfcp_fsf_fcp_handler_common(req);
2081
2082 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) { 2082 if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
2083 set_host_byte(scpnt, DID_TRANSPORT_DISRUPTED); 2083 set_host_byte(scpnt, DID_TRANSPORT_DISRUPTED);
2084 goto skip_fsfstatus; 2084 goto skip_fsfstatus;
@@ -2170,12 +2170,13 @@ int zfcp_fsf_fcp_cmnd(struct scsi_cmnd *scsi_cmnd)
2170 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; 2170 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
2171 struct zfcp_qdio *qdio = adapter->qdio; 2171 struct zfcp_qdio *qdio = adapter->qdio;
2172 struct fsf_qtcb_bottom_io *io; 2172 struct fsf_qtcb_bottom_io *io;
2173 unsigned long flags;
2173 2174
2174 if (unlikely(!(atomic_read(&zfcp_sdev->status) & 2175 if (unlikely(!(atomic_read(&zfcp_sdev->status) &
2175 ZFCP_STATUS_COMMON_UNBLOCKED))) 2176 ZFCP_STATUS_COMMON_UNBLOCKED)))
2176 return -EBUSY; 2177 return -EBUSY;
2177 2178
2178 spin_lock(&qdio->req_q_lock); 2179 spin_lock_irqsave(&qdio->req_q_lock, flags);
2179 if (atomic_read(&qdio->req_q_free) <= 0) { 2180 if (atomic_read(&qdio->req_q_free) <= 0) {
2180 atomic_inc(&qdio->req_q_full); 2181 atomic_inc(&qdio->req_q_full);
2181 goto out; 2182 goto out;
@@ -2239,7 +2240,7 @@ failed_scsi_cmnd:
2239 zfcp_fsf_req_free(req); 2240 zfcp_fsf_req_free(req);
2240 scsi_cmnd->host_scribble = NULL; 2241 scsi_cmnd->host_scribble = NULL;
2241out: 2242out:
2242 spin_unlock(&qdio->req_q_lock); 2243 spin_unlock_irqrestore(&qdio->req_q_lock, flags);
2243 return retval; 2244 return retval;
2244} 2245}
2245 2246
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 50286d8707f3..63529ed801eb 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -76,8 +76,8 @@ static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result)
76 scpnt->scsi_done(scpnt); 76 scpnt->scsi_done(scpnt);
77} 77}
78 78
79static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt, 79static
80 void (*done) (struct scsi_cmnd *)) 80int zfcp_scsi_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scpnt)
81{ 81{
82 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device); 82 struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
83 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter; 83 struct zfcp_adapter *adapter = zfcp_sdev->port->adapter;
@@ -87,7 +87,6 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
87 /* reset the status for this request */ 87 /* reset the status for this request */
88 scpnt->result = 0; 88 scpnt->result = 0;
89 scpnt->host_scribble = NULL; 89 scpnt->host_scribble = NULL;
90 scpnt->scsi_done = done;
91 90
92 scsi_result = fc_remote_port_chkready(rport); 91 scsi_result = fc_remote_port_chkready(rport);
93 if (unlikely(scsi_result)) { 92 if (unlikely(scsi_result)) {
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index fcf08b3f52c1..b7bd5b0cc7aa 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1765,7 +1765,7 @@ out:
1765} /* End twa_scsi_eh_reset() */ 1765} /* End twa_scsi_eh_reset() */
1766 1766
1767/* This is the main scsi queue function to handle scsi opcodes */ 1767/* This is the main scsi queue function to handle scsi opcodes */
1768static int twa_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 1768static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1769{ 1769{
1770 int request_id, retval; 1770 int request_id, retval;
1771 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; 1771 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
@@ -1812,6 +1812,8 @@ out:
1812 return retval; 1812 return retval;
1813} /* End twa_scsi_queue() */ 1813} /* End twa_scsi_queue() */
1814 1814
1815static DEF_SCSI_QCMD(twa_scsi_queue)
1816
1815/* This function hands scsi cdb's to the firmware */ 1817/* This function hands scsi cdb's to the firmware */
1816static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg) 1818static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg)
1817{ 1819{
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 6a95d111d207..13e39e1fdfe2 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1501,7 +1501,7 @@ out:
1501} /* End twl_scsi_eh_reset() */ 1501} /* End twl_scsi_eh_reset() */
1502 1502
1503/* This is the main scsi queue function to handle scsi opcodes */ 1503/* This is the main scsi queue function to handle scsi opcodes */
1504static int twl_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 1504static int twl_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1505{ 1505{
1506 int request_id, retval; 1506 int request_id, retval;
1507 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata; 1507 TW_Device_Extension *tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
@@ -1536,6 +1536,8 @@ out:
1536 return retval; 1536 return retval;
1537} /* End twl_scsi_queue() */ 1537} /* End twl_scsi_queue() */
1538 1538
1539static DEF_SCSI_QCMD(twl_scsi_queue)
1540
1539/* This function tells the controller to shut down */ 1541/* This function tells the controller to shut down */
1540static void __twl_shutdown(TW_Device_Extension *tw_dev) 1542static void __twl_shutdown(TW_Device_Extension *tw_dev)
1541{ 1543{
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index b1125341f4c8..7fe96ff60c58 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1947,7 +1947,7 @@ static int tw_scsiop_test_unit_ready_complete(TW_Device_Extension *tw_dev, int r
1947} /* End tw_scsiop_test_unit_ready_complete() */ 1947} /* End tw_scsiop_test_unit_ready_complete() */
1948 1948
1949/* This is the main scsi queue function to handle scsi opcodes */ 1949/* This is the main scsi queue function to handle scsi opcodes */
1950static int tw_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 1950static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1951{ 1951{
1952 unsigned char *command = SCpnt->cmnd; 1952 unsigned char *command = SCpnt->cmnd;
1953 int request_id = 0; 1953 int request_id = 0;
@@ -2023,6 +2023,8 @@ static int tw_scsi_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd
2023 return retval; 2023 return retval;
2024} /* End tw_scsi_queue() */ 2024} /* End tw_scsi_queue() */
2025 2025
2026static DEF_SCSI_QCMD(tw_scsi_queue)
2027
2026/* This function is the interrupt service routine */ 2028/* This function is the interrupt service routine */
2027static irqreturn_t tw_interrupt(int irq, void *dev_instance) 2029static irqreturn_t tw_interrupt(int irq, void *dev_instance)
2028{ 2030{
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 89fc1c8af86b..f672491774eb 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -167,7 +167,7 @@ MODULE_LICENSE("GPL");
167#include "53c700_d.h" 167#include "53c700_d.h"
168 168
169 169
170STATIC int NCR_700_queuecommand(struct scsi_cmnd *, void (*done)(struct scsi_cmnd *)); 170STATIC int NCR_700_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *);
171STATIC int NCR_700_abort(struct scsi_cmnd * SCpnt); 171STATIC int NCR_700_abort(struct scsi_cmnd * SCpnt);
172STATIC int NCR_700_bus_reset(struct scsi_cmnd * SCpnt); 172STATIC int NCR_700_bus_reset(struct scsi_cmnd * SCpnt);
173STATIC int NCR_700_host_reset(struct scsi_cmnd * SCpnt); 173STATIC int NCR_700_host_reset(struct scsi_cmnd * SCpnt);
@@ -1749,8 +1749,8 @@ NCR_700_intr(int irq, void *dev_id)
1749 return IRQ_RETVAL(handled); 1749 return IRQ_RETVAL(handled);
1750} 1750}
1751 1751
1752STATIC int 1752static int
1753NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)) 1753NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
1754{ 1754{
1755 struct NCR_700_Host_Parameters *hostdata = 1755 struct NCR_700_Host_Parameters *hostdata =
1756 (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0]; 1756 (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0];
@@ -1904,6 +1904,8 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
1904 return 0; 1904 return 0;
1905} 1905}
1906 1906
1907STATIC DEF_SCSI_QCMD(NCR_700_queuecommand)
1908
1907STATIC int 1909STATIC int
1908NCR_700_abort(struct scsi_cmnd * SCp) 1910NCR_700_abort(struct scsi_cmnd * SCp)
1909{ 1911{
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index fc0b4b81d552..f66c33b9ab41 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2807,7 +2807,7 @@ static int BusLogic_host_reset(struct scsi_cmnd * SCpnt)
2807 Outgoing Mailbox for execution by the associated Host Adapter. 2807 Outgoing Mailbox for execution by the associated Host Adapter.
2808*/ 2808*/
2809 2809
2810static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRoutine) (struct scsi_cmnd *)) 2810static int BusLogic_QueueCommand_lck(struct scsi_cmnd *Command, void (*CompletionRoutine) (struct scsi_cmnd *))
2811{ 2811{
2812 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata; 2812 struct BusLogic_HostAdapter *HostAdapter = (struct BusLogic_HostAdapter *) Command->device->host->hostdata;
2813 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[Command->device->id]; 2813 struct BusLogic_TargetFlags *TargetFlags = &HostAdapter->TargetFlags[Command->device->id];
@@ -2994,6 +2994,7 @@ static int BusLogic_QueueCommand(struct scsi_cmnd *Command, void (*CompletionRou
2994 return 0; 2994 return 0;
2995} 2995}
2996 2996
2997static DEF_SCSI_QCMD(BusLogic_QueueCommand)
2997 2998
2998#if 0 2999#if 0
2999/* 3000/*
diff --git a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h
index 73f237a1ed94..649fcb31f26d 100644
--- a/drivers/scsi/BusLogic.h
+++ b/drivers/scsi/BusLogic.h
@@ -1319,7 +1319,7 @@ static inline void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T Co
1319*/ 1319*/
1320 1320
1321static const char *BusLogic_DriverInfo(struct Scsi_Host *); 1321static const char *BusLogic_DriverInfo(struct Scsi_Host *);
1322static int BusLogic_QueueCommand(struct scsi_cmnd *, void (*CompletionRoutine) (struct scsi_cmnd *)); 1322static int BusLogic_QueueCommand(struct Scsi_Host *h, struct scsi_cmnd *);
1323static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *); 1323static int BusLogic_BIOSDiskParameters(struct scsi_device *, struct block_device *, sector_t, int *);
1324static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *, char *, char **, off_t, int, int); 1324static int BusLogic_ProcDirectoryInfo(struct Scsi_Host *, char *, char **, off_t, int, int);
1325static int BusLogic_SlaveConfigure(struct scsi_device *); 1325static int BusLogic_SlaveConfigure(struct scsi_device *);
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 5d2f148889ad..9a5629f94f95 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -952,7 +952,7 @@ static void NCR5380_exit(struct Scsi_Host *instance)
952 * Locks: host lock taken by caller 952 * Locks: host lock taken by caller
953 */ 953 */
954 954
955static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) 955static int NCR5380_queue_command_lck(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
956{ 956{
957 struct Scsi_Host *instance = cmd->device->host; 957 struct Scsi_Host *instance = cmd->device->host;
958 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; 958 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
@@ -1021,6 +1021,7 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1021 return 0; 1021 return 0;
1022} 1022}
1023 1023
1024static DEF_SCSI_QCMD(NCR5380_queue_command)
1024 1025
1025/** 1026/**
1026 * NCR5380_main - NCR state machines 1027 * NCR5380_main - NCR state machines
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index bdc468c9e1d9..fd40a32b1f6f 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -313,7 +313,7 @@ static void NCR5380_print(struct Scsi_Host *instance);
313#endif 313#endif
314static int NCR5380_abort(Scsi_Cmnd * cmd); 314static int NCR5380_abort(Scsi_Cmnd * cmd);
315static int NCR5380_bus_reset(Scsi_Cmnd * cmd); 315static int NCR5380_bus_reset(Scsi_Cmnd * cmd);
316static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)); 316static int NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
317static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance, 317static int __maybe_unused NCR5380_proc_info(struct Scsi_Host *instance,
318 char *buffer, char **start, off_t offset, int length, int inout); 318 char *buffer, char **start, off_t offset, int length, int inout);
319 319
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
index 6961f78742ae..c91888a0a23c 100644
--- a/drivers/scsi/NCR53c406a.c
+++ b/drivers/scsi/NCR53c406a.c
@@ -693,7 +693,7 @@ static void wait_intr(void)
693} 693}
694#endif 694#endif
695 695
696static int NCR53c406a_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) 696static int NCR53c406a_queue_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
697{ 697{
698 int i; 698 int i;
699 699
@@ -726,6 +726,8 @@ static int NCR53c406a_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
726 return 0; 726 return 0;
727} 727}
728 728
729static DEF_SCSI_QCMD(NCR53c406a_queue)
730
729static int NCR53c406a_host_reset(Scsi_Cmnd * SCpnt) 731static int NCR53c406a_host_reset(Scsi_Cmnd * SCpnt)
730{ 732{
731 DEB(printk("NCR53c406a_reset called\n")); 733 DEB(printk("NCR53c406a_reset called\n"));
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index dbbc601948e5..dc5ac6e528c4 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -911,7 +911,7 @@ static int inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struc
911 * queue the command down to the controller 911 * queue the command down to the controller
912 */ 912 */
913 913
914static int inia100_queue(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd *)) 914static int inia100_queue_lck(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd *))
915{ 915{
916 struct orc_scb *scb; 916 struct orc_scb *scb;
917 struct orc_host *host; /* Point to Host adapter control block */ 917 struct orc_host *host; /* Point to Host adapter control block */
@@ -930,6 +930,8 @@ static int inia100_queue(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd
930 return 0; 930 return 0;
931} 931}
932 932
933static DEF_SCSI_QCMD(inia100_queue)
934
933/***************************************************************************** 935/*****************************************************************************
934 Function name : inia100_abort 936 Function name : inia100_abort
935 Description : Abort a queued command. 937 Description : Abort a queued command.
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 29c0ed1cf507..2c93d9496d62 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -248,7 +248,7 @@ static struct aac_driver_ident aac_drivers[] = {
248 * TODO: unify with aac_scsi_cmd(). 248 * TODO: unify with aac_scsi_cmd().
249 */ 249 */
250 250
251static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 251static int aac_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
252{ 252{
253 struct Scsi_Host *host = cmd->device->host; 253 struct Scsi_Host *host = cmd->device->host;
254 struct aac_dev *dev = (struct aac_dev *)host->hostdata; 254 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
@@ -267,6 +267,8 @@ static int aac_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd
267 return (aac_scsi_cmd(cmd) ? FAILED : 0); 267 return (aac_scsi_cmd(cmd) ? FAILED : 0);
268} 268}
269 269
270static DEF_SCSI_QCMD(aac_queuecommand)
271
270/** 272/**
271 * aac_info - Returns the host adapter name 273 * aac_info - Returns the host adapter name
272 * @shost: Scsi host to report on 274 * @shost: Scsi host to report on
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 0ec3da6f3e12..081c6de92bc5 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -9500,7 +9500,7 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
9500 * in the 'scp' result field. 9500 * in the 'scp' result field.
9501 */ 9501 */
9502static int 9502static int
9503advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *)) 9503advansys_queuecommand_lck(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
9504{ 9504{
9505 struct Scsi_Host *shost = scp->device->host; 9505 struct Scsi_Host *shost = scp->device->host;
9506 int asc_res, result = 0; 9506 int asc_res, result = 0;
@@ -9525,6 +9525,8 @@ advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
9525 return result; 9525 return result;
9526} 9526}
9527 9527
9528static DEF_SCSI_QCMD(advansys_queuecommand)
9529
9528static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base) 9530static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
9529{ 9531{
9530 PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) | 9532 PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 8eab8587ff21..c5169f01c1cd 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1056,7 +1056,7 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
1056 * queue a command 1056 * queue a command
1057 * 1057 *
1058 */ 1058 */
1059static int aha152x_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 1059static int aha152x_queue_lck(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
1060{ 1060{
1061#if 0 1061#if 0
1062 if(*SCpnt->cmnd == REQUEST_SENSE) { 1062 if(*SCpnt->cmnd == REQUEST_SENSE) {
@@ -1070,6 +1070,8 @@ static int aha152x_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
1070 return aha152x_internal_queue(SCpnt, NULL, 0, done); 1070 return aha152x_internal_queue(SCpnt, NULL, 0, done);
1071} 1071}
1072 1072
1073static DEF_SCSI_QCMD(aha152x_queue)
1074
1073 1075
1074/* 1076/*
1075 * 1077 *
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 4f785f254c1f..195823a51aab 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -558,7 +558,7 @@ static void aha1542_intr_handle(struct Scsi_Host *shost)
558 }; 558 };
559} 559}
560 560
561static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) 561static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
562{ 562{
563 unchar ahacmd = CMD_START_SCSI; 563 unchar ahacmd = CMD_START_SCSI;
564 unchar direction; 564 unchar direction;
@@ -718,6 +718,8 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
718 return 0; 718 return 0;
719} 719}
720 720
721static DEF_SCSI_QCMD(aha1542_queuecommand)
722
721/* Initialize mailboxes */ 723/* Initialize mailboxes */
722static void setup_mailboxes(int bse, struct Scsi_Host *shpnt) 724static void setup_mailboxes(int bse, struct Scsi_Host *shpnt)
723{ 725{
diff --git a/drivers/scsi/aha1542.h b/drivers/scsi/aha1542.h
index 1db538552d56..b871d2b57f93 100644
--- a/drivers/scsi/aha1542.h
+++ b/drivers/scsi/aha1542.h
@@ -132,7 +132,7 @@ struct ccb { /* Command Control Block 5.3 */
132}; 132};
133 133
134static int aha1542_detect(struct scsi_host_template *); 134static int aha1542_detect(struct scsi_host_template *);
135static int aha1542_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 135static int aha1542_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
136static int aha1542_bus_reset(Scsi_Cmnd * SCpnt); 136static int aha1542_bus_reset(Scsi_Cmnd * SCpnt);
137static int aha1542_dev_reset(Scsi_Cmnd * SCpnt); 137static int aha1542_dev_reset(Scsi_Cmnd * SCpnt);
138static int aha1542_host_reset(Scsi_Cmnd * SCpnt); 138static int aha1542_host_reset(Scsi_Cmnd * SCpnt);
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index 0107a4cc3331..d058f1ab82b5 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -331,7 +331,7 @@ static irqreturn_t aha1740_intr_handle(int irq, void *dev_id)
331 return IRQ_RETVAL(handled); 331 return IRQ_RETVAL(handled);
332} 332}
333 333
334static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)) 334static int aha1740_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
335{ 335{
336 unchar direction; 336 unchar direction;
337 unchar *cmd = (unchar *) SCpnt->cmnd; 337 unchar *cmd = (unchar *) SCpnt->cmnd;
@@ -503,6 +503,8 @@ static int aha1740_queuecommand(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *))
503 return 0; 503 return 0;
504} 504}
505 505
506static DEF_SCSI_QCMD(aha1740_queuecommand)
507
506/* Query the board for its irq_level and irq_type. Nothing else matters 508/* Query the board for its irq_level and irq_type. Nothing else matters
507 in enhanced mode on an EISA bus. */ 509 in enhanced mode on an EISA bus. */
508 510
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 88ad8482ef59..25d066624476 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -573,7 +573,7 @@ ahd_linux_info(struct Scsi_Host *host)
573 * Queue an SCB to the controller. 573 * Queue an SCB to the controller.
574 */ 574 */
575static int 575static int
576ahd_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) 576ahd_linux_queue_lck(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
577{ 577{
578 struct ahd_softc *ahd; 578 struct ahd_softc *ahd;
579 struct ahd_linux_device *dev = scsi_transport_device_data(cmd->device); 579 struct ahd_linux_device *dev = scsi_transport_device_data(cmd->device);
@@ -588,6 +588,8 @@ ahd_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
588 return rtn; 588 return rtn;
589} 589}
590 590
591static DEF_SCSI_QCMD(ahd_linux_queue)
592
591static struct scsi_target ** 593static struct scsi_target **
592ahd_linux_target_in_softc(struct scsi_target *starget) 594ahd_linux_target_in_softc(struct scsi_target *starget)
593{ 595{
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index aeea7a61478e..4a359bb307c6 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -528,7 +528,7 @@ ahc_linux_info(struct Scsi_Host *host)
528 * Queue an SCB to the controller. 528 * Queue an SCB to the controller.
529 */ 529 */
530static int 530static int
531ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *)) 531ahc_linux_queue_lck(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
532{ 532{
533 struct ahc_softc *ahc; 533 struct ahc_softc *ahc;
534 struct ahc_linux_device *dev = scsi_transport_device_data(cmd->device); 534 struct ahc_linux_device *dev = scsi_transport_device_data(cmd->device);
@@ -548,6 +548,8 @@ ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
548 return rtn; 548 return rtn;
549} 549}
550 550
551static DEF_SCSI_QCMD(ahc_linux_queue)
552
551static inline struct scsi_target ** 553static inline struct scsi_target **
552ahc_linux_target_in_softc(struct scsi_target *starget) 554ahc_linux_target_in_softc(struct scsi_target *starget)
553{ 555{
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index aee73fafccc8..4ff60a08df0f 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -10234,7 +10234,7 @@ static void aic7xxx_buildscb(struct aic7xxx_host *p, struct scsi_cmnd *cmd,
10234 * Description: 10234 * Description:
10235 * Queue a SCB to the controller. 10235 * Queue a SCB to the controller.
10236 *-F*************************************************************************/ 10236 *-F*************************************************************************/
10237static int aic7xxx_queue(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)) 10237static int aic7xxx_queue_lck(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
10238{ 10238{
10239 struct aic7xxx_host *p; 10239 struct aic7xxx_host *p;
10240 struct aic7xxx_scb *scb; 10240 struct aic7xxx_scb *scb;
@@ -10292,6 +10292,8 @@ static int aic7xxx_queue(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
10292 return (0); 10292 return (0);
10293} 10293}
10294 10294
10295static DEF_SCSI_QCMD(aic7xxx_queue)
10296
10295/*+F************************************************************************* 10297/*+F*************************************************************************
10296 * Function: 10298 * Function:
10297 * aic7xxx_bus_device_reset 10299 * aic7xxx_bus_device_reset
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 05a78e515a24..17e3df4f016f 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -85,8 +85,7 @@ static int arcmsr_abort(struct scsi_cmnd *);
85static int arcmsr_bus_reset(struct scsi_cmnd *); 85static int arcmsr_bus_reset(struct scsi_cmnd *);
86static int arcmsr_bios_param(struct scsi_device *sdev, 86static int arcmsr_bios_param(struct scsi_device *sdev,
87 struct block_device *bdev, sector_t capacity, int *info); 87 struct block_device *bdev, sector_t capacity, int *info);
88static int arcmsr_queue_command(struct scsi_cmnd *cmd, 88static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
89 void (*done) (struct scsi_cmnd *));
90static int arcmsr_probe(struct pci_dev *pdev, 89static int arcmsr_probe(struct pci_dev *pdev,
91 const struct pci_device_id *id); 90 const struct pci_device_id *id);
92static void arcmsr_remove(struct pci_dev *pdev); 91static void arcmsr_remove(struct pci_dev *pdev);
@@ -2081,7 +2080,7 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb,
2081 } 2080 }
2082} 2081}
2083 2082
2084static int arcmsr_queue_command(struct scsi_cmnd *cmd, 2083static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd,
2085 void (* done)(struct scsi_cmnd *)) 2084 void (* done)(struct scsi_cmnd *))
2086{ 2085{
2087 struct Scsi_Host *host = cmd->device->host; 2086 struct Scsi_Host *host = cmd->device->host;
@@ -2124,6 +2123,8 @@ static int arcmsr_queue_command(struct scsi_cmnd *cmd,
2124 return 0; 2123 return 0;
2125} 2124}
2126 2125
2126static DEF_SCSI_QCMD(arcmsr_queue_command)
2127
2127static bool arcmsr_get_hba_config(struct AdapterControlBlock *acb) 2128static bool arcmsr_get_hba_config(struct AdapterControlBlock *acb)
2128{ 2129{
2129 struct MessageUnit_A __iomem *reg = acb->pmuA; 2130 struct MessageUnit_A __iomem *reg = acb->pmuA;
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index 918ccf818757..ec166726b314 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -2511,7 +2511,7 @@ acornscsi_intr(int irq, void *dev_id)
2511 * done - function called on completion, with pointer to command descriptor 2511 * done - function called on completion, with pointer to command descriptor
2512 * Returns : 0, or < 0 on error. 2512 * Returns : 0, or < 0 on error.
2513 */ 2513 */
2514int acornscsi_queuecmd(struct scsi_cmnd *SCpnt, 2514static int acornscsi_queuecmd_lck(struct scsi_cmnd *SCpnt,
2515 void (*done)(struct scsi_cmnd *)) 2515 void (*done)(struct scsi_cmnd *))
2516{ 2516{
2517 AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata; 2517 AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata;
@@ -2561,6 +2561,8 @@ int acornscsi_queuecmd(struct scsi_cmnd *SCpnt,
2561 return 0; 2561 return 0;
2562} 2562}
2563 2563
2564DEF_SCSI_QCMD(acornscsi_queuecmd)
2565
2564/* 2566/*
2565 * Prototype: void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1, struct scsi_cmnd **SCpntp2, int result) 2567 * Prototype: void acornscsi_reportstatus(struct scsi_cmnd **SCpntp1, struct scsi_cmnd **SCpntp2, int result)
2566 * Purpose : pass a result to *SCpntp1, and check if *SCpntp1 = *SCpntp2 2568 * Purpose : pass a result to *SCpntp1, and check if *SCpntp1 = *SCpntp2
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 9e71ac611146..2b2ce21e227e 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -2198,7 +2198,7 @@ no_command:
2198 * Returns: 0 on success, else error. 2198 * Returns: 0 on success, else error.
2199 * Notes: io_request_lock is held, interrupts are disabled. 2199 * Notes: io_request_lock is held, interrupts are disabled.
2200 */ 2200 */
2201int fas216_queue_command(struct scsi_cmnd *SCpnt, 2201static int fas216_queue_command_lck(struct scsi_cmnd *SCpnt,
2202 void (*done)(struct scsi_cmnd *)) 2202 void (*done)(struct scsi_cmnd *))
2203{ 2203{
2204 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; 2204 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
@@ -2240,6 +2240,8 @@ int fas216_queue_command(struct scsi_cmnd *SCpnt,
2240 return result; 2240 return result;
2241} 2241}
2242 2242
2243DEF_SCSI_QCMD(fas216_queue_command)
2244
2243/** 2245/**
2244 * fas216_internal_done - trigger restart of a waiting thread in fas216_noqueue_command 2246 * fas216_internal_done - trigger restart of a waiting thread in fas216_noqueue_command
2245 * @SCpnt: Command to wake 2247 * @SCpnt: Command to wake
@@ -2263,7 +2265,7 @@ static void fas216_internal_done(struct scsi_cmnd *SCpnt)
2263 * Returns: scsi result code. 2265 * Returns: scsi result code.
2264 * Notes: io_request_lock is held, interrupts are disabled. 2266 * Notes: io_request_lock is held, interrupts are disabled.
2265 */ 2267 */
2266int fas216_noqueue_command(struct scsi_cmnd *SCpnt, 2268static int fas216_noqueue_command_lck(struct scsi_cmnd *SCpnt,
2267 void (*done)(struct scsi_cmnd *)) 2269 void (*done)(struct scsi_cmnd *))
2268{ 2270{
2269 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; 2271 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
@@ -2277,7 +2279,7 @@ int fas216_noqueue_command(struct scsi_cmnd *SCpnt,
2277 BUG_ON(info->scsi.irq != NO_IRQ); 2279 BUG_ON(info->scsi.irq != NO_IRQ);
2278 2280
2279 info->internal_done = 0; 2281 info->internal_done = 0;
2280 fas216_queue_command(SCpnt, fas216_internal_done); 2282 fas216_queue_command_lck(SCpnt, fas216_internal_done);
2281 2283
2282 /* 2284 /*
2283 * This wastes time, since we can't return until the command is 2285 * This wastes time, since we can't return until the command is
@@ -2310,6 +2312,8 @@ int fas216_noqueue_command(struct scsi_cmnd *SCpnt,
2310 return 0; 2312 return 0;
2311} 2313}
2312 2314
2315DEF_SCSI_QCMD(fas216_noqueue_command)
2316
2313/* 2317/*
2314 * Error handler timeout function. Indicate that we timed out, 2318 * Error handler timeout function. Indicate that we timed out,
2315 * and wake up any error handler process so it can continue. 2319 * and wake up any error handler process so it can continue.
diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
index b65f4cf0eec9..f30f8d659dc4 100644
--- a/drivers/scsi/arm/fas216.h
+++ b/drivers/scsi/arm/fas216.h
@@ -331,23 +331,21 @@ extern int fas216_init (struct Scsi_Host *instance);
331 */ 331 */
332extern int fas216_add (struct Scsi_Host *instance, struct device *dev); 332extern int fas216_add (struct Scsi_Host *instance, struct device *dev);
333 333
334/* Function: int fas216_queue_command(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 334/* Function: int fas216_queue_command(struct Scsi_Host *h, struct scsi_cmnd *SCpnt)
335 * Purpose : queue a command for adapter to process. 335 * Purpose : queue a command for adapter to process.
336 * Params : SCpnt - Command to queue 336 * Params : h - host adapter
337 * done - done function to call once command is complete 337 * : SCpnt - Command to queue
338 * Returns : 0 - success, else error 338 * Returns : 0 - success, else error
339 */ 339 */
340extern int fas216_queue_command(struct scsi_cmnd *, 340extern int fas216_queue_command(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
341 void (*done)(struct scsi_cmnd *));
342 341
343/* Function: int fas216_noqueue_command(istruct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 342/* Function: int fas216_noqueue_command(struct Scsi_Host *h, struct scsi_cmnd *SCpnt)
344 * Purpose : queue a command for adapter to process, and process it to completion. 343 * Purpose : queue a command for adapter to process, and process it to completion.
345 * Params : SCpnt - Command to queue 344 * Params : h - host adapter
346 * done - done function to call once command is complete 345 * : SCpnt - Command to queue
347 * Returns : 0 - success, else error 346 * Returns : 0 - success, else error
348 */ 347 */
349extern int fas216_noqueue_command(struct scsi_cmnd *, 348extern int fas216_noqueue_command(struct Scsi_Host *, struct scsi_cmnd *);
350 void (*done)(struct scsi_cmnd *));
351 349
352/* Function: irqreturn_t fas216_intr (FAS216_Info *info) 350/* Function: irqreturn_t fas216_intr (FAS216_Info *info)
353 * Purpose : handle interrupts from the interface to progress a command 351 * Purpose : handle interrupts from the interface to progress a command
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 158ebc3644d8..88b2928b4d3b 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -910,7 +910,7 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags)
910 * 910 *
911 */ 911 */
912 912
913static int NCR5380_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) 913static int NCR5380_queue_command_lck(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
914{ 914{
915 SETUP_HOSTDATA(cmd->device->host); 915 SETUP_HOSTDATA(cmd->device->host);
916 Scsi_Cmnd *tmp; 916 Scsi_Cmnd *tmp;
@@ -1022,6 +1022,8 @@ static int NCR5380_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
1022 return 0; 1022 return 0;
1023} 1023}
1024 1024
1025static DEF_SCSI_QCMD(NCR5380_queue_command)
1026
1025/* 1027/*
1026 * Function : NCR5380_main (void) 1028 * Function : NCR5380_main (void)
1027 * 1029 *
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index ad7a23aef0ec..3e8658e2f154 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -572,23 +572,6 @@ static void falcon_get_lock(void)
572} 572}
573 573
574 574
575/* This is the wrapper function for NCR5380_queue_command(). It just
576 * tries to get the lock on the ST-DMA (see above) and then calls the
577 * original function.
578 */
579
580#if 0
581int atari_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
582{
583 /* falcon_get_lock();
584 * ++guenther: moved to NCR5380_queue_command() to prevent
585 * race condition, see there for an explanation.
586 */
587 return NCR5380_queue_command(cmd, done);
588}
589#endif
590
591
592int __init atari_scsi_detect(struct scsi_host_template *host) 575int __init atari_scsi_detect(struct scsi_host_template *host)
593{ 576{
594 static int called = 0; 577 static int called = 0;
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index ab5bdda6903e..76029d570beb 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -605,7 +605,7 @@ handled:
605 * 605 *
606 * Queue a command to the ATP queue. Called with the host lock held. 606 * Queue a command to the ATP queue. Called with the host lock held.
607 */ 607 */
608static int atp870u_queuecommand(struct scsi_cmnd * req_p, 608static int atp870u_queuecommand_lck(struct scsi_cmnd *req_p,
609 void (*done) (struct scsi_cmnd *)) 609 void (*done) (struct scsi_cmnd *))
610{ 610{
611 unsigned char c; 611 unsigned char c;
@@ -694,6 +694,8 @@ static int atp870u_queuecommand(struct scsi_cmnd * req_p,
694 return 0; 694 return 0;
695} 695}
696 696
697static DEF_SCSI_QCMD(atp870u_queuecommand)
698
697/** 699/**
698 * send_s870 - send a command to the controller 700 * send_s870 - send a command to the controller
699 * @host: host 701 * @host: host
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 8daa716739d1..8ca967dee66d 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -30,8 +30,7 @@ DEFINE_IDR(bfad_im_port_index);
30struct scsi_transport_template *bfad_im_scsi_transport_template; 30struct scsi_transport_template *bfad_im_scsi_transport_template;
31struct scsi_transport_template *bfad_im_scsi_vport_transport_template; 31struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
32static void bfad_im_itnim_work_handler(struct work_struct *work); 32static void bfad_im_itnim_work_handler(struct work_struct *work);
33static int bfad_im_queuecommand(struct scsi_cmnd *cmnd, 33static int bfad_im_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmnd);
34 void (*done)(struct scsi_cmnd *));
35static int bfad_im_slave_alloc(struct scsi_device *sdev); 34static int bfad_im_slave_alloc(struct scsi_device *sdev);
36static void bfad_im_fc_rport_add(struct bfad_im_port_s *im_port, 35static void bfad_im_fc_rport_add(struct bfad_im_port_s *im_port,
37 struct bfad_itnim_s *itnim); 36 struct bfad_itnim_s *itnim);
@@ -1120,7 +1119,7 @@ bfad_im_itnim_work_handler(struct work_struct *work)
1120 * Scsi_Host template entry, queue a SCSI command to the BFAD. 1119 * Scsi_Host template entry, queue a SCSI command to the BFAD.
1121 */ 1120 */
1122static int 1121static int
1123bfad_im_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) 1122bfad_im_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
1124{ 1123{
1125 struct bfad_im_port_s *im_port = 1124 struct bfad_im_port_s *im_port =
1126 (struct bfad_im_port_s *) cmnd->device->host->hostdata[0]; 1125 (struct bfad_im_port_s *) cmnd->device->host->hostdata[0];
@@ -1187,6 +1186,8 @@ out_fail_cmd:
1187 return 0; 1186 return 0;
1188} 1187}
1189 1188
1189static DEF_SCSI_QCMD(bfad_im_queuecommand)
1190
1190void 1191void
1191bfad_os_rport_online_wait(struct bfad_s *bfad) 1192bfad_os_rport_online_wait(struct bfad_s *bfad)
1192{ 1193{
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 54f50b07dac7..8f1b5c8bf903 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -1080,7 +1080,7 @@ static void build_srb(struct scsi_cmnd *cmd, struct DeviceCtlBlk *dcb,
1080 * and is expected to be held on return. 1080 * and is expected to be held on return.
1081 * 1081 *
1082 **/ 1082 **/
1083static int dc395x_queue_command(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 1083static int dc395x_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
1084{ 1084{
1085 struct DeviceCtlBlk *dcb; 1085 struct DeviceCtlBlk *dcb;
1086 struct ScsiReqBlk *srb; 1086 struct ScsiReqBlk *srb;
@@ -1154,6 +1154,7 @@ complete:
1154 return 0; 1154 return 0;
1155} 1155}
1156 1156
1157static DEF_SCSI_QCMD(dc395x_queue_command)
1157 1158
1158/* 1159/*
1159 * Return the disk geometry for the given SCSI device. 1160 * Return the disk geometry for the given SCSI device.
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 23dec0063385..cffcb108ac96 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -423,7 +423,7 @@ static int adpt_slave_configure(struct scsi_device * device)
423 return 0; 423 return 0;
424} 424}
425 425
426static int adpt_queue(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd *)) 426static int adpt_queue_lck(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd *))
427{ 427{
428 adpt_hba* pHba = NULL; 428 adpt_hba* pHba = NULL;
429 struct adpt_device* pDev = NULL; /* dpt per device information */ 429 struct adpt_device* pDev = NULL; /* dpt per device information */
@@ -491,6 +491,8 @@ static int adpt_queue(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd *))
491 return adpt_scsi_to_i2o(pHba, cmd, pDev); 491 return adpt_scsi_to_i2o(pHba, cmd, pDev);
492} 492}
493 493
494static DEF_SCSI_QCMD(adpt_queue)
495
494static int adpt_bios_param(struct scsi_device *sdev, struct block_device *dev, 496static int adpt_bios_param(struct scsi_device *sdev, struct block_device *dev,
495 sector_t capacity, int geom[]) 497 sector_t capacity, int geom[])
496{ 498{
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
index 337746d46043..beded716f93f 100644
--- a/drivers/scsi/dpti.h
+++ b/drivers/scsi/dpti.h
@@ -29,7 +29,7 @@
29 */ 29 */
30 30
31static int adpt_detect(struct scsi_host_template * sht); 31static int adpt_detect(struct scsi_host_template * sht);
32static int adpt_queue(struct scsi_cmnd * cmd, void (*cmdcomplete) (struct scsi_cmnd *)); 32static int adpt_queue(struct Scsi_Host *h, struct scsi_cmnd * cmd);
33static int adpt_abort(struct scsi_cmnd * cmd); 33static int adpt_abort(struct scsi_cmnd * cmd);
34static int adpt_reset(struct scsi_cmnd* cmd); 34static int adpt_reset(struct scsi_cmnd* cmd);
35static int adpt_release(struct Scsi_Host *host); 35static int adpt_release(struct Scsi_Host *host);
diff --git a/drivers/scsi/dtc.h b/drivers/scsi/dtc.h
index 0b205f8c7326..cdc621204b66 100644
--- a/drivers/scsi/dtc.h
+++ b/drivers/scsi/dtc.h
@@ -36,7 +36,7 @@ static int dtc_abort(Scsi_Cmnd *);
36static int dtc_biosparam(struct scsi_device *, struct block_device *, 36static int dtc_biosparam(struct scsi_device *, struct block_device *,
37 sector_t, int*); 37 sector_t, int*);
38static int dtc_detect(struct scsi_host_template *); 38static int dtc_detect(struct scsi_host_template *);
39static int dtc_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 39static int dtc_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
40static int dtc_bus_reset(Scsi_Cmnd *); 40static int dtc_bus_reset(Scsi_Cmnd *);
41 41
42#ifndef CMD_PER_LUN 42#ifndef CMD_PER_LUN
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index d1c31378f6da..53925ac178fd 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -505,8 +505,7 @@
505 505
506static int eata2x_detect(struct scsi_host_template *); 506static int eata2x_detect(struct scsi_host_template *);
507static int eata2x_release(struct Scsi_Host *); 507static int eata2x_release(struct Scsi_Host *);
508static int eata2x_queuecommand(struct scsi_cmnd *, 508static int eata2x_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
509 void (*done) (struct scsi_cmnd *));
510static int eata2x_eh_abort(struct scsi_cmnd *); 509static int eata2x_eh_abort(struct scsi_cmnd *);
511static int eata2x_eh_host_reset(struct scsi_cmnd *); 510static int eata2x_eh_host_reset(struct scsi_cmnd *);
512static int eata2x_bios_param(struct scsi_device *, struct block_device *, 511static int eata2x_bios_param(struct scsi_device *, struct block_device *,
@@ -1758,7 +1757,7 @@ static void scsi_to_dev_dir(unsigned int i, struct hostdata *ha)
1758 1757
1759} 1758}
1760 1759
1761static int eata2x_queuecommand(struct scsi_cmnd *SCpnt, 1760static int eata2x_queuecommand_lck(struct scsi_cmnd *SCpnt,
1762 void (*done) (struct scsi_cmnd *)) 1761 void (*done) (struct scsi_cmnd *))
1763{ 1762{
1764 struct Scsi_Host *shost = SCpnt->device->host; 1763 struct Scsi_Host *shost = SCpnt->device->host;
@@ -1843,6 +1842,8 @@ static int eata2x_queuecommand(struct scsi_cmnd *SCpnt,
1843 return 0; 1842 return 0;
1844} 1843}
1845 1844
1845static DEF_SCSI_QCMD(eata2x_queuecommand)
1846
1846static int eata2x_eh_abort(struct scsi_cmnd *SCarg) 1847static int eata2x_eh_abort(struct scsi_cmnd *SCarg)
1847{ 1848{
1848 struct Scsi_Host *shost = SCarg->device->host; 1849 struct Scsi_Host *shost = SCarg->device->host;
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 60886c19065e..4a9641e69f54 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -335,7 +335,7 @@ static inline unsigned int eata_pio_send_command(unsigned long base, unsigned ch
335 return 0; 335 return 0;
336} 336}
337 337
338static int eata_pio_queue(struct scsi_cmnd *cmd, 338static int eata_pio_queue_lck(struct scsi_cmnd *cmd,
339 void (*done)(struct scsi_cmnd *)) 339 void (*done)(struct scsi_cmnd *))
340{ 340{
341 unsigned int x, y; 341 unsigned int x, y;
@@ -438,6 +438,8 @@ static int eata_pio_queue(struct scsi_cmnd *cmd,
438 return 0; 438 return 0;
439} 439}
440 440
441static DEF_SCSI_QCMD(eata_pio_queue)
442
441static int eata_pio_abort(struct scsi_cmnd *cmd) 443static int eata_pio_abort(struct scsi_cmnd *cmd)
442{ 444{
443 unsigned int loop = 100; 445 unsigned int loop = 100;
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index e2bc779f86c1..57558523c1b8 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -916,7 +916,7 @@ static void esp_event_queue_full(struct esp *esp, struct esp_cmd_entry *ent)
916 scsi_track_queue_full(dev, lp->num_tagged - 1); 916 scsi_track_queue_full(dev, lp->num_tagged - 1);
917} 917}
918 918
919static int esp_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 919static int esp_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
920{ 920{
921 struct scsi_device *dev = cmd->device; 921 struct scsi_device *dev = cmd->device;
922 struct esp *esp = shost_priv(dev->host); 922 struct esp *esp = shost_priv(dev->host);
@@ -941,6 +941,8 @@ static int esp_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd
941 return 0; 941 return 0;
942} 942}
943 943
944static DEF_SCSI_QCMD(esp_queuecommand)
945
944static int esp_check_gross_error(struct esp *esp) 946static int esp_check_gross_error(struct esp *esp)
945{ 947{
946 if (esp->sreg & ESP_STAT_SPAM) { 948 if (esp->sreg & ESP_STAT_SPAM) {
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index 2ad95aa8f585..a2c6135d337e 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -1072,7 +1072,7 @@ static int fd_mcs_release(struct Scsi_Host *shpnt)
1072 return 0; 1072 return 0;
1073} 1073}
1074 1074
1075static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) 1075static int fd_mcs_queue_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
1076{ 1076{
1077 struct Scsi_Host *shpnt = SCpnt->device->host; 1077 struct Scsi_Host *shpnt = SCpnt->device->host;
1078 1078
@@ -1122,6 +1122,8 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
1122 return 0; 1122 return 0;
1123} 1123}
1124 1124
1125static DEF_SCSI_QCMD(fd_mcs_queue)
1126
1125#if DEBUG_ABORT || DEBUG_RESET 1127#if DEBUG_ABORT || DEBUG_RESET
1126static void fd_mcs_print_info(Scsi_Cmnd * SCpnt) 1128static void fd_mcs_print_info(Scsi_Cmnd * SCpnt)
1127{ 1129{
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index e296bcc57d5c..69b7aa54f43f 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -1419,7 +1419,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id)
1419 return IRQ_HANDLED; 1419 return IRQ_HANDLED;
1420} 1420}
1421 1421
1422static int fdomain_16x0_queue(struct scsi_cmnd *SCpnt, 1422static int fdomain_16x0_queue_lck(struct scsi_cmnd *SCpnt,
1423 void (*done)(struct scsi_cmnd *)) 1423 void (*done)(struct scsi_cmnd *))
1424{ 1424{
1425 if (in_command) { 1425 if (in_command) {
@@ -1469,6 +1469,8 @@ static int fdomain_16x0_queue(struct scsi_cmnd *SCpnt,
1469 return 0; 1469 return 0;
1470} 1470}
1471 1471
1472static DEF_SCSI_QCMD(fdomain_16x0_queue)
1473
1472#if DEBUG_ABORT 1474#if DEBUG_ABORT
1473static void print_info(struct scsi_cmnd *SCpnt) 1475static void print_info(struct scsi_cmnd *SCpnt)
1474{ 1476{
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index cbb20b13b228..92f185081e62 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -246,7 +246,7 @@ void fnic_set_port_id(struct fc_lport *, u32, struct fc_frame *);
246void fnic_update_mac(struct fc_lport *, u8 *new); 246void fnic_update_mac(struct fc_lport *, u8 *new);
247void fnic_update_mac_locked(struct fnic *, u8 *new); 247void fnic_update_mac_locked(struct fnic *, u8 *new);
248 248
249int fnic_queuecommand(struct scsi_cmnd *, void (*done)(struct scsi_cmnd *)); 249int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
250int fnic_abort_cmd(struct scsi_cmnd *); 250int fnic_abort_cmd(struct scsi_cmnd *);
251int fnic_device_reset(struct scsi_cmnd *); 251int fnic_device_reset(struct scsi_cmnd *);
252int fnic_host_reset(struct scsi_cmnd *); 252int fnic_host_reset(struct scsi_cmnd *);
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 198cbab3e894..22d02404d15f 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -349,7 +349,7 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
349 * Routine to send a scsi cdb 349 * Routine to send a scsi cdb
350 * Called with host_lock held and interrupts disabled. 350 * Called with host_lock held and interrupts disabled.
351 */ 351 */
352int fnic_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) 352static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
353{ 353{
354 struct fc_lport *lp; 354 struct fc_lport *lp;
355 struct fc_rport *rport; 355 struct fc_rport *rport;
@@ -457,6 +457,8 @@ out:
457 return ret; 457 return ret;
458} 458}
459 459
460DEF_SCSI_QCMD(fnic_queuecommand)
461
460/* 462/*
461 * fnic_fcpio_fw_reset_cmpl_handler 463 * fnic_fcpio_fw_reset_cmpl_handler
462 * Routine to handle fw reset completion 464 * Routine to handle fw reset completion
diff --git a/drivers/scsi/g_NCR5380.h b/drivers/scsi/g_NCR5380.h
index 921764c9ab24..1bcdb7beb77b 100644
--- a/drivers/scsi/g_NCR5380.h
+++ b/drivers/scsi/g_NCR5380.h
@@ -46,7 +46,7 @@
46static int generic_NCR5380_abort(Scsi_Cmnd *); 46static int generic_NCR5380_abort(Scsi_Cmnd *);
47static int generic_NCR5380_detect(struct scsi_host_template *); 47static int generic_NCR5380_detect(struct scsi_host_template *);
48static int generic_NCR5380_release_resources(struct Scsi_Host *); 48static int generic_NCR5380_release_resources(struct Scsi_Host *);
49static int generic_NCR5380_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 49static int generic_NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
50static int generic_NCR5380_bus_reset(Scsi_Cmnd *); 50static int generic_NCR5380_bus_reset(Scsi_Cmnd *);
51static const char* generic_NCR5380_info(struct Scsi_Host *); 51static const char* generic_NCR5380_info(struct Scsi_Host *);
52 52
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 841101846b88..76365700e2d5 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -185,7 +185,7 @@ static long gdth_unlocked_ioctl(struct file *filep, unsigned int cmd,
185 unsigned long arg); 185 unsigned long arg);
186 186
187static void gdth_flush(gdth_ha_str *ha); 187static void gdth_flush(gdth_ha_str *ha);
188static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *)); 188static int gdth_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
189static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp, 189static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp,
190 struct gdth_cmndinfo *cmndinfo); 190 struct gdth_cmndinfo *cmndinfo);
191static void gdth_scsi_done(struct scsi_cmnd *scp); 191static void gdth_scsi_done(struct scsi_cmnd *scp);
@@ -4004,7 +4004,7 @@ static int gdth_bios_param(struct scsi_device *sdev,struct block_device *bdev,se
4004} 4004}
4005 4005
4006 4006
4007static int gdth_queuecommand(struct scsi_cmnd *scp, 4007static int gdth_queuecommand_lck(struct scsi_cmnd *scp,
4008 void (*done)(struct scsi_cmnd *)) 4008 void (*done)(struct scsi_cmnd *))
4009{ 4009{
4010 gdth_ha_str *ha = shost_priv(scp->device->host); 4010 gdth_ha_str *ha = shost_priv(scp->device->host);
@@ -4022,6 +4022,8 @@ static int gdth_queuecommand(struct scsi_cmnd *scp,
4022 return __gdth_queuecommand(ha, scp, cmndinfo); 4022 return __gdth_queuecommand(ha, scp, cmndinfo);
4023} 4023}
4024 4024
4025static DEF_SCSI_QCMD(gdth_queuecommand)
4026
4025static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp, 4027static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp,
4026 struct gdth_cmndinfo *cmndinfo) 4028 struct gdth_cmndinfo *cmndinfo)
4027{ 4029{
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index c5d0606ad097..a6dea08664fc 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -31,7 +31,6 @@
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/smp_lock.h>
35#include <linux/compat.h> 34#include <linux/compat.h>
36#include <linux/blktrace_api.h> 35#include <linux/blktrace_api.h>
37#include <linux/uaccess.h> 36#include <linux/uaccess.h>
@@ -91,11 +90,7 @@ static const struct pci_device_id hpsa_pci_device_id[] = {
91 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSE, 0x103C, 0x3252}, 90 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSE, 0x103C, 0x3252},
92 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSE, 0x103C, 0x3253}, 91 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSE, 0x103C, 0x3253},
93 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSE, 0x103C, 0x3254}, 92 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSE, 0x103C, 0x3254},
94#define PCI_DEVICE_ID_HP_CISSF 0x333f 93 {PCI_VENDOR_ID_HP, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
95 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSF, 0x103C, 0x333F},
96 {PCI_VENDOR_ID_HP, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
97 PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
98 {PCI_VENDOR_ID_COMPAQ, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
99 PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0}, 94 PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
100 {0,} 95 {0,}
101}; 96};
@@ -114,8 +109,6 @@ static struct board_type products[] = {
114 {0x3249103C, "Smart Array P812", &SA5_access}, 109 {0x3249103C, "Smart Array P812", &SA5_access},
115 {0x324a103C, "Smart Array P712m", &SA5_access}, 110 {0x324a103C, "Smart Array P712m", &SA5_access},
116 {0x324b103C, "Smart Array P711m", &SA5_access}, 111 {0x324b103C, "Smart Array P711m", &SA5_access},
117 {0x3233103C, "StorageWorks P1210m", &SA5_access},
118 {0x333F103C, "StorageWorks P1210m", &SA5_access},
119 {0x3250103C, "Smart Array", &SA5_access}, 112 {0x3250103C, "Smart Array", &SA5_access},
120 {0x3250113C, "Smart Array", &SA5_access}, 113 {0x3250113C, "Smart Array", &SA5_access},
121 {0x3250123C, "Smart Array", &SA5_access}, 114 {0x3250123C, "Smart Array", &SA5_access},
@@ -143,8 +136,7 @@ static void fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
143 void *buff, size_t size, u8 page_code, unsigned char *scsi3addr, 136 void *buff, size_t size, u8 page_code, unsigned char *scsi3addr,
144 int cmd_type); 137 int cmd_type);
145 138
146static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd, 139static int hpsa_scsi_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
147 void (*done)(struct scsi_cmnd *));
148static void hpsa_scan_start(struct Scsi_Host *); 140static void hpsa_scan_start(struct Scsi_Host *);
149static int hpsa_scan_finished(struct Scsi_Host *sh, 141static int hpsa_scan_finished(struct Scsi_Host *sh,
150 unsigned long elapsed_time); 142 unsigned long elapsed_time);
@@ -1926,7 +1918,7 @@ sglist_finished:
1926} 1918}
1927 1919
1928 1920
1929static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd, 1921static int hpsa_scsi_queue_command_lck(struct scsi_cmnd *cmd,
1930 void (*done)(struct scsi_cmnd *)) 1922 void (*done)(struct scsi_cmnd *))
1931{ 1923{
1932 struct ctlr_info *h; 1924 struct ctlr_info *h;
@@ -2020,6 +2012,8 @@ static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd,
2020 return 0; 2012 return 0;
2021} 2013}
2022 2014
2015static DEF_SCSI_QCMD(hpsa_scsi_queue_command)
2016
2023static void hpsa_scan_start(struct Scsi_Host *sh) 2017static void hpsa_scan_start(struct Scsi_Host *sh)
2024{ 2018{
2025 struct ctlr_info *h = shost_to_hba(sh); 2019 struct ctlr_info *h = shost_to_hba(sh);
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 0729f150b33a..10b65556937b 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -751,7 +751,7 @@ static void hptiop_post_req_mv(struct hptiop_hba *hba,
751 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bit, hba); 751 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bit, hba);
752} 752}
753 753
754static int hptiop_queuecommand(struct scsi_cmnd *scp, 754static int hptiop_queuecommand_lck(struct scsi_cmnd *scp,
755 void (*done)(struct scsi_cmnd *)) 755 void (*done)(struct scsi_cmnd *))
756{ 756{
757 struct Scsi_Host *host = scp->device->host; 757 struct Scsi_Host *host = scp->device->host;
@@ -819,6 +819,8 @@ cmd_done:
819 return 0; 819 return 0;
820} 820}
821 821
822static DEF_SCSI_QCMD(hptiop_queuecommand)
823
822static const char *hptiop_info(struct Scsi_Host *host) 824static const char *hptiop_info(struct Scsi_Host *host)
823{ 825{
824 return driver_name_long; 826 return driver_name_long;
diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c
index 9a4b69d4f4eb..67fc8ffd52e6 100644
--- a/drivers/scsi/ibmmca.c
+++ b/drivers/scsi/ibmmca.c
@@ -39,7 +39,7 @@
39#include <scsi/scsi_host.h> 39#include <scsi/scsi_host.h>
40 40
41/* Common forward declarations for all Linux-versions: */ 41/* Common forward declarations for all Linux-versions: */
42static int ibmmca_queuecommand (Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); 42static int ibmmca_queuecommand (struct Scsi_Host *, struct scsi_cmnd *);
43static int ibmmca_abort (Scsi_Cmnd *); 43static int ibmmca_abort (Scsi_Cmnd *);
44static int ibmmca_host_reset (Scsi_Cmnd *); 44static int ibmmca_host_reset (Scsi_Cmnd *);
45static int ibmmca_biosparam (struct scsi_device *, struct block_device *, sector_t, int *); 45static int ibmmca_biosparam (struct scsi_device *, struct block_device *, sector_t, int *);
@@ -1691,7 +1691,7 @@ static int __devexit ibmmca_remove(struct device *dev)
1691} 1691}
1692 1692
1693/* The following routine is the SCSI command queue for the midlevel driver */ 1693/* The following routine is the SCSI command queue for the midlevel driver */
1694static int ibmmca_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) 1694static int ibmmca_queuecommand_lck(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1695{ 1695{
1696 unsigned int ldn; 1696 unsigned int ldn;
1697 unsigned int scsi_cmd; 1697 unsigned int scsi_cmd;
@@ -1996,6 +1996,8 @@ static int ibmmca_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1996 return 0; 1996 return 0;
1997} 1997}
1998 1998
1999static DEF_SCSI_QCMD(ibmmca_queuecommand)
2000
1999static int __ibmmca_abort(Scsi_Cmnd * cmd) 2001static int __ibmmca_abort(Scsi_Cmnd * cmd)
2000{ 2002{
2001 /* Abort does not work, as the adapter never generates an interrupt on 2003 /* Abort does not work, as the adapter never generates an interrupt on
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 00d08b25425f..57cad7e20caa 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1606,7 +1606,7 @@ static inline int ibmvfc_host_chkready(struct ibmvfc_host *vhost)
1606 * Returns: 1606 * Returns:
1607 * 0 on success / other on failure 1607 * 0 on success / other on failure
1608 **/ 1608 **/
1609static int ibmvfc_queuecommand(struct scsi_cmnd *cmnd, 1609static int ibmvfc_queuecommand_lck(struct scsi_cmnd *cmnd,
1610 void (*done) (struct scsi_cmnd *)) 1610 void (*done) (struct scsi_cmnd *))
1611{ 1611{
1612 struct ibmvfc_host *vhost = shost_priv(cmnd->device->host); 1612 struct ibmvfc_host *vhost = shost_priv(cmnd->device->host);
@@ -1672,6 +1672,8 @@ static int ibmvfc_queuecommand(struct scsi_cmnd *cmnd,
1672 return 0; 1672 return 0;
1673} 1673}
1674 1674
1675static DEF_SCSI_QCMD(ibmvfc_queuecommand)
1676
1675/** 1677/**
1676 * ibmvfc_sync_completion - Signal that a synchronous command has completed 1678 * ibmvfc_sync_completion - Signal that a synchronous command has completed
1677 * @evt: ibmvfc event struct 1679 * @evt: ibmvfc event struct
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 67f78a470f5f..041958453e2a 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -713,7 +713,7 @@ static inline u16 lun_from_dev(struct scsi_device *dev)
713 * @cmd: struct scsi_cmnd to be executed 713 * @cmd: struct scsi_cmnd to be executed
714 * @done: Callback function to be called when cmd is completed 714 * @done: Callback function to be called when cmd is completed
715*/ 715*/
716static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd, 716static int ibmvscsi_queuecommand_lck(struct scsi_cmnd *cmnd,
717 void (*done) (struct scsi_cmnd *)) 717 void (*done) (struct scsi_cmnd *))
718{ 718{
719 struct srp_cmd *srp_cmd; 719 struct srp_cmd *srp_cmd;
@@ -766,6 +766,8 @@ static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd,
766 return ibmvscsi_send_srp_event(evt_struct, hostdata, 0); 766 return ibmvscsi_send_srp_event(evt_struct, hostdata, 0);
767} 767}
768 768
769static DEF_SCSI_QCMD(ibmvscsi_queuecommand)
770
769/* ------------------------------------------------------------ 771/* ------------------------------------------------------------
770 * Routines for driver initialization 772 * Routines for driver initialization
771 */ 773 */
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 4734ab0b3ff6..99aa0e5699bc 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -926,7 +926,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
926 return 0; 926 return 0;
927} 927}
928 928
929static int imm_queuecommand(struct scsi_cmnd *cmd, 929static int imm_queuecommand_lck(struct scsi_cmnd *cmd,
930 void (*done)(struct scsi_cmnd *)) 930 void (*done)(struct scsi_cmnd *))
931{ 931{
932 imm_struct *dev = imm_dev(cmd->device->host); 932 imm_struct *dev = imm_dev(cmd->device->host);
@@ -949,6 +949,8 @@ static int imm_queuecommand(struct scsi_cmnd *cmd,
949 return 0; 949 return 0;
950} 950}
951 951
952static DEF_SCSI_QCMD(imm_queuecommand)
953
952/* 954/*
953 * Apparently the disk->capacity attribute is off by 1 sector 955 * Apparently the disk->capacity attribute is off by 1 sector
954 * for all disk drives. We add the one here, but it should really 956 * for all disk drives. We add the one here, but it should really
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index 52bdc6df6b92..6568aab745a0 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -334,7 +334,7 @@ static uchar calc_sync_xfer(unsigned int period, unsigned int offset)
334 334
335static void in2000_execute(struct Scsi_Host *instance); 335static void in2000_execute(struct Scsi_Host *instance);
336 336
337static int in2000_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) 337static int in2000_queuecommand_lck(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
338{ 338{
339 struct Scsi_Host *instance; 339 struct Scsi_Host *instance;
340 struct IN2000_hostdata *hostdata; 340 struct IN2000_hostdata *hostdata;
@@ -431,6 +431,8 @@ static int in2000_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
431 return 0; 431 return 0;
432} 432}
433 433
434static DEF_SCSI_QCMD(in2000_queuecommand)
435
434 436
435 437
436/* 438/*
diff --git a/drivers/scsi/in2000.h b/drivers/scsi/in2000.h
index 0fb8b06b8392..5821e1fbce08 100644
--- a/drivers/scsi/in2000.h
+++ b/drivers/scsi/in2000.h
@@ -396,7 +396,7 @@ struct IN2000_hostdata {
396 flags) 396 flags)
397 397
398static int in2000_detect(struct scsi_host_template *) in2000__INIT; 398static int in2000_detect(struct scsi_host_template *) in2000__INIT;
399static int in2000_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 399static int in2000_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
400static int in2000_abort(Scsi_Cmnd *); 400static int in2000_abort(Scsi_Cmnd *);
401static void in2000_setup(char *, int *) in2000__INIT; 401static void in2000_setup(char *, int *) in2000__INIT;
402static int in2000_biosparam(struct scsi_device *, struct block_device *, 402static int in2000_biosparam(struct scsi_device *, struct block_device *,
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index 108797761b95..9627d062e16b 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2639,7 +2639,7 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c
2639 * will cause the mid layer to call us again later with the command) 2639 * will cause the mid layer to call us again later with the command)
2640 */ 2640 */
2641 2641
2642static int i91u_queuecommand(struct scsi_cmnd *cmd, 2642static int i91u_queuecommand_lck(struct scsi_cmnd *cmd,
2643 void (*done)(struct scsi_cmnd *)) 2643 void (*done)(struct scsi_cmnd *))
2644{ 2644{
2645 struct initio_host *host = (struct initio_host *) cmd->device->host->hostdata; 2645 struct initio_host *host = (struct initio_host *) cmd->device->host->hostdata;
@@ -2656,6 +2656,8 @@ static int i91u_queuecommand(struct scsi_cmnd *cmd,
2656 return 0; 2656 return 0;
2657} 2657}
2658 2658
2659static DEF_SCSI_QCMD(i91u_queuecommand)
2660
2659/** 2661/**
2660 * i91u_bus_reset - reset the SCSI bus 2662 * i91u_bus_reset - reset the SCSI bus
2661 * @cmnd: Command block we want to trigger the reset for 2663 * @cmnd: Command block we want to trigger the reset for
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index fa60d7df44be..5bbaee597e88 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -5709,7 +5709,7 @@ static void ipr_scsi_done(struct ipr_cmnd *ipr_cmd)
5709 * SCSI_MLQUEUE_DEVICE_BUSY if device is busy 5709 * SCSI_MLQUEUE_DEVICE_BUSY if device is busy
5710 * SCSI_MLQUEUE_HOST_BUSY if host is busy 5710 * SCSI_MLQUEUE_HOST_BUSY if host is busy
5711 **/ 5711 **/
5712static int ipr_queuecommand(struct scsi_cmnd *scsi_cmd, 5712static int ipr_queuecommand_lck(struct scsi_cmnd *scsi_cmd,
5713 void (*done) (struct scsi_cmnd *)) 5713 void (*done) (struct scsi_cmnd *))
5714{ 5714{
5715 struct ipr_ioa_cfg *ioa_cfg; 5715 struct ipr_ioa_cfg *ioa_cfg;
@@ -5792,6 +5792,8 @@ static int ipr_queuecommand(struct scsi_cmnd *scsi_cmd,
5792 return 0; 5792 return 0;
5793} 5793}
5794 5794
5795static DEF_SCSI_QCMD(ipr_queuecommand)
5796
5795/** 5797/**
5796 * ipr_ioctl - IOCTL handler 5798 * ipr_ioctl - IOCTL handler
5797 * @sdev: scsi device struct 5799 * @sdev: scsi device struct
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index f83a116955f2..b2511acd39bd 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -232,7 +232,7 @@ static int ips_detect(struct scsi_host_template *);
232static int ips_release(struct Scsi_Host *); 232static int ips_release(struct Scsi_Host *);
233static int ips_eh_abort(struct scsi_cmnd *); 233static int ips_eh_abort(struct scsi_cmnd *);
234static int ips_eh_reset(struct scsi_cmnd *); 234static int ips_eh_reset(struct scsi_cmnd *);
235static int ips_queue(struct scsi_cmnd *, void (*)(struct scsi_cmnd *)); 235static int ips_queue(struct Scsi_Host *, struct scsi_cmnd *);
236static const char *ips_info(struct Scsi_Host *); 236static const char *ips_info(struct Scsi_Host *);
237static irqreturn_t do_ipsintr(int, void *); 237static irqreturn_t do_ipsintr(int, void *);
238static int ips_hainit(ips_ha_t *); 238static int ips_hainit(ips_ha_t *);
@@ -1046,7 +1046,7 @@ static int ips_eh_reset(struct scsi_cmnd *SC)
1046/* Linux obtains io_request_lock before calling this function */ 1046/* Linux obtains io_request_lock before calling this function */
1047/* */ 1047/* */
1048/****************************************************************************/ 1048/****************************************************************************/
1049static int ips_queue(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *)) 1049static int ips_queue_lck(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *))
1050{ 1050{
1051 ips_ha_t *ha; 1051 ips_ha_t *ha;
1052 ips_passthru_t *pt; 1052 ips_passthru_t *pt;
@@ -1137,6 +1137,8 @@ static int ips_queue(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *))
1137 return (0); 1137 return (0);
1138} 1138}
1139 1139
1140static DEF_SCSI_QCMD(ips_queue)
1141
1140/****************************************************************************/ 1142/****************************************************************************/
1141/* */ 1143/* */
1142/* Routine Name: ips_biosparam */ 1144/* Routine Name: ips_biosparam */
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index e340373b509b..2924363d142b 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -1753,7 +1753,7 @@ static inline int fc_fcp_lport_queue_ready(struct fc_lport *lport)
1753 * This is the i/o strategy routine, called by the SCSI layer. This routine 1753 * This is the i/o strategy routine, called by the SCSI layer. This routine
1754 * is called with the host_lock held. 1754 * is called with the host_lock held.
1755 */ 1755 */
1756int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *)) 1756static int fc_queuecommand_lck(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *))
1757{ 1757{
1758 struct fc_lport *lport; 1758 struct fc_lport *lport;
1759 struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); 1759 struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
@@ -1851,6 +1851,8 @@ out:
1851 spin_lock_irq(lport->host->host_lock); 1851 spin_lock_irq(lport->host->host_lock);
1852 return rc; 1852 return rc;
1853} 1853}
1854
1855DEF_SCSI_QCMD(fc_queuecommand)
1854EXPORT_SYMBOL(fc_queuecommand); 1856EXPORT_SYMBOL(fc_queuecommand);
1855 1857
1856/** 1858/**
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 633e09036357..c15fde808c33 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1599,7 +1599,7 @@ enum {
1599 FAILURE_SESSION_NOT_READY, 1599 FAILURE_SESSION_NOT_READY,
1600}; 1600};
1601 1601
1602int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) 1602static int iscsi_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
1603{ 1603{
1604 struct iscsi_cls_session *cls_session; 1604 struct iscsi_cls_session *cls_session;
1605 struct Scsi_Host *host; 1605 struct Scsi_Host *host;
@@ -1736,6 +1736,8 @@ fault:
1736 spin_lock(host->host_lock); 1736 spin_lock(host->host_lock);
1737 return 0; 1737 return 0;
1738} 1738}
1739
1740DEF_SCSI_QCMD(iscsi_queuecommand)
1739EXPORT_SYMBOL_GPL(iscsi_queuecommand); 1741EXPORT_SYMBOL_GPL(iscsi_queuecommand);
1740 1742
1741int iscsi_change_queue_depth(struct scsi_device *sdev, int depth, int reason) 1743int iscsi_change_queue_depth(struct scsi_device *sdev, int depth, int reason)
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 55f09e92ab59..29251fabecc6 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -189,7 +189,7 @@ int sas_queue_up(struct sas_task *task)
189 * Note: XXX: Remove the host unlock/lock pair when SCSI Core can 189 * Note: XXX: Remove the host unlock/lock pair when SCSI Core can
190 * call us without holding an IRQ spinlock... 190 * call us without holding an IRQ spinlock...
191 */ 191 */
192int sas_queuecommand(struct scsi_cmnd *cmd, 192static int sas_queuecommand_lck(struct scsi_cmnd *cmd,
193 void (*scsi_done)(struct scsi_cmnd *)) 193 void (*scsi_done)(struct scsi_cmnd *))
194 __releases(host->host_lock) 194 __releases(host->host_lock)
195 __acquires(dev->sata_dev.ap->lock) 195 __acquires(dev->sata_dev.ap->lock)
@@ -254,6 +254,8 @@ out:
254 return res; 254 return res;
255} 255}
256 256
257DEF_SCSI_QCMD(sas_queuecommand)
258
257static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) 259static void sas_eh_finish_cmd(struct scsi_cmnd *cmd)
258{ 260{
259 struct sas_task *task = TO_SAS_TASK(cmd); 261 struct sas_task *task = TO_SAS_TASK(cmd);
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index f64b65a770b8..581837b3c71a 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -2899,7 +2899,7 @@ void lpfc_poll_timeout(unsigned long ptr)
2899 * SCSI_MLQUEUE_HOST_BUSY - Block all devices served by this host temporarily. 2899 * SCSI_MLQUEUE_HOST_BUSY - Block all devices served by this host temporarily.
2900 **/ 2900 **/
2901static int 2901static int
2902lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) 2902lpfc_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2903{ 2903{
2904 struct Scsi_Host *shost = cmnd->device->host; 2904 struct Scsi_Host *shost = cmnd->device->host;
2905 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 2905 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
@@ -3060,6 +3060,8 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
3060 return 0; 3060 return 0;
3061} 3061}
3062 3062
3063static DEF_SCSI_QCMD(lpfc_queuecommand)
3064
3063/** 3065/**
3064 * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point 3066 * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point
3065 * @cmnd: Pointer to scsi_cmnd data structure. 3067 * @cmnd: Pointer to scsi_cmnd data structure.
diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
index 3ddb4dc62d5d..6c42dff0f4d3 100644
--- a/drivers/scsi/mac53c94.c
+++ b/drivers/scsi/mac53c94.c
@@ -66,7 +66,7 @@ static void cmd_done(struct fsc_state *, int result);
66static void set_dma_cmds(struct fsc_state *, struct scsi_cmnd *); 66static void set_dma_cmds(struct fsc_state *, struct scsi_cmnd *);
67 67
68 68
69static int mac53c94_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 69static int mac53c94_queue_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
70{ 70{
71 struct fsc_state *state; 71 struct fsc_state *state;
72 72
@@ -99,6 +99,8 @@ static int mac53c94_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *
99 return 0; 99 return 0;
100} 100}
101 101
102static DEF_SCSI_QCMD(mac53c94_queue)
103
102static int mac53c94_host_reset(struct scsi_cmnd *cmd) 104static int mac53c94_host_reset(struct scsi_cmnd *cmd)
103{ 105{
104 struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata; 106 struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata;
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 7ceb5cf12c6b..9aa048525eb2 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -366,7 +366,7 @@ mega_runpendq(adapter_t *adapter)
366 * The command queuing entry point for the mid-layer. 366 * The command queuing entry point for the mid-layer.
367 */ 367 */
368static int 368static int
369megaraid_queue(Scsi_Cmnd *scmd, void (*done)(Scsi_Cmnd *)) 369megaraid_queue_lck(Scsi_Cmnd *scmd, void (*done)(Scsi_Cmnd *))
370{ 370{
371 adapter_t *adapter; 371 adapter_t *adapter;
372 scb_t *scb; 372 scb_t *scb;
@@ -409,6 +409,8 @@ megaraid_queue(Scsi_Cmnd *scmd, void (*done)(Scsi_Cmnd *))
409 return busy; 409 return busy;
410} 410}
411 411
412static DEF_SCSI_QCMD(megaraid_queue)
413
412/** 414/**
413 * mega_allocate_scb() 415 * mega_allocate_scb()
414 * @adapter - pointer to our soft state 416 * @adapter - pointer to our soft state
@@ -4456,7 +4458,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
4456 4458
4457 scb->idx = CMDID_INT_CMDS; 4459 scb->idx = CMDID_INT_CMDS;
4458 4460
4459 megaraid_queue(scmd, mega_internal_done); 4461 megaraid_queue_lck(scmd, mega_internal_done);
4460 4462
4461 wait_for_completion(&adapter->int_waitq); 4463 wait_for_completion(&adapter->int_waitq);
4462 4464
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 2b4a048cadf1..f5644745e24e 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -987,7 +987,7 @@ static int mega_query_adapter(adapter_t *);
987static int issue_scb(adapter_t *, scb_t *); 987static int issue_scb(adapter_t *, scb_t *);
988static int mega_setup_mailbox(adapter_t *); 988static int mega_setup_mailbox(adapter_t *);
989 989
990static int megaraid_queue (Scsi_Cmnd *, void (*)(Scsi_Cmnd *)); 990static int megaraid_queue (struct Scsi_Host *, struct scsi_cmnd *);
991static scb_t * mega_build_cmd(adapter_t *, Scsi_Cmnd *, int *); 991static scb_t * mega_build_cmd(adapter_t *, Scsi_Cmnd *, int *);
992static void __mega_runpendq(adapter_t *); 992static void __mega_runpendq(adapter_t *);
993static int issue_scb_block(adapter_t *, u_char *); 993static int issue_scb_block(adapter_t *, u_char *);
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index a7810a106b37..5708cb27d078 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -113,8 +113,7 @@ static int megaraid_mbox_fire_sync_cmd(adapter_t *);
113static void megaraid_mbox_display_scb(adapter_t *, scb_t *); 113static void megaraid_mbox_display_scb(adapter_t *, scb_t *);
114static void megaraid_mbox_setup_device_map(adapter_t *); 114static void megaraid_mbox_setup_device_map(adapter_t *);
115 115
116static int megaraid_queue_command(struct scsi_cmnd *, 116static int megaraid_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
117 void (*)(struct scsi_cmnd *));
118static scb_t *megaraid_mbox_build_cmd(adapter_t *, struct scsi_cmnd *, int *); 117static scb_t *megaraid_mbox_build_cmd(adapter_t *, struct scsi_cmnd *, int *);
119static void megaraid_mbox_runpendq(adapter_t *, scb_t *); 118static void megaraid_mbox_runpendq(adapter_t *, scb_t *);
120static void megaraid_mbox_prepare_pthru(adapter_t *, scb_t *, 119static void megaraid_mbox_prepare_pthru(adapter_t *, scb_t *,
@@ -1484,7 +1483,7 @@ mbox_post_cmd(adapter_t *adapter, scb_t *scb)
1484 * Queue entry point for mailbox based controllers. 1483 * Queue entry point for mailbox based controllers.
1485 */ 1484 */
1486static int 1485static int
1487megaraid_queue_command(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *)) 1486megaraid_queue_command_lck(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
1488{ 1487{
1489 adapter_t *adapter; 1488 adapter_t *adapter;
1490 scb_t *scb; 1489 scb_t *scb;
@@ -1513,6 +1512,8 @@ megaraid_queue_command(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
1513 return if_busy; 1512 return if_busy;
1514} 1513}
1515 1514
1515static DEF_SCSI_QCMD(megaraid_queue_command)
1516
1516/** 1517/**
1517 * megaraid_mbox_build_cmd - transform the mid-layer scsi commands 1518 * megaraid_mbox_build_cmd - transform the mid-layer scsi commands
1518 * @adapter : controller's soft state 1519 * @adapter : controller's soft state
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index eb29d5085131..7451bc096a01 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -1334,7 +1334,7 @@ megasas_dump_pending_frames(struct megasas_instance *instance)
1334 * @done: Callback entry point 1334 * @done: Callback entry point
1335 */ 1335 */
1336static int 1336static int
1337megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *)) 1337megasas_queue_command_lck(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
1338{ 1338{
1339 u32 frame_count; 1339 u32 frame_count;
1340 struct megasas_cmd *cmd; 1340 struct megasas_cmd *cmd;
@@ -1417,6 +1417,8 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
1417 return 0; 1417 return 0;
1418} 1418}
1419 1419
1420static DEF_SCSI_QCMD(megasas_queue_command)
1421
1420static struct megasas_instance *megasas_lookup_instance(u16 host_no) 1422static struct megasas_instance *megasas_lookup_instance(u16 host_no)
1421{ 1423{
1422 int i; 1424 int i;
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index 1f784fde2510..197aa1b3f0f3 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -1627,7 +1627,7 @@ static void cmd_complete(struct mesh_state *ms)
1627 * Called by midlayer with host locked to queue a new 1627 * Called by midlayer with host locked to queue a new
1628 * request 1628 * request
1629 */ 1629 */
1630static int mesh_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 1630static int mesh_queue_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
1631{ 1631{
1632 struct mesh_state *ms; 1632 struct mesh_state *ms;
1633 1633
@@ -1648,6 +1648,8 @@ static int mesh_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
1648 return 0; 1648 return 0;
1649} 1649}
1650 1650
1651static DEF_SCSI_QCMD(mesh_queue)
1652
1651/* 1653/*
1652 * Called to handle interrupts, either call by the interrupt 1654 * Called to handle interrupts, either call by the interrupt
1653 * handler (do_mesh_interrupt) or by other functions in 1655 * handler (do_mesh_interrupt) or by other functions in
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 16e99b686354..1a96a00418a4 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -3315,7 +3315,7 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status)
3315 * SCSI_MLQUEUE_HOST_BUSY if the entire host queue is full 3315 * SCSI_MLQUEUE_HOST_BUSY if the entire host queue is full
3316 */ 3316 */
3317static int 3317static int
3318_scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *)) 3318_scsih_qcmd_lck(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
3319{ 3319{
3320 struct MPT2SAS_ADAPTER *ioc = shost_priv(scmd->device->host); 3320 struct MPT2SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
3321 struct MPT2SAS_DEVICE *sas_device_priv_data; 3321 struct MPT2SAS_DEVICE *sas_device_priv_data;
@@ -3441,6 +3441,8 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
3441 return SCSI_MLQUEUE_HOST_BUSY; 3441 return SCSI_MLQUEUE_HOST_BUSY;
3442} 3442}
3443 3443
3444static DEF_SCSI_QCMD(_scsih_qcmd)
3445
3444/** 3446/**
3445 * _scsih_normalize_sense - normalize descriptor and fixed format sense data 3447 * _scsih_normalize_sense - normalize descriptor and fixed format sense data
3446 * @sense_buffer: sense data returned by target 3448 * @sense_buffer: sense data returned by target
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index d013a2aa2fd5..46cc3825638d 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -8029,7 +8029,7 @@ static int ncr53c8xx_slave_configure(struct scsi_device *device)
8029 return 0; 8029 return 0;
8030} 8030}
8031 8031
8032static int ncr53c8xx_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) 8032static int ncr53c8xx_queue_command_lck (struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
8033{ 8033{
8034 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; 8034 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
8035 unsigned long flags; 8035 unsigned long flags;
@@ -8068,6 +8068,8 @@ printk("ncr53c8xx : command successfully queued\n");
8068 return sts; 8068 return sts;
8069} 8069}
8070 8070
8071static DEF_SCSI_QCMD(ncr53c8xx_queue_command)
8072
8071irqreturn_t ncr53c8xx_intr(int irq, void *dev_id) 8073irqreturn_t ncr53c8xx_intr(int irq, void *dev_id)
8072{ 8074{
8073 unsigned long flags; 8075 unsigned long flags;
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 4c1e54545200..6b8b021400f8 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -196,8 +196,7 @@ static void __exit exit_nsp32 (void);
196static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int); 196static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int);
197 197
198static int nsp32_detect (struct pci_dev *pdev); 198static int nsp32_detect (struct pci_dev *pdev);
199static int nsp32_queuecommand(struct scsi_cmnd *, 199static int nsp32_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
200 void (*done)(struct scsi_cmnd *));
201static const char *nsp32_info (struct Scsi_Host *); 200static const char *nsp32_info (struct Scsi_Host *);
202static int nsp32_release (struct Scsi_Host *); 201static int nsp32_release (struct Scsi_Host *);
203 202
@@ -909,7 +908,7 @@ static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt)
909 return TRUE; 908 return TRUE;
910} 909}
911 910
912static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 911static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
913{ 912{
914 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; 913 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;
915 nsp32_target *target; 914 nsp32_target *target;
@@ -1050,6 +1049,8 @@ static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
1050 return 0; 1049 return 0;
1051} 1050}
1052 1051
1052static DEF_SCSI_QCMD(nsp32_queuecommand)
1053
1053/* initialize asic */ 1054/* initialize asic */
1054static int nsp32hw_init(nsp32_hw_data *data) 1055static int nsp32hw_init(nsp32_hw_data *data)
1055{ 1056{
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index 0433ea6f27c9..b37c8a3c1bb0 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -951,8 +951,8 @@ static int _osd_req_finalize_cdb_cont(struct osd_request *or, const u8 *cap_key)
951 /* create a bio for continuation segment */ 951 /* create a bio for continuation segment */
952 bio = bio_map_kern(req_q, or->cdb_cont.buff, or->cdb_cont.total_bytes, 952 bio = bio_map_kern(req_q, or->cdb_cont.buff, or->cdb_cont.total_bytes,
953 GFP_KERNEL); 953 GFP_KERNEL);
954 if (unlikely(!bio)) 954 if (IS_ERR(bio))
955 return -ENOMEM; 955 return PTR_ERR(bio);
956 956
957 bio->bi_rw |= REQ_WRITE; 957 bio->bi_rw |= REQ_WRITE;
958 958
diff --git a/drivers/scsi/pas16.h b/drivers/scsi/pas16.h
index 8dc5b1a5f5da..a04281cace2e 100644
--- a/drivers/scsi/pas16.h
+++ b/drivers/scsi/pas16.h
@@ -118,7 +118,7 @@ static int pas16_abort(Scsi_Cmnd *);
118static int pas16_biosparam(struct scsi_device *, struct block_device *, 118static int pas16_biosparam(struct scsi_device *, struct block_device *,
119 sector_t, int*); 119 sector_t, int*);
120static int pas16_detect(struct scsi_host_template *); 120static int pas16_detect(struct scsi_host_template *);
121static int pas16_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 121static int pas16_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
122static int pas16_bus_reset(Scsi_Cmnd *); 122static int pas16_bus_reset(Scsi_Cmnd *);
123 123
124#ifndef CMD_PER_LUN 124#ifndef CMD_PER_LUN
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 9326c2c14880..be3f33d31a99 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -184,7 +184,7 @@ static void nsp_scsi_done(struct scsi_cmnd *SCpnt)
184 SCpnt->scsi_done(SCpnt); 184 SCpnt->scsi_done(SCpnt);
185} 185}
186 186
187static int nsp_queuecommand(struct scsi_cmnd *SCpnt, 187static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt,
188 void (*done)(struct scsi_cmnd *)) 188 void (*done)(struct scsi_cmnd *))
189{ 189{
190#ifdef NSP_DEBUG 190#ifdef NSP_DEBUG
@@ -264,6 +264,8 @@ static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
264 return 0; 264 return 0;
265} 265}
266 266
267static DEF_SCSI_QCMD(nsp_queuecommand)
268
267/* 269/*
268 * setup PIO FIFO transfer mode and enable/disable to data out 270 * setup PIO FIFO transfer mode and enable/disable to data out
269 */ 271 */
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index d68c9f267c5e..7fc9a9d0a448 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -299,8 +299,7 @@ static int nsp_proc_info (
299 off_t offset, 299 off_t offset,
300 int length, 300 int length,
301 int inout); 301 int inout);
302static int nsp_queuecommand(struct scsi_cmnd *SCpnt, 302static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
303 void (* done)(struct scsi_cmnd *SCpnt));
304 303
305/* Error handler */ 304/* Error handler */
306/*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/ 305/*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 0ae27cb5cd6f..8552296edaa1 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -547,7 +547,7 @@ SYM53C500_info(struct Scsi_Host *SChost)
547} 547}
548 548
549static int 549static int
550SYM53C500_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) 550SYM53C500_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
551{ 551{
552 int i; 552 int i;
553 int port_base = SCpnt->device->host->io_port; 553 int port_base = SCpnt->device->host->io_port;
@@ -583,6 +583,8 @@ SYM53C500_queue(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
583 return 0; 583 return 0;
584} 584}
585 585
586static DEF_SCSI_QCMD(SYM53C500_queue)
587
586static int 588static int
587SYM53C500_host_reset(struct scsi_cmnd *SCpnt) 589SYM53C500_host_reset(struct scsi_cmnd *SCpnt)
588{ 590{
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index 8e38ca8cd101..7f064f9ca828 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -50,7 +50,6 @@
50#include <linux/dma-mapping.h> 50#include <linux/dma-mapping.h>
51#include <linux/pci.h> 51#include <linux/pci.h>
52#include <linux/interrupt.h> 52#include <linux/interrupt.h>
53#include <linux/smp_lock.h>
54#include <scsi/libsas.h> 53#include <scsi/libsas.h>
55#include <scsi/scsi_tcq.h> 54#include <scsi/scsi_tcq.h>
56#include <scsi/sas_ata.h> 55#include <scsi/sas_ata.h>
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index cf89091e4c3d..300d59f389da 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -62,6 +62,7 @@
62static unsigned int pmcraid_debug_log; 62static unsigned int pmcraid_debug_log;
63static unsigned int pmcraid_disable_aen; 63static unsigned int pmcraid_disable_aen;
64static unsigned int pmcraid_log_level = IOASC_LOG_LEVEL_MUST; 64static unsigned int pmcraid_log_level = IOASC_LOG_LEVEL_MUST;
65static unsigned int pmcraid_enable_msix;
65 66
66/* 67/*
67 * Data structures to support multiple adapters by the LLD. 68 * Data structures to support multiple adapters by the LLD.
@@ -3478,7 +3479,7 @@ static int pmcraid_copy_sglist(
3478 * SCSI_MLQUEUE_DEVICE_BUSY if device is busy 3479 * SCSI_MLQUEUE_DEVICE_BUSY if device is busy
3479 * SCSI_MLQUEUE_HOST_BUSY if host is busy 3480 * SCSI_MLQUEUE_HOST_BUSY if host is busy
3480 */ 3481 */
3481static int pmcraid_queuecommand( 3482static int pmcraid_queuecommand_lck(
3482 struct scsi_cmnd *scsi_cmd, 3483 struct scsi_cmnd *scsi_cmd,
3483 void (*done) (struct scsi_cmnd *) 3484 void (*done) (struct scsi_cmnd *)
3484) 3485)
@@ -3584,6 +3585,8 @@ static int pmcraid_queuecommand(
3584 return rc; 3585 return rc;
3585} 3586}
3586 3587
3588static DEF_SCSI_QCMD(pmcraid_queuecommand)
3589
3587/** 3590/**
3588 * pmcraid_open -char node "open" entry, allowed only users with admin access 3591 * pmcraid_open -char node "open" entry, allowed only users with admin access
3589 */ 3592 */
@@ -4689,7 +4692,8 @@ pmcraid_register_interrupt_handler(struct pmcraid_instance *pinstance)
4689 int rc; 4692 int rc;
4690 struct pci_dev *pdev = pinstance->pdev; 4693 struct pci_dev *pdev = pinstance->pdev;
4691 4694
4692 if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { 4695 if ((pmcraid_enable_msix) &&
4696 (pci_find_capability(pdev, PCI_CAP_ID_MSIX))) {
4693 int num_hrrq = PMCRAID_NUM_MSIX_VECTORS; 4697 int num_hrrq = PMCRAID_NUM_MSIX_VECTORS;
4694 struct msix_entry entries[PMCRAID_NUM_MSIX_VECTORS]; 4698 struct msix_entry entries[PMCRAID_NUM_MSIX_VECTORS];
4695 int i; 4699 int i;
diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
index 1134279604e8..4db210d93947 100644
--- a/drivers/scsi/pmcraid.h
+++ b/drivers/scsi/pmcraid.h
@@ -42,7 +42,7 @@
42 */ 42 */
43#define PMCRAID_DRIVER_NAME "PMC MaxRAID" 43#define PMCRAID_DRIVER_NAME "PMC MaxRAID"
44#define PMCRAID_DEVFILE "pmcsas" 44#define PMCRAID_DEVFILE "pmcsas"
45#define PMCRAID_DRIVER_VERSION "2.0.3" 45#define PMCRAID_DRIVER_VERSION "1.0.3"
46#define PMCRAID_DRIVER_DATE __DATE__ 46#define PMCRAID_DRIVER_DATE __DATE__
47 47
48#define PMCRAID_FW_VERSION_1 0x002 48#define PMCRAID_FW_VERSION_1 0x002
@@ -333,11 +333,9 @@ struct pmcraid_config_table_entry {
333 __u8 lun[PMCRAID_LUN_LEN]; 333 __u8 lun[PMCRAID_LUN_LEN];
334} __attribute__((packed, aligned(4))); 334} __attribute__((packed, aligned(4)));
335 335
336/* extended configuration table sizes are of 64 bytes in size */ 336/* extended configuration table sizes are also of 32 bytes in size */
337#define PMCRAID_CFGTE_EXT_SIZE 32
338struct pmcraid_config_table_entry_ext { 337struct pmcraid_config_table_entry_ext {
339 struct pmcraid_config_table_entry cfgte; 338 struct pmcraid_config_table_entry cfgte;
340 __u8 cfgte_ext[PMCRAID_CFGTE_EXT_SIZE];
341}; 339};
342 340
343/* resource types (config_table_entry.resource_type values) */ 341/* resource types (config_table_entry.resource_type values) */
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 7bc2d796e403..d164c9639361 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -798,7 +798,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
798 return 0; 798 return 0;
799} 799}
800 800
801static int ppa_queuecommand(struct scsi_cmnd *cmd, 801static int ppa_queuecommand_lck(struct scsi_cmnd *cmd,
802 void (*done) (struct scsi_cmnd *)) 802 void (*done) (struct scsi_cmnd *))
803{ 803{
804 ppa_struct *dev = ppa_dev(cmd->device->host); 804 ppa_struct *dev = ppa_dev(cmd->device->host);
@@ -821,6 +821,8 @@ static int ppa_queuecommand(struct scsi_cmnd *cmd,
821 return 0; 821 return 0;
822} 822}
823 823
824static DEF_SCSI_QCMD(ppa_queuecommand)
825
824/* 826/*
825 * Apparently the disk->capacity attribute is off by 1 sector 827 * Apparently the disk->capacity attribute is off by 1 sector
826 * for all disk drives. We add the one here, but it should really 828 * for all disk drives. We add the one here, but it should really
diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c
index 92ffbb510498..cd178b9e40cd 100644
--- a/drivers/scsi/ps3rom.c
+++ b/drivers/scsi/ps3rom.c
@@ -211,7 +211,7 @@ static int ps3rom_write_request(struct ps3_storage_device *dev,
211 return 0; 211 return 0;
212} 212}
213 213
214static int ps3rom_queuecommand(struct scsi_cmnd *cmd, 214static int ps3rom_queuecommand_lck(struct scsi_cmnd *cmd,
215 void (*done)(struct scsi_cmnd *)) 215 void (*done)(struct scsi_cmnd *))
216{ 216{
217 struct ps3rom_private *priv = shost_priv(cmd->device->host); 217 struct ps3rom_private *priv = shost_priv(cmd->device->host);
@@ -260,6 +260,8 @@ static int ps3rom_queuecommand(struct scsi_cmnd *cmd,
260 return 0; 260 return 0;
261} 261}
262 262
263static DEF_SCSI_QCMD(ps3rom_queuecommand)
264
263static int decode_lv1_status(u64 status, unsigned char *sense_key, 265static int decode_lv1_status(u64 status, unsigned char *sense_key,
264 unsigned char *asc, unsigned char *ascq) 266 unsigned char *asc, unsigned char *ascq)
265{ 267{
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index b8166ecfd0e3..5dec684bf010 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -727,7 +727,7 @@ qla1280_info(struct Scsi_Host *host)
727 * context which is a big NO! NO!. 727 * context which is a big NO! NO!.
728 **************************************************************************/ 728 **************************************************************************/
729static int 729static int
730qla1280_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)) 730qla1280_queuecommand_lck(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
731{ 731{
732 struct Scsi_Host *host = cmd->device->host; 732 struct Scsi_Host *host = cmd->device->host;
733 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata; 733 struct scsi_qla_host *ha = (struct scsi_qla_host *)host->hostdata;
@@ -756,6 +756,8 @@ qla1280_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))
756 return status; 756 return status;
757} 757}
758 758
759static DEF_SCSI_QCMD(qla1280_queuecommand)
760
759enum action { 761enum action {
760 ABORT_COMMAND, 762 ABORT_COMMAND,
761 DEVICE_RESET, 763 DEVICE_RESET,
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 3a22effced5f..9ce539d4557e 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2409,7 +2409,6 @@ struct qla_hw_data {
2409 uint32_t enable_target_reset :1; 2409 uint32_t enable_target_reset :1;
2410 uint32_t enable_lip_full_login :1; 2410 uint32_t enable_lip_full_login :1;
2411 uint32_t enable_led_scheme :1; 2411 uint32_t enable_led_scheme :1;
2412 uint32_t inta_enabled :1;
2413 uint32_t msi_enabled :1; 2412 uint32_t msi_enabled :1;
2414 uint32_t msix_enabled :1; 2413 uint32_t msix_enabled :1;
2415 uint32_t disable_serdes :1; 2414 uint32_t disable_serdes :1;
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 5f94430b42f0..4c1ba6263eb3 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -1061,6 +1061,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
1061 fcp_cmnd->additional_cdb_len |= 2; 1061 fcp_cmnd->additional_cdb_len |= 2;
1062 1062
1063 int_to_scsilun(sp->cmd->device->lun, &fcp_cmnd->lun); 1063 int_to_scsilun(sp->cmd->device->lun, &fcp_cmnd->lun);
1064 host_to_fcp_swap((uint8_t *)&fcp_cmnd->lun, sizeof(fcp_cmnd->lun));
1064 memcpy(fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); 1065 memcpy(fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len);
1065 cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(fcp_cmnd_len); 1066 cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(fcp_cmnd_len);
1066 cmd_pkt->fcp_cmnd_dseg_address[0] = cpu_to_le32( 1067 cmd_pkt->fcp_cmnd_dseg_address[0] = cpu_to_le32(
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 1f06ddd9bdd1..7f77898486a9 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2491,14 +2491,15 @@ skip_msix:
2491skip_msi: 2491skip_msi:
2492 2492
2493 ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler, 2493 ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler,
2494 IRQF_SHARED, QLA2XXX_DRIVER_NAME, rsp); 2494 ha->flags.msi_enabled ? 0 : IRQF_SHARED,
2495 QLA2XXX_DRIVER_NAME, rsp);
2495 if (ret) { 2496 if (ret) {
2496 qla_printk(KERN_WARNING, ha, 2497 qla_printk(KERN_WARNING, ha,
2497 "Failed to reserve interrupt %d already in use.\n", 2498 "Failed to reserve interrupt %d already in use.\n",
2498 ha->pdev->irq); 2499 ha->pdev->irq);
2499 goto fail; 2500 goto fail;
2500 } 2501 }
2501 ha->flags.inta_enabled = 1; 2502
2502clear_risc_ints: 2503clear_risc_ints:
2503 2504
2504 /* 2505 /*
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
index 8d9edfb39803..ae2acacc0003 100644
--- a/drivers/scsi/qla2xxx/qla_nx.c
+++ b/drivers/scsi/qla2xxx/qla_nx.c
@@ -2749,6 +2749,7 @@ sufficient_dsds:
2749 goto queuing_error_fcp_cmnd; 2749 goto queuing_error_fcp_cmnd;
2750 2750
2751 int_to_scsilun(sp->cmd->device->lun, &cmd_pkt->lun); 2751 int_to_scsilun(sp->cmd->device->lun, &cmd_pkt->lun);
2752 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun));
2752 2753
2753 /* build FCP_CMND IU */ 2754 /* build FCP_CMND IU */
2754 memset(ctx->fcp_cmnd, 0, sizeof(struct fcp_cmnd)); 2755 memset(ctx->fcp_cmnd, 0, sizeof(struct fcp_cmnd));
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 1830e6e97315..2c0876c81a3f 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -179,8 +179,7 @@ static int qla2xxx_slave_alloc(struct scsi_device *);
179static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); 179static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
180static void qla2xxx_scan_start(struct Scsi_Host *); 180static void qla2xxx_scan_start(struct Scsi_Host *);
181static void qla2xxx_slave_destroy(struct scsi_device *); 181static void qla2xxx_slave_destroy(struct scsi_device *);
182static int qla2xxx_queuecommand(struct scsi_cmnd *cmd, 182static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
183 void (*fn)(struct scsi_cmnd *));
184static int qla2xxx_eh_abort(struct scsi_cmnd *); 183static int qla2xxx_eh_abort(struct scsi_cmnd *);
185static int qla2xxx_eh_device_reset(struct scsi_cmnd *); 184static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
186static int qla2xxx_eh_target_reset(struct scsi_cmnd *); 185static int qla2xxx_eh_target_reset(struct scsi_cmnd *);
@@ -535,7 +534,7 @@ qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport,
535} 534}
536 535
537static int 536static int
538qla2xxx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 537qla2xxx_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
539{ 538{
540 scsi_qla_host_t *vha = shost_priv(cmd->device->host); 539 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
541 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; 540 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
@@ -609,6 +608,8 @@ qc24_fail_command:
609 return 0; 608 return 0;
610} 609}
611 610
611static DEF_SCSI_QCMD(qla2xxx_queuecommand)
612
612 613
613/* 614/*
614 * qla2x00_eh_wait_on_command 615 * qla2x00_eh_wait_on_command
@@ -828,7 +829,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
828{ 829{
829 scsi_qla_host_t *vha = shost_priv(cmd->device->host); 830 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
830 srb_t *sp; 831 srb_t *sp;
831 int ret; 832 int ret = SUCCESS;
832 unsigned int id, lun; 833 unsigned int id, lun;
833 unsigned long flags; 834 unsigned long flags;
834 int wait = 0; 835 int wait = 0;
@@ -2063,6 +2064,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2063 ha->init_cb_size = sizeof(struct mid_init_cb_81xx); 2064 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
2064 ha->gid_list_info_size = 8; 2065 ha->gid_list_info_size = 8;
2065 ha->optrom_size = OPTROM_SIZE_82XX; 2066 ha->optrom_size = OPTROM_SIZE_82XX;
2067 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX;
2066 ha->isp_ops = &qla82xx_isp_ops; 2068 ha->isp_ops = &qla82xx_isp_ops;
2067 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; 2069 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
2068 ha->flash_data_off = FARX_ACCESS_FLASH_DATA; 2070 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 8edbccb3232d..cf0075a2d0c2 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,9 +7,9 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.03.04-k0" 10#define QLA2XXX_VERSION "8.03.05-k0"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 3 13#define QLA_DRIVER_MINOR_VER 3
14#define QLA_DRIVER_PATCH_VER 4 14#define QLA_DRIVER_PATCH_VER 5
15#define QLA_DRIVER_BETA_VER 0 15#define QLA_DRIVER_BETA_VER 0
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index f4cd846abf6d..0d48fb4d1044 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -79,8 +79,7 @@ static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc);
79/* 79/*
80 * SCSI host template entry points 80 * SCSI host template entry points
81 */ 81 */
82static int qla4xxx_queuecommand(struct scsi_cmnd *cmd, 82static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
83 void (*done) (struct scsi_cmnd *));
84static int qla4xxx_eh_abort(struct scsi_cmnd *cmd); 83static int qla4xxx_eh_abort(struct scsi_cmnd *cmd);
85static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd); 84static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd);
86static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd); 85static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd);
@@ -464,7 +463,7 @@ void qla4xxx_srb_compl(struct kref *ref)
464 * completion handling). Unfortunely, it sometimes calls the scheduler 463 * completion handling). Unfortunely, it sometimes calls the scheduler
465 * in interrupt context which is a big NO! NO!. 464 * in interrupt context which is a big NO! NO!.
466 **/ 465 **/
467static int qla4xxx_queuecommand(struct scsi_cmnd *cmd, 466static int qla4xxx_queuecommand_lck(struct scsi_cmnd *cmd,
468 void (*done)(struct scsi_cmnd *)) 467 void (*done)(struct scsi_cmnd *))
469{ 468{
470 struct scsi_qla_host *ha = to_qla_host(cmd->device->host); 469 struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
@@ -538,6 +537,8 @@ qc_fail_command:
538 return 0; 537 return 0;
539} 538}
540 539
540static DEF_SCSI_QCMD(qla4xxx_queuecommand)
541
541/** 542/**
542 * qla4xxx_mem_free - frees memory allocated to adapter 543 * qla4xxx_mem_free - frees memory allocated to adapter
543 * @ha: Pointer to host adapter structure. 544 * @ha: Pointer to host adapter structure.
diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index 1ad51552d6b1..c3a9151ca823 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -439,7 +439,7 @@ irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id)
439 * Queued command 439 * Queued command
440 */ 440 */
441 441
442int qlogicfas408_queuecommand(struct scsi_cmnd *cmd, 442static int qlogicfas408_queuecommand_lck(struct scsi_cmnd *cmd,
443 void (*done) (struct scsi_cmnd *)) 443 void (*done) (struct scsi_cmnd *))
444{ 444{
445 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 445 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
@@ -459,6 +459,8 @@ int qlogicfas408_queuecommand(struct scsi_cmnd *cmd,
459 return 0; 459 return 0;
460} 460}
461 461
462DEF_SCSI_QCMD(qlogicfas408_queuecommand)
463
462/* 464/*
463 * Return bios parameters 465 * Return bios parameters
464 */ 466 */
diff --git a/drivers/scsi/qlogicfas408.h b/drivers/scsi/qlogicfas408.h
index 260626427a32..2f6c0a166200 100644
--- a/drivers/scsi/qlogicfas408.h
+++ b/drivers/scsi/qlogicfas408.h
@@ -103,8 +103,7 @@ struct qlogicfas408_priv {
103#define get_priv_by_host(x) (struct qlogicfas408_priv *)&((x)->hostdata[0]) 103#define get_priv_by_host(x) (struct qlogicfas408_priv *)&((x)->hostdata[0])
104 104
105irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id); 105irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id);
106int qlogicfas408_queuecommand(struct scsi_cmnd * cmd, 106int qlogicfas408_queuecommand(struct Scsi_Host *h, struct scsi_cmnd * cmd);
107 void (*done) (struct scsi_cmnd *));
108int qlogicfas408_biosparam(struct scsi_device * disk, 107int qlogicfas408_biosparam(struct scsi_device * disk,
109 struct block_device *dev, 108 struct block_device *dev,
110 sector_t capacity, int ip[]); 109 sector_t capacity, int ip[]);
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index f8c561cf751e..664c9572d0c9 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1003,7 +1003,7 @@ static int qlogicpti_slave_configure(struct scsi_device *sdev)
1003 * 1003 *
1004 * "This code must fly." -davem 1004 * "This code must fly." -davem
1005 */ 1005 */
1006static int qlogicpti_queuecommand(struct scsi_cmnd *Cmnd, void (*done)(struct scsi_cmnd *)) 1006static int qlogicpti_queuecommand_lck(struct scsi_cmnd *Cmnd, void (*done)(struct scsi_cmnd *))
1007{ 1007{
1008 struct Scsi_Host *host = Cmnd->device->host; 1008 struct Scsi_Host *host = Cmnd->device->host;
1009 struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata; 1009 struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
@@ -1052,6 +1052,8 @@ toss_command:
1052 return 1; 1052 return 1;
1053} 1053}
1054 1054
1055static DEF_SCSI_QCMD(qlogicpti_queuecommand)
1056
1055static int qlogicpti_return_status(struct Status_Entry *sts, int id) 1057static int qlogicpti_return_status(struct Status_Entry *sts, int id)
1056{ 1058{
1057 int host_status = DID_ERROR; 1059 int host_status = DID_ERROR;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 348fba0a8976..2aeb2e9c4d3b 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -634,12 +634,13 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
634 * Description: a serial number identifies a request for error recovery 634 * Description: a serial number identifies a request for error recovery
635 * and debugging purposes. Protected by the Host_Lock of host. 635 * and debugging purposes. Protected by the Host_Lock of host.
636 */ 636 */
637static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd) 637void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd)
638{ 638{
639 cmd->serial_number = host->cmd_serial_number++; 639 cmd->serial_number = host->cmd_serial_number++;
640 if (cmd->serial_number == 0) 640 if (cmd->serial_number == 0)
641 cmd->serial_number = host->cmd_serial_number++; 641 cmd->serial_number = host->cmd_serial_number++;
642} 642}
643EXPORT_SYMBOL(scsi_cmd_get_serial);
643 644
644/** 645/**
645 * scsi_dispatch_command - Dispatch a command to the low-level driver. 646 * scsi_dispatch_command - Dispatch a command to the low-level driver.
@@ -651,7 +652,6 @@ static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd
651int scsi_dispatch_cmd(struct scsi_cmnd *cmd) 652int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
652{ 653{
653 struct Scsi_Host *host = cmd->device->host; 654 struct Scsi_Host *host = cmd->device->host;
654 unsigned long flags = 0;
655 unsigned long timeout; 655 unsigned long timeout;
656 int rtn = 0; 656 int rtn = 0;
657 657
@@ -737,23 +737,15 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
737 goto out; 737 goto out;
738 } 738 }
739 739
740 spin_lock_irqsave(host->host_lock, flags);
741 /*
742 * AK: unlikely race here: for some reason the timer could
743 * expire before the serial number is set up below.
744 *
745 * TODO: kill serial or move to blk layer
746 */
747 scsi_cmd_get_serial(host, cmd);
748
749 if (unlikely(host->shost_state == SHOST_DEL)) { 740 if (unlikely(host->shost_state == SHOST_DEL)) {
750 cmd->result = (DID_NO_CONNECT << 16); 741 cmd->result = (DID_NO_CONNECT << 16);
751 scsi_done(cmd); 742 scsi_done(cmd);
752 } else { 743 } else {
753 trace_scsi_dispatch_cmd_start(cmd); 744 trace_scsi_dispatch_cmd_start(cmd);
754 rtn = host->hostt->queuecommand(cmd, scsi_done); 745 cmd->scsi_done = scsi_done;
746 rtn = host->hostt->queuecommand(host, cmd);
755 } 747 }
756 spin_unlock_irqrestore(host->host_lock, flags); 748
757 if (rtn) { 749 if (rtn) {
758 trace_scsi_dispatch_cmd_error(cmd, rtn); 750 trace_scsi_dispatch_cmd_error(cmd, rtn);
759 if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && 751 if (rtn != SCSI_MLQUEUE_DEVICE_BUSY &&
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 2c36bae3bd4b..2f1f9b079b10 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -3538,7 +3538,7 @@ static void sdebug_remove_adapter(void)
3538} 3538}
3539 3539
3540static 3540static
3541int scsi_debug_queuecommand(struct scsi_cmnd *SCpnt, done_funct_t done) 3541int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
3542{ 3542{
3543 unsigned char *cmd = (unsigned char *) SCpnt->cmnd; 3543 unsigned char *cmd = (unsigned char *) SCpnt->cmnd;
3544 int len, k; 3544 int len, k;
@@ -3884,6 +3884,8 @@ write:
3884 (delay_override ? 0 : scsi_debug_delay)); 3884 (delay_override ? 0 : scsi_debug_delay));
3885} 3885}
3886 3886
3887static DEF_SCSI_QCMD(scsi_debug_queuecommand)
3888
3887static struct scsi_host_template sdebug_driver_template = { 3889static struct scsi_host_template sdebug_driver_template = {
3888 .proc_info = scsi_debug_proc_info, 3890 .proc_info = scsi_debug_proc_info,
3889 .proc_name = sdebug_proc_name, 3891 .proc_name = sdebug_proc_name,
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index f3cf924a2cd9..30ac116186f5 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -615,7 +615,7 @@ static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
615 return rtn; 615 return rtn;
616} 616}
617 617
618static int __scsi_try_to_abort_cmd(struct scsi_cmnd *scmd) 618static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)
619{ 619{
620 if (!scmd->device->host->hostt->eh_abort_handler) 620 if (!scmd->device->host->hostt->eh_abort_handler)
621 return FAILED; 621 return FAILED;
@@ -623,31 +623,9 @@ static int __scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)
623 return scmd->device->host->hostt->eh_abort_handler(scmd); 623 return scmd->device->host->hostt->eh_abort_handler(scmd);
624} 624}
625 625
626/**
627 * scsi_try_to_abort_cmd - Ask host to abort a running command.
628 * @scmd: SCSI cmd to abort from Lower Level.
629 *
630 * Notes:
631 * This function will not return until the user's completion function
632 * has been called. there is no timeout on this operation. if the
633 * author of the low-level driver wishes this operation to be timed,
634 * they can provide this facility themselves. helper functions in
635 * scsi_error.c can be supplied to make this easier to do.
636 */
637static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)
638{
639 /*
640 * scsi_done was called just after the command timed out and before
641 * we had a chance to process it. (db)
642 */
643 if (scmd->serial_number == 0)
644 return SUCCESS;
645 return __scsi_try_to_abort_cmd(scmd);
646}
647
648static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) 626static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd)
649{ 627{
650 if (__scsi_try_to_abort_cmd(scmd) != SUCCESS) 628 if (scsi_try_to_abort_cmd(scmd) != SUCCESS)
651 if (scsi_try_bus_device_reset(scmd) != SUCCESS) 629 if (scsi_try_bus_device_reset(scmd) != SUCCESS)
652 if (scsi_try_target_reset(scmd) != SUCCESS) 630 if (scsi_try_target_reset(scmd) != SUCCESS)
653 if (scsi_try_bus_reset(scmd) != SUCCESS) 631 if (scsi_try_bus_reset(scmd) != SUCCESS)
@@ -773,17 +751,15 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
773 struct Scsi_Host *shost = sdev->host; 751 struct Scsi_Host *shost = sdev->host;
774 DECLARE_COMPLETION_ONSTACK(done); 752 DECLARE_COMPLETION_ONSTACK(done);
775 unsigned long timeleft; 753 unsigned long timeleft;
776 unsigned long flags;
777 struct scsi_eh_save ses; 754 struct scsi_eh_save ses;
778 int rtn; 755 int rtn;
779 756
780 scsi_eh_prep_cmnd(scmd, &ses, cmnd, cmnd_size, sense_bytes); 757 scsi_eh_prep_cmnd(scmd, &ses, cmnd, cmnd_size, sense_bytes);
781 shost->eh_action = &done; 758 shost->eh_action = &done;
782 759
783 spin_lock_irqsave(shost->host_lock, flags);
784 scsi_log_send(scmd); 760 scsi_log_send(scmd);
785 shost->hostt->queuecommand(scmd, scsi_eh_done); 761 scmd->scsi_done = scsi_eh_done;
786 spin_unlock_irqrestore(shost->host_lock, flags); 762 shost->hostt->queuecommand(shost, scmd);
787 763
788 timeleft = wait_for_completion_timeout(&done, timeout); 764 timeleft = wait_for_completion_timeout(&done, timeout);
789 765
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index eafeeda6e194..4a3842212c50 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1403,11 +1403,6 @@ static void scsi_softirq_done(struct request *rq)
1403 1403
1404 INIT_LIST_HEAD(&cmd->eh_entry); 1404 INIT_LIST_HEAD(&cmd->eh_entry);
1405 1405
1406 /*
1407 * Set the serial numbers back to zero
1408 */
1409 cmd->serial_number = 0;
1410
1411 atomic_inc(&cmd->device->iodone_cnt); 1406 atomic_inc(&cmd->device->iodone_cnt);
1412 if (cmd->result) 1407 if (cmd->result)
1413 atomic_inc(&cmd->device->ioerr_cnt); 1408 atomic_inc(&cmd->device->ioerr_cnt);
@@ -1642,9 +1637,8 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
1642 1637
1643 blk_queue_max_segment_size(q, dma_get_max_seg_size(dev)); 1638 blk_queue_max_segment_size(q, dma_get_max_seg_size(dev));
1644 1639
1645 /* New queue, no concurrency on queue_flags */
1646 if (!shost->use_clustering) 1640 if (!shost->use_clustering)
1647 queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q); 1641 q->limits.cluster = 0;
1648 1642
1649 /* 1643 /*
1650 * set a reasonable default alignment on word boundaries: the 1644 * set a reasonable default alignment on word boundaries: the
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b9ab3a590e4b..956496182c80 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -46,7 +46,6 @@
46#include <linux/blkdev.h> 46#include <linux/blkdev.h>
47#include <linux/blkpg.h> 47#include <linux/blkpg.h>
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/smp_lock.h>
50#include <linux/mutex.h> 49#include <linux/mutex.h>
51#include <linux/string_helpers.h> 50#include <linux/string_helpers.h>
52#include <linux/async.h> 51#include <linux/async.h>
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 9c73dbda3bbb..606215e54b88 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -572,7 +572,7 @@ stex_slave_destroy(struct scsi_device *sdev)
572} 572}
573 573
574static int 574static int
575stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) 575stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
576{ 576{
577 struct st_hba *hba; 577 struct st_hba *hba;
578 struct Scsi_Host *host; 578 struct Scsi_Host *host;
@@ -698,6 +698,8 @@ stex_queuecommand(struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
698 return 0; 698 return 0;
699} 699}
700 700
701static DEF_SCSI_QCMD(stex_queuecommand)
702
701static void stex_scsi_done(struct st_ccb *ccb) 703static void stex_scsi_done(struct st_ccb *ccb)
702{ 704{
703 struct scsi_cmnd *cmd = ccb->cmd; 705 struct scsi_cmnd *cmd = ccb->cmd;
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 713620ed70d9..4f0e5485ffde 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -908,7 +908,7 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)
908 */ 908 */
909 909
910/* Only make static if a wrapper function is used */ 910/* Only make static if a wrapper function is used */
911static int NCR5380_queue_command(struct scsi_cmnd *cmd, 911static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd,
912 void (*done)(struct scsi_cmnd *)) 912 void (*done)(struct scsi_cmnd *))
913{ 913{
914 SETUP_HOSTDATA(cmd->device->host); 914 SETUP_HOSTDATA(cmd->device->host);
@@ -1019,6 +1019,8 @@ static int NCR5380_queue_command(struct scsi_cmnd *cmd,
1019 return 0; 1019 return 0;
1020} 1020}
1021 1021
1022static DEF_SCSI_QCMD(NCR5380_queue_command)
1023
1022/* 1024/*
1023 * Function : NCR5380_main (void) 1025 * Function : NCR5380_main (void)
1024 * 1026 *
diff --git a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h
index b29a9d661ca4..bcefd8458e65 100644
--- a/drivers/scsi/sun3_scsi.h
+++ b/drivers/scsi/sun3_scsi.h
@@ -51,8 +51,7 @@ static int sun3scsi_abort(struct scsi_cmnd *);
51static int sun3scsi_detect (struct scsi_host_template *); 51static int sun3scsi_detect (struct scsi_host_template *);
52static const char *sun3scsi_info (struct Scsi_Host *); 52static const char *sun3scsi_info (struct Scsi_Host *);
53static int sun3scsi_bus_reset(struct scsi_cmnd *); 53static int sun3scsi_bus_reset(struct scsi_cmnd *);
54static int sun3scsi_queue_command(struct scsi_cmnd *, 54static int sun3scsi_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
55 void (*done)(struct scsi_cmnd *));
56static int sun3scsi_release (struct Scsi_Host *); 55static int sun3scsi_release (struct Scsi_Host *);
57 56
58#ifndef CMD_PER_LUN 57#ifndef CMD_PER_LUN
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c
index e5c369bb568f..190107ae120b 100644
--- a/drivers/scsi/sym53c416.c
+++ b/drivers/scsi/sym53c416.c
@@ -734,7 +734,7 @@ const char *sym53c416_info(struct Scsi_Host *SChost)
734 return info; 734 return info;
735} 735}
736 736
737int sym53c416_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 737static int sym53c416_queuecommand_lck(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
738{ 738{
739 int base; 739 int base;
740 unsigned long flags = 0; 740 unsigned long flags = 0;
@@ -761,6 +761,8 @@ int sym53c416_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
761 return 0; 761 return 0;
762} 762}
763 763
764DEF_SCSI_QCMD(sym53c416_queuecommand)
765
764static int sym53c416_host_reset(Scsi_Cmnd *SCpnt) 766static int sym53c416_host_reset(Scsi_Cmnd *SCpnt)
765{ 767{
766 int base; 768 int base;
diff --git a/drivers/scsi/sym53c416.h b/drivers/scsi/sym53c416.h
index 77860d0748ff..387de5d80a70 100644
--- a/drivers/scsi/sym53c416.h
+++ b/drivers/scsi/sym53c416.h
@@ -25,7 +25,7 @@
25static int sym53c416_detect(struct scsi_host_template *); 25static int sym53c416_detect(struct scsi_host_template *);
26static const char *sym53c416_info(struct Scsi_Host *); 26static const char *sym53c416_info(struct Scsi_Host *);
27static int sym53c416_release(struct Scsi_Host *); 27static int sym53c416_release(struct Scsi_Host *);
28static int sym53c416_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 28static int sym53c416_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
29static int sym53c416_host_reset(Scsi_Cmnd *); 29static int sym53c416_host_reset(Scsi_Cmnd *);
30static int sym53c416_bios_param(struct scsi_device *, struct block_device *, 30static int sym53c416_bios_param(struct scsi_device *, struct block_device *,
31 sector_t, int *); 31 sector_t, int *);
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 8b955b534a36..6b97ded9d45d 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -505,7 +505,7 @@ void sym_log_bus_error(struct Scsi_Host *shost)
505 * queuecommand method. Entered with the host adapter lock held and 505 * queuecommand method. Entered with the host adapter lock held and
506 * interrupts disabled. 506 * interrupts disabled.
507 */ 507 */
508static int sym53c8xx_queue_command(struct scsi_cmnd *cmd, 508static int sym53c8xx_queue_command_lck(struct scsi_cmnd *cmd,
509 void (*done)(struct scsi_cmnd *)) 509 void (*done)(struct scsi_cmnd *))
510{ 510{
511 struct sym_hcb *np = SYM_SOFTC_PTR(cmd); 511 struct sym_hcb *np = SYM_SOFTC_PTR(cmd);
@@ -536,6 +536,8 @@ static int sym53c8xx_queue_command(struct scsi_cmnd *cmd,
536 return 0; 536 return 0;
537} 537}
538 538
539static DEF_SCSI_QCMD(sym53c8xx_queue_command)
540
539/* 541/*
540 * Linux entry point of the interrupt handler. 542 * Linux entry point of the interrupt handler.
541 */ 543 */
diff --git a/drivers/scsi/t128.h b/drivers/scsi/t128.h
index 76a069b7ac0b..ada1115079c9 100644
--- a/drivers/scsi/t128.h
+++ b/drivers/scsi/t128.h
@@ -96,8 +96,7 @@ static int t128_abort(struct scsi_cmnd *);
96static int t128_biosparam(struct scsi_device *, struct block_device *, 96static int t128_biosparam(struct scsi_device *, struct block_device *,
97 sector_t, int*); 97 sector_t, int*);
98static int t128_detect(struct scsi_host_template *); 98static int t128_detect(struct scsi_host_template *);
99static int t128_queue_command(struct scsi_cmnd *, 99static int t128_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
100 void (*done)(struct scsi_cmnd *));
101static int t128_bus_reset(struct scsi_cmnd *); 100static int t128_bus_reset(struct scsi_cmnd *);
102 101
103#ifndef CMD_PER_LUN 102#ifndef CMD_PER_LUN
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index 27866b0adfeb..a124a28f2ccb 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -1883,7 +1883,7 @@ dc390_ScsiRstDetect( struct dc390_acb* pACB )
1883 return; 1883 return;
1884} 1884}
1885 1885
1886static int DC390_queuecommand(struct scsi_cmnd *cmd, 1886static int DC390_queuecommand_lck(struct scsi_cmnd *cmd,
1887 void (*done)(struct scsi_cmnd *)) 1887 void (*done)(struct scsi_cmnd *))
1888{ 1888{
1889 struct scsi_device *sdev = cmd->device; 1889 struct scsi_device *sdev = cmd->device;
@@ -1944,6 +1944,8 @@ static int DC390_queuecommand(struct scsi_cmnd *cmd,
1944 return SCSI_MLQUEUE_DEVICE_BUSY; 1944 return SCSI_MLQUEUE_DEVICE_BUSY;
1945} 1945}
1946 1946
1947static DEF_SCSI_QCMD(DC390_queuecommand)
1948
1947static void dc390_dumpinfo (struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB) 1949static void dc390_dumpinfo (struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
1948{ 1950{
1949 struct pci_dev *pdev; 1951 struct pci_dev *pdev;
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
index 5d9fdeeb2315..edfc5da8be4c 100644
--- a/drivers/scsi/u14-34f.c
+++ b/drivers/scsi/u14-34f.c
@@ -433,7 +433,7 @@
433 433
434static int u14_34f_detect(struct scsi_host_template *); 434static int u14_34f_detect(struct scsi_host_template *);
435static int u14_34f_release(struct Scsi_Host *); 435static int u14_34f_release(struct Scsi_Host *);
436static int u14_34f_queuecommand(struct scsi_cmnd *, void (*done)(struct scsi_cmnd *)); 436static int u14_34f_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
437static int u14_34f_eh_abort(struct scsi_cmnd *); 437static int u14_34f_eh_abort(struct scsi_cmnd *);
438static int u14_34f_eh_host_reset(struct scsi_cmnd *); 438static int u14_34f_eh_host_reset(struct scsi_cmnd *);
439static int u14_34f_bios_param(struct scsi_device *, struct block_device *, 439static int u14_34f_bios_param(struct scsi_device *, struct block_device *,
@@ -1248,7 +1248,7 @@ static void scsi_to_dev_dir(unsigned int i, unsigned int j) {
1248 1248
1249} 1249}
1250 1250
1251static int u14_34f_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) { 1251static int u14_34f_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) {
1252 unsigned int i, j, k; 1252 unsigned int i, j, k;
1253 struct mscp *cpp; 1253 struct mscp *cpp;
1254 1254
@@ -1329,6 +1329,8 @@ static int u14_34f_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scs
1329 return 0; 1329 return 0;
1330} 1330}
1331 1331
1332static DEF_SCSI_QCMD(u14_34f_queuecommand)
1333
1332static int u14_34f_eh_abort(struct scsi_cmnd *SCarg) { 1334static int u14_34f_eh_abort(struct scsi_cmnd *SCarg) {
1333 unsigned int i, j; 1335 unsigned int i, j;
1334 1336
diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c
index 27aa40f3980e..0571ef9639cb 100644
--- a/drivers/scsi/ultrastor.c
+++ b/drivers/scsi/ultrastor.c
@@ -700,7 +700,7 @@ static inline void build_sg_list(struct mscp *mscp, struct scsi_cmnd *SCpnt)
700 mscp->transfer_data_length = transfer_length; 700 mscp->transfer_data_length = transfer_length;
701} 701}
702 702
703static int ultrastor_queuecommand(struct scsi_cmnd *SCpnt, 703static int ultrastor_queuecommand_lck(struct scsi_cmnd *SCpnt,
704 void (*done) (struct scsi_cmnd *)) 704 void (*done) (struct scsi_cmnd *))
705{ 705{
706 struct mscp *my_mscp; 706 struct mscp *my_mscp;
@@ -825,6 +825,8 @@ retry:
825 return 0; 825 return 0;
826} 826}
827 827
828static DEF_SCSI_QCMD(ultrastor_queuecommand)
829
828/* This code must deal with 2 cases: 830/* This code must deal with 2 cases:
829 831
830 1. The command has not been written to the OGM. In this case, set 832 1. The command has not been written to the OGM. In this case, set
diff --git a/drivers/scsi/ultrastor.h b/drivers/scsi/ultrastor.h
index a692905f95f7..165c18b5cf5f 100644
--- a/drivers/scsi/ultrastor.h
+++ b/drivers/scsi/ultrastor.h
@@ -15,8 +15,7 @@
15 15
16static int ultrastor_detect(struct scsi_host_template *); 16static int ultrastor_detect(struct scsi_host_template *);
17static const char *ultrastor_info(struct Scsi_Host *shpnt); 17static const char *ultrastor_info(struct Scsi_Host *shpnt);
18static int ultrastor_queuecommand(struct scsi_cmnd *, 18static int ultrastor_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
19 void (*done)(struct scsi_cmnd *));
20static int ultrastor_abort(struct scsi_cmnd *); 19static int ultrastor_abort(struct scsi_cmnd *);
21static int ultrastor_host_reset(struct scsi_cmnd *); 20static int ultrastor_host_reset(struct scsi_cmnd *);
22static int ultrastor_biosparam(struct scsi_device *, struct block_device *, 21static int ultrastor_biosparam(struct scsi_device *, struct block_device *,
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 26894459c37f..a18996d24466 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -690,7 +690,7 @@ static int pvscsi_queue_ring(struct pvscsi_adapter *adapter,
690 return 0; 690 return 0;
691} 691}
692 692
693static int pvscsi_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) 693static int pvscsi_queue_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
694{ 694{
695 struct Scsi_Host *host = cmd->device->host; 695 struct Scsi_Host *host = cmd->device->host;
696 struct pvscsi_adapter *adapter = shost_priv(host); 696 struct pvscsi_adapter *adapter = shost_priv(host);
@@ -719,6 +719,8 @@ static int pvscsi_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
719 return 0; 719 return 0;
720} 720}
721 721
722static DEF_SCSI_QCMD(pvscsi_queue)
723
722static int pvscsi_abort(struct scsi_cmnd *cmd) 724static int pvscsi_abort(struct scsi_cmnd *cmd)
723{ 725{
724 struct pvscsi_adapter *adapter = shost_priv(cmd->device->host); 726 struct pvscsi_adapter *adapter = shost_priv(cmd->device->host);
diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index b701bf2cc187..5f697e0bd009 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -371,8 +371,8 @@ calc_sync_msg(unsigned int period, unsigned int offset, unsigned int fast,
371 msg[1] = offset; 371 msg[1] = offset;
372} 372}
373 373
374int 374static int
375wd33c93_queuecommand(struct scsi_cmnd *cmd, 375wd33c93_queuecommand_lck(struct scsi_cmnd *cmd,
376 void (*done)(struct scsi_cmnd *)) 376 void (*done)(struct scsi_cmnd *))
377{ 377{
378 struct WD33C93_hostdata *hostdata; 378 struct WD33C93_hostdata *hostdata;
@@ -468,6 +468,8 @@ wd33c93_queuecommand(struct scsi_cmnd *cmd,
468 return 0; 468 return 0;
469} 469}
470 470
471DEF_SCSI_QCMD(wd33c93_queuecommand)
472
471/* 473/*
472 * This routine attempts to start a scsi command. If the host_card is 474 * This routine attempts to start a scsi command. If the host_card is
473 * already connected, we give up immediately. Otherwise, look through 475 * already connected, we give up immediately. Otherwise, look through
diff --git a/drivers/scsi/wd33c93.h b/drivers/scsi/wd33c93.h
index 1ed5f3bf388e..3b463d7304dc 100644
--- a/drivers/scsi/wd33c93.h
+++ b/drivers/scsi/wd33c93.h
@@ -343,8 +343,7 @@ struct WD33C93_hostdata {
343void wd33c93_init (struct Scsi_Host *instance, const wd33c93_regs regs, 343void wd33c93_init (struct Scsi_Host *instance, const wd33c93_regs regs,
344 dma_setup_t setup, dma_stop_t stop, int clock_freq); 344 dma_setup_t setup, dma_stop_t stop, int clock_freq);
345int wd33c93_abort (struct scsi_cmnd *cmd); 345int wd33c93_abort (struct scsi_cmnd *cmd);
346int wd33c93_queuecommand (struct scsi_cmnd *cmd, 346int wd33c93_queuecommand (struct Scsi_Host *h, struct scsi_cmnd *cmd);
347 void (*done)(struct scsi_cmnd *));
348void wd33c93_intr (struct Scsi_Host *instance); 347void wd33c93_intr (struct Scsi_Host *instance);
349int wd33c93_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); 348int wd33c93_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
350int wd33c93_host_reset (struct scsi_cmnd *); 349int wd33c93_host_reset (struct scsi_cmnd *);
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index 333580bf37c5..db451ae0a368 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -1082,7 +1082,7 @@ static irqreturn_t wd7000_intr(int irq, void *dev_id)
1082 return IRQ_HANDLED; 1082 return IRQ_HANDLED;
1083} 1083}
1084 1084
1085static int wd7000_queuecommand(struct scsi_cmnd *SCpnt, 1085static int wd7000_queuecommand_lck(struct scsi_cmnd *SCpnt,
1086 void (*done)(struct scsi_cmnd *)) 1086 void (*done)(struct scsi_cmnd *))
1087{ 1087{
1088 Scb *scb; 1088 Scb *scb;
@@ -1139,6 +1139,8 @@ static int wd7000_queuecommand(struct scsi_cmnd *SCpnt,
1139 return 0; 1139 return 0;
1140} 1140}
1141 1141
1142static DEF_SCSI_QCMD(wd7000_queuecommand)
1143
1142static int wd7000_diagnostics(Adapter * host, int code) 1144static int wd7000_diagnostics(Adapter * host, int code)
1143{ 1145{
1144 static IcbDiag icb = { ICB_OP_DIAGNOSTICS }; 1146 static IcbDiag icb = { ICB_OP_DIAGNOSTICS };
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 4d8e14b7aa93..09a550860dcf 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2872,7 +2872,7 @@ static struct console serial8250_console = {
2872 .device = uart_console_device, 2872 .device = uart_console_device,
2873 .setup = serial8250_console_setup, 2873 .setup = serial8250_console_setup,
2874 .early_setup = serial8250_console_early_setup, 2874 .early_setup = serial8250_console_early_setup,
2875 .flags = CON_PRINTBUFFER, 2875 .flags = CON_PRINTBUFFER | CON_ANYTIME,
2876 .index = -1, 2876 .index = -1,
2877 .data = &serial8250_reg, 2877 .data = &serial8250_reg,
2878}; 2878};
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index fa62578fcd20..bcc31f2140ac 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -18,7 +18,6 @@ static char *serial_version = "$Revision: 1.25 $";
18#include <linux/tty.h> 18#include <linux/tty.h>
19#include <linux/tty_flip.h> 19#include <linux/tty_flip.h>
20#include <linux/major.h> 20#include <linux/major.h>
21#include <linux/smp_lock.h>
22#include <linux/string.h> 21#include <linux/string.h>
23#include <linux/fcntl.h> 22#include <linux/fcntl.h>
24#include <linux/mm.h> 23#include <linux/mm.h>
diff --git a/drivers/serial/kgdboc.c b/drivers/serial/kgdboc.c
index 3374618300af..25a8bc565f40 100644
--- a/drivers/serial/kgdboc.c
+++ b/drivers/serial/kgdboc.c
@@ -90,7 +90,8 @@ static DECLARE_WORK(kgdboc_restore_input_work, kgdboc_restore_input_helper);
90 90
91static void kgdboc_restore_input(void) 91static void kgdboc_restore_input(void)
92{ 92{
93 schedule_work(&kgdboc_restore_input_work); 93 if (likely(system_state == SYSTEM_RUNNING))
94 schedule_work(&kgdboc_restore_input_work);
94} 95}
95 96
96static int kgdboc_register_kbd(char **cptr) 97static int kgdboc_register_kbd(char **cptr)
diff --git a/drivers/serial/mfd.c b/drivers/serial/mfd.c
index 5fc699e929dc..d40010a22ecd 100644
--- a/drivers/serial/mfd.c
+++ b/drivers/serial/mfd.c
@@ -900,8 +900,7 @@ serial_hsu_set_termios(struct uart_port *port, struct ktermios *termios,
900 unsigned char cval, fcr = 0; 900 unsigned char cval, fcr = 0;
901 unsigned long flags; 901 unsigned long flags;
902 unsigned int baud, quot; 902 unsigned int baud, quot;
903 u32 mul = 0x3600; 903 u32 ps, mul;
904 u32 ps = 0x10;
905 904
906 switch (termios->c_cflag & CSIZE) { 905 switch (termios->c_cflag & CSIZE) {
907 case CS5: 906 case CS5:
@@ -943,31 +942,24 @@ serial_hsu_set_termios(struct uart_port *port, struct ktermios *termios,
943 baud = uart_get_baud_rate(port, termios, old, 0, 4000000); 942 baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
944 943
945 quot = 1; 944 quot = 1;
945 ps = 0x10;
946 mul = 0x3600;
946 switch (baud) { 947 switch (baud) {
947 case 3500000: 948 case 3500000:
948 mul = 0x3345; 949 mul = 0x3345;
949 ps = 0xC; 950 ps = 0xC;
950 break; 951 break;
951 case 3000000:
952 mul = 0x2EE0;
953 break;
954 case 2500000:
955 mul = 0x2710;
956 break;
957 case 2000000:
958 mul = 0x1F40;
959 break;
960 case 1843200: 952 case 1843200:
961 mul = 0x2400; 953 mul = 0x2400;
962 break; 954 break;
955 case 3000000:
956 case 2500000:
957 case 2000000:
963 case 1500000: 958 case 1500000:
964 mul = 0x1770;
965 break;
966 case 1000000: 959 case 1000000:
967 mul = 0xFA0;
968 break;
969 case 500000: 960 case 500000:
970 mul = 0x7D0; 961 /* mul/ps/quot = 0x9C4/0x10/0x1 will make a 500000 bps */
962 mul = baud / 500000 * 0x9C4;
971 break; 963 break;
972 default: 964 default:
973 /* Use uart_get_divisor to get quot for other baud rates */ 965 /* Use uart_get_divisor to get quot for other baud rates */
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index c4ea14670d44..9ffa5bee44ab 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -29,7 +29,6 @@
29#include <linux/console.h> 29#include <linux/console.h>
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/smp_lock.h>
33#include <linux/device.h> 32#include <linux/device.h>
34#include <linux/serial.h> /* for serial_state and serial_icounter_struct */ 33#include <linux/serial.h> /* for serial_state and serial_icounter_struct */
35#include <linux/serial_core.h> 34#include <linux/serial_core.h>
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c
index cb12a8e1466b..3f5e387ed564 100644
--- a/drivers/sh/clk/core.c
+++ b/drivers/sh/clk/core.c
@@ -418,8 +418,11 @@ int clk_register(struct clk *clk)
418 list_add(&clk->sibling, &root_clks); 418 list_add(&clk->sibling, &root_clks);
419 419
420 list_add(&clk->node, &clock_list); 420 list_add(&clk->node, &clock_list);
421
422#ifdef CONFIG_SH_CLK_CPG_LEGACY
421 if (clk->ops && clk->ops->init) 423 if (clk->ops && clk->ops->init)
422 clk->ops->init(clk); 424 clk->ops->init(clk);
425#endif
423 426
424out_unlock: 427out_unlock:
425 mutex_unlock(&clock_list_sem); 428 mutex_unlock(&clock_list_sem);
@@ -455,19 +458,13 @@ EXPORT_SYMBOL_GPL(clk_get_rate);
455 458
456int clk_set_rate(struct clk *clk, unsigned long rate) 459int clk_set_rate(struct clk *clk, unsigned long rate)
457{ 460{
458 return clk_set_rate_ex(clk, rate, 0);
459}
460EXPORT_SYMBOL_GPL(clk_set_rate);
461
462int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id)
463{
464 int ret = -EOPNOTSUPP; 461 int ret = -EOPNOTSUPP;
465 unsigned long flags; 462 unsigned long flags;
466 463
467 spin_lock_irqsave(&clock_lock, flags); 464 spin_lock_irqsave(&clock_lock, flags);
468 465
469 if (likely(clk->ops && clk->ops->set_rate)) { 466 if (likely(clk->ops && clk->ops->set_rate)) {
470 ret = clk->ops->set_rate(clk, rate, algo_id); 467 ret = clk->ops->set_rate(clk, rate);
471 if (ret != 0) 468 if (ret != 0)
472 goto out_unlock; 469 goto out_unlock;
473 } else { 470 } else {
@@ -485,7 +482,7 @@ out_unlock:
485 482
486 return ret; 483 return ret;
487} 484}
488EXPORT_SYMBOL_GPL(clk_set_rate_ex); 485EXPORT_SYMBOL_GPL(clk_set_rate);
489 486
490int clk_set_parent(struct clk *clk, struct clk *parent) 487int clk_set_parent(struct clk *clk, struct clk *parent)
491{ 488{
@@ -653,8 +650,7 @@ static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state)
653 clkp->ops->set_parent(clkp, 650 clkp->ops->set_parent(clkp,
654 clkp->parent); 651 clkp->parent);
655 if (likely(clkp->ops->set_rate)) 652 if (likely(clkp->ops->set_rate))
656 clkp->ops->set_rate(clkp, 653 clkp->ops->set_rate(clkp, rate);
657 rate, NO_CHANGE);
658 else if (likely(clkp->ops->recalc)) 654 else if (likely(clkp->ops->recalc))
659 clkp->rate = clkp->ops->recalc(clkp); 655 clkp->rate = clkp->ops->recalc(clkp);
660 } 656 }
diff --git a/drivers/sh/clk/cpg.c b/drivers/sh/clk/cpg.c
index 3aea5f0ceb09..6172335ae323 100644
--- a/drivers/sh/clk/cpg.c
+++ b/drivers/sh/clk/cpg.c
@@ -110,8 +110,7 @@ static int sh_clk_div6_set_parent(struct clk *clk, struct clk *parent)
110 return 0; 110 return 0;
111} 111}
112 112
113static int sh_clk_div6_set_rate(struct clk *clk, 113static int sh_clk_div6_set_rate(struct clk *clk, unsigned long rate)
114 unsigned long rate, int algo_id)
115{ 114{
116 unsigned long value; 115 unsigned long value;
117 int idx; 116 int idx;
@@ -132,7 +131,7 @@ static int sh_clk_div6_enable(struct clk *clk)
132 unsigned long value; 131 unsigned long value;
133 int ret; 132 int ret;
134 133
135 ret = sh_clk_div6_set_rate(clk, clk->rate, 0); 134 ret = sh_clk_div6_set_rate(clk, clk->rate);
136 if (ret == 0) { 135 if (ret == 0) {
137 value = __raw_readl(clk->enable_reg); 136 value = __raw_readl(clk->enable_reg);
138 value &= ~0x100; /* clear stop bit to enable clock */ 137 value &= ~0x100; /* clear stop bit to enable clock */
@@ -253,7 +252,7 @@ static int sh_clk_div4_set_parent(struct clk *clk, struct clk *parent)
253 return 0; 252 return 0;
254} 253}
255 254
256static int sh_clk_div4_set_rate(struct clk *clk, unsigned long rate, int algo_id) 255static int sh_clk_div4_set_rate(struct clk *clk, unsigned long rate)
257{ 256{
258 struct clk_div4_table *d4t = clk->priv; 257 struct clk_div4_table *d4t = clk->priv;
259 unsigned long value; 258 unsigned long value;
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 154529aacc03..a067046c9da2 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -352,8 +352,12 @@ atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer)
352 352
353 xfer->tx_dma = xfer->rx_dma = INVALID_DMA_ADDRESS; 353 xfer->tx_dma = xfer->rx_dma = INVALID_DMA_ADDRESS;
354 if (xfer->tx_buf) { 354 if (xfer->tx_buf) {
355 /* tx_buf is a const void* where we need a void * for the dma
356 * mapping */
357 void *nonconst_tx = (void *)xfer->tx_buf;
358
355 xfer->tx_dma = dma_map_single(dev, 359 xfer->tx_dma = dma_map_single(dev,
356 (void *) xfer->tx_buf, xfer->len, 360 nonconst_tx, xfer->len,
357 DMA_TO_DEVICE); 361 DMA_TO_DEVICE);
358 if (dma_mapping_error(dev, xfer->tx_dma)) 362 if (dma_mapping_error(dev, xfer->tx_dma))
359 return -ENOMEM; 363 return -ENOMEM;
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 90439314cf67..0838c79861e4 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -413,6 +413,11 @@ static void poll_transfer(struct dw_spi *dws)
413{ 413{
414 while (dws->write(dws)) 414 while (dws->write(dws))
415 dws->read(dws); 415 dws->read(dws);
416 /*
417 * There is a possibility that the last word of a transaction
418 * will be lost if data is not ready. Re-read to solve this issue.
419 */
420 dws->read(dws);
416 421
417 transfer_complete(dws); 422 transfer_complete(dws);
418} 423}
diff --git a/drivers/ssb/b43_pci_bridge.c b/drivers/ssb/b43_pci_bridge.c
index ef9c6a04ad8f..744d3f6e4709 100644
--- a/drivers/ssb/b43_pci_bridge.c
+++ b/drivers/ssb/b43_pci_bridge.c
@@ -24,6 +24,7 @@ static const struct pci_device_id b43_pci_bridge_tbl[] = {
24 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4312) }, 24 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4312) },
25 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4315) }, 25 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4315) },
26 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4318) }, 26 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4318) },
27 { PCI_DEVICE(PCI_VENDOR_ID_BCM_GVC, 0x4318) },
27 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4319) }, 28 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4319) },
28 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4320) }, 29 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4320) },
29 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4321) }, 30 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4321) },
diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c
index 8c95d8c2a4f4..016c6f7f8630 100644
--- a/drivers/staging/asus_oled/asus_oled.c
+++ b/drivers/staging/asus_oled/asus_oled.c
@@ -620,13 +620,13 @@ static ssize_t class_set_picture(struct device *device,
620 620
621#define ASUS_OLED_DEVICE_ATTR(_file) dev_attr_asus_oled_##_file 621#define ASUS_OLED_DEVICE_ATTR(_file) dev_attr_asus_oled_##_file
622 622
623static DEVICE_ATTR(asus_oled_enabled, S_IWUGO | S_IRUGO, 623static DEVICE_ATTR(asus_oled_enabled, S_IWUSR | S_IRUGO,
624 get_enabled, set_enabled); 624 get_enabled, set_enabled);
625static DEVICE_ATTR(asus_oled_picture, S_IWUGO , NULL, set_picture); 625static DEVICE_ATTR(asus_oled_picture, S_IWUSR , NULL, set_picture);
626 626
627static DEVICE_ATTR(enabled, S_IWUGO | S_IRUGO, 627static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO,
628 class_get_enabled, class_set_enabled); 628 class_get_enabled, class_set_enabled);
629static DEVICE_ATTR(picture, S_IWUGO, NULL, class_set_picture); 629static DEVICE_ATTR(picture, S_IWUSR, NULL, class_set_picture);
630 630
631static int asus_oled_probe(struct usb_interface *interface, 631static int asus_oled_probe(struct usb_interface *interface,
632 const struct usb_device_id *id) 632 const struct usb_device_id *id)
diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c
index b68a7e5173be..d85de82f941a 100644
--- a/drivers/staging/batman-adv/hard-interface.c
+++ b/drivers/staging/batman-adv/hard-interface.c
@@ -463,9 +463,6 @@ static void hardif_remove_interface(struct batman_if *batman_if)
463 return; 463 return;
464 464
465 batman_if->if_status = IF_TO_BE_REMOVED; 465 batman_if->if_status = IF_TO_BE_REMOVED;
466
467 /* caller must take if_list_lock */
468 list_del_rcu(&batman_if->list);
469 synchronize_rcu(); 466 synchronize_rcu();
470 sysfs_del_hardif(&batman_if->hardif_obj); 467 sysfs_del_hardif(&batman_if->hardif_obj);
471 hardif_put(batman_if); 468 hardif_put(batman_if);
@@ -474,13 +471,21 @@ static void hardif_remove_interface(struct batman_if *batman_if)
474void hardif_remove_interfaces(void) 471void hardif_remove_interfaces(void)
475{ 472{
476 struct batman_if *batman_if, *batman_if_tmp; 473 struct batman_if *batman_if, *batman_if_tmp;
474 struct list_head if_queue;
475
476 INIT_LIST_HEAD(&if_queue);
477 477
478 rtnl_lock();
479 spin_lock(&if_list_lock); 478 spin_lock(&if_list_lock);
480 list_for_each_entry_safe(batman_if, batman_if_tmp, &if_list, list) { 479 list_for_each_entry_safe(batman_if, batman_if_tmp, &if_list, list) {
481 hardif_remove_interface(batman_if); 480 list_del_rcu(&batman_if->list);
481 list_add_tail(&batman_if->list, &if_queue);
482 } 482 }
483 spin_unlock(&if_list_lock); 483 spin_unlock(&if_list_lock);
484
485 rtnl_lock();
486 list_for_each_entry_safe(batman_if, batman_if_tmp, &if_queue, list) {
487 hardif_remove_interface(batman_if);
488 }
484 rtnl_unlock(); 489 rtnl_unlock();
485} 490}
486 491
@@ -507,8 +512,10 @@ static int hard_if_event(struct notifier_block *this,
507 break; 512 break;
508 case NETDEV_UNREGISTER: 513 case NETDEV_UNREGISTER:
509 spin_lock(&if_list_lock); 514 spin_lock(&if_list_lock);
510 hardif_remove_interface(batman_if); 515 list_del_rcu(&batman_if->list);
511 spin_unlock(&if_list_lock); 516 spin_unlock(&if_list_lock);
517
518 hardif_remove_interface(batman_if);
512 break; 519 break;
513 case NETDEV_CHANGEMTU: 520 case NETDEV_CHANGEMTU:
514 if (batman_if->soft_iface) 521 if (batman_if->soft_iface)
diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c
index 3904db9ce7b1..0e996181daf7 100644
--- a/drivers/staging/batman-adv/soft-interface.c
+++ b/drivers/staging/batman-adv/soft-interface.c
@@ -194,14 +194,15 @@ void interface_rx(struct net_device *soft_iface,
194 struct bat_priv *priv = netdev_priv(soft_iface); 194 struct bat_priv *priv = netdev_priv(soft_iface);
195 195
196 /* check if enough space is available for pulling, and pull */ 196 /* check if enough space is available for pulling, and pull */
197 if (!pskb_may_pull(skb, hdr_size)) { 197 if (!pskb_may_pull(skb, hdr_size))
198 kfree_skb(skb); 198 goto dropped;
199 return; 199
200 }
201 skb_pull_rcsum(skb, hdr_size); 200 skb_pull_rcsum(skb, hdr_size);
202/* skb_set_mac_header(skb, -sizeof(struct ethhdr));*/ 201/* skb_set_mac_header(skb, -sizeof(struct ethhdr));*/
203 202
204 /* skb->dev & skb->pkt_type are set here */ 203 /* skb->dev & skb->pkt_type are set here */
204 if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
205 goto dropped;
205 skb->protocol = eth_type_trans(skb, soft_iface); 206 skb->protocol = eth_type_trans(skb, soft_iface);
206 207
207 /* should not be neccesary anymore as we use skb_pull_rcsum() 208 /* should not be neccesary anymore as we use skb_pull_rcsum()
@@ -216,6 +217,11 @@ void interface_rx(struct net_device *soft_iface,
216 soft_iface->last_rx = jiffies; 217 soft_iface->last_rx = jiffies;
217 218
218 netif_rx(skb); 219 netif_rx(skb);
220 return;
221
222dropped:
223 kfree_skb(skb);
224 return;
219} 225}
220 226
221#ifdef HAVE_NET_DEVICE_OPS 227#ifdef HAVE_NET_DEVICE_OPS
diff --git a/drivers/staging/brcm80211/README b/drivers/staging/brcm80211/README
index c8f1cf1b4409..a27bb0b4f581 100644
--- a/drivers/staging/brcm80211/README
+++ b/drivers/staging/brcm80211/README
@@ -88,7 +88,9 @@ with the driver.
88 88
89Contact Info: 89Contact Info:
90============= 90=============
91Brett Rudley brudley@broadcom.com 91Brett Rudley brudley@broadcom.com
92Henry Ptasinski henryp@broadcom.com 92Henry Ptasinski henryp@broadcom.com
93Dowan Kim dowan@broadcom.com 93Dowan Kim dowan@broadcom.com
94Roland Vossen rvossen@broadcom.com
95Arend van Spriel arend@broadcom.com
94 96
diff --git a/drivers/staging/brcm80211/TODO b/drivers/staging/brcm80211/TODO
index dbf904184899..24ebadbe4241 100644
--- a/drivers/staging/brcm80211/TODO
+++ b/drivers/staging/brcm80211/TODO
@@ -46,4 +46,6 @@ Contact
46Brett Rudley <brudley@broadcom.com> 46Brett Rudley <brudley@broadcom.com>
47Henry Ptasinski <henryp@broadcom.com> 47Henry Ptasinski <henryp@broadcom.com>
48Dowan Kim <dowan@broadcom.com> 48Dowan Kim <dowan@broadcom.com>
49Roland Vossen <rvossen@broadcom.com>
50Arend van Spriel <arend@broadcom.com>
49 51
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 1f177a67ff11..de784ff08caa 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -2295,8 +2295,8 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp)
2295 usbduxsub_tmp->inBuffer = NULL; 2295 usbduxsub_tmp->inBuffer = NULL;
2296 kfree(usbduxsub_tmp->insnBuffer); 2296 kfree(usbduxsub_tmp->insnBuffer);
2297 usbduxsub_tmp->insnBuffer = NULL; 2297 usbduxsub_tmp->insnBuffer = NULL;
2298 kfree(usbduxsub_tmp->inBuffer); 2298 kfree(usbduxsub_tmp->outBuffer);
2299 usbduxsub_tmp->inBuffer = NULL; 2299 usbduxsub_tmp->outBuffer = NULL;
2300 kfree(usbduxsub_tmp->dac_commands); 2300 kfree(usbduxsub_tmp->dac_commands);
2301 usbduxsub_tmp->dac_commands = NULL; 2301 usbduxsub_tmp->dac_commands = NULL;
2302 kfree(usbduxsub_tmp->dux_commands); 2302 kfree(usbduxsub_tmp->dux_commands);
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c
index e7f1d5778cec..52389308f333 100644
--- a/drivers/staging/cx25821/cx25821-video.c
+++ b/drivers/staging/cx25821/cx25821-video.c
@@ -92,7 +92,7 @@ int cx25821_get_format_size(void)
92 return ARRAY_SIZE(formats); 92 return ARRAY_SIZE(formats);
93} 93}
94 94
95struct cx25821_fmt *format_by_fourcc(unsigned int fourcc) 95struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc)
96{ 96{
97 unsigned int i; 97 unsigned int i;
98 98
@@ -848,7 +848,7 @@ static int video_open(struct file *file)
848 pix_format = 848 pix_format =
849 (dev->channels[ch_id].pixel_formats == 849 (dev->channels[ch_id].pixel_formats ==
850 PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV; 850 PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
851 fh->fmt = format_by_fourcc(pix_format); 851 fh->fmt = cx25821_format_by_fourcc(pix_format);
852 852
853 v4l2_prio_open(&dev->channels[ch_id].prio, &fh->prio); 853 v4l2_prio_open(&dev->channels[ch_id].prio, &fh->prio);
854 854
@@ -1010,7 +1010,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1010 if (0 != err) 1010 if (0 != err)
1011 return err; 1011 return err;
1012 1012
1013 fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); 1013 fh->fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat);
1014 fh->vidq.field = f->fmt.pix.field; 1014 fh->vidq.field = f->fmt.pix.field;
1015 1015
1016 /* check if width and height is valid based on set standard */ 1016 /* check if width and height is valid based on set standard */
@@ -1119,7 +1119,7 @@ int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fo
1119 enum v4l2_field field; 1119 enum v4l2_field field;
1120 unsigned int maxw, maxh; 1120 unsigned int maxw, maxh;
1121 1121
1122 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 1122 fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat);
1123 if (NULL == fmt) 1123 if (NULL == fmt)
1124 return -EINVAL; 1124 return -EINVAL;
1125 1125
diff --git a/drivers/staging/cx25821/cx25821-video.h b/drivers/staging/cx25821/cx25821-video.h
index cc6034b1a95d..a2415d33235b 100644
--- a/drivers/staging/cx25821/cx25821-video.h
+++ b/drivers/staging/cx25821/cx25821-video.h
@@ -87,7 +87,7 @@ extern unsigned int vid_limit;
87 87
88#define FORMAT_FLAGS_PACKED 0x01 88#define FORMAT_FLAGS_PACKED 0x01
89extern struct cx25821_fmt formats[]; 89extern struct cx25821_fmt formats[];
90extern struct cx25821_fmt *format_by_fourcc(unsigned int fourcc); 90extern struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc);
91extern struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM]; 91extern struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM];
92 92
93extern void cx25821_dump_video_queue(struct cx25821_dev *dev, 93extern void cx25821_dump_video_queue(struct cx25821_dev *dev,
diff --git a/drivers/staging/easycap/easycap.h b/drivers/staging/easycap/easycap.h
index f3c827eb0abe..884263b2775d 100644
--- a/drivers/staging/easycap/easycap.h
+++ b/drivers/staging/easycap/easycap.h
@@ -75,9 +75,9 @@
75#include <linux/errno.h> 75#include <linux/errno.h>
76#include <linux/init.h> 76#include <linux/init.h>
77#include <linux/slab.h> 77#include <linux/slab.h>
78#include <linux/smp_lock.h>
78#include <linux/module.h> 79#include <linux/module.h>
79#include <linux/kref.h> 80#include <linux/kref.h>
80#include <linux/smp_lock.h>
81#include <linux/usb.h> 81#include <linux/usb.h>
82#include <linux/uaccess.h> 82#include <linux/uaccess.h>
83 83
diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c
index a145a15cfdb3..8894ab14f167 100644
--- a/drivers/staging/frontier/tranzport.c
+++ b/drivers/staging/frontier/tranzport.c
@@ -204,7 +204,7 @@ static void usb_tranzport_abort_transfers(struct usb_tranzport *dev)
204 t->value = temp; \ 204 t->value = temp; \
205 return count; \ 205 return count; \
206 } \ 206 } \
207 static DEVICE_ATTR(value, S_IWUGO | S_IRUGO, show_##value, set_##value); 207 static DEVICE_ATTR(value, S_IWUSR | S_IRUGO, show_##value, set_##value);
208 208
209show_int(enable); 209show_int(enable);
210show_int(offline); 210show_int(offline);
diff --git a/drivers/staging/go7007/go7007-driver.c b/drivers/staging/go7007/go7007-driver.c
index b3f42f37a313..48d4e483d8a4 100644
--- a/drivers/staging/go7007/go7007-driver.c
+++ b/drivers/staging/go7007/go7007-driver.c
@@ -199,7 +199,7 @@ static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
199 struct go7007 *go = i2c_get_adapdata(adapter); 199 struct go7007 *go = i2c_get_adapdata(adapter);
200 struct v4l2_device *v4l2_dev = &go->v4l2_dev; 200 struct v4l2_device *v4l2_dev = &go->v4l2_dev;
201 201
202 if (v4l2_i2c_new_subdev(v4l2_dev, adapter, NULL, type, addr, NULL)) 202 if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, addr, NULL))
203 return 0; 203 return 0;
204 204
205 printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", type); 205 printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", type);
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 41d9acf4cd61..6f8d67d0d64f 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -72,8 +72,7 @@ struct storvsc_driver_context {
72 72
73/* Static decl */ 73/* Static decl */
74static int storvsc_probe(struct device *dev); 74static int storvsc_probe(struct device *dev);
75static int storvsc_queuecommand(struct scsi_cmnd *scmnd, 75static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
76 void (*done)(struct scsi_cmnd *));
77static int storvsc_device_alloc(struct scsi_device *); 76static int storvsc_device_alloc(struct scsi_device *);
78static int storvsc_device_configure(struct scsi_device *); 77static int storvsc_device_configure(struct scsi_device *);
79static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd); 78static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
@@ -595,7 +594,7 @@ static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
595/* 594/*
596 * storvsc_queuecommand - Initiate command processing 595 * storvsc_queuecommand - Initiate command processing
597 */ 596 */
598static int storvsc_queuecommand(struct scsi_cmnd *scmnd, 597static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
599 void (*done)(struct scsi_cmnd *)) 598 void (*done)(struct scsi_cmnd *))
600{ 599{
601 int ret; 600 int ret;
@@ -783,6 +782,8 @@ retry_request:
783 return ret; 782 return ret;
784} 783}
785 784
785static DEF_SCSI_QCMD(storvsc_queuecommand)
786
786static int storvsc_merge_bvec(struct request_queue *q, 787static int storvsc_merge_bvec(struct request_queue *q,
787 struct bvec_merge_data *bmd, struct bio_vec *bvec) 788 struct bvec_merge_data *bmd, struct bio_vec *bvec)
788{ 789{
diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c
index c86d1498737d..1c1e98aee2d9 100644
--- a/drivers/staging/iio/accel/adis16220_core.c
+++ b/drivers/staging/iio/accel/adis16220_core.c
@@ -507,7 +507,7 @@ static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL,
507 adis16220_write_reset, 0); 507 adis16220_write_reset, 0);
508 508
509#define IIO_DEV_ATTR_CAPTURE(_store) \ 509#define IIO_DEV_ATTR_CAPTURE(_store) \
510 IIO_DEVICE_ATTR(capture, S_IWUGO, NULL, _store, 0) 510 IIO_DEVICE_ATTR(capture, S_IWUSR, NULL, _store, 0)
511 511
512static IIO_DEV_ATTR_CAPTURE(adis16220_write_capture); 512static IIO_DEV_ATTR_CAPTURE(adis16220_write_capture);
513 513
diff --git a/drivers/staging/intel_sst/intel_sst_app_interface.c b/drivers/staging/intel_sst/intel_sst_app_interface.c
index 9618c7997461..991440015e92 100644
--- a/drivers/staging/intel_sst/intel_sst_app_interface.c
+++ b/drivers/staging/intel_sst/intel_sst_app_interface.c
@@ -34,7 +34,6 @@
34#include <linux/uaccess.h> 34#include <linux/uaccess.h>
35#include <linux/firmware.h> 35#include <linux/firmware.h>
36#include <linux/ioctl.h> 36#include <linux/ioctl.h>
37#include <linux/smp_lock.h>
38#ifdef CONFIG_MRST_RAR_HANDLER 37#ifdef CONFIG_MRST_RAR_HANDLER
39#include <linux/rar_register.h> 38#include <linux/rar_register.h>
40#include "../../../drivers/staging/memrar/memrar.h" 39#include "../../../drivers/staging/memrar/memrar.h"
diff --git a/drivers/staging/intel_sst/intel_sst_stream_encoded.c b/drivers/staging/intel_sst/intel_sst_stream_encoded.c
index fbae39fda5c0..5c455608b024 100644
--- a/drivers/staging/intel_sst/intel_sst_stream_encoded.c
+++ b/drivers/staging/intel_sst/intel_sst_stream_encoded.c
@@ -1269,7 +1269,7 @@ finish:
1269 dbufs->output_bytes_produced = total_output; 1269 dbufs->output_bytes_produced = total_output;
1270 str_info->status = str_info->prev; 1270 str_info->status = str_info->prev;
1271 str_info->prev = STREAM_DECODE; 1271 str_info->prev = STREAM_DECODE;
1272 str_info->decode_ibuf = NULL;
1273 kfree(str_info->decode_ibuf); 1272 kfree(str_info->decode_ibuf);
1273 str_info->decode_ibuf = NULL;
1274 return retval; 1274 return retval;
1275} 1275}
diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c
index a2671404f7ac..da4f42af3838 100644
--- a/drivers/staging/keucr/scsiglue.c
+++ b/drivers/staging/keucr/scsiglue.c
@@ -87,7 +87,7 @@ static int slave_configure(struct scsi_device *sdev)
87 87
88/* This is always called with scsi_lock(host) held */ 88/* This is always called with scsi_lock(host) held */
89//----- queuecommand() --------------------- 89//----- queuecommand() ---------------------
90static int queuecommand(struct scsi_cmnd *srb, void (*done)(struct scsi_cmnd *)) 90static int queuecommand_lck(struct scsi_cmnd *srb, void (*done)(struct scsi_cmnd *))
91{ 91{
92 struct us_data *us = host_to_us(srb->device->host); 92 struct us_data *us = host_to_us(srb->device->host);
93 93
@@ -117,6 +117,8 @@ static int queuecommand(struct scsi_cmnd *srb, void (*done)(struct scsi_cmnd *))
117 return 0; 117 return 0;
118} 118}
119 119
120static DEF_SCSI_QCMD(queuecommand)
121
120/*********************************************************************** 122/***********************************************************************
121 * Error handling functions 123 * Error handling functions
122 ***********************************************************************/ 124 ***********************************************************************/
diff --git a/drivers/staging/line6/control.c b/drivers/staging/line6/control.c
index 040e25ca6d33..67e23b6e2d35 100644
--- a/drivers/staging/line6/control.c
+++ b/drivers/staging/line6/control.c
@@ -266,210 +266,210 @@ VARIAX_PARAM_R(float, mix2);
266VARIAX_PARAM_R(float, mix1); 266VARIAX_PARAM_R(float, mix1);
267VARIAX_PARAM_R(int, pickup_wiring); 267VARIAX_PARAM_R(int, pickup_wiring);
268 268
269static DEVICE_ATTR(tweak, S_IWUGO | S_IRUGO, pod_get_tweak, pod_set_tweak); 269static DEVICE_ATTR(tweak, S_IWUSR | S_IRUGO, pod_get_tweak, pod_set_tweak);
270static DEVICE_ATTR(wah_position, S_IWUGO | S_IRUGO, pod_get_wah_position, 270static DEVICE_ATTR(wah_position, S_IWUSR | S_IRUGO, pod_get_wah_position,
271 pod_set_wah_position); 271 pod_set_wah_position);
272static DEVICE_ATTR(compression_gain, S_IWUGO | S_IRUGO, 272static DEVICE_ATTR(compression_gain, S_IWUSR | S_IRUGO,
273 pod_get_compression_gain, pod_set_compression_gain); 273 pod_get_compression_gain, pod_set_compression_gain);
274static DEVICE_ATTR(vol_pedal_position, S_IWUGO | S_IRUGO, 274static DEVICE_ATTR(vol_pedal_position, S_IWUSR | S_IRUGO,
275 pod_get_vol_pedal_position, pod_set_vol_pedal_position); 275 pod_get_vol_pedal_position, pod_set_vol_pedal_position);
276static DEVICE_ATTR(compression_threshold, S_IWUGO | S_IRUGO, 276static DEVICE_ATTR(compression_threshold, S_IWUSR | S_IRUGO,
277 pod_get_compression_threshold, 277 pod_get_compression_threshold,
278 pod_set_compression_threshold); 278 pod_set_compression_threshold);
279static DEVICE_ATTR(pan, S_IWUGO | S_IRUGO, pod_get_pan, pod_set_pan); 279static DEVICE_ATTR(pan, S_IWUSR | S_IRUGO, pod_get_pan, pod_set_pan);
280static DEVICE_ATTR(amp_model_setup, S_IWUGO | S_IRUGO, pod_get_amp_model_setup, 280static DEVICE_ATTR(amp_model_setup, S_IWUSR | S_IRUGO, pod_get_amp_model_setup,
281 pod_set_amp_model_setup); 281 pod_set_amp_model_setup);
282static DEVICE_ATTR(amp_model, S_IWUGO | S_IRUGO, pod_get_amp_model, 282static DEVICE_ATTR(amp_model, S_IWUSR | S_IRUGO, pod_get_amp_model,
283 pod_set_amp_model); 283 pod_set_amp_model);
284static DEVICE_ATTR(drive, S_IWUGO | S_IRUGO, pod_get_drive, pod_set_drive); 284static DEVICE_ATTR(drive, S_IWUSR | S_IRUGO, pod_get_drive, pod_set_drive);
285static DEVICE_ATTR(bass, S_IWUGO | S_IRUGO, pod_get_bass, pod_set_bass); 285static DEVICE_ATTR(bass, S_IWUSR | S_IRUGO, pod_get_bass, pod_set_bass);
286static DEVICE_ATTR(mid, S_IWUGO | S_IRUGO, pod_get_mid, pod_set_mid); 286static DEVICE_ATTR(mid, S_IWUSR | S_IRUGO, pod_get_mid, pod_set_mid);
287static DEVICE_ATTR(lowmid, S_IWUGO | S_IRUGO, pod_get_lowmid, pod_set_lowmid); 287static DEVICE_ATTR(lowmid, S_IWUSR | S_IRUGO, pod_get_lowmid, pod_set_lowmid);
288static DEVICE_ATTR(treble, S_IWUGO | S_IRUGO, pod_get_treble, pod_set_treble); 288static DEVICE_ATTR(treble, S_IWUSR | S_IRUGO, pod_get_treble, pod_set_treble);
289static DEVICE_ATTR(highmid, S_IWUGO | S_IRUGO, pod_get_highmid, 289static DEVICE_ATTR(highmid, S_IWUSR | S_IRUGO, pod_get_highmid,
290 pod_set_highmid); 290 pod_set_highmid);
291static DEVICE_ATTR(chan_vol, S_IWUGO | S_IRUGO, pod_get_chan_vol, 291static DEVICE_ATTR(chan_vol, S_IWUSR | S_IRUGO, pod_get_chan_vol,
292 pod_set_chan_vol); 292 pod_set_chan_vol);
293static DEVICE_ATTR(reverb_mix, S_IWUGO | S_IRUGO, pod_get_reverb_mix, 293static DEVICE_ATTR(reverb_mix, S_IWUSR | S_IRUGO, pod_get_reverb_mix,
294 pod_set_reverb_mix); 294 pod_set_reverb_mix);
295static DEVICE_ATTR(effect_setup, S_IWUGO | S_IRUGO, pod_get_effect_setup, 295static DEVICE_ATTR(effect_setup, S_IWUSR | S_IRUGO, pod_get_effect_setup,
296 pod_set_effect_setup); 296 pod_set_effect_setup);
297static DEVICE_ATTR(band_1_frequency, S_IWUGO | S_IRUGO, 297static DEVICE_ATTR(band_1_frequency, S_IWUSR | S_IRUGO,
298 pod_get_band_1_frequency, pod_set_band_1_frequency); 298 pod_get_band_1_frequency, pod_set_band_1_frequency);
299static DEVICE_ATTR(presence, S_IWUGO | S_IRUGO, pod_get_presence, 299static DEVICE_ATTR(presence, S_IWUSR | S_IRUGO, pod_get_presence,
300 pod_set_presence); 300 pod_set_presence);
301static DEVICE_ATTR2(treble__bass, treble, S_IWUGO | S_IRUGO, 301static DEVICE_ATTR2(treble__bass, treble, S_IWUSR | S_IRUGO,
302 pod_get_treble__bass, pod_set_treble__bass); 302 pod_get_treble__bass, pod_set_treble__bass);
303static DEVICE_ATTR(noise_gate_enable, S_IWUGO | S_IRUGO, 303static DEVICE_ATTR(noise_gate_enable, S_IWUSR | S_IRUGO,
304 pod_get_noise_gate_enable, pod_set_noise_gate_enable); 304 pod_get_noise_gate_enable, pod_set_noise_gate_enable);
305static DEVICE_ATTR(gate_threshold, S_IWUGO | S_IRUGO, pod_get_gate_threshold, 305static DEVICE_ATTR(gate_threshold, S_IWUSR | S_IRUGO, pod_get_gate_threshold,
306 pod_set_gate_threshold); 306 pod_set_gate_threshold);
307static DEVICE_ATTR(gate_decay_time, S_IWUGO | S_IRUGO, pod_get_gate_decay_time, 307static DEVICE_ATTR(gate_decay_time, S_IWUSR | S_IRUGO, pod_get_gate_decay_time,
308 pod_set_gate_decay_time); 308 pod_set_gate_decay_time);
309static DEVICE_ATTR(stomp_enable, S_IWUGO | S_IRUGO, pod_get_stomp_enable, 309static DEVICE_ATTR(stomp_enable, S_IWUSR | S_IRUGO, pod_get_stomp_enable,
310 pod_set_stomp_enable); 310 pod_set_stomp_enable);
311static DEVICE_ATTR(comp_enable, S_IWUGO | S_IRUGO, pod_get_comp_enable, 311static DEVICE_ATTR(comp_enable, S_IWUSR | S_IRUGO, pod_get_comp_enable,
312 pod_set_comp_enable); 312 pod_set_comp_enable);
313static DEVICE_ATTR(stomp_time, S_IWUGO | S_IRUGO, pod_get_stomp_time, 313static DEVICE_ATTR(stomp_time, S_IWUSR | S_IRUGO, pod_get_stomp_time,
314 pod_set_stomp_time); 314 pod_set_stomp_time);
315static DEVICE_ATTR(delay_enable, S_IWUGO | S_IRUGO, pod_get_delay_enable, 315static DEVICE_ATTR(delay_enable, S_IWUSR | S_IRUGO, pod_get_delay_enable,
316 pod_set_delay_enable); 316 pod_set_delay_enable);
317static DEVICE_ATTR(mod_param_1, S_IWUGO | S_IRUGO, pod_get_mod_param_1, 317static DEVICE_ATTR(mod_param_1, S_IWUSR | S_IRUGO, pod_get_mod_param_1,
318 pod_set_mod_param_1); 318 pod_set_mod_param_1);
319static DEVICE_ATTR(delay_param_1, S_IWUGO | S_IRUGO, pod_get_delay_param_1, 319static DEVICE_ATTR(delay_param_1, S_IWUSR | S_IRUGO, pod_get_delay_param_1,
320 pod_set_delay_param_1); 320 pod_set_delay_param_1);
321static DEVICE_ATTR(delay_param_1_note_value, S_IWUGO | S_IRUGO, 321static DEVICE_ATTR(delay_param_1_note_value, S_IWUSR | S_IRUGO,
322 pod_get_delay_param_1_note_value, 322 pod_get_delay_param_1_note_value,
323 pod_set_delay_param_1_note_value); 323 pod_set_delay_param_1_note_value);
324static DEVICE_ATTR2(band_2_frequency__bass, band_2_frequency, S_IWUGO | S_IRUGO, 324static DEVICE_ATTR2(band_2_frequency__bass, band_2_frequency, S_IWUSR | S_IRUGO,
325 pod_get_band_2_frequency__bass, 325 pod_get_band_2_frequency__bass,
326 pod_set_band_2_frequency__bass); 326 pod_set_band_2_frequency__bass);
327static DEVICE_ATTR(delay_param_2, S_IWUGO | S_IRUGO, pod_get_delay_param_2, 327static DEVICE_ATTR(delay_param_2, S_IWUSR | S_IRUGO, pod_get_delay_param_2,
328 pod_set_delay_param_2); 328 pod_set_delay_param_2);
329static DEVICE_ATTR(delay_volume_mix, S_IWUGO | S_IRUGO, 329static DEVICE_ATTR(delay_volume_mix, S_IWUSR | S_IRUGO,
330 pod_get_delay_volume_mix, pod_set_delay_volume_mix); 330 pod_get_delay_volume_mix, pod_set_delay_volume_mix);
331static DEVICE_ATTR(delay_param_3, S_IWUGO | S_IRUGO, pod_get_delay_param_3, 331static DEVICE_ATTR(delay_param_3, S_IWUSR | S_IRUGO, pod_get_delay_param_3,
332 pod_set_delay_param_3); 332 pod_set_delay_param_3);
333static DEVICE_ATTR(reverb_enable, S_IWUGO | S_IRUGO, pod_get_reverb_enable, 333static DEVICE_ATTR(reverb_enable, S_IWUSR | S_IRUGO, pod_get_reverb_enable,
334 pod_set_reverb_enable); 334 pod_set_reverb_enable);
335static DEVICE_ATTR(reverb_type, S_IWUGO | S_IRUGO, pod_get_reverb_type, 335static DEVICE_ATTR(reverb_type, S_IWUSR | S_IRUGO, pod_get_reverb_type,
336 pod_set_reverb_type); 336 pod_set_reverb_type);
337static DEVICE_ATTR(reverb_decay, S_IWUGO | S_IRUGO, pod_get_reverb_decay, 337static DEVICE_ATTR(reverb_decay, S_IWUSR | S_IRUGO, pod_get_reverb_decay,
338 pod_set_reverb_decay); 338 pod_set_reverb_decay);
339static DEVICE_ATTR(reverb_tone, S_IWUGO | S_IRUGO, pod_get_reverb_tone, 339static DEVICE_ATTR(reverb_tone, S_IWUSR | S_IRUGO, pod_get_reverb_tone,
340 pod_set_reverb_tone); 340 pod_set_reverb_tone);
341static DEVICE_ATTR(reverb_pre_delay, S_IWUGO | S_IRUGO, 341static DEVICE_ATTR(reverb_pre_delay, S_IWUSR | S_IRUGO,
342 pod_get_reverb_pre_delay, pod_set_reverb_pre_delay); 342 pod_get_reverb_pre_delay, pod_set_reverb_pre_delay);
343static DEVICE_ATTR(reverb_pre_post, S_IWUGO | S_IRUGO, pod_get_reverb_pre_post, 343static DEVICE_ATTR(reverb_pre_post, S_IWUSR | S_IRUGO, pod_get_reverb_pre_post,
344 pod_set_reverb_pre_post); 344 pod_set_reverb_pre_post);
345static DEVICE_ATTR(band_2_frequency, S_IWUGO | S_IRUGO, 345static DEVICE_ATTR(band_2_frequency, S_IWUSR | S_IRUGO,
346 pod_get_band_2_frequency, pod_set_band_2_frequency); 346 pod_get_band_2_frequency, pod_set_band_2_frequency);
347static DEVICE_ATTR2(band_3_frequency__bass, band_3_frequency, S_IWUGO | S_IRUGO, 347static DEVICE_ATTR2(band_3_frequency__bass, band_3_frequency, S_IWUSR | S_IRUGO,
348 pod_get_band_3_frequency__bass, 348 pod_get_band_3_frequency__bass,
349 pod_set_band_3_frequency__bass); 349 pod_set_band_3_frequency__bass);
350static DEVICE_ATTR(wah_enable, S_IWUGO | S_IRUGO, pod_get_wah_enable, 350static DEVICE_ATTR(wah_enable, S_IWUSR | S_IRUGO, pod_get_wah_enable,
351 pod_set_wah_enable); 351 pod_set_wah_enable);
352static DEVICE_ATTR(modulation_lo_cut, S_IWUGO | S_IRUGO, 352static DEVICE_ATTR(modulation_lo_cut, S_IWUSR | S_IRUGO,
353 pod_get_modulation_lo_cut, pod_set_modulation_lo_cut); 353 pod_get_modulation_lo_cut, pod_set_modulation_lo_cut);
354static DEVICE_ATTR(delay_reverb_lo_cut, S_IWUGO | S_IRUGO, 354static DEVICE_ATTR(delay_reverb_lo_cut, S_IWUSR | S_IRUGO,
355 pod_get_delay_reverb_lo_cut, pod_set_delay_reverb_lo_cut); 355 pod_get_delay_reverb_lo_cut, pod_set_delay_reverb_lo_cut);
356static DEVICE_ATTR(volume_pedal_minimum, S_IWUGO | S_IRUGO, 356static DEVICE_ATTR(volume_pedal_minimum, S_IWUSR | S_IRUGO,
357 pod_get_volume_pedal_minimum, pod_set_volume_pedal_minimum); 357 pod_get_volume_pedal_minimum, pod_set_volume_pedal_minimum);
358static DEVICE_ATTR(eq_pre_post, S_IWUGO | S_IRUGO, pod_get_eq_pre_post, 358static DEVICE_ATTR(eq_pre_post, S_IWUSR | S_IRUGO, pod_get_eq_pre_post,
359 pod_set_eq_pre_post); 359 pod_set_eq_pre_post);
360static DEVICE_ATTR(volume_pre_post, S_IWUGO | S_IRUGO, pod_get_volume_pre_post, 360static DEVICE_ATTR(volume_pre_post, S_IWUSR | S_IRUGO, pod_get_volume_pre_post,
361 pod_set_volume_pre_post); 361 pod_set_volume_pre_post);
362static DEVICE_ATTR(di_model, S_IWUGO | S_IRUGO, pod_get_di_model, 362static DEVICE_ATTR(di_model, S_IWUSR | S_IRUGO, pod_get_di_model,
363 pod_set_di_model); 363 pod_set_di_model);
364static DEVICE_ATTR(di_delay, S_IWUGO | S_IRUGO, pod_get_di_delay, 364static DEVICE_ATTR(di_delay, S_IWUSR | S_IRUGO, pod_get_di_delay,
365 pod_set_di_delay); 365 pod_set_di_delay);
366static DEVICE_ATTR(mod_enable, S_IWUGO | S_IRUGO, pod_get_mod_enable, 366static DEVICE_ATTR(mod_enable, S_IWUSR | S_IRUGO, pod_get_mod_enable,
367 pod_set_mod_enable); 367 pod_set_mod_enable);
368static DEVICE_ATTR(mod_param_1_note_value, S_IWUGO | S_IRUGO, 368static DEVICE_ATTR(mod_param_1_note_value, S_IWUSR | S_IRUGO,
369 pod_get_mod_param_1_note_value, 369 pod_get_mod_param_1_note_value,
370 pod_set_mod_param_1_note_value); 370 pod_set_mod_param_1_note_value);
371static DEVICE_ATTR(mod_param_2, S_IWUGO | S_IRUGO, pod_get_mod_param_2, 371static DEVICE_ATTR(mod_param_2, S_IWUSR | S_IRUGO, pod_get_mod_param_2,
372 pod_set_mod_param_2); 372 pod_set_mod_param_2);
373static DEVICE_ATTR(mod_param_3, S_IWUGO | S_IRUGO, pod_get_mod_param_3, 373static DEVICE_ATTR(mod_param_3, S_IWUSR | S_IRUGO, pod_get_mod_param_3,
374 pod_set_mod_param_3); 374 pod_set_mod_param_3);
375static DEVICE_ATTR(mod_param_4, S_IWUGO | S_IRUGO, pod_get_mod_param_4, 375static DEVICE_ATTR(mod_param_4, S_IWUSR | S_IRUGO, pod_get_mod_param_4,
376 pod_set_mod_param_4); 376 pod_set_mod_param_4);
377static DEVICE_ATTR(mod_param_5, S_IWUGO | S_IRUGO, pod_get_mod_param_5, 377static DEVICE_ATTR(mod_param_5, S_IWUSR | S_IRUGO, pod_get_mod_param_5,
378 pod_set_mod_param_5); 378 pod_set_mod_param_5);
379static DEVICE_ATTR(mod_volume_mix, S_IWUGO | S_IRUGO, pod_get_mod_volume_mix, 379static DEVICE_ATTR(mod_volume_mix, S_IWUSR | S_IRUGO, pod_get_mod_volume_mix,
380 pod_set_mod_volume_mix); 380 pod_set_mod_volume_mix);
381static DEVICE_ATTR(mod_pre_post, S_IWUGO | S_IRUGO, pod_get_mod_pre_post, 381static DEVICE_ATTR(mod_pre_post, S_IWUSR | S_IRUGO, pod_get_mod_pre_post,
382 pod_set_mod_pre_post); 382 pod_set_mod_pre_post);
383static DEVICE_ATTR(modulation_model, S_IWUGO | S_IRUGO, 383static DEVICE_ATTR(modulation_model, S_IWUSR | S_IRUGO,
384 pod_get_modulation_model, pod_set_modulation_model); 384 pod_get_modulation_model, pod_set_modulation_model);
385static DEVICE_ATTR(band_3_frequency, S_IWUGO | S_IRUGO, 385static DEVICE_ATTR(band_3_frequency, S_IWUSR | S_IRUGO,
386 pod_get_band_3_frequency, pod_set_band_3_frequency); 386 pod_get_band_3_frequency, pod_set_band_3_frequency);
387static DEVICE_ATTR2(band_4_frequency__bass, band_4_frequency, S_IWUGO | S_IRUGO, 387static DEVICE_ATTR2(band_4_frequency__bass, band_4_frequency, S_IWUSR | S_IRUGO,
388 pod_get_band_4_frequency__bass, 388 pod_get_band_4_frequency__bass,
389 pod_set_band_4_frequency__bass); 389 pod_set_band_4_frequency__bass);
390static DEVICE_ATTR(mod_param_1_double_precision, S_IWUGO | S_IRUGO, 390static DEVICE_ATTR(mod_param_1_double_precision, S_IWUSR | S_IRUGO,
391 pod_get_mod_param_1_double_precision, 391 pod_get_mod_param_1_double_precision,
392 pod_set_mod_param_1_double_precision); 392 pod_set_mod_param_1_double_precision);
393static DEVICE_ATTR(delay_param_1_double_precision, S_IWUGO | S_IRUGO, 393static DEVICE_ATTR(delay_param_1_double_precision, S_IWUSR | S_IRUGO,
394 pod_get_delay_param_1_double_precision, 394 pod_get_delay_param_1_double_precision,
395 pod_set_delay_param_1_double_precision); 395 pod_set_delay_param_1_double_precision);
396static DEVICE_ATTR(eq_enable, S_IWUGO | S_IRUGO, pod_get_eq_enable, 396static DEVICE_ATTR(eq_enable, S_IWUSR | S_IRUGO, pod_get_eq_enable,
397 pod_set_eq_enable); 397 pod_set_eq_enable);
398static DEVICE_ATTR(tap, S_IWUGO | S_IRUGO, pod_get_tap, pod_set_tap); 398static DEVICE_ATTR(tap, S_IWUSR | S_IRUGO, pod_get_tap, pod_set_tap);
399static DEVICE_ATTR(volume_tweak_pedal_assign, S_IWUGO | S_IRUGO, 399static DEVICE_ATTR(volume_tweak_pedal_assign, S_IWUSR | S_IRUGO,
400 pod_get_volume_tweak_pedal_assign, 400 pod_get_volume_tweak_pedal_assign,
401 pod_set_volume_tweak_pedal_assign); 401 pod_set_volume_tweak_pedal_assign);
402static DEVICE_ATTR(band_5_frequency, S_IWUGO | S_IRUGO, 402static DEVICE_ATTR(band_5_frequency, S_IWUSR | S_IRUGO,
403 pod_get_band_5_frequency, pod_set_band_5_frequency); 403 pod_get_band_5_frequency, pod_set_band_5_frequency);
404static DEVICE_ATTR(tuner, S_IWUGO | S_IRUGO, pod_get_tuner, pod_set_tuner); 404static DEVICE_ATTR(tuner, S_IWUSR | S_IRUGO, pod_get_tuner, pod_set_tuner);
405static DEVICE_ATTR(mic_selection, S_IWUGO | S_IRUGO, pod_get_mic_selection, 405static DEVICE_ATTR(mic_selection, S_IWUSR | S_IRUGO, pod_get_mic_selection,
406 pod_set_mic_selection); 406 pod_set_mic_selection);
407static DEVICE_ATTR(cabinet_model, S_IWUGO | S_IRUGO, pod_get_cabinet_model, 407static DEVICE_ATTR(cabinet_model, S_IWUSR | S_IRUGO, pod_get_cabinet_model,
408 pod_set_cabinet_model); 408 pod_set_cabinet_model);
409static DEVICE_ATTR(stomp_model, S_IWUGO | S_IRUGO, pod_get_stomp_model, 409static DEVICE_ATTR(stomp_model, S_IWUSR | S_IRUGO, pod_get_stomp_model,
410 pod_set_stomp_model); 410 pod_set_stomp_model);
411static DEVICE_ATTR(roomlevel, S_IWUGO | S_IRUGO, pod_get_roomlevel, 411static DEVICE_ATTR(roomlevel, S_IWUSR | S_IRUGO, pod_get_roomlevel,
412 pod_set_roomlevel); 412 pod_set_roomlevel);
413static DEVICE_ATTR(band_4_frequency, S_IWUGO | S_IRUGO, 413static DEVICE_ATTR(band_4_frequency, S_IWUSR | S_IRUGO,
414 pod_get_band_4_frequency, pod_set_band_4_frequency); 414 pod_get_band_4_frequency, pod_set_band_4_frequency);
415static DEVICE_ATTR(band_6_frequency, S_IWUGO | S_IRUGO, 415static DEVICE_ATTR(band_6_frequency, S_IWUSR | S_IRUGO,
416 pod_get_band_6_frequency, pod_set_band_6_frequency); 416 pod_get_band_6_frequency, pod_set_band_6_frequency);
417static DEVICE_ATTR(stomp_param_1_note_value, S_IWUGO | S_IRUGO, 417static DEVICE_ATTR(stomp_param_1_note_value, S_IWUSR | S_IRUGO,
418 pod_get_stomp_param_1_note_value, 418 pod_get_stomp_param_1_note_value,
419 pod_set_stomp_param_1_note_value); 419 pod_set_stomp_param_1_note_value);
420static DEVICE_ATTR(stomp_param_2, S_IWUGO | S_IRUGO, pod_get_stomp_param_2, 420static DEVICE_ATTR(stomp_param_2, S_IWUSR | S_IRUGO, pod_get_stomp_param_2,
421 pod_set_stomp_param_2); 421 pod_set_stomp_param_2);
422static DEVICE_ATTR(stomp_param_3, S_IWUGO | S_IRUGO, pod_get_stomp_param_3, 422static DEVICE_ATTR(stomp_param_3, S_IWUSR | S_IRUGO, pod_get_stomp_param_3,
423 pod_set_stomp_param_3); 423 pod_set_stomp_param_3);
424static DEVICE_ATTR(stomp_param_4, S_IWUGO | S_IRUGO, pod_get_stomp_param_4, 424static DEVICE_ATTR(stomp_param_4, S_IWUSR | S_IRUGO, pod_get_stomp_param_4,
425 pod_set_stomp_param_4); 425 pod_set_stomp_param_4);
426static DEVICE_ATTR(stomp_param_5, S_IWUGO | S_IRUGO, pod_get_stomp_param_5, 426static DEVICE_ATTR(stomp_param_5, S_IWUSR | S_IRUGO, pod_get_stomp_param_5,
427 pod_set_stomp_param_5); 427 pod_set_stomp_param_5);
428static DEVICE_ATTR(stomp_param_6, S_IWUGO | S_IRUGO, pod_get_stomp_param_6, 428static DEVICE_ATTR(stomp_param_6, S_IWUSR | S_IRUGO, pod_get_stomp_param_6,
429 pod_set_stomp_param_6); 429 pod_set_stomp_param_6);
430static DEVICE_ATTR(amp_switch_select, S_IWUGO | S_IRUGO, 430static DEVICE_ATTR(amp_switch_select, S_IWUSR | S_IRUGO,
431 pod_get_amp_switch_select, pod_set_amp_switch_select); 431 pod_get_amp_switch_select, pod_set_amp_switch_select);
432static DEVICE_ATTR(delay_param_4, S_IWUGO | S_IRUGO, pod_get_delay_param_4, 432static DEVICE_ATTR(delay_param_4, S_IWUSR | S_IRUGO, pod_get_delay_param_4,
433 pod_set_delay_param_4); 433 pod_set_delay_param_4);
434static DEVICE_ATTR(delay_param_5, S_IWUGO | S_IRUGO, pod_get_delay_param_5, 434static DEVICE_ATTR(delay_param_5, S_IWUSR | S_IRUGO, pod_get_delay_param_5,
435 pod_set_delay_param_5); 435 pod_set_delay_param_5);
436static DEVICE_ATTR(delay_pre_post, S_IWUGO | S_IRUGO, pod_get_delay_pre_post, 436static DEVICE_ATTR(delay_pre_post, S_IWUSR | S_IRUGO, pod_get_delay_pre_post,
437 pod_set_delay_pre_post); 437 pod_set_delay_pre_post);
438static DEVICE_ATTR(delay_model, S_IWUGO | S_IRUGO, pod_get_delay_model, 438static DEVICE_ATTR(delay_model, S_IWUSR | S_IRUGO, pod_get_delay_model,
439 pod_set_delay_model); 439 pod_set_delay_model);
440static DEVICE_ATTR(delay_verb_model, S_IWUGO | S_IRUGO, 440static DEVICE_ATTR(delay_verb_model, S_IWUSR | S_IRUGO,
441 pod_get_delay_verb_model, pod_set_delay_verb_model); 441 pod_get_delay_verb_model, pod_set_delay_verb_model);
442static DEVICE_ATTR(tempo_msb, S_IWUGO | S_IRUGO, pod_get_tempo_msb, 442static DEVICE_ATTR(tempo_msb, S_IWUSR | S_IRUGO, pod_get_tempo_msb,
443 pod_set_tempo_msb); 443 pod_set_tempo_msb);
444static DEVICE_ATTR(tempo_lsb, S_IWUGO | S_IRUGO, pod_get_tempo_lsb, 444static DEVICE_ATTR(tempo_lsb, S_IWUSR | S_IRUGO, pod_get_tempo_lsb,
445 pod_set_tempo_lsb); 445 pod_set_tempo_lsb);
446static DEVICE_ATTR(wah_model, S_IWUGO | S_IRUGO, pod_get_wah_model, 446static DEVICE_ATTR(wah_model, S_IWUSR | S_IRUGO, pod_get_wah_model,
447 pod_set_wah_model); 447 pod_set_wah_model);
448static DEVICE_ATTR(bypass_volume, S_IWUGO | S_IRUGO, pod_get_bypass_volume, 448static DEVICE_ATTR(bypass_volume, S_IWUSR | S_IRUGO, pod_get_bypass_volume,
449 pod_set_bypass_volume); 449 pod_set_bypass_volume);
450static DEVICE_ATTR(fx_loop_on_off, S_IWUGO | S_IRUGO, pod_get_fx_loop_on_off, 450static DEVICE_ATTR(fx_loop_on_off, S_IWUSR | S_IRUGO, pod_get_fx_loop_on_off,
451 pod_set_fx_loop_on_off); 451 pod_set_fx_loop_on_off);
452static DEVICE_ATTR(tweak_param_select, S_IWUGO | S_IRUGO, 452static DEVICE_ATTR(tweak_param_select, S_IWUSR | S_IRUGO,
453 pod_get_tweak_param_select, pod_set_tweak_param_select); 453 pod_get_tweak_param_select, pod_set_tweak_param_select);
454static DEVICE_ATTR(amp1_engage, S_IWUGO | S_IRUGO, pod_get_amp1_engage, 454static DEVICE_ATTR(amp1_engage, S_IWUSR | S_IRUGO, pod_get_amp1_engage,
455 pod_set_amp1_engage); 455 pod_set_amp1_engage);
456static DEVICE_ATTR(band_1_gain, S_IWUGO | S_IRUGO, pod_get_band_1_gain, 456static DEVICE_ATTR(band_1_gain, S_IWUSR | S_IRUGO, pod_get_band_1_gain,
457 pod_set_band_1_gain); 457 pod_set_band_1_gain);
458static DEVICE_ATTR2(band_2_gain__bass, band_2_gain, S_IWUGO | S_IRUGO, 458static DEVICE_ATTR2(band_2_gain__bass, band_2_gain, S_IWUSR | S_IRUGO,
459 pod_get_band_2_gain__bass, pod_set_band_2_gain__bass); 459 pod_get_band_2_gain__bass, pod_set_band_2_gain__bass);
460static DEVICE_ATTR(band_2_gain, S_IWUGO | S_IRUGO, pod_get_band_2_gain, 460static DEVICE_ATTR(band_2_gain, S_IWUSR | S_IRUGO, pod_get_band_2_gain,
461 pod_set_band_2_gain); 461 pod_set_band_2_gain);
462static DEVICE_ATTR2(band_3_gain__bass, band_3_gain, S_IWUGO | S_IRUGO, 462static DEVICE_ATTR2(band_3_gain__bass, band_3_gain, S_IWUSR | S_IRUGO,
463 pod_get_band_3_gain__bass, pod_set_band_3_gain__bass); 463 pod_get_band_3_gain__bass, pod_set_band_3_gain__bass);
464static DEVICE_ATTR(band_3_gain, S_IWUGO | S_IRUGO, pod_get_band_3_gain, 464static DEVICE_ATTR(band_3_gain, S_IWUSR | S_IRUGO, pod_get_band_3_gain,
465 pod_set_band_3_gain); 465 pod_set_band_3_gain);
466static DEVICE_ATTR2(band_4_gain__bass, band_4_gain, S_IWUGO | S_IRUGO, 466static DEVICE_ATTR2(band_4_gain__bass, band_4_gain, S_IWUSR | S_IRUGO,
467 pod_get_band_4_gain__bass, pod_set_band_4_gain__bass); 467 pod_get_band_4_gain__bass, pod_set_band_4_gain__bass);
468static DEVICE_ATTR2(band_5_gain__bass, band_5_gain, S_IWUGO | S_IRUGO, 468static DEVICE_ATTR2(band_5_gain__bass, band_5_gain, S_IWUSR | S_IRUGO,
469 pod_get_band_5_gain__bass, pod_set_band_5_gain__bass); 469 pod_get_band_5_gain__bass, pod_set_band_5_gain__bass);
470static DEVICE_ATTR(band_4_gain, S_IWUGO | S_IRUGO, pod_get_band_4_gain, 470static DEVICE_ATTR(band_4_gain, S_IWUSR | S_IRUGO, pod_get_band_4_gain,
471 pod_set_band_4_gain); 471 pod_set_band_4_gain);
472static DEVICE_ATTR2(band_6_gain__bass, band_6_gain, S_IWUGO | S_IRUGO, 472static DEVICE_ATTR2(band_6_gain__bass, band_6_gain, S_IWUSR | S_IRUGO,
473 pod_get_band_6_gain__bass, pod_set_band_6_gain__bass); 473 pod_get_band_6_gain__bass, pod_set_band_6_gain__bass);
474static DEVICE_ATTR(body, S_IRUGO, variax_get_body, line6_nop_write); 474static DEVICE_ATTR(body, S_IRUGO, variax_get_body, line6_nop_write);
475static DEVICE_ATTR(pickup1_enable, S_IRUGO, variax_get_pickup1_enable, 475static DEVICE_ATTR(pickup1_enable, S_IRUGO, variax_get_pickup1_enable,
diff --git a/drivers/staging/line6/midi.c b/drivers/staging/line6/midi.c
index 4304dfe6c166..ab67e889d2c4 100644
--- a/drivers/staging/line6/midi.c
+++ b/drivers/staging/line6/midi.c
@@ -350,9 +350,9 @@ static ssize_t midi_set_midi_mask_receive(struct device *dev,
350 return count; 350 return count;
351} 351}
352 352
353static DEVICE_ATTR(midi_mask_transmit, S_IWUGO | S_IRUGO, 353static DEVICE_ATTR(midi_mask_transmit, S_IWUSR | S_IRUGO,
354 midi_get_midi_mask_transmit, midi_set_midi_mask_transmit); 354 midi_get_midi_mask_transmit, midi_set_midi_mask_transmit);
355static DEVICE_ATTR(midi_mask_receive, S_IWUGO | S_IRUGO, 355static DEVICE_ATTR(midi_mask_receive, S_IWUSR | S_IRUGO,
356 midi_get_midi_mask_receive, midi_set_midi_mask_receive); 356 midi_get_midi_mask_receive, midi_set_midi_mask_receive);
357 357
358/* MIDI device destructor */ 358/* MIDI device destructor */
diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index e54770e34d2e..b9c55f9eb501 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -79,9 +79,9 @@ static ssize_t pcm_set_impulse_period(struct device *dev,
79 return count; 79 return count;
80} 80}
81 81
82static DEVICE_ATTR(impulse_volume, S_IWUGO | S_IRUGO, pcm_get_impulse_volume, 82static DEVICE_ATTR(impulse_volume, S_IWUSR | S_IRUGO, pcm_get_impulse_volume,
83 pcm_set_impulse_volume); 83 pcm_set_impulse_volume);
84static DEVICE_ATTR(impulse_period, S_IWUGO | S_IRUGO, pcm_get_impulse_period, 84static DEVICE_ATTR(impulse_period, S_IWUSR | S_IRUGO, pcm_get_impulse_period,
85 pcm_set_impulse_period); 85 pcm_set_impulse_period);
86 86
87#endif 87#endif
diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c
index 22e2cedcacf7..d9b30212585c 100644
--- a/drivers/staging/line6/pod.c
+++ b/drivers/staging/line6/pod.c
@@ -1051,48 +1051,48 @@ POD_GET_SYSTEM_PARAM(tuner_pitch, 1);
1051#undef GET_SYSTEM_PARAM 1051#undef GET_SYSTEM_PARAM
1052 1052
1053/* POD special files: */ 1053/* POD special files: */
1054static DEVICE_ATTR(channel, S_IWUGO | S_IRUGO, pod_get_channel, 1054static DEVICE_ATTR(channel, S_IWUSR | S_IRUGO, pod_get_channel,
1055 pod_set_channel); 1055 pod_set_channel);
1056static DEVICE_ATTR(clip, S_IRUGO, pod_wait_for_clip, line6_nop_write); 1056static DEVICE_ATTR(clip, S_IRUGO, pod_wait_for_clip, line6_nop_write);
1057static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write); 1057static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write);
1058static DEVICE_ATTR(dirty, S_IRUGO, pod_get_dirty, line6_nop_write); 1058static DEVICE_ATTR(dirty, S_IRUGO, pod_get_dirty, line6_nop_write);
1059static DEVICE_ATTR(dump, S_IWUGO | S_IRUGO, pod_get_dump, pod_set_dump); 1059static DEVICE_ATTR(dump, S_IWUSR | S_IRUGO, pod_get_dump, pod_set_dump);
1060static DEVICE_ATTR(dump_buf, S_IWUGO | S_IRUGO, pod_get_dump_buf, 1060static DEVICE_ATTR(dump_buf, S_IWUSR | S_IRUGO, pod_get_dump_buf,
1061 pod_set_dump_buf); 1061 pod_set_dump_buf);
1062static DEVICE_ATTR(finish, S_IWUGO, line6_nop_read, pod_set_finish); 1062static DEVICE_ATTR(finish, S_IWUSR, line6_nop_read, pod_set_finish);
1063static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version, 1063static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version,
1064 line6_nop_write); 1064 line6_nop_write);
1065static DEVICE_ATTR(midi_postprocess, S_IWUGO | S_IRUGO, 1065static DEVICE_ATTR(midi_postprocess, S_IWUSR | S_IRUGO,
1066 pod_get_midi_postprocess, pod_set_midi_postprocess); 1066 pod_get_midi_postprocess, pod_set_midi_postprocess);
1067static DEVICE_ATTR(monitor_level, S_IWUGO | S_IRUGO, pod_get_monitor_level, 1067static DEVICE_ATTR(monitor_level, S_IWUSR | S_IRUGO, pod_get_monitor_level,
1068 pod_set_monitor_level); 1068 pod_set_monitor_level);
1069static DEVICE_ATTR(name, S_IRUGO, pod_get_name, line6_nop_write); 1069static DEVICE_ATTR(name, S_IRUGO, pod_get_name, line6_nop_write);
1070static DEVICE_ATTR(name_buf, S_IRUGO, pod_get_name_buf, line6_nop_write); 1070static DEVICE_ATTR(name_buf, S_IRUGO, pod_get_name_buf, line6_nop_write);
1071static DEVICE_ATTR(retrieve_amp_setup, S_IWUGO, line6_nop_read, 1071static DEVICE_ATTR(retrieve_amp_setup, S_IWUSR, line6_nop_read,
1072 pod_set_retrieve_amp_setup); 1072 pod_set_retrieve_amp_setup);
1073static DEVICE_ATTR(retrieve_channel, S_IWUGO, line6_nop_read, 1073static DEVICE_ATTR(retrieve_channel, S_IWUSR, line6_nop_read,
1074 pod_set_retrieve_channel); 1074 pod_set_retrieve_channel);
1075static DEVICE_ATTR(retrieve_effects_setup, S_IWUGO, line6_nop_read, 1075static DEVICE_ATTR(retrieve_effects_setup, S_IWUSR, line6_nop_read,
1076 pod_set_retrieve_effects_setup); 1076 pod_set_retrieve_effects_setup);
1077static DEVICE_ATTR(routing, S_IWUGO | S_IRUGO, pod_get_routing, 1077static DEVICE_ATTR(routing, S_IWUSR | S_IRUGO, pod_get_routing,
1078 pod_set_routing); 1078 pod_set_routing);
1079static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number, 1079static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number,
1080 line6_nop_write); 1080 line6_nop_write);
1081static DEVICE_ATTR(store_amp_setup, S_IWUGO, line6_nop_read, 1081static DEVICE_ATTR(store_amp_setup, S_IWUSR, line6_nop_read,
1082 pod_set_store_amp_setup); 1082 pod_set_store_amp_setup);
1083static DEVICE_ATTR(store_channel, S_IWUGO, line6_nop_read, 1083static DEVICE_ATTR(store_channel, S_IWUSR, line6_nop_read,
1084 pod_set_store_channel); 1084 pod_set_store_channel);
1085static DEVICE_ATTR(store_effects_setup, S_IWUGO, line6_nop_read, 1085static DEVICE_ATTR(store_effects_setup, S_IWUSR, line6_nop_read,
1086 pod_set_store_effects_setup); 1086 pod_set_store_effects_setup);
1087static DEVICE_ATTR(tuner_freq, S_IWUGO | S_IRUGO, pod_get_tuner_freq, 1087static DEVICE_ATTR(tuner_freq, S_IWUSR | S_IRUGO, pod_get_tuner_freq,
1088 pod_set_tuner_freq); 1088 pod_set_tuner_freq);
1089static DEVICE_ATTR(tuner_mute, S_IWUGO | S_IRUGO, pod_get_tuner_mute, 1089static DEVICE_ATTR(tuner_mute, S_IWUSR | S_IRUGO, pod_get_tuner_mute,
1090 pod_set_tuner_mute); 1090 pod_set_tuner_mute);
1091static DEVICE_ATTR(tuner_note, S_IRUGO, pod_get_tuner_note, line6_nop_write); 1091static DEVICE_ATTR(tuner_note, S_IRUGO, pod_get_tuner_note, line6_nop_write);
1092static DEVICE_ATTR(tuner_pitch, S_IRUGO, pod_get_tuner_pitch, line6_nop_write); 1092static DEVICE_ATTR(tuner_pitch, S_IRUGO, pod_get_tuner_pitch, line6_nop_write);
1093 1093
1094#ifdef CONFIG_LINE6_USB_RAW 1094#ifdef CONFIG_LINE6_USB_RAW
1095static DEVICE_ATTR(raw, S_IWUGO, line6_nop_read, line6_set_raw); 1095static DEVICE_ATTR(raw, S_IWUSR, line6_nop_read, line6_set_raw);
1096#endif 1096#endif
1097 1097
1098/* control info callback */ 1098/* control info callback */
diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c
index 6a10b0f9749a..879e6992bbc6 100644
--- a/drivers/staging/line6/toneport.c
+++ b/drivers/staging/line6/toneport.c
@@ -154,9 +154,9 @@ static ssize_t toneport_set_led_green(struct device *dev,
154 return count; 154 return count;
155} 155}
156 156
157static DEVICE_ATTR(led_red, S_IWUGO | S_IRUGO, line6_nop_read, 157static DEVICE_ATTR(led_red, S_IWUSR | S_IRUGO, line6_nop_read,
158 toneport_set_led_red); 158 toneport_set_led_red);
159static DEVICE_ATTR(led_green, S_IWUGO | S_IRUGO, line6_nop_read, 159static DEVICE_ATTR(led_green, S_IWUSR | S_IRUGO, line6_nop_read,
160 toneport_set_led_green); 160 toneport_set_led_green);
161 161
162static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) 162static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
diff --git a/drivers/staging/line6/variax.c b/drivers/staging/line6/variax.c
index 894eee7f2317..81241cdf1be9 100644
--- a/drivers/staging/line6/variax.c
+++ b/drivers/staging/line6/variax.c
@@ -549,21 +549,21 @@ static ssize_t variax_set_raw2(struct device *dev,
549#endif 549#endif
550 550
551/* Variax workbench special files: */ 551/* Variax workbench special files: */
552static DEVICE_ATTR(model, S_IWUGO | S_IRUGO, variax_get_model, 552static DEVICE_ATTR(model, S_IWUSR | S_IRUGO, variax_get_model,
553 variax_set_model); 553 variax_set_model);
554static DEVICE_ATTR(volume, S_IWUGO | S_IRUGO, variax_get_volume, 554static DEVICE_ATTR(volume, S_IWUSR | S_IRUGO, variax_get_volume,
555 variax_set_volume); 555 variax_set_volume);
556static DEVICE_ATTR(tone, S_IWUGO | S_IRUGO, variax_get_tone, variax_set_tone); 556static DEVICE_ATTR(tone, S_IWUSR | S_IRUGO, variax_get_tone, variax_set_tone);
557static DEVICE_ATTR(name, S_IRUGO, variax_get_name, line6_nop_write); 557static DEVICE_ATTR(name, S_IRUGO, variax_get_name, line6_nop_write);
558static DEVICE_ATTR(bank, S_IRUGO, variax_get_bank, line6_nop_write); 558static DEVICE_ATTR(bank, S_IRUGO, variax_get_bank, line6_nop_write);
559static DEVICE_ATTR(dump, S_IRUGO, variax_get_dump, line6_nop_write); 559static DEVICE_ATTR(dump, S_IRUGO, variax_get_dump, line6_nop_write);
560static DEVICE_ATTR(active, S_IWUGO | S_IRUGO, variax_get_active, 560static DEVICE_ATTR(active, S_IWUSR | S_IRUGO, variax_get_active,
561 variax_set_active); 561 variax_set_active);
562static DEVICE_ATTR(guitar, S_IRUGO, variax_get_guitar, line6_nop_write); 562static DEVICE_ATTR(guitar, S_IRUGO, variax_get_guitar, line6_nop_write);
563 563
564#ifdef CONFIG_LINE6_USB_RAW 564#ifdef CONFIG_LINE6_USB_RAW
565static DEVICE_ATTR(raw, S_IWUGO, line6_nop_read, line6_set_raw); 565static DEVICE_ATTR(raw, S_IWUSR, line6_nop_read, line6_set_raw);
566static DEVICE_ATTR(raw2, S_IWUGO, line6_nop_read, variax_set_raw2); 566static DEVICE_ATTR(raw2, S_IWUSR, line6_nop_read, variax_set_raw2);
567#endif 567#endif
568 568
569/* 569/*
diff --git a/drivers/staging/quickstart/quickstart.c b/drivers/staging/quickstart/quickstart.c
index d746715d3d89..d83bec876d2e 100644
--- a/drivers/staging/quickstart/quickstart.c
+++ b/drivers/staging/quickstart/quickstart.c
@@ -355,7 +355,6 @@ static int quickstart_acpi_remove(struct acpi_device *device, int type)
355static void quickstart_exit(void) 355static void quickstart_exit(void)
356{ 356{
357 input_unregister_device(quickstart_input); 357 input_unregister_device(quickstart_input);
358 input_free_device(quickstart_input);
359 358
360 device_remove_file(&pf_device->dev, &dev_attr_pressed_button); 359 device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
361 device_remove_file(&pf_device->dev, &dev_attr_buttons); 360 device_remove_file(&pf_device->dev, &dev_attr_buttons);
@@ -375,6 +374,7 @@ static int __init quickstart_init_input(void)
375{ 374{
376 struct quickstart_btn **ptr = &quickstart_data.btn_lst; 375 struct quickstart_btn **ptr = &quickstart_data.btn_lst;
377 int count; 376 int count;
377 int ret;
378 378
379 quickstart_input = input_allocate_device(); 379 quickstart_input = input_allocate_device();
380 380
@@ -391,7 +391,13 @@ static int __init quickstart_init_input(void)
391 ptr = &((*ptr)->next); 391 ptr = &((*ptr)->next);
392 } 392 }
393 393
394 return input_register_device(quickstart_input); 394 ret = input_register_device(quickstart_input);
395 if (ret) {
396 input_free_device(quickstart_input);
397 return ret;
398 }
399
400 return 0;
395} 401}
396 402
397static int __init quickstart_init(void) 403static int __init quickstart_init(void)
diff --git a/drivers/staging/rt2860/usb_main_dev.c b/drivers/staging/rt2860/usb_main_dev.c
index ddacfc6c4861..cd15daae5412 100644
--- a/drivers/staging/rt2860/usb_main_dev.c
+++ b/drivers/staging/rt2860/usb_main_dev.c
@@ -182,6 +182,7 @@ struct usb_device_id rtusb_usb_id[] = {
182 {USB_DEVICE(0x2001, 0x3C09)}, /* D-Link */ 182 {USB_DEVICE(0x2001, 0x3C09)}, /* D-Link */
183 {USB_DEVICE(0x2001, 0x3C0A)}, /* D-Link 3072 */ 183 {USB_DEVICE(0x2001, 0x3C0A)}, /* D-Link 3072 */
184 {USB_DEVICE(0x2019, 0xED14)}, /* Planex Communications, Inc. */ 184 {USB_DEVICE(0x2019, 0xED14)}, /* Planex Communications, Inc. */
185 {USB_DEVICE(0x0411, 0x015D)}, /* Buffalo Airstation WLI-UC-GN */
185 {} /* Terminating entry */ 186 {} /* Terminating entry */
186}; 187};
187 188
diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 46000d72f4c4..3bdf9b31cc4e 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -264,8 +264,12 @@ HwHSSIThreeWire(
264 264
265 udelay(10); 265 udelay(10);
266 } 266 }
267 if (TryCnt == TC_3W_POLL_MAX_TRY_CNT) 267 if (TryCnt == TC_3W_POLL_MAX_TRY_CNT) {
268 panic("HwThreeWire(): CmdReg: %#X RE|WE bits are not clear!!\n", u1bTmp); 268 printk(KERN_ERR "rtl8187se: HwThreeWire(): CmdReg:"
269 " %#X RE|WE bits are not clear!!\n", u1bTmp);
270 dump_stack();
271 return 0;
272 }
269 273
270 /* RTL8187S HSSI Read/Write Function */ 274 /* RTL8187S HSSI Read/Write Function */
271 u1bTmp = read_nic_byte(dev, RF_SW_CONFIG); 275 u1bTmp = read_nic_byte(dev, RF_SW_CONFIG);
@@ -298,13 +302,23 @@ HwHSSIThreeWire(
298 int idx; 302 int idx;
299 int ByteCnt = nDataBufBitCnt / 8; 303 int ByteCnt = nDataBufBitCnt / 8;
300 /* printk("%d\n",nDataBufBitCnt); */ 304 /* printk("%d\n",nDataBufBitCnt); */
301 if ((nDataBufBitCnt % 8) != 0) 305 if ((nDataBufBitCnt % 8) != 0) {
302 panic("HwThreeWire(): nDataBufBitCnt(%d) should be multiple of 8!!!\n", 306 printk(KERN_ERR "rtl8187se: "
303 nDataBufBitCnt); 307 "HwThreeWire(): nDataBufBitCnt(%d)"
308 " should be multiple of 8!!!\n",
309 nDataBufBitCnt);
310 dump_stack();
311 nDataBufBitCnt += 8;
312 nDataBufBitCnt &= ~7;
313 }
304 314
305 if (nDataBufBitCnt > 64) 315 if (nDataBufBitCnt > 64) {
306 panic("HwThreeWire(): nDataBufBitCnt(%d) should <= 64!!!\n", 316 printk(KERN_ERR "rtl8187se: HwThreeWire():"
307 nDataBufBitCnt); 317 " nDataBufBitCnt(%d) should <= 64!!!\n",
318 nDataBufBitCnt);
319 dump_stack();
320 nDataBufBitCnt = 64;
321 }
308 322
309 for (idx = 0; idx < ByteCnt; idx++) 323 for (idx = 0; idx < ByteCnt; idx++)
310 write_nic_byte(dev, (SW_3W_DB0+idx), *(pDataBuf+idx)); 324 write_nic_byte(dev, (SW_3W_DB0+idx), *(pDataBuf+idx));
diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h
index d1674cd282dc..831d81e0e429 100644
--- a/drivers/staging/rtl8712/osdep_service.h
+++ b/drivers/staging/rtl8712/osdep_service.h
@@ -22,7 +22,6 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/kref.h> 24#include <linux/kref.h>
25#include <linux/smp_lock.h>
26#include <linux/netdevice.h> 25#include <linux/netdevice.h>
27#include <linux/skbuff.h> 26#include <linux/skbuff.h>
28#include <linux/usb.h> 27#include <linux/usb.h>
diff --git a/drivers/staging/rtl8712/usb_halinit.c b/drivers/staging/rtl8712/usb_halinit.c
index f6569dce3012..0e9483bbabe1 100644
--- a/drivers/staging/rtl8712/usb_halinit.c
+++ b/drivers/staging/rtl8712/usb_halinit.c
@@ -37,7 +37,7 @@ u8 r8712_usb_hal_bus_init(struct _adapter *padapter)
37{ 37{
38 u8 val8 = 0; 38 u8 val8 = 0;
39 u8 ret = _SUCCESS; 39 u8 ret = _SUCCESS;
40 u8 PollingCnt = 20; 40 int PollingCnt = 20;
41 struct registry_priv *pregistrypriv = &padapter->registrypriv; 41 struct registry_priv *pregistrypriv = &padapter->registrypriv;
42 42
43 if (pregistrypriv->chip_version == RTL8712_FPGA) { 43 if (pregistrypriv->chip_version == RTL8712_FPGA) {
diff --git a/drivers/staging/samsung-laptop/samsung-laptop.c b/drivers/staging/samsung-laptop/samsung-laptop.c
index eb44b60e1eb5..ac2bf11e1119 100644
--- a/drivers/staging/samsung-laptop/samsung-laptop.c
+++ b/drivers/staging/samsung-laptop/samsung-laptop.c
@@ -356,7 +356,7 @@ static ssize_t set_silent_state(struct device *dev,
356 } 356 }
357 return count; 357 return count;
358} 358}
359static DEVICE_ATTR(silent, S_IWUGO | S_IRUGO, 359static DEVICE_ATTR(silent, S_IWUSR | S_IRUGO,
360 get_silent_state, set_silent_state); 360 get_silent_state, set_silent_state);
361 361
362 362
diff --git a/drivers/staging/speakup/buffers.c b/drivers/staging/speakup/buffers.c
index b7b60d5e8660..a2db956edd54 100644
--- a/drivers/staging/speakup/buffers.c
+++ b/drivers/staging/speakup/buffers.c
@@ -1,5 +1,4 @@
1#include <linux/console.h> 1#include <linux/console.h>
2#include <linux/smp_lock.h>
3#include <linux/types.h> 2#include <linux/types.h>
4#include <linux/wait.h> 3#include <linux/wait.h>
5 4
diff --git a/drivers/staging/speakup/fakekey.c b/drivers/staging/speakup/fakekey.c
index adb93f21c0d6..65b231178f05 100644
--- a/drivers/staging/speakup/fakekey.c
+++ b/drivers/staging/speakup/fakekey.c
@@ -62,7 +62,6 @@ void speakup_remove_virtual_keyboard(void)
62{ 62{
63 if (virt_keyboard != NULL) { 63 if (virt_keyboard != NULL) {
64 input_unregister_device(virt_keyboard); 64 input_unregister_device(virt_keyboard);
65 input_free_device(virt_keyboard);
66 virt_keyboard = NULL; 65 virt_keyboard = NULL;
67 } 66 }
68} 67}
diff --git a/drivers/staging/spectra/ffsport.c b/drivers/staging/spectra/ffsport.c
index c7932da03c56..63a9d0adf32d 100644
--- a/drivers/staging/spectra/ffsport.c
+++ b/drivers/staging/spectra/ffsport.c
@@ -656,7 +656,7 @@ static int SBD_setup_device(struct spectra_nand_dev *dev, int which)
656 /* Here we force report 512 byte hardware sector size to Kernel */ 656 /* Here we force report 512 byte hardware sector size to Kernel */
657 blk_queue_logical_block_size(dev->queue, 512); 657 blk_queue_logical_block_size(dev->queue, 512);
658 658
659 blk_queue_ordered(dev->queue, QUEUE_ORDERED_DRAIN_FLUSH); 659 blk_queue_flush(dev->queue, REQ_FLUSH);
660 660
661 dev->thread = kthread_run(spectra_trans_thread, dev, "nand_thd"); 661 dev->thread = kthread_run(spectra_trans_thread, dev, "nand_thd");
662 if (IS_ERR(dev->thread)) { 662 if (IS_ERR(dev->thread)) {
diff --git a/drivers/staging/stradis/Kconfig b/drivers/staging/stradis/Kconfig
index 92e891141896..02f0fc504cf5 100644
--- a/drivers/staging/stradis/Kconfig
+++ b/drivers/staging/stradis/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_STRADIS 1config VIDEO_STRADIS
2 tristate "Stradis 4:2:2 MPEG-2 video driver (DEPRECATED)" 2 tristate "Stradis 4:2:2 MPEG-2 video driver (DEPRECATED)"
3 depends on EXPERIMENTAL && PCI && VIDEO_V4L1 && VIRT_TO_BUS 3 depends on EXPERIMENTAL && PCI && VIDEO_V4L1 && VIRT_TO_BUS && BKL
4 help 4 help
5 Say Y here to enable support for the Stradis 4:2:2 MPEG-2 video 5 Say Y here to enable support for the Stradis 4:2:2 MPEG-2 video
6 driver for PCI. There is a product page at 6 driver for PCI. There is a product page at
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 664e6038090d..b143258f094a 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -545,7 +545,7 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
545 545
546 /* Load tuner module */ 546 /* Load tuner module */
547 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 547 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
548 NULL, "tuner", dev->tuner_addr, NULL); 548 "tuner", dev->tuner_addr, NULL);
549 549
550 memset(&tun_setup, 0, sizeof(tun_setup)); 550 memset(&tun_setup, 0, sizeof(tun_setup));
551 tun_setup.type = dev->tuner_type; 551 tun_setup.type = dev->tuner_type;
@@ -683,7 +683,7 @@ static int tm6000_init_dev(struct tm6000_core *dev)
683 683
684 if (dev->caps.has_tda9874) 684 if (dev->caps.has_tda9874)
685 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, 685 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
686 NULL, "tvaudio", I2C_ADDR_TDA9874, NULL); 686 "tvaudio", I2C_ADDR_TDA9874, NULL);
687 687
688 /* register and initialize V4L2 */ 688 /* register and initialize V4L2 */
689 rc = tm6000_v4l2_register(dev); 689 rc = tm6000_v4l2_register(dev);
diff --git a/drivers/staging/winbond/sysdef.h b/drivers/staging/winbond/sysdef.h
index 9195adf98e14..d0d71f69bc8c 100644
--- a/drivers/staging/winbond/sysdef.h
+++ b/drivers/staging/winbond/sysdef.h
@@ -2,6 +2,9 @@
2 2
3#ifndef SYS_DEF_H 3#ifndef SYS_DEF_H
4#define SYS_DEF_H 4#define SYS_DEF_H
5
6#include <linux/delay.h>
7
5#define WB_LINUX 8#define WB_LINUX
6#define WB_LINUX_WPA_PSK 9#define WB_LINUX_WPA_PSK
7 10
diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
index 6c574a994d11..6b3cf00b0ff4 100644
--- a/drivers/staging/zram/zram_sysfs.c
+++ b/drivers/staging/zram/zram_sysfs.c
@@ -189,10 +189,10 @@ static ssize_t mem_used_total_show(struct device *dev,
189 return sprintf(buf, "%llu\n", val); 189 return sprintf(buf, "%llu\n", val);
190} 190}
191 191
192static DEVICE_ATTR(disksize, S_IRUGO | S_IWUGO, 192static DEVICE_ATTR(disksize, S_IRUGO | S_IWUSR,
193 disksize_show, disksize_store); 193 disksize_show, disksize_store);
194static DEVICE_ATTR(initstate, S_IRUGO, initstate_show, NULL); 194static DEVICE_ATTR(initstate, S_IRUGO, initstate_show, NULL);
195static DEVICE_ATTR(reset, S_IWUGO, NULL, reset_store); 195static DEVICE_ATTR(reset, S_IWUSR, NULL, reset_store);
196static DEVICE_ATTR(num_reads, S_IRUGO, num_reads_show, NULL); 196static DEVICE_ATTR(num_reads, S_IRUGO, num_reads_show, NULL);
197static DEVICE_ATTR(num_writes, S_IRUGO, num_writes_show, NULL); 197static DEVICE_ATTR(num_writes, S_IRUGO, num_writes_show, NULL);
198static DEVICE_ATTR(invalid_io, S_IRUGO, invalid_io_show, NULL); 198static DEVICE_ATTR(invalid_io, S_IRUGO, invalid_io_show, NULL);
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 81b46585edf7..c5f8e5bda2b2 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -716,8 +716,8 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
716 if (msg->len < 128) 716 if (msg->len < 128)
717 *--dp = (msg->len << 1) | EA; 717 *--dp = (msg->len << 1) | EA;
718 else { 718 else {
719 *--dp = ((msg->len & 127) << 1) | EA; 719 *--dp = (msg->len >> 7); /* bits 7 - 15 */
720 *--dp = (msg->len >> 6) & 0xfe; 720 *--dp = (msg->len & 127) << 1; /* bits 0 - 6 */
721 } 721 }
722 } 722 }
723 723
@@ -968,6 +968,8 @@ static void gsm_control_reply(struct gsm_mux *gsm, int cmd, u8 *data,
968{ 968{
969 struct gsm_msg *msg; 969 struct gsm_msg *msg;
970 msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->ftype); 970 msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->ftype);
971 if (msg == NULL)
972 return;
971 msg->data[0] = (cmd & 0xFE) << 1 | EA; /* Clear C/R */ 973 msg->data[0] = (cmd & 0xFE) << 1 | EA; /* Clear C/R */
972 msg->data[1] = (dlen << 1) | EA; 974 msg->data[1] = (dlen << 1) | EA;
973 memcpy(msg->data + 2, data, dlen); 975 memcpy(msg->data + 2, data, dlen);
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index eaa5d3efa79d..c556ed9db13d 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -554,7 +554,7 @@ EXPORT_SYMBOL(handle_sysrq);
554#ifdef CONFIG_INPUT 554#ifdef CONFIG_INPUT
555 555
556/* Simple translation table for the SysRq keys */ 556/* Simple translation table for the SysRq keys */
557static const unsigned char sysrq_xlate[KEY_MAX + 1] = 557static const unsigned char sysrq_xlate[KEY_CNT] =
558 "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */ 558 "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
559 "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */ 559 "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
560 "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */ 560 "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
@@ -563,53 +563,129 @@ static const unsigned char sysrq_xlate[KEY_MAX + 1] =
563 "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */ 563 "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
564 "\r\000/"; /* 0x60 - 0x6f */ 564 "\r\000/"; /* 0x60 - 0x6f */
565 565
566static bool sysrq_down; 566struct sysrq_state {
567static int sysrq_alt_use; 567 struct input_handle handle;
568static int sysrq_alt; 568 struct work_struct reinject_work;
569static DEFINE_SPINLOCK(sysrq_event_lock); 569 unsigned long key_down[BITS_TO_LONGS(KEY_CNT)];
570 unsigned int alt;
571 unsigned int alt_use;
572 bool active;
573 bool need_reinject;
574};
575
576static void sysrq_reinject_alt_sysrq(struct work_struct *work)
577{
578 struct sysrq_state *sysrq =
579 container_of(work, struct sysrq_state, reinject_work);
580 struct input_handle *handle = &sysrq->handle;
581 unsigned int alt_code = sysrq->alt_use;
582
583 if (sysrq->need_reinject) {
584 /* Simulate press and release of Alt + SysRq */
585 input_inject_event(handle, EV_KEY, alt_code, 1);
586 input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
587 input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
588
589 input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
590 input_inject_event(handle, EV_KEY, alt_code, 0);
591 input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
592 }
593}
570 594
571static bool sysrq_filter(struct input_handle *handle, unsigned int type, 595static bool sysrq_filter(struct input_handle *handle,
572 unsigned int code, int value) 596 unsigned int type, unsigned int code, int value)
573{ 597{
598 struct sysrq_state *sysrq = handle->private;
599 bool was_active = sysrq->active;
574 bool suppress; 600 bool suppress;
575 601
576 /* We are called with interrupts disabled, just take the lock */ 602 switch (type) {
577 spin_lock(&sysrq_event_lock);
578 603
579 if (type != EV_KEY) 604 case EV_SYN:
580 goto out; 605 suppress = false;
606 break;
581 607
582 switch (code) { 608 case EV_KEY:
609 switch (code) {
583 610
584 case KEY_LEFTALT: 611 case KEY_LEFTALT:
585 case KEY_RIGHTALT: 612 case KEY_RIGHTALT:
586 if (value) 613 if (!value) {
587 sysrq_alt = code; 614 /* One of ALTs is being released */
588 else { 615 if (sysrq->active && code == sysrq->alt_use)
589 if (sysrq_down && code == sysrq_alt_use) 616 sysrq->active = false;
590 sysrq_down = false;
591 617
592 sysrq_alt = 0; 618 sysrq->alt = KEY_RESERVED;
619
620 } else if (value != 2) {
621 sysrq->alt = code;
622 sysrq->need_reinject = false;
623 }
624 break;
625
626 case KEY_SYSRQ:
627 if (value == 1 && sysrq->alt != KEY_RESERVED) {
628 sysrq->active = true;
629 sysrq->alt_use = sysrq->alt;
630 /*
631 * If nothing else will be pressed we'll need
632 * to * re-inject Alt-SysRq keysroke.
633 */
634 sysrq->need_reinject = true;
635 }
636
637 /*
638 * Pretend that sysrq was never pressed at all. This
639 * is needed to properly handle KGDB which will try
640 * to release all keys after exiting debugger. If we
641 * do not clear key bit it KGDB will end up sending
642 * release events for Alt and SysRq, potentially
643 * triggering print screen function.
644 */
645 if (sysrq->active)
646 clear_bit(KEY_SYSRQ, handle->dev->key);
647
648 break;
649
650 default:
651 if (sysrq->active && value && value != 2) {
652 sysrq->need_reinject = false;
653 __handle_sysrq(sysrq_xlate[code], true);
654 }
655 break;
593 } 656 }
594 break;
595 657
596 case KEY_SYSRQ: 658 suppress = sysrq->active;
597 if (value == 1 && sysrq_alt) { 659
598 sysrq_down = true; 660 if (!sysrq->active) {
599 sysrq_alt_use = sysrq_alt; 661 /*
662 * If we are not suppressing key presses keep track of
663 * keyboard state so we can release keys that have been
664 * pressed before entering SysRq mode.
665 */
666 if (value)
667 set_bit(code, sysrq->key_down);
668 else
669 clear_bit(code, sysrq->key_down);
670
671 if (was_active)
672 schedule_work(&sysrq->reinject_work);
673
674 } else if (value == 0 &&
675 test_and_clear_bit(code, sysrq->key_down)) {
676 /*
677 * Pass on release events for keys that was pressed before
678 * entering SysRq mode.
679 */
680 suppress = false;
600 } 681 }
601 break; 682 break;
602 683
603 default: 684 default:
604 if (sysrq_down && value && value != 2) 685 suppress = sysrq->active;
605 __handle_sysrq(sysrq_xlate[code], true);
606 break; 686 break;
607 } 687 }
608 688
609out:
610 suppress = sysrq_down;
611 spin_unlock(&sysrq_event_lock);
612
613 return suppress; 689 return suppress;
614} 690}
615 691
@@ -617,28 +693,28 @@ static int sysrq_connect(struct input_handler *handler,
617 struct input_dev *dev, 693 struct input_dev *dev,
618 const struct input_device_id *id) 694 const struct input_device_id *id)
619{ 695{
620 struct input_handle *handle; 696 struct sysrq_state *sysrq;
621 int error; 697 int error;
622 698
623 sysrq_down = false; 699 sysrq = kzalloc(sizeof(struct sysrq_state), GFP_KERNEL);
624 sysrq_alt = 0; 700 if (!sysrq)
625
626 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
627 if (!handle)
628 return -ENOMEM; 701 return -ENOMEM;
629 702
630 handle->dev = dev; 703 INIT_WORK(&sysrq->reinject_work, sysrq_reinject_alt_sysrq);
631 handle->handler = handler; 704
632 handle->name = "sysrq"; 705 sysrq->handle.dev = dev;
706 sysrq->handle.handler = handler;
707 sysrq->handle.name = "sysrq";
708 sysrq->handle.private = sysrq;
633 709
634 error = input_register_handle(handle); 710 error = input_register_handle(&sysrq->handle);
635 if (error) { 711 if (error) {
636 pr_err("Failed to register input sysrq handler, error %d\n", 712 pr_err("Failed to register input sysrq handler, error %d\n",
637 error); 713 error);
638 goto err_free; 714 goto err_free;
639 } 715 }
640 716
641 error = input_open_device(handle); 717 error = input_open_device(&sysrq->handle);
642 if (error) { 718 if (error) {
643 pr_err("Failed to open input device, error %d\n", error); 719 pr_err("Failed to open input device, error %d\n", error);
644 goto err_unregister; 720 goto err_unregister;
@@ -647,17 +723,20 @@ static int sysrq_connect(struct input_handler *handler,
647 return 0; 723 return 0;
648 724
649 err_unregister: 725 err_unregister:
650 input_unregister_handle(handle); 726 input_unregister_handle(&sysrq->handle);
651 err_free: 727 err_free:
652 kfree(handle); 728 kfree(sysrq);
653 return error; 729 return error;
654} 730}
655 731
656static void sysrq_disconnect(struct input_handle *handle) 732static void sysrq_disconnect(struct input_handle *handle)
657{ 733{
734 struct sysrq_state *sysrq = handle->private;
735
658 input_close_device(handle); 736 input_close_device(handle);
737 cancel_work_sync(&sysrq->reinject_work);
659 input_unregister_handle(handle); 738 input_unregister_handle(handle);
660 kfree(handle); 739 kfree(sysrq);
661} 740}
662 741
663/* 742/*
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index c05c5af5aa04..35480dd57a30 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -559,6 +559,9 @@ void __tty_hangup(struct tty_struct *tty)
559 559
560 tty_lock(); 560 tty_lock();
561 561
562 /* some functions below drop BTM, so we need this bit */
563 set_bit(TTY_HUPPING, &tty->flags);
564
562 /* inuse_filps is protected by the single tty lock, 565 /* inuse_filps is protected by the single tty lock,
563 this really needs to change if we want to flush the 566 this really needs to change if we want to flush the
564 workqueue with the lock held */ 567 workqueue with the lock held */
@@ -578,6 +581,10 @@ void __tty_hangup(struct tty_struct *tty)
578 } 581 }
579 spin_unlock(&tty_files_lock); 582 spin_unlock(&tty_files_lock);
580 583
584 /*
585 * it drops BTM and thus races with reopen
586 * we protect the race by TTY_HUPPING
587 */
581 tty_ldisc_hangup(tty); 588 tty_ldisc_hangup(tty);
582 589
583 read_lock(&tasklist_lock); 590 read_lock(&tasklist_lock);
@@ -615,7 +622,6 @@ void __tty_hangup(struct tty_struct *tty)
615 tty->session = NULL; 622 tty->session = NULL;
616 tty->pgrp = NULL; 623 tty->pgrp = NULL;
617 tty->ctrl_status = 0; 624 tty->ctrl_status = 0;
618 set_bit(TTY_HUPPED, &tty->flags);
619 spin_unlock_irqrestore(&tty->ctrl_lock, flags); 625 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
620 626
621 /* Account for the p->signal references we killed */ 627 /* Account for the p->signal references we killed */
@@ -641,6 +647,7 @@ void __tty_hangup(struct tty_struct *tty)
641 * can't yet guarantee all that. 647 * can't yet guarantee all that.
642 */ 648 */
643 set_bit(TTY_HUPPED, &tty->flags); 649 set_bit(TTY_HUPPED, &tty->flags);
650 clear_bit(TTY_HUPPING, &tty->flags);
644 tty_ldisc_enable(tty); 651 tty_ldisc_enable(tty);
645 652
646 tty_unlock(); 653 tty_unlock();
@@ -1310,7 +1317,9 @@ static int tty_reopen(struct tty_struct *tty)
1310{ 1317{
1311 struct tty_driver *driver = tty->driver; 1318 struct tty_driver *driver = tty->driver;
1312 1319
1313 if (test_bit(TTY_CLOSING, &tty->flags)) 1320 if (test_bit(TTY_CLOSING, &tty->flags) ||
1321 test_bit(TTY_HUPPING, &tty->flags) ||
1322 test_bit(TTY_LDISC_CHANGING, &tty->flags))
1314 return -EIO; 1323 return -EIO;
1315 1324
1316 if (driver->type == TTY_DRIVER_TYPE_PTY && 1325 if (driver->type == TTY_DRIVER_TYPE_PTY &&
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index d8e96b005023..4214d58276f7 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -454,6 +454,8 @@ static int tty_ldisc_open(struct tty_struct *tty, struct tty_ldisc *ld)
454 /* BTM here locks versus a hangup event */ 454 /* BTM here locks versus a hangup event */
455 WARN_ON(!tty_locked()); 455 WARN_ON(!tty_locked());
456 ret = ld->ops->open(tty); 456 ret = ld->ops->open(tty);
457 if (ret)
458 clear_bit(TTY_LDISC_OPEN, &tty->flags);
457 return ret; 459 return ret;
458 } 460 }
459 return 0; 461 return 0;
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index a858d2b87b94..51fe1795d5a8 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright(C) 2005, Benedikt Spranger <b.spranger@linutronix.de> 4 * Copyright(C) 2005, Benedikt Spranger <b.spranger@linutronix.de>
5 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de> 5 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
6 * Copyright(C) 2006, Hans J. Koch <hjk@linutronix.de> 6 * Copyright(C) 2006, Hans J. Koch <hjk@hansjkoch.de>
7 * Copyright(C) 2006, Greg Kroah-Hartman <greg@kroah.com> 7 * Copyright(C) 2006, Greg Kroah-Hartman <greg@kroah.com>
8 * 8 *
9 * Userspace IO 9 * Userspace IO
diff --git a/drivers/uio/uio_cif.c b/drivers/uio/uio_cif.c
index a8ea2f19a0cc..a84a451159ed 100644
--- a/drivers/uio/uio_cif.c
+++ b/drivers/uio/uio_cif.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * UIO Hilscher CIF card driver 2 * UIO Hilscher CIF card driver
3 * 3 *
4 * (C) 2007 Hans J. Koch <hjk@linutronix.de> 4 * (C) 2007 Hans J. Koch <hjk@hansjkoch.de>
5 * Original code (C) 2005 Benedikt Spranger <b.spranger@linutronix.de> 5 * Original code (C) 2005 Benedikt Spranger <b.spranger@linutronix.de>
6 * 6 *
7 * Licensed under GPL version 2 only. 7 * Licensed under GPL version 2 only.
diff --git a/drivers/uio/uio_netx.c b/drivers/uio/uio_netx.c
index 5a18e9f7b836..5ffdb483b015 100644
--- a/drivers/uio/uio_netx.c
+++ b/drivers/uio/uio_netx.c
@@ -2,7 +2,7 @@
2 * UIO driver for Hilscher NetX based fieldbus cards (cifX, comX). 2 * UIO driver for Hilscher NetX based fieldbus cards (cifX, comX).
3 * See http://www.hilscher.com for details. 3 * See http://www.hilscher.com for details.
4 * 4 *
5 * (C) 2007 Hans J. Koch <hjk@linutronix.de> 5 * (C) 2007 Hans J. Koch <hjk@hansjkoch.de>
6 * (C) 2008 Manuel Traut <manut@linutronix.de> 6 * (C) 2008 Manuel Traut <manut@linutronix.de>
7 * 7 *
8 * Licensed under GPL version 2 only. 8 * Licensed under GPL version 2 only.
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index ea071a5b6eee..44447f54942f 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -2301,7 +2301,7 @@ out:
2301 return ret; 2301 return ret;
2302} 2302}
2303 2303
2304static DEVICE_ATTR(stat_status, S_IWUGO | S_IRUGO, read_status, reboot); 2304static DEVICE_ATTR(stat_status, S_IWUSR | S_IRUGO, read_status, reboot);
2305 2305
2306static ssize_t read_human_status(struct device *dev, 2306static ssize_t read_human_status(struct device *dev,
2307 struct device_attribute *attr, char *buf) 2307 struct device_attribute *attr, char *buf)
@@ -2364,8 +2364,7 @@ out:
2364 return ret; 2364 return ret;
2365} 2365}
2366 2366
2367static DEVICE_ATTR(stat_human_status, S_IWUGO | S_IRUGO, 2367static DEVICE_ATTR(stat_human_status, S_IRUGO, read_human_status, NULL);
2368 read_human_status, NULL);
2369 2368
2370static ssize_t read_delin(struct device *dev, struct device_attribute *attr, 2369static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
2371 char *buf) 2370 char *buf)
@@ -2397,7 +2396,7 @@ out:
2397 return ret; 2396 return ret;
2398} 2397}
2399 2398
2400static DEVICE_ATTR(stat_delin, S_IWUGO | S_IRUGO, read_delin, NULL); 2399static DEVICE_ATTR(stat_delin, S_IRUGO, read_delin, NULL);
2401 2400
2402#define UEA_ATTR(name, reset) \ 2401#define UEA_ATTR(name, reset) \
2403 \ 2402 \
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 05bf5a27b5b0..989e16e4ab5c 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -951,7 +951,9 @@ static int usbatm_atm_init(struct usbatm_data *instance)
951 * condition: callbacks we register can be executed at once, before we have 951 * condition: callbacks we register can be executed at once, before we have
952 * initialized the struct atm_dev. To protect against this, all callbacks 952 * initialized the struct atm_dev. To protect against this, all callbacks
953 * abort if atm_dev->dev_data is NULL. */ 953 * abort if atm_dev->dev_data is NULL. */
954 atm_dev = atm_dev_register(instance->driver_name, &usbatm_atm_devops, -1, NULL); 954 atm_dev = atm_dev_register(instance->driver_name,
955 &instance->usb_intf->dev, &usbatm_atm_devops,
956 -1, NULL);
955 if (!atm_dev) { 957 if (!atm_dev) {
956 usb_err(instance, "%s: failed to register ATM device!\n", __func__); 958 usb_err(instance, "%s: failed to register ATM device!\n", __func__);
957 return -1; 959 return -1;
@@ -966,14 +968,6 @@ static int usbatm_atm_init(struct usbatm_data *instance)
966 /* temp init ATM device, set to 128kbit */ 968 /* temp init ATM device, set to 128kbit */
967 atm_dev->link_rate = 128 * 1000 / 424; 969 atm_dev->link_rate = 128 * 1000 / 424;
968 970
969 ret = sysfs_create_link(&atm_dev->class_dev.kobj,
970 &instance->usb_intf->dev.kobj, "device");
971 if (ret) {
972 atm_err(instance, "%s: sysfs_create_link failed: %d\n",
973 __func__, ret);
974 goto fail_sysfs;
975 }
976
977 if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) { 971 if (instance->driver->atm_start && ((ret = instance->driver->atm_start(instance, atm_dev)) < 0)) {
978 atm_err(instance, "%s: atm_start failed: %d!\n", __func__, ret); 972 atm_err(instance, "%s: atm_start failed: %d!\n", __func__, ret);
979 goto fail; 973 goto fail;
@@ -992,8 +986,6 @@ static int usbatm_atm_init(struct usbatm_data *instance)
992 return 0; 986 return 0;
993 987
994 fail: 988 fail:
995 sysfs_remove_link(&atm_dev->class_dev.kobj, "device");
996 fail_sysfs:
997 instance->atm_dev = NULL; 989 instance->atm_dev = NULL;
998 atm_dev_deregister(atm_dev); /* usbatm_atm_dev_close will eventually be called */ 990 atm_dev_deregister(atm_dev); /* usbatm_atm_dev_close will eventually be called */
999 return ret; 991 return ret;
@@ -1329,7 +1321,6 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
1329 1321
1330 /* ATM finalize */ 1322 /* ATM finalize */
1331 if (instance->atm_dev) { 1323 if (instance->atm_dev) {
1332 sysfs_remove_link(&instance->atm_dev->class_dev.kobj, "device");
1333 atm_dev_deregister(instance->atm_dev); 1324 atm_dev_deregister(instance->atm_dev);
1334 instance->atm_dev = NULL; 1325 instance->atm_dev = NULL;
1335 } 1326 }
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 9eed5b52d9de..bcc24779ba0e 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -107,11 +107,19 @@ config USB_SUSPEND
107 If you are unsure about this, say N here. 107 If you are unsure about this, say N here.
108 108
109config USB_OTG 109config USB_OTG
110 bool 110 bool "OTG support"
111 depends on USB && EXPERIMENTAL 111 depends on USB && EXPERIMENTAL
112 depends on USB_SUSPEND 112 depends on USB_SUSPEND
113 default n 113 default n
114 114 help
115 The most notable feature of USB OTG is support for a
116 "Dual-Role" device, which can act as either a device
117 or a host. The initial role is decided by the type of
118 plug inserted and can be changed later when two dual
119 role devices talk to each other.
120
121 Select this only if your board has Mini-AB/Micro-AB
122 connector.
115 123
116config USB_OTG_WHITELIST 124config USB_OTG_WHITELIST
117 bool "Rely on OTG Targeted Peripherals List" 125 bool "Rely on OTG Targeted Peripherals List"
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index ddb4dc980923..a3d2e2399655 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -54,7 +54,6 @@
54#include <linux/gfp.h> 54#include <linux/gfp.h>
55#include <linux/poll.h> 55#include <linux/poll.h>
56#include <linux/usb.h> 56#include <linux/usb.h>
57#include <linux/smp_lock.h>
58#include <linux/usbdevice_fs.h> 57#include <linux/usbdevice_fs.h>
59#include <linux/usb/hcd.h> 58#include <linux/usb/hcd.h>
60#include <linux/mutex.h> 59#include <linux/mutex.h>
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 045bb4b823e1..a7131ad630f9 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -37,7 +37,6 @@
37#include <linux/fs.h> 37#include <linux/fs.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/smp_lock.h>
41#include <linux/signal.h> 40#include <linux/signal.h>
42#include <linux/poll.h> 41#include <linux/poll.h>
43#include <linux/module.h> 42#include <linux/module.h>
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 9fe34fb78ef1..cf6a5423de09 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -19,7 +19,6 @@
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/rwsem.h> 20#include <linux/rwsem.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/smp_lock.h>
23#include <linux/usb.h> 22#include <linux/usb.h>
24 23
25#include "usb.h" 24#include "usb.h"
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 61800f77dac8..ced846ac4141 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1330,6 +1330,8 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
1330 */ 1330 */
1331 1331
1332 if (usb_endpoint_xfer_control(&urb->ep->desc)) { 1332 if (usb_endpoint_xfer_control(&urb->ep->desc)) {
1333 if (hcd->self.uses_pio_for_control)
1334 return ret;
1333 if (hcd->self.uses_dma) { 1335 if (hcd->self.uses_dma) {
1334 urb->setup_dma = dma_map_single( 1336 urb->setup_dma = dma_map_single(
1335 hcd->self.controller, 1337 hcd->self.controller,
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 9819a4cc3b26..b690aa35df9a 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -39,7 +39,6 @@
39#include <linux/parser.h> 39#include <linux/parser.h>
40#include <linux/notifier.h> 40#include <linux/notifier.h>
41#include <linux/seq_file.h> 41#include <linux/seq_file.h>
42#include <linux/smp_lock.h>
43#include <linux/usb/hcd.h> 42#include <linux/usb/hcd.h>
44#include <asm/byteorder.h> 43#include <asm/byteorder.h>
45#include "usb.h" 44#include "usb.h"
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index b5e20e873cba..717ff653fa23 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -2017,7 +2017,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
2017 } 2017 }
2018 } else { 2018 } else {
2019 /* gpio_request fail so use -EINVAL for gpio_is_valid */ 2019 /* gpio_request fail so use -EINVAL for gpio_is_valid */
2020 ubc->vbus_pin = -EINVAL; 2020 udc->vbus_pin = -EINVAL;
2021 } 2021 }
2022 } 2022 }
2023 2023
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 7b5cc16e4a0b..8572dad5ecbb 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1047,9 +1047,9 @@ composite_unbind(struct usb_gadget *gadget)
1047 kfree(cdev->req->buf); 1047 kfree(cdev->req->buf);
1048 usb_ep_free_request(gadget->ep0, cdev->req); 1048 usb_ep_free_request(gadget->ep0, cdev->req);
1049 } 1049 }
1050 device_remove_file(&gadget->dev, &dev_attr_suspended);
1050 kfree(cdev); 1051 kfree(cdev);
1051 set_gadget_data(gadget, NULL); 1052 set_gadget_data(gadget, NULL);
1052 device_remove_file(&gadget->dev, &dev_attr_suspended);
1053 composite = NULL; 1053 composite = NULL;
1054} 1054}
1055 1055
@@ -1107,14 +1107,6 @@ static int composite_bind(struct usb_gadget *gadget)
1107 */ 1107 */
1108 usb_ep_autoconfig_reset(cdev->gadget); 1108 usb_ep_autoconfig_reset(cdev->gadget);
1109 1109
1110 /* standardized runtime overrides for device ID data */
1111 if (idVendor)
1112 cdev->desc.idVendor = cpu_to_le16(idVendor);
1113 if (idProduct)
1114 cdev->desc.idProduct = cpu_to_le16(idProduct);
1115 if (bcdDevice)
1116 cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);
1117
1118 /* composite gadget needs to assign strings for whole device (like 1110 /* composite gadget needs to assign strings for whole device (like
1119 * serial number), register function drivers, potentially update 1111 * serial number), register function drivers, potentially update
1120 * power state and consumption, etc 1112 * power state and consumption, etc
@@ -1126,6 +1118,14 @@ static int composite_bind(struct usb_gadget *gadget)
1126 cdev->desc = *composite->dev; 1118 cdev->desc = *composite->dev;
1127 cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket; 1119 cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1128 1120
1121 /* standardized runtime overrides for device ID data */
1122 if (idVendor)
1123 cdev->desc.idVendor = cpu_to_le16(idVendor);
1124 if (idProduct)
1125 cdev->desc.idProduct = cpu_to_le16(idProduct);
1126 if (bcdDevice)
1127 cdev->desc.bcdDevice = cpu_to_le16(bcdDevice);
1128
1129 /* stirng overrides */ 1129 /* stirng overrides */
1130 if (iManufacturer || !cdev->desc.iManufacturer) { 1130 if (iManufacturer || !cdev->desc.iManufacturer) {
1131 if (!iManufacturer && !composite->iManufacturer && 1131 if (!iManufacturer && !composite->iManufacturer &&
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 4a830df4fc31..484c5ba5450e 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -30,7 +30,6 @@
30#include <linux/blkdev.h> 30#include <linux/blkdev.h>
31#include <linux/pagemap.h> 31#include <linux/pagemap.h>
32#include <asm/unaligned.h> 32#include <asm/unaligned.h>
33#include <linux/smp_lock.h>
34 33
35#include <linux/usb/composite.h> 34#include <linux/usb/composite.h>
36#include <linux/usb/functionfs.h> 35#include <linux/usb/functionfs.h>
diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c
index 4f891eddd060..598e7e2ab80c 100644
--- a/drivers/usb/gadget/f_hid.c
+++ b/drivers/usb/gadget/f_hid.c
@@ -25,7 +25,6 @@
25#include <linux/cdev.h> 25#include <linux/cdev.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/poll.h> 27#include <linux/poll.h>
28#include <linux/smp_lock.h>
29#include <linux/uaccess.h> 28#include <linux/uaccess.h>
30#include <linux/wait.h> 29#include <linux/wait.h>
31#include <linux/usb/g_hid.h> 30#include <linux/usb/g_hid.h>
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 86afdc73322f..6e2599661b5b 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -1067,7 +1067,7 @@ static inline void create_debug_files (struct ehci_hcd *ehci)
1067 &debug_registers_fops)) 1067 &debug_registers_fops))
1068 goto file_error; 1068 goto file_error;
1069 1069
1070 if (!debugfs_create_file("lpm", S_IRUGO|S_IWUGO, ehci->debug_dir, bus, 1070 if (!debugfs_create_file("lpm", S_IRUGO|S_IWUSR, ehci->debug_dir, bus,
1071 &debug_lpm_fops)) 1071 &debug_lpm_fops))
1072 goto file_error; 1072 goto file_error;
1073 1073
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 502a7e6fef42..e9062806d4a2 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1063,10 +1063,11 @@ rescan:
1063 tmp && tmp != qh; 1063 tmp && tmp != qh;
1064 tmp = tmp->qh_next.qh) 1064 tmp = tmp->qh_next.qh)
1065 continue; 1065 continue;
1066 /* periodic qh self-unlinks on empty */ 1066 /* periodic qh self-unlinks on empty, and a COMPLETING qh
1067 if (!tmp) 1067 * may already be unlinked.
1068 goto nogood; 1068 */
1069 unlink_async (ehci, qh); 1069 if (tmp)
1070 unlink_async(ehci, qh);
1070 /* FALL THROUGH */ 1071 /* FALL THROUGH */
1071 case QH_STATE_UNLINK: /* wait for hw to finish? */ 1072 case QH_STATE_UNLINK: /* wait for hw to finish? */
1072 case QH_STATE_UNLINK_WAIT: 1073 case QH_STATE_UNLINK_WAIT:
@@ -1083,7 +1084,6 @@ idle_timeout:
1083 } 1084 }
1084 /* else FALL THROUGH */ 1085 /* else FALL THROUGH */
1085 default: 1086 default:
1086nogood:
1087 /* caller was supposed to have unlinked any requests; 1087 /* caller was supposed to have unlinked any requests;
1088 * that's not our job. just leak this memory. 1088 * that's not our job. just leak this memory.
1089 */ 1089 */
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index d36e4e75e08d..12f70c302b0b 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -141,6 +141,10 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci)
141 qh_put (ehci->async); 141 qh_put (ehci->async);
142 ehci->async = NULL; 142 ehci->async = NULL;
143 143
144 if (ehci->dummy)
145 qh_put(ehci->dummy);
146 ehci->dummy = NULL;
147
144 /* DMA consistent memory and pools */ 148 /* DMA consistent memory and pools */
145 if (ehci->qtd_pool) 149 if (ehci->qtd_pool)
146 dma_pool_destroy (ehci->qtd_pool); 150 dma_pool_destroy (ehci->qtd_pool);
@@ -227,8 +231,26 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags)
227 if (ehci->periodic == NULL) { 231 if (ehci->periodic == NULL) {
228 goto fail; 232 goto fail;
229 } 233 }
230 for (i = 0; i < ehci->periodic_size; i++) 234
231 ehci->periodic [i] = EHCI_LIST_END(ehci); 235 if (ehci->use_dummy_qh) {
236 struct ehci_qh_hw *hw;
237 ehci->dummy = ehci_qh_alloc(ehci, flags);
238 if (!ehci->dummy)
239 goto fail;
240
241 hw = ehci->dummy->hw;
242 hw->hw_next = EHCI_LIST_END(ehci);
243 hw->hw_qtd_next = EHCI_LIST_END(ehci);
244 hw->hw_alt_next = EHCI_LIST_END(ehci);
245 hw->hw_token &= ~QTD_STS_ACTIVE;
246 ehci->dummy->hw = hw;
247
248 for (i = 0; i < ehci->periodic_size; i++)
249 ehci->periodic[i] = ehci->dummy->qh_dma;
250 } else {
251 for (i = 0; i < ehci->periodic_size; i++)
252 ehci->periodic[i] = EHCI_LIST_END(ehci);
253 }
232 254
233 /* software shadow of hardware table */ 255 /* software shadow of hardware table */
234 ehci->pshadow = kcalloc(ehci->periodic_size, sizeof(void *), flags); 256 ehci->pshadow = kcalloc(ehci->periodic_size, sizeof(void *), flags);
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index a1e8d273103f..655f3c9f88bf 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -103,6 +103,19 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
103 if (retval) 103 if (retval)
104 return retval; 104 return retval;
105 105
106 if ((pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x7808) ||
107 (pdev->vendor == PCI_VENDOR_ID_ATI && pdev->device == 0x4396)) {
108 /* EHCI controller on AMD SB700/SB800/Hudson-2/3 platforms may
109 * read/write memory space which does not belong to it when
110 * there is NULL pointer with T-bit set to 1 in the frame list
111 * table. To avoid the issue, the frame list link pointer
112 * should always contain a valid pointer to a inactive qh.
113 */
114 ehci->use_dummy_qh = 1;
115 ehci_info(ehci, "applying AMD SB700/SB800/Hudson-2/3 EHCI "
116 "dummy qh workaround\n");
117 }
118
106 /* data structure init */ 119 /* data structure init */
107 retval = ehci_init(hcd); 120 retval = ehci_init(hcd);
108 if (retval) 121 if (retval)
@@ -148,6 +161,18 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
148 if (pdev->revision < 0xa4) 161 if (pdev->revision < 0xa4)
149 ehci->no_selective_suspend = 1; 162 ehci->no_selective_suspend = 1;
150 break; 163 break;
164
165 /* MCP89 chips on the MacBookAir3,1 give EPROTO when
166 * fetching device descriptors unless LPM is disabled.
167 * There are also intermittent problems enumerating
168 * devices with PPCD enabled.
169 */
170 case 0x0d9d:
171 ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89");
172 ehci->has_lpm = 0;
173 ehci->has_ppcd = 0;
174 ehci->command &= ~CMD_PPCEE;
175 break;
151 } 176 }
152 break; 177 break;
153 case PCI_VENDOR_ID_VIA: 178 case PCI_VENDOR_ID_VIA:
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index a92526d6e5ae..d9f78eb26572 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -98,7 +98,14 @@ static void periodic_unlink (struct ehci_hcd *ehci, unsigned frame, void *ptr)
98 */ 98 */
99 *prev_p = *periodic_next_shadow(ehci, &here, 99 *prev_p = *periodic_next_shadow(ehci, &here,
100 Q_NEXT_TYPE(ehci, *hw_p)); 100 Q_NEXT_TYPE(ehci, *hw_p));
101 *hw_p = *shadow_next_periodic(ehci, &here, Q_NEXT_TYPE(ehci, *hw_p)); 101
102 if (!ehci->use_dummy_qh ||
103 *shadow_next_periodic(ehci, &here, Q_NEXT_TYPE(ehci, *hw_p))
104 != EHCI_LIST_END(ehci))
105 *hw_p = *shadow_next_periodic(ehci, &here,
106 Q_NEXT_TYPE(ehci, *hw_p));
107 else
108 *hw_p = ehci->dummy->qh_dma;
102} 109}
103 110
104/* how many of the uframe's 125 usecs are allocated? */ 111/* how many of the uframe's 125 usecs are allocated? */
@@ -2335,7 +2342,11 @@ restart:
2335 * pointer for much longer, if at all. 2342 * pointer for much longer, if at all.
2336 */ 2343 */
2337 *q_p = q.itd->itd_next; 2344 *q_p = q.itd->itd_next;
2338 *hw_p = q.itd->hw_next; 2345 if (!ehci->use_dummy_qh ||
2346 q.itd->hw_next != EHCI_LIST_END(ehci))
2347 *hw_p = q.itd->hw_next;
2348 else
2349 *hw_p = ehci->dummy->qh_dma;
2339 type = Q_NEXT_TYPE(ehci, q.itd->hw_next); 2350 type = Q_NEXT_TYPE(ehci, q.itd->hw_next);
2340 wmb(); 2351 wmb();
2341 modified = itd_complete (ehci, q.itd); 2352 modified = itd_complete (ehci, q.itd);
@@ -2368,7 +2379,11 @@ restart:
2368 * URB completion. 2379 * URB completion.
2369 */ 2380 */
2370 *q_p = q.sitd->sitd_next; 2381 *q_p = q.sitd->sitd_next;
2371 *hw_p = q.sitd->hw_next; 2382 if (!ehci->use_dummy_qh ||
2383 q.sitd->hw_next != EHCI_LIST_END(ehci))
2384 *hw_p = q.sitd->hw_next;
2385 else
2386 *hw_p = ehci->dummy->qh_dma;
2372 type = Q_NEXT_TYPE(ehci, q.sitd->hw_next); 2387 type = Q_NEXT_TYPE(ehci, q.sitd->hw_next);
2373 wmb(); 2388 wmb();
2374 modified = sitd_complete (ehci, q.sitd); 2389 modified = sitd_complete (ehci, q.sitd);
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index bde823f704e9..ba8eab366b82 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -73,6 +73,7 @@ struct ehci_hcd { /* one per controller */
73 73
74 /* async schedule support */ 74 /* async schedule support */
75 struct ehci_qh *async; 75 struct ehci_qh *async;
76 struct ehci_qh *dummy; /* For AMD quirk use */
76 struct ehci_qh *reclaim; 77 struct ehci_qh *reclaim;
77 unsigned scanning : 1; 78 unsigned scanning : 1;
78 79
@@ -131,6 +132,7 @@ struct ehci_hcd { /* one per controller */
131 unsigned need_io_watchdog:1; 132 unsigned need_io_watchdog:1;
132 unsigned broken_periodic:1; 133 unsigned broken_periodic:1;
133 unsigned fs_i_thresh:1; /* Intel iso scheduling */ 134 unsigned fs_i_thresh:1; /* Intel iso scheduling */
135 unsigned use_dummy_qh:1; /* AMD Frame List table quirk*/
134 136
135 /* required for usb32 quirk */ 137 /* required for usb32 quirk */
136 #define OHCI_CTRL_HCFS (3 << 6) 138 #define OHCI_CTRL_HCFS (3 << 6)
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 8196fa11fec4..43a39eb56cc6 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -70,7 +70,6 @@
70#include <linux/ioport.h> 70#include <linux/ioport.h>
71#include <linux/sched.h> 71#include <linux/sched.h>
72#include <linux/slab.h> 72#include <linux/slab.h>
73#include <linux/smp_lock.h>
74#include <linux/errno.h> 73#include <linux/errno.h>
75#include <linux/init.h> 74#include <linux/init.h>
76#include <linux/list.h> 75#include <linux/list.h>
@@ -2684,7 +2683,7 @@ static int __devexit isp1362_remove(struct platform_device *pdev)
2684 return 0; 2683 return 0;
2685} 2684}
2686 2685
2687static int __init isp1362_probe(struct platform_device *pdev) 2686static int __devinit isp1362_probe(struct platform_device *pdev)
2688{ 2687{
2689 struct usb_hcd *hcd; 2688 struct usb_hcd *hcd;
2690 struct isp1362_hcd *isp1362_hcd; 2689 struct isp1362_hcd *isp1362_hcd;
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index 6e7fb5f38db6..ee60cd3ea642 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -12,7 +12,6 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/debugfs.h> 14#include <linux/debugfs.h>
15#include <linux/smp_lock.h>
16#include <asm/io.h> 15#include <asm/io.h>
17 16
18#include "uhci-hcd.h" 17#include "uhci-hcd.h"
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index fef5a1f9d483..5d963e350494 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -229,6 +229,13 @@ void xhci_ring_device(struct xhci_hcd *xhci, int slot_id)
229static void xhci_disable_port(struct xhci_hcd *xhci, u16 wIndex, 229static void xhci_disable_port(struct xhci_hcd *xhci, u16 wIndex,
230 u32 __iomem *addr, u32 port_status) 230 u32 __iomem *addr, u32 port_status)
231{ 231{
232 /* Don't allow the USB core to disable SuperSpeed ports. */
233 if (xhci->port_array[wIndex] == 0x03) {
234 xhci_dbg(xhci, "Ignoring request to disable "
235 "SuperSpeed port.\n");
236 return;
237 }
238
232 /* Write 1 to disable the port */ 239 /* Write 1 to disable the port */
233 xhci_writel(xhci, port_status | PORT_PE, addr); 240 xhci_writel(xhci, port_status | PORT_PE, addr);
234 port_status = xhci_readl(xhci, addr); 241 port_status = xhci_readl(xhci, addr);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 202770676da3..1d0f45f0e7a6 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1045,7 +1045,7 @@ static inline u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
1045 if (udev->speed == USB_SPEED_SUPER) 1045 if (udev->speed == USB_SPEED_SUPER)
1046 return ep->ss_ep_comp.wBytesPerInterval; 1046 return ep->ss_ep_comp.wBytesPerInterval;
1047 1047
1048 max_packet = ep->desc.wMaxPacketSize & 0x3ff; 1048 max_packet = GET_MAX_PACKET(ep->desc.wMaxPacketSize);
1049 max_burst = (ep->desc.wMaxPacketSize & 0x1800) >> 11; 1049 max_burst = (ep->desc.wMaxPacketSize & 0x1800) >> 11;
1050 /* A 0 in max burst means 1 transfer per ESIT */ 1050 /* A 0 in max burst means 1 transfer per ESIT */
1051 return max_packet * (max_burst + 1); 1051 return max_packet * (max_burst + 1);
@@ -1135,7 +1135,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1135 /* Fall through */ 1135 /* Fall through */
1136 case USB_SPEED_FULL: 1136 case USB_SPEED_FULL:
1137 case USB_SPEED_LOW: 1137 case USB_SPEED_LOW:
1138 max_packet = ep->desc.wMaxPacketSize & 0x3ff; 1138 max_packet = GET_MAX_PACKET(ep->desc.wMaxPacketSize);
1139 ep_ctx->ep_info2 |= MAX_PACKET(max_packet); 1139 ep_ctx->ep_info2 |= MAX_PACKET(max_packet);
1140 break; 1140 break;
1141 default: 1141 default:
@@ -1443,6 +1443,13 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1443 xhci->dcbaa = NULL; 1443 xhci->dcbaa = NULL;
1444 1444
1445 scratchpad_free(xhci); 1445 scratchpad_free(xhci);
1446
1447 xhci->num_usb2_ports = 0;
1448 xhci->num_usb3_ports = 0;
1449 kfree(xhci->usb2_ports);
1450 kfree(xhci->usb3_ports);
1451 kfree(xhci->port_array);
1452
1446 xhci->page_size = 0; 1453 xhci->page_size = 0;
1447 xhci->page_shift = 0; 1454 xhci->page_shift = 0;
1448 xhci->bus_suspended = 0; 1455 xhci->bus_suspended = 0;
@@ -1627,6 +1634,166 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
1627 &xhci->ir_set->erst_dequeue); 1634 &xhci->ir_set->erst_dequeue);
1628} 1635}
1629 1636
1637static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
1638 u32 __iomem *addr, u8 major_revision)
1639{
1640 u32 temp, port_offset, port_count;
1641 int i;
1642
1643 if (major_revision > 0x03) {
1644 xhci_warn(xhci, "Ignoring unknown port speed, "
1645 "Ext Cap %p, revision = 0x%x\n",
1646 addr, major_revision);
1647 /* Ignoring port protocol we can't understand. FIXME */
1648 return;
1649 }
1650
1651 /* Port offset and count in the third dword, see section 7.2 */
1652 temp = xhci_readl(xhci, addr + 2);
1653 port_offset = XHCI_EXT_PORT_OFF(temp);
1654 port_count = XHCI_EXT_PORT_COUNT(temp);
1655 xhci_dbg(xhci, "Ext Cap %p, port offset = %u, "
1656 "count = %u, revision = 0x%x\n",
1657 addr, port_offset, port_count, major_revision);
1658 /* Port count includes the current port offset */
1659 if (port_offset == 0 || (port_offset + port_count - 1) > num_ports)
1660 /* WTF? "Valid values are ‘1’ to MaxPorts" */
1661 return;
1662 port_offset--;
1663 for (i = port_offset; i < (port_offset + port_count); i++) {
1664 /* Duplicate entry. Ignore the port if the revisions differ. */
1665 if (xhci->port_array[i] != 0) {
1666 xhci_warn(xhci, "Duplicate port entry, Ext Cap %p,"
1667 " port %u\n", addr, i);
1668 xhci_warn(xhci, "Port was marked as USB %u, "
1669 "duplicated as USB %u\n",
1670 xhci->port_array[i], major_revision);
1671 /* Only adjust the roothub port counts if we haven't
1672 * found a similar duplicate.
1673 */
1674 if (xhci->port_array[i] != major_revision &&
1675 xhci->port_array[i] != (u8) -1) {
1676 if (xhci->port_array[i] == 0x03)
1677 xhci->num_usb3_ports--;
1678 else
1679 xhci->num_usb2_ports--;
1680 xhci->port_array[i] = (u8) -1;
1681 }
1682 /* FIXME: Should we disable the port? */
1683 continue;
1684 }
1685 xhci->port_array[i] = major_revision;
1686 if (major_revision == 0x03)
1687 xhci->num_usb3_ports++;
1688 else
1689 xhci->num_usb2_ports++;
1690 }
1691 /* FIXME: Should we disable ports not in the Extended Capabilities? */
1692}
1693
1694/*
1695 * Scan the Extended Capabilities for the "Supported Protocol Capabilities" that
1696 * specify what speeds each port is supposed to be. We can't count on the port
1697 * speed bits in the PORTSC register being correct until a device is connected,
1698 * but we need to set up the two fake roothubs with the correct number of USB
1699 * 3.0 and USB 2.0 ports at host controller initialization time.
1700 */
1701static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
1702{
1703 u32 __iomem *addr;
1704 u32 offset;
1705 unsigned int num_ports;
1706 int i, port_index;
1707
1708 addr = &xhci->cap_regs->hcc_params;
1709 offset = XHCI_HCC_EXT_CAPS(xhci_readl(xhci, addr));
1710 if (offset == 0) {
1711 xhci_err(xhci, "No Extended Capability registers, "
1712 "unable to set up roothub.\n");
1713 return -ENODEV;
1714 }
1715
1716 num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
1717 xhci->port_array = kzalloc(sizeof(*xhci->port_array)*num_ports, flags);
1718 if (!xhci->port_array)
1719 return -ENOMEM;
1720
1721 /*
1722 * For whatever reason, the first capability offset is from the
1723 * capability register base, not from the HCCPARAMS register.
1724 * See section 5.3.6 for offset calculation.
1725 */
1726 addr = &xhci->cap_regs->hc_capbase + offset;
1727 while (1) {
1728 u32 cap_id;
1729
1730 cap_id = xhci_readl(xhci, addr);
1731 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL)
1732 xhci_add_in_port(xhci, num_ports, addr,
1733 (u8) XHCI_EXT_PORT_MAJOR(cap_id));
1734 offset = XHCI_EXT_CAPS_NEXT(cap_id);
1735 if (!offset || (xhci->num_usb2_ports + xhci->num_usb3_ports)
1736 == num_ports)
1737 break;
1738 /*
1739 * Once you're into the Extended Capabilities, the offset is
1740 * always relative to the register holding the offset.
1741 */
1742 addr += offset;
1743 }
1744
1745 if (xhci->num_usb2_ports == 0 && xhci->num_usb3_ports == 0) {
1746 xhci_warn(xhci, "No ports on the roothubs?\n");
1747 return -ENODEV;
1748 }
1749 xhci_dbg(xhci, "Found %u USB 2.0 ports and %u USB 3.0 ports.\n",
1750 xhci->num_usb2_ports, xhci->num_usb3_ports);
1751 /*
1752 * Note we could have all USB 3.0 ports, or all USB 2.0 ports.
1753 * Not sure how the USB core will handle a hub with no ports...
1754 */
1755 if (xhci->num_usb2_ports) {
1756 xhci->usb2_ports = kmalloc(sizeof(*xhci->usb2_ports)*
1757 xhci->num_usb2_ports, flags);
1758 if (!xhci->usb2_ports)
1759 return -ENOMEM;
1760
1761 port_index = 0;
1762 for (i = 0; i < num_ports; i++) {
1763 if (xhci->port_array[i] == 0x03 ||
1764 xhci->port_array[i] == 0 ||
1765 xhci->port_array[i] == -1)
1766 continue;
1767
1768 xhci->usb2_ports[port_index] =
1769 &xhci->op_regs->port_status_base +
1770 NUM_PORT_REGS*i;
1771 xhci_dbg(xhci, "USB 2.0 port at index %u, "
1772 "addr = %p\n", i,
1773 xhci->usb2_ports[port_index]);
1774 port_index++;
1775 }
1776 }
1777 if (xhci->num_usb3_ports) {
1778 xhci->usb3_ports = kmalloc(sizeof(*xhci->usb3_ports)*
1779 xhci->num_usb3_ports, flags);
1780 if (!xhci->usb3_ports)
1781 return -ENOMEM;
1782
1783 port_index = 0;
1784 for (i = 0; i < num_ports; i++)
1785 if (xhci->port_array[i] == 0x03) {
1786 xhci->usb3_ports[port_index] =
1787 &xhci->op_regs->port_status_base +
1788 NUM_PORT_REGS*i;
1789 xhci_dbg(xhci, "USB 3.0 port at index %u, "
1790 "addr = %p\n", i,
1791 xhci->usb3_ports[port_index]);
1792 port_index++;
1793 }
1794 }
1795 return 0;
1796}
1630 1797
1631int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) 1798int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
1632{ 1799{
@@ -1809,6 +1976,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
1809 1976
1810 if (scratchpad_alloc(xhci, flags)) 1977 if (scratchpad_alloc(xhci, flags))
1811 goto fail; 1978 goto fail;
1979 if (xhci_setup_port_arrays(xhci, flags))
1980 goto fail;
1812 1981
1813 return 0; 1982 return 0;
1814 1983
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 9f3115e729b1..df558f6f84e3 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2104,7 +2104,6 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
2104 2104
2105 if (!(status & STS_EINT)) { 2105 if (!(status & STS_EINT)) {
2106 spin_unlock(&xhci->lock); 2106 spin_unlock(&xhci->lock);
2107 xhci_warn(xhci, "Spurious interrupt.\n");
2108 return IRQ_NONE; 2107 return IRQ_NONE;
2109 } 2108 }
2110 xhci_dbg(xhci, "op reg status = %08x\n", status); 2109 xhci_dbg(xhci, "op reg status = %08x\n", status);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 5d7d4e951ea4..45e4a3108cc3 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -577,6 +577,65 @@ static void xhci_restore_registers(struct xhci_hcd *xhci)
577 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base); 577 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base);
578} 578}
579 579
580static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci)
581{
582 u64 val_64;
583
584 /* step 2: initialize command ring buffer */
585 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
586 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) |
587 (xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
588 xhci->cmd_ring->dequeue) &
589 (u64) ~CMD_RING_RSVD_BITS) |
590 xhci->cmd_ring->cycle_state;
591 xhci_dbg(xhci, "// Setting command ring address to 0x%llx\n",
592 (long unsigned long) val_64);
593 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring);
594}
595
596/*
597 * The whole command ring must be cleared to zero when we suspend the host.
598 *
599 * The host doesn't save the command ring pointer in the suspend well, so we
600 * need to re-program it on resume. Unfortunately, the pointer must be 64-byte
601 * aligned, because of the reserved bits in the command ring dequeue pointer
602 * register. Therefore, we can't just set the dequeue pointer back in the
603 * middle of the ring (TRBs are 16-byte aligned).
604 */
605static void xhci_clear_command_ring(struct xhci_hcd *xhci)
606{
607 struct xhci_ring *ring;
608 struct xhci_segment *seg;
609
610 ring = xhci->cmd_ring;
611 seg = ring->deq_seg;
612 do {
613 memset(seg->trbs, 0, SEGMENT_SIZE);
614 seg = seg->next;
615 } while (seg != ring->deq_seg);
616
617 /* Reset the software enqueue and dequeue pointers */
618 ring->deq_seg = ring->first_seg;
619 ring->dequeue = ring->first_seg->trbs;
620 ring->enq_seg = ring->deq_seg;
621 ring->enqueue = ring->dequeue;
622
623 /*
624 * Ring is now zeroed, so the HW should look for change of ownership
625 * when the cycle bit is set to 1.
626 */
627 ring->cycle_state = 1;
628
629 /*
630 * Reset the hardware dequeue pointer.
631 * Yes, this will need to be re-written after resume, but we're paranoid
632 * and want to make sure the hardware doesn't access bogus memory
633 * because, say, the BIOS or an SMI started the host without changing
634 * the command ring pointers.
635 */
636 xhci_set_cmd_ring_deq(xhci);
637}
638
580/* 639/*
581 * Stop HC (not bus-specific) 640 * Stop HC (not bus-specific)
582 * 641 *
@@ -604,6 +663,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
604 spin_unlock_irq(&xhci->lock); 663 spin_unlock_irq(&xhci->lock);
605 return -ETIMEDOUT; 664 return -ETIMEDOUT;
606 } 665 }
666 xhci_clear_command_ring(xhci);
607 667
608 /* step 3: save registers */ 668 /* step 3: save registers */
609 xhci_save_registers(xhci); 669 xhci_save_registers(xhci);
@@ -635,7 +695,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
635 u32 command, temp = 0; 695 u32 command, temp = 0;
636 struct usb_hcd *hcd = xhci_to_hcd(xhci); 696 struct usb_hcd *hcd = xhci_to_hcd(xhci);
637 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 697 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
638 u64 val_64;
639 int old_state, retval; 698 int old_state, retval;
640 699
641 old_state = hcd->state; 700 old_state = hcd->state;
@@ -648,15 +707,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
648 /* step 1: restore register */ 707 /* step 1: restore register */
649 xhci_restore_registers(xhci); 708 xhci_restore_registers(xhci);
650 /* step 2: initialize command ring buffer */ 709 /* step 2: initialize command ring buffer */
651 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 710 xhci_set_cmd_ring_deq(xhci);
652 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) |
653 (xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
654 xhci->cmd_ring->dequeue) &
655 (u64) ~CMD_RING_RSVD_BITS) |
656 xhci->cmd_ring->cycle_state;
657 xhci_dbg(xhci, "// Setting command ring address to 0x%llx\n",
658 (long unsigned long) val_64);
659 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring);
660 /* step 3: restore state and start state*/ 711 /* step 3: restore state and start state*/
661 /* step 3: set CRS flag */ 712 /* step 3: set CRS flag */
662 command = xhci_readl(xhci, &xhci->op_regs->command); 713 command = xhci_readl(xhci, &xhci->op_regs->command);
@@ -714,6 +765,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
714 return retval; 765 return retval;
715 } 766 }
716 767
768 spin_unlock_irq(&xhci->lock);
717 /* Re-setup MSI-X */ 769 /* Re-setup MSI-X */
718 if (hcd->irq) 770 if (hcd->irq)
719 free_irq(hcd->irq, hcd); 771 free_irq(hcd->irq, hcd);
@@ -736,6 +788,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
736 hcd->irq = pdev->irq; 788 hcd->irq = pdev->irq;
737 } 789 }
738 790
791 spin_lock_irq(&xhci->lock);
739 /* step 4: set Run/Stop bit */ 792 /* step 4: set Run/Stop bit */
740 command = xhci_readl(xhci, &xhci->op_regs->command); 793 command = xhci_readl(xhci, &xhci->op_regs->command);
741 command |= CMD_RUN; 794 command |= CMD_RUN;
@@ -1496,6 +1549,15 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
1496 cmd_completion = command->completion; 1549 cmd_completion = command->completion;
1497 cmd_status = &command->status; 1550 cmd_status = &command->status;
1498 command->command_trb = xhci->cmd_ring->enqueue; 1551 command->command_trb = xhci->cmd_ring->enqueue;
1552
1553 /* Enqueue pointer can be left pointing to the link TRB,
1554 * we must handle that
1555 */
1556 if ((command->command_trb->link.control & TRB_TYPE_BITMASK)
1557 == TRB_TYPE(TRB_LINK))
1558 command->command_trb =
1559 xhci->cmd_ring->enq_seg->next->trbs;
1560
1499 list_add_tail(&command->cmd_list, &virt_dev->cmd_list); 1561 list_add_tail(&command->cmd_list, &virt_dev->cmd_list);
1500 } else { 1562 } else {
1501 in_ctx = virt_dev->in_ctx; 1563 in_ctx = virt_dev->in_ctx;
@@ -2219,6 +2281,15 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
2219 /* Attempt to submit the Reset Device command to the command ring */ 2281 /* Attempt to submit the Reset Device command to the command ring */
2220 spin_lock_irqsave(&xhci->lock, flags); 2282 spin_lock_irqsave(&xhci->lock, flags);
2221 reset_device_cmd->command_trb = xhci->cmd_ring->enqueue; 2283 reset_device_cmd->command_trb = xhci->cmd_ring->enqueue;
2284
2285 /* Enqueue pointer can be left pointing to the link TRB,
2286 * we must handle that
2287 */
2288 if ((reset_device_cmd->command_trb->link.control & TRB_TYPE_BITMASK)
2289 == TRB_TYPE(TRB_LINK))
2290 reset_device_cmd->command_trb =
2291 xhci->cmd_ring->enq_seg->next->trbs;
2292
2222 list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list); 2293 list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list);
2223 ret = xhci_queue_reset_device(xhci, slot_id); 2294 ret = xhci_queue_reset_device(xhci, slot_id);
2224 if (ret) { 2295 if (ret) {
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 93d3bf4d213c..170c367112d2 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -454,6 +454,24 @@ struct xhci_doorbell_array {
454 454
455 455
456/** 456/**
457 * struct xhci_protocol_caps
458 * @revision: major revision, minor revision, capability ID,
459 * and next capability pointer.
460 * @name_string: Four ASCII characters to say which spec this xHC
461 * follows, typically "USB ".
462 * @port_info: Port offset, count, and protocol-defined information.
463 */
464struct xhci_protocol_caps {
465 u32 revision;
466 u32 name_string;
467 u32 port_info;
468};
469
470#define XHCI_EXT_PORT_MAJOR(x) (((x) >> 24) & 0xff)
471#define XHCI_EXT_PORT_OFF(x) ((x) & 0xff)
472#define XHCI_EXT_PORT_COUNT(x) (((x) >> 8) & 0xff)
473
474/**
457 * struct xhci_container_ctx 475 * struct xhci_container_ctx
458 * @type: Type of context. Used to calculated offsets to contained contexts. 476 * @type: Type of context. Used to calculated offsets to contained contexts.
459 * @size: Size of the context data 477 * @size: Size of the context data
@@ -621,6 +639,11 @@ struct xhci_ep_ctx {
621#define MAX_PACKET_MASK (0xffff << 16) 639#define MAX_PACKET_MASK (0xffff << 16)
622#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) 640#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff)
623 641
642/* Get max packet size from ep desc. Bit 10..0 specify the max packet size.
643 * USB2.0 spec 9.6.6.
644 */
645#define GET_MAX_PACKET(p) ((p) & 0x7ff)
646
624/* tx_info bitmasks */ 647/* tx_info bitmasks */
625#define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff) 648#define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff)
626#define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16) 649#define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16)
@@ -1235,6 +1258,14 @@ struct xhci_hcd {
1235 u32 suspended_ports[8]; /* which ports are 1258 u32 suspended_ports[8]; /* which ports are
1236 suspended */ 1259 suspended */
1237 unsigned long resume_done[MAX_HC_PORTS]; 1260 unsigned long resume_done[MAX_HC_PORTS];
1261 /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */
1262 u8 *port_array;
1263 /* Array of pointers to USB 3.0 PORTSC registers */
1264 u32 __iomem **usb3_ports;
1265 unsigned int num_usb3_ports;
1266 /* Array of pointers to USB 2.0 PORTSC registers */
1267 u32 __iomem **usb2_ports;
1268 unsigned int num_usb2_ports;
1238}; 1269};
1239 1270
1240/* For testing purposes */ 1271/* For testing purposes */
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 5a47805d9580..c90c89dc0003 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -364,7 +364,7 @@ static int mts_scsi_host_reset(struct scsi_cmnd *srb)
364} 364}
365 365
366static int 366static int
367mts_scsi_queuecommand(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback); 367mts_scsi_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *srb);
368 368
369static void mts_transfer_cleanup( struct urb *transfer ); 369static void mts_transfer_cleanup( struct urb *transfer );
370static void mts_do_sg(struct urb * transfer); 370static void mts_do_sg(struct urb * transfer);
@@ -573,7 +573,7 @@ mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc)
573 573
574 574
575static int 575static int
576mts_scsi_queuecommand(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback) 576mts_scsi_queuecommand_lck(struct scsi_cmnd *srb, mts_scsi_cmnd_callback callback)
577{ 577{
578 struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]); 578 struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]);
579 int err = 0; 579 int err = 0;
@@ -626,6 +626,8 @@ out:
626 return err; 626 return err;
627} 627}
628 628
629static DEF_SCSI_QCMD(mts_scsi_queuecommand)
630
629static struct scsi_host_template mts_scsi_host_template = { 631static struct scsi_host_template mts_scsi_host_template = {
630 .module = THIS_MODULE, 632 .module = THIS_MODULE,
631 .name = "microtekX6", 633 .name = "microtekX6",
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c
index 2f43c57743c9..9251773ecef4 100644
--- a/drivers/usb/misc/cypress_cy7c63.c
+++ b/drivers/usb/misc/cypress_cy7c63.c
@@ -196,11 +196,9 @@ static ssize_t get_port1_handler(struct device *dev,
196 return read_port(dev, attr, buf, 1, CYPRESS_READ_PORT_ID1); 196 return read_port(dev, attr, buf, 1, CYPRESS_READ_PORT_ID1);
197} 197}
198 198
199static DEVICE_ATTR(port0, S_IWUGO | S_IRUGO, 199static DEVICE_ATTR(port0, S_IRUGO | S_IWUSR, get_port0_handler, set_port0_handler);
200 get_port0_handler, set_port0_handler);
201 200
202static DEVICE_ATTR(port1, S_IWUGO | S_IRUGO, 201static DEVICE_ATTR(port1, S_IRUGO | S_IWUSR, get_port1_handler, set_port1_handler);
203 get_port1_handler, set_port1_handler);
204 202
205 203
206static int cypress_probe(struct usb_interface *interface, 204static int cypress_probe(struct usb_interface *interface,
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index d77aba46ae85..f63776a48e2a 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -86,7 +86,7 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr,
86 return count; 86 return count;
87} 87}
88 88
89static DEVICE_ATTR(speed, S_IWUGO | S_IRUGO, show_speed, set_speed); 89static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR, show_speed, set_speed);
90 90
91static int tv_probe(struct usb_interface *interface, 91static int tv_probe(struct usb_interface *interface,
92 const struct usb_device_id *id) 92 const struct usb_device_id *id)
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index 63da2c3c838f..c96f51de1696 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -94,7 +94,7 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
94 change_color(led); \ 94 change_color(led); \
95 return count; \ 95 return count; \
96} \ 96} \
97static DEVICE_ATTR(value, S_IWUGO | S_IRUGO, show_##value, set_##value); 97static DEVICE_ATTR(value, S_IRUGO | S_IWUSR, show_##value, set_##value);
98show_set(blue); 98show_set(blue);
99show_set(red); 99show_set(red);
100show_set(green); 100show_set(green);
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
index de8ef945b536..417b8f207e8b 100644
--- a/drivers/usb/misc/usbsevseg.c
+++ b/drivers/usb/misc/usbsevseg.c
@@ -192,7 +192,7 @@ static ssize_t set_attr_##name(struct device *dev, \
192 \ 192 \
193 return count; \ 193 return count; \
194} \ 194} \
195static DEVICE_ATTR(name, S_IWUGO | S_IRUGO, show_attr_##name, set_attr_##name); 195static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_attr_##name, set_attr_##name);
196 196
197static ssize_t show_attr_text(struct device *dev, 197static ssize_t show_attr_text(struct device *dev,
198 struct device_attribute *attr, char *buf) 198 struct device_attribute *attr, char *buf)
@@ -223,7 +223,7 @@ static ssize_t set_attr_text(struct device *dev,
223 return count; 223 return count;
224} 224}
225 225
226static DEVICE_ATTR(text, S_IWUGO | S_IRUGO, show_attr_text, set_attr_text); 226static DEVICE_ATTR(text, S_IRUGO | S_IWUSR, show_attr_text, set_attr_text);
227 227
228static ssize_t show_attr_decimals(struct device *dev, 228static ssize_t show_attr_decimals(struct device *dev,
229 struct device_attribute *attr, char *buf) 229 struct device_attribute *attr, char *buf)
@@ -272,8 +272,7 @@ static ssize_t set_attr_decimals(struct device *dev,
272 return count; 272 return count;
273} 273}
274 274
275static DEVICE_ATTR(decimals, S_IWUGO | S_IRUGO, 275static DEVICE_ATTR(decimals, S_IRUGO | S_IWUSR, show_attr_decimals, set_attr_decimals);
276 show_attr_decimals, set_attr_decimals);
277 276
278static ssize_t show_attr_textmode(struct device *dev, 277static ssize_t show_attr_textmode(struct device *dev,
279 struct device_attribute *attr, char *buf) 278 struct device_attribute *attr, char *buf)
@@ -319,8 +318,7 @@ static ssize_t set_attr_textmode(struct device *dev,
319 return -EINVAL; 318 return -EINVAL;
320} 319}
321 320
322static DEVICE_ATTR(textmode, S_IWUGO | S_IRUGO, 321static DEVICE_ATTR(textmode, S_IRUGO | S_IWUSR, show_attr_textmode, set_attr_textmode);
323 show_attr_textmode, set_attr_textmode);
324 322
325 323
326MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered); 324MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered);
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 796e2f68f749..4ff21587ab03 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -3,7 +3,7 @@
3/* 3/*
4 * uss720.c -- USS720 USB Parport Cable. 4 * uss720.c -- USS720 USB Parport Cable.
5 * 5 *
6 * Copyright (C) 1999, 2005 6 * Copyright (C) 1999, 2005, 2010
7 * Thomas Sailer (t.sailer@alumni.ethz.ch) 7 * Thomas Sailer (t.sailer@alumni.ethz.ch)
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
@@ -776,6 +776,8 @@ static const struct usb_device_id uss720_table[] = {
776 { USB_DEVICE(0x0557, 0x2001) }, 776 { USB_DEVICE(0x0557, 0x2001) },
777 { USB_DEVICE(0x0729, 0x1284) }, 777 { USB_DEVICE(0x0729, 0x1284) },
778 { USB_DEVICE(0x1293, 0x0002) }, 778 { USB_DEVICE(0x1293, 0x0002) },
779 { USB_DEVICE(0x1293, 0x0002) },
780 { USB_DEVICE(0x050d, 0x0002) },
779 { } /* Terminating entry */ 781 { } /* Terminating entry */
780}; 782};
781 783
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 719c6180b31f..ac5bfd619e62 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -536,6 +536,7 @@ static const struct file_operations yurex_fops = {
536 .open = yurex_open, 536 .open = yurex_open,
537 .release = yurex_release, 537 .release = yurex_release,
538 .fasync = yurex_fasync, 538 .fasync = yurex_fasync,
539 .llseek = default_llseek,
539}; 540};
540 541
541 542
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 44cb37b5a4dc..c436e1e2c3b6 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -15,7 +15,6 @@
15#include <linux/poll.h> 15#include <linux/poll.h>
16#include <linux/compat.h> 16#include <linux/compat.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/smp_lock.h>
19#include <linux/scatterlist.h> 18#include <linux/scatterlist.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21 20
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 8ec94f15a738..e5ce42bd316e 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -11,7 +11,6 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/usb.h> 12#include <linux/usb.h>
13#include <linux/fs.h> 13#include <linux/fs.h>
14#include <linux/smp_lock.h>
15#include <asm/uaccess.h> 14#include <asm/uaccess.h>
16 15
17#include "usb_mon.h" 16#include "usb_mon.h"
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index e6669fc3b804..99beebce8550 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2116,12 +2116,15 @@ bad_config:
2116 * Otherwise, wait till the gadget driver hooks up. 2116 * Otherwise, wait till the gadget driver hooks up.
2117 */ 2117 */
2118 if (!is_otg_enabled(musb) && is_host_enabled(musb)) { 2118 if (!is_otg_enabled(musb) && is_host_enabled(musb)) {
2119 struct usb_hcd *hcd = musb_to_hcd(musb);
2120
2119 MUSB_HST_MODE(musb); 2121 MUSB_HST_MODE(musb);
2120 musb->xceiv->default_a = 1; 2122 musb->xceiv->default_a = 1;
2121 musb->xceiv->state = OTG_STATE_A_IDLE; 2123 musb->xceiv->state = OTG_STATE_A_IDLE;
2122 2124
2123 status = usb_add_hcd(musb_to_hcd(musb), -1, 0); 2125 status = usb_add_hcd(musb_to_hcd(musb), -1, 0);
2124 2126
2127 hcd->self.uses_pio_for_control = 1;
2125 DBG(1, "%s mode, status %d, devctl %02x %c\n", 2128 DBG(1, "%s mode, status %d, devctl %02x %c\n",
2126 "HOST", status, 2129 "HOST", status,
2127 musb_readb(musb->mregs, MUSB_DEVCTL), 2130 musb_readb(musb->mregs, MUSB_DEVCTL),
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 36cfd060dbe5..9d6ade82b9f2 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -92,6 +92,59 @@
92 92
93/* ----------------------------------------------------------------------- */ 93/* ----------------------------------------------------------------------- */
94 94
95/* Maps the buffer to dma */
96
97static inline void map_dma_buffer(struct musb_request *request,
98 struct musb *musb)
99{
100 if (request->request.dma == DMA_ADDR_INVALID) {
101 request->request.dma = dma_map_single(
102 musb->controller,
103 request->request.buf,
104 request->request.length,
105 request->tx
106 ? DMA_TO_DEVICE
107 : DMA_FROM_DEVICE);
108 request->mapped = 1;
109 } else {
110 dma_sync_single_for_device(musb->controller,
111 request->request.dma,
112 request->request.length,
113 request->tx
114 ? DMA_TO_DEVICE
115 : DMA_FROM_DEVICE);
116 request->mapped = 0;
117 }
118}
119
120/* Unmap the buffer from dma and maps it back to cpu */
121static inline void unmap_dma_buffer(struct musb_request *request,
122 struct musb *musb)
123{
124 if (request->request.dma == DMA_ADDR_INVALID) {
125 DBG(20, "not unmapping a never mapped buffer\n");
126 return;
127 }
128 if (request->mapped) {
129 dma_unmap_single(musb->controller,
130 request->request.dma,
131 request->request.length,
132 request->tx
133 ? DMA_TO_DEVICE
134 : DMA_FROM_DEVICE);
135 request->request.dma = DMA_ADDR_INVALID;
136 request->mapped = 0;
137 } else {
138 dma_sync_single_for_cpu(musb->controller,
139 request->request.dma,
140 request->request.length,
141 request->tx
142 ? DMA_TO_DEVICE
143 : DMA_FROM_DEVICE);
144
145 }
146}
147
95/* 148/*
96 * Immediately complete a request. 149 * Immediately complete a request.
97 * 150 *
@@ -119,24 +172,8 @@ __acquires(ep->musb->lock)
119 172
120 ep->busy = 1; 173 ep->busy = 1;
121 spin_unlock(&musb->lock); 174 spin_unlock(&musb->lock);
122 if (is_dma_capable()) { 175 if (is_dma_capable() && ep->dma)
123 if (req->mapped) { 176 unmap_dma_buffer(req, musb);
124 dma_unmap_single(musb->controller,
125 req->request.dma,
126 req->request.length,
127 req->tx
128 ? DMA_TO_DEVICE
129 : DMA_FROM_DEVICE);
130 req->request.dma = DMA_ADDR_INVALID;
131 req->mapped = 0;
132 } else if (req->request.dma != DMA_ADDR_INVALID)
133 dma_sync_single_for_cpu(musb->controller,
134 req->request.dma,
135 req->request.length,
136 req->tx
137 ? DMA_TO_DEVICE
138 : DMA_FROM_DEVICE);
139 }
140 if (request->status == 0) 177 if (request->status == 0)
141 DBG(5, "%s done request %p, %d/%d\n", 178 DBG(5, "%s done request %p, %d/%d\n",
142 ep->end_point.name, request, 179 ep->end_point.name, request,
@@ -395,6 +432,13 @@ static void txstate(struct musb *musb, struct musb_request *req)
395#endif 432#endif
396 433
397 if (!use_dma) { 434 if (!use_dma) {
435 /*
436 * Unmap the dma buffer back to cpu if dma channel
437 * programming fails
438 */
439 if (is_dma_capable() && musb_ep->dma)
440 unmap_dma_buffer(req, musb);
441
398 musb_write_fifo(musb_ep->hw_ep, fifo_count, 442 musb_write_fifo(musb_ep->hw_ep, fifo_count,
399 (u8 *) (request->buf + request->actual)); 443 (u8 *) (request->buf + request->actual));
400 request->actual += fifo_count; 444 request->actual += fifo_count;
@@ -713,6 +757,21 @@ static void rxstate(struct musb *musb, struct musb_request *req)
713 return; 757 return;
714 } 758 }
715#endif 759#endif
760 /*
761 * Unmap the dma buffer back to cpu if dma channel
762 * programming fails. This buffer is mapped if the
763 * channel allocation is successful
764 */
765 if (is_dma_capable() && musb_ep->dma) {
766 unmap_dma_buffer(req, musb);
767
768 /*
769 * Clear DMAENAB and AUTOCLEAR for the
770 * PIO mode transfer
771 */
772 csr &= ~(MUSB_RXCSR_DMAENAB | MUSB_RXCSR_AUTOCLEAR);
773 musb_writew(epio, MUSB_RXCSR, csr);
774 }
716 775
717 musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *) 776 musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *)
718 (request->buf + request->actual)); 777 (request->buf + request->actual));
@@ -837,7 +896,9 @@ void musb_g_rx(struct musb *musb, u8 epnum)
837 if (!request) 896 if (!request)
838 return; 897 return;
839 } 898 }
899#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_TUSB_OMAP_DMA)
840exit: 900exit:
901#endif
841 /* Analyze request */ 902 /* Analyze request */
842 rxstate(musb, to_musb_request(request)); 903 rxstate(musb, to_musb_request(request));
843} 904}
@@ -1150,26 +1211,9 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req,
1150 request->epnum = musb_ep->current_epnum; 1211 request->epnum = musb_ep->current_epnum;
1151 request->tx = musb_ep->is_in; 1212 request->tx = musb_ep->is_in;
1152 1213
1153 if (is_dma_capable() && musb_ep->dma) { 1214 if (is_dma_capable() && musb_ep->dma)
1154 if (request->request.dma == DMA_ADDR_INVALID) { 1215 map_dma_buffer(request, musb);
1155 request->request.dma = dma_map_single( 1216 else
1156 musb->controller,
1157 request->request.buf,
1158 request->request.length,
1159 request->tx
1160 ? DMA_TO_DEVICE
1161 : DMA_FROM_DEVICE);
1162 request->mapped = 1;
1163 } else {
1164 dma_sync_single_for_device(musb->controller,
1165 request->request.dma,
1166 request->request.length,
1167 request->tx
1168 ? DMA_TO_DEVICE
1169 : DMA_FROM_DEVICE);
1170 request->mapped = 0;
1171 }
1172 } else
1173 request->mapped = 0; 1217 request->mapped = 0;
1174 1218
1175 spin_lock_irqsave(&musb->lock, lockflags); 1219 spin_lock_irqsave(&musb->lock, lockflags);
@@ -1789,6 +1833,8 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1789 spin_unlock_irqrestore(&musb->lock, flags); 1833 spin_unlock_irqrestore(&musb->lock, flags);
1790 1834
1791 if (is_otg_enabled(musb)) { 1835 if (is_otg_enabled(musb)) {
1836 struct usb_hcd *hcd = musb_to_hcd(musb);
1837
1792 DBG(3, "OTG startup...\n"); 1838 DBG(3, "OTG startup...\n");
1793 1839
1794 /* REVISIT: funcall to other code, which also 1840 /* REVISIT: funcall to other code, which also
@@ -1803,6 +1849,8 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1803 musb->gadget_driver = NULL; 1849 musb->gadget_driver = NULL;
1804 musb->g.dev.driver = NULL; 1850 musb->g.dev.driver = NULL;
1805 spin_unlock_irqrestore(&musb->lock, flags); 1851 spin_unlock_irqrestore(&musb->lock, flags);
1852 } else {
1853 hcd->self.uses_pio_for_control = 1;
1806 } 1854 }
1807 } 1855 }
1808 } 1856 }
diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c
index bdc3ea66be69..9fea48264fa2 100644
--- a/drivers/usb/otg/langwell_otg.c
+++ b/drivers/usb/otg/langwell_otg.c
@@ -1896,7 +1896,7 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
1896 } 1896 }
1897 return count; 1897 return count;
1898} 1898}
1899static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUGO, get_a_bus_req, set_a_bus_req); 1899static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req);
1900 1900
1901static ssize_t 1901static ssize_t
1902get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf) 1902get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
@@ -1942,8 +1942,7 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr,
1942 } 1942 }
1943 return count; 1943 return count;
1944} 1944}
1945static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUGO, 1945static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop, set_a_bus_drop);
1946 get_a_bus_drop, set_a_bus_drop);
1947 1946
1948static ssize_t 1947static ssize_t
1949get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf) 1948get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
@@ -1988,7 +1987,7 @@ set_b_bus_req(struct device *dev, struct device_attribute *attr,
1988 } 1987 }
1989 return count; 1988 return count;
1990} 1989}
1991static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUGO, get_b_bus_req, set_b_bus_req); 1990static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req);
1992 1991
1993static ssize_t 1992static ssize_t
1994set_a_clr_err(struct device *dev, struct device_attribute *attr, 1993set_a_clr_err(struct device *dev, struct device_attribute *attr,
@@ -2012,7 +2011,7 @@ set_a_clr_err(struct device *dev, struct device_attribute *attr,
2012 } 2011 }
2013 return count; 2012 return count;
2014} 2013}
2015static DEVICE_ATTR(a_clr_err, S_IWUGO, NULL, set_a_clr_err); 2014static DEVICE_ATTR(a_clr_err, S_IWUSR, NULL, set_a_clr_err);
2016 2015
2017static struct attribute *inputs_attrs[] = { 2016static struct attribute *inputs_attrs[] = {
2018 &dev_attr_a_bus_req.attr, 2017 &dev_attr_a_bus_req.attr,
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 76f8b3556672..2dec50013528 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -201,6 +201,7 @@ static struct usb_device_id id_table_combined [] = {
201 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) }, 201 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
202 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) }, 202 { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
203 { USB_DEVICE(FTDI_VID, FTDI_R2000KU_TRUE_RNG) }, 203 { USB_DEVICE(FTDI_VID, FTDI_R2000KU_TRUE_RNG) },
204 { USB_DEVICE(FTDI_VID, FTDI_VARDAAN_PID) },
204 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) }, 205 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) },
205 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) }, 206 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) },
206 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) }, 207 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) },
@@ -696,6 +697,7 @@ static struct usb_device_id id_table_combined [] = {
696 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk }, 697 .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
697 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, 698 { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
698 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_SERIAL_VX7_PID) }, 699 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_SERIAL_VX7_PID) },
700 { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_CT29B_PID) },
699 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, 701 { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) },
700 { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) }, 702 { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) },
701 { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, 703 { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) },
@@ -794,6 +796,7 @@ static struct usb_device_id id_table_combined [] = {
794 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LOGBOOKML_PID) }, 796 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LOGBOOKML_PID) },
795 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LS_LOGBOOK_PID) }, 797 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LS_LOGBOOK_PID) },
796 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_HS_LOGBOOK_PID) }, 798 { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_HS_LOGBOOK_PID) },
799 { USB_DEVICE(FTDI_VID, FTDI_DOTEC_PID) },
797 { USB_DEVICE(QIHARDWARE_VID, MILKYMISTONE_JTAGSERIAL_PID), 800 { USB_DEVICE(QIHARDWARE_VID, MILKYMISTONE_JTAGSERIAL_PID),
798 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 801 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
799 { }, /* Optional parameter entry */ 802 { }, /* Optional parameter entry */
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 263f62551197..bf0867285481 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -114,6 +114,9 @@
114/* Lenz LI-USB Computer Interface. */ 114/* Lenz LI-USB Computer Interface. */
115#define FTDI_LENZ_LIUSB_PID 0xD780 115#define FTDI_LENZ_LIUSB_PID 0xD780
116 116
117/* Vardaan Enterprises Serial Interface VEUSB422R3 */
118#define FTDI_VARDAAN_PID 0xF070
119
117/* 120/*
118 * Xsens Technologies BV products (http://www.xsens.com). 121 * Xsens Technologies BV products (http://www.xsens.com).
119 */ 122 */
@@ -721,6 +724,7 @@
721 */ 724 */
722#define RTSYSTEMS_VID 0x2100 /* Vendor ID */ 725#define RTSYSTEMS_VID 0x2100 /* Vendor ID */
723#define RTSYSTEMS_SERIAL_VX7_PID 0x9e52 /* Serial converter for VX-7 Radios using FT232RL */ 726#define RTSYSTEMS_SERIAL_VX7_PID 0x9e52 /* Serial converter for VX-7 Radios using FT232RL */
727#define RTSYSTEMS_CT29B_PID 0x9e54 /* CT29B Radio Cable */
724 728
725/* 729/*
726 * Bayer Ascensia Contour blood glucose meter USB-converter cable. 730 * Bayer Ascensia Contour blood glucose meter USB-converter cable.
@@ -1077,6 +1081,11 @@
1077#define MJSG_HD_RADIO_PID 0x937C 1081#define MJSG_HD_RADIO_PID 0x937C
1078 1082
1079/* 1083/*
1084 * D.O.Tec products (http://www.directout.eu)
1085 */
1086#define FTDI_DOTEC_PID 0x9868
1087
1088/*
1080 * Xverve Signalyzer tools (http://www.signalyzer.com/) 1089 * Xverve Signalyzer tools (http://www.signalyzer.com/)
1081 */ 1090 */
1082#define XVERVE_SIGNALYZER_ST_PID 0xBCA0 1091#define XVERVE_SIGNALYZER_ST_PID 0xBCA0
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index e64da74bdcc5..6954de50c0ff 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -21,7 +21,6 @@
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>
25#include <linux/tty.h> 24#include <linux/tty.h>
26#include <linux/tty_driver.h> 25#include <linux/tty_driver.h>
27#include <linux/tty_flip.h> 26#include <linux/tty_flip.h>
@@ -52,6 +51,7 @@ static struct usb_driver usb_serial_driver = {
52 .suspend = usb_serial_suspend, 51 .suspend = usb_serial_suspend,
53 .resume = usb_serial_resume, 52 .resume = usb_serial_resume,
54 .no_dynamic_id = 1, 53 .no_dynamic_id = 1,
54 .supports_autosuspend = 1,
55}; 55};
56 56
57/* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead 57/* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead
@@ -1344,6 +1344,8 @@ int usb_serial_register(struct usb_serial_driver *driver)
1344 return -ENODEV; 1344 return -ENODEV;
1345 1345
1346 fixup_generic(driver); 1346 fixup_generic(driver);
1347 if (driver->usb_driver)
1348 driver->usb_driver->supports_autosuspend = 1;
1347 1349
1348 if (!driver->description) 1350 if (!driver->description)
1349 driver->description = driver->driver.name; 1351 driver->description = driver->driver.name;
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index a688b1e686ea..689ee1fb702a 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -285,7 +285,7 @@ static int slave_configure(struct scsi_device *sdev)
285 285
286/* queue a command */ 286/* queue a command */
287/* This is always called with scsi_lock(host) held */ 287/* This is always called with scsi_lock(host) held */
288static int queuecommand(struct scsi_cmnd *srb, 288static int queuecommand_lck(struct scsi_cmnd *srb,
289 void (*done)(struct scsi_cmnd *)) 289 void (*done)(struct scsi_cmnd *))
290{ 290{
291 struct us_data *us = host_to_us(srb->device->host); 291 struct us_data *us = host_to_us(srb->device->host);
@@ -315,6 +315,8 @@ static int queuecommand(struct scsi_cmnd *srb,
315 return 0; 315 return 0;
316} 316}
317 317
318static DEF_SCSI_QCMD(queuecommand)
319
318/*********************************************************************** 320/***********************************************************************
319 * Error handling functions 321 * Error handling functions
320 ***********************************************************************/ 322 ***********************************************************************/
diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c
index 57fc2f532cab..ceba512f84d0 100644
--- a/drivers/usb/storage/sierra_ms.c
+++ b/drivers/usb/storage/sierra_ms.c
@@ -121,7 +121,7 @@ static ssize_t show_truinst(struct device *dev, struct device_attribute *attr,
121 } 121 }
122 return result; 122 return result;
123} 123}
124static DEVICE_ATTR(truinst, S_IWUGO | S_IRUGO, show_truinst, NULL); 124static DEVICE_ATTR(truinst, S_IRUGO, show_truinst, NULL);
125 125
126int sierra_ms_init(struct us_data *us) 126int sierra_ms_init(struct us_data *us)
127{ 127{
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index d1268191acbd..339fac3949df 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -430,7 +430,7 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
430 return 0; 430 return 0;
431} 431}
432 432
433static int uas_queuecommand(struct scsi_cmnd *cmnd, 433static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
434 void (*done)(struct scsi_cmnd *)) 434 void (*done)(struct scsi_cmnd *))
435{ 435{
436 struct scsi_device *sdev = cmnd->device; 436 struct scsi_device *sdev = cmnd->device;
@@ -488,6 +488,8 @@ static int uas_queuecommand(struct scsi_cmnd *cmnd,
488 return 0; 488 return 0;
489} 489}
490 490
491static DEF_SCSI_QCMD(uas_queuecommand)
492
491static int uas_eh_abort_handler(struct scsi_cmnd *cmnd) 493static int uas_eh_abort_handler(struct scsi_cmnd *cmnd)
492{ 494{
493 struct scsi_device *sdev = cmnd->device; 495 struct scsi_device *sdev = cmnd->device;
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 6ccdd3dd5259..fcc1e32ce256 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -481,6 +481,13 @@ UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
481 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 481 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
482 US_FL_MAX_SECTORS_64), 482 US_FL_MAX_SECTORS_64),
483 483
484/* Reported by Vitaly Kuznetsov <vitty@altlinux.ru> */
485UNUSUAL_DEV( 0x04e8, 0x5122, 0x0000, 0x9999,
486 "Samsung",
487 "YP-CP3",
488 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
489 US_FL_MAX_SECTORS_64 | US_FL_BULK_IGNORE_TAG),
490
484/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 491/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
485 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and 492 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and
486 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011. 493 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 4b4da5b86ff9..f442668a1e52 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -129,8 +129,9 @@ static void handle_tx(struct vhost_net *net)
129 size_t hdr_size; 129 size_t hdr_size;
130 struct socket *sock; 130 struct socket *sock;
131 131
132 sock = rcu_dereference_check(vq->private_data, 132 /* TODO: check that we are running from vhost_worker?
133 lockdep_is_held(&vq->mutex)); 133 * Not sure it's worth it, it's straight-forward enough. */
134 sock = rcu_dereference_check(vq->private_data, 1);
134 if (!sock) 135 if (!sock)
135 return; 136 return;
136 137
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 94701ff3a23a..159c77a5746f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -884,6 +884,7 @@ static int log_write(void __user *log_base,
884 int r; 884 int r;
885 if (!write_length) 885 if (!write_length)
886 return 0; 886 return 0;
887 write_length += write_address % VHOST_PAGE_SIZE;
887 write_address /= VHOST_PAGE_SIZE; 888 write_address /= VHOST_PAGE_SIZE;
888 for (;;) { 889 for (;;) {
889 u64 base = (u64)(unsigned long)log_base; 890 u64 base = (u64)(unsigned long)log_base;
@@ -897,7 +898,7 @@ static int log_write(void __user *log_base,
897 if (write_length <= VHOST_PAGE_SIZE) 898 if (write_length <= VHOST_PAGE_SIZE)
898 break; 899 break;
899 write_length -= VHOST_PAGE_SIZE; 900 write_length -= VHOST_PAGE_SIZE;
900 write_address += VHOST_PAGE_SIZE; 901 write_address += 1;
901 } 902 }
902 return r; 903 return r;
903} 904}
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 37771d0916ef..9f36a29b10b4 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -186,6 +186,14 @@ config FB_SYS_FOPS
186 depends on FB 186 depends on FB
187 default n 187 default n
188 188
189config FB_WMT_GE_ROPS
190 tristate
191 depends on FB
192 default n
193 ---help---
194 Include functions for accelerated rectangle filling and area
195 copying using WonderMedia Graphics Engine operations.
196
189config FB_DEFERRED_IO 197config FB_DEFERRED_IO
190 bool 198 bool
191 depends on FB 199 depends on FB
@@ -635,6 +643,72 @@ config FB_BFIN_LQ035Q1
635 To compile this driver as a module, choose M here: the 643 To compile this driver as a module, choose M here: the
636 module will be called bfin-lq035q1-fb. 644 module will be called bfin-lq035q1-fb.
637 645
646config FB_BF537_LQ035
647 tristate "SHARP LQ035 TFT LCD (BF537 STAMP)"
648 depends on FB && (BF534 || BF536 || BF537) && I2C_BLACKFIN_TWI
649 select FB_CFB_FILLRECT
650 select FB_CFB_COPYAREA
651 select FB_CFB_IMAGEBLIT
652 select BFIN_GPTIMERS
653 help
654 This is the framebuffer device for a SHARP LQ035Q7DB03 TFT LCD
655 attached to a BF537.
656
657 To compile this driver as a module, choose M here: the
658 module will be called bf537-lq035.
659
660config FB_BFIN_7393
661 tristate "Blackfin ADV7393 Video encoder"
662 depends on FB && BLACKFIN
663 select I2C
664 select FB_CFB_FILLRECT
665 select FB_CFB_COPYAREA
666 select FB_CFB_IMAGEBLIT
667 help
668 This is the framebuffer device for a ADV7393 video encoder
669 attached to a Blackfin on the PPI port.
670 If your Blackfin board has a ADV7393 select Y.
671
672 To compile this driver as a module, choose M here: the
673 module will be called bfin_adv7393fb.
674
675choice
676 prompt "Video mode support"
677 depends on FB_BFIN_7393
678 default NTSC
679
680config NTSC
681 bool 'NTSC 720x480'
682
683config PAL
684 bool 'PAL 720x576'
685
686config NTSC_640x480
687 bool 'NTSC 640x480 (Experimental)'
688
689config PAL_640x480
690 bool 'PAL 640x480 (Experimental)'
691
692config NTSC_YCBCR
693 bool 'NTSC 720x480 YCbCR input'
694
695config PAL_YCBCR
696 bool 'PAL 720x576 YCbCR input'
697
698endchoice
699
700choice
701 prompt "Size of ADV7393 frame buffer memory Single/Double Size"
702 depends on (FB_BFIN_7393)
703 default ADV7393_1XMEM
704
705config ADV7393_1XMEM
706 bool 'Single'
707
708config ADV7393_2XMEM
709 bool 'Double'
710endchoice
711
638config FB_STI 712config FB_STI
639 tristate "HP STI frame buffer device support" 713 tristate "HP STI frame buffer device support"
640 depends on FB && PARISC 714 depends on FB && PARISC
@@ -750,24 +824,14 @@ config FB_N411
750config FB_HGA 824config FB_HGA
751 tristate "Hercules mono graphics support" 825 tristate "Hercules mono graphics support"
752 depends on FB && X86 826 depends on FB && X86
753 select FB_CFB_FILLRECT
754 select FB_CFB_COPYAREA
755 select FB_CFB_IMAGEBLIT
756 help 827 help
757 Say Y here if you have a Hercules mono graphics card. 828 Say Y here if you have a Hercules mono graphics card.
758 829
759 To compile this driver as a module, choose M here: the 830 To compile this driver as a module, choose M here: the
760 module will be called hgafb. 831 module will be called hgafb.
761 832
762 As this card technology is 15 years old, most people will answer N 833 As this card technology is at least 25 years old,
763 here. 834 most people will answer N here.
764
765config FB_HGA_ACCEL
766 bool "Hercules mono Acceleration functions (EXPERIMENTAL)"
767 depends on FB_HGA && EXPERIMENTAL
768 ---help---
769 This will compile the Hercules mono graphics with
770 acceleration functions.
771 835
772config FB_SGIVW 836config FB_SGIVW
773 tristate "SGI Visual Workstation framebuffer support" 837 tristate "SGI Visual Workstation framebuffer support"
@@ -1722,6 +1786,24 @@ config FB_AU1200
1722 various panels and CRTs by passing in kernel cmd line option 1786 various panels and CRTs by passing in kernel cmd line option
1723 au1200fb:panel=<name>. 1787 au1200fb:panel=<name>.
1724 1788
1789config FB_VT8500
1790 bool "VT8500 LCD Driver"
1791 depends on (FB = y) && ARM && ARCH_VT8500 && VTWM_VERSION_VT8500
1792 select FB_WMT_GE_ROPS
1793 select FB_SYS_IMAGEBLIT
1794 help
1795 This is the framebuffer driver for VIA VT8500 integrated LCD
1796 controller.
1797
1798config FB_WM8505
1799 bool "WM8505 frame buffer support"
1800 depends on (FB = y) && ARM && ARCH_VT8500 && VTWM_VERSION_WM8505
1801 select FB_WMT_GE_ROPS
1802 select FB_SYS_IMAGEBLIT
1803 help
1804 This is the framebuffer driver for WonderMedia WM8505
1805 integrated LCD controller.
1806
1725source "drivers/video/geode/Kconfig" 1807source "drivers/video/geode/Kconfig"
1726 1808
1727config FB_HIT 1809config FB_HIT
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 03678e3021ab..f9de51c39ad7 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_FB_SVGALIB) += svgalib.o
26obj-$(CONFIG_FB_MACMODES) += macmodes.o 26obj-$(CONFIG_FB_MACMODES) += macmodes.o
27obj-$(CONFIG_FB_DDC) += fb_ddc.o 27obj-$(CONFIG_FB_DDC) += fb_ddc.o
28obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o 28obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o
29obj-$(CONFIG_FB_WMT_GE_ROPS) += wmt_ge_rops.o
29 30
30# Hardware specific drivers go first 31# Hardware specific drivers go first
31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o 32obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o
@@ -104,6 +105,8 @@ obj-$(CONFIG_FB_W100) += w100fb.o
104obj-$(CONFIG_FB_TMIO) += tmiofb.o 105obj-$(CONFIG_FB_TMIO) += tmiofb.o
105obj-$(CONFIG_FB_AU1100) += au1100fb.o 106obj-$(CONFIG_FB_AU1100) += au1100fb.o
106obj-$(CONFIG_FB_AU1200) += au1200fb.o 107obj-$(CONFIG_FB_AU1200) += au1200fb.o
108obj-$(CONFIG_FB_VT8500) += vt8500lcdfb.o
109obj-$(CONFIG_FB_WM8505) += wm8505fb.o
107obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o 110obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o
108obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o 111obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o
109obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o 112obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o
@@ -142,9 +145,11 @@ obj-$(CONFIG_FB_VESA) += vesafb.o
142obj-$(CONFIG_FB_EFI) += efifb.o 145obj-$(CONFIG_FB_EFI) += efifb.o
143obj-$(CONFIG_FB_VGA16) += vga16fb.o 146obj-$(CONFIG_FB_VGA16) += vga16fb.o
144obj-$(CONFIG_FB_OF) += offb.o 147obj-$(CONFIG_FB_OF) += offb.o
148obj-$(CONFIG_FB_BF537_LQ035) += bf537-lq035.o
145obj-$(CONFIG_FB_BF54X_LQ043) += bf54x-lq043fb.o 149obj-$(CONFIG_FB_BF54X_LQ043) += bf54x-lq043fb.o
146obj-$(CONFIG_FB_BFIN_LQ035Q1) += bfin-lq035q1-fb.o 150obj-$(CONFIG_FB_BFIN_LQ035Q1) += bfin-lq035q1-fb.o
147obj-$(CONFIG_FB_BFIN_T350MCQB) += bfin-t350mcqb-fb.o 151obj-$(CONFIG_FB_BFIN_T350MCQB) += bfin-t350mcqb-fb.o
152obj-$(CONFIG_FB_BFIN_7393) += bfin_adv7393fb.o
148obj-$(CONFIG_FB_MX3) += mx3fb.o 153obj-$(CONFIG_FB_MX3) += mx3fb.o
149obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o 154obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o
150 155
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index e207810bba3c..08703299ef61 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -197,12 +197,12 @@ static int backlight_suspend(struct device *dev, pm_message_t state)
197{ 197{
198 struct backlight_device *bd = to_backlight_device(dev); 198 struct backlight_device *bd = to_backlight_device(dev);
199 199
200 if (bd->ops->options & BL_CORE_SUSPENDRESUME) { 200 mutex_lock(&bd->ops_lock);
201 mutex_lock(&bd->ops_lock); 201 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
202 bd->props.state |= BL_CORE_SUSPENDED; 202 bd->props.state |= BL_CORE_SUSPENDED;
203 backlight_update_status(bd); 203 backlight_update_status(bd);
204 mutex_unlock(&bd->ops_lock);
205 } 204 }
205 mutex_unlock(&bd->ops_lock);
206 206
207 return 0; 207 return 0;
208} 208}
@@ -211,12 +211,12 @@ static int backlight_resume(struct device *dev)
211{ 211{
212 struct backlight_device *bd = to_backlight_device(dev); 212 struct backlight_device *bd = to_backlight_device(dev);
213 213
214 if (bd->ops->options & BL_CORE_SUSPENDRESUME) { 214 mutex_lock(&bd->ops_lock);
215 mutex_lock(&bd->ops_lock); 215 if (bd->ops && bd->ops->options & BL_CORE_SUSPENDRESUME) {
216 bd->props.state &= ~BL_CORE_SUSPENDED; 216 bd->props.state &= ~BL_CORE_SUSPENDED;
217 backlight_update_status(bd); 217 backlight_update_status(bd);
218 mutex_unlock(&bd->ops_lock);
219 } 218 }
219 mutex_unlock(&bd->ops_lock);
220 220
221 return 0; 221 return 0;
222} 222}
diff --git a/drivers/video/bf537-lq035.c b/drivers/video/bf537-lq035.c
new file mode 100644
index 000000000000..18c507874ff1
--- /dev/null
+++ b/drivers/video/bf537-lq035.c
@@ -0,0 +1,914 @@
1/*
2 * Analog Devices Blackfin(BF537 STAMP) + SHARP TFT LCD.
3 * http://docs.blackfin.uclinux.org/doku.php?id=hw:cards:tft-lcd
4 *
5 * Copyright 2006-2010 Analog Devices Inc.
6 * Licensed under the GPL-2.
7 */
8
9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10
11#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/string.h>
15#include <linux/mm.h>
16#include <linux/delay.h>
17#include <linux/fb.h>
18#include <linux/ioport.h>
19#include <linux/init.h>
20#include <linux/types.h>
21#include <linux/gpio.h>
22#include <linux/interrupt.h>
23#include <linux/sched.h>
24#include <linux/timer.h>
25#include <linux/device.h>
26#include <linux/backlight.h>
27#include <linux/lcd.h>
28#include <linux/i2c.h>
29#include <linux/spinlock.h>
30#include <linux/dma-mapping.h>
31#include <linux/slab.h>
32#include <linux/platform_device.h>
33
34#include <asm/blackfin.h>
35#include <asm/irq.h>
36#include <asm/dpmc.h>
37#include <asm/dma.h>
38#include <asm/portmux.h>
39
40#define NO_BL 1
41
42#define MAX_BRIGHENESS 95
43#define MIN_BRIGHENESS 5
44#define NBR_PALETTE 256
45
46static const unsigned short ppi_pins[] = {
47 P_PPI0_CLK, P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
48 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
49 P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, P_PPI0_D11,
50 P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15, 0
51};
52
53static unsigned char *fb_buffer; /* RGB Buffer */
54static unsigned long *dma_desc_table;
55static int t_conf_done, lq035_open_cnt;
56static DEFINE_SPINLOCK(bfin_lq035_lock);
57
58static int landscape;
59module_param(landscape, int, 0);
60MODULE_PARM_DESC(landscape,
61 "LANDSCAPE use 320x240 instead of Native 240x320 Resolution");
62
63static int bgr;
64module_param(bgr, int, 0);
65MODULE_PARM_DESC(bgr,
66 "BGR use 16-bit BGR-565 instead of RGB-565");
67
68static int nocursor = 1;
69module_param(nocursor, int, 0644);
70MODULE_PARM_DESC(nocursor, "cursor enable/disable");
71
72static unsigned long current_brightness; /* backlight */
73
74/* AD5280 vcomm */
75static unsigned char vcomm_value = 150;
76static struct i2c_client *ad5280_client;
77
78static void set_vcomm(void)
79{
80 int nr;
81
82 if (!ad5280_client)
83 return;
84
85 nr = i2c_smbus_write_byte_data(ad5280_client, 0x00, vcomm_value);
86 if (nr)
87 pr_err("i2c_smbus_write_byte_data fail: %d\n", nr);
88}
89
90static int __devinit ad5280_probe(struct i2c_client *client,
91 const struct i2c_device_id *id)
92{
93 int ret;
94 if (!i2c_check_functionality(client->adapter,
95 I2C_FUNC_SMBUS_BYTE_DATA)) {
96 dev_err(&client->dev, "SMBUS Byte Data not Supported\n");
97 return -EIO;
98 }
99
100 ret = i2c_smbus_write_byte_data(client, 0x00, vcomm_value);
101 if (ret) {
102 dev_err(&client->dev, "write fail: %d\n", ret);
103 return ret;
104 }
105
106 ad5280_client = client;
107
108 return 0;
109}
110
111static int __devexit ad5280_remove(struct i2c_client *client)
112{
113 ad5280_client = NULL;
114 return 0;
115}
116
117static const struct i2c_device_id ad5280_id[] = {
118 {"bf537-lq035-ad5280", 0},
119 {}
120};
121
122MODULE_DEVICE_TABLE(i2c, ad5280_id);
123
124static struct i2c_driver ad5280_driver = {
125 .driver = {
126 .name = "bf537-lq035-ad5280",
127 },
128 .probe = ad5280_probe,
129 .remove = __devexit_p(ad5280_remove),
130 .id_table = ad5280_id,
131};
132
133#ifdef CONFIG_PNAV10
134#define MOD GPIO_PH13
135
136#define bfin_write_TIMER_LP_CONFIG bfin_write_TIMER0_CONFIG
137#define bfin_write_TIMER_LP_WIDTH bfin_write_TIMER0_WIDTH
138#define bfin_write_TIMER_LP_PERIOD bfin_write_TIMER0_PERIOD
139#define bfin_read_TIMER_LP_COUNTER bfin_read_TIMER0_COUNTER
140#define TIMDIS_LP TIMDIS0
141#define TIMEN_LP TIMEN0
142
143#define bfin_write_TIMER_SPS_CONFIG bfin_write_TIMER1_CONFIG
144#define bfin_write_TIMER_SPS_WIDTH bfin_write_TIMER1_WIDTH
145#define bfin_write_TIMER_SPS_PERIOD bfin_write_TIMER1_PERIOD
146#define TIMDIS_SPS TIMDIS1
147#define TIMEN_SPS TIMEN1
148
149#define bfin_write_TIMER_SP_CONFIG bfin_write_TIMER5_CONFIG
150#define bfin_write_TIMER_SP_WIDTH bfin_write_TIMER5_WIDTH
151#define bfin_write_TIMER_SP_PERIOD bfin_write_TIMER5_PERIOD
152#define TIMDIS_SP TIMDIS5
153#define TIMEN_SP TIMEN5
154
155#define bfin_write_TIMER_PS_CLS_CONFIG bfin_write_TIMER2_CONFIG
156#define bfin_write_TIMER_PS_CLS_WIDTH bfin_write_TIMER2_WIDTH
157#define bfin_write_TIMER_PS_CLS_PERIOD bfin_write_TIMER2_PERIOD
158#define TIMDIS_PS_CLS TIMDIS2
159#define TIMEN_PS_CLS TIMEN2
160
161#define bfin_write_TIMER_REV_CONFIG bfin_write_TIMER3_CONFIG
162#define bfin_write_TIMER_REV_WIDTH bfin_write_TIMER3_WIDTH
163#define bfin_write_TIMER_REV_PERIOD bfin_write_TIMER3_PERIOD
164#define TIMDIS_REV TIMDIS3
165#define TIMEN_REV TIMEN3
166#define bfin_read_TIMER_REV_COUNTER bfin_read_TIMER3_COUNTER
167
168#define FREQ_PPI_CLK (5*1024*1024) /* PPI_CLK 5MHz */
169
170#define TIMERS {P_TMR0, P_TMR1, P_TMR2, P_TMR3, P_TMR5, 0}
171
172#else
173
174#define UD GPIO_PF13 /* Up / Down */
175#define MOD GPIO_PF10
176#define LBR GPIO_PF14 /* Left Right */
177
178#define bfin_write_TIMER_LP_CONFIG bfin_write_TIMER6_CONFIG
179#define bfin_write_TIMER_LP_WIDTH bfin_write_TIMER6_WIDTH
180#define bfin_write_TIMER_LP_PERIOD bfin_write_TIMER6_PERIOD
181#define bfin_read_TIMER_LP_COUNTER bfin_read_TIMER6_COUNTER
182#define TIMDIS_LP TIMDIS6
183#define TIMEN_LP TIMEN6
184
185#define bfin_write_TIMER_SPS_CONFIG bfin_write_TIMER1_CONFIG
186#define bfin_write_TIMER_SPS_WIDTH bfin_write_TIMER1_WIDTH
187#define bfin_write_TIMER_SPS_PERIOD bfin_write_TIMER1_PERIOD
188#define TIMDIS_SPS TIMDIS1
189#define TIMEN_SPS TIMEN1
190
191#define bfin_write_TIMER_SP_CONFIG bfin_write_TIMER0_CONFIG
192#define bfin_write_TIMER_SP_WIDTH bfin_write_TIMER0_WIDTH
193#define bfin_write_TIMER_SP_PERIOD bfin_write_TIMER0_PERIOD
194#define TIMDIS_SP TIMDIS0
195#define TIMEN_SP TIMEN0
196
197#define bfin_write_TIMER_PS_CLS_CONFIG bfin_write_TIMER7_CONFIG
198#define bfin_write_TIMER_PS_CLS_WIDTH bfin_write_TIMER7_WIDTH
199#define bfin_write_TIMER_PS_CLS_PERIOD bfin_write_TIMER7_PERIOD
200#define TIMDIS_PS_CLS TIMDIS7
201#define TIMEN_PS_CLS TIMEN7
202
203#define bfin_write_TIMER_REV_CONFIG bfin_write_TIMER5_CONFIG
204#define bfin_write_TIMER_REV_WIDTH bfin_write_TIMER5_WIDTH
205#define bfin_write_TIMER_REV_PERIOD bfin_write_TIMER5_PERIOD
206#define TIMDIS_REV TIMDIS5
207#define TIMEN_REV TIMEN5
208#define bfin_read_TIMER_REV_COUNTER bfin_read_TIMER5_COUNTER
209
210#define FREQ_PPI_CLK (6*1000*1000) /* PPI_CLK 6MHz */
211#define TIMERS {P_TMR0, P_TMR1, P_TMR5, P_TMR6, P_TMR7, 0}
212
213#endif
214
215#define LCD_X_RES 240 /* Horizontal Resolution */
216#define LCD_Y_RES 320 /* Vertical Resolution */
217
218#define LCD_BBP 16 /* Bit Per Pixel */
219
220/* the LCD and the DMA start counting differently;
221 * since one starts at 0 and the other starts at 1,
222 * we have a difference of 1 between START_LINES
223 * and U_LINES.
224 */
225#define START_LINES 8 /* lines for field flyback or field blanking signal */
226#define U_LINES 9 /* number of undisplayed blanking lines */
227
228#define FRAMES_PER_SEC (60)
229
230#define DCLKS_PER_FRAME (FREQ_PPI_CLK/FRAMES_PER_SEC)
231#define DCLKS_PER_LINE (DCLKS_PER_FRAME/(LCD_Y_RES+U_LINES))
232
233#define PPI_CONFIG_VALUE (PORT_DIR|XFR_TYPE|DLEN_16|POLS)
234#define PPI_DELAY_VALUE (0)
235#define TIMER_CONFIG (PWM_OUT|PERIOD_CNT|TIN_SEL|CLK_SEL)
236
237#define ACTIVE_VIDEO_MEM_OFFSET (LCD_X_RES*START_LINES*(LCD_BBP/8))
238#define ACTIVE_VIDEO_MEM_SIZE (LCD_Y_RES*LCD_X_RES*(LCD_BBP/8))
239#define TOTAL_VIDEO_MEM_SIZE ((LCD_Y_RES+U_LINES)*LCD_X_RES*(LCD_BBP/8))
240#define TOTAL_DMA_DESC_SIZE (2 * sizeof(u32) * (LCD_Y_RES + U_LINES))
241
242static void start_timers(void) /* CHECK with HW */
243{
244 unsigned long flags;
245
246 local_irq_save(flags);
247
248 bfin_write_TIMER_ENABLE(TIMEN_REV);
249 SSYNC();
250
251 while (bfin_read_TIMER_REV_COUNTER() <= 11)
252 continue;
253 bfin_write_TIMER_ENABLE(TIMEN_LP);
254 SSYNC();
255
256 while (bfin_read_TIMER_LP_COUNTER() < 3)
257 continue;
258 bfin_write_TIMER_ENABLE(TIMEN_SP|TIMEN_SPS|TIMEN_PS_CLS);
259 SSYNC();
260 t_conf_done = 1;
261 local_irq_restore(flags);
262}
263
264static void config_timers(void)
265{
266 /* Stop timers */
267 bfin_write_TIMER_DISABLE(TIMDIS_SP|TIMDIS_SPS|TIMDIS_REV|
268 TIMDIS_LP|TIMDIS_PS_CLS);
269 SSYNC();
270
271 /* LP, timer 6 */
272 bfin_write_TIMER_LP_CONFIG(TIMER_CONFIG|PULSE_HI);
273 bfin_write_TIMER_LP_WIDTH(1);
274
275 bfin_write_TIMER_LP_PERIOD(DCLKS_PER_LINE);
276 SSYNC();
277
278 /* SPS, timer 1 */
279 bfin_write_TIMER_SPS_CONFIG(TIMER_CONFIG|PULSE_HI);
280 bfin_write_TIMER_SPS_WIDTH(DCLKS_PER_LINE*2);
281 bfin_write_TIMER_SPS_PERIOD((DCLKS_PER_LINE * (LCD_Y_RES+U_LINES)));
282 SSYNC();
283
284 /* SP, timer 0 */
285 bfin_write_TIMER_SP_CONFIG(TIMER_CONFIG|PULSE_HI);
286 bfin_write_TIMER_SP_WIDTH(1);
287 bfin_write_TIMER_SP_PERIOD(DCLKS_PER_LINE);
288 SSYNC();
289
290 /* PS & CLS, timer 7 */
291 bfin_write_TIMER_PS_CLS_CONFIG(TIMER_CONFIG);
292 bfin_write_TIMER_PS_CLS_WIDTH(LCD_X_RES + START_LINES);
293 bfin_write_TIMER_PS_CLS_PERIOD(DCLKS_PER_LINE);
294
295 SSYNC();
296
297#ifdef NO_BL
298 /* REV, timer 5 */
299 bfin_write_TIMER_REV_CONFIG(TIMER_CONFIG|PULSE_HI);
300
301 bfin_write_TIMER_REV_WIDTH(DCLKS_PER_LINE);
302 bfin_write_TIMER_REV_PERIOD(DCLKS_PER_LINE*2);
303
304 SSYNC();
305#endif
306}
307
308static void config_ppi(void)
309{
310 bfin_write_PPI_DELAY(PPI_DELAY_VALUE);
311 bfin_write_PPI_COUNT(LCD_X_RES-1);
312 /* 0x10 -> PORT_CFG -> 2 or 3 frame syncs */
313 bfin_write_PPI_CONTROL((PPI_CONFIG_VALUE|0x10) & (~POLS));
314}
315
316static int config_dma(void)
317{
318 u32 i;
319
320 if (landscape) {
321
322 for (i = 0; i < U_LINES; ++i) {
323 /* blanking lines point to first line of fb_buffer */
324 dma_desc_table[2*i] = (unsigned long)&dma_desc_table[2*i+2];
325 dma_desc_table[2*i+1] = (unsigned long)fb_buffer;
326 }
327
328 for (i = U_LINES; i < U_LINES + LCD_Y_RES; ++i) {
329 /* visible lines */
330 dma_desc_table[2*i] = (unsigned long)&dma_desc_table[2*i+2];
331 dma_desc_table[2*i+1] = (unsigned long)fb_buffer +
332 (LCD_Y_RES+U_LINES-1-i)*2;
333 }
334
335 /* last descriptor points to first */
336 dma_desc_table[2*(LCD_Y_RES+U_LINES-1)] = (unsigned long)&dma_desc_table[0];
337
338 set_dma_x_count(CH_PPI, LCD_X_RES);
339 set_dma_x_modify(CH_PPI, LCD_Y_RES * (LCD_BBP / 8));
340 set_dma_y_count(CH_PPI, 0);
341 set_dma_y_modify(CH_PPI, 0);
342 set_dma_next_desc_addr(CH_PPI, (void *)dma_desc_table[0]);
343 set_dma_config(CH_PPI, DMAFLOW_LARGE | NDSIZE_4 | WDSIZE_16);
344
345 } else {
346
347 set_dma_config(CH_PPI, set_bfin_dma_config(DIR_READ,
348 DMA_FLOW_AUTO,
349 INTR_DISABLE,
350 DIMENSION_2D,
351 DATA_SIZE_16,
352 DMA_NOSYNC_KEEP_DMA_BUF));
353 set_dma_x_count(CH_PPI, LCD_X_RES);
354 set_dma_x_modify(CH_PPI, LCD_BBP / 8);
355 set_dma_y_count(CH_PPI, LCD_Y_RES+U_LINES);
356 set_dma_y_modify(CH_PPI, LCD_BBP / 8);
357 set_dma_start_addr(CH_PPI, (unsigned long) fb_buffer);
358 }
359
360 return 0;
361}
362
363static int __devinit request_ports(void)
364{
365 u16 tmr_req[] = TIMERS;
366
367 /*
368 UD: PF13
369 MOD: PF10
370 LBR: PF14
371 PPI_CLK: PF15
372 */
373
374 if (peripheral_request_list(ppi_pins, KBUILD_MODNAME)) {
375 pr_err("requesting PPI peripheral failed\n");
376 return -EBUSY;
377 }
378
379 if (peripheral_request_list(tmr_req, KBUILD_MODNAME)) {
380 peripheral_free_list(ppi_pins);
381 pr_err("requesting timer peripheral failed\n");
382 return -EBUSY;
383 }
384
385#if (defined(UD) && defined(LBR))
386 if (gpio_request(UD, KBUILD_MODNAME)) {
387 pr_err("requesting GPIO %d failed\n", UD);
388 return -EBUSY;
389 }
390
391 if (gpio_request(LBR, KBUILD_MODNAME)) {
392 pr_err("requesting GPIO %d failed\n", LBR);
393 gpio_free(UD);
394 return -EBUSY;
395 }
396
397 gpio_direction_output(UD, 0);
398 gpio_direction_output(LBR, 1);
399
400#endif
401
402 if (gpio_request(MOD, KBUILD_MODNAME)) {
403 pr_err("requesting GPIO %d failed\n", MOD);
404#if (defined(UD) && defined(LBR))
405 gpio_free(LBR);
406 gpio_free(UD);
407#endif
408 return -EBUSY;
409 }
410
411 gpio_direction_output(MOD, 1);
412
413 SSYNC();
414 return 0;
415}
416
417static void free_ports(void)
418{
419 u16 tmr_req[] = TIMERS;
420
421 peripheral_free_list(ppi_pins);
422 peripheral_free_list(tmr_req);
423
424#if defined(UD) && defined(LBR)
425 gpio_free(LBR);
426 gpio_free(UD);
427#endif
428 gpio_free(MOD);
429}
430
431static struct fb_info bfin_lq035_fb;
432
433static struct fb_var_screeninfo bfin_lq035_fb_defined = {
434 .bits_per_pixel = LCD_BBP,
435 .activate = FB_ACTIVATE_TEST,
436 .xres = LCD_X_RES, /*default portrait mode RGB*/
437 .yres = LCD_Y_RES,
438 .xres_virtual = LCD_X_RES,
439 .yres_virtual = LCD_Y_RES,
440 .height = -1,
441 .width = -1,
442 .left_margin = 0,
443 .right_margin = 0,
444 .upper_margin = 0,
445 .lower_margin = 0,
446 .red = {11, 5, 0},
447 .green = {5, 6, 0},
448 .blue = {0, 5, 0},
449 .transp = {0, 0, 0},
450};
451
452static struct fb_fix_screeninfo bfin_lq035_fb_fix __devinitdata = {
453 .id = KBUILD_MODNAME,
454 .smem_len = ACTIVE_VIDEO_MEM_SIZE,
455 .type = FB_TYPE_PACKED_PIXELS,
456 .visual = FB_VISUAL_TRUECOLOR,
457 .xpanstep = 0,
458 .ypanstep = 0,
459 .line_length = LCD_X_RES*(LCD_BBP/8),
460 .accel = FB_ACCEL_NONE,
461};
462
463
464static int bfin_lq035_fb_open(struct fb_info *info, int user)
465{
466 unsigned long flags;
467
468 spin_lock_irqsave(&bfin_lq035_lock, flags);
469 lq035_open_cnt++;
470 spin_unlock_irqrestore(&bfin_lq035_lock, flags);
471
472 if (lq035_open_cnt <= 1) {
473 bfin_write_PPI_CONTROL(0);
474 SSYNC();
475
476 set_vcomm();
477 config_dma();
478 config_ppi();
479
480 /* start dma */
481 enable_dma(CH_PPI);
482 SSYNC();
483 bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() | PORT_EN);
484 SSYNC();
485
486 if (!t_conf_done) {
487 config_timers();
488 start_timers();
489 }
490 /* gpio_set_value(MOD,1); */
491 }
492
493 return 0;
494}
495
496static int bfin_lq035_fb_release(struct fb_info *info, int user)
497{
498 unsigned long flags;
499
500 spin_lock_irqsave(&bfin_lq035_lock, flags);
501 lq035_open_cnt--;
502 spin_unlock_irqrestore(&bfin_lq035_lock, flags);
503
504
505 if (lq035_open_cnt <= 0) {
506
507 bfin_write_PPI_CONTROL(0);
508 SSYNC();
509
510 disable_dma(CH_PPI);
511 }
512
513 return 0;
514}
515
516
517static int bfin_lq035_fb_check_var(struct fb_var_screeninfo *var,
518 struct fb_info *info)
519{
520 switch (var->bits_per_pixel) {
521 case 16:/* DIRECTCOLOUR, 64k */
522 var->red.offset = info->var.red.offset;
523 var->green.offset = info->var.green.offset;
524 var->blue.offset = info->var.blue.offset;
525 var->red.length = info->var.red.length;
526 var->green.length = info->var.green.length;
527 var->blue.length = info->var.blue.length;
528 var->transp.offset = 0;
529 var->transp.length = 0;
530 var->transp.msb_right = 0;
531 var->red.msb_right = 0;
532 var->green.msb_right = 0;
533 var->blue.msb_right = 0;
534 break;
535 default:
536 pr_debug("%s: depth not supported: %u BPP\n", __func__,
537 var->bits_per_pixel);
538 return -EINVAL;
539 }
540
541 if (info->var.xres != var->xres ||
542 info->var.yres != var->yres ||
543 info->var.xres_virtual != var->xres_virtual ||
544 info->var.yres_virtual != var->yres_virtual) {
545 pr_debug("%s: Resolution not supported: X%u x Y%u\n",
546 __func__, var->xres, var->yres);
547 return -EINVAL;
548 }
549
550 /*
551 * Memory limit
552 */
553
554 if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) {
555 pr_debug("%s: Memory Limit requested yres_virtual = %u\n",
556 __func__, var->yres_virtual);
557 return -ENOMEM;
558 }
559
560 return 0;
561}
562
563/* fb_rotate
564 * Rotate the display of this angle. This doesn't seems to be used by the core,
565 * but as our hardware supports it, so why not implementing it...
566 */
567static void bfin_lq035_fb_rotate(struct fb_info *fbi, int angle)
568{
569 pr_debug("%s: %p %d", __func__, fbi, angle);
570#if (defined(UD) && defined(LBR))
571 switch (angle) {
572
573 case 180:
574 gpio_set_value(LBR, 0);
575 gpio_set_value(UD, 1);
576 break;
577 default:
578 gpio_set_value(LBR, 1);
579 gpio_set_value(UD, 0);
580 break;
581 }
582#endif
583}
584
585static int bfin_lq035_fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
586{
587 if (nocursor)
588 return 0;
589 else
590 return -EINVAL; /* just to force soft_cursor() call */
591}
592
593static int bfin_lq035_fb_setcolreg(u_int regno, u_int red, u_int green,
594 u_int blue, u_int transp,
595 struct fb_info *info)
596{
597 if (regno >= NBR_PALETTE)
598 return -EINVAL;
599
600 if (info->var.grayscale)
601 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
602 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
603
604 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
605
606 u32 value;
607 /* Place color in the pseudopalette */
608 if (regno > 16)
609 return -EINVAL;
610
611 red >>= (16 - info->var.red.length);
612 green >>= (16 - info->var.green.length);
613 blue >>= (16 - info->var.blue.length);
614
615 value = (red << info->var.red.offset) |
616 (green << info->var.green.offset)|
617 (blue << info->var.blue.offset);
618 value &= 0xFFFF;
619
620 ((u32 *) (info->pseudo_palette))[regno] = value;
621
622 }
623
624 return 0;
625}
626
627static struct fb_ops bfin_lq035_fb_ops = {
628 .owner = THIS_MODULE,
629 .fb_open = bfin_lq035_fb_open,
630 .fb_release = bfin_lq035_fb_release,
631 .fb_check_var = bfin_lq035_fb_check_var,
632 .fb_rotate = bfin_lq035_fb_rotate,
633 .fb_fillrect = cfb_fillrect,
634 .fb_copyarea = cfb_copyarea,
635 .fb_imageblit = cfb_imageblit,
636 .fb_cursor = bfin_lq035_fb_cursor,
637 .fb_setcolreg = bfin_lq035_fb_setcolreg,
638};
639
640static int bl_get_brightness(struct backlight_device *bd)
641{
642 return current_brightness;
643}
644
645static const struct backlight_ops bfin_lq035fb_bl_ops = {
646 .get_brightness = bl_get_brightness,
647};
648
649static struct backlight_device *bl_dev;
650
651static int bfin_lcd_get_power(struct lcd_device *dev)
652{
653 return 0;
654}
655
656static int bfin_lcd_set_power(struct lcd_device *dev, int power)
657{
658 return 0;
659}
660
661static int bfin_lcd_get_contrast(struct lcd_device *dev)
662{
663 return (int)vcomm_value;
664}
665
666static int bfin_lcd_set_contrast(struct lcd_device *dev, int contrast)
667{
668 if (contrast > 255)
669 contrast = 255;
670 if (contrast < 0)
671 contrast = 0;
672
673 vcomm_value = (unsigned char)contrast;
674 set_vcomm();
675 return 0;
676}
677
678static int bfin_lcd_check_fb(struct lcd_device *lcd, struct fb_info *fi)
679{
680 if (!fi || (fi == &bfin_lq035_fb))
681 return 1;
682 return 0;
683}
684
685static struct lcd_ops bfin_lcd_ops = {
686 .get_power = bfin_lcd_get_power,
687 .set_power = bfin_lcd_set_power,
688 .get_contrast = bfin_lcd_get_contrast,
689 .set_contrast = bfin_lcd_set_contrast,
690 .check_fb = bfin_lcd_check_fb,
691};
692
693static struct lcd_device *lcd_dev;
694
695static int __devinit bfin_lq035_probe(struct platform_device *pdev)
696{
697 struct backlight_properties props;
698 dma_addr_t dma_handle;
699
700 if (request_dma(CH_PPI, KBUILD_MODNAME)) {
701 pr_err("couldn't request PPI DMA\n");
702 return -EFAULT;
703 }
704
705 if (request_ports()) {
706 pr_err("couldn't request gpio port\n");
707 free_dma(CH_PPI);
708 return -EFAULT;
709 }
710
711 fb_buffer = dma_alloc_coherent(NULL, TOTAL_VIDEO_MEM_SIZE,
712 &dma_handle, GFP_KERNEL);
713 if (fb_buffer == NULL) {
714 pr_err("couldn't allocate dma buffer\n");
715 free_dma(CH_PPI);
716 free_ports();
717 return -ENOMEM;
718 }
719
720 if (L1_DATA_A_LENGTH)
721 dma_desc_table = l1_data_sram_zalloc(TOTAL_DMA_DESC_SIZE);
722 else
723 dma_desc_table = dma_alloc_coherent(NULL, TOTAL_DMA_DESC_SIZE,
724 &dma_handle, 0);
725
726 if (dma_desc_table == NULL) {
727 pr_err("couldn't allocate dma descriptor\n");
728 free_dma(CH_PPI);
729 free_ports();
730 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
731 return -ENOMEM;
732 }
733
734 bfin_lq035_fb.screen_base = (void *)fb_buffer;
735 bfin_lq035_fb_fix.smem_start = (int)fb_buffer;
736 if (landscape) {
737 bfin_lq035_fb_defined.xres = LCD_Y_RES;
738 bfin_lq035_fb_defined.yres = LCD_X_RES;
739 bfin_lq035_fb_defined.xres_virtual = LCD_Y_RES;
740 bfin_lq035_fb_defined.yres_virtual = LCD_X_RES;
741
742 bfin_lq035_fb_fix.line_length = LCD_Y_RES*(LCD_BBP/8);
743 } else {
744 bfin_lq035_fb.screen_base += ACTIVE_VIDEO_MEM_OFFSET;
745 bfin_lq035_fb_fix.smem_start += ACTIVE_VIDEO_MEM_OFFSET;
746 }
747
748 bfin_lq035_fb_defined.green.msb_right = 0;
749 bfin_lq035_fb_defined.red.msb_right = 0;
750 bfin_lq035_fb_defined.blue.msb_right = 0;
751 bfin_lq035_fb_defined.green.offset = 5;
752 bfin_lq035_fb_defined.green.length = 6;
753 bfin_lq035_fb_defined.red.length = 5;
754 bfin_lq035_fb_defined.blue.length = 5;
755
756 if (bgr) {
757 bfin_lq035_fb_defined.red.offset = 0;
758 bfin_lq035_fb_defined.blue.offset = 11;
759 } else {
760 bfin_lq035_fb_defined.red.offset = 11;
761 bfin_lq035_fb_defined.blue.offset = 0;
762 }
763
764 bfin_lq035_fb.fbops = &bfin_lq035_fb_ops;
765 bfin_lq035_fb.var = bfin_lq035_fb_defined;
766
767 bfin_lq035_fb.fix = bfin_lq035_fb_fix;
768 bfin_lq035_fb.flags = FBINFO_DEFAULT;
769
770
771 bfin_lq035_fb.pseudo_palette = kzalloc(sizeof(u32) * 16, GFP_KERNEL);
772 if (bfin_lq035_fb.pseudo_palette == NULL) {
773 pr_err("failed to allocate pseudo_palette\n");
774 free_dma(CH_PPI);
775 free_ports();
776 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
777 return -ENOMEM;
778 }
779
780 if (fb_alloc_cmap(&bfin_lq035_fb.cmap, NBR_PALETTE, 0) < 0) {
781 pr_err("failed to allocate colormap (%d entries)\n",
782 NBR_PALETTE);
783 free_dma(CH_PPI);
784 free_ports();
785 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
786 kfree(bfin_lq035_fb.pseudo_palette);
787 return -EFAULT;
788 }
789
790 if (register_framebuffer(&bfin_lq035_fb) < 0) {
791 pr_err("unable to register framebuffer\n");
792 free_dma(CH_PPI);
793 free_ports();
794 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
795 fb_buffer = NULL;
796 kfree(bfin_lq035_fb.pseudo_palette);
797 fb_dealloc_cmap(&bfin_lq035_fb.cmap);
798 return -EINVAL;
799 }
800
801 i2c_add_driver(&ad5280_driver);
802
803 memset(&props, 0, sizeof(props));
804 props.max_brightness = MAX_BRIGHENESS;
805 bl_dev = backlight_device_register("bf537-bl", NULL, NULL,
806 &bfin_lq035fb_bl_ops, &props);
807
808 lcd_dev = lcd_device_register(KBUILD_MODNAME, &pdev->dev, NULL,
809 &bfin_lcd_ops);
810 lcd_dev->props.max_contrast = 255,
811
812 pr_info("initialized");
813
814 return 0;
815}
816
817static int __devexit bfin_lq035_remove(struct platform_device *pdev)
818{
819 if (fb_buffer != NULL)
820 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
821
822 if (L1_DATA_A_LENGTH)
823 l1_data_sram_free(dma_desc_table);
824 else
825 dma_free_coherent(NULL, TOTAL_DMA_DESC_SIZE, NULL, 0);
826
827 bfin_write_TIMER_DISABLE(TIMEN_SP|TIMEN_SPS|TIMEN_PS_CLS|
828 TIMEN_LP|TIMEN_REV);
829 t_conf_done = 0;
830
831 free_dma(CH_PPI);
832
833
834 kfree(bfin_lq035_fb.pseudo_palette);
835 fb_dealloc_cmap(&bfin_lq035_fb.cmap);
836
837
838 lcd_device_unregister(lcd_dev);
839 backlight_device_unregister(bl_dev);
840
841 unregister_framebuffer(&bfin_lq035_fb);
842 i2c_del_driver(&ad5280_driver);
843
844 free_ports();
845
846 pr_info("unregistered LCD driver\n");
847
848 return 0;
849}
850
851#ifdef CONFIG_PM
852static int bfin_lq035_suspend(struct platform_device *pdev, pm_message_t state)
853{
854 if (lq035_open_cnt > 0) {
855 bfin_write_PPI_CONTROL(0);
856 SSYNC();
857 disable_dma(CH_PPI);
858 }
859
860 return 0;
861}
862
863static int bfin_lq035_resume(struct platform_device *pdev)
864{
865 if (lq035_open_cnt > 0) {
866 bfin_write_PPI_CONTROL(0);
867 SSYNC();
868
869 config_dma();
870 config_ppi();
871
872 enable_dma(CH_PPI);
873 bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() | PORT_EN);
874 SSYNC();
875
876 config_timers();
877 start_timers();
878 } else {
879 t_conf_done = 0;
880 }
881
882 return 0;
883}
884#else
885# define bfin_lq035_suspend NULL
886# define bfin_lq035_resume NULL
887#endif
888
889static struct platform_driver bfin_lq035_driver = {
890 .probe = bfin_lq035_probe,
891 .remove = __devexit_p(bfin_lq035_remove),
892 .suspend = bfin_lq035_suspend,
893 .resume = bfin_lq035_resume,
894 .driver = {
895 .name = KBUILD_MODNAME,
896 .owner = THIS_MODULE,
897 },
898};
899
900static int __init bfin_lq035_driver_init(void)
901{
902 request_module("i2c-bfin-twi");
903 return platform_driver_register(&bfin_lq035_driver);
904}
905module_init(bfin_lq035_driver_init);
906
907static void __exit bfin_lq035_driver_cleanup(void)
908{
909 platform_driver_unregister(&bfin_lq035_driver);
910}
911module_exit(bfin_lq035_driver_cleanup);
912
913MODULE_DESCRIPTION("SHARP LQ035Q7DB03 TFT LCD Driver");
914MODULE_LICENSE("GPL");
diff --git a/drivers/video/bfin_adv7393fb.c b/drivers/video/bfin_adv7393fb.c
new file mode 100644
index 000000000000..8486f541156b
--- /dev/null
+++ b/drivers/video/bfin_adv7393fb.c
@@ -0,0 +1,832 @@
1/*
2 * Frame buffer driver for ADV7393/2 video encoder
3 *
4 * Copyright 2006-2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or late.
6 */
7
8/*
9 * TODO: Remove Globals
10 * TODO: Code Cleanup
11 */
12
13#define pr_fmt(fmt) DRIVER_NAME ": " fmt
14
15#include <linux/module.h>
16#include <linux/kernel.h>
17#include <linux/errno.h>
18#include <linux/string.h>
19#include <linux/mm.h>
20#include <linux/tty.h>
21#include <linux/slab.h>
22#include <linux/delay.h>
23#include <linux/fb.h>
24#include <linux/ioport.h>
25#include <linux/init.h>
26#include <linux/types.h>
27#include <linux/interrupt.h>
28#include <linux/sched.h>
29#include <asm/blackfin.h>
30#include <asm/irq.h>
31#include <asm/dma.h>
32#include <linux/uaccess.h>
33#include <linux/gpio.h>
34#include <asm/portmux.h>
35
36#include <linux/dma-mapping.h>
37#include <linux/proc_fs.h>
38#include <linux/platform_device.h>
39
40#include <linux/i2c.h>
41#include <linux/i2c-dev.h>
42
43#include "bfin_adv7393fb.h"
44
45static int mode = VMODE;
46static int mem = VMEM;
47static int nocursor = 1;
48
49static const unsigned short ppi_pins[] = {
50 P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
51 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
52 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
53 P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, P_PPI0_D11,
54 P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15,
55 0
56};
57
58/*
59 * card parameters
60 */
61
62static struct bfin_adv7393_fb_par {
63 /* structure holding blackfin / adv7393 paramters when
64 screen is blanked */
65 struct {
66 u8 Mode; /* ntsc/pal/? */
67 } vga_state;
68 atomic_t ref_count;
69} bfin_par;
70
71/* --------------------------------------------------------------------- */
72
73static struct fb_var_screeninfo bfin_adv7393_fb_defined = {
74 .xres = 720,
75 .yres = 480,
76 .xres_virtual = 720,
77 .yres_virtual = 480,
78 .bits_per_pixel = 16,
79 .activate = FB_ACTIVATE_TEST,
80 .height = -1,
81 .width = -1,
82 .left_margin = 0,
83 .right_margin = 0,
84 .upper_margin = 0,
85 .lower_margin = 0,
86 .vmode = FB_VMODE_INTERLACED,
87 .red = {11, 5, 0},
88 .green = {5, 6, 0},
89 .blue = {0, 5, 0},
90 .transp = {0, 0, 0},
91};
92
93static struct fb_fix_screeninfo bfin_adv7393_fb_fix __devinitdata = {
94 .id = "BFIN ADV7393",
95 .smem_len = 720 * 480 * 2,
96 .type = FB_TYPE_PACKED_PIXELS,
97 .visual = FB_VISUAL_TRUECOLOR,
98 .xpanstep = 0,
99 .ypanstep = 0,
100 .line_length = 720 * 2,
101 .accel = FB_ACCEL_NONE
102};
103
104static struct fb_ops bfin_adv7393_fb_ops = {
105 .owner = THIS_MODULE,
106 .fb_open = bfin_adv7393_fb_open,
107 .fb_release = bfin_adv7393_fb_release,
108 .fb_check_var = bfin_adv7393_fb_check_var,
109 .fb_pan_display = bfin_adv7393_fb_pan_display,
110 .fb_blank = bfin_adv7393_fb_blank,
111 .fb_fillrect = cfb_fillrect,
112 .fb_copyarea = cfb_copyarea,
113 .fb_imageblit = cfb_imageblit,
114 .fb_cursor = bfin_adv7393_fb_cursor,
115 .fb_setcolreg = bfin_adv7393_fb_setcolreg,
116};
117
118static int dma_desc_list(struct adv7393fb_device *fbdev, u16 arg)
119{
120 if (arg == BUILD) { /* Build */
121 fbdev->vb1 = l1_data_sram_zalloc(sizeof(struct dmasg));
122 if (fbdev->vb1 == NULL)
123 goto error;
124
125 fbdev->av1 = l1_data_sram_zalloc(sizeof(struct dmasg));
126 if (fbdev->av1 == NULL)
127 goto error;
128
129 fbdev->vb2 = l1_data_sram_zalloc(sizeof(struct dmasg));
130 if (fbdev->vb2 == NULL)
131 goto error;
132
133 fbdev->av2 = l1_data_sram_zalloc(sizeof(struct dmasg));
134 if (fbdev->av2 == NULL)
135 goto error;
136
137 /* Build linked DMA descriptor list */
138 fbdev->vb1->next_desc_addr = fbdev->av1;
139 fbdev->av1->next_desc_addr = fbdev->vb2;
140 fbdev->vb2->next_desc_addr = fbdev->av2;
141 fbdev->av2->next_desc_addr = fbdev->vb1;
142
143 /* Save list head */
144 fbdev->descriptor_list_head = fbdev->av2;
145
146 /* Vertical Blanking Field 1 */
147 fbdev->vb1->start_addr = VB_DUMMY_MEMORY_SOURCE;
148 fbdev->vb1->cfg = DMA_CFG_VAL;
149
150 fbdev->vb1->x_count =
151 fbdev->modes[mode].xres + fbdev->modes[mode].boeft_blank;
152
153 fbdev->vb1->x_modify = 0;
154 fbdev->vb1->y_count = fbdev->modes[mode].vb1_lines;
155 fbdev->vb1->y_modify = 0;
156
157 /* Active Video Field 1 */
158
159 fbdev->av1->start_addr = (unsigned long)fbdev->fb_mem;
160 fbdev->av1->cfg = DMA_CFG_VAL;
161 fbdev->av1->x_count =
162 fbdev->modes[mode].xres + fbdev->modes[mode].boeft_blank;
163 fbdev->av1->x_modify = fbdev->modes[mode].bpp / 8;
164 fbdev->av1->y_count = fbdev->modes[mode].a_lines;
165 fbdev->av1->y_modify =
166 (fbdev->modes[mode].xres - fbdev->modes[mode].boeft_blank +
167 1) * (fbdev->modes[mode].bpp / 8);
168
169 /* Vertical Blanking Field 2 */
170
171 fbdev->vb2->start_addr = VB_DUMMY_MEMORY_SOURCE;
172 fbdev->vb2->cfg = DMA_CFG_VAL;
173 fbdev->vb2->x_count =
174 fbdev->modes[mode].xres + fbdev->modes[mode].boeft_blank;
175
176 fbdev->vb2->x_modify = 0;
177 fbdev->vb2->y_count = fbdev->modes[mode].vb2_lines;
178 fbdev->vb2->y_modify = 0;
179
180 /* Active Video Field 2 */
181
182 fbdev->av2->start_addr =
183 (unsigned long)fbdev->fb_mem + fbdev->line_len;
184
185 fbdev->av2->cfg = DMA_CFG_VAL;
186
187 fbdev->av2->x_count =
188 fbdev->modes[mode].xres + fbdev->modes[mode].boeft_blank;
189
190 fbdev->av2->x_modify = (fbdev->modes[mode].bpp / 8);
191 fbdev->av2->y_count = fbdev->modes[mode].a_lines;
192
193 fbdev->av2->y_modify =
194 (fbdev->modes[mode].xres - fbdev->modes[mode].boeft_blank +
195 1) * (fbdev->modes[mode].bpp / 8);
196
197 return 1;
198 }
199
200error:
201 l1_data_sram_free(fbdev->vb1);
202 l1_data_sram_free(fbdev->av1);
203 l1_data_sram_free(fbdev->vb2);
204 l1_data_sram_free(fbdev->av2);
205
206 return 0;
207}
208
209static int bfin_config_dma(struct adv7393fb_device *fbdev)
210{
211 BUG_ON(!(fbdev->fb_mem));
212
213 set_dma_x_count(CH_PPI, fbdev->descriptor_list_head->x_count);
214 set_dma_x_modify(CH_PPI, fbdev->descriptor_list_head->x_modify);
215 set_dma_y_count(CH_PPI, fbdev->descriptor_list_head->y_count);
216 set_dma_y_modify(CH_PPI, fbdev->descriptor_list_head->y_modify);
217 set_dma_start_addr(CH_PPI, fbdev->descriptor_list_head->start_addr);
218 set_dma_next_desc_addr(CH_PPI,
219 fbdev->descriptor_list_head->next_desc_addr);
220 set_dma_config(CH_PPI, fbdev->descriptor_list_head->cfg);
221
222 return 1;
223}
224
225static void bfin_disable_dma(void)
226{
227 bfin_write_DMA0_CONFIG(bfin_read_DMA0_CONFIG() & ~DMAEN);
228}
229
230static void bfin_config_ppi(struct adv7393fb_device *fbdev)
231{
232 if (ANOMALY_05000183) {
233 bfin_write_TIMER2_CONFIG(WDTH_CAP);
234 bfin_write_TIMER_ENABLE(TIMEN2);
235 }
236
237 bfin_write_PPI_CONTROL(0x381E);
238 bfin_write_PPI_FRAME(fbdev->modes[mode].tot_lines);
239 bfin_write_PPI_COUNT(fbdev->modes[mode].xres +
240 fbdev->modes[mode].boeft_blank - 1);
241 bfin_write_PPI_DELAY(fbdev->modes[mode].aoeft_blank - 1);
242}
243
244static void bfin_enable_ppi(void)
245{
246 bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() | PORT_EN);
247}
248
249static void bfin_disable_ppi(void)
250{
251 bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() & ~PORT_EN);
252}
253
254static inline int adv7393_write(struct i2c_client *client, u8 reg, u8 value)
255{
256 return i2c_smbus_write_byte_data(client, reg, value);
257}
258
259static inline int adv7393_read(struct i2c_client *client, u8 reg)
260{
261 return i2c_smbus_read_byte_data(client, reg);
262}
263
264static int
265adv7393_write_block(struct i2c_client *client,
266 const u8 *data, unsigned int len)
267{
268 int ret = -1;
269 u8 reg;
270
271 while (len >= 2) {
272 reg = *data++;
273 ret = adv7393_write(client, reg, *data++);
274 if (ret < 0)
275 break;
276 len -= 2;
277 }
278
279 return ret;
280}
281
282static int adv7393_mode(struct i2c_client *client, u16 mode)
283{
284 switch (mode) {
285 case POWER_ON: /* ADV7393 Sleep mode OFF */
286 adv7393_write(client, 0x00, 0x1E);
287 break;
288 case POWER_DOWN: /* ADV7393 Sleep mode ON */
289 adv7393_write(client, 0x00, 0x1F);
290 break;
291 case BLANK_OFF: /* Pixel Data Valid */
292 adv7393_write(client, 0x82, 0xCB);
293 break;
294 case BLANK_ON: /* Pixel Data Invalid */
295 adv7393_write(client, 0x82, 0x8B);
296 break;
297 default:
298 return -EINVAL;
299 break;
300 }
301 return 0;
302}
303
304static irqreturn_t ppi_irq_error(int irq, void *dev_id)
305{
306
307 struct adv7393fb_device *fbdev = (struct adv7393fb_device *)dev_id;
308
309 u16 status = bfin_read_PPI_STATUS();
310
311 pr_debug("%s: PPI Status = 0x%X\n", __func__, status);
312
313 if (status) {
314 bfin_disable_dma(); /* TODO: Check Sequence */
315 bfin_disable_ppi();
316 bfin_clear_PPI_STATUS();
317 bfin_config_dma(fbdev);
318 bfin_enable_ppi();
319 }
320
321 return IRQ_HANDLED;
322
323}
324
325static int proc_output(char *buf)
326{
327 char *p = buf;
328
329 p += sprintf(p,
330 "Usage:\n"
331 "echo 0x[REG][Value] > adv7393\n"
332 "example: echo 0x1234 >adv7393\n"
333 "writes 0x34 into Register 0x12\n");
334
335 return p - buf;
336}
337
338static int
339adv7393_read_proc(char *page, char **start, off_t off,
340 int count, int *eof, void *data)
341{
342 int len;
343
344 len = proc_output(page);
345 if (len <= off + count)
346 *eof = 1;
347 *start = page + off;
348 len -= off;
349 if (len > count)
350 len = count;
351 if (len < 0)
352 len = 0;
353 return len;
354}
355
356static int
357adv7393_write_proc(struct file *file, const char __user * buffer,
358 unsigned long count, void *data)
359{
360 struct adv7393fb_device *fbdev = data;
361 char line[8];
362 unsigned int val;
363 int ret;
364
365 ret = copy_from_user(line, buffer, count);
366 if (ret)
367 return -EFAULT;
368
369 val = simple_strtoul(line, NULL, 0);
370 adv7393_write(fbdev->client, val >> 8, val & 0xff);
371
372 return count;
373}
374
375static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
376 const struct i2c_device_id *id)
377{
378 int ret = 0;
379 struct proc_dir_entry *entry;
380 int num_modes = ARRAY_SIZE(known_modes);
381
382 struct adv7393fb_device *fbdev = NULL;
383
384 if (mem > 2) {
385 dev_err(&client->dev, "mem out of allowed range [1;2]\n");
386 return -EINVAL;
387 }
388
389 if (mode > num_modes) {
390 dev_err(&client->dev, "mode %d: not supported", mode);
391 return -EFAULT;
392 }
393
394 fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
395 if (!fbdev) {
396 dev_err(&client->dev, "failed to allocate device private record");
397 return -ENOMEM;
398 }
399
400 i2c_set_clientdata(client, fbdev);
401
402 fbdev->modes = known_modes;
403 fbdev->client = client;
404
405 fbdev->fb_len =
406 mem * fbdev->modes[mode].xres * fbdev->modes[mode].xres *
407 (fbdev->modes[mode].bpp / 8);
408
409 fbdev->line_len =
410 fbdev->modes[mode].xres * (fbdev->modes[mode].bpp / 8);
411
412 /* Workaround "PPI Does Not Start Properly In Specific Mode" */
413 if (ANOMALY_05000400) {
414 if (gpio_request(P_IDENT(P_PPI0_FS3), "PPI0_FS3")) {
415 dev_err(&client->dev, "PPI0_FS3 GPIO request failed\n");
416 ret = -EBUSY;
417 goto out_8;
418 }
419 gpio_direction_output(P_IDENT(P_PPI0_FS3), 0);
420 }
421
422 if (peripheral_request_list(ppi_pins, DRIVER_NAME)) {
423 dev_err(&client->dev, "requesting PPI peripheral failed\n");
424 ret = -EFAULT;
425 goto out_8;
426 }
427
428 fbdev->fb_mem =
429 dma_alloc_coherent(NULL, fbdev->fb_len, &fbdev->dma_handle,
430 GFP_KERNEL);
431
432 if (NULL == fbdev->fb_mem) {
433 dev_err(&client->dev, "couldn't allocate dma buffer (%d bytes)\n",
434 (u32) fbdev->fb_len);
435 ret = -ENOMEM;
436 goto out_7;
437 }
438
439 fbdev->info.screen_base = (void *)fbdev->fb_mem;
440 bfin_adv7393_fb_fix.smem_start = (int)fbdev->fb_mem;
441
442 bfin_adv7393_fb_fix.smem_len = fbdev->fb_len;
443 bfin_adv7393_fb_fix.line_length = fbdev->line_len;
444
445 if (mem > 1)
446 bfin_adv7393_fb_fix.ypanstep = 1;
447
448 bfin_adv7393_fb_defined.red.length = 5;
449 bfin_adv7393_fb_defined.green.length = 6;
450 bfin_adv7393_fb_defined.blue.length = 5;
451
452 bfin_adv7393_fb_defined.xres = fbdev->modes[mode].xres;
453 bfin_adv7393_fb_defined.yres = fbdev->modes[mode].yres;
454 bfin_adv7393_fb_defined.xres_virtual = fbdev->modes[mode].xres;
455 bfin_adv7393_fb_defined.yres_virtual = mem * fbdev->modes[mode].yres;
456 bfin_adv7393_fb_defined.bits_per_pixel = fbdev->modes[mode].bpp;
457
458 fbdev->info.fbops = &bfin_adv7393_fb_ops;
459 fbdev->info.var = bfin_adv7393_fb_defined;
460 fbdev->info.fix = bfin_adv7393_fb_fix;
461 fbdev->info.par = &bfin_par;
462 fbdev->info.flags = FBINFO_DEFAULT;
463
464 fbdev->info.pseudo_palette = kzalloc(sizeof(u32) * 16, GFP_KERNEL);
465 if (!fbdev->info.pseudo_palette) {
466 dev_err(&client->dev, "failed to allocate pseudo_palette\n");
467 ret = -ENOMEM;
468 goto out_6;
469 }
470
471 if (fb_alloc_cmap(&fbdev->info.cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) < 0) {
472 dev_err(&client->dev, "failed to allocate colormap (%d entries)\n",
473 BFIN_LCD_NBR_PALETTE_ENTRIES);
474 ret = -EFAULT;
475 goto out_5;
476 }
477
478 if (request_dma(CH_PPI, "BF5xx_PPI_DMA") < 0) {
479 dev_err(&client->dev, "unable to request PPI DMA\n");
480 ret = -EFAULT;
481 goto out_4;
482 }
483
484 if (request_irq(IRQ_PPI_ERROR, ppi_irq_error, IRQF_DISABLED,
485 "PPI ERROR", fbdev) < 0) {
486 dev_err(&client->dev, "unable to request PPI ERROR IRQ\n");
487 ret = -EFAULT;
488 goto out_3;
489 }
490
491 fbdev->open = 0;
492
493 ret = adv7393_write_block(client, fbdev->modes[mode].adv7393_i2c_initd,
494 fbdev->modes[mode].adv7393_i2c_initd_len);
495
496 if (ret) {
497 dev_err(&client->dev, "i2c attach: init error\n");
498 goto out_1;
499 }
500
501
502 if (register_framebuffer(&fbdev->info) < 0) {
503 dev_err(&client->dev, "unable to register framebuffer\n");
504 ret = -EFAULT;
505 goto out_1;
506 }
507
508 dev_info(&client->dev, "fb%d: %s frame buffer device\n",
509 fbdev->info.node, fbdev->info.fix.id);
510 dev_info(&client->dev, "fb memory address : 0x%p\n", fbdev->fb_mem);
511
512 entry = create_proc_entry("driver/adv7393", 0, NULL);
513 if (!entry) {
514 dev_err(&client->dev, "unable to create /proc entry\n");
515 ret = -EFAULT;
516 goto out_0;
517 }
518
519 entry->read_proc = adv7393_read_proc;
520 entry->write_proc = adv7393_write_proc;
521 entry->data = fbdev;
522
523 return 0;
524
525 out_0:
526 unregister_framebuffer(&fbdev->info);
527 out_1:
528 free_irq(IRQ_PPI_ERROR, fbdev);
529 out_3:
530 free_dma(CH_PPI);
531 out_4:
532 dma_free_coherent(NULL, fbdev->fb_len, fbdev->fb_mem,
533 fbdev->dma_handle);
534 out_5:
535 fb_dealloc_cmap(&fbdev->info.cmap);
536 out_6:
537 kfree(fbdev->info.pseudo_palette);
538 out_7:
539 peripheral_free_list(ppi_pins);
540 out_8:
541 kfree(fbdev);
542
543 return ret;
544}
545
546static int bfin_adv7393_fb_open(struct fb_info *info, int user)
547{
548 struct adv7393fb_device *fbdev = to_adv7393fb_device(info);
549
550 fbdev->info.screen_base = (void *)fbdev->fb_mem;
551 if (!fbdev->info.screen_base) {
552 dev_err(&fbdev->client->dev, "unable to map device\n");
553 return -ENOMEM;
554 }
555
556 fbdev->open = 1;
557 dma_desc_list(fbdev, BUILD);
558 adv7393_mode(fbdev->client, BLANK_OFF);
559 bfin_config_ppi(fbdev);
560 bfin_config_dma(fbdev);
561 bfin_enable_ppi();
562
563 return 0;
564}
565
566static int bfin_adv7393_fb_release(struct fb_info *info, int user)
567{
568 struct adv7393fb_device *fbdev = to_adv7393fb_device(info);
569
570 adv7393_mode(fbdev->client, BLANK_ON);
571 bfin_disable_dma();
572 bfin_disable_ppi();
573 dma_desc_list(fbdev, DESTRUCT);
574 fbdev->open = 0;
575 return 0;
576}
577
578static int
579bfin_adv7393_fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
580{
581
582 switch (var->bits_per_pixel) {
583 case 16:/* DIRECTCOLOUR, 64k */
584 var->red.offset = info->var.red.offset;
585 var->green.offset = info->var.green.offset;
586 var->blue.offset = info->var.blue.offset;
587 var->red.length = info->var.red.length;
588 var->green.length = info->var.green.length;
589 var->blue.length = info->var.blue.length;
590 var->transp.offset = 0;
591 var->transp.length = 0;
592 var->transp.msb_right = 0;
593 var->red.msb_right = 0;
594 var->green.msb_right = 0;
595 var->blue.msb_right = 0;
596 break;
597 default:
598 pr_debug("%s: depth not supported: %u BPP\n", __func__,
599 var->bits_per_pixel);
600 return -EINVAL;
601 }
602
603 if (info->var.xres != var->xres ||
604 info->var.yres != var->yres ||
605 info->var.xres_virtual != var->xres_virtual ||
606 info->var.yres_virtual != var->yres_virtual) {
607 pr_debug("%s: Resolution not supported: X%u x Y%u\n",
608 __func__, var->xres, var->yres);
609 return -EINVAL;
610 }
611
612 /*
613 * Memory limit
614 */
615
616 if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) {
617 pr_debug("%s: Memory Limit requested yres_virtual = %u\n",
618 __func__, var->yres_virtual);
619 return -ENOMEM;
620 }
621
622 return 0;
623}
624
625static int
626bfin_adv7393_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
627{
628 int dy;
629 u32 dmaaddr;
630 struct adv7393fb_device *fbdev = to_adv7393fb_device(info);
631
632 if (!var || !info)
633 return -EINVAL;
634
635 if (var->xoffset - info->var.xoffset) {
636 /* No support for X panning for now! */
637 return -EINVAL;
638 }
639 dy = var->yoffset - info->var.yoffset;
640
641 if (dy) {
642 pr_debug("%s: Panning screen of %d lines\n", __func__, dy);
643
644 dmaaddr = fbdev->av1->start_addr;
645 dmaaddr += (info->fix.line_length * dy);
646 /* TODO: Wait for current frame to finished */
647
648 fbdev->av1->start_addr = (unsigned long)dmaaddr;
649 fbdev->av2->start_addr = (unsigned long)dmaaddr + fbdev->line_len;
650 }
651
652 return 0;
653
654}
655
656/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */
657static int bfin_adv7393_fb_blank(int blank, struct fb_info *info)
658{
659 struct adv7393fb_device *fbdev = to_adv7393fb_device(info);
660
661 switch (blank) {
662
663 case VESA_NO_BLANKING:
664 /* Turn on panel */
665 adv7393_mode(fbdev->client, BLANK_OFF);
666 break;
667
668 case VESA_VSYNC_SUSPEND:
669 case VESA_HSYNC_SUSPEND:
670 case VESA_POWERDOWN:
671 /* Turn off panel */
672 adv7393_mode(fbdev->client, BLANK_ON);
673 break;
674
675 default:
676 return -EINVAL;
677 break;
678 }
679 return 0;
680}
681
682int bfin_adv7393_fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
683{
684 if (nocursor)
685 return 0;
686 else
687 return -EINVAL; /* just to force soft_cursor() call */
688}
689
690static int bfin_adv7393_fb_setcolreg(u_int regno, u_int red, u_int green,
691 u_int blue, u_int transp,
692 struct fb_info *info)
693{
694 if (regno >= BFIN_LCD_NBR_PALETTE_ENTRIES)
695 return -EINVAL;
696
697 if (info->var.grayscale)
698 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
699 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
700
701 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
702 u32 value;
703 /* Place color in the pseudopalette */
704 if (regno > 16)
705 return -EINVAL;
706
707 red >>= (16 - info->var.red.length);
708 green >>= (16 - info->var.green.length);
709 blue >>= (16 - info->var.blue.length);
710
711 value = (red << info->var.red.offset) |
712 (green << info->var.green.offset)|
713 (blue << info->var.blue.offset);
714 value &= 0xFFFF;
715
716 ((u32 *) (info->pseudo_palette))[regno] = value;
717 }
718
719 return 0;
720}
721
722static int __devexit bfin_adv7393_fb_remove(struct i2c_client *client)
723{
724 struct adv7393fb_device *fbdev = i2c_get_clientdata(client);
725
726 adv7393_mode(client, POWER_DOWN);
727
728 if (fbdev->fb_mem)
729 dma_free_coherent(NULL, fbdev->fb_len, fbdev->fb_mem, fbdev->dma_handle);
730 free_dma(CH_PPI);
731 free_irq(IRQ_PPI_ERROR, fbdev);
732 unregister_framebuffer(&fbdev->info);
733 remove_proc_entry("driver/adv7393", NULL);
734 fb_dealloc_cmap(&fbdev->info.cmap);
735 kfree(fbdev->info.pseudo_palette);
736
737 if (ANOMALY_05000400)
738 gpio_free(P_IDENT(P_PPI0_FS3)); /* FS3 */
739 peripheral_free_list(ppi_pins);
740 kfree(fbdev);
741
742 return 0;
743}
744
745#ifdef CONFIG_PM
746static int bfin_adv7393_fb_suspend(struct device *dev)
747{
748 struct adv7393fb_device *fbdev = dev_get_drvdata(dev);
749
750 if (fbdev->open) {
751 bfin_disable_dma();
752 bfin_disable_ppi();
753 dma_desc_list(fbdev, DESTRUCT);
754 }
755 adv7393_mode(fbdev->client, POWER_DOWN);
756
757 return 0;
758}
759
760static int bfin_adv7393_fb_resume(struct device *dev)
761{
762 struct adv7393fb_device *fbdev = dev_get_drvdata(dev);
763
764 adv7393_mode(fbdev->client, POWER_ON);
765
766 if (fbdev->open) {
767 dma_desc_list(fbdev, BUILD);
768 bfin_config_ppi(fbdev);
769 bfin_config_dma(fbdev);
770 bfin_enable_ppi();
771 }
772
773 return 0;
774}
775
776static const struct dev_pm_ops bfin_adv7393_dev_pm_ops = {
777 .suspend = bfin_adv7393_fb_suspend,
778 .resume = bfin_adv7393_fb_resume,
779};
780#endif
781
782static const struct i2c_device_id bfin_adv7393_id[] = {
783 {DRIVER_NAME, 0},
784 {}
785};
786
787MODULE_DEVICE_TABLE(i2c, bfin_adv7393_id);
788
789static struct i2c_driver bfin_adv7393_fb_driver = {
790 .driver = {
791 .name = DRIVER_NAME,
792#ifdef CONFIG_PM
793 .pm = &bfin_adv7393_dev_pm_ops,
794#endif
795 },
796 .probe = bfin_adv7393_fb_probe,
797 .remove = __devexit_p(bfin_adv7393_fb_remove),
798 .id_table = bfin_adv7393_id,
799};
800
801static int __init bfin_adv7393_fb_driver_init(void)
802{
803#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
804 request_module("i2c-bfin-twi");
805#else
806 request_module("i2c-gpio");
807#endif
808
809 return i2c_add_driver(&bfin_adv7393_fb_driver);
810}
811module_init(bfin_adv7393_fb_driver_init);
812
813static void __exit bfin_adv7393_fb_driver_cleanup(void)
814{
815 i2c_del_driver(&bfin_adv7393_fb_driver);
816}
817module_exit(bfin_adv7393_fb_driver_cleanup);
818
819MODULE_LICENSE("GPL");
820MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
821MODULE_DESCRIPTION("Frame buffer driver for ADV7393/2 Video Encoder");
822
823module_param(mode, int, 0);
824MODULE_PARM_DESC(mode,
825 "Video Mode (0=NTSC,1=PAL,2=NTSC 640x480,3=PAL 640x480,4=NTSC YCbCr input,5=PAL YCbCr input)");
826
827module_param(mem, int, 0);
828MODULE_PARM_DESC(mem,
829 "Size of frame buffer memory 1=Single 2=Double Size (allows y-panning / frame stacking)");
830
831module_param(nocursor, int, 0644);
832MODULE_PARM_DESC(nocursor, "cursor enable/disable");
diff --git a/drivers/video/bfin_adv7393fb.h b/drivers/video/bfin_adv7393fb.h
new file mode 100644
index 000000000000..8c7f9e4fc6eb
--- /dev/null
+++ b/drivers/video/bfin_adv7393fb.h
@@ -0,0 +1,321 @@
1/*
2 * Frame buffer driver for ADV7393/2 video encoder
3 *
4 * Copyright 2006-2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or late.
6 */
7
8#ifndef __BFIN_ADV7393FB_H__
9#define __BFIN_ADV7393FB_H__
10
11#define BFIN_LCD_NBR_PALETTE_ENTRIES 256
12
13#ifdef CONFIG_NTSC
14# define VMODE 0
15#endif
16#ifdef CONFIG_PAL
17# define VMODE 1
18#endif
19#ifdef CONFIG_NTSC_640x480
20# define VMODE 2
21#endif
22#ifdef CONFIG_PAL_640x480
23# define VMODE 3
24#endif
25#ifdef CONFIG_NTSC_YCBCR
26# define VMODE 4
27#endif
28#ifdef CONFIG_PAL_YCBCR
29# define VMODE 5
30#endif
31
32#ifndef VMODE
33# define VMODE 1
34#endif
35
36#ifdef CONFIG_ADV7393_2XMEM
37# define VMEM 2
38#else
39# define VMEM 1
40#endif
41
42#if defined(CONFIG_BF537) || defined(CONFIG_BF536) || defined(CONFIG_BF534)
43# define DMA_CFG_VAL 0x7935 /* Set Sync Bit */
44# define VB_DUMMY_MEMORY_SOURCE L1_DATA_B_START
45#else
46# define DMA_CFG_VAL 0x7915
47# define VB_DUMMY_MEMORY_SOURCE BOOT_ROM_START
48#endif
49
50enum {
51 DESTRUCT,
52 BUILD,
53};
54
55enum {
56 POWER_ON,
57 POWER_DOWN,
58 BLANK_ON,
59 BLANK_OFF,
60};
61
62#define DRIVER_NAME "bfin-adv7393"
63
64struct adv7393fb_modes {
65 const s8 name[25]; /* Full name */
66 u16 xres; /* Active Horizonzal Pixels */
67 u16 yres; /* Active Vertical Pixels */
68 u16 bpp;
69 u16 vmode;
70 u16 a_lines; /* Active Lines per Field */
71 u16 vb1_lines; /* Vertical Blanking Field 1 Lines */
72 u16 vb2_lines; /* Vertical Blanking Field 2 Lines */
73 u16 tot_lines; /* Total Lines per Frame */
74 u16 boeft_blank; /* Before Odd/Even Field Transition No. of Blank Pixels */
75 u16 aoeft_blank; /* After Odd/Even Field Transition No. of Blank Pixels */
76 const s8 *adv7393_i2c_initd;
77 u16 adv7393_i2c_initd_len;
78};
79
80static const u8 init_NTSC_TESTPATTERN[] = {
81 0x00, 0x1E, /* Power up all DACs and PLL */
82 0x01, 0x00, /* SD-Only Mode */
83 0x80, 0x10, /* SSAF Luma Filter Enabled, NTSC Mode */
84 0x82, 0xCB, /* Step control on, pixel data valid, pedestal on, PrPb SSAF on, CVBS/YC output */
85 0x84, 0x40, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
86};
87
88static const u8 init_NTSC[] = {
89 0x00, 0x1E, /* Power up all DACs and PLL */
90 0xC3, 0x26, /* Program RGB->YCrCb Color Space convertion matrix */
91 0xC5, 0x12, /* Program RGB->YCrCb Color Space convertion matrix */
92 0xC2, 0x4A, /* Program RGB->YCrCb Color Space convertion matrix */
93 0xC6, 0x5E, /* Program RGB->YCrCb Color Space convertion matrix */
94 0xBD, 0x19, /* Program RGB->YCrCb Color Space convertion matrix */
95 0xBF, 0x42, /* Program RGB->YCrCb Color Space convertion matrix */
96 0x8C, 0x1F, /* NTSC Subcarrier Frequency */
97 0x8D, 0x7C, /* NTSC Subcarrier Frequency */
98 0x8E, 0xF0, /* NTSC Subcarrier Frequency */
99 0x8F, 0x21, /* NTSC Subcarrier Frequency */
100 0x01, 0x00, /* SD-Only Mode */
101 0x80, 0x30, /* SSAF Luma Filter Enabled, NTSC Mode */
102 0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
103 0x87, 0x80, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
104 0x86, 0x82,
105 0x8B, 0x11,
106 0x88, 0x20,
107 0x8A, 0x0d,
108};
109
110static const u8 init_PAL[] = {
111 0x00, 0x1E, /* Power up all DACs and PLL */
112 0xC3, 0x26, /* Program RGB->YCrCb Color Space convertion matrix */
113 0xC5, 0x12, /* Program RGB->YCrCb Color Space convertion matrix */
114 0xC2, 0x4A, /* Program RGB->YCrCb Color Space convertion matrix */
115 0xC6, 0x5E, /* Program RGB->YCrCb Color Space convertion matrix */
116 0xBD, 0x19, /* Program RGB->YCrCb Color Space convertion matrix */
117 0xBF, 0x42, /* Program RGB->YCrCb Color Space convertion matrix */
118 0x8C, 0xCB, /* PAL Subcarrier Frequency */
119 0x8D, 0x8A, /* PAL Subcarrier Frequency */
120 0x8E, 0x09, /* PAL Subcarrier Frequency */
121 0x8F, 0x2A, /* PAL Subcarrier Frequency */
122 0x01, 0x00, /* SD-Only Mode */
123 0x80, 0x11, /* SSAF Luma Filter Enabled, PAL Mode */
124 0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
125 0x87, 0x80, /* SD Color Bar Test Pattern Enabled, DAC 2 = Luma, DAC 3 = Chroma */
126 0x86, 0x82,
127 0x8B, 0x11,
128 0x88, 0x20,
129 0x8A, 0x0d,
130};
131
132static const u8 init_NTSC_YCbCr[] = {
133 0x00, 0x1E, /* Power up all DACs and PLL */
134 0x8C, 0x1F, /* NTSC Subcarrier Frequency */
135 0x8D, 0x7C, /* NTSC Subcarrier Frequency */
136 0x8E, 0xF0, /* NTSC Subcarrier Frequency */
137 0x8F, 0x21, /* NTSC Subcarrier Frequency */
138 0x01, 0x00, /* SD-Only Mode */
139 0x80, 0x30, /* SSAF Luma Filter Enabled, NTSC Mode */
140 0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
141 0x87, 0x00, /* DAC 2 = Luma, DAC 3 = Chroma */
142 0x86, 0x82,
143 0x8B, 0x11,
144 0x88, 0x08,
145 0x8A, 0x0d,
146};
147
148static const u8 init_PAL_YCbCr[] = {
149 0x00, 0x1E, /* Power up all DACs and PLL */
150 0x8C, 0xCB, /* PAL Subcarrier Frequency */
151 0x8D, 0x8A, /* PAL Subcarrier Frequency */
152 0x8E, 0x09, /* PAL Subcarrier Frequency */
153 0x8F, 0x2A, /* PAL Subcarrier Frequency */
154 0x01, 0x00, /* SD-Only Mode */
155 0x80, 0x11, /* SSAF Luma Filter Enabled, PAL Mode */
156 0x82, 0x8B, /* Step control on, pixel data invalid, pedestal on, PrPb SSAF on, CVBS/YC output */
157 0x87, 0x00, /* DAC 2 = Luma, DAC 3 = Chroma */
158 0x86, 0x82,
159 0x8B, 0x11,
160 0x88, 0x08,
161 0x8A, 0x0d,
162};
163
164static struct adv7393fb_modes known_modes[] = {
165 /* NTSC 720x480 CRT */
166 {
167 .name = "NTSC 720x480",
168 .xres = 720,
169 .yres = 480,
170 .bpp = 16,
171 .vmode = FB_VMODE_INTERLACED,
172 .a_lines = 240,
173 .vb1_lines = 22,
174 .vb2_lines = 23,
175 .tot_lines = 525,
176 .boeft_blank = 16,
177 .aoeft_blank = 122,
178 .adv7393_i2c_initd = init_NTSC,
179 .adv7393_i2c_initd_len = sizeof(init_NTSC)
180 },
181 /* PAL 720x480 CRT */
182 {
183 .name = "PAL 720x576",
184 .xres = 720,
185 .yres = 576,
186 .bpp = 16,
187 .vmode = FB_VMODE_INTERLACED,
188 .a_lines = 288,
189 .vb1_lines = 24,
190 .vb2_lines = 25,
191 .tot_lines = 625,
192 .boeft_blank = 12,
193 .aoeft_blank = 132,
194 .adv7393_i2c_initd = init_PAL,
195 .adv7393_i2c_initd_len = sizeof(init_PAL)
196 },
197 /* NTSC 640x480 CRT Experimental */
198 {
199 .name = "NTSC 640x480",
200 .xres = 640,
201 .yres = 480,
202 .bpp = 16,
203 .vmode = FB_VMODE_INTERLACED,
204 .a_lines = 240,
205 .vb1_lines = 22,
206 .vb2_lines = 23,
207 .tot_lines = 525,
208 .boeft_blank = 16 + 40,
209 .aoeft_blank = 122 + 40,
210 .adv7393_i2c_initd = init_NTSC,
211 .adv7393_i2c_initd_len = sizeof(init_NTSC)
212 },
213 /* PAL 640x480 CRT Experimental */
214 {
215 .name = "PAL 640x480",
216 .xres = 640,
217 .yres = 480,
218 .bpp = 16,
219 .vmode = FB_VMODE_INTERLACED,
220 .a_lines = 288 - 20,
221 .vb1_lines = 24 + 20,
222 .vb2_lines = 25 + 20,
223 .tot_lines = 625,
224 .boeft_blank = 12 + 40,
225 .aoeft_blank = 132 + 40,
226 .adv7393_i2c_initd = init_PAL,
227 .adv7393_i2c_initd_len = sizeof(init_PAL)
228 },
229 /* NTSC 720x480 YCbCR */
230 {
231 .name = "NTSC 720x480 YCbCR",
232 .xres = 720,
233 .yres = 480,
234 .bpp = 16,
235 .vmode = FB_VMODE_INTERLACED,
236 .a_lines = 240,
237 .vb1_lines = 22,
238 .vb2_lines = 23,
239 .tot_lines = 525,
240 .boeft_blank = 16,
241 .aoeft_blank = 122,
242 .adv7393_i2c_initd = init_NTSC_YCbCr,
243 .adv7393_i2c_initd_len = sizeof(init_NTSC_YCbCr)
244 },
245 /* PAL 720x480 CRT */
246 {
247 .name = "PAL 720x576 YCbCR",
248 .xres = 720,
249 .yres = 576,
250 .bpp = 16,
251 .vmode = FB_VMODE_INTERLACED,
252 .a_lines = 288,
253 .vb1_lines = 24,
254 .vb2_lines = 25,
255 .tot_lines = 625,
256 .boeft_blank = 12,
257 .aoeft_blank = 132,
258 .adv7393_i2c_initd = init_PAL_YCbCr,
259 .adv7393_i2c_initd_len = sizeof(init_PAL_YCbCr)
260 }
261};
262
263struct adv7393fb_regs {
264
265};
266
267struct adv7393fb_device {
268 struct fb_info info; /* FB driver info record */
269
270 struct i2c_client *client;
271
272 struct dmasg *descriptor_list_head;
273 struct dmasg *vb1;
274 struct dmasg *av1;
275 struct dmasg *vb2;
276 struct dmasg *av2;
277
278 dma_addr_t dma_handle;
279
280 struct fb_info bfin_adv7393_fb;
281
282 struct adv7393fb_modes *modes;
283
284 struct adv7393fb_regs *regs; /* Registers memory map */
285 size_t regs_len;
286 size_t fb_len;
287 size_t line_len;
288 u16 open;
289 u16 *fb_mem; /* RGB Buffer */
290
291};
292
293#define to_adv7393fb_device(_info) \
294 (_info ? container_of(_info, struct adv7393fb_device, info) : NULL);
295
296static int bfin_adv7393_fb_open(struct fb_info *info, int user);
297static int bfin_adv7393_fb_release(struct fb_info *info, int user);
298static int bfin_adv7393_fb_check_var(struct fb_var_screeninfo *var,
299 struct fb_info *info);
300
301static int bfin_adv7393_fb_pan_display(struct fb_var_screeninfo *var,
302 struct fb_info *info);
303
304static int bfin_adv7393_fb_blank(int blank, struct fb_info *info);
305
306static void bfin_config_ppi(struct adv7393fb_device *fbdev);
307static int bfin_config_dma(struct adv7393fb_device *fbdev);
308static void bfin_disable_dma(void);
309static void bfin_enable_ppi(void);
310static void bfin_disable_ppi(void);
311
312static inline int adv7393_write(struct i2c_client *client, u8 reg, u8 value);
313static inline int adv7393_read(struct i2c_client *client, u8 reg);
314static int adv7393_write_block(struct i2c_client *client, const u8 *data,
315 unsigned int len);
316
317int bfin_adv7393_fb_cursor(struct fb_info *info, struct fb_cursor *cursor);
318static int bfin_adv7393_fb_setcolreg(u_int, u_int, u_int, u_int,
319 u_int, struct fb_info *info);
320
321#endif
diff --git a/drivers/video/carminefb.c b/drivers/video/carminefb.c
index 6b19136aa181..caaa27d4a46a 100644
--- a/drivers/video/carminefb.c
+++ b/drivers/video/carminefb.c
@@ -654,7 +654,7 @@ static int __devinit carminefb_probe(struct pci_dev *dev,
654 printk(KERN_ERR "carminefb: Memory bar is only %d bytes, %d " 654 printk(KERN_ERR "carminefb: Memory bar is only %d bytes, %d "
655 "are required.", carminefb_fix.smem_len, 655 "are required.", carminefb_fix.smem_len,
656 CARMINE_TOTAL_DIPLAY_MEM); 656 CARMINE_TOTAL_DIPLAY_MEM);
657 goto err_free_reg_mmio; 657 goto err_unmap_vregs;
658 } 658 }
659 659
660 if (!request_mem_region(carminefb_fix.smem_start, 660 if (!request_mem_region(carminefb_fix.smem_start,
@@ -667,8 +667,6 @@ static int __devinit carminefb_probe(struct pci_dev *dev,
667 carminefb_fix.smem_len); 667 carminefb_fix.smem_len);
668 if (!hw->screen_mem) { 668 if (!hw->screen_mem) {
669 printk(KERN_ERR "carmine: Can't ioremap smem area.\n"); 669 printk(KERN_ERR "carmine: Can't ioremap smem area.\n");
670 release_mem_region(carminefb_fix.smem_start,
671 carminefb_fix.smem_len);
672 goto err_reg_smem; 670 goto err_reg_smem;
673 } 671 }
674 672
@@ -710,7 +708,7 @@ err_deinit_hw:
710err_unmap_screen: 708err_unmap_screen:
711 iounmap(hw->screen_mem); 709 iounmap(hw->screen_mem);
712err_reg_smem: 710err_reg_smem:
713 release_mem_region(carminefb_fix.mmio_start, carminefb_fix.mmio_len); 711 release_mem_region(carminefb_fix.smem_start, carminefb_fix.smem_len);
714err_unmap_vregs: 712err_unmap_vregs:
715 iounmap(hw->v_regs); 713 iounmap(hw->v_regs);
716err_free_reg_mmio: 714err_free_reg_mmio:
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 54e32c513610..915448ec75bf 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -47,7 +47,6 @@
47#include <linux/ioport.h> 47#include <linux/ioport.h>
48#include <linux/init.h> 48#include <linux/init.h>
49#include <linux/screen_info.h> 49#include <linux/screen_info.h>
50#include <linux/smp_lock.h>
51#include <video/vga.h> 50#include <video/vga.h>
52#include <asm/io.h> 51#include <asm/io.h>
53 52
diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index cad7d45c8bac..c265aed09e04 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -1029,10 +1029,6 @@ static int __init fb_probe(struct platform_device *device)
1029 goto err_release_pl_mem; 1029 goto err_release_pl_mem;
1030 } 1030 }
1031 1031
1032 ret = request_irq(par->irq, lcdc_irq_handler, 0, DRIVER_NAME, par);
1033 if (ret)
1034 goto err_release_pl_mem;
1035
1036 /* Initialize par */ 1032 /* Initialize par */
1037 da8xx_fb_info->var.bits_per_pixel = lcd_cfg->bpp; 1033 da8xx_fb_info->var.bits_per_pixel = lcd_cfg->bpp;
1038 1034
@@ -1060,7 +1056,7 @@ static int __init fb_probe(struct platform_device *device)
1060 1056
1061 ret = fb_alloc_cmap(&da8xx_fb_info->cmap, PALETTE_SIZE, 0); 1057 ret = fb_alloc_cmap(&da8xx_fb_info->cmap, PALETTE_SIZE, 0);
1062 if (ret) 1058 if (ret)
1063 goto err_free_irq; 1059 goto err_release_pl_mem;
1064 da8xx_fb_info->cmap.len = par->palette_sz; 1060 da8xx_fb_info->cmap.len = par->palette_sz;
1065 1061
1066 /* initialize var_screeninfo */ 1062 /* initialize var_screeninfo */
@@ -1088,8 +1084,13 @@ static int __init fb_probe(struct platform_device *device)
1088 goto err_cpu_freq; 1084 goto err_cpu_freq;
1089 } 1085 }
1090#endif 1086#endif
1087
1088 ret = request_irq(par->irq, lcdc_irq_handler, 0, DRIVER_NAME, par);
1089 if (ret)
1090 goto irq_freq;
1091 return 0; 1091 return 0;
1092 1092
1093irq_freq:
1093#ifdef CONFIG_CPU_FREQ 1094#ifdef CONFIG_CPU_FREQ
1094err_cpu_freq: 1095err_cpu_freq:
1095 unregister_framebuffer(da8xx_fb_info); 1096 unregister_framebuffer(da8xx_fb_info);
@@ -1098,9 +1099,6 @@ err_cpu_freq:
1098err_dealloc_cmap: 1099err_dealloc_cmap:
1099 fb_dealloc_cmap(&da8xx_fb_info->cmap); 1100 fb_dealloc_cmap(&da8xx_fb_info->cmap);
1100 1101
1101err_free_irq:
1102 free_irq(par->irq, par);
1103
1104err_release_pl_mem: 1102err_release_pl_mem:
1105 dma_free_coherent(NULL, PALETTE_SIZE, par->v_palette_base, 1103 dma_free_coherent(NULL, PALETTE_SIZE, par->v_palette_base,
1106 par->p_palette_base); 1104 par->p_palette_base);
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
index f53b9f1d6aba..5c3960da755a 100644
--- a/drivers/video/fbcmap.c
+++ b/drivers/video/fbcmap.c
@@ -80,6 +80,7 @@ static const struct fb_cmap default_16_colors = {
80 * @cmap: frame buffer colormap structure 80 * @cmap: frame buffer colormap structure
81 * @len: length of @cmap 81 * @len: length of @cmap
82 * @transp: boolean, 1 if there is transparency, 0 otherwise 82 * @transp: boolean, 1 if there is transparency, 0 otherwise
83 * @flags: flags for kmalloc memory allocation
83 * 84 *
84 * Allocates memory for a colormap @cmap. @len is the 85 * Allocates memory for a colormap @cmap. @len is the
85 * number of entries in the palette. 86 * number of entries in the palette.
@@ -88,34 +89,48 @@ static const struct fb_cmap default_16_colors = {
88 * 89 *
89 */ 90 */
90 91
91int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp) 92int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
92{ 93{
93 int size = len*sizeof(u16); 94 int size = len * sizeof(u16);
94 95 int ret = -ENOMEM;
95 if (cmap->len != len) { 96
96 fb_dealloc_cmap(cmap); 97 if (cmap->len != len) {
97 if (!len) 98 fb_dealloc_cmap(cmap);
98 return 0; 99 if (!len)
99 if (!(cmap->red = kmalloc(size, GFP_ATOMIC))) 100 return 0;
100 goto fail; 101
101 if (!(cmap->green = kmalloc(size, GFP_ATOMIC))) 102 cmap->red = kmalloc(size, flags);
102 goto fail; 103 if (!cmap->red)
103 if (!(cmap->blue = kmalloc(size, GFP_ATOMIC))) 104 goto fail;
104 goto fail; 105 cmap->green = kmalloc(size, flags);
105 if (transp) { 106 if (!cmap->green)
106 if (!(cmap->transp = kmalloc(size, GFP_ATOMIC))) 107 goto fail;
108 cmap->blue = kmalloc(size, flags);
109 if (!cmap->blue)
110 goto fail;
111 if (transp) {
112 cmap->transp = kmalloc(size, flags);
113 if (!cmap->transp)
114 goto fail;
115 } else {
116 cmap->transp = NULL;
117 }
118 }
119 cmap->start = 0;
120 cmap->len = len;
121 ret = fb_copy_cmap(fb_default_cmap(len), cmap);
122 if (ret)
107 goto fail; 123 goto fail;
108 } else 124 return 0;
109 cmap->transp = NULL;
110 }
111 cmap->start = 0;
112 cmap->len = len;
113 fb_copy_cmap(fb_default_cmap(len), cmap);
114 return 0;
115 125
116fail: 126fail:
117 fb_dealloc_cmap(cmap); 127 fb_dealloc_cmap(cmap);
118 return -ENOMEM; 128 return ret;
129}
130
131int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp)
132{
133 return fb_alloc_cmap_gfp(cmap, len, transp, GFP_ATOMIC);
119} 134}
120 135
121/** 136/**
@@ -250,8 +265,12 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
250 int rc, size = cmap->len * sizeof(u16); 265 int rc, size = cmap->len * sizeof(u16);
251 struct fb_cmap umap; 266 struct fb_cmap umap;
252 267
268 if (size < 0 || size < cmap->len)
269 return -E2BIG;
270
253 memset(&umap, 0, sizeof(struct fb_cmap)); 271 memset(&umap, 0, sizeof(struct fb_cmap));
254 rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL); 272 rc = fb_alloc_cmap_gfp(&umap, cmap->len, cmap->transp != NULL,
273 GFP_KERNEL);
255 if (rc) 274 if (rc)
256 return rc; 275 return rc;
257 if (copy_from_user(umap.red, cmap->red, size) || 276 if (copy_from_user(umap.red, cmap->red, size) ||
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 563a98b88e9b..4f57485f8c54 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -973,6 +973,90 @@ void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
973 DPRINTK("========================================\n"); 973 DPRINTK("========================================\n");
974} 974}
975 975
976/**
977 * fb_edid_add_monspecs() - add monitor video modes from E-EDID data
978 * @edid: 128 byte array with an E-EDID block
979 * @spacs: monitor specs to be extended
980 */
981void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs)
982{
983 unsigned char *block;
984 struct fb_videomode *m;
985 int num = 0, i;
986 u8 svd[64], edt[(128 - 4) / DETAILED_TIMING_DESCRIPTION_SIZE];
987 u8 pos = 4, svd_n = 0;
988
989 if (!edid)
990 return;
991
992 if (!edid_checksum(edid))
993 return;
994
995 if (edid[0] != 0x2 ||
996 edid[2] < 4 || edid[2] > 128 - DETAILED_TIMING_DESCRIPTION_SIZE)
997 return;
998
999 DPRINTK(" Short Video Descriptors\n");
1000
1001 while (pos < edid[2]) {
1002 u8 len = edid[pos] & 0x1f, type = (edid[pos] >> 5) & 7;
1003 pr_debug("Data block %u of %u bytes\n", type, len);
1004 if (type == 2)
1005 for (i = pos; i < pos + len; i++) {
1006 u8 idx = edid[pos + i] & 0x7f;
1007 svd[svd_n++] = idx;
1008 pr_debug("N%sative mode #%d\n",
1009 edid[pos + i] & 0x80 ? "" : "on-n", idx);
1010 }
1011 pos += len + 1;
1012 }
1013
1014 block = edid + edid[2];
1015
1016 DPRINTK(" Extended Detailed Timings\n");
1017
1018 for (i = 0; i < (128 - edid[2]) / DETAILED_TIMING_DESCRIPTION_SIZE;
1019 i++, block += DETAILED_TIMING_DESCRIPTION_SIZE)
1020 if (PIXEL_CLOCK)
1021 edt[num++] = block - edid;
1022
1023 /* Yikes, EDID data is totally useless */
1024 if (!(num + svd_n))
1025 return;
1026
1027 m = kzalloc((specs->modedb_len + num + svd_n) *
1028 sizeof(struct fb_videomode), GFP_KERNEL);
1029
1030 if (!m)
1031 return;
1032
1033 memcpy(m, specs->modedb, specs->modedb_len * sizeof(struct fb_videomode));
1034
1035 for (i = specs->modedb_len; i < specs->modedb_len + num; i++) {
1036 get_detailed_timing(edid + edt[i - specs->modedb_len], &m[i]);
1037 if (i == specs->modedb_len)
1038 m[i].flag |= FB_MODE_IS_FIRST;
1039 pr_debug("Adding %ux%u@%u\n", m[i].xres, m[i].yres, m[i].refresh);
1040 }
1041
1042 for (i = specs->modedb_len + num; i < specs->modedb_len + num + svd_n; i++) {
1043 int idx = svd[i - specs->modedb_len - num];
1044 if (!idx || idx > 63) {
1045 pr_warning("Reserved SVD code %d\n", idx);
1046 } else if (idx > ARRAY_SIZE(cea_modes) || !cea_modes[idx].xres) {
1047 pr_warning("Unimplemented SVD code %d\n", idx);
1048 } else {
1049 memcpy(&m[i], cea_modes + idx, sizeof(m[i]));
1050 pr_debug("Adding SVD #%d: %ux%u@%u\n", idx,
1051 m[i].xres, m[i].yres, m[i].refresh);
1052 }
1053 }
1054
1055 kfree(specs->modedb);
1056 specs->modedb = m;
1057 specs->modedb_len = specs->modedb_len + num + svd_n;
1058}
1059
976/* 1060/*
977 * VESA Generalized Timing Formula (GTF) 1061 * VESA Generalized Timing Formula (GTF)
978 */ 1062 */
@@ -1289,6 +1373,9 @@ void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
1289{ 1373{
1290 specs = NULL; 1374 specs = NULL;
1291} 1375}
1376void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs)
1377{
1378}
1292void fb_destroy_modedb(struct fb_videomode *modedb) 1379void fb_destroy_modedb(struct fb_videomode *modedb)
1293{ 1380{
1294} 1381}
@@ -1396,6 +1483,7 @@ EXPORT_SYMBOL(fb_firmware_edid);
1396 1483
1397EXPORT_SYMBOL(fb_parse_edid); 1484EXPORT_SYMBOL(fb_parse_edid);
1398EXPORT_SYMBOL(fb_edid_to_monspecs); 1485EXPORT_SYMBOL(fb_edid_to_monspecs);
1486EXPORT_SYMBOL(fb_edid_add_monspecs);
1399EXPORT_SYMBOL(fb_get_mode); 1487EXPORT_SYMBOL(fb_get_mode);
1400EXPORT_SYMBOL(fb_validate_mode); 1488EXPORT_SYMBOL(fb_validate_mode);
1401EXPORT_SYMBOL(fb_destroy_modedb); 1489EXPORT_SYMBOL(fb_destroy_modedb);
diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h
index e4c4d89b7860..be8ccb47ebe0 100644
--- a/drivers/video/geode/lxfb.h
+++ b/drivers/video/geode/lxfb.h
@@ -22,6 +22,7 @@
22#define DC_HFILT_COUNT 0x100 22#define DC_HFILT_COUNT 0x100
23#define DC_VFILT_COUNT 0x100 23#define DC_VFILT_COUNT 0x100
24#define VP_COEFF_SIZE 0x1000 24#define VP_COEFF_SIZE 0x1000
25#define VP_PAL_COUNT 0x100
25 26
26#define OUTPUT_CRT 0x01 27#define OUTPUT_CRT 0x01
27#define OUTPUT_PANEL 0x02 28#define OUTPUT_PANEL 0x02
@@ -48,7 +49,8 @@ struct lxfb_par {
48 uint64_t vp[VP_REG_COUNT]; 49 uint64_t vp[VP_REG_COUNT];
49 uint64_t fp[FP_REG_COUNT]; 50 uint64_t fp[FP_REG_COUNT];
50 51
51 uint32_t pal[DC_PAL_COUNT]; 52 uint32_t dc_pal[DC_PAL_COUNT];
53 uint32_t vp_pal[VP_PAL_COUNT];
52 uint32_t hcoeff[DC_HFILT_COUNT * 2]; 54 uint32_t hcoeff[DC_HFILT_COUNT * 2];
53 uint32_t vcoeff[DC_VFILT_COUNT]; 55 uint32_t vcoeff[DC_VFILT_COUNT];
54 uint32_t vp_coeff[VP_COEFF_SIZE / 4]; 56 uint32_t vp_coeff[VP_COEFF_SIZE / 4];
diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c
index bc35a95e59d4..79e9abc72b83 100644
--- a/drivers/video/geode/lxfb_ops.c
+++ b/drivers/video/geode/lxfb_ops.c
@@ -276,10 +276,10 @@ static void lx_graphics_enable(struct fb_info *info)
276 write_fp(par, FP_PT1, 0); 276 write_fp(par, FP_PT1, 0);
277 temp = FP_PT2_SCRC; 277 temp = FP_PT2_SCRC;
278 278
279 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) 279 if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT))
280 temp |= FP_PT2_HSP; 280 temp |= FP_PT2_HSP;
281 281
282 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) 282 if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT))
283 temp |= FP_PT2_VSP; 283 temp |= FP_PT2_VSP;
284 284
285 write_fp(par, FP_PT2, temp); 285 write_fp(par, FP_PT2, temp);
@@ -610,10 +610,15 @@ static void lx_save_regs(struct lxfb_par *par)
610 memcpy(par->vp, par->vp_regs, sizeof(par->vp)); 610 memcpy(par->vp, par->vp_regs, sizeof(par->vp));
611 memcpy(par->fp, par->vp_regs + VP_FP_START, sizeof(par->fp)); 611 memcpy(par->fp, par->vp_regs + VP_FP_START, sizeof(par->fp));
612 612
613 /* save the palette */ 613 /* save the display controller palette */
614 write_dc(par, DC_PAL_ADDRESS, 0); 614 write_dc(par, DC_PAL_ADDRESS, 0);
615 for (i = 0; i < ARRAY_SIZE(par->pal); i++) 615 for (i = 0; i < ARRAY_SIZE(par->dc_pal); i++)
616 par->pal[i] = read_dc(par, DC_PAL_DATA); 616 par->dc_pal[i] = read_dc(par, DC_PAL_DATA);
617
618 /* save the video processor palette */
619 write_vp(par, VP_PAR, 0);
620 for (i = 0; i < ARRAY_SIZE(par->vp_pal); i++)
621 par->vp_pal[i] = read_vp(par, VP_PDR);
617 622
618 /* save the horizontal filter coefficients */ 623 /* save the horizontal filter coefficients */
619 filt = par->dc[DC_IRQ_FILT_CTL] | DC_IRQ_FILT_CTL_H_FILT_SEL; 624 filt = par->dc[DC_IRQ_FILT_CTL] | DC_IRQ_FILT_CTL_H_FILT_SEL;
@@ -706,8 +711,8 @@ static void lx_restore_display_ctlr(struct lxfb_par *par)
706 711
707 /* restore the palette */ 712 /* restore the palette */
708 write_dc(par, DC_PAL_ADDRESS, 0); 713 write_dc(par, DC_PAL_ADDRESS, 0);
709 for (i = 0; i < ARRAY_SIZE(par->pal); i++) 714 for (i = 0; i < ARRAY_SIZE(par->dc_pal); i++)
710 write_dc(par, DC_PAL_DATA, par->pal[i]); 715 write_dc(par, DC_PAL_DATA, par->dc_pal[i]);
711 716
712 /* restore the horizontal filter coefficients */ 717 /* restore the horizontal filter coefficients */
713 filt = par->dc[DC_IRQ_FILT_CTL] | DC_IRQ_FILT_CTL_H_FILT_SEL; 718 filt = par->dc[DC_IRQ_FILT_CTL] | DC_IRQ_FILT_CTL_H_FILT_SEL;
@@ -751,6 +756,11 @@ static void lx_restore_video_proc(struct lxfb_par *par)
751 } 756 }
752 } 757 }
753 758
759 /* restore video processor palette */
760 write_vp(par, VP_PAR, 0);
761 for (i = 0; i < ARRAY_SIZE(par->vp_pal); i++)
762 write_vp(par, VP_PDR, par->vp_pal[i]);
763
754 /* restore video coeff ram */ 764 /* restore video coeff ram */
755 memcpy(par->vp_regs + VP_VCR, par->vp_coeff, sizeof(par->vp_coeff)); 765 memcpy(par->vp_regs + VP_VCR, par->vp_coeff, sizeof(par->vp_coeff));
756} 766}
diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c
index af8f0f2cc782..4052718eefaa 100644
--- a/drivers/video/hgafb.c
+++ b/drivers/video/hgafb.c
@@ -454,7 +454,6 @@ static int hgafb_blank(int blank_mode, struct fb_info *info)
454/* 454/*
455 * Accel functions 455 * Accel functions
456 */ 456 */
457#ifdef CONFIG_FB_HGA_ACCEL
458static void hgafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) 457static void hgafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
459{ 458{
460 u_int rows, y; 459 u_int rows, y;
@@ -466,7 +465,7 @@ static void hgafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
466 dest = rowaddr(info, y) + (rect->dx >> 3); 465 dest = rowaddr(info, y) + (rect->dx >> 3);
467 switch (rect->rop) { 466 switch (rect->rop) {
468 case ROP_COPY: 467 case ROP_COPY:
469 //fb_memset(dest, rect->color, (rect->width >> 3)); 468 memset_io(dest, rect->color, (rect->width >> 3));
470 break; 469 break;
471 case ROP_XOR: 470 case ROP_XOR:
472 fb_writeb(~(fb_readb(dest)), dest); 471 fb_writeb(~(fb_readb(dest)), dest);
@@ -488,7 +487,7 @@ static void hgafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
488 for (rows = area->height; rows--; ) { 487 for (rows = area->height; rows--; ) {
489 src = rowaddr(info, y1) + (area->sx >> 3); 488 src = rowaddr(info, y1) + (area->sx >> 3);
490 dest = rowaddr(info, y2) + (area->dx >> 3); 489 dest = rowaddr(info, y2) + (area->dx >> 3);
491 //fb_memmove(dest, src, (area->width >> 3)); 490 memmove(dest, src, (area->width >> 3));
492 y1++; 491 y1++;
493 y2++; 492 y2++;
494 } 493 }
@@ -499,7 +498,7 @@ static void hgafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
499 for (rows = area->height; rows--;) { 498 for (rows = area->height; rows--;) {
500 src = rowaddr(info, y1) + (area->sx >> 3); 499 src = rowaddr(info, y1) + (area->sx >> 3);
501 dest = rowaddr(info, y2) + (area->dx >> 3); 500 dest = rowaddr(info, y2) + (area->dx >> 3);
502 //fb_memmove(dest, src, (area->width >> 3)); 501 memmove(dest, src, (area->width >> 3));
503 y1--; 502 y1--;
504 y2--; 503 y2--;
505 } 504 }
@@ -511,20 +510,17 @@ static void hgafb_imageblit(struct fb_info *info, const struct fb_image *image)
511 u8 __iomem *dest; 510 u8 __iomem *dest;
512 u8 *cdat = (u8 *) image->data; 511 u8 *cdat = (u8 *) image->data;
513 u_int rows, y = image->dy; 512 u_int rows, y = image->dy;
513 u_int x;
514 u8 d; 514 u8 d;
515 515
516 for (rows = image->height; rows--; y++) { 516 for (rows = image->height; rows--; y++) {
517 d = *cdat++; 517 for (x = 0; x < image->width; x+= 8) {
518 dest = rowaddr(info, y) + (image->dx >> 3); 518 d = *cdat++;
519 fb_writeb(d, dest); 519 dest = rowaddr(info, y) + ((image->dx + x)>> 3);
520 fb_writeb(d, dest);
521 }
520 } 522 }
521} 523}
522#else /* !CONFIG_FB_HGA_ACCEL */
523#define hgafb_fillrect cfb_fillrect
524#define hgafb_copyarea cfb_copyarea
525#define hgafb_imageblit cfb_imageblit
526#endif /* CONFIG_FB_HGA_ACCEL */
527
528 524
529static struct fb_ops hgafb_ops = { 525static struct fb_ops hgafb_ops = {
530 .owner = THIS_MODULE, 526 .owner = THIS_MODULE,
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c
index cd2c728a809b..7db17d0d8a8c 100644
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -45,8 +45,10 @@ static void i810i2c_setscl(void *data, int state)
45 struct i810fb_par *par = chan->par; 45 struct i810fb_par *par = chan->par;
46 u8 __iomem *mmio = par->mmio_start_virtual; 46 u8 __iomem *mmio = par->mmio_start_virtual;
47 47
48 i810_writel(mmio, chan->ddc_base, (state ? SCL_VAL_OUT : 0) | SCL_DIR | 48 if (state)
49 SCL_DIR_MASK | SCL_VAL_MASK); 49 i810_writel(mmio, chan->ddc_base, SCL_DIR_MASK | SCL_VAL_MASK);
50 else
51 i810_writel(mmio, chan->ddc_base, SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK);
50 i810_readl(mmio, chan->ddc_base); /* flush posted write */ 52 i810_readl(mmio, chan->ddc_base); /* flush posted write */
51} 53}
52 54
@@ -56,8 +58,10 @@ static void i810i2c_setsda(void *data, int state)
56 struct i810fb_par *par = chan->par; 58 struct i810fb_par *par = chan->par;
57 u8 __iomem *mmio = par->mmio_start_virtual; 59 u8 __iomem *mmio = par->mmio_start_virtual;
58 60
59 i810_writel(mmio, chan->ddc_base, (state ? SDA_VAL_OUT : 0) | SDA_DIR | 61 if (state)
60 SDA_DIR_MASK | SDA_VAL_MASK); 62 i810_writel(mmio, chan->ddc_base, SDA_DIR_MASK | SDA_VAL_MASK);
63 else
64 i810_writel(mmio, chan->ddc_base, SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK);
61 i810_readl(mmio, chan->ddc_base); /* flush posted write */ 65 i810_readl(mmio, chan->ddc_base); /* flush posted write */
62} 66}
63 67
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 5c363d026f64..1ab2c2588675 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -53,11 +53,8 @@
53#define LCDC_SIZE 0x04 53#define LCDC_SIZE 0x04
54#define SIZE_XMAX(x) ((((x) >> 4) & 0x3f) << 20) 54#define SIZE_XMAX(x) ((((x) >> 4) & 0x3f) << 20)
55 55
56#ifdef CONFIG_ARCH_MX1 56#define YMAX_MASK (cpu_is_mx1() ? 0x1ff : 0x3ff)
57#define SIZE_YMAX(y) ((y) & 0x1ff) 57#define SIZE_YMAX(y) ((y) & YMAX_MASK)
58#else
59#define SIZE_YMAX(y) ((y) & 0x3ff)
60#endif
61 58
62#define LCDC_VPW 0x08 59#define LCDC_VPW 0x08
63#define VPW_VPW(x) ((x) & 0x3ff) 60#define VPW_VPW(x) ((x) & 0x3ff)
@@ -623,7 +620,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf
623 if (var->right_margin > 255) 620 if (var->right_margin > 255)
624 printk(KERN_ERR "%s: invalid right_margin %d\n", 621 printk(KERN_ERR "%s: invalid right_margin %d\n",
625 info->fix.id, var->right_margin); 622 info->fix.id, var->right_margin);
626 if (var->yres < 1 || var->yres > 511) 623 if (var->yres < 1 || var->yres > YMAX_MASK)
627 printk(KERN_ERR "%s: invalid yres %d\n", 624 printk(KERN_ERR "%s: invalid yres %d\n",
628 info->fix.id, var->yres); 625 info->fix.id, var->yres);
629 if (var->vsync_len > 100) 626 if (var->vsync_len > 100)
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c
index 0a4dbdc1693a..d2bb365f09b3 100644
--- a/drivers/video/modedb.c
+++ b/drivers/video/modedb.c
@@ -274,10 +274,61 @@ static const struct fb_videomode modedb[] = {
274 /* 800x520i @ 50 Hz, 15.625 kHz hsync (PAL RGB) */ 274 /* 800x520i @ 50 Hz, 15.625 kHz hsync (PAL RGB) */
275 NULL, 50, 800, 520, 58823, 144, 64, 72, 28, 80, 5, 275 NULL, 50, 800, 520, 58823, 144, 64, 72, 28, 80, 5,
276 0, FB_VMODE_INTERLACED 276 0, FB_VMODE_INTERLACED
277 }, {
278 /* 864x480 @ 60 Hz, 35.15 kHz hsync */
279 NULL, 60, 864, 480, 27777, 1, 1, 1, 1, 0, 0,
280 0, FB_VMODE_NONINTERLACED
277 }, 281 },
278}; 282};
279 283
280#ifdef CONFIG_FB_MODE_HELPERS 284#ifdef CONFIG_FB_MODE_HELPERS
285const struct fb_videomode cea_modes[64] = {
286 /* #1: 640x480p@59.94/60Hz */
287 [1] = {
288 NULL, 60, 640, 480, 39722, 48, 16, 33, 10, 96, 2, 0, FB_VMODE_NONINTERLACED, 0,
289 },
290 /* #3: 720x480p@59.94/60Hz */
291 [3] = {
292 NULL, 60, 720, 480, 37037, 60, 16, 30, 9, 62, 6, 0, FB_VMODE_NONINTERLACED, 0,
293 },
294 /* #5: 1920x1080i@59.94/60Hz */
295 [5] = {
296 NULL, 60, 1920, 1080, 13763, 148, 88, 15, 2, 44, 5,
297 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_INTERLACED, 0,
298 },
299 /* #7: 720(1440)x480iH@59.94/60Hz */
300 [7] = {
301 NULL, 60, 1440, 480, 18554/*37108*/, 114, 38, 15, 4, 124, 3, 0, FB_VMODE_INTERLACED, 0,
302 },
303 /* #9: 720(1440)x240pH@59.94/60Hz */
304 [9] = {
305 NULL, 60, 1440, 240, 18554, 114, 38, 16, 4, 124, 3, 0, FB_VMODE_NONINTERLACED, 0,
306 },
307 /* #18: 720x576pH@50Hz */
308 [18] = {
309 NULL, 50, 720, 576, 37037, 68, 12, 39, 5, 64, 5, 0, FB_VMODE_NONINTERLACED, 0,
310 },
311 /* #19: 1280x720p@50Hz */
312 [19] = {
313 NULL, 50, 1280, 720, 13468, 220, 440, 20, 5, 40, 5,
314 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, 0,
315 },
316 /* #20: 1920x1080i@50Hz */
317 [20] = {
318 NULL, 50, 1920, 1080, 13480, 148, 528, 15, 5, 528, 5,
319 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_INTERLACED, 0,
320 },
321 /* #32: 1920x1080p@23.98/24Hz */
322 [32] = {
323 NULL, 24, 1920, 1080, 13468, 148, 638, 36, 4, 44, 5,
324 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, 0,
325 },
326 /* #35: (2880)x480p4x@59.94/60Hz */
327 [35] = {
328 NULL, 60, 2880, 480, 9250, 240, 64, 30, 9, 248, 6, 0, FB_VMODE_NONINTERLACED, 0,
329 },
330};
331
281const struct fb_videomode vesa_modes[] = { 332const struct fb_videomode vesa_modes[] = {
282 /* 0 640x350-85 VESA */ 333 /* 0 640x350-85 VESA */
283 { NULL, 85, 640, 350, 31746, 96, 32, 60, 32, 64, 3, 334 { NULL, 85, 640, 350, 31746, 96, 32, 60, 32, 64, 3,
@@ -855,6 +906,7 @@ const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode,
855 abs(cmode->yres - mode->yres); 906 abs(cmode->yres - mode->yres);
856 if (diff > d) { 907 if (diff > d) {
857 diff = d; 908 diff = d;
909 diff_refresh = abs(cmode->refresh - mode->refresh);
858 best = cmode; 910 best = cmode;
859 } else if (diff == d) { 911 } else if (diff == d) {
860 d = abs(cmode->refresh - mode->refresh); 912 d = abs(cmode->refresh - mode->refresh);
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index 7cfc170bce19..cb013919e9ce 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -27,6 +27,7 @@
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29 29
30#include <mach/dma.h>
30#include <mach/hardware.h> 31#include <mach/hardware.h>
31#include <mach/ipu.h> 32#include <mach/ipu.h>
32#include <mach/mx3fb.h> 33#include <mach/mx3fb.h>
@@ -1420,6 +1421,9 @@ static bool chan_filter(struct dma_chan *chan, void *arg)
1420 struct device *dev; 1421 struct device *dev;
1421 struct mx3fb_platform_data *mx3fb_pdata; 1422 struct mx3fb_platform_data *mx3fb_pdata;
1422 1423
1424 if (!imx_dma_is_ipu(chan))
1425 return false;
1426
1423 if (!rq) 1427 if (!rq)
1424 return false; 1428 return false;
1425 1429
@@ -1470,8 +1474,7 @@ static int mx3fb_probe(struct platform_device *pdev)
1470 goto eremap; 1474 goto eremap;
1471 } 1475 }
1472 1476
1473 pr_debug("Remapped %x to %x at %p\n", sdc_reg->start, sdc_reg->end, 1477 pr_debug("Remapped %pR at %p\n", sdc_reg, mx3fb->reg_base);
1474 mx3fb->reg_base);
1475 1478
1476 /* IDMAC interface */ 1479 /* IDMAC interface */
1477 dmaengine_get(); 1480 dmaengine_get();
diff --git a/drivers/video/omap/Kconfig b/drivers/video/omap/Kconfig
index 455c6055325d..083c8fe53e24 100644
--- a/drivers/video/omap/Kconfig
+++ b/drivers/video/omap/Kconfig
@@ -1,7 +1,7 @@
1config FB_OMAP 1config FB_OMAP
2 tristate "OMAP frame buffer support (EXPERIMENTAL)" 2 tristate "OMAP frame buffer support (EXPERIMENTAL)"
3 depends on FB && ARCH_OMAP && (OMAP2_DSS = "n") 3 depends on FB && (OMAP2_DSS = "n")
4 4 depends on ARCH_OMAP1 || ARCH_OMAP2 || ARCH_OMAP3
5 select FB_CFB_FILLRECT 5 select FB_CFB_FILLRECT
6 select FB_CFB_COPYAREA 6 select FB_CFB_COPYAREA
7 select FB_CFB_IMAGEBLIT 7 select FB_CFB_IMAGEBLIT
diff --git a/drivers/video/omap2/vram.c b/drivers/video/omap2/vram.c
index 2fd7e5271be9..9441e2eb3dee 100644
--- a/drivers/video/omap2/vram.c
+++ b/drivers/video/omap2/vram.c
@@ -551,7 +551,7 @@ void __init omap_vram_reserve_sdram_memblock(void)
551 if (!size) 551 if (!size)
552 return; 552 return;
553 553
554 size = PAGE_ALIGN(size); 554 size = ALIGN(size, SZ_2M);
555 555
556 if (paddr) { 556 if (paddr) {
557 if (paddr & ~PAGE_MASK) { 557 if (paddr & ~PAGE_MASK) {
@@ -576,7 +576,7 @@ void __init omap_vram_reserve_sdram_memblock(void)
576 return; 576 return;
577 } 577 }
578 } else { 578 } else {
579 paddr = memblock_alloc(size, PAGE_SIZE); 579 paddr = memblock_alloc(size, SZ_2M);
580 } 580 }
581 581
582 memblock_free(paddr, size); 582 memblock_free(paddr, size);
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index a6247fc081ab..28b1c6c3d8ac 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -410,28 +410,6 @@ s1d13xxxfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
410 ************************************************************/ 410 ************************************************************/
411 411
412/** 412/**
413 * bltbit_wait_bitset - waits for change in register value
414 * @info : framebuffer structure
415 * @bit : value expected in register
416 * @timeout : ...
417 *
418 * waits until value changes INTO bit
419 */
420static u8
421bltbit_wait_bitset(struct fb_info *info, u8 bit, int timeout)
422{
423 while (!(s1d13xxxfb_readreg(info->par, S1DREG_BBLT_CTL0) & bit)) {
424 udelay(10);
425 if (!--timeout) {
426 dbg_blit("wait_bitset timeout\n");
427 break;
428 }
429 }
430
431 return timeout;
432}
433
434/**
435 * bltbit_wait_bitclear - waits for change in register value 413 * bltbit_wait_bitclear - waits for change in register value
436 * @info : frambuffer structure 414 * @info : frambuffer structure
437 * @bit : value currently in register 415 * @bit : value currently in register
@@ -454,34 +432,6 @@ bltbit_wait_bitclear(struct fb_info *info, u8 bit, int timeout)
454 return timeout; 432 return timeout;
455} 433}
456 434
457/**
458 * bltbit_fifo_status - checks the current status of the fifo
459 * @info : framebuffer structure
460 *
461 * returns number of free words in buffer
462 */
463static u8
464bltbit_fifo_status(struct fb_info *info)
465{
466 u8 status;
467
468 status = s1d13xxxfb_readreg(info->par, S1DREG_BBLT_CTL0);
469
470 /* its empty so room for 16 words */
471 if (status & BBLT_FIFO_EMPTY)
472 return 16;
473
474 /* its full so we dont want to add */
475 if (status & BBLT_FIFO_FULL)
476 return 0;
477
478 /* its atleast half full but we can add one atleast */
479 if (status & BBLT_FIFO_NOT_FULL)
480 return 1;
481
482 return 0;
483}
484
485/* 435/*
486 * s1d13xxxfb_bitblt_copyarea - accelerated copyarea function 436 * s1d13xxxfb_bitblt_copyarea - accelerated copyarea function
487 * @info : framebuffer structure 437 * @info : framebuffer structure
diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index f9aca9d13d1b..83ce9a04d872 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -23,6 +23,7 @@
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/pm_runtime.h>
26 27
27#include <mach/map.h> 28#include <mach/map.h>
28#include <plat/regs-fb-v4.h> 29#include <plat/regs-fb-v4.h>
@@ -1013,8 +1014,30 @@ static int s3c_fb_ioctl(struct fb_info *info, unsigned int cmd,
1013 return ret; 1014 return ret;
1014} 1015}
1015 1016
1017static int s3c_fb_open(struct fb_info *info, int user)
1018{
1019 struct s3c_fb_win *win = info->par;
1020 struct s3c_fb *sfb = win->parent;
1021
1022 pm_runtime_get_sync(sfb->dev);
1023
1024 return 0;
1025}
1026
1027static int s3c_fb_release(struct fb_info *info, int user)
1028{
1029 struct s3c_fb_win *win = info->par;
1030 struct s3c_fb *sfb = win->parent;
1031
1032 pm_runtime_put_sync(sfb->dev);
1033
1034 return 0;
1035}
1036
1016static struct fb_ops s3c_fb_ops = { 1037static struct fb_ops s3c_fb_ops = {
1017 .owner = THIS_MODULE, 1038 .owner = THIS_MODULE,
1039 .fb_open = s3c_fb_open,
1040 .fb_release = s3c_fb_release,
1018 .fb_check_var = s3c_fb_check_var, 1041 .fb_check_var = s3c_fb_check_var,
1019 .fb_set_par = s3c_fb_set_par, 1042 .fb_set_par = s3c_fb_set_par,
1020 .fb_blank = s3c_fb_blank, 1043 .fb_blank = s3c_fb_blank,
@@ -1322,6 +1345,8 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
1322 1345
1323 clk_enable(sfb->bus_clk); 1346 clk_enable(sfb->bus_clk);
1324 1347
1348 pm_runtime_enable(sfb->dev);
1349
1325 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1350 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1326 if (!res) { 1351 if (!res) {
1327 dev_err(dev, "failed to find registers\n"); 1352 dev_err(dev, "failed to find registers\n");
@@ -1360,6 +1385,9 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
1360 1385
1361 dev_dbg(dev, "got resources (regs %p), probing windows\n", sfb->regs); 1386 dev_dbg(dev, "got resources (regs %p), probing windows\n", sfb->regs);
1362 1387
1388 platform_set_drvdata(pdev, sfb);
1389 pm_runtime_get_sync(sfb->dev);
1390
1363 /* setup gpio and output polarity controls */ 1391 /* setup gpio and output polarity controls */
1364 1392
1365 pd->setup_gpio(); 1393 pd->setup_gpio();
@@ -1400,6 +1428,7 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
1400 } 1428 }
1401 1429
1402 platform_set_drvdata(pdev, sfb); 1430 platform_set_drvdata(pdev, sfb);
1431 pm_runtime_put_sync(sfb->dev);
1403 1432
1404 return 0; 1433 return 0;
1405 1434
@@ -1434,6 +1463,8 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
1434 struct s3c_fb *sfb = platform_get_drvdata(pdev); 1463 struct s3c_fb *sfb = platform_get_drvdata(pdev);
1435 int win; 1464 int win;
1436 1465
1466 pm_runtime_get_sync(sfb->dev);
1467
1437 for (win = 0; win < S3C_FB_MAX_WIN; win++) 1468 for (win = 0; win < S3C_FB_MAX_WIN; win++)
1438 if (sfb->windows[win]) 1469 if (sfb->windows[win])
1439 s3c_fb_release_win(sfb, sfb->windows[win]); 1470 s3c_fb_release_win(sfb, sfb->windows[win]);
@@ -1450,12 +1481,74 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
1450 1481
1451 kfree(sfb); 1482 kfree(sfb);
1452 1483
1484 pm_runtime_put_sync(sfb->dev);
1485 pm_runtime_disable(sfb->dev);
1486
1453 return 0; 1487 return 0;
1454} 1488}
1455 1489
1456#ifdef CONFIG_PM 1490#ifdef CONFIG_PM
1457static int s3c_fb_suspend(struct platform_device *pdev, pm_message_t state) 1491static int s3c_fb_suspend(struct device *dev)
1492{
1493 struct platform_device *pdev = to_platform_device(dev);
1494 struct s3c_fb *sfb = platform_get_drvdata(pdev);
1495 struct s3c_fb_win *win;
1496 int win_no;
1497
1498 for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) {
1499 win = sfb->windows[win_no];
1500 if (!win)
1501 continue;
1502
1503 /* use the blank function to push into power-down */
1504 s3c_fb_blank(FB_BLANK_POWERDOWN, win->fbinfo);
1505 }
1506
1507 clk_disable(sfb->bus_clk);
1508 return 0;
1509}
1510
1511static int s3c_fb_resume(struct device *dev)
1512{
1513 struct platform_device *pdev = to_platform_device(dev);
1514 struct s3c_fb *sfb = platform_get_drvdata(pdev);
1515 struct s3c_fb_platdata *pd = sfb->pdata;
1516 struct s3c_fb_win *win;
1517 int win_no;
1518
1519 clk_enable(sfb->bus_clk);
1520
1521 /* setup registers */
1522 writel(pd->vidcon1, sfb->regs + VIDCON1);
1523
1524 /* zero all windows before we do anything */
1525 for (win_no = 0; win_no < sfb->variant.nr_windows; win_no++)
1526 s3c_fb_clear_win(sfb, win_no);
1527
1528 for (win_no = 0; win_no < sfb->variant.nr_windows - 1; win_no++) {
1529 void __iomem *regs = sfb->regs + sfb->variant.keycon;
1530
1531 regs += (win_no * 8);
1532 writel(0xffffff, regs + WKEYCON0);
1533 writel(0xffffff, regs + WKEYCON1);
1534 }
1535
1536 /* restore framebuffers */
1537 for (win_no = 0; win_no < S3C_FB_MAX_WIN; win_no++) {
1538 win = sfb->windows[win_no];
1539 if (!win)
1540 continue;
1541
1542 dev_dbg(&pdev->dev, "resuming window %d\n", win_no);
1543 s3c_fb_set_par(win->fbinfo);
1544 }
1545
1546 return 0;
1547}
1548
1549int s3c_fb_runtime_suspend(struct device *dev)
1458{ 1550{
1551 struct platform_device *pdev = to_platform_device(dev);
1459 struct s3c_fb *sfb = platform_get_drvdata(pdev); 1552 struct s3c_fb *sfb = platform_get_drvdata(pdev);
1460 struct s3c_fb_win *win; 1553 struct s3c_fb_win *win;
1461 int win_no; 1554 int win_no;
@@ -1473,8 +1566,9 @@ static int s3c_fb_suspend(struct platform_device *pdev, pm_message_t state)
1473 return 0; 1566 return 0;
1474} 1567}
1475 1568
1476static int s3c_fb_resume(struct platform_device *pdev) 1569int s3c_fb_runtime_resume(struct device *dev)
1477{ 1570{
1571 struct platform_device *pdev = to_platform_device(dev);
1478 struct s3c_fb *sfb = platform_get_drvdata(pdev); 1572 struct s3c_fb *sfb = platform_get_drvdata(pdev);
1479 struct s3c_fb_platdata *pd = sfb->pdata; 1573 struct s3c_fb_platdata *pd = sfb->pdata;
1480 struct s3c_fb_win *win; 1574 struct s3c_fb_win *win;
@@ -1509,9 +1603,12 @@ static int s3c_fb_resume(struct platform_device *pdev)
1509 1603
1510 return 0; 1604 return 0;
1511} 1605}
1606
1512#else 1607#else
1513#define s3c_fb_suspend NULL 1608#define s3c_fb_suspend NULL
1514#define s3c_fb_resume NULL 1609#define s3c_fb_resume NULL
1610#define s3c_fb_runtime_suspend NULL
1611#define s3c_fb_runtime_resume NULL
1515#endif 1612#endif
1516 1613
1517 1614
@@ -1710,15 +1807,21 @@ static struct platform_device_id s3c_fb_driver_ids[] = {
1710}; 1807};
1711MODULE_DEVICE_TABLE(platform, s3c_fb_driver_ids); 1808MODULE_DEVICE_TABLE(platform, s3c_fb_driver_ids);
1712 1809
1810static const struct dev_pm_ops s3cfb_pm_ops = {
1811 .suspend = s3c_fb_suspend,
1812 .resume = s3c_fb_resume,
1813 .runtime_suspend = s3c_fb_runtime_suspend,
1814 .runtime_resume = s3c_fb_runtime_resume,
1815};
1816
1713static struct platform_driver s3c_fb_driver = { 1817static struct platform_driver s3c_fb_driver = {
1714 .probe = s3c_fb_probe, 1818 .probe = s3c_fb_probe,
1715 .remove = __devexit_p(s3c_fb_remove), 1819 .remove = __devexit_p(s3c_fb_remove),
1716 .suspend = s3c_fb_suspend,
1717 .resume = s3c_fb_resume,
1718 .id_table = s3c_fb_driver_ids, 1820 .id_table = s3c_fb_driver_ids,
1719 .driver = { 1821 .driver = {
1720 .name = "s3c-fb", 1822 .name = "s3c-fb",
1721 .owner = THIS_MODULE, 1823 .owner = THIS_MODULE,
1824 .pm = &s3cfb_pm_ops,
1722 }, 1825 },
1723}; 1826};
1724 1827
diff --git a/drivers/video/sh_mipi_dsi.c b/drivers/video/sh_mipi_dsi.c
index 3f3d431033ca..24640c8458ab 100644
--- a/drivers/video/sh_mipi_dsi.c
+++ b/drivers/video/sh_mipi_dsi.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/pm_runtime.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/string.h> 18#include <linux/string.h>
18#include <linux/types.h> 19#include <linux/types.h>
@@ -21,18 +22,40 @@
21#include <video/sh_mipi_dsi.h> 22#include <video/sh_mipi_dsi.h>
22#include <video/sh_mobile_lcdc.h> 23#include <video/sh_mobile_lcdc.h>
23 24
24#define CMTSRTCTR 0x80d0 25#define SYSCTRL 0x0000
25#define CMTSRTREQ 0x8070 26#define SYSCONF 0x0004
26 27#define TIMSET 0x0008
28#define RESREQSET0 0x0018
29#define RESREQSET1 0x001c
30#define HSTTOVSET 0x0020
31#define LPRTOVSET 0x0024
32#define TATOVSET 0x0028
33#define PRTOVSET 0x002c
34#define DSICTRL 0x0030
27#define DSIINTE 0x0060 35#define DSIINTE 0x0060
36#define PHYCTRL 0x0070
37
38/* relative to linkbase */
39#define DTCTR 0x0000
40#define VMCTR1 0x0020
41#define VMCTR2 0x0024
42#define VMLEN1 0x0028
43#define CMTSRTREQ 0x0070
44#define CMTSRTCTR 0x00d0
28 45
29/* E.g., sh7372 has 2 MIPI-DSIs - one for each LCDC */ 46/* E.g., sh7372 has 2 MIPI-DSIs - one for each LCDC */
30#define MAX_SH_MIPI_DSI 2 47#define MAX_SH_MIPI_DSI 2
31 48
32struct sh_mipi { 49struct sh_mipi {
33 void __iomem *base; 50 void __iomem *base;
51 void __iomem *linkbase;
34 struct clk *dsit_clk; 52 struct clk *dsit_clk;
35 struct clk *dsip_clk; 53 struct clk *dsip_clk;
54 struct device *dev;
55
56 void *next_board_data;
57 void (*next_display_on)(void *board_data, struct fb_info *info);
58 void (*next_display_off)(void *board_data);
36}; 59};
37 60
38static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI]; 61static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI];
@@ -55,10 +78,10 @@ static int sh_mipi_send_short(struct sh_mipi *mipi, u8 dsi_cmd,
55 int cnt = 100; 78 int cnt = 100;
56 79
57 /* transmit a short packet to LCD panel */ 80 /* transmit a short packet to LCD panel */
58 iowrite32(1 | data, mipi->base + 0x80d0); /* CMTSRTCTR */ 81 iowrite32(1 | data, mipi->linkbase + CMTSRTCTR);
59 iowrite32(1, mipi->base + 0x8070); /* CMTSRTREQ */ 82 iowrite32(1, mipi->linkbase + CMTSRTREQ);
60 83
61 while ((ioread32(mipi->base + 0x8070) & 1) && --cnt) 84 while ((ioread32(mipi->linkbase + CMTSRTREQ) & 1) && --cnt)
62 udelay(1); 85 udelay(1);
63 86
64 return cnt ? 0 : -ETIMEDOUT; 87 return cnt ? 0 : -ETIMEDOUT;
@@ -90,7 +113,7 @@ static void sh_mipi_dsi_enable(struct sh_mipi *mipi, bool enable)
90 * enable LCDC data tx, transition to LPS after completion of each HS 113 * enable LCDC data tx, transition to LPS after completion of each HS
91 * packet 114 * packet
92 */ 115 */
93 iowrite32(0x00000002 | enable, mipi->base + 0x8000); /* DTCTR */ 116 iowrite32(0x00000002 | enable, mipi->linkbase + DTCTR);
94} 117}
95 118
96static void sh_mipi_shutdown(struct platform_device *pdev) 119static void sh_mipi_shutdown(struct platform_device *pdev)
@@ -104,14 +127,22 @@ static void mipi_display_on(void *arg, struct fb_info *info)
104{ 127{
105 struct sh_mipi *mipi = arg; 128 struct sh_mipi *mipi = arg;
106 129
130 pm_runtime_get_sync(mipi->dev);
107 sh_mipi_dsi_enable(mipi, true); 131 sh_mipi_dsi_enable(mipi, true);
132
133 if (mipi->next_display_on)
134 mipi->next_display_on(mipi->next_board_data, info);
108} 135}
109 136
110static void mipi_display_off(void *arg) 137static void mipi_display_off(void *arg)
111{ 138{
112 struct sh_mipi *mipi = arg; 139 struct sh_mipi *mipi = arg;
113 140
141 if (mipi->next_display_off)
142 mipi->next_display_off(mipi->next_board_data);
143
114 sh_mipi_dsi_enable(mipi, false); 144 sh_mipi_dsi_enable(mipi, false);
145 pm_runtime_put(mipi->dev);
115} 146}
116 147
117static int __init sh_mipi_setup(struct sh_mipi *mipi, 148static int __init sh_mipi_setup(struct sh_mipi *mipi,
@@ -119,8 +150,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
119{ 150{
120 void __iomem *base = mipi->base; 151 void __iomem *base = mipi->base;
121 struct sh_mobile_lcdc_chan_cfg *ch = pdata->lcd_chan; 152 struct sh_mobile_lcdc_chan_cfg *ch = pdata->lcd_chan;
122 u32 pctype, datatype, pixfmt; 153 u32 pctype, datatype, pixfmt, linelength, vmctr2 = 0x00e00000;
123 u32 linelength;
124 bool yuv; 154 bool yuv;
125 155
126 /* 156 /*
@@ -223,10 +253,10 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
223 return -EINVAL; 253 return -EINVAL;
224 254
225 /* reset DSI link */ 255 /* reset DSI link */
226 iowrite32(0x00000001, base); /* SYSCTRL */ 256 iowrite32(0x00000001, base + SYSCTRL);
227 /* Hold reset for 100 cycles of the slowest of bus, HS byte and LP clock */ 257 /* Hold reset for 100 cycles of the slowest of bus, HS byte and LP clock */
228 udelay(50); 258 udelay(50);
229 iowrite32(0x00000000, base); /* SYSCTRL */ 259 iowrite32(0x00000000, base + SYSCTRL);
230 260
231 /* setup DSI link */ 261 /* setup DSI link */
232 262
@@ -238,7 +268,7 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
238 * ECC check enable 268 * ECC check enable
239 * additionally enable first two lanes 269 * additionally enable first two lanes
240 */ 270 */
241 iowrite32(0x00003703, base + 0x04); /* SYSCONF */ 271 iowrite32(0x00003703, base + SYSCONF);
242 /* 272 /*
243 * T_wakeup = 0x7000 273 * T_wakeup = 0x7000
244 * T_hs-trail = 3 274 * T_hs-trail = 3
@@ -246,28 +276,28 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
246 * T_clk-trail = 3 276 * T_clk-trail = 3
247 * T_clk-prepare = 2 277 * T_clk-prepare = 2
248 */ 278 */
249 iowrite32(0x70003332, base + 0x08); /* TIMSET */ 279 iowrite32(0x70003332, base + TIMSET);
250 /* no responses requested */ 280 /* no responses requested */
251 iowrite32(0x00000000, base + 0x18); /* RESREQSET0 */ 281 iowrite32(0x00000000, base + RESREQSET0);
252 /* request response to packets of type 0x28 */ 282 /* request response to packets of type 0x28 */
253 iowrite32(0x00000100, base + 0x1c); /* RESREQSET1 */ 283 iowrite32(0x00000100, base + RESREQSET1);
254 /* High-speed transmission timeout, default 0xffffffff */ 284 /* High-speed transmission timeout, default 0xffffffff */
255 iowrite32(0x0fffffff, base + 0x20); /* HSTTOVSET */ 285 iowrite32(0x0fffffff, base + HSTTOVSET);
256 /* LP reception timeout, default 0xffffffff */ 286 /* LP reception timeout, default 0xffffffff */
257 iowrite32(0x0fffffff, base + 0x24); /* LPRTOVSET */ 287 iowrite32(0x0fffffff, base + LPRTOVSET);
258 /* Turn-around timeout, default 0xffffffff */ 288 /* Turn-around timeout, default 0xffffffff */
259 iowrite32(0x0fffffff, base + 0x28); /* TATOVSET */ 289 iowrite32(0x0fffffff, base + TATOVSET);
260 /* Peripheral reset timeout, default 0xffffffff */ 290 /* Peripheral reset timeout, default 0xffffffff */
261 iowrite32(0x0fffffff, base + 0x2c); /* PRTOVSET */ 291 iowrite32(0x0fffffff, base + PRTOVSET);
262 /* Enable timeout counters */ 292 /* Enable timeout counters */
263 iowrite32(0x00000f00, base + 0x30); /* DSICTRL */ 293 iowrite32(0x00000f00, base + DSICTRL);
264 /* Interrupts not used, disable all */ 294 /* Interrupts not used, disable all */
265 iowrite32(0, base + DSIINTE); 295 iowrite32(0, base + DSIINTE);
266 /* DSI-Tx bias on */ 296 /* DSI-Tx bias on */
267 iowrite32(0x00000001, base + 0x70); /* PHYCTRL */ 297 iowrite32(0x00000001, base + PHYCTRL);
268 udelay(200); 298 udelay(200);
269 /* Deassert resets, power on, set multiplier */ 299 /* Deassert resets, power on, set multiplier */
270 iowrite32(0x03070b01, base + 0x70); /* PHYCTRL */ 300 iowrite32(0x03070b01, base + PHYCTRL);
271 301
272 /* setup l-bridge */ 302 /* setup l-bridge */
273 303
@@ -275,20 +305,28 @@ static int __init sh_mipi_setup(struct sh_mipi *mipi,
275 * Enable transmission of all packets, 305 * Enable transmission of all packets,
276 * transmit LPS after each HS packet completion 306 * transmit LPS after each HS packet completion
277 */ 307 */
278 iowrite32(0x00000006, base + 0x8000); /* DTCTR */ 308 iowrite32(0x00000006, mipi->linkbase + DTCTR);
279 /* VSYNC width = 2 (<< 17) */ 309 /* VSYNC width = 2 (<< 17) */
280 iowrite32(0x00040000 | (pctype << 12) | datatype, base + 0x8020); /* VMCTR1 */ 310 iowrite32((ch->lcd_cfg[0].vsync_len << pdata->vsynw_offset) |
311 (pdata->clksrc << 16) | (pctype << 12) | datatype,
312 mipi->linkbase + VMCTR1);
313
281 /* 314 /*
282 * Non-burst mode with sync pulses: VSE and HSE are output, 315 * Non-burst mode with sync pulses: VSE and HSE are output,
283 * HSA period allowed, no commands in LP 316 * HSA period allowed, no commands in LP
284 */ 317 */
285 iowrite32(0x00e00000, base + 0x8024); /* VMCTR2 */ 318 if (pdata->flags & SH_MIPI_DSI_HSABM)
319 vmctr2 |= 0x20;
320 if (pdata->flags & SH_MIPI_DSI_HSPBM)
321 vmctr2 |= 0x10;
322 iowrite32(vmctr2, mipi->linkbase + VMCTR2);
323
286 /* 324 /*
287 * 0x660 = 1632 bytes per line (RGB24, 544 pixels: see 325 * 0x660 = 1632 bytes per line (RGB24, 544 pixels: see
288 * sh_mobile_lcdc_info.ch[0].lcd_cfg[0].xres), HSALEN = 1 - default 326 * sh_mobile_lcdc_info.ch[0].lcd_cfg[0].xres), HSALEN = 1 - default
289 * (unused, since VMCTR2[HSABM] = 0) 327 * (unused if VMCTR2[HSABM] = 0)
290 */ 328 */
291 iowrite32(1 | (linelength << 16), base + 0x8028); /* VMLEN1 */ 329 iowrite32(1 | (linelength << 16), mipi->linkbase + VMLEN1);
292 330
293 msleep(5); 331 msleep(5);
294 332
@@ -321,11 +359,12 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
321 struct sh_mipi *mipi; 359 struct sh_mipi *mipi;
322 struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data; 360 struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data;
323 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 361 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
362 struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
324 unsigned long rate, f_current; 363 unsigned long rate, f_current;
325 int idx = pdev->id, ret; 364 int idx = pdev->id, ret;
326 char dsip_clk[] = "dsi.p_clk"; 365 char dsip_clk[] = "dsi.p_clk";
327 366
328 if (!res || idx >= ARRAY_SIZE(mipi_dsi) || !pdata) 367 if (!res || !res2 || idx >= ARRAY_SIZE(mipi_dsi) || !pdata)
329 return -ENODEV; 368 return -ENODEV;
330 369
331 mutex_lock(&array_lock); 370 mutex_lock(&array_lock);
@@ -356,6 +395,20 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
356 goto emap; 395 goto emap;
357 } 396 }
358 397
398 if (!request_mem_region(res2->start, resource_size(res2), pdev->name)) {
399 dev_err(&pdev->dev, "MIPI register region 2 already claimed\n");
400 ret = -EBUSY;
401 goto ereqreg2;
402 }
403
404 mipi->linkbase = ioremap(res2->start, resource_size(res2));
405 if (!mipi->linkbase) {
406 ret = -ENOMEM;
407 goto emap2;
408 }
409
410 mipi->dev = &pdev->dev;
411
359 mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk"); 412 mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk");
360 if (IS_ERR(mipi->dsit_clk)) { 413 if (IS_ERR(mipi->dsit_clk)) {
361 ret = PTR_ERR(mipi->dsit_clk); 414 ret = PTR_ERR(mipi->dsit_clk);
@@ -405,6 +458,9 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
405 458
406 mipi_dsi[idx] = mipi; 459 mipi_dsi[idx] = mipi;
407 460
461 pm_runtime_enable(&pdev->dev);
462 pm_runtime_resume(&pdev->dev);
463
408 ret = sh_mipi_setup(mipi, pdata); 464 ret = sh_mipi_setup(mipi, pdata);
409 if (ret < 0) 465 if (ret < 0)
410 goto emipisetup; 466 goto emipisetup;
@@ -412,15 +468,22 @@ static int __init sh_mipi_probe(struct platform_device *pdev)
412 mutex_unlock(&array_lock); 468 mutex_unlock(&array_lock);
413 platform_set_drvdata(pdev, mipi); 469 platform_set_drvdata(pdev, mipi);
414 470
471 /* Save original LCDC callbacks */
472 mipi->next_board_data = pdata->lcd_chan->board_cfg.board_data;
473 mipi->next_display_on = pdata->lcd_chan->board_cfg.display_on;
474 mipi->next_display_off = pdata->lcd_chan->board_cfg.display_off;
475
415 /* Set up LCDC callbacks */ 476 /* Set up LCDC callbacks */
416 pdata->lcd_chan->board_cfg.board_data = mipi; 477 pdata->lcd_chan->board_cfg.board_data = mipi;
417 pdata->lcd_chan->board_cfg.display_on = mipi_display_on; 478 pdata->lcd_chan->board_cfg.display_on = mipi_display_on;
418 pdata->lcd_chan->board_cfg.display_off = mipi_display_off; 479 pdata->lcd_chan->board_cfg.display_off = mipi_display_off;
480 pdata->lcd_chan->board_cfg.owner = THIS_MODULE;
419 481
420 return 0; 482 return 0;
421 483
422emipisetup: 484emipisetup:
423 mipi_dsi[idx] = NULL; 485 mipi_dsi[idx] = NULL;
486 pm_runtime_disable(&pdev->dev);
424 clk_disable(mipi->dsip_clk); 487 clk_disable(mipi->dsip_clk);
425eclkpon: 488eclkpon:
426 clk_disable(mipi->dsit_clk); 489 clk_disable(mipi->dsit_clk);
@@ -431,6 +494,10 @@ eclkpget:
431esettrate: 494esettrate:
432 clk_put(mipi->dsit_clk); 495 clk_put(mipi->dsit_clk);
433eclktget: 496eclktget:
497 iounmap(mipi->linkbase);
498emap2:
499 release_mem_region(res2->start, resource_size(res2));
500ereqreg2:
434 iounmap(mipi->base); 501 iounmap(mipi->base);
435emap: 502emap:
436 release_mem_region(res->start, resource_size(res)); 503 release_mem_region(res->start, resource_size(res));
@@ -447,6 +514,7 @@ static int __exit sh_mipi_remove(struct platform_device *pdev)
447{ 514{
448 struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data; 515 struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data;
449 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 516 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
517 struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
450 struct sh_mipi *mipi = platform_get_drvdata(pdev); 518 struct sh_mipi *mipi = platform_get_drvdata(pdev);
451 int i, ret; 519 int i, ret;
452 520
@@ -467,14 +535,19 @@ static int __exit sh_mipi_remove(struct platform_device *pdev)
467 if (ret < 0) 535 if (ret < 0)
468 return ret; 536 return ret;
469 537
538 pdata->lcd_chan->board_cfg.owner = NULL;
470 pdata->lcd_chan->board_cfg.display_on = NULL; 539 pdata->lcd_chan->board_cfg.display_on = NULL;
471 pdata->lcd_chan->board_cfg.display_off = NULL; 540 pdata->lcd_chan->board_cfg.display_off = NULL;
472 pdata->lcd_chan->board_cfg.board_data = NULL; 541 pdata->lcd_chan->board_cfg.board_data = NULL;
473 542
543 pm_runtime_disable(&pdev->dev);
474 clk_disable(mipi->dsip_clk); 544 clk_disable(mipi->dsip_clk);
475 clk_disable(mipi->dsit_clk); 545 clk_disable(mipi->dsit_clk);
476 clk_put(mipi->dsit_clk); 546 clk_put(mipi->dsit_clk);
477 clk_put(mipi->dsip_clk); 547 clk_put(mipi->dsip_clk);
548 iounmap(mipi->linkbase);
549 if (res2)
550 release_mem_region(res2->start, resource_size(res2));
478 iounmap(mipi->base); 551 iounmap(mipi->base);
479 if (res) 552 if (res)
480 release_mem_region(res->start, resource_size(res)); 553 release_mem_region(res->start, resource_size(res));
diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index d7df10315d8d..76f9fac9020f 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -209,7 +209,11 @@ enum hotplug_state {
209struct sh_hdmi { 209struct sh_hdmi {
210 void __iomem *base; 210 void __iomem *base;
211 enum hotplug_state hp_state; /* hot-plug status */ 211 enum hotplug_state hp_state; /* hot-plug status */
212 bool preprogrammed_mode; /* use a pre-programmed VIC or the external mode */ 212 u8 preprogrammed_vic; /* use a pre-programmed VIC or
213 the external mode */
214 u8 edid_block_addr;
215 u8 edid_segment_nr;
216 u8 edid_blocks;
213 struct clk *hdmi_clk; 217 struct clk *hdmi_clk;
214 struct device *dev; 218 struct device *dev;
215 struct fb_info *info; 219 struct fb_info *info;
@@ -342,7 +346,7 @@ static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi)
342 hdmi_write(hdmi, var->vsync_len, HDMI_EXTERNAL_V_DURATION); 346 hdmi_write(hdmi, var->vsync_len, HDMI_EXTERNAL_V_DURATION);
343 347
344 /* Set bit 0 of HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS here for external mode */ 348 /* Set bit 0 of HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS here for external mode */
345 if (!hdmi->preprogrammed_mode) 349 if (!hdmi->preprogrammed_vic)
346 hdmi_write(hdmi, sync | 1 | (voffset << 4), 350 hdmi_write(hdmi, sync | 1 | (voffset << 4),
347 HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS); 351 HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS);
348} 352}
@@ -466,7 +470,18 @@ static void sh_hdmi_audio_config(struct sh_hdmi *hdmi)
466 */ 470 */
467static void sh_hdmi_phy_config(struct sh_hdmi *hdmi) 471static void sh_hdmi_phy_config(struct sh_hdmi *hdmi)
468{ 472{
469 if (hdmi->var.yres > 480) { 473 if (hdmi->var.pixclock < 10000) {
474 /* for 1080p8bit 148MHz */
475 hdmi_write(hdmi, 0x1d, HDMI_SLIPHDMIT_PARAM_SETTINGS_1);
476 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_2);
477 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_3);
478 hdmi_write(hdmi, 0x4c, HDMI_SLIPHDMIT_PARAM_SETTINGS_5);
479 hdmi_write(hdmi, 0x1e, HDMI_SLIPHDMIT_PARAM_SETTINGS_6);
480 hdmi_write(hdmi, 0x48, HDMI_SLIPHDMIT_PARAM_SETTINGS_7);
481 hdmi_write(hdmi, 0x0e, HDMI_SLIPHDMIT_PARAM_SETTINGS_8);
482 hdmi_write(hdmi, 0x25, HDMI_SLIPHDMIT_PARAM_SETTINGS_9);
483 hdmi_write(hdmi, 0x04, HDMI_SLIPHDMIT_PARAM_SETTINGS_10);
484 } else if (hdmi->var.pixclock < 30000) {
470 /* 720p, 8bit, 74.25MHz. Might need to be adjusted for other formats */ 485 /* 720p, 8bit, 74.25MHz. Might need to be adjusted for other formats */
471 /* 486 /*
472 * [1:0] Speed_A 487 * [1:0] Speed_A
@@ -565,13 +580,11 @@ static void sh_hdmi_avi_infoframe_setup(struct sh_hdmi *hdmi)
565 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB3); 580 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB3);
566 581
567 /* 582 /*
568 * VIC = 1280 x 720p: ignored if external config is used 583 * VIC should be ignored if external config is used, so, we could just use 0,
569 * Send 2 for 720 x 480p, 16 for 1080p, ignored in external mode 584 * but play safe and use a valid value in any case just in case
570 */ 585 */
571 if (hdmi->var.yres == 1080 && hdmi->var.xres == 1920) 586 if (hdmi->preprogrammed_vic)
572 vic = 16; 587 vic = hdmi->preprogrammed_vic;
573 else if (hdmi->var.yres == 480 && hdmi->var.xres == 720)
574 vic = 2;
575 else 588 else
576 vic = 4; 589 vic = 4;
577 hdmi_write(hdmi, vic, HDMI_CTRL_PKT_BUF_ACCESS_PB4); 590 hdmi_write(hdmi, vic, HDMI_CTRL_PKT_BUF_ACCESS_PB4);
@@ -685,11 +698,21 @@ static void sh_hdmi_configure(struct sh_hdmi *hdmi)
685} 698}
686 699
687static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi, 700static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi,
688 const struct fb_videomode *mode) 701 const struct fb_videomode *mode,
702 unsigned long *hdmi_rate, unsigned long *parent_rate)
689{ 703{
690 long target = PICOS2KHZ(mode->pixclock) * 1000, 704 unsigned long target = PICOS2KHZ(mode->pixclock) * 1000, rate_error;
691 rate = clk_round_rate(hdmi->hdmi_clk, target); 705 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
692 unsigned long rate_error = rate > 0 ? abs(rate - target) : ULONG_MAX; 706
707 *hdmi_rate = clk_round_rate(hdmi->hdmi_clk, target);
708 if ((long)*hdmi_rate < 0)
709 *hdmi_rate = clk_get_rate(hdmi->hdmi_clk);
710
711 rate_error = (long)*hdmi_rate > 0 ? abs(*hdmi_rate - target) : ULONG_MAX;
712 if (rate_error && pdata->clk_optimize_parent)
713 rate_error = pdata->clk_optimize_parent(target, hdmi_rate, parent_rate);
714 else if (clk_get_parent(hdmi->hdmi_clk))
715 *parent_rate = clk_get_rate(clk_get_parent(hdmi->hdmi_clk));
693 716
694 dev_dbg(hdmi->dev, "%u-%u-%u-%u x %u-%u-%u-%u\n", 717 dev_dbg(hdmi->dev, "%u-%u-%u-%u x %u-%u-%u-%u\n",
695 mode->left_margin, mode->xres, 718 mode->left_margin, mode->xres,
@@ -697,14 +720,15 @@ static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi,
697 mode->upper_margin, mode->yres, 720 mode->upper_margin, mode->yres,
698 mode->lower_margin, mode->vsync_len); 721 mode->lower_margin, mode->vsync_len);
699 722
700 dev_dbg(hdmi->dev, "\t@%lu(+/-%lu)Hz, e=%lu / 1000, r=%uHz\n", target, 723 dev_dbg(hdmi->dev, "\t@%lu(+/-%lu)Hz, e=%lu / 1000, r=%uHz, p=%luHz\n", target,
701 rate_error, rate_error ? 10000 / (10 * target / rate_error) : 0, 724 rate_error, rate_error ? 10000 / (10 * target / rate_error) : 0,
702 mode->refresh); 725 mode->refresh, *parent_rate);
703 726
704 return rate_error; 727 return rate_error;
705} 728}
706 729
707static int sh_hdmi_read_edid(struct sh_hdmi *hdmi) 730static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate,
731 unsigned long *parent_rate)
708{ 732{
709 struct fb_var_screeninfo tmpvar; 733 struct fb_var_screeninfo tmpvar;
710 struct fb_var_screeninfo *var = &tmpvar; 734 struct fb_var_screeninfo *var = &tmpvar;
@@ -735,7 +759,38 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi)
735 printk(KERN_CONT "\n"); 759 printk(KERN_CONT "\n");
736#endif 760#endif
737 761
738 fb_edid_to_monspecs(edid, &hdmi->monspec); 762 if (!hdmi->edid_blocks) {
763 fb_edid_to_monspecs(edid, &hdmi->monspec);
764 hdmi->edid_blocks = edid[126] + 1;
765
766 dev_dbg(hdmi->dev, "%d main modes, %d extension blocks\n",
767 hdmi->monspec.modedb_len, hdmi->edid_blocks - 1);
768 } else {
769 dev_dbg(hdmi->dev, "Extension %u detected, DTD start %u\n",
770 edid[0], edid[2]);
771 fb_edid_add_monspecs(edid, &hdmi->monspec);
772 }
773
774 if (hdmi->edid_blocks > hdmi->edid_segment_nr * 2 +
775 (hdmi->edid_block_addr >> 7) + 1) {
776 /* More blocks to read */
777 if (hdmi->edid_block_addr) {
778 hdmi->edid_block_addr = 0;
779 hdmi->edid_segment_nr++;
780 } else {
781 hdmi->edid_block_addr = 0x80;
782 }
783 /* Set EDID word address */
784 hdmi_write(hdmi, hdmi->edid_block_addr, HDMI_EDID_WORD_ADDRESS);
785 /* Enable EDID interrupt */
786 hdmi_write(hdmi, 0xC6, HDMI_INTERRUPT_MASK_1);
787 /* Set EDID segment pointer - starts reading EDID */
788 hdmi_write(hdmi, hdmi->edid_segment_nr, HDMI_EDID_SEGMENT_POINTER);
789 return -EAGAIN;
790 }
791
792 /* All E-EDID blocks ready */
793 dev_dbg(hdmi->dev, "%d main and extended modes\n", hdmi->monspec.modedb_len);
739 794
740 fb_get_options("sh_mobile_lcdc", &forced); 795 fb_get_options("sh_mobile_lcdc", &forced);
741 if (forced && *forced) { 796 if (forced && *forced) {
@@ -754,11 +809,14 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi)
754 for (i = 0, mode = hdmi->monspec.modedb; 809 for (i = 0, mode = hdmi->monspec.modedb;
755 f_width && f_height && i < hdmi->monspec.modedb_len && !exact_match; 810 f_width && f_height && i < hdmi->monspec.modedb_len && !exact_match;
756 i++, mode++) { 811 i++, mode++) {
757 unsigned long rate_error = sh_hdmi_rate_error(hdmi, mode); 812 unsigned long rate_error;
758 813
759 /* No interest in unmatching modes */ 814 /* No interest in unmatching modes */
760 if (f_width != mode->xres || f_height != mode->yres) 815 if (f_width != mode->xres || f_height != mode->yres)
761 continue; 816 continue;
817
818 rate_error = sh_hdmi_rate_error(hdmi, mode, hdmi_rate, parent_rate);
819
762 if (f_refresh == mode->refresh || (!f_refresh && !rate_error)) 820 if (f_refresh == mode->refresh || (!f_refresh && !rate_error))
763 /* 821 /*
764 * Exact match if either the refresh rate matches or it 822 * Exact match if either the refresh rate matches or it
@@ -802,7 +860,7 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi)
802 860
803 if (modelist) { 861 if (modelist) {
804 found = &modelist->mode; 862 found = &modelist->mode;
805 found_rate_error = sh_hdmi_rate_error(hdmi, found); 863 found_rate_error = sh_hdmi_rate_error(hdmi, found, hdmi_rate, parent_rate);
806 } 864 }
807 } 865 }
808 866
@@ -810,16 +868,27 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi)
810 if (!found) 868 if (!found)
811 return -ENXIO; 869 return -ENXIO;
812 870
813 dev_info(hdmi->dev, "Using %s mode %ux%u@%uHz (%luHz), clock error %luHz\n", 871 if (found->xres == 640 && found->yres == 480 && found->refresh == 60)
814 modelist ? "default" : "EDID", found->xres, found->yres, 872 hdmi->preprogrammed_vic = 1;
815 found->refresh, PICOS2KHZ(found->pixclock) * 1000, found_rate_error); 873 else if (found->xres == 720 && found->yres == 480 && found->refresh == 60)
816 874 hdmi->preprogrammed_vic = 2;
817 if ((found->xres == 720 && found->yres == 480) || 875 else if (found->xres == 720 && found->yres == 576 && found->refresh == 50)
818 (found->xres == 1280 && found->yres == 720) || 876 hdmi->preprogrammed_vic = 17;
819 (found->xres == 1920 && found->yres == 1080)) 877 else if (found->xres == 1280 && found->yres == 720 && found->refresh == 60)
820 hdmi->preprogrammed_mode = true; 878 hdmi->preprogrammed_vic = 4;
879 else if (found->xres == 1920 && found->yres == 1080 && found->refresh == 24)
880 hdmi->preprogrammed_vic = 32;
881 else if (found->xres == 1920 && found->yres == 1080 && found->refresh == 50)
882 hdmi->preprogrammed_vic = 31;
883 else if (found->xres == 1920 && found->yres == 1080 && found->refresh == 60)
884 hdmi->preprogrammed_vic = 16;
821 else 885 else
822 hdmi->preprogrammed_mode = false; 886 hdmi->preprogrammed_vic = 0;
887
888 dev_dbg(hdmi->dev, "Using %s %s mode %ux%u@%uHz (%luHz), clock error %luHz\n",
889 modelist ? "default" : "EDID", hdmi->preprogrammed_vic ? "VIC" : "external",
890 found->xres, found->yres, found->refresh,
891 PICOS2KHZ(found->pixclock) * 1000, found_rate_error);
823 892
824 fb_videomode_to_var(&hdmi->var, found); 893 fb_videomode_to_var(&hdmi->var, found);
825 sh_hdmi_external_video_param(hdmi); 894 sh_hdmi_external_video_param(hdmi);
@@ -868,32 +937,34 @@ static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id)
868 /* Check, if hot plug & MSENS pin status are both high */ 937 /* Check, if hot plug & MSENS pin status are both high */
869 if ((msens & 0xC0) == 0xC0) { 938 if ((msens & 0xC0) == 0xC0) {
870 /* Display plug in */ 939 /* Display plug in */
940 hdmi->edid_segment_nr = 0;
941 hdmi->edid_block_addr = 0;
942 hdmi->edid_blocks = 0;
871 hdmi->hp_state = HDMI_HOTPLUG_CONNECTED; 943 hdmi->hp_state = HDMI_HOTPLUG_CONNECTED;
872 944
873 /* Set EDID word address */ 945 /* Set EDID word address */
874 hdmi_write(hdmi, 0x00, HDMI_EDID_WORD_ADDRESS); 946 hdmi_write(hdmi, 0x00, HDMI_EDID_WORD_ADDRESS);
875 /* Set EDID segment pointer */
876 hdmi_write(hdmi, 0x00, HDMI_EDID_SEGMENT_POINTER);
877 /* Enable EDID interrupt */ 947 /* Enable EDID interrupt */
878 hdmi_write(hdmi, 0xC6, HDMI_INTERRUPT_MASK_1); 948 hdmi_write(hdmi, 0xC6, HDMI_INTERRUPT_MASK_1);
949 /* Set EDID segment pointer - starts reading EDID */
950 hdmi_write(hdmi, 0x00, HDMI_EDID_SEGMENT_POINTER);
879 } else if (!(status1 & 0x80)) { 951 } else if (!(status1 & 0x80)) {
880 /* Display unplug, beware multiple interrupts */ 952 /* Display unplug, beware multiple interrupts */
881 if (hdmi->hp_state != HDMI_HOTPLUG_DISCONNECTED) 953 if (hdmi->hp_state != HDMI_HOTPLUG_DISCONNECTED) {
954 hdmi->hp_state = HDMI_HOTPLUG_DISCONNECTED;
882 schedule_delayed_work(&hdmi->edid_work, 0); 955 schedule_delayed_work(&hdmi->edid_work, 0);
883 956 }
884 hdmi->hp_state = HDMI_HOTPLUG_DISCONNECTED;
885 /* display_off will switch back to mode_a */ 957 /* display_off will switch back to mode_a */
886 } 958 }
887 } else if (status1 & 2) { 959 } else if (status1 & 2) {
888 /* EDID error interrupt: retry */ 960 /* EDID error interrupt: retry */
889 /* Set EDID word address */ 961 /* Set EDID word address */
890 hdmi_write(hdmi, 0x00, HDMI_EDID_WORD_ADDRESS); 962 hdmi_write(hdmi, hdmi->edid_block_addr, HDMI_EDID_WORD_ADDRESS);
891 /* Set EDID segment pointer */ 963 /* Set EDID segment pointer */
892 hdmi_write(hdmi, 0x00, HDMI_EDID_SEGMENT_POINTER); 964 hdmi_write(hdmi, hdmi->edid_segment_nr, HDMI_EDID_SEGMENT_POINTER);
893 } else if (status1 & 4) { 965 } else if (status1 & 4) {
894 /* Disable EDID interrupt */ 966 /* Disable EDID interrupt */
895 hdmi_write(hdmi, 0xC0, HDMI_INTERRUPT_MASK_1); 967 hdmi_write(hdmi, 0xC0, HDMI_INTERRUPT_MASK_1);
896 hdmi->hp_state = HDMI_HOTPLUG_EDID_DONE;
897 schedule_delayed_work(&hdmi->edid_work, msecs_to_jiffies(10)); 968 schedule_delayed_work(&hdmi->edid_work, msecs_to_jiffies(10));
898 } 969 }
899 970
@@ -972,39 +1043,37 @@ static bool sh_hdmi_must_reconfigure(struct sh_hdmi *hdmi)
972 1043
973/** 1044/**
974 * sh_hdmi_clk_configure() - set HDMI clock frequency and enable the clock 1045 * sh_hdmi_clk_configure() - set HDMI clock frequency and enable the clock
975 * @hdmi: driver context 1046 * @hdmi: driver context
976 * @pixclock: pixel clock period in picoseconds 1047 * @hdmi_rate: HDMI clock frequency in Hz
977 * return: configured positive rate if successful 1048 * @parent_rate: if != 0 - set parent clock rate for optimal precision
978 * 0 if couldn't set the rate, but managed to enable the clock 1049 * return: configured positive rate if successful
979 * negative error, if couldn't enable the clock 1050 * 0 if couldn't set the rate, but managed to enable the
1051 * clock, negative error, if couldn't enable the clock
980 */ 1052 */
981static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long pixclock) 1053static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate,
1054 unsigned long parent_rate)
982{ 1055{
983 long rate;
984 int ret; 1056 int ret;
985 1057
986 rate = PICOS2KHZ(pixclock) * 1000; 1058 if (parent_rate && clk_get_parent(hdmi->hdmi_clk)) {
987 rate = clk_round_rate(hdmi->hdmi_clk, rate); 1059 ret = clk_set_rate(clk_get_parent(hdmi->hdmi_clk), parent_rate);
988 if (rate > 0) {
989 ret = clk_set_rate(hdmi->hdmi_clk, rate);
990 if (ret < 0) { 1060 if (ret < 0) {
991 dev_warn(hdmi->dev, "Cannot set rate %ld: %d\n", rate, ret); 1061 dev_warn(hdmi->dev, "Cannot set parent rate %ld: %d\n", parent_rate, ret);
992 rate = 0; 1062 hdmi_rate = clk_round_rate(hdmi->hdmi_clk, hdmi_rate);
993 } else { 1063 } else {
994 dev_dbg(hdmi->dev, "HDMI set frequency %lu\n", rate); 1064 dev_dbg(hdmi->dev, "HDMI set parent frequency %lu\n", parent_rate);
995 } 1065 }
996 } else {
997 rate = 0;
998 dev_warn(hdmi->dev, "Cannot get suitable rate: %ld\n", rate);
999 } 1066 }
1000 1067
1001 ret = clk_enable(hdmi->hdmi_clk); 1068 ret = clk_set_rate(hdmi->hdmi_clk, hdmi_rate);
1002 if (ret < 0) { 1069 if (ret < 0) {
1003 dev_err(hdmi->dev, "Cannot enable clock: %d\n", ret); 1070 dev_warn(hdmi->dev, "Cannot set rate %ld: %d\n", hdmi_rate, ret);
1004 return ret; 1071 hdmi_rate = 0;
1072 } else {
1073 dev_dbg(hdmi->dev, "HDMI set frequency %lu\n", hdmi_rate);
1005 } 1074 }
1006 1075
1007 return rate; 1076 return hdmi_rate;
1008} 1077}
1009 1078
1010/* Hotplug interrupt occurred, read EDID */ 1079/* Hotplug interrupt occurred, read EDID */
@@ -1023,17 +1092,20 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1023 1092
1024 mutex_lock(&hdmi->mutex); 1093 mutex_lock(&hdmi->mutex);
1025 1094
1026 if (hdmi->hp_state == HDMI_HOTPLUG_EDID_DONE) { 1095 if (hdmi->hp_state == HDMI_HOTPLUG_CONNECTED) {
1096 unsigned long parent_rate = 0, hdmi_rate;
1097
1027 /* A device has been plugged in */ 1098 /* A device has been plugged in */
1028 pm_runtime_get_sync(hdmi->dev); 1099 pm_runtime_get_sync(hdmi->dev);
1029 1100
1030 ret = sh_hdmi_read_edid(hdmi); 1101 ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate);
1031 if (ret < 0) 1102 if (ret < 0)
1032 goto out; 1103 goto out;
1033 1104
1105 hdmi->hp_state = HDMI_HOTPLUG_EDID_DONE;
1106
1034 /* Reconfigure the clock */ 1107 /* Reconfigure the clock */
1035 clk_disable(hdmi->hdmi_clk); 1108 ret = sh_hdmi_clk_configure(hdmi, hdmi_rate, parent_rate);
1036 ret = sh_hdmi_clk_configure(hdmi, hdmi->var.pixclock);
1037 if (ret < 0) 1109 if (ret < 0)
1038 goto out; 1110 goto out;
1039 1111
@@ -1085,7 +1157,7 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1085 } 1157 }
1086 1158
1087out: 1159out:
1088 if (ret < 0) 1160 if (ret < 0 && ret != -EAGAIN)
1089 hdmi->hp_state = HDMI_HOTPLUG_DISCONNECTED; 1161 hdmi->hp_state = HDMI_HOTPLUG_DISCONNECTED;
1090 mutex_unlock(&hdmi->mutex); 1162 mutex_unlock(&hdmi->mutex);
1091 1163
@@ -1166,13 +1238,22 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1166 goto egetclk; 1238 goto egetclk;
1167 } 1239 }
1168 1240
1169 /* Some arbitrary relaxed pixclock just to get things started */ 1241 /* An arbitrary relaxed pixclock just to get things started: from standard 480p */
1170 rate = sh_hdmi_clk_configure(hdmi, 37037); 1242 rate = clk_round_rate(hdmi->hdmi_clk, PICOS2KHZ(37037));
1243 if (rate > 0)
1244 rate = sh_hdmi_clk_configure(hdmi, rate, 0);
1245
1171 if (rate < 0) { 1246 if (rate < 0) {
1172 ret = rate; 1247 ret = rate;
1173 goto erate; 1248 goto erate;
1174 } 1249 }
1175 1250
1251 ret = clk_enable(hdmi->hdmi_clk);
1252 if (ret < 0) {
1253 dev_err(hdmi->dev, "Cannot enable clock: %d\n", ret);
1254 goto erate;
1255 }
1256
1176 dev_dbg(&pdev->dev, "Enabled HDMI clock at %luHz\n", rate); 1257 dev_dbg(&pdev->dev, "Enabled HDMI clock at %luHz\n", rate);
1177 1258
1178 if (!request_mem_region(res->start, resource_size(res), dev_name(&pdev->dev))) { 1259 if (!request_mem_region(res->start, resource_size(res), dev_name(&pdev->dev))) {
@@ -1190,10 +1271,6 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1190 1271
1191 platform_set_drvdata(pdev, hdmi); 1272 platform_set_drvdata(pdev, hdmi);
1192 1273
1193 /* Product and revision IDs are 0 in sh-mobile version */
1194 dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n",
1195 hdmi_read(hdmi, HDMI_PRODUCT_ID), hdmi_read(hdmi, HDMI_REVISION_ID));
1196
1197 /* Set up LCDC callbacks */ 1274 /* Set up LCDC callbacks */
1198 board_cfg = &pdata->lcd_chan->board_cfg; 1275 board_cfg = &pdata->lcd_chan->board_cfg;
1199 board_cfg->owner = THIS_MODULE; 1276 board_cfg->owner = THIS_MODULE;
@@ -1206,6 +1283,10 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1206 pm_runtime_enable(&pdev->dev); 1283 pm_runtime_enable(&pdev->dev);
1207 pm_runtime_resume(&pdev->dev); 1284 pm_runtime_resume(&pdev->dev);
1208 1285
1286 /* Product and revision IDs are 0 in sh-mobile version */
1287 dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n",
1288 hdmi_read(hdmi, HDMI_PRODUCT_ID), hdmi_read(hdmi, HDMI_REVISION_ID));
1289
1209 ret = request_irq(irq, sh_hdmi_hotplug, 0, 1290 ret = request_irq(irq, sh_hdmi_hotplug, 0,
1210 dev_name(&pdev->dev), hdmi); 1291 dev_name(&pdev->dev), hdmi);
1211 if (ret < 0) { 1292 if (ret < 0) {
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index 9b1364723c65..cffec90afa93 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -54,8 +54,8 @@ static int lcdc_shared_regs[] = {
54}; 54};
55#define NR_SHARED_REGS ARRAY_SIZE(lcdc_shared_regs) 55#define NR_SHARED_REGS ARRAY_SIZE(lcdc_shared_regs)
56 56
57#define DEFAULT_XRES 1280 57#define MAX_XRES 1920
58#define DEFAULT_YRES 1024 58#define MAX_YRES 1080
59 59
60static unsigned long lcdc_offs_mainlcd[NR_CH_REGS] = { 60static unsigned long lcdc_offs_mainlcd[NR_CH_REGS] = {
61 [LDDCKPAT1R] = 0x400, 61 [LDDCKPAT1R] = 0x400,
@@ -139,6 +139,7 @@ struct sh_mobile_lcdc_priv {
139 struct notifier_block notifier; 139 struct notifier_block notifier;
140 unsigned long saved_shared_regs[NR_SHARED_REGS]; 140 unsigned long saved_shared_regs[NR_SHARED_REGS];
141 int started; 141 int started;
142 int forced_bpp; /* 2 channel LCDC must share bpp setting */
142}; 143};
143 144
144static bool banked(int reg_nr) 145static bool banked(int reg_nr)
@@ -461,13 +462,18 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
461 struct sh_mobile_lcdc_chan *ch; 462 struct sh_mobile_lcdc_chan *ch;
462 struct sh_mobile_lcdc_board_cfg *board_cfg; 463 struct sh_mobile_lcdc_board_cfg *board_cfg;
463 unsigned long tmp; 464 unsigned long tmp;
465 int bpp = 0;
464 int k, m; 466 int k, m;
465 int ret = 0; 467 int ret = 0;
466 468
467 /* enable clocks before accessing the hardware */ 469 /* enable clocks before accessing the hardware */
468 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) 470 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
469 if (priv->ch[k].enabled) 471 if (priv->ch[k].enabled) {
470 sh_mobile_lcdc_clk_on(priv); 472 sh_mobile_lcdc_clk_on(priv);
473 if (!bpp)
474 bpp = priv->ch[k].info->var.bits_per_pixel;
475 }
476 }
471 477
472 /* reset */ 478 /* reset */
473 lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) | LCDC_RESET); 479 lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) | LCDC_RESET);
@@ -535,7 +541,17 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
535 } 541 }
536 542
537 /* word and long word swap */ 543 /* word and long word swap */
538 lcdc_write(priv, _LDDDSR, lcdc_read(priv, _LDDDSR) | 6); 544 switch (bpp) {
545 case 16:
546 lcdc_write(priv, _LDDDSR, lcdc_read(priv, _LDDDSR) | 6);
547 break;
548 case 24:
549 lcdc_write(priv, _LDDDSR, lcdc_read(priv, _LDDDSR) | 7);
550 break;
551 case 32:
552 lcdc_write(priv, _LDDDSR, lcdc_read(priv, _LDDDSR) | 4);
553 break;
554 }
539 555
540 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { 556 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
541 ch = &priv->ch[k]; 557 ch = &priv->ch[k];
@@ -546,7 +562,16 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
546 /* set bpp format in PKF[4:0] */ 562 /* set bpp format in PKF[4:0] */
547 tmp = lcdc_read_chan(ch, LDDFR); 563 tmp = lcdc_read_chan(ch, LDDFR);
548 tmp &= ~0x0001001f; 564 tmp &= ~0x0001001f;
549 tmp |= (ch->info->var.bits_per_pixel == 16) ? 3 : 0; 565 switch (ch->info->var.bits_per_pixel) {
566 case 16:
567 tmp |= 0x03;
568 break;
569 case 24:
570 tmp |= 0x0b;
571 break;
572 case 32:
573 break;
574 }
550 lcdc_write_chan(ch, LDDFR, tmp); 575 lcdc_write_chan(ch, LDDFR, tmp);
551 576
552 /* point out our frame buffer */ 577 /* point out our frame buffer */
@@ -860,7 +885,7 @@ static void sh_mobile_fb_reconfig(struct fb_info *info)
860 /* Couldn't reconfigure, hopefully, can continue as before */ 885 /* Couldn't reconfigure, hopefully, can continue as before */
861 return; 886 return;
862 887
863 info->fix.line_length = mode2.xres * (ch->cfg.bpp / 8); 888 info->fix.line_length = mode1.xres * (ch->cfg.bpp / 8);
864 889
865 /* 890 /*
866 * fb_set_var() calls the notifier change internally, only if 891 * fb_set_var() calls the notifier change internally, only if
@@ -868,7 +893,7 @@ static void sh_mobile_fb_reconfig(struct fb_info *info)
868 * user event, we have to call the chain ourselves. 893 * user event, we have to call the chain ourselves.
869 */ 894 */
870 event.info = info; 895 event.info = info;
871 event.data = &mode2; 896 event.data = &mode1;
872 fb_notifier_call_chain(evnt, &event); 897 fb_notifier_call_chain(evnt, &event);
873} 898}
874 899
@@ -913,25 +938,30 @@ static int sh_mobile_open(struct fb_info *info, int user)
913static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 938static int sh_mobile_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
914{ 939{
915 struct sh_mobile_lcdc_chan *ch = info->par; 940 struct sh_mobile_lcdc_chan *ch = info->par;
941 struct sh_mobile_lcdc_priv *p = ch->lcdc;
916 942
917 if (var->xres < 160 || var->xres > 1920 || 943 if (var->xres > MAX_XRES || var->yres > MAX_YRES ||
918 var->yres < 120 || var->yres > 1080 ||
919 var->left_margin < 32 || var->left_margin > 320 ||
920 var->right_margin < 12 || var->right_margin > 240 ||
921 var->upper_margin < 12 || var->upper_margin > 120 ||
922 var->lower_margin < 1 || var->lower_margin > 64 ||
923 var->hsync_len < 32 || var->hsync_len > 240 ||
924 var->vsync_len < 2 || var->vsync_len > 64 ||
925 var->pixclock < 6000 || var->pixclock > 40000 ||
926 var->xres * var->yres * (ch->cfg.bpp / 8) * 2 > info->fix.smem_len) { 944 var->xres * var->yres * (ch->cfg.bpp / 8) * 2 > info->fix.smem_len) {
927 dev_warn(info->dev, "Invalid info: %u %u %u %u %u %u %u %u %u!\n", 945 dev_warn(info->dev, "Invalid info: %u-%u-%u-%u x %u-%u-%u-%u @ %lukHz!\n",
928 var->xres, var->yres, 946 var->left_margin, var->xres, var->right_margin, var->hsync_len,
929 var->left_margin, var->right_margin, 947 var->upper_margin, var->yres, var->lower_margin, var->vsync_len,
930 var->upper_margin, var->lower_margin, 948 PICOS2KHZ(var->pixclock));
931 var->hsync_len, var->vsync_len,
932 var->pixclock);
933 return -EINVAL; 949 return -EINVAL;
934 } 950 }
951
952 /* only accept the forced_bpp for dual channel configurations */
953 if (p->forced_bpp && p->forced_bpp != var->bits_per_pixel)
954 return -EINVAL;
955
956 switch (var->bits_per_pixel) {
957 case 16: /* PKF[4:0] = 00011 - RGB 565 */
958 case 24: /* PKF[4:0] = 01011 - RGB 888 */
959 case 32: /* PKF[4:0] = 00000 - RGBA 888 */
960 break;
961 default:
962 return -EINVAL;
963 }
964
935 return 0; 965 return 0;
936} 966}
937 967
@@ -964,19 +994,27 @@ static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp)
964 var->transp.length = 0; 994 var->transp.length = 0;
965 break; 995 break;
966 996
967 case 32: /* PKF[4:0] = 00000 - RGB 888 997 case 24: /* PKF[4:0] = 01011 - RGB 888 */
968 * sh7722 pdf says 00RRGGBB but reality is GGBB00RR 998 var->red.offset = 16;
969 * this may be because LDDDSR has word swap enabled..
970 */
971 var->red.offset = 0;
972 var->red.length = 8; 999 var->red.length = 8;
973 var->green.offset = 24; 1000 var->green.offset = 8;
974 var->green.length = 8; 1001 var->green.length = 8;
975 var->blue.offset = 16; 1002 var->blue.offset = 0;
976 var->blue.length = 8; 1003 var->blue.length = 8;
977 var->transp.offset = 0; 1004 var->transp.offset = 0;
978 var->transp.length = 0; 1005 var->transp.length = 0;
979 break; 1006 break;
1007
1008 case 32: /* PKF[4:0] = 00000 - RGBA 888 */
1009 var->red.offset = 16;
1010 var->red.length = 8;
1011 var->green.offset = 8;
1012 var->green.length = 8;
1013 var->blue.offset = 0;
1014 var->blue.length = 8;
1015 var->transp.offset = 24;
1016 var->transp.length = 8;
1017 break;
980 default: 1018 default:
981 return -EINVAL; 1019 return -EINVAL;
982 } 1020 }
@@ -1180,6 +1218,10 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
1180 goto err1; 1218 goto err1;
1181 } 1219 }
1182 1220
1221 /* for dual channel LCDC (MAIN + SUB) force shared bpp setting */
1222 if (j == 2)
1223 priv->forced_bpp = pdata->ch[0].bpp;
1224
1183 priv->base = ioremap_nocache(res->start, resource_size(res)); 1225 priv->base = ioremap_nocache(res->start, resource_size(res));
1184 if (!priv->base) 1226 if (!priv->base)
1185 goto err1; 1227 goto err1;
@@ -1226,7 +1268,7 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
1226 } 1268 }
1227 1269
1228 if (!mode) 1270 if (!mode)
1229 max_size = DEFAULT_XRES * DEFAULT_YRES; 1271 max_size = MAX_XRES * MAX_YRES;
1230 else if (max_cfg) 1272 else if (max_cfg)
1231 dev_dbg(&pdev->dev, "Found largest videomode %ux%u\n", 1273 dev_dbg(&pdev->dev, "Found largest videomode %ux%u\n",
1232 max_cfg->xres, max_cfg->yres); 1274 max_cfg->xres, max_cfg->yres);
diff --git a/drivers/video/sis/init.c b/drivers/video/sis/init.c
index c311ad3c3687..66de832361cc 100644
--- a/drivers/video/sis/init.c
+++ b/drivers/video/sis/init.c
@@ -56,17 +56,13 @@
56 * Used by permission. 56 * Used by permission.
57 */ 57 */
58 58
59#ifdef HAVE_CONFIG_H
60#include "config.h"
61#endif
62
63#include "init.h" 59#include "init.h"
64 60
65#ifdef SIS300 61#ifdef CONFIG_FB_SIS_300
66#include "300vtbl.h" 62#include "300vtbl.h"
67#endif 63#endif
68 64
69#ifdef SIS315H 65#ifdef CONFIG_FB_SIS_315
70#include "310vtbl.h" 66#include "310vtbl.h"
71#endif 67#endif
72 68
@@ -78,7 +74,7 @@
78/* POINTER INITIALIZATION */ 74/* POINTER INITIALIZATION */
79/*********************************************/ 75/*********************************************/
80 76
81#if defined(SIS300) || defined(SIS315H) 77#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
82static void 78static void
83InitCommonPointer(struct SiS_Private *SiS_Pr) 79InitCommonPointer(struct SiS_Private *SiS_Pr)
84{ 80{
@@ -160,7 +156,7 @@ InitCommonPointer(struct SiS_Private *SiS_Pr)
160} 156}
161#endif 157#endif
162 158
163#ifdef SIS300 159#ifdef CONFIG_FB_SIS_300
164static void 160static void
165InitTo300Pointer(struct SiS_Private *SiS_Pr) 161InitTo300Pointer(struct SiS_Private *SiS_Pr)
166{ 162{
@@ -237,7 +233,7 @@ InitTo300Pointer(struct SiS_Private *SiS_Pr)
237} 233}
238#endif 234#endif
239 235
240#ifdef SIS315H 236#ifdef CONFIG_FB_SIS_315
241static void 237static void
242InitTo310Pointer(struct SiS_Private *SiS_Pr) 238InitTo310Pointer(struct SiS_Private *SiS_Pr)
243{ 239{
@@ -321,13 +317,13 @@ bool
321SiSInitPtr(struct SiS_Private *SiS_Pr) 317SiSInitPtr(struct SiS_Private *SiS_Pr)
322{ 318{
323 if(SiS_Pr->ChipType < SIS_315H) { 319 if(SiS_Pr->ChipType < SIS_315H) {
324#ifdef SIS300 320#ifdef CONFIG_FB_SIS_300
325 InitTo300Pointer(SiS_Pr); 321 InitTo300Pointer(SiS_Pr);
326#else 322#else
327 return false; 323 return false;
328#endif 324#endif
329 } else { 325 } else {
330#ifdef SIS315H 326#ifdef CONFIG_FB_SIS_315
331 InitTo310Pointer(SiS_Pr); 327 InitTo310Pointer(SiS_Pr);
332#else 328#else
333 return false; 329 return false;
@@ -340,9 +336,7 @@ SiSInitPtr(struct SiS_Private *SiS_Pr)
340/* HELPER: Get ModeID */ 336/* HELPER: Get ModeID */
341/*********************************************/ 337/*********************************************/
342 338
343#ifndef SIS_XORG_XF86
344static 339static
345#endif
346unsigned short 340unsigned short
347SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay, 341SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay,
348 int Depth, bool FSTN, int LCDwidth, int LCDheight) 342 int Depth, bool FSTN, int LCDwidth, int LCDheight)
@@ -882,59 +876,59 @@ SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDispl
882/*********************************************/ 876/*********************************************/
883 877
884void 878void
885SiS_SetReg(SISIOADDRESS port, unsigned short index, unsigned short data) 879SiS_SetReg(SISIOADDRESS port, u8 index, u8 data)
886{ 880{
887 OutPortByte(port, index); 881 outb(index, port);
888 OutPortByte(port + 1, data); 882 outb(data, port + 1);
889} 883}
890 884
891void 885void
892SiS_SetRegByte(SISIOADDRESS port, unsigned short data) 886SiS_SetRegByte(SISIOADDRESS port, u8 data)
893{ 887{
894 OutPortByte(port, data); 888 outb(data, port);
895} 889}
896 890
897void 891void
898SiS_SetRegShort(SISIOADDRESS port, unsigned short data) 892SiS_SetRegShort(SISIOADDRESS port, u16 data)
899{ 893{
900 OutPortWord(port, data); 894 outw(data, port);
901} 895}
902 896
903void 897void
904SiS_SetRegLong(SISIOADDRESS port, unsigned int data) 898SiS_SetRegLong(SISIOADDRESS port, u32 data)
905{ 899{
906 OutPortLong(port, data); 900 outl(data, port);
907} 901}
908 902
909unsigned char 903u8
910SiS_GetReg(SISIOADDRESS port, unsigned short index) 904SiS_GetReg(SISIOADDRESS port, u8 index)
911{ 905{
912 OutPortByte(port, index); 906 outb(index, port);
913 return(InPortByte(port + 1)); 907 return inb(port + 1);
914} 908}
915 909
916unsigned char 910u8
917SiS_GetRegByte(SISIOADDRESS port) 911SiS_GetRegByte(SISIOADDRESS port)
918{ 912{
919 return(InPortByte(port)); 913 return inb(port);
920} 914}
921 915
922unsigned short 916u16
923SiS_GetRegShort(SISIOADDRESS port) 917SiS_GetRegShort(SISIOADDRESS port)
924{ 918{
925 return(InPortWord(port)); 919 return inw(port);
926} 920}
927 921
928unsigned int 922u32
929SiS_GetRegLong(SISIOADDRESS port) 923SiS_GetRegLong(SISIOADDRESS port)
930{ 924{
931 return(InPortLong(port)); 925 return inl(port);
932} 926}
933 927
934void 928void
935SiS_SetRegANDOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND, unsigned short DataOR) 929SiS_SetRegANDOR(SISIOADDRESS Port, u8 Index, u8 DataAND, u8 DataOR)
936{ 930{
937 unsigned short temp; 931 u8 temp;
938 932
939 temp = SiS_GetReg(Port, Index); 933 temp = SiS_GetReg(Port, Index);
940 temp = (temp & (DataAND)) | DataOR; 934 temp = (temp & (DataAND)) | DataOR;
@@ -942,9 +936,9 @@ SiS_SetRegANDOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND,
942} 936}
943 937
944void 938void
945SiS_SetRegAND(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND) 939SiS_SetRegAND(SISIOADDRESS Port, u8 Index, u8 DataAND)
946{ 940{
947 unsigned short temp; 941 u8 temp;
948 942
949 temp = SiS_GetReg(Port, Index); 943 temp = SiS_GetReg(Port, Index);
950 temp &= DataAND; 944 temp &= DataAND;
@@ -952,9 +946,9 @@ SiS_SetRegAND(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND)
952} 946}
953 947
954void 948void
955SiS_SetRegOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataOR) 949SiS_SetRegOR(SISIOADDRESS Port, u8 Index, u8 DataOR)
956{ 950{
957 unsigned short temp; 951 u8 temp;
958 952
959 temp = SiS_GetReg(Port, Index); 953 temp = SiS_GetReg(Port, Index);
960 temp |= DataOR; 954 temp |= DataOR;
@@ -1089,7 +1083,7 @@ static void
1089SiSInitPCIetc(struct SiS_Private *SiS_Pr) 1083SiSInitPCIetc(struct SiS_Private *SiS_Pr)
1090{ 1084{
1091 switch(SiS_Pr->ChipType) { 1085 switch(SiS_Pr->ChipType) {
1092#ifdef SIS300 1086#ifdef CONFIG_FB_SIS_300
1093 case SIS_300: 1087 case SIS_300:
1094 case SIS_540: 1088 case SIS_540:
1095 case SIS_630: 1089 case SIS_630:
@@ -1108,7 +1102,7 @@ SiSInitPCIetc(struct SiS_Private *SiS_Pr)
1108 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A); 1102 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A);
1109 break; 1103 break;
1110#endif 1104#endif
1111#ifdef SIS315H 1105#ifdef CONFIG_FB_SIS_315
1112 case SIS_315H: 1106 case SIS_315H:
1113 case SIS_315: 1107 case SIS_315:
1114 case SIS_315PRO: 1108 case SIS_315PRO:
@@ -1152,9 +1146,7 @@ SiSInitPCIetc(struct SiS_Private *SiS_Pr)
1152/* HELPER: SetLVDSetc */ 1146/* HELPER: SetLVDSetc */
1153/*********************************************/ 1147/*********************************************/
1154 1148
1155#ifdef SIS_LINUX_KERNEL
1156static 1149static
1157#endif
1158void 1150void
1159SiSSetLVDSetc(struct SiS_Private *SiS_Pr) 1151SiSSetLVDSetc(struct SiS_Private *SiS_Pr)
1160{ 1152{
@@ -1174,7 +1166,7 @@ SiSSetLVDSetc(struct SiS_Private *SiS_Pr)
1174 if((temp == 1) || (temp == 2)) return; 1166 if((temp == 1) || (temp == 2)) return;
1175 1167
1176 switch(SiS_Pr->ChipType) { 1168 switch(SiS_Pr->ChipType) {
1177#ifdef SIS300 1169#ifdef CONFIG_FB_SIS_300
1178 case SIS_540: 1170 case SIS_540:
1179 case SIS_630: 1171 case SIS_630:
1180 case SIS_730: 1172 case SIS_730:
@@ -1188,7 +1180,7 @@ SiSSetLVDSetc(struct SiS_Private *SiS_Pr)
1188 } 1180 }
1189 break; 1181 break;
1190#endif 1182#endif
1191#ifdef SIS315H 1183#ifdef CONFIG_FB_SIS_315
1192 case SIS_550: 1184 case SIS_550:
1193 case SIS_650: 1185 case SIS_650:
1194 case SIS_740: 1186 case SIS_740:
@@ -1420,9 +1412,7 @@ SiS_ResetSegmentRegisters(struct SiS_Private *SiS_Pr)
1420/* HELPER: GetVBType */ 1412/* HELPER: GetVBType */
1421/*********************************************/ 1413/*********************************************/
1422 1414
1423#ifdef SIS_LINUX_KERNEL
1424static 1415static
1425#endif
1426void 1416void
1427SiS_GetVBType(struct SiS_Private *SiS_Pr) 1417SiS_GetVBType(struct SiS_Private *SiS_Pr)
1428{ 1418{
@@ -1487,7 +1477,6 @@ SiS_GetVBType(struct SiS_Private *SiS_Pr)
1487/* HELPER: Check RAM size */ 1477/* HELPER: Check RAM size */
1488/*********************************************/ 1478/*********************************************/
1489 1479
1490#ifdef SIS_LINUX_KERNEL
1491static bool 1480static bool
1492SiS_CheckMemorySize(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 1481SiS_CheckMemorySize(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1493 unsigned short ModeIdIndex) 1482 unsigned short ModeIdIndex)
@@ -1501,13 +1490,12 @@ SiS_CheckMemorySize(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1501 if(AdapterMemSize < memorysize) return false; 1490 if(AdapterMemSize < memorysize) return false;
1502 return true; 1491 return true;
1503} 1492}
1504#endif
1505 1493
1506/*********************************************/ 1494/*********************************************/
1507/* HELPER: Get DRAM type */ 1495/* HELPER: Get DRAM type */
1508/*********************************************/ 1496/*********************************************/
1509 1497
1510#ifdef SIS315H 1498#ifdef CONFIG_FB_SIS_315
1511static unsigned char 1499static unsigned char
1512SiS_Get310DRAMType(struct SiS_Private *SiS_Pr) 1500SiS_Get310DRAMType(struct SiS_Private *SiS_Pr)
1513{ 1501{
@@ -1574,7 +1562,6 @@ SiS_GetMCLK(struct SiS_Private *SiS_Pr)
1574/* HELPER: ClearBuffer */ 1562/* HELPER: ClearBuffer */
1575/*********************************************/ 1563/*********************************************/
1576 1564
1577#ifdef SIS_LINUX_KERNEL
1578static void 1565static void
1579SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 1566SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
1580{ 1567{
@@ -1587,7 +1574,7 @@ SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
1587 1574
1588 if(SiS_Pr->SiS_ModeType >= ModeEGA) { 1575 if(SiS_Pr->SiS_ModeType >= ModeEGA) {
1589 if(ModeNo > 0x13) { 1576 if(ModeNo > 0x13) {
1590 SiS_SetMemory(memaddr, memsize, 0); 1577 memset_io(memaddr, 0, memsize);
1591 } else { 1578 } else {
1592 pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; 1579 pBuffer = (unsigned short SISIOMEMTYPE *)memaddr;
1593 for(i = 0; i < 0x4000; i++) writew(0x0000, &pBuffer[i]); 1580 for(i = 0; i < 0x4000; i++) writew(0x0000, &pBuffer[i]);
@@ -1596,10 +1583,9 @@ SiS_ClearBuffer(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
1596 pBuffer = (unsigned short SISIOMEMTYPE *)memaddr; 1583 pBuffer = (unsigned short SISIOMEMTYPE *)memaddr;
1597 for(i = 0; i < 0x4000; i++) writew(0x0720, &pBuffer[i]); 1584 for(i = 0; i < 0x4000; i++) writew(0x0720, &pBuffer[i]);
1598 } else { 1585 } else {
1599 SiS_SetMemory(memaddr, 0x8000, 0); 1586 memset_io(memaddr, 0, 0x8000);
1600 } 1587 }
1601} 1588}
1602#endif
1603 1589
1604/*********************************************/ 1590/*********************************************/
1605/* HELPER: SearchModeID */ 1591/* HELPER: SearchModeID */
@@ -2132,7 +2118,7 @@ SiS_SetCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2132 SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F); 2118 SiS_SetReg(SiS_Pr->SiS_P3d4,0x14,0x4F);
2133 } 2119 }
2134 2120
2135#ifdef SIS315H 2121#ifdef CONFIG_FB_SIS_315
2136 if(SiS_Pr->ChipType == XGI_20) { 2122 if(SiS_Pr->ChipType == XGI_20) {
2137 SiS_SetReg(SiS_Pr->SiS_P3d4,0x04,crt1data[4] - 1); 2123 SiS_SetReg(SiS_Pr->SiS_P3d4,0x04,crt1data[4] - 1);
2138 if(!(temp = crt1data[5] & 0x1f)) { 2124 if(!(temp = crt1data[5] & 0x1f)) {
@@ -2215,7 +2201,7 @@ SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2215 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,clkb); 2201 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2c,clkb);
2216 2202
2217 if(SiS_Pr->ChipType >= SIS_315H) { 2203 if(SiS_Pr->ChipType >= SIS_315H) {
2218#ifdef SIS315H 2204#ifdef CONFIG_FB_SIS_315
2219 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01); 2205 SiS_SetReg(SiS_Pr->SiS_P3c4,0x2D,0x01);
2220 if(SiS_Pr->ChipType == XGI_20) { 2206 if(SiS_Pr->ChipType == XGI_20) {
2221 unsigned short mf = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex); 2207 unsigned short mf = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex);
@@ -2236,7 +2222,7 @@ SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2236/* FIFO */ 2222/* FIFO */
2237/*********************************************/ 2223/*********************************************/
2238 2224
2239#ifdef SIS300 2225#ifdef CONFIG_FB_SIS_300
2240void 2226void
2241SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1, 2227SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1,
2242 unsigned short *idx2) 2228 unsigned short *idx2)
@@ -2506,11 +2492,7 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2506 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data); 2492 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x09,0x80,data);
2507 2493
2508 /* Write foreground and background queue */ 2494 /* Write foreground and background queue */
2509#ifdef SIS_LINUX_KERNEL
2510 templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); 2495 templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50);
2511#else
2512 templ = pciReadLong(0x00000000, 0x50);
2513#endif
2514 2496
2515 if(SiS_Pr->ChipType == SIS_730) { 2497 if(SiS_Pr->ChipType == SIS_730) {
2516 2498
@@ -2530,13 +2512,8 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2530 2512
2531 } 2513 }
2532 2514
2533#ifdef SIS_LINUX_KERNEL
2534 sisfb_write_nbridge_pci_dword(SiS_Pr, 0x50, templ); 2515 sisfb_write_nbridge_pci_dword(SiS_Pr, 0x50, templ);
2535 templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xA0); 2516 templ = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xA0);
2536#else
2537 pciWriteLong(0x00000000, 0x50, templ);
2538 templ = pciReadLong(0x00000000, 0xA0);
2539#endif
2540 2517
2541 /* GUI grant timer (PCI config 0xA3) */ 2518 /* GUI grant timer (PCI config 0xA3) */
2542 if(SiS_Pr->ChipType == SIS_730) { 2519 if(SiS_Pr->ChipType == SIS_730) {
@@ -2552,15 +2529,11 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2552 2529
2553 } 2530 }
2554 2531
2555#ifdef SIS_LINUX_KERNEL
2556 sisfb_write_nbridge_pci_dword(SiS_Pr, 0xA0, templ); 2532 sisfb_write_nbridge_pci_dword(SiS_Pr, 0xA0, templ);
2557#else
2558 pciWriteLong(0x00000000, 0xA0, templ);
2559#endif
2560} 2533}
2561#endif /* SIS300 */ 2534#endif /* CONFIG_FB_SIS_300 */
2562 2535
2563#ifdef SIS315H 2536#ifdef CONFIG_FB_SIS_315
2564static void 2537static void
2565SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex) 2538SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
2566{ 2539{
@@ -2612,7 +2585,7 @@ SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2612 } 2585 }
2613 2586
2614 if(SiS_Pr->ChipType < SIS_315H) { 2587 if(SiS_Pr->ChipType < SIS_315H) {
2615#ifdef SIS300 2588#ifdef CONFIG_FB_SIS_300
2616 if(VCLK > 150) data |= 0x80; 2589 if(VCLK > 150) data |= 0x80;
2617 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data); 2590 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x07,0x7B,data);
2618 2591
@@ -2621,7 +2594,7 @@ SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2621 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data); 2594 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xF7,data);
2622#endif 2595#endif
2623 } else if(SiS_Pr->ChipType < XGI_20) { 2596 } else if(SiS_Pr->ChipType < XGI_20) {
2624#ifdef SIS315H 2597#ifdef CONFIG_FB_SIS_315
2625 if(VCLK >= 166) data |= 0x0c; 2598 if(VCLK >= 166) data |= 0x0c;
2626 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); 2599 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data);
2627 2600
@@ -2630,7 +2603,7 @@ SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2630 } 2603 }
2631#endif 2604#endif
2632 } else { 2605 } else {
2633#ifdef SIS315H 2606#ifdef CONFIG_FB_SIS_315
2634 if(VCLK >= 200) data |= 0x0c; 2607 if(VCLK >= 200) data |= 0x0c;
2635 if(SiS_Pr->ChipType == XGI_20) data &= ~0x04; 2608 if(SiS_Pr->ChipType == XGI_20) data &= ~0x04;
2636 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data); 2609 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x32,0xf3,data);
@@ -2675,7 +2648,7 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2675 unsigned short ModeIdIndex, unsigned short RRTI) 2648 unsigned short ModeIdIndex, unsigned short RRTI)
2676{ 2649{
2677 unsigned short data, infoflag = 0, modeflag, resindex; 2650 unsigned short data, infoflag = 0, modeflag, resindex;
2678#ifdef SIS315H 2651#ifdef CONFIG_FB_SIS_315
2679 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 2652 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
2680 unsigned short data2, data3; 2653 unsigned short data2, data3;
2681#endif 2654#endif
@@ -2736,7 +2709,7 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2736 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,data); 2709 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0F,0xB7,data);
2737 } 2710 }
2738 2711
2739#ifdef SIS315H 2712#ifdef CONFIG_FB_SIS_315
2740 if(SiS_Pr->ChipType >= SIS_315H) { 2713 if(SiS_Pr->ChipType >= SIS_315H) {
2741 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xfb); 2714 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x31,0xfb);
2742 } 2715 }
@@ -2826,7 +2799,7 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2826 2799
2827 SiS_SetVCLKState(SiS_Pr, ModeNo, RRTI, ModeIdIndex); 2800 SiS_SetVCLKState(SiS_Pr, ModeNo, RRTI, ModeIdIndex);
2828 2801
2829#ifdef SIS315H 2802#ifdef CONFIG_FB_SIS_315
2830 if(((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) || 2803 if(((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) ||
2831 (SiS_Pr->ChipType == XGI_40)) { 2804 (SiS_Pr->ChipType == XGI_40)) {
2832 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) { 2805 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40) {
@@ -2845,7 +2818,7 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
2845#endif 2818#endif
2846} 2819}
2847 2820
2848#ifdef SIS315H 2821#ifdef CONFIG_FB_SIS_315
2849static void 2822static void
2850SiS_SetupDualChip(struct SiS_Private *SiS_Pr) 2823SiS_SetupDualChip(struct SiS_Private *SiS_Pr)
2851{ 2824{
@@ -2999,11 +2972,6 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho
2999 SiS_Pr->SiS_SelectCRT2Rate = 0; 2972 SiS_Pr->SiS_SelectCRT2Rate = 0;
3000 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); 2973 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
3001 2974
3002#ifdef SIS_XORG_XF86
3003 xf86DrvMsgVerb(0, X_PROBED, 4, "(init: VBType=0x%04x, VBInfo=0x%04x)\n",
3004 SiS_Pr->SiS_VBType, SiS_Pr->SiS_VBInfo);
3005#endif
3006
3007 if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) { 2975 if(SiS_Pr->SiS_VBInfo & SetSimuScanMode) {
3008 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 2976 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
3009 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 2977 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
@@ -3028,7 +2996,7 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho
3028 } 2996 }
3029 2997
3030 switch(SiS_Pr->ChipType) { 2998 switch(SiS_Pr->ChipType) {
3031#ifdef SIS300 2999#ifdef CONFIG_FB_SIS_300
3032 case SIS_300: 3000 case SIS_300:
3033 SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo, RefreshRateTableIndex); 3001 SiS_SetCRT1FIFO_300(SiS_Pr, ModeNo, RefreshRateTableIndex);
3034 break; 3002 break;
@@ -3039,7 +3007,7 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho
3039 break; 3007 break;
3040#endif 3008#endif
3041 default: 3009 default:
3042#ifdef SIS315H 3010#ifdef CONFIG_FB_SIS_315
3043 if(SiS_Pr->ChipType == XGI_20) { 3011 if(SiS_Pr->ChipType == XGI_20) {
3044 unsigned char sr2b = 0, sr2c = 0; 3012 unsigned char sr2b = 0, sr2c = 0;
3045 switch(ModeNo) { 3013 switch(ModeNo) {
@@ -3062,7 +3030,7 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho
3062 3030
3063 SiS_SetCRT1ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 3031 SiS_SetCRT1ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3064 3032
3065#ifdef SIS315H 3033#ifdef CONFIG_FB_SIS_315
3066 if(SiS_Pr->ChipType == XGI_40) { 3034 if(SiS_Pr->ChipType == XGI_40) {
3067 SiS_SetupDualChip(SiS_Pr); 3035 SiS_SetupDualChip(SiS_Pr);
3068 } 3036 }
@@ -3070,11 +3038,9 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sho
3070 3038
3071 SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex); 3039 SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex);
3072 3040
3073#ifdef SIS_LINUX_KERNEL
3074 if(SiS_Pr->SiS_flag_clearbuffer) { 3041 if(SiS_Pr->SiS_flag_clearbuffer) {
3075 SiS_ClearBuffer(SiS_Pr, ModeNo); 3042 SiS_ClearBuffer(SiS_Pr, ModeNo);
3076 } 3043 }
3077#endif
3078 3044
3079 if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) { 3045 if(!(SiS_Pr->SiS_VBInfo & (SetSimuScanMode | SwitchCRT2 | SetCRT2ToLCDA))) {
3080 SiS_WaitRetrace1(SiS_Pr); 3046 SiS_WaitRetrace1(SiS_Pr);
@@ -3104,7 +3070,7 @@ SiS_InitVB(struct SiS_Private *SiS_Pr)
3104static void 3070static void
3105SiS_ResetVB(struct SiS_Private *SiS_Pr) 3071SiS_ResetVB(struct SiS_Private *SiS_Pr)
3106{ 3072{
3107#ifdef SIS315H 3073#ifdef CONFIG_FB_SIS_315
3108 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 3074 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
3109 unsigned short temp; 3075 unsigned short temp;
3110 3076
@@ -3139,7 +3105,7 @@ SiS_StrangeStuff(struct SiS_Private *SiS_Pr)
3139 * which locks CRT2 in some way to CRT1 timing. Disable 3105 * which locks CRT2 in some way to CRT1 timing. Disable
3140 * this here. 3106 * this here.
3141 */ 3107 */
3142#ifdef SIS315H 3108#ifdef CONFIG_FB_SIS_315
3143 if((IS_SIS651) || (IS_SISM650) || 3109 if((IS_SIS651) || (IS_SISM650) ||
3144 SiS_Pr->ChipType == SIS_340 || 3110 SiS_Pr->ChipType == SIS_340 ||
3145 SiS_Pr->ChipType == XGI_40) { 3111 SiS_Pr->ChipType == XGI_40) {
@@ -3160,7 +3126,7 @@ SiS_StrangeStuff(struct SiS_Private *SiS_Pr)
3160static void 3126static void
3161SiS_Handle760(struct SiS_Private *SiS_Pr) 3127SiS_Handle760(struct SiS_Private *SiS_Pr)
3162{ 3128{
3163#ifdef SIS315H 3129#ifdef CONFIG_FB_SIS_315
3164 unsigned int somebase; 3130 unsigned int somebase;
3165 unsigned char temp1, temp2, temp3; 3131 unsigned char temp1, temp2, temp3;
3166 3132
@@ -3170,11 +3136,7 @@ SiS_Handle760(struct SiS_Private *SiS_Pr)
3170 (!(SiS_Pr->SiS_SysFlags & SF_760UMA)) ) 3136 (!(SiS_Pr->SiS_SysFlags & SF_760UMA)) )
3171 return; 3137 return;
3172 3138
3173#ifdef SIS_LINUX_KERNEL
3174 somebase = sisfb_read_mio_pci_word(SiS_Pr, 0x74); 3139 somebase = sisfb_read_mio_pci_word(SiS_Pr, 0x74);
3175#else
3176 somebase = pciReadWord(0x00001000, 0x74);
3177#endif
3178 somebase &= 0xffff; 3140 somebase &= 0xffff;
3179 3141
3180 if(somebase == 0) return; 3142 if(somebase == 0) return;
@@ -3190,105 +3152,34 @@ SiS_Handle760(struct SiS_Private *SiS_Pr)
3190 temp2 = 0x0b; 3152 temp2 = 0x0b;
3191 } 3153 }
3192 3154
3193#ifdef SIS_LINUX_KERNEL
3194 sisfb_write_nbridge_pci_byte(SiS_Pr, 0x7e, temp1); 3155 sisfb_write_nbridge_pci_byte(SiS_Pr, 0x7e, temp1);
3195 sisfb_write_nbridge_pci_byte(SiS_Pr, 0x8d, temp2); 3156 sisfb_write_nbridge_pci_byte(SiS_Pr, 0x8d, temp2);
3196#else
3197 pciWriteByte(0x00000000, 0x7e, temp1);
3198 pciWriteByte(0x00000000, 0x8d, temp2);
3199#endif
3200 3157
3201 SiS_SetRegByte((somebase + 0x85), temp3); 3158 SiS_SetRegByte((somebase + 0x85), temp3);
3202#endif 3159#endif
3203} 3160}
3204 3161
3205/*********************************************/ 3162/*********************************************/
3206/* X.org/XFree86: SET SCREEN PITCH */
3207/*********************************************/
3208
3209#ifdef SIS_XORG_XF86
3210static void
3211SiS_SetPitchCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn)
3212{
3213 SISPtr pSiS = SISPTR(pScrn);
3214 unsigned short HDisplay = pSiS->scrnPitch >> 3;
3215
3216 SiS_SetReg(SiS_Pr->SiS_P3d4,0x13,(HDisplay & 0xFF));
3217 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0xF0,(HDisplay >> 8));
3218}
3219
3220static void
3221SiS_SetPitchCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn)
3222{
3223 SISPtr pSiS = SISPTR(pScrn);
3224 unsigned short HDisplay = pSiS->scrnPitch2 >> 3;
3225
3226 /* Unlock CRT2 */
3227 if(pSiS->VGAEngine == SIS_315_VGA)
3228 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2F, 0x01);
3229 else
3230 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24, 0x01);
3231
3232 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(HDisplay & 0xFF));
3233 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0xF0,(HDisplay >> 8));
3234}
3235
3236static void
3237SiS_SetPitch(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn)
3238{
3239 SISPtr pSiS = SISPTR(pScrn);
3240 bool isslavemode = false;
3241
3242 if( (pSiS->VBFlags2 & VB2_VIDEOBRIDGE) &&
3243 ( ((pSiS->VGAEngine == SIS_300_VGA) &&
3244 (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0xa0) == 0x20) ||
3245 ((pSiS->VGAEngine == SIS_315_VGA) &&
3246 (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x50) == 0x10) ) ) {
3247 isslavemode = true;
3248 }
3249
3250 /* We need to set pitch for CRT1 if bridge is in slave mode, too */
3251 if((pSiS->VBFlags & DISPTYPE_DISP1) || (isslavemode)) {
3252 SiS_SetPitchCRT1(SiS_Pr, pScrn);
3253 }
3254 /* We must not set the pitch for CRT2 if bridge is in slave mode */
3255 if((pSiS->VBFlags & DISPTYPE_DISP2) && (!isslavemode)) {
3256 SiS_SetPitchCRT2(SiS_Pr, pScrn);
3257 }
3258}
3259#endif
3260
3261/*********************************************/
3262/* SiSSetMode() */ 3163/* SiSSetMode() */
3263/*********************************************/ 3164/*********************************************/
3264 3165
3265#ifdef SIS_XORG_XF86
3266/* We need pScrn for setting the pitch correctly */
3267bool
3268SiSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, unsigned short ModeNo, bool dosetpitch)
3269#else
3270bool 3166bool
3271SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 3167SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
3272#endif
3273{ 3168{
3274 SISIOADDRESS BaseAddr = SiS_Pr->IOAddress; 3169 SISIOADDRESS BaseAddr = SiS_Pr->IOAddress;
3275 unsigned short RealModeNo, ModeIdIndex; 3170 unsigned short RealModeNo, ModeIdIndex;
3276 unsigned char backupreg = 0; 3171 unsigned char backupreg = 0;
3277#ifdef SIS_LINUX_KERNEL
3278 unsigned short KeepLockReg; 3172 unsigned short KeepLockReg;
3279 3173
3280 SiS_Pr->UseCustomMode = false; 3174 SiS_Pr->UseCustomMode = false;
3281 SiS_Pr->CRT1UsesCustomMode = false; 3175 SiS_Pr->CRT1UsesCustomMode = false;
3282#endif
3283 3176
3284 SiS_Pr->SiS_flag_clearbuffer = 0; 3177 SiS_Pr->SiS_flag_clearbuffer = 0;
3285 3178
3286 if(SiS_Pr->UseCustomMode) { 3179 if(SiS_Pr->UseCustomMode) {
3287 ModeNo = 0xfe; 3180 ModeNo = 0xfe;
3288 } else { 3181 } else {
3289#ifdef SIS_LINUX_KERNEL
3290 if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1; 3182 if(!(ModeNo & 0x80)) SiS_Pr->SiS_flag_clearbuffer = 1;
3291#endif
3292 ModeNo &= 0x7f; 3183 ModeNo &= 0x7f;
3293 } 3184 }
3294 3185
@@ -3301,13 +3192,8 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
3301 SiS_GetSysFlags(SiS_Pr); 3192 SiS_GetSysFlags(SiS_Pr);
3302 3193
3303 SiS_Pr->SiS_VGAINFO = 0x11; 3194 SiS_Pr->SiS_VGAINFO = 0x11;
3304#if defined(SIS_XORG_XF86) && (defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__))
3305 if(pScrn) SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
3306#endif
3307 3195
3308#ifdef SIS_LINUX_KERNEL
3309 KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); 3196 KeepLockReg = SiS_GetReg(SiS_Pr->SiS_P3c4,0x05);
3310#endif
3311 SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86); 3197 SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86);
3312 3198
3313 SiSInitPCIetc(SiS_Pr); 3199 SiSInitPCIetc(SiS_Pr);
@@ -3344,12 +3230,10 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
3344 SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex); 3230 SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex);
3345 SiS_SetLowModeTest(SiS_Pr, ModeNo); 3231 SiS_SetLowModeTest(SiS_Pr, ModeNo);
3346 3232
3347#ifdef SIS_LINUX_KERNEL
3348 /* Check memory size (kernel framebuffer driver only) */ 3233 /* Check memory size (kernel framebuffer driver only) */
3349 if(!SiS_CheckMemorySize(SiS_Pr, ModeNo, ModeIdIndex)) { 3234 if(!SiS_CheckMemorySize(SiS_Pr, ModeNo, ModeIdIndex)) {
3350 return false; 3235 return false;
3351 } 3236 }
3352#endif
3353 3237
3354 SiS_OpenCRTC(SiS_Pr); 3238 SiS_OpenCRTC(SiS_Pr);
3355 3239
@@ -3384,7 +3268,7 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
3384 SiS_DisplayOn(SiS_Pr); 3268 SiS_DisplayOn(SiS_Pr);
3385 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF); 3269 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF);
3386 3270
3387#ifdef SIS315H 3271#ifdef CONFIG_FB_SIS_315
3388 if(SiS_Pr->ChipType >= SIS_315H) { 3272 if(SiS_Pr->ChipType >= SIS_315H) {
3389 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 3273 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
3390 if(!(SiS_IsDualEdge(SiS_Pr))) { 3274 if(!(SiS_IsDualEdge(SiS_Pr))) {
@@ -3396,7 +3280,7 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
3396 3280
3397 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 3281 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
3398 if(SiS_Pr->ChipType >= SIS_315H) { 3282 if(SiS_Pr->ChipType >= SIS_315H) {
3399#ifdef SIS315H 3283#ifdef CONFIG_FB_SIS_315
3400 if(!SiS_Pr->SiS_ROMNew) { 3284 if(!SiS_Pr->SiS_ROMNew) {
3401 if(SiS_IsVAMode(SiS_Pr)) { 3285 if(SiS_IsVAMode(SiS_Pr)) {
3402 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01); 3286 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01);
@@ -3424,424 +3308,16 @@ SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
3424 } 3308 }
3425 } 3309 }
3426 3310
3427#ifdef SIS_XORG_XF86
3428 if(pScrn) {
3429 /* SetPitch: Adapt to virtual size & position */
3430 if((ModeNo > 0x13) && (dosetpitch)) {
3431 SiS_SetPitch(SiS_Pr, pScrn);
3432 }
3433
3434 /* Backup/Set ModeNo in BIOS scratch area */
3435 SiS_GetSetModeID(pScrn, ModeNo);
3436 }
3437#endif
3438
3439 SiS_CloseCRTC(SiS_Pr); 3311 SiS_CloseCRTC(SiS_Pr);
3440 3312
3441 SiS_Handle760(SiS_Pr); 3313 SiS_Handle760(SiS_Pr);
3442 3314
3443#ifdef SIS_LINUX_KERNEL
3444 /* We never lock registers in XF86 */ 3315 /* We never lock registers in XF86 */
3445 if(KeepLockReg != 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00); 3316 if(KeepLockReg != 0xA1) SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x00);
3446#endif
3447 3317
3448 return true; 3318 return true;
3449} 3319}
3450 3320
3451/*********************************************/
3452/* X.org/XFree86: SiSBIOSSetMode() */
3453/* for non-Dual-Head mode */
3454/*********************************************/
3455
3456#ifdef SIS_XORG_XF86
3457bool
3458SiSBIOSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
3459 DisplayModePtr mode, bool IsCustom)
3460{
3461 SISPtr pSiS = SISPTR(pScrn);
3462 unsigned short ModeNo = 0;
3463
3464 SiS_Pr->UseCustomMode = false;
3465
3466 if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
3467
3468 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n",
3469 SiS_Pr->CHDisplay,
3470 (mode->Flags & V_INTERLACE ? SiS_Pr->CVDisplay * 2 :
3471 (mode->Flags & V_DBLSCAN ? SiS_Pr->CVDisplay / 2 :
3472 SiS_Pr->CVDisplay)));
3473
3474 } else {
3475
3476 /* Don't need vbflags here; checks done earlier */
3477 ModeNo = SiS_GetModeNumber(pScrn, mode, pSiS->VBFlags);
3478 if(!ModeNo) return false;
3479
3480 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo);
3481
3482 }
3483
3484 return(SiSSetMode(SiS_Pr, pScrn, ModeNo, true));
3485}
3486
3487/*********************************************/
3488/* X.org/XFree86: SiSBIOSSetModeCRT2() */
3489/* for Dual-Head modes */
3490/*********************************************/
3491
3492bool
3493SiSBIOSSetModeCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
3494 DisplayModePtr mode, bool IsCustom)
3495{
3496 SISIOADDRESS BaseAddr = SiS_Pr->IOAddress;
3497 SISPtr pSiS = SISPTR(pScrn);
3498#ifdef SISDUALHEAD
3499 SISEntPtr pSiSEnt = pSiS->entityPrivate;
3500#endif
3501 unsigned short ModeIdIndex;
3502 unsigned short ModeNo = 0;
3503 unsigned char backupreg = 0;
3504
3505 SiS_Pr->UseCustomMode = false;
3506
3507 /* Remember: Custom modes for CRT2 are ONLY supported
3508 * -) on the 30x/B/C, and
3509 * -) if CRT2 is LCD or VGA, or CRT1 is LCDA
3510 */
3511
3512 if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
3513
3514 ModeNo = 0xfe;
3515
3516 } else {
3517
3518 ModeNo = SiS_GetModeNumber(pScrn, mode, pSiS->VBFlags);
3519 if(!ModeNo) return false;
3520
3521 }
3522
3523 SiSRegInit(SiS_Pr, BaseAddr);
3524 SiSInitPtr(SiS_Pr);
3525 SiS_GetSysFlags(SiS_Pr);
3526#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__)
3527 SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
3528#else
3529 SiS_Pr->SiS_VGAINFO = 0x11;
3530#endif
3531
3532 SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86);
3533
3534 SiSInitPCIetc(SiS_Pr);
3535 SiSSetLVDSetc(SiS_Pr);
3536 SiSDetermineROMUsage(SiS_Pr);
3537
3538 /* Save mode info so we can set it from within SetMode for CRT1 */
3539#ifdef SISDUALHEAD
3540 if(pSiS->DualHeadMode) {
3541 pSiSEnt->CRT2ModeNo = ModeNo;
3542 pSiSEnt->CRT2DMode = mode;
3543 pSiSEnt->CRT2IsCustom = IsCustom;
3544 pSiSEnt->CRT2CR30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
3545 pSiSEnt->CRT2CR31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31);
3546 pSiSEnt->CRT2CR35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
3547 pSiSEnt->CRT2CR38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
3548#if 0
3549 /* We can't set CRT2 mode before CRT1 mode is set - says who...? */
3550 if(pSiSEnt->CRT1ModeNo == -1) {
3551 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3552 "Setting CRT2 mode delayed until after setting CRT1 mode\n");
3553 return true;
3554 }
3555#endif
3556 pSiSEnt->CRT2ModeSet = true;
3557 }
3558#endif
3559
3560 if(SiS_Pr->UseCustomMode) {
3561
3562 unsigned short temptemp = SiS_Pr->CVDisplay;
3563
3564 if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1;
3565 else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1;
3566
3567 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3568 "Setting custom mode %dx%d on CRT2\n",
3569 SiS_Pr->CHDisplay, temptemp);
3570
3571 } else {
3572
3573 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3574 "Setting standard mode 0x%x on CRT2\n", ModeNo);
3575
3576 }
3577
3578 SiS_UnLockCRT2(SiS_Pr);
3579
3580 if(!SiS_Pr->UseCustomMode) {
3581 if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return false;
3582 } else {
3583 ModeIdIndex = 0;
3584 }
3585
3586 SiS_GetVBType(SiS_Pr);
3587
3588 SiS_InitVB(SiS_Pr);
3589 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
3590 if(SiS_Pr->ChipType >= SIS_315H) {
3591 SiS_ResetVB(SiS_Pr);
3592 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10);
3593 SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x00,0x0c);
3594 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
3595 } else {
3596 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
3597 }
3598 }
3599
3600 /* Get VB information (connectors, connected devices) */
3601 if(!SiS_Pr->UseCustomMode) {
3602 SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 1);
3603 } else {
3604 /* If this is a custom mode, we don't check the modeflag for CRT2Mode */
3605 SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 0);
3606 }
3607 SiS_SetYPbPr(SiS_Pr);
3608 SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex);
3609 SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex);
3610 SiS_SetLowModeTest(SiS_Pr, ModeNo);
3611
3612 SiS_ResetSegmentRegisters(SiS_Pr);
3613
3614 /* Set mode on CRT2 */
3615 if( (SiS_Pr->SiS_VBType & VB_SISVB) ||
3616 (SiS_Pr->SiS_IF_DEF_LVDS == 1) ||
3617 (SiS_Pr->SiS_IF_DEF_CH70xx != 0) ||
3618 (SiS_Pr->SiS_IF_DEF_TRUMPION != 0) ) {
3619 SiS_SetCRT2Group(SiS_Pr, ModeNo);
3620 }
3621
3622 SiS_StrangeStuff(SiS_Pr);
3623
3624 SiS_DisplayOn(SiS_Pr);
3625 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF);
3626
3627 if(SiS_Pr->ChipType >= SIS_315H) {
3628 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
3629 if(!(SiS_IsDualEdge(SiS_Pr))) {
3630 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
3631 }
3632 }
3633 }
3634
3635 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
3636 if(SiS_Pr->ChipType >= SIS_315H) {
3637 if(!SiS_Pr->SiS_ROMNew) {
3638 if(SiS_IsVAMode(SiS_Pr)) {
3639 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x35,0x01);
3640 } else {
3641 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x35,0xFE);
3642 }
3643 }
3644
3645 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg);
3646
3647 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & SetCRT2ToLCD) {
3648 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc);
3649 }
3650 } else if((SiS_Pr->ChipType == SIS_630) ||
3651 (SiS_Pr->ChipType == SIS_730)) {
3652 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg);
3653 }
3654 }
3655
3656 /* SetPitch: Adapt to virtual size & position */
3657 SiS_SetPitchCRT2(SiS_Pr, pScrn);
3658
3659 SiS_Handle760(SiS_Pr);
3660
3661 return true;
3662}
3663
3664/*********************************************/
3665/* X.org/XFree86: SiSBIOSSetModeCRT1() */
3666/* for Dual-Head modes */
3667/*********************************************/
3668
3669bool
3670SiSBIOSSetModeCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
3671 DisplayModePtr mode, bool IsCustom)
3672{
3673 SISIOADDRESS BaseAddr = SiS_Pr->IOAddress;
3674 SISPtr pSiS = SISPTR(pScrn);
3675 unsigned short ModeIdIndex, ModeNo = 0;
3676 unsigned char backupreg = 0;
3677#ifdef SISDUALHEAD
3678 SISEntPtr pSiSEnt = pSiS->entityPrivate;
3679 unsigned char backupcr30, backupcr31, backupcr38, backupcr35, backupp40d=0;
3680 bool backupcustom;
3681#endif
3682
3683 SiS_Pr->UseCustomMode = false;
3684
3685 if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
3686
3687 unsigned short temptemp = SiS_Pr->CVDisplay;
3688
3689 if(SiS_Pr->CModeFlag & DoubleScanMode) temptemp >>= 1;
3690 else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1;
3691
3692 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3693 "Setting custom mode %dx%d on CRT1\n",
3694 SiS_Pr->CHDisplay, temptemp);
3695 ModeNo = 0xfe;
3696
3697 } else {
3698
3699 ModeNo = SiS_GetModeNumber(pScrn, mode, 0); /* don't give VBFlags */
3700 if(!ModeNo) return false;
3701
3702 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3703 "Setting standard mode 0x%x on CRT1\n", ModeNo);
3704 }
3705
3706 SiSInitPtr(SiS_Pr);
3707 SiSRegInit(SiS_Pr, BaseAddr);
3708 SiS_GetSysFlags(SiS_Pr);
3709#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__)
3710 SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
3711#else
3712 SiS_Pr->SiS_VGAINFO = 0x11;
3713#endif
3714
3715 SiS_SetReg(SiS_Pr->SiS_P3c4,0x05,0x86);
3716
3717 SiSInitPCIetc(SiS_Pr);
3718 SiSSetLVDSetc(SiS_Pr);
3719 SiSDetermineROMUsage(SiS_Pr);
3720
3721 SiS_UnLockCRT2(SiS_Pr);
3722
3723 if(!SiS_Pr->UseCustomMode) {
3724 if(!(SiS_SearchModeID(SiS_Pr, &ModeNo, &ModeIdIndex))) return false;
3725 } else {
3726 ModeIdIndex = 0;
3727 }
3728
3729 /* Determine VBType */
3730 SiS_GetVBType(SiS_Pr);
3731
3732 SiS_InitVB(SiS_Pr);
3733 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
3734 if(SiS_Pr->ChipType >= SIS_315H) {
3735 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
3736 } else {
3737 backupreg = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
3738 }
3739 }
3740
3741 /* Get VB information (connectors, connected devices) */
3742 /* (We don't care if the current mode is a CRT2 mode) */
3743 SiS_GetVBInfo(SiS_Pr, ModeNo, ModeIdIndex, 0);
3744 SiS_SetYPbPr(SiS_Pr);
3745 SiS_SetTVMode(SiS_Pr, ModeNo, ModeIdIndex);
3746 SiS_GetLCDResInfo(SiS_Pr, ModeNo, ModeIdIndex);
3747 SiS_SetLowModeTest(SiS_Pr, ModeNo);
3748
3749 SiS_OpenCRTC(SiS_Pr);
3750
3751 /* Set mode on CRT1 */
3752 SiS_SetCRT1Group(SiS_Pr, ModeNo, ModeIdIndex);
3753 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
3754 SiS_SetCRT2Group(SiS_Pr, ModeNo);
3755 }
3756
3757 /* SetPitch: Adapt to virtual size & position */
3758 SiS_SetPitchCRT1(SiS_Pr, pScrn);
3759
3760 SiS_HandleCRT1(SiS_Pr);
3761
3762 SiS_StrangeStuff(SiS_Pr);
3763
3764 SiS_CloseCRTC(SiS_Pr);
3765
3766#ifdef SISDUALHEAD
3767 if(pSiS->DualHeadMode) {
3768 pSiSEnt->CRT1ModeNo = ModeNo;
3769 pSiSEnt->CRT1DMode = mode;
3770 }
3771#endif
3772
3773 if(SiS_Pr->UseCustomMode) {
3774 SiS_Pr->CRT1UsesCustomMode = true;
3775 SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock;
3776 SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag;
3777 } else {
3778 SiS_Pr->CRT1UsesCustomMode = false;
3779 }
3780
3781 /* Reset CRT2 if changing mode on CRT1 */
3782#ifdef SISDUALHEAD
3783 if(pSiS->DualHeadMode) {
3784 if(pSiSEnt->CRT2ModeNo != -1) {
3785 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
3786 "(Re-)Setting mode for CRT2\n");
3787 backupcustom = SiS_Pr->UseCustomMode;
3788 backupcr30 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
3789 backupcr31 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31);
3790 backupcr35 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
3791 backupcr38 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
3792 if(SiS_Pr->SiS_VBType & VB_SISVB) {
3793 /* Backup LUT-enable */
3794 if(pSiSEnt->CRT2ModeSet) {
3795 backupp40d = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x0d) & 0x08;
3796 }
3797 }
3798 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
3799 SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,pSiSEnt->CRT2CR30);
3800 SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,pSiSEnt->CRT2CR31);
3801 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,pSiSEnt->CRT2CR35);
3802 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,pSiSEnt->CRT2CR38);
3803 }
3804
3805 SiSBIOSSetModeCRT2(SiS_Pr, pSiSEnt->pScrn_1,
3806 pSiSEnt->CRT2DMode, pSiSEnt->CRT2IsCustom);
3807
3808 SiS_SetReg(SiS_Pr->SiS_P3d4,0x30,backupcr30);
3809 SiS_SetReg(SiS_Pr->SiS_P3d4,0x31,backupcr31);
3810 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupcr35);
3811 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupcr38);
3812 if(SiS_Pr->SiS_VBType & VB_SISVB) {
3813 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0d, ~0x08, backupp40d);
3814 }
3815 SiS_Pr->UseCustomMode = backupcustom;
3816 }
3817 }
3818#endif
3819
3820 /* Warning: From here, the custom mode entries in SiS_Pr are
3821 * possibly overwritten
3822 */
3823
3824 SiS_DisplayOn(SiS_Pr);
3825 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0xFF);
3826
3827 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
3828 if(SiS_Pr->ChipType >= SIS_315H) {
3829 SiS_SetReg(SiS_Pr->SiS_P3d4,0x38,backupreg);
3830 } else if((SiS_Pr->ChipType == SIS_630) ||
3831 (SiS_Pr->ChipType == SIS_730)) {
3832 SiS_SetReg(SiS_Pr->SiS_P3d4,0x35,backupreg);
3833 }
3834 }
3835
3836 SiS_Handle760(SiS_Pr);
3837
3838 /* Backup/Set ModeNo in BIOS scratch area */
3839 SiS_GetSetModeID(pScrn,ModeNo);
3840
3841 return true;
3842}
3843#endif /* Linux_XF86 */
3844
3845#ifndef GETBITSTR 3321#ifndef GETBITSTR
3846#define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) 3322#define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l))
3847#define GENMASK(mask) BITMASK(1?mask,0?mask) 3323#define GENMASK(mask) BITMASK(1?mask,0?mask)
@@ -3927,7 +3403,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
3927 SiS_Pr->CVBlankStart = SiS_Pr->SiS_VGAVDE; 3403 SiS_Pr->CVBlankStart = SiS_Pr->SiS_VGAVDE;
3928 3404
3929 if(SiS_Pr->ChipType < SIS_315H) { 3405 if(SiS_Pr->ChipType < SIS_315H) {
3930#ifdef SIS300 3406#ifdef CONFIG_FB_SIS_300
3931 tempbx = SiS_Pr->SiS_VGAHT; 3407 tempbx = SiS_Pr->SiS_VGAHT;
3932 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 3408 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3933 tempbx = SiS_Pr->PanelHT; 3409 tempbx = SiS_Pr->PanelHT;
@@ -3936,7 +3412,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
3936 remaining = tempbx % 8; 3412 remaining = tempbx % 8;
3937#endif 3413#endif
3938 } else { 3414 } else {
3939#ifdef SIS315H 3415#ifdef CONFIG_FB_SIS_315
3940 /* OK for LCDA, LVDS */ 3416 /* OK for LCDA, LVDS */
3941 tempbx = SiS_Pr->PanelHT - SiS_Pr->PanelXRes; 3417 tempbx = SiS_Pr->PanelHT - SiS_Pr->PanelXRes;
3942 tempax = SiS_Pr->SiS_VGAHDE; /* not /2 ! */ 3418 tempax = SiS_Pr->SiS_VGAHDE; /* not /2 ! */
@@ -3950,7 +3426,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
3950 SiS_Pr->CHTotal = SiS_Pr->CHBlankEnd = tempbx; 3426 SiS_Pr->CHTotal = SiS_Pr->CHBlankEnd = tempbx;
3951 3427
3952 if(SiS_Pr->ChipType < SIS_315H) { 3428 if(SiS_Pr->ChipType < SIS_315H) {
3953#ifdef SIS300 3429#ifdef CONFIG_FB_SIS_300
3954 if(SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) { 3430 if(SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) {
3955 SiS_Pr->CHSyncStart = SiS_Pr->SiS_VGAHDE + ((SiS_Pr->PanelHRS + 1) & ~1); 3431 SiS_Pr->CHSyncStart = SiS_Pr->SiS_VGAHDE + ((SiS_Pr->PanelHRS + 1) & ~1);
3956 SiS_Pr->CHSyncEnd = SiS_Pr->CHSyncStart + SiS_Pr->PanelHRE; 3432 SiS_Pr->CHSyncEnd = SiS_Pr->CHSyncStart + SiS_Pr->PanelHRE;
@@ -3982,7 +3458,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
3982 } 3458 }
3983#endif 3459#endif
3984 } else { 3460 } else {
3985#ifdef SIS315H 3461#ifdef CONFIG_FB_SIS_315
3986 tempax = VGAHDE; 3462 tempax = VGAHDE;
3987 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 3463 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3988 tempbx = SiS_Pr->PanelXRes; 3464 tempbx = SiS_Pr->PanelXRes;
@@ -4001,7 +3477,7 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
4001 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 3477 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
4002 tempax = SiS_Pr->PanelYRes; 3478 tempax = SiS_Pr->PanelYRes;
4003 } else if(SiS_Pr->ChipType < SIS_315H) { 3479 } else if(SiS_Pr->ChipType < SIS_315H) {
4004#ifdef SIS300 3480#ifdef CONFIG_FB_SIS_300
4005 /* Stupid hack for 640x400/320x200 */ 3481 /* Stupid hack for 640x400/320x200 */
4006 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 3482 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
4007 if((tempax + tempbx) == 438) tempbx += 16; 3483 if((tempax + tempbx) == 438) tempbx += 16;
@@ -4054,36 +3530,12 @@ SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
4054 if(modeflag & DoubleScanMode) tempax |= 0x80; 3530 if(modeflag & DoubleScanMode) tempax |= 0x80;
4055 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,tempax); 3531 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,0x5F,tempax);
4056 3532
4057#ifdef SIS_XORG_XF86
4058#ifdef TWDEBUG
4059 xf86DrvMsg(0, X_INFO, "%d %d %d %d %d %d %d %d (%d %d %d %d)\n",
4060 SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal,
4061 SiS_Pr->CVDisplay, SiS_Pr->CVSyncStart, SiS_Pr->CVSyncEnd, SiS_Pr->CVTotal,
4062 SiS_Pr->CHBlankStart, SiS_Pr->CHBlankEnd, SiS_Pr->CVBlankStart, SiS_Pr->CVBlankEnd);
4063 xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n",
4064 SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1],
4065 SiS_Pr->CCRT1CRTC[2], SiS_Pr->CCRT1CRTC[3],
4066 SiS_Pr->CCRT1CRTC[4], SiS_Pr->CCRT1CRTC[5],
4067 SiS_Pr->CCRT1CRTC[6], SiS_Pr->CCRT1CRTC[7]);
4068 xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n",
4069 SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9],
4070 SiS_Pr->CCRT1CRTC[10], SiS_Pr->CCRT1CRTC[11],
4071 SiS_Pr->CCRT1CRTC[12], SiS_Pr->CCRT1CRTC[13],
4072 SiS_Pr->CCRT1CRTC[14], SiS_Pr->CCRT1CRTC[15]);
4073 xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", SiS_Pr->CCRT1CRTC[16]);
4074#endif
4075#endif
4076} 3533}
4077 3534
4078void 3535void
4079SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, 3536SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata,
4080 int xres, int yres, 3537 int xres, int yres,
4081#ifdef SIS_XORG_XF86
4082 DisplayModePtr current
4083#endif
4084#ifdef SIS_LINUX_KERNEL
4085 struct fb_var_screeninfo *var, bool writeres 3538 struct fb_var_screeninfo *var, bool writeres
4086#endif
4087) 3539)
4088{ 3540{
4089 unsigned short HRE, HBE, HRS, HBS, HDE, HT; 3541 unsigned short HRE, HBE, HRS, HBS, HDE, HT;
@@ -4127,25 +3579,10 @@ SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata,
4127 3579
4128 D = B - F - C; 3580 D = B - F - C;
4129 3581
4130#ifdef SIS_XORG_XF86
4131 current->HDisplay = (E * 8);
4132 current->HSyncStart = (E * 8) + (F * 8);
4133 current->HSyncEnd = (E * 8) + (F * 8) + (C * 8);
4134 current->HTotal = (E * 8) + (F * 8) + (C * 8) + (D * 8);
4135#ifdef TWDEBUG
4136 xf86DrvMsg(0, X_INFO,
4137 "H: A %d B %d C %d D %d E %d F %d HT %d HDE %d HRS %d HBS %d HBE %d HRE %d\n",
4138 A, B, C, D, E, F, HT, HDE, HRS, HBS, HBE, HRE);
4139#else
4140 (void)VBS; (void)HBS; (void)A;
4141#endif
4142#endif
4143#ifdef SIS_LINUX_KERNEL
4144 if(writeres) var->xres = xres = E * 8; 3582 if(writeres) var->xres = xres = E * 8;
4145 var->left_margin = D * 8; 3583 var->left_margin = D * 8;
4146 var->right_margin = F * 8; 3584 var->right_margin = F * 8;
4147 var->hsync_len = C * 8; 3585 var->hsync_len = C * 8;
4148#endif
4149 3586
4150 /* Vertical */ 3587 /* Vertical */
4151 sr_data = crdata[13]; 3588 sr_data = crdata[13];
@@ -4192,30 +3629,10 @@ SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata,
4192 3629
4193 D = B - F - C; 3630 D = B - F - C;
4194 3631
4195#ifdef SIS_XORG_XF86
4196 current->VDisplay = VDE + 1;
4197 current->VSyncStart = VRS + 1;
4198 current->VSyncEnd = ((VRS & ~0x1f) | VRE) + 1;
4199 if(VRE <= (VRS & 0x1f)) current->VSyncEnd += 32;
4200 current->VTotal = E + D + C + F;
4201#if 0
4202 current->VDisplay = E;
4203 current->VSyncStart = E + D;
4204 current->VSyncEnd = E + D + C;
4205 current->VTotal = E + D + C + F;
4206#endif
4207#ifdef TWDEBUG
4208 xf86DrvMsg(0, X_INFO,
4209 "V: A %d B %d C %d D %d E %d F %d VT %d VDE %d VRS %d VBS %d VBE %d VRE %d\n",
4210 A, B, C, D, E, F, VT, VDE, VRS, VBS, VBE, VRE);
4211#endif
4212#endif
4213#ifdef SIS_LINUX_KERNEL
4214 if(writeres) var->yres = yres = E; 3632 if(writeres) var->yres = yres = E;
4215 var->upper_margin = D; 3633 var->upper_margin = D;
4216 var->lower_margin = F; 3634 var->lower_margin = F;
4217 var->vsync_len = C; 3635 var->vsync_len = C;
4218#endif
4219 3636
4220 if((xres == 320) && ((yres == 200) || (yres == 240))) { 3637 if((xres == 320) && ((yres == 200) || (yres == 240))) {
4221 /* Terrible hack, but correct CRTC data for 3638 /* Terrible hack, but correct CRTC data for
@@ -4224,17 +3641,9 @@ SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata,
4224 * a negative D. The CRT controller does not 3641 * a negative D. The CRT controller does not
4225 * seem to like correcting HRE to 50) 3642 * seem to like correcting HRE to 50)
4226 */ 3643 */
4227#ifdef SIS_XORG_XF86
4228 current->HDisplay = 320;
4229 current->HSyncStart = 328;
4230 current->HSyncEnd = 376;
4231 current->HTotal = 400;
4232#endif
4233#ifdef SIS_LINUX_KERNEL
4234 var->left_margin = (400 - 376); 3644 var->left_margin = (400 - 376);
4235 var->right_margin = (328 - 320); 3645 var->right_margin = (328 - 320);
4236 var->hsync_len = (376 - 328); 3646 var->hsync_len = (376 - 328);
4237#endif
4238 3647
4239 } 3648 }
4240 3649
diff --git a/drivers/video/sis/init.h b/drivers/video/sis/init.h
index b96005c39c67..aff73842d877 100644
--- a/drivers/video/sis/init.h
+++ b/drivers/video/sis/init.h
@@ -53,21 +53,8 @@
53#ifndef _INIT_H_ 53#ifndef _INIT_H_
54#define _INIT_H_ 54#define _INIT_H_
55 55
56#include "osdef.h"
57#include "initdef.h" 56#include "initdef.h"
58 57
59#ifdef SIS_XORG_XF86
60#include "sis.h"
61#define SIS_NEED_inSISREG
62#define SIS_NEED_inSISREGW
63#define SIS_NEED_inSISREGL
64#define SIS_NEED_outSISREG
65#define SIS_NEED_outSISREGW
66#define SIS_NEED_outSISREGL
67#include "sis_regs.h"
68#endif
69
70#ifdef SIS_LINUX_KERNEL
71#include "vgatypes.h" 58#include "vgatypes.h"
72#include "vstruct.h" 59#include "vstruct.h"
73#ifdef SIS_CP 60#ifdef SIS_CP
@@ -78,7 +65,6 @@
78#include <linux/fb.h> 65#include <linux/fb.h>
79#include "sis.h" 66#include "sis.h"
80#include <video/sisfb.h> 67#include <video/sisfb.h>
81#endif
82 68
83/* Mode numbers */ 69/* Mode numbers */
84static const unsigned short ModeIndex_320x200[] = {0x59, 0x41, 0x00, 0x4f}; 70static const unsigned short ModeIndex_320x200[] = {0x59, 0x41, 0x00, 0x4f};
@@ -286,7 +272,7 @@ static const struct SiS_ModeResInfo_S SiS_ModeResInfo[] =
286 { 1280, 854, 8,16} /* 0x22 */ 272 { 1280, 854, 8,16} /* 0x22 */
287}; 273};
288 274
289#if defined(SIS300) || defined(SIS315H) 275#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
290static const struct SiS_StandTable_S SiS_StandTable[]= 276static const struct SiS_StandTable_S SiS_StandTable[]=
291{ 277{
292/* 0x00: MD_0_200 */ 278/* 0x00: MD_0_200 */
@@ -1521,10 +1507,6 @@ static const struct SiS_LVDSCRT1Data SiS_LVDSCRT1640x480_1_H[] =
1521}; 1507};
1522 1508
1523bool SiSInitPtr(struct SiS_Private *SiS_Pr); 1509bool SiSInitPtr(struct SiS_Private *SiS_Pr);
1524#ifdef SIS_XORG_XF86
1525unsigned short SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay,
1526 int Depth, bool FSTN, int LCDwith, int LCDheight);
1527#endif
1528unsigned short SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay, 1510unsigned short SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay,
1529 int VDisplay, int Depth, bool FSTN, 1511 int VDisplay, int Depth, bool FSTN,
1530 unsigned short CustomT, int LCDwith, int LCDheight, 1512 unsigned short CustomT, int LCDwith, int LCDheight,
@@ -1534,33 +1516,14 @@ unsigned short SiS_GetModeID_TV(int VGAEngine, unsigned int VBFlags, int HDispla
1534unsigned short SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay, 1516unsigned short SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay,
1535 int VDisplay, int Depth, unsigned int VBFlags2); 1517 int VDisplay, int Depth, unsigned int VBFlags2);
1536 1518
1537void SiS_SetReg(SISIOADDRESS port, unsigned short index, unsigned short data);
1538void SiS_SetRegByte(SISIOADDRESS port, unsigned short data);
1539void SiS_SetRegShort(SISIOADDRESS port, unsigned short data);
1540void SiS_SetRegLong(SISIOADDRESS port, unsigned int data);
1541unsigned char SiS_GetReg(SISIOADDRESS port, unsigned short index);
1542unsigned char SiS_GetRegByte(SISIOADDRESS port);
1543unsigned short SiS_GetRegShort(SISIOADDRESS port);
1544unsigned int SiS_GetRegLong(SISIOADDRESS port);
1545void SiS_SetRegANDOR(SISIOADDRESS Port, unsigned short Index, unsigned short DataAND,
1546 unsigned short DataOR);
1547void SiS_SetRegAND(SISIOADDRESS Port,unsigned short Index, unsigned short DataAND);
1548void SiS_SetRegOR(SISIOADDRESS Port,unsigned short Index, unsigned short DataOR);
1549
1550void SiS_DisplayOn(struct SiS_Private *SiS_Pr); 1519void SiS_DisplayOn(struct SiS_Private *SiS_Pr);
1551void SiS_DisplayOff(struct SiS_Private *SiS_Pr); 1520void SiS_DisplayOff(struct SiS_Private *SiS_Pr);
1552void SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); 1521void SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr);
1553#ifndef SIS_LINUX_KERNEL
1554void SiSSetLVDSetc(struct SiS_Private *SiS_Pr);
1555#endif
1556void SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable); 1522void SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable);
1557void SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable); 1523void SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable);
1558unsigned short SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 1524unsigned short SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1559 unsigned short ModeIdIndex); 1525 unsigned short ModeIdIndex);
1560bool SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr); 1526bool SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr);
1561#ifndef SIS_LINUX_KERNEL
1562void SiS_GetVBType(struct SiS_Private *SiS_Pr);
1563#endif
1564 1527
1565bool SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo, 1528bool SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo,
1566 unsigned short *ModeIdIndex); 1529 unsigned short *ModeIdIndex);
@@ -1572,37 +1535,19 @@ unsigned short SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short Mode
1572 unsigned short ModeIdIndex); 1535 unsigned short ModeIdIndex);
1573unsigned short SiS_GetOffset(struct SiS_Private *SiS_Pr,unsigned short ModeNo, 1536unsigned short SiS_GetOffset(struct SiS_Private *SiS_Pr,unsigned short ModeNo,
1574 unsigned short ModeIdIndex, unsigned short RRTI); 1537 unsigned short ModeIdIndex, unsigned short RRTI);
1575#ifdef SIS300 1538#ifdef CONFIG_FB_SIS_300
1576void SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1, 1539void SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1,
1577 unsigned short *idx2); 1540 unsigned short *idx2);
1578unsigned short SiS_GetFIFOThresholdB300(unsigned short idx1, unsigned short idx2); 1541unsigned short SiS_GetFIFOThresholdB300(unsigned short idx1, unsigned short idx2);
1579unsigned short SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index); 1542unsigned short SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index);
1580#endif 1543#endif
1581void SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex); 1544void SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
1582#ifdef SIS_XORG_XF86
1583bool SiSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn, unsigned short ModeNo,
1584 bool dosetpitch);
1585bool SiSBIOSSetMode(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
1586 DisplayModePtr mode, bool IsCustom);
1587bool SiSBIOSSetModeCRT2(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
1588 DisplayModePtr mode, bool IsCustom);
1589bool SiSBIOSSetModeCRT1(struct SiS_Private *SiS_Pr, ScrnInfoPtr pScrn,
1590 DisplayModePtr mode, bool IsCustom);
1591#endif
1592#ifdef SIS_LINUX_KERNEL
1593bool SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo); 1545bool SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo);
1594#endif
1595void SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth); 1546void SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth);
1596void SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 1547void SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1597 unsigned short ModeIdIndex); 1548 unsigned short ModeIdIndex);
1598#ifdef SIS_XORG_XF86
1599void SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres,
1600 int yres, DisplayModePtr current);
1601#endif
1602#ifdef SIS_LINUX_KERNEL
1603void SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres, 1549void SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres,
1604 int yres, struct fb_var_screeninfo *var, bool writeres); 1550 int yres, struct fb_var_screeninfo *var, bool writeres);
1605#endif
1606 1551
1607/* From init301.c: */ 1552/* From init301.c: */
1608extern void SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 1553extern void SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
@@ -1626,29 +1571,16 @@ extern unsigned short SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short
1626extern bool SiS_IsVAMode(struct SiS_Private *); 1571extern bool SiS_IsVAMode(struct SiS_Private *);
1627extern bool SiS_IsDualEdge(struct SiS_Private *); 1572extern bool SiS_IsDualEdge(struct SiS_Private *);
1628 1573
1629#ifdef SIS_XORG_XF86 1574#ifdef CONFIG_FB_SIS_300
1630/* From other modules: */
1631extern unsigned short SiS_CheckBuildCustomMode(ScrnInfoPtr pScrn, DisplayModePtr mode,
1632 unsigned int VBFlags);
1633extern unsigned char SiS_GetSetBIOSScratch(ScrnInfoPtr pScrn, unsigned short offset,
1634 unsigned char value);
1635extern unsigned char SiS_GetSetModeID(ScrnInfoPtr pScrn, unsigned char id);
1636extern unsigned short SiS_GetModeNumber(ScrnInfoPtr pScrn, DisplayModePtr mode,
1637 unsigned int VBFlags);
1638#endif
1639
1640#ifdef SIS_LINUX_KERNEL
1641#ifdef SIS300
1642extern unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg); 1575extern unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg);
1643extern void sisfb_write_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg, 1576extern void sisfb_write_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg,
1644 unsigned int val); 1577 unsigned int val);
1645#endif 1578#endif
1646#ifdef SIS315H 1579#ifdef CONFIG_FB_SIS_315
1647extern void sisfb_write_nbridge_pci_byte(struct SiS_Private *SiS_Pr, int reg, 1580extern void sisfb_write_nbridge_pci_byte(struct SiS_Private *SiS_Pr, int reg,
1648 unsigned char val); 1581 unsigned char val);
1649extern unsigned int sisfb_read_mio_pci_word(struct SiS_Private *SiS_Pr, int reg); 1582extern unsigned int sisfb_read_mio_pci_word(struct SiS_Private *SiS_Pr, int reg);
1650#endif 1583#endif
1651#endif
1652 1584
1653#endif 1585#endif
1654 1586
diff --git a/drivers/video/sis/init301.c b/drivers/video/sis/init301.c
index da33d801c22e..a89e3cafd5ad 100644
--- a/drivers/video/sis/init301.c
+++ b/drivers/video/sis/init301.c
@@ -57,10 +57,6 @@
57 * 57 *
58 */ 58 */
59 59
60#ifdef HAVE_CONFIG_H
61#include "config.h"
62#endif
63
64#if 1 60#if 1
65#define SET_EMI /* 302LV/ELV: Set EMI values */ 61#define SET_EMI /* 302LV/ELV: Set EMI values */
66#endif 62#endif
@@ -75,11 +71,11 @@
75 71
76#include "init301.h" 72#include "init301.h"
77 73
78#ifdef SIS300 74#ifdef CONFIG_FB_SIS_300
79#include "oem300.h" 75#include "oem300.h"
80#endif 76#endif
81 77
82#ifdef SIS315H 78#ifdef CONFIG_FB_SIS_315
83#include "oem310.h" 79#include "oem310.h"
84#endif 80#endif
85 81
@@ -87,9 +83,7 @@
87#define SiS_I2CDELAYSHORT 150 83#define SiS_I2CDELAYSHORT 150
88 84
89static unsigned short SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr); 85static unsigned short SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr);
90#ifdef SIS_LINUX_KERNEL
91static void SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); 86static void SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
92#endif
93 87
94/*********************************************/ 88/*********************************************/
95/* HELPER: Lock/Unlock CRT2 */ 89/* HELPER: Lock/Unlock CRT2 */
@@ -106,9 +100,7 @@ SiS_UnLockCRT2(struct SiS_Private *SiS_Pr)
106 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); 100 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01);
107} 101}
108 102
109#ifdef SIS_LINUX_KERNEL
110static 103static
111#endif
112void 104void
113SiS_LockCRT2(struct SiS_Private *SiS_Pr) 105SiS_LockCRT2(struct SiS_Private *SiS_Pr)
114{ 106{
@@ -138,7 +130,7 @@ SiS_SetRegSR11ANDOR(struct SiS_Private *SiS_Pr, unsigned short DataAND, unsigned
138/* HELPER: Get Pointer to LCD structure */ 130/* HELPER: Get Pointer to LCD structure */
139/*********************************************/ 131/*********************************************/
140 132
141#ifdef SIS315H 133#ifdef CONFIG_FB_SIS_315
142static unsigned char * 134static unsigned char *
143GetLCDStructPtr661(struct SiS_Private *SiS_Pr) 135GetLCDStructPtr661(struct SiS_Private *SiS_Pr)
144{ 136{
@@ -404,7 +396,7 @@ SiS_SaveCRT2Info(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
404/* HELPER: GET SOME DATA FROM BIOS ROM */ 396/* HELPER: GET SOME DATA FROM BIOS ROM */
405/*********************************************/ 397/*********************************************/
406 398
407#ifdef SIS300 399#ifdef CONFIG_FB_SIS_300
408static bool 400static bool
409SiS_CR36BIOSWord23b(struct SiS_Private *SiS_Pr) 401SiS_CR36BIOSWord23b(struct SiS_Private *SiS_Pr)
410{ 402{
@@ -449,7 +441,7 @@ SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime)
449 SiS_GetReg(SiS_Pr->SiS_P3c4, 0x05); 441 SiS_GetReg(SiS_Pr->SiS_P3c4, 0x05);
450} 442}
451 443
452#if defined(SIS300) || defined(SIS315H) 444#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
453static void 445static void
454SiS_GenericDelay(struct SiS_Private *SiS_Pr, unsigned short delay) 446SiS_GenericDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
455{ 447{
@@ -457,7 +449,7 @@ SiS_GenericDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
457} 449}
458#endif 450#endif
459 451
460#ifdef SIS315H 452#ifdef CONFIG_FB_SIS_315
461static void 453static void
462SiS_LongDelay(struct SiS_Private *SiS_Pr, unsigned short delay) 454SiS_LongDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
463{ 455{
@@ -467,7 +459,7 @@ SiS_LongDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
467} 459}
468#endif 460#endif
469 461
470#if defined(SIS300) || defined(SIS315H) 462#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
471static void 463static void
472SiS_ShortDelay(struct SiS_Private *SiS_Pr, unsigned short delay) 464SiS_ShortDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
473{ 465{
@@ -480,14 +472,14 @@ SiS_ShortDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
480static void 472static void
481SiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime) 473SiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime)
482{ 474{
483#if defined(SIS300) || defined(SIS315H) 475#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
484 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 476 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
485 unsigned short PanelID, DelayIndex, Delay=0; 477 unsigned short PanelID, DelayIndex, Delay=0;
486#endif 478#endif
487 479
488 if(SiS_Pr->ChipType < SIS_315H) { 480 if(SiS_Pr->ChipType < SIS_315H) {
489 481
490#ifdef SIS300 482#ifdef CONFIG_FB_SIS_300
491 483
492 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); 484 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
493 if(SiS_Pr->SiS_VBType & VB_SISVB) { 485 if(SiS_Pr->SiS_VBType & VB_SISVB) {
@@ -513,11 +505,11 @@ SiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime)
513 } 505 }
514 SiS_ShortDelay(SiS_Pr, Delay); 506 SiS_ShortDelay(SiS_Pr, Delay);
515 507
516#endif /* SIS300 */ 508#endif /* CONFIG_FB_SIS_300 */
517 509
518 } else { 510 } else {
519 511
520#ifdef SIS315H 512#ifdef CONFIG_FB_SIS_315
521 513
522 if((SiS_Pr->ChipType >= SIS_661) || 514 if((SiS_Pr->ChipType >= SIS_661) ||
523 (SiS_Pr->ChipType <= SIS_315PRO) || 515 (SiS_Pr->ChipType <= SIS_315PRO) ||
@@ -579,12 +571,12 @@ SiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime)
579 571
580 } 572 }
581 573
582#endif /* SIS315H */ 574#endif /* CONFIG_FB_SIS_315 */
583 575
584 } 576 }
585} 577}
586 578
587#ifdef SIS315H 579#ifdef CONFIG_FB_SIS_315
588static void 580static void
589SiS_PanelDelayLoop(struct SiS_Private *SiS_Pr, unsigned short DelayTime, unsigned short DelayLoop) 581SiS_PanelDelayLoop(struct SiS_Private *SiS_Pr, unsigned short DelayTime, unsigned short DelayLoop)
590{ 582{
@@ -613,7 +605,7 @@ SiS_WaitRetrace1(struct SiS_Private *SiS_Pr)
613 while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); 605 while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog);
614} 606}
615 607
616#if defined(SIS300) || defined(SIS315H) 608#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
617static void 609static void
618SiS_WaitRetrace2(struct SiS_Private *SiS_Pr, unsigned short reg) 610SiS_WaitRetrace2(struct SiS_Private *SiS_Pr, unsigned short reg)
619{ 611{
@@ -630,7 +622,7 @@ static void
630SiS_WaitVBRetrace(struct SiS_Private *SiS_Pr) 622SiS_WaitVBRetrace(struct SiS_Private *SiS_Pr)
631{ 623{
632 if(SiS_Pr->ChipType < SIS_315H) { 624 if(SiS_Pr->ChipType < SIS_315H) {
633#ifdef SIS300 625#ifdef CONFIG_FB_SIS_300
634 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 626 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
635 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; 627 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return;
636 } 628 }
@@ -641,7 +633,7 @@ SiS_WaitVBRetrace(struct SiS_Private *SiS_Pr)
641 } 633 }
642#endif 634#endif
643 } else { 635 } else {
644#ifdef SIS315H 636#ifdef CONFIG_FB_SIS_315
645 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { 637 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) {
646 SiS_WaitRetrace1(SiS_Pr); 638 SiS_WaitRetrace1(SiS_Pr);
647 } else { 639 } else {
@@ -686,7 +678,7 @@ SiS_VBLongWait(struct SiS_Private *SiS_Pr)
686/* HELPER: MISC */ 678/* HELPER: MISC */
687/*********************************************/ 679/*********************************************/
688 680
689#ifdef SIS300 681#ifdef CONFIG_FB_SIS_300
690static bool 682static bool
691SiS_Is301B(struct SiS_Private *SiS_Pr) 683SiS_Is301B(struct SiS_Private *SiS_Pr)
692{ 684{
@@ -708,7 +700,7 @@ SiS_CRT2IsLCD(struct SiS_Private *SiS_Pr)
708bool 700bool
709SiS_IsDualEdge(struct SiS_Private *SiS_Pr) 701SiS_IsDualEdge(struct SiS_Private *SiS_Pr)
710{ 702{
711#ifdef SIS315H 703#ifdef CONFIG_FB_SIS_315
712 if(SiS_Pr->ChipType >= SIS_315H) { 704 if(SiS_Pr->ChipType >= SIS_315H) {
713 if((SiS_Pr->ChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { 705 if((SiS_Pr->ChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) {
714 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableDualEdge) return true; 706 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableDualEdge) return true;
@@ -721,7 +713,7 @@ SiS_IsDualEdge(struct SiS_Private *SiS_Pr)
721bool 713bool
722SiS_IsVAMode(struct SiS_Private *SiS_Pr) 714SiS_IsVAMode(struct SiS_Private *SiS_Pr)
723{ 715{
724#ifdef SIS315H 716#ifdef CONFIG_FB_SIS_315
725 unsigned short flag; 717 unsigned short flag;
726 718
727 if(SiS_Pr->ChipType >= SIS_315H) { 719 if(SiS_Pr->ChipType >= SIS_315H) {
@@ -732,7 +724,7 @@ SiS_IsVAMode(struct SiS_Private *SiS_Pr)
732 return false; 724 return false;
733} 725}
734 726
735#ifdef SIS315H 727#ifdef CONFIG_FB_SIS_315
736static bool 728static bool
737SiS_IsVAorLCD(struct SiS_Private *SiS_Pr) 729SiS_IsVAorLCD(struct SiS_Private *SiS_Pr)
738{ 730{
@@ -745,7 +737,7 @@ SiS_IsVAorLCD(struct SiS_Private *SiS_Pr)
745static bool 737static bool
746SiS_IsDualLink(struct SiS_Private *SiS_Pr) 738SiS_IsDualLink(struct SiS_Private *SiS_Pr)
747{ 739{
748#ifdef SIS315H 740#ifdef CONFIG_FB_SIS_315
749 if(SiS_Pr->ChipType >= SIS_315H) { 741 if(SiS_Pr->ChipType >= SIS_315H) {
750 if((SiS_CRT2IsLCD(SiS_Pr)) || 742 if((SiS_CRT2IsLCD(SiS_Pr)) ||
751 (SiS_IsVAMode(SiS_Pr))) { 743 (SiS_IsVAMode(SiS_Pr))) {
@@ -756,7 +748,7 @@ SiS_IsDualLink(struct SiS_Private *SiS_Pr)
756 return false; 748 return false;
757} 749}
758 750
759#ifdef SIS315H 751#ifdef CONFIG_FB_SIS_315
760static bool 752static bool
761SiS_TVEnabled(struct SiS_Private *SiS_Pr) 753SiS_TVEnabled(struct SiS_Private *SiS_Pr)
762{ 754{
@@ -768,7 +760,7 @@ SiS_TVEnabled(struct SiS_Private *SiS_Pr)
768} 760}
769#endif 761#endif
770 762
771#ifdef SIS315H 763#ifdef CONFIG_FB_SIS_315
772static bool 764static bool
773SiS_LCDAEnabled(struct SiS_Private *SiS_Pr) 765SiS_LCDAEnabled(struct SiS_Private *SiS_Pr)
774{ 766{
@@ -777,7 +769,7 @@ SiS_LCDAEnabled(struct SiS_Private *SiS_Pr)
777} 769}
778#endif 770#endif
779 771
780#ifdef SIS315H 772#ifdef CONFIG_FB_SIS_315
781static bool 773static bool
782SiS_WeHaveBacklightCtrl(struct SiS_Private *SiS_Pr) 774SiS_WeHaveBacklightCtrl(struct SiS_Private *SiS_Pr)
783{ 775{
@@ -788,7 +780,7 @@ SiS_WeHaveBacklightCtrl(struct SiS_Private *SiS_Pr)
788} 780}
789#endif 781#endif
790 782
791#ifdef SIS315H 783#ifdef CONFIG_FB_SIS_315
792static bool 784static bool
793SiS_IsNotM650orLater(struct SiS_Private *SiS_Pr) 785SiS_IsNotM650orLater(struct SiS_Private *SiS_Pr)
794{ 786{
@@ -804,7 +796,7 @@ SiS_IsNotM650orLater(struct SiS_Private *SiS_Pr)
804} 796}
805#endif 797#endif
806 798
807#ifdef SIS315H 799#ifdef CONFIG_FB_SIS_315
808static bool 800static bool
809SiS_IsYPbPr(struct SiS_Private *SiS_Pr) 801SiS_IsYPbPr(struct SiS_Private *SiS_Pr)
810{ 802{
@@ -816,7 +808,7 @@ SiS_IsYPbPr(struct SiS_Private *SiS_Pr)
816} 808}
817#endif 809#endif
818 810
819#ifdef SIS315H 811#ifdef CONFIG_FB_SIS_315
820static bool 812static bool
821SiS_IsChScart(struct SiS_Private *SiS_Pr) 813SiS_IsChScart(struct SiS_Private *SiS_Pr)
822{ 814{
@@ -828,7 +820,7 @@ SiS_IsChScart(struct SiS_Private *SiS_Pr)
828} 820}
829#endif 821#endif
830 822
831#ifdef SIS315H 823#ifdef CONFIG_FB_SIS_315
832static bool 824static bool
833SiS_IsTVOrYPbPrOrScart(struct SiS_Private *SiS_Pr) 825SiS_IsTVOrYPbPrOrScart(struct SiS_Private *SiS_Pr)
834{ 826{
@@ -848,7 +840,7 @@ SiS_IsTVOrYPbPrOrScart(struct SiS_Private *SiS_Pr)
848} 840}
849#endif 841#endif
850 842
851#ifdef SIS315H 843#ifdef CONFIG_FB_SIS_315
852static bool 844static bool
853SiS_IsLCDOrLCDA(struct SiS_Private *SiS_Pr) 845SiS_IsLCDOrLCDA(struct SiS_Private *SiS_Pr)
854{ 846{
@@ -914,7 +906,7 @@ SiS_BridgeInSlavemode(struct SiS_Private *SiS_Pr)
914/*********************************************/ 906/*********************************************/
915 907
916/* Setup general purpose IO for Chrontel communication */ 908/* Setup general purpose IO for Chrontel communication */
917#ifdef SIS300 909#ifdef CONFIG_FB_SIS_300
918void 910void
919SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo) 911SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo)
920{ 912{
@@ -923,11 +915,7 @@ SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo)
923 915
924 if(!(SiS_Pr->SiS_ChSW)) return; 916 if(!(SiS_Pr->SiS_ChSW)) return;
925 917
926#ifdef SIS_LINUX_KERNEL
927 acpibase = sisfb_read_lpc_pci_dword(SiS_Pr, 0x74); 918 acpibase = sisfb_read_lpc_pci_dword(SiS_Pr, 0x74);
928#else
929 acpibase = pciReadLong(0x00000800, 0x74);
930#endif
931 acpibase &= 0xFFFF; 919 acpibase &= 0xFFFF;
932 if(!acpibase) return; 920 if(!acpibase) return;
933 temp = SiS_GetRegShort((acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ 921 temp = SiS_GetRegShort((acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */
@@ -969,7 +957,7 @@ SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
969 tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV); 957 tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV);
970 tempbx |= tempax; 958 tempbx |= tempax;
971 959
972#ifdef SIS315H 960#ifdef CONFIG_FB_SIS_315
973 if(SiS_Pr->ChipType >= SIS_315H) { 961 if(SiS_Pr->ChipType >= SIS_315H) {
974 if(SiS_Pr->SiS_VBType & VB_SISLCDA) { 962 if(SiS_Pr->SiS_VBType & VB_SISLCDA) {
975 if(ModeNo == 0x03) { 963 if(ModeNo == 0x03) {
@@ -1019,7 +1007,7 @@ SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1019 } 1007 }
1020 } 1008 }
1021 1009
1022#endif /* SIS315H */ 1010#endif /* CONFIG_FB_SIS_315 */
1023 1011
1024 if(!(SiS_Pr->SiS_VBType & VB_SISVGA2)) { 1012 if(!(SiS_Pr->SiS_VBType & VB_SISVGA2)) {
1025 tempbx &= ~(SetCRT2ToRAMDAC); 1013 tempbx &= ~(SetCRT2ToRAMDAC);
@@ -1154,24 +1142,16 @@ SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
1154 1142
1155 SiS_Pr->SiS_VBInfo = tempbx; 1143 SiS_Pr->SiS_VBInfo = tempbx;
1156 1144
1157#ifdef SIS300 1145#ifdef CONFIG_FB_SIS_300
1158 if(SiS_Pr->ChipType == SIS_630) { 1146 if(SiS_Pr->ChipType == SIS_630) {
1159 SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo); 1147 SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo);
1160 } 1148 }
1161#endif 1149#endif
1162 1150
1163#ifdef SIS_LINUX_KERNEL
1164#if 0 1151#if 0
1165 printk(KERN_DEBUG "sisfb: (init301: VBInfo= 0x%04x, SetFlag=0x%04x)\n", 1152 printk(KERN_DEBUG "sisfb: (init301: VBInfo= 0x%04x, SetFlag=0x%04x)\n",
1166 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); 1153 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag);
1167#endif 1154#endif
1168#endif
1169#ifdef SIS_XORG_XF86
1170#ifdef TWDEBUG
1171 xf86DrvMsg(0, X_PROBED, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n",
1172 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag);
1173#endif
1174#endif
1175} 1155}
1176 1156
1177/*********************************************/ 1157/*********************************************/
@@ -1415,12 +1395,6 @@ SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
1415 } 1395 }
1416 1396
1417 SiS_Pr->SiS_VBInfo &= ~SetPALTV; 1397 SiS_Pr->SiS_VBInfo &= ~SetPALTV;
1418
1419#ifdef SIS_XORG_XF86
1420#ifdef TWDEBUG
1421 xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo);
1422#endif
1423#endif
1424} 1398}
1425 1399
1426/*********************************************/ 1400/*********************************************/
@@ -1443,22 +1417,10 @@ SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr)
1443static void 1417static void
1444SiS_GetLCDInfoBIOS(struct SiS_Private *SiS_Pr) 1418SiS_GetLCDInfoBIOS(struct SiS_Private *SiS_Pr)
1445{ 1419{
1446#ifdef SIS315H 1420#ifdef CONFIG_FB_SIS_315
1447 unsigned char *ROMAddr; 1421 unsigned char *ROMAddr;
1448 unsigned short temp; 1422 unsigned short temp;
1449 1423
1450#ifdef SIS_XORG_XF86
1451#ifdef TWDEBUG
1452 xf86DrvMsg(0, X_INFO, "Paneldata driver: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n",
1453 SiS_Pr->PanelHT, SiS_Pr->PanelVT,
1454 SiS_Pr->PanelHRS, SiS_Pr->PanelHRE,
1455 SiS_Pr->PanelVRS, SiS_Pr->PanelVRE,
1456 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK,
1457 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A,
1458 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B);
1459#endif
1460#endif
1461
1462 if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) { 1424 if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) {
1463 if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) { 1425 if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) {
1464 SiS_Pr->SiS_NeedRomModeData = true; 1426 SiS_Pr->SiS_NeedRomModeData = true;
@@ -1480,18 +1442,6 @@ SiS_GetLCDInfoBIOS(struct SiS_Private *SiS_Pr)
1480 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C = 1442 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C =
1481 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20]; 1443 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20];
1482 1444
1483#ifdef SIS_XORG_XF86
1484#ifdef TWDEBUG
1485 xf86DrvMsg(0, X_INFO, "Paneldata BIOS: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n",
1486 SiS_Pr->PanelHT, SiS_Pr->PanelVT,
1487 SiS_Pr->PanelHRS, SiS_Pr->PanelHRE,
1488 SiS_Pr->PanelVRS, SiS_Pr->PanelVRE,
1489 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK,
1490 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A,
1491 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B);
1492#endif
1493#endif
1494
1495 } 1445 }
1496#endif 1446#endif
1497} 1447}
@@ -1517,13 +1467,13 @@ SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sh
1517{ 1467{
1518 unsigned short temp,modeflag,resinfo=0,modexres=0,modeyres=0; 1468 unsigned short temp,modeflag,resinfo=0,modexres=0,modeyres=0;
1519 bool panelcanscale = false; 1469 bool panelcanscale = false;
1520#ifdef SIS300 1470#ifdef CONFIG_FB_SIS_300
1521 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 1471 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
1522 static const unsigned char SiS300SeriesLCDRes[] = 1472 static const unsigned char SiS300SeriesLCDRes[] =
1523 { 0, 1, 2, 3, 7, 4, 5, 8, 1473 { 0, 1, 2, 3, 7, 4, 5, 8,
1524 0, 0, 10, 0, 0, 0, 0, 15 }; 1474 0, 0, 10, 0, 0, 0, 0, 15 };
1525#endif 1475#endif
1526#ifdef SIS315H 1476#ifdef CONFIG_FB_SIS_315
1527 unsigned char *myptr = NULL; 1477 unsigned char *myptr = NULL;
1528#endif 1478#endif
1529 1479
@@ -1562,7 +1512,7 @@ SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sh
1562 SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; 1512 SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1;
1563 } 1513 }
1564 temp &= 0x0f; 1514 temp &= 0x0f;
1565#ifdef SIS300 1515#ifdef CONFIG_FB_SIS_300
1566 if(SiS_Pr->ChipType < SIS_315H) { 1516 if(SiS_Pr->ChipType < SIS_315H) {
1567 /* Very old BIOSes only know 7 sizes (NetVista 2179, 1.01g) */ 1517 /* Very old BIOSes only know 7 sizes (NetVista 2179, 1.01g) */
1568 if(SiS_Pr->SiS_VBType & VB_SIS301) { 1518 if(SiS_Pr->SiS_VBType & VB_SIS301) {
@@ -1574,7 +1524,7 @@ SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sh
1574#endif 1524#endif
1575 1525
1576 /* Translate to our internal types */ 1526 /* Translate to our internal types */
1577#ifdef SIS315H 1527#ifdef CONFIG_FB_SIS_315
1578 if(SiS_Pr->ChipType == SIS_550) { 1528 if(SiS_Pr->ChipType == SIS_550) {
1579 if (temp == Panel310_1152x768) temp = Panel_320x240_2; /* Verified working */ 1529 if (temp == Panel310_1152x768) temp = Panel_320x240_2; /* Verified working */
1580 else if(temp == Panel310_320x240_2) temp = Panel_320x240_2; 1530 else if(temp == Panel310_320x240_2) temp = Panel_320x240_2;
@@ -1597,7 +1547,7 @@ SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sh
1597 1547
1598 SiS_Pr->SiS_LCDResInfo = temp; 1548 SiS_Pr->SiS_LCDResInfo = temp;
1599 1549
1600#ifdef SIS300 1550#ifdef CONFIG_FB_SIS_300
1601 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 1551 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
1602 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { 1552 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
1603 SiS_Pr->SiS_LCDResInfo = Panel_Barco1366; 1553 SiS_Pr->SiS_LCDResInfo = Panel_Barco1366;
@@ -1639,7 +1589,7 @@ SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sh
1639 else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 1589 else if(SiS_Pr->UsePanelScaler == 1) SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1640 1590
1641 /* Dual link, Pass 1:1 BIOS default, etc. */ 1591 /* Dual link, Pass 1:1 BIOS default, etc. */
1642#ifdef SIS315H 1592#ifdef CONFIG_FB_SIS_315
1643 if(SiS_Pr->ChipType >= SIS_661) { 1593 if(SiS_Pr->ChipType >= SIS_661) {
1644 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 1594 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
1645 if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11; 1595 if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11;
@@ -2076,7 +2026,7 @@ SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sh
2076 } 2026 }
2077 } 2027 }
2078 2028
2079#ifdef SIS300 2029#ifdef CONFIG_FB_SIS_300
2080 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 2030 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2081 if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) { 2031 if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) {
2082 SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */ 2032 SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */
@@ -2186,17 +2136,10 @@ SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned sh
2186 SiS_Pr->SiS_SetFlag |= LCDVESATiming; 2136 SiS_Pr->SiS_SetFlag |= LCDVESATiming;
2187 } 2137 }
2188 2138
2189#ifdef SIS_LINUX_KERNEL
2190#if 0 2139#if 0
2191 printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n", 2140 printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n",
2192 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo); 2141 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo);
2193#endif 2142#endif
2194#endif
2195#ifdef SIS_XORG_XF86
2196 xf86DrvMsgVerb(0, X_PROBED, 4,
2197 "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n",
2198 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag);
2199#endif
2200} 2143}
2201 2144
2202/*********************************************/ 2145/*********************************************/
@@ -2359,7 +2302,7 @@ SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned shor
2359 VCLKIndex = SiS_Pr->PanelVCLKIdx315; 2302 VCLKIndex = SiS_Pr->PanelVCLKIdx315;
2360 } 2303 }
2361 2304
2362#ifdef SIS300 2305#ifdef CONFIG_FB_SIS_300
2363 /* Special Timing: Barco iQ Pro R series */ 2306 /* Special Timing: Barco iQ Pro R series */
2364 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44; 2307 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44;
2365 2308
@@ -2410,12 +2353,6 @@ SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned shor
2410 2353
2411 } 2354 }
2412 2355
2413#ifdef SIS_XORG_XF86
2414#ifdef TWDEBUG
2415 xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex);
2416#endif
2417#endif
2418
2419 return VCLKIndex; 2356 return VCLKIndex;
2420} 2357}
2421 2358
@@ -2428,10 +2365,10 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2428{ 2365{
2429 unsigned short i, j, modeflag, tempah=0; 2366 unsigned short i, j, modeflag, tempah=0;
2430 short tempcl; 2367 short tempcl;
2431#if defined(SIS300) || defined(SIS315H) 2368#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
2432 unsigned short tempbl; 2369 unsigned short tempbl;
2433#endif 2370#endif
2434#ifdef SIS315H 2371#ifdef CONFIG_FB_SIS_315
2435 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 2372 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
2436 unsigned short tempah2, tempbl2; 2373 unsigned short tempah2, tempbl2;
2437#endif 2374#endif
@@ -2454,7 +2391,7 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2454 2391
2455 if(SiS_Pr->ChipType < SIS_315H) { 2392 if(SiS_Pr->ChipType < SIS_315H) {
2456 2393
2457#ifdef SIS300 /* ---- 300 series ---- */ 2394#ifdef CONFIG_FB_SIS_300 /* ---- 300 series ---- */
2458 2395
2459 /* For 301BDH: (with LCD via LVDS) */ 2396 /* For 301BDH: (with LCD via LVDS) */
2460 if(SiS_Pr->SiS_VBType & VB_NoLCD) { 2397 if(SiS_Pr->SiS_VBType & VB_NoLCD) {
@@ -2477,11 +2414,11 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2477 2414
2478 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; 2415 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0;
2479 2416
2480#endif /* SIS300 */ 2417#endif /* CONFIG_FB_SIS_300 */
2481 2418
2482 } else { 2419 } else {
2483 2420
2484#ifdef SIS315H /* ------- 315/330 series ------ */ 2421#ifdef CONFIG_FB_SIS_315 /* ------- 315/330 series ------ */
2485 2422
2486 if(ModeNo > 0x13) { 2423 if(ModeNo > 0x13) {
2487 tempcl -= ModeVGA; 2424 tempcl -= ModeVGA;
@@ -2494,7 +2431,7 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2494 2431
2495 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; 2432 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50;
2496 2433
2497#endif /* SIS315H */ 2434#endif /* CONFIG_FB_SIS_315 */
2498 2435
2499 } 2436 }
2500 2437
@@ -2503,7 +2440,7 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2503 if(SiS_Pr->ChipType < SIS_315H) { 2440 if(SiS_Pr->ChipType < SIS_315H) {
2504 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); 2441 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah);
2505 } else { 2442 } else {
2506#ifdef SIS315H 2443#ifdef CONFIG_FB_SIS_315
2507 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 2444 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2508 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); 2445 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah);
2509 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 2446 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
@@ -2584,7 +2521,7 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2584 2521
2585 if(SiS_Pr->ChipType >= SIS_315H) { 2522 if(SiS_Pr->ChipType >= SIS_315H) {
2586 2523
2587#ifdef SIS315H 2524#ifdef CONFIG_FB_SIS_315
2588 /* LVDS can only be slave in 8bpp modes */ 2525 /* LVDS can only be slave in 8bpp modes */
2589 tempah = 0x80; 2526 tempah = 0x80;
2590 if((modeflag & CRT2Mode) && (SiS_Pr->SiS_ModeType > ModeVGA)) { 2527 if((modeflag & CRT2Mode) && (SiS_Pr->SiS_ModeType > ModeVGA)) {
@@ -2604,7 +2541,7 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2604 2541
2605 } else { 2542 } else {
2606 2543
2607#ifdef SIS300 2544#ifdef CONFIG_FB_SIS_300
2608 tempah = 0; 2545 tempah = 0;
2609 if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { 2546 if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) {
2610 tempah |= 0x02; 2547 tempah |= 0x02;
@@ -2626,7 +2563,7 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2626 2563
2627 if(SiS_Pr->ChipType >= SIS_315H) { 2564 if(SiS_Pr->ChipType >= SIS_315H) {
2628 2565
2629#ifdef SIS315H 2566#ifdef CONFIG_FB_SIS_315
2630 /* unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); */ 2567 /* unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); */
2631 2568
2632 /* The following is nearly unpreditable and varies from machine 2569 /* The following is nearly unpreditable and varies from machine
@@ -2718,11 +2655,11 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2718 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); 2655 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah);
2719 } 2656 }
2720 2657
2721#endif /* SIS315H */ 2658#endif /* CONFIG_FB_SIS_315 */
2722 2659
2723 } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { 2660 } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
2724 2661
2725#ifdef SIS300 2662#ifdef CONFIG_FB_SIS_300
2726 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); 2663 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f);
2727 2664
2728 if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || 2665 if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) ||
@@ -2745,7 +2682,7 @@ SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
2745 2682
2746 } else { /* LVDS */ 2683 } else { /* LVDS */
2747 2684
2748#ifdef SIS315H 2685#ifdef CONFIG_FB_SIS_315
2749 if(SiS_Pr->ChipType >= SIS_315H) { 2686 if(SiS_Pr->ChipType >= SIS_315H) {
2750 2687
2751 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 2688 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
@@ -2931,7 +2868,7 @@ SiS_GetCRT2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
2931 } 2868 }
2932 } 2869 }
2933 2870
2934#ifdef SIS315H 2871#ifdef CONFIG_FB_SIS_315
2935 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { 2872 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
2936 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 2873 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
2937 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 2874 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
@@ -3036,7 +2973,7 @@ SiS_GetCRT2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
3036 case Panel_1280x1024: tempbx = 24; break; 2973 case Panel_1280x1024: tempbx = 24; break;
3037 case Panel_1400x1050: tempbx = 26; break; 2974 case Panel_1400x1050: tempbx = 26; break;
3038 case Panel_1600x1200: tempbx = 28; break; 2975 case Panel_1600x1200: tempbx = 28; break;
3039#ifdef SIS300 2976#ifdef CONFIG_FB_SIS_300
3040 case Panel_Barco1366: tempbx = 80; break; 2977 case Panel_Barco1366: tempbx = 80; break;
3041#endif 2978#endif
3042 } 2979 }
@@ -3053,7 +2990,7 @@ SiS_GetCRT2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
3053 2990
3054 if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 30; 2991 if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 30;
3055 2992
3056#ifdef SIS300 2993#ifdef CONFIG_FB_SIS_300
3057 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { 2994 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
3058 tempbx = 82; 2995 tempbx = 82;
3059 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 2996 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
@@ -3189,7 +3126,7 @@ SiS_GetCRT2DataLVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
3189 3126
3190 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 3127 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3191 3128
3192#ifdef SIS315H 3129#ifdef CONFIG_FB_SIS_315
3193 SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 3130 SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3194 SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex); 3131 SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex);
3195#endif 3132#endif
@@ -3214,7 +3151,7 @@ SiS_GetCRT2DataLVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
3214 case 16: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; 3151 case 16: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break;
3215 case 18: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break; 3152 case 18: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break;
3216 case 20: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; 3153 case 20: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break;
3217#ifdef SIS300 3154#ifdef CONFIG_FB_SIS_300
3218 case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break; 3155 case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break;
3219 case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break; 3156 case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break;
3220 case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break; 3157 case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break;
@@ -3248,7 +3185,7 @@ SiS_GetCRT2DataLVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned
3248 (SiS_Pr->SiS_SetFlag & SetDOSMode) ) { 3185 (SiS_Pr->SiS_SetFlag & SetDOSMode) ) {
3249 SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; 3186 SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes;
3250 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; 3187 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes;
3251#ifdef SIS300 3188#ifdef CONFIG_FB_SIS_300
3252 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { 3189 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
3253 if(ResIndex < 0x08) { 3190 if(ResIndex < 0x08) {
3254 SiS_Pr->SiS_HDE = 1280; 3191 SiS_Pr->SiS_HDE = 1280;
@@ -3270,7 +3207,7 @@ SiS_GetCRT2Data301(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3270 unsigned short resinfo, CRT2Index, ResIndex; 3207 unsigned short resinfo, CRT2Index, ResIndex;
3271 const struct SiS_LCDData *LCDPtr = NULL; 3208 const struct SiS_LCDData *LCDPtr = NULL;
3272 const struct SiS_TVData *TVPtr = NULL; 3209 const struct SiS_TVData *TVPtr = NULL;
3273#ifdef SIS315H 3210#ifdef CONFIG_FB_SIS_315
3274 short resinfo661; 3211 short resinfo661;
3275#endif 3212#endif
3276 3213
@@ -3283,7 +3220,7 @@ SiS_GetCRT2Data301(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3283 } else { 3220 } else {
3284 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 3221 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3285 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 3222 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
3286#ifdef SIS315H 3223#ifdef CONFIG_FB_SIS_315
3287 resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661; 3224 resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661;
3288 if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && 3225 if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) &&
3289 (SiS_Pr->SiS_SetFlag & LCDVESATiming) && 3226 (SiS_Pr->SiS_SetFlag & LCDVESATiming) &&
@@ -3460,7 +3397,7 @@ SiS_GetCRT2Data301(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3460 3397
3461 } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) { 3398 } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) {
3462 3399
3463#ifdef SIS315H 3400#ifdef CONFIG_FB_SIS_315
3464 SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr]; 3401 SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr];
3465 SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1]; 3402 SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1];
3466 SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8); 3403 SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8);
@@ -3520,19 +3457,13 @@ SiS_GetCRT2Data301(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3520 case Panel_1680x1050 : 3457 case Panel_1680x1050 :
3521 case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break; 3458 case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break;
3522 case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break; 3459 case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break;
3523#ifdef SIS315H 3460#ifdef CONFIG_FB_SIS_315
3524 case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break; 3461 case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break;
3525 case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; 3462 case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break;
3526#endif 3463#endif
3527 default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; 3464 default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break;
3528 } 3465 }
3529 3466
3530#ifdef SIS_XORG_XF86
3531#ifdef TWDEBUG
3532 xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex);
3533#endif
3534#endif
3535
3536 SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; 3467 SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX;
3537 SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; 3468 SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT;
3538 SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; 3469 SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT;
@@ -3624,7 +3555,7 @@ SiS_GetLVDSDesPtr(struct SiS_Private *SiS_Pr)
3624{ 3555{
3625 const struct SiS_LVDSDes *PanelDesPtr = NULL; 3556 const struct SiS_LVDSDes *PanelDesPtr = NULL;
3626 3557
3627#ifdef SIS300 3558#ifdef CONFIG_FB_SIS_300
3628 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 3559 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
3629 3560
3630 if(SiS_Pr->ChipType < SIS_315H) { 3561 if(SiS_Pr->ChipType < SIS_315H) {
@@ -3696,7 +3627,7 @@ SiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3696 3627
3697 if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 3628 if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3698 3629
3699#ifdef SIS315H 3630#ifdef CONFIG_FB_SIS_315
3700 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 3631 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3701 /* non-pass 1:1 only, see above */ 3632 /* non-pass 1:1 only, see above */
3702 if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { 3633 if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) {
@@ -3771,7 +3702,7 @@ SiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3771 } else { 3702 } else {
3772 3703
3773 if(SiS_Pr->ChipType < SIS_315H) { 3704 if(SiS_Pr->ChipType < SIS_315H) {
3774#ifdef SIS300 3705#ifdef CONFIG_FB_SIS_300
3775 switch(SiS_Pr->SiS_LCDResInfo) { 3706 switch(SiS_Pr->SiS_LCDResInfo) {
3776 case Panel_800x600: 3707 case Panel_800x600:
3777 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { 3708 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) {
@@ -3816,7 +3747,7 @@ SiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3816 } 3747 }
3817#endif 3748#endif
3818 } else { 3749 } else {
3819#ifdef SIS315H 3750#ifdef CONFIG_FB_SIS_315
3820 switch(SiS_Pr->SiS_LCDResInfo) { 3751 switch(SiS_Pr->SiS_LCDResInfo) {
3821 case Panel_1024x768: 3752 case Panel_1024x768:
3822 case Panel_1280x1024: 3753 case Panel_1280x1024:
@@ -3844,7 +3775,7 @@ SiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3844 if(SiS_Pr->ChipType < SIS_315H) { 3775 if(SiS_Pr->ChipType < SIS_315H) {
3845 if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320; 3776 if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320;
3846 } else { 3777 } else {
3847#ifdef SIS315H 3778#ifdef CONFIG_FB_SIS_315
3848 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480; 3779 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480;
3849 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804; 3780 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804;
3850 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704; 3781 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704;
@@ -3866,7 +3797,7 @@ SiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
3866/* DISABLE VIDEO BRIDGE */ 3797/* DISABLE VIDEO BRIDGE */
3867/*********************************************/ 3798/*********************************************/
3868 3799
3869#ifdef SIS315H 3800#ifdef CONFIG_FB_SIS_315
3870static int 3801static int
3871SiS_HandlePWD(struct SiS_Private *SiS_Pr) 3802SiS_HandlePWD(struct SiS_Private *SiS_Pr)
3872{ 3803{
@@ -3891,11 +3822,6 @@ SiS_HandlePWD(struct SiS_Private *SiS_Pr)
3891 ret = 1; 3822 ret = 1;
3892 } 3823 }
3893 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x27,0x7f,temp); 3824 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x27,0x7f,temp);
3894#ifdef SIS_XORG_XF86
3895#ifdef TWDEBUG
3896 xf86DrvMsg(0, 0, "Setting PWD %x\n", temp);
3897#endif
3898#endif
3899 } 3825 }
3900#endif 3826#endif
3901 return ret; 3827 return ret;
@@ -3909,7 +3835,7 @@ SiS_HandlePWD(struct SiS_Private *SiS_Pr)
3909void 3835void
3910SiS_DisableBridge(struct SiS_Private *SiS_Pr) 3836SiS_DisableBridge(struct SiS_Private *SiS_Pr)
3911{ 3837{
3912#ifdef SIS315H 3838#ifdef CONFIG_FB_SIS_315
3913 unsigned short tempah, pushax=0, modenum; 3839 unsigned short tempah, pushax=0, modenum;
3914#endif 3840#endif
3915 unsigned short temp=0; 3841 unsigned short temp=0;
@@ -3920,7 +3846,7 @@ SiS_DisableBridge(struct SiS_Private *SiS_Pr)
3920 3846
3921 if(SiS_Pr->ChipType < SIS_315H) { 3847 if(SiS_Pr->ChipType < SIS_315H) {
3922 3848
3923#ifdef SIS300 /* 300 series */ 3849#ifdef CONFIG_FB_SIS_300 /* 300 series */
3924 3850
3925 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 3851 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
3926 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 3852 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
@@ -3953,11 +3879,11 @@ SiS_DisableBridge(struct SiS_Private *SiS_Pr)
3953 } 3879 }
3954 } 3880 }
3955 3881
3956#endif /* SIS300 */ 3882#endif /* CONFIG_FB_SIS_300 */
3957 3883
3958 } else { 3884 } else {
3959 3885
3960#ifdef SIS315H /* 315 series */ 3886#ifdef CONFIG_FB_SIS_315 /* 315 series */
3961 3887
3962 int didpwd = 0; 3888 int didpwd = 0;
3963 bool custom1 = (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || 3889 bool custom1 = (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) ||
@@ -4081,14 +4007,14 @@ SiS_DisableBridge(struct SiS_Private *SiS_Pr)
4081 4007
4082 } 4008 }
4083 4009
4084#endif /* SIS315H */ 4010#endif /* CONFIG_FB_SIS_315 */
4085 4011
4086 } 4012 }
4087 4013
4088 } else { /* ============ For 301 ================ */ 4014 } else { /* ============ For 301 ================ */
4089 4015
4090 if(SiS_Pr->ChipType < SIS_315H) { 4016 if(SiS_Pr->ChipType < SIS_315H) {
4091#ifdef SIS300 4017#ifdef CONFIG_FB_SIS_300
4092 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) { 4018 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4093 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08); 4019 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4094 SiS_PanelDelay(SiS_Pr, 3); 4020 SiS_PanelDelay(SiS_Pr, 3);
@@ -4111,7 +4037,7 @@ SiS_DisableBridge(struct SiS_Private *SiS_Pr)
4111 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 4037 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4112 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); 4038 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp);
4113 } else { 4039 } else {
4114#ifdef SIS300 4040#ifdef CONFIG_FB_SIS_300
4115 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ 4041 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */
4116 if( (!(SiS_CRT2IsLCD(SiS_Pr))) || 4042 if( (!(SiS_CRT2IsLCD(SiS_Pr))) ||
4117 (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) { 4043 (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) {
@@ -4127,7 +4053,7 @@ SiS_DisableBridge(struct SiS_Private *SiS_Pr)
4127 4053
4128 if(SiS_Pr->ChipType < SIS_315H) { 4054 if(SiS_Pr->ChipType < SIS_315H) {
4129 4055
4130#ifdef SIS300 /* 300 series */ 4056#ifdef CONFIG_FB_SIS_300 /* 300 series */
4131 4057
4132 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 4058 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
4133 SiS_SetCH700x(SiS_Pr,0x0E,0x09); 4059 SiS_SetCH700x(SiS_Pr,0x0E,0x09);
@@ -4171,11 +4097,11 @@ SiS_DisableBridge(struct SiS_Private *SiS_Pr)
4171 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04); 4097 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
4172 } 4098 }
4173 4099
4174#endif /* SIS300 */ 4100#endif /* CONFIG_FB_SIS_300 */
4175 4101
4176 } else { 4102 } else {
4177 4103
4178#ifdef SIS315H /* 315 series */ 4104#ifdef CONFIG_FB_SIS_315 /* 315 series */
4179 4105
4180 if(!(SiS_IsNotM650orLater(SiS_Pr))) { 4106 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
4181 /*if(SiS_Pr->ChipType < SIS_340) { */ /* XGI needs this */ 4107 /*if(SiS_Pr->ChipType < SIS_340) { */ /* XGI needs this */
@@ -4288,7 +4214,7 @@ SiS_DisableBridge(struct SiS_Private *SiS_Pr)
4288 } 4214 }
4289 } 4215 }
4290 4216
4291#endif /* SIS315H */ 4217#endif /* CONFIG_FB_SIS_315 */
4292 4218
4293 } /* 315 series */ 4219 } /* 315 series */
4294 4220
@@ -4304,14 +4230,12 @@ SiS_DisableBridge(struct SiS_Private *SiS_Pr)
4304 * from outside the context of a mode switch! 4230 * from outside the context of a mode switch!
4305 * MUST call getVBType before calling this 4231 * MUST call getVBType before calling this
4306 */ 4232 */
4307#ifdef SIS_LINUX_KERNEL
4308static 4233static
4309#endif
4310void 4234void
4311SiS_EnableBridge(struct SiS_Private *SiS_Pr) 4235SiS_EnableBridge(struct SiS_Private *SiS_Pr)
4312{ 4236{
4313 unsigned short temp=0, tempah; 4237 unsigned short temp=0, tempah;
4314#ifdef SIS315H 4238#ifdef CONFIG_FB_SIS_315
4315 unsigned short temp1, pushax=0; 4239 unsigned short temp1, pushax=0;
4316 bool delaylong = false; 4240 bool delaylong = false;
4317#endif 4241#endif
@@ -4322,7 +4246,7 @@ SiS_EnableBridge(struct SiS_Private *SiS_Pr)
4322 4246
4323 if(SiS_Pr->ChipType < SIS_315H) { 4247 if(SiS_Pr->ChipType < SIS_315H) {
4324 4248
4325#ifdef SIS300 /* 300 series */ 4249#ifdef CONFIG_FB_SIS_300 /* 300 series */
4326 4250
4327 if(SiS_CRT2IsLCD(SiS_Pr)) { 4251 if(SiS_CRT2IsLCD(SiS_Pr)) {
4328 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 4252 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
@@ -4385,11 +4309,11 @@ SiS_EnableBridge(struct SiS_Private *SiS_Pr)
4385 } 4309 }
4386 4310
4387 4311
4388#endif /* SIS300 */ 4312#endif /* CONFIG_FB_SIS_300 */
4389 4313
4390 } else { 4314 } else {
4391 4315
4392#ifdef SIS315H /* 315 series */ 4316#ifdef CONFIG_FB_SIS_315 /* 315 series */
4393 4317
4394#ifdef SET_EMI 4318#ifdef SET_EMI
4395 unsigned char r30=0, r31=0, r32=0, r33=0, cr36=0; 4319 unsigned char r30=0, r31=0, r32=0, r33=0, cr36=0;
@@ -4688,7 +4612,7 @@ SiS_EnableBridge(struct SiS_Private *SiS_Pr)
4688 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); 4612 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
4689 } 4613 }
4690 4614
4691#endif /* SIS315H */ 4615#endif /* CONFIG_FB_SIS_315 */
4692 4616
4693 } 4617 }
4694 4618
@@ -4739,7 +4663,7 @@ SiS_EnableBridge(struct SiS_Private *SiS_Pr)
4739 4663
4740 if(SiS_Pr->ChipType < SIS_315H) { 4664 if(SiS_Pr->ChipType < SIS_315H) {
4741 4665
4742#ifdef SIS300 /* 300 series */ 4666#ifdef CONFIG_FB_SIS_300 /* 300 series */
4743 4667
4744 if(SiS_CRT2IsLCD(SiS_Pr)) { 4668 if(SiS_CRT2IsLCD(SiS_Pr)) {
4745 if(SiS_Pr->ChipType == SIS_730) { 4669 if(SiS_Pr->ChipType == SIS_730) {
@@ -4783,11 +4707,11 @@ SiS_EnableBridge(struct SiS_Private *SiS_Pr)
4783 } 4707 }
4784 } 4708 }
4785 4709
4786#endif /* SIS300 */ 4710#endif /* CONFIG_FB_SIS_300 */
4787 4711
4788 } else { 4712 } else {
4789 4713
4790#ifdef SIS315H /* 315 series */ 4714#ifdef CONFIG_FB_SIS_315 /* 315 series */
4791 4715
4792 if(!(SiS_IsNotM650orLater(SiS_Pr))) { 4716 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
4793 /*if(SiS_Pr->ChipType < SIS_340) {*/ /* XGI needs this */ 4717 /*if(SiS_Pr->ChipType < SIS_340) {*/ /* XGI needs this */
@@ -4881,7 +4805,7 @@ SiS_EnableBridge(struct SiS_Private *SiS_Pr)
4881 } 4805 }
4882 } 4806 }
4883 4807
4884#endif /* SIS315H */ 4808#endif /* CONFIG_FB_SIS_315 */
4885 4809
4886 } /* 310 series */ 4810 } /* 310 series */
4887 4811
@@ -4971,7 +4895,7 @@ SiS_SetCRT2Sync(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned shor
4971 4895
4972 if(SiS_Pr->ChipType < SIS_315H) { 4896 if(SiS_Pr->ChipType < SIS_315H) {
4973 4897
4974#ifdef SIS300 /* ---- 300 series --- */ 4898#ifdef CONFIG_FB_SIS_300 /* ---- 300 series --- */
4975 4899
4976 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* 630 - 301B(-DH) */ 4900 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* 630 - 301B(-DH) */
4977 4901
@@ -5000,11 +4924,11 @@ SiS_SetCRT2Sync(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned shor
5000 4924
5001 } 4925 }
5002 4926
5003#endif /* SIS300 */ 4927#endif /* CONFIG_FB_SIS_300 */
5004 4928
5005 } else { 4929 } else {
5006 4930
5007#ifdef SIS315H /* ------- 315 series ------ */ 4931#ifdef CONFIG_FB_SIS_315 /* ------- 315 series ------ */
5008 4932
5009 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* 315 - LVDS */ 4933 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* 315 - LVDS */
5010 4934
@@ -5076,13 +5000,13 @@ SiS_SetCRT2Sync(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned shor
5076 } 5000 }
5077 5001
5078 } 5002 }
5079#endif /* SIS315H */ 5003#endif /* CONFIG_FB_SIS_315 */
5080 } 5004 }
5081 } 5005 }
5082} 5006}
5083 5007
5084/* Set CRT2 FIFO on 300/540/630/730 */ 5008/* Set CRT2 FIFO on 300/540/630/730 */
5085#ifdef SIS300 5009#ifdef CONFIG_FB_SIS_300
5086static void 5010static void
5087SiS_SetCRT2FIFO_300(struct SiS_Private *SiS_Pr,unsigned short ModeNo) 5011SiS_SetCRT2FIFO_300(struct SiS_Private *SiS_Pr,unsigned short ModeNo)
5088{ 5012{
@@ -5154,13 +5078,8 @@ SiS_SetCRT2FIFO_300(struct SiS_Private *SiS_Pr,unsigned short ModeNo)
5154 5078
5155 } else { 5079 } else {
5156 5080
5157#ifdef SIS_LINUX_KERNEL
5158 pci50 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50); 5081 pci50 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50);
5159 pciA0 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xa0); 5082 pciA0 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xa0);
5160#else
5161 pci50 = pciReadLong(0x00000000, 0x50);
5162 pciA0 = pciReadLong(0x00000000, 0xA0);
5163#endif
5164 5083
5165 if(SiS_Pr->ChipType == SIS_730) { 5084 if(SiS_Pr->ChipType == SIS_730) {
5166 5085
@@ -5262,7 +5181,7 @@ SiS_SetCRT2FIFO_300(struct SiS_Private *SiS_Pr,unsigned short ModeNo)
5262#endif 5181#endif
5263 5182
5264/* Set CRT2 FIFO on 315/330 series */ 5183/* Set CRT2 FIFO on 315/330 series */
5265#ifdef SIS315H 5184#ifdef CONFIG_FB_SIS_315
5266static void 5185static void
5267SiS_SetCRT2FIFO_310(struct SiS_Private *SiS_Pr) 5186SiS_SetCRT2FIFO_310(struct SiS_Private *SiS_Pr)
5268{ 5187{
@@ -5420,27 +5339,6 @@ SiS_SetGroup1_301(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned sho
5420 5339
5421 temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); 5340 temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02));
5422 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); /* ? */ 5341 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); /* ? */
5423
5424#ifdef SIS_XORG_XF86
5425#ifdef TWDEBUG
5426 xf86DrvMsg(0, X_INFO, "%d %d %d %d %d %d %d %d (%d %d %d %d)\n",
5427 SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal,
5428 SiS_Pr->CVDisplay, SiS_Pr->CVSyncStart, SiS_Pr->CVSyncEnd, SiS_Pr->CVTotal,
5429 SiS_Pr->CHBlankStart, SiS_Pr->CHBlankEnd, SiS_Pr->CVBlankStart, SiS_Pr->CVBlankEnd);
5430
5431 xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n",
5432 SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1],
5433 SiS_Pr->CCRT1CRTC[2], SiS_Pr->CCRT1CRTC[3],
5434 SiS_Pr->CCRT1CRTC[4], SiS_Pr->CCRT1CRTC[5],
5435 SiS_Pr->CCRT1CRTC[6], SiS_Pr->CCRT1CRTC[7]);
5436 xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n",
5437 SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9],
5438 SiS_Pr->CCRT1CRTC[10], SiS_Pr->CCRT1CRTC[11],
5439 SiS_Pr->CCRT1CRTC[12], SiS_Pr->CCRT1CRTC[13],
5440 SiS_Pr->CCRT1CRTC[14], SiS_Pr->CCRT1CRTC[15]);
5441 xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", SiS_Pr->CCRT1CRTC[16]);
5442#endif
5443#endif
5444} 5342}
5445 5343
5446/* Setup panel link 5344/* Setup panel link
@@ -5455,17 +5353,17 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5455 unsigned short push2, tempax, tempbx, tempcx, temp; 5353 unsigned short push2, tempax, tempbx, tempcx, temp;
5456 unsigned int tempeax = 0, tempebx, tempecx, tempvcfact = 0; 5354 unsigned int tempeax = 0, tempebx, tempecx, tempvcfact = 0;
5457 bool islvds = false, issis = false, chkdclkfirst = false; 5355 bool islvds = false, issis = false, chkdclkfirst = false;
5458#ifdef SIS300 5356#ifdef CONFIG_FB_SIS_300
5459 unsigned short crt2crtc = 0; 5357 unsigned short crt2crtc = 0;
5460#endif 5358#endif
5461#ifdef SIS315H 5359#ifdef CONFIG_FB_SIS_315
5462 unsigned short pushcx; 5360 unsigned short pushcx;
5463#endif 5361#endif
5464 5362
5465 if(ModeNo <= 0x13) { 5363 if(ModeNo <= 0x13) {
5466 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 5364 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
5467 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; 5365 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
5468#ifdef SIS300 5366#ifdef CONFIG_FB_SIS_300
5469 crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 5367 crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5470#endif 5368#endif
5471 } else if(SiS_Pr->UseCustomMode) { 5369 } else if(SiS_Pr->UseCustomMode) {
@@ -5473,7 +5371,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5473 } else { 5371 } else {
5474 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 5372 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5475 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 5373 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
5476#ifdef SIS300 5374#ifdef CONFIG_FB_SIS_300
5477 crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 5375 crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5478#endif 5376#endif
5479 } 5377 }
@@ -5494,7 +5392,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5494 } 5392 }
5495 } 5393 }
5496 5394
5497#ifdef SIS315H 5395#ifdef CONFIG_FB_SIS_315
5498 if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 5396 if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
5499 if(IS_SIS330) { 5397 if(IS_SIS330) {
5500 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); 5398 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10);
@@ -5744,7 +5642,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5744 5642
5745 if(SiS_Pr->ChipType < SIS_315H) { 5643 if(SiS_Pr->ChipType < SIS_315H) {
5746 5644
5747#ifdef SIS300 /* 300 series */ 5645#ifdef CONFIG_FB_SIS_300 /* 300 series */
5748 tempeax = SiS_Pr->SiS_VGAVDE << 6; 5646 tempeax = SiS_Pr->SiS_VGAVDE << 6;
5749 temp = (tempeax % (unsigned int)SiS_Pr->SiS_VDE); 5647 temp = (tempeax % (unsigned int)SiS_Pr->SiS_VDE);
5750 tempeax = tempeax / (unsigned int)SiS_Pr->SiS_VDE; 5648 tempeax = tempeax / (unsigned int)SiS_Pr->SiS_VDE;
@@ -5755,11 +5653,11 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5755 temp = (unsigned short)(tempeax & 0x00FF); 5653 temp = (unsigned short)(tempeax & 0x00FF);
5756 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */ 5654 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */
5757 tempvcfact = temp; 5655 tempvcfact = temp;
5758#endif /* SIS300 */ 5656#endif /* CONFIG_FB_SIS_300 */
5759 5657
5760 } else { 5658 } else {
5761 5659
5762#ifdef SIS315H /* 315 series */ 5660#ifdef CONFIG_FB_SIS_315 /* 315 series */
5763 tempeax = SiS_Pr->SiS_VGAVDE << 18; 5661 tempeax = SiS_Pr->SiS_VGAVDE << 18;
5764 tempebx = SiS_Pr->SiS_VDE; 5662 tempebx = SiS_Pr->SiS_VDE;
5765 temp = (tempeax % tempebx); 5663 temp = (tempeax % tempebx);
@@ -5845,7 +5743,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5845 temp = (unsigned short)(tempecx & 0x00FF); 5743 temp = (unsigned short)(tempecx & 0x00FF);
5846 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); 5744 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp);
5847 5745
5848#ifdef SIS315H 5746#ifdef CONFIG_FB_SIS_315
5849 if(SiS_Pr->ChipType >= SIS_315H) { 5747 if(SiS_Pr->ChipType >= SIS_315H) {
5850 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 5748 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
5851 if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SISLVDS)) { 5749 if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SISLVDS)) {
@@ -5863,7 +5761,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5863 } 5761 }
5864#endif 5762#endif
5865 5763
5866#ifdef SIS300 5764#ifdef CONFIG_FB_SIS_300
5867 if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 5765 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
5868 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 5766 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
5869 unsigned char *trumpdata; 5767 unsigned char *trumpdata;
@@ -5899,7 +5797,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5899 } 5797 }
5900#endif 5798#endif
5901 5799
5902#ifdef SIS315H 5800#ifdef CONFIG_FB_SIS_315
5903 if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) { 5801 if(SiS_Pr->SiS_IF_DEF_FSTN || SiS_Pr->SiS_IF_DEF_DSTN) {
5904 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x25,0x00); 5802 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x25,0x00);
5905 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x26,0x00); 5803 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x26,0x00);
@@ -5954,7 +5852,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5954 temp = tempax & 0x00FF; 5852 temp = tempax & 0x00FF;
5955 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp); 5853 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp);
5956 temp = ((tempax & 0xFF00) >> 8) << 3; 5854 temp = ((tempax & 0xFF00) >> 8) << 3;
5957 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp); 5855 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port, 0x44, 0x07, temp);
5958 5856
5959 tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ 5857 tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */
5960 if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 || 5858 if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 ||
@@ -5968,7 +5866,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5968 temp = ((tempeax & 0xFF0000) >> 16) | 0x10; 5866 temp = ((tempeax & 0xFF0000) >> 16) | 0x10;
5969 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp); 5867 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp);
5970 temp = ((tempeax & 0x01000000) >> 24) << 7; 5868 temp = ((tempeax & 0x01000000) >> 24) << 7;
5971 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp); 5869 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port, 0x3C, 0x7F, temp);
5972 5870
5973 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03); 5871 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03);
5974 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0x50); 5872 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0x50);
@@ -5999,7 +5897,7 @@ SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned s
5999 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,0x0a); 5897 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,0x0a);
6000 } 5898 }
6001 } 5899 }
6002#endif /* SIS315H */ 5900#endif /* CONFIG_FB_SIS_315 */
6003} 5901}
6004 5902
6005/* Set Part 1 */ 5903/* Set Part 1 */
@@ -6007,12 +5905,12 @@ static void
6007SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, 5905SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
6008 unsigned short RefreshRateTableIndex) 5906 unsigned short RefreshRateTableIndex)
6009{ 5907{
6010#if defined(SIS300) || defined(SIS315H) 5908#if defined(CONFIG_FB_SIS_300) || defined(CONFIG_FB_SIS_315)
6011 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 5909 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
6012#endif 5910#endif
6013 unsigned short temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0; 5911 unsigned short temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0;
6014 unsigned short pushbx=0, CRT1Index=0, modeflag, resinfo=0; 5912 unsigned short pushbx=0, CRT1Index=0, modeflag, resinfo=0;
6015#ifdef SIS315H 5913#ifdef CONFIG_FB_SIS_315
6016 unsigned short tempbl=0; 5914 unsigned short tempbl=0;
6017#endif 5915#endif
6018 5916
@@ -6038,11 +5936,11 @@ SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6038 (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) { 5936 (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) {
6039 5937
6040 if(SiS_Pr->ChipType < SIS_315H ) { 5938 if(SiS_Pr->ChipType < SIS_315H ) {
6041#ifdef SIS300 5939#ifdef CONFIG_FB_SIS_300
6042 SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo); 5940 SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo);
6043#endif 5941#endif
6044 } else { 5942 } else {
6045#ifdef SIS315H 5943#ifdef CONFIG_FB_SIS_315
6046 SiS_SetCRT2FIFO_310(SiS_Pr); 5944 SiS_SetCRT2FIFO_310(SiS_Pr);
6047#endif 5945#endif
6048 } 5946 }
@@ -6051,7 +5949,7 @@ SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6051 5949
6052 if(SiS_Pr->ChipType < SIS_315H ) { 5950 if(SiS_Pr->ChipType < SIS_315H ) {
6053 5951
6054#ifdef SIS300 /* ------------- 300 series --------------*/ 5952#ifdef CONFIG_FB_SIS_300 /* ------------- 300 series --------------*/
6055 5953
6056 temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ 5954 temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
6057 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ 5955 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */
@@ -6070,11 +5968,11 @@ SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6070 5968
6071 bridgeadd = 12; 5969 bridgeadd = 12;
6072 5970
6073#endif /* SIS300 */ 5971#endif /* CONFIG_FB_SIS_300 */
6074 5972
6075 } else { 5973 } else {
6076 5974
6077#ifdef SIS315H /* ------------------- 315/330 series --------------- */ 5975#ifdef CONFIG_FB_SIS_315 /* ------------------- 315/330 series --------------- */
6078 5976
6079 tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */ 5977 tempcx = SiS_Pr->SiS_VGAHT; /* BTVGA2HT 0x08,0x09 */
6080 if(modeflag & HalfDCLK) { 5978 if(modeflag & HalfDCLK) {
@@ -6125,7 +6023,7 @@ SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6125 } 6023 }
6126 } 6024 }
6127 6025
6128#endif /* SIS315H */ 6026#endif /* CONFIG_FB_SIS_315 */
6129 6027
6130 } /* 315/330 series */ 6028 } /* 315/330 series */
6131 6029
@@ -6256,7 +6154,7 @@ SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6256 6154
6257 if(SiS_Pr->ChipType < SIS_315H) { 6155 if(SiS_Pr->ChipType < SIS_315H) {
6258 6156
6259#ifdef SIS300 /* ---------- 300 series -------------- */ 6157#ifdef CONFIG_FB_SIS_300 /* ---------- 300 series -------------- */
6260 6158
6261 if(SiS_Pr->SiS_VBType & VB_SISVB) { 6159 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6262 temp = 0x20; 6160 temp = 0x20;
@@ -6310,11 +6208,11 @@ SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6310 6208
6311 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ 6209 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */
6312 6210
6313#endif /* SIS300 */ 6211#endif /* CONFIG_FB_SIS_300 */
6314 6212
6315 } else { 6213 } else {
6316 6214
6317#ifdef SIS315H /* --------------- 315/330 series ---------------*/ 6215#ifdef CONFIG_FB_SIS_315 /* --------------- 315/330 series ---------------*/
6318 6216
6319 if(SiS_Pr->ChipType < SIS_661) { 6217 if(SiS_Pr->ChipType < SIS_661) {
6320 6218
@@ -6349,7 +6247,7 @@ SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6349 if(modeflag & HalfDCLK) tempax |= 0x40; 6247 if(modeflag & HalfDCLK) tempax |= 0x40;
6350 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); 6248 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax);
6351 6249
6352#endif /* SIS315H */ 6250#endif /* CONFIG_FB_SIS_315 */
6353 6251
6354 } 6252 }
6355 6253
@@ -6381,7 +6279,7 @@ SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6381/* SET PART 2 REGISTER GROUP */ 6279/* SET PART 2 REGISTER GROUP */
6382/*********************************************/ 6280/*********************************************/
6383 6281
6384#ifdef SIS315H 6282#ifdef CONFIG_FB_SIS_315
6385static unsigned char * 6283static unsigned char *
6386SiS_GetGroup2CLVXPtr(struct SiS_Private *SiS_Pr, int tabletype) 6284SiS_GetGroup2CLVXPtr(struct SiS_Private *SiS_Pr, int tabletype)
6387{ 6285{
@@ -6478,7 +6376,7 @@ SiS_GetCRT2Part2Ptr(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned sh
6478} 6376}
6479#endif 6377#endif
6480 6378
6481#ifdef SIS300 6379#ifdef CONFIG_FB_SIS_300
6482static void 6380static void
6483SiS_Group2LCDSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short crt2crtc) 6381SiS_Group2LCDSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short crt2crtc)
6484{ 6382{
@@ -6690,7 +6588,7 @@ SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
6690 unsigned int longtemp, PhaseIndex; 6588 unsigned int longtemp, PhaseIndex;
6691 bool newtvphase; 6589 bool newtvphase;
6692 const unsigned char *TimingPoint; 6590 const unsigned char *TimingPoint;
6693#ifdef SIS315H 6591#ifdef CONFIG_FB_SIS_315
6694 unsigned short resindex, CRT2Index; 6592 unsigned short resindex, CRT2Index;
6695 const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL; 6593 const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL;
6696 6594
@@ -7069,7 +6967,7 @@ SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
7069 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB); 6967 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x17,0xFB);
7070 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF); 6968 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x18,0xDF);
7071 6969
7072#ifdef SIS315H 6970#ifdef CONFIG_FB_SIS_315
7073 if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 6971 if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
7074 &CRT2Index, &resindex)) { 6972 &CRT2Index, &resindex)) {
7075 switch(CRT2Index) { 6973 switch(CRT2Index) {
@@ -7130,12 +7028,6 @@ SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
7130 7028
7131 /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ 7029 /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */
7132 7030
7133#ifdef SIS_XORG_XF86
7134#ifdef TWDEBUG
7135 xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx);
7136#endif
7137#endif
7138
7139 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */ 7031 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */
7140 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */ 7032 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */
7141 7033
@@ -7184,12 +7076,6 @@ SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
7184 tempbx = SiS_Pr->CVSyncStart; 7076 tempbx = SiS_Pr->CVSyncStart;
7185 } 7077 }
7186 7078
7187#ifdef SIS_XORG_XF86
7188#ifdef TWDEBUG
7189 xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx);
7190#endif
7191#endif
7192
7193 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */ 7079 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */
7194 7080
7195 temp = (tempbx >> 4) & 0xF0; 7081 temp = (tempbx >> 4) & 0xF0;
@@ -7201,15 +7087,9 @@ SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
7201 temp |= (SiS_Pr->CVSyncEnd & 0x0f); 7087 temp |= (SiS_Pr->CVSyncEnd & 0x0f);
7202 } 7088 }
7203 7089
7204#ifdef SIS_XORG_XF86
7205#ifdef TWDEBUG
7206 xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f));
7207#endif
7208#endif
7209
7210 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); 7090 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp);
7211 7091
7212#ifdef SIS300 7092#ifdef CONFIG_FB_SIS_300
7213 SiS_Group2LCDSpecial(SiS_Pr, ModeNo, crt2crtc); 7093 SiS_Group2LCDSpecial(SiS_Pr, ModeNo, crt2crtc);
7214#endif 7094#endif
7215 7095
@@ -7245,12 +7125,6 @@ SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
7245 tempax >>= 1; 7125 tempax >>= 1;
7246 } 7126 }
7247 7127
7248#ifdef SIS_XORG_XF86
7249#ifdef TWDEBUG
7250 xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx);
7251#endif
7252#endif
7253
7254 tempbx += bridgeoffset; 7128 tempbx += bridgeoffset;
7255 7129
7256 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,tempbx); /* lcdhdee */ 7130 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,tempbx); /* lcdhdee */
@@ -7276,12 +7150,6 @@ SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
7276 tempbx += bridgeoffset; 7150 tempbx += bridgeoffset;
7277 } 7151 }
7278 7152
7279#ifdef SIS_XORG_XF86
7280#ifdef TWDEBUG
7281 xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx);
7282#endif
7283#endif
7284
7285 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */ 7153 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */
7286 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0)); 7154 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0));
7287 7155
@@ -7300,20 +7168,14 @@ SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
7300 tempbx += bridgeoffset; 7168 tempbx += bridgeoffset;
7301 } 7169 }
7302 7170
7303#ifdef SIS_XORG_XF86
7304#ifdef TWDEBUG
7305 xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx);
7306#endif
7307#endif
7308
7309 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */ 7171 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */
7310 7172
7311 SiS_SetGroup2_Tail(SiS_Pr, ModeNo); 7173 SiS_SetGroup2_Tail(SiS_Pr, ModeNo);
7312 7174
7313#ifdef SIS300 7175#ifdef CONFIG_FB_SIS_300
7314 SiS_Set300Part2Regs(SiS_Pr, ModeIdIndex, RefreshRateTableIndex, ModeNo); 7176 SiS_Set300Part2Regs(SiS_Pr, ModeIdIndex, RefreshRateTableIndex, ModeNo);
7315#endif 7177#endif
7316#ifdef SIS315H 7178#ifdef CONFIG_FB_SIS_315
7317 } /* CRT2-LCD from table */ 7179 } /* CRT2-LCD from table */
7318#endif 7180#endif
7319} 7181}
@@ -7382,7 +7244,7 @@ SiS_SetGroup3(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
7382/* SET PART 4 REGISTER GROUP */ 7244/* SET PART 4 REGISTER GROUP */
7383/*********************************************/ 7245/*********************************************/
7384 7246
7385#ifdef SIS315H 7247#ifdef CONFIG_FB_SIS_315
7386#if 0 7248#if 0
7387static void 7249static void
7388SiS_ShiftXPos(struct SiS_Private *SiS_Pr, int shift) 7250SiS_ShiftXPos(struct SiS_Private *SiS_Pr, int shift)
@@ -8011,7 +7873,7 @@ SiS_SetCHTVReg(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
8011 7873
8012 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 7874 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
8013 7875
8014#ifdef SIS300 7876#ifdef CONFIG_FB_SIS_300
8015 7877
8016 /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ 7878 /* Chrontel 7005 - I assume that it does not come with a 315 series chip */
8017 7879
@@ -8124,7 +7986,7 @@ SiS_SetCHTVReg(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
8124 7986
8125 /* Chrontel 7019 - assumed that it does not come with a 300 series chip */ 7987 /* Chrontel 7019 - assumed that it does not come with a 300 series chip */
8126 7988
8127#ifdef SIS315H 7989#ifdef CONFIG_FB_SIS_315
8128 7990
8129 unsigned short temp; 7991 unsigned short temp;
8130 7992
@@ -8175,7 +8037,7 @@ SiS_SetCHTVReg(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short
8175 8037
8176} 8038}
8177 8039
8178#ifdef SIS315H /* ----------- 315 series only ---------- */ 8040#ifdef CONFIG_FB_SIS_315 /* ----------- 315 series only ---------- */
8179 8041
8180void 8042void
8181SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr) 8043SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr)
@@ -8657,7 +8519,7 @@ SiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr)
8657bool 8519bool
8658SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo) 8520SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
8659{ 8521{
8660#ifdef SIS300 8522#ifdef CONFIG_FB_SIS_300
8661 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase; 8523 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
8662#endif 8524#endif
8663 unsigned short ModeIdIndex, RefreshRateTableIndex; 8525 unsigned short ModeIdIndex, RefreshRateTableIndex;
@@ -8703,16 +8565,6 @@ SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
8703 SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 8565 SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8704 } 8566 }
8705 8567
8706#ifdef SIS_XORG_XF86
8707#ifdef TWDEBUG
8708 xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES);
8709 xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE);
8710 xf86DrvMsg(0, X_INFO, "(init301: VGAHDE 0x%03x VGAVDE 0x%03x)\n", SiS_Pr->SiS_VGAHDE, SiS_Pr->SiS_VGAVDE);
8711 xf86DrvMsg(0, X_INFO, "(init301: HT 0x%03x VT 0x%03x)\n", SiS_Pr->SiS_HT, SiS_Pr->SiS_VT);
8712 xf86DrvMsg(0, X_INFO, "(init301: VGAHT 0x%03x VGAVT 0x%03x)\n", SiS_Pr->SiS_VGAHT, SiS_Pr->SiS_VGAVT);
8713#endif
8714#endif
8715
8716 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8568 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8717 SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 8569 SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8718 } 8570 }
@@ -8722,12 +8574,12 @@ SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
8722 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8574 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8723 8575
8724 SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 8576 SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8725#ifdef SIS315H 8577#ifdef CONFIG_FB_SIS_315
8726 SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 8578 SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8727#endif 8579#endif
8728 SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex); 8580 SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex);
8729 SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex); 8581 SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8730#ifdef SIS315H 8582#ifdef CONFIG_FB_SIS_315
8731 SiS_SetGroup4_C_ELV(SiS_Pr, ModeNo, ModeIdIndex); 8583 SiS_SetGroup4_C_ELV(SiS_Pr, ModeNo, ModeIdIndex);
8732#endif 8584#endif
8733 SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex); 8585 SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex);
@@ -8758,7 +8610,7 @@ SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
8758 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 8610 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
8759 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 8611 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
8760 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 8612 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8761#ifdef SIS315H 8613#ifdef CONFIG_FB_SIS_315
8762 SiS_SetCH701xForLCD(SiS_Pr); 8614 SiS_SetCH701xForLCD(SiS_Pr);
8763#endif 8615#endif
8764 } 8616 }
@@ -8771,7 +8623,7 @@ SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
8771 8623
8772 } 8624 }
8773 8625
8774#ifdef SIS300 8626#ifdef CONFIG_FB_SIS_300
8775 if(SiS_Pr->ChipType < SIS_315H) { 8627 if(SiS_Pr->ChipType < SIS_315H) {
8776 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8628 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8777 if(SiS_Pr->SiS_UseOEM) { 8629 if(SiS_Pr->SiS_UseOEM) {
@@ -8794,7 +8646,7 @@ SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
8794 } 8646 }
8795#endif 8647#endif
8796 8648
8797#ifdef SIS315H 8649#ifdef CONFIG_FB_SIS_315
8798 if(SiS_Pr->ChipType >= SIS_315H) { 8650 if(SiS_Pr->ChipType >= SIS_315H) {
8799 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8651 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8800 if(SiS_Pr->ChipType < SIS_661) { 8652 if(SiS_Pr->ChipType < SIS_661) {
@@ -8873,7 +8725,7 @@ SiS_SetupDDCN(struct SiS_Private *SiS_Pr)
8873 } 8725 }
8874} 8726}
8875 8727
8876#ifdef SIS300 8728#ifdef CONFIG_FB_SIS_300
8877static unsigned char * 8729static unsigned char *
8878SiS_SetTrumpBlockLoop(struct SiS_Private *SiS_Pr, unsigned char *dataptr) 8730SiS_SetTrumpBlockLoop(struct SiS_Private *SiS_Pr, unsigned char *dataptr)
8879{ 8731{
@@ -8923,11 +8775,6 @@ SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr)
8923 dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr); 8775 dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr);
8924 if(!dataptr) return false; 8776 if(!dataptr) return false;
8925 } 8777 }
8926#ifdef SIS_XORG_XF86
8927#ifdef TWDEBUG
8928 xf86DrvMsg(0, X_INFO, "Trumpion block success\n");
8929#endif
8930#endif
8931 return true; 8778 return true;
8932} 8779}
8933#endif 8780#endif
@@ -9002,9 +8849,7 @@ SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val)
9002 SiS_SetChReg(SiS_Pr, reg, val, 0); 8849 SiS_SetChReg(SiS_Pr, reg, val, 0);
9003} 8850}
9004 8851
9005#ifdef SIS_LINUX_KERNEL
9006static 8852static
9007#endif
9008void 8853void
9009SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val) 8854SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val)
9010{ 8855{
@@ -9091,9 +8936,7 @@ SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempbx)
9091 8936
9092/* Read from Chrontel 70xx */ 8937/* Read from Chrontel 70xx */
9093/* Parameter is [Register no (S7-S0)] */ 8938/* Parameter is [Register no (S7-S0)] */
9094#ifdef SIS_LINUX_KERNEL
9095static 8939static
9096#endif
9097unsigned short 8940unsigned short
9098SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempbx) 8941SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempbx)
9099{ 8942{
@@ -9114,9 +8957,7 @@ SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg,
9114} 8957}
9115 8958
9116/* Our own DDC functions */ 8959/* Our own DDC functions */
9117#ifndef SIS_XORG_XF86
9118static 8960static
9119#endif
9120unsigned short 8961unsigned short
9121SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine, 8962SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine,
9122 unsigned short adaptnum, unsigned short DDCdatatype, bool checkcr32, 8963 unsigned short adaptnum, unsigned short DDCdatatype, bool checkcr32,
@@ -9224,12 +9065,6 @@ SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine,
9224 9065
9225 SiS_SetupDDCN(SiS_Pr); 9066 SiS_SetupDDCN(SiS_Pr);
9226 9067
9227#ifdef SIS_XORG_XF86
9228#ifdef TWDEBUG
9229 xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n",
9230 SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp);
9231#endif
9232#endif
9233 return 0; 9068 return 0;
9234} 9069}
9235 9070
@@ -9292,11 +9127,6 @@ SiS_DoProbeDDC(struct SiS_Private *SiS_Pr)
9292 SiS_SetSwitchDDC2(SiS_Pr); 9127 SiS_SetSwitchDDC2(SiS_Pr);
9293 if(SiS_PrepareDDC(SiS_Pr)) { 9128 if(SiS_PrepareDDC(SiS_Pr)) {
9294 SiS_SetStop(SiS_Pr); 9129 SiS_SetStop(SiS_Pr);
9295#ifdef SIS_XORG_XF86
9296#ifdef TWDEBUG
9297 xf86DrvMsg(0, X_INFO, "Probe: Prepare failed\n");
9298#endif
9299#endif
9300 return 0xFFFF; 9130 return 0xFFFF;
9301 } 9131 }
9302 mask = 0xf0; 9132 mask = 0xf0;
@@ -9310,11 +9140,6 @@ SiS_DoProbeDDC(struct SiS_Private *SiS_Pr)
9310 } else { 9140 } else {
9311 failed = true; 9141 failed = true;
9312 ret = 0xFFFF; 9142 ret = 0xFFFF;
9313#ifdef SIS_XORG_XF86
9314#ifdef TWDEBUG
9315 xf86DrvMsg(0, X_INFO, "Probe: Read 1 failed\n");
9316#endif
9317#endif
9318 } 9143 }
9319 } 9144 }
9320 if(!failed) { 9145 if(!failed) {
@@ -9324,11 +9149,6 @@ SiS_DoProbeDDC(struct SiS_Private *SiS_Pr)
9324 if(temp == value) ret = 0; 9149 if(temp == value) ret = 0;
9325 else { 9150 else {
9326 ret = 0xFFFF; 9151 ret = 0xFFFF;
9327#ifdef SIS_XORG_XF86
9328#ifdef TWDEBUG
9329 xf86DrvMsg(0, X_INFO, "Probe: Read 2 failed\n");
9330#endif
9331#endif
9332 if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { 9152 if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
9333 if(temp == 0x30) ret = 0; 9153 if(temp == 0x30) ret = 0;
9334 } 9154 }
@@ -9338,9 +9158,7 @@ SiS_DoProbeDDC(struct SiS_Private *SiS_Pr)
9338 return ret; 9158 return ret;
9339} 9159}
9340 9160
9341#ifndef SIS_XORG_XF86
9342static 9161static
9343#endif
9344unsigned short 9162unsigned short
9345SiS_ProbeDDC(struct SiS_Private *SiS_Pr) 9163SiS_ProbeDDC(struct SiS_Private *SiS_Pr)
9346{ 9164{
@@ -9357,9 +9175,7 @@ SiS_ProbeDDC(struct SiS_Private *SiS_Pr)
9357 return flag; 9175 return flag;
9358} 9176}
9359 9177
9360#ifndef SIS_XORG_XF86
9361static 9178static
9362#endif
9363unsigned short 9179unsigned short
9364SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, unsigned char *buffer) 9180SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, unsigned char *buffer)
9365{ 9181{
@@ -9606,11 +9422,6 @@ SiS_SetSCLKHigh(struct SiS_Private *SiS_Pr)
9606 temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); 9422 temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);
9607 } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog); 9423 } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog);
9608 if (!watchdog) { 9424 if (!watchdog) {
9609#ifdef SIS_XORG_XF86
9610#ifdef TWDEBUG
9611 xf86DrvMsg(0, X_INFO, "SetClkHigh failed\n");
9612#endif
9613#endif
9614 return 0xFFFF; 9425 return 0xFFFF;
9615 } 9426 }
9616 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 9427 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
@@ -9641,7 +9452,7 @@ SiS_CheckACK(struct SiS_Private *SiS_Pr)
9641 9452
9642/* =============== SiS 315/330 O.E.M. ================= */ 9453/* =============== SiS 315/330 O.E.M. ================= */
9643 9454
9644#ifdef SIS315H 9455#ifdef CONFIG_FB_SIS_315
9645 9456
9646static unsigned short 9457static unsigned short
9647GetRAMDACromptr(struct SiS_Private *SiS_Pr) 9458GetRAMDACromptr(struct SiS_Private *SiS_Pr)
@@ -10829,7 +10640,7 @@ SiS_FinalizeLCD(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned shor
10829 10640
10830/* ================= SiS 300 O.E.M. ================== */ 10641/* ================= SiS 300 O.E.M. ================== */
10831 10642
10832#ifdef SIS300 10643#ifdef CONFIG_FB_SIS_300
10833 10644
10834static void 10645static void
10835SetOEMLCDData2(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex, 10646SetOEMLCDData2(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex,
diff --git a/drivers/video/sis/init301.h b/drivers/video/sis/init301.h
index 51d99222375d..2112d6d7feda 100644
--- a/drivers/video/sis/init301.h
+++ b/drivers/video/sis/init301.h
@@ -53,15 +53,8 @@
53#ifndef _INIT301_H_ 53#ifndef _INIT301_H_
54#define _INIT301_H_ 54#define _INIT301_H_
55 55
56#include "osdef.h"
57#include "initdef.h" 56#include "initdef.h"
58 57
59#ifdef SIS_XORG_XF86
60#include "sis.h"
61#include "sis_regs.h"
62#endif
63
64#ifdef SIS_LINUX_KERNEL
65#include "vgatypes.h" 58#include "vgatypes.h"
66#include "vstruct.h" 59#include "vstruct.h"
67#ifdef SIS_CP 60#ifdef SIS_CP
@@ -72,7 +65,6 @@
72#include <linux/fb.h> 65#include <linux/fb.h>
73#include "sis.h" 66#include "sis.h"
74#include <video/sisfb.h> 67#include <video/sisfb.h>
75#endif
76 68
77static const unsigned char SiS_YPbPrTable[3][64] = { 69static const unsigned char SiS_YPbPrTable[3][64] = {
78 { 70 {
@@ -237,7 +229,7 @@ static const unsigned char SiS_Part2CLVX_6[] = { /* 1080i */
237 0xFF,0xFF, 229 0xFF,0xFF,
238}; 230};
239 231
240#ifdef SIS315H 232#ifdef CONFIG_FB_SIS_315
241/* 661 et al LCD data structure (2.03.00) */ 233/* 661 et al LCD data structure (2.03.00) */
242static const unsigned char SiS_LCDStruct661[] = { 234static const unsigned char SiS_LCDStruct661[] = {
243 /* 1024x768 */ 235 /* 1024x768 */
@@ -279,7 +271,7 @@ static const unsigned char SiS_LCDStruct661[] = {
279}; 271};
280#endif 272#endif
281 273
282#ifdef SIS300 274#ifdef CONFIG_FB_SIS_300
283static unsigned char SiS300_TrumpionData[14][80] = { 275static unsigned char SiS300_TrumpionData[14][80] = {
284 { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02, 276 { 0x02,0x0A,0x0A,0x01,0x04,0x01,0x00,0x03,0x0D,0x00,0x0D,0x10,0x7F,0x00,0x80,0x02,
285 0x20,0x03,0x0B,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x10,0x00,0x00,0x04,0x23, 277 0x20,0x03,0x0B,0x00,0x90,0x01,0xC1,0x01,0x60,0x0C,0x30,0x10,0x00,0x00,0x04,0x23,
@@ -356,9 +348,6 @@ static unsigned char SiS300_TrumpionData[14][80] = {
356#endif 348#endif
357 349
358void SiS_UnLockCRT2(struct SiS_Private *SiS_Pr); 350void SiS_UnLockCRT2(struct SiS_Private *SiS_Pr);
359#ifndef SIS_LINUX_KERNEL
360void SiS_LockCRT2(struct SiS_Private *SiS_Pr);
361#endif
362void SiS_EnableCRT2(struct SiS_Private *SiS_Pr); 351void SiS_EnableCRT2(struct SiS_Private *SiS_Pr);
363unsigned short SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex); 352unsigned short SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
364void SiS_WaitRetrace1(struct SiS_Private *SiS_Pr); 353void SiS_WaitRetrace1(struct SiS_Private *SiS_Pr);
@@ -375,9 +364,6 @@ unsigned short SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo
375 unsigned short RefreshRateTableIndex); 364 unsigned short RefreshRateTableIndex);
376unsigned short SiS_GetResInfo(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex); 365unsigned short SiS_GetResInfo(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex);
377void SiS_DisableBridge(struct SiS_Private *SiS_Pr); 366void SiS_DisableBridge(struct SiS_Private *SiS_Pr);
378#ifndef SIS_LINUX_KERNEL
379void SiS_EnableBridge(struct SiS_Private *SiS_Pr);
380#endif
381bool SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo); 367bool SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo);
382void SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr); 368void SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr);
383void SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr); 369void SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr);
@@ -386,13 +372,9 @@ void SiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned cha
386unsigned short SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempax); 372unsigned short SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempax);
387void SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val); 373void SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
388unsigned short SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempax); 374unsigned short SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempax);
389#ifndef SIS_LINUX_KERNEL
390void SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
391unsigned short SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempax);
392#endif
393void SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg, 375void SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg,
394 unsigned char orval,unsigned short andval); 376 unsigned char orval,unsigned short andval);
395#ifdef SIS315H 377#ifdef CONFIG_FB_SIS_315
396static void SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr); 378static void SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr);
397static void SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr); 379static void SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr);
398static void SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr); 380static void SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr);
@@ -401,7 +383,7 @@ void SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr);
401void SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr); 383void SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr);
402#endif /* 315 */ 384#endif /* 315 */
403 385
404#ifdef SIS300 386#ifdef CONFIG_FB_SIS_300
405static bool SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr); 387static bool SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr);
406void SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo); 388void SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo);
407#endif 389#endif
@@ -412,21 +394,12 @@ unsigned short SiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, i
412 unsigned short adaptnum, unsigned short DDCdatatype, 394 unsigned short adaptnum, unsigned short DDCdatatype,
413 unsigned char *buffer, unsigned int VBFlags2); 395 unsigned char *buffer, unsigned int VBFlags2);
414 396
415#ifdef SIS_XORG_XF86
416unsigned short SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags,
417 int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype,
418 bool checkcr32, unsigned int VBFlags2);
419unsigned short SiS_ProbeDDC(struct SiS_Private *SiS_Pr);
420unsigned short SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype,
421 unsigned char *buffer);
422#else
423static unsigned short SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, 397static unsigned short SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags,
424 int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype, 398 int VGAEngine, unsigned short adaptnum, unsigned short DDCdatatype,
425 bool checkcr32, unsigned int VBFlags2); 399 bool checkcr32, unsigned int VBFlags2);
426static unsigned short SiS_ProbeDDC(struct SiS_Private *SiS_Pr); 400static unsigned short SiS_ProbeDDC(struct SiS_Private *SiS_Pr);
427static unsigned short SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, 401static unsigned short SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype,
428 unsigned char *buffer); 402 unsigned char *buffer);
429#endif
430static void SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr); 403static void SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr);
431static unsigned short SiS_SetStart(struct SiS_Private *SiS_Pr); 404static unsigned short SiS_SetStart(struct SiS_Private *SiS_Pr);
432static unsigned short SiS_SetStop(struct SiS_Private *SiS_Pr); 405static unsigned short SiS_SetStop(struct SiS_Private *SiS_Pr);
@@ -441,13 +414,13 @@ static unsigned short SiS_PrepareDDC(struct SiS_Private *SiS_Pr);
441static void SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno); 414static void SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno);
442static unsigned short SiS_DoProbeDDC(struct SiS_Private *SiS_Pr); 415static unsigned short SiS_DoProbeDDC(struct SiS_Private *SiS_Pr);
443 416
444#ifdef SIS300 417#ifdef CONFIG_FB_SIS_300
445static void SiS_OEM300Setting(struct SiS_Private *SiS_Pr, 418static void SiS_OEM300Setting(struct SiS_Private *SiS_Pr,
446 unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefTabindex); 419 unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefTabindex);
447static void SetOEMLCDData2(struct SiS_Private *SiS_Pr, 420static void SetOEMLCDData2(struct SiS_Private *SiS_Pr,
448 unsigned short ModeNo, unsigned short ModeIdIndex,unsigned short RefTableIndex); 421 unsigned short ModeNo, unsigned short ModeIdIndex,unsigned short RefTableIndex);
449#endif 422#endif
450#ifdef SIS315H 423#ifdef CONFIG_FB_SIS_315
451static void SiS_OEM310Setting(struct SiS_Private *SiS_Pr, 424static void SiS_OEM310Setting(struct SiS_Private *SiS_Pr,
452 unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI); 425 unsigned short ModeNo,unsigned short ModeIdIndex, unsigned short RRTI);
453static void SiS_OEM661Setting(struct SiS_Private *SiS_Pr, 426static void SiS_OEM661Setting(struct SiS_Private *SiS_Pr,
@@ -455,17 +428,6 @@ static void SiS_OEM661Setting(struct SiS_Private *SiS_Pr,
455static void SiS_FinalizeLCD(struct SiS_Private *, unsigned short, unsigned short); 428static void SiS_FinalizeLCD(struct SiS_Private *, unsigned short, unsigned short);
456#endif 429#endif
457 430
458extern void SiS_SetReg(SISIOADDRESS, unsigned short, unsigned short);
459extern void SiS_SetRegByte(SISIOADDRESS, unsigned short);
460extern void SiS_SetRegShort(SISIOADDRESS, unsigned short);
461extern void SiS_SetRegLong(SISIOADDRESS, unsigned int);
462extern unsigned char SiS_GetReg(SISIOADDRESS, unsigned short);
463extern unsigned char SiS_GetRegByte(SISIOADDRESS);
464extern unsigned short SiS_GetRegShort(SISIOADDRESS);
465extern unsigned int SiS_GetRegLong(SISIOADDRESS);
466extern void SiS_SetRegANDOR(SISIOADDRESS, unsigned short, unsigned short, unsigned short);
467extern void SiS_SetRegOR(SISIOADDRESS, unsigned short, unsigned short);
468extern void SiS_SetRegAND(SISIOADDRESS, unsigned short, unsigned short);
469extern void SiS_DisplayOff(struct SiS_Private *SiS_Pr); 431extern void SiS_DisplayOff(struct SiS_Private *SiS_Pr);
470extern void SiS_DisplayOn(struct SiS_Private *SiS_Pr); 432extern void SiS_DisplayOn(struct SiS_Private *SiS_Pr);
471extern bool SiS_SearchModeID(struct SiS_Private *, unsigned short *, unsigned short *); 433extern bool SiS_SearchModeID(struct SiS_Private *, unsigned short *, unsigned short *);
@@ -482,15 +444,13 @@ extern void SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short M
482extern void SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth); 444extern void SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth);
483extern unsigned short SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide); 445extern unsigned short SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
484extern unsigned short SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide); 446extern unsigned short SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
485#ifdef SIS300 447#ifdef CONFIG_FB_SIS_300
486extern void SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *tempbx, 448extern void SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *tempbx,
487 unsigned short *tempcl); 449 unsigned short *tempcl);
488extern unsigned short SiS_GetFIFOThresholdB300(unsigned short tempbx, unsigned short tempcl); 450extern unsigned short SiS_GetFIFOThresholdB300(unsigned short tempbx, unsigned short tempcl);
489extern unsigned short SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index); 451extern unsigned short SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index);
490#ifdef SIS_LINUX_KERNEL
491extern unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg); 452extern unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg);
492extern unsigned int sisfb_read_lpc_pci_dword(struct SiS_Private *SiS_Pr, int reg); 453extern unsigned int sisfb_read_lpc_pci_dword(struct SiS_Private *SiS_Pr, int reg);
493#endif 454#endif
494#endif
495 455
496#endif 456#endif
diff --git a/drivers/video/sis/initextlfb.c b/drivers/video/sis/initextlfb.c
index 99c04a4855d1..9dec64da4015 100644
--- a/drivers/video/sis/initextlfb.c
+++ b/drivers/video/sis/initextlfb.c
@@ -25,7 +25,6 @@
25 * Author: Thomas Winischhofer <thomas@winischhofer.net> 25 * Author: Thomas Winischhofer <thomas@winischhofer.net>
26 */ 26 */
27 27
28#include "osdef.h"
29#include "initdef.h" 28#include "initdef.h"
30#include "vgatypes.h" 29#include "vgatypes.h"
31#include "vstruct.h" 30#include "vstruct.h"
@@ -59,7 +58,7 @@ sisfb_mode_rate_to_dclock(struct SiS_Private *SiS_Pr, unsigned char modeno,
59 58
60 if(rateindex > 0) rateindex--; 59 if(rateindex > 0) rateindex--;
61 60
62#ifdef SIS315H 61#ifdef CONFIG_FB_SIS_315
63 switch(ModeNo) { 62 switch(ModeNo) {
64 case 0x5a: ModeNo = 0x50; break; 63 case 0x5a: ModeNo = 0x50; break;
65 case 0x5b: ModeNo = 0x56; 64 case 0x5b: ModeNo = 0x56;
@@ -103,7 +102,7 @@ sisfb_mode_rate_to_ddata(struct SiS_Private *SiS_Pr, unsigned char modeno,
103 102
104 if(rateindex > 0) rateindex--; 103 if(rateindex > 0) rateindex--;
105 104
106#ifdef SIS315H 105#ifdef CONFIG_FB_SIS_315
107 switch(ModeNo) { 106 switch(ModeNo) {
108 case 0x5a: ModeNo = 0x50; break; 107 case 0x5a: ModeNo = 0x50; break;
109 case 0x5b: ModeNo = 0x56; 108 case 0x5b: ModeNo = 0x56;
@@ -187,7 +186,7 @@ sisfb_gettotalfrommode(struct SiS_Private *SiS_Pr, unsigned char modeno, int *ht
187 186
188 if(rateindex > 0) rateindex--; 187 if(rateindex > 0) rateindex--;
189 188
190#ifdef SIS315H 189#ifdef CONFIG_FB_SIS_315
191 switch(ModeNo) { 190 switch(ModeNo) {
192 case 0x5a: ModeNo = 0x50; break; 191 case 0x5a: ModeNo = 0x50; break;
193 case 0x5b: ModeNo = 0x56; 192 case 0x5b: ModeNo = 0x56;
diff --git a/drivers/video/sis/osdef.h b/drivers/video/sis/osdef.h
deleted file mode 100644
index 6ff8f988a1a7..000000000000
--- a/drivers/video/sis/osdef.h
+++ /dev/null
@@ -1,133 +0,0 @@
1/* $XFree86$ */
2/* $XdotOrg$ */
3/*
4 * OS depending defines
5 *
6 * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria
7 *
8 * If distributed as part of the Linux kernel, the following license terms
9 * apply:
10 *
11 * * This program is free software; you can redistribute it and/or modify
12 * * it under the terms of the GNU General Public License as published by
13 * * the Free Software Foundation; either version 2 of the named License,
14 * * or any later version.
15 * *
16 * * This program is distributed in the hope that it will be useful,
17 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * * GNU General Public License for more details.
20 * *
21 * * You should have received a copy of the GNU General Public License
22 * * along with this program; if not, write to the Free Software
23 * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
24 *
25 * Otherwise, the following license terms apply:
26 *
27 * * Redistribution and use in source and binary forms, with or without
28 * * modification, are permitted provided that the following conditions
29 * * are met:
30 * * 1) Redistributions of source code must retain the above copyright
31 * * notice, this list of conditions and the following disclaimer.
32 * * 2) Redistributions in binary form must reproduce the above copyright
33 * * notice, this list of conditions and the following disclaimer in the
34 * * documentation and/or other materials provided with the distribution.
35 * * 3) The name of the author may not be used to endorse or promote products
36 * * derived from this software without specific prior written permission.
37 * *
38 * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
39 * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40 * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
41 * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
42 * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 * * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45 * * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
47 * * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 *
49 * Author: Thomas Winischhofer <thomas@winischhofer.net>
50 * Silicon Integrated Systems, Inc. (used by permission)
51 *
52 */
53
54#ifndef _SIS_OSDEF_H_
55#define _SIS_OSDEF_H_
56
57/* The choices are: */
58#define SIS_LINUX_KERNEL /* Linux kernel framebuffer */
59#undef SIS_XORG_XF86 /* XFree86/X.org */
60
61#ifdef OutPortByte
62#undef OutPortByte
63#endif
64
65#ifdef OutPortWord
66#undef OutPortWord
67#endif
68
69#ifdef OutPortLong
70#undef OutPortLong
71#endif
72
73#ifdef InPortByte
74#undef InPortByte
75#endif
76
77#ifdef InPortWord
78#undef InPortWord
79#endif
80
81#ifdef InPortLong
82#undef InPortLong
83#endif
84
85/**********************************************************************/
86/* LINUX KERNEL */
87/**********************************************************************/
88
89#ifdef SIS_LINUX_KERNEL
90
91#ifdef CONFIG_FB_SIS_300
92#define SIS300
93#endif
94
95#ifdef CONFIG_FB_SIS_315
96#define SIS315H
97#endif
98
99#if !defined(SIS300) && !defined(SIS315H)
100#warning Neither CONFIG_FB_SIS_300 nor CONFIG_FB_SIS_315 is set
101#warning sisfb will not work!
102#endif
103
104#define OutPortByte(p,v) outb((u8)(v),(SISIOADDRESS)(p))
105#define OutPortWord(p,v) outw((u16)(v),(SISIOADDRESS)(p))
106#define OutPortLong(p,v) outl((u32)(v),(SISIOADDRESS)(p))
107#define InPortByte(p) inb((SISIOADDRESS)(p))
108#define InPortWord(p) inw((SISIOADDRESS)(p))
109#define InPortLong(p) inl((SISIOADDRESS)(p))
110#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset_io(MemoryAddress, value, MemorySize)
111
112#endif /* LINUX_KERNEL */
113
114/**********************************************************************/
115/* XFree86/X.org */
116/**********************************************************************/
117
118#ifdef SIS_XORG_XF86
119
120#define SIS300
121#define SIS315H
122
123#define OutPortByte(p,v) outSISREG((IOADDRESS)(p),(CARD8)(v))
124#define OutPortWord(p,v) outSISREGW((IOADDRESS)(p),(CARD16)(v))
125#define OutPortLong(p,v) outSISREGL((IOADDRESS)(p),(CARD32)(v))
126#define InPortByte(p) inSISREG((IOADDRESS)(p))
127#define InPortWord(p) inSISREGW((IOADDRESS)(p))
128#define InPortLong(p) inSISREGL((IOADDRESS)(p))
129#define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
130
131#endif /* XF86 */
132
133#endif /* _OSDEF_H_ */
diff --git a/drivers/video/sis/sis.h b/drivers/video/sis/sis.h
index 7c5710e3fb56..eac7a01925f3 100644
--- a/drivers/video/sis/sis.h
+++ b/drivers/video/sis/sis.h
@@ -24,7 +24,6 @@
24#ifndef _SIS_H_ 24#ifndef _SIS_H_
25#define _SIS_H_ 25#define _SIS_H_
26 26
27#include "osdef.h"
28#include <video/sisfb.h> 27#include <video/sisfb.h>
29 28
30#include "vgatypes.h" 29#include "vgatypes.h"
@@ -308,58 +307,19 @@
308#define VB2_LCDOVER1600BRIDGE (VB2_307T | VB2_307LV) 307#define VB2_LCDOVER1600BRIDGE (VB2_307T | VB2_307LV)
309#define VB2_RAMDAC202MHZBRIDGE (VB2_301C | VB2_307T) 308#define VB2_RAMDAC202MHZBRIDGE (VB2_301C | VB2_307T)
310 309
311/* I/O port access macros */ 310/* I/O port access functions */
312#define inSISREG(base) inb(base) 311
313 312void SiS_SetReg(SISIOADDRESS, u8, u8);
314#define outSISREG(base,val) outb(val,base) 313void SiS_SetRegByte(SISIOADDRESS, u8);
315 314void SiS_SetRegShort(SISIOADDRESS, u16);
316#define orSISREG(base,val) \ 315void SiS_SetRegLong(SISIOADDRESS, u32);
317 do { \ 316void SiS_SetRegANDOR(SISIOADDRESS, u8, u8, u8);
318 u8 __Temp = inSISREG(base); \ 317void SiS_SetRegAND(SISIOADDRESS, u8, u8);
319 outSISREG(base, __Temp | (val));\ 318void SiS_SetRegOR(SISIOADDRESS, u8, u8);
320 } while (0) 319u8 SiS_GetReg(SISIOADDRESS, u8);
321 320u8 SiS_GetRegByte(SISIOADDRESS);
322#define andSISREG(base,val) \ 321u16 SiS_GetRegShort(SISIOADDRESS);
323 do { \ 322u32 SiS_GetRegLong(SISIOADDRESS);
324 u8 __Temp = inSISREG(base); \
325 outSISREG(base, __Temp & (val));\
326 } while (0)
327
328#define inSISIDXREG(base,idx,var) \
329 do { \
330 outSISREG(base, idx); \
331 var = inSISREG((base)+1); \
332 } while (0)
333
334#define outSISIDXREG(base,idx,val) \
335 do { \
336 outSISREG(base, idx); \
337 outSISREG((base)+1, val); \
338 } while (0)
339
340#define orSISIDXREG(base,idx,val) \
341 do { \
342 u8 __Temp; \
343 outSISREG(base, idx); \
344 __Temp = inSISREG((base)+1) | (val); \
345 outSISREG((base)+1, __Temp); \
346 } while (0)
347
348#define andSISIDXREG(base,idx,and) \
349 do { \
350 u8 __Temp; \
351 outSISREG(base, idx); \
352 __Temp = inSISREG((base)+1) & (and); \
353 outSISREG((base)+1, __Temp); \
354 } while (0)
355
356#define setSISIDXREG(base,idx,and,or) \
357 do { \
358 u8 __Temp; \
359 outSISREG(base, idx); \
360 __Temp = (inSISREG((base)+1) & (and)) | (or); \
361 outSISREG((base)+1, __Temp); \
362 } while (0)
363 323
364/* MMIO access macros */ 324/* MMIO access macros */
365#define MMIO_IN8(base, offset) readb((base+offset)) 325#define MMIO_IN8(base, offset) readb((base+offset))
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index 3dde12b0ab06..2fb8c5a660fb 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -60,6 +60,11 @@
60#include "sis.h" 60#include "sis.h"
61#include "sis_main.h" 61#include "sis_main.h"
62 62
63#if !defined(CONFIG_FB_SIS_300) && !defined(CONFIG_FB_SIS_315)
64#warning Neither CONFIG_FB_SIS_300 nor CONFIG_FB_SIS_315 is set
65#warning sisfb will not work!
66#endif
67
63static void sisfb_handle_command(struct sis_video_info *ivideo, 68static void sisfb_handle_command(struct sis_video_info *ivideo,
64 struct sisfb_cmd *sisfb_command); 69 struct sisfb_cmd *sisfb_command);
65 70
@@ -732,7 +737,7 @@ sisfb_bridgeisslave(struct sis_video_info *ivideo)
732 if(!(ivideo->vbflags2 & VB2_VIDEOBRIDGE)) 737 if(!(ivideo->vbflags2 & VB2_VIDEOBRIDGE))
733 return false; 738 return false;
734 739
735 inSISIDXREG(SISPART1,0x00,P1_00); 740 P1_00 = SiS_GetReg(SISPART1, 0x00);
736 if( ((ivideo->sisvga_engine == SIS_300_VGA) && (P1_00 & 0xa0) == 0x20) || 741 if( ((ivideo->sisvga_engine == SIS_300_VGA) && (P1_00 & 0xa0) == 0x20) ||
737 ((ivideo->sisvga_engine == SIS_315_VGA) && (P1_00 & 0x50) == 0x10) ) { 742 ((ivideo->sisvga_engine == SIS_315_VGA) && (P1_00 & 0x50) == 0x10) ) {
738 return true; 743 return true;
@@ -746,11 +751,11 @@ sisfballowretracecrt1(struct sis_video_info *ivideo)
746{ 751{
747 u8 temp; 752 u8 temp;
748 753
749 inSISIDXREG(SISCR,0x17,temp); 754 temp = SiS_GetReg(SISCR, 0x17);
750 if(!(temp & 0x80)) 755 if(!(temp & 0x80))
751 return false; 756 return false;
752 757
753 inSISIDXREG(SISSR,0x1f,temp); 758 temp = SiS_GetReg(SISSR, 0x1f);
754 if(temp & 0xc0) 759 if(temp & 0xc0)
755 return false; 760 return false;
756 761
@@ -763,7 +768,7 @@ sisfbcheckvretracecrt1(struct sis_video_info *ivideo)
763 if(!sisfballowretracecrt1(ivideo)) 768 if(!sisfballowretracecrt1(ivideo))
764 return false; 769 return false;
765 770
766 if(inSISREG(SISINPSTAT) & 0x08) 771 if (SiS_GetRegByte(SISINPSTAT) & 0x08)
767 return true; 772 return true;
768 else 773 else
769 return false; 774 return false;
@@ -778,9 +783,9 @@ sisfbwaitretracecrt1(struct sis_video_info *ivideo)
778 return; 783 return;
779 784
780 watchdog = 65536; 785 watchdog = 65536;
781 while((!(inSISREG(SISINPSTAT) & 0x08)) && --watchdog); 786 while ((!(SiS_GetRegByte(SISINPSTAT) & 0x08)) && --watchdog);
782 watchdog = 65536; 787 watchdog = 65536;
783 while((inSISREG(SISINPSTAT) & 0x08) && --watchdog); 788 while ((SiS_GetRegByte(SISINPSTAT) & 0x08) && --watchdog);
784} 789}
785 790
786static bool 791static bool
@@ -794,7 +799,7 @@ sisfbcheckvretracecrt2(struct sis_video_info *ivideo)
794 default: return false; 799 default: return false;
795 } 800 }
796 801
797 inSISIDXREG(SISPART1, reg, temp); 802 temp = SiS_GetReg(SISPART1, reg);
798 if(temp & 0x02) 803 if(temp & 0x02)
799 return true; 804 return true;
800 else 805 else
@@ -832,10 +837,10 @@ sisfb_setupvbblankflags(struct sis_video_info *ivideo, u32 *vcount, u32 *hcount)
832 default: 837 default:
833 case SIS_315_VGA: idx = 0x30; break; 838 case SIS_315_VGA: idx = 0x30; break;
834 } 839 }
835 inSISIDXREG(SISPART1,(idx+0),reg1); /* 30 */ 840 reg1 = SiS_GetReg(SISPART1, (idx+0)); /* 30 */
836 inSISIDXREG(SISPART1,(idx+1),reg2); /* 31 */ 841 reg2 = SiS_GetReg(SISPART1, (idx+1)); /* 31 */
837 inSISIDXREG(SISPART1,(idx+2),reg3); /* 32 */ 842 reg3 = SiS_GetReg(SISPART1, (idx+2)); /* 32 */
838 inSISIDXREG(SISPART1,(idx+3),reg4); /* 33 */ 843 reg4 = SiS_GetReg(SISPART1, (idx+3)); /* 33 */
839 if(reg1 & 0x01) ret |= FB_VBLANK_VBLANKING; 844 if(reg1 & 0x01) ret |= FB_VBLANK_VBLANKING;
840 if(reg1 & 0x02) ret |= FB_VBLANK_VSYNCING; 845 if(reg1 & 0x02) ret |= FB_VBLANK_VSYNCING;
841 if(reg4 & 0x80) ret |= FB_VBLANK_HBLANKING; 846 if(reg4 & 0x80) ret |= FB_VBLANK_HBLANKING;
@@ -848,13 +853,13 @@ sisfb_setupvbblankflags(struct sis_video_info *ivideo, u32 *vcount, u32 *hcount)
848 FB_VBLANK_HAVE_VBLANK | 853 FB_VBLANK_HAVE_VBLANK |
849 FB_VBLANK_HAVE_VCOUNT | 854 FB_VBLANK_HAVE_VCOUNT |
850 FB_VBLANK_HAVE_HCOUNT); 855 FB_VBLANK_HAVE_HCOUNT);
851 reg1 = inSISREG(SISINPSTAT); 856 reg1 = SiS_GetRegByte(SISINPSTAT);
852 if(reg1 & 0x08) ret |= FB_VBLANK_VSYNCING; 857 if(reg1 & 0x08) ret |= FB_VBLANK_VSYNCING;
853 if(reg1 & 0x01) ret |= FB_VBLANK_VBLANKING; 858 if(reg1 & 0x01) ret |= FB_VBLANK_VBLANKING;
854 inSISIDXREG(SISCR,0x20,reg1); 859 reg1 = SiS_GetReg(SISCR, 0x20);
855 inSISIDXREG(SISCR,0x1b,reg1); 860 reg1 = SiS_GetReg(SISCR, 0x1b);
856 inSISIDXREG(SISCR,0x1c,reg2); 861 reg2 = SiS_GetReg(SISCR, 0x1c);
857 inSISIDXREG(SISCR,0x1d,reg3); 862 reg3 = SiS_GetReg(SISCR, 0x1d);
858 (*vcount) = reg2 | ((reg3 & 0x07) << 8); 863 (*vcount) = reg2 | ((reg3 & 0x07) << 8);
859 (*hcount) = (reg1 | ((reg3 & 0x10) << 4)) << 3; 864 (*hcount) = (reg1 | ((reg3 & 0x10) << 4)) << 3;
860 } 865 }
@@ -925,12 +930,12 @@ sisfb_myblank(struct sis_video_info *ivideo, int blank)
925 (ivideo->sisfb_thismonitor.feature & 0xe0))) { 930 (ivideo->sisfb_thismonitor.feature & 0xe0))) {
926 931
927 if(ivideo->sisvga_engine == SIS_315_VGA) { 932 if(ivideo->sisvga_engine == SIS_315_VGA) {
928 setSISIDXREG(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xbf, cr63); 933 SiS_SetRegANDOR(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xbf, cr63);
929 } 934 }
930 935
931 if(!(sisfb_bridgeisslave(ivideo))) { 936 if(!(sisfb_bridgeisslave(ivideo))) {
932 setSISIDXREG(SISSR, 0x01, ~0x20, sr01); 937 SiS_SetRegANDOR(SISSR, 0x01, ~0x20, sr01);
933 setSISIDXREG(SISSR, 0x1f, 0x3f, sr1f); 938 SiS_SetRegANDOR(SISSR, 0x1f, 0x3f, sr1f);
934 } 939 }
935 } 940 }
936 941
@@ -960,25 +965,25 @@ sisfb_myblank(struct sis_video_info *ivideo, int blank)
960 (ivideo->vbflags2 & (VB2_301|VB2_30xBDH|VB2_LVDS))) || 965 (ivideo->vbflags2 & (VB2_301|VB2_30xBDH|VB2_LVDS))) ||
961 ((ivideo->sisvga_engine == SIS_315_VGA) && 966 ((ivideo->sisvga_engine == SIS_315_VGA) &&
962 ((ivideo->vbflags2 & (VB2_LVDS | VB2_CHRONTEL)) == VB2_LVDS))) { 967 ((ivideo->vbflags2 & (VB2_LVDS | VB2_CHRONTEL)) == VB2_LVDS))) {
963 setSISIDXREG(SISSR, 0x11, ~0x0c, sr11); 968 SiS_SetRegANDOR(SISSR, 0x11, ~0x0c, sr11);
964 } 969 }
965 970
966 if(ivideo->sisvga_engine == SIS_300_VGA) { 971 if(ivideo->sisvga_engine == SIS_300_VGA) {
967 if((ivideo->vbflags2 & VB2_30xB) && 972 if((ivideo->vbflags2 & VB2_30xB) &&
968 (!(ivideo->vbflags2 & VB2_30xBDH))) { 973 (!(ivideo->vbflags2 & VB2_30xBDH))) {
969 setSISIDXREG(SISPART1, 0x13, 0x3f, p1_13); 974 SiS_SetRegANDOR(SISPART1, 0x13, 0x3f, p1_13);
970 } 975 }
971 } else if(ivideo->sisvga_engine == SIS_315_VGA) { 976 } else if(ivideo->sisvga_engine == SIS_315_VGA) {
972 if((ivideo->vbflags2 & VB2_30xB) && 977 if((ivideo->vbflags2 & VB2_30xB) &&
973 (!(ivideo->vbflags2 & VB2_30xBDH))) { 978 (!(ivideo->vbflags2 & VB2_30xBDH))) {
974 setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); 979 SiS_SetRegANDOR(SISPART2, 0x00, 0x1f, p2_0);
975 } 980 }
976 } 981 }
977 982
978 } else if(ivideo->currentvbflags & CRT2_VGA) { 983 } else if(ivideo->currentvbflags & CRT2_VGA) {
979 984
980 if(ivideo->vbflags2 & VB2_30xB) { 985 if(ivideo->vbflags2 & VB2_30xB) {
981 setSISIDXREG(SISPART2, 0x00, 0x1f, p2_0); 986 SiS_SetRegANDOR(SISPART2, 0x00, 0x1f, p2_0);
982 } 987 }
983 988
984 } 989 }
@@ -1109,15 +1114,15 @@ sisfb_set_pitch(struct sis_video_info *ivideo)
1109 1114
1110 /* We need to set pitch for CRT1 if bridge is in slave mode, too */ 1115 /* We need to set pitch for CRT1 if bridge is in slave mode, too */
1111 if((ivideo->currentvbflags & VB_DISPTYPE_DISP1) || (isslavemode)) { 1116 if((ivideo->currentvbflags & VB_DISPTYPE_DISP1) || (isslavemode)) {
1112 outSISIDXREG(SISCR,0x13,(HDisplay1 & 0xFF)); 1117 SiS_SetReg(SISCR, 0x13, (HDisplay1 & 0xFF));
1113 setSISIDXREG(SISSR,0x0E,0xF0,(HDisplay1 >> 8)); 1118 SiS_SetRegANDOR(SISSR, 0x0E, 0xF0, (HDisplay1 >> 8));
1114 } 1119 }
1115 1120
1116 /* We must not set the pitch for CRT2 if bridge is in slave mode */ 1121 /* We must not set the pitch for CRT2 if bridge is in slave mode */
1117 if((ivideo->currentvbflags & VB_DISPTYPE_DISP2) && (!isslavemode)) { 1122 if((ivideo->currentvbflags & VB_DISPTYPE_DISP2) && (!isslavemode)) {
1118 orSISIDXREG(SISPART1,ivideo->CRT2_write_enable,0x01); 1123 SiS_SetRegOR(SISPART1, ivideo->CRT2_write_enable, 0x01);
1119 outSISIDXREG(SISPART1,0x07,(HDisplay2 & 0xFF)); 1124 SiS_SetReg(SISPART1, 0x07, (HDisplay2 & 0xFF));
1120 setSISIDXREG(SISPART1,0x09,0xF0,(HDisplay2 >> 8)); 1125 SiS_SetRegANDOR(SISPART1, 0x09, 0xF0, (HDisplay2 >> 8));
1121 } 1126 }
1122} 1127}
1123 1128
@@ -1162,7 +1167,7 @@ sisfb_set_mode(struct sis_video_info *ivideo, int clrscrn)
1162 /* >=2.6.12's fbcon clears the screen anyway */ 1167 /* >=2.6.12's fbcon clears the screen anyway */
1163 modeno |= 0x80; 1168 modeno |= 0x80;
1164 1169
1165 outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); 1170 SiS_SetReg(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD);
1166 1171
1167 sisfb_pre_setmode(ivideo); 1172 sisfb_pre_setmode(ivideo);
1168 1173
@@ -1171,7 +1176,7 @@ sisfb_set_mode(struct sis_video_info *ivideo, int clrscrn)
1171 return -EINVAL; 1176 return -EINVAL;
1172 } 1177 }
1173 1178
1174 outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); 1179 SiS_SetReg(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD);
1175 1180
1176 sisfb_post_setmode(ivideo); 1181 sisfb_post_setmode(ivideo);
1177 1182
@@ -1303,13 +1308,13 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in
1303static void 1308static void
1304sisfb_set_base_CRT1(struct sis_video_info *ivideo, unsigned int base) 1309sisfb_set_base_CRT1(struct sis_video_info *ivideo, unsigned int base)
1305{ 1310{
1306 outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD); 1311 SiS_SetReg(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD);
1307 1312
1308 outSISIDXREG(SISCR, 0x0D, base & 0xFF); 1313 SiS_SetReg(SISCR, 0x0D, base & 0xFF);
1309 outSISIDXREG(SISCR, 0x0C, (base >> 8) & 0xFF); 1314 SiS_SetReg(SISCR, 0x0C, (base >> 8) & 0xFF);
1310 outSISIDXREG(SISSR, 0x0D, (base >> 16) & 0xFF); 1315 SiS_SetReg(SISSR, 0x0D, (base >> 16) & 0xFF);
1311 if(ivideo->sisvga_engine == SIS_315_VGA) { 1316 if(ivideo->sisvga_engine == SIS_315_VGA) {
1312 setSISIDXREG(SISSR, 0x37, 0xFE, (base >> 24) & 0x01); 1317 SiS_SetRegANDOR(SISSR, 0x37, 0xFE, (base >> 24) & 0x01);
1313 } 1318 }
1314} 1319}
1315 1320
@@ -1317,12 +1322,12 @@ static void
1317sisfb_set_base_CRT2(struct sis_video_info *ivideo, unsigned int base) 1322sisfb_set_base_CRT2(struct sis_video_info *ivideo, unsigned int base)
1318{ 1323{
1319 if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { 1324 if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) {
1320 orSISIDXREG(SISPART1, ivideo->CRT2_write_enable, 0x01); 1325 SiS_SetRegOR(SISPART1, ivideo->CRT2_write_enable, 0x01);
1321 outSISIDXREG(SISPART1, 0x06, (base & 0xFF)); 1326 SiS_SetReg(SISPART1, 0x06, (base & 0xFF));
1322 outSISIDXREG(SISPART1, 0x05, ((base >> 8) & 0xFF)); 1327 SiS_SetReg(SISPART1, 0x05, ((base >> 8) & 0xFF));
1323 outSISIDXREG(SISPART1, 0x04, ((base >> 16) & 0xFF)); 1328 SiS_SetReg(SISPART1, 0x04, ((base >> 16) & 0xFF));
1324 if(ivideo->sisvga_engine == SIS_315_VGA) { 1329 if(ivideo->sisvga_engine == SIS_315_VGA) {
1325 setSISIDXREG(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7); 1330 SiS_SetRegANDOR(SISPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7);
1326 } 1331 }
1327 } 1332 }
1328} 1333}
@@ -1383,15 +1388,15 @@ sisfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue,
1383 1388
1384 switch(info->var.bits_per_pixel) { 1389 switch(info->var.bits_per_pixel) {
1385 case 8: 1390 case 8:
1386 outSISREG(SISDACA, regno); 1391 SiS_SetRegByte(SISDACA, regno);
1387 outSISREG(SISDACD, (red >> 10)); 1392 SiS_SetRegByte(SISDACD, (red >> 10));
1388 outSISREG(SISDACD, (green >> 10)); 1393 SiS_SetRegByte(SISDACD, (green >> 10));
1389 outSISREG(SISDACD, (blue >> 10)); 1394 SiS_SetRegByte(SISDACD, (blue >> 10));
1390 if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) { 1395 if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) {
1391 outSISREG(SISDAC2A, regno); 1396 SiS_SetRegByte(SISDAC2A, regno);
1392 outSISREG(SISDAC2D, (red >> 8)); 1397 SiS_SetRegByte(SISDAC2D, (red >> 8));
1393 outSISREG(SISDAC2D, (green >> 8)); 1398 SiS_SetRegByte(SISDAC2D, (green >> 8));
1394 outSISREG(SISDAC2D, (blue >> 8)); 1399 SiS_SetRegByte(SISDAC2D, (blue >> 8));
1395 } 1400 }
1396 break; 1401 break;
1397 case 16: 1402 case 16:
@@ -1956,7 +1961,7 @@ sisfb_get_dram_size(struct sis_video_info *ivideo)
1956 switch(ivideo->chip) { 1961 switch(ivideo->chip) {
1957#ifdef CONFIG_FB_SIS_300 1962#ifdef CONFIG_FB_SIS_300
1958 case SIS_300: 1963 case SIS_300:
1959 inSISIDXREG(SISSR, 0x14, reg); 1964 reg = SiS_GetReg(SISSR, 0x14);
1960 ivideo->video_size = ((reg & 0x3F) + 1) << 20; 1965 ivideo->video_size = ((reg & 0x3F) + 1) << 20;
1961 break; 1966 break;
1962 case SIS_540: 1967 case SIS_540:
@@ -1972,7 +1977,7 @@ sisfb_get_dram_size(struct sis_video_info *ivideo)
1972 case SIS_315H: 1977 case SIS_315H:
1973 case SIS_315PRO: 1978 case SIS_315PRO:
1974 case SIS_315: 1979 case SIS_315:
1975 inSISIDXREG(SISSR, 0x14, reg); 1980 reg = SiS_GetReg(SISSR, 0x14);
1976 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20; 1981 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20;
1977 switch((reg >> 2) & 0x03) { 1982 switch((reg >> 2) & 0x03) {
1978 case 0x01: 1983 case 0x01:
@@ -1984,31 +1989,31 @@ sisfb_get_dram_size(struct sis_video_info *ivideo)
1984 } 1989 }
1985 break; 1990 break;
1986 case SIS_330: 1991 case SIS_330:
1987 inSISIDXREG(SISSR, 0x14, reg); 1992 reg = SiS_GetReg(SISSR, 0x14);
1988 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20; 1993 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20;
1989 if(reg & 0x0c) ivideo->video_size <<= 1; 1994 if(reg & 0x0c) ivideo->video_size <<= 1;
1990 break; 1995 break;
1991 case SIS_550: 1996 case SIS_550:
1992 case SIS_650: 1997 case SIS_650:
1993 case SIS_740: 1998 case SIS_740:
1994 inSISIDXREG(SISSR, 0x14, reg); 1999 reg = SiS_GetReg(SISSR, 0x14);
1995 ivideo->video_size = (((reg & 0x3f) + 1) << 2) << 20; 2000 ivideo->video_size = (((reg & 0x3f) + 1) << 2) << 20;
1996 break; 2001 break;
1997 case SIS_661: 2002 case SIS_661:
1998 case SIS_741: 2003 case SIS_741:
1999 inSISIDXREG(SISCR, 0x79, reg); 2004 reg = SiS_GetReg(SISCR, 0x79);
2000 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20; 2005 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20;
2001 break; 2006 break;
2002 case SIS_660: 2007 case SIS_660:
2003 case SIS_760: 2008 case SIS_760:
2004 case SIS_761: 2009 case SIS_761:
2005 inSISIDXREG(SISCR, 0x79, reg); 2010 reg = SiS_GetReg(SISCR, 0x79);
2006 reg = (reg & 0xf0) >> 4; 2011 reg = (reg & 0xf0) >> 4;
2007 if(reg) { 2012 if(reg) {
2008 ivideo->video_size = (1 << reg) << 20; 2013 ivideo->video_size = (1 << reg) << 20;
2009 ivideo->UMAsize = ivideo->video_size; 2014 ivideo->UMAsize = ivideo->video_size;
2010 } 2015 }
2011 inSISIDXREG(SISCR, 0x78, reg); 2016 reg = SiS_GetReg(SISCR, 0x78);
2012 reg &= 0x30; 2017 reg &= 0x30;
2013 if(reg) { 2018 if(reg) {
2014 if(reg == 0x10) { 2019 if(reg == 0x10) {
@@ -2022,7 +2027,7 @@ sisfb_get_dram_size(struct sis_video_info *ivideo)
2022 case SIS_340: 2027 case SIS_340:
2023 case XGI_20: 2028 case XGI_20:
2024 case XGI_40: 2029 case XGI_40:
2025 inSISIDXREG(SISSR, 0x14, reg); 2030 reg = SiS_GetReg(SISSR, 0x14);
2026 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20; 2031 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20;
2027 if(ivideo->chip != XGI_20) { 2032 if(ivideo->chip != XGI_20) {
2028 reg = (reg & 0x0c) >> 2; 2033 reg = (reg & 0x0c) >> 2;
@@ -2056,11 +2061,11 @@ sisfb_detect_VB_connect(struct sis_video_info *ivideo)
2056 2061
2057#ifdef CONFIG_FB_SIS_300 2062#ifdef CONFIG_FB_SIS_300
2058 if(ivideo->sisvga_engine == SIS_300_VGA) { 2063 if(ivideo->sisvga_engine == SIS_300_VGA) {
2059 inSISIDXREG(SISSR, 0x17, temp); 2064 temp = SiS_GetReg(SISSR, 0x17);
2060 if((temp & 0x0F) && (ivideo->chip != SIS_300)) { 2065 if((temp & 0x0F) && (ivideo->chip != SIS_300)) {
2061 /* PAL/NTSC is stored on SR16 on such machines */ 2066 /* PAL/NTSC is stored on SR16 on such machines */
2062 if(!(ivideo->vbflags & (TV_PAL | TV_NTSC | TV_PALM | TV_PALN))) { 2067 if(!(ivideo->vbflags & (TV_PAL | TV_NTSC | TV_PALM | TV_PALN))) {
2063 inSISIDXREG(SISSR, 0x16, temp); 2068 temp = SiS_GetReg(SISSR, 0x16);
2064 if(temp & 0x20) 2069 if(temp & 0x20)
2065 ivideo->vbflags |= TV_PAL; 2070 ivideo->vbflags |= TV_PAL;
2066 else 2071 else
@@ -2070,7 +2075,7 @@ sisfb_detect_VB_connect(struct sis_video_info *ivideo)
2070 } 2075 }
2071#endif 2076#endif
2072 2077
2073 inSISIDXREG(SISCR, 0x32, cr32); 2078 cr32 = SiS_GetReg(SISCR, 0x32);
2074 2079
2075 if(cr32 & SIS_CRT1) { 2080 if(cr32 & SIS_CRT1) {
2076 ivideo->sisfb_crt1off = 0; 2081 ivideo->sisfb_crt1off = 0;
@@ -2146,15 +2151,15 @@ sisfb_detect_VB_connect(struct sis_video_info *ivideo)
2146 } 2151 }
2147 if(!(ivideo->vbflags & (TV_PAL | TV_NTSC | TV_PALM | TV_PALN | TV_NTSCJ))) { 2152 if(!(ivideo->vbflags & (TV_PAL | TV_NTSC | TV_PALM | TV_PALN | TV_NTSCJ))) {
2148 if(ivideo->sisvga_engine == SIS_300_VGA) { 2153 if(ivideo->sisvga_engine == SIS_300_VGA) {
2149 inSISIDXREG(SISSR, 0x38, temp); 2154 temp = SiS_GetReg(SISSR, 0x38);
2150 if(temp & 0x01) ivideo->vbflags |= TV_PAL; 2155 if(temp & 0x01) ivideo->vbflags |= TV_PAL;
2151 else ivideo->vbflags |= TV_NTSC; 2156 else ivideo->vbflags |= TV_NTSC;
2152 } else if((ivideo->chip <= SIS_315PRO) || (ivideo->chip >= SIS_330)) { 2157 } else if((ivideo->chip <= SIS_315PRO) || (ivideo->chip >= SIS_330)) {
2153 inSISIDXREG(SISSR, 0x38, temp); 2158 temp = SiS_GetReg(SISSR, 0x38);
2154 if(temp & 0x01) ivideo->vbflags |= TV_PAL; 2159 if(temp & 0x01) ivideo->vbflags |= TV_PAL;
2155 else ivideo->vbflags |= TV_NTSC; 2160 else ivideo->vbflags |= TV_NTSC;
2156 } else { 2161 } else {
2157 inSISIDXREG(SISCR, 0x79, temp); 2162 temp = SiS_GetReg(SISCR, 0x79);
2158 if(temp & 0x20) ivideo->vbflags |= TV_PAL; 2163 if(temp & 0x20) ivideo->vbflags |= TV_PAL;
2159 else ivideo->vbflags |= TV_NTSC; 2164 else ivideo->vbflags |= TV_NTSC;
2160 } 2165 }
@@ -2193,26 +2198,26 @@ sisfb_sense_crt1(struct sis_video_info *ivideo)
2193 u16 temp = 0xffff; 2198 u16 temp = 0xffff;
2194 int i; 2199 int i;
2195 2200
2196 inSISIDXREG(SISSR,0x1F,sr1F); 2201 sr1F = SiS_GetReg(SISSR, 0x1F);
2197 orSISIDXREG(SISSR,0x1F,0x04); 2202 SiS_SetRegOR(SISSR, 0x1F, 0x04);
2198 andSISIDXREG(SISSR,0x1F,0x3F); 2203 SiS_SetRegAND(SISSR, 0x1F, 0x3F);
2199 if(sr1F & 0xc0) mustwait = true; 2204 if(sr1F & 0xc0) mustwait = true;
2200 2205
2201#ifdef CONFIG_FB_SIS_315 2206#ifdef CONFIG_FB_SIS_315
2202 if(ivideo->sisvga_engine == SIS_315_VGA) { 2207 if(ivideo->sisvga_engine == SIS_315_VGA) {
2203 inSISIDXREG(SISCR,ivideo->SiS_Pr.SiS_MyCR63,cr63); 2208 cr63 = SiS_GetReg(SISCR, ivideo->SiS_Pr.SiS_MyCR63);
2204 cr63 &= 0x40; 2209 cr63 &= 0x40;
2205 andSISIDXREG(SISCR,ivideo->SiS_Pr.SiS_MyCR63,0xBF); 2210 SiS_SetRegAND(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xBF);
2206 } 2211 }
2207#endif 2212#endif
2208 2213
2209 inSISIDXREG(SISCR,0x17,cr17); 2214 cr17 = SiS_GetReg(SISCR, 0x17);
2210 cr17 &= 0x80; 2215 cr17 &= 0x80;
2211 if(!cr17) { 2216 if(!cr17) {
2212 orSISIDXREG(SISCR,0x17,0x80); 2217 SiS_SetRegOR(SISCR, 0x17, 0x80);
2213 mustwait = true; 2218 mustwait = true;
2214 outSISIDXREG(SISSR, 0x00, 0x01); 2219 SiS_SetReg(SISSR, 0x00, 0x01);
2215 outSISIDXREG(SISSR, 0x00, 0x03); 2220 SiS_SetReg(SISSR, 0x00, 0x03);
2216 } 2221 }
2217 2222
2218 if(mustwait) { 2223 if(mustwait) {
@@ -2221,18 +2226,18 @@ sisfb_sense_crt1(struct sis_video_info *ivideo)
2221 2226
2222#ifdef CONFIG_FB_SIS_315 2227#ifdef CONFIG_FB_SIS_315
2223 if(ivideo->chip >= SIS_330) { 2228 if(ivideo->chip >= SIS_330) {
2224 andSISIDXREG(SISCR,0x32,~0x20); 2229 SiS_SetRegAND(SISCR, 0x32, ~0x20);
2225 if(ivideo->chip >= SIS_340) { 2230 if(ivideo->chip >= SIS_340) {
2226 outSISIDXREG(SISCR, 0x57, 0x4a); 2231 SiS_SetReg(SISCR, 0x57, 0x4a);
2227 } else { 2232 } else {
2228 outSISIDXREG(SISCR, 0x57, 0x5f); 2233 SiS_SetReg(SISCR, 0x57, 0x5f);
2229 } 2234 }
2230 orSISIDXREG(SISCR, 0x53, 0x02); 2235 SiS_SetRegOR(SISCR, 0x53, 0x02);
2231 while((inSISREG(SISINPSTAT)) & 0x01) break; 2236 while ((SiS_GetRegByte(SISINPSTAT)) & 0x01) break;
2232 while(!((inSISREG(SISINPSTAT)) & 0x01)) break; 2237 while (!((SiS_GetRegByte(SISINPSTAT)) & 0x01)) break;
2233 if((inSISREG(SISMISCW)) & 0x10) temp = 1; 2238 if ((SiS_GetRegByte(SISMISCW)) & 0x10) temp = 1;
2234 andSISIDXREG(SISCR, 0x53, 0xfd); 2239 SiS_SetRegAND(SISCR, 0x53, 0xfd);
2235 andSISIDXREG(SISCR, 0x57, 0x00); 2240 SiS_SetRegAND(SISCR, 0x57, 0x00);
2236 } 2241 }
2237#endif 2242#endif
2238 2243
@@ -2249,18 +2254,18 @@ sisfb_sense_crt1(struct sis_video_info *ivideo)
2249 } 2254 }
2250 2255
2251 if((temp) && (temp != 0xffff)) { 2256 if((temp) && (temp != 0xffff)) {
2252 orSISIDXREG(SISCR,0x32,0x20); 2257 SiS_SetRegOR(SISCR, 0x32, 0x20);
2253 } 2258 }
2254 2259
2255#ifdef CONFIG_FB_SIS_315 2260#ifdef CONFIG_FB_SIS_315
2256 if(ivideo->sisvga_engine == SIS_315_VGA) { 2261 if(ivideo->sisvga_engine == SIS_315_VGA) {
2257 setSISIDXREG(SISCR,ivideo->SiS_Pr.SiS_MyCR63,0xBF,cr63); 2262 SiS_SetRegANDOR(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xBF, cr63);
2258 } 2263 }
2259#endif 2264#endif
2260 2265
2261 setSISIDXREG(SISCR,0x17,0x7F,cr17); 2266 SiS_SetRegANDOR(SISCR, 0x17, 0x7F, cr17);
2262 2267
2263 outSISIDXREG(SISSR,0x1F,sr1F); 2268 SiS_SetReg(SISSR, 0x1F, sr1F);
2264} 2269}
2265 2270
2266/* Determine and detect attached devices on SiS30x */ 2271/* Determine and detect attached devices on SiS30x */
@@ -2281,7 +2286,7 @@ SiS_SenseLCD(struct sis_video_info *ivideo)
2281 return; 2286 return;
2282 2287
2283 /* If LCD already set up by BIOS, skip it */ 2288 /* If LCD already set up by BIOS, skip it */
2284 inSISIDXREG(SISCR, 0x32, reg); 2289 reg = SiS_GetReg(SISCR, 0x32);
2285 if(reg & 0x08) 2290 if(reg & 0x08)
2286 return; 2291 return;
2287 2292
@@ -2344,10 +2349,10 @@ SiS_SenseLCD(struct sis_video_info *ivideo)
2344 else 2349 else
2345 cr37 |= 0xc0; 2350 cr37 |= 0xc0;
2346 2351
2347 outSISIDXREG(SISCR, 0x36, paneltype); 2352 SiS_SetReg(SISCR, 0x36, paneltype);
2348 cr37 &= 0xf1; 2353 cr37 &= 0xf1;
2349 setSISIDXREG(SISCR, 0x37, 0x0c, cr37); 2354 SiS_SetRegANDOR(SISCR, 0x37, 0x0c, cr37);
2350 orSISIDXREG(SISCR, 0x32, 0x08); 2355 SiS_SetRegOR(SISCR, 0x32, 0x08);
2351 2356
2352 ivideo->SiS_Pr.PanelSelfDetected = true; 2357 ivideo->SiS_Pr.PanelSelfDetected = true;
2353} 2358}
@@ -2361,19 +2366,19 @@ SISDoSense(struct sis_video_info *ivideo, u16 type, u16 test)
2361 result = 0; 2366 result = 0;
2362 for(i = 0; i < 3; i++) { 2367 for(i = 0; i < 3; i++) {
2363 mytest = test; 2368 mytest = test;
2364 outSISIDXREG(SISPART4,0x11,(type & 0x00ff)); 2369 SiS_SetReg(SISPART4, 0x11, (type & 0x00ff));
2365 temp = (type >> 8) | (mytest & 0x00ff); 2370 temp = (type >> 8) | (mytest & 0x00ff);
2366 setSISIDXREG(SISPART4,0x10,0xe0,temp); 2371 SiS_SetRegANDOR(SISPART4, 0x10, 0xe0, temp);
2367 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1500); 2372 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1500);
2368 mytest >>= 8; 2373 mytest >>= 8;
2369 mytest &= 0x7f; 2374 mytest &= 0x7f;
2370 inSISIDXREG(SISPART4,0x03,temp); 2375 temp = SiS_GetReg(SISPART4, 0x03);
2371 temp ^= 0x0e; 2376 temp ^= 0x0e;
2372 temp &= mytest; 2377 temp &= mytest;
2373 if(temp == mytest) result++; 2378 if(temp == mytest) result++;
2374#if 1 2379#if 1
2375 outSISIDXREG(SISPART4,0x11,0x00); 2380 SiS_SetReg(SISPART4, 0x11, 0x00);
2376 andSISIDXREG(SISPART4,0x10,0xe0); 2381 SiS_SetRegAND(SISPART4, 0x10, 0xe0);
2377 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1000); 2382 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1000);
2378#endif 2383#endif
2379 } 2384 }
@@ -2395,7 +2400,7 @@ SiS_Sense30x(struct sis_video_info *ivideo)
2395 2400
2396 if(ivideo->vbflags2 & VB2_301) { 2401 if(ivideo->vbflags2 & VB2_301) {
2397 svhs = 0x00b9; cvbs = 0x00b3; vga2 = 0x00d1; 2402 svhs = 0x00b9; cvbs = 0x00b3; vga2 = 0x00d1;
2398 inSISIDXREG(SISPART4,0x01,myflag); 2403 myflag = SiS_GetReg(SISPART4, 0x01);
2399 if(myflag & 0x04) { 2404 if(myflag & 0x04) {
2400 svhs = 0x00dd; cvbs = 0x00ee; vga2 = 0x00fd; 2405 svhs = 0x00dd; cvbs = 0x00ee; vga2 = 0x00fd;
2401 } 2406 }
@@ -2425,7 +2430,7 @@ SiS_Sense30x(struct sis_video_info *ivideo)
2425 } 2430 }
2426 2431
2427 if(ivideo->chip == SIS_300) { 2432 if(ivideo->chip == SIS_300) {
2428 inSISIDXREG(SISSR,0x3b,myflag); 2433 myflag = SiS_GetReg(SISSR, 0x3b);
2429 if(!(myflag & 0x01)) vga2 = vga2_c = 0; 2434 if(!(myflag & 0x01)) vga2 = vga2_c = 0;
2430 } 2435 }
2431 2436
@@ -2433,93 +2438,93 @@ SiS_Sense30x(struct sis_video_info *ivideo)
2433 vga2 = vga2_c = 0; 2438 vga2 = vga2_c = 0;
2434 } 2439 }
2435 2440
2436 inSISIDXREG(SISSR,0x1e,backupSR_1e); 2441 backupSR_1e = SiS_GetReg(SISSR, 0x1e);
2437 orSISIDXREG(SISSR,0x1e,0x20); 2442 SiS_SetRegOR(SISSR, 0x1e, 0x20);
2438 2443
2439 inSISIDXREG(SISPART4,0x0d,backupP4_0d); 2444 backupP4_0d = SiS_GetReg(SISPART4, 0x0d);
2440 if(ivideo->vbflags2 & VB2_30xC) { 2445 if(ivideo->vbflags2 & VB2_30xC) {
2441 setSISIDXREG(SISPART4,0x0d,~0x07,0x01); 2446 SiS_SetRegANDOR(SISPART4, 0x0d, ~0x07, 0x01);
2442 } else { 2447 } else {
2443 orSISIDXREG(SISPART4,0x0d,0x04); 2448 SiS_SetRegOR(SISPART4, 0x0d, 0x04);
2444 } 2449 }
2445 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x2000); 2450 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x2000);
2446 2451
2447 inSISIDXREG(SISPART2,0x00,backupP2_00); 2452 backupP2_00 = SiS_GetReg(SISPART2, 0x00);
2448 outSISIDXREG(SISPART2,0x00,((backupP2_00 | 0x1c) & 0xfc)); 2453 SiS_SetReg(SISPART2, 0x00, ((backupP2_00 | 0x1c) & 0xfc));
2449 2454
2450 inSISIDXREG(SISPART2,0x4d,backupP2_4d); 2455 backupP2_4d = SiS_GetReg(SISPART2, 0x4d);
2451 if(ivideo->vbflags2 & VB2_SISYPBPRBRIDGE) { 2456 if(ivideo->vbflags2 & VB2_SISYPBPRBRIDGE) {
2452 outSISIDXREG(SISPART2,0x4d,(backupP2_4d & ~0x10)); 2457 SiS_SetReg(SISPART2, 0x4d, (backupP2_4d & ~0x10));
2453 } 2458 }
2454 2459
2455 if(!(ivideo->vbflags2 & VB2_30xCLV)) { 2460 if(!(ivideo->vbflags2 & VB2_30xCLV)) {
2456 SISDoSense(ivideo, 0, 0); 2461 SISDoSense(ivideo, 0, 0);
2457 } 2462 }
2458 2463
2459 andSISIDXREG(SISCR, 0x32, ~0x14); 2464 SiS_SetRegAND(SISCR, 0x32, ~0x14);
2460 2465
2461 if(vga2_c || vga2) { 2466 if(vga2_c || vga2) {
2462 if(SISDoSense(ivideo, vga2, vga2_c)) { 2467 if(SISDoSense(ivideo, vga2, vga2_c)) {
2463 if(biosflag & 0x01) { 2468 if(biosflag & 0x01) {
2464 printk(KERN_INFO "%s %s SCART output\n", stdstr, tvstr); 2469 printk(KERN_INFO "%s %s SCART output\n", stdstr, tvstr);
2465 orSISIDXREG(SISCR, 0x32, 0x04); 2470 SiS_SetRegOR(SISCR, 0x32, 0x04);
2466 } else { 2471 } else {
2467 printk(KERN_INFO "%s secondary VGA connection\n", stdstr); 2472 printk(KERN_INFO "%s secondary VGA connection\n", stdstr);
2468 orSISIDXREG(SISCR, 0x32, 0x10); 2473 SiS_SetRegOR(SISCR, 0x32, 0x10);
2469 } 2474 }
2470 } 2475 }
2471 } 2476 }
2472 2477
2473 andSISIDXREG(SISCR, 0x32, 0x3f); 2478 SiS_SetRegAND(SISCR, 0x32, 0x3f);
2474 2479
2475 if(ivideo->vbflags2 & VB2_30xCLV) { 2480 if(ivideo->vbflags2 & VB2_30xCLV) {
2476 orSISIDXREG(SISPART4,0x0d,0x04); 2481 SiS_SetRegOR(SISPART4, 0x0d, 0x04);
2477 } 2482 }
2478 2483
2479 if((ivideo->sisvga_engine == SIS_315_VGA) && (ivideo->vbflags2 & VB2_SISYPBPRBRIDGE)) { 2484 if((ivideo->sisvga_engine == SIS_315_VGA) && (ivideo->vbflags2 & VB2_SISYPBPRBRIDGE)) {
2480 outSISIDXREG(SISPART2,0x4d,(backupP2_4d | 0x10)); 2485 SiS_SetReg(SISPART2, 0x4d, (backupP2_4d | 0x10));
2481 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x2000); 2486 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x2000);
2482 if((result = SISDoSense(ivideo, svhs, 0x0604))) { 2487 if((result = SISDoSense(ivideo, svhs, 0x0604))) {
2483 if((result = SISDoSense(ivideo, cvbs, 0x0804))) { 2488 if((result = SISDoSense(ivideo, cvbs, 0x0804))) {
2484 printk(KERN_INFO "%s %s YPbPr component output\n", stdstr, tvstr); 2489 printk(KERN_INFO "%s %s YPbPr component output\n", stdstr, tvstr);
2485 orSISIDXREG(SISCR,0x32,0x80); 2490 SiS_SetRegOR(SISCR, 0x32, 0x80);
2486 } 2491 }
2487 } 2492 }
2488 outSISIDXREG(SISPART2,0x4d,backupP2_4d); 2493 SiS_SetReg(SISPART2, 0x4d, backupP2_4d);
2489 } 2494 }
2490 2495
2491 andSISIDXREG(SISCR, 0x32, ~0x03); 2496 SiS_SetRegAND(SISCR, 0x32, ~0x03);
2492 2497
2493 if(!(ivideo->vbflags & TV_YPBPR)) { 2498 if(!(ivideo->vbflags & TV_YPBPR)) {
2494 if((result = SISDoSense(ivideo, svhs, svhs_c))) { 2499 if((result = SISDoSense(ivideo, svhs, svhs_c))) {
2495 printk(KERN_INFO "%s %s SVIDEO output\n", stdstr, tvstr); 2500 printk(KERN_INFO "%s %s SVIDEO output\n", stdstr, tvstr);
2496 orSISIDXREG(SISCR, 0x32, 0x02); 2501 SiS_SetRegOR(SISCR, 0x32, 0x02);
2497 } 2502 }
2498 if((biosflag & 0x02) || (!result)) { 2503 if((biosflag & 0x02) || (!result)) {
2499 if(SISDoSense(ivideo, cvbs, cvbs_c)) { 2504 if(SISDoSense(ivideo, cvbs, cvbs_c)) {
2500 printk(KERN_INFO "%s %s COMPOSITE output\n", stdstr, tvstr); 2505 printk(KERN_INFO "%s %s COMPOSITE output\n", stdstr, tvstr);
2501 orSISIDXREG(SISCR, 0x32, 0x01); 2506 SiS_SetRegOR(SISCR, 0x32, 0x01);
2502 } 2507 }
2503 } 2508 }
2504 } 2509 }
2505 2510
2506 SISDoSense(ivideo, 0, 0); 2511 SISDoSense(ivideo, 0, 0);
2507 2512
2508 outSISIDXREG(SISPART2,0x00,backupP2_00); 2513 SiS_SetReg(SISPART2, 0x00, backupP2_00);
2509 outSISIDXREG(SISPART4,0x0d,backupP4_0d); 2514 SiS_SetReg(SISPART4, 0x0d, backupP4_0d);
2510 outSISIDXREG(SISSR,0x1e,backupSR_1e); 2515 SiS_SetReg(SISSR, 0x1e, backupSR_1e);
2511 2516
2512 if(ivideo->vbflags2 & VB2_30xCLV) { 2517 if(ivideo->vbflags2 & VB2_30xCLV) {
2513 inSISIDXREG(SISPART2,0x00,biosflag); 2518 biosflag = SiS_GetReg(SISPART2, 0x00);
2514 if(biosflag & 0x20) { 2519 if(biosflag & 0x20) {
2515 for(myflag = 2; myflag > 0; myflag--) { 2520 for(myflag = 2; myflag > 0; myflag--) {
2516 biosflag ^= 0x20; 2521 biosflag ^= 0x20;
2517 outSISIDXREG(SISPART2,0x00,biosflag); 2522 SiS_SetReg(SISPART2, 0x00, biosflag);
2518 } 2523 }
2519 } 2524 }
2520 } 2525 }
2521 2526
2522 outSISIDXREG(SISPART2,0x00,backupP2_00); 2527 SiS_SetReg(SISPART2, 0x00, backupP2_00);
2523} 2528}
2524 2529
2525/* Determine and detect attached TV's on Chrontel */ 2530/* Determine and detect attached TV's on Chrontel */
@@ -2583,20 +2588,20 @@ SiS_SenseCh(struct sis_video_info *ivideo)
2583 if(temp1 == 0x02) { 2588 if(temp1 == 0x02) {
2584 printk(KERN_INFO "%s SVIDEO output\n", stdstr); 2589 printk(KERN_INFO "%s SVIDEO output\n", stdstr);
2585 ivideo->vbflags |= TV_SVIDEO; 2590 ivideo->vbflags |= TV_SVIDEO;
2586 orSISIDXREG(SISCR, 0x32, 0x02); 2591 SiS_SetRegOR(SISCR, 0x32, 0x02);
2587 andSISIDXREG(SISCR, 0x32, ~0x05); 2592 SiS_SetRegAND(SISCR, 0x32, ~0x05);
2588 } else if (temp1 == 0x01) { 2593 } else if (temp1 == 0x01) {
2589 printk(KERN_INFO "%s CVBS output\n", stdstr); 2594 printk(KERN_INFO "%s CVBS output\n", stdstr);
2590 ivideo->vbflags |= TV_AVIDEO; 2595 ivideo->vbflags |= TV_AVIDEO;
2591 orSISIDXREG(SISCR, 0x32, 0x01); 2596 SiS_SetRegOR(SISCR, 0x32, 0x01);
2592 andSISIDXREG(SISCR, 0x32, ~0x06); 2597 SiS_SetRegAND(SISCR, 0x32, ~0x06);
2593 } else { 2598 } else {
2594 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x0e, 0x01, 0xF8); 2599 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x0e, 0x01, 0xF8);
2595 andSISIDXREG(SISCR, 0x32, ~0x07); 2600 SiS_SetRegAND(SISCR, 0x32, ~0x07);
2596 } 2601 }
2597 } else if(temp1 == 0) { 2602 } else if(temp1 == 0) {
2598 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x0e, 0x01, 0xF8); 2603 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x0e, 0x01, 0xF8);
2599 andSISIDXREG(SISCR, 0x32, ~0x07); 2604 SiS_SetRegAND(SISCR, 0x32, ~0x07);
2600 } 2605 }
2601 /* Set general purpose IO for Chrontel communication */ 2606 /* Set general purpose IO for Chrontel communication */
2602 SiS_SetChrontelGPIO(&ivideo->SiS_Pr, 0x00); 2607 SiS_SetChrontelGPIO(&ivideo->SiS_Pr, 0x00);
@@ -2627,22 +2632,22 @@ SiS_SenseCh(struct sis_video_info *ivideo)
2627 case 0x01: 2632 case 0x01:
2628 printk(KERN_INFO "%s CVBS output\n", stdstr); 2633 printk(KERN_INFO "%s CVBS output\n", stdstr);
2629 ivideo->vbflags |= TV_AVIDEO; 2634 ivideo->vbflags |= TV_AVIDEO;
2630 orSISIDXREG(SISCR, 0x32, 0x01); 2635 SiS_SetRegOR(SISCR, 0x32, 0x01);
2631 andSISIDXREG(SISCR, 0x32, ~0x06); 2636 SiS_SetRegAND(SISCR, 0x32, ~0x06);
2632 break; 2637 break;
2633 case 0x02: 2638 case 0x02:
2634 printk(KERN_INFO "%s SVIDEO output\n", stdstr); 2639 printk(KERN_INFO "%s SVIDEO output\n", stdstr);
2635 ivideo->vbflags |= TV_SVIDEO; 2640 ivideo->vbflags |= TV_SVIDEO;
2636 orSISIDXREG(SISCR, 0x32, 0x02); 2641 SiS_SetRegOR(SISCR, 0x32, 0x02);
2637 andSISIDXREG(SISCR, 0x32, ~0x05); 2642 SiS_SetRegAND(SISCR, 0x32, ~0x05);
2638 break; 2643 break;
2639 case 0x04: 2644 case 0x04:
2640 printk(KERN_INFO "%s SCART output\n", stdstr); 2645 printk(KERN_INFO "%s SCART output\n", stdstr);
2641 orSISIDXREG(SISCR, 0x32, 0x04); 2646 SiS_SetRegOR(SISCR, 0x32, 0x04);
2642 andSISIDXREG(SISCR, 0x32, ~0x03); 2647 SiS_SetRegAND(SISCR, 0x32, ~0x03);
2643 break; 2648 break;
2644 default: 2649 default:
2645 andSISIDXREG(SISCR, 0x32, ~0x07); 2650 SiS_SetRegAND(SISCR, 0x32, ~0x07);
2646 } 2651 }
2647#endif 2652#endif
2648 } 2653 }
@@ -2660,10 +2665,10 @@ sisfb_get_VB_type(struct sis_video_info *ivideo)
2660 if(ivideo->chip == XGI_20) 2665 if(ivideo->chip == XGI_20)
2661 return; 2666 return;
2662 2667
2663 inSISIDXREG(SISPART4, 0x00, vb_chipid); 2668 vb_chipid = SiS_GetReg(SISPART4, 0x00);
2664 switch(vb_chipid) { 2669 switch(vb_chipid) {
2665 case 0x01: 2670 case 0x01:
2666 inSISIDXREG(SISPART4, 0x01, reg); 2671 reg = SiS_GetReg(SISPART4, 0x01);
2667 if(reg < 0xb0) { 2672 if(reg < 0xb0) {
2668 ivideo->vbflags |= VB_301; /* Deprecated */ 2673 ivideo->vbflags |= VB_301; /* Deprecated */
2669 ivideo->vbflags2 |= VB2_301; 2674 ivideo->vbflags2 |= VB2_301;
@@ -2671,7 +2676,7 @@ sisfb_get_VB_type(struct sis_video_info *ivideo)
2671 } else if(reg < 0xc0) { 2676 } else if(reg < 0xc0) {
2672 ivideo->vbflags |= VB_301B; /* Deprecated */ 2677 ivideo->vbflags |= VB_301B; /* Deprecated */
2673 ivideo->vbflags2 |= VB2_301B; 2678 ivideo->vbflags2 |= VB2_301B;
2674 inSISIDXREG(SISPART4,0x23,reg); 2679 reg = SiS_GetReg(SISPART4, 0x23);
2675 if(!(reg & 0x02)) { 2680 if(!(reg & 0x02)) {
2676 ivideo->vbflags |= VB_30xBDH; /* Deprecated */ 2681 ivideo->vbflags |= VB_30xBDH; /* Deprecated */
2677 ivideo->vbflags2 |= VB2_30xBDH; 2682 ivideo->vbflags2 |= VB2_30xBDH;
@@ -2688,7 +2693,7 @@ sisfb_get_VB_type(struct sis_video_info *ivideo)
2688 ivideo->vbflags2 |= VB2_301LV; 2693 ivideo->vbflags2 |= VB2_301LV;
2689 printk(KERN_INFO "%s SiS301LV %s\n", stdstr, bridgestr); 2694 printk(KERN_INFO "%s SiS301LV %s\n", stdstr, bridgestr);
2690 } else if(reg <= 0xe1) { 2695 } else if(reg <= 0xe1) {
2691 inSISIDXREG(SISPART4,0x39,reg); 2696 reg = SiS_GetReg(SISPART4, 0x39);
2692 if(reg == 0xff) { 2697 if(reg == 0xff) {
2693 ivideo->vbflags |= VB_302LV; /* Deprecated */ 2698 ivideo->vbflags |= VB_302LV; /* Deprecated */
2694 ivideo->vbflags2 |= VB2_302LV; 2699 ivideo->vbflags2 |= VB2_302LV;
@@ -2713,7 +2718,7 @@ sisfb_get_VB_type(struct sis_video_info *ivideo)
2713 } 2718 }
2714 2719
2715 if((!(ivideo->vbflags2 & VB2_VIDEOBRIDGE)) && (ivideo->chip != SIS_300)) { 2720 if((!(ivideo->vbflags2 & VB2_VIDEOBRIDGE)) && (ivideo->chip != SIS_300)) {
2716 inSISIDXREG(SISCR, 0x37, reg); 2721 reg = SiS_GetReg(SISCR, 0x37);
2717 reg &= SIS_EXTERNAL_CHIP_MASK; 2722 reg &= SIS_EXTERNAL_CHIP_MASK;
2718 reg >>= 1; 2723 reg >>= 1;
2719 if(ivideo->sisvga_engine == SIS_300_VGA) { 2724 if(ivideo->sisvga_engine == SIS_300_VGA) {
@@ -2754,7 +2759,7 @@ sisfb_get_VB_type(struct sis_video_info *ivideo)
2754#endif 2759#endif
2755 } else if(ivideo->chip >= SIS_661) { 2760 } else if(ivideo->chip >= SIS_661) {
2756#ifdef CONFIG_FB_SIS_315 2761#ifdef CONFIG_FB_SIS_315
2757 inSISIDXREG(SISCR, 0x38, reg); 2762 reg = SiS_GetReg(SISCR, 0x38);
2758 reg >>= 5; 2763 reg >>= 5;
2759 switch(reg) { 2764 switch(reg) {
2760 case 0x02: 2765 case 0x02:
@@ -2817,13 +2822,13 @@ sisfb_engine_init(struct sis_video_info *ivideo)
2817 2822
2818 tqueue_pos = (ivideo->video_size - ivideo->cmdQueueSize) / (64 * 1024); 2823 tqueue_pos = (ivideo->video_size - ivideo->cmdQueueSize) / (64 * 1024);
2819 2824
2820 inSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_SET, tq_state); 2825 tq_state = SiS_GetReg(SISSR, IND_SIS_TURBOQUEUE_SET);
2821 tq_state |= 0xf0; 2826 tq_state |= 0xf0;
2822 tq_state &= 0xfc; 2827 tq_state &= 0xfc;
2823 tq_state |= (u8)(tqueue_pos >> 8); 2828 tq_state |= (u8)(tqueue_pos >> 8);
2824 outSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_SET, tq_state); 2829 SiS_SetReg(SISSR, IND_SIS_TURBOQUEUE_SET, tq_state);
2825 2830
2826 outSISIDXREG(SISSR, IND_SIS_TURBOQUEUE_ADR, (u8)(tqueue_pos & 0xff)); 2831 SiS_SetReg(SISSR, IND_SIS_TURBOQUEUE_ADR, (u8)(tqueue_pos & 0xff));
2827 2832
2828 ivideo->caps |= TURBO_QUEUE_CAP; 2833 ivideo->caps |= TURBO_QUEUE_CAP;
2829 } 2834 }
@@ -2860,8 +2865,8 @@ sisfb_engine_init(struct sis_video_info *ivideo)
2860 } 2865 }
2861 } 2866 }
2862 2867
2863 outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_THRESHOLD, COMMAND_QUEUE_THRESHOLD); 2868 SiS_SetReg(SISSR, IND_SIS_CMDQUEUE_THRESHOLD, COMMAND_QUEUE_THRESHOLD);
2864 outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, SIS_CMD_QUEUE_RESET); 2869 SiS_SetReg(SISSR, IND_SIS_CMDQUEUE_SET, SIS_CMD_QUEUE_RESET);
2865 2870
2866 if((ivideo->chip >= XGI_40) && ivideo->modechanged) { 2871 if((ivideo->chip >= XGI_40) && ivideo->modechanged) {
2867 /* Must disable dual pipe on XGI_40. Can't do 2872 /* Must disable dual pipe on XGI_40. Can't do
@@ -2873,7 +2878,7 @@ sisfb_engine_init(struct sis_video_info *ivideo)
2873 2878
2874 MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, 0); 2879 MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, 0);
2875 2880
2876 outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, (temp | SIS_VRAM_CMDQUEUE_ENABLE)); 2881 SiS_SetReg(SISSR, IND_SIS_CMDQUEUE_SET, (temp | SIS_VRAM_CMDQUEUE_ENABLE));
2877 2882
2878 tempq = MMIO_IN32(ivideo->mmio_vbase, Q_READ_PTR); 2883 tempq = MMIO_IN32(ivideo->mmio_vbase, Q_READ_PTR);
2879 MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, tempq); 2884 MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, tempq);
@@ -2890,7 +2895,7 @@ sisfb_engine_init(struct sis_video_info *ivideo)
2890 2895
2891 sisfb_syncaccel(ivideo); 2896 sisfb_syncaccel(ivideo);
2892 2897
2893 outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, SIS_CMD_QUEUE_RESET); 2898 SiS_SetReg(SISSR, IND_SIS_CMDQUEUE_SET, SIS_CMD_QUEUE_RESET);
2894 2899
2895 } 2900 }
2896 } 2901 }
@@ -2899,7 +2904,7 @@ sisfb_engine_init(struct sis_video_info *ivideo)
2899 MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_WRITEPORT, tempq); 2904 MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_WRITEPORT, tempq);
2900 2905
2901 temp |= (SIS_MMIO_CMD_ENABLE | SIS_CMD_AUTO_CORR); 2906 temp |= (SIS_MMIO_CMD_ENABLE | SIS_CMD_AUTO_CORR);
2902 outSISIDXREG(SISSR, IND_SIS_CMDQUEUE_SET, temp); 2907 SiS_SetReg(SISSR, IND_SIS_CMDQUEUE_SET, temp);
2903 2908
2904 tempq = (u32)(ivideo->video_size - ivideo->cmdQueueSize); 2909 tempq = (u32)(ivideo->video_size - ivideo->cmdQueueSize);
2905 MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_PHYBASE, tempq); 2910 MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_PHYBASE, tempq);
@@ -2917,7 +2922,7 @@ sisfb_detect_lcd_type(struct sis_video_info *ivideo)
2917 u8 reg; 2922 u8 reg;
2918 int i; 2923 int i;
2919 2924
2920 inSISIDXREG(SISCR, 0x36, reg); 2925 reg = SiS_GetReg(SISCR, 0x36);
2921 reg &= 0x0f; 2926 reg &= 0x0f;
2922 if(ivideo->sisvga_engine == SIS_300_VGA) { 2927 if(ivideo->sisvga_engine == SIS_300_VGA) {
2923 ivideo->CRT2LCDType = sis300paneltype[reg]; 2928 ivideo->CRT2LCDType = sis300paneltype[reg];
@@ -2936,8 +2941,8 @@ sisfb_detect_lcd_type(struct sis_video_info *ivideo)
2936 if(ivideo->CRT2LCDType == LCD_UNKNOWN) { 2941 if(ivideo->CRT2LCDType == LCD_UNKNOWN) {
2937 /* For broken BIOSes: Assume 1024x768, RGB18 */ 2942 /* For broken BIOSes: Assume 1024x768, RGB18 */
2938 ivideo->CRT2LCDType = LCD_1024x768; 2943 ivideo->CRT2LCDType = LCD_1024x768;
2939 setSISIDXREG(SISCR,0x36,0xf0,0x02); 2944 SiS_SetRegANDOR(SISCR, 0x36, 0xf0, 0x02);
2940 setSISIDXREG(SISCR,0x37,0xee,0x01); 2945 SiS_SetRegANDOR(SISCR, 0x37, 0xee, 0x01);
2941 printk(KERN_DEBUG "sisfb: Invalid panel ID (%02x), assuming 1024x768, RGB18\n", reg); 2946 printk(KERN_DEBUG "sisfb: Invalid panel ID (%02x), assuming 1024x768, RGB18\n", reg);
2942 } 2947 }
2943 2948
@@ -2975,10 +2980,10 @@ sisfb_save_pdc_emi(struct sis_video_info *ivideo)
2975 if(ivideo->sisvga_engine == SIS_300_VGA) { 2980 if(ivideo->sisvga_engine == SIS_300_VGA) {
2976 if(ivideo->vbflags2 & (VB2_LVDS | VB2_30xBDH)) { 2981 if(ivideo->vbflags2 & (VB2_LVDS | VB2_30xBDH)) {
2977 int tmp; 2982 int tmp;
2978 inSISIDXREG(SISCR,0x30,tmp); 2983 tmp = SiS_GetReg(SISCR, 0x30);
2979 if(tmp & 0x20) { 2984 if(tmp & 0x20) {
2980 /* Currently on LCD? If yes, read current pdc */ 2985 /* Currently on LCD? If yes, read current pdc */
2981 inSISIDXREG(SISPART1,0x13,ivideo->detectedpdc); 2986 ivideo->detectedpdc = SiS_GetReg(SISPART1, 0x13);
2982 ivideo->detectedpdc &= 0x3c; 2987 ivideo->detectedpdc &= 0x3c;
2983 if(ivideo->SiS_Pr.PDC == -1) { 2988 if(ivideo->SiS_Pr.PDC == -1) {
2984 /* Let option override detection */ 2989 /* Let option override detection */
@@ -3002,7 +3007,7 @@ sisfb_save_pdc_emi(struct sis_video_info *ivideo)
3002 /* Try to find about LCDA */ 3007 /* Try to find about LCDA */
3003 if(ivideo->vbflags2 & VB2_SISLCDABRIDGE) { 3008 if(ivideo->vbflags2 & VB2_SISLCDABRIDGE) {
3004 int tmp; 3009 int tmp;
3005 inSISIDXREG(SISPART1,0x13,tmp); 3010 tmp = SiS_GetReg(SISPART1, 0x13);
3006 if(tmp & 0x04) { 3011 if(tmp & 0x04) {
3007 ivideo->SiS_Pr.SiS_UseLCDA = true; 3012 ivideo->SiS_Pr.SiS_UseLCDA = true;
3008 ivideo->detectedlcda = 0x03; 3013 ivideo->detectedlcda = 0x03;
@@ -3012,16 +3017,16 @@ sisfb_save_pdc_emi(struct sis_video_info *ivideo)
3012 /* Save PDC */ 3017 /* Save PDC */
3013 if(ivideo->vbflags2 & VB2_SISLVDSBRIDGE) { 3018 if(ivideo->vbflags2 & VB2_SISLVDSBRIDGE) {
3014 int tmp; 3019 int tmp;
3015 inSISIDXREG(SISCR,0x30,tmp); 3020 tmp = SiS_GetReg(SISCR, 0x30);
3016 if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) { 3021 if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) {
3017 /* Currently on LCD? If yes, read current pdc */ 3022 /* Currently on LCD? If yes, read current pdc */
3018 u8 pdc; 3023 u8 pdc;
3019 inSISIDXREG(SISPART1,0x2D,pdc); 3024 pdc = SiS_GetReg(SISPART1, 0x2D);
3020 ivideo->detectedpdc = (pdc & 0x0f) << 1; 3025 ivideo->detectedpdc = (pdc & 0x0f) << 1;
3021 ivideo->detectedpdca = (pdc & 0xf0) >> 3; 3026 ivideo->detectedpdca = (pdc & 0xf0) >> 3;
3022 inSISIDXREG(SISPART1,0x35,pdc); 3027 pdc = SiS_GetReg(SISPART1, 0x35);
3023 ivideo->detectedpdc |= ((pdc >> 7) & 0x01); 3028 ivideo->detectedpdc |= ((pdc >> 7) & 0x01);
3024 inSISIDXREG(SISPART1,0x20,pdc); 3029 pdc = SiS_GetReg(SISPART1, 0x20);
3025 ivideo->detectedpdca |= ((pdc >> 6) & 0x01); 3030 ivideo->detectedpdca |= ((pdc >> 6) & 0x01);
3026 if(ivideo->newrom) { 3031 if(ivideo->newrom) {
3027 /* New ROM invalidates other PDC resp. */ 3032 /* New ROM invalidates other PDC resp. */
@@ -3055,10 +3060,10 @@ sisfb_save_pdc_emi(struct sis_video_info *ivideo)
3055 3060
3056 /* Save EMI */ 3061 /* Save EMI */
3057 if(ivideo->vbflags2 & VB2_SISEMIBRIDGE) { 3062 if(ivideo->vbflags2 & VB2_SISEMIBRIDGE) {
3058 inSISIDXREG(SISPART4,0x30,ivideo->SiS_Pr.EMI_30); 3063 ivideo->SiS_Pr.EMI_30 = SiS_GetReg(SISPART4, 0x30);
3059 inSISIDXREG(SISPART4,0x31,ivideo->SiS_Pr.EMI_31); 3064 ivideo->SiS_Pr.EMI_31 = SiS_GetReg(SISPART4, 0x31);
3060 inSISIDXREG(SISPART4,0x32,ivideo->SiS_Pr.EMI_32); 3065 ivideo->SiS_Pr.EMI_32 = SiS_GetReg(SISPART4, 0x32);
3061 inSISIDXREG(SISPART4,0x33,ivideo->SiS_Pr.EMI_33); 3066 ivideo->SiS_Pr.EMI_33 = SiS_GetReg(SISPART4, 0x33);
3062 ivideo->SiS_Pr.HaveEMI = true; 3067 ivideo->SiS_Pr.HaveEMI = true;
3063 if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) { 3068 if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) {
3064 ivideo->SiS_Pr.HaveEMILCD = true; 3069 ivideo->SiS_Pr.HaveEMILCD = true;
@@ -3483,8 +3488,8 @@ sisfb_check_engine_and_sync(struct sis_video_info *ivideo)
3483 * ivideo->accel here, as this might have 3488 * ivideo->accel here, as this might have
3484 * been changed before this is called. 3489 * been changed before this is called.
3485 */ 3490 */
3486 inSISIDXREG(SISSR, IND_SIS_PCI_ADDRESS_SET, cr30); 3491 cr30 = SiS_GetReg(SISSR, IND_SIS_PCI_ADDRESS_SET);
3487 inSISIDXREG(SISSR, IND_SIS_MODULE_ENABLE, cr31); 3492 cr31 = SiS_GetReg(SISSR, IND_SIS_MODULE_ENABLE);
3488 /* MMIO and 2D/3D engine enabled? */ 3493 /* MMIO and 2D/3D engine enabled? */
3489 if((cr30 & SIS_MEM_MAP_IO_ENABLE) && (cr31 & 0x42)) { 3494 if((cr30 & SIS_MEM_MAP_IO_ENABLE) && (cr31 & 0x42)) {
3490#ifdef CONFIG_FB_SIS_300 3495#ifdef CONFIG_FB_SIS_300
@@ -3502,7 +3507,7 @@ sisfb_check_engine_and_sync(struct sis_video_info *ivideo)
3502 * enabled, and that the queue 3507 * enabled, and that the queue
3503 * is not in the state of "reset" 3508 * is not in the state of "reset"
3504 */ 3509 */
3505 inSISIDXREG(SISSR, 0x26, cr30); 3510 cr30 = SiS_GetReg(SISSR, 0x26);
3506 if((cr30 & 0xe0) && (!(cr30 & 0x01))) { 3511 if((cr30 & 0xe0) && (!(cr30 & 0x01))) {
3507 sisfb_syncaccel(ivideo); 3512 sisfb_syncaccel(ivideo);
3508 } 3513 }
@@ -3519,9 +3524,9 @@ sisfb_pre_setmode(struct sis_video_info *ivideo)
3519 3524
3520 ivideo->currentvbflags &= (VB_VIDEOBRIDGE | VB_DISPTYPE_DISP2); 3525 ivideo->currentvbflags &= (VB_VIDEOBRIDGE | VB_DISPTYPE_DISP2);
3521 3526
3522 outSISIDXREG(SISSR, 0x05, 0x86); 3527 SiS_SetReg(SISSR, 0x05, 0x86);
3523 3528
3524 inSISIDXREG(SISCR, 0x31, cr31); 3529 cr31 = SiS_GetReg(SISCR, 0x31);
3525 cr31 &= ~0x60; 3530 cr31 &= ~0x60;
3526 cr31 |= 0x04; 3531 cr31 |= 0x04;
3527 3532
@@ -3530,11 +3535,11 @@ sisfb_pre_setmode(struct sis_video_info *ivideo)
3530#ifdef CONFIG_FB_SIS_315 3535#ifdef CONFIG_FB_SIS_315
3531 if(ivideo->sisvga_engine == SIS_315_VGA) { 3536 if(ivideo->sisvga_engine == SIS_315_VGA) {
3532 if(ivideo->chip >= SIS_661) { 3537 if(ivideo->chip >= SIS_661) {
3533 inSISIDXREG(SISCR, 0x38, cr38); 3538 cr38 = SiS_GetReg(SISCR, 0x38);
3534 cr38 &= ~0x07; /* Clear LCDA/DualEdge and YPbPr bits */ 3539 cr38 &= ~0x07; /* Clear LCDA/DualEdge and YPbPr bits */
3535 } else { 3540 } else {
3536 tvregnum = 0x38; 3541 tvregnum = 0x38;
3537 inSISIDXREG(SISCR, tvregnum, cr38); 3542 cr38 = SiS_GetReg(SISCR, tvregnum);
3538 cr38 &= ~0x3b; /* Clear LCDA/DualEdge and YPbPr bits */ 3543 cr38 &= ~0x3b; /* Clear LCDA/DualEdge and YPbPr bits */
3539 } 3544 }
3540 } 3545 }
@@ -3542,7 +3547,7 @@ sisfb_pre_setmode(struct sis_video_info *ivideo)
3542#ifdef CONFIG_FB_SIS_300 3547#ifdef CONFIG_FB_SIS_300
3543 if(ivideo->sisvga_engine == SIS_300_VGA) { 3548 if(ivideo->sisvga_engine == SIS_300_VGA) {
3544 tvregnum = 0x35; 3549 tvregnum = 0x35;
3545 inSISIDXREG(SISCR, tvregnum, cr38); 3550 cr38 = SiS_GetReg(SISCR, tvregnum);
3546 } 3551 }
3547#endif 3552#endif
3548 3553
@@ -3649,20 +3654,20 @@ sisfb_pre_setmode(struct sis_video_info *ivideo)
3649 cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE); 3654 cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE);
3650 } 3655 }
3651 3656
3652 outSISIDXREG(SISCR, 0x30, cr30); 3657 SiS_SetReg(SISCR, 0x30, cr30);
3653 outSISIDXREG(SISCR, 0x33, cr33); 3658 SiS_SetReg(SISCR, 0x33, cr33);
3654 3659
3655 if(ivideo->chip >= SIS_661) { 3660 if(ivideo->chip >= SIS_661) {
3656#ifdef CONFIG_FB_SIS_315 3661#ifdef CONFIG_FB_SIS_315
3657 cr31 &= ~0x01; /* Clear PAL flag (now in CR35) */ 3662 cr31 &= ~0x01; /* Clear PAL flag (now in CR35) */
3658 setSISIDXREG(SISCR, 0x35, ~0x10, cr35); /* Leave overscan bit alone */ 3663 SiS_SetRegANDOR(SISCR, 0x35, ~0x10, cr35); /* Leave overscan bit alone */
3659 cr38 &= 0x07; /* Use only LCDA and HiVision/YPbPr bits */ 3664 cr38 &= 0x07; /* Use only LCDA and HiVision/YPbPr bits */
3660 setSISIDXREG(SISCR, 0x38, 0xf8, cr38); 3665 SiS_SetRegANDOR(SISCR, 0x38, 0xf8, cr38);
3661#endif 3666#endif
3662 } else if(ivideo->chip != SIS_300) { 3667 } else if(ivideo->chip != SIS_300) {
3663 outSISIDXREG(SISCR, tvregnum, cr38); 3668 SiS_SetReg(SISCR, tvregnum, cr38);
3664 } 3669 }
3665 outSISIDXREG(SISCR, 0x31, cr31); 3670 SiS_SetReg(SISCR, 0x31, cr31);
3666 3671
3667 ivideo->SiS_Pr.SiS_UseOEM = ivideo->sisfb_useoem; 3672 ivideo->SiS_Pr.SiS_UseOEM = ivideo->sisfb_useoem;
3668 3673
@@ -3677,15 +3682,15 @@ sisfb_fixup_SR11(struct sis_video_info *ivideo)
3677 u8 tmpreg; 3682 u8 tmpreg;
3678 3683
3679 if(ivideo->chip >= SIS_661) { 3684 if(ivideo->chip >= SIS_661) {
3680 inSISIDXREG(SISSR,0x11,tmpreg); 3685 tmpreg = SiS_GetReg(SISSR, 0x11);
3681 if(tmpreg & 0x20) { 3686 if(tmpreg & 0x20) {
3682 inSISIDXREG(SISSR,0x3e,tmpreg); 3687 tmpreg = SiS_GetReg(SISSR, 0x3e);
3683 tmpreg = (tmpreg + 1) & 0xff; 3688 tmpreg = (tmpreg + 1) & 0xff;
3684 outSISIDXREG(SISSR,0x3e,tmpreg); 3689 SiS_SetReg(SISSR, 0x3e, tmpreg);
3685 inSISIDXREG(SISSR,0x11,tmpreg); 3690 tmpreg = SiS_GetReg(SISSR, 0x11);
3686 } 3691 }
3687 if(tmpreg & 0xf0) { 3692 if(tmpreg & 0xf0) {
3688 andSISIDXREG(SISSR,0x11,0x0f); 3693 SiS_SetRegAND(SISSR, 0x11, 0x0f);
3689 } 3694 }
3690 } 3695 }
3691} 3696}
@@ -3711,7 +3716,7 @@ sisfb_set_TVxposoffset(struct sis_video_info *ivideo, int val)
3711 case 1: 3716 case 1:
3712 x += val; 3717 x += val;
3713 if(x < 0) x = 0; 3718 if(x < 0) x = 0;
3714 outSISIDXREG(SISSR,0x05,0x86); 3719 SiS_SetReg(SISSR, 0x05, 0x86);
3715 SiS_SetCH700x(&ivideo->SiS_Pr, 0x0a, (x & 0xff)); 3720 SiS_SetCH700x(&ivideo->SiS_Pr, 0x0a, (x & 0xff));
3716 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x08, ((x & 0x0100) >> 7), 0xFD); 3721 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x08, ((x & 0x0100) >> 7), 0xFD);
3717 break; 3722 break;
@@ -3740,11 +3745,11 @@ sisfb_set_TVxposoffset(struct sis_video_info *ivideo, int val)
3740 temp += (val * 2); 3745 temp += (val * 2);
3741 p2_43 = temp & 0xff; 3746 p2_43 = temp & 0xff;
3742 p2_42 = (temp & 0xf00) >> 4; 3747 p2_42 = (temp & 0xf00) >> 4;
3743 outSISIDXREG(SISPART2,0x1f,p2_1f); 3748 SiS_SetReg(SISPART2, 0x1f, p2_1f);
3744 setSISIDXREG(SISPART2,0x20,0x0F,p2_20); 3749 SiS_SetRegANDOR(SISPART2, 0x20, 0x0F, p2_20);
3745 setSISIDXREG(SISPART2,0x2b,0xF0,p2_2b); 3750 SiS_SetRegANDOR(SISPART2, 0x2b, 0xF0, p2_2b);
3746 setSISIDXREG(SISPART2,0x42,0x0F,p2_42); 3751 SiS_SetRegANDOR(SISPART2, 0x42, 0x0F, p2_42);
3747 outSISIDXREG(SISPART2,0x43,p2_43); 3752 SiS_SetReg(SISPART2, 0x43, p2_43);
3748 } 3753 }
3749 } 3754 }
3750} 3755}
@@ -3769,7 +3774,7 @@ sisfb_set_TVyposoffset(struct sis_video_info *ivideo, int val)
3769 case 1: 3774 case 1:
3770 y -= val; 3775 y -= val;
3771 if(y < 0) y = 0; 3776 if(y < 0) y = 0;
3772 outSISIDXREG(SISSR,0x05,0x86); 3777 SiS_SetReg(SISSR, 0x05, 0x86);
3773 SiS_SetCH700x(&ivideo->SiS_Pr, 0x0b, (y & 0xff)); 3778 SiS_SetCH700x(&ivideo->SiS_Pr, 0x0b, (y & 0xff));
3774 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x08, ((y & 0x0100) >> 8), 0xFE); 3779 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x08, ((y & 0x0100) >> 8), 0xFE);
3775 break; 3780 break;
@@ -3793,8 +3798,8 @@ sisfb_set_TVyposoffset(struct sis_video_info *ivideo, int val)
3793 p2_02 += 2; 3798 p2_02 += 2;
3794 } 3799 }
3795 } 3800 }
3796 outSISIDXREG(SISPART2,0x01,p2_01); 3801 SiS_SetReg(SISPART2, 0x01, p2_01);
3797 outSISIDXREG(SISPART2,0x02,p2_02); 3802 SiS_SetReg(SISPART2, 0x02, p2_02);
3798 } 3803 }
3799 } 3804 }
3800} 3805}
@@ -3811,7 +3816,7 @@ sisfb_post_setmode(struct sis_video_info *ivideo)
3811 u8 reg1; 3816 u8 reg1;
3812#endif 3817#endif
3813 3818
3814 outSISIDXREG(SISSR, 0x05, 0x86); 3819 SiS_SetReg(SISSR, 0x05, 0x86);
3815 3820
3816#ifdef CONFIG_FB_SIS_315 3821#ifdef CONFIG_FB_SIS_315
3817 sisfb_fixup_SR11(ivideo); 3822 sisfb_fixup_SR11(ivideo);
@@ -3835,7 +3840,7 @@ sisfb_post_setmode(struct sis_video_info *ivideo)
3835 crt1isoff = false; 3840 crt1isoff = false;
3836 reg = 0x80; 3841 reg = 0x80;
3837 } 3842 }
3838 setSISIDXREG(SISCR, 0x17, 0x7f, reg); 3843 SiS_SetRegANDOR(SISCR, 0x17, 0x7f, reg);
3839 } 3844 }
3840#endif 3845#endif
3841#ifdef CONFIG_FB_SIS_315 3846#ifdef CONFIG_FB_SIS_315
@@ -3849,8 +3854,8 @@ sisfb_post_setmode(struct sis_video_info *ivideo)
3849 reg = 0x00; 3854 reg = 0x00;
3850 reg1 = 0x00; 3855 reg1 = 0x00;
3851 } 3856 }
3852 setSISIDXREG(SISCR, ivideo->SiS_Pr.SiS_MyCR63, ~0x40, reg); 3857 SiS_SetRegANDOR(SISCR, ivideo->SiS_Pr.SiS_MyCR63, ~0x40, reg);
3853 setSISIDXREG(SISSR, 0x1f, ~0xc0, reg1); 3858 SiS_SetRegANDOR(SISSR, 0x1f, 0x3f, reg1);
3854 } 3859 }
3855#endif 3860#endif
3856 3861
@@ -3866,17 +3871,17 @@ sisfb_post_setmode(struct sis_video_info *ivideo)
3866 } 3871 }
3867 } 3872 }
3868 3873
3869 andSISIDXREG(SISSR, IND_SIS_RAMDAC_CONTROL, ~0x04); 3874 SiS_SetRegAND(SISSR, IND_SIS_RAMDAC_CONTROL, ~0x04);
3870 3875
3871 if(ivideo->currentvbflags & CRT2_TV) { 3876 if(ivideo->currentvbflags & CRT2_TV) {
3872 if(ivideo->vbflags2 & VB2_SISBRIDGE) { 3877 if(ivideo->vbflags2 & VB2_SISBRIDGE) {
3873 inSISIDXREG(SISPART2,0x1f,ivideo->p2_1f); 3878 ivideo->p2_1f = SiS_GetReg(SISPART2, 0x1f);
3874 inSISIDXREG(SISPART2,0x20,ivideo->p2_20); 3879 ivideo->p2_20 = SiS_GetReg(SISPART2, 0x20);
3875 inSISIDXREG(SISPART2,0x2b,ivideo->p2_2b); 3880 ivideo->p2_2b = SiS_GetReg(SISPART2, 0x2b);
3876 inSISIDXREG(SISPART2,0x42,ivideo->p2_42); 3881 ivideo->p2_42 = SiS_GetReg(SISPART2, 0x42);
3877 inSISIDXREG(SISPART2,0x43,ivideo->p2_43); 3882 ivideo->p2_43 = SiS_GetReg(SISPART2, 0x43);
3878 inSISIDXREG(SISPART2,0x01,ivideo->p2_01); 3883 ivideo->p2_01 = SiS_GetReg(SISPART2, 0x01);
3879 inSISIDXREG(SISPART2,0x02,ivideo->p2_02); 3884 ivideo->p2_02 = SiS_GetReg(SISPART2, 0x02);
3880 } else if(ivideo->vbflags2 & VB2_CHRONTEL) { 3885 } else if(ivideo->vbflags2 & VB2_CHRONTEL) {
3881 if(ivideo->chronteltype == 1) { 3886 if(ivideo->chronteltype == 1) {
3882 ivideo->tvx = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0a); 3887 ivideo->tvx = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0a);
@@ -4100,7 +4105,6 @@ sisfb_find_rom(struct pci_dev *pdev)
4100 struct sis_video_info *ivideo = pci_get_drvdata(pdev); 4105 struct sis_video_info *ivideo = pci_get_drvdata(pdev);
4101 void __iomem *rom_base; 4106 void __iomem *rom_base;
4102 unsigned char *myrombase = NULL; 4107 unsigned char *myrombase = NULL;
4103 u32 temp;
4104 size_t romsize; 4108 size_t romsize;
4105 4109
4106 /* First, try the official pci ROM functions (except 4110 /* First, try the official pci ROM functions (except
@@ -4114,14 +4118,6 @@ sisfb_find_rom(struct pci_dev *pdev)
4114 if(sisfb_check_rom(rom_base, ivideo)) { 4118 if(sisfb_check_rom(rom_base, ivideo)) {
4115 4119
4116 if((myrombase = vmalloc(65536))) { 4120 if((myrombase = vmalloc(65536))) {
4117
4118 /* Work around bug in pci/rom.c: Folks forgot to check
4119 * whether the size retrieved from the BIOS image eventually
4120 * is larger than the mapped size
4121 */
4122 if(pci_resource_len(pdev, PCI_ROM_RESOURCE) < romsize)
4123 romsize = pci_resource_len(pdev, PCI_ROM_RESOURCE);
4124
4125 memcpy_fromio(myrombase, rom_base, 4121 memcpy_fromio(myrombase, rom_base,
4126 (romsize > 65536) ? 65536 : romsize); 4122 (romsize > 65536) ? 65536 : romsize);
4127 } 4123 }
@@ -4135,43 +4131,29 @@ sisfb_find_rom(struct pci_dev *pdev)
4135 /* Otherwise do it the conventional way. */ 4131 /* Otherwise do it the conventional way. */
4136 4132
4137#if defined(__i386__) || defined(__x86_64__) 4133#if defined(__i386__) || defined(__x86_64__)
4134 {
4135 u32 temp;
4138 4136
4139 for(temp = 0x000c0000; temp < 0x000f0000; temp += 0x00001000) { 4137 for (temp = 0x000c0000; temp < 0x000f0000; temp += 0x00001000) {
4140 4138
4141 rom_base = ioremap(temp, 65536); 4139 rom_base = ioremap(temp, 65536);
4142 if(!rom_base) 4140 if (!rom_base)
4143 continue; 4141 continue;
4144 4142
4145 if(!sisfb_check_rom(rom_base, ivideo)) { 4143 if (!sisfb_check_rom(rom_base, ivideo)) {
4146 iounmap(rom_base); 4144 iounmap(rom_base);
4147 continue; 4145 continue;
4148 } 4146 }
4149
4150 if((myrombase = vmalloc(65536)))
4151 memcpy_fromio(myrombase, rom_base, 65536);
4152
4153 iounmap(rom_base);
4154 break;
4155
4156 }
4157 4147
4158#else 4148 if ((myrombase = vmalloc(65536)))
4149 memcpy_fromio(myrombase, rom_base, 65536);
4159 4150
4160 pci_read_config_dword(pdev, PCI_ROM_ADDRESS, &temp); 4151 iounmap(rom_base);
4161 pci_write_config_dword(pdev, PCI_ROM_ADDRESS, 4152 break;
4162 (ivideo->video_base & PCI_ROM_ADDRESS_MASK) | PCI_ROM_ADDRESS_ENABLE);
4163 4153
4164 rom_base = ioremap(ivideo->video_base, 65536);
4165 if(rom_base) {
4166 if(sisfb_check_rom(rom_base, ivideo)) {
4167 if((myrombase = vmalloc(65536)))
4168 memcpy_fromio(myrombase, rom_base, 65536);
4169 } 4154 }
4170 iounmap(rom_base);
4171 }
4172
4173 pci_write_config_dword(pdev, PCI_ROM_ADDRESS, temp);
4174 4155
4156 }
4175#endif 4157#endif
4176 4158
4177 return myrombase; 4159 return myrombase;
@@ -4212,10 +4194,10 @@ sisfb_post_300_buswidth(struct sis_video_info *ivideo)
4212 unsigned char reg; 4194 unsigned char reg;
4213 int i, j; 4195 int i, j;
4214 4196
4215 andSISIDXREG(SISSR, 0x15, 0xFB); 4197 SiS_SetRegAND(SISSR, 0x15, 0xFB);
4216 orSISIDXREG(SISSR, 0x15, 0x04); 4198 SiS_SetRegOR(SISSR, 0x15, 0x04);
4217 outSISIDXREG(SISSR, 0x13, 0x00); 4199 SiS_SetReg(SISSR, 0x13, 0x00);
4218 outSISIDXREG(SISSR, 0x14, 0xBF); 4200 SiS_SetReg(SISSR, 0x14, 0xBF);
4219 4201
4220 for(i = 0; i < 2; i++) { 4202 for(i = 0; i < 2; i++) {
4221 temp = 0x1234; 4203 temp = 0x1234;
@@ -4223,12 +4205,12 @@ sisfb_post_300_buswidth(struct sis_video_info *ivideo)
4223 writew(temp, FBAddress); 4205 writew(temp, FBAddress);
4224 if(readw(FBAddress) == temp) 4206 if(readw(FBAddress) == temp)
4225 break; 4207 break;
4226 orSISIDXREG(SISSR, 0x3c, 0x01); 4208 SiS_SetRegOR(SISSR, 0x3c, 0x01);
4227 inSISIDXREG(SISSR, 0x05, reg); 4209 reg = SiS_GetReg(SISSR, 0x05);
4228 inSISIDXREG(SISSR, 0x05, reg); 4210 reg = SiS_GetReg(SISSR, 0x05);
4229 andSISIDXREG(SISSR, 0x3c, 0xfe); 4211 SiS_SetRegAND(SISSR, 0x3c, 0xfe);
4230 inSISIDXREG(SISSR, 0x05, reg); 4212 reg = SiS_GetReg(SISSR, 0x05);
4231 inSISIDXREG(SISSR, 0x05, reg); 4213 reg = SiS_GetReg(SISSR, 0x05);
4232 temp++; 4214 temp++;
4233 } 4215 }
4234 } 4216 }
@@ -4238,7 +4220,7 @@ sisfb_post_300_buswidth(struct sis_video_info *ivideo)
4238 writel(0x89ABCDEFL, (FBAddress + 8)); 4220 writel(0x89ABCDEFL, (FBAddress + 8));
4239 writel(0xCDEF0123L, (FBAddress + 12)); 4221 writel(0xCDEF0123L, (FBAddress + 12));
4240 4222
4241 inSISIDXREG(SISSR, 0x3b, reg); 4223 reg = SiS_GetReg(SISSR, 0x3b);
4242 if(reg & 0x01) { 4224 if(reg & 0x01) {
4243 if(readl((FBAddress + 12)) == 0xCDEF0123L) 4225 if(readl((FBAddress + 12)) == 0xCDEF0123L)
4244 return 4; /* Channel A 128bit */ 4226 return 4; /* Channel A 128bit */
@@ -4301,13 +4283,13 @@ sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration, int buswidth
4301 PhysicalAdrHalfPage = (PageCapacity / 2 + PhysicalAdrHigh) % PageCapacity; 4283 PhysicalAdrHalfPage = (PageCapacity / 2 + PhysicalAdrHigh) % PageCapacity;
4302 PhysicalAdrOtherPage = PageCapacity * SiS_DRAMType[k][2] + PhysicalAdrHigh; 4284 PhysicalAdrOtherPage = PageCapacity * SiS_DRAMType[k][2] + PhysicalAdrHigh;
4303 4285
4304 andSISIDXREG(SISSR, 0x15, 0xFB); /* Test */ 4286 SiS_SetRegAND(SISSR, 0x15, 0xFB); /* Test */
4305 orSISIDXREG(SISSR, 0x15, 0x04); /* Test */ 4287 SiS_SetRegOR(SISSR, 0x15, 0x04); /* Test */
4306 sr14 = (SiS_DRAMType[k][3] * buswidth) - 1; 4288 sr14 = (SiS_DRAMType[k][3] * buswidth) - 1;
4307 if(buswidth == 4) sr14 |= 0x80; 4289 if(buswidth == 4) sr14 |= 0x80;
4308 else if(buswidth == 2) sr14 |= 0x40; 4290 else if(buswidth == 2) sr14 |= 0x40;
4309 outSISIDXREG(SISSR, 0x13, SiS_DRAMType[k][4]); 4291 SiS_SetReg(SISSR, 0x13, SiS_DRAMType[k][4]);
4310 outSISIDXREG(SISSR, 0x14, sr14); 4292 SiS_SetReg(SISSR, 0x14, sr14);
4311 4293
4312 BankNumHigh <<= 16; 4294 BankNumHigh <<= 16;
4313 BankNumMid <<= 16; 4295 BankNumMid <<= 16;
@@ -4374,13 +4356,13 @@ sisfb_post_sis300(struct pci_dev *pdev)
4374 if(!ivideo->SiS_Pr.UseROM) 4356 if(!ivideo->SiS_Pr.UseROM)
4375 bios = NULL; 4357 bios = NULL;
4376 4358
4377 outSISIDXREG(SISSR, 0x05, 0x86); 4359 SiS_SetReg(SISSR, 0x05, 0x86);
4378 4360
4379 if(bios) { 4361 if(bios) {
4380 if(bios[0x52] & 0x80) { 4362 if(bios[0x52] & 0x80) {
4381 memtype = bios[0x52]; 4363 memtype = bios[0x52];
4382 } else { 4364 } else {
4383 inSISIDXREG(SISSR, 0x3a, memtype); 4365 memtype = SiS_GetReg(SISSR, 0x3a);
4384 } 4366 }
4385 memtype &= 0x07; 4367 memtype &= 0x07;
4386 } 4368 }
@@ -4404,19 +4386,19 @@ sisfb_post_sis300(struct pci_dev *pdev)
4404 v6 = bios[rindex++]; 4386 v6 = bios[rindex++];
4405 } 4387 }
4406 } 4388 }
4407 outSISIDXREG(SISSR, 0x28, v1); 4389 SiS_SetReg(SISSR, 0x28, v1);
4408 outSISIDXREG(SISSR, 0x29, v2); 4390 SiS_SetReg(SISSR, 0x29, v2);
4409 outSISIDXREG(SISSR, 0x2a, v3); 4391 SiS_SetReg(SISSR, 0x2a, v3);
4410 outSISIDXREG(SISSR, 0x2e, v4); 4392 SiS_SetReg(SISSR, 0x2e, v4);
4411 outSISIDXREG(SISSR, 0x2f, v5); 4393 SiS_SetReg(SISSR, 0x2f, v5);
4412 outSISIDXREG(SISSR, 0x30, v6); 4394 SiS_SetReg(SISSR, 0x30, v6);
4413 4395
4414 v1 = 0x10; 4396 v1 = 0x10;
4415 if(bios) 4397 if(bios)
4416 v1 = bios[0xa4]; 4398 v1 = bios[0xa4];
4417 outSISIDXREG(SISSR, 0x07, v1); /* DAC speed */ 4399 SiS_SetReg(SISSR, 0x07, v1); /* DAC speed */
4418 4400
4419 outSISIDXREG(SISSR, 0x11, 0x0f); /* DDC, power save */ 4401 SiS_SetReg(SISSR, 0x11, 0x0f); /* DDC, power save */
4420 4402
4421 v1 = 0x01; v2 = 0x43; v3 = 0x1e; v4 = 0x2a; 4403 v1 = 0x01; v2 = 0x43; v3 = 0x1e; v4 = 0x2a;
4422 v5 = 0x06; v6 = 0x00; v7 = 0x00; v8 = 0x00; 4404 v5 = 0x06; v6 = 0x00; v7 = 0x00; v8 = 0x00;
@@ -4433,87 +4415,87 @@ sisfb_post_sis300(struct pci_dev *pdev)
4433 } 4415 }
4434 if(ivideo->revision_id >= 0x80) 4416 if(ivideo->revision_id >= 0x80)
4435 v3 &= 0xfd; 4417 v3 &= 0xfd;
4436 outSISIDXREG(SISSR, 0x15, v1); /* Ram type (assuming 0, BIOS 0xa5 step 8) */ 4418 SiS_SetReg(SISSR, 0x15, v1); /* Ram type (assuming 0, BIOS 0xa5 step 8) */
4437 outSISIDXREG(SISSR, 0x16, v2); 4419 SiS_SetReg(SISSR, 0x16, v2);
4438 outSISIDXREG(SISSR, 0x17, v3); 4420 SiS_SetReg(SISSR, 0x17, v3);
4439 outSISIDXREG(SISSR, 0x18, v4); 4421 SiS_SetReg(SISSR, 0x18, v4);
4440 outSISIDXREG(SISSR, 0x19, v5); 4422 SiS_SetReg(SISSR, 0x19, v5);
4441 outSISIDXREG(SISSR, 0x1a, v6); 4423 SiS_SetReg(SISSR, 0x1a, v6);
4442 outSISIDXREG(SISSR, 0x1b, v7); 4424 SiS_SetReg(SISSR, 0x1b, v7);
4443 outSISIDXREG(SISSR, 0x1c, v8); /* ---- */ 4425 SiS_SetReg(SISSR, 0x1c, v8); /* ---- */
4444 andSISIDXREG(SISSR, 0x15 ,0xfb); 4426 SiS_SetRegAND(SISSR, 0x15, 0xfb);
4445 orSISIDXREG(SISSR, 0x15, 0x04); 4427 SiS_SetRegOR(SISSR, 0x15, 0x04);
4446 if(bios) { 4428 if(bios) {
4447 if(bios[0x53] & 0x02) { 4429 if(bios[0x53] & 0x02) {
4448 orSISIDXREG(SISSR, 0x19, 0x20); 4430 SiS_SetRegOR(SISSR, 0x19, 0x20);
4449 } 4431 }
4450 } 4432 }
4451 v1 = 0x04; /* DAC pedestal (BIOS 0xe5) */ 4433 v1 = 0x04; /* DAC pedestal (BIOS 0xe5) */
4452 if(ivideo->revision_id >= 0x80) 4434 if(ivideo->revision_id >= 0x80)
4453 v1 |= 0x01; 4435 v1 |= 0x01;
4454 outSISIDXREG(SISSR, 0x1f, v1); 4436 SiS_SetReg(SISSR, 0x1f, v1);
4455 outSISIDXREG(SISSR, 0x20, 0xa4); /* linear & relocated io & disable a0000 */ 4437 SiS_SetReg(SISSR, 0x20, 0xa4); /* linear & relocated io & disable a0000 */
4456 v1 = 0xf6; v2 = 0x0d; v3 = 0x00; 4438 v1 = 0xf6; v2 = 0x0d; v3 = 0x00;
4457 if(bios) { 4439 if(bios) {
4458 v1 = bios[0xe8]; 4440 v1 = bios[0xe8];
4459 v2 = bios[0xe9]; 4441 v2 = bios[0xe9];
4460 v3 = bios[0xea]; 4442 v3 = bios[0xea];
4461 } 4443 }
4462 outSISIDXREG(SISSR, 0x23, v1); 4444 SiS_SetReg(SISSR, 0x23, v1);
4463 outSISIDXREG(SISSR, 0x24, v2); 4445 SiS_SetReg(SISSR, 0x24, v2);
4464 outSISIDXREG(SISSR, 0x25, v3); 4446 SiS_SetReg(SISSR, 0x25, v3);
4465 outSISIDXREG(SISSR, 0x21, 0x84); 4447 SiS_SetReg(SISSR, 0x21, 0x84);
4466 outSISIDXREG(SISSR, 0x22, 0x00); 4448 SiS_SetReg(SISSR, 0x22, 0x00);
4467 outSISIDXREG(SISCR, 0x37, 0x00); 4449 SiS_SetReg(SISCR, 0x37, 0x00);
4468 orSISIDXREG(SISPART1, 0x24, 0x01); /* unlock crt2 */ 4450 SiS_SetRegOR(SISPART1, 0x24, 0x01); /* unlock crt2 */
4469 outSISIDXREG(SISPART1, 0x00, 0x00); 4451 SiS_SetReg(SISPART1, 0x00, 0x00);
4470 v1 = 0x40; v2 = 0x11; 4452 v1 = 0x40; v2 = 0x11;
4471 if(bios) { 4453 if(bios) {
4472 v1 = bios[0xec]; 4454 v1 = bios[0xec];
4473 v2 = bios[0xeb]; 4455 v2 = bios[0xeb];
4474 } 4456 }
4475 outSISIDXREG(SISPART1, 0x02, v1); 4457 SiS_SetReg(SISPART1, 0x02, v1);
4476 4458
4477 if(ivideo->revision_id >= 0x80) 4459 if(ivideo->revision_id >= 0x80)
4478 v2 &= ~0x01; 4460 v2 &= ~0x01;
4479 4461
4480 inSISIDXREG(SISPART4, 0x00, reg); 4462 reg = SiS_GetReg(SISPART4, 0x00);
4481 if((reg == 1) || (reg == 2)) { 4463 if((reg == 1) || (reg == 2)) {
4482 outSISIDXREG(SISCR, 0x37, 0x02); 4464 SiS_SetReg(SISCR, 0x37, 0x02);
4483 outSISIDXREG(SISPART2, 0x00, 0x1c); 4465 SiS_SetReg(SISPART2, 0x00, 0x1c);
4484 v4 = 0x00; v5 = 0x00; v6 = 0x10; 4466 v4 = 0x00; v5 = 0x00; v6 = 0x10;
4485 if(ivideo->SiS_Pr.UseROM) { 4467 if(ivideo->SiS_Pr.UseROM) {
4486 v4 = bios[0xf5]; 4468 v4 = bios[0xf5];
4487 v5 = bios[0xf6]; 4469 v5 = bios[0xf6];
4488 v6 = bios[0xf7]; 4470 v6 = bios[0xf7];
4489 } 4471 }
4490 outSISIDXREG(SISPART4, 0x0d, v4); 4472 SiS_SetReg(SISPART4, 0x0d, v4);
4491 outSISIDXREG(SISPART4, 0x0e, v5); 4473 SiS_SetReg(SISPART4, 0x0e, v5);
4492 outSISIDXREG(SISPART4, 0x10, v6); 4474 SiS_SetReg(SISPART4, 0x10, v6);
4493 outSISIDXREG(SISPART4, 0x0f, 0x3f); 4475 SiS_SetReg(SISPART4, 0x0f, 0x3f);
4494 inSISIDXREG(SISPART4, 0x01, reg); 4476 reg = SiS_GetReg(SISPART4, 0x01);
4495 if(reg >= 0xb0) { 4477 if(reg >= 0xb0) {
4496 inSISIDXREG(SISPART4, 0x23, reg); 4478 reg = SiS_GetReg(SISPART4, 0x23);
4497 reg &= 0x20; 4479 reg &= 0x20;
4498 reg <<= 1; 4480 reg <<= 1;
4499 outSISIDXREG(SISPART4, 0x23, reg); 4481 SiS_SetReg(SISPART4, 0x23, reg);
4500 } 4482 }
4501 } else { 4483 } else {
4502 v2 &= ~0x10; 4484 v2 &= ~0x10;
4503 } 4485 }
4504 outSISIDXREG(SISSR, 0x32, v2); 4486 SiS_SetReg(SISSR, 0x32, v2);
4505 4487
4506 andSISIDXREG(SISPART1, 0x24, 0xfe); /* Lock CRT2 */ 4488 SiS_SetRegAND(SISPART1, 0x24, 0xfe); /* Lock CRT2 */
4507 4489
4508 inSISIDXREG(SISSR, 0x16, reg); 4490 reg = SiS_GetReg(SISSR, 0x16);
4509 reg &= 0xc3; 4491 reg &= 0xc3;
4510 outSISIDXREG(SISCR, 0x35, reg); 4492 SiS_SetReg(SISCR, 0x35, reg);
4511 outSISIDXREG(SISCR, 0x83, 0x00); 4493 SiS_SetReg(SISCR, 0x83, 0x00);
4512#if !defined(__i386__) && !defined(__x86_64__) 4494#if !defined(__i386__) && !defined(__x86_64__)
4513 if(sisfb_videoram) { 4495 if(sisfb_videoram) {
4514 outSISIDXREG(SISSR, 0x13, 0x28); /* ? */ 4496 SiS_SetReg(SISSR, 0x13, 0x28); /* ? */
4515 reg = ((sisfb_videoram >> 10) - 1) | 0x40; 4497 reg = ((sisfb_videoram >> 10) - 1) | 0x40;
4516 outSISIDXREG(SISSR, 0x14, reg); 4498 SiS_SetReg(SISSR, 0x14, reg);
4517 } else { 4499 } else {
4518#endif 4500#endif
4519 /* Need to map max FB size for finding out about RAM size */ 4501 /* Need to map max FB size for finding out about RAM size */
@@ -4526,8 +4508,8 @@ sisfb_post_sis300(struct pci_dev *pdev)
4526 } else { 4508 } else {
4527 printk(KERN_DEBUG 4509 printk(KERN_DEBUG
4528 "sisfb: Failed to map memory for size detection, assuming 8MB\n"); 4510 "sisfb: Failed to map memory for size detection, assuming 8MB\n");
4529 outSISIDXREG(SISSR, 0x13, 0x28); /* ? */ 4511 SiS_SetReg(SISSR, 0x13, 0x28); /* ? */
4530 outSISIDXREG(SISSR, 0x14, 0x47); /* 8MB, 64bit default */ 4512 SiS_SetReg(SISSR, 0x14, 0x47); /* 8MB, 64bit default */
4531 } 4513 }
4532#if !defined(__i386__) && !defined(__x86_64__) 4514#if !defined(__i386__) && !defined(__x86_64__)
4533 } 4515 }
@@ -4536,7 +4518,7 @@ sisfb_post_sis300(struct pci_dev *pdev)
4536 v1 = bios[0xe6]; 4518 v1 = bios[0xe6];
4537 v2 = bios[0xe7]; 4519 v2 = bios[0xe7];
4538 } else { 4520 } else {
4539 inSISIDXREG(SISSR, 0x3a, reg); 4521 reg = SiS_GetReg(SISSR, 0x3a);
4540 if((reg & 0x30) == 0x30) { 4522 if((reg & 0x30) == 0x30) {
4541 v1 = 0x04; /* PCI */ 4523 v1 = 0x04; /* PCI */
4542 v2 = 0x92; 4524 v2 = 0x92;
@@ -4545,8 +4527,8 @@ sisfb_post_sis300(struct pci_dev *pdev)
4545 v2 = 0xb2; 4527 v2 = 0xb2;
4546 } 4528 }
4547 } 4529 }
4548 outSISIDXREG(SISSR, 0x21, v1); 4530 SiS_SetReg(SISSR, 0x21, v1);
4549 outSISIDXREG(SISSR, 0x22, v2); 4531 SiS_SetReg(SISSR, 0x22, v2);
4550 4532
4551 /* Sense CRT1 */ 4533 /* Sense CRT1 */
4552 sisfb_sense_crt1(ivideo); 4534 sisfb_sense_crt1(ivideo);
@@ -4559,13 +4541,13 @@ sisfb_post_sis300(struct pci_dev *pdev)
4559 ivideo->SiS_Pr.VideoMemorySize = 8 << 20; 4541 ivideo->SiS_Pr.VideoMemorySize = 8 << 20;
4560 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80); 4542 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80);
4561 4543
4562 outSISIDXREG(SISSR, 0x05, 0x86); 4544 SiS_SetReg(SISSR, 0x05, 0x86);
4563 4545
4564 /* Display off */ 4546 /* Display off */
4565 orSISIDXREG(SISSR, 0x01, 0x20); 4547 SiS_SetRegOR(SISSR, 0x01, 0x20);
4566 4548
4567 /* Save mode number in CR34 */ 4549 /* Save mode number in CR34 */
4568 outSISIDXREG(SISCR, 0x34, 0x2e); 4550 SiS_SetReg(SISCR, 0x34, 0x2e);
4569 4551
4570 /* Let everyone know what the current mode is */ 4552 /* Let everyone know what the current mode is */
4571 ivideo->modeprechange = 0x2e; 4553 ivideo->modeprechange = 0x2e;
@@ -4588,7 +4570,7 @@ sisfb_post_xgi_delay(struct sis_video_info *ivideo, int delay)
4588 u8 reg; 4570 u8 reg;
4589 4571
4590 for(i = 0; i <= (delay * 10 * 36); i++) { 4572 for(i = 0; i <= (delay * 10 * 36); i++) {
4591 inSISIDXREG(SISSR, 0x05, reg); 4573 reg = SiS_GetReg(SISSR, 0x05);
4592 reg++; 4574 reg++;
4593 } 4575 }
4594} 4576}
@@ -4680,7 +4662,7 @@ sisfb_post_xgi_ramsize(struct sis_video_info *ivideo)
4680 * - if running on non-x86, there usually is no VGA window 4662 * - if running on non-x86, there usually is no VGA window
4681 * at a0000. 4663 * at a0000.
4682 */ 4664 */
4683 orSISIDXREG(SISSR, 0x20, (0x80 | 0x04)); 4665 SiS_SetRegOR(SISSR, 0x20, (0x80 | 0x04));
4684 4666
4685 /* Need to map max FB size for finding out about RAM size */ 4667 /* Need to map max FB size for finding out about RAM size */
4686 mapsize = ivideo->video_size; 4668 mapsize = ivideo->video_size;
@@ -4688,76 +4670,76 @@ sisfb_post_xgi_ramsize(struct sis_video_info *ivideo)
4688 4670
4689 if(!ivideo->video_vbase) { 4671 if(!ivideo->video_vbase) {
4690 printk(KERN_ERR "sisfb: Unable to detect RAM size. Setting default.\n"); 4672 printk(KERN_ERR "sisfb: Unable to detect RAM size. Setting default.\n");
4691 outSISIDXREG(SISSR, 0x13, 0x35); 4673 SiS_SetReg(SISSR, 0x13, 0x35);
4692 outSISIDXREG(SISSR, 0x14, 0x41); 4674 SiS_SetReg(SISSR, 0x14, 0x41);
4693 /* TODO */ 4675 /* TODO */
4694 return; 4676 return;
4695 } 4677 }
4696 4678
4697 /* Non-interleaving */ 4679 /* Non-interleaving */
4698 outSISIDXREG(SISSR, 0x15, 0x00); 4680 SiS_SetReg(SISSR, 0x15, 0x00);
4699 /* No tiling */ 4681 /* No tiling */
4700 outSISIDXREG(SISSR, 0x1c, 0x00); 4682 SiS_SetReg(SISSR, 0x1c, 0x00);
4701 4683
4702 if(ivideo->chip == XGI_20) { 4684 if(ivideo->chip == XGI_20) {
4703 4685
4704 channelab = 1; 4686 channelab = 1;
4705 inSISIDXREG(SISCR, 0x97, reg); 4687 reg = SiS_GetReg(SISCR, 0x97);
4706 if(!(reg & 0x01)) { /* Single 32/16 */ 4688 if(!(reg & 0x01)) { /* Single 32/16 */
4707 buswidth = 32; 4689 buswidth = 32;
4708 outSISIDXREG(SISSR, 0x13, 0xb1); 4690 SiS_SetReg(SISSR, 0x13, 0xb1);
4709 outSISIDXREG(SISSR, 0x14, 0x52); 4691 SiS_SetReg(SISSR, 0x14, 0x52);
4710 sisfb_post_xgi_delay(ivideo, 1); 4692 sisfb_post_xgi_delay(ivideo, 1);
4711 sr14 = 0x02; 4693 sr14 = 0x02;
4712 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) 4694 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize))
4713 goto bail_out; 4695 goto bail_out;
4714 4696
4715 outSISIDXREG(SISSR, 0x13, 0x31); 4697 SiS_SetReg(SISSR, 0x13, 0x31);
4716 outSISIDXREG(SISSR, 0x14, 0x42); 4698 SiS_SetReg(SISSR, 0x14, 0x42);
4717 sisfb_post_xgi_delay(ivideo, 1); 4699 sisfb_post_xgi_delay(ivideo, 1);
4718 if(sisfb_post_xgi_rwtest(ivideo, 23, 23, mapsize)) 4700 if(sisfb_post_xgi_rwtest(ivideo, 23, 23, mapsize))
4719 goto bail_out; 4701 goto bail_out;
4720 4702
4721 buswidth = 16; 4703 buswidth = 16;
4722 outSISIDXREG(SISSR, 0x13, 0xb1); 4704 SiS_SetReg(SISSR, 0x13, 0xb1);
4723 outSISIDXREG(SISSR, 0x14, 0x41); 4705 SiS_SetReg(SISSR, 0x14, 0x41);
4724 sisfb_post_xgi_delay(ivideo, 1); 4706 sisfb_post_xgi_delay(ivideo, 1);
4725 sr14 = 0x01; 4707 sr14 = 0x01;
4726 if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize)) 4708 if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize))
4727 goto bail_out; 4709 goto bail_out;
4728 else 4710 else
4729 outSISIDXREG(SISSR, 0x13, 0x31); 4711 SiS_SetReg(SISSR, 0x13, 0x31);
4730 } else { /* Dual 16/8 */ 4712 } else { /* Dual 16/8 */
4731 buswidth = 16; 4713 buswidth = 16;
4732 outSISIDXREG(SISSR, 0x13, 0xb1); 4714 SiS_SetReg(SISSR, 0x13, 0xb1);
4733 outSISIDXREG(SISSR, 0x14, 0x41); 4715 SiS_SetReg(SISSR, 0x14, 0x41);
4734 sisfb_post_xgi_delay(ivideo, 1); 4716 sisfb_post_xgi_delay(ivideo, 1);
4735 sr14 = 0x01; 4717 sr14 = 0x01;
4736 if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize)) 4718 if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize))
4737 goto bail_out; 4719 goto bail_out;
4738 4720
4739 outSISIDXREG(SISSR, 0x13, 0x31); 4721 SiS_SetReg(SISSR, 0x13, 0x31);
4740 outSISIDXREG(SISSR, 0x14, 0x31); 4722 SiS_SetReg(SISSR, 0x14, 0x31);
4741 sisfb_post_xgi_delay(ivideo, 1); 4723 sisfb_post_xgi_delay(ivideo, 1);
4742 if(sisfb_post_xgi_rwtest(ivideo, 22, 22, mapsize)) 4724 if(sisfb_post_xgi_rwtest(ivideo, 22, 22, mapsize))
4743 goto bail_out; 4725 goto bail_out;
4744 4726
4745 buswidth = 8; 4727 buswidth = 8;
4746 outSISIDXREG(SISSR, 0x13, 0xb1); 4728 SiS_SetReg(SISSR, 0x13, 0xb1);
4747 outSISIDXREG(SISSR, 0x14, 0x30); 4729 SiS_SetReg(SISSR, 0x14, 0x30);
4748 sisfb_post_xgi_delay(ivideo, 1); 4730 sisfb_post_xgi_delay(ivideo, 1);
4749 sr14 = 0x00; 4731 sr14 = 0x00;
4750 if(sisfb_post_xgi_rwtest(ivideo, 21, 22, mapsize)) 4732 if(sisfb_post_xgi_rwtest(ivideo, 21, 22, mapsize))
4751 goto bail_out; 4733 goto bail_out;
4752 else 4734 else
4753 outSISIDXREG(SISSR, 0x13, 0x31); 4735 SiS_SetReg(SISSR, 0x13, 0x31);
4754 } 4736 }
4755 4737
4756 } else { /* XGI_40 */ 4738 } else { /* XGI_40 */
4757 4739
4758 inSISIDXREG(SISCR, 0x97, reg); 4740 reg = SiS_GetReg(SISCR, 0x97);
4759 if(!(reg & 0x10)) { 4741 if(!(reg & 0x10)) {
4760 inSISIDXREG(SISSR, 0x39, reg); 4742 reg = SiS_GetReg(SISSR, 0x39);
4761 reg >>= 1; 4743 reg >>= 1;
4762 } 4744 }
4763 4745
@@ -4765,52 +4747,52 @@ sisfb_post_xgi_ramsize(struct sis_video_info *ivideo)
4765 buswidth = 32; 4747 buswidth = 32;
4766 if(ivideo->revision_id == 2) { 4748 if(ivideo->revision_id == 2) {
4767 channelab = 2; 4749 channelab = 2;
4768 outSISIDXREG(SISSR, 0x13, 0xa1); 4750 SiS_SetReg(SISSR, 0x13, 0xa1);
4769 outSISIDXREG(SISSR, 0x14, 0x44); 4751 SiS_SetReg(SISSR, 0x14, 0x44);
4770 sr14 = 0x04; 4752 sr14 = 0x04;
4771 sisfb_post_xgi_delay(ivideo, 1); 4753 sisfb_post_xgi_delay(ivideo, 1);
4772 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) 4754 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize))
4773 goto bail_out; 4755 goto bail_out;
4774 4756
4775 outSISIDXREG(SISSR, 0x13, 0x21); 4757 SiS_SetReg(SISSR, 0x13, 0x21);
4776 outSISIDXREG(SISSR, 0x14, 0x34); 4758 SiS_SetReg(SISSR, 0x14, 0x34);
4777 if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize)) 4759 if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize))
4778 goto bail_out; 4760 goto bail_out;
4779 4761
4780 channelab = 1; 4762 channelab = 1;
4781 outSISIDXREG(SISSR, 0x13, 0xa1); 4763 SiS_SetReg(SISSR, 0x13, 0xa1);
4782 outSISIDXREG(SISSR, 0x14, 0x40); 4764 SiS_SetReg(SISSR, 0x14, 0x40);
4783 sr14 = 0x00; 4765 sr14 = 0x00;
4784 if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize)) 4766 if(sisfb_post_xgi_rwtest(ivideo, 22, 23, mapsize))
4785 goto bail_out; 4767 goto bail_out;
4786 4768
4787 outSISIDXREG(SISSR, 0x13, 0x21); 4769 SiS_SetReg(SISSR, 0x13, 0x21);
4788 outSISIDXREG(SISSR, 0x14, 0x30); 4770 SiS_SetReg(SISSR, 0x14, 0x30);
4789 } else { 4771 } else {
4790 channelab = 3; 4772 channelab = 3;
4791 outSISIDXREG(SISSR, 0x13, 0xa1); 4773 SiS_SetReg(SISSR, 0x13, 0xa1);
4792 outSISIDXREG(SISSR, 0x14, 0x4c); 4774 SiS_SetReg(SISSR, 0x14, 0x4c);
4793 sr14 = 0x0c; 4775 sr14 = 0x0c;
4794 sisfb_post_xgi_delay(ivideo, 1); 4776 sisfb_post_xgi_delay(ivideo, 1);
4795 if(sisfb_post_xgi_rwtest(ivideo, 23, 25, mapsize)) 4777 if(sisfb_post_xgi_rwtest(ivideo, 23, 25, mapsize))
4796 goto bail_out; 4778 goto bail_out;
4797 4779
4798 channelab = 2; 4780 channelab = 2;
4799 outSISIDXREG(SISSR, 0x14, 0x48); 4781 SiS_SetReg(SISSR, 0x14, 0x48);
4800 sisfb_post_xgi_delay(ivideo, 1); 4782 sisfb_post_xgi_delay(ivideo, 1);
4801 sr14 = 0x08; 4783 sr14 = 0x08;
4802 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) 4784 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize))
4803 goto bail_out; 4785 goto bail_out;
4804 4786
4805 outSISIDXREG(SISSR, 0x13, 0x21); 4787 SiS_SetReg(SISSR, 0x13, 0x21);
4806 outSISIDXREG(SISSR, 0x14, 0x3c); 4788 SiS_SetReg(SISSR, 0x14, 0x3c);
4807 sr14 = 0x0c; 4789 sr14 = 0x0c;
4808 4790
4809 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) { 4791 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) {
4810 channelab = 3; 4792 channelab = 3;
4811 } else { 4793 } else {
4812 channelab = 2; 4794 channelab = 2;
4813 outSISIDXREG(SISSR, 0x14, 0x38); 4795 SiS_SetReg(SISSR, 0x14, 0x38);
4814 sr14 = 0x08; 4796 sr14 = 0x08;
4815 } 4797 }
4816 } 4798 }
@@ -4821,26 +4803,26 @@ sisfb_post_xgi_ramsize(struct sis_video_info *ivideo)
4821 buswidth = 64; 4803 buswidth = 64;
4822 if(ivideo->revision_id == 2) { 4804 if(ivideo->revision_id == 2) {
4823 channelab = 1; 4805 channelab = 1;
4824 outSISIDXREG(SISSR, 0x13, 0xa1); 4806 SiS_SetReg(SISSR, 0x13, 0xa1);
4825 outSISIDXREG(SISSR, 0x14, 0x52); 4807 SiS_SetReg(SISSR, 0x14, 0x52);
4826 sisfb_post_xgi_delay(ivideo, 1); 4808 sisfb_post_xgi_delay(ivideo, 1);
4827 sr14 = 0x02; 4809 sr14 = 0x02;
4828 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize)) 4810 if(sisfb_post_xgi_rwtest(ivideo, 23, 24, mapsize))
4829 goto bail_out; 4811 goto bail_out;
4830 4812
4831 outSISIDXREG(SISSR, 0x13, 0x21); 4813 SiS_SetReg(SISSR, 0x13, 0x21);
4832 outSISIDXREG(SISSR, 0x14, 0x42); 4814 SiS_SetReg(SISSR, 0x14, 0x42);
4833 } else { 4815 } else {
4834 channelab = 2; 4816 channelab = 2;
4835 outSISIDXREG(SISSR, 0x13, 0xa1); 4817 SiS_SetReg(SISSR, 0x13, 0xa1);
4836 outSISIDXREG(SISSR, 0x14, 0x5a); 4818 SiS_SetReg(SISSR, 0x14, 0x5a);
4837 sisfb_post_xgi_delay(ivideo, 1); 4819 sisfb_post_xgi_delay(ivideo, 1);
4838 sr14 = 0x0a; 4820 sr14 = 0x0a;
4839 if(sisfb_post_xgi_rwtest(ivideo, 24, 25, mapsize)) 4821 if(sisfb_post_xgi_rwtest(ivideo, 24, 25, mapsize))
4840 goto bail_out; 4822 goto bail_out;
4841 4823
4842 outSISIDXREG(SISSR, 0x13, 0x21); 4824 SiS_SetReg(SISSR, 0x13, 0x21);
4843 outSISIDXREG(SISSR, 0x14, 0x4a); 4825 SiS_SetReg(SISSR, 0x14, 0x4a);
4844 } 4826 }
4845 sisfb_post_xgi_delay(ivideo, 1); 4827 sisfb_post_xgi_delay(ivideo, 1);
4846 4828
@@ -4848,7 +4830,7 @@ sisfb_post_xgi_ramsize(struct sis_video_info *ivideo)
4848 } 4830 }
4849 4831
4850bail_out: 4832bail_out:
4851 setSISIDXREG(SISSR, 0x14, 0xf0, sr14); 4833 SiS_SetRegANDOR(SISSR, 0x14, 0xf0, sr14);
4852 sisfb_post_xgi_delay(ivideo, 1); 4834 sisfb_post_xgi_delay(ivideo, 1);
4853 4835
4854 j = (ivideo->chip == XGI_20) ? 5 : 9; 4836 j = (ivideo->chip == XGI_20) ? 5 : 9;
@@ -4858,13 +4840,13 @@ bail_out:
4858 4840
4859 reg = (ivideo->chip == XGI_20) ? 4841 reg = (ivideo->chip == XGI_20) ?
4860 dramsr13[(i * 5) + 4] : dramsr13_4[(i * 5) + 4]; 4842 dramsr13[(i * 5) + 4] : dramsr13_4[(i * 5) + 4];
4861 setSISIDXREG(SISSR, 0x13, 0x80, reg); 4843 SiS_SetRegANDOR(SISSR, 0x13, 0x80, reg);
4862 sisfb_post_xgi_delay(ivideo, 50); 4844 sisfb_post_xgi_delay(ivideo, 50);
4863 4845
4864 ranksize = (ivideo->chip == XGI_20) ? 4846 ranksize = (ivideo->chip == XGI_20) ?
4865 dramsr13[(i * 5) + 3] : dramsr13_4[(i * 5) + 3]; 4847 dramsr13[(i * 5) + 3] : dramsr13_4[(i * 5) + 3];
4866 4848
4867 inSISIDXREG(SISSR, 0x13, reg); 4849 reg = SiS_GetReg(SISSR, 0x13);
4868 if(reg & 0x80) ranksize <<= 1; 4850 if(reg & 0x80) ranksize <<= 1;
4869 4851
4870 if(ivideo->chip == XGI_20) { 4852 if(ivideo->chip == XGI_20) {
@@ -4883,7 +4865,7 @@ bail_out:
4883 4865
4884 if(!reg) continue; 4866 if(!reg) continue;
4885 4867
4886 setSISIDXREG(SISSR, 0x14, 0x0f, (reg & 0xf0)); 4868 SiS_SetRegANDOR(SISSR, 0x14, 0x0f, (reg & 0xf0));
4887 sisfb_post_xgi_delay(ivideo, 1); 4869 sisfb_post_xgi_delay(ivideo, 1);
4888 4870
4889 if(sisfb_post_xgi_rwtest(ivideo, j, ((reg >> 4) + channelab - 2 + 20), mapsize)) 4871 if(sisfb_post_xgi_rwtest(ivideo, j, ((reg >> 4) + channelab - 2 + 20), mapsize))
@@ -4928,9 +4910,9 @@ sisfb_post_xgi_setclocks(struct sis_video_info *ivideo, u8 regb)
4928 v2 = ivideo->bios_abase[0x90 + index + 1]; 4910 v2 = ivideo->bios_abase[0x90 + index + 1];
4929 v3 = ivideo->bios_abase[0x90 + index + 2]; 4911 v3 = ivideo->bios_abase[0x90 + index + 2];
4930 } 4912 }
4931 outSISIDXREG(SISSR, 0x28, v1); 4913 SiS_SetReg(SISSR, 0x28, v1);
4932 outSISIDXREG(SISSR, 0x29, v2); 4914 SiS_SetReg(SISSR, 0x29, v2);
4933 outSISIDXREG(SISSR, 0x2a, v3); 4915 SiS_SetReg(SISSR, 0x2a, v3);
4934 sisfb_post_xgi_delay(ivideo, 0x43); 4916 sisfb_post_xgi_delay(ivideo, 0x43);
4935 sisfb_post_xgi_delay(ivideo, 0x43); 4917 sisfb_post_xgi_delay(ivideo, 0x43);
4936 sisfb_post_xgi_delay(ivideo, 0x43); 4918 sisfb_post_xgi_delay(ivideo, 0x43);
@@ -4941,9 +4923,9 @@ sisfb_post_xgi_setclocks(struct sis_video_info *ivideo, u8 regb)
4941 v2 = ivideo->bios_abase[0xb8 + index + 1]; 4923 v2 = ivideo->bios_abase[0xb8 + index + 1];
4942 v3 = ivideo->bios_abase[0xb8 + index + 2]; 4924 v3 = ivideo->bios_abase[0xb8 + index + 2];
4943 } 4925 }
4944 outSISIDXREG(SISSR, 0x2e, v1); 4926 SiS_SetReg(SISSR, 0x2e, v1);
4945 outSISIDXREG(SISSR, 0x2f, v2); 4927 SiS_SetReg(SISSR, 0x2f, v2);
4946 outSISIDXREG(SISSR, 0x30, v3); 4928 SiS_SetReg(SISSR, 0x30, v3);
4947 sisfb_post_xgi_delay(ivideo, 0x43); 4929 sisfb_post_xgi_delay(ivideo, 0x43);
4948 sisfb_post_xgi_delay(ivideo, 0x43); 4930 sisfb_post_xgi_delay(ivideo, 0x43);
4949 sisfb_post_xgi_delay(ivideo, 0x43); 4931 sisfb_post_xgi_delay(ivideo, 0x43);
@@ -5016,29 +4998,29 @@ sisfb_post_xgi(struct pci_dev *pdev)
5016 }; 4998 };
5017 4999
5018 /* VGA enable */ 5000 /* VGA enable */
5019 reg = inSISREG(SISVGAENABLE) | 0x01; 5001 reg = SiS_GetRegByte(SISVGAENABLE) | 0x01;
5020 outSISREG(SISVGAENABLE, reg); 5002 SiS_SetRegByte(SISVGAENABLE, reg);
5021 5003
5022 /* Misc */ 5004 /* Misc */
5023 reg = inSISREG(SISMISCR) | 0x01; 5005 reg = SiS_GetRegByte(SISMISCR) | 0x01;
5024 outSISREG(SISMISCW, reg); 5006 SiS_SetRegByte(SISMISCW, reg);
5025 5007
5026 /* Unlock SR */ 5008 /* Unlock SR */
5027 outSISIDXREG(SISSR, 0x05, 0x86); 5009 SiS_SetReg(SISSR, 0x05, 0x86);
5028 inSISIDXREG(SISSR, 0x05, reg); 5010 reg = SiS_GetReg(SISSR, 0x05);
5029 if(reg != 0xa1) 5011 if(reg != 0xa1)
5030 return 0; 5012 return 0;
5031 5013
5032 /* Clear some regs */ 5014 /* Clear some regs */
5033 for(i = 0; i < 0x22; i++) { 5015 for(i = 0; i < 0x22; i++) {
5034 if(0x06 + i == 0x20) continue; 5016 if(0x06 + i == 0x20) continue;
5035 outSISIDXREG(SISSR, 0x06 + i, 0x00); 5017 SiS_SetReg(SISSR, 0x06 + i, 0x00);
5036 } 5018 }
5037 for(i = 0; i < 0x0b; i++) { 5019 for(i = 0; i < 0x0b; i++) {
5038 outSISIDXREG(SISSR, 0x31 + i, 0x00); 5020 SiS_SetReg(SISSR, 0x31 + i, 0x00);
5039 } 5021 }
5040 for(i = 0; i < 0x10; i++) { 5022 for(i = 0; i < 0x10; i++) {
5041 outSISIDXREG(SISCR, 0x30 + i, 0x00); 5023 SiS_SetReg(SISCR, 0x30 + i, 0x00);
5042 } 5024 }
5043 5025
5044 ptr = cs78; 5026 ptr = cs78;
@@ -5046,7 +5028,7 @@ sisfb_post_xgi(struct pci_dev *pdev)
5046 ptr = (const u8 *)&bios[0x78]; 5028 ptr = (const u8 *)&bios[0x78];
5047 } 5029 }
5048 for(i = 0; i < 3; i++) { 5030 for(i = 0; i < 3; i++) {
5049 outSISIDXREG(SISSR, 0x23 + i, ptr[i]); 5031 SiS_SetReg(SISSR, 0x23 + i, ptr[i]);
5050 } 5032 }
5051 5033
5052 ptr = cs76; 5034 ptr = cs76;
@@ -5054,7 +5036,7 @@ sisfb_post_xgi(struct pci_dev *pdev)
5054 ptr = (const u8 *)&bios[0x76]; 5036 ptr = (const u8 *)&bios[0x76];
5055 } 5037 }
5056 for(i = 0; i < 2; i++) { 5038 for(i = 0; i < 2; i++) {
5057 outSISIDXREG(SISSR, 0x21 + i, ptr[i]); 5039 SiS_SetReg(SISSR, 0x21 + i, ptr[i]);
5058 } 5040 }
5059 5041
5060 v1 = 0x18; v2 = 0x00; 5042 v1 = 0x18; v2 = 0x00;
@@ -5062,83 +5044,83 @@ sisfb_post_xgi(struct pci_dev *pdev)
5062 v1 = bios[0x74]; 5044 v1 = bios[0x74];
5063 v2 = bios[0x75]; 5045 v2 = bios[0x75];
5064 } 5046 }
5065 outSISIDXREG(SISSR, 0x07, v1); 5047 SiS_SetReg(SISSR, 0x07, v1);
5066 outSISIDXREG(SISSR, 0x11, 0x0f); 5048 SiS_SetReg(SISSR, 0x11, 0x0f);
5067 outSISIDXREG(SISSR, 0x1f, v2); 5049 SiS_SetReg(SISSR, 0x1f, v2);
5068 /* PCI linear mode, RelIO enabled, A0000 decoding disabled */ 5050 /* PCI linear mode, RelIO enabled, A0000 decoding disabled */
5069 outSISIDXREG(SISSR, 0x20, 0x80 | 0x20 | 0x04); 5051 SiS_SetReg(SISSR, 0x20, 0x80 | 0x20 | 0x04);
5070 outSISIDXREG(SISSR, 0x27, 0x74); 5052 SiS_SetReg(SISSR, 0x27, 0x74);
5071 5053
5072 ptr = cs7b; 5054 ptr = cs7b;
5073 if(ivideo->haveXGIROM) { 5055 if(ivideo->haveXGIROM) {
5074 ptr = (const u8 *)&bios[0x7b]; 5056 ptr = (const u8 *)&bios[0x7b];
5075 } 5057 }
5076 for(i = 0; i < 3; i++) { 5058 for(i = 0; i < 3; i++) {
5077 outSISIDXREG(SISSR, 0x31 + i, ptr[i]); 5059 SiS_SetReg(SISSR, 0x31 + i, ptr[i]);
5078 } 5060 }
5079 5061
5080 if(ivideo->chip == XGI_40) { 5062 if(ivideo->chip == XGI_40) {
5081 if(ivideo->revision_id == 2) { 5063 if(ivideo->revision_id == 2) {
5082 setSISIDXREG(SISSR, 0x3b, 0x3f, 0xc0); 5064 SiS_SetRegANDOR(SISSR, 0x3b, 0x3f, 0xc0);
5083 } 5065 }
5084 outSISIDXREG(SISCR, 0x7d, 0xfe); 5066 SiS_SetReg(SISCR, 0x7d, 0xfe);
5085 outSISIDXREG(SISCR, 0x7e, 0x0f); 5067 SiS_SetReg(SISCR, 0x7e, 0x0f);
5086 } 5068 }
5087 if(ivideo->revision_id == 0) { /* 40 *and* 20? */ 5069 if(ivideo->revision_id == 0) { /* 40 *and* 20? */
5088 andSISIDXREG(SISCR, 0x58, 0xd7); 5070 SiS_SetRegAND(SISCR, 0x58, 0xd7);
5089 inSISIDXREG(SISCR, 0xcb, reg); 5071 reg = SiS_GetReg(SISCR, 0xcb);
5090 if(reg & 0x20) { 5072 if(reg & 0x20) {
5091 setSISIDXREG(SISCR, 0x58, 0xd7, (reg & 0x10) ? 0x08 : 0x20); /* =0x28 Z7 ? */ 5073 SiS_SetRegANDOR(SISCR, 0x58, 0xd7, (reg & 0x10) ? 0x08 : 0x20); /* =0x28 Z7 ? */
5092 } 5074 }
5093 } 5075 }
5094 5076
5095 reg = (ivideo->chip == XGI_40) ? 0x20 : 0x00; 5077 reg = (ivideo->chip == XGI_40) ? 0x20 : 0x00;
5096 setSISIDXREG(SISCR, 0x38, 0x1f, reg); 5078 SiS_SetRegANDOR(SISCR, 0x38, 0x1f, reg);
5097 5079
5098 if(ivideo->chip == XGI_20) { 5080 if(ivideo->chip == XGI_20) {
5099 outSISIDXREG(SISSR, 0x36, 0x70); 5081 SiS_SetReg(SISSR, 0x36, 0x70);
5100 } else { 5082 } else {
5101 outSISIDXREG(SISVID, 0x00, 0x86); 5083 SiS_SetReg(SISVID, 0x00, 0x86);
5102 outSISIDXREG(SISVID, 0x32, 0x00); 5084 SiS_SetReg(SISVID, 0x32, 0x00);
5103 outSISIDXREG(SISVID, 0x30, 0x00); 5085 SiS_SetReg(SISVID, 0x30, 0x00);
5104 outSISIDXREG(SISVID, 0x32, 0x01); 5086 SiS_SetReg(SISVID, 0x32, 0x01);
5105 outSISIDXREG(SISVID, 0x30, 0x00); 5087 SiS_SetReg(SISVID, 0x30, 0x00);
5106 andSISIDXREG(SISVID, 0x2f, 0xdf); 5088 SiS_SetRegAND(SISVID, 0x2f, 0xdf);
5107 andSISIDXREG(SISCAP, 0x00, 0x3f); 5089 SiS_SetRegAND(SISCAP, 0x00, 0x3f);
5108 5090
5109 outSISIDXREG(SISPART1, 0x2f, 0x01); 5091 SiS_SetReg(SISPART1, 0x2f, 0x01);
5110 outSISIDXREG(SISPART1, 0x00, 0x00); 5092 SiS_SetReg(SISPART1, 0x00, 0x00);
5111 outSISIDXREG(SISPART1, 0x02, bios[0x7e]); 5093 SiS_SetReg(SISPART1, 0x02, bios[0x7e]);
5112 outSISIDXREG(SISPART1, 0x2e, 0x08); 5094 SiS_SetReg(SISPART1, 0x2e, 0x08);
5113 andSISIDXREG(SISPART1, 0x35, 0x7f); 5095 SiS_SetRegAND(SISPART1, 0x35, 0x7f);
5114 andSISIDXREG(SISPART1, 0x50, 0xfe); 5096 SiS_SetRegAND(SISPART1, 0x50, 0xfe);
5115 5097
5116 inSISIDXREG(SISPART4, 0x00, reg); 5098 reg = SiS_GetReg(SISPART4, 0x00);
5117 if(reg == 1 || reg == 2) { 5099 if(reg == 1 || reg == 2) {
5118 outSISIDXREG(SISPART2, 0x00, 0x1c); 5100 SiS_SetReg(SISPART2, 0x00, 0x1c);
5119 outSISIDXREG(SISPART4, 0x0d, bios[0x7f]); 5101 SiS_SetReg(SISPART4, 0x0d, bios[0x7f]);
5120 outSISIDXREG(SISPART4, 0x0e, bios[0x80]); 5102 SiS_SetReg(SISPART4, 0x0e, bios[0x80]);
5121 outSISIDXREG(SISPART4, 0x10, bios[0x81]); 5103 SiS_SetReg(SISPART4, 0x10, bios[0x81]);
5122 andSISIDXREG(SISPART4, 0x0f, 0x3f); 5104 SiS_SetRegAND(SISPART4, 0x0f, 0x3f);
5123 5105
5124 inSISIDXREG(SISPART4, 0x01, reg); 5106 reg = SiS_GetReg(SISPART4, 0x01);
5125 if((reg & 0xf0) >= 0xb0) { 5107 if((reg & 0xf0) >= 0xb0) {
5126 inSISIDXREG(SISPART4, 0x23, reg); 5108 reg = SiS_GetReg(SISPART4, 0x23);
5127 if(reg & 0x20) reg |= 0x40; 5109 if(reg & 0x20) reg |= 0x40;
5128 outSISIDXREG(SISPART4, 0x23, reg); 5110 SiS_SetReg(SISPART4, 0x23, reg);
5129 reg = (reg & 0x20) ? 0x02 : 0x00; 5111 reg = (reg & 0x20) ? 0x02 : 0x00;
5130 setSISIDXREG(SISPART1, 0x1e, 0xfd, reg); 5112 SiS_SetRegANDOR(SISPART1, 0x1e, 0xfd, reg);
5131 } 5113 }
5132 } 5114 }
5133 5115
5134 v1 = bios[0x77]; 5116 v1 = bios[0x77];
5135 5117
5136 inSISIDXREG(SISSR, 0x3b, reg); 5118 reg = SiS_GetReg(SISSR, 0x3b);
5137 if(reg & 0x02) { 5119 if(reg & 0x02) {
5138 inSISIDXREG(SISSR, 0x3a, reg); 5120 reg = SiS_GetReg(SISSR, 0x3a);
5139 v2 = (reg & 0x30) >> 3; 5121 v2 = (reg & 0x30) >> 3;
5140 if(!(v2 & 0x04)) v2 ^= 0x02; 5122 if(!(v2 & 0x04)) v2 ^= 0x02;
5141 inSISIDXREG(SISSR, 0x39, reg); 5123 reg = SiS_GetReg(SISSR, 0x39);
5142 if(reg & 0x80) v2 |= 0x80; 5124 if(reg & 0x80) v2 |= 0x80;
5143 v2 |= 0x01; 5125 v2 |= 0x01;
5144 5126
@@ -5171,36 +5153,36 @@ sisfb_post_xgi(struct pci_dev *pdev)
5171 v2 |= 0x08; 5153 v2 |= 0x08;
5172 } 5154 }
5173 } 5155 }
5174 setSISIDXREG(SISCR, 0x5f, 0xf0, v2); 5156 SiS_SetRegANDOR(SISCR, 0x5f, 0xf0, v2);
5175 } 5157 }
5176 outSISIDXREG(SISSR, 0x22, v1); 5158 SiS_SetReg(SISSR, 0x22, v1);
5177 5159
5178 if(ivideo->revision_id == 2) { 5160 if(ivideo->revision_id == 2) {
5179 inSISIDXREG(SISSR, 0x3b, v1); 5161 v1 = SiS_GetReg(SISSR, 0x3b);
5180 inSISIDXREG(SISSR, 0x3a, v2); 5162 v2 = SiS_GetReg(SISSR, 0x3a);
5181 regd = bios[0x90 + 3] | (bios[0x90 + 4] << 8); 5163 regd = bios[0x90 + 3] | (bios[0x90 + 4] << 8);
5182 if( (!(v1 & 0x02)) && (v2 & 0x30) && (regd < 0xcf) ) 5164 if( (!(v1 & 0x02)) && (v2 & 0x30) && (regd < 0xcf) )
5183 setSISIDXREG(SISCR, 0x5f, 0xf1, 0x01); 5165 SiS_SetRegANDOR(SISCR, 0x5f, 0xf1, 0x01);
5184 5166
5185 if((mypdev = pci_get_device(0x10de, 0x01e0, NULL))) { 5167 if((mypdev = pci_get_device(0x10de, 0x01e0, NULL))) {
5186 /* TODO: set CR5f &0xf1 | 0x01 for version 6570 5168 /* TODO: set CR5f &0xf1 | 0x01 for version 6570
5187 * of nforce 2 ROM 5169 * of nforce 2 ROM
5188 */ 5170 */
5189 if(0) 5171 if(0)
5190 setSISIDXREG(SISCR, 0x5f, 0xf1, 0x01); 5172 SiS_SetRegANDOR(SISCR, 0x5f, 0xf1, 0x01);
5191 pci_dev_put(mypdev); 5173 pci_dev_put(mypdev);
5192 } 5174 }
5193 } 5175 }
5194 5176
5195 v1 = 0x30; 5177 v1 = 0x30;
5196 inSISIDXREG(SISSR, 0x3b, reg); 5178 reg = SiS_GetReg(SISSR, 0x3b);
5197 inSISIDXREG(SISCR, 0x5f, v2); 5179 v2 = SiS_GetReg(SISCR, 0x5f);
5198 if((!(reg & 0x02)) && (v2 & 0x0e)) 5180 if((!(reg & 0x02)) && (v2 & 0x0e))
5199 v1 |= 0x08; 5181 v1 |= 0x08;
5200 outSISIDXREG(SISSR, 0x27, v1); 5182 SiS_SetReg(SISSR, 0x27, v1);
5201 5183
5202 if(bios[0x64] & 0x01) { 5184 if(bios[0x64] & 0x01) {
5203 setSISIDXREG(SISCR, 0x5f, 0xf0, bios[0x64]); 5185 SiS_SetRegANDOR(SISCR, 0x5f, 0xf0, bios[0x64]);
5204 } 5186 }
5205 5187
5206 v1 = bios[0x4f7]; 5188 v1 = bios[0x4f7];
@@ -5208,27 +5190,27 @@ sisfb_post_xgi(struct pci_dev *pdev)
5208 regd = (regd >> 20) & 0x0f; 5190 regd = (regd >> 20) & 0x0f;
5209 if(regd == 1) { 5191 if(regd == 1) {
5210 v1 &= 0xfc; 5192 v1 &= 0xfc;
5211 orSISIDXREG(SISCR, 0x5f, 0x08); 5193 SiS_SetRegOR(SISCR, 0x5f, 0x08);
5212 } 5194 }
5213 outSISIDXREG(SISCR, 0x48, v1); 5195 SiS_SetReg(SISCR, 0x48, v1);
5214 5196
5215 setSISIDXREG(SISCR, 0x47, 0x04, bios[0x4f6] & 0xfb); 5197 SiS_SetRegANDOR(SISCR, 0x47, 0x04, bios[0x4f6] & 0xfb);
5216 setSISIDXREG(SISCR, 0x49, 0xf0, bios[0x4f8] & 0x0f); 5198 SiS_SetRegANDOR(SISCR, 0x49, 0xf0, bios[0x4f8] & 0x0f);
5217 setSISIDXREG(SISCR, 0x4a, 0x60, bios[0x4f9] & 0x9f); 5199 SiS_SetRegANDOR(SISCR, 0x4a, 0x60, bios[0x4f9] & 0x9f);
5218 setSISIDXREG(SISCR, 0x4b, 0x08, bios[0x4fa] & 0xf7); 5200 SiS_SetRegANDOR(SISCR, 0x4b, 0x08, bios[0x4fa] & 0xf7);
5219 setSISIDXREG(SISCR, 0x4c, 0x80, bios[0x4fb] & 0x7f); 5201 SiS_SetRegANDOR(SISCR, 0x4c, 0x80, bios[0x4fb] & 0x7f);
5220 outSISIDXREG(SISCR, 0x70, bios[0x4fc]); 5202 SiS_SetReg(SISCR, 0x70, bios[0x4fc]);
5221 setSISIDXREG(SISCR, 0x71, 0xf0, bios[0x4fd] & 0x0f); 5203 SiS_SetRegANDOR(SISCR, 0x71, 0xf0, bios[0x4fd] & 0x0f);
5222 outSISIDXREG(SISCR, 0x74, 0xd0); 5204 SiS_SetReg(SISCR, 0x74, 0xd0);
5223 setSISIDXREG(SISCR, 0x74, 0xcf, bios[0x4fe] & 0x30); 5205 SiS_SetRegANDOR(SISCR, 0x74, 0xcf, bios[0x4fe] & 0x30);
5224 setSISIDXREG(SISCR, 0x75, 0xe0, bios[0x4ff] & 0x1f); 5206 SiS_SetRegANDOR(SISCR, 0x75, 0xe0, bios[0x4ff] & 0x1f);
5225 setSISIDXREG(SISCR, 0x76, 0xe0, bios[0x500] & 0x1f); 5207 SiS_SetRegANDOR(SISCR, 0x76, 0xe0, bios[0x500] & 0x1f);
5226 v1 = bios[0x501]; 5208 v1 = bios[0x501];
5227 if((mypdev = pci_get_device(0x8086, 0x2530, NULL))) { 5209 if((mypdev = pci_get_device(0x8086, 0x2530, NULL))) {
5228 v1 = 0xf0; 5210 v1 = 0xf0;
5229 pci_dev_put(mypdev); 5211 pci_dev_put(mypdev);
5230 } 5212 }
5231 outSISIDXREG(SISCR, 0x77, v1); 5213 SiS_SetReg(SISCR, 0x77, v1);
5232 } 5214 }
5233 5215
5234 /* RAM type */ 5216 /* RAM type */
@@ -5239,14 +5221,14 @@ sisfb_post_xgi(struct pci_dev *pdev)
5239 if(ivideo->haveXGIROM) { 5221 if(ivideo->haveXGIROM) {
5240 v1 = bios[0x140 + regb]; 5222 v1 = bios[0x140 + regb];
5241 } 5223 }
5242 outSISIDXREG(SISCR, 0x6d, v1); 5224 SiS_SetReg(SISCR, 0x6d, v1);
5243 5225
5244 ptr = cs128; 5226 ptr = cs128;
5245 if(ivideo->haveXGIROM) { 5227 if(ivideo->haveXGIROM) {
5246 ptr = (const u8 *)&bios[0x128]; 5228 ptr = (const u8 *)&bios[0x128];
5247 } 5229 }
5248 for(i = 0, j = 0; i < 3; i++, j += 8) { 5230 for(i = 0, j = 0; i < 3; i++, j += 8) {
5249 outSISIDXREG(SISCR, 0x68 + i, ptr[j + regb]); 5231 SiS_SetReg(SISCR, 0x68 + i, ptr[j + regb]);
5250 } 5232 }
5251 5233
5252 ptr = cs31a; 5234 ptr = cs31a;
@@ -5270,14 +5252,14 @@ sisfb_post_xgi(struct pci_dev *pdev)
5270 if(regd & 0x01) reg |= 0x04; 5252 if(regd & 0x01) reg |= 0x04;
5271 if(regd & 0x02) reg |= 0x08; 5253 if(regd & 0x02) reg |= 0x08;
5272 regd >>= 2; 5254 regd >>= 2;
5273 outSISIDXREG(SISCR, rega, reg); 5255 SiS_SetReg(SISCR, rega, reg);
5274 inSISIDXREG(SISCR, rega, reg); 5256 reg = SiS_GetReg(SISCR, rega);
5275 inSISIDXREG(SISCR, rega, reg); 5257 reg = SiS_GetReg(SISCR, rega);
5276 reg += 0x10; 5258 reg += 0x10;
5277 } 5259 }
5278 } 5260 }
5279 5261
5280 andSISIDXREG(SISCR, 0x6e, 0xfc); 5262 SiS_SetRegAND(SISCR, 0x6e, 0xfc);
5281 5263
5282 ptr = NULL; 5264 ptr = NULL;
5283 if(ivideo->haveXGIROM) { 5265 if(ivideo->haveXGIROM) {
@@ -5285,7 +5267,7 @@ sisfb_post_xgi(struct pci_dev *pdev)
5285 ptr = (const u8 *)&bios[index]; 5267 ptr = (const u8 *)&bios[index];
5286 } 5268 }
5287 for(i = 0; i < 4; i++) { 5269 for(i = 0; i < 4; i++) {
5288 setSISIDXREG(SISCR, 0x6e, 0xfc, i); 5270 SiS_SetRegANDOR(SISCR, 0x6e, 0xfc, i);
5289 reg = 0x00; 5271 reg = 0x00;
5290 for(j = 0; j < 2; j++) { 5272 for(j = 0; j < 2; j++) {
5291 regd = 0; 5273 regd = 0;
@@ -5299,9 +5281,9 @@ sisfb_post_xgi(struct pci_dev *pdev)
5299 if(regd & 0x01) reg |= 0x01; 5281 if(regd & 0x01) reg |= 0x01;
5300 if(regd & 0x02) reg |= 0x02; 5282 if(regd & 0x02) reg |= 0x02;
5301 regd >>= 2; 5283 regd >>= 2;
5302 outSISIDXREG(SISCR, 0x6f, reg); 5284 SiS_SetReg(SISCR, 0x6f, reg);
5303 inSISIDXREG(SISCR, 0x6f, reg); 5285 reg = SiS_GetReg(SISCR, 0x6f);
5304 inSISIDXREG(SISCR, 0x6f, reg); 5286 reg = SiS_GetReg(SISCR, 0x6f);
5305 reg += 0x08; 5287 reg += 0x08;
5306 } 5288 }
5307 } 5289 }
@@ -5312,10 +5294,10 @@ sisfb_post_xgi(struct pci_dev *pdev)
5312 ptr = (const u8 *)&bios[0x148]; 5294 ptr = (const u8 *)&bios[0x148];
5313 } 5295 }
5314 for(i = 0, j = 0; i < 2; i++, j += 8) { 5296 for(i = 0, j = 0; i < 2; i++, j += 8) {
5315 outSISIDXREG(SISCR, 0x80 + i, ptr[j + regb]); 5297 SiS_SetReg(SISCR, 0x80 + i, ptr[j + regb]);
5316 } 5298 }
5317 5299
5318 andSISIDXREG(SISCR, 0x89, 0x8f); 5300 SiS_SetRegAND(SISCR, 0x89, 0x8f);
5319 5301
5320 ptr = cs45a; 5302 ptr = cs45a;
5321 if(ivideo->haveXGIROM) { 5303 if(ivideo->haveXGIROM) {
@@ -5329,9 +5311,9 @@ sisfb_post_xgi(struct pci_dev *pdev)
5329 if(regd & 0x01) reg |= 0x01; 5311 if(regd & 0x01) reg |= 0x01;
5330 if(regd & 0x02) reg |= 0x02; 5312 if(regd & 0x02) reg |= 0x02;
5331 regd >>= 2; 5313 regd >>= 2;
5332 outSISIDXREG(SISCR, 0x89, reg); 5314 SiS_SetReg(SISCR, 0x89, reg);
5333 inSISIDXREG(SISCR, 0x89, reg); 5315 reg = SiS_GetReg(SISCR, 0x89);
5334 inSISIDXREG(SISCR, 0x89, reg); 5316 reg = SiS_GetReg(SISCR, 0x89);
5335 reg += 0x10; 5317 reg += 0x10;
5336 } 5318 }
5337 5319
@@ -5342,27 +5324,27 @@ sisfb_post_xgi(struct pci_dev *pdev)
5342 v3 = bios[0x120 + regb]; 5324 v3 = bios[0x120 + regb];
5343 v4 = bios[0x1ca]; 5325 v4 = bios[0x1ca];
5344 } 5326 }
5345 outSISIDXREG(SISCR, 0x45, v1 & 0x0f); 5327 SiS_SetReg(SISCR, 0x45, v1 & 0x0f);
5346 outSISIDXREG(SISCR, 0x99, (v1 >> 4) & 0x07); 5328 SiS_SetReg(SISCR, 0x99, (v1 >> 4) & 0x07);
5347 orSISIDXREG(SISCR, 0x40, v1 & 0x80); 5329 SiS_SetRegOR(SISCR, 0x40, v1 & 0x80);
5348 outSISIDXREG(SISCR, 0x41, v2); 5330 SiS_SetReg(SISCR, 0x41, v2);
5349 5331
5350 ptr = cs170; 5332 ptr = cs170;
5351 if(ivideo->haveXGIROM) { 5333 if(ivideo->haveXGIROM) {
5352 ptr = (const u8 *)&bios[0x170]; 5334 ptr = (const u8 *)&bios[0x170];
5353 } 5335 }
5354 for(i = 0, j = 0; i < 7; i++, j += 8) { 5336 for(i = 0, j = 0; i < 7; i++, j += 8) {
5355 outSISIDXREG(SISCR, 0x90 + i, ptr[j + regb]); 5337 SiS_SetReg(SISCR, 0x90 + i, ptr[j + regb]);
5356 } 5338 }
5357 5339
5358 outSISIDXREG(SISCR, 0x59, v3); 5340 SiS_SetReg(SISCR, 0x59, v3);
5359 5341
5360 ptr = cs1a8; 5342 ptr = cs1a8;
5361 if(ivideo->haveXGIROM) { 5343 if(ivideo->haveXGIROM) {
5362 ptr = (const u8 *)&bios[0x1a8]; 5344 ptr = (const u8 *)&bios[0x1a8];
5363 } 5345 }
5364 for(i = 0, j = 0; i < 3; i++, j += 8) { 5346 for(i = 0, j = 0; i < 3; i++, j += 8) {
5365 outSISIDXREG(SISCR, 0xc3 + i, ptr[j + regb]); 5347 SiS_SetReg(SISCR, 0xc3 + i, ptr[j + regb]);
5366 } 5348 }
5367 5349
5368 ptr = cs100; 5350 ptr = cs100;
@@ -5370,27 +5352,27 @@ sisfb_post_xgi(struct pci_dev *pdev)
5370 ptr = (const u8 *)&bios[0x100]; 5352 ptr = (const u8 *)&bios[0x100];
5371 } 5353 }
5372 for(i = 0, j = 0; i < 2; i++, j += 8) { 5354 for(i = 0, j = 0; i < 2; i++, j += 8) {
5373 outSISIDXREG(SISCR, 0x8a + i, ptr[j + regb]); 5355 SiS_SetReg(SISCR, 0x8a + i, ptr[j + regb]);
5374 } 5356 }
5375 5357
5376 outSISIDXREG(SISCR, 0xcf, v4); 5358 SiS_SetReg(SISCR, 0xcf, v4);
5377 5359
5378 outSISIDXREG(SISCR, 0x83, 0x09); 5360 SiS_SetReg(SISCR, 0x83, 0x09);
5379 outSISIDXREG(SISCR, 0x87, 0x00); 5361 SiS_SetReg(SISCR, 0x87, 0x00);
5380 5362
5381 if(ivideo->chip == XGI_40) { 5363 if(ivideo->chip == XGI_40) {
5382 if( (ivideo->revision_id == 1) || 5364 if( (ivideo->revision_id == 1) ||
5383 (ivideo->revision_id == 2) ) { 5365 (ivideo->revision_id == 2) ) {
5384 outSISIDXREG(SISCR, 0x8c, 0x87); 5366 SiS_SetReg(SISCR, 0x8c, 0x87);
5385 } 5367 }
5386 } 5368 }
5387 5369
5388 outSISIDXREG(SISSR, 0x17, 0x00); 5370 SiS_SetReg(SISSR, 0x17, 0x00);
5389 outSISIDXREG(SISSR, 0x1a, 0x87); 5371 SiS_SetReg(SISSR, 0x1a, 0x87);
5390 5372
5391 if(ivideo->chip == XGI_20) { 5373 if(ivideo->chip == XGI_20) {
5392 outSISIDXREG(SISSR, 0x15, 0x00); 5374 SiS_SetReg(SISSR, 0x15, 0x00);
5393 outSISIDXREG(SISSR, 0x1c, 0x00); 5375 SiS_SetReg(SISSR, 0x1c, 0x00);
5394 } 5376 }
5395 5377
5396 ramtype = 0x00; v1 = 0x10; 5378 ramtype = 0x00; v1 = 0x10;
@@ -5400,16 +5382,16 @@ sisfb_post_xgi(struct pci_dev *pdev)
5400 } 5382 }
5401 if(!(ramtype & 0x80)) { 5383 if(!(ramtype & 0x80)) {
5402 if(ivideo->chip == XGI_20) { 5384 if(ivideo->chip == XGI_20) {
5403 outSISIDXREG(SISCR, 0x97, v1); 5385 SiS_SetReg(SISCR, 0x97, v1);
5404 inSISIDXREG(SISCR, 0x97, reg); 5386 reg = SiS_GetReg(SISCR, 0x97);
5405 if(reg & 0x10) { 5387 if(reg & 0x10) {
5406 ramtype = (reg & 0x01) << 1; 5388 ramtype = (reg & 0x01) << 1;
5407 } 5389 }
5408 } else { 5390 } else {
5409 inSISIDXREG(SISSR, 0x39, reg); 5391 reg = SiS_GetReg(SISSR, 0x39);
5410 ramtype = reg & 0x02; 5392 ramtype = reg & 0x02;
5411 if(!(ramtype)) { 5393 if(!(ramtype)) {
5412 inSISIDXREG(SISSR, 0x3a, reg); 5394 reg = SiS_GetReg(SISSR, 0x3a);
5413 ramtype = (reg >> 1) & 0x01; 5395 ramtype = (reg >> 1) & 0x01;
5414 } 5396 }
5415 } 5397 }
@@ -5430,55 +5412,55 @@ sisfb_post_xgi(struct pci_dev *pdev)
5430 v2 = bios[regb + 0x160]; 5412 v2 = bios[regb + 0x160];
5431 v3 = bios[regb + 0x168]; 5413 v3 = bios[regb + 0x168];
5432 } 5414 }
5433 outSISIDXREG(SISCR, 0x82, v1); 5415 SiS_SetReg(SISCR, 0x82, v1);
5434 outSISIDXREG(SISCR, 0x85, v2); 5416 SiS_SetReg(SISCR, 0x85, v2);
5435 outSISIDXREG(SISCR, 0x86, v3); 5417 SiS_SetReg(SISCR, 0x86, v3);
5436 } else { 5418 } else {
5437 outSISIDXREG(SISCR, 0x82, 0x88); 5419 SiS_SetReg(SISCR, 0x82, 0x88);
5438 outSISIDXREG(SISCR, 0x86, 0x00); 5420 SiS_SetReg(SISCR, 0x86, 0x00);
5439 inSISIDXREG(SISCR, 0x86, reg); 5421 reg = SiS_GetReg(SISCR, 0x86);
5440 outSISIDXREG(SISCR, 0x86, 0x88); 5422 SiS_SetReg(SISCR, 0x86, 0x88);
5441 inSISIDXREG(SISCR, 0x86, reg); 5423 reg = SiS_GetReg(SISCR, 0x86);
5442 outSISIDXREG(SISCR, 0x86, bios[regb + 0x168]); 5424 SiS_SetReg(SISCR, 0x86, bios[regb + 0x168]);
5443 outSISIDXREG(SISCR, 0x82, 0x77); 5425 SiS_SetReg(SISCR, 0x82, 0x77);
5444 outSISIDXREG(SISCR, 0x85, 0x00); 5426 SiS_SetReg(SISCR, 0x85, 0x00);
5445 inSISIDXREG(SISCR, 0x85, reg); 5427 reg = SiS_GetReg(SISCR, 0x85);
5446 outSISIDXREG(SISCR, 0x85, 0x88); 5428 SiS_SetReg(SISCR, 0x85, 0x88);
5447 inSISIDXREG(SISCR, 0x85, reg); 5429 reg = SiS_GetReg(SISCR, 0x85);
5448 outSISIDXREG(SISCR, 0x85, bios[regb + 0x160]); 5430 SiS_SetReg(SISCR, 0x85, bios[regb + 0x160]);
5449 outSISIDXREG(SISCR, 0x82, bios[regb + 0x158]); 5431 SiS_SetReg(SISCR, 0x82, bios[regb + 0x158]);
5450 } 5432 }
5451 if(ivideo->chip == XGI_40) { 5433 if(ivideo->chip == XGI_40) {
5452 outSISIDXREG(SISCR, 0x97, 0x00); 5434 SiS_SetReg(SISCR, 0x97, 0x00);
5453 } 5435 }
5454 outSISIDXREG(SISCR, 0x98, 0x01); 5436 SiS_SetReg(SISCR, 0x98, 0x01);
5455 outSISIDXREG(SISCR, 0x9a, 0x02); 5437 SiS_SetReg(SISCR, 0x9a, 0x02);
5456 5438
5457 outSISIDXREG(SISSR, 0x18, 0x01); 5439 SiS_SetReg(SISSR, 0x18, 0x01);
5458 if((ivideo->chip == XGI_20) || 5440 if((ivideo->chip == XGI_20) ||
5459 (ivideo->revision_id == 2)) { 5441 (ivideo->revision_id == 2)) {
5460 outSISIDXREG(SISSR, 0x19, 0x40); 5442 SiS_SetReg(SISSR, 0x19, 0x40);
5461 } else { 5443 } else {
5462 outSISIDXREG(SISSR, 0x19, 0x20); 5444 SiS_SetReg(SISSR, 0x19, 0x20);
5463 } 5445 }
5464 outSISIDXREG(SISSR, 0x16, 0x00); 5446 SiS_SetReg(SISSR, 0x16, 0x00);
5465 outSISIDXREG(SISSR, 0x16, 0x80); 5447 SiS_SetReg(SISSR, 0x16, 0x80);
5466 if((ivideo->chip == XGI_20) || (bios[0x1cb] != 0x0c)) { 5448 if((ivideo->chip == XGI_20) || (bios[0x1cb] != 0x0c)) {
5467 sisfb_post_xgi_delay(ivideo, 0x43); 5449 sisfb_post_xgi_delay(ivideo, 0x43);
5468 sisfb_post_xgi_delay(ivideo, 0x43); 5450 sisfb_post_xgi_delay(ivideo, 0x43);
5469 sisfb_post_xgi_delay(ivideo, 0x43); 5451 sisfb_post_xgi_delay(ivideo, 0x43);
5470 outSISIDXREG(SISSR, 0x18, 0x00); 5452 SiS_SetReg(SISSR, 0x18, 0x00);
5471 if((ivideo->chip == XGI_20) || 5453 if((ivideo->chip == XGI_20) ||
5472 (ivideo->revision_id == 2)) { 5454 (ivideo->revision_id == 2)) {
5473 outSISIDXREG(SISSR, 0x19, 0x40); 5455 SiS_SetReg(SISSR, 0x19, 0x40);
5474 } else { 5456 } else {
5475 outSISIDXREG(SISSR, 0x19, 0x20); 5457 SiS_SetReg(SISSR, 0x19, 0x20);
5476 } 5458 }
5477 } else if((ivideo->chip == XGI_40) && (bios[0x1cb] == 0x0c)) { 5459 } else if((ivideo->chip == XGI_40) && (bios[0x1cb] == 0x0c)) {
5478 /* outSISIDXREG(SISSR, 0x16, 0x0c); */ /* ? */ 5460 /* SiS_SetReg(SISSR, 0x16, 0x0c); */ /* ? */
5479 } 5461 }
5480 outSISIDXREG(SISSR, 0x16, 0x00); 5462 SiS_SetReg(SISSR, 0x16, 0x00);
5481 outSISIDXREG(SISSR, 0x16, 0x80); 5463 SiS_SetReg(SISSR, 0x16, 0x80);
5482 sisfb_post_xgi_delay(ivideo, 4); 5464 sisfb_post_xgi_delay(ivideo, 4);
5483 v1 = 0x31; v2 = 0x03; v3 = 0x83; v4 = 0x03; v5 = 0x83; 5465 v1 = 0x31; v2 = 0x03; v3 = 0x83; v4 = 0x03; v5 = 0x83;
5484 if(ivideo->haveXGIROM) { 5466 if(ivideo->haveXGIROM) {
@@ -5489,74 +5471,74 @@ sisfb_post_xgi(struct pci_dev *pdev)
5489 v4 = bios[index + 2]; 5471 v4 = bios[index + 2];
5490 v5 = bios[index + 3]; 5472 v5 = bios[index + 3];
5491 } 5473 }
5492 outSISIDXREG(SISSR, 0x18, v1); 5474 SiS_SetReg(SISSR, 0x18, v1);
5493 outSISIDXREG(SISSR, 0x19, ((ivideo->chip == XGI_20) ? 0x02 : 0x01)); 5475 SiS_SetReg(SISSR, 0x19, ((ivideo->chip == XGI_20) ? 0x02 : 0x01));
5494 outSISIDXREG(SISSR, 0x16, v2); 5476 SiS_SetReg(SISSR, 0x16, v2);
5495 outSISIDXREG(SISSR, 0x16, v3); 5477 SiS_SetReg(SISSR, 0x16, v3);
5496 sisfb_post_xgi_delay(ivideo, 0x43); 5478 sisfb_post_xgi_delay(ivideo, 0x43);
5497 outSISIDXREG(SISSR, 0x1b, 0x03); 5479 SiS_SetReg(SISSR, 0x1b, 0x03);
5498 sisfb_post_xgi_delay(ivideo, 0x22); 5480 sisfb_post_xgi_delay(ivideo, 0x22);
5499 outSISIDXREG(SISSR, 0x18, v1); 5481 SiS_SetReg(SISSR, 0x18, v1);
5500 outSISIDXREG(SISSR, 0x19, 0x00); 5482 SiS_SetReg(SISSR, 0x19, 0x00);
5501 outSISIDXREG(SISSR, 0x16, v4); 5483 SiS_SetReg(SISSR, 0x16, v4);
5502 outSISIDXREG(SISSR, 0x16, v5); 5484 SiS_SetReg(SISSR, 0x16, v5);
5503 outSISIDXREG(SISSR, 0x1b, 0x00); 5485 SiS_SetReg(SISSR, 0x1b, 0x00);
5504 break; 5486 break;
5505 case 1: 5487 case 1:
5506 outSISIDXREG(SISCR, 0x82, 0x77); 5488 SiS_SetReg(SISCR, 0x82, 0x77);
5507 outSISIDXREG(SISCR, 0x86, 0x00); 5489 SiS_SetReg(SISCR, 0x86, 0x00);
5508 inSISIDXREG(SISCR, 0x86, reg); 5490 reg = SiS_GetReg(SISCR, 0x86);
5509 outSISIDXREG(SISCR, 0x86, 0x88); 5491 SiS_SetReg(SISCR, 0x86, 0x88);
5510 inSISIDXREG(SISCR, 0x86, reg); 5492 reg = SiS_GetReg(SISCR, 0x86);
5511 v1 = cs168[regb]; v2 = cs160[regb]; v3 = cs158[regb]; 5493 v1 = cs168[regb]; v2 = cs160[regb]; v3 = cs158[regb];
5512 if(ivideo->haveXGIROM) { 5494 if(ivideo->haveXGIROM) {
5513 v1 = bios[regb + 0x168]; 5495 v1 = bios[regb + 0x168];
5514 v2 = bios[regb + 0x160]; 5496 v2 = bios[regb + 0x160];
5515 v3 = bios[regb + 0x158]; 5497 v3 = bios[regb + 0x158];
5516 } 5498 }
5517 outSISIDXREG(SISCR, 0x86, v1); 5499 SiS_SetReg(SISCR, 0x86, v1);
5518 outSISIDXREG(SISCR, 0x82, 0x77); 5500 SiS_SetReg(SISCR, 0x82, 0x77);
5519 outSISIDXREG(SISCR, 0x85, 0x00); 5501 SiS_SetReg(SISCR, 0x85, 0x00);
5520 inSISIDXREG(SISCR, 0x85, reg); 5502 reg = SiS_GetReg(SISCR, 0x85);
5521 outSISIDXREG(SISCR, 0x85, 0x88); 5503 SiS_SetReg(SISCR, 0x85, 0x88);
5522 inSISIDXREG(SISCR, 0x85, reg); 5504 reg = SiS_GetReg(SISCR, 0x85);
5523 outSISIDXREG(SISCR, 0x85, v2); 5505 SiS_SetReg(SISCR, 0x85, v2);
5524 outSISIDXREG(SISCR, 0x82, v3); 5506 SiS_SetReg(SISCR, 0x82, v3);
5525 outSISIDXREG(SISCR, 0x98, 0x01); 5507 SiS_SetReg(SISCR, 0x98, 0x01);
5526 outSISIDXREG(SISCR, 0x9a, 0x02); 5508 SiS_SetReg(SISCR, 0x9a, 0x02);
5527 5509
5528 outSISIDXREG(SISSR, 0x28, 0x64); 5510 SiS_SetReg(SISSR, 0x28, 0x64);
5529 outSISIDXREG(SISSR, 0x29, 0x63); 5511 SiS_SetReg(SISSR, 0x29, 0x63);
5530 sisfb_post_xgi_delay(ivideo, 15); 5512 sisfb_post_xgi_delay(ivideo, 15);
5531 outSISIDXREG(SISSR, 0x18, 0x00); 5513 SiS_SetReg(SISSR, 0x18, 0x00);
5532 outSISIDXREG(SISSR, 0x19, 0x20); 5514 SiS_SetReg(SISSR, 0x19, 0x20);
5533 outSISIDXREG(SISSR, 0x16, 0x00); 5515 SiS_SetReg(SISSR, 0x16, 0x00);
5534 outSISIDXREG(SISSR, 0x16, 0x80); 5516 SiS_SetReg(SISSR, 0x16, 0x80);
5535 outSISIDXREG(SISSR, 0x18, 0xc5); 5517 SiS_SetReg(SISSR, 0x18, 0xc5);
5536 outSISIDXREG(SISSR, 0x19, 0x23); 5518 SiS_SetReg(SISSR, 0x19, 0x23);
5537 outSISIDXREG(SISSR, 0x16, 0x00); 5519 SiS_SetReg(SISSR, 0x16, 0x00);
5538 outSISIDXREG(SISSR, 0x16, 0x80); 5520 SiS_SetReg(SISSR, 0x16, 0x80);
5539 sisfb_post_xgi_delay(ivideo, 1); 5521 sisfb_post_xgi_delay(ivideo, 1);
5540 outSISIDXREG(SISCR, 0x97,0x11); 5522 SiS_SetReg(SISCR, 0x97, 0x11);
5541 sisfb_post_xgi_setclocks(ivideo, regb); 5523 sisfb_post_xgi_setclocks(ivideo, regb);
5542 sisfb_post_xgi_delay(ivideo, 0x46); 5524 sisfb_post_xgi_delay(ivideo, 0x46);
5543 outSISIDXREG(SISSR, 0x18, 0xc5); 5525 SiS_SetReg(SISSR, 0x18, 0xc5);
5544 outSISIDXREG(SISSR, 0x19, 0x23); 5526 SiS_SetReg(SISSR, 0x19, 0x23);
5545 outSISIDXREG(SISSR, 0x16, 0x00); 5527 SiS_SetReg(SISSR, 0x16, 0x00);
5546 outSISIDXREG(SISSR, 0x16, 0x80); 5528 SiS_SetReg(SISSR, 0x16, 0x80);
5547 sisfb_post_xgi_delay(ivideo, 1); 5529 sisfb_post_xgi_delay(ivideo, 1);
5548 outSISIDXREG(SISSR, 0x1b, 0x04); 5530 SiS_SetReg(SISSR, 0x1b, 0x04);
5549 sisfb_post_xgi_delay(ivideo, 1); 5531 sisfb_post_xgi_delay(ivideo, 1);
5550 outSISIDXREG(SISSR, 0x1b, 0x00); 5532 SiS_SetReg(SISSR, 0x1b, 0x00);
5551 sisfb_post_xgi_delay(ivideo, 1); 5533 sisfb_post_xgi_delay(ivideo, 1);
5552 v1 = 0x31; 5534 v1 = 0x31;
5553 if(ivideo->haveXGIROM) { 5535 if(ivideo->haveXGIROM) {
5554 v1 = bios[0xf0]; 5536 v1 = bios[0xf0];
5555 } 5537 }
5556 outSISIDXREG(SISSR, 0x18, v1); 5538 SiS_SetReg(SISSR, 0x18, v1);
5557 outSISIDXREG(SISSR, 0x19, 0x06); 5539 SiS_SetReg(SISSR, 0x19, 0x06);
5558 outSISIDXREG(SISSR, 0x16, 0x04); 5540 SiS_SetReg(SISSR, 0x16, 0x04);
5559 outSISIDXREG(SISSR, 0x16, 0x84); 5541 SiS_SetReg(SISSR, 0x16, 0x84);
5560 sisfb_post_xgi_delay(ivideo, 1); 5542 sisfb_post_xgi_delay(ivideo, 1);
5561 break; 5543 break;
5562 default: 5544 default:
@@ -5564,85 +5546,85 @@ sisfb_post_xgi(struct pci_dev *pdev)
5564 if((ivideo->chip == XGI_40) && 5546 if((ivideo->chip == XGI_40) &&
5565 ((ivideo->revision_id == 1) || 5547 ((ivideo->revision_id == 1) ||
5566 (ivideo->revision_id == 2))) { 5548 (ivideo->revision_id == 2))) {
5567 outSISIDXREG(SISCR, 0x82, bios[regb + 0x158]); 5549 SiS_SetReg(SISCR, 0x82, bios[regb + 0x158]);
5568 outSISIDXREG(SISCR, 0x85, bios[regb + 0x160]); 5550 SiS_SetReg(SISCR, 0x85, bios[regb + 0x160]);
5569 outSISIDXREG(SISCR, 0x86, bios[regb + 0x168]); 5551 SiS_SetReg(SISCR, 0x86, bios[regb + 0x168]);
5570 } else { 5552 } else {
5571 outSISIDXREG(SISCR, 0x82, 0x88); 5553 SiS_SetReg(SISCR, 0x82, 0x88);
5572 outSISIDXREG(SISCR, 0x86, 0x00); 5554 SiS_SetReg(SISCR, 0x86, 0x00);
5573 inSISIDXREG(SISCR, 0x86, reg); 5555 reg = SiS_GetReg(SISCR, 0x86);
5574 outSISIDXREG(SISCR, 0x86, 0x88); 5556 SiS_SetReg(SISCR, 0x86, 0x88);
5575 outSISIDXREG(SISCR, 0x82, 0x77); 5557 SiS_SetReg(SISCR, 0x82, 0x77);
5576 outSISIDXREG(SISCR, 0x85, 0x00); 5558 SiS_SetReg(SISCR, 0x85, 0x00);
5577 inSISIDXREG(SISCR, 0x85, reg); 5559 reg = SiS_GetReg(SISCR, 0x85);
5578 outSISIDXREG(SISCR, 0x85, 0x88); 5560 SiS_SetReg(SISCR, 0x85, 0x88);
5579 inSISIDXREG(SISCR, 0x85, reg); 5561 reg = SiS_GetReg(SISCR, 0x85);
5580 v1 = cs160[regb]; v2 = cs158[regb]; 5562 v1 = cs160[regb]; v2 = cs158[regb];
5581 if(ivideo->haveXGIROM) { 5563 if(ivideo->haveXGIROM) {
5582 v1 = bios[regb + 0x160]; 5564 v1 = bios[regb + 0x160];
5583 v2 = bios[regb + 0x158]; 5565 v2 = bios[regb + 0x158];
5584 } 5566 }
5585 outSISIDXREG(SISCR, 0x85, v1); 5567 SiS_SetReg(SISCR, 0x85, v1);
5586 outSISIDXREG(SISCR, 0x82, v2); 5568 SiS_SetReg(SISCR, 0x82, v2);
5587 } 5569 }
5588 if(ivideo->chip == XGI_40) { 5570 if(ivideo->chip == XGI_40) {
5589 outSISIDXREG(SISCR, 0x97, 0x11); 5571 SiS_SetReg(SISCR, 0x97, 0x11);
5590 } 5572 }
5591 if((ivideo->chip == XGI_40) && (ivideo->revision_id == 2)) { 5573 if((ivideo->chip == XGI_40) && (ivideo->revision_id == 2)) {
5592 outSISIDXREG(SISCR, 0x98, 0x01); 5574 SiS_SetReg(SISCR, 0x98, 0x01);
5593 } else { 5575 } else {
5594 outSISIDXREG(SISCR, 0x98, 0x03); 5576 SiS_SetReg(SISCR, 0x98, 0x03);
5595 } 5577 }
5596 outSISIDXREG(SISCR, 0x9a, 0x02); 5578 SiS_SetReg(SISCR, 0x9a, 0x02);
5597 5579
5598 if(ivideo->chip == XGI_40) { 5580 if(ivideo->chip == XGI_40) {
5599 outSISIDXREG(SISSR, 0x18, 0x01); 5581 SiS_SetReg(SISSR, 0x18, 0x01);
5600 } else { 5582 } else {
5601 outSISIDXREG(SISSR, 0x18, 0x00); 5583 SiS_SetReg(SISSR, 0x18, 0x00);
5602 } 5584 }
5603 outSISIDXREG(SISSR, 0x19, 0x40); 5585 SiS_SetReg(SISSR, 0x19, 0x40);
5604 outSISIDXREG(SISSR, 0x16, 0x00); 5586 SiS_SetReg(SISSR, 0x16, 0x00);
5605 outSISIDXREG(SISSR, 0x16, 0x80); 5587 SiS_SetReg(SISSR, 0x16, 0x80);
5606 if((ivideo->chip == XGI_40) && (bios[0x1cb] != 0x0c)) { 5588 if((ivideo->chip == XGI_40) && (bios[0x1cb] != 0x0c)) {
5607 sisfb_post_xgi_delay(ivideo, 0x43); 5589 sisfb_post_xgi_delay(ivideo, 0x43);
5608 sisfb_post_xgi_delay(ivideo, 0x43); 5590 sisfb_post_xgi_delay(ivideo, 0x43);
5609 sisfb_post_xgi_delay(ivideo, 0x43); 5591 sisfb_post_xgi_delay(ivideo, 0x43);
5610 outSISIDXREG(SISSR, 0x18, 0x00); 5592 SiS_SetReg(SISSR, 0x18, 0x00);
5611 outSISIDXREG(SISSR, 0x19, 0x40); 5593 SiS_SetReg(SISSR, 0x19, 0x40);
5612 outSISIDXREG(SISSR, 0x16, 0x00); 5594 SiS_SetReg(SISSR, 0x16, 0x00);
5613 outSISIDXREG(SISSR, 0x16, 0x80); 5595 SiS_SetReg(SISSR, 0x16, 0x80);
5614 } 5596 }
5615 sisfb_post_xgi_delay(ivideo, 4); 5597 sisfb_post_xgi_delay(ivideo, 4);
5616 v1 = 0x31; 5598 v1 = 0x31;
5617 if(ivideo->haveXGIROM) { 5599 if(ivideo->haveXGIROM) {
5618 v1 = bios[0xf0]; 5600 v1 = bios[0xf0];
5619 } 5601 }
5620 outSISIDXREG(SISSR, 0x18, v1); 5602 SiS_SetReg(SISSR, 0x18, v1);
5621 outSISIDXREG(SISSR, 0x19, 0x01); 5603 SiS_SetReg(SISSR, 0x19, 0x01);
5622 if(ivideo->chip == XGI_40) { 5604 if(ivideo->chip == XGI_40) {
5623 outSISIDXREG(SISSR, 0x16, bios[0x53e]); 5605 SiS_SetReg(SISSR, 0x16, bios[0x53e]);
5624 outSISIDXREG(SISSR, 0x16, bios[0x53f]); 5606 SiS_SetReg(SISSR, 0x16, bios[0x53f]);
5625 } else { 5607 } else {
5626 outSISIDXREG(SISSR, 0x16, 0x05); 5608 SiS_SetReg(SISSR, 0x16, 0x05);
5627 outSISIDXREG(SISSR, 0x16, 0x85); 5609 SiS_SetReg(SISSR, 0x16, 0x85);
5628 } 5610 }
5629 sisfb_post_xgi_delay(ivideo, 0x43); 5611 sisfb_post_xgi_delay(ivideo, 0x43);
5630 if(ivideo->chip == XGI_40) { 5612 if(ivideo->chip == XGI_40) {
5631 outSISIDXREG(SISSR, 0x1b, 0x01); 5613 SiS_SetReg(SISSR, 0x1b, 0x01);
5632 } else { 5614 } else {
5633 outSISIDXREG(SISSR, 0x1b, 0x03); 5615 SiS_SetReg(SISSR, 0x1b, 0x03);
5634 } 5616 }
5635 sisfb_post_xgi_delay(ivideo, 0x22); 5617 sisfb_post_xgi_delay(ivideo, 0x22);
5636 outSISIDXREG(SISSR, 0x18, v1); 5618 SiS_SetReg(SISSR, 0x18, v1);
5637 outSISIDXREG(SISSR, 0x19, 0x00); 5619 SiS_SetReg(SISSR, 0x19, 0x00);
5638 if(ivideo->chip == XGI_40) { 5620 if(ivideo->chip == XGI_40) {
5639 outSISIDXREG(SISSR, 0x16, bios[0x540]); 5621 SiS_SetReg(SISSR, 0x16, bios[0x540]);
5640 outSISIDXREG(SISSR, 0x16, bios[0x541]); 5622 SiS_SetReg(SISSR, 0x16, bios[0x541]);
5641 } else { 5623 } else {
5642 outSISIDXREG(SISSR, 0x16, 0x05); 5624 SiS_SetReg(SISSR, 0x16, 0x05);
5643 outSISIDXREG(SISSR, 0x16, 0x85); 5625 SiS_SetReg(SISSR, 0x16, 0x85);
5644 } 5626 }
5645 outSISIDXREG(SISSR, 0x1b, 0x00); 5627 SiS_SetReg(SISSR, 0x1b, 0x00);
5646 } 5628 }
5647 5629
5648 regb = 0; /* ! */ 5630 regb = 0; /* ! */
@@ -5650,7 +5632,7 @@ sisfb_post_xgi(struct pci_dev *pdev)
5650 if(ivideo->haveXGIROM) { 5632 if(ivideo->haveXGIROM) {
5651 v1 = bios[0x110 + regb]; 5633 v1 = bios[0x110 + regb];
5652 } 5634 }
5653 outSISIDXREG(SISSR, 0x1b, v1); 5635 SiS_SetReg(SISSR, 0x1b, v1);
5654 5636
5655 /* RAM size */ 5637 /* RAM size */
5656 v1 = 0x00; v2 = 0x00; 5638 v1 = 0x00; v2 = 0x00;
@@ -5662,8 +5644,8 @@ sisfb_post_xgi(struct pci_dev *pdev)
5662 regd = 1 << regb; 5644 regd = 1 << regb;
5663 if((v1 & 0x40) && (v2 & regd) && ivideo->haveXGIROM) { 5645 if((v1 & 0x40) && (v2 & regd) && ivideo->haveXGIROM) {
5664 5646
5665 outSISIDXREG(SISSR, 0x13, bios[regb + 0xe0]); 5647 SiS_SetReg(SISSR, 0x13, bios[regb + 0xe0]);
5666 outSISIDXREG(SISSR, 0x14, bios[regb + 0xe0 + 8]); 5648 SiS_SetReg(SISSR, 0x14, bios[regb + 0xe0 + 8]);
5667 5649
5668 } else { 5650 } else {
5669 5651
@@ -5675,24 +5657,24 @@ sisfb_post_xgi(struct pci_dev *pdev)
5675 ivideo->SiS_Pr.VideoMemorySize = 8 << 20; 5657 ivideo->SiS_Pr.VideoMemorySize = 8 << 20;
5676 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80); 5658 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80);
5677 5659
5678 outSISIDXREG(SISSR, 0x05, 0x86); 5660 SiS_SetReg(SISSR, 0x05, 0x86);
5679 5661
5680 /* Disable read-cache */ 5662 /* Disable read-cache */
5681 andSISIDXREG(SISSR, 0x21, 0xdf); 5663 SiS_SetRegAND(SISSR, 0x21, 0xdf);
5682 sisfb_post_xgi_ramsize(ivideo); 5664 sisfb_post_xgi_ramsize(ivideo);
5683 /* Enable read-cache */ 5665 /* Enable read-cache */
5684 orSISIDXREG(SISSR, 0x21, 0x20); 5666 SiS_SetRegOR(SISSR, 0x21, 0x20);
5685 5667
5686 } 5668 }
5687 5669
5688#if 0 5670#if 0
5689 printk(KERN_DEBUG "-----------------\n"); 5671 printk(KERN_DEBUG "-----------------\n");
5690 for(i = 0; i < 0xff; i++) { 5672 for(i = 0; i < 0xff; i++) {
5691 inSISIDXREG(SISCR, i, reg); 5673 reg = SiS_GetReg(SISCR, i);
5692 printk(KERN_DEBUG "CR%02x(%x) = 0x%02x\n", i, SISCR, reg); 5674 printk(KERN_DEBUG "CR%02x(%x) = 0x%02x\n", i, SISCR, reg);
5693 } 5675 }
5694 for(i = 0; i < 0x40; i++) { 5676 for(i = 0; i < 0x40; i++) {
5695 inSISIDXREG(SISSR, i, reg); 5677 reg = SiS_GetReg(SISSR, i);
5696 printk(KERN_DEBUG "SR%02x(%x) = 0x%02x\n", i, SISSR, reg); 5678 printk(KERN_DEBUG "SR%02x(%x) = 0x%02x\n", i, SISSR, reg);
5697 } 5679 }
5698 printk(KERN_DEBUG "-----------------\n"); 5680 printk(KERN_DEBUG "-----------------\n");
@@ -5700,13 +5682,13 @@ sisfb_post_xgi(struct pci_dev *pdev)
5700 5682
5701 /* Sense CRT1 */ 5683 /* Sense CRT1 */
5702 if(ivideo->chip == XGI_20) { 5684 if(ivideo->chip == XGI_20) {
5703 orSISIDXREG(SISCR, 0x32, 0x20); 5685 SiS_SetRegOR(SISCR, 0x32, 0x20);
5704 } else { 5686 } else {
5705 inSISIDXREG(SISPART4, 0x00, reg); 5687 reg = SiS_GetReg(SISPART4, 0x00);
5706 if((reg == 1) || (reg == 2)) { 5688 if((reg == 1) || (reg == 2)) {
5707 sisfb_sense_crt1(ivideo); 5689 sisfb_sense_crt1(ivideo);
5708 } else { 5690 } else {
5709 orSISIDXREG(SISCR, 0x32, 0x20); 5691 SiS_SetRegOR(SISCR, 0x32, 0x20);
5710 } 5692 }
5711 } 5693 }
5712 5694
@@ -5717,20 +5699,20 @@ sisfb_post_xgi(struct pci_dev *pdev)
5717 ivideo->curFSTN = ivideo->curDSTN = 0; 5699 ivideo->curFSTN = ivideo->curDSTN = 0;
5718 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80); 5700 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80);
5719 5701
5720 outSISIDXREG(SISSR, 0x05, 0x86); 5702 SiS_SetReg(SISSR, 0x05, 0x86);
5721 5703
5722 /* Display off */ 5704 /* Display off */
5723 orSISIDXREG(SISSR, 0x01, 0x20); 5705 SiS_SetRegOR(SISSR, 0x01, 0x20);
5724 5706
5725 /* Save mode number in CR34 */ 5707 /* Save mode number in CR34 */
5726 outSISIDXREG(SISCR, 0x34, 0x2e); 5708 SiS_SetReg(SISCR, 0x34, 0x2e);
5727 5709
5728 /* Let everyone know what the current mode is */ 5710 /* Let everyone know what the current mode is */
5729 ivideo->modeprechange = 0x2e; 5711 ivideo->modeprechange = 0x2e;
5730 5712
5731 if(ivideo->chip == XGI_40) { 5713 if(ivideo->chip == XGI_40) {
5732 inSISIDXREG(SISCR, 0xca, reg); 5714 reg = SiS_GetReg(SISCR, 0xca);
5733 inSISIDXREG(SISCR, 0xcc, v1); 5715 v1 = SiS_GetReg(SISCR, 0xcc);
5734 if((reg & 0x10) && (!(v1 & 0x04))) { 5716 if((reg & 0x10) && (!(v1 & 0x04))) {
5735 printk(KERN_ERR 5717 printk(KERN_ERR
5736 "sisfb: Please connect power to the card.\n"); 5718 "sisfb: Please connect power to the card.\n");
@@ -5973,7 +5955,7 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
5973 } 5955 }
5974#endif 5956#endif
5975 5957
5976 outSISIDXREG(SISSR, 0x05, 0x86); 5958 SiS_SetReg(SISSR, 0x05, 0x86);
5977 5959
5978 if( (!ivideo->sisvga_enabled) 5960 if( (!ivideo->sisvga_enabled)
5979#if !defined(__i386__) && !defined(__x86_64__) 5961#if !defined(__i386__) && !defined(__x86_64__)
@@ -5981,13 +5963,13 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
5981#endif 5963#endif
5982 ) { 5964 ) {
5983 for(i = 0x30; i <= 0x3f; i++) { 5965 for(i = 0x30; i <= 0x3f; i++) {
5984 outSISIDXREG(SISCR, i, 0x00); 5966 SiS_SetReg(SISCR, i, 0x00);
5985 } 5967 }
5986 } 5968 }
5987 5969
5988 /* Find out about current video mode */ 5970 /* Find out about current video mode */
5989 ivideo->modeprechange = 0x03; 5971 ivideo->modeprechange = 0x03;
5990 inSISIDXREG(SISCR, 0x34, reg); 5972 reg = SiS_GetReg(SISCR, 0x34);
5991 if(reg & 0x7f) { 5973 if(reg & 0x7f) {
5992 ivideo->modeprechange = reg & 0x7f; 5974 ivideo->modeprechange = reg & 0x7f;
5993 } else if(ivideo->sisvga_enabled) { 5975 } else if(ivideo->sisvga_enabled) {
@@ -6084,9 +6066,9 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
6084 if((ivideo->sisfb_mode_idx < 0) || 6066 if((ivideo->sisfb_mode_idx < 0) ||
6085 ((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF)) { 6067 ((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF)) {
6086 /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ 6068 /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */
6087 orSISIDXREG(SISSR, IND_SIS_PCI_ADDRESS_SET, (SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE)); 6069 SiS_SetRegOR(SISSR, IND_SIS_PCI_ADDRESS_SET, (SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE));
6088 /* Enable 2D accelerator engine */ 6070 /* Enable 2D accelerator engine */
6089 orSISIDXREG(SISSR, IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D); 6071 SiS_SetRegOR(SISSR, IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D);
6090 } 6072 }
6091 6073
6092 if(sisfb_pdc != 0xff) { 6074 if(sisfb_pdc != 0xff) {
diff --git a/drivers/video/sis/vgatypes.h b/drivers/video/sis/vgatypes.h
index 81a22eaabfde..12c0dfaf2518 100644
--- a/drivers/video/sis/vgatypes.h
+++ b/drivers/video/sis/vgatypes.h
@@ -55,21 +55,10 @@
55 55
56#define SISIOMEMTYPE 56#define SISIOMEMTYPE
57 57
58#ifdef SIS_LINUX_KERNEL
59typedef unsigned long SISIOADDRESS; 58typedef unsigned long SISIOADDRESS;
60#include <linux/types.h> /* Need __iomem */ 59#include <linux/types.h> /* Need __iomem */
61#undef SISIOMEMTYPE 60#undef SISIOMEMTYPE
62#define SISIOMEMTYPE __iomem 61#define SISIOMEMTYPE __iomem
63#endif
64
65#ifdef SIS_XORG_XF86
66#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0)
67typedef unsigned long IOADDRESS;
68typedef unsigned long SISIOADDRESS;
69#else
70typedef IOADDRESS SISIOADDRESS;
71#endif
72#endif
73 62
74typedef enum _SIS_CHIP_TYPE { 63typedef enum _SIS_CHIP_TYPE {
75 SIS_VGALegacy = 0, 64 SIS_VGALegacy = 0,
diff --git a/drivers/video/sis/vstruct.h b/drivers/video/sis/vstruct.h
index bef4aae388d0..ea94d214dcff 100644
--- a/drivers/video/sis/vstruct.h
+++ b/drivers/video/sis/vstruct.h
@@ -233,24 +233,15 @@ struct SiS_Private
233{ 233{
234 unsigned char ChipType; 234 unsigned char ChipType;
235 unsigned char ChipRevision; 235 unsigned char ChipRevision;
236#ifdef SIS_XORG_XF86
237 PCITAG PciTag;
238#endif
239#ifdef SIS_LINUX_KERNEL
240 void *ivideo; 236 void *ivideo;
241#endif
242 unsigned char *VirtualRomBase; 237 unsigned char *VirtualRomBase;
243 bool UseROM; 238 bool UseROM;
244#ifdef SIS_LINUX_KERNEL
245 unsigned char SISIOMEMTYPE *VideoMemoryAddress; 239 unsigned char SISIOMEMTYPE *VideoMemoryAddress;
246 unsigned int VideoMemorySize; 240 unsigned int VideoMemorySize;
247#endif
248 SISIOADDRESS IOAddress; 241 SISIOADDRESS IOAddress;
249 SISIOADDRESS IOAddress2; /* For dual chip XGI volari */ 242 SISIOADDRESS IOAddress2; /* For dual chip XGI volari */
250 243
251#ifdef SIS_LINUX_KERNEL
252 SISIOADDRESS RelIO; 244 SISIOADDRESS RelIO;
253#endif
254 SISIOADDRESS SiS_P3c4; 245 SISIOADDRESS SiS_P3c4;
255 SISIOADDRESS SiS_P3d4; 246 SISIOADDRESS SiS_P3d4;
256 SISIOADDRESS SiS_P3c0; 247 SISIOADDRESS SiS_P3c0;
@@ -280,9 +271,6 @@ struct SiS_Private
280 unsigned short SiS_IF_DEF_FSTN; 271 unsigned short SiS_IF_DEF_FSTN;
281 unsigned short SiS_SysFlags; 272 unsigned short SiS_SysFlags;
282 unsigned char SiS_VGAINFO; 273 unsigned char SiS_VGAINFO;
283#ifdef SIS_XORG_XF86
284 unsigned short SiS_CP1, SiS_CP2, SiS_CP3, SiS_CP4;
285#endif
286 bool SiS_UseROM; 274 bool SiS_UseROM;
287 bool SiS_ROMNew; 275 bool SiS_ROMNew;
288 bool SiS_XGIROM; 276 bool SiS_XGIROM;
diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
index 74a679ef0f5c..020589a6bf02 100644
--- a/drivers/video/udlfb.c
+++ b/drivers/video/udlfb.c
@@ -1404,7 +1404,7 @@ static struct device_attribute fb_device_attrs[] = {
1404 __ATTR_RO(metrics_bytes_identical), 1404 __ATTR_RO(metrics_bytes_identical),
1405 __ATTR_RO(metrics_bytes_sent), 1405 __ATTR_RO(metrics_bytes_sent),
1406 __ATTR_RO(metrics_cpu_kcycles_used), 1406 __ATTR_RO(metrics_cpu_kcycles_used),
1407 __ATTR(metrics_reset, S_IWUGO, NULL, metrics_reset_store), 1407 __ATTR(metrics_reset, S_IWUSR, NULL, metrics_reset_store),
1408}; 1408};
1409 1409
1410/* 1410/*
diff --git a/drivers/video/via/via-core.c b/drivers/video/via/via-core.c
index a3aa91709503..6723d6910cde 100644
--- a/drivers/video/via/via-core.c
+++ b/drivers/video/via/via-core.c
@@ -15,6 +15,9 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/list.h>
19#include <linux/pm.h>
20#include <asm/olpc.h>
18 21
19/* 22/*
20 * The default port config. 23 * The default port config.
@@ -29,6 +32,19 @@ static struct via_port_cfg adap_configs[] = {
29}; 32};
30 33
31/* 34/*
35 * The OLPC XO-1.5 puts the camera power and reset lines onto
36 * GPIO 2C.
37 */
38static const struct via_port_cfg olpc_adap_configs[] = {
39 [VIA_PORT_26] = { VIA_PORT_I2C, VIA_MODE_I2C, VIASR, 0x26 },
40 [VIA_PORT_31] = { VIA_PORT_I2C, VIA_MODE_I2C, VIASR, 0x31 },
41 [VIA_PORT_25] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x25 },
42 [VIA_PORT_2C] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x2c },
43 [VIA_PORT_3D] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x3d },
44 { 0, 0, 0, 0 }
45};
46
47/*
32 * We currently only support one viafb device (will there ever be 48 * We currently only support one viafb device (will there ever be
33 * more than one?), so just declare it globally here. 49 * more than one?), so just declare it globally here.
34 */ 50 */
@@ -575,6 +591,78 @@ static void via_teardown_subdevs(void)
575 } 591 }
576} 592}
577 593
594/*
595 * Power management functions
596 */
597#ifdef CONFIG_PM
598static LIST_HEAD(viafb_pm_hooks);
599static DEFINE_MUTEX(viafb_pm_hooks_lock);
600
601void viafb_pm_register(struct viafb_pm_hooks *hooks)
602{
603 INIT_LIST_HEAD(&hooks->list);
604
605 mutex_lock(&viafb_pm_hooks_lock);
606 list_add_tail(&hooks->list, &viafb_pm_hooks);
607 mutex_unlock(&viafb_pm_hooks_lock);
608}
609EXPORT_SYMBOL_GPL(viafb_pm_register);
610
611void viafb_pm_unregister(struct viafb_pm_hooks *hooks)
612{
613 mutex_lock(&viafb_pm_hooks_lock);
614 list_del(&hooks->list);
615 mutex_unlock(&viafb_pm_hooks_lock);
616}
617EXPORT_SYMBOL_GPL(viafb_pm_unregister);
618
619static int via_suspend(struct pci_dev *pdev, pm_message_t state)
620{
621 struct viafb_pm_hooks *hooks;
622
623 if (state.event != PM_EVENT_SUSPEND)
624 return 0;
625 /*
626 * "I've occasionally hit a few drivers that caused suspend
627 * failures, and each and every time it was a driver bug, and
628 * the right thing to do was to just ignore the error and suspend
629 * anyway - returning an error code and trying to undo the suspend
630 * is not what anybody ever really wants, even if our model
631 *_allows_ for it."
632 * -- Linus Torvalds, Dec. 7, 2009
633 */
634 mutex_lock(&viafb_pm_hooks_lock);
635 list_for_each_entry_reverse(hooks, &viafb_pm_hooks, list)
636 hooks->suspend(hooks->private);
637 mutex_unlock(&viafb_pm_hooks_lock);
638
639 pci_save_state(pdev);
640 pci_disable_device(pdev);
641 pci_set_power_state(pdev, pci_choose_state(pdev, state));
642 return 0;
643}
644
645static int via_resume(struct pci_dev *pdev)
646{
647 struct viafb_pm_hooks *hooks;
648
649 /* Get the bus side powered up */
650 pci_set_power_state(pdev, PCI_D0);
651 pci_restore_state(pdev);
652 if (pci_enable_device(pdev))
653 return 0;
654
655 pci_set_master(pdev);
656
657 /* Now bring back any subdevs */
658 mutex_lock(&viafb_pm_hooks_lock);
659 list_for_each_entry(hooks, &viafb_pm_hooks, list)
660 hooks->resume(hooks->private);
661 mutex_unlock(&viafb_pm_hooks_lock);
662
663 return 0;
664}
665#endif /* CONFIG_PM */
578 666
579static int __devinit via_pci_probe(struct pci_dev *pdev, 667static int __devinit via_pci_probe(struct pci_dev *pdev,
580 const struct pci_device_id *ent) 668 const struct pci_device_id *ent)
@@ -584,6 +672,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
584 ret = pci_enable_device(pdev); 672 ret = pci_enable_device(pdev);
585 if (ret) 673 if (ret)
586 return ret; 674 return ret;
675
587 /* 676 /*
588 * Global device initialization. 677 * Global device initialization.
589 */ 678 */
@@ -591,6 +680,9 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
591 global_dev.pdev = pdev; 680 global_dev.pdev = pdev;
592 global_dev.chip_type = ent->driver_data; 681 global_dev.chip_type = ent->driver_data;
593 global_dev.port_cfg = adap_configs; 682 global_dev.port_cfg = adap_configs;
683 if (machine_is_olpc())
684 global_dev.port_cfg = olpc_adap_configs;
685
594 spin_lock_init(&global_dev.reg_lock); 686 spin_lock_init(&global_dev.reg_lock);
595 ret = via_pci_setup_mmio(&global_dev); 687 ret = via_pci_setup_mmio(&global_dev);
596 if (ret) 688 if (ret)
@@ -663,8 +755,8 @@ static struct pci_driver via_driver = {
663 .probe = via_pci_probe, 755 .probe = via_pci_probe,
664 .remove = __devexit_p(via_pci_remove), 756 .remove = __devexit_p(via_pci_remove),
665#ifdef CONFIG_PM 757#ifdef CONFIG_PM
666 .suspend = viafb_suspend, 758 .suspend = via_suspend,
667 .resume = viafb_resume, 759 .resume = via_resume,
668#endif 760#endif
669}; 761};
670 762
diff --git a/drivers/video/via/via-gpio.c b/drivers/video/via/via-gpio.c
index 39acb37e7a1d..c2a0a1cfd3b3 100644
--- a/drivers/video/via/via-gpio.c
+++ b/drivers/video/via/via-gpio.c
@@ -172,6 +172,28 @@ static void viafb_gpio_disable(struct viafb_gpio *gpio)
172 via_write_reg_mask(VIASR, gpio->vg_port_index, 0, 0x02); 172 via_write_reg_mask(VIASR, gpio->vg_port_index, 0, 0x02);
173} 173}
174 174
175#ifdef CONFIG_PM
176
177static int viafb_gpio_suspend(void *private)
178{
179 return 0;
180}
181
182static int viafb_gpio_resume(void *private)
183{
184 int i;
185
186 for (i = 0; i < gpio_config.gpio_chip.ngpio; i += 2)
187 viafb_gpio_enable(gpio_config.active_gpios[i]);
188 return 0;
189}
190
191static struct viafb_pm_hooks viafb_gpio_pm_hooks = {
192 .suspend = viafb_gpio_suspend,
193 .resume = viafb_gpio_resume
194};
195#endif /* CONFIG_PM */
196
175/* 197/*
176 * Look up a specific gpio and return the number it was assigned. 198 * Look up a specific gpio and return the number it was assigned.
177 */ 199 */
@@ -236,6 +258,9 @@ static __devinit int viafb_gpio_probe(struct platform_device *platdev)
236 printk(KERN_ERR "viafb: failed to add gpios (%d)\n", ret); 258 printk(KERN_ERR "viafb: failed to add gpios (%d)\n", ret);
237 gpio_config.gpio_chip.ngpio = 0; 259 gpio_config.gpio_chip.ngpio = 0;
238 } 260 }
261#ifdef CONFIG_PM
262 viafb_pm_register(&viafb_gpio_pm_hooks);
263#endif
239 return ret; 264 return ret;
240} 265}
241 266
@@ -245,6 +270,10 @@ static int viafb_gpio_remove(struct platform_device *platdev)
245 unsigned long flags; 270 unsigned long flags;
246 int ret = 0, i; 271 int ret = 0, i;
247 272
273#ifdef CONFIG_PM
274 viafb_pm_unregister(&viafb_gpio_pm_hooks);
275#endif
276
248 /* 277 /*
249 * Get unregistered. 278 * Get unregistered.
250 */ 279 */
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index d298cfccd6fc..289edd519527 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1672,31 +1672,19 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres)
1672 1672
1673 1673
1674#ifdef CONFIG_PM 1674#ifdef CONFIG_PM
1675int viafb_suspend(struct pci_dev *pdev, pm_message_t state) 1675static int viafb_suspend(void *unused)
1676{ 1676{
1677 if (state.event == PM_EVENT_SUSPEND) { 1677 acquire_console_sem();
1678 acquire_console_sem(); 1678 fb_set_suspend(viafbinfo, 1);
1679 fb_set_suspend(viafbinfo, 1); 1679 viafb_sync(viafbinfo);
1680 1680 release_console_sem();
1681 viafb_sync(viafbinfo);
1682
1683 pci_save_state(pdev);
1684 pci_disable_device(pdev);
1685 pci_set_power_state(pdev, pci_choose_state(pdev, state));
1686 release_console_sem();
1687 }
1688 1681
1689 return 0; 1682 return 0;
1690} 1683}
1691 1684
1692int viafb_resume(struct pci_dev *pdev) 1685static int viafb_resume(void *unused)
1693{ 1686{
1694 acquire_console_sem(); 1687 acquire_console_sem();
1695 pci_set_power_state(pdev, PCI_D0);
1696 pci_restore_state(pdev);
1697 if (pci_enable_device(pdev))
1698 goto fail;
1699 pci_set_master(pdev);
1700 if (viaparinfo->shared->vdev->engine_mmio) 1688 if (viaparinfo->shared->vdev->engine_mmio)
1701 viafb_reset_engine(viaparinfo); 1689 viafb_reset_engine(viaparinfo);
1702 viafb_set_par(viafbinfo); 1690 viafb_set_par(viafbinfo);
@@ -1704,11 +1692,15 @@ int viafb_resume(struct pci_dev *pdev)
1704 viafb_set_par(viafbinfo1); 1692 viafb_set_par(viafbinfo1);
1705 fb_set_suspend(viafbinfo, 0); 1693 fb_set_suspend(viafbinfo, 0);
1706 1694
1707fail:
1708 release_console_sem(); 1695 release_console_sem();
1709 return 0; 1696 return 0;
1710} 1697}
1711 1698
1699static struct viafb_pm_hooks viafb_fb_pm_hooks = {
1700 .suspend = viafb_suspend,
1701 .resume = viafb_resume
1702};
1703
1712#endif 1704#endif
1713 1705
1714 1706
@@ -1899,6 +1891,10 @@ int __devinit via_fb_pci_probe(struct viafb_dev *vdev)
1899 1891
1900 viafb_init_proc(viaparinfo->shared); 1892 viafb_init_proc(viaparinfo->shared);
1901 viafb_init_dac(IGA2); 1893 viafb_init_dac(IGA2);
1894
1895#ifdef CONFIG_PM
1896 viafb_pm_register(&viafb_fb_pm_hooks);
1897#endif
1902 return 0; 1898 return 0;
1903 1899
1904out_fb_unreg: 1900out_fb_unreg:
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
index 4960e3da6645..d66f963e930e 100644
--- a/drivers/video/via/viafbdev.h
+++ b/drivers/video/via/viafbdev.h
@@ -108,6 +108,4 @@ void via_fb_pci_remove(struct pci_dev *pdev);
108/* Temporary */ 108/* Temporary */
109int viafb_init(void); 109int viafb_init(void);
110void viafb_exit(void); 110void viafb_exit(void);
111int viafb_suspend(struct pci_dev *pdev, pm_message_t state);
112int viafb_resume(struct pci_dev *pdev);
113#endif /* __VIAFBDEV_H__ */ 111#endif /* __VIAFBDEV_H__ */
diff --git a/drivers/video/vt8500lcdfb.c b/drivers/video/vt8500lcdfb.c
new file mode 100644
index 000000000000..7617f12e4fd7
--- /dev/null
+++ b/drivers/video/vt8500lcdfb.c
@@ -0,0 +1,447 @@
1/*
2 * linux/drivers/video/vt8500lcdfb.c
3 *
4 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
5 *
6 * Based on skeletonfb.c and pxafb.c
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
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
18#include <linux/module.h>
19#include <linux/kernel.h>
20#include <linux/errno.h>
21#include <linux/string.h>
22#include <linux/mm.h>
23#include <linux/slab.h>
24#include <linux/delay.h>
25#include <linux/fb.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/io.h>
29#include <linux/dma-mapping.h>
30#include <linux/platform_device.h>
31#include <linux/wait.h>
32
33#include <mach/vt8500fb.h>
34
35#include "vt8500lcdfb.h"
36#include "wmt_ge_rops.h"
37
38#define to_vt8500lcd_info(__info) container_of(__info, \
39 struct vt8500lcd_info, fb)
40
41static int vt8500lcd_set_par(struct fb_info *info)
42{
43 struct vt8500lcd_info *fbi = to_vt8500lcd_info(info);
44 int reg_bpp = 5; /* 16bpp */
45 int i;
46 unsigned long control0;
47
48 if (!fbi)
49 return -EINVAL;
50
51 if (info->var.bits_per_pixel <= 8) {
52 /* palettized */
53 info->var.red.offset = 0;
54 info->var.red.length = info->var.bits_per_pixel;
55 info->var.red.msb_right = 0;
56
57 info->var.green.offset = 0;
58 info->var.green.length = info->var.bits_per_pixel;
59 info->var.green.msb_right = 0;
60
61 info->var.blue.offset = 0;
62 info->var.blue.length = info->var.bits_per_pixel;
63 info->var.blue.msb_right = 0;
64
65 info->var.transp.offset = 0;
66 info->var.transp.length = 0;
67 info->var.transp.msb_right = 0;
68
69 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
70 info->fix.line_length = info->var.xres_virtual /
71 (8/info->var.bits_per_pixel);
72 } else {
73 /* non-palettized */
74 info->var.transp.offset = 0;
75 info->var.transp.length = 0;
76 info->var.transp.msb_right = 0;
77
78 if (info->var.bits_per_pixel == 16) {
79 /* RGB565 */
80 info->var.red.offset = 11;
81 info->var.red.length = 5;
82 info->var.red.msb_right = 0;
83 info->var.green.offset = 5;
84 info->var.green.length = 6;
85 info->var.green.msb_right = 0;
86 info->var.blue.offset = 0;
87 info->var.blue.length = 5;
88 info->var.blue.msb_right = 0;
89 } else {
90 /* Equal depths per channel */
91 info->var.red.offset = info->var.bits_per_pixel
92 * 2 / 3;
93 info->var.red.length = info->var.bits_per_pixel / 3;
94 info->var.red.msb_right = 0;
95 info->var.green.offset = info->var.bits_per_pixel / 3;
96 info->var.green.length = info->var.bits_per_pixel / 3;
97 info->var.green.msb_right = 0;
98 info->var.blue.offset = 0;
99 info->var.blue.length = info->var.bits_per_pixel / 3;
100 info->var.blue.msb_right = 0;
101 }
102
103 info->fix.visual = FB_VISUAL_TRUECOLOR;
104 info->fix.line_length = info->var.bits_per_pixel > 16 ?
105 info->var.xres_virtual << 2 :
106 info->var.xres_virtual << 1;
107 }
108
109 for (i = 0; i < 8; i++) {
110 if (bpp_values[i] == info->var.bits_per_pixel) {
111 reg_bpp = i;
112 continue;
113 }
114 }
115
116 control0 = readl(fbi->regbase) & ~0xf;
117 writel(0, fbi->regbase);
118 while (readl(fbi->regbase + 0x38) & 0x10)
119 /* wait */;
120 writel((((info->var.hsync_len - 1) & 0x3f) << 26)
121 | ((info->var.left_margin & 0xff) << 18)
122 | (((info->var.xres - 1) & 0x3ff) << 8)
123 | (info->var.right_margin & 0xff), fbi->regbase + 0x4);
124 writel((((info->var.vsync_len - 1) & 0x3f) << 26)
125 | ((info->var.upper_margin & 0xff) << 18)
126 | (((info->var.yres - 1) & 0x3ff) << 8)
127 | (info->var.lower_margin & 0xff), fbi->regbase + 0x8);
128 writel((((info->var.yres - 1) & 0x400) << 2)
129 | ((info->var.xres - 1) & 0x400), fbi->regbase + 0x10);
130 writel(0x80000000, fbi->regbase + 0x20);
131 writel(control0 | (reg_bpp << 1) | 0x100, fbi->regbase);
132
133 return 0;
134}
135
136static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf)
137{
138 chan &= 0xffff;
139 chan >>= 16 - bf->length;
140 return chan << bf->offset;
141}
142
143static int vt8500lcd_setcolreg(unsigned regno, unsigned red, unsigned green,
144 unsigned blue, unsigned transp,
145 struct fb_info *info) {
146 struct vt8500lcd_info *fbi = to_vt8500lcd_info(info);
147 int ret = 1;
148 unsigned int val;
149 if (regno >= 256)
150 return -EINVAL;
151
152 if (info->var.grayscale)
153 red = green = blue =
154 (19595 * red + 38470 * green + 7471 * blue) >> 16;
155
156 switch (fbi->fb.fix.visual) {
157 case FB_VISUAL_TRUECOLOR:
158 if (regno < 16) {
159 u32 *pal = fbi->fb.pseudo_palette;
160
161 val = chan_to_field(red, &fbi->fb.var.red);
162 val |= chan_to_field(green, &fbi->fb.var.green);
163 val |= chan_to_field(blue, &fbi->fb.var.blue);
164
165 pal[regno] = val;
166 ret = 0;
167 }
168 break;
169
170 case FB_VISUAL_STATIC_PSEUDOCOLOR:
171 case FB_VISUAL_PSEUDOCOLOR:
172 writew((red & 0xf800)
173 | ((green >> 5) & 0x7e0)
174 | ((blue >> 11) & 0x1f),
175 fbi->palette_cpu + sizeof(u16) * regno);
176 break;
177 }
178
179 return ret;
180}
181
182static int vt8500lcd_ioctl(struct fb_info *info, unsigned int cmd,
183 unsigned long arg)
184{
185 int ret = 0;
186 struct vt8500lcd_info *fbi = to_vt8500lcd_info(info);
187
188 if (cmd == FBIO_WAITFORVSYNC) {
189 /* Unmask End of Frame interrupt */
190 writel(0xffffffff ^ (1 << 3), fbi->regbase + 0x3c);
191 ret = wait_event_interruptible_timeout(fbi->wait,
192 readl(fbi->regbase + 0x38) & (1 << 3), HZ / 10);
193 /* Mask back to reduce unwanted interrupt traffic */
194 writel(0xffffffff, fbi->regbase + 0x3c);
195 if (ret < 0)
196 return ret;
197 if (ret == 0)
198 return -ETIMEDOUT;
199 }
200
201 return ret;
202}
203
204static int vt8500lcd_pan_display(struct fb_var_screeninfo *var,
205 struct fb_info *info)
206{
207 unsigned pixlen = info->fix.line_length / info->var.xres_virtual;
208 unsigned off = pixlen * var->xoffset
209 + info->fix.line_length * var->yoffset;
210 struct vt8500lcd_info *fbi = to_vt8500lcd_info(info);
211
212 writel((1 << 31)
213 | (((var->xres_virtual - var->xres) * pixlen / 4) << 20)
214 | (off >> 2), fbi->regbase + 0x20);
215 return 0;
216}
217
218static struct fb_ops vt8500lcd_ops = {
219 .owner = THIS_MODULE,
220 .fb_set_par = vt8500lcd_set_par,
221 .fb_setcolreg = vt8500lcd_setcolreg,
222 .fb_fillrect = wmt_ge_fillrect,
223 .fb_copyarea = wmt_ge_copyarea,
224 .fb_imageblit = sys_imageblit,
225 .fb_sync = wmt_ge_sync,
226 .fb_ioctl = vt8500lcd_ioctl,
227 .fb_pan_display = vt8500lcd_pan_display,
228};
229
230static irqreturn_t vt8500lcd_handle_irq(int irq, void *dev_id)
231{
232 struct vt8500lcd_info *fbi = dev_id;
233
234 if (readl(fbi->regbase + 0x38) & (1 << 3))
235 wake_up_interruptible(&fbi->wait);
236
237 writel(0xffffffff, fbi->regbase + 0x38);
238 return IRQ_HANDLED;
239}
240
241static int __devinit vt8500lcd_probe(struct platform_device *pdev)
242{
243 struct vt8500lcd_info *fbi;
244 struct resource *res;
245 struct vt8500fb_platform_data *pdata = pdev->dev.platform_data;
246 void *addr;
247 int irq, ret;
248
249 ret = -ENOMEM;
250 fbi = NULL;
251
252 fbi = kzalloc(sizeof(struct vt8500lcd_info) + sizeof(u32) * 16,
253 GFP_KERNEL);
254 if (!fbi) {
255 dev_err(&pdev->dev, "Failed to initialize framebuffer device\n");
256 ret = -ENOMEM;
257 goto failed;
258 }
259
260 strcpy(fbi->fb.fix.id, "VT8500 LCD");
261
262 fbi->fb.fix.type = FB_TYPE_PACKED_PIXELS;
263 fbi->fb.fix.xpanstep = 0;
264 fbi->fb.fix.ypanstep = 1;
265 fbi->fb.fix.ywrapstep = 0;
266 fbi->fb.fix.accel = FB_ACCEL_NONE;
267
268 fbi->fb.var.nonstd = 0;
269 fbi->fb.var.activate = FB_ACTIVATE_NOW;
270 fbi->fb.var.height = -1;
271 fbi->fb.var.width = -1;
272 fbi->fb.var.vmode = FB_VMODE_NONINTERLACED;
273
274 fbi->fb.fbops = &vt8500lcd_ops;
275 fbi->fb.flags = FBINFO_DEFAULT
276 | FBINFO_HWACCEL_COPYAREA
277 | FBINFO_HWACCEL_FILLRECT
278 | FBINFO_HWACCEL_YPAN
279 | FBINFO_VIRTFB
280 | FBINFO_PARTIAL_PAN_OK;
281 fbi->fb.node = -1;
282
283 addr = fbi;
284 addr = addr + sizeof(struct vt8500lcd_info);
285 fbi->fb.pseudo_palette = addr;
286
287 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
288 if (res == NULL) {
289 dev_err(&pdev->dev, "no I/O memory resource defined\n");
290 ret = -ENODEV;
291 goto failed_fbi;
292 }
293
294 res = request_mem_region(res->start, resource_size(res), "vt8500lcd");
295 if (res == NULL) {
296 dev_err(&pdev->dev, "failed to request I/O memory\n");
297 ret = -EBUSY;
298 goto failed_fbi;
299 }
300
301 fbi->regbase = ioremap(res->start, resource_size(res));
302 if (fbi->regbase == NULL) {
303 dev_err(&pdev->dev, "failed to map I/O memory\n");
304 ret = -EBUSY;
305 goto failed_free_res;
306 }
307
308 fbi->fb.fix.smem_start = pdata->video_mem_phys;
309 fbi->fb.fix.smem_len = pdata->video_mem_len;
310 fbi->fb.screen_base = pdata->video_mem_virt;
311
312 fbi->palette_size = PAGE_ALIGN(512);
313 fbi->palette_cpu = dma_alloc_coherent(&pdev->dev,
314 fbi->palette_size,
315 &fbi->palette_phys,
316 GFP_KERNEL);
317 if (fbi->palette_cpu == NULL) {
318 dev_err(&pdev->dev, "Failed to allocate palette buffer\n");
319 ret = -ENOMEM;
320 goto failed_free_io;
321 }
322
323 irq = platform_get_irq(pdev, 0);
324 if (irq < 0) {
325 dev_err(&pdev->dev, "no IRQ defined\n");
326 ret = -ENODEV;
327 goto failed_free_palette;
328 }
329
330 ret = request_irq(irq, vt8500lcd_handle_irq, IRQF_DISABLED, "LCD", fbi);
331 if (ret) {
332 dev_err(&pdev->dev, "request_irq failed: %d\n", ret);
333 ret = -EBUSY;
334 goto failed_free_palette;
335 }
336
337 init_waitqueue_head(&fbi->wait);
338
339 if (fb_alloc_cmap(&fbi->fb.cmap, 256, 0) < 0) {
340 dev_err(&pdev->dev, "Failed to allocate color map\n");
341 ret = -ENOMEM;
342 goto failed_free_irq;
343 }
344
345 fb_videomode_to_var(&fbi->fb.var, &pdata->mode);
346 fbi->fb.var.bits_per_pixel = pdata->bpp;
347 fbi->fb.var.xres_virtual = pdata->xres_virtual;
348 fbi->fb.var.yres_virtual = pdata->yres_virtual;
349
350 ret = vt8500lcd_set_par(&fbi->fb);
351 if (ret) {
352 dev_err(&pdev->dev, "Failed to set parameters\n");
353 goto failed_free_cmap;
354 }
355
356 writel(fbi->fb.fix.smem_start >> 22, fbi->regbase + 0x1c);
357 writel((fbi->palette_phys & 0xfffffe00) | 1, fbi->regbase + 0x18);
358
359 platform_set_drvdata(pdev, fbi);
360
361 ret = register_framebuffer(&fbi->fb);
362 if (ret < 0) {
363 dev_err(&pdev->dev,
364 "Failed to register framebuffer device: %d\n", ret);
365 goto failed_free_cmap;
366 }
367
368 /*
369 * Ok, now enable the LCD controller
370 */
371 writel(readl(fbi->regbase) | 1, fbi->regbase);
372
373 return 0;
374
375failed_free_cmap:
376 if (fbi->fb.cmap.len)
377 fb_dealloc_cmap(&fbi->fb.cmap);
378failed_free_irq:
379 free_irq(irq, fbi);
380failed_free_palette:
381 dma_free_coherent(&pdev->dev, fbi->palette_size,
382 fbi->palette_cpu, fbi->palette_phys);
383failed_free_io:
384 iounmap(fbi->regbase);
385failed_free_res:
386 release_mem_region(res->start, resource_size(res));
387failed_fbi:
388 platform_set_drvdata(pdev, NULL);
389 kfree(fbi);
390failed:
391 return ret;
392}
393
394static int __devexit vt8500lcd_remove(struct platform_device *pdev)
395{
396 struct vt8500lcd_info *fbi = platform_get_drvdata(pdev);
397 struct resource *res;
398 int irq;
399
400 unregister_framebuffer(&fbi->fb);
401
402 writel(0, fbi->regbase);
403
404 if (fbi->fb.cmap.len)
405 fb_dealloc_cmap(&fbi->fb.cmap);
406
407 irq = platform_get_irq(pdev, 0);
408 free_irq(irq, fbi);
409
410 dma_free_coherent(&pdev->dev, fbi->palette_size,
411 fbi->palette_cpu, fbi->palette_phys);
412
413 iounmap(fbi->regbase);
414
415 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
416 release_mem_region(res->start, resource_size(res));
417
418 kfree(fbi);
419
420 return 0;
421}
422
423static struct platform_driver vt8500lcd_driver = {
424 .probe = vt8500lcd_probe,
425 .remove = __devexit_p(vt8500lcd_remove),
426 .driver = {
427 .owner = THIS_MODULE,
428 .name = "vt8500-lcd",
429 },
430};
431
432static int __init vt8500lcd_init(void)
433{
434 return platform_driver_register(&vt8500lcd_driver);
435}
436
437static void __exit vt8500lcd_exit(void)
438{
439 platform_driver_unregister(&vt8500lcd_driver);
440}
441
442module_init(vt8500lcd_init);
443module_exit(vt8500lcd_exit);
444
445MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com>");
446MODULE_DESCRIPTION("LCD controller driver for VIA VT8500");
447MODULE_LICENSE("GPL");
diff --git a/drivers/video/vt8500lcdfb.h b/drivers/video/vt8500lcdfb.h
new file mode 100644
index 000000000000..36ca3ca09d83
--- /dev/null
+++ b/drivers/video/vt8500lcdfb.h
@@ -0,0 +1,34 @@
1/*
2 * linux/drivers/video/vt8500lcdfb.h
3 *
4 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
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
16struct vt8500lcd_info {
17 struct fb_info fb;
18 void __iomem *regbase;
19 void __iomem *palette_cpu;
20 dma_addr_t palette_phys;
21 size_t palette_size;
22 wait_queue_head_t wait;
23};
24
25static int bpp_values[] = {
26 1,
27 2,
28 4,
29 8,
30 12,
31 16,
32 18,
33 24,
34};
diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
new file mode 100644
index 000000000000..96e34a569169
--- /dev/null
+++ b/drivers/video/wm8505fb.c
@@ -0,0 +1,422 @@
1/*
2 * WonderMedia WM8505 Frame Buffer device driver
3 *
4 * Copyright (C) 2010 Ed Spiridonov <edo.rus@gmail.com>
5 * Based on vt8500lcdfb.c
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
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
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/errno.h>
20#include <linux/string.h>
21#include <linux/mm.h>
22#include <linux/slab.h>
23#include <linux/delay.h>
24#include <linux/fb.h>
25#include <linux/init.h>
26#include <linux/interrupt.h>
27#include <linux/io.h>
28#include <linux/dma-mapping.h>
29#include <linux/platform_device.h>
30#include <linux/wait.h>
31
32#include <mach/vt8500fb.h>
33
34#include "wm8505fb_regs.h"
35#include "wmt_ge_rops.h"
36
37#define DRIVER_NAME "wm8505-fb"
38
39#define to_wm8505fb_info(__info) container_of(__info, \
40 struct wm8505fb_info, fb)
41struct wm8505fb_info {
42 struct fb_info fb;
43 void __iomem *regbase;
44 unsigned int contrast;
45};
46
47
48static int wm8505fb_init_hw(struct fb_info *info)
49{
50 struct wm8505fb_info *fbi = to_wm8505fb_info(info);
51
52 int i;
53
54 /* I know the purpose only of few registers, so clear unknown */
55 for (i = 0; i < 0x200; i += 4)
56 writel(0, fbi->regbase + i);
57
58 /* Set frame buffer address */
59 writel(fbi->fb.fix.smem_start, fbi->regbase + WMT_GOVR_FBADDR);
60 writel(fbi->fb.fix.smem_start, fbi->regbase + WMT_GOVR_FBADDR1);
61
62 /* Set in-memory picture format to RGB 32bpp */
63 writel(0x1c, fbi->regbase + WMT_GOVR_COLORSPACE);
64 writel(1, fbi->regbase + WMT_GOVR_COLORSPACE1);
65
66 /* Virtual buffer size */
67 writel(info->var.xres, fbi->regbase + WMT_GOVR_XRES);
68 writel(info->var.xres_virtual, fbi->regbase + WMT_GOVR_XRES_VIRTUAL);
69
70 /* black magic ;) */
71 writel(0xf, fbi->regbase + WMT_GOVR_FHI);
72 writel(4, fbi->regbase + WMT_GOVR_DVO_SET);
73 writel(1, fbi->regbase + WMT_GOVR_MIF_ENABLE);
74 writel(1, fbi->regbase + WMT_GOVR_REG_UPDATE);
75
76 return 0;
77}
78
79static int wm8505fb_set_timing(struct fb_info *info)
80{
81 struct wm8505fb_info *fbi = to_wm8505fb_info(info);
82
83 int h_start = info->var.left_margin;
84 int h_end = h_start + info->var.xres;
85 int h_all = h_end + info->var.right_margin;
86 int h_sync = info->var.hsync_len;
87
88 int v_start = info->var.upper_margin;
89 int v_end = v_start + info->var.yres;
90 int v_all = v_end + info->var.lower_margin;
91 int v_sync = info->var.vsync_len;
92
93 writel(0, fbi->regbase + WMT_GOVR_TG);
94
95 writel(h_start, fbi->regbase + WMT_GOVR_TIMING_H_START);
96 writel(h_end, fbi->regbase + WMT_GOVR_TIMING_H_END);
97 writel(h_all, fbi->regbase + WMT_GOVR_TIMING_H_ALL);
98 writel(h_sync, fbi->regbase + WMT_GOVR_TIMING_H_SYNC);
99
100 writel(v_start, fbi->regbase + WMT_GOVR_TIMING_V_START);
101 writel(v_end, fbi->regbase + WMT_GOVR_TIMING_V_END);
102 writel(v_all, fbi->regbase + WMT_GOVR_TIMING_V_ALL);
103 writel(v_sync, fbi->regbase + WMT_GOVR_TIMING_V_SYNC);
104
105 writel(1, fbi->regbase + WMT_GOVR_TG);
106
107 return 0;
108}
109
110
111static int wm8505fb_set_par(struct fb_info *info)
112{
113 struct wm8505fb_info *fbi = to_wm8505fb_info(info);
114
115 if (!fbi)
116 return -EINVAL;
117
118 if (info->var.bits_per_pixel == 32) {
119 info->var.red.offset = 16;
120 info->var.red.length = 8;
121 info->var.red.msb_right = 0;
122 info->var.green.offset = 8;
123 info->var.green.length = 8;
124 info->var.green.msb_right = 0;
125 info->var.blue.offset = 0;
126 info->var.blue.length = 8;
127 info->var.blue.msb_right = 0;
128 info->fix.visual = FB_VISUAL_TRUECOLOR;
129 info->fix.line_length = info->var.xres_virtual << 2;
130 }
131
132 wm8505fb_set_timing(info);
133
134 writel(fbi->contrast<<16 | fbi->contrast<<8 | fbi->contrast,
135 fbi->regbase + WMT_GOVR_CONTRAST);
136
137 return 0;
138}
139
140static ssize_t contrast_show(struct device *dev,
141 struct device_attribute *attr, char *buf)
142{
143 struct fb_info *info = dev_get_drvdata(dev);
144 struct wm8505fb_info *fbi = to_wm8505fb_info(info);
145
146 return sprintf(buf, "%d\n", fbi->contrast);
147}
148
149static ssize_t contrast_store(struct device *dev,
150 struct device_attribute *attr,
151 const char *buf, size_t count)
152{
153 struct fb_info *info = dev_get_drvdata(dev);
154 struct wm8505fb_info *fbi = to_wm8505fb_info(info);
155 unsigned long tmp;
156
157 if (strict_strtoul(buf, 10, &tmp) || (tmp > 0xff))
158 return -EINVAL;
159 fbi->contrast = tmp;
160
161 wm8505fb_set_par(info);
162
163 return count;
164}
165
166static DEVICE_ATTR(contrast, 0644, contrast_show, contrast_store);
167
168static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf)
169{
170 chan &= 0xffff;
171 chan >>= 16 - bf->length;
172 return chan << bf->offset;
173}
174
175static int wm8505fb_setcolreg(unsigned regno, unsigned red, unsigned green,
176 unsigned blue, unsigned transp,
177 struct fb_info *info) {
178 struct wm8505fb_info *fbi = to_wm8505fb_info(info);
179 int ret = 1;
180 unsigned int val;
181 if (regno >= 256)
182 return -EINVAL;
183
184 if (info->var.grayscale)
185 red = green = blue =
186 (19595 * red + 38470 * green + 7471 * blue) >> 16;
187
188 switch (fbi->fb.fix.visual) {
189 case FB_VISUAL_TRUECOLOR:
190 if (regno < 16) {
191 u32 *pal = info->pseudo_palette;
192
193 val = chan_to_field(red, &fbi->fb.var.red);
194 val |= chan_to_field(green, &fbi->fb.var.green);
195 val |= chan_to_field(blue, &fbi->fb.var.blue);
196
197 pal[regno] = val;
198 ret = 0;
199 }
200 break;
201 }
202
203 return ret;
204}
205
206static int wm8505fb_pan_display(struct fb_var_screeninfo *var,
207 struct fb_info *info)
208{
209 struct wm8505fb_info *fbi = to_wm8505fb_info(info);
210
211 writel(var->xoffset, fbi->regbase + WMT_GOVR_XPAN);
212 writel(var->yoffset, fbi->regbase + WMT_GOVR_YPAN);
213 return 0;
214}
215
216static int wm8505fb_blank(int blank, struct fb_info *info)
217{
218 struct wm8505fb_info *fbi = to_wm8505fb_info(info);
219
220 switch (blank) {
221 case FB_BLANK_UNBLANK:
222 wm8505fb_set_timing(info);
223 break;
224 default:
225 writel(0, fbi->regbase + WMT_GOVR_TIMING_V_SYNC);
226 break;
227 }
228
229 return 0;
230}
231
232static struct fb_ops wm8505fb_ops = {
233 .owner = THIS_MODULE,
234 .fb_set_par = wm8505fb_set_par,
235 .fb_setcolreg = wm8505fb_setcolreg,
236 .fb_fillrect = wmt_ge_fillrect,
237 .fb_copyarea = wmt_ge_copyarea,
238 .fb_imageblit = sys_imageblit,
239 .fb_sync = wmt_ge_sync,
240 .fb_pan_display = wm8505fb_pan_display,
241 .fb_blank = wm8505fb_blank,
242};
243
244static int __devinit wm8505fb_probe(struct platform_device *pdev)
245{
246 struct wm8505fb_info *fbi;
247 struct resource *res;
248 void *addr;
249 struct vt8500fb_platform_data *pdata;
250 int ret;
251
252 pdata = pdev->dev.platform_data;
253
254 ret = -ENOMEM;
255 fbi = NULL;
256
257 fbi = kzalloc(sizeof(struct wm8505fb_info) + sizeof(u32) * 16,
258 GFP_KERNEL);
259 if (!fbi) {
260 dev_err(&pdev->dev, "Failed to initialize framebuffer device\n");
261 ret = -ENOMEM;
262 goto failed;
263 }
264
265 strcpy(fbi->fb.fix.id, DRIVER_NAME);
266
267 fbi->fb.fix.type = FB_TYPE_PACKED_PIXELS;
268 fbi->fb.fix.xpanstep = 1;
269 fbi->fb.fix.ypanstep = 1;
270 fbi->fb.fix.ywrapstep = 0;
271 fbi->fb.fix.accel = FB_ACCEL_NONE;
272
273 fbi->fb.fbops = &wm8505fb_ops;
274 fbi->fb.flags = FBINFO_DEFAULT
275 | FBINFO_HWACCEL_COPYAREA
276 | FBINFO_HWACCEL_FILLRECT
277 | FBINFO_HWACCEL_XPAN
278 | FBINFO_HWACCEL_YPAN
279 | FBINFO_VIRTFB
280 | FBINFO_PARTIAL_PAN_OK;
281 fbi->fb.node = -1;
282
283 addr = fbi;
284 addr = addr + sizeof(struct wm8505fb_info);
285 fbi->fb.pseudo_palette = addr;
286
287 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
288 if (res == NULL) {
289 dev_err(&pdev->dev, "no I/O memory resource defined\n");
290 ret = -ENODEV;
291 goto failed_fbi;
292 }
293
294 res = request_mem_region(res->start, resource_size(res), DRIVER_NAME);
295 if (res == NULL) {
296 dev_err(&pdev->dev, "failed to request I/O memory\n");
297 ret = -EBUSY;
298 goto failed_fbi;
299 }
300
301 fbi->regbase = ioremap(res->start, resource_size(res));
302 if (fbi->regbase == NULL) {
303 dev_err(&pdev->dev, "failed to map I/O memory\n");
304 ret = -EBUSY;
305 goto failed_free_res;
306 }
307
308 fb_videomode_to_var(&fbi->fb.var, &pdata->mode);
309
310 fbi->fb.var.nonstd = 0;
311 fbi->fb.var.activate = FB_ACTIVATE_NOW;
312
313 fbi->fb.var.height = -1;
314 fbi->fb.var.width = -1;
315 fbi->fb.var.xres_virtual = pdata->xres_virtual;
316 fbi->fb.var.yres_virtual = pdata->yres_virtual;
317 fbi->fb.var.bits_per_pixel = pdata->bpp;
318
319 fbi->fb.fix.smem_start = pdata->video_mem_phys;
320 fbi->fb.fix.smem_len = pdata->video_mem_len;
321 fbi->fb.screen_base = pdata->video_mem_virt;
322 fbi->fb.screen_size = pdata->video_mem_len;
323
324 if (fb_alloc_cmap(&fbi->fb.cmap, 256, 0) < 0) {
325 dev_err(&pdev->dev, "Failed to allocate color map\n");
326 ret = -ENOMEM;
327 goto failed_free_io;
328 }
329
330 wm8505fb_init_hw(&fbi->fb);
331
332 fbi->contrast = 0x80;
333 ret = wm8505fb_set_par(&fbi->fb);
334 if (ret) {
335 dev_err(&pdev->dev, "Failed to set parameters\n");
336 goto failed_free_cmap;
337 }
338
339 platform_set_drvdata(pdev, fbi);
340
341 ret = register_framebuffer(&fbi->fb);
342 if (ret < 0) {
343 dev_err(&pdev->dev,
344 "Failed to register framebuffer device: %d\n", ret);
345 goto failed_free_cmap;
346 }
347
348 ret = device_create_file(&pdev->dev, &dev_attr_contrast);
349 if (ret < 0) {
350 printk(KERN_WARNING "fb%d: failed to register attributes (%d)\n",
351 fbi->fb.node, ret);
352 }
353
354 printk(KERN_INFO "fb%d: %s frame buffer at 0x%lx-0x%lx\n",
355 fbi->fb.node, fbi->fb.fix.id, fbi->fb.fix.smem_start,
356 fbi->fb.fix.smem_start + fbi->fb.fix.smem_len - 1);
357
358 return 0;
359
360failed_free_cmap:
361 if (fbi->fb.cmap.len)
362 fb_dealloc_cmap(&fbi->fb.cmap);
363failed_free_io:
364 iounmap(fbi->regbase);
365failed_free_res:
366 release_mem_region(res->start, resource_size(res));
367failed_fbi:
368 platform_set_drvdata(pdev, NULL);
369 kfree(fbi);
370failed:
371 return ret;
372}
373
374static int __devexit wm8505fb_remove(struct platform_device *pdev)
375{
376 struct wm8505fb_info *fbi = platform_get_drvdata(pdev);
377 struct resource *res;
378
379 device_remove_file(&pdev->dev, &dev_attr_contrast);
380
381 unregister_framebuffer(&fbi->fb);
382
383 writel(0, fbi->regbase);
384
385 if (fbi->fb.cmap.len)
386 fb_dealloc_cmap(&fbi->fb.cmap);
387
388 iounmap(fbi->regbase);
389
390 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
391 release_mem_region(res->start, resource_size(res));
392
393 kfree(fbi);
394
395 return 0;
396}
397
398static struct platform_driver wm8505fb_driver = {
399 .probe = wm8505fb_probe,
400 .remove = __devexit_p(wm8505fb_remove),
401 .driver = {
402 .owner = THIS_MODULE,
403 .name = DRIVER_NAME,
404 },
405};
406
407static int __init wm8505fb_init(void)
408{
409 return platform_driver_register(&wm8505fb_driver);
410}
411
412static void __exit wm8505fb_exit(void)
413{
414 platform_driver_unregister(&wm8505fb_driver);
415}
416
417module_init(wm8505fb_init);
418module_exit(wm8505fb_exit);
419
420MODULE_AUTHOR("Ed Spiridonov <edo.rus@gmail.com>");
421MODULE_DESCRIPTION("Framebuffer driver for WMT WM8505");
422MODULE_LICENSE("GPL");
diff --git a/drivers/video/wm8505fb_regs.h b/drivers/video/wm8505fb_regs.h
new file mode 100644
index 000000000000..4dd41668c6d1
--- /dev/null
+++ b/drivers/video/wm8505fb_regs.h
@@ -0,0 +1,76 @@
1/*
2 * GOVR registers list for WM8505 chips
3 *
4 * Copyright (C) 2010 Ed Spiridonov <edo.rus@gmail.com>
5 * Based on VIA/WonderMedia wm8510-govrh-reg.h
6 * http://github.com/projectgus/kernel_wm8505/blob/wm8505_2.6.29/
7 * drivers/video/wmt/register/wm8510/wm8510-govrh-reg.h
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
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
19#ifndef _WM8505FB_REGS_H
20#define _WM8505FB_REGS_H
21
22/*
23 * Color space select register, default value 0x1c
24 * BIT0 GOVRH_DVO_YUV2RGB_ENABLE
25 * BIT1 GOVRH_VGA_YUV2RGB_ENABLE
26 * BIT2 GOVRH_RGB_MODE
27 * BIT3 GOVRH_DAC_CLKINV
28 * BIT4 GOVRH_BLANK_ZERO
29 */
30#define WMT_GOVR_COLORSPACE 0x1e4
31/*
32 * Another colorspace select register, default value 1
33 * BIT0 GOVRH_DVO_RGB
34 * BIT1 GOVRH_DVO_YUV422
35 */
36#define WMT_GOVR_COLORSPACE1 0x30
37
38#define WMT_GOVR_CONTRAST 0x1b8
39#define WMT_GOVR_BRGHTNESS 0x1bc /* incompatible with RGB? */
40
41/* Framubeffer address */
42#define WMT_GOVR_FBADDR 0x90
43#define WMT_GOVR_FBADDR1 0x94 /* UV offset in YUV mode */
44
45/* Offset of visible window */
46#define WMT_GOVR_XPAN 0xa4
47#define WMT_GOVR_YPAN 0xa0
48
49#define WMT_GOVR_XRES 0x98
50#define WMT_GOVR_XRES_VIRTUAL 0x9c
51
52#define WMT_GOVR_MIF_ENABLE 0x80
53#define WMT_GOVR_FHI 0xa8
54#define WMT_GOVR_REG_UPDATE 0xe4
55
56/*
57 * BIT0 GOVRH_DVO_OUTWIDTH
58 * BIT1 GOVRH_DVO_SYNC_POLAR
59 * BIT2 GOVRH_DVO_ENABLE
60 */
61#define WMT_GOVR_DVO_SET 0x148
62
63/* Timing generator? */
64#define WMT_GOVR_TG 0x100
65
66/* Timings */
67#define WMT_GOVR_TIMING_H_ALL 0x108
68#define WMT_GOVR_TIMING_V_ALL 0x10c
69#define WMT_GOVR_TIMING_V_START 0x110
70#define WMT_GOVR_TIMING_V_END 0x114
71#define WMT_GOVR_TIMING_H_START 0x118
72#define WMT_GOVR_TIMING_H_END 0x11c
73#define WMT_GOVR_TIMING_V_SYNC 0x128
74#define WMT_GOVR_TIMING_H_SYNC 0x12c
75
76#endif /* _WM8505FB_REGS_H */
diff --git a/drivers/video/wmt_ge_rops.c b/drivers/video/wmt_ge_rops.c
new file mode 100644
index 000000000000..45832b7ef7d2
--- /dev/null
+++ b/drivers/video/wmt_ge_rops.c
@@ -0,0 +1,186 @@
1/*
2 * linux/drivers/video/wmt_ge_rops.c
3 *
4 * Accelerators for raster operations using WonderMedia Graphics Engine
5 *
6 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
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
18#include <linux/module.h>
19#include <linux/fb.h>
20#include <linux/platform_device.h>
21#include "fb_draw.h"
22
23#define GE_COMMAND_OFF 0x00
24#define GE_DEPTH_OFF 0x04
25#define GE_HIGHCOLOR_OFF 0x08
26#define GE_ROPCODE_OFF 0x14
27#define GE_FIRE_OFF 0x18
28#define GE_SRCBASE_OFF 0x20
29#define GE_SRCDISPW_OFF 0x24
30#define GE_SRCDISPH_OFF 0x28
31#define GE_SRCAREAX_OFF 0x2c
32#define GE_SRCAREAY_OFF 0x30
33#define GE_SRCAREAW_OFF 0x34
34#define GE_SRCAREAH_OFF 0x38
35#define GE_DESTBASE_OFF 0x3c
36#define GE_DESTDISPW_OFF 0x40
37#define GE_DESTDISPH_OFF 0x44
38#define GE_DESTAREAX_OFF 0x48
39#define GE_DESTAREAY_OFF 0x4c
40#define GE_DESTAREAW_OFF 0x50
41#define GE_DESTAREAH_OFF 0x54
42#define GE_PAT0C_OFF 0x88 /* Pattern 0 color */
43#define GE_ENABLE_OFF 0xec
44#define GE_INTEN_OFF 0xf0
45#define GE_STATUS_OFF 0xf8
46
47static void __iomem *regbase;
48
49void wmt_ge_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
50{
51 unsigned long fg, pat;
52
53 if (p->state != FBINFO_STATE_RUNNING)
54 return;
55
56 if (p->fix.visual == FB_VISUAL_TRUECOLOR ||
57 p->fix.visual == FB_VISUAL_DIRECTCOLOR)
58 fg = ((u32 *) (p->pseudo_palette))[rect->color];
59 else
60 fg = rect->color;
61
62 pat = pixel_to_pat(p->var.bits_per_pixel, fg);
63
64 if (p->fbops->fb_sync)
65 p->fbops->fb_sync(p);
66
67 writel(p->var.bits_per_pixel == 32 ? 3 :
68 (p->var.bits_per_pixel == 8 ? 0 : 1), regbase + GE_DEPTH_OFF);
69 writel(p->var.bits_per_pixel == 15 ? 1 : 0, regbase + GE_HIGHCOLOR_OFF);
70 writel(p->fix.smem_start, regbase + GE_DESTBASE_OFF);
71 writel(p->var.xres_virtual - 1, regbase + GE_DESTDISPW_OFF);
72 writel(p->var.yres_virtual - 1, regbase + GE_DESTDISPH_OFF);
73 writel(rect->dx, regbase + GE_DESTAREAX_OFF);
74 writel(rect->dy, regbase + GE_DESTAREAY_OFF);
75 writel(rect->width - 1, regbase + GE_DESTAREAW_OFF);
76 writel(rect->height - 1, regbase + GE_DESTAREAH_OFF);
77
78 writel(pat, regbase + GE_PAT0C_OFF);
79 writel(1, regbase + GE_COMMAND_OFF);
80 writel(rect->rop == ROP_XOR ? 0x5a : 0xf0, regbase + GE_ROPCODE_OFF);
81 writel(1, regbase + GE_FIRE_OFF);
82}
83EXPORT_SYMBOL_GPL(wmt_ge_fillrect);
84
85void wmt_ge_copyarea(struct fb_info *p, const struct fb_copyarea *area)
86{
87 if (p->state != FBINFO_STATE_RUNNING)
88 return;
89
90 if (p->fbops->fb_sync)
91 p->fbops->fb_sync(p);
92
93 writel(p->var.bits_per_pixel > 16 ? 3 :
94 (p->var.bits_per_pixel > 8 ? 1 : 0), regbase + GE_DEPTH_OFF);
95
96 writel(p->fix.smem_start, regbase + GE_SRCBASE_OFF);
97 writel(p->var.xres_virtual - 1, regbase + GE_SRCDISPW_OFF);
98 writel(p->var.yres_virtual - 1, regbase + GE_SRCDISPH_OFF);
99 writel(area->sx, regbase + GE_SRCAREAX_OFF);
100 writel(area->sy, regbase + GE_SRCAREAY_OFF);
101 writel(area->width - 1, regbase + GE_SRCAREAW_OFF);
102 writel(area->height - 1, regbase + GE_SRCAREAH_OFF);
103
104 writel(p->fix.smem_start, regbase + GE_DESTBASE_OFF);
105 writel(p->var.xres_virtual - 1, regbase + GE_DESTDISPW_OFF);
106 writel(p->var.yres_virtual - 1, regbase + GE_DESTDISPH_OFF);
107 writel(area->dx, regbase + GE_DESTAREAX_OFF);
108 writel(area->dy, regbase + GE_DESTAREAY_OFF);
109 writel(area->width - 1, regbase + GE_DESTAREAW_OFF);
110 writel(area->height - 1, regbase + GE_DESTAREAH_OFF);
111
112 writel(0xcc, regbase + GE_ROPCODE_OFF);
113 writel(1, regbase + GE_COMMAND_OFF);
114 writel(1, regbase + GE_FIRE_OFF);
115}
116EXPORT_SYMBOL_GPL(wmt_ge_copyarea);
117
118int wmt_ge_sync(struct fb_info *p)
119{
120 int loops = 5000000;
121 while ((readl(regbase + GE_STATUS_OFF) & 4) && --loops)
122 cpu_relax();
123 return loops > 0 ? 0 : -EBUSY;
124}
125EXPORT_SYMBOL_GPL(wmt_ge_sync);
126
127static int __devinit wmt_ge_rops_probe(struct platform_device *pdev)
128{
129 struct resource *res;
130
131 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
132 if (res == NULL) {
133 dev_err(&pdev->dev, "no I/O memory resource defined\n");
134 return -ENODEV;
135 }
136
137 /* Only one ROP engine is presently supported. */
138 if (unlikely(regbase)) {
139 WARN_ON(1);
140 return -EBUSY;
141 }
142
143 regbase = ioremap(res->start, resource_size(res));
144 if (regbase == NULL) {
145 dev_err(&pdev->dev, "failed to map I/O memory\n");
146 return -EBUSY;
147 }
148
149 writel(1, regbase + GE_ENABLE_OFF);
150 printk(KERN_INFO "Enabled support for WMT GE raster acceleration\n");
151
152 return 0;
153}
154
155static int __devexit wmt_ge_rops_remove(struct platform_device *pdev)
156{
157 iounmap(regbase);
158 return 0;
159}
160
161static struct platform_driver wmt_ge_rops_driver = {
162 .probe = wmt_ge_rops_probe,
163 .remove = __devexit_p(wmt_ge_rops_remove),
164 .driver = {
165 .owner = THIS_MODULE,
166 .name = "wmt_ge_rops",
167 },
168};
169
170static int __init wmt_ge_rops_init(void)
171{
172 return platform_driver_register(&wmt_ge_rops_driver);
173}
174
175static void __exit wmt_ge_rops_exit(void)
176{
177 platform_driver_unregister(&wmt_ge_rops_driver);
178}
179
180module_init(wmt_ge_rops_init);
181module_exit(wmt_ge_rops_exit);
182
183MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com");
184MODULE_DESCRIPTION("Accelerators for raster operations using "
185 "WonderMedia Graphics Engine");
186MODULE_LICENSE("GPL");
diff --git a/drivers/video/wmt_ge_rops.h b/drivers/video/wmt_ge_rops.h
new file mode 100644
index 000000000000..87380751a443
--- /dev/null
+++ b/drivers/video/wmt_ge_rops.h
@@ -0,0 +1,5 @@
1extern void wmt_ge_fillrect(struct fb_info *info,
2 const struct fb_fillrect *rect);
3extern void wmt_ge_copyarea(struct fb_info *info,
4 const struct fb_copyarea *area);
5extern int wmt_ge_sync(struct fb_info *info);
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 3a43ebf83a49..efb35aa8309a 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -9,19 +9,19 @@ static ssize_t device_show(struct device *_d,
9 struct device_attribute *attr, char *buf) 9 struct device_attribute *attr, char *buf)
10{ 10{
11 struct virtio_device *dev = container_of(_d,struct virtio_device,dev); 11 struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
12 return sprintf(buf, "%hu", dev->id.device); 12 return sprintf(buf, "0x%04x\n", dev->id.device);
13} 13}
14static ssize_t vendor_show(struct device *_d, 14static ssize_t vendor_show(struct device *_d,
15 struct device_attribute *attr, char *buf) 15 struct device_attribute *attr, char *buf)
16{ 16{
17 struct virtio_device *dev = container_of(_d,struct virtio_device,dev); 17 struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
18 return sprintf(buf, "%hu", dev->id.vendor); 18 return sprintf(buf, "0x%04x\n", dev->id.vendor);
19} 19}
20static ssize_t status_show(struct device *_d, 20static ssize_t status_show(struct device *_d,
21 struct device_attribute *attr, char *buf) 21 struct device_attribute *attr, char *buf)
22{ 22{
23 struct virtio_device *dev = container_of(_d,struct virtio_device,dev); 23 struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
24 return sprintf(buf, "0x%08x", dev->config->get_status(dev)); 24 return sprintf(buf, "0x%08x\n", dev->config->get_status(dev));
25} 25}
26static ssize_t modalias_show(struct device *_d, 26static ssize_t modalias_show(struct device *_d,
27 struct device_attribute *attr, char *buf) 27 struct device_attribute *attr, char *buf)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 1475ed6b575f..cc2f73e03475 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -230,9 +230,6 @@ add_head:
230 pr_debug("Added buffer head %i to %p\n", head, vq); 230 pr_debug("Added buffer head %i to %p\n", head, vq);
231 END_USE(vq); 231 END_USE(vq);
232 232
233 /* If we're indirect, we can fit many (assuming not OOM). */
234 if (vq->indirect)
235 return vq->num_free ? vq->vring.num : 0;
236 return vq->num_free; 233 return vq->num_free;
237} 234}
238EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp); 235EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 4a291045ebac..a5ad77ef4266 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -558,6 +558,9 @@ config IT8712F_WDT
558 This is the driver for the built-in watchdog timer on the IT8712F 558 This is the driver for the built-in watchdog timer on the IT8712F
559 Super I/0 chipset used on many motherboards. 559 Super I/0 chipset used on many motherboards.
560 560
561 If the driver does not work, then make sure that the game port in
562 the BIOS is enabled.
563
561 To compile this driver as a module, choose M here: the 564 To compile this driver as a module, choose M here: the
562 module will be called it8712f_wdt. 565 module will be called it8712f_wdt.
563 566
diff --git a/drivers/watchdog/bcm63xx_wdt.c b/drivers/watchdog/bcm63xx_wdt.c
index a1debc89356b..3c5045a206dd 100644
--- a/drivers/watchdog/bcm63xx_wdt.c
+++ b/drivers/watchdog/bcm63xx_wdt.c
@@ -18,7 +18,6 @@
18#include <linux/miscdevice.h> 18#include <linux/miscdevice.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/moduleparam.h> 20#include <linux/moduleparam.h>
21#include <linux/reboot.h>
22#include <linux/types.h> 21#include <linux/types.h>
23#include <linux/uaccess.h> 22#include <linux/uaccess.h>
24#include <linux/watchdog.h> 23#include <linux/watchdog.h>
@@ -220,14 +219,6 @@ static long bcm63xx_wdt_ioctl(struct file *file, unsigned int cmd,
220 } 219 }
221} 220}
222 221
223static int bcm63xx_wdt_notify_sys(struct notifier_block *this,
224 unsigned long code, void *unused)
225{
226 if (code == SYS_DOWN || code == SYS_HALT)
227 bcm63xx_wdt_pause();
228 return NOTIFY_DONE;
229}
230
231static const struct file_operations bcm63xx_wdt_fops = { 222static const struct file_operations bcm63xx_wdt_fops = {
232 .owner = THIS_MODULE, 223 .owner = THIS_MODULE,
233 .llseek = no_llseek, 224 .llseek = no_llseek,
@@ -243,12 +234,8 @@ static struct miscdevice bcm63xx_wdt_miscdev = {
243 .fops = &bcm63xx_wdt_fops, 234 .fops = &bcm63xx_wdt_fops,
244}; 235};
245 236
246static struct notifier_block bcm63xx_wdt_notifier = {
247 .notifier_call = bcm63xx_wdt_notify_sys,
248};
249 237
250 238static int __devinit bcm63xx_wdt_probe(struct platform_device *pdev)
251static int bcm63xx_wdt_probe(struct platform_device *pdev)
252{ 239{
253 int ret; 240 int ret;
254 struct resource *r; 241 struct resource *r;
@@ -280,16 +267,10 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev)
280 wdt_time); 267 wdt_time);
281 } 268 }
282 269
283 ret = register_reboot_notifier(&bcm63xx_wdt_notifier);
284 if (ret) {
285 dev_err(&pdev->dev, "failed to register reboot_notifier\n");
286 goto unregister_timer;
287 }
288
289 ret = misc_register(&bcm63xx_wdt_miscdev); 270 ret = misc_register(&bcm63xx_wdt_miscdev);
290 if (ret < 0) { 271 if (ret < 0) {
291 dev_err(&pdev->dev, "failed to register watchdog device\n"); 272 dev_err(&pdev->dev, "failed to register watchdog device\n");
292 goto unregister_reboot_notifier; 273 goto unregister_timer;
293 } 274 }
294 275
295 dev_info(&pdev->dev, " started, timer margin: %d sec\n", 276 dev_info(&pdev->dev, " started, timer margin: %d sec\n",
@@ -297,8 +278,6 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev)
297 278
298 return 0; 279 return 0;
299 280
300unregister_reboot_notifier:
301 unregister_reboot_notifier(&bcm63xx_wdt_notifier);
302unregister_timer: 281unregister_timer:
303 bcm63xx_timer_unregister(TIMER_WDT_ID); 282 bcm63xx_timer_unregister(TIMER_WDT_ID);
304unmap: 283unmap:
@@ -306,25 +285,28 @@ unmap:
306 return ret; 285 return ret;
307} 286}
308 287
309static int bcm63xx_wdt_remove(struct platform_device *pdev) 288static int __devexit bcm63xx_wdt_remove(struct platform_device *pdev)
310{ 289{
311 if (!nowayout) 290 if (!nowayout)
312 bcm63xx_wdt_pause(); 291 bcm63xx_wdt_pause();
313 292
314 misc_deregister(&bcm63xx_wdt_miscdev); 293 misc_deregister(&bcm63xx_wdt_miscdev);
315
316 iounmap(bcm63xx_wdt_device.regs);
317
318 unregister_reboot_notifier(&bcm63xx_wdt_notifier);
319 bcm63xx_timer_unregister(TIMER_WDT_ID); 294 bcm63xx_timer_unregister(TIMER_WDT_ID);
320 295 iounmap(bcm63xx_wdt_device.regs);
321 return 0; 296 return 0;
322} 297}
323 298
299static void bcm63xx_wdt_shutdown(struct platform_device *pdev)
300{
301 bcm63xx_wdt_pause();
302}
303
324static struct platform_driver bcm63xx_wdt = { 304static struct platform_driver bcm63xx_wdt = {
325 .probe = bcm63xx_wdt_probe, 305 .probe = bcm63xx_wdt_probe,
326 .remove = bcm63xx_wdt_remove, 306 .remove = __devexit_p(bcm63xx_wdt_remove),
307 .shutdown = bcm63xx_wdt_shutdown,
327 .driver = { 308 .driver = {
309 .owner = THIS_MODULE,
328 .name = "bcm63xx-wdt", 310 .name = "bcm63xx-wdt",
329 } 311 }
330}; 312};
diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c
index 9c21d19043a6..f6bd6f10fcec 100644
--- a/drivers/watchdog/gef_wdt.c
+++ b/drivers/watchdog/gef_wdt.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/miscdevice.h> 31#include <linux/miscdevice.h>
32#include <linux/watchdog.h> 32#include <linux/watchdog.h>
33#include <linux/fs.h>
33#include <linux/of.h> 34#include <linux/of.h>
34#include <linux/of_platform.h> 35#include <linux/of_platform.h>
35#include <linux/io.h> 36#include <linux/io.h>
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index f7e90fe47b71..b8838d2c67a6 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -32,6 +32,7 @@
32 * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH) 32 * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH)
33 * document number 320066-003, 320257-008: EP80597 (IICH) 33 * document number 320066-003, 320257-008: EP80597 (IICH)
34 * document number TBD : Cougar Point (CPT) 34 * document number TBD : Cougar Point (CPT)
35 * document number TBD : Patsburg (PBG)
35 */ 36 */
36 37
37/* 38/*
@@ -146,7 +147,8 @@ enum iTCO_chipsets {
146 TCO_CPT29, /* Cougar Point */ 147 TCO_CPT29, /* Cougar Point */
147 TCO_CPT30, /* Cougar Point */ 148 TCO_CPT30, /* Cougar Point */
148 TCO_CPT31, /* Cougar Point */ 149 TCO_CPT31, /* Cougar Point */
149 TCO_PBG, /* Patsburg */ 150 TCO_PBG1, /* Patsburg */
151 TCO_PBG2, /* Patsburg */
150}; 152};
151 153
152static struct { 154static struct {
@@ -235,6 +237,7 @@ static struct {
235 {"Cougar Point", 2}, 237 {"Cougar Point", 2},
236 {"Cougar Point", 2}, 238 {"Cougar Point", 2},
237 {"Patsburg", 2}, 239 {"Patsburg", 2},
240 {"Patsburg", 2},
238 {NULL, 0} 241 {NULL, 0}
239}; 242};
240 243
@@ -350,7 +353,8 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = {
350 { ITCO_PCI_DEVICE(0x1c5d, TCO_CPT29)}, 353 { ITCO_PCI_DEVICE(0x1c5d, TCO_CPT29)},
351 { ITCO_PCI_DEVICE(0x1c5e, TCO_CPT30)}, 354 { ITCO_PCI_DEVICE(0x1c5e, TCO_CPT30)},
352 { ITCO_PCI_DEVICE(0x1c5f, TCO_CPT31)}, 355 { ITCO_PCI_DEVICE(0x1c5f, TCO_CPT31)},
353 { ITCO_PCI_DEVICE(0x1d40, TCO_PBG)}, 356 { ITCO_PCI_DEVICE(0x1d40, TCO_PBG1)},
357 { ITCO_PCI_DEVICE(0x1d41, TCO_PBG2)},
354 { 0, }, /* End of list */ 358 { 0, }, /* End of list */
355}; 359};
356MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl); 360MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index eb8a78d77d9d..533a199e7a3f 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -8,9 +8,12 @@ obj-$(CONFIG_BLOCK) += biomerge.o
8obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o 8obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
9obj-$(CONFIG_XEN_XENCOMM) += xencomm.o 9obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
10obj-$(CONFIG_XEN_BALLOON) += balloon.o 10obj-$(CONFIG_XEN_BALLOON) += balloon.o
11obj-$(CONFIG_XEN_DEV_EVTCHN) += evtchn.o 11obj-$(CONFIG_XEN_DEV_EVTCHN) += xen-evtchn.o
12obj-$(CONFIG_XENFS) += xenfs/ 12obj-$(CONFIG_XENFS) += xenfs/
13obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o 13obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o
14obj-$(CONFIG_XEN_PLATFORM_PCI) += platform-pci.o 14obj-$(CONFIG_XEN_PLATFORM_PCI) += platform-pci.o
15obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o 15obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
16obj-$(CONFIG_XEN_DOM0) += pci.o 16obj-$(CONFIG_XEN_DOM0) += pci.o
17
18xen-evtchn-y := evtchn.o
19
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 500290b150bb..43f9f02c7db0 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -50,6 +50,7 @@
50#include <asm/pgtable.h> 50#include <asm/pgtable.h>
51#include <asm/uaccess.h> 51#include <asm/uaccess.h>
52#include <asm/tlb.h> 52#include <asm/tlb.h>
53#include <asm/e820.h>
53 54
54#include <asm/xen/hypervisor.h> 55#include <asm/xen/hypervisor.h>
55#include <asm/xen/hypercall.h> 56#include <asm/xen/hypercall.h>
@@ -119,7 +120,7 @@ static void scrub_page(struct page *page)
119} 120}
120 121
121/* balloon_append: add the given page to the balloon. */ 122/* balloon_append: add the given page to the balloon. */
122static void balloon_append(struct page *page) 123static void __balloon_append(struct page *page)
123{ 124{
124 /* Lowmem is re-populated first, so highmem pages go at list tail. */ 125 /* Lowmem is re-populated first, so highmem pages go at list tail. */
125 if (PageHighMem(page)) { 126 if (PageHighMem(page)) {
@@ -130,7 +131,11 @@ static void balloon_append(struct page *page)
130 list_add(&page->lru, &ballooned_pages); 131 list_add(&page->lru, &ballooned_pages);
131 balloon_stats.balloon_low++; 132 balloon_stats.balloon_low++;
132 } 133 }
134}
133 135
136static void balloon_append(struct page *page)
137{
138 __balloon_append(page);
134 totalram_pages--; 139 totalram_pages--;
135} 140}
136 141
@@ -191,7 +196,7 @@ static unsigned long current_target(void)
191 196
192static int increase_reservation(unsigned long nr_pages) 197static int increase_reservation(unsigned long nr_pages)
193{ 198{
194 unsigned long pfn, i, flags; 199 unsigned long pfn, i;
195 struct page *page; 200 struct page *page;
196 long rc; 201 long rc;
197 struct xen_memory_reservation reservation = { 202 struct xen_memory_reservation reservation = {
@@ -203,8 +208,6 @@ static int increase_reservation(unsigned long nr_pages)
203 if (nr_pages > ARRAY_SIZE(frame_list)) 208 if (nr_pages > ARRAY_SIZE(frame_list))
204 nr_pages = ARRAY_SIZE(frame_list); 209 nr_pages = ARRAY_SIZE(frame_list);
205 210
206 spin_lock_irqsave(&xen_reservation_lock, flags);
207
208 page = balloon_first_page(); 211 page = balloon_first_page();
209 for (i = 0; i < nr_pages; i++) { 212 for (i = 0; i < nr_pages; i++) {
210 BUG_ON(page == NULL); 213 BUG_ON(page == NULL);
@@ -247,14 +250,12 @@ static int increase_reservation(unsigned long nr_pages)
247 balloon_stats.current_pages += rc; 250 balloon_stats.current_pages += rc;
248 251
249 out: 252 out:
250 spin_unlock_irqrestore(&xen_reservation_lock, flags);
251
252 return rc < 0 ? rc : rc != nr_pages; 253 return rc < 0 ? rc : rc != nr_pages;
253} 254}
254 255
255static int decrease_reservation(unsigned long nr_pages) 256static int decrease_reservation(unsigned long nr_pages)
256{ 257{
257 unsigned long pfn, i, flags; 258 unsigned long pfn, i;
258 struct page *page; 259 struct page *page;
259 int need_sleep = 0; 260 int need_sleep = 0;
260 int ret; 261 int ret;
@@ -292,8 +293,6 @@ static int decrease_reservation(unsigned long nr_pages)
292 kmap_flush_unused(); 293 kmap_flush_unused();
293 flush_tlb_all(); 294 flush_tlb_all();
294 295
295 spin_lock_irqsave(&xen_reservation_lock, flags);
296
297 /* No more mappings: invalidate P2M and add to balloon. */ 296 /* No more mappings: invalidate P2M and add to balloon. */
298 for (i = 0; i < nr_pages; i++) { 297 for (i = 0; i < nr_pages; i++) {
299 pfn = mfn_to_pfn(frame_list[i]); 298 pfn = mfn_to_pfn(frame_list[i]);
@@ -308,8 +307,6 @@ static int decrease_reservation(unsigned long nr_pages)
308 307
309 balloon_stats.current_pages -= nr_pages; 308 balloon_stats.current_pages -= nr_pages;
310 309
311 spin_unlock_irqrestore(&xen_reservation_lock, flags);
312
313 return need_sleep; 310 return need_sleep;
314} 311}
315 312
@@ -395,7 +392,7 @@ static struct notifier_block xenstore_notifier;
395 392
396static int __init balloon_init(void) 393static int __init balloon_init(void)
397{ 394{
398 unsigned long pfn; 395 unsigned long pfn, extra_pfn_end;
399 struct page *page; 396 struct page *page;
400 397
401 if (!xen_pv_domain()) 398 if (!xen_pv_domain())
@@ -415,11 +412,24 @@ static int __init balloon_init(void)
415 412
416 register_balloon(&balloon_sysdev); 413 register_balloon(&balloon_sysdev);
417 414
418 /* Initialise the balloon with excess memory space. */ 415 /*
419 for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) { 416 * Initialise the balloon with excess memory space. We need
417 * to make sure we don't add memory which doesn't exist or
418 * logically exist. The E820 map can be trimmed to be smaller
419 * than the amount of physical memory due to the mem= command
420 * line parameter. And if this is a 32-bit non-HIGHMEM kernel
421 * on a system with memory which requires highmem to access,
422 * don't try to use it.
423 */
424 extra_pfn_end = min(min(max_pfn, e820_end_of_ram_pfn()),
425 (unsigned long)PFN_DOWN(xen_extra_mem_start + xen_extra_mem_size));
426 for (pfn = PFN_UP(xen_extra_mem_start);
427 pfn < extra_pfn_end;
428 pfn++) {
420 page = pfn_to_page(pfn); 429 page = pfn_to_page(pfn);
421 if (!PageReserved(page)) 430 /* totalram_pages doesn't include the boot-time
422 balloon_append(page); 431 balloon extension, so don't subtract from it. */
432 __balloon_append(page);
423 } 433 }
424 434
425 target_watch.callback = watch_target; 435 target_watch.callback = watch_target;
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 321a0c8346e5..31af0ac31a98 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -105,7 +105,6 @@ struct irq_info
105 105
106static struct irq_info *irq_info; 106static struct irq_info *irq_info;
107static int *pirq_to_irq; 107static int *pirq_to_irq;
108static int nr_pirqs;
109 108
110static int *evtchn_to_irq; 109static int *evtchn_to_irq;
111struct cpu_evtchn_s { 110struct cpu_evtchn_s {
@@ -278,17 +277,17 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)
278 cpumask_copy(irq_to_desc(irq)->affinity, cpumask_of(cpu)); 277 cpumask_copy(irq_to_desc(irq)->affinity, cpumask_of(cpu));
279#endif 278#endif
280 279
281 __clear_bit(chn, cpu_evtchn_mask(cpu_from_irq(irq))); 280 clear_bit(chn, cpu_evtchn_mask(cpu_from_irq(irq)));
282 __set_bit(chn, cpu_evtchn_mask(cpu)); 281 set_bit(chn, cpu_evtchn_mask(cpu));
283 282
284 irq_info[irq].cpu = cpu; 283 irq_info[irq].cpu = cpu;
285} 284}
286 285
287static void init_evtchn_cpu_bindings(void) 286static void init_evtchn_cpu_bindings(void)
288{ 287{
288 int i;
289#ifdef CONFIG_SMP 289#ifdef CONFIG_SMP
290 struct irq_desc *desc; 290 struct irq_desc *desc;
291 int i;
292 291
293 /* By default all event channels notify CPU#0. */ 292 /* By default all event channels notify CPU#0. */
294 for_each_irq_desc(i, desc) { 293 for_each_irq_desc(i, desc) {
@@ -296,7 +295,10 @@ static void init_evtchn_cpu_bindings(void)
296 } 295 }
297#endif 296#endif
298 297
299 memset(cpu_evtchn_mask(0), ~0, sizeof(struct cpu_evtchn_s)); 298 for_each_possible_cpu(i)
299 memset(cpu_evtchn_mask(i),
300 (i == 0) ? ~0 : 0, sizeof(struct cpu_evtchn_s));
301
300} 302}
301 303
302static inline void clear_evtchn(int port) 304static inline void clear_evtchn(int port)
@@ -382,12 +384,17 @@ static int get_nr_hw_irqs(void)
382 return ret; 384 return ret;
383} 385}
384 386
385/* callers of this function should make sure that PHYSDEVOP_get_nr_pirqs 387static int find_unbound_pirq(int type)
386 * succeeded otherwise nr_pirqs won't hold the right value */
387static int find_unbound_pirq(void)
388{ 388{
389 int i; 389 int rc, i;
390 for (i = nr_pirqs-1; i >= 0; i--) { 390 struct physdev_get_free_pirq op_get_free_pirq;
391 op_get_free_pirq.type = type;
392
393 rc = HYPERVISOR_physdev_op(PHYSDEVOP_get_free_pirq, &op_get_free_pirq);
394 if (!rc)
395 return op_get_free_pirq.pirq;
396
397 for (i = 0; i < nr_irqs; i++) {
391 if (pirq_to_irq[i] < 0) 398 if (pirq_to_irq[i] < 0)
392 return i; 399 return i;
393 } 400 }
@@ -420,7 +427,7 @@ static int find_unbound_irq(void)
420 if (irq == start) 427 if (irq == start)
421 goto no_irqs; 428 goto no_irqs;
422 429
423 res = irq_alloc_desc_at(irq, 0); 430 res = irq_alloc_desc_at(irq, -1);
424 431
425 if (WARN_ON(res != irq)) 432 if (WARN_ON(res != irq))
426 return -1; 433 return -1;
@@ -608,10 +615,10 @@ int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name)
608 615
609 spin_lock(&irq_mapping_update_lock); 616 spin_lock(&irq_mapping_update_lock);
610 617
611 if ((pirq > nr_pirqs) || (gsi > nr_irqs)) { 618 if ((pirq > nr_irqs) || (gsi > nr_irqs)) {
612 printk(KERN_WARNING "xen_map_pirq_gsi: %s %s is incorrect!\n", 619 printk(KERN_WARNING "xen_map_pirq_gsi: %s %s is incorrect!\n",
613 pirq > nr_pirqs ? "nr_pirqs" :"", 620 pirq > nr_irqs ? "pirq" :"",
614 gsi > nr_irqs ? "nr_irqs" : ""); 621 gsi > nr_irqs ? "gsi" : "");
615 goto out; 622 goto out;
616 } 623 }
617 624
@@ -627,7 +634,7 @@ int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name)
627 if (identity_mapped_irq(gsi) || (!xen_initial_domain() && 634 if (identity_mapped_irq(gsi) || (!xen_initial_domain() &&
628 xen_pv_domain())) { 635 xen_pv_domain())) {
629 irq = gsi; 636 irq = gsi;
630 irq_alloc_desc_at(irq, 0); 637 irq_alloc_desc_at(irq, -1);
631 } else 638 } else
632 irq = find_unbound_irq(); 639 irq = find_unbound_irq();
633 640
@@ -661,17 +668,21 @@ out:
661#include <linux/msi.h> 668#include <linux/msi.h>
662#include "../pci/msi.h" 669#include "../pci/msi.h"
663 670
664void xen_allocate_pirq_msi(char *name, int *irq, int *pirq) 671void xen_allocate_pirq_msi(char *name, int *irq, int *pirq, int alloc)
665{ 672{
666 spin_lock(&irq_mapping_update_lock); 673 spin_lock(&irq_mapping_update_lock);
667 674
668 *irq = find_unbound_irq(); 675 if (alloc & XEN_ALLOC_IRQ) {
669 if (*irq == -1) 676 *irq = find_unbound_irq();
670 goto out; 677 if (*irq == -1)
678 goto out;
679 }
671 680
672 *pirq = find_unbound_pirq(); 681 if (alloc & XEN_ALLOC_PIRQ) {
673 if (*pirq == -1) 682 *pirq = find_unbound_pirq(MAP_PIRQ_TYPE_MSI);
674 goto out; 683 if (*pirq == -1)
684 goto out;
685 }
675 686
676 set_irq_chip_and_handler_name(*irq, &xen_pirq_chip, 687 set_irq_chip_and_handler_name(*irq, &xen_pirq_chip,
677 handle_level_irq, name); 688 handle_level_irq, name);
@@ -752,13 +763,14 @@ int xen_destroy_irq(int irq)
752 goto out; 763 goto out;
753 764
754 if (xen_initial_domain()) { 765 if (xen_initial_domain()) {
755 unmap_irq.pirq = info->u.pirq.gsi; 766 unmap_irq.pirq = info->u.pirq.pirq;
756 unmap_irq.domid = DOMID_SELF; 767 unmap_irq.domid = DOMID_SELF;
757 rc = HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, &unmap_irq); 768 rc = HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, &unmap_irq);
758 if (rc) { 769 if (rc) {
759 printk(KERN_WARNING "unmap irq failed %d\n", rc); 770 printk(KERN_WARNING "unmap irq failed %d\n", rc);
760 goto out; 771 goto out;
761 } 772 }
773 pirq_to_irq[info->u.pirq.pirq] = -1;
762 } 774 }
763 irq_info[irq] = mk_unbound_info(); 775 irq_info[irq] = mk_unbound_info();
764 776
@@ -779,6 +791,11 @@ int xen_gsi_from_irq(unsigned irq)
779 return gsi_from_irq(irq); 791 return gsi_from_irq(irq);
780} 792}
781 793
794int xen_irq_from_pirq(unsigned pirq)
795{
796 return pirq_to_irq[pirq];
797}
798
782int bind_evtchn_to_irq(unsigned int evtchn) 799int bind_evtchn_to_irq(unsigned int evtchn)
783{ 800{
784 int irq; 801 int irq;
@@ -1276,6 +1293,42 @@ static int retrigger_dynirq(unsigned int irq)
1276 return ret; 1293 return ret;
1277} 1294}
1278 1295
1296static void restore_cpu_pirqs(void)
1297{
1298 int pirq, rc, irq, gsi;
1299 struct physdev_map_pirq map_irq;
1300
1301 for (pirq = 0; pirq < nr_irqs; pirq++) {
1302 irq = pirq_to_irq[pirq];
1303 if (irq == -1)
1304 continue;
1305
1306 /* save/restore of PT devices doesn't work, so at this point the
1307 * only devices present are GSI based emulated devices */
1308 gsi = gsi_from_irq(irq);
1309 if (!gsi)
1310 continue;
1311
1312 map_irq.domid = DOMID_SELF;
1313 map_irq.type = MAP_PIRQ_TYPE_GSI;
1314 map_irq.index = gsi;
1315 map_irq.pirq = pirq;
1316
1317 rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
1318 if (rc) {
1319 printk(KERN_WARNING "xen map irq failed gsi=%d irq=%d pirq=%d rc=%d\n",
1320 gsi, irq, pirq, rc);
1321 irq_info[irq] = mk_unbound_info();
1322 pirq_to_irq[pirq] = -1;
1323 continue;
1324 }
1325
1326 printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq);
1327
1328 startup_pirq(irq);
1329 }
1330}
1331
1279static void restore_cpu_virqs(unsigned int cpu) 1332static void restore_cpu_virqs(unsigned int cpu)
1280{ 1333{
1281 struct evtchn_bind_virq bind_virq; 1334 struct evtchn_bind_virq bind_virq;
@@ -1419,6 +1472,8 @@ void xen_irq_resume(void)
1419 1472
1420 unmask_evtchn(evtchn); 1473 unmask_evtchn(evtchn);
1421 } 1474 }
1475
1476 restore_cpu_pirqs();
1422} 1477}
1423 1478
1424static struct irq_chip xen_dynamic_chip __read_mostly = { 1479static struct irq_chip xen_dynamic_chip __read_mostly = {
@@ -1503,26 +1558,17 @@ void xen_callback_vector(void) {}
1503 1558
1504void __init xen_init_IRQ(void) 1559void __init xen_init_IRQ(void)
1505{ 1560{
1506 int i, rc; 1561 int i;
1507 struct physdev_nr_pirqs op_nr_pirqs;
1508 1562
1509 cpu_evtchn_mask_p = kcalloc(nr_cpu_ids, sizeof(struct cpu_evtchn_s), 1563 cpu_evtchn_mask_p = kcalloc(nr_cpu_ids, sizeof(struct cpu_evtchn_s),
1510 GFP_KERNEL); 1564 GFP_KERNEL);
1511 irq_info = kcalloc(nr_irqs, sizeof(*irq_info), GFP_KERNEL); 1565 irq_info = kcalloc(nr_irqs, sizeof(*irq_info), GFP_KERNEL);
1512 1566
1513 rc = HYPERVISOR_physdev_op(PHYSDEVOP_get_nr_pirqs, &op_nr_pirqs); 1567 /* We are using nr_irqs as the maximum number of pirq available but
1514 if (rc < 0) { 1568 * that number is actually chosen by Xen and we don't know exactly
1515 nr_pirqs = nr_irqs; 1569 * what it is. Be careful choosing high pirq numbers. */
1516 if (rc != -ENOSYS) 1570 pirq_to_irq = kcalloc(nr_irqs, sizeof(*pirq_to_irq), GFP_KERNEL);
1517 printk(KERN_WARNING "PHYSDEVOP_get_nr_pirqs returned rc=%d\n", rc); 1571 for (i = 0; i < nr_irqs; i++)
1518 } else {
1519 if (xen_pv_domain() && !xen_initial_domain())
1520 nr_pirqs = max((int)op_nr_pirqs.nr_pirqs, nr_irqs);
1521 else
1522 nr_pirqs = op_nr_pirqs.nr_pirqs;
1523 }
1524 pirq_to_irq = kcalloc(nr_pirqs, sizeof(*pirq_to_irq), GFP_KERNEL);
1525 for (i = 0; i < nr_pirqs; i++)
1526 pirq_to_irq[i] = -1; 1572 pirq_to_irq[i] = -1;
1527 1573
1528 evtchn_to_irq = kcalloc(NR_EVENT_CHANNELS, sizeof(*evtchn_to_irq), 1574 evtchn_to_irq = kcalloc(NR_EVENT_CHANNELS, sizeof(*evtchn_to_irq),
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index fec6ba3c08a8..ef11daf0cafe 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -69,20 +69,51 @@ struct per_user_data {
69 const char *name; 69 const char *name;
70}; 70};
71 71
72/* Who's bound to each port? */ 72/*
73static struct per_user_data *port_user[NR_EVENT_CHANNELS]; 73 * Who's bound to each port? This is logically an array of struct
74 * per_user_data *, but we encode the current enabled-state in bit 0.
75 */
76static unsigned long *port_user;
74static DEFINE_SPINLOCK(port_user_lock); /* protects port_user[] and ring_prod */ 77static DEFINE_SPINLOCK(port_user_lock); /* protects port_user[] and ring_prod */
75 78
76irqreturn_t evtchn_interrupt(int irq, void *data) 79static inline struct per_user_data *get_port_user(unsigned port)
80{
81 return (struct per_user_data *)(port_user[port] & ~1);
82}
83
84static inline void set_port_user(unsigned port, struct per_user_data *u)
85{
86 port_user[port] = (unsigned long)u;
87}
88
89static inline bool get_port_enabled(unsigned port)
90{
91 return port_user[port] & 1;
92}
93
94static inline void set_port_enabled(unsigned port, bool enabled)
95{
96 if (enabled)
97 port_user[port] |= 1;
98 else
99 port_user[port] &= ~1;
100}
101
102static irqreturn_t evtchn_interrupt(int irq, void *data)
77{ 103{
78 unsigned int port = (unsigned long)data; 104 unsigned int port = (unsigned long)data;
79 struct per_user_data *u; 105 struct per_user_data *u;
80 106
81 spin_lock(&port_user_lock); 107 spin_lock(&port_user_lock);
82 108
83 u = port_user[port]; 109 u = get_port_user(port);
110
111 WARN(!get_port_enabled(port),
112 "Interrupt for port %d, but apparently not enabled; per-user %p\n",
113 port, u);
84 114
85 disable_irq_nosync(irq); 115 disable_irq_nosync(irq);
116 set_port_enabled(port, false);
86 117
87 if ((u->ring_prod - u->ring_cons) < EVTCHN_RING_SIZE) { 118 if ((u->ring_prod - u->ring_cons) < EVTCHN_RING_SIZE) {
88 u->ring[EVTCHN_RING_MASK(u->ring_prod)] = port; 119 u->ring[EVTCHN_RING_MASK(u->ring_prod)] = port;
@@ -92,9 +123,8 @@ irqreturn_t evtchn_interrupt(int irq, void *data)
92 kill_fasync(&u->evtchn_async_queue, 123 kill_fasync(&u->evtchn_async_queue,
93 SIGIO, POLL_IN); 124 SIGIO, POLL_IN);
94 } 125 }
95 } else { 126 } else
96 u->ring_overflow = 1; 127 u->ring_overflow = 1;
97 }
98 128
99 spin_unlock(&port_user_lock); 129 spin_unlock(&port_user_lock);
100 130
@@ -198,9 +228,18 @@ static ssize_t evtchn_write(struct file *file, const char __user *buf,
198 goto out; 228 goto out;
199 229
200 spin_lock_irq(&port_user_lock); 230 spin_lock_irq(&port_user_lock);
201 for (i = 0; i < (count/sizeof(evtchn_port_t)); i++) 231
202 if ((kbuf[i] < NR_EVENT_CHANNELS) && (port_user[kbuf[i]] == u)) 232 for (i = 0; i < (count/sizeof(evtchn_port_t)); i++) {
203 enable_irq(irq_from_evtchn(kbuf[i])); 233 unsigned port = kbuf[i];
234
235 if (port < NR_EVENT_CHANNELS &&
236 get_port_user(port) == u &&
237 !get_port_enabled(port)) {
238 set_port_enabled(port, true);
239 enable_irq(irq_from_evtchn(port));
240 }
241 }
242
204 spin_unlock_irq(&port_user_lock); 243 spin_unlock_irq(&port_user_lock);
205 244
206 rc = count; 245 rc = count;
@@ -222,8 +261,9 @@ static int evtchn_bind_to_user(struct per_user_data *u, int port)
222 * interrupt handler yet, and our caller has already 261 * interrupt handler yet, and our caller has already
223 * serialized bind operations.) 262 * serialized bind operations.)
224 */ 263 */
225 BUG_ON(port_user[port] != NULL); 264 BUG_ON(get_port_user(port) != NULL);
226 port_user[port] = u; 265 set_port_user(port, u);
266 set_port_enabled(port, true); /* start enabled */
227 267
228 rc = bind_evtchn_to_irqhandler(port, evtchn_interrupt, IRQF_DISABLED, 268 rc = bind_evtchn_to_irqhandler(port, evtchn_interrupt, IRQF_DISABLED,
229 u->name, (void *)(unsigned long)port); 269 u->name, (void *)(unsigned long)port);
@@ -239,10 +279,7 @@ static void evtchn_unbind_from_user(struct per_user_data *u, int port)
239 279
240 unbind_from_irqhandler(irq, (void *)(unsigned long)port); 280 unbind_from_irqhandler(irq, (void *)(unsigned long)port);
241 281
242 /* make sure we unbind the irq handler before clearing the port */ 282 set_port_user(port, NULL);
243 barrier();
244
245 port_user[port] = NULL;
246} 283}
247 284
248static long evtchn_ioctl(struct file *file, 285static long evtchn_ioctl(struct file *file,
@@ -333,15 +370,17 @@ static long evtchn_ioctl(struct file *file,
333 spin_lock_irq(&port_user_lock); 370 spin_lock_irq(&port_user_lock);
334 371
335 rc = -ENOTCONN; 372 rc = -ENOTCONN;
336 if (port_user[unbind.port] != u) { 373 if (get_port_user(unbind.port) != u) {
337 spin_unlock_irq(&port_user_lock); 374 spin_unlock_irq(&port_user_lock);
338 break; 375 break;
339 } 376 }
340 377
341 evtchn_unbind_from_user(u, unbind.port); 378 disable_irq(irq_from_evtchn(unbind.port));
342 379
343 spin_unlock_irq(&port_user_lock); 380 spin_unlock_irq(&port_user_lock);
344 381
382 evtchn_unbind_from_user(u, unbind.port);
383
345 rc = 0; 384 rc = 0;
346 break; 385 break;
347 } 386 }
@@ -355,7 +394,7 @@ static long evtchn_ioctl(struct file *file,
355 394
356 if (notify.port >= NR_EVENT_CHANNELS) { 395 if (notify.port >= NR_EVENT_CHANNELS) {
357 rc = -EINVAL; 396 rc = -EINVAL;
358 } else if (port_user[notify.port] != u) { 397 } else if (get_port_user(notify.port) != u) {
359 rc = -ENOTCONN; 398 rc = -ENOTCONN;
360 } else { 399 } else {
361 notify_remote_via_evtchn(notify.port); 400 notify_remote_via_evtchn(notify.port);
@@ -431,7 +470,7 @@ static int evtchn_open(struct inode *inode, struct file *filp)
431 470
432 filp->private_data = u; 471 filp->private_data = u;
433 472
434 return 0; 473 return nonseekable_open(inode, filp);;
435} 474}
436 475
437static int evtchn_release(struct inode *inode, struct file *filp) 476static int evtchn_release(struct inode *inode, struct file *filp)
@@ -444,14 +483,21 @@ static int evtchn_release(struct inode *inode, struct file *filp)
444 free_page((unsigned long)u->ring); 483 free_page((unsigned long)u->ring);
445 484
446 for (i = 0; i < NR_EVENT_CHANNELS; i++) { 485 for (i = 0; i < NR_EVENT_CHANNELS; i++) {
447 if (port_user[i] != u) 486 if (get_port_user(i) != u)
448 continue; 487 continue;
449 488
450 evtchn_unbind_from_user(port_user[i], i); 489 disable_irq(irq_from_evtchn(i));
451 } 490 }
452 491
453 spin_unlock_irq(&port_user_lock); 492 spin_unlock_irq(&port_user_lock);
454 493
494 for (i = 0; i < NR_EVENT_CHANNELS; i++) {
495 if (get_port_user(i) != u)
496 continue;
497
498 evtchn_unbind_from_user(get_port_user(i), i);
499 }
500
455 kfree(u->name); 501 kfree(u->name);
456 kfree(u); 502 kfree(u);
457 503
@@ -467,12 +513,12 @@ static const struct file_operations evtchn_fops = {
467 .fasync = evtchn_fasync, 513 .fasync = evtchn_fasync,
468 .open = evtchn_open, 514 .open = evtchn_open,
469 .release = evtchn_release, 515 .release = evtchn_release,
470 .llseek = noop_llseek, 516 .llseek = no_llseek,
471}; 517};
472 518
473static struct miscdevice evtchn_miscdev = { 519static struct miscdevice evtchn_miscdev = {
474 .minor = MISC_DYNAMIC_MINOR, 520 .minor = MISC_DYNAMIC_MINOR,
475 .name = "evtchn", 521 .name = "xen/evtchn",
476 .fops = &evtchn_fops, 522 .fops = &evtchn_fops,
477}; 523};
478static int __init evtchn_init(void) 524static int __init evtchn_init(void)
@@ -482,8 +528,11 @@ static int __init evtchn_init(void)
482 if (!xen_domain()) 528 if (!xen_domain())
483 return -ENODEV; 529 return -ENODEV;
484 530
531 port_user = kcalloc(NR_EVENT_CHANNELS, sizeof(*port_user), GFP_KERNEL);
532 if (port_user == NULL)
533 return -ENOMEM;
534
485 spin_lock_init(&port_user_lock); 535 spin_lock_init(&port_user_lock);
486 memset(port_user, 0, sizeof(port_user));
487 536
488 /* Create '/dev/misc/evtchn'. */ 537 /* Create '/dev/misc/evtchn'. */
489 err = misc_register(&evtchn_miscdev); 538 err = misc_register(&evtchn_miscdev);
@@ -499,6 +548,9 @@ static int __init evtchn_init(void)
499 548
500static void __exit evtchn_cleanup(void) 549static void __exit evtchn_cleanup(void)
501{ 550{
551 kfree(port_user);
552 port_user = NULL;
553
502 misc_deregister(&evtchn_miscdev); 554 misc_deregister(&evtchn_miscdev);
503} 555}
504 556
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index ef9c7db52077..db8c4c4ac880 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -49,6 +49,7 @@ static int xen_hvm_suspend(void *data)
49 49
50 if (!*cancelled) { 50 if (!*cancelled) {
51 xen_irq_resume(); 51 xen_irq_resume();
52 xen_console_resume();
52 xen_timer_resume(); 53 xen_timer_resume();
53 } 54 }
54 55
diff --git a/drivers/xen/xenfs/privcmd.c b/drivers/xen/xenfs/privcmd.c
index f80be7f6eb95..dbd3b16fd131 100644
--- a/drivers/xen/xenfs/privcmd.c
+++ b/drivers/xen/xenfs/privcmd.c
@@ -15,7 +15,6 @@
15#include <linux/mman.h> 15#include <linux/mman.h>
16#include <linux/uaccess.h> 16#include <linux/uaccess.h>
17#include <linux/swap.h> 17#include <linux/swap.h>
18#include <linux/smp_lock.h>
19#include <linux/highmem.h> 18#include <linux/highmem.h>
20#include <linux/pagemap.h> 19#include <linux/pagemap.h>
21#include <linux/seq_file.h> 20#include <linux/seq_file.h>
@@ -266,9 +265,7 @@ static int mmap_return_errors(void *data, void *state)
266 xen_pfn_t *mfnp = data; 265 xen_pfn_t *mfnp = data;
267 struct mmap_batch_state *st = state; 266 struct mmap_batch_state *st = state;
268 267
269 put_user(*mfnp, st->user++); 268 return put_user(*mfnp, st->user++);
270
271 return 0;
272} 269}
273 270
274static struct vm_operations_struct privcmd_vm_ops; 271static struct vm_operations_struct privcmd_vm_ops;
@@ -323,10 +320,8 @@ static long privcmd_ioctl_mmap_batch(void __user *udata)
323 up_write(&mm->mmap_sem); 320 up_write(&mm->mmap_sem);
324 321
325 if (state.err > 0) { 322 if (state.err > 0) {
326 ret = 0;
327
328 state.user = m.arr; 323 state.user = m.arr;
329 traverse_pages(m.num, sizeof(xen_pfn_t), 324 ret = traverse_pages(m.num, sizeof(xen_pfn_t),
330 &pagelist, 325 &pagelist,
331 mmap_return_errors, &state); 326 mmap_return_errors, &state);
332 } 327 }
@@ -384,8 +379,9 @@ static int privcmd_mmap(struct file *file, struct vm_area_struct *vma)
384 if (xen_feature(XENFEAT_auto_translated_physmap)) 379 if (xen_feature(XENFEAT_auto_translated_physmap))
385 return -ENOSYS; 380 return -ENOSYS;
386 381
387 /* DONTCOPY is essential for Xen as copy_page_range is broken. */ 382 /* DONTCOPY is essential for Xen because copy_page_range doesn't know
388 vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY; 383 * how to recreate these mappings */
384 vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY | VM_PFNMAP;
389 vma->vm_ops = &privcmd_vm_ops; 385 vma->vm_ops = &privcmd_vm_ops;
390 vma->vm_private_data = NULL; 386 vma->vm_private_data = NULL;
391 387
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index f6339d11d59c..1aa389719846 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -12,8 +12,6 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/fs.h> 13#include <linux/fs.h>
14#include <linux/magic.h> 14#include <linux/magic.h>
15#include <linux/mm.h>
16#include <linux/backing-dev.h>
17 15
18#include <xen/xen.h> 16#include <xen/xen.h>
19 17
@@ -24,28 +22,12 @@
24MODULE_DESCRIPTION("Xen filesystem"); 22MODULE_DESCRIPTION("Xen filesystem");
25MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
26 24
27static int xenfs_set_page_dirty(struct page *page)
28{
29 return !TestSetPageDirty(page);
30}
31
32static const struct address_space_operations xenfs_aops = {
33 .set_page_dirty = xenfs_set_page_dirty,
34};
35
36static struct backing_dev_info xenfs_backing_dev_info = {
37 .ra_pages = 0, /* No readahead */
38 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
39};
40
41static struct inode *xenfs_make_inode(struct super_block *sb, int mode) 25static struct inode *xenfs_make_inode(struct super_block *sb, int mode)
42{ 26{
43 struct inode *ret = new_inode(sb); 27 struct inode *ret = new_inode(sb);
44 28
45 if (ret) { 29 if (ret) {
46 ret->i_mode = mode; 30 ret->i_mode = mode;
47 ret->i_mapping->a_ops = &xenfs_aops;
48 ret->i_mapping->backing_dev_info = &xenfs_backing_dev_info;
49 ret->i_uid = ret->i_gid = 0; 31 ret->i_uid = ret->i_gid = 0;
50 ret->i_blocks = 0; 32 ret->i_blocks = 0;
51 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; 33 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
@@ -121,9 +103,9 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
121 return rc; 103 return rc;
122} 104}
123 105
124static int xenfs_mount(struct file_system_type *fs_type, 106static struct dentry *xenfs_mount(struct file_system_type *fs_type,
125 int flags, const char *dev_name, 107 int flags, const char *dev_name,
126 void *data) 108 void *data)
127{ 109{
128 return mount_single(fs_type, flags, data, xenfs_fill_super); 110 return mount_single(fs_type, flags, data, xenfs_fill_super);
129} 111}
@@ -137,25 +119,11 @@ static struct file_system_type xenfs_type = {
137 119
138static int __init xenfs_init(void) 120static int __init xenfs_init(void)
139{ 121{
140 int err; 122 if (xen_domain())
141 if (!xen_domain()) { 123 return register_filesystem(&xenfs_type);
142 printk(KERN_INFO "xenfs: not registering filesystem on non-xen platform\n");
143 return 0;
144 }
145
146 err = register_filesystem(&xenfs_type);
147 if (err) {
148 printk(KERN_ERR "xenfs: Unable to register filesystem!\n");
149 goto out;
150 }
151
152 err = bdi_init(&xenfs_backing_dev_info);
153 if (err)
154 unregister_filesystem(&xenfs_type);
155
156 out:
157 124
158 return err; 125 printk(KERN_INFO "XENFS: not registering filesystem on non-xen platform\n");
126 return 0;
159} 127}
160 128
161static void __exit xenfs_exit(void) 129static void __exit xenfs_exit(void)
diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c
index cafc50454292..e0c84725d3e9 100644
--- a/drivers/zorro/proc.c
+++ b/drivers/zorro/proc.c
@@ -13,7 +13,6 @@
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/seq_file.h> 14#include <linux/seq_file.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/smp_lock.h>
17#include <asm/uaccess.h> 16#include <asm/uaccess.h>
18#include <asm/amigahw.h> 17#include <asm/amigahw.h>
19#include <asm/setup.h> 18#include <asm/setup.h>
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index d5c1401f0031..d34896cfb19f 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -980,19 +980,11 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
980 } 980 }
981} 981}
982 982
983static DEFINE_MUTEX(autofs4_ioctl_mutex);
984
985static long autofs4_root_ioctl(struct file *filp, 983static long autofs4_root_ioctl(struct file *filp,
986 unsigned int cmd, unsigned long arg) 984 unsigned int cmd, unsigned long arg)
987{ 985{
988 long ret;
989 struct inode *inode = filp->f_dentry->d_inode; 986 struct inode *inode = filp->f_dentry->d_inode;
990 987 return autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
991 mutex_lock(&autofs4_ioctl_mutex);
992 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
993 mutex_unlock(&autofs4_ioctl_mutex);
994
995 return ret;
996} 988}
997 989
998#ifdef CONFIG_COMPAT 990#ifdef CONFIG_COMPAT
@@ -1002,13 +994,11 @@ static long autofs4_root_compat_ioctl(struct file *filp,
1002 struct inode *inode = filp->f_path.dentry->d_inode; 994 struct inode *inode = filp->f_path.dentry->d_inode;
1003 int ret; 995 int ret;
1004 996
1005 mutex_lock(&autofs4_ioctl_mutex);
1006 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL) 997 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
1007 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); 998 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
1008 else 999 else
1009 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, 1000 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd,
1010 (unsigned long)compat_ptr(arg)); 1001 (unsigned long)compat_ptr(arg));
1011 mutex_unlock(&autofs4_ioctl_mutex);
1012 1002
1013 return ret; 1003 return ret;
1014} 1004}
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 06e8ff12b97c..4230252fd689 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -11,7 +11,6 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/kmod.h> 12#include <linux/kmod.h>
13#include <linux/major.h> 13#include <linux/major.h>
14#include <linux/smp_lock.h>
15#include <linux/device_cgroup.h> 14#include <linux/device_cgroup.h>
16#include <linux/highmem.h> 15#include <linux/highmem.h>
17#include <linux/blkdev.h> 16#include <linux/blkdev.h>
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 7845d1f7d1d9..b50bc4bd5c56 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -91,23 +91,10 @@ static inline int compressed_bio_size(struct btrfs_root *root,
91static struct bio *compressed_bio_alloc(struct block_device *bdev, 91static struct bio *compressed_bio_alloc(struct block_device *bdev,
92 u64 first_byte, gfp_t gfp_flags) 92 u64 first_byte, gfp_t gfp_flags)
93{ 93{
94 struct bio *bio;
95 int nr_vecs; 94 int nr_vecs;
96 95
97 nr_vecs = bio_get_nr_vecs(bdev); 96 nr_vecs = bio_get_nr_vecs(bdev);
98 bio = bio_alloc(gfp_flags, nr_vecs); 97 return btrfs_bio_alloc(bdev, first_byte >> 9, nr_vecs, gfp_flags);
99
100 if (bio == NULL && (current->flags & PF_MEMALLOC)) {
101 while (!bio && (nr_vecs /= 2))
102 bio = bio_alloc(gfp_flags, nr_vecs);
103 }
104
105 if (bio) {
106 bio->bi_size = 0;
107 bio->bi_bdev = bdev;
108 bio->bi_sector = first_byte >> 9;
109 }
110 return bio;
111} 98}
112 99
113static int check_compressed_csum(struct inode *inode, 100static int check_compressed_csum(struct inode *inode,
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 8db9234f6b41..af52f6d7a4d8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -808,9 +808,9 @@ struct btrfs_block_group_cache {
808 int extents_thresh; 808 int extents_thresh;
809 int free_extents; 809 int free_extents;
810 int total_bitmaps; 810 int total_bitmaps;
811 int ro:1; 811 unsigned int ro:1;
812 int dirty:1; 812 unsigned int dirty:1;
813 int iref:1; 813 unsigned int iref:1;
814 814
815 int disk_cache_state; 815 int disk_cache_state;
816 816
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index fb827d0d7181..51d2e4de34eb 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -28,6 +28,7 @@
28#include <linux/freezer.h> 28#include <linux/freezer.h>
29#include <linux/crc32c.h> 29#include <linux/crc32c.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/migrate.h>
31#include "compat.h" 32#include "compat.h"
32#include "ctree.h" 33#include "ctree.h"
33#include "disk-io.h" 34#include "disk-io.h"
@@ -355,6 +356,8 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
355 ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE, 356 ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE,
356 btrfs_header_generation(eb)); 357 btrfs_header_generation(eb));
357 BUG_ON(ret); 358 BUG_ON(ret);
359 WARN_ON(!btrfs_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN));
360
358 found_start = btrfs_header_bytenr(eb); 361 found_start = btrfs_header_bytenr(eb);
359 if (found_start != start) { 362 if (found_start != start) {
360 WARN_ON(1); 363 WARN_ON(1);
@@ -693,6 +696,27 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
693 __btree_submit_bio_done); 696 __btree_submit_bio_done);
694} 697}
695 698
699#ifdef CONFIG_MIGRATION
700static int btree_migratepage(struct address_space *mapping,
701 struct page *newpage, struct page *page)
702{
703 /*
704 * we can't safely write a btree page from here,
705 * we haven't done the locking hook
706 */
707 if (PageDirty(page))
708 return -EAGAIN;
709 /*
710 * Buffers may be managed in a filesystem specific way.
711 * We must have no buffers or drop them.
712 */
713 if (page_has_private(page) &&
714 !try_to_release_page(page, GFP_KERNEL))
715 return -EAGAIN;
716 return migrate_page(mapping, newpage, page);
717}
718#endif
719
696static int btree_writepage(struct page *page, struct writeback_control *wbc) 720static int btree_writepage(struct page *page, struct writeback_control *wbc)
697{ 721{
698 struct extent_io_tree *tree; 722 struct extent_io_tree *tree;
@@ -707,8 +731,7 @@ static int btree_writepage(struct page *page, struct writeback_control *wbc)
707 } 731 }
708 732
709 redirty_page_for_writepage(wbc, page); 733 redirty_page_for_writepage(wbc, page);
710 eb = btrfs_find_tree_block(root, page_offset(page), 734 eb = btrfs_find_tree_block(root, page_offset(page), PAGE_CACHE_SIZE);
711 PAGE_CACHE_SIZE);
712 WARN_ON(!eb); 735 WARN_ON(!eb);
713 736
714 was_dirty = test_and_set_bit(EXTENT_BUFFER_DIRTY, &eb->bflags); 737 was_dirty = test_and_set_bit(EXTENT_BUFFER_DIRTY, &eb->bflags);
@@ -799,6 +822,9 @@ static const struct address_space_operations btree_aops = {
799 .releasepage = btree_releasepage, 822 .releasepage = btree_releasepage,
800 .invalidatepage = btree_invalidatepage, 823 .invalidatepage = btree_invalidatepage,
801 .sync_page = block_sync_page, 824 .sync_page = block_sync_page,
825#ifdef CONFIG_MIGRATION
826 .migratepage = btree_migratepage,
827#endif
802}; 828};
803 829
804int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, 830int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
@@ -981,7 +1007,10 @@ static int find_and_setup_root(struct btrfs_root *tree_root,
981 blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); 1007 blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item));
982 root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), 1008 root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
983 blocksize, generation); 1009 blocksize, generation);
984 BUG_ON(!root->node); 1010 if (!root->node || !btrfs_buffer_uptodate(root->node, generation)) {
1011 free_extent_buffer(root->node);
1012 return -EIO;
1013 }
985 root->commit_root = btrfs_root_node(root); 1014 root->commit_root = btrfs_root_node(root);
986 return 0; 1015 return 0;
987} 1016}
@@ -1538,10 +1567,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1538 GFP_NOFS); 1567 GFP_NOFS);
1539 struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root), 1568 struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root),
1540 GFP_NOFS); 1569 GFP_NOFS);
1541 struct btrfs_root *tree_root = kzalloc(sizeof(struct btrfs_root), 1570 struct btrfs_root *tree_root = btrfs_sb(sb);
1542 GFP_NOFS); 1571 struct btrfs_fs_info *fs_info = tree_root->fs_info;
1543 struct btrfs_fs_info *fs_info = kzalloc(sizeof(*fs_info),
1544 GFP_NOFS);
1545 struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root), 1572 struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root),
1546 GFP_NOFS); 1573 GFP_NOFS);
1547 struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root), 1574 struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root),
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 951ef09b82f4..659f532d26a0 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -166,7 +166,7 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
166static struct dentry *btrfs_get_parent(struct dentry *child) 166static struct dentry *btrfs_get_parent(struct dentry *child)
167{ 167{
168 struct inode *dir = child->d_inode; 168 struct inode *dir = child->d_inode;
169 static struct dentry *dentry; 169 struct dentry *dentry;
170 struct btrfs_root *root = BTRFS_I(dir)->root; 170 struct btrfs_root *root = BTRFS_I(dir)->root;
171 struct btrfs_path *path; 171 struct btrfs_path *path;
172 struct extent_buffer *leaf; 172 struct extent_buffer *leaf;
@@ -232,9 +232,85 @@ fail:
232 return ERR_PTR(ret); 232 return ERR_PTR(ret);
233} 233}
234 234
235static int btrfs_get_name(struct dentry *parent, char *name,
236 struct dentry *child)
237{
238 struct inode *inode = child->d_inode;
239 struct inode *dir = parent->d_inode;
240 struct btrfs_path *path;
241 struct btrfs_root *root = BTRFS_I(dir)->root;
242 struct btrfs_inode_ref *iref;
243 struct btrfs_root_ref *rref;
244 struct extent_buffer *leaf;
245 unsigned long name_ptr;
246 struct btrfs_key key;
247 int name_len;
248 int ret;
249
250 if (!dir || !inode)
251 return -EINVAL;
252
253 if (!S_ISDIR(dir->i_mode))
254 return -EINVAL;
255
256 path = btrfs_alloc_path();
257 if (!path)
258 return -ENOMEM;
259 path->leave_spinning = 1;
260
261 if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) {
262 key.objectid = BTRFS_I(inode)->root->root_key.objectid;
263 key.type = BTRFS_ROOT_BACKREF_KEY;
264 key.offset = (u64)-1;
265 root = root->fs_info->tree_root;
266 } else {
267 key.objectid = inode->i_ino;
268 key.offset = dir->i_ino;
269 key.type = BTRFS_INODE_REF_KEY;
270 }
271
272 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
273 if (ret < 0) {
274 btrfs_free_path(path);
275 return ret;
276 } else if (ret > 0) {
277 if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) {
278 path->slots[0]--;
279 } else {
280 btrfs_free_path(path);
281 return -ENOENT;
282 }
283 }
284 leaf = path->nodes[0];
285
286 if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) {
287 rref = btrfs_item_ptr(leaf, path->slots[0],
288 struct btrfs_root_ref);
289 name_ptr = (unsigned long)(rref + 1);
290 name_len = btrfs_root_ref_name_len(leaf, rref);
291 } else {
292 iref = btrfs_item_ptr(leaf, path->slots[0],
293 struct btrfs_inode_ref);
294 name_ptr = (unsigned long)(iref + 1);
295 name_len = btrfs_inode_ref_name_len(leaf, iref);
296 }
297
298 read_extent_buffer(leaf, name, name_ptr, name_len);
299 btrfs_free_path(path);
300
301 /*
302 * have to add the null termination to make sure that reconnect_path
303 * gets the right len for strlen
304 */
305 name[name_len] = '\0';
306
307 return 0;
308}
309
235const struct export_operations btrfs_export_ops = { 310const struct export_operations btrfs_export_ops = {
236 .encode_fh = btrfs_encode_fh, 311 .encode_fh = btrfs_encode_fh,
237 .fh_to_dentry = btrfs_fh_to_dentry, 312 .fh_to_dentry = btrfs_fh_to_dentry,
238 .fh_to_parent = btrfs_fh_to_parent, 313 .fh_to_parent = btrfs_fh_to_parent,
239 .get_parent = btrfs_get_parent, 314 .get_parent = btrfs_get_parent,
315 .get_name = btrfs_get_name,
240}; 316};
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0c097f3aec41..227e5815d838 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -429,6 +429,7 @@ err:
429 429
430static int cache_block_group(struct btrfs_block_group_cache *cache, 430static int cache_block_group(struct btrfs_block_group_cache *cache,
431 struct btrfs_trans_handle *trans, 431 struct btrfs_trans_handle *trans,
432 struct btrfs_root *root,
432 int load_cache_only) 433 int load_cache_only)
433{ 434{
434 struct btrfs_fs_info *fs_info = cache->fs_info; 435 struct btrfs_fs_info *fs_info = cache->fs_info;
@@ -442,9 +443,12 @@ static int cache_block_group(struct btrfs_block_group_cache *cache,
442 443
443 /* 444 /*
444 * We can't do the read from on-disk cache during a commit since we need 445 * We can't do the read from on-disk cache during a commit since we need
445 * to have the normal tree locking. 446 * to have the normal tree locking. Also if we are currently trying to
447 * allocate blocks for the tree root we can't do the fast caching since
448 * we likely hold important locks.
446 */ 449 */
447 if (!trans->transaction->in_commit) { 450 if (!trans->transaction->in_commit &&
451 (root && root != root->fs_info->tree_root)) {
448 spin_lock(&cache->lock); 452 spin_lock(&cache->lock);
449 if (cache->cached != BTRFS_CACHE_NO) { 453 if (cache->cached != BTRFS_CACHE_NO) {
450 spin_unlock(&cache->lock); 454 spin_unlock(&cache->lock);
@@ -2741,6 +2745,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
2741 struct btrfs_root *root = block_group->fs_info->tree_root; 2745 struct btrfs_root *root = block_group->fs_info->tree_root;
2742 struct inode *inode = NULL; 2746 struct inode *inode = NULL;
2743 u64 alloc_hint = 0; 2747 u64 alloc_hint = 0;
2748 int dcs = BTRFS_DC_ERROR;
2744 int num_pages = 0; 2749 int num_pages = 0;
2745 int retries = 0; 2750 int retries = 0;
2746 int ret = 0; 2751 int ret = 0;
@@ -2795,6 +2800,8 @@ again:
2795 2800
2796 spin_lock(&block_group->lock); 2801 spin_lock(&block_group->lock);
2797 if (block_group->cached != BTRFS_CACHE_FINISHED) { 2802 if (block_group->cached != BTRFS_CACHE_FINISHED) {
2803 /* We're not cached, don't bother trying to write stuff out */
2804 dcs = BTRFS_DC_WRITTEN;
2798 spin_unlock(&block_group->lock); 2805 spin_unlock(&block_group->lock);
2799 goto out_put; 2806 goto out_put;
2800 } 2807 }
@@ -2821,6 +2828,8 @@ again:
2821 ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages, 2828 ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages,
2822 num_pages, num_pages, 2829 num_pages, num_pages,
2823 &alloc_hint); 2830 &alloc_hint);
2831 if (!ret)
2832 dcs = BTRFS_DC_SETUP;
2824 btrfs_free_reserved_data_space(inode, num_pages); 2833 btrfs_free_reserved_data_space(inode, num_pages);
2825out_put: 2834out_put:
2826 iput(inode); 2835 iput(inode);
@@ -2828,10 +2837,7 @@ out_free:
2828 btrfs_release_path(root, path); 2837 btrfs_release_path(root, path);
2829out: 2838out:
2830 spin_lock(&block_group->lock); 2839 spin_lock(&block_group->lock);
2831 if (ret) 2840 block_group->disk_cache_state = dcs;
2832 block_group->disk_cache_state = BTRFS_DC_ERROR;
2833 else
2834 block_group->disk_cache_state = BTRFS_DC_SETUP;
2835 spin_unlock(&block_group->lock); 2841 spin_unlock(&block_group->lock);
2836 2842
2837 return ret; 2843 return ret;
@@ -3037,7 +3043,13 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags)
3037 3043
3038u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags) 3044u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags)
3039{ 3045{
3040 u64 num_devices = root->fs_info->fs_devices->rw_devices; 3046 /*
3047 * we add in the count of missing devices because we want
3048 * to make sure that any RAID levels on a degraded FS
3049 * continue to be honored.
3050 */
3051 u64 num_devices = root->fs_info->fs_devices->rw_devices +
3052 root->fs_info->fs_devices->missing_devices;
3041 3053
3042 if (num_devices == 1) 3054 if (num_devices == 1)
3043 flags &= ~(BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID0); 3055 flags &= ~(BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID0);
@@ -3412,7 +3424,7 @@ again:
3412 * our reservation. 3424 * our reservation.
3413 */ 3425 */
3414 if (unused <= space_info->total_bytes) { 3426 if (unused <= space_info->total_bytes) {
3415 unused -= space_info->total_bytes; 3427 unused = space_info->total_bytes - unused;
3416 if (unused >= num_bytes) { 3428 if (unused >= num_bytes) {
3417 if (!reserved) 3429 if (!reserved)
3418 space_info->bytes_reserved += orig_bytes; 3430 space_info->bytes_reserved += orig_bytes;
@@ -4080,7 +4092,7 @@ static int update_block_group(struct btrfs_trans_handle *trans,
4080 * space back to the block group, otherwise we will leak space. 4092 * space back to the block group, otherwise we will leak space.
4081 */ 4093 */
4082 if (!alloc && cache->cached == BTRFS_CACHE_NO) 4094 if (!alloc && cache->cached == BTRFS_CACHE_NO)
4083 cache_block_group(cache, trans, 1); 4095 cache_block_group(cache, trans, NULL, 1);
4084 4096
4085 byte_in_group = bytenr - cache->key.objectid; 4097 byte_in_group = bytenr - cache->key.objectid;
4086 WARN_ON(byte_in_group > cache->key.offset); 4098 WARN_ON(byte_in_group > cache->key.offset);
@@ -4930,11 +4942,31 @@ search:
4930 btrfs_get_block_group(block_group); 4942 btrfs_get_block_group(block_group);
4931 search_start = block_group->key.objectid; 4943 search_start = block_group->key.objectid;
4932 4944
4945 /*
4946 * this can happen if we end up cycling through all the
4947 * raid types, but we want to make sure we only allocate
4948 * for the proper type.
4949 */
4950 if (!block_group_bits(block_group, data)) {
4951 u64 extra = BTRFS_BLOCK_GROUP_DUP |
4952 BTRFS_BLOCK_GROUP_RAID1 |
4953 BTRFS_BLOCK_GROUP_RAID10;
4954
4955 /*
4956 * if they asked for extra copies and this block group
4957 * doesn't provide them, bail. This does allow us to
4958 * fill raid0 from raid1.
4959 */
4960 if ((data & extra) && !(block_group->flags & extra))
4961 goto loop;
4962 }
4963
4933have_block_group: 4964have_block_group:
4934 if (unlikely(block_group->cached == BTRFS_CACHE_NO)) { 4965 if (unlikely(block_group->cached == BTRFS_CACHE_NO)) {
4935 u64 free_percent; 4966 u64 free_percent;
4936 4967
4937 ret = cache_block_group(block_group, trans, 1); 4968 ret = cache_block_group(block_group, trans,
4969 orig_root, 1);
4938 if (block_group->cached == BTRFS_CACHE_FINISHED) 4970 if (block_group->cached == BTRFS_CACHE_FINISHED)
4939 goto have_block_group; 4971 goto have_block_group;
4940 4972
@@ -4958,7 +4990,8 @@ have_block_group:
4958 if (loop > LOOP_CACHING_NOWAIT || 4990 if (loop > LOOP_CACHING_NOWAIT ||
4959 (loop > LOOP_FIND_IDEAL && 4991 (loop > LOOP_FIND_IDEAL &&
4960 atomic_read(&space_info->caching_threads) < 2)) { 4992 atomic_read(&space_info->caching_threads) < 2)) {
4961 ret = cache_block_group(block_group, trans, 0); 4993 ret = cache_block_group(block_group, trans,
4994 orig_root, 0);
4962 BUG_ON(ret); 4995 BUG_ON(ret);
4963 } 4996 }
4964 found_uncached_bg = true; 4997 found_uncached_bg = true;
@@ -5515,7 +5548,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
5515 u64 num_bytes = ins->offset; 5548 u64 num_bytes = ins->offset;
5516 5549
5517 block_group = btrfs_lookup_block_group(root->fs_info, ins->objectid); 5550 block_group = btrfs_lookup_block_group(root->fs_info, ins->objectid);
5518 cache_block_group(block_group, trans, 0); 5551 cache_block_group(block_group, trans, NULL, 0);
5519 caching_ctl = get_caching_control(block_group); 5552 caching_ctl = get_caching_control(block_group);
5520 5553
5521 if (!caching_ctl) { 5554 if (!caching_ctl) {
@@ -6300,9 +6333,13 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
6300 NULL, NULL); 6333 NULL, NULL);
6301 BUG_ON(ret < 0); 6334 BUG_ON(ret < 0);
6302 if (ret > 0) { 6335 if (ret > 0) {
6303 ret = btrfs_del_orphan_item(trans, tree_root, 6336 /* if we fail to delete the orphan item this time
6304 root->root_key.objectid); 6337 * around, it'll get picked up the next time.
6305 BUG_ON(ret); 6338 *
6339 * The most common failure here is just -ENOENT.
6340 */
6341 btrfs_del_orphan_item(trans, tree_root,
6342 root->root_key.objectid);
6306 } 6343 }
6307 } 6344 }
6308 6345
@@ -7878,7 +7915,14 @@ static u64 update_block_group_flags(struct btrfs_root *root, u64 flags)
7878 u64 stripped = BTRFS_BLOCK_GROUP_RAID0 | 7915 u64 stripped = BTRFS_BLOCK_GROUP_RAID0 |
7879 BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID10; 7916 BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID10;
7880 7917
7881 num_devices = root->fs_info->fs_devices->rw_devices; 7918 /*
7919 * we add in the count of missing devices because we want
7920 * to make sure that any RAID levels on a degraded FS
7921 * continue to be honored.
7922 */
7923 num_devices = root->fs_info->fs_devices->rw_devices +
7924 root->fs_info->fs_devices->missing_devices;
7925
7882 if (num_devices == 1) { 7926 if (num_devices == 1) {
7883 stripped |= BTRFS_BLOCK_GROUP_DUP; 7927 stripped |= BTRFS_BLOCK_GROUP_DUP;
7884 stripped = flags & ~stripped; 7928 stripped = flags & ~stripped;
@@ -8247,7 +8291,6 @@ int btrfs_read_block_groups(struct btrfs_root *root)
8247 break; 8291 break;
8248 if (ret != 0) 8292 if (ret != 0)
8249 goto error; 8293 goto error;
8250
8251 leaf = path->nodes[0]; 8294 leaf = path->nodes[0];
8252 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 8295 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
8253 cache = kzalloc(sizeof(*cache), GFP_NOFS); 8296 cache = kzalloc(sizeof(*cache), GFP_NOFS);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index eac10e3260a9..3e86b9f36507 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1828,9 +1828,9 @@ static void end_bio_extent_preparewrite(struct bio *bio, int err)
1828 bio_put(bio); 1828 bio_put(bio);
1829} 1829}
1830 1830
1831static struct bio * 1831struct bio *
1832extent_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs, 1832btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
1833 gfp_t gfp_flags) 1833 gfp_t gfp_flags)
1834{ 1834{
1835 struct bio *bio; 1835 struct bio *bio;
1836 1836
@@ -1919,7 +1919,7 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree,
1919 else 1919 else
1920 nr = bio_get_nr_vecs(bdev); 1920 nr = bio_get_nr_vecs(bdev);
1921 1921
1922 bio = extent_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH); 1922 bio = btrfs_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH);
1923 1923
1924 bio_add_page(bio, page, page_size, offset); 1924 bio_add_page(bio, page, page_size, offset);
1925 bio->bi_end_io = end_io_func; 1925 bio->bi_end_io = end_io_func;
@@ -2901,21 +2901,53 @@ out:
2901int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 2901int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2902 __u64 start, __u64 len, get_extent_t *get_extent) 2902 __u64 start, __u64 len, get_extent_t *get_extent)
2903{ 2903{
2904 int ret; 2904 int ret = 0;
2905 u64 off = start; 2905 u64 off = start;
2906 u64 max = start + len; 2906 u64 max = start + len;
2907 u32 flags = 0; 2907 u32 flags = 0;
2908 u32 found_type;
2909 u64 last;
2908 u64 disko = 0; 2910 u64 disko = 0;
2911 struct btrfs_key found_key;
2909 struct extent_map *em = NULL; 2912 struct extent_map *em = NULL;
2910 struct extent_state *cached_state = NULL; 2913 struct extent_state *cached_state = NULL;
2914 struct btrfs_path *path;
2915 struct btrfs_file_extent_item *item;
2911 int end = 0; 2916 int end = 0;
2912 u64 em_start = 0, em_len = 0; 2917 u64 em_start = 0, em_len = 0;
2913 unsigned long emflags; 2918 unsigned long emflags;
2914 ret = 0; 2919 int hole = 0;
2915 2920
2916 if (len == 0) 2921 if (len == 0)
2917 return -EINVAL; 2922 return -EINVAL;
2918 2923
2924 path = btrfs_alloc_path();
2925 if (!path)
2926 return -ENOMEM;
2927 path->leave_spinning = 1;
2928
2929 ret = btrfs_lookup_file_extent(NULL, BTRFS_I(inode)->root,
2930 path, inode->i_ino, -1, 0);
2931 if (ret < 0) {
2932 btrfs_free_path(path);
2933 return ret;
2934 }
2935 WARN_ON(!ret);
2936 path->slots[0]--;
2937 item = btrfs_item_ptr(path->nodes[0], path->slots[0],
2938 struct btrfs_file_extent_item);
2939 btrfs_item_key_to_cpu(path->nodes[0], &found_key, path->slots[0]);
2940 found_type = btrfs_key_type(&found_key);
2941
2942 /* No extents, just return */
2943 if (found_key.objectid != inode->i_ino ||
2944 found_type != BTRFS_EXTENT_DATA_KEY) {
2945 btrfs_free_path(path);
2946 return 0;
2947 }
2948 last = found_key.offset;
2949 btrfs_free_path(path);
2950
2919 lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len, 0, 2951 lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len, 0,
2920 &cached_state, GFP_NOFS); 2952 &cached_state, GFP_NOFS);
2921 em = get_extent(inode, NULL, 0, off, max - off, 0); 2953 em = get_extent(inode, NULL, 0, off, max - off, 0);
@@ -2925,11 +2957,18 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2925 ret = PTR_ERR(em); 2957 ret = PTR_ERR(em);
2926 goto out; 2958 goto out;
2927 } 2959 }
2960
2928 while (!end) { 2961 while (!end) {
2962 hole = 0;
2929 off = em->start + em->len; 2963 off = em->start + em->len;
2930 if (off >= max) 2964 if (off >= max)
2931 end = 1; 2965 end = 1;
2932 2966
2967 if (em->block_start == EXTENT_MAP_HOLE) {
2968 hole = 1;
2969 goto next;
2970 }
2971
2933 em_start = em->start; 2972 em_start = em->start;
2934 em_len = em->len; 2973 em_len = em->len;
2935 2974
@@ -2939,8 +2978,6 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2939 if (em->block_start == EXTENT_MAP_LAST_BYTE) { 2978 if (em->block_start == EXTENT_MAP_LAST_BYTE) {
2940 end = 1; 2979 end = 1;
2941 flags |= FIEMAP_EXTENT_LAST; 2980 flags |= FIEMAP_EXTENT_LAST;
2942 } else if (em->block_start == EXTENT_MAP_HOLE) {
2943 flags |= FIEMAP_EXTENT_UNWRITTEN;
2944 } else if (em->block_start == EXTENT_MAP_INLINE) { 2981 } else if (em->block_start == EXTENT_MAP_INLINE) {
2945 flags |= (FIEMAP_EXTENT_DATA_INLINE | 2982 flags |= (FIEMAP_EXTENT_DATA_INLINE |
2946 FIEMAP_EXTENT_NOT_ALIGNED); 2983 FIEMAP_EXTENT_NOT_ALIGNED);
@@ -2953,10 +2990,10 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2953 if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) 2990 if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags))
2954 flags |= FIEMAP_EXTENT_ENCODED; 2991 flags |= FIEMAP_EXTENT_ENCODED;
2955 2992
2993next:
2956 emflags = em->flags; 2994 emflags = em->flags;
2957 free_extent_map(em); 2995 free_extent_map(em);
2958 em = NULL; 2996 em = NULL;
2959
2960 if (!end) { 2997 if (!end) {
2961 em = get_extent(inode, NULL, 0, off, max - off, 0); 2998 em = get_extent(inode, NULL, 0, off, max - off, 0);
2962 if (!em) 2999 if (!em)
@@ -2967,15 +3004,23 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2967 } 3004 }
2968 emflags = em->flags; 3005 emflags = em->flags;
2969 } 3006 }
3007
2970 if (test_bit(EXTENT_FLAG_VACANCY, &emflags)) { 3008 if (test_bit(EXTENT_FLAG_VACANCY, &emflags)) {
2971 flags |= FIEMAP_EXTENT_LAST; 3009 flags |= FIEMAP_EXTENT_LAST;
2972 end = 1; 3010 end = 1;
2973 } 3011 }
2974 3012
2975 ret = fiemap_fill_next_extent(fieinfo, em_start, disko, 3013 if (em_start == last) {
2976 em_len, flags); 3014 flags |= FIEMAP_EXTENT_LAST;
2977 if (ret) 3015 end = 1;
2978 goto out_free; 3016 }
3017
3018 if (!hole) {
3019 ret = fiemap_fill_next_extent(fieinfo, em_start, disko,
3020 em_len, flags);
3021 if (ret)
3022 goto out_free;
3023 }
2979 } 3024 }
2980out_free: 3025out_free:
2981 free_extent_map(em); 3026 free_extent_map(em);
@@ -3836,8 +3881,10 @@ int try_release_extent_buffer(struct extent_io_tree *tree, struct page *page)
3836 3881
3837 spin_lock(&tree->buffer_lock); 3882 spin_lock(&tree->buffer_lock);
3838 eb = radix_tree_lookup(&tree->buffer, start >> PAGE_CACHE_SHIFT); 3883 eb = radix_tree_lookup(&tree->buffer, start >> PAGE_CACHE_SHIFT);
3839 if (!eb) 3884 if (!eb) {
3840 goto out; 3885 spin_unlock(&tree->buffer_lock);
3886 return ret;
3887 }
3841 3888
3842 if (test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) { 3889 if (test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) {
3843 ret = 0; 3890 ret = 0;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 1c6d4f342ef7..4183c8178f01 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -310,4 +310,7 @@ int extent_clear_unlock_delalloc(struct inode *inode,
310 struct extent_io_tree *tree, 310 struct extent_io_tree *tree,
311 u64 start, u64 end, struct page *locked_page, 311 u64 start, u64 end, struct page *locked_page,
312 unsigned long op); 312 unsigned long op);
313struct bio *
314btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs,
315 gfp_t gfp_flags);
313#endif 316#endif
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index e354c33df082..66836d85763b 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -48,30 +48,34 @@ static noinline int btrfs_copy_from_user(loff_t pos, int num_pages,
48 struct page **prepared_pages, 48 struct page **prepared_pages,
49 struct iov_iter *i) 49 struct iov_iter *i)
50{ 50{
51 size_t copied; 51 size_t copied = 0;
52 int pg = 0; 52 int pg = 0;
53 int offset = pos & (PAGE_CACHE_SIZE - 1); 53 int offset = pos & (PAGE_CACHE_SIZE - 1);
54 int total_copied = 0;
54 55
55 while (write_bytes > 0) { 56 while (write_bytes > 0) {
56 size_t count = min_t(size_t, 57 size_t count = min_t(size_t,
57 PAGE_CACHE_SIZE - offset, write_bytes); 58 PAGE_CACHE_SIZE - offset, write_bytes);
58 struct page *page = prepared_pages[pg]; 59 struct page *page = prepared_pages[pg];
59again: 60 /*
60 if (unlikely(iov_iter_fault_in_readable(i, count))) 61 * Copy data from userspace to the current page
61 return -EFAULT; 62 *
62 63 * Disable pagefault to avoid recursive lock since
63 /* Copy data from userspace to the current page */ 64 * the pages are already locked
64 copied = iov_iter_copy_from_user(page, i, offset, count); 65 */
66 pagefault_disable();
67 copied = iov_iter_copy_from_user_atomic(page, i, offset, count);
68 pagefault_enable();
65 69
66 /* Flush processor's dcache for this page */ 70 /* Flush processor's dcache for this page */
67 flush_dcache_page(page); 71 flush_dcache_page(page);
68 iov_iter_advance(i, copied); 72 iov_iter_advance(i, copied);
69 write_bytes -= copied; 73 write_bytes -= copied;
74 total_copied += copied;
70 75
76 /* Return to btrfs_file_aio_write to fault page */
71 if (unlikely(copied == 0)) { 77 if (unlikely(copied == 0)) {
72 count = min_t(size_t, PAGE_CACHE_SIZE - offset, 78 break;
73 iov_iter_single_seg_count(i));
74 goto again;
75 } 79 }
76 80
77 if (unlikely(copied < PAGE_CACHE_SIZE - offset)) { 81 if (unlikely(copied < PAGE_CACHE_SIZE - offset)) {
@@ -81,7 +85,7 @@ again:
81 offset = 0; 85 offset = 0;
82 } 86 }
83 } 87 }
84 return 0; 88 return total_copied;
85} 89}
86 90
87/* 91/*
@@ -854,6 +858,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
854 unsigned long last_index; 858 unsigned long last_index;
855 int will_write; 859 int will_write;
856 int buffered = 0; 860 int buffered = 0;
861 int copied = 0;
862 int dirty_pages = 0;
857 863
858 will_write = ((file->f_flags & O_DSYNC) || IS_SYNC(inode) || 864 will_write = ((file->f_flags & O_DSYNC) || IS_SYNC(inode) ||
859 (file->f_flags & O_DIRECT)); 865 (file->f_flags & O_DIRECT));
@@ -970,7 +976,17 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
970 WARN_ON(num_pages > nrptrs); 976 WARN_ON(num_pages > nrptrs);
971 memset(pages, 0, sizeof(struct page *) * nrptrs); 977 memset(pages, 0, sizeof(struct page *) * nrptrs);
972 978
973 ret = btrfs_delalloc_reserve_space(inode, write_bytes); 979 /*
980 * Fault pages before locking them in prepare_pages
981 * to avoid recursive lock
982 */
983 if (unlikely(iov_iter_fault_in_readable(&i, write_bytes))) {
984 ret = -EFAULT;
985 goto out;
986 }
987
988 ret = btrfs_delalloc_reserve_space(inode,
989 num_pages << PAGE_CACHE_SHIFT);
974 if (ret) 990 if (ret)
975 goto out; 991 goto out;
976 992
@@ -978,37 +994,49 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
978 pos, first_index, last_index, 994 pos, first_index, last_index,
979 write_bytes); 995 write_bytes);
980 if (ret) { 996 if (ret) {
981 btrfs_delalloc_release_space(inode, write_bytes); 997 btrfs_delalloc_release_space(inode,
998 num_pages << PAGE_CACHE_SHIFT);
982 goto out; 999 goto out;
983 } 1000 }
984 1001
985 ret = btrfs_copy_from_user(pos, num_pages, 1002 copied = btrfs_copy_from_user(pos, num_pages,
986 write_bytes, pages, &i); 1003 write_bytes, pages, &i);
987 if (ret == 0) { 1004 dirty_pages = (copied + PAGE_CACHE_SIZE - 1) >>
1005 PAGE_CACHE_SHIFT;
1006
1007 if (num_pages > dirty_pages) {
1008 if (copied > 0)
1009 atomic_inc(
1010 &BTRFS_I(inode)->outstanding_extents);
1011 btrfs_delalloc_release_space(inode,
1012 (num_pages - dirty_pages) <<
1013 PAGE_CACHE_SHIFT);
1014 }
1015
1016 if (copied > 0) {
988 dirty_and_release_pages(NULL, root, file, pages, 1017 dirty_and_release_pages(NULL, root, file, pages,
989 num_pages, pos, write_bytes); 1018 dirty_pages, pos, copied);
990 } 1019 }
991 1020
992 btrfs_drop_pages(pages, num_pages); 1021 btrfs_drop_pages(pages, num_pages);
993 if (ret) {
994 btrfs_delalloc_release_space(inode, write_bytes);
995 goto out;
996 }
997 1022
998 if (will_write) { 1023 if (copied > 0) {
999 filemap_fdatawrite_range(inode->i_mapping, pos, 1024 if (will_write) {
1000 pos + write_bytes - 1); 1025 filemap_fdatawrite_range(inode->i_mapping, pos,
1001 } else { 1026 pos + copied - 1);
1002 balance_dirty_pages_ratelimited_nr(inode->i_mapping, 1027 } else {
1003 num_pages); 1028 balance_dirty_pages_ratelimited_nr(
1004 if (num_pages < 1029 inode->i_mapping,
1005 (root->leafsize >> PAGE_CACHE_SHIFT) + 1) 1030 dirty_pages);
1006 btrfs_btree_balance_dirty(root, 1); 1031 if (dirty_pages <
1007 btrfs_throttle(root); 1032 (root->leafsize >> PAGE_CACHE_SHIFT) + 1)
1033 btrfs_btree_balance_dirty(root, 1);
1034 btrfs_throttle(root);
1035 }
1008 } 1036 }
1009 1037
1010 pos += write_bytes; 1038 pos += copied;
1011 num_written += write_bytes; 1039 num_written += copied;
1012 1040
1013 cond_resched(); 1041 cond_resched();
1014 } 1042 }
@@ -1047,8 +1075,14 @@ out:
1047 1075
1048 if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) { 1076 if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) {
1049 trans = btrfs_start_transaction(root, 0); 1077 trans = btrfs_start_transaction(root, 0);
1078 if (IS_ERR(trans)) {
1079 num_written = PTR_ERR(trans);
1080 goto done;
1081 }
1082 mutex_lock(&inode->i_mutex);
1050 ret = btrfs_log_dentry_safe(trans, root, 1083 ret = btrfs_log_dentry_safe(trans, root,
1051 file->f_dentry); 1084 file->f_dentry);
1085 mutex_unlock(&inode->i_mutex);
1052 if (ret == 0) { 1086 if (ret == 0) {
1053 ret = btrfs_sync_log(trans, root); 1087 ret = btrfs_sync_log(trans, root);
1054 if (ret == 0) 1088 if (ret == 0)
@@ -1067,6 +1101,7 @@ out:
1067 (start_pos + num_written - 1) >> PAGE_CACHE_SHIFT); 1101 (start_pos + num_written - 1) >> PAGE_CACHE_SHIFT);
1068 } 1102 }
1069 } 1103 }
1104done:
1070 current->backing_dev_info = NULL; 1105 current->backing_dev_info = NULL;
1071 return num_written ? num_written : err; 1106 return num_written ? num_written : err;
1072} 1107}
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 22ee0dc2e6b8..60d684266959 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -290,7 +290,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
290 (unsigned long long)BTRFS_I(inode)->generation, 290 (unsigned long long)BTRFS_I(inode)->generation,
291 (unsigned long long)generation, 291 (unsigned long long)generation,
292 (unsigned long long)block_group->key.objectid); 292 (unsigned long long)block_group->key.objectid);
293 goto out; 293 goto free_cache;
294 } 294 }
295 295
296 if (!num_entries) 296 if (!num_entries)
@@ -524,6 +524,12 @@ int btrfs_write_out_cache(struct btrfs_root *root,
524 return 0; 524 return 0;
525 } 525 }
526 526
527 node = rb_first(&block_group->free_space_offset);
528 if (!node) {
529 iput(inode);
530 return 0;
531 }
532
527 last_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT; 533 last_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT;
528 filemap_write_and_wait(inode->i_mapping); 534 filemap_write_and_wait(inode->i_mapping);
529 btrfs_wait_ordered_range(inode, inode->i_size & 535 btrfs_wait_ordered_range(inode, inode->i_size &
@@ -543,10 +549,6 @@ int btrfs_write_out_cache(struct btrfs_root *root,
543 */ 549 */
544 first_page_offset = (sizeof(u32) * num_checksums) + sizeof(u64); 550 first_page_offset = (sizeof(u32) * num_checksums) + sizeof(u64);
545 551
546 node = rb_first(&block_group->free_space_offset);
547 if (!node)
548 goto out_free;
549
550 /* 552 /*
551 * Lock all pages first so we can lock the extent safely. 553 * Lock all pages first so we can lock the extent safely.
552 * 554 *
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 558cac2dfa54..72f31ecb5c90 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -495,7 +495,7 @@ again:
495 add_async_extent(async_cow, start, num_bytes, 495 add_async_extent(async_cow, start, num_bytes,
496 total_compressed, pages, nr_pages_ret); 496 total_compressed, pages, nr_pages_ret);
497 497
498 if (start + num_bytes < end && start + num_bytes < actual_end) { 498 if (start + num_bytes < end) {
499 start += num_bytes; 499 start += num_bytes;
500 pages = NULL; 500 pages = NULL;
501 cond_resched(); 501 cond_resched();
@@ -4501,6 +4501,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
4501 BTRFS_I(inode)->index_cnt = 2; 4501 BTRFS_I(inode)->index_cnt = 2;
4502 BTRFS_I(inode)->root = root; 4502 BTRFS_I(inode)->root = root;
4503 BTRFS_I(inode)->generation = trans->transid; 4503 BTRFS_I(inode)->generation = trans->transid;
4504 inode->i_generation = BTRFS_I(inode)->generation;
4504 btrfs_set_inode_space_info(root, inode); 4505 btrfs_set_inode_space_info(root, inode);
4505 4506
4506 if (mode & S_IFDIR) 4507 if (mode & S_IFDIR)
@@ -4622,12 +4623,12 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
4622} 4623}
4623 4624
4624static int btrfs_add_nondir(struct btrfs_trans_handle *trans, 4625static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
4625 struct dentry *dentry, struct inode *inode, 4626 struct inode *dir, struct dentry *dentry,
4626 int backref, u64 index) 4627 struct inode *inode, int backref, u64 index)
4627{ 4628{
4628 int err = btrfs_add_link(trans, dentry->d_parent->d_inode, 4629 int err = btrfs_add_link(trans, dir, inode,
4629 inode, dentry->d_name.name, 4630 dentry->d_name.name, dentry->d_name.len,
4630 dentry->d_name.len, backref, index); 4631 backref, index);
4631 if (!err) { 4632 if (!err) {
4632 d_instantiate(dentry, inode); 4633 d_instantiate(dentry, inode);
4633 return 0; 4634 return 0;
@@ -4668,8 +4669,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
4668 btrfs_set_trans_block_group(trans, dir); 4669 btrfs_set_trans_block_group(trans, dir);
4669 4670
4670 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4671 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
4671 dentry->d_name.len, 4672 dentry->d_name.len, dir->i_ino, objectid,
4672 dentry->d_parent->d_inode->i_ino, objectid,
4673 BTRFS_I(dir)->block_group, mode, &index); 4673 BTRFS_I(dir)->block_group, mode, &index);
4674 err = PTR_ERR(inode); 4674 err = PTR_ERR(inode);
4675 if (IS_ERR(inode)) 4675 if (IS_ERR(inode))
@@ -4682,7 +4682,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
4682 } 4682 }
4683 4683
4684 btrfs_set_trans_block_group(trans, inode); 4684 btrfs_set_trans_block_group(trans, inode);
4685 err = btrfs_add_nondir(trans, dentry, inode, 0, index); 4685 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);
4686 if (err) 4686 if (err)
4687 drop_inode = 1; 4687 drop_inode = 1;
4688 else { 4688 else {
@@ -4730,10 +4730,8 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
4730 btrfs_set_trans_block_group(trans, dir); 4730 btrfs_set_trans_block_group(trans, dir);
4731 4731
4732 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4732 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
4733 dentry->d_name.len, 4733 dentry->d_name.len, dir->i_ino, objectid,
4734 dentry->d_parent->d_inode->i_ino, 4734 BTRFS_I(dir)->block_group, mode, &index);
4735 objectid, BTRFS_I(dir)->block_group, mode,
4736 &index);
4737 err = PTR_ERR(inode); 4735 err = PTR_ERR(inode);
4738 if (IS_ERR(inode)) 4736 if (IS_ERR(inode))
4739 goto out_unlock; 4737 goto out_unlock;
@@ -4745,7 +4743,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
4745 } 4743 }
4746 4744
4747 btrfs_set_trans_block_group(trans, inode); 4745 btrfs_set_trans_block_group(trans, inode);
4748 err = btrfs_add_nondir(trans, dentry, inode, 0, index); 4746 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);
4749 if (err) 4747 if (err)
4750 drop_inode = 1; 4748 drop_inode = 1;
4751 else { 4749 else {
@@ -4787,6 +4785,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
4787 return -EPERM; 4785 return -EPERM;
4788 4786
4789 btrfs_inc_nlink(inode); 4787 btrfs_inc_nlink(inode);
4788 inode->i_ctime = CURRENT_TIME;
4790 4789
4791 err = btrfs_set_inode_index(dir, &index); 4790 err = btrfs_set_inode_index(dir, &index);
4792 if (err) 4791 if (err)
@@ -4805,15 +4804,17 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
4805 btrfs_set_trans_block_group(trans, dir); 4804 btrfs_set_trans_block_group(trans, dir);
4806 ihold(inode); 4805 ihold(inode);
4807 4806
4808 err = btrfs_add_nondir(trans, dentry, inode, 1, index); 4807 err = btrfs_add_nondir(trans, dir, dentry, inode, 1, index);
4809 4808
4810 if (err) { 4809 if (err) {
4811 drop_inode = 1; 4810 drop_inode = 1;
4812 } else { 4811 } else {
4812 struct dentry *parent = dget_parent(dentry);
4813 btrfs_update_inode_block_group(trans, dir); 4813 btrfs_update_inode_block_group(trans, dir);
4814 err = btrfs_update_inode(trans, root, inode); 4814 err = btrfs_update_inode(trans, root, inode);
4815 BUG_ON(err); 4815 BUG_ON(err);
4816 btrfs_log_new_name(trans, inode, NULL, dentry->d_parent); 4816 btrfs_log_new_name(trans, inode, NULL, parent);
4817 dput(parent);
4817 } 4818 }
4818 4819
4819 nr = trans->blocks_used; 4820 nr = trans->blocks_used;
@@ -4853,8 +4854,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
4853 btrfs_set_trans_block_group(trans, dir); 4854 btrfs_set_trans_block_group(trans, dir);
4854 4855
4855 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4856 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
4856 dentry->d_name.len, 4857 dentry->d_name.len, dir->i_ino, objectid,
4857 dentry->d_parent->d_inode->i_ino, objectid,
4858 BTRFS_I(dir)->block_group, S_IFDIR | mode, 4858 BTRFS_I(dir)->block_group, S_IFDIR | mode,
4859 &index); 4859 &index);
4860 if (IS_ERR(inode)) { 4860 if (IS_ERR(inode)) {
@@ -4877,9 +4877,8 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
4877 if (err) 4877 if (err)
4878 goto out_fail; 4878 goto out_fail;
4879 4879
4880 err = btrfs_add_link(trans, dentry->d_parent->d_inode, 4880 err = btrfs_add_link(trans, dir, inode, dentry->d_name.name,
4881 inode, dentry->d_name.name, 4881 dentry->d_name.len, 0, index);
4882 dentry->d_name.len, 0, index);
4883 if (err) 4882 if (err)
4884 goto out_fail; 4883 goto out_fail;
4885 4884
@@ -5535,13 +5534,21 @@ struct btrfs_dio_private {
5535 u64 bytes; 5534 u64 bytes;
5536 u32 *csums; 5535 u32 *csums;
5537 void *private; 5536 void *private;
5537
5538 /* number of bios pending for this dio */
5539 atomic_t pending_bios;
5540
5541 /* IO errors */
5542 int errors;
5543
5544 struct bio *orig_bio;
5538}; 5545};
5539 5546
5540static void btrfs_endio_direct_read(struct bio *bio, int err) 5547static void btrfs_endio_direct_read(struct bio *bio, int err)
5541{ 5548{
5549 struct btrfs_dio_private *dip = bio->bi_private;
5542 struct bio_vec *bvec_end = bio->bi_io_vec + bio->bi_vcnt - 1; 5550 struct bio_vec *bvec_end = bio->bi_io_vec + bio->bi_vcnt - 1;
5543 struct bio_vec *bvec = bio->bi_io_vec; 5551 struct bio_vec *bvec = bio->bi_io_vec;
5544 struct btrfs_dio_private *dip = bio->bi_private;
5545 struct inode *inode = dip->inode; 5552 struct inode *inode = dip->inode;
5546 struct btrfs_root *root = BTRFS_I(inode)->root; 5553 struct btrfs_root *root = BTRFS_I(inode)->root;
5547 u64 start; 5554 u64 start;
@@ -5595,15 +5602,18 @@ static void btrfs_endio_direct_write(struct bio *bio, int err)
5595 struct btrfs_trans_handle *trans; 5602 struct btrfs_trans_handle *trans;
5596 struct btrfs_ordered_extent *ordered = NULL; 5603 struct btrfs_ordered_extent *ordered = NULL;
5597 struct extent_state *cached_state = NULL; 5604 struct extent_state *cached_state = NULL;
5605 u64 ordered_offset = dip->logical_offset;
5606 u64 ordered_bytes = dip->bytes;
5598 int ret; 5607 int ret;
5599 5608
5600 if (err) 5609 if (err)
5601 goto out_done; 5610 goto out_done;
5602 5611again:
5603 ret = btrfs_dec_test_ordered_pending(inode, &ordered, 5612 ret = btrfs_dec_test_first_ordered_pending(inode, &ordered,
5604 dip->logical_offset, dip->bytes); 5613 &ordered_offset,
5614 ordered_bytes);
5605 if (!ret) 5615 if (!ret)
5606 goto out_done; 5616 goto out_test;
5607 5617
5608 BUG_ON(!ordered); 5618 BUG_ON(!ordered);
5609 5619
@@ -5663,8 +5673,20 @@ out_unlock:
5663out: 5673out:
5664 btrfs_delalloc_release_metadata(inode, ordered->len); 5674 btrfs_delalloc_release_metadata(inode, ordered->len);
5665 btrfs_end_transaction(trans, root); 5675 btrfs_end_transaction(trans, root);
5676 ordered_offset = ordered->file_offset + ordered->len;
5666 btrfs_put_ordered_extent(ordered); 5677 btrfs_put_ordered_extent(ordered);
5667 btrfs_put_ordered_extent(ordered); 5678 btrfs_put_ordered_extent(ordered);
5679
5680out_test:
5681 /*
5682 * our bio might span multiple ordered extents. If we haven't
5683 * completed the accounting for the whole dio, go back and try again
5684 */
5685 if (ordered_offset < dip->logical_offset + dip->bytes) {
5686 ordered_bytes = dip->logical_offset + dip->bytes -
5687 ordered_offset;
5688 goto again;
5689 }
5668out_done: 5690out_done:
5669 bio->bi_private = dip->private; 5691 bio->bi_private = dip->private;
5670 5692
@@ -5684,6 +5706,176 @@ static int __btrfs_submit_bio_start_direct_io(struct inode *inode, int rw,
5684 return 0; 5706 return 0;
5685} 5707}
5686 5708
5709static void btrfs_end_dio_bio(struct bio *bio, int err)
5710{
5711 struct btrfs_dio_private *dip = bio->bi_private;
5712
5713 if (err) {
5714 printk(KERN_ERR "btrfs direct IO failed ino %lu rw %lu "
5715 "sector %#Lx len %u err no %d\n",
5716 dip->inode->i_ino, bio->bi_rw,
5717 (unsigned long long)bio->bi_sector, bio->bi_size, err);
5718 dip->errors = 1;
5719
5720 /*
5721 * before atomic variable goto zero, we must make sure
5722 * dip->errors is perceived to be set.
5723 */
5724 smp_mb__before_atomic_dec();
5725 }
5726
5727 /* if there are more bios still pending for this dio, just exit */
5728 if (!atomic_dec_and_test(&dip->pending_bios))
5729 goto out;
5730
5731 if (dip->errors)
5732 bio_io_error(dip->orig_bio);
5733 else {
5734 set_bit(BIO_UPTODATE, &dip->orig_bio->bi_flags);
5735 bio_endio(dip->orig_bio, 0);
5736 }
5737out:
5738 bio_put(bio);
5739}
5740
5741static struct bio *btrfs_dio_bio_alloc(struct block_device *bdev,
5742 u64 first_sector, gfp_t gfp_flags)
5743{
5744 int nr_vecs = bio_get_nr_vecs(bdev);
5745 return btrfs_bio_alloc(bdev, first_sector, nr_vecs, gfp_flags);
5746}
5747
5748static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
5749 int rw, u64 file_offset, int skip_sum,
5750 u32 *csums)
5751{
5752 int write = rw & REQ_WRITE;
5753 struct btrfs_root *root = BTRFS_I(inode)->root;
5754 int ret;
5755
5756 bio_get(bio);
5757 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
5758 if (ret)
5759 goto err;
5760
5761 if (write && !skip_sum) {
5762 ret = btrfs_wq_submit_bio(root->fs_info,
5763 inode, rw, bio, 0, 0,
5764 file_offset,
5765 __btrfs_submit_bio_start_direct_io,
5766 __btrfs_submit_bio_done);
5767 goto err;
5768 } else if (!skip_sum)
5769 btrfs_lookup_bio_sums_dio(root, inode, bio,
5770 file_offset, csums);
5771
5772 ret = btrfs_map_bio(root, rw, bio, 0, 1);
5773err:
5774 bio_put(bio);
5775 return ret;
5776}
5777
5778static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
5779 int skip_sum)
5780{
5781 struct inode *inode = dip->inode;
5782 struct btrfs_root *root = BTRFS_I(inode)->root;
5783 struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree;
5784 struct bio *bio;
5785 struct bio *orig_bio = dip->orig_bio;
5786 struct bio_vec *bvec = orig_bio->bi_io_vec;
5787 u64 start_sector = orig_bio->bi_sector;
5788 u64 file_offset = dip->logical_offset;
5789 u64 submit_len = 0;
5790 u64 map_length;
5791 int nr_pages = 0;
5792 u32 *csums = dip->csums;
5793 int ret = 0;
5794
5795 bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS);
5796 if (!bio)
5797 return -ENOMEM;
5798 bio->bi_private = dip;
5799 bio->bi_end_io = btrfs_end_dio_bio;
5800 atomic_inc(&dip->pending_bios);
5801
5802 map_length = orig_bio->bi_size;
5803 ret = btrfs_map_block(map_tree, READ, start_sector << 9,
5804 &map_length, NULL, 0);
5805 if (ret) {
5806 bio_put(bio);
5807 return -EIO;
5808 }
5809
5810 while (bvec <= (orig_bio->bi_io_vec + orig_bio->bi_vcnt - 1)) {
5811 if (unlikely(map_length < submit_len + bvec->bv_len ||
5812 bio_add_page(bio, bvec->bv_page, bvec->bv_len,
5813 bvec->bv_offset) < bvec->bv_len)) {
5814 /*
5815 * inc the count before we submit the bio so
5816 * we know the end IO handler won't happen before
5817 * we inc the count. Otherwise, the dip might get freed
5818 * before we're done setting it up
5819 */
5820 atomic_inc(&dip->pending_bios);
5821 ret = __btrfs_submit_dio_bio(bio, inode, rw,
5822 file_offset, skip_sum,
5823 csums);
5824 if (ret) {
5825 bio_put(bio);
5826 atomic_dec(&dip->pending_bios);
5827 goto out_err;
5828 }
5829
5830 if (!skip_sum)
5831 csums = csums + nr_pages;
5832 start_sector += submit_len >> 9;
5833 file_offset += submit_len;
5834
5835 submit_len = 0;
5836 nr_pages = 0;
5837
5838 bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev,
5839 start_sector, GFP_NOFS);
5840 if (!bio)
5841 goto out_err;
5842 bio->bi_private = dip;
5843 bio->bi_end_io = btrfs_end_dio_bio;
5844
5845 map_length = orig_bio->bi_size;
5846 ret = btrfs_map_block(map_tree, READ, start_sector << 9,
5847 &map_length, NULL, 0);
5848 if (ret) {
5849 bio_put(bio);
5850 goto out_err;
5851 }
5852 } else {
5853 submit_len += bvec->bv_len;
5854 nr_pages ++;
5855 bvec++;
5856 }
5857 }
5858
5859 ret = __btrfs_submit_dio_bio(bio, inode, rw, file_offset, skip_sum,
5860 csums);
5861 if (!ret)
5862 return 0;
5863
5864 bio_put(bio);
5865out_err:
5866 dip->errors = 1;
5867 /*
5868 * before atomic variable goto zero, we must
5869 * make sure dip->errors is perceived to be set.
5870 */
5871 smp_mb__before_atomic_dec();
5872 if (atomic_dec_and_test(&dip->pending_bios))
5873 bio_io_error(dip->orig_bio);
5874
5875 /* bio_end_io() will handle error, so we needn't return it */
5876 return 0;
5877}
5878
5687static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode, 5879static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode,
5688 loff_t file_offset) 5880 loff_t file_offset)
5689{ 5881{
@@ -5723,36 +5915,18 @@ static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode,
5723 5915
5724 dip->disk_bytenr = (u64)bio->bi_sector << 9; 5916 dip->disk_bytenr = (u64)bio->bi_sector << 9;
5725 bio->bi_private = dip; 5917 bio->bi_private = dip;
5918 dip->errors = 0;
5919 dip->orig_bio = bio;
5920 atomic_set(&dip->pending_bios, 0);
5726 5921
5727 if (write) 5922 if (write)
5728 bio->bi_end_io = btrfs_endio_direct_write; 5923 bio->bi_end_io = btrfs_endio_direct_write;
5729 else 5924 else
5730 bio->bi_end_io = btrfs_endio_direct_read; 5925 bio->bi_end_io = btrfs_endio_direct_read;
5731 5926
5732 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); 5927 ret = btrfs_submit_direct_hook(rw, dip, skip_sum);
5733 if (ret) 5928 if (!ret)
5734 goto out_err;
5735
5736 if (write && !skip_sum) {
5737 ret = btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
5738 inode, rw, bio, 0, 0,
5739 dip->logical_offset,
5740 __btrfs_submit_bio_start_direct_io,
5741 __btrfs_submit_bio_done);
5742 if (ret)
5743 goto out_err;
5744 return; 5929 return;
5745 } else if (!skip_sum)
5746 btrfs_lookup_bio_sums_dio(root, inode, bio,
5747 dip->logical_offset, dip->csums);
5748
5749 ret = btrfs_map_bio(root, rw, bio, 0, 1);
5750 if (ret)
5751 goto out_err;
5752 return;
5753out_err:
5754 kfree(dip->csums);
5755 kfree(dip);
5756free_ordered: 5930free_ordered:
5757 /* 5931 /*
5758 * If this is a write, we need to clean up the reserved space and kill 5932 * If this is a write, we need to clean up the reserved space and kill
@@ -5760,8 +5934,7 @@ free_ordered:
5760 */ 5934 */
5761 if (write) { 5935 if (write) {
5762 struct btrfs_ordered_extent *ordered; 5936 struct btrfs_ordered_extent *ordered;
5763 ordered = btrfs_lookup_ordered_extent(inode, 5937 ordered = btrfs_lookup_ordered_extent(inode, file_offset);
5764 dip->logical_offset);
5765 if (!test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags) && 5938 if (!test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags) &&
5766 !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags)) 5939 !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags))
5767 btrfs_free_reserved_extent(root, ordered->start, 5940 btrfs_free_reserved_extent(root, ordered->start,
@@ -6607,8 +6780,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
6607 BUG_ON(ret); 6780 BUG_ON(ret);
6608 6781
6609 if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) { 6782 if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) {
6610 btrfs_log_new_name(trans, old_inode, old_dir, 6783 struct dentry *parent = dget_parent(new_dentry);
6611 new_dentry->d_parent); 6784 btrfs_log_new_name(trans, old_inode, old_dir, parent);
6785 dput(parent);
6612 btrfs_end_log_trans(root); 6786 btrfs_end_log_trans(root);
6613 } 6787 }
6614out_fail: 6788out_fail:
@@ -6758,8 +6932,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
6758 btrfs_set_trans_block_group(trans, dir); 6932 btrfs_set_trans_block_group(trans, dir);
6759 6933
6760 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 6934 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
6761 dentry->d_name.len, 6935 dentry->d_name.len, dir->i_ino, objectid,
6762 dentry->d_parent->d_inode->i_ino, objectid,
6763 BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, 6936 BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO,
6764 &index); 6937 &index);
6765 err = PTR_ERR(inode); 6938 err = PTR_ERR(inode);
@@ -6773,7 +6946,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
6773 } 6946 }
6774 6947
6775 btrfs_set_trans_block_group(trans, inode); 6948 btrfs_set_trans_block_group(trans, inode);
6776 err = btrfs_add_nondir(trans, dentry, inode, 0, index); 6949 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);
6777 if (err) 6950 if (err)
6778 drop_inode = 1; 6951 drop_inode = 1;
6779 else { 6952 else {
@@ -6844,6 +7017,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
6844 struct btrfs_root *root = BTRFS_I(inode)->root; 7017 struct btrfs_root *root = BTRFS_I(inode)->root;
6845 struct btrfs_key ins; 7018 struct btrfs_key ins;
6846 u64 cur_offset = start; 7019 u64 cur_offset = start;
7020 u64 i_size;
6847 int ret = 0; 7021 int ret = 0;
6848 bool own_trans = true; 7022 bool own_trans = true;
6849 7023
@@ -6885,11 +7059,11 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
6885 (actual_len > inode->i_size) && 7059 (actual_len > inode->i_size) &&
6886 (cur_offset > inode->i_size)) { 7060 (cur_offset > inode->i_size)) {
6887 if (cur_offset > actual_len) 7061 if (cur_offset > actual_len)
6888 i_size_write(inode, actual_len); 7062 i_size = actual_len;
6889 else 7063 else
6890 i_size_write(inode, cur_offset); 7064 i_size = cur_offset;
6891 i_size_write(inode, cur_offset); 7065 i_size_write(inode, i_size);
6892 btrfs_ordered_update_i_size(inode, cur_offset, NULL); 7066 btrfs_ordered_update_i_size(inode, i_size, NULL);
6893 } 7067 }
6894 7068
6895 ret = btrfs_update_inode(trans, root, inode); 7069 ret = btrfs_update_inode(trans, root, inode);
@@ -6943,6 +7117,10 @@ static long btrfs_fallocate(struct inode *inode, int mode,
6943 btrfs_wait_ordered_range(inode, alloc_start, alloc_end - alloc_start); 7117 btrfs_wait_ordered_range(inode, alloc_start, alloc_end - alloc_start);
6944 7118
6945 mutex_lock(&inode->i_mutex); 7119 mutex_lock(&inode->i_mutex);
7120 ret = inode_newsize_ok(inode, alloc_end);
7121 if (ret)
7122 goto out;
7123
6946 if (alloc_start > inode->i_size) { 7124 if (alloc_start > inode->i_size) {
6947 ret = btrfs_cont_expand(inode, alloc_start); 7125 ret = btrfs_cont_expand(inode, alloc_start);
6948 if (ret) 7126 if (ret)
@@ -7139,6 +7317,7 @@ static const struct inode_operations btrfs_symlink_inode_operations = {
7139 .readlink = generic_readlink, 7317 .readlink = generic_readlink,
7140 .follow_link = page_follow_link_light, 7318 .follow_link = page_follow_link_light,
7141 .put_link = page_put_link, 7319 .put_link = page_put_link,
7320 .getattr = btrfs_getattr,
7142 .permission = btrfs_permission, 7321 .permission = btrfs_permission,
7143 .setxattr = btrfs_setxattr, 7322 .setxattr = btrfs_setxattr,
7144 .getxattr = btrfs_getxattr, 7323 .getxattr = btrfs_getxattr,
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 463d91b4dd3a..f87552a1d7ea 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -233,7 +233,8 @@ static noinline int create_subvol(struct btrfs_root *root,
233 struct btrfs_inode_item *inode_item; 233 struct btrfs_inode_item *inode_item;
234 struct extent_buffer *leaf; 234 struct extent_buffer *leaf;
235 struct btrfs_root *new_root; 235 struct btrfs_root *new_root;
236 struct inode *dir = dentry->d_parent->d_inode; 236 struct dentry *parent = dget_parent(dentry);
237 struct inode *dir;
237 int ret; 238 int ret;
238 int err; 239 int err;
239 u64 objectid; 240 u64 objectid;
@@ -242,8 +243,13 @@ static noinline int create_subvol(struct btrfs_root *root,
242 243
243 ret = btrfs_find_free_objectid(NULL, root->fs_info->tree_root, 244 ret = btrfs_find_free_objectid(NULL, root->fs_info->tree_root,
244 0, &objectid); 245 0, &objectid);
245 if (ret) 246 if (ret) {
247 dput(parent);
246 return ret; 248 return ret;
249 }
250
251 dir = parent->d_inode;
252
247 /* 253 /*
248 * 1 - inode item 254 * 1 - inode item
249 * 2 - refs 255 * 2 - refs
@@ -251,8 +257,10 @@ static noinline int create_subvol(struct btrfs_root *root,
251 * 2 - dir items 257 * 2 - dir items
252 */ 258 */
253 trans = btrfs_start_transaction(root, 6); 259 trans = btrfs_start_transaction(root, 6);
254 if (IS_ERR(trans)) 260 if (IS_ERR(trans)) {
261 dput(parent);
255 return PTR_ERR(trans); 262 return PTR_ERR(trans);
263 }
256 264
257 leaf = btrfs_alloc_free_block(trans, root, root->leafsize, 265 leaf = btrfs_alloc_free_block(trans, root, root->leafsize,
258 0, objectid, NULL, 0, 0, 0); 266 0, objectid, NULL, 0, 0, 0);
@@ -339,6 +347,7 @@ static noinline int create_subvol(struct btrfs_root *root,
339 347
340 d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry)); 348 d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry));
341fail: 349fail:
350 dput(parent);
342 if (async_transid) { 351 if (async_transid) {
343 *async_transid = trans->transid; 352 *async_transid = trans->transid;
344 err = btrfs_commit_transaction_async(trans, root, 1); 353 err = btrfs_commit_transaction_async(trans, root, 1);
@@ -354,6 +363,7 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
354 char *name, int namelen, u64 *async_transid) 363 char *name, int namelen, u64 *async_transid)
355{ 364{
356 struct inode *inode; 365 struct inode *inode;
366 struct dentry *parent;
357 struct btrfs_pending_snapshot *pending_snapshot; 367 struct btrfs_pending_snapshot *pending_snapshot;
358 struct btrfs_trans_handle *trans; 368 struct btrfs_trans_handle *trans;
359 int ret; 369 int ret;
@@ -396,7 +406,9 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
396 406
397 btrfs_orphan_cleanup(pending_snapshot->snap); 407 btrfs_orphan_cleanup(pending_snapshot->snap);
398 408
399 inode = btrfs_lookup_dentry(dentry->d_parent->d_inode, dentry); 409 parent = dget_parent(dentry);
410 inode = btrfs_lookup_dentry(parent->d_inode, dentry);
411 dput(parent);
400 if (IS_ERR(inode)) { 412 if (IS_ERR(inode)) {
401 ret = PTR_ERR(inode); 413 ret = PTR_ERR(inode);
402 goto fail; 414 goto fail;
@@ -935,23 +947,42 @@ out:
935 947
936static noinline int btrfs_ioctl_snap_create(struct file *file, 948static noinline int btrfs_ioctl_snap_create(struct file *file,
937 void __user *arg, int subvol, 949 void __user *arg, int subvol,
938 int async) 950 int v2)
939{ 951{
940 struct btrfs_ioctl_vol_args *vol_args = NULL; 952 struct btrfs_ioctl_vol_args *vol_args = NULL;
941 struct btrfs_ioctl_async_vol_args *async_vol_args = NULL; 953 struct btrfs_ioctl_vol_args_v2 *vol_args_v2 = NULL;
942 char *name; 954 char *name;
943 u64 fd; 955 u64 fd;
944 u64 transid = 0;
945 int ret; 956 int ret;
946 957
947 if (async) { 958 if (v2) {
948 async_vol_args = memdup_user(arg, sizeof(*async_vol_args)); 959 u64 transid = 0;
949 if (IS_ERR(async_vol_args)) 960 u64 *ptr = NULL;
950 return PTR_ERR(async_vol_args); 961
962 vol_args_v2 = memdup_user(arg, sizeof(*vol_args_v2));
963 if (IS_ERR(vol_args_v2))
964 return PTR_ERR(vol_args_v2);
965
966 if (vol_args_v2->flags & ~BTRFS_SUBVOL_CREATE_ASYNC) {
967 ret = -EINVAL;
968 goto out;
969 }
970
971 name = vol_args_v2->name;
972 fd = vol_args_v2->fd;
973 vol_args_v2->name[BTRFS_SUBVOL_NAME_MAX] = '\0';
974
975 if (vol_args_v2->flags & BTRFS_SUBVOL_CREATE_ASYNC)
976 ptr = &transid;
977
978 ret = btrfs_ioctl_snap_create_transid(file, name, fd,
979 subvol, ptr);
951 980
952 name = async_vol_args->name; 981 if (ret == 0 && ptr &&
953 fd = async_vol_args->fd; 982 copy_to_user(arg +
954 async_vol_args->name[BTRFS_SNAPSHOT_NAME_MAX] = '\0'; 983 offsetof(struct btrfs_ioctl_vol_args_v2,
984 transid), ptr, sizeof(*ptr)))
985 ret = -EFAULT;
955 } else { 986 } else {
956 vol_args = memdup_user(arg, sizeof(*vol_args)); 987 vol_args = memdup_user(arg, sizeof(*vol_args));
957 if (IS_ERR(vol_args)) 988 if (IS_ERR(vol_args))
@@ -959,20 +990,13 @@ static noinline int btrfs_ioctl_snap_create(struct file *file,
959 name = vol_args->name; 990 name = vol_args->name;
960 fd = vol_args->fd; 991 fd = vol_args->fd;
961 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0'; 992 vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
962 }
963
964 ret = btrfs_ioctl_snap_create_transid(file, name, fd,
965 subvol, &transid);
966 993
967 if (!ret && async) { 994 ret = btrfs_ioctl_snap_create_transid(file, name, fd,
968 if (copy_to_user(arg + 995 subvol, NULL);
969 offsetof(struct btrfs_ioctl_async_vol_args,
970 transid), &transid, sizeof(transid)))
971 return -EFAULT;
972 } 996 }
973 997out:
974 kfree(vol_args); 998 kfree(vol_args);
975 kfree(async_vol_args); 999 kfree(vol_args_v2);
976 1000
977 return ret; 1001 return ret;
978} 1002}
@@ -1669,12 +1693,11 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1669 olen = len = src->i_size - off; 1693 olen = len = src->i_size - off;
1670 /* if we extend to eof, continue to block boundary */ 1694 /* if we extend to eof, continue to block boundary */
1671 if (off + len == src->i_size) 1695 if (off + len == src->i_size)
1672 len = ((src->i_size + bs-1) & ~(bs-1)) 1696 len = ALIGN(src->i_size, bs) - off;
1673 - off;
1674 1697
1675 /* verify the end result is block aligned */ 1698 /* verify the end result is block aligned */
1676 if ((off & (bs-1)) || 1699 if (!IS_ALIGNED(off, bs) || !IS_ALIGNED(off + len, bs) ||
1677 ((off + len) & (bs-1))) 1700 !IS_ALIGNED(destoff, bs))
1678 goto out_unlock; 1701 goto out_unlock;
1679 1702
1680 /* do any pending delalloc/csum calc on src, one way or 1703 /* do any pending delalloc/csum calc on src, one way or
@@ -1874,8 +1897,8 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1874 * but shouldn't round up the file size 1897 * but shouldn't round up the file size
1875 */ 1898 */
1876 endoff = new_key.offset + datal; 1899 endoff = new_key.offset + datal;
1877 if (endoff > off+olen) 1900 if (endoff > destoff+olen)
1878 endoff = off+olen; 1901 endoff = destoff+olen;
1879 if (endoff > inode->i_size) 1902 if (endoff > inode->i_size)
1880 btrfs_i_size_write(inode, endoff); 1903 btrfs_i_size_write(inode, endoff);
1881 1904
@@ -2235,7 +2258,7 @@ long btrfs_ioctl(struct file *file, unsigned int
2235 return btrfs_ioctl_getversion(file, argp); 2258 return btrfs_ioctl_getversion(file, argp);
2236 case BTRFS_IOC_SNAP_CREATE: 2259 case BTRFS_IOC_SNAP_CREATE:
2237 return btrfs_ioctl_snap_create(file, argp, 0, 0); 2260 return btrfs_ioctl_snap_create(file, argp, 0, 0);
2238 case BTRFS_IOC_SNAP_CREATE_ASYNC: 2261 case BTRFS_IOC_SNAP_CREATE_V2:
2239 return btrfs_ioctl_snap_create(file, argp, 0, 1); 2262 return btrfs_ioctl_snap_create(file, argp, 0, 1);
2240 case BTRFS_IOC_SUBVOL_CREATE: 2263 case BTRFS_IOC_SUBVOL_CREATE:
2241 return btrfs_ioctl_snap_create(file, argp, 1, 0); 2264 return btrfs_ioctl_snap_create(file, argp, 1, 0);
diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
index 17c99ebdf960..c344d12c646b 100644
--- a/fs/btrfs/ioctl.h
+++ b/fs/btrfs/ioctl.h
@@ -30,11 +30,15 @@ struct btrfs_ioctl_vol_args {
30 char name[BTRFS_PATH_NAME_MAX + 1]; 30 char name[BTRFS_PATH_NAME_MAX + 1];
31}; 31};
32 32
33#define BTRFS_SNAPSHOT_NAME_MAX 4079 33#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
34struct btrfs_ioctl_async_vol_args { 34
35#define BTRFS_SUBVOL_NAME_MAX 4039
36struct btrfs_ioctl_vol_args_v2 {
35 __s64 fd; 37 __s64 fd;
36 __u64 transid; 38 __u64 transid;
37 char name[BTRFS_SNAPSHOT_NAME_MAX + 1]; 39 __u64 flags;
40 __u64 unused[4];
41 char name[BTRFS_SUBVOL_NAME_MAX + 1];
38}; 42};
39 43
40#define BTRFS_INO_LOOKUP_PATH_MAX 4080 44#define BTRFS_INO_LOOKUP_PATH_MAX 4080
@@ -187,6 +191,6 @@ struct btrfs_ioctl_space_args {
187 struct btrfs_ioctl_space_args) 191 struct btrfs_ioctl_space_args)
188#define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64) 192#define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
189#define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64) 193#define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
190#define BTRFS_IOC_SNAP_CREATE_ASYNC _IOW(BTRFS_IOCTL_MAGIC, 23, \ 194#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
191 struct btrfs_ioctl_async_vol_args) 195 struct btrfs_ioctl_vol_args_v2)
192#endif 196#endif
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index f4621f6deca1..ae7737e352c9 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -250,6 +250,73 @@ int btrfs_add_ordered_sum(struct inode *inode,
250 250
251/* 251/*
252 * this is used to account for finished IO across a given range 252 * this is used to account for finished IO across a given range
253 * of the file. The IO may span ordered extents. If
254 * a given ordered_extent is completely done, 1 is returned, otherwise
255 * 0.
256 *
257 * test_and_set_bit on a flag in the struct btrfs_ordered_extent is used
258 * to make sure this function only returns 1 once for a given ordered extent.
259 *
260 * file_offset is updated to one byte past the range that is recorded as
261 * complete. This allows you to walk forward in the file.
262 */
263int btrfs_dec_test_first_ordered_pending(struct inode *inode,
264 struct btrfs_ordered_extent **cached,
265 u64 *file_offset, u64 io_size)
266{
267 struct btrfs_ordered_inode_tree *tree;
268 struct rb_node *node;
269 struct btrfs_ordered_extent *entry = NULL;
270 int ret;
271 u64 dec_end;
272 u64 dec_start;
273 u64 to_dec;
274
275 tree = &BTRFS_I(inode)->ordered_tree;
276 spin_lock(&tree->lock);
277 node = tree_search(tree, *file_offset);
278 if (!node) {
279 ret = 1;
280 goto out;
281 }
282
283 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
284 if (!offset_in_entry(entry, *file_offset)) {
285 ret = 1;
286 goto out;
287 }
288
289 dec_start = max(*file_offset, entry->file_offset);
290 dec_end = min(*file_offset + io_size, entry->file_offset +
291 entry->len);
292 *file_offset = dec_end;
293 if (dec_start > dec_end) {
294 printk(KERN_CRIT "bad ordering dec_start %llu end %llu\n",
295 (unsigned long long)dec_start,
296 (unsigned long long)dec_end);
297 }
298 to_dec = dec_end - dec_start;
299 if (to_dec > entry->bytes_left) {
300 printk(KERN_CRIT "bad ordered accounting left %llu size %llu\n",
301 (unsigned long long)entry->bytes_left,
302 (unsigned long long)to_dec);
303 }
304 entry->bytes_left -= to_dec;
305 if (entry->bytes_left == 0)
306 ret = test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags);
307 else
308 ret = 1;
309out:
310 if (!ret && cached && entry) {
311 *cached = entry;
312 atomic_inc(&entry->refs);
313 }
314 spin_unlock(&tree->lock);
315 return ret == 0;
316}
317
318/*
319 * this is used to account for finished IO across a given range
253 * of the file. The IO should not span ordered extents. If 320 * of the file. The IO should not span ordered extents. If
254 * a given ordered_extent is completely done, 1 is returned, otherwise 321 * a given ordered_extent is completely done, 1 is returned, otherwise
255 * 0. 322 * 0.
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index 8ac365492a3f..61dca83119dd 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -141,6 +141,9 @@ int btrfs_remove_ordered_extent(struct inode *inode,
141int btrfs_dec_test_ordered_pending(struct inode *inode, 141int btrfs_dec_test_ordered_pending(struct inode *inode,
142 struct btrfs_ordered_extent **cached, 142 struct btrfs_ordered_extent **cached,
143 u64 file_offset, u64 io_size); 143 u64 file_offset, u64 io_size);
144int btrfs_dec_test_first_ordered_pending(struct inode *inode,
145 struct btrfs_ordered_extent **cached,
146 u64 *file_offset, u64 io_size);
144int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset, 147int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
145 u64 start, u64 len, u64 disk_len, int type); 148 u64 start, u64 len, u64 disk_len, int type);
146int btrfs_add_ordered_extent_dio(struct inode *inode, u64 file_offset, 149int btrfs_add_ordered_extent_dio(struct inode *inode, u64 file_offset,
diff --git a/fs/btrfs/orphan.c b/fs/btrfs/orphan.c
index 79cba5fbc28e..f8be250963a0 100644
--- a/fs/btrfs/orphan.c
+++ b/fs/btrfs/orphan.c
@@ -56,8 +56,12 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
56 return -ENOMEM; 56 return -ENOMEM;
57 57
58 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); 58 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
59 if (ret) 59 if (ret < 0)
60 goto out; 60 goto out;
61 if (ret) {
62 ret = -ENOENT;
63 goto out;
64 }
61 65
62 ret = btrfs_del_item(trans, root, path); 66 ret = btrfs_del_item(trans, root, path);
63 67
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 8299a25ffc8f..883c6fa1367e 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -244,6 +244,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
244 case Opt_space_cache: 244 case Opt_space_cache:
245 printk(KERN_INFO "btrfs: enabling disk space caching\n"); 245 printk(KERN_INFO "btrfs: enabling disk space caching\n");
246 btrfs_set_opt(info->mount_opt, SPACE_CACHE); 246 btrfs_set_opt(info->mount_opt, SPACE_CACHE);
247 break;
247 case Opt_clear_cache: 248 case Opt_clear_cache:
248 printk(KERN_INFO "btrfs: force clearing of disk cache\n"); 249 printk(KERN_INFO "btrfs: force clearing of disk cache\n");
249 btrfs_set_opt(info->mount_opt, CLEAR_CACHE); 250 btrfs_set_opt(info->mount_opt, CLEAR_CACHE);
@@ -562,12 +563,26 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
562 563
563static int btrfs_test_super(struct super_block *s, void *data) 564static int btrfs_test_super(struct super_block *s, void *data)
564{ 565{
565 struct btrfs_fs_devices *test_fs_devices = data; 566 struct btrfs_root *test_root = data;
566 struct btrfs_root *root = btrfs_sb(s); 567 struct btrfs_root *root = btrfs_sb(s);
567 568
568 return root->fs_info->fs_devices == test_fs_devices; 569 /*
570 * If this super block is going away, return false as it
571 * can't match as an existing super block.
572 */
573 if (!atomic_read(&s->s_active))
574 return 0;
575 return root->fs_info->fs_devices == test_root->fs_info->fs_devices;
576}
577
578static int btrfs_set_super(struct super_block *s, void *data)
579{
580 s->s_fs_info = data;
581
582 return set_anon_super(s, data);
569} 583}
570 584
585
571/* 586/*
572 * Find a superblock for the given device / mount point. 587 * Find a superblock for the given device / mount point.
573 * 588 *
@@ -581,6 +596,8 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
581 struct super_block *s; 596 struct super_block *s;
582 struct dentry *root; 597 struct dentry *root;
583 struct btrfs_fs_devices *fs_devices = NULL; 598 struct btrfs_fs_devices *fs_devices = NULL;
599 struct btrfs_root *tree_root = NULL;
600 struct btrfs_fs_info *fs_info = NULL;
584 fmode_t mode = FMODE_READ; 601 fmode_t mode = FMODE_READ;
585 char *subvol_name = NULL; 602 char *subvol_name = NULL;
586 u64 subvol_objectid = 0; 603 u64 subvol_objectid = 0;
@@ -608,8 +625,24 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
608 goto error_close_devices; 625 goto error_close_devices;
609 } 626 }
610 627
628 /*
629 * Setup a dummy root and fs_info for test/set super. This is because
630 * we don't actually fill this stuff out until open_ctree, but we need
631 * it for searching for existing supers, so this lets us do that and
632 * then open_ctree will properly initialize everything later.
633 */
634 fs_info = kzalloc(sizeof(struct btrfs_fs_info), GFP_NOFS);
635 tree_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS);
636 if (!fs_info || !tree_root) {
637 error = -ENOMEM;
638 goto error_close_devices;
639 }
640 fs_info->tree_root = tree_root;
641 fs_info->fs_devices = fs_devices;
642 tree_root->fs_info = fs_info;
643
611 bdev = fs_devices->latest_bdev; 644 bdev = fs_devices->latest_bdev;
612 s = sget(fs_type, btrfs_test_super, set_anon_super, fs_devices); 645 s = sget(fs_type, btrfs_test_super, btrfs_set_super, tree_root);
613 if (IS_ERR(s)) 646 if (IS_ERR(s))
614 goto error_s; 647 goto error_s;
615 648
@@ -652,9 +685,9 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
652 mutex_unlock(&root->d_inode->i_mutex); 685 mutex_unlock(&root->d_inode->i_mutex);
653 686
654 if (IS_ERR(new_root)) { 687 if (IS_ERR(new_root)) {
688 dput(root);
655 deactivate_locked_super(s); 689 deactivate_locked_super(s);
656 error = PTR_ERR(new_root); 690 error = PTR_ERR(new_root);
657 dput(root);
658 goto error_free_subvol_name; 691 goto error_free_subvol_name;
659 } 692 }
660 if (!new_root->d_inode) { 693 if (!new_root->d_inode) {
@@ -675,6 +708,8 @@ error_s:
675 error = PTR_ERR(s); 708 error = PTR_ERR(s);
676error_close_devices: 709error_close_devices:
677 btrfs_close_devices(fs_devices); 710 btrfs_close_devices(fs_devices);
711 kfree(fs_info);
712 kfree(tree_root);
678error_free_subvol_name: 713error_free_subvol_name:
679 kfree(subvol_name); 714 kfree(subvol_name);
680 return ERR_PTR(error); 715 return ERR_PTR(error);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 1fffbc017bdf..f50e931fc217 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -902,6 +902,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
902 struct btrfs_root *root = pending->root; 902 struct btrfs_root *root = pending->root;
903 struct btrfs_root *parent_root; 903 struct btrfs_root *parent_root;
904 struct inode *parent_inode; 904 struct inode *parent_inode;
905 struct dentry *parent;
905 struct dentry *dentry; 906 struct dentry *dentry;
906 struct extent_buffer *tmp; 907 struct extent_buffer *tmp;
907 struct extent_buffer *old; 908 struct extent_buffer *old;
@@ -941,7 +942,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
941 trans->block_rsv = &pending->block_rsv; 942 trans->block_rsv = &pending->block_rsv;
942 943
943 dentry = pending->dentry; 944 dentry = pending->dentry;
944 parent_inode = dentry->d_parent->d_inode; 945 parent = dget_parent(dentry);
946 parent_inode = parent->d_inode;
945 parent_root = BTRFS_I(parent_inode)->root; 947 parent_root = BTRFS_I(parent_inode)->root;
946 record_root_in_trans(trans, parent_root); 948 record_root_in_trans(trans, parent_root);
947 949
@@ -989,6 +991,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
989 parent_inode->i_ino, index, 991 parent_inode->i_ino, index,
990 dentry->d_name.name, dentry->d_name.len); 992 dentry->d_name.name, dentry->d_name.len);
991 BUG_ON(ret); 993 BUG_ON(ret);
994 dput(parent);
992 995
993 key.offset = (u64)-1; 996 key.offset = (u64)-1;
994 pending->snap = btrfs_read_fs_root_no_name(root->fs_info, &key); 997 pending->snap = btrfs_read_fs_root_no_name(root->fs_info, &key);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index a29f19384a27..054744ac5719 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2869,6 +2869,7 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
2869{ 2869{
2870 int ret = 0; 2870 int ret = 0;
2871 struct btrfs_root *root; 2871 struct btrfs_root *root;
2872 struct dentry *old_parent = NULL;
2872 2873
2873 /* 2874 /*
2874 * for regular files, if its inode is already on disk, we don't 2875 * for regular files, if its inode is already on disk, we don't
@@ -2910,10 +2911,13 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
2910 if (IS_ROOT(parent)) 2911 if (IS_ROOT(parent))
2911 break; 2912 break;
2912 2913
2913 parent = parent->d_parent; 2914 parent = dget_parent(parent);
2915 dput(old_parent);
2916 old_parent = parent;
2914 inode = parent->d_inode; 2917 inode = parent->d_inode;
2915 2918
2916 } 2919 }
2920 dput(old_parent);
2917out: 2921out:
2918 return ret; 2922 return ret;
2919} 2923}
@@ -2945,6 +2949,7 @@ int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
2945{ 2949{
2946 int inode_only = exists_only ? LOG_INODE_EXISTS : LOG_INODE_ALL; 2950 int inode_only = exists_only ? LOG_INODE_EXISTS : LOG_INODE_ALL;
2947 struct super_block *sb; 2951 struct super_block *sb;
2952 struct dentry *old_parent = NULL;
2948 int ret = 0; 2953 int ret = 0;
2949 u64 last_committed = root->fs_info->last_trans_committed; 2954 u64 last_committed = root->fs_info->last_trans_committed;
2950 2955
@@ -3016,10 +3021,13 @@ int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
3016 if (IS_ROOT(parent)) 3021 if (IS_ROOT(parent))
3017 break; 3022 break;
3018 3023
3019 parent = parent->d_parent; 3024 parent = dget_parent(parent);
3025 dput(old_parent);
3026 old_parent = parent;
3020 } 3027 }
3021 ret = 0; 3028 ret = 0;
3022end_trans: 3029end_trans:
3030 dput(old_parent);
3023 if (ret < 0) { 3031 if (ret < 0) {
3024 BUG_ON(ret != -ENOSPC); 3032 BUG_ON(ret != -ENOSPC);
3025 root->fs_info->last_trans_log_full_commit = trans->transid; 3033 root->fs_info->last_trans_log_full_commit = trans->transid;
@@ -3039,8 +3047,13 @@ end_no_trans:
3039int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans, 3047int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans,
3040 struct btrfs_root *root, struct dentry *dentry) 3048 struct btrfs_root *root, struct dentry *dentry)
3041{ 3049{
3042 return btrfs_log_inode_parent(trans, root, dentry->d_inode, 3050 struct dentry *parent = dget_parent(dentry);
3043 dentry->d_parent, 0); 3051 int ret;
3052
3053 ret = btrfs_log_inode_parent(trans, root, dentry->d_inode, parent, 0);
3054 dput(parent);
3055
3056 return ret;
3044} 3057}
3045 3058
3046/* 3059/*
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index cc04dc1445d6..6b9884507837 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -412,12 +412,16 @@ static noinline int device_list_add(const char *path,
412 412
413 device->fs_devices = fs_devices; 413 device->fs_devices = fs_devices;
414 fs_devices->num_devices++; 414 fs_devices->num_devices++;
415 } else if (strcmp(device->name, path)) { 415 } else if (!device->name || strcmp(device->name, path)) {
416 name = kstrdup(path, GFP_NOFS); 416 name = kstrdup(path, GFP_NOFS);
417 if (!name) 417 if (!name)
418 return -ENOMEM; 418 return -ENOMEM;
419 kfree(device->name); 419 kfree(device->name);
420 device->name = name; 420 device->name = name;
421 if (device->missing) {
422 fs_devices->missing_devices--;
423 device->missing = 0;
424 }
421 } 425 }
422 426
423 if (found_transid > fs_devices->latest_trans) { 427 if (found_transid > fs_devices->latest_trans) {
@@ -1236,6 +1240,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1236 1240
1237 device->fs_devices->num_devices--; 1241 device->fs_devices->num_devices--;
1238 1242
1243 if (device->missing)
1244 root->fs_info->fs_devices->missing_devices--;
1245
1239 next_device = list_entry(root->fs_info->fs_devices->devices.next, 1246 next_device = list_entry(root->fs_info->fs_devices->devices.next,
1240 struct btrfs_device, dev_list); 1247 struct btrfs_device, dev_list);
1241 if (device->bdev == root->fs_info->sb->s_bdev) 1248 if (device->bdev == root->fs_info->sb->s_bdev)
@@ -3080,7 +3087,9 @@ static struct btrfs_device *add_missing_dev(struct btrfs_root *root,
3080 device->devid = devid; 3087 device->devid = devid;
3081 device->work.func = pending_bios_fn; 3088 device->work.func = pending_bios_fn;
3082 device->fs_devices = fs_devices; 3089 device->fs_devices = fs_devices;
3090 device->missing = 1;
3083 fs_devices->num_devices++; 3091 fs_devices->num_devices++;
3092 fs_devices->missing_devices++;
3084 spin_lock_init(&device->io_lock); 3093 spin_lock_init(&device->io_lock);
3085 INIT_LIST_HEAD(&device->dev_alloc_list); 3094 INIT_LIST_HEAD(&device->dev_alloc_list);
3086 memcpy(device->uuid, dev_uuid, BTRFS_UUID_SIZE); 3095 memcpy(device->uuid, dev_uuid, BTRFS_UUID_SIZE);
@@ -3278,6 +3287,15 @@ static int read_one_dev(struct btrfs_root *root,
3278 device = add_missing_dev(root, devid, dev_uuid); 3287 device = add_missing_dev(root, devid, dev_uuid);
3279 if (!device) 3288 if (!device)
3280 return -ENOMEM; 3289 return -ENOMEM;
3290 } else if (!device->missing) {
3291 /*
3292 * this happens when a device that was properly setup
3293 * in the device info lists suddenly goes bad.
3294 * device->bdev is NULL, and so we have to set
3295 * device->missing to one here
3296 */
3297 root->fs_info->fs_devices->missing_devices++;
3298 device->missing = 1;
3281 } 3299 }
3282 } 3300 }
3283 3301
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 2b638b6e4eea..2740db49eb04 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -44,6 +44,7 @@ struct btrfs_device {
44 44
45 int writeable; 45 int writeable;
46 int in_fs_metadata; 46 int in_fs_metadata;
47 int missing;
47 48
48 spinlock_t io_lock; 49 spinlock_t io_lock;
49 50
@@ -93,6 +94,7 @@ struct btrfs_fs_devices {
93 u64 num_devices; 94 u64 num_devices;
94 u64 open_devices; 95 u64 open_devices;
95 u64 rw_devices; 96 u64 rw_devices;
97 u64 missing_devices;
96 u64 total_rw_bytes; 98 u64 total_rw_bytes;
97 struct block_device *latest_bdev; 99 struct block_device *latest_bdev;
98 100
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index e9c874abc9e1..561438b6a50c 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -204,7 +204,7 @@ static int readpage_nounlock(struct file *filp, struct page *page)
204 err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout, 204 err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
205 page->index << PAGE_CACHE_SHIFT, &len, 205 page->index << PAGE_CACHE_SHIFT, &len,
206 ci->i_truncate_seq, ci->i_truncate_size, 206 ci->i_truncate_seq, ci->i_truncate_size,
207 &page, 1); 207 &page, 1, 0);
208 if (err == -ENOENT) 208 if (err == -ENOENT)
209 err = 0; 209 err = 0;
210 if (err < 0) { 210 if (err < 0) {
@@ -287,7 +287,7 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
287 rc = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout, 287 rc = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
288 offset, &len, 288 offset, &len,
289 ci->i_truncate_seq, ci->i_truncate_size, 289 ci->i_truncate_seq, ci->i_truncate_size,
290 pages, nr_pages); 290 pages, nr_pages, 0);
291 if (rc == -ENOENT) 291 if (rc == -ENOENT)
292 rc = 0; 292 rc = 0;
293 if (rc < 0) 293 if (rc < 0)
@@ -774,7 +774,7 @@ get_more_pages:
774 snapc, do_sync, 774 snapc, do_sync,
775 ci->i_truncate_seq, 775 ci->i_truncate_seq,
776 ci->i_truncate_size, 776 ci->i_truncate_size,
777 &inode->i_mtime, true, 1); 777 &inode->i_mtime, true, 1, 0);
778 max_pages = req->r_num_pages; 778 max_pages = req->r_num_pages;
779 779
780 alloc_page_vec(fsc, req); 780 alloc_page_vec(fsc, req);
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 98ab13e2b71d..60d27bc9eb83 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1430,8 +1430,8 @@ static int try_nonblocking_invalidate(struct inode *inode)
1430 invalidating_gen == ci->i_rdcache_gen) { 1430 invalidating_gen == ci->i_rdcache_gen) {
1431 /* success. */ 1431 /* success. */
1432 dout("try_nonblocking_invalidate %p success\n", inode); 1432 dout("try_nonblocking_invalidate %p success\n", inode);
1433 ci->i_rdcache_gen = 0; 1433 /* save any racing async invalidate some trouble */
1434 ci->i_rdcache_revoking = 0; 1434 ci->i_rdcache_revoking = ci->i_rdcache_gen - 1;
1435 return 0; 1435 return 0;
1436 } 1436 }
1437 dout("try_nonblocking_invalidate %p failed\n", inode); 1437 dout("try_nonblocking_invalidate %p failed\n", inode);
@@ -2273,8 +2273,7 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2273{ 2273{
2274 struct ceph_inode_info *ci = ceph_inode(inode); 2274 struct ceph_inode_info *ci = ceph_inode(inode);
2275 int mds = session->s_mds; 2275 int mds = session->s_mds;
2276 unsigned seq = le32_to_cpu(grant->seq); 2276 int seq = le32_to_cpu(grant->seq);
2277 unsigned issue_seq = le32_to_cpu(grant->issue_seq);
2278 int newcaps = le32_to_cpu(grant->caps); 2277 int newcaps = le32_to_cpu(grant->caps);
2279 int issued, implemented, used, wanted, dirty; 2278 int issued, implemented, used, wanted, dirty;
2280 u64 size = le64_to_cpu(grant->size); 2279 u64 size = le64_to_cpu(grant->size);
@@ -2286,8 +2285,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2286 int revoked_rdcache = 0; 2285 int revoked_rdcache = 0;
2287 int queue_invalidate = 0; 2286 int queue_invalidate = 0;
2288 2287
2289 dout("handle_cap_grant inode %p cap %p mds%d seq %u/%u %s\n", 2288 dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n",
2290 inode, cap, mds, seq, issue_seq, ceph_cap_string(newcaps)); 2289 inode, cap, mds, seq, ceph_cap_string(newcaps));
2291 dout(" size %llu max_size %llu, i_size %llu\n", size, max_size, 2290 dout(" size %llu max_size %llu, i_size %llu\n", size, max_size,
2292 inode->i_size); 2291 inode->i_size);
2293 2292
@@ -2383,7 +2382,6 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2383 } 2382 }
2384 2383
2385 cap->seq = seq; 2384 cap->seq = seq;
2386 cap->issue_seq = issue_seq;
2387 2385
2388 /* file layout may have changed */ 2386 /* file layout may have changed */
2389 ci->i_layout = grant->layout; 2387 ci->i_layout = grant->layout;
@@ -2691,6 +2689,11 @@ static void handle_cap_import(struct ceph_mds_client *mdsc,
2691 NULL /* no caps context */); 2689 NULL /* no caps context */);
2692 try_flush_caps(inode, session, NULL); 2690 try_flush_caps(inode, session, NULL);
2693 up_read(&mdsc->snap_rwsem); 2691 up_read(&mdsc->snap_rwsem);
2692
2693 /* make sure we re-request max_size, if necessary */
2694 spin_lock(&inode->i_lock);
2695 ci->i_requested_max_size = 0;
2696 spin_unlock(&inode->i_lock);
2694} 2697}
2695 2698
2696/* 2699/*
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index e0a2dc6fcafc..d902948a90d8 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -40,7 +40,8 @@ int ceph_init_dentry(struct dentry *dentry)
40 if (dentry->d_fsdata) 40 if (dentry->d_fsdata)
41 return 0; 41 return 0;
42 42
43 if (ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP) 43 if (dentry->d_parent == NULL || /* nfs fh_to_dentry */
44 ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP)
44 dentry->d_op = &ceph_dentry_ops; 45 dentry->d_op = &ceph_dentry_ops;
45 else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR) 46 else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR)
46 dentry->d_op = &ceph_snapdir_dentry_ops; 47 dentry->d_op = &ceph_snapdir_dentry_ops;
@@ -114,8 +115,8 @@ static int __dcache_readdir(struct file *filp,
114 spin_lock(&dcache_lock); 115 spin_lock(&dcache_lock);
115 116
116 /* start at beginning? */ 117 /* start at beginning? */
117 if (filp->f_pos == 2 || (last && 118 if (filp->f_pos == 2 || last == NULL ||
118 filp->f_pos < ceph_dentry(last)->offset)) { 119 filp->f_pos < ceph_dentry(last)->offset) {
119 if (list_empty(&parent->d_subdirs)) 120 if (list_empty(&parent->d_subdirs))
120 goto out_unlock; 121 goto out_unlock;
121 p = parent->d_subdirs.prev; 122 p = parent->d_subdirs.prev;
@@ -336,7 +337,10 @@ more:
336 if (req->r_reply_info.dir_end) { 337 if (req->r_reply_info.dir_end) {
337 kfree(fi->last_name); 338 kfree(fi->last_name);
338 fi->last_name = NULL; 339 fi->last_name = NULL;
339 fi->next_offset = 2; 340 if (ceph_frag_is_rightmost(frag))
341 fi->next_offset = 2;
342 else
343 fi->next_offset = 0;
340 } else { 344 } else {
341 rinfo = &req->r_reply_info; 345 rinfo = &req->r_reply_info;
342 err = note_last_dentry(fi, 346 err = note_last_dentry(fi,
@@ -355,18 +359,22 @@ more:
355 u64 pos = ceph_make_fpos(frag, off); 359 u64 pos = ceph_make_fpos(frag, off);
356 struct ceph_mds_reply_inode *in = 360 struct ceph_mds_reply_inode *in =
357 rinfo->dir_in[off - fi->offset].in; 361 rinfo->dir_in[off - fi->offset].in;
362 struct ceph_vino vino;
363 ino_t ino;
364
358 dout("readdir off %d (%d/%d) -> %lld '%.*s' %p\n", 365 dout("readdir off %d (%d/%d) -> %lld '%.*s' %p\n",
359 off, off - fi->offset, rinfo->dir_nr, pos, 366 off, off - fi->offset, rinfo->dir_nr, pos,
360 rinfo->dir_dname_len[off - fi->offset], 367 rinfo->dir_dname_len[off - fi->offset],
361 rinfo->dir_dname[off - fi->offset], in); 368 rinfo->dir_dname[off - fi->offset], in);
362 BUG_ON(!in); 369 BUG_ON(!in);
363 ftype = le32_to_cpu(in->mode) >> 12; 370 ftype = le32_to_cpu(in->mode) >> 12;
371 vino.ino = le64_to_cpu(in->ino);
372 vino.snap = le64_to_cpu(in->snapid);
373 ino = ceph_vino_to_ino(vino);
364 if (filldir(dirent, 374 if (filldir(dirent,
365 rinfo->dir_dname[off - fi->offset], 375 rinfo->dir_dname[off - fi->offset],
366 rinfo->dir_dname_len[off - fi->offset], 376 rinfo->dir_dname_len[off - fi->offset],
367 pos, 377 pos, ino, ftype) < 0) {
368 le64_to_cpu(in->ino),
369 ftype) < 0) {
370 dout("filldir stopping us...\n"); 378 dout("filldir stopping us...\n");
371 return 0; 379 return 0;
372 } 380 }
@@ -414,6 +422,7 @@ static void reset_readdir(struct ceph_file_info *fi)
414 fi->last_readdir = NULL; 422 fi->last_readdir = NULL;
415 } 423 }
416 kfree(fi->last_name); 424 kfree(fi->last_name);
425 fi->last_name = NULL;
417 fi->next_offset = 2; /* compensate for . and .. */ 426 fi->next_offset = 2; /* compensate for . and .. */
418 if (fi->dentry) { 427 if (fi->dentry) {
419 dput(fi->dentry); 428 dput(fi->dentry);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index e77c28cf3690..7d0e4a82d898 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -154,11 +154,13 @@ int ceph_open(struct inode *inode, struct file *file)
154 } 154 }
155 155
156 /* 156 /*
157 * No need to block if we have any caps. Update wanted set 157 * No need to block if we have caps on the auth MDS (for
158 * write) or any MDS (for read). Update wanted set
158 * asynchronously. 159 * asynchronously.
159 */ 160 */
160 spin_lock(&inode->i_lock); 161 spin_lock(&inode->i_lock);
161 if (__ceph_is_any_real_caps(ci)) { 162 if (__ceph_is_any_real_caps(ci) &&
163 (((fmode & CEPH_FILE_MODE_WR) == 0) || ci->i_auth_cap)) {
162 int mds_wanted = __ceph_caps_mds_wanted(ci); 164 int mds_wanted = __ceph_caps_mds_wanted(ci);
163 int issued = __ceph_caps_issued(ci, NULL); 165 int issued = __ceph_caps_issued(ci, NULL);
164 166
@@ -280,11 +282,13 @@ int ceph_release(struct inode *inode, struct file *file)
280static int striped_read(struct inode *inode, 282static int striped_read(struct inode *inode,
281 u64 off, u64 len, 283 u64 off, u64 len,
282 struct page **pages, int num_pages, 284 struct page **pages, int num_pages,
283 int *checkeof) 285 int *checkeof, bool align_to_pages,
286 unsigned long buf_align)
284{ 287{
285 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 288 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
286 struct ceph_inode_info *ci = ceph_inode(inode); 289 struct ceph_inode_info *ci = ceph_inode(inode);
287 u64 pos, this_len; 290 u64 pos, this_len;
291 int io_align, page_align;
288 int page_off = off & ~PAGE_CACHE_MASK; /* first byte's offset in page */ 292 int page_off = off & ~PAGE_CACHE_MASK; /* first byte's offset in page */
289 int left, pages_left; 293 int left, pages_left;
290 int read; 294 int read;
@@ -300,14 +304,19 @@ static int striped_read(struct inode *inode,
300 page_pos = pages; 304 page_pos = pages;
301 pages_left = num_pages; 305 pages_left = num_pages;
302 read = 0; 306 read = 0;
307 io_align = off & ~PAGE_MASK;
303 308
304more: 309more:
310 if (align_to_pages)
311 page_align = (pos - io_align + buf_align) & ~PAGE_MASK;
312 else
313 page_align = pos & ~PAGE_MASK;
305 this_len = left; 314 this_len = left;
306 ret = ceph_osdc_readpages(&fsc->client->osdc, ceph_vino(inode), 315 ret = ceph_osdc_readpages(&fsc->client->osdc, ceph_vino(inode),
307 &ci->i_layout, pos, &this_len, 316 &ci->i_layout, pos, &this_len,
308 ci->i_truncate_seq, 317 ci->i_truncate_seq,
309 ci->i_truncate_size, 318 ci->i_truncate_size,
310 page_pos, pages_left); 319 page_pos, pages_left, page_align);
311 hit_stripe = this_len < left; 320 hit_stripe = this_len < left;
312 was_short = ret >= 0 && ret < this_len; 321 was_short = ret >= 0 && ret < this_len;
313 if (ret == -ENOENT) 322 if (ret == -ENOENT)
@@ -368,32 +377,34 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data,
368 struct inode *inode = file->f_dentry->d_inode; 377 struct inode *inode = file->f_dentry->d_inode;
369 struct page **pages; 378 struct page **pages;
370 u64 off = *poff; 379 u64 off = *poff;
371 int num_pages = calc_pages_for(off, len); 380 int num_pages, ret;
372 int ret;
373 381
374 dout("sync_read on file %p %llu~%u %s\n", file, off, len, 382 dout("sync_read on file %p %llu~%u %s\n", file, off, len,
375 (file->f_flags & O_DIRECT) ? "O_DIRECT" : ""); 383 (file->f_flags & O_DIRECT) ? "O_DIRECT" : "");
376 384
377 if (file->f_flags & O_DIRECT) { 385 if (file->f_flags & O_DIRECT) {
378 pages = ceph_get_direct_page_vector(data, num_pages, off, len); 386 num_pages = calc_pages_for((unsigned long)data, len);
379 387 pages = ceph_get_direct_page_vector(data, num_pages, true);
380 /*
381 * flush any page cache pages in this range. this
382 * will make concurrent normal and O_DIRECT io slow,
383 * but it will at least behave sensibly when they are
384 * in sequence.
385 */
386 } else { 388 } else {
389 num_pages = calc_pages_for(off, len);
387 pages = ceph_alloc_page_vector(num_pages, GFP_NOFS); 390 pages = ceph_alloc_page_vector(num_pages, GFP_NOFS);
388 } 391 }
389 if (IS_ERR(pages)) 392 if (IS_ERR(pages))
390 return PTR_ERR(pages); 393 return PTR_ERR(pages);
391 394
395 /*
396 * flush any page cache pages in this range. this
397 * will make concurrent normal and sync io slow,
398 * but it will at least behave sensibly when they are
399 * in sequence.
400 */
392 ret = filemap_write_and_wait(inode->i_mapping); 401 ret = filemap_write_and_wait(inode->i_mapping);
393 if (ret < 0) 402 if (ret < 0)
394 goto done; 403 goto done;
395 404
396 ret = striped_read(inode, off, len, pages, num_pages, checkeof); 405 ret = striped_read(inode, off, len, pages, num_pages, checkeof,
406 file->f_flags & O_DIRECT,
407 (unsigned long)data & ~PAGE_MASK);
397 408
398 if (ret >= 0 && (file->f_flags & O_DIRECT) == 0) 409 if (ret >= 0 && (file->f_flags & O_DIRECT) == 0)
399 ret = ceph_copy_page_vector_to_user(pages, data, off, ret); 410 ret = ceph_copy_page_vector_to_user(pages, data, off, ret);
@@ -402,7 +413,7 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data,
402 413
403done: 414done:
404 if (file->f_flags & O_DIRECT) 415 if (file->f_flags & O_DIRECT)
405 ceph_put_page_vector(pages, num_pages); 416 ceph_put_page_vector(pages, num_pages, true);
406 else 417 else
407 ceph_release_page_vector(pages, num_pages); 418 ceph_release_page_vector(pages, num_pages);
408 dout("sync_read result %d\n", ret); 419 dout("sync_read result %d\n", ret);
@@ -448,6 +459,8 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
448 int flags; 459 int flags;
449 int do_sync = 0; 460 int do_sync = 0;
450 int check_caps = 0; 461 int check_caps = 0;
462 int page_align, io_align;
463 unsigned long buf_align;
451 int ret; 464 int ret;
452 struct timespec mtime = CURRENT_TIME; 465 struct timespec mtime = CURRENT_TIME;
453 466
@@ -462,6 +475,9 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
462 else 475 else
463 pos = *offset; 476 pos = *offset;
464 477
478 io_align = pos & ~PAGE_MASK;
479 buf_align = (unsigned long)data & ~PAGE_MASK;
480
465 ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left); 481 ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left);
466 if (ret < 0) 482 if (ret < 0)
467 return ret; 483 return ret;
@@ -486,20 +502,27 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data,
486 */ 502 */
487more: 503more:
488 len = left; 504 len = left;
505 if (file->f_flags & O_DIRECT) {
506 /* write from beginning of first page, regardless of
507 io alignment */
508 page_align = (pos - io_align + buf_align) & ~PAGE_MASK;
509 num_pages = calc_pages_for((unsigned long)data, len);
510 } else {
511 page_align = pos & ~PAGE_MASK;
512 num_pages = calc_pages_for(pos, len);
513 }
489 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, 514 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
490 ceph_vino(inode), pos, &len, 515 ceph_vino(inode), pos, &len,
491 CEPH_OSD_OP_WRITE, flags, 516 CEPH_OSD_OP_WRITE, flags,
492 ci->i_snap_realm->cached_context, 517 ci->i_snap_realm->cached_context,
493 do_sync, 518 do_sync,
494 ci->i_truncate_seq, ci->i_truncate_size, 519 ci->i_truncate_seq, ci->i_truncate_size,
495 &mtime, false, 2); 520 &mtime, false, 2, page_align);
496 if (!req) 521 if (!req)
497 return -ENOMEM; 522 return -ENOMEM;
498 523
499 num_pages = calc_pages_for(pos, len);
500
501 if (file->f_flags & O_DIRECT) { 524 if (file->f_flags & O_DIRECT) {
502 pages = ceph_get_direct_page_vector(data, num_pages, pos, len); 525 pages = ceph_get_direct_page_vector(data, num_pages, false);
503 if (IS_ERR(pages)) { 526 if (IS_ERR(pages)) {
504 ret = PTR_ERR(pages); 527 ret = PTR_ERR(pages);
505 goto out; 528 goto out;
@@ -549,7 +572,7 @@ more:
549 } 572 }
550 573
551 if (file->f_flags & O_DIRECT) 574 if (file->f_flags & O_DIRECT)
552 ceph_put_page_vector(pages, num_pages); 575 ceph_put_page_vector(pages, num_pages, false);
553 else if (file->f_flags & O_SYNC) 576 else if (file->f_flags & O_SYNC)
554 ceph_release_page_vector(pages, num_pages); 577 ceph_release_page_vector(pages, num_pages);
555 578
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 1d6a45b5a04c..bf1286588f26 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2,7 +2,6 @@
2 2
3#include <linux/module.h> 3#include <linux/module.h>
4#include <linux/fs.h> 4#include <linux/fs.h>
5#include <linux/smp_lock.h>
6#include <linux/slab.h> 5#include <linux/slab.h>
7#include <linux/string.h> 6#include <linux/string.h>
8#include <linux/uaccess.h> 7#include <linux/uaccess.h>
@@ -471,7 +470,9 @@ void ceph_fill_file_time(struct inode *inode, int issued,
471 470
472 if (issued & (CEPH_CAP_FILE_EXCL| 471 if (issued & (CEPH_CAP_FILE_EXCL|
473 CEPH_CAP_FILE_WR| 472 CEPH_CAP_FILE_WR|
474 CEPH_CAP_FILE_BUFFER)) { 473 CEPH_CAP_FILE_BUFFER|
474 CEPH_CAP_AUTH_EXCL|
475 CEPH_CAP_XATTR_EXCL)) {
475 if (timespec_compare(ctime, &inode->i_ctime) > 0) { 476 if (timespec_compare(ctime, &inode->i_ctime) > 0) {
476 dout("ctime %ld.%09ld -> %ld.%09ld inc w/ cap\n", 477 dout("ctime %ld.%09ld -> %ld.%09ld inc w/ cap\n",
477 inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec, 478 inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
@@ -511,7 +512,7 @@ void ceph_fill_file_time(struct inode *inode, int issued,
511 warn = 1; 512 warn = 1;
512 } 513 }
513 } else { 514 } else {
514 /* we have no write caps; whatever the MDS says is true */ 515 /* we have no write|excl caps; whatever the MDS says is true */
515 if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) >= 0) { 516 if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) >= 0) {
516 inode->i_ctime = *ctime; 517 inode->i_ctime = *ctime;
517 inode->i_mtime = *mtime; 518 inode->i_mtime = *mtime;
@@ -567,12 +568,17 @@ static int fill_inode(struct inode *inode,
567 568
568 /* 569 /*
569 * provided version will be odd if inode value is projected, 570 * provided version will be odd if inode value is projected,
570 * even if stable. skip the update if we have a newer info 571 * even if stable. skip the update if we have newer stable
571 * (e.g., due to inode info racing form multiple MDSs), or if 572 * info (ours>=theirs, e.g. due to racing mds replies), unless
572 * we are getting projected (unstable) inode info. 573 * we are getting projected (unstable) info (in which case the
574 * version is odd, and we want ours>theirs).
575 * us them
576 * 2 2 skip
577 * 3 2 skip
578 * 3 3 update
573 */ 579 */
574 if (le64_to_cpu(info->version) > 0 && 580 if (le64_to_cpu(info->version) > 0 &&
575 (ci->i_version & ~1) > le64_to_cpu(info->version)) 581 (ci->i_version & ~1) >= le64_to_cpu(info->version))
576 goto no_change; 582 goto no_change;
577 583
578 issued = __ceph_caps_issued(ci, &implemented); 584 issued = __ceph_caps_issued(ci, &implemented);
@@ -606,7 +612,14 @@ static int fill_inode(struct inode *inode,
606 le32_to_cpu(info->time_warp_seq), 612 le32_to_cpu(info->time_warp_seq),
607 &ctime, &mtime, &atime); 613 &ctime, &mtime, &atime);
608 614
609 ci->i_max_size = le64_to_cpu(info->max_size); 615 /* only update max_size on auth cap */
616 if ((info->cap.flags & CEPH_CAP_FLAG_AUTH) &&
617 ci->i_max_size != le64_to_cpu(info->max_size)) {
618 dout("max_size %lld -> %llu\n", ci->i_max_size,
619 le64_to_cpu(info->max_size));
620 ci->i_max_size = le64_to_cpu(info->max_size);
621 }
622
610 ci->i_layout = info->layout; 623 ci->i_layout = info->layout;
611 inode->i_blkbits = fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1; 624 inode->i_blkbits = fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1;
612 625
@@ -1055,7 +1068,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
1055 ininfo = rinfo->targeti.in; 1068 ininfo = rinfo->targeti.in;
1056 vino.ino = le64_to_cpu(ininfo->ino); 1069 vino.ino = le64_to_cpu(ininfo->ino);
1057 vino.snap = le64_to_cpu(ininfo->snapid); 1070 vino.snap = le64_to_cpu(ininfo->snapid);
1058 if (!dn->d_inode) { 1071 in = dn->d_inode;
1072 if (!in) {
1059 in = ceph_get_inode(sb, vino); 1073 in = ceph_get_inode(sb, vino);
1060 if (IS_ERR(in)) { 1074 if (IS_ERR(in)) {
1061 pr_err("fill_trace bad get_inode " 1075 pr_err("fill_trace bad get_inode "
@@ -1386,11 +1400,8 @@ static void ceph_invalidate_work(struct work_struct *work)
1386 spin_lock(&inode->i_lock); 1400 spin_lock(&inode->i_lock);
1387 dout("invalidate_pages %p gen %d revoking %d\n", inode, 1401 dout("invalidate_pages %p gen %d revoking %d\n", inode,
1388 ci->i_rdcache_gen, ci->i_rdcache_revoking); 1402 ci->i_rdcache_gen, ci->i_rdcache_revoking);
1389 if (ci->i_rdcache_gen == 0 || 1403 if (ci->i_rdcache_revoking != ci->i_rdcache_gen) {
1390 ci->i_rdcache_revoking != ci->i_rdcache_gen) {
1391 BUG_ON(ci->i_rdcache_revoking > ci->i_rdcache_gen);
1392 /* nevermind! */ 1404 /* nevermind! */
1393 ci->i_rdcache_revoking = 0;
1394 spin_unlock(&inode->i_lock); 1405 spin_unlock(&inode->i_lock);
1395 goto out; 1406 goto out;
1396 } 1407 }
@@ -1400,15 +1411,16 @@ static void ceph_invalidate_work(struct work_struct *work)
1400 ceph_invalidate_nondirty_pages(inode->i_mapping); 1411 ceph_invalidate_nondirty_pages(inode->i_mapping);
1401 1412
1402 spin_lock(&inode->i_lock); 1413 spin_lock(&inode->i_lock);
1403 if (orig_gen == ci->i_rdcache_gen) { 1414 if (orig_gen == ci->i_rdcache_gen &&
1415 orig_gen == ci->i_rdcache_revoking) {
1404 dout("invalidate_pages %p gen %d successful\n", inode, 1416 dout("invalidate_pages %p gen %d successful\n", inode,
1405 ci->i_rdcache_gen); 1417 ci->i_rdcache_gen);
1406 ci->i_rdcache_gen = 0; 1418 ci->i_rdcache_revoking--;
1407 ci->i_rdcache_revoking = 0;
1408 check = 1; 1419 check = 1;
1409 } else { 1420 } else {
1410 dout("invalidate_pages %p gen %d raced, gen now %d\n", 1421 dout("invalidate_pages %p gen %d raced, now %d revoking %d\n",
1411 inode, orig_gen, ci->i_rdcache_gen); 1422 inode, orig_gen, ci->i_rdcache_gen,
1423 ci->i_rdcache_revoking);
1412 } 1424 }
1413 spin_unlock(&inode->i_lock); 1425 spin_unlock(&inode->i_lock);
1414 1426
@@ -1739,7 +1751,7 @@ int ceph_do_getattr(struct inode *inode, int mask)
1739 return 0; 1751 return 0;
1740 } 1752 }
1741 1753
1742 dout("do_getattr inode %p mask %s\n", inode, ceph_cap_string(mask)); 1754 dout("do_getattr inode %p mask %s mode 0%o\n", inode, ceph_cap_string(mask), inode->i_mode);
1743 if (ceph_caps_issued_mask(ceph_inode(inode), mask, 1)) 1755 if (ceph_caps_issued_mask(ceph_inode(inode), mask, 1))
1744 return 0; 1756 return 0;
1745 1757
diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
index a6ce54e94eb5..52e8fd74d450 100644
--- a/fs/ceph/ioctl.h
+++ b/fs/ceph/ioctl.h
@@ -4,7 +4,7 @@
4#include <linux/ioctl.h> 4#include <linux/ioctl.h>
5#include <linux/types.h> 5#include <linux/types.h>
6 6
7#define CEPH_IOCTL_MAGIC 0x98 7#define CEPH_IOCTL_MAGIC 0x97
8 8
9/* just use u64 to align sanely on all archs */ 9/* just use u64 to align sanely on all archs */
10struct ceph_ioctl_layout { 10struct ceph_ioctl_layout {
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index 40abde93c345..476b329867d4 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -11,40 +11,68 @@
11 * Implement fcntl and flock locking functions. 11 * Implement fcntl and flock locking functions.
12 */ 12 */
13static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file, 13static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file,
14 u64 pid, u64 pid_ns, 14 int cmd, u8 wait, struct file_lock *fl)
15 int cmd, u64 start, u64 length, u8 wait)
16{ 15{
17 struct inode *inode = file->f_dentry->d_inode; 16 struct inode *inode = file->f_dentry->d_inode;
18 struct ceph_mds_client *mdsc = 17 struct ceph_mds_client *mdsc =
19 ceph_sb_to_client(inode->i_sb)->mdsc; 18 ceph_sb_to_client(inode->i_sb)->mdsc;
20 struct ceph_mds_request *req; 19 struct ceph_mds_request *req;
21 int err; 20 int err;
21 u64 length = 0;
22 22
23 req = ceph_mdsc_create_request(mdsc, operation, USE_AUTH_MDS); 23 req = ceph_mdsc_create_request(mdsc, operation, USE_AUTH_MDS);
24 if (IS_ERR(req)) 24 if (IS_ERR(req))
25 return PTR_ERR(req); 25 return PTR_ERR(req);
26 req->r_inode = igrab(inode); 26 req->r_inode = igrab(inode);
27 27
28 /* mds requires start and length rather than start and end */
29 if (LLONG_MAX == fl->fl_end)
30 length = 0;
31 else
32 length = fl->fl_end - fl->fl_start + 1;
33
28 dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, " 34 dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, "
29 "length: %llu, wait: %d, type`: %d", (int)lock_type, 35 "length: %llu, wait: %d, type`: %d", (int)lock_type,
30 (int)operation, pid, start, length, wait, cmd); 36 (int)operation, (u64)fl->fl_pid, fl->fl_start,
37 length, wait, fl->fl_type);
38
31 39
32 req->r_args.filelock_change.rule = lock_type; 40 req->r_args.filelock_change.rule = lock_type;
33 req->r_args.filelock_change.type = cmd; 41 req->r_args.filelock_change.type = cmd;
34 req->r_args.filelock_change.pid = cpu_to_le64(pid); 42 req->r_args.filelock_change.pid = cpu_to_le64((u64)fl->fl_pid);
35 /* This should be adjusted, but I'm not sure if 43 /* This should be adjusted, but I'm not sure if
36 namespaces actually get id numbers*/ 44 namespaces actually get id numbers*/
37 req->r_args.filelock_change.pid_namespace = 45 req->r_args.filelock_change.pid_namespace =
38 cpu_to_le64((u64)pid_ns); 46 cpu_to_le64((u64)(unsigned long)fl->fl_nspid);
39 req->r_args.filelock_change.start = cpu_to_le64(start); 47 req->r_args.filelock_change.start = cpu_to_le64(fl->fl_start);
40 req->r_args.filelock_change.length = cpu_to_le64(length); 48 req->r_args.filelock_change.length = cpu_to_le64(length);
41 req->r_args.filelock_change.wait = wait; 49 req->r_args.filelock_change.wait = wait;
42 50
43 err = ceph_mdsc_do_request(mdsc, inode, req); 51 err = ceph_mdsc_do_request(mdsc, inode, req);
52
53 if ( operation == CEPH_MDS_OP_GETFILELOCK){
54 fl->fl_pid = le64_to_cpu(req->r_reply_info.filelock_reply->pid);
55 if (CEPH_LOCK_SHARED == req->r_reply_info.filelock_reply->type)
56 fl->fl_type = F_RDLCK;
57 else if (CEPH_LOCK_EXCL == req->r_reply_info.filelock_reply->type)
58 fl->fl_type = F_WRLCK;
59 else
60 fl->fl_type = F_UNLCK;
61
62 fl->fl_start = le64_to_cpu(req->r_reply_info.filelock_reply->start);
63 length = le64_to_cpu(req->r_reply_info.filelock_reply->start) +
64 le64_to_cpu(req->r_reply_info.filelock_reply->length);
65 if (length >= 1)
66 fl->fl_end = length -1;
67 else
68 fl->fl_end = 0;
69
70 }
44 ceph_mdsc_put_request(req); 71 ceph_mdsc_put_request(req);
45 dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, " 72 dout("ceph_lock_message: rule: %d, op: %d, pid: %llu, start: %llu, "
46 "length: %llu, wait: %d, type`: %d err code %d", (int)lock_type, 73 "length: %llu, wait: %d, type`: %d, err code %d", (int)lock_type,
47 (int)operation, pid, start, length, wait, cmd, err); 74 (int)operation, (u64)fl->fl_pid, fl->fl_start,
75 length, wait, fl->fl_type, err);
48 return err; 76 return err;
49} 77}
50 78
@@ -54,7 +82,6 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file,
54 */ 82 */
55int ceph_lock(struct file *file, int cmd, struct file_lock *fl) 83int ceph_lock(struct file *file, int cmd, struct file_lock *fl)
56{ 84{
57 u64 length;
58 u8 lock_cmd; 85 u8 lock_cmd;
59 int err; 86 int err;
60 u8 wait = 0; 87 u8 wait = 0;
@@ -76,29 +103,20 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl)
76 else 103 else
77 lock_cmd = CEPH_LOCK_UNLOCK; 104 lock_cmd = CEPH_LOCK_UNLOCK;
78 105
79 if (LLONG_MAX == fl->fl_end) 106 err = ceph_lock_message(CEPH_LOCK_FCNTL, op, file, lock_cmd, wait, fl);
80 length = 0;
81 else
82 length = fl->fl_end - fl->fl_start + 1;
83
84 err = ceph_lock_message(CEPH_LOCK_FCNTL, op, file,
85 (u64)fl->fl_pid,
86 (u64)(unsigned long)fl->fl_nspid,
87 lock_cmd, fl->fl_start,
88 length, wait);
89 if (!err) { 107 if (!err) {
90 dout("mds locked, locking locally"); 108 if ( op != CEPH_MDS_OP_GETFILELOCK ){
91 err = posix_lock_file(file, fl, NULL); 109 dout("mds locked, locking locally");
92 if (err && (CEPH_MDS_OP_SETFILELOCK == op)) { 110 err = posix_lock_file(file, fl, NULL);
93 /* undo! This should only happen if the kernel detects 111 if (err && (CEPH_MDS_OP_SETFILELOCK == op)) {
94 * local deadlock. */ 112 /* undo! This should only happen if the kernel detects
95 ceph_lock_message(CEPH_LOCK_FCNTL, op, file, 113 * local deadlock. */
96 (u64)fl->fl_pid, 114 ceph_lock_message(CEPH_LOCK_FCNTL, op, file,
97 (u64)(unsigned long)fl->fl_nspid, 115 CEPH_LOCK_UNLOCK, 0, fl);
98 CEPH_LOCK_UNLOCK, fl->fl_start, 116 dout("got %d on posix_lock_file, undid lock", err);
99 length, 0); 117 }
100 dout("got %d on posix_lock_file, undid lock", err);
101 } 118 }
119
102 } else { 120 } else {
103 dout("mds returned error code %d", err); 121 dout("mds returned error code %d", err);
104 } 122 }
@@ -107,7 +125,6 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl)
107 125
108int ceph_flock(struct file *file, int cmd, struct file_lock *fl) 126int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
109{ 127{
110 u64 length;
111 u8 lock_cmd; 128 u8 lock_cmd;
112 int err; 129 int err;
113 u8 wait = 1; 130 u8 wait = 1;
@@ -127,26 +144,15 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
127 lock_cmd = CEPH_LOCK_EXCL; 144 lock_cmd = CEPH_LOCK_EXCL;
128 else 145 else
129 lock_cmd = CEPH_LOCK_UNLOCK; 146 lock_cmd = CEPH_LOCK_UNLOCK;
130 /* mds requires start and length rather than start and end */
131 if (LLONG_MAX == fl->fl_end)
132 length = 0;
133 else
134 length = fl->fl_end - fl->fl_start + 1;
135 147
136 err = ceph_lock_message(CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK, 148 err = ceph_lock_message(CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK,
137 file, (u64)fl->fl_pid, 149 file, lock_cmd, wait, fl);
138 (u64)(unsigned long)fl->fl_nspid,
139 lock_cmd, fl->fl_start,
140 length, wait);
141 if (!err) { 150 if (!err) {
142 err = flock_lock_file_wait(file, fl); 151 err = flock_lock_file_wait(file, fl);
143 if (err) { 152 if (err) {
144 ceph_lock_message(CEPH_LOCK_FLOCK, 153 ceph_lock_message(CEPH_LOCK_FLOCK,
145 CEPH_MDS_OP_SETFILELOCK, 154 CEPH_MDS_OP_SETFILELOCK,
146 file, (u64)fl->fl_pid, 155 file, CEPH_LOCK_UNLOCK, 0, fl);
147 (u64)(unsigned long)fl->fl_nspid,
148 CEPH_LOCK_UNLOCK, fl->fl_start,
149 length, 0);
150 dout("got %d on flock_lock_file_wait, undid lock", err); 156 dout("got %d on flock_lock_file_wait, undid lock", err);
151 } 157 }
152 } else { 158 } else {
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 3142b15940c2..38800eaa81d0 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -6,7 +6,6 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/debugfs.h> 7#include <linux/debugfs.h>
8#include <linux/seq_file.h> 8#include <linux/seq_file.h>
9#include <linux/smp_lock.h>
10 9
11#include "super.h" 10#include "super.h"
12#include "mds_client.h" 11#include "mds_client.h"
@@ -203,6 +202,38 @@ out_bad:
203} 202}
204 203
205/* 204/*
205 * parse fcntl F_GETLK results
206 */
207static int parse_reply_info_filelock(void **p, void *end,
208 struct ceph_mds_reply_info_parsed *info)
209{
210 if (*p + sizeof(*info->filelock_reply) > end)
211 goto bad;
212
213 info->filelock_reply = *p;
214 *p += sizeof(*info->filelock_reply);
215
216 if (unlikely(*p != end))
217 goto bad;
218 return 0;
219
220bad:
221 return -EIO;
222}
223
224/*
225 * parse extra results
226 */
227static int parse_reply_info_extra(void **p, void *end,
228 struct ceph_mds_reply_info_parsed *info)
229{
230 if (info->head->op == CEPH_MDS_OP_GETFILELOCK)
231 return parse_reply_info_filelock(p, end, info);
232 else
233 return parse_reply_info_dir(p, end, info);
234}
235
236/*
206 * parse entire mds reply 237 * parse entire mds reply
207 */ 238 */
208static int parse_reply_info(struct ceph_msg *msg, 239static int parse_reply_info(struct ceph_msg *msg,
@@ -224,10 +255,10 @@ static int parse_reply_info(struct ceph_msg *msg,
224 goto out_bad; 255 goto out_bad;
225 } 256 }
226 257
227 /* dir content */ 258 /* extra */
228 ceph_decode_32_safe(&p, end, len, bad); 259 ceph_decode_32_safe(&p, end, len, bad);
229 if (len > 0) { 260 if (len > 0) {
230 err = parse_reply_info_dir(&p, p+len, info); 261 err = parse_reply_info_extra(&p, p+len, info);
231 if (err < 0) 262 if (err < 0)
232 goto out_bad; 263 goto out_bad;
233 } 264 }
@@ -529,6 +560,9 @@ static void __register_request(struct ceph_mds_client *mdsc,
529 ceph_mdsc_get_request(req); 560 ceph_mdsc_get_request(req);
530 __insert_request(mdsc, req); 561 __insert_request(mdsc, req);
531 562
563 req->r_uid = current_fsuid();
564 req->r_gid = current_fsgid();
565
532 if (dir) { 566 if (dir) {
533 struct ceph_inode_info *ci = ceph_inode(dir); 567 struct ceph_inode_info *ci = ceph_inode(dir);
534 568
@@ -1588,8 +1622,8 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
1588 1622
1589 head->mdsmap_epoch = cpu_to_le32(mdsc->mdsmap->m_epoch); 1623 head->mdsmap_epoch = cpu_to_le32(mdsc->mdsmap->m_epoch);
1590 head->op = cpu_to_le32(req->r_op); 1624 head->op = cpu_to_le32(req->r_op);
1591 head->caller_uid = cpu_to_le32(current_fsuid()); 1625 head->caller_uid = cpu_to_le32(req->r_uid);
1592 head->caller_gid = cpu_to_le32(current_fsgid()); 1626 head->caller_gid = cpu_to_le32(req->r_gid);
1593 head->args = req->r_args; 1627 head->args = req->r_args;
1594 1628
1595 ceph_encode_filepath(&p, end, ino1, path1); 1629 ceph_encode_filepath(&p, end, ino1, path1);
@@ -2072,7 +2106,7 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
2072 2106
2073 mutex_lock(&session->s_mutex); 2107 mutex_lock(&session->s_mutex);
2074 if (err < 0) { 2108 if (err < 0) {
2075 pr_err("mdsc_handle_reply got corrupt reply mds%d\n", mds); 2109 pr_err("mdsc_handle_reply got corrupt reply mds%d(tid:%lld)\n", mds, tid);
2076 ceph_msg_dump(msg); 2110 ceph_msg_dump(msg);
2077 goto out_err; 2111 goto out_err;
2078 } 2112 }
@@ -2092,7 +2126,8 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
2092 mutex_lock(&req->r_fill_mutex); 2126 mutex_lock(&req->r_fill_mutex);
2093 err = ceph_fill_trace(mdsc->fsc->sb, req, req->r_session); 2127 err = ceph_fill_trace(mdsc->fsc->sb, req, req->r_session);
2094 if (err == 0) { 2128 if (err == 0) {
2095 if (result == 0 && rinfo->dir_nr) 2129 if (result == 0 && req->r_op != CEPH_MDS_OP_GETFILELOCK &&
2130 rinfo->dir_nr)
2096 ceph_readdir_prepopulate(req, req->r_session); 2131 ceph_readdir_prepopulate(req, req->r_session);
2097 ceph_unreserve_caps(mdsc, &req->r_caps_reservation); 2132 ceph_unreserve_caps(mdsc, &req->r_caps_reservation);
2098 } 2133 }
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index d66d63c72355..aabe563b54db 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -42,26 +42,37 @@ struct ceph_mds_reply_info_in {
42}; 42};
43 43
44/* 44/*
45 * parsed info about an mds reply, including information about the 45 * parsed info about an mds reply, including information about
46 * target inode and/or its parent directory and dentry, and directory 46 * either: 1) the target inode and/or its parent directory and dentry,
47 * contents (for readdir results). 47 * and directory contents (for readdir results), or
48 * 2) the file range lock info (for fcntl F_GETLK results).
48 */ 49 */
49struct ceph_mds_reply_info_parsed { 50struct ceph_mds_reply_info_parsed {
50 struct ceph_mds_reply_head *head; 51 struct ceph_mds_reply_head *head;
51 52
53 /* trace */
52 struct ceph_mds_reply_info_in diri, targeti; 54 struct ceph_mds_reply_info_in diri, targeti;
53 struct ceph_mds_reply_dirfrag *dirfrag; 55 struct ceph_mds_reply_dirfrag *dirfrag;
54 char *dname; 56 char *dname;
55 u32 dname_len; 57 u32 dname_len;
56 struct ceph_mds_reply_lease *dlease; 58 struct ceph_mds_reply_lease *dlease;
57 59
58 struct ceph_mds_reply_dirfrag *dir_dir; 60 /* extra */
59 int dir_nr; 61 union {
60 char **dir_dname; 62 /* for fcntl F_GETLK results */
61 u32 *dir_dname_len; 63 struct ceph_filelock *filelock_reply;
62 struct ceph_mds_reply_lease **dir_dlease; 64
63 struct ceph_mds_reply_info_in *dir_in; 65 /* for readdir results */
64 u8 dir_complete, dir_end; 66 struct {
67 struct ceph_mds_reply_dirfrag *dir_dir;
68 int dir_nr;
69 char **dir_dname;
70 u32 *dir_dname_len;
71 struct ceph_mds_reply_lease **dir_dlease;
72 struct ceph_mds_reply_info_in *dir_in;
73 u8 dir_complete, dir_end;
74 };
75 };
65 76
66 /* encoded blob describing snapshot contexts for certain 77 /* encoded blob describing snapshot contexts for certain
67 operations (e.g., open) */ 78 operations (e.g., open) */
@@ -170,6 +181,8 @@ struct ceph_mds_request {
170 181
171 union ceph_mds_request_args r_args; 182 union ceph_mds_request_args r_args;
172 int r_fmode; /* file mode, if expecting cap */ 183 int r_fmode; /* file mode, if expecting cap */
184 uid_t r_uid;
185 gid_t r_gid;
173 186
174 /* for choosing which mds to send this request to */ 187 /* for choosing which mds to send this request to */
175 int r_direct_mode; 188 int r_direct_mode;
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 1886294e12f7..7f01728a4657 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -293,9 +293,7 @@ struct ceph_inode_info {
293 int i_rd_ref, i_rdcache_ref, i_wr_ref; 293 int i_rd_ref, i_rdcache_ref, i_wr_ref;
294 int i_wrbuffer_ref, i_wrbuffer_ref_head; 294 int i_wrbuffer_ref, i_wrbuffer_ref_head;
295 u32 i_shared_gen; /* increment each time we get FILE_SHARED */ 295 u32 i_shared_gen; /* increment each time we get FILE_SHARED */
296 u32 i_rdcache_gen; /* we increment this each time we get 296 u32 i_rdcache_gen; /* incremented each time we get FILE_CACHE. */
297 FILE_CACHE. If it's non-zero, we
298 _may_ have cached pages. */
299 u32 i_rdcache_revoking; /* RDCACHE gen to async invalidate, if any */ 297 u32 i_rdcache_revoking; /* RDCACHE gen to async invalidate, if any */
300 298
301 struct list_head i_unsafe_writes; /* uncommitted sync writes */ 299 struct list_head i_unsafe_writes; /* uncommitted sync writes */
diff --git a/fs/cifs/Kconfig b/fs/cifs/Kconfig
index 0ed213970ced..ee45648b0d1a 100644
--- a/fs/cifs/Kconfig
+++ b/fs/cifs/Kconfig
@@ -4,6 +4,7 @@ config CIFS
4 select NLS 4 select NLS
5 select CRYPTO 5 select CRYPTO
6 select CRYPTO_MD5 6 select CRYPTO_MD5
7 select CRYPTO_HMAC
7 select CRYPTO_ARC4 8 select CRYPTO_ARC4
8 help 9 help
9 This is the client VFS module for the Common Internet File System 10 This is the client VFS module for the Common Internet File System
@@ -143,6 +144,13 @@ config CIFS_FSCACHE
143 to be cached locally on disk through the general filesystem cache 144 to be cached locally on disk through the general filesystem cache
144 manager. If unsure, say N. 145 manager. If unsure, say N.
145 146
147config CIFS_ACL
148 bool "Provide CIFS ACL support (EXPERIMENTAL)"
149 depends on EXPERIMENTAL && CIFS_XATTR
150 help
151 Allows to fetch CIFS/NTFS ACL from the server. The DACL blob
152 is handed over to the application/caller.
153
146config CIFS_EXPERIMENTAL 154config CIFS_EXPERIMENTAL
147 bool "CIFS Experimental Features (EXPERIMENTAL)" 155 bool "CIFS Experimental Features (EXPERIMENTAL)"
148 depends on CIFS && EXPERIMENTAL 156 depends on CIFS && EXPERIMENTAL
diff --git a/fs/cifs/Makefile b/fs/cifs/Makefile
index adefa60a9bdc..43b19dd39191 100644
--- a/fs/cifs/Makefile
+++ b/fs/cifs/Makefile
@@ -6,7 +6,9 @@ obj-$(CONFIG_CIFS) += cifs.o
6cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \ 6cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \
7 link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o \ 7 link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o \
8 md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o \ 8 md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o \
9 readdir.o ioctl.o sess.o export.o cifsacl.o 9 readdir.o ioctl.o sess.o export.o
10
11cifs-$(CONFIG_CIFS_ACL) += cifsacl.o
10 12
11cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o 13cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
12 14
diff --git a/fs/cifs/README b/fs/cifs/README
index ee68d1036544..46af99ab3614 100644
--- a/fs/cifs/README
+++ b/fs/cifs/README
@@ -337,6 +337,15 @@ A partial list of the supported mount options follows:
337 wsize default write size (default 57344) 337 wsize default write size (default 57344)
338 maximum wsize currently allowed by CIFS is 57344 (fourteen 338 maximum wsize currently allowed by CIFS is 57344 (fourteen
339 4096 byte pages) 339 4096 byte pages)
340 actimeo=n attribute cache timeout in seconds (default 1 second).
341 After this timeout, the cifs client requests fresh attribute
342 information from the server. This option allows to tune the
343 attribute cache timeout to suit the workload needs. Shorter
344 timeouts mean better the cache coherency, but increased number
345 of calls to the server. Longer timeouts mean reduced number
346 of calls to the server at the expense of less stricter cache
347 coherency checks (i.e. incorrect attribute cache for a short
348 period of time).
340 rw mount the network share read-write (note that the 349 rw mount the network share read-write (note that the
341 server may still consider the share read-only) 350 server may still consider the share read-only)
342 ro mount network share read-only 351 ro mount network share read-only
diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h
index e9a393c9c2ca..7852cd677051 100644
--- a/fs/cifs/cifs_fs_sb.h
+++ b/fs/cifs/cifs_fs_sb.h
@@ -48,6 +48,7 @@ struct cifs_sb_info {
48 struct nls_table *local_nls; 48 struct nls_table *local_nls;
49 unsigned int rsize; 49 unsigned int rsize;
50 unsigned int wsize; 50 unsigned int wsize;
51 unsigned long actimeo; /* attribute cache timeout (jiffies) */
51 atomic_t active; 52 atomic_t active;
52 uid_t mnt_uid; 53 uid_t mnt_uid;
53 gid_t mnt_gid; 54 gid_t mnt_gid;
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index c9b4792ae825..a437ec391a01 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -30,8 +30,6 @@
30#include "cifs_debug.h" 30#include "cifs_debug.h"
31 31
32 32
33#ifdef CONFIG_CIFS_EXPERIMENTAL
34
35static struct cifs_wksid wksidarr[NUM_WK_SIDS] = { 33static struct cifs_wksid wksidarr[NUM_WK_SIDS] = {
36 {{1, 0, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }, "null user"}, 34 {{1, 0, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }, "null user"},
37 {{1, 1, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0} }, "nobody"}, 35 {{1, 1, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0} }, "nobody"},
@@ -560,7 +558,7 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
560 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); 558 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
561 559
562 if (IS_ERR(tlink)) 560 if (IS_ERR(tlink))
563 return NULL; 561 return ERR_CAST(tlink);
564 562
565 xid = GetXid(); 563 xid = GetXid();
566 rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen); 564 rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen);
@@ -568,7 +566,9 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
568 566
569 cifs_put_tlink(tlink); 567 cifs_put_tlink(tlink);
570 568
571 cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen); 569 cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
570 if (rc)
571 return ERR_PTR(rc);
572 return pntsd; 572 return pntsd;
573} 573}
574 574
@@ -583,7 +583,7 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
583 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); 583 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
584 584
585 if (IS_ERR(tlink)) 585 if (IS_ERR(tlink))
586 return NULL; 586 return ERR_CAST(tlink);
587 587
588 tcon = tlink_tcon(tlink); 588 tcon = tlink_tcon(tlink);
589 xid = GetXid(); 589 xid = GetXid();
@@ -591,23 +591,22 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
591 rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0, 591 rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0,
592 &fid, &oplock, NULL, cifs_sb->local_nls, 592 &fid, &oplock, NULL, cifs_sb->local_nls,
593 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 593 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
594 if (rc) { 594 if (!rc) {
595 cERROR(1, "Unable to open file to get ACL"); 595 rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
596 goto out; 596 CIFSSMBClose(xid, tcon, fid);
597 } 597 }
598 598
599 rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
600 cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
601
602 CIFSSMBClose(xid, tcon, fid);
603 out:
604 cifs_put_tlink(tlink); 599 cifs_put_tlink(tlink);
605 FreeXid(xid); 600 FreeXid(xid);
601
602 cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
603 if (rc)
604 return ERR_PTR(rc);
606 return pntsd; 605 return pntsd;
607} 606}
608 607
609/* Retrieve an ACL from the server */ 608/* Retrieve an ACL from the server */
610static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, 609struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
611 struct inode *inode, const char *path, 610 struct inode *inode, const char *path,
612 u32 *pacllen) 611 u32 *pacllen)
613{ 612{
@@ -695,7 +694,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
695} 694}
696 695
697/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ 696/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
698void 697int
699cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, 698cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
700 struct inode *inode, const char *path, const __u16 *pfid) 699 struct inode *inode, const char *path, const __u16 *pfid)
701{ 700{
@@ -711,17 +710,21 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
711 pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen); 710 pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen);
712 711
713 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ 712 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
714 if (pntsd) 713 if (IS_ERR(pntsd)) {
714 rc = PTR_ERR(pntsd);
715 cERROR(1, "%s: error %d getting sec desc", __func__, rc);
716 } else {
715 rc = parse_sec_desc(pntsd, acllen, fattr); 717 rc = parse_sec_desc(pntsd, acllen, fattr);
716 if (rc) 718 kfree(pntsd);
717 cFYI(1, "parse sec desc failed rc = %d", rc); 719 if (rc)
720 cERROR(1, "parse sec desc failed rc = %d", rc);
721 }
718 722
719 kfree(pntsd); 723 return rc;
720 return;
721} 724}
722 725
723/* Convert mode bits to an ACL so we can update the ACL on the server */ 726/* Convert mode bits to an ACL so we can update the ACL on the server */
724int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) 727int mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode)
725{ 728{
726 int rc = 0; 729 int rc = 0;
727 __u32 secdesclen = 0; 730 __u32 secdesclen = 0;
@@ -736,7 +739,10 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
736 /* Add three ACEs for owner, group, everyone getting rid of 739 /* Add three ACEs for owner, group, everyone getting rid of
737 other ACEs as chmod disables ACEs and set the security descriptor */ 740 other ACEs as chmod disables ACEs and set the security descriptor */
738 741
739 if (pntsd) { 742 if (IS_ERR(pntsd)) {
743 rc = PTR_ERR(pntsd);
744 cERROR(1, "%s: error %d getting sec desc", __func__, rc);
745 } else {
740 /* allocate memory for the smb header, 746 /* allocate memory for the smb header,
741 set security descriptor request security descriptor 747 set security descriptor request security descriptor
742 parameters, and secuirty descriptor itself */ 748 parameters, and secuirty descriptor itself */
@@ -766,4 +772,3 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
766 772
767 return rc; 773 return rc;
768} 774}
769#endif /* CONFIG_CIFS_EXPERIMENTAL */
diff --git a/fs/cifs/cifsacl.h b/fs/cifs/cifsacl.h
index 6c8096cf5155..c4ae7d036563 100644
--- a/fs/cifs/cifsacl.h
+++ b/fs/cifs/cifsacl.h
@@ -74,11 +74,7 @@ struct cifs_wksid {
74 char sidname[SIDNAMELENGTH]; 74 char sidname[SIDNAMELENGTH];
75} __attribute__((packed)); 75} __attribute__((packed));
76 76
77#ifdef CONFIG_CIFS_EXPERIMENTAL
78
79extern int match_sid(struct cifs_sid *); 77extern int match_sid(struct cifs_sid *);
80extern int compare_sids(const struct cifs_sid *, const struct cifs_sid *); 78extern int compare_sids(const struct cifs_sid *, const struct cifs_sid *);
81 79
82#endif /* CONFIG_CIFS_EXPERIMENTAL */
83
84#endif /* _CIFSACL_H */ 80#endif /* _CIFSACL_H */
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 9c3789762ab7..3936aa7f2c22 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -458,9 +458,13 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
458 seq_printf(s, ",acl"); 458 seq_printf(s, ",acl");
459 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) 459 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
460 seq_printf(s, ",mfsymlinks"); 460 seq_printf(s, ",mfsymlinks");
461 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE)
462 seq_printf(s, ",fsc");
461 463
462 seq_printf(s, ",rsize=%d", cifs_sb->rsize); 464 seq_printf(s, ",rsize=%d", cifs_sb->rsize);
463 seq_printf(s, ",wsize=%d", cifs_sb->wsize); 465 seq_printf(s, ",wsize=%d", cifs_sb->wsize);
466 /* convert actimeo and display it in seconds */
467 seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
464 468
465 return 0; 469 return 0;
466} 470}
@@ -933,7 +937,6 @@ init_cifs(void)
933 GlobalCurrentXid = 0; 937 GlobalCurrentXid = 0;
934 GlobalTotalActiveXid = 0; 938 GlobalTotalActiveXid = 0;
935 GlobalMaxActiveXid = 0; 939 GlobalMaxActiveXid = 0;
936 memset(Local_System_Name, 0, 15);
937 spin_lock_init(&cifs_tcp_ses_lock); 940 spin_lock_init(&cifs_tcp_ses_lock);
938 spin_lock_init(&cifs_file_list_lock); 941 spin_lock_init(&cifs_file_list_lock);
939 spin_lock_init(&GlobalMid_Lock); 942 spin_lock_init(&GlobalMid_Lock);
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index b577bf0a1bb3..7136c0c3e2f9 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -45,6 +45,16 @@
45#define CIFS_MIN_RCV_POOL 4 45#define CIFS_MIN_RCV_POOL 4
46 46
47/* 47/*
48 * default attribute cache timeout (jiffies)
49 */
50#define CIFS_DEF_ACTIMEO (1 * HZ)
51
52/*
53 * max attribute cache timeout (jiffies) - 2^30
54 */
55#define CIFS_MAX_ACTIMEO (1 << 30)
56
57/*
48 * MAX_REQ is the maximum number of requests that WE will send 58 * MAX_REQ is the maximum number of requests that WE will send
49 * on one socket concurrently. It also matches the most common 59 * on one socket concurrently. It also matches the most common
50 * value of max multiplex returned by servers. We may 60 * value of max multiplex returned by servers. We may
@@ -746,8 +756,6 @@ GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
746GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */ 756GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */
747GLOBAL_EXTERN spinlock_t GlobalMid_Lock; /* protects above & list operations */ 757GLOBAL_EXTERN spinlock_t GlobalMid_Lock; /* protects above & list operations */
748 /* on midQ entries */ 758 /* on midQ entries */
749GLOBAL_EXTERN char Local_System_Name[15];
750
751/* 759/*
752 * Global counters, updated atomically 760 * Global counters, updated atomically
753 */ 761 */
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 7ed69b6b5fe6..e6d1481b16c1 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -54,7 +54,8 @@ do { \
54 __func__, curr_xid, (int)rc); \ 54 __func__, curr_xid, (int)rc); \
55} while (0) 55} while (0)
56extern char *build_path_from_dentry(struct dentry *); 56extern char *build_path_from_dentry(struct dentry *);
57extern char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb); 57extern char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb,
58 struct cifsTconInfo *tcon);
58extern char *build_wildcard_path_from_dentry(struct dentry *direntry); 59extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
59extern char *cifs_compose_mount_options(const char *sb_mountdata, 60extern char *cifs_compose_mount_options(const char *sb_mountdata,
60 const char *fullpath, const struct dfs_info3_param *ref, 61 const char *fullpath, const struct dfs_info3_param *ref,
@@ -79,9 +80,7 @@ extern bool is_valid_oplock_break(struct smb_hdr *smb,
79 struct TCP_Server_Info *); 80 struct TCP_Server_Info *);
80extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof); 81extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof);
81extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, bool); 82extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, bool);
82#ifdef CONFIG_CIFS_EXPERIMENTAL
83extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool); 83extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool);
84#endif
85extern unsigned int smbCalcSize(struct smb_hdr *ptr); 84extern unsigned int smbCalcSize(struct smb_hdr *ptr);
86extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr); 85extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr);
87extern int decode_negTokenInit(unsigned char *security_blob, int length, 86extern int decode_negTokenInit(unsigned char *security_blob, int length,
@@ -130,10 +129,12 @@ extern int cifs_get_file_info_unix(struct file *filp);
130extern int cifs_get_inode_info_unix(struct inode **pinode, 129extern int cifs_get_inode_info_unix(struct inode **pinode,
131 const unsigned char *search_path, 130 const unsigned char *search_path,
132 struct super_block *sb, int xid); 131 struct super_block *sb, int xid);
133extern void cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, 132extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
134 struct cifs_fattr *fattr, struct inode *inode, 133 struct cifs_fattr *fattr, struct inode *inode,
135 const char *path, const __u16 *pfid); 134 const char *path, const __u16 *pfid);
136extern int mode_to_acl(struct inode *inode, const char *path, __u64); 135extern int mode_to_cifs_acl(struct inode *inode, const char *path, __u64);
136extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *,
137 const char *, u32 *);
137 138
138extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *, 139extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
139 const char *); 140 const char *);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 2f2632b6df5a..67acfb3acad2 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -2478,95 +2478,6 @@ querySymLinkRetry:
2478} 2478}
2479 2479
2480#ifdef CONFIG_CIFS_EXPERIMENTAL 2480#ifdef CONFIG_CIFS_EXPERIMENTAL
2481/* Initialize NT TRANSACT SMB into small smb request buffer.
2482 This assumes that all NT TRANSACTS that we init here have
2483 total parm and data under about 400 bytes (to fit in small cifs
2484 buffer size), which is the case so far, it easily fits. NB:
2485 Setup words themselves and ByteCount
2486 MaxSetupCount (size of returned setup area) and
2487 MaxParameterCount (returned parms size) must be set by caller */
2488static int
2489smb_init_nttransact(const __u16 sub_command, const int setup_count,
2490 const int parm_len, struct cifsTconInfo *tcon,
2491 void **ret_buf)
2492{
2493 int rc;
2494 __u32 temp_offset;
2495 struct smb_com_ntransact_req *pSMB;
2496
2497 rc = small_smb_init(SMB_COM_NT_TRANSACT, 19 + setup_count, tcon,
2498 (void **)&pSMB);
2499 if (rc)
2500 return rc;
2501 *ret_buf = (void *)pSMB;
2502 pSMB->Reserved = 0;
2503 pSMB->TotalParameterCount = cpu_to_le32(parm_len);
2504 pSMB->TotalDataCount = 0;
2505 pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -
2506 MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);
2507 pSMB->ParameterCount = pSMB->TotalParameterCount;
2508 pSMB->DataCount = pSMB->TotalDataCount;
2509 temp_offset = offsetof(struct smb_com_ntransact_req, Parms) +
2510 (setup_count * 2) - 4 /* for rfc1001 length itself */;
2511 pSMB->ParameterOffset = cpu_to_le32(temp_offset);
2512 pSMB->DataOffset = cpu_to_le32(temp_offset + parm_len);
2513 pSMB->SetupCount = setup_count; /* no need to le convert byte fields */
2514 pSMB->SubCommand = cpu_to_le16(sub_command);
2515 return 0;
2516}
2517
2518static int
2519validate_ntransact(char *buf, char **ppparm, char **ppdata,
2520 __u32 *pparmlen, __u32 *pdatalen)
2521{
2522 char *end_of_smb;
2523 __u32 data_count, data_offset, parm_count, parm_offset;
2524 struct smb_com_ntransact_rsp *pSMBr;
2525
2526 *pdatalen = 0;
2527 *pparmlen = 0;
2528
2529 if (buf == NULL)
2530 return -EINVAL;
2531
2532 pSMBr = (struct smb_com_ntransact_rsp *)buf;
2533
2534 /* ByteCount was converted from little endian in SendReceive */
2535 end_of_smb = 2 /* sizeof byte count */ + pSMBr->ByteCount +
2536 (char *)&pSMBr->ByteCount;
2537
2538 data_offset = le32_to_cpu(pSMBr->DataOffset);
2539 data_count = le32_to_cpu(pSMBr->DataCount);
2540 parm_offset = le32_to_cpu(pSMBr->ParameterOffset);
2541 parm_count = le32_to_cpu(pSMBr->ParameterCount);
2542
2543 *ppparm = (char *)&pSMBr->hdr.Protocol + parm_offset;
2544 *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset;
2545
2546 /* should we also check that parm and data areas do not overlap? */
2547 if (*ppparm > end_of_smb) {
2548 cFYI(1, "parms start after end of smb");
2549 return -EINVAL;
2550 } else if (parm_count + *ppparm > end_of_smb) {
2551 cFYI(1, "parm end after end of smb");
2552 return -EINVAL;
2553 } else if (*ppdata > end_of_smb) {
2554 cFYI(1, "data starts after end of smb");
2555 return -EINVAL;
2556 } else if (data_count + *ppdata > end_of_smb) {
2557 cFYI(1, "data %p + count %d (%p) past smb end %p start %p",
2558 *ppdata, data_count, (data_count + *ppdata),
2559 end_of_smb, pSMBr);
2560 return -EINVAL;
2561 } else if (parm_count + data_count > pSMBr->ByteCount) {
2562 cFYI(1, "parm count and data count larger than SMB");
2563 return -EINVAL;
2564 }
2565 *pdatalen = data_count;
2566 *pparmlen = parm_count;
2567 return 0;
2568}
2569
2570int 2481int
2571CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon, 2482CIFSSMBQueryReparseLinkInfo(const int xid, struct cifsTconInfo *tcon,
2572 const unsigned char *searchName, 2483 const unsigned char *searchName,
@@ -3056,7 +2967,97 @@ GetExtAttrOut:
3056 2967
3057#endif /* CONFIG_POSIX */ 2968#endif /* CONFIG_POSIX */
3058 2969
3059#ifdef CONFIG_CIFS_EXPERIMENTAL 2970#ifdef CONFIG_CIFS_ACL
2971/*
2972 * Initialize NT TRANSACT SMB into small smb request buffer. This assumes that
2973 * all NT TRANSACTS that we init here have total parm and data under about 400
2974 * bytes (to fit in small cifs buffer size), which is the case so far, it
2975 * easily fits. NB: Setup words themselves and ByteCount MaxSetupCount (size of
2976 * returned setup area) and MaxParameterCount (returned parms size) must be set
2977 * by caller
2978 */
2979static int
2980smb_init_nttransact(const __u16 sub_command, const int setup_count,
2981 const int parm_len, struct cifsTconInfo *tcon,
2982 void **ret_buf)
2983{
2984 int rc;
2985 __u32 temp_offset;
2986 struct smb_com_ntransact_req *pSMB;
2987
2988 rc = small_smb_init(SMB_COM_NT_TRANSACT, 19 + setup_count, tcon,
2989 (void **)&pSMB);
2990 if (rc)
2991 return rc;
2992 *ret_buf = (void *)pSMB;
2993 pSMB->Reserved = 0;
2994 pSMB->TotalParameterCount = cpu_to_le32(parm_len);
2995 pSMB->TotalDataCount = 0;
2996 pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -
2997 MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);
2998 pSMB->ParameterCount = pSMB->TotalParameterCount;
2999 pSMB->DataCount = pSMB->TotalDataCount;
3000 temp_offset = offsetof(struct smb_com_ntransact_req, Parms) +
3001 (setup_count * 2) - 4 /* for rfc1001 length itself */;
3002 pSMB->ParameterOffset = cpu_to_le32(temp_offset);
3003 pSMB->DataOffset = cpu_to_le32(temp_offset + parm_len);
3004 pSMB->SetupCount = setup_count; /* no need to le convert byte fields */
3005 pSMB->SubCommand = cpu_to_le16(sub_command);
3006 return 0;
3007}
3008
3009static int
3010validate_ntransact(char *buf, char **ppparm, char **ppdata,
3011 __u32 *pparmlen, __u32 *pdatalen)
3012{
3013 char *end_of_smb;
3014 __u32 data_count, data_offset, parm_count, parm_offset;
3015 struct smb_com_ntransact_rsp *pSMBr;
3016
3017 *pdatalen = 0;
3018 *pparmlen = 0;
3019
3020 if (buf == NULL)
3021 return -EINVAL;
3022
3023 pSMBr = (struct smb_com_ntransact_rsp *)buf;
3024
3025 /* ByteCount was converted from little endian in SendReceive */
3026 end_of_smb = 2 /* sizeof byte count */ + pSMBr->ByteCount +
3027 (char *)&pSMBr->ByteCount;
3028
3029 data_offset = le32_to_cpu(pSMBr->DataOffset);
3030 data_count = le32_to_cpu(pSMBr->DataCount);
3031 parm_offset = le32_to_cpu(pSMBr->ParameterOffset);
3032 parm_count = le32_to_cpu(pSMBr->ParameterCount);
3033
3034 *ppparm = (char *)&pSMBr->hdr.Protocol + parm_offset;
3035 *ppdata = (char *)&pSMBr->hdr.Protocol + data_offset;
3036
3037 /* should we also check that parm and data areas do not overlap? */
3038 if (*ppparm > end_of_smb) {
3039 cFYI(1, "parms start after end of smb");
3040 return -EINVAL;
3041 } else if (parm_count + *ppparm > end_of_smb) {
3042 cFYI(1, "parm end after end of smb");
3043 return -EINVAL;
3044 } else if (*ppdata > end_of_smb) {
3045 cFYI(1, "data starts after end of smb");
3046 return -EINVAL;
3047 } else if (data_count + *ppdata > end_of_smb) {
3048 cFYI(1, "data %p + count %d (%p) past smb end %p start %p",
3049 *ppdata, data_count, (data_count + *ppdata),
3050 end_of_smb, pSMBr);
3051 return -EINVAL;
3052 } else if (parm_count + data_count > pSMBr->ByteCount) {
3053 cFYI(1, "parm count and data count larger than SMB");
3054 return -EINVAL;
3055 }
3056 *pdatalen = data_count;
3057 *pparmlen = parm_count;
3058 return 0;
3059}
3060
3060/* Get Security Descriptor (by handle) from remote server for a file or dir */ 3061/* Get Security Descriptor (by handle) from remote server for a file or dir */
3061int 3062int
3062CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid, 3063CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid,
@@ -3214,7 +3215,7 @@ setCifsAclRetry:
3214 return (rc); 3215 return (rc);
3215} 3216}
3216 3217
3217#endif /* CONFIG_CIFS_EXPERIMENTAL */ 3218#endif /* CONFIG_CIFS_ACL */
3218 3219
3219/* Legacy Query Path Information call for lookup to old servers such 3220/* Legacy Query Path Information call for lookup to old servers such
3220 as Win9x/WinME */ 3221 as Win9x/WinME */
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 251a17c03545..cc1a8604a790 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -105,6 +105,7 @@ struct smb_vol {
105 unsigned int wsize; 105 unsigned int wsize;
106 bool sockopt_tcp_nodelay:1; 106 bool sockopt_tcp_nodelay:1;
107 unsigned short int port; 107 unsigned short int port;
108 unsigned long actimeo; /* attribute cache timeout (jiffies) */
108 char *prepath; 109 char *prepath;
109 struct sockaddr_storage srcaddr; /* allow binding to a local IP */ 110 struct sockaddr_storage srcaddr; /* allow binding to a local IP */
110 struct nls_table *local_nls; 111 struct nls_table *local_nls;
@@ -806,23 +807,20 @@ cifs_parse_mount_options(char *options, const char *devname,
806 short int override_gid = -1; 807 short int override_gid = -1;
807 bool uid_specified = false; 808 bool uid_specified = false;
808 bool gid_specified = false; 809 bool gid_specified = false;
810 char *nodename = utsname()->nodename;
809 811
810 separator[0] = ','; 812 separator[0] = ',';
811 separator[1] = 0; 813 separator[1] = 0;
812 814
813 if (Local_System_Name[0] != 0) 815 /*
814 memcpy(vol->source_rfc1001_name, Local_System_Name, 15); 816 * does not have to be perfect mapping since field is
815 else { 817 * informational, only used for servers that do not support
816 char *nodename = utsname()->nodename; 818 * port 445 and it can be overridden at mount time
817 int n = strnlen(nodename, 15); 819 */
818 memset(vol->source_rfc1001_name, 0x20, 15); 820 memset(vol->source_rfc1001_name, 0x20, 15);
819 for (i = 0; i < n; i++) { 821 for (i = 0; i < strnlen(nodename, 15); i++)
820 /* does not have to be perfect mapping since field is 822 vol->source_rfc1001_name[i] = toupper(nodename[i]);
821 informational, only used for servers that do not support 823
822 port 445 and it can be overridden at mount time */
823 vol->source_rfc1001_name[i] = toupper(nodename[i]);
824 }
825 }
826 vol->source_rfc1001_name[15] = 0; 824 vol->source_rfc1001_name[15] = 0;
827 /* null target name indicates to use *SMBSERVR default called name 825 /* null target name indicates to use *SMBSERVR default called name
828 if we end up sending RFC1001 session initialize */ 826 if we end up sending RFC1001 session initialize */
@@ -840,6 +838,8 @@ cifs_parse_mount_options(char *options, const char *devname,
840 /* default to using server inode numbers where available */ 838 /* default to using server inode numbers where available */
841 vol->server_ino = 1; 839 vol->server_ino = 1;
842 840
841 vol->actimeo = CIFS_DEF_ACTIMEO;
842
843 if (!options) 843 if (!options)
844 return 1; 844 return 1;
845 845
@@ -1214,6 +1214,16 @@ cifs_parse_mount_options(char *options, const char *devname,
1214 printk(KERN_WARNING "CIFS: server net" 1214 printk(KERN_WARNING "CIFS: server net"
1215 "biosname longer than 15 truncated.\n"); 1215 "biosname longer than 15 truncated.\n");
1216 } 1216 }
1217 } else if (strnicmp(data, "actimeo", 7) == 0) {
1218 if (value && *value) {
1219 vol->actimeo = HZ * simple_strtoul(value,
1220 &value, 0);
1221 if (vol->actimeo > CIFS_MAX_ACTIMEO) {
1222 cERROR(1, "CIFS: attribute cache"
1223 "timeout too large");
1224 return 1;
1225 }
1226 }
1217 } else if (strnicmp(data, "credentials", 4) == 0) { 1227 } else if (strnicmp(data, "credentials", 4) == 0) {
1218 /* ignore */ 1228 /* ignore */
1219 } else if (strnicmp(data, "version", 3) == 0) { 1229 } else if (strnicmp(data, "version", 3) == 0) {
@@ -1352,6 +1362,11 @@ cifs_parse_mount_options(char *options, const char *devname,
1352 "supported. Instead set " 1362 "supported. Instead set "
1353 "/proc/fs/cifs/LookupCacheEnabled to 0\n"); 1363 "/proc/fs/cifs/LookupCacheEnabled to 0\n");
1354 } else if (strnicmp(data, "fsc", 3) == 0) { 1364 } else if (strnicmp(data, "fsc", 3) == 0) {
1365#ifndef CONFIG_CIFS_FSCACHE
1366 cERROR(1, "FS-Cache support needs CONFIG_CIFS_FSCACHE"
1367 "kernel config option set");
1368 return 1;
1369#endif
1355 vol->fsc = true; 1370 vol->fsc = true;
1356 } else if (strnicmp(data, "mfsymlinks", 10) == 0) { 1371 } else if (strnicmp(data, "mfsymlinks", 10) == 0) {
1357 vol->mfsymlinks = true; 1372 vol->mfsymlinks = true;
@@ -2566,6 +2581,8 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info,
2566 cFYI(1, "file mode: 0x%x dir mode: 0x%x", 2581 cFYI(1, "file mode: 0x%x dir mode: 0x%x",
2567 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode); 2582 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode);
2568 2583
2584 cifs_sb->actimeo = pvolume_info->actimeo;
2585
2569 if (pvolume_info->noperm) 2586 if (pvolume_info->noperm)
2570 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; 2587 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
2571 if (pvolume_info->setuids) 2588 if (pvolume_info->setuids)
@@ -2816,13 +2833,13 @@ remote_path_check:
2816 /* check if a whole path (including prepath) is not remote */ 2833 /* check if a whole path (including prepath) is not remote */
2817 if (!rc && cifs_sb->prepathlen && tcon) { 2834 if (!rc && cifs_sb->prepathlen && tcon) {
2818 /* build_path_to_root works only when we have a valid tcon */ 2835 /* build_path_to_root works only when we have a valid tcon */
2819 full_path = cifs_build_path_to_root(cifs_sb); 2836 full_path = cifs_build_path_to_root(cifs_sb, tcon);
2820 if (full_path == NULL) { 2837 if (full_path == NULL) {
2821 rc = -ENOMEM; 2838 rc = -ENOMEM;
2822 goto mount_fail_check; 2839 goto mount_fail_check;
2823 } 2840 }
2824 rc = is_path_accessible(xid, tcon, cifs_sb, full_path); 2841 rc = is_path_accessible(xid, tcon, cifs_sb, full_path);
2825 if (rc != -EREMOTE) { 2842 if (rc != 0 && rc != -EREMOTE) {
2826 kfree(full_path); 2843 kfree(full_path);
2827 goto mount_fail_check; 2844 goto mount_fail_check;
2828 } 2845 }
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c
index 0eb87026cad3..548f06230a6d 100644
--- a/fs/cifs/dns_resolve.c
+++ b/fs/cifs/dns_resolve.c
@@ -66,7 +66,7 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
66 /* Search for server name delimiter */ 66 /* Search for server name delimiter */
67 sep = memchr(hostname, '\\', len); 67 sep = memchr(hostname, '\\', len);
68 if (sep) 68 if (sep)
69 len = sep - unc; 69 len = sep - hostname;
70 else 70 else
71 cFYI(1, "%s: probably server name is whole unc: %s", 71 cFYI(1, "%s: probably server name is whole unc: %s",
72 __func__, unc); 72 __func__, unc);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 06c3e83fa387..5a28660ca2b5 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1108,7 +1108,6 @@ static ssize_t cifs_write(struct cifsFileInfo *open_file,
1108 return total_written; 1108 return total_written;
1109} 1109}
1110 1110
1111#ifdef CONFIG_CIFS_EXPERIMENTAL
1112struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, 1111struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
1113 bool fsuid_only) 1112 bool fsuid_only)
1114{ 1113{
@@ -1142,7 +1141,6 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
1142 spin_unlock(&cifs_file_list_lock); 1141 spin_unlock(&cifs_file_list_lock);
1143 return NULL; 1142 return NULL;
1144} 1143}
1145#endif
1146 1144
1147struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode, 1145struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode,
1148 bool fsuid_only) 1146 bool fsuid_only)
@@ -2271,8 +2269,10 @@ void cifs_oplock_break_get(struct cifsFileInfo *cfile)
2271 2269
2272void cifs_oplock_break_put(struct cifsFileInfo *cfile) 2270void cifs_oplock_break_put(struct cifsFileInfo *cfile)
2273{ 2271{
2272 struct super_block *sb = cfile->dentry->d_sb;
2273
2274 cifsFileInfo_put(cfile); 2274 cifsFileInfo_put(cfile);
2275 cifs_sb_deactive(cfile->dentry->d_sb); 2275 cifs_sb_deactive(sb);
2276} 2276}
2277 2277
2278const struct address_space_operations cifs_addr_ops = { 2278const struct address_space_operations cifs_addr_ops = {
diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c
index a2ad94efcfe6..297a43d0ff7f 100644
--- a/fs/cifs/fscache.c
+++ b/fs/cifs/fscache.c
@@ -2,7 +2,7 @@
2 * fs/cifs/fscache.c - CIFS filesystem cache interface 2 * fs/cifs/fscache.c - CIFS filesystem cache interface
3 * 3 *
4 * Copyright (c) 2010 Novell, Inc. 4 * Copyright (c) 2010 Novell, Inc.
5 * Author(s): Suresh Jayaraman (sjayaraman@suse.de> 5 * Author(s): Suresh Jayaraman <sjayaraman@suse.de>
6 * 6 *
7 * This library is free software; you can redistribute it and/or modify 7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published 8 * it under the terms of the GNU Lesser General Public License as published
@@ -67,10 +67,12 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode)
67 if (cifsi->fscache) 67 if (cifsi->fscache)
68 return; 68 return;
69 69
70 cifsi->fscache = fscache_acquire_cookie(tcon->fscache, 70 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE) {
71 cifsi->fscache = fscache_acquire_cookie(tcon->fscache,
71 &cifs_fscache_inode_object_def, cifsi); 72 &cifs_fscache_inode_object_def, cifsi);
72 cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)", tcon->fscache, 73 cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)", tcon->fscache,
73 cifsi->fscache); 74 cifsi->fscache);
75 }
74} 76}
75 77
76void cifs_fscache_release_inode_cookie(struct inode *inode) 78void cifs_fscache_release_inode_cookie(struct inode *inode)
@@ -101,10 +103,8 @@ void cifs_fscache_set_inode_cookie(struct inode *inode, struct file *filp)
101{ 103{
102 if ((filp->f_flags & O_ACCMODE) != O_RDONLY) 104 if ((filp->f_flags & O_ACCMODE) != O_RDONLY)
103 cifs_fscache_disable_inode_cookie(inode); 105 cifs_fscache_disable_inode_cookie(inode);
104 else { 106 else
105 cifs_fscache_enable_inode_cookie(inode); 107 cifs_fscache_enable_inode_cookie(inode);
106 cFYI(1, "CIFS: fscache inode cookie set");
107 }
108} 108}
109 109
110void cifs_fscache_reset_inode_cookie(struct inode *inode) 110void cifs_fscache_reset_inode_cookie(struct inode *inode)
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index ef3a55bf86b6..589f3e3f6e00 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -686,13 +686,18 @@ int cifs_get_inode_info(struct inode **pinode,
686 cFYI(1, "cifs_sfu_type failed: %d", tmprc); 686 cFYI(1, "cifs_sfu_type failed: %d", tmprc);
687 } 687 }
688 688
689#ifdef CONFIG_CIFS_EXPERIMENTAL 689#ifdef CONFIG_CIFS_ACL
690 /* fill in 0777 bits from ACL */ 690 /* fill in 0777 bits from ACL */
691 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { 691 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
692 cFYI(1, "Getting mode bits from ACL"); 692 rc = cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path,
693 cifs_acl_to_fattr(cifs_sb, &fattr, *pinode, full_path, pfid); 693 pfid);
694 if (rc) {
695 cFYI(1, "%s: Getting ACL failed with error: %d",
696 __func__, rc);
697 goto cgii_exit;
698 }
694 } 699 }
695#endif 700#endif /* CONFIG_CIFS_ACL */
696 701
697 /* fill in remaining high mode bits e.g. SUID, VTX */ 702 /* fill in remaining high mode bits e.g. SUID, VTX */
698 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) 703 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
@@ -723,12 +728,12 @@ static const struct inode_operations cifs_ipc_inode_ops = {
723 .lookup = cifs_lookup, 728 .lookup = cifs_lookup,
724}; 729};
725 730
726char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb) 731char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb,
732 struct cifsTconInfo *tcon)
727{ 733{
728 int pplen = cifs_sb->prepathlen; 734 int pplen = cifs_sb->prepathlen;
729 int dfsplen; 735 int dfsplen;
730 char *full_path = NULL; 736 char *full_path = NULL;
731 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
732 737
733 /* if no prefix path, simply set path to the root of share to "" */ 738 /* if no prefix path, simply set path to the root of share to "" */
734 if (pplen == 0) { 739 if (pplen == 0) {
@@ -870,7 +875,7 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
870 char *full_path; 875 char *full_path;
871 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); 876 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
872 877
873 full_path = cifs_build_path_to_root(cifs_sb); 878 full_path = cifs_build_path_to_root(cifs_sb, tcon);
874 if (full_path == NULL) 879 if (full_path == NULL)
875 return ERR_PTR(-ENOMEM); 880 return ERR_PTR(-ENOMEM);
876 881
@@ -881,8 +886,10 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
881 rc = cifs_get_inode_info(&inode, full_path, NULL, sb, 886 rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
882 xid, NULL); 887 xid, NULL);
883 888
884 if (!inode) 889 if (!inode) {
885 return ERR_PTR(rc); 890 inode = ERR_PTR(rc);
891 goto out;
892 }
886 893
887#ifdef CONFIG_CIFS_FSCACHE 894#ifdef CONFIG_CIFS_FSCACHE
888 /* populate tcon->resource_id */ 895 /* populate tcon->resource_id */
@@ -898,13 +905,11 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)
898 inode->i_uid = cifs_sb->mnt_uid; 905 inode->i_uid = cifs_sb->mnt_uid;
899 inode->i_gid = cifs_sb->mnt_gid; 906 inode->i_gid = cifs_sb->mnt_gid;
900 } else if (rc) { 907 } else if (rc) {
901 kfree(full_path);
902 _FreeXid(xid);
903 iget_failed(inode); 908 iget_failed(inode);
904 return ERR_PTR(rc); 909 inode = ERR_PTR(rc);
905 } 910 }
906 911
907 912out:
908 kfree(full_path); 913 kfree(full_path);
909 /* can not call macro FreeXid here since in a void func 914 /* can not call macro FreeXid here since in a void func
910 * TODO: This is no longer true 915 * TODO: This is no longer true
@@ -1648,6 +1653,7 @@ static bool
1648cifs_inode_needs_reval(struct inode *inode) 1653cifs_inode_needs_reval(struct inode *inode)
1649{ 1654{
1650 struct cifsInodeInfo *cifs_i = CIFS_I(inode); 1655 struct cifsInodeInfo *cifs_i = CIFS_I(inode);
1656 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1651 1657
1652 if (cifs_i->clientCanCacheRead) 1658 if (cifs_i->clientCanCacheRead)
1653 return false; 1659 return false;
@@ -1658,19 +1664,21 @@ cifs_inode_needs_reval(struct inode *inode)
1658 if (cifs_i->time == 0) 1664 if (cifs_i->time == 0)
1659 return true; 1665 return true;
1660 1666
1661 /* FIXME: the actimeo should be tunable */ 1667 if (!time_in_range(jiffies, cifs_i->time,
1662 if (time_after_eq(jiffies, cifs_i->time + HZ)) 1668 cifs_i->time + cifs_sb->actimeo))
1663 return true; 1669 return true;
1664 1670
1665 /* hardlinked files w/ noserverino get "special" treatment */ 1671 /* hardlinked files w/ noserverino get "special" treatment */
1666 if (!(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) && 1672 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&
1667 S_ISREG(inode->i_mode) && inode->i_nlink != 1) 1673 S_ISREG(inode->i_mode) && inode->i_nlink != 1)
1668 return true; 1674 return true;
1669 1675
1670 return false; 1676 return false;
1671} 1677}
1672 1678
1673/* check invalid_mapping flag and zap the cache if it's set */ 1679/*
1680 * Zap the cache. Called when invalid_mapping flag is set.
1681 */
1674static void 1682static void
1675cifs_invalidate_mapping(struct inode *inode) 1683cifs_invalidate_mapping(struct inode *inode)
1676{ 1684{
@@ -2114,11 +2122,16 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
2114 2122
2115 if (attrs->ia_valid & ATTR_MODE) { 2123 if (attrs->ia_valid & ATTR_MODE) {
2116 rc = 0; 2124 rc = 0;
2117#ifdef CONFIG_CIFS_EXPERIMENTAL 2125#ifdef CONFIG_CIFS_ACL
2118 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) 2126 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
2119 rc = mode_to_acl(inode, full_path, mode); 2127 rc = mode_to_cifs_acl(inode, full_path, mode);
2120 else 2128 if (rc) {
2121#endif 2129 cFYI(1, "%s: Setting ACL failed with error: %d",
2130 __func__, rc);
2131 goto cifs_setattr_exit;
2132 }
2133 } else
2134#endif /* CONFIG_CIFS_ACL */
2122 if (((mode & S_IWUGO) == 0) && 2135 if (((mode & S_IWUGO) == 0) &&
2123 (cifsInode->cifsAttrs & ATTR_READONLY) == 0) { 2136 (cifsInode->cifsAttrs & ATTR_READONLY) == 0) {
2124 2137
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index ef7bb7b50f58..a73eb9f4bdaf 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -226,26 +226,29 @@ static int initiate_cifs_search(const int xid, struct file *file)
226 char *full_path = NULL; 226 char *full_path = NULL;
227 struct cifsFileInfo *cifsFile; 227 struct cifsFileInfo *cifsFile;
228 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 228 struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
229 struct tcon_link *tlink; 229 struct tcon_link *tlink = NULL;
230 struct cifsTconInfo *pTcon; 230 struct cifsTconInfo *pTcon;
231 231
232 tlink = cifs_sb_tlink(cifs_sb);
233 if (IS_ERR(tlink))
234 return PTR_ERR(tlink);
235 pTcon = tlink_tcon(tlink);
236
237 if (file->private_data == NULL)
238 file->private_data =
239 kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
240 if (file->private_data == NULL) { 232 if (file->private_data == NULL) {
241 rc = -ENOMEM; 233 tlink = cifs_sb_tlink(cifs_sb);
242 goto error_exit; 234 if (IS_ERR(tlink))
235 return PTR_ERR(tlink);
236
237 cifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
238 if (cifsFile == NULL) {
239 rc = -ENOMEM;
240 goto error_exit;
241 }
242 file->private_data = cifsFile;
243 cifsFile->tlink = cifs_get_tlink(tlink);
244 pTcon = tlink_tcon(tlink);
245 } else {
246 cifsFile = file->private_data;
247 pTcon = tlink_tcon(cifsFile->tlink);
243 } 248 }
244 249
245 cifsFile = file->private_data;
246 cifsFile->invalidHandle = true; 250 cifsFile->invalidHandle = true;
247 cifsFile->srch_inf.endOfSearch = false; 251 cifsFile->srch_inf.endOfSearch = false;
248 cifsFile->tlink = cifs_get_tlink(tlink);
249 252
250 full_path = build_path_from_dentry(file->f_path.dentry); 253 full_path = build_path_from_dentry(file->f_path.dentry);
251 if (full_path == NULL) { 254 if (full_path == NULL) {
@@ -756,18 +759,6 @@ static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
756 rc = filldir(direntry, qstring.name, qstring.len, file->f_pos, 759 rc = filldir(direntry, qstring.name, qstring.len, file->f_pos,
757 ino, fattr.cf_dtype); 760 ino, fattr.cf_dtype);
758 761
759 /*
760 * we can not return filldir errors to the caller since they are
761 * "normal" when the stat blocksize is too small - we return remapped
762 * error instead
763 *
764 * FIXME: This looks bogus. filldir returns -EOVERFLOW in the above
765 * case already. Why should we be clobbering other errors from it?
766 */
767 if (rc) {
768 cFYI(1, "filldir rc = %d", rc);
769 rc = -EOVERFLOW;
770 }
771 dput(tmp_dentry); 762 dput(tmp_dentry);
772 return rc; 763 return rc;
773} 764}
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index a264b744bb41..eae2a1491608 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -30,10 +30,11 @@
30 30
31#define MAX_EA_VALUE_SIZE 65535 31#define MAX_EA_VALUE_SIZE 65535
32#define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib" 32#define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib"
33#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
33#define CIFS_XATTR_USER_PREFIX "user." 34#define CIFS_XATTR_USER_PREFIX "user."
34#define CIFS_XATTR_SYSTEM_PREFIX "system." 35#define CIFS_XATTR_SYSTEM_PREFIX "system."
35#define CIFS_XATTR_OS2_PREFIX "os2." 36#define CIFS_XATTR_OS2_PREFIX "os2."
36#define CIFS_XATTR_SECURITY_PREFIX ".security" 37#define CIFS_XATTR_SECURITY_PREFIX "security."
37#define CIFS_XATTR_TRUSTED_PREFIX "trusted." 38#define CIFS_XATTR_TRUSTED_PREFIX "trusted."
38#define XATTR_TRUSTED_PREFIX_LEN 8 39#define XATTR_TRUSTED_PREFIX_LEN 8
39#define XATTR_SECURITY_PREFIX_LEN 9 40#define XATTR_SECURITY_PREFIX_LEN 9
@@ -277,29 +278,8 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
277 cifs_sb->local_nls, 278 cifs_sb->local_nls,
278 cifs_sb->mnt_cifs_flags & 279 cifs_sb->mnt_cifs_flags &
279 CIFS_MOUNT_MAP_SPECIAL_CHR); 280 CIFS_MOUNT_MAP_SPECIAL_CHR);
280#ifdef CONFIG_CIFS_EXPERIMENTAL
281 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
282 __u16 fid;
283 int oplock = 0;
284 struct cifs_ntsd *pacl = NULL;
285 __u32 buflen = 0;
286 if (experimEnabled)
287 rc = CIFSSMBOpen(xid, pTcon, full_path,
288 FILE_OPEN, GENERIC_READ, 0, &fid,
289 &oplock, NULL, cifs_sb->local_nls,
290 cifs_sb->mnt_cifs_flags &
291 CIFS_MOUNT_MAP_SPECIAL_CHR);
292 /* else rc is EOPNOTSUPP from above */
293
294 if (rc == 0) {
295 rc = CIFSSMBGetCIFSACL(xid, pTcon, fid, &pacl,
296 &buflen);
297 CIFSSMBClose(xid, pTcon, fid);
298 }
299 }
300#endif /* EXPERIMENTAL */
301#else 281#else
302 cFYI(1, "query POSIX ACL not supported yet"); 282 cFYI(1, "Query POSIX ACL not supported yet");
303#endif /* CONFIG_CIFS_POSIX */ 283#endif /* CONFIG_CIFS_POSIX */
304 } else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT, 284 } else if (strncmp(ea_name, POSIX_ACL_XATTR_DEFAULT,
305 strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) { 285 strlen(POSIX_ACL_XATTR_DEFAULT)) == 0) {
@@ -311,8 +291,33 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
311 cifs_sb->mnt_cifs_flags & 291 cifs_sb->mnt_cifs_flags &
312 CIFS_MOUNT_MAP_SPECIAL_CHR); 292 CIFS_MOUNT_MAP_SPECIAL_CHR);
313#else 293#else
314 cFYI(1, "query POSIX default ACL not supported yet"); 294 cFYI(1, "Query POSIX default ACL not supported yet");
315#endif 295#endif /* CONFIG_CIFS_POSIX */
296 } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
297 strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
298#ifdef CONFIG_CIFS_ACL
299 u32 acllen;
300 struct cifs_ntsd *pacl;
301
302 pacl = get_cifs_acl(cifs_sb, direntry->d_inode,
303 full_path, &acllen);
304 if (IS_ERR(pacl)) {
305 rc = PTR_ERR(pacl);
306 cERROR(1, "%s: error %zd getting sec desc",
307 __func__, rc);
308 } else {
309 if (ea_value) {
310 if (acllen > buf_size)
311 acllen = -ERANGE;
312 else
313 memcpy(ea_value, pacl, acllen);
314 }
315 rc = acllen;
316 kfree(pacl);
317 }
318#else
319 cFYI(1, "Query CIFS ACL not supported yet");
320#endif /* CONFIG_CIFS_ACL */
316 } else if (strncmp(ea_name, 321 } else if (strncmp(ea_name,
317 CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) { 322 CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) {
318 cFYI(1, "Trusted xattr namespace not supported yet"); 323 cFYI(1, "Trusted xattr namespace not supported yet");
diff --git a/fs/compat.c b/fs/compat.c
index c580c322fa6b..eb1740ac8c0a 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1350,6 +1350,10 @@ static int compat_count(compat_uptr_t __user *argv, int max)
1350 argv++; 1350 argv++;
1351 if (i++ >= max) 1351 if (i++ >= max)
1352 return -E2BIG; 1352 return -E2BIG;
1353
1354 if (fatal_signal_pending(current))
1355 return -ERESTARTNOHAND;
1356 cond_resched();
1353 } 1357 }
1354 } 1358 }
1355 return i; 1359 return i;
@@ -1391,6 +1395,12 @@ static int compat_copy_strings(int argc, compat_uptr_t __user *argv,
1391 while (len > 0) { 1395 while (len > 0) {
1392 int offset, bytes_to_copy; 1396 int offset, bytes_to_copy;
1393 1397
1398 if (fatal_signal_pending(current)) {
1399 ret = -ERESTARTNOHAND;
1400 goto out;
1401 }
1402 cond_resched();
1403
1394 offset = pos % PAGE_SIZE; 1404 offset = pos % PAGE_SIZE;
1395 if (offset == 0) 1405 if (offset == 0)
1396 offset = PAGE_SIZE; 1406 offset = PAGE_SIZE;
@@ -1407,18 +1417,8 @@ static int compat_copy_strings(int argc, compat_uptr_t __user *argv,
1407 if (!kmapped_page || kpos != (pos & PAGE_MASK)) { 1417 if (!kmapped_page || kpos != (pos & PAGE_MASK)) {
1408 struct page *page; 1418 struct page *page;
1409 1419
1410#ifdef CONFIG_STACK_GROWSUP 1420 page = get_arg_page(bprm, pos, 1);
1411 ret = expand_stack_downwards(bprm->vma, pos); 1421 if (!page) {
1412 if (ret < 0) {
1413 /* We've exceed the stack rlimit. */
1414 ret = -E2BIG;
1415 goto out;
1416 }
1417#endif
1418 ret = get_user_pages(current, bprm->mm, pos,
1419 1, 1, 1, &page, NULL);
1420 if (ret <= 0) {
1421 /* We've exceed the stack rlimit. */
1422 ret = -E2BIG; 1422 ret = -E2BIG;
1423 goto out; 1423 goto out;
1424 } 1424 }
@@ -1539,8 +1539,10 @@ int compat_do_execve(char * filename,
1539 return retval; 1539 return retval;
1540 1540
1541out: 1541out:
1542 if (bprm->mm) 1542 if (bprm->mm) {
1543 acct_arg_size(bprm, 0);
1543 mmput(bprm->mm); 1544 mmput(bprm->mm);
1545 }
1544 1546
1545out_file: 1547out_file:
1546 if (bprm->file) { 1548 if (bprm->file) {
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 410ed188faa1..a60579b007b0 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -19,7 +19,6 @@
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>
23#include <linux/ioctl.h> 22#include <linux/ioctl.h>
24#include <linux/if.h> 23#include <linux/if.h>
25#include <linux/if_bridge.h> 24#include <linux/if_bridge.h>
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c
index 253732382d37..2720178b7718 100644
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -28,7 +28,6 @@
28#include <linux/key.h> 28#include <linux/key.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/seq_file.h> 30#include <linux/seq_file.h>
31#include <linux/smp_lock.h>
32#include <linux/file.h> 31#include <linux/file.h>
33#include <linux/crypto.h> 32#include <linux/crypto.h>
34#include "ecryptfs_kernel.h" 33#include "ecryptfs_kernel.h"
diff --git a/fs/exec.c b/fs/exec.c
index 99d33a1371e9..c62efcb959c7 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -164,7 +164,26 @@ out:
164 164
165#ifdef CONFIG_MMU 165#ifdef CONFIG_MMU
166 166
167static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, 167void acct_arg_size(struct linux_binprm *bprm, unsigned long pages)
168{
169 struct mm_struct *mm = current->mm;
170 long diff = (long)(pages - bprm->vma_pages);
171
172 if (!mm || !diff)
173 return;
174
175 bprm->vma_pages = pages;
176
177#ifdef SPLIT_RSS_COUNTING
178 add_mm_counter(mm, MM_ANONPAGES, diff);
179#else
180 spin_lock(&mm->page_table_lock);
181 add_mm_counter(mm, MM_ANONPAGES, diff);
182 spin_unlock(&mm->page_table_lock);
183#endif
184}
185
186struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
168 int write) 187 int write)
169{ 188{
170 struct page *page; 189 struct page *page;
@@ -186,6 +205,8 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
186 unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start; 205 unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start;
187 struct rlimit *rlim; 206 struct rlimit *rlim;
188 207
208 acct_arg_size(bprm, size / PAGE_SIZE);
209
189 /* 210 /*
190 * We've historically supported up to 32 pages (ARG_MAX) 211 * We've historically supported up to 32 pages (ARG_MAX)
191 * of argument strings even with small stacks 212 * of argument strings even with small stacks
@@ -254,6 +275,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
254 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP; 275 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
255 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); 276 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
256 INIT_LIST_HEAD(&vma->anon_vma_chain); 277 INIT_LIST_HEAD(&vma->anon_vma_chain);
278
279 err = security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1);
280 if (err)
281 goto err;
282
257 err = insert_vm_struct(mm, vma); 283 err = insert_vm_struct(mm, vma);
258 if (err) 284 if (err)
259 goto err; 285 goto err;
@@ -276,7 +302,11 @@ static bool valid_arg_len(struct linux_binprm *bprm, long len)
276 302
277#else 303#else
278 304
279static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, 305void acct_arg_size(struct linux_binprm *bprm, unsigned long pages)
306{
307}
308
309struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
280 int write) 310 int write)
281{ 311{
282 struct page *page; 312 struct page *page;
@@ -1003,6 +1033,7 @@ int flush_old_exec(struct linux_binprm * bprm)
1003 /* 1033 /*
1004 * Release all of the old mmap stuff 1034 * Release all of the old mmap stuff
1005 */ 1035 */
1036 acct_arg_size(bprm, 0);
1006 retval = exec_mmap(bprm->mm); 1037 retval = exec_mmap(bprm->mm);
1007 if (retval) 1038 if (retval)
1008 goto out; 1039 goto out;
@@ -1426,8 +1457,10 @@ int do_execve(const char * filename,
1426 return retval; 1457 return retval;
1427 1458
1428out: 1459out:
1429 if (bprm->mm) 1460 if (bprm->mm) {
1430 mmput (bprm->mm); 1461 acct_arg_size(bprm, 0);
1462 mmput(bprm->mm);
1463 }
1431 1464
1432out_file: 1465out_file:
1433 if (bprm->file) { 1466 if (bprm->file) {
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 2fedaf8b5012..acf8695fa8f0 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -27,7 +27,6 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/blkdev.h> 28#include <linux/blkdev.h>
29#include <linux/parser.h> 29#include <linux/parser.h>
30#include <linux/smp_lock.h>
31#include <linux/buffer_head.h> 30#include <linux/buffer_head.h>
32#include <linux/exportfs.h> 31#include <linux/exportfs.h>
33#include <linux/vfs.h> 32#include <linux/vfs.h>
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 6a5edea2d70b..94ce3d7a1c4b 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -910,6 +910,7 @@ struct ext4_inode_info {
910#define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */ 910#define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
911#define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */ 911#define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
912#define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */ 912#define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
913#define EXT4_MOUNT_MBLK_IO_SUBMIT 0x4000000 /* multi-block io submits */
913#define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */ 914#define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
914#define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */ 915#define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
915#define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */ 916#define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bdbe69902207..e659597b690b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2125,9 +2125,12 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd,
2125 */ 2125 */
2126 if (unlikely(journal_data && PageChecked(page))) 2126 if (unlikely(journal_data && PageChecked(page)))
2127 err = __ext4_journalled_writepage(page, len); 2127 err = __ext4_journalled_writepage(page, len);
2128 else 2128 else if (test_opt(inode->i_sb, MBLK_IO_SUBMIT))
2129 err = ext4_bio_write_page(&io_submit, page, 2129 err = ext4_bio_write_page(&io_submit, page,
2130 len, mpd->wbc); 2130 len, mpd->wbc);
2131 else
2132 err = block_write_full_page(page,
2133 noalloc_get_block_write, mpd->wbc);
2131 2134
2132 if (!err) 2135 if (!err)
2133 mpd->pages_written++; 2136 mpd->pages_written++;
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index bf5ae883b1bd..eb3bc2fe647e 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -331,6 +331,30 @@ mext_out:
331 return err; 331 return err;
332 } 332 }
333 333
334 case FITRIM:
335 {
336 struct super_block *sb = inode->i_sb;
337 struct fstrim_range range;
338 int ret = 0;
339
340 if (!capable(CAP_SYS_ADMIN))
341 return -EPERM;
342
343 if (copy_from_user(&range, (struct fstrim_range *)arg,
344 sizeof(range)))
345 return -EFAULT;
346
347 ret = ext4_trim_fs(sb, &range);
348 if (ret < 0)
349 return ret;
350
351 if (copy_to_user((struct fstrim_range *)arg, &range,
352 sizeof(range)))
353 return -EFAULT;
354
355 return 0;
356 }
357
334 default: 358 default:
335 return -ENOTTY; 359 return -ENOTTY;
336 } 360 }
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 92203b8a099f..dc40e75cba88 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -872,7 +872,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
872 if (namelen > EXT4_NAME_LEN) 872 if (namelen > EXT4_NAME_LEN)
873 return NULL; 873 return NULL;
874 if ((namelen <= 2) && (name[0] == '.') && 874 if ((namelen <= 2) && (name[0] == '.') &&
875 (name[1] == '.' || name[1] == '0')) { 875 (name[1] == '.' || name[1] == '\0')) {
876 /* 876 /*
877 * "." or ".." will only be in the first block 877 * "." or ".." will only be in the first block
878 * NFS may look up ".."; "." should be handled by the VFS 878 * NFS may look up ".."; "." should be handled by the VFS
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 7f5451cd1d38..beacce11ac50 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -237,8 +237,6 @@ static void ext4_end_bio(struct bio *bio, int error)
237 } while (bh != head); 237 } while (bh != head);
238 } 238 }
239 239
240 put_io_page(io_end->pages[i]);
241
242 /* 240 /*
243 * If this is a partial write which happened to make 241 * If this is a partial write which happened to make
244 * all buffers uptodate then we can optimize away a 242 * all buffers uptodate then we can optimize away a
@@ -248,6 +246,8 @@ static void ext4_end_bio(struct bio *bio, int error)
248 */ 246 */
249 if (!partial_write) 247 if (!partial_write)
250 SetPageUptodate(page); 248 SetPageUptodate(page);
249
250 put_io_page(io_end->pages[i]);
251 } 251 }
252 io_end->num_io_pages = 0; 252 io_end->num_io_pages = 0;
253 inode = io_end->inode; 253 inode = io_end->inode;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 61182fe6254e..fb15c9c0be74 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1026,6 +1026,8 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
1026 !(def_mount_opts & EXT4_DEFM_NODELALLOC)) 1026 !(def_mount_opts & EXT4_DEFM_NODELALLOC))
1027 seq_puts(seq, ",nodelalloc"); 1027 seq_puts(seq, ",nodelalloc");
1028 1028
1029 if (test_opt(sb, MBLK_IO_SUBMIT))
1030 seq_puts(seq, ",mblk_io_submit");
1029 if (sbi->s_stripe) 1031 if (sbi->s_stripe)
1030 seq_printf(seq, ",stripe=%lu", sbi->s_stripe); 1032 seq_printf(seq, ",stripe=%lu", sbi->s_stripe);
1031 /* 1033 /*
@@ -1197,7 +1199,6 @@ static const struct super_operations ext4_sops = {
1197 .quota_write = ext4_quota_write, 1199 .quota_write = ext4_quota_write,
1198#endif 1200#endif
1199 .bdev_try_to_free_page = bdev_try_to_free_page, 1201 .bdev_try_to_free_page = bdev_try_to_free_page,
1200 .trim_fs = ext4_trim_fs
1201}; 1202};
1202 1203
1203static const struct super_operations ext4_nojournal_sops = { 1204static const struct super_operations ext4_nojournal_sops = {
@@ -1240,8 +1241,8 @@ enum {
1240 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, 1241 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
1241 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, 1242 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
1242 Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version, 1243 Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
1243 Opt_stripe, Opt_delalloc, Opt_nodelalloc, 1244 Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_mblk_io_submit,
1244 Opt_block_validity, Opt_noblock_validity, 1245 Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity,
1245 Opt_inode_readahead_blks, Opt_journal_ioprio, 1246 Opt_inode_readahead_blks, Opt_journal_ioprio,
1246 Opt_dioread_nolock, Opt_dioread_lock, 1247 Opt_dioread_nolock, Opt_dioread_lock,
1247 Opt_discard, Opt_nodiscard, 1248 Opt_discard, Opt_nodiscard,
@@ -1305,6 +1306,8 @@ static const match_table_t tokens = {
1305 {Opt_resize, "resize"}, 1306 {Opt_resize, "resize"},
1306 {Opt_delalloc, "delalloc"}, 1307 {Opt_delalloc, "delalloc"},
1307 {Opt_nodelalloc, "nodelalloc"}, 1308 {Opt_nodelalloc, "nodelalloc"},
1309 {Opt_mblk_io_submit, "mblk_io_submit"},
1310 {Opt_nomblk_io_submit, "nomblk_io_submit"},
1308 {Opt_block_validity, "block_validity"}, 1311 {Opt_block_validity, "block_validity"},
1309 {Opt_noblock_validity, "noblock_validity"}, 1312 {Opt_noblock_validity, "noblock_validity"},
1310 {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, 1313 {Opt_inode_readahead_blks, "inode_readahead_blks=%u"},
@@ -1726,6 +1729,12 @@ set_qf_format:
1726 case Opt_nodelalloc: 1729 case Opt_nodelalloc:
1727 clear_opt(sbi->s_mount_opt, DELALLOC); 1730 clear_opt(sbi->s_mount_opt, DELALLOC);
1728 break; 1731 break;
1732 case Opt_mblk_io_submit:
1733 set_opt(sbi->s_mount_opt, MBLK_IO_SUBMIT);
1734 break;
1735 case Opt_nomblk_io_submit:
1736 clear_opt(sbi->s_mount_opt, MBLK_IO_SUBMIT);
1737 break;
1729 case Opt_stripe: 1738 case Opt_stripe:
1730 if (match_int(&args[0], &option)) 1739 if (match_int(&args[0], &option))
1731 return 0; 1740 return 0;
@@ -2799,9 +2808,6 @@ static void ext4_clear_request_list(void)
2799 struct ext4_li_request *elr; 2808 struct ext4_li_request *elr;
2800 2809
2801 mutex_lock(&ext4_li_info->li_list_mtx); 2810 mutex_lock(&ext4_li_info->li_list_mtx);
2802 if (list_empty(&ext4_li_info->li_request_list))
2803 return;
2804
2805 list_for_each_safe(pos, n, &ext4_li_info->li_request_list) { 2811 list_for_each_safe(pos, n, &ext4_li_info->li_request_list) {
2806 elr = list_entry(pos, struct ext4_li_request, 2812 elr = list_entry(pos, struct ext4_li_request,
2807 lr_request); 2813 lr_request);
@@ -3268,13 +3274,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3268 * Test whether we have more sectors than will fit in sector_t, 3274 * Test whether we have more sectors than will fit in sector_t,
3269 * and whether the max offset is addressable by the page cache. 3275 * and whether the max offset is addressable by the page cache.
3270 */ 3276 */
3271 ret = generic_check_addressable(sb->s_blocksize_bits, 3277 err = generic_check_addressable(sb->s_blocksize_bits,
3272 ext4_blocks_count(es)); 3278 ext4_blocks_count(es));
3273 if (ret) { 3279 if (err) {
3274 ext4_msg(sb, KERN_ERR, "filesystem" 3280 ext4_msg(sb, KERN_ERR, "filesystem"
3275 " too large to mount safely on this system"); 3281 " too large to mount safely on this system");
3276 if (sizeof(sector_t) < 8) 3282 if (sizeof(sector_t) < 8)
3277 ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); 3283 ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled");
3284 ret = err;
3278 goto failed_mount; 3285 goto failed_mount;
3279 } 3286 }
3280 3287
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index c8224587123f..8b984a2cebbd 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/compat.h>
16 17
17static const struct file_operations fuse_direct_io_file_operations; 18static const struct file_operations fuse_direct_io_file_operations;
18 19
@@ -134,6 +135,7 @@ EXPORT_SYMBOL_GPL(fuse_do_open);
134void fuse_finish_open(struct inode *inode, struct file *file) 135void fuse_finish_open(struct inode *inode, struct file *file)
135{ 136{
136 struct fuse_file *ff = file->private_data; 137 struct fuse_file *ff = file->private_data;
138 struct fuse_conn *fc = get_fuse_conn(inode);
137 139
138 if (ff->open_flags & FOPEN_DIRECT_IO) 140 if (ff->open_flags & FOPEN_DIRECT_IO)
139 file->f_op = &fuse_direct_io_file_operations; 141 file->f_op = &fuse_direct_io_file_operations;
@@ -141,6 +143,15 @@ void fuse_finish_open(struct inode *inode, struct file *file)
141 invalidate_inode_pages2(inode->i_mapping); 143 invalidate_inode_pages2(inode->i_mapping);
142 if (ff->open_flags & FOPEN_NONSEEKABLE) 144 if (ff->open_flags & FOPEN_NONSEEKABLE)
143 nonseekable_open(inode, file); 145 nonseekable_open(inode, file);
146 if (fc->atomic_o_trunc && (file->f_flags & O_TRUNC)) {
147 struct fuse_inode *fi = get_fuse_inode(inode);
148
149 spin_lock(&fc->lock);
150 fi->attr_version = ++fc->attr_version;
151 i_size_write(inode, 0);
152 spin_unlock(&fc->lock);
153 fuse_invalidate_attr(inode);
154 }
144} 155}
145 156
146int fuse_open_common(struct inode *inode, struct file *file, bool isdir) 157int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
@@ -1618,6 +1629,58 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
1618} 1629}
1619 1630
1620/* 1631/*
1632 * CUSE servers compiled on 32bit broke on 64bit kernels because the
1633 * ABI was defined to be 'struct iovec' which is different on 32bit
1634 * and 64bit. Fortunately we can determine which structure the server
1635 * used from the size of the reply.
1636 */
1637static int fuse_copy_ioctl_iovec(struct iovec *dst, void *src,
1638 size_t transferred, unsigned count,
1639 bool is_compat)
1640{
1641#ifdef CONFIG_COMPAT
1642 if (count * sizeof(struct compat_iovec) == transferred) {
1643 struct compat_iovec *ciov = src;
1644 unsigned i;
1645
1646 /*
1647 * With this interface a 32bit server cannot support
1648 * non-compat (i.e. ones coming from 64bit apps) ioctl
1649 * requests
1650 */
1651 if (!is_compat)
1652 return -EINVAL;
1653
1654 for (i = 0; i < count; i++) {
1655 dst[i].iov_base = compat_ptr(ciov[i].iov_base);
1656 dst[i].iov_len = ciov[i].iov_len;
1657 }
1658 return 0;
1659 }
1660#endif
1661
1662 if (count * sizeof(struct iovec) != transferred)
1663 return -EIO;
1664
1665 memcpy(dst, src, transferred);
1666 return 0;
1667}
1668
1669/* Make sure iov_length() won't overflow */
1670static int fuse_verify_ioctl_iov(struct iovec *iov, size_t count)
1671{
1672 size_t n;
1673 u32 max = FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT;
1674
1675 for (n = 0; n < count; n++) {
1676 if (iov->iov_len > (size_t) max)
1677 return -ENOMEM;
1678 max -= iov->iov_len;
1679 }
1680 return 0;
1681}
1682
1683/*
1621 * For ioctls, there is no generic way to determine how much memory 1684 * For ioctls, there is no generic way to determine how much memory
1622 * needs to be read and/or written. Furthermore, ioctls are allowed 1685 * needs to be read and/or written. Furthermore, ioctls are allowed
1623 * to dereference the passed pointer, so the parameter requires deep 1686 * to dereference the passed pointer, so the parameter requires deep
@@ -1798,18 +1861,25 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
1798 in_iovs + out_iovs > FUSE_IOCTL_MAX_IOV) 1861 in_iovs + out_iovs > FUSE_IOCTL_MAX_IOV)
1799 goto out; 1862 goto out;
1800 1863
1801 err = -EIO;
1802 if ((in_iovs + out_iovs) * sizeof(struct iovec) != transferred)
1803 goto out;
1804
1805 /* okay, copy in iovs and retry */
1806 vaddr = kmap_atomic(pages[0], KM_USER0); 1864 vaddr = kmap_atomic(pages[0], KM_USER0);
1807 memcpy(page_address(iov_page), vaddr, transferred); 1865 err = fuse_copy_ioctl_iovec(page_address(iov_page), vaddr,
1866 transferred, in_iovs + out_iovs,
1867 (flags & FUSE_IOCTL_COMPAT) != 0);
1808 kunmap_atomic(vaddr, KM_USER0); 1868 kunmap_atomic(vaddr, KM_USER0);
1869 if (err)
1870 goto out;
1809 1871
1810 in_iov = page_address(iov_page); 1872 in_iov = page_address(iov_page);
1811 out_iov = in_iov + in_iovs; 1873 out_iov = in_iov + in_iovs;
1812 1874
1875 err = fuse_verify_ioctl_iov(in_iov, in_iovs);
1876 if (err)
1877 goto out;
1878
1879 err = fuse_verify_ioctl_iov(out_iov, out_iovs);
1880 if (err)
1881 goto out;
1882
1813 goto retry; 1883 goto retry;
1814 } 1884 }
1815 1885
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 58a9b9998b42..f606baf9ba72 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -631,6 +631,7 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,
631 struct fs_disk_quota *fdq) 631 struct fs_disk_quota *fdq)
632{ 632{
633 struct inode *inode = &ip->i_inode; 633 struct inode *inode = &ip->i_inode;
634 struct gfs2_sbd *sdp = GFS2_SB(inode);
634 struct address_space *mapping = inode->i_mapping; 635 struct address_space *mapping = inode->i_mapping;
635 unsigned long index = loc >> PAGE_CACHE_SHIFT; 636 unsigned long index = loc >> PAGE_CACHE_SHIFT;
636 unsigned offset = loc & (PAGE_CACHE_SIZE - 1); 637 unsigned offset = loc & (PAGE_CACHE_SIZE - 1);
@@ -658,11 +659,11 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,
658 qd->qd_qb.qb_value = qp->qu_value; 659 qd->qd_qb.qb_value = qp->qu_value;
659 if (fdq) { 660 if (fdq) {
660 if (fdq->d_fieldmask & FS_DQ_BSOFT) { 661 if (fdq->d_fieldmask & FS_DQ_BSOFT) {
661 qp->qu_warn = cpu_to_be64(fdq->d_blk_softlimit); 662 qp->qu_warn = cpu_to_be64(fdq->d_blk_softlimit >> sdp->sd_fsb2bb_shift);
662 qd->qd_qb.qb_warn = qp->qu_warn; 663 qd->qd_qb.qb_warn = qp->qu_warn;
663 } 664 }
664 if (fdq->d_fieldmask & FS_DQ_BHARD) { 665 if (fdq->d_fieldmask & FS_DQ_BHARD) {
665 qp->qu_limit = cpu_to_be64(fdq->d_blk_hardlimit); 666 qp->qu_limit = cpu_to_be64(fdq->d_blk_hardlimit >> sdp->sd_fsb2bb_shift);
666 qd->qd_qb.qb_limit = qp->qu_limit; 667 qd->qd_qb.qb_limit = qp->qu_limit;
667 } 668 }
668 } 669 }
@@ -1497,9 +1498,9 @@ static int gfs2_get_dqblk(struct super_block *sb, int type, qid_t id,
1497 fdq->d_version = FS_DQUOT_VERSION; 1498 fdq->d_version = FS_DQUOT_VERSION;
1498 fdq->d_flags = (type == QUOTA_USER) ? FS_USER_QUOTA : FS_GROUP_QUOTA; 1499 fdq->d_flags = (type == QUOTA_USER) ? FS_USER_QUOTA : FS_GROUP_QUOTA;
1499 fdq->d_id = id; 1500 fdq->d_id = id;
1500 fdq->d_blk_hardlimit = be64_to_cpu(qlvb->qb_limit); 1501 fdq->d_blk_hardlimit = be64_to_cpu(qlvb->qb_limit) << sdp->sd_fsb2bb_shift;
1501 fdq->d_blk_softlimit = be64_to_cpu(qlvb->qb_warn); 1502 fdq->d_blk_softlimit = be64_to_cpu(qlvb->qb_warn) << sdp->sd_fsb2bb_shift;
1502 fdq->d_bcount = be64_to_cpu(qlvb->qb_value); 1503 fdq->d_bcount = be64_to_cpu(qlvb->qb_value) << sdp->sd_fsb2bb_shift;
1503 1504
1504 gfs2_glock_dq_uninit(&q_gh); 1505 gfs2_glock_dq_uninit(&q_gh);
1505out: 1506out:
@@ -1566,10 +1567,10 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
1566 1567
1567 /* If nothing has changed, this is a no-op */ 1568 /* If nothing has changed, this is a no-op */
1568 if ((fdq->d_fieldmask & FS_DQ_BSOFT) && 1569 if ((fdq->d_fieldmask & FS_DQ_BSOFT) &&
1569 (fdq->d_blk_softlimit == be64_to_cpu(qd->qd_qb.qb_warn))) 1570 ((fdq->d_blk_softlimit >> sdp->sd_fsb2bb_shift) == be64_to_cpu(qd->qd_qb.qb_warn)))
1570 fdq->d_fieldmask ^= FS_DQ_BSOFT; 1571 fdq->d_fieldmask ^= FS_DQ_BSOFT;
1571 if ((fdq->d_fieldmask & FS_DQ_BHARD) && 1572 if ((fdq->d_fieldmask & FS_DQ_BHARD) &&
1572 (fdq->d_blk_hardlimit == be64_to_cpu(qd->qd_qb.qb_limit))) 1573 ((fdq->d_blk_hardlimit >> sdp->sd_fsb2bb_shift) == be64_to_cpu(qd->qd_qb.qb_limit)))
1573 fdq->d_fieldmask ^= FS_DQ_BHARD; 1574 fdq->d_fieldmask ^= FS_DQ_BHARD;
1574 if (fdq->d_fieldmask == 0) 1575 if (fdq->d_fieldmask == 0)
1575 goto out_i; 1576 goto out_i;
diff --git a/fs/ioctl.c b/fs/ioctl.c
index e92fdbb3bc3a..d6cc16476620 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -6,7 +6,6 @@
6 6
7#include <linux/syscalls.h> 7#include <linux/syscalls.h>
8#include <linux/mm.h> 8#include <linux/mm.h>
9#include <linux/smp_lock.h>
10#include <linux/capability.h> 9#include <linux/capability.h>
11#include <linux/file.h> 10#include <linux/file.h>
12#include <linux/fs.h> 11#include <linux/fs.h>
@@ -530,41 +529,6 @@ static int ioctl_fsthaw(struct file *filp)
530 return thaw_super(sb); 529 return thaw_super(sb);
531} 530}
532 531
533static int ioctl_fstrim(struct file *filp, void __user *argp)
534{
535 struct super_block *sb = filp->f_path.dentry->d_inode->i_sb;
536 struct fstrim_range range;
537 int ret = 0;
538
539 if (!capable(CAP_SYS_ADMIN))
540 return -EPERM;
541
542 /* If filesystem doesn't support trim feature, return. */
543 if (sb->s_op->trim_fs == NULL)
544 return -EOPNOTSUPP;
545
546 /* If a blockdevice-backed filesystem isn't specified, return EINVAL. */
547 if (sb->s_bdev == NULL)
548 return -EINVAL;
549
550 if (argp == NULL) {
551 range.start = 0;
552 range.len = ULLONG_MAX;
553 range.minlen = 0;
554 } else if (copy_from_user(&range, argp, sizeof(range)))
555 return -EFAULT;
556
557 ret = sb->s_op->trim_fs(sb, &range);
558 if (ret < 0)
559 return ret;
560
561 if ((argp != NULL) &&
562 (copy_to_user(argp, &range, sizeof(range))))
563 return -EFAULT;
564
565 return 0;
566}
567
568/* 532/*
569 * When you add any new common ioctls to the switches above and below 533 * When you add any new common ioctls to the switches above and below
570 * please update compat_sys_ioctl() too. 534 * please update compat_sys_ioctl() too.
@@ -615,10 +579,6 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
615 error = ioctl_fsthaw(filp); 579 error = ioctl_fsthaw(filp);
616 break; 580 break;
617 581
618 case FITRIM:
619 error = ioctl_fstrim(filp, argp);
620 break;
621
622 case FS_IOC_FIEMAP: 582 case FS_IOC_FIEMAP:
623 return ioctl_fiemap(filp, arg); 583 return ioctl_fiemap(filp, arg);
624 584
diff --git a/fs/ioprio.c b/fs/ioprio.c
index 2f7d05c89922..7da2a06508e5 100644
--- a/fs/ioprio.c
+++ b/fs/ioprio.c
@@ -103,22 +103,15 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
103 } 103 }
104 104
105 ret = -ESRCH; 105 ret = -ESRCH;
106 /* 106 rcu_read_lock();
107 * We want IOPRIO_WHO_PGRP/IOPRIO_WHO_USER to be "atomic",
108 * so we can't use rcu_read_lock(). See re-copy of ->ioprio
109 * in copy_process().
110 */
111 read_lock(&tasklist_lock);
112 switch (which) { 107 switch (which) {
113 case IOPRIO_WHO_PROCESS: 108 case IOPRIO_WHO_PROCESS:
114 rcu_read_lock();
115 if (!who) 109 if (!who)
116 p = current; 110 p = current;
117 else 111 else
118 p = find_task_by_vpid(who); 112 p = find_task_by_vpid(who);
119 if (p) 113 if (p)
120 ret = set_task_ioprio(p, ioprio); 114 ret = set_task_ioprio(p, ioprio);
121 rcu_read_unlock();
122 break; 115 break;
123 case IOPRIO_WHO_PGRP: 116 case IOPRIO_WHO_PGRP:
124 if (!who) 117 if (!who)
@@ -141,12 +134,7 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
141 break; 134 break;
142 135
143 do_each_thread(g, p) { 136 do_each_thread(g, p) {
144 int match; 137 if (__task_cred(p)->uid != who)
145
146 rcu_read_lock();
147 match = __task_cred(p)->uid == who;
148 rcu_read_unlock();
149 if (!match)
150 continue; 138 continue;
151 ret = set_task_ioprio(p, ioprio); 139 ret = set_task_ioprio(p, ioprio);
152 if (ret) 140 if (ret)
@@ -160,7 +148,7 @@ free_uid:
160 ret = -EINVAL; 148 ret = -EINVAL;
161 } 149 }
162 150
163 read_unlock(&tasklist_lock); 151 rcu_read_unlock();
164 return ret; 152 return ret;
165} 153}
166 154
@@ -204,17 +192,15 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
204 int ret = -ESRCH; 192 int ret = -ESRCH;
205 int tmpio; 193 int tmpio;
206 194
207 read_lock(&tasklist_lock); 195 rcu_read_lock();
208 switch (which) { 196 switch (which) {
209 case IOPRIO_WHO_PROCESS: 197 case IOPRIO_WHO_PROCESS:
210 rcu_read_lock();
211 if (!who) 198 if (!who)
212 p = current; 199 p = current;
213 else 200 else
214 p = find_task_by_vpid(who); 201 p = find_task_by_vpid(who);
215 if (p) 202 if (p)
216 ret = get_task_ioprio(p); 203 ret = get_task_ioprio(p);
217 rcu_read_unlock();
218 break; 204 break;
219 case IOPRIO_WHO_PGRP: 205 case IOPRIO_WHO_PGRP:
220 if (!who) 206 if (!who)
@@ -241,12 +227,7 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
241 break; 227 break;
242 228
243 do_each_thread(g, p) { 229 do_each_thread(g, p) {
244 int match; 230 if (__task_cred(p)->uid != user->uid)
245
246 rcu_read_lock();
247 match = __task_cred(p)->uid == user->uid;
248 rcu_read_unlock();
249 if (!match)
250 continue; 231 continue;
251 tmpio = get_task_ioprio(p); 232 tmpio = get_task_ioprio(p);
252 if (tmpio < 0) 233 if (tmpio < 0)
@@ -264,6 +245,6 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
264 ret = -EINVAL; 245 ret = -EINVAL;
265 } 246 }
266 247
267 read_unlock(&tasklist_lock); 248 rcu_read_unlock();
268 return ret; 249 return ret;
269} 250}
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index c590d155c095..f837ba953529 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -899,6 +899,14 @@ journal_t * jbd2_journal_init_dev(struct block_device *bdev,
899 899
900 /* journal descriptor can store up to n blocks -bzzz */ 900 /* journal descriptor can store up to n blocks -bzzz */
901 journal->j_blocksize = blocksize; 901 journal->j_blocksize = blocksize;
902 journal->j_dev = bdev;
903 journal->j_fs_dev = fs_dev;
904 journal->j_blk_offset = start;
905 journal->j_maxlen = len;
906 bdevname(journal->j_dev, journal->j_devname);
907 p = journal->j_devname;
908 while ((p = strchr(p, '/')))
909 *p = '!';
902 jbd2_stats_proc_init(journal); 910 jbd2_stats_proc_init(journal);
903 n = journal->j_blocksize / sizeof(journal_block_tag_t); 911 n = journal->j_blocksize / sizeof(journal_block_tag_t);
904 journal->j_wbufsize = n; 912 journal->j_wbufsize = n;
@@ -908,14 +916,6 @@ journal_t * jbd2_journal_init_dev(struct block_device *bdev,
908 __func__); 916 __func__);
909 goto out_err; 917 goto out_err;
910 } 918 }
911 journal->j_dev = bdev;
912 journal->j_fs_dev = fs_dev;
913 journal->j_blk_offset = start;
914 journal->j_maxlen = len;
915 bdevname(journal->j_dev, journal->j_devname);
916 p = journal->j_devname;
917 while ((p = strchr(p, '/')))
918 *p = '!';
919 919
920 bh = __getblk(journal->j_dev, start, journal->j_blocksize); 920 bh = __getblk(journal->j_dev, start, journal->j_blocksize);
921 if (!bh) { 921 if (!bh) {
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index d5bb86866e6c..25509eb28fd7 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -14,7 +14,6 @@
14#include <linux/sunrpc/clnt.h> 14#include <linux/sunrpc/clnt.h>
15#include <linux/sunrpc/svc.h> 15#include <linux/sunrpc/svc.h>
16#include <linux/lockd/lockd.h> 16#include <linux/lockd/lockd.h>
17#include <linux/smp_lock.h>
18#include <linux/kthread.h> 17#include <linux/kthread.h>
19 18
20#define NLMDBG_FACILITY NLMDBG_CLIENT 19#define NLMDBG_FACILITY NLMDBG_CLIENT
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 47ea1e1925b8..332c54cf75e0 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/smp_lock.h>
11#include <linux/slab.h> 10#include <linux/slab.h>
12#include <linux/types.h> 11#include <linux/types.h>
13#include <linux/errno.h> 12#include <linux/errno.h>
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 25e21e4023b2..ed0c59fe23ce 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -124,7 +124,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
124 continue; 124 continue;
125 if (host->h_server != ni->server) 125 if (host->h_server != ni->server)
126 continue; 126 continue;
127 if (ni->server && 127 if (ni->server && ni->src_len != 0 &&
128 !rpc_cmp_addr(nlm_srcaddr(host), ni->src_sap)) 128 !rpc_cmp_addr(nlm_srcaddr(host), ni->src_sap))
129 continue; 129 continue;
130 130
@@ -167,6 +167,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
167 host->h_addrlen = ni->salen; 167 host->h_addrlen = ni->salen;
168 rpc_set_port(nlm_addr(host), 0); 168 rpc_set_port(nlm_addr(host), 0);
169 memcpy(nlm_srcaddr(host), ni->src_sap, ni->src_len); 169 memcpy(nlm_srcaddr(host), ni->src_sap, ni->src_len);
170 host->h_srcaddrlen = ni->src_len;
170 host->h_version = ni->version; 171 host->h_version = ni->version;
171 host->h_proto = ni->protocol; 172 host->h_proto = ni->protocol;
172 host->h_rpcclnt = NULL; 173 host->h_rpcclnt = NULL;
@@ -238,9 +239,6 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
238 const char *hostname, 239 const char *hostname,
239 int noresvport) 240 int noresvport)
240{ 241{
241 const struct sockaddr source = {
242 .sa_family = AF_UNSPEC,
243 };
244 struct nlm_lookup_host_info ni = { 242 struct nlm_lookup_host_info ni = {
245 .server = 0, 243 .server = 0,
246 .sap = sap, 244 .sap = sap,
@@ -249,8 +247,6 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
249 .version = version, 247 .version = version,
250 .hostname = hostname, 248 .hostname = hostname,
251 .hostname_len = strlen(hostname), 249 .hostname_len = strlen(hostname),
252 .src_sap = &source,
253 .src_len = sizeof(source),
254 .noresvport = noresvport, 250 .noresvport = noresvport,
255 }; 251 };
256 252
@@ -357,7 +353,6 @@ nlm_bind_host(struct nlm_host *host)
357 .protocol = host->h_proto, 353 .protocol = host->h_proto,
358 .address = nlm_addr(host), 354 .address = nlm_addr(host),
359 .addrsize = host->h_addrlen, 355 .addrsize = host->h_addrlen,
360 .saddress = nlm_srcaddr(host),
361 .timeout = &timeparms, 356 .timeout = &timeparms,
362 .servername = host->h_name, 357 .servername = host->h_name,
363 .program = &nlm_program, 358 .program = &nlm_program,
@@ -376,6 +371,8 @@ nlm_bind_host(struct nlm_host *host)
376 args.flags |= RPC_CLNT_CREATE_HARDRTRY; 371 args.flags |= RPC_CLNT_CREATE_HARDRTRY;
377 if (host->h_noresvport) 372 if (host->h_noresvport)
378 args.flags |= RPC_CLNT_CREATE_NONPRIVPORT; 373 args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
374 if (host->h_srcaddrlen)
375 args.saddress = nlm_srcaddr(host);
379 376
380 clnt = rpc_create(&args); 377 clnt = rpc_create(&args);
381 if (!IS_ERR(clnt)) 378 if (!IS_ERR(clnt))
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index a336e832475d..38d261192453 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -9,7 +9,6 @@
9 9
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/time.h> 11#include <linux/time.h>
12#include <linux/smp_lock.h>
13#include <linux/lockd/lockd.h> 12#include <linux/lockd/lockd.h>
14#include <linux/lockd/share.h> 13#include <linux/lockd/share.h>
15 14
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index c462d346acbd..ef5659b211e9 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -25,7 +25,6 @@
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/smp_lock.h>
29#include <linux/sunrpc/clnt.h> 28#include <linux/sunrpc/clnt.h>
30#include <linux/sunrpc/svc.h> 29#include <linux/sunrpc/svc.h>
31#include <linux/lockd/nlm.h> 30#include <linux/lockd/nlm.h>
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index c3069f38d602..0caea5310ac3 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -9,7 +9,6 @@
9 9
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/time.h> 11#include <linux/time.h>
12#include <linux/smp_lock.h>
13#include <linux/lockd/lockd.h> 12#include <linux/lockd/lockd.h>
14#include <linux/lockd/share.h> 13#include <linux/lockd/share.h>
15 14
diff --git a/fs/locks.c b/fs/locks.c
index 0e62dd35d088..8729347bcd1a 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -122,7 +122,6 @@
122#include <linux/module.h> 122#include <linux/module.h>
123#include <linux/security.h> 123#include <linux/security.h>
124#include <linux/slab.h> 124#include <linux/slab.h>
125#include <linux/smp_lock.h>
126#include <linux/syscalls.h> 125#include <linux/syscalls.h>
127#include <linux/time.h> 126#include <linux/time.h>
128#include <linux/rcupdate.h> 127#include <linux/rcupdate.h>
diff --git a/fs/namei.c b/fs/namei.c
index 5362af9b7372..4ff7ca530533 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1748,6 +1748,9 @@ struct file *do_filp_open(int dfd, const char *pathname,
1748 if (!(open_flag & O_CREAT)) 1748 if (!(open_flag & O_CREAT))
1749 mode = 0; 1749 mode = 0;
1750 1750
1751 /* Must never be set by userspace */
1752 open_flag &= ~FMODE_NONOTIFY;
1753
1751 /* 1754 /*
1752 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only 1755 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
1753 * check for O_DSYNC if the need any syncing at all we enforce it's 1756 * check for O_DSYNC if the need any syncing at all we enforce it's
diff --git a/fs/namespace.c b/fs/namespace.c
index 8a415c9c5e55..3dbfc072ec70 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -13,7 +13,6 @@
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/percpu.h> 15#include <linux/percpu.h>
16#include <linux/smp_lock.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
19#include <linux/acct.h> 18#include <linux/acct.h>
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index aac8832e919e..f22b12e7d337 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -19,7 +19,6 @@
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <asm/uaccess.h> 20#include <asm/uaccess.h>
21#include <asm/byteorder.h> 21#include <asm/byteorder.h>
22#include <linux/smp_lock.h>
23 22
24#include <linux/ncp_fs.h> 23#include <linux/ncp_fs.h>
25 24
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 6c754f70c529..cb50aaf981df 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -17,7 +17,6 @@
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/smp_lock.h>
21 20
22#include <linux/ncp_fs.h> 21#include <linux/ncp_fs.h>
23#include "ncplib_kernel.h" 22#include "ncplib_kernel.h"
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index d290545aa0c4..8fb93b604e73 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -26,7 +26,6 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/smp_lock.h>
30#include <linux/vfs.h> 29#include <linux/vfs.h>
31#include <linux/mount.h> 30#include <linux/mount.h>
32#include <linux/seq_file.h> 31#include <linux/seq_file.h>
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index c2a1f9a155c3..d40a547e3377 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -17,7 +17,6 @@
17#include <linux/mount.h> 17#include <linux/mount.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/highuid.h> 19#include <linux/highuid.h>
20#include <linux/smp_lock.h>
21#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
22#include <linux/sched.h> 21#include <linux/sched.h>
23 22
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index aeec017fe814..93a8b3bd69e3 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -9,7 +9,6 @@
9#include <linux/completion.h> 9#include <linux/completion.h>
10#include <linux/ip.h> 10#include <linux/ip.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/smp_lock.h>
13#include <linux/sunrpc/svc.h> 12#include <linux/sunrpc/svc.h>
14#include <linux/sunrpc/svcsock.h> 13#include <linux/sunrpc/svcsock.h>
15#include <linux/nfs_fs.h> 14#include <linux/nfs_fs.h>
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 232a7eead33a..1fd62fc49be3 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -11,7 +11,6 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/smp_lock.h>
15#include <linux/spinlock.h> 14#include <linux/spinlock.h>
16 15
17#include <linux/nfs4.h> 16#include <linux/nfs4.h>
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 07ac3847e562..996dd8989a91 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -34,6 +34,7 @@
34#include <linux/mount.h> 34#include <linux/mount.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/kmemleak.h>
37 38
38#include "delegation.h" 39#include "delegation.h"
39#include "iostat.h" 40#include "iostat.h"
@@ -56,7 +57,7 @@ static int nfs_rename(struct inode *, struct dentry *,
56 struct inode *, struct dentry *); 57 struct inode *, struct dentry *);
57static int nfs_fsync_dir(struct file *, int); 58static int nfs_fsync_dir(struct file *, int);
58static loff_t nfs_llseek_dir(struct file *, loff_t, int); 59static loff_t nfs_llseek_dir(struct file *, loff_t, int);
59static int nfs_readdir_clear_array(struct page*, gfp_t); 60static void nfs_readdir_clear_array(struct page*);
60 61
61const struct file_operations nfs_dir_operations = { 62const struct file_operations nfs_dir_operations = {
62 .llseek = nfs_llseek_dir, 63 .llseek = nfs_llseek_dir,
@@ -82,8 +83,8 @@ const struct inode_operations nfs_dir_inode_operations = {
82 .setattr = nfs_setattr, 83 .setattr = nfs_setattr,
83}; 84};
84 85
85const struct address_space_operations nfs_dir_addr_space_ops = { 86const struct address_space_operations nfs_dir_aops = {
86 .releasepage = nfs_readdir_clear_array, 87 .freepage = nfs_readdir_clear_array,
87}; 88};
88 89
89#ifdef CONFIG_NFS_V3 90#ifdef CONFIG_NFS_V3
@@ -161,6 +162,7 @@ struct nfs_cache_array_entry {
161 u64 cookie; 162 u64 cookie;
162 u64 ino; 163 u64 ino;
163 struct qstr string; 164 struct qstr string;
165 unsigned char d_type;
164}; 166};
165 167
166struct nfs_cache_array { 168struct nfs_cache_array {
@@ -170,14 +172,13 @@ struct nfs_cache_array {
170 struct nfs_cache_array_entry array[0]; 172 struct nfs_cache_array_entry array[0];
171}; 173};
172 174
173#define MAX_READDIR_ARRAY ((PAGE_SIZE - sizeof(struct nfs_cache_array)) / sizeof(struct nfs_cache_array_entry))
174
175typedef __be32 * (*decode_dirent_t)(struct xdr_stream *, struct nfs_entry *, struct nfs_server *, int); 175typedef __be32 * (*decode_dirent_t)(struct xdr_stream *, struct nfs_entry *, struct nfs_server *, int);
176typedef struct { 176typedef struct {
177 struct file *file; 177 struct file *file;
178 struct page *page; 178 struct page *page;
179 unsigned long page_index; 179 unsigned long page_index;
180 u64 *dir_cookie; 180 u64 *dir_cookie;
181 u64 last_cookie;
181 loff_t current_index; 182 loff_t current_index;
182 decode_dirent_t decode; 183 decode_dirent_t decode;
183 184
@@ -194,9 +195,13 @@ typedef struct {
194static 195static
195struct nfs_cache_array *nfs_readdir_get_array(struct page *page) 196struct nfs_cache_array *nfs_readdir_get_array(struct page *page)
196{ 197{
198 void *ptr;
197 if (page == NULL) 199 if (page == NULL)
198 return ERR_PTR(-EIO); 200 return ERR_PTR(-EIO);
199 return (struct nfs_cache_array *)kmap(page); 201 ptr = kmap(page);
202 if (ptr == NULL)
203 return ERR_PTR(-ENOMEM);
204 return ptr;
200} 205}
201 206
202static 207static
@@ -209,14 +214,15 @@ void nfs_readdir_release_array(struct page *page)
209 * we are freeing strings created by nfs_add_to_readdir_array() 214 * we are freeing strings created by nfs_add_to_readdir_array()
210 */ 215 */
211static 216static
212int nfs_readdir_clear_array(struct page *page, gfp_t mask) 217void nfs_readdir_clear_array(struct page *page)
213{ 218{
214 struct nfs_cache_array *array = nfs_readdir_get_array(page); 219 struct nfs_cache_array *array;
215 int i; 220 int i;
221
222 array = kmap_atomic(page, KM_USER0);
216 for (i = 0; i < array->size; i++) 223 for (i = 0; i < array->size; i++)
217 kfree(array->array[i].string.name); 224 kfree(array->array[i].string.name);
218 nfs_readdir_release_array(page); 225 kunmap_atomic(array, KM_USER0);
219 return 0;
220} 226}
221 227
222/* 228/*
@@ -231,6 +237,11 @@ int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int le
231 string->name = kmemdup(name, len, GFP_KERNEL); 237 string->name = kmemdup(name, len, GFP_KERNEL);
232 if (string->name == NULL) 238 if (string->name == NULL)
233 return -ENOMEM; 239 return -ENOMEM;
240 /*
241 * Avoid a kmemleak false positive. The pointer to the name is stored
242 * in a page cache page which kmemleak does not scan.
243 */
244 kmemleak_not_leak(string->name);
234 string->hash = full_name_hash(name, len); 245 string->hash = full_name_hash(name, len);
235 return 0; 246 return 0;
236} 247}
@@ -244,20 +255,24 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page)
244 255
245 if (IS_ERR(array)) 256 if (IS_ERR(array))
246 return PTR_ERR(array); 257 return PTR_ERR(array);
247 ret = -EIO;
248 if (array->size >= MAX_READDIR_ARRAY)
249 goto out;
250 258
251 cache_entry = &array->array[array->size]; 259 cache_entry = &array->array[array->size];
260
261 /* Check that this entry lies within the page bounds */
262 ret = -ENOSPC;
263 if ((char *)&cache_entry[1] - (char *)page_address(page) > PAGE_SIZE)
264 goto out;
265
252 cache_entry->cookie = entry->prev_cookie; 266 cache_entry->cookie = entry->prev_cookie;
253 cache_entry->ino = entry->ino; 267 cache_entry->ino = entry->ino;
268 cache_entry->d_type = entry->d_type;
254 ret = nfs_readdir_make_qstr(&cache_entry->string, entry->name, entry->len); 269 ret = nfs_readdir_make_qstr(&cache_entry->string, entry->name, entry->len);
255 if (ret) 270 if (ret)
256 goto out; 271 goto out;
257 array->last_cookie = entry->cookie; 272 array->last_cookie = entry->cookie;
258 if (entry->eof == 1)
259 array->eof_index = array->size;
260 array->size++; 273 array->size++;
274 if (entry->eof != 0)
275 array->eof_index = array->size;
261out: 276out:
262 nfs_readdir_release_array(page); 277 nfs_readdir_release_array(page);
263 return ret; 278 return ret;
@@ -272,7 +287,7 @@ int nfs_readdir_search_for_pos(struct nfs_cache_array *array, nfs_readdir_descri
272 if (diff < 0) 287 if (diff < 0)
273 goto out_eof; 288 goto out_eof;
274 if (diff >= array->size) { 289 if (diff >= array->size) {
275 if (array->eof_index > 0) 290 if (array->eof_index >= 0)
276 goto out_eof; 291 goto out_eof;
277 desc->current_index += array->size; 292 desc->current_index += array->size;
278 return -EAGAIN; 293 return -EAGAIN;
@@ -281,8 +296,6 @@ int nfs_readdir_search_for_pos(struct nfs_cache_array *array, nfs_readdir_descri
281 index = (unsigned int)diff; 296 index = (unsigned int)diff;
282 *desc->dir_cookie = array->array[index].cookie; 297 *desc->dir_cookie = array->array[index].cookie;
283 desc->cache_entry_index = index; 298 desc->cache_entry_index = index;
284 if (index == array->eof_index)
285 desc->eof = 1;
286 return 0; 299 return 0;
287out_eof: 300out_eof:
288 desc->eof = 1; 301 desc->eof = 1;
@@ -296,17 +309,16 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
296 int status = -EAGAIN; 309 int status = -EAGAIN;
297 310
298 for (i = 0; i < array->size; i++) { 311 for (i = 0; i < array->size; i++) {
299 if (i == array->eof_index) {
300 desc->eof = 1;
301 status = -EBADCOOKIE;
302 }
303 if (array->array[i].cookie == *desc->dir_cookie) { 312 if (array->array[i].cookie == *desc->dir_cookie) {
304 desc->cache_entry_index = i; 313 desc->cache_entry_index = i;
305 status = 0; 314 return 0;
306 break;
307 } 315 }
308 } 316 }
309 317 if (array->eof_index >= 0) {
318 status = -EBADCOOKIE;
319 if (*desc->dir_cookie == array->last_cookie)
320 desc->eof = 1;
321 }
310 return status; 322 return status;
311} 323}
312 324
@@ -314,10 +326,7 @@ static
314int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) 326int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)
315{ 327{
316 struct nfs_cache_array *array; 328 struct nfs_cache_array *array;
317 int status = -EBADCOOKIE; 329 int status;
318
319 if (desc->dir_cookie == NULL)
320 goto out;
321 330
322 array = nfs_readdir_get_array(desc->page); 331 array = nfs_readdir_get_array(desc->page);
323 if (IS_ERR(array)) { 332 if (IS_ERR(array)) {
@@ -330,6 +339,10 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)
330 else 339 else
331 status = nfs_readdir_search_for_cookie(array, desc); 340 status = nfs_readdir_search_for_cookie(array, desc);
332 341
342 if (status == -EAGAIN) {
343 desc->last_cookie = array->last_cookie;
344 desc->page_index++;
345 }
333 nfs_readdir_release_array(desc->page); 346 nfs_readdir_release_array(desc->page);
334out: 347out:
335 return status; 348 return status;
@@ -381,13 +394,9 @@ int xdr_decode(nfs_readdir_descriptor_t *desc, struct nfs_entry *entry, struct x
381static 394static
382int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry) 395int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry)
383{ 396{
384 struct nfs_inode *node;
385 if (dentry->d_inode == NULL) 397 if (dentry->d_inode == NULL)
386 goto different; 398 goto different;
387 node = NFS_I(dentry->d_inode); 399 if (nfs_compare_fh(entry->fh, NFS_FH(dentry->d_inode)) != 0)
388 if (node->fh.size != entry->fh->size)
389 goto different;
390 if (strncmp(node->fh.data, entry->fh->data, node->fh.size) != 0)
391 goto different; 400 goto different;
392 return 1; 401 return 1;
393different: 402different:
@@ -449,14 +458,15 @@ out:
449 458
450/* Perform conversion from xdr to cache array */ 459/* Perform conversion from xdr to cache array */
451static 460static
452void nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *entry, 461int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *entry,
453 void *xdr_page, struct page *page, unsigned int buflen) 462 void *xdr_page, struct page *page, unsigned int buflen)
454{ 463{
455 struct xdr_stream stream; 464 struct xdr_stream stream;
456 struct xdr_buf buf; 465 struct xdr_buf buf;
457 __be32 *ptr = xdr_page; 466 __be32 *ptr = xdr_page;
458 int status;
459 struct nfs_cache_array *array; 467 struct nfs_cache_array *array;
468 unsigned int count = 0;
469 int status;
460 470
461 buf.head->iov_base = xdr_page; 471 buf.head->iov_base = xdr_page;
462 buf.head->iov_len = buflen; 472 buf.head->iov_len = buflen;
@@ -471,21 +481,32 @@ void nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *e
471 481
472 do { 482 do {
473 status = xdr_decode(desc, entry, &stream); 483 status = xdr_decode(desc, entry, &stream);
474 if (status != 0) 484 if (status != 0) {
485 if (status == -EAGAIN)
486 status = 0;
475 break; 487 break;
488 }
476 489
477 if (nfs_readdir_add_to_array(entry, page) == -1) 490 count++;
478 break; 491
479 if (desc->plus == 1) 492 if (desc->plus != 0)
480 nfs_prime_dcache(desc->file->f_path.dentry, entry); 493 nfs_prime_dcache(desc->file->f_path.dentry, entry);
494
495 status = nfs_readdir_add_to_array(entry, page);
496 if (status != 0)
497 break;
481 } while (!entry->eof); 498 } while (!entry->eof);
482 499
483 if (status == -EBADCOOKIE && entry->eof) { 500 if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) {
484 array = nfs_readdir_get_array(page); 501 array = nfs_readdir_get_array(page);
485 array->eof_index = array->size - 1; 502 if (!IS_ERR(array)) {
486 status = 0; 503 array->eof_index = array->size;
487 nfs_readdir_release_array(page); 504 status = 0;
505 nfs_readdir_release_array(page);
506 } else
507 status = PTR_ERR(array);
488 } 508 }
509 return status;
489} 510}
490 511
491static 512static
@@ -537,11 +558,11 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
537 struct nfs_entry entry; 558 struct nfs_entry entry;
538 struct file *file = desc->file; 559 struct file *file = desc->file;
539 struct nfs_cache_array *array; 560 struct nfs_cache_array *array;
540 int status = 0; 561 int status = -ENOMEM;
541 unsigned int array_size = ARRAY_SIZE(pages); 562 unsigned int array_size = ARRAY_SIZE(pages);
542 563
543 entry.prev_cookie = 0; 564 entry.prev_cookie = 0;
544 entry.cookie = *desc->dir_cookie; 565 entry.cookie = desc->last_cookie;
545 entry.eof = 0; 566 entry.eof = 0;
546 entry.fh = nfs_alloc_fhandle(); 567 entry.fh = nfs_alloc_fhandle();
547 entry.fattr = nfs_alloc_fattr(); 568 entry.fattr = nfs_alloc_fattr();
@@ -549,6 +570,10 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
549 goto out; 570 goto out;
550 571
551 array = nfs_readdir_get_array(page); 572 array = nfs_readdir_get_array(page);
573 if (IS_ERR(array)) {
574 status = PTR_ERR(array);
575 goto out;
576 }
552 memset(array, 0, sizeof(struct nfs_cache_array)); 577 memset(array, 0, sizeof(struct nfs_cache_array));
553 array->eof_index = -1; 578 array->eof_index = -1;
554 579
@@ -556,12 +581,19 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
556 if (!pages_ptr) 581 if (!pages_ptr)
557 goto out_release_array; 582 goto out_release_array;
558 do { 583 do {
584 unsigned int pglen;
559 status = nfs_readdir_xdr_filler(pages, desc, &entry, file, inode); 585 status = nfs_readdir_xdr_filler(pages, desc, &entry, file, inode);
560 586
561 if (status < 0) 587 if (status < 0)
562 break; 588 break;
563 nfs_readdir_page_filler(desc, &entry, pages_ptr, page, array_size * PAGE_SIZE); 589 pglen = status;
564 } while (array->eof_index < 0 && array->size < MAX_READDIR_ARRAY); 590 status = nfs_readdir_page_filler(desc, &entry, pages_ptr, page, pglen);
591 if (status < 0) {
592 if (status == -ENOSPC)
593 status = 0;
594 break;
595 }
596 } while (array->eof_index < 0);
565 597
566 nfs_readdir_free_large_page(pages_ptr, pages, array_size); 598 nfs_readdir_free_large_page(pages_ptr, pages, array_size);
567out_release_array: 599out_release_array:
@@ -582,8 +614,10 @@ static
582int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page) 614int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page)
583{ 615{
584 struct inode *inode = desc->file->f_path.dentry->d_inode; 616 struct inode *inode = desc->file->f_path.dentry->d_inode;
617 int ret;
585 618
586 if (nfs_readdir_xdr_to_array(desc, page, inode) < 0) 619 ret = nfs_readdir_xdr_to_array(desc, page, inode);
620 if (ret < 0)
587 goto error; 621 goto error;
588 SetPageUptodate(page); 622 SetPageUptodate(page);
589 623
@@ -595,12 +629,14 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page* page)
595 return 0; 629 return 0;
596 error: 630 error:
597 unlock_page(page); 631 unlock_page(page);
598 return -EIO; 632 return ret;
599} 633}
600 634
601static 635static
602void cache_page_release(nfs_readdir_descriptor_t *desc) 636void cache_page_release(nfs_readdir_descriptor_t *desc)
603{ 637{
638 if (!desc->page->mapping)
639 nfs_readdir_clear_array(desc->page);
604 page_cache_release(desc->page); 640 page_cache_release(desc->page);
605 desc->page = NULL; 641 desc->page = NULL;
606} 642}
@@ -608,12 +644,8 @@ void cache_page_release(nfs_readdir_descriptor_t *desc)
608static 644static
609struct page *get_cache_page(nfs_readdir_descriptor_t *desc) 645struct page *get_cache_page(nfs_readdir_descriptor_t *desc)
610{ 646{
611 struct page *page; 647 return read_cache_page(desc->file->f_path.dentry->d_inode->i_mapping,
612 page = read_cache_page(desc->file->f_path.dentry->d_inode->i_mapping,
613 desc->page_index, (filler_t *)nfs_readdir_filler, desc); 648 desc->page_index, (filler_t *)nfs_readdir_filler, desc);
614 if (IS_ERR(page))
615 desc->eof = 1;
616 return page;
617} 649}
618 650
619/* 651/*
@@ -629,9 +661,8 @@ int find_cache_page(nfs_readdir_descriptor_t *desc)
629 return PTR_ERR(desc->page); 661 return PTR_ERR(desc->page);
630 662
631 res = nfs_readdir_search_array(desc); 663 res = nfs_readdir_search_array(desc);
632 if (res == 0) 664 if (res != 0)
633 return 0; 665 cache_page_release(desc);
634 cache_page_release(desc);
635 return res; 666 return res;
636} 667}
637 668
@@ -639,22 +670,18 @@ int find_cache_page(nfs_readdir_descriptor_t *desc)
639static inline 670static inline
640int readdir_search_pagecache(nfs_readdir_descriptor_t *desc) 671int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
641{ 672{
642 int res = -EAGAIN; 673 int res;
643 674
644 while (1) { 675 if (desc->page_index == 0) {
645 res = find_cache_page(desc); 676 desc->current_index = 0;
646 if (res != -EAGAIN) 677 desc->last_cookie = 0;
647 break;
648 desc->page_index++;
649 } 678 }
679 do {
680 res = find_cache_page(desc);
681 } while (res == -EAGAIN);
650 return res; 682 return res;
651} 683}
652 684
653static inline unsigned int dt_type(struct inode *inode)
654{
655 return (inode->i_mode >> 12) & 15;
656}
657
658/* 685/*
659 * Once we've found the start of the dirent within a page: fill 'er up... 686 * Once we've found the start of the dirent within a page: fill 'er up...
660 */ 687 */
@@ -666,35 +693,35 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
666 int i = 0; 693 int i = 0;
667 int res = 0; 694 int res = 0;
668 struct nfs_cache_array *array = NULL; 695 struct nfs_cache_array *array = NULL;
669 unsigned int d_type = DT_UNKNOWN;
670 struct dentry *dentry = NULL;
671 696
672 array = nfs_readdir_get_array(desc->page); 697 array = nfs_readdir_get_array(desc->page);
698 if (IS_ERR(array)) {
699 res = PTR_ERR(array);
700 goto out;
701 }
673 702
674 for (i = desc->cache_entry_index; i < array->size; i++) { 703 for (i = desc->cache_entry_index; i < array->size; i++) {
675 d_type = DT_UNKNOWN; 704 struct nfs_cache_array_entry *ent;
676 705
677 res = filldir(dirent, array->array[i].string.name, 706 ent = &array->array[i];
678 array->array[i].string.len, file->f_pos, 707 if (filldir(dirent, ent->string.name, ent->string.len,
679 nfs_compat_user_ino64(array->array[i].ino), d_type); 708 file->f_pos, nfs_compat_user_ino64(ent->ino),
680 if (res < 0) 709 ent->d_type) < 0) {
710 desc->eof = 1;
681 break; 711 break;
712 }
682 file->f_pos++; 713 file->f_pos++;
683 desc->cache_entry_index = i;
684 if (i < (array->size-1)) 714 if (i < (array->size-1))
685 *desc->dir_cookie = array->array[i+1].cookie; 715 *desc->dir_cookie = array->array[i+1].cookie;
686 else 716 else
687 *desc->dir_cookie = array->last_cookie; 717 *desc->dir_cookie = array->last_cookie;
688 if (i == array->eof_index) {
689 desc->eof = 1;
690 break;
691 }
692 } 718 }
719 if (array->eof_index >= 0)
720 desc->eof = 1;
693 721
694 nfs_readdir_release_array(desc->page); 722 nfs_readdir_release_array(desc->page);
723out:
695 cache_page_release(desc); 724 cache_page_release(desc);
696 if (dentry != NULL)
697 dput(dentry);
698 dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n", 725 dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n",
699 (unsigned long long)*desc->dir_cookie, res); 726 (unsigned long long)*desc->dir_cookie, res);
700 return res; 727 return res;
@@ -729,13 +756,14 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
729 goto out; 756 goto out;
730 } 757 }
731 758
732 if (nfs_readdir_xdr_to_array(desc, page, inode) == -1) {
733 status = -EIO;
734 goto out_release;
735 }
736
737 desc->page_index = 0; 759 desc->page_index = 0;
760 desc->last_cookie = *desc->dir_cookie;
738 desc->page = page; 761 desc->page = page;
762
763 status = nfs_readdir_xdr_to_array(desc, page, inode);
764 if (status < 0)
765 goto out_release;
766
739 status = nfs_do_filldir(desc, dirent, filldir); 767 status = nfs_do_filldir(desc, dirent, filldir);
740 768
741 out: 769 out:
@@ -757,7 +785,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
757 struct inode *inode = dentry->d_inode; 785 struct inode *inode = dentry->d_inode;
758 nfs_readdir_descriptor_t my_desc, 786 nfs_readdir_descriptor_t my_desc,
759 *desc = &my_desc; 787 *desc = &my_desc;
760 int res = -ENOMEM; 788 int res;
761 789
762 dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n", 790 dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n",
763 dentry->d_parent->d_name.name, dentry->d_name.name, 791 dentry->d_parent->d_name.name, dentry->d_name.name,
@@ -782,18 +810,18 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
782 if (res < 0) 810 if (res < 0)
783 goto out; 811 goto out;
784 812
785 while (desc->eof != 1) { 813 do {
786 res = readdir_search_pagecache(desc); 814 res = readdir_search_pagecache(desc);
787 815
788 if (res == -EBADCOOKIE) { 816 if (res == -EBADCOOKIE) {
817 res = 0;
789 /* This means either end of directory */ 818 /* This means either end of directory */
790 if (*desc->dir_cookie && desc->eof == 0) { 819 if (*desc->dir_cookie && desc->eof == 0) {
791 /* Or that the server has 'lost' a cookie */ 820 /* Or that the server has 'lost' a cookie */
792 res = uncached_readdir(desc, dirent, filldir); 821 res = uncached_readdir(desc, dirent, filldir);
793 if (res >= 0) 822 if (res == 0)
794 continue; 823 continue;
795 } 824 }
796 res = 0;
797 break; 825 break;
798 } 826 }
799 if (res == -ETOOSMALL && desc->plus) { 827 if (res == -ETOOSMALL && desc->plus) {
@@ -808,11 +836,9 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
808 break; 836 break;
809 837
810 res = nfs_do_filldir(desc, dirent, filldir); 838 res = nfs_do_filldir(desc, dirent, filldir);
811 if (res < 0) { 839 if (res < 0)
812 res = 0;
813 break; 840 break;
814 } 841 } while (!desc->eof);
815 }
816out: 842out:
817 nfs_unblock_sillyrename(dentry); 843 nfs_unblock_sillyrename(dentry);
818 if (res > 0) 844 if (res > 0)
@@ -1345,12 +1371,12 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
1345 res = NULL; 1371 res = NULL;
1346 goto out; 1372 goto out;
1347 /* This turned out not to be a regular file */ 1373 /* This turned out not to be a regular file */
1348 case -EISDIR:
1349 case -ENOTDIR: 1374 case -ENOTDIR:
1350 goto no_open; 1375 goto no_open;
1351 case -ELOOP: 1376 case -ELOOP:
1352 if (!(nd->intent.open.flags & O_NOFOLLOW)) 1377 if (!(nd->intent.open.flags & O_NOFOLLOW))
1353 goto no_open; 1378 goto no_open;
1379 /* case -EISDIR: */
1354 /* case -EINVAL: */ 1380 /* case -EINVAL: */
1355 default: 1381 default:
1356 res = ERR_CAST(inode); 1382 res = ERR_CAST(inode);
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 84d3c8b90206..e6ace0d93c71 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -867,7 +867,7 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, const struct iovec *iov,
867 goto out; 867 goto out;
868 nfs_alloc_commit_data(dreq); 868 nfs_alloc_commit_data(dreq);
869 869
870 if (dreq->commit_data == NULL || count < wsize) 870 if (dreq->commit_data == NULL || count <= wsize)
871 sync = NFS_FILE_SYNC; 871 sync = NFS_FILE_SYNC;
872 872
873 dreq->inode = inode; 873 dreq->inode = inode;
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 60677f9f1311..7bf029ef4084 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -693,6 +693,7 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
693{ 693{
694 struct inode *inode = filp->f_mapping->host; 694 struct inode *inode = filp->f_mapping->host;
695 int status = 0; 695 int status = 0;
696 unsigned int saved_type = fl->fl_type;
696 697
697 /* Try local locking first */ 698 /* Try local locking first */
698 posix_test_lock(filp, fl); 699 posix_test_lock(filp, fl);
@@ -700,6 +701,7 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
700 /* found a conflict */ 701 /* found a conflict */
701 goto out; 702 goto out;
702 } 703 }
704 fl->fl_type = saved_type;
703 705
704 if (nfs_have_delegation(inode, FMODE_READ)) 706 if (nfs_have_delegation(inode, FMODE_READ))
705 goto out_noconflict; 707 goto out_noconflict;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 314f57164602..e67e31c73416 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -289,6 +289,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
289 } else if (S_ISDIR(inode->i_mode)) { 289 } else if (S_ISDIR(inode->i_mode)) {
290 inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->dir_inode_ops; 290 inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->dir_inode_ops;
291 inode->i_fop = &nfs_dir_operations; 291 inode->i_fop = &nfs_dir_operations;
292 inode->i_data.a_ops = &nfs_dir_aops;
292 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS)) 293 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS))
293 set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_I(inode)->flags); 294 set_bit(NFS_INO_ADVISE_RDPLUS, &NFS_I(inode)->flags);
294 /* Deal with crossing mountpoints */ 295 /* Deal with crossing mountpoints */
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index db08ff3ff454..e6356b750b77 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -362,6 +362,15 @@ unsigned int nfs_page_length(struct page *page)
362} 362}
363 363
364/* 364/*
365 * Convert a umode to a dirent->d_type
366 */
367static inline
368unsigned char nfs_umode_to_dtype(umode_t mode)
369{
370 return (mode >> 12) & 15;
371}
372
373/*
365 * Determine the number of pages in an array of length 'len' and 374 * Determine the number of pages in an array of length 'len' and
366 * with a base offset of 'base' 375 * with a base offset of 'base'
367 */ 376 */
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index eceafe74f473..4f981f1f6689 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -505,13 +505,13 @@ static struct rpc_procinfo mnt3_procedures[] = {
505 505
506static struct rpc_version mnt_version1 = { 506static struct rpc_version mnt_version1 = {
507 .number = 1, 507 .number = 1,
508 .nrprocs = 2, 508 .nrprocs = ARRAY_SIZE(mnt_procedures),
509 .procs = mnt_procedures, 509 .procs = mnt_procedures,
510}; 510};
511 511
512static struct rpc_version mnt_version3 = { 512static struct rpc_version mnt_version3 = {
513 .number = 3, 513 .number = 3,
514 .nrprocs = 2, 514 .nrprocs = ARRAY_SIZE(mnt3_procedures),
515 .procs = mnt3_procedures, 515 .procs = mnt3_procedures,
516}; 516};
517 517
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index e6bf45710cc7..5914a1911c95 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -423,7 +423,7 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
423 struct page **page; 423 struct page **page;
424 size_t hdrlen; 424 size_t hdrlen;
425 unsigned int pglen, recvd; 425 unsigned int pglen, recvd;
426 int status, nr = 0; 426 int status;
427 427
428 if ((status = ntohl(*p++))) 428 if ((status = ntohl(*p++)))
429 return nfs_stat_to_errno(status); 429 return nfs_stat_to_errno(status);
@@ -443,7 +443,7 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
443 if (pglen > recvd) 443 if (pglen > recvd)
444 pglen = recvd; 444 pglen = recvd;
445 page = rcvbuf->pages; 445 page = rcvbuf->pages;
446 return nr; 446 return pglen;
447} 447}
448 448
449static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) 449static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
@@ -485,6 +485,8 @@ nfs_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, struct nfs_se
485 entry->prev_cookie = entry->cookie; 485 entry->prev_cookie = entry->cookie;
486 entry->cookie = ntohl(*p++); 486 entry->cookie = ntohl(*p++);
487 487
488 entry->d_type = DT_UNKNOWN;
489
488 p = xdr_inline_peek(xdr, 8); 490 p = xdr_inline_peek(xdr, 8);
489 if (p != NULL) 491 if (p != NULL)
490 entry->eof = !p[0] && p[1]; 492 entry->eof = !p[0] && p[1];
@@ -495,7 +497,7 @@ nfs_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, struct nfs_se
495 497
496out_overflow: 498out_overflow:
497 print_overflow_msg(__func__, xdr); 499 print_overflow_msg(__func__, xdr);
498 return ERR_PTR(-EIO); 500 return ERR_PTR(-EAGAIN);
499} 501}
500 502
501/* 503/*
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index d9a5e832c257..f6cc60f06dac 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -555,7 +555,7 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res
555 struct page **page; 555 struct page **page;
556 size_t hdrlen; 556 size_t hdrlen;
557 u32 recvd, pglen; 557 u32 recvd, pglen;
558 int status, nr = 0; 558 int status;
559 559
560 status = ntohl(*p++); 560 status = ntohl(*p++);
561 /* Decode post_op_attrs */ 561 /* Decode post_op_attrs */
@@ -586,7 +586,7 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res
586 pglen = recvd; 586 pglen = recvd;
587 page = rcvbuf->pages; 587 page = rcvbuf->pages;
588 588
589 return nr; 589 return pglen;
590} 590}
591 591
592__be32 * 592__be32 *
@@ -622,11 +622,13 @@ nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, struct nfs_s
622 entry->prev_cookie = entry->cookie; 622 entry->prev_cookie = entry->cookie;
623 p = xdr_decode_hyper(p, &entry->cookie); 623 p = xdr_decode_hyper(p, &entry->cookie);
624 624
625 entry->d_type = DT_UNKNOWN;
625 if (plus) { 626 if (plus) {
626 entry->fattr->valid = 0; 627 entry->fattr->valid = 0;
627 p = xdr_decode_post_op_attr_stream(xdr, entry->fattr); 628 p = xdr_decode_post_op_attr_stream(xdr, entry->fattr);
628 if (IS_ERR(p)) 629 if (IS_ERR(p))
629 goto out_overflow_exit; 630 goto out_overflow_exit;
631 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
630 /* In fact, a post_op_fh3: */ 632 /* In fact, a post_op_fh3: */
631 p = xdr_inline_decode(xdr, 4); 633 p = xdr_inline_decode(xdr, 4);
632 if (unlikely(!p)) 634 if (unlikely(!p))
@@ -656,7 +658,7 @@ nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, struct nfs_s
656out_overflow: 658out_overflow:
657 print_overflow_msg(__func__, xdr); 659 print_overflow_msg(__func__, xdr);
658out_overflow_exit: 660out_overflow_exit:
659 return ERR_PTR(-EIO); 661 return ERR_PTR(-EAGAIN);
660} 662}
661 663
662/* 664/*
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 0f24cdf2cb13..4435e5e1f904 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2852,8 +2852,10 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
2852 nfs4_setup_readdir(cookie, NFS_COOKIEVERF(dir), dentry, &args); 2852 nfs4_setup_readdir(cookie, NFS_COOKIEVERF(dir), dentry, &args);
2853 res.pgbase = args.pgbase; 2853 res.pgbase = args.pgbase;
2854 status = nfs4_call_sync(NFS_SERVER(dir), &msg, &args, &res, 0); 2854 status = nfs4_call_sync(NFS_SERVER(dir), &msg, &args, &res, 0);
2855 if (status == 0) 2855 if (status >= 0) {
2856 memcpy(NFS_COOKIEVERF(dir), res.verifier.data, NFS4_VERIFIER_SIZE); 2856 memcpy(NFS_COOKIEVERF(dir), res.verifier.data, NFS4_VERIFIER_SIZE);
2857 status += args.pgbase;
2858 }
2857 2859
2858 nfs_invalidate_atime(dir); 2860 nfs_invalidate_atime(dir);
2859 2861
@@ -3359,6 +3361,8 @@ static ssize_t nfs4_proc_get_acl(struct inode *inode, void *buf, size_t buflen)
3359 ret = nfs_revalidate_inode(server, inode); 3361 ret = nfs_revalidate_inode(server, inode);
3360 if (ret < 0) 3362 if (ret < 0)
3361 return ret; 3363 return ret;
3364 if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL)
3365 nfs_zap_acl_cache(inode);
3362 ret = nfs4_read_cached_acl(inode, buf, buflen); 3366 ret = nfs4_read_cached_acl(inode, buf, buflen);
3363 if (ret != -ENOENT) 3367 if (ret != -ENOENT)
3364 return ret; 3368 return ret;
@@ -3387,6 +3391,13 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
3387 nfs_inode_return_delegation(inode); 3391 nfs_inode_return_delegation(inode);
3388 buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase); 3392 buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase);
3389 ret = nfs4_call_sync(server, &msg, &arg, &res, 1); 3393 ret = nfs4_call_sync(server, &msg, &arg, &res, 1);
3394 /*
3395 * Acl update can result in inode attribute update.
3396 * so mark the attribute cache invalid.
3397 */
3398 spin_lock(&inode->i_lock);
3399 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATTR;
3400 spin_unlock(&inode->i_lock);
3390 nfs_access_zap_cache(inode); 3401 nfs_access_zap_cache(inode);
3391 nfs_zap_acl_cache(inode); 3402 nfs_zap_acl_cache(inode);
3392 return ret; 3403 return ret;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index f313c4cce7e4..9f1826b012e6 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4518,7 +4518,7 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
4518 xdr_read_pages(xdr, pglen); 4518 xdr_read_pages(xdr, pglen);
4519 4519
4520 4520
4521 return 0; 4521 return pglen;
4522} 4522}
4523 4523
4524static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) 4524static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req)
@@ -6208,6 +6208,10 @@ __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
6208 if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID) 6208 if (entry->fattr->valid & NFS_ATTR_FATTR_FILEID)
6209 entry->ino = entry->fattr->fileid; 6209 entry->ino = entry->fattr->fileid;
6210 6210
6211 entry->d_type = DT_UNKNOWN;
6212 if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE)
6213 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
6214
6211 if (verify_attr_len(xdr, p, len) < 0) 6215 if (verify_attr_len(xdr, p, len) < 0)
6212 goto out_overflow; 6216 goto out_overflow;
6213 6217
@@ -6221,7 +6225,7 @@ __be32 *nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
6221 6225
6222out_overflow: 6226out_overflow:
6223 print_overflow_msg(__func__, xdr); 6227 print_overflow_msg(__func__, xdr);
6224 return ERR_PTR(-EIO); 6228 return ERR_PTR(-EAGAIN);
6225} 6229}
6226 6230
6227/* 6231/*
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 137b549e63db..b68536cc9046 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -115,7 +115,7 @@ int nfs_set_page_tag_locked(struct nfs_page *req)
115{ 115{
116 if (!nfs_lock_request_dontget(req)) 116 if (!nfs_lock_request_dontget(req))
117 return 0; 117 return 0;
118 if (req->wb_page != NULL) 118 if (test_bit(PG_MAPPED, &req->wb_flags))
119 radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); 119 radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
120 return 1; 120 return 1;
121} 121}
@@ -125,7 +125,7 @@ int nfs_set_page_tag_locked(struct nfs_page *req)
125 */ 125 */
126void nfs_clear_page_tag_locked(struct nfs_page *req) 126void nfs_clear_page_tag_locked(struct nfs_page *req)
127{ 127{
128 if (req->wb_page != NULL) { 128 if (test_bit(PG_MAPPED, &req->wb_flags)) {
129 struct inode *inode = req->wb_context->path.dentry->d_inode; 129 struct inode *inode = req->wb_context->path.dentry->d_inode;
130 struct nfs_inode *nfsi = NFS_I(inode); 130 struct nfs_inode *nfsi = NFS_I(inode);
131 131
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index e4b62c6f5a6e..aedcaa7f291f 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -152,7 +152,6 @@ static void nfs_readpage_release(struct nfs_page *req)
152 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), 152 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
153 req->wb_bytes, 153 req->wb_bytes,
154 (long long)req_offset(req)); 154 (long long)req_offset(req));
155 nfs_clear_request(req);
156 nfs_release_request(req); 155 nfs_release_request(req);
157} 156}
158 157
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 0a42e8f4adcb..4100630c9a5b 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -39,7 +39,6 @@
39#include <linux/nfs_mount.h> 39#include <linux/nfs_mount.h>
40#include <linux/nfs4_mount.h> 40#include <linux/nfs4_mount.h>
41#include <linux/lockd/bind.h> 41#include <linux/lockd/bind.h>
42#include <linux/smp_lock.h>
43#include <linux/seq_file.h> 42#include <linux/seq_file.h>
44#include <linux/mount.h> 43#include <linux/mount.h>
45#include <linux/mnt_namespace.h> 44#include <linux/mnt_namespace.h>
@@ -67,6 +66,12 @@
67 66
68#define NFSDBG_FACILITY NFSDBG_VFS 67#define NFSDBG_FACILITY NFSDBG_VFS
69 68
69#ifdef CONFIG_NFS_V3
70#define NFS_DEFAULT_VERSION 3
71#else
72#define NFS_DEFAULT_VERSION 2
73#endif
74
70enum { 75enum {
71 /* Mount options that take no arguments */ 76 /* Mount options that take no arguments */
72 Opt_soft, Opt_hard, 77 Opt_soft, Opt_hard,
@@ -1064,12 +1069,10 @@ static int nfs_parse_mount_options(char *raw,
1064 mnt->flags |= NFS_MOUNT_VER3; 1069 mnt->flags |= NFS_MOUNT_VER3;
1065 mnt->version = 3; 1070 mnt->version = 3;
1066 break; 1071 break;
1067#ifdef CONFIG_NFS_V4
1068 case Opt_v4: 1072 case Opt_v4:
1069 mnt->flags &= ~NFS_MOUNT_VER3; 1073 mnt->flags &= ~NFS_MOUNT_VER3;
1070 mnt->version = 4; 1074 mnt->version = 4;
1071 break; 1075 break;
1072#endif
1073 case Opt_udp: 1076 case Opt_udp:
1074 mnt->flags &= ~NFS_MOUNT_TCP; 1077 mnt->flags &= ~NFS_MOUNT_TCP;
1075 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; 1078 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
@@ -1281,12 +1284,10 @@ static int nfs_parse_mount_options(char *raw,
1281 mnt->flags |= NFS_MOUNT_VER3; 1284 mnt->flags |= NFS_MOUNT_VER3;
1282 mnt->version = 3; 1285 mnt->version = 3;
1283 break; 1286 break;
1284#ifdef CONFIG_NFS_V4
1285 case NFS4_VERSION: 1287 case NFS4_VERSION:
1286 mnt->flags &= ~NFS_MOUNT_VER3; 1288 mnt->flags &= ~NFS_MOUNT_VER3;
1287 mnt->version = 4; 1289 mnt->version = 4;
1288 break; 1290 break;
1289#endif
1290 default: 1291 default:
1291 goto out_invalid_value; 1292 goto out_invalid_value;
1292 } 1293 }
@@ -2277,7 +2278,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2277 }; 2278 };
2278 int error = -ENOMEM; 2279 int error = -ENOMEM;
2279 2280
2280 data = nfs_alloc_parsed_mount_data(3); 2281 data = nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION);
2281 mntfh = nfs_alloc_fhandle(); 2282 mntfh = nfs_alloc_fhandle();
2282 if (data == NULL || mntfh == NULL) 2283 if (data == NULL || mntfh == NULL)
2283 goto out_free_fh; 2284 goto out_free_fh;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 4c14c17a5276..10d648ea128b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -390,6 +390,7 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
390 if (nfs_have_delegation(inode, FMODE_WRITE)) 390 if (nfs_have_delegation(inode, FMODE_WRITE))
391 nfsi->change_attr++; 391 nfsi->change_attr++;
392 } 392 }
393 set_bit(PG_MAPPED, &req->wb_flags);
393 SetPagePrivate(req->wb_page); 394 SetPagePrivate(req->wb_page);
394 set_page_private(req->wb_page, (unsigned long)req); 395 set_page_private(req->wb_page, (unsigned long)req);
395 nfsi->npages++; 396 nfsi->npages++;
@@ -415,6 +416,7 @@ static void nfs_inode_remove_request(struct nfs_page *req)
415 spin_lock(&inode->i_lock); 416 spin_lock(&inode->i_lock);
416 set_page_private(req->wb_page, 0); 417 set_page_private(req->wb_page, 0);
417 ClearPagePrivate(req->wb_page); 418 ClearPagePrivate(req->wb_page);
419 clear_bit(PG_MAPPED, &req->wb_flags);
418 radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index); 420 radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index);
419 nfsi->npages--; 421 nfsi->npages--;
420 if (!nfsi->npages) { 422 if (!nfsi->npages) {
@@ -422,7 +424,6 @@ static void nfs_inode_remove_request(struct nfs_page *req)
422 iput(inode); 424 iput(inode);
423 } else 425 } else
424 spin_unlock(&inode->i_lock); 426 spin_unlock(&inode->i_lock);
425 nfs_clear_request(req);
426 nfs_release_request(req); 427 nfs_release_request(req);
427} 428}
428 429
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 2a533a0af2a9..7e84a852cdae 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -260,9 +260,11 @@ void fill_post_wcc(struct svc_fh *fhp)
260 err = vfs_getattr(fhp->fh_export->ex_path.mnt, fhp->fh_dentry, 260 err = vfs_getattr(fhp->fh_export->ex_path.mnt, fhp->fh_dentry,
261 &fhp->fh_post_attr); 261 &fhp->fh_post_attr);
262 fhp->fh_post_change = fhp->fh_dentry->d_inode->i_version; 262 fhp->fh_post_change = fhp->fh_dentry->d_inode->i_version;
263 if (err) 263 if (err) {
264 fhp->fh_post_saved = 0; 264 fhp->fh_post_saved = 0;
265 else 265 /* Grab the ctime anyway - set_change_info might use it */
266 fhp->fh_post_attr.ctime = fhp->fh_dentry->d_inode->i_ctime;
267 } else
266 fhp->fh_post_saved = 1; 268 fhp->fh_post_saved = 1;
267} 269}
268 270
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index ad2bfa68d534..116cab970e0f 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2262,7 +2262,7 @@ nfs4_file_downgrade(struct nfs4_file *fp, unsigned int share_access)
2262 * Spawn a thread to perform a recall on the delegation represented 2262 * Spawn a thread to perform a recall on the delegation represented
2263 * by the lease (file_lock) 2263 * by the lease (file_lock)
2264 * 2264 *
2265 * Called from break_lease() with lock_kernel() held. 2265 * Called from break_lease() with lock_flocks() held.
2266 * Note: we assume break_lease will only call this *once* for any given 2266 * Note: we assume break_lease will only call this *once* for any given
2267 * lease. 2267 * lease.
2268 */ 2268 */
@@ -2286,7 +2286,7 @@ void nfsd_break_deleg_cb(struct file_lock *fl)
2286 list_add_tail(&dp->dl_recall_lru, &del_recall_lru); 2286 list_add_tail(&dp->dl_recall_lru, &del_recall_lru);
2287 spin_unlock(&recall_lock); 2287 spin_unlock(&recall_lock);
2288 2288
2289 /* only place dl_time is set. protected by lock_kernel*/ 2289 /* only place dl_time is set. protected by lock_flocks*/
2290 dp->dl_time = get_seconds(); 2290 dp->dl_time = get_seconds();
2291 2291
2292 /* 2292 /*
@@ -2303,7 +2303,7 @@ void nfsd_break_deleg_cb(struct file_lock *fl)
2303/* 2303/*
2304 * The file_lock is being reapd. 2304 * The file_lock is being reapd.
2305 * 2305 *
2306 * Called by locks_free_lock() with lock_kernel() held. 2306 * Called by locks_free_lock() with lock_flocks() held.
2307 */ 2307 */
2308static 2308static
2309void nfsd_release_deleg_cb(struct file_lock *fl) 2309void nfsd_release_deleg_cb(struct file_lock *fl)
@@ -2318,7 +2318,7 @@ void nfsd_release_deleg_cb(struct file_lock *fl)
2318} 2318}
2319 2319
2320/* 2320/*
2321 * Called from setlease() with lock_kernel() held 2321 * Called from setlease() with lock_flocks() held
2322 */ 2322 */
2323static 2323static
2324int nfsd_same_client_deleg_cb(struct file_lock *onlist, struct file_lock *try) 2324int nfsd_same_client_deleg_cb(struct file_lock *onlist, struct file_lock *try)
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
index 4d476ff08ae6..60fce3dc5cb5 100644
--- a/fs/nfsd/xdr4.h
+++ b/fs/nfsd/xdr4.h
@@ -484,18 +484,17 @@ static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp)
484static inline void 484static inline void
485set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp) 485set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
486{ 486{
487 BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved); 487 BUG_ON(!fhp->fh_pre_saved);
488 cinfo->atomic = 1; 488 cinfo->atomic = fhp->fh_post_saved;
489 cinfo->change_supported = IS_I_VERSION(fhp->fh_dentry->d_inode); 489 cinfo->change_supported = IS_I_VERSION(fhp->fh_dentry->d_inode);
490 if (cinfo->change_supported) { 490
491 cinfo->before_change = fhp->fh_pre_change; 491 cinfo->before_change = fhp->fh_pre_change;
492 cinfo->after_change = fhp->fh_post_change; 492 cinfo->after_change = fhp->fh_post_change;
493 } else { 493 cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
494 cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec; 494 cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
495 cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec; 495 cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
496 cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec; 496 cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
497 cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec; 497
498 }
499} 498}
500 499
501int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *); 500int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
index 49c844dab33a..59e5fe742f7b 100644
--- a/fs/nilfs2/dat.c
+++ b/fs/nilfs2/dat.c
@@ -335,7 +335,7 @@ int nilfs_dat_move(struct inode *dat, __u64 vblocknr, sector_t blocknr)
335 * the device at this point. 335 * the device at this point.
336 * 336 *
337 * To prevent nilfs_dat_translate() from returning the 337 * To prevent nilfs_dat_translate() from returning the
338 * uncommited block number, this makes a copy of the entry 338 * uncommitted block number, this makes a copy of the entry
339 * buffer and redirects nilfs_dat_translate() to the copy. 339 * buffer and redirects nilfs_dat_translate() to the copy.
340 */ 340 */
341 if (!buffer_nilfs_redirected(entry_bh)) { 341 if (!buffer_nilfs_redirected(entry_bh)) {
diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c
index 33ad25ddd5c4..caf9a6a3fb54 100644
--- a/fs/nilfs2/gcinode.c
+++ b/fs/nilfs2/gcinode.c
@@ -176,7 +176,6 @@ int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *bh)
176int nilfs_init_gcinode(struct inode *inode) 176int nilfs_init_gcinode(struct inode *inode)
177{ 177{
178 struct nilfs_inode_info *ii = NILFS_I(inode); 178 struct nilfs_inode_info *ii = NILFS_I(inode);
179 struct the_nilfs *nilfs = NILFS_SB(inode->i_sb)->s_nilfs;
180 179
181 inode->i_mode = S_IFREG; 180 inode->i_mode = S_IFREG;
182 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS); 181 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
@@ -186,14 +185,6 @@ int nilfs_init_gcinode(struct inode *inode)
186 ii->i_flags = 0; 185 ii->i_flags = 0;
187 nilfs_bmap_init_gc(ii->i_bmap); 186 nilfs_bmap_init_gc(ii->i_bmap);
188 187
189 /*
190 * Add the inode to GC inode list. Garbage Collection
191 * is serialized and no two processes manipulate the
192 * list simultaneously.
193 */
194 igrab(inode);
195 list_add(&NILFS_I(inode)->i_dirty, &nilfs->ns_gc_inodes);
196
197 return 0; 188 return 0;
198} 189}
199 190
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 3e90f86d5bfe..b185e937a335 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -337,6 +337,7 @@ static int nilfs_ioctl_move_blocks(struct super_block *sb,
337 struct nilfs_argv *argv, void *buf) 337 struct nilfs_argv *argv, void *buf)
338{ 338{
339 size_t nmembs = argv->v_nmembs; 339 size_t nmembs = argv->v_nmembs;
340 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs;
340 struct inode *inode; 341 struct inode *inode;
341 struct nilfs_vdesc *vdesc; 342 struct nilfs_vdesc *vdesc;
342 struct buffer_head *bh, *n; 343 struct buffer_head *bh, *n;
@@ -349,10 +350,21 @@ static int nilfs_ioctl_move_blocks(struct super_block *sb,
349 ino = vdesc->vd_ino; 350 ino = vdesc->vd_ino;
350 cno = vdesc->vd_cno; 351 cno = vdesc->vd_cno;
351 inode = nilfs_iget_for_gc(sb, ino, cno); 352 inode = nilfs_iget_for_gc(sb, ino, cno);
352 if (unlikely(inode == NULL)) { 353 if (IS_ERR(inode)) {
353 ret = -ENOMEM; 354 ret = PTR_ERR(inode);
354 goto failed; 355 goto failed;
355 } 356 }
357 if (list_empty(&NILFS_I(inode)->i_dirty)) {
358 /*
359 * Add the inode to GC inode list. Garbage Collection
360 * is serialized and no two processes manipulate the
361 * list simultaneously.
362 */
363 igrab(inode);
364 list_add(&NILFS_I(inode)->i_dirty,
365 &nilfs->ns_gc_inodes);
366 }
367
356 do { 368 do {
357 ret = nilfs_ioctl_move_inode_block(inode, vdesc, 369 ret = nilfs_ioctl_move_inode_block(inode, vdesc,
358 &buffers); 370 &buffers);
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index b04f88eed09e..f35794b97e8e 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -92,7 +92,11 @@ static int fanotify_get_response_from_access(struct fsnotify_group *group,
92 92
93 pr_debug("%s: group=%p event=%p\n", __func__, group, event); 93 pr_debug("%s: group=%p event=%p\n", __func__, group, event);
94 94
95 wait_event(group->fanotify_data.access_waitq, event->response); 95 wait_event(group->fanotify_data.access_waitq, event->response ||
96 atomic_read(&group->fanotify_data.bypass_perm));
97
98 if (!event->response) /* bypass_perm set */
99 return 0;
96 100
97 /* userspace responded, convert to something usable */ 101 /* userspace responded, convert to something usable */
98 spin_lock(&event->lock); 102 spin_lock(&event->lock);
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 063224812b7e..8b61220cffc5 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -106,20 +106,29 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event)
106 return client_fd; 106 return client_fd;
107} 107}
108 108
109static ssize_t fill_event_metadata(struct fsnotify_group *group, 109static int fill_event_metadata(struct fsnotify_group *group,
110 struct fanotify_event_metadata *metadata, 110 struct fanotify_event_metadata *metadata,
111 struct fsnotify_event *event) 111 struct fsnotify_event *event)
112{ 112{
113 int ret = 0;
114
113 pr_debug("%s: group=%p metadata=%p event=%p\n", __func__, 115 pr_debug("%s: group=%p metadata=%p event=%p\n", __func__,
114 group, metadata, event); 116 group, metadata, event);
115 117
116 metadata->event_len = FAN_EVENT_METADATA_LEN; 118 metadata->event_len = FAN_EVENT_METADATA_LEN;
119 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
117 metadata->vers = FANOTIFY_METADATA_VERSION; 120 metadata->vers = FANOTIFY_METADATA_VERSION;
118 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS; 121 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
119 metadata->pid = pid_vnr(event->tgid); 122 metadata->pid = pid_vnr(event->tgid);
120 metadata->fd = create_fd(group, event); 123 if (unlikely(event->mask & FAN_Q_OVERFLOW))
124 metadata->fd = FAN_NOFD;
125 else {
126 metadata->fd = create_fd(group, event);
127 if (metadata->fd < 0)
128 ret = metadata->fd;
129 }
121 130
122 return metadata->fd; 131 return ret;
123} 132}
124 133
125#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS 134#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
@@ -200,7 +209,7 @@ static int prepare_for_access_response(struct fsnotify_group *group,
200 209
201 mutex_lock(&group->fanotify_data.access_mutex); 210 mutex_lock(&group->fanotify_data.access_mutex);
202 211
203 if (group->fanotify_data.bypass_perm) { 212 if (atomic_read(&group->fanotify_data.bypass_perm)) {
204 mutex_unlock(&group->fanotify_data.access_mutex); 213 mutex_unlock(&group->fanotify_data.access_mutex);
205 kmem_cache_free(fanotify_response_event_cache, re); 214 kmem_cache_free(fanotify_response_event_cache, re);
206 event->response = FAN_ALLOW; 215 event->response = FAN_ALLOW;
@@ -257,24 +266,34 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
257 266
258 pr_debug("%s: group=%p event=%p\n", __func__, group, event); 267 pr_debug("%s: group=%p event=%p\n", __func__, group, event);
259 268
260 fd = fill_event_metadata(group, &fanotify_event_metadata, event); 269 ret = fill_event_metadata(group, &fanotify_event_metadata, event);
261 if (fd < 0) 270 if (ret < 0)
262 return fd; 271 goto out;
263 272
273 fd = fanotify_event_metadata.fd;
264 ret = prepare_for_access_response(group, event, fd); 274 ret = prepare_for_access_response(group, event, fd);
265 if (ret) 275 if (ret)
266 goto out_close_fd; 276 goto out_close_fd;
267 277
268 ret = -EFAULT; 278 ret = -EFAULT;
269 if (copy_to_user(buf, &fanotify_event_metadata, FAN_EVENT_METADATA_LEN)) 279 if (copy_to_user(buf, &fanotify_event_metadata,
280 fanotify_event_metadata.event_len))
270 goto out_kill_access_response; 281 goto out_kill_access_response;
271 282
272 return FAN_EVENT_METADATA_LEN; 283 return fanotify_event_metadata.event_len;
273 284
274out_kill_access_response: 285out_kill_access_response:
275 remove_access_response(group, event, fd); 286 remove_access_response(group, event, fd);
276out_close_fd: 287out_close_fd:
277 sys_close(fd); 288 if (fd != FAN_NOFD)
289 sys_close(fd);
290out:
291#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
292 if (event->mask & FAN_ALL_PERM_EVENTS) {
293 event->response = FAN_DENY;
294 wake_up(&group->fanotify_data.access_waitq);
295 }
296#endif
278 return ret; 297 return ret;
279} 298}
280 299
@@ -382,7 +401,7 @@ static int fanotify_release(struct inode *ignored, struct file *file)
382 401
383 mutex_lock(&group->fanotify_data.access_mutex); 402 mutex_lock(&group->fanotify_data.access_mutex);
384 403
385 group->fanotify_data.bypass_perm = true; 404 atomic_inc(&group->fanotify_data.bypass_perm);
386 405
387 list_for_each_entry_safe(re, lre, &group->fanotify_data.access_list, list) { 406 list_for_each_entry_safe(re, lre, &group->fanotify_data.access_list, list) {
388 pr_debug("%s: found group=%p re=%p event=%p\n", __func__, group, 407 pr_debug("%s: found group=%p re=%p event=%p\n", __func__, group,
@@ -586,11 +605,10 @@ static int fanotify_add_vfsmount_mark(struct fsnotify_group *group,
586{ 605{
587 struct fsnotify_mark *fsn_mark; 606 struct fsnotify_mark *fsn_mark;
588 __u32 added; 607 __u32 added;
608 int ret = 0;
589 609
590 fsn_mark = fsnotify_find_vfsmount_mark(group, mnt); 610 fsn_mark = fsnotify_find_vfsmount_mark(group, mnt);
591 if (!fsn_mark) { 611 if (!fsn_mark) {
592 int ret;
593
594 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks) 612 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks)
595 return -ENOSPC; 613 return -ENOSPC;
596 614
@@ -600,17 +618,16 @@ static int fanotify_add_vfsmount_mark(struct fsnotify_group *group,
600 618
601 fsnotify_init_mark(fsn_mark, fanotify_free_mark); 619 fsnotify_init_mark(fsn_mark, fanotify_free_mark);
602 ret = fsnotify_add_mark(fsn_mark, group, NULL, mnt, 0); 620 ret = fsnotify_add_mark(fsn_mark, group, NULL, mnt, 0);
603 if (ret) { 621 if (ret)
604 fanotify_free_mark(fsn_mark); 622 goto err;
605 return ret;
606 }
607 } 623 }
608 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags); 624 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);
609 fsnotify_put_mark(fsn_mark); 625
610 if (added & ~mnt->mnt_fsnotify_mask) 626 if (added & ~mnt->mnt_fsnotify_mask)
611 fsnotify_recalc_vfsmount_mask(mnt); 627 fsnotify_recalc_vfsmount_mask(mnt);
612 628err:
613 return 0; 629 fsnotify_put_mark(fsn_mark);
630 return ret;
614} 631}
615 632
616static int fanotify_add_inode_mark(struct fsnotify_group *group, 633static int fanotify_add_inode_mark(struct fsnotify_group *group,
@@ -619,6 +636,7 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group,
619{ 636{
620 struct fsnotify_mark *fsn_mark; 637 struct fsnotify_mark *fsn_mark;
621 __u32 added; 638 __u32 added;
639 int ret = 0;
622 640
623 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode); 641 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode);
624 642
@@ -634,8 +652,6 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group,
634 652
635 fsn_mark = fsnotify_find_inode_mark(group, inode); 653 fsn_mark = fsnotify_find_inode_mark(group, inode);
636 if (!fsn_mark) { 654 if (!fsn_mark) {
637 int ret;
638
639 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks) 655 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks)
640 return -ENOSPC; 656 return -ENOSPC;
641 657
@@ -645,16 +661,16 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group,
645 661
646 fsnotify_init_mark(fsn_mark, fanotify_free_mark); 662 fsnotify_init_mark(fsn_mark, fanotify_free_mark);
647 ret = fsnotify_add_mark(fsn_mark, group, inode, NULL, 0); 663 ret = fsnotify_add_mark(fsn_mark, group, inode, NULL, 0);
648 if (ret) { 664 if (ret)
649 fanotify_free_mark(fsn_mark); 665 goto err;
650 return ret;
651 }
652 } 666 }
653 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags); 667 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);
654 fsnotify_put_mark(fsn_mark); 668
655 if (added & ~inode->i_fsnotify_mask) 669 if (added & ~inode->i_fsnotify_mask)
656 fsnotify_recalc_inode_mask(inode); 670 fsnotify_recalc_inode_mask(inode);
657 return 0; 671err:
672 fsnotify_put_mark(fsn_mark);
673 return ret;
658} 674}
659 675
660/* fanotify syscalls */ 676/* fanotify syscalls */
@@ -687,8 +703,10 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
687 703
688 /* fsnotify_alloc_group takes a ref. Dropped in fanotify_release */ 704 /* fsnotify_alloc_group takes a ref. Dropped in fanotify_release */
689 group = fsnotify_alloc_group(&fanotify_fsnotify_ops); 705 group = fsnotify_alloc_group(&fanotify_fsnotify_ops);
690 if (IS_ERR(group)) 706 if (IS_ERR(group)) {
707 free_uid(user);
691 return PTR_ERR(group); 708 return PTR_ERR(group);
709 }
692 710
693 group->fanotify_data.user = user; 711 group->fanotify_data.user = user;
694 atomic_inc(&user->fanotify_listeners); 712 atomic_inc(&user->fanotify_listeners);
@@ -698,6 +716,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
698 mutex_init(&group->fanotify_data.access_mutex); 716 mutex_init(&group->fanotify_data.access_mutex);
699 init_waitqueue_head(&group->fanotify_data.access_waitq); 717 init_waitqueue_head(&group->fanotify_data.access_waitq);
700 INIT_LIST_HEAD(&group->fanotify_data.access_list); 718 INIT_LIST_HEAD(&group->fanotify_data.access_list);
719 atomic_set(&group->fanotify_data.bypass_perm, 0);
701#endif 720#endif
702 switch (flags & FAN_ALL_CLASS_BITS) { 721 switch (flags & FAN_ALL_CLASS_BITS) {
703 case FAN_CLASS_NOTIF: 722 case FAN_CLASS_NOTIF:
@@ -764,8 +783,10 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags,
764 if (flags & ~FAN_ALL_MARK_FLAGS) 783 if (flags & ~FAN_ALL_MARK_FLAGS)
765 return -EINVAL; 784 return -EINVAL;
766 switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) { 785 switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) {
767 case FAN_MARK_ADD: 786 case FAN_MARK_ADD: /* fallthrough */
768 case FAN_MARK_REMOVE: 787 case FAN_MARK_REMOVE:
788 if (!mask)
789 return -EINVAL;
769 case FAN_MARK_FLUSH: 790 case FAN_MARK_FLUSH:
770 break; 791 break;
771 default: 792 default:
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 444c305a468c..4cd5d5d78f9f 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -752,6 +752,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
752 if (ret >= 0) 752 if (ret >= 0)
753 return ret; 753 return ret;
754 754
755 fsnotify_put_group(group);
755 atomic_dec(&user->inotify_devs); 756 atomic_dec(&user->inotify_devs);
756out_free_uid: 757out_free_uid:
757 free_uid(user); 758 free_uid(user);
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 52c7557f3e25..9f26ac9be2a4 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1964,8 +1964,10 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
1964 if (reg == NULL) 1964 if (reg == NULL)
1965 return ERR_PTR(-ENOMEM); 1965 return ERR_PTR(-ENOMEM);
1966 1966
1967 if (strlen(name) > O2HB_MAX_REGION_NAME_LEN) 1967 if (strlen(name) > O2HB_MAX_REGION_NAME_LEN) {
1968 return ERR_PTR(-ENAMETOOLONG); 1968 ret = -ENAMETOOLONG;
1969 goto free;
1970 }
1969 1971
1970 spin_lock(&o2hb_live_lock); 1972 spin_lock(&o2hb_live_lock);
1971 reg->hr_region_num = 0; 1973 reg->hr_region_num = 0;
@@ -1974,7 +1976,8 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
1974 O2NM_MAX_REGIONS); 1976 O2NM_MAX_REGIONS);
1975 if (reg->hr_region_num >= O2NM_MAX_REGIONS) { 1977 if (reg->hr_region_num >= O2NM_MAX_REGIONS) {
1976 spin_unlock(&o2hb_live_lock); 1978 spin_unlock(&o2hb_live_lock);
1977 return ERR_PTR(-EFBIG); 1979 ret = -EFBIG;
1980 goto free;
1978 } 1981 }
1979 set_bit(reg->hr_region_num, o2hb_region_bitmap); 1982 set_bit(reg->hr_region_num, o2hb_region_bitmap);
1980 } 1983 }
@@ -1986,10 +1989,13 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
1986 ret = o2hb_debug_region_init(reg, o2hb_debug_dir); 1989 ret = o2hb_debug_region_init(reg, o2hb_debug_dir);
1987 if (ret) { 1990 if (ret) {
1988 config_item_put(&reg->hr_item); 1991 config_item_put(&reg->hr_item);
1989 return ERR_PTR(ret); 1992 goto free;
1990 } 1993 }
1991 1994
1992 return &reg->hr_item; 1995 return &reg->hr_item;
1996free:
1997 kfree(reg);
1998 return ERR_PTR(ret);
1993} 1999}
1994 2000
1995static void o2hb_heartbeat_group_drop_item(struct config_group *group, 2001static void o2hb_heartbeat_group_drop_item(struct config_group *group,
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index edaded48e7e9..895532ac4d98 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -476,7 +476,6 @@ static void ocfs2_dentry_iput(struct dentry *dentry, struct inode *inode)
476 476
477out: 477out:
478 iput(inode); 478 iput(inode);
479 ocfs2_dentry_attach_gen(dentry);
480} 479}
481 480
482/* 481/*
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 58a93b953735..cc2aaa96cfe5 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -959,7 +959,7 @@ static int dlm_match_regions(struct dlm_ctxt *dlm,
959 r += O2HB_MAX_REGION_NAME_LEN; 959 r += O2HB_MAX_REGION_NAME_LEN;
960 } 960 }
961 961
962 local = kmalloc(sizeof(qr->qr_regions), GFP_KERNEL); 962 local = kmalloc(sizeof(qr->qr_regions), GFP_ATOMIC);
963 if (!local) { 963 if (!local) {
964 status = -ENOMEM; 964 status = -ENOMEM;
965 goto bail; 965 goto bail;
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 1efea3615589..70dd3b1798f1 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -159,9 +159,9 @@ struct ocfs2_lock_res {
159 char l_name[OCFS2_LOCK_ID_MAX_LEN]; 159 char l_name[OCFS2_LOCK_ID_MAX_LEN];
160 unsigned int l_ro_holders; 160 unsigned int l_ro_holders;
161 unsigned int l_ex_holders; 161 unsigned int l_ex_holders;
162 char l_level; 162 signed char l_level;
163 char l_requested; 163 signed char l_requested;
164 char l_blocking; 164 signed char l_blocking;
165 165
166 /* Data packed - type enum ocfs2_lock_type */ 166 /* Data packed - type enum ocfs2_lock_type */
167 unsigned char l_type; 167 unsigned char l_type;
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index 252e7c82f929..a5ebe421195f 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -190,7 +190,7 @@ static struct ocfs2_live_connection *ocfs2_connection_find(const char *name)
190 return c; 190 return c;
191 } 191 }
192 192
193 return c; 193 return NULL;
194} 194}
195 195
196/* 196/*
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index f02c0ef31578..cfeab7ce3697 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -41,7 +41,6 @@
41#include <linux/mount.h> 41#include <linux/mount.h>
42#include <linux/seq_file.h> 42#include <linux/seq_file.h>
43#include <linux/quotaops.h> 43#include <linux/quotaops.h>
44#include <linux/smp_lock.h>
45 44
46#define MLOG_MASK_PREFIX ML_SUPER 45#define MLOG_MASK_PREFIX ML_SUPER
47#include <cluster/masklog.h> 46#include <cluster/masklog.h>
diff --git a/fs/pipe.c b/fs/pipe.c
index a8012a955720..04629f36e397 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1199,12 +1199,24 @@ int pipe_proc_fn(struct ctl_table *table, int write, void __user *buf,
1199 return ret; 1199 return ret;
1200} 1200}
1201 1201
1202/*
1203 * After the inode slimming patch, i_pipe/i_bdev/i_cdev share the same
1204 * location, so checking ->i_pipe is not enough to verify that this is a
1205 * pipe.
1206 */
1207struct pipe_inode_info *get_pipe_info(struct file *file)
1208{
1209 struct inode *i = file->f_path.dentry->d_inode;
1210
1211 return S_ISFIFO(i->i_mode) ? i->i_pipe : NULL;
1212}
1213
1202long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg) 1214long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
1203{ 1215{
1204 struct pipe_inode_info *pipe; 1216 struct pipe_inode_info *pipe;
1205 long ret; 1217 long ret;
1206 1218
1207 pipe = file->f_path.dentry->d_inode->i_pipe; 1219 pipe = get_pipe_info(file);
1208 if (!pipe) 1220 if (!pipe)
1209 return -EBADF; 1221 return -EBADF;
1210 1222
diff --git a/fs/proc/base.c b/fs/proc/base.c
index f3d02ca461ec..182845147fe4 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1574,7 +1574,7 @@ static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
1574 if (!tmp) 1574 if (!tmp)
1575 return -ENOMEM; 1575 return -ENOMEM;
1576 1576
1577 pathname = d_path_with_unreachable(path, tmp, PAGE_SIZE); 1577 pathname = d_path(path, tmp, PAGE_SIZE);
1578 len = PTR_ERR(pathname); 1578 len = PTR_ERR(pathname);
1579 if (IS_ERR(pathname)) 1579 if (IS_ERR(pathname))
1580 goto out; 1580 goto out;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 9c2b5f484879..3ddb6068177c 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -16,7 +16,6 @@
16#include <linux/limits.h> 16#include <linux/limits.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/smp_lock.h>
20#include <linux/sysctl.h> 19#include <linux/sysctl.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22 21
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index da6b01d70f01..c126c83b9a45 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -706,6 +706,7 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask,
706 * skip over unmapped regions. 706 * skip over unmapped regions.
707 */ 707 */
708#define PAGEMAP_WALK_SIZE (PMD_SIZE) 708#define PAGEMAP_WALK_SIZE (PMD_SIZE)
709#define PAGEMAP_WALK_MASK (PMD_MASK)
709static ssize_t pagemap_read(struct file *file, char __user *buf, 710static ssize_t pagemap_read(struct file *file, char __user *buf,
710 size_t count, loff_t *ppos) 711 size_t count, loff_t *ppos)
711{ 712{
@@ -776,7 +777,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
776 unsigned long end; 777 unsigned long end;
777 778
778 pm.pos = 0; 779 pm.pos = 0;
779 end = start_vaddr + PAGEMAP_WALK_SIZE; 780 end = (start_vaddr + PAGEMAP_WALK_SIZE) & PAGEMAP_WALK_MASK;
780 /* overflow ? */ 781 /* overflow ? */
781 if (end < start_vaddr || end > end_vaddr) 782 if (end < start_vaddr || end > end_vaddr)
782 end = end_vaddr; 783 end = end_vaddr;
diff --git a/fs/read_write.c b/fs/read_write.c
index 431a0ed610c8..5d431bacbea9 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -9,7 +9,6 @@
9#include <linux/fcntl.h> 9#include <linux/fcntl.h>
10#include <linux/file.h> 10#include <linux/file.h>
11#include <linux/uio.h> 11#include <linux/uio.h>
12#include <linux/smp_lock.h>
13#include <linux/fsnotify.h> 12#include <linux/fsnotify.h>
14#include <linux/security.h> 13#include <linux/security.h>
15#include <linux/module.h> 14#include <linux/module.h>
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 41656d40dc5c..0bae036831e2 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -8,7 +8,6 @@
8#include <linux/reiserfs_acl.h> 8#include <linux/reiserfs_acl.h>
9#include <linux/reiserfs_xattr.h> 9#include <linux/reiserfs_xattr.h>
10#include <linux/exportfs.h> 10#include <linux/exportfs.h>
11#include <linux/smp_lock.h>
12#include <linux/pagemap.h> 11#include <linux/pagemap.h>
13#include <linux/highmem.h> 12#include <linux/highmem.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index adf22b485cea..79265fdc317a 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -9,7 +9,6 @@
9#include <linux/time.h> 9#include <linux/time.h>
10#include <asm/uaccess.h> 10#include <asm/uaccess.h>
11#include <linux/pagemap.h> 11#include <linux/pagemap.h>
12#include <linux/smp_lock.h>
13#include <linux/compat.h> 12#include <linux/compat.h>
14 13
15/* 14/*
@@ -184,12 +183,11 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
184 return 0; 183 return 0;
185 } 184 }
186 185
187 /* we need to make sure nobody is changing the file size beneath
188 ** us
189 */
190 reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb);
191 depth = reiserfs_write_lock_once(inode->i_sb); 186 depth = reiserfs_write_lock_once(inode->i_sb);
192 187
188 /* we need to make sure nobody is changing the file size beneath us */
189 reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb);
190
193 write_from = inode->i_size & (blocksize - 1); 191 write_from = inode->i_size & (blocksize - 1);
194 /* if we are on a block boundary, we are already unpacked. */ 192 /* if we are on a block boundary, we are already unpacked. */
195 if (write_from == 0) { 193 if (write_from == 0) {
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 076c8b194682..d31bce1a9f90 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -43,7 +43,6 @@
43#include <linux/fcntl.h> 43#include <linux/fcntl.h>
44#include <linux/stat.h> 44#include <linux/stat.h>
45#include <linux/string.h> 45#include <linux/string.h>
46#include <linux/smp_lock.h>
47#include <linux/buffer_head.h> 46#include <linux/buffer_head.h>
48#include <linux/workqueue.h> 47#include <linux/workqueue.h>
49#include <linux/writeback.h> 48#include <linux/writeback.h>
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 3bf7a6457f4d..b243117b8752 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -28,7 +28,6 @@
28#include <linux/mount.h> 28#include <linux/mount.h>
29#include <linux/namei.h> 29#include <linux/namei.h>
30#include <linux/crc32.h> 30#include <linux/crc32.h>
31#include <linux/smp_lock.h>
32 31
33struct file_system_type reiserfs_fs_type; 32struct file_system_type reiserfs_fs_type;
34 33
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index 536d697a8a28..90d2fcb67a31 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -472,7 +472,9 @@ int reiserfs_acl_chmod(struct inode *inode)
472 struct reiserfs_transaction_handle th; 472 struct reiserfs_transaction_handle th;
473 size_t size = reiserfs_xattr_nblocks(inode, 473 size_t size = reiserfs_xattr_nblocks(inode,
474 reiserfs_acl_size(clone->a_count)); 474 reiserfs_acl_size(clone->a_count));
475 reiserfs_write_lock(inode->i_sb); 475 int depth;
476
477 depth = reiserfs_write_lock_once(inode->i_sb);
476 error = journal_begin(&th, inode->i_sb, size * 2); 478 error = journal_begin(&th, inode->i_sb, size * 2);
477 if (!error) { 479 if (!error) {
478 int error2; 480 int error2;
@@ -482,7 +484,7 @@ int reiserfs_acl_chmod(struct inode *inode)
482 if (error2) 484 if (error2)
483 error = error2; 485 error = error2;
484 } 486 }
485 reiserfs_write_unlock(inode->i_sb); 487 reiserfs_write_unlock_once(inode->i_sb, depth);
486 } 488 }
487 posix_acl_release(clone); 489 posix_acl_release(clone);
488 return error; 490 return error;
diff --git a/fs/splice.c b/fs/splice.c
index 8f1dfaecc8f0..ce2f02579e35 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1311,18 +1311,6 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
1311static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe, 1311static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,
1312 struct pipe_inode_info *opipe, 1312 struct pipe_inode_info *opipe,
1313 size_t len, unsigned int flags); 1313 size_t len, unsigned int flags);
1314/*
1315 * After the inode slimming patch, i_pipe/i_bdev/i_cdev share the same
1316 * location, so checking ->i_pipe is not enough to verify that this is a
1317 * pipe.
1318 */
1319static inline struct pipe_inode_info *pipe_info(struct inode *inode)
1320{
1321 if (S_ISFIFO(inode->i_mode))
1322 return inode->i_pipe;
1323
1324 return NULL;
1325}
1326 1314
1327/* 1315/*
1328 * Determine where to splice to/from. 1316 * Determine where to splice to/from.
@@ -1336,8 +1324,8 @@ static long do_splice(struct file *in, loff_t __user *off_in,
1336 loff_t offset, *off; 1324 loff_t offset, *off;
1337 long ret; 1325 long ret;
1338 1326
1339 ipipe = pipe_info(in->f_path.dentry->d_inode); 1327 ipipe = get_pipe_info(in);
1340 opipe = pipe_info(out->f_path.dentry->d_inode); 1328 opipe = get_pipe_info(out);
1341 1329
1342 if (ipipe && opipe) { 1330 if (ipipe && opipe) {
1343 if (off_in || off_out) 1331 if (off_in || off_out)
@@ -1555,7 +1543,7 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *iov,
1555 int error; 1543 int error;
1556 long ret; 1544 long ret;
1557 1545
1558 pipe = pipe_info(file->f_path.dentry->d_inode); 1546 pipe = get_pipe_info(file);
1559 if (!pipe) 1547 if (!pipe)
1560 return -EBADF; 1548 return -EBADF;
1561 1549
@@ -1642,7 +1630,7 @@ static long vmsplice_to_pipe(struct file *file, const struct iovec __user *iov,
1642 }; 1630 };
1643 long ret; 1631 long ret;
1644 1632
1645 pipe = pipe_info(file->f_path.dentry->d_inode); 1633 pipe = get_pipe_info(file);
1646 if (!pipe) 1634 if (!pipe)
1647 return -EBADF; 1635 return -EBADF;
1648 1636
@@ -2022,8 +2010,8 @@ static int link_pipe(struct pipe_inode_info *ipipe,
2022static long do_tee(struct file *in, struct file *out, size_t len, 2010static long do_tee(struct file *in, struct file *out, size_t len,
2023 unsigned int flags) 2011 unsigned int flags)
2024{ 2012{
2025 struct pipe_inode_info *ipipe = pipe_info(in->f_path.dentry->d_inode); 2013 struct pipe_inode_info *ipipe = get_pipe_info(in);
2026 struct pipe_inode_info *opipe = pipe_info(out->f_path.dentry->d_inode); 2014 struct pipe_inode_info *opipe = get_pipe_info(out);
2027 int ret = -EINVAL; 2015 int ret = -EINVAL;
2028 2016
2029 /* 2017 /*
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 7d287afccde5..691f61223ed6 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -934,7 +934,6 @@ xfs_aops_discard_page(
934 struct xfs_inode *ip = XFS_I(inode); 934 struct xfs_inode *ip = XFS_I(inode);
935 struct buffer_head *bh, *head; 935 struct buffer_head *bh, *head;
936 loff_t offset = page_offset(page); 936 loff_t offset = page_offset(page);
937 ssize_t len = 1 << inode->i_blkbits;
938 937
939 if (!xfs_is_delayed_page(page, IO_DELAY)) 938 if (!xfs_is_delayed_page(page, IO_DELAY))
940 goto out_invalidate; 939 goto out_invalidate;
@@ -949,58 +948,14 @@ xfs_aops_discard_page(
949 xfs_ilock(ip, XFS_ILOCK_EXCL); 948 xfs_ilock(ip, XFS_ILOCK_EXCL);
950 bh = head = page_buffers(page); 949 bh = head = page_buffers(page);
951 do { 950 do {
952 int done;
953 xfs_fileoff_t offset_fsb;
954 xfs_bmbt_irec_t imap;
955 int nimaps = 1;
956 int error; 951 int error;
957 xfs_fsblock_t firstblock; 952 xfs_fileoff_t start_fsb;
958 xfs_bmap_free_t flist;
959 953
960 if (!buffer_delay(bh)) 954 if (!buffer_delay(bh))
961 goto next_buffer; 955 goto next_buffer;
962 956
963 offset_fsb = XFS_B_TO_FSBT(ip->i_mount, offset); 957 start_fsb = XFS_B_TO_FSBT(ip->i_mount, offset);
964 958 error = xfs_bmap_punch_delalloc_range(ip, start_fsb, 1);
965 /*
966 * Map the range first and check that it is a delalloc extent
967 * before trying to unmap the range. Otherwise we will be
968 * trying to remove a real extent (which requires a
969 * transaction) or a hole, which is probably a bad idea...
970 */
971 error = xfs_bmapi(NULL, ip, offset_fsb, 1,
972 XFS_BMAPI_ENTIRE, NULL, 0, &imap,
973 &nimaps, NULL);
974
975 if (error) {
976 /* something screwed, just bail */
977 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {
978 xfs_fs_cmn_err(CE_ALERT, ip->i_mount,
979 "page discard failed delalloc mapping lookup.");
980 }
981 break;
982 }
983 if (!nimaps) {
984 /* nothing there */
985 goto next_buffer;
986 }
987 if (imap.br_startblock != DELAYSTARTBLOCK) {
988 /* been converted, ignore */
989 goto next_buffer;
990 }
991 WARN_ON(imap.br_blockcount == 0);
992
993 /*
994 * Note: while we initialise the firstblock/flist pair, they
995 * should never be used because blocks should never be
996 * allocated or freed for a delalloc extent and hence we need
997 * don't cancel or finish them after the xfs_bunmapi() call.
998 */
999 xfs_bmap_init(&flist, &firstblock);
1000 error = xfs_bunmapi(NULL, ip, offset_fsb, 1, 0, 1, &firstblock,
1001 &flist, &done);
1002
1003 ASSERT(!flist.xbf_count && !flist.xbf_first);
1004 if (error) { 959 if (error) {
1005 /* something screwed, just bail */ 960 /* something screwed, just bail */
1006 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { 961 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {
@@ -1010,7 +965,7 @@ xfs_aops_discard_page(
1010 break; 965 break;
1011 } 966 }
1012next_buffer: 967next_buffer:
1013 offset += len; 968 offset += 1 << inode->i_blkbits;
1014 969
1015 } while ((bh = bh->b_this_page) != head); 970 } while ((bh = bh->b_this_page) != head);
1016 971
@@ -1505,11 +1460,42 @@ xfs_vm_write_failed(
1505 struct inode *inode = mapping->host; 1460 struct inode *inode = mapping->host;
1506 1461
1507 if (to > inode->i_size) { 1462 if (to > inode->i_size) {
1508 struct iattr ia = { 1463 /*
1509 .ia_valid = ATTR_SIZE | ATTR_FORCE, 1464 * punch out the delalloc blocks we have already allocated. We
1510 .ia_size = inode->i_size, 1465 * don't call xfs_setattr() to do this as we may be in the
1511 }; 1466 * middle of a multi-iovec write and so the vfs inode->i_size
1512 xfs_setattr(XFS_I(inode), &ia, XFS_ATTR_NOLOCK); 1467 * will not match the xfs ip->i_size and so it will zero too
1468 * much. Hence we jus truncate the page cache to zero what is
1469 * necessary and punch the delalloc blocks directly.
1470 */
1471 struct xfs_inode *ip = XFS_I(inode);
1472 xfs_fileoff_t start_fsb;
1473 xfs_fileoff_t end_fsb;
1474 int error;
1475
1476 truncate_pagecache(inode, to, inode->i_size);
1477
1478 /*
1479 * Check if there are any blocks that are outside of i_size
1480 * that need to be trimmed back.
1481 */
1482 start_fsb = XFS_B_TO_FSB(ip->i_mount, inode->i_size) + 1;
1483 end_fsb = XFS_B_TO_FSB(ip->i_mount, to);
1484 if (end_fsb <= start_fsb)
1485 return;
1486
1487 xfs_ilock(ip, XFS_ILOCK_EXCL);
1488 error = xfs_bmap_punch_delalloc_range(ip, start_fsb,
1489 end_fsb - start_fsb);
1490 if (error) {
1491 /* something screwed, just bail */
1492 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {
1493 xfs_fs_cmn_err(CE_ALERT, ip->i_mount,
1494 "xfs_vm_write_failed: unable to clean up ino %lld",
1495 ip->i_ino);
1496 }
1497 }
1498 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1513 } 1499 }
1514} 1500}
1515 1501
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index aa1d353def29..4c5deb6e9e31 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -488,29 +488,16 @@ found:
488 spin_unlock(&pag->pag_buf_lock); 488 spin_unlock(&pag->pag_buf_lock);
489 xfs_perag_put(pag); 489 xfs_perag_put(pag);
490 490
491 /* Attempt to get the semaphore without sleeping, 491 if (xfs_buf_cond_lock(bp)) {
492 * if this does not work then we need to drop the 492 /* failed, so wait for the lock if requested. */
493 * spinlock and do a hard attempt on the semaphore.
494 */
495 if (down_trylock(&bp->b_sema)) {
496 if (!(flags & XBF_TRYLOCK)) { 493 if (!(flags & XBF_TRYLOCK)) {
497 /* wait for buffer ownership */
498 xfs_buf_lock(bp); 494 xfs_buf_lock(bp);
499 XFS_STATS_INC(xb_get_locked_waited); 495 XFS_STATS_INC(xb_get_locked_waited);
500 } else { 496 } else {
501 /* We asked for a trylock and failed, no need
502 * to look at file offset and length here, we
503 * know that this buffer at least overlaps our
504 * buffer and is locked, therefore our buffer
505 * either does not exist, or is this buffer.
506 */
507 xfs_buf_rele(bp); 497 xfs_buf_rele(bp);
508 XFS_STATS_INC(xb_busy_locked); 498 XFS_STATS_INC(xb_busy_locked);
509 return NULL; 499 return NULL;
510 } 500 }
511 } else {
512 /* trylock worked */
513 XB_SET_OWNER(bp);
514 } 501 }
515 502
516 if (bp->b_flags & XBF_STALE) { 503 if (bp->b_flags & XBF_STALE) {
@@ -876,10 +863,18 @@ xfs_buf_rele(
876 */ 863 */
877 864
878/* 865/*
879 * Locks a buffer object, if it is not already locked. 866 * Locks a buffer object, if it is not already locked. Note that this in
880 * Note that this in no way locks the underlying pages, so it is only 867 * no way locks the underlying pages, so it is only useful for
881 * useful for synchronizing concurrent use of buffer objects, not for 868 * synchronizing concurrent use of buffer objects, not for synchronizing
882 * synchronizing independent access to the underlying pages. 869 * independent access to the underlying pages.
870 *
871 * If we come across a stale, pinned, locked buffer, we know that we are
872 * being asked to lock a buffer that has been reallocated. Because it is
873 * pinned, we know that the log has not been pushed to disk and hence it
874 * will still be locked. Rather than continuing to have trylock attempts
875 * fail until someone else pushes the log, push it ourselves before
876 * returning. This means that the xfsaild will not get stuck trying
877 * to push on stale inode buffers.
883 */ 878 */
884int 879int
885xfs_buf_cond_lock( 880xfs_buf_cond_lock(
@@ -890,6 +885,8 @@ xfs_buf_cond_lock(
890 locked = down_trylock(&bp->b_sema) == 0; 885 locked = down_trylock(&bp->b_sema) == 0;
891 if (locked) 886 if (locked)
892 XB_SET_OWNER(bp); 887 XB_SET_OWNER(bp);
888 else if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE))
889 xfs_log_force(bp->b_target->bt_mount, 0);
893 890
894 trace_xfs_buf_cond_lock(bp, _RET_IP_); 891 trace_xfs_buf_cond_lock(bp, _RET_IP_);
895 return locked ? 0 : -EBUSY; 892 return locked ? 0 : -EBUSY;
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 8abd12e32e13..4111cd3966c7 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -5471,8 +5471,13 @@ xfs_getbmap(
5471 if (error) 5471 if (error)
5472 goto out_unlock_iolock; 5472 goto out_unlock_iolock;
5473 } 5473 }
5474 5474 /*
5475 ASSERT(ip->i_delayed_blks == 0); 5475 * even after flushing the inode, there can still be delalloc
5476 * blocks on the inode beyond EOF due to speculative
5477 * preallocation. These are not removed until the release
5478 * function is called or the inode is inactivated. Hence we
5479 * cannot assert here that ip->i_delayed_blks == 0.
5480 */
5476 } 5481 }
5477 5482
5478 lock = xfs_ilock_map_shared(ip); 5483 lock = xfs_ilock_map_shared(ip);
@@ -6070,3 +6075,79 @@ xfs_bmap_disk_count_leaves(
6070 *count += xfs_bmbt_disk_get_blockcount(frp); 6075 *count += xfs_bmbt_disk_get_blockcount(frp);
6071 } 6076 }
6072} 6077}
6078
6079/*
6080 * dead simple method of punching delalyed allocation blocks from a range in
6081 * the inode. Walks a block at a time so will be slow, but is only executed in
6082 * rare error cases so the overhead is not critical. This will alays punch out
6083 * both the start and end blocks, even if the ranges only partially overlap
6084 * them, so it is up to the caller to ensure that partial blocks are not
6085 * passed in.
6086 */
6087int
6088xfs_bmap_punch_delalloc_range(
6089 struct xfs_inode *ip,
6090 xfs_fileoff_t start_fsb,
6091 xfs_fileoff_t length)
6092{
6093 xfs_fileoff_t remaining = length;
6094 int error = 0;
6095
6096 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
6097
6098 do {
6099 int done;
6100 xfs_bmbt_irec_t imap;
6101 int nimaps = 1;
6102 xfs_fsblock_t firstblock;
6103 xfs_bmap_free_t flist;
6104
6105 /*
6106 * Map the range first and check that it is a delalloc extent
6107 * before trying to unmap the range. Otherwise we will be
6108 * trying to remove a real extent (which requires a
6109 * transaction) or a hole, which is probably a bad idea...
6110 */
6111 error = xfs_bmapi(NULL, ip, start_fsb, 1,
6112 XFS_BMAPI_ENTIRE, NULL, 0, &imap,
6113 &nimaps, NULL);
6114
6115 if (error) {
6116 /* something screwed, just bail */
6117 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {
6118 xfs_fs_cmn_err(CE_ALERT, ip->i_mount,
6119 "Failed delalloc mapping lookup ino %lld fsb %lld.",
6120 ip->i_ino, start_fsb);
6121 }
6122 break;
6123 }
6124 if (!nimaps) {
6125 /* nothing there */
6126 goto next_block;
6127 }
6128 if (imap.br_startblock != DELAYSTARTBLOCK) {
6129 /* been converted, ignore */
6130 goto next_block;
6131 }
6132 WARN_ON(imap.br_blockcount == 0);
6133
6134 /*
6135 * Note: while we initialise the firstblock/flist pair, they
6136 * should never be used because blocks should never be
6137 * allocated or freed for a delalloc extent and hence we need
6138 * don't cancel or finish them after the xfs_bunmapi() call.
6139 */
6140 xfs_bmap_init(&flist, &firstblock);
6141 error = xfs_bunmapi(NULL, ip, start_fsb, 1, 0, 1, &firstblock,
6142 &flist, &done);
6143 if (error)
6144 break;
6145
6146 ASSERT(!flist.xbf_count && !flist.xbf_first);
6147next_block:
6148 start_fsb++;
6149 remaining--;
6150 } while(remaining > 0);
6151
6152 return error;
6153}
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index 71ec9b6ecdfc..3651191daea1 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -394,6 +394,11 @@ xfs_bmap_count_blocks(
394 int whichfork, 394 int whichfork,
395 int *count); 395 int *count);
396 396
397int
398xfs_bmap_punch_delalloc_range(
399 struct xfs_inode *ip,
400 xfs_fileoff_t start_fsb,
401 xfs_fileoff_t length);
397#endif /* __KERNEL__ */ 402#endif /* __KERNEL__ */
398 403
399#endif /* __XFS_BMAP_H__ */ 404#endif /* __XFS_BMAP_H__ */
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index 3b9582c60a22..e60490bc00a6 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -377,6 +377,19 @@ xfs_swap_extents(
377 ip->i_d.di_format = tip->i_d.di_format; 377 ip->i_d.di_format = tip->i_d.di_format;
378 tip->i_d.di_format = tmp; 378 tip->i_d.di_format = tmp;
379 379
380 /*
381 * The extents in the source inode could still contain speculative
382 * preallocation beyond EOF (e.g. the file is open but not modified
383 * while defrag is in progress). In that case, we need to copy over the
384 * number of delalloc blocks the data fork in the source inode is
385 * tracking beyond EOF so that when the fork is truncated away when the
386 * temporary inode is unlinked we don't underrun the i_delayed_blks
387 * counter on that inode.
388 */
389 ASSERT(tip->i_delayed_blks == 0);
390 tip->i_delayed_blks = ip->i_delayed_blks;
391 ip->i_delayed_blks = 0;
392
380 ilf_fields = XFS_ILOG_CORE; 393 ilf_fields = XFS_ILOG_CORE;
381 394
382 switch(ip->i_d.di_format) { 395 switch(ip->i_d.di_format) {
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index ed9990267661..c78cc6a3d87c 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -58,6 +58,7 @@ xfs_error_trap(int e)
58int xfs_etest[XFS_NUM_INJECT_ERROR]; 58int xfs_etest[XFS_NUM_INJECT_ERROR];
59int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR]; 59int64_t xfs_etest_fsid[XFS_NUM_INJECT_ERROR];
60char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR]; 60char * xfs_etest_fsname[XFS_NUM_INJECT_ERROR];
61int xfs_error_test_active;
61 62
62int 63int
63xfs_error_test(int error_tag, int *fsidp, char *expression, 64xfs_error_test(int error_tag, int *fsidp, char *expression,
@@ -108,6 +109,7 @@ xfs_errortag_add(int error_tag, xfs_mount_t *mp)
108 len = strlen(mp->m_fsname); 109 len = strlen(mp->m_fsname);
109 xfs_etest_fsname[i] = kmem_alloc(len + 1, KM_SLEEP); 110 xfs_etest_fsname[i] = kmem_alloc(len + 1, KM_SLEEP);
110 strcpy(xfs_etest_fsname[i], mp->m_fsname); 111 strcpy(xfs_etest_fsname[i], mp->m_fsname);
112 xfs_error_test_active++;
111 return 0; 113 return 0;
112 } 114 }
113 } 115 }
@@ -137,6 +139,7 @@ xfs_errortag_clearall(xfs_mount_t *mp, int loud)
137 xfs_etest_fsid[i] = 0LL; 139 xfs_etest_fsid[i] = 0LL;
138 kmem_free(xfs_etest_fsname[i]); 140 kmem_free(xfs_etest_fsname[i]);
139 xfs_etest_fsname[i] = NULL; 141 xfs_etest_fsname[i] = NULL;
142 xfs_error_test_active--;
140 } 143 }
141 } 144 }
142 145
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index c2c1a072bb82..f338847f80b8 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -127,13 +127,14 @@ extern void xfs_corruption_error(const char *tag, int level,
127#define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT 127#define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT
128 128
129#ifdef DEBUG 129#ifdef DEBUG
130extern int xfs_error_test_active;
130extern int xfs_error_test(int, int *, char *, int, char *, unsigned long); 131extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
131 132
132#define XFS_NUM_INJECT_ERROR 10 133#define XFS_NUM_INJECT_ERROR 10
133#define XFS_TEST_ERROR(expr, mp, tag, rf) \ 134#define XFS_TEST_ERROR(expr, mp, tag, rf) \
134 ((expr) || \ 135 ((expr) || (xfs_error_test_active && \
135 xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \ 136 xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \
136 (rf))) 137 (rf))))
137 138
138extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp); 139extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp);
139extern int xfs_errortag_clearall(xfs_mount_t *mp, int loud); 140extern int xfs_errortag_clearall(xfs_mount_t *mp, int loud);
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index c7ac020705df..7c8d30c453c3 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -657,18 +657,37 @@ xfs_inode_item_unlock(
657} 657}
658 658
659/* 659/*
660 * This is called to find out where the oldest active copy of the 660 * This is called to find out where the oldest active copy of the inode log
661 * inode log item in the on disk log resides now that the last log 661 * item in the on disk log resides now that the last log write of it completed
662 * write of it completed at the given lsn. Since we always re-log 662 * at the given lsn. Since we always re-log all dirty data in an inode, the
663 * all dirty data in an inode, the latest copy in the on disk log 663 * latest copy in the on disk log is the only one that matters. Therefore,
664 * is the only one that matters. Therefore, simply return the 664 * simply return the given lsn.
665 * given lsn. 665 *
666 * If the inode has been marked stale because the cluster is being freed, we
667 * don't want to (re-)insert this inode into the AIL. There is a race condition
668 * where the cluster buffer may be unpinned before the inode is inserted into
669 * the AIL during transaction committed processing. If the buffer is unpinned
670 * before the inode item has been committed and inserted, then it is possible
671 * for the buffer to be written and IO completions before the inode is inserted
672 * into the AIL. In that case, we'd be inserting a clean, stale inode into the
673 * AIL which will never get removed. It will, however, get reclaimed which
674 * triggers an assert in xfs_inode_free() complaining about freein an inode
675 * still in the AIL.
676 *
677 * To avoid this, return a lower LSN than the one passed in so that the
678 * transaction committed code will not move the inode forward in the AIL but
679 * will still unpin it properly.
666 */ 680 */
667STATIC xfs_lsn_t 681STATIC xfs_lsn_t
668xfs_inode_item_committed( 682xfs_inode_item_committed(
669 struct xfs_log_item *lip, 683 struct xfs_log_item *lip,
670 xfs_lsn_t lsn) 684 xfs_lsn_t lsn)
671{ 685{
686 struct xfs_inode_log_item *iip = INODE_ITEM(lip);
687 struct xfs_inode *ip = iip->ili_inode;
688
689 if (xfs_iflags_test(ip, XFS_ISTALE))
690 return lsn - 1;
672 return lsn; 691 return lsn;
673} 692}
674 693
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c
index d2af0a8381a6..77a59891734e 100644
--- a/fs/xfs/xfs_rename.c
+++ b/fs/xfs/xfs_rename.c
@@ -297,6 +297,7 @@ xfs_rename(
297 * it and some incremental backup programs won't work without it. 297 * it and some incremental backup programs won't work without it.
298 */ 298 */
299 xfs_trans_ichgtime(tp, src_ip, XFS_ICHGTIME_CHG); 299 xfs_trans_ichgtime(tp, src_ip, XFS_ICHGTIME_CHG);
300 xfs_trans_log_inode(tp, src_ip, XFS_ILOG_CORE);
300 301
301 /* 302 /*
302 * Adjust the link count on src_dp. This is necessary when 303 * Adjust the link count on src_dp. This is necessary when
diff --git a/include/acpi/video.h b/include/acpi/video.h
index 551793c9b6e8..0e98e679d3a7 100644
--- a/include/acpi/video.h
+++ b/include/acpi/video.h
@@ -1,6 +1,10 @@
1#ifndef __ACPI_VIDEO_H 1#ifndef __ACPI_VIDEO_H
2#define __ACPI_VIDEO_H 2#define __ACPI_VIDEO_H
3 3
4#include <linux/errno.h> /* for ENODEV */
5
6struct acpi_device;
7
4#define ACPI_VIDEO_DISPLAY_CRT 1 8#define ACPI_VIDEO_DISPLAY_CRT 1
5#define ACPI_VIDEO_DISPLAY_TV 2 9#define ACPI_VIDEO_DISPLAY_TV 2
6#define ACPI_VIDEO_DISPLAY_DVI 3 10#define ACPI_VIDEO_DISPLAY_DVI 3
@@ -26,4 +30,3 @@ static inline int acpi_video_get_edid(struct acpi_device *device, int type,
26#endif 30#endif
27 31
28#endif 32#endif
29
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 8c641bed9bbd..a2776e2807a4 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -287,6 +287,8 @@ typedef struct drm_i915_irq_wait {
287#define I915_PARAM_HAS_EXECBUF2 9 287#define I915_PARAM_HAS_EXECBUF2 9
288#define I915_PARAM_HAS_BSD 10 288#define I915_PARAM_HAS_BSD 10
289#define I915_PARAM_HAS_BLT 11 289#define I915_PARAM_HAS_BLT 11
290#define I915_PARAM_HAS_RELAXED_FENCING 12
291#define I915_PARAM_HAS_COHERENT_RINGS 13
290 292
291typedef struct drm_i915_getparam { 293typedef struct drm_i915_getparam {
292 int param; 294 int param;
diff --git a/include/drm/nouveau_drm.h b/include/drm/nouveau_drm.h
index 01a714119506..bc5590b1a1ac 100644
--- a/include/drm/nouveau_drm.h
+++ b/include/drm/nouveau_drm.h
@@ -80,6 +80,7 @@ struct drm_nouveau_gpuobj_free {
80#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12 80#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12
81#define NOUVEAU_GETPARAM_GRAPH_UNITS 13 81#define NOUVEAU_GETPARAM_GRAPH_UNITS 13
82#define NOUVEAU_GETPARAM_PTIMER_TIME 14 82#define NOUVEAU_GETPARAM_PTIMER_TIME 14
83#define NOUVEAU_GETPARAM_HAS_BO_USAGE 15
83struct drm_nouveau_getparam { 84struct drm_nouveau_getparam {
84 uint64_t param; 85 uint64_t param;
85 uint64_t value; 86 uint64_t value;
@@ -95,6 +96,12 @@ struct drm_nouveau_setparam {
95#define NOUVEAU_GEM_DOMAIN_GART (1 << 2) 96#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
96#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) 97#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
97 98
99#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
100#define NOUVEAU_GEM_TILE_16BPP 0x00000001
101#define NOUVEAU_GEM_TILE_32BPP 0x00000002
102#define NOUVEAU_GEM_TILE_ZETA 0x00000004
103#define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
104
98struct drm_nouveau_gem_info { 105struct drm_nouveau_gem_info {
99 uint32_t handle; 106 uint32_t handle;
100 uint32_t domain; 107 uint32_t domain;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 050a7bccb836..67c91b4418b0 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -219,7 +219,7 @@ static inline int acpi_video_display_switch_support(void)
219 219
220extern int acpi_blacklisted(void); 220extern int acpi_blacklisted(void);
221extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); 221extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d);
222extern int acpi_osi_setup(char *str); 222extern void acpi_osi_setup(char *str);
223 223
224#ifdef CONFIG_ACPI_NUMA 224#ifdef CONFIG_ACPI_NUMA
225int acpi_get_pxm(acpi_handle handle); 225int acpi_get_pxm(acpi_handle handle);
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index a8e4e832cdbb..475f8c42c0e9 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -427,8 +427,10 @@ extern rwlock_t vcc_sklist_lock;
427 427
428#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb)) 428#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb))
429 429
430struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops, 430struct atm_dev *atm_dev_register(const char *type, struct device *parent,
431 int number,unsigned long *flags); /* number == -1: pick first available */ 431 const struct atmdev_ops *ops,
432 int number, /* -1 == pick first available */
433 unsigned long *flags);
432struct atm_dev *atm_dev_lookup(int number); 434struct atm_dev *atm_dev_lookup(int number);
433void atm_dev_deregister(struct atm_dev *dev); 435void atm_dev_deregister(struct atm_dev *dev);
434 436
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index a065612fc928..64a7114a9394 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -29,6 +29,7 @@ struct linux_binprm{
29 char buf[BINPRM_BUF_SIZE]; 29 char buf[BINPRM_BUF_SIZE];
30#ifdef CONFIG_MMU 30#ifdef CONFIG_MMU
31 struct vm_area_struct *vma; 31 struct vm_area_struct *vma;
32 unsigned long vma_pages;
32#else 33#else
33# define MAX_ARG_PAGES 32 34# define MAX_ARG_PAGES 32
34 struct page *page[MAX_ARG_PAGES]; 35 struct page *page[MAX_ARG_PAGES];
@@ -59,6 +60,10 @@ struct linux_binprm{
59 unsigned long loader, exec; 60 unsigned long loader, exec;
60}; 61};
61 62
63extern void acct_arg_size(struct linux_binprm *bprm, unsigned long pages);
64extern struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
65 int write);
66
62#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 67#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
63#define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT) 68#define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
64 69
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index aae86fd10c4f..36ab42c9bb99 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -250,7 +250,7 @@ struct queue_limits {
250 250
251 unsigned char misaligned; 251 unsigned char misaligned;
252 unsigned char discard_misaligned; 252 unsigned char discard_misaligned;
253 unsigned char no_cluster; 253 unsigned char cluster;
254 signed char discard_zeroes_data; 254 signed char discard_zeroes_data;
255}; 255};
256 256
@@ -380,7 +380,6 @@ struct request_queue
380#endif 380#endif
381}; 381};
382 382
383#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */
384#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */ 383#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */
385#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */ 384#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */
386#define QUEUE_FLAG_SYNCFULL 3 /* read queue has been filled */ 385#define QUEUE_FLAG_SYNCFULL 3 /* read queue has been filled */
@@ -403,7 +402,6 @@ struct request_queue
403#define QUEUE_FLAG_SECDISCARD 19 /* supports SECDISCARD */ 402#define QUEUE_FLAG_SECDISCARD 19 /* supports SECDISCARD */
404 403
405#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ 404#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
406 (1 << QUEUE_FLAG_CLUSTER) | \
407 (1 << QUEUE_FLAG_STACKABLE) | \ 405 (1 << QUEUE_FLAG_STACKABLE) | \
408 (1 << QUEUE_FLAG_SAME_COMP) | \ 406 (1 << QUEUE_FLAG_SAME_COMP) | \
409 (1 << QUEUE_FLAG_ADD_RANDOM)) 407 (1 << QUEUE_FLAG_ADD_RANDOM))
@@ -510,6 +508,11 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
510 508
511#define rq_data_dir(rq) ((rq)->cmd_flags & 1) 509#define rq_data_dir(rq) ((rq)->cmd_flags & 1)
512 510
511static inline unsigned int blk_queue_cluster(struct request_queue *q)
512{
513 return q->limits.cluster;
514}
515
513/* 516/*
514 * We regard a request as sync, if either a read or a sync write 517 * We regard a request as sync, if either a read or a sync write
515 */ 518 */
@@ -805,6 +808,7 @@ extern struct request_queue *blk_init_allocated_queue(struct request_queue *,
805extern void blk_cleanup_queue(struct request_queue *); 808extern void blk_cleanup_queue(struct request_queue *);
806extern void blk_queue_make_request(struct request_queue *, make_request_fn *); 809extern void blk_queue_make_request(struct request_queue *, make_request_fn *);
807extern void blk_queue_bounce_limit(struct request_queue *, u64); 810extern void blk_queue_bounce_limit(struct request_queue *, u64);
811extern void blk_limits_max_hw_sectors(struct queue_limits *, unsigned int);
808extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int); 812extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int);
809extern void blk_queue_max_segments(struct request_queue *, unsigned short); 813extern void blk_queue_max_segments(struct request_queue *, unsigned short);
810extern void blk_queue_max_segment_size(struct request_queue *, unsigned int); 814extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 266ab9291232..499dfe982a0e 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -105,6 +105,8 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
105 105
106#define alloc_bootmem(x) \ 106#define alloc_bootmem(x) \
107 __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 107 __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
108#define alloc_bootmem_align(x, align) \
109 __alloc_bootmem(x, align, __pa(MAX_DMA_ADDRESS))
108#define alloc_bootmem_nopanic(x) \ 110#define alloc_bootmem_nopanic(x) \
109 __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 111 __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
110#define alloc_bootmem_pages(x) \ 112#define alloc_bootmem_pages(x) \
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
index f22b2e941686..72c72bfccb88 100644
--- a/include/linux/ceph/libceph.h
+++ b/include/linux/ceph/libceph.h
@@ -227,9 +227,10 @@ extern int ceph_open_session(struct ceph_client *client);
227extern void ceph_release_page_vector(struct page **pages, int num_pages); 227extern void ceph_release_page_vector(struct page **pages, int num_pages);
228 228
229extern struct page **ceph_get_direct_page_vector(const char __user *data, 229extern struct page **ceph_get_direct_page_vector(const char __user *data,
230 int num_pages, 230 int num_pages,
231 loff_t off, size_t len); 231 bool write_page);
232extern void ceph_put_page_vector(struct page **pages, int num_pages); 232extern void ceph_put_page_vector(struct page **pages, int num_pages,
233 bool dirty);
233extern void ceph_release_page_vector(struct page **pages, int num_pages); 234extern void ceph_release_page_vector(struct page **pages, int num_pages);
234extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags); 235extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags);
235extern int ceph_copy_user_to_page_vector(struct page **pages, 236extern int ceph_copy_user_to_page_vector(struct page **pages,
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index 5956d62c3057..a108b425fee2 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -82,6 +82,7 @@ struct ceph_msg {
82 struct ceph_buffer *middle; 82 struct ceph_buffer *middle;
83 struct page **pages; /* data payload. NOT OWNER. */ 83 struct page **pages; /* data payload. NOT OWNER. */
84 unsigned nr_pages; /* size of page array */ 84 unsigned nr_pages; /* size of page array */
85 unsigned page_alignment; /* io offset in first page */
85 struct ceph_pagelist *pagelist; /* instead of pages */ 86 struct ceph_pagelist *pagelist; /* instead of pages */
86 struct list_head list_head; 87 struct list_head list_head;
87 struct kref kref; 88 struct kref kref;
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 6c91fb032c39..a1af29648fb5 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -79,6 +79,7 @@ struct ceph_osd_request {
79 struct ceph_file_layout r_file_layout; 79 struct ceph_file_layout r_file_layout;
80 struct ceph_snap_context *r_snapc; /* snap context for writes */ 80 struct ceph_snap_context *r_snapc; /* snap context for writes */
81 unsigned r_num_pages; /* size of page array (follows) */ 81 unsigned r_num_pages; /* size of page array (follows) */
82 unsigned r_page_alignment; /* io offset in first page */
82 struct page **r_pages; /* pages for data payload */ 83 struct page **r_pages; /* pages for data payload */
83 int r_pages_from_pool; 84 int r_pages_from_pool;
84 int r_own_pages; /* if true, i own page list */ 85 int r_own_pages; /* if true, i own page list */
@@ -194,7 +195,8 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
194 int do_sync, u32 truncate_seq, 195 int do_sync, u32 truncate_seq,
195 u64 truncate_size, 196 u64 truncate_size,
196 struct timespec *mtime, 197 struct timespec *mtime,
197 bool use_mempool, int num_reply); 198 bool use_mempool, int num_reply,
199 int page_align);
198 200
199static inline void ceph_osdc_get_request(struct ceph_osd_request *req) 201static inline void ceph_osdc_get_request(struct ceph_osd_request *req)
200{ 202{
@@ -218,7 +220,8 @@ extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
218 struct ceph_file_layout *layout, 220 struct ceph_file_layout *layout,
219 u64 off, u64 *plen, 221 u64 off, u64 *plen,
220 u32 truncate_seq, u64 truncate_size, 222 u32 truncate_seq, u64 truncate_size,
221 struct page **pages, int nr_pages); 223 struct page **pages, int nr_pages,
224 int page_align);
222 225
223extern int ceph_osdc_writepages(struct ceph_osd_client *osdc, 226extern int ceph_osdc_writepages(struct ceph_osd_client *osdc,
224 struct ceph_vino vino, 227 struct ceph_vino vino,
diff --git a/include/linux/cnt32_to_63.h b/include/linux/cnt32_to_63.h
index 7605fdd1eb65..e3d8bf26e5eb 100644
--- a/include/linux/cnt32_to_63.h
+++ b/include/linux/cnt32_to_63.h
@@ -61,13 +61,31 @@ union cnt32_to_63 {
61 * 61 *
62 * 2) this code must not be preempted for a duration longer than the 62 * 2) this code must not be preempted for a duration longer than the
63 * 32-bit counter half period minus the longest period between two 63 * 32-bit counter half period minus the longest period between two
64 * calls to this code. 64 * calls to this code;
65 * 65 *
66 * Those requirements ensure proper update to the state bit in memory. 66 * Those requirements ensure proper update to the state bit in memory.
67 * This is usually not a problem in practice, but if it is then a kernel 67 * This is usually not a problem in practice, but if it is then a kernel
68 * timer should be scheduled to manage for this code to be executed often 68 * timer should be scheduled to manage for this code to be executed often
69 * enough. 69 * enough.
70 * 70 *
71 * And finally:
72 *
73 * 3) the cnt_lo argument must be seen as a globally incrementing value,
74 * meaning that it should be a direct reference to the counter data which
75 * can be evaluated according to a specific ordering within the macro,
76 * and not the result of a previous evaluation stored in a variable.
77 *
78 * For example, this is wrong:
79 *
80 * u32 partial = get_hw_count();
81 * u64 full = cnt32_to_63(partial);
82 * return full;
83 *
84 * This is fine:
85 *
86 * u64 full = cnt32_to_63(get_hw_count());
87 * return full;
88 *
71 * Note that the top bit (bit 63) in the returned value should be considered 89 * Note that the top bit (bit 63) in the returned value should be considered
72 * as garbage. It is not cleared here because callers are likely to use a 90 * as garbage. It is not cleared here because callers are likely to use a
73 * multiplier on the returned value which can get rid of the top bit 91 * multiplier on the returned value which can get rid of the top bit
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 4823af64e9db..5f09323ee880 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -10,11 +10,6 @@
10 * 10 *
11 * CPUs are exported via sysfs in the class/cpu/devices/ 11 * CPUs are exported via sysfs in the class/cpu/devices/
12 * directory. 12 * directory.
13 *
14 * Per-cpu interfaces can be implemented using a struct device_interface.
15 * See the following for how to do this:
16 * - drivers/base/intf.c
17 * - Documentation/driver-model/interface.txt
18 */ 13 */
19#ifndef _LINUX_CPU_H_ 14#ifndef _LINUX_CPU_H_
20#define _LINUX_CPU_H_ 15#define _LINUX_CPU_H_
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index a7d9dc21391d..7b776d71d36d 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -175,10 +175,21 @@ static inline int set_msi_sid(struct irte *irte, struct pci_dev *dev)
175 return 0; 175 return 0;
176} 176}
177 177
178#define enable_intr_remapping(mode) (-1)
179#define disable_intr_remapping() (0)
180#define reenable_intr_remapping(mode) (0)
181#define intr_remapping_enabled (0) 178#define intr_remapping_enabled (0)
179
180static inline int enable_intr_remapping(int eim)
181{
182 return -1;
183}
184
185static inline void disable_intr_remapping(void)
186{
187}
188
189static inline int reenable_intr_remapping(int eim)
190{
191 return 0;
192}
182#endif 193#endif
183 194
184/* Can't use the common MSI interrupt functions 195/* Can't use the common MSI interrupt functions
diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h
index 0f0121467fc4..6c6133f76e16 100644
--- a/include/linux/fanotify.h
+++ b/include/linux/fanotify.h
@@ -83,11 +83,13 @@
83 FAN_ALL_PERM_EVENTS |\ 83 FAN_ALL_PERM_EVENTS |\
84 FAN_Q_OVERFLOW) 84 FAN_Q_OVERFLOW)
85 85
86#define FANOTIFY_METADATA_VERSION 2 86#define FANOTIFY_METADATA_VERSION 3
87 87
88struct fanotify_event_metadata { 88struct fanotify_event_metadata {
89 __u32 event_len; 89 __u32 event_len;
90 __u32 vers; 90 __u8 vers;
91 __u8 reserved;
92 __u16 metadata_len;
91 __aligned_u64 mask; 93 __aligned_u64 mask;
92 __s32 fd; 94 __s32 fd;
93 __s32 pid; 95 __s32 pid;
@@ -96,11 +98,13 @@ struct fanotify_event_metadata {
96struct fanotify_response { 98struct fanotify_response {
97 __s32 fd; 99 __s32 fd;
98 __u32 response; 100 __u32 response;
99} __attribute__ ((packed)); 101};
100 102
101/* Legit userspace responses to a _PERM event */ 103/* Legit userspace responses to a _PERM event */
102#define FAN_ALLOW 0x01 104#define FAN_ALLOW 0x01
103#define FAN_DENY 0x02 105#define FAN_DENY 0x02
106/* No fd set in event */
107#define FAN_NOFD -1
104 108
105/* Helper functions to deal with fanotify_event_metadata buffers */ 109/* Helper functions to deal with fanotify_event_metadata buffers */
106#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) 110#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 7fca3dc4e475..68ba85a00c06 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -1092,6 +1092,8 @@ extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var);
1092extern const unsigned char *fb_firmware_edid(struct device *device); 1092extern const unsigned char *fb_firmware_edid(struct device *device);
1093extern void fb_edid_to_monspecs(unsigned char *edid, 1093extern void fb_edid_to_monspecs(unsigned char *edid,
1094 struct fb_monspecs *specs); 1094 struct fb_monspecs *specs);
1095extern void fb_edid_add_monspecs(unsigned char *edid,
1096 struct fb_monspecs *specs);
1095extern void fb_destroy_modedb(struct fb_videomode *modedb); 1097extern void fb_destroy_modedb(struct fb_videomode *modedb);
1096extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb); 1098extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb);
1097extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter); 1099extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter);
@@ -1122,6 +1124,7 @@ extern const struct fb_videomode *fb_find_best_display(const struct fb_monspecs
1122 1124
1123/* drivers/video/fbcmap.c */ 1125/* drivers/video/fbcmap.c */
1124extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp); 1126extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
1127extern int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags);
1125extern void fb_dealloc_cmap(struct fb_cmap *cmap); 1128extern void fb_dealloc_cmap(struct fb_cmap *cmap);
1126extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to); 1129extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to);
1127extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to); 1130extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to);
@@ -1149,6 +1152,7 @@ struct fb_videomode {
1149 1152
1150extern const char *fb_mode_option; 1153extern const char *fb_mode_option;
1151extern const struct fb_videomode vesa_modes[]; 1154extern const struct fb_videomode vesa_modes[];
1155extern const struct fb_videomode cea_modes[64];
1152 1156
1153struct fb_modelist { 1157struct fb_modelist {
1154 struct list_head list; 1158 struct list_head list;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 334d68a17108..090f0eacde29 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -34,9 +34,9 @@
34#define SEEK_MAX SEEK_END 34#define SEEK_MAX SEEK_END
35 35
36struct fstrim_range { 36struct fstrim_range {
37 uint64_t start; 37 __u64 start;
38 uint64_t len; 38 __u64 len;
39 uint64_t minlen; 39 __u64 minlen;
40}; 40};
41 41
42/* And dynamically-tunable limits and defaults: */ 42/* And dynamically-tunable limits and defaults: */
@@ -602,6 +602,7 @@ struct address_space_operations {
602 sector_t (*bmap)(struct address_space *, sector_t); 602 sector_t (*bmap)(struct address_space *, sector_t);
603 void (*invalidatepage) (struct page *, unsigned long); 603 void (*invalidatepage) (struct page *, unsigned long);
604 int (*releasepage) (struct page *, gfp_t); 604 int (*releasepage) (struct page *, gfp_t);
605 void (*freepage)(struct page *);
605 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov, 606 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
606 loff_t offset, unsigned long nr_segs); 607 loff_t offset, unsigned long nr_segs);
607 int (*get_xip_mem)(struct address_space *, pgoff_t, int, 608 int (*get_xip_mem)(struct address_space *, pgoff_t, int,
@@ -1612,7 +1613,6 @@ struct super_operations {
1612 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 1613 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
1613#endif 1614#endif
1614 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 1615 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
1615 int (*trim_fs) (struct super_block *, struct fstrim_range *);
1616}; 1616};
1617 1617
1618/* 1618/*
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 5c185fa27089..b10bcdeaef76 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -235,9 +235,6 @@ static inline void fsnotify_open(struct file *file)
235 if (S_ISDIR(inode->i_mode)) 235 if (S_ISDIR(inode->i_mode))
236 mask |= FS_ISDIR; 236 mask |= FS_ISDIR;
237 237
238 /* FMODE_NONOTIFY must never be set from user */
239 file->f_mode &= ~FMODE_NONOTIFY;
240
241 fsnotify_parent(path, NULL, mask); 238 fsnotify_parent(path, NULL, mask);
242 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0); 239 fsnotify(inode, mask, path, FSNOTIFY_EVENT_PATH, NULL, 0);
243} 240}
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 0a68f924f06f..7380763595d3 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -166,7 +166,7 @@ struct fsnotify_group {
166 struct mutex access_mutex; 166 struct mutex access_mutex;
167 struct list_head access_list; 167 struct list_head access_list;
168 wait_queue_head_t access_waitq; 168 wait_queue_head_t access_waitq;
169 bool bypass_perm; /* protected by access_mutex */ 169 atomic_t bypass_perm;
170#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */ 170#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */
171 int f_flags; 171 int f_flags;
172 unsigned int max_marks; 172 unsigned int max_marks;
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index e8713d55360a..f54adfcbec9c 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -360,7 +360,7 @@ void drain_local_pages(void *dummy);
360 360
361extern gfp_t gfp_allowed_mask; 361extern gfp_t gfp_allowed_mask;
362 362
363extern void set_gfp_allowed_mask(gfp_t mask); 363extern void pm_restrict_gfp_mask(void);
364extern gfp_t clear_gfp_allowed_mask(gfp_t mask); 364extern void pm_restore_gfp_mask(void);
365 365
366#endif /* __LINUX_GFP_H */ 366#endif /* __LINUX_GFP_H */
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index ce73a30113b4..dd1a56fbe924 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -16,6 +16,8 @@ struct gpio_keys_button {
16struct gpio_keys_platform_data { 16struct gpio_keys_platform_data {
17 struct gpio_keys_button *buttons; 17 struct gpio_keys_button *buttons;
18 int nbuttons; 18 int nbuttons;
19 unsigned int poll_interval; /* polling interval in msecs -
20 for polling driver only */
19 unsigned int rep:1; /* enable input subsystem auto repeat */ 21 unsigned int rep:1; /* enable input subsystem auto repeat */
20 int (*enable)(struct device *dev); 22 int (*enable)(struct device *dev);
21 void (*disable)(struct device *dev); 23 void (*disable)(struct device *dev);
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 41cb31f14ee3..32f9fd6619b4 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -2,9 +2,6 @@
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
6#include <linux/smp_lock.h>
7#endif
8#include <linux/lockdep.h> 5#include <linux/lockdep.h>
9#include <linux/ftrace_irq.h> 6#include <linux/ftrace_irq.h>
10#include <asm/hardirq.h> 7#include <asm/hardirq.h>
@@ -97,7 +94,8 @@
97#define in_nmi() (preempt_count() & NMI_MASK) 94#define in_nmi() (preempt_count() & NMI_MASK)
98 95
99#if defined(CONFIG_PREEMPT) && defined(CONFIG_BKL) 96#if defined(CONFIG_PREEMPT) && defined(CONFIG_BKL)
100# define PREEMPT_INATOMIC_BASE kernel_locked() 97# include <linux/sched.h>
98# define PREEMPT_INATOMIC_BASE (current->lock_depth >= 0)
101#else 99#else
102# define PREEMPT_INATOMIC_BASE 0 100# define PREEMPT_INATOMIC_BASE 0
103#endif 101#endif
diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h
index a2d6ea49ec56..d1e55fed2c7d 100644
--- a/include/linux/hw_breakpoint.h
+++ b/include/linux/hw_breakpoint.h
@@ -33,6 +33,8 @@ enum bp_type_idx {
33 33
34#ifdef CONFIG_HAVE_HW_BREAKPOINT 34#ifdef CONFIG_HAVE_HW_BREAKPOINT
35 35
36extern int __init init_hw_breakpoint(void);
37
36static inline void hw_breakpoint_init(struct perf_event_attr *attr) 38static inline void hw_breakpoint_init(struct perf_event_attr *attr)
37{ 39{
38 memset(attr, 0, sizeof(*attr)); 40 memset(attr, 0, sizeof(*attr));
@@ -108,6 +110,8 @@ static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
108 110
109#else /* !CONFIG_HAVE_HW_BREAKPOINT */ 111#else /* !CONFIG_HAVE_HW_BREAKPOINT */
110 112
113static inline int __init init_hw_breakpoint(void) { return 0; }
114
111static inline struct perf_event * 115static inline struct perf_event *
112register_user_hw_breakpoint(struct perf_event_attr *attr, 116register_user_hw_breakpoint(struct perf_event_attr *attr,
113 perf_overflow_handler_t triggered, 117 perf_overflow_handler_t triggered,
diff --git a/include/linux/input.h b/include/linux/input.h
index 6ef44465db8d..9777668883be 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -47,6 +47,25 @@ struct input_id {
47 __u16 version; 47 __u16 version;
48}; 48};
49 49
50/**
51 * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls
52 * @value: latest reported value for the axis.
53 * @minimum: specifies minimum value for the axis.
54 * @maximum: specifies maximum value for the axis.
55 * @fuzz: specifies fuzz value that is used to filter noise from
56 * the event stream.
57 * @flat: values that are within this value will be discarded by
58 * joydev interface and reported as 0 instead.
59 * @resolution: specifies resolution for the values reported for
60 * the axis.
61 *
62 * Note that input core does not clamp reported values to the
63 * [minimum, maximum] limits, such task is left to userspace.
64 *
65 * Resolution for main axes (ABS_X, ABS_Y, ABS_Z) is reported in
66 * units per millimeter (units/mm), resolution for rotational axes
67 * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian.
68 */
50struct input_absinfo { 69struct input_absinfo {
51 __s32 value; 70 __s32 value;
52 __s32 minimum; 71 __s32 minimum;
@@ -85,8 +104,10 @@ struct input_keymap_entry {
85#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ 104#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */
86#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */ 105#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */
87 106
88#define EVIOCGKEYCODE _IOR('E', 0x04, struct input_keymap_entry) /* get keycode */ 107#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */
89#define EVIOCSKEYCODE _IOW('E', 0x04, struct input_keymap_entry) /* set keycode */ 108#define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry)
109#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */
110#define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry)
90 111
91#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ 112#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
92#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ 113#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
@@ -624,6 +645,10 @@ struct input_keymap_entry {
624#define KEY_CAMERA_FOCUS 0x210 645#define KEY_CAMERA_FOCUS 0x210
625#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ 646#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */
626 647
648#define KEY_TOUCHPAD_TOGGLE 0x212 /* Request switch touchpad on or off */
649#define KEY_TOUCHPAD_ON 0x213
650#define KEY_TOUCHPAD_OFF 0x214
651
627#define BTN_TRIGGER_HAPPY 0x2c0 652#define BTN_TRIGGER_HAPPY 0x2c0
628#define BTN_TRIGGER_HAPPY1 0x2c0 653#define BTN_TRIGGER_HAPPY1 0x2c0
629#define BTN_TRIGGER_HAPPY2 0x2c1 654#define BTN_TRIGGER_HAPPY2 0x2c1
@@ -1130,7 +1155,7 @@ struct input_mt_slot {
1130 * of tracked contacts 1155 * of tracked contacts
1131 * @mtsize: number of MT slots the device uses 1156 * @mtsize: number of MT slots the device uses
1132 * @slot: MT slot currently being transmitted 1157 * @slot: MT slot currently being transmitted
1133 * @absinfo: array of &struct absinfo elements holding information 1158 * @absinfo: array of &struct input_absinfo elements holding information
1134 * about absolute axes (current value, min, max, flat, fuzz, 1159 * about absolute axes (current value, min, max, flat, fuzz,
1135 * resolution) 1160 * resolution)
1136 * @key: reflects current state of device's keys/buttons 1161 * @key: reflects current state of device's keys/buttons
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index d377ea815d45..e9bb22cba764 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -112,7 +112,6 @@ struct resource_list {
112/* PC/ISA/whatever - the normal PC address spaces: IO and memory */ 112/* PC/ISA/whatever - the normal PC address spaces: IO and memory */
113extern struct resource ioport_resource; 113extern struct resource ioport_resource;
114extern struct resource iomem_resource; 114extern struct resource iomem_resource;
115extern int resource_alloc_from_bottom;
116 115
117extern struct resource *request_resource_conflict(struct resource *root, struct resource *new); 116extern struct resource *request_resource_conflict(struct resource *root, struct resource *new);
118extern int request_resource(struct resource *root, struct resource *new); 117extern int request_resource(struct resource *root, struct resource *new);
@@ -124,6 +123,7 @@ extern void reserve_region_with_split(struct resource *root,
124extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new); 123extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new);
125extern int insert_resource(struct resource *parent, struct resource *new); 124extern int insert_resource(struct resource *parent, struct resource *new);
126extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new); 125extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
126extern void arch_remove_reservations(struct resource *avail);
127extern int allocate_resource(struct resource *root, struct resource *new, 127extern int allocate_resource(struct resource *root, struct resource *new,
128 resource_size_t size, resource_size_t min, 128 resource_size_t size, resource_size_t min,
129 resource_size_t max, resource_size_t align, 129 resource_size_t max, resource_size_t align,
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 15b77b8dc7e1..d947b1231662 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -986,7 +986,7 @@ extern void ata_host_init(struct ata_host *, struct device *,
986 unsigned long, struct ata_port_operations *); 986 unsigned long, struct ata_port_operations *);
987extern int ata_scsi_detect(struct scsi_host_template *sht); 987extern int ata_scsi_detect(struct scsi_host_template *sht);
988extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 988extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
989extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); 989extern int ata_scsi_queuecmd(struct Scsi_Host *h, struct scsi_cmnd *cmd);
990extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev, 990extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev,
991 int cmd, void __user *arg); 991 int cmd, void __user *arg);
992extern void ata_sas_port_destroy(struct ata_port *); 992extern void ata_sas_port_destroy(struct ata_port *);
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index a34dea46b629..2dee05e5119a 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -43,6 +43,7 @@ struct nlm_host {
43 struct sockaddr_storage h_addr; /* peer address */ 43 struct sockaddr_storage h_addr; /* peer address */
44 size_t h_addrlen; 44 size_t h_addrlen;
45 struct sockaddr_storage h_srcaddr; /* our address (optional) */ 45 struct sockaddr_storage h_srcaddr; /* our address (optional) */
46 size_t h_srcaddrlen;
46 struct rpc_clnt *h_rpcclnt; /* RPC client to talk to peer */ 47 struct rpc_clnt *h_rpcclnt; /* RPC client to talk to peer */
47 char *h_name; /* remote hostname */ 48 char *h_name; /* remote hostname */
48 u32 h_version; /* interface version */ 49 u32 h_version; /* interface version */
diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
index 1ff81b51b656..dd3c34ebca9a 100644
--- a/include/linux/marvell_phy.h
+++ b/include/linux/marvell_phy.h
@@ -11,6 +11,7 @@
11#define MARVELL_PHY_ID_88E1118 0x01410e10 11#define MARVELL_PHY_ID_88E1118 0x01410e10
12#define MARVELL_PHY_ID_88E1121R 0x01410cb0 12#define MARVELL_PHY_ID_88E1121R 0x01410cb0
13#define MARVELL_PHY_ID_88E1145 0x01410cd0 13#define MARVELL_PHY_ID_88E1145 0x01410cd0
14#define MARVELL_PHY_ID_88E1149R 0x01410e50
14#define MARVELL_PHY_ID_88E1240 0x01410e30 15#define MARVELL_PHY_ID_88E1240 0x01410e30
15#define MARVELL_PHY_ID_88E1318S 0x01410e90 16#define MARVELL_PHY_ID_88E1318S 0x01410e90
16 17
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 4307231bd22f..31c237a00c48 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -161,6 +161,9 @@ extern void register_page_bootmem_info_node(struct pglist_data *pgdat);
161extern void put_page_bootmem(struct page *page); 161extern void put_page_bootmem(struct page *page);
162#endif 162#endif
163 163
164void lock_memory_hotplug(void);
165void unlock_memory_hotplug(void);
166
164#else /* ! CONFIG_MEMORY_HOTPLUG */ 167#else /* ! CONFIG_MEMORY_HOTPLUG */
165/* 168/*
166 * Stub functions for when hotplug is off 169 * Stub functions for when hotplug is off
@@ -192,6 +195,9 @@ static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
192{ 195{
193} 196}
194 197
198static inline void lock_memory_hotplug(void) {}
199static inline void unlock_memory_hotplug(void) {}
200
195#endif /* ! CONFIG_MEMORY_HOTPLUG */ 201#endif /* ! CONFIG_MEMORY_HOTPLUG */
196 202
197#ifdef CONFIG_MEMORY_HOTREMOVE 203#ifdef CONFIG_MEMORY_HOTREMOVE
diff --git a/include/linux/mfd/wm8350/audio.h b/include/linux/mfd/wm8350/audio.h
index a95141eafce3..bd581c6fa085 100644
--- a/include/linux/mfd/wm8350/audio.h
+++ b/include/linux/mfd/wm8350/audio.h
@@ -522,9 +522,6 @@
522#define WM8350_MCLK_SEL_PLL_32K 3 522#define WM8350_MCLK_SEL_PLL_32K 3
523#define WM8350_MCLK_SEL_MCLK 5 523#define WM8350_MCLK_SEL_MCLK 5
524 524
525#define WM8350_MCLK_DIR_OUT 0
526#define WM8350_MCLK_DIR_IN 1
527
528/* clock divider id's */ 525/* clock divider id's */
529#define WM8350_ADC_CLKDIV 0 526#define WM8350_ADC_CLKDIV 0
530#define WM8350_DAC_CLKDIV 1 527#define WM8350_DAC_CLKDIV 1
diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h
index 5c51f367c061..add8a1b8bcf0 100644
--- a/include/linux/mfd/wm8994/pdata.h
+++ b/include/linux/mfd/wm8994/pdata.h
@@ -29,7 +29,7 @@ struct wm8994_ldo_pdata {
29#define WM8994_CONFIGURE_GPIO 0x8000 29#define WM8994_CONFIGURE_GPIO 0x8000
30 30
31#define WM8994_DRC_REGS 5 31#define WM8994_DRC_REGS 5
32#define WM8994_EQ_REGS 19 32#define WM8994_EQ_REGS 20
33 33
34/** 34/**
35 * DRC configurations are specified with a label and a set of register 35 * DRC configurations are specified with a label and a set of register
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 6d87f68ce4b6..30f6fad99a58 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -168,6 +168,7 @@ struct mmc_host {
168 /* DDR mode at 1.8V */ 168 /* DDR mode at 1.8V */
169#define MMC_CAP_1_2V_DDR (1 << 12) /* can support */ 169#define MMC_CAP_1_2V_DDR (1 << 12) /* can support */
170 /* DDR mode at 1.2V */ 170 /* DDR mode at 1.2V */
171#define MMC_CAP_POWER_OFF_CARD (1 << 13) /* Can power off after boot */
171 172
172 mmc_pm_flag_t pm_caps; /* supported pm features */ 173 mmc_pm_flag_t pm_caps; /* supported pm features */
173 174
diff --git a/include/linux/module.h b/include/linux/module.h
index b29e7458b966..7575bbbdf2a2 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -517,7 +517,7 @@ static inline void __module_get(struct module *module)
517#define symbol_put_addr(p) do { } while(0) 517#define symbol_put_addr(p) do { } while(0)
518 518
519#endif /* CONFIG_MODULE_UNLOAD */ 519#endif /* CONFIG_MODULE_UNLOAD */
520int use_module(struct module *a, struct module *b); 520int ref_module(struct module *a, struct module *b);
521 521
522/* This is a #define so the string doesn't get put in every .o file */ 522/* This is a #define so the string doesn't get put in every .o file */
523#define module_name(mod) \ 523#define module_name(mod) \
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index bba26684acdc..29d504d5d1c3 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -401,6 +401,7 @@ extern const struct inode_operations nfs3_file_inode_operations;
401#endif /* CONFIG_NFS_V3 */ 401#endif /* CONFIG_NFS_V3 */
402extern const struct file_operations nfs_file_operations; 402extern const struct file_operations nfs_file_operations;
403extern const struct address_space_operations nfs_file_aops; 403extern const struct address_space_operations nfs_file_aops;
404extern const struct address_space_operations nfs_dir_aops;
404 405
405static inline struct nfs_open_context *nfs_file_open_context(struct file *filp) 406static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
406{ 407{
@@ -593,12 +594,6 @@ nfs_fileid_to_ino_t(u64 fileid)
593 return ino; 594 return ino;
594} 595}
595 596
596#define nfs_wait_event(clnt, wq, condition) \
597({ \
598 int __retval = wait_event_killable(wq, condition); \
599 __retval; \
600})
601
602#define NFS_JUKEBOX_RETRY_TIME (5 * HZ) 597#define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
603 598
604#endif /* __KERNEL__ */ 599#endif /* __KERNEL__ */
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index f8b60e7f4c44..d55cee73f634 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -29,6 +29,7 @@
29 */ 29 */
30enum { 30enum {
31 PG_BUSY = 0, 31 PG_BUSY = 0,
32 PG_MAPPED,
32 PG_CLEAN, 33 PG_CLEAN,
33 PG_NEED_COMMIT, 34 PG_NEED_COMMIT,
34 PG_NEED_RESCHED, 35 PG_NEED_RESCHED,
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index ba6cc8f223c9..80f07198a31a 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -483,6 +483,7 @@ struct nfs_entry {
483 int eof; 483 int eof;
484 struct nfs_fh * fh; 484 struct nfs_fh * fh;
485 struct nfs_fattr * fattr; 485 struct nfs_fattr * fattr;
486 unsigned char d_type;
486}; 487};
487 488
488/* 489/*
diff --git a/include/linux/node.h b/include/linux/node.h
index 06292dac3eab..1466945cc9ef 100644
--- a/include/linux/node.h
+++ b/include/linux/node.h
@@ -10,11 +10,6 @@
10 * 10 *
11 * Nodes are exported via driverfs in the class/node/devices/ 11 * Nodes are exported via driverfs in the class/node/devices/
12 * directory. 12 * directory.
13 *
14 * Per-node interfaces can be implemented using a struct device_interface.
15 * See the following for how to do this:
16 * - drivers/base/intf.c
17 * - Documentation/driver-model/interface.txt
18 */ 13 */
19#ifndef _LINUX_NODE_H_ 14#ifndef _LINUX_NODE_H_
20#define _LINUX_NODE_H_ 15#define _LINUX_NODE_H_
diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h
index 5bb13b3db84d..b02195dfc1b0 100644
--- a/include/linux/page_cgroup.h
+++ b/include/linux/page_cgroup.h
@@ -59,8 +59,6 @@ static inline void ClearPageCgroup##uname(struct page_cgroup *pc) \
59static inline int TestClearPageCgroup##uname(struct page_cgroup *pc) \ 59static inline int TestClearPageCgroup##uname(struct page_cgroup *pc) \
60 { return test_and_clear_bit(PCG_##lname, &pc->flags); } 60 { return test_and_clear_bit(PCG_##lname, &pc->flags); }
61 61
62TESTPCGFLAG(Locked, LOCK)
63
64/* Cache flag is set only once (at allocation) */ 62/* Cache flag is set only once (at allocation) */
65TESTPCGFLAG(Cache, CACHE) 63TESTPCGFLAG(Cache, CACHE)
66CLEARPCGFLAG(Cache, CACHE) 64CLEARPCGFLAG(Cache, CACHE)
@@ -104,6 +102,11 @@ static inline void unlock_page_cgroup(struct page_cgroup *pc)
104 bit_spin_unlock(PCG_LOCK, &pc->flags); 102 bit_spin_unlock(PCG_LOCK, &pc->flags);
105} 103}
106 104
105static inline int page_is_cgroup_locked(struct page_cgroup *pc)
106{
107 return bit_spin_is_locked(PCG_LOCK, &pc->flags);
108}
109
107#else /* CONFIG_CGROUP_MEM_RES_CTLR */ 110#else /* CONFIG_CGROUP_MEM_RES_CTLR */
108struct page_cgroup; 111struct page_cgroup;
109 112
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index c6bcfe93b9ca..cb845c16ad7d 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2047,6 +2047,7 @@
2047#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182 2047#define PCI_DEVICE_ID_AFAVLAB_P030 0x2182
2048#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150 2048#define PCI_SUBDEVICE_ID_AFAVLAB_P061 0x2150
2049 2049
2050#define PCI_VENDOR_ID_BCM_GVC 0x14a4
2050#define PCI_VENDOR_ID_BROADCOM 0x14e4 2051#define PCI_VENDOR_ID_BROADCOM 0x14e4
2051#define PCI_DEVICE_ID_TIGON3_5752 0x1600 2052#define PCI_DEVICE_ID_TIGON3_5752 0x1600
2052#define PCI_DEVICE_ID_TIGON3_5752M 0x1601 2053#define PCI_DEVICE_ID_TIGON3_5752M 0x1601
@@ -2441,6 +2442,7 @@
2441#define PCI_DEVICE_ID_INTEL_MFD_SDIO2 0x0822 2442#define PCI_DEVICE_ID_INTEL_MFD_SDIO2 0x0822
2442#define PCI_DEVICE_ID_INTEL_MFD_EMMC0 0x0823 2443#define PCI_DEVICE_ID_INTEL_MFD_EMMC0 0x0823
2443#define PCI_DEVICE_ID_INTEL_MFD_EMMC1 0x0824 2444#define PCI_DEVICE_ID_INTEL_MFD_EMMC1 0x0824
2445#define PCI_DEVICE_ID_INTEL_MRST_SD2 0x084F
2444#define PCI_DEVICE_ID_INTEL_I960 0x0960 2446#define PCI_DEVICE_ID_INTEL_I960 0x0960
2445#define PCI_DEVICE_ID_INTEL_I960RM 0x0962 2447#define PCI_DEVICE_ID_INTEL_I960RM 0x0962
2446#define PCI_DEVICE_ID_INTEL_8257X_SOL 0x1062 2448#define PCI_DEVICE_ID_INTEL_8257X_SOL 0x1062
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 40150f345982..4f1279e105ee 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -850,6 +850,7 @@ struct perf_event_context {
850 int nr_active; 850 int nr_active;
851 int is_active; 851 int is_active;
852 int nr_stat; 852 int nr_stat;
853 int rotate_disable;
853 atomic_t refcount; 854 atomic_t refcount;
854 struct task_struct *task; 855 struct task_struct *task;
855 856
@@ -886,6 +887,7 @@ struct perf_cpu_context {
886 int exclusive; 887 int exclusive;
887 struct list_head rotation_list; 888 struct list_head rotation_list;
888 int jiffies_interval; 889 int jiffies_interval;
890 struct pmu *active_pmu;
889}; 891};
890 892
891struct perf_output_handle { 893struct perf_output_handle {
@@ -908,20 +910,6 @@ extern int perf_num_counters(void);
908extern const char *perf_pmu_name(void); 910extern const char *perf_pmu_name(void);
909extern void __perf_event_task_sched_in(struct task_struct *task); 911extern void __perf_event_task_sched_in(struct task_struct *task);
910extern void __perf_event_task_sched_out(struct task_struct *task, struct task_struct *next); 912extern void __perf_event_task_sched_out(struct task_struct *task, struct task_struct *next);
911
912extern atomic_t perf_task_events;
913
914static inline void perf_event_task_sched_in(struct task_struct *task)
915{
916 COND_STMT(&perf_task_events, __perf_event_task_sched_in(task));
917}
918
919static inline
920void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next)
921{
922 COND_STMT(&perf_task_events, __perf_event_task_sched_out(task, next));
923}
924
925extern int perf_event_init_task(struct task_struct *child); 913extern int perf_event_init_task(struct task_struct *child);
926extern void perf_event_exit_task(struct task_struct *child); 914extern void perf_event_exit_task(struct task_struct *child);
927extern void perf_event_free_task(struct task_struct *task); 915extern void perf_event_free_task(struct task_struct *task);
@@ -1030,6 +1018,21 @@ have_event:
1030 __perf_sw_event(event_id, nr, nmi, regs, addr); 1018 __perf_sw_event(event_id, nr, nmi, regs, addr);
1031} 1019}
1032 1020
1021extern atomic_t perf_task_events;
1022
1023static inline void perf_event_task_sched_in(struct task_struct *task)
1024{
1025 COND_STMT(&perf_task_events, __perf_event_task_sched_in(task));
1026}
1027
1028static inline
1029void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next)
1030{
1031 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 1, NULL, 0);
1032
1033 COND_STMT(&perf_task_events, __perf_event_task_sched_out(task, next));
1034}
1035
1033extern void perf_event_mmap(struct vm_area_struct *vma); 1036extern void perf_event_mmap(struct vm_area_struct *vma);
1034extern struct perf_guest_info_callbacks *perf_guest_cbs; 1037extern struct perf_guest_info_callbacks *perf_guest_cbs;
1035extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); 1038extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index 445796945ac9..bb27d7ec2fb9 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -160,5 +160,6 @@ void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *);
160 160
161/* for F_SETPIPE_SZ and F_GETPIPE_SZ */ 161/* for F_SETPIPE_SZ and F_GETPIPE_SZ */
162long pipe_fcntl(struct file *, unsigned int, unsigned long arg); 162long pipe_fcntl(struct file *, unsigned int, unsigned long arg);
163struct pipe_inode_info *get_pipe_info(struct file *file);
163 164
164#endif 165#endif
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 3ec2358f8692..d19f1cca7f74 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -77,7 +77,8 @@ static inline void device_set_run_wake(struct device *dev, bool enable)
77 77
78static inline bool pm_runtime_suspended(struct device *dev) 78static inline bool pm_runtime_suspended(struct device *dev)
79{ 79{
80 return dev->power.runtime_status == RPM_SUSPENDED; 80 return dev->power.runtime_status == RPM_SUSPENDED
81 && !dev->power.disable_depth;
81} 82}
82 83
83static inline void pm_runtime_mark_last_busy(struct device *dev) 84static inline void pm_runtime_mark_last_busy(struct device *dev)
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 5ca47e59b727..c21072adbfad 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -22,7 +22,6 @@
22#include <asm/unaligned.h> 22#include <asm/unaligned.h>
23#include <linux/bitops.h> 23#include <linux/bitops.h>
24#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
25#include <linux/smp_lock.h>
26#include <linux/buffer_head.h> 25#include <linux/buffer_head.h>
27#include <linux/reiserfs_fs_i.h> 26#include <linux/reiserfs_fs_i.h>
28#include <linux/reiserfs_fs_sb.h> 27#include <linux/reiserfs_fs_sb.h>
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index d42f274418b8..bbad657a3725 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -6,7 +6,6 @@
6#include <linux/if_link.h> 6#include <linux/if_link.h>
7#include <linux/if_addr.h> 7#include <linux/if_addr.h>
8#include <linux/neighbour.h> 8#include <linux/neighbour.h>
9#include <linux/netdevice.h>
10 9
11/* rtnetlink families. Values up to 127 are reserved for real address 10/* rtnetlink families. Values up to 127 are reserved for real address
12 * families, values above 128 may be used arbitrarily. 11 * families, values above 128 may be used arbitrarily.
@@ -606,6 +605,7 @@ struct tcamsg {
606#ifdef __KERNEL__ 605#ifdef __KERNEL__
607 606
608#include <linux/mutex.h> 607#include <linux/mutex.h>
608#include <linux/netdevice.h>
609 609
610static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str) 610static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
611{ 611{
diff --git a/include/linux/sched.h b/include/linux/sched.h
index d0036e52a24a..223874538b33 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -143,7 +143,7 @@ extern unsigned long nr_iowait_cpu(int cpu);
143extern unsigned long this_cpu_load(void); 143extern unsigned long this_cpu_load(void);
144 144
145 145
146extern void calc_global_load(void); 146extern void calc_global_load(unsigned long ticks);
147 147
148extern unsigned long get_parent_ip(unsigned long addr); 148extern unsigned long get_parent_ip(unsigned long addr);
149 149
@@ -862,6 +862,7 @@ struct sched_group {
862 * single CPU. 862 * single CPU.
863 */ 863 */
864 unsigned int cpu_power, cpu_power_orig; 864 unsigned int cpu_power, cpu_power_orig;
865 unsigned int group_weight;
865 866
866 /* 867 /*
867 * The CPUs this group covers. 868 * The CPUs this group covers.
diff --git a/include/linux/sh_clk.h b/include/linux/sh_clk.h
index cea0c38e7a63..9a52f72527dc 100644
--- a/include/linux/sh_clk.h
+++ b/include/linux/sh_clk.h
@@ -19,11 +19,13 @@ struct clk_mapping {
19}; 19};
20 20
21struct clk_ops { 21struct clk_ops {
22#ifdef CONFIG_SH_CLK_CPG_LEGACY
22 void (*init)(struct clk *clk); 23 void (*init)(struct clk *clk);
24#endif
23 int (*enable)(struct clk *clk); 25 int (*enable)(struct clk *clk);
24 void (*disable)(struct clk *clk); 26 void (*disable)(struct clk *clk);
25 unsigned long (*recalc)(struct clk *clk); 27 unsigned long (*recalc)(struct clk *clk);
26 int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id); 28 int (*set_rate)(struct clk *clk, unsigned long rate);
27 int (*set_parent)(struct clk *clk, struct clk *parent); 29 int (*set_parent)(struct clk *clk, struct clk *parent);
28 long (*round_rate)(struct clk *clk, unsigned long rate); 30 long (*round_rate)(struct clk *clk, unsigned long rate);
29}; 31};
@@ -67,36 +69,6 @@ int clk_register(struct clk *);
67void clk_unregister(struct clk *); 69void clk_unregister(struct clk *);
68void clk_enable_init_clocks(void); 70void clk_enable_init_clocks(void);
69 71
70/**
71 * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
72 * @clk: clock source
73 * @rate: desired clock rate in Hz
74 * @algo_id: algorithm id to be passed down to ops->set_rate
75 *
76 * Returns success (0) or negative errno.
77 */
78int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
79
80enum clk_sh_algo_id {
81 NO_CHANGE = 0,
82
83 IUS_N1_N1,
84 IUS_322,
85 IUS_522,
86 IUS_N11,
87
88 SB_N1,
89
90 SB3_N1,
91 SB3_32,
92 SB3_43,
93 SB3_54,
94
95 BP_N1,
96
97 IP_N1,
98};
99
100struct clk_div_mult_table { 72struct clk_div_mult_table {
101 unsigned int *divisors; 73 unsigned int *divisors;
102 unsigned int nr_divisors; 74 unsigned int nr_divisors;
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
index 291f721144c2..3a1988202731 100644
--- a/include/linux/smp_lock.h
+++ b/include/linux/smp_lock.h
@@ -4,8 +4,6 @@
4#ifdef CONFIG_LOCK_KERNEL 4#ifdef CONFIG_LOCK_KERNEL
5#include <linux/sched.h> 5#include <linux/sched.h>
6 6
7#define kernel_locked() (current->lock_depth >= 0)
8
9extern int __lockfunc __reacquire_kernel_lock(void); 7extern int __lockfunc __reacquire_kernel_lock(void);
10extern void __lockfunc __release_kernel_lock(void); 8extern void __lockfunc __release_kernel_lock(void);
11 9
@@ -58,7 +56,6 @@ static inline void cycle_kernel_lock(void)
58#define lock_kernel() 56#define lock_kernel()
59#define unlock_kernel() 57#define unlock_kernel()
60#define cycle_kernel_lock() do { } while(0) 58#define cycle_kernel_lock() do { } while(0)
61#define kernel_locked() 1
62#endif /* CONFIG_BKL */ 59#endif /* CONFIG_BKL */
63 60
64#define release_kernel_lock(task) do { } while(0) 61#define release_kernel_lock(task) do { } while(0)
diff --git a/include/linux/snmp.h b/include/linux/snmp.h
index ebb0c80ffd6e..12b2b18e50c1 100644
--- a/include/linux/snmp.h
+++ b/include/linux/snmp.h
@@ -230,6 +230,7 @@ enum
230 LINUX_MIB_TCPMINTTLDROP, /* RFC 5082 */ 230 LINUX_MIB_TCPMINTTLDROP, /* RFC 5082 */
231 LINUX_MIB_TCPDEFERACCEPTDROP, 231 LINUX_MIB_TCPDEFERACCEPTDROP,
232 LINUX_MIB_IPRPFILTER, /* IP Reverse Path Filter (rp_filter) */ 232 LINUX_MIB_IPRPFILTER, /* IP Reverse Path Filter (rp_filter) */
233 LINUX_MIB_TCPTIMEWAITOVERFLOW, /* TCPTimeWaitOverflow */
233 __LINUX_MIB_MAX 234 __LINUX_MIB_MAX
234}; 235};
235 236
diff --git a/include/linux/ssb/ssb_driver_gige.h b/include/linux/ssb/ssb_driver_gige.h
index 942e38736901..eba52a100533 100644
--- a/include/linux/ssb/ssb_driver_gige.h
+++ b/include/linux/ssb/ssb_driver_gige.h
@@ -96,16 +96,21 @@ static inline bool ssb_gige_must_flush_posted_writes(struct pci_dev *pdev)
96 return 0; 96 return 0;
97} 97}
98 98
99extern char * nvram_get(const char *name); 99#ifdef CONFIG_BCM47XX
100#include <asm/mach-bcm47xx/nvram.h>
100/* Get the device MAC address */ 101/* Get the device MAC address */
101static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr) 102static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
102{ 103{
103#ifdef CONFIG_BCM47XX 104 char buf[20];
104 char *res = nvram_get("et0macaddr"); 105 if (nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
105 if (res) 106 return;
106 memcpy(macaddr, res, 6); 107 nvram_parse_macaddr(buf, macaddr);
107#endif
108} 108}
109#else
110static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
111{
112}
113#endif
109 114
110extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev, 115extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
111 struct pci_dev *pdev); 116 struct pci_dev *pdev);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index c7ea9bc8897c..54e4eaaa0561 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -13,7 +13,6 @@
13#include <linux/tty_driver.h> 13#include <linux/tty_driver.h>
14#include <linux/tty_ldisc.h> 14#include <linux/tty_ldisc.h>
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/smp_lock.h>
17 16
18#include <asm/system.h> 17#include <asm/system.h>
19 18
@@ -367,6 +366,7 @@ struct tty_file_private {
367#define TTY_HUPPED 18 /* Post driver->hangup() */ 366#define TTY_HUPPED 18 /* Post driver->hangup() */
368#define TTY_FLUSHING 19 /* Flushing to ldisc in progress */ 367#define TTY_FLUSHING 19 /* Flushing to ldisc in progress */
369#define TTY_FLUSHPENDING 20 /* Queued buffer flush pending */ 368#define TTY_FLUSHPENDING 20 /* Queued buffer flush pending */
369#define TTY_HUPPING 21 /* ->hangup() in progress */
370 370
371#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) 371#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
372 372
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index d6188e5a52df..665517c05eaf 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright(C) 2005, Benedikt Spranger <b.spranger@linutronix.de> 4 * Copyright(C) 2005, Benedikt Spranger <b.spranger@linutronix.de>
5 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de> 5 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
6 * Copyright(C) 2006, Hans J. Koch <hjk@linutronix.de> 6 * Copyright(C) 2006, Hans J. Koch <hjk@hansjkoch.de>
7 * Copyright(C) 2006, Greg Kroah-Hartman <greg@kroah.com> 7 * Copyright(C) 2006, Greg Kroah-Hartman <greg@kroah.com>
8 * 8 *
9 * Userspace IO driver. 9 * Userspace IO driver.
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 24300d8a1bc1..a28eb2592577 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -313,6 +313,10 @@ struct usb_bus {
313 int busnum; /* Bus number (in order of reg) */ 313 int busnum; /* Bus number (in order of reg) */
314 const char *bus_name; /* stable id (PCI slot_name etc) */ 314 const char *bus_name; /* stable id (PCI slot_name etc) */
315 u8 uses_dma; /* Does the host controller use DMA? */ 315 u8 uses_dma; /* Does the host controller use DMA? */
316 u8 uses_pio_for_control; /*
317 * Does the host controller use PIO
318 * for control transfers?
319 */
316 u8 otg_port; /* 0, or number of OTG/HNP port */ 320 u8 otg_port; /* 0, or number of OTG/HNP port */
317 unsigned is_b_host:1; /* true during some HNP roleswitches */ 321 unsigned is_b_host:1; /* true during some HNP roleswitches */
318 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ 322 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
diff --git a/include/linux/via-core.h b/include/linux/via-core.h
index 38bffd8ccca5..9c21cdf3e3b3 100644
--- a/include/linux/via-core.h
+++ b/include/linux/via-core.h
@@ -60,6 +60,21 @@ struct via_port_cfg {
60}; 60};
61 61
62/* 62/*
63 * Allow subdevs to register suspend/resume hooks.
64 */
65#ifdef CONFIG_PM
66struct viafb_pm_hooks {
67 struct list_head list;
68 int (*suspend)(void *private);
69 int (*resume)(void *private);
70 void *private;
71};
72
73void viafb_pm_register(struct viafb_pm_hooks *hooks);
74void viafb_pm_unregister(struct viafb_pm_hooks *hooks);
75#endif /* CONFIG_PM */
76
77/*
63 * This is the global viafb "device" containing stuff needed by 78 * This is the global viafb "device" containing stuff needed by
64 * all subdevs. 79 * all subdevs.
65 */ 80 */
diff --git a/include/linux/video_output.h b/include/linux/video_output.h
index 2fb46bc9340d..ed5cdeb3604d 100644
--- a/include/linux/video_output.h
+++ b/include/linux/video_output.h
@@ -23,6 +23,7 @@
23#ifndef _LINUX_VIDEO_OUTPUT_H 23#ifndef _LINUX_VIDEO_OUTPUT_H
24#define _LINUX_VIDEO_OUTPUT_H 24#define _LINUX_VIDEO_OUTPUT_H
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/err.h>
26struct output_device; 27struct output_device;
27struct output_properties { 28struct output_properties {
28 int (*set_state)(struct output_device *); 29 int (*set_state)(struct output_device *);
@@ -34,9 +35,23 @@ struct output_device {
34 struct device dev; 35 struct device dev;
35}; 36};
36#define to_output_device(obj) container_of(obj, struct output_device, dev) 37#define to_output_device(obj) container_of(obj, struct output_device, dev)
38#if defined(CONFIG_VIDEO_OUTPUT_CONTROL) || defined(CONFIG_VIDEO_OUTPUT_CONTROL_MODULE)
37struct output_device *video_output_register(const char *name, 39struct output_device *video_output_register(const char *name,
38 struct device *dev, 40 struct device *dev,
39 void *devdata, 41 void *devdata,
40 struct output_properties *op); 42 struct output_properties *op);
41void video_output_unregister(struct output_device *dev); 43void video_output_unregister(struct output_device *dev);
44#else
45static struct output_device *video_output_register(const char *name,
46 struct device *dev,
47 void *devdata,
48 struct output_properties *op)
49{
50 return ERR_PTR(-ENODEV);
51}
52static void video_output_unregister(struct output_device *dev)
53{
54 return;
55}
56#endif
42#endif 57#endif
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index a03dcf62ca9d..44b54f619ac6 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -7,8 +7,6 @@
7 7
8struct vm_area_struct; /* vma defining user mapping in mm_types.h */ 8struct vm_area_struct; /* vma defining user mapping in mm_types.h */
9 9
10extern bool vmap_lazy_unmap;
11
12/* bits in flags of vmalloc's vm_struct below */ 10/* bits in flags of vmalloc's vm_struct below */
13#define VM_IOREMAP 0x00000001 /* ioremap() and friends */ 11#define VM_IOREMAP 0x00000001 /* ioremap() and friends */
14#define VM_ALLOC 0x00000002 /* vmalloc() */ 12#define VM_ALLOC 0x00000002 /* vmalloc() */
diff --git a/include/media/saa7146.h b/include/media/saa7146.h
index 7a9f76ecbbbd..ac7ce00f39cf 100644
--- a/include/media/saa7146.h
+++ b/include/media/saa7146.h
@@ -161,7 +161,7 @@ extern struct list_head saa7146_devices;
161extern struct mutex saa7146_devices_lock; 161extern struct mutex saa7146_devices_lock;
162int saa7146_register_extension(struct saa7146_extension*); 162int saa7146_register_extension(struct saa7146_extension*);
163int saa7146_unregister_extension(struct saa7146_extension*); 163int saa7146_unregister_extension(struct saa7146_extension*);
164struct saa7146_format* format_by_fourcc(struct saa7146_dev *dev, int fourcc); 164struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fourcc);
165int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt); 165int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt);
166void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt); 166void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt);
167int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length ); 167int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length );
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 41dd480e45f1..239125af3ea3 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -137,31 +137,27 @@ struct v4l2_subdev_ops;
137 137
138 138
139/* Load an i2c module and return an initialized v4l2_subdev struct. 139/* Load an i2c module and return an initialized v4l2_subdev struct.
140 Only call request_module if module_name != NULL.
141 The client_type argument is the name of the chip that's on the adapter. */ 140 The client_type argument is the name of the chip that's on the adapter. */
142struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, 141struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev,
143 struct i2c_adapter *adapter, 142 struct i2c_adapter *adapter, const char *client_type,
144 const char *module_name, const char *client_type,
145 int irq, void *platform_data, 143 int irq, void *platform_data,
146 u8 addr, const unsigned short *probe_addrs); 144 u8 addr, const unsigned short *probe_addrs);
147 145
148/* Load an i2c module and return an initialized v4l2_subdev struct. 146/* Load an i2c module and return an initialized v4l2_subdev struct.
149 Only call request_module if module_name != NULL.
150 The client_type argument is the name of the chip that's on the adapter. */ 147 The client_type argument is the name of the chip that's on the adapter. */
151static inline struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, 148static inline struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
152 struct i2c_adapter *adapter, 149 struct i2c_adapter *adapter, const char *client_type,
153 const char *module_name, const char *client_type,
154 u8 addr, const unsigned short *probe_addrs) 150 u8 addr, const unsigned short *probe_addrs)
155{ 151{
156 return v4l2_i2c_new_subdev_cfg(v4l2_dev, adapter, module_name, 152 return v4l2_i2c_new_subdev_cfg(v4l2_dev, adapter, client_type, 0, NULL,
157 client_type, 0, NULL, addr, probe_addrs); 153 addr, probe_addrs);
158} 154}
159 155
160struct i2c_board_info; 156struct i2c_board_info;
161 157
162struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, 158struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
163 struct i2c_adapter *adapter, const char *module_name, 159 struct i2c_adapter *adapter, struct i2c_board_info *info,
164 struct i2c_board_info *info, const unsigned short *probe_addrs); 160 const unsigned short *probe_addrs);
165 161
166/* Initialize an v4l2_subdev with data from an i2c_client struct */ 162/* Initialize an v4l2_subdev with data from an i2c_client struct */
167void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, 163void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 6648036b728d..b16f307d471a 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -51,6 +51,8 @@ struct v4l2_device {
51 unsigned int notification, void *arg); 51 unsigned int notification, void *arg);
52 /* The control handler. May be NULL. */ 52 /* The control handler. May be NULL. */
53 struct v4l2_ctrl_handler *ctrl_handler; 53 struct v4l2_ctrl_handler *ctrl_handler;
54 /* BKL replacement mutex. Temporary solution only. */
55 struct mutex ioctl_lock;
54}; 56};
55 57
56/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev. 58/* Initialize v4l2_dev and make dev->driver_data point to v4l2_dev.
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 90c9e2872f27..18e5c3f67580 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -10,6 +10,7 @@ extern void unix_inflight(struct file *fp);
10extern void unix_notinflight(struct file *fp); 10extern void unix_notinflight(struct file *fp);
11extern void unix_gc(void); 11extern void unix_gc(void);
12extern void wait_for_unix_gc(void); 12extern void wait_for_unix_gc(void);
13extern struct sock *unix_get_socket(struct file *filp);
13 14
14#define UNIX_HASH_SIZE 256 15#define UNIX_HASH_SIZE 256
15 16
@@ -56,6 +57,7 @@ struct unix_sock {
56 spinlock_t lock; 57 spinlock_t lock;
57 unsigned int gc_candidate : 1; 58 unsigned int gc_candidate : 1;
58 unsigned int gc_maybe_cycle : 1; 59 unsigned int gc_maybe_cycle : 1;
60 unsigned char recursion_level;
59 struct socket_wq peer_wq; 61 struct socket_wq peer_wq;
60}; 62};
61#define unix_sk(__sk) ((struct unix_sock *)__sk) 63#define unix_sk(__sk) ((struct unix_sock *)__sk)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 2a7936d7851d..97b8b7c9b63c 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1355,7 +1355,7 @@ enum wiphy_flags {
1355 WIPHY_FLAG_4ADDR_AP = BIT(5), 1355 WIPHY_FLAG_4ADDR_AP = BIT(5),
1356 WIPHY_FLAG_4ADDR_STATION = BIT(6), 1356 WIPHY_FLAG_4ADDR_STATION = BIT(6),
1357 WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7), 1357 WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7),
1358 WIPHY_FLAG_IBSS_RSN = BIT(7), 1358 WIPHY_FLAG_IBSS_RSN = BIT(8),
1359}; 1359};
1360 1360
1361struct mac_address { 1361struct mac_address {
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 55590ab16b3e..6beb1ffc2b7f 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -303,7 +303,7 @@ static inline void neigh_confirm(struct neighbour *neigh)
303 303
304static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) 304static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
305{ 305{
306 unsigned long now = ACCESS_ONCE(jiffies); 306 unsigned long now = jiffies;
307 307
308 if (neigh->used != now) 308 if (neigh->used != now)
309 neigh->used = now; 309 neigh->used = now;
diff --git a/include/net/sock.h b/include/net/sock.h
index a6338d039857..659d968d95c5 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1155,6 +1155,8 @@ extern void sk_common_release(struct sock *sk);
1155/* Initialise core socket variables */ 1155/* Initialise core socket variables */
1156extern void sock_init_data(struct socket *sock, struct sock *sk); 1156extern void sock_init_data(struct socket *sock, struct sock *sk);
1157 1157
1158extern void sk_filter_release_rcu(struct rcu_head *rcu);
1159
1158/** 1160/**
1159 * sk_filter_release - release a socket filter 1161 * sk_filter_release - release a socket filter
1160 * @fp: filter to remove 1162 * @fp: filter to remove
@@ -1165,7 +1167,7 @@ extern void sock_init_data(struct socket *sock, struct sock *sk);
1165static inline void sk_filter_release(struct sk_filter *fp) 1167static inline void sk_filter_release(struct sk_filter *fp)
1166{ 1168{
1167 if (atomic_dec_and_test(&fp->refcnt)) 1169 if (atomic_dec_and_test(&fp->refcnt))
1168 kfree(fp); 1170 call_rcu_bh(&fp->rcu, sk_filter_release_rcu);
1169} 1171}
1170 1172
1171static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp) 1173static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index f986ab7ffe6f..5c4c1678f7be 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -1006,8 +1006,7 @@ void fc_fcp_destroy(struct fc_lport *);
1006/* 1006/*
1007 * SCSI INTERACTION LAYER 1007 * SCSI INTERACTION LAYER
1008 *****************************/ 1008 *****************************/
1009int fc_queuecommand(struct scsi_cmnd *, 1009int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
1010 void (*done)(struct scsi_cmnd *));
1011int fc_eh_abort(struct scsi_cmnd *); 1010int fc_eh_abort(struct scsi_cmnd *);
1012int fc_eh_device_reset(struct scsi_cmnd *); 1011int fc_eh_device_reset(struct scsi_cmnd *);
1013int fc_eh_host_reset(struct scsi_cmnd *); 1012int fc_eh_host_reset(struct scsi_cmnd *);
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ae5196aae1a5..b81d969ddc67 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -341,8 +341,7 @@ extern int iscsi_eh_abort(struct scsi_cmnd *sc);
341extern int iscsi_eh_recover_target(struct scsi_cmnd *sc); 341extern int iscsi_eh_recover_target(struct scsi_cmnd *sc);
342extern int iscsi_eh_session_reset(struct scsi_cmnd *sc); 342extern int iscsi_eh_session_reset(struct scsi_cmnd *sc);
343extern int iscsi_eh_device_reset(struct scsi_cmnd *sc); 343extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
344extern int iscsi_queuecommand(struct scsi_cmnd *sc, 344extern int iscsi_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *sc);
345 void (*done)(struct scsi_cmnd *));
346 345
347/* 346/*
348 * iSCSI host helpers. 347 * iSCSI host helpers.
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 3dec1949f69c..90ce527ecf3d 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -621,8 +621,7 @@ int sas_set_phy_speed(struct sas_phy *phy,
621int sas_phy_enable(struct sas_phy *phy, int enabled); 621int sas_phy_enable(struct sas_phy *phy, int enabled);
622int sas_phy_reset(struct sas_phy *phy, int hard_reset); 622int sas_phy_reset(struct sas_phy *phy, int hard_reset);
623int sas_queue_up(struct sas_task *task); 623int sas_queue_up(struct sas_task *task);
624extern int sas_queuecommand(struct scsi_cmnd *, 624extern int sas_queuecommand(struct Scsi_Host * ,struct scsi_cmnd *);
625 void (*scsi_done)(struct scsi_cmnd *));
626extern int sas_target_alloc(struct scsi_target *); 625extern int sas_target_alloc(struct scsi_target *);
627extern int sas_slave_alloc(struct scsi_device *); 626extern int sas_slave_alloc(struct scsi_device *);
628extern int sas_slave_configure(struct scsi_device *); 627extern int sas_slave_configure(struct scsi_device *);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index d0a6a845f204..e7e385842a38 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -127,8 +127,7 @@ struct scsi_host_template {
127 * 127 *
128 * STATUS: REQUIRED 128 * STATUS: REQUIRED
129 */ 129 */
130 int (* queuecommand)(struct scsi_cmnd *, 130 int (* queuecommand)(struct Scsi_Host *, struct scsi_cmnd *);
131 void (*done)(struct scsi_cmnd *));
132 131
133 /* 132 /*
134 * The transfer functions are used to queue a scsi command to 133 * The transfer functions are used to queue a scsi command to
@@ -505,6 +504,25 @@ struct scsi_host_template {
505}; 504};
506 505
507/* 506/*
507 * Temporary #define for host lock push down. Can be removed when all
508 * drivers have been updated to take advantage of unlocked
509 * queuecommand.
510 *
511 */
512#define DEF_SCSI_QCMD(func_name) \
513 int func_name(struct Scsi_Host *shost, struct scsi_cmnd *cmd) \
514 { \
515 unsigned long irq_flags; \
516 int rc; \
517 spin_lock_irqsave(shost->host_lock, irq_flags); \
518 scsi_cmd_get_serial(shost, cmd); \
519 rc = func_name##_lck (cmd, cmd->scsi_done); \
520 spin_unlock_irqrestore(shost->host_lock, irq_flags); \
521 return rc; \
522 }
523
524
525/*
508 * shost state: If you alter this, you also need to alter scsi_sysfs.c 526 * shost state: If you alter this, you also need to alter scsi_sysfs.c
509 * (for the ascii descriptions) and the state model enforcer: 527 * (for the ascii descriptions) and the state model enforcer:
510 * scsi_host_set_state() 528 * scsi_host_set_state()
@@ -752,6 +770,7 @@ extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
752extern void scsi_host_put(struct Scsi_Host *t); 770extern void scsi_host_put(struct Scsi_Host *t);
753extern struct Scsi_Host *scsi_host_lookup(unsigned short); 771extern struct Scsi_Host *scsi_host_lookup(unsigned short);
754extern const char *scsi_host_state_name(enum scsi_host_state); 772extern const char *scsi_host_state_name(enum scsi_host_state);
773extern void scsi_cmd_get_serial(struct Scsi_Host *, struct scsi_cmnd *);
755 774
756extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); 775extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *);
757 776
diff --git a/include/sound/sh_fsi.h b/include/sound/sh_fsi.h
index fa60cbda90a4..d79894192ae3 100644
--- a/include/sound/sh_fsi.h
+++ b/include/sound/sh_fsi.h
@@ -85,7 +85,9 @@
85 * ACK_MD (FSI2) 85 * ACK_MD (FSI2)
86 * CKG1 (FSI) 86 * CKG1 (FSI)
87 * 87 *
88 * err: return value < 0 88 * err : return value < 0
89 * no change : return value == 0
90 * change xMD : return value > 0
89 * 91 *
90 * 0x-00000AB 92 * 0x-00000AB
91 * 93 *
@@ -111,7 +113,7 @@
111struct sh_fsi_platform_info { 113struct sh_fsi_platform_info {
112 unsigned long porta_flags; 114 unsigned long porta_flags;
113 unsigned long portb_flags; 115 unsigned long portb_flags;
114 int (*set_rate)(int is_porta, int rate); /* for master mode */ 116 int (*set_rate)(struct device *dev, int is_porta, int rate, int enable);
115}; 117};
116 118
117#endif /* __SOUND_FSI_H */ 119#endif /* __SOUND_FSI_H */
diff --git a/include/video/da8xx-fb.h b/include/video/da8xx-fb.h
index 6316cdabf73f..89d43b3d4cb9 100644
--- a/include/video/da8xx-fb.h
+++ b/include/video/da8xx-fb.h
@@ -99,7 +99,6 @@ struct lcd_sync_arg {
99#define FBIPUT_COLOR _IOW('F', 6, int) 99#define FBIPUT_COLOR _IOW('F', 6, int)
100#define FBIPUT_HSYNC _IOW('F', 9, int) 100#define FBIPUT_HSYNC _IOW('F', 9, int)
101#define FBIPUT_VSYNC _IOW('F', 10, int) 101#define FBIPUT_VSYNC _IOW('F', 10, int)
102#define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t)
103 102
104#endif /* ifndef DA8XX_FB_H */ 103#endif /* ifndef DA8XX_FB_H */
105 104
diff --git a/include/video/s1d13xxxfb.h b/include/video/s1d13xxxfb.h
index f0736cff2ca3..55f534491a3d 100644
--- a/include/video/s1d13xxxfb.h
+++ b/include/video/s1d13xxxfb.h
@@ -136,12 +136,6 @@
136#define S1DREG_DELAYOFF 0xFFFE 136#define S1DREG_DELAYOFF 0xFFFE
137#define S1DREG_DELAYON 0xFFFF 137#define S1DREG_DELAYON 0xFFFF
138 138
139#define BBLT_FIFO_EMPTY 0x00
140#define BBLT_FIFO_NOT_EMPTY 0x40
141#define BBLT_FIFO_NOT_FULL 0x30
142#define BBLT_FIFO_HALF_FULL 0x20
143#define BBLT_FIFO_FULL 0x10
144
145#define BBLT_SOLID_FILL 0x0c 139#define BBLT_SOLID_FILL 0x0c
146 140
147 141
diff --git a/include/video/sh_mipi_dsi.h b/include/video/sh_mipi_dsi.h
index 18bca08f9f59..6cb95c977de9 100644
--- a/include/video/sh_mipi_dsi.h
+++ b/include/video/sh_mipi_dsi.h
@@ -27,9 +27,15 @@ enum sh_mipi_dsi_data_fmt {
27 27
28struct sh_mobile_lcdc_chan_cfg; 28struct sh_mobile_lcdc_chan_cfg;
29 29
30#define SH_MIPI_DSI_HSABM (1 << 0)
31#define SH_MIPI_DSI_HSPBM (1 << 1)
32
30struct sh_mipi_dsi_info { 33struct sh_mipi_dsi_info {
31 enum sh_mipi_dsi_data_fmt data_format; 34 enum sh_mipi_dsi_data_fmt data_format;
32 struct sh_mobile_lcdc_chan_cfg *lcd_chan; 35 struct sh_mobile_lcdc_chan_cfg *lcd_chan;
36 unsigned long flags;
37 u32 clksrc;
38 unsigned int vsynw_offset;
33}; 39};
34 40
35#endif 41#endif
diff --git a/include/video/sh_mobile_hdmi.h b/include/video/sh_mobile_hdmi.h
index 1e1aa54ab2e4..b56932927d0a 100644
--- a/include/video/sh_mobile_hdmi.h
+++ b/include/video/sh_mobile_hdmi.h
@@ -13,6 +13,7 @@
13 13
14struct sh_mobile_lcdc_chan_cfg; 14struct sh_mobile_lcdc_chan_cfg;
15struct device; 15struct device;
16struct clk;
16 17
17/* 18/*
18 * flags format 19 * flags format
@@ -33,6 +34,8 @@ struct sh_mobile_hdmi_info {
33 struct sh_mobile_lcdc_chan_cfg *lcd_chan; 34 struct sh_mobile_lcdc_chan_cfg *lcd_chan;
34 struct device *lcd_dev; 35 struct device *lcd_dev;
35 unsigned int flags; 36 unsigned int flags;
37 long (*clk_optimize_parent)(unsigned long target, unsigned long *best_freq,
38 unsigned long *parent_freq);
36}; 39};
37 40
38#endif 41#endif
diff --git a/include/xen/events.h b/include/xen/events.h
index 646dd17d3aa4..00f53ddcc062 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -76,7 +76,9 @@ int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name);
76 76
77#ifdef CONFIG_PCI_MSI 77#ifdef CONFIG_PCI_MSI
78/* Allocate an irq and a pirq to be used with MSIs. */ 78/* Allocate an irq and a pirq to be used with MSIs. */
79void xen_allocate_pirq_msi(char *name, int *irq, int *pirq); 79#define XEN_ALLOC_PIRQ (1 << 0)
80#define XEN_ALLOC_IRQ (1 << 1)
81void xen_allocate_pirq_msi(char *name, int *irq, int *pirq, int alloc_mask);
80int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int type); 82int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int type);
81#endif 83#endif
82 84
@@ -89,4 +91,7 @@ int xen_vector_from_irq(unsigned pirq);
89/* Return gsi allocated to pirq */ 91/* Return gsi allocated to pirq */
90int xen_gsi_from_irq(unsigned pirq); 92int xen_gsi_from_irq(unsigned pirq);
91 93
94/* Return irq from pirq */
95int xen_irq_from_pirq(unsigned pirq);
96
92#endif /* _XEN_EVENTS_H */ 97#endif /* _XEN_EVENTS_H */
diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h
index e8cbf431c8cc..75271b9a8f61 100644
--- a/include/xen/interface/io/ring.h
+++ b/include/xen/interface/io/ring.h
@@ -24,8 +24,15 @@ typedef unsigned int RING_IDX;
24 * A ring contains as many entries as will fit, rounded down to the nearest 24 * A ring contains as many entries as will fit, rounded down to the nearest
25 * power of two (so we can mask with (size-1) to loop around). 25 * power of two (so we can mask with (size-1) to loop around).
26 */ 26 */
27#define __RING_SIZE(_s, _sz) \ 27#define __CONST_RING_SIZE(_s, _sz) \
28 (__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0]))) 28 (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
29 sizeof(((struct _s##_sring *)0)->ring[0])))
30
31/*
32 * The same for passing in an actual pointer instead of a name tag.
33 */
34#define __RING_SIZE(_s, _sz) \
35 (__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
29 36
30/* 37/*
31 * Macros to make the correct C datatypes for a new kind of ring. 38 * Macros to make the correct C datatypes for a new kind of ring.
diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index d7a6c13bde69..eac3ce153719 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -141,6 +141,19 @@ struct xen_machphys_mfn_list {
141DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list); 141DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list);
142 142
143/* 143/*
144 * Returns the location in virtual address space of the machine_to_phys
145 * mapping table. Architectures which do not have a m2p table, or which do not
146 * map it by default into guest address space, do not implement this command.
147 * arg == addr of xen_machphys_mapping_t.
148 */
149#define XENMEM_machphys_mapping 12
150struct xen_machphys_mapping {
151 unsigned long v_start, v_end; /* Start and end virtual addresses. */
152 unsigned long max_mfn; /* Maximum MFN that can be looked up. */
153};
154DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
155
156/*
144 * Sets the GPFN at which a particular page appears in the specified guest's 157 * Sets the GPFN at which a particular page appears in the specified guest's
145 * pseudophysical address space. 158 * pseudophysical address space.
146 * arg == addr of xen_add_to_physmap_t. 159 * arg == addr of xen_add_to_physmap_t.
diff --git a/include/xen/interface/physdev.h b/include/xen/interface/physdev.h
index 2b2c66c3df00..534cac89a77d 100644
--- a/include/xen/interface/physdev.h
+++ b/include/xen/interface/physdev.h
@@ -188,6 +188,16 @@ struct physdev_nr_pirqs {
188 uint32_t nr_pirqs; 188 uint32_t nr_pirqs;
189}; 189};
190 190
191/* type is MAP_PIRQ_TYPE_GSI or MAP_PIRQ_TYPE_MSI
192 * the hypercall returns a free pirq */
193#define PHYSDEVOP_get_free_pirq 23
194struct physdev_get_free_pirq {
195 /* IN */
196 int type;
197 /* OUT */
198 uint32_t pirq;
199};
200
191/* 201/*
192 * Notify that some PIRQ-bound event channels have been unmasked. 202 * Notify that some PIRQ-bound event channels have been unmasked.
193 * ** This command is obsolete since interface version 0x00030202 and is ** 203 * ** This command is obsolete since interface version 0x00030202 and is **
diff --git a/include/xen/page.h b/include/xen/page.h
index eaf85fab1263..0be36b976f4b 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -1 +1,8 @@
1#ifndef _XEN_PAGE_H
2#define _XEN_PAGE_H
3
1#include <asm/xen/page.h> 4#include <asm/xen/page.h>
5
6extern phys_addr_t xen_extra_mem_start, xen_extra_mem_size;
7
8#endif /* _XEN_PAGE_H */
diff --git a/include/xen/privcmd.h b/include/xen/privcmd.h
index b42cdfd92fee..17857fb4d550 100644
--- a/include/xen/privcmd.h
+++ b/include/xen/privcmd.h
@@ -34,13 +34,10 @@
34#define __LINUX_PUBLIC_PRIVCMD_H__ 34#define __LINUX_PUBLIC_PRIVCMD_H__
35 35
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/compiler.h>
37 38
38typedef unsigned long xen_pfn_t; 39typedef unsigned long xen_pfn_t;
39 40
40#ifndef __user
41#define __user
42#endif
43
44struct privcmd_hypercall { 41struct privcmd_hypercall {
45 __u64 op; 42 __u64 op;
46 __u64 arg[5]; 43 __u64 arg[5];
diff --git a/init/Kconfig b/init/Kconfig
index 88c10468db46..c9728992a776 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -613,6 +613,19 @@ config CGROUP_MEM_RES_CTLR_SWAP
613 if boot option "noswapaccount" is set, swap will not be accounted. 613 if boot option "noswapaccount" is set, swap will not be accounted.
614 Now, memory usage of swap_cgroup is 2 bytes per entry. If swap page 614 Now, memory usage of swap_cgroup is 2 bytes per entry. If swap page
615 size is 4096bytes, 512k per 1Gbytes of swap. 615 size is 4096bytes, 512k per 1Gbytes of swap.
616config CGROUP_MEM_RES_CTLR_SWAP_ENABLED
617 bool "Memory Resource Controller Swap Extension enabled by default"
618 depends on CGROUP_MEM_RES_CTLR_SWAP
619 default y
620 help
621 Memory Resource Controller Swap Extension comes with its price in
622 a bigger memory consumption. General purpose distribution kernels
623 which want to enable the feautre but keep it disabled by default
624 and let the user enable it by swapaccount boot command line
625 parameter should have this option unselected.
626 For those who want to have the feature enabled by default should
627 select this option (if, for some reason, they need to disable it
628 then noswapaccount does the trick).
616 629
617menuconfig CGROUP_SCHED 630menuconfig CGROUP_SCHED
618 bool "Group CPU scheduler" 631 bool "Group CPU scheduler"
diff --git a/init/main.c b/init/main.c
index e59af24a0b7c..8646401f7a0e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -20,7 +20,6 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/smp_lock.h>
24#include <linux/initrd.h> 23#include <linux/initrd.h>
25#include <linux/bootmem.h> 24#include <linux/bootmem.h>
26#include <linux/acpi.h> 25#include <linux/acpi.h>
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 37755d621924..a6e729766821 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -82,7 +82,7 @@ static kdbtab_t kdb_base_commands[50];
82#define for_each_kdbcmd(cmd, num) \ 82#define for_each_kdbcmd(cmd, num) \
83 for ((cmd) = kdb_base_commands, (num) = 0; \ 83 for ((cmd) = kdb_base_commands, (num) = 0; \
84 num < kdb_max_commands; \ 84 num < kdb_max_commands; \
85 num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++, num++) 85 num++, num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++)
86 86
87typedef struct _kdbmsg { 87typedef struct _kdbmsg {
88 int km_diag; /* kdb diagnostic */ 88 int km_diag; /* kdb diagnostic */
@@ -646,7 +646,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0)
646 } 646 }
647 if (!s->usable) 647 if (!s->usable)
648 return KDB_NOTIMP; 648 return KDB_NOTIMP;
649 s->command = kmalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB); 649 s->command = kzalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB);
650 if (!s->command) { 650 if (!s->command) {
651 kdb_printf("Could not allocate new kdb_defcmd table for %s\n", 651 kdb_printf("Could not allocate new kdb_defcmd table for %s\n",
652 cmdstr); 652 cmdstr);
@@ -2361,7 +2361,7 @@ static int kdb_pid(int argc, const char **argv)
2361 */ 2361 */
2362static int kdb_ll(int argc, const char **argv) 2362static int kdb_ll(int argc, const char **argv)
2363{ 2363{
2364 int diag; 2364 int diag = 0;
2365 unsigned long addr; 2365 unsigned long addr;
2366 long offset = 0; 2366 long offset = 0;
2367 unsigned long va; 2367 unsigned long va;
@@ -2400,20 +2400,21 @@ static int kdb_ll(int argc, const char **argv)
2400 char buf[80]; 2400 char buf[80];
2401 2401
2402 if (KDB_FLAG(CMD_INTERRUPT)) 2402 if (KDB_FLAG(CMD_INTERRUPT))
2403 return 0; 2403 goto out;
2404 2404
2405 sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va); 2405 sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va);
2406 diag = kdb_parse(buf); 2406 diag = kdb_parse(buf);
2407 if (diag) 2407 if (diag)
2408 return diag; 2408 goto out;
2409 2409
2410 addr = va + linkoffset; 2410 addr = va + linkoffset;
2411 if (kdb_getword(&va, addr, sizeof(va))) 2411 if (kdb_getword(&va, addr, sizeof(va)))
2412 return 0; 2412 goto out;
2413 } 2413 }
2414 kfree(command);
2415 2414
2416 return 0; 2415out:
2416 kfree(command);
2417 return diag;
2417} 2418}
2418 2419
2419static int kdb_kgdb(int argc, const char **argv) 2420static int kdb_kgdb(int argc, const char **argv)
@@ -2739,13 +2740,13 @@ int kdb_register_repeat(char *cmd,
2739 } 2740 }
2740 if (kdb_commands) { 2741 if (kdb_commands) {
2741 memcpy(new, kdb_commands, 2742 memcpy(new, kdb_commands,
2742 kdb_max_commands * sizeof(*new)); 2743 (kdb_max_commands - KDB_BASE_CMD_MAX) * sizeof(*new));
2743 kfree(kdb_commands); 2744 kfree(kdb_commands);
2744 } 2745 }
2745 memset(new + kdb_max_commands, 0, 2746 memset(new + kdb_max_commands, 0,
2746 kdb_command_extend * sizeof(*new)); 2747 kdb_command_extend * sizeof(*new));
2747 kdb_commands = new; 2748 kdb_commands = new;
2748 kp = kdb_commands + kdb_max_commands; 2749 kp = kdb_commands + kdb_max_commands - KDB_BASE_CMD_MAX;
2749 kdb_max_commands += kdb_command_extend; 2750 kdb_max_commands += kdb_command_extend;
2750 } 2751 }
2751 2752
diff --git a/kernel/exit.c b/kernel/exit.c
index 21aa7b3001fb..676149a4ac5f 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -914,6 +914,15 @@ NORET_TYPE void do_exit(long code)
914 if (unlikely(!tsk->pid)) 914 if (unlikely(!tsk->pid))
915 panic("Attempted to kill the idle task!"); 915 panic("Attempted to kill the idle task!");
916 916
917 /*
918 * If do_exit is called because this processes oopsed, it's possible
919 * that get_fs() was left as KERNEL_DS, so reset it to USER_DS before
920 * continuing. Amongst other possible reasons, this is to prevent
921 * mm_release()->clear_child_tid() from writing to a user-controlled
922 * kernel address.
923 */
924 set_fs(USER_DS);
925
917 tracehook_report_exit(&code); 926 tracehook_report_exit(&code);
918 927
919 validate_creds_for_do_exit(tsk); 928 validate_creds_for_do_exit(tsk);
diff --git a/kernel/fork.c b/kernel/fork.c
index 3b159c5991b7..5447dc7defa9 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -273,6 +273,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
273 273
274 setup_thread_stack(tsk, orig); 274 setup_thread_stack(tsk, orig);
275 clear_user_return_notifier(tsk); 275 clear_user_return_notifier(tsk);
276 clear_tsk_need_resched(tsk);
276 stackend = end_of_stack(tsk); 277 stackend = end_of_stack(tsk);
277 *stackend = STACK_END_MAGIC; /* for overflow detection */ 278 *stackend = STACK_END_MAGIC; /* for overflow detection */
278 279
diff --git a/kernel/futex.c b/kernel/futex.c
index 6c683b37f2ce..40a8777a27d0 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2489,7 +2489,8 @@ void exit_robust_list(struct task_struct *curr)
2489{ 2489{
2490 struct robust_list_head __user *head = curr->robust_list; 2490 struct robust_list_head __user *head = curr->robust_list;
2491 struct robust_list __user *entry, *next_entry, *pending; 2491 struct robust_list __user *entry, *next_entry, *pending;
2492 unsigned int limit = ROBUST_LIST_LIMIT, pi, next_pi, pip; 2492 unsigned int limit = ROBUST_LIST_LIMIT, pi, pip;
2493 unsigned int uninitialized_var(next_pi);
2493 unsigned long futex_offset; 2494 unsigned long futex_offset;
2494 int rc; 2495 int rc;
2495 2496
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index 06da4dfc339b..a7934ac75e5b 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -49,7 +49,8 @@ void compat_exit_robust_list(struct task_struct *curr)
49{ 49{
50 struct compat_robust_list_head __user *head = curr->compat_robust_list; 50 struct compat_robust_list_head __user *head = curr->compat_robust_list;
51 struct robust_list __user *entry, *next_entry, *pending; 51 struct robust_list __user *entry, *next_entry, *pending;
52 unsigned int limit = ROBUST_LIST_LIMIT, pi, next_pi, pip; 52 unsigned int limit = ROBUST_LIST_LIMIT, pi, pip;
53 unsigned int uninitialized_var(next_pi);
53 compat_uptr_t uentry, next_uentry, upending; 54 compat_uptr_t uentry, next_uentry, upending;
54 compat_long_t futex_offset; 55 compat_long_t futex_offset;
55 int rc; 56 int rc;
diff --git a/kernel/hw_breakpoint.c b/kernel/hw_breakpoint.c
index 2c9120f0afca..e5325825aeb6 100644
--- a/kernel/hw_breakpoint.c
+++ b/kernel/hw_breakpoint.c
@@ -620,7 +620,7 @@ static struct pmu perf_breakpoint = {
620 .read = hw_breakpoint_pmu_read, 620 .read = hw_breakpoint_pmu_read,
621}; 621};
622 622
623static int __init init_hw_breakpoint(void) 623int __init init_hw_breakpoint(void)
624{ 624{
625 unsigned int **task_bp_pinned; 625 unsigned int **task_bp_pinned;
626 int cpu, err_cpu; 626 int cpu, err_cpu;
@@ -655,6 +655,5 @@ static int __init init_hw_breakpoint(void)
655 655
656 return -ENOMEM; 656 return -ENOMEM;
657} 657}
658core_initcall(init_hw_breakpoint);
659 658
660 659
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 01b1d3a88983..6c8a2a9f8a7b 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -214,7 +214,7 @@ static int irq_spurious_proc_show(struct seq_file *m, void *v)
214 214
215static int irq_spurious_proc_open(struct inode *inode, struct file *file) 215static int irq_spurious_proc_open(struct inode *inode, struct file *file)
216{ 216{
217 return single_open(file, irq_spurious_proc_show, NULL); 217 return single_open(file, irq_spurious_proc_show, PDE(inode)->data);
218} 218}
219 219
220static const struct file_operations irq_spurious_proc_fops = { 220static const struct file_operations irq_spurious_proc_fops = {
diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index f16763ff8481..90f881904bb1 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -145,7 +145,9 @@ void irq_work_run(void)
145 * Clear the BUSY bit and return to the free state if 145 * Clear the BUSY bit and return to the free state if
146 * no-one else claimed it meanwhile. 146 * no-one else claimed it meanwhile.
147 */ 147 */
148 cmpxchg(&entry->next, next_flags(NULL, IRQ_WORK_BUSY), NULL); 148 (void)cmpxchg(&entry->next,
149 next_flags(NULL, IRQ_WORK_BUSY),
150 NULL);
149 } 151 }
150} 152}
151EXPORT_SYMBOL_GPL(irq_work_run); 153EXPORT_SYMBOL_GPL(irq_work_run);
diff --git a/kernel/module.c b/kernel/module.c
index 437a74a7524a..d190664f25ff 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2326,6 +2326,18 @@ static void find_module_sections(struct module *mod, struct load_info *info)
2326 kmemleak_scan_area(mod->trace_events, sizeof(*mod->trace_events) * 2326 kmemleak_scan_area(mod->trace_events, sizeof(*mod->trace_events) *
2327 mod->num_trace_events, GFP_KERNEL); 2327 mod->num_trace_events, GFP_KERNEL);
2328#endif 2328#endif
2329#ifdef CONFIG_TRACING
2330 mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
2331 sizeof(*mod->trace_bprintk_fmt_start),
2332 &mod->num_trace_bprintk_fmt);
2333 /*
2334 * This section contains pointers to allocated objects in the trace
2335 * code and not scanning it leads to false positives.
2336 */
2337 kmemleak_scan_area(mod->trace_bprintk_fmt_start,
2338 sizeof(*mod->trace_bprintk_fmt_start) *
2339 mod->num_trace_bprintk_fmt, GFP_KERNEL);
2340#endif
2329#ifdef CONFIG_FTRACE_MCOUNT_RECORD 2341#ifdef CONFIG_FTRACE_MCOUNT_RECORD
2330 /* sechdrs[0].sh_size is always zero */ 2342 /* sechdrs[0].sh_size is always zero */
2331 mod->ftrace_callsites = section_objs(info, "__mcount_loc", 2343 mod->ftrace_callsites = section_objs(info, "__mcount_loc",
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index cb6c0d2af68f..2870feee81dd 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -31,6 +31,7 @@
31#include <linux/kernel_stat.h> 31#include <linux/kernel_stat.h>
32#include <linux/perf_event.h> 32#include <linux/perf_event.h>
33#include <linux/ftrace_event.h> 33#include <linux/ftrace_event.h>
34#include <linux/hw_breakpoint.h>
34 35
35#include <asm/irq_regs.h> 36#include <asm/irq_regs.h>
36 37
@@ -1286,8 +1287,6 @@ void __perf_event_task_sched_out(struct task_struct *task,
1286{ 1287{
1287 int ctxn; 1288 int ctxn;
1288 1289
1289 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 1, NULL, 0);
1290
1291 for_each_task_context_nr(ctxn) 1290 for_each_task_context_nr(ctxn)
1292 perf_event_context_sched_out(task, ctxn, next); 1291 perf_event_context_sched_out(task, ctxn, next);
1293} 1292}
@@ -1621,8 +1620,12 @@ static void rotate_ctx(struct perf_event_context *ctx)
1621{ 1620{
1622 raw_spin_lock(&ctx->lock); 1621 raw_spin_lock(&ctx->lock);
1623 1622
1624 /* Rotate the first entry last of non-pinned groups */ 1623 /*
1625 list_rotate_left(&ctx->flexible_groups); 1624 * Rotate the first entry last of non-pinned groups. Rotation might be
1625 * disabled by the inheritance code.
1626 */
1627 if (!ctx->rotate_disable)
1628 list_rotate_left(&ctx->flexible_groups);
1626 1629
1627 raw_spin_unlock(&ctx->lock); 1630 raw_spin_unlock(&ctx->lock);
1628} 1631}
@@ -2234,11 +2237,6 @@ int perf_event_release_kernel(struct perf_event *event)
2234 raw_spin_unlock_irq(&ctx->lock); 2237 raw_spin_unlock_irq(&ctx->lock);
2235 mutex_unlock(&ctx->mutex); 2238 mutex_unlock(&ctx->mutex);
2236 2239
2237 mutex_lock(&event->owner->perf_event_mutex);
2238 list_del_init(&event->owner_entry);
2239 mutex_unlock(&event->owner->perf_event_mutex);
2240 put_task_struct(event->owner);
2241
2242 free_event(event); 2240 free_event(event);
2243 2241
2244 return 0; 2242 return 0;
@@ -2251,9 +2249,43 @@ EXPORT_SYMBOL_GPL(perf_event_release_kernel);
2251static int perf_release(struct inode *inode, struct file *file) 2249static int perf_release(struct inode *inode, struct file *file)
2252{ 2250{
2253 struct perf_event *event = file->private_data; 2251 struct perf_event *event = file->private_data;
2252 struct task_struct *owner;
2254 2253
2255 file->private_data = NULL; 2254 file->private_data = NULL;
2256 2255
2256 rcu_read_lock();
2257 owner = ACCESS_ONCE(event->owner);
2258 /*
2259 * Matches the smp_wmb() in perf_event_exit_task(). If we observe
2260 * !owner it means the list deletion is complete and we can indeed
2261 * free this event, otherwise we need to serialize on
2262 * owner->perf_event_mutex.
2263 */
2264 smp_read_barrier_depends();
2265 if (owner) {
2266 /*
2267 * Since delayed_put_task_struct() also drops the last
2268 * task reference we can safely take a new reference
2269 * while holding the rcu_read_lock().
2270 */
2271 get_task_struct(owner);
2272 }
2273 rcu_read_unlock();
2274
2275 if (owner) {
2276 mutex_lock(&owner->perf_event_mutex);
2277 /*
2278 * We have to re-check the event->owner field, if it is cleared
2279 * we raced with perf_event_exit_task(), acquiring the mutex
2280 * ensured they're done, and we can proceed with freeing the
2281 * event.
2282 */
2283 if (event->owner)
2284 list_del_init(&event->owner_entry);
2285 mutex_unlock(&owner->perf_event_mutex);
2286 put_task_struct(owner);
2287 }
2288
2257 return perf_event_release_kernel(event); 2289 return perf_event_release_kernel(event);
2258} 2290}
2259 2291
@@ -3792,6 +3824,8 @@ static void perf_event_task_event(struct perf_task_event *task_event)
3792 rcu_read_lock(); 3824 rcu_read_lock();
3793 list_for_each_entry_rcu(pmu, &pmus, entry) { 3825 list_for_each_entry_rcu(pmu, &pmus, entry) {
3794 cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); 3826 cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
3827 if (cpuctx->active_pmu != pmu)
3828 goto next;
3795 perf_event_task_ctx(&cpuctx->ctx, task_event); 3829 perf_event_task_ctx(&cpuctx->ctx, task_event);
3796 3830
3797 ctx = task_event->task_ctx; 3831 ctx = task_event->task_ctx;
@@ -3927,6 +3961,8 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
3927 rcu_read_lock(); 3961 rcu_read_lock();
3928 list_for_each_entry_rcu(pmu, &pmus, entry) { 3962 list_for_each_entry_rcu(pmu, &pmus, entry) {
3929 cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); 3963 cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
3964 if (cpuctx->active_pmu != pmu)
3965 goto next;
3930 perf_event_comm_ctx(&cpuctx->ctx, comm_event); 3966 perf_event_comm_ctx(&cpuctx->ctx, comm_event);
3931 3967
3932 ctxn = pmu->task_ctx_nr; 3968 ctxn = pmu->task_ctx_nr;
@@ -4112,6 +4148,8 @@ got_name:
4112 rcu_read_lock(); 4148 rcu_read_lock();
4113 list_for_each_entry_rcu(pmu, &pmus, entry) { 4149 list_for_each_entry_rcu(pmu, &pmus, entry) {
4114 cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); 4150 cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
4151 if (cpuctx->active_pmu != pmu)
4152 goto next;
4115 perf_event_mmap_ctx(&cpuctx->ctx, mmap_event, 4153 perf_event_mmap_ctx(&cpuctx->ctx, mmap_event,
4116 vma->vm_flags & VM_EXEC); 4154 vma->vm_flags & VM_EXEC);
4117 4155
@@ -4681,7 +4719,7 @@ static int perf_swevent_init(struct perf_event *event)
4681 break; 4719 break;
4682 } 4720 }
4683 4721
4684 if (event_id > PERF_COUNT_SW_MAX) 4722 if (event_id >= PERF_COUNT_SW_MAX)
4685 return -ENOENT; 4723 return -ENOENT;
4686 4724
4687 if (!event->parent) { 4725 if (!event->parent) {
@@ -5113,20 +5151,36 @@ static void *find_pmu_context(int ctxn)
5113 return NULL; 5151 return NULL;
5114} 5152}
5115 5153
5116static void free_pmu_context(void * __percpu cpu_context) 5154static void update_pmu_context(struct pmu *pmu, struct pmu *old_pmu)
5117{ 5155{
5118 struct pmu *pmu; 5156 int cpu;
5157
5158 for_each_possible_cpu(cpu) {
5159 struct perf_cpu_context *cpuctx;
5160
5161 cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
5162
5163 if (cpuctx->active_pmu == old_pmu)
5164 cpuctx->active_pmu = pmu;
5165 }
5166}
5167
5168static void free_pmu_context(struct pmu *pmu)
5169{
5170 struct pmu *i;
5119 5171
5120 mutex_lock(&pmus_lock); 5172 mutex_lock(&pmus_lock);
5121 /* 5173 /*
5122 * Like a real lame refcount. 5174 * Like a real lame refcount.
5123 */ 5175 */
5124 list_for_each_entry(pmu, &pmus, entry) { 5176 list_for_each_entry(i, &pmus, entry) {
5125 if (pmu->pmu_cpu_context == cpu_context) 5177 if (i->pmu_cpu_context == pmu->pmu_cpu_context) {
5178 update_pmu_context(i, pmu);
5126 goto out; 5179 goto out;
5180 }
5127 } 5181 }
5128 5182
5129 free_percpu(cpu_context); 5183 free_percpu(pmu->pmu_cpu_context);
5130out: 5184out:
5131 mutex_unlock(&pmus_lock); 5185 mutex_unlock(&pmus_lock);
5132} 5186}
@@ -5158,6 +5212,7 @@ int perf_pmu_register(struct pmu *pmu)
5158 cpuctx->ctx.pmu = pmu; 5212 cpuctx->ctx.pmu = pmu;
5159 cpuctx->jiffies_interval = 1; 5213 cpuctx->jiffies_interval = 1;
5160 INIT_LIST_HEAD(&cpuctx->rotation_list); 5214 INIT_LIST_HEAD(&cpuctx->rotation_list);
5215 cpuctx->active_pmu = pmu;
5161 } 5216 }
5162 5217
5163got_cpu_context: 5218got_cpu_context:
@@ -5209,7 +5264,7 @@ void perf_pmu_unregister(struct pmu *pmu)
5209 synchronize_rcu(); 5264 synchronize_rcu();
5210 5265
5211 free_percpu(pmu->pmu_disable_count); 5266 free_percpu(pmu->pmu_disable_count);
5212 free_pmu_context(pmu->pmu_cpu_context); 5267 free_pmu_context(pmu);
5213} 5268}
5214 5269
5215struct pmu *perf_init_event(struct perf_event *event) 5270struct pmu *perf_init_event(struct perf_event *event)
@@ -5677,7 +5732,7 @@ SYSCALL_DEFINE5(perf_event_open,
5677 mutex_unlock(&ctx->mutex); 5732 mutex_unlock(&ctx->mutex);
5678 5733
5679 event->owner = current; 5734 event->owner = current;
5680 get_task_struct(current); 5735
5681 mutex_lock(&current->perf_event_mutex); 5736 mutex_lock(&current->perf_event_mutex);
5682 list_add_tail(&event->owner_entry, &current->perf_event_list); 5737 list_add_tail(&event->owner_entry, &current->perf_event_list);
5683 mutex_unlock(&current->perf_event_mutex); 5738 mutex_unlock(&current->perf_event_mutex);
@@ -5745,12 +5800,6 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
5745 ++ctx->generation; 5800 ++ctx->generation;
5746 mutex_unlock(&ctx->mutex); 5801 mutex_unlock(&ctx->mutex);
5747 5802
5748 event->owner = current;
5749 get_task_struct(current);
5750 mutex_lock(&current->perf_event_mutex);
5751 list_add_tail(&event->owner_entry, &current->perf_event_list);
5752 mutex_unlock(&current->perf_event_mutex);
5753
5754 return event; 5803 return event;
5755 5804
5756err_free: 5805err_free:
@@ -5901,8 +5950,24 @@ again:
5901 */ 5950 */
5902void perf_event_exit_task(struct task_struct *child) 5951void perf_event_exit_task(struct task_struct *child)
5903{ 5952{
5953 struct perf_event *event, *tmp;
5904 int ctxn; 5954 int ctxn;
5905 5955
5956 mutex_lock(&child->perf_event_mutex);
5957 list_for_each_entry_safe(event, tmp, &child->perf_event_list,
5958 owner_entry) {
5959 list_del_init(&event->owner_entry);
5960
5961 /*
5962 * Ensure the list deletion is visible before we clear
5963 * the owner, closes a race against perf_release() where
5964 * we need to serialize on the owner->perf_event_mutex.
5965 */
5966 smp_wmb();
5967 event->owner = NULL;
5968 }
5969 mutex_unlock(&child->perf_event_mutex);
5970
5906 for_each_task_context_nr(ctxn) 5971 for_each_task_context_nr(ctxn)
5907 perf_event_exit_task_context(child, ctxn); 5972 perf_event_exit_task_context(child, ctxn);
5908} 5973}
@@ -6122,6 +6187,7 @@ int perf_event_init_context(struct task_struct *child, int ctxn)
6122 struct perf_event *event; 6187 struct perf_event *event;
6123 struct task_struct *parent = current; 6188 struct task_struct *parent = current;
6124 int inherited_all = 1; 6189 int inherited_all = 1;
6190 unsigned long flags;
6125 int ret = 0; 6191 int ret = 0;
6126 6192
6127 child->perf_event_ctxp[ctxn] = NULL; 6193 child->perf_event_ctxp[ctxn] = NULL;
@@ -6162,6 +6228,15 @@ int perf_event_init_context(struct task_struct *child, int ctxn)
6162 break; 6228 break;
6163 } 6229 }
6164 6230
6231 /*
6232 * We can't hold ctx->lock when iterating the ->flexible_group list due
6233 * to allocations, but we need to prevent rotation because
6234 * rotate_ctx() will change the list from interrupt context.
6235 */
6236 raw_spin_lock_irqsave(&parent_ctx->lock, flags);
6237 parent_ctx->rotate_disable = 1;
6238 raw_spin_unlock_irqrestore(&parent_ctx->lock, flags);
6239
6165 list_for_each_entry(event, &parent_ctx->flexible_groups, group_entry) { 6240 list_for_each_entry(event, &parent_ctx->flexible_groups, group_entry) {
6166 ret = inherit_task_group(event, parent, parent_ctx, 6241 ret = inherit_task_group(event, parent, parent_ctx,
6167 child, ctxn, &inherited_all); 6242 child, ctxn, &inherited_all);
@@ -6169,6 +6244,10 @@ int perf_event_init_context(struct task_struct *child, int ctxn)
6169 break; 6244 break;
6170 } 6245 }
6171 6246
6247 raw_spin_lock_irqsave(&parent_ctx->lock, flags);
6248 parent_ctx->rotate_disable = 0;
6249 raw_spin_unlock_irqrestore(&parent_ctx->lock, flags);
6250
6172 child_ctx = child->perf_event_ctxp[ctxn]; 6251 child_ctx = child->perf_event_ctxp[ctxn];
6173 6252
6174 if (child_ctx && inherited_all) { 6253 if (child_ctx && inherited_all) {
@@ -6321,6 +6400,8 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
6321 6400
6322void __init perf_event_init(void) 6401void __init perf_event_init(void)
6323{ 6402{
6403 int ret;
6404
6324 perf_event_init_all_cpus(); 6405 perf_event_init_all_cpus();
6325 init_srcu_struct(&pmus_srcu); 6406 init_srcu_struct(&pmus_srcu);
6326 perf_pmu_register(&perf_swevent); 6407 perf_pmu_register(&perf_swevent);
@@ -6328,4 +6409,7 @@ void __init perf_event_init(void)
6328 perf_pmu_register(&perf_task_clock); 6409 perf_pmu_register(&perf_task_clock);
6329 perf_tp_register(); 6410 perf_tp_register();
6330 perf_cpu_notifier(perf_cpu_notify); 6411 perf_cpu_notifier(perf_cpu_notify);
6412
6413 ret = init_hw_breakpoint();
6414 WARN(ret, "hw_breakpoint initialization failed with: %d", ret);
6331} 6415}
diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c
index c7a8f453919e..aeaa7f846821 100644
--- a/kernel/pm_qos_params.c
+++ b/kernel/pm_qos_params.c
@@ -121,10 +121,10 @@ static inline int pm_qos_get_value(struct pm_qos_object *o)
121 121
122 switch (o->type) { 122 switch (o->type) {
123 case PM_QOS_MIN: 123 case PM_QOS_MIN:
124 return plist_last(&o->requests)->prio; 124 return plist_first(&o->requests)->prio;
125 125
126 case PM_QOS_MAX: 126 case PM_QOS_MAX:
127 return plist_first(&o->requests)->prio; 127 return plist_last(&o->requests)->prio;
128 128
129 default: 129 default:
130 /* runtime check for not using enum */ 130 /* runtime check for not using enum */
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 6842eeba5879..05bb7173850e 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -37,13 +37,13 @@ static int check_clock(const clockid_t which_clock)
37 if (pid == 0) 37 if (pid == 0)
38 return 0; 38 return 0;
39 39
40 read_lock(&tasklist_lock); 40 rcu_read_lock();
41 p = find_task_by_vpid(pid); 41 p = find_task_by_vpid(pid);
42 if (!p || !(CPUCLOCK_PERTHREAD(which_clock) ? 42 if (!p || !(CPUCLOCK_PERTHREAD(which_clock) ?
43 same_thread_group(p, current) : thread_group_leader(p))) { 43 same_thread_group(p, current) : has_group_leader_pid(p))) {
44 error = -EINVAL; 44 error = -EINVAL;
45 } 45 }
46 read_unlock(&tasklist_lock); 46 rcu_read_unlock();
47 47
48 return error; 48 return error;
49} 49}
@@ -390,7 +390,7 @@ int posix_cpu_timer_create(struct k_itimer *new_timer)
390 390
391 INIT_LIST_HEAD(&new_timer->it.cpu.entry); 391 INIT_LIST_HEAD(&new_timer->it.cpu.entry);
392 392
393 read_lock(&tasklist_lock); 393 rcu_read_lock();
394 if (CPUCLOCK_PERTHREAD(new_timer->it_clock)) { 394 if (CPUCLOCK_PERTHREAD(new_timer->it_clock)) {
395 if (pid == 0) { 395 if (pid == 0) {
396 p = current; 396 p = current;
@@ -404,7 +404,7 @@ int posix_cpu_timer_create(struct k_itimer *new_timer)
404 p = current->group_leader; 404 p = current->group_leader;
405 } else { 405 } else {
406 p = find_task_by_vpid(pid); 406 p = find_task_by_vpid(pid);
407 if (p && !thread_group_leader(p)) 407 if (p && !has_group_leader_pid(p))
408 p = NULL; 408 p = NULL;
409 } 409 }
410 } 410 }
@@ -414,7 +414,7 @@ int posix_cpu_timer_create(struct k_itimer *new_timer)
414 } else { 414 } else {
415 ret = -EINVAL; 415 ret = -EINVAL;
416 } 416 }
417 read_unlock(&tasklist_lock); 417 rcu_read_unlock();
418 418
419 return ret; 419 return ret;
420} 420}
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 29bff6117abc..a5aff3ebad38 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -246,9 +246,13 @@ config PM_OPS
246 depends on PM_SLEEP || PM_RUNTIME 246 depends on PM_SLEEP || PM_RUNTIME
247 default y 247 default y
248 248
249config ARCH_HAS_OPP
250 bool
251
249config PM_OPP 252config PM_OPP
250 bool "Operating Performance Point (OPP) Layer library" 253 bool "Operating Performance Point (OPP) Layer library"
251 depends on PM 254 depends on PM
255 depends on ARCH_HAS_OPP
252 ---help--- 256 ---help---
253 SOCs have a standard set of tuples consisting of frequency and 257 SOCs have a standard set of tuples consisting of frequency and
254 voltage pairs that the device will support per voltage domain. This 258 voltage pairs that the device will support per voltage domain. This
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 657272e91d0a..048d0b514831 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -327,7 +327,6 @@ static int create_image(int platform_mode)
327int hibernation_snapshot(int platform_mode) 327int hibernation_snapshot(int platform_mode)
328{ 328{
329 int error; 329 int error;
330 gfp_t saved_mask;
331 330
332 error = platform_begin(platform_mode); 331 error = platform_begin(platform_mode);
333 if (error) 332 if (error)
@@ -339,7 +338,7 @@ int hibernation_snapshot(int platform_mode)
339 goto Close; 338 goto Close;
340 339
341 suspend_console(); 340 suspend_console();
342 saved_mask = clear_gfp_allowed_mask(GFP_IOFS); 341 pm_restrict_gfp_mask();
343 error = dpm_suspend_start(PMSG_FREEZE); 342 error = dpm_suspend_start(PMSG_FREEZE);
344 if (error) 343 if (error)
345 goto Recover_platform; 344 goto Recover_platform;
@@ -348,7 +347,10 @@ int hibernation_snapshot(int platform_mode)
348 goto Recover_platform; 347 goto Recover_platform;
349 348
350 error = create_image(platform_mode); 349 error = create_image(platform_mode);
351 /* Control returns here after successful restore */ 350 /*
351 * Control returns here (1) after the image has been created or the
352 * image creation has failed and (2) after a successful restore.
353 */
352 354
353 Resume_devices: 355 Resume_devices:
354 /* We may need to release the preallocated image pages here. */ 356 /* We may need to release the preallocated image pages here. */
@@ -357,7 +359,10 @@ int hibernation_snapshot(int platform_mode)
357 359
358 dpm_resume_end(in_suspend ? 360 dpm_resume_end(in_suspend ?
359 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); 361 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE);
360 set_gfp_allowed_mask(saved_mask); 362
363 if (error || !in_suspend)
364 pm_restore_gfp_mask();
365
361 resume_console(); 366 resume_console();
362 Close: 367 Close:
363 platform_end(platform_mode); 368 platform_end(platform_mode);
@@ -452,17 +457,16 @@ static int resume_target_kernel(bool platform_mode)
452int hibernation_restore(int platform_mode) 457int hibernation_restore(int platform_mode)
453{ 458{
454 int error; 459 int error;
455 gfp_t saved_mask;
456 460
457 pm_prepare_console(); 461 pm_prepare_console();
458 suspend_console(); 462 suspend_console();
459 saved_mask = clear_gfp_allowed_mask(GFP_IOFS); 463 pm_restrict_gfp_mask();
460 error = dpm_suspend_start(PMSG_QUIESCE); 464 error = dpm_suspend_start(PMSG_QUIESCE);
461 if (!error) { 465 if (!error) {
462 error = resume_target_kernel(platform_mode); 466 error = resume_target_kernel(platform_mode);
463 dpm_resume_end(PMSG_RECOVER); 467 dpm_resume_end(PMSG_RECOVER);
464 } 468 }
465 set_gfp_allowed_mask(saved_mask); 469 pm_restore_gfp_mask();
466 resume_console(); 470 resume_console();
467 pm_restore_console(); 471 pm_restore_console();
468 return error; 472 return error;
@@ -476,7 +480,6 @@ int hibernation_restore(int platform_mode)
476int hibernation_platform_enter(void) 480int hibernation_platform_enter(void)
477{ 481{
478 int error; 482 int error;
479 gfp_t saved_mask;
480 483
481 if (!hibernation_ops) 484 if (!hibernation_ops)
482 return -ENOSYS; 485 return -ENOSYS;
@@ -492,7 +495,6 @@ int hibernation_platform_enter(void)
492 495
493 entering_platform_hibernation = true; 496 entering_platform_hibernation = true;
494 suspend_console(); 497 suspend_console();
495 saved_mask = clear_gfp_allowed_mask(GFP_IOFS);
496 error = dpm_suspend_start(PMSG_HIBERNATE); 498 error = dpm_suspend_start(PMSG_HIBERNATE);
497 if (error) { 499 if (error) {
498 if (hibernation_ops->recover) 500 if (hibernation_ops->recover)
@@ -536,7 +538,6 @@ int hibernation_platform_enter(void)
536 Resume_devices: 538 Resume_devices:
537 entering_platform_hibernation = false; 539 entering_platform_hibernation = false;
538 dpm_resume_end(PMSG_RESTORE); 540 dpm_resume_end(PMSG_RESTORE);
539 set_gfp_allowed_mask(saved_mask);
540 resume_console(); 541 resume_console();
541 542
542 Close: 543 Close:
@@ -646,6 +647,7 @@ int hibernate(void)
646 swsusp_free(); 647 swsusp_free();
647 if (!error) 648 if (!error)
648 power_down(); 649 power_down();
650 pm_restore_gfp_mask();
649 } else { 651 } else {
650 pr_debug("PM: Image restored successfully.\n"); 652 pr_debug("PM: Image restored successfully.\n");
651 } 653 }
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 7335952ee473..ecf770509d0d 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -197,7 +197,6 @@ static int suspend_enter(suspend_state_t state)
197int suspend_devices_and_enter(suspend_state_t state) 197int suspend_devices_and_enter(suspend_state_t state)
198{ 198{
199 int error; 199 int error;
200 gfp_t saved_mask;
201 200
202 if (!suspend_ops) 201 if (!suspend_ops)
203 return -ENOSYS; 202 return -ENOSYS;
@@ -208,7 +207,7 @@ int suspend_devices_and_enter(suspend_state_t state)
208 goto Close; 207 goto Close;
209 } 208 }
210 suspend_console(); 209 suspend_console();
211 saved_mask = clear_gfp_allowed_mask(GFP_IOFS); 210 pm_restrict_gfp_mask();
212 suspend_test_start(); 211 suspend_test_start();
213 error = dpm_suspend_start(PMSG_SUSPEND); 212 error = dpm_suspend_start(PMSG_SUSPEND);
214 if (error) { 213 if (error) {
@@ -225,7 +224,7 @@ int suspend_devices_and_enter(suspend_state_t state)
225 suspend_test_start(); 224 suspend_test_start();
226 dpm_resume_end(PMSG_RESUME); 225 dpm_resume_end(PMSG_RESUME);
227 suspend_test_finish("resume devices"); 226 suspend_test_finish("resume devices");
228 set_gfp_allowed_mask(saved_mask); 227 pm_restore_gfp_mask();
229 resume_console(); 228 resume_console();
230 Close: 229 Close:
231 if (suspend_ops->end) 230 if (suspend_ops->end)
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index a0e4a86ccf94..8c7e4832b9be 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (C) 1998,2001-2005 Pavel Machek <pavel@ucw.cz> 7 * Copyright (C) 1998,2001-2005 Pavel Machek <pavel@ucw.cz>
8 * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl> 8 * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
9 * Copyright (C) 2010 Bojan Smojver <bojan@rexursive.com>
9 * 10 *
10 * This file is released under the GPLv2. 11 * This file is released under the GPLv2.
11 * 12 *
@@ -29,7 +30,7 @@
29 30
30#include "power.h" 31#include "power.h"
31 32
32#define HIBERNATE_SIG "LINHIB0001" 33#define HIBERNATE_SIG "S1SUSPEND"
33 34
34/* 35/*
35 * The swap map is a data structure used for keeping track of each page 36 * The swap map is a data structure used for keeping track of each page
@@ -753,30 +754,43 @@ static int load_image_lzo(struct swap_map_handle *handle,
753{ 754{
754 unsigned int m; 755 unsigned int m;
755 int error = 0; 756 int error = 0;
757 struct bio *bio;
756 struct timeval start; 758 struct timeval start;
757 struct timeval stop; 759 struct timeval stop;
758 unsigned nr_pages; 760 unsigned nr_pages;
759 size_t off, unc_len, cmp_len; 761 size_t i, off, unc_len, cmp_len;
760 unsigned char *unc, *cmp, *page; 762 unsigned char *unc, *cmp, *page[LZO_CMP_PAGES];
761 763
762 page = (void *)__get_free_page(__GFP_WAIT | __GFP_HIGH); 764 for (i = 0; i < LZO_CMP_PAGES; i++) {
763 if (!page) { 765 page[i] = (void *)__get_free_page(__GFP_WAIT | __GFP_HIGH);
764 printk(KERN_ERR "PM: Failed to allocate LZO page\n"); 766 if (!page[i]) {
765 return -ENOMEM; 767 printk(KERN_ERR "PM: Failed to allocate LZO page\n");
768
769 while (i)
770 free_page((unsigned long)page[--i]);
771
772 return -ENOMEM;
773 }
766 } 774 }
767 775
768 unc = vmalloc(LZO_UNC_SIZE); 776 unc = vmalloc(LZO_UNC_SIZE);
769 if (!unc) { 777 if (!unc) {
770 printk(KERN_ERR "PM: Failed to allocate LZO uncompressed\n"); 778 printk(KERN_ERR "PM: Failed to allocate LZO uncompressed\n");
771 free_page((unsigned long)page); 779
780 for (i = 0; i < LZO_CMP_PAGES; i++)
781 free_page((unsigned long)page[i]);
782
772 return -ENOMEM; 783 return -ENOMEM;
773 } 784 }
774 785
775 cmp = vmalloc(LZO_CMP_SIZE); 786 cmp = vmalloc(LZO_CMP_SIZE);
776 if (!cmp) { 787 if (!cmp) {
777 printk(KERN_ERR "PM: Failed to allocate LZO compressed\n"); 788 printk(KERN_ERR "PM: Failed to allocate LZO compressed\n");
789
778 vfree(unc); 790 vfree(unc);
779 free_page((unsigned long)page); 791 for (i = 0; i < LZO_CMP_PAGES; i++)
792 free_page((unsigned long)page[i]);
793
780 return -ENOMEM; 794 return -ENOMEM;
781 } 795 }
782 796
@@ -787,6 +801,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
787 if (!m) 801 if (!m)
788 m = 1; 802 m = 1;
789 nr_pages = 0; 803 nr_pages = 0;
804 bio = NULL;
790 do_gettimeofday(&start); 805 do_gettimeofday(&start);
791 806
792 error = snapshot_write_next(snapshot); 807 error = snapshot_write_next(snapshot);
@@ -794,11 +809,11 @@ static int load_image_lzo(struct swap_map_handle *handle,
794 goto out_finish; 809 goto out_finish;
795 810
796 for (;;) { 811 for (;;) {
797 error = swap_read_page(handle, page, NULL); /* sync */ 812 error = swap_read_page(handle, page[0], NULL); /* sync */
798 if (error) 813 if (error)
799 break; 814 break;
800 815
801 cmp_len = *(size_t *)page; 816 cmp_len = *(size_t *)page[0];
802 if (unlikely(!cmp_len || 817 if (unlikely(!cmp_len ||
803 cmp_len > lzo1x_worst_compress(LZO_UNC_SIZE))) { 818 cmp_len > lzo1x_worst_compress(LZO_UNC_SIZE))) {
804 printk(KERN_ERR "PM: Invalid LZO compressed length\n"); 819 printk(KERN_ERR "PM: Invalid LZO compressed length\n");
@@ -806,13 +821,20 @@ static int load_image_lzo(struct swap_map_handle *handle,
806 break; 821 break;
807 } 822 }
808 823
809 memcpy(cmp, page, PAGE_SIZE); 824 for (off = PAGE_SIZE, i = 1;
810 for (off = PAGE_SIZE; off < LZO_HEADER + cmp_len; off += PAGE_SIZE) { 825 off < LZO_HEADER + cmp_len; off += PAGE_SIZE, i++) {
811 error = swap_read_page(handle, page, NULL); /* sync */ 826 error = swap_read_page(handle, page[i], &bio);
812 if (error) 827 if (error)
813 goto out_finish; 828 goto out_finish;
829 }
814 830
815 memcpy(cmp + off, page, PAGE_SIZE); 831 error = hib_wait_on_bio_chain(&bio); /* need all data now */
832 if (error)
833 goto out_finish;
834
835 for (off = 0, i = 0;
836 off < LZO_HEADER + cmp_len; off += PAGE_SIZE, i++) {
837 memcpy(cmp + off, page[i], PAGE_SIZE);
816 } 838 }
817 839
818 unc_len = LZO_UNC_SIZE; 840 unc_len = LZO_UNC_SIZE;
@@ -857,7 +879,8 @@ out_finish:
857 879
858 vfree(cmp); 880 vfree(cmp);
859 vfree(unc); 881 vfree(unc);
860 free_page((unsigned long)page); 882 for (i = 0; i < LZO_CMP_PAGES; i++)
883 free_page((unsigned long)page[i]);
861 884
862 return error; 885 return error;
863} 886}
diff --git a/kernel/power/user.c b/kernel/power/user.c
index e819e17877ca..c36c3b9e8a84 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -137,7 +137,7 @@ static int snapshot_release(struct inode *inode, struct file *filp)
137 free_all_swap_pages(data->swap); 137 free_all_swap_pages(data->swap);
138 if (data->frozen) 138 if (data->frozen)
139 thaw_processes(); 139 thaw_processes();
140 pm_notifier_call_chain(data->mode == O_WRONLY ? 140 pm_notifier_call_chain(data->mode == O_RDONLY ?
141 PM_POST_HIBERNATION : PM_POST_RESTORE); 141 PM_POST_HIBERNATION : PM_POST_RESTORE);
142 atomic_inc(&snapshot_device_available); 142 atomic_inc(&snapshot_device_available);
143 143
@@ -263,6 +263,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
263 case SNAPSHOT_UNFREEZE: 263 case SNAPSHOT_UNFREEZE:
264 if (!data->frozen || data->ready) 264 if (!data->frozen || data->ready)
265 break; 265 break;
266 pm_restore_gfp_mask();
266 thaw_processes(); 267 thaw_processes();
267 usermodehelper_enable(); 268 usermodehelper_enable();
268 data->frozen = 0; 269 data->frozen = 0;
@@ -275,6 +276,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
275 error = -EPERM; 276 error = -EPERM;
276 break; 277 break;
277 } 278 }
279 pm_restore_gfp_mask();
278 error = hibernation_snapshot(data->platform_support); 280 error = hibernation_snapshot(data->platform_support);
279 if (!error) 281 if (!error)
280 error = put_user(in_suspend, (int __user *)arg); 282 error = put_user(in_suspend, (int __user *)arg);
diff --git a/kernel/printk.c b/kernel/printk.c
index 9a2264fc42ca..a23315dc4498 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1082,13 +1082,15 @@ void printk_tick(void)
1082 1082
1083int printk_needs_cpu(int cpu) 1083int printk_needs_cpu(int cpu)
1084{ 1084{
1085 if (unlikely(cpu_is_offline(cpu)))
1086 printk_tick();
1085 return per_cpu(printk_pending, cpu); 1087 return per_cpu(printk_pending, cpu);
1086} 1088}
1087 1089
1088void wake_up_klogd(void) 1090void wake_up_klogd(void)
1089{ 1091{
1090 if (waitqueue_active(&log_wait)) 1092 if (waitqueue_active(&log_wait))
1091 __raw_get_cpu_var(printk_pending) = 1; 1093 this_cpu_write(printk_pending, 1);
1092} 1094}
1093 1095
1094/** 1096/**
diff --git a/kernel/resource.c b/kernel/resource.c
index 9fad33efd0db..798e2fae2a06 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -40,23 +40,6 @@ EXPORT_SYMBOL(iomem_resource);
40 40
41static DEFINE_RWLOCK(resource_lock); 41static DEFINE_RWLOCK(resource_lock);
42 42
43/*
44 * By default, we allocate free space bottom-up. The architecture can request
45 * top-down by clearing this flag. The user can override the architecture's
46 * choice with the "resource_alloc_from_bottom" kernel boot option, but that
47 * should only be a debugging tool.
48 */
49int resource_alloc_from_bottom = 1;
50
51static __init int setup_alloc_from_bottom(char *s)
52{
53 printk(KERN_INFO
54 "resource: allocating from bottom-up; please report a bug\n");
55 resource_alloc_from_bottom = 1;
56 return 0;
57}
58early_param("resource_alloc_from_bottom", setup_alloc_from_bottom);
59
60static void *r_next(struct seq_file *m, void *v, loff_t *pos) 43static void *r_next(struct seq_file *m, void *v, loff_t *pos)
61{ 44{
62 struct resource *p = v; 45 struct resource *p = v;
@@ -374,6 +357,10 @@ int __weak page_is_ram(unsigned long pfn)
374 return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1; 357 return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1;
375} 358}
376 359
360void __weak arch_remove_reservations(struct resource *avail)
361{
362}
363
377static resource_size_t simple_align_resource(void *data, 364static resource_size_t simple_align_resource(void *data,
378 const struct resource *avail, 365 const struct resource *avail,
379 resource_size_t size, 366 resource_size_t size,
@@ -397,74 +384,7 @@ static bool resource_contains(struct resource *res1, struct resource *res2)
397} 384}
398 385
399/* 386/*
400 * Find the resource before "child" in the sibling list of "root" children.
401 */
402static struct resource *find_sibling_prev(struct resource *root, struct resource *child)
403{
404 struct resource *this;
405
406 for (this = root->child; this; this = this->sibling)
407 if (this->sibling == child)
408 return this;
409
410 return NULL;
411}
412
413/*
414 * Find empty slot in the resource tree given range and alignment. 387 * Find empty slot in the resource tree given range and alignment.
415 * This version allocates from the end of the root resource first.
416 */
417static int find_resource_from_top(struct resource *root, struct resource *new,
418 resource_size_t size, resource_size_t min,
419 resource_size_t max, resource_size_t align,
420 resource_size_t (*alignf)(void *,
421 const struct resource *,
422 resource_size_t,
423 resource_size_t),
424 void *alignf_data)
425{
426 struct resource *this;
427 struct resource tmp, avail, alloc;
428
429 tmp.start = root->end;
430 tmp.end = root->end;
431
432 this = find_sibling_prev(root, NULL);
433 for (;;) {
434 if (this) {
435 if (this->end < root->end)
436 tmp.start = this->end + 1;
437 } else
438 tmp.start = root->start;
439
440 resource_clip(&tmp, min, max);
441
442 /* Check for overflow after ALIGN() */
443 avail = *new;
444 avail.start = ALIGN(tmp.start, align);
445 avail.end = tmp.end;
446 if (avail.start >= tmp.start) {
447 alloc.start = alignf(alignf_data, &avail, size, align);
448 alloc.end = alloc.start + size - 1;
449 if (resource_contains(&avail, &alloc)) {
450 new->start = alloc.start;
451 new->end = alloc.end;
452 return 0;
453 }
454 }
455
456 if (!this || this->start == root->start)
457 break;
458
459 tmp.end = this->start - 1;
460 this = find_sibling_prev(root, this);
461 }
462 return -EBUSY;
463}
464
465/*
466 * Find empty slot in the resource tree given range and alignment.
467 * This version allocates from the beginning of the root resource first.
468 */ 388 */
469static int find_resource(struct resource *root, struct resource *new, 389static int find_resource(struct resource *root, struct resource *new,
470 resource_size_t size, resource_size_t min, 390 resource_size_t size, resource_size_t min,
@@ -478,23 +398,24 @@ static int find_resource(struct resource *root, struct resource *new,
478 struct resource *this = root->child; 398 struct resource *this = root->child;
479 struct resource tmp = *new, avail, alloc; 399 struct resource tmp = *new, avail, alloc;
480 400
401 tmp.flags = new->flags;
481 tmp.start = root->start; 402 tmp.start = root->start;
482 /* 403 /*
483 * Skip past an allocated resource that starts at 0, since the 404 * Skip past an allocated resource that starts at 0, since the assignment
484 * assignment of this->start - 1 to tmp->end below would cause an 405 * of this->start - 1 to tmp->end below would cause an underflow.
485 * underflow.
486 */ 406 */
487 if (this && this->start == 0) { 407 if (this && this->start == 0) {
488 tmp.start = this->end + 1; 408 tmp.start = this->end + 1;
489 this = this->sibling; 409 this = this->sibling;
490 } 410 }
491 for (;;) { 411 for(;;) {
492 if (this) 412 if (this)
493 tmp.end = this->start - 1; 413 tmp.end = this->start - 1;
494 else 414 else
495 tmp.end = root->end; 415 tmp.end = root->end;
496 416
497 resource_clip(&tmp, min, max); 417 resource_clip(&tmp, min, max);
418 arch_remove_reservations(&tmp);
498 419
499 /* Check for overflow after ALIGN() */ 420 /* Check for overflow after ALIGN() */
500 avail = *new; 421 avail = *new;
@@ -509,10 +430,8 @@ static int find_resource(struct resource *root, struct resource *new,
509 return 0; 430 return 0;
510 } 431 }
511 } 432 }
512
513 if (!this) 433 if (!this)
514 break; 434 break;
515
516 tmp.start = this->end + 1; 435 tmp.start = this->end + 1;
517 this = this->sibling; 436 this = this->sibling;
518 } 437 }
@@ -545,10 +464,7 @@ int allocate_resource(struct resource *root, struct resource *new,
545 alignf = simple_align_resource; 464 alignf = simple_align_resource;
546 465
547 write_lock(&resource_lock); 466 write_lock(&resource_lock);
548 if (resource_alloc_from_bottom) 467 err = find_resource(root, new, size, min, max, align, alignf, alignf_data);
549 err = find_resource(root, new, size, min, max, align, alignf, alignf_data);
550 else
551 err = find_resource_from_top(root, new, size, min, max, align, alignf, alignf_data);
552 if (err >= 0 && __request_resource(root, new)) 468 if (err >= 0 && __request_resource(root, new))
553 err = -EBUSY; 469 err = -EBUSY;
554 write_unlock(&resource_lock); 470 write_unlock(&resource_lock);
diff --git a/kernel/sched.c b/kernel/sched.c
index aa14a56f9d03..297d1a0eedb0 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -560,18 +560,8 @@ struct rq {
560 560
561static DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); 561static DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
562 562
563static inline
564void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags)
565{
566 rq->curr->sched_class->check_preempt_curr(rq, p, flags);
567 563
568 /* 564static void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags);
569 * A queue event has occurred, and we're going to schedule. In
570 * this case, we can save a useless back to back clock update.
571 */
572 if (test_tsk_need_resched(p))
573 rq->skip_clock_update = 1;
574}
575 565
576static inline int cpu_of(struct rq *rq) 566static inline int cpu_of(struct rq *rq)
577{ 567{
@@ -646,22 +636,18 @@ static inline struct task_group *task_group(struct task_struct *p)
646 636
647#endif /* CONFIG_CGROUP_SCHED */ 637#endif /* CONFIG_CGROUP_SCHED */
648 638
649static u64 irq_time_cpu(int cpu); 639static void update_rq_clock_task(struct rq *rq, s64 delta);
650static void sched_irq_time_avg_update(struct rq *rq, u64 irq_time);
651 640
652inline void update_rq_clock(struct rq *rq) 641static void update_rq_clock(struct rq *rq)
653{ 642{
654 if (!rq->skip_clock_update) { 643 s64 delta;
655 int cpu = cpu_of(rq);
656 u64 irq_time;
657 644
658 rq->clock = sched_clock_cpu(cpu); 645 if (rq->skip_clock_update)
659 irq_time = irq_time_cpu(cpu); 646 return;
660 if (rq->clock - irq_time > rq->clock_task)
661 rq->clock_task = rq->clock - irq_time;
662 647
663 sched_irq_time_avg_update(rq, irq_time); 648 delta = sched_clock_cpu(cpu_of(rq)) - rq->clock;
664 } 649 rq->clock += delta;
650 update_rq_clock_task(rq, delta);
665} 651}
666 652
667/* 653/*
@@ -1934,10 +1920,9 @@ static void deactivate_task(struct rq *rq, struct task_struct *p, int flags)
1934 * They are read and saved off onto struct rq in update_rq_clock(). 1920 * They are read and saved off onto struct rq in update_rq_clock().
1935 * This may result in other CPU reading this CPU's irq time and can 1921 * This may result in other CPU reading this CPU's irq time and can
1936 * race with irq/account_system_vtime on this CPU. We would either get old 1922 * race with irq/account_system_vtime on this CPU. We would either get old
1937 * or new value (or semi updated value on 32 bit) with a side effect of 1923 * or new value with a side effect of accounting a slice of irq time to wrong
1938 * accounting a slice of irq time to wrong task when irq is in progress 1924 * task when irq is in progress while we read rq->clock. That is a worthy
1939 * while we read rq->clock. That is a worthy compromise in place of having 1925 * compromise in place of having locks on each irq in account_system_time.
1940 * locks on each irq in account_system_time.
1941 */ 1926 */
1942static DEFINE_PER_CPU(u64, cpu_hardirq_time); 1927static DEFINE_PER_CPU(u64, cpu_hardirq_time);
1943static DEFINE_PER_CPU(u64, cpu_softirq_time); 1928static DEFINE_PER_CPU(u64, cpu_softirq_time);
@@ -1955,19 +1940,58 @@ void disable_sched_clock_irqtime(void)
1955 sched_clock_irqtime = 0; 1940 sched_clock_irqtime = 0;
1956} 1941}
1957 1942
1958static u64 irq_time_cpu(int cpu) 1943#ifndef CONFIG_64BIT
1944static DEFINE_PER_CPU(seqcount_t, irq_time_seq);
1945
1946static inline void irq_time_write_begin(void)
1959{ 1947{
1960 if (!sched_clock_irqtime) 1948 __this_cpu_inc(irq_time_seq.sequence);
1961 return 0; 1949 smp_wmb();
1950}
1962 1951
1952static inline void irq_time_write_end(void)
1953{
1954 smp_wmb();
1955 __this_cpu_inc(irq_time_seq.sequence);
1956}
1957
1958static inline u64 irq_time_read(int cpu)
1959{
1960 u64 irq_time;
1961 unsigned seq;
1962
1963 do {
1964 seq = read_seqcount_begin(&per_cpu(irq_time_seq, cpu));
1965 irq_time = per_cpu(cpu_softirq_time, cpu) +
1966 per_cpu(cpu_hardirq_time, cpu);
1967 } while (read_seqcount_retry(&per_cpu(irq_time_seq, cpu), seq));
1968
1969 return irq_time;
1970}
1971#else /* CONFIG_64BIT */
1972static inline void irq_time_write_begin(void)
1973{
1974}
1975
1976static inline void irq_time_write_end(void)
1977{
1978}
1979
1980static inline u64 irq_time_read(int cpu)
1981{
1963 return per_cpu(cpu_softirq_time, cpu) + per_cpu(cpu_hardirq_time, cpu); 1982 return per_cpu(cpu_softirq_time, cpu) + per_cpu(cpu_hardirq_time, cpu);
1964} 1983}
1984#endif /* CONFIG_64BIT */
1965 1985
1986/*
1987 * Called before incrementing preempt_count on {soft,}irq_enter
1988 * and before decrementing preempt_count on {soft,}irq_exit.
1989 */
1966void account_system_vtime(struct task_struct *curr) 1990void account_system_vtime(struct task_struct *curr)
1967{ 1991{
1968 unsigned long flags; 1992 unsigned long flags;
1993 s64 delta;
1969 int cpu; 1994 int cpu;
1970 u64 now, delta;
1971 1995
1972 if (!sched_clock_irqtime) 1996 if (!sched_clock_irqtime)
1973 return; 1997 return;
@@ -1975,9 +1999,10 @@ void account_system_vtime(struct task_struct *curr)
1975 local_irq_save(flags); 1999 local_irq_save(flags);
1976 2000
1977 cpu = smp_processor_id(); 2001 cpu = smp_processor_id();
1978 now = sched_clock_cpu(cpu); 2002 delta = sched_clock_cpu(cpu) - __this_cpu_read(irq_start_time);
1979 delta = now - per_cpu(irq_start_time, cpu); 2003 __this_cpu_add(irq_start_time, delta);
1980 per_cpu(irq_start_time, cpu) = now; 2004
2005 irq_time_write_begin();
1981 /* 2006 /*
1982 * We do not account for softirq time from ksoftirqd here. 2007 * We do not account for softirq time from ksoftirqd here.
1983 * We want to continue accounting softirq time to ksoftirqd thread 2008 * We want to continue accounting softirq time to ksoftirqd thread
@@ -1985,33 +2010,55 @@ void account_system_vtime(struct task_struct *curr)
1985 * that do not consume any time, but still wants to run. 2010 * that do not consume any time, but still wants to run.
1986 */ 2011 */
1987 if (hardirq_count()) 2012 if (hardirq_count())
1988 per_cpu(cpu_hardirq_time, cpu) += delta; 2013 __this_cpu_add(cpu_hardirq_time, delta);
1989 else if (in_serving_softirq() && !(curr->flags & PF_KSOFTIRQD)) 2014 else if (in_serving_softirq() && !(curr->flags & PF_KSOFTIRQD))
1990 per_cpu(cpu_softirq_time, cpu) += delta; 2015 __this_cpu_add(cpu_softirq_time, delta);
1991 2016
2017 irq_time_write_end();
1992 local_irq_restore(flags); 2018 local_irq_restore(flags);
1993} 2019}
1994EXPORT_SYMBOL_GPL(account_system_vtime); 2020EXPORT_SYMBOL_GPL(account_system_vtime);
1995 2021
1996static void sched_irq_time_avg_update(struct rq *rq, u64 curr_irq_time) 2022static void update_rq_clock_task(struct rq *rq, s64 delta)
1997{ 2023{
1998 if (sched_clock_irqtime && sched_feat(NONIRQ_POWER)) { 2024 s64 irq_delta;
1999 u64 delta_irq = curr_irq_time - rq->prev_irq_time; 2025
2000 rq->prev_irq_time = curr_irq_time; 2026 irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;
2001 sched_rt_avg_update(rq, delta_irq); 2027
2002 } 2028 /*
2029 * Since irq_time is only updated on {soft,}irq_exit, we might run into
2030 * this case when a previous update_rq_clock() happened inside a
2031 * {soft,}irq region.
2032 *
2033 * When this happens, we stop ->clock_task and only update the
2034 * prev_irq_time stamp to account for the part that fit, so that a next
2035 * update will consume the rest. This ensures ->clock_task is
2036 * monotonic.
2037 *
2038 * It does however cause some slight miss-attribution of {soft,}irq
2039 * time, a more accurate solution would be to update the irq_time using
2040 * the current rq->clock timestamp, except that would require using
2041 * atomic ops.
2042 */
2043 if (irq_delta > delta)
2044 irq_delta = delta;
2045
2046 rq->prev_irq_time += irq_delta;
2047 delta -= irq_delta;
2048 rq->clock_task += delta;
2049
2050 if (irq_delta && sched_feat(NONIRQ_POWER))
2051 sched_rt_avg_update(rq, irq_delta);
2003} 2052}
2004 2053
2005#else 2054#else /* CONFIG_IRQ_TIME_ACCOUNTING */
2006 2055
2007static u64 irq_time_cpu(int cpu) 2056static void update_rq_clock_task(struct rq *rq, s64 delta)
2008{ 2057{
2009 return 0; 2058 rq->clock_task += delta;
2010} 2059}
2011 2060
2012static void sched_irq_time_avg_update(struct rq *rq, u64 curr_irq_time) { } 2061#endif /* CONFIG_IRQ_TIME_ACCOUNTING */
2013
2014#endif
2015 2062
2016#include "sched_idletask.c" 2063#include "sched_idletask.c"
2017#include "sched_fair.c" 2064#include "sched_fair.c"
@@ -2118,6 +2165,31 @@ static inline void check_class_changed(struct rq *rq, struct task_struct *p,
2118 p->sched_class->prio_changed(rq, p, oldprio, running); 2165 p->sched_class->prio_changed(rq, p, oldprio, running);
2119} 2166}
2120 2167
2168static void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags)
2169{
2170 const struct sched_class *class;
2171
2172 if (p->sched_class == rq->curr->sched_class) {
2173 rq->curr->sched_class->check_preempt_curr(rq, p, flags);
2174 } else {
2175 for_each_class(class) {
2176 if (class == rq->curr->sched_class)
2177 break;
2178 if (class == p->sched_class) {
2179 resched_task(rq->curr);
2180 break;
2181 }
2182 }
2183 }
2184
2185 /*
2186 * A queue event has occurred, and we're going to schedule. In
2187 * this case, we can save a useless back to back clock update.
2188 */
2189 if (rq->curr->se.on_rq && test_tsk_need_resched(rq->curr))
2190 rq->skip_clock_update = 1;
2191}
2192
2121#ifdef CONFIG_SMP 2193#ifdef CONFIG_SMP
2122/* 2194/*
2123 * Is this task likely cache-hot: 2195 * Is this task likely cache-hot:
@@ -3104,6 +3176,15 @@ static long calc_load_fold_active(struct rq *this_rq)
3104 return delta; 3176 return delta;
3105} 3177}
3106 3178
3179static unsigned long
3180calc_load(unsigned long load, unsigned long exp, unsigned long active)
3181{
3182 load *= exp;
3183 load += active * (FIXED_1 - exp);
3184 load += 1UL << (FSHIFT - 1);
3185 return load >> FSHIFT;
3186}
3187
3107#ifdef CONFIG_NO_HZ 3188#ifdef CONFIG_NO_HZ
3108/* 3189/*
3109 * For NO_HZ we delay the active fold to the next LOAD_FREQ update. 3190 * For NO_HZ we delay the active fold to the next LOAD_FREQ update.
@@ -3133,6 +3214,128 @@ static long calc_load_fold_idle(void)
3133 3214
3134 return delta; 3215 return delta;
3135} 3216}
3217
3218/**
3219 * fixed_power_int - compute: x^n, in O(log n) time
3220 *
3221 * @x: base of the power
3222 * @frac_bits: fractional bits of @x
3223 * @n: power to raise @x to.
3224 *
3225 * By exploiting the relation between the definition of the natural power
3226 * function: x^n := x*x*...*x (x multiplied by itself for n times), and
3227 * the binary encoding of numbers used by computers: n := \Sum n_i * 2^i,
3228 * (where: n_i \elem {0, 1}, the binary vector representing n),
3229 * we find: x^n := x^(\Sum n_i * 2^i) := \Prod x^(n_i * 2^i), which is
3230 * of course trivially computable in O(log_2 n), the length of our binary
3231 * vector.
3232 */
3233static unsigned long
3234fixed_power_int(unsigned long x, unsigned int frac_bits, unsigned int n)
3235{
3236 unsigned long result = 1UL << frac_bits;
3237
3238 if (n) for (;;) {
3239 if (n & 1) {
3240 result *= x;
3241 result += 1UL << (frac_bits - 1);
3242 result >>= frac_bits;
3243 }
3244 n >>= 1;
3245 if (!n)
3246 break;
3247 x *= x;
3248 x += 1UL << (frac_bits - 1);
3249 x >>= frac_bits;
3250 }
3251
3252 return result;
3253}
3254
3255/*
3256 * a1 = a0 * e + a * (1 - e)
3257 *
3258 * a2 = a1 * e + a * (1 - e)
3259 * = (a0 * e + a * (1 - e)) * e + a * (1 - e)
3260 * = a0 * e^2 + a * (1 - e) * (1 + e)
3261 *
3262 * a3 = a2 * e + a * (1 - e)
3263 * = (a0 * e^2 + a * (1 - e) * (1 + e)) * e + a * (1 - e)
3264 * = a0 * e^3 + a * (1 - e) * (1 + e + e^2)
3265 *
3266 * ...
3267 *
3268 * an = a0 * e^n + a * (1 - e) * (1 + e + ... + e^n-1) [1]
3269 * = a0 * e^n + a * (1 - e) * (1 - e^n)/(1 - e)
3270 * = a0 * e^n + a * (1 - e^n)
3271 *
3272 * [1] application of the geometric series:
3273 *
3274 * n 1 - x^(n+1)
3275 * S_n := \Sum x^i = -------------
3276 * i=0 1 - x
3277 */
3278static unsigned long
3279calc_load_n(unsigned long load, unsigned long exp,
3280 unsigned long active, unsigned int n)
3281{
3282
3283 return calc_load(load, fixed_power_int(exp, FSHIFT, n), active);
3284}
3285
3286/*
3287 * NO_HZ can leave us missing all per-cpu ticks calling
3288 * calc_load_account_active(), but since an idle CPU folds its delta into
3289 * calc_load_tasks_idle per calc_load_account_idle(), all we need to do is fold
3290 * in the pending idle delta if our idle period crossed a load cycle boundary.
3291 *
3292 * Once we've updated the global active value, we need to apply the exponential
3293 * weights adjusted to the number of cycles missed.
3294 */
3295static void calc_global_nohz(unsigned long ticks)
3296{
3297 long delta, active, n;
3298
3299 if (time_before(jiffies, calc_load_update))
3300 return;
3301
3302 /*
3303 * If we crossed a calc_load_update boundary, make sure to fold
3304 * any pending idle changes, the respective CPUs might have
3305 * missed the tick driven calc_load_account_active() update
3306 * due to NO_HZ.
3307 */
3308 delta = calc_load_fold_idle();
3309 if (delta)
3310 atomic_long_add(delta, &calc_load_tasks);
3311
3312 /*
3313 * If we were idle for multiple load cycles, apply them.
3314 */
3315 if (ticks >= LOAD_FREQ) {
3316 n = ticks / LOAD_FREQ;
3317
3318 active = atomic_long_read(&calc_load_tasks);
3319 active = active > 0 ? active * FIXED_1 : 0;
3320
3321 avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n);
3322 avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n);
3323 avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n);
3324
3325 calc_load_update += n * LOAD_FREQ;
3326 }
3327
3328 /*
3329 * Its possible the remainder of the above division also crosses
3330 * a LOAD_FREQ period, the regular check in calc_global_load()
3331 * which comes after this will take care of that.
3332 *
3333 * Consider us being 11 ticks before a cycle completion, and us
3334 * sleeping for 4*LOAD_FREQ + 22 ticks, then the above code will
3335 * age us 4 cycles, and the test in calc_global_load() will
3336 * pick up the final one.
3337 */
3338}
3136#else 3339#else
3137static void calc_load_account_idle(struct rq *this_rq) 3340static void calc_load_account_idle(struct rq *this_rq)
3138{ 3341{
@@ -3142,6 +3345,10 @@ static inline long calc_load_fold_idle(void)
3142{ 3345{
3143 return 0; 3346 return 0;
3144} 3347}
3348
3349static void calc_global_nohz(unsigned long ticks)
3350{
3351}
3145#endif 3352#endif
3146 3353
3147/** 3354/**
@@ -3159,24 +3366,17 @@ void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
3159 loads[2] = (avenrun[2] + offset) << shift; 3366 loads[2] = (avenrun[2] + offset) << shift;
3160} 3367}
3161 3368
3162static unsigned long
3163calc_load(unsigned long load, unsigned long exp, unsigned long active)
3164{
3165 load *= exp;
3166 load += active * (FIXED_1 - exp);
3167 return load >> FSHIFT;
3168}
3169
3170/* 3369/*
3171 * calc_load - update the avenrun load estimates 10 ticks after the 3370 * calc_load - update the avenrun load estimates 10 ticks after the
3172 * CPUs have updated calc_load_tasks. 3371 * CPUs have updated calc_load_tasks.
3173 */ 3372 */
3174void calc_global_load(void) 3373void calc_global_load(unsigned long ticks)
3175{ 3374{
3176 unsigned long upd = calc_load_update + 10;
3177 long active; 3375 long active;
3178 3376
3179 if (time_before(jiffies, upd)) 3377 calc_global_nohz(ticks);
3378
3379 if (time_before(jiffies, calc_load_update + 10))
3180 return; 3380 return;
3181 3381
3182 active = atomic_long_read(&calc_load_tasks); 3382 active = atomic_long_read(&calc_load_tasks);
@@ -3830,7 +4030,6 @@ static void put_prev_task(struct rq *rq, struct task_struct *prev)
3830{ 4030{
3831 if (prev->se.on_rq) 4031 if (prev->se.on_rq)
3832 update_rq_clock(rq); 4032 update_rq_clock(rq);
3833 rq->skip_clock_update = 0;
3834 prev->sched_class->put_prev_task(rq, prev); 4033 prev->sched_class->put_prev_task(rq, prev);
3835} 4034}
3836 4035
@@ -3888,7 +4087,6 @@ need_resched_nonpreemptible:
3888 hrtick_clear(rq); 4087 hrtick_clear(rq);
3889 4088
3890 raw_spin_lock_irq(&rq->lock); 4089 raw_spin_lock_irq(&rq->lock);
3891 clear_tsk_need_resched(prev);
3892 4090
3893 switch_count = &prev->nivcsw; 4091 switch_count = &prev->nivcsw;
3894 if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { 4092 if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
@@ -3920,6 +4118,8 @@ need_resched_nonpreemptible:
3920 4118
3921 put_prev_task(rq, prev); 4119 put_prev_task(rq, prev);
3922 next = pick_next_task(rq); 4120 next = pick_next_task(rq);
4121 clear_tsk_need_resched(prev);
4122 rq->skip_clock_update = 0;
3923 4123
3924 if (likely(prev != next)) { 4124 if (likely(prev != next)) {
3925 sched_info_switch(prev, next); 4125 sched_info_switch(prev, next);
@@ -6960,6 +7160,8 @@ static void init_sched_groups_power(int cpu, struct sched_domain *sd)
6960 if (cpu != group_first_cpu(sd->groups)) 7160 if (cpu != group_first_cpu(sd->groups))
6961 return; 7161 return;
6962 7162
7163 sd->groups->group_weight = cpumask_weight(sched_group_cpus(sd->groups));
7164
6963 child = sd->child; 7165 child = sd->child;
6964 7166
6965 sd->groups->cpu_power = 0; 7167 sd->groups->cpu_power = 0;
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index f4f6a8326dd0..00ebd7686676 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1654,12 +1654,6 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
1654 struct cfs_rq *cfs_rq = task_cfs_rq(curr); 1654 struct cfs_rq *cfs_rq = task_cfs_rq(curr);
1655 int scale = cfs_rq->nr_running >= sched_nr_latency; 1655 int scale = cfs_rq->nr_running >= sched_nr_latency;
1656 1656
1657 if (unlikely(rt_prio(p->prio)))
1658 goto preempt;
1659
1660 if (unlikely(p->sched_class != &fair_sched_class))
1661 return;
1662
1663 if (unlikely(se == pse)) 1657 if (unlikely(se == pse))
1664 return; 1658 return;
1665 1659
@@ -1764,10 +1758,6 @@ static void pull_task(struct rq *src_rq, struct task_struct *p,
1764 set_task_cpu(p, this_cpu); 1758 set_task_cpu(p, this_cpu);
1765 activate_task(this_rq, p, 0); 1759 activate_task(this_rq, p, 0);
1766 check_preempt_curr(this_rq, p, 0); 1760 check_preempt_curr(this_rq, p, 0);
1767
1768 /* re-arm NEWIDLE balancing when moving tasks */
1769 src_rq->avg_idle = this_rq->avg_idle = 2*sysctl_sched_migration_cost;
1770 this_rq->idle_stamp = 0;
1771} 1761}
1772 1762
1773/* 1763/*
@@ -2035,13 +2025,16 @@ struct sd_lb_stats {
2035 unsigned long this_load_per_task; 2025 unsigned long this_load_per_task;
2036 unsigned long this_nr_running; 2026 unsigned long this_nr_running;
2037 unsigned long this_has_capacity; 2027 unsigned long this_has_capacity;
2028 unsigned int this_idle_cpus;
2038 2029
2039 /* Statistics of the busiest group */ 2030 /* Statistics of the busiest group */
2031 unsigned int busiest_idle_cpus;
2040 unsigned long max_load; 2032 unsigned long max_load;
2041 unsigned long busiest_load_per_task; 2033 unsigned long busiest_load_per_task;
2042 unsigned long busiest_nr_running; 2034 unsigned long busiest_nr_running;
2043 unsigned long busiest_group_capacity; 2035 unsigned long busiest_group_capacity;
2044 unsigned long busiest_has_capacity; 2036 unsigned long busiest_has_capacity;
2037 unsigned int busiest_group_weight;
2045 2038
2046 int group_imb; /* Is there imbalance in this sd */ 2039 int group_imb; /* Is there imbalance in this sd */
2047#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 2040#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
@@ -2063,6 +2056,8 @@ struct sg_lb_stats {
2063 unsigned long sum_nr_running; /* Nr tasks running in the group */ 2056 unsigned long sum_nr_running; /* Nr tasks running in the group */
2064 unsigned long sum_weighted_load; /* Weighted load of group's tasks */ 2057 unsigned long sum_weighted_load; /* Weighted load of group's tasks */
2065 unsigned long group_capacity; 2058 unsigned long group_capacity;
2059 unsigned long idle_cpus;
2060 unsigned long group_weight;
2066 int group_imb; /* Is there an imbalance in the group ? */ 2061 int group_imb; /* Is there an imbalance in the group ? */
2067 int group_has_capacity; /* Is there extra capacity in the group? */ 2062 int group_has_capacity; /* Is there extra capacity in the group? */
2068}; 2063};
@@ -2431,7 +2426,8 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
2431 sgs->group_load += load; 2426 sgs->group_load += load;
2432 sgs->sum_nr_running += rq->nr_running; 2427 sgs->sum_nr_running += rq->nr_running;
2433 sgs->sum_weighted_load += weighted_cpuload(i); 2428 sgs->sum_weighted_load += weighted_cpuload(i);
2434 2429 if (idle_cpu(i))
2430 sgs->idle_cpus++;
2435 } 2431 }
2436 2432
2437 /* 2433 /*
@@ -2469,6 +2465,7 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
2469 sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power, SCHED_LOAD_SCALE); 2465 sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power, SCHED_LOAD_SCALE);
2470 if (!sgs->group_capacity) 2466 if (!sgs->group_capacity)
2471 sgs->group_capacity = fix_small_capacity(sd, group); 2467 sgs->group_capacity = fix_small_capacity(sd, group);
2468 sgs->group_weight = group->group_weight;
2472 2469
2473 if (sgs->group_capacity > sgs->sum_nr_running) 2470 if (sgs->group_capacity > sgs->sum_nr_running)
2474 sgs->group_has_capacity = 1; 2471 sgs->group_has_capacity = 1;
@@ -2576,13 +2573,16 @@ static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu,
2576 sds->this_nr_running = sgs.sum_nr_running; 2573 sds->this_nr_running = sgs.sum_nr_running;
2577 sds->this_load_per_task = sgs.sum_weighted_load; 2574 sds->this_load_per_task = sgs.sum_weighted_load;
2578 sds->this_has_capacity = sgs.group_has_capacity; 2575 sds->this_has_capacity = sgs.group_has_capacity;
2576 sds->this_idle_cpus = sgs.idle_cpus;
2579 } else if (update_sd_pick_busiest(sd, sds, sg, &sgs, this_cpu)) { 2577 } else if (update_sd_pick_busiest(sd, sds, sg, &sgs, this_cpu)) {
2580 sds->max_load = sgs.avg_load; 2578 sds->max_load = sgs.avg_load;
2581 sds->busiest = sg; 2579 sds->busiest = sg;
2582 sds->busiest_nr_running = sgs.sum_nr_running; 2580 sds->busiest_nr_running = sgs.sum_nr_running;
2581 sds->busiest_idle_cpus = sgs.idle_cpus;
2583 sds->busiest_group_capacity = sgs.group_capacity; 2582 sds->busiest_group_capacity = sgs.group_capacity;
2584 sds->busiest_load_per_task = sgs.sum_weighted_load; 2583 sds->busiest_load_per_task = sgs.sum_weighted_load;
2585 sds->busiest_has_capacity = sgs.group_has_capacity; 2584 sds->busiest_has_capacity = sgs.group_has_capacity;
2585 sds->busiest_group_weight = sgs.group_weight;
2586 sds->group_imb = sgs.group_imb; 2586 sds->group_imb = sgs.group_imb;
2587 } 2587 }
2588 2588
@@ -2860,8 +2860,26 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2860 if (sds.this_load >= sds.avg_load) 2860 if (sds.this_load >= sds.avg_load)
2861 goto out_balanced; 2861 goto out_balanced;
2862 2862
2863 if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load) 2863 /*
2864 goto out_balanced; 2864 * In the CPU_NEWLY_IDLE, use imbalance_pct to be conservative.
2865 * And to check for busy balance use !idle_cpu instead of
2866 * CPU_NOT_IDLE. This is because HT siblings will use CPU_NOT_IDLE
2867 * even when they are idle.
2868 */
2869 if (idle == CPU_NEWLY_IDLE || !idle_cpu(this_cpu)) {
2870 if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load)
2871 goto out_balanced;
2872 } else {
2873 /*
2874 * This cpu is idle. If the busiest group load doesn't
2875 * have more tasks than the number of available cpu's and
2876 * there is no imbalance between this and busiest group
2877 * wrt to idle cpu's, it is balanced.
2878 */
2879 if ((sds.this_idle_cpus <= sds.busiest_idle_cpus + 1) &&
2880 sds.busiest_nr_running <= sds.busiest_group_weight)
2881 goto out_balanced;
2882 }
2865 2883
2866force_balance: 2884force_balance:
2867 /* Looks like there is an imbalance. Compute it */ 2885 /* Looks like there is an imbalance. Compute it */
@@ -3197,8 +3215,10 @@ static void idle_balance(int this_cpu, struct rq *this_rq)
3197 interval = msecs_to_jiffies(sd->balance_interval); 3215 interval = msecs_to_jiffies(sd->balance_interval);
3198 if (time_after(next_balance, sd->last_balance + interval)) 3216 if (time_after(next_balance, sd->last_balance + interval))
3199 next_balance = sd->last_balance + interval; 3217 next_balance = sd->last_balance + interval;
3200 if (pulled_task) 3218 if (pulled_task) {
3219 this_rq->idle_stamp = 0;
3201 break; 3220 break;
3221 }
3202 } 3222 }
3203 3223
3204 raw_spin_lock(&this_rq->lock); 3224 raw_spin_lock(&this_rq->lock);
diff --git a/kernel/sched_stoptask.c b/kernel/sched_stoptask.c
index 45bddc0c1048..2bf6b47058c1 100644
--- a/kernel/sched_stoptask.c
+++ b/kernel/sched_stoptask.c
@@ -19,14 +19,14 @@ select_task_rq_stop(struct rq *rq, struct task_struct *p,
19static void 19static void
20check_preempt_curr_stop(struct rq *rq, struct task_struct *p, int flags) 20check_preempt_curr_stop(struct rq *rq, struct task_struct *p, int flags)
21{ 21{
22 resched_task(rq->curr); /* we preempt everything */ 22 /* we're never preempted */
23} 23}
24 24
25static struct task_struct *pick_next_task_stop(struct rq *rq) 25static struct task_struct *pick_next_task_stop(struct rq *rq)
26{ 26{
27 struct task_struct *stop = rq->stop; 27 struct task_struct *stop = rq->stop;
28 28
29 if (stop && stop->state == TASK_RUNNING) 29 if (stop && stop->se.on_rq)
30 return stop; 30 return stop;
31 31
32 return NULL; 32 return NULL;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index b65bf634035e..5abfa1518554 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -702,7 +702,6 @@ static struct ctl_table kern_table[] = {
702 .extra1 = &zero, 702 .extra1 = &zero,
703 .extra2 = &ten_thousand, 703 .extra2 = &ten_thousand,
704 }, 704 },
705#endif
706 { 705 {
707 .procname = "dmesg_restrict", 706 .procname = "dmesg_restrict",
708 .data = &dmesg_restrict, 707 .data = &dmesg_restrict,
@@ -712,6 +711,7 @@ static struct ctl_table kern_table[] = {
712 .extra1 = &zero, 711 .extra1 = &zero,
713 .extra2 = &one, 712 .extra2 = &one,
714 }, 713 },
714#endif
715 { 715 {
716 .procname = "ngroups_max", 716 .procname = "ngroups_max",
717 .data = &ngroups_max, 717 .data = &ngroups_max,
diff --git a/kernel/timer.c b/kernel/timer.c
index 68a9ae7679b7..353b9227c2ec 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1252,6 +1252,12 @@ unsigned long get_next_timer_interrupt(unsigned long now)
1252 struct tvec_base *base = __get_cpu_var(tvec_bases); 1252 struct tvec_base *base = __get_cpu_var(tvec_bases);
1253 unsigned long expires; 1253 unsigned long expires;
1254 1254
1255 /*
1256 * Pretend that there is no timer pending if the cpu is offline.
1257 * Possible pending timers will be migrated later to an active cpu.
1258 */
1259 if (cpu_is_offline(smp_processor_id()))
1260 return now + NEXT_TIMER_MAX_DELTA;
1255 spin_lock(&base->lock); 1261 spin_lock(&base->lock);
1256 if (time_before_eq(base->next_timer, base->timer_jiffies)) 1262 if (time_before_eq(base->next_timer, base->timer_jiffies))
1257 base->next_timer = __next_timer_interrupt(base); 1263 base->next_timer = __next_timer_interrupt(base);
@@ -1319,7 +1325,7 @@ void do_timer(unsigned long ticks)
1319{ 1325{
1320 jiffies_64 += ticks; 1326 jiffies_64 += ticks;
1321 update_wall_time(); 1327 update_wall_time();
1322 calc_global_load(); 1328 calc_global_load(ticks);
1323} 1329}
1324 1330
1325#ifdef __ARCH_WANT_SYS_ALARM 1331#ifdef __ARCH_WANT_SYS_ALARM
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index e04b8bcdef88..ea37e2ff4164 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -126,7 +126,7 @@ if FTRACE
126config FUNCTION_TRACER 126config FUNCTION_TRACER
127 bool "Kernel Function Tracer" 127 bool "Kernel Function Tracer"
128 depends on HAVE_FUNCTION_TRACER 128 depends on HAVE_FUNCTION_TRACER
129 select FRAME_POINTER if (!ARM_UNWIND) 129 select FRAME_POINTER if !ARM_UNWIND && !S390
130 select KALLSYMS 130 select KALLSYMS
131 select GENERIC_TRACER 131 select GENERIC_TRACER
132 select CONTEXT_SWITCH_TRACER 132 select CONTEXT_SWITCH_TRACER
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 82d9b8106cd0..f8cf959bad45 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -17,7 +17,6 @@
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>
21#include <linux/notifier.h> 20#include <linux/notifier.h>
22#include <linux/irqflags.h> 21#include <linux/irqflags.h>
23#include <linux/debugfs.h> 22#include <linux/debugfs.h>
@@ -1284,6 +1283,8 @@ void trace_dump_stack(void)
1284 __ftrace_trace_stack(global_trace.buffer, flags, 3, preempt_count()); 1283 __ftrace_trace_stack(global_trace.buffer, flags, 3, preempt_count());
1285} 1284}
1286 1285
1286static DEFINE_PER_CPU(int, user_stack_count);
1287
1287void 1288void
1288ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc) 1289ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc)
1289{ 1290{
@@ -1302,6 +1303,18 @@ ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc)
1302 if (unlikely(in_nmi())) 1303 if (unlikely(in_nmi()))
1303 return; 1304 return;
1304 1305
1306 /*
1307 * prevent recursion, since the user stack tracing may
1308 * trigger other kernel events.
1309 */
1310 preempt_disable();
1311 if (__this_cpu_read(user_stack_count))
1312 goto out;
1313
1314 __this_cpu_inc(user_stack_count);
1315
1316
1317
1305 event = trace_buffer_lock_reserve(buffer, TRACE_USER_STACK, 1318 event = trace_buffer_lock_reserve(buffer, TRACE_USER_STACK,
1306 sizeof(*entry), flags, pc); 1319 sizeof(*entry), flags, pc);
1307 if (!event) 1320 if (!event)
@@ -1319,6 +1332,11 @@ ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc)
1319 save_stack_trace_user(&trace); 1332 save_stack_trace_user(&trace);
1320 if (!filter_check_discard(call, entry, buffer, event)) 1333 if (!filter_check_discard(call, entry, buffer, event))
1321 ring_buffer_unlock_commit(buffer, event); 1334 ring_buffer_unlock_commit(buffer, event);
1335
1336 __this_cpu_dec(user_stack_count);
1337
1338 out:
1339 preempt_enable();
1322} 1340}
1323 1341
1324#ifdef UNUSED 1342#ifdef UNUSED
@@ -2320,11 +2338,19 @@ tracing_write_stub(struct file *filp, const char __user *ubuf,
2320 return count; 2338 return count;
2321} 2339}
2322 2340
2341static loff_t tracing_seek(struct file *file, loff_t offset, int origin)
2342{
2343 if (file->f_mode & FMODE_READ)
2344 return seq_lseek(file, offset, origin);
2345 else
2346 return 0;
2347}
2348
2323static const struct file_operations tracing_fops = { 2349static const struct file_operations tracing_fops = {
2324 .open = tracing_open, 2350 .open = tracing_open,
2325 .read = seq_read, 2351 .read = seq_read,
2326 .write = tracing_write_stub, 2352 .write = tracing_write_stub,
2327 .llseek = seq_lseek, 2353 .llseek = tracing_seek,
2328 .release = tracing_release, 2354 .release = tracing_release,
2329}; 2355};
2330 2356
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 90db1bd1a978..e785b0f2aea5 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -661,7 +661,7 @@ void wq_worker_waking_up(struct task_struct *task, unsigned int cpu)
661{ 661{
662 struct worker *worker = kthread_data(task); 662 struct worker *worker = kthread_data(task);
663 663
664 if (likely(!(worker->flags & WORKER_NOT_RUNNING))) 664 if (!(worker->flags & WORKER_NOT_RUNNING))
665 atomic_inc(get_gcwq_nr_running(cpu)); 665 atomic_inc(get_gcwq_nr_running(cpu));
666} 666}
667 667
@@ -687,7 +687,7 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task,
687 struct global_cwq *gcwq = get_gcwq(cpu); 687 struct global_cwq *gcwq = get_gcwq(cpu);
688 atomic_t *nr_running = get_gcwq_nr_running(cpu); 688 atomic_t *nr_running = get_gcwq_nr_running(cpu);
689 689
690 if (unlikely(worker->flags & WORKER_NOT_RUNNING)) 690 if (worker->flags & WORKER_NOT_RUNNING)
691 return NULL; 691 return NULL;
692 692
693 /* this can only happen on the local cpu */ 693 /* this can only happen on the local cpu */
@@ -3692,7 +3692,8 @@ static int __init init_workqueues(void)
3692 system_nrt_wq = alloc_workqueue("events_nrt", WQ_NON_REENTRANT, 0); 3692 system_nrt_wq = alloc_workqueue("events_nrt", WQ_NON_REENTRANT, 0);
3693 system_unbound_wq = alloc_workqueue("events_unbound", WQ_UNBOUND, 3693 system_unbound_wq = alloc_workqueue("events_unbound", WQ_UNBOUND,
3694 WQ_UNBOUND_MAX_ACTIVE); 3694 WQ_UNBOUND_MAX_ACTIVE);
3695 BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq); 3695 BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq ||
3696 !system_unbound_wq);
3696 return 0; 3697 return 0;
3697} 3698}
3698early_initcall(init_workqueues); 3699early_initcall(init_workqueues);
diff --git a/lib/debug_locks.c b/lib/debug_locks.c
index 5bf0020b9248..b1c177307677 100644
--- a/lib/debug_locks.c
+++ b/lib/debug_locks.c
@@ -8,7 +8,6 @@
8 * 8 *
9 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> 9 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
10 */ 10 */
11#include <linux/kernel.h>
12#include <linux/rwsem.h> 11#include <linux/rwsem.h>
13#include <linux/mutex.h> 12#include <linux/mutex.h>
14#include <linux/module.h> 13#include <linux/module.h>
@@ -39,7 +38,6 @@ int debug_locks_off(void)
39{ 38{
40 if (__debug_locks_off()) { 39 if (__debug_locks_off()) {
41 if (!debug_locks_silent) { 40 if (!debug_locks_silent) {
42 oops_in_progress = 1;
43 console_verbose(); 41 console_verbose();
44 return 1; 42 return 1;
45 } 43 }
diff --git a/mm/filemap.c b/mm/filemap.c
index ea89840fc65f..6b9aee20f242 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -143,13 +143,18 @@ void __remove_from_page_cache(struct page *page)
143void remove_from_page_cache(struct page *page) 143void remove_from_page_cache(struct page *page)
144{ 144{
145 struct address_space *mapping = page->mapping; 145 struct address_space *mapping = page->mapping;
146 void (*freepage)(struct page *);
146 147
147 BUG_ON(!PageLocked(page)); 148 BUG_ON(!PageLocked(page));
148 149
150 freepage = mapping->a_ops->freepage;
149 spin_lock_irq(&mapping->tree_lock); 151 spin_lock_irq(&mapping->tree_lock);
150 __remove_from_page_cache(page); 152 __remove_from_page_cache(page);
151 spin_unlock_irq(&mapping->tree_lock); 153 spin_unlock_irq(&mapping->tree_lock);
152 mem_cgroup_uncharge_cache_page(page); 154 mem_cgroup_uncharge_cache_page(page);
155
156 if (freepage)
157 freepage(page);
153} 158}
154EXPORT_SYMBOL(remove_from_page_cache); 159EXPORT_SYMBOL(remove_from_page_cache);
155 160
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index c4a3558589ab..85855240933d 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2738,7 +2738,8 @@ out_page_table_lock:
2738 unlock_page(pagecache_page); 2738 unlock_page(pagecache_page);
2739 put_page(pagecache_page); 2739 put_page(pagecache_page);
2740 } 2740 }
2741 unlock_page(page); 2741 if (page != pagecache_page)
2742 unlock_page(page);
2742 2743
2743out_mutex: 2744out_mutex:
2744 mutex_unlock(&hugetlb_instantiation_mutex); 2745 mutex_unlock(&hugetlb_instantiation_mutex);
diff --git a/mm/ksm.c b/mm/ksm.c
index 65ab5c7067d9..43bc893470b4 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1724,8 +1724,13 @@ static int ksm_memory_callback(struct notifier_block *self,
1724 /* 1724 /*
1725 * Keep it very simple for now: just lock out ksmd and 1725 * Keep it very simple for now: just lock out ksmd and
1726 * MADV_UNMERGEABLE while any memory is going offline. 1726 * MADV_UNMERGEABLE while any memory is going offline.
1727 * mutex_lock_nested() is necessary because lockdep was alarmed
1728 * that here we take ksm_thread_mutex inside notifier chain
1729 * mutex, and later take notifier chain mutex inside
1730 * ksm_thread_mutex to unlock it. But that's safe because both
1731 * are inside mem_hotplug_mutex.
1727 */ 1732 */
1728 mutex_lock(&ksm_thread_mutex); 1733 mutex_lock_nested(&ksm_thread_mutex, SINGLE_DEPTH_NESTING);
1729 break; 1734 break;
1730 1735
1731 case MEM_OFFLINE: 1736 case MEM_OFFLINE:
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2efa8ea07ff7..7a22b4129211 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -61,7 +61,14 @@ struct mem_cgroup *root_mem_cgroup __read_mostly;
61#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP 61#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
62/* Turned on only when memory cgroup is enabled && really_do_swap_account = 1 */ 62/* Turned on only when memory cgroup is enabled && really_do_swap_account = 1 */
63int do_swap_account __read_mostly; 63int do_swap_account __read_mostly;
64static int really_do_swap_account __initdata = 1; /* for remember boot option*/ 64
65/* for remember boot option*/
66#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED
67static int really_do_swap_account __initdata = 1;
68#else
69static int really_do_swap_account __initdata = 0;
70#endif
71
65#else 72#else
66#define do_swap_account (0) 73#define do_swap_account (0)
67#endif 74#endif
@@ -278,13 +285,14 @@ enum move_type {
278 285
279/* "mc" and its members are protected by cgroup_mutex */ 286/* "mc" and its members are protected by cgroup_mutex */
280static struct move_charge_struct { 287static struct move_charge_struct {
281 spinlock_t lock; /* for from, to, moving_task */ 288 spinlock_t lock; /* for from, to */
282 struct mem_cgroup *from; 289 struct mem_cgroup *from;
283 struct mem_cgroup *to; 290 struct mem_cgroup *to;
284 unsigned long precharge; 291 unsigned long precharge;
285 unsigned long moved_charge; 292 unsigned long moved_charge;
286 unsigned long moved_swap; 293 unsigned long moved_swap;
287 struct task_struct *moving_task; /* a task moving charges */ 294 struct task_struct *moving_task; /* a task moving charges */
295 struct mm_struct *mm;
288 wait_queue_head_t waitq; /* a waitq for other context */ 296 wait_queue_head_t waitq; /* a waitq for other context */
289} mc = { 297} mc = {
290 .lock = __SPIN_LOCK_UNLOCKED(mc.lock), 298 .lock = __SPIN_LOCK_UNLOCKED(mc.lock),
@@ -2152,7 +2160,7 @@ static void __mem_cgroup_move_account(struct page_cgroup *pc,
2152{ 2160{
2153 VM_BUG_ON(from == to); 2161 VM_BUG_ON(from == to);
2154 VM_BUG_ON(PageLRU(pc->page)); 2162 VM_BUG_ON(PageLRU(pc->page));
2155 VM_BUG_ON(!PageCgroupLocked(pc)); 2163 VM_BUG_ON(!page_is_cgroup_locked(pc));
2156 VM_BUG_ON(!PageCgroupUsed(pc)); 2164 VM_BUG_ON(!PageCgroupUsed(pc));
2157 VM_BUG_ON(pc->mem_cgroup != from); 2165 VM_BUG_ON(pc->mem_cgroup != from);
2158 2166
@@ -4631,7 +4639,7 @@ static unsigned long mem_cgroup_count_precharge(struct mm_struct *mm)
4631 unsigned long precharge; 4639 unsigned long precharge;
4632 struct vm_area_struct *vma; 4640 struct vm_area_struct *vma;
4633 4641
4634 down_read(&mm->mmap_sem); 4642 /* We've already held the mmap_sem */
4635 for (vma = mm->mmap; vma; vma = vma->vm_next) { 4643 for (vma = mm->mmap; vma; vma = vma->vm_next) {
4636 struct mm_walk mem_cgroup_count_precharge_walk = { 4644 struct mm_walk mem_cgroup_count_precharge_walk = {
4637 .pmd_entry = mem_cgroup_count_precharge_pte_range, 4645 .pmd_entry = mem_cgroup_count_precharge_pte_range,
@@ -4643,7 +4651,6 @@ static unsigned long mem_cgroup_count_precharge(struct mm_struct *mm)
4643 walk_page_range(vma->vm_start, vma->vm_end, 4651 walk_page_range(vma->vm_start, vma->vm_end,
4644 &mem_cgroup_count_precharge_walk); 4652 &mem_cgroup_count_precharge_walk);
4645 } 4653 }
4646 up_read(&mm->mmap_sem);
4647 4654
4648 precharge = mc.precharge; 4655 precharge = mc.precharge;
4649 mc.precharge = 0; 4656 mc.precharge = 0;
@@ -4694,11 +4701,16 @@ static void mem_cgroup_clear_mc(void)
4694 4701
4695 mc.moved_swap = 0; 4702 mc.moved_swap = 0;
4696 } 4703 }
4704 if (mc.mm) {
4705 up_read(&mc.mm->mmap_sem);
4706 mmput(mc.mm);
4707 }
4697 spin_lock(&mc.lock); 4708 spin_lock(&mc.lock);
4698 mc.from = NULL; 4709 mc.from = NULL;
4699 mc.to = NULL; 4710 mc.to = NULL;
4700 mc.moving_task = NULL;
4701 spin_unlock(&mc.lock); 4711 spin_unlock(&mc.lock);
4712 mc.moving_task = NULL;
4713 mc.mm = NULL;
4702 mem_cgroup_end_move(from); 4714 mem_cgroup_end_move(from);
4703 memcg_oom_recover(from); 4715 memcg_oom_recover(from);
4704 memcg_oom_recover(to); 4716 memcg_oom_recover(to);
@@ -4724,12 +4736,21 @@ static int mem_cgroup_can_attach(struct cgroup_subsys *ss,
4724 return 0; 4736 return 0;
4725 /* We move charges only when we move a owner of the mm */ 4737 /* We move charges only when we move a owner of the mm */
4726 if (mm->owner == p) { 4738 if (mm->owner == p) {
4739 /*
4740 * We do all the move charge works under one mmap_sem to
4741 * avoid deadlock with down_write(&mmap_sem)
4742 * -> try_charge() -> if (mc.moving_task) -> sleep.
4743 */
4744 down_read(&mm->mmap_sem);
4745
4727 VM_BUG_ON(mc.from); 4746 VM_BUG_ON(mc.from);
4728 VM_BUG_ON(mc.to); 4747 VM_BUG_ON(mc.to);
4729 VM_BUG_ON(mc.precharge); 4748 VM_BUG_ON(mc.precharge);
4730 VM_BUG_ON(mc.moved_charge); 4749 VM_BUG_ON(mc.moved_charge);
4731 VM_BUG_ON(mc.moved_swap); 4750 VM_BUG_ON(mc.moved_swap);
4732 VM_BUG_ON(mc.moving_task); 4751 VM_BUG_ON(mc.moving_task);
4752 VM_BUG_ON(mc.mm);
4753
4733 mem_cgroup_start_move(from); 4754 mem_cgroup_start_move(from);
4734 spin_lock(&mc.lock); 4755 spin_lock(&mc.lock);
4735 mc.from = from; 4756 mc.from = from;
@@ -4737,14 +4758,16 @@ static int mem_cgroup_can_attach(struct cgroup_subsys *ss,
4737 mc.precharge = 0; 4758 mc.precharge = 0;
4738 mc.moved_charge = 0; 4759 mc.moved_charge = 0;
4739 mc.moved_swap = 0; 4760 mc.moved_swap = 0;
4740 mc.moving_task = current;
4741 spin_unlock(&mc.lock); 4761 spin_unlock(&mc.lock);
4762 mc.moving_task = current;
4763 mc.mm = mm;
4742 4764
4743 ret = mem_cgroup_precharge_mc(mm); 4765 ret = mem_cgroup_precharge_mc(mm);
4744 if (ret) 4766 if (ret)
4745 mem_cgroup_clear_mc(); 4767 mem_cgroup_clear_mc();
4746 } 4768 /* We call up_read() and mmput() in clear_mc(). */
4747 mmput(mm); 4769 } else
4770 mmput(mm);
4748 } 4771 }
4749 return ret; 4772 return ret;
4750} 4773}
@@ -4832,7 +4855,7 @@ static void mem_cgroup_move_charge(struct mm_struct *mm)
4832 struct vm_area_struct *vma; 4855 struct vm_area_struct *vma;
4833 4856
4834 lru_add_drain_all(); 4857 lru_add_drain_all();
4835 down_read(&mm->mmap_sem); 4858 /* We've already held the mmap_sem */
4836 for (vma = mm->mmap; vma; vma = vma->vm_next) { 4859 for (vma = mm->mmap; vma; vma = vma->vm_next) {
4837 int ret; 4860 int ret;
4838 struct mm_walk mem_cgroup_move_charge_walk = { 4861 struct mm_walk mem_cgroup_move_charge_walk = {
@@ -4851,7 +4874,6 @@ static void mem_cgroup_move_charge(struct mm_struct *mm)
4851 */ 4874 */
4852 break; 4875 break;
4853 } 4876 }
4854 up_read(&mm->mmap_sem);
4855} 4877}
4856 4878
4857static void mem_cgroup_move_task(struct cgroup_subsys *ss, 4879static void mem_cgroup_move_task(struct cgroup_subsys *ss,
@@ -4860,17 +4882,11 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss,
4860 struct task_struct *p, 4882 struct task_struct *p,
4861 bool threadgroup) 4883 bool threadgroup)
4862{ 4884{
4863 struct mm_struct *mm; 4885 if (!mc.mm)
4864
4865 if (!mc.to)
4866 /* no need to move charge */ 4886 /* no need to move charge */
4867 return; 4887 return;
4868 4888
4869 mm = get_task_mm(p); 4889 mem_cgroup_move_charge(mc.mm);
4870 if (mm) {
4871 mem_cgroup_move_charge(mm);
4872 mmput(mm);
4873 }
4874 mem_cgroup_clear_mc(); 4890 mem_cgroup_clear_mc();
4875} 4891}
4876#else /* !CONFIG_MMU */ 4892#else /* !CONFIG_MMU */
@@ -4911,10 +4927,20 @@ struct cgroup_subsys mem_cgroup_subsys = {
4911}; 4927};
4912 4928
4913#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP 4929#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
4930static int __init enable_swap_account(char *s)
4931{
4932 /* consider enabled if no parameter or 1 is given */
4933 if (!s || !strcmp(s, "1"))
4934 really_do_swap_account = 1;
4935 else if (!strcmp(s, "0"))
4936 really_do_swap_account = 0;
4937 return 1;
4938}
4939__setup("swapaccount", enable_swap_account);
4914 4940
4915static int __init disable_swap_account(char *s) 4941static int __init disable_swap_account(char *s)
4916{ 4942{
4917 really_do_swap_account = 0; 4943 enable_swap_account("0");
4918 return 1; 4944 return 1;
4919} 4945}
4920__setup("noswapaccount", disable_swap_account); 4946__setup("noswapaccount", disable_swap_account);
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 124324134ff6..46ab2c044b0e 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -51,6 +51,7 @@
51#include <linux/slab.h> 51#include <linux/slab.h>
52#include <linux/swapops.h> 52#include <linux/swapops.h>
53#include <linux/hugetlb.h> 53#include <linux/hugetlb.h>
54#include <linux/memory_hotplug.h>
54#include "internal.h" 55#include "internal.h"
55 56
56int sysctl_memory_failure_early_kill __read_mostly = 0; 57int sysctl_memory_failure_early_kill __read_mostly = 0;
@@ -1230,11 +1231,10 @@ static int get_any_page(struct page *p, unsigned long pfn, int flags)
1230 return 1; 1231 return 1;
1231 1232
1232 /* 1233 /*
1233 * The lock_system_sleep prevents a race with memory hotplug, 1234 * The lock_memory_hotplug prevents a race with memory hotplug.
1234 * because the isolation assumes there's only a single user.
1235 * This is a big hammer, a better would be nicer. 1235 * This is a big hammer, a better would be nicer.
1236 */ 1236 */
1237 lock_system_sleep(); 1237 lock_memory_hotplug();
1238 1238
1239 /* 1239 /*
1240 * Isolate the page, so that it doesn't get reallocated if it 1240 * Isolate the page, so that it doesn't get reallocated if it
@@ -1264,7 +1264,7 @@ static int get_any_page(struct page *p, unsigned long pfn, int flags)
1264 ret = 1; 1264 ret = 1;
1265 } 1265 }
1266 unset_migratetype_isolate(p); 1266 unset_migratetype_isolate(p);
1267 unlock_system_sleep(); 1267 unlock_memory_hotplug();
1268 return ret; 1268 return ret;
1269} 1269}
1270 1270
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 9260314a221e..2c6523af5473 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -34,6 +34,23 @@
34 34
35#include "internal.h" 35#include "internal.h"
36 36
37DEFINE_MUTEX(mem_hotplug_mutex);
38
39void lock_memory_hotplug(void)
40{
41 mutex_lock(&mem_hotplug_mutex);
42
43 /* for exclusive hibernation if CONFIG_HIBERNATION=y */
44 lock_system_sleep();
45}
46
47void unlock_memory_hotplug(void)
48{
49 unlock_system_sleep();
50 mutex_unlock(&mem_hotplug_mutex);
51}
52
53
37/* add this memory to iomem resource */ 54/* add this memory to iomem resource */
38static struct resource *register_memory_resource(u64 start, u64 size) 55static struct resource *register_memory_resource(u64 start, u64 size)
39{ 56{
@@ -493,7 +510,7 @@ int mem_online_node(int nid)
493 pg_data_t *pgdat; 510 pg_data_t *pgdat;
494 int ret; 511 int ret;
495 512
496 lock_system_sleep(); 513 lock_memory_hotplug();
497 pgdat = hotadd_new_pgdat(nid, 0); 514 pgdat = hotadd_new_pgdat(nid, 0);
498 if (pgdat) { 515 if (pgdat) {
499 ret = -ENOMEM; 516 ret = -ENOMEM;
@@ -504,7 +521,7 @@ int mem_online_node(int nid)
504 BUG_ON(ret); 521 BUG_ON(ret);
505 522
506out: 523out:
507 unlock_system_sleep(); 524 unlock_memory_hotplug();
508 return ret; 525 return ret;
509} 526}
510 527
@@ -516,7 +533,7 @@ int __ref add_memory(int nid, u64 start, u64 size)
516 struct resource *res; 533 struct resource *res;
517 int ret; 534 int ret;
518 535
519 lock_system_sleep(); 536 lock_memory_hotplug();
520 537
521 res = register_memory_resource(start, size); 538 res = register_memory_resource(start, size);
522 ret = -EEXIST; 539 ret = -EEXIST;
@@ -563,7 +580,7 @@ error:
563 release_memory_resource(res); 580 release_memory_resource(res);
564 581
565out: 582out:
566 unlock_system_sleep(); 583 unlock_memory_hotplug();
567 return ret; 584 return ret;
568} 585}
569EXPORT_SYMBOL_GPL(add_memory); 586EXPORT_SYMBOL_GPL(add_memory);
@@ -791,7 +808,7 @@ static int offline_pages(unsigned long start_pfn,
791 if (!test_pages_in_a_zone(start_pfn, end_pfn)) 808 if (!test_pages_in_a_zone(start_pfn, end_pfn))
792 return -EINVAL; 809 return -EINVAL;
793 810
794 lock_system_sleep(); 811 lock_memory_hotplug();
795 812
796 zone = page_zone(pfn_to_page(start_pfn)); 813 zone = page_zone(pfn_to_page(start_pfn));
797 node = zone_to_nid(zone); 814 node = zone_to_nid(zone);
@@ -880,7 +897,7 @@ repeat:
880 writeback_set_ratelimit(); 897 writeback_set_ratelimit();
881 898
882 memory_notify(MEM_OFFLINE, &arg); 899 memory_notify(MEM_OFFLINE, &arg);
883 unlock_system_sleep(); 900 unlock_memory_hotplug();
884 return 0; 901 return 0;
885 902
886failed_removal: 903failed_removal:
@@ -891,7 +908,7 @@ failed_removal:
891 undo_isolate_page_range(start_pfn, end_pfn); 908 undo_isolate_page_range(start_pfn, end_pfn);
892 909
893out: 910out:
894 unlock_system_sleep(); 911 unlock_memory_hotplug();
895 return ret; 912 return ret;
896} 913}
897 914
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 4a57f135b76e..11ff260fb282 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1307,15 +1307,18 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
1307 goto out; 1307 goto out;
1308 1308
1309 /* Find the mm_struct */ 1309 /* Find the mm_struct */
1310 rcu_read_lock();
1310 read_lock(&tasklist_lock); 1311 read_lock(&tasklist_lock);
1311 task = pid ? find_task_by_vpid(pid) : current; 1312 task = pid ? find_task_by_vpid(pid) : current;
1312 if (!task) { 1313 if (!task) {
1313 read_unlock(&tasklist_lock); 1314 read_unlock(&tasklist_lock);
1315 rcu_read_unlock();
1314 err = -ESRCH; 1316 err = -ESRCH;
1315 goto out; 1317 goto out;
1316 } 1318 }
1317 mm = get_task_mm(task); 1319 mm = get_task_mm(task);
1318 read_unlock(&tasklist_lock); 1320 read_unlock(&tasklist_lock);
1321 rcu_read_unlock();
1319 1322
1320 err = -EINVAL; 1323 err = -EINVAL;
1321 if (!mm) 1324 if (!mm)
diff --git a/mm/mmap.c b/mm/mmap.c
index b179abb1474a..50a4aa0255a0 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2462,6 +2462,7 @@ int install_special_mapping(struct mm_struct *mm,
2462 unsigned long addr, unsigned long len, 2462 unsigned long addr, unsigned long len,
2463 unsigned long vm_flags, struct page **pages) 2463 unsigned long vm_flags, struct page **pages)
2464{ 2464{
2465 int ret;
2465 struct vm_area_struct *vma; 2466 struct vm_area_struct *vma;
2466 2467
2467 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 2468 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
@@ -2479,16 +2480,23 @@ int install_special_mapping(struct mm_struct *mm,
2479 vma->vm_ops = &special_mapping_vmops; 2480 vma->vm_ops = &special_mapping_vmops;
2480 vma->vm_private_data = pages; 2481 vma->vm_private_data = pages;
2481 2482
2482 if (unlikely(insert_vm_struct(mm, vma))) { 2483 ret = security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1);
2483 kmem_cache_free(vm_area_cachep, vma); 2484 if (ret)
2484 return -ENOMEM; 2485 goto out;
2485 } 2486
2487 ret = insert_vm_struct(mm, vma);
2488 if (ret)
2489 goto out;
2486 2490
2487 mm->total_vm += len >> PAGE_SHIFT; 2491 mm->total_vm += len >> PAGE_SHIFT;
2488 2492
2489 perf_event_mmap(vma); 2493 perf_event_mmap(vma);
2490 2494
2491 return 0; 2495 return 0;
2496
2497out:
2498 kmem_cache_free(vm_area_cachep, vma);
2499 return ret;
2492} 2500}
2493 2501
2494static DEFINE_MUTEX(mm_all_locks_mutex); 2502static DEFINE_MUTEX(mm_all_locks_mutex);
diff --git a/mm/nommu.c b/mm/nommu.c
index 3613517c7592..27a9ac588516 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1717,6 +1717,7 @@ void exit_mmap(struct mm_struct *mm)
1717 mm->mmap = vma->vm_next; 1717 mm->mmap = vma->vm_next;
1718 delete_vma_from_mm(vma); 1718 delete_vma_from_mm(vma);
1719 delete_vma(mm, vma); 1719 delete_vma(mm, vma);
1720 cond_resched();
1720 } 1721 }
1721 1722
1722 kleave(""); 1723 kleave("");
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 07a654486f75..ff7e15872398 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -104,19 +104,24 @@ gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK;
104 * only be modified with pm_mutex held, unless the suspend/hibernate code is 104 * only be modified with pm_mutex held, unless the suspend/hibernate code is
105 * guaranteed not to run in parallel with that modification). 105 * guaranteed not to run in parallel with that modification).
106 */ 106 */
107void set_gfp_allowed_mask(gfp_t mask) 107
108static gfp_t saved_gfp_mask;
109
110void pm_restore_gfp_mask(void)
108{ 111{
109 WARN_ON(!mutex_is_locked(&pm_mutex)); 112 WARN_ON(!mutex_is_locked(&pm_mutex));
110 gfp_allowed_mask = mask; 113 if (saved_gfp_mask) {
114 gfp_allowed_mask = saved_gfp_mask;
115 saved_gfp_mask = 0;
116 }
111} 117}
112 118
113gfp_t clear_gfp_allowed_mask(gfp_t mask) 119void pm_restrict_gfp_mask(void)
114{ 120{
115 gfp_t ret = gfp_allowed_mask;
116
117 WARN_ON(!mutex_is_locked(&pm_mutex)); 121 WARN_ON(!mutex_is_locked(&pm_mutex));
118 gfp_allowed_mask &= ~mask; 122 WARN_ON(saved_gfp_mask);
119 return ret; 123 saved_gfp_mask = gfp_allowed_mask;
124 gfp_allowed_mask &= ~GFP_IOFS;
120} 125}
121#endif /* CONFIG_PM_SLEEP */ 126#endif /* CONFIG_PM_SLEEP */
122 127
@@ -3008,14 +3013,6 @@ static __init_refok int __build_all_zonelists(void *data)
3008 build_zonelist_cache(pgdat); 3013 build_zonelist_cache(pgdat);
3009 } 3014 }
3010 3015
3011#ifdef CONFIG_MEMORY_HOTPLUG
3012 /* Setup real pagesets for the new zone */
3013 if (data) {
3014 struct zone *zone = data;
3015 setup_zone_pageset(zone);
3016 }
3017#endif
3018
3019 /* 3016 /*
3020 * Initialize the boot_pagesets that are going to be used 3017 * Initialize the boot_pagesets that are going to be used
3021 * for bootstrapping processors. The real pagesets for 3018 * for bootstrapping processors. The real pagesets for
@@ -3064,7 +3061,11 @@ void build_all_zonelists(void *data)
3064 } else { 3061 } else {
3065 /* we have to stop all cpus to guarantee there is no user 3062 /* we have to stop all cpus to guarantee there is no user
3066 of zonelist */ 3063 of zonelist */
3067 stop_machine(__build_all_zonelists, data, NULL); 3064#ifdef CONFIG_MEMORY_HOTPLUG
3065 if (data)
3066 setup_zone_pageset((struct zone *)data);
3067#endif
3068 stop_machine(__build_all_zonelists, NULL, NULL);
3068 /* cpuset refresh routine should be here */ 3069 /* cpuset refresh routine should be here */
3069 } 3070 }
3070 vm_total_pages = nr_free_pagecache_pages(); 3071 vm_total_pages = nr_free_pagecache_pages();
diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index 8b1a2ce21ee5..38cc58b8b2b0 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -139,7 +139,6 @@ int walk_page_range(unsigned long addr, unsigned long end,
139 pgd_t *pgd; 139 pgd_t *pgd;
140 unsigned long next; 140 unsigned long next;
141 int err = 0; 141 int err = 0;
142 struct vm_area_struct *vma;
143 142
144 if (addr >= end) 143 if (addr >= end)
145 return err; 144 return err;
@@ -149,15 +148,17 @@ int walk_page_range(unsigned long addr, unsigned long end,
149 148
150 pgd = pgd_offset(walk->mm, addr); 149 pgd = pgd_offset(walk->mm, addr);
151 do { 150 do {
151 struct vm_area_struct *uninitialized_var(vma);
152
152 next = pgd_addr_end(addr, end); 153 next = pgd_addr_end(addr, end);
153 154
155#ifdef CONFIG_HUGETLB_PAGE
154 /* 156 /*
155 * handle hugetlb vma individually because pagetable walk for 157 * handle hugetlb vma individually because pagetable walk for
156 * the hugetlb page is dependent on the architecture and 158 * the hugetlb page is dependent on the architecture and
157 * we can't handled it in the same manner as non-huge pages. 159 * we can't handled it in the same manner as non-huge pages.
158 */ 160 */
159 vma = find_vma(walk->mm, addr); 161 vma = find_vma(walk->mm, addr);
160#ifdef CONFIG_HUGETLB_PAGE
161 if (vma && is_vm_hugetlb_page(vma)) { 162 if (vma && is_vm_hugetlb_page(vma)) {
162 if (vma->vm_end < next) 163 if (vma->vm_end < next)
163 next = vma->vm_end; 164 next = vma->vm_end;
diff --git a/mm/slub.c b/mm/slub.c
index 981fb730aa04..bec0e355fbad 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3401,13 +3401,13 @@ static int validate_slab(struct kmem_cache *s, struct page *page,
3401 3401
3402 for_each_free_object(p, s, page->freelist) { 3402 for_each_free_object(p, s, page->freelist) {
3403 set_bit(slab_index(p, s, addr), map); 3403 set_bit(slab_index(p, s, addr), map);
3404 if (!check_object(s, page, p, 0)) 3404 if (!check_object(s, page, p, SLUB_RED_INACTIVE))
3405 return 0; 3405 return 0;
3406 } 3406 }
3407 3407
3408 for_each_object(p, s, addr, page->objects) 3408 for_each_object(p, s, addr, page->objects)
3409 if (!test_bit(slab_index(p, s, addr), map)) 3409 if (!test_bit(slab_index(p, s, addr), map))
3410 if (!check_object(s, page, p, 1)) 3410 if (!check_object(s, page, p, SLUB_RED_ACTIVE))
3411 return 0; 3411 return 0;
3412 return 1; 3412 return 1;
3413} 3413}
diff --git a/mm/truncate.c b/mm/truncate.c
index ba887bff48c5..3c2d5ddfa0d4 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -390,6 +390,10 @@ invalidate_complete_page2(struct address_space *mapping, struct page *page)
390 __remove_from_page_cache(page); 390 __remove_from_page_cache(page);
391 spin_unlock_irq(&mapping->tree_lock); 391 spin_unlock_irq(&mapping->tree_lock);
392 mem_cgroup_uncharge_cache_page(page); 392 mem_cgroup_uncharge_cache_page(page);
393
394 if (mapping->a_ops->freepage)
395 mapping->a_ops->freepage(page);
396
393 page_cache_release(page); /* pagecache ref */ 397 page_cache_release(page); /* pagecache ref */
394 return 1; 398 return 1;
395failed: 399failed:
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index a3d66b3dc5cb..eb5cc7d00c5a 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -31,8 +31,6 @@
31#include <asm/tlbflush.h> 31#include <asm/tlbflush.h>
32#include <asm/shmparam.h> 32#include <asm/shmparam.h>
33 33
34bool vmap_lazy_unmap __read_mostly = true;
35
36/*** Page table manipulation functions ***/ 34/*** Page table manipulation functions ***/
37 35
38static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end) 36static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
@@ -503,9 +501,6 @@ static unsigned long lazy_max_pages(void)
503{ 501{
504 unsigned int log; 502 unsigned int log;
505 503
506 if (!vmap_lazy_unmap)
507 return 0;
508
509 log = fls(num_online_cpus()); 504 log = fls(num_online_cpus());
510 505
511 return log * (32UL * 1024 * 1024 / PAGE_SIZE); 506 return log * (32UL * 1024 * 1024 / PAGE_SIZE);
@@ -566,7 +561,6 @@ static void __purge_vmap_area_lazy(unsigned long *start, unsigned long *end,
566 if (va->va_end > *end) 561 if (va->va_end > *end)
567 *end = va->va_end; 562 *end = va->va_end;
568 nr += (va->va_end - va->va_start) >> PAGE_SHIFT; 563 nr += (va->va_end - va->va_start) >> PAGE_SHIFT;
569 unmap_vmap_area(va);
570 list_add_tail(&va->purge_list, &valist); 564 list_add_tail(&va->purge_list, &valist);
571 va->flags |= VM_LAZY_FREEING; 565 va->flags |= VM_LAZY_FREEING;
572 va->flags &= ~VM_LAZY_FREE; 566 va->flags &= ~VM_LAZY_FREE;
@@ -611,10 +605,11 @@ static void purge_vmap_area_lazy(void)
611} 605}
612 606
613/* 607/*
614 * Free and unmap a vmap area, caller ensuring flush_cache_vunmap had been 608 * Free a vmap area, caller ensuring that the area has been unmapped
615 * called for the correct range previously. 609 * and flush_cache_vunmap had been called for the correct range
610 * previously.
616 */ 611 */
617static void free_unmap_vmap_area_noflush(struct vmap_area *va) 612static void free_vmap_area_noflush(struct vmap_area *va)
618{ 613{
619 va->flags |= VM_LAZY_FREE; 614 va->flags |= VM_LAZY_FREE;
620 atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr); 615 atomic_add((va->va_end - va->va_start) >> PAGE_SHIFT, &vmap_lazy_nr);
@@ -623,6 +618,16 @@ static void free_unmap_vmap_area_noflush(struct vmap_area *va)
623} 618}
624 619
625/* 620/*
621 * Free and unmap a vmap area, caller ensuring flush_cache_vunmap had been
622 * called for the correct range previously.
623 */
624static void free_unmap_vmap_area_noflush(struct vmap_area *va)
625{
626 unmap_vmap_area(va);
627 free_vmap_area_noflush(va);
628}
629
630/*
626 * Free and unmap a vmap area 631 * Free and unmap a vmap area
627 */ 632 */
628static void free_unmap_vmap_area(struct vmap_area *va) 633static void free_unmap_vmap_area(struct vmap_area *va)
@@ -798,7 +803,7 @@ static void free_vmap_block(struct vmap_block *vb)
798 spin_unlock(&vmap_block_tree_lock); 803 spin_unlock(&vmap_block_tree_lock);
799 BUG_ON(tmp != vb); 804 BUG_ON(tmp != vb);
800 805
801 free_unmap_vmap_area_noflush(vb->va); 806 free_vmap_area_noflush(vb->va);
802 call_rcu(&vb->rcu_head, rcu_free_vb); 807 call_rcu(&vb->rcu_head, rcu_free_vb);
803} 808}
804 809
@@ -936,6 +941,8 @@ static void vb_free(const void *addr, unsigned long size)
936 rcu_read_unlock(); 941 rcu_read_unlock();
937 BUG_ON(!vb); 942 BUG_ON(!vb);
938 943
944 vunmap_page_range((unsigned long)addr, (unsigned long)addr + size);
945
939 spin_lock(&vb->lock); 946 spin_lock(&vb->lock);
940 BUG_ON(bitmap_allocate_region(vb->dirty_map, offset >> PAGE_SHIFT, order)); 947 BUG_ON(bitmap_allocate_region(vb->dirty_map, offset >> PAGE_SHIFT, order));
941 948
@@ -988,7 +995,6 @@ void vm_unmap_aliases(void)
988 995
989 s = vb->va->va_start + (i << PAGE_SHIFT); 996 s = vb->va->va_start + (i << PAGE_SHIFT);
990 e = vb->va->va_start + (j << PAGE_SHIFT); 997 e = vb->va->va_start + (j << PAGE_SHIFT);
991 vunmap_page_range(s, e);
992 flush = 1; 998 flush = 1;
993 999
994 if (s < start) 1000 if (s < start)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index d31d7ce52c0e..9ca587c69274 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -494,9 +494,16 @@ static int __remove_mapping(struct address_space *mapping, struct page *page)
494 spin_unlock_irq(&mapping->tree_lock); 494 spin_unlock_irq(&mapping->tree_lock);
495 swapcache_free(swap, page); 495 swapcache_free(swap, page);
496 } else { 496 } else {
497 void (*freepage)(struct page *);
498
499 freepage = mapping->a_ops->freepage;
500
497 __remove_from_page_cache(page); 501 __remove_from_page_cache(page);
498 spin_unlock_irq(&mapping->tree_lock); 502 spin_unlock_irq(&mapping->tree_lock);
499 mem_cgroup_uncharge_cache_page(page); 503 mem_cgroup_uncharge_cache_page(page);
504
505 if (freepage != NULL)
506 freepage(page);
500 } 507 }
501 508
502 return 1; 509 return 1;
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 42eac4d33216..8f62f17ee1c7 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -750,8 +750,6 @@ static const char * const vmstat_text[] = {
750 "nr_shmem", 750 "nr_shmem",
751 "nr_dirtied", 751 "nr_dirtied",
752 "nr_written", 752 "nr_written",
753 "nr_dirty_threshold",
754 "nr_dirty_background_threshold",
755 753
756#ifdef CONFIG_NUMA 754#ifdef CONFIG_NUMA
757 "numa_hit", 755 "numa_hit",
@@ -761,6 +759,8 @@ static const char * const vmstat_text[] = {
761 "numa_local", 759 "numa_local",
762 "numa_other", 760 "numa_other",
763#endif 761#endif
762 "nr_dirty_threshold",
763 "nr_dirty_background_threshold",
764 764
765#ifdef CONFIG_VM_EVENT_COUNTERS 765#ifdef CONFIG_VM_EVENT_COUNTERS
766 "pgpgin", 766 "pgpgin",
diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
index 799c631f0fed..f7fa67c78766 100644
--- a/net/atm/atm_sysfs.c
+++ b/net/atm/atm_sysfs.c
@@ -143,12 +143,13 @@ static struct class atm_class = {
143 .dev_uevent = atm_uevent, 143 .dev_uevent = atm_uevent,
144}; 144};
145 145
146int atm_register_sysfs(struct atm_dev *adev) 146int atm_register_sysfs(struct atm_dev *adev, struct device *parent)
147{ 147{
148 struct device *cdev = &adev->class_dev; 148 struct device *cdev = &adev->class_dev;
149 int i, j, err; 149 int i, j, err;
150 150
151 cdev->class = &atm_class; 151 cdev->class = &atm_class;
152 cdev->parent = parent;
152 dev_set_drvdata(cdev, adev); 153 dev_set_drvdata(cdev, adev);
153 154
154 dev_set_name(cdev, "%s%d", adev->type, adev->number); 155 dev_set_name(cdev, "%s%d", adev->type, adev->number);
diff --git a/net/atm/resources.c b/net/atm/resources.c
index d29e58261511..23f45ce6f351 100644
--- a/net/atm/resources.c
+++ b/net/atm/resources.c
@@ -74,8 +74,9 @@ struct atm_dev *atm_dev_lookup(int number)
74} 74}
75EXPORT_SYMBOL(atm_dev_lookup); 75EXPORT_SYMBOL(atm_dev_lookup);
76 76
77struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops, 77struct atm_dev *atm_dev_register(const char *type, struct device *parent,
78 int number, unsigned long *flags) 78 const struct atmdev_ops *ops, int number,
79 unsigned long *flags)
79{ 80{
80 struct atm_dev *dev, *inuse; 81 struct atm_dev *dev, *inuse;
81 82
@@ -115,7 +116,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
115 goto out_fail; 116 goto out_fail;
116 } 117 }
117 118
118 if (atm_register_sysfs(dev) < 0) { 119 if (atm_register_sysfs(dev, parent) < 0) {
119 pr_err("atm_register_sysfs failed for dev %s\n", type); 120 pr_err("atm_register_sysfs failed for dev %s\n", type);
120 atm_proc_dev_deregister(dev); 121 atm_proc_dev_deregister(dev);
121 goto out_fail; 122 goto out_fail;
diff --git a/net/atm/resources.h b/net/atm/resources.h
index 126fb1840dfb..521431e30507 100644
--- a/net/atm/resources.h
+++ b/net/atm/resources.h
@@ -42,6 +42,6 @@ static inline void atm_proc_dev_deregister(struct atm_dev *dev)
42 42
43#endif /* CONFIG_PROC_FS */ 43#endif /* CONFIG_PROC_FS */
44 44
45int atm_register_sysfs(struct atm_dev *adev); 45int atm_register_sysfs(struct atm_dev *adev, struct device *parent);
46void atm_unregister_sysfs(struct atm_dev *adev); 46void atm_unregister_sysfs(struct atm_dev *adev);
47#endif 47#endif
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index d0927d1fdada..66b9e5c0523a 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -882,7 +882,7 @@ static int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type)
882 int lm = 0; 882 int lm = 0;
883 883
884 if (type != SCO_LINK && type != ESCO_LINK) 884 if (type != SCO_LINK && type != ESCO_LINK)
885 return 0; 885 return -EINVAL;
886 886
887 BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr)); 887 BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
888 888
@@ -908,7 +908,7 @@ static int sco_connect_cfm(struct hci_conn *hcon, __u8 status)
908 BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status); 908 BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
909 909
910 if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) 910 if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)
911 return 0; 911 return -EINVAL;
912 912
913 if (!status) { 913 if (!status) {
914 struct sco_conn *conn; 914 struct sco_conn *conn;
@@ -927,7 +927,7 @@ static int sco_disconn_cfm(struct hci_conn *hcon, __u8 reason)
927 BT_DBG("hcon %p reason %d", hcon, reason); 927 BT_DBG("hcon %p reason %d", hcon, reason);
928 928
929 if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) 929 if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)
930 return 0; 930 return -EINVAL;
931 931
932 sco_conn_del(hcon, bt_err(reason)); 932 sco_conn_del(hcon, bt_err(reason));
933 933
diff --git a/net/ceph/Makefile b/net/ceph/Makefile
index aab1cabb8035..5f19415ec9c0 100644
--- a/net/ceph/Makefile
+++ b/net/ceph/Makefile
@@ -1,9 +1,6 @@
1# 1#
2# Makefile for CEPH filesystem. 2# Makefile for CEPH filesystem.
3# 3#
4
5ifneq ($(KERNELRELEASE),)
6
7obj-$(CONFIG_CEPH_LIB) += libceph.o 4obj-$(CONFIG_CEPH_LIB) += libceph.o
8 5
9libceph-objs := ceph_common.o messenger.o msgpool.o buffer.o pagelist.o \ 6libceph-objs := ceph_common.o messenger.o msgpool.o buffer.o pagelist.o \
@@ -16,22 +13,3 @@ libceph-objs := ceph_common.o messenger.o msgpool.o buffer.o pagelist.o \
16 ceph_fs.o ceph_strings.o ceph_hash.o \ 13 ceph_fs.o ceph_strings.o ceph_hash.o \
17 pagevec.o 14 pagevec.o
18 15
19else
20#Otherwise we were called directly from the command
21# line; invoke the kernel build system.
22
23KERNELDIR ?= /lib/modules/$(shell uname -r)/build
24PWD := $(shell pwd)
25
26default: all
27
28all:
29 $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_CEPH_LIB=m modules
30
31modules_install:
32 $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_CEPH_LIB=m modules_install
33
34clean:
35 $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
36
37endif
diff --git a/net/ceph/buffer.c b/net/ceph/buffer.c
index 53d8abfa25d5..bf3e6a13c215 100644
--- a/net/ceph/buffer.c
+++ b/net/ceph/buffer.c
@@ -19,7 +19,7 @@ struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp)
19 if (b->vec.iov_base) { 19 if (b->vec.iov_base) {
20 b->is_vmalloc = false; 20 b->is_vmalloc = false;
21 } else { 21 } else {
22 b->vec.iov_base = __vmalloc(len, gfp, PAGE_KERNEL); 22 b->vec.iov_base = __vmalloc(len, gfp | __GFP_HIGHMEM, PAGE_KERNEL);
23 if (!b->vec.iov_base) { 23 if (!b->vec.iov_base) {
24 kfree(b); 24 kfree(b);
25 return NULL; 25 return NULL;
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 0e8157ee5d43..b6ff4a1519ab 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -97,11 +97,9 @@ struct workqueue_struct *ceph_msgr_wq;
97int ceph_msgr_init(void) 97int ceph_msgr_init(void)
98{ 98{
99 ceph_msgr_wq = create_workqueue("ceph-msgr"); 99 ceph_msgr_wq = create_workqueue("ceph-msgr");
100 if (IS_ERR(ceph_msgr_wq)) { 100 if (!ceph_msgr_wq) {
101 int ret = PTR_ERR(ceph_msgr_wq); 101 pr_err("msgr_init failed to create workqueue\n");
102 pr_err("msgr_init failed to create workqueue: %d\n", ret); 102 return -ENOMEM;
103 ceph_msgr_wq = NULL;
104 return ret;
105 } 103 }
106 return 0; 104 return 0;
107} 105}
@@ -540,8 +538,7 @@ static void prepare_write_message(struct ceph_connection *con)
540 /* initialize page iterator */ 538 /* initialize page iterator */
541 con->out_msg_pos.page = 0; 539 con->out_msg_pos.page = 0;
542 if (m->pages) 540 if (m->pages)
543 con->out_msg_pos.page_pos = 541 con->out_msg_pos.page_pos = m->page_alignment;
544 le16_to_cpu(m->hdr.data_off) & ~PAGE_MASK;
545 else 542 else
546 con->out_msg_pos.page_pos = 0; 543 con->out_msg_pos.page_pos = 0;
547 con->out_msg_pos.data_pos = 0; 544 con->out_msg_pos.data_pos = 0;
@@ -1491,7 +1488,7 @@ static int read_partial_message(struct ceph_connection *con)
1491 struct ceph_msg *m = con->in_msg; 1488 struct ceph_msg *m = con->in_msg;
1492 int ret; 1489 int ret;
1493 int to, left; 1490 int to, left;
1494 unsigned front_len, middle_len, data_len, data_off; 1491 unsigned front_len, middle_len, data_len;
1495 int datacrc = con->msgr->nocrc; 1492 int datacrc = con->msgr->nocrc;
1496 int skip; 1493 int skip;
1497 u64 seq; 1494 u64 seq;
@@ -1527,19 +1524,17 @@ static int read_partial_message(struct ceph_connection *con)
1527 data_len = le32_to_cpu(con->in_hdr.data_len); 1524 data_len = le32_to_cpu(con->in_hdr.data_len);
1528 if (data_len > CEPH_MSG_MAX_DATA_LEN) 1525 if (data_len > CEPH_MSG_MAX_DATA_LEN)
1529 return -EIO; 1526 return -EIO;
1530 data_off = le16_to_cpu(con->in_hdr.data_off);
1531 1527
1532 /* verify seq# */ 1528 /* verify seq# */
1533 seq = le64_to_cpu(con->in_hdr.seq); 1529 seq = le64_to_cpu(con->in_hdr.seq);
1534 if ((s64)seq - (s64)con->in_seq < 1) { 1530 if ((s64)seq - (s64)con->in_seq < 1) {
1535 pr_info("skipping %s%lld %s seq %lld, expected %lld\n", 1531 pr_info("skipping %s%lld %s seq %lld expected %lld\n",
1536 ENTITY_NAME(con->peer_name), 1532 ENTITY_NAME(con->peer_name),
1537 ceph_pr_addr(&con->peer_addr.in_addr), 1533 ceph_pr_addr(&con->peer_addr.in_addr),
1538 seq, con->in_seq + 1); 1534 seq, con->in_seq + 1);
1539 con->in_base_pos = -front_len - middle_len - data_len - 1535 con->in_base_pos = -front_len - middle_len - data_len -
1540 sizeof(m->footer); 1536 sizeof(m->footer);
1541 con->in_tag = CEPH_MSGR_TAG_READY; 1537 con->in_tag = CEPH_MSGR_TAG_READY;
1542 con->in_seq++;
1543 return 0; 1538 return 0;
1544 } else if ((s64)seq - (s64)con->in_seq > 1) { 1539 } else if ((s64)seq - (s64)con->in_seq > 1) {
1545 pr_err("read_partial_message bad seq %lld expected %lld\n", 1540 pr_err("read_partial_message bad seq %lld expected %lld\n",
@@ -1576,7 +1571,7 @@ static int read_partial_message(struct ceph_connection *con)
1576 1571
1577 con->in_msg_pos.page = 0; 1572 con->in_msg_pos.page = 0;
1578 if (m->pages) 1573 if (m->pages)
1579 con->in_msg_pos.page_pos = data_off & ~PAGE_MASK; 1574 con->in_msg_pos.page_pos = m->page_alignment;
1580 else 1575 else
1581 con->in_msg_pos.page_pos = 0; 1576 con->in_msg_pos.page_pos = 0;
1582 con->in_msg_pos.data_pos = 0; 1577 con->in_msg_pos.data_pos = 0;
@@ -2301,6 +2296,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
2301 2296
2302 /* data */ 2297 /* data */
2303 m->nr_pages = 0; 2298 m->nr_pages = 0;
2299 m->page_alignment = 0;
2304 m->pages = NULL; 2300 m->pages = NULL;
2305 m->pagelist = NULL; 2301 m->pagelist = NULL;
2306 m->bio = NULL; 2302 m->bio = NULL;
@@ -2370,6 +2366,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con,
2370 type, front_len); 2366 type, front_len);
2371 return NULL; 2367 return NULL;
2372 } 2368 }
2369 msg->page_alignment = le16_to_cpu(hdr->data_off);
2373 } 2370 }
2374 memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr)); 2371 memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr));
2375 2372
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 79391994b3ed..3e20a122ffa2 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -71,6 +71,7 @@ void ceph_calc_raw_layout(struct ceph_osd_client *osdc,
71 op->extent.length = objlen; 71 op->extent.length = objlen;
72 } 72 }
73 req->r_num_pages = calc_pages_for(off, *plen); 73 req->r_num_pages = calc_pages_for(off, *plen);
74 req->r_page_alignment = off & ~PAGE_MASK;
74 if (op->op == CEPH_OSD_OP_WRITE) 75 if (op->op == CEPH_OSD_OP_WRITE)
75 op->payload_len = *plen; 76 op->payload_len = *plen;
76 77
@@ -390,6 +391,8 @@ void ceph_osdc_build_request(struct ceph_osd_request *req,
390 req->r_request->hdr.data_len = cpu_to_le32(data_len); 391 req->r_request->hdr.data_len = cpu_to_le32(data_len);
391 } 392 }
392 393
394 req->r_request->page_alignment = req->r_page_alignment;
395
393 BUG_ON(p > msg->front.iov_base + msg->front.iov_len); 396 BUG_ON(p > msg->front.iov_base + msg->front.iov_len);
394 msg_size = p - msg->front.iov_base; 397 msg_size = p - msg->front.iov_base;
395 msg->front.iov_len = msg_size; 398 msg->front.iov_len = msg_size;
@@ -419,7 +422,8 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
419 u32 truncate_seq, 422 u32 truncate_seq,
420 u64 truncate_size, 423 u64 truncate_size,
421 struct timespec *mtime, 424 struct timespec *mtime,
422 bool use_mempool, int num_reply) 425 bool use_mempool, int num_reply,
426 int page_align)
423{ 427{
424 struct ceph_osd_req_op ops[3]; 428 struct ceph_osd_req_op ops[3];
425 struct ceph_osd_request *req; 429 struct ceph_osd_request *req;
@@ -447,6 +451,10 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
447 calc_layout(osdc, vino, layout, off, plen, req, ops); 451 calc_layout(osdc, vino, layout, off, plen, req, ops);
448 req->r_file_layout = *layout; /* keep a copy */ 452 req->r_file_layout = *layout; /* keep a copy */
449 453
454 /* in case it differs from natural alignment that calc_layout
455 filled in for us */
456 req->r_page_alignment = page_align;
457
450 ceph_osdc_build_request(req, off, plen, ops, 458 ceph_osdc_build_request(req, off, plen, ops,
451 snapc, 459 snapc,
452 mtime, 460 mtime,
@@ -1489,7 +1497,7 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
1489 struct ceph_vino vino, struct ceph_file_layout *layout, 1497 struct ceph_vino vino, struct ceph_file_layout *layout,
1490 u64 off, u64 *plen, 1498 u64 off, u64 *plen,
1491 u32 truncate_seq, u64 truncate_size, 1499 u32 truncate_seq, u64 truncate_size,
1492 struct page **pages, int num_pages) 1500 struct page **pages, int num_pages, int page_align)
1493{ 1501{
1494 struct ceph_osd_request *req; 1502 struct ceph_osd_request *req;
1495 int rc = 0; 1503 int rc = 0;
@@ -1499,15 +1507,15 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
1499 req = ceph_osdc_new_request(osdc, layout, vino, off, plen, 1507 req = ceph_osdc_new_request(osdc, layout, vino, off, plen,
1500 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, 1508 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
1501 NULL, 0, truncate_seq, truncate_size, NULL, 1509 NULL, 0, truncate_seq, truncate_size, NULL,
1502 false, 1); 1510 false, 1, page_align);
1503 if (!req) 1511 if (!req)
1504 return -ENOMEM; 1512 return -ENOMEM;
1505 1513
1506 /* it may be a short read due to an object boundary */ 1514 /* it may be a short read due to an object boundary */
1507 req->r_pages = pages; 1515 req->r_pages = pages;
1508 1516
1509 dout("readpages final extent is %llu~%llu (%d pages)\n", 1517 dout("readpages final extent is %llu~%llu (%d pages align %d)\n",
1510 off, *plen, req->r_num_pages); 1518 off, *plen, req->r_num_pages, page_align);
1511 1519
1512 rc = ceph_osdc_start_request(osdc, req, false); 1520 rc = ceph_osdc_start_request(osdc, req, false);
1513 if (!rc) 1521 if (!rc)
@@ -1533,6 +1541,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
1533{ 1541{
1534 struct ceph_osd_request *req; 1542 struct ceph_osd_request *req;
1535 int rc = 0; 1543 int rc = 0;
1544 int page_align = off & ~PAGE_MASK;
1536 1545
1537 BUG_ON(vino.snap != CEPH_NOSNAP); 1546 BUG_ON(vino.snap != CEPH_NOSNAP);
1538 req = ceph_osdc_new_request(osdc, layout, vino, off, &len, 1547 req = ceph_osdc_new_request(osdc, layout, vino, off, &len,
@@ -1541,7 +1550,7 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
1541 CEPH_OSD_FLAG_WRITE, 1550 CEPH_OSD_FLAG_WRITE,
1542 snapc, do_sync, 1551 snapc, do_sync,
1543 truncate_seq, truncate_size, mtime, 1552 truncate_seq, truncate_size, mtime,
1544 nofail, 1); 1553 nofail, 1, page_align);
1545 if (!req) 1554 if (!req)
1546 return -ENOMEM; 1555 return -ENOMEM;
1547 1556
@@ -1638,8 +1647,7 @@ static struct ceph_msg *get_reply(struct ceph_connection *con,
1638 m = ceph_msg_get(req->r_reply); 1647 m = ceph_msg_get(req->r_reply);
1639 1648
1640 if (data_len > 0) { 1649 if (data_len > 0) {
1641 unsigned data_off = le16_to_cpu(hdr->data_off); 1650 int want = calc_pages_for(req->r_page_alignment, data_len);
1642 int want = calc_pages_for(data_off & ~PAGE_MASK, data_len);
1643 1651
1644 if (unlikely(req->r_num_pages < want)) { 1652 if (unlikely(req->r_num_pages < want)) {
1645 pr_warning("tid %lld reply %d > expected %d pages\n", 1653 pr_warning("tid %lld reply %d > expected %d pages\n",
@@ -1651,6 +1659,7 @@ static struct ceph_msg *get_reply(struct ceph_connection *con,
1651 } 1659 }
1652 m->pages = req->r_pages; 1660 m->pages = req->r_pages;
1653 m->nr_pages = req->r_num_pages; 1661 m->nr_pages = req->r_num_pages;
1662 m->page_alignment = req->r_page_alignment;
1654#ifdef CONFIG_BLOCK 1663#ifdef CONFIG_BLOCK
1655 m->bio = req->r_bio; 1664 m->bio = req->r_bio;
1656#endif 1665#endif
diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c
index 54caf0687155..1a040e64c69f 100644
--- a/net/ceph/pagevec.c
+++ b/net/ceph/pagevec.c
@@ -13,8 +13,7 @@
13 * build a vector of user pages 13 * build a vector of user pages
14 */ 14 */
15struct page **ceph_get_direct_page_vector(const char __user *data, 15struct page **ceph_get_direct_page_vector(const char __user *data,
16 int num_pages, 16 int num_pages, bool write_page)
17 loff_t off, size_t len)
18{ 17{
19 struct page **pages; 18 struct page **pages;
20 int rc; 19 int rc;
@@ -25,24 +24,27 @@ struct page **ceph_get_direct_page_vector(const char __user *data,
25 24
26 down_read(&current->mm->mmap_sem); 25 down_read(&current->mm->mmap_sem);
27 rc = get_user_pages(current, current->mm, (unsigned long)data, 26 rc = get_user_pages(current, current->mm, (unsigned long)data,
28 num_pages, 0, 0, pages, NULL); 27 num_pages, write_page, 0, pages, NULL);
29 up_read(&current->mm->mmap_sem); 28 up_read(&current->mm->mmap_sem);
30 if (rc < 0) 29 if (rc < num_pages)
31 goto fail; 30 goto fail;
32 return pages; 31 return pages;
33 32
34fail: 33fail:
35 kfree(pages); 34 ceph_put_page_vector(pages, rc > 0 ? rc : 0, false);
36 return ERR_PTR(rc); 35 return ERR_PTR(rc);
37} 36}
38EXPORT_SYMBOL(ceph_get_direct_page_vector); 37EXPORT_SYMBOL(ceph_get_direct_page_vector);
39 38
40void ceph_put_page_vector(struct page **pages, int num_pages) 39void ceph_put_page_vector(struct page **pages, int num_pages, bool dirty)
41{ 40{
42 int i; 41 int i;
43 42
44 for (i = 0; i < num_pages; i++) 43 for (i = 0; i < num_pages; i++) {
44 if (dirty)
45 set_page_dirty_lock(pages[i]);
45 put_page(pages[i]); 46 put_page(pages[i]);
47 }
46 kfree(pages); 48 kfree(pages);
47} 49}
48EXPORT_SYMBOL(ceph_put_page_vector); 50EXPORT_SYMBOL(ceph_put_page_vector);
diff --git a/net/core/filter.c b/net/core/filter.c
index 23e9b2a6b4c8..ae21a0d3c4a2 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -589,23 +589,16 @@ int sk_chk_filter(struct sock_filter *filter, int flen)
589EXPORT_SYMBOL(sk_chk_filter); 589EXPORT_SYMBOL(sk_chk_filter);
590 590
591/** 591/**
592 * sk_filter_rcu_release: Release a socket filter by rcu_head 592 * sk_filter_release_rcu - Release a socket filter by rcu_head
593 * @rcu: rcu_head that contains the sk_filter to free 593 * @rcu: rcu_head that contains the sk_filter to free
594 */ 594 */
595static void sk_filter_rcu_release(struct rcu_head *rcu) 595void sk_filter_release_rcu(struct rcu_head *rcu)
596{ 596{
597 struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu); 597 struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu);
598 598
599 sk_filter_release(fp); 599 kfree(fp);
600}
601
602static void sk_filter_delayed_uncharge(struct sock *sk, struct sk_filter *fp)
603{
604 unsigned int size = sk_filter_len(fp);
605
606 atomic_sub(size, &sk->sk_omem_alloc);
607 call_rcu_bh(&fp->rcu, sk_filter_rcu_release);
608} 600}
601EXPORT_SYMBOL(sk_filter_release_rcu);
609 602
610/** 603/**
611 * sk_attach_filter - attach a socket filter 604 * sk_attach_filter - attach a socket filter
@@ -649,7 +642,7 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
649 rcu_assign_pointer(sk->sk_filter, fp); 642 rcu_assign_pointer(sk->sk_filter, fp);
650 643
651 if (old_fp) 644 if (old_fp)
652 sk_filter_delayed_uncharge(sk, old_fp); 645 sk_filter_uncharge(sk, old_fp);
653 return 0; 646 return 0;
654} 647}
655EXPORT_SYMBOL_GPL(sk_attach_filter); 648EXPORT_SYMBOL_GPL(sk_attach_filter);
@@ -663,7 +656,7 @@ int sk_detach_filter(struct sock *sk)
663 sock_owned_by_user(sk)); 656 sock_owned_by_user(sk));
664 if (filter) { 657 if (filter) {
665 rcu_assign_pointer(sk->sk_filter, NULL); 658 rcu_assign_pointer(sk->sk_filter, NULL);
666 sk_filter_delayed_uncharge(sk, filter); 659 sk_filter_uncharge(sk, filter);
667 ret = 0; 660 ret = 0;
668 } 661 }
669 return ret; 662 return ret;
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index a5ff5a89f376..7f902cad10f8 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -712,15 +712,21 @@ static void rx_queue_release(struct kobject *kobj)
712 712
713 713
714 map = rcu_dereference_raw(queue->rps_map); 714 map = rcu_dereference_raw(queue->rps_map);
715 if (map) 715 if (map) {
716 RCU_INIT_POINTER(queue->rps_map, NULL);
716 call_rcu(&map->rcu, rps_map_release); 717 call_rcu(&map->rcu, rps_map_release);
718 }
717 719
718 flow_table = rcu_dereference_raw(queue->rps_flow_table); 720 flow_table = rcu_dereference_raw(queue->rps_flow_table);
719 if (flow_table) 721 if (flow_table) {
722 RCU_INIT_POINTER(queue->rps_flow_table, NULL);
720 call_rcu(&flow_table->rcu, rps_dev_flow_table_release); 723 call_rcu(&flow_table->rcu, rps_dev_flow_table_release);
724 }
721 725
722 if (atomic_dec_and_test(&first->count)) 726 if (atomic_dec_and_test(&first->count))
723 kfree(first); 727 kfree(first);
728 else
729 memset(kobj, 0, sizeof(*kobj));
724} 730}
725 731
726static struct kobj_type rx_queue_ktype = { 732static struct kobj_type rx_queue_ktype = {
diff --git a/net/core/request_sock.c b/net/core/request_sock.c
index 7552495aff7a..fceeb37d7161 100644
--- a/net/core/request_sock.c
+++ b/net/core/request_sock.c
@@ -45,9 +45,7 @@ int reqsk_queue_alloc(struct request_sock_queue *queue,
45 nr_table_entries = roundup_pow_of_two(nr_table_entries + 1); 45 nr_table_entries = roundup_pow_of_two(nr_table_entries + 1);
46 lopt_size += nr_table_entries * sizeof(struct request_sock *); 46 lopt_size += nr_table_entries * sizeof(struct request_sock *);
47 if (lopt_size > PAGE_SIZE) 47 if (lopt_size > PAGE_SIZE)
48 lopt = __vmalloc(lopt_size, 48 lopt = vzalloc(lopt_size);
49 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
50 PAGE_KERNEL);
51 else 49 else
52 lopt = kzalloc(lopt_size, GFP_KERNEL); 50 lopt = kzalloc(lopt_size, GFP_KERNEL);
53 if (lopt == NULL) 51 if (lopt == NULL)
diff --git a/net/core/timestamping.c b/net/core/timestamping.c
index 0ae6c22da85b..c19bb4ee405e 100644
--- a/net/core/timestamping.c
+++ b/net/core/timestamping.c
@@ -96,11 +96,13 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb)
96 struct phy_device *phydev; 96 struct phy_device *phydev;
97 unsigned int type; 97 unsigned int type;
98 98
99 skb_push(skb, ETH_HLEN); 99 if (skb_headroom(skb) < ETH_HLEN)
100 return false;
101 __skb_push(skb, ETH_HLEN);
100 102
101 type = classify(skb); 103 type = classify(skb);
102 104
103 skb_pull(skb, ETH_HLEN); 105 __skb_pull(skb, ETH_HLEN);
104 106
105 switch (type) { 107 switch (type) {
106 case PTP_CLASS_V1_IPV4: 108 case PTP_CLASS_V1_IPV4:
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 265985370fa1..e424a09e83f6 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -239,7 +239,8 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
239 dccp_update_gsr(sk, seqno); 239 dccp_update_gsr(sk, seqno);
240 240
241 if (dh->dccph_type != DCCP_PKT_SYNC && 241 if (dh->dccph_type != DCCP_PKT_SYNC &&
242 (ackno != DCCP_PKT_WITHOUT_ACK_SEQ)) 242 ackno != DCCP_PKT_WITHOUT_ACK_SEQ &&
243 after48(ackno, dp->dccps_gar))
243 dp->dccps_gar = ackno; 244 dp->dccps_gar = ackno;
244 } else { 245 } else {
245 unsigned long now = jiffies; 246 unsigned long now = jiffies;
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index a76b78de679f..6f97268ed85f 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -1556,6 +1556,8 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
1556 if (r_len > sizeof(struct linkinfo_dn)) 1556 if (r_len > sizeof(struct linkinfo_dn))
1557 r_len = sizeof(struct linkinfo_dn); 1557 r_len = sizeof(struct linkinfo_dn);
1558 1558
1559 memset(&link, 0, sizeof(link));
1560
1559 switch(sock->state) { 1561 switch(sock->state) {
1560 case SS_CONNECTING: 1562 case SS_CONNECTING:
1561 link.idn_linkstate = LL_CONNECTING; 1563 link.idn_linkstate = LL_CONNECTING;
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c
index f8c1ae4b41f0..15dcc1a586b4 100644
--- a/net/econet/af_econet.c
+++ b/net/econet/af_econet.c
@@ -31,6 +31,7 @@
31#include <linux/skbuff.h> 31#include <linux/skbuff.h>
32#include <linux/udp.h> 32#include <linux/udp.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/vmalloc.h>
34#include <net/sock.h> 35#include <net/sock.h>
35#include <net/inet_common.h> 36#include <net/inet_common.h>
36#include <linux/stat.h> 37#include <linux/stat.h>
@@ -276,12 +277,12 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
276#endif 277#endif
277#ifdef CONFIG_ECONET_AUNUDP 278#ifdef CONFIG_ECONET_AUNUDP
278 struct msghdr udpmsg; 279 struct msghdr udpmsg;
279 struct iovec iov[msg->msg_iovlen+1]; 280 struct iovec iov[2];
280 struct aunhdr ah; 281 struct aunhdr ah;
281 struct sockaddr_in udpdest; 282 struct sockaddr_in udpdest;
282 __kernel_size_t size; 283 __kernel_size_t size;
283 int i;
284 mm_segment_t oldfs; 284 mm_segment_t oldfs;
285 char *userbuf;
285#endif 286#endif
286 287
287 /* 288 /*
@@ -297,23 +298,14 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
297 298
298 mutex_lock(&econet_mutex); 299 mutex_lock(&econet_mutex);
299 300
300 if (saddr == NULL) { 301 if (saddr == NULL || msg->msg_namelen < sizeof(struct sockaddr_ec)) {
301 struct econet_sock *eo = ec_sk(sk); 302 mutex_unlock(&econet_mutex);
302 303 return -EINVAL;
303 addr.station = eo->station; 304 }
304 addr.net = eo->net; 305 addr.station = saddr->addr.station;
305 port = eo->port; 306 addr.net = saddr->addr.net;
306 cb = eo->cb; 307 port = saddr->port;
307 } else { 308 cb = saddr->cb;
308 if (msg->msg_namelen < sizeof(struct sockaddr_ec)) {
309 mutex_unlock(&econet_mutex);
310 return -EINVAL;
311 }
312 addr.station = saddr->addr.station;
313 addr.net = saddr->addr.net;
314 port = saddr->port;
315 cb = saddr->cb;
316 }
317 309
318 /* Look for a device with the right network number. */ 310 /* Look for a device with the right network number. */
319 dev = net2dev_map[addr.net]; 311 dev = net2dev_map[addr.net];
@@ -328,17 +320,17 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
328 } 320 }
329 } 321 }
330 322
331 if (len + 15 > dev->mtu) {
332 mutex_unlock(&econet_mutex);
333 return -EMSGSIZE;
334 }
335
336 if (dev->type == ARPHRD_ECONET) { 323 if (dev->type == ARPHRD_ECONET) {
337 /* Real hardware Econet. We're not worthy etc. */ 324 /* Real hardware Econet. We're not worthy etc. */
338#ifdef CONFIG_ECONET_NATIVE 325#ifdef CONFIG_ECONET_NATIVE
339 unsigned short proto = 0; 326 unsigned short proto = 0;
340 int res; 327 int res;
341 328
329 if (len + 15 > dev->mtu) {
330 mutex_unlock(&econet_mutex);
331 return -EMSGSIZE;
332 }
333
342 dev_hold(dev); 334 dev_hold(dev);
343 335
344 skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev), 336 skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev),
@@ -351,7 +343,6 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
351 343
352 eb = (struct ec_cb *)&skb->cb; 344 eb = (struct ec_cb *)&skb->cb;
353 345
354 /* BUG: saddr may be NULL */
355 eb->cookie = saddr->cookie; 346 eb->cookie = saddr->cookie;
356 eb->sec = *saddr; 347 eb->sec = *saddr;
357 eb->sent = ec_tx_done; 348 eb->sent = ec_tx_done;
@@ -415,6 +406,11 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
415 return -ENETDOWN; /* No socket - can't send */ 406 return -ENETDOWN; /* No socket - can't send */
416 } 407 }
417 408
409 if (len > 32768) {
410 err = -E2BIG;
411 goto error;
412 }
413
418 /* Make up a UDP datagram and hand it off to some higher intellect. */ 414 /* Make up a UDP datagram and hand it off to some higher intellect. */
419 415
420 memset(&udpdest, 0, sizeof(udpdest)); 416 memset(&udpdest, 0, sizeof(udpdest));
@@ -446,36 +442,26 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
446 442
447 /* tack our header on the front of the iovec */ 443 /* tack our header on the front of the iovec */
448 size = sizeof(struct aunhdr); 444 size = sizeof(struct aunhdr);
449 /*
450 * XXX: that is b0rken. We can't mix userland and kernel pointers
451 * in iovec, since on a lot of platforms copy_from_user() will
452 * *not* work with the kernel and userland ones at the same time,
453 * regardless of what we do with set_fs(). And we are talking about
454 * econet-over-ethernet here, so "it's only ARM anyway" doesn't
455 * apply. Any suggestions on fixing that code? -- AV
456 */
457 iov[0].iov_base = (void *)&ah; 445 iov[0].iov_base = (void *)&ah;
458 iov[0].iov_len = size; 446 iov[0].iov_len = size;
459 for (i = 0; i < msg->msg_iovlen; i++) { 447
460 void __user *base = msg->msg_iov[i].iov_base; 448 userbuf = vmalloc(len);
461 size_t iov_len = msg->msg_iov[i].iov_len; 449 if (userbuf == NULL) {
462 /* Check it now since we switch to KERNEL_DS later. */ 450 err = -ENOMEM;
463 if (!access_ok(VERIFY_READ, base, iov_len)) { 451 goto error;
464 mutex_unlock(&econet_mutex);
465 return -EFAULT;
466 }
467 iov[i+1].iov_base = base;
468 iov[i+1].iov_len = iov_len;
469 size += iov_len;
470 } 452 }
471 453
454 iov[1].iov_base = userbuf;
455 iov[1].iov_len = len;
456 err = memcpy_fromiovec(userbuf, msg->msg_iov, len);
457 if (err)
458 goto error_free_buf;
459
472 /* Get a skbuff (no data, just holds our cb information) */ 460 /* Get a skbuff (no data, just holds our cb information) */
473 if ((skb = sock_alloc_send_skb(sk, 0, 461 if ((skb = sock_alloc_send_skb(sk, 0,
474 msg->msg_flags & MSG_DONTWAIT, 462 msg->msg_flags & MSG_DONTWAIT,
475 &err)) == NULL) { 463 &err)) == NULL)
476 mutex_unlock(&econet_mutex); 464 goto error_free_buf;
477 return err;
478 }
479 465
480 eb = (struct ec_cb *)&skb->cb; 466 eb = (struct ec_cb *)&skb->cb;
481 467
@@ -491,7 +477,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
491 udpmsg.msg_name = (void *)&udpdest; 477 udpmsg.msg_name = (void *)&udpdest;
492 udpmsg.msg_namelen = sizeof(udpdest); 478 udpmsg.msg_namelen = sizeof(udpdest);
493 udpmsg.msg_iov = &iov[0]; 479 udpmsg.msg_iov = &iov[0];
494 udpmsg.msg_iovlen = msg->msg_iovlen + 1; 480 udpmsg.msg_iovlen = 2;
495 udpmsg.msg_control = NULL; 481 udpmsg.msg_control = NULL;
496 udpmsg.msg_controllen = 0; 482 udpmsg.msg_controllen = 0;
497 udpmsg.msg_flags=0; 483 udpmsg.msg_flags=0;
@@ -499,9 +485,13 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
499 oldfs = get_fs(); set_fs(KERNEL_DS); /* More privs :-) */ 485 oldfs = get_fs(); set_fs(KERNEL_DS); /* More privs :-) */
500 err = sock_sendmsg(udpsock, &udpmsg, size); 486 err = sock_sendmsg(udpsock, &udpmsg, size);
501 set_fs(oldfs); 487 set_fs(oldfs);
488
489error_free_buf:
490 vfree(userbuf);
502#else 491#else
503 err = -EPROTOTYPE; 492 err = -EPROTOTYPE;
504#endif 493#endif
494 error:
505 mutex_unlock(&econet_mutex); 495 mutex_unlock(&econet_mutex);
506 496
507 return err; 497 return err;
@@ -671,6 +661,11 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg)
671 err = 0; 661 err = 0;
672 switch (cmd) { 662 switch (cmd) {
673 case SIOCSIFADDR: 663 case SIOCSIFADDR:
664 if (!capable(CAP_NET_ADMIN)) {
665 err = -EPERM;
666 break;
667 }
668
674 edev = dev->ec_ptr; 669 edev = dev->ec_ptr;
675 if (edev == NULL) { 670 if (edev == NULL) {
676 /* Magic up a new one. */ 671 /* Magic up a new one. */
@@ -856,9 +851,13 @@ static void aun_incoming(struct sk_buff *skb, struct aunhdr *ah, size_t len)
856{ 851{
857 struct iphdr *ip = ip_hdr(skb); 852 struct iphdr *ip = ip_hdr(skb);
858 unsigned char stn = ntohl(ip->saddr) & 0xff; 853 unsigned char stn = ntohl(ip->saddr) & 0xff;
854 struct dst_entry *dst = skb_dst(skb);
855 struct ec_device *edev = NULL;
859 struct sock *sk = NULL; 856 struct sock *sk = NULL;
860 struct sk_buff *newskb; 857 struct sk_buff *newskb;
861 struct ec_device *edev = skb->dev->ec_ptr; 858
859 if (dst)
860 edev = dst->dev->ec_ptr;
862 861
863 if (! edev) 862 if (! edev)
864 goto bad; 863 goto bad;
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 200eb538fbb3..0f280348e0fd 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -365,7 +365,7 @@ static struct tnode *tnode_alloc(size_t size)
365 if (size <= PAGE_SIZE) 365 if (size <= PAGE_SIZE)
366 return kzalloc(size, GFP_KERNEL); 366 return kzalloc(size, GFP_KERNEL);
367 else 367 else
368 return __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL); 368 return vzalloc(size);
369} 369}
370 370
371static void __tnode_vfree(struct work_struct *arg) 371static void __tnode_vfree(struct work_struct *arg)
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 96bc7f9475a3..e5d1a44bcbdf 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -569,6 +569,9 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
569 /* No need to clone since we're just using its address. */ 569 /* No need to clone since we're just using its address. */
570 rt2 = rt; 570 rt2 = rt;
571 571
572 if (!fl.nl_u.ip4_u.saddr)
573 fl.nl_u.ip4_u.saddr = rt->rt_src;
574
572 err = xfrm_lookup(net, (struct dst_entry **)&rt, &fl, NULL, 0); 575 err = xfrm_lookup(net, (struct dst_entry **)&rt, &fl, NULL, 0);
573 switch (err) { 576 switch (err) {
574 case 0: 577 case 0:
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 1b344f30b463..3c0369a3a663 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -133,8 +133,7 @@ int __inet_inherit_port(struct sock *sk, struct sock *child)
133 } 133 }
134 } 134 }
135 } 135 }
136 sk_add_bind_node(child, &tb->owners); 136 inet_bind_hash(child, tb, port);
137 inet_csk(child)->icsk_bind_hash = tb;
138 spin_unlock(&head->lock); 137 spin_unlock(&head->lock);
139 138
140 return 0; 139 return 0;
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 1b48eb1ed453..b14ec7d03b6e 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -253,6 +253,7 @@ static const struct snmp_mib snmp4_net_list[] = {
253 SNMP_MIB_ITEM("TCPMinTTLDrop", LINUX_MIB_TCPMINTTLDROP), 253 SNMP_MIB_ITEM("TCPMinTTLDrop", LINUX_MIB_TCPMINTTLDROP),
254 SNMP_MIB_ITEM("TCPDeferAcceptDrop", LINUX_MIB_TCPDEFERACCEPTDROP), 254 SNMP_MIB_ITEM("TCPDeferAcceptDrop", LINUX_MIB_TCPDEFERACCEPTDROP),
255 SNMP_MIB_ITEM("IPReversePathFilter", LINUX_MIB_IPRPFILTER), 255 SNMP_MIB_ITEM("IPReversePathFilter", LINUX_MIB_IPRPFILTER),
256 SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW),
256 SNMP_MIB_SENTINEL 257 SNMP_MIB_SENTINEL
257}; 258};
258 259
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index e91911d7aae2..1b4ec21497a4 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -26,6 +26,8 @@ static int zero;
26static int tcp_retr1_max = 255; 26static int tcp_retr1_max = 255;
27static int ip_local_port_range_min[] = { 1, 1 }; 27static int ip_local_port_range_min[] = { 1, 1 };
28static int ip_local_port_range_max[] = { 65535, 65535 }; 28static int ip_local_port_range_max[] = { 65535, 65535 };
29static int tcp_adv_win_scale_min = -31;
30static int tcp_adv_win_scale_max = 31;
29 31
30/* Update system visible IP port range */ 32/* Update system visible IP port range */
31static void set_local_port_range(int range[2]) 33static void set_local_port_range(int range[2])
@@ -426,7 +428,9 @@ static struct ctl_table ipv4_table[] = {
426 .data = &sysctl_tcp_adv_win_scale, 428 .data = &sysctl_tcp_adv_win_scale,
427 .maxlen = sizeof(int), 429 .maxlen = sizeof(int),
428 .mode = 0644, 430 .mode = 0644,
429 .proc_handler = proc_dointvec 431 .proc_handler = proc_dointvec_minmax,
432 .extra1 = &tcp_adv_win_scale_min,
433 .extra2 = &tcp_adv_win_scale_max,
430 }, 434 },
431 { 435 {
432 .procname = "tcp_tw_reuse", 436 .procname = "tcp_tw_reuse",
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 081419969485..f15c36a706ec 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2246,7 +2246,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2246 /* Values greater than interface MTU won't take effect. However 2246 /* Values greater than interface MTU won't take effect. However
2247 * at the point when this call is done we typically don't yet 2247 * at the point when this call is done we typically don't yet
2248 * know which interface is going to be used */ 2248 * know which interface is going to be used */
2249 if (val < 64 || val > MAX_TCP_WINDOW) { 2249 if (val < TCP_MIN_MSS || val > MAX_TCP_WINDOW) {
2250 err = -EINVAL; 2250 err = -EINVAL;
2251 break; 2251 break;
2252 } 2252 }
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 69ccbc1dde9c..e13da6de1fc7 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2043,7 +2043,9 @@ get_req:
2043 } 2043 }
2044get_sk: 2044get_sk:
2045 sk_nulls_for_each_from(sk, node) { 2045 sk_nulls_for_each_from(sk, node) {
2046 if (sk->sk_family == st->family && net_eq(sock_net(sk), net)) { 2046 if (!net_eq(sock_net(sk), net))
2047 continue;
2048 if (sk->sk_family == st->family) {
2047 cur = sk; 2049 cur = sk;
2048 goto out; 2050 goto out;
2049 } 2051 }
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 43cf901d7659..a66735f75963 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -347,7 +347,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
347 * socket up. We've got bigger problems than 347 * socket up. We've got bigger problems than
348 * non-graceful socket closings. 348 * non-graceful socket closings.
349 */ 349 */
350 LIMIT_NETDEBUG(KERN_INFO "TCP: time wait bucket table overflow\n"); 350 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPTIMEWAITOVERFLOW);
351 } 351 }
352 352
353 tcp_update_metrics(sk); 353 tcp_update_metrics(sk);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 05b1ecf36763..61c2463e2753 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -231,11 +231,10 @@ void tcp_select_initial_window(int __space, __u32 mss,
231 /* when initializing use the value from init_rcv_wnd 231 /* when initializing use the value from init_rcv_wnd
232 * rather than the default from above 232 * rather than the default from above
233 */ 233 */
234 if (init_rcv_wnd && 234 if (init_rcv_wnd)
235 (*rcv_wnd > init_rcv_wnd * mss)) 235 *rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss);
236 *rcv_wnd = init_rcv_wnd * mss; 236 else
237 else if (*rcv_wnd > init_cwnd * mss) 237 *rcv_wnd = min(*rcv_wnd, init_cwnd * mss);
238 *rcv_wnd = init_cwnd * mss;
239 } 238 }
240 239
241 /* Set the clamp no higher than max representable value */ 240 /* Set the clamp no higher than max representable value */
@@ -386,27 +385,30 @@ struct tcp_out_options {
386 */ 385 */
387static u8 tcp_cookie_size_check(u8 desired) 386static u8 tcp_cookie_size_check(u8 desired)
388{ 387{
389 if (desired > 0) { 388 int cookie_size;
389
390 if (desired > 0)
390 /* previously specified */ 391 /* previously specified */
391 return desired; 392 return desired;
392 } 393
393 if (sysctl_tcp_cookie_size <= 0) { 394 cookie_size = ACCESS_ONCE(sysctl_tcp_cookie_size);
395 if (cookie_size <= 0)
394 /* no default specified */ 396 /* no default specified */
395 return 0; 397 return 0;
396 } 398
397 if (sysctl_tcp_cookie_size <= TCP_COOKIE_MIN) { 399 if (cookie_size <= TCP_COOKIE_MIN)
398 /* value too small, specify minimum */ 400 /* value too small, specify minimum */
399 return TCP_COOKIE_MIN; 401 return TCP_COOKIE_MIN;
400 } 402
401 if (sysctl_tcp_cookie_size >= TCP_COOKIE_MAX) { 403 if (cookie_size >= TCP_COOKIE_MAX)
402 /* value too large, specify maximum */ 404 /* value too large, specify maximum */
403 return TCP_COOKIE_MAX; 405 return TCP_COOKIE_MAX;
404 } 406
405 if (0x1 & sysctl_tcp_cookie_size) { 407 if (cookie_size & 1)
406 /* 8-bit multiple, illegal, fix it */ 408 /* 8-bit multiple, illegal, fix it */
407 return (u8)(sysctl_tcp_cookie_size + 0x1); 409 cookie_size++;
408 } 410
409 return (u8)sysctl_tcp_cookie_size; 411 return (u8)cookie_size;
410} 412}
411 413
412/* Write previously computed TCP options to the packet. 414/* Write previously computed TCP options to the packet.
@@ -1513,6 +1515,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb)
1513 struct tcp_sock *tp = tcp_sk(sk); 1515 struct tcp_sock *tp = tcp_sk(sk);
1514 const struct inet_connection_sock *icsk = inet_csk(sk); 1516 const struct inet_connection_sock *icsk = inet_csk(sk);
1515 u32 send_win, cong_win, limit, in_flight; 1517 u32 send_win, cong_win, limit, in_flight;
1518 int win_divisor;
1516 1519
1517 if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN) 1520 if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN)
1518 goto send_now; 1521 goto send_now;
@@ -1544,13 +1547,14 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb)
1544 if ((skb != tcp_write_queue_tail(sk)) && (limit >= skb->len)) 1547 if ((skb != tcp_write_queue_tail(sk)) && (limit >= skb->len))
1545 goto send_now; 1548 goto send_now;
1546 1549
1547 if (sysctl_tcp_tso_win_divisor) { 1550 win_divisor = ACCESS_ONCE(sysctl_tcp_tso_win_divisor);
1551 if (win_divisor) {
1548 u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache); 1552 u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache);
1549 1553
1550 /* If at least some fraction of a window is available, 1554 /* If at least some fraction of a window is available,
1551 * just use it. 1555 * just use it.
1552 */ 1556 */
1553 chunk /= sysctl_tcp_tso_win_divisor; 1557 chunk /= win_divisor;
1554 if (limit >= chunk) 1558 if (limit >= chunk)
1555 goto send_now; 1559 goto send_now;
1556 } else { 1560 } else {
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index b41ce0f0d514..93b7a933a775 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -98,7 +98,11 @@
98#endif 98#endif
99 99
100#define INFINITY_LIFE_TIME 0xFFFFFFFF 100#define INFINITY_LIFE_TIME 0xFFFFFFFF
101#define TIME_DELTA(a, b) ((unsigned long)((long)(a) - (long)(b))) 101
102static inline u32 cstamp_delta(unsigned long cstamp)
103{
104 return (cstamp - INITIAL_JIFFIES) * 100UL / HZ;
105}
102 106
103#define ADDRCONF_TIMER_FUZZ_MINUS (HZ > 50 ? HZ/50 : 1) 107#define ADDRCONF_TIMER_FUZZ_MINUS (HZ > 50 ? HZ/50 : 1)
104#define ADDRCONF_TIMER_FUZZ (HZ / 4) 108#define ADDRCONF_TIMER_FUZZ (HZ / 4)
@@ -2754,13 +2758,13 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2754 ifa->state = INET6_IFADDR_STATE_DEAD; 2758 ifa->state = INET6_IFADDR_STATE_DEAD;
2755 spin_unlock_bh(&ifa->state_lock); 2759 spin_unlock_bh(&ifa->state_lock);
2756 2760
2757 if (state == INET6_IFADDR_STATE_DEAD) { 2761 if (state != INET6_IFADDR_STATE_DEAD) {
2758 in6_ifa_put(ifa);
2759 } else {
2760 __ipv6_ifa_notify(RTM_DELADDR, ifa); 2762 __ipv6_ifa_notify(RTM_DELADDR, ifa);
2761 atomic_notifier_call_chain(&inet6addr_chain, 2763 atomic_notifier_call_chain(&inet6addr_chain,
2762 NETDEV_DOWN, ifa); 2764 NETDEV_DOWN, ifa);
2763 } 2765 }
2766
2767 in6_ifa_put(ifa);
2764 write_lock_bh(&idev->lock); 2768 write_lock_bh(&idev->lock);
2765 } 2769 }
2766 } 2770 }
@@ -3444,10 +3448,8 @@ static int put_cacheinfo(struct sk_buff *skb, unsigned long cstamp,
3444{ 3448{
3445 struct ifa_cacheinfo ci; 3449 struct ifa_cacheinfo ci;
3446 3450
3447 ci.cstamp = (u32)(TIME_DELTA(cstamp, INITIAL_JIFFIES) / HZ * 100 3451 ci.cstamp = cstamp_delta(cstamp);
3448 + TIME_DELTA(cstamp, INITIAL_JIFFIES) % HZ * 100 / HZ); 3452 ci.tstamp = cstamp_delta(tstamp);
3449 ci.tstamp = (u32)(TIME_DELTA(tstamp, INITIAL_JIFFIES) / HZ * 100
3450 + TIME_DELTA(tstamp, INITIAL_JIFFIES) % HZ * 100 / HZ);
3451 ci.ifa_prefered = preferred; 3453 ci.ifa_prefered = preferred;
3452 ci.ifa_valid = valid; 3454 ci.ifa_valid = valid;
3453 3455
@@ -3798,8 +3800,10 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
3798 array[DEVCONF_AUTOCONF] = cnf->autoconf; 3800 array[DEVCONF_AUTOCONF] = cnf->autoconf;
3799 array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits; 3801 array[DEVCONF_DAD_TRANSMITS] = cnf->dad_transmits;
3800 array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits; 3802 array[DEVCONF_RTR_SOLICITS] = cnf->rtr_solicits;
3801 array[DEVCONF_RTR_SOLICIT_INTERVAL] = cnf->rtr_solicit_interval; 3803 array[DEVCONF_RTR_SOLICIT_INTERVAL] =
3802 array[DEVCONF_RTR_SOLICIT_DELAY] = cnf->rtr_solicit_delay; 3804 jiffies_to_msecs(cnf->rtr_solicit_interval);
3805 array[DEVCONF_RTR_SOLICIT_DELAY] =
3806 jiffies_to_msecs(cnf->rtr_solicit_delay);
3803 array[DEVCONF_FORCE_MLD_VERSION] = cnf->force_mld_version; 3807 array[DEVCONF_FORCE_MLD_VERSION] = cnf->force_mld_version;
3804#ifdef CONFIG_IPV6_PRIVACY 3808#ifdef CONFIG_IPV6_PRIVACY
3805 array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr; 3809 array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
@@ -3813,7 +3817,8 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
3813 array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; 3817 array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo;
3814#ifdef CONFIG_IPV6_ROUTER_PREF 3818#ifdef CONFIG_IPV6_ROUTER_PREF
3815 array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref; 3819 array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref;
3816 array[DEVCONF_RTR_PROBE_INTERVAL] = cnf->rtr_probe_interval; 3820 array[DEVCONF_RTR_PROBE_INTERVAL] =
3821 jiffies_to_msecs(cnf->rtr_probe_interval);
3817#ifdef CONFIG_IPV6_ROUTE_INFO 3822#ifdef CONFIG_IPV6_ROUTE_INFO
3818 array[DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN] = cnf->accept_ra_rt_info_max_plen; 3823 array[DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN] = cnf->accept_ra_rt_info_max_plen;
3819#endif 3824#endif
@@ -3929,10 +3934,9 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
3929 NLA_PUT_U32(skb, IFLA_INET6_FLAGS, idev->if_flags); 3934 NLA_PUT_U32(skb, IFLA_INET6_FLAGS, idev->if_flags);
3930 3935
3931 ci.max_reasm_len = IPV6_MAXPLEN; 3936 ci.max_reasm_len = IPV6_MAXPLEN;
3932 ci.tstamp = (__u32)(TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) / HZ * 100 3937 ci.tstamp = cstamp_delta(idev->tstamp);
3933 + TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) % HZ * 100 / HZ); 3938 ci.reachable_time = jiffies_to_msecs(idev->nd_parms->reachable_time);
3934 ci.reachable_time = idev->nd_parms->reachable_time; 3939 ci.retrans_time = jiffies_to_msecs(idev->nd_parms->retrans_time);
3935 ci.retrans_time = idev->nd_parms->retrans_time;
3936 NLA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci); 3940 NLA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci);
3937 3941
3938 nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32)); 3942 nla = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32));
@@ -4017,11 +4021,11 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
4017 kfree_skb(skb); 4021 kfree_skb(skb);
4018 goto errout; 4022 goto errout;
4019 } 4023 }
4020 rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); 4024 rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFINFO, NULL, GFP_ATOMIC);
4021 return; 4025 return;
4022errout: 4026errout:
4023 if (err < 0) 4027 if (err < 0)
4024 rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); 4028 rtnl_set_sk_err(net, RTNLGRP_IPV6_IFINFO, err);
4025} 4029}
4026 4030
4027static inline size_t inet6_prefix_nlmsg_size(void) 4031static inline size_t inet6_prefix_nlmsg_size(void)
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 2a59610c2a58..70e891a20fb9 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1175,6 +1175,8 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
1175 sizeof (struct ipv6hdr); 1175 sizeof (struct ipv6hdr);
1176 1176
1177 dev->mtu = rt->rt6i_dev->mtu - sizeof (struct ipv6hdr); 1177 dev->mtu = rt->rt6i_dev->mtu - sizeof (struct ipv6hdr);
1178 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
1179 dev->mtu-=8;
1178 1180
1179 if (dev->mtu < IPV6_MIN_MTU) 1181 if (dev->mtu < IPV6_MIN_MTU)
1180 dev->mtu = IPV6_MIN_MTU; 1182 dev->mtu = IPV6_MIN_MTU;
@@ -1363,12 +1365,17 @@ static const struct net_device_ops ip6_tnl_netdev_ops = {
1363 1365
1364static void ip6_tnl_dev_setup(struct net_device *dev) 1366static void ip6_tnl_dev_setup(struct net_device *dev)
1365{ 1367{
1368 struct ip6_tnl *t;
1369
1366 dev->netdev_ops = &ip6_tnl_netdev_ops; 1370 dev->netdev_ops = &ip6_tnl_netdev_ops;
1367 dev->destructor = ip6_dev_free; 1371 dev->destructor = ip6_dev_free;
1368 1372
1369 dev->type = ARPHRD_TUNNEL6; 1373 dev->type = ARPHRD_TUNNEL6;
1370 dev->hard_header_len = LL_MAX_HEADER + sizeof (struct ipv6hdr); 1374 dev->hard_header_len = LL_MAX_HEADER + sizeof (struct ipv6hdr);
1371 dev->mtu = ETH_DATA_LEN - sizeof (struct ipv6hdr); 1375 dev->mtu = ETH_DATA_LEN - sizeof (struct ipv6hdr);
1376 t = netdev_priv(dev);
1377 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
1378 dev->mtu-=8;
1372 dev->flags |= IFF_NOARP; 1379 dev->flags |= IFF_NOARP;
1373 dev->addr_len = sizeof(struct in6_addr); 1380 dev->addr_len = sizeof(struct in6_addr);
1374 dev->features |= NETIF_F_NETNS_LOCAL; 1381 dev->features |= NETIF_F_NETNS_LOCAL;
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index d6bfaec3bbbf..8c4d00c7cd2b 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -606,8 +606,9 @@ static int ipip6_rcv(struct sk_buff *skb)
606 return 0; 606 return 0;
607 } 607 }
608 608
609 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); 609 /* no tunnel matched, let upstream know, ipsec may handle it */
610 rcu_read_unlock(); 610 rcu_read_unlock();
611 return 1;
611out: 612out:
612 kfree_skb(skb); 613 kfree_skb(skb);
613 return 0; 614 return 0;
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 7f097989cde2..a6de3059746d 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -45,7 +45,6 @@
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>
49#include <linux/socket.h> 48#include <linux/socket.h>
50#include <linux/sockios.h> 49#include <linux/sockios.h>
51#include <linux/slab.h> 50#include <linux/slab.h>
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c
index 7fa86373de41..7c567b8aa89a 100644
--- a/net/irda/irnet/irnet_ppp.c
+++ b/net/irda/irnet/irnet_ppp.c
@@ -15,7 +15,6 @@
15 15
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/smp_lock.h>
19#include "irnet_ppp.h" /* Private header */ 18#include "irnet_ppp.h" /* Private header */
20/* Please put other headers in irnet.h - Thanks */ 19/* Please put other headers in irnet.h - Thanks */
21 20
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index 285761e77d90..f6054f9ccbe3 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -550,22 +550,30 @@ EXPORT_SYMBOL(irttp_close_tsap);
550 */ 550 */
551int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) 551int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)
552{ 552{
553 int ret;
554
553 IRDA_ASSERT(self != NULL, return -1;); 555 IRDA_ASSERT(self != NULL, return -1;);
554 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); 556 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
555 IRDA_ASSERT(skb != NULL, return -1;); 557 IRDA_ASSERT(skb != NULL, return -1;);
556 558
557 IRDA_DEBUG(4, "%s()\n", __func__); 559 IRDA_DEBUG(4, "%s()\n", __func__);
558 560
561 /* Take shortcut on zero byte packets */
562 if (skb->len == 0) {
563 ret = 0;
564 goto err;
565 }
566
559 /* Check that nothing bad happens */ 567 /* Check that nothing bad happens */
560 if ((skb->len == 0) || (!self->connected)) { 568 if (!self->connected) {
561 IRDA_DEBUG(1, "%s(), No data, or not connected\n", 569 IRDA_WARNING("%s(), Not connected\n", __func__);
562 __func__); 570 ret = -ENOTCONN;
563 goto err; 571 goto err;
564 } 572 }
565 573
566 if (skb->len > self->max_seg_size) { 574 if (skb->len > self->max_seg_size) {
567 IRDA_DEBUG(1, "%s(), UData is too large for IrLAP!\n", 575 IRDA_ERROR("%s(), UData is too large for IrLAP!\n", __func__);
568 __func__); 576 ret = -EMSGSIZE;
569 goto err; 577 goto err;
570 } 578 }
571 579
@@ -576,7 +584,7 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)
576 584
577err: 585err:
578 dev_kfree_skb(skb); 586 dev_kfree_skb(skb);
579 return -1; 587 return ret;
580} 588}
581EXPORT_SYMBOL(irttp_udata_request); 589EXPORT_SYMBOL(irttp_udata_request);
582 590
@@ -599,9 +607,15 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
599 IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__, 607 IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__,
600 skb_queue_len(&self->tx_queue)); 608 skb_queue_len(&self->tx_queue));
601 609
610 /* Take shortcut on zero byte packets */
611 if (skb->len == 0) {
612 ret = 0;
613 goto err;
614 }
615
602 /* Check that nothing bad happens */ 616 /* Check that nothing bad happens */
603 if ((skb->len == 0) || (!self->connected)) { 617 if (!self->connected) {
604 IRDA_WARNING("%s: No data, or not connected\n", __func__); 618 IRDA_WARNING("%s: Not connected\n", __func__);
605 ret = -ENOTCONN; 619 ret = -ENOTCONN;
606 goto err; 620 goto err;
607 } 621 }
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 0bf6a59545ab..522e219f3558 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -674,4 +674,8 @@ MODULE_LICENSE("GPL");
674MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); 674MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");
675MODULE_DESCRIPTION("L2TP over IP"); 675MODULE_DESCRIPTION("L2TP over IP");
676MODULE_VERSION("1.0"); 676MODULE_VERSION("1.0");
677MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET, SOCK_DGRAM, IPPROTO_L2TP); 677
678/* Use the value of SOCK_DGRAM (2) directory, because __stringify does't like
679 * enums
680 */
681MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET, 2, IPPROTO_L2TP);
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 582612998211..e35dbe55f520 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -317,8 +317,9 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
317 goto out; 317 goto out;
318 rc = -ENODEV; 318 rc = -ENODEV;
319 rtnl_lock(); 319 rtnl_lock();
320 rcu_read_lock();
320 if (sk->sk_bound_dev_if) { 321 if (sk->sk_bound_dev_if) {
321 llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if); 322 llc->dev = dev_get_by_index_rcu(&init_net, sk->sk_bound_dev_if);
322 if (llc->dev) { 323 if (llc->dev) {
323 if (!addr->sllc_arphrd) 324 if (!addr->sllc_arphrd)
324 addr->sllc_arphrd = llc->dev->type; 325 addr->sllc_arphrd = llc->dev->type;
@@ -329,13 +330,13 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
329 !llc_mac_match(addr->sllc_mac, 330 !llc_mac_match(addr->sllc_mac,
330 llc->dev->dev_addr)) { 331 llc->dev->dev_addr)) {
331 rc = -EINVAL; 332 rc = -EINVAL;
332 dev_put(llc->dev);
333 llc->dev = NULL; 333 llc->dev = NULL;
334 } 334 }
335 } 335 }
336 } else 336 } else
337 llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd, 337 llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd,
338 addr->sllc_mac); 338 addr->sllc_mac);
339 rcu_read_unlock();
339 rtnl_unlock(); 340 rtnl_unlock();
340 if (!llc->dev) 341 if (!llc->dev)
341 goto out; 342 goto out;
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index 4d6f8653ec88..8e8ea9cb7093 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -92,7 +92,7 @@ config MAC80211_MESH
92config MAC80211_LEDS 92config MAC80211_LEDS
93 bool "Enable LED triggers" 93 bool "Enable LED triggers"
94 depends on MAC80211 94 depends on MAC80211
95 select NEW_LEDS 95 depends on LEDS_CLASS
96 select LEDS_TRIGGERS 96 select LEDS_TRIGGERS
97 ---help--- 97 ---help---
98 This option enables a few LED triggers for different 98 This option enables a few LED triggers for different
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 902b03ee8f60..54fb4a0e76f0 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2247,6 +2247,10 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
2247 break; 2247 break;
2248 case cpu_to_le16(IEEE80211_STYPE_DEAUTH): 2248 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
2249 case cpu_to_le16(IEEE80211_STYPE_DISASSOC): 2249 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
2250 if (is_multicast_ether_addr(mgmt->da) &&
2251 !is_broadcast_ether_addr(mgmt->da))
2252 return RX_DROP_MONITOR;
2253
2250 /* process only for station */ 2254 /* process only for station */
2251 if (sdata->vif.type != NL80211_IFTYPE_STATION) 2255 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2252 return RX_DROP_MONITOR; 2256 return RX_DROP_MONITOR;
@@ -2741,6 +2745,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2741 2745
2742 if (ieee80211_prepare_and_rx_handle(&rx, skb, true)) 2746 if (ieee80211_prepare_and_rx_handle(&rx, skb, true))
2743 return; 2747 return;
2748 goto out;
2744 } 2749 }
2745 } 2750 }
2746 2751
@@ -2780,6 +2785,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2780 return; 2785 return;
2781 } 2786 }
2782 2787
2788 out:
2783 dev_kfree_skb(skb); 2789 dev_kfree_skb(skb);
2784} 2790}
2785 2791
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 96c594309506..7a637b80a62e 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1587,7 +1587,12 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
1587 list) { 1587 list) {
1588 if (!ieee80211_sdata_running(tmp_sdata)) 1588 if (!ieee80211_sdata_running(tmp_sdata))
1589 continue; 1589 continue;
1590 if (tmp_sdata->vif.type != NL80211_IFTYPE_AP) 1590 if (tmp_sdata->vif.type ==
1591 NL80211_IFTYPE_MONITOR ||
1592 tmp_sdata->vif.type ==
1593 NL80211_IFTYPE_AP_VLAN ||
1594 tmp_sdata->vif.type ==
1595 NL80211_IFTYPE_WDS)
1591 continue; 1596 continue;
1592 if (compare_ether_addr(tmp_sdata->vif.addr, 1597 if (compare_ether_addr(tmp_sdata->vif.addr,
1593 hdr->addr2) == 0) { 1598 hdr->addr2) == 0) {
@@ -1732,15 +1737,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1732 int nh_pos, h_pos; 1737 int nh_pos, h_pos;
1733 struct sta_info *sta = NULL; 1738 struct sta_info *sta = NULL;
1734 u32 sta_flags = 0; 1739 u32 sta_flags = 0;
1740 struct sk_buff *tmp_skb;
1735 1741
1736 if (unlikely(skb->len < ETH_HLEN)) { 1742 if (unlikely(skb->len < ETH_HLEN)) {
1737 ret = NETDEV_TX_OK; 1743 ret = NETDEV_TX_OK;
1738 goto fail; 1744 goto fail;
1739 } 1745 }
1740 1746
1741 nh_pos = skb_network_header(skb) - skb->data;
1742 h_pos = skb_transport_header(skb) - skb->data;
1743
1744 /* convert Ethernet header to proper 802.11 header (based on 1747 /* convert Ethernet header to proper 802.11 header (based on
1745 * operation mode) */ 1748 * operation mode) */
1746 ethertype = (skb->data[12] << 8) | skb->data[13]; 1749 ethertype = (skb->data[12] << 8) | skb->data[13];
@@ -1913,6 +1916,20 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1913 goto fail; 1916 goto fail;
1914 } 1917 }
1915 1918
1919 /*
1920 * If the skb is shared we need to obtain our own copy.
1921 */
1922 if (skb_shared(skb)) {
1923 tmp_skb = skb;
1924 skb = skb_copy(skb, GFP_ATOMIC);
1925 kfree_skb(tmp_skb);
1926
1927 if (!skb) {
1928 ret = NETDEV_TX_OK;
1929 goto fail;
1930 }
1931 }
1932
1916 hdr.frame_control = fc; 1933 hdr.frame_control = fc;
1917 hdr.duration_id = 0; 1934 hdr.duration_id = 0;
1918 hdr.seq_ctrl = 0; 1935 hdr.seq_ctrl = 0;
@@ -1931,6 +1948,9 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1931 encaps_len = 0; 1948 encaps_len = 0;
1932 } 1949 }
1933 1950
1951 nh_pos = skb_network_header(skb) - skb->data;
1952 h_pos = skb_transport_header(skb) - skb->data;
1953
1934 skb_pull(skb, skip_header_bytes); 1954 skb_pull(skb, skip_header_bytes);
1935 nh_pos -= skip_header_bytes; 1955 nh_pos -= skip_header_bytes;
1936 h_pos -= skip_header_bytes; 1956 h_pos -= skip_header_bytes;
diff --git a/net/netfilter/ipvs/Kconfig b/net/netfilter/ipvs/Kconfig
index a22dac227055..70bd1d0774c6 100644
--- a/net/netfilter/ipvs/Kconfig
+++ b/net/netfilter/ipvs/Kconfig
@@ -4,6 +4,7 @@
4menuconfig IP_VS 4menuconfig IP_VS
5 tristate "IP virtual server support" 5 tristate "IP virtual server support"
6 depends on NET && INET && NETFILTER 6 depends on NET && INET && NETFILTER
7 depends on (NF_CONNTRACK || NF_CONNTRACK=n)
7 ---help--- 8 ---help---
8 IP Virtual Server support will let you build a high-performance 9 IP Virtual Server support will let you build a high-performance
9 virtual server based on cluster of two or more real servers. This 10 virtual server based on cluster of two or more real servers. This
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 8920f2a83327..4e37c1cbe8b2 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -567,7 +567,7 @@ int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
567 goto out; 567 goto out;
568 } 568 }
569 569
570 if (args->nr_local > (u64)UINT_MAX) { 570 if (args->nr_local > UIO_MAXIOV) {
571 ret = -EMSGSIZE; 571 ret = -EMSGSIZE;
572 goto out; 572 goto out;
573 } 573 }
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 6bd554323a34..0b9ee34ad35c 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2932,6 +2932,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
2932 struct sctp_association *asoc = NULL; 2932 struct sctp_association *asoc = NULL;
2933 struct sctp_setpeerprim prim; 2933 struct sctp_setpeerprim prim;
2934 struct sctp_chunk *chunk; 2934 struct sctp_chunk *chunk;
2935 struct sctp_af *af;
2935 int err; 2936 int err;
2936 2937
2937 sp = sctp_sk(sk); 2938 sp = sctp_sk(sk);
@@ -2959,6 +2960,13 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
2959 if (!sctp_state(asoc, ESTABLISHED)) 2960 if (!sctp_state(asoc, ESTABLISHED))
2960 return -ENOTCONN; 2961 return -ENOTCONN;
2961 2962
2963 af = sctp_get_af_specific(prim.sspp_addr.ss_family);
2964 if (!af)
2965 return -EINVAL;
2966
2967 if (!af->addr_valid((union sctp_addr *)&prim.sspp_addr, sp, NULL))
2968 return -EADDRNOTAVAIL;
2969
2962 if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr)) 2970 if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr))
2963 return -EADDRNOTAVAIL; 2971 return -EADDRNOTAVAIL;
2964 2972
diff --git a/net/socket.c b/net/socket.c
index 3ca2fd9e3720..088fb3fd45e0 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -732,6 +732,21 @@ static int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
732 return ret; 732 return ret;
733} 733}
734 734
735/**
736 * kernel_recvmsg - Receive a message from a socket (kernel space)
737 * @sock: The socket to receive the message from
738 * @msg: Received message
739 * @vec: Input s/g array for message data
740 * @num: Size of input s/g array
741 * @size: Number of bytes to read
742 * @flags: Message flags (MSG_DONTWAIT, etc...)
743 *
744 * On return the msg structure contains the scatter/gather array passed in the
745 * vec argument. The array is modified so that it consists of the unfilled
746 * portion of the original array.
747 *
748 * The returned value is the total number of bytes received, or an error.
749 */
735int kernel_recvmsg(struct socket *sock, struct msghdr *msg, 750int kernel_recvmsg(struct socket *sock, struct msghdr *msg,
736 struct kvec *vec, size_t num, size_t size, int flags) 751 struct kvec *vec, size_t num, size_t size, int flags)
737{ 752{
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 9dab9573be41..92ce94f5146b 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -989,20 +989,26 @@ call_refreshresult(struct rpc_task *task)
989 dprint_status(task); 989 dprint_status(task);
990 990
991 task->tk_status = 0; 991 task->tk_status = 0;
992 task->tk_action = call_allocate; 992 task->tk_action = call_refresh;
993 if (status >= 0 && rpcauth_uptodatecred(task))
994 return;
995 switch (status) { 993 switch (status) {
996 case -EACCES: 994 case 0:
997 rpc_exit(task, -EACCES); 995 if (rpcauth_uptodatecred(task))
998 return; 996 task->tk_action = call_allocate;
999 case -ENOMEM:
1000 rpc_exit(task, -ENOMEM);
1001 return; 997 return;
1002 case -ETIMEDOUT: 998 case -ETIMEDOUT:
1003 rpc_delay(task, 3*HZ); 999 rpc_delay(task, 3*HZ);
1000 case -EAGAIN:
1001 status = -EACCES;
1002 if (!task->tk_cred_retry)
1003 break;
1004 task->tk_cred_retry--;
1005 dprintk("RPC: %5u %s: retry refresh creds\n",
1006 task->tk_pid, __func__);
1007 return;
1004 } 1008 }
1005 task->tk_action = call_refresh; 1009 dprintk("RPC: %5u %s: refresh creds failed with error %d\n",
1010 task->tk_pid, __func__, status);
1011 rpc_exit(task, status);
1006} 1012}
1007 1013
1008/* 1014/*
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c
index f71a73107ae9..80df89d957ba 100644
--- a/net/sunrpc/stats.c
+++ b/net/sunrpc/stats.c
@@ -115,9 +115,7 @@ EXPORT_SYMBOL_GPL(svc_seq_show);
115 */ 115 */
116struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) 116struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt)
117{ 117{
118 struct rpc_iostats *new; 118 return kcalloc(clnt->cl_maxproc, sizeof(struct rpc_iostats), GFP_KERNEL);
119 new = kcalloc(clnt->cl_maxproc, sizeof(struct rpc_iostats), GFP_KERNEL);
120 return new;
121} 119}
122EXPORT_SYMBOL_GPL(rpc_alloc_iostats); 120EXPORT_SYMBOL_GPL(rpc_alloc_iostats);
123 121
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index c82fe739fbdc..3f2c5559ca1a 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -5,7 +5,6 @@
5 */ 5 */
6 6
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/smp_lock.h>
9#include <linux/errno.h> 8#include <linux/errno.h>
10#include <linux/freezer.h> 9#include <linux/freezer.h>
11#include <linux/kthread.h> 10#include <linux/kthread.h>
@@ -213,6 +212,7 @@ int svc_create_xprt(struct svc_serv *serv, const char *xprt_name,
213 spin_lock(&svc_xprt_class_lock); 212 spin_lock(&svc_xprt_class_lock);
214 list_for_each_entry(xcl, &svc_xprt_class_list, xcl_list) { 213 list_for_each_entry(xcl, &svc_xprt_class_list, xcl_list) {
215 struct svc_xprt *newxprt; 214 struct svc_xprt *newxprt;
215 unsigned short newport;
216 216
217 if (strcmp(xprt_name, xcl->xcl_name)) 217 if (strcmp(xprt_name, xcl->xcl_name))
218 continue; 218 continue;
@@ -231,8 +231,9 @@ int svc_create_xprt(struct svc_serv *serv, const char *xprt_name,
231 spin_lock_bh(&serv->sv_lock); 231 spin_lock_bh(&serv->sv_lock);
232 list_add(&newxprt->xpt_list, &serv->sv_permsocks); 232 list_add(&newxprt->xpt_list, &serv->sv_permsocks);
233 spin_unlock_bh(&serv->sv_lock); 233 spin_unlock_bh(&serv->sv_lock);
234 newport = svc_xprt_local_port(newxprt);
234 clear_bit(XPT_BUSY, &newxprt->xpt_flags); 235 clear_bit(XPT_BUSY, &newxprt->xpt_flags);
235 return svc_xprt_local_port(newxprt); 236 return newport;
236 } 237 }
237 err: 238 err:
238 spin_unlock(&svc_xprt_class_lock); 239 spin_unlock(&svc_xprt_class_lock);
@@ -426,8 +427,13 @@ void svc_xprt_received(struct svc_xprt *xprt)
426{ 427{
427 BUG_ON(!test_bit(XPT_BUSY, &xprt->xpt_flags)); 428 BUG_ON(!test_bit(XPT_BUSY, &xprt->xpt_flags));
428 xprt->xpt_pool = NULL; 429 xprt->xpt_pool = NULL;
430 /* As soon as we clear busy, the xprt could be closed and
431 * 'put', so we need a reference to call svc_xprt_enqueue with:
432 */
433 svc_xprt_get(xprt);
429 clear_bit(XPT_BUSY, &xprt->xpt_flags); 434 clear_bit(XPT_BUSY, &xprt->xpt_flags);
430 svc_xprt_enqueue(xprt); 435 svc_xprt_enqueue(xprt);
436 svc_xprt_put(xprt);
431} 437}
432EXPORT_SYMBOL_GPL(svc_xprt_received); 438EXPORT_SYMBOL_GPL(svc_xprt_received);
433 439
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 3c95304a0817..2268e6798124 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1343,9 +1343,25 @@ static void unix_destruct_scm(struct sk_buff *skb)
1343 sock_wfree(skb); 1343 sock_wfree(skb);
1344} 1344}
1345 1345
1346#define MAX_RECURSION_LEVEL 4
1347
1346static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb) 1348static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
1347{ 1349{
1348 int i; 1350 int i;
1351 unsigned char max_level = 0;
1352 int unix_sock_count = 0;
1353
1354 for (i = scm->fp->count - 1; i >= 0; i--) {
1355 struct sock *sk = unix_get_socket(scm->fp->fp[i]);
1356
1357 if (sk) {
1358 unix_sock_count++;
1359 max_level = max(max_level,
1360 unix_sk(sk)->recursion_level);
1361 }
1362 }
1363 if (unlikely(max_level > MAX_RECURSION_LEVEL))
1364 return -ETOOMANYREFS;
1349 1365
1350 /* 1366 /*
1351 * Need to duplicate file references for the sake of garbage 1367 * Need to duplicate file references for the sake of garbage
@@ -1356,9 +1372,11 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
1356 if (!UNIXCB(skb).fp) 1372 if (!UNIXCB(skb).fp)
1357 return -ENOMEM; 1373 return -ENOMEM;
1358 1374
1359 for (i = scm->fp->count-1; i >= 0; i--) 1375 if (unix_sock_count) {
1360 unix_inflight(scm->fp->fp[i]); 1376 for (i = scm->fp->count - 1; i >= 0; i--)
1361 return 0; 1377 unix_inflight(scm->fp->fp[i]);
1378 }
1379 return max_level;
1362} 1380}
1363 1381
1364static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool send_fds) 1382static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool send_fds)
@@ -1393,6 +1411,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1393 struct sk_buff *skb; 1411 struct sk_buff *skb;
1394 long timeo; 1412 long timeo;
1395 struct scm_cookie tmp_scm; 1413 struct scm_cookie tmp_scm;
1414 int max_level;
1396 1415
1397 if (NULL == siocb->scm) 1416 if (NULL == siocb->scm)
1398 siocb->scm = &tmp_scm; 1417 siocb->scm = &tmp_scm;
@@ -1431,8 +1450,9 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
1431 goto out; 1450 goto out;
1432 1451
1433 err = unix_scm_to_skb(siocb->scm, skb, true); 1452 err = unix_scm_to_skb(siocb->scm, skb, true);
1434 if (err) 1453 if (err < 0)
1435 goto out_free; 1454 goto out_free;
1455 max_level = err + 1;
1436 unix_get_secdata(siocb->scm, skb); 1456 unix_get_secdata(siocb->scm, skb);
1437 1457
1438 skb_reset_transport_header(skb); 1458 skb_reset_transport_header(skb);
@@ -1514,6 +1534,8 @@ restart:
1514 if (sock_flag(other, SOCK_RCVTSTAMP)) 1534 if (sock_flag(other, SOCK_RCVTSTAMP))
1515 __net_timestamp(skb); 1535 __net_timestamp(skb);
1516 skb_queue_tail(&other->sk_receive_queue, skb); 1536 skb_queue_tail(&other->sk_receive_queue, skb);
1537 if (max_level > unix_sk(other)->recursion_level)
1538 unix_sk(other)->recursion_level = max_level;
1517 unix_state_unlock(other); 1539 unix_state_unlock(other);
1518 other->sk_data_ready(other, len); 1540 other->sk_data_ready(other, len);
1519 sock_put(other); 1541 sock_put(other);
@@ -1544,6 +1566,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1544 int sent = 0; 1566 int sent = 0;
1545 struct scm_cookie tmp_scm; 1567 struct scm_cookie tmp_scm;
1546 bool fds_sent = false; 1568 bool fds_sent = false;
1569 int max_level;
1547 1570
1548 if (NULL == siocb->scm) 1571 if (NULL == siocb->scm)
1549 siocb->scm = &tmp_scm; 1572 siocb->scm = &tmp_scm;
@@ -1607,10 +1630,11 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1607 1630
1608 /* Only send the fds in the first buffer */ 1631 /* Only send the fds in the first buffer */
1609 err = unix_scm_to_skb(siocb->scm, skb, !fds_sent); 1632 err = unix_scm_to_skb(siocb->scm, skb, !fds_sent);
1610 if (err) { 1633 if (err < 0) {
1611 kfree_skb(skb); 1634 kfree_skb(skb);
1612 goto out_err; 1635 goto out_err;
1613 } 1636 }
1637 max_level = err + 1;
1614 fds_sent = true; 1638 fds_sent = true;
1615 1639
1616 err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); 1640 err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
@@ -1626,6 +1650,8 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
1626 goto pipe_err_free; 1650 goto pipe_err_free;
1627 1651
1628 skb_queue_tail(&other->sk_receive_queue, skb); 1652 skb_queue_tail(&other->sk_receive_queue, skb);
1653 if (max_level > unix_sk(other)->recursion_level)
1654 unix_sk(other)->recursion_level = max_level;
1629 unix_state_unlock(other); 1655 unix_state_unlock(other);
1630 other->sk_data_ready(other, size); 1656 other->sk_data_ready(other, size);
1631 sent += size; 1657 sent += size;
@@ -1845,6 +1871,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1845 unix_state_lock(sk); 1871 unix_state_lock(sk);
1846 skb = skb_dequeue(&sk->sk_receive_queue); 1872 skb = skb_dequeue(&sk->sk_receive_queue);
1847 if (skb == NULL) { 1873 if (skb == NULL) {
1874 unix_sk(sk)->recursion_level = 0;
1848 if (copied >= target) 1875 if (copied >= target)
1849 goto unlock; 1876 goto unlock;
1850 1877
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index c8df6fda0b1f..f89f83bf828e 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -96,7 +96,7 @@ static DECLARE_WAIT_QUEUE_HEAD(unix_gc_wait);
96unsigned int unix_tot_inflight; 96unsigned int unix_tot_inflight;
97 97
98 98
99static struct sock *unix_get_socket(struct file *filp) 99struct sock *unix_get_socket(struct file *filp)
100{ 100{
101 struct sock *u_sock = NULL; 101 struct sock *u_sock = NULL;
102 struct inode *inode = filp->f_path.dentry->d_inode; 102 struct inode *inode = filp->f_path.dentry->d_inode;
@@ -259,9 +259,16 @@ static void inc_inflight_move_tail(struct unix_sock *u)
259} 259}
260 260
261static bool gc_in_progress = false; 261static bool gc_in_progress = false;
262#define UNIX_INFLIGHT_TRIGGER_GC 16000
262 263
263void wait_for_unix_gc(void) 264void wait_for_unix_gc(void)
264{ 265{
266 /*
267 * If number of inflight sockets is insane,
268 * force a garbage collect right now.
269 */
270 if (unix_tot_inflight > UNIX_INFLIGHT_TRIGGER_GC && !gc_in_progress)
271 unix_gc();
265 wait_event(unix_gc_wait, gc_in_progress == false); 272 wait_event(unix_gc_wait, gc_in_progress == false);
266} 273}
267 274
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index d0c92dddb26b..17cd0c04d139 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -44,6 +44,38 @@ rdev_freq_to_chan(struct cfg80211_registered_device *rdev,
44 return chan; 44 return chan;
45} 45}
46 46
47static bool can_beacon_sec_chan(struct wiphy *wiphy,
48 struct ieee80211_channel *chan,
49 enum nl80211_channel_type channel_type)
50{
51 struct ieee80211_channel *sec_chan;
52 int diff;
53
54 switch (channel_type) {
55 case NL80211_CHAN_HT40PLUS:
56 diff = 20;
57 break;
58 case NL80211_CHAN_HT40MINUS:
59 diff = -20;
60 break;
61 default:
62 return false;
63 }
64
65 sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff);
66 if (!sec_chan)
67 return false;
68
69 /* we'll need a DFS capability later */
70 if (sec_chan->flags & (IEEE80211_CHAN_DISABLED |
71 IEEE80211_CHAN_PASSIVE_SCAN |
72 IEEE80211_CHAN_NO_IBSS |
73 IEEE80211_CHAN_RADAR))
74 return false;
75
76 return true;
77}
78
47int cfg80211_set_freq(struct cfg80211_registered_device *rdev, 79int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
48 struct wireless_dev *wdev, int freq, 80 struct wireless_dev *wdev, int freq,
49 enum nl80211_channel_type channel_type) 81 enum nl80211_channel_type channel_type)
@@ -68,6 +100,28 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
68 if (!chan) 100 if (!chan)
69 return -EINVAL; 101 return -EINVAL;
70 102
103 /* Both channels should be able to initiate communication */
104 if (wdev && (wdev->iftype == NL80211_IFTYPE_ADHOC ||
105 wdev->iftype == NL80211_IFTYPE_AP ||
106 wdev->iftype == NL80211_IFTYPE_AP_VLAN ||
107 wdev->iftype == NL80211_IFTYPE_MESH_POINT ||
108 wdev->iftype == NL80211_IFTYPE_P2P_GO)) {
109 switch (channel_type) {
110 case NL80211_CHAN_HT40PLUS:
111 case NL80211_CHAN_HT40MINUS:
112 if (!can_beacon_sec_chan(&rdev->wiphy, chan,
113 channel_type)) {
114 printk(KERN_DEBUG
115 "cfg80211: Secondary channel not "
116 "allowed to initiate communication\n");
117 return -EINVAL;
118 }
119 break;
120 default:
121 break;
122 }
123 }
124
71 result = rdev->ops->set_channel(&rdev->wiphy, 125 result = rdev->ops->set_channel(&rdev->wiphy,
72 wdev ? wdev->netdev : NULL, 126 wdev ? wdev->netdev : NULL,
73 chan, channel_type); 127 chan, channel_type);
diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c
index 73e7b954ad28..b25c6463c3e9 100644
--- a/net/x25/x25_link.c
+++ b/net/x25/x25_link.c
@@ -394,6 +394,7 @@ void __exit x25_link_free(void)
394 list_for_each_safe(entry, tmp, &x25_neigh_list) { 394 list_for_each_safe(entry, tmp, &x25_neigh_list) {
395 nb = list_entry(entry, struct x25_neigh, node); 395 nb = list_entry(entry, struct x25_neigh, node);
396 __x25_remove_neigh(nb); 396 __x25_remove_neigh(nb);
397 dev_put(nb->dev);
397 } 398 }
398 write_unlock_bh(&x25_neigh_list_lock); 399 write_unlock_bh(&x25_neigh_list_lock);
399} 400}
diff --git a/net/xfrm/xfrm_hash.c b/net/xfrm/xfrm_hash.c
index a2023ec52329..1e98bc0fe0a5 100644
--- a/net/xfrm/xfrm_hash.c
+++ b/net/xfrm/xfrm_hash.c
@@ -19,7 +19,7 @@ struct hlist_head *xfrm_hash_alloc(unsigned int sz)
19 if (sz <= PAGE_SIZE) 19 if (sz <= PAGE_SIZE)
20 n = kzalloc(sz, GFP_KERNEL); 20 n = kzalloc(sz, GFP_KERNEL);
21 else if (hashdist) 21 else if (hashdist)
22 n = __vmalloc(sz, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL); 22 n = vzalloc(sz);
23 else 23 else
24 n = (struct hlist_head *) 24 n = (struct hlist_head *)
25 __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 25 __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO,
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index eb96ce52f178..220ebc05c7af 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1268,7 +1268,7 @@ struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x,
1268 1268
1269 return xc; 1269 return xc;
1270error: 1270error:
1271 kfree(xc); 1271 xfrm_state_put(xc);
1272 return NULL; 1272 return NULL;
1273} 1273}
1274EXPORT_SYMBOL(xfrm_state_migrate); 1274EXPORT_SYMBOL(xfrm_state_migrate);
diff --git a/scripts/gfp-translate b/scripts/gfp-translate
index d81b968d864e..c9230e158a8f 100644
--- a/scripts/gfp-translate
+++ b/scripts/gfp-translate
@@ -63,7 +63,12 @@ fi
63 63
64# Extract GFP flags from the kernel source 64# Extract GFP flags from the kernel source
65TMPFILE=`mktemp -t gfptranslate-XXXXXX` || exit 1 65TMPFILE=`mktemp -t gfptranslate-XXXXXX` || exit 1
66grep "^#define __GFP" $SOURCE/include/linux/gfp.h | sed -e 's/(__force gfp_t)//' | sed -e 's/u)/)/' | grep -v GFP_BITS | sed -e 's/)\//) \//' > $TMPFILE 66grep -q ___GFP $SOURCE/include/linux/gfp.h
67if [ $? -eq 0 ]; then
68 grep "^#define ___GFP" $SOURCE/include/linux/gfp.h | sed -e 's/u$//' | grep -v GFP_BITS > $TMPFILE
69else
70 grep "^#define __GFP" $SOURCE/include/linux/gfp.h | sed -e 's/(__force gfp_t)//' | sed -e 's/u)/)/' | grep -v GFP_BITS | sed -e 's/)\//) \//' > $TMPFILE
71fi
67 72
68# Parse the flags 73# Parse the flags
69IFS=" 74IFS="
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 184eb6a0b505..e57826ced380 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -164,6 +164,7 @@ struct menu {
164 struct menu *list; 164 struct menu *list;
165 struct symbol *sym; 165 struct symbol *sym;
166 struct property *prompt; 166 struct property *prompt;
167 struct expr *visibility;
167 struct expr *dep; 168 struct expr *dep;
168 unsigned int flags; 169 unsigned int flags;
169 char *help; 170 char *help;
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 753cdbd7b805..3f7240df0f3b 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -107,6 +107,7 @@ void menu_end_menu(void);
107void menu_add_entry(struct symbol *sym); 107void menu_add_entry(struct symbol *sym);
108void menu_end_entry(void); 108void menu_end_entry(void);
109void menu_add_dep(struct expr *dep); 109void menu_add_dep(struct expr *dep);
110void menu_add_visibility(struct expr *dep);
110struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); 111struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
111struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); 112struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
112void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); 113void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 7e83aef42c6d..b9d9aa18e6d6 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -152,6 +152,12 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr
152 return menu_add_prop(type, prompt, NULL, dep); 152 return menu_add_prop(type, prompt, NULL, dep);
153} 153}
154 154
155void menu_add_visibility(struct expr *expr)
156{
157 current_entry->visibility = expr_alloc_and(current_entry->visibility,
158 expr);
159}
160
155void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) 161void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
156{ 162{
157 menu_add_prop(type, NULL, expr, dep); 163 menu_add_prop(type, NULL, expr, dep);
@@ -410,6 +416,11 @@ bool menu_is_visible(struct menu *menu)
410 if (!menu->prompt) 416 if (!menu->prompt)
411 return false; 417 return false;
412 418
419 if (menu->visibility) {
420 if (expr_calc_value(menu->visibility) == no)
421 return no;
422 }
423
413 sym = menu->sym; 424 sym = menu->sym;
414 if (sym) { 425 if (sym) {
415 sym_calc_value(sym); 426 sym_calc_value(sym);
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
index d8bc74249622..c9e690eb7545 100644
--- a/scripts/kconfig/zconf.gperf
+++ b/scripts/kconfig/zconf.gperf
@@ -38,6 +38,7 @@ hex, T_TYPE, TF_COMMAND, S_HEX
38string, T_TYPE, TF_COMMAND, S_STRING 38string, T_TYPE, TF_COMMAND, S_STRING
39select, T_SELECT, TF_COMMAND 39select, T_SELECT, TF_COMMAND
40range, T_RANGE, TF_COMMAND 40range, T_RANGE, TF_COMMAND
41visible, T_VISIBLE, TF_COMMAND
41option, T_OPTION, TF_COMMAND 42option, T_OPTION, TF_COMMAND
42on, T_ON, TF_PARAM 43on, T_ON, TF_PARAM
43modules, T_OPT_MODULES, TF_OPTION 44modules, T_OPT_MODULES, TF_OPTION
diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped
index c1748faf4634..4055d5de1750 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -32,7 +32,7 @@
32struct kconf_id; 32struct kconf_id;
33 33
34static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); 34static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
35/* maximum key range = 47, duplicates = 0 */ 35/* maximum key range = 50, duplicates = 0 */
36 36
37#ifdef __GNUC__ 37#ifdef __GNUC__
38__inline 38__inline
@@ -46,32 +46,32 @@ kconf_id_hash (register const char *str, register unsigned int len)
46{ 46{
47 static unsigned char asso_values[] = 47 static unsigned char asso_values[] =
48 { 48 {
49 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
50 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
51 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 51 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 52 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
53 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
54 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 54 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
55 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 55 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
56 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 56 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
57 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 57 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
58 49, 49, 49, 49, 49, 49, 49, 49, 11, 5, 58 52, 52, 52, 52, 52, 52, 52, 52, 40, 5,
59 0, 0, 5, 49, 5, 20, 49, 49, 5, 20, 59 0, 0, 5, 52, 0, 20, 52, 52, 10, 20,
60 5, 0, 30, 49, 0, 15, 0, 10, 0, 49, 60 5, 0, 35, 52, 0, 30, 0, 15, 0, 52,
61 25, 49, 49, 49, 49, 49, 49, 49, 49, 49, 61 15, 52, 52, 52, 52, 52, 52, 52, 52, 52,
62 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 62 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
63 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 63 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
64 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 64 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
65 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 65 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
66 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 66 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
67 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 67 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
68 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 68 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
69 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 69 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
70 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 70 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
71 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 71 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
72 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 72 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
73 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 73 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
74 49, 49, 49, 49, 49, 49 74 52, 52, 52, 52, 52, 52
75 }; 75 };
76 register int hval = len; 76 register int hval = len;
77 77
@@ -102,25 +102,26 @@ struct kconf_id_strings_t
102 char kconf_id_strings_str12[sizeof("default")]; 102 char kconf_id_strings_str12[sizeof("default")];
103 char kconf_id_strings_str13[sizeof("def_bool")]; 103 char kconf_id_strings_str13[sizeof("def_bool")];
104 char kconf_id_strings_str14[sizeof("help")]; 104 char kconf_id_strings_str14[sizeof("help")];
105 char kconf_id_strings_str15[sizeof("bool")];
106 char kconf_id_strings_str16[sizeof("config")]; 105 char kconf_id_strings_str16[sizeof("config")];
107 char kconf_id_strings_str17[sizeof("def_tristate")]; 106 char kconf_id_strings_str17[sizeof("def_tristate")];
108 char kconf_id_strings_str18[sizeof("boolean")]; 107 char kconf_id_strings_str18[sizeof("hex")];
109 char kconf_id_strings_str19[sizeof("defconfig_list")]; 108 char kconf_id_strings_str19[sizeof("defconfig_list")];
110 char kconf_id_strings_str21[sizeof("string")];
111 char kconf_id_strings_str22[sizeof("if")]; 109 char kconf_id_strings_str22[sizeof("if")];
112 char kconf_id_strings_str23[sizeof("int")]; 110 char kconf_id_strings_str23[sizeof("int")];
113 char kconf_id_strings_str26[sizeof("select")];
114 char kconf_id_strings_str27[sizeof("modules")]; 111 char kconf_id_strings_str27[sizeof("modules")];
115 char kconf_id_strings_str28[sizeof("tristate")]; 112 char kconf_id_strings_str28[sizeof("tristate")];
116 char kconf_id_strings_str29[sizeof("menu")]; 113 char kconf_id_strings_str29[sizeof("menu")];
117 char kconf_id_strings_str31[sizeof("source")];
118 char kconf_id_strings_str32[sizeof("comment")]; 114 char kconf_id_strings_str32[sizeof("comment")];
119 char kconf_id_strings_str33[sizeof("hex")];
120 char kconf_id_strings_str35[sizeof("menuconfig")]; 115 char kconf_id_strings_str35[sizeof("menuconfig")];
121 char kconf_id_strings_str36[sizeof("prompt")]; 116 char kconf_id_strings_str36[sizeof("string")];
122 char kconf_id_strings_str37[sizeof("depends")]; 117 char kconf_id_strings_str37[sizeof("visible")];
118 char kconf_id_strings_str41[sizeof("prompt")];
119 char kconf_id_strings_str42[sizeof("depends")];
120 char kconf_id_strings_str44[sizeof("bool")];
121 char kconf_id_strings_str46[sizeof("select")];
122 char kconf_id_strings_str47[sizeof("boolean")];
123 char kconf_id_strings_str48[sizeof("mainmenu")]; 123 char kconf_id_strings_str48[sizeof("mainmenu")];
124 char kconf_id_strings_str51[sizeof("source")];
124 }; 125 };
125static struct kconf_id_strings_t kconf_id_strings_contents = 126static struct kconf_id_strings_t kconf_id_strings_contents =
126 { 127 {
@@ -136,25 +137,26 @@ static struct kconf_id_strings_t kconf_id_strings_contents =
136 "default", 137 "default",
137 "def_bool", 138 "def_bool",
138 "help", 139 "help",
139 "bool",
140 "config", 140 "config",
141 "def_tristate", 141 "def_tristate",
142 "boolean", 142 "hex",
143 "defconfig_list", 143 "defconfig_list",
144 "string",
145 "if", 144 "if",
146 "int", 145 "int",
147 "select",
148 "modules", 146 "modules",
149 "tristate", 147 "tristate",
150 "menu", 148 "menu",
151 "source",
152 "comment", 149 "comment",
153 "hex",
154 "menuconfig", 150 "menuconfig",
151 "string",
152 "visible",
155 "prompt", 153 "prompt",
156 "depends", 154 "depends",
157 "mainmenu" 155 "bool",
156 "select",
157 "boolean",
158 "mainmenu",
159 "source"
158 }; 160 };
159#define kconf_id_strings ((const char *) &kconf_id_strings_contents) 161#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
160#ifdef __GNUC__ 162#ifdef __GNUC__
@@ -168,11 +170,11 @@ kconf_id_lookup (register const char *str, register unsigned int len)
168{ 170{
169 enum 171 enum
170 { 172 {
171 TOTAL_KEYWORDS = 31, 173 TOTAL_KEYWORDS = 32,
172 MIN_WORD_LENGTH = 2, 174 MIN_WORD_LENGTH = 2,
173 MAX_WORD_LENGTH = 14, 175 MAX_WORD_LENGTH = 14,
174 MIN_HASH_VALUE = 2, 176 MIN_HASH_VALUE = 2,
175 MAX_HASH_VALUE = 48 177 MAX_HASH_VALUE = 51
176 }; 178 };
177 179
178 static struct kconf_id wordlist[] = 180 static struct kconf_id wordlist[] =
@@ -191,31 +193,35 @@ kconf_id_lookup (register const char *str, register unsigned int len)
191 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, 193 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
192 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, 194 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
193 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND}, 195 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND},
194 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15, T_TYPE, TF_COMMAND, S_BOOLEAN}, 196 {-1},
195 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND}, 197 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND},
196 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, 198 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE},
197 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_BOOLEAN}, 199 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_HEX},
198 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION}, 200 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION},
199 {-1}, 201 {-1}, {-1},
200 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING},
201 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM}, 202 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM},
202 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT}, 203 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT},
203 {-1}, {-1}, 204 {-1}, {-1}, {-1},
204 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SELECT, TF_COMMAND},
205 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION}, 205 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION},
206 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE}, 206 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE},
207 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND}, 207 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND},
208 {-1}, 208 {-1}, {-1},
209 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND},
210 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, 209 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
211 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX}, 210 {-1}, {-1},
212 {-1},
213 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND}, 211 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND},
214 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_PROMPT, TF_COMMAND}, 212 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_TYPE, TF_COMMAND, S_STRING},
215 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_DEPENDS, TF_COMMAND}, 213 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_VISIBLE, TF_COMMAND},
216 {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, 214 {-1}, {-1}, {-1},
215 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_PROMPT, TF_COMMAND},
216 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_DEPENDS, TF_COMMAND},
217 {-1}, 217 {-1},
218 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND} 218 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str44, T_TYPE, TF_COMMAND, S_BOOLEAN},
219 {-1},
220 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_SELECT, TF_COMMAND},
221 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN},
222 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND},
223 {-1}, {-1},
224 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_SOURCE, TF_COMMAND}
219 }; 225 };
220 226
221 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) 227 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 699d4b265186..4c5495ea205e 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -160,18 +160,19 @@ static struct menu *current_menu, *current_entry;
160 T_DEFAULT = 275, 160 T_DEFAULT = 275,
161 T_SELECT = 276, 161 T_SELECT = 276,
162 T_RANGE = 277, 162 T_RANGE = 277,
163 T_OPTION = 278, 163 T_VISIBLE = 278,
164 T_ON = 279, 164 T_OPTION = 279,
165 T_WORD = 280, 165 T_ON = 280,
166 T_WORD_QUOTE = 281, 166 T_WORD = 281,
167 T_UNEQUAL = 282, 167 T_WORD_QUOTE = 282,
168 T_CLOSE_PAREN = 283, 168 T_UNEQUAL = 283,
169 T_OPEN_PAREN = 284, 169 T_CLOSE_PAREN = 284,
170 T_EOL = 285, 170 T_OPEN_PAREN = 285,
171 T_OR = 286, 171 T_EOL = 286,
172 T_AND = 287, 172 T_OR = 287,
173 T_EQUAL = 288, 173 T_AND = 288,
174 T_NOT = 289 174 T_EQUAL = 289,
175 T_NOT = 290
175 }; 176 };
176#endif 177#endif
177 178
@@ -419,20 +420,20 @@ union yyalloc
419/* YYFINAL -- State number of the termination state. */ 420/* YYFINAL -- State number of the termination state. */
420#define YYFINAL 11 421#define YYFINAL 11
421/* YYLAST -- Last index in YYTABLE. */ 422/* YYLAST -- Last index in YYTABLE. */
422#define YYLAST 277 423#define YYLAST 290
423 424
424/* YYNTOKENS -- Number of terminals. */ 425/* YYNTOKENS -- Number of terminals. */
425#define YYNTOKENS 35 426#define YYNTOKENS 36
426/* YYNNTS -- Number of nonterminals. */ 427/* YYNNTS -- Number of nonterminals. */
427#define YYNNTS 48 428#define YYNNTS 50
428/* YYNRULES -- Number of rules. */ 429/* YYNRULES -- Number of rules. */
429#define YYNRULES 113 430#define YYNRULES 118
430/* YYNRULES -- Number of states. */ 431/* YYNRULES -- Number of states. */
431#define YYNSTATES 185 432#define YYNSTATES 191
432 433
433/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 434/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
434#define YYUNDEFTOK 2 435#define YYUNDEFTOK 2
435#define YYMAXUTOK 289 436#define YYMAXUTOK 290
436 437
437#define YYTRANSLATE(YYX) \ 438#define YYTRANSLATE(YYX) \
438 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 439 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -468,7 +469,8 @@ static const yytype_uint8 yytranslate[] =
468 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 469 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
469 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 470 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
470 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 471 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
471 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 472 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
473 35
472}; 474};
473 475
474#if YYDEBUG 476#if YYDEBUG
@@ -478,72 +480,73 @@ static const yytype_uint16 yyprhs[] =
478{ 480{
479 0, 0, 3, 6, 8, 11, 13, 14, 17, 20, 481 0, 0, 3, 6, 8, 11, 13, 14, 17, 20,
480 23, 26, 31, 36, 40, 42, 44, 46, 48, 50, 482 23, 26, 31, 36, 40, 42, 44, 46, 48, 50,
481 52, 54, 56, 58, 60, 62, 64, 66, 70, 73, 483 52, 54, 56, 58, 60, 62, 64, 66, 68, 72,
482 77, 80, 84, 87, 88, 91, 94, 97, 100, 103, 484 75, 79, 82, 86, 89, 90, 93, 96, 99, 102,
483 106, 110, 115, 120, 125, 131, 135, 136, 140, 141, 485 105, 108, 112, 117, 122, 127, 133, 137, 138, 142,
484 144, 148, 151, 153, 157, 158, 161, 164, 167, 170, 486 143, 146, 150, 153, 155, 159, 160, 163, 166, 169,
485 173, 178, 182, 185, 190, 191, 194, 198, 200, 204, 487 172, 175, 180, 184, 187, 192, 193, 196, 200, 202,
486 205, 208, 211, 214, 218, 222, 225, 227, 231, 232, 488 206, 207, 210, 213, 216, 220, 224, 228, 230, 234,
487 235, 238, 241, 245, 249, 252, 255, 258, 259, 262, 489 235, 238, 241, 244, 248, 252, 255, 258, 261, 262,
488 265, 268, 273, 274, 277, 279, 281, 284, 287, 290, 490 265, 268, 271, 276, 277, 280, 283, 286, 287, 290,
489 292, 295, 296, 299, 301, 305, 309, 313, 316, 320, 491 292, 294, 297, 300, 303, 305, 308, 309, 312, 314,
490 324, 326, 328, 329 492 318, 322, 326, 329, 333, 337, 339, 341, 342
491}; 493};
492 494
493/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 495/* YYRHS -- A `-1'-separated list of the rules' RHS. */
494static const yytype_int8 yyrhs[] = 496static const yytype_int8 yyrhs[] =
495{ 497{
496 36, 0, -1, 78, 37, -1, 37, -1, 62, 38, 498 37, 0, -1, 81, 38, -1, 38, -1, 63, 39,
497 -1, 38, -1, -1, 38, 40, -1, 38, 54, -1, 499 -1, 39, -1, -1, 39, 41, -1, 39, 55, -1,
498 38, 66, -1, 38, 77, -1, 38, 25, 1, 30, 500 39, 67, -1, 39, 80, -1, 39, 26, 1, 31,
499 -1, 38, 39, 1, 30, -1, 38, 1, 30, -1, 501 -1, 39, 40, 1, 31, -1, 39, 1, 31, -1,
500 16, -1, 18, -1, 19, -1, 21, -1, 17, -1, 502 16, -1, 18, -1, 19, -1, 21, -1, 17, -1,
501 22, -1, 20, -1, 30, -1, 60, -1, 70, -1, 503 22, -1, 20, -1, 23, -1, 31, -1, 61, -1,
502 43, -1, 45, -1, 68, -1, 25, 1, 30, -1, 504 71, -1, 44, -1, 46, -1, 69, -1, 26, 1,
503 1, 30, -1, 10, 25, 30, -1, 42, 46, -1, 505 31, -1, 1, 31, -1, 10, 26, 31, -1, 43,
504 11, 25, 30, -1, 44, 46, -1, -1, 46, 47, 506 47, -1, 11, 26, 31, -1, 45, 47, -1, -1,
505 -1, 46, 48, -1, 46, 74, -1, 46, 72, -1, 507 47, 48, -1, 47, 49, -1, 47, 75, -1, 47,
506 46, 41, -1, 46, 30, -1, 19, 75, 30, -1, 508 73, -1, 47, 42, -1, 47, 31, -1, 19, 78,
507 18, 76, 79, 30, -1, 20, 80, 79, 30, -1, 509 31, -1, 18, 79, 82, 31, -1, 20, 83, 82,
508 21, 25, 79, 30, -1, 22, 81, 81, 79, 30, 510 31, -1, 21, 26, 82, 31, -1, 22, 84, 84,
509 -1, 23, 49, 30, -1, -1, 49, 25, 50, -1, 511 82, 31, -1, 24, 50, 31, -1, -1, 50, 26,
510 -1, 33, 76, -1, 7, 82, 30, -1, 51, 55, 512 51, -1, -1, 34, 79, -1, 7, 85, 31, -1,
511 -1, 77, -1, 52, 57, 53, -1, -1, 55, 56, 513 52, 56, -1, 80, -1, 53, 58, 54, -1, -1,
512 -1, 55, 74, -1, 55, 72, -1, 55, 30, -1, 514 56, 57, -1, 56, 75, -1, 56, 73, -1, 56,
513 55, 41, -1, 18, 76, 79, 30, -1, 19, 75, 515 31, -1, 56, 42, -1, 18, 79, 82, 31, -1,
514 30, -1, 17, 30, -1, 20, 25, 79, 30, -1, 516 19, 78, 31, -1, 17, 31, -1, 20, 26, 82,
515 -1, 57, 40, -1, 14, 80, 78, -1, 77, -1, 517 31, -1, -1, 58, 41, -1, 14, 83, 81, -1,
516 58, 61, 59, -1, -1, 61, 40, -1, 61, 66, 518 80, -1, 59, 62, 60, -1, -1, 62, 41, -1,
517 -1, 61, 54, -1, 3, 76, 78, -1, 4, 76, 519 62, 67, -1, 62, 55, -1, 3, 79, 81, -1,
518 30, -1, 63, 73, -1, 77, -1, 64, 67, 65, 520 4, 79, 31, -1, 64, 76, 74, -1, 80, -1,
519 -1, -1, 67, 40, -1, 67, 66, -1, 67, 54, 521 65, 68, 66, -1, -1, 68, 41, -1, 68, 67,
520 -1, 6, 76, 30, -1, 9, 76, 30, -1, 69, 522 -1, 68, 55, -1, 6, 79, 31, -1, 9, 79,
521 73, -1, 12, 30, -1, 71, 13, -1, -1, 73, 523 31, -1, 70, 74, -1, 12, 31, -1, 72, 13,
522 74, -1, 73, 30, -1, 73, 41, -1, 16, 24, 524 -1, -1, 74, 75, -1, 74, 31, -1, 74, 42,
523 80, 30, -1, -1, 76, 79, -1, 25, -1, 26, 525 -1, 16, 25, 83, 31, -1, -1, 76, 77, -1,
524 -1, 5, 30, -1, 8, 30, -1, 15, 30, -1, 526 76, 31, -1, 23, 82, -1, -1, 79, 82, -1,
525 30, -1, 78, 30, -1, -1, 14, 80, -1, 81, 527 26, -1, 27, -1, 5, 31, -1, 8, 31, -1,
526 -1, 81, 33, 81, -1, 81, 27, 81, -1, 29, 528 15, 31, -1, 31, -1, 81, 31, -1, -1, 14,
527 80, 28, -1, 34, 80, -1, 80, 31, 80, -1, 529 83, -1, 84, -1, 84, 34, 84, -1, 84, 28,
528 80, 32, 80, -1, 25, -1, 26, -1, -1, 25, 530 84, -1, 30, 83, 29, -1, 35, 83, -1, 83,
529 -1 531 32, 83, -1, 83, 33, 83, -1, 26, -1, 27,
532 -1, -1, 26, -1
530}; 533};
531 534
532/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 535/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
533static const yytype_uint16 yyrline[] = 536static const yytype_uint16 yyrline[] =
534{ 537{
535 0, 107, 107, 107, 109, 109, 111, 113, 114, 115, 538 0, 108, 108, 108, 110, 110, 112, 114, 115, 116,
536 116, 117, 118, 122, 126, 126, 126, 126, 126, 126, 539 117, 118, 119, 123, 127, 127, 127, 127, 127, 127,
537 126, 130, 131, 132, 133, 134, 135, 139, 140, 146, 540 127, 127, 131, 132, 133, 134, 135, 136, 140, 141,
538 154, 160, 168, 178, 180, 181, 182, 183, 184, 185, 541 147, 155, 161, 169, 179, 181, 182, 183, 184, 185,
539 188, 196, 202, 212, 218, 224, 227, 229, 240, 241, 542 186, 189, 197, 203, 213, 219, 225, 228, 230, 241,
540 246, 255, 260, 268, 271, 273, 274, 275, 276, 277, 543 242, 247, 256, 261, 269, 272, 274, 275, 276, 277,
541 280, 286, 297, 303, 313, 315, 320, 328, 336, 339, 544 278, 281, 287, 298, 304, 314, 316, 321, 329, 337,
542 341, 342, 343, 348, 355, 362, 367, 375, 378, 380, 545 340, 342, 343, 344, 349, 356, 363, 368, 376, 379,
543 381, 382, 385, 393, 400, 407, 413, 420, 422, 423, 546 381, 382, 383, 386, 394, 401, 408, 414, 421, 423,
544 424, 427, 435, 437, 442, 443, 446, 447, 448, 452, 547 424, 425, 428, 436, 438, 439, 442, 449, 451, 456,
545 453, 456, 457, 460, 461, 462, 463, 464, 465, 466, 548 457, 460, 461, 462, 466, 467, 470, 471, 474, 475,
546 469, 470, 473, 474 549 476, 477, 478, 479, 480, 483, 484, 487, 488
547}; 550};
548#endif 551#endif
549 552
@@ -556,7 +559,7 @@ static const char *const yytname[] =
556 "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", 559 "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
557 "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", 560 "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
558 "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE", 561 "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE",
559 "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", 562 "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL",
560 "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL", 563 "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL",
561 "T_NOT", "$accept", "input", "start", "stmt_list", "option_name", 564 "T_NOT", "$accept", "input", "start", "stmt_list", "option_name",
562 "common_stmt", "option_error", "config_entry_start", "config_stmt", 565 "common_stmt", "option_error", "config_entry_start", "config_stmt",
@@ -567,8 +570,8 @@ static const char *const yytname[] =
567 "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu", 570 "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu",
568 "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt", 571 "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt",
569 "comment", "comment_stmt", "help_start", "help", "depends_list", 572 "comment", "comment_stmt", "help_start", "help", "depends_list",
570 "depends", "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr", 573 "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt",
571 "symbol", "word_opt", 0 574 "end", "nl", "if_expr", "expr", "symbol", "word_opt", 0
572}; 575};
573#endif 576#endif
574 577
@@ -580,25 +583,25 @@ static const yytype_uint16 yytoknum[] =
580 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 583 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
581 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 584 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
582 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 585 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
583 285, 286, 287, 288, 289 586 285, 286, 287, 288, 289, 290
584}; 587};
585# endif 588# endif
586 589
587/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 590/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
588static const yytype_uint8 yyr1[] = 591static const yytype_uint8 yyr1[] =
589{ 592{
590 0, 35, 36, 36, 37, 37, 38, 38, 38, 38, 593 0, 36, 37, 37, 38, 38, 39, 39, 39, 39,
591 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 594 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
592 39, 40, 40, 40, 40, 40, 40, 41, 41, 42, 595 40, 40, 41, 41, 41, 41, 41, 41, 42, 42,
593 43, 44, 45, 46, 46, 46, 46, 46, 46, 46, 596 43, 44, 45, 46, 47, 47, 47, 47, 47, 47,
594 47, 47, 47, 47, 47, 48, 49, 49, 50, 50, 597 47, 48, 48, 48, 48, 48, 49, 50, 50, 51,
595 51, 52, 53, 54, 55, 55, 55, 55, 55, 55, 598 51, 52, 53, 54, 55, 56, 56, 56, 56, 56,
596 56, 56, 56, 56, 57, 57, 58, 59, 60, 61, 599 56, 57, 57, 57, 57, 58, 58, 59, 60, 61,
597 61, 61, 61, 62, 63, 64, 65, 66, 67, 67, 600 62, 62, 62, 62, 63, 64, 65, 66, 67, 68,
598 67, 67, 68, 69, 70, 71, 72, 73, 73, 73, 601 68, 68, 68, 69, 70, 71, 72, 73, 74, 74,
599 73, 74, 75, 75, 76, 76, 77, 77, 77, 78, 602 74, 74, 75, 76, 76, 76, 77, 78, 78, 79,
600 78, 79, 79, 80, 80, 80, 80, 80, 80, 80, 603 79, 80, 80, 80, 81, 81, 82, 82, 83, 83,
601 81, 81, 82, 82 604 83, 83, 83, 83, 83, 84, 84, 85, 85
602}; 605};
603 606
604/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 607/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
@@ -606,16 +609,16 @@ static const yytype_uint8 yyr2[] =
606{ 609{
607 0, 2, 2, 1, 2, 1, 0, 2, 2, 2, 610 0, 2, 2, 1, 2, 1, 0, 2, 2, 2,
608 2, 4, 4, 3, 1, 1, 1, 1, 1, 1, 611 2, 4, 4, 3, 1, 1, 1, 1, 1, 1,
609 1, 1, 1, 1, 1, 1, 1, 3, 2, 3, 612 1, 1, 1, 1, 1, 1, 1, 1, 3, 2,
610 2, 3, 2, 0, 2, 2, 2, 2, 2, 2, 613 3, 2, 3, 2, 0, 2, 2, 2, 2, 2,
611 3, 4, 4, 4, 5, 3, 0, 3, 0, 2, 614 2, 3, 4, 4, 4, 5, 3, 0, 3, 0,
612 3, 2, 1, 3, 0, 2, 2, 2, 2, 2, 615 2, 3, 2, 1, 3, 0, 2, 2, 2, 2,
613 4, 3, 2, 4, 0, 2, 3, 1, 3, 0, 616 2, 4, 3, 2, 4, 0, 2, 3, 1, 3,
614 2, 2, 2, 3, 3, 2, 1, 3, 0, 2, 617 0, 2, 2, 2, 3, 3, 3, 1, 3, 0,
615 2, 2, 3, 3, 2, 2, 2, 0, 2, 2, 618 2, 2, 2, 3, 3, 2, 2, 2, 0, 2,
616 2, 4, 0, 2, 1, 1, 2, 2, 2, 1, 619 2, 2, 4, 0, 2, 2, 2, 0, 2, 1,
617 2, 0, 2, 1, 3, 3, 3, 2, 3, 3, 620 1, 2, 2, 2, 1, 2, 0, 2, 1, 3,
618 1, 1, 0, 1 621 3, 3, 2, 3, 3, 1, 1, 0, 1
619}; 622};
620 623
621/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 624/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -623,165 +626,172 @@ static const yytype_uint8 yyr2[] =
623 means the default is an error. */ 626 means the default is an error. */
624static const yytype_uint8 yydefact[] = 627static const yytype_uint8 yydefact[] =
625{ 628{
626 6, 0, 99, 0, 3, 0, 6, 6, 94, 95, 629 6, 0, 104, 0, 3, 0, 6, 6, 99, 100,
627 0, 1, 0, 0, 0, 0, 112, 0, 0, 0, 630 0, 1, 0, 0, 0, 0, 117, 0, 0, 0,
628 0, 0, 0, 14, 18, 15, 16, 20, 17, 19, 631 0, 0, 0, 14, 18, 15, 16, 20, 17, 19,
629 0, 21, 0, 7, 33, 24, 33, 25, 54, 64, 632 21, 0, 22, 0, 7, 34, 25, 34, 26, 55,
630 8, 69, 22, 87, 78, 9, 26, 87, 23, 10, 633 65, 8, 70, 23, 93, 79, 9, 27, 88, 24,
631 0, 100, 2, 73, 13, 0, 96, 0, 113, 0, 634 10, 0, 105, 2, 74, 13, 0, 101, 0, 118,
632 97, 0, 0, 0, 110, 111, 0, 0, 0, 103, 635 0, 102, 0, 0, 0, 115, 116, 0, 0, 0,
633 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 636 108, 103, 0, 0, 0, 0, 0, 0, 0, 88,
634 0, 74, 82, 50, 83, 29, 31, 0, 107, 0, 637 0, 0, 75, 83, 51, 84, 30, 32, 0, 112,
635 0, 66, 0, 0, 11, 12, 0, 0, 0, 0, 638 0, 0, 67, 0, 0, 11, 12, 0, 0, 0,
636 92, 0, 0, 0, 46, 0, 39, 38, 34, 35, 639 0, 97, 0, 0, 0, 47, 0, 40, 39, 35,
637 0, 37, 36, 0, 0, 92, 0, 58, 59, 55, 640 36, 0, 38, 37, 0, 0, 97, 0, 59, 60,
638 57, 56, 65, 53, 52, 70, 72, 68, 71, 67, 641 56, 58, 57, 66, 54, 53, 71, 73, 69, 72,
639 89, 90, 88, 79, 81, 77, 80, 76, 106, 108, 642 68, 106, 95, 0, 94, 80, 82, 78, 81, 77,
640 109, 105, 104, 28, 85, 0, 101, 0, 101, 101, 643 90, 91, 89, 111, 113, 114, 110, 109, 29, 86,
641 101, 0, 0, 0, 86, 62, 101, 0, 101, 0, 644 0, 106, 0, 106, 106, 106, 0, 0, 0, 87,
642 0, 0, 40, 93, 0, 0, 101, 48, 45, 27, 645 63, 106, 0, 106, 0, 96, 0, 0, 41, 98,
643 0, 61, 0, 91, 102, 41, 42, 43, 0, 0, 646 0, 0, 106, 49, 46, 28, 0, 62, 0, 107,
644 47, 60, 63, 44, 49 647 92, 42, 43, 44, 0, 0, 48, 61, 64, 45,
648 50
645}; 649};
646 650
647/* YYDEFGOTO[NTERM-NUM]. */ 651/* YYDEFGOTO[NTERM-NUM]. */
648static const yytype_int16 yydefgoto[] = 652static const yytype_int16 yydefgoto[] =
649{ 653{
650 -1, 3, 4, 5, 32, 33, 107, 34, 35, 36, 654 -1, 3, 4, 5, 33, 34, 108, 35, 36, 37,
651 37, 73, 108, 109, 152, 180, 38, 39, 123, 40, 655 38, 74, 109, 110, 157, 186, 39, 40, 124, 41,
652 75, 119, 76, 41, 127, 42, 77, 6, 43, 44, 656 76, 120, 77, 42, 128, 43, 78, 6, 44, 45,
653 135, 45, 79, 46, 47, 48, 110, 111, 78, 112, 657 137, 46, 80, 47, 48, 49, 111, 112, 81, 113,
654 147, 148, 49, 7, 161, 68, 69, 59 658 79, 134, 152, 153, 50, 7, 165, 69, 70, 60
655}; 659};
656 660
657/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 661/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
658 STATE-NUM. */ 662 STATE-NUM. */
659#define YYPACT_NINF -89 663#define YYPACT_NINF -90
660static const yytype_int16 yypact[] = 664static const yytype_int16 yypact[] =
661{ 665{
662 3, 4, -89, 20, -89, 100, -89, 7, -89, -89, 666 4, 42, -90, 96, -90, 111, -90, 15, -90, -90,
663 -8, -89, 17, 4, 28, 4, 37, 36, 4, 68, 667 75, -90, 82, 42, 104, 42, 110, 107, 42, 115,
664 87, -18, 69, -89, -89, -89, -89, -89, -89, -89, 668 125, -4, 121, -90, -90, -90, -90, -90, -90, -90,
665 128, -89, 138, -89, -89, -89, -89, -89, -89, -89, 669 -90, 162, -90, 163, -90, -90, -90, -90, -90, -90,
666 -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, 670 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
667 127, -89, -89, 110, -89, 126, -89, 136, -89, 137, 671 -90, 139, -90, -90, 138, -90, 142, -90, 143, -90,
668 -89, 147, 150, 152, -89, -89, -18, -18, 171, -14, 672 152, -90, 164, 167, 168, -90, -90, -4, -4, 77,
669 -89, 153, 157, 34, 67, 180, 233, 220, 207, 220, 673 -18, -90, 177, 185, 33, 71, 195, 247, 236, -2,
670 154, -89, -89, -89, -89, -89, -89, 0, -89, -18, 674 236, 171, -90, -90, -90, -90, -90, -90, 41, -90,
671 -18, 110, 44, 44, -89, -89, 163, 174, 182, 4, 675 -4, -4, 138, 97, 97, -90, -90, 186, 187, 194,
672 4, -18, 194, 44, -89, 219, -89, -89, -89, -89, 676 42, 42, -4, 196, 97, -90, 219, -90, -90, -90,
673 223, -89, -89, 203, 4, 4, 215, -89, -89, -89, 677 -90, 210, -90, -90, 204, 42, 42, 199, -90, -90,
674 -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, 678 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
675 -89, -89, -89, -89, -89, -89, -89, -89, -89, 213, 679 -90, 222, -90, 223, -90, -90, -90, -90, -90, -90,
676 -89, -89, -89, -89, -89, -18, 232, 227, 232, -5, 680 -90, -90, -90, -90, 215, -90, -90, -90, -90, -90,
677 232, 44, 35, 234, -89, -89, 232, 235, 232, 224, 681 -4, 222, 228, 222, -5, 222, 97, 35, 229, -90,
678 -18, 236, -89, -89, 237, 238, 232, 216, -89, -89, 682 -90, 222, 232, 222, -4, -90, 135, 233, -90, -90,
679 240, -89, 241, -89, 71, -89, -89, -89, 242, 4, 683 234, 235, 222, 240, -90, -90, 237, -90, 239, -13,
680 -89, -89, -89, -89, -89 684 -90, -90, -90, -90, 244, 42, -90, -90, -90, -90,
685 -90
681}; 686};
682 687
683/* YYPGOTO[NTERM-NUM]. */ 688/* YYPGOTO[NTERM-NUM]. */
684static const yytype_int16 yypgoto[] = 689static const yytype_int16 yypgoto[] =
685{ 690{
686 -89, -89, 255, 267, -89, 47, -57, -89, -89, -89, 691 -90, -90, 269, 271, -90, 23, -70, -90, -90, -90,
687 -89, 239, -89, -89, -89, -89, -89, -89, -89, 130, 692 -90, 243, -90, -90, -90, -90, -90, -90, -90, -48,
688 -89, -89, -89, -89, -89, -89, -89, -89, -89, -89, 693 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
689 -89, 181, -89, -89, -89, -89, -89, 199, 229, 16, 694 -90, -20, -90, -90, -90, -90, -90, 206, 205, -68,
690 162, -1, 74, -7, 103, -65, -88, -89 695 -90, -90, 169, -1, 27, -7, 118, -66, -89, -90
691}; 696};
692 697
693/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 698/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
694 positive, shift that token. If negative, reduce the rule which 699 positive, shift that token. If negative, reduce the rule which
695 number is the opposite. If zero, do what YYDEFACT says. 700 number is the opposite. If zero, do what YYDEFACT says.
696 If YYTABLE_NINF, syntax error. */ 701 If YYTABLE_NINF, syntax error. */
697#define YYTABLE_NINF -85 702#define YYTABLE_NINF -86
698static const yytype_int16 yytable[] = 703static const yytype_int16 yytable[] =
699{ 704{
700 10, 87, 88, 53, 141, 142, 1, 64, 65, 160, 705 10, 88, 89, 54, 146, 147, 119, 1, 122, 164,
701 1, 66, 55, 92, 57, 151, 67, 61, 118, 93, 706 93, 141, 56, 142, 58, 156, 94, 62, 1, 90,
702 11, 131, 2, 131, 139, 140, 89, 90, 138, 8, 707 91, 131, 65, 66, 144, 145, 67, 90, 91, 132,
703 9, 89, 90, 2, -30, 96, 149, 51, -30, -30, 708 127, 68, 136, -31, 97, 2, 154, -31, -31, -31,
704 -30, -30, -30, -30, -30, -30, 97, 54, -30, -30, 709 -31, -31, -31, -31, -31, 98, 52, -31, -31, 99,
705 98, -30, 99, 100, 101, 102, 103, 104, 56, 105, 710 -31, 100, 101, 102, 103, 104, -31, 105, 129, 106,
706 167, 91, 58, 166, 106, 168, 60, -32, 96, 64, 711 138, 173, 92, 141, 107, 142, 174, 172, 8, 9,
707 65, -32, -32, -32, -32, -32, -32, -32, -32, 97, 712 143, -33, 97, 90, 91, -33, -33, -33, -33, -33,
708 159, -32, -32, 98, -32, 99, 100, 101, 102, 103, 713 -33, -33, -33, 98, 166, -33, -33, 99, -33, 100,
709 104, 121, 105, 62, 132, 174, 132, 106, 146, 70, 714 101, 102, 103, 104, -33, 105, 11, 106, 179, 151,
710 -5, 12, 89, 90, 13, 14, 15, 16, 17, 18, 715 123, 126, 107, 135, 125, 130, 2, 139, 2, 90,
711 19, 20, 63, 156, 21, 22, 23, 24, 25, 26, 716 91, -5, 12, 55, 161, 13, 14, 15, 16, 17,
712 27, 28, 29, 122, 125, 30, 133, -4, 12, 71, 717 18, 19, 20, 65, 66, 21, 22, 23, 24, 25,
713 31, 13, 14, 15, 16, 17, 18, 19, 20, 72, 718 26, 27, 28, 29, 30, 57, 59, 31, 61, -4,
714 51, 21, 22, 23, 24, 25, 26, 27, 28, 29, 719 12, 63, 32, 13, 14, 15, 16, 17, 18, 19,
715 124, 129, 30, 137, -84, 96, 81, 31, -84, -84, 720 20, 64, 71, 21, 22, 23, 24, 25, 26, 27,
716 -84, -84, -84, -84, -84, -84, 82, 83, -84, -84, 721 28, 29, 30, 72, 73, 31, 180, 90, 91, 52,
717 98, -84, -84, -84, -84, -84, -84, 84, 184, 105, 722 32, -85, 97, 82, 83, -85, -85, -85, -85, -85,
718 85, 96, 86, 94, 130, -51, -51, 95, -51, -51, 723 -85, -85, -85, 84, 190, -85, -85, 99, -85, -85,
719 -51, -51, 97, 143, -51, -51, 98, 113, 114, 115, 724 -85, -85, -85, -85, -85, 85, 97, 106, 86, 87,
720 116, 2, 89, 90, 144, 105, 145, 126, 96, 134, 725 -52, -52, 140, -52, -52, -52, -52, 98, 95, -52,
721 117, -75, -75, -75, -75, -75, -75, -75, -75, 150, 726 -52, 99, 114, 115, 116, 117, 96, 148, 149, 150,
722 153, -75, -75, 98, 13, 14, 15, 16, 17, 18, 727 158, 106, 155, 159, 97, 163, 118, -76, -76, -76,
723 19, 20, 105, 155, 21, 22, 154, 130, 14, 15, 728 -76, -76, -76, -76, -76, 160, 164, -76, -76, 99,
724 158, 17, 18, 19, 20, 90, 160, 21, 22, 179, 729 13, 14, 15, 16, 17, 18, 19, 20, 91, 106,
725 31, 163, 164, 165, 173, 89, 90, 162, 128, 170, 730 21, 22, 14, 15, 140, 17, 18, 19, 20, 168,
726 136, 172, 52, 31, 169, 171, 175, 176, 177, 178, 731 175, 21, 22, 177, 181, 182, 183, 32, 187, 167,
727 181, 182, 183, 50, 120, 74, 80, 157 732 188, 169, 170, 171, 185, 189, 53, 51, 32, 176,
733 75, 178, 121, 0, 133, 162, 0, 0, 0, 0,
734 184
728}; 735};
729 736
730static const yytype_uint8 yycheck[] = 737static const yytype_int16 yycheck[] =
731{ 738{
732 1, 66, 67, 10, 92, 93, 3, 25, 26, 14, 739 1, 67, 68, 10, 93, 94, 76, 3, 76, 14,
733 3, 29, 13, 27, 15, 103, 34, 18, 75, 33, 740 28, 81, 13, 81, 15, 104, 34, 18, 3, 32,
734 0, 78, 30, 80, 89, 90, 31, 32, 28, 25, 741 33, 23, 26, 27, 90, 91, 30, 32, 33, 31,
735 26, 31, 32, 30, 0, 1, 101, 30, 4, 5, 742 78, 35, 80, 0, 1, 31, 102, 4, 5, 6,
736 6, 7, 8, 9, 10, 11, 12, 30, 14, 15, 743 7, 8, 9, 10, 11, 12, 31, 14, 15, 16,
737 16, 17, 18, 19, 20, 21, 22, 23, 30, 25, 744 17, 18, 19, 20, 21, 22, 23, 24, 78, 26,
738 25, 68, 25, 151, 30, 30, 30, 0, 1, 25, 745 80, 26, 69, 133, 31, 133, 31, 156, 26, 27,
739 26, 4, 5, 6, 7, 8, 9, 10, 11, 12, 746 29, 0, 1, 32, 33, 4, 5, 6, 7, 8,
740 145, 14, 15, 16, 17, 18, 19, 20, 21, 22, 747 9, 10, 11, 12, 150, 14, 15, 16, 17, 18,
741 23, 75, 25, 25, 78, 160, 80, 30, 99, 30, 748 19, 20, 21, 22, 23, 24, 0, 26, 164, 100,
742 0, 1, 31, 32, 4, 5, 6, 7, 8, 9, 749 77, 78, 31, 80, 77, 78, 31, 80, 31, 32,
743 10, 11, 25, 114, 14, 15, 16, 17, 18, 19, 750 33, 0, 1, 31, 115, 4, 5, 6, 7, 8,
744 20, 21, 22, 76, 77, 25, 79, 0, 1, 1, 751 9, 10, 11, 26, 27, 14, 15, 16, 17, 18,
745 30, 4, 5, 6, 7, 8, 9, 10, 11, 1, 752 19, 20, 21, 22, 23, 31, 26, 26, 31, 0,
746 30, 14, 15, 16, 17, 18, 19, 20, 21, 22, 753 1, 26, 31, 4, 5, 6, 7, 8, 9, 10,
747 76, 77, 25, 79, 0, 1, 30, 30, 4, 5, 754 11, 26, 31, 14, 15, 16, 17, 18, 19, 20,
748 6, 7, 8, 9, 10, 11, 30, 30, 14, 15, 755 21, 22, 23, 1, 1, 26, 31, 32, 33, 31,
749 16, 17, 18, 19, 20, 21, 22, 30, 179, 25, 756 31, 0, 1, 31, 31, 4, 5, 6, 7, 8,
750 30, 1, 30, 30, 30, 5, 6, 30, 8, 9, 757 9, 10, 11, 31, 185, 14, 15, 16, 17, 18,
751 10, 11, 12, 30, 14, 15, 16, 17, 18, 19, 758 19, 20, 21, 22, 23, 31, 1, 26, 31, 31,
752 20, 30, 31, 32, 30, 25, 24, 77, 1, 79, 759 5, 6, 31, 8, 9, 10, 11, 12, 31, 14,
753 30, 4, 5, 6, 7, 8, 9, 10, 11, 25, 760 15, 16, 17, 18, 19, 20, 31, 31, 31, 25,
754 1, 14, 15, 16, 4, 5, 6, 7, 8, 9, 761 1, 26, 26, 13, 1, 26, 31, 4, 5, 6,
755 10, 11, 25, 30, 14, 15, 13, 30, 5, 6, 762 7, 8, 9, 10, 11, 31, 14, 14, 15, 16,
756 25, 8, 9, 10, 11, 32, 14, 14, 15, 33, 763 4, 5, 6, 7, 8, 9, 10, 11, 33, 26,
757 30, 148, 149, 150, 30, 31, 32, 30, 77, 156, 764 14, 15, 5, 6, 31, 8, 9, 10, 11, 31,
758 79, 158, 7, 30, 30, 30, 30, 30, 30, 166, 765 31, 14, 15, 31, 31, 31, 31, 31, 31, 151,
759 30, 30, 30, 6, 75, 36, 47, 115 766 31, 153, 154, 155, 34, 31, 7, 6, 31, 161,
767 37, 163, 76, -1, 79, 116, -1, -1, -1, -1,
768 172
760}; 769};
761 770
762/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 771/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
763 symbol of state STATE-NUM. */ 772 symbol of state STATE-NUM. */
764static const yytype_uint8 yystos[] = 773static const yytype_uint8 yystos[] =
765{ 774{
766 0, 3, 30, 36, 37, 38, 62, 78, 25, 26, 775 0, 3, 31, 37, 38, 39, 63, 81, 26, 27,
767 76, 0, 1, 4, 5, 6, 7, 8, 9, 10, 776 79, 0, 1, 4, 5, 6, 7, 8, 9, 10,
768 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 777 11, 14, 15, 16, 17, 18, 19, 20, 21, 22,
769 25, 30, 39, 40, 42, 43, 44, 45, 51, 52, 778 23, 26, 31, 40, 41, 43, 44, 45, 46, 52,
770 54, 58, 60, 63, 64, 66, 68, 69, 70, 77, 779 53, 55, 59, 61, 64, 65, 67, 69, 70, 71,
771 38, 30, 37, 78, 30, 76, 30, 76, 25, 82, 780 80, 39, 31, 38, 81, 31, 79, 31, 79, 26,
772 30, 76, 25, 25, 25, 26, 29, 34, 80, 81, 781 85, 31, 79, 26, 26, 26, 27, 30, 35, 83,
773 30, 1, 1, 46, 46, 55, 57, 61, 73, 67, 782 84, 31, 1, 1, 47, 47, 56, 58, 62, 76,
774 73, 30, 30, 30, 30, 30, 30, 80, 80, 31, 783 68, 74, 31, 31, 31, 31, 31, 31, 83, 83,
775 32, 78, 27, 33, 30, 30, 1, 12, 16, 18, 784 32, 33, 81, 28, 34, 31, 31, 1, 12, 16,
776 19, 20, 21, 22, 23, 25, 30, 41, 47, 48, 785 18, 19, 20, 21, 22, 24, 26, 31, 42, 48,
777 71, 72, 74, 17, 18, 19, 20, 30, 41, 56, 786 49, 72, 73, 75, 17, 18, 19, 20, 31, 42,
778 72, 74, 40, 53, 77, 40, 54, 59, 66, 77, 787 57, 73, 75, 41, 54, 80, 41, 55, 60, 67,
779 30, 41, 74, 40, 54, 65, 66, 77, 28, 80, 788 80, 23, 31, 74, 77, 41, 55, 66, 67, 80,
780 80, 81, 81, 30, 30, 24, 76, 75, 76, 80, 789 31, 42, 75, 29, 83, 83, 84, 84, 31, 31,
781 25, 81, 49, 1, 13, 30, 76, 75, 25, 80, 790 25, 79, 78, 79, 83, 26, 84, 50, 1, 13,
782 14, 79, 30, 79, 79, 79, 81, 25, 30, 30, 791 31, 79, 78, 26, 14, 82, 83, 82, 31, 82,
783 79, 30, 79, 30, 80, 30, 30, 30, 79, 33, 792 82, 82, 84, 26, 31, 31, 82, 31, 82, 83,
784 50, 30, 30, 30, 76 793 31, 31, 31, 31, 82, 34, 51, 31, 31, 31,
794 79
785}; 795};
786 796
787#define yyerrok (yyerrstatus = 0) 797#define yyerrok (yyerrstatus = 0)
@@ -1292,7 +1302,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1292 1302
1293 switch (yytype) 1303 switch (yytype)
1294 { 1304 {
1295 case 52: /* "choice_entry" */ 1305 case 53: /* "choice_entry" */
1296 1306
1297 { 1307 {
1298 fprintf(stderr, "%s:%d: missing end statement for this entry\n", 1308 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1302,7 +1312,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1302}; 1312};
1303 1313
1304 break; 1314 break;
1305 case 58: /* "if_entry" */ 1315 case 59: /* "if_entry" */
1306 1316
1307 { 1317 {
1308 fprintf(stderr, "%s:%d: missing end statement for this entry\n", 1318 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1312,7 +1322,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1312}; 1322};
1313 1323
1314 break; 1324 break;
1315 case 64: /* "menu_entry" */ 1325 case 65: /* "menu_entry" */
1316 1326
1317 { 1327 {
1318 fprintf(stderr, "%s:%d: missing end statement for this entry\n", 1328 fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1644,17 +1654,17 @@ yyreduce:
1644 { zconf_error("invalid statement"); ;} 1654 { zconf_error("invalid statement"); ;}
1645 break; 1655 break;
1646 1656
1647 case 27: 1657 case 28:
1648 1658
1649 { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;} 1659 { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;}
1650 break; 1660 break;
1651 1661
1652 case 28: 1662 case 29:
1653 1663
1654 { zconf_error("invalid option"); ;} 1664 { zconf_error("invalid option"); ;}
1655 break; 1665 break;
1656 1666
1657 case 29: 1667 case 30:
1658 1668
1659 { 1669 {
1660 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); 1670 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
@@ -1664,7 +1674,7 @@ yyreduce:
1664;} 1674;}
1665 break; 1675 break;
1666 1676
1667 case 30: 1677 case 31:
1668 1678
1669 { 1679 {
1670 menu_end_entry(); 1680 menu_end_entry();
@@ -1672,7 +1682,7 @@ yyreduce:
1672;} 1682;}
1673 break; 1683 break;
1674 1684
1675 case 31: 1685 case 32:
1676 1686
1677 { 1687 {
1678 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); 1688 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
@@ -1682,7 +1692,7 @@ yyreduce:
1682;} 1692;}
1683 break; 1693 break;
1684 1694
1685 case 32: 1695 case 33:
1686 1696
1687 { 1697 {
1688 if (current_entry->prompt) 1698 if (current_entry->prompt)
@@ -1694,7 +1704,7 @@ yyreduce:
1694;} 1704;}
1695 break; 1705 break;
1696 1706
1697 case 40: 1707 case 41:
1698 1708
1699 { 1709 {
1700 menu_set_type((yyvsp[(1) - (3)].id)->stype); 1710 menu_set_type((yyvsp[(1) - (3)].id)->stype);
@@ -1704,7 +1714,7 @@ yyreduce:
1704;} 1714;}
1705 break; 1715 break;
1706 1716
1707 case 41: 1717 case 42:
1708 1718
1709 { 1719 {
1710 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); 1720 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
@@ -1712,7 +1722,7 @@ yyreduce:
1712;} 1722;}
1713 break; 1723 break;
1714 1724
1715 case 42: 1725 case 43:
1716 1726
1717 { 1727 {
1718 menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr)); 1728 menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr));
@@ -1724,7 +1734,7 @@ yyreduce:
1724;} 1734;}
1725 break; 1735 break;
1726 1736
1727 case 43: 1737 case 44:
1728 1738
1729 { 1739 {
1730 menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr)); 1740 menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr));
@@ -1732,7 +1742,7 @@ yyreduce:
1732;} 1742;}
1733 break; 1743 break;
1734 1744
1735 case 44: 1745 case 45:
1736 1746
1737 { 1747 {
1738 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr)); 1748 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr));
@@ -1740,7 +1750,7 @@ yyreduce:
1740;} 1750;}
1741 break; 1751 break;
1742 1752
1743 case 47: 1753 case 48:
1744 1754
1745 { 1755 {
1746 struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string))); 1756 struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string)));
@@ -1752,17 +1762,17 @@ yyreduce:
1752;} 1762;}
1753 break; 1763 break;
1754 1764
1755 case 48: 1765 case 49:
1756 1766
1757 { (yyval.string) = NULL; ;} 1767 { (yyval.string) = NULL; ;}
1758 break; 1768 break;
1759 1769
1760 case 49: 1770 case 50:
1761 1771
1762 { (yyval.string) = (yyvsp[(2) - (2)].string); ;} 1772 { (yyval.string) = (yyvsp[(2) - (2)].string); ;}
1763 break; 1773 break;
1764 1774
1765 case 50: 1775 case 51:
1766 1776
1767 { 1777 {
1768 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE); 1778 struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE);
@@ -1773,14 +1783,14 @@ yyreduce:
1773;} 1783;}
1774 break; 1784 break;
1775 1785
1776 case 51: 1786 case 52:
1777 1787
1778 { 1788 {
1779 (yyval.menu) = menu_add_menu(); 1789 (yyval.menu) = menu_add_menu();
1780;} 1790;}
1781 break; 1791 break;
1782 1792
1783 case 52: 1793 case 53:
1784 1794
1785 { 1795 {
1786 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) { 1796 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) {
@@ -1790,7 +1800,7 @@ yyreduce:
1790;} 1800;}
1791 break; 1801 break;
1792 1802
1793 case 60: 1803 case 61:
1794 1804
1795 { 1805 {
1796 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); 1806 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
@@ -1798,7 +1808,7 @@ yyreduce:
1798;} 1808;}
1799 break; 1809 break;
1800 1810
1801 case 61: 1811 case 62:
1802 1812
1803 { 1813 {
1804 if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) { 1814 if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) {
@@ -1811,7 +1821,7 @@ yyreduce:
1811;} 1821;}
1812 break; 1822 break;
1813 1823
1814 case 62: 1824 case 63:
1815 1825
1816 { 1826 {
1817 current_entry->sym->flags |= SYMBOL_OPTIONAL; 1827 current_entry->sym->flags |= SYMBOL_OPTIONAL;
@@ -1819,7 +1829,7 @@ yyreduce:
1819;} 1829;}
1820 break; 1830 break;
1821 1831
1822 case 63: 1832 case 64:
1823 1833
1824 { 1834 {
1825 if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) { 1835 if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) {
@@ -1831,7 +1841,7 @@ yyreduce:
1831;} 1841;}
1832 break; 1842 break;
1833 1843
1834 case 66: 1844 case 67:
1835 1845
1836 { 1846 {
1837 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); 1847 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
@@ -1841,7 +1851,7 @@ yyreduce:
1841;} 1851;}
1842 break; 1852 break;
1843 1853
1844 case 67: 1854 case 68:
1845 1855
1846 { 1856 {
1847 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) { 1857 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) {
@@ -1851,14 +1861,14 @@ yyreduce:
1851;} 1861;}
1852 break; 1862 break;
1853 1863
1854 case 73: 1864 case 74:
1855 1865
1856 { 1866 {
1857 menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL); 1867 menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL);
1858;} 1868;}
1859 break; 1869 break;
1860 1870
1861 case 74: 1871 case 75:
1862 1872
1863 { 1873 {
1864 menu_add_entry(NULL); 1874 menu_add_entry(NULL);
@@ -1867,14 +1877,14 @@ yyreduce:
1867;} 1877;}
1868 break; 1878 break;
1869 1879
1870 case 75: 1880 case 76:
1871 1881
1872 { 1882 {
1873 (yyval.menu) = menu_add_menu(); 1883 (yyval.menu) = menu_add_menu();
1874;} 1884;}
1875 break; 1885 break;
1876 1886
1877 case 76: 1887 case 77:
1878 1888
1879 { 1889 {
1880 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) { 1890 if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) {
@@ -1884,7 +1894,7 @@ yyreduce:
1884;} 1894;}
1885 break; 1895 break;
1886 1896
1887 case 82: 1897 case 83:
1888 1898
1889 { 1899 {
1890 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); 1900 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
@@ -1892,7 +1902,7 @@ yyreduce:
1892;} 1902;}
1893 break; 1903 break;
1894 1904
1895 case 83: 1905 case 84:
1896 1906
1897 { 1907 {
1898 menu_add_entry(NULL); 1908 menu_add_entry(NULL);
@@ -1901,14 +1911,14 @@ yyreduce:
1901;} 1911;}
1902 break; 1912 break;
1903 1913
1904 case 84: 1914 case 85:
1905 1915
1906 { 1916 {
1907 menu_end_entry(); 1917 menu_end_entry();
1908;} 1918;}
1909 break; 1919 break;
1910 1920
1911 case 85: 1921 case 86:
1912 1922
1913 { 1923 {
1914 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); 1924 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
@@ -1916,14 +1926,14 @@ yyreduce:
1916;} 1926;}
1917 break; 1927 break;
1918 1928
1919 case 86: 1929 case 87:
1920 1930
1921 { 1931 {
1922 current_entry->help = (yyvsp[(2) - (2)].string); 1932 current_entry->help = (yyvsp[(2) - (2)].string);
1923;} 1933;}
1924 break; 1934 break;
1925 1935
1926 case 91: 1936 case 92:
1927 1937
1928 { 1938 {
1929 menu_add_dep((yyvsp[(3) - (4)].expr)); 1939 menu_add_dep((yyvsp[(3) - (4)].expr));
@@ -1931,84 +1941,91 @@ yyreduce:
1931;} 1941;}
1932 break; 1942 break;
1933 1943
1934 case 93: 1944 case 96:
1945
1946 {
1947 menu_add_visibility((yyvsp[(2) - (2)].expr));
1948;}
1949 break;
1950
1951 case 98:
1935 1952
1936 { 1953 {
1937 menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr)); 1954 menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr));
1938;} 1955;}
1939 break; 1956 break;
1940 1957
1941 case 96: 1958 case 101:
1942 1959
1943 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1960 { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
1944 break; 1961 break;
1945 1962
1946 case 97: 1963 case 102:
1947 1964
1948 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1965 { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
1949 break; 1966 break;
1950 1967
1951 case 98: 1968 case 103:
1952 1969
1953 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1970 { (yyval.id) = (yyvsp[(1) - (2)].id); ;}
1954 break; 1971 break;
1955 1972
1956 case 101: 1973 case 106:
1957 1974
1958 { (yyval.expr) = NULL; ;} 1975 { (yyval.expr) = NULL; ;}
1959 break; 1976 break;
1960 1977
1961 case 102: 1978 case 107:
1962 1979
1963 { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} 1980 { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
1964 break; 1981 break;
1965 1982
1966 case 103: 1983 case 108:
1967 1984
1968 { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;} 1985 { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;}
1969 break; 1986 break;
1970 1987
1971 case 104: 1988 case 109:
1972 1989
1973 { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} 1990 { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
1974 break; 1991 break;
1975 1992
1976 case 105: 1993 case 110:
1977 1994
1978 { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} 1995 { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
1979 break; 1996 break;
1980 1997
1981 case 106: 1998 case 111:
1982 1999
1983 { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} 2000 { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;}
1984 break; 2001 break;
1985 2002
1986 case 107: 2003 case 112:
1987 2004
1988 { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;} 2005 { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;}
1989 break; 2006 break;
1990 2007
1991 case 108: 2008 case 113:
1992 2009
1993 { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} 2010 { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
1994 break; 2011 break;
1995 2012
1996 case 109: 2013 case 114:
1997 2014
1998 { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} 2015 { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
1999 break; 2016 break;
2000 2017
2001 case 110: 2018 case 115:
2002 2019
2003 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;} 2020 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;}
2004 break; 2021 break;
2005 2022
2006 case 111: 2023 case 116:
2007 2024
2008 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;} 2025 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;}
2009 break; 2026 break;
2010 2027
2011 case 112: 2028 case 117:
2012 2029
2013 { (yyval.string) = NULL; ;} 2030 { (yyval.string) = NULL; ;}
2014 break; 2031 break;
@@ -2278,6 +2295,7 @@ static const char *zconf_tokenname(int token)
2278 case T_IF: return "if"; 2295 case T_IF: return "if";
2279 case T_ENDIF: return "endif"; 2296 case T_ENDIF: return "endif";
2280 case T_DEPENDS: return "depends"; 2297 case T_DEPENDS: return "depends";
2298 case T_VISIBLE: return "visible";
2281 } 2299 }
2282 return "<token>"; 2300 return "<token>";
2283} 2301}
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 2abd3c7ff15d..49fb4ab664c3 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -36,7 +36,7 @@ static struct menu *current_menu, *current_entry;
36#define YYERROR_VERBOSE 36#define YYERROR_VERBOSE
37#endif 37#endif
38%} 38%}
39%expect 28 39%expect 30
40 40
41%union 41%union
42{ 42{
@@ -68,6 +68,7 @@ static struct menu *current_menu, *current_entry;
68%token <id>T_DEFAULT 68%token <id>T_DEFAULT
69%token <id>T_SELECT 69%token <id>T_SELECT
70%token <id>T_RANGE 70%token <id>T_RANGE
71%token <id>T_VISIBLE
71%token <id>T_OPTION 72%token <id>T_OPTION
72%token <id>T_ON 73%token <id>T_ON
73%token <string> T_WORD 74%token <string> T_WORD
@@ -123,7 +124,7 @@ stmt_list:
123; 124;
124 125
125option_name: 126option_name:
126 T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT 127 T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
127; 128;
128 129
129common_stmt: 130common_stmt:
@@ -359,7 +360,7 @@ menu: T_MENU prompt T_EOL
359 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); 360 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
360}; 361};
361 362
362menu_entry: menu depends_list 363menu_entry: menu visibility_list depends_list
363{ 364{
364 $$ = menu_add_menu(); 365 $$ = menu_add_menu();
365}; 366};
@@ -430,6 +431,19 @@ depends: T_DEPENDS T_ON expr T_EOL
430 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); 431 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
431}; 432};
432 433
434/* visibility option */
435
436visibility_list:
437 /* empty */
438 | visibility_list visible
439 | visibility_list T_EOL
440;
441
442visible: T_VISIBLE if_expr
443{
444 menu_add_visibility($2);
445};
446
433/* prompt statement */ 447/* prompt statement */
434 448
435prompt_stmt_opt: 449prompt_stmt_opt:
@@ -526,6 +540,7 @@ static const char *zconf_tokenname(int token)
526 case T_IF: return "if"; 540 case T_IF: return "if";
527 case T_ENDIF: return "endif"; 541 case T_ENDIF: return "endif";
528 case T_DEPENDS: return "depends"; 542 case T_DEPENDS: return "depends";
543 case T_VISIBLE: return "visible";
529 } 544 }
530 return "<token>"; 545 return "<token>";
531} 546}
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index cdb6dc1f6458..39580a5dc5df 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -5,7 +5,7 @@ use strict;
5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## 5## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
6## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## 6## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
7## Copyright (C) 2001 Simon Huggins ## 7## Copyright (C) 2001 Simon Huggins ##
8## Copyright (C) 2005-2009 Randy Dunlap ## 8## Copyright (C) 2005-2010 Randy Dunlap ##
9## ## 9## ##
10## #define enhancements by Armin Kuster <akuster@mvista.com> ## 10## #define enhancements by Armin Kuster <akuster@mvista.com> ##
11## Copyright (c) 2000 MontaVista Software, Inc. ## 11## Copyright (c) 2000 MontaVista Software, Inc. ##
@@ -453,7 +453,7 @@ sub output_highlight {
453 if ($output_mode eq "html" || $output_mode eq "xml") { 453 if ($output_mode eq "html" || $output_mode eq "xml") {
454 $contents = local_unescape($contents); 454 $contents = local_unescape($contents);
455 # convert data read & converted thru xml_escape() into &xyz; format: 455 # convert data read & converted thru xml_escape() into &xyz; format:
456 $contents =~ s/\\\\\\/&/g; 456 $contents =~ s/\\\\\\/\&/g;
457 } 457 }
458# print STDERR "contents b4:$contents\n"; 458# print STDERR "contents b4:$contents\n";
459 eval $dohighlight; 459 eval $dohighlight;
@@ -770,7 +770,11 @@ sub output_struct_xml(%) {
770 print $args{'type'} . " " . $args{'struct'} . " {\n"; 770 print $args{'type'} . " " . $args{'struct'} . " {\n";
771 foreach $parameter (@{$args{'parameterlist'}}) { 771 foreach $parameter (@{$args{'parameterlist'}}) {
772 if ($parameter =~ /^#/) { 772 if ($parameter =~ /^#/) {
773 print "$parameter\n"; 773 my $prm = $parameter;
774 # convert data read & converted thru xml_escape() into &xyz; format:
775 # This allows us to have #define macros interspersed in a struct.
776 $prm =~ s/\\\\\\/\&/g;
777 print "$prm\n";
774 next; 778 next;
775 } 779 }
776 780
@@ -1701,6 +1705,8 @@ sub push_parameter($$$) {
1701 } 1705 }
1702 } 1706 }
1703 1707
1708 $param = xml_escape($param);
1709
1704 # strip spaces from $param so that it is one continous string 1710 # strip spaces from $param so that it is one continous string
1705 # on @parameterlist; 1711 # on @parameterlist;
1706 # this fixes a problem where check_sections() cannot find 1712 # this fixes a problem where check_sections() cannot find
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index 58e933a20544..39667174971d 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -119,7 +119,7 @@ static uint_t (*Elf_r_sym)(Elf_Rel const *rp) = fn_ELF_R_SYM;
119 119
120static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type) 120static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type)
121{ 121{
122 rp->r_info = ELF_R_INFO(sym, type); 122 rp->r_info = _w(ELF_R_INFO(sym, type));
123} 123}
124static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO; 124static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO;
125 125
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 8509bb512935..bbbe584d4494 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -125,7 +125,9 @@ exuberant()
125 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ 125 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
126 --extra=+f --c-kinds=-px \ 126 --extra=+f --c-kinds=-px \
127 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \ 127 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \
128 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' 128 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \
129 --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \
130 --regex-c++='/^DEFINE_EVENT\(([^,)]*).*/trace_\1/'
129 131
130 all_kconfigs | xargs $1 -a \ 132 all_kconfigs | xargs $1 -a \
131 --langdef=kconfig --language-force=kconfig \ 133 --langdef=kconfig --language-force=kconfig \
diff --git a/sound/atmel/abdac.c b/sound/atmel/abdac.c
index f2f41c854221..6e2409181895 100644
--- a/sound/atmel/abdac.c
+++ b/sound/atmel/abdac.c
@@ -420,9 +420,9 @@ static int __devinit atmel_abdac_probe(struct platform_device *pdev)
420 return PTR_ERR(pclk); 420 return PTR_ERR(pclk);
421 } 421 }
422 sample_clk = clk_get(&pdev->dev, "sample_clk"); 422 sample_clk = clk_get(&pdev->dev, "sample_clk");
423 if (IS_ERR(pclk)) { 423 if (IS_ERR(sample_clk)) {
424 dev_dbg(&pdev->dev, "no sample clock\n"); 424 dev_dbg(&pdev->dev, "no sample clock\n");
425 retval = PTR_ERR(pclk); 425 retval = PTR_ERR(sample_clk);
426 goto out_put_pclk; 426 goto out_put_pclk;
427 } 427 }
428 clk_enable(pclk); 428 clk_enable(pclk);
diff --git a/sound/core/info.c b/sound/core/info.c
index b70564ed8b37..7077f601da5a 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -23,7 +23,6 @@
23#include <linux/time.h> 23#include <linux/time.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/smp_lock.h>
27#include <linux/string.h> 26#include <linux/string.h>
28#include <sound/core.h> 27#include <sound/core.h>
29#include <sound/minors.h> 28#include <sound/minors.h>
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 5c8c7dff8ede..b753ec661fcf 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1510,16 +1510,19 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
1510static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file) 1510static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file)
1511{ 1511{
1512 struct snd_pcm_substream *substream; 1512 struct snd_pcm_substream *substream;
1513 struct snd_pcm_runtime *runtime;
1514 int i;
1513 1515
1514 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 1516 for (i = 0; i < 2; i++) {
1515 if (substream != NULL) { 1517 substream = pcm_oss_file->streams[i];
1516 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); 1518 if (!substream)
1517 substream->runtime->oss.prepare = 1; 1519 continue;
1518 } 1520 runtime = substream->runtime;
1519 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
1520 if (substream != NULL) {
1521 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); 1521 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
1522 substream->runtime->oss.prepare = 1; 1522 runtime->oss.prepare = 1;
1523 runtime->oss.buffer_used = 0;
1524 runtime->oss.prev_hw_ptr_period = 0;
1525 runtime->oss.period_ptr = 0;
1523 } 1526 }
1524 return 0; 1527 return 0;
1525} 1528}
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index a1707cca9c66..b75db8e9cc0f 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -223,7 +223,7 @@ static void xrun_log(struct snd_pcm_substream *substream,
223 entry->jiffies = jiffies; 223 entry->jiffies = jiffies;
224 entry->pos = pos; 224 entry->pos = pos;
225 entry->period_size = runtime->period_size; 225 entry->period_size = runtime->period_size;
226 entry->buffer_size = runtime->buffer_size;; 226 entry->buffer_size = runtime->buffer_size;
227 entry->old_hw_ptr = runtime->status->hw_ptr; 227 entry->old_hw_ptr = runtime->status->hw_ptr;
228 entry->hw_ptr_base = runtime->hw_ptr_base; 228 entry->hw_ptr_base = runtime->hw_ptr_base;
229 log->idx = (log->idx + 1) % XRUN_LOG_CNT; 229 log->idx = (log->idx + 1) % XRUN_LOG_CNT;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 8bc7cb3db330..e82c1f97d99e 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -22,7 +22,6 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/file.h> 23#include <linux/file.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/smp_lock.h>
26#include <linux/time.h> 25#include <linux/time.h>
27#include <linux/pm_qos_params.h> 26#include <linux/pm_qos_params.h>
28#include <linux/uio.h> 27#include <linux/uio.h>
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 62a093efb453..66691fe437e6 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -21,7 +21,6 @@
21 21
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>
25#include <linux/time.h> 24#include <linux/time.h>
26#include <linux/device.h> 25#include <linux/device.h>
27#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
diff --git a/sound/oss/dev_table.c b/sound/oss/dev_table.c
index 727bdb9ba2dc..d8cf3e58dc76 100644
--- a/sound/oss/dev_table.c
+++ b/sound/oss/dev_table.c
@@ -71,7 +71,7 @@ int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
71 if (sound_nblocks >= MAX_MEM_BLOCKS) 71 if (sound_nblocks >= MAX_MEM_BLOCKS)
72 sound_nblocks = MAX_MEM_BLOCKS - 1; 72 sound_nblocks = MAX_MEM_BLOCKS - 1;
73 73
74 op = (struct audio_operations *) (sound_mem_blocks[sound_nblocks] = vmalloc(sizeof(struct audio_operations))); 74 op = (struct audio_operations *) (sound_mem_blocks[sound_nblocks] = vzalloc(sizeof(struct audio_operations)));
75 sound_nblocks++; 75 sound_nblocks++;
76 if (sound_nblocks >= MAX_MEM_BLOCKS) 76 if (sound_nblocks >= MAX_MEM_BLOCKS)
77 sound_nblocks = MAX_MEM_BLOCKS - 1; 77 sound_nblocks = MAX_MEM_BLOCKS - 1;
@@ -81,7 +81,6 @@ int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
81 sound_unload_audiodev(num); 81 sound_unload_audiodev(num);
82 return -(ENOMEM); 82 return -(ENOMEM);
83 } 83 }
84 memset((char *) op, 0, sizeof(struct audio_operations));
85 init_waitqueue_head(&op->in_sleeper); 84 init_waitqueue_head(&op->in_sleeper);
86 init_waitqueue_head(&op->out_sleeper); 85 init_waitqueue_head(&op->out_sleeper);
87 init_waitqueue_head(&op->poll_sleeper); 86 init_waitqueue_head(&op->poll_sleeper);
@@ -128,7 +127,7 @@ int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
128 /* FIXME: This leaks a mixer_operations struct every time its called 127 /* FIXME: This leaks a mixer_operations struct every time its called
129 until you unload sound! */ 128 until you unload sound! */
130 129
131 op = (struct mixer_operations *) (sound_mem_blocks[sound_nblocks] = vmalloc(sizeof(struct mixer_operations))); 130 op = (struct mixer_operations *) (sound_mem_blocks[sound_nblocks] = vzalloc(sizeof(struct mixer_operations)));
132 sound_nblocks++; 131 sound_nblocks++;
133 if (sound_nblocks >= MAX_MEM_BLOCKS) 132 if (sound_nblocks >= MAX_MEM_BLOCKS)
134 sound_nblocks = MAX_MEM_BLOCKS - 1; 133 sound_nblocks = MAX_MEM_BLOCKS - 1;
@@ -137,7 +136,6 @@ int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
137 printk(KERN_ERR "Sound: Can't allocate mixer driver for (%s)\n", name); 136 printk(KERN_ERR "Sound: Can't allocate mixer driver for (%s)\n", name);
138 return -ENOMEM; 137 return -ENOMEM;
139 } 138 }
140 memset((char *) op, 0, sizeof(struct mixer_operations));
141 memcpy((char *) op, (char *) driver, driver_size); 139 memcpy((char *) op, (char *) driver, driver_size);
142 140
143 strlcpy(op->name, name, sizeof(op->name)); 141 strlcpy(op->name, name, sizeof(op->name));
diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c
index 782b3b84dac6..ceedb1eff203 100644
--- a/sound/oss/midibuf.c
+++ b/sound/oss/midibuf.c
@@ -178,7 +178,7 @@ int MIDIbuf_open(int dev, struct file *file)
178 return err; 178 return err;
179 179
180 parms[dev].prech_timeout = MAX_SCHEDULE_TIMEOUT; 180 parms[dev].prech_timeout = MAX_SCHEDULE_TIMEOUT;
181 midi_in_buf[dev] = (struct midi_buf *) vmalloc(sizeof(struct midi_buf)); 181 midi_in_buf[dev] = vmalloc(sizeof(struct midi_buf));
182 182
183 if (midi_in_buf[dev] == NULL) 183 if (midi_in_buf[dev] == NULL)
184 { 184 {
@@ -188,7 +188,7 @@ int MIDIbuf_open(int dev, struct file *file)
188 } 188 }
189 midi_in_buf[dev]->len = midi_in_buf[dev]->head = midi_in_buf[dev]->tail = 0; 189 midi_in_buf[dev]->len = midi_in_buf[dev]->head = midi_in_buf[dev]->tail = 0;
190 190
191 midi_out_buf[dev] = (struct midi_buf *) vmalloc(sizeof(struct midi_buf)); 191 midi_out_buf[dev] = vmalloc(sizeof(struct midi_buf));
192 192
193 if (midi_out_buf[dev] == NULL) 193 if (midi_out_buf[dev] == NULL)
194 { 194 {
diff --git a/sound/oss/pss.c b/sound/oss/pss.c
index e19dd5dcc2de..9b800ce5100e 100644
--- a/sound/oss/pss.c
+++ b/sound/oss/pss.c
@@ -859,7 +859,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg,
859 return 0; 859 return 0;
860 860
861 case SNDCTL_COPR_LOAD: 861 case SNDCTL_COPR_LOAD:
862 buf = (copr_buffer *) vmalloc(sizeof(copr_buffer)); 862 buf = vmalloc(sizeof(copr_buffer));
863 if (buf == NULL) 863 if (buf == NULL)
864 return -ENOSPC; 864 return -ENOSPC;
865 if (copy_from_user(buf, arg, sizeof(copr_buffer))) { 865 if (copy_from_user(buf, arg, sizeof(copr_buffer))) {
@@ -871,7 +871,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg,
871 return err; 871 return err;
872 872
873 case SNDCTL_COPR_SENDMSG: 873 case SNDCTL_COPR_SENDMSG:
874 mbuf = (copr_msg *)vmalloc(sizeof(copr_msg)); 874 mbuf = vmalloc(sizeof(copr_msg));
875 if (mbuf == NULL) 875 if (mbuf == NULL)
876 return -ENOSPC; 876 return -ENOSPC;
877 if (copy_from_user(mbuf, arg, sizeof(copr_msg))) { 877 if (copy_from_user(mbuf, arg, sizeof(copr_msg))) {
@@ -895,7 +895,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg,
895 895
896 case SNDCTL_COPR_RCVMSG: 896 case SNDCTL_COPR_RCVMSG:
897 err = 0; 897 err = 0;
898 mbuf = (copr_msg *)vmalloc(sizeof(copr_msg)); 898 mbuf = vmalloc(sizeof(copr_msg));
899 if (mbuf == NULL) 899 if (mbuf == NULL)
900 return -ENOSPC; 900 return -ENOSPC;
901 data = (unsigned short *)mbuf->data; 901 data = (unsigned short *)mbuf->data;
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c
index e85789e53816..5ea1098ac427 100644
--- a/sound/oss/sequencer.c
+++ b/sound/oss/sequencer.c
@@ -1646,13 +1646,13 @@ void sequencer_init(void)
1646{ 1646{
1647 if (sequencer_ok) 1647 if (sequencer_ok)
1648 return; 1648 return;
1649 queue = (unsigned char *)vmalloc(SEQ_MAX_QUEUE * EV_SZ); 1649 queue = vmalloc(SEQ_MAX_QUEUE * EV_SZ);
1650 if (queue == NULL) 1650 if (queue == NULL)
1651 { 1651 {
1652 printk(KERN_ERR "sequencer: Can't allocate memory for sequencer output queue\n"); 1652 printk(KERN_ERR "sequencer: Can't allocate memory for sequencer output queue\n");
1653 return; 1653 return;
1654 } 1654 }
1655 iqueue = (unsigned char *)vmalloc(SEQ_MAX_QUEUE * IEV_SZ); 1655 iqueue = vmalloc(SEQ_MAX_QUEUE * IEV_SZ);
1656 if (iqueue == NULL) 1656 if (iqueue == NULL)
1657 { 1657 {
1658 printk(KERN_ERR "sequencer: Can't allocate memory for sequencer input queue\n"); 1658 printk(KERN_ERR "sequencer: Can't allocate memory for sequencer input queue\n");
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 62895a719fcb..22dbd91811a4 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -435,7 +435,7 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev)
435 struct hpi_message hm; 435 struct hpi_message hm;
436 struct hpi_response hr; 436 struct hpi_response hr;
437 struct hpi_adapter *pa; 437 struct hpi_adapter *pa;
438 pa = (struct hpi_adapter *)pci_get_drvdata(pci_dev); 438 pa = pci_get_drvdata(pci_dev);
439 439
440 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, 440 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
441 HPI_SUBSYS_DELETE_ADAPTER); 441 HPI_SUBSYS_DELETE_ADAPTER);
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 4679ed83a43b..2f3cacbd5528 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1129,10 +1129,11 @@ snd_azf3328_codec_setdmaa(struct snd_azf3328 *chip,
1129 1129
1130 count_areas = size/2; 1130 count_areas = size/2;
1131 addr_area2 = addr+count_areas; 1131 addr_area2 = addr+count_areas;
1132 count_areas--; /* max. index */
1133 snd_azf3328_dbgcodec("setdma: buffers %08lx[%u] / %08lx[%u]\n", 1132 snd_azf3328_dbgcodec("setdma: buffers %08lx[%u] / %08lx[%u]\n",
1134 addr, count_areas, addr_area2, count_areas); 1133 addr, count_areas, addr_area2, count_areas);
1135 1134
1135 count_areas--; /* max. index */
1136
1136 /* build combined I/O buffer length word */ 1137 /* build combined I/O buffer length word */
1137 lengths = (count_areas << 16) | (count_areas); 1138 lengths = (count_areas << 16) | (count_areas);
1138 spin_lock_irqsave(&chip->reg_lock, flags); 1139 spin_lock_irqsave(&chip->reg_lock, flags);
@@ -1740,11 +1741,15 @@ static const struct snd_pcm_hardware snd_azf3328_hardware =
1740 .rate_max = AZF_FREQ_66200, 1741 .rate_max = AZF_FREQ_66200,
1741 .channels_min = 1, 1742 .channels_min = 1,
1742 .channels_max = 2, 1743 .channels_max = 2,
1743 .buffer_bytes_max = 65536, 1744 .buffer_bytes_max = (64*1024),
1744 .period_bytes_min = 64, 1745 .period_bytes_min = 1024,
1745 .period_bytes_max = 65536, 1746 .period_bytes_max = (32*1024),
1746 .periods_min = 1, 1747 /* We simply have two DMA areas (instead of a list of descriptors
1747 .periods_max = 1024, 1748 such as other cards); I believe that this is a fixed hardware
1749 attribute and there isn't much driver magic to be done to expand it.
1750 Thus indicate that we have at least and at most 2 periods. */
1751 .periods_min = 2,
1752 .periods_max = 2,
1748 /* FIXME: maybe that card actually has a FIFO? 1753 /* FIXME: maybe that card actually has a FIFO?
1749 * Hmm, it seems newer revisions do have one, but we still don't know 1754 * Hmm, it seems newer revisions do have one, but we still don't know
1750 * its size... */ 1755 * its size... */
@@ -1980,8 +1985,13 @@ snd_azf3328_timer_stop(struct snd_timer *timer)
1980 chip = snd_timer_chip(timer); 1985 chip = snd_timer_chip(timer);
1981 spin_lock_irqsave(&chip->reg_lock, flags); 1986 spin_lock_irqsave(&chip->reg_lock, flags);
1982 /* disable timer countdown and interrupt */ 1987 /* disable timer countdown and interrupt */
1983 /* FIXME: should we write TIMER_IRQ_ACK here? */ 1988 /* Hmm, should we write TIMER_IRQ_ACK here?
1984 snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0); 1989 YES indeed, otherwise a rogue timer operation - which prompts
1990 ALSA(?) to call repeated stop() in vain, but NOT start() -
1991 will never end (value 0x03 is kept shown in control byte).
1992 Simply manually poking 0x04 _once_ immediately successfully stops
1993 the hardware/ALSA interrupt activity. */
1994 snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x04);
1985 spin_unlock_irqrestore(&chip->reg_lock, flags); 1995 spin_unlock_irqrestore(&chip->reg_lock, flags);
1986 snd_azf3328_dbgcallleave(); 1996 snd_azf3328_dbgcallleave();
1987 return 0; 1997 return 0;
diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c
index 85ab43e89212..457d21189b0d 100644
--- a/sound/pci/ctxfi/ctpcm.c
+++ b/sound/pci/ctxfi/ctpcm.c
@@ -129,8 +129,6 @@ static int ct_pcm_playback_open(struct snd_pcm_substream *substream)
129 129
130 apcm->substream = substream; 130 apcm->substream = substream;
131 apcm->interrupt = ct_atc_pcm_interrupt; 131 apcm->interrupt = ct_atc_pcm_interrupt;
132 runtime->private_data = apcm;
133 runtime->private_free = ct_atc_pcm_free_substream;
134 if (IEC958 == substream->pcm->device) { 132 if (IEC958 == substream->pcm->device) {
135 runtime->hw = ct_spdif_passthru_playback_hw; 133 runtime->hw = ct_spdif_passthru_playback_hw;
136 atc->spdif_out_passthru(atc, 1); 134 atc->spdif_out_passthru(atc, 1);
@@ -155,8 +153,12 @@ static int ct_pcm_playback_open(struct snd_pcm_substream *substream)
155 } 153 }
156 154
157 apcm->timer = ct_timer_instance_new(atc->timer, apcm); 155 apcm->timer = ct_timer_instance_new(atc->timer, apcm);
158 if (!apcm->timer) 156 if (!apcm->timer) {
157 kfree(apcm);
159 return -ENOMEM; 158 return -ENOMEM;
159 }
160 runtime->private_data = apcm;
161 runtime->private_free = ct_atc_pcm_free_substream;
160 162
161 return 0; 163 return 0;
162} 164}
@@ -278,8 +280,6 @@ static int ct_pcm_capture_open(struct snd_pcm_substream *substream)
278 apcm->started = 0; 280 apcm->started = 0;
279 apcm->substream = substream; 281 apcm->substream = substream;
280 apcm->interrupt = ct_atc_pcm_interrupt; 282 apcm->interrupt = ct_atc_pcm_interrupt;
281 runtime->private_data = apcm;
282 runtime->private_free = ct_atc_pcm_free_substream;
283 runtime->hw = ct_pcm_capture_hw; 283 runtime->hw = ct_pcm_capture_hw;
284 runtime->hw.rate_max = atc->rsr * atc->msr; 284 runtime->hw.rate_max = atc->rsr * atc->msr;
285 285
@@ -298,8 +298,12 @@ static int ct_pcm_capture_open(struct snd_pcm_substream *substream)
298 } 298 }
299 299
300 apcm->timer = ct_timer_instance_new(atc->timer, apcm); 300 apcm->timer = ct_timer_instance_new(atc->timer, apcm);
301 if (!apcm->timer) 301 if (!apcm->timer) {
302 kfree(apcm);
302 return -ENOMEM; 303 return -ENOMEM;
304 }
305 runtime->private_data = apcm;
306 runtime->private_free = ct_atc_pcm_free_substream;
303 307
304 return 0; 308 return 0;
305} 309}
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
index cb0c23a6b473..4a663471dadc 100644
--- a/sound/pci/hda/hda_eld.c
+++ b/sound/pci/hda/hda_eld.c
@@ -189,6 +189,9 @@ static void hdmi_update_short_audio_desc(struct cea_sad *a,
189 a->channels = GRAB_BITS(buf, 0, 0, 3); 189 a->channels = GRAB_BITS(buf, 0, 0, 3);
190 a->channels++; 190 a->channels++;
191 191
192 a->sample_bits = 0;
193 a->max_bitrate = 0;
194
192 a->format = GRAB_BITS(buf, 0, 3, 4); 195 a->format = GRAB_BITS(buf, 0, 3, 4);
193 switch (a->format) { 196 switch (a->format) {
194 case AUDIO_CODING_TYPE_REF_STREAM_HEADER: 197 case AUDIO_CODING_TYPE_REF_STREAM_HEADER:
@@ -198,7 +201,6 @@ static void hdmi_update_short_audio_desc(struct cea_sad *a,
198 201
199 case AUDIO_CODING_TYPE_LPCM: 202 case AUDIO_CODING_TYPE_LPCM:
200 val = GRAB_BITS(buf, 2, 0, 3); 203 val = GRAB_BITS(buf, 2, 0, 3);
201 a->sample_bits = 0;
202 for (i = 0; i < 3; i++) 204 for (i = 0; i < 3; i++)
203 if (val & (1 << i)) 205 if (val & (1 << i))
204 a->sample_bits |= cea_sample_sizes[i + 1]; 206 a->sample_bits |= cea_sample_sizes[i + 1];
@@ -598,24 +600,19 @@ void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm,
598{ 600{
599 int i; 601 int i;
600 602
601 pcm->rates = 0; 603 /* assume basic audio support (the basic audio flag is not in ELD;
602 pcm->formats = 0; 604 * however, all audio capable sinks are required to support basic
603 pcm->maxbps = 0; 605 * audio) */
604 pcm->channels_min = -1; 606 pcm->rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
605 pcm->channels_max = 0; 607 pcm->formats = SNDRV_PCM_FMTBIT_S16_LE;
608 pcm->maxbps = 16;
609 pcm->channels_max = 2;
606 for (i = 0; i < eld->sad_count; i++) { 610 for (i = 0; i < eld->sad_count; i++) {
607 struct cea_sad *a = &eld->sad[i]; 611 struct cea_sad *a = &eld->sad[i];
608 pcm->rates |= a->rates; 612 pcm->rates |= a->rates;
609 if (a->channels < pcm->channels_min)
610 pcm->channels_min = a->channels;
611 if (a->channels > pcm->channels_max) 613 if (a->channels > pcm->channels_max)
612 pcm->channels_max = a->channels; 614 pcm->channels_max = a->channels;
613 if (a->format == AUDIO_CODING_TYPE_LPCM) { 615 if (a->format == AUDIO_CODING_TYPE_LPCM) {
614 if (a->sample_bits & AC_SUPPCM_BITS_16) {
615 pcm->formats |= SNDRV_PCM_FMTBIT_S16_LE;
616 if (pcm->maxbps < 16)
617 pcm->maxbps = 16;
618 }
619 if (a->sample_bits & AC_SUPPCM_BITS_20) { 616 if (a->sample_bits & AC_SUPPCM_BITS_20) {
620 pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; 617 pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE;
621 if (pcm->maxbps < 20) 618 if (pcm->maxbps < 20)
@@ -635,7 +632,6 @@ void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm,
635 /* restrict the parameters by the values the codec provides */ 632 /* restrict the parameters by the values the codec provides */
636 pcm->rates &= codec_pars->rates; 633 pcm->rates &= codec_pars->rates;
637 pcm->formats &= codec_pars->formats; 634 pcm->formats &= codec_pars->formats;
638 pcm->channels_min = max(pcm->channels_min, codec_pars->channels_min);
639 pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max); 635 pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max);
640 pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps); 636 pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps);
641} 637}
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 21aa9b0e28f6..b030c8eba21f 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -2296,6 +2296,7 @@ static int azx_dev_free(struct snd_device *device)
2296 */ 2296 */
2297static struct snd_pci_quirk position_fix_list[] __devinitdata = { 2297static struct snd_pci_quirk position_fix_list[] __devinitdata = {
2298 SND_PCI_QUIRK(0x1025, 0x009f, "Acer Aspire 5110", POS_FIX_LPIB), 2298 SND_PCI_QUIRK(0x1025, 0x009f, "Acer Aspire 5110", POS_FIX_LPIB),
2299 SND_PCI_QUIRK(0x1025, 0x026f, "Acer Aspire 5538", POS_FIX_LPIB),
2299 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), 2300 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB),
2300 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), 2301 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB),
2301 SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB), 2302 SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB),
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 6361f752b5f3..76bd58a0e2b6 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -2116,8 +2116,8 @@ static void cxt5066_update_speaker(struct hda_codec *codec)
2116 struct conexant_spec *spec = codec->spec; 2116 struct conexant_spec *spec = codec->spec;
2117 unsigned int pinctl; 2117 unsigned int pinctl;
2118 2118
2119 snd_printdd("CXT5066: update speaker, hp_present=%d\n", 2119 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
2120 spec->hp_present); 2120 spec->hp_present, spec->cur_eapd);
2121 2121
2122 /* Port A (HP) */ 2122 /* Port A (HP) */
2123 pinctl = ((spec->hp_present & 1) && spec->cur_eapd) ? PIN_HP : 0; 2123 pinctl = ((spec->hp_present & 1) && spec->cur_eapd) ? PIN_HP : 0;
@@ -2125,11 +2125,20 @@ static void cxt5066_update_speaker(struct hda_codec *codec)
2125 pinctl); 2125 pinctl);
2126 2126
2127 /* Port D (HP/LO) */ 2127 /* Port D (HP/LO) */
2128 pinctl = ((spec->hp_present & 2) && spec->cur_eapd) 2128 if (spec->dell_automute) {
2129 ? spec->port_d_mode : 0; 2129 /* DELL AIO Port Rule: PortA> PortD> IntSpk */
2130 /* Mute if Port A is connected on Thinkpad */ 2130 pinctl = (!(spec->hp_present & 1) && spec->cur_eapd)
2131 if (spec->thinkpad && (spec->hp_present & 1)) 2131 ? PIN_OUT : 0;
2132 pinctl = 0; 2132 } else if (spec->thinkpad) {
2133 if (spec->cur_eapd)
2134 pinctl = spec->port_d_mode;
2135 /* Mute dock line-out if Port A (laptop HP) is present */
2136 if (spec->hp_present& 1)
2137 pinctl = 0;
2138 } else {
2139 pinctl = ((spec->hp_present & 2) && spec->cur_eapd)
2140 ? spec->port_d_mode : 0;
2141 }
2133 snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2142 snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2134 pinctl); 2143 pinctl);
2135 2144
@@ -2137,14 +2146,6 @@ static void cxt5066_update_speaker(struct hda_codec *codec)
2137 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; 2146 pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0;
2138 snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2147 snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2139 pinctl); 2148 pinctl);
2140
2141 if (spec->dell_automute) {
2142 /* DELL AIO Port Rule: PortA > PortD > IntSpk */
2143 pinctl = (!(spec->hp_present & 1) && spec->cur_eapd)
2144 ? PIN_OUT : 0;
2145 snd_hda_codec_write(codec, 0x1c, 0,
2146 AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
2147 }
2148} 2149}
2149 2150
2150/* turn on/off EAPD (+ mute HP) as a master switch */ 2151/* turn on/off EAPD (+ mute HP) as a master switch */
@@ -3095,11 +3096,11 @@ static const char *cxt5066_models[CXT5066_MODELS] = {
3095static struct snd_pci_quirk cxt5066_cfg_tbl[] = { 3096static struct snd_pci_quirk cxt5066_cfg_tbl[] = {
3096 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), 3097 SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD),
3097 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), 3098 SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO),
3098 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", 3099 SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD),
3099 CXT5066_DELL_LAPTOP),
3100 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO), 3100 SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO),
3101 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), 3101 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD),
3102 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 3102 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP),
3103 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_HP_LAPTOP),
3103 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 3104 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD),
3104 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), 3105 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5),
3105 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5), 3106 SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5),
@@ -3108,8 +3109,10 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = {
3108 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), 3109 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5),
3109 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), 3110 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD),
3110 SND_PCI_QUIRK(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD), 3111 SND_PCI_QUIRK(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD),
3112 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD),
3111 SND_PCI_QUIRK(0x17aa, 0x21b3, "Thinkpad Edge 13 (197)", CXT5066_IDEAPAD), 3113 SND_PCI_QUIRK(0x17aa, 0x21b3, "Thinkpad Edge 13 (197)", CXT5066_IDEAPAD),
3112 SND_PCI_QUIRK(0x17aa, 0x21b4, "Thinkpad Edge", CXT5066_IDEAPAD), 3114 SND_PCI_QUIRK(0x17aa, 0x21b4, "Thinkpad Edge", CXT5066_IDEAPAD),
3115 SND_PCI_QUIRK(0x17aa, 0x21c8, "Thinkpad Edge 11", CXT5066_IDEAPAD),
3113 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD), 3116 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD),
3114 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G series", CXT5066_IDEAPAD), 3117 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G series", CXT5066_IDEAPAD),
3115 SND_PCI_QUIRK(0x17aa, 0x390a, "Lenovo S10-3t", CXT5066_IDEAPAD), 3118 SND_PCI_QUIRK(0x17aa, 0x390a, "Lenovo S10-3t", CXT5066_IDEAPAD),
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index d3e49aa5b9ec..31df7747990d 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -834,7 +834,6 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
834 return -ENODEV; 834 return -ENODEV;
835 } else { 835 } else {
836 /* fallback to the codec default */ 836 /* fallback to the codec default */
837 hinfo->channels_min = codec_pars->channels_min;
838 hinfo->channels_max = codec_pars->channels_max; 837 hinfo->channels_max = codec_pars->channels_max;
839 hinfo->rates = codec_pars->rates; 838 hinfo->rates = codec_pars->rates;
840 hinfo->formats = codec_pars->formats; 839 hinfo->formats = codec_pars->formats;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 5f00589cb791..427da45d7906 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1614,6 +1614,7 @@ do_sku:
1614 spec->init_amp = ALC_INIT_GPIO3; 1614 spec->init_amp = ALC_INIT_GPIO3;
1615 break; 1615 break;
1616 case 5: 1616 case 5:
1617 default:
1617 spec->init_amp = ALC_INIT_DEFAULT; 1618 spec->init_amp = ALC_INIT_DEFAULT;
1618 break; 1619 break;
1619 } 1620 }
@@ -2014,6 +2015,36 @@ static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
2014}; 2015};
2015 2016
2016/* 2017/*
2018 *ALC888 Acer Aspire 7730G model
2019 */
2020
2021static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2022/* Bias voltage on for external mic port */
2023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2024/* Front Mic: set to PIN_IN (empty by default) */
2025 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2026/* Unselect Front Mic by default in input mixer 3 */
2027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2028/* Enable unsolicited event for HP jack */
2029 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2030/* Enable speaker output */
2031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2033 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2034/* Enable headphone output */
2035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2038 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2039/*Enable internal subwoofer */
2040 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2041 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2042 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2043 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2044 { }
2045};
2046
2047/*
2017 * ALC889 Acer Aspire 8930G model 2048 * ALC889 Acer Aspire 8930G model
2018 */ 2049 */
2019 2050
@@ -2200,6 +2231,16 @@ static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
2200 spec->autocfg.speaker_pins[2] = 0x17; 2231 spec->autocfg.speaker_pins[2] = 0x17;
2201} 2232}
2202 2233
2234static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2235{
2236 struct alc_spec *spec = codec->spec;
2237
2238 spec->autocfg.hp_pins[0] = 0x15;
2239 spec->autocfg.speaker_pins[0] = 0x14;
2240 spec->autocfg.speaker_pins[1] = 0x16;
2241 spec->autocfg.speaker_pins[2] = 0x17;
2242}
2243
2203static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec) 2244static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
2204{ 2245{
2205 struct alc_spec *spec = codec->spec; 2246 struct alc_spec *spec = codec->spec;
@@ -4554,6 +4595,7 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
4554 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), 4595 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
4555 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), 4596 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
4556 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), 4597 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4598 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
4557 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), 4599 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
4558 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), 4600 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
4559 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), 4601 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
@@ -9524,13 +9566,6 @@ static struct hda_verb alc883_acer_eapd_verbs[] = {
9524 { } 9566 { }
9525}; 9567};
9526 9568
9527static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9528 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9529 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9530 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9531 { } /* end */
9532};
9533
9534static void alc888_6st_dell_setup(struct hda_codec *codec) 9569static void alc888_6st_dell_setup(struct hda_codec *codec)
9535{ 9570{
9536 struct alc_spec *spec = codec->spec; 9571 struct alc_spec *spec = codec->spec;
@@ -9831,7 +9866,6 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
9831 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), 9866 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9832 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), 9867 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9833 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY), 9868 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
9834 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
9835 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), 9869 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
9836 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), 9870 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
9837 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 9871 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
@@ -10328,7 +10362,7 @@ static struct alc_config_preset alc882_presets[] = {
10328 .const_channel_count = 6, 10362 .const_channel_count = 6,
10329 .input_mux = &alc883_capture_source, 10363 .input_mux = &alc883_capture_source,
10330 .unsol_event = alc_automute_amp_unsol_event, 10364 .unsol_event = alc_automute_amp_unsol_event,
10331 .setup = alc888_acer_aspire_6530g_setup, 10365 .setup = alc888_acer_aspire_7730g_setup,
10332 .init_hook = alc_automute_amp, 10366 .init_hook = alc_automute_amp,
10333 }, 10367 },
10334 [ALC883_MEDION] = { 10368 [ALC883_MEDION] = {
@@ -10796,7 +10830,8 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
10796{ 10830{
10797 struct alc_spec *spec = codec->spec; 10831 struct alc_spec *spec = codec->spec;
10798 struct auto_pin_cfg *cfg = &spec->autocfg; 10832 struct auto_pin_cfg *cfg = &spec->autocfg;
10799 int i, err; 10833 int i, err, type;
10834 int type_idx = 0;
10800 hda_nid_t nid; 10835 hda_nid_t nid;
10801 10836
10802 for (i = 0; i < cfg->num_inputs; i++) { 10837 for (i = 0; i < cfg->num_inputs; i++) {
@@ -10805,9 +10840,15 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
10805 nid = cfg->inputs[i].pin; 10840 nid = cfg->inputs[i].pin;
10806 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { 10841 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
10807 char label[32]; 10842 char label[32];
10843 type = cfg->inputs[i].type;
10844 if (i > 0 && type == cfg->inputs[i - 1].type)
10845 type_idx++;
10846 else
10847 type_idx = 0;
10808 snprintf(label, sizeof(label), "%s Boost", 10848 snprintf(label, sizeof(label), "%s Boost",
10809 hda_get_autocfg_input_label(codec, cfg, i)); 10849 hda_get_autocfg_input_label(codec, cfg, i));
10810 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0, 10850 err = add_control(spec, ALC_CTL_WIDGET_VOL, label,
10851 type_idx,
10811 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 10852 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10812 if (err < 0) 10853 if (err < 0)
10813 return err; 10854 return err;
@@ -14623,7 +14664,10 @@ static int alc275_setup_dual_adc(struct hda_codec *codec)
14623/* different alc269-variants */ 14664/* different alc269-variants */
14624enum { 14665enum {
14625 ALC269_TYPE_NORMAL, 14666 ALC269_TYPE_NORMAL,
14667 ALC269_TYPE_ALC258,
14626 ALC269_TYPE_ALC259, 14668 ALC269_TYPE_ALC259,
14669 ALC269_TYPE_ALC269VB,
14670 ALC269_TYPE_ALC270,
14627 ALC269_TYPE_ALC271X, 14671 ALC269_TYPE_ALC271X,
14628}; 14672};
14629 14673
@@ -14763,6 +14807,8 @@ static int alc269_resume(struct hda_codec *codec)
14763enum { 14807enum {
14764 ALC269_FIXUP_SONY_VAIO, 14808 ALC269_FIXUP_SONY_VAIO,
14765 ALC269_FIXUP_DELL_M101Z, 14809 ALC269_FIXUP_DELL_M101Z,
14810 ALC269_FIXUP_LENOVO_EDGE14,
14811 ALC269_FIXUP_ASUS_G73JW,
14766}; 14812};
14767 14813
14768static const struct alc_fixup alc269_fixups[] = { 14814static const struct alc_fixup alc269_fixups[] = {
@@ -14780,11 +14826,22 @@ static const struct alc_fixup alc269_fixups[] = {
14780 {} 14826 {}
14781 } 14827 }
14782 }, 14828 },
14829 [ALC269_FIXUP_LENOVO_EDGE14] = {
14830 .sku = ALC_FIXUP_SKU_IGNORE,
14831 },
14832 [ALC269_FIXUP_ASUS_G73JW] = {
14833 .pins = (const struct alc_pincfg[]) {
14834 { 0x17, 0x99130111 }, /* subwoofer */
14835 { }
14836 }
14837 },
14783}; 14838};
14784 14839
14785static struct snd_pci_quirk alc269_fixup_tbl[] = { 14840static struct snd_pci_quirk alc269_fixup_tbl[] = {
14786 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), 14841 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
14787 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 14842 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
14843 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_LENOVO_EDGE14),
14844 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
14788 {} 14845 {}
14789}; 14846};
14790 14847
@@ -15023,7 +15080,7 @@ static int alc269_fill_coef(struct hda_codec *codec)
15023static int patch_alc269(struct hda_codec *codec) 15080static int patch_alc269(struct hda_codec *codec)
15024{ 15081{
15025 struct alc_spec *spec; 15082 struct alc_spec *spec;
15026 int board_config; 15083 int board_config, coef;
15027 int err; 15084 int err;
15028 15085
15029 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 15086 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -15034,14 +15091,23 @@ static int patch_alc269(struct hda_codec *codec)
15034 15091
15035 alc_auto_parse_customize_define(codec); 15092 alc_auto_parse_customize_define(codec);
15036 15093
15037 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){ 15094 coef = alc_read_coef_idx(codec, 0);
15095 if ((coef & 0x00f0) == 0x0010) {
15038 if (codec->bus->pci->subsystem_vendor == 0x1025 && 15096 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15039 spec->cdefine.platform_type == 1) { 15097 spec->cdefine.platform_type == 1) {
15040 alc_codec_rename(codec, "ALC271X"); 15098 alc_codec_rename(codec, "ALC271X");
15041 spec->codec_variant = ALC269_TYPE_ALC271X; 15099 spec->codec_variant = ALC269_TYPE_ALC271X;
15042 } else { 15100 } else if ((coef & 0xf000) == 0x1000) {
15101 spec->codec_variant = ALC269_TYPE_ALC270;
15102 } else if ((coef & 0xf000) == 0x2000) {
15043 alc_codec_rename(codec, "ALC259"); 15103 alc_codec_rename(codec, "ALC259");
15044 spec->codec_variant = ALC269_TYPE_ALC259; 15104 spec->codec_variant = ALC269_TYPE_ALC259;
15105 } else if ((coef & 0xf000) == 0x3000) {
15106 alc_codec_rename(codec, "ALC258");
15107 spec->codec_variant = ALC269_TYPE_ALC258;
15108 } else {
15109 alc_codec_rename(codec, "ALC269VB");
15110 spec->codec_variant = ALC269_TYPE_ALC269VB;
15045 } 15111 }
15046 } else 15112 } else
15047 alc_fix_pll_init(codec, 0x20, 0x04, 15); 15113 alc_fix_pll_init(codec, 0x20, 0x04, 15);
@@ -15104,7 +15170,7 @@ static int patch_alc269(struct hda_codec *codec)
15104 spec->stream_digital_capture = &alc269_pcm_digital_capture; 15170 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15105 15171
15106 if (!spec->adc_nids) { /* wasn't filled automatically? use default */ 15172 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
15107 if (spec->codec_variant != ALC269_TYPE_NORMAL) { 15173 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
15108 spec->adc_nids = alc269_adc_nids; 15174 spec->adc_nids = alc269_adc_nids;
15109 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); 15175 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15110 spec->capsrc_nids = alc269_capsrc_nids; 15176 spec->capsrc_nids = alc269_capsrc_nids;
@@ -16898,7 +16964,7 @@ static struct alc_config_preset alc861vd_presets[] = {
16898static int alc861vd_auto_create_input_ctls(struct hda_codec *codec, 16964static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16899 const struct auto_pin_cfg *cfg) 16965 const struct auto_pin_cfg *cfg)
16900{ 16966{
16901 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0); 16967 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
16902} 16968}
16903 16969
16904 16970
@@ -18952,6 +19018,8 @@ static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18952 return 0x02; 19018 return 0x02;
18953 else if (nid >= 0x0c && nid <= 0x0e) 19019 else if (nid >= 0x0c && nid <= 0x0e)
18954 return nid - 0x0c + 0x02; 19020 return nid - 0x0c + 0x02;
19021 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19022 return 0x25;
18955 else 19023 else
18956 return 0; 19024 return 0;
18957} 19025}
@@ -18960,7 +19028,7 @@ static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18960static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin, 19028static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18961 hda_nid_t dac) 19029 hda_nid_t dac)
18962{ 19030{
18963 hda_nid_t mix[4]; 19031 hda_nid_t mix[5];
18964 int i, num; 19032 int i, num;
18965 19033
18966 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); 19034 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
@@ -19298,6 +19366,7 @@ static const struct alc_fixup alc662_fixups[] = {
19298 19366
19299static struct snd_pci_quirk alc662_fixup_tbl[] = { 19367static struct snd_pci_quirk alc662_fixup_tbl[] = {
19300 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), 19368 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
19369 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
19301 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), 19370 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
19302 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), 19371 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19303 {} 19372 {}
@@ -19419,7 +19488,10 @@ static int patch_alc888(struct hda_codec *codec)
19419{ 19488{
19420 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){ 19489 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19421 kfree(codec->chip_name); 19490 kfree(codec->chip_name);
19422 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL); 19491 if (codec->vendor_id == 0x10ec0887)
19492 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19493 else
19494 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
19423 if (!codec->chip_name) { 19495 if (!codec->chip_name) {
19424 alc_free(codec); 19496 alc_free(codec);
19425 return -ENOMEM; 19497 return -ENOMEM;
@@ -19909,7 +19981,7 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = {
19909 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 19981 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
19910 .patch = patch_alc882 }, 19982 .patch = patch_alc882 },
19911 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 19983 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
19912 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, 19984 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
19913 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 19985 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
19914 .patch = patch_alc882 }, 19986 .patch = patch_alc882 },
19915 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 }, 19987 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 93fa59cc60ef..efa4225f5fd6 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -389,6 +389,11 @@ static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
389 0x11, 0x20, 0 389 0x11, 0x20, 0
390}; 390};
391 391
392#define STAC92HD87B_NUM_DMICS 1
393static hda_nid_t stac92hd87b_dmic_nids[STAC92HD87B_NUM_DMICS + 1] = {
394 0x11, 0
395};
396
392#define STAC92HD83XXX_NUM_CAPS 2 397#define STAC92HD83XXX_NUM_CAPS 2
393static unsigned long stac92hd83xxx_capvols[] = { 398static unsigned long stac92hd83xxx_capvols[] = {
394 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), 399 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
@@ -1622,6 +1627,8 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1622static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = { 1627static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1, 1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1624 "Alienware M17x", STAC_ALIENWARE_M17X), 1629 "Alienware M17x", STAC_ALIENWARE_M17X),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1631 "Alienware M17x", STAC_ALIENWARE_M17X),
1625 {} /* terminator */ 1632 {} /* terminator */
1626}; 1633};
1627 1634
@@ -3486,10 +3493,8 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3486 return err; 3493 return err;
3487 } 3494 }
3488 3495
3489 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { 3496 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3490 snd_hda_add_imux_item(imux, label, index, NULL); 3497 snd_hda_add_imux_item(imux, label, index, NULL);
3491 spec->num_analog_muxes++;
3492 }
3493 } 3498 }
3494 3499
3495 return 0; 3500 return 0;
@@ -5452,12 +5457,17 @@ again:
5452 stac92hd83xxx_brd_tbl[spec->board_config]); 5457 stac92hd83xxx_brd_tbl[spec->board_config]);
5453 5458
5454 switch (codec->vendor_id) { 5459 switch (codec->vendor_id) {
5460 case 0x111d76d1:
5461 case 0x111d76d9:
5462 spec->dmic_nids = stac92hd87b_dmic_nids;
5463 spec->num_dmics = stac92xx_connected_ports(codec,
5464 stac92hd87b_dmic_nids,
5465 STAC92HD87B_NUM_DMICS);
5466 /* Fall through */
5455 case 0x111d7666: 5467 case 0x111d7666:
5456 case 0x111d7667: 5468 case 0x111d7667:
5457 case 0x111d7668: 5469 case 0x111d7668:
5458 case 0x111d7669: 5470 case 0x111d7669:
5459 case 0x111d76d1:
5460 case 0x111d76d9:
5461 spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids); 5471 spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids);
5462 spec->pin_nids = stac92hd88xxx_pin_nids; 5472 spec->pin_nids = stac92hd88xxx_pin_nids;
5463 spec->mono_nid = 0; 5473 spec->mono_nid = 0;
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 400f9ebd243e..629a5494347a 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1866,6 +1866,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1866 }, 1866 },
1867 { 1867 {
1868 .subvendor = 0x1028, 1868 .subvendor = 0x1028,
1869 .subdevice = 0x0182,
1870 .name = "Dell Latitude D610", /* STAC9750/51 */
1871 .type = AC97_TUNE_HP_ONLY
1872 },
1873 {
1874 .subvendor = 0x1028,
1869 .subdevice = 0x0186, 1875 .subdevice = 0x0186,
1870 .name = "Dell Latitude D810", /* cf. Malone #41015 */ 1876 .name = "Dell Latitude D810", /* cf. Malone #41015 */
1871 .type = AC97_TUNE_HP_MUTE_LED 1877 .type = AC97_TUNE_HP_MUTE_LED
diff --git a/sound/pci/mixart/mixart_hwdep.h b/sound/pci/mixart/mixart_hwdep.h
index a46f5083db99..812e288ef2e7 100644
--- a/sound/pci/mixart/mixart_hwdep.h
+++ b/sound/pci/mixart/mixart_hwdep.h
@@ -25,11 +25,21 @@
25 25
26#include <sound/hwdep.h> 26#include <sound/hwdep.h>
27 27
28#ifndef readl_be
28#define readl_be(x) be32_to_cpu(__raw_readl(x)) 29#define readl_be(x) be32_to_cpu(__raw_readl(x))
30#endif
31
32#ifndef writel_be
29#define writel_be(data,addr) __raw_writel(cpu_to_be32(data),addr) 33#define writel_be(data,addr) __raw_writel(cpu_to_be32(data),addr)
34#endif
30 35
36#ifndef readl_le
31#define readl_le(x) le32_to_cpu(__raw_readl(x)) 37#define readl_le(x) le32_to_cpu(__raw_readl(x))
38#endif
39
40#ifndef writel_le
32#define writel_le(data,addr) __raw_writel(cpu_to_le32(data),addr) 41#define writel_le(data,addr) __raw_writel(cpu_to_le32(data),addr)
42#endif
33 43
34#define MIXART_MEM(mgr,x) ((mgr)->mem[0].virt + (x)) 44#define MIXART_MEM(mgr,x) ((mgr)->mem[0].virt + (x))
35#define MIXART_REG(mgr,x) ((mgr)->mem[1].virt + (x)) 45#define MIXART_REG(mgr,x) ((mgr)->mem[1].virt + (x))
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 85081172403f..b47cfd45b3b9 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -1228,10 +1228,8 @@ int __devinit snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1228 chip->rsrc[i].start + 1, 1228 chip->rsrc[i].start + 1,
1229 rnames[i]) == NULL) { 1229 rnames[i]) == NULL) {
1230 printk(KERN_ERR "snd: can't request rsrc " 1230 printk(KERN_ERR "snd: can't request rsrc "
1231 " %d (%s: 0x%016llx:%016llx)\n", 1231 " %d (%s: %pR)\n",
1232 i, rnames[i], 1232 i, rnames[i], &chip->rsrc[i]);
1233 (unsigned long long)chip->rsrc[i].start,
1234 (unsigned long long)chip->rsrc[i].end);
1235 err = -ENODEV; 1233 err = -ENODEV;
1236 goto __error; 1234 goto __error;
1237 } 1235 }
@@ -1256,10 +1254,8 @@ int __devinit snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1256 chip->rsrc[i].start + 1, 1254 chip->rsrc[i].start + 1,
1257 rnames[i]) == NULL) { 1255 rnames[i]) == NULL) {
1258 printk(KERN_ERR "snd: can't request rsrc " 1256 printk(KERN_ERR "snd: can't request rsrc "
1259 " %d (%s: 0x%016llx:%016llx)\n", 1257 " %d (%s: %pR)\n",
1260 i, rnames[i], 1258 i, rnames[i], &chip->rsrc[i]);
1261 (unsigned long long)chip->rsrc[i].start,
1262 (unsigned long long)chip->rsrc[i].end);
1263 err = -ENODEV; 1259 err = -ENODEV;
1264 goto __error; 1260 goto __error;
1265 } 1261 }
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
index e720d5e6f04c..bee3c94f58b0 100644
--- a/sound/soc/atmel/Kconfig
+++ b/sound/soc/atmel/Kconfig
@@ -16,7 +16,8 @@ config SND_ATMEL_SOC_SSC
16 16
17config SND_AT91_SOC_SAM9G20_WM8731 17config SND_AT91_SOC_SAM9G20_WM8731
18 tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board" 18 tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board"
19 depends on ATMEL_SSC && ARCH_AT91SAM9G20 && SND_ATMEL_SOC 19 depends on ATMEL_SSC && ARCH_AT91SAM9G20 && SND_ATMEL_SOC && \
20 AT91_PROGRAMMABLE_CLOCKS
20 select SND_ATMEL_SOC_SSC 21 select SND_ATMEL_SOC_SSC
21 select SND_SOC_WM8731 22 select SND_SOC_WM8731
22 help 23 help
@@ -25,7 +26,7 @@ config SND_AT91_SOC_SAM9G20_WM8731
25 26
26config SND_AT32_SOC_PLAYPAQ 27config SND_AT32_SOC_PLAYPAQ
27 tristate "SoC Audio support for PlayPaq with WM8510" 28 tristate "SoC Audio support for PlayPaq with WM8510"
28 depends on SND_ATMEL_SOC && BOARD_PLAYPAQ 29 depends on SND_ATMEL_SOC && BOARD_PLAYPAQ && AT91_PROGRAMMABLE_CLOCKS
29 select SND_ATMEL_SOC_SSC 30 select SND_ATMEL_SOC_SSC
30 select SND_SOC_WM8510 31 select SND_SOC_WM8510
31 help 32 help
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
index 293569dfd0ed..e521ada80542 100644
--- a/sound/soc/atmel/sam9g20_wm8731.c
+++ b/sound/soc/atmel/sam9g20_wm8731.c
@@ -222,9 +222,9 @@ static int __init at91sam9g20ek_init(void)
222 } 222 }
223 223
224 pllb = clk_get(NULL, "pllb"); 224 pllb = clk_get(NULL, "pllb");
225 if (IS_ERR(mclk)) { 225 if (IS_ERR(pllb)) {
226 printk(KERN_ERR "ASoC: Failed to get PLLB\n"); 226 printk(KERN_ERR "ASoC: Failed to get PLLB\n");
227 ret = PTR_ERR(mclk); 227 ret = PTR_ERR(pllb);
228 goto err_mclk; 228 goto err_mclk;
229 } 229 }
230 ret = clk_set_parent(mclk, pllb); 230 ret = clk_set_parent(mclk, pllb);
@@ -240,6 +240,7 @@ static int __init at91sam9g20ek_init(void)
240 if (!at91sam9g20ek_snd_device) { 240 if (!at91sam9g20ek_snd_device) {
241 printk(KERN_ERR "ASoC: Platform device allocation failed\n"); 241 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
242 ret = -ENOMEM; 242 ret = -ENOMEM;
243 goto err_mclk;
243 } 244 }
244 245
245 platform_set_drvdata(at91sam9g20ek_snd_device, 246 platform_set_drvdata(at91sam9g20ek_snd_device,
@@ -248,11 +249,13 @@ static int __init at91sam9g20ek_init(void)
248 ret = platform_device_add(at91sam9g20ek_snd_device); 249 ret = platform_device_add(at91sam9g20ek_snd_device);
249 if (ret) { 250 if (ret) {
250 printk(KERN_ERR "ASoC: Platform device allocation failed\n"); 251 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
251 platform_device_put(at91sam9g20ek_snd_device); 252 goto err_device_add;
252 } 253 }
253 254
254 return ret; 255 return ret;
255 256
257err_device_add:
258 platform_device_put(at91sam9g20ek_snd_device);
256err_mclk: 259err_mclk:
257 clk_put(mclk); 260 clk_put(mclk);
258 mclk = NULL; 261 mclk = NULL;
diff --git a/sound/soc/atmel/snd-soc-afeb9260.c b/sound/soc/atmel/snd-soc-afeb9260.c
index e3d283561c19..86e0f8586dc3 100644
--- a/sound/soc/atmel/snd-soc-afeb9260.c
+++ b/sound/soc/atmel/snd-soc-afeb9260.c
@@ -167,7 +167,6 @@ static int __init afeb9260_soc_init(void)
167 167
168 return 0; 168 return 0;
169err1: 169err1:
170 platform_device_del(afeb9260_snd_device);
171 platform_device_put(afeb9260_snd_device); 170 platform_device_put(afeb9260_snd_device);
172 return err; 171 return err;
173} 172}
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index bc22ee93a75d..d63e28773eb1 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -28,6 +28,11 @@
28#include <sound/max98088.h> 28#include <sound/max98088.h>
29#include "max98088.h" 29#include "max98088.h"
30 30
31enum max98088_type {
32 MAX98088,
33 MAX98089,
34};
35
31struct max98088_cdata { 36struct max98088_cdata {
32 unsigned int rate; 37 unsigned int rate;
33 unsigned int fmt; 38 unsigned int fmt;
@@ -36,6 +41,7 @@ struct max98088_cdata {
36 41
37struct max98088_priv { 42struct max98088_priv {
38 u8 reg_cache[M98088_REG_CNT]; 43 u8 reg_cache[M98088_REG_CNT];
44 enum max98088_type devtype;
39 void *control_data; 45 void *control_data;
40 struct max98088_pdata *pdata; 46 struct max98088_pdata *pdata;
41 unsigned int sysclk; 47 unsigned int sysclk;
@@ -2013,7 +2019,10 @@ err_access:
2013 2019
2014static int max98088_remove(struct snd_soc_codec *codec) 2020static int max98088_remove(struct snd_soc_codec *codec)
2015{ 2021{
2022 struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
2023
2016 max98088_set_bias_level(codec, SND_SOC_BIAS_OFF); 2024 max98088_set_bias_level(codec, SND_SOC_BIAS_OFF);
2025 kfree(max98088->eq_texts);
2017 2026
2018 return 0; 2027 return 0;
2019} 2028}
@@ -2040,6 +2049,8 @@ static int max98088_i2c_probe(struct i2c_client *i2c,
2040 if (max98088 == NULL) 2049 if (max98088 == NULL)
2041 return -ENOMEM; 2050 return -ENOMEM;
2042 2051
2052 max98088->devtype = id->driver_data;
2053
2043 i2c_set_clientdata(i2c, max98088); 2054 i2c_set_clientdata(i2c, max98088);
2044 max98088->control_data = i2c; 2055 max98088->control_data = i2c;
2045 max98088->pdata = i2c->dev.platform_data; 2056 max98088->pdata = i2c->dev.platform_data;
@@ -2059,7 +2070,8 @@ static int __devexit max98088_i2c_remove(struct i2c_client *client)
2059} 2070}
2060 2071
2061static const struct i2c_device_id max98088_i2c_id[] = { 2072static const struct i2c_device_id max98088_i2c_id[] = {
2062 { "max98088", 0 }, 2073 { "max98088", MAX98088 },
2074 { "max98089", MAX98089 },
2063 { } 2075 { }
2064}; 2076};
2065MODULE_DEVICE_TABLE(i2c, max98088_i2c_id); 2077MODULE_DEVICE_TABLE(i2c, max98088_i2c_id);
diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c
index 00d67cc8e206..061f9e5a497b 100644
--- a/sound/soc/codecs/stac9766.c
+++ b/sound/soc/codecs/stac9766.c
@@ -383,6 +383,7 @@ static struct snd_soc_codec_driver soc_codec_dev_stac9766 = {
383 .reg_cache_size = sizeof(stac9766_reg), 383 .reg_cache_size = sizeof(stac9766_reg),
384 .reg_word_size = sizeof(u16), 384 .reg_word_size = sizeof(u16),
385 .reg_cache_step = 2, 385 .reg_cache_step = 2,
386 .reg_cache_default = stac9766_reg,
386}; 387};
387 388
388static __devinit int stac9766_probe(struct platform_device *pdev) 389static __devinit int stac9766_probe(struct platform_device *pdev)
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index fc687790188b..77b8f9ae29be 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1176,7 +1176,7 @@ EXPORT_SYMBOL_GPL(aic3x_set_gpio);
1176int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio) 1176int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio)
1177{ 1177{
1178 u8 reg = gpio ? AIC3X_GPIO2_REG : AIC3X_GPIO1_REG; 1178 u8 reg = gpio ? AIC3X_GPIO2_REG : AIC3X_GPIO1_REG;
1179 u8 val, bit = gpio ? 2: 1; 1179 u8 val = 0, bit = gpio ? 2 : 1;
1180 1180
1181 aic3x_read(codec, reg, &val); 1181 aic3x_read(codec, reg, &val);
1182 return (val >> bit) & 1; 1182 return (val >> bit) & 1;
@@ -1204,7 +1204,7 @@ EXPORT_SYMBOL_GPL(aic3x_set_headset_detection);
1204 1204
1205int aic3x_headset_detected(struct snd_soc_codec *codec) 1205int aic3x_headset_detected(struct snd_soc_codec *codec)
1206{ 1206{
1207 u8 val; 1207 u8 val = 0;
1208 aic3x_read(codec, AIC3X_HEADSET_DETECT_CTRL_B, &val); 1208 aic3x_read(codec, AIC3X_HEADSET_DETECT_CTRL_B, &val);
1209 return (val >> 4) & 1; 1209 return (val >> 4) & 1;
1210} 1210}
@@ -1212,7 +1212,7 @@ EXPORT_SYMBOL_GPL(aic3x_headset_detected);
1212 1212
1213int aic3x_button_pressed(struct snd_soc_codec *codec) 1213int aic3x_button_pressed(struct snd_soc_codec *codec)
1214{ 1214{
1215 u8 val; 1215 u8 val = 0;
1216 aic3x_read(codec, AIC3X_HEADSET_DETECT_CTRL_B, &val); 1216 aic3x_read(codec, AIC3X_HEADSET_DETECT_CTRL_B, &val);
1217 return (val >> 5) & 1; 1217 return (val >> 5) & 1;
1218} 1218}
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index ee4fb201de60..d2c243095673 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -78,8 +78,10 @@ static int tpa6130a2_i2c_write(int reg, u8 value)
78 78
79 if (data->power_state) { 79 if (data->power_state) {
80 val = i2c_smbus_write_byte_data(tpa6130a2_client, reg, value); 80 val = i2c_smbus_write_byte_data(tpa6130a2_client, reg, value);
81 if (val < 0) 81 if (val < 0) {
82 dev_err(&tpa6130a2_client->dev, "Write failed\n"); 82 dev_err(&tpa6130a2_client->dev, "Write failed\n");
83 return val;
84 }
83 } 85 }
84 86
85 /* Either powered on or off, we save the context */ 87 /* Either powered on or off, we save the context */
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c
index 7540a509a6f5..464f0cfa4c7a 100644
--- a/sound/soc/codecs/uda134x.c
+++ b/sound/soc/codecs/uda134x.c
@@ -597,6 +597,7 @@ static struct snd_soc_codec_driver soc_codec_dev_uda134x = {
597 .resume = uda134x_soc_resume, 597 .resume = uda134x_soc_resume,
598 .reg_cache_size = sizeof(uda134x_reg), 598 .reg_cache_size = sizeof(uda134x_reg),
599 .reg_word_size = sizeof(u8), 599 .reg_word_size = sizeof(u8),
600 .reg_cache_default = uda134x_reg,
600 .reg_cache_step = 1, 601 .reg_cache_step = 1,
601 .read = uda134x_read_reg_cache, 602 .read = uda134x_read_reg_cache,
602 .write = uda134x_write, 603 .write = uda134x_write,
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index f4f1fba38eb9..7611add7f8c3 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -831,7 +831,7 @@ static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai,
831 } 831 }
832 832
833 /* MCLK direction */ 833 /* MCLK direction */
834 if (dir == WM8350_MCLK_DIR_OUT) 834 if (dir == SND_SOC_CLOCK_OUT)
835 wm8350_set_bits(wm8350, WM8350_CLOCK_CONTROL_2, 835 wm8350_set_bits(wm8350, WM8350_CLOCK_CONTROL_2,
836 WM8350_MCLK_DIR); 836 WM8350_MCLK_DIR);
837 else 837 else
@@ -1586,6 +1586,13 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec)
1586 wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME, 1586 wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME,
1587 WM8350_OUT2_VU | WM8350_OUT2R_MUTE); 1587 WM8350_OUT2_VU | WM8350_OUT2R_MUTE);
1588 1588
1589 /* Make sure AIF tristating is disabled by default */
1590 wm8350_clear_bits(wm8350, WM8350_AI_FORMATING, WM8350_AIF_TRI);
1591
1592 /* Make sure we've got a sane companding setup too */
1593 wm8350_clear_bits(wm8350, WM8350_ADC_DAC_COMP,
1594 WM8350_DAC_COMP | WM8350_LOOPBACK);
1595
1589 /* Make sure jack detect is disabled to start off with */ 1596 /* Make sure jack detect is disabled to start off with */
1590 wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, 1597 wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
1591 WM8350_JDL_ENA | WM8350_JDR_ENA); 1598 WM8350_JDL_ENA | WM8350_JDR_ENA);
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c
index 712ef7c76f90..9a433a5396cb 100644
--- a/sound/soc/codecs/wm8523.c
+++ b/sound/soc/codecs/wm8523.c
@@ -146,7 +146,6 @@ static int wm8523_startup(struct snd_pcm_substream *substream,
146 return -EINVAL; 146 return -EINVAL;
147 } 147 }
148 148
149 return 0;
150 snd_pcm_hw_constraint_list(substream->runtime, 0, 149 snd_pcm_hw_constraint_list(substream->runtime, 0,
151 SNDRV_PCM_HW_PARAM_RATE, 150 SNDRV_PCM_HW_PARAM_RATE,
152 &wm8523->rate_constraint); 151 &wm8523->rate_constraint);
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c
index a2e0ed59b376..8725d4e75431 100644
--- a/sound/soc/codecs/wm8580.c
+++ b/sound/soc/codecs/wm8580.c
@@ -161,7 +161,7 @@
161static const u16 wm8580_reg[] = { 161static const u16 wm8580_reg[] = {
162 0x0121, 0x017e, 0x007d, 0x0014, /*R3*/ 162 0x0121, 0x017e, 0x007d, 0x0014, /*R3*/
163 0x0121, 0x017e, 0x007d, 0x0194, /*R7*/ 163 0x0121, 0x017e, 0x007d, 0x0194, /*R7*/
164 0x001c, 0x0002, 0x0002, 0x00c2, /*R11*/ 164 0x0010, 0x0002, 0x0002, 0x00c2, /*R11*/
165 0x0182, 0x0082, 0x000a, 0x0024, /*R15*/ 165 0x0182, 0x0082, 0x000a, 0x0024, /*R15*/
166 0x0009, 0x0000, 0x00ff, 0x0000, /*R19*/ 166 0x0009, 0x0000, 0x00ff, 0x0000, /*R19*/
167 0x00ff, 0x00ff, 0x00ff, 0x00ff, /*R23*/ 167 0x00ff, 0x00ff, 0x00ff, 0x00ff, /*R23*/
@@ -491,16 +491,16 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream,
491 paifa |= 0x8; 491 paifa |= 0x8;
492 break; 492 break;
493 case SNDRV_PCM_FORMAT_S20_3LE: 493 case SNDRV_PCM_FORMAT_S20_3LE:
494 paifa |= 0x10; 494 paifa |= 0x0;
495 paifb |= WM8580_AIF_LENGTH_20; 495 paifb |= WM8580_AIF_LENGTH_20;
496 break; 496 break;
497 case SNDRV_PCM_FORMAT_S24_LE: 497 case SNDRV_PCM_FORMAT_S24_LE:
498 paifa |= 0x10; 498 paifa |= 0x0;
499 paifb |= WM8580_AIF_LENGTH_24; 499 paifb |= WM8580_AIF_LENGTH_24;
500 break; 500 break;
501 case SNDRV_PCM_FORMAT_S32_LE: 501 case SNDRV_PCM_FORMAT_S32_LE:
502 paifa |= 0x10; 502 paifa |= 0x0;
503 paifb |= WM8580_AIF_LENGTH_24; 503 paifb |= WM8580_AIF_LENGTH_32;
504 break; 504 break;
505 default: 505 default:
506 return -EINVAL; 506 return -EINVAL;
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 631385802eb4..e725c09a3e79 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -526,7 +526,7 @@ static int wm8731_probe(struct snd_soc_codec *codec)
526 snd_soc_update_bits(codec, WM8731_RINVOL, 0x100, 0); 526 snd_soc_update_bits(codec, WM8731_RINVOL, 0x100, 0);
527 527
528 /* Disable bypass path by default */ 528 /* Disable bypass path by default */
529 snd_soc_update_bits(codec, WM8731_APANA, 0x4, 0); 529 snd_soc_update_bits(codec, WM8731_APANA, 0x8, 0);
530 530
531 snd_soc_add_controls(codec, wm8731_snd_controls, 531 snd_soc_add_controls(codec, wm8731_snd_controls,
532 ARRAY_SIZE(wm8731_snd_controls)); 532 ARRAY_SIZE(wm8731_snd_controls));
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index 04182c464e35..0132a27140ae 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -34,7 +34,6 @@
34/* codec private data */ 34/* codec private data */
35struct wm8776_priv { 35struct wm8776_priv {
36 enum snd_soc_control_type control_type; 36 enum snd_soc_control_type control_type;
37 u16 reg_cache[WM8776_CACHEREGNUM];
38 int sysclk[2]; 37 int sysclk[2];
39}; 38};
40 39
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 33be84e506ea..9001cc48ba13 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -818,7 +818,8 @@ static int wm8904_get_deemph(struct snd_kcontrol *kcontrol,
818 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 818 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
819 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); 819 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
820 820
821 return wm8904->deemph; 821 ucontrol->value.enumerated.item[0] = wm8904->deemph;
822 return 0;
822} 823}
823 824
824static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, 825static int wm8904_put_deemph(struct snd_kcontrol *kcontrol,
@@ -2498,6 +2499,8 @@ static int wm8904_remove(struct snd_soc_codec *codec)
2498 2499
2499 wm8904_set_bias_level(codec, SND_SOC_BIAS_OFF); 2500 wm8904_set_bias_level(codec, SND_SOC_BIAS_OFF);
2500 regulator_bulk_free(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); 2501 regulator_bulk_free(ARRAY_SIZE(wm8904->supplies), wm8904->supplies);
2502 kfree(wm8904->retune_mobile_texts);
2503 kfree(wm8904->drc_texts);
2501 2504
2502 return 0; 2505 return 0;
2503} 2506}
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c
index f89ad6c9a80b..9cbab8e1de01 100644
--- a/sound/soc/codecs/wm8955.c
+++ b/sound/soc/codecs/wm8955.c
@@ -380,7 +380,8 @@ static int wm8955_get_deemph(struct snd_kcontrol *kcontrol,
380 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 380 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
381 struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); 381 struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
382 382
383 return wm8955->deemph; 383 ucontrol->value.enumerated.item[0] = wm8955->deemph;
384 return 0;
384} 385}
385 386
386static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, 387static int wm8955_put_deemph(struct snd_kcontrol *kcontrol,
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 8d5efb333c33..21986c42272f 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -138,7 +138,8 @@ static int wm8960_get_deemph(struct snd_kcontrol *kcontrol,
138 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 138 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
139 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 139 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
140 140
141 return wm8960->deemph; 141 ucontrol->value.enumerated.item[0] = wm8960->deemph;
142 return 0;
142} 143}
143 144
144static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, 145static int wm8960_put_deemph(struct snd_kcontrol *kcontrol,
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c
index 4f326f604104..8340485c9851 100644
--- a/sound/soc/codecs/wm8961.c
+++ b/sound/soc/codecs/wm8961.c
@@ -711,7 +711,7 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream,
711 if (fs <= 24000) 711 if (fs <= 24000)
712 reg |= WM8961_DACSLOPE; 712 reg |= WM8961_DACSLOPE;
713 else 713 else
714 reg &= WM8961_DACSLOPE; 714 reg &= ~WM8961_DACSLOPE;
715 snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg); 715 snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg);
716 716
717 return 0; 717 return 0;
@@ -736,7 +736,7 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id,
736 freq /= 2; 736 freq /= 2;
737 } else { 737 } else {
738 dev_dbg(codec->dev, "Using MCLK/1 for %dHz MCLK\n", freq); 738 dev_dbg(codec->dev, "Using MCLK/1 for %dHz MCLK\n", freq);
739 reg &= WM8961_MCLKDIV; 739 reg &= ~WM8961_MCLKDIV;
740 } 740 }
741 741
742 snd_soc_write(codec, WM8961_CLOCKING1, reg); 742 snd_soc_write(codec, WM8961_CLOCKING1, reg);
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 894d0cd3aa9b..1304ca91a11c 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3339,7 +3339,7 @@ static irqreturn_t wm8962_irq(int irq, void *data)
3339 int mask; 3339 int mask;
3340 int active; 3340 int active;
3341 3341
3342 mask = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2); 3342 mask = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2_MASK);
3343 3343
3344 active = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2); 3344 active = snd_soc_read(codec, WM8962_INTERRUPT_STATUS_2);
3345 active &= ~mask; 3345 active &= ~mask;
@@ -3500,8 +3500,11 @@ static ssize_t wm8962_beep_set(struct device *dev,
3500{ 3500{
3501 struct wm8962_priv *wm8962 = dev_get_drvdata(dev); 3501 struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
3502 long int time; 3502 long int time;
3503 int ret;
3503 3504
3504 strict_strtol(buf, 10, &time); 3505 ret = strict_strtol(buf, 10, &time);
3506 if (ret != 0)
3507 return ret;
3505 3508
3506 input_event(wm8962->beep, EV_SND, SND_TONE, time); 3509 input_event(wm8962->beep, EV_SND, SND_TONE, time);
3507 3510
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 0db59c3aa5d4..4d3e6f1ac584 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -3903,6 +3903,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3903 return -ENOMEM; 3903 return -ENOMEM;
3904 snd_soc_codec_set_drvdata(codec, wm8994); 3904 snd_soc_codec_set_drvdata(codec, wm8994);
3905 3905
3906 codec->reg_cache = &wm8994->reg_cache;
3907
3906 wm8994->pdata = dev_get_platdata(codec->dev->parent); 3908 wm8994->pdata = dev_get_platdata(codec->dev->parent);
3907 wm8994->codec = codec; 3909 wm8994->codec = codec;
3908 3910
@@ -4059,6 +4061,8 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
4059 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, wm8994); 4061 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, wm8994);
4060 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, wm8994); 4062 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, wm8994);
4061 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET, wm8994); 4063 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET, wm8994);
4064 kfree(wm8994->retune_mobile_texts);
4065 kfree(wm8994->drc_texts);
4062 kfree(wm8994); 4066 kfree(wm8994);
4063 4067
4064 return 0; 4068 return 0;
@@ -4071,6 +4075,8 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8994 = {
4071 .resume = wm8994_resume, 4075 .resume = wm8994_resume,
4072 .read = wm8994_read, 4076 .read = wm8994_read,
4073 .write = wm8994_write, 4077 .write = wm8994_write,
4078 .readable_register = wm8994_readable,
4079 .volatile_register = wm8994_volatile,
4074 .set_bias_level = wm8994_set_bias_level, 4080 .set_bias_level = wm8994_set_bias_level,
4075}; 4081};
4076 4082
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 19ca782ac970..0e24092722c3 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -293,7 +293,7 @@ SOC_DOUBLE_R("Speaker Switch",
293SOC_DOUBLE_R("Speaker ZC Switch", 293SOC_DOUBLE_R("Speaker ZC Switch",
294 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, 294 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
295 7, 1, 0), 295 7, 1, 0),
296SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 0, 3, 7, 0, 296SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 3, 0, 7, 0,
297 spkboost_tlv), 297 spkboost_tlv),
298SOC_ENUM("Speaker Reference", speaker_ref), 298SOC_ENUM("Speaker Reference", speaker_ref),
299SOC_ENUM("Speaker Mode", speaker_mode), 299SOC_ENUM("Speaker Mode", speaker_mode),
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 2b07b17a6b2d..bc9e6b0b3f6f 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -157,12 +157,23 @@ static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd)
157} 157}
158 158
159/* davinci-evm digital audio interface glue - connects codec <--> CPU */ 159/* davinci-evm digital audio interface glue - connects codec <--> CPU */
160static struct snd_soc_dai_link evm_dai = { 160static struct snd_soc_dai_link dm6446_evm_dai = {
161 .name = "TLV320AIC3X", 161 .name = "TLV320AIC3X",
162 .stream_name = "AIC3X", 162 .stream_name = "AIC3X",
163 .cpu_dai_name = "davinci-mcasp.0", 163 .cpu_dai_name = "davinci-mcbsp",
164 .codec_dai_name = "tlv320aic3x-hifi", 164 .codec_dai_name = "tlv320aic3x-hifi",
165 .codec_name = "tlv320aic3x-codec.0-001a", 165 .codec_name = "tlv320aic3x-codec.1-001b",
166 .platform_name = "davinci-pcm-audio",
167 .init = evm_aic3x_init,
168 .ops = &evm_ops,
169};
170
171static struct snd_soc_dai_link dm355_evm_dai = {
172 .name = "TLV320AIC3X",
173 .stream_name = "AIC3X",
174 .cpu_dai_name = "davinci-mcbsp.1",
175 .codec_dai_name = "tlv320aic3x-hifi",
176 .codec_name = "tlv320aic3x-codec.1-001b",
166 .platform_name = "davinci-pcm-audio", 177 .platform_name = "davinci-pcm-audio",
167 .init = evm_aic3x_init, 178 .init = evm_aic3x_init,
168 .ops = &evm_ops, 179 .ops = &evm_ops,
@@ -172,10 +183,10 @@ static struct snd_soc_dai_link dm365_evm_dai = {
172#ifdef CONFIG_SND_DM365_AIC3X_CODEC 183#ifdef CONFIG_SND_DM365_AIC3X_CODEC
173 .name = "TLV320AIC3X", 184 .name = "TLV320AIC3X",
174 .stream_name = "AIC3X", 185 .stream_name = "AIC3X",
175 .cpu_dai_name = "davinci-i2s", 186 .cpu_dai_name = "davinci-mcbsp",
176 .codec_dai_name = "tlv320aic3x-hifi", 187 .codec_dai_name = "tlv320aic3x-hifi",
177 .init = evm_aic3x_init, 188 .init = evm_aic3x_init,
178 .codec_name = "tlv320aic3x-codec.0-001a", 189 .codec_name = "tlv320aic3x-codec.1-0018",
179 .ops = &evm_ops, 190 .ops = &evm_ops,
180#elif defined(CONFIG_SND_DM365_VOICE_CODEC) 191#elif defined(CONFIG_SND_DM365_VOICE_CODEC)
181 .name = "Voice Codec - CQ93VC", 192 .name = "Voice Codec - CQ93VC",
@@ -219,10 +230,17 @@ static struct snd_soc_dai_link da8xx_evm_dai = {
219 .ops = &evm_ops, 230 .ops = &evm_ops,
220}; 231};
221 232
222/* davinci dm6446, dm355 evm audio machine driver */ 233/* davinci dm6446 evm audio machine driver */
223static struct snd_soc_card snd_soc_card_evm = { 234static struct snd_soc_card dm6446_snd_soc_card_evm = {
224 .name = "DaVinci EVM", 235 .name = "DaVinci DM6446 EVM",
225 .dai_link = &evm_dai, 236 .dai_link = &dm6446_evm_dai,
237 .num_links = 1,
238};
239
240/* davinci dm355 evm audio machine driver */
241static struct snd_soc_card dm355_snd_soc_card_evm = {
242 .name = "DaVinci DM355 EVM",
243 .dai_link = &dm355_evm_dai,
226 .num_links = 1, 244 .num_links = 1,
227}; 245};
228 246
@@ -261,10 +279,10 @@ static int __init evm_init(void)
261 int ret; 279 int ret;
262 280
263 if (machine_is_davinci_evm()) { 281 if (machine_is_davinci_evm()) {
264 evm_snd_dev_data = &snd_soc_card_evm; 282 evm_snd_dev_data = &dm6446_snd_soc_card_evm;
265 index = 0; 283 index = 0;
266 } else if (machine_is_davinci_dm355_evm()) { 284 } else if (machine_is_davinci_dm355_evm()) {
267 evm_snd_dev_data = &snd_soc_card_evm; 285 evm_snd_dev_data = &dm355_snd_soc_card_evm;
268 index = 1; 286 index = 1;
269 } else if (machine_is_davinci_dm365_evm()) { 287 } else if (machine_is_davinci_dm365_evm()) {
270 evm_snd_dev_data = &dm365_snd_soc_card_evm; 288 evm_snd_dev_data = &dm365_snd_soc_card_evm;
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index d46b545d41f4..9e0e565e6ed9 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -426,9 +426,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
426 snd_pcm_format_t fmt; 426 snd_pcm_format_t fmt;
427 unsigned element_cnt = 1; 427 unsigned element_cnt = 1;
428 428
429 dai->capture_dma_data = dev->dma_params;
430 dai->playback_dma_data = dev->dma_params;
431
432 /* general line settings */ 429 /* general line settings */
433 spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG); 430 spcr = davinci_mcbsp_read_reg(dev, DAVINCI_MCBSP_SPCR_REG);
434 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { 431 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
@@ -601,6 +598,15 @@ static int davinci_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
601 return ret; 598 return ret;
602} 599}
603 600
601static int davinci_i2s_startup(struct snd_pcm_substream *substream,
602 struct snd_soc_dai *dai)
603{
604 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
605
606 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
607 return 0;
608}
609
604static void davinci_i2s_shutdown(struct snd_pcm_substream *substream, 610static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
605 struct snd_soc_dai *dai) 611 struct snd_soc_dai *dai)
606{ 612{
@@ -612,6 +618,7 @@ static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
612#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 618#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000
613 619
614static struct snd_soc_dai_ops davinci_i2s_dai_ops = { 620static struct snd_soc_dai_ops davinci_i2s_dai_ops = {
621 .startup = davinci_i2s_startup,
615 .shutdown = davinci_i2s_shutdown, 622 .shutdown = davinci_i2s_shutdown,
616 .prepare = davinci_i2s_prepare, 623 .prepare = davinci_i2s_prepare,
617 .trigger = davinci_i2s_trigger, 624 .trigger = davinci_i2s_trigger,
@@ -749,7 +756,7 @@ static struct platform_driver davinci_mcbsp_driver = {
749 .probe = davinci_i2s_probe, 756 .probe = davinci_i2s_probe,
750 .remove = davinci_i2s_remove, 757 .remove = davinci_i2s_remove,
751 .driver = { 758 .driver = {
752 .name = "davinci-i2s", 759 .name = "davinci-mcbsp",
753 .owner = THIS_MODULE, 760 .owner = THIS_MODULE,
754 }, 761 },
755}; 762};
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 86918ee12419..fb55d2c5d704 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -715,9 +715,6 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
715 int word_length; 715 int word_length;
716 u8 fifo_level; 716 u8 fifo_level;
717 717
718 cpu_dai->capture_dma_data = dev->dma_params;
719 cpu_dai->playback_dma_data = dev->dma_params;
720
721 davinci_hw_common_param(dev, substream->stream); 718 davinci_hw_common_param(dev, substream->stream);
722 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 719 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
723 fifo_level = dev->txnumevt; 720 fifo_level = dev->txnumevt;
@@ -799,7 +796,17 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
799 return ret; 796 return ret;
800} 797}
801 798
799static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
800 struct snd_soc_dai *dai)
801{
802 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai);
803
804 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
805 return 0;
806}
807
802static struct snd_soc_dai_ops davinci_mcasp_dai_ops = { 808static struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
809 .startup = davinci_mcasp_startup,
803 .trigger = davinci_mcasp_trigger, 810 .trigger = davinci_mcasp_trigger,
804 .hw_params = davinci_mcasp_hw_params, 811 .hw_params = davinci_mcasp_hw_params,
805 .set_fmt = davinci_mcasp_set_dai_fmt, 812 .set_fmt = davinci_mcasp_set_dai_fmt,
diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c
index 009b6521a1bf..6c6666a1f942 100644
--- a/sound/soc/davinci/davinci-sffsdr.c
+++ b/sound/soc/davinci/davinci-sffsdr.c
@@ -84,7 +84,7 @@ static struct snd_soc_ops sffsdr_ops = {
84static struct snd_soc_dai_link sffsdr_dai = { 84static struct snd_soc_dai_link sffsdr_dai = {
85 .name = "PCM3008", /* Codec name */ 85 .name = "PCM3008", /* Codec name */
86 .stream_name = "PCM3008 HiFi", 86 .stream_name = "PCM3008 HiFi",
87 .cpu_dai_name = "davinci-asp.0", 87 .cpu_dai_name = "davinci-mcbsp",
88 .codec_dai_name = "pcm3008-hifi", 88 .codec_dai_name = "pcm3008-hifi",
89 .codec_name = "pcm3008-codec", 89 .codec_name = "pcm3008-codec",
90 .platform_name = "davinci-pcm-audio", 90 .platform_name = "davinci-pcm-audio",
diff --git a/sound/soc/davinci/davinci-vcif.c b/sound/soc/davinci/davinci-vcif.c
index ea232f6a2c21..9d2afccc3a2d 100644
--- a/sound/soc/davinci/davinci-vcif.c
+++ b/sound/soc/davinci/davinci-vcif.c
@@ -97,9 +97,6 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
97 &davinci_vcif_dev->dma_params[substream->stream]; 97 &davinci_vcif_dev->dma_params[substream->stream];
98 u32 w; 98 u32 w;
99 99
100 dai->capture_dma_data = davinci_vcif_dev->dma_params;
101 dai->playback_dma_data = davinci_vcif_dev->dma_params;
102
103 /* Restart the codec before setup */ 100 /* Restart the codec before setup */
104 davinci_vcif_stop(substream); 101 davinci_vcif_stop(substream);
105 davinci_vcif_start(substream); 102 davinci_vcif_start(substream);
@@ -174,9 +171,19 @@ static int davinci_vcif_trigger(struct snd_pcm_substream *substream, int cmd,
174 return ret; 171 return ret;
175} 172}
176 173
174static int davinci_vcif_startup(struct snd_pcm_substream *substream,
175 struct snd_soc_dai *dai)
176{
177 struct davinci_vcif_dev *dev = snd_soc_dai_get_drvdata(dai);
178
179 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
180 return 0;
181}
182
177#define DAVINCI_VCIF_RATES SNDRV_PCM_RATE_8000_48000 183#define DAVINCI_VCIF_RATES SNDRV_PCM_RATE_8000_48000
178 184
179static struct snd_soc_dai_ops davinci_vcif_dai_ops = { 185static struct snd_soc_dai_ops davinci_vcif_dai_ops = {
186 .startup = davinci_vcif_startup,
180 .trigger = davinci_vcif_trigger, 187 .trigger = davinci_vcif_trigger,
181 .hw_params = davinci_vcif_hw_params, 188 .hw_params = davinci_vcif_hw_params,
182}; 189};
@@ -240,7 +247,10 @@ fail:
240 247
241static int davinci_vcif_remove(struct platform_device *pdev) 248static int davinci_vcif_remove(struct platform_device *pdev)
242{ 249{
250 struct davinci_vcif_dev *davinci_vcif_dev = dev_get_drvdata(&pdev->dev);
251
243 snd_soc_unregister_dai(&pdev->dev); 252 snd_soc_unregister_dai(&pdev->dev);
253 kfree(davinci_vcif_dev);
244 254
245 return 0; 255 return 0;
246} 256}
diff --git a/sound/soc/ep93xx/simone.c b/sound/soc/ep93xx/simone.c
index 4b0d19913728..286817946c56 100644
--- a/sound/soc/ep93xx/simone.c
+++ b/sound/soc/ep93xx/simone.c
@@ -54,24 +54,26 @@ static int __init simone_init(void)
54 54
55 ret = platform_device_add(simone_snd_ac97_device); 55 ret = platform_device_add(simone_snd_ac97_device);
56 if (ret) 56 if (ret)
57 goto fail; 57 goto fail1;
58 58
59 simone_snd_device = platform_device_alloc("soc-audio", -1); 59 simone_snd_device = platform_device_alloc("soc-audio", -1);
60 if (!simone_snd_device) { 60 if (!simone_snd_device) {
61 ret = -ENOMEM; 61 ret = -ENOMEM;
62 goto fail; 62 goto fail2;
63 } 63 }
64 64
65 platform_set_drvdata(simone_snd_device, &snd_soc_simone); 65 platform_set_drvdata(simone_snd_device, &snd_soc_simone);
66 ret = platform_device_add(simone_snd_device); 66 ret = platform_device_add(simone_snd_device);
67 if (ret) { 67 if (ret)
68 platform_device_put(simone_snd_device); 68 goto fail3;
69 goto fail;
70 }
71 69
72 return ret; 70 return 0;
73 71
74fail: 72fail3:
73 platform_device_put(simone_snd_device);
74fail2:
75 platform_device_del(simone_snd_ac97_device);
76fail1:
75 platform_device_put(simone_snd_ac97_device); 77 platform_device_put(simone_snd_ac97_device);
76 return ret; 78 return ret;
77} 79}
diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c
index 53251e6b5bd5..108b5d8bd0e9 100644
--- a/sound/soc/fsl/efika-audio-fabric.c
+++ b/sound/soc/fsl/efika-audio-fabric.c
@@ -76,6 +76,7 @@ static __init int efika_fabric_init(void)
76 rc = platform_device_add(pdev); 76 rc = platform_device_add(pdev);
77 if (rc) { 77 if (rc) {
78 pr_err("efika_fabric_init: platform_device_add() failed\n"); 78 pr_err("efika_fabric_init: platform_device_add() failed\n");
79 platform_device_put(pdev);
79 return -ENODEV; 80 return -ENODEV;
80 } 81 }
81 return 0; 82 return 0;
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
index dce6b551cd78..f92dca07cd35 100644
--- a/sound/soc/fsl/mpc5200_dma.c
+++ b/sound/soc/fsl/mpc5200_dma.c
@@ -9,7 +9,6 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/of_device.h> 10#include <linux/of_device.h>
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/of_device.h>
13#include <linux/of_platform.h> 12#include <linux/of_platform.h>
14 13
15#include <sound/soc.h> 14#include <sound/soc.h>
diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c
index 74ffed41340f..9018fa5bf0db 100644
--- a/sound/soc/fsl/mpc5200_psc_i2s.c
+++ b/sound/soc/fsl/mpc5200_psc_i2s.c
@@ -160,7 +160,7 @@ static int __devinit psc_i2s_of_probe(struct platform_device *op,
160 rc = snd_soc_register_dais(&op->dev, psc_i2s_dai, ARRAY_SIZE(psc_i2s_dai)); 160 rc = snd_soc_register_dais(&op->dev, psc_i2s_dai, ARRAY_SIZE(psc_i2s_dai));
161 if (rc != 0) { 161 if (rc != 0) {
162 pr_err("Failed to register DAI\n"); 162 pr_err("Failed to register DAI\n");
163 return 0; 163 return rc;
164 } 164 }
165 165
166 psc_dma = dev_get_drvdata(&op->dev); 166 psc_dma = dev_get_drvdata(&op->dev);
diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c
index 0d7dcf1e4863..7d7847a1e66b 100644
--- a/sound/soc/fsl/mpc8610_hpcd.c
+++ b/sound/soc/fsl/mpc8610_hpcd.c
@@ -498,6 +498,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
498 dev_err(&pdev->dev, "platform device add failed\n"); 498 dev_err(&pdev->dev, "platform device add failed\n");
499 goto error; 499 goto error;
500 } 500 }
501 dev_set_drvdata(&pdev->dev, sound_device);
501 502
502 of_node_put(codec_np); 503 of_node_put(codec_np);
503 504
diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c
index 63b9eaa1ebc2..026b756961e0 100644
--- a/sound/soc/fsl/p1022_ds.c
+++ b/sound/soc/fsl/p1022_ds.c
@@ -498,6 +498,7 @@ static int p1022_ds_probe(struct platform_device *pdev)
498 dev_err(&pdev->dev, "platform device add failed\n"); 498 dev_err(&pdev->dev, "platform device add failed\n");
499 goto error; 499 goto error;
500 } 500 }
501 dev_set_drvdata(&pdev->dev, sound_device);
501 502
502 of_node_put(codec_np); 503 of_node_put(codec_np);
503 504
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index 25f27ec1dd6e..ba4d85e317ed 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -76,6 +76,7 @@ static __init int pcm030_fabric_init(void)
76 rc = platform_device_add(pdev); 76 rc = platform_device_add(pdev);
77 if (rc) { 77 if (rc) {
78 pr_err("pcm030_fabric_init: platform_device_add() failed\n"); 78 pr_err("pcm030_fabric_init: platform_device_add() failed\n");
79 platform_device_put(pdev);
79 return -ENODEV; 80 return -ENODEV;
80 } 81 }
81 return 0; 82 return 0;
diff --git a/sound/soc/imx/eukrea-tlv320.c b/sound/soc/imx/eukrea-tlv320.c
index b59675257ce5..dd4fffdbd177 100644
--- a/sound/soc/imx/eukrea-tlv320.c
+++ b/sound/soc/imx/eukrea-tlv320.c
@@ -34,8 +34,8 @@ static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream,
34 struct snd_pcm_hw_params *params) 34 struct snd_pcm_hw_params *params)
35{ 35{
36 struct snd_soc_pcm_runtime *rtd = substream->private_data; 36 struct snd_soc_pcm_runtime *rtd = substream->private_data;
37 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 37 struct snd_soc_dai *codec_dai = rtd->codec_dai;
38 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 38 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
39 int ret; 39 int ret;
40 40
41 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | 41 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
@@ -79,10 +79,10 @@ static struct snd_soc_ops eukrea_tlv320_snd_ops = {
79static struct snd_soc_dai_link eukrea_tlv320_dai = { 79static struct snd_soc_dai_link eukrea_tlv320_dai = {
80 .name = "tlv320aic23", 80 .name = "tlv320aic23",
81 .stream_name = "TLV320AIC23", 81 .stream_name = "TLV320AIC23",
82 .codec_dai = "tlv320aic23-hifi", 82 .codec_dai_name = "tlv320aic23-hifi",
83 .platform_name = "imx-pcm-audio.0", 83 .platform_name = "imx-pcm-audio.0",
84 .codec_name = "tlv320aic23-codec.0-001a", 84 .codec_name = "tlv320aic23-codec.0-001a",
85 .cpu_dai = "imx-ssi.0", 85 .cpu_dai_name = "imx-ssi.0",
86 .ops = &eukrea_tlv320_snd_ops, 86 .ops = &eukrea_tlv320_snd_ops,
87}; 87};
88 88
diff --git a/sound/soc/imx/imx-pcm-dma-mx2.c b/sound/soc/imx/imx-pcm-dma-mx2.c
index fd493ee1428e..671ef8dd524c 100644
--- a/sound/soc/imx/imx-pcm-dma-mx2.c
+++ b/sound/soc/imx/imx-pcm-dma-mx2.c
@@ -20,6 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/dmaengine.h>
23 24
24#include <sound/core.h> 25#include <sound/core.h>
25#include <sound/initval.h> 26#include <sound/initval.h>
@@ -27,165 +28,146 @@
27#include <sound/pcm_params.h> 28#include <sound/pcm_params.h>
28#include <sound/soc.h> 29#include <sound/soc.h>
29 30
30#include <mach/dma-mx1-mx2.h> 31#include <mach/dma.h>
31 32
32#include "imx-ssi.h" 33#include "imx-ssi.h"
33 34
34struct imx_pcm_runtime_data { 35struct imx_pcm_runtime_data {
35 int sg_count; 36 int period_bytes;
36 struct scatterlist *sg_list;
37 int period;
38 int periods; 37 int periods;
39 unsigned long dma_addr;
40 int dma; 38 int dma;
41 struct snd_pcm_substream *substream;
42 unsigned long offset; 39 unsigned long offset;
43 unsigned long size; 40 unsigned long size;
44 unsigned long period_cnt;
45 void *buf; 41 void *buf;
46 int period_time; 42 int period_time;
43 struct dma_async_tx_descriptor *desc;
44 struct dma_chan *dma_chan;
45 struct imx_dma_data dma_data;
47}; 46};
48 47
49/* Called by the DMA framework when a period has elapsed */ 48static void audio_dma_irq(void *data)
50static void imx_ssi_dma_progression(int channel, void *data,
51 struct scatterlist *sg)
52{ 49{
53 struct snd_pcm_substream *substream = data; 50 struct snd_pcm_substream *substream = (struct snd_pcm_substream *)data;
54 struct snd_pcm_runtime *runtime = substream->runtime; 51 struct snd_pcm_runtime *runtime = substream->runtime;
55 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 52 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
56 53
57 if (!sg) 54 iprtd->offset += iprtd->period_bytes;
58 return; 55 iprtd->offset %= iprtd->period_bytes * iprtd->periods;
59
60 runtime = iprtd->substream->runtime;
61 56
62 iprtd->offset = sg->dma_address - runtime->dma_addr; 57 snd_pcm_period_elapsed(substream);
63
64 snd_pcm_period_elapsed(iprtd->substream);
65} 58}
66 59
67static void imx_ssi_dma_callback(int channel, void *data) 60static bool filter(struct dma_chan *chan, void *param)
68{ 61{
69 pr_err("%s shouldn't be called\n", __func__); 62 struct imx_pcm_runtime_data *iprtd = param;
70}
71 63
72static void snd_imx_dma_err_callback(int channel, void *data, int err) 64 if (!imx_dma_is_general_purpose(chan))
73{ 65 return false;
74 struct snd_pcm_substream *substream = data;
75 struct snd_soc_pcm_runtime *rtd = substream->private_data;
76 struct imx_pcm_dma_params *dma_params =
77 snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream);
78 struct snd_pcm_runtime *runtime = substream->runtime;
79 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
80 int ret;
81 66
82 pr_err("DMA timeout on channel %d -%s%s%s%s\n", 67 chan->private = &iprtd->dma_data;
83 channel,
84 err & IMX_DMA_ERR_BURST ? " burst" : "",
85 err & IMX_DMA_ERR_REQUEST ? " request" : "",
86 err & IMX_DMA_ERR_TRANSFER ? " transfer" : "",
87 err & IMX_DMA_ERR_BUFFER ? " buffer" : "");
88 68
89 imx_dma_disable(iprtd->dma); 69 return true;
90 ret = imx_dma_setup_sg(iprtd->dma, iprtd->sg_list, iprtd->sg_count,
91 IMX_DMA_LENGTH_LOOP, dma_params->dma_addr,
92 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
93 DMA_MODE_WRITE : DMA_MODE_READ);
94 if (!ret)
95 imx_dma_enable(iprtd->dma);
96} 70}
97 71
98static int imx_ssi_dma_alloc(struct snd_pcm_substream *substream) 72static int imx_ssi_dma_alloc(struct snd_pcm_substream *substream,
73 struct snd_pcm_hw_params *params)
99{ 74{
100 struct snd_soc_pcm_runtime *rtd = substream->private_data; 75 struct snd_soc_pcm_runtime *rtd = substream->private_data;
101 struct imx_pcm_dma_params *dma_params; 76 struct imx_pcm_dma_params *dma_params;
102 struct snd_pcm_runtime *runtime = substream->runtime; 77 struct snd_pcm_runtime *runtime = substream->runtime;
103 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 78 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
79 struct dma_slave_config slave_config;
80 dma_cap_mask_t mask;
81 enum dma_slave_buswidth buswidth;
104 int ret; 82 int ret;
105 83
106 dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 84 dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
107 85
108 iprtd->dma = imx_dma_request_by_prio(DRV_NAME, DMA_PRIO_HIGH); 86 iprtd->dma_data.peripheral_type = IMX_DMATYPE_SSI;
109 if (iprtd->dma < 0) { 87 iprtd->dma_data.priority = DMA_PRIO_HIGH;
110 pr_err("Failed to claim the audio DMA\n"); 88 iprtd->dma_data.dma_request = dma_params->dma;
111 return -ENODEV;
112 }
113 89
114 ret = imx_dma_setup_handlers(iprtd->dma, 90 /* Try to grab a DMA channel */
115 imx_ssi_dma_callback, 91 dma_cap_zero(mask);
116 snd_imx_dma_err_callback, substream); 92 dma_cap_set(DMA_SLAVE, mask);
117 if (ret) 93 iprtd->dma_chan = dma_request_channel(mask, filter, iprtd);
118 goto out; 94 if (!iprtd->dma_chan)
95 return -EINVAL;
119 96
120 ret = imx_dma_setup_progression_handler(iprtd->dma, 97 switch (params_format(params)) {
121 imx_ssi_dma_progression); 98 case SNDRV_PCM_FORMAT_S16_LE:
122 if (ret) { 99 buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
123 pr_err("Failed to setup the DMA handler\n"); 100 break;
124 goto out; 101 case SNDRV_PCM_FORMAT_S20_3LE:
102 case SNDRV_PCM_FORMAT_S24_LE:
103 buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
104 break;
105 default:
106 return 0;
125 } 107 }
126 108
127 ret = imx_dma_config_channel(iprtd->dma, 109 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
128 IMX_DMA_MEMSIZE_16 | IMX_DMA_TYPE_FIFO, 110 slave_config.direction = DMA_TO_DEVICE;
129 IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR, 111 slave_config.dst_addr = dma_params->dma_addr;
130 dma_params->dma, 1); 112 slave_config.dst_addr_width = buswidth;
131 if (ret < 0) { 113 slave_config.dst_maxburst = dma_params->burstsize;
132 pr_err("Cannot configure DMA channel: %d\n", ret); 114 } else {
133 goto out; 115 slave_config.direction = DMA_FROM_DEVICE;
116 slave_config.src_addr = dma_params->dma_addr;
117 slave_config.src_addr_width = buswidth;
118 slave_config.src_maxburst = dma_params->burstsize;
134 } 119 }
135 120
136 imx_dma_config_burstlen(iprtd->dma, dma_params->burstsize * 2); 121 ret = dmaengine_slave_config(iprtd->dma_chan, &slave_config);
122 if (ret)
123 return ret;
137 124
138 return 0; 125 return 0;
139out:
140 imx_dma_free(iprtd->dma);
141 return ret;
142} 126}
143 127
144static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, 128static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream,
145 struct snd_pcm_hw_params *params) 129 struct snd_pcm_hw_params *params)
146{ 130{
131 struct snd_soc_pcm_runtime *rtd = substream->private_data;
147 struct snd_pcm_runtime *runtime = substream->runtime; 132 struct snd_pcm_runtime *runtime = substream->runtime;
148 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 133 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
149 int i;
150 unsigned long dma_addr; 134 unsigned long dma_addr;
135 struct dma_chan *chan;
136 struct imx_pcm_dma_params *dma_params;
137 int ret;
151 138
152 imx_ssi_dma_alloc(substream); 139 dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
140 ret = imx_ssi_dma_alloc(substream, params);
141 if (ret)
142 return ret;
143 chan = iprtd->dma_chan;
153 144
154 iprtd->size = params_buffer_bytes(params); 145 iprtd->size = params_buffer_bytes(params);
155 iprtd->periods = params_periods(params); 146 iprtd->periods = params_periods(params);
156 iprtd->period = params_period_bytes(params); 147 iprtd->period_bytes = params_period_bytes(params);
157 iprtd->offset = 0; 148 iprtd->offset = 0;
158 iprtd->period_time = HZ / (params_rate(params) / 149 iprtd->period_time = HZ / (params_rate(params) /
159 params_period_size(params)); 150 params_period_size(params));
160 151
161 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); 152 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
162 153
163 if (iprtd->sg_count != iprtd->periods) {
164 kfree(iprtd->sg_list);
165
166 iprtd->sg_list = kcalloc(iprtd->periods + 1,
167 sizeof(struct scatterlist), GFP_KERNEL);
168 if (!iprtd->sg_list)
169 return -ENOMEM;
170 iprtd->sg_count = iprtd->periods + 1;
171 }
172
173 sg_init_table(iprtd->sg_list, iprtd->sg_count);
174 dma_addr = runtime->dma_addr; 154 dma_addr = runtime->dma_addr;
175 155
176 for (i = 0; i < iprtd->periods; i++) { 156 iprtd->buf = (unsigned int *)substream->dma_buffer.area;
177 iprtd->sg_list[i].page_link = 0; 157
178 iprtd->sg_list[i].offset = 0; 158 iprtd->desc = chan->device->device_prep_dma_cyclic(chan, dma_addr,
179 iprtd->sg_list[i].dma_address = dma_addr; 159 iprtd->period_bytes * iprtd->periods,
180 iprtd->sg_list[i].length = iprtd->period; 160 iprtd->period_bytes,
181 dma_addr += iprtd->period; 161 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
162 DMA_TO_DEVICE : DMA_FROM_DEVICE);
163 if (!iprtd->desc) {
164 dev_err(&chan->dev->device, "cannot prepare slave dma\n");
165 return -EINVAL;
182 } 166 }
183 167
184 /* close the loop */ 168 iprtd->desc->callback = audio_dma_irq;
185 iprtd->sg_list[iprtd->sg_count - 1].offset = 0; 169 iprtd->desc->callback_param = substream;
186 iprtd->sg_list[iprtd->sg_count - 1].length = 0; 170
187 iprtd->sg_list[iprtd->sg_count - 1].page_link =
188 ((unsigned long) iprtd->sg_list | 0x01) & ~0x02;
189 return 0; 171 return 0;
190} 172}
191 173
@@ -194,41 +176,21 @@ static int snd_imx_pcm_hw_free(struct snd_pcm_substream *substream)
194 struct snd_pcm_runtime *runtime = substream->runtime; 176 struct snd_pcm_runtime *runtime = substream->runtime;
195 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 177 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
196 178
197 if (iprtd->dma >= 0) { 179 if (iprtd->dma_chan) {
198 imx_dma_free(iprtd->dma); 180 dma_release_channel(iprtd->dma_chan);
199 iprtd->dma = -EINVAL; 181 iprtd->dma_chan = NULL;
200 } 182 }
201 183
202 kfree(iprtd->sg_list);
203 iprtd->sg_list = NULL;
204
205 return 0; 184 return 0;
206} 185}
207 186
208static int snd_imx_pcm_prepare(struct snd_pcm_substream *substream) 187static int snd_imx_pcm_prepare(struct snd_pcm_substream *substream)
209{ 188{
210 struct snd_pcm_runtime *runtime = substream->runtime;
211 struct snd_soc_pcm_runtime *rtd = substream->private_data; 189 struct snd_soc_pcm_runtime *rtd = substream->private_data;
212 struct imx_pcm_dma_params *dma_params; 190 struct imx_pcm_dma_params *dma_params;
213 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
214 int err;
215 191
216 dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 192 dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
217 193
218 iprtd->substream = substream;
219 iprtd->buf = (unsigned int *)substream->dma_buffer.area;
220 iprtd->period_cnt = 0;
221
222 pr_debug("%s: buf: %p period: %d periods: %d\n",
223 __func__, iprtd->buf, iprtd->period, iprtd->periods);
224
225 err = imx_dma_setup_sg(iprtd->dma, iprtd->sg_list, iprtd->sg_count,
226 IMX_DMA_LENGTH_LOOP, dma_params->dma_addr,
227 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
228 DMA_MODE_WRITE : DMA_MODE_READ);
229 if (err)
230 return err;
231
232 return 0; 194 return 0;
233} 195}
234 196
@@ -241,14 +203,14 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
241 case SNDRV_PCM_TRIGGER_START: 203 case SNDRV_PCM_TRIGGER_START:
242 case SNDRV_PCM_TRIGGER_RESUME: 204 case SNDRV_PCM_TRIGGER_RESUME:
243 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 205 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
244 imx_dma_enable(iprtd->dma); 206 dmaengine_submit(iprtd->desc);
245 207
246 break; 208 break;
247 209
248 case SNDRV_PCM_TRIGGER_STOP: 210 case SNDRV_PCM_TRIGGER_STOP:
249 case SNDRV_PCM_TRIGGER_SUSPEND: 211 case SNDRV_PCM_TRIGGER_SUSPEND:
250 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 212 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
251 imx_dma_disable(iprtd->dma); 213 dmaengine_terminate_all(iprtd->dma_chan);
252 214
253 break; 215 break;
254 default: 216 default:
@@ -263,6 +225,9 @@ static snd_pcm_uframes_t snd_imx_pcm_pointer(struct snd_pcm_substream *substream
263 struct snd_pcm_runtime *runtime = substream->runtime; 225 struct snd_pcm_runtime *runtime = substream->runtime;
264 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 226 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
265 227
228 pr_debug("%s: %ld %ld\n", __func__, iprtd->offset,
229 bytes_to_frames(substream->runtime, iprtd->offset));
230
266 return bytes_to_frames(substream->runtime, iprtd->offset); 231 return bytes_to_frames(substream->runtime, iprtd->offset);
267} 232}
268 233
@@ -279,7 +244,7 @@ static struct snd_pcm_hardware snd_imx_hardware = {
279 .channels_max = 2, 244 .channels_max = 2,
280 .buffer_bytes_max = IMX_SSI_DMABUF_SIZE, 245 .buffer_bytes_max = IMX_SSI_DMABUF_SIZE,
281 .period_bytes_min = 128, 246 .period_bytes_min = 128,
282 .period_bytes_max = 16 * 1024, 247 .period_bytes_max = 65535, /* Limited by SDMA engine */
283 .periods_min = 2, 248 .periods_min = 2,
284 .periods_max = 255, 249 .periods_max = 255,
285 .fifo_size = 0, 250 .fifo_size = 0,
@@ -304,11 +269,23 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
304 } 269 }
305 270
306 snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); 271 snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware);
272
273 return 0;
274}
275
276static int snd_imx_close(struct snd_pcm_substream *substream)
277{
278 struct snd_pcm_runtime *runtime = substream->runtime;
279 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
280
281 kfree(iprtd);
282
307 return 0; 283 return 0;
308} 284}
309 285
310static struct snd_pcm_ops imx_pcm_ops = { 286static struct snd_pcm_ops imx_pcm_ops = {
311 .open = snd_imx_open, 287 .open = snd_imx_open,
288 .close = snd_imx_close,
312 .ioctl = snd_pcm_lib_ioctl, 289 .ioctl = snd_pcm_lib_ioctl,
313 .hw_params = snd_imx_pcm_hw_params, 290 .hw_params = snd_imx_pcm_hw_params,
314 .hw_free = snd_imx_pcm_hw_free, 291 .hw_free = snd_imx_pcm_hw_free,
@@ -340,7 +317,6 @@ static struct platform_driver imx_pcm_driver = {
340 .name = "imx-pcm-audio", 317 .name = "imx-pcm-audio",
341 .owner = THIS_MODULE, 318 .owner = THIS_MODULE,
342 }, 319 },
343
344 .probe = imx_soc_platform_probe, 320 .probe = imx_soc_platform_probe,
345 .remove = __devexit_p(imx_soc_platform_remove), 321 .remove = __devexit_p(imx_soc_platform_remove),
346}; 322};
@@ -356,4 +332,3 @@ static void __exit snd_imx_pcm_exit(void)
356 platform_driver_unregister(&imx_pcm_driver); 332 platform_driver_unregister(&imx_pcm_driver);
357} 333}
358module_exit(snd_imx_pcm_exit); 334module_exit(snd_imx_pcm_exit);
359
diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c
index d4bd345b0a8d..390b6ffc2658 100644
--- a/sound/soc/imx/imx-ssi.c
+++ b/sound/soc/imx/imx-ssi.c
@@ -439,7 +439,22 @@ void imx_pcm_free(struct snd_pcm *pcm)
439} 439}
440EXPORT_SYMBOL_GPL(imx_pcm_free); 440EXPORT_SYMBOL_GPL(imx_pcm_free);
441 441
442static int imx_ssi_dai_probe(struct snd_soc_dai *dai)
443{
444 struct imx_ssi *ssi = dev_get_drvdata(dai->dev);
445 uint32_t val;
446
447 snd_soc_dai_set_drvdata(dai, ssi);
448
449 val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.burstsize) |
450 SSI_SFCSR_RFWM0(ssi->dma_params_rx.burstsize);
451 writel(val, ssi->base + SSI_SFCSR);
452
453 return 0;
454}
455
442static struct snd_soc_dai_driver imx_ssi_dai = { 456static struct snd_soc_dai_driver imx_ssi_dai = {
457 .probe = imx_ssi_dai_probe,
443 .playback = { 458 .playback = {
444 .channels_min = 2, 459 .channels_min = 2,
445 .channels_max = 2, 460 .channels_max = 2,
@@ -455,20 +470,6 @@ static struct snd_soc_dai_driver imx_ssi_dai = {
455 .ops = &imx_ssi_pcm_dai_ops, 470 .ops = &imx_ssi_pcm_dai_ops,
456}; 471};
457 472
458static int imx_ssi_dai_probe(struct snd_soc_dai *dai)
459{
460 struct imx_ssi *ssi = dev_get_drvdata(dai->dev);
461 uint32_t val;
462
463 snd_soc_dai_set_drvdata(dai, ssi);
464
465 val = SSI_SFCSR_TFWM0(ssi->dma_params_tx.burstsize) |
466 SSI_SFCSR_RFWM0(ssi->dma_params_rx.burstsize);
467 writel(val, ssi->base + SSI_SFCSR);
468
469 return 0;
470}
471
472static struct snd_soc_dai_driver imx_ac97_dai = { 473static struct snd_soc_dai_driver imx_ac97_dai = {
473 .probe = imx_ssi_dai_probe, 474 .probe = imx_ssi_dai_probe,
474 .ac97_control = 1, 475 .ac97_control = 1,
@@ -677,9 +678,25 @@ static int imx_ssi_probe(struct platform_device *pdev)
677 goto failed_register; 678 goto failed_register;
678 } 679 }
679 680
680 ssi->soc_platform_pdev = platform_device_alloc("imx-fiq-pcm-audio", pdev->id); 681 ssi->soc_platform_pdev_fiq = platform_device_alloc("imx-fiq-pcm-audio", pdev->id);
681 if (!ssi->soc_platform_pdev) 682 if (!ssi->soc_platform_pdev_fiq) {
683 ret = -ENOMEM;
684 goto failed_pdev_fiq_alloc;
685 }
686
687 platform_set_drvdata(ssi->soc_platform_pdev_fiq, ssi);
688 ret = platform_device_add(ssi->soc_platform_pdev_fiq);
689 if (ret) {
690 dev_err(&pdev->dev, "failed to add platform device\n");
691 goto failed_pdev_fiq_add;
692 }
693
694 ssi->soc_platform_pdev = platform_device_alloc("imx-pcm-audio", pdev->id);
695 if (!ssi->soc_platform_pdev) {
696 ret = -ENOMEM;
682 goto failed_pdev_alloc; 697 goto failed_pdev_alloc;
698 }
699
683 platform_set_drvdata(ssi->soc_platform_pdev, ssi); 700 platform_set_drvdata(ssi->soc_platform_pdev, ssi);
684 ret = platform_device_add(ssi->soc_platform_pdev); 701 ret = platform_device_add(ssi->soc_platform_pdev);
685 if (ret) { 702 if (ret) {
@@ -692,6 +709,10 @@ static int imx_ssi_probe(struct platform_device *pdev)
692failed_pdev_add: 709failed_pdev_add:
693 platform_device_put(ssi->soc_platform_pdev); 710 platform_device_put(ssi->soc_platform_pdev);
694failed_pdev_alloc: 711failed_pdev_alloc:
712 platform_device_del(ssi->soc_platform_pdev_fiq);
713failed_pdev_fiq_add:
714 platform_device_put(ssi->soc_platform_pdev_fiq);
715failed_pdev_fiq_alloc:
695 snd_soc_unregister_dai(&pdev->dev); 716 snd_soc_unregister_dai(&pdev->dev);
696failed_register: 717failed_register:
697failed_ac97: 718failed_ac97:
@@ -712,8 +733,8 @@ static int __devexit imx_ssi_remove(struct platform_device *pdev)
712 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 733 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
713 struct imx_ssi *ssi = platform_get_drvdata(pdev); 734 struct imx_ssi *ssi = platform_get_drvdata(pdev);
714 735
715 platform_device_del(ssi->soc_platform_pdev); 736 platform_device_unregister(ssi->soc_platform_pdev);
716 platform_device_put(ssi->soc_platform_pdev); 737 platform_device_unregister(ssi->soc_platform_pdev_fiq);
717 738
718 snd_soc_unregister_dai(&pdev->dev); 739 snd_soc_unregister_dai(&pdev->dev);
719 740
diff --git a/sound/soc/imx/imx-ssi.h b/sound/soc/imx/imx-ssi.h
index 53b780d9b2b0..a4406a134892 100644
--- a/sound/soc/imx/imx-ssi.h
+++ b/sound/soc/imx/imx-ssi.h
@@ -185,6 +185,9 @@
185 185
186#define DRV_NAME "imx-ssi" 186#define DRV_NAME "imx-ssi"
187 187
188#include <linux/dmaengine.h>
189#include <mach/dma.h>
190
188struct imx_pcm_dma_params { 191struct imx_pcm_dma_params {
189 int dma; 192 int dma;
190 unsigned long dma_addr; 193 unsigned long dma_addr;
@@ -212,6 +215,7 @@ struct imx_ssi {
212 int enabled; 215 int enabled;
213 216
214 struct platform_device *soc_platform_pdev; 217 struct platform_device *soc_platform_pdev;
218 struct platform_device *soc_platform_pdev_fiq;
215}; 219};
216 220
217struct snd_soc_platform *imx_ssi_fiq_init(struct platform_device *pdev, 221struct snd_soc_platform *imx_ssi_fiq_init(struct platform_device *pdev,
diff --git a/sound/soc/imx/phycore-ac97.c b/sound/soc/imx/phycore-ac97.c
index 6a65dd705519..9eabc28667e6 100644
--- a/sound/soc/imx/phycore-ac97.c
+++ b/sound/soc/imx/phycore-ac97.c
@@ -20,9 +20,6 @@
20#include <sound/soc-dapm.h> 20#include <sound/soc-dapm.h>
21#include <asm/mach-types.h> 21#include <asm/mach-types.h>
22 22
23#include "../codecs/wm9712.h"
24#include "imx-ssi.h"
25
26static struct snd_soc_card imx_phycore; 23static struct snd_soc_card imx_phycore;
27 24
28static struct snd_soc_ops imx_phycore_hifi_ops = { 25static struct snd_soc_ops imx_phycore_hifi_ops = {
@@ -41,11 +38,12 @@ static struct snd_soc_dai_link imx_phycore_dai_ac97[] = {
41}; 38};
42 39
43static struct snd_soc_card imx_phycore = { 40static struct snd_soc_card imx_phycore = {
44 .name = "PhyCORE-audio", 41 .name = "PhyCORE-ac97-audio",
45 .dai_link = imx_phycore_dai_ac97, 42 .dai_link = imx_phycore_dai_ac97,
46 .num_links = ARRAY_SIZE(imx_phycore_dai_ac97), 43 .num_links = ARRAY_SIZE(imx_phycore_dai_ac97),
47}; 44};
48 45
46static struct platform_device *imx_phycore_snd_ac97_device;
49static struct platform_device *imx_phycore_snd_device; 47static struct platform_device *imx_phycore_snd_device;
50 48
51static int __init imx_phycore_init(void) 49static int __init imx_phycore_init(void)
@@ -56,29 +54,42 @@ static int __init imx_phycore_init(void)
56 /* return happy. We might run on a totally different machine */ 54 /* return happy. We might run on a totally different machine */
57 return 0; 55 return 0;
58 56
59 imx_phycore_snd_device = platform_device_alloc("soc-audio", -1); 57 imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1);
60 if (!imx_phycore_snd_device) 58 if (!imx_phycore_snd_ac97_device)
61 return -ENOMEM; 59 return -ENOMEM;
62 60
63 platform_set_drvdata(imx_phycore_snd_device, &imx_phycore); 61 platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore);
64 ret = platform_device_add(imx_phycore_snd_device); 62 ret = platform_device_add(imx_phycore_snd_ac97_device);
63 if (ret)
64 goto fail1;
65 65
66 imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1); 66 imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1);
67 if (!imx_phycore_snd_device) 67 if (!imx_phycore_snd_device) {
68 return -ENOMEM; 68 ret = -ENOMEM;
69 goto fail2;
70 }
69 ret = platform_device_add(imx_phycore_snd_device); 71 ret = platform_device_add(imx_phycore_snd_device);
70 72
71 if (ret) { 73 if (ret) {
72 printk(KERN_ERR "ASoC: Platform device allocation failed\n"); 74 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
73 platform_device_put(imx_phycore_snd_device); 75 goto fail3;
74 } 76 }
75 77
78 return 0;
79
80fail3:
81 platform_device_put(imx_phycore_snd_device);
82fail2:
83 platform_device_del(imx_phycore_snd_ac97_device);
84fail1:
85 platform_device_put(imx_phycore_snd_ac97_device);
76 return ret; 86 return ret;
77} 87}
78 88
79static void __exit imx_phycore_exit(void) 89static void __exit imx_phycore_exit(void)
80{ 90{
81 platform_device_unregister(imx_phycore_snd_device); 91 platform_device_unregister(imx_phycore_snd_device);
92 platform_device_unregister(imx_phycore_snd_ac97_device);
82} 93}
83 94
84late_initcall(imx_phycore_init); 95late_initcall(imx_phycore_init);
diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c
index 293dc748797c..dac6732da969 100644
--- a/sound/soc/nuc900/nuc900-ac97.c
+++ b/sound/soc/nuc900/nuc900-ac97.c
@@ -49,7 +49,7 @@ static unsigned short nuc900_ac97_read(struct snd_ac97 *ac97,
49 mutex_lock(&ac97_mutex); 49 mutex_lock(&ac97_mutex);
50 50
51 val = nuc900_checkready(); 51 val = nuc900_checkready();
52 if (!!val) { 52 if (val) {
53 dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); 53 dev_err(nuc900_audio->dev, "AC97 codec is not ready\n");
54 goto out; 54 goto out;
55 } 55 }
@@ -102,7 +102,7 @@ static void nuc900_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
102 mutex_lock(&ac97_mutex); 102 mutex_lock(&ac97_mutex);
103 103
104 tmp = nuc900_checkready(); 104 tmp = nuc900_checkready();
105 if (!!tmp) 105 if (tmp)
106 dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); 106 dev_err(nuc900_audio->dev, "AC97 codec is not ready\n");
107 107
108 /* clear the R_WB bit and write register index */ 108 /* clear the R_WB bit and write register index */
@@ -149,7 +149,7 @@ static void nuc900_ac97_warm_reset(struct snd_ac97 *ac97)
149 udelay(100); 149 udelay(100);
150 150
151 val = nuc900_checkready(); 151 val = nuc900_checkready();
152 if (!!val) 152 if (val)
153 dev_err(nuc900_audio->dev, "AC97 codec is not ready\n"); 153 dev_err(nuc900_audio->dev, "AC97 codec is not ready\n");
154 154
155 mutex_unlock(&ac97_mutex); 155 mutex_unlock(&ac97_mutex);
@@ -263,8 +263,7 @@ static int nuc900_ac97_trigger(struct snd_pcm_substream *substream,
263 return ret; 263 return ret;
264} 264}
265 265
266static int nuc900_ac97_probe(struct platform_device *pdev, 266static int nuc900_ac97_probe(struct snd_soc_dai *dai)
267 struct snd_soc_dai *dai)
268{ 267{
269 struct nuc900_audio *nuc900_audio = nuc900_ac97_data; 268 struct nuc900_audio *nuc900_audio = nuc900_ac97_data;
270 unsigned long val; 269 unsigned long val;
@@ -284,12 +283,12 @@ static int nuc900_ac97_probe(struct platform_device *pdev,
284 return 0; 283 return 0;
285} 284}
286 285
287static void nuc900_ac97_remove(struct platform_device *pdev, 286static int nuc900_ac97_remove(struct snd_soc_dai *dai)
288 struct snd_soc_dai *dai)
289{ 287{
290 struct nuc900_audio *nuc900_audio = nuc900_ac97_data; 288 struct nuc900_audio *nuc900_audio = nuc900_ac97_data;
291 289
292 clk_disable(nuc900_audio->clk); 290 clk_disable(nuc900_audio->clk);
291 return 0;
293} 292}
294 293
295static struct snd_soc_dai_ops nuc900_ac97_dai_ops = { 294static struct snd_soc_dai_ops nuc900_ac97_dai_ops = {
@@ -313,7 +312,7 @@ static struct snd_soc_dai_driver nuc900_ac97_dai = {
313 .channels_max = 2, 312 .channels_max = 2,
314 }, 313 },
315 .ops = &nuc900_ac97_dai_ops, 314 .ops = &nuc900_ac97_dai_ops,
316} 315};
317 316
318static int __devinit nuc900_ac97_drvprobe(struct platform_device *pdev) 317static int __devinit nuc900_ac97_drvprobe(struct platform_device *pdev)
319{ 318{
@@ -384,7 +383,6 @@ out0:
384 383
385static int __devexit nuc900_ac97_drvremove(struct platform_device *pdev) 384static int __devexit nuc900_ac97_drvremove(struct platform_device *pdev)
386{ 385{
387
388 snd_soc_unregister_dai(&pdev->dev); 386 snd_soc_unregister_dai(&pdev->dev);
389 387
390 clk_put(nuc900_ac97_data->clk); 388 clk_put(nuc900_ac97_data->clk);
@@ -392,6 +390,7 @@ static int __devexit nuc900_ac97_drvremove(struct platform_device *pdev)
392 release_mem_region(nuc900_ac97_data->res->start, 390 release_mem_region(nuc900_ac97_data->res->start,
393 resource_size(nuc900_ac97_data->res)); 391 resource_size(nuc900_ac97_data->res));
394 392
393 kfree(nuc900_ac97_data);
395 nuc900_ac97_data = NULL; 394 nuc900_ac97_data = NULL;
396 395
397 return 0; 396 return 0;
diff --git a/sound/soc/nuc900/nuc900-audio.h b/sound/soc/nuc900/nuc900-audio.h
index aeed8ead2b2b..59f7e8ed1a68 100644
--- a/sound/soc/nuc900/nuc900-audio.h
+++ b/sound/soc/nuc900/nuc900-audio.h
@@ -110,4 +110,6 @@ struct nuc900_audio {
110 110
111}; 111};
112 112
113extern struct nuc900_audio *nuc900_ac97_data;
114
113#endif /*end _NUC900_AUDIO_H */ 115#endif /*end _NUC900_AUDIO_H */
diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c
index 195d1ac94771..8263f56dc665 100644
--- a/sound/soc/nuc900/nuc900-pcm.c
+++ b/sound/soc/nuc900/nuc900-pcm.c
@@ -50,12 +50,12 @@ static int nuc900_dma_hw_params(struct snd_pcm_substream *substream,
50 unsigned long flags; 50 unsigned long flags;
51 int ret = 0; 51 int ret = 0;
52 52
53 spin_lock_irqsave(&nuc900_audio->lock, flags);
54
55 ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); 53 ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
56 if (ret < 0) 54 if (ret < 0)
57 return ret; 55 return ret;
58 56
57 spin_lock_irqsave(&nuc900_audio->lock, flags);
58
59 nuc900_audio->substream = substream; 59 nuc900_audio->substream = substream;
60 nuc900_audio->dma_addr[substream->stream] = runtime->dma_addr; 60 nuc900_audio->dma_addr[substream->stream] = runtime->dma_addr;
61 nuc900_audio->buffersize[substream->stream] = 61 nuc900_audio->buffersize[substream->stream] =
@@ -169,6 +169,7 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream)
169 struct snd_pcm_runtime *runtime = substream->runtime; 169 struct snd_pcm_runtime *runtime = substream->runtime;
170 struct nuc900_audio *nuc900_audio = runtime->private_data; 170 struct nuc900_audio *nuc900_audio = runtime->private_data;
171 unsigned long flags, val; 171 unsigned long flags, val;
172 int ret = 0;
172 173
173 spin_lock_irqsave(&nuc900_audio->lock, flags); 174 spin_lock_irqsave(&nuc900_audio->lock, flags);
174 175
@@ -197,10 +198,10 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream)
197 AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val); 198 AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val);
198 break; 199 break;
199 default: 200 default:
200 return -EINVAL; 201 ret = -EINVAL;
201 } 202 }
202 spin_unlock_irqrestore(&nuc900_audio->lock, flags); 203 spin_unlock_irqrestore(&nuc900_audio->lock, flags);
203 return 0; 204 return ret;
204} 205}
205 206
206static int nuc900_dma_trigger(struct snd_pcm_substream *substream, int cmd) 207static int nuc900_dma_trigger(struct snd_pcm_substream *substream, int cmd)
@@ -332,7 +333,7 @@ static struct snd_soc_platform_driver nuc900_soc_platform = {
332 .ops = &nuc900_dma_ops, 333 .ops = &nuc900_dma_ops,
333 .pcm_new = nuc900_dma_new, 334 .pcm_new = nuc900_dma_new,
334 .pcm_free = nuc900_dma_free_dma_buffers, 335 .pcm_free = nuc900_dma_free_dma_buffers,
335} 336};
336 337
337static int __devinit nuc900_soc_platform_probe(struct platform_device *pdev) 338static int __devinit nuc900_soc_platform_probe(struct platform_device *pdev)
338{ 339{
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index d542ea2ff6be..a088db6d5091 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -12,8 +12,8 @@ config SND_OMAP_SOC_MCPDM
12config SND_OMAP_SOC_N810 12config SND_OMAP_SOC_N810
13 tristate "SoC Audio support for Nokia N810" 13 tristate "SoC Audio support for Nokia N810"
14 depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C 14 depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C
15 depends on OMAP_MUX
15 select SND_OMAP_SOC_MCBSP 16 select SND_OMAP_SOC_MCBSP
16 select OMAP_MUX
17 select SND_SOC_TLV320AIC3X 17 select SND_SOC_TLV320AIC3X
18 help 18 help
19 Say Y if you want to add support for SoC audio on Nokia N810. 19 Say Y if you want to add support for SoC audio on Nokia N810.
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index d211c9fa5a91..7e84f24b9a88 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -644,15 +644,23 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
644 644
645 645
646 case OMAP_MCBSP_CLKR_SRC_CLKR: 646 case OMAP_MCBSP_CLKR_SRC_CLKR:
647 if (cpu_class_is_omap1())
648 break;
647 omap2_mcbsp1_mux_clkr_src(CLKR_SRC_CLKR); 649 omap2_mcbsp1_mux_clkr_src(CLKR_SRC_CLKR);
648 break; 650 break;
649 case OMAP_MCBSP_CLKR_SRC_CLKX: 651 case OMAP_MCBSP_CLKR_SRC_CLKX:
652 if (cpu_class_is_omap1())
653 break;
650 omap2_mcbsp1_mux_clkr_src(CLKR_SRC_CLKX); 654 omap2_mcbsp1_mux_clkr_src(CLKR_SRC_CLKX);
651 break; 655 break;
652 case OMAP_MCBSP_FSR_SRC_FSR: 656 case OMAP_MCBSP_FSR_SRC_FSR:
657 if (cpu_class_is_omap1())
658 break;
653 omap2_mcbsp1_mux_fsr_src(FSR_SRC_FSR); 659 omap2_mcbsp1_mux_fsr_src(FSR_SRC_FSR);
654 break; 660 break;
655 case OMAP_MCBSP_FSR_SRC_FSX: 661 case OMAP_MCBSP_FSR_SRC_FSX:
662 if (cpu_class_is_omap1())
663 break;
656 omap2_mcbsp1_mux_fsr_src(FSR_SRC_FSX); 664 omap2_mcbsp1_mux_fsr_src(FSR_SRC_FSX);
657 break; 665 break;
658 default: 666 default:
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c
index dbd9d96b5f92..4ee33ce2cb98 100644
--- a/sound/soc/omap/omap3pandora.c
+++ b/sound/soc/omap/omap3pandora.c
@@ -306,6 +306,7 @@ static int __init omap3pandora_soc_init(void)
306 pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n", 306 pr_err(PREFIX "Failed to get DAC regulator from %s: %ld\n",
307 dev_name(&omap3pandora_snd_device->dev), 307 dev_name(&omap3pandora_snd_device->dev),
308 PTR_ERR(omap3pandora_dac_reg)); 308 PTR_ERR(omap3pandora_dac_reg));
309 ret = PTR_ERR(omap3pandora_dac_reg);
309 goto fail3; 310 goto fail3;
310 } 311 }
311 312
diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c
index f0e662556428..65ae00e976ef 100644
--- a/sound/soc/omap/osk5912.c
+++ b/sound/soc/omap/osk5912.c
@@ -177,7 +177,8 @@ static int __init osk_soc_init(void)
177 tlv320aic23_mclk = clk_get(dev, "mclk"); 177 tlv320aic23_mclk = clk_get(dev, "mclk");
178 if (IS_ERR(tlv320aic23_mclk)) { 178 if (IS_ERR(tlv320aic23_mclk)) {
179 printk(KERN_ERR "Could not get mclk clock\n"); 179 printk(KERN_ERR "Could not get mclk clock\n");
180 return -ENODEV; 180 err = PTR_ERR(tlv320aic23_mclk);
181 goto err2;
181 } 182 }
182 183
183 /* 184 /*
@@ -188,7 +189,7 @@ static int __init osk_soc_init(void)
188 if (clk_set_rate(tlv320aic23_mclk, CODEC_CLOCK)) { 189 if (clk_set_rate(tlv320aic23_mclk, CODEC_CLOCK)) {
189 printk(KERN_ERR "Cannot set MCLK for AIC23 CODEC\n"); 190 printk(KERN_ERR "Cannot set MCLK for AIC23 CODEC\n");
190 err = -ECANCELED; 191 err = -ECANCELED;
191 goto err1; 192 goto err3;
192 } 193 }
193 } 194 }
194 195
@@ -196,9 +197,12 @@ static int __init osk_soc_init(void)
196 (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK); 197 (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK);
197 198
198 return 0; 199 return 0;
199err1: 200
201err3:
200 clk_put(tlv320aic23_mclk); 202 clk_put(tlv320aic23_mclk);
203err2:
201 platform_device_del(osk_snd_device); 204 platform_device_del(osk_snd_device);
205err1:
202 platform_device_put(osk_snd_device); 206 platform_device_put(osk_snd_device);
203 207
204 return err; 208 return err;
@@ -207,6 +211,7 @@ err1:
207 211
208static void __exit osk_soc_exit(void) 212static void __exit osk_soc_exit(void)
209{ 213{
214 clk_put(tlv320aic23_mclk);
210 platform_device_unregister(osk_snd_device); 215 platform_device_unregister(osk_snd_device);
211} 216}
212 217
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index 37f191bbfdd9..580f48571303 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -1,6 +1,7 @@
1config SND_PXA2XX_SOC 1config SND_PXA2XX_SOC
2 tristate "SoC Audio for the Intel PXA2xx chip" 2 tristate "SoC Audio for the Intel PXA2xx chip"
3 depends on ARCH_PXA 3 depends on ARCH_PXA
4 select SND_ARM
4 select SND_PXA2XX_LIB 5 select SND_PXA2XX_LIB
5 help 6 help
6 Say Y or M if you want to add support for codecs attached to 7 Say Y or M if you want to add support for codecs attached to
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
index 97e9423615c9..f451acd4935b 100644
--- a/sound/soc/pxa/corgi.c
+++ b/sound/soc/pxa/corgi.c
@@ -100,8 +100,13 @@ static int corgi_startup(struct snd_pcm_substream *substream)
100 struct snd_soc_pcm_runtime *rtd = substream->private_data; 100 struct snd_soc_pcm_runtime *rtd = substream->private_data;
101 struct snd_soc_codec *codec = rtd->codec; 101 struct snd_soc_codec *codec = rtd->codec;
102 102
103 mutex_lock(&codec->mutex);
104
103 /* check the jack status at stream startup */ 105 /* check the jack status at stream startup */
104 corgi_ext_control(codec); 106 corgi_ext_control(codec);
107
108 mutex_unlock(&codec->mutex);
109
105 return 0; 110 return 0;
106} 111}
107 112
diff --git a/sound/soc/pxa/magician.c b/sound/soc/pxa/magician.c
index b8207ced4072..5ef0526924b9 100644
--- a/sound/soc/pxa/magician.c
+++ b/sound/soc/pxa/magician.c
@@ -72,9 +72,13 @@ static int magician_startup(struct snd_pcm_substream *substream)
72 struct snd_soc_pcm_runtime *rtd = substream->private_data; 72 struct snd_soc_pcm_runtime *rtd = substream->private_data;
73 struct snd_soc_codec *codec = rtd->codec; 73 struct snd_soc_codec *codec = rtd->codec;
74 74
75 mutex_lock(&codec->mutex);
76
75 /* check the jack status at stream startup */ 77 /* check the jack status at stream startup */
76 magician_ext_control(codec); 78 magician_ext_control(codec);
77 79
80 mutex_unlock(&codec->mutex);
81
78 return 0; 82 return 0;
79} 83}
80 84
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c
index af84ee9c5e11..84edd0385a21 100644
--- a/sound/soc/pxa/poodle.c
+++ b/sound/soc/pxa/poodle.c
@@ -77,8 +77,13 @@ static int poodle_startup(struct snd_pcm_substream *substream)
77 struct snd_soc_pcm_runtime *rtd = substream->private_data; 77 struct snd_soc_pcm_runtime *rtd = substream->private_data;
78 struct snd_soc_codec *codec = rtd->codec; 78 struct snd_soc_codec *codec = rtd->codec;
79 79
80 mutex_lock(&codec->mutex);
81
80 /* check the jack status at stream startup */ 82 /* check the jack status at stream startup */
81 poodle_ext_control(codec); 83 poodle_ext_control(codec);
84
85 mutex_unlock(&codec->mutex);
86
82 return 0; 87 return 0;
83} 88}
84 89
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index f470f360f4dd..0b30d7de24ec 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -108,8 +108,13 @@ static int spitz_startup(struct snd_pcm_substream *substream)
108 struct snd_soc_pcm_runtime *rtd = substream->private_data; 108 struct snd_soc_pcm_runtime *rtd = substream->private_data;
109 struct snd_soc_codec *codec = rtd->codec; 109 struct snd_soc_codec *codec = rtd->codec;
110 110
111 mutex_lock(&codec->mutex);
112
111 /* check the jack status at stream startup */ 113 /* check the jack status at stream startup */
112 spitz_ext_control(codec); 114 spitz_ext_control(codec);
115
116 mutex_unlock(&codec->mutex);
117
113 return 0; 118 return 0;
114} 119}
115 120
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c
index 73d0edd8ded9..7b983f935454 100644
--- a/sound/soc/pxa/tosa.c
+++ b/sound/soc/pxa/tosa.c
@@ -81,8 +81,13 @@ static int tosa_startup(struct snd_pcm_substream *substream)
81 struct snd_soc_pcm_runtime *rtd = substream->private_data; 81 struct snd_soc_pcm_runtime *rtd = substream->private_data;
82 struct snd_soc_codec *codec = rtd->codec; 82 struct snd_soc_codec *codec = rtd->codec;
83 83
84 mutex_lock(&codec->mutex);
85
84 /* check the jack status at stream startup */ 86 /* check the jack status at stream startup */
85 tosa_ext_control(codec); 87 tosa_ext_control(codec);
88
89 mutex_unlock(&codec->mutex);
90
86 return 0; 91 return 0;
87} 92}
88 93
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
index 8a6b53ccd203..d85bf8a0abb2 100644
--- a/sound/soc/s3c24xx/Kconfig
+++ b/sound/soc/s3c24xx/Kconfig
@@ -2,6 +2,7 @@ config SND_S3C24XX_SOC
2 tristate "SoC Audio for the Samsung S3CXXXX chips" 2 tristate "SoC Audio for the Samsung S3CXXXX chips"
3 depends on ARCH_S3C2410 || ARCH_S3C64XX || ARCH_S5PC100 || ARCH_S5PV210 3 depends on ARCH_S3C2410 || ARCH_S3C64XX || ARCH_S5PC100 || ARCH_S5PV210
4 select S3C64XX_DMA if ARCH_S3C64XX 4 select S3C64XX_DMA if ARCH_S3C64XX
5 select S3C2410_DMA if ARCH_S3C2410
5 help 6 help
6 Say Y or M if you want to add support for codecs attached to 7 Say Y or M if you want to add support for codecs attached to
7 the S3C24XX AC97 or I2S interfaces. You will also need to 8 the S3C24XX AC97 or I2S interfaces. You will also need to
diff --git a/sound/soc/s3c24xx/rx1950_uda1380.c b/sound/soc/s3c24xx/rx1950_uda1380.c
index ffd5cf2fb0a9..468cc11fdf47 100644
--- a/sound/soc/s3c24xx/rx1950_uda1380.c
+++ b/sound/soc/s3c24xx/rx1950_uda1380.c
@@ -50,7 +50,6 @@ static unsigned int rates[] = {
50 16000, 50 16000,
51 44100, 51 44100,
52 48000, 52 48000,
53 88200,
54}; 53};
55 54
56static struct snd_pcm_hw_constraint_list hw_rates = { 55static struct snd_pcm_hw_constraint_list hw_rates = {
@@ -130,7 +129,6 @@ static const struct snd_soc_dapm_route audio_map[] = {
130}; 129};
131 130
132static struct platform_device *s3c24xx_snd_device; 131static struct platform_device *s3c24xx_snd_device;
133static struct clk *xtal;
134 132
135static int rx1950_startup(struct snd_pcm_substream *substream) 133static int rx1950_startup(struct snd_pcm_substream *substream)
136{ 134{
@@ -179,10 +177,8 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
179 case 44100: 177 case 44100:
180 case 88200: 178 case 88200:
181 clk_source = S3C24XX_CLKSRC_MPLL; 179 clk_source = S3C24XX_CLKSRC_MPLL;
182 fs_mode = S3C2410_IISMOD_256FS; 180 fs_mode = S3C2410_IISMOD_384FS;
183 div = clk_get_rate(xtal) / (256 * rate); 181 div = 1;
184 if (clk_get_rate(xtal) % (256 * rate) > (128 * rate))
185 div++;
186 break; 182 break;
187 default: 183 default:
188 printk(KERN_ERR "%s: rate %d is not supported\n", 184 printk(KERN_ERR "%s: rate %d is not supported\n",
@@ -210,7 +206,7 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
210 206
211 /* set MCLK division for sample rate */ 207 /* set MCLK division for sample rate */
212 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK, 208 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
213 S3C2410_IISMOD_384FS); 209 fs_mode);
214 if (ret < 0) 210 if (ret < 0)
215 return ret; 211 return ret;
216 212
@@ -295,17 +291,8 @@ static int __init rx1950_init(void)
295 goto err_plat_add; 291 goto err_plat_add;
296 } 292 }
297 293
298 xtal = clk_get(&s3c24xx_snd_device->dev, "xtal");
299
300 if (IS_ERR(xtal)) {
301 ret = PTR_ERR(xtal);
302 platform_device_unregister(s3c24xx_snd_device);
303 goto err_clk;
304 }
305
306 return 0; 294 return 0;
307 295
308err_clk:
309err_plat_add: 296err_plat_add:
310err_plat_alloc: 297err_plat_alloc:
311err_gpio_conf: 298err_gpio_conf:
@@ -320,7 +307,6 @@ static void __exit rx1950_exit(void)
320 platform_device_unregister(s3c24xx_snd_device); 307 platform_device_unregister(s3c24xx_snd_device);
321 snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), 308 snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
322 hp_jack_gpios); 309 hp_jack_gpios);
323 clk_put(xtal);
324 gpio_free(S3C2410_GPA(1)); 310 gpio_free(S3C2410_GPA(1));
325} 311}
326 312
diff --git a/sound/soc/s3c24xx/smdk_spdif.c b/sound/soc/s3c24xx/smdk_spdif.c
index f31d22ad7c88..c8bd90488a87 100644
--- a/sound/soc/s3c24xx/smdk_spdif.c
+++ b/sound/soc/s3c24xx/smdk_spdif.c
@@ -38,7 +38,7 @@ static int set_audio_clock_heirachy(struct platform_device *pdev)
38 } 38 }
39 39
40 mout_epll = clk_get(NULL, "mout_epll"); 40 mout_epll = clk_get(NULL, "mout_epll");
41 if (IS_ERR(fout_epll)) { 41 if (IS_ERR(mout_epll)) {
42 printk(KERN_WARNING "%s: Cannot find mout_epll.\n", 42 printk(KERN_WARNING "%s: Cannot find mout_epll.\n",
43 __func__); 43 __func__);
44 ret = -EINVAL; 44 ret = -EINVAL;
@@ -54,7 +54,7 @@ static int set_audio_clock_heirachy(struct platform_device *pdev)
54 } 54 }
55 55
56 sclk_spdif = clk_get(NULL, "sclk_spdif"); 56 sclk_spdif = clk_get(NULL, "sclk_spdif");
57 if (IS_ERR(fout_epll)) { 57 if (IS_ERR(sclk_spdif)) {
58 printk(KERN_WARNING "%s: Cannot find sclk_spdif.\n", 58 printk(KERN_WARNING "%s: Cannot find sclk_spdif.\n",
59 __func__); 59 __func__);
60 ret = -EINVAL; 60 ret = -EINVAL;
diff --git a/sound/soc/s6000/s6000-i2s.c b/sound/soc/s6000/s6000-i2s.c
index 8778faa174a6..3052f64b2403 100644
--- a/sound/soc/s6000/s6000-i2s.c
+++ b/sound/soc/s6000/s6000-i2s.c
@@ -434,7 +434,7 @@ static struct snd_soc_dai_driver s6000_i2s_dai = {
434 .rate_max = 1562500, 434 .rate_max = 1562500,
435 }, 435 },
436 .ops = &s6000_i2s_dai_ops, 436 .ops = &s6000_i2s_dai_ops,
437} 437};
438 438
439static int __devinit s6000_i2s_probe(struct platform_device *pdev) 439static int __devinit s6000_i2s_probe(struct platform_device *pdev)
440{ 440{
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c
index 271fd222bf19..ab3ccaec72d2 100644
--- a/sound/soc/s6000/s6000-pcm.c
+++ b/sound/soc/s6000/s6000-pcm.c
@@ -473,7 +473,7 @@ static int s6000_pcm_new(struct snd_card *card,
473 } 473 }
474 474
475 res = request_irq(params->irq, s6000_pcm_irq, IRQF_SHARED, 475 res = request_irq(params->irq, s6000_pcm_irq, IRQF_SHARED,
476 s6000_soc_platform.name, pcm); 476 "s6000-audio", pcm);
477 if (res) { 477 if (res) {
478 printk(KERN_ERR "s6000-pcm couldn't get IRQ\n"); 478 printk(KERN_ERR "s6000-pcm couldn't get IRQ\n");
479 return res; 479 return res;
diff --git a/sound/soc/s6000/s6105-ipcam.c b/sound/soc/s6000/s6105-ipcam.c
index 96c05e137538..c1244c5bc730 100644
--- a/sound/soc/s6000/s6105-ipcam.c
+++ b/sound/soc/s6000/s6105-ipcam.c
@@ -167,7 +167,7 @@ static int s6105_aic3x_init(struct snd_soc_pcm_runtime *rtd)
167 167
168 snd_soc_dapm_sync(codec); 168 snd_soc_dapm_sync(codec);
169 169
170 snd_ctl_add(codec->snd_card, snd_ctl_new1(&audio_out_mux, codec)); 170 snd_ctl_add(codec->card->snd_card, snd_ctl_new1(&audio_out_mux, codec));
171 171
172 return 0; 172 return 0;
173} 173}
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 507e709f2807..4c2404b1b862 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -132,6 +132,8 @@ struct fsi_priv {
132 struct fsi_stream playback; 132 struct fsi_stream playback;
133 struct fsi_stream capture; 133 struct fsi_stream capture;
134 134
135 long rate;
136
135 u32 mst_ctrl; 137 u32 mst_ctrl;
136}; 138};
137 139
@@ -854,10 +856,17 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream,
854{ 856{
855 struct fsi_priv *fsi = fsi_get_priv(substream); 857 struct fsi_priv *fsi = fsi_get_priv(substream);
856 int is_play = fsi_is_play(substream); 858 int is_play = fsi_is_play(substream);
859 struct fsi_master *master = fsi_get_master(fsi);
860 int (*set_rate)(struct device *dev, int is_porta, int rate, int enable);
857 861
858 fsi_irq_disable(fsi, is_play); 862 fsi_irq_disable(fsi, is_play);
859 fsi_clk_ctrl(fsi, 0); 863 fsi_clk_ctrl(fsi, 0);
860 864
865 set_rate = master->info->set_rate;
866 if (set_rate && fsi->rate)
867 set_rate(dai->dev, fsi_is_port_a(fsi), fsi->rate, 0);
868 fsi->rate = 0;
869
861 pm_runtime_put_sync(dai->dev); 870 pm_runtime_put_sync(dai->dev);
862} 871}
863 872
@@ -891,20 +900,20 @@ static int fsi_dai_hw_params(struct snd_pcm_substream *substream,
891{ 900{
892 struct fsi_priv *fsi = fsi_get_priv(substream); 901 struct fsi_priv *fsi = fsi_get_priv(substream);
893 struct fsi_master *master = fsi_get_master(fsi); 902 struct fsi_master *master = fsi_get_master(fsi);
894 int (*set_rate)(int is_porta, int rate) = master->info->set_rate; 903 int (*set_rate)(struct device *dev, int is_porta, int rate, int enable);
895 int fsi_ver = master->core->ver; 904 int fsi_ver = master->core->ver;
896 int is_play = fsi_is_play(substream); 905 long rate = params_rate(params);
897 int ret; 906 int ret;
898 907
899 /* if slave mode, set_rate is not needed */ 908 set_rate = master->info->set_rate;
900 if (!fsi_is_master_mode(fsi, is_play)) 909 if (!set_rate)
901 return 0; 910 return 0;
902 911
903 /* it is error if no set_rate */ 912 ret = set_rate(dai->dev, fsi_is_port_a(fsi), rate, 1);
904 if (!set_rate) 913 if (ret < 0) /* error */
905 return -EIO; 914 return ret;
906 915
907 ret = set_rate(fsi_is_port_a(fsi), params_rate(params)); 916 fsi->rate = rate;
908 if (ret > 0) { 917 if (ret > 0) {
909 u32 data = 0; 918 u32 data = 0;
910 919
diff --git a/sound/soc/sh/ssi.c b/sound/soc/sh/ssi.c
index 40bbdf1591dc..05192d97b377 100644
--- a/sound/soc/sh/ssi.c
+++ b/sound/soc/sh/ssi.c
@@ -387,7 +387,7 @@ static int __devinit sh4_soc_dai_probe(struct platform_device *pdev)
387 387
388static int __devexit sh4_soc_dai_remove(struct platform_device *pdev) 388static int __devexit sh4_soc_dai_remove(struct platform_device *pdev)
389{ 389{
390 snd_soc_unregister_dai(&pdev->dev, ARRAY_SIZE(sh4_ssi_dai)); 390 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(sh4_ssi_dai));
391 return 0; 391 return 0;
392} 392}
393 393
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 614a8b30d87b..85b7d548f167 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1619,12 +1619,14 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
1619#ifdef CONFIG_SND_SOC_AC97_BUS 1619#ifdef CONFIG_SND_SOC_AC97_BUS
1620 /* register any AC97 codecs */ 1620 /* register any AC97 codecs */
1621 for (i = 0; i < card->num_rtd; i++) { 1621 for (i = 0; i < card->num_rtd; i++) {
1622 ret = soc_register_ac97_dai_link(&card->rtd[i]); 1622 ret = soc_register_ac97_dai_link(&card->rtd[i]);
1623 if (ret < 0) { 1623 if (ret < 0) {
1624 printk(KERN_ERR "asoc: failed to register AC97 %s\n", card->name); 1624 printk(KERN_ERR "asoc: failed to register AC97 %s\n", card->name);
1625 goto probe_dai_err; 1625 while (--i >= 0)
1626 } 1626 soc_unregister_ac97_dai_link(&card->rtd[i]);
1627 goto probe_dai_err;
1627 } 1628 }
1629 }
1628#endif 1630#endif
1629 1631
1630 card->instantiated = 1; 1632 card->instantiated = 1;
@@ -3043,8 +3045,10 @@ int snd_soc_register_dais(struct device *dev,
3043 for (i = 0; i < count; i++) { 3045 for (i = 0; i < count; i++) {
3044 3046
3045 dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL); 3047 dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
3046 if (dai == NULL) 3048 if (dai == NULL) {
3047 return -ENOMEM; 3049 ret = -ENOMEM;
3050 goto err;
3051 }
3048 3052
3049 /* create DAI component name */ 3053 /* create DAI component name */
3050 dai->name = fmt_multiple_name(dev, &dai_drv[i]); 3054 dai->name = fmt_multiple_name(dev, &dai_drv[i]);
@@ -3070,7 +3074,9 @@ int snd_soc_register_dais(struct device *dev,
3070 pr_debug("Registered DAI '%s'\n", dai->name); 3074 pr_debug("Registered DAI '%s'\n", dai->name);
3071 } 3075 }
3072 3076
3077 mutex_lock(&client_mutex);
3073 snd_soc_instantiate_cards(); 3078 snd_soc_instantiate_cards();
3079 mutex_unlock(&client_mutex);
3074 return 0; 3080 return 0;
3075 3081
3076err: 3082err:
@@ -3263,9 +3269,6 @@ int snd_soc_register_codec(struct device *dev,
3263 return 0; 3269 return 0;
3264 3270
3265error: 3271error:
3266 for (i--; i >= 0; i--)
3267 snd_soc_unregister_dai(dev);
3268
3269 if (codec->reg_cache) 3272 if (codec->reg_cache)
3270 kfree(codec->reg_cache); 3273 kfree(codec->reg_cache);
3271 kfree(codec->name); 3274 kfree(codec->name);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 7d85c6496afa..c721502833bc 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -683,12 +683,12 @@ static int dapm_seq_compare(struct snd_soc_dapm_widget *a,
683 struct snd_soc_dapm_widget *b, 683 struct snd_soc_dapm_widget *b,
684 int sort[]) 684 int sort[])
685{ 685{
686 if (a->codec != b->codec)
687 return (unsigned long)a - (unsigned long)b;
688 if (sort[a->id] != sort[b->id]) 686 if (sort[a->id] != sort[b->id])
689 return sort[a->id] - sort[b->id]; 687 return sort[a->id] - sort[b->id];
690 if (a->reg != b->reg) 688 if (a->reg != b->reg)
691 return a->reg - b->reg; 689 return a->reg - b->reg;
690 if (a->codec != b->codec)
691 return (unsigned long)a->codec - (unsigned long)b->codec;
692 692
693 return 0; 693 return 0;
694} 694}
@@ -944,6 +944,9 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
944 case SND_SOC_DAPM_STREAM_RESUME: 944 case SND_SOC_DAPM_STREAM_RESUME:
945 sys_power = 1; 945 sys_power = 1;
946 break; 946 break;
947 case SND_SOC_DAPM_STREAM_STOP:
948 sys_power = !!codec->active;
949 break;
947 case SND_SOC_DAPM_STREAM_SUSPEND: 950 case SND_SOC_DAPM_STREAM_SUSPEND:
948 sys_power = 0; 951 sys_power = 0;
949 break; 952 break;
diff --git a/sound/sound_core.c b/sound/sound_core.c
index c03bbaefdbc3..5580aced8730 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -104,7 +104,6 @@ module_exit(cleanup_soundcore);
104 104
105#include <linux/init.h> 105#include <linux/init.h>
106#include <linux/slab.h> 106#include <linux/slab.h>
107#include <linux/smp_lock.h>
108#include <linux/types.h> 107#include <linux/types.h>
109#include <linux/kernel.h> 108#include <linux/kernel.h>
110#include <linux/sound.h> 109#include <linux/sound.h>
diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
index 1bc56b2b94e2..337a00241a1f 100644
--- a/sound/spi/at73c213.c
+++ b/sound/spi/at73c213.c
@@ -155,7 +155,7 @@ static int snd_at73c213_set_bitrate(struct snd_at73c213 *chip)
155 if (max_tries < 1) 155 if (max_tries < 1)
156 max_tries = 1; 156 max_tries = 1;
157 157
158 /* ssc_div must be a power of 2. */ 158 /* ssc_div must be even. */
159 ssc_div = (ssc_div + 1) & ~1UL; 159 ssc_div = (ssc_div + 1) & ~1UL;
160 160
161 if ((ssc_rate / (ssc_div * 2 * 16)) < BITRATE_MIN) { 161 if ((ssc_rate / (ssc_div * 2 * 16)) < BITRATE_MIN) {
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 93bd2ff001fb..564491fa18b2 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -197,7 +197,7 @@ static void sig_atexit(void)
197 if (child_pid > 0) 197 if (child_pid > 0)
198 kill(child_pid, SIGTERM); 198 kill(child_pid, SIGTERM);
199 199
200 if (signr == -1) 200 if (signr == -1 || signr == SIGUSR1)
201 return; 201 return;
202 202
203 signal(signr, SIG_DFL); 203 signal(signr, SIG_DFL);
@@ -515,6 +515,7 @@ static int __cmd_record(int argc, const char **argv)
515 atexit(sig_atexit); 515 atexit(sig_atexit);
516 signal(SIGCHLD, sig_handler); 516 signal(SIGCHLD, sig_handler);
517 signal(SIGINT, sig_handler); 517 signal(SIGINT, sig_handler);
518 signal(SIGUSR1, sig_handler);
518 519
519 if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) { 520 if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) {
520 perror("failed to create pipes"); 521 perror("failed to create pipes");
@@ -606,6 +607,7 @@ static int __cmd_record(int argc, const char **argv)
606 execvp(argv[0], (char **)argv); 607 execvp(argv[0], (char **)argv);
607 608
608 perror(argv[0]); 609 perror(argv[0]);
610 kill(getppid(), SIGUSR1);
609 exit(-1); 611 exit(-1);
610 } 612 }
611 613
@@ -697,17 +699,18 @@ static int __cmd_record(int argc, const char **argv)
697 if (err < 0) 699 if (err < 0)
698 err = event__synthesize_kernel_mmap(process_synthesized_event, 700 err = event__synthesize_kernel_mmap(process_synthesized_event,
699 session, machine, "_stext"); 701 session, machine, "_stext");
700 if (err < 0) { 702 if (err < 0)
701 pr_err("Couldn't record kernel reference relocation symbol.\n"); 703 pr_err("Couldn't record kernel reference relocation symbol\n"
702 return err; 704 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
703 } 705 "Check /proc/kallsyms permission or run as root.\n");
704 706
705 err = event__synthesize_modules(process_synthesized_event, 707 err = event__synthesize_modules(process_synthesized_event,
706 session, machine); 708 session, machine);
707 if (err < 0) { 709 if (err < 0)
708 pr_err("Couldn't record kernel reference relocation symbol.\n"); 710 pr_err("Couldn't record kernel module information.\n"
709 return err; 711 "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n"
710 } 712 "Check /proc/modules permission or run as root.\n");
713
711 if (perf_guest) 714 if (perf_guest)
712 perf_session__process_machines(session, event__synthesize_guest_os); 715 perf_session__process_machines(session, event__synthesize_guest_os);
713 716
@@ -761,7 +764,7 @@ static int __cmd_record(int argc, const char **argv)
761 } 764 }
762 } 765 }
763 766
764 if (quiet) 767 if (quiet || signr == SIGUSR1)
765 return 0; 768 return 0;
766 769
767 fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); 770 fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking);
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index d7e67b167ea3..64a85bafde63 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -946,11 +946,16 @@ perf_header__find_attr(u64 id, struct perf_header *header)
946 946
947 /* 947 /*
948 * We set id to -1 if the data file doesn't contain sample 948 * We set id to -1 if the data file doesn't contain sample
949 * ids. Check for this and avoid walking through the entire 949 * ids. This can happen when the data file contains one type
950 * list of ids which may be large. 950 * of event and in that case, the header can still store the
951 * event attribute information. Check for this and avoid
952 * walking through the entire list of ids which may be large.
951 */ 953 */
952 if (id == -1ULL) 954 if (id == -1ULL) {
955 if (header->attrs > 0)
956 return &header->attr[0]->attr;
953 return NULL; 957 return NULL;
958 }
954 959
955 for (i = 0; i < header->attrs; i++) { 960 for (i = 0; i < header->attrs; i++) {
956 struct perf_header_attr *attr = header->attr[i]; 961 struct perf_header_attr *attr = header->attr[i];
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index b39f499e575a..d628c8d1cf5e 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -295,7 +295,9 @@ static void symbols__insert_by_name(struct rb_root *self, struct symbol *sym)
295{ 295{
296 struct rb_node **p = &self->rb_node; 296 struct rb_node **p = &self->rb_node;
297 struct rb_node *parent = NULL; 297 struct rb_node *parent = NULL;
298 struct symbol_name_rb_node *symn = ((void *)sym) - sizeof(*parent), *s; 298 struct symbol_name_rb_node *symn, *s;
299
300 symn = container_of(sym, struct symbol_name_rb_node, sym);
299 301
300 while (*p != NULL) { 302 while (*p != NULL) {
301 parent = *p; 303 parent = *p;
@@ -530,7 +532,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
530 struct machine *machine = kmaps->machine; 532 struct machine *machine = kmaps->machine;
531 struct map *curr_map = map; 533 struct map *curr_map = map;
532 struct symbol *pos; 534 struct symbol *pos;
533 int count = 0; 535 int count = 0, moved = 0;
534 struct rb_root *root = &self->symbols[map->type]; 536 struct rb_root *root = &self->symbols[map->type];
535 struct rb_node *next = rb_first(root); 537 struct rb_node *next = rb_first(root);
536 int kernel_range = 0; 538 int kernel_range = 0;
@@ -588,6 +590,11 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
588 char dso_name[PATH_MAX]; 590 char dso_name[PATH_MAX];
589 struct dso *dso; 591 struct dso *dso;
590 592
593 if (count == 0) {
594 curr_map = map;
595 goto filter_symbol;
596 }
597
591 if (self->kernel == DSO_TYPE_GUEST_KERNEL) 598 if (self->kernel == DSO_TYPE_GUEST_KERNEL)
592 snprintf(dso_name, sizeof(dso_name), 599 snprintf(dso_name, sizeof(dso_name),
593 "[guest.kernel].%d", 600 "[guest.kernel].%d",
@@ -613,7 +620,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
613 map_groups__insert(kmaps, curr_map); 620 map_groups__insert(kmaps, curr_map);
614 ++kernel_range; 621 ++kernel_range;
615 } 622 }
616 623filter_symbol:
617 if (filter && filter(curr_map, pos)) { 624 if (filter && filter(curr_map, pos)) {
618discard_symbol: rb_erase(&pos->rb_node, root); 625discard_symbol: rb_erase(&pos->rb_node, root);
619 symbol__delete(pos); 626 symbol__delete(pos);
@@ -621,8 +628,9 @@ discard_symbol: rb_erase(&pos->rb_node, root);
621 if (curr_map != map) { 628 if (curr_map != map) {
622 rb_erase(&pos->rb_node, root); 629 rb_erase(&pos->rb_node, root);
623 symbols__insert(&curr_map->dso->symbols[curr_map->type], pos); 630 symbols__insert(&curr_map->dso->symbols[curr_map->type], pos);
624 } 631 ++moved;
625 count++; 632 } else
633 ++count;
626 } 634 }
627 } 635 }
628 636
@@ -632,7 +640,7 @@ discard_symbol: rb_erase(&pos->rb_node, root);
632 dso__set_loaded(curr_map->dso, curr_map->type); 640 dso__set_loaded(curr_map->dso, curr_map->type);
633 } 641 }
634 642
635 return count; 643 return count + moved;
636} 644}
637 645
638int dso__load_kallsyms(struct dso *self, const char *filename, 646int dso__load_kallsyms(struct dso *self, const char *filename,
@@ -2123,14 +2131,55 @@ static struct dso *machine__create_kernel(struct machine *self)
2123 return kernel; 2131 return kernel;
2124} 2132}
2125 2133
2134struct process_args {
2135 u64 start;
2136};
2137
2138static int symbol__in_kernel(void *arg, const char *name,
2139 char type __used, u64 start)
2140{
2141 struct process_args *args = arg;
2142
2143 if (strchr(name, '['))
2144 return 0;
2145
2146 args->start = start;
2147 return 1;
2148}
2149
2150/* Figure out the start address of kernel map from /proc/kallsyms */
2151static u64 machine__get_kernel_start_addr(struct machine *machine)
2152{
2153 const char *filename;
2154 char path[PATH_MAX];
2155 struct process_args args;
2156
2157 if (machine__is_host(machine)) {
2158 filename = "/proc/kallsyms";
2159 } else {
2160 if (machine__is_default_guest(machine))
2161 filename = (char *)symbol_conf.default_guest_kallsyms;
2162 else {
2163 sprintf(path, "%s/proc/kallsyms", machine->root_dir);
2164 filename = path;
2165 }
2166 }
2167
2168 if (kallsyms__parse(filename, &args, symbol__in_kernel) <= 0)
2169 return 0;
2170
2171 return args.start;
2172}
2173
2126int __machine__create_kernel_maps(struct machine *self, struct dso *kernel) 2174int __machine__create_kernel_maps(struct machine *self, struct dso *kernel)
2127{ 2175{
2128 enum map_type type; 2176 enum map_type type;
2177 u64 start = machine__get_kernel_start_addr(self);
2129 2178
2130 for (type = 0; type < MAP__NR_TYPES; ++type) { 2179 for (type = 0; type < MAP__NR_TYPES; ++type) {
2131 struct kmap *kmap; 2180 struct kmap *kmap;
2132 2181
2133 self->vmlinux_maps[type] = map__new2(0, kernel, type); 2182 self->vmlinux_maps[type] = map__new2(start, kernel, type);
2134 if (self->vmlinux_maps[type] == NULL) 2183 if (self->vmlinux_maps[type] == NULL)
2135 return -1; 2184 return -1;
2136 2185
diff --git a/usr/initramfs_data.S b/usr/initramfs_data.S
index 792a750d9441..c14322d1c0cf 100644
--- a/usr/initramfs_data.S
+++ b/usr/initramfs_data.S
@@ -22,14 +22,15 @@
22*/ 22*/
23 23
24#include <linux/stringify.h> 24#include <linux/stringify.h>
25#include <asm-generic/vmlinux.lds.h>
25 26
26.section .init.ramfs,"a" 27.section .init.ramfs,"a"
27__irf_start: 28__irf_start:
28.incbin __stringify(INITRAMFS_IMAGE) 29.incbin __stringify(INITRAMFS_IMAGE)
29__irf_end: 30__irf_end:
30.section .init.ramfs.info,"a" 31.section .init.ramfs.info,"a"
31.globl __initramfs_size 32.globl VMLINUX_SYMBOL(__initramfs_size)
32__initramfs_size: 33VMLINUX_SYMBOL(__initramfs_size):
33#ifdef CONFIG_64BIT 34#ifdef CONFIG_64BIT
34 .quad __irf_end - __irf_start 35 .quad __irf_end - __irf_start
35#else 36#else