aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-02-24 06:49:55 -0500
committerDavid S. Miller <davem@davemloft.net>2009-02-24 06:49:55 -0500
commit467388f29fc9cebfb70e7a187107b6b5d772cb44 (patch)
tree4e6fffa65f38addffc149a5fe88be3d2161eaf6e
parent028e1415a78733fcd2cba4b4c001826cc37a373e (diff)
parentf7e603ad8f78cd3b59e33fa72707da0cbabdf699 (diff)
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
-rw-r--r--.mailmap4
-rw-r--r--CREDITS1
-rw-r--r--Documentation/ABI/testing/sysfs-firmware-memmap2
-rw-r--r--Documentation/DocBook/Makefile2
-rw-r--r--Documentation/DocBook/device-drivers.tmpl418
-rw-r--r--Documentation/DocBook/kernel-api.tmpl377
-rw-r--r--Documentation/PCI/PCIEBUS-HOWTO.txt2
-rw-r--r--Documentation/cgroups/cgroups.txt6
-rw-r--r--Documentation/cgroups/cpusets.txt65
-rw-r--r--Documentation/cpu-freq/user-guide.txt16
-rw-r--r--Documentation/driver-model/device.txt8
-rw-r--r--Documentation/filesystems/sysfs-pci.txt13
-rw-r--r--Documentation/filesystems/sysfs.txt50
-rw-r--r--Documentation/filesystems/ubifs.txt7
-rw-r--r--Documentation/hwmon/hpfall.c101
-rw-r--r--Documentation/hwmon/lis3lv02d8
-rw-r--r--Documentation/kernel-doc-nano-HOWTO.txt7
-rw-r--r--Documentation/kernel-parameters.txt4
-rw-r--r--Documentation/tracers/mmiotrace.txt6
-rw-r--r--MAINTAINERS54
-rw-r--r--Makefile4
-rw-r--r--README2
-rw-r--r--arch/alpha/include/asm/bug.h4
-rw-r--r--arch/alpha/kernel/process.c8
-rw-r--r--arch/alpha/kernel/smp.c12
-rw-r--r--arch/arm/configs/at91sam9260ek_defconfig2
-rw-r--r--arch/arm/configs/at91sam9261ek_defconfig2
-rw-r--r--arch/arm/configs/at91sam9263ek_defconfig2
-rw-r--r--arch/arm/configs/at91sam9rlek_defconfig2
-rw-r--r--arch/arm/configs/qil-a9260_defconfig2
-rw-r--r--arch/arm/kernel/elf.c4
-rw-r--r--arch/arm/kernel/entry-armv.S1
-rw-r--r--arch/arm/kernel/entry-common.S2
-rw-r--r--arch/arm/kernel/irq.c2
-rw-r--r--arch/arm/kernel/machine_kexec.c4
-rw-r--r--arch/arm/mach-at91/at91cap9_devices.c2
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c2
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c2
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c2
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c2
-rw-r--r--arch/arm/mach-at91/gpio.c15
-rw-r--r--arch/arm/mach-at91/include/mach/board.h1
-rw-r--r--arch/arm/mach-ep93xx/include/mach/gesbc9312.h3
-rw-r--r--arch/arm/mach-ep93xx/include/mach/hardware.h1
-rw-r--r--arch/arm/mach-kirkwood/irq.c2
-rw-r--r--arch/arm/mach-msm/board-halibut.c1
-rw-r--r--arch/arm/mach-mv78xx0/irq.c2
-rw-r--r--arch/arm/mach-omap1/devices.c2
-rw-r--r--arch/arm/mach-omap1/mcbsp.c98
-rw-r--r--arch/arm/mach-omap2/clock.c16
-rw-r--r--arch/arm/mach-omap2/devices.c11
-rw-r--r--arch/arm/mach-omap2/id.c6
-rw-r--r--arch/arm/mach-omap2/irq.c1
-rw-r--r--arch/arm/mach-omap2/mcbsp.c145
-rw-r--r--arch/arm/mach-omap2/sleep24xx.S3
-rw-r--r--arch/arm/mach-omap2/timer-gp.c3
-rw-r--r--arch/arm/mach-orion5x/irq.c2
-rw-r--r--arch/arm/mach-pxa/dma.c18
-rw-r--r--arch/arm/mach-pxa/include/mach/regs-ac97.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/regs-ssp.h3
-rw-r--r--arch/arm/mach-pxa/pxa300.c4
-rw-r--r--arch/arm/mach-pxa/pxa320.c2
-rw-r--r--arch/arm/mach-sa1100/generic.c2
-rw-r--r--arch/arm/mm/fault-armv.c5
-rw-r--r--arch/arm/mm/mmu.c3
-rw-r--r--arch/arm/plat-omap/devices.c7
-rw-r--r--arch/arm/plat-omap/dma.c5
-rw-r--r--arch/arm/plat-omap/include/mach/cpu.h1
-rw-r--r--arch/arm/plat-omap/include/mach/mcbsp.h6
-rw-r--r--arch/arm/plat-omap/include/mach/mmc.h10
-rw-r--r--arch/arm/plat-omap/mcbsp.c52
-rw-r--r--arch/arm/plat-orion/gpio.c73
-rw-r--r--arch/arm/plat-orion/include/plat/gpio.h3
-rw-r--r--arch/avr32/mach-at32ap/include/mach/board.h1
-rw-r--r--arch/blackfin/Kconfig52
-rw-r--r--arch/blackfin/Makefile106
-rw-r--r--arch/blackfin/configs/BF518F-EZBRD_defconfig9
-rw-r--r--arch/blackfin/configs/BF526-EZBRD_defconfig2
-rw-r--r--arch/blackfin/configs/BF527-EZKIT_defconfig2
-rw-r--r--arch/blackfin/configs/BF533-EZKIT_defconfig2
-rw-r--r--arch/blackfin/configs/BF533-STAMP_defconfig2
-rw-r--r--arch/blackfin/configs/BF537-STAMP_defconfig2
-rw-r--r--arch/blackfin/configs/BF538-EZKIT_defconfig2
-rw-r--r--arch/blackfin/configs/BF548-EZKIT_defconfig2
-rw-r--r--arch/blackfin/configs/BF561-EZKIT_defconfig2
-rw-r--r--arch/blackfin/configs/CM-BF527_defconfig445
-rw-r--r--arch/blackfin/include/asm/checksum.h34
-rw-r--r--arch/blackfin/include/asm/delay.h35
-rw-r--r--arch/blackfin/include/asm/gpio.h58
-rw-r--r--arch/blackfin/include/asm/kgdb.h53
-rw-r--r--arch/blackfin/include/asm/mem_init.h2
-rw-r--r--arch/blackfin/include/asm/pda.h1
-rw-r--r--arch/blackfin/include/asm/reboot.h2
-rw-r--r--arch/blackfin/kernel/Makefile2
-rw-r--r--arch/blackfin/kernel/bfin_dma_5xx.c7
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c578
-rw-r--r--arch/blackfin/kernel/cplb-mpu/cplbinit.c4
-rw-r--r--arch/blackfin/kernel/cplb-nompu/cplbmgr.c12
-rw-r--r--arch/blackfin/kernel/irqchip.c8
-rw-r--r--arch/blackfin/kernel/reboot.c30
-rw-r--r--arch/blackfin/kernel/setup.c12
-rw-r--r--arch/blackfin/kernel/traps.c39
-rw-r--r--arch/blackfin/mach-bf518/boards/ezbrd.c59
-rw-r--r--arch/blackfin/mach-bf518/include/mach/portmux.h2
-rw-r--r--arch/blackfin/mach-bf527/boards/cm_bf527.c18
-rw-r--r--arch/blackfin/mach-bf527/boards/ezbrd.c18
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c18
-rw-r--r--arch/blackfin/mach-bf527/include/mach/portmux.h2
-rw-r--r--arch/blackfin/mach-bf533/boards/blackstamp.c4
-rw-r--r--arch/blackfin/mach-bf533/boards/stamp.c4
-rw-r--r--arch/blackfin/mach-bf533/include/mach/portmux.h5
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537.c6
-rw-r--r--arch/blackfin/mach-bf537/boards/generic_board.c12
-rw-r--r--arch/blackfin/mach-bf537/boards/minotaur.c8
-rw-r--r--arch/blackfin/mach-bf537/boards/pnav10.c10
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c14
-rw-r--r--arch/blackfin/mach-bf537/boards/tcm_bf537.c10
-rw-r--r--arch/blackfin/mach-bf537/include/mach/portmux.h1
-rw-r--r--arch/blackfin/mach-bf538/include/mach/portmux.h1
-rw-r--r--arch/blackfin/mach-bf548/boards/ezkit.c4
-rw-r--r--arch/blackfin/mach-bf548/include/mach/anomaly.h1
-rw-r--r--arch/blackfin/mach-bf548/include/mach/bf548.h12
-rw-r--r--arch/blackfin/mach-bf548/include/mach/gpio.h12
-rw-r--r--arch/blackfin/mach-bf548/include/mach/portmux.h1
-rw-r--r--arch/blackfin/mach-bf561/include/mach/defBF561.h2
-rw-r--r--arch/blackfin/mach-bf561/include/mach/portmux.h1
-rw-r--r--arch/blackfin/mach-common/clocks-init.c3
-rw-r--r--arch/blackfin/mach-common/entry.S9
-rw-r--r--arch/blackfin/mach-common/head.S84
-rw-r--r--arch/blackfin/mach-common/interrupt.S2
-rw-r--r--arch/blackfin/mach-common/ints-priority.c11
-rw-r--r--arch/blackfin/mach-common/pm.c11
-rw-r--r--arch/frv/mm/dma-alloc.c2
-rw-r--r--arch/ia64/Kconfig7
-rw-r--r--arch/ia64/configs/xen_domu_defconfig1601
-rw-r--r--arch/ia64/include/asm/kvm.h4
-rw-r--r--arch/ia64/include/asm/mmzone.h4
-rw-r--r--arch/ia64/include/asm/sn/bte.h2
-rw-r--r--arch/ia64/kernel/smpboot.c5
-rw-r--r--arch/ia64/kvm/kvm-ia64.c4
-rw-r--r--arch/ia64/kvm/process.c17
-rw-r--r--arch/ia64/mm/numa.c4
-rw-r--r--arch/ia64/sn/kernel/bte.c7
-rw-r--r--arch/ia64/sn/kernel/io_acpi_init.c2
-rw-r--r--arch/ia64/sn/kernel/io_init.c2
-rw-r--r--arch/ia64/xen/Kconfig3
-rw-r--r--arch/ia64/xen/xen_pv_ops.c4
-rw-r--r--arch/m68k/atari/ataints.c16
-rw-r--r--arch/m68k/atari/atakeyb.c4
-rw-r--r--arch/m68k/atari/config.c2
-rw-r--r--arch/m68k/atari/debug.c22
-rw-r--r--arch/m68k/atari/time.c8
-rw-r--r--arch/m68k/include/asm/atarihw.h4
-rw-r--r--arch/m68k/include/asm/atariints.h6
-rw-r--r--arch/mips/include/asm/spinlock.h1
-rw-r--r--arch/mn10300/Kconfig1
-rw-r--r--arch/mn10300/unit-asb2305/pci.c2
-rw-r--r--arch/powerpc/boot/dts/mpc8313erdb.dts11
-rw-r--r--arch/powerpc/configs/83xx/mpc8313_rdb_defconfig2
-rw-r--r--arch/powerpc/include/asm/pgtable-4k.h2
-rw-r--r--arch/powerpc/include/asm/pgtable-64k.h2
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc32.h3
-rw-r--r--arch/powerpc/kernel/align.c7
-rw-r--r--arch/powerpc/kernel/ftrace.c5
-rw-r--r--arch/powerpc/kernel/pci-common.c17
-rw-r--r--arch/powerpc/kvm/powerpc.c4
-rw-r--r--arch/powerpc/lib/sstep.c2
-rw-r--r--arch/powerpc/mm/fsl_booke_mmu.c4
-rw-r--r--arch/powerpc/mm/hash_low_32.S2
-rw-r--r--arch/powerpc/mm/numa.c5
-rw-r--r--arch/powerpc/mm/pgtable_32.c4
-rw-r--r--arch/powerpc/oprofile/cell/spu_profiler.c1
-rw-r--r--arch/powerpc/platforms/82xx/pq2ads-pci-pic.c2
-rw-r--r--arch/powerpc/platforms/ps3/mm.c2
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-memory.c1
-rw-r--r--arch/powerpc/sysdev/cpm2_pic.c2
-rw-r--r--arch/powerpc/sysdev/ipic.c2
-rw-r--r--arch/s390/defconfig87
-rw-r--r--arch/s390/include/asm/cputime.h2
-rw-r--r--arch/s390/include/asm/lowcore.h4
-rw-r--r--arch/s390/include/asm/setup.h2
-rw-r--r--arch/s390/kernel/irq.c2
-rw-r--r--arch/s390/kernel/setup.c9
-rw-r--r--arch/s390/kvm/kvm-s390.c4
-rw-r--r--arch/sh/boards/board-ap325rxa.c63
-rw-r--r--arch/sh/configs/ap325rxa_defconfig27
-rw-r--r--arch/sh/configs/migor_defconfig42
-rw-r--r--arch/sh/include/asm/mutex-llsc.h21
-rw-r--r--arch/sh/include/asm/syscall_32.h22
-rw-r--r--arch/sh/include/asm/syscall_64.h22
-rw-r--r--arch/sh/kernel/cpu/sh4/fpu.c2
-rw-r--r--arch/sh/kernel/setup.c8
-rw-r--r--arch/sh/kernel/signal_32.c4
-rw-r--r--arch/sh/kernel/signal_64.c4
-rw-r--r--arch/sh/lib/checksum.S69
-rw-r--r--arch/sparc/include/asm/cpudata_64.h2
-rw-r--r--arch/sparc/include/asm/irq_64.h4
-rw-r--r--arch/sparc/include/asm/kdebug_64.h2
-rw-r--r--arch/sparc/include/asm/nmi.h10
-rw-r--r--arch/sparc/include/asm/pcr.h46
-rw-r--r--arch/sparc/include/asm/pil.h1
-rw-r--r--arch/sparc/kernel/Makefile2
-rw-r--r--arch/sparc/kernel/cpu.c33
-rw-r--r--arch/sparc/kernel/head_64.S31
-rw-r--r--arch/sparc/kernel/irq_64.c68
-rw-r--r--arch/sparc/kernel/kernel.h1
-rw-r--r--arch/sparc/kernel/nmi.c225
-rw-r--r--arch/sparc/kernel/pcr.c158
-rw-r--r--arch/sparc/kernel/process_64.c5
-rw-r--r--arch/sparc/kernel/setup_64.c2
-rw-r--r--arch/sparc/kernel/ttable.S3
-rw-r--r--arch/sparc/lib/GENbzero.S6
-rw-r--r--arch/sparc/lib/GENcopy_from_user.S8
-rw-r--r--arch/sparc/lib/GENcopy_to_user.S8
-rw-r--r--arch/sparc/lib/NG2copy_from_user.S9
-rw-r--r--arch/sparc/lib/NG2copy_to_user.S9
-rw-r--r--arch/sparc/lib/NGbzero.S6
-rw-r--r--arch/sparc/lib/NGcopy_from_user.S9
-rw-r--r--arch/sparc/lib/NGcopy_to_user.S9
-rw-r--r--arch/sparc/lib/U1copy_from_user.S8
-rw-r--r--arch/sparc/lib/U1copy_to_user.S8
-rw-r--r--arch/sparc/lib/U3copy_from_user.S6
-rw-r--r--arch/sparc/lib/U3copy_to_user.S8
-rw-r--r--arch/sparc/lib/bzero.S6
-rw-r--r--arch/sparc/lib/copy_in_user.S61
-rw-r--r--arch/sparc/mm/fault_64.c44
-rw-r--r--arch/sparc/oprofile/init.c232
-rw-r--r--arch/um/drivers/vde_user.c6
-rw-r--r--arch/x86/Kconfig11
-rw-r--r--arch/x86/Kconfig.cpu28
-rw-r--r--arch/x86/Kconfig.debug24
-rw-r--r--arch/x86/ia32/ia32entry.S8
-rw-r--r--arch/x86/include/asm/a.out-core.h4
-rw-r--r--arch/x86/include/asm/cpufeature.h1
-rw-r--r--arch/x86/include/asm/kvm.h7
-rw-r--r--arch/x86/include/asm/math_emu.h29
-rw-r--r--arch/x86/include/asm/mmzone_32.h2
-rw-r--r--arch/x86/include/asm/mmzone_64.h2
-rw-r--r--arch/x86/include/asm/mpspec.h6
-rw-r--r--arch/x86/include/asm/page.h1
-rw-r--r--arch/x86/include/asm/paravirt.h18
-rw-r--r--arch/x86/include/asm/pgtable.h26
-rw-r--r--arch/x86/include/asm/processor.h2
-rw-r--r--arch/x86/include/asm/spinlock.h1
-rw-r--r--arch/x86/include/asm/traps.h4
-rw-r--r--arch/x86/include/asm/xen/page.h2
-rw-r--r--arch/x86/kernel/acpi/boot.c23
-rw-r--r--arch/x86/kernel/acpi/sleep.c4
-rw-r--r--arch/x86/kernel/acpi/wakeup_64.S30
-rw-r--r--arch/x86/kernel/apic.c4
-rw-r--r--arch/x86/kernel/apm_32.c4
-rw-r--r--arch/x86/kernel/cpu/cpufreq/Kconfig11
-rw-r--r--arch/x86/kernel/cpu/cpufreq/powernow-k8.c40
-rw-r--r--arch/x86/kernel/cpu/intel.c3
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c15
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_64.c7
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_amd_64.c2
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_intel_64.c4
-rw-r--r--arch/x86/kernel/entry_64.S1
-rw-r--r--arch/x86/kernel/ftrace.c17
-rw-r--r--arch/x86/kernel/hpet.c14
-rw-r--r--arch/x86/kernel/i8237.c17
-rw-r--r--arch/x86/kernel/io_apic.c25
-rw-r--r--arch/x86/kernel/irqinit_32.c12
-rw-r--r--arch/x86/kernel/olpc.c2
-rw-r--r--arch/x86/kernel/paravirt.c26
-rw-r--r--arch/x86/kernel/process.c6
-rw-r--r--arch/x86/kernel/process_32.c3
-rw-r--r--arch/x86/kernel/process_64.c9
-rw-r--r--arch/x86/kernel/ptrace.c16
-rw-r--r--arch/x86/kernel/setup.c2
-rw-r--r--arch/x86/kernel/time_64.c2
-rw-r--r--arch/x86/kernel/traps.c25
-rw-r--r--arch/x86/kernel/vmi_32.c11
-rw-r--r--arch/x86/kernel/vmiclock_32.c7
-rw-r--r--arch/x86/kvm/i8254.c2
-rw-r--r--arch/x86/kvm/irq.c7
-rw-r--r--arch/x86/kvm/irq.h1
-rw-r--r--arch/x86/kvm/lapic.c66
-rw-r--r--arch/x86/kvm/lapic.h2
-rw-r--r--arch/x86/kvm/mmu.c9
-rw-r--r--arch/x86/kvm/svm.c1
-rw-r--r--arch/x86/kvm/vmx.c5
-rw-r--r--arch/x86/kvm/x86.c10
-rw-r--r--arch/x86/mach-default/setup.c14
-rw-r--r--arch/x86/mach-voyager/setup.c14
-rw-r--r--arch/x86/mach-voyager/voyager_smp.c25
-rw-r--r--arch/x86/math-emu/fpu_entry.c6
-rw-r--r--arch/x86/math-emu/fpu_proto.h4
-rw-r--r--arch/x86/math-emu/fpu_system.h16
-rw-r--r--arch/x86/math-emu/get_address.c69
-rw-r--r--arch/x86/mm/fault.c8
-rw-r--r--arch/x86/mm/ioremap.c19
-rw-r--r--arch/x86/mm/numa_64.c2
-rw-r--r--arch/x86/mm/pageattr.c30
-rw-r--r--arch/x86/mm/pat.c83
-rw-r--r--arch/x86/xen/multicalls.h4
-rw-r--r--block/blk-timeout.c9
-rw-r--r--block/blktrace.c2
-rw-r--r--block/bsg.c17
-rw-r--r--block/genhd.c8
-rw-r--r--crypto/ahash.c2
-rw-r--r--crypto/algapi.c6
-rw-r--r--crypto/api.c20
-rw-r--r--crypto/lrw.c8
-rw-r--r--crypto/scatterwalk.c3
-rw-r--r--crypto/shash.c7
-rw-r--r--drivers/acpi/Kconfig10
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/acpica/tbutils.c7
-rw-r--r--drivers/acpi/acpica/uteval.c21
-rw-r--r--drivers/acpi/battery.c25
-rw-r--r--drivers/acpi/container.c5
-rw-r--r--drivers/acpi/dock.c14
-rw-r--r--drivers/acpi/ec.c11
-rw-r--r--drivers/acpi/glue.c8
-rw-r--r--drivers/acpi/osl.c54
-rw-r--r--drivers/acpi/pci_link.c2
-rw-r--r--drivers/acpi/processor_idle.c667
-rw-r--r--drivers/acpi/processor_perflib.c105
-rw-r--r--drivers/acpi/sleep.c53
-rw-r--r--drivers/acpi/tables.c7
-rw-r--r--drivers/acpi/video.c16
-rw-r--r--drivers/ata/ahci.c9
-rw-r--r--drivers/ata/libata-core.c96
-rw-r--r--drivers/ata/libata-eh.c87
-rw-r--r--drivers/ata/libata-pmp.c2
-rw-r--r--drivers/ata/libata-scsi.c1
-rw-r--r--drivers/ata/libata-sff.c28
-rw-r--r--drivers/ata/libata.h4
-rw-r--r--drivers/ata/pata_qdi.c2
-rw-r--r--drivers/ata/pata_via.c4
-rw-r--r--drivers/ata/sata_mv.c4
-rw-r--r--drivers/ata/sata_nv.c21
-rw-r--r--drivers/ata/sata_sil.c2
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/dd.c17
-rw-r--r--drivers/base/power/main.c3
-rw-r--r--drivers/base/sys.c7
-rw-r--r--drivers/block/aoe/aoe.h1
-rw-r--r--drivers/block/aoe/aoenet.c2
-rw-r--r--drivers/block/ataflop.c4
-rw-r--r--drivers/block/cciss.c215
-rw-r--r--drivers/block/floppy.c79
-rw-r--r--drivers/block/nbd.c9
-rw-r--r--drivers/block/paride/pg.c2
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/scc.h2
-rw-r--r--drivers/char/sx.c13
-rw-r--r--drivers/char/tpm/tpm_infineon.c4
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c47
-rw-r--r--drivers/dma/dmaengine.c2
-rw-r--r--drivers/dma/dw_dmac.c5
-rw-r--r--drivers/dma/dw_dmac_regs.h2
-rw-r--r--drivers/firewire/fw-card.c9
-rw-r--r--drivers/firmware/memmap.c2
-rw-r--r--drivers/gpu/drm/Kconfig15
-rw-r--r--drivers/gpu/drm/drm_crtc.c3
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c21
-rw-r--r--drivers/gpu/drm/drm_fops.c3
-rw-r--r--drivers/gpu/drm/drm_gem.c79
-rw-r--r--drivers/gpu/drm/drm_irq.c1
-rw-r--r--drivers/gpu/drm/drm_memory.c7
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c49
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c30
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h11
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c268
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c97
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c13
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h10
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c8
-rw-r--r--drivers/gpu/drm/i915/intel_display.c181
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h1
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c8
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c51
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c872
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo_regs.h404
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c27
-rw-r--r--drivers/hid/hid-core.c13
-rw-r--r--drivers/hid/hid-ids.h3
-rw-r--r--drivers/hid/hidraw.c14
-rw-r--r--drivers/hwmon/f71882fg.c4
-rw-r--r--drivers/hwmon/hp_accel.c94
-rw-r--r--drivers/hwmon/lis3lv02d.c195
-rw-r--r--drivers/hwmon/lis3lv02d.h21
-rw-r--r--drivers/hwmon/vt1211.c2
-rw-r--r--drivers/hwmon/w83627ehf.c2
-rw-r--r--drivers/ide/qd65xx.c2
-rw-r--r--drivers/ide/qd65xx.h2
-rw-r--r--drivers/ieee1394/dv1394.c8
-rw-r--r--drivers/md/dm-io.c2
-rw-r--r--drivers/md/dm-kcopyd.c2
-rw-r--r--drivers/md/linear.c6
-rw-r--r--drivers/md/md.c28
-rw-r--r--drivers/md/raid1.c3
-rw-r--r--drivers/media/common/tuners/tuner-simple.c10
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c16
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c16
-rw-r--r--drivers/media/radio/radio-si470x.c55
-rw-r--r--drivers/media/video/gspca/gspca.c5
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c26
-rw-r--r--drivers/mfd/htc-egpio.c4
-rw-r--r--drivers/mfd/pcf50633-core.c2
-rw-r--r--drivers/mfd/sm501.c26
-rw-r--r--drivers/mfd/twl4030-core.c2
-rw-r--r--drivers/mfd/wm8350-core.c48
-rw-r--r--drivers/mfd/wm8350-regmap.c2
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/misc/atmel-ssc.c2
-rw-r--r--drivers/misc/hpilo.c6
-rw-r--r--drivers/misc/hpilo.h2
-rw-r--r--drivers/misc/sgi-xp/xpc.h5
-rw-r--r--drivers/misc/sgi-xp/xpc_uv.c11
-rw-r--r--drivers/mmc/card/block.c2
-rw-r--r--drivers/mmc/card/mmc_test.c2
-rw-r--r--drivers/mmc/host/atmel-mci.c5
-rw-r--r--drivers/mmc/host/omap_hsmmc.c98
-rw-r--r--drivers/mmc/host/s3cmci.c2
-rw-r--r--drivers/mmc/host/sdhci-pci.c3
-rw-r--r--drivers/mmc/host/sdhci.c7
-rw-r--r--drivers/mmc/host/sdhci.h3
-rw-r--r--drivers/mtd/maps/sa1100-flash.c4
-rw-r--r--drivers/mtd/nand/atmel_nand.c3
-rw-r--r--drivers/net/arm/etherh.c2
-rw-r--r--drivers/parport/parport_atari.c6
-rw-r--r--drivers/parport/parport_serial.c5
-rw-r--r--drivers/pci/intel-iommu.c30
-rw-r--r--drivers/pci/msi.c10
-rw-r--r--drivers/pci/pci-driver.c164
-rw-r--r--drivers/pci/pci-sysfs.c4
-rw-r--r--drivers/pci/pci.c17
-rw-r--r--drivers/pci/pci.h20
-rw-r--r--drivers/pci/pcie/aspm.c4
-rw-r--r--drivers/pci/pcie/portdrv_pci.c16
-rw-r--r--drivers/pci/rom.c9
-rw-r--r--drivers/platform/x86/Kconfig3
-rw-r--r--drivers/platform/x86/asus-laptop.c176
-rw-r--r--drivers/platform/x86/asus_acpi.c16
-rw-r--r--drivers/platform/x86/eeepc-laptop.c164
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c25
-rw-r--r--drivers/platform/x86/hp-wmi.c6
-rw-r--r--drivers/platform/x86/panasonic-laptop.c2
-rw-r--r--drivers/power/pcf50633-charger.c3
-rw-r--r--drivers/rtc/Kconfig6
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-au1xxx.c2
-rw-r--r--drivers/rtc/rtc-dm355evm.c175
-rw-r--r--drivers/rtc/rtc-ds1390.c1
-rw-r--r--drivers/rtc/rtc-pxa.c2
-rw-r--r--drivers/s390/block/dasd.c46
-rw-r--r--drivers/s390/block/dasd_devmap.c2
-rw-r--r--drivers/s390/char/sclp.c5
-rw-r--r--drivers/s390/char/sclp_cmd.c5
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c15
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.h2
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c1
-rw-r--r--drivers/scsi/libiscsi.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c13
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h5
-rw-r--r--drivers/scsi/qla2xxx/qla_devtbl.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_fw.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h9
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c58
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c40
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c16
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/scsi_scan.c1
-rw-r--r--drivers/scsi/sg.c2
-rw-r--r--drivers/serial/8250.c15
-rw-r--r--drivers/serial/8250_pci.c36
-rw-r--r--drivers/serial/atmel_serial.c4
-rw-r--r--drivers/serial/jsm/jsm_driver.c3
-rw-r--r--drivers/spi/spi_gpio.c2
-rw-r--r--drivers/staging/android/Kconfig1
-rw-r--r--drivers/staging/android/ram_console.c14
-rw-r--r--drivers/staging/android/timed_gpio.c2
-rw-r--r--drivers/staging/at76_usb/Kconfig2
-rw-r--r--drivers/staging/at76_usb/at76_usb.c4620
-rw-r--r--drivers/staging/at76_usb/at76_usb.h227
-rw-r--r--drivers/staging/panel/panel.c10
-rw-r--r--drivers/usb/Makefile1
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/core/hcd-pci.c15
-rw-r--r--drivers/usb/core/hcd.h1
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c46
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c4
-rw-r--r--drivers/usb/host/ehci-pci.c1
-rw-r--r--drivers/usb/host/ohci-pci.c1
-rw-r--r--drivers/usb/host/uhci-hcd.c1
-rw-r--r--drivers/usb/host/whci/asl.c4
-rw-r--r--drivers/usb/host/whci/pzl.c4
-rw-r--r--drivers/usb/serial/aircable.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c5
-rw-r--r--drivers/usb/serial/ftdi_sio.h3
-rw-r--r--drivers/usb/serial/option.c93
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c10
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h2
-rw-r--r--drivers/usb/storage/scsiglue.c2
-rw-r--r--drivers/usb/storage/transport.c36
-rw-r--r--drivers/usb/storage/unusual_devs.h17
-rw-r--r--drivers/video/Kconfig8
-rw-r--r--drivers/video/atafb.c22
-rw-r--r--drivers/video/aty/aty128fb.c34
-rw-r--r--drivers/video/aty/atyfb_base.c42
-rw-r--r--drivers/video/aty/radeon_base.c10
-rw-r--r--drivers/video/aty/radeon_pm.c103
-rw-r--r--drivers/video/aty/radeonfb.h2
-rw-r--r--drivers/video/backlight/Makefile2
-rw-r--r--drivers/video/backlight/da903x_bl.c (renamed from drivers/video/backlight/da903x.c)0
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c2
-rw-r--r--drivers/video/fbcmap.c20
-rw-r--r--drivers/video/fbmem.c135
-rw-r--r--drivers/video/geode/gx1fb_core.c17
-rw-r--r--drivers/video/geode/gxfb_core.c17
-rw-r--r--drivers/video/geode/lxfb_core.c17
-rw-r--r--drivers/w1/slaves/w1_therm.c2
-rw-r--r--drivers/watchdog/Kconfig2
-rw-r--r--drivers/watchdog/at91rm9200_wdt.c4
-rw-r--r--drivers/watchdog/at91sam9_wdt.c1
-rw-r--r--drivers/watchdog/iTCO_vendor_support.c32
-rw-r--r--drivers/watchdog/iTCO_wdt.c35
-rw-r--r--drivers/xen/manage.c8
-rw-r--r--fs/binfmt_elf.c14
-rw-r--r--fs/bio.c5
-rw-r--r--fs/btrfs/Kconfig13
-rw-r--r--fs/btrfs/async-thread.c61
-rw-r--r--fs/btrfs/compression.c1
-rw-r--r--fs/btrfs/ctree.c315
-rw-r--r--fs/btrfs/ctree.h37
-rw-r--r--fs/btrfs/disk-io.c166
-rw-r--r--fs/btrfs/disk-io.h12
-rw-r--r--fs/btrfs/extent-tree.c519
-rw-r--r--fs/btrfs/extent_io.c134
-rw-r--r--fs/btrfs/extent_io.h18
-rw-r--r--fs/btrfs/extent_map.c1
-rw-r--r--fs/btrfs/file.c13
-rw-r--r--fs/btrfs/inode-map.c1
-rw-r--r--fs/btrfs/inode.c88
-rw-r--r--fs/btrfs/ioctl.c1
-rw-r--r--fs/btrfs/locking.c207
-rw-r--r--fs/btrfs/locking.h6
-rw-r--r--fs/btrfs/ordered-data.c4
-rw-r--r--fs/btrfs/ref-cache.c1
-rw-r--r--fs/btrfs/ref-cache.h1
-rw-r--r--fs/btrfs/super.c11
-rw-r--r--fs/btrfs/transaction.c6
-rw-r--r--fs/btrfs/tree-defrag.c1
-rw-r--r--fs/btrfs/tree-log.c356
-rw-r--r--fs/btrfs/volumes.c55
-rw-r--r--fs/btrfs/xattr.c48
-rw-r--r--fs/btrfs/xattr.h2
-rw-r--r--fs/buffer.c5
-rw-r--r--fs/cifs/CHANGES15
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/cifsglob.h6
-rw-r--r--fs/cifs/cifsproto.h4
-rw-r--r--fs/cifs/cifssmb.c7
-rw-r--r--fs/cifs/connect.c51
-rw-r--r--fs/cifs/dir.c307
-rw-r--r--fs/cifs/inode.c104
-rw-r--r--fs/cifs/readdir.c58
-rw-r--r--fs/cifs/sess.c91
-rw-r--r--fs/compat.c2
-rw-r--r--fs/compat_ioctl.c4
-rw-r--r--fs/ecryptfs/crypto.c4
-rw-r--r--fs/exec.c28
-rw-r--r--fs/ext2/super.c9
-rw-r--r--fs/ext3/super.c11
-rw-r--r--fs/ext4/ext4.h2
-rw-r--r--fs/ext4/inode.c27
-rw-r--r--fs/ext4/mballoc.c32
-rw-r--r--fs/ext4/migrate.c8
-rw-r--r--fs/ext4/super.c11
-rw-r--r--fs/hugetlbfs/inode.c8
-rw-r--r--fs/internal.h2
-rw-r--r--fs/jbd/journal.c17
-rw-r--r--fs/jbd2/journal.c17
-rw-r--r--fs/jbd2/transaction.c42
-rw-r--r--fs/lockd/svclock.c6
-rw-r--r--fs/namespace.c6
-rw-r--r--fs/notify/inotify/inotify.c2
-rw-r--r--fs/ocfs2/alloc.c3
-rw-r--r--fs/ocfs2/dcache.c42
-rw-r--r--fs/ocfs2/dcache.h9
-rw-r--r--fs/ocfs2/dlmglue.c4
-rw-r--r--fs/ocfs2/journal.h6
-rw-r--r--fs/ocfs2/ocfs2.h6
-rw-r--r--fs/ocfs2/quota_global.c4
-rw-r--r--fs/ocfs2/super.c3
-rw-r--r--fs/ocfs2/xattr.c17
-rw-r--r--fs/proc/inode.c4
-rw-r--r--fs/seq_file.c151
-rw-r--r--fs/super.c21
-rw-r--r--fs/timerfd.c12
-rw-r--r--fs/ubifs/budget.c35
-rw-r--r--fs/ubifs/debug.c122
-rw-r--r--fs/ubifs/debug.h36
-rw-r--r--fs/ubifs/dir.c96
-rw-r--r--fs/ubifs/file.c9
-rw-r--r--fs/ubifs/gc.c28
-rw-r--r--fs/ubifs/io.c22
-rw-r--r--fs/ubifs/journal.c2
-rw-r--r--fs/ubifs/lprops.c12
-rw-r--r--fs/ubifs/lpt_commit.c44
-rw-r--r--fs/ubifs/master.c2
-rw-r--r--fs/ubifs/orphan.c38
-rw-r--r--fs/ubifs/super.c195
-rw-r--r--fs/ubifs/tnc.c12
-rw-r--r--fs/ubifs/ubifs.h26
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c79
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c6
-rw-r--r--fs/xfs/xfs_dfrag.c10
-rw-r--r--fs/xfs/xfs_log_recover.c31
-rw-r--r--include/acpi/pdc_intel.h2
-rw-r--r--include/asm-frv/pgtable.h2
-rw-r--r--include/crypto/hash.h2
-rw-r--r--include/drm/drmP.h2
-rw-r--r--include/drm/drm_crtc.h2
-rw-r--r--include/drm/drm_crtc_helper.h10
-rw-r--r--include/drm/i915_drm.h2
-rw-r--r--include/linux/async.h8
-rw-r--r--include/linux/ata.h15
-rw-r--r--include/linux/bio.h2
-rw-r--r--include/linux/blktrace_api.h1
-rw-r--r--include/linux/cgroup.h1
-rw-r--r--include/linux/crypto.h7
-rw-r--r--include/linux/device.h2
-rw-r--r--include/linux/dmaengine.h2
-rw-r--r--include/linux/fb.h15
-rw-r--r--include/linux/firmware-map.h2
-rw-r--r--include/linux/fs.h24
-rw-r--r--include/linux/hugetlb.h11
-rw-r--r--include/linux/init_task.h11
-rw-r--r--include/linux/jbd2.h3
-rw-r--r--include/linux/kernel.h3
-rw-r--r--include/linux/kvm.h10
-rw-r--r--include/linux/kvm_host.h1
-rw-r--r--include/linux/libata.h19
-rw-r--r--include/linux/mm.h24
-rw-r--r--include/linux/mmzone.h2
-rw-r--r--include/linux/module.h1
-rw-r--r--include/linux/pci.h2
-rw-r--r--include/linux/pci_ids.h5
-rw-r--r--include/linux/pm.h2
-rw-r--r--include/linux/sched.h63
-rw-r--r--include/linux/seq_file.h1
-rw-r--r--include/linux/serial_core.h1
-rw-r--r--include/linux/slab.h1
-rw-r--r--include/linux/soundcard.h74
-rw-r--r--include/linux/spi/spi_bitbang.h7
-rw-r--r--include/linux/spinlock.h5
-rw-r--r--include/linux/syscalls.h28
-rw-r--r--include/linux/timerfd.h16
-rw-r--r--include/linux/vmalloc.h4
-rw-r--r--include/linux/wait.h11
-rw-r--r--include/video/aty128.h4
-rw-r--r--include/video/mach64.h24
-rw-r--r--include/video/radeon.h18
-rw-r--r--init/do_mounts.c13
-rw-r--r--init/do_mounts_md.c5
-rw-r--r--ipc/shm.c12
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/async.c94
-rw-r--r--kernel/cgroup.c5
-rw-r--r--kernel/exit.c3
-rw-r--r--kernel/fork.c6
-rw-r--r--kernel/futex.c53
-rw-r--r--kernel/irq/numa_migrate.c7
-rw-r--r--kernel/itimer.c4
-rw-r--r--kernel/kexec.c7
-rw-r--r--kernel/posix-cpu-timers.c123
-rw-r--r--kernel/power/Makefile2
-rw-r--r--kernel/power/console.c6
-rw-r--r--kernel/power/disk.c22
-rw-r--r--kernel/power/main.c34
-rw-r--r--kernel/power/swap.c5
-rw-r--r--kernel/power/user.c8
-rw-r--r--kernel/printk.c15
-rw-r--r--kernel/profile.c3
-rw-r--r--kernel/sched.c46
-rw-r--r--kernel/sched_fair.c11
-rw-r--r--kernel/sched_stats.h45
-rw-r--r--kernel/signal.c8
-rw-r--r--kernel/sys.c16
-rw-r--r--kernel/sysctl.c5
-rw-r--r--kernel/trace/Kconfig25
-rw-r--r--kernel/trace/ftrace.c11
-rw-r--r--kernel/trace/trace_mmiotrace.c14
-rw-r--r--kernel/trace/trace_selftest.c19
-rw-r--r--kernel/user.c3
-rw-r--r--kernel/wait.c59
-rw-r--r--lib/Kconfig.debug2
-rw-r--r--mm/fremap.c2
-rw-r--r--mm/hugetlb.c28
-rw-r--r--mm/memory.c2
-rw-r--r--mm/migrate.c2
-rw-r--r--mm/mlock.c12
-rw-r--r--mm/mmap.c48
-rw-r--r--mm/mprotect.c5
-rw-r--r--mm/page-writeback.c35
-rw-r--r--mm/page_alloc.c27
-rw-r--r--mm/page_cgroup.c3
-rw-r--r--mm/page_io.c2
-rw-r--r--mm/rmap.c3
-rw-r--r--mm/slab.c1
-rw-r--r--mm/slob.c1
-rw-r--r--mm/slub.c1
-rw-r--r--mm/swapfile.c4
-rw-r--r--mm/util.c20
-rw-r--r--mm/vmalloc.c10
-rw-r--r--mm/vmscan.c28
-rw-r--r--net/ipv4/cipso_ipv4.c9
-rw-r--r--scripts/bootgraph.pl4
-rwxr-xr-xscripts/kernel-doc40
-rw-r--r--scripts/markup_oops.pl161
-rw-r--r--scripts/mod/file2alias.c1
-rwxr-xr-xscripts/package/mkspec8
-rwxr-xr-xscripts/setlocalversion9
-rwxr-xr-xscripts/tags.sh12
-rw-r--r--security/selinux/netlabel.c4
-rw-r--r--sound/arm/aaci.c6
-rw-r--r--sound/core/jack.c2
-rw-r--r--sound/core/oss/pcm_oss.c2
-rw-r--r--sound/drivers/mtpav.c3
-rw-r--r--sound/oss/dmasound/dmasound_atari.c16
-rw-r--r--sound/pci/hda/hda_codec.c19
-rw-r--r--sound/pci/hda/hda_codec.h1
-rw-r--r--sound/pci/hda/hda_hwdep.c2
-rw-r--r--sound/pci/hda/hda_intel.c8
-rw-r--r--sound/pci/hda/hda_local.h2
-rw-r--r--sound/pci/hda/hda_proc.c3
-rw-r--r--sound/pci/hda/patch_analog.c15
-rw-r--r--sound/pci/hda/patch_intelhdmi.c61
-rw-r--r--sound/pci/hda/patch_realtek.c6
-rw-r--r--sound/pci/hda/patch_sigmatel.c15
-rw-r--r--sound/pci/intel8x0.c2
-rw-r--r--sound/pci/oxygen/virtuoso.c17
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c2
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.h2
-rw-r--r--sound/soc/codecs/tlv320aic3x.c11
-rw-r--r--sound/soc/codecs/wm8350.c2
-rw-r--r--sound/soc/codecs/wm8990.c7
-rw-r--r--sound/soc/omap/omap-pcm.c5
-rw-r--r--sound/soc/omap/sdp3430.c4
-rw-r--r--sound/soc/soc-core.c5
-rw-r--r--sound/usb/usbaudio.c21
-rw-r--r--sound/usb/usbmidi.c1
-rw-r--r--virt/kvm/iommu.c6
-rw-r--r--virt/kvm/kvm_main.c43
754 files changed, 17542 insertions, 7709 deletions
diff --git a/.mailmap b/.mailmap
index 4e83e7b52d15..a62e6a84fd1e 100644
--- a/.mailmap
+++ b/.mailmap
@@ -92,6 +92,7 @@ Rudolf Marek <R.Marek@sh.cvut.cz>
92Rui Saraiva <rmps@joel.ist.utl.pt> 92Rui Saraiva <rmps@joel.ist.utl.pt>
93Sachin P Sant <ssant@in.ibm.com> 93Sachin P Sant <ssant@in.ibm.com>
94Sam Ravnborg <sam@mars.ravnborg.org> 94Sam Ravnborg <sam@mars.ravnborg.org>
95Sascha Hauer <s.hauer@pengutronix.de>
95S.Çağlar Onur <caglar@pardus.org.tr> 96S.Çağlar Onur <caglar@pardus.org.tr>
96Simon Kelley <simon@thekelleys.org.uk> 97Simon Kelley <simon@thekelleys.org.uk>
97Stéphane Witzmann <stephane.witzmann@ubpmes.univ-bpclermont.fr> 98Stéphane Witzmann <stephane.witzmann@ubpmes.univ-bpclermont.fr>
@@ -100,6 +101,7 @@ Tejun Heo <htejun@gmail.com>
100Thomas Graf <tgraf@suug.ch> 101Thomas Graf <tgraf@suug.ch>
101Tony Luck <tony.luck@intel.com> 102Tony Luck <tony.luck@intel.com>
102Tsuneo Yoshioka <Tsuneo.Yoshioka@f-secure.com> 103Tsuneo Yoshioka <Tsuneo.Yoshioka@f-secure.com>
103Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
104Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> 104Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
105Uwe Kleine-König <ukl@pengutronix.de>
106Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
105Valdis Kletnieks <Valdis.Kletnieks@vt.edu> 107Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
diff --git a/CREDITS b/CREDITS
index 2b39168c06aa..5e0736722afd 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2166,7 +2166,6 @@ D: Initial implementation of VC's, pty's and select()
2166 2166
2167N: Pavel Machek 2167N: Pavel Machek
2168E: pavel@ucw.cz 2168E: pavel@ucw.cz
2169E: pavel@suse.cz
2170D: Softcursor for vga, hypertech cdrom support, vcsa bugfix, nbd 2169D: Softcursor for vga, hypertech cdrom support, vcsa bugfix, nbd
2171D: sun4/330 port, capabilities for elf, speedup for rm on ext2, USB, 2170D: sun4/330 port, capabilities for elf, speedup for rm on ext2, USB,
2172D: work on suspend-to-ram/disk, killing duplicates from ioctl32 2171D: work on suspend-to-ram/disk, killing duplicates from ioctl32
diff --git a/Documentation/ABI/testing/sysfs-firmware-memmap b/Documentation/ABI/testing/sysfs-firmware-memmap
index 0d99ee6ae02e..eca0d65087dc 100644
--- a/Documentation/ABI/testing/sysfs-firmware-memmap
+++ b/Documentation/ABI/testing/sysfs-firmware-memmap
@@ -1,6 +1,6 @@
1What: /sys/firmware/memmap/ 1What: /sys/firmware/memmap/
2Date: June 2008 2Date: June 2008
3Contact: Bernhard Walle <bwalle@suse.de> 3Contact: Bernhard Walle <bernhard.walle@gmx.de>
4Description: 4Description:
5 On all platforms, the firmware provides a memory map which the 5 On all platforms, the firmware provides a memory map which the
6 kernel reads. The resources from that memory map are registered 6 kernel reads. The resources from that memory map are registered
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index dc3154e49279..1462ed86d40a 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -6,7 +6,7 @@
6# To add a new book the only step required is to add the book to the 6# To add a new book the only step required is to add the book to the
7# list of DOCBOOKS. 7# list of DOCBOOKS.
8 8
9DOCBOOKS := z8530book.xml mcabook.xml \ 9DOCBOOKS := z8530book.xml mcabook.xml device-drivers.xml \
10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \ 10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
11 procfs-guide.xml writing_usb_driver.xml networking.xml \ 11 procfs-guide.xml writing_usb_driver.xml networking.xml \
12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \ 12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \
diff --git a/Documentation/DocBook/device-drivers.tmpl b/Documentation/DocBook/device-drivers.tmpl
new file mode 100644
index 000000000000..94a20fe8fedf
--- /dev/null
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -0,0 +1,418 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="LinuxDriversAPI">
6 <bookinfo>
7 <title>Linux Device Drivers</title>
8
9 <legalnotice>
10 <para>
11 This documentation is free software; you can redistribute
12 it and/or modify it under the terms of the GNU General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later
15 version.
16 </para>
17
18 <para>
19 This program is distributed in the hope that it will be
20 useful, but WITHOUT ANY WARRANTY; without even the implied
21 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
23 </para>
24
25 <para>
26 You should have received a copy of the GNU General Public
27 License along with this program; if not, write to the Free
28 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 MA 02111-1307 USA
30 </para>
31
32 <para>
33 For more details see the file COPYING in the source
34 distribution of Linux.
35 </para>
36 </legalnotice>
37 </bookinfo>
38
39<toc></toc>
40
41 <chapter id="Basics">
42 <title>Driver Basics</title>
43 <sect1><title>Driver Entry and Exit points</title>
44!Iinclude/linux/init.h
45 </sect1>
46
47 <sect1><title>Atomic and pointer manipulation</title>
48!Iarch/x86/include/asm/atomic_32.h
49!Iarch/x86/include/asm/unaligned.h
50 </sect1>
51
52 <sect1><title>Delaying, scheduling, and timer routines</title>
53!Iinclude/linux/sched.h
54!Ekernel/sched.c
55!Ekernel/timer.c
56 </sect1>
57 <sect1><title>High-resolution timers</title>
58!Iinclude/linux/ktime.h
59!Iinclude/linux/hrtimer.h
60!Ekernel/hrtimer.c
61 </sect1>
62 <sect1><title>Workqueues and Kevents</title>
63!Ekernel/workqueue.c
64 </sect1>
65 <sect1><title>Internal Functions</title>
66!Ikernel/exit.c
67!Ikernel/signal.c
68!Iinclude/linux/kthread.h
69!Ekernel/kthread.c
70 </sect1>
71
72 <sect1><title>Kernel objects manipulation</title>
73<!--
74X!Iinclude/linux/kobject.h
75-->
76!Elib/kobject.c
77 </sect1>
78
79 <sect1><title>Kernel utility functions</title>
80!Iinclude/linux/kernel.h
81!Ekernel/printk.c
82!Ekernel/panic.c
83!Ekernel/sys.c
84!Ekernel/rcupdate.c
85 </sect1>
86
87 <sect1><title>Device Resource Management</title>
88!Edrivers/base/devres.c
89 </sect1>
90
91 </chapter>
92
93 <chapter id="devdrivers">
94 <title>Device drivers infrastructure</title>
95 <sect1><title>Device Drivers Base</title>
96<!--
97X!Iinclude/linux/device.h
98-->
99!Edrivers/base/driver.c
100!Edrivers/base/core.c
101!Edrivers/base/class.c
102!Edrivers/base/firmware_class.c
103!Edrivers/base/transport_class.c
104<!-- Cannot be included, because
105 attribute_container_add_class_device_adapter
106 and attribute_container_classdev_to_container
107 exceed allowed 44 characters maximum
108X!Edrivers/base/attribute_container.c
109-->
110!Edrivers/base/sys.c
111<!--
112X!Edrivers/base/interface.c
113-->
114!Edrivers/base/platform.c
115!Edrivers/base/bus.c
116 </sect1>
117 <sect1><title>Device Drivers Power Management</title>
118!Edrivers/base/power/main.c
119 </sect1>
120 <sect1><title>Device Drivers ACPI Support</title>
121<!-- Internal functions only
122X!Edrivers/acpi/sleep/main.c
123X!Edrivers/acpi/sleep/wakeup.c
124X!Edrivers/acpi/motherboard.c
125X!Edrivers/acpi/bus.c
126-->
127!Edrivers/acpi/scan.c
128!Idrivers/acpi/scan.c
129<!-- No correct structured comments
130X!Edrivers/acpi/pci_bind.c
131-->
132 </sect1>
133 <sect1><title>Device drivers PnP support</title>
134!Idrivers/pnp/core.c
135<!-- No correct structured comments
136X!Edrivers/pnp/system.c
137 -->
138!Edrivers/pnp/card.c
139!Idrivers/pnp/driver.c
140!Edrivers/pnp/manager.c
141!Edrivers/pnp/support.c
142 </sect1>
143 <sect1><title>Userspace IO devices</title>
144!Edrivers/uio/uio.c
145!Iinclude/linux/uio_driver.h
146 </sect1>
147 </chapter>
148
149 <chapter id="parportdev">
150 <title>Parallel Port Devices</title>
151!Iinclude/linux/parport.h
152!Edrivers/parport/ieee1284.c
153!Edrivers/parport/share.c
154!Idrivers/parport/daisy.c
155 </chapter>
156
157 <chapter id="message_devices">
158 <title>Message-based devices</title>
159 <sect1><title>Fusion message devices</title>
160!Edrivers/message/fusion/mptbase.c
161!Idrivers/message/fusion/mptbase.c
162!Edrivers/message/fusion/mptscsih.c
163!Idrivers/message/fusion/mptscsih.c
164!Idrivers/message/fusion/mptctl.c
165!Idrivers/message/fusion/mptspi.c
166!Idrivers/message/fusion/mptfc.c
167!Idrivers/message/fusion/mptlan.c
168 </sect1>
169 <sect1><title>I2O message devices</title>
170!Iinclude/linux/i2o.h
171!Idrivers/message/i2o/core.h
172!Edrivers/message/i2o/iop.c
173!Idrivers/message/i2o/iop.c
174!Idrivers/message/i2o/config-osm.c
175!Edrivers/message/i2o/exec-osm.c
176!Idrivers/message/i2o/exec-osm.c
177!Idrivers/message/i2o/bus-osm.c
178!Edrivers/message/i2o/device.c
179!Idrivers/message/i2o/device.c
180!Idrivers/message/i2o/driver.c
181!Idrivers/message/i2o/pci.c
182!Idrivers/message/i2o/i2o_block.c
183!Idrivers/message/i2o/i2o_scsi.c
184!Idrivers/message/i2o/i2o_proc.c
185 </sect1>
186 </chapter>
187
188 <chapter id="snddev">
189 <title>Sound Devices</title>
190!Iinclude/sound/core.h
191!Esound/sound_core.c
192!Iinclude/sound/pcm.h
193!Esound/core/pcm.c
194!Esound/core/device.c
195!Esound/core/info.c
196!Esound/core/rawmidi.c
197!Esound/core/sound.c
198!Esound/core/memory.c
199!Esound/core/pcm_memory.c
200!Esound/core/init.c
201!Esound/core/isadma.c
202!Esound/core/control.c
203!Esound/core/pcm_lib.c
204!Esound/core/hwdep.c
205!Esound/core/pcm_native.c
206!Esound/core/memalloc.c
207<!-- FIXME: Removed for now since no structured comments in source
208X!Isound/sound_firmware.c
209-->
210 </chapter>
211
212 <chapter id="uart16x50">
213 <title>16x50 UART Driver</title>
214!Iinclude/linux/serial_core.h
215!Edrivers/serial/serial_core.c
216!Edrivers/serial/8250.c
217 </chapter>
218
219 <chapter id="fbdev">
220 <title>Frame Buffer Library</title>
221
222 <para>
223 The frame buffer drivers depend heavily on four data structures.
224 These structures are declared in include/linux/fb.h. They are
225 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
226 The last three can be made available to and from userland.
227 </para>
228
229 <para>
230 fb_info defines the current state of a particular video card.
231 Inside fb_info, there exists a fb_ops structure which is a
232 collection of needed functions to make fbdev and fbcon work.
233 fb_info is only visible to the kernel.
234 </para>
235
236 <para>
237 fb_var_screeninfo is used to describe the features of a video card
238 that are user defined. With fb_var_screeninfo, things such as
239 depth and the resolution may be defined.
240 </para>
241
242 <para>
243 The next structure is fb_fix_screeninfo. This defines the
244 properties of a card that are created when a mode is set and can't
245 be changed otherwise. A good example of this is the start of the
246 frame buffer memory. This "locks" the address of the frame buffer
247 memory, so that it cannot be changed or moved.
248 </para>
249
250 <para>
251 The last structure is fb_monospecs. In the old API, there was
252 little importance for fb_monospecs. This allowed for forbidden things
253 such as setting a mode of 800x600 on a fix frequency monitor. With
254 the new API, fb_monospecs prevents such things, and if used
255 correctly, can prevent a monitor from being cooked. fb_monospecs
256 will not be useful until kernels 2.5.x.
257 </para>
258
259 <sect1><title>Frame Buffer Memory</title>
260!Edrivers/video/fbmem.c
261 </sect1>
262<!--
263 <sect1><title>Frame Buffer Console</title>
264X!Edrivers/video/console/fbcon.c
265 </sect1>
266-->
267 <sect1><title>Frame Buffer Colormap</title>
268!Edrivers/video/fbcmap.c
269 </sect1>
270<!-- FIXME:
271 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
272 out until somebody adds docs. KAO
273 <sect1><title>Frame Buffer Generic Functions</title>
274X!Idrivers/video/fbgen.c
275 </sect1>
276KAO -->
277 <sect1><title>Frame Buffer Video Mode Database</title>
278!Idrivers/video/modedb.c
279!Edrivers/video/modedb.c
280 </sect1>
281 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
282!Edrivers/video/macmodes.c
283 </sect1>
284 <sect1><title>Frame Buffer Fonts</title>
285 <para>
286 Refer to the file drivers/video/console/fonts.c for more information.
287 </para>
288<!-- FIXME: Removed for now since no structured comments in source
289X!Idrivers/video/console/fonts.c
290-->
291 </sect1>
292 </chapter>
293
294 <chapter id="input_subsystem">
295 <title>Input Subsystem</title>
296!Iinclude/linux/input.h
297!Edrivers/input/input.c
298!Edrivers/input/ff-core.c
299!Edrivers/input/ff-memless.c
300 </chapter>
301
302 <chapter id="spi">
303 <title>Serial Peripheral Interface (SPI)</title>
304 <para>
305 SPI is the "Serial Peripheral Interface", widely used with
306 embedded systems because it is a simple and efficient
307 interface: basically a multiplexed shift register.
308 Its three signal wires hold a clock (SCK, often in the range
309 of 1-20 MHz), a "Master Out, Slave In" (MOSI) data line, and
310 a "Master In, Slave Out" (MISO) data line.
311 SPI is a full duplex protocol; for each bit shifted out the
312 MOSI line (one per clock) another is shifted in on the MISO line.
313 Those bits are assembled into words of various sizes on the
314 way to and from system memory.
315 An additional chipselect line is usually active-low (nCS);
316 four signals are normally used for each peripheral, plus
317 sometimes an interrupt.
318 </para>
319 <para>
320 The SPI bus facilities listed here provide a generalized
321 interface to declare SPI busses and devices, manage them
322 according to the standard Linux driver model, and perform
323 input/output operations.
324 At this time, only "master" side interfaces are supported,
325 where Linux talks to SPI peripherals and does not implement
326 such a peripheral itself.
327 (Interfaces to support implementing SPI slaves would
328 necessarily look different.)
329 </para>
330 <para>
331 The programming interface is structured around two kinds of driver,
332 and two kinds of device.
333 A "Controller Driver" abstracts the controller hardware, which may
334 be as simple as a set of GPIO pins or as complex as a pair of FIFOs
335 connected to dual DMA engines on the other side of the SPI shift
336 register (maximizing throughput). Such drivers bridge between
337 whatever bus they sit on (often the platform bus) and SPI, and
338 expose the SPI side of their device as a
339 <structname>struct spi_master</structname>.
340 SPI devices are children of that master, represented as a
341 <structname>struct spi_device</structname> and manufactured from
342 <structname>struct spi_board_info</structname> descriptors which
343 are usually provided by board-specific initialization code.
344 A <structname>struct spi_driver</structname> is called a
345 "Protocol Driver", and is bound to a spi_device using normal
346 driver model calls.
347 </para>
348 <para>
349 The I/O model is a set of queued messages. Protocol drivers
350 submit one or more <structname>struct spi_message</structname>
351 objects, which are processed and completed asynchronously.
352 (There are synchronous wrappers, however.) Messages are
353 built from one or more <structname>struct spi_transfer</structname>
354 objects, each of which wraps a full duplex SPI transfer.
355 A variety of protocol tweaking options are needed, because
356 different chips adopt very different policies for how they
357 use the bits transferred with SPI.
358 </para>
359!Iinclude/linux/spi/spi.h
360!Fdrivers/spi/spi.c spi_register_board_info
361!Edrivers/spi/spi.c
362 </chapter>
363
364 <chapter id="i2c">
365 <title>I<superscript>2</superscript>C and SMBus Subsystem</title>
366
367 <para>
368 I<superscript>2</superscript>C (or without fancy typography, "I2C")
369 is an acronym for the "Inter-IC" bus, a simple bus protocol which is
370 widely used where low data rate communications suffice.
371 Since it's also a licensed trademark, some vendors use another
372 name (such as "Two-Wire Interface", TWI) for the same bus.
373 I2C only needs two signals (SCL for clock, SDA for data), conserving
374 board real estate and minimizing signal quality issues.
375 Most I2C devices use seven bit addresses, and bus speeds of up
376 to 400 kHz; there's a high speed extension (3.4 MHz) that's not yet
377 found wide use.
378 I2C is a multi-master bus; open drain signaling is used to
379 arbitrate between masters, as well as to handshake and to
380 synchronize clocks from slower clients.
381 </para>
382
383 <para>
384 The Linux I2C programming interfaces support only the master
385 side of bus interactions, not the slave side.
386 The programming interface is structured around two kinds of driver,
387 and two kinds of device.
388 An I2C "Adapter Driver" abstracts the controller hardware; it binds
389 to a physical device (perhaps a PCI device or platform_device) and
390 exposes a <structname>struct i2c_adapter</structname> representing
391 each I2C bus segment it manages.
392 On each I2C bus segment will be I2C devices represented by a
393 <structname>struct i2c_client</structname>. Those devices will
394 be bound to a <structname>struct i2c_driver</structname>,
395 which should follow the standard Linux driver model.
396 (At this writing, a legacy model is more widely used.)
397 There are functions to perform various I2C protocol operations; at
398 this writing all such functions are usable only from task context.
399 </para>
400
401 <para>
402 The System Management Bus (SMBus) is a sibling protocol. Most SMBus
403 systems are also I2C conformant. The electrical constraints are
404 tighter for SMBus, and it standardizes particular protocol messages
405 and idioms. Controllers that support I2C can also support most
406 SMBus operations, but SMBus controllers don't support all the protocol
407 options that an I2C controller will.
408 There are functions to perform various SMBus protocol operations,
409 either using I2C primitives or by issuing SMBus commands to
410 i2c_adapter devices which don't support those I2C operations.
411 </para>
412
413!Iinclude/linux/i2c.h
414!Fdrivers/i2c/i2c-boardinfo.c i2c_register_board_info
415!Edrivers/i2c/i2c-core.c
416 </chapter>
417
418</book>
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index 5818ff75786a..bc962cda6504 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -38,58 +38,6 @@
38 38
39<toc></toc> 39<toc></toc>
40 40
41 <chapter id="Basics">
42 <title>Driver Basics</title>
43 <sect1><title>Driver Entry and Exit points</title>
44!Iinclude/linux/init.h
45 </sect1>
46
47 <sect1><title>Atomic and pointer manipulation</title>
48!Iarch/x86/include/asm/atomic_32.h
49!Iarch/x86/include/asm/unaligned.h
50 </sect1>
51
52 <sect1><title>Delaying, scheduling, and timer routines</title>
53!Iinclude/linux/sched.h
54!Ekernel/sched.c
55!Ekernel/timer.c
56 </sect1>
57 <sect1><title>High-resolution timers</title>
58!Iinclude/linux/ktime.h
59!Iinclude/linux/hrtimer.h
60!Ekernel/hrtimer.c
61 </sect1>
62 <sect1><title>Workqueues and Kevents</title>
63!Ekernel/workqueue.c
64 </sect1>
65 <sect1><title>Internal Functions</title>
66!Ikernel/exit.c
67!Ikernel/signal.c
68!Iinclude/linux/kthread.h
69!Ekernel/kthread.c
70 </sect1>
71
72 <sect1><title>Kernel objects manipulation</title>
73<!--
74X!Iinclude/linux/kobject.h
75-->
76!Elib/kobject.c
77 </sect1>
78
79 <sect1><title>Kernel utility functions</title>
80!Iinclude/linux/kernel.h
81!Ekernel/printk.c
82!Ekernel/panic.c
83!Ekernel/sys.c
84!Ekernel/rcupdate.c
85 </sect1>
86
87 <sect1><title>Device Resource Management</title>
88!Edrivers/base/devres.c
89 </sect1>
90
91 </chapter>
92
93 <chapter id="adt"> 41 <chapter id="adt">
94 <title>Data Types</title> 42 <title>Data Types</title>
95 <sect1><title>Doubly Linked Lists</title> 43 <sect1><title>Doubly Linked Lists</title>
@@ -298,62 +246,6 @@ X!Earch/x86/kernel/mca_32.c
298!Ikernel/acct.c 246!Ikernel/acct.c
299 </chapter> 247 </chapter>
300 248
301 <chapter id="devdrivers">
302 <title>Device drivers infrastructure</title>
303 <sect1><title>Device Drivers Base</title>
304<!--
305X!Iinclude/linux/device.h
306-->
307!Edrivers/base/driver.c
308!Edrivers/base/core.c
309!Edrivers/base/class.c
310!Edrivers/base/firmware_class.c
311!Edrivers/base/transport_class.c
312<!-- Cannot be included, because
313 attribute_container_add_class_device_adapter
314 and attribute_container_classdev_to_container
315 exceed allowed 44 characters maximum
316X!Edrivers/base/attribute_container.c
317-->
318!Edrivers/base/sys.c
319<!--
320X!Edrivers/base/interface.c
321-->
322!Edrivers/base/platform.c
323!Edrivers/base/bus.c
324 </sect1>
325 <sect1><title>Device Drivers Power Management</title>
326!Edrivers/base/power/main.c
327 </sect1>
328 <sect1><title>Device Drivers ACPI Support</title>
329<!-- Internal functions only
330X!Edrivers/acpi/sleep/main.c
331X!Edrivers/acpi/sleep/wakeup.c
332X!Edrivers/acpi/motherboard.c
333X!Edrivers/acpi/bus.c
334-->
335!Edrivers/acpi/scan.c
336!Idrivers/acpi/scan.c
337<!-- No correct structured comments
338X!Edrivers/acpi/pci_bind.c
339-->
340 </sect1>
341 <sect1><title>Device drivers PnP support</title>
342!Idrivers/pnp/core.c
343<!-- No correct structured comments
344X!Edrivers/pnp/system.c
345 -->
346!Edrivers/pnp/card.c
347!Idrivers/pnp/driver.c
348!Edrivers/pnp/manager.c
349!Edrivers/pnp/support.c
350 </sect1>
351 <sect1><title>Userspace IO devices</title>
352!Edrivers/uio/uio.c
353!Iinclude/linux/uio_driver.h
354 </sect1>
355 </chapter>
356
357 <chapter id="blkdev"> 249 <chapter id="blkdev">
358 <title>Block Devices</title> 250 <title>Block Devices</title>
359!Eblock/blk-core.c 251!Eblock/blk-core.c
@@ -381,275 +273,6 @@ X!Edrivers/pnp/system.c
381!Edrivers/char/misc.c 273!Edrivers/char/misc.c
382 </chapter> 274 </chapter>
383 275
384 <chapter id="parportdev">
385 <title>Parallel Port Devices</title>
386!Iinclude/linux/parport.h
387!Edrivers/parport/ieee1284.c
388!Edrivers/parport/share.c
389!Idrivers/parport/daisy.c
390 </chapter>
391
392 <chapter id="message_devices">
393 <title>Message-based devices</title>
394 <sect1><title>Fusion message devices</title>
395!Edrivers/message/fusion/mptbase.c
396!Idrivers/message/fusion/mptbase.c
397!Edrivers/message/fusion/mptscsih.c
398!Idrivers/message/fusion/mptscsih.c
399!Idrivers/message/fusion/mptctl.c
400!Idrivers/message/fusion/mptspi.c
401!Idrivers/message/fusion/mptfc.c
402!Idrivers/message/fusion/mptlan.c
403 </sect1>
404 <sect1><title>I2O message devices</title>
405!Iinclude/linux/i2o.h
406!Idrivers/message/i2o/core.h
407!Edrivers/message/i2o/iop.c
408!Idrivers/message/i2o/iop.c
409!Idrivers/message/i2o/config-osm.c
410!Edrivers/message/i2o/exec-osm.c
411!Idrivers/message/i2o/exec-osm.c
412!Idrivers/message/i2o/bus-osm.c
413!Edrivers/message/i2o/device.c
414!Idrivers/message/i2o/device.c
415!Idrivers/message/i2o/driver.c
416!Idrivers/message/i2o/pci.c
417!Idrivers/message/i2o/i2o_block.c
418!Idrivers/message/i2o/i2o_scsi.c
419!Idrivers/message/i2o/i2o_proc.c
420 </sect1>
421 </chapter>
422
423 <chapter id="snddev">
424 <title>Sound Devices</title>
425!Iinclude/sound/core.h
426!Esound/sound_core.c
427!Iinclude/sound/pcm.h
428!Esound/core/pcm.c
429!Esound/core/device.c
430!Esound/core/info.c
431!Esound/core/rawmidi.c
432!Esound/core/sound.c
433!Esound/core/memory.c
434!Esound/core/pcm_memory.c
435!Esound/core/init.c
436!Esound/core/isadma.c
437!Esound/core/control.c
438!Esound/core/pcm_lib.c
439!Esound/core/hwdep.c
440!Esound/core/pcm_native.c
441!Esound/core/memalloc.c
442<!-- FIXME: Removed for now since no structured comments in source
443X!Isound/sound_firmware.c
444-->
445 </chapter>
446
447 <chapter id="uart16x50">
448 <title>16x50 UART Driver</title>
449!Iinclude/linux/serial_core.h
450!Edrivers/serial/serial_core.c
451!Edrivers/serial/8250.c
452 </chapter>
453
454 <chapter id="fbdev">
455 <title>Frame Buffer Library</title>
456
457 <para>
458 The frame buffer drivers depend heavily on four data structures.
459 These structures are declared in include/linux/fb.h. They are
460 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
461 The last three can be made available to and from userland.
462 </para>
463
464 <para>
465 fb_info defines the current state of a particular video card.
466 Inside fb_info, there exists a fb_ops structure which is a
467 collection of needed functions to make fbdev and fbcon work.
468 fb_info is only visible to the kernel.
469 </para>
470
471 <para>
472 fb_var_screeninfo is used to describe the features of a video card
473 that are user defined. With fb_var_screeninfo, things such as
474 depth and the resolution may be defined.
475 </para>
476
477 <para>
478 The next structure is fb_fix_screeninfo. This defines the
479 properties of a card that are created when a mode is set and can't
480 be changed otherwise. A good example of this is the start of the
481 frame buffer memory. This "locks" the address of the frame buffer
482 memory, so that it cannot be changed or moved.
483 </para>
484
485 <para>
486 The last structure is fb_monospecs. In the old API, there was
487 little importance for fb_monospecs. This allowed for forbidden things
488 such as setting a mode of 800x600 on a fix frequency monitor. With
489 the new API, fb_monospecs prevents such things, and if used
490 correctly, can prevent a monitor from being cooked. fb_monospecs
491 will not be useful until kernels 2.5.x.
492 </para>
493
494 <sect1><title>Frame Buffer Memory</title>
495!Edrivers/video/fbmem.c
496 </sect1>
497<!--
498 <sect1><title>Frame Buffer Console</title>
499X!Edrivers/video/console/fbcon.c
500 </sect1>
501-->
502 <sect1><title>Frame Buffer Colormap</title>
503!Edrivers/video/fbcmap.c
504 </sect1>
505<!-- FIXME:
506 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
507 out until somebody adds docs. KAO
508 <sect1><title>Frame Buffer Generic Functions</title>
509X!Idrivers/video/fbgen.c
510 </sect1>
511KAO -->
512 <sect1><title>Frame Buffer Video Mode Database</title>
513!Idrivers/video/modedb.c
514!Edrivers/video/modedb.c
515 </sect1>
516 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
517!Edrivers/video/macmodes.c
518 </sect1>
519 <sect1><title>Frame Buffer Fonts</title>
520 <para>
521 Refer to the file drivers/video/console/fonts.c for more information.
522 </para>
523<!-- FIXME: Removed for now since no structured comments in source
524X!Idrivers/video/console/fonts.c
525-->
526 </sect1>
527 </chapter>
528
529 <chapter id="input_subsystem">
530 <title>Input Subsystem</title>
531!Iinclude/linux/input.h
532!Edrivers/input/input.c
533!Edrivers/input/ff-core.c
534!Edrivers/input/ff-memless.c
535 </chapter>
536
537 <chapter id="spi">
538 <title>Serial Peripheral Interface (SPI)</title>
539 <para>
540 SPI is the "Serial Peripheral Interface", widely used with
541 embedded systems because it is a simple and efficient
542 interface: basically a multiplexed shift register.
543 Its three signal wires hold a clock (SCK, often in the range
544 of 1-20 MHz), a "Master Out, Slave In" (MOSI) data line, and
545 a "Master In, Slave Out" (MISO) data line.
546 SPI is a full duplex protocol; for each bit shifted out the
547 MOSI line (one per clock) another is shifted in on the MISO line.
548 Those bits are assembled into words of various sizes on the
549 way to and from system memory.
550 An additional chipselect line is usually active-low (nCS);
551 four signals are normally used for each peripheral, plus
552 sometimes an interrupt.
553 </para>
554 <para>
555 The SPI bus facilities listed here provide a generalized
556 interface to declare SPI busses and devices, manage them
557 according to the standard Linux driver model, and perform
558 input/output operations.
559 At this time, only "master" side interfaces are supported,
560 where Linux talks to SPI peripherals and does not implement
561 such a peripheral itself.
562 (Interfaces to support implementing SPI slaves would
563 necessarily look different.)
564 </para>
565 <para>
566 The programming interface is structured around two kinds of driver,
567 and two kinds of device.
568 A "Controller Driver" abstracts the controller hardware, which may
569 be as simple as a set of GPIO pins or as complex as a pair of FIFOs
570 connected to dual DMA engines on the other side of the SPI shift
571 register (maximizing throughput). Such drivers bridge between
572 whatever bus they sit on (often the platform bus) and SPI, and
573 expose the SPI side of their device as a
574 <structname>struct spi_master</structname>.
575 SPI devices are children of that master, represented as a
576 <structname>struct spi_device</structname> and manufactured from
577 <structname>struct spi_board_info</structname> descriptors which
578 are usually provided by board-specific initialization code.
579 A <structname>struct spi_driver</structname> is called a
580 "Protocol Driver", and is bound to a spi_device using normal
581 driver model calls.
582 </para>
583 <para>
584 The I/O model is a set of queued messages. Protocol drivers
585 submit one or more <structname>struct spi_message</structname>
586 objects, which are processed and completed asynchronously.
587 (There are synchronous wrappers, however.) Messages are
588 built from one or more <structname>struct spi_transfer</structname>
589 objects, each of which wraps a full duplex SPI transfer.
590 A variety of protocol tweaking options are needed, because
591 different chips adopt very different policies for how they
592 use the bits transferred with SPI.
593 </para>
594!Iinclude/linux/spi/spi.h
595!Fdrivers/spi/spi.c spi_register_board_info
596!Edrivers/spi/spi.c
597 </chapter>
598
599 <chapter id="i2c">
600 <title>I<superscript>2</superscript>C and SMBus Subsystem</title>
601
602 <para>
603 I<superscript>2</superscript>C (or without fancy typography, "I2C")
604 is an acronym for the "Inter-IC" bus, a simple bus protocol which is
605 widely used where low data rate communications suffice.
606 Since it's also a licensed trademark, some vendors use another
607 name (such as "Two-Wire Interface", TWI) for the same bus.
608 I2C only needs two signals (SCL for clock, SDA for data), conserving
609 board real estate and minimizing signal quality issues.
610 Most I2C devices use seven bit addresses, and bus speeds of up
611 to 400 kHz; there's a high speed extension (3.4 MHz) that's not yet
612 found wide use.
613 I2C is a multi-master bus; open drain signaling is used to
614 arbitrate between masters, as well as to handshake and to
615 synchronize clocks from slower clients.
616 </para>
617
618 <para>
619 The Linux I2C programming interfaces support only the master
620 side of bus interactions, not the slave side.
621 The programming interface is structured around two kinds of driver,
622 and two kinds of device.
623 An I2C "Adapter Driver" abstracts the controller hardware; it binds
624 to a physical device (perhaps a PCI device or platform_device) and
625 exposes a <structname>struct i2c_adapter</structname> representing
626 each I2C bus segment it manages.
627 On each I2C bus segment will be I2C devices represented by a
628 <structname>struct i2c_client</structname>. Those devices will
629 be bound to a <structname>struct i2c_driver</structname>,
630 which should follow the standard Linux driver model.
631 (At this writing, a legacy model is more widely used.)
632 There are functions to perform various I2C protocol operations; at
633 this writing all such functions are usable only from task context.
634 </para>
635
636 <para>
637 The System Management Bus (SMBus) is a sibling protocol. Most SMBus
638 systems are also I2C conformant. The electrical constraints are
639 tighter for SMBus, and it standardizes particular protocol messages
640 and idioms. Controllers that support I2C can also support most
641 SMBus operations, but SMBus controllers don't support all the protocol
642 options that an I2C controller will.
643 There are functions to perform various SMBus protocol operations,
644 either using I2C primitives or by issuing SMBus commands to
645 i2c_adapter devices which don't support those I2C operations.
646 </para>
647
648!Iinclude/linux/i2c.h
649!Fdrivers/i2c/i2c-boardinfo.c i2c_register_board_info
650!Edrivers/i2c/i2c-core.c
651 </chapter>
652
653 <chapter id="clk"> 276 <chapter id="clk">
654 <title>Clock Framework</title> 277 <title>Clock Framework</title>
655 278
diff --git a/Documentation/PCI/PCIEBUS-HOWTO.txt b/Documentation/PCI/PCIEBUS-HOWTO.txt
index 9a07e38631b0..6bd5f372adec 100644
--- a/Documentation/PCI/PCIEBUS-HOWTO.txt
+++ b/Documentation/PCI/PCIEBUS-HOWTO.txt
@@ -93,7 +93,7 @@ the PCI Express Port Bus driver from loading a service driver.
93 93
94int pcie_port_service_register(struct pcie_port_service_driver *new) 94int pcie_port_service_register(struct pcie_port_service_driver *new)
95 95
96This API replaces the Linux Driver Model's pci_module_init API. A 96This API replaces the Linux Driver Model's pci_register_driver API. A
97service driver should always calls pcie_port_service_register at 97service driver should always calls pcie_port_service_register at
98module init. Note that after service driver being loaded, calls 98module init. Note that after service driver being loaded, calls
99such as pci_enable_device(dev) and pci_set_master(dev) are no longer 99such as pci_enable_device(dev) and pci_set_master(dev) are no longer
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt
index d9e5d6f41b92..93feb8444489 100644
--- a/Documentation/cgroups/cgroups.txt
+++ b/Documentation/cgroups/cgroups.txt
@@ -252,10 +252,8 @@ cgroup file system directories.
252When a task is moved from one cgroup to another, it gets a new 252When a task is moved from one cgroup to another, it gets a new
253css_set pointer - if there's an already existing css_set with the 253css_set pointer - if there's an already existing css_set with the
254desired collection of cgroups then that group is reused, else a new 254desired collection of cgroups then that group is reused, else a new
255css_set is allocated. Note that the current implementation uses a 255css_set is allocated. The appropriate existing css_set is located by
256linear search to locate an appropriate existing css_set, so isn't 256looking into a hash table.
257very efficient. A future version will use a hash table for better
258performance.
259 257
260To allow access from a cgroup to the css_sets (and hence tasks) 258To allow access from a cgroup to the css_sets (and hence tasks)
261that comprise it, a set of cg_cgroup_link objects form a lattice; 259that comprise it, a set of cg_cgroup_link objects form a lattice;
diff --git a/Documentation/cgroups/cpusets.txt b/Documentation/cgroups/cpusets.txt
index 5c86c258c791..0611e9528c7c 100644
--- a/Documentation/cgroups/cpusets.txt
+++ b/Documentation/cgroups/cpusets.txt
@@ -142,7 +142,7 @@ into the rest of the kernel, none in performance critical paths:
142 - in fork and exit, to attach and detach a task from its cpuset. 142 - in fork and exit, to attach and detach a task from its cpuset.
143 - in sched_setaffinity, to mask the requested CPUs by what's 143 - in sched_setaffinity, to mask the requested CPUs by what's
144 allowed in that tasks cpuset. 144 allowed in that tasks cpuset.
145 - in sched.c migrate_all_tasks(), to keep migrating tasks within 145 - in sched.c migrate_live_tasks(), to keep migrating tasks within
146 the CPUs allowed by their cpuset, if possible. 146 the CPUs allowed by their cpuset, if possible.
147 - in the mbind and set_mempolicy system calls, to mask the requested 147 - in the mbind and set_mempolicy system calls, to mask the requested
148 Memory Nodes by what's allowed in that tasks cpuset. 148 Memory Nodes by what's allowed in that tasks cpuset.
@@ -175,6 +175,10 @@ files describing that cpuset:
175 - mem_exclusive flag: is memory placement exclusive? 175 - mem_exclusive flag: is memory placement exclusive?
176 - mem_hardwall flag: is memory allocation hardwalled 176 - mem_hardwall flag: is memory allocation hardwalled
177 - memory_pressure: measure of how much paging pressure in cpuset 177 - memory_pressure: measure of how much paging pressure in cpuset
178 - memory_spread_page flag: if set, spread page cache evenly on allowed nodes
179 - memory_spread_slab flag: if set, spread slab cache evenly on allowed nodes
180 - sched_load_balance flag: if set, load balance within CPUs on that cpuset
181 - sched_relax_domain_level: the searching range when migrating tasks
178 182
179In addition, the root cpuset only has the following file: 183In addition, the root cpuset only has the following file:
180 - memory_pressure_enabled flag: compute memory_pressure? 184 - memory_pressure_enabled flag: compute memory_pressure?
@@ -252,7 +256,7 @@ is causing.
252 256
253This is useful both on tightly managed systems running a wide mix of 257This is useful both on tightly managed systems running a wide mix of
254submitted jobs, which may choose to terminate or re-prioritize jobs that 258submitted jobs, which may choose to terminate or re-prioritize jobs that
255are trying to use more memory than allowed on the nodes assigned them, 259are trying to use more memory than allowed on the nodes assigned to them,
256and with tightly coupled, long running, massively parallel scientific 260and with tightly coupled, long running, massively parallel scientific
257computing jobs that will dramatically fail to meet required performance 261computing jobs that will dramatically fail to meet required performance
258goals if they start to use more memory than allowed to them. 262goals if they start to use more memory than allowed to them.
@@ -378,7 +382,7 @@ as cpusets and sched_setaffinity.
378The algorithmic cost of load balancing and its impact on key shared 382The algorithmic cost of load balancing and its impact on key shared
379kernel data structures such as the task list increases more than 383kernel data structures such as the task list increases more than
380linearly with the number of CPUs being balanced. So the scheduler 384linearly with the number of CPUs being balanced. So the scheduler
381has support to partition the systems CPUs into a number of sched 385has support to partition the systems CPUs into a number of sched
382domains such that it only load balances within each sched domain. 386domains such that it only load balances within each sched domain.
383Each sched domain covers some subset of the CPUs in the system; 387Each sched domain covers some subset of the CPUs in the system;
384no two sched domains overlap; some CPUs might not be in any sched 388no two sched domains overlap; some CPUs might not be in any sched
@@ -485,17 +489,22 @@ of CPUs allowed to a cpuset having 'sched_load_balance' enabled.
485The internal kernel cpuset to scheduler interface passes from the 489The internal kernel cpuset to scheduler interface passes from the
486cpuset code to the scheduler code a partition of the load balanced 490cpuset code to the scheduler code a partition of the load balanced
487CPUs in the system. This partition is a set of subsets (represented 491CPUs in the system. This partition is a set of subsets (represented
488as an array of cpumask_t) of CPUs, pairwise disjoint, that cover all 492as an array of struct cpumask) of CPUs, pairwise disjoint, that cover
489the CPUs that must be load balanced. 493all the CPUs that must be load balanced.
490 494
491Whenever the 'sched_load_balance' flag changes, or CPUs come or go 495The cpuset code builds a new such partition and passes it to the
492from a cpuset with this flag enabled, or a cpuset with this flag 496scheduler sched domain setup code, to have the sched domains rebuilt
493enabled is removed, the cpuset code builds a new such partition and 497as necessary, whenever:
494passes it to the scheduler sched domain setup code, to have the sched 498 - the 'sched_load_balance' flag of a cpuset with non-empty CPUs changes,
495domains rebuilt as necessary. 499 - or CPUs come or go from a cpuset with this flag enabled,
500 - or 'sched_relax_domain_level' value of a cpuset with non-empty CPUs
501 and with this flag enabled changes,
502 - or a cpuset with non-empty CPUs and with this flag enabled is removed,
503 - or a cpu is offlined/onlined.
496 504
497This partition exactly defines what sched domains the scheduler should 505This partition exactly defines what sched domains the scheduler should
498setup - one sched domain for each element (cpumask_t) in the partition. 506setup - one sched domain for each element (struct cpumask) in the
507partition.
499 508
500The scheduler remembers the currently active sched domain partitions. 509The scheduler remembers the currently active sched domain partitions.
501When the scheduler routine partition_sched_domains() is invoked from 510When the scheduler routine partition_sched_domains() is invoked from
@@ -559,7 +568,7 @@ domain, the largest value among those is used. Be careful, if one
559requests 0 and others are -1 then 0 is used. 568requests 0 and others are -1 then 0 is used.
560 569
561Note that modifying this file will have both good and bad effects, 570Note that modifying this file will have both good and bad effects,
562and whether it is acceptable or not will be depend on your situation. 571and whether it is acceptable or not depends on your situation.
563Don't modify this file if you are not sure. 572Don't modify this file if you are not sure.
564 573
565If your situation is: 574If your situation is:
@@ -600,19 +609,15 @@ to allocate a page of memory for that task.
600 609
601If a cpuset has its 'cpus' modified, then each task in that cpuset 610If a cpuset has its 'cpus' modified, then each task in that cpuset
602will have its allowed CPU placement changed immediately. Similarly, 611will have its allowed CPU placement changed immediately. Similarly,
603if a tasks pid is written to a cpusets 'tasks' file, in either its 612if a tasks pid is written to another cpusets 'tasks' file, then its
604current cpuset or another cpuset, then its allowed CPU placement is 613allowed CPU placement is changed immediately. If such a task had been
605changed immediately. If such a task had been bound to some subset 614bound to some subset of its cpuset using the sched_setaffinity() call,
606of its cpuset using the sched_setaffinity() call, the task will be 615the task will be allowed to run on any CPU allowed in its new cpuset,
607allowed to run on any CPU allowed in its new cpuset, negating the 616negating the effect of the prior sched_setaffinity() call.
608affect of the prior sched_setaffinity() call.
609 617
610In summary, the memory placement of a task whose cpuset is changed is 618In summary, the memory placement of a task whose cpuset is changed is
611updated by the kernel, on the next allocation of a page for that task, 619updated by the kernel, on the next allocation of a page for that task,
612but the processor placement is not updated, until that tasks pid is 620and the processor placement is updated immediately.
613rewritten to the 'tasks' file of its cpuset. This is done to avoid
614impacting the scheduler code in the kernel with a check for changes
615in a tasks processor placement.
616 621
617Normally, once a page is allocated (given a physical page 622Normally, once a page is allocated (given a physical page
618of main memory) then that page stays on whatever node it 623of main memory) then that page stays on whatever node it
@@ -681,10 +686,14 @@ and then start a subshell 'sh' in that cpuset:
681 # The next line should display '/Charlie' 686 # The next line should display '/Charlie'
682 cat /proc/self/cpuset 687 cat /proc/self/cpuset
683 688
684In the future, a C library interface to cpusets will likely be 689There are ways to query or modify cpusets:
685available. For now, the only way to query or modify cpusets is 690 - via the cpuset file system directly, using the various cd, mkdir, echo,
686via the cpuset file system, using the various cd, mkdir, echo, cat, 691 cat, rmdir commands from the shell, or their equivalent from C.
687rmdir commands from the shell, or their equivalent from C. 692 - via the C library libcpuset.
693 - via the C library libcgroup.
694 (http://sourceforge.net/proects/libcg/)
695 - via the python application cset.
696 (http://developer.novell.com/wiki/index.php/Cpuset)
688 697
689The sched_setaffinity calls can also be done at the shell prompt using 698The sched_setaffinity calls can also be done at the shell prompt using
690SGI's runon or Robert Love's taskset. The mbind and set_mempolicy 699SGI's runon or Robert Love's taskset. The mbind and set_mempolicy
@@ -756,7 +765,7 @@ mount -t cpuset X /dev/cpuset
756 765
757is equivalent to 766is equivalent to
758 767
759mount -t cgroup -ocpuset X /dev/cpuset 768mount -t cgroup -ocpuset,noprefix X /dev/cpuset
760echo "/sbin/cpuset_release_agent" > /dev/cpuset/release_agent 769echo "/sbin/cpuset_release_agent" > /dev/cpuset/release_agent
761 770
7622.2 Adding/removing cpus 7712.2 Adding/removing cpus
diff --git a/Documentation/cpu-freq/user-guide.txt b/Documentation/cpu-freq/user-guide.txt
index e3443ddcfb89..917918f84fc7 100644
--- a/Documentation/cpu-freq/user-guide.txt
+++ b/Documentation/cpu-freq/user-guide.txt
@@ -195,19 +195,3 @@ scaling_setspeed. By "echoing" a new frequency into this
195 you can change the speed of the CPU, 195 you can change the speed of the CPU,
196 but only within the limits of 196 but only within the limits of
197 scaling_min_freq and scaling_max_freq. 197 scaling_min_freq and scaling_max_freq.
198
199
2003.2 Deprecated Interfaces
201-------------------------
202
203Depending on your kernel configuration, you might find the following
204cpufreq-related files:
205/proc/cpufreq
206/proc/sys/cpu/*/speed
207/proc/sys/cpu/*/speed-min
208/proc/sys/cpu/*/speed-max
209
210These are files for deprecated interfaces to cpufreq, which offer far
211less functionality. Because of this, these interfaces aren't described
212here.
213
diff --git a/Documentation/driver-model/device.txt b/Documentation/driver-model/device.txt
index a05ec50f8004..a7cbfff40d07 100644
--- a/Documentation/driver-model/device.txt
+++ b/Documentation/driver-model/device.txt
@@ -127,9 +127,11 @@ void unlock_device(struct device * dev);
127Attributes 127Attributes
128~~~~~~~~~~ 128~~~~~~~~~~
129struct device_attribute { 129struct device_attribute {
130 struct attribute attr; 130 struct attribute attr;
131 ssize_t (*show)(struct device * dev, char * buf, size_t count, loff_t off); 131 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
132 ssize_t (*store)(struct device * dev, const char * buf, size_t count, loff_t off); 132 char *buf);
133 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
134 const char *buf, size_t count);
133}; 135};
134 136
135Attributes of devices can be exported via drivers using a simple 137Attributes of devices can be exported via drivers using a simple
diff --git a/Documentation/filesystems/sysfs-pci.txt b/Documentation/filesystems/sysfs-pci.txt
index 68ef48839c04..9f8740ca3f3b 100644
--- a/Documentation/filesystems/sysfs-pci.txt
+++ b/Documentation/filesystems/sysfs-pci.txt
@@ -9,6 +9,7 @@ that support it. For example, a given bus might look like this:
9 | |-- class 9 | |-- class
10 | |-- config 10 | |-- config
11 | |-- device 11 | |-- device
12 | |-- enable
12 | |-- irq 13 | |-- irq
13 | |-- local_cpus 14 | |-- local_cpus
14 | |-- resource 15 | |-- resource
@@ -32,6 +33,7 @@ files, each with their own function.
32 class PCI class (ascii, ro) 33 class PCI class (ascii, ro)
33 config PCI config space (binary, rw) 34 config PCI config space (binary, rw)
34 device PCI device (ascii, ro) 35 device PCI device (ascii, ro)
36 enable Whether the device is enabled (ascii, rw)
35 irq IRQ number (ascii, ro) 37 irq IRQ number (ascii, ro)
36 local_cpus nearby CPU mask (cpumask, ro) 38 local_cpus nearby CPU mask (cpumask, ro)
37 resource PCI resource host addresses (ascii, ro) 39 resource PCI resource host addresses (ascii, ro)
@@ -57,10 +59,19 @@ used to do actual device programming from userspace. Note that some platforms
57don't support mmapping of certain resources, so be sure to check the return 59don't support mmapping of certain resources, so be sure to check the return
58value from any attempted mmap. 60value from any attempted mmap.
59 61
62The 'enable' file provides a counter that indicates how many times the device
63has been enabled. If the 'enable' file currently returns '4', and a '1' is
64echoed into it, it will then return '5'. Echoing a '0' into it will decrease
65the count. Even when it returns to 0, though, some of the initialisation
66may not be reversed.
67
60The 'rom' file is special in that it provides read-only access to the device's 68The 'rom' file is special in that it provides read-only access to the device's
61ROM file, if available. It's disabled by default, however, so applications 69ROM file, if available. It's disabled by default, however, so applications
62should write the string "1" to the file to enable it before attempting a read 70should write the string "1" to the file to enable it before attempting a read
63call, and disable it following the access by writing "0" to the file. 71call, and disable it following the access by writing "0" to the file. Note
72that the device must be enabled for a rom read to return data succesfully.
73In the event a driver is not bound to the device, it can be enabled using the
74'enable' file, documented above.
64 75
65Accessing legacy resources through sysfs 76Accessing legacy resources through sysfs
66---------------------------------------- 77----------------------------------------
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt
index 9e9c348275a9..7e81e37c0b1e 100644
--- a/Documentation/filesystems/sysfs.txt
+++ b/Documentation/filesystems/sysfs.txt
@@ -2,8 +2,10 @@
2sysfs - _The_ filesystem for exporting kernel objects. 2sysfs - _The_ filesystem for exporting kernel objects.
3 3
4Patrick Mochel <mochel@osdl.org> 4Patrick Mochel <mochel@osdl.org>
5Mike Murphy <mamurph@cs.clemson.edu>
5 6
610 January 2003 7Revised: 22 February 2009
8Original: 10 January 2003
7 9
8 10
9What it is: 11What it is:
@@ -64,12 +66,13 @@ An attribute definition is simply:
64 66
65struct attribute { 67struct attribute {
66 char * name; 68 char * name;
69 struct module *owner;
67 mode_t mode; 70 mode_t mode;
68}; 71};
69 72
70 73
71int sysfs_create_file(struct kobject * kobj, struct attribute * attr); 74int sysfs_create_file(struct kobject * kobj, const struct attribute * attr);
72void sysfs_remove_file(struct kobject * kobj, struct attribute * attr); 75void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr);
73 76
74 77
75A bare attribute contains no means to read or write the value of the 78A bare attribute contains no means to read or write the value of the
@@ -80,9 +83,11 @@ a specific object type.
80For example, the driver model defines struct device_attribute like: 83For example, the driver model defines struct device_attribute like:
81 84
82struct device_attribute { 85struct device_attribute {
83 struct attribute attr; 86 struct attribute attr;
84 ssize_t (*show)(struct device * dev, char * buf); 87 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
85 ssize_t (*store)(struct device * dev, const char * buf); 88 char *buf);
89 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
90 const char *buf, size_t count);
86}; 91};
87 92
88int device_create_file(struct device *, struct device_attribute *); 93int device_create_file(struct device *, struct device_attribute *);
@@ -90,12 +95,8 @@ void device_remove_file(struct device *, struct device_attribute *);
90 95
91It also defines this helper for defining device attributes: 96It also defines this helper for defining device attributes:
92 97
93#define DEVICE_ATTR(_name, _mode, _show, _store) \ 98#define DEVICE_ATTR(_name, _mode, _show, _store) \
94struct device_attribute dev_attr_##_name = { \ 99struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
95 .attr = {.name = __stringify(_name) , .mode = _mode }, \
96 .show = _show, \
97 .store = _store, \
98};
99 100
100For example, declaring 101For example, declaring
101 102
@@ -107,9 +108,9 @@ static struct device_attribute dev_attr_foo = {
107 .attr = { 108 .attr = {
108 .name = "foo", 109 .name = "foo",
109 .mode = S_IWUSR | S_IRUGO, 110 .mode = S_IWUSR | S_IRUGO,
111 .show = show_foo,
112 .store = store_foo,
110 }, 113 },
111 .show = show_foo,
112 .store = store_foo,
113}; 114};
114 115
115 116
@@ -161,10 +162,12 @@ To read or write attributes, show() or store() methods must be
161specified when declaring the attribute. The method types should be as 162specified when declaring the attribute. The method types should be as
162simple as those defined for device attributes: 163simple as those defined for device attributes:
163 164
164 ssize_t (*show)(struct device * dev, char * buf); 165ssize_t (*show)(struct device * dev, struct device_attribute * attr,
165 ssize_t (*store)(struct device * dev, const char * buf); 166 char * buf);
167ssize_t (*store)(struct device * dev, struct device_attribute * attr,
168 const char * buf);
166 169
167IOW, they should take only an object and a buffer as parameters. 170IOW, they should take only an object, an attribute, and a buffer as parameters.
168 171
169 172
170sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the 173sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the
@@ -299,14 +302,16 @@ The following interface layers currently exist in sysfs:
299Structure: 302Structure:
300 303
301struct device_attribute { 304struct device_attribute {
302 struct attribute attr; 305 struct attribute attr;
303 ssize_t (*show)(struct device * dev, char * buf); 306 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
304 ssize_t (*store)(struct device * dev, const char * buf); 307 char *buf);
308 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
309 const char *buf, size_t count);
305}; 310};
306 311
307Declaring: 312Declaring:
308 313
309DEVICE_ATTR(_name, _str, _mode, _show, _store); 314DEVICE_ATTR(_name, _mode, _show, _store);
310 315
311Creation/Removal: 316Creation/Removal:
312 317
@@ -342,7 +347,8 @@ Structure:
342struct driver_attribute { 347struct driver_attribute {
343 struct attribute attr; 348 struct attribute attr;
344 ssize_t (*show)(struct device_driver *, char * buf); 349 ssize_t (*show)(struct device_driver *, char * buf);
345 ssize_t (*store)(struct device_driver *, const char * buf); 350 ssize_t (*store)(struct device_driver *, const char * buf,
351 size_t count);
346}; 352};
347 353
348Declaring: 354Declaring:
diff --git a/Documentation/filesystems/ubifs.txt b/Documentation/filesystems/ubifs.txt
index 84da2a4ba25a..12fedb7834c6 100644
--- a/Documentation/filesystems/ubifs.txt
+++ b/Documentation/filesystems/ubifs.txt
@@ -79,13 +79,6 @@ Mount options
79 79
80(*) == default. 80(*) == default.
81 81
82norm_unmount (*) commit on unmount; the journal is committed
83 when the file-system is unmounted so that the
84 next mount does not have to replay the journal
85 and it becomes very fast;
86fast_unmount do not commit on unmount; this option makes
87 unmount faster, but the next mount slower
88 because of the need to replay the journal.
89bulk_read read more in one go to take advantage of flash 82bulk_read read more in one go to take advantage of flash
90 media that read faster sequentially 83 media that read faster sequentially
91no_bulk_read (*) do not bulk-read 84no_bulk_read (*) do not bulk-read
diff --git a/Documentation/hwmon/hpfall.c b/Documentation/hwmon/hpfall.c
new file mode 100644
index 000000000000..bbea1ccfd46a
--- /dev/null
+++ b/Documentation/hwmon/hpfall.c
@@ -0,0 +1,101 @@
1/* Disk protection for HP machines.
2 *
3 * Copyright 2008 Eric Piel
4 * Copyright 2009 Pavel Machek <pavel@suse.cz>
5 *
6 * GPLv2.
7 */
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <unistd.h>
12#include <fcntl.h>
13#include <sys/stat.h>
14#include <sys/types.h>
15#include <string.h>
16#include <stdint.h>
17#include <errno.h>
18#include <signal.h>
19
20void write_int(char *path, int i)
21{
22 char buf[1024];
23 int fd = open(path, O_RDWR);
24 if (fd < 0) {
25 perror("open");
26 exit(1);
27 }
28 sprintf(buf, "%d", i);
29 if (write(fd, buf, strlen(buf)) != strlen(buf)) {
30 perror("write");
31 exit(1);
32 }
33 close(fd);
34}
35
36void set_led(int on)
37{
38 write_int("/sys/class/leds/hp::hddprotect/brightness", on);
39}
40
41void protect(int seconds)
42{
43 write_int("/sys/block/sda/device/unload_heads", seconds*1000);
44}
45
46int on_ac(void)
47{
48// /sys/class/power_supply/AC0/online
49}
50
51int lid_open(void)
52{
53// /proc/acpi/button/lid/LID/state
54}
55
56void ignore_me(void)
57{
58 protect(0);
59 set_led(0);
60
61}
62
63int main(int argc, char* argv[])
64{
65 int fd, ret;
66
67 fd = open("/dev/freefall", O_RDONLY);
68 if (fd < 0) {
69 perror("open");
70 return EXIT_FAILURE;
71 }
72
73 signal(SIGALRM, ignore_me);
74
75 for (;;) {
76 unsigned char count;
77
78 ret = read(fd, &count, sizeof(count));
79 alarm(0);
80 if ((ret == -1) && (errno == EINTR)) {
81 /* Alarm expired, time to unpark the heads */
82 continue;
83 }
84
85 if (ret != sizeof(count)) {
86 perror("read");
87 break;
88 }
89
90 protect(21);
91 set_led(1);
92 if (1 || on_ac() || lid_open()) {
93 alarm(2);
94 } else {
95 alarm(20);
96 }
97 }
98
99 close(fd);
100 return EXIT_SUCCESS;
101}
diff --git a/Documentation/hwmon/lis3lv02d b/Documentation/hwmon/lis3lv02d
index 0fcfc4a7ccdc..287f8c902656 100644
--- a/Documentation/hwmon/lis3lv02d
+++ b/Documentation/hwmon/lis3lv02d
@@ -33,6 +33,14 @@ rate - reports the sampling rate of the accelerometer device in HZ
33This driver also provides an absolute input class device, allowing 33This driver also provides an absolute input class device, allowing
34the laptop to act as a pinball machine-esque joystick. 34the laptop to act as a pinball machine-esque joystick.
35 35
36Another feature of the driver is misc device called "freefall" that
37acts similar to /dev/rtc and reacts on free-fall interrupts received
38from the device. It supports blocking operations, poll/select and
39fasync operation modes. You must read 1 bytes from the device. The
40result is number of free-fall interrupts since the last successful
41read (or 255 if number of interrupts would not fit).
42
43
36Axes orientation 44Axes orientation
37---------------- 45----------------
38 46
diff --git a/Documentation/kernel-doc-nano-HOWTO.txt b/Documentation/kernel-doc-nano-HOWTO.txt
index d73fbd2b2b45..026ec7d57384 100644
--- a/Documentation/kernel-doc-nano-HOWTO.txt
+++ b/Documentation/kernel-doc-nano-HOWTO.txt
@@ -43,7 +43,8 @@ Only comments so marked will be considered by the kernel-doc scripts,
43and any comment so marked must be in kernel-doc format. Do not use 43and any comment so marked must be in kernel-doc format. Do not use
44"/**" to be begin a comment block unless the comment block contains 44"/**" to be begin a comment block unless the comment block contains
45kernel-doc formatted comments. The closing comment marker for 45kernel-doc formatted comments. The closing comment marker for
46kernel-doc comments can be either "*/" or "**/". 46kernel-doc comments can be either "*/" or "**/", but "*/" is
47preferred in the Linux kernel tree.
47 48
48Kernel-doc comments should be placed just before the function 49Kernel-doc comments should be placed just before the function
49or data structure being described. 50or data structure being described.
@@ -63,7 +64,7 @@ Example kernel-doc function comment:
63 * comment lines. 64 * comment lines.
64 * 65 *
65 * The longer description can have multiple paragraphs. 66 * The longer description can have multiple paragraphs.
66 **/ 67 */
67 68
68The first line, with the short description, must be on a single line. 69The first line, with the short description, must be on a single line.
69 70
@@ -85,7 +86,7 @@ Example kernel-doc data structure comment.
85 * perhaps with more lines and words. 86 * perhaps with more lines and words.
86 * 87 *
87 * Longer description of this structure. 88 * Longer description of this structure.
88 **/ 89 */
89 90
90The kernel-doc function comments describe each parameter to the 91The kernel-doc function comments describe each parameter to the
91function, in order, with the @name lines. 92function, in order, with the @name lines.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index d8362cf9909e..319785b6dcb1 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -134,7 +134,7 @@ and is between 256 and 4096 characters. It is defined in the file
134 134
135 acpi= [HW,ACPI,X86-64,i386] 135 acpi= [HW,ACPI,X86-64,i386]
136 Advanced Configuration and Power Interface 136 Advanced Configuration and Power Interface
137 Format: { force | off | ht | strict | noirq } 137 Format: { force | off | ht | strict | noirq | rsdt }
138 force -- enable ACPI if default was off 138 force -- enable ACPI if default was off
139 off -- disable ACPI if default was on 139 off -- disable ACPI if default was on
140 noirq -- do not use ACPI for IRQ routing 140 noirq -- do not use ACPI for IRQ routing
@@ -937,6 +937,8 @@ and is between 256 and 4096 characters. It is defined in the file
937 937
938 938
939 intel_iommu= [DMAR] Intel IOMMU driver (DMAR) option 939 intel_iommu= [DMAR] Intel IOMMU driver (DMAR) option
940 on
941 Enable intel iommu driver.
940 off 942 off
941 Disable intel iommu driver. 943 Disable intel iommu driver.
942 igfx_off [Default Off] 944 igfx_off [Default Off]
diff --git a/Documentation/tracers/mmiotrace.txt b/Documentation/tracers/mmiotrace.txt
index cde23b4a12a1..5731c67abc55 100644
--- a/Documentation/tracers/mmiotrace.txt
+++ b/Documentation/tracers/mmiotrace.txt
@@ -78,12 +78,10 @@ to view your kernel log and look for "mmiotrace has lost events" warning. If
78events were lost, the trace is incomplete. You should enlarge the buffers and 78events were lost, the trace is incomplete. You should enlarge the buffers and
79try again. Buffers are enlarged by first seeing how large the current buffers 79try again. Buffers are enlarged by first seeing how large the current buffers
80are: 80are:
81$ cat /debug/tracing/trace_entries 81$ cat /debug/tracing/buffer_size_kb
82gives you a number. Approximately double this number and write it back, for 82gives you a number. Approximately double this number and write it back, for
83instance: 83instance:
84$ echo 0 > /debug/tracing/tracing_enabled 84$ echo 128000 > /debug/tracing/buffer_size_kb
85$ echo 128000 > /debug/tracing/trace_entries
86$ echo 1 > /debug/tracing/tracing_enabled
87Then start again from the top. 85Then start again from the top.
88 86
89If you are doing a trace for a driver project, e.g. Nouveau, you should also 87If you are doing a trace for a driver project, e.g. Nouveau, you should also
diff --git a/MAINTAINERS b/MAINTAINERS
index 474ec0c53272..59fd2d1d94a7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -692,6 +692,13 @@ M: kernel@wantstofly.org
692L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only) 692L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
693S: Maintained 693S: Maintained
694 694
695ARM/NUVOTON W90X900 ARM ARCHITECTURE
696P: Wan ZongShun
697M: mcuos.com@gmail.com
698L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
699W: http://www.mcuos.com
700S: Maintained
701
695ARPD SUPPORT 702ARPD SUPPORT
696P: Jonathan Layes 703P: Jonathan Layes
697L: netdev@vger.kernel.org 704L: netdev@vger.kernel.org
@@ -911,7 +918,7 @@ S: Maintained
911BLACKFIN ARCHITECTURE 918BLACKFIN ARCHITECTURE
912P: Bryan Wu 919P: Bryan Wu
913M: cooloney@kernel.org 920M: cooloney@kernel.org
914L: uclinux-dist-devel@blackfin.uclinux.org (subscribers-only) 921L: uclinux-dist-devel@blackfin.uclinux.org
915W: http://blackfin.uclinux.org 922W: http://blackfin.uclinux.org
916S: Supported 923S: Supported
917 924
@@ -1021,6 +1028,14 @@ M: mb@bu3sch.de
1021W: http://bu3sch.de/btgpio.php 1028W: http://bu3sch.de/btgpio.php
1022S: Maintained 1029S: Maintained
1023 1030
1031BTRFS FILE SYSTEM
1032P: Chris Mason
1033M: chris.mason@oracle.com
1034L: linux-btrfs@vger.kernel.org
1035W: http://btrfs.wiki.kernel.org/
1036T: git kernel.org:/pub/scm/linux/kernel/git/mason/btrfs-unstable.git
1037S: Maintained
1038
1024BTTV VIDEO4LINUX DRIVER 1039BTTV VIDEO4LINUX DRIVER
1025P: Mauro Carvalho Chehab 1040P: Mauro Carvalho Chehab
1026M: mchehab@infradead.org 1041M: mchehab@infradead.org
@@ -1194,6 +1209,8 @@ S: Supported
1194CONTROL GROUPS (CGROUPS) 1209CONTROL GROUPS (CGROUPS)
1195P: Paul Menage 1210P: Paul Menage
1196M: menage@google.com 1211M: menage@google.com
1212P: Li Zefan
1213M: lizf@cn.fujitsu.com
1197L: containers@lists.linux-foundation.org 1214L: containers@lists.linux-foundation.org
1198S: Maintained 1215S: Maintained
1199 1216
@@ -1895,10 +1912,10 @@ W: http://gigaset307x.sourceforge.net/
1895S: Maintained 1912S: Maintained
1896 1913
1897HARD DRIVE ACTIVE PROTECTION SYSTEM (HDAPS) DRIVER 1914HARD DRIVE ACTIVE PROTECTION SYSTEM (HDAPS) DRIVER
1898P: Robert Love 1915P: Frank Seidel
1899M: rlove@rlove.org 1916M: frank@f-seidel.de
1900M: linux-kernel@vger.kernel.org 1917L: lm-sensors@lm-sensors.org
1901W: http://www.kernel.org/pub/linux/kernel/people/rml/hdaps/ 1918W: http://www.kernel.org/pub/linux/kernel/people/fseidel/hdaps/
1902S: Maintained 1919S: Maintained
1903 1920
1904GSPCA FINEPIX SUBDRIVER 1921GSPCA FINEPIX SUBDRIVER
@@ -1991,7 +2008,7 @@ S: Maintained
1991 2008
1992HIBERNATION (aka Software Suspend, aka swsusp) 2009HIBERNATION (aka Software Suspend, aka swsusp)
1993P: Pavel Machek 2010P: Pavel Machek
1994M: pavel@suse.cz 2011M: pavel@ucw.cz
1995P: Rafael J. Wysocki 2012P: Rafael J. Wysocki
1996M: rjw@sisk.pl 2013M: rjw@sisk.pl
1997L: linux-pm@lists.linux-foundation.org 2014L: linux-pm@lists.linux-foundation.org
@@ -2212,7 +2229,7 @@ P: Sean Hefty
2212M: sean.hefty@intel.com 2229M: sean.hefty@intel.com
2213P: Hal Rosenstock 2230P: Hal Rosenstock
2214M: hal.rosenstock@gmail.com 2231M: hal.rosenstock@gmail.com
2215L: general@lists.openfabrics.org 2232L: general@lists.openfabrics.org (moderated for non-subscribers)
2216W: http://www.openib.org/ 2233W: http://www.openib.org/
2217T: git kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git 2234T: git kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git
2218S: Supported 2235S: Supported
@@ -3317,8 +3334,8 @@ P: Jeremy Fitzhardinge
3317M: jeremy@xensource.com 3334M: jeremy@xensource.com
3318P: Chris Wright 3335P: Chris Wright
3319M: chrisw@sous-sol.org 3336M: chrisw@sous-sol.org
3320P: Zachary Amsden 3337P: Alok Kataria
3321M: zach@vmware.com 3338M: akataria@vmware.com
3322P: Rusty Russell 3339P: Rusty Russell
3323M: rusty@rustcorp.com.au 3340M: rusty@rustcorp.com.au
3324L: virtualization@lists.osdl.org 3341L: virtualization@lists.osdl.org
@@ -3529,6 +3546,12 @@ S: Maintained
3529PXA MMCI DRIVER 3546PXA MMCI DRIVER
3530S: Orphan 3547S: Orphan
3531 3548
3549PXA RTC DRIVER
3550P: Robert Jarzmik
3551M: robert.jarzmik@free.fr
3552L: rtc-linux@googlegroups.com
3553S: Maintained
3554
3532QLOGIC QLA2XXX FC-SCSI DRIVER 3555QLOGIC QLA2XXX FC-SCSI DRIVER
3533P: Andrew Vasquez 3556P: Andrew Vasquez
3534M: linux-driver@qlogic.com 3557M: linux-driver@qlogic.com
@@ -4156,7 +4179,7 @@ SUSPEND TO RAM
4156P: Len Brown 4179P: Len Brown
4157M: len.brown@intel.com 4180M: len.brown@intel.com
4158P: Pavel Machek 4181P: Pavel Machek
4159M: pavel@suse.cz 4182M: pavel@ucw.cz
4160P: Rafael J. Wysocki 4183P: Rafael J. Wysocki
4161M: rjw@sisk.pl 4184M: rjw@sisk.pl
4162L: linux-pm@lists.linux-foundation.org 4185L: linux-pm@lists.linux-foundation.org
@@ -4277,8 +4300,8 @@ P: Rajiv Andrade
4277M: srajiv@linux.vnet.ibm.com 4300M: srajiv@linux.vnet.ibm.com
4278W: http://tpmdd.sourceforge.net 4301W: http://tpmdd.sourceforge.net
4279P: Marcel Selhorst 4302P: Marcel Selhorst
4280M: tpm@selhorst.net 4303M: m.selhorst@sirrix.com
4281W: http://www.prosec.rub.de/tpm/ 4304W: http://www.sirrix.com
4282L: tpmdd-devel@lists.sourceforge.net (moderated for non-subscribers) 4305L: tpmdd-devel@lists.sourceforge.net (moderated for non-subscribers)
4283S: Maintained 4306S: Maintained
4284 4307
@@ -4841,6 +4864,7 @@ P: Ingo Molnar
4841M: mingo@redhat.com 4864M: mingo@redhat.com
4842P: H. Peter Anvin 4865P: H. Peter Anvin
4843M: hpa@zytor.com 4866M: hpa@zytor.com
4867M: x86@kernel.org
4844L: linux-kernel@vger.kernel.org 4868L: linux-kernel@vger.kernel.org
4845T: git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git 4869T: git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git
4846S: Maintained 4870S: Maintained
@@ -4907,11 +4931,11 @@ L: zd1211-devs@lists.sourceforge.net (subscribers-only)
4907S: Maintained 4931S: Maintained
4908 4932
4909ZR36067 VIDEO FOR LINUX DRIVER 4933ZR36067 VIDEO FOR LINUX DRIVER
4910P: Ronald Bultje
4911M: rbultje@ronald.bitfreak.net
4912L: mjpeg-users@lists.sourceforge.net 4934L: mjpeg-users@lists.sourceforge.net
4935L: linux-media@vger.kernel.org
4913W: http://mjpeg.sourceforge.net/driver-zoran/ 4936W: http://mjpeg.sourceforge.net/driver-zoran/
4914S: Maintained 4937T: Mercurial http://linuxtv.org/hg/v4l-dvb
4938S: Odd Fixes
4915 4939
4916ZS DECSTATION Z85C30 SERIAL DRIVER 4940ZS DECSTATION Z85C30 SERIAL DRIVER
4917P: Maciej W. Rozycki 4941P: Maciej W. Rozycki
diff --git a/Makefile b/Makefile
index 7715b2c14fb4..df6ce3e80090 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 29 3SUBLEVEL = 29
4EXTRAVERSION = -rc3 4EXTRAVERSION = -rc6
5NAME = Erotic Pickled Herring 5NAME = Erotic Pickled Herring
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -389,6 +389,7 @@ PHONY += outputmakefile
389# output directory. 389# output directory.
390outputmakefile: 390outputmakefile:
391ifneq ($(KBUILD_SRC),) 391ifneq ($(KBUILD_SRC),)
392 $(Q)ln -fsn $(srctree) source
392 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ 393 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
393 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) 394 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
394endif 395endif
@@ -946,7 +947,6 @@ ifneq ($(KBUILD_SRC),)
946 mkdir -p include2; \ 947 mkdir -p include2; \
947 ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \ 948 ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
948 fi 949 fi
949 ln -fsn $(srctree) source
950endif 950endif
951 951
952# prepare2 creates a makefile if using a separate output directory 952# prepare2 creates a makefile if using a separate output directory
diff --git a/README b/README
index 90a07658ede1..d6c6c742c1d7 100644
--- a/README
+++ b/README
@@ -188,7 +188,7 @@ CONFIGURING the kernel:
188 values to random values. 188 values to random values.
189 189
190 You can find more information on using the Linux kernel config tools 190 You can find more information on using the Linux kernel config tools
191 in Documentation/kbuild/make-configs.txt. 191 in Documentation/kbuild/kconfig.txt.
192 192
193 NOTES on "make config": 193 NOTES on "make config":
194 - having unnecessary drivers will make the kernel bigger, and can 194 - having unnecessary drivers will make the kernel bigger, and can
diff --git a/arch/alpha/include/asm/bug.h b/arch/alpha/include/asm/bug.h
index 7b85b7c93709..1720c8ad86fe 100644
--- a/arch/alpha/include/asm/bug.h
+++ b/arch/alpha/include/asm/bug.h
@@ -8,12 +8,12 @@
8 8
9/* ??? Would be nice to use .gprel32 here, but we can't be sure that the 9/* ??? Would be nice to use .gprel32 here, but we can't be sure that the
10 function loaded the GP, so this could fail in modules. */ 10 function loaded the GP, so this could fail in modules. */
11#define BUG() { \ 11#define BUG() do { \
12 __asm__ __volatile__( \ 12 __asm__ __volatile__( \
13 "call_pal %0 # bugchk\n\t" \ 13 "call_pal %0 # bugchk\n\t" \
14 ".long %1\n\t.8byte %2" \ 14 ".long %1\n\t.8byte %2" \
15 : : "i"(PAL_bugchk), "i"(__LINE__), "i"(__FILE__)); \ 15 : : "i"(PAL_bugchk), "i"(__LINE__), "i"(__FILE__)); \
16 for ( ; ; ); } 16 for ( ; ; ); } while (0)
17 17
18#define HAVE_ARCH_BUG 18#define HAVE_ARCH_BUG
19#endif 19#endif
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index f238370c907d..8d0097f10208 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -93,8 +93,8 @@ common_shutdown_1(void *generic_ptr)
93 if (cpuid != boot_cpuid) { 93 if (cpuid != boot_cpuid) {
94 flags |= 0x00040000UL; /* "remain halted" */ 94 flags |= 0x00040000UL; /* "remain halted" */
95 *pflags = flags; 95 *pflags = flags;
96 cpu_clear(cpuid, cpu_present_map); 96 set_cpu_present(cpuid, false);
97 cpu_clear(cpuid, cpu_possible_map); 97 set_cpu_possible(cpuid, false);
98 halt(); 98 halt();
99 } 99 }
100#endif 100#endif
@@ -120,8 +120,8 @@ common_shutdown_1(void *generic_ptr)
120 120
121#ifdef CONFIG_SMP 121#ifdef CONFIG_SMP
122 /* Wait for the secondaries to halt. */ 122 /* Wait for the secondaries to halt. */
123 cpu_clear(boot_cpuid, cpu_present_map); 123 set_cpu_present(boot_cpuid, false);
124 cpu_clear(boot_cpuid, cpu_possible_map); 124 set_cpu_possible(boot_cpuid, false);
125 while (cpus_weight(cpu_present_map)) 125 while (cpus_weight(cpu_present_map))
126 barrier(); 126 barrier();
127#endif 127#endif
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 00f1dc3dfd5f..b1fe5674c3a1 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -120,12 +120,12 @@ void __cpuinit
120smp_callin(void) 120smp_callin(void)
121{ 121{
122 int cpuid = hard_smp_processor_id(); 122 int cpuid = hard_smp_processor_id();
123 cpumask_t mask = cpu_online_map;
124 123
125 if (cpu_test_and_set(cpuid, mask)) { 124 if (cpu_online(cpuid)) {
126 printk("??, cpu 0x%x already present??\n", cpuid); 125 printk("??, cpu 0x%x already present??\n", cpuid);
127 BUG(); 126 BUG();
128 } 127 }
128 set_cpu_online(cpuid, true);
129 129
130 /* Turn on machine checks. */ 130 /* Turn on machine checks. */
131 wrmces(7); 131 wrmces(7);
@@ -436,8 +436,8 @@ setup_smp(void)
436 ((char *)cpubase + i*hwrpb->processor_size); 436 ((char *)cpubase + i*hwrpb->processor_size);
437 if ((cpu->flags & 0x1cc) == 0x1cc) { 437 if ((cpu->flags & 0x1cc) == 0x1cc) {
438 smp_num_probed++; 438 smp_num_probed++;
439 cpu_set(i, cpu_possible_map); 439 set_cpu_possible(i, true);
440 cpu_set(i, cpu_present_map); 440 set_cpu_present(i, true);
441 cpu->pal_revision = boot_cpu_palrev; 441 cpu->pal_revision = boot_cpu_palrev;
442 } 442 }
443 443
@@ -470,8 +470,8 @@ smp_prepare_cpus(unsigned int max_cpus)
470 470
471 /* Nothing to do on a UP box, or when told not to. */ 471 /* Nothing to do on a UP box, or when told not to. */
472 if (smp_num_probed == 1 || max_cpus == 0) { 472 if (smp_num_probed == 1 || max_cpus == 0) {
473 cpu_possible_map = cpumask_of_cpu(boot_cpuid); 473 init_cpu_possible(cpumask_of(boot_cpuid));
474 cpu_present_map = cpumask_of_cpu(boot_cpuid); 474 init_cpu_present(cpumask_of(boot_cpuid));
475 printk(KERN_INFO "SMP mode deactivated.\n"); 475 printk(KERN_INFO "SMP mode deactivated.\n");
476 return; 476 return;
477 } 477 }
diff --git a/arch/arm/configs/at91sam9260ek_defconfig b/arch/arm/configs/at91sam9260ek_defconfig
index e0ee7060f9aa..98e2f3de4bc5 100644
--- a/arch/arm/configs/at91sam9260ek_defconfig
+++ b/arch/arm/configs/at91sam9260ek_defconfig
@@ -608,7 +608,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
608# Watchdog Device Drivers 608# Watchdog Device Drivers
609# 609#
610# CONFIG_SOFT_WATCHDOG is not set 610# CONFIG_SOFT_WATCHDOG is not set
611CONFIG_AT91SAM9_WATCHDOG=y 611CONFIG_AT91SAM9X_WATCHDOG=y
612 612
613# 613#
614# USB-based Watchdog Cards 614# USB-based Watchdog Cards
diff --git a/arch/arm/configs/at91sam9261ek_defconfig b/arch/arm/configs/at91sam9261ek_defconfig
index 01d1ef97d8be..149456142392 100644
--- a/arch/arm/configs/at91sam9261ek_defconfig
+++ b/arch/arm/configs/at91sam9261ek_defconfig
@@ -700,7 +700,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
700# Watchdog Device Drivers 700# Watchdog Device Drivers
701# 701#
702# CONFIG_SOFT_WATCHDOG is not set 702# CONFIG_SOFT_WATCHDOG is not set
703CONFIG_AT91SAM9_WATCHDOG=y 703CONFIG_AT91SAM9X_WATCHDOG=y
704 704
705# 705#
706# USB-based Watchdog Cards 706# USB-based Watchdog Cards
diff --git a/arch/arm/configs/at91sam9263ek_defconfig b/arch/arm/configs/at91sam9263ek_defconfig
index 036a126725c1..21599f3c6275 100644
--- a/arch/arm/configs/at91sam9263ek_defconfig
+++ b/arch/arm/configs/at91sam9263ek_defconfig
@@ -710,7 +710,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
710# Watchdog Device Drivers 710# Watchdog Device Drivers
711# 711#
712# CONFIG_SOFT_WATCHDOG is not set 712# CONFIG_SOFT_WATCHDOG is not set
713CONFIG_AT91SAM9_WATCHDOG=y 713CONFIG_AT91SAM9X_WATCHDOG=y
714 714
715# 715#
716# USB-based Watchdog Cards 716# USB-based Watchdog Cards
diff --git a/arch/arm/configs/at91sam9rlek_defconfig b/arch/arm/configs/at91sam9rlek_defconfig
index 237a2a6a8517..e2df81a3e804 100644
--- a/arch/arm/configs/at91sam9rlek_defconfig
+++ b/arch/arm/configs/at91sam9rlek_defconfig
@@ -606,7 +606,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
606# Watchdog Device Drivers 606# Watchdog Device Drivers
607# 607#
608# CONFIG_SOFT_WATCHDOG is not set 608# CONFIG_SOFT_WATCHDOG is not set
609CONFIG_AT91SAM9_WATCHDOG=y 609CONFIG_AT91SAM9X_WATCHDOG=y
610 610
611# 611#
612# Sonics Silicon Backplane 612# Sonics Silicon Backplane
diff --git a/arch/arm/configs/qil-a9260_defconfig b/arch/arm/configs/qil-a9260_defconfig
index cd1d717903ac..9b32d0eb89ba 100644
--- a/arch/arm/configs/qil-a9260_defconfig
+++ b/arch/arm/configs/qil-a9260_defconfig
@@ -727,7 +727,7 @@ CONFIG_WATCHDOG_NOWAYOUT=y
727# Watchdog Device Drivers 727# Watchdog Device Drivers
728# 728#
729# CONFIG_SOFT_WATCHDOG is not set 729# CONFIG_SOFT_WATCHDOG is not set
730# CONFIG_AT91SAM9_WATCHDOG is not set 730# CONFIG_AT91SAM9X_WATCHDOG is not set
731 731
732# 732#
733# USB-based Watchdog Cards 733# USB-based Watchdog Cards
diff --git a/arch/arm/kernel/elf.c b/arch/arm/kernel/elf.c
index 84849098c8e8..d4a0da1e48f4 100644
--- a/arch/arm/kernel/elf.c
+++ b/arch/arm/kernel/elf.c
@@ -74,9 +74,9 @@ EXPORT_SYMBOL(elf_set_personality);
74 */ 74 */
75int arm_elf_read_implies_exec(const struct elf32_hdr *x, int executable_stack) 75int arm_elf_read_implies_exec(const struct elf32_hdr *x, int executable_stack)
76{ 76{
77 if (executable_stack != EXSTACK_ENABLE_X) 77 if (executable_stack != EXSTACK_DISABLE_X)
78 return 1; 78 return 1;
79 if (cpu_architecture() <= CPU_ARCH_ARMv6) 79 if (cpu_architecture() < CPU_ARCH_ARMv6)
80 return 1; 80 return 1;
81 return 0; 81 return 0;
82} 82}
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 77b047475539..85040cfeb5e5 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -650,6 +650,7 @@ ENTRY(fp_enter)
650no_fp: mov pc, lr 650no_fp: mov pc, lr
651 651
652__und_usr_unknown: 652__und_usr_unknown:
653 enable_irq
653 mov r0, sp 654 mov r0, sp
654 adr lr, ret_from_exception 655 adr lr, ret_from_exception
655 b do_undefinstr 656 b do_undefinstr
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 06269ea375c5..49a6ba926c2b 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -136,7 +136,7 @@ ENTRY(mcount)
136 ldmia sp!, {r0-r3, pc} 136 ldmia sp!, {r0-r3, pc}
137 137
138trace: 138trace:
139 ldr r1, [fp, #-4] 139 ldr r1, [fp, #-4] @ lr of instrumented routine
140 mov r0, lr 140 mov r0, lr
141 sub r0, r0, #MCOUNT_INSN_SIZE 141 sub r0, r0, #MCOUNT_INSN_SIZE
142 mov lr, pc 142 mov lr, pc
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 7141cee1fab7..363db186cb93 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -101,7 +101,7 @@ unlock:
101/* Handle bad interrupts */ 101/* Handle bad interrupts */
102static struct irq_desc bad_irq_desc = { 102static struct irq_desc bad_irq_desc = {
103 .handle_irq = handle_bad_irq, 103 .handle_irq = handle_bad_irq,
104 .lock = SPIN_LOCK_UNLOCKED 104 .lock = __SPIN_LOCK_UNLOCKED(bad_irq_desc.lock),
105}; 105};
106 106
107/* 107/*
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index 440dc62cdc3a..598ca61e7bca 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -13,8 +13,8 @@
13#include <asm/cacheflush.h> 13#include <asm/cacheflush.h>
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
15 15
16const extern unsigned char relocate_new_kernel[]; 16extern const unsigned char relocate_new_kernel[];
17const extern unsigned int relocate_new_kernel_size; 17extern const unsigned int relocate_new_kernel_size;
18 18
19extern void setup_mm_for_reboot(char mode); 19extern void setup_mm_for_reboot(char mode);
20 20
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index 9eca2209cde6..412aa49ad2fb 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -697,7 +697,7 @@ static void __init at91_add_device_rtt(void)
697 * Watchdog 697 * Watchdog
698 * -------------------------------------------------------------------- */ 698 * -------------------------------------------------------------------- */
699 699
700#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 700#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
701static struct platform_device at91cap9_wdt_device = { 701static struct platform_device at91cap9_wdt_device = {
702 .name = "at91_wdt", 702 .name = "at91_wdt",
703 .id = -1, 703 .id = -1,
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index fdde1ea21b07..d74c9ac007e7 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -643,7 +643,7 @@ static void __init at91_add_device_rtt(void)
643 * Watchdog 643 * Watchdog
644 * -------------------------------------------------------------------- */ 644 * -------------------------------------------------------------------- */
645 645
646#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 646#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
647static struct platform_device at91sam9260_wdt_device = { 647static struct platform_device at91sam9260_wdt_device = {
648 .name = "at91_wdt", 648 .name = "at91_wdt",
649 .id = -1, 649 .id = -1,
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 17289756f80f..59fc48311fb0 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -621,7 +621,7 @@ static void __init at91_add_device_rtt(void)
621 * Watchdog 621 * Watchdog
622 * -------------------------------------------------------------------- */ 622 * -------------------------------------------------------------------- */
623 623
624#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 624#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
625static struct platform_device at91sam9261_wdt_device = { 625static struct platform_device at91sam9261_wdt_device = {
626 .name = "at91_wdt", 626 .name = "at91_wdt",
627 .id = -1, 627 .id = -1,
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index b753cb879d8e..134af97ff340 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -854,7 +854,7 @@ static void __init at91_add_device_rtt(void)
854 * Watchdog 854 * Watchdog
855 * -------------------------------------------------------------------- */ 855 * -------------------------------------------------------------------- */
856 856
857#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 857#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
858static struct platform_device at91sam9263_wdt_device = { 858static struct platform_device at91sam9263_wdt_device = {
859 .name = "at91_wdt", 859 .name = "at91_wdt",
860 .id = -1, 860 .id = -1,
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 145324f4ec56..728186515cdf 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -609,7 +609,7 @@ static void __init at91_add_device_rtt(void)
609 * Watchdog 609 * Watchdog
610 * -------------------------------------------------------------------- */ 610 * -------------------------------------------------------------------- */
611 611
612#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) 612#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
613static struct platform_device at91sam9rl_wdt_device = { 613static struct platform_device at91sam9rl_wdt_device = {
614 .name = "at91_wdt", 614 .name = "at91_wdt",
615 .id = -1, 615 .id = -1,
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index 9b0447c3d59b..2f7d4977dce9 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -490,7 +490,8 @@ postcore_initcall(at91_gpio_debugfs_init);
490 490
491/*--------------------------------------------------------------------------*/ 491/*--------------------------------------------------------------------------*/
492 492
493/* This lock class tells lockdep that GPIO irqs are in a different 493/*
494 * This lock class tells lockdep that GPIO irqs are in a different
494 * category than their parents, so it won't report false recursion. 495 * category than their parents, so it won't report false recursion.
495 */ 496 */
496static struct lock_class_key gpio_lock_class; 497static struct lock_class_key gpio_lock_class;
@@ -509,9 +510,6 @@ void __init at91_gpio_irq_setup(void)
509 unsigned id = this->id; 510 unsigned id = this->id;
510 unsigned i; 511 unsigned i;
511 512
512 /* enable PIO controller's clock */
513 clk_enable(this->clock);
514
515 __raw_writel(~0, this->regbase + PIO_IDR); 513 __raw_writel(~0, this->regbase + PIO_IDR);
516 514
517 for (i = 0, pin = this->chipbase; i < 32; i++, pin++) { 515 for (i = 0, pin = this->chipbase; i < 32; i++, pin++) {
@@ -556,7 +554,14 @@ void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks)
556 data->chipbase = PIN_BASE + i * 32; 554 data->chipbase = PIN_BASE + i * 32;
557 data->regbase = data->offset + (void __iomem *)AT91_VA_BASE_SYS; 555 data->regbase = data->offset + (void __iomem *)AT91_VA_BASE_SYS;
558 556
559 /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */ 557 /* enable PIO controller's clock */
558 clk_enable(data->clock);
559
560 /*
561 * Some processors share peripheral ID between multiple GPIO banks.
562 * SAM9263 (PIOC, PIOD, PIOE)
563 * CAP9 (PIOA, PIOB, PIOC, PIOD)
564 */
560 if (last && last->id == data->id) 565 if (last && last->id == data->id)
561 last->next = data; 566 last->next = data;
562 } 567 }
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index fb51f0e0a83f..0b3ae21b4565 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -93,6 +93,7 @@ struct atmel_nand_data {
93 u8 enable_pin; /* chip enable */ 93 u8 enable_pin; /* chip enable */
94 u8 det_pin; /* card detect */ 94 u8 det_pin; /* card detect */
95 u8 rdy_pin; /* ready/busy */ 95 u8 rdy_pin; /* ready/busy */
96 u8 rdy_pin_active_low; /* rdy_pin value is inverted */
96 u8 ale; /* address line number connected to ALE */ 97 u8 ale; /* address line number connected to ALE */
97 u8 cle; /* address line number connected to CLE */ 98 u8 cle; /* address line number connected to CLE */
98 u8 bus_width_16; /* buswidth is 16 bit */ 99 u8 bus_width_16; /* buswidth is 16 bit */
diff --git a/arch/arm/mach-ep93xx/include/mach/gesbc9312.h b/arch/arm/mach-ep93xx/include/mach/gesbc9312.h
deleted file mode 100644
index 21fe2b922aa5..000000000000
--- a/arch/arm/mach-ep93xx/include/mach/gesbc9312.h
+++ /dev/null
@@ -1,3 +0,0 @@
1/*
2 * arch/arm/mach-ep93xx/include/mach/gesbc9312.h
3 */
diff --git a/arch/arm/mach-ep93xx/include/mach/hardware.h b/arch/arm/mach-ep93xx/include/mach/hardware.h
index 529807d182bf..2866297310b7 100644
--- a/arch/arm/mach-ep93xx/include/mach/hardware.h
+++ b/arch/arm/mach-ep93xx/include/mach/hardware.h
@@ -10,7 +10,6 @@
10 10
11#include "platform.h" 11#include "platform.h"
12 12
13#include "gesbc9312.h"
14#include "ts72xx.h" 13#include "ts72xx.h"
15 14
16#endif 15#endif
diff --git a/arch/arm/mach-kirkwood/irq.c b/arch/arm/mach-kirkwood/irq.c
index efb86b700276..06083b23bb44 100644
--- a/arch/arm/mach-kirkwood/irq.c
+++ b/arch/arm/mach-kirkwood/irq.c
@@ -42,7 +42,7 @@ void __init kirkwood_init_irq(void)
42 writel(0, GPIO_EDGE_CAUSE(32)); 42 writel(0, GPIO_EDGE_CAUSE(32));
43 43
44 for (i = IRQ_KIRKWOOD_GPIO_START; i < NR_IRQS; i++) { 44 for (i = IRQ_KIRKWOOD_GPIO_START; i < NR_IRQS; i++) {
45 set_irq_chip(i, &orion_gpio_irq_level_chip); 45 set_irq_chip(i, &orion_gpio_irq_chip);
46 set_irq_handler(i, handle_level_irq); 46 set_irq_handler(i, handle_level_irq);
47 irq_desc[i].status |= IRQ_LEVEL; 47 irq_desc[i].status |= IRQ_LEVEL;
48 set_irq_flags(i, IRQF_VALID); 48 set_irq_flags(i, IRQF_VALID);
diff --git a/arch/arm/mach-msm/board-halibut.c b/arch/arm/mach-msm/board-halibut.c
index c2a96e3965a6..e61967dde9a1 100644
--- a/arch/arm/mach-msm/board-halibut.c
+++ b/arch/arm/mach-msm/board-halibut.c
@@ -27,6 +27,7 @@
27#include <asm/mach/map.h> 27#include <asm/mach/map.h>
28#include <asm/mach/flash.h> 28#include <asm/mach/flash.h>
29 29
30#include <mach/irqs.h>
30#include <mach/board.h> 31#include <mach/board.h>
31#include <mach/msm_iomap.h> 32#include <mach/msm_iomap.h>
32 33
diff --git a/arch/arm/mach-mv78xx0/irq.c b/arch/arm/mach-mv78xx0/irq.c
index e273418797b4..30b7e4bcdbc7 100644
--- a/arch/arm/mach-mv78xx0/irq.c
+++ b/arch/arm/mach-mv78xx0/irq.c
@@ -40,7 +40,7 @@ void __init mv78xx0_init_irq(void)
40 writel(0, GPIO_EDGE_CAUSE(0)); 40 writel(0, GPIO_EDGE_CAUSE(0));
41 41
42 for (i = IRQ_MV78XX0_GPIO_START; i < NR_IRQS; i++) { 42 for (i = IRQ_MV78XX0_GPIO_START; i < NR_IRQS; i++) {
43 set_irq_chip(i, &orion_gpio_irq_level_chip); 43 set_irq_chip(i, &orion_gpio_irq_chip);
44 set_irq_handler(i, handle_level_irq); 44 set_irq_handler(i, handle_level_irq);
45 irq_desc[i].status |= IRQ_LEVEL; 45 irq_desc[i].status |= IRQ_LEVEL;
46 set_irq_flags(i, IRQF_VALID); 46 set_irq_flags(i, IRQF_VALID);
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index 77382d8b6b2f..ba5d7c08dc17 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -181,7 +181,7 @@ void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
181 } 181 }
182 size = OMAP1_MMC_SIZE; 182 size = OMAP1_MMC_SIZE;
183 183
184 omap_mmc_add(i, base, size, irq, mmc_data[i]); 184 omap_mmc_add("mmci-omap", i, base, size, irq, mmc_data[i]);
185 }; 185 };
186} 186}
187 187
diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c
index ca7a0cc1707c..575ba31295cf 100644
--- a/arch/arm/mach-omap1/mcbsp.c
+++ b/arch/arm/mach-omap1/mcbsp.c
@@ -28,81 +28,8 @@
28#define DPS_RSTCT2_PER_EN (1 << 0) 28#define DPS_RSTCT2_PER_EN (1 << 0)
29#define DSP_RSTCT2_WD_PER_EN (1 << 1) 29#define DSP_RSTCT2_WD_PER_EN (1 << 1)
30 30
31struct mcbsp_internal_clk {
32 struct clk clk;
33 struct clk **childs;
34 int n_childs;
35};
36
37#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) 31#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX)
38static void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk) 32const char *clk_names[] = { "dsp_ck", "api_ck", "dspxor_ck" };
39{
40 const char *clk_names[] = { "dsp_ck", "api_ck", "dspxor_ck" };
41 int i;
42
43 mclk->n_childs = ARRAY_SIZE(clk_names);
44 mclk->childs = kzalloc(mclk->n_childs * sizeof(struct clk *),
45 GFP_KERNEL);
46
47 for (i = 0; i < mclk->n_childs; i++) {
48 /* We fake a platform device to get correct device id */
49 struct platform_device pdev;
50
51 pdev.dev.bus = &platform_bus_type;
52 pdev.id = mclk->clk.id;
53 mclk->childs[i] = clk_get(&pdev.dev, clk_names[i]);
54 if (IS_ERR(mclk->childs[i]))
55 printk(KERN_ERR "Could not get clock %s (%d).\n",
56 clk_names[i], mclk->clk.id);
57 }
58}
59
60static int omap_mcbsp_clk_enable(struct clk *clk)
61{
62 struct mcbsp_internal_clk *mclk = container_of(clk,
63 struct mcbsp_internal_clk, clk);
64 int i;
65
66 for (i = 0; i < mclk->n_childs; i++)
67 clk_enable(mclk->childs[i]);
68 return 0;
69}
70
71static void omap_mcbsp_clk_disable(struct clk *clk)
72{
73 struct mcbsp_internal_clk *mclk = container_of(clk,
74 struct mcbsp_internal_clk, clk);
75 int i;
76
77 for (i = 0; i < mclk->n_childs; i++)
78 clk_disable(mclk->childs[i]);
79}
80
81static struct mcbsp_internal_clk omap_mcbsp_clks[] = {
82 {
83 .clk = {
84 .name = "mcbsp_clk",
85 .id = 1,
86 .enable = omap_mcbsp_clk_enable,
87 .disable = omap_mcbsp_clk_disable,
88 },
89 },
90 {
91 .clk = {
92 .name = "mcbsp_clk",
93 .id = 3,
94 .enable = omap_mcbsp_clk_enable,
95 .disable = omap_mcbsp_clk_disable,
96 },
97 },
98};
99
100#define omap_mcbsp_clks_size ARRAY_SIZE(omap_mcbsp_clks)
101#else
102#define omap_mcbsp_clks_size 0
103static struct mcbsp_internal_clk __initdata *omap_mcbsp_clks;
104static inline void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk)
105{ }
106#endif 33#endif
107 34
108static void omap1_mcbsp_request(unsigned int id) 35static void omap1_mcbsp_request(unsigned int id)
@@ -167,8 +94,9 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
167 .rx_irq = INT_McBSP1RX, 94 .rx_irq = INT_McBSP1RX,
168 .tx_irq = INT_McBSP1TX, 95 .tx_irq = INT_McBSP1TX,
169 .ops = &omap1_mcbsp_ops, 96 .ops = &omap1_mcbsp_ops,
170 .clk_name = "mcbsp_clk", 97 .clk_names = clk_names,
171 }, 98 .num_clks = 3,
99 },
172 { 100 {
173 .phys_base = OMAP1510_MCBSP2_BASE, 101 .phys_base = OMAP1510_MCBSP2_BASE,
174 .dma_rx_sync = OMAP_DMA_MCBSP2_RX, 102 .dma_rx_sync = OMAP_DMA_MCBSP2_RX,
@@ -184,7 +112,8 @@ static struct omap_mcbsp_platform_data omap15xx_mcbsp_pdata[] = {
184 .rx_irq = INT_McBSP3RX, 112 .rx_irq = INT_McBSP3RX,
185 .tx_irq = INT_McBSP3TX, 113 .tx_irq = INT_McBSP3TX,
186 .ops = &omap1_mcbsp_ops, 114 .ops = &omap1_mcbsp_ops,
187 .clk_name = "mcbsp_clk", 115 .clk_names = clk_names,
116 .num_clks = 3,
188 }, 117 },
189}; 118};
190#define OMAP15XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap15xx_mcbsp_pdata) 119#define OMAP15XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap15xx_mcbsp_pdata)
@@ -202,7 +131,8 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
202 .rx_irq = INT_McBSP1RX, 131 .rx_irq = INT_McBSP1RX,
203 .tx_irq = INT_McBSP1TX, 132 .tx_irq = INT_McBSP1TX,
204 .ops = &omap1_mcbsp_ops, 133 .ops = &omap1_mcbsp_ops,
205 .clk_name = "mcbsp_clk", 134 .clk_names = clk_names,
135 .num_clks = 3,
206 }, 136 },
207 { 137 {
208 .phys_base = OMAP1610_MCBSP2_BASE, 138 .phys_base = OMAP1610_MCBSP2_BASE,
@@ -219,7 +149,8 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
219 .rx_irq = INT_McBSP3RX, 149 .rx_irq = INT_McBSP3RX,
220 .tx_irq = INT_McBSP3TX, 150 .tx_irq = INT_McBSP3TX,
221 .ops = &omap1_mcbsp_ops, 151 .ops = &omap1_mcbsp_ops,
222 .clk_name = "mcbsp_clk", 152 .clk_names = clk_names,
153 .num_clks = 3,
223 }, 154 },
224}; 155};
225#define OMAP16XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap16xx_mcbsp_pdata) 156#define OMAP16XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap16xx_mcbsp_pdata)
@@ -230,15 +161,6 @@ static struct omap_mcbsp_platform_data omap16xx_mcbsp_pdata[] = {
230 161
231int __init omap1_mcbsp_init(void) 162int __init omap1_mcbsp_init(void)
232{ 163{
233 int i;
234
235 for (i = 0; i < omap_mcbsp_clks_size; i++) {
236 if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
237 omap_mcbsp_clk_init(&omap_mcbsp_clks[i]);
238 clk_register(&omap_mcbsp_clks[i].clk);
239 }
240 }
241
242 if (cpu_is_omap730()) 164 if (cpu_is_omap730())
243 omap_mcbsp_count = OMAP730_MCBSP_PDATA_SZ; 165 omap_mcbsp_count = OMAP730_MCBSP_PDATA_SZ;
244 if (cpu_is_omap15xx()) 166 if (cpu_is_omap15xx())
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index ad721e0cbf7a..ce4d46a4a838 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -565,7 +565,7 @@ u32 omap2_clksel_to_divisor(struct clk *clk, u32 field_val)
565 * 565 *
566 * Given a struct clk of a rate-selectable clksel clock, and a clock divisor, 566 * Given a struct clk of a rate-selectable clksel clock, and a clock divisor,
567 * find the corresponding register field value. The return register value is 567 * find the corresponding register field value. The return register value is
568 * the value before left-shifting. Returns 0xffffffff on error 568 * the value before left-shifting. Returns ~0 on error
569 */ 569 */
570u32 omap2_divisor_to_clksel(struct clk *clk, u32 div) 570u32 omap2_divisor_to_clksel(struct clk *clk, u32 div)
571{ 571{
@@ -577,7 +577,7 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div)
577 577
578 clks = omap2_get_clksel_by_parent(clk, clk->parent); 578 clks = omap2_get_clksel_by_parent(clk, clk->parent);
579 if (clks == NULL) 579 if (clks == NULL)
580 return 0; 580 return ~0;
581 581
582 for (clkr = clks->rates; clkr->div; clkr++) { 582 for (clkr = clks->rates; clkr->div; clkr++) {
583 if ((clkr->flags & cpu_mask) && (clkr->div == div)) 583 if ((clkr->flags & cpu_mask) && (clkr->div == div))
@@ -588,7 +588,7 @@ u32 omap2_divisor_to_clksel(struct clk *clk, u32 div)
588 printk(KERN_ERR "clock: Could not find divisor %d for " 588 printk(KERN_ERR "clock: Could not find divisor %d for "
589 "clock %s parent %s\n", div, clk->name, 589 "clock %s parent %s\n", div, clk->name,
590 clk->parent->name); 590 clk->parent->name);
591 return 0; 591 return ~0;
592 } 592 }
593 593
594 return clkr->val; 594 return clkr->val;
@@ -708,7 +708,7 @@ static u32 omap2_clksel_get_src_field(void __iomem **src_addr,
708 return 0; 708 return 0;
709 709
710 for (clkr = clks->rates; clkr->div; clkr++) { 710 for (clkr = clks->rates; clkr->div; clkr++) {
711 if (clkr->flags & (cpu_mask | DEFAULT_RATE)) 711 if (clkr->flags & cpu_mask && clkr->flags & DEFAULT_RATE)
712 break; /* Found the default rate for this platform */ 712 break; /* Found the default rate for this platform */
713 } 713 }
714 714
@@ -746,7 +746,7 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
746 return -EINVAL; 746 return -EINVAL;
747 747
748 if (clk->usecount > 0) 748 if (clk->usecount > 0)
749 _omap2_clk_disable(clk); 749 omap2_clk_disable(clk);
750 750
751 /* Set new source value (previous dividers if any in effect) */ 751 /* Set new source value (previous dividers if any in effect) */
752 reg_val = __raw_readl(src_addr) & ~field_mask; 752 reg_val = __raw_readl(src_addr) & ~field_mask;
@@ -759,11 +759,11 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
759 wmb(); 759 wmb();
760 } 760 }
761 761
762 if (clk->usecount > 0)
763 _omap2_clk_enable(clk);
764
765 clk->parent = new_parent; 762 clk->parent = new_parent;
766 763
764 if (clk->usecount > 0)
765 omap2_clk_enable(clk);
766
767 /* CLKSEL clocks follow their parents' rates, divided by a divisor */ 767 /* CLKSEL clocks follow their parents' rates, divided by a divisor */
768 clk->rate = new_parent->rate; 768 clk->rate = new_parent->rate;
769 769
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 9d7216ff6c9f..ce03fa750775 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -421,6 +421,7 @@ void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
421 int nr_controllers) 421 int nr_controllers)
422{ 422{
423 int i; 423 int i;
424 char *name;
424 425
425 for (i = 0; i < nr_controllers; i++) { 426 for (i = 0; i < nr_controllers; i++) {
426 unsigned long base, size; 427 unsigned long base, size;
@@ -450,12 +451,14 @@ void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
450 continue; 451 continue;
451 } 452 }
452 453
453 if (cpu_is_omap2420()) 454 if (cpu_is_omap2420()) {
454 size = OMAP2420_MMC_SIZE; 455 size = OMAP2420_MMC_SIZE;
455 else 456 name = "mmci-omap";
457 } else {
456 size = HSMMC_SIZE; 458 size = HSMMC_SIZE;
457 459 name = "mmci-omap-hs";
458 omap_mmc_add(i, base, size, irq, mmc_data[i]); 460 }
461 omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
459 }; 462 };
460} 463}
461 464
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index b0f8e7d62798..b52a02fc7cd6 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -172,9 +172,13 @@ void __init omap34xx_check_revision(void)
172 omap_revision = OMAP3430_REV_ES3_0; 172 omap_revision = OMAP3430_REV_ES3_0;
173 rev_name = "ES3.0"; 173 rev_name = "ES3.0";
174 break; 174 break;
175 case 4:
176 omap_revision = OMAP3430_REV_ES3_1;
177 rev_name = "ES3.1";
178 break;
175 default: 179 default:
176 /* Use the latest known revision as default */ 180 /* Use the latest known revision as default */
177 omap_revision = OMAP3430_REV_ES3_0; 181 omap_revision = OMAP3430_REV_ES3_1;
178 rev_name = "Unknown revision\n"; 182 rev_name = "Unknown revision\n";
179 } 183 }
180 } 184 }
diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index 636e2821af7d..9ba20d985dda 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -134,6 +134,7 @@ static struct irq_chip omap_irq_chip = {
134 .ack = omap_mask_ack_irq, 134 .ack = omap_mask_ack_irq,
135 .mask = omap_mask_irq, 135 .mask = omap_mask_irq,
136 .unmask = omap_unmask_irq, 136 .unmask = omap_unmask_irq,
137 .disable = omap_mask_irq,
137}; 138};
138 139
139static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank) 140static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index e20023c9d15d..a9e631fc1134 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -24,106 +24,7 @@
24#include <mach/cpu.h> 24#include <mach/cpu.h>
25#include <mach/mcbsp.h> 25#include <mach/mcbsp.h>
26 26
27struct mcbsp_internal_clk { 27const char *clk_names[] = { "mcbsp_ick", "mcbsp_fck" };
28 struct clk clk;
29 struct clk **childs;
30 int n_childs;
31};
32
33#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
34static void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk)
35{
36 const char *clk_names[] = { "mcbsp_ick", "mcbsp_fck" };
37 int i;
38
39 mclk->n_childs = ARRAY_SIZE(clk_names);
40 mclk->childs = kzalloc(mclk->n_childs * sizeof(struct clk *),
41 GFP_KERNEL);
42
43 for (i = 0; i < mclk->n_childs; i++) {
44 /* We fake a platform device to get correct device id */
45 struct platform_device pdev;
46
47 pdev.dev.bus = &platform_bus_type;
48 pdev.id = mclk->clk.id;
49 mclk->childs[i] = clk_get(&pdev.dev, clk_names[i]);
50 if (IS_ERR(mclk->childs[i]))
51 printk(KERN_ERR "Could not get clock %s (%d).\n",
52 clk_names[i], mclk->clk.id);
53 }
54}
55
56static int omap_mcbsp_clk_enable(struct clk *clk)
57{
58 struct mcbsp_internal_clk *mclk = container_of(clk,
59 struct mcbsp_internal_clk, clk);
60 int i;
61
62 for (i = 0; i < mclk->n_childs; i++)
63 clk_enable(mclk->childs[i]);
64 return 0;
65}
66
67static void omap_mcbsp_clk_disable(struct clk *clk)
68{
69 struct mcbsp_internal_clk *mclk = container_of(clk,
70 struct mcbsp_internal_clk, clk);
71 int i;
72
73 for (i = 0; i < mclk->n_childs; i++)
74 clk_disable(mclk->childs[i]);
75}
76
77static struct mcbsp_internal_clk omap_mcbsp_clks[] = {
78 {
79 .clk = {
80 .name = "mcbsp_clk",
81 .id = 1,
82 .enable = omap_mcbsp_clk_enable,
83 .disable = omap_mcbsp_clk_disable,
84 },
85 },
86 {
87 .clk = {
88 .name = "mcbsp_clk",
89 .id = 2,
90 .enable = omap_mcbsp_clk_enable,
91 .disable = omap_mcbsp_clk_disable,
92 },
93 },
94 {
95 .clk = {
96 .name = "mcbsp_clk",
97 .id = 3,
98 .enable = omap_mcbsp_clk_enable,
99 .disable = omap_mcbsp_clk_disable,
100 },
101 },
102 {
103 .clk = {
104 .name = "mcbsp_clk",
105 .id = 4,
106 .enable = omap_mcbsp_clk_enable,
107 .disable = omap_mcbsp_clk_disable,
108 },
109 },
110 {
111 .clk = {
112 .name = "mcbsp_clk",
113 .id = 5,
114 .enable = omap_mcbsp_clk_enable,
115 .disable = omap_mcbsp_clk_disable,
116 },
117 },
118};
119
120#define omap_mcbsp_clks_size ARRAY_SIZE(omap_mcbsp_clks)
121#else
122#define omap_mcbsp_clks_size 0
123static struct mcbsp_internal_clk __initdata *omap_mcbsp_clks;
124static inline void omap_mcbsp_clk_init(struct clk *clk)
125{ }
126#endif
127 28
128static void omap2_mcbsp2_mux_setup(void) 29static void omap2_mcbsp2_mux_setup(void)
129{ 30{
@@ -156,7 +57,8 @@ static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
156 .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 57 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
157 .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 58 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
158 .ops = &omap2_mcbsp_ops, 59 .ops = &omap2_mcbsp_ops,
159 .clk_name = "mcbsp_clk", 60 .clk_names = clk_names,
61 .num_clks = 2,
160 }, 62 },
161 { 63 {
162 .phys_base = OMAP24XX_MCBSP2_BASE, 64 .phys_base = OMAP24XX_MCBSP2_BASE,
@@ -165,7 +67,8 @@ static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
165 .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 67 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
166 .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 68 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
167 .ops = &omap2_mcbsp_ops, 69 .ops = &omap2_mcbsp_ops,
168 .clk_name = "mcbsp_clk", 70 .clk_names = clk_names,
71 .num_clks = 2,
169 }, 72 },
170}; 73};
171#define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata) 74#define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata)
@@ -183,7 +86,8 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
183 .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 86 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
184 .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 87 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
185 .ops = &omap2_mcbsp_ops, 88 .ops = &omap2_mcbsp_ops,
186 .clk_name = "mcbsp_clk", 89 .clk_names = clk_names,
90 .num_clks = 2,
187 }, 91 },
188 { 92 {
189 .phys_base = OMAP24XX_MCBSP2_BASE, 93 .phys_base = OMAP24XX_MCBSP2_BASE,
@@ -192,7 +96,8 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
192 .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 96 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
193 .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 97 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
194 .ops = &omap2_mcbsp_ops, 98 .ops = &omap2_mcbsp_ops,
195 .clk_name = "mcbsp_clk", 99 .clk_names = clk_names,
100 .num_clks = 2,
196 }, 101 },
197 { 102 {
198 .phys_base = OMAP2430_MCBSP3_BASE, 103 .phys_base = OMAP2430_MCBSP3_BASE,
@@ -201,7 +106,8 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
201 .rx_irq = INT_24XX_MCBSP3_IRQ_RX, 106 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
202 .tx_irq = INT_24XX_MCBSP3_IRQ_TX, 107 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
203 .ops = &omap2_mcbsp_ops, 108 .ops = &omap2_mcbsp_ops,
204 .clk_name = "mcbsp_clk", 109 .clk_names = clk_names,
110 .num_clks = 2,
205 }, 111 },
206 { 112 {
207 .phys_base = OMAP2430_MCBSP4_BASE, 113 .phys_base = OMAP2430_MCBSP4_BASE,
@@ -210,7 +116,8 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
210 .rx_irq = INT_24XX_MCBSP4_IRQ_RX, 116 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
211 .tx_irq = INT_24XX_MCBSP4_IRQ_TX, 117 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
212 .ops = &omap2_mcbsp_ops, 118 .ops = &omap2_mcbsp_ops,
213 .clk_name = "mcbsp_clk", 119 .clk_names = clk_names,
120 .num_clks = 2,
214 }, 121 },
215 { 122 {
216 .phys_base = OMAP2430_MCBSP5_BASE, 123 .phys_base = OMAP2430_MCBSP5_BASE,
@@ -219,7 +126,8 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
219 .rx_irq = INT_24XX_MCBSP5_IRQ_RX, 126 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
220 .tx_irq = INT_24XX_MCBSP5_IRQ_TX, 127 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
221 .ops = &omap2_mcbsp_ops, 128 .ops = &omap2_mcbsp_ops,
222 .clk_name = "mcbsp_clk", 129 .clk_names = clk_names,
130 .num_clks = 2,
223 }, 131 },
224}; 132};
225#define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata) 133#define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata)
@@ -237,7 +145,8 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
237 .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 145 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
238 .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 146 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
239 .ops = &omap2_mcbsp_ops, 147 .ops = &omap2_mcbsp_ops,
240 .clk_name = "mcbsp_clk", 148 .clk_names = clk_names,
149 .num_clks = 2,
241 }, 150 },
242 { 151 {
243 .phys_base = OMAP34XX_MCBSP2_BASE, 152 .phys_base = OMAP34XX_MCBSP2_BASE,
@@ -246,7 +155,8 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
246 .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 155 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
247 .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 156 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
248 .ops = &omap2_mcbsp_ops, 157 .ops = &omap2_mcbsp_ops,
249 .clk_name = "mcbsp_clk", 158 .clk_names = clk_names,
159 .num_clks = 2,
250 }, 160 },
251 { 161 {
252 .phys_base = OMAP34XX_MCBSP3_BASE, 162 .phys_base = OMAP34XX_MCBSP3_BASE,
@@ -255,7 +165,8 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
255 .rx_irq = INT_24XX_MCBSP3_IRQ_RX, 165 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
256 .tx_irq = INT_24XX_MCBSP3_IRQ_TX, 166 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
257 .ops = &omap2_mcbsp_ops, 167 .ops = &omap2_mcbsp_ops,
258 .clk_name = "mcbsp_clk", 168 .clk_names = clk_names,
169 .num_clks = 2,
259 }, 170 },
260 { 171 {
261 .phys_base = OMAP34XX_MCBSP4_BASE, 172 .phys_base = OMAP34XX_MCBSP4_BASE,
@@ -264,7 +175,8 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
264 .rx_irq = INT_24XX_MCBSP4_IRQ_RX, 175 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
265 .tx_irq = INT_24XX_MCBSP4_IRQ_TX, 176 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
266 .ops = &omap2_mcbsp_ops, 177 .ops = &omap2_mcbsp_ops,
267 .clk_name = "mcbsp_clk", 178 .clk_names = clk_names,
179 .num_clks = 2,
268 }, 180 },
269 { 181 {
270 .phys_base = OMAP34XX_MCBSP5_BASE, 182 .phys_base = OMAP34XX_MCBSP5_BASE,
@@ -273,7 +185,8 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
273 .rx_irq = INT_24XX_MCBSP5_IRQ_RX, 185 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
274 .tx_irq = INT_24XX_MCBSP5_IRQ_TX, 186 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
275 .ops = &omap2_mcbsp_ops, 187 .ops = &omap2_mcbsp_ops,
276 .clk_name = "mcbsp_clk", 188 .clk_names = clk_names,
189 .num_clks = 2,
277 }, 190 },
278}; 191};
279#define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata) 192#define OMAP34XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap34xx_mcbsp_pdata)
@@ -284,14 +197,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
284 197
285static int __init omap2_mcbsp_init(void) 198static int __init omap2_mcbsp_init(void)
286{ 199{
287 int i;
288
289 for (i = 0; i < omap_mcbsp_clks_size; i++) {
290 /* Once we call clk_get inside init, we do not register it */
291 omap_mcbsp_clk_init(&omap_mcbsp_clks[i]);
292 clk_register(&omap_mcbsp_clks[i].clk);
293 }
294
295 if (cpu_is_omap2420()) 200 if (cpu_is_omap2420())
296 omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ; 201 omap_mcbsp_count = OMAP2420_MCBSP_PDATA_SZ;
297 if (cpu_is_omap2430()) 202 if (cpu_is_omap2430())
diff --git a/arch/arm/mach-omap2/sleep24xx.S b/arch/arm/mach-omap2/sleep24xx.S
index 43336b93b21c..bf9e96105e11 100644
--- a/arch/arm/mach-omap2/sleep24xx.S
+++ b/arch/arm/mach-omap2/sleep24xx.S
@@ -93,9 +93,8 @@ ENTRY(omap24xx_cpu_suspend)
93 orr r4, r4, #0x40 @ enable self refresh on idle req 93 orr r4, r4, #0x40 @ enable self refresh on idle req
94 mov r5, #0x2000 @ set delay (DPLL relock + DLL relock) 94 mov r5, #0x2000 @ set delay (DPLL relock + DLL relock)
95 str r4, [r2] @ make it so 95 str r4, [r2] @ make it so
96 mov r2, #0
97 nop 96 nop
98 mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt 97 mcr p15, 0, r3, c7, c0, 4 @ wait for interrupt
99 nop 98 nop
100loop: 99loop:
101 subs r5, r5, #0x1 @ awake, wait just a bit 100 subs r5, r5, #0x1 @ awake, wait just a bit
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index ae6036300f60..9fc13a2cc3f4 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -118,7 +118,8 @@ static void __init omap2_gp_clockevent_init(void)
118 clockevent_gpt.max_delta_ns = 118 clockevent_gpt.max_delta_ns =
119 clockevent_delta2ns(0xffffffff, &clockevent_gpt); 119 clockevent_delta2ns(0xffffffff, &clockevent_gpt);
120 clockevent_gpt.min_delta_ns = 120 clockevent_gpt.min_delta_ns =
121 clockevent_delta2ns(1, &clockevent_gpt); 121 clockevent_delta2ns(3, &clockevent_gpt);
122 /* Timer internal resynch latency. */
122 123
123 clockevent_gpt.cpumask = cpumask_of(0); 124 clockevent_gpt.cpumask = cpumask_of(0);
124 clockevents_register_device(&clockevent_gpt); 125 clockevents_register_device(&clockevent_gpt);
diff --git a/arch/arm/mach-orion5x/irq.c b/arch/arm/mach-orion5x/irq.c
index 0caae43301e5..e03f7b45cb0d 100644
--- a/arch/arm/mach-orion5x/irq.c
+++ b/arch/arm/mach-orion5x/irq.c
@@ -44,7 +44,7 @@ void __init orion5x_init_irq(void)
44 * User can use set_type() if he wants to use edge types handlers. 44 * User can use set_type() if he wants to use edge types handlers.
45 */ 45 */
46 for (i = IRQ_ORION5X_GPIO_START; i < NR_IRQS; i++) { 46 for (i = IRQ_ORION5X_GPIO_START; i < NR_IRQS; i++) {
47 set_irq_chip(i, &orion_gpio_irq_level_chip); 47 set_irq_chip(i, &orion_gpio_irq_chip);
48 set_irq_handler(i, handle_level_irq); 48 set_irq_handler(i, handle_level_irq);
49 irq_desc[i].status |= IRQ_LEVEL; 49 irq_desc[i].status |= IRQ_LEVEL;
50 set_irq_flags(i, IRQF_VALID); 50 set_irq_flags(i, IRQF_VALID);
diff --git a/arch/arm/mach-pxa/dma.c b/arch/arm/mach-pxa/dma.c
index b1514fb20d3a..7de17fc5d54b 100644
--- a/arch/arm/mach-pxa/dma.c
+++ b/arch/arm/mach-pxa/dma.c
@@ -121,20 +121,22 @@ int __init pxa_init_dma(int num_ch)
121 if (dma_channels == NULL) 121 if (dma_channels == NULL)
122 return -ENOMEM; 122 return -ENOMEM;
123 123
124 ret = request_irq(IRQ_DMA, dma_irq_handler, IRQF_DISABLED, "DMA", NULL);
125 if (ret) {
126 printk (KERN_CRIT "Wow! Can't register IRQ for DMA\n");
127 kfree(dma_channels);
128 return ret;
129 }
130
131 /* dma channel priorities on pxa2xx processors: 124 /* dma channel priorities on pxa2xx processors:
132 * ch 0 - 3, 16 - 19 <--> (0) DMA_PRIO_HIGH 125 * ch 0 - 3, 16 - 19 <--> (0) DMA_PRIO_HIGH
133 * ch 4 - 7, 20 - 23 <--> (1) DMA_PRIO_MEDIUM 126 * ch 4 - 7, 20 - 23 <--> (1) DMA_PRIO_MEDIUM
134 * ch 8 - 15, 24 - 31 <--> (2) DMA_PRIO_LOW 127 * ch 8 - 15, 24 - 31 <--> (2) DMA_PRIO_LOW
135 */ 128 */
136 for (i = 0; i < num_ch; i++) 129 for (i = 0; i < num_ch; i++) {
130 DCSR(i) = 0;
137 dma_channels[i].prio = min((i & 0xf) >> 2, DMA_PRIO_LOW); 131 dma_channels[i].prio = min((i & 0xf) >> 2, DMA_PRIO_LOW);
132 }
133
134 ret = request_irq(IRQ_DMA, dma_irq_handler, IRQF_DISABLED, "DMA", NULL);
135 if (ret) {
136 printk (KERN_CRIT "Wow! Can't register IRQ for DMA\n");
137 kfree(dma_channels);
138 return ret;
139 }
138 140
139 num_dma_channels = num_ch; 141 num_dma_channels = num_ch;
140 return 0; 142 return 0;
diff --git a/arch/arm/mach-pxa/include/mach/regs-ac97.h b/arch/arm/mach-pxa/include/mach/regs-ac97.h
index e41b9d202b8c..b8d14bd9ae59 100644
--- a/arch/arm/mach-pxa/include/mach/regs-ac97.h
+++ b/arch/arm/mach-pxa/include/mach/regs-ac97.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_ARCH_REGS_AC97_H 1#ifndef __ASM_ARCH_REGS_AC97_H
2#define __ASM_ARCH_REGS_AC97_H 2#define __ASM_ARCH_REGS_AC97_H
3 3
4#include <mach/hardware.h>
5
4/* 6/*
5 * AC97 Controller registers 7 * AC97 Controller registers
6 */ 8 */
diff --git a/arch/arm/mach-pxa/include/mach/regs-ssp.h b/arch/arm/mach-pxa/include/mach/regs-ssp.h
index 3c04cde2cf1f..cf31986f6f05 100644
--- a/arch/arm/mach-pxa/include/mach/regs-ssp.h
+++ b/arch/arm/mach-pxa/include/mach/regs-ssp.h
@@ -41,6 +41,9 @@
41#elif defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) 41#elif defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
42#define SSCR0_SCR (0x000fff00) /* Serial Clock Rate (mask) */ 42#define SSCR0_SCR (0x000fff00) /* Serial Clock Rate (mask) */
43#define SSCR0_SerClkDiv(x) (((x) - 1) << 8) /* Divisor [1..4096] */ 43#define SSCR0_SerClkDiv(x) (((x) - 1) << 8) /* Divisor [1..4096] */
44#endif
45
46#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
44#define SSCR0_EDSS (1 << 20) /* Extended data size select */ 47#define SSCR0_EDSS (1 << 20) /* Extended data size select */
45#define SSCR0_NCS (1 << 21) /* Network clock select */ 48#define SSCR0_NCS (1 << 21) /* Network clock select */
46#define SSCR0_RIM (1 << 22) /* Receive FIFO overrrun interrupt mask */ 49#define SSCR0_RIM (1 << 22) /* Receive FIFO overrrun interrupt mask */
diff --git a/arch/arm/mach-pxa/pxa300.c b/arch/arm/mach-pxa/pxa300.c
index f735e58e6669..83fb609b6eb7 100644
--- a/arch/arm/mach-pxa/pxa300.c
+++ b/arch/arm/mach-pxa/pxa300.c
@@ -88,13 +88,13 @@ static struct pxa3xx_mfp_addr_map pxa310_mfp_addr_map[] __initdata = {
88static DEFINE_PXA3_CKEN(common_nand, NAND, 156000000, 0); 88static DEFINE_PXA3_CKEN(common_nand, NAND, 156000000, 0);
89 89
90static struct clk_lookup common_clkregs[] = { 90static struct clk_lookup common_clkregs[] = {
91 INIT_CLKREG(&clk_common_nand, "pxa3xx-nand", "NANDCLK"), 91 INIT_CLKREG(&clk_common_nand, "pxa3xx-nand", NULL),
92}; 92};
93 93
94static DEFINE_PXA3_CKEN(pxa310_mmc3, MMC3, 19500000, 0); 94static DEFINE_PXA3_CKEN(pxa310_mmc3, MMC3, 19500000, 0);
95 95
96static struct clk_lookup pxa310_clkregs[] = { 96static struct clk_lookup pxa310_clkregs[] = {
97 INIT_CLKREG(&clk_pxa310_mmc3, "pxa2xx-mci.2", "MMCCLK"), 97 INIT_CLKREG(&clk_pxa310_mmc3, "pxa2xx-mci.2", NULL),
98}; 98};
99 99
100static int __init pxa300_init(void) 100static int __init pxa300_init(void)
diff --git a/arch/arm/mach-pxa/pxa320.c b/arch/arm/mach-pxa/pxa320.c
index effe408c186f..36f066196fa2 100644
--- a/arch/arm/mach-pxa/pxa320.c
+++ b/arch/arm/mach-pxa/pxa320.c
@@ -83,7 +83,7 @@ static struct pxa3xx_mfp_addr_map pxa320_mfp_addr_map[] __initdata = {
83static DEFINE_PXA3_CKEN(pxa320_nand, NAND, 104000000, 0); 83static DEFINE_PXA3_CKEN(pxa320_nand, NAND, 104000000, 0);
84 84
85static struct clk_lookup pxa320_clkregs[] = { 85static struct clk_lookup pxa320_clkregs[] = {
86 INIT_CLKREG(&clk_pxa320_nand, "pxa3xx-nand", "NANDCLK"), 86 INIT_CLKREG(&clk_pxa320_nand, "pxa3xx-nand", NULL),
87}; 87};
88 88
89static int __init pxa320_init(void) 89static int __init pxa320_init(void)
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index c1fbd5b5f9c4..23cfdd593954 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -289,7 +289,7 @@ static struct platform_device sa11x0pcmcia_device = {
289}; 289};
290 290
291static struct platform_device sa11x0mtd_device = { 291static struct platform_device sa11x0mtd_device = {
292 .name = "flash", 292 .name = "sa1100-mtd",
293 .id = -1, 293 .id = -1,
294}; 294};
295 295
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index 81d0b8772de3..bc0099d5ae85 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -66,7 +66,10 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
66 * fault (ie, is old), we can safely ignore any issues. 66 * fault (ie, is old), we can safely ignore any issues.
67 */ 67 */
68 if (ret && (pte_val(entry) & L_PTE_MT_MASK) != shared_pte_mask) { 68 if (ret && (pte_val(entry) & L_PTE_MT_MASK) != shared_pte_mask) {
69 flush_cache_page(vma, address, pte_pfn(entry)); 69 unsigned long pfn = pte_pfn(entry);
70 flush_cache_page(vma, address, pfn);
71 outer_flush_range((pfn << PAGE_SHIFT),
72 (pfn << PAGE_SHIFT) + PAGE_SIZE);
70 pte_val(entry) &= ~L_PTE_MT_MASK; 73 pte_val(entry) &= ~L_PTE_MT_MASK;
71 pte_val(entry) |= shared_pte_mask; 74 pte_val(entry) |= shared_pte_mask;
72 set_pte_at(vma->vm_mm, address, pte, entry); 75 set_pte_at(vma->vm_mm, address, pte, entry);
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 9b36c5cb5e9f..d4d082c5c2d4 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -693,7 +693,8 @@ static void __init sanity_check_meminfo(void)
693 * Check whether this memory bank would entirely overlap 693 * Check whether this memory bank would entirely overlap
694 * the vmalloc area. 694 * the vmalloc area.
695 */ 695 */
696 if (__va(bank->start) >= VMALLOC_MIN) { 696 if (__va(bank->start) >= VMALLOC_MIN ||
697 __va(bank->start) < PAGE_OFFSET) {
697 printk(KERN_NOTICE "Ignoring RAM at %.8lx-%.8lx " 698 printk(KERN_NOTICE "Ignoring RAM at %.8lx-%.8lx "
698 "(vmalloc region overlap).\n", 699 "(vmalloc region overlap).\n",
699 bank->start, bank->start + bank->size - 1); 700 bank->start, bank->start + bank->size - 1);
diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c
index ac15c23fd5da..208dbb121f47 100644
--- a/arch/arm/plat-omap/devices.c
+++ b/arch/arm/plat-omap/devices.c
@@ -200,14 +200,15 @@ void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
200/* 200/*
201 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init. 201 * Register MMC devices. Called from mach-omap1 and mach-omap2 device init.
202 */ 202 */
203int __init omap_mmc_add(int id, unsigned long base, unsigned long size, 203int __init omap_mmc_add(const char *name, int id, unsigned long base,
204 unsigned int irq, struct omap_mmc_platform_data *data) 204 unsigned long size, unsigned int irq,
205 struct omap_mmc_platform_data *data)
205{ 206{
206 struct platform_device *pdev; 207 struct platform_device *pdev;
207 struct resource res[OMAP_MMC_NR_RES]; 208 struct resource res[OMAP_MMC_NR_RES];
208 int ret; 209 int ret;
209 210
210 pdev = platform_device_alloc("mmci-omap", id); 211 pdev = platform_device_alloc(name, id);
211 if (!pdev) 212 if (!pdev)
212 return -ENOMEM; 213 return -ENOMEM;
213 214
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index e77373c39f8c..47ec77af4ccb 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -709,6 +709,7 @@ int omap_request_dma(int dev_id, const char *dev_name,
709 chan->dev_name = dev_name; 709 chan->dev_name = dev_name;
710 chan->callback = callback; 710 chan->callback = callback;
711 chan->data = data; 711 chan->data = data;
712 chan->flags = 0;
712 713
713#ifndef CONFIG_ARCH_OMAP1 714#ifndef CONFIG_ARCH_OMAP1
714 if (cpu_class_is_omap2()) { 715 if (cpu_class_is_omap2()) {
@@ -1888,11 +1889,11 @@ static int omap2_dma_handle_ch(int ch)
1888 status = dma_read(CSR(ch)); 1889 status = dma_read(CSR(ch));
1889 } 1890 }
1890 1891
1892 dma_write(status, CSR(ch));
1893
1891 if (likely(dma_chan[ch].callback != NULL)) 1894 if (likely(dma_chan[ch].callback != NULL))
1892 dma_chan[ch].callback(ch, status, dma_chan[ch].data); 1895 dma_chan[ch].callback(ch, status, dma_chan[ch].data);
1893 1896
1894 dma_write(status, CSR(ch));
1895
1896 return 0; 1897 return 0;
1897} 1898}
1898 1899
diff --git a/arch/arm/plat-omap/include/mach/cpu.h b/arch/arm/plat-omap/include/mach/cpu.h
index b2062f1175de..a8e1178a9468 100644
--- a/arch/arm/plat-omap/include/mach/cpu.h
+++ b/arch/arm/plat-omap/include/mach/cpu.h
@@ -339,6 +339,7 @@ IS_OMAP_TYPE(3430, 0x3430)
339#define OMAP3430_REV_ES2_0 0x34301034 339#define OMAP3430_REV_ES2_0 0x34301034
340#define OMAP3430_REV_ES2_1 0x34302034 340#define OMAP3430_REV_ES2_1 0x34302034
341#define OMAP3430_REV_ES3_0 0x34303034 341#define OMAP3430_REV_ES3_0 0x34303034
342#define OMAP3430_REV_ES3_1 0x34304034
342 343
343/* 344/*
344 * omap_chip bits 345 * omap_chip bits
diff --git a/arch/arm/plat-omap/include/mach/mcbsp.h b/arch/arm/plat-omap/include/mach/mcbsp.h
index eef873db3d48..113c2466c86a 100644
--- a/arch/arm/plat-omap/include/mach/mcbsp.h
+++ b/arch/arm/plat-omap/include/mach/mcbsp.h
@@ -344,7 +344,8 @@ struct omap_mcbsp_platform_data {
344 u8 dma_rx_sync, dma_tx_sync; 344 u8 dma_rx_sync, dma_tx_sync;
345 u16 rx_irq, tx_irq; 345 u16 rx_irq, tx_irq;
346 struct omap_mcbsp_ops *ops; 346 struct omap_mcbsp_ops *ops;
347 char const *clk_name; 347 char const **clk_names;
348 int num_clks;
348}; 349};
349 350
350struct omap_mcbsp { 351struct omap_mcbsp {
@@ -376,7 +377,8 @@ struct omap_mcbsp {
376 /* Protect the field .free, while checking if the mcbsp is in use */ 377 /* Protect the field .free, while checking if the mcbsp is in use */
377 spinlock_t lock; 378 spinlock_t lock;
378 struct omap_mcbsp_platform_data *pdata; 379 struct omap_mcbsp_platform_data *pdata;
379 struct clk *clk; 380 struct clk **clks;
381 int num_clks;
380}; 382};
381extern struct omap_mcbsp **mcbsp_ptr; 383extern struct omap_mcbsp **mcbsp_ptr;
382extern int omap_mcbsp_count; 384extern int omap_mcbsp_count;
diff --git a/arch/arm/plat-omap/include/mach/mmc.h b/arch/arm/plat-omap/include/mach/mmc.h
index 031250f02805..73a9e15031b1 100644
--- a/arch/arm/plat-omap/include/mach/mmc.h
+++ b/arch/arm/plat-omap/include/mach/mmc.h
@@ -115,8 +115,9 @@ void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
115 int nr_controllers); 115 int nr_controllers);
116void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data, 116void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
117 int nr_controllers); 117 int nr_controllers);
118int omap_mmc_add(int id, unsigned long base, unsigned long size, 118int omap_mmc_add(const char *name, int id, unsigned long base,
119 unsigned int irq, struct omap_mmc_platform_data *data); 119 unsigned long size, unsigned int irq,
120 struct omap_mmc_platform_data *data);
120#else 121#else
121static inline void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data, 122static inline void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
122 int nr_controllers) 123 int nr_controllers)
@@ -126,8 +127,9 @@ static inline void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
126 int nr_controllers) 127 int nr_controllers)
127{ 128{
128} 129}
129static inline int omap_mmc_add(int id, unsigned long base, unsigned long size, 130static inline int omap_mmc_add(const char *name, int id, unsigned long base,
130 unsigned int irq, struct omap_mmc_platform_data *data) 131 unsigned long size, unsigned int irq,
132 struct omap_mmc_platform_data *data)
131{ 133{
132 return 0; 134 return 0;
133} 135}
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index f2401a831f99..e5842e30e534 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -214,6 +214,7 @@ EXPORT_SYMBOL(omap_mcbsp_set_io_type);
214int omap_mcbsp_request(unsigned int id) 214int omap_mcbsp_request(unsigned int id)
215{ 215{
216 struct omap_mcbsp *mcbsp; 216 struct omap_mcbsp *mcbsp;
217 int i;
217 int err; 218 int err;
218 219
219 if (!omap_mcbsp_check_valid_id(id)) { 220 if (!omap_mcbsp_check_valid_id(id)) {
@@ -225,7 +226,8 @@ int omap_mcbsp_request(unsigned int id)
225 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request) 226 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
226 mcbsp->pdata->ops->request(id); 227 mcbsp->pdata->ops->request(id);
227 228
228 clk_enable(mcbsp->clk); 229 for (i = 0; i < mcbsp->num_clks; i++)
230 clk_enable(mcbsp->clks[i]);
229 231
230 spin_lock(&mcbsp->lock); 232 spin_lock(&mcbsp->lock);
231 if (!mcbsp->free) { 233 if (!mcbsp->free) {
@@ -276,6 +278,7 @@ EXPORT_SYMBOL(omap_mcbsp_request);
276void omap_mcbsp_free(unsigned int id) 278void omap_mcbsp_free(unsigned int id)
277{ 279{
278 struct omap_mcbsp *mcbsp; 280 struct omap_mcbsp *mcbsp;
281 int i;
279 282
280 if (!omap_mcbsp_check_valid_id(id)) { 283 if (!omap_mcbsp_check_valid_id(id)) {
281 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); 284 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
@@ -286,7 +289,8 @@ void omap_mcbsp_free(unsigned int id)
286 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) 289 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free)
287 mcbsp->pdata->ops->free(id); 290 mcbsp->pdata->ops->free(id);
288 291
289 clk_disable(mcbsp->clk); 292 for (i = mcbsp->num_clks - 1; i >= 0; i--)
293 clk_disable(mcbsp->clks[i]);
290 294
291 spin_lock(&mcbsp->lock); 295 spin_lock(&mcbsp->lock);
292 if (mcbsp->free) { 296 if (mcbsp->free) {
@@ -872,6 +876,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
872 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; 876 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
873 struct omap_mcbsp *mcbsp; 877 struct omap_mcbsp *mcbsp;
874 int id = pdev->id - 1; 878 int id = pdev->id - 1;
879 int i;
875 int ret = 0; 880 int ret = 0;
876 881
877 if (!pdata) { 882 if (!pdata) {
@@ -916,14 +921,25 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
916 mcbsp->dma_rx_sync = pdata->dma_rx_sync; 921 mcbsp->dma_rx_sync = pdata->dma_rx_sync;
917 mcbsp->dma_tx_sync = pdata->dma_tx_sync; 922 mcbsp->dma_tx_sync = pdata->dma_tx_sync;
918 923
919 if (pdata->clk_name) 924 if (pdata->num_clks) {
920 mcbsp->clk = clk_get(&pdev->dev, pdata->clk_name); 925 mcbsp->num_clks = pdata->num_clks;
921 if (IS_ERR(mcbsp->clk)) { 926 mcbsp->clks = kzalloc(mcbsp->num_clks * sizeof(struct clk *),
922 dev_err(&pdev->dev, 927 GFP_KERNEL);
923 "Invalid clock configuration for McBSP%d.\n", 928 if (!mcbsp->clks) {
924 mcbsp->id); 929 ret = -ENOMEM;
925 ret = PTR_ERR(mcbsp->clk); 930 goto exit;
926 goto err_clk; 931 }
932 for (i = 0; i < mcbsp->num_clks; i++) {
933 mcbsp->clks[i] = clk_get(&pdev->dev, pdata->clk_names[i]);
934 if (IS_ERR(mcbsp->clks[i])) {
935 dev_err(&pdev->dev,
936 "Invalid %s configuration for McBSP%d.\n",
937 pdata->clk_names[i], mcbsp->id);
938 ret = PTR_ERR(mcbsp->clks[i]);
939 goto err_clk;
940 }
941 }
942
927 } 943 }
928 944
929 mcbsp->pdata = pdata; 945 mcbsp->pdata = pdata;
@@ -932,6 +948,9 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
932 return 0; 948 return 0;
933 949
934err_clk: 950err_clk:
951 while (i--)
952 clk_put(mcbsp->clks[i]);
953 kfree(mcbsp->clks);
935 iounmap(mcbsp->io_base); 954 iounmap(mcbsp->io_base);
936err_ioremap: 955err_ioremap:
937 mcbsp->free = 0; 956 mcbsp->free = 0;
@@ -942,6 +961,7 @@ exit:
942static int __devexit omap_mcbsp_remove(struct platform_device *pdev) 961static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
943{ 962{
944 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); 963 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
964 int i;
945 965
946 platform_set_drvdata(pdev, NULL); 966 platform_set_drvdata(pdev, NULL);
947 if (mcbsp) { 967 if (mcbsp) {
@@ -950,12 +970,18 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
950 mcbsp->pdata->ops->free) 970 mcbsp->pdata->ops->free)
951 mcbsp->pdata->ops->free(mcbsp->id); 971 mcbsp->pdata->ops->free(mcbsp->id);
952 972
953 clk_disable(mcbsp->clk); 973 for (i = mcbsp->num_clks - 1; i >= 0; i--) {
954 clk_put(mcbsp->clk); 974 clk_disable(mcbsp->clks[i]);
975 clk_put(mcbsp->clks[i]);
976 }
955 977
956 iounmap(mcbsp->io_base); 978 iounmap(mcbsp->io_base);
957 979
958 mcbsp->clk = NULL; 980 if (mcbsp->num_clks) {
981 kfree(mcbsp->clks);
982 mcbsp->clks = NULL;
983 mcbsp->num_clks = 0;
984 }
959 mcbsp->free = 0; 985 mcbsp->free = 0;
960 mcbsp->dev = NULL; 986 mcbsp->dev = NULL;
961 } 987 }
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index 967186425ca1..0d12c2164766 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -265,51 +265,36 @@ EXPORT_SYMBOL(orion_gpio_set_blink);
265 * polarity LEVEL mask 265 * polarity LEVEL mask
266 * 266 *
267 ****************************************************************************/ 267 ****************************************************************************/
268static void gpio_irq_edge_ack(u32 irq)
269{
270 int pin = irq_to_gpio(irq);
271
272 writel(~(1 << (pin & 31)), GPIO_EDGE_CAUSE(pin));
273}
274
275static void gpio_irq_edge_mask(u32 irq)
276{
277 int pin = irq_to_gpio(irq);
278 u32 u;
279
280 u = readl(GPIO_EDGE_MASK(pin));
281 u &= ~(1 << (pin & 31));
282 writel(u, GPIO_EDGE_MASK(pin));
283}
284 268
285static void gpio_irq_edge_unmask(u32 irq) 269static void gpio_irq_ack(u32 irq)
286{ 270{
287 int pin = irq_to_gpio(irq); 271 int type = irq_desc[irq].status & IRQ_TYPE_SENSE_MASK;
288 u32 u; 272 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
289 273 int pin = irq_to_gpio(irq);
290 u = readl(GPIO_EDGE_MASK(pin)); 274 writel(~(1 << (pin & 31)), GPIO_EDGE_CAUSE(pin));
291 u |= 1 << (pin & 31); 275 }
292 writel(u, GPIO_EDGE_MASK(pin));
293} 276}
294 277
295static void gpio_irq_level_mask(u32 irq) 278static void gpio_irq_mask(u32 irq)
296{ 279{
297 int pin = irq_to_gpio(irq); 280 int pin = irq_to_gpio(irq);
298 u32 u; 281 int type = irq_desc[irq].status & IRQ_TYPE_SENSE_MASK;
299 282 u32 reg = (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) ?
300 u = readl(GPIO_LEVEL_MASK(pin)); 283 GPIO_EDGE_MASK(pin) : GPIO_LEVEL_MASK(pin);
284 u32 u = readl(reg);
301 u &= ~(1 << (pin & 31)); 285 u &= ~(1 << (pin & 31));
302 writel(u, GPIO_LEVEL_MASK(pin)); 286 writel(u, reg);
303} 287}
304 288
305static void gpio_irq_level_unmask(u32 irq) 289static void gpio_irq_unmask(u32 irq)
306{ 290{
307 int pin = irq_to_gpio(irq); 291 int pin = irq_to_gpio(irq);
308 u32 u; 292 int type = irq_desc[irq].status & IRQ_TYPE_SENSE_MASK;
309 293 u32 reg = (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) ?
310 u = readl(GPIO_LEVEL_MASK(pin)); 294 GPIO_EDGE_MASK(pin) : GPIO_LEVEL_MASK(pin);
295 u32 u = readl(reg);
311 u |= 1 << (pin & 31); 296 u |= 1 << (pin & 31);
312 writel(u, GPIO_LEVEL_MASK(pin)); 297 writel(u, reg);
313} 298}
314 299
315static int gpio_irq_set_type(u32 irq, u32 type) 300static int gpio_irq_set_type(u32 irq, u32 type)
@@ -331,9 +316,9 @@ static int gpio_irq_set_type(u32 irq, u32 type)
331 * Set edge/level type. 316 * Set edge/level type.
332 */ 317 */
333 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { 318 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
334 desc->chip = &orion_gpio_irq_edge_chip; 319 desc->handle_irq = handle_edge_irq;
335 } else if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) { 320 } else if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
336 desc->chip = &orion_gpio_irq_level_chip; 321 desc->handle_irq = handle_level_irq;
337 } else { 322 } else {
338 printk(KERN_ERR "failed to set irq=%d (type=%d)\n", irq, type); 323 printk(KERN_ERR "failed to set irq=%d (type=%d)\n", irq, type);
339 return -EINVAL; 324 return -EINVAL;
@@ -371,19 +356,11 @@ static int gpio_irq_set_type(u32 irq, u32 type)
371 return 0; 356 return 0;
372} 357}
373 358
374struct irq_chip orion_gpio_irq_edge_chip = { 359struct irq_chip orion_gpio_irq_chip = {
375 .name = "orion_gpio_irq_edge", 360 .name = "orion_gpio",
376 .ack = gpio_irq_edge_ack, 361 .ack = gpio_irq_ack,
377 .mask = gpio_irq_edge_mask, 362 .mask = gpio_irq_mask,
378 .unmask = gpio_irq_edge_unmask, 363 .unmask = gpio_irq_unmask,
379 .set_type = gpio_irq_set_type,
380};
381
382struct irq_chip orion_gpio_irq_level_chip = {
383 .name = "orion_gpio_irq_level",
384 .mask = gpio_irq_level_mask,
385 .mask_ack = gpio_irq_level_mask,
386 .unmask = gpio_irq_level_unmask,
387 .set_type = gpio_irq_set_type, 364 .set_type = gpio_irq_set_type,
388}; 365};
389 366
diff --git a/arch/arm/plat-orion/include/plat/gpio.h b/arch/arm/plat-orion/include/plat/gpio.h
index 54deaf274b52..ec743e82c876 100644
--- a/arch/arm/plat-orion/include/plat/gpio.h
+++ b/arch/arm/plat-orion/include/plat/gpio.h
@@ -31,8 +31,7 @@ void orion_gpio_set_blink(unsigned pin, int blink);
31/* 31/*
32 * GPIO interrupt handling. 32 * GPIO interrupt handling.
33 */ 33 */
34extern struct irq_chip orion_gpio_irq_edge_chip; 34extern struct irq_chip orion_gpio_irq_chip;
35extern struct irq_chip orion_gpio_irq_level_chip;
36void orion_gpio_irq_handler(int irqoff); 35void orion_gpio_irq_handler(int irqoff);
37 36
38 37
diff --git a/arch/avr32/mach-at32ap/include/mach/board.h b/arch/avr32/mach-at32ap/include/mach/board.h
index aafaf7a78886..cff8e84f78f2 100644
--- a/arch/avr32/mach-at32ap/include/mach/board.h
+++ b/arch/avr32/mach-at32ap/include/mach/board.h
@@ -116,6 +116,7 @@ struct atmel_nand_data {
116 int enable_pin; /* chip enable */ 116 int enable_pin; /* chip enable */
117 int det_pin; /* card detect */ 117 int det_pin; /* card detect */
118 int rdy_pin; /* ready/busy */ 118 int rdy_pin; /* ready/busy */
119 u8 rdy_pin_active_low; /* rdy_pin value is inverted */
119 u8 ale; /* address line number connected to ALE */ 120 u8 ale; /* address line number connected to ALE */
120 u8 cle; /* address line number connected to CLE */ 121 u8 cle; /* address line number connected to CLE */
121 u8 bus_width_16; /* buswidth is 16 bit */ 122 u8 bus_width_16; /* buswidth is 16 bit */
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index a949c4fbbddd..8f1f97d56e1e 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -169,26 +169,51 @@ config BF542
169 help 169 help
170 BF542 Processor Support. 170 BF542 Processor Support.
171 171
172config BF542M
173 bool "BF542m"
174 help
175 BF542 Processor Support.
176
172config BF544 177config BF544
173 bool "BF544" 178 bool "BF544"
174 help 179 help
175 BF544 Processor Support. 180 BF544 Processor Support.
176 181
182config BF544M
183 bool "BF544m"
184 help
185 BF544 Processor Support.
186
177config BF547 187config BF547
178 bool "BF547" 188 bool "BF547"
179 help 189 help
180 BF547 Processor Support. 190 BF547 Processor Support.
181 191
192config BF547M
193 bool "BF547m"
194 help
195 BF547 Processor Support.
196
182config BF548 197config BF548
183 bool "BF548" 198 bool "BF548"
184 help 199 help
185 BF548 Processor Support. 200 BF548 Processor Support.
186 201
202config BF548M
203 bool "BF548m"
204 help
205 BF548 Processor Support.
206
187config BF549 207config BF549
188 bool "BF549" 208 bool "BF549"
189 help 209 help
190 BF549 Processor Support. 210 BF549 Processor Support.
191 211
212config BF549M
213 bool "BF549m"
214 help
215 BF549 Processor Support.
216
192config BF561 217config BF561
193 bool "BF561" 218 bool "BF561"
194 help 219 help
@@ -224,39 +249,39 @@ config TICK_SOURCE_SYSTMR0
224 249
225config BF_REV_MIN 250config BF_REV_MIN
226 int 251 int
227 default 0 if (BF51x || BF52x || BF54x) 252 default 0 if (BF51x || BF52x || (BF54x && !BF54xM))
228 default 2 if (BF537 || BF536 || BF534) 253 default 2 if (BF537 || BF536 || BF534)
229 default 3 if (BF561 ||BF533 || BF532 || BF531) 254 default 3 if (BF561 || BF533 || BF532 || BF531 || BF54xM)
230 default 4 if (BF538 || BF539) 255 default 4 if (BF538 || BF539)
231 256
232config BF_REV_MAX 257config BF_REV_MAX
233 int 258 int
234 default 2 if (BF51x || BF52x || BF54x) 259 default 2 if (BF51x || BF52x || (BF54x && !BF54xM))
235 default 3 if (BF537 || BF536 || BF534) 260 default 3 if (BF537 || BF536 || BF534 || BF54xM)
236 default 5 if (BF561 || BF538 || BF539) 261 default 5 if (BF561 || BF538 || BF539)
237 default 6 if (BF533 || BF532 || BF531) 262 default 6 if (BF533 || BF532 || BF531)
238 263
239choice 264choice
240 prompt "Silicon Rev" 265 prompt "Silicon Rev"
241 default BF_REV_0_1 if (BF51x || BF52x || BF54x) 266 default BF_REV_0_1 if (BF51x || BF52x || (BF54x && !BF54xM))
242 default BF_REV_0_2 if (BF534 || BF536 || BF537) 267 default BF_REV_0_2 if (BF534 || BF536 || BF537)
243 default BF_REV_0_3 if (BF531 || BF532 || BF533 || BF561) 268 default BF_REV_0_3 if (BF531 || BF532 || BF533 || BF54xM || BF561)
244 269
245config BF_REV_0_0 270config BF_REV_0_0
246 bool "0.0" 271 bool "0.0"
247 depends on (BF51x || BF52x || BF54x) 272 depends on (BF51x || BF52x || (BF54x && !BF54xM))
248 273
249config BF_REV_0_1 274config BF_REV_0_1
250 bool "0.1" 275 bool "0.1"
251 depends on (BF52x || BF54x) 276 depends on (BF52x || (BF54x && !BF54xM))
252 277
253config BF_REV_0_2 278config BF_REV_0_2
254 bool "0.2" 279 bool "0.2"
255 depends on (BF52x || BF537 || BF536 || BF534 || BF54x) 280 depends on (BF52x || BF537 || BF536 || BF534 || (BF54x && !BF54xM))
256 281
257config BF_REV_0_3 282config BF_REV_0_3
258 bool "0.3" 283 bool "0.3"
259 depends on (BF561 || BF537 || BF536 || BF534 || BF533 || BF532 || BF531) 284 depends on (BF54xM || BF561 || BF537 || BF536 || BF534 || BF533 || BF532 || BF531)
260 285
261config BF_REV_0_4 286config BF_REV_0_4
262 bool "0.4" 287 bool "0.4"
@@ -293,9 +318,14 @@ config BF53x
293 depends on (BF531 || BF532 || BF533 || BF534 || BF536 || BF537) 318 depends on (BF531 || BF532 || BF533 || BF534 || BF536 || BF537)
294 default y 319 default y
295 320
321config BF54xM
322 bool
323 depends on (BF542M || BF544M || BF547M || BF548M || BF549M)
324 default y
325
296config BF54x 326config BF54x
297 bool 327 bool
298 depends on (BF542 || BF544 || BF547 || BF548 || BF549) 328 depends on (BF542 || BF544 || BF547 || BF548 || BF549 || BF54xM)
299 default y 329 default y
300 330
301config MEM_GENERIC_BOARD 331config MEM_GENERIC_BOARD
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index e550c8d46066..d54c8283825c 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -21,57 +21,67 @@ KALLSYMS += --symbol-prefix=_
21KBUILD_DEFCONFIG := BF537-STAMP_defconfig 21KBUILD_DEFCONFIG := BF537-STAMP_defconfig
22 22
23# setup the machine name and the machine dependent settings 23# setup the machine name and the machine dependent settings
24machine-$(CONFIG_BF512) := bf518 24machine-$(CONFIG_BF512) := bf518
25machine-$(CONFIG_BF514) := bf518 25machine-$(CONFIG_BF514) := bf518
26machine-$(CONFIG_BF516) := bf518 26machine-$(CONFIG_BF516) := bf518
27machine-$(CONFIG_BF518) := bf518 27machine-$(CONFIG_BF518) := bf518
28machine-$(CONFIG_BF522) := bf527 28machine-$(CONFIG_BF522) := bf527
29machine-$(CONFIG_BF523) := bf527 29machine-$(CONFIG_BF523) := bf527
30machine-$(CONFIG_BF524) := bf527 30machine-$(CONFIG_BF524) := bf527
31machine-$(CONFIG_BF525) := bf527 31machine-$(CONFIG_BF525) := bf527
32machine-$(CONFIG_BF526) := bf527 32machine-$(CONFIG_BF526) := bf527
33machine-$(CONFIG_BF527) := bf527 33machine-$(CONFIG_BF527) := bf527
34machine-$(CONFIG_BF531) := bf533 34machine-$(CONFIG_BF531) := bf533
35machine-$(CONFIG_BF532) := bf533 35machine-$(CONFIG_BF532) := bf533
36machine-$(CONFIG_BF533) := bf533 36machine-$(CONFIG_BF533) := bf533
37machine-$(CONFIG_BF534) := bf537 37machine-$(CONFIG_BF534) := bf537
38machine-$(CONFIG_BF536) := bf537 38machine-$(CONFIG_BF536) := bf537
39machine-$(CONFIG_BF537) := bf537 39machine-$(CONFIG_BF537) := bf537
40machine-$(CONFIG_BF538) := bf538 40machine-$(CONFIG_BF538) := bf538
41machine-$(CONFIG_BF539) := bf538 41machine-$(CONFIG_BF539) := bf538
42machine-$(CONFIG_BF542) := bf548 42machine-$(CONFIG_BF542) := bf548
43machine-$(CONFIG_BF544) := bf548 43machine-$(CONFIG_BF542M) := bf548
44machine-$(CONFIG_BF547) := bf548 44machine-$(CONFIG_BF544) := bf548
45machine-$(CONFIG_BF548) := bf548 45machine-$(CONFIG_BF544M) := bf548
46machine-$(CONFIG_BF549) := bf548 46machine-$(CONFIG_BF547) := bf548
47machine-$(CONFIG_BF561) := bf561 47machine-$(CONFIG_BF547M) := bf548
48machine-$(CONFIG_BF548) := bf548
49machine-$(CONFIG_BF548M) := bf548
50machine-$(CONFIG_BF549) := bf548
51machine-$(CONFIG_BF549M) := bf548
52machine-$(CONFIG_BF561) := bf561
48MACHINE := $(machine-y) 53MACHINE := $(machine-y)
49export MACHINE 54export MACHINE
50 55
51cpu-$(CONFIG_BF512) := bf512 56cpu-$(CONFIG_BF512) := bf512
52cpu-$(CONFIG_BF514) := bf514 57cpu-$(CONFIG_BF514) := bf514
53cpu-$(CONFIG_BF516) := bf516 58cpu-$(CONFIG_BF516) := bf516
54cpu-$(CONFIG_BF518) := bf518 59cpu-$(CONFIG_BF518) := bf518
55cpu-$(CONFIG_BF522) := bf522 60cpu-$(CONFIG_BF522) := bf522
56cpu-$(CONFIG_BF523) := bf523 61cpu-$(CONFIG_BF523) := bf523
57cpu-$(CONFIG_BF524) := bf524 62cpu-$(CONFIG_BF524) := bf524
58cpu-$(CONFIG_BF525) := bf525 63cpu-$(CONFIG_BF525) := bf525
59cpu-$(CONFIG_BF526) := bf526 64cpu-$(CONFIG_BF526) := bf526
60cpu-$(CONFIG_BF527) := bf527 65cpu-$(CONFIG_BF527) := bf527
61cpu-$(CONFIG_BF531) := bf531 66cpu-$(CONFIG_BF531) := bf531
62cpu-$(CONFIG_BF532) := bf532 67cpu-$(CONFIG_BF532) := bf532
63cpu-$(CONFIG_BF533) := bf533 68cpu-$(CONFIG_BF533) := bf533
64cpu-$(CONFIG_BF534) := bf534 69cpu-$(CONFIG_BF534) := bf534
65cpu-$(CONFIG_BF536) := bf536 70cpu-$(CONFIG_BF536) := bf536
66cpu-$(CONFIG_BF537) := bf537 71cpu-$(CONFIG_BF537) := bf537
67cpu-$(CONFIG_BF538) := bf538 72cpu-$(CONFIG_BF538) := bf538
68cpu-$(CONFIG_BF539) := bf539 73cpu-$(CONFIG_BF539) := bf539
69cpu-$(CONFIG_BF542) := bf542 74cpu-$(CONFIG_BF542) := bf542
70cpu-$(CONFIG_BF544) := bf544 75cpu-$(CONFIG_BF542M) := bf542m
71cpu-$(CONFIG_BF547) := bf547 76cpu-$(CONFIG_BF544) := bf544
72cpu-$(CONFIG_BF548) := bf548 77cpu-$(CONFIG_BF544M) := bf544m
73cpu-$(CONFIG_BF549) := bf549 78cpu-$(CONFIG_BF547) := bf547
74cpu-$(CONFIG_BF561) := bf561 79cpu-$(CONFIG_BF547M) := bf547m
80cpu-$(CONFIG_BF548) := bf548
81cpu-$(CONFIG_BF548M) := bf548m
82cpu-$(CONFIG_BF549) := bf549
83cpu-$(CONFIG_BF549M) := bf549m
84cpu-$(CONFIG_BF561) := bf561
75 85
76rev-$(CONFIG_BF_REV_0_0) := 0.0 86rev-$(CONFIG_BF_REV_0_0) := 0.0
77rev-$(CONFIG_BF_REV_0_1) := 0.1 87rev-$(CONFIG_BF_REV_0_1) := 0.1
diff --git a/arch/blackfin/configs/BF518F-EZBRD_defconfig b/arch/blackfin/configs/BF518F-EZBRD_defconfig
index defb9785c65b..4fdb9e04759f 100644
--- a/arch/blackfin/configs/BF518F-EZBRD_defconfig
+++ b/arch/blackfin/configs/BF518F-EZBRD_defconfig
@@ -1,6 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.28-rc2 3# Linux kernel version: 2.6.28-rc2
4# Fri Jan 9 17:58:41 2009
4# 5#
5# CONFIG_MMU is not set 6# CONFIG_MMU is not set
6# CONFIG_FPU is not set 7# CONFIG_FPU is not set
@@ -149,6 +150,7 @@ CONFIG_BF_REV_0_0=y
149# CONFIG_BF_REV_ANY is not set 150# CONFIG_BF_REV_ANY is not set
150# CONFIG_BF_REV_NONE is not set 151# CONFIG_BF_REV_NONE is not set
151CONFIG_BF51x=y 152CONFIG_BF51x=y
153CONFIG_MEM_MT48LC32M8A2_75=y
152CONFIG_BFIN518F_EZBRD=y 154CONFIG_BFIN518F_EZBRD=y
153 155
154# 156#
@@ -598,7 +600,10 @@ CONFIG_PHYLIB=y
598# CONFIG_MDIO_BITBANG is not set 600# CONFIG_MDIO_BITBANG is not set
599CONFIG_NET_ETHERNET=y 601CONFIG_NET_ETHERNET=y
600CONFIG_MII=y 602CONFIG_MII=y
601# CONFIG_BFIN_MAC is not set 603CONFIG_BFIN_MAC=y
604CONFIG_BFIN_TX_DESC_NUM=10
605CONFIG_BFIN_RX_DESC_NUM=20
606# CONFIG_BFIN_MAC_RMII is not set
602# CONFIG_SMC91X is not set 607# CONFIG_SMC91X is not set
603# CONFIG_SMSC911X is not set 608# CONFIG_SMSC911X is not set
604# CONFIG_DM9000 is not set 609# CONFIG_DM9000 is not set
@@ -679,7 +684,7 @@ CONFIG_VT_CONSOLE=y
679CONFIG_HW_CONSOLE=y 684CONFIG_HW_CONSOLE=y
680# CONFIG_VT_HW_CONSOLE_BINDING is not set 685# CONFIG_VT_HW_CONSOLE_BINDING is not set
681# CONFIG_DEVKMEM is not set 686# CONFIG_DEVKMEM is not set
682# CONFIG_BFIN_JTAG_COMM is not set 687CONFIG_BFIN_JTAG_COMM=m
683# CONFIG_SERIAL_NONSTANDARD is not set 688# CONFIG_SERIAL_NONSTANDARD is not set
684 689
685# 690#
diff --git a/arch/blackfin/configs/BF526-EZBRD_defconfig b/arch/blackfin/configs/BF526-EZBRD_defconfig
index 992424ff3153..8e2b855b8db7 100644
--- a/arch/blackfin/configs/BF526-EZBRD_defconfig
+++ b/arch/blackfin/configs/BF526-EZBRD_defconfig
@@ -723,7 +723,7 @@ CONFIG_VT_CONSOLE=y
723CONFIG_HW_CONSOLE=y 723CONFIG_HW_CONSOLE=y
724# CONFIG_VT_HW_CONSOLE_BINDING is not set 724# CONFIG_VT_HW_CONSOLE_BINDING is not set
725# CONFIG_DEVKMEM is not set 725# CONFIG_DEVKMEM is not set
726# CONFIG_BFIN_JTAG_COMM is not set 726CONFIG_BFIN_JTAG_COMM=m
727# CONFIG_SERIAL_NONSTANDARD is not set 727# CONFIG_SERIAL_NONSTANDARD is not set
728 728
729# 729#
diff --git a/arch/blackfin/configs/BF527-EZKIT_defconfig b/arch/blackfin/configs/BF527-EZKIT_defconfig
index 21e3c1af55ba..833128b39724 100644
--- a/arch/blackfin/configs/BF527-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF527-EZKIT_defconfig
@@ -767,7 +767,7 @@ CONFIG_VT_CONSOLE=y
767CONFIG_HW_CONSOLE=y 767CONFIG_HW_CONSOLE=y
768# CONFIG_VT_HW_CONSOLE_BINDING is not set 768# CONFIG_VT_HW_CONSOLE_BINDING is not set
769# CONFIG_DEVKMEM is not set 769# CONFIG_DEVKMEM is not set
770# CONFIG_BFIN_JTAG_COMM is not set 770CONFIG_BFIN_JTAG_COMM=m
771# CONFIG_SERIAL_NONSTANDARD is not set 771# CONFIG_SERIAL_NONSTANDARD is not set
772 772
773# 773#
diff --git a/arch/blackfin/configs/BF533-EZKIT_defconfig b/arch/blackfin/configs/BF533-EZKIT_defconfig
index 0bdf20a1af61..334c94b51c40 100644
--- a/arch/blackfin/configs/BF533-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF533-EZKIT_defconfig
@@ -672,7 +672,7 @@ CONFIG_BFIN_DMA_INTERFACE=m
672CONFIG_SIMPLE_GPIO=m 672CONFIG_SIMPLE_GPIO=m
673# CONFIG_VT is not set 673# CONFIG_VT is not set
674# CONFIG_DEVKMEM is not set 674# CONFIG_DEVKMEM is not set
675# CONFIG_BFIN_JTAG_COMM is not set 675CONFIG_BFIN_JTAG_COMM=m
676# CONFIG_SERIAL_NONSTANDARD is not set 676# CONFIG_SERIAL_NONSTANDARD is not set
677 677
678# 678#
diff --git a/arch/blackfin/configs/BF533-STAMP_defconfig b/arch/blackfin/configs/BF533-STAMP_defconfig
index 2f747d6e97e2..9d733436e300 100644
--- a/arch/blackfin/configs/BF533-STAMP_defconfig
+++ b/arch/blackfin/configs/BF533-STAMP_defconfig
@@ -679,7 +679,7 @@ CONFIG_BFIN_DMA_INTERFACE=m
679CONFIG_SIMPLE_GPIO=m 679CONFIG_SIMPLE_GPIO=m
680# CONFIG_VT is not set 680# CONFIG_VT is not set
681# CONFIG_DEVKMEM is not set 681# CONFIG_DEVKMEM is not set
682# CONFIG_BFIN_JTAG_COMM is not set 682CONFIG_BFIN_JTAG_COMM=m
683# CONFIG_SERIAL_NONSTANDARD is not set 683# CONFIG_SERIAL_NONSTANDARD is not set
684 684
685# 685#
diff --git a/arch/blackfin/configs/BF537-STAMP_defconfig b/arch/blackfin/configs/BF537-STAMP_defconfig
index 8b0a81294e65..4fb4108d3103 100644
--- a/arch/blackfin/configs/BF537-STAMP_defconfig
+++ b/arch/blackfin/configs/BF537-STAMP_defconfig
@@ -722,7 +722,7 @@ CONFIG_BFIN_DMA_INTERFACE=m
722CONFIG_SIMPLE_GPIO=m 722CONFIG_SIMPLE_GPIO=m
723# CONFIG_VT is not set 723# CONFIG_VT is not set
724# CONFIG_DEVKMEM is not set 724# CONFIG_DEVKMEM is not set
725# CONFIG_BFIN_JTAG_COMM is not set 725CONFIG_BFIN_JTAG_COMM=m
726# CONFIG_SERIAL_NONSTANDARD is not set 726# CONFIG_SERIAL_NONSTANDARD is not set
727 727
728# 728#
diff --git a/arch/blackfin/configs/BF538-EZKIT_defconfig b/arch/blackfin/configs/BF538-EZKIT_defconfig
index a1f766bf7d9b..cb32f5624a1b 100644
--- a/arch/blackfin/configs/BF538-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF538-EZKIT_defconfig
@@ -726,7 +726,7 @@ CONFIG_BFIN_DMA_INTERFACE=m
726CONFIG_SIMPLE_GPIO=m 726CONFIG_SIMPLE_GPIO=m
727# CONFIG_VT is not set 727# CONFIG_VT is not set
728# CONFIG_DEVKMEM is not set 728# CONFIG_DEVKMEM is not set
729# CONFIG_BFIN_JTAG_COMM is not set 729CONFIG_BFIN_JTAG_COMM=m
730# CONFIG_SERIAL_NONSTANDARD is not set 730# CONFIG_SERIAL_NONSTANDARD is not set
731 731
732# 732#
diff --git a/arch/blackfin/configs/BF548-EZKIT_defconfig b/arch/blackfin/configs/BF548-EZKIT_defconfig
index cd2da6b7692c..0f8697618aa5 100644
--- a/arch/blackfin/configs/BF548-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF548-EZKIT_defconfig
@@ -856,7 +856,7 @@ CONFIG_VT_CONSOLE=y
856CONFIG_HW_CONSOLE=y 856CONFIG_HW_CONSOLE=y
857# CONFIG_VT_HW_CONSOLE_BINDING is not set 857# CONFIG_VT_HW_CONSOLE_BINDING is not set
858# CONFIG_DEVKMEM is not set 858# CONFIG_DEVKMEM is not set
859# CONFIG_BFIN_JTAG_COMM is not set 859CONFIG_BFIN_JTAG_COMM=m
860# CONFIG_SERIAL_NONSTANDARD is not set 860# CONFIG_SERIAL_NONSTANDARD is not set
861 861
862# 862#
diff --git a/arch/blackfin/configs/BF561-EZKIT_defconfig b/arch/blackfin/configs/BF561-EZKIT_defconfig
index b398ca202dbd..042c7adfccfa 100644
--- a/arch/blackfin/configs/BF561-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF561-EZKIT_defconfig
@@ -709,7 +709,7 @@ CONFIG_BFIN_DMA_INTERFACE=m
709CONFIG_SIMPLE_GPIO=m 709CONFIG_SIMPLE_GPIO=m
710# CONFIG_VT is not set 710# CONFIG_VT is not set
711# CONFIG_DEVKMEM is not set 711# CONFIG_DEVKMEM is not set
712# CONFIG_BFIN_JTAG_COMM is not set 712CONFIG_BFIN_JTAG_COMM=m
713# CONFIG_SERIAL_NONSTANDARD is not set 713# CONFIG_SERIAL_NONSTANDARD is not set
714 714
715# 715#
diff --git a/arch/blackfin/configs/CM-BF527_defconfig b/arch/blackfin/configs/CM-BF527_defconfig
index 95146948166f..865ed85a5760 100644
--- a/arch/blackfin/configs/CM-BF527_defconfig
+++ b/arch/blackfin/configs/CM-BF527_defconfig
@@ -1,7 +1,6 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.24.7 3# Linux kernel version: 2.6.28
4# Fri Jul 18 18:00:41 2008
5# 4#
6# CONFIG_MMU is not set 5# CONFIG_MMU is not set
7# CONFIG_FPU is not set 6# CONFIG_FPU is not set
@@ -9,7 +8,6 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
9# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set 8# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
10CONFIG_BLACKFIN=y 9CONFIG_BLACKFIN=y
11CONFIG_ZONE_DMA=y 10CONFIG_ZONE_DMA=y
12CONFIG_SEMAPHORE_SLEEPERS=y
13CONFIG_GENERIC_FIND_NEXT_BIT=y 11CONFIG_GENERIC_FIND_NEXT_BIT=y
14CONFIG_GENERIC_HWEIGHT=y 12CONFIG_GENERIC_HWEIGHT=y
15CONFIG_GENERIC_HARDIRQS=y 13CONFIG_GENERIC_HARDIRQS=y
@@ -32,18 +30,16 @@ CONFIG_SYSVIPC_SYSCTL=y
32# CONFIG_POSIX_MQUEUE is not set 30# CONFIG_POSIX_MQUEUE is not set
33# CONFIG_BSD_PROCESS_ACCT is not set 31# CONFIG_BSD_PROCESS_ACCT is not set
34# CONFIG_TASKSTATS is not set 32# CONFIG_TASKSTATS is not set
35# CONFIG_USER_NS is not set
36# CONFIG_PID_NS is not set
37# CONFIG_AUDIT is not set 33# CONFIG_AUDIT is not set
38CONFIG_IKCONFIG=y 34CONFIG_IKCONFIG=y
39CONFIG_IKCONFIG_PROC=y 35CONFIG_IKCONFIG_PROC=y
40CONFIG_LOG_BUF_SHIFT=14 36CONFIG_LOG_BUF_SHIFT=14
41# CONFIG_CGROUPS is not set 37# CONFIG_CGROUPS is not set
42CONFIG_FAIR_GROUP_SCHED=y 38# CONFIG_GROUP_SCHED is not set
43CONFIG_FAIR_USER_SCHED=y 39CONFIG_SYSFS_DEPRECATED=y
44# CONFIG_FAIR_CGROUP_SCHED is not set 40CONFIG_SYSFS_DEPRECATED_V2=y
45# CONFIG_SYSFS_DEPRECATED is not set
46# CONFIG_RELAY is not set 41# CONFIG_RELAY is not set
42# CONFIG_NAMESPACES is not set
47CONFIG_BLK_DEV_INITRD=y 43CONFIG_BLK_DEV_INITRD=y
48CONFIG_INITRAMFS_SOURCE="" 44CONFIG_INITRAMFS_SOURCE=""
49# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 45# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -52,26 +48,35 @@ CONFIG_EMBEDDED=y
52CONFIG_UID16=y 48CONFIG_UID16=y
53CONFIG_SYSCTL_SYSCALL=y 49CONFIG_SYSCTL_SYSCALL=y
54CONFIG_KALLSYMS=y 50CONFIG_KALLSYMS=y
51# CONFIG_KALLSYMS_ALL is not set
55# CONFIG_KALLSYMS_EXTRA_PASS is not set 52# CONFIG_KALLSYMS_EXTRA_PASS is not set
56CONFIG_HOTPLUG=y 53CONFIG_HOTPLUG=y
57CONFIG_PRINTK=y 54CONFIG_PRINTK=y
58CONFIG_BUG=y 55CONFIG_BUG=y
59# CONFIG_ELF_CORE is not set 56# CONFIG_ELF_CORE is not set
57CONFIG_COMPAT_BRK=y
60CONFIG_BASE_FULL=y 58CONFIG_BASE_FULL=y
61CONFIG_FUTEX=y 59CONFIG_FUTEX=y
62CONFIG_ANON_INODES=y 60CONFIG_ANON_INODES=y
63CONFIG_EPOLL=y 61CONFIG_EPOLL=y
64CONFIG_SIGNALFD=y 62CONFIG_SIGNALFD=y
63CONFIG_TIMERFD=y
65CONFIG_EVENTFD=y 64CONFIG_EVENTFD=y
65CONFIG_AIO=y
66CONFIG_VM_EVENT_COUNTERS=y 66CONFIG_VM_EVENT_COUNTERS=y
67CONFIG_SLAB=y 67CONFIG_SLAB=y
68# CONFIG_SLUB is not set 68# CONFIG_SLUB is not set
69# CONFIG_SLOB is not set 69# CONFIG_SLOB is not set
70# CONFIG_PROFILING is not set
71# CONFIG_MARKERS is not set
72CONFIG_HAVE_OPROFILE=y
73# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
70CONFIG_SLABINFO=y 74CONFIG_SLABINFO=y
71CONFIG_RT_MUTEXES=y 75CONFIG_RT_MUTEXES=y
72CONFIG_TINY_SHMEM=y 76CONFIG_TINY_SHMEM=y
73CONFIG_BASE_SMALL=0 77CONFIG_BASE_SMALL=0
74CONFIG_MODULES=y 78CONFIG_MODULES=y
79# CONFIG_MODULE_FORCE_LOAD is not set
75CONFIG_MODULE_UNLOAD=y 80CONFIG_MODULE_UNLOAD=y
76# CONFIG_MODULE_FORCE_UNLOAD is not set 81# CONFIG_MODULE_FORCE_UNLOAD is not set
77# CONFIG_MODVERSIONS is not set 82# CONFIG_MODVERSIONS is not set
@@ -82,6 +87,7 @@ CONFIG_BLOCK=y
82# CONFIG_BLK_DEV_IO_TRACE is not set 87# CONFIG_BLK_DEV_IO_TRACE is not set
83# CONFIG_LSF is not set 88# CONFIG_LSF is not set
84# CONFIG_BLK_DEV_BSG is not set 89# CONFIG_BLK_DEV_BSG is not set
90# CONFIG_BLK_DEV_INTEGRITY is not set
85 91
86# 92#
87# IO Schedulers 93# IO Schedulers
@@ -95,9 +101,11 @@ CONFIG_IOSCHED_CFQ=y
95CONFIG_DEFAULT_CFQ=y 101CONFIG_DEFAULT_CFQ=y
96# CONFIG_DEFAULT_NOOP is not set 102# CONFIG_DEFAULT_NOOP is not set
97CONFIG_DEFAULT_IOSCHED="cfq" 103CONFIG_DEFAULT_IOSCHED="cfq"
104CONFIG_CLASSIC_RCU=y
98# CONFIG_PREEMPT_NONE is not set 105# CONFIG_PREEMPT_NONE is not set
99CONFIG_PREEMPT_VOLUNTARY=y 106CONFIG_PREEMPT_VOLUNTARY=y
100# CONFIG_PREEMPT is not set 107# CONFIG_PREEMPT is not set
108# CONFIG_FREEZER is not set
101 109
102# 110#
103# Blackfin Processor Options 111# Blackfin Processor Options
@@ -106,6 +114,10 @@ CONFIG_PREEMPT_VOLUNTARY=y
106# 114#
107# Processor and Board Settings 115# Processor and Board Settings
108# 116#
117# CONFIG_BF512 is not set
118# CONFIG_BF514 is not set
119# CONFIG_BF516 is not set
120# CONFIG_BF518 is not set
109# CONFIG_BF522 is not set 121# CONFIG_BF522 is not set
110# CONFIG_BF523 is not set 122# CONFIG_BF523 is not set
111# CONFIG_BF524 is not set 123# CONFIG_BF524 is not set
@@ -118,48 +130,32 @@ CONFIG_BF527=y
118# CONFIG_BF534 is not set 130# CONFIG_BF534 is not set
119# CONFIG_BF536 is not set 131# CONFIG_BF536 is not set
120# CONFIG_BF537 is not set 132# CONFIG_BF537 is not set
133# CONFIG_BF538 is not set
134# CONFIG_BF539 is not set
121# CONFIG_BF542 is not set 135# CONFIG_BF542 is not set
136# CONFIG_BF542M is not set
122# CONFIG_BF544 is not set 137# CONFIG_BF544 is not set
138# CONFIG_BF544M is not set
123# CONFIG_BF547 is not set 139# CONFIG_BF547 is not set
140# CONFIG_BF547M is not set
124# CONFIG_BF548 is not set 141# CONFIG_BF548 is not set
142# CONFIG_BF548M is not set
125# CONFIG_BF549 is not set 143# CONFIG_BF549 is not set
144# CONFIG_BF549M is not set
126# CONFIG_BF561 is not set 145# CONFIG_BF561 is not set
146CONFIG_BF_REV_MIN=0
147CONFIG_BF_REV_MAX=2
127# CONFIG_BF_REV_0_0 is not set 148# CONFIG_BF_REV_0_0 is not set
128CONFIG_BF_REV_0_1=y 149CONFIG_BF_REV_0_1=y
129# CONFIG_BF_REV_0_2 is not set 150# CONFIG_BF_REV_0_2 is not set
130# CONFIG_BF_REV_0_3 is not set 151# CONFIG_BF_REV_0_3 is not set
131# CONFIG_BF_REV_0_4 is not set 152# CONFIG_BF_REV_0_4 is not set
132# CONFIG_BF_REV_0_5 is not set 153# CONFIG_BF_REV_0_5 is not set
154# CONFIG_BF_REV_0_6 is not set
133# CONFIG_BF_REV_ANY is not set 155# CONFIG_BF_REV_ANY is not set
134# CONFIG_BF_REV_NONE is not set 156# CONFIG_BF_REV_NONE is not set
135CONFIG_BF52x=y 157CONFIG_BF52x=y
136CONFIG_MEM_MT48LC16M16A2TG_75=y 158CONFIG_MEM_MT48LC16M16A2TG_75=y
137# CONFIG_BFIN527_EZKIT is not set
138CONFIG_BFIN527_BLUETECHNIX_CM=y
139
140#
141# BF527 Specific Configuration
142#
143
144#
145# Alternative Multiplexing Scheme
146#
147# CONFIG_BF527_SPORT0_PORTF is not set
148CONFIG_BF527_SPORT0_PORTG=y
149CONFIG_BF527_SPORT0_TSCLK_PG10=y
150# CONFIG_BF527_SPORT0_TSCLK_PG14 is not set
151CONFIG_BF527_UART1_PORTF=y
152# CONFIG_BF527_UART1_PORTG is not set
153# CONFIG_BF527_NAND_D_PORTF is not set
154CONFIG_BF527_NAND_D_PORTH=y
155
156#
157# Interrupt Priority Assignment
158#
159
160#
161# Priority
162#
163CONFIG_IRQ_PLL_WAKEUP=7 159CONFIG_IRQ_PLL_WAKEUP=7
164CONFIG_IRQ_DMA0_ERROR=7 160CONFIG_IRQ_DMA0_ERROR=7
165CONFIG_IRQ_DMAR0_BLK=7 161CONFIG_IRQ_DMAR0_BLK=7
@@ -179,7 +175,6 @@ CONFIG_IRQ_SPORT0_TX=9
179CONFIG_IRQ_SPORT1_RX=9 175CONFIG_IRQ_SPORT1_RX=9
180CONFIG_IRQ_SPORT1_TX=9 176CONFIG_IRQ_SPORT1_TX=9
181CONFIG_IRQ_TWI=10 177CONFIG_IRQ_TWI=10
182CONFIG_IRQ_SPI=10
183CONFIG_IRQ_UART0_RX=10 178CONFIG_IRQ_UART0_RX=10
184CONFIG_IRQ_UART0_TX=10 179CONFIG_IRQ_UART0_TX=10
185CONFIG_IRQ_UART1_RX=10 180CONFIG_IRQ_UART1_RX=10
@@ -205,6 +200,34 @@ CONFIG_IRQ_MEM_DMA1=13
205CONFIG_IRQ_WATCH=13 200CONFIG_IRQ_WATCH=13
206CONFIG_IRQ_PORTF_INTA=13 201CONFIG_IRQ_PORTF_INTA=13
207CONFIG_IRQ_PORTF_INTB=13 202CONFIG_IRQ_PORTF_INTB=13
203# CONFIG_BFIN527_EZKIT is not set
204CONFIG_BFIN527_BLUETECHNIX_CM=y
205# CONFIG_BFIN526_EZBRD is not set
206
207#
208# BF527 Specific Configuration
209#
210
211#
212# Alternative Multiplexing Scheme
213#
214# CONFIG_BF527_SPORT0_PORTF is not set
215CONFIG_BF527_SPORT0_PORTG=y
216CONFIG_BF527_SPORT0_TSCLK_PG10=y
217# CONFIG_BF527_SPORT0_TSCLK_PG14 is not set
218CONFIG_BF527_UART1_PORTF=y
219# CONFIG_BF527_UART1_PORTG is not set
220# CONFIG_BF527_NAND_D_PORTF is not set
221CONFIG_BF527_NAND_D_PORTH=y
222
223#
224# Interrupt Priority Assignment
225#
226
227#
228# Priority
229#
230CONFIG_IRQ_SPI=10
208CONFIG_IRQ_SPI_ERROR=7 231CONFIG_IRQ_SPI_ERROR=7
209CONFIG_IRQ_NFC_ERROR=7 232CONFIG_IRQ_NFC_ERROR=7
210CONFIG_IRQ_HDMA_ERROR=7 233CONFIG_IRQ_HDMA_ERROR=7
@@ -226,7 +249,6 @@ CONFIG_BOOT_LOAD=0x1000
226# 249#
227CONFIG_CLKIN_HZ=25000000 250CONFIG_CLKIN_HZ=25000000
228# CONFIG_BFIN_KERNEL_CLOCK is not set 251# CONFIG_BFIN_KERNEL_CLOCK is not set
229CONFIG_MAX_MEM_SIZE=512
230CONFIG_MAX_VCO_HZ=600000000 252CONFIG_MAX_VCO_HZ=600000000
231CONFIG_MIN_VCO_HZ=50000000 253CONFIG_MIN_VCO_HZ=50000000
232CONFIG_MAX_SCLK_HZ=133333333 254CONFIG_MAX_SCLK_HZ=133333333
@@ -240,10 +262,10 @@ CONFIG_HZ_250=y
240# CONFIG_HZ_300 is not set 262# CONFIG_HZ_300 is not set
241# CONFIG_HZ_1000 is not set 263# CONFIG_HZ_1000 is not set
242CONFIG_HZ=250 264CONFIG_HZ=250
265# CONFIG_SCHED_HRTICK is not set
243CONFIG_GENERIC_TIME=y 266CONFIG_GENERIC_TIME=y
244CONFIG_GENERIC_CLOCKEVENTS=y 267CONFIG_GENERIC_CLOCKEVENTS=y
245# CONFIG_CYCLES_CLOCKSOURCE is not set 268# CONFIG_CYCLES_CLOCKSOURCE is not set
246# CONFIG_TICK_ONESHOT is not set
247# CONFIG_NO_HZ is not set 269# CONFIG_NO_HZ is not set
248# CONFIG_HIGH_RES_TIMERS is not set 270# CONFIG_HIGH_RES_TIMERS is not set
249CONFIG_GENERIC_CLOCKEVENTS_BUILD=y 271CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
@@ -277,6 +299,12 @@ CONFIG_ACCESS_OK_L1=y
277CONFIG_CACHELINE_ALIGNED_L1=y 299CONFIG_CACHELINE_ALIGNED_L1=y
278# CONFIG_SYSCALL_TAB_L1 is not set 300# CONFIG_SYSCALL_TAB_L1 is not set
279# CONFIG_CPLB_SWITCH_TAB_L1 is not set 301# CONFIG_CPLB_SWITCH_TAB_L1 is not set
302CONFIG_APP_STACK_L1=y
303
304#
305# Speed Optimizations
306#
307CONFIG_BFIN_INS_LOWOVERHEAD=y
280CONFIG_RAMKERNEL=y 308CONFIG_RAMKERNEL=y
281# CONFIG_ROMKERNEL is not set 309# CONFIG_ROMKERNEL is not set
282CONFIG_SELECT_MEMORY_MODEL=y 310CONFIG_SELECT_MEMORY_MODEL=y
@@ -285,10 +313,10 @@ CONFIG_FLATMEM_MANUAL=y
285# CONFIG_SPARSEMEM_MANUAL is not set 313# CONFIG_SPARSEMEM_MANUAL is not set
286CONFIG_FLATMEM=y 314CONFIG_FLATMEM=y
287CONFIG_FLAT_NODE_MEM_MAP=y 315CONFIG_FLAT_NODE_MEM_MAP=y
288# CONFIG_SPARSEMEM_STATIC is not set 316CONFIG_PAGEFLAGS_EXTENDED=y
289# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
290CONFIG_SPLIT_PTLOCK_CPUS=4 317CONFIG_SPLIT_PTLOCK_CPUS=4
291# CONFIG_RESOURCES_64BIT is not set 318# CONFIG_RESOURCES_64BIT is not set
319# CONFIG_PHYS_ADDR_T_64BIT is not set
292CONFIG_ZONE_DMA_FLAG=1 320CONFIG_ZONE_DMA_FLAG=1
293CONFIG_VIRT_TO_BUS=y 321CONFIG_VIRT_TO_BUS=y
294CONFIG_BFIN_GPTIMERS=y 322CONFIG_BFIN_GPTIMERS=y
@@ -334,7 +362,6 @@ CONFIG_BANK_3=0xFFC0
334# 362#
335# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 363# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
336# 364#
337# CONFIG_PCI is not set
338# CONFIG_ARCH_SUPPORTS_MSI is not set 365# CONFIG_ARCH_SUPPORTS_MSI is not set
339# CONFIG_PCCARD is not set 366# CONFIG_PCCARD is not set
340 367
@@ -345,25 +372,20 @@ CONFIG_BINFMT_ELF_FDPIC=y
345CONFIG_BINFMT_FLAT=y 372CONFIG_BINFMT_FLAT=y
346CONFIG_BINFMT_ZFLAT=y 373CONFIG_BINFMT_ZFLAT=y
347# CONFIG_BINFMT_SHARED_FLAT is not set 374# CONFIG_BINFMT_SHARED_FLAT is not set
375# CONFIG_HAVE_AOUT is not set
348# CONFIG_BINFMT_MISC is not set 376# CONFIG_BINFMT_MISC is not set
349 377
350# 378#
351# Power management options 379# Power management options
352# 380#
353# CONFIG_PM is not set 381# CONFIG_PM is not set
354CONFIG_SUSPEND_UP_POSSIBLE=y 382CONFIG_ARCH_SUSPEND_POSSIBLE=y
355# CONFIG_PM_BFIN_SLEEP_DEEPER is not set
356# CONFIG_PM_BFIN_SLEEP is not set
357# CONFIG_PM_WAKEUP_BY_GPIO is not set 383# CONFIG_PM_WAKEUP_BY_GPIO is not set
358 384
359# 385#
360# CPU Frequency scaling 386# CPU Frequency scaling
361# 387#
362# CONFIG_CPU_FREQ is not set 388# CONFIG_CPU_FREQ is not set
363
364#
365# Networking
366#
367CONFIG_NET=y 389CONFIG_NET=y
368 390
369# 391#
@@ -376,6 +398,7 @@ CONFIG_XFRM=y
376# CONFIG_XFRM_USER is not set 398# CONFIG_XFRM_USER is not set
377# CONFIG_XFRM_SUB_POLICY is not set 399# CONFIG_XFRM_SUB_POLICY is not set
378# CONFIG_XFRM_MIGRATE is not set 400# CONFIG_XFRM_MIGRATE is not set
401# CONFIG_XFRM_STATISTICS is not set
379# CONFIG_NET_KEY is not set 402# CONFIG_NET_KEY is not set
380CONFIG_INET=y 403CONFIG_INET=y
381# CONFIG_IP_MULTICAST is not set 404# CONFIG_IP_MULTICAST is not set
@@ -405,8 +428,6 @@ CONFIG_TCP_CONG_CUBIC=y
405CONFIG_DEFAULT_TCP_CONG="cubic" 428CONFIG_DEFAULT_TCP_CONG="cubic"
406# CONFIG_TCP_MD5SIG is not set 429# CONFIG_TCP_MD5SIG is not set
407# CONFIG_IPV6 is not set 430# CONFIG_IPV6 is not set
408# CONFIG_INET6_XFRM_TUNNEL is not set
409# CONFIG_INET6_TUNNEL is not set
410# CONFIG_NETLABEL is not set 431# CONFIG_NETLABEL is not set
411# CONFIG_NETWORK_SECMARK is not set 432# CONFIG_NETWORK_SECMARK is not set
412# CONFIG_NETFILTER is not set 433# CONFIG_NETFILTER is not set
@@ -415,6 +436,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
415# CONFIG_TIPC is not set 436# CONFIG_TIPC is not set
416# CONFIG_ATM is not set 437# CONFIG_ATM is not set
417# CONFIG_BRIDGE is not set 438# CONFIG_BRIDGE is not set
439# CONFIG_NET_DSA is not set
418# CONFIG_VLAN_8021Q is not set 440# CONFIG_VLAN_8021Q is not set
419# CONFIG_DECNET is not set 441# CONFIG_DECNET is not set
420# CONFIG_LLC2 is not set 442# CONFIG_LLC2 is not set
@@ -431,14 +453,14 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
431# 453#
432# CONFIG_NET_PKTGEN is not set 454# CONFIG_NET_PKTGEN is not set
433# CONFIG_HAMRADIO is not set 455# CONFIG_HAMRADIO is not set
456# CONFIG_CAN is not set
434# CONFIG_IRDA is not set 457# CONFIG_IRDA is not set
435# CONFIG_BT is not set 458# CONFIG_BT is not set
436# CONFIG_AF_RXRPC is not set 459# CONFIG_AF_RXRPC is not set
437 460# CONFIG_PHONET is not set
438# 461CONFIG_WIRELESS=y
439# Wireless
440#
441# CONFIG_CFG80211 is not set 462# CONFIG_CFG80211 is not set
463CONFIG_WIRELESS_OLD_REGULATORY=y
442# CONFIG_WIRELESS_EXT is not set 464# CONFIG_WIRELESS_EXT is not set
443# CONFIG_MAC80211 is not set 465# CONFIG_MAC80211 is not set
444# CONFIG_IEEE80211 is not set 466# CONFIG_IEEE80211 is not set
@@ -456,6 +478,8 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
456CONFIG_STANDALONE=y 478CONFIG_STANDALONE=y
457CONFIG_PREVENT_FIRMWARE_BUILD=y 479CONFIG_PREVENT_FIRMWARE_BUILD=y
458# CONFIG_FW_LOADER is not set 480# CONFIG_FW_LOADER is not set
481# CONFIG_DEBUG_DRIVER is not set
482# CONFIG_DEBUG_DEVRES is not set
459# CONFIG_SYS_HYPERVISOR is not set 483# CONFIG_SYS_HYPERVISOR is not set
460# CONFIG_CONNECTOR is not set 484# CONFIG_CONNECTOR is not set
461CONFIG_MTD=y 485CONFIG_MTD=y
@@ -464,6 +488,7 @@ CONFIG_MTD=y
464CONFIG_MTD_PARTITIONS=y 488CONFIG_MTD_PARTITIONS=y
465# CONFIG_MTD_REDBOOT_PARTS is not set 489# CONFIG_MTD_REDBOOT_PARTS is not set
466# CONFIG_MTD_CMDLINE_PARTS is not set 490# CONFIG_MTD_CMDLINE_PARTS is not set
491# CONFIG_MTD_AR7_PARTS is not set
467 492
468# 493#
469# User Modules And Translation Layers 494# User Modules And Translation Layers
@@ -507,6 +532,7 @@ CONFIG_MTD_ROM=m
507# 532#
508CONFIG_MTD_COMPLEX_MAPPINGS=y 533CONFIG_MTD_COMPLEX_MAPPINGS=y
509# CONFIG_MTD_PHYSMAP is not set 534# CONFIG_MTD_PHYSMAP is not set
535# CONFIG_MTD_GPIO_ADDR is not set
510# CONFIG_MTD_UCLINUX is not set 536# CONFIG_MTD_UCLINUX is not set
511# CONFIG_MTD_PLATRAM is not set 537# CONFIG_MTD_PLATRAM is not set
512 538
@@ -542,10 +568,12 @@ CONFIG_BLK_DEV=y
542CONFIG_BLK_DEV_RAM=y 568CONFIG_BLK_DEV_RAM=y
543CONFIG_BLK_DEV_RAM_COUNT=16 569CONFIG_BLK_DEV_RAM_COUNT=16
544CONFIG_BLK_DEV_RAM_SIZE=4096 570CONFIG_BLK_DEV_RAM_SIZE=4096
545CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 571# CONFIG_BLK_DEV_XIP is not set
546# CONFIG_CDROM_PKTCDVD is not set 572# CONFIG_CDROM_PKTCDVD is not set
547# CONFIG_ATA_OVER_ETH is not set 573# CONFIG_ATA_OVER_ETH is not set
574# CONFIG_BLK_DEV_HD is not set
548# CONFIG_MISC_DEVICES is not set 575# CONFIG_MISC_DEVICES is not set
576CONFIG_HAVE_IDE=y
549# CONFIG_IDE is not set 577# CONFIG_IDE is not set
550 578
551# 579#
@@ -558,7 +586,6 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
558# CONFIG_ATA is not set 586# CONFIG_ATA is not set
559# CONFIG_MD is not set 587# CONFIG_MD is not set
560CONFIG_NETDEVICES=y 588CONFIG_NETDEVICES=y
561# CONFIG_NETDEVICES_MULTIQUEUE is not set
562# CONFIG_DUMMY is not set 589# CONFIG_DUMMY is not set
563# CONFIG_BONDING is not set 590# CONFIG_BONDING is not set
564# CONFIG_MACVLAN is not set 591# CONFIG_MACVLAN is not set
@@ -579,6 +606,7 @@ CONFIG_PHYLIB=y
579# CONFIG_SMSC_PHY is not set 606# CONFIG_SMSC_PHY is not set
580# CONFIG_BROADCOM_PHY is not set 607# CONFIG_BROADCOM_PHY is not set
581# CONFIG_ICPLUS_PHY is not set 608# CONFIG_ICPLUS_PHY is not set
609# CONFIG_REALTEK_PHY is not set
582# CONFIG_FIXED_PHY is not set 610# CONFIG_FIXED_PHY is not set
583# CONFIG_MDIO_BITBANG is not set 611# CONFIG_MDIO_BITBANG is not set
584CONFIG_NET_ETHERNET=y 612CONFIG_NET_ETHERNET=y
@@ -591,11 +619,14 @@ CONFIG_BFIN_MAC_RMII=y
591# CONFIG_SMC91X is not set 619# CONFIG_SMC91X is not set
592# CONFIG_SMSC911X is not set 620# CONFIG_SMSC911X is not set
593# CONFIG_DM9000 is not set 621# CONFIG_DM9000 is not set
622# CONFIG_ENC28J60 is not set
594# CONFIG_IBM_NEW_EMAC_ZMII is not set 623# CONFIG_IBM_NEW_EMAC_ZMII is not set
595# CONFIG_IBM_NEW_EMAC_RGMII is not set 624# CONFIG_IBM_NEW_EMAC_RGMII is not set
596# CONFIG_IBM_NEW_EMAC_TAH is not set 625# CONFIG_IBM_NEW_EMAC_TAH is not set
597# CONFIG_IBM_NEW_EMAC_EMAC4 is not set 626# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
598# CONFIG_B44 is not set 627# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
628# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
629# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
599# CONFIG_NETDEV_1000 is not set 630# CONFIG_NETDEV_1000 is not set
600# CONFIG_NETDEV_10000 is not set 631# CONFIG_NETDEV_10000 is not set
601 632
@@ -604,6 +635,7 @@ CONFIG_BFIN_MAC_RMII=y
604# 635#
605# CONFIG_WLAN_PRE80211 is not set 636# CONFIG_WLAN_PRE80211 is not set
606# CONFIG_WLAN_80211 is not set 637# CONFIG_WLAN_80211 is not set
638# CONFIG_IWLWIFI_LEDS is not set
607 639
608# 640#
609# USB Network Adapters 641# USB Network Adapters
@@ -616,7 +648,6 @@ CONFIG_BFIN_MAC_RMII=y
616# CONFIG_WAN is not set 648# CONFIG_WAN is not set
617# CONFIG_PPP is not set 649# CONFIG_PPP is not set
618# CONFIG_SLIP is not set 650# CONFIG_SLIP is not set
619# CONFIG_SHAPER is not set
620# CONFIG_NETCONSOLE is not set 651# CONFIG_NETCONSOLE is not set
621# CONFIG_NETPOLL is not set 652# CONFIG_NETPOLL is not set
622# CONFIG_NET_POLL_CONTROLLER is not set 653# CONFIG_NET_POLL_CONTROLLER is not set
@@ -642,14 +673,15 @@ CONFIG_BFIN_MAC_RMII=y
642# CONFIG_BF5xx_PPIFCD is not set 673# CONFIG_BF5xx_PPIFCD is not set
643# CONFIG_BFIN_SIMPLE_TIMER is not set 674# CONFIG_BFIN_SIMPLE_TIMER is not set
644# CONFIG_BF5xx_PPI is not set 675# CONFIG_BF5xx_PPI is not set
645CONFIG_BFIN_OTP=y 676# CONFIG_BF5xx_EPPI is not set
646# CONFIG_BFIN_OTP_WRITE_ENABLE is not set
647# CONFIG_BFIN_SPORT is not set 677# CONFIG_BFIN_SPORT is not set
648# CONFIG_BFIN_TIMER_LATENCY is not set 678# CONFIG_BFIN_TIMER_LATENCY is not set
649# CONFIG_TWI_LCD is not set 679# CONFIG_TWI_LCD is not set
680CONFIG_BFIN_DMA_INTERFACE=m
650CONFIG_SIMPLE_GPIO=m 681CONFIG_SIMPLE_GPIO=m
651# CONFIG_VT is not set 682# CONFIG_VT is not set
652# CONFIG_DEVKMEM is not set 683# CONFIG_DEVKMEM is not set
684# CONFIG_BFIN_JTAG_COMM is not set
653# CONFIG_SERIAL_NONSTANDARD is not set 685# CONFIG_SERIAL_NONSTANDARD is not set
654 686
655# 687#
@@ -673,6 +705,8 @@ CONFIG_SERIAL_CORE_CONSOLE=y
673# CONFIG_SERIAL_BFIN_SPORT is not set 705# CONFIG_SERIAL_BFIN_SPORT is not set
674CONFIG_UNIX98_PTYS=y 706CONFIG_UNIX98_PTYS=y
675# CONFIG_LEGACY_PTYS is not set 707# CONFIG_LEGACY_PTYS is not set
708CONFIG_BFIN_OTP=y
709# CONFIG_BFIN_OTP_WRITE_ENABLE is not set
676 710
677# 711#
678# CAN, the car bus and industrial fieldbus 712# CAN, the car bus and industrial fieldbus
@@ -680,44 +714,49 @@ CONFIG_UNIX98_PTYS=y
680# CONFIG_CAN4LINUX is not set 714# CONFIG_CAN4LINUX is not set
681# CONFIG_IPMI_HANDLER is not set 715# CONFIG_IPMI_HANDLER is not set
682# CONFIG_HW_RANDOM is not set 716# CONFIG_HW_RANDOM is not set
683# CONFIG_GEN_RTC is not set
684# CONFIG_R3964 is not set 717# CONFIG_R3964 is not set
685# CONFIG_RAW_DRIVER is not set 718# CONFIG_RAW_DRIVER is not set
686# CONFIG_TCG_TPM is not set 719# CONFIG_TCG_TPM is not set
687CONFIG_I2C=y 720CONFIG_I2C=y
688CONFIG_I2C_BOARDINFO=y 721CONFIG_I2C_BOARDINFO=y
689CONFIG_I2C_CHARDEV=m 722CONFIG_I2C_CHARDEV=m
723CONFIG_I2C_HELPER_AUTO=y
690 724
691# 725#
692# I2C Algorithms 726# I2C Hardware Bus support
693# 727#
694# CONFIG_I2C_ALGOBIT is not set
695# CONFIG_I2C_ALGOPCF is not set
696# CONFIG_I2C_ALGOPCA is not set
697 728
698# 729#
699# I2C Hardware Bus support 730# I2C system bus drivers (mostly embedded / system-on-chip)
700# 731#
701CONFIG_I2C_BLACKFIN_TWI=m 732CONFIG_I2C_BLACKFIN_TWI=m
702CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100 733CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100
703# CONFIG_I2C_GPIO is not set 734# CONFIG_I2C_GPIO is not set
704# CONFIG_I2C_OCORES is not set 735# CONFIG_I2C_OCORES is not set
705# CONFIG_I2C_PARPORT_LIGHT is not set
706# CONFIG_I2C_SIMTEC is not set 736# CONFIG_I2C_SIMTEC is not set
737
738#
739# External I2C/SMBus adapter drivers
740#
741# CONFIG_I2C_PARPORT_LIGHT is not set
707# CONFIG_I2C_TAOS_EVM is not set 742# CONFIG_I2C_TAOS_EVM is not set
708# CONFIG_I2C_STUB is not set
709# CONFIG_I2C_TINY_USB is not set 743# CONFIG_I2C_TINY_USB is not set
710 744
711# 745#
746# Other I2C/SMBus bus drivers
747#
748# CONFIG_I2C_PCA_PLATFORM is not set
749# CONFIG_I2C_STUB is not set
750
751#
712# Miscellaneous I2C Chip support 752# Miscellaneous I2C Chip support
713# 753#
714# CONFIG_SENSORS_DS1337 is not set
715# CONFIG_SENSORS_DS1374 is not set
716# CONFIG_DS1682 is not set 754# CONFIG_DS1682 is not set
755# CONFIG_AT24 is not set
717# CONFIG_SENSORS_AD5252 is not set 756# CONFIG_SENSORS_AD5252 is not set
718# CONFIG_EEPROM_LEGACY is not set 757# CONFIG_SENSORS_EEPROM is not set
719# CONFIG_SENSORS_PCF8574 is not set 758# CONFIG_SENSORS_PCF8574 is not set
720# CONFIG_SENSORS_PCF8575 is not set 759# CONFIG_PCF8575 is not set
721# CONFIG_SENSORS_PCA9539 is not set 760# CONFIG_SENSORS_PCA9539 is not set
722# CONFIG_SENSORS_PCF8591 is not set 761# CONFIG_SENSORS_PCF8591 is not set
723# CONFIG_SENSORS_MAX6875 is not set 762# CONFIG_SENSORS_MAX6875 is not set
@@ -726,37 +765,41 @@ CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100
726# CONFIG_I2C_DEBUG_ALGO is not set 765# CONFIG_I2C_DEBUG_ALGO is not set
727# CONFIG_I2C_DEBUG_BUS is not set 766# CONFIG_I2C_DEBUG_BUS is not set
728# CONFIG_I2C_DEBUG_CHIP is not set 767# CONFIG_I2C_DEBUG_CHIP is not set
729
730#
731# SPI support
732#
733CONFIG_SPI=y 768CONFIG_SPI=y
769# CONFIG_SPI_DEBUG is not set
734CONFIG_SPI_MASTER=y 770CONFIG_SPI_MASTER=y
735 771
736# 772#
737# SPI Master Controller Drivers 773# SPI Master Controller Drivers
738# 774#
739CONFIG_SPI_BFIN=y 775CONFIG_SPI_BFIN=y
776# CONFIG_SPI_BFIN_LOCK is not set
740# CONFIG_SPI_BITBANG is not set 777# CONFIG_SPI_BITBANG is not set
741 778
742# 779#
743# SPI Protocol Masters 780# SPI Protocol Masters
744# 781#
745# CONFIG_EEPROM_AT25 is not set 782# CONFIG_SPI_AT25 is not set
746# CONFIG_SPI_SPIDEV is not set 783# CONFIG_SPI_SPIDEV is not set
747# CONFIG_SPI_TLE62X0 is not set 784# CONFIG_SPI_TLE62X0 is not set
785CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
786# CONFIG_GPIOLIB is not set
748# CONFIG_W1 is not set 787# CONFIG_W1 is not set
749# CONFIG_POWER_SUPPLY is not set 788# CONFIG_POWER_SUPPLY is not set
750CONFIG_HWMON=y 789CONFIG_HWMON=y
751# CONFIG_HWMON_VID is not set 790# CONFIG_HWMON_VID is not set
791# CONFIG_SENSORS_AD7414 is not set
752# CONFIG_SENSORS_AD7418 is not set 792# CONFIG_SENSORS_AD7418 is not set
793# CONFIG_SENSORS_ADCXX is not set
753# CONFIG_SENSORS_ADM1021 is not set 794# CONFIG_SENSORS_ADM1021 is not set
754# CONFIG_SENSORS_ADM1025 is not set 795# CONFIG_SENSORS_ADM1025 is not set
755# CONFIG_SENSORS_ADM1026 is not set 796# CONFIG_SENSORS_ADM1026 is not set
756# CONFIG_SENSORS_ADM1029 is not set 797# CONFIG_SENSORS_ADM1029 is not set
757# CONFIG_SENSORS_ADM1031 is not set 798# CONFIG_SENSORS_ADM1031 is not set
758# CONFIG_SENSORS_ADM9240 is not set 799# CONFIG_SENSORS_ADM9240 is not set
800# CONFIG_SENSORS_ADT7462 is not set
759# CONFIG_SENSORS_ADT7470 is not set 801# CONFIG_SENSORS_ADT7470 is not set
802# CONFIG_SENSORS_ADT7473 is not set
760# CONFIG_SENSORS_ATXP1 is not set 803# CONFIG_SENSORS_ATXP1 is not set
761# CONFIG_SENSORS_DS1621 is not set 804# CONFIG_SENSORS_DS1621 is not set
762# CONFIG_SENSORS_F71805F is not set 805# CONFIG_SENSORS_F71805F is not set
@@ -777,6 +820,7 @@ CONFIG_HWMON=y
777# CONFIG_SENSORS_LM90 is not set 820# CONFIG_SENSORS_LM90 is not set
778# CONFIG_SENSORS_LM92 is not set 821# CONFIG_SENSORS_LM92 is not set
779# CONFIG_SENSORS_LM93 is not set 822# CONFIG_SENSORS_LM93 is not set
823# CONFIG_SENSORS_MAX1111 is not set
780# CONFIG_SENSORS_MAX1619 is not set 824# CONFIG_SENSORS_MAX1619 is not set
781# CONFIG_SENSORS_MAX6650 is not set 825# CONFIG_SENSORS_MAX6650 is not set
782# CONFIG_SENSORS_PC87360 is not set 826# CONFIG_SENSORS_PC87360 is not set
@@ -785,6 +829,7 @@ CONFIG_HWMON=y
785# CONFIG_SENSORS_SMSC47M1 is not set 829# CONFIG_SENSORS_SMSC47M1 is not set
786# CONFIG_SENSORS_SMSC47M192 is not set 830# CONFIG_SENSORS_SMSC47M192 is not set
787# CONFIG_SENSORS_SMSC47B397 is not set 831# CONFIG_SENSORS_SMSC47B397 is not set
832# CONFIG_SENSORS_ADS7828 is not set
788# CONFIG_SENSORS_THMC50 is not set 833# CONFIG_SENSORS_THMC50 is not set
789# CONFIG_SENSORS_VT1211 is not set 834# CONFIG_SENSORS_VT1211 is not set
790# CONFIG_SENSORS_W83781D is not set 835# CONFIG_SENSORS_W83781D is not set
@@ -792,9 +837,12 @@ CONFIG_HWMON=y
792# CONFIG_SENSORS_W83792D is not set 837# CONFIG_SENSORS_W83792D is not set
793# CONFIG_SENSORS_W83793 is not set 838# CONFIG_SENSORS_W83793 is not set
794# CONFIG_SENSORS_W83L785TS is not set 839# CONFIG_SENSORS_W83L785TS is not set
840# CONFIG_SENSORS_W83L786NG is not set
795# CONFIG_SENSORS_W83627HF is not set 841# CONFIG_SENSORS_W83627HF is not set
796# CONFIG_SENSORS_W83627EHF is not set 842# CONFIG_SENSORS_W83627EHF is not set
797# CONFIG_HWMON_DEBUG_CHIP is not set 843# CONFIG_HWMON_DEBUG_CHIP is not set
844# CONFIG_THERMAL is not set
845# CONFIG_THERMAL_HWMON is not set
798CONFIG_WATCHDOG=y 846CONFIG_WATCHDOG=y
799# CONFIG_WATCHDOG_NOWAYOUT is not set 847# CONFIG_WATCHDOG_NOWAYOUT is not set
800 848
@@ -810,21 +858,31 @@ CONFIG_BFIN_WDT=y
810# CONFIG_USBPCWATCHDOG is not set 858# CONFIG_USBPCWATCHDOG is not set
811 859
812# 860#
813# Sonics Silicon Backplane
814#
815CONFIG_SSB_POSSIBLE=y
816# CONFIG_SSB is not set
817
818#
819# Multifunction device drivers 861# Multifunction device drivers
820# 862#
863# CONFIG_MFD_CORE is not set
821# CONFIG_MFD_SM501 is not set 864# CONFIG_MFD_SM501 is not set
865# CONFIG_HTC_PASIC3 is not set
866# CONFIG_MFD_TMIO is not set
867# CONFIG_PMIC_DA903X is not set
868# CONFIG_MFD_WM8400 is not set
869# CONFIG_MFD_WM8350_I2C is not set
870# CONFIG_REGULATOR is not set
822 871
823# 872#
824# Multimedia devices 873# Multimedia devices
825# 874#
875
876#
877# Multimedia core support
878#
826# CONFIG_VIDEO_DEV is not set 879# CONFIG_VIDEO_DEV is not set
827# CONFIG_DVB_CORE is not set 880# CONFIG_DVB_CORE is not set
881# CONFIG_VIDEO_MEDIA is not set
882
883#
884# Multimedia drivers
885#
828# CONFIG_DAB is not set 886# CONFIG_DAB is not set
829 887
830# 888#
@@ -839,10 +897,6 @@ CONFIG_SSB_POSSIBLE=y
839# Display device support 897# Display device support
840# 898#
841# CONFIG_DISPLAY_SUPPORT is not set 899# CONFIG_DISPLAY_SUPPORT is not set
842
843#
844# Sound
845#
846# CONFIG_SOUND is not set 900# CONFIG_SOUND is not set
847CONFIG_USB_SUPPORT=y 901CONFIG_USB_SUPPORT=y
848CONFIG_USB_ARCH_HAS_HCD=y 902CONFIG_USB_ARCH_HAS_HCD=y
@@ -850,6 +904,7 @@ CONFIG_USB_ARCH_HAS_HCD=y
850# CONFIG_USB_ARCH_HAS_EHCI is not set 904# CONFIG_USB_ARCH_HAS_EHCI is not set
851CONFIG_USB=y 905CONFIG_USB=y
852# CONFIG_USB_DEBUG is not set 906# CONFIG_USB_DEBUG is not set
907# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
853 908
854# 909#
855# Miscellaneous USB options 910# Miscellaneous USB options
@@ -860,40 +915,48 @@ CONFIG_USB_DEVICE_CLASS=y
860# CONFIG_USB_OTG is not set 915# CONFIG_USB_OTG is not set
861# CONFIG_USB_OTG_WHITELIST is not set 916# CONFIG_USB_OTG_WHITELIST is not set
862CONFIG_USB_OTG_BLACKLIST_HUB=y 917CONFIG_USB_OTG_BLACKLIST_HUB=y
918CONFIG_USB_MON=y
919# CONFIG_USB_WUSB is not set
920# CONFIG_USB_WUSB_CBAF is not set
863 921
864# 922#
865# USB Host Controller Drivers 923# USB Host Controller Drivers
866# 924#
925# CONFIG_USB_C67X00_HCD is not set
867# CONFIG_USB_ISP116X_HCD is not set 926# CONFIG_USB_ISP116X_HCD is not set
868# CONFIG_USB_ISP1362_HCD is not set
869# CONFIG_USB_ISP1760_HCD is not set 927# CONFIG_USB_ISP1760_HCD is not set
928# CONFIG_USB_ISP1362_HCD is not set
870# CONFIG_USB_SL811_HCD is not set 929# CONFIG_USB_SL811_HCD is not set
871# CONFIG_USB_R8A66597_HCD is not set 930# CONFIG_USB_R8A66597_HCD is not set
931# CONFIG_USB_HWA_HCD is not set
872CONFIG_USB_MUSB_HDRC=y 932CONFIG_USB_MUSB_HDRC=y
873CONFIG_USB_MUSB_SOC=y 933CONFIG_USB_MUSB_SOC=y
874 934
875# 935#
876# Blackfin high speed USB support 936# Blackfin high speed USB Support
877# 937#
878CONFIG_USB_MUSB_HOST=y 938CONFIG_USB_MUSB_HOST=y
879# CONFIG_USB_MUSB_PERIPHERAL is not set 939# CONFIG_USB_MUSB_PERIPHERAL is not set
880# CONFIG_USB_MUSB_OTG is not set 940# CONFIG_USB_MUSB_OTG is not set
881CONFIG_USB_MUSB_HDRC_HCD=y 941CONFIG_USB_MUSB_HDRC_HCD=y
882CONFIG_MUSB_PIO_ONLY=y 942CONFIG_MUSB_PIO_ONLY=y
883CONFIG_USB_MUSB_LOGLEVEL=0 943CONFIG_MUSB_DMA_POLL=y
944# CONFIG_USB_MUSB_DEBUG is not set
884 945
885# 946#
886# USB Device Class drivers 947# USB Device Class drivers
887# 948#
888# CONFIG_USB_ACM is not set 949# CONFIG_USB_ACM is not set
889# CONFIG_USB_PRINTER is not set 950# CONFIG_USB_PRINTER is not set
951# CONFIG_USB_WDM is not set
952# CONFIG_USB_TMC is not set
890 953
891# 954#
892# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 955# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;
893# 956#
894 957
895# 958#
896# may also be needed; see USB_STORAGE Help for more information 959# see USB_STORAGE Help for more information
897# 960#
898# CONFIG_USB_LIBUSUAL is not set 961# CONFIG_USB_LIBUSUAL is not set
899 962
@@ -901,15 +964,10 @@ CONFIG_USB_MUSB_LOGLEVEL=0
901# USB Imaging devices 964# USB Imaging devices
902# 965#
903# CONFIG_USB_MDC800 is not set 966# CONFIG_USB_MDC800 is not set
904CONFIG_USB_MON=y
905 967
906# 968#
907# USB port drivers 969# USB port drivers
908# 970#
909
910#
911# USB Serial Converter support
912#
913# CONFIG_USB_SERIAL is not set 971# CONFIG_USB_SERIAL is not set
914 972
915# 973#
@@ -918,7 +976,7 @@ CONFIG_USB_MON=y
918# CONFIG_USB_EMI62 is not set 976# CONFIG_USB_EMI62 is not set
919# CONFIG_USB_EMI26 is not set 977# CONFIG_USB_EMI26 is not set
920# CONFIG_USB_ADUTUX is not set 978# CONFIG_USB_ADUTUX is not set
921# CONFIG_USB_AUERSWALD is not set 979# CONFIG_USB_SEVSEG is not set
922# CONFIG_USB_RIO500 is not set 980# CONFIG_USB_RIO500 is not set
923# CONFIG_USB_LEGOTOWER is not set 981# CONFIG_USB_LEGOTOWER is not set
924# CONFIG_USB_LCD is not set 982# CONFIG_USB_LCD is not set
@@ -934,17 +992,13 @@ CONFIG_USB_MON=y
934# CONFIG_USB_LD is not set 992# CONFIG_USB_LD is not set
935# CONFIG_USB_TRANCEVIBRATOR is not set 993# CONFIG_USB_TRANCEVIBRATOR is not set
936# CONFIG_USB_IOWARRIOR is not set 994# CONFIG_USB_IOWARRIOR is not set
937 995# CONFIG_USB_ISIGHTFW is not set
938# 996# CONFIG_USB_VST is not set
939# USB DSL modem support
940#
941
942#
943# USB Gadget Support
944#
945# CONFIG_USB_GADGET is not set 997# CONFIG_USB_GADGET is not set
946# CONFIG_MMC is not set 998# CONFIG_MMC is not set
999# CONFIG_MEMSTICK is not set
947# CONFIG_NEW_LEDS is not set 1000# CONFIG_NEW_LEDS is not set
1001# CONFIG_ACCESSIBILITY is not set
948CONFIG_RTC_LIB=y 1002CONFIG_RTC_LIB=y
949CONFIG_RTC_CLASS=y 1003CONFIG_RTC_CLASS=y
950CONFIG_RTC_HCTOSYS=y 1004CONFIG_RTC_HCTOSYS=y
@@ -973,51 +1027,59 @@ CONFIG_RTC_INTF_DEV=y
973# CONFIG_RTC_DRV_PCF8563 is not set 1027# CONFIG_RTC_DRV_PCF8563 is not set
974# CONFIG_RTC_DRV_PCF8583 is not set 1028# CONFIG_RTC_DRV_PCF8583 is not set
975# CONFIG_RTC_DRV_M41T80 is not set 1029# CONFIG_RTC_DRV_M41T80 is not set
1030# CONFIG_RTC_DRV_S35390A is not set
1031# CONFIG_RTC_DRV_FM3130 is not set
1032# CONFIG_RTC_DRV_RX8581 is not set
976 1033
977# 1034#
978# SPI RTC drivers 1035# SPI RTC drivers
979# 1036#
980# CONFIG_RTC_DRV_RS5C348 is not set 1037# CONFIG_RTC_DRV_M41T94 is not set
1038# CONFIG_RTC_DRV_DS1305 is not set
1039# CONFIG_RTC_DRV_DS1390 is not set
981# CONFIG_RTC_DRV_MAX6902 is not set 1040# CONFIG_RTC_DRV_MAX6902 is not set
1041# CONFIG_RTC_DRV_R9701 is not set
1042# CONFIG_RTC_DRV_RS5C348 is not set
1043# CONFIG_RTC_DRV_DS3234 is not set
982 1044
983# 1045#
984# Platform RTC drivers 1046# Platform RTC drivers
985# 1047#
1048# CONFIG_RTC_DRV_DS1286 is not set
1049# CONFIG_RTC_DRV_DS1511 is not set
986# CONFIG_RTC_DRV_DS1553 is not set 1050# CONFIG_RTC_DRV_DS1553 is not set
987# CONFIG_RTC_DRV_STK17TA8 is not set
988# CONFIG_RTC_DRV_DS1742 is not set 1051# CONFIG_RTC_DRV_DS1742 is not set
1052# CONFIG_RTC_DRV_STK17TA8 is not set
989# CONFIG_RTC_DRV_M48T86 is not set 1053# CONFIG_RTC_DRV_M48T86 is not set
1054# CONFIG_RTC_DRV_M48T35 is not set
990# CONFIG_RTC_DRV_M48T59 is not set 1055# CONFIG_RTC_DRV_M48T59 is not set
1056# CONFIG_RTC_DRV_BQ4802 is not set
991# CONFIG_RTC_DRV_V3020 is not set 1057# CONFIG_RTC_DRV_V3020 is not set
992 1058
993# 1059#
994# on-CPU RTC drivers 1060# on-CPU RTC drivers
995# 1061#
996CONFIG_RTC_DRV_BFIN=y 1062CONFIG_RTC_DRV_BFIN=y
997 1063# CONFIG_DMADEVICES is not set
998#
999# Userspace I/O
1000#
1001# CONFIG_UIO is not set 1064# CONFIG_UIO is not set
1065# CONFIG_STAGING is not set
1002 1066
1003# 1067#
1004# File systems 1068# File systems
1005# 1069#
1006# CONFIG_EXT2_FS is not set 1070# CONFIG_EXT2_FS is not set
1007# CONFIG_EXT3_FS is not set 1071# CONFIG_EXT3_FS is not set
1008# CONFIG_EXT4DEV_FS is not set 1072# CONFIG_EXT4_FS is not set
1009# CONFIG_REISERFS_FS is not set 1073# CONFIG_REISERFS_FS is not set
1010# CONFIG_JFS_FS is not set 1074# CONFIG_JFS_FS is not set
1011# CONFIG_FS_POSIX_ACL is not set 1075# CONFIG_FS_POSIX_ACL is not set
1076CONFIG_FILE_LOCKING=y
1012# CONFIG_XFS_FS is not set 1077# CONFIG_XFS_FS is not set
1013# CONFIG_GFS2_FS is not set
1014# CONFIG_OCFS2_FS is not set 1078# CONFIG_OCFS2_FS is not set
1015# CONFIG_MINIX_FS is not set 1079# CONFIG_DNOTIFY is not set
1016# CONFIG_ROMFS_FS is not set
1017CONFIG_INOTIFY=y 1080CONFIG_INOTIFY=y
1018CONFIG_INOTIFY_USER=y 1081CONFIG_INOTIFY_USER=y
1019# CONFIG_QUOTA is not set 1082# CONFIG_QUOTA is not set
1020# CONFIG_DNOTIFY is not set
1021# CONFIG_AUTOFS_FS is not set 1083# CONFIG_AUTOFS_FS is not set
1022# CONFIG_AUTOFS4_FS is not set 1084# CONFIG_AUTOFS4_FS is not set
1023# CONFIG_FUSE_FS is not set 1085# CONFIG_FUSE_FS is not set
@@ -1059,8 +1121,11 @@ CONFIG_SYSFS=y
1059# CONFIG_JFFS2_FS is not set 1121# CONFIG_JFFS2_FS is not set
1060# CONFIG_CRAMFS is not set 1122# CONFIG_CRAMFS is not set
1061# CONFIG_VXFS_FS is not set 1123# CONFIG_VXFS_FS is not set
1124# CONFIG_MINIX_FS is not set
1125# CONFIG_OMFS_FS is not set
1062# CONFIG_HPFS_FS is not set 1126# CONFIG_HPFS_FS is not set
1063# CONFIG_QNX4FS_FS is not set 1127# CONFIG_QNX4FS_FS is not set
1128# CONFIG_ROMFS_FS is not set
1064# CONFIG_SYSV_FS is not set 1129# CONFIG_SYSV_FS is not set
1065# CONFIG_UFS_FS is not set 1130# CONFIG_UFS_FS is not set
1066CONFIG_NETWORK_FILESYSTEMS=y 1131CONFIG_NETWORK_FILESYSTEMS=y
@@ -1068,13 +1133,12 @@ CONFIG_NFS_FS=m
1068CONFIG_NFS_V3=y 1133CONFIG_NFS_V3=y
1069# CONFIG_NFS_V3_ACL is not set 1134# CONFIG_NFS_V3_ACL is not set
1070# CONFIG_NFS_V4 is not set 1135# CONFIG_NFS_V4 is not set
1071# CONFIG_NFS_DIRECTIO is not set
1072# CONFIG_NFSD is not set 1136# CONFIG_NFSD is not set
1073CONFIG_LOCKD=m 1137CONFIG_LOCKD=m
1074CONFIG_LOCKD_V4=y 1138CONFIG_LOCKD_V4=y
1075CONFIG_NFS_COMMON=y 1139CONFIG_NFS_COMMON=y
1076CONFIG_SUNRPC=m 1140CONFIG_SUNRPC=m
1077# CONFIG_SUNRPC_BIND34 is not set 1141# CONFIG_SUNRPC_REGISTER_V4 is not set
1078# CONFIG_RPCSEC_GSS_KRB5 is not set 1142# CONFIG_RPCSEC_GSS_KRB5 is not set
1079# CONFIG_RPCSEC_GSS_SPKM3 is not set 1143# CONFIG_RPCSEC_GSS_SPKM3 is not set
1080CONFIG_SMB_FS=m 1144CONFIG_SMB_FS=m
@@ -1130,7 +1194,6 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1130# CONFIG_NLS_KOI8_U is not set 1194# CONFIG_NLS_KOI8_U is not set
1131# CONFIG_NLS_UTF8 is not set 1195# CONFIG_NLS_UTF8 is not set
1132# CONFIG_DLM is not set 1196# CONFIG_DLM is not set
1133# CONFIG_INSTRUMENTATION is not set
1134 1197
1135# 1198#
1136# Kernel hacking 1199# Kernel hacking
@@ -1138,14 +1201,61 @@ CONFIG_NLS_DEFAULT="iso8859-1"
1138# CONFIG_PRINTK_TIME is not set 1201# CONFIG_PRINTK_TIME is not set
1139CONFIG_ENABLE_WARN_DEPRECATED=y 1202CONFIG_ENABLE_WARN_DEPRECATED=y
1140CONFIG_ENABLE_MUST_CHECK=y 1203CONFIG_ENABLE_MUST_CHECK=y
1204CONFIG_FRAME_WARN=1024
1141# CONFIG_MAGIC_SYSRQ is not set 1205# CONFIG_MAGIC_SYSRQ is not set
1142# CONFIG_UNUSED_SYMBOLS is not set 1206# CONFIG_UNUSED_SYMBOLS is not set
1143CONFIG_DEBUG_FS=y 1207CONFIG_DEBUG_FS=y
1144# CONFIG_HEADERS_CHECK is not set 1208# CONFIG_HEADERS_CHECK is not set
1145# CONFIG_DEBUG_KERNEL is not set 1209CONFIG_DEBUG_KERNEL=y
1210# CONFIG_DEBUG_SHIRQ is not set
1211CONFIG_DETECT_SOFTLOCKUP=y
1212# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1213CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1214# CONFIG_SCHED_DEBUG is not set
1215# CONFIG_SCHEDSTATS is not set
1216# CONFIG_TIMER_STATS is not set
1217# CONFIG_DEBUG_OBJECTS is not set
1218# CONFIG_DEBUG_SLAB is not set
1219# CONFIG_DEBUG_RT_MUTEXES is not set
1220# CONFIG_RT_MUTEX_TESTER is not set
1221# CONFIG_DEBUG_SPINLOCK is not set
1222# CONFIG_DEBUG_MUTEXES is not set
1223# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1224# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1225# CONFIG_DEBUG_KOBJECT is not set
1146# CONFIG_DEBUG_BUGVERBOSE is not set 1226# CONFIG_DEBUG_BUGVERBOSE is not set
1227# CONFIG_DEBUG_INFO is not set
1228# CONFIG_DEBUG_VM is not set
1229# CONFIG_DEBUG_WRITECOUNT is not set
1230# CONFIG_DEBUG_MEMORY_INIT is not set
1231# CONFIG_DEBUG_LIST is not set
1232# CONFIG_DEBUG_SG is not set
1233# CONFIG_FRAME_POINTER is not set
1234# CONFIG_BOOT_PRINTK_DELAY is not set
1235# CONFIG_RCU_TORTURE_TEST is not set
1236# CONFIG_RCU_CPU_STALL_DETECTOR is not set
1237# CONFIG_BACKTRACE_SELF_TEST is not set
1238# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1239# CONFIG_FAULT_INJECTION is not set
1240# CONFIG_SYSCTL_SYSCALL_CHECK is not set
1241
1242#
1243# Tracers
1244#
1245# CONFIG_SCHED_TRACER is not set
1246# CONFIG_CONTEXT_SWITCH_TRACER is not set
1247# CONFIG_BOOT_TRACER is not set
1248# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
1147# CONFIG_SAMPLES is not set 1249# CONFIG_SAMPLES is not set
1250CONFIG_HAVE_ARCH_KGDB=y
1251# CONFIG_KGDB is not set
1252# CONFIG_DEBUG_STACKOVERFLOW is not set
1253# CONFIG_DEBUG_STACK_USAGE is not set
1254# CONFIG_KGDB_TESTCASE is not set
1255CONFIG_DEBUG_VERBOSE=y
1148CONFIG_DEBUG_MMRS=y 1256CONFIG_DEBUG_MMRS=y
1257# CONFIG_DEBUG_HWERR is not set
1258# CONFIG_DEBUG_DOUBLEFAULT is not set
1149CONFIG_DEBUG_HUNT_FOR_ZERO=y 1259CONFIG_DEBUG_HUNT_FOR_ZERO=y
1150CONFIG_DEBUG_BFIN_HWTRACE_ON=y 1260CONFIG_DEBUG_BFIN_HWTRACE_ON=y
1151CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y 1261CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
@@ -1154,7 +1264,7 @@ CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
1154CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0 1264CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
1155# CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set 1265# CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
1156# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 1266# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
1157CONFIG_EARLY_PRINTK=y 1267# CONFIG_EARLY_PRINTK is not set
1158# CONFIG_CPLB_INFO is not set 1268# CONFIG_CPLB_INFO is not set
1159CONFIG_ACCESS_CHECK=y 1269CONFIG_ACCESS_CHECK=y
1160 1270
@@ -1163,10 +1273,96 @@ CONFIG_ACCESS_CHECK=y
1163# 1273#
1164# CONFIG_KEYS is not set 1274# CONFIG_KEYS is not set
1165CONFIG_SECURITY=y 1275CONFIG_SECURITY=y
1276# CONFIG_SECURITYFS is not set
1166# CONFIG_SECURITY_NETWORK is not set 1277# CONFIG_SECURITY_NETWORK is not set
1167# CONFIG_SECURITY_CAPABILITIES is not set 1278# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1168# CONFIG_SECURITY_ROOTPLUG is not set 1279# CONFIG_SECURITY_ROOTPLUG is not set
1169# CONFIG_CRYPTO is not set 1280CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
1281CONFIG_CRYPTO=y
1282
1283#
1284# Crypto core or helper
1285#
1286# CONFIG_CRYPTO_FIPS is not set
1287# CONFIG_CRYPTO_MANAGER is not set
1288# CONFIG_CRYPTO_MANAGER2 is not set
1289# CONFIG_CRYPTO_GF128MUL is not set
1290# CONFIG_CRYPTO_NULL is not set
1291# CONFIG_CRYPTO_CRYPTD is not set
1292# CONFIG_CRYPTO_AUTHENC is not set
1293# CONFIG_CRYPTO_TEST is not set
1294
1295#
1296# Authenticated Encryption with Associated Data
1297#
1298# CONFIG_CRYPTO_CCM is not set
1299# CONFIG_CRYPTO_GCM is not set
1300# CONFIG_CRYPTO_SEQIV is not set
1301
1302#
1303# Block modes
1304#
1305# CONFIG_CRYPTO_CBC is not set
1306# CONFIG_CRYPTO_CTR is not set
1307# CONFIG_CRYPTO_CTS is not set
1308# CONFIG_CRYPTO_ECB is not set
1309# CONFIG_CRYPTO_LRW is not set
1310# CONFIG_CRYPTO_PCBC is not set
1311# CONFIG_CRYPTO_XTS is not set
1312
1313#
1314# Hash modes
1315#
1316# CONFIG_CRYPTO_HMAC is not set
1317# CONFIG_CRYPTO_XCBC is not set
1318
1319#
1320# Digest
1321#
1322# CONFIG_CRYPTO_CRC32C is not set
1323# CONFIG_CRYPTO_MD4 is not set
1324# CONFIG_CRYPTO_MD5 is not set
1325# CONFIG_CRYPTO_MICHAEL_MIC is not set
1326# CONFIG_CRYPTO_RMD128 is not set
1327# CONFIG_CRYPTO_RMD160 is not set
1328# CONFIG_CRYPTO_RMD256 is not set
1329# CONFIG_CRYPTO_RMD320 is not set
1330# CONFIG_CRYPTO_SHA1 is not set
1331# CONFIG_CRYPTO_SHA256 is not set
1332# CONFIG_CRYPTO_SHA512 is not set
1333# CONFIG_CRYPTO_TGR192 is not set
1334# CONFIG_CRYPTO_WP512 is not set
1335
1336#
1337# Ciphers
1338#
1339# CONFIG_CRYPTO_AES is not set
1340# CONFIG_CRYPTO_ANUBIS is not set
1341# CONFIG_CRYPTO_ARC4 is not set
1342# CONFIG_CRYPTO_BLOWFISH is not set
1343# CONFIG_CRYPTO_CAMELLIA is not set
1344# CONFIG_CRYPTO_CAST5 is not set
1345# CONFIG_CRYPTO_CAST6 is not set
1346# CONFIG_CRYPTO_DES is not set
1347# CONFIG_CRYPTO_FCRYPT is not set
1348# CONFIG_CRYPTO_KHAZAD is not set
1349# CONFIG_CRYPTO_SALSA20 is not set
1350# CONFIG_CRYPTO_SEED is not set
1351# CONFIG_CRYPTO_SERPENT is not set
1352# CONFIG_CRYPTO_TEA is not set
1353# CONFIG_CRYPTO_TWOFISH is not set
1354
1355#
1356# Compression
1357#
1358# CONFIG_CRYPTO_DEFLATE is not set
1359# CONFIG_CRYPTO_LZO is not set
1360
1361#
1362# Random Number Generation
1363#
1364# CONFIG_CRYPTO_ANSI_CPRNG is not set
1365CONFIG_CRYPTO_HW=y
1170 1366
1171# 1367#
1172# Library routines 1368# Library routines
@@ -1174,6 +1370,7 @@ CONFIG_SECURITY=y
1174CONFIG_BITREVERSE=y 1370CONFIG_BITREVERSE=y
1175CONFIG_CRC_CCITT=m 1371CONFIG_CRC_CCITT=m
1176# CONFIG_CRC16 is not set 1372# CONFIG_CRC16 is not set
1373# CONFIG_CRC_T10DIF is not set
1177# CONFIG_CRC_ITU_T is not set 1374# CONFIG_CRC_ITU_T is not set
1178CONFIG_CRC32=y 1375CONFIG_CRC32=y
1179# CONFIG_CRC7 is not set 1376# CONFIG_CRC7 is not set
diff --git a/arch/blackfin/include/asm/checksum.h b/arch/blackfin/include/asm/checksum.h
index f67289a0d8d2..793581fc9556 100644
--- a/arch/blackfin/include/asm/checksum.h
+++ b/arch/blackfin/include/asm/checksum.h
@@ -63,23 +63,23 @@ static inline __wsum
63csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len, 63csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
64 unsigned short proto, __wsum sum) 64 unsigned short proto, __wsum sum)
65{ 65{
66 66 unsigned int carry;
67 __asm__ ("%0 = %0 + %1;\n\t" 67
68 "CC = AC0;\n\t" 68 __asm__ ("%0 = %0 + %2;\n\t"
69 "if !CC jump 4;\n\t" 69 "CC = AC0;\n\t"
70 "%0 = %0 + %4;\n\t" 70 "%1 = CC;\n\t"
71 "%0 = %0 + %2;\n\t" 71 "%0 = %0 + %1;\n\t"
72 "CC = AC0;\n\t" 72 "%0 = %0 + %3;\n\t"
73 "if !CC jump 4;\n\t" 73 "CC = AC0;\n\t"
74 "%0 = %0 + %4;\n\t" 74 "%1 = CC;\n\t"
75 "%0 = %0 + %3;\n\t" 75 "%0 = %0 + %1;\n\t"
76 "CC = AC0;\n\t" 76 "%0 = %0 + %4;\n\t"
77 "if !CC jump 4;\n\t" 77 "CC = AC0;\n\t"
78 "%0 = %0 + %4;\n\t" 78 "%1 = CC;\n\t"
79 "NOP;\n\t" 79 "%0 = %0 + %1;\n\t"
80 : "=d" (sum) 80 : "=d" (sum), "=&d" (carry)
81 : "d" (daddr), "d" (saddr), "d" ((ntohs(len)<<16)+proto*256), "d" (1), "0"(sum) 81 : "d" (daddr), "d" (saddr), "d" ((len + proto) << 8), "0"(sum)
82 : "CC"); 82 : "CC");
83 83
84 return (sum); 84 return (sum);
85} 85}
diff --git a/arch/blackfin/include/asm/delay.h b/arch/blackfin/include/asm/delay.h
index 0889c3abb593..c31f91cc1d5d 100644
--- a/arch/blackfin/include/asm/delay.h
+++ b/arch/blackfin/include/asm/delay.h
@@ -13,29 +13,7 @@
13 13
14static inline void __delay(unsigned long loops) 14static inline void __delay(unsigned long loops)
15{ 15{
16 if (ANOMALY_05000312) { 16__asm__ __volatile__ (
17 /* Interrupted loads to loop registers -> bad */
18 unsigned long tmp;
19 __asm__ __volatile__(
20 "[--SP] = LC0;"
21 "[--SP] = LT0;"
22 "[--SP] = LB0;"
23 "LSETUP (1f,1f) LC0 = %1;"
24 "1: NOP;"
25 /* We take advantage of the fact that LC0 is 0 at
26 * the end of the loop. Otherwise we'd need some
27 * NOPs after the CLI here.
28 */
29 "CLI %0;"
30 "LB0 = [SP++];"
31 "LT0 = [SP++];"
32 "LC0 = [SP++];"
33 "STI %0;"
34 : "=d" (tmp)
35 : "a" (loops)
36 );
37 } else
38 __asm__ __volatile__ (
39 "LSETUP(1f, 1f) LC0 = %0;" 17 "LSETUP(1f, 1f) LC0 = %0;"
40 "1: NOP;" 18 "1: NOP;"
41 : 19 :
@@ -47,16 +25,15 @@ static inline void __delay(unsigned long loops)
47#include <linux/param.h> /* needed for HZ */ 25#include <linux/param.h> /* needed for HZ */
48 26
49/* 27/*
50 * Use only for very small delays ( < 1 msec). Should probably use a 28 * close approximation borrowed from m68knommu to avoid 64-bit math
51 * lookup table, really, as the multiplications take much too long with
52 * short delays. This is a "reasonable" implementation, though (and the
53 * first constant multiplications gets optimized away if the delay is
54 * a constant)
55 */ 29 */
30
31#define HZSCALE (268435456 / (1000000/HZ))
32
56static inline void udelay(unsigned long usecs) 33static inline void udelay(unsigned long usecs)
57{ 34{
58 extern unsigned long loops_per_jiffy; 35 extern unsigned long loops_per_jiffy;
59 __delay(usecs * loops_per_jiffy / (1000000 / HZ)); 36 __delay((((usecs * HZSCALE) >> 11) * (loops_per_jiffy >> 11)) >> 6);
60} 37}
61 38
62#endif 39#endif
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h
index 9477d82fcad2..d4a082ef75b4 100644
--- a/arch/blackfin/include/asm/gpio.h
+++ b/arch/blackfin/include/asm/gpio.h
@@ -27,60 +27,6 @@
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 28 */
29 29
30/*
31* Number BF537/6/4 BF561 BF533/2/1
32* BF527/5/2
33*
34* GPIO_0 PF0 PF0 PF0
35* GPIO_1 PF1 PF1 PF1
36* GPIO_2 PF2 PF2 PF2
37* GPIO_3 PF3 PF3 PF3
38* GPIO_4 PF4 PF4 PF4
39* GPIO_5 PF5 PF5 PF5
40* GPIO_6 PF6 PF6 PF6
41* GPIO_7 PF7 PF7 PF7
42* GPIO_8 PF8 PF8 PF8
43* GPIO_9 PF9 PF9 PF9
44* GPIO_10 PF10 PF10 PF10
45* GPIO_11 PF11 PF11 PF11
46* GPIO_12 PF12 PF12 PF12
47* GPIO_13 PF13 PF13 PF13
48* GPIO_14 PF14 PF14 PF14
49* GPIO_15 PF15 PF15 PF15
50* GPIO_16 PG0 PF16
51* GPIO_17 PG1 PF17
52* GPIO_18 PG2 PF18
53* GPIO_19 PG3 PF19
54* GPIO_20 PG4 PF20
55* GPIO_21 PG5 PF21
56* GPIO_22 PG6 PF22
57* GPIO_23 PG7 PF23
58* GPIO_24 PG8 PF24
59* GPIO_25 PG9 PF25
60* GPIO_26 PG10 PF26
61* GPIO_27 PG11 PF27
62* GPIO_28 PG12 PF28
63* GPIO_29 PG13 PF29
64* GPIO_30 PG14 PF30
65* GPIO_31 PG15 PF31
66* GPIO_32 PH0 PF32
67* GPIO_33 PH1 PF33
68* GPIO_34 PH2 PF34
69* GPIO_35 PH3 PF35
70* GPIO_36 PH4 PF36
71* GPIO_37 PH5 PF37
72* GPIO_38 PH6 PF38
73* GPIO_39 PH7 PF39
74* GPIO_40 PH8 PF40
75* GPIO_41 PH9 PF41
76* GPIO_42 PH10 PF42
77* GPIO_43 PH11 PF43
78* GPIO_44 PH12 PF44
79* GPIO_45 PH13 PF45
80* GPIO_46 PH14 PF46
81* GPIO_47 PH15 PF47
82*/
83
84#ifndef __ARCH_BLACKFIN_GPIO_H__ 30#ifndef __ARCH_BLACKFIN_GPIO_H__
85#define __ARCH_BLACKFIN_GPIO_H__ 31#define __ARCH_BLACKFIN_GPIO_H__
86 32
@@ -295,10 +241,6 @@ int bfin_gpio_direction_output(unsigned gpio, int value);
295int bfin_gpio_get_value(unsigned gpio); 241int bfin_gpio_get_value(unsigned gpio);
296void bfin_gpio_set_value(unsigned gpio, int value); 242void bfin_gpio_set_value(unsigned gpio, int value);
297 243
298#ifndef BF548_FAMILY
299#define bfin_gpio_set_value(gpio, value) set_gpio_data(gpio, value)
300#endif
301
302#ifdef CONFIG_GPIOLIB 244#ifdef CONFIG_GPIOLIB
303#include <asm-generic/gpio.h> /* cansleep wrappers */ 245#include <asm-generic/gpio.h> /* cansleep wrappers */
304 246
diff --git a/arch/blackfin/include/asm/kgdb.h b/arch/blackfin/include/asm/kgdb.h
index 26ebac6646d8..c8b256d2ea30 100644
--- a/arch/blackfin/include/asm/kgdb.h
+++ b/arch/blackfin/include/asm/kgdb.h
@@ -1,32 +1,8 @@
1/* 1/* Blackfin KGDB header
2 * File: include/asm-blackfin/kgdb.h
3 * Based on:
4 * Author: Sonic Zhang
5 *
6 * Created:
7 * Description:
8 *
9 * Rev: $Id: kgdb_bfin_linux-2.6.x.patch 4934 2007-02-13 09:32:11Z sonicz $
10 *
11 * Modified:
12 * Copyright 2005-2006 Analog Devices Inc.
13 *
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
15 * 2 *
16 * This program is free software; you can redistribute it and/or modify 3 * Copyright 2005-2009 Analog Devices Inc.
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 * 4 *
21 * This program is distributed in the hope that it will be useful, 5 * Licensed under the GPL-2 or later.
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see the file COPYING, or write
28 * to the Free Software Foundation, Inc.,
29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */ 6 */
31 7
32#ifndef __ASM_BLACKFIN_KGDB_H__ 8#ifndef __ASM_BLACKFIN_KGDB_H__
@@ -37,17 +13,18 @@
37/* gdb locks */ 13/* gdb locks */
38#define KGDB_MAX_NO_CPUS 8 14#define KGDB_MAX_NO_CPUS 8
39 15
40/************************************************************************/ 16/*
41/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ 17 * BUFMAX defines the maximum number of characters in inbound/outbound buffers.
42/* at least NUMREGBYTES*2 are needed for register packets */ 18 * At least NUMREGBYTES*2 are needed for register packets.
43/* Longer buffer is needed to list all threads */ 19 * Longer buffer is needed to list all threads.
20 */
44#define BUFMAX 2048 21#define BUFMAX 2048
45 22
46/* 23/*
47 * Note that this register image is different from 24 * Note that this register image is different from
48 * the register image that Linux produces at interrupt time. 25 * the register image that Linux produces at interrupt time.
49 * 26 *
50 * Linux's register image is defined by struct pt_regs in ptrace.h. 27 * Linux's register image is defined by struct pt_regs in ptrace.h.
51 */ 28 */
52enum regnames { 29enum regnames {
53 /* Core Registers */ 30 /* Core Registers */
@@ -104,14 +81,14 @@ enum regnames {
104 BFIN_RETX, 81 BFIN_RETX,
105 BFIN_RETN, 82 BFIN_RETN,
106 BFIN_RETE, 83 BFIN_RETE,
107 84
108 /* Pseudo Registers */ 85 /* Pseudo Registers */
109 BFIN_PC, 86 BFIN_PC,
110 BFIN_CC, 87 BFIN_CC,
111 BFIN_EXTRA1, /* Address of .text section. */ 88 BFIN_EXTRA1, /* Address of .text section. */
112 BFIN_EXTRA2, /* Address of .data section. */ 89 BFIN_EXTRA2, /* Address of .data section. */
113 BFIN_EXTRA3, /* Address of .bss section. */ 90 BFIN_EXTRA3, /* Address of .bss section. */
114 BFIN_FDPIC_EXEC, 91 BFIN_FDPIC_EXEC,
115 BFIN_FDPIC_INTERP, 92 BFIN_FDPIC_INTERP,
116 93
117 /* MMRs */ 94 /* MMRs */
@@ -126,7 +103,7 @@ enum regnames {
126 103
127static inline void arch_kgdb_breakpoint(void) 104static inline void arch_kgdb_breakpoint(void)
128{ 105{
129 asm(" EXCPT 2;"); 106 asm("EXCPT 2;");
130} 107}
131#define BREAK_INSTR_SIZE 2 108#define BREAK_INSTR_SIZE 2
132#define CACHE_FLUSH_IS_SAFE 1 109#define CACHE_FLUSH_IS_SAFE 1
diff --git a/arch/blackfin/include/asm/mem_init.h b/arch/blackfin/include/asm/mem_init.h
index 255a9316ad36..61f7487fbf12 100644
--- a/arch/blackfin/include/asm/mem_init.h
+++ b/arch/blackfin/include/asm/mem_init.h
@@ -115,7 +115,7 @@
115#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num) 115#define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num)
116 116
117/* Enable SCLK Out */ 117/* Enable SCLK Out */
118#define mem_SDGCTL (0x80000000 | SCTLE | SDRAM_CL | SDRAM_tRAS | SDRAM_tRP | SDRAM_tRCD | SDRAM_tWR | PSS) 118#define mem_SDGCTL (SCTLE | SDRAM_CL | SDRAM_tRAS | SDRAM_tRP | SDRAM_tRCD | SDRAM_tWR | PSS)
119#else 119#else
120#define mem_SDRRC CONFIG_MEM_SDRRC 120#define mem_SDRRC CONFIG_MEM_SDRRC
121#define mem_SDGCTL CONFIG_MEM_SDGCTL 121#define mem_SDGCTL CONFIG_MEM_SDGCTL
diff --git a/arch/blackfin/include/asm/pda.h b/arch/blackfin/include/asm/pda.h
index bd8d4a7efeb2..a67142740df0 100644
--- a/arch/blackfin/include/asm/pda.h
+++ b/arch/blackfin/include/asm/pda.h
@@ -59,6 +59,7 @@ struct blackfin_pda { /* Per-processor Data Area */
59 unsigned long icplb_fault_addr; 59 unsigned long icplb_fault_addr;
60 unsigned long retx; 60 unsigned long retx;
61 unsigned long seqstat; 61 unsigned long seqstat;
62 unsigned int __nmi_count; /* number of times NMI asserted on this CPU */
62}; 63};
63 64
64extern struct blackfin_pda cpu_pda[]; 65extern struct blackfin_pda cpu_pda[];
diff --git a/arch/blackfin/include/asm/reboot.h b/arch/blackfin/include/asm/reboot.h
index 4856d62b7467..ae1e36329bec 100644
--- a/arch/blackfin/include/asm/reboot.h
+++ b/arch/blackfin/include/asm/reboot.h
@@ -15,6 +15,6 @@ extern void native_machine_halt(void);
15extern void native_machine_power_off(void); 15extern void native_machine_power_off(void);
16 16
17/* common reboot workarounds */ 17/* common reboot workarounds */
18extern void bfin_gpio_reset_spi0_ssel1(void); 18extern void bfin_reset_boot_spi_cs(unsigned short pin);
19 19
20#endif 20#endif
diff --git a/arch/blackfin/kernel/Makefile b/arch/blackfin/kernel/Makefile
index 38a233374f07..4a92a86824b7 100644
--- a/arch/blackfin/kernel/Makefile
+++ b/arch/blackfin/kernel/Makefile
@@ -15,6 +15,8 @@ else
15 obj-y += time.o 15 obj-y += time.o
16endif 16endif
17 17
18CFLAGS_kgdb_test.o := -mlong-calls -O0
19
18obj-$(CONFIG_IPIPE) += ipipe.o 20obj-$(CONFIG_IPIPE) += ipipe.o
19obj-$(CONFIG_IPIPE_TRACE_MCOUNT) += mcount.o 21obj-$(CONFIG_IPIPE_TRACE_MCOUNT) += mcount.o
20obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o 22obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o
diff --git a/arch/blackfin/kernel/bfin_dma_5xx.c b/arch/blackfin/kernel/bfin_dma_5xx.c
index 07e02c0d1c07..8531693fb48d 100644
--- a/arch/blackfin/kernel/bfin_dma_5xx.c
+++ b/arch/blackfin/kernel/bfin_dma_5xx.c
@@ -249,6 +249,13 @@ static void __dma_memcpy(u32 daddr, s16 dmod, u32 saddr, s16 smod, size_t cnt, u
249 249
250 spin_lock_irqsave(&mdma_lock, flags); 250 spin_lock_irqsave(&mdma_lock, flags);
251 251
252 /* Force a sync in case a previous config reset on this channel
253 * occurred. This is needed so subsequent writes to DMA registers
254 * are not spuriously lost/corrupted. Do it under irq lock and
255 * without the anomaly version (because we are atomic already).
256 */
257 __builtin_bfin_ssync();
258
252 if (bfin_read_MDMA_S0_CONFIG()) 259 if (bfin_read_MDMA_S0_CONFIG())
253 while (!(bfin_read_MDMA_D0_IRQ_STATUS() & DMA_DONE)) 260 while (!(bfin_read_MDMA_D0_IRQ_STATUS() & DMA_DONE))
254 continue; 261 continue;
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index 4c14331978f6..51dac55c524a 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -27,59 +27,6 @@
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 28 */
29 29
30/*
31* Number BF537/6/4 BF561 BF533/2/1 BF549/8/4/2
32*
33* GPIO_0 PF0 PF0 PF0 PA0...PJ13
34* GPIO_1 PF1 PF1 PF1
35* GPIO_2 PF2 PF2 PF2
36* GPIO_3 PF3 PF3 PF3
37* GPIO_4 PF4 PF4 PF4
38* GPIO_5 PF5 PF5 PF5
39* GPIO_6 PF6 PF6 PF6
40* GPIO_7 PF7 PF7 PF7
41* GPIO_8 PF8 PF8 PF8
42* GPIO_9 PF9 PF9 PF9
43* GPIO_10 PF10 PF10 PF10
44* GPIO_11 PF11 PF11 PF11
45* GPIO_12 PF12 PF12 PF12
46* GPIO_13 PF13 PF13 PF13
47* GPIO_14 PF14 PF14 PF14
48* GPIO_15 PF15 PF15 PF15
49* GPIO_16 PG0 PF16
50* GPIO_17 PG1 PF17
51* GPIO_18 PG2 PF18
52* GPIO_19 PG3 PF19
53* GPIO_20 PG4 PF20
54* GPIO_21 PG5 PF21
55* GPIO_22 PG6 PF22
56* GPIO_23 PG7 PF23
57* GPIO_24 PG8 PF24
58* GPIO_25 PG9 PF25
59* GPIO_26 PG10 PF26
60* GPIO_27 PG11 PF27
61* GPIO_28 PG12 PF28
62* GPIO_29 PG13 PF29
63* GPIO_30 PG14 PF30
64* GPIO_31 PG15 PF31
65* GPIO_32 PH0 PF32
66* GPIO_33 PH1 PF33
67* GPIO_34 PH2 PF34
68* GPIO_35 PH3 PF35
69* GPIO_36 PH4 PF36
70* GPIO_37 PH5 PF37
71* GPIO_38 PH6 PF38
72* GPIO_39 PH7 PF39
73* GPIO_40 PH8 PF40
74* GPIO_41 PH9 PF41
75* GPIO_42 PH10 PF42
76* GPIO_43 PH11 PF43
77* GPIO_44 PH12 PF44
78* GPIO_45 PH13 PF45
79* GPIO_46 PH14 PF46
80* GPIO_47 PH15 PF47
81*/
82
83#include <linux/delay.h> 30#include <linux/delay.h>
84#include <linux/module.h> 31#include <linux/module.h>
85#include <linux/err.h> 32#include <linux/err.h>
@@ -119,62 +66,61 @@ enum {
119#define AWA_DUMMY_READ(...) do { } while (0) 66#define AWA_DUMMY_READ(...) do { } while (0)
120#endif 67#endif
121 68
69static struct gpio_port_t * const gpio_array[] = {
122#if defined(BF533_FAMILY) || defined(BF538_FAMILY) 70#if defined(BF533_FAMILY) || defined(BF538_FAMILY)
123static struct gpio_port_t *gpio_bankb[] = {
124 (struct gpio_port_t *) FIO_FLAG_D, 71 (struct gpio_port_t *) FIO_FLAG_D,
125}; 72#elif defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
126#endif
127
128#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
129static struct gpio_port_t *gpio_bankb[] = {
130 (struct gpio_port_t *) PORTFIO, 73 (struct gpio_port_t *) PORTFIO,
131 (struct gpio_port_t *) PORTGIO, 74 (struct gpio_port_t *) PORTGIO,
132 (struct gpio_port_t *) PORTHIO, 75 (struct gpio_port_t *) PORTHIO,
76#elif defined(BF561_FAMILY)
77 (struct gpio_port_t *) FIO0_FLAG_D,
78 (struct gpio_port_t *) FIO1_FLAG_D,
79 (struct gpio_port_t *) FIO2_FLAG_D,
80#elif defined(BF548_FAMILY)
81 (struct gpio_port_t *)PORTA_FER,
82 (struct gpio_port_t *)PORTB_FER,
83 (struct gpio_port_t *)PORTC_FER,
84 (struct gpio_port_t *)PORTD_FER,
85 (struct gpio_port_t *)PORTE_FER,
86 (struct gpio_port_t *)PORTF_FER,
87 (struct gpio_port_t *)PORTG_FER,
88 (struct gpio_port_t *)PORTH_FER,
89 (struct gpio_port_t *)PORTI_FER,
90 (struct gpio_port_t *)PORTJ_FER,
91#else
92# error no gpio arrays defined
93#endif
133}; 94};
134 95
135static unsigned short *port_fer[] = { 96#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
97static unsigned short * const port_fer[] = {
136 (unsigned short *) PORTF_FER, 98 (unsigned short *) PORTF_FER,
137 (unsigned short *) PORTG_FER, 99 (unsigned short *) PORTG_FER,
138 (unsigned short *) PORTH_FER, 100 (unsigned short *) PORTH_FER,
139}; 101};
140#endif
141 102
142#if defined(BF527_FAMILY) || defined(BF518_FAMILY) 103# if !defined(BF537_FAMILY)
143static unsigned short *port_mux[] = { 104static unsigned short * const port_mux[] = {
144 (unsigned short *) PORTF_MUX, 105 (unsigned short *) PORTF_MUX,
145 (unsigned short *) PORTG_MUX, 106 (unsigned short *) PORTG_MUX,
146 (unsigned short *) PORTH_MUX, 107 (unsigned short *) PORTH_MUX,
147}; 108};
148 109
149static const 110static const
150u8 pmux_offset[][16] = 111u8 pmux_offset[][16] = {
151 {{ 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 4, 6, 8, 8, 10, 10 }, /* PORTF */ 112# if defined(BF527_FAMILY)
152 { 0, 0, 0, 0, 0, 2, 2, 4, 4, 6, 8, 10, 10, 10, 12, 12 }, /* PORTG */ 113 { 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 4, 6, 8, 8, 10, 10 }, /* PORTF */
153 { 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 4 }, /* PORTH */ 114 { 0, 0, 0, 0, 0, 2, 2, 4, 4, 6, 8, 10, 10, 10, 12, 12 }, /* PORTG */
154 }; 115 { 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 4 }, /* PORTH */
155#endif 116# elif defined(BF518_FAMILY)
156 117 { 0, 2, 2, 2, 2, 2, 2, 4, 6, 6, 6, 8, 8, 8, 8, 10 }, /* PORTF */
157#ifdef BF561_FAMILY 118 { 0, 0, 0, 2, 4, 6, 6, 6, 8, 10, 10, 12, 14, 14, 14, 14 }, /* PORTG */
158static struct gpio_port_t *gpio_bankb[] = { 119 { 0, 0, 0, 0, 2, 2, 4, 6, 10, 10, 10, 10, 10, 10, 10, 10 }, /* PORTH */
159 (struct gpio_port_t *) FIO0_FLAG_D, 120# endif
160 (struct gpio_port_t *) FIO1_FLAG_D,
161 (struct gpio_port_t *) FIO2_FLAG_D,
162}; 121};
163#endif 122# endif
164 123
165#ifdef BF548_FAMILY
166static struct gpio_port_t *gpio_array[] = {
167 (struct gpio_port_t *)PORTA_FER,
168 (struct gpio_port_t *)PORTB_FER,
169 (struct gpio_port_t *)PORTC_FER,
170 (struct gpio_port_t *)PORTD_FER,
171 (struct gpio_port_t *)PORTE_FER,
172 (struct gpio_port_t *)PORTF_FER,
173 (struct gpio_port_t *)PORTG_FER,
174 (struct gpio_port_t *)PORTH_FER,
175 (struct gpio_port_t *)PORTI_FER,
176 (struct gpio_port_t *)PORTJ_FER,
177};
178#endif 124#endif
179 125
180static unsigned short reserved_gpio_map[GPIO_BANK_NUM]; 126static unsigned short reserved_gpio_map[GPIO_BANK_NUM];
@@ -188,35 +134,9 @@ static struct str_ident {
188} str_ident[MAX_RESOURCES]; 134} str_ident[MAX_RESOURCES];
189 135
190#if defined(CONFIG_PM) 136#if defined(CONFIG_PM)
191#if defined(CONFIG_BF54x)
192static struct gpio_port_s gpio_bank_saved[GPIO_BANK_NUM];
193#else
194static unsigned short wakeup_map[GPIO_BANK_NUM];
195static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS];
196static struct gpio_port_s gpio_bank_saved[GPIO_BANK_NUM]; 137static struct gpio_port_s gpio_bank_saved[GPIO_BANK_NUM];
197
198#ifdef BF533_FAMILY
199static unsigned int sic_iwr_irqs[] = {IRQ_PROG_INTB};
200#endif
201
202#ifdef BF537_FAMILY
203static unsigned int sic_iwr_irqs[] = {IRQ_PROG_INTB, IRQ_PORTG_INTB, IRQ_MAC_TX};
204#endif
205
206#ifdef BF538_FAMILY
207static unsigned int sic_iwr_irqs[] = {IRQ_PORTF_INTB};
208#endif 138#endif
209 139
210#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
211static unsigned int sic_iwr_irqs[] = {IRQ_PORTF_INTB, IRQ_PORTG_INTB, IRQ_PORTH_INTB};
212#endif
213
214#ifdef BF561_FAMILY
215static unsigned int sic_iwr_irqs[] = {IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB};
216#endif
217#endif
218#endif /* CONFIG_PM */
219
220inline int check_gpio(unsigned gpio) 140inline int check_gpio(unsigned gpio)
221{ 141{
222#if defined(BF548_FAMILY) 142#if defined(BF548_FAMILY)
@@ -330,9 +250,10 @@ static struct {
330 {.res = P_SPI0_SSEL3, .offset = 0}, 250 {.res = P_SPI0_SSEL3, .offset = 0},
331}; 251};
332 252
333static void portmux_setup(unsigned short per, unsigned short function) 253static void portmux_setup(unsigned short per)
334{ 254{
335 u16 y, offset, muxreg; 255 u16 y, offset, muxreg;
256 u16 function = P_FUNCT2MUX(per);
336 257
337 for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) { 258 for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) {
338 if (port_mux_lut[y].res == per) { 259 if (port_mux_lut[y].res == per) {
@@ -353,30 +274,33 @@ static void portmux_setup(unsigned short per, unsigned short function)
353 } 274 }
354} 275}
355#elif defined(BF548_FAMILY) 276#elif defined(BF548_FAMILY)
356inline void portmux_setup(unsigned short portno, unsigned short function) 277inline void portmux_setup(unsigned short per)
357{ 278{
358 u32 pmux; 279 u32 pmux;
280 u16 ident = P_IDENT(per);
281 u16 function = P_FUNCT2MUX(per);
359 282
360 pmux = gpio_array[gpio_bank(portno)]->port_mux; 283 pmux = gpio_array[gpio_bank(ident)]->port_mux;
361 284
362 pmux &= ~(0x3 << (2 * gpio_sub_n(portno))); 285 pmux &= ~(0x3 << (2 * gpio_sub_n(ident)));
363 pmux |= (function & 0x3) << (2 * gpio_sub_n(portno)); 286 pmux |= (function & 0x3) << (2 * gpio_sub_n(ident));
364 287
365 gpio_array[gpio_bank(portno)]->port_mux = pmux; 288 gpio_array[gpio_bank(ident)]->port_mux = pmux;
366} 289}
367 290
368inline u16 get_portmux(unsigned short portno) 291inline u16 get_portmux(unsigned short per)
369{ 292{
370 u32 pmux; 293 u32 pmux;
294 u16 ident = P_IDENT(per);
371 295
372 pmux = gpio_array[gpio_bank(portno)]->port_mux; 296 pmux = gpio_array[gpio_bank(ident)]->port_mux;
373 297
374 return (pmux >> (2 * gpio_sub_n(portno)) & 0x3); 298 return (pmux >> (2 * gpio_sub_n(ident)) & 0x3);
375} 299}
376#elif defined(BF527_FAMILY) || defined(BF518_FAMILY) 300#elif defined(BF527_FAMILY) || defined(BF518_FAMILY)
377inline void portmux_setup(unsigned short portno, unsigned short function) 301inline void portmux_setup(unsigned short per)
378{ 302{
379 u16 pmux, ident = P_IDENT(portno); 303 u16 pmux, ident = P_IDENT(per), function = P_FUNCT2MUX(per);
380 u8 offset = pmux_offset[gpio_bank(ident)][gpio_sub_n(ident)]; 304 u8 offset = pmux_offset[gpio_bank(ident)][gpio_sub_n(ident)];
381 305
382 pmux = *port_mux[gpio_bank(ident)]; 306 pmux = *port_mux[gpio_bank(ident)];
@@ -424,90 +348,71 @@ void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
424 unsigned long flags; \ 348 unsigned long flags; \
425 local_irq_save_hw(flags); \ 349 local_irq_save_hw(flags); \
426 if (arg) \ 350 if (arg) \
427 gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ 351 gpio_array[gpio_bank(gpio)]->name |= gpio_bit(gpio); \
428 else \ 352 else \
429 gpio_bankb[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \ 353 gpio_array[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \
430 AWA_DUMMY_READ(name); \ 354 AWA_DUMMY_READ(name); \
431 local_irq_restore_hw(flags); \ 355 local_irq_restore_hw(flags); \
432} \ 356} \
433EXPORT_SYMBOL(set_gpio_ ## name); 357EXPORT_SYMBOL(set_gpio_ ## name);
434 358
435SET_GPIO(dir) 359SET_GPIO(dir) /* set_gpio_dir() */
436SET_GPIO(inen) 360SET_GPIO(inen) /* set_gpio_inen() */
437SET_GPIO(polar) 361SET_GPIO(polar) /* set_gpio_polar() */
438SET_GPIO(edge) 362SET_GPIO(edge) /* set_gpio_edge() */
439SET_GPIO(both) 363SET_GPIO(both) /* set_gpio_both() */
440 364
441 365
442#if ANOMALY_05000311 || ANOMALY_05000323
443#define SET_GPIO_SC(name) \ 366#define SET_GPIO_SC(name) \
444void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ 367void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
445{ \ 368{ \
446 unsigned long flags; \ 369 unsigned long flags; \
447 local_irq_save_hw(flags); \ 370 if (ANOMALY_05000311 || ANOMALY_05000323) \
448 if (arg) \ 371 local_irq_save_hw(flags); \
449 gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \
450 else \
451 gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \
452 AWA_DUMMY_READ(name); \
453 local_irq_restore_hw(flags); \
454} \
455EXPORT_SYMBOL(set_gpio_ ## name);
456#else
457#define SET_GPIO_SC(name) \
458void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
459{ \
460 if (arg) \ 372 if (arg) \
461 gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ 373 gpio_array[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \
462 else \ 374 else \
463 gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \ 375 gpio_array[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \
376 if (ANOMALY_05000311 || ANOMALY_05000323) { \
377 AWA_DUMMY_READ(name); \
378 local_irq_restore_hw(flags); \
379 } \
464} \ 380} \
465EXPORT_SYMBOL(set_gpio_ ## name); 381EXPORT_SYMBOL(set_gpio_ ## name);
466#endif
467 382
468SET_GPIO_SC(maska) 383SET_GPIO_SC(maska)
469SET_GPIO_SC(maskb) 384SET_GPIO_SC(maskb)
470SET_GPIO_SC(data) 385SET_GPIO_SC(data)
471 386
472#if ANOMALY_05000311 || ANOMALY_05000323
473void set_gpio_toggle(unsigned gpio) 387void set_gpio_toggle(unsigned gpio)
474{ 388{
475 unsigned long flags; 389 unsigned long flags;
476 local_irq_save_hw(flags); 390 if (ANOMALY_05000311 || ANOMALY_05000323)
477 gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); 391 local_irq_save_hw(flags);
478 AWA_DUMMY_READ(toggle); 392 gpio_array[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
479 local_irq_restore_hw(flags); 393 if (ANOMALY_05000311 || ANOMALY_05000323) {
480} 394 AWA_DUMMY_READ(toggle);
481#else 395 local_irq_restore_hw(flags);
482void set_gpio_toggle(unsigned gpio) 396 }
483{
484 gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
485} 397}
486#endif
487EXPORT_SYMBOL(set_gpio_toggle); 398EXPORT_SYMBOL(set_gpio_toggle);
488 399
489 400
490/*Set current PORT date (16-bit word)*/ 401/*Set current PORT date (16-bit word)*/
491 402
492#if ANOMALY_05000311 || ANOMALY_05000323
493#define SET_GPIO_P(name) \ 403#define SET_GPIO_P(name) \
494void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \ 404void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \
495{ \ 405{ \
496 unsigned long flags; \ 406 unsigned long flags; \
497 local_irq_save_hw(flags); \ 407 if (ANOMALY_05000311 || ANOMALY_05000323) \
498 gpio_bankb[gpio_bank(gpio)]->name = arg; \ 408 local_irq_save_hw(flags); \
499 AWA_DUMMY_READ(name); \ 409 gpio_array[gpio_bank(gpio)]->name = arg; \
500 local_irq_restore_hw(flags); \ 410 if (ANOMALY_05000311 || ANOMALY_05000323) { \
411 AWA_DUMMY_READ(name); \
412 local_irq_restore_hw(flags); \
413 } \
501} \ 414} \
502EXPORT_SYMBOL(set_gpiop_ ## name); 415EXPORT_SYMBOL(set_gpiop_ ## name);
503#else
504#define SET_GPIO_P(name) \
505void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \
506{ \
507 gpio_bankb[gpio_bank(gpio)]->name = arg; \
508} \
509EXPORT_SYMBOL(set_gpiop_ ## name);
510#endif
511 416
512SET_GPIO_P(data) 417SET_GPIO_P(data)
513SET_GPIO_P(dir) 418SET_GPIO_P(dir)
@@ -519,27 +424,21 @@ SET_GPIO_P(maska)
519SET_GPIO_P(maskb) 424SET_GPIO_P(maskb)
520 425
521/* Get a specific bit */ 426/* Get a specific bit */
522#if ANOMALY_05000311 || ANOMALY_05000323
523#define GET_GPIO(name) \ 427#define GET_GPIO(name) \
524unsigned short get_gpio_ ## name(unsigned gpio) \ 428unsigned short get_gpio_ ## name(unsigned gpio) \
525{ \ 429{ \
526 unsigned long flags; \ 430 unsigned long flags; \
527 unsigned short ret; \ 431 unsigned short ret; \
528 local_irq_save_hw(flags); \ 432 if (ANOMALY_05000311 || ANOMALY_05000323) \
529 ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \ 433 local_irq_save_hw(flags); \
530 AWA_DUMMY_READ(name); \ 434 ret = 0x01 & (gpio_array[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \
531 local_irq_restore_hw(flags); \ 435 if (ANOMALY_05000311 || ANOMALY_05000323) { \
436 AWA_DUMMY_READ(name); \
437 local_irq_restore_hw(flags); \
438 } \
532 return ret; \ 439 return ret; \
533} \ 440} \
534EXPORT_SYMBOL(get_gpio_ ## name); 441EXPORT_SYMBOL(get_gpio_ ## name);
535#else
536#define GET_GPIO(name) \
537unsigned short get_gpio_ ## name(unsigned gpio) \
538{ \
539 return (0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio))); \
540} \
541EXPORT_SYMBOL(get_gpio_ ## name);
542#endif
543 442
544GET_GPIO(data) 443GET_GPIO(data)
545GET_GPIO(dir) 444GET_GPIO(dir)
@@ -552,27 +451,21 @@ GET_GPIO(maskb)
552 451
553/*Get current PORT date (16-bit word)*/ 452/*Get current PORT date (16-bit word)*/
554 453
555#if ANOMALY_05000311 || ANOMALY_05000323
556#define GET_GPIO_P(name) \ 454#define GET_GPIO_P(name) \
557unsigned short get_gpiop_ ## name(unsigned gpio) \ 455unsigned short get_gpiop_ ## name(unsigned gpio) \
558{ \ 456{ \
559 unsigned long flags; \ 457 unsigned long flags; \
560 unsigned short ret; \ 458 unsigned short ret; \
561 local_irq_save_hw(flags); \ 459 if (ANOMALY_05000311 || ANOMALY_05000323) \
562 ret = (gpio_bankb[gpio_bank(gpio)]->name); \ 460 local_irq_save_hw(flags); \
563 AWA_DUMMY_READ(name); \ 461 ret = (gpio_array[gpio_bank(gpio)]->name); \
564 local_irq_restore_hw(flags); \ 462 if (ANOMALY_05000311 || ANOMALY_05000323) { \
463 AWA_DUMMY_READ(name); \
464 local_irq_restore_hw(flags); \
465 } \
565 return ret; \ 466 return ret; \
566} \ 467} \
567EXPORT_SYMBOL(get_gpiop_ ## name); 468EXPORT_SYMBOL(get_gpiop_ ## name);
568#else
569#define GET_GPIO_P(name) \
570unsigned short get_gpiop_ ## name(unsigned gpio) \
571{ \
572 return (gpio_bankb[gpio_bank(gpio)]->name);\
573} \
574EXPORT_SYMBOL(get_gpiop_ ## name);
575#endif
576 469
577GET_GPIO_P(data) 470GET_GPIO_P(data)
578GET_GPIO_P(dir) 471GET_GPIO_P(dir)
@@ -585,6 +478,26 @@ GET_GPIO_P(maskb)
585 478
586 479
587#ifdef CONFIG_PM 480#ifdef CONFIG_PM
481
482static unsigned short wakeup_map[GPIO_BANK_NUM];
483static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS];
484
485static const unsigned int sic_iwr_irqs[] = {
486#if defined(BF533_FAMILY)
487 IRQ_PROG_INTB
488#elif defined(BF537_FAMILY)
489 IRQ_PROG_INTB, IRQ_PORTG_INTB, IRQ_MAC_TX
490#elif defined(BF538_FAMILY)
491 IRQ_PORTF_INTB
492#elif defined(BF527_FAMILY) || defined(BF518_FAMILY)
493 IRQ_PORTF_INTB, IRQ_PORTG_INTB, IRQ_PORTH_INTB
494#elif defined(BF561_FAMILY)
495 IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB
496#else
497# error no SIC_IWR defined
498#endif
499};
500
588/*********************************************************** 501/***********************************************************
589* 502*
590* FUNCTIONS: Blackfin PM Setup API 503* FUNCTIONS: Blackfin PM Setup API
@@ -669,18 +582,18 @@ u32 bfin_pm_standby_setup(void)
669 mask = wakeup_map[gpio_bank(i)]; 582 mask = wakeup_map[gpio_bank(i)];
670 bank = gpio_bank(i); 583 bank = gpio_bank(i);
671 584
672 gpio_bank_saved[bank].maskb = gpio_bankb[bank]->maskb; 585 gpio_bank_saved[bank].maskb = gpio_array[bank]->maskb;
673 gpio_bankb[bank]->maskb = 0; 586 gpio_array[bank]->maskb = 0;
674 587
675 if (mask) { 588 if (mask) {
676#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) 589#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
677 gpio_bank_saved[bank].fer = *port_fer[bank]; 590 gpio_bank_saved[bank].fer = *port_fer[bank];
678#endif 591#endif
679 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen; 592 gpio_bank_saved[bank].inen = gpio_array[bank]->inen;
680 gpio_bank_saved[bank].polar = gpio_bankb[bank]->polar; 593 gpio_bank_saved[bank].polar = gpio_array[bank]->polar;
681 gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; 594 gpio_bank_saved[bank].dir = gpio_array[bank]->dir;
682 gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; 595 gpio_bank_saved[bank].edge = gpio_array[bank]->edge;
683 gpio_bank_saved[bank].both = gpio_bankb[bank]->both; 596 gpio_bank_saved[bank].both = gpio_array[bank]->both;
684 gpio_bank_saved[bank].reserved = 597 gpio_bank_saved[bank].reserved =
685 reserved_gpio_map[bank]; 598 reserved_gpio_map[bank];
686 599
@@ -700,7 +613,7 @@ u32 bfin_pm_standby_setup(void)
700 } 613 }
701 614
702 bfin_internal_set_wake(sic_iwr_irqs[bank], 1); 615 bfin_internal_set_wake(sic_iwr_irqs[bank], 1);
703 gpio_bankb[bank]->maskb_set = wakeup_map[gpio_bank(i)]; 616 gpio_array[bank]->maskb_set = wakeup_map[gpio_bank(i)];
704 } 617 }
705 } 618 }
706 619
@@ -721,18 +634,18 @@ void bfin_pm_standby_restore(void)
721#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) 634#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
722 *port_fer[bank] = gpio_bank_saved[bank].fer; 635 *port_fer[bank] = gpio_bank_saved[bank].fer;
723#endif 636#endif
724 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen; 637 gpio_array[bank]->inen = gpio_bank_saved[bank].inen;
725 gpio_bankb[bank]->dir = gpio_bank_saved[bank].dir; 638 gpio_array[bank]->dir = gpio_bank_saved[bank].dir;
726 gpio_bankb[bank]->polar = gpio_bank_saved[bank].polar; 639 gpio_array[bank]->polar = gpio_bank_saved[bank].polar;
727 gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; 640 gpio_array[bank]->edge = gpio_bank_saved[bank].edge;
728 gpio_bankb[bank]->both = gpio_bank_saved[bank].both; 641 gpio_array[bank]->both = gpio_bank_saved[bank].both;
729 642
730 reserved_gpio_map[bank] = 643 reserved_gpio_map[bank] =
731 gpio_bank_saved[bank].reserved; 644 gpio_bank_saved[bank].reserved;
732 bfin_internal_set_wake(sic_iwr_irqs[bank], 0); 645 bfin_internal_set_wake(sic_iwr_irqs[bank], 0);
733 } 646 }
734 647
735 gpio_bankb[bank]->maskb = gpio_bank_saved[bank].maskb; 648 gpio_array[bank]->maskb = gpio_bank_saved[bank].maskb;
736 } 649 }
737 AWA_DUMMY_READ(maskb); 650 AWA_DUMMY_READ(maskb);
738} 651}
@@ -745,21 +658,21 @@ void bfin_gpio_pm_hibernate_suspend(void)
745 bank = gpio_bank(i); 658 bank = gpio_bank(i);
746 659
747#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) 660#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
748 gpio_bank_saved[bank].fer = *port_fer[bank]; 661 gpio_bank_saved[bank].fer = *port_fer[bank];
749#if defined(BF527_FAMILY) || defined(BF518_FAMILY) 662#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
750 gpio_bank_saved[bank].mux = *port_mux[bank]; 663 gpio_bank_saved[bank].mux = *port_mux[bank];
751#else 664#else
752 if (bank == 0) 665 if (bank == 0)
753 gpio_bank_saved[bank].mux = bfin_read_PORT_MUX(); 666 gpio_bank_saved[bank].mux = bfin_read_PORT_MUX();
754#endif 667#endif
755#endif 668#endif
756 gpio_bank_saved[bank].data = gpio_bankb[bank]->data; 669 gpio_bank_saved[bank].data = gpio_array[bank]->data;
757 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen; 670 gpio_bank_saved[bank].inen = gpio_array[bank]->inen;
758 gpio_bank_saved[bank].polar = gpio_bankb[bank]->polar; 671 gpio_bank_saved[bank].polar = gpio_array[bank]->polar;
759 gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; 672 gpio_bank_saved[bank].dir = gpio_array[bank]->dir;
760 gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; 673 gpio_bank_saved[bank].edge = gpio_array[bank]->edge;
761 gpio_bank_saved[bank].both = gpio_bankb[bank]->both; 674 gpio_bank_saved[bank].both = gpio_array[bank]->both;
762 gpio_bank_saved[bank].maska = gpio_bankb[bank]->maska; 675 gpio_bank_saved[bank].maska = gpio_array[bank]->maska;
763 } 676 }
764 677
765 AWA_DUMMY_READ(maska); 678 AWA_DUMMY_READ(maska);
@@ -770,27 +683,27 @@ void bfin_gpio_pm_hibernate_restore(void)
770 int i, bank; 683 int i, bank;
771 684
772 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { 685 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
773 bank = gpio_bank(i); 686 bank = gpio_bank(i);
774 687
775#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) 688#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
776#if defined(BF527_FAMILY) || defined(BF518_FAMILY) 689#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
777 *port_mux[bank] = gpio_bank_saved[bank].mux; 690 *port_mux[bank] = gpio_bank_saved[bank].mux;
778#else 691#else
779 if (bank == 0) 692 if (bank == 0)
780 bfin_write_PORT_MUX(gpio_bank_saved[bank].mux); 693 bfin_write_PORT_MUX(gpio_bank_saved[bank].mux);
781#endif 694#endif
782 *port_fer[bank] = gpio_bank_saved[bank].fer; 695 *port_fer[bank] = gpio_bank_saved[bank].fer;
783#endif 696#endif
784 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen; 697 gpio_array[bank]->inen = gpio_bank_saved[bank].inen;
785 gpio_bankb[bank]->dir = gpio_bank_saved[bank].dir; 698 gpio_array[bank]->dir = gpio_bank_saved[bank].dir;
786 gpio_bankb[bank]->polar = gpio_bank_saved[bank].polar; 699 gpio_array[bank]->polar = gpio_bank_saved[bank].polar;
787 gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; 700 gpio_array[bank]->edge = gpio_bank_saved[bank].edge;
788 gpio_bankb[bank]->both = gpio_bank_saved[bank].both; 701 gpio_array[bank]->both = gpio_bank_saved[bank].both;
789 702
790 gpio_bankb[bank]->data_set = gpio_bank_saved[bank].data 703 gpio_array[bank]->data_set = gpio_bank_saved[bank].data
791 | gpio_bank_saved[bank].dir; 704 | gpio_bank_saved[bank].dir;
792 705
793 gpio_bankb[bank]->maska = gpio_bank_saved[bank].maska; 706 gpio_array[bank]->maska = gpio_bank_saved[bank].maska;
794 } 707 }
795 AWA_DUMMY_READ(maska); 708 AWA_DUMMY_READ(maska);
796} 709}
@@ -817,12 +730,12 @@ void bfin_gpio_pm_hibernate_suspend(void)
817 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { 730 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
818 bank = gpio_bank(i); 731 bank = gpio_bank(i);
819 732
820 gpio_bank_saved[bank].fer = gpio_array[bank]->port_fer; 733 gpio_bank_saved[bank].fer = gpio_array[bank]->port_fer;
821 gpio_bank_saved[bank].mux = gpio_array[bank]->port_mux; 734 gpio_bank_saved[bank].mux = gpio_array[bank]->port_mux;
822 gpio_bank_saved[bank].data = gpio_array[bank]->port_data; 735 gpio_bank_saved[bank].data = gpio_array[bank]->data;
823 gpio_bank_saved[bank].data = gpio_array[bank]->port_data; 736 gpio_bank_saved[bank].data = gpio_array[bank]->data;
824 gpio_bank_saved[bank].inen = gpio_array[bank]->port_inen; 737 gpio_bank_saved[bank].inen = gpio_array[bank]->inen;
825 gpio_bank_saved[bank].dir = gpio_array[bank]->port_dir_set; 738 gpio_bank_saved[bank].dir = gpio_array[bank]->dir_set;
826 } 739 }
827} 740}
828 741
@@ -831,21 +744,21 @@ void bfin_gpio_pm_hibernate_restore(void)
831 int i, bank; 744 int i, bank;
832 745
833 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { 746 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
834 bank = gpio_bank(i); 747 bank = gpio_bank(i);
835 748
836 gpio_array[bank]->port_mux = gpio_bank_saved[bank].mux; 749 gpio_array[bank]->port_mux = gpio_bank_saved[bank].mux;
837 gpio_array[bank]->port_fer = gpio_bank_saved[bank].fer; 750 gpio_array[bank]->port_fer = gpio_bank_saved[bank].fer;
838 gpio_array[bank]->port_inen = gpio_bank_saved[bank].inen; 751 gpio_array[bank]->inen = gpio_bank_saved[bank].inen;
839 gpio_array[bank]->port_dir_set = gpio_bank_saved[bank].dir; 752 gpio_array[bank]->dir_set = gpio_bank_saved[bank].dir;
840 gpio_array[bank]->port_set = gpio_bank_saved[bank].data 753 gpio_array[bank]->data_set = gpio_bank_saved[bank].data
841 | gpio_bank_saved[bank].dir; 754 | gpio_bank_saved[bank].dir;
842 } 755 }
843} 756}
844#endif 757#endif
845 758
846unsigned short get_gpio_dir(unsigned gpio) 759unsigned short get_gpio_dir(unsigned gpio)
847{ 760{
848 return (0x01 & (gpio_array[gpio_bank(gpio)]->port_dir_clear >> gpio_sub_n(gpio))); 761 return (0x01 & (gpio_array[gpio_bank(gpio)]->dir_clear >> gpio_sub_n(gpio)));
849} 762}
850EXPORT_SYMBOL(get_gpio_dir); 763EXPORT_SYMBOL(get_gpio_dir);
851 764
@@ -905,9 +818,7 @@ int peripheral_request(unsigned short per, const char *label)
905 */ 818 */
906 819
907#ifdef BF548_FAMILY 820#ifdef BF548_FAMILY
908 u16 funct = get_portmux(ident); 821 if (!((per & P_MAYSHARE) && get_portmux(per) == P_FUNCT2MUX(per))) {
909
910 if (!((per & P_MAYSHARE) && (funct == P_FUNCT2MUX(per)))) {
911#else 822#else
912 if (!(per & P_MAYSHARE)) { 823 if (!(per & P_MAYSHARE)) {
913#endif 824#endif
@@ -931,11 +842,7 @@ int peripheral_request(unsigned short per, const char *label)
931 anyway: 842 anyway:
932 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident); 843 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident);
933 844
934#ifdef BF548_FAMILY 845 portmux_setup(per);
935 portmux_setup(ident, P_FUNCT2MUX(per));
936#else
937 portmux_setup(per, P_FUNCT2MUX(per));
938#endif
939 port_setup(ident, PERIPHERAL_USAGE); 846 port_setup(ident, PERIPHERAL_USAGE);
940 847
941 local_irq_restore_hw(flags); 848 local_irq_restore_hw(flags);
@@ -977,9 +884,6 @@ void peripheral_free(unsigned short per)
977 if (!(per & P_DEFINED)) 884 if (!(per & P_DEFINED))
978 return; 885 return;
979 886
980 if (check_gpio(ident) < 0)
981 return;
982
983 local_irq_save_hw(flags); 887 local_irq_save_hw(flags);
984 888
985 if (unlikely(!(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident)))) { 889 if (unlikely(!(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident)))) {
@@ -1056,9 +960,15 @@ int bfin_gpio_request(unsigned gpio, const char *label)
1056 local_irq_restore_hw(flags); 960 local_irq_restore_hw(flags);
1057 return -EBUSY; 961 return -EBUSY;
1058 } 962 }
1059 if (unlikely(reserved_gpio_irq_map[gpio_bank(gpio)] & gpio_bit(gpio))) 963 if (unlikely(reserved_gpio_irq_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1060 printk(KERN_NOTICE "bfin-gpio: GPIO %d is already reserved as gpio-irq!" 964 printk(KERN_NOTICE "bfin-gpio: GPIO %d is already reserved as gpio-irq!"
1061 " (Documentation/blackfin/bfin-gpio-notes.txt)\n", gpio); 965 " (Documentation/blackfin/bfin-gpio-notes.txt)\n", gpio);
966 }
967#ifndef BF548_FAMILY
968 else { /* Reset POLAR setting when acquiring a gpio for the first time */
969 set_gpio_polar(gpio, 0);
970 }
971#endif
1062 972
1063 reserved_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio); 973 reserved_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio);
1064 set_label(gpio, label); 974 set_label(gpio, label);
@@ -1078,6 +988,8 @@ void bfin_gpio_free(unsigned gpio)
1078 if (check_gpio(gpio) < 0) 988 if (check_gpio(gpio) < 0)
1079 return; 989 return;
1080 990
991 might_sleep();
992
1081 local_irq_save_hw(flags); 993 local_irq_save_hw(flags);
1082 994
1083 if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) { 995 if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) {
@@ -1158,8 +1070,16 @@ void bfin_gpio_irq_free(unsigned gpio)
1158 local_irq_restore_hw(flags); 1070 local_irq_restore_hw(flags);
1159} 1071}
1160 1072
1161 1073static inline void __bfin_gpio_direction_input(unsigned gpio)
1074{
1162#ifdef BF548_FAMILY 1075#ifdef BF548_FAMILY
1076 gpio_array[gpio_bank(gpio)]->dir_clear = gpio_bit(gpio);
1077#else
1078 gpio_array[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
1079#endif
1080 gpio_array[gpio_bank(gpio)]->inen |= gpio_bit(gpio);
1081}
1082
1163int bfin_gpio_direction_input(unsigned gpio) 1083int bfin_gpio_direction_input(unsigned gpio)
1164{ 1084{
1165 unsigned long flags; 1085 unsigned long flags;
@@ -1170,125 +1090,85 @@ int bfin_gpio_direction_input(unsigned gpio)
1170 } 1090 }
1171 1091
1172 local_irq_save_hw(flags); 1092 local_irq_save_hw(flags);
1173 gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); 1093 __bfin_gpio_direction_input(gpio);
1174 gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); 1094 AWA_DUMMY_READ(inen);
1175 local_irq_restore_hw(flags); 1095 local_irq_restore_hw(flags);
1176 1096
1177 return 0; 1097 return 0;
1178} 1098}
1179EXPORT_SYMBOL(bfin_gpio_direction_input); 1099EXPORT_SYMBOL(bfin_gpio_direction_input);
1180 1100
1181int bfin_gpio_direction_output(unsigned gpio, int value) 1101void bfin_gpio_irq_prepare(unsigned gpio)
1182{ 1102{
1103#ifdef BF548_FAMILY
1183 unsigned long flags; 1104 unsigned long flags;
1105#endif
1184 1106
1185 if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { 1107 port_setup(gpio, GPIO_USAGE);
1186 gpio_error(gpio);
1187 return -EINVAL;
1188 }
1189 1108
1109#ifdef BF548_FAMILY
1190 local_irq_save_hw(flags); 1110 local_irq_save_hw(flags);
1191 gpio_array[gpio_bank(gpio)]->port_inen &= ~gpio_bit(gpio); 1111 __bfin_gpio_direction_input(gpio);
1192 gpio_set_value(gpio, value);
1193 gpio_array[gpio_bank(gpio)]->port_dir_set = gpio_bit(gpio);
1194 local_irq_restore_hw(flags); 1112 local_irq_restore_hw(flags);
1195 1113#endif
1196 return 0;
1197} 1114}
1198EXPORT_SYMBOL(bfin_gpio_direction_output);
1199 1115
1200void bfin_gpio_set_value(unsigned gpio, int arg) 1116void bfin_gpio_set_value(unsigned gpio, int arg)
1201{ 1117{
1202 if (arg) 1118 if (arg)
1203 gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); 1119 gpio_array[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
1204 else 1120 else
1205 gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio); 1121 gpio_array[gpio_bank(gpio)]->data_clear = gpio_bit(gpio);
1206} 1122}
1207EXPORT_SYMBOL(bfin_gpio_set_value); 1123EXPORT_SYMBOL(bfin_gpio_set_value);
1208 1124
1209int bfin_gpio_get_value(unsigned gpio) 1125int bfin_gpio_direction_output(unsigned gpio, int value)
1210{
1211 return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio)));
1212}
1213EXPORT_SYMBOL(bfin_gpio_get_value);
1214
1215void bfin_gpio_irq_prepare(unsigned gpio)
1216{ 1126{
1217 unsigned long flags; 1127 unsigned long flags;
1218 1128
1219 port_setup(gpio, GPIO_USAGE); 1129 if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1130 gpio_error(gpio);
1131 return -EINVAL;
1132 }
1220 1133
1221 local_irq_save_hw(flags); 1134 local_irq_save_hw(flags);
1222 gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio);
1223 gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio);
1224 local_irq_restore_hw(flags);
1225}
1226 1135
1136 gpio_array[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
1137 gpio_set_value(gpio, value);
1138#ifdef BF548_FAMILY
1139 gpio_array[gpio_bank(gpio)]->dir_set = gpio_bit(gpio);
1227#else 1140#else
1141 gpio_array[gpio_bank(gpio)]->dir |= gpio_bit(gpio);
1142#endif
1143
1144 AWA_DUMMY_READ(dir);
1145 local_irq_restore_hw(flags);
1146
1147 return 0;
1148}
1149EXPORT_SYMBOL(bfin_gpio_direction_output);
1228 1150
1229int bfin_gpio_get_value(unsigned gpio) 1151int bfin_gpio_get_value(unsigned gpio)
1230{ 1152{
1153#ifdef BF548_FAMILY
1154 return (1 & (gpio_array[gpio_bank(gpio)]->data >> gpio_sub_n(gpio)));
1155#else
1231 unsigned long flags; 1156 unsigned long flags;
1232 int ret;
1233 1157
1234 if (unlikely(get_gpio_edge(gpio))) { 1158 if (unlikely(get_gpio_edge(gpio))) {
1159 int ret;
1235 local_irq_save_hw(flags); 1160 local_irq_save_hw(flags);
1236 set_gpio_edge(gpio, 0); 1161 set_gpio_edge(gpio, 0);
1237 ret = get_gpio_data(gpio); 1162 ret = get_gpio_data(gpio);
1238 set_gpio_edge(gpio, 1); 1163 set_gpio_edge(gpio, 1);
1239 local_irq_restore_hw(flags); 1164 local_irq_restore_hw(flags);
1240
1241 return ret; 1165 return ret;
1242 } else 1166 } else
1243 return get_gpio_data(gpio); 1167 return get_gpio_data(gpio);
1168#endif
1244} 1169}
1245EXPORT_SYMBOL(bfin_gpio_get_value); 1170EXPORT_SYMBOL(bfin_gpio_get_value);
1246 1171
1247
1248int bfin_gpio_direction_input(unsigned gpio)
1249{
1250 unsigned long flags;
1251
1252 if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1253 gpio_error(gpio);
1254 return -EINVAL;
1255 }
1256
1257 local_irq_save_hw(flags);
1258 gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
1259 gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio);
1260 AWA_DUMMY_READ(inen);
1261 local_irq_restore_hw(flags);
1262
1263 return 0;
1264}
1265EXPORT_SYMBOL(bfin_gpio_direction_input);
1266
1267int bfin_gpio_direction_output(unsigned gpio, int value)
1268{
1269 unsigned long flags;
1270
1271 if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1272 gpio_error(gpio);
1273 return -EINVAL;
1274 }
1275
1276 local_irq_save_hw(flags);
1277 gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
1278
1279 if (value)
1280 gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
1281 else
1282 gpio_bankb[gpio_bank(gpio)]->data_clear = gpio_bit(gpio);
1283
1284 gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio);
1285 AWA_DUMMY_READ(dir);
1286 local_irq_restore_hw(flags);
1287
1288 return 0;
1289}
1290EXPORT_SYMBOL(bfin_gpio_direction_output);
1291
1292/* If we are booting from SPI and our board lacks a strong enough pull up, 1172/* If we are booting from SPI and our board lacks a strong enough pull up,
1293 * the core can reset and execute the bootrom faster than the resistor can 1173 * the core can reset and execute the bootrom faster than the resistor can
1294 * pull the signal logically high. To work around this (common) error in 1174 * pull the signal logically high. To work around this (common) error in
@@ -1299,23 +1179,15 @@ EXPORT_SYMBOL(bfin_gpio_direction_output);
1299 * lives here as we need to force all the GPIO states w/out going through 1179 * lives here as we need to force all the GPIO states w/out going through
1300 * BUG() checks and such. 1180 * BUG() checks and such.
1301 */ 1181 */
1302void bfin_gpio_reset_spi0_ssel1(void) 1182void bfin_reset_boot_spi_cs(unsigned short pin)
1303{ 1183{
1304 u16 gpio = P_IDENT(P_SPI0_SSEL1); 1184 unsigned short gpio = P_IDENT(pin);
1305
1306 port_setup(gpio, GPIO_USAGE); 1185 port_setup(gpio, GPIO_USAGE);
1307 gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); 1186 gpio_array[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
1308 AWA_DUMMY_READ(data_set); 1187 AWA_DUMMY_READ(data_set);
1309 udelay(1); 1188 udelay(1);
1310} 1189}
1311 1190
1312void bfin_gpio_irq_prepare(unsigned gpio)
1313{
1314 port_setup(gpio, GPIO_USAGE);
1315}
1316
1317#endif /*BF548_FAMILY */
1318
1319#if defined(CONFIG_PROC_FS) 1191#if defined(CONFIG_PROC_FS)
1320static int gpio_proc_read(char *buf, char **start, off_t offset, 1192static int gpio_proc_read(char *buf, char **start, off_t offset,
1321 int len, int *unused_i, void *unused_v) 1193 int len, int *unused_i, void *unused_v)
@@ -1369,11 +1241,7 @@ int bfin_gpiolib_get_value(struct gpio_chip *chip, unsigned gpio)
1369 1241
1370void bfin_gpiolib_set_value(struct gpio_chip *chip, unsigned gpio, int value) 1242void bfin_gpiolib_set_value(struct gpio_chip *chip, unsigned gpio, int value)
1371{ 1243{
1372#ifdef BF548_FAMILY
1373 return bfin_gpio_set_value(gpio, value); 1244 return bfin_gpio_set_value(gpio, value);
1374#else
1375 return set_gpio_data(gpio, value);
1376#endif
1377} 1245}
1378 1246
1379int bfin_gpiolib_gpio_request(struct gpio_chip *chip, unsigned gpio) 1247int bfin_gpiolib_gpio_request(struct gpio_chip *chip, unsigned gpio)
diff --git a/arch/blackfin/kernel/cplb-mpu/cplbinit.c b/arch/blackfin/kernel/cplb-mpu/cplbinit.c
index bdb958486e76..3e329a6ce041 100644
--- a/arch/blackfin/kernel/cplb-mpu/cplbinit.c
+++ b/arch/blackfin/kernel/cplb-mpu/cplbinit.c
@@ -63,10 +63,8 @@ void __init generate_cplb_tables_cpu(unsigned int cpu)
63 dcplb_tbl[cpu][i_d].addr = 0; 63 dcplb_tbl[cpu][i_d].addr = 0;
64 dcplb_tbl[cpu][i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB; 64 dcplb_tbl[cpu][i_d++].data = SDRAM_OOPS | PAGE_SIZE_1KB;
65 65
66#if 0
67 icplb_tbl[cpu][i_i].addr = 0; 66 icplb_tbl[cpu][i_i].addr = 0;
68 icplb_tbl[cpu][i_i++].data = i_cache | CPLB_USER_RD | PAGE_SIZE_4KB; 67 icplb_tbl[cpu][i_i++].data = i_cache | CPLB_USER_RD | PAGE_SIZE_1KB;
69#endif
70 68
71 /* Cover kernel memory with 4M pages. */ 69 /* Cover kernel memory with 4M pages. */
72 addr = 0; 70 addr = 0;
diff --git a/arch/blackfin/kernel/cplb-nompu/cplbmgr.c b/arch/blackfin/kernel/cplb-nompu/cplbmgr.c
index 376249ab2694..8cbb47c7b663 100644
--- a/arch/blackfin/kernel/cplb-nompu/cplbmgr.c
+++ b/arch/blackfin/kernel/cplb-nompu/cplbmgr.c
@@ -163,12 +163,14 @@ MGR_ATTR static int icplb_miss(int cpu)
163 nr_icplb_supv_miss[cpu]++; 163 nr_icplb_supv_miss[cpu]++;
164 164
165 base = 0; 165 base = 0;
166 for (idx = 0; idx < icplb_nr_bounds; idx++) { 166 idx = 0;
167 do {
167 eaddr = icplb_bounds[idx].eaddr; 168 eaddr = icplb_bounds[idx].eaddr;
168 if (addr < eaddr) 169 if (addr < eaddr)
169 break; 170 break;
170 base = eaddr; 171 base = eaddr;
171 } 172 } while (++idx < icplb_nr_bounds);
173
172 if (unlikely(idx == icplb_nr_bounds)) 174 if (unlikely(idx == icplb_nr_bounds))
173 return CPLB_NO_ADDR_MATCH; 175 return CPLB_NO_ADDR_MATCH;
174 176
@@ -208,12 +210,14 @@ MGR_ATTR static int dcplb_miss(int cpu)
208 nr_dcplb_supv_miss[cpu]++; 210 nr_dcplb_supv_miss[cpu]++;
209 211
210 base = 0; 212 base = 0;
211 for (idx = 0; idx < dcplb_nr_bounds; idx++) { 213 idx = 0;
214 do {
212 eaddr = dcplb_bounds[idx].eaddr; 215 eaddr = dcplb_bounds[idx].eaddr;
213 if (addr < eaddr) 216 if (addr < eaddr)
214 break; 217 break;
215 base = eaddr; 218 base = eaddr;
216 } 219 } while (++idx < dcplb_nr_bounds);
220
217 if (unlikely(idx == dcplb_nr_bounds)) 221 if (unlikely(idx == dcplb_nr_bounds))
218 return CPLB_NO_ADDR_MATCH; 222 return CPLB_NO_ADDR_MATCH;
219 223
diff --git a/arch/blackfin/kernel/irqchip.c b/arch/blackfin/kernel/irqchip.c
index ab8209cbbad0..75724eee6494 100644
--- a/arch/blackfin/kernel/irqchip.c
+++ b/arch/blackfin/kernel/irqchip.c
@@ -35,6 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/irq.h> 36#include <linux/irq.h>
37#include <asm/trace.h> 37#include <asm/trace.h>
38#include <asm/pda.h>
38 39
39static atomic_t irq_err_count; 40static atomic_t irq_err_count;
40static spinlock_t irq_controller_lock; 41static spinlock_t irq_controller_lock;
@@ -91,8 +92,13 @@ int show_interrupts(struct seq_file *p, void *v)
91 seq_putc(p, '\n'); 92 seq_putc(p, '\n');
92 skip: 93 skip:
93 spin_unlock_irqrestore(&irq_desc[i].lock, flags); 94 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
94 } else if (i == NR_IRQS) 95 } else if (i == NR_IRQS) {
96 seq_printf(p, "NMI: ");
97 for_each_online_cpu(j)
98 seq_printf(p, "%10u ", cpu_pda[j].__nmi_count);
99 seq_printf(p, " CORE Non Maskable Interrupt\n");
95 seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count)); 100 seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count));
101 }
96 return 0; 102 return 0;
97} 103}
98 104
diff --git a/arch/blackfin/kernel/reboot.c b/arch/blackfin/kernel/reboot.c
index eeee8cb43360..53d08dee8531 100644
--- a/arch/blackfin/kernel/reboot.c
+++ b/arch/blackfin/kernel/reboot.c
@@ -20,8 +20,8 @@
20 * reset while the Core B bit (on dual core parts) is cleared by 20 * reset while the Core B bit (on dual core parts) is cleared by
21 * the core reset. 21 * the core reset.
22 */ 22 */
23__attribute__((l1_text)) 23__attribute__ ((__l1_text__, __noreturn__))
24static void _bfin_reset(void) 24static void bfin_reset(void)
25{ 25{
26 /* Wait for completion of "system" events such as cache line 26 /* Wait for completion of "system" events such as cache line
27 * line fills so that we avoid infinite stalls later on as 27 * line fills so that we avoid infinite stalls later on as
@@ -30,7 +30,11 @@ static void _bfin_reset(void)
30 */ 30 */
31 __builtin_bfin_ssync(); 31 __builtin_bfin_ssync();
32 32
33 while (1) { 33 /* The bootrom checks to see how it was reset and will
34 * automatically perform a software reset for us when
35 * it starts executing after the core reset.
36 */
37 if (ANOMALY_05000353 || ANOMALY_05000386) {
34 /* Initiate System software reset. */ 38 /* Initiate System software reset. */
35 bfin_write_SWRST(0x7); 39 bfin_write_SWRST(0x7);
36 40
@@ -50,6 +54,11 @@ static void _bfin_reset(void)
50 /* Clear System software reset */ 54 /* Clear System software reset */
51 bfin_write_SWRST(0); 55 bfin_write_SWRST(0);
52 56
57 /* The BF526 ROM will crash during reset */
58#if defined(__ADSPBF522__) || defined(__ADSPBF524__) || defined(__ADSPBF526__)
59 bfin_read_SWRST();
60#endif
61
53 /* Wait for the SWRST write to complete. Cannot rely on SSYNC 62 /* Wait for the SWRST write to complete. Cannot rely on SSYNC
54 * though as the System state is all reset now. 63 * though as the System state is all reset now.
55 */ 64 */
@@ -60,22 +69,11 @@ static void _bfin_reset(void)
60 : "a" (15 * 1) 69 : "a" (15 * 1)
61 : "LC1", "LB1", "LT1" 70 : "LC1", "LB1", "LT1"
62 ); 71 );
72 }
63 73
74 while (1)
64 /* Issue core reset */ 75 /* Issue core reset */
65 asm("raise 1"); 76 asm("raise 1");
66 }
67}
68
69static void bfin_reset(void)
70{
71 if (ANOMALY_05000353 || ANOMALY_05000386)
72 _bfin_reset();
73 else
74 /* the bootrom checks to see how it was reset and will
75 * automatically perform a software reset for us when
76 * it starts executing boot
77 */
78 asm("raise 1;");
79} 77}
80 78
81__attribute__((weak)) 79__attribute__((weak))
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index b2a811347b65..e5c116230800 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -60,7 +60,7 @@ void __initdata *init_retx, *init_saved_retx, *init_saved_seqstat,
60#define BFIN_MEMMAP_MAX 128 /* number of entries in bfin_memmap */ 60#define BFIN_MEMMAP_MAX 128 /* number of entries in bfin_memmap */
61#define BFIN_MEMMAP_RAM 1 61#define BFIN_MEMMAP_RAM 1
62#define BFIN_MEMMAP_RESERVED 2 62#define BFIN_MEMMAP_RESERVED 2
63struct bfin_memmap { 63static struct bfin_memmap {
64 int nr_map; 64 int nr_map;
65 struct bfin_memmap_entry { 65 struct bfin_memmap_entry {
66 unsigned long long addr; /* start of memory segment */ 66 unsigned long long addr; /* start of memory segment */
@@ -824,7 +824,15 @@ void __init setup_arch(char **cmdline_p)
824 flash_probe(); 824 flash_probe();
825#endif 825#endif
826 826
827 printk(KERN_INFO "Boot Mode: %i\n", bfin_read_SYSCR() & 0xF);
828
829 /* Newer parts mirror SWRST bits in SYSCR */
830#if defined(CONFIG_BF53x) || defined(CONFIG_BF561) || \
831 defined(CONFIG_BF538) || defined(CONFIG_BF539)
827 _bfin_swrst = bfin_read_SWRST(); 832 _bfin_swrst = bfin_read_SWRST();
833#else
834 _bfin_swrst = bfin_read_SYSCR();
835#endif
828 836
829#ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT 837#ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT
830 bfin_write_SWRST(_bfin_swrst & ~DOUBLE_FAULT); 838 bfin_write_SWRST(_bfin_swrst & ~DOUBLE_FAULT);
@@ -853,7 +861,7 @@ void __init setup_arch(char **cmdline_p)
853 else if (_bfin_swrst & RESET_SOFTWARE) 861 else if (_bfin_swrst & RESET_SOFTWARE)
854 printk(KERN_NOTICE "Reset caused by Software reset\n"); 862 printk(KERN_NOTICE "Reset caused by Software reset\n");
855 863
856 printk(KERN_INFO "Blackfin support (C) 2004-2008 Analog Devices, Inc.\n"); 864 printk(KERN_INFO "Blackfin support (C) 2004-2009 Analog Devices, Inc.\n");
857 if (bfin_compiled_revid() == 0xffff) 865 if (bfin_compiled_revid() == 0xffff)
858 printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU); 866 printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU);
859 else if (bfin_compiled_revid() == -1) 867 else if (bfin_compiled_revid() == -1)
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index 5b0667da8d05..ffe7fb53eccb 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -673,6 +673,14 @@ static void decode_instruction(unsigned short *address)
673 verbose_printk("RTI"); 673 verbose_printk("RTI");
674 else if (opcode == 0x0012) 674 else if (opcode == 0x0012)
675 verbose_printk("RTX"); 675 verbose_printk("RTX");
676 else if (opcode == 0x0013)
677 verbose_printk("RTN");
678 else if (opcode == 0x0014)
679 verbose_printk("RTE");
680 else if (opcode == 0x0025)
681 verbose_printk("EMUEXCPT");
682 else if (opcode == 0x0040 && opcode <= 0x0047)
683 verbose_printk("STI R%i", opcode & 7);
676 else if (opcode >= 0x0050 && opcode <= 0x0057) 684 else if (opcode >= 0x0050 && opcode <= 0x0057)
677 verbose_printk("JUMP (P%i)", opcode & 7); 685 verbose_printk("JUMP (P%i)", opcode & 7);
678 else if (opcode >= 0x0060 && opcode <= 0x0067) 686 else if (opcode >= 0x0060 && opcode <= 0x0067)
@@ -681,6 +689,10 @@ static void decode_instruction(unsigned short *address)
681 verbose_printk("CALL (PC+P%i)", opcode & 7); 689 verbose_printk("CALL (PC+P%i)", opcode & 7);
682 else if (opcode >= 0x0080 && opcode <= 0x0087) 690 else if (opcode >= 0x0080 && opcode <= 0x0087)
683 verbose_printk("JUMP (PC+P%i)", opcode & 7); 691 verbose_printk("JUMP (PC+P%i)", opcode & 7);
692 else if (opcode >= 0x0090 && opcode <= 0x009F)
693 verbose_printk("RAISE 0x%x", opcode & 0xF);
694 else if (opcode >= 0x00A0 && opcode <= 0x00AF)
695 verbose_printk("EXCPT 0x%x", opcode & 0xF);
684 else if ((opcode >= 0x1000 && opcode <= 0x13FF) || (opcode >= 0x1800 && opcode <= 0x1BFF)) 696 else if ((opcode >= 0x1000 && opcode <= 0x13FF) || (opcode >= 0x1800 && opcode <= 0x1BFF))
685 verbose_printk("IF !CC JUMP"); 697 verbose_printk("IF !CC JUMP");
686 else if ((opcode >= 0x1400 && opcode <= 0x17ff) || (opcode >= 0x1c00 && opcode <= 0x1fff)) 698 else if ((opcode >= 0x1400 && opcode <= 0x17ff) || (opcode >= 0x1c00 && opcode <= 0x1fff))
@@ -820,11 +832,8 @@ void show_stack(struct task_struct *task, unsigned long *stack)
820 decode_address(buf, (unsigned int)stack); 832 decode_address(buf, (unsigned int)stack);
821 printk(KERN_NOTICE " SP: [0x%p] %s\n", stack, buf); 833 printk(KERN_NOTICE " SP: [0x%p] %s\n", stack, buf);
822 834
823 addr = (unsigned int *)((unsigned int)stack & ~0x3F);
824
825 /* First thing is to look for a frame pointer */ 835 /* First thing is to look for a frame pointer */
826 for (addr = (unsigned int *)((unsigned int)stack & ~0xF), i = 0; 836 for (addr = (unsigned int *)((unsigned int)stack & ~0xF); addr < endstack; addr++) {
827 addr < endstack; addr++, i++) {
828 if (*addr & 0x1) 837 if (*addr & 0x1)
829 continue; 838 continue;
830 ins_addr = (unsigned short *)*addr; 839 ins_addr = (unsigned short *)*addr;
@@ -834,7 +843,8 @@ void show_stack(struct task_struct *task, unsigned long *stack)
834 843
835 if (fp) { 844 if (fp) {
836 /* Let's check to see if it is a frame pointer */ 845 /* Let's check to see if it is a frame pointer */
837 while (fp >= (addr - 1) && fp < endstack && fp) 846 while (fp >= (addr - 1) && fp < endstack
847 && fp && ((unsigned int) fp & 0x3) == 0)
838 fp = (unsigned int *)*fp; 848 fp = (unsigned int *)*fp;
839 if (fp == 0 || fp == endstack) { 849 if (fp == 0 || fp == endstack) {
840 fp = addr - 1; 850 fp = addr - 1;
@@ -1052,8 +1062,9 @@ void show_regs(struct pt_regs *fp)
1052 char buf [150]; 1062 char buf [150];
1053 struct irqaction *action; 1063 struct irqaction *action;
1054 unsigned int i; 1064 unsigned int i;
1055 unsigned long flags; 1065 unsigned long flags = 0;
1056 unsigned int cpu = smp_processor_id(); 1066 unsigned int cpu = smp_processor_id();
1067 unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic();
1057 1068
1058 verbose_printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\t\t%s\n", print_tainted()); 1069 verbose_printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\t\t%s\n", print_tainted());
1059 verbose_printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n", 1070 verbose_printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n",
@@ -1073,17 +1084,22 @@ void show_regs(struct pt_regs *fp)
1073 } 1084 }
1074 verbose_printk(KERN_NOTICE " EXCAUSE : 0x%lx\n", 1085 verbose_printk(KERN_NOTICE " EXCAUSE : 0x%lx\n",
1075 fp->seqstat & SEQSTAT_EXCAUSE); 1086 fp->seqstat & SEQSTAT_EXCAUSE);
1076 for (i = 6; i <= 15 ; i++) { 1087 for (i = 2; i <= 15 ; i++) {
1077 if (fp->ipend & (1 << i)) { 1088 if (fp->ipend & (1 << i)) {
1078 decode_address(buf, bfin_read32(EVT0 + 4*i)); 1089 if (i != 4) {
1079 verbose_printk(KERN_NOTICE " physical IVG%i asserted : %s\n", i, buf); 1090 decode_address(buf, bfin_read32(EVT0 + 4*i));
1091 verbose_printk(KERN_NOTICE " physical IVG%i asserted : %s\n", i, buf);
1092 } else
1093 verbose_printk(KERN_NOTICE " interrupts disabled\n");
1080 } 1094 }
1081 } 1095 }
1082 1096
1083 /* if no interrupts are going off, don't print this out */ 1097 /* if no interrupts are going off, don't print this out */
1084 if (fp->ipend & ~0x3F) { 1098 if (fp->ipend & ~0x3F) {
1085 for (i = 0; i < (NR_IRQS - 1); i++) { 1099 for (i = 0; i < (NR_IRQS - 1); i++) {
1086 spin_lock_irqsave(&irq_desc[i].lock, flags); 1100 if (!in_atomic)
1101 spin_lock_irqsave(&irq_desc[i].lock, flags);
1102
1087 action = irq_desc[i].action; 1103 action = irq_desc[i].action;
1088 if (!action) 1104 if (!action)
1089 goto unlock; 1105 goto unlock;
@@ -1096,7 +1112,8 @@ void show_regs(struct pt_regs *fp)
1096 } 1112 }
1097 verbose_printk("\n"); 1113 verbose_printk("\n");
1098unlock: 1114unlock:
1099 spin_unlock_irqrestore(&irq_desc[i].lock, flags); 1115 if (!in_atomic)
1116 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
1100 } 1117 }
1101 } 1118 }
1102 1119
diff --git a/arch/blackfin/mach-bf518/boards/ezbrd.c b/arch/blackfin/mach-bf518/boards/ezbrd.c
index 15f1351c8645..0e175342112e 100644
--- a/arch/blackfin/mach-bf518/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf518/boards/ezbrd.c
@@ -46,6 +46,7 @@
46#include <asm/dpmc.h> 46#include <asm/dpmc.h>
47#include <asm/bfin_sdh.h> 47#include <asm/bfin_sdh.h>
48#include <linux/spi/ad7877.h> 48#include <linux/spi/ad7877.h>
49#include <net/dsa.h>
49 50
50/* 51/*
51 * Name the Board for the /proc/cpuinfo 52 * Name the Board for the /proc/cpuinfo
@@ -104,8 +105,31 @@ static struct platform_device rtc_device = {
104#endif 105#endif
105 106
106#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 107#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
108static struct platform_device bfin_mii_bus = {
109 .name = "bfin_mii_bus",
110};
111
107static struct platform_device bfin_mac_device = { 112static struct platform_device bfin_mac_device = {
108 .name = "bfin_mac", 113 .name = "bfin_mac",
114 .dev.platform_data = &bfin_mii_bus,
115};
116#endif
117
118#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
119static struct dsa_platform_data ksz8893m_switch_data = {
120 .mii_bus = &bfin_mii_bus.dev,
121 .netdev = &bfin_mac_device.dev,
122 .port_names[0] = NULL,
123 .port_names[1] = "eth%d",
124 .port_names[2] = "eth%d",
125 .port_names[3] = "cpu",
126};
127
128static struct platform_device ksz8893m_switch_device = {
129 .name = "dsa",
130 .id = 0,
131 .num_resources = 0,
132 .dev.platform_data = &ksz8893m_switch_data,
109}; 133};
110#endif 134#endif
111 135
@@ -147,6 +171,15 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
147}; 171};
148#endif 172#endif
149 173
174#if defined(CONFIG_NET_DSA_KSZ8893M) \
175 || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
176/* SPI SWITCH CHIP */
177static struct bfin5xx_spi_chip spi_switch_info = {
178 .enable_dma = 0,
179 .bits_per_word = 8,
180};
181#endif
182
150#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE) 183#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
151static struct bfin5xx_spi_chip spi_mmc_chip_info = { 184static struct bfin5xx_spi_chip spi_mmc_chip_info = {
152 .enable_dma = 1, 185 .enable_dma = 1,
@@ -226,6 +259,19 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
226 }, 259 },
227#endif 260#endif
228 261
262#if defined(CONFIG_NET_DSA_KSZ8893M) \
263 || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
264 {
265 .modalias = "ksz8893m",
266 .max_speed_hz = 5000000,
267 .bus_num = 0,
268 .chip_select = 1,
269 .platform_data = NULL,
270 .controller_data = &spi_switch_info,
271 .mode = SPI_MODE_3,
272 },
273#endif
274
229#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE) 275#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
230 { 276 {
231 .modalias = "spi_mmc_dummy", 277 .modalias = "spi_mmc_dummy",
@@ -473,7 +519,6 @@ static struct platform_device i2c_bfin_twi_device = {
473}; 519};
474#endif 520#endif
475 521
476#ifdef CONFIG_I2C_BOARDINFO
477static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 522static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
478#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) 523#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
479 { 524 {
@@ -487,7 +532,6 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
487 }, 532 },
488#endif 533#endif
489}; 534};
490#endif
491 535
492#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 536#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
493static struct platform_device bfin_sport0_uart_device = { 537static struct platform_device bfin_sport0_uart_device = {
@@ -584,9 +628,14 @@ static struct platform_device *stamp_devices[] __initdata = {
584#endif 628#endif
585 629
586#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 630#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
631 &bfin_mii_bus,
587 &bfin_mac_device, 632 &bfin_mac_device,
588#endif 633#endif
589 634
635#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
636 &ksz8893m_switch_device,
637#endif
638
590#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) 639#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
591 &bfin_spi0_device, 640 &bfin_spi0_device,
592 &bfin_spi1_device, 641 &bfin_spi1_device,
@@ -632,12 +681,8 @@ static struct platform_device *stamp_devices[] __initdata = {
632static int __init ezbrd_init(void) 681static int __init ezbrd_init(void)
633{ 682{
634 printk(KERN_INFO "%s(): registering device resources\n", __func__); 683 printk(KERN_INFO "%s(): registering device resources\n", __func__);
635
636#ifdef CONFIG_I2C_BOARDINFO
637 i2c_register_board_info(0, bfin_i2c_board_info, 684 i2c_register_board_info(0, bfin_i2c_board_info,
638 ARRAY_SIZE(bfin_i2c_board_info)); 685 ARRAY_SIZE(bfin_i2c_board_info));
639#endif
640
641 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 686 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
642 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 687 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
643 return 0; 688 return 0;
@@ -649,7 +694,7 @@ void native_machine_restart(char *cmd)
649{ 694{
650 /* workaround reboot hang when booting from SPI */ 695 /* workaround reboot hang when booting from SPI */
651 if ((bfin_read_SYSCR() & 0x7) == 0x3) 696 if ((bfin_read_SYSCR() & 0x7) == 0x3)
652 bfin_gpio_reset_spi0_ssel1(); 697 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
653} 698}
654 699
655void bfin_get_ether_addr(char *addr) 700void bfin_get_ether_addr(char *addr)
diff --git a/arch/blackfin/mach-bf518/include/mach/portmux.h b/arch/blackfin/mach-bf518/include/mach/portmux.h
index ac16d54734d4..f618b487b2b0 100644
--- a/arch/blackfin/mach-bf518/include/mach/portmux.h
+++ b/arch/blackfin/mach-bf518/include/mach/portmux.h
@@ -103,6 +103,8 @@
103#define P_SPI1_SSEL4 (P_DEFINED | P_IDENT(GPIO_PF8) | P_FUNCT(2)) 103#define P_SPI1_SSEL4 (P_DEFINED | P_IDENT(GPIO_PF8) | P_FUNCT(2))
104#define P_SPI1_SSEL5 (P_DEFINED | P_IDENT(GPIO_PG11) | P_FUNCT(2)) 104#define P_SPI1_SSEL5 (P_DEFINED | P_IDENT(GPIO_PG11) | P_FUNCT(2))
105 105
106#define P_DEFAULT_BOOT_SPI_CS P_SPI0_SSEL2
107
106/* SPORT Port Mux */ 108/* SPORT Port Mux */
107#define P_SPORT0_DRPRI (P_DEFINED | P_IDENT(GPIO_PG3) | P_FUNCT(0)) 109#define P_SPORT0_DRPRI (P_DEFINED | P_IDENT(GPIO_PG3) | P_FUNCT(0))
108#define P_SPORT0_RSCLK (P_DEFINED | P_IDENT(GPIO_PG4) | P_FUNCT(0)) 110#define P_SPORT0_RSCLK (P_DEFINED | P_IDENT(GPIO_PG4) | P_FUNCT(0))
diff --git a/arch/blackfin/mach-bf527/boards/cm_bf527.c b/arch/blackfin/mach-bf527/boards/cm_bf527.c
index a2c3578f4b6c..856c097b5317 100644
--- a/arch/blackfin/mach-bf527/boards/cm_bf527.c
+++ b/arch/blackfin/mach-bf527/boards/cm_bf527.c
@@ -403,8 +403,13 @@ static struct platform_device isp1362_hcd_device = {
403#endif 403#endif
404 404
405#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 405#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
406static struct platform_device bfin_mii_bus = {
407 .name = "bfin_mii_bus",
408};
409
406static struct platform_device bfin_mac_device = { 410static struct platform_device bfin_mac_device = {
407 .name = "bfin_mac", 411 .name = "bfin_mac",
412 .dev.platform_data = &bfin_mii_bus,
408}; 413};
409#endif 414#endif
410 415
@@ -793,7 +798,6 @@ static struct platform_device i2c_bfin_twi_device = {
793}; 798};
794#endif 799#endif
795 800
796#ifdef CONFIG_I2C_BOARDINFO
797static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 801static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
798#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) 802#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
799 { 803 {
@@ -809,7 +813,6 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
809 }, 813 },
810#endif 814#endif
811}; 815};
812#endif
813 816
814#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 817#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
815static struct platform_device bfin_sport0_uart_device = { 818static struct platform_device bfin_sport0_uart_device = {
@@ -920,6 +923,7 @@ static struct platform_device *stamp_devices[] __initdata = {
920#endif 923#endif
921 924
922#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 925#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
926 &bfin_mii_bus,
923 &bfin_mac_device, 927 &bfin_mac_device,
924#endif 928#endif
925 929
@@ -968,27 +972,23 @@ static struct platform_device *stamp_devices[] __initdata = {
968 &bfin_gpios_device, 972 &bfin_gpios_device,
969}; 973};
970 974
971static int __init stamp_init(void) 975static int __init cm_init(void)
972{ 976{
973 printk(KERN_INFO "%s(): registering device resources\n", __func__); 977 printk(KERN_INFO "%s(): registering device resources\n", __func__);
974
975#ifdef CONFIG_I2C_BOARDINFO
976 i2c_register_board_info(0, bfin_i2c_board_info, 978 i2c_register_board_info(0, bfin_i2c_board_info,
977 ARRAY_SIZE(bfin_i2c_board_info)); 979 ARRAY_SIZE(bfin_i2c_board_info));
978#endif
979
980 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 980 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
981 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 981 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
982 return 0; 982 return 0;
983} 983}
984 984
985arch_initcall(stamp_init); 985arch_initcall(cm_init);
986 986
987void native_machine_restart(char *cmd) 987void native_machine_restart(char *cmd)
988{ 988{
989 /* workaround reboot hang when booting from SPI */ 989 /* workaround reboot hang when booting from SPI */
990 if ((bfin_read_SYSCR() & 0x7) == 0x3) 990 if ((bfin_read_SYSCR() & 0x7) == 0x3)
991 bfin_gpio_reset_spi0_ssel1(); 991 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
992} 992}
993 993
994void bfin_get_ether_addr(char *addr) 994void bfin_get_ether_addr(char *addr)
diff --git a/arch/blackfin/mach-bf527/boards/ezbrd.c b/arch/blackfin/mach-bf527/boards/ezbrd.c
index 0314bd3355eb..83606fcdde27 100644
--- a/arch/blackfin/mach-bf527/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf527/boards/ezbrd.c
@@ -208,8 +208,13 @@ static struct platform_device rtc_device = {
208 208
209 209
210#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 210#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
211static struct platform_device bfin_mii_bus = {
212 .name = "bfin_mii_bus",
213};
214
211static struct platform_device bfin_mac_device = { 215static struct platform_device bfin_mac_device = {
212 .name = "bfin_mac", 216 .name = "bfin_mac",
217 .dev.platform_data = &bfin_mii_bus,
213}; 218};
214#endif 219#endif
215 220
@@ -590,7 +595,6 @@ static struct platform_device i2c_bfin_twi_device = {
590}; 595};
591#endif 596#endif
592 597
593#ifdef CONFIG_I2C_BOARDINFO
594static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 598static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
595#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) 599#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
596 { 600 {
@@ -604,7 +608,6 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
604 }, 608 },
605#endif 609#endif
606}; 610};
607#endif
608 611
609#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 612#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
610static struct platform_device bfin_sport0_uart_device = { 613static struct platform_device bfin_sport0_uart_device = {
@@ -720,6 +723,7 @@ static struct platform_device *stamp_devices[] __initdata = {
720#endif 723#endif
721 724
722#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 725#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
726 &bfin_mii_bus,
723 &bfin_mac_device, 727 &bfin_mac_device,
724#endif 728#endif
725 729
@@ -764,27 +768,23 @@ static struct platform_device *stamp_devices[] __initdata = {
764 &bfin_gpios_device, 768 &bfin_gpios_device,
765}; 769};
766 770
767static int __init stamp_init(void) 771static int __init ezbrd_init(void)
768{ 772{
769 printk(KERN_INFO "%s(): registering device resources\n", __func__); 773 printk(KERN_INFO "%s(): registering device resources\n", __func__);
770
771#ifdef CONFIG_I2C_BOARDINFO
772 i2c_register_board_info(0, bfin_i2c_board_info, 774 i2c_register_board_info(0, bfin_i2c_board_info,
773 ARRAY_SIZE(bfin_i2c_board_info)); 775 ARRAY_SIZE(bfin_i2c_board_info));
774#endif
775
776 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 776 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
777 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 777 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
778 return 0; 778 return 0;
779} 779}
780 780
781arch_initcall(stamp_init); 781arch_initcall(ezbrd_init);
782 782
783void native_machine_restart(char *cmd) 783void native_machine_restart(char *cmd)
784{ 784{
785 /* workaround reboot hang when booting from SPI */ 785 /* workaround reboot hang when booting from SPI */
786 if ((bfin_read_SYSCR() & 0x7) == 0x3) 786 if ((bfin_read_SYSCR() & 0x7) == 0x3)
787 bfin_gpio_reset_spi0_ssel1(); 787 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
788} 788}
789 789
790void bfin_get_ether_addr(char *addr) 790void bfin_get_ether_addr(char *addr)
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index 9454fb7b18c3..d0864111ef59 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -425,8 +425,13 @@ static struct platform_device isp1362_hcd_device = {
425#endif 425#endif
426 426
427#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 427#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
428static struct platform_device bfin_mii_bus = {
429 .name = "bfin_mii_bus",
430};
431
428static struct platform_device bfin_mac_device = { 432static struct platform_device bfin_mac_device = {
429 .name = "bfin_mac", 433 .name = "bfin_mac",
434 .dev.platform_data = &bfin_mii_bus,
430}; 435};
431#endif 436#endif
432 437
@@ -830,7 +835,6 @@ static struct platform_device i2c_bfin_twi_device = {
830}; 835};
831#endif 836#endif
832 837
833#ifdef CONFIG_I2C_BOARDINFO
834static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 838static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
835#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) 839#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
836 { 840 {
@@ -844,7 +848,6 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
844 }, 848 },
845#endif 849#endif
846}; 850};
847#endif
848 851
849#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 852#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
850static struct platform_device bfin_sport0_uart_device = { 853static struct platform_device bfin_sport0_uart_device = {
@@ -988,6 +991,7 @@ static struct platform_device *stamp_devices[] __initdata = {
988#endif 991#endif
989 992
990#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 993#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
994 &bfin_mii_bus,
991 &bfin_mac_device, 995 &bfin_mac_device,
992#endif 996#endif
993 997
@@ -1048,27 +1052,23 @@ static struct platform_device *stamp_devices[] __initdata = {
1048 &bfin_gpios_device, 1052 &bfin_gpios_device,
1049}; 1053};
1050 1054
1051static int __init stamp_init(void) 1055static int __init ezkit_init(void)
1052{ 1056{
1053 printk(KERN_INFO "%s(): registering device resources\n", __func__); 1057 printk(KERN_INFO "%s(): registering device resources\n", __func__);
1054
1055#ifdef CONFIG_I2C_BOARDINFO
1056 i2c_register_board_info(0, bfin_i2c_board_info, 1058 i2c_register_board_info(0, bfin_i2c_board_info,
1057 ARRAY_SIZE(bfin_i2c_board_info)); 1059 ARRAY_SIZE(bfin_i2c_board_info));
1058#endif
1059
1060 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 1060 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
1061 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 1061 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
1062 return 0; 1062 return 0;
1063} 1063}
1064 1064
1065arch_initcall(stamp_init); 1065arch_initcall(ezkit_init);
1066 1066
1067void native_machine_restart(char *cmd) 1067void native_machine_restart(char *cmd)
1068{ 1068{
1069 /* workaround reboot hang when booting from SPI */ 1069 /* workaround reboot hang when booting from SPI */
1070 if ((bfin_read_SYSCR() & 0x7) == 0x3) 1070 if ((bfin_read_SYSCR() & 0x7) == 0x3)
1071 bfin_gpio_reset_spi0_ssel1(); 1071 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
1072} 1072}
1073 1073
1074void bfin_get_ether_addr(char *addr) 1074void bfin_get_ether_addr(char *addr)
diff --git a/arch/blackfin/mach-bf527/include/mach/portmux.h b/arch/blackfin/mach-bf527/include/mach/portmux.h
index 7f6da2c386bb..72b1652be4da 100644
--- a/arch/blackfin/mach-bf527/include/mach/portmux.h
+++ b/arch/blackfin/mach-bf527/include/mach/portmux.h
@@ -73,6 +73,8 @@
73 73
74#define P_HWAIT (P_DONTCARE) 74#define P_HWAIT (P_DONTCARE)
75 75
76#define P_DEFAULT_BOOT_SPI_CS P_SPI0_SSEL1
77
76#define P_SPI0_SS (P_DEFINED | P_IDENT(GPIO_PG1) | P_FUNCT(0)) 78#define P_SPI0_SS (P_DEFINED | P_IDENT(GPIO_PG1) | P_FUNCT(0))
77#define P_SPI0_SSEL1 (P_DEFINED | P_IDENT(GPIO_PG1) | P_FUNCT(2)) 79#define P_SPI0_SSEL1 (P_DEFINED | P_IDENT(GPIO_PG1) | P_FUNCT(2))
78#define P_SPI0_SCK (P_DEFINED | P_IDENT(GPIO_PG2) | P_FUNCT(2)) 80#define P_SPI0_SCK (P_DEFINED | P_IDENT(GPIO_PG2) | P_FUNCT(2))
diff --git a/arch/blackfin/mach-bf533/boards/blackstamp.c b/arch/blackfin/mach-bf533/boards/blackstamp.c
index 6ee607c259ac..015c18f85e7f 100644
--- a/arch/blackfin/mach-bf533/boards/blackstamp.c
+++ b/arch/blackfin/mach-bf533/boards/blackstamp.c
@@ -309,10 +309,8 @@ static struct platform_device i2c_gpio_device = {
309}; 309};
310#endif 310#endif
311 311
312#ifdef CONFIG_I2C_BOARDINFO
313static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 312static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
314}; 313};
315#endif
316 314
317static const unsigned int cclk_vlev_datasheet[] = 315static const unsigned int cclk_vlev_datasheet[] =
318{ 316{
@@ -390,10 +388,8 @@ static int __init blackstamp_init(void)
390 388
391 printk(KERN_INFO "%s(): registering device resources\n", __func__); 389 printk(KERN_INFO "%s(): registering device resources\n", __func__);
392 390
393#ifdef CONFIG_I2C_BOARDINFO
394 i2c_register_board_info(0, bfin_i2c_board_info, 391 i2c_register_board_info(0, bfin_i2c_board_info,
395 ARRAY_SIZE(bfin_i2c_board_info)); 392 ARRAY_SIZE(bfin_i2c_board_info));
396#endif
397 393
398 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 394 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
399 if (ret < 0) 395 if (ret < 0)
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c
index 07f9ad1e189c..db96f33f72e2 100644
--- a/arch/blackfin/mach-bf533/boards/stamp.c
+++ b/arch/blackfin/mach-bf533/boards/stamp.c
@@ -441,7 +441,6 @@ static struct platform_device i2c_gpio_device = {
441}; 441};
442#endif 442#endif
443 443
444#ifdef CONFIG_I2C_BOARDINFO
445static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 444static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
446#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE) 445#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
447 { 446 {
@@ -461,7 +460,6 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
461 }, 460 },
462#endif 461#endif
463}; 462};
464#endif
465 463
466static const unsigned int cclk_vlev_datasheet[] = 464static const unsigned int cclk_vlev_datasheet[] =
467{ 465{
@@ -550,10 +548,8 @@ static int __init stamp_init(void)
550 548
551 printk(KERN_INFO "%s(): registering device resources\n", __func__); 549 printk(KERN_INFO "%s(): registering device resources\n", __func__);
552 550
553#ifdef CONFIG_I2C_BOARDINFO
554 i2c_register_board_info(0, bfin_i2c_board_info, 551 i2c_register_board_info(0, bfin_i2c_board_info,
555 ARRAY_SIZE(bfin_i2c_board_info)); 552 ARRAY_SIZE(bfin_i2c_board_info));
556#endif
557 553
558 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 554 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
559 if (ret < 0) 555 if (ret < 0)
diff --git a/arch/blackfin/mach-bf533/include/mach/portmux.h b/arch/blackfin/mach-bf533/include/mach/portmux.h
index 685a2651dcda..2f59ce0b0cb5 100644
--- a/arch/blackfin/mach-bf533/include/mach/portmux.h
+++ b/arch/blackfin/mach-bf533/include/mach/portmux.h
@@ -54,14 +54,11 @@
54#define P_SPI0_SSEL2 (P_DEFINED | P_IDENT(GPIO_PF2)) 54#define P_SPI0_SSEL2 (P_DEFINED | P_IDENT(GPIO_PF2))
55#define P_SPI0_SSEL1 (P_DEFINED | P_IDENT(GPIO_PF1)) 55#define P_SPI0_SSEL1 (P_DEFINED | P_IDENT(GPIO_PF1))
56#define P_SPI0_SS (P_DEFINED | P_IDENT(GPIO_PF0)) 56#define P_SPI0_SS (P_DEFINED | P_IDENT(GPIO_PF0))
57#define P_DEFAULT_BOOT_SPI_CS P_SPI0_SSEL2
57 58
58#define P_TMR2 (P_DONTCARE) 59#define P_TMR2 (P_DONTCARE)
59#define P_TMR1 (P_DONTCARE) 60#define P_TMR1 (P_DONTCARE)
60#define P_TMR0 (P_DONTCARE) 61#define P_TMR0 (P_DONTCARE)
61#define P_TMRCLK (P_DEFINED | P_IDENT(GPIO_PF1)) 62#define P_TMRCLK (P_DEFINED | P_IDENT(GPIO_PF1))
62 63
63
64
65
66
67#endif /* _MACH_PORTMUX_H_ */ 64#endif /* _MACH_PORTMUX_H_ */
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537.c b/arch/blackfin/mach-bf537/boards/cm_bf537.c
index 6ac8e4d5bd38..9cd8fb2a30d3 100644
--- a/arch/blackfin/mach-bf537/boards/cm_bf537.c
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537.c
@@ -479,8 +479,13 @@ static struct platform_device bfin_sport1_uart_device = {
479#endif 479#endif
480 480
481#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 481#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
482static struct platform_device bfin_mii_bus = {
483 .name = "bfin_mii_bus",
484};
485
482static struct platform_device bfin_mac_device = { 486static struct platform_device bfin_mac_device = {
483 .name = "bfin_mac", 487 .name = "bfin_mac",
488 .dev.platform_data = &bfin_mii_bus,
484}; 489};
485#endif 490#endif
486 491
@@ -591,6 +596,7 @@ static struct platform_device *cm_bf537_devices[] __initdata = {
591#endif 596#endif
592 597
593#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 598#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
599 &bfin_mii_bus,
594 &bfin_mac_device, 600 &bfin_mac_device,
595#endif 601#endif
596 602
diff --git a/arch/blackfin/mach-bf537/boards/generic_board.c b/arch/blackfin/mach-bf537/boards/generic_board.c
index dd6e6bfb98ea..da710fdc4569 100644
--- a/arch/blackfin/mach-bf537/boards/generic_board.c
+++ b/arch/blackfin/mach-bf537/boards/generic_board.c
@@ -262,8 +262,13 @@ static struct platform_device isp1362_hcd_device = {
262#endif 262#endif
263 263
264#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 264#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
265static struct platform_device bfin_mii_bus = {
266 .name = "bfin_mii_bus",
267};
268
265static struct platform_device bfin_mac_device = { 269static struct platform_device bfin_mac_device = {
266 .name = "bfin_mac", 270 .name = "bfin_mac",
271 .dev.platform_data = &bfin_mii_bus,
267}; 272};
268#endif 273#endif
269 274
@@ -662,6 +667,7 @@ static struct platform_device *stamp_devices[] __initdata = {
662#endif 667#endif
663 668
664#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 669#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
670 &bfin_mii_bus,
665 &bfin_mac_device, 671 &bfin_mac_device,
666#endif 672#endif
667 673
@@ -708,7 +714,7 @@ static struct platform_device *stamp_devices[] __initdata = {
708#endif 714#endif
709}; 715};
710 716
711static int __init stamp_init(void) 717static int __init generic_init(void)
712{ 718{
713 printk(KERN_INFO "%s(): registering device resources\n", __func__); 719 printk(KERN_INFO "%s(): registering device resources\n", __func__);
714 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 720 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
@@ -720,13 +726,13 @@ static int __init stamp_init(void)
720 return 0; 726 return 0;
721} 727}
722 728
723arch_initcall(stamp_init); 729arch_initcall(generic_init);
724 730
725void native_machine_restart(char *cmd) 731void native_machine_restart(char *cmd)
726{ 732{
727 /* workaround reboot hang when booting from SPI */ 733 /* workaround reboot hang when booting from SPI */
728 if ((bfin_read_SYSCR() & 0x7) == 0x3) 734 if ((bfin_read_SYSCR() & 0x7) == 0x3)
729 bfin_gpio_reset_spi0_ssel1(); 735 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
730} 736}
731 737
732#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 738#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
diff --git a/arch/blackfin/mach-bf537/boards/minotaur.c b/arch/blackfin/mach-bf537/boards/minotaur.c
index bb795341cb17..db7d3a385e4b 100644
--- a/arch/blackfin/mach-bf537/boards/minotaur.c
+++ b/arch/blackfin/mach-bf537/boards/minotaur.c
@@ -61,8 +61,13 @@ static struct platform_device rtc_device = {
61#endif 61#endif
62 62
63#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 63#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
64static struct platform_device bfin_mii_bus = {
65 .name = "bfin_mii_bus",
66};
67
64static struct platform_device bfin_mac_device = { 68static struct platform_device bfin_mac_device = {
65 .name = "bfin_mac", 69 .name = "bfin_mac",
70 .dev.platform_data = &bfin_mii_bus,
66}; 71};
67#endif 72#endif
68 73
@@ -324,6 +329,7 @@ static struct platform_device *minotaur_devices[] __initdata = {
324#endif 329#endif
325 330
326#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 331#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
332 &bfin_mii_bus,
327 &bfin_mac_device, 333 &bfin_mac_device,
328#endif 334#endif
329 335
@@ -377,5 +383,5 @@ void native_machine_restart(char *cmd)
377{ 383{
378 /* workaround reboot hang when booting from SPI */ 384 /* workaround reboot hang when booting from SPI */
379 if ((bfin_read_SYSCR() & 0x7) == 0x3) 385 if ((bfin_read_SYSCR() & 0x7) == 0x3)
380 bfin_gpio_reset_spi0_ssel1(); 386 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
381} 387}
diff --git a/arch/blackfin/mach-bf537/boards/pnav10.c b/arch/blackfin/mach-bf537/boards/pnav10.c
index 89de94f4545d..590eb3a139b7 100644
--- a/arch/blackfin/mach-bf537/boards/pnav10.c
+++ b/arch/blackfin/mach-bf537/boards/pnav10.c
@@ -198,8 +198,13 @@ static struct platform_device isp1362_hcd_device = {
198#endif 198#endif
199 199
200#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 200#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
201static struct platform_device bfin_mii_bus = {
202 .name = "bfin_mii_bus",
203};
204
201static struct platform_device bfin_mac_device = { 205static struct platform_device bfin_mac_device = {
202 .name = "bfin_mac", 206 .name = "bfin_mac",
207 .dev.platform_data = &bfin_mii_bus,
203}; 208};
204#endif 209#endif
205 210
@@ -529,6 +534,7 @@ static struct platform_device *stamp_devices[] __initdata = {
529#endif 534#endif
530 535
531#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 536#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
537 &bfin_mii_bus,
532 &bfin_mac_device, 538 &bfin_mac_device,
533#endif 539#endif
534 540
@@ -558,7 +564,7 @@ static struct platform_device *stamp_devices[] __initdata = {
558#endif 564#endif
559}; 565};
560 566
561static int __init stamp_init(void) 567static int __init pnav_init(void)
562{ 568{
563 printk(KERN_INFO "%s(): registering device resources\n", __func__); 569 printk(KERN_INFO "%s(): registering device resources\n", __func__);
564 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 570 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
@@ -569,7 +575,7 @@ static int __init stamp_init(void)
569 return 0; 575 return 0;
570} 576}
571 577
572arch_initcall(stamp_init); 578arch_initcall(pnav_init);
573 579
574void bfin_get_ether_addr(char *addr) 580void bfin_get_ether_addr(char *addr)
575{ 581{
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index d812e2514a2f..cd04c5e44878 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -321,8 +321,13 @@ static struct platform_device isp1362_hcd_device = {
321#endif 321#endif
322 322
323#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 323#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
324static struct platform_device bfin_mii_bus = {
325 .name = "bfin_mii_bus",
326};
327
324static struct platform_device bfin_mac_device = { 328static struct platform_device bfin_mac_device = {
325 .name = "bfin_mac", 329 .name = "bfin_mac",
330 .dev.platform_data = &bfin_mii_bus,
326}; 331};
327#endif 332#endif
328 333
@@ -1068,7 +1073,6 @@ static struct adp5588_kpad_platform_data adp5588_kpad_data = {
1068}; 1073};
1069#endif 1074#endif
1070 1075
1071#ifdef CONFIG_I2C_BOARDINFO
1072static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 1076static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1073#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE) 1077#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
1074 { 1078 {
@@ -1102,7 +1106,6 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1102 }, 1106 },
1103#endif 1107#endif
1104}; 1108};
1105#endif
1106 1109
1107#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 1110#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
1108static struct platform_device bfin_sport0_uart_device = { 1111static struct platform_device bfin_sport0_uart_device = {
@@ -1217,6 +1220,7 @@ static struct platform_device *stamp_devices[] __initdata = {
1217#endif 1220#endif
1218 1221
1219#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 1222#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
1223 &bfin_mii_bus,
1220 &bfin_mac_device, 1224 &bfin_mac_device,
1221#endif 1225#endif
1222 1226
@@ -1284,12 +1288,8 @@ static struct platform_device *stamp_devices[] __initdata = {
1284static int __init stamp_init(void) 1288static int __init stamp_init(void)
1285{ 1289{
1286 printk(KERN_INFO "%s(): registering device resources\n", __func__); 1290 printk(KERN_INFO "%s(): registering device resources\n", __func__);
1287
1288#ifdef CONFIG_I2C_BOARDINFO
1289 i2c_register_board_info(0, bfin_i2c_board_info, 1291 i2c_register_board_info(0, bfin_i2c_board_info,
1290 ARRAY_SIZE(bfin_i2c_board_info)); 1292 ARRAY_SIZE(bfin_i2c_board_info));
1291#endif
1292
1293 bfin_plat_nand_init(); 1293 bfin_plat_nand_init();
1294 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 1294 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
1295 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 1295 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
@@ -1307,7 +1307,7 @@ void native_machine_restart(char *cmd)
1307{ 1307{
1308 /* workaround reboot hang when booting from SPI */ 1308 /* workaround reboot hang when booting from SPI */
1309 if ((bfin_read_SYSCR() & 0x7) == 0x3) 1309 if ((bfin_read_SYSCR() & 0x7) == 0x3)
1310 bfin_gpio_reset_spi0_ssel1(); 1310 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
1311} 1311}
1312 1312
1313/* 1313/*
diff --git a/arch/blackfin/mach-bf537/boards/tcm_bf537.c b/arch/blackfin/mach-bf537/boards/tcm_bf537.c
index 2f4b066153c5..3f4f203a06ec 100644
--- a/arch/blackfin/mach-bf537/boards/tcm_bf537.c
+++ b/arch/blackfin/mach-bf537/boards/tcm_bf537.c
@@ -481,8 +481,13 @@ static struct platform_device bfin_sport1_uart_device = {
481#endif 481#endif
482 482
483#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 483#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
484static struct platform_device bfin_mii_bus = {
485 .name = "bfin_mii_bus",
486};
487
484static struct platform_device bfin_mac_device = { 488static struct platform_device bfin_mac_device = {
485 .name = "bfin_mac", 489 .name = "bfin_mac",
490 .dev.platform_data = &bfin_mii_bus,
486}; 491};
487#endif 492#endif
488 493
@@ -593,6 +598,7 @@ static struct platform_device *cm_bf537_devices[] __initdata = {
593#endif 598#endif
594 599
595#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 600#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
601 &bfin_mii_bus,
596 &bfin_mac_device, 602 &bfin_mac_device,
597#endif 603#endif
598 604
@@ -615,7 +621,7 @@ static struct platform_device *cm_bf537_devices[] __initdata = {
615 &bfin_gpios_device, 621 &bfin_gpios_device,
616}; 622};
617 623
618static int __init cm_bf537_init(void) 624static int __init tcm_bf537_init(void)
619{ 625{
620 printk(KERN_INFO "%s(): registering device resources\n", __func__); 626 printk(KERN_INFO "%s(): registering device resources\n", __func__);
621 platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices)); 627 platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices));
@@ -629,7 +635,7 @@ static int __init cm_bf537_init(void)
629 return 0; 635 return 0;
630} 636}
631 637
632arch_initcall(cm_bf537_init); 638arch_initcall(tcm_bf537_init);
633 639
634void bfin_get_ether_addr(char *addr) 640void bfin_get_ether_addr(char *addr)
635{ 641{
diff --git a/arch/blackfin/mach-bf537/include/mach/portmux.h b/arch/blackfin/mach-bf537/include/mach/portmux.h
index 78fee6e0f237..87285e75e903 100644
--- a/arch/blackfin/mach-bf537/include/mach/portmux.h
+++ b/arch/blackfin/mach-bf537/include/mach/portmux.h
@@ -31,6 +31,7 @@
31#define P_PPI0_FS1 (P_DEFINED | P_IDENT(GPIO_PF9) | P_FUNCT(1)) 31#define P_PPI0_FS1 (P_DEFINED | P_IDENT(GPIO_PF9) | P_FUNCT(1))
32#define P_TACLK0 (P_DEFINED | P_IDENT(GPIO_PF14) | P_FUNCT(1)) 32#define P_TACLK0 (P_DEFINED | P_IDENT(GPIO_PF14) | P_FUNCT(1))
33#define P_TMRCLK (P_DEFINED | P_IDENT(GPIO_PF15) | P_FUNCT(1)) 33#define P_TMRCLK (P_DEFINED | P_IDENT(GPIO_PF15) | P_FUNCT(1))
34#define P_DEFAULT_BOOT_SPI_CS P_SPI0_SSEL1
34 35
35#define P_PPI0_D0 (P_DEFINED | P_IDENT(GPIO_PG0) | P_FUNCT(0)) 36#define P_PPI0_D0 (P_DEFINED | P_IDENT(GPIO_PG0) | P_FUNCT(0))
36#define P_PPI0_D1 (P_DEFINED | P_IDENT(GPIO_PG1) | P_FUNCT(0)) 37#define P_PPI0_D1 (P_DEFINED | P_IDENT(GPIO_PG1) | P_FUNCT(0))
diff --git a/arch/blackfin/mach-bf538/include/mach/portmux.h b/arch/blackfin/mach-bf538/include/mach/portmux.h
index 1e031b588b47..c8db264e3e4d 100644
--- a/arch/blackfin/mach-bf538/include/mach/portmux.h
+++ b/arch/blackfin/mach-bf538/include/mach/portmux.h
@@ -102,5 +102,6 @@
102#define P_SPI0_SSEL2 (P_DEFINED | P_IDENT(GPIO_PF2)) 102#define P_SPI0_SSEL2 (P_DEFINED | P_IDENT(GPIO_PF2))
103#define P_SPI0_SSEL1 (P_DEFINED | P_IDENT(GPIO_PF1)) 103#define P_SPI0_SSEL1 (P_DEFINED | P_IDENT(GPIO_PF1))
104#define P_SPI0_SS (P_DEFINED | P_IDENT(GPIO_PF0)) 104#define P_SPI0_SS (P_DEFINED | P_IDENT(GPIO_PF0))
105#define P_DEFAULT_BOOT_SPI_CS P_SPI0_SSEL2
105 106
106#endif /* _MACH_PORTMUX_H_ */ 107#endif /* _MACH_PORTMUX_H_ */
diff --git a/arch/blackfin/mach-bf548/boards/ezkit.c b/arch/blackfin/mach-bf548/boards/ezkit.c
index 309c16014cae..096e661700a7 100644
--- a/arch/blackfin/mach-bf548/boards/ezkit.c
+++ b/arch/blackfin/mach-bf548/boards/ezkit.c
@@ -781,7 +781,6 @@ static struct platform_device i2c_bfin_twi1_device = {
781#endif 781#endif
782#endif 782#endif
783 783
784#ifdef CONFIG_I2C_BOARDINFO
785static struct i2c_board_info __initdata bfin_i2c_board_info0[] = { 784static struct i2c_board_info __initdata bfin_i2c_board_info0[] = {
786}; 785};
787 786
@@ -800,7 +799,6 @@ static struct i2c_board_info __initdata bfin_i2c_board_info1[] = {
800#endif 799#endif
801}; 800};
802#endif 801#endif
803#endif
804 802
805#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 803#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
806#include <linux/gpio_keys.h> 804#include <linux/gpio_keys.h>
@@ -956,14 +954,12 @@ static int __init ezkit_init(void)
956{ 954{
957 printk(KERN_INFO "%s(): registering device resources\n", __func__); 955 printk(KERN_INFO "%s(): registering device resources\n", __func__);
958 956
959#ifdef CONFIG_I2C_BOARDINFO
960 i2c_register_board_info(0, bfin_i2c_board_info0, 957 i2c_register_board_info(0, bfin_i2c_board_info0,
961 ARRAY_SIZE(bfin_i2c_board_info0)); 958 ARRAY_SIZE(bfin_i2c_board_info0));
962#if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */ 959#if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
963 i2c_register_board_info(1, bfin_i2c_board_info1, 960 i2c_register_board_info(1, bfin_i2c_board_info1,
964 ARRAY_SIZE(bfin_i2c_board_info1)); 961 ARRAY_SIZE(bfin_i2c_board_info1));
965#endif 962#endif
966#endif
967 963
968 platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices)); 964 platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
969 965
diff --git a/arch/blackfin/mach-bf548/include/mach/anomaly.h b/arch/blackfin/mach-bf548/include/mach/anomaly.h
index 3b5430999f4f..23d03c52f4b4 100644
--- a/arch/blackfin/mach-bf548/include/mach/anomaly.h
+++ b/arch/blackfin/mach-bf548/include/mach/anomaly.h
@@ -175,6 +175,7 @@
175#define ANOMALY_05000311 (0) 175#define ANOMALY_05000311 (0)
176#define ANOMALY_05000323 (0) 176#define ANOMALY_05000323 (0)
177#define ANOMALY_05000363 (0) 177#define ANOMALY_05000363 (0)
178#define ANOMALY_05000380 (0)
178#define ANOMALY_05000412 (0) 179#define ANOMALY_05000412 (0)
179#define ANOMALY_05000432 (0) 180#define ANOMALY_05000432 (0)
180#define ANOMALY_05000435 (0) 181#define ANOMALY_05000435 (0)
diff --git a/arch/blackfin/mach-bf548/include/mach/bf548.h b/arch/blackfin/mach-bf548/include/mach/bf548.h
index f0e569984810..cd31f72bdd82 100644
--- a/arch/blackfin/mach-bf548/include/mach/bf548.h
+++ b/arch/blackfin/mach-bf548/include/mach/bf548.h
@@ -104,6 +104,18 @@
104 104
105#define AMGCTLVAL (V_AMBEN | V_AMCKEN) 105#define AMGCTLVAL (V_AMBEN | V_AMCKEN)
106 106
107#if defined(CONFIG_BF542M)
108# define CONFIG_BF542
109#elif defined(CONFIG_BF544M)
110# define CONFIG_BF544
111#elif defined(CONFIG_BF547M)
112# define CONFIG_BF547
113#elif defined(CONFIG_BF548M)
114# define CONFIG_BF548
115#elif defined(CONFIG_BF549M)
116# define CONFIG_BF549
117#endif
118
107#if defined(CONFIG_BF542) 119#if defined(CONFIG_BF542)
108# define CPU "BF542" 120# define CPU "BF542"
109# define CPUID 0x27de 121# define CPUID 0x27de
diff --git a/arch/blackfin/mach-bf548/include/mach/gpio.h b/arch/blackfin/mach-bf548/include/mach/gpio.h
index bba82dc75f16..3a2051709787 100644
--- a/arch/blackfin/mach-bf548/include/mach/gpio.h
+++ b/arch/blackfin/mach-bf548/include/mach/gpio.h
@@ -195,17 +195,17 @@
195struct gpio_port_t { 195struct gpio_port_t {
196 unsigned short port_fer; 196 unsigned short port_fer;
197 unsigned short dummy1; 197 unsigned short dummy1;
198 unsigned short port_data; 198 unsigned short data;
199 unsigned short dummy2; 199 unsigned short dummy2;
200 unsigned short port_set; 200 unsigned short data_set;
201 unsigned short dummy3; 201 unsigned short dummy3;
202 unsigned short port_clear; 202 unsigned short data_clear;
203 unsigned short dummy4; 203 unsigned short dummy4;
204 unsigned short port_dir_set; 204 unsigned short dir_set;
205 unsigned short dummy5; 205 unsigned short dummy5;
206 unsigned short port_dir_clear; 206 unsigned short dir_clear;
207 unsigned short dummy6; 207 unsigned short dummy6;
208 unsigned short port_inen; 208 unsigned short inen;
209 unsigned short dummy7; 209 unsigned short dummy7;
210 unsigned int port_mux; 210 unsigned int port_mux;
211}; 211};
diff --git a/arch/blackfin/mach-bf548/include/mach/portmux.h b/arch/blackfin/mach-bf548/include/mach/portmux.h
index 8177a567dcdb..ffb1d0a44b4d 100644
--- a/arch/blackfin/mach-bf548/include/mach/portmux.h
+++ b/arch/blackfin/mach-bf548/include/mach/portmux.h
@@ -125,6 +125,7 @@
125#define P_KEY_COL2 (P_DEFINED | P_IDENT(GPIO_PD14) | P_FUNCT(3)) 125#define P_KEY_COL2 (P_DEFINED | P_IDENT(GPIO_PD14) | P_FUNCT(3))
126#define P_KEY_COL3 (P_DEFINED | P_IDENT(GPIO_PD15) | P_FUNCT(3)) 126#define P_KEY_COL3 (P_DEFINED | P_IDENT(GPIO_PD15) | P_FUNCT(3))
127 127
128#define P_DEFAULT_BOOT_SPI_CS P_SPI0_SSEL1
128#define P_SPI0_SCK (P_DEFINED | P_IDENT(GPIO_PE0) | P_FUNCT(0)) 129#define P_SPI0_SCK (P_DEFINED | P_IDENT(GPIO_PE0) | P_FUNCT(0))
129#define P_SPI0_MISO (P_DEFINED | P_IDENT(GPIO_PE1) | P_FUNCT(0)) 130#define P_SPI0_MISO (P_DEFINED | P_IDENT(GPIO_PE1) | P_FUNCT(0))
130#define P_SPI0_MOSI (P_DEFINED | P_IDENT(GPIO_PE2) | P_FUNCT(0)) 131#define P_SPI0_MOSI (P_DEFINED | P_IDENT(GPIO_PE2) | P_FUNCT(0))
diff --git a/arch/blackfin/mach-bf561/include/mach/defBF561.h b/arch/blackfin/mach-bf561/include/mach/defBF561.h
index d7c509759659..cf922295f4ce 100644
--- a/arch/blackfin/mach-bf561/include/mach/defBF561.h
+++ b/arch/blackfin/mach-bf561/include/mach/defBF561.h
@@ -1106,6 +1106,8 @@
1106#define DLEN_8 0x0 /* PPI Data Length mask for DLEN=8 */ 1106#define DLEN_8 0x0 /* PPI Data Length mask for DLEN=8 */
1107#define DLEN(x) (((x-9) & 0x07) << 11) /* PPI Data Length (only works for x=10-->x=16) */ 1107#define DLEN(x) (((x-9) & 0x07) << 11) /* PPI Data Length (only works for x=10-->x=16) */
1108#define POL 0x0000C000 /* PPI Signal Polarities */ 1108#define POL 0x0000C000 /* PPI Signal Polarities */
1109#define POLC 0x4000 /* PPI Clock Polarity */
1110#define POLS 0x8000 /* PPI Frame Sync Polarity */
1109 1111
1110/* PPI_STATUS Masks */ 1112/* PPI_STATUS Masks */
1111#define FLD 0x00000400 /* Field Indicator */ 1113#define FLD 0x00000400 /* Field Indicator */
diff --git a/arch/blackfin/mach-bf561/include/mach/portmux.h b/arch/blackfin/mach-bf561/include/mach/portmux.h
index a6ee8206efb6..2e5ad6347dea 100644
--- a/arch/blackfin/mach-bf561/include/mach/portmux.h
+++ b/arch/blackfin/mach-bf561/include/mach/portmux.h
@@ -85,5 +85,6 @@
85#define P_SPI0_MOSI (P_DONTCARE) 85#define P_SPI0_MOSI (P_DONTCARE)
86#define P_SPI0_MISO (P_DONTCARE) 86#define P_SPI0_MISO (P_DONTCARE)
87#define P_SPI0_SCK (P_DONTCARE) 87#define P_SPI0_SCK (P_DONTCARE)
88#define P_DEFAULT_BOOT_SPI_CS P_SPI0_SSEL2
88 89
89#endif /* _MACH_PORTMUX_H_ */ 90#endif /* _MACH_PORTMUX_H_ */
diff --git a/arch/blackfin/mach-common/clocks-init.c b/arch/blackfin/mach-common/clocks-init.c
index 5d182abefc7b..9dddb6f8cc85 100644
--- a/arch/blackfin/mach-common/clocks-init.c
+++ b/arch/blackfin/mach-common/clocks-init.c
@@ -14,6 +14,7 @@
14#include <asm/clocks.h> 14#include <asm/clocks.h>
15#include <asm/mem_init.h> 15#include <asm/mem_init.h>
16 16
17#define SDGCTL_WIDTH (1 << 31) /* SDRAM external data path width */
17#define PLL_CTL_VAL \ 18#define PLL_CTL_VAL \
18 (((CONFIG_VCO_MULT & 63) << 9) | CLKIN_HALF | \ 19 (((CONFIG_VCO_MULT & 63) << 9) | CLKIN_HALF | \
19 (PLL_BYPASS << 8) | (ANOMALY_05000265 ? 0x8000 : 0)) 20 (PLL_BYPASS << 8) | (ANOMALY_05000265 ? 0x8000 : 0))
@@ -76,7 +77,7 @@ void init_clocks(void)
76 bfin_write_PLL_DIV(CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV); 77 bfin_write_PLL_DIV(CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
77#ifdef EBIU_SDGCTL 78#ifdef EBIU_SDGCTL
78 bfin_write_EBIU_SDRRC(mem_SDRRC); 79 bfin_write_EBIU_SDRRC(mem_SDRRC);
79 bfin_write_EBIU_SDGCTL(mem_SDGCTL); 80 bfin_write_EBIU_SDGCTL((bfin_read_EBIU_SDGCTL() & SDGCTL_WIDTH) | mem_SDGCTL);
80#else 81#else
81 bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() & ~(SRREQ)); 82 bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() & ~(SRREQ));
82 do_sync(); 83 do_sync();
diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S
index fae774651374..88de053bbe8e 100644
--- a/arch/blackfin/mach-common/entry.S
+++ b/arch/blackfin/mach-common/entry.S
@@ -151,13 +151,6 @@ ENTRY(_ex_syscall)
151 jump.s _bfin_return_from_exception; 151 jump.s _bfin_return_from_exception;
152ENDPROC(_ex_syscall) 152ENDPROC(_ex_syscall)
153 153
154ENTRY(_ex_soft_bp)
155 r7 = retx;
156 r7 += -2;
157 retx = r7;
158 jump.s _ex_trap_c;
159ENDPROC(_ex_soft_bp)
160
161ENTRY(_ex_single_step) 154ENTRY(_ex_single_step)
162 /* If we just returned from an interrupt, the single step event is 155 /* If we just returned from an interrupt, the single step event is
163 for the RTI instruction. */ 156 for the RTI instruction. */
@@ -1087,7 +1080,7 @@ ENTRY(_ex_table)
1087 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined 1080 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
1088 */ 1081 */
1089 .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */ 1082 .long _ex_syscall /* 0x00 - User Defined - Linux Syscall */
1090 .long _ex_soft_bp /* 0x01 - User Defined - Software breakpoint */ 1083 .long _ex_trap_c /* 0x01 - User Defined - Software breakpoint */
1091#ifdef CONFIG_KGDB 1084#ifdef CONFIG_KGDB
1092 .long _ex_trap_c /* 0x02 - User Defined - KGDB initial connection 1085 .long _ex_trap_c /* 0x02 - User Defined - KGDB initial connection
1093 and break signal trap */ 1086 and break signal trap */
diff --git a/arch/blackfin/mach-common/head.S b/arch/blackfin/mach-common/head.S
index e1e42c029e15..698d4c05947e 100644
--- a/arch/blackfin/mach-common/head.S
+++ b/arch/blackfin/mach-common/head.S
@@ -17,6 +17,19 @@
17 17
18__INIT 18__INIT
19 19
20ENTRY(__init_clear_bss)
21 r2 = r2 - r1;
22 cc = r2 == 0;
23 if cc jump .L_bss_done;
24 r2 >>= 2;
25 p1 = r1;
26 p2 = r2;
27 lsetup (1f, 1f) lc0 = p2;
281: [p1++] = r0;
29.L_bss_done:
30 rts;
31ENDPROC(__init_clear_bss)
32
20#define INITIAL_STACK (L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12) 33#define INITIAL_STACK (L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12)
21 34
22ENTRY(__start) 35ENTRY(__start)
@@ -144,6 +157,35 @@ ENTRY(__start)
144 call _init_early_exception_vectors; 157 call _init_early_exception_vectors;
145#endif 158#endif
146 159
160 r0 = 0 (x);
161 /* Zero out all of the fun bss regions */
162#if L1_DATA_A_LENGTH > 0
163 r1.l = __sbss_l1;
164 r1.h = __sbss_l1;
165 r2.l = __ebss_l1;
166 r2.h = __ebss_l1;
167 call __init_clear_bss
168#endif
169#if L1_DATA_B_LENGTH > 0
170 r1.l = __sbss_b_l1;
171 r1.h = __sbss_b_l1;
172 r2.l = __ebss_b_l1;
173 r2.h = __ebss_b_l1;
174 call __init_clear_bss
175#endif
176#if L2_LENGTH > 0
177 r1.l = __sbss_l2;
178 r1.h = __sbss_l2;
179 r2.l = __ebss_l2;
180 r2.h = __ebss_l2;
181 call __init_clear_bss
182#endif
183 r1.l = ___bss_start;
184 r1.h = ___bss_start;
185 r2.l = ___bss_stop;
186 r2.h = ___bss_stop;
187 call __init_clear_bss
188
147 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */ 189 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
148 call _bfin_relocate_l1_mem; 190 call _bfin_relocate_l1_mem;
149#ifdef CONFIG_BFIN_KERNEL_CLOCK 191#ifdef CONFIG_BFIN_KERNEL_CLOCK
@@ -185,19 +227,6 @@ ENDPROC(__start)
185# define WDOG_CTL WDOGA_CTL 227# define WDOG_CTL WDOGA_CTL
186#endif 228#endif
187 229
188ENTRY(__init_clear_bss)
189 r2 = r2 - r1;
190 cc = r2 == 0;
191 if cc jump .L_bss_done;
192 r2 >>= 2;
193 p1 = r1;
194 p2 = r2;
195 lsetup (1f, 1f) lc0 = p2;
1961: [p1++] = r0;
197.L_bss_done:
198 rts;
199ENDPROC(__init_clear_bss)
200
201ENTRY(_real_start) 230ENTRY(_real_start)
202 /* Enable nested interrupts */ 231 /* Enable nested interrupts */
203 [--sp] = reti; 232 [--sp] = reti;
@@ -209,35 +238,6 @@ ENTRY(_real_start)
209 w[p0] = r0; 238 w[p0] = r0;
210 ssync; 239 ssync;
211 240
212 r0 = 0 (x);
213 /* Zero out all of the fun bss regions */
214#if L1_DATA_A_LENGTH > 0
215 r1.l = __sbss_l1;
216 r1.h = __sbss_l1;
217 r2.l = __ebss_l1;
218 r2.h = __ebss_l1;
219 call __init_clear_bss
220#endif
221#if L1_DATA_B_LENGTH > 0
222 r1.l = __sbss_b_l1;
223 r1.h = __sbss_b_l1;
224 r2.l = __ebss_b_l1;
225 r2.h = __ebss_b_l1;
226 call __init_clear_bss
227#endif
228#if L2_LENGTH > 0
229 r1.l = __sbss_l2;
230 r1.h = __sbss_l2;
231 r2.l = __ebss_l2;
232 r2.h = __ebss_l2;
233 call __init_clear_bss
234#endif
235 r1.l = ___bss_start;
236 r1.h = ___bss_start;
237 r2.l = ___bss_stop;
238 r2.h = ___bss_stop;
239 call __init_clear_bss
240
241 /* Pass the u-boot arguments to the global value command line */ 241 /* Pass the u-boot arguments to the global value command line */
242 R0 = R7; 242 R0 = R7;
243 call _cmdline_init; 243 call _cmdline_init;
diff --git a/arch/blackfin/mach-common/interrupt.S b/arch/blackfin/mach-common/interrupt.S
index 473df0f7fa78..43c4eb9acb65 100644
--- a/arch/blackfin/mach-common/interrupt.S
+++ b/arch/blackfin/mach-common/interrupt.S
@@ -195,7 +195,7 @@ ENDPROC(_evt_ivhw)
195/* Interrupt routine for evt2 (NMI). 195/* Interrupt routine for evt2 (NMI).
196 * We don't actually use this, so just return. 196 * We don't actually use this, so just return.
197 * For inner circle type details, please see: 197 * For inner circle type details, please see:
198 * http://docs.blackfin.uclinux.org/doku.php?id=linux:nmi 198 * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:nmi
199 */ 199 */
200ENTRY(_evt_nmi) 200ENTRY(_evt_nmi)
201.weak _evt_nmi 201.weak _evt_nmi
diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c
index 1bba6030dce9..202494568c6c 100644
--- a/arch/blackfin/mach-common/ints-priority.c
+++ b/arch/blackfin/mach-common/ints-priority.c
@@ -1101,10 +1101,9 @@ int __init init_arch_irq(void)
1101 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 | 1101 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
1102 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW; 1102 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
1103 1103
1104#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) \ 1104#ifdef SIC_IWR0
1105 || defined(BF538_FAMILY) || defined(CONFIG_BF51x)
1106 bfin_write_SIC_IWR0(IWR_DISABLE_ALL); 1105 bfin_write_SIC_IWR0(IWR_DISABLE_ALL);
1107#if defined(CONFIG_BF52x) || defined(CONFIG_BF51x) 1106# ifdef SIC_IWR1
1108 /* BF52x/BF51x system reset does not properly reset SIC_IWR1 which 1107 /* BF52x/BF51x system reset does not properly reset SIC_IWR1 which
1109 * will screw up the bootrom as it relies on MDMA0/1 waking it 1108 * will screw up the bootrom as it relies on MDMA0/1 waking it
1110 * up from IDLE instructions. See this report for more info: 1109 * up from IDLE instructions. See this report for more info:
@@ -1114,10 +1113,8 @@ int __init init_arch_irq(void)
1114 bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11)); 1113 bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11));
1115 else 1114 else
1116 bfin_write_SIC_IWR1(IWR_DISABLE_ALL); 1115 bfin_write_SIC_IWR1(IWR_DISABLE_ALL);
1117#else 1116# endif
1118 bfin_write_SIC_IWR1(IWR_DISABLE_ALL); 1117# ifdef SIC_IWR2
1119#endif
1120# ifdef CONFIG_BF54x
1121 bfin_write_SIC_IWR2(IWR_DISABLE_ALL); 1118 bfin_write_SIC_IWR2(IWR_DISABLE_ALL);
1122# endif 1119# endif
1123#else 1120#else
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c
index d3d70fd67c16..f48a6aebb49b 100644
--- a/arch/blackfin/mach-common/pm.c
+++ b/arch/blackfin/mach-common/pm.c
@@ -82,10 +82,9 @@ void bfin_pm_suspend_standby_enter(void)
82 82
83 bfin_pm_standby_restore(); 83 bfin_pm_standby_restore();
84 84
85#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) || \ 85#ifdef SIC_IWR0
86 defined(CONFIG_BF538) || defined(CONFIG_BF539) || defined(CONFIG_BF51x)
87 bfin_write_SIC_IWR0(IWR_DISABLE_ALL); 86 bfin_write_SIC_IWR0(IWR_DISABLE_ALL);
88#if defined(CONFIG_BF52x) || defined(CONFIG_BF51x) 87# ifdef SIC_IWR1
89 /* BF52x system reset does not properly reset SIC_IWR1 which 88 /* BF52x system reset does not properly reset SIC_IWR1 which
90 * will screw up the bootrom as it relies on MDMA0/1 waking it 89 * will screw up the bootrom as it relies on MDMA0/1 waking it
91 * up from IDLE instructions. See this report for more info: 90 * up from IDLE instructions. See this report for more info:
@@ -95,10 +94,8 @@ void bfin_pm_suspend_standby_enter(void)
95 bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11)); 94 bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11));
96 else 95 else
97 bfin_write_SIC_IWR1(IWR_DISABLE_ALL); 96 bfin_write_SIC_IWR1(IWR_DISABLE_ALL);
98#else 97# endif
99 bfin_write_SIC_IWR1(IWR_DISABLE_ALL); 98# ifdef SIC_IWR2
100#endif
101# ifdef CONFIG_BF54x
102 bfin_write_SIC_IWR2(IWR_DISABLE_ALL); 99 bfin_write_SIC_IWR2(IWR_DISABLE_ALL);
103# endif 100# endif
104#else 101#else
diff --git a/arch/frv/mm/dma-alloc.c b/arch/frv/mm/dma-alloc.c
index dc6522c464d4..44840e73e907 100644
--- a/arch/frv/mm/dma-alloc.c
+++ b/arch/frv/mm/dma-alloc.c
@@ -36,10 +36,10 @@
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/hardirq.h>
39 40
40#include <asm/pgalloc.h> 41#include <asm/pgalloc.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/hardirq.h>
43#include <asm/mmu_context.h> 43#include <asm/mmu_context.h>
44#include <asm/pgtable.h> 44#include <asm/pgtable.h>
45#include <asm/mmu.h> 45#include <asm/mmu.h>
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 6183aeccecf1..4eb45c012498 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -221,7 +221,11 @@ config IA64_HP_SIM
221 221
222config IA64_XEN_GUEST 222config IA64_XEN_GUEST
223 bool "Xen guest" 223 bool "Xen guest"
224 select SWIOTLB
224 depends on XEN 225 depends on XEN
226 help
227 Build a kernel that runs on Xen guest domain. At this moment only
228 16KB page size in supported.
225 229
226endchoice 230endchoice
227 231
@@ -479,8 +483,7 @@ config HOLES_IN_ZONE
479 default y if VIRTUAL_MEM_MAP 483 default y if VIRTUAL_MEM_MAP
480 484
481config HAVE_ARCH_EARLY_PFN_TO_NID 485config HAVE_ARCH_EARLY_PFN_TO_NID
482 def_bool y 486 def_bool NUMA && SPARSEMEM
483 depends on NEED_MULTIPLE_NODES
484 487
485config HAVE_ARCH_NODEDATA_EXTENSION 488config HAVE_ARCH_NODEDATA_EXTENSION
486 def_bool y 489 def_bool y
diff --git a/arch/ia64/configs/xen_domu_defconfig b/arch/ia64/configs/xen_domu_defconfig
new file mode 100644
index 000000000000..0bb0714dc19d
--- /dev/null
+++ b/arch/ia64/configs/xen_domu_defconfig
@@ -0,0 +1,1601 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.29-rc1
4# Fri Jan 16 11:49:59 2009
5#
6CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
7
8#
9# General setup
10#
11CONFIG_EXPERIMENTAL=y
12CONFIG_LOCK_KERNEL=y
13CONFIG_INIT_ENV_ARG_LIMIT=32
14CONFIG_LOCALVERSION=""
15CONFIG_LOCALVERSION_AUTO=y
16CONFIG_SWAP=y
17CONFIG_SYSVIPC=y
18CONFIG_SYSVIPC_SYSCTL=y
19CONFIG_POSIX_MQUEUE=y
20# CONFIG_BSD_PROCESS_ACCT is not set
21# CONFIG_TASKSTATS is not set
22# CONFIG_AUDIT is not set
23CONFIG_IKCONFIG=y
24CONFIG_IKCONFIG_PROC=y
25CONFIG_LOG_BUF_SHIFT=20
26CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
27# CONFIG_GROUP_SCHED is not set
28
29#
30# Control Group support
31#
32# CONFIG_CGROUPS is not set
33CONFIG_SYSFS_DEPRECATED=y
34CONFIG_SYSFS_DEPRECATED_V2=y
35# CONFIG_RELAY is not set
36CONFIG_NAMESPACES=y
37# CONFIG_UTS_NS is not set
38# CONFIG_IPC_NS is not set
39# CONFIG_USER_NS is not set
40# CONFIG_PID_NS is not set
41CONFIG_BLK_DEV_INITRD=y
42CONFIG_INITRAMFS_SOURCE=""
43CONFIG_CC_OPTIMIZE_FOR_SIZE=y
44CONFIG_SYSCTL=y
45# CONFIG_EMBEDDED is not set
46CONFIG_SYSCTL_SYSCALL=y
47CONFIG_KALLSYMS=y
48CONFIG_KALLSYMS_ALL=y
49CONFIG_KALLSYMS_STRIP_GENERATED=y
50# CONFIG_KALLSYMS_EXTRA_PASS is not set
51CONFIG_HOTPLUG=y
52CONFIG_PRINTK=y
53CONFIG_BUG=y
54CONFIG_ELF_CORE=y
55CONFIG_COMPAT_BRK=y
56CONFIG_BASE_FULL=y
57CONFIG_FUTEX=y
58CONFIG_ANON_INODES=y
59CONFIG_EPOLL=y
60CONFIG_SIGNALFD=y
61CONFIG_TIMERFD=y
62CONFIG_EVENTFD=y
63CONFIG_SHMEM=y
64CONFIG_AIO=y
65CONFIG_VM_EVENT_COUNTERS=y
66CONFIG_PCI_QUIRKS=y
67CONFIG_SLUB_DEBUG=y
68# CONFIG_SLAB is not set
69CONFIG_SLUB=y
70# CONFIG_SLOB is not set
71# CONFIG_PROFILING is not set
72CONFIG_HAVE_OPROFILE=y
73# CONFIG_KPROBES is not set
74CONFIG_HAVE_KPROBES=y
75CONFIG_HAVE_KRETPROBES=y
76CONFIG_HAVE_ARCH_TRACEHOOK=y
77CONFIG_HAVE_DMA_ATTRS=y
78CONFIG_USE_GENERIC_SMP_HELPERS=y
79# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
80CONFIG_SLABINFO=y
81CONFIG_RT_MUTEXES=y
82CONFIG_BASE_SMALL=0
83CONFIG_MODULES=y
84# CONFIG_MODULE_FORCE_LOAD is not set
85CONFIG_MODULE_UNLOAD=y
86# CONFIG_MODULE_FORCE_UNLOAD is not set
87CONFIG_MODVERSIONS=y
88CONFIG_MODULE_SRCVERSION_ALL=y
89CONFIG_STOP_MACHINE=y
90CONFIG_BLOCK=y
91# CONFIG_BLK_DEV_IO_TRACE is not set
92# CONFIG_BLK_DEV_BSG is not set
93# CONFIG_BLK_DEV_INTEGRITY is not set
94
95#
96# IO Schedulers
97#
98CONFIG_IOSCHED_NOOP=y
99CONFIG_IOSCHED_AS=y
100CONFIG_IOSCHED_DEADLINE=y
101CONFIG_IOSCHED_CFQ=y
102CONFIG_DEFAULT_AS=y
103# CONFIG_DEFAULT_DEADLINE is not set
104# CONFIG_DEFAULT_CFQ is not set
105# CONFIG_DEFAULT_NOOP is not set
106CONFIG_DEFAULT_IOSCHED="anticipatory"
107CONFIG_CLASSIC_RCU=y
108# CONFIG_TREE_RCU is not set
109# CONFIG_PREEMPT_RCU is not set
110# CONFIG_TREE_RCU_TRACE is not set
111# CONFIG_PREEMPT_RCU_TRACE is not set
112CONFIG_FREEZER=y
113
114#
115# Processor type and features
116#
117CONFIG_IA64=y
118CONFIG_64BIT=y
119CONFIG_ZONE_DMA=y
120CONFIG_QUICKLIST=y
121CONFIG_MMU=y
122CONFIG_SWIOTLB=y
123CONFIG_IOMMU_HELPER=y
124CONFIG_RWSEM_XCHGADD_ALGORITHM=y
125CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=y
126CONFIG_GENERIC_FIND_NEXT_BIT=y
127CONFIG_GENERIC_CALIBRATE_DELAY=y
128CONFIG_GENERIC_TIME=y
129CONFIG_GENERIC_TIME_VSYSCALL=y
130CONFIG_HAVE_SETUP_PER_CPU_AREA=y
131CONFIG_DMI=y
132CONFIG_EFI=y
133CONFIG_GENERIC_IOMAP=y
134CONFIG_SCHED_OMIT_FRAME_POINTER=y
135CONFIG_AUDIT_ARCH=y
136CONFIG_PARAVIRT_GUEST=y
137CONFIG_PARAVIRT=y
138CONFIG_XEN=y
139CONFIG_XEN_XENCOMM=y
140CONFIG_NO_IDLE_HZ=y
141# CONFIG_IA64_GENERIC is not set
142# CONFIG_IA64_DIG is not set
143# CONFIG_IA64_DIG_VTD is not set
144# CONFIG_IA64_HP_ZX1 is not set
145# CONFIG_IA64_HP_ZX1_SWIOTLB is not set
146# CONFIG_IA64_SGI_SN2 is not set
147# CONFIG_IA64_SGI_UV is not set
148# CONFIG_IA64_HP_SIM is not set
149CONFIG_IA64_XEN_GUEST=y
150# CONFIG_ITANIUM is not set
151CONFIG_MCKINLEY=y
152# CONFIG_IA64_PAGE_SIZE_4KB is not set
153# CONFIG_IA64_PAGE_SIZE_8KB is not set
154CONFIG_IA64_PAGE_SIZE_16KB=y
155# CONFIG_IA64_PAGE_SIZE_64KB is not set
156CONFIG_PGTABLE_3=y
157# CONFIG_PGTABLE_4 is not set
158CONFIG_HZ=250
159# CONFIG_HZ_100 is not set
160CONFIG_HZ_250=y
161# CONFIG_HZ_300 is not set
162# CONFIG_HZ_1000 is not set
163# CONFIG_SCHED_HRTICK is not set
164CONFIG_IA64_L1_CACHE_SHIFT=7
165CONFIG_IA64_CYCLONE=y
166CONFIG_IOSAPIC=y
167CONFIG_FORCE_MAX_ZONEORDER=17
168# CONFIG_VIRT_CPU_ACCOUNTING is not set
169CONFIG_SMP=y
170CONFIG_NR_CPUS=16
171CONFIG_HOTPLUG_CPU=y
172CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
173CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
174# CONFIG_SCHED_SMT is not set
175CONFIG_PERMIT_BSP_REMOVE=y
176CONFIG_FORCE_CPEI_RETARGET=y
177CONFIG_PREEMPT_NONE=y
178# CONFIG_PREEMPT_VOLUNTARY is not set
179# CONFIG_PREEMPT is not set
180CONFIG_SELECT_MEMORY_MODEL=y
181CONFIG_FLATMEM_MANUAL=y
182# CONFIG_DISCONTIGMEM_MANUAL is not set
183# CONFIG_SPARSEMEM_MANUAL is not set
184CONFIG_FLATMEM=y
185CONFIG_FLAT_NODE_MEM_MAP=y
186CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
187CONFIG_PAGEFLAGS_EXTENDED=y
188CONFIG_SPLIT_PTLOCK_CPUS=4
189CONFIG_MIGRATION=y
190CONFIG_PHYS_ADDR_T_64BIT=y
191CONFIG_ZONE_DMA_FLAG=1
192CONFIG_BOUNCE=y
193CONFIG_NR_QUICK=1
194CONFIG_VIRT_TO_BUS=y
195CONFIG_UNEVICTABLE_LRU=y
196CONFIG_ARCH_SELECT_MEMORY_MODEL=y
197CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
198CONFIG_ARCH_FLATMEM_ENABLE=y
199CONFIG_ARCH_SPARSEMEM_ENABLE=y
200CONFIG_ARCH_POPULATES_NODE_MAP=y
201CONFIG_VIRTUAL_MEM_MAP=y
202CONFIG_HOLES_IN_ZONE=y
203# CONFIG_IA32_SUPPORT is not set
204# CONFIG_COMPAT_FOR_U64_ALIGNMENT is not set
205CONFIG_IA64_MCA_RECOVERY=y
206CONFIG_PERFMON=y
207CONFIG_IA64_PALINFO=y
208# CONFIG_IA64_MC_ERR_INJECT is not set
209# CONFIG_IA64_ESI is not set
210# CONFIG_IA64_HP_AML_NFW is not set
211CONFIG_KEXEC=y
212# CONFIG_CRASH_DUMP is not set
213
214#
215# Firmware Drivers
216#
217# CONFIG_FIRMWARE_MEMMAP is not set
218CONFIG_EFI_VARS=y
219CONFIG_EFI_PCDP=y
220CONFIG_DMIID=y
221CONFIG_BINFMT_ELF=y
222# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
223# CONFIG_HAVE_AOUT is not set
224CONFIG_BINFMT_MISC=m
225
226#
227# Power management and ACPI options
228#
229CONFIG_PM=y
230# CONFIG_PM_DEBUG is not set
231CONFIG_PM_SLEEP=y
232CONFIG_SUSPEND=y
233CONFIG_SUSPEND_FREEZER=y
234CONFIG_ACPI=y
235CONFIG_ACPI_SLEEP=y
236CONFIG_ACPI_PROCFS=y
237CONFIG_ACPI_PROCFS_POWER=y
238CONFIG_ACPI_SYSFS_POWER=y
239CONFIG_ACPI_PROC_EVENT=y
240CONFIG_ACPI_BUTTON=m
241CONFIG_ACPI_FAN=m
242# CONFIG_ACPI_DOCK is not set
243CONFIG_ACPI_PROCESSOR=m
244CONFIG_ACPI_HOTPLUG_CPU=y
245CONFIG_ACPI_THERMAL=m
246# CONFIG_ACPI_CUSTOM_DSDT is not set
247CONFIG_ACPI_BLACKLIST_YEAR=0
248# CONFIG_ACPI_DEBUG is not set
249# CONFIG_ACPI_PCI_SLOT is not set
250CONFIG_ACPI_SYSTEM=y
251CONFIG_ACPI_CONTAINER=m
252
253#
254# CPU Frequency scaling
255#
256# CONFIG_CPU_FREQ is not set
257
258#
259# Bus options (PCI, PCMCIA)
260#
261CONFIG_PCI=y
262CONFIG_PCI_DOMAINS=y
263CONFIG_PCI_SYSCALL=y
264# CONFIG_PCIEPORTBUS is not set
265CONFIG_ARCH_SUPPORTS_MSI=y
266# CONFIG_PCI_MSI is not set
267CONFIG_PCI_LEGACY=y
268# CONFIG_PCI_DEBUG is not set
269# CONFIG_PCI_STUB is not set
270CONFIG_HOTPLUG_PCI=m
271# CONFIG_HOTPLUG_PCI_FAKE is not set
272CONFIG_HOTPLUG_PCI_ACPI=m
273# CONFIG_HOTPLUG_PCI_ACPI_IBM is not set
274# CONFIG_HOTPLUG_PCI_CPCI is not set
275# CONFIG_HOTPLUG_PCI_SHPC is not set
276# CONFIG_PCCARD is not set
277CONFIG_NET=y
278
279#
280# Networking options
281#
282# CONFIG_NET_NS is not set
283CONFIG_COMPAT_NET_DEV_OPS=y
284CONFIG_PACKET=y
285# CONFIG_PACKET_MMAP is not set
286CONFIG_UNIX=y
287CONFIG_XFRM=y
288# CONFIG_XFRM_USER is not set
289# CONFIG_XFRM_SUB_POLICY is not set
290# CONFIG_XFRM_MIGRATE is not set
291# CONFIG_XFRM_STATISTICS is not set
292# CONFIG_NET_KEY is not set
293CONFIG_INET=y
294CONFIG_IP_MULTICAST=y
295# CONFIG_IP_ADVANCED_ROUTER is not set
296CONFIG_IP_FIB_HASH=y
297# CONFIG_IP_PNP is not set
298# CONFIG_NET_IPIP is not set
299# CONFIG_NET_IPGRE is not set
300# CONFIG_IP_MROUTE is not set
301CONFIG_ARPD=y
302CONFIG_SYN_COOKIES=y
303# CONFIG_INET_AH is not set
304# CONFIG_INET_ESP is not set
305# CONFIG_INET_IPCOMP is not set
306# CONFIG_INET_XFRM_TUNNEL is not set
307# CONFIG_INET_TUNNEL is not set
308CONFIG_INET_XFRM_MODE_TRANSPORT=y
309CONFIG_INET_XFRM_MODE_TUNNEL=y
310CONFIG_INET_XFRM_MODE_BEET=y
311# CONFIG_INET_LRO is not set
312CONFIG_INET_DIAG=y
313CONFIG_INET_TCP_DIAG=y
314# CONFIG_TCP_CONG_ADVANCED is not set
315CONFIG_TCP_CONG_CUBIC=y
316CONFIG_DEFAULT_TCP_CONG="cubic"
317# CONFIG_TCP_MD5SIG is not set
318# CONFIG_IPV6 is not set
319# CONFIG_NETWORK_SECMARK is not set
320# CONFIG_NETFILTER is not set
321# CONFIG_IP_DCCP is not set
322# CONFIG_IP_SCTP is not set
323# CONFIG_TIPC is not set
324# CONFIG_ATM is not set
325# CONFIG_BRIDGE is not set
326# CONFIG_NET_DSA is not set
327# CONFIG_VLAN_8021Q is not set
328# CONFIG_DECNET is not set
329# CONFIG_LLC2 is not set
330# CONFIG_IPX is not set
331# CONFIG_ATALK is not set
332# CONFIG_X25 is not set
333# CONFIG_LAPB is not set
334# CONFIG_ECONET is not set
335# CONFIG_WAN_ROUTER is not set
336# CONFIG_NET_SCHED is not set
337# CONFIG_DCB is not set
338
339#
340# Network testing
341#
342# CONFIG_NET_PKTGEN is not set
343# CONFIG_HAMRADIO is not set
344# CONFIG_CAN is not set
345# CONFIG_IRDA is not set
346# CONFIG_BT is not set
347# CONFIG_AF_RXRPC is not set
348# CONFIG_PHONET is not set
349# CONFIG_WIRELESS is not set
350# CONFIG_WIMAX is not set
351# CONFIG_RFKILL is not set
352# CONFIG_NET_9P is not set
353
354#
355# Device Drivers
356#
357
358#
359# Generic Driver Options
360#
361CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
362CONFIG_STANDALONE=y
363CONFIG_PREVENT_FIRMWARE_BUILD=y
364CONFIG_FW_LOADER=y
365CONFIG_FIRMWARE_IN_KERNEL=y
366CONFIG_EXTRA_FIRMWARE=""
367# CONFIG_DEBUG_DRIVER is not set
368# CONFIG_DEBUG_DEVRES is not set
369# CONFIG_SYS_HYPERVISOR is not set
370# CONFIG_CONNECTOR is not set
371# CONFIG_MTD is not set
372# CONFIG_PARPORT is not set
373CONFIG_PNP=y
374CONFIG_PNP_DEBUG_MESSAGES=y
375
376#
377# Protocols
378#
379CONFIG_PNPACPI=y
380CONFIG_BLK_DEV=y
381# CONFIG_BLK_CPQ_DA is not set
382# CONFIG_BLK_CPQ_CISS_DA is not set
383# CONFIG_BLK_DEV_DAC960 is not set
384# CONFIG_BLK_DEV_UMEM is not set
385# CONFIG_BLK_DEV_COW_COMMON is not set
386CONFIG_BLK_DEV_LOOP=m
387CONFIG_BLK_DEV_CRYPTOLOOP=m
388CONFIG_BLK_DEV_NBD=m
389# CONFIG_BLK_DEV_SX8 is not set
390# CONFIG_BLK_DEV_UB is not set
391CONFIG_BLK_DEV_RAM=y
392CONFIG_BLK_DEV_RAM_COUNT=16
393CONFIG_BLK_DEV_RAM_SIZE=4096
394# CONFIG_BLK_DEV_XIP is not set
395# CONFIG_CDROM_PKTCDVD is not set
396# CONFIG_ATA_OVER_ETH is not set
397CONFIG_XEN_BLKDEV_FRONTEND=y
398# CONFIG_BLK_DEV_HD is not set
399CONFIG_MISC_DEVICES=y
400# CONFIG_PHANTOM is not set
401# CONFIG_EEPROM_93CX6 is not set
402# CONFIG_SGI_IOC4 is not set
403# CONFIG_TIFM_CORE is not set
404# CONFIG_ICS932S401 is not set
405# CONFIG_ENCLOSURE_SERVICES is not set
406# CONFIG_HP_ILO is not set
407# CONFIG_C2PORT is not set
408CONFIG_HAVE_IDE=y
409CONFIG_IDE=y
410
411#
412# Please see Documentation/ide/ide.txt for help/info on IDE drives
413#
414CONFIG_IDE_TIMINGS=y
415CONFIG_IDE_ATAPI=y
416# CONFIG_BLK_DEV_IDE_SATA is not set
417CONFIG_IDE_GD=y
418CONFIG_IDE_GD_ATA=y
419# CONFIG_IDE_GD_ATAPI is not set
420CONFIG_BLK_DEV_IDECD=y
421CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
422# CONFIG_BLK_DEV_IDETAPE is not set
423# CONFIG_BLK_DEV_IDEACPI is not set
424# CONFIG_IDE_TASK_IOCTL is not set
425CONFIG_IDE_PROC_FS=y
426
427#
428# IDE chipset support/bugfixes
429#
430# CONFIG_IDE_GENERIC is not set
431# CONFIG_BLK_DEV_PLATFORM is not set
432# CONFIG_BLK_DEV_IDEPNP is not set
433CONFIG_BLK_DEV_IDEDMA_SFF=y
434
435#
436# PCI IDE chipsets support
437#
438CONFIG_BLK_DEV_IDEPCI=y
439CONFIG_IDEPCI_PCIBUS_ORDER=y
440# CONFIG_BLK_DEV_OFFBOARD is not set
441CONFIG_BLK_DEV_GENERIC=y
442# CONFIG_BLK_DEV_OPTI621 is not set
443CONFIG_BLK_DEV_IDEDMA_PCI=y
444# CONFIG_BLK_DEV_AEC62XX is not set
445# CONFIG_BLK_DEV_ALI15X3 is not set
446# CONFIG_BLK_DEV_AMD74XX is not set
447CONFIG_BLK_DEV_CMD64X=y
448# CONFIG_BLK_DEV_TRIFLEX is not set
449# CONFIG_BLK_DEV_CS5520 is not set
450# CONFIG_BLK_DEV_CS5530 is not set
451# CONFIG_BLK_DEV_HPT366 is not set
452# CONFIG_BLK_DEV_JMICRON is not set
453# CONFIG_BLK_DEV_SC1200 is not set
454CONFIG_BLK_DEV_PIIX=y
455# CONFIG_BLK_DEV_IT8172 is not set
456# CONFIG_BLK_DEV_IT8213 is not set
457# CONFIG_BLK_DEV_IT821X is not set
458# CONFIG_BLK_DEV_NS87415 is not set
459# CONFIG_BLK_DEV_PDC202XX_OLD is not set
460# CONFIG_BLK_DEV_PDC202XX_NEW is not set
461# CONFIG_BLK_DEV_SVWKS is not set
462# CONFIG_BLK_DEV_SIIMAGE is not set
463# CONFIG_BLK_DEV_SLC90E66 is not set
464# CONFIG_BLK_DEV_TRM290 is not set
465# CONFIG_BLK_DEV_VIA82CXXX is not set
466# CONFIG_BLK_DEV_TC86C001 is not set
467CONFIG_BLK_DEV_IDEDMA=y
468
469#
470# SCSI device support
471#
472# CONFIG_RAID_ATTRS is not set
473CONFIG_SCSI=y
474CONFIG_SCSI_DMA=y
475# CONFIG_SCSI_TGT is not set
476CONFIG_SCSI_NETLINK=y
477CONFIG_SCSI_PROC_FS=y
478
479#
480# SCSI support type (disk, tape, CD-ROM)
481#
482CONFIG_BLK_DEV_SD=y
483CONFIG_CHR_DEV_ST=m
484# CONFIG_CHR_DEV_OSST is not set
485CONFIG_BLK_DEV_SR=m
486# CONFIG_BLK_DEV_SR_VENDOR is not set
487CONFIG_CHR_DEV_SG=m
488# CONFIG_CHR_DEV_SCH is not set
489
490#
491# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
492#
493# CONFIG_SCSI_MULTI_LUN is not set
494# CONFIG_SCSI_CONSTANTS is not set
495# CONFIG_SCSI_LOGGING is not set
496# CONFIG_SCSI_SCAN_ASYNC is not set
497CONFIG_SCSI_WAIT_SCAN=m
498
499#
500# SCSI Transports
501#
502CONFIG_SCSI_SPI_ATTRS=y
503CONFIG_SCSI_FC_ATTRS=y
504# CONFIG_SCSI_ISCSI_ATTRS is not set
505# CONFIG_SCSI_SAS_LIBSAS is not set
506# CONFIG_SCSI_SRP_ATTRS is not set
507CONFIG_SCSI_LOWLEVEL=y
508# CONFIG_ISCSI_TCP is not set
509# CONFIG_SCSI_CXGB3_ISCSI is not set
510# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
511# CONFIG_SCSI_3W_9XXX is not set
512# CONFIG_SCSI_ACARD is not set
513# CONFIG_SCSI_AACRAID is not set
514# CONFIG_SCSI_AIC7XXX is not set
515# CONFIG_SCSI_AIC7XXX_OLD is not set
516# CONFIG_SCSI_AIC79XX is not set
517# CONFIG_SCSI_AIC94XX is not set
518# CONFIG_SCSI_DPT_I2O is not set
519# CONFIG_SCSI_ADVANSYS is not set
520# CONFIG_SCSI_ARCMSR is not set
521# CONFIG_MEGARAID_NEWGEN is not set
522# CONFIG_MEGARAID_LEGACY is not set
523# CONFIG_MEGARAID_SAS is not set
524# CONFIG_SCSI_HPTIOP is not set
525# CONFIG_LIBFC is not set
526# CONFIG_FCOE is not set
527# CONFIG_SCSI_DMX3191D is not set
528# CONFIG_SCSI_FUTURE_DOMAIN is not set
529# CONFIG_SCSI_IPS is not set
530# CONFIG_SCSI_INITIO is not set
531# CONFIG_SCSI_INIA100 is not set
532# CONFIG_SCSI_MVSAS is not set
533# CONFIG_SCSI_STEX is not set
534CONFIG_SCSI_SYM53C8XX_2=y
535CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
536CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
537CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
538CONFIG_SCSI_SYM53C8XX_MMIO=y
539CONFIG_SCSI_QLOGIC_1280=y
540# CONFIG_SCSI_QLA_FC is not set
541# CONFIG_SCSI_QLA_ISCSI is not set
542# CONFIG_SCSI_LPFC is not set
543# CONFIG_SCSI_DC395x is not set
544# CONFIG_SCSI_DC390T is not set
545# CONFIG_SCSI_DEBUG is not set
546# CONFIG_SCSI_SRP is not set
547# CONFIG_SCSI_DH is not set
548# CONFIG_ATA is not set
549CONFIG_MD=y
550CONFIG_BLK_DEV_MD=m
551CONFIG_MD_LINEAR=m
552CONFIG_MD_RAID0=m
553CONFIG_MD_RAID1=m
554# CONFIG_MD_RAID10 is not set
555# CONFIG_MD_RAID456 is not set
556CONFIG_MD_MULTIPATH=m
557# CONFIG_MD_FAULTY is not set
558CONFIG_BLK_DEV_DM=m
559# CONFIG_DM_DEBUG is not set
560CONFIG_DM_CRYPT=m
561CONFIG_DM_SNAPSHOT=m
562CONFIG_DM_MIRROR=m
563CONFIG_DM_ZERO=m
564# CONFIG_DM_MULTIPATH is not set
565# CONFIG_DM_DELAY is not set
566# CONFIG_DM_UEVENT is not set
567CONFIG_FUSION=y
568CONFIG_FUSION_SPI=y
569CONFIG_FUSION_FC=y
570# CONFIG_FUSION_SAS is not set
571CONFIG_FUSION_MAX_SGE=128
572CONFIG_FUSION_CTL=y
573# CONFIG_FUSION_LOGGING is not set
574
575#
576# IEEE 1394 (FireWire) support
577#
578
579#
580# Enable only one of the two stacks, unless you know what you are doing
581#
582# CONFIG_FIREWIRE is not set
583# CONFIG_IEEE1394 is not set
584# CONFIG_I2O is not set
585CONFIG_NETDEVICES=y
586CONFIG_DUMMY=m
587# CONFIG_BONDING is not set
588# CONFIG_MACVLAN is not set
589# CONFIG_EQUALIZER is not set
590# CONFIG_TUN is not set
591# CONFIG_VETH is not set
592# CONFIG_NET_SB1000 is not set
593# CONFIG_ARCNET is not set
594CONFIG_PHYLIB=y
595
596#
597# MII PHY device drivers
598#
599# CONFIG_MARVELL_PHY is not set
600# CONFIG_DAVICOM_PHY is not set
601# CONFIG_QSEMI_PHY is not set
602# CONFIG_LXT_PHY is not set
603# CONFIG_CICADA_PHY is not set
604# CONFIG_VITESSE_PHY is not set
605# CONFIG_SMSC_PHY is not set
606# CONFIG_BROADCOM_PHY is not set
607# CONFIG_ICPLUS_PHY is not set
608# CONFIG_REALTEK_PHY is not set
609# CONFIG_NATIONAL_PHY is not set
610# CONFIG_STE10XP is not set
611# CONFIG_LSI_ET1011C_PHY is not set
612# CONFIG_FIXED_PHY is not set
613# CONFIG_MDIO_BITBANG is not set
614CONFIG_NET_ETHERNET=y
615CONFIG_MII=m
616# CONFIG_HAPPYMEAL is not set
617# CONFIG_SUNGEM is not set
618# CONFIG_CASSINI is not set
619# CONFIG_NET_VENDOR_3COM is not set
620CONFIG_NET_TULIP=y
621# CONFIG_DE2104X is not set
622CONFIG_TULIP=m
623# CONFIG_TULIP_MWI is not set
624# CONFIG_TULIP_MMIO is not set
625# CONFIG_TULIP_NAPI is not set
626# CONFIG_DE4X5 is not set
627# CONFIG_WINBOND_840 is not set
628# CONFIG_DM9102 is not set
629# CONFIG_ULI526X is not set
630# CONFIG_HP100 is not set
631# CONFIG_IBM_NEW_EMAC_ZMII is not set
632# CONFIG_IBM_NEW_EMAC_RGMII is not set
633# CONFIG_IBM_NEW_EMAC_TAH is not set
634# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
635# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
636# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
637# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
638CONFIG_NET_PCI=y
639# CONFIG_PCNET32 is not set
640# CONFIG_AMD8111_ETH is not set
641# CONFIG_ADAPTEC_STARFIRE is not set
642# CONFIG_B44 is not set
643# CONFIG_FORCEDETH is not set
644CONFIG_E100=m
645# CONFIG_FEALNX is not set
646# CONFIG_NATSEMI is not set
647# CONFIG_NE2K_PCI is not set
648# CONFIG_8139CP is not set
649# CONFIG_8139TOO is not set
650# CONFIG_R6040 is not set
651# CONFIG_SIS900 is not set
652# CONFIG_EPIC100 is not set
653# CONFIG_SMSC9420 is not set
654# CONFIG_SUNDANCE is not set
655# CONFIG_TLAN is not set
656# CONFIG_VIA_RHINE is not set
657# CONFIG_SC92031 is not set
658# CONFIG_ATL2 is not set
659CONFIG_NETDEV_1000=y
660# CONFIG_ACENIC is not set
661# CONFIG_DL2K is not set
662CONFIG_E1000=y
663# CONFIG_E1000E is not set
664# CONFIG_IP1000 is not set
665# CONFIG_IGB is not set
666# CONFIG_NS83820 is not set
667# CONFIG_HAMACHI is not set
668# CONFIG_YELLOWFIN is not set
669# CONFIG_R8169 is not set
670# CONFIG_SIS190 is not set
671# CONFIG_SKGE is not set
672# CONFIG_SKY2 is not set
673# CONFIG_VIA_VELOCITY is not set
674CONFIG_TIGON3=y
675# CONFIG_BNX2 is not set
676# CONFIG_QLA3XXX is not set
677# CONFIG_ATL1 is not set
678# CONFIG_ATL1E is not set
679# CONFIG_JME is not set
680CONFIG_NETDEV_10000=y
681# CONFIG_CHELSIO_T1 is not set
682CONFIG_CHELSIO_T3_DEPENDS=y
683# CONFIG_CHELSIO_T3 is not set
684# CONFIG_ENIC is not set
685# CONFIG_IXGBE is not set
686# CONFIG_IXGB is not set
687# CONFIG_S2IO is not set
688# CONFIG_MYRI10GE is not set
689# CONFIG_NETXEN_NIC is not set
690# CONFIG_NIU is not set
691# CONFIG_MLX4_EN is not set
692# CONFIG_MLX4_CORE is not set
693# CONFIG_TEHUTI is not set
694# CONFIG_BNX2X is not set
695# CONFIG_QLGE is not set
696# CONFIG_SFC is not set
697# CONFIG_TR is not set
698
699#
700# Wireless LAN
701#
702# CONFIG_WLAN_PRE80211 is not set
703# CONFIG_WLAN_80211 is not set
704# CONFIG_IWLWIFI_LEDS is not set
705
706#
707# Enable WiMAX (Networking options) to see the WiMAX drivers
708#
709
710#
711# USB Network Adapters
712#
713# CONFIG_USB_CATC is not set
714# CONFIG_USB_KAWETH is not set
715# CONFIG_USB_PEGASUS is not set
716# CONFIG_USB_RTL8150 is not set
717# CONFIG_USB_USBNET is not set
718# CONFIG_WAN is not set
719CONFIG_XEN_NETDEV_FRONTEND=y
720# CONFIG_FDDI is not set
721# CONFIG_HIPPI is not set
722# CONFIG_PPP is not set
723# CONFIG_SLIP is not set
724# CONFIG_NET_FC is not set
725CONFIG_NETCONSOLE=y
726# CONFIG_NETCONSOLE_DYNAMIC is not set
727CONFIG_NETPOLL=y
728# CONFIG_NETPOLL_TRAP is not set
729CONFIG_NET_POLL_CONTROLLER=y
730# CONFIG_ISDN is not set
731# CONFIG_PHONE is not set
732
733#
734# Input device support
735#
736CONFIG_INPUT=y
737# CONFIG_INPUT_FF_MEMLESS is not set
738# CONFIG_INPUT_POLLDEV is not set
739
740#
741# Userland interfaces
742#
743CONFIG_INPUT_MOUSEDEV=y
744CONFIG_INPUT_MOUSEDEV_PSAUX=y
745CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
746CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
747# CONFIG_INPUT_JOYDEV is not set
748# CONFIG_INPUT_EVDEV is not set
749# CONFIG_INPUT_EVBUG is not set
750
751#
752# Input Device Drivers
753#
754CONFIG_INPUT_KEYBOARD=y
755CONFIG_KEYBOARD_ATKBD=y
756# CONFIG_KEYBOARD_SUNKBD is not set
757# CONFIG_KEYBOARD_LKKBD is not set
758# CONFIG_KEYBOARD_XTKBD is not set
759# CONFIG_KEYBOARD_NEWTON is not set
760# CONFIG_KEYBOARD_STOWAWAY is not set
761CONFIG_INPUT_MOUSE=y
762CONFIG_MOUSE_PS2=y
763CONFIG_MOUSE_PS2_ALPS=y
764CONFIG_MOUSE_PS2_LOGIPS2PP=y
765CONFIG_MOUSE_PS2_SYNAPTICS=y
766CONFIG_MOUSE_PS2_LIFEBOOK=y
767CONFIG_MOUSE_PS2_TRACKPOINT=y
768# CONFIG_MOUSE_PS2_ELANTECH is not set
769# CONFIG_MOUSE_PS2_TOUCHKIT is not set
770# CONFIG_MOUSE_SERIAL is not set
771# CONFIG_MOUSE_APPLETOUCH is not set
772# CONFIG_MOUSE_BCM5974 is not set
773# CONFIG_MOUSE_VSXXXAA is not set
774# CONFIG_INPUT_JOYSTICK is not set
775# CONFIG_INPUT_TABLET is not set
776# CONFIG_INPUT_TOUCHSCREEN is not set
777# CONFIG_INPUT_MISC is not set
778
779#
780# Hardware I/O ports
781#
782CONFIG_SERIO=y
783CONFIG_SERIO_I8042=y
784# CONFIG_SERIO_SERPORT is not set
785# CONFIG_SERIO_PCIPS2 is not set
786CONFIG_SERIO_LIBPS2=y
787# CONFIG_SERIO_RAW is not set
788CONFIG_GAMEPORT=m
789# CONFIG_GAMEPORT_NS558 is not set
790# CONFIG_GAMEPORT_L4 is not set
791# CONFIG_GAMEPORT_EMU10K1 is not set
792# CONFIG_GAMEPORT_FM801 is not set
793
794#
795# Character devices
796#
797CONFIG_VT=y
798CONFIG_CONSOLE_TRANSLATIONS=y
799CONFIG_VT_CONSOLE=y
800CONFIG_HW_CONSOLE=y
801# CONFIG_VT_HW_CONSOLE_BINDING is not set
802CONFIG_DEVKMEM=y
803CONFIG_SERIAL_NONSTANDARD=y
804# CONFIG_COMPUTONE is not set
805# CONFIG_ROCKETPORT is not set
806# CONFIG_CYCLADES is not set
807# CONFIG_DIGIEPCA is not set
808# CONFIG_MOXA_INTELLIO is not set
809# CONFIG_MOXA_SMARTIO is not set
810# CONFIG_ISI is not set
811# CONFIG_SYNCLINKMP is not set
812# CONFIG_SYNCLINK_GT is not set
813# CONFIG_N_HDLC is not set
814# CONFIG_RISCOM8 is not set
815# CONFIG_SPECIALIX is not set
816# CONFIG_SX is not set
817# CONFIG_RIO is not set
818# CONFIG_STALDRV is not set
819# CONFIG_NOZOMI is not set
820
821#
822# Serial drivers
823#
824CONFIG_SERIAL_8250=y
825CONFIG_SERIAL_8250_CONSOLE=y
826CONFIG_SERIAL_8250_PCI=y
827CONFIG_SERIAL_8250_PNP=y
828CONFIG_SERIAL_8250_NR_UARTS=6
829CONFIG_SERIAL_8250_RUNTIME_UARTS=4
830CONFIG_SERIAL_8250_EXTENDED=y
831CONFIG_SERIAL_8250_SHARE_IRQ=y
832# CONFIG_SERIAL_8250_DETECT_IRQ is not set
833# CONFIG_SERIAL_8250_RSA is not set
834
835#
836# Non-8250 serial port support
837#
838CONFIG_SERIAL_CORE=y
839CONFIG_SERIAL_CORE_CONSOLE=y
840# CONFIG_SERIAL_JSM is not set
841CONFIG_UNIX98_PTYS=y
842# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
843CONFIG_LEGACY_PTYS=y
844CONFIG_LEGACY_PTY_COUNT=256
845CONFIG_HVC_DRIVER=y
846CONFIG_HVC_IRQ=y
847CONFIG_HVC_XEN=y
848# CONFIG_IPMI_HANDLER is not set
849# CONFIG_HW_RANDOM is not set
850CONFIG_EFI_RTC=y
851# CONFIG_R3964 is not set
852# CONFIG_APPLICOM is not set
853CONFIG_RAW_DRIVER=m
854CONFIG_MAX_RAW_DEVS=256
855CONFIG_HPET=y
856CONFIG_HPET_MMAP=y
857# CONFIG_HANGCHECK_TIMER is not set
858# CONFIG_TCG_TPM is not set
859CONFIG_DEVPORT=y
860CONFIG_I2C=m
861CONFIG_I2C_BOARDINFO=y
862# CONFIG_I2C_CHARDEV is not set
863CONFIG_I2C_HELPER_AUTO=y
864CONFIG_I2C_ALGOBIT=m
865
866#
867# I2C Hardware Bus support
868#
869
870#
871# PC SMBus host controller drivers
872#
873# CONFIG_I2C_ALI1535 is not set
874# CONFIG_I2C_ALI1563 is not set
875# CONFIG_I2C_ALI15X3 is not set
876# CONFIG_I2C_AMD756 is not set
877# CONFIG_I2C_AMD8111 is not set
878# CONFIG_I2C_I801 is not set
879# CONFIG_I2C_ISCH is not set
880# CONFIG_I2C_PIIX4 is not set
881# CONFIG_I2C_NFORCE2 is not set
882# CONFIG_I2C_SIS5595 is not set
883# CONFIG_I2C_SIS630 is not set
884# CONFIG_I2C_SIS96X is not set
885# CONFIG_I2C_VIA is not set
886# CONFIG_I2C_VIAPRO is not set
887
888#
889# I2C system bus drivers (mostly embedded / system-on-chip)
890#
891# CONFIG_I2C_OCORES is not set
892# CONFIG_I2C_SIMTEC is not set
893
894#
895# External I2C/SMBus adapter drivers
896#
897# CONFIG_I2C_PARPORT_LIGHT is not set
898# CONFIG_I2C_TAOS_EVM is not set
899# CONFIG_I2C_TINY_USB is not set
900
901#
902# Graphics adapter I2C/DDC channel drivers
903#
904# CONFIG_I2C_VOODOO3 is not set
905
906#
907# Other I2C/SMBus bus drivers
908#
909# CONFIG_I2C_PCA_PLATFORM is not set
910# CONFIG_I2C_STUB is not set
911
912#
913# Miscellaneous I2C Chip support
914#
915# CONFIG_DS1682 is not set
916# CONFIG_AT24 is not set
917# CONFIG_SENSORS_EEPROM is not set
918# CONFIG_SENSORS_PCF8574 is not set
919# CONFIG_PCF8575 is not set
920# CONFIG_SENSORS_PCA9539 is not set
921# CONFIG_SENSORS_PCF8591 is not set
922# CONFIG_SENSORS_MAX6875 is not set
923# CONFIG_SENSORS_TSL2550 is not set
924# CONFIG_I2C_DEBUG_CORE is not set
925# CONFIG_I2C_DEBUG_ALGO is not set
926# CONFIG_I2C_DEBUG_BUS is not set
927# CONFIG_I2C_DEBUG_CHIP is not set
928# CONFIG_SPI is not set
929# CONFIG_W1 is not set
930CONFIG_POWER_SUPPLY=y
931# CONFIG_POWER_SUPPLY_DEBUG is not set
932# CONFIG_PDA_POWER is not set
933# CONFIG_BATTERY_DS2760 is not set
934# CONFIG_BATTERY_BQ27x00 is not set
935CONFIG_HWMON=y
936# CONFIG_HWMON_VID is not set
937# CONFIG_SENSORS_AD7414 is not set
938# CONFIG_SENSORS_AD7418 is not set
939# CONFIG_SENSORS_ADM1021 is not set
940# CONFIG_SENSORS_ADM1025 is not set
941# CONFIG_SENSORS_ADM1026 is not set
942# CONFIG_SENSORS_ADM1029 is not set
943# CONFIG_SENSORS_ADM1031 is not set
944# CONFIG_SENSORS_ADM9240 is not set
945# CONFIG_SENSORS_ADT7462 is not set
946# CONFIG_SENSORS_ADT7470 is not set
947# CONFIG_SENSORS_ADT7473 is not set
948# CONFIG_SENSORS_ATXP1 is not set
949# CONFIG_SENSORS_DS1621 is not set
950# CONFIG_SENSORS_I5K_AMB is not set
951# CONFIG_SENSORS_F71805F is not set
952# CONFIG_SENSORS_F71882FG is not set
953# CONFIG_SENSORS_F75375S is not set
954# CONFIG_SENSORS_GL518SM is not set
955# CONFIG_SENSORS_GL520SM is not set
956# CONFIG_SENSORS_IT87 is not set
957# CONFIG_SENSORS_LM63 is not set
958# CONFIG_SENSORS_LM75 is not set
959# CONFIG_SENSORS_LM77 is not set
960# CONFIG_SENSORS_LM78 is not set
961# CONFIG_SENSORS_LM80 is not set
962# CONFIG_SENSORS_LM83 is not set
963# CONFIG_SENSORS_LM85 is not set
964# CONFIG_SENSORS_LM87 is not set
965# CONFIG_SENSORS_LM90 is not set
966# CONFIG_SENSORS_LM92 is not set
967# CONFIG_SENSORS_LM93 is not set
968# CONFIG_SENSORS_LTC4245 is not set
969# CONFIG_SENSORS_MAX1619 is not set
970# CONFIG_SENSORS_MAX6650 is not set
971# CONFIG_SENSORS_PC87360 is not set
972# CONFIG_SENSORS_PC87427 is not set
973# CONFIG_SENSORS_SIS5595 is not set
974# CONFIG_SENSORS_DME1737 is not set
975# CONFIG_SENSORS_SMSC47M1 is not set
976# CONFIG_SENSORS_SMSC47M192 is not set
977# CONFIG_SENSORS_SMSC47B397 is not set
978# CONFIG_SENSORS_ADS7828 is not set
979# CONFIG_SENSORS_THMC50 is not set
980# CONFIG_SENSORS_VIA686A is not set
981# CONFIG_SENSORS_VT1211 is not set
982# CONFIG_SENSORS_VT8231 is not set
983# CONFIG_SENSORS_W83781D is not set
984# CONFIG_SENSORS_W83791D is not set
985# CONFIG_SENSORS_W83792D is not set
986# CONFIG_SENSORS_W83793 is not set
987# CONFIG_SENSORS_W83L785TS is not set
988# CONFIG_SENSORS_W83L786NG is not set
989# CONFIG_SENSORS_W83627HF is not set
990# CONFIG_SENSORS_W83627EHF is not set
991# CONFIG_SENSORS_LIS3LV02D is not set
992# CONFIG_HWMON_DEBUG_CHIP is not set
993CONFIG_THERMAL=m
994# CONFIG_THERMAL_HWMON is not set
995# CONFIG_WATCHDOG is not set
996CONFIG_SSB_POSSIBLE=y
997
998#
999# Sonics Silicon Backplane
1000#
1001# CONFIG_SSB is not set
1002
1003#
1004# Multifunction device drivers
1005#
1006# CONFIG_MFD_CORE is not set
1007# CONFIG_MFD_SM501 is not set
1008# CONFIG_HTC_PASIC3 is not set
1009# CONFIG_MFD_TMIO is not set
1010# CONFIG_MFD_WM8400 is not set
1011# CONFIG_MFD_WM8350_I2C is not set
1012# CONFIG_MFD_PCF50633 is not set
1013# CONFIG_REGULATOR is not set
1014
1015#
1016# Multimedia devices
1017#
1018
1019#
1020# Multimedia core support
1021#
1022# CONFIG_VIDEO_DEV is not set
1023# CONFIG_DVB_CORE is not set
1024# CONFIG_VIDEO_MEDIA is not set
1025
1026#
1027# Multimedia drivers
1028#
1029CONFIG_DAB=y
1030# CONFIG_USB_DABUSB is not set
1031
1032#
1033# Graphics support
1034#
1035CONFIG_AGP=m
1036CONFIG_DRM=m
1037CONFIG_DRM_TDFX=m
1038CONFIG_DRM_R128=m
1039CONFIG_DRM_RADEON=m
1040CONFIG_DRM_MGA=m
1041CONFIG_DRM_SIS=m
1042# CONFIG_DRM_VIA is not set
1043# CONFIG_DRM_SAVAGE is not set
1044# CONFIG_VGASTATE is not set
1045# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1046# CONFIG_FB is not set
1047# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1048
1049#
1050# Display device support
1051#
1052# CONFIG_DISPLAY_SUPPORT is not set
1053
1054#
1055# Console display driver support
1056#
1057CONFIG_VGA_CONSOLE=y
1058# CONFIG_VGACON_SOFT_SCROLLBACK is not set
1059CONFIG_DUMMY_CONSOLE=y
1060# CONFIG_SOUND is not set
1061CONFIG_HID_SUPPORT=y
1062CONFIG_HID=y
1063# CONFIG_HID_DEBUG is not set
1064# CONFIG_HIDRAW is not set
1065
1066#
1067# USB Input Devices
1068#
1069CONFIG_USB_HID=y
1070# CONFIG_HID_PID is not set
1071# CONFIG_USB_HIDDEV is not set
1072
1073#
1074# Special HID drivers
1075#
1076CONFIG_HID_COMPAT=y
1077CONFIG_HID_A4TECH=y
1078CONFIG_HID_APPLE=y
1079CONFIG_HID_BELKIN=y
1080CONFIG_HID_CHERRY=y
1081CONFIG_HID_CHICONY=y
1082CONFIG_HID_CYPRESS=y
1083CONFIG_HID_EZKEY=y
1084CONFIG_HID_GYRATION=y
1085CONFIG_HID_LOGITECH=y
1086# CONFIG_LOGITECH_FF is not set
1087# CONFIG_LOGIRUMBLEPAD2_FF is not set
1088CONFIG_HID_MICROSOFT=y
1089CONFIG_HID_MONTEREY=y
1090CONFIG_HID_NTRIG=y
1091CONFIG_HID_PANTHERLORD=y
1092# CONFIG_PANTHERLORD_FF is not set
1093CONFIG_HID_PETALYNX=y
1094CONFIG_HID_SAMSUNG=y
1095CONFIG_HID_SONY=y
1096CONFIG_HID_SUNPLUS=y
1097# CONFIG_GREENASIA_FF is not set
1098CONFIG_HID_TOPSEED=y
1099# CONFIG_THRUSTMASTER_FF is not set
1100# CONFIG_ZEROPLUS_FF is not set
1101CONFIG_USB_SUPPORT=y
1102CONFIG_USB_ARCH_HAS_HCD=y
1103CONFIG_USB_ARCH_HAS_OHCI=y
1104CONFIG_USB_ARCH_HAS_EHCI=y
1105CONFIG_USB=y
1106# CONFIG_USB_DEBUG is not set
1107# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
1108
1109#
1110# Miscellaneous USB options
1111#
1112CONFIG_USB_DEVICEFS=y
1113CONFIG_USB_DEVICE_CLASS=y
1114# CONFIG_USB_DYNAMIC_MINORS is not set
1115# CONFIG_USB_SUSPEND is not set
1116# CONFIG_USB_OTG is not set
1117# CONFIG_USB_MON is not set
1118# CONFIG_USB_WUSB is not set
1119# CONFIG_USB_WUSB_CBAF is not set
1120
1121#
1122# USB Host Controller Drivers
1123#
1124# CONFIG_USB_C67X00_HCD is not set
1125CONFIG_USB_EHCI_HCD=m
1126# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1127# CONFIG_USB_EHCI_TT_NEWSCHED is not set
1128# CONFIG_USB_OXU210HP_HCD is not set
1129# CONFIG_USB_ISP116X_HCD is not set
1130# CONFIG_USB_ISP1760_HCD is not set
1131CONFIG_USB_OHCI_HCD=m
1132# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
1133# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
1134CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1135CONFIG_USB_UHCI_HCD=y
1136# CONFIG_USB_SL811_HCD is not set
1137# CONFIG_USB_R8A66597_HCD is not set
1138# CONFIG_USB_WHCI_HCD is not set
1139# CONFIG_USB_HWA_HCD is not set
1140
1141#
1142# USB Device Class drivers
1143#
1144# CONFIG_USB_ACM is not set
1145# CONFIG_USB_PRINTER is not set
1146# CONFIG_USB_WDM is not set
1147# CONFIG_USB_TMC is not set
1148
1149#
1150# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;
1151#
1152
1153#
1154# see USB_STORAGE Help for more information
1155#
1156CONFIG_USB_STORAGE=m
1157# CONFIG_USB_STORAGE_DEBUG is not set
1158# CONFIG_USB_STORAGE_DATAFAB is not set
1159# CONFIG_USB_STORAGE_FREECOM is not set
1160# CONFIG_USB_STORAGE_ISD200 is not set
1161# CONFIG_USB_STORAGE_USBAT is not set
1162# CONFIG_USB_STORAGE_SDDR09 is not set
1163# CONFIG_USB_STORAGE_SDDR55 is not set
1164# CONFIG_USB_STORAGE_JUMPSHOT is not set
1165# CONFIG_USB_STORAGE_ALAUDA is not set
1166# CONFIG_USB_STORAGE_ONETOUCH is not set
1167# CONFIG_USB_STORAGE_KARMA is not set
1168# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
1169# CONFIG_USB_LIBUSUAL is not set
1170
1171#
1172# USB Imaging devices
1173#
1174# CONFIG_USB_MDC800 is not set
1175# CONFIG_USB_MICROTEK is not set
1176
1177#
1178# USB port drivers
1179#
1180# CONFIG_USB_SERIAL is not set
1181
1182#
1183# USB Miscellaneous drivers
1184#
1185# CONFIG_USB_EMI62 is not set
1186# CONFIG_USB_EMI26 is not set
1187# CONFIG_USB_ADUTUX is not set
1188# CONFIG_USB_SEVSEG is not set
1189# CONFIG_USB_RIO500 is not set
1190# CONFIG_USB_LEGOTOWER is not set
1191# CONFIG_USB_LCD is not set
1192# CONFIG_USB_BERRY_CHARGE is not set
1193# CONFIG_USB_LED is not set
1194# CONFIG_USB_CYPRESS_CY7C63 is not set
1195# CONFIG_USB_CYTHERM is not set
1196# CONFIG_USB_PHIDGET is not set
1197# CONFIG_USB_IDMOUSE is not set
1198# CONFIG_USB_FTDI_ELAN is not set
1199# CONFIG_USB_APPLEDISPLAY is not set
1200# CONFIG_USB_SISUSBVGA is not set
1201# CONFIG_USB_LD is not set
1202# CONFIG_USB_TRANCEVIBRATOR is not set
1203# CONFIG_USB_IOWARRIOR is not set
1204# CONFIG_USB_TEST is not set
1205# CONFIG_USB_ISIGHTFW is not set
1206# CONFIG_USB_VST is not set
1207# CONFIG_USB_GADGET is not set
1208
1209#
1210# OTG and related infrastructure
1211#
1212# CONFIG_UWB is not set
1213# CONFIG_MMC is not set
1214# CONFIG_MEMSTICK is not set
1215# CONFIG_NEW_LEDS is not set
1216# CONFIG_ACCESSIBILITY is not set
1217# CONFIG_INFINIBAND is not set
1218# CONFIG_RTC_CLASS is not set
1219# CONFIG_DMADEVICES is not set
1220# CONFIG_UIO is not set
1221CONFIG_XEN_BALLOON=y
1222CONFIG_XEN_SCRUB_PAGES=y
1223CONFIG_XENFS=y
1224CONFIG_XEN_COMPAT_XENFS=y
1225# CONFIG_STAGING is not set
1226# CONFIG_MSPEC is not set
1227
1228#
1229# File systems
1230#
1231CONFIG_EXT2_FS=y
1232CONFIG_EXT2_FS_XATTR=y
1233CONFIG_EXT2_FS_POSIX_ACL=y
1234CONFIG_EXT2_FS_SECURITY=y
1235# CONFIG_EXT2_FS_XIP is not set
1236CONFIG_EXT3_FS=y
1237CONFIG_EXT3_FS_XATTR=y
1238CONFIG_EXT3_FS_POSIX_ACL=y
1239CONFIG_EXT3_FS_SECURITY=y
1240# CONFIG_EXT4_FS is not set
1241CONFIG_JBD=y
1242CONFIG_FS_MBCACHE=y
1243CONFIG_REISERFS_FS=y
1244# CONFIG_REISERFS_CHECK is not set
1245# CONFIG_REISERFS_PROC_INFO is not set
1246CONFIG_REISERFS_FS_XATTR=y
1247CONFIG_REISERFS_FS_POSIX_ACL=y
1248CONFIG_REISERFS_FS_SECURITY=y
1249# CONFIG_JFS_FS is not set
1250CONFIG_FS_POSIX_ACL=y
1251CONFIG_FILE_LOCKING=y
1252CONFIG_XFS_FS=y
1253# CONFIG_XFS_QUOTA is not set
1254# CONFIG_XFS_POSIX_ACL is not set
1255# CONFIG_XFS_RT is not set
1256# CONFIG_XFS_DEBUG is not set
1257# CONFIG_GFS2_FS is not set
1258# CONFIG_OCFS2_FS is not set
1259# CONFIG_BTRFS_FS is not set
1260CONFIG_DNOTIFY=y
1261CONFIG_INOTIFY=y
1262CONFIG_INOTIFY_USER=y
1263# CONFIG_QUOTA is not set
1264CONFIG_AUTOFS_FS=y
1265CONFIG_AUTOFS4_FS=y
1266# CONFIG_FUSE_FS is not set
1267
1268#
1269# CD-ROM/DVD Filesystems
1270#
1271CONFIG_ISO9660_FS=m
1272CONFIG_JOLIET=y
1273# CONFIG_ZISOFS is not set
1274CONFIG_UDF_FS=m
1275CONFIG_UDF_NLS=y
1276
1277#
1278# DOS/FAT/NT Filesystems
1279#
1280CONFIG_FAT_FS=y
1281# CONFIG_MSDOS_FS is not set
1282CONFIG_VFAT_FS=y
1283CONFIG_FAT_DEFAULT_CODEPAGE=437
1284CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1285CONFIG_NTFS_FS=m
1286# CONFIG_NTFS_DEBUG is not set
1287# CONFIG_NTFS_RW is not set
1288
1289#
1290# Pseudo filesystems
1291#
1292CONFIG_PROC_FS=y
1293CONFIG_PROC_KCORE=y
1294CONFIG_PROC_SYSCTL=y
1295CONFIG_PROC_PAGE_MONITOR=y
1296CONFIG_SYSFS=y
1297CONFIG_TMPFS=y
1298# CONFIG_TMPFS_POSIX_ACL is not set
1299CONFIG_HUGETLBFS=y
1300CONFIG_HUGETLB_PAGE=y
1301# CONFIG_CONFIGFS_FS is not set
1302CONFIG_MISC_FILESYSTEMS=y
1303# CONFIG_ADFS_FS is not set
1304# CONFIG_AFFS_FS is not set
1305# CONFIG_HFS_FS is not set
1306# CONFIG_HFSPLUS_FS is not set
1307# CONFIG_BEFS_FS is not set
1308# CONFIG_BFS_FS is not set
1309# CONFIG_EFS_FS is not set
1310# CONFIG_CRAMFS is not set
1311# CONFIG_SQUASHFS is not set
1312# CONFIG_VXFS_FS is not set
1313# CONFIG_MINIX_FS is not set
1314# CONFIG_OMFS_FS is not set
1315# CONFIG_HPFS_FS is not set
1316# CONFIG_QNX4FS_FS is not set
1317# CONFIG_ROMFS_FS is not set
1318# CONFIG_SYSV_FS is not set
1319# CONFIG_UFS_FS is not set
1320CONFIG_NETWORK_FILESYSTEMS=y
1321CONFIG_NFS_FS=m
1322CONFIG_NFS_V3=y
1323# CONFIG_NFS_V3_ACL is not set
1324CONFIG_NFS_V4=y
1325CONFIG_NFSD=m
1326CONFIG_NFSD_V3=y
1327# CONFIG_NFSD_V3_ACL is not set
1328CONFIG_NFSD_V4=y
1329CONFIG_LOCKD=m
1330CONFIG_LOCKD_V4=y
1331CONFIG_EXPORTFS=m
1332CONFIG_NFS_COMMON=y
1333CONFIG_SUNRPC=m
1334CONFIG_SUNRPC_GSS=m
1335# CONFIG_SUNRPC_REGISTER_V4 is not set
1336CONFIG_RPCSEC_GSS_KRB5=m
1337# CONFIG_RPCSEC_GSS_SPKM3 is not set
1338CONFIG_SMB_FS=m
1339CONFIG_SMB_NLS_DEFAULT=y
1340CONFIG_SMB_NLS_REMOTE="cp437"
1341CONFIG_CIFS=m
1342# CONFIG_CIFS_STATS is not set
1343# CONFIG_CIFS_WEAK_PW_HASH is not set
1344# CONFIG_CIFS_XATTR is not set
1345# CONFIG_CIFS_DEBUG2 is not set
1346# CONFIG_CIFS_EXPERIMENTAL is not set
1347# CONFIG_NCP_FS is not set
1348# CONFIG_CODA_FS is not set
1349# CONFIG_AFS_FS is not set
1350
1351#
1352# Partition Types
1353#
1354CONFIG_PARTITION_ADVANCED=y
1355# CONFIG_ACORN_PARTITION is not set
1356# CONFIG_OSF_PARTITION is not set
1357# CONFIG_AMIGA_PARTITION is not set
1358# CONFIG_ATARI_PARTITION is not set
1359# CONFIG_MAC_PARTITION is not set
1360CONFIG_MSDOS_PARTITION=y
1361# CONFIG_BSD_DISKLABEL is not set
1362# CONFIG_MINIX_SUBPARTITION is not set
1363# CONFIG_SOLARIS_X86_PARTITION is not set
1364# CONFIG_UNIXWARE_DISKLABEL is not set
1365# CONFIG_LDM_PARTITION is not set
1366CONFIG_SGI_PARTITION=y
1367# CONFIG_ULTRIX_PARTITION is not set
1368# CONFIG_SUN_PARTITION is not set
1369# CONFIG_KARMA_PARTITION is not set
1370CONFIG_EFI_PARTITION=y
1371# CONFIG_SYSV68_PARTITION is not set
1372CONFIG_NLS=y
1373CONFIG_NLS_DEFAULT="iso8859-1"
1374CONFIG_NLS_CODEPAGE_437=y
1375CONFIG_NLS_CODEPAGE_737=m
1376CONFIG_NLS_CODEPAGE_775=m
1377CONFIG_NLS_CODEPAGE_850=m
1378CONFIG_NLS_CODEPAGE_852=m
1379CONFIG_NLS_CODEPAGE_855=m
1380CONFIG_NLS_CODEPAGE_857=m
1381CONFIG_NLS_CODEPAGE_860=m
1382CONFIG_NLS_CODEPAGE_861=m
1383CONFIG_NLS_CODEPAGE_862=m
1384CONFIG_NLS_CODEPAGE_863=m
1385CONFIG_NLS_CODEPAGE_864=m
1386CONFIG_NLS_CODEPAGE_865=m
1387CONFIG_NLS_CODEPAGE_866=m
1388CONFIG_NLS_CODEPAGE_869=m
1389CONFIG_NLS_CODEPAGE_936=m
1390CONFIG_NLS_CODEPAGE_950=m
1391CONFIG_NLS_CODEPAGE_932=m
1392CONFIG_NLS_CODEPAGE_949=m
1393CONFIG_NLS_CODEPAGE_874=m
1394CONFIG_NLS_ISO8859_8=m
1395CONFIG_NLS_CODEPAGE_1250=m
1396CONFIG_NLS_CODEPAGE_1251=m
1397# CONFIG_NLS_ASCII is not set
1398CONFIG_NLS_ISO8859_1=y
1399CONFIG_NLS_ISO8859_2=m
1400CONFIG_NLS_ISO8859_3=m
1401CONFIG_NLS_ISO8859_4=m
1402CONFIG_NLS_ISO8859_5=m
1403CONFIG_NLS_ISO8859_6=m
1404CONFIG_NLS_ISO8859_7=m
1405CONFIG_NLS_ISO8859_9=m
1406CONFIG_NLS_ISO8859_13=m
1407CONFIG_NLS_ISO8859_14=m
1408CONFIG_NLS_ISO8859_15=m
1409CONFIG_NLS_KOI8_R=m
1410CONFIG_NLS_KOI8_U=m
1411CONFIG_NLS_UTF8=m
1412# CONFIG_DLM is not set
1413
1414#
1415# Kernel hacking
1416#
1417# CONFIG_PRINTK_TIME is not set
1418CONFIG_ENABLE_WARN_DEPRECATED=y
1419CONFIG_ENABLE_MUST_CHECK=y
1420CONFIG_FRAME_WARN=2048
1421CONFIG_MAGIC_SYSRQ=y
1422# CONFIG_UNUSED_SYMBOLS is not set
1423# CONFIG_DEBUG_FS is not set
1424# CONFIG_HEADERS_CHECK is not set
1425CONFIG_DEBUG_KERNEL=y
1426# CONFIG_DEBUG_SHIRQ is not set
1427CONFIG_DETECT_SOFTLOCKUP=y
1428# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1429CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1430CONFIG_SCHED_DEBUG=y
1431# CONFIG_SCHEDSTATS is not set
1432# CONFIG_TIMER_STATS is not set
1433# CONFIG_DEBUG_OBJECTS is not set
1434# CONFIG_SLUB_DEBUG_ON is not set
1435# CONFIG_SLUB_STATS is not set
1436# CONFIG_DEBUG_RT_MUTEXES is not set
1437# CONFIG_RT_MUTEX_TESTER is not set
1438# CONFIG_DEBUG_SPINLOCK is not set
1439CONFIG_DEBUG_MUTEXES=y
1440# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1441# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1442# CONFIG_DEBUG_KOBJECT is not set
1443# CONFIG_DEBUG_INFO is not set
1444# CONFIG_DEBUG_VM is not set
1445# CONFIG_DEBUG_WRITECOUNT is not set
1446CONFIG_DEBUG_MEMORY_INIT=y
1447# CONFIG_DEBUG_LIST is not set
1448# CONFIG_DEBUG_SG is not set
1449# CONFIG_DEBUG_NOTIFIERS is not set
1450# CONFIG_BOOT_PRINTK_DELAY is not set
1451# CONFIG_RCU_TORTURE_TEST is not set
1452# CONFIG_RCU_CPU_STALL_DETECTOR is not set
1453# CONFIG_BACKTRACE_SELF_TEST is not set
1454# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1455# CONFIG_FAULT_INJECTION is not set
1456# CONFIG_SYSCTL_SYSCALL_CHECK is not set
1457
1458#
1459# Tracers
1460#
1461# CONFIG_SCHED_TRACER is not set
1462# CONFIG_CONTEXT_SWITCH_TRACER is not set
1463# CONFIG_BOOT_TRACER is not set
1464# CONFIG_TRACE_BRANCH_PROFILING is not set
1465# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
1466# CONFIG_SAMPLES is not set
1467CONFIG_IA64_GRANULE_16MB=y
1468# CONFIG_IA64_GRANULE_64MB is not set
1469# CONFIG_IA64_PRINT_HAZARDS is not set
1470# CONFIG_DISABLE_VHPT is not set
1471# CONFIG_IA64_DEBUG_CMPXCHG is not set
1472# CONFIG_IA64_DEBUG_IRQ is not set
1473
1474#
1475# Security options
1476#
1477# CONFIG_KEYS is not set
1478# CONFIG_SECURITY is not set
1479# CONFIG_SECURITYFS is not set
1480# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1481CONFIG_CRYPTO=y
1482
1483#
1484# Crypto core or helper
1485#
1486# CONFIG_CRYPTO_FIPS is not set
1487CONFIG_CRYPTO_ALGAPI=y
1488CONFIG_CRYPTO_ALGAPI2=y
1489CONFIG_CRYPTO_AEAD2=y
1490CONFIG_CRYPTO_BLKCIPHER=m
1491CONFIG_CRYPTO_BLKCIPHER2=y
1492CONFIG_CRYPTO_HASH=y
1493CONFIG_CRYPTO_HASH2=y
1494CONFIG_CRYPTO_RNG2=y
1495CONFIG_CRYPTO_MANAGER=m
1496CONFIG_CRYPTO_MANAGER2=y
1497# CONFIG_CRYPTO_GF128MUL is not set
1498# CONFIG_CRYPTO_NULL is not set
1499# CONFIG_CRYPTO_CRYPTD is not set
1500# CONFIG_CRYPTO_AUTHENC is not set
1501# CONFIG_CRYPTO_TEST is not set
1502
1503#
1504# Authenticated Encryption with Associated Data
1505#
1506# CONFIG_CRYPTO_CCM is not set
1507# CONFIG_CRYPTO_GCM is not set
1508# CONFIG_CRYPTO_SEQIV is not set
1509
1510#
1511# Block modes
1512#
1513CONFIG_CRYPTO_CBC=m
1514# CONFIG_CRYPTO_CTR is not set
1515# CONFIG_CRYPTO_CTS is not set
1516CONFIG_CRYPTO_ECB=m
1517# CONFIG_CRYPTO_LRW is not set
1518CONFIG_CRYPTO_PCBC=m
1519# CONFIG_CRYPTO_XTS is not set
1520
1521#
1522# Hash modes
1523#
1524# CONFIG_CRYPTO_HMAC is not set
1525# CONFIG_CRYPTO_XCBC is not set
1526
1527#
1528# Digest
1529#
1530# CONFIG_CRYPTO_CRC32C is not set
1531# CONFIG_CRYPTO_MD4 is not set
1532CONFIG_CRYPTO_MD5=y
1533# CONFIG_CRYPTO_MICHAEL_MIC is not set
1534# CONFIG_CRYPTO_RMD128 is not set
1535# CONFIG_CRYPTO_RMD160 is not set
1536# CONFIG_CRYPTO_RMD256 is not set
1537# CONFIG_CRYPTO_RMD320 is not set
1538# CONFIG_CRYPTO_SHA1 is not set
1539# CONFIG_CRYPTO_SHA256 is not set
1540# CONFIG_CRYPTO_SHA512 is not set
1541# CONFIG_CRYPTO_TGR192 is not set
1542# CONFIG_CRYPTO_WP512 is not set
1543
1544#
1545# Ciphers
1546#
1547# CONFIG_CRYPTO_AES is not set
1548# CONFIG_CRYPTO_ANUBIS is not set
1549# CONFIG_CRYPTO_ARC4 is not set
1550# CONFIG_CRYPTO_BLOWFISH is not set
1551# CONFIG_CRYPTO_CAMELLIA is not set
1552# CONFIG_CRYPTO_CAST5 is not set
1553# CONFIG_CRYPTO_CAST6 is not set
1554CONFIG_CRYPTO_DES=m
1555# CONFIG_CRYPTO_FCRYPT is not set
1556# CONFIG_CRYPTO_KHAZAD is not set
1557# CONFIG_CRYPTO_SALSA20 is not set
1558# CONFIG_CRYPTO_SEED is not set
1559# CONFIG_CRYPTO_SERPENT is not set
1560# CONFIG_CRYPTO_TEA is not set
1561# CONFIG_CRYPTO_TWOFISH is not set
1562
1563#
1564# Compression
1565#
1566# CONFIG_CRYPTO_DEFLATE is not set
1567# CONFIG_CRYPTO_LZO is not set
1568
1569#
1570# Random Number Generation
1571#
1572# CONFIG_CRYPTO_ANSI_CPRNG is not set
1573CONFIG_CRYPTO_HW=y
1574# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1575CONFIG_HAVE_KVM=y
1576CONFIG_VIRTUALIZATION=y
1577# CONFIG_KVM is not set
1578# CONFIG_VIRTIO_PCI is not set
1579# CONFIG_VIRTIO_BALLOON is not set
1580
1581#
1582# Library routines
1583#
1584CONFIG_BITREVERSE=y
1585CONFIG_GENERIC_FIND_LAST_BIT=y
1586# CONFIG_CRC_CCITT is not set
1587# CONFIG_CRC16 is not set
1588# CONFIG_CRC_T10DIF is not set
1589CONFIG_CRC_ITU_T=m
1590CONFIG_CRC32=y
1591# CONFIG_CRC7 is not set
1592# CONFIG_LIBCRC32C is not set
1593CONFIG_PLIST=y
1594CONFIG_HAS_IOMEM=y
1595CONFIG_HAS_IOPORT=y
1596CONFIG_HAS_DMA=y
1597CONFIG_GENERIC_HARDIRQS=y
1598CONFIG_GENERIC_IRQ_PROBE=y
1599CONFIG_GENERIC_PENDING_IRQ=y
1600CONFIG_IRQ_PER_CPU=y
1601# CONFIG_IOMMU_API is not set
diff --git a/arch/ia64/include/asm/kvm.h b/arch/ia64/include/asm/kvm.h
index 68aa6da807c1..bfa86b6af7cd 100644
--- a/arch/ia64/include/asm/kvm.h
+++ b/arch/ia64/include/asm/kvm.h
@@ -25,6 +25,10 @@
25 25
26#include <linux/ioctl.h> 26#include <linux/ioctl.h>
27 27
28/* Select x86 specific features in <linux/kvm.h> */
29#define __KVM_HAVE_IOAPIC
30#define __KVM_HAVE_DEVICE_ASSIGNMENT
31
28/* Architectural interrupt line count. */ 32/* Architectural interrupt line count. */
29#define KVM_NR_INTERRUPTS 256 33#define KVM_NR_INTERRUPTS 256
30 34
diff --git a/arch/ia64/include/asm/mmzone.h b/arch/ia64/include/asm/mmzone.h
index 34efe88eb849..f2ca32069b3f 100644
--- a/arch/ia64/include/asm/mmzone.h
+++ b/arch/ia64/include/asm/mmzone.h
@@ -31,10 +31,6 @@ static inline int pfn_to_nid(unsigned long pfn)
31#endif 31#endif
32} 32}
33 33
34#ifdef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
35extern int early_pfn_to_nid(unsigned long pfn);
36#endif
37
38#ifdef CONFIG_IA64_DIG /* DIG systems are small */ 34#ifdef CONFIG_IA64_DIG /* DIG systems are small */
39# define MAX_PHYSNODE_ID 8 35# define MAX_PHYSNODE_ID 8
40# define NR_NODE_MEMBLKS (MAX_NUMNODES * 8) 36# define NR_NODE_MEMBLKS (MAX_NUMNODES * 8)
diff --git a/arch/ia64/include/asm/sn/bte.h b/arch/ia64/include/asm/sn/bte.h
index 5efecf06c9a4..96798d2da7c2 100644
--- a/arch/ia64/include/asm/sn/bte.h
+++ b/arch/ia64/include/asm/sn/bte.h
@@ -39,7 +39,7 @@
39/* BTE status register only supports 16 bits for length field */ 39/* BTE status register only supports 16 bits for length field */
40#define BTE_LEN_BITS (16) 40#define BTE_LEN_BITS (16)
41#define BTE_LEN_MASK ((1 << BTE_LEN_BITS) - 1) 41#define BTE_LEN_MASK ((1 << BTE_LEN_BITS) - 1)
42#define BTE_MAX_XFER ((1 << BTE_LEN_BITS) * L1_CACHE_BYTES) 42#define BTE_MAX_XFER (BTE_LEN_MASK << L1_CACHE_SHIFT)
43 43
44 44
45/* Define hardware */ 45/* Define hardware */
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 11463994a7d5..52290547c85b 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -736,14 +736,15 @@ int __cpu_disable(void)
736 return -EBUSY; 736 return -EBUSY;
737 } 737 }
738 738
739 cpu_clear(cpu, cpu_online_map);
740
739 if (migrate_platform_irqs(cpu)) { 741 if (migrate_platform_irqs(cpu)) {
740 cpu_set(cpu, cpu_online_map); 742 cpu_set(cpu, cpu_online_map);
741 return (-EBUSY); 743 return -EBUSY;
742 } 744 }
743 745
744 remove_siblinginfo(cpu); 746 remove_siblinginfo(cpu);
745 fixup_irqs(); 747 fixup_irqs();
746 cpu_clear(cpu, cpu_online_map);
747 local_flush_tlb_all(); 748 local_flush_tlb_all();
748 cpu_clear(cpu, cpu_callin_map); 749 cpu_clear(cpu, cpu_callin_map);
749 return 0; 750 return 0;
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 4e586f6110aa..28f982045f29 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1337,6 +1337,10 @@ static void kvm_release_vm_pages(struct kvm *kvm)
1337 } 1337 }
1338} 1338}
1339 1339
1340void kvm_arch_sync_events(struct kvm *kvm)
1341{
1342}
1343
1340void kvm_arch_destroy_vm(struct kvm *kvm) 1344void kvm_arch_destroy_vm(struct kvm *kvm)
1341{ 1345{
1342 kvm_iommu_unmap_guest(kvm); 1346 kvm_iommu_unmap_guest(kvm);
diff --git a/arch/ia64/kvm/process.c b/arch/ia64/kvm/process.c
index 552d07724207..230eae482f32 100644
--- a/arch/ia64/kvm/process.c
+++ b/arch/ia64/kvm/process.c
@@ -455,13 +455,18 @@ fpswa_ret_t vmm_fp_emulate(int fp_fault, void *bundle, unsigned long *ipsr,
455 if (!vmm_fpswa_interface) 455 if (!vmm_fpswa_interface)
456 return (fpswa_ret_t) {-1, 0, 0, 0}; 456 return (fpswa_ret_t) {-1, 0, 0, 0};
457 457
458 /*
459 * Just let fpswa driver to use hardware fp registers.
460 * No fp register is valid in memory.
461 */
462 memset(&fp_state, 0, sizeof(fp_state_t)); 458 memset(&fp_state, 0, sizeof(fp_state_t));
463 459
464 /* 460 /*
461 * compute fp_state. only FP registers f6 - f11 are used by the
462 * vmm, so set those bits in the mask and set the low volatile
463 * pointer to point to these registers.
464 */
465 fp_state.bitmask_low64 = 0xfc0; /* bit6..bit11 */
466
467 fp_state.fp_state_low_volatile = (fp_state_low_volatile_t *) &regs->f6;
468
469 /*
465 * unsigned long (*EFI_FPSWA) ( 470 * unsigned long (*EFI_FPSWA) (
466 * unsigned long trap_type, 471 * unsigned long trap_type,
467 * void *Bundle, 472 * void *Bundle,
@@ -545,10 +550,6 @@ void reflect_interruption(u64 ifa, u64 isr, u64 iim,
545 status = vmm_handle_fpu_swa(0, regs, isr); 550 status = vmm_handle_fpu_swa(0, regs, isr);
546 if (!status) 551 if (!status)
547 return ; 552 return ;
548 else if (-EAGAIN == status) {
549 vcpu_decrement_iip(vcpu);
550 return ;
551 }
552 break; 553 break;
553 } 554 }
554 555
diff --git a/arch/ia64/mm/numa.c b/arch/ia64/mm/numa.c
index b73bf1838e57..3efea7d0a351 100644
--- a/arch/ia64/mm/numa.c
+++ b/arch/ia64/mm/numa.c
@@ -58,7 +58,7 @@ paddr_to_nid(unsigned long paddr)
58 * SPARSEMEM to allocate the SPARSEMEM sectionmap on the NUMA node where 58 * SPARSEMEM to allocate the SPARSEMEM sectionmap on the NUMA node where
59 * the section resides. 59 * the section resides.
60 */ 60 */
61int early_pfn_to_nid(unsigned long pfn) 61int __meminit __early_pfn_to_nid(unsigned long pfn)
62{ 62{
63 int i, section = pfn >> PFN_SECTION_SHIFT, ssec, esec; 63 int i, section = pfn >> PFN_SECTION_SHIFT, ssec, esec;
64 64
@@ -70,7 +70,7 @@ int early_pfn_to_nid(unsigned long pfn)
70 return node_memblk[i].nid; 70 return node_memblk[i].nid;
71 } 71 }
72 72
73 return 0; 73 return -1;
74} 74}
75 75
76#ifdef CONFIG_MEMORY_HOTPLUG 76#ifdef CONFIG_MEMORY_HOTPLUG
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
index 9456d4034024..c6d6b62db66c 100644
--- a/arch/ia64/sn/kernel/bte.c
+++ b/arch/ia64/sn/kernel/bte.c
@@ -97,9 +97,10 @@ bte_result_t bte_copy(u64 src, u64 dest, u64 len, u64 mode, void *notification)
97 return BTE_SUCCESS; 97 return BTE_SUCCESS;
98 } 98 }
99 99
100 BUG_ON((len & L1_CACHE_MASK) || 100 BUG_ON(len & L1_CACHE_MASK);
101 (src & L1_CACHE_MASK) || (dest & L1_CACHE_MASK)); 101 BUG_ON(src & L1_CACHE_MASK);
102 BUG_ON(!(len < ((BTE_LEN_MASK + 1) << L1_CACHE_SHIFT))); 102 BUG_ON(dest & L1_CACHE_MASK);
103 BUG_ON(len > BTE_MAX_XFER);
103 104
104 /* 105 /*
105 * Start with interface corresponding to cpu number 106 * Start with interface corresponding to cpu number
diff --git a/arch/ia64/sn/kernel/io_acpi_init.c b/arch/ia64/sn/kernel/io_acpi_init.c
index c5a214026a77..d0223abbbbd4 100644
--- a/arch/ia64/sn/kernel/io_acpi_init.c
+++ b/arch/ia64/sn/kernel/io_acpi_init.c
@@ -443,7 +443,7 @@ sn_acpi_slot_fixup(struct pci_dev *dev)
443 size = pci_resource_len(dev, PCI_ROM_RESOURCE); 443 size = pci_resource_len(dev, PCI_ROM_RESOURCE);
444 addr = ioremap(pcidev_info->pdi_pio_mapped_addr[PCI_ROM_RESOURCE], 444 addr = ioremap(pcidev_info->pdi_pio_mapped_addr[PCI_ROM_RESOURCE],
445 size); 445 size);
446 image_size = pci_get_rom_size(addr, size); 446 image_size = pci_get_rom_size(dev, addr, size);
447 dev->resource[PCI_ROM_RESOURCE].start = (unsigned long) addr; 447 dev->resource[PCI_ROM_RESOURCE].start = (unsigned long) addr;
448 dev->resource[PCI_ROM_RESOURCE].end = 448 dev->resource[PCI_ROM_RESOURCE].end =
449 (unsigned long) addr + image_size - 1; 449 (unsigned long) addr + image_size - 1;
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 4e1801bad83a..e2eb2da60f96 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -269,7 +269,7 @@ sn_io_slot_fixup(struct pci_dev *dev)
269 269
270 rom = ioremap(pci_resource_start(dev, PCI_ROM_RESOURCE), 270 rom = ioremap(pci_resource_start(dev, PCI_ROM_RESOURCE),
271 size + 1); 271 size + 1);
272 image_size = pci_get_rom_size(rom, size + 1); 272 image_size = pci_get_rom_size(dev, rom, size + 1);
273 dev->resource[PCI_ROM_RESOURCE].end = 273 dev->resource[PCI_ROM_RESOURCE].end =
274 dev->resource[PCI_ROM_RESOURCE].start + 274 dev->resource[PCI_ROM_RESOURCE].start +
275 image_size - 1; 275 image_size - 1;
diff --git a/arch/ia64/xen/Kconfig b/arch/ia64/xen/Kconfig
index f1683a20275b..515e0826803a 100644
--- a/arch/ia64/xen/Kconfig
+++ b/arch/ia64/xen/Kconfig
@@ -8,8 +8,7 @@ config XEN
8 depends on PARAVIRT && MCKINLEY && IA64_PAGE_SIZE_16KB && EXPERIMENTAL 8 depends on PARAVIRT && MCKINLEY && IA64_PAGE_SIZE_16KB && EXPERIMENTAL
9 select XEN_XENCOMM 9 select XEN_XENCOMM
10 select NO_IDLE_HZ 10 select NO_IDLE_HZ
11 11 # followings are required to save/restore.
12 # those are required to save/restore.
13 select ARCH_SUSPEND_POSSIBLE 12 select ARCH_SUSPEND_POSSIBLE
14 select SUSPEND 13 select SUSPEND
15 select PM_SLEEP 14 select PM_SLEEP
diff --git a/arch/ia64/xen/xen_pv_ops.c b/arch/ia64/xen/xen_pv_ops.c
index 04cd12350455..936cff3c96e0 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
@@ -153,7 +153,7 @@ xen_post_smp_prepare_boot_cpu(void)
153 xen_setup_vcpu_info_placement(); 153 xen_setup_vcpu_info_placement();
154} 154}
155 155
156static const struct pv_init_ops xen_init_ops __initdata = { 156static const struct pv_init_ops xen_init_ops __initconst = {
157 .banner = xen_banner, 157 .banner = xen_banner,
158 158
159 .reserve_memory = xen_reserve_memory, 159 .reserve_memory = xen_reserve_memory,
@@ -337,7 +337,7 @@ xen_iosapic_write(char __iomem *iosapic, unsigned int reg, u32 val)
337 HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op); 337 HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op);
338} 338}
339 339
340static const struct pv_iosapic_ops xen_iosapic_ops __initdata = { 340static const struct pv_iosapic_ops xen_iosapic_ops __initconst = {
341 .pcat_compat_init = xen_pcat_compat_init, 341 .pcat_compat_init = xen_pcat_compat_init,
342 .__get_irq_chip = xen_iosapic_get_irq_chip, 342 .__get_irq_chip = xen_iosapic_get_irq_chip,
343 343
diff --git a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c
index dba4afabb444..39478dd08e67 100644
--- a/arch/m68k/atari/ataints.c
+++ b/arch/m68k/atari/ataints.c
@@ -187,8 +187,8 @@ __asm__ (__ALIGN_STR "\n" \
187" jbra ret_from_interrupt\n" \ 187" jbra ret_from_interrupt\n" \
188 : : "i" (&kstat_cpu(0).irqs[n+8]), "i" (&irq_handler[n+8]), \ 188 : : "i" (&kstat_cpu(0).irqs[n+8]), "i" (&irq_handler[n+8]), \
189 "n" (PT_OFF_SR), "n" (n), \ 189 "n" (PT_OFF_SR), "n" (n), \
190 "i" (n & 8 ? (n & 16 ? &tt_mfp.int_mk_a : &mfp.int_mk_a) \ 190 "i" (n & 8 ? (n & 16 ? &tt_mfp.int_mk_a : &st_mfp.int_mk_a) \
191 : (n & 16 ? &tt_mfp.int_mk_b : &mfp.int_mk_b)), \ 191 : (n & 16 ? &tt_mfp.int_mk_b : &st_mfp.int_mk_b)), \
192 "m" (preempt_count()), "di" (HARDIRQ_OFFSET) \ 192 "m" (preempt_count()), "di" (HARDIRQ_OFFSET) \
193); \ 193); \
194 for (;;); /* fake noreturn */ \ 194 for (;;); /* fake noreturn */ \
@@ -366,14 +366,14 @@ void __init atari_init_IRQ(void)
366 /* Initialize the MFP(s) */ 366 /* Initialize the MFP(s) */
367 367
368#ifdef ATARI_USE_SOFTWARE_EOI 368#ifdef ATARI_USE_SOFTWARE_EOI
369 mfp.vec_adr = 0x48; /* Software EOI-Mode */ 369 st_mfp.vec_adr = 0x48; /* Software EOI-Mode */
370#else 370#else
371 mfp.vec_adr = 0x40; /* Automatic EOI-Mode */ 371 st_mfp.vec_adr = 0x40; /* Automatic EOI-Mode */
372#endif 372#endif
373 mfp.int_en_a = 0x00; /* turn off MFP-Ints */ 373 st_mfp.int_en_a = 0x00; /* turn off MFP-Ints */
374 mfp.int_en_b = 0x00; 374 st_mfp.int_en_b = 0x00;
375 mfp.int_mk_a = 0xff; /* no Masking */ 375 st_mfp.int_mk_a = 0xff; /* no Masking */
376 mfp.int_mk_b = 0xff; 376 st_mfp.int_mk_b = 0xff;
377 377
378 if (ATARIHW_PRESENT(TT_MFP)) { 378 if (ATARIHW_PRESENT(TT_MFP)) {
379#ifdef ATARI_USE_SOFTWARE_EOI 379#ifdef ATARI_USE_SOFTWARE_EOI
diff --git a/arch/m68k/atari/atakeyb.c b/arch/m68k/atari/atakeyb.c
index a5f33c059979..4add96d13b19 100644
--- a/arch/m68k/atari/atakeyb.c
+++ b/arch/m68k/atari/atakeyb.c
@@ -609,10 +609,10 @@ int atari_keyb_init(void)
609 ACIA_RHTID : 0); 609 ACIA_RHTID : 0);
610 610
611 /* make sure the interrupt line is up */ 611 /* make sure the interrupt line is up */
612 } while ((mfp.par_dt_reg & 0x10) == 0); 612 } while ((st_mfp.par_dt_reg & 0x10) == 0);
613 613
614 /* enable ACIA Interrupts */ 614 /* enable ACIA Interrupts */
615 mfp.active_edge &= ~0x10; 615 st_mfp.active_edge &= ~0x10;
616 atari_turnon_irq(IRQ_MFP_ACIA); 616 atari_turnon_irq(IRQ_MFP_ACIA);
617 617
618 ikbd_self_test = 1; 618 ikbd_self_test = 1;
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index 49c28cdbea5c..ae2d96e5d618 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -258,7 +258,7 @@ void __init config_atari(void)
258 printk("STND_SHIFTER "); 258 printk("STND_SHIFTER ");
259 } 259 }
260 } 260 }
261 if (hwreg_present(&mfp.par_dt_reg)) { 261 if (hwreg_present(&st_mfp.par_dt_reg)) {
262 ATARIHW_SET(ST_MFP); 262 ATARIHW_SET(ST_MFP);
263 printk("ST_MFP "); 263 printk("ST_MFP ");
264 } 264 }
diff --git a/arch/m68k/atari/debug.c b/arch/m68k/atari/debug.c
index 702b15ccfab7..28efdc33c1ae 100644
--- a/arch/m68k/atari/debug.c
+++ b/arch/m68k/atari/debug.c
@@ -34,9 +34,9 @@ static struct console atari_console_driver = {
34 34
35static inline void ata_mfp_out(char c) 35static inline void ata_mfp_out(char c)
36{ 36{
37 while (!(mfp.trn_stat & 0x80)) /* wait for tx buf empty */ 37 while (!(st_mfp.trn_stat & 0x80)) /* wait for tx buf empty */
38 barrier(); 38 barrier();
39 mfp.usart_dta = c; 39 st_mfp.usart_dta = c;
40} 40}
41 41
42static void atari_mfp_console_write(struct console *co, const char *str, 42static void atari_mfp_console_write(struct console *co, const char *str,
@@ -91,7 +91,7 @@ static int ata_par_out(char c)
91 /* This a some-seconds timeout in case no printer is connected */ 91 /* This a some-seconds timeout in case no printer is connected */
92 unsigned long i = loops_per_jiffy > 1 ? loops_per_jiffy : 10000000/HZ; 92 unsigned long i = loops_per_jiffy > 1 ? loops_per_jiffy : 10000000/HZ;
93 93
94 while ((mfp.par_dt_reg & 1) && --i) /* wait for BUSY == L */ 94 while ((st_mfp.par_dt_reg & 1) && --i) /* wait for BUSY == L */
95 ; 95 ;
96 if (!i) 96 if (!i)
97 return 0; 97 return 0;
@@ -131,9 +131,9 @@ static void atari_par_console_write(struct console *co, const char *str,
131#if 0 131#if 0
132int atari_mfp_console_wait_key(struct console *co) 132int atari_mfp_console_wait_key(struct console *co)
133{ 133{
134 while (!(mfp.rcv_stat & 0x80)) /* wait for rx buf filled */ 134 while (!(st_mfp.rcv_stat & 0x80)) /* wait for rx buf filled */
135 barrier(); 135 barrier();
136 return mfp.usart_dta; 136 return st_mfp.usart_dta;
137} 137}
138 138
139int atari_scc_console_wait_key(struct console *co) 139int atari_scc_console_wait_key(struct console *co)
@@ -175,12 +175,12 @@ static void __init atari_init_mfp_port(int cflag)
175 baud = B9600; /* use default 9600bps for non-implemented rates */ 175 baud = B9600; /* use default 9600bps for non-implemented rates */
176 baud -= B1200; /* baud_table[] starts at 1200bps */ 176 baud -= B1200; /* baud_table[] starts at 1200bps */
177 177
178 mfp.trn_stat &= ~0x01; /* disable TX */ 178 st_mfp.trn_stat &= ~0x01; /* disable TX */
179 mfp.usart_ctr = parity | csize | 0x88; /* 1:16 clk mode, 1 stop bit */ 179 st_mfp.usart_ctr = parity | csize | 0x88; /* 1:16 clk mode, 1 stop bit */
180 mfp.tim_ct_cd &= 0x70; /* stop timer D */ 180 st_mfp.tim_ct_cd &= 0x70; /* stop timer D */
181 mfp.tim_dt_d = baud_table[baud]; 181 st_mfp.tim_dt_d = baud_table[baud];
182 mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */ 182 st_mfp.tim_ct_cd |= 0x01; /* start timer D, 1:4 */
183 mfp.trn_stat |= 0x01; /* enable TX */ 183 st_mfp.trn_stat |= 0x01; /* enable TX */
184} 184}
185 185
186#define SCC_WRITE(reg, val) \ 186#define SCC_WRITE(reg, val) \
diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c
index d076ff8d1b39..a0531f34c617 100644
--- a/arch/m68k/atari/time.c
+++ b/arch/m68k/atari/time.c
@@ -27,9 +27,9 @@ void __init
27atari_sched_init(irq_handler_t timer_routine) 27atari_sched_init(irq_handler_t timer_routine)
28{ 28{
29 /* set Timer C data Register */ 29 /* set Timer C data Register */
30 mfp.tim_dt_c = INT_TICKS; 30 st_mfp.tim_dt_c = INT_TICKS;
31 /* start timer C, div = 1:100 */ 31 /* start timer C, div = 1:100 */
32 mfp.tim_ct_cd = (mfp.tim_ct_cd & 15) | 0x60; 32 st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 15) | 0x60;
33 /* install interrupt service routine for MFP Timer C */ 33 /* install interrupt service routine for MFP Timer C */
34 if (request_irq(IRQ_MFP_TIMC, timer_routine, IRQ_TYPE_SLOW, 34 if (request_irq(IRQ_MFP_TIMC, timer_routine, IRQ_TYPE_SLOW,
35 "timer", timer_routine)) 35 "timer", timer_routine))
@@ -46,11 +46,11 @@ unsigned long atari_gettimeoffset (void)
46 unsigned long ticks, offset = 0; 46 unsigned long ticks, offset = 0;
47 47
48 /* read MFP timer C current value */ 48 /* read MFP timer C current value */
49 ticks = mfp.tim_dt_c; 49 ticks = st_mfp.tim_dt_c;
50 /* The probability of underflow is less than 2% */ 50 /* The probability of underflow is less than 2% */
51 if (ticks > INT_TICKS - INT_TICKS / 50) 51 if (ticks > INT_TICKS - INT_TICKS / 50)
52 /* Check for pending timer interrupt */ 52 /* Check for pending timer interrupt */
53 if (mfp.int_pn_b & (1 << 5)) 53 if (st_mfp.int_pn_b & (1 << 5))
54 offset = TICK_SIZE; 54 offset = TICK_SIZE;
55 55
56 ticks = INT_TICKS - ticks; 56 ticks = INT_TICKS - ticks;
diff --git a/arch/m68k/include/asm/atarihw.h b/arch/m68k/include/asm/atarihw.h
index 1412b4ab202f..a714e1aa072a 100644
--- a/arch/m68k/include/asm/atarihw.h
+++ b/arch/m68k/include/asm/atarihw.h
@@ -113,7 +113,7 @@ extern struct atari_hw_present atari_hw_present;
113 * of nops on various machines. Somebody claimed that the tstb takes 600 ns. 113 * of nops on various machines. Somebody claimed that the tstb takes 600 ns.
114 */ 114 */
115#define MFPDELAY() \ 115#define MFPDELAY() \
116 __asm__ __volatile__ ( "tstb %0" : : "m" (mfp.par_dt_reg) : "cc" ); 116 __asm__ __volatile__ ( "tstb %0" : : "m" (st_mfp.par_dt_reg) : "cc" );
117 117
118/* Do cache push/invalidate for DMA read/write. This function obeys the 118/* Do cache push/invalidate for DMA read/write. This function obeys the
119 * snooping on some machines (Medusa) and processors: The Medusa itself can 119 * snooping on some machines (Medusa) and processors: The Medusa itself can
@@ -565,7 +565,7 @@ struct MFP
565 u_char char_dummy23; 565 u_char char_dummy23;
566 u_char usart_dta; 566 u_char usart_dta;
567 }; 567 };
568# define mfp ((*(volatile struct MFP*)MFP_BAS)) 568# define st_mfp ((*(volatile struct MFP*)MFP_BAS))
569 569
570/* TT's second MFP */ 570/* TT's second MFP */
571 571
diff --git a/arch/m68k/include/asm/atariints.h b/arch/m68k/include/asm/atariints.h
index 5748e99f4e26..f597892e43a0 100644
--- a/arch/m68k/include/asm/atariints.h
+++ b/arch/m68k/include/asm/atariints.h
@@ -113,7 +113,7 @@ static inline int get_mfp_bit( unsigned irq, int type )
113{ unsigned char mask, *reg; 113{ unsigned char mask, *reg;
114 114
115 mask = 1 << (irq & 7); 115 mask = 1 << (irq & 7);
116 reg = (unsigned char *)&mfp.int_en_a + type*4 + 116 reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
117 ((irq & 8) >> 2) + (((irq-8) & 16) << 3); 117 ((irq & 8) >> 2) + (((irq-8) & 16) << 3);
118 return( *reg & mask ); 118 return( *reg & mask );
119} 119}
@@ -123,7 +123,7 @@ static inline void set_mfp_bit( unsigned irq, int type )
123{ unsigned char mask, *reg; 123{ unsigned char mask, *reg;
124 124
125 mask = 1 << (irq & 7); 125 mask = 1 << (irq & 7);
126 reg = (unsigned char *)&mfp.int_en_a + type*4 + 126 reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
127 ((irq & 8) >> 2) + (((irq-8) & 16) << 3); 127 ((irq & 8) >> 2) + (((irq-8) & 16) << 3);
128 __asm__ __volatile__ ( "orb %0,%1" 128 __asm__ __volatile__ ( "orb %0,%1"
129 : : "di" (mask), "m" (*reg) : "memory" ); 129 : : "di" (mask), "m" (*reg) : "memory" );
@@ -134,7 +134,7 @@ static inline void clear_mfp_bit( unsigned irq, int type )
134{ unsigned char mask, *reg; 134{ unsigned char mask, *reg;
135 135
136 mask = ~(1 << (irq & 7)); 136 mask = ~(1 << (irq & 7));
137 reg = (unsigned char *)&mfp.int_en_a + type*4 + 137 reg = (unsigned char *)&st_mfp.int_en_a + type*4 +
138 ((irq & 8) >> 2) + (((irq-8) & 16) << 3); 138 ((irq & 8) >> 2) + (((irq-8) & 16) << 3);
139 if (type == MFP_PENDING || type == MFP_SERVICE) 139 if (type == MFP_PENDING || type == MFP_SERVICE)
140 __asm__ __volatile__ ( "moveb %0,%1" 140 __asm__ __volatile__ ( "moveb %0,%1"
diff --git a/arch/mips/include/asm/spinlock.h b/arch/mips/include/asm/spinlock.h
index 1a1f320c30d8..0884947ebe27 100644
--- a/arch/mips/include/asm/spinlock.h
+++ b/arch/mips/include/asm/spinlock.h
@@ -51,6 +51,7 @@ static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
51 51
52 return (((counters >> 14) - counters) & 0x1fff) > 1; 52 return (((counters >> 14) - counters) & 0x1fff) > 1;
53} 53}
54#define __raw_spin_is_contended __raw_spin_is_contended
54 55
55static inline void __raw_spin_lock(raw_spinlock_t *lock) 56static inline void __raw_spin_lock(raw_spinlock_t *lock)
56{ 57{
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 9a9f43358879..41d16822e616 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -7,6 +7,7 @@ mainmenu "Linux Kernel Configuration"
7 7
8config MN10300 8config MN10300
9 def_bool y 9 def_bool y
10 select HAVE_OPROFILE
10 11
11config AM33 12config AM33
12 def_bool y 13 def_bool y
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 1a86425fec42..07dbbcda3b2e 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -173,7 +173,7 @@ static int pci_ampci_write_config_byte(struct pci_bus *bus, unsigned int devfn,
173 BRIDGEREGB(where) = value; 173 BRIDGEREGB(where) = value;
174 } else { 174 } else {
175 if (bus->number == 0 && 175 if (bus->number == 0 &&
176 (devfn == PCI_DEVFN(2, 0) && devfn == PCI_DEVFN(3, 0)) 176 (devfn == PCI_DEVFN(2, 0) || devfn == PCI_DEVFN(3, 0))
177 ) 177 )
178 __pcidebug("<= %02x", bus, devfn, where, value); 178 __pcidebug("<= %02x", bus, devfn, where, value);
179 CONFIG_ADDRESS = CONFIG_CMD(bus, devfn, where); 179 CONFIG_ADDRESS = CONFIG_CMD(bus, devfn, where);
diff --git a/arch/powerpc/boot/dts/mpc8313erdb.dts b/arch/powerpc/boot/dts/mpc8313erdb.dts
index 909a89cab9ac..3ebf7ec0484c 100644
--- a/arch/powerpc/boot/dts/mpc8313erdb.dts
+++ b/arch/powerpc/boot/dts/mpc8313erdb.dts
@@ -191,7 +191,8 @@
191 interrupts = <37 0x8 36 0x8 35 0x8>; 191 interrupts = <37 0x8 36 0x8 35 0x8>;
192 interrupt-parent = <&ipic>; 192 interrupt-parent = <&ipic>;
193 tbi-handle = < &tbi0 >; 193 tbi-handle = < &tbi0 >;
194 phy-handle = < &phy1 >; 194 /* Vitesse 7385 isn't on the MDIO bus */
195 fixed-link = <1 1 1000 0 0>;
195 fsl,magic-packet; 196 fsl,magic-packet;
196 197
197 mdio@24520 { 198 mdio@24520 {
@@ -199,12 +200,6 @@
199 #size-cells = <0>; 200 #size-cells = <0>;
200 compatible = "fsl,gianfar-mdio"; 201 compatible = "fsl,gianfar-mdio";
201 reg = <0x24520 0x20>; 202 reg = <0x24520 0x20>;
202 phy1: ethernet-phy@1 {
203 interrupt-parent = <&ipic>;
204 interrupts = <19 0x8>;
205 reg = <0x1>;
206 device_type = "ethernet-phy";
207 };
208 phy4: ethernet-phy@4 { 203 phy4: ethernet-phy@4 {
209 interrupt-parent = <&ipic>; 204 interrupt-parent = <&ipic>;
210 interrupts = <20 0x8>; 205 interrupts = <20 0x8>;
@@ -219,6 +214,8 @@
219 }; 214 };
220 215
221 enet1: ethernet@25000 { 216 enet1: ethernet@25000 {
217 #address-cells = <1>;
218 #size-cells = <1>;
222 cell-index = <1>; 219 cell-index = <1>;
223 device_type = "network"; 220 device_type = "network";
224 model = "eTSEC"; 221 model = "eTSEC";
diff --git a/arch/powerpc/configs/83xx/mpc8313_rdb_defconfig b/arch/powerpc/configs/83xx/mpc8313_rdb_defconfig
index 9e47ae957e2e..409d017621a8 100644
--- a/arch/powerpc/configs/83xx/mpc8313_rdb_defconfig
+++ b/arch/powerpc/configs/83xx/mpc8313_rdb_defconfig
@@ -651,7 +651,7 @@ CONFIG_CICADA_PHY=y
651# CONFIG_NATIONAL_PHY is not set 651# CONFIG_NATIONAL_PHY is not set
652# CONFIG_STE10XP is not set 652# CONFIG_STE10XP is not set
653# CONFIG_LSI_ET1011C_PHY is not set 653# CONFIG_LSI_ET1011C_PHY is not set
654# CONFIG_FIXED_PHY is not set 654CONFIG_FIXED_PHY=y
655# CONFIG_MDIO_BITBANG is not set 655# CONFIG_MDIO_BITBANG is not set
656CONFIG_NET_ETHERNET=y 656CONFIG_NET_ETHERNET=y
657CONFIG_MII=y 657CONFIG_MII=y
diff --git a/arch/powerpc/include/asm/pgtable-4k.h b/arch/powerpc/include/asm/pgtable-4k.h
index 6b18ba9d2d85..1dbca4e7de67 100644
--- a/arch/powerpc/include/asm/pgtable-4k.h
+++ b/arch/powerpc/include/asm/pgtable-4k.h
@@ -60,7 +60,7 @@
60/* It should be preserving the high 48 bits and then specifically */ 60/* It should be preserving the high 48 bits and then specifically */
61/* preserving _PAGE_SECONDARY | _PAGE_GROUP_IX */ 61/* preserving _PAGE_SECONDARY | _PAGE_GROUP_IX */
62#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | \ 62#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | \
63 _PAGE_HPTEFLAGS) 63 _PAGE_HPTEFLAGS | _PAGE_SPECIAL)
64 64
65/* Bits to mask out from a PMD to get to the PTE page */ 65/* Bits to mask out from a PMD to get to the PTE page */
66#define PMD_MASKED_BITS 0 66#define PMD_MASKED_BITS 0
diff --git a/arch/powerpc/include/asm/pgtable-64k.h b/arch/powerpc/include/asm/pgtable-64k.h
index 07b0d8f09cb6..7389003349a6 100644
--- a/arch/powerpc/include/asm/pgtable-64k.h
+++ b/arch/powerpc/include/asm/pgtable-64k.h
@@ -114,7 +114,7 @@ static inline struct subpage_prot_table *pgd_subpage_prot(pgd_t *pgd)
114 * pgprot changes 114 * pgprot changes
115 */ 115 */
116#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ 116#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
117 _PAGE_ACCESSED) 117 _PAGE_ACCESSED | _PAGE_SPECIAL)
118 118
119/* Bits to mask out from a PMD to get to the PTE page */ 119/* Bits to mask out from a PMD to get to the PTE page */
120#define PMD_MASKED_BITS 0x1ff 120#define PMD_MASKED_BITS 0x1ff
diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h
index f69a4d977729..820b5f0a35ce 100644
--- a/arch/powerpc/include/asm/pgtable-ppc32.h
+++ b/arch/powerpc/include/asm/pgtable-ppc32.h
@@ -429,7 +429,8 @@ extern int icache_44x_need_flush;
429#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE() 429#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE()
430#endif 430#endif
431 431
432#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 432#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | \
433 _PAGE_SPECIAL)
433 434
434 435
435#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \ 436#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index 5af4e9b2dbe2..ada06924a423 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -646,11 +646,16 @@ static int emulate_vsx(unsigned char __user *addr, unsigned int reg,
646 unsigned int areg, struct pt_regs *regs, 646 unsigned int areg, struct pt_regs *regs,
647 unsigned int flags, unsigned int length) 647 unsigned int flags, unsigned int length)
648{ 648{
649 char *ptr = (char *) &current->thread.TS_FPR(reg); 649 char *ptr;
650 int ret = 0; 650 int ret = 0;
651 651
652 flush_vsx_to_thread(current); 652 flush_vsx_to_thread(current);
653 653
654 if (reg < 32)
655 ptr = (char *) &current->thread.TS_FPR(reg);
656 else
657 ptr = (char *) &current->thread.vr[reg - 32];
658
654 if (flags & ST) 659 if (flags & ST)
655 ret = __copy_to_user(addr, ptr, length); 660 ret = __copy_to_user(addr, ptr, length);
656 else { 661 else {
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 5355244c99ff..60c60ccf5e3c 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -195,8 +195,9 @@ __ftrace_make_nop(struct module *mod,
195 return -EINVAL; 195 return -EINVAL;
196 } 196 }
197 197
198 offset = (unsigned)((unsigned short)jmp[0]) << 16 | 198 /* The bottom half is signed extended */
199 (unsigned)((unsigned short)jmp[1]); 199 offset = ((unsigned)((unsigned short)jmp[0]) << 16) +
200 (int)((short)jmp[1]);
200 201
201 DEBUGP(" %x ", offset); 202 DEBUGP(" %x ", offset);
202 203
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 19b12d2cbb4b..0f4181272311 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -561,8 +561,21 @@ int pci_mmap_legacy_page_range(struct pci_bus *bus,
561 (unsigned long long)(offset + size - 1)); 561 (unsigned long long)(offset + size - 1));
562 562
563 if (mmap_state == pci_mmap_mem) { 563 if (mmap_state == pci_mmap_mem) {
564 if ((offset + size) > hose->isa_mem_size) 564 /* Hack alert !
565 return -ENXIO; 565 *
566 * Because X is lame and can fail starting if it gets an error trying
567 * to mmap legacy_mem (instead of just moving on without legacy memory
568 * access) we fake it here by giving it anonymous memory, effectively
569 * behaving just like /dev/zero
570 */
571 if ((offset + size) > hose->isa_mem_size) {
572 printk(KERN_DEBUG
573 "Process %s (pid:%d) mapped non-existing PCI legacy memory for 0%04x:%02x\n",
574 current->comm, current->pid, pci_domain_nr(bus), bus->number);
575 if (vma->vm_flags & VM_SHARED)
576 return shmem_zero_setup(vma);
577 return 0;
578 }
566 offset += hose->isa_mem_phys; 579 offset += hose->isa_mem_phys;
567 } else { 580 } else {
568 unsigned long io_offset = (unsigned long)hose->io_base_virt - _IO_BASE; 581 unsigned long io_offset = (unsigned long)hose->io_base_virt - _IO_BASE;
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 2822c8ccfaaf..5f81256287f5 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -125,6 +125,10 @@ static void kvmppc_free_vcpus(struct kvm *kvm)
125 } 125 }
126} 126}
127 127
128void kvm_arch_sync_events(struct kvm *kvm)
129{
130}
131
128void kvm_arch_destroy_vm(struct kvm *kvm) 132void kvm_arch_destroy_vm(struct kvm *kvm)
129{ 133{
130 kvmppc_free_vcpus(kvm); 134 kvmppc_free_vcpus(kvm);
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 4aae0c387645..13b7d54f185b 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -172,6 +172,8 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
172 } 172 }
173 break; 173 break;
174 case 0x378: /* orx */ 174 case 0x378: /* orx */
175 if (instr & 1)
176 break;
175 rs = (instr >> 21) & 0x1f; 177 rs = (instr >> 21) & 0x1f;
176 rb = (instr >> 11) & 0x1f; 178 rb = (instr >> 11) & 0x1f;
177 if (rs == rb) { /* mr */ 179 if (rs == rb) { /* mr */
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c
index 1971e4ee3d6e..ea6e41e39d9f 100644
--- a/arch/powerpc/mm/fsl_booke_mmu.c
+++ b/arch/powerpc/mm/fsl_booke_mmu.c
@@ -73,7 +73,7 @@ extern unsigned int tlbcam_index;
73/* 73/*
74 * Return PA for this VA if it is mapped by a CAM, or 0 74 * Return PA for this VA if it is mapped by a CAM, or 0
75 */ 75 */
76unsigned long v_mapped_by_tlbcam(unsigned long va) 76phys_addr_t v_mapped_by_tlbcam(unsigned long va)
77{ 77{
78 int b; 78 int b;
79 for (b = 0; b < tlbcam_index; ++b) 79 for (b = 0; b < tlbcam_index; ++b)
@@ -85,7 +85,7 @@ unsigned long v_mapped_by_tlbcam(unsigned long va)
85/* 85/*
86 * Return VA for a given PA or 0 if not mapped 86 * Return VA for a given PA or 0 if not mapped
87 */ 87 */
88unsigned long p_mapped_by_tlbcam(unsigned long pa) 88unsigned long p_mapped_by_tlbcam(phys_addr_t pa)
89{ 89{
90 int b; 90 int b;
91 for (b = 0; b < tlbcam_index; ++b) 91 for (b = 0; b < tlbcam_index; ++b)
diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S
index 67850ec9feb3..14af8cedab70 100644
--- a/arch/powerpc/mm/hash_low_32.S
+++ b/arch/powerpc/mm/hash_low_32.S
@@ -320,7 +320,7 @@ _GLOBAL(create_hpte)
320 and r8,r8,r0 /* writable if _RW & _DIRTY */ 320 and r8,r8,r0 /* writable if _RW & _DIRTY */
321 rlwimi r5,r5,32-1,30,30 /* _PAGE_USER -> PP msb */ 321 rlwimi r5,r5,32-1,30,30 /* _PAGE_USER -> PP msb */
322 rlwimi r5,r5,32-2,31,31 /* _PAGE_USER -> PP lsb */ 322 rlwimi r5,r5,32-2,31,31 /* _PAGE_USER -> PP lsb */
323 ori r8,r8,0xe14 /* clear out reserved bits and M */ 323 ori r8,r8,0xe04 /* clear out reserved bits */
324 andc r8,r5,r8 /* PP = user? (rw&dirty? 2: 3): 0 */ 324 andc r8,r5,r8 /* PP = user? (rw&dirty? 2: 3): 0 */
325BEGIN_FTR_SECTION 325BEGIN_FTR_SECTION
326 rlwinm r8,r8,0,~_PAGE_COHERENT /* clear M (coherence not required) */ 326 rlwinm r8,r8,0,~_PAGE_COHERENT /* clear M (coherence not required) */
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 7393bd76d698..5ac08b8ab654 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -19,6 +19,7 @@
19#include <linux/notifier.h> 19#include <linux/notifier.h>
20#include <linux/lmb.h> 20#include <linux/lmb.h>
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/pfn.h>
22#include <asm/sparsemem.h> 23#include <asm/sparsemem.h>
23#include <asm/prom.h> 24#include <asm/prom.h>
24#include <asm/system.h> 25#include <asm/system.h>
@@ -882,7 +883,7 @@ static void mark_reserved_regions_for_nid(int nid)
882 unsigned long physbase = lmb.reserved.region[i].base; 883 unsigned long physbase = lmb.reserved.region[i].base;
883 unsigned long size = lmb.reserved.region[i].size; 884 unsigned long size = lmb.reserved.region[i].size;
884 unsigned long start_pfn = physbase >> PAGE_SHIFT; 885 unsigned long start_pfn = physbase >> PAGE_SHIFT;
885 unsigned long end_pfn = ((physbase + size) >> PAGE_SHIFT); 886 unsigned long end_pfn = PFN_UP(physbase + size);
886 struct node_active_region node_ar; 887 struct node_active_region node_ar;
887 unsigned long node_end_pfn = node->node_start_pfn + 888 unsigned long node_end_pfn = node->node_start_pfn +
888 node->node_spanned_pages; 889 node->node_spanned_pages;
@@ -908,7 +909,7 @@ static void mark_reserved_regions_for_nid(int nid)
908 */ 909 */
909 if (end_pfn > node_ar.end_pfn) 910 if (end_pfn > node_ar.end_pfn)
910 reserve_size = (node_ar.end_pfn << PAGE_SHIFT) 911 reserve_size = (node_ar.end_pfn << PAGE_SHIFT)
911 - (start_pfn << PAGE_SHIFT); 912 - physbase;
912 /* 913 /*
913 * Only worry about *this* node, others may not 914 * Only worry about *this* node, others may not
914 * yet have valid NODE_DATA(). 915 * yet have valid NODE_DATA().
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 22972cd83cc9..58bcaeba728d 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -61,8 +61,8 @@ void setbat(int index, unsigned long virt, phys_addr_t phys,
61 61
62#ifdef HAVE_TLBCAM 62#ifdef HAVE_TLBCAM
63extern unsigned int tlbcam_index; 63extern unsigned int tlbcam_index;
64extern unsigned long v_mapped_by_tlbcam(unsigned long va); 64extern phys_addr_t v_mapped_by_tlbcam(unsigned long va);
65extern unsigned long p_mapped_by_tlbcam(unsigned long pa); 65extern unsigned long p_mapped_by_tlbcam(phys_addr_t pa);
66#else /* !HAVE_TLBCAM */ 66#else /* !HAVE_TLBCAM */
67#define v_mapped_by_tlbcam(x) (0UL) 67#define v_mapped_by_tlbcam(x) (0UL)
68#define p_mapped_by_tlbcam(x) (0UL) 68#define p_mapped_by_tlbcam(x) (0UL)
diff --git a/arch/powerpc/oprofile/cell/spu_profiler.c b/arch/powerpc/oprofile/cell/spu_profiler.c
index 9305ddaac512..b129d007e7fe 100644
--- a/arch/powerpc/oprofile/cell/spu_profiler.c
+++ b/arch/powerpc/oprofile/cell/spu_profiler.c
@@ -16,6 +16,7 @@
16#include <linux/smp.h> 16#include <linux/smp.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <asm/cell-pmu.h> 18#include <asm/cell-pmu.h>
19#include <asm/time.h>
19#include "pr_util.h" 20#include "pr_util.h"
20 21
21#define SCALE_SHIFT 14 22#define SCALE_SHIFT 14
diff --git a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
index 9876d7e072f4..ddf0bdc0fc8b 100644
--- a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
+++ b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
@@ -186,7 +186,7 @@ out_unmap_regs:
186 iounmap(priv->regs); 186 iounmap(priv->regs);
187out_free_bootmem: 187out_free_bootmem:
188 free_bootmem((unsigned long)priv, 188 free_bootmem((unsigned long)priv,
189 sizeof(sizeof(struct pq2ads_pci_pic))); 189 sizeof(struct pq2ads_pci_pic));
190 of_node_put(np); 190 of_node_put(np);
191out_unmap_irq: 191out_unmap_irq:
192 irq_dispose_mapping(irq); 192 irq_dispose_mapping(irq);
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index 67de6bf3db3d..d281cc0bca71 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -328,7 +328,7 @@ static int __init ps3_mm_add_memory(void)
328 return result; 328 return result;
329} 329}
330 330
331core_initcall(ps3_mm_add_memory); 331device_initcall(ps3_mm_add_memory);
332 332
333/*============================================================================*/ 333/*============================================================================*/
334/* dma routines */ 334/* dma routines */
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index a623ad256e9e..9b21ee68ea50 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -14,6 +14,7 @@
14#include <asm/firmware.h> 14#include <asm/firmware.h>
15#include <asm/machdep.h> 15#include <asm/machdep.h>
16#include <asm/pSeries_reconfig.h> 16#include <asm/pSeries_reconfig.h>
17#include <asm/sparsemem.h>
17 18
18static int pseries_remove_lmb(unsigned long base, unsigned int lmb_size) 19static int pseries_remove_lmb(unsigned long base, unsigned int lmb_size)
19{ 20{
diff --git a/arch/powerpc/sysdev/cpm2_pic.c b/arch/powerpc/sysdev/cpm2_pic.c
index b16ca3ed65d2..78f1f7cca0a0 100644
--- a/arch/powerpc/sysdev/cpm2_pic.c
+++ b/arch/powerpc/sysdev/cpm2_pic.c
@@ -165,7 +165,7 @@ static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type)
165 edibit = (14 - (src - CPM2_IRQ_EXT1)); 165 edibit = (14 - (src - CPM2_IRQ_EXT1));
166 else 166 else
167 if (src >= CPM2_IRQ_PORTC15 && src <= CPM2_IRQ_PORTC0) 167 if (src >= CPM2_IRQ_PORTC15 && src <= CPM2_IRQ_PORTC0)
168 edibit = (31 - (src - CPM2_IRQ_PORTC15)); 168 edibit = (31 - (CPM2_IRQ_PORTC0 - src));
169 else 169 else
170 return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL; 170 return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL;
171 171
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 88a983ece5c9..9a89cd3e80a2 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -890,7 +890,7 @@ unsigned int ipic_get_irq(void)
890 return irq_linear_revmap(primary_ipic->irqhost, irq); 890 return irq_linear_revmap(primary_ipic->irqhost, irq);
891} 891}
892 892
893#ifdef CONFIG_PM 893#ifdef CONFIG_SUSPEND
894static struct { 894static struct {
895 u32 sicfr; 895 u32 sicfr;
896 u32 siprr[2]; 896 u32 siprr[2];
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index a0e748da9909..31e809c77790 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.28-rc6 3# Linux kernel version: 2.6.29-rc4
4# Thu Nov 27 11:00:49 2008 4# Wed Feb 11 10:07:16 2009
5# 5#
6CONFIG_SCHED_MC=y 6CONFIG_SCHED_MC=y
7CONFIG_MMU=y 7CONFIG_MMU=y
@@ -14,12 +14,14 @@ CONFIG_RWSEM_XCHGADD_ALGORITHM=y
14# CONFIG_ARCH_HAS_ILOG2_U64 is not set 14# CONFIG_ARCH_HAS_ILOG2_U64 is not set
15CONFIG_GENERIC_HWEIGHT=y 15CONFIG_GENERIC_HWEIGHT=y
16CONFIG_GENERIC_TIME=y 16CONFIG_GENERIC_TIME=y
17CONFIG_GENERIC_TIME_VSYSCALL=y
17CONFIG_GENERIC_CLOCKEVENTS=y 18CONFIG_GENERIC_CLOCKEVENTS=y
18CONFIG_GENERIC_BUG=y 19CONFIG_GENERIC_BUG=y
19CONFIG_NO_IOMEM=y 20CONFIG_NO_IOMEM=y
20CONFIG_NO_DMA=y 21CONFIG_NO_DMA=y
21CONFIG_GENERIC_LOCKBREAK=y 22CONFIG_GENERIC_LOCKBREAK=y
22CONFIG_PGSTE=y 23CONFIG_PGSTE=y
24CONFIG_VIRT_CPU_ACCOUNTING=y
23CONFIG_S390=y 25CONFIG_S390=y
24CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 26CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
25 27
@@ -39,20 +41,29 @@ CONFIG_POSIX_MQUEUE=y
39# CONFIG_TASKSTATS is not set 41# CONFIG_TASKSTATS is not set
40CONFIG_AUDIT=y 42CONFIG_AUDIT=y
41# CONFIG_AUDITSYSCALL is not set 43# CONFIG_AUDITSYSCALL is not set
44
45#
46# RCU Subsystem
47#
48CONFIG_CLASSIC_RCU=y
49# CONFIG_TREE_RCU is not set
50# CONFIG_PREEMPT_RCU is not set
51# CONFIG_TREE_RCU_TRACE is not set
52# CONFIG_PREEMPT_RCU_TRACE is not set
42CONFIG_IKCONFIG=y 53CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y 54CONFIG_IKCONFIG_PROC=y
44CONFIG_LOG_BUF_SHIFT=17 55CONFIG_LOG_BUF_SHIFT=17
56CONFIG_GROUP_SCHED=y
57CONFIG_FAIR_GROUP_SCHED=y
58# CONFIG_RT_GROUP_SCHED is not set
59CONFIG_USER_SCHED=y
60# CONFIG_CGROUP_SCHED is not set
45CONFIG_CGROUPS=y 61CONFIG_CGROUPS=y
46# CONFIG_CGROUP_DEBUG is not set 62# CONFIG_CGROUP_DEBUG is not set
47CONFIG_CGROUP_NS=y 63CONFIG_CGROUP_NS=y
48# CONFIG_CGROUP_FREEZER is not set 64# CONFIG_CGROUP_FREEZER is not set
49# CONFIG_CGROUP_DEVICE is not set 65# CONFIG_CGROUP_DEVICE is not set
50# CONFIG_CPUSETS is not set 66# CONFIG_CPUSETS is not set
51CONFIG_GROUP_SCHED=y
52CONFIG_FAIR_GROUP_SCHED=y
53# CONFIG_RT_GROUP_SCHED is not set
54CONFIG_USER_SCHED=y
55# CONFIG_CGROUP_SCHED is not set
56# CONFIG_CGROUP_CPUACCT is not set 67# CONFIG_CGROUP_CPUACCT is not set
57# CONFIG_RESOURCE_COUNTERS is not set 68# CONFIG_RESOURCE_COUNTERS is not set
58CONFIG_SYSFS_DEPRECATED=y 69CONFIG_SYSFS_DEPRECATED=y
@@ -63,6 +74,7 @@ CONFIG_UTS_NS=y
63CONFIG_IPC_NS=y 74CONFIG_IPC_NS=y
64# CONFIG_USER_NS is not set 75# CONFIG_USER_NS is not set
65# CONFIG_PID_NS is not set 76# CONFIG_PID_NS is not set
77# CONFIG_NET_NS is not set
66CONFIG_BLK_DEV_INITRD=y 78CONFIG_BLK_DEV_INITRD=y
67CONFIG_INITRAMFS_SOURCE="" 79CONFIG_INITRAMFS_SOURCE=""
68# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 80# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -91,17 +103,17 @@ CONFIG_SLAB=y
91# CONFIG_SLUB is not set 103# CONFIG_SLUB is not set
92# CONFIG_SLOB is not set 104# CONFIG_SLOB is not set
93# CONFIG_PROFILING is not set 105# CONFIG_PROFILING is not set
94# CONFIG_MARKERS is not set
95CONFIG_HAVE_OPROFILE=y 106CONFIG_HAVE_OPROFILE=y
96CONFIG_KPROBES=y 107CONFIG_KPROBES=y
108CONFIG_HAVE_SYSCALL_WRAPPERS=y
97CONFIG_KRETPROBES=y 109CONFIG_KRETPROBES=y
98CONFIG_HAVE_KPROBES=y 110CONFIG_HAVE_KPROBES=y
99CONFIG_HAVE_KRETPROBES=y 111CONFIG_HAVE_KRETPROBES=y
100CONFIG_HAVE_ARCH_TRACEHOOK=y 112CONFIG_HAVE_ARCH_TRACEHOOK=y
113CONFIG_USE_GENERIC_SMP_HELPERS=y
101# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 114# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
102CONFIG_SLABINFO=y 115CONFIG_SLABINFO=y
103CONFIG_RT_MUTEXES=y 116CONFIG_RT_MUTEXES=y
104# CONFIG_TINY_SHMEM is not set
105CONFIG_BASE_SMALL=0 117CONFIG_BASE_SMALL=0
106CONFIG_MODULES=y 118CONFIG_MODULES=y
107# CONFIG_MODULE_FORCE_LOAD is not set 119# CONFIG_MODULE_FORCE_LOAD is not set
@@ -109,7 +121,7 @@ CONFIG_MODULE_UNLOAD=y
109# CONFIG_MODULE_FORCE_UNLOAD is not set 121# CONFIG_MODULE_FORCE_UNLOAD is not set
110CONFIG_MODVERSIONS=y 122CONFIG_MODVERSIONS=y
111# CONFIG_MODULE_SRCVERSION_ALL is not set 123# CONFIG_MODULE_SRCVERSION_ALL is not set
112CONFIG_KMOD=y 124CONFIG_INIT_ALL_POSSIBLE=y
113CONFIG_STOP_MACHINE=y 125CONFIG_STOP_MACHINE=y
114CONFIG_BLOCK=y 126CONFIG_BLOCK=y
115# CONFIG_BLK_DEV_IO_TRACE is not set 127# CONFIG_BLK_DEV_IO_TRACE is not set
@@ -130,7 +142,6 @@ CONFIG_DEFAULT_DEADLINE=y
130# CONFIG_DEFAULT_NOOP is not set 142# CONFIG_DEFAULT_NOOP is not set
131CONFIG_DEFAULT_IOSCHED="deadline" 143CONFIG_DEFAULT_IOSCHED="deadline"
132CONFIG_PREEMPT_NOTIFIERS=y 144CONFIG_PREEMPT_NOTIFIERS=y
133CONFIG_CLASSIC_RCU=y
134# CONFIG_FREEZER is not set 145# CONFIG_FREEZER is not set
135 146
136# 147#
@@ -161,6 +172,7 @@ CONFIG_S390_EXEC_PROTECT=y
161CONFIG_MARCH_Z900=y 172CONFIG_MARCH_Z900=y
162# CONFIG_MARCH_Z990 is not set 173# CONFIG_MARCH_Z990 is not set
163# CONFIG_MARCH_Z9_109 is not set 174# CONFIG_MARCH_Z9_109 is not set
175# CONFIG_MARCH_Z10 is not set
164CONFIG_PACK_STACK=y 176CONFIG_PACK_STACK=y
165# CONFIG_SMALL_STACK is not set 177# CONFIG_SMALL_STACK is not set
166CONFIG_CHECK_STACK=y 178CONFIG_CHECK_STACK=y
@@ -174,7 +186,6 @@ CONFIG_ARCH_POPULATES_NODE_MAP=y
174# CONFIG_PREEMPT_NONE is not set 186# CONFIG_PREEMPT_NONE is not set
175# CONFIG_PREEMPT_VOLUNTARY is not set 187# CONFIG_PREEMPT_VOLUNTARY is not set
176CONFIG_PREEMPT=y 188CONFIG_PREEMPT=y
177# CONFIG_PREEMPT_RCU is not set
178CONFIG_ARCH_SPARSEMEM_ENABLE=y 189CONFIG_ARCH_SPARSEMEM_ENABLE=y
179CONFIG_ARCH_SPARSEMEM_DEFAULT=y 190CONFIG_ARCH_SPARSEMEM_DEFAULT=y
180CONFIG_ARCH_SELECT_MEMORY_MODEL=y 191CONFIG_ARCH_SELECT_MEMORY_MODEL=y
@@ -195,7 +206,6 @@ CONFIG_MEMORY_HOTREMOVE=y
195CONFIG_PAGEFLAGS_EXTENDED=y 206CONFIG_PAGEFLAGS_EXTENDED=y
196CONFIG_SPLIT_PTLOCK_CPUS=4 207CONFIG_SPLIT_PTLOCK_CPUS=4
197CONFIG_MIGRATION=y 208CONFIG_MIGRATION=y
198CONFIG_RESOURCES_64BIT=y
199CONFIG_PHYS_ADDR_T_64BIT=y 209CONFIG_PHYS_ADDR_T_64BIT=y
200CONFIG_ZONE_DMA_FLAG=1 210CONFIG_ZONE_DMA_FLAG=1
201CONFIG_BOUNCE=y 211CONFIG_BOUNCE=y
@@ -207,7 +217,6 @@ CONFIG_UNEVICTABLE_LRU=y
207# 217#
208CONFIG_MACHCHK_WARNING=y 218CONFIG_MACHCHK_WARNING=y
209CONFIG_QDIO=y 219CONFIG_QDIO=y
210# CONFIG_QDIO_DEBUG is not set
211CONFIG_CHSC_SCH=m 220CONFIG_CHSC_SCH=m
212 221
213# 222#
@@ -227,15 +236,13 @@ CONFIG_PFAULT=y
227# CONFIG_SHARED_KERNEL is not set 236# CONFIG_SHARED_KERNEL is not set
228# CONFIG_CMM is not set 237# CONFIG_CMM is not set
229# CONFIG_PAGE_STATES is not set 238# CONFIG_PAGE_STATES is not set
230CONFIG_VIRT_TIMER=y
231CONFIG_VIRT_CPU_ACCOUNTING=y
232# CONFIG_APPLDATA_BASE is not set 239# CONFIG_APPLDATA_BASE is not set
233CONFIG_HZ_100=y 240CONFIG_HZ_100=y
234# CONFIG_HZ_250 is not set 241# CONFIG_HZ_250 is not set
235# CONFIG_HZ_300 is not set 242# CONFIG_HZ_300 is not set
236# CONFIG_HZ_1000 is not set 243# CONFIG_HZ_1000 is not set
237CONFIG_HZ=100 244CONFIG_HZ=100
238# CONFIG_SCHED_HRTICK is not set 245CONFIG_SCHED_HRTICK=y
239CONFIG_S390_HYPFS_FS=y 246CONFIG_S390_HYPFS_FS=y
240CONFIG_KEXEC=y 247CONFIG_KEXEC=y
241# CONFIG_ZFCPDUMP is not set 248# CONFIG_ZFCPDUMP is not set
@@ -245,6 +252,7 @@ CONFIG_NET=y
245# 252#
246# Networking options 253# Networking options
247# 254#
255CONFIG_COMPAT_NET_DEV_OPS=y
248CONFIG_PACKET=y 256CONFIG_PACKET=y
249# CONFIG_PACKET_MMAP is not set 257# CONFIG_PACKET_MMAP is not set
250CONFIG_UNIX=y 258CONFIG_UNIX=y
@@ -383,6 +391,7 @@ CONFIG_NET_SCH_TBF=m
383CONFIG_NET_SCH_GRED=m 391CONFIG_NET_SCH_GRED=m
384CONFIG_NET_SCH_DSMARK=m 392CONFIG_NET_SCH_DSMARK=m
385# CONFIG_NET_SCH_NETEM is not set 393# CONFIG_NET_SCH_NETEM is not set
394# CONFIG_NET_SCH_DRR is not set
386# CONFIG_NET_SCH_INGRESS is not set 395# CONFIG_NET_SCH_INGRESS is not set
387 396
388# 397#
@@ -400,6 +409,7 @@ CONFIG_CLS_U32_MARK=y
400CONFIG_NET_CLS_RSVP=m 409CONFIG_NET_CLS_RSVP=m
401CONFIG_NET_CLS_RSVP6=m 410CONFIG_NET_CLS_RSVP6=m
402CONFIG_NET_CLS_FLOW=m 411CONFIG_NET_CLS_FLOW=m
412# CONFIG_NET_CLS_CGROUP is not set
403# CONFIG_NET_EMATCH is not set 413# CONFIG_NET_EMATCH is not set
404CONFIG_NET_CLS_ACT=y 414CONFIG_NET_CLS_ACT=y
405CONFIG_NET_ACT_POLICE=y 415CONFIG_NET_ACT_POLICE=y
@@ -411,6 +421,7 @@ CONFIG_NET_ACT_NAT=m
411# CONFIG_NET_ACT_SKBEDIT is not set 421# CONFIG_NET_ACT_SKBEDIT is not set
412# CONFIG_NET_CLS_IND is not set 422# CONFIG_NET_CLS_IND is not set
413CONFIG_NET_SCH_FIFO=y 423CONFIG_NET_SCH_FIFO=y
424# CONFIG_DCB is not set
414 425
415# 426#
416# Network testing 427# Network testing
@@ -428,6 +439,7 @@ CONFIG_CAN_VCAN=m
428# CONFIG_CAN_DEBUG_DEVICES is not set 439# CONFIG_CAN_DEBUG_DEVICES is not set
429# CONFIG_AF_RXRPC is not set 440# CONFIG_AF_RXRPC is not set
430# CONFIG_PHONET is not set 441# CONFIG_PHONET is not set
442# CONFIG_WIMAX is not set
431# CONFIG_RFKILL is not set 443# CONFIG_RFKILL is not set
432# CONFIG_NET_9P is not set 444# CONFIG_NET_9P is not set
433# CONFIG_PCMCIA is not set 445# CONFIG_PCMCIA is not set
@@ -475,11 +487,15 @@ CONFIG_DASD_DIAG=y
475CONFIG_DASD_EER=y 487CONFIG_DASD_EER=y
476CONFIG_VIRTIO_BLK=m 488CONFIG_VIRTIO_BLK=m
477CONFIG_MISC_DEVICES=y 489CONFIG_MISC_DEVICES=y
478# CONFIG_EEPROM_93CX6 is not set
479# CONFIG_ENCLOSURE_SERVICES is not set 490# CONFIG_ENCLOSURE_SERVICES is not set
480# CONFIG_C2PORT is not set 491# CONFIG_C2PORT is not set
481 492
482# 493#
494# EEPROM support
495#
496# CONFIG_EEPROM_93CX6 is not set
497
498#
483# SCSI device support 499# SCSI device support
484# 500#
485# CONFIG_RAID_ATTRS is not set 501# CONFIG_RAID_ATTRS is not set
@@ -520,6 +536,7 @@ CONFIG_SCSI_FC_ATTRS=y
520# CONFIG_SCSI_SRP_ATTRS is not set 536# CONFIG_SCSI_SRP_ATTRS is not set
521CONFIG_SCSI_LOWLEVEL=y 537CONFIG_SCSI_LOWLEVEL=y
522# CONFIG_ISCSI_TCP is not set 538# CONFIG_ISCSI_TCP is not set
539# CONFIG_LIBFC is not set
523# CONFIG_SCSI_DEBUG is not set 540# CONFIG_SCSI_DEBUG is not set
524CONFIG_ZFCP=y 541CONFIG_ZFCP=y
525CONFIG_SCSI_DH=m 542CONFIG_SCSI_DH=m
@@ -566,6 +583,10 @@ CONFIG_NET_ETHERNET=y
566CONFIG_NETDEV_1000=y 583CONFIG_NETDEV_1000=y
567CONFIG_NETDEV_10000=y 584CONFIG_NETDEV_10000=y
568# CONFIG_TR is not set 585# CONFIG_TR is not set
586
587#
588# Enable WiMAX (Networking options) to see the WiMAX drivers
589#
569# CONFIG_WAN is not set 590# CONFIG_WAN is not set
570 591
571# 592#
@@ -593,9 +614,11 @@ CONFIG_VIRTIO_NET=m
593# 614#
594CONFIG_DEVKMEM=y 615CONFIG_DEVKMEM=y
595CONFIG_UNIX98_PTYS=y 616CONFIG_UNIX98_PTYS=y
617# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
596CONFIG_LEGACY_PTYS=y 618CONFIG_LEGACY_PTYS=y
597CONFIG_LEGACY_PTY_COUNT=256 619CONFIG_LEGACY_PTY_COUNT=256
598CONFIG_HVC_DRIVER=y 620CONFIG_HVC_DRIVER=y
621CONFIG_HVC_IUCV=y
599CONFIG_VIRTIO_CONSOLE=y 622CONFIG_VIRTIO_CONSOLE=y
600CONFIG_HW_RANDOM=m 623CONFIG_HW_RANDOM=m
601CONFIG_HW_RANDOM_VIRTIO=m 624CONFIG_HW_RANDOM_VIRTIO=m
@@ -645,7 +668,6 @@ CONFIG_S390_VMUR=m
645# CONFIG_NEW_LEDS is not set 668# CONFIG_NEW_LEDS is not set
646CONFIG_ACCESSIBILITY=y 669CONFIG_ACCESSIBILITY=y
647# CONFIG_STAGING is not set 670# CONFIG_STAGING is not set
648CONFIG_STAGING_EXCLUDE_BUILD=y
649 671
650# 672#
651# File systems 673# File systems
@@ -668,6 +690,7 @@ CONFIG_FILE_LOCKING=y
668# CONFIG_XFS_FS is not set 690# CONFIG_XFS_FS is not set
669# CONFIG_GFS2_FS is not set 691# CONFIG_GFS2_FS is not set
670# CONFIG_OCFS2_FS is not set 692# CONFIG_OCFS2_FS is not set
693# CONFIG_BTRFS_FS is not set
671CONFIG_DNOTIFY=y 694CONFIG_DNOTIFY=y
672CONFIG_INOTIFY=y 695CONFIG_INOTIFY=y
673CONFIG_INOTIFY_USER=y 696CONFIG_INOTIFY_USER=y
@@ -703,10 +726,7 @@ CONFIG_TMPFS_POSIX_ACL=y
703# CONFIG_HUGETLBFS is not set 726# CONFIG_HUGETLBFS is not set
704# CONFIG_HUGETLB_PAGE is not set 727# CONFIG_HUGETLB_PAGE is not set
705CONFIG_CONFIGFS_FS=m 728CONFIG_CONFIGFS_FS=m
706 729CONFIG_MISC_FILESYSTEMS=y
707#
708# Miscellaneous filesystems
709#
710# CONFIG_ADFS_FS is not set 730# CONFIG_ADFS_FS is not set
711# CONFIG_AFFS_FS is not set 731# CONFIG_AFFS_FS is not set
712# CONFIG_HFS_FS is not set 732# CONFIG_HFS_FS is not set
@@ -715,6 +735,7 @@ CONFIG_CONFIGFS_FS=m
715# CONFIG_BFS_FS is not set 735# CONFIG_BFS_FS is not set
716# CONFIG_EFS_FS is not set 736# CONFIG_EFS_FS is not set
717# CONFIG_CRAMFS is not set 737# CONFIG_CRAMFS is not set
738# CONFIG_SQUASHFS is not set
718# CONFIG_VXFS_FS is not set 739# CONFIG_VXFS_FS is not set
719# CONFIG_MINIX_FS is not set 740# CONFIG_MINIX_FS is not set
720# CONFIG_OMFS_FS is not set 741# CONFIG_OMFS_FS is not set
@@ -808,6 +829,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
808CONFIG_DEBUG_MEMORY_INIT=y 829CONFIG_DEBUG_MEMORY_INIT=y
809# CONFIG_DEBUG_LIST is not set 830# CONFIG_DEBUG_LIST is not set
810# CONFIG_DEBUG_SG is not set 831# CONFIG_DEBUG_SG is not set
832# CONFIG_DEBUG_NOTIFIERS is not set
811# CONFIG_FRAME_POINTER is not set 833# CONFIG_FRAME_POINTER is not set
812# CONFIG_RCU_TORTURE_TEST is not set 834# CONFIG_RCU_TORTURE_TEST is not set
813# CONFIG_RCU_CPU_STALL_DETECTOR is not set 835# CONFIG_RCU_CPU_STALL_DETECTOR is not set
@@ -818,15 +840,19 @@ CONFIG_DEBUG_MEMORY_INIT=y
818# CONFIG_FAULT_INJECTION is not set 840# CONFIG_FAULT_INJECTION is not set
819# CONFIG_LATENCYTOP is not set 841# CONFIG_LATENCYTOP is not set
820CONFIG_SYSCTL_SYSCALL_CHECK=y 842CONFIG_SYSCTL_SYSCALL_CHECK=y
843CONFIG_HAVE_FUNCTION_TRACER=y
821 844
822# 845#
823# Tracers 846# Tracers
824# 847#
848# CONFIG_FUNCTION_TRACER is not set
825# CONFIG_IRQSOFF_TRACER is not set 849# CONFIG_IRQSOFF_TRACER is not set
826# CONFIG_PREEMPT_TRACER is not set 850# CONFIG_PREEMPT_TRACER is not set
827# CONFIG_SCHED_TRACER is not set 851# CONFIG_SCHED_TRACER is not set
828# CONFIG_CONTEXT_SWITCH_TRACER is not set 852# CONFIG_CONTEXT_SWITCH_TRACER is not set
829# CONFIG_BOOT_TRACER is not set 853# CONFIG_BOOT_TRACER is not set
854# CONFIG_TRACE_BRANCH_PROFILING is not set
855# CONFIG_STACK_TRACER is not set
830# CONFIG_DYNAMIC_PRINTK_DEBUG is not set 856# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
831CONFIG_SAMPLES=y 857CONFIG_SAMPLES=y
832# CONFIG_SAMPLE_KOBJECT is not set 858# CONFIG_SAMPLE_KOBJECT is not set
@@ -847,11 +873,17 @@ CONFIG_CRYPTO=y
847# 873#
848CONFIG_CRYPTO_FIPS=y 874CONFIG_CRYPTO_FIPS=y
849CONFIG_CRYPTO_ALGAPI=y 875CONFIG_CRYPTO_ALGAPI=y
850CONFIG_CRYPTO_AEAD=y 876CONFIG_CRYPTO_ALGAPI2=y
877CONFIG_CRYPTO_AEAD=m
878CONFIG_CRYPTO_AEAD2=y
851CONFIG_CRYPTO_BLKCIPHER=y 879CONFIG_CRYPTO_BLKCIPHER=y
852CONFIG_CRYPTO_HASH=y 880CONFIG_CRYPTO_BLKCIPHER2=y
853CONFIG_CRYPTO_RNG=y 881CONFIG_CRYPTO_HASH=m
882CONFIG_CRYPTO_HASH2=y
883CONFIG_CRYPTO_RNG=m
884CONFIG_CRYPTO_RNG2=y
854CONFIG_CRYPTO_MANAGER=y 885CONFIG_CRYPTO_MANAGER=y
886CONFIG_CRYPTO_MANAGER2=y
855CONFIG_CRYPTO_GF128MUL=m 887CONFIG_CRYPTO_GF128MUL=m
856# CONFIG_CRYPTO_NULL is not set 888# CONFIG_CRYPTO_NULL is not set
857# CONFIG_CRYPTO_CRYPTD is not set 889# CONFIG_CRYPTO_CRYPTD is not set
@@ -885,7 +917,7 @@ CONFIG_CRYPTO_HMAC=m
885# 917#
886# Digest 918# Digest
887# 919#
888# CONFIG_CRYPTO_CRC32C is not set 920CONFIG_CRYPTO_CRC32C=m
889# CONFIG_CRYPTO_MD4 is not set 921# CONFIG_CRYPTO_MD4 is not set
890CONFIG_CRYPTO_MD5=m 922CONFIG_CRYPTO_MD5=m
891# CONFIG_CRYPTO_MICHAEL_MIC is not set 923# CONFIG_CRYPTO_MICHAEL_MIC is not set
@@ -942,6 +974,7 @@ CONFIG_S390_PRNG=m
942# Library routines 974# Library routines
943# 975#
944CONFIG_BITREVERSE=m 976CONFIG_BITREVERSE=m
977CONFIG_GENERIC_FIND_LAST_BIT=y
945# CONFIG_CRC_CCITT is not set 978# CONFIG_CRC_CCITT is not set
946# CONFIG_CRC16 is not set 979# CONFIG_CRC16 is not set
947CONFIG_CRC_T10DIF=y 980CONFIG_CRC_T10DIF=y
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index 521726430afa..95b0f7db3c69 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -145,7 +145,7 @@ cputime_to_timeval(const cputime_t cputime, struct timeval *value)
145 value->tv_usec = rp.subreg.even / 4096; 145 value->tv_usec = rp.subreg.even / 4096;
146 value->tv_sec = rp.subreg.odd; 146 value->tv_sec = rp.subreg.odd;
147#else 147#else
148 value->tv_usec = cputime % 4096000000ULL; 148 value->tv_usec = (cputime % 4096000000ULL) / 4096;
149 value->tv_sec = cputime / 4096000000ULL; 149 value->tv_sec = cputime / 4096000000ULL;
150#endif 150#endif
151} 151}
diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h
index ffdef5fe8587..f3720defdd16 100644
--- a/arch/s390/include/asm/lowcore.h
+++ b/arch/s390/include/asm/lowcore.h
@@ -384,8 +384,8 @@ struct _lowcore
384 __u32 panic_magic; /* 0xe00 */ 384 __u32 panic_magic; /* 0xe00 */
385 385
386 /* Per cpu primary space access list */ 386 /* Per cpu primary space access list */
387 __u8 pad_0xe04[0xe3c-0xe04]; /* 0xe04 */ 387 __u8 pad_0xe04[0xe38-0xe04]; /* 0xe04 */
388 __u32 vdso_per_cpu_data; /* 0xe3c */ 388 __u64 vdso_per_cpu_data; /* 0xe38 */
389 __u32 paste[16]; /* 0xe40 */ 389 __u32 paste[16]; /* 0xe40 */
390 390
391 __u8 pad13[0x11b8-0xe80]; /* 0xe80 */ 391 __u8 pad13[0x11b8-0xe80]; /* 0xe80 */
diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h
index 2bd9faeb3919..e8bd6ac22c99 100644
--- a/arch/s390/include/asm/setup.h
+++ b/arch/s390/include/asm/setup.h
@@ -43,6 +43,8 @@ struct mem_chunk {
43 43
44extern struct mem_chunk memory_chunk[]; 44extern struct mem_chunk memory_chunk[];
45extern unsigned long real_memory_size; 45extern unsigned long real_memory_size;
46extern int memory_end_set;
47extern unsigned long memory_end;
46 48
47void detect_memory_layout(struct mem_chunk chunk[]); 49void detect_memory_layout(struct mem_chunk chunk[]);
48 50
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index e7c5bfb7c755..026a37a94fc9 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -95,6 +95,7 @@ asmlinkage void do_softirq(void)
95 local_irq_restore(flags); 95 local_irq_restore(flags);
96} 96}
97 97
98#ifdef CONFIG_PROC_FS
98void init_irq_proc(void) 99void init_irq_proc(void)
99{ 100{
100 struct proc_dir_entry *root_irq_dir; 101 struct proc_dir_entry *root_irq_dir;
@@ -102,3 +103,4 @@ void init_irq_proc(void)
102 root_irq_dir = proc_mkdir("irq", NULL); 103 root_irq_dir = proc_mkdir("irq", NULL);
103 create_prof_cpu_mask(root_irq_dir); 104 create_prof_cpu_mask(root_irq_dir);
104} 105}
106#endif
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index d825f4950e4e..c5cfb6185eac 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -82,7 +82,9 @@ char elf_platform[ELF_PLATFORM_SIZE];
82 82
83struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS]; 83struct mem_chunk __initdata memory_chunk[MEMORY_CHUNKS];
84volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */ 84volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
85static unsigned long __initdata memory_end; 85
86int __initdata memory_end_set;
87unsigned long __initdata memory_end;
86 88
87/* 89/*
88 * This is set up by the setup-routine at boot-time 90 * This is set up by the setup-routine at boot-time
@@ -281,6 +283,7 @@ void (*pm_power_off)(void) = machine_power_off;
281static int __init early_parse_mem(char *p) 283static int __init early_parse_mem(char *p)
282{ 284{
283 memory_end = memparse(p, &p); 285 memory_end = memparse(p, &p);
286 memory_end_set = 1;
284 return 0; 287 return 0;
285} 288}
286early_param("mem", early_parse_mem); 289early_param("mem", early_parse_mem);
@@ -508,8 +511,10 @@ static void __init setup_memory_end(void)
508 int i; 511 int i;
509 512
510#if defined(CONFIG_ZFCPDUMP) || defined(CONFIG_ZFCPDUMP_MODULE) 513#if defined(CONFIG_ZFCPDUMP) || defined(CONFIG_ZFCPDUMP_MODULE)
511 if (ipl_info.type == IPL_TYPE_FCP_DUMP) 514 if (ipl_info.type == IPL_TYPE_FCP_DUMP) {
512 memory_end = ZFCPDUMP_HSA_SIZE; 515 memory_end = ZFCPDUMP_HSA_SIZE;
516 memory_end_set = 1;
517 }
513#endif 518#endif
514 memory_size = 0; 519 memory_size = 0;
515 memory_end &= PAGE_MASK; 520 memory_end &= PAGE_MASK;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index be8497186b96..0d33893e1e89 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -212,6 +212,10 @@ static void kvm_free_vcpus(struct kvm *kvm)
212 } 212 }
213} 213}
214 214
215void kvm_arch_sync_events(struct kvm *kvm)
216{
217}
218
215void kvm_arch_destroy_vm(struct kvm *kvm) 219void kvm_arch_destroy_vm(struct kvm *kvm)
216{ 220{
217 kvm_free_vcpus(kvm); 221 kvm_free_vcpus(kvm);
diff --git a/arch/sh/boards/board-ap325rxa.c b/arch/sh/boards/board-ap325rxa.c
index caf4c33f4e84..7c35787d29b4 100644
--- a/arch/sh/boards/board-ap325rxa.c
+++ b/arch/sh/boards/board-ap325rxa.c
@@ -22,6 +22,7 @@
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/spi/spi.h> 23#include <linux/spi/spi.h>
24#include <linux/spi/spi_gpio.h> 24#include <linux/spi/spi_gpio.h>
25#include <media/ov772x.h>
25#include <media/soc_camera_platform.h> 26#include <media/soc_camera_platform.h>
26#include <media/sh_mobile_ceu.h> 27#include <media/sh_mobile_ceu.h>
27#include <video/sh_mobile_lcdc.h> 28#include <video/sh_mobile_lcdc.h>
@@ -216,7 +217,14 @@ static struct platform_device lcdc_device = {
216 }, 217 },
217}; 218};
218 219
220static void camera_power(int val)
221{
222 gpio_set_value(GPIO_PTZ5, val); /* RST_CAM/RSTB */
223 mdelay(10);
224}
225
219#ifdef CONFIG_I2C 226#ifdef CONFIG_I2C
227/* support for the old ncm03j camera */
220static unsigned char camera_ncm03j_magic[] = 228static unsigned char camera_ncm03j_magic[] =
221{ 229{
222 0x87, 0x00, 0x88, 0x08, 0x89, 0x01, 0x8A, 0xE8, 230 0x87, 0x00, 0x88, 0x08, 0x89, 0x01, 0x8A, 0xE8,
@@ -237,6 +245,23 @@ static unsigned char camera_ncm03j_magic[] =
237 0x63, 0xD4, 0x64, 0xEA, 0xD6, 0x0F, 245 0x63, 0xD4, 0x64, 0xEA, 0xD6, 0x0F,
238}; 246};
239 247
248static int camera_probe(void)
249{
250 struct i2c_adapter *a = i2c_get_adapter(0);
251 struct i2c_msg msg;
252 int ret;
253
254 camera_power(1);
255 msg.addr = 0x6e;
256 msg.buf = camera_ncm03j_magic;
257 msg.len = 2;
258 msg.flags = 0;
259 ret = i2c_transfer(a, &msg, 1);
260 camera_power(0);
261
262 return ret;
263}
264
240static int camera_set_capture(struct soc_camera_platform_info *info, 265static int camera_set_capture(struct soc_camera_platform_info *info,
241 int enable) 266 int enable)
242{ 267{
@@ -245,9 +270,11 @@ static int camera_set_capture(struct soc_camera_platform_info *info,
245 int ret = 0; 270 int ret = 0;
246 int i; 271 int i;
247 272
273 camera_power(0);
248 if (!enable) 274 if (!enable)
249 return 0; /* no disable for now */ 275 return 0; /* no disable for now */
250 276
277 camera_power(1);
251 for (i = 0; i < ARRAY_SIZE(camera_ncm03j_magic); i += 2) { 278 for (i = 0; i < ARRAY_SIZE(camera_ncm03j_magic); i += 2) {
252 u_int8_t buf[8]; 279 u_int8_t buf[8];
253 280
@@ -286,8 +313,35 @@ static struct platform_device camera_device = {
286 .platform_data = &camera_info, 313 .platform_data = &camera_info,
287 }, 314 },
288}; 315};
316
317static int __init camera_setup(void)
318{
319 if (camera_probe() > 0)
320 platform_device_register(&camera_device);
321
322 return 0;
323}
324late_initcall(camera_setup);
325
289#endif /* CONFIG_I2C */ 326#endif /* CONFIG_I2C */
290 327
328static int ov7725_power(struct device *dev, int mode)
329{
330 camera_power(0);
331 if (mode)
332 camera_power(1);
333
334 return 0;
335}
336
337static struct ov772x_camera_info ov7725_info = {
338 .buswidth = SOCAM_DATAWIDTH_8,
339 .flags = OV772X_FLAG_VFLIP | OV772X_FLAG_HFLIP,
340 .link = {
341 .power = ov7725_power,
342 },
343};
344
291static struct sh_mobile_ceu_info sh_mobile_ceu_info = { 345static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
292 .flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH | 346 .flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
293 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8, 347 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8,
@@ -338,9 +392,6 @@ static struct platform_device *ap325rxa_devices[] __initdata = {
338 &ap325rxa_nor_flash_device, 392 &ap325rxa_nor_flash_device,
339 &lcdc_device, 393 &lcdc_device,
340 &ceu_device, 394 &ceu_device,
341#ifdef CONFIG_I2C
342 &camera_device,
343#endif
344 &nand_flash_device, 395 &nand_flash_device,
345 &sdcard_cn3_device, 396 &sdcard_cn3_device,
346}; 397};
@@ -349,6 +400,10 @@ static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = {
349 { 400 {
350 I2C_BOARD_INFO("pcf8563", 0x51), 401 I2C_BOARD_INFO("pcf8563", 0x51),
351 }, 402 },
403 {
404 I2C_BOARD_INFO("ov772x", 0x21),
405 .platform_data = &ov7725_info,
406 },
352}; 407};
353 408
354static struct spi_board_info ap325rxa_spi_devices[] = { 409static struct spi_board_info ap325rxa_spi_devices[] = {
@@ -426,7 +481,7 @@ static int __init ap325rxa_devices_setup(void)
426 gpio_request(GPIO_PTZ6, NULL); 481 gpio_request(GPIO_PTZ6, NULL);
427 gpio_direction_output(GPIO_PTZ6, 0); /* STBY_CAM */ 482 gpio_direction_output(GPIO_PTZ6, 0); /* STBY_CAM */
428 gpio_request(GPIO_PTZ5, NULL); 483 gpio_request(GPIO_PTZ5, NULL);
429 gpio_direction_output(GPIO_PTZ5, 1); /* RST_CAM */ 484 gpio_direction_output(GPIO_PTZ5, 0); /* RST_CAM */
430 gpio_request(GPIO_PTZ4, NULL); 485 gpio_request(GPIO_PTZ4, NULL);
431 gpio_direction_output(GPIO_PTZ4, 0); /* SADDR */ 486 gpio_direction_output(GPIO_PTZ4, 0); /* SADDR */
432 487
diff --git a/arch/sh/configs/ap325rxa_defconfig b/arch/sh/configs/ap325rxa_defconfig
index 5c423fa8e6b8..352f87d50fdc 100644
--- a/arch/sh/configs/ap325rxa_defconfig
+++ b/arch/sh/configs/ap325rxa_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.28 3# Linux kernel version: 2.6.29-rc2
4# Fri Jan 9 16:54:19 2009 4# Tue Jan 27 11:45:08 2009
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y 7CONFIG_SUPERH32=y
@@ -45,12 +45,12 @@ CONFIG_BSD_PROCESS_ACCT=y
45# CONFIG_AUDIT is not set 45# CONFIG_AUDIT is not set
46# CONFIG_IKCONFIG is not set 46# CONFIG_IKCONFIG is not set
47CONFIG_LOG_BUF_SHIFT=14 47CONFIG_LOG_BUF_SHIFT=14
48# CONFIG_CGROUPS is not set
49CONFIG_GROUP_SCHED=y 48CONFIG_GROUP_SCHED=y
50CONFIG_FAIR_GROUP_SCHED=y 49CONFIG_FAIR_GROUP_SCHED=y
51# CONFIG_RT_GROUP_SCHED is not set 50# CONFIG_RT_GROUP_SCHED is not set
52CONFIG_USER_SCHED=y 51CONFIG_USER_SCHED=y
53# CONFIG_CGROUP_SCHED is not set 52# CONFIG_CGROUP_SCHED is not set
53# CONFIG_CGROUPS is not set
54CONFIG_SYSFS_DEPRECATED=y 54CONFIG_SYSFS_DEPRECATED=y
55CONFIG_SYSFS_DEPRECATED_V2=y 55CONFIG_SYSFS_DEPRECATED_V2=y
56# CONFIG_RELAY is not set 56# CONFIG_RELAY is not set
@@ -378,6 +378,7 @@ CONFIG_WIRELESS=y
378# CONFIG_WIRELESS_EXT is not set 378# CONFIG_WIRELESS_EXT is not set
379# CONFIG_LIB80211 is not set 379# CONFIG_LIB80211 is not set
380# CONFIG_MAC80211 is not set 380# CONFIG_MAC80211 is not set
381# CONFIG_WIMAX is not set
381# CONFIG_RFKILL is not set 382# CONFIG_RFKILL is not set
382# CONFIG_NET_9P is not set 383# CONFIG_NET_9P is not set
383 384
@@ -400,6 +401,7 @@ CONFIG_MTD=y
400# CONFIG_MTD_DEBUG is not set 401# CONFIG_MTD_DEBUG is not set
401CONFIG_MTD_CONCAT=y 402CONFIG_MTD_CONCAT=y
402CONFIG_MTD_PARTITIONS=y 403CONFIG_MTD_PARTITIONS=y
404# CONFIG_MTD_TESTS is not set
403# CONFIG_MTD_REDBOOT_PARTS is not set 405# CONFIG_MTD_REDBOOT_PARTS is not set
404CONFIG_MTD_CMDLINE_PARTS=y 406CONFIG_MTD_CMDLINE_PARTS=y
405# CONFIG_MTD_AR7_PARTS is not set 407# CONFIG_MTD_AR7_PARTS is not set
@@ -447,9 +449,7 @@ CONFIG_MTD_CFI_UTIL=y
447# 449#
448# CONFIG_MTD_COMPLEX_MAPPINGS is not set 450# CONFIG_MTD_COMPLEX_MAPPINGS is not set
449CONFIG_MTD_PHYSMAP=y 451CONFIG_MTD_PHYSMAP=y
450CONFIG_MTD_PHYSMAP_START=0xffffffff 452# CONFIG_MTD_PHYSMAP_COMPAT is not set
451CONFIG_MTD_PHYSMAP_LEN=0
452CONFIG_MTD_PHYSMAP_BANKWIDTH=0
453# CONFIG_MTD_PLATRAM is not set 453# CONFIG_MTD_PLATRAM is not set
454 454
455# 455#
@@ -480,6 +480,12 @@ CONFIG_MTD_NAND_SH_FLCTL=y
480# CONFIG_MTD_ONENAND is not set 480# CONFIG_MTD_ONENAND is not set
481 481
482# 482#
483# LPDDR flash memory drivers
484#
485# CONFIG_MTD_LPDDR is not set
486# CONFIG_MTD_QINFO_PROBE is not set
487
488#
483# UBI - Unsorted block images 489# UBI - Unsorted block images
484# 490#
485CONFIG_MTD_UBI=y 491CONFIG_MTD_UBI=y
@@ -607,6 +613,10 @@ CONFIG_SMSC911X=y
607# CONFIG_WLAN_PRE80211 is not set 613# CONFIG_WLAN_PRE80211 is not set
608# CONFIG_WLAN_80211 is not set 614# CONFIG_WLAN_80211 is not set
609# CONFIG_IWLWIFI_LEDS is not set 615# CONFIG_IWLWIFI_LEDS is not set
616
617#
618# Enable WiMAX (Networking options) to see the WiMAX drivers
619#
610# CONFIG_WAN is not set 620# CONFIG_WAN is not set
611# CONFIG_PPP is not set 621# CONFIG_PPP is not set
612# CONFIG_SLIP is not set 622# CONFIG_SLIP is not set
@@ -790,6 +800,7 @@ CONFIG_SSB_POSSIBLE=y
790# CONFIG_PMIC_DA903X is not set 800# CONFIG_PMIC_DA903X is not set
791# CONFIG_MFD_WM8400 is not set 801# CONFIG_MFD_WM8400 is not set
792# CONFIG_MFD_WM8350_I2C is not set 802# CONFIG_MFD_WM8350_I2C is not set
803# CONFIG_MFD_PCF50633 is not set
793# CONFIG_REGULATOR is not set 804# CONFIG_REGULATOR is not set
794 805
795# 806#
@@ -837,7 +848,7 @@ CONFIG_SOC_CAMERA=y
837# CONFIG_SOC_CAMERA_MT9V022 is not set 848# CONFIG_SOC_CAMERA_MT9V022 is not set
838# CONFIG_SOC_CAMERA_TW9910 is not set 849# CONFIG_SOC_CAMERA_TW9910 is not set
839CONFIG_SOC_CAMERA_PLATFORM=y 850CONFIG_SOC_CAMERA_PLATFORM=y
840# CONFIG_SOC_CAMERA_OV772X is not set 851CONFIG_SOC_CAMERA_OV772X=y
841CONFIG_VIDEO_SH_MOBILE_CEU=y 852CONFIG_VIDEO_SH_MOBILE_CEU=y
842# CONFIG_RADIO_ADAPTERS is not set 853# CONFIG_RADIO_ADAPTERS is not set
843# CONFIG_DAB is not set 854# CONFIG_DAB is not set
@@ -1012,6 +1023,7 @@ CONFIG_FS_POSIX_ACL=y
1012CONFIG_FILE_LOCKING=y 1023CONFIG_FILE_LOCKING=y
1013# CONFIG_XFS_FS is not set 1024# CONFIG_XFS_FS is not set
1014# CONFIG_OCFS2_FS is not set 1025# CONFIG_OCFS2_FS is not set
1026# CONFIG_BTRFS_FS is not set
1015CONFIG_DNOTIFY=y 1027CONFIG_DNOTIFY=y
1016CONFIG_INOTIFY=y 1028CONFIG_INOTIFY=y
1017CONFIG_INOTIFY_USER=y 1029CONFIG_INOTIFY_USER=y
@@ -1060,6 +1072,7 @@ CONFIG_MISC_FILESYSTEMS=y
1060# CONFIG_JFFS2_FS is not set 1072# CONFIG_JFFS2_FS is not set
1061# CONFIG_UBIFS_FS is not set 1073# CONFIG_UBIFS_FS is not set
1062# CONFIG_CRAMFS is not set 1074# CONFIG_CRAMFS is not set
1075# CONFIG_SQUASHFS is not set
1063# CONFIG_VXFS_FS is not set 1076# CONFIG_VXFS_FS is not set
1064# CONFIG_MINIX_FS is not set 1077# CONFIG_MINIX_FS is not set
1065# CONFIG_OMFS_FS is not set 1078# CONFIG_OMFS_FS is not set
diff --git a/arch/sh/configs/migor_defconfig b/arch/sh/configs/migor_defconfig
index 7758263514bc..678576796bdf 100644
--- a/arch/sh/configs/migor_defconfig
+++ b/arch/sh/configs/migor_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.28 3# Linux kernel version: 2.6.29-rc1
4# Fri Jan 9 17:09:35 2009 4# Thu Jan 22 09:16:16 2009
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y 7CONFIG_SUPERH32=y
@@ -45,8 +45,12 @@ CONFIG_SYSVIPC_SYSCTL=y
45CONFIG_IKCONFIG=y 45CONFIG_IKCONFIG=y
46CONFIG_IKCONFIG_PROC=y 46CONFIG_IKCONFIG_PROC=y
47CONFIG_LOG_BUF_SHIFT=14 47CONFIG_LOG_BUF_SHIFT=14
48# CONFIG_CGROUPS is not set
49# CONFIG_GROUP_SCHED is not set 48# CONFIG_GROUP_SCHED is not set
49
50#
51# Control Group support
52#
53# CONFIG_CGROUPS is not set
50CONFIG_SYSFS_DEPRECATED=y 54CONFIG_SYSFS_DEPRECATED=y
51CONFIG_SYSFS_DEPRECATED_V2=y 55CONFIG_SYSFS_DEPRECATED_V2=y
52# CONFIG_RELAY is not set 56# CONFIG_RELAY is not set
@@ -389,6 +393,7 @@ CONFIG_WIRELESS_EXT=y
389CONFIG_WIRELESS_EXT_SYSFS=y 393CONFIG_WIRELESS_EXT_SYSFS=y
390# CONFIG_LIB80211 is not set 394# CONFIG_LIB80211 is not set
391# CONFIG_MAC80211 is not set 395# CONFIG_MAC80211 is not set
396# CONFIG_WIMAX is not set
392# CONFIG_RFKILL is not set 397# CONFIG_RFKILL is not set
393# CONFIG_NET_9P is not set 398# CONFIG_NET_9P is not set
394 399
@@ -411,6 +416,7 @@ CONFIG_MTD=y
411# CONFIG_MTD_DEBUG is not set 416# CONFIG_MTD_DEBUG is not set
412CONFIG_MTD_CONCAT=y 417CONFIG_MTD_CONCAT=y
413CONFIG_MTD_PARTITIONS=y 418CONFIG_MTD_PARTITIONS=y
419# CONFIG_MTD_TESTS is not set
414# CONFIG_MTD_REDBOOT_PARTS is not set 420# CONFIG_MTD_REDBOOT_PARTS is not set
415CONFIG_MTD_CMDLINE_PARTS=y 421CONFIG_MTD_CMDLINE_PARTS=y
416# CONFIG_MTD_AR7_PARTS is not set 422# CONFIG_MTD_AR7_PARTS is not set
@@ -458,9 +464,7 @@ CONFIG_MTD_CFI_UTIL=y
458# 464#
459# CONFIG_MTD_COMPLEX_MAPPINGS is not set 465# CONFIG_MTD_COMPLEX_MAPPINGS is not set
460CONFIG_MTD_PHYSMAP=y 466CONFIG_MTD_PHYSMAP=y
461CONFIG_MTD_PHYSMAP_START=0xffffffff 467# CONFIG_MTD_PHYSMAP_COMPAT is not set
462CONFIG_MTD_PHYSMAP_LEN=0
463CONFIG_MTD_PHYSMAP_BANKWIDTH=0
464# CONFIG_MTD_PLATRAM is not set 468# CONFIG_MTD_PLATRAM is not set
465 469
466# 470#
@@ -488,6 +492,12 @@ CONFIG_MTD_NAND_PLATFORM=y
488# CONFIG_MTD_ONENAND is not set 492# CONFIG_MTD_ONENAND is not set
489 493
490# 494#
495# LPDDR flash memory drivers
496#
497# CONFIG_MTD_LPDDR is not set
498# CONFIG_MTD_QINFO_PROBE is not set
499
500#
491# UBI - Unsorted block images 501# UBI - Unsorted block images
492# 502#
493# CONFIG_MTD_UBI is not set 503# CONFIG_MTD_UBI is not set
@@ -587,6 +597,10 @@ CONFIG_SMC91X=y
587# CONFIG_WLAN_PRE80211 is not set 597# CONFIG_WLAN_PRE80211 is not set
588# CONFIG_WLAN_80211 is not set 598# CONFIG_WLAN_80211 is not set
589# CONFIG_IWLWIFI_LEDS is not set 599# CONFIG_IWLWIFI_LEDS is not set
600
601#
602# Enable WiMAX (Networking options) to see the WiMAX drivers
603#
590# CONFIG_WAN is not set 604# CONFIG_WAN is not set
591# CONFIG_PPP is not set 605# CONFIG_PPP is not set
592# CONFIG_SLIP is not set 606# CONFIG_SLIP is not set
@@ -761,6 +775,7 @@ CONFIG_SSB_POSSIBLE=y
761# CONFIG_PMIC_DA903X is not set 775# CONFIG_PMIC_DA903X is not set
762# CONFIG_MFD_WM8400 is not set 776# CONFIG_MFD_WM8400 is not set
763# CONFIG_MFD_WM8350_I2C is not set 777# CONFIG_MFD_WM8350_I2C is not set
778# CONFIG_MFD_PCF50633 is not set
764# CONFIG_REGULATOR is not set 779# CONFIG_REGULATOR is not set
765 780
766# 781#
@@ -806,9 +821,9 @@ CONFIG_SOC_CAMERA=y
806# CONFIG_SOC_CAMERA_MT9M111 is not set 821# CONFIG_SOC_CAMERA_MT9M111 is not set
807# CONFIG_SOC_CAMERA_MT9T031 is not set 822# CONFIG_SOC_CAMERA_MT9T031 is not set
808# CONFIG_SOC_CAMERA_MT9V022 is not set 823# CONFIG_SOC_CAMERA_MT9V022 is not set
809# CONFIG_SOC_CAMERA_TW9910 is not set 824CONFIG_SOC_CAMERA_TW9910=y
810CONFIG_SOC_CAMERA_PLATFORM=y 825# CONFIG_SOC_CAMERA_PLATFORM is not set
811# CONFIG_SOC_CAMERA_OV772X is not set 826CONFIG_SOC_CAMERA_OV772X=y
812CONFIG_VIDEO_SH_MOBILE_CEU=y 827CONFIG_VIDEO_SH_MOBILE_CEU=y
813# CONFIG_RADIO_ADAPTERS is not set 828# CONFIG_RADIO_ADAPTERS is not set
814# CONFIG_DAB is not set 829# CONFIG_DAB is not set
@@ -866,11 +881,13 @@ CONFIG_USB_GADGET_SELECTED=y
866# CONFIG_USB_GADGET_PXA25X is not set 881# CONFIG_USB_GADGET_PXA25X is not set
867# CONFIG_USB_GADGET_PXA27X is not set 882# CONFIG_USB_GADGET_PXA27X is not set
868# CONFIG_USB_GADGET_S3C2410 is not set 883# CONFIG_USB_GADGET_S3C2410 is not set
884# CONFIG_USB_GADGET_IMX is not set
869CONFIG_USB_GADGET_M66592=y 885CONFIG_USB_GADGET_M66592=y
870CONFIG_USB_M66592=y 886CONFIG_USB_M66592=y
871CONFIG_SUPERH_BUILT_IN_M66592=y 887CONFIG_SUPERH_BUILT_IN_M66592=y
872# CONFIG_USB_GADGET_AMD5536UDC is not set 888# CONFIG_USB_GADGET_AMD5536UDC is not set
873# CONFIG_USB_GADGET_FSL_QE is not set 889# CONFIG_USB_GADGET_FSL_QE is not set
890# CONFIG_USB_GADGET_CI13XXX is not set
874# CONFIG_USB_GADGET_NET2280 is not set 891# CONFIG_USB_GADGET_NET2280 is not set
875# CONFIG_USB_GADGET_GOKU is not set 892# CONFIG_USB_GADGET_GOKU is not set
876# CONFIG_USB_GADGET_DUMMY_HCD is not set 893# CONFIG_USB_GADGET_DUMMY_HCD is not set
@@ -883,6 +900,11 @@ CONFIG_USB_G_SERIAL=y
883# CONFIG_USB_MIDI_GADGET is not set 900# CONFIG_USB_MIDI_GADGET is not set
884# CONFIG_USB_G_PRINTER is not set 901# CONFIG_USB_G_PRINTER is not set
885# CONFIG_USB_CDC_COMPOSITE is not set 902# CONFIG_USB_CDC_COMPOSITE is not set
903
904#
905# OTG and related infrastructure
906#
907# CONFIG_USB_GPIO_VBUS is not set
886# CONFIG_MMC is not set 908# CONFIG_MMC is not set
887# CONFIG_MEMSTICK is not set 909# CONFIG_MEMSTICK is not set
888# CONFIG_NEW_LEDS is not set 910# CONFIG_NEW_LEDS is not set
@@ -961,6 +983,7 @@ CONFIG_UIO_PDRV_GENIRQ=y
961CONFIG_FILE_LOCKING=y 983CONFIG_FILE_LOCKING=y
962# CONFIG_XFS_FS is not set 984# CONFIG_XFS_FS is not set
963# CONFIG_OCFS2_FS is not set 985# CONFIG_OCFS2_FS is not set
986# CONFIG_BTRFS_FS is not set
964# CONFIG_DNOTIFY is not set 987# CONFIG_DNOTIFY is not set
965# CONFIG_INOTIFY is not set 988# CONFIG_INOTIFY is not set
966# CONFIG_QUOTA is not set 989# CONFIG_QUOTA is not set
@@ -1004,6 +1027,7 @@ CONFIG_MISC_FILESYSTEMS=y
1004# CONFIG_EFS_FS is not set 1027# CONFIG_EFS_FS is not set
1005# CONFIG_JFFS2_FS is not set 1028# CONFIG_JFFS2_FS is not set
1006# CONFIG_CRAMFS is not set 1029# CONFIG_CRAMFS is not set
1030# CONFIG_SQUASHFS is not set
1007# CONFIG_VXFS_FS is not set 1031# CONFIG_VXFS_FS is not set
1008# CONFIG_MINIX_FS is not set 1032# CONFIG_MINIX_FS is not set
1009# CONFIG_OMFS_FS is not set 1033# CONFIG_OMFS_FS is not set
diff --git a/arch/sh/include/asm/mutex-llsc.h b/arch/sh/include/asm/mutex-llsc.h
index ee839ee58ac8..090358a7e1bb 100644
--- a/arch/sh/include/asm/mutex-llsc.h
+++ b/arch/sh/include/asm/mutex-llsc.h
@@ -21,38 +21,36 @@
21static inline void 21static inline void
22__mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *)) 22__mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *))
23{ 23{
24 int __ex_flag, __res; 24 int __done, __res;
25 25
26 __asm__ __volatile__ ( 26 __asm__ __volatile__ (
27 "movli.l @%2, %0 \n" 27 "movli.l @%2, %0 \n"
28 "add #-1, %0 \n" 28 "add #-1, %0 \n"
29 "movco.l %0, @%2 \n" 29 "movco.l %0, @%2 \n"
30 "movt %1 \n" 30 "movt %1 \n"
31 : "=&z" (__res), "=&r" (__ex_flag) 31 : "=&z" (__res), "=&r" (__done)
32 : "r" (&(count)->counter) 32 : "r" (&(count)->counter)
33 : "t"); 33 : "t");
34 34
35 __res |= !__ex_flag; 35 if (unlikely(!__done || __res != 0))
36 if (unlikely(__res != 0))
37 fail_fn(count); 36 fail_fn(count);
38} 37}
39 38
40static inline int 39static inline int
41__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) 40__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
42{ 41{
43 int __ex_flag, __res; 42 int __done, __res;
44 43
45 __asm__ __volatile__ ( 44 __asm__ __volatile__ (
46 "movli.l @%2, %0 \n" 45 "movli.l @%2, %0 \n"
47 "add #-1, %0 \n" 46 "add #-1, %0 \n"
48 "movco.l %0, @%2 \n" 47 "movco.l %0, @%2 \n"
49 "movt %1 \n" 48 "movt %1 \n"
50 : "=&z" (__res), "=&r" (__ex_flag) 49 : "=&z" (__res), "=&r" (__done)
51 : "r" (&(count)->counter) 50 : "r" (&(count)->counter)
52 : "t"); 51 : "t");
53 52
54 __res |= !__ex_flag; 53 if (unlikely(!__done || __res != 0))
55 if (unlikely(__res != 0))
56 __res = fail_fn(count); 54 __res = fail_fn(count);
57 55
58 return __res; 56 return __res;
@@ -61,19 +59,18 @@ __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
61static inline void 59static inline void
62__mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *)) 60__mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *))
63{ 61{
64 int __ex_flag, __res; 62 int __done, __res;
65 63
66 __asm__ __volatile__ ( 64 __asm__ __volatile__ (
67 "movli.l @%2, %0 \n\t" 65 "movli.l @%2, %0 \n\t"
68 "add #1, %0 \n\t" 66 "add #1, %0 \n\t"
69 "movco.l %0, @%2 \n\t" 67 "movco.l %0, @%2 \n\t"
70 "movt %1 \n\t" 68 "movt %1 \n\t"
71 : "=&z" (__res), "=&r" (__ex_flag) 69 : "=&z" (__res), "=&r" (__done)
72 : "r" (&(count)->counter) 70 : "r" (&(count)->counter)
73 : "t"); 71 : "t");
74 72
75 __res |= !__ex_flag; 73 if (unlikely(!__done || __res <= 0))
76 if (unlikely(__res <= 0))
77 fail_fn(count); 74 fail_fn(count);
78} 75}
79 76
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h
index 05a868a71ef5..5bc34681d994 100644
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -21,23 +21,10 @@ static inline void syscall_rollback(struct task_struct *task,
21 */ 21 */
22} 22}
23 23
24static inline bool syscall_has_error(struct pt_regs *regs)
25{
26 return (regs->sr & 0x1) ? true : false;
27}
28static inline void syscall_set_error(struct pt_regs *regs)
29{
30 regs->sr |= 0x1;
31}
32static inline void syscall_clear_error(struct pt_regs *regs)
33{
34 regs->sr &= ~0x1;
35}
36
37static inline long syscall_get_error(struct task_struct *task, 24static inline long syscall_get_error(struct task_struct *task,
38 struct pt_regs *regs) 25 struct pt_regs *regs)
39{ 26{
40 return syscall_has_error(regs) ? regs->regs[0] : 0; 27 return IS_ERR_VALUE(regs->regs[0]) ? regs->regs[0] : 0;
41} 28}
42 29
43static inline long syscall_get_return_value(struct task_struct *task, 30static inline long syscall_get_return_value(struct task_struct *task,
@@ -50,13 +37,10 @@ static inline void syscall_set_return_value(struct task_struct *task,
50 struct pt_regs *regs, 37 struct pt_regs *regs,
51 int error, long val) 38 int error, long val)
52{ 39{
53 if (error) { 40 if (error)
54 syscall_set_error(regs);
55 regs->regs[0] = -error; 41 regs->regs[0] = -error;
56 } else { 42 else
57 syscall_clear_error(regs);
58 regs->regs[0] = val; 43 regs->regs[0] = val;
59 }
60} 44}
61 45
62static inline void syscall_get_arguments(struct task_struct *task, 46static inline void syscall_get_arguments(struct task_struct *task,
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h
index e1143b9784d6..c3561ca72bee 100644
--- a/arch/sh/include/asm/syscall_64.h
+++ b/arch/sh/include/asm/syscall_64.h
@@ -21,23 +21,10 @@ static inline void syscall_rollback(struct task_struct *task,
21 */ 21 */
22} 22}
23 23
24static inline bool syscall_has_error(struct pt_regs *regs)
25{
26 return (regs->sr & 0x1) ? true : false;
27}
28static inline void syscall_set_error(struct pt_regs *regs)
29{
30 regs->sr |= 0x1;
31}
32static inline void syscall_clear_error(struct pt_regs *regs)
33{
34 regs->sr &= ~0x1;
35}
36
37static inline long syscall_get_error(struct task_struct *task, 24static inline long syscall_get_error(struct task_struct *task,
38 struct pt_regs *regs) 25 struct pt_regs *regs)
39{ 26{
40 return syscall_has_error(regs) ? regs->regs[9] : 0; 27 return IS_ERR_VALUE(regs->regs[9]) ? regs->regs[9] : 0;
41} 28}
42 29
43static inline long syscall_get_return_value(struct task_struct *task, 30static inline long syscall_get_return_value(struct task_struct *task,
@@ -50,13 +37,10 @@ static inline void syscall_set_return_value(struct task_struct *task,
50 struct pt_regs *regs, 37 struct pt_regs *regs,
51 int error, long val) 38 int error, long val)
52{ 39{
53 if (error) { 40 if (error)
54 syscall_set_error(regs);
55 regs->regs[9] = -error; 41 regs->regs[9] = -error;
56 } else { 42 else
57 syscall_clear_error(regs);
58 regs->regs[9] = val; 43 regs->regs[9] = val;
59 }
60} 44}
61 45
62static inline void syscall_get_arguments(struct task_struct *task, 46static inline void syscall_get_arguments(struct task_struct *task,
diff --git a/arch/sh/kernel/cpu/sh4/fpu.c b/arch/sh/kernel/cpu/sh4/fpu.c
index 2780917c0088..e3ea5411da6d 100644
--- a/arch/sh/kernel/cpu/sh4/fpu.c
+++ b/arch/sh/kernel/cpu/sh4/fpu.c
@@ -423,7 +423,7 @@ static int ieee_fpe_handler(struct pt_regs *regs)
423 int m; 423 int m;
424 unsigned int hx; 424 unsigned int hx;
425 425
426 m = (finsn >> 9) & 0x7; 426 m = (finsn >> 8) & 0x7;
427 hx = tsk->thread.fpu.hard.fp_regs[m]; 427 hx = tsk->thread.fpu.hard.fp_regs[m];
428 428
429 if ((tsk->thread.fpu.hard.fpscr & FPSCR_CAUSE_ERROR) 429 if ((tsk->thread.fpu.hard.fpscr & FPSCR_CAUSE_ERROR)
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 534247508572..370d2cfa34eb 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -262,11 +262,11 @@ void __init setup_bootmem_allocator(unsigned long free_pfn)
262 BOOTMEM_DEFAULT); 262 BOOTMEM_DEFAULT);
263 263
264 /* 264 /*
265 * reserve physical page 0 - it's a special BIOS page on many boxes, 265 * Reserve physical pages below CONFIG_ZERO_PAGE_OFFSET.
266 * enabling clean reboots, SMP operation, laptop functions.
267 */ 266 */
268 reserve_bootmem(__MEMORY_START, CONFIG_ZERO_PAGE_OFFSET, 267 if (CONFIG_ZERO_PAGE_OFFSET != 0)
269 BOOTMEM_DEFAULT); 268 reserve_bootmem(__MEMORY_START, CONFIG_ZERO_PAGE_OFFSET,
269 BOOTMEM_DEFAULT);
270 270
271 sparse_memory_present_with_active_regions(0); 271 sparse_memory_present_with_active_regions(0);
272 272
diff --git a/arch/sh/kernel/signal_32.c b/arch/sh/kernel/signal_32.c
index 77c21bde376a..17784e19ae34 100644
--- a/arch/sh/kernel/signal_32.c
+++ b/arch/sh/kernel/signal_32.c
@@ -510,7 +510,6 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs,
510 case -ERESTARTNOHAND: 510 case -ERESTARTNOHAND:
511 no_system_call_restart: 511 no_system_call_restart:
512 regs->regs[0] = -EINTR; 512 regs->regs[0] = -EINTR;
513 regs->sr |= 1;
514 break; 513 break;
515 514
516 case -ERESTARTSYS: 515 case -ERESTARTSYS:
@@ -589,8 +588,7 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
589 588
590 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 589 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
591 if (signr > 0) { 590 if (signr > 0) {
592 if (regs->sr & 1) 591 handle_syscall_restart(save_r0, regs, &ka.sa);
593 handle_syscall_restart(save_r0, regs, &ka.sa);
594 592
595 /* Whee! Actually deliver the signal. */ 593 /* Whee! Actually deliver the signal. */
596 if (handle_signal(signr, &ka, &info, oldset, 594 if (handle_signal(signr, &ka, &info, oldset,
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c
index b22fdfaaa191..0663a0ee6021 100644
--- a/arch/sh/kernel/signal_64.c
+++ b/arch/sh/kernel/signal_64.c
@@ -60,7 +60,6 @@ handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa)
60 case -ERESTARTNOHAND: 60 case -ERESTARTNOHAND:
61 no_system_call_restart: 61 no_system_call_restart:
62 regs->regs[REG_RET] = -EINTR; 62 regs->regs[REG_RET] = -EINTR;
63 regs->sr |= 1;
64 break; 63 break;
65 64
66 case -ERESTARTSYS: 65 case -ERESTARTSYS:
@@ -109,8 +108,7 @@ static int do_signal(struct pt_regs *regs, sigset_t *oldset)
109 108
110 signr = get_signal_to_deliver(&info, &ka, regs, 0); 109 signr = get_signal_to_deliver(&info, &ka, regs, 0);
111 if (signr > 0) { 110 if (signr > 0) {
112 if (regs->sr & 1) 111 handle_syscall_restart(regs, &ka.sa);
113 handle_syscall_restart(regs, &ka.sa);
114 112
115 /* Whee! Actually deliver the signal. */ 113 /* Whee! Actually deliver the signal. */
116 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 114 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
diff --git a/arch/sh/lib/checksum.S b/arch/sh/lib/checksum.S
index cbdd0d40e545..356c8ec92893 100644
--- a/arch/sh/lib/checksum.S
+++ b/arch/sh/lib/checksum.S
@@ -36,8 +36,7 @@
36 */ 36 */
37 37
38/* 38/*
39 * unsigned int csum_partial(const unsigned char *buf, int len, 39 * asmlinkage __wsum csum_partial(const void *buf, int len, __wsum sum);
40 * unsigned int sum);
41 */ 40 */
42 41
43.text 42.text
@@ -49,11 +48,31 @@ ENTRY(csum_partial)
49 * Fortunately, it is easy to convert 2-byte alignment to 4-byte 48 * Fortunately, it is easy to convert 2-byte alignment to 4-byte
50 * alignment for the unrolled loop. 49 * alignment for the unrolled loop.
51 */ 50 */
52 mov r5, r1
53 mov r4, r0 51 mov r4, r0
54 tst #2, r0 ! Check alignment. 52 tst #3, r0 ! Check alignment.
55 bt 2f ! Jump if alignment is ok. 53 bt/s 2f ! Jump if alignment is ok.
54 mov r4, r7 ! Keep a copy to check for alignment
56 ! 55 !
56 tst #1, r0 ! Check alignment.
57 bt 21f ! Jump if alignment is boundary of 2bytes.
58
59 ! buf is odd
60 tst r5, r5
61 add #-1, r5
62 bt 9f
63 mov.b @r4+, r0
64 extu.b r0, r0
65 addc r0, r6 ! t=0 from previous tst
66 mov r6, r0
67 shll8 r6
68 shlr16 r0
69 shlr8 r0
70 or r0, r6
71 mov r4, r0
72 tst #2, r0
73 bt 2f
7421:
75 ! buf is 2 byte aligned (len could be 0)
57 add #-2, r5 ! Alignment uses up two bytes. 76 add #-2, r5 ! Alignment uses up two bytes.
58 cmp/pz r5 ! 77 cmp/pz r5 !
59 bt/s 1f ! Jump if we had at least two bytes. 78 bt/s 1f ! Jump if we had at least two bytes.
@@ -61,16 +80,17 @@ ENTRY(csum_partial)
61 bra 6f 80 bra 6f
62 add #2, r5 ! r5 was < 2. Deal with it. 81 add #2, r5 ! r5 was < 2. Deal with it.
631: 821:
64 mov r5, r1 ! Save new len for later use.
65 mov.w @r4+, r0 83 mov.w @r4+, r0
66 extu.w r0, r0 84 extu.w r0, r0
67 addc r0, r6 85 addc r0, r6
68 bf 2f 86 bf 2f
69 add #1, r6 87 add #1, r6
702: 882:
89 ! buf is 4 byte aligned (len could be 0)
90 mov r5, r1
71 mov #-5, r0 91 mov #-5, r0
72 shld r0, r5 92 shld r0, r1
73 tst r5, r5 93 tst r1, r1
74 bt/s 4f ! if it's =0, go to 4f 94 bt/s 4f ! if it's =0, go to 4f
75 clrt 95 clrt
76 .align 2 96 .align 2
@@ -92,30 +112,31 @@ ENTRY(csum_partial)
92 addc r0, r6 112 addc r0, r6
93 addc r2, r6 113 addc r2, r6
94 movt r0 114 movt r0
95 dt r5 115 dt r1
96 bf/s 3b 116 bf/s 3b
97 cmp/eq #1, r0 117 cmp/eq #1, r0
98 ! here, we know r5==0 118 ! here, we know r1==0
99 addc r5, r6 ! add carry to r6 119 addc r1, r6 ! add carry to r6
1004: 1204:
101 mov r1, r0 121 mov r5, r0
102 and #0x1c, r0 122 and #0x1c, r0
103 tst r0, r0 123 tst r0, r0
104 bt/s 6f 124 bt 6f
105 mov r0, r5 125 ! 4 bytes or more remaining
106 shlr2 r5 126 mov r0, r1
127 shlr2 r1
107 mov #0, r2 128 mov #0, r2
1085: 1295:
109 addc r2, r6 130 addc r2, r6
110 mov.l @r4+, r2 131 mov.l @r4+, r2
111 movt r0 132 movt r0
112 dt r5 133 dt r1
113 bf/s 5b 134 bf/s 5b
114 cmp/eq #1, r0 135 cmp/eq #1, r0
115 addc r2, r6 136 addc r2, r6
116 addc r5, r6 ! r5==0 here, so it means add carry-bit 137 addc r1, r6 ! r1==0 here, so it means add carry-bit
1176: 1386:
118 mov r1, r5 139 ! 3 bytes or less remaining
119 mov #3, r0 140 mov #3, r0
120 and r0, r5 141 and r0, r5
121 tst r5, r5 142 tst r5, r5
@@ -139,8 +160,18 @@ ENTRY(csum_partial)
1398: 1608:
140 addc r0, r6 161 addc r0, r6
141 mov #0, r0 162 mov #0, r0
142 addc r0, r6 163 addc r0, r6
1439: 1649:
165 ! Check if the buffer was misaligned, if so realign sum
166 mov r7, r0
167 tst #1, r0
168 bt 10f
169 mov r6, r0
170 shll8 r6
171 shlr16 r0
172 shlr8 r0
173 or r0, r6
17410:
144 rts 175 rts
145 mov r6, r0 176 mov r6, r0
146 177
diff --git a/arch/sparc/include/asm/cpudata_64.h b/arch/sparc/include/asm/cpudata_64.h
index 7da7c13d23c4..a11b89ee9ef8 100644
--- a/arch/sparc/include/asm/cpudata_64.h
+++ b/arch/sparc/include/asm/cpudata_64.h
@@ -17,7 +17,7 @@
17typedef struct { 17typedef struct {
18 /* Dcache line 1 */ 18 /* Dcache line 1 */
19 unsigned int __softirq_pending; /* must be 1st, see rtrap.S */ 19 unsigned int __softirq_pending; /* must be 1st, see rtrap.S */
20 unsigned int __pad0; 20 unsigned int __nmi_count;
21 unsigned long clock_tick; /* %tick's per second */ 21 unsigned long clock_tick; /* %tick's per second */
22 unsigned long __pad; 22 unsigned long __pad;
23 unsigned int __pad1; 23 unsigned int __pad1;
diff --git a/arch/sparc/include/asm/irq_64.h b/arch/sparc/include/asm/irq_64.h
index d47d4a1955a9..1934f2cbf513 100644
--- a/arch/sparc/include/asm/irq_64.h
+++ b/arch/sparc/include/asm/irq_64.h
@@ -66,9 +66,6 @@ extern void virt_irq_free(unsigned int virt_irq);
66extern void __init init_IRQ(void); 66extern void __init init_IRQ(void);
67extern void fixup_irqs(void); 67extern void fixup_irqs(void);
68 68
69extern int register_perfctr_intr(void (*handler)(struct pt_regs *));
70extern void release_perfctr_intr(void (*handler)(struct pt_regs *));
71
72static inline void set_softint(unsigned long bits) 69static inline void set_softint(unsigned long bits)
73{ 70{
74 __asm__ __volatile__("wr %0, 0x0, %%set_softint" 71 __asm__ __volatile__("wr %0, 0x0, %%set_softint"
@@ -98,5 +95,6 @@ void __trigger_all_cpu_backtrace(void);
98extern void *hardirq_stack[NR_CPUS]; 95extern void *hardirq_stack[NR_CPUS];
99extern void *softirq_stack[NR_CPUS]; 96extern void *softirq_stack[NR_CPUS];
100#define __ARCH_HAS_DO_SOFTIRQ 97#define __ARCH_HAS_DO_SOFTIRQ
98#define ARCH_HAS_NMI_WATCHDOG
101 99
102#endif 100#endif
diff --git a/arch/sparc/include/asm/kdebug_64.h b/arch/sparc/include/asm/kdebug_64.h
index f905b773235a..feb3578e12c4 100644
--- a/arch/sparc/include/asm/kdebug_64.h
+++ b/arch/sparc/include/asm/kdebug_64.h
@@ -14,6 +14,8 @@ enum die_val {
14 DIE_TRAP, 14 DIE_TRAP,
15 DIE_TRAP_TL1, 15 DIE_TRAP_TL1,
16 DIE_CALL, 16 DIE_CALL,
17 DIE_NMI,
18 DIE_NMIWATCHDOG,
17}; 19};
18 20
19#endif 21#endif
diff --git a/arch/sparc/include/asm/nmi.h b/arch/sparc/include/asm/nmi.h
new file mode 100644
index 000000000000..fbd546dd4feb
--- /dev/null
+++ b/arch/sparc/include/asm/nmi.h
@@ -0,0 +1,10 @@
1#ifndef __NMI_H
2#define __NMI_H
3
4extern int __init nmi_init(void);
5extern void perfctr_irq(int irq, struct pt_regs *regs);
6extern void nmi_adjust_hz(unsigned int new_hz);
7
8extern int nmi_usable;
9
10#endif /* __NMI_H */
diff --git a/arch/sparc/include/asm/pcr.h b/arch/sparc/include/asm/pcr.h
new file mode 100644
index 000000000000..a2f5c61f924e
--- /dev/null
+++ b/arch/sparc/include/asm/pcr.h
@@ -0,0 +1,46 @@
1#ifndef __PCR_H
2#define __PCR_H
3
4struct pcr_ops {
5 u64 (*read)(void);
6 void (*write)(u64);
7};
8extern const struct pcr_ops *pcr_ops;
9
10extern void deferred_pcr_work_irq(int irq, struct pt_regs *regs);
11extern void schedule_deferred_pcr_work(void);
12
13#define PCR_PIC_PRIV 0x00000001 /* PIC access is privileged */
14#define PCR_STRACE 0x00000002 /* Trace supervisor events */
15#define PCR_UTRACE 0x00000004 /* Trace user events */
16#define PCR_N2_HTRACE 0x00000008 /* Trace hypervisor events */
17#define PCR_N2_TOE_OV0 0x00000010 /* Trap if PIC 0 overflows */
18#define PCR_N2_TOE_OV1 0x00000020 /* Trap if PIC 1 overflows */
19#define PCR_N2_MASK0 0x00003fc0
20#define PCR_N2_MASK0_SHIFT 6
21#define PCR_N2_SL0 0x0003c000
22#define PCR_N2_SL0_SHIFT 14
23#define PCR_N2_OV0 0x00040000
24#define PCR_N2_MASK1 0x07f80000
25#define PCR_N2_MASK1_SHIFT 19
26#define PCR_N2_SL1 0x78000000
27#define PCR_N2_SL1_SHIFT 27
28#define PCR_N2_OV1 0x80000000
29
30extern unsigned int picl_shift;
31
32/* In order to commonize as much of the implementation as
33 * possible, we use PICH as our counter. Mostly this is
34 * to accomodate Niagara-1 which can only count insn cycles
35 * in PICH.
36 */
37static inline u64 picl_value(unsigned int nmi_hz)
38{
39 u32 delta = local_cpu_data().clock_tick / (nmi_hz << picl_shift);
40
41 return ((u64)((0 - delta) & 0xffffffff)) << 32;
42}
43
44extern u64 pcr_enable;
45
46#endif /* __PCR_H */
diff --git a/arch/sparc/include/asm/pil.h b/arch/sparc/include/asm/pil.h
index d573820c0ff4..32a7efe76d00 100644
--- a/arch/sparc/include/asm/pil.h
+++ b/arch/sparc/include/asm/pil.h
@@ -23,6 +23,7 @@
23#define PIL_SMP_CTX_NEW_VERSION 4 23#define PIL_SMP_CTX_NEW_VERSION 4
24#define PIL_DEVICE_IRQ 5 24#define PIL_DEVICE_IRQ 5
25#define PIL_SMP_CALL_FUNC_SNGL 6 25#define PIL_SMP_CALL_FUNC_SNGL 6
26#define PIL_DEFERRED_PCR_WORK 7
26#define PIL_NORMAL_MAX 14 27#define PIL_NORMAL_MAX 14
27#define PIL_NMI 15 28#define PIL_NMI 15
28 29
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 53adcaa0348b..54742e58831c 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -52,6 +52,8 @@ obj-$(CONFIG_SPARC64) += visemul.o
52obj-$(CONFIG_SPARC64) += hvapi.o 52obj-$(CONFIG_SPARC64) += hvapi.o
53obj-$(CONFIG_SPARC64) += sstate.o 53obj-$(CONFIG_SPARC64) += sstate.o
54obj-$(CONFIG_SPARC64) += mdesc.o 54obj-$(CONFIG_SPARC64) += mdesc.o
55obj-$(CONFIG_SPARC64) += pcr.o
56obj-$(CONFIG_SPARC64) += nmi.o
55 57
56# sparc32 do not use GENERIC_HARDIRQS but uses the generic devres implementation 58# sparc32 do not use GENERIC_HARDIRQS but uses the generic devres implementation
57obj-$(CONFIG_SPARC32) += devres.o 59obj-$(CONFIG_SPARC32) += devres.o
diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c
index 32d32b4824f5..d85c3dc4953a 100644
--- a/arch/sparc/kernel/cpu.c
+++ b/arch/sparc/kernel/cpu.c
@@ -26,6 +26,7 @@ EXPORT_PER_CPU_SYMBOL(__cpu_data);
26struct cpu_info { 26struct cpu_info {
27 int psr_vers; 27 int psr_vers;
28 const char *name; 28 const char *name;
29 const char *pmu_name;
29}; 30};
30 31
31struct fpu_info { 32struct fpu_info {
@@ -45,6 +46,9 @@ struct manufacturer_info {
45#define CPU(ver, _name) \ 46#define CPU(ver, _name) \
46{ .psr_vers = ver, .name = _name } 47{ .psr_vers = ver, .name = _name }
47 48
49#define CPU_PMU(ver, _name, _pmu_name) \
50{ .psr_vers = ver, .name = _name, .pmu_name = _pmu_name }
51
48#define FPU(ver, _name) \ 52#define FPU(ver, _name) \
49{ .fp_vers = ver, .name = _name } 53{ .fp_vers = ver, .name = _name }
50 54
@@ -183,10 +187,10 @@ static const struct manufacturer_info __initconst manufacturer_info[] = {
183},{ 187},{
184 0x17, 188 0x17,
185 .cpu_info = { 189 .cpu_info = {
186 CPU(0x10, "TI UltraSparc I (SpitFire)"), 190 CPU_PMU(0x10, "TI UltraSparc I (SpitFire)", "ultra12"),
187 CPU(0x11, "TI UltraSparc II (BlackBird)"), 191 CPU_PMU(0x11, "TI UltraSparc II (BlackBird)", "ultra12"),
188 CPU(0x12, "TI UltraSparc IIi (Sabre)"), 192 CPU_PMU(0x12, "TI UltraSparc IIi (Sabre)", "ultra12"),
189 CPU(0x13, "TI UltraSparc IIe (Hummingbird)"), 193 CPU_PMU(0x13, "TI UltraSparc IIe (Hummingbird)", "ultra12"),
190 CPU(-1, NULL) 194 CPU(-1, NULL)
191 }, 195 },
192 .fpu_info = { 196 .fpu_info = {
@@ -199,7 +203,7 @@ static const struct manufacturer_info __initconst manufacturer_info[] = {
199},{ 203},{
200 0x22, 204 0x22,
201 .cpu_info = { 205 .cpu_info = {
202 CPU(0x10, "TI UltraSparc I (SpitFire)"), 206 CPU_PMU(0x10, "TI UltraSparc I (SpitFire)", "ultra12"),
203 CPU(-1, NULL) 207 CPU(-1, NULL)
204 }, 208 },
205 .fpu_info = { 209 .fpu_info = {
@@ -209,12 +213,12 @@ static const struct manufacturer_info __initconst manufacturer_info[] = {
209},{ 213},{
210 0x3e, 214 0x3e,
211 .cpu_info = { 215 .cpu_info = {
212 CPU(0x14, "TI UltraSparc III (Cheetah)"), 216 CPU_PMU(0x14, "TI UltraSparc III (Cheetah)", "ultra3"),
213 CPU(0x15, "TI UltraSparc III+ (Cheetah+)"), 217 CPU_PMU(0x15, "TI UltraSparc III+ (Cheetah+)", "ultra3+"),
214 CPU(0x16, "TI UltraSparc IIIi (Jalapeno)"), 218 CPU_PMU(0x16, "TI UltraSparc IIIi (Jalapeno)", "ultra3i"),
215 CPU(0x18, "TI UltraSparc IV (Jaguar)"), 219 CPU_PMU(0x18, "TI UltraSparc IV (Jaguar)", "ultra3+"),
216 CPU(0x19, "TI UltraSparc IV+ (Panther)"), 220 CPU_PMU(0x19, "TI UltraSparc IV+ (Panther)", "ultra4+"),
217 CPU(0x22, "TI UltraSparc IIIi+ (Serrano)"), 221 CPU_PMU(0x22, "TI UltraSparc IIIi+ (Serrano)", "ultra3i"),
218 CPU(-1, NULL) 222 CPU(-1, NULL)
219 }, 223 },
220 .fpu_info = { 224 .fpu_info = {
@@ -234,6 +238,7 @@ static const struct manufacturer_info __initconst manufacturer_info[] = {
234 238
235const char *sparc_cpu_type; 239const char *sparc_cpu_type;
236const char *sparc_fpu_type; 240const char *sparc_fpu_type;
241const char *sparc_pmu_type;
237 242
238unsigned int fsr_storage; 243unsigned int fsr_storage;
239 244
@@ -244,6 +249,7 @@ static void set_cpu_and_fpu(int psr_impl, int psr_vers, int fpu_vers)
244 249
245 sparc_cpu_type = NULL; 250 sparc_cpu_type = NULL;
246 sparc_fpu_type = NULL; 251 sparc_fpu_type = NULL;
252 sparc_pmu_type = NULL;
247 manuf = NULL; 253 manuf = NULL;
248 254
249 for (i = 0; i < ARRAY_SIZE(manufacturer_info); i++) 255 for (i = 0; i < ARRAY_SIZE(manufacturer_info); i++)
@@ -263,6 +269,7 @@ static void set_cpu_and_fpu(int psr_impl, int psr_vers, int fpu_vers)
263 { 269 {
264 if (cpu->psr_vers == psr_vers) { 270 if (cpu->psr_vers == psr_vers) {
265 sparc_cpu_type = cpu->name; 271 sparc_cpu_type = cpu->name;
272 sparc_pmu_type = cpu->pmu_name;
266 sparc_fpu_type = "No FPU"; 273 sparc_fpu_type = "No FPU";
267 break; 274 break;
268 } 275 }
@@ -290,6 +297,8 @@ static void set_cpu_and_fpu(int psr_impl, int psr_vers, int fpu_vers)
290 psr_impl, fpu_vers); 297 psr_impl, fpu_vers);
291 sparc_fpu_type = "Unknown FPU"; 298 sparc_fpu_type = "Unknown FPU";
292 } 299 }
300 if (sparc_pmu_type == NULL)
301 sparc_pmu_type = "Unknown PMU";
293} 302}
294 303
295#ifdef CONFIG_SPARC32 304#ifdef CONFIG_SPARC32
@@ -315,11 +324,13 @@ static void __init sun4v_cpu_probe(void)
315 case SUN4V_CHIP_NIAGARA1: 324 case SUN4V_CHIP_NIAGARA1:
316 sparc_cpu_type = "UltraSparc T1 (Niagara)"; 325 sparc_cpu_type = "UltraSparc T1 (Niagara)";
317 sparc_fpu_type = "UltraSparc T1 integrated FPU"; 326 sparc_fpu_type = "UltraSparc T1 integrated FPU";
327 sparc_pmu_type = "niagara";
318 break; 328 break;
319 329
320 case SUN4V_CHIP_NIAGARA2: 330 case SUN4V_CHIP_NIAGARA2:
321 sparc_cpu_type = "UltraSparc T2 (Niagara2)"; 331 sparc_cpu_type = "UltraSparc T2 (Niagara2)";
322 sparc_fpu_type = "UltraSparc T2 integrated FPU"; 332 sparc_fpu_type = "UltraSparc T2 integrated FPU";
333 sparc_pmu_type = "niagara2";
323 break; 334 break;
324 335
325 default: 336 default:
diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
index 8ffee714f932..a46c3a21e26d 100644
--- a/arch/sparc/kernel/head_64.S
+++ b/arch/sparc/kernel/head_64.S
@@ -891,10 +891,35 @@ prom_tba: .xword 0
891tlb_type: .word 0 /* Must NOT end up in BSS */ 891tlb_type: .word 0 /* Must NOT end up in BSS */
892 .section ".fixup",#alloc,#execinstr 892 .section ".fixup",#alloc,#execinstr
893 893
894 .globl __ret_efault, __retl_efault 894 .globl __ret_efault, __retl_efault, __ret_one, __retl_one
895__ret_efault: 895ENTRY(__ret_efault)
896 ret 896 ret
897 restore %g0, -EFAULT, %o0 897 restore %g0, -EFAULT, %o0
898__retl_efault: 898ENDPROC(__ret_efault)
899
900ENTRY(__retl_efault)
899 retl 901 retl
900 mov -EFAULT, %o0 902 mov -EFAULT, %o0
903ENDPROC(__retl_efault)
904
905ENTRY(__retl_one)
906 retl
907 mov 1, %o0
908ENDPROC(__retl_one)
909
910ENTRY(__ret_one_asi)
911 wr %g0, ASI_AIUS, %asi
912 ret
913 restore %g0, 1, %o0
914ENDPROC(__ret_one_asi)
915
916ENTRY(__retl_one_asi)
917 wr %g0, ASI_AIUS, %asi
918 retl
919 mov 1, %o0
920ENDPROC(__retl_one_asi)
921
922ENTRY(__retl_o1)
923 retl
924 mov %o1, %o0
925ENDPROC(__retl_o1)
diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c
index cab8e0286871..e289376198eb 100644
--- a/arch/sparc/kernel/irq_64.c
+++ b/arch/sparc/kernel/irq_64.c
@@ -196,6 +196,11 @@ int show_interrupts(struct seq_file *p, void *v)
196 seq_putc(p, '\n'); 196 seq_putc(p, '\n');
197skip: 197skip:
198 spin_unlock_irqrestore(&irq_desc[i].lock, flags); 198 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
199 } else if (i == NR_IRQS) {
200 seq_printf(p, "NMI: ");
201 for_each_online_cpu(j)
202 seq_printf(p, "%10u ", cpu_data(j).__nmi_count);
203 seq_printf(p, " Non-maskable interrupts\n");
199 } 204 }
200 return 0; 205 return 0;
201} 206}
@@ -778,69 +783,6 @@ void do_softirq(void)
778 local_irq_restore(flags); 783 local_irq_restore(flags);
779} 784}
780 785
781static void unhandled_perf_irq(struct pt_regs *regs)
782{
783 unsigned long pcr, pic;
784
785 read_pcr(pcr);
786 read_pic(pic);
787
788 write_pcr(0);
789
790 printk(KERN_EMERG "CPU %d: Got unexpected perf counter IRQ.\n",
791 smp_processor_id());
792 printk(KERN_EMERG "CPU %d: PCR[%016lx] PIC[%016lx]\n",
793 smp_processor_id(), pcr, pic);
794}
795
796/* Almost a direct copy of the powerpc PMC code. */
797static DEFINE_SPINLOCK(perf_irq_lock);
798static void *perf_irq_owner_caller; /* mostly for debugging */
799static void (*perf_irq)(struct pt_regs *regs) = unhandled_perf_irq;
800
801/* Invoked from level 15 PIL handler in trap table. */
802void perfctr_irq(int irq, struct pt_regs *regs)
803{
804 clear_softint(1 << irq);
805 perf_irq(regs);
806}
807
808int register_perfctr_intr(void (*handler)(struct pt_regs *))
809{
810 int ret;
811
812 if (!handler)
813 return -EINVAL;
814
815 spin_lock(&perf_irq_lock);
816 if (perf_irq != unhandled_perf_irq) {
817 printk(KERN_WARNING "register_perfctr_intr: "
818 "perf IRQ busy (reserved by caller %p)\n",
819 perf_irq_owner_caller);
820 ret = -EBUSY;
821 goto out;
822 }
823
824 perf_irq_owner_caller = __builtin_return_address(0);
825 perf_irq = handler;
826
827 ret = 0;
828out:
829 spin_unlock(&perf_irq_lock);
830
831 return ret;
832}
833EXPORT_SYMBOL_GPL(register_perfctr_intr);
834
835void release_perfctr_intr(void (*handler)(struct pt_regs *))
836{
837 spin_lock(&perf_irq_lock);
838 perf_irq_owner_caller = NULL;
839 perf_irq = unhandled_perf_irq;
840 spin_unlock(&perf_irq_lock);
841}
842EXPORT_SYMBOL_GPL(release_perfctr_intr);
843
844#ifdef CONFIG_HOTPLUG_CPU 786#ifdef CONFIG_HOTPLUG_CPU
845void fixup_irqs(void) 787void fixup_irqs(void)
846{ 788{
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 81a972e8d8ea..15d8a3f645c9 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -5,6 +5,7 @@
5 5
6/* cpu.c */ 6/* cpu.c */
7extern const char *sparc_cpu_type; 7extern const char *sparc_cpu_type;
8extern const char *sparc_pmu_type;
8extern const char *sparc_fpu_type; 9extern const char *sparc_fpu_type;
9 10
10extern unsigned int fsr_storage; 11extern unsigned int fsr_storage;
diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c
new file mode 100644
index 000000000000..f3577223c863
--- /dev/null
+++ b/arch/sparc/kernel/nmi.c
@@ -0,0 +1,225 @@
1/* Pseudo NMI support on sparc64 systems.
2 *
3 * Copyright (C) 2009 David S. Miller <davem@davemloft.net>
4 *
5 * The NMI watchdog support and infrastructure is based almost
6 * entirely upon the x86 NMI support code.
7 */
8#include <linux/kernel.h>
9#include <linux/param.h>
10#include <linux/init.h>
11#include <linux/percpu.h>
12#include <linux/nmi.h>
13#include <linux/module.h>
14#include <linux/kprobes.h>
15#include <linux/kernel_stat.h>
16#include <linux/slab.h>
17#include <linux/kdebug.h>
18#include <linux/delay.h>
19#include <linux/smp.h>
20
21#include <asm/ptrace.h>
22#include <asm/local.h>
23#include <asm/pcr.h>
24
25/* We don't have a real NMI on sparc64, but we can fake one
26 * up using profiling counter overflow interrupts and interrupt
27 * levels.
28 *
29 * The profile overflow interrupts at level 15, so we use
30 * level 14 as our IRQ off level.
31 */
32
33static int nmi_watchdog_active;
34static int panic_on_timeout;
35
36int nmi_usable;
37EXPORT_SYMBOL_GPL(nmi_usable);
38
39static unsigned int nmi_hz = HZ;
40
41static DEFINE_PER_CPU(unsigned int, last_irq_sum);
42static DEFINE_PER_CPU(local_t, alert_counter);
43static DEFINE_PER_CPU(int, nmi_touch);
44
45void touch_nmi_watchdog(void)
46{
47 if (nmi_watchdog_active) {
48 int cpu;
49
50 for_each_present_cpu(cpu) {
51 if (per_cpu(nmi_touch, cpu) != 1)
52 per_cpu(nmi_touch, cpu) = 1;
53 }
54 }
55
56 touch_softlockup_watchdog();
57}
58EXPORT_SYMBOL(touch_nmi_watchdog);
59
60static void die_nmi(const char *str, struct pt_regs *regs, int do_panic)
61{
62 if (notify_die(DIE_NMIWATCHDOG, str, regs, 0,
63 pt_regs_trap_type(regs), SIGINT) == NOTIFY_STOP)
64 return;
65
66 console_verbose();
67 bust_spinlocks(1);
68
69 printk(KERN_EMERG "%s", str);
70 printk(" on CPU%d, ip %08lx, registers:\n",
71 smp_processor_id(), regs->tpc);
72 show_regs(regs);
73 dump_stack();
74
75 bust_spinlocks(0);
76
77 if (do_panic || panic_on_oops)
78 panic("Non maskable interrupt");
79
80 local_irq_enable();
81 do_exit(SIGBUS);
82}
83
84notrace __kprobes void perfctr_irq(int irq, struct pt_regs *regs)
85{
86 unsigned int sum, touched = 0;
87 int cpu = smp_processor_id();
88
89 clear_softint(1 << irq);
90 pcr_ops->write(PCR_PIC_PRIV);
91
92 local_cpu_data().__nmi_count++;
93
94 if (notify_die(DIE_NMI, "nmi", regs, 0,
95 pt_regs_trap_type(regs), SIGINT) == NOTIFY_STOP)
96 touched = 1;
97
98 sum = kstat_irqs_cpu(0, cpu);
99 if (__get_cpu_var(nmi_touch)) {
100 __get_cpu_var(nmi_touch) = 0;
101 touched = 1;
102 }
103 if (!touched && __get_cpu_var(last_irq_sum) == sum) {
104 local_inc(&__get_cpu_var(alert_counter));
105 if (local_read(&__get_cpu_var(alert_counter)) == 5 * nmi_hz)
106 die_nmi("BUG: NMI Watchdog detected LOCKUP",
107 regs, panic_on_timeout);
108 } else {
109 __get_cpu_var(last_irq_sum) = sum;
110 local_set(&__get_cpu_var(alert_counter), 0);
111 }
112 if (nmi_usable) {
113 write_pic(picl_value(nmi_hz));
114 pcr_ops->write(pcr_enable);
115 }
116}
117
118static inline unsigned int get_nmi_count(int cpu)
119{
120 return cpu_data(cpu).__nmi_count;
121}
122
123static int endflag __initdata;
124
125static __init void nmi_cpu_busy(void *data)
126{
127 local_irq_enable_in_hardirq();
128 while (endflag == 0)
129 mb();
130}
131
132static void report_broken_nmi(int cpu, int *prev_nmi_count)
133{
134 printk(KERN_CONT "\n");
135
136 printk(KERN_WARNING
137 "WARNING: CPU#%d: NMI appears to be stuck (%d->%d)!\n",
138 cpu, prev_nmi_count[cpu], get_nmi_count(cpu));
139
140 printk(KERN_WARNING
141 "Please report this to bugzilla.kernel.org,\n");
142 printk(KERN_WARNING
143 "and attach the output of the 'dmesg' command.\n");
144
145 nmi_usable = 0;
146}
147
148static void stop_watchdog(void *unused)
149{
150 pcr_ops->write(PCR_PIC_PRIV);
151}
152
153static int __init check_nmi_watchdog(void)
154{
155 unsigned int *prev_nmi_count;
156 int cpu, err;
157
158 prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(unsigned int), GFP_KERNEL);
159 if (!prev_nmi_count) {
160 err = -ENOMEM;
161 goto error;
162 }
163
164 printk(KERN_INFO "Testing NMI watchdog ... ");
165
166 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0);
167
168 for_each_possible_cpu(cpu)
169 prev_nmi_count[cpu] = get_nmi_count(cpu);
170 local_irq_enable();
171 mdelay((20 * 1000) / nmi_hz); /* wait 20 ticks */
172
173 for_each_online_cpu(cpu) {
174 if (get_nmi_count(cpu) - prev_nmi_count[cpu] <= 5)
175 report_broken_nmi(cpu, prev_nmi_count);
176 }
177 endflag = 1;
178 if (!nmi_usable) {
179 kfree(prev_nmi_count);
180 err = -ENODEV;
181 goto error;
182 }
183 printk("OK.\n");
184
185 nmi_hz = 1;
186
187 kfree(prev_nmi_count);
188 return 0;
189error:
190 on_each_cpu(stop_watchdog, NULL, 1);
191 return err;
192}
193
194static void start_watchdog(void *unused)
195{
196 pcr_ops->write(PCR_PIC_PRIV);
197 write_pic(picl_value(nmi_hz));
198
199 pcr_ops->write(pcr_enable);
200}
201
202void nmi_adjust_hz(unsigned int new_hz)
203{
204 nmi_hz = new_hz;
205 on_each_cpu(start_watchdog, NULL, 1);
206}
207EXPORT_SYMBOL_GPL(nmi_adjust_hz);
208
209int __init nmi_init(void)
210{
211 nmi_usable = 1;
212
213 on_each_cpu(start_watchdog, NULL, 1);
214
215 return check_nmi_watchdog();
216}
217
218static int __init setup_nmi_watchdog(char *str)
219{
220 if (!strncmp(str, "panic", 5))
221 panic_on_timeout = 1;
222
223 return 0;
224}
225__setup("nmi_watchdog=", setup_nmi_watchdog);
diff --git a/arch/sparc/kernel/pcr.c b/arch/sparc/kernel/pcr.c
new file mode 100644
index 000000000000..1ae8cdd7e703
--- /dev/null
+++ b/arch/sparc/kernel/pcr.c
@@ -0,0 +1,158 @@
1/* pcr.c: Generic sparc64 performance counter infrastructure.
2 *
3 * Copyright (C) 2009 David S. Miller (davem@davemloft.net)
4 */
5#include <linux/kernel.h>
6#include <linux/module.h>
7#include <linux/init.h>
8#include <linux/irq.h>
9
10#include <asm/pil.h>
11#include <asm/pcr.h>
12#include <asm/nmi.h>
13
14/* This code is shared between various users of the performance
15 * counters. Users will be oprofile, pseudo-NMI watchdog, and the
16 * perf_counter support layer.
17 */
18
19#define PCR_SUN4U_ENABLE (PCR_PIC_PRIV | PCR_STRACE | PCR_UTRACE)
20#define PCR_N2_ENABLE (PCR_PIC_PRIV | PCR_STRACE | PCR_UTRACE | \
21 PCR_N2_TOE_OV1 | \
22 (2 << PCR_N2_SL1_SHIFT) | \
23 (0xff << PCR_N2_MASK1_SHIFT))
24
25u64 pcr_enable;
26unsigned int picl_shift;
27
28/* Performance counter interrupts run unmasked at PIL level 15.
29 * Therefore we can't do things like wakeups and other work
30 * that expects IRQ disabling to be adhered to in locking etc.
31 *
32 * Therefore in such situations we defer the work by signalling
33 * a lower level cpu IRQ.
34 */
35void deferred_pcr_work_irq(int irq, struct pt_regs *regs)
36{
37 clear_softint(1 << PIL_DEFERRED_PCR_WORK);
38}
39
40void schedule_deferred_pcr_work(void)
41{
42 set_softint(1 << PIL_DEFERRED_PCR_WORK);
43}
44
45const struct pcr_ops *pcr_ops;
46EXPORT_SYMBOL_GPL(pcr_ops);
47
48static u64 direct_pcr_read(void)
49{
50 u64 val;
51
52 read_pcr(val);
53 return val;
54}
55
56static void direct_pcr_write(u64 val)
57{
58 write_pcr(val);
59}
60
61static const struct pcr_ops direct_pcr_ops = {
62 .read = direct_pcr_read,
63 .write = direct_pcr_write,
64};
65
66static void n2_pcr_write(u64 val)
67{
68 unsigned long ret;
69
70 ret = sun4v_niagara2_setperf(HV_N2_PERF_SPARC_CTL, val);
71 if (val != HV_EOK)
72 write_pcr(val);
73}
74
75static const struct pcr_ops n2_pcr_ops = {
76 .read = direct_pcr_read,
77 .write = n2_pcr_write,
78};
79
80static unsigned long perf_hsvc_group;
81static unsigned long perf_hsvc_major;
82static unsigned long perf_hsvc_minor;
83
84static int __init register_perf_hsvc(void)
85{
86 if (tlb_type == hypervisor) {
87 switch (sun4v_chip_type) {
88 case SUN4V_CHIP_NIAGARA1:
89 perf_hsvc_group = HV_GRP_NIAG_PERF;
90 break;
91
92 case SUN4V_CHIP_NIAGARA2:
93 perf_hsvc_group = HV_GRP_N2_CPU;
94 break;
95
96 default:
97 return -ENODEV;
98 }
99
100
101 perf_hsvc_major = 1;
102 perf_hsvc_minor = 0;
103 if (sun4v_hvapi_register(perf_hsvc_group,
104 perf_hsvc_major,
105 &perf_hsvc_minor)) {
106 printk("perfmon: Could not register hvapi.\n");
107 return -ENODEV;
108 }
109 }
110 return 0;
111}
112
113static void __init unregister_perf_hsvc(void)
114{
115 if (tlb_type != hypervisor)
116 return;
117 sun4v_hvapi_unregister(perf_hsvc_group);
118}
119
120int __init pcr_arch_init(void)
121{
122 int err = register_perf_hsvc();
123
124 if (err)
125 return err;
126
127 switch (tlb_type) {
128 case hypervisor:
129 pcr_ops = &n2_pcr_ops;
130 pcr_enable = PCR_N2_ENABLE;
131 picl_shift = 2;
132 break;
133
134 case cheetah:
135 case cheetah_plus:
136 pcr_ops = &direct_pcr_ops;
137 pcr_enable = PCR_SUN4U_ENABLE;
138 break;
139
140 case spitfire:
141 /* UltraSPARC-I/II and derivatives lack a profile
142 * counter overflow interrupt so we can't make use of
143 * their hardware currently.
144 */
145 /* fallthrough */
146 default:
147 err = -ENODEV;
148 goto out_unregister;
149 }
150
151 return nmi_init();
152
153out_unregister:
154 unregister_perf_hsvc();
155 return err;
156}
157
158arch_initcall(pcr_arch_init);
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index cc8b5604442c..a73954b87f0a 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -29,6 +29,7 @@
29#include <linux/cpu.h> 29#include <linux/cpu.h>
30#include <linux/elfcore.h> 30#include <linux/elfcore.h>
31#include <linux/sysrq.h> 31#include <linux/sysrq.h>
32#include <linux/nmi.h>
32 33
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
34#include <asm/system.h> 35#include <asm/system.h>
@@ -52,8 +53,10 @@
52 53
53static void sparc64_yield(int cpu) 54static void sparc64_yield(int cpu)
54{ 55{
55 if (tlb_type != hypervisor) 56 if (tlb_type != hypervisor) {
57 touch_nmi_watchdog();
56 return; 58 return;
59 }
57 60
58 clear_thread_flag(TIF_POLLING_NRFLAG); 61 clear_thread_flag(TIF_POLLING_NRFLAG);
59 smp_mb__after_clear_bit(); 62 smp_mb__after_clear_bit();
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index 49d061f4ae9d..f2bcfd2967d7 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -354,6 +354,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)
354 seq_printf(m, 354 seq_printf(m,
355 "cpu\t\t: %s\n" 355 "cpu\t\t: %s\n"
356 "fpu\t\t: %s\n" 356 "fpu\t\t: %s\n"
357 "pmu\t\t: %s\n"
357 "prom\t\t: %s\n" 358 "prom\t\t: %s\n"
358 "type\t\t: %s\n" 359 "type\t\t: %s\n"
359 "ncpus probed\t: %d\n" 360 "ncpus probed\t: %d\n"
@@ -366,6 +367,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)
366 , 367 ,
367 sparc_cpu_type, 368 sparc_cpu_type,
368 sparc_fpu_type, 369 sparc_fpu_type,
370 sparc_pmu_type,
369 prom_version, 371 prom_version,
370 ((tlb_type == hypervisor) ? 372 ((tlb_type == hypervisor) ?
371 "sun4v" : 373 "sun4v" :
diff --git a/arch/sparc/kernel/ttable.S b/arch/sparc/kernel/ttable.S
index ea925503b42e..d9bdfb9d5c18 100644
--- a/arch/sparc/kernel/ttable.S
+++ b/arch/sparc/kernel/ttable.S
@@ -63,7 +63,8 @@ tl0_irq6: TRAP_IRQ(smp_call_function_single_client, 6)
63#else 63#else
64tl0_irq6: BTRAP(0x46) 64tl0_irq6: BTRAP(0x46)
65#endif 65#endif
66tl0_irq7: BTRAP(0x47) BTRAP(0x48) BTRAP(0x49) 66tl0_irq7: TRAP_IRQ(deferred_pcr_work_irq, 7)
67tl0_irq8: BTRAP(0x48) BTRAP(0x49)
67tl0_irq10: BTRAP(0x4a) BTRAP(0x4b) BTRAP(0x4c) BTRAP(0x4d) 68tl0_irq10: BTRAP(0x4a) BTRAP(0x4b) BTRAP(0x4c) BTRAP(0x4d)
68tl0_irq14: TRAP_IRQ(timer_interrupt, 14) 69tl0_irq14: TRAP_IRQ(timer_interrupt, 14)
69tl0_irq15: TRAP_NMI_IRQ(perfctr_irq, 15) 70tl0_irq15: TRAP_NMI_IRQ(perfctr_irq, 15)
diff --git a/arch/sparc/lib/GENbzero.S b/arch/sparc/lib/GENbzero.S
index 6a4f956a2f7a..8e7a843ddd88 100644
--- a/arch/sparc/lib/GENbzero.S
+++ b/arch/sparc/lib/GENbzero.S
@@ -6,13 +6,9 @@
6 6
7#define EX_ST(x,y) \ 7#define EX_ST(x,y) \
898: x,y; \ 898: x,y; \
9 .section .fixup; \
10 .align 4; \
1199: retl; \
12 mov %o1, %o0; \
13 .section __ex_table,"a";\ 9 .section __ex_table,"a";\
14 .align 4; \ 10 .align 4; \
15 .word 98b, 99b; \ 11 .word 98b, __retl_o1; \
16 .text; \ 12 .text; \
17 .align 4; 13 .align 4;
18 14
diff --git a/arch/sparc/lib/GENcopy_from_user.S b/arch/sparc/lib/GENcopy_from_user.S
index 2b9df99e87f9..b7d0bd6b1406 100644
--- a/arch/sparc/lib/GENcopy_from_user.S
+++ b/arch/sparc/lib/GENcopy_from_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -27,7 +23,7 @@
27#define PREAMBLE \ 23#define PREAMBLE \
28 rd %asi, %g1; \ 24 rd %asi, %g1; \
29 cmp %g1, ASI_AIUS; \ 25 cmp %g1, ASI_AIUS; \
30 bne,pn %icc, memcpy_user_stub; \ 26 bne,pn %icc, ___copy_in_user; \
31 nop 27 nop
32#endif 28#endif
33 29
diff --git a/arch/sparc/lib/GENcopy_to_user.S b/arch/sparc/lib/GENcopy_to_user.S
index bb3f7084daf9..780550e1afc7 100644
--- a/arch/sparc/lib/GENcopy_to_user.S
+++ b/arch/sparc/lib/GENcopy_to_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -31,7 +27,7 @@
31#define PREAMBLE \ 27#define PREAMBLE \
32 rd %asi, %g1; \ 28 rd %asi, %g1; \
33 cmp %g1, ASI_AIUS; \ 29 cmp %g1, ASI_AIUS; \
34 bne,pn %icc, memcpy_user_stub; \ 30 bne,pn %icc, ___copy_in_user; \
35 nop 31 nop
36#endif 32#endif
37 33
diff --git a/arch/sparc/lib/NG2copy_from_user.S b/arch/sparc/lib/NG2copy_from_user.S
index c77ef5f22102..119ccb9a54f4 100644
--- a/arch/sparc/lib/NG2copy_from_user.S
+++ b/arch/sparc/lib/NG2copy_from_user.S
@@ -5,14 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: wr %g0, ASI_AIUS, %asi;\
11 retl; \
12 mov 1, %o0; \
13 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
14 .align 4; \ 9 .align 4; \
15 .word 98b, 99b; \ 10 .word 98b, __retl_one_asi;\
16 .text; \ 11 .text; \
17 .align 4; 12 .align 4;
18 13
@@ -33,7 +28,7 @@
33#define PREAMBLE \ 28#define PREAMBLE \
34 rd %asi, %g1; \ 29 rd %asi, %g1; \
35 cmp %g1, ASI_AIUS; \ 30 cmp %g1, ASI_AIUS; \
36 bne,pn %icc, memcpy_user_stub; \ 31 bne,pn %icc, ___copy_in_user; \
37 nop 32 nop
38#endif 33#endif
39 34
diff --git a/arch/sparc/lib/NG2copy_to_user.S b/arch/sparc/lib/NG2copy_to_user.S
index 4bd4093acbbd..7fe1ccefd9d0 100644
--- a/arch/sparc/lib/NG2copy_to_user.S
+++ b/arch/sparc/lib/NG2copy_to_user.S
@@ -5,14 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: wr %g0, ASI_AIUS, %asi;\
11 retl; \
12 mov 1, %o0; \
13 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
14 .align 4; \ 9 .align 4; \
15 .word 98b, 99b; \ 10 .word 98b, __retl_one_asi;\
16 .text; \ 11 .text; \
17 .align 4; 12 .align 4;
18 13
@@ -42,7 +37,7 @@
42#define PREAMBLE \ 37#define PREAMBLE \
43 rd %asi, %g1; \ 38 rd %asi, %g1; \
44 cmp %g1, ASI_AIUS; \ 39 cmp %g1, ASI_AIUS; \
45 bne,pn %icc, memcpy_user_stub; \ 40 bne,pn %icc, ___copy_in_user; \
46 nop 41 nop
47#endif 42#endif
48 43
diff --git a/arch/sparc/lib/NGbzero.S b/arch/sparc/lib/NGbzero.S
index 814d5f7a45e1..beab29bf419b 100644
--- a/arch/sparc/lib/NGbzero.S
+++ b/arch/sparc/lib/NGbzero.S
@@ -6,13 +6,9 @@
6 6
7#define EX_ST(x,y) \ 7#define EX_ST(x,y) \
898: x,y; \ 898: x,y; \
9 .section .fixup; \
10 .align 4; \
1199: retl; \
12 mov %o1, %o0; \
13 .section __ex_table,"a";\ 9 .section __ex_table,"a";\
14 .align 4; \ 10 .align 4; \
15 .word 98b, 99b; \ 11 .word 98b, __retl_o1; \
16 .text; \ 12 .text; \
17 .align 4; 13 .align 4;
18 14
diff --git a/arch/sparc/lib/NGcopy_from_user.S b/arch/sparc/lib/NGcopy_from_user.S
index e7f433f71b42..5d1e4d1ac21e 100644
--- a/arch/sparc/lib/NGcopy_from_user.S
+++ b/arch/sparc/lib/NGcopy_from_user.S
@@ -5,14 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: wr %g0, ASI_AIUS, %asi;\
11 ret; \
12 restore %g0, 1, %o0; \
13 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
14 .align 4; \ 9 .align 4; \
15 .word 98b, 99b; \ 10 .word 98b, __ret_one_asi;\
16 .text; \ 11 .text; \
17 .align 4; 12 .align 4;
18 13
@@ -30,7 +25,7 @@
30#define PREAMBLE \ 25#define PREAMBLE \
31 rd %asi, %g1; \ 26 rd %asi, %g1; \
32 cmp %g1, ASI_AIUS; \ 27 cmp %g1, ASI_AIUS; \
33 bne,pn %icc, memcpy_user_stub; \ 28 bne,pn %icc, ___copy_in_user; \
34 nop 29 nop
35#endif 30#endif
36 31
diff --git a/arch/sparc/lib/NGcopy_to_user.S b/arch/sparc/lib/NGcopy_to_user.S
index 6ea01c5532a0..ff630dcb273c 100644
--- a/arch/sparc/lib/NGcopy_to_user.S
+++ b/arch/sparc/lib/NGcopy_to_user.S
@@ -5,14 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: wr %g0, ASI_AIUS, %asi;\
11 ret; \
12 restore %g0, 1, %o0; \
13 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
14 .align 4; \ 9 .align 4; \
15 .word 98b, 99b; \ 10 .word 98b, __ret_one_asi;\
16 .text; \ 11 .text; \
17 .align 4; 12 .align 4;
18 13
@@ -33,7 +28,7 @@
33#define PREAMBLE \ 28#define PREAMBLE \
34 rd %asi, %g1; \ 29 rd %asi, %g1; \
35 cmp %g1, ASI_AIUS; \ 30 cmp %g1, ASI_AIUS; \
36 bne,pn %icc, memcpy_user_stub; \ 31 bne,pn %icc, ___copy_in_user; \
37 nop 32 nop
38#endif 33#endif
39 34
diff --git a/arch/sparc/lib/U1copy_from_user.S b/arch/sparc/lib/U1copy_from_user.S
index 3192b0bf4fab..a6ae2ea04bf5 100644
--- a/arch/sparc/lib/U1copy_from_user.S
+++ b/arch/sparc/lib/U1copy_from_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -27,7 +23,7 @@
27#define PREAMBLE \ 23#define PREAMBLE \
28 rd %asi, %g1; \ 24 rd %asi, %g1; \
29 cmp %g1, ASI_AIUS; \ 25 cmp %g1, ASI_AIUS; \
30 bne,pn %icc, memcpy_user_stub; \ 26 bne,pn %icc, ___copy_in_user; \
31 nop; \ 27 nop; \
32 28
33#include "U1memcpy.S" 29#include "U1memcpy.S"
diff --git a/arch/sparc/lib/U1copy_to_user.S b/arch/sparc/lib/U1copy_to_user.S
index d1210ffb0b82..f4b970eeb485 100644
--- a/arch/sparc/lib/U1copy_to_user.S
+++ b/arch/sparc/lib/U1copy_to_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -27,7 +23,7 @@
27#define PREAMBLE \ 23#define PREAMBLE \
28 rd %asi, %g1; \ 24 rd %asi, %g1; \
29 cmp %g1, ASI_AIUS; \ 25 cmp %g1, ASI_AIUS; \
30 bne,pn %icc, memcpy_user_stub; \ 26 bne,pn %icc, ___copy_in_user; \
31 nop; \ 27 nop; \
32 28
33#include "U1memcpy.S" 29#include "U1memcpy.S"
diff --git a/arch/sparc/lib/U3copy_from_user.S b/arch/sparc/lib/U3copy_from_user.S
index f5bfc8d9d216..b1acd1331c33 100644
--- a/arch/sparc/lib/U3copy_from_user.S
+++ b/arch/sparc/lib/U3copy_from_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
diff --git a/arch/sparc/lib/U3copy_to_user.S b/arch/sparc/lib/U3copy_to_user.S
index 2334f111bb0c..ef1e493afdfa 100644
--- a/arch/sparc/lib/U3copy_to_user.S
+++ b/arch/sparc/lib/U3copy_to_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -27,7 +23,7 @@
27#define PREAMBLE \ 23#define PREAMBLE \
28 rd %asi, %g1; \ 24 rd %asi, %g1; \
29 cmp %g1, ASI_AIUS; \ 25 cmp %g1, ASI_AIUS; \
30 bne,pn %icc, memcpy_user_stub; \ 26 bne,pn %icc, ___copy_in_user; \
31 nop; \ 27 nop; \
32 28
33#include "U3memcpy.S" 29#include "U3memcpy.S"
diff --git a/arch/sparc/lib/bzero.S b/arch/sparc/lib/bzero.S
index c7bbae8c590f..b6557297440f 100644
--- a/arch/sparc/lib/bzero.S
+++ b/arch/sparc/lib/bzero.S
@@ -88,13 +88,9 @@ __bzero_done:
88 88
89#define EX_ST(x,y) \ 89#define EX_ST(x,y) \
9098: x,y; \ 9098: x,y; \
91 .section .fixup; \
92 .align 4; \
9399: retl; \
94 mov %o1, %o0; \
95 .section __ex_table,"a";\ 91 .section __ex_table,"a";\
96 .align 4; \ 92 .align 4; \
97 .word 98b, 99b; \ 93 .word 98b, __retl_o1; \
98 .text; \ 94 .text; \
99 .align 4; 95 .align 4;
100 96
diff --git a/arch/sparc/lib/copy_in_user.S b/arch/sparc/lib/copy_in_user.S
index 650af3f21f78..302c0e60dc2c 100644
--- a/arch/sparc/lib/copy_in_user.S
+++ b/arch/sparc/lib/copy_in_user.S
@@ -3,19 +3,16 @@
3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#include <linux/linkage.h>
6#include <asm/asi.h> 7#include <asm/asi.h>
7 8
8#define XCC xcc 9#define XCC xcc
9 10
10#define EX(x,y) \ 11#define EX(x,y) \
1198: x,y; \ 1298: x,y; \
12 .section .fixup; \
13 .align 4; \
1499: retl; \
15 mov 1, %o0; \
16 .section __ex_table,"a";\ 13 .section __ex_table,"a";\
17 .align 4; \ 14 .align 4; \
18 .word 98b, 99b; \ 15 .word 98b, __retl_one; \
19 .text; \ 16 .text; \
20 .align 4; 17 .align 4;
21 18
@@ -31,18 +28,7 @@
31 * to copy register windows around during thread cloning. 28 * to copy register windows around during thread cloning.
32 */ 29 */
33 30
34 .globl ___copy_in_user 31ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
35 .type ___copy_in_user,#function
36___copy_in_user: /* %o0=dst, %o1=src, %o2=len */
37 /* Writing to %asi is _expensive_ so we hardcode it.
38 * Reading %asi to check for KERNEL_DS is comparatively
39 * cheap.
40 */
41 rd %asi, %g1
42 cmp %g1, ASI_AIUS
43 bne,pn %icc, memcpy_user_stub
44 nop
45
46 cmp %o2, 0 32 cmp %o2, 0
47 be,pn %XCC, 85f 33 be,pn %XCC, 85f
48 or %o0, %o1, %o3 34 or %o0, %o1, %o3
@@ -53,22 +39,24 @@ ___copy_in_user: /* %o0=dst, %o1=src, %o2=len */
53 /* 16 < len <= 64 */ 39 /* 16 < len <= 64 */
54 andcc %o3, 0x7, %g0 40 andcc %o3, 0x7, %g0
55 bne,pn %XCC, 90f 41 bne,pn %XCC, 90f
56 sub %o0, %o1, %o3 42 nop
57 43
58 andn %o2, 0x7, %o4 44 andn %o2, 0x7, %o4
59 and %o2, 0x7, %o2 45 and %o2, 0x7, %o2
601: subcc %o4, 0x8, %o4 461: subcc %o4, 0x8, %o4
61 EX(ldxa [%o1] %asi, %o5) 47 EX(ldxa [%o1] %asi, %o5)
62 EX(stxa %o5, [%o1 + %o3] ASI_AIUS) 48 EX(stxa %o5, [%o0] %asi)
49 add %o1, 0x8, %o1
63 bgu,pt %XCC, 1b 50 bgu,pt %XCC, 1b
64 add %o1, 0x8, %o1 51 add %o0, 0x8, %o0
65 andcc %o2, 0x4, %g0 52 andcc %o2, 0x4, %g0
66 be,pt %XCC, 1f 53 be,pt %XCC, 1f
67 nop 54 nop
68 sub %o2, 0x4, %o2 55 sub %o2, 0x4, %o2
69 EX(lduwa [%o1] %asi, %o5) 56 EX(lduwa [%o1] %asi, %o5)
70 EX(stwa %o5, [%o1 + %o3] ASI_AIUS) 57 EX(stwa %o5, [%o0] %asi)
71 add %o1, 0x4, %o1 58 add %o1, 0x4, %o1
59 add %o0, 0x4, %o0
721: cmp %o2, 0 601: cmp %o2, 0
73 be,pt %XCC, 85f 61 be,pt %XCC, 85f
74 nop 62 nop
@@ -78,14 +66,15 @@ ___copy_in_user: /* %o0=dst, %o1=src, %o2=len */
7880: /* 0 < len <= 16 */ 6680: /* 0 < len <= 16 */
79 andcc %o3, 0x3, %g0 67 andcc %o3, 0x3, %g0
80 bne,pn %XCC, 90f 68 bne,pn %XCC, 90f
81 sub %o0, %o1, %o3 69 nop
82 70
8382: 7182:
84 subcc %o2, 4, %o2 72 subcc %o2, 4, %o2
85 EX(lduwa [%o1] %asi, %g1) 73 EX(lduwa [%o1] %asi, %g1)
86 EX(stwa %g1, [%o1 + %o3] ASI_AIUS) 74 EX(stwa %g1, [%o0] %asi)
75 add %o1, 4, %o1
87 bgu,pt %XCC, 82b 76 bgu,pt %XCC, 82b
88 add %o1, 4, %o1 77 add %o0, 4, %o0
89 78
9085: retl 7985: retl
91 clr %o0 80 clr %o0
@@ -94,26 +83,10 @@ ___copy_in_user: /* %o0=dst, %o1=src, %o2=len */
9490: 8390:
95 subcc %o2, 1, %o2 84 subcc %o2, 1, %o2
96 EX(lduba [%o1] %asi, %g1) 85 EX(lduba [%o1] %asi, %g1)
97 EX(stba %g1, [%o1 + %o3] ASI_AIUS) 86 EX(stba %g1, [%o0] %asi)
87 add %o1, 1, %o1
98 bgu,pt %XCC, 90b 88 bgu,pt %XCC, 90b
99 add %o1, 1, %o1 89 add %o0, 1, %o0
100 retl 90 retl
101 clr %o0 91 clr %o0
102 92ENDPROC(___copy_in_user)
103 .size ___copy_in_user, .-___copy_in_user
104
105 /* Act like copy_{to,in}_user(), ie. return zero instead
106 * of original destination pointer. This is invoked when
107 * copy_{to,in}_user() finds that %asi is kernel space.
108 */
109 .globl memcpy_user_stub
110 .type memcpy_user_stub,#function
111memcpy_user_stub:
112 save %sp, -192, %sp
113 mov %i0, %o0
114 mov %i1, %o1
115 call memcpy
116 mov %i2, %o2
117 ret
118 restore %g0, %g0, %o0
119 .size memcpy_user_stub, .-memcpy_user_stub
diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
index a9e474bf6385..4ab8993b0863 100644
--- a/arch/sparc/mm/fault_64.c
+++ b/arch/sparc/mm/fault_64.c
@@ -19,6 +19,7 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/kprobes.h> 20#include <linux/kprobes.h>
21#include <linux/kdebug.h> 21#include <linux/kdebug.h>
22#include <linux/percpu.h>
22 23
23#include <asm/page.h> 24#include <asm/page.h>
24#include <asm/pgtable.h> 25#include <asm/pgtable.h>
@@ -224,6 +225,30 @@ cannot_handle:
224 unhandled_fault (address, current, regs); 225 unhandled_fault (address, current, regs);
225} 226}
226 227
228static void noinline bogus_32bit_fault_tpc(struct pt_regs *regs)
229{
230 static int times;
231
232 if (times++ < 10)
233 printk(KERN_ERR "FAULT[%s:%d]: 32-bit process reports "
234 "64-bit TPC [%lx]\n",
235 current->comm, current->pid,
236 regs->tpc);
237 show_regs(regs);
238}
239
240static void noinline bogus_32bit_fault_address(struct pt_regs *regs,
241 unsigned long addr)
242{
243 static int times;
244
245 if (times++ < 10)
246 printk(KERN_ERR "FAULT[%s:%d]: 32-bit process "
247 "reports 64-bit fault address [%lx]\n",
248 current->comm, current->pid, addr);
249 show_regs(regs);
250}
251
227asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) 252asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
228{ 253{
229 struct mm_struct *mm = current->mm; 254 struct mm_struct *mm = current->mm;
@@ -244,6 +269,19 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
244 (fault_code & FAULT_CODE_DTLB)) 269 (fault_code & FAULT_CODE_DTLB))
245 BUG(); 270 BUG();
246 271
272 if (test_thread_flag(TIF_32BIT)) {
273 if (!(regs->tstate & TSTATE_PRIV)) {
274 if (unlikely((regs->tpc >> 32) != 0)) {
275 bogus_32bit_fault_tpc(regs);
276 goto intr_or_no_mm;
277 }
278 }
279 if (unlikely((address >> 32) != 0)) {
280 bogus_32bit_fault_address(regs, address);
281 goto intr_or_no_mm;
282 }
283 }
284
247 if (regs->tstate & TSTATE_PRIV) { 285 if (regs->tstate & TSTATE_PRIV) {
248 unsigned long tpc = regs->tpc; 286 unsigned long tpc = regs->tpc;
249 287
@@ -264,12 +302,6 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
264 if (in_atomic() || !mm) 302 if (in_atomic() || !mm)
265 goto intr_or_no_mm; 303 goto intr_or_no_mm;
266 304
267 if (test_thread_flag(TIF_32BIT)) {
268 if (!(regs->tstate & TSTATE_PRIV))
269 regs->tpc &= 0xffffffff;
270 address &= 0xffffffff;
271 }
272
273 if (!down_read_trylock(&mm->mmap_sem)) { 305 if (!down_read_trylock(&mm->mmap_sem)) {
274 if ((regs->tstate & TSTATE_PRIV) && 306 if ((regs->tstate & TSTATE_PRIV) &&
275 !search_exception_tables(regs->tpc)) { 307 !search_exception_tables(regs->tpc)) {
diff --git a/arch/sparc/oprofile/init.c b/arch/sparc/oprofile/init.c
index d6e170c074fc..d172f86439b1 100644
--- a/arch/sparc/oprofile/init.c
+++ b/arch/sparc/oprofile/init.c
@@ -13,217 +13,57 @@
13#include <linux/init.h> 13#include <linux/init.h>
14 14
15#ifdef CONFIG_SPARC64 15#ifdef CONFIG_SPARC64
16#include <asm/hypervisor.h> 16#include <linux/notifier.h>
17#include <asm/spitfire.h> 17#include <linux/rcupdate.h>
18#include <asm/cpudata.h> 18#include <linux/kdebug.h>
19#include <asm/irq.h> 19#include <asm/nmi.h>
20 20
21static int nmi_enabled; 21static int profile_timer_exceptions_notify(struct notifier_block *self,
22 22 unsigned long val, void *data)
23struct pcr_ops {
24 u64 (*read)(void);
25 void (*write)(u64);
26};
27static const struct pcr_ops *pcr_ops;
28
29static u64 direct_pcr_read(void)
30{
31 u64 val;
32
33 read_pcr(val);
34 return val;
35}
36
37static void direct_pcr_write(u64 val)
38{
39 write_pcr(val);
40}
41
42static const struct pcr_ops direct_pcr_ops = {
43 .read = direct_pcr_read,
44 .write = direct_pcr_write,
45};
46
47static void n2_pcr_write(u64 val)
48{ 23{
49 unsigned long ret; 24 struct die_args *args = (struct die_args *)data;
50 25 int ret = NOTIFY_DONE;
51 ret = sun4v_niagara2_setperf(HV_N2_PERF_SPARC_CTL, val);
52 if (val != HV_EOK)
53 write_pcr(val);
54}
55
56static const struct pcr_ops n2_pcr_ops = {
57 .read = direct_pcr_read,
58 .write = n2_pcr_write,
59};
60
61/* In order to commonize as much of the implementation as
62 * possible, we use PICH as our counter. Mostly this is
63 * to accomodate Niagara-1 which can only count insn cycles
64 * in PICH.
65 */
66static u64 picl_value(void)
67{
68 u32 delta = local_cpu_data().clock_tick / HZ;
69
70 return ((u64)((0 - delta) & 0xffffffff)) << 32;
71}
72
73#define PCR_PIC_PRIV 0x00000001 /* PIC access is privileged */
74#define PCR_STRACE 0x00000002 /* Trace supervisor events */
75#define PCR_UTRACE 0x00000004 /* Trace user events */
76#define PCR_N2_HTRACE 0x00000008 /* Trace hypervisor events */
77#define PCR_N2_TOE_OV0 0x00000010 /* Trap if PIC 0 overflows */
78#define PCR_N2_TOE_OV1 0x00000020 /* Trap if PIC 1 overflows */
79#define PCR_N2_MASK0 0x00003fc0
80#define PCR_N2_MASK0_SHIFT 6
81#define PCR_N2_SL0 0x0003c000
82#define PCR_N2_SL0_SHIFT 14
83#define PCR_N2_OV0 0x00040000
84#define PCR_N2_MASK1 0x07f80000
85#define PCR_N2_MASK1_SHIFT 19
86#define PCR_N2_SL1 0x78000000
87#define PCR_N2_SL1_SHIFT 27
88#define PCR_N2_OV1 0x80000000
89
90#define PCR_SUN4U_ENABLE (PCR_PIC_PRIV | PCR_STRACE | PCR_UTRACE)
91#define PCR_N2_ENABLE (PCR_PIC_PRIV | PCR_STRACE | PCR_UTRACE | \
92 PCR_N2_TOE_OV1 | \
93 (2 << PCR_N2_SL1_SHIFT) | \
94 (0xff << PCR_N2_MASK1_SHIFT))
95
96static u64 pcr_enable = PCR_SUN4U_ENABLE;
97
98static void nmi_handler(struct pt_regs *regs)
99{
100 pcr_ops->write(PCR_PIC_PRIV);
101
102 if (nmi_enabled) {
103 oprofile_add_sample(regs, 0);
104
105 write_pic(picl_value());
106 pcr_ops->write(pcr_enable);
107 }
108}
109
110/* We count "clock cycle" events in the lower 32-bit PIC.
111 * Then configure it such that it overflows every HZ, and thus
112 * generates a level 15 interrupt at that frequency.
113 */
114static void cpu_nmi_start(void *_unused)
115{
116 pcr_ops->write(PCR_PIC_PRIV);
117 write_pic(picl_value());
118
119 pcr_ops->write(pcr_enable);
120}
121 26
122static void cpu_nmi_stop(void *_unused) 27 switch (val) {
123{ 28 case DIE_NMI:
124 pcr_ops->write(PCR_PIC_PRIV); 29 oprofile_add_sample(args->regs, 0);
125} 30 ret = NOTIFY_STOP;
126 31 break;
127static int nmi_start(void) 32 default:
128{ 33 break;
129 int err = register_perfctr_intr(nmi_handler);
130
131 if (!err) {
132 nmi_enabled = 1;
133 wmb();
134 err = on_each_cpu(cpu_nmi_start, NULL, 1);
135 if (err) {
136 nmi_enabled = 0;
137 wmb();
138 on_each_cpu(cpu_nmi_stop, NULL, 1);
139 release_perfctr_intr(nmi_handler);
140 }
141 } 34 }
142 35 return ret;
143 return err;
144}
145
146static void nmi_stop(void)
147{
148 nmi_enabled = 0;
149 wmb();
150
151 on_each_cpu(cpu_nmi_stop, NULL, 1);
152 release_perfctr_intr(nmi_handler);
153 synchronize_sched();
154} 36}
155 37
156static unsigned long perf_hsvc_group; 38static struct notifier_block profile_timer_exceptions_nb = {
157static unsigned long perf_hsvc_major; 39 .notifier_call = profile_timer_exceptions_notify,
158static unsigned long perf_hsvc_minor; 40};
159 41
160static int __init register_perf_hsvc(void) 42static int timer_start(void)
161{ 43{
162 if (tlb_type == hypervisor) { 44 if (register_die_notifier(&profile_timer_exceptions_nb))
163 switch (sun4v_chip_type) { 45 return 1;
164 case SUN4V_CHIP_NIAGARA1: 46 nmi_adjust_hz(HZ);
165 perf_hsvc_group = HV_GRP_NIAG_PERF;
166 break;
167
168 case SUN4V_CHIP_NIAGARA2:
169 perf_hsvc_group = HV_GRP_N2_CPU;
170 break;
171
172 default:
173 return -ENODEV;
174 }
175
176
177 perf_hsvc_major = 1;
178 perf_hsvc_minor = 0;
179 if (sun4v_hvapi_register(perf_hsvc_group,
180 perf_hsvc_major,
181 &perf_hsvc_minor)) {
182 printk("perfmon: Could not register N2 hvapi.\n");
183 return -ENODEV;
184 }
185 }
186 return 0; 47 return 0;
187} 48}
188 49
189static void unregister_perf_hsvc(void) 50
51static void timer_stop(void)
190{ 52{
191 if (tlb_type != hypervisor) 53 nmi_adjust_hz(1);
192 return; 54 unregister_die_notifier(&profile_timer_exceptions_nb);
193 sun4v_hvapi_unregister(perf_hsvc_group); 55 synchronize_sched(); /* Allow already-started NMIs to complete. */
194} 56}
195 57
196static int oprofile_nmi_init(struct oprofile_operations *ops) 58static int op_nmi_timer_init(struct oprofile_operations *ops)
197{ 59{
198 int err = register_perf_hsvc(); 60 if (!nmi_usable)
199
200 if (err)
201 return err;
202
203 switch (tlb_type) {
204 case hypervisor:
205 pcr_ops = &n2_pcr_ops;
206 pcr_enable = PCR_N2_ENABLE;
207 break;
208
209 case cheetah:
210 case cheetah_plus:
211 pcr_ops = &direct_pcr_ops;
212 break;
213
214 default:
215 return -ENODEV; 61 return -ENODEV;
216 }
217 62
218 ops->create_files = NULL; 63 ops->start = timer_start;
219 ops->setup = NULL; 64 ops->stop = timer_stop;
220 ops->shutdown = NULL;
221 ops->start = nmi_start;
222 ops->stop = nmi_stop;
223 ops->cpu_type = "timer"; 65 ops->cpu_type = "timer";
224 66 printk(KERN_INFO "oprofile: Using perfctr NMI timer interrupt.\n");
225 printk(KERN_INFO "oprofile: Using perfctr based NMI timer interrupt.\n");
226
227 return 0; 67 return 0;
228} 68}
229#endif 69#endif
@@ -233,7 +73,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
233 int ret = -ENODEV; 73 int ret = -ENODEV;
234 74
235#ifdef CONFIG_SPARC64 75#ifdef CONFIG_SPARC64
236 ret = oprofile_nmi_init(ops); 76 ret = op_nmi_timer_init(ops);
237 if (!ret) 77 if (!ret)
238 return ret; 78 return ret;
239#endif 79#endif
@@ -241,10 +81,6 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
241 return ret; 81 return ret;
242} 82}
243 83
244
245void oprofile_arch_exit(void) 84void oprofile_arch_exit(void)
246{ 85{
247#ifdef CONFIG_SPARC64
248 unregister_perf_hsvc();
249#endif
250} 86}
diff --git a/arch/um/drivers/vde_user.c b/arch/um/drivers/vde_user.c
index 56533db25343..c5c43253e6ce 100644
--- a/arch/um/drivers/vde_user.c
+++ b/arch/um/drivers/vde_user.c
@@ -78,7 +78,7 @@ void vde_init_libstuff(struct vde_data *vpri, struct vde_init *init)
78{ 78{
79 struct vde_open_args *args; 79 struct vde_open_args *args;
80 80
81 vpri->args = kmalloc(sizeof(struct vde_open_args), UM_GFP_KERNEL); 81 vpri->args = uml_kmalloc(sizeof(struct vde_open_args), UM_GFP_KERNEL);
82 if (vpri->args == NULL) { 82 if (vpri->args == NULL) {
83 printk(UM_KERN_ERR "vde_init_libstuff - vde_open_args " 83 printk(UM_KERN_ERR "vde_init_libstuff - vde_open_args "
84 "allocation failed"); 84 "allocation failed");
@@ -91,8 +91,8 @@ void vde_init_libstuff(struct vde_data *vpri, struct vde_init *init)
91 args->group = init->group; 91 args->group = init->group;
92 args->mode = init->mode ? init->mode : 0700; 92 args->mode = init->mode ? init->mode : 0700;
93 93
94 args->port ? printk(UM_KERN_INFO "port %d", args->port) : 94 args->port ? printk("port %d", args->port) :
95 printk(UM_KERN_INFO "undefined port"); 95 printk("undefined port");
96} 96}
97 97
98int vde_user_read(void *conn, void *buf, int len) 98int vde_user_read(void *conn, void *buf, int len)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 73f7fe8fd4d1..9c39095b33fc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1802,6 +1802,17 @@ config DMAR
1802 and include PCI device scope covered by these DMA 1802 and include PCI device scope covered by these DMA
1803 remapping devices. 1803 remapping devices.
1804 1804
1805config DMAR_DEFAULT_ON
1806 def_bool n
1807 prompt "Enable DMA Remapping Devices by default"
1808 depends on DMAR
1809 help
1810 Selecting this option will enable a DMAR device at boot time if
1811 one is found. If this option is not selected, DMAR support can
1812 be enabled by passing intel_iommu=on to the kernel. It is
1813 recommended you say N here while the DMAR code remains
1814 experimental.
1815
1805config DMAR_GFX_WA 1816config DMAR_GFX_WA
1806 def_bool y 1817 def_bool y
1807 prompt "Support for Graphics workaround" 1818 prompt "Support for Graphics workaround"
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 8078955845ae..c98d52e82966 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -167,9 +167,9 @@ config MK7
167config MK8 167config MK8
168 bool "Opteron/Athlon64/Hammer/K8" 168 bool "Opteron/Athlon64/Hammer/K8"
169 help 169 help
170 Select this for an AMD Opteron or Athlon64 Hammer-family processor. Enables 170 Select this for an AMD Opteron or Athlon64 Hammer-family processor.
171 use of some extended instructions, and passes appropriate optimization 171 Enables use of some extended instructions, and passes appropriate
172 flags to GCC. 172 optimization flags to GCC.
173 173
174config MCRUSOE 174config MCRUSOE
175 bool "Crusoe" 175 bool "Crusoe"
@@ -256,9 +256,11 @@ config MPSC
256config MCORE2 256config MCORE2
257 bool "Core 2/newer Xeon" 257 bool "Core 2/newer Xeon"
258 help 258 help
259 Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and 53xx) 259
260 CPUs. You can distinguish newer from older Xeons by the CPU family 260 Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
261 in /proc/cpuinfo. Newer ones have 6 and older ones 15 (not a typo) 261 53xx) CPUs. You can distinguish newer from older Xeons by the CPU
262 family in /proc/cpuinfo. Newer ones have 6 and older ones 15
263 (not a typo)
262 264
263config GENERIC_CPU 265config GENERIC_CPU
264 bool "Generic-x86-64" 266 bool "Generic-x86-64"
@@ -320,14 +322,14 @@ config X86_PPRO_FENCE
320 bool "PentiumPro memory ordering errata workaround" 322 bool "PentiumPro memory ordering errata workaround"
321 depends on M686 || M586MMX || M586TSC || M586 || M486 || M386 || MGEODEGX1 323 depends on M686 || M586MMX || M586TSC || M586 || M486 || M386 || MGEODEGX1
322 help 324 help
323 Old PentiumPro multiprocessor systems had errata that could cause memory 325 Old PentiumPro multiprocessor systems had errata that could cause
324 operations to violate the x86 ordering standard in rare cases. Enabling this 326 memory operations to violate the x86 ordering standard in rare cases.
325 option will attempt to work around some (but not all) occurances of 327 Enabling this option will attempt to work around some (but not all)
326 this problem, at the cost of much heavier spinlock and memory barrier 328 occurances of this problem, at the cost of much heavier spinlock and
327 operations. 329 memory barrier operations.
328 330
329 If unsure, say n here. Even distro kernels should think twice before enabling 331 If unsure, say n here. Even distro kernels should think twice before
330 this: there are few systems, and an unlikely bug. 332 enabling this: there are few systems, and an unlikely bug.
331 333
332config X86_F00F_BUG 334config X86_F00F_BUG
333 def_bool y 335 def_bool y
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 10d6cc3fd052..e1983fa025d2 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -174,28 +174,8 @@ config IOMMU_LEAK
174 Add a simple leak tracer to the IOMMU code. This is useful when you 174 Add a simple leak tracer to the IOMMU code. This is useful when you
175 are debugging a buggy device driver that leaks IOMMU mappings. 175 are debugging a buggy device driver that leaks IOMMU mappings.
176 176
177config MMIOTRACE 177config HAVE_MMIOTRACE_SUPPORT
178 bool "Memory mapped IO tracing" 178 def_bool y
179 depends on DEBUG_KERNEL && PCI
180 select TRACING
181 help
182 Mmiotrace traces Memory Mapped I/O access and is meant for
183 debugging and reverse engineering. It is called from the ioremap
184 implementation and works via page faults. Tracing is disabled by
185 default and can be enabled at run-time.
186
187 See Documentation/tracers/mmiotrace.txt.
188 If you are not helping to develop drivers, say N.
189
190config MMIOTRACE_TEST
191 tristate "Test module for mmiotrace"
192 depends on MMIOTRACE && m
193 help
194 This is a dumb module for testing mmiotrace. It is very dangerous
195 as it will write garbage to IO memory starting at a given address.
196 However, it should be safe to use on e.g. unused portion of VRAM.
197
198 Say N, unless you absolutely know what you are doing.
199 179
200# 180#
201# IO delay types: 181# IO delay types:
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 256b00b61892..5a0d76dc56a4 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -418,9 +418,9 @@ ENTRY(ia32_syscall)
418 orl $TS_COMPAT,TI_status(%r10) 418 orl $TS_COMPAT,TI_status(%r10)
419 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10) 419 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r10)
420 jnz ia32_tracesys 420 jnz ia32_tracesys
421ia32_do_syscall:
422 cmpl $(IA32_NR_syscalls-1),%eax 421 cmpl $(IA32_NR_syscalls-1),%eax
423 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */ 422 ja ia32_badsys
423ia32_do_call:
424 IA32_ARG_FIXUP 424 IA32_ARG_FIXUP
425 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative 425 call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
426ia32_sysret: 426ia32_sysret:
@@ -435,7 +435,9 @@ ia32_tracesys:
435 call syscall_trace_enter 435 call syscall_trace_enter
436 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */ 436 LOAD_ARGS32 ARGOFFSET /* reload args from stack in case ptrace changed it */
437 RESTORE_REST 437 RESTORE_REST
438 jmp ia32_do_syscall 438 cmpl $(IA32_NR_syscalls-1),%eax
439 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
440 jmp ia32_do_call
439END(ia32_syscall) 441END(ia32_syscall)
440 442
441ia32_badsys: 443ia32_badsys:
diff --git a/arch/x86/include/asm/a.out-core.h b/arch/x86/include/asm/a.out-core.h
index 37822206083e..3c601f8224be 100644
--- a/arch/x86/include/asm/a.out-core.h
+++ b/arch/x86/include/asm/a.out-core.h
@@ -23,8 +23,6 @@
23 */ 23 */
24static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump) 24static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
25{ 25{
26 u16 gs;
27
28/* changed the size calculations - should hopefully work better. lbt */ 26/* changed the size calculations - should hopefully work better. lbt */
29 dump->magic = CMAGIC; 27 dump->magic = CMAGIC;
30 dump->start_code = 0; 28 dump->start_code = 0;
@@ -57,7 +55,7 @@ static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
57 dump->regs.ds = (u16)regs->ds; 55 dump->regs.ds = (u16)regs->ds;
58 dump->regs.es = (u16)regs->es; 56 dump->regs.es = (u16)regs->es;
59 dump->regs.fs = (u16)regs->fs; 57 dump->regs.fs = (u16)regs->fs;
60 savesegment(gs, gs); 58 savesegment(gs, dump->regs.gs);
61 dump->regs.orig_ax = regs->orig_ax; 59 dump->regs.orig_ax = regs->orig_ax;
62 dump->regs.ip = regs->ip; 60 dump->regs.ip = regs->ip;
63 dump->regs.cs = (u16)regs->cs; 61 dump->regs.cs = (u16)regs->cs;
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index ea408dcba513..7301e60dc4a8 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -93,6 +93,7 @@
93#define X86_FEATURE_XTOPOLOGY (3*32+22) /* cpu topology enum extensions */ 93#define X86_FEATURE_XTOPOLOGY (3*32+22) /* cpu topology enum extensions */
94#define X86_FEATURE_TSC_RELIABLE (3*32+23) /* TSC is known to be reliable */ 94#define X86_FEATURE_TSC_RELIABLE (3*32+23) /* TSC is known to be reliable */
95#define X86_FEATURE_NONSTOP_TSC (3*32+24) /* TSC does not stop in C states */ 95#define X86_FEATURE_NONSTOP_TSC (3*32+24) /* TSC does not stop in C states */
96#define X86_FEATURE_CLFLUSH_MONITOR (3*32+25) /* "" clflush reqd with monitor */
96 97
97/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ 98/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
98#define X86_FEATURE_XMM3 (4*32+ 0) /* "pni" SSE-3 */ 99#define X86_FEATURE_XMM3 (4*32+ 0) /* "pni" SSE-3 */
diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
index d2e3bf3608af..886c9402ec45 100644
--- a/arch/x86/include/asm/kvm.h
+++ b/arch/x86/include/asm/kvm.h
@@ -9,6 +9,13 @@
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/ioctl.h> 10#include <linux/ioctl.h>
11 11
12/* Select x86 specific features in <linux/kvm.h> */
13#define __KVM_HAVE_PIT
14#define __KVM_HAVE_IOAPIC
15#define __KVM_HAVE_DEVICE_ASSIGNMENT
16#define __KVM_HAVE_MSI
17#define __KVM_HAVE_USER_NMI
18
12/* Architectural interrupt line count. */ 19/* Architectural interrupt line count. */
13#define KVM_NR_INTERRUPTS 256 20#define KVM_NR_INTERRUPTS 256
14 21
diff --git a/arch/x86/include/asm/math_emu.h b/arch/x86/include/asm/math_emu.h
index 5a65b107ad58..031f6266f425 100644
--- a/arch/x86/include/asm/math_emu.h
+++ b/arch/x86/include/asm/math_emu.h
@@ -1,31 +1,18 @@
1#ifndef _ASM_X86_MATH_EMU_H 1#ifndef _ASM_X86_MATH_EMU_H
2#define _ASM_X86_MATH_EMU_H 2#define _ASM_X86_MATH_EMU_H
3 3
4#include <asm/ptrace.h>
5#include <asm/vm86.h>
6
4/* This structure matches the layout of the data saved to the stack 7/* This structure matches the layout of the data saved to the stack
5 following a device-not-present interrupt, part of it saved 8 following a device-not-present interrupt, part of it saved
6 automatically by the 80386/80486. 9 automatically by the 80386/80486.
7 */ 10 */
8struct info { 11struct math_emu_info {
9 long ___orig_eip; 12 long ___orig_eip;
10 long ___ebx; 13 union {
11 long ___ecx; 14 struct pt_regs *regs;
12 long ___edx; 15 struct kernel_vm86_regs *vm86;
13 long ___esi; 16 };
14 long ___edi;
15 long ___ebp;
16 long ___eax;
17 long ___ds;
18 long ___es;
19 long ___fs;
20 long ___orig_eax;
21 long ___eip;
22 long ___cs;
23 long ___eflags;
24 long ___esp;
25 long ___ss;
26 long ___vm86_es; /* This and the following only in vm86 mode */
27 long ___vm86_ds;
28 long ___vm86_fs;
29 long ___vm86_gs;
30}; 17};
31#endif /* _ASM_X86_MATH_EMU_H */ 18#endif /* _ASM_X86_MATH_EMU_H */
diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
index 07f1af494ca5..105fb90a0635 100644
--- a/arch/x86/include/asm/mmzone_32.h
+++ b/arch/x86/include/asm/mmzone_32.h
@@ -32,8 +32,6 @@ static inline void get_memcfg_numa(void)
32 get_memcfg_numa_flat(); 32 get_memcfg_numa_flat();
33} 33}
34 34
35extern int early_pfn_to_nid(unsigned long pfn);
36
37extern void resume_map_numa_kva(pgd_t *pgd); 35extern void resume_map_numa_kva(pgd_t *pgd);
38 36
39#else /* !CONFIG_NUMA */ 37#else /* !CONFIG_NUMA */
diff --git a/arch/x86/include/asm/mmzone_64.h b/arch/x86/include/asm/mmzone_64.h
index a5b3817d4b9e..a29f48c2a322 100644
--- a/arch/x86/include/asm/mmzone_64.h
+++ b/arch/x86/include/asm/mmzone_64.h
@@ -40,8 +40,6 @@ static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
40#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ 40#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
41 NODE_DATA(nid)->node_spanned_pages) 41 NODE_DATA(nid)->node_spanned_pages)
42 42
43extern int early_pfn_to_nid(unsigned long pfn);
44
45#ifdef CONFIG_NUMA_EMU 43#ifdef CONFIG_NUMA_EMU
46#define FAKE_NODE_MIN_SIZE (64 * 1024 * 1024) 44#define FAKE_NODE_MIN_SIZE (64 * 1024 * 1024)
47#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL)) 45#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL))
diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h
index 62d14ce3cd00..bd22f2a3713f 100644
--- a/arch/x86/include/asm/mpspec.h
+++ b/arch/x86/include/asm/mpspec.h
@@ -60,6 +60,7 @@ extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
60 u32 gsi); 60 u32 gsi);
61extern void mp_config_acpi_legacy_irqs(void); 61extern void mp_config_acpi_legacy_irqs(void);
62extern int mp_register_gsi(u32 gsi, int edge_level, int active_high_low); 62extern int mp_register_gsi(u32 gsi, int edge_level, int active_high_low);
63extern int acpi_probe_gsi(void);
63#ifdef CONFIG_X86_IO_APIC 64#ifdef CONFIG_X86_IO_APIC
64extern int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin, 65extern int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
65 u32 gsi, int triggering, int polarity); 66 u32 gsi, int triggering, int polarity);
@@ -71,6 +72,11 @@ mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
71 return 0; 72 return 0;
72} 73}
73#endif 74#endif
75#else /* !CONFIG_ACPI: */
76static inline int acpi_probe_gsi(void)
77{
78 return 0;
79}
74#endif /* CONFIG_ACPI */ 80#endif /* CONFIG_ACPI */
75 81
76#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS) 82#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS)
diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
index e9873a2e8695..776579119a00 100644
--- a/arch/x86/include/asm/page.h
+++ b/arch/x86/include/asm/page.h
@@ -57,7 +57,6 @@ typedef struct { pgdval_t pgd; } pgd_t;
57typedef struct { pgprotval_t pgprot; } pgprot_t; 57typedef struct { pgprotval_t pgprot; } pgprot_t;
58 58
59extern int page_is_ram(unsigned long pagenr); 59extern int page_is_ram(unsigned long pagenr);
60extern int pagerange_is_ram(unsigned long start, unsigned long end);
61extern int devmem_is_allowed(unsigned long pagenr); 60extern int devmem_is_allowed(unsigned long pagenr);
62extern void map_devmem(unsigned long pfn, unsigned long size, 61extern void map_devmem(unsigned long pfn, unsigned long size,
63 pgprot_t vma_prot); 62 pgprot_t vma_prot);
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index ba3e2ff6aedc..e299287e8e33 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -1352,14 +1352,7 @@ static inline void arch_leave_lazy_cpu_mode(void)
1352 PVOP_VCALL0(pv_cpu_ops.lazy_mode.leave); 1352 PVOP_VCALL0(pv_cpu_ops.lazy_mode.leave);
1353} 1353}
1354 1354
1355static inline void arch_flush_lazy_cpu_mode(void) 1355void arch_flush_lazy_cpu_mode(void);
1356{
1357 if (unlikely(paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU)) {
1358 arch_leave_lazy_cpu_mode();
1359 arch_enter_lazy_cpu_mode();
1360 }
1361}
1362
1363 1356
1364#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE 1357#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
1365static inline void arch_enter_lazy_mmu_mode(void) 1358static inline void arch_enter_lazy_mmu_mode(void)
@@ -1372,13 +1365,7 @@ static inline void arch_leave_lazy_mmu_mode(void)
1372 PVOP_VCALL0(pv_mmu_ops.lazy_mode.leave); 1365 PVOP_VCALL0(pv_mmu_ops.lazy_mode.leave);
1373} 1366}
1374 1367
1375static inline void arch_flush_lazy_mmu_mode(void) 1368void arch_flush_lazy_mmu_mode(void);
1376{
1377 if (unlikely(paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU)) {
1378 arch_leave_lazy_mmu_mode();
1379 arch_enter_lazy_mmu_mode();
1380 }
1381}
1382 1369
1383static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx, 1370static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
1384 unsigned long phys, pgprot_t flags) 1371 unsigned long phys, pgprot_t flags)
@@ -1402,6 +1389,7 @@ static inline int __raw_spin_is_contended(struct raw_spinlock *lock)
1402{ 1389{
1403 return PVOP_CALL1(int, pv_lock_ops.spin_is_contended, lock); 1390 return PVOP_CALL1(int, pv_lock_ops.spin_is_contended, lock);
1404} 1391}
1392#define __raw_spin_is_contended __raw_spin_is_contended
1405 1393
1406static __always_inline void __raw_spin_lock(struct raw_spinlock *lock) 1394static __always_inline void __raw_spin_lock(struct raw_spinlock *lock)
1407{ 1395{
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 06bbcbd66e9c..4f5af8447d54 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -302,16 +302,30 @@ static inline pte_t pte_mkspecial(pte_t pte)
302 302
303extern pteval_t __supported_pte_mask; 303extern pteval_t __supported_pte_mask;
304 304
305/*
306 * Mask out unsupported bits in a present pgprot. Non-present pgprots
307 * can use those bits for other purposes, so leave them be.
308 */
309static inline pgprotval_t massage_pgprot(pgprot_t pgprot)
310{
311 pgprotval_t protval = pgprot_val(pgprot);
312
313 if (protval & _PAGE_PRESENT)
314 protval &= __supported_pte_mask;
315
316 return protval;
317}
318
305static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) 319static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
306{ 320{
307 return __pte((((phys_addr_t)page_nr << PAGE_SHIFT) | 321 return __pte(((phys_addr_t)page_nr << PAGE_SHIFT) |
308 pgprot_val(pgprot)) & __supported_pte_mask); 322 massage_pgprot(pgprot));
309} 323}
310 324
311static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) 325static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
312{ 326{
313 return __pmd((((phys_addr_t)page_nr << PAGE_SHIFT) | 327 return __pmd(((phys_addr_t)page_nr << PAGE_SHIFT) |
314 pgprot_val(pgprot)) & __supported_pte_mask); 328 massage_pgprot(pgprot));
315} 329}
316 330
317static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 331static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
@@ -323,7 +337,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
323 * the newprot (if present): 337 * the newprot (if present):
324 */ 338 */
325 val &= _PAGE_CHG_MASK; 339 val &= _PAGE_CHG_MASK;
326 val |= pgprot_val(newprot) & (~_PAGE_CHG_MASK) & __supported_pte_mask; 340 val |= massage_pgprot(newprot) & ~_PAGE_CHG_MASK;
327 341
328 return __pte(val); 342 return __pte(val);
329} 343}
@@ -339,7 +353,7 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
339 353
340#define pte_pgprot(x) __pgprot(pte_flags(x) & PTE_FLAGS_MASK) 354#define pte_pgprot(x) __pgprot(pte_flags(x) & PTE_FLAGS_MASK)
341 355
342#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) 356#define canon_pgprot(p) __pgprot(massage_pgprot(p))
343 357
344static inline int is_new_memtype_allowed(unsigned long flags, 358static inline int is_new_memtype_allowed(unsigned long flags,
345 unsigned long new_flags) 359 unsigned long new_flags)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 091cd8855f2e..3bfd5235a9eb 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -353,7 +353,7 @@ struct i387_soft_struct {
353 u8 no_update; 353 u8 no_update;
354 u8 rm; 354 u8 rm;
355 u8 alimit; 355 u8 alimit;
356 struct info *info; 356 struct math_emu_info *info;
357 u32 entry_eip; 357 u32 entry_eip;
358}; 358};
359 359
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index d17c91981da2..8247e94ac6b1 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -245,6 +245,7 @@ static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
245{ 245{
246 return __ticket_spin_is_contended(lock); 246 return __ticket_spin_is_contended(lock);
247} 247}
248#define __raw_spin_is_contended __raw_spin_is_contended
248 249
249static __always_inline void __raw_spin_lock(raw_spinlock_t *lock) 250static __always_inline void __raw_spin_lock(raw_spinlock_t *lock)
250{ 251{
diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
index 2ee0a3bceedf..cf3bb053da0b 100644
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -41,7 +41,7 @@ dotraplinkage void do_int3(struct pt_regs *, long);
41dotraplinkage void do_overflow(struct pt_regs *, long); 41dotraplinkage void do_overflow(struct pt_regs *, long);
42dotraplinkage void do_bounds(struct pt_regs *, long); 42dotraplinkage void do_bounds(struct pt_regs *, long);
43dotraplinkage void do_invalid_op(struct pt_regs *, long); 43dotraplinkage void do_invalid_op(struct pt_regs *, long);
44dotraplinkage void do_device_not_available(struct pt_regs *, long); 44dotraplinkage void do_device_not_available(struct pt_regs);
45dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long); 45dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long);
46dotraplinkage void do_invalid_TSS(struct pt_regs *, long); 46dotraplinkage void do_invalid_TSS(struct pt_regs *, long);
47dotraplinkage void do_segment_not_present(struct pt_regs *, long); 47dotraplinkage void do_segment_not_present(struct pt_regs *, long);
@@ -77,7 +77,7 @@ extern int panic_on_unrecovered_nmi;
77extern int kstack_depth_to_print; 77extern int kstack_depth_to_print;
78 78
79void math_error(void __user *); 79void math_error(void __user *);
80asmlinkage void math_emulate(long); 80void math_emulate(struct math_emu_info *);
81#ifdef CONFIG_X86_32 81#ifdef CONFIG_X86_32
82unsigned long patch_espfix_desc(unsigned long, unsigned long); 82unsigned long patch_espfix_desc(unsigned long, unsigned long);
83#else 83#else
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index 7ef617ef1df3..4bd990ee43df 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -137,7 +137,7 @@ static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot)
137 pte_t pte; 137 pte_t pte;
138 138
139 pte.pte = ((phys_addr_t)page_nr << PAGE_SHIFT) | 139 pte.pte = ((phys_addr_t)page_nr << PAGE_SHIFT) |
140 (pgprot_val(pgprot) & __supported_pte_mask); 140 massage_pgprot(pgprot);
141 141
142 return pte; 142 return pte;
143} 143}
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index d37593c2f438..7678f10c4568 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -973,6 +973,29 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
973 nr_ioapics++; 973 nr_ioapics++;
974} 974}
975 975
976int __init acpi_probe_gsi(void)
977{
978 int idx;
979 int gsi;
980 int max_gsi = 0;
981
982 if (acpi_disabled)
983 return 0;
984
985 if (!acpi_ioapic)
986 return 0;
987
988 max_gsi = 0;
989 for (idx = 0; idx < nr_ioapics; idx++) {
990 gsi = mp_ioapic_routing[idx].gsi_end;
991
992 if (gsi > max_gsi)
993 max_gsi = gsi;
994 }
995
996 return max_gsi + 1;
997}
998
976static void assign_to_mp_irq(struct mp_config_intsrc *m, 999static void assign_to_mp_irq(struct mp_config_intsrc *m,
977 struct mp_config_intsrc *mp_irq) 1000 struct mp_config_intsrc *mp_irq)
978{ 1001{
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index 707c1f6f95fa..a60c1f3bcb87 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -156,11 +156,11 @@ static int __init acpi_sleep_setup(char *str)
156#ifdef CONFIG_HIBERNATION 156#ifdef CONFIG_HIBERNATION
157 if (strncmp(str, "s4_nohwsig", 10) == 0) 157 if (strncmp(str, "s4_nohwsig", 10) == 0)
158 acpi_no_s4_hw_signature(); 158 acpi_no_s4_hw_signature();
159 if (strncmp(str, "s4_nonvs", 8) == 0)
160 acpi_s4_no_nvs();
159#endif 161#endif
160 if (strncmp(str, "old_ordering", 12) == 0) 162 if (strncmp(str, "old_ordering", 12) == 0)
161 acpi_old_suspend_ordering(); 163 acpi_old_suspend_ordering();
162 if (strncmp(str, "s4_nonvs", 8) == 0)
163 acpi_s4_no_nvs();
164 str = strchr(str, ','); 164 str = strchr(str, ',');
165 if (str != NULL) 165 if (str != NULL)
166 str += strspn(str, ", \t"); 166 str += strspn(str, ", \t");
diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
index bcc293423a70..96258d9dc974 100644
--- a/arch/x86/kernel/acpi/wakeup_64.S
+++ b/arch/x86/kernel/acpi/wakeup_64.S
@@ -13,7 +13,6 @@
13 * Hooray, we are in Long 64-bit mode (but still running in low memory) 13 * Hooray, we are in Long 64-bit mode (but still running in low memory)
14 */ 14 */
15ENTRY(wakeup_long64) 15ENTRY(wakeup_long64)
16wakeup_long64:
17 movq saved_magic, %rax 16 movq saved_magic, %rax
18 movq $0x123456789abcdef0, %rdx 17 movq $0x123456789abcdef0, %rdx
19 cmpq %rdx, %rax 18 cmpq %rdx, %rax
@@ -34,16 +33,12 @@ wakeup_long64:
34 33
35 movq saved_rip, %rax 34 movq saved_rip, %rax
36 jmp *%rax 35 jmp *%rax
36ENDPROC(wakeup_long64)
37 37
38bogus_64_magic: 38bogus_64_magic:
39 jmp bogus_64_magic 39 jmp bogus_64_magic
40 40
41 .align 2 41ENTRY(do_suspend_lowlevel)
42 .p2align 4,,15
43.globl do_suspend_lowlevel
44 .type do_suspend_lowlevel,@function
45do_suspend_lowlevel:
46.LFB5:
47 subq $8, %rsp 42 subq $8, %rsp
48 xorl %eax, %eax 43 xorl %eax, %eax
49 call save_processor_state 44 call save_processor_state
@@ -67,7 +62,7 @@ do_suspend_lowlevel:
67 pushfq 62 pushfq
68 popq pt_regs_flags(%rax) 63 popq pt_regs_flags(%rax)
69 64
70 movq $.L97, saved_rip(%rip) 65 movq $resume_point, saved_rip(%rip)
71 66
72 movq %rsp, saved_rsp 67 movq %rsp, saved_rsp
73 movq %rbp, saved_rbp 68 movq %rbp, saved_rbp
@@ -78,14 +73,12 @@ do_suspend_lowlevel:
78 addq $8, %rsp 73 addq $8, %rsp
79 movl $3, %edi 74 movl $3, %edi
80 xorl %eax, %eax 75 xorl %eax, %eax
81 jmp acpi_enter_sleep_state 76 call acpi_enter_sleep_state
82.L97: 77 /* in case something went wrong, restore the machine status and go on */
83 .p2align 4,,7 78 jmp resume_point
84.L99:
85 .align 4
86 movl $24, %eax
87 movw %ax, %ds
88 79
80 .align 4
81resume_point:
89 /* We don't restore %rax, it must be 0 anyway */ 82 /* We don't restore %rax, it must be 0 anyway */
90 movq $saved_context, %rax 83 movq $saved_context, %rax
91 movq saved_context_cr4(%rax), %rbx 84 movq saved_context_cr4(%rax), %rbx
@@ -117,12 +110,9 @@ do_suspend_lowlevel:
117 xorl %eax, %eax 110 xorl %eax, %eax
118 addq $8, %rsp 111 addq $8, %rsp
119 jmp restore_processor_state 112 jmp restore_processor_state
120.LFE5: 113ENDPROC(do_suspend_lowlevel)
121.Lfe5: 114
122 .size do_suspend_lowlevel, .Lfe5-do_suspend_lowlevel
123
124.data 115.data
125ALIGN
126ENTRY(saved_rbp) .quad 0 116ENTRY(saved_rbp) .quad 0
127ENTRY(saved_rsi) .quad 0 117ENTRY(saved_rsi) .quad 0
128ENTRY(saved_rdi) .quad 0 118ENTRY(saved_rdi) .quad 0
diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c
index 4b6df2469fe3..570f36e44e59 100644
--- a/arch/x86/kernel/apic.c
+++ b/arch/x86/kernel/apic.c
@@ -862,7 +862,7 @@ void clear_local_APIC(void)
862 } 862 }
863 863
864 /* lets not touch this if we didn't frob it */ 864 /* lets not touch this if we didn't frob it */
865#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(X86_MCE_INTEL) 865#if defined(CONFIG_X86_MCE_P4THERMAL) || defined(CONFIG_X86_MCE_INTEL)
866 if (maxlvt >= 5) { 866 if (maxlvt >= 5) {
867 v = apic_read(APIC_LVTTHMR); 867 v = apic_read(APIC_LVTTHMR);
868 apic_write(APIC_LVTTHMR, v | APIC_LVT_MASKED); 868 apic_write(APIC_LVTTHMR, v | APIC_LVT_MASKED);
@@ -1436,7 +1436,7 @@ static int __init detect_init_APIC(void)
1436 switch (boot_cpu_data.x86_vendor) { 1436 switch (boot_cpu_data.x86_vendor) {
1437 case X86_VENDOR_AMD: 1437 case X86_VENDOR_AMD:
1438 if ((boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model > 1) || 1438 if ((boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model > 1) ||
1439 (boot_cpu_data.x86 == 15)) 1439 (boot_cpu_data.x86 >= 15))
1440 break; 1440 break;
1441 goto no_apic; 1441 goto no_apic;
1442 case X86_VENDOR_INTEL: 1442 case X86_VENDOR_INTEL:
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 98807bb095ad..266ec6c18b6c 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -1192,6 +1192,7 @@ static int suspend(int vetoable)
1192 device_suspend(PMSG_SUSPEND); 1192 device_suspend(PMSG_SUSPEND);
1193 local_irq_disable(); 1193 local_irq_disable();
1194 device_power_down(PMSG_SUSPEND); 1194 device_power_down(PMSG_SUSPEND);
1195 sysdev_suspend(PMSG_SUSPEND);
1195 1196
1196 local_irq_enable(); 1197 local_irq_enable();
1197 1198
@@ -1208,6 +1209,7 @@ static int suspend(int vetoable)
1208 if (err != APM_SUCCESS) 1209 if (err != APM_SUCCESS)
1209 apm_error("suspend", err); 1210 apm_error("suspend", err);
1210 err = (err == APM_SUCCESS) ? 0 : -EIO; 1211 err = (err == APM_SUCCESS) ? 0 : -EIO;
1212 sysdev_resume();
1211 device_power_up(PMSG_RESUME); 1213 device_power_up(PMSG_RESUME);
1212 local_irq_enable(); 1214 local_irq_enable();
1213 device_resume(PMSG_RESUME); 1215 device_resume(PMSG_RESUME);
@@ -1228,6 +1230,7 @@ static void standby(void)
1228 1230
1229 local_irq_disable(); 1231 local_irq_disable();
1230 device_power_down(PMSG_SUSPEND); 1232 device_power_down(PMSG_SUSPEND);
1233 sysdev_suspend(PMSG_SUSPEND);
1231 local_irq_enable(); 1234 local_irq_enable();
1232 1235
1233 err = set_system_power_state(APM_STATE_STANDBY); 1236 err = set_system_power_state(APM_STATE_STANDBY);
@@ -1235,6 +1238,7 @@ static void standby(void)
1235 apm_error("standby", err); 1238 apm_error("standby", err);
1236 1239
1237 local_irq_disable(); 1240 local_irq_disable();
1241 sysdev_resume();
1238 device_power_up(PMSG_RESUME); 1242 device_power_up(PMSG_RESUME);
1239 local_irq_enable(); 1243 local_irq_enable();
1240} 1244}
diff --git a/arch/x86/kernel/cpu/cpufreq/Kconfig b/arch/x86/kernel/cpu/cpufreq/Kconfig
index efae3b22a0ff..65792c2cc462 100644
--- a/arch/x86/kernel/cpu/cpufreq/Kconfig
+++ b/arch/x86/kernel/cpu/cpufreq/Kconfig
@@ -245,17 +245,6 @@ config X86_E_POWERSAVER
245 245
246comment "shared options" 246comment "shared options"
247 247
248config X86_ACPI_CPUFREQ_PROC_INTF
249 bool "/proc/acpi/processor/../performance interface (deprecated)"
250 depends on PROC_FS
251 depends on X86_ACPI_CPUFREQ || X86_POWERNOW_K7_ACPI || X86_POWERNOW_K8_ACPI
252 help
253 This enables the deprecated /proc/acpi/processor/../performance
254 interface. While it is helpful for debugging, the generic,
255 cross-architecture cpufreq interfaces should be used.
256
257 If in doubt, say N.
258
259config X86_SPEEDSTEP_LIB 248config X86_SPEEDSTEP_LIB
260 tristate 249 tristate
261 default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD) 250 default (X86_SPEEDSTEP_ICH || X86_SPEEDSTEP_SMI || X86_P4_CLOCKMOD)
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 5c28b37dea11..6428aa17b40e 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -939,10 +939,25 @@ static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data)
939 free_cpumask_var(data->acpi_data.shared_cpu_map); 939 free_cpumask_var(data->acpi_data.shared_cpu_map);
940} 940}
941 941
942static int get_transition_latency(struct powernow_k8_data *data)
943{
944 int max_latency = 0;
945 int i;
946 for (i = 0; i < data->acpi_data.state_count; i++) {
947 int cur_latency = data->acpi_data.states[i].transition_latency
948 + data->acpi_data.states[i].bus_master_latency;
949 if (cur_latency > max_latency)
950 max_latency = cur_latency;
951 }
952 /* value in usecs, needs to be in nanoseconds */
953 return 1000 * max_latency;
954}
955
942#else 956#else
943static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; } 957static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; }
944static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; } 958static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; }
945static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; } 959static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; }
960static int get_transition_latency(struct powernow_k8_data *data) { return 0; }
946#endif /* CONFIG_X86_POWERNOW_K8_ACPI */ 961#endif /* CONFIG_X86_POWERNOW_K8_ACPI */
947 962
948/* Take a frequency, and issue the fid/vid transition command */ 963/* Take a frequency, and issue the fid/vid transition command */
@@ -1142,8 +1157,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1142 data->cpu = pol->cpu; 1157 data->cpu = pol->cpu;
1143 data->currpstate = HW_PSTATE_INVALID; 1158 data->currpstate = HW_PSTATE_INVALID;
1144 1159
1145 rc = powernow_k8_cpu_init_acpi(data); 1160 if (powernow_k8_cpu_init_acpi(data)) {
1146 if (rc) {
1147 /* 1161 /*
1148 * Use the PSB BIOS structure. This is only availabe on 1162 * Use the PSB BIOS structure. This is only availabe on
1149 * an UP version, and is deprecated by AMD. 1163 * an UP version, and is deprecated by AMD.
@@ -1161,19 +1175,28 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1161 "ACPI maintainers and complain to your BIOS " 1175 "ACPI maintainers and complain to your BIOS "
1162 "vendor.\n"); 1176 "vendor.\n");
1163#endif 1177#endif
1164 goto err_out; 1178 kfree(data);
1179 return -ENODEV;
1165 } 1180 }
1166 if (pol->cpu != 0) { 1181 if (pol->cpu != 0) {
1167 printk(KERN_ERR FW_BUG PFX "No ACPI _PSS objects for " 1182 printk(KERN_ERR FW_BUG PFX "No ACPI _PSS objects for "
1168 "CPU other than CPU0. Complain to your BIOS " 1183 "CPU other than CPU0. Complain to your BIOS "
1169 "vendor.\n"); 1184 "vendor.\n");
1170 goto err_out; 1185 kfree(data);
1186 return -ENODEV;
1171 } 1187 }
1172 rc = find_psb_table(data); 1188 rc = find_psb_table(data);
1173 if (rc) { 1189 if (rc) {
1174 goto err_out; 1190 kfree(data);
1191 return -ENODEV;
1175 } 1192 }
1176 } 1193 /* Take a crude guess here.
1194 * That guess was in microseconds, so multiply with 1000 */
1195 pol->cpuinfo.transition_latency = (
1196 ((data->rvo + 8) * data->vstable * VST_UNITS_20US) +
1197 ((1 << data->irt) * 30)) * 1000;
1198 } else /* ACPI _PSS objects available */
1199 pol->cpuinfo.transition_latency = get_transition_latency(data);
1177 1200
1178 /* only run on specific CPU from here on */ 1201 /* only run on specific CPU from here on */
1179 oldmask = current->cpus_allowed; 1202 oldmask = current->cpus_allowed;
@@ -1204,11 +1227,6 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1204 cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu)); 1227 cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu));
1205 data->available_cores = pol->cpus; 1228 data->available_cores = pol->cpus;
1206 1229
1207 /* Take a crude guess here.
1208 * That guess was in microseconds, so multiply with 1000 */
1209 pol->cpuinfo.transition_latency = (((data->rvo + 8) * data->vstable * VST_UNITS_20US)
1210 + (3 * (1 << data->irt) * 10)) * 1000;
1211
1212 if (cpu_family == CPU_HW_PSTATE) 1230 if (cpu_family == CPU_HW_PSTATE)
1213 pol->cur = find_khz_freq_from_pstate(data->powernow_table, data->currpstate); 1231 pol->cur = find_khz_freq_from_pstate(data->powernow_table, data->currpstate);
1214 else 1232 else
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 430e5c38a544..24ff26a38ade 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -291,6 +291,9 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
291 ds_init_intel(c); 291 ds_init_intel(c);
292 } 292 }
293 293
294 if (c->x86 == 6 && c->x86_model == 29 && cpu_has_clflush)
295 set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR);
296
294#ifdef CONFIG_X86_64 297#ifdef CONFIG_X86_64
295 if (c->x86 == 15) 298 if (c->x86 == 15)
296 c->x86_cache_alignment = c->x86_clflush_size * 2; 299 c->x86_cache_alignment = c->x86_clflush_size * 2;
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 48533d77be78..da299eb85fc0 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -36,8 +36,11 @@ static struct _cache_table cache_table[] __cpuinitdata =
36{ 36{
37 { 0x06, LVL_1_INST, 8 }, /* 4-way set assoc, 32 byte line size */ 37 { 0x06, LVL_1_INST, 8 }, /* 4-way set assoc, 32 byte line size */
38 { 0x08, LVL_1_INST, 16 }, /* 4-way set assoc, 32 byte line size */ 38 { 0x08, LVL_1_INST, 16 }, /* 4-way set assoc, 32 byte line size */
39 { 0x09, LVL_1_INST, 32 }, /* 4-way set assoc, 64 byte line size */
39 { 0x0a, LVL_1_DATA, 8 }, /* 2 way set assoc, 32 byte line size */ 40 { 0x0a, LVL_1_DATA, 8 }, /* 2 way set assoc, 32 byte line size */
40 { 0x0c, LVL_1_DATA, 16 }, /* 4-way set assoc, 32 byte line size */ 41 { 0x0c, LVL_1_DATA, 16 }, /* 4-way set assoc, 32 byte line size */
42 { 0x0d, LVL_1_DATA, 16 }, /* 4-way set assoc, 64 byte line size */
43 { 0x21, LVL_2, 256 }, /* 8-way set assoc, 64 byte line size */
41 { 0x22, LVL_3, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */ 44 { 0x22, LVL_3, 512 }, /* 4-way set assoc, sectored cache, 64 byte line size */
42 { 0x23, LVL_3, 1024 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 45 { 0x23, LVL_3, 1024 }, /* 8-way set assoc, sectored cache, 64 byte line size */
43 { 0x25, LVL_3, 2048 }, /* 8-way set assoc, sectored cache, 64 byte line size */ 46 { 0x25, LVL_3, 2048 }, /* 8-way set assoc, sectored cache, 64 byte line size */
@@ -85,6 +88,18 @@ static struct _cache_table cache_table[] __cpuinitdata =
85 { 0x85, LVL_2, 2048 }, /* 8-way set assoc, 32 byte line size */ 88 { 0x85, LVL_2, 2048 }, /* 8-way set assoc, 32 byte line size */
86 { 0x86, LVL_2, 512 }, /* 4-way set assoc, 64 byte line size */ 89 { 0x86, LVL_2, 512 }, /* 4-way set assoc, 64 byte line size */
87 { 0x87, LVL_2, 1024 }, /* 8-way set assoc, 64 byte line size */ 90 { 0x87, LVL_2, 1024 }, /* 8-way set assoc, 64 byte line size */
91 { 0xd0, LVL_3, 512 }, /* 4-way set assoc, 64 byte line size */
92 { 0xd1, LVL_3, 1024 }, /* 4-way set assoc, 64 byte line size */
93 { 0xd2, LVL_3, 2048 }, /* 4-way set assoc, 64 byte line size */
94 { 0xd6, LVL_3, 1024 }, /* 8-way set assoc, 64 byte line size */
95 { 0xd7, LVL_3, 2038 }, /* 8-way set assoc, 64 byte line size */
96 { 0xd8, LVL_3, 4096 }, /* 12-way set assoc, 64 byte line size */
97 { 0xdc, LVL_3, 2048 }, /* 12-way set assoc, 64 byte line size */
98 { 0xdd, LVL_3, 4096 }, /* 12-way set assoc, 64 byte line size */
99 { 0xde, LVL_3, 8192 }, /* 12-way set assoc, 64 byte line size */
100 { 0xe2, LVL_3, 2048 }, /* 16-way set assoc, 64 byte line size */
101 { 0xe3, LVL_3, 4096 }, /* 16-way set assoc, 64 byte line size */
102 { 0xe4, LVL_3, 8192 }, /* 16-way set assoc, 64 byte line size */
88 { 0x00, 0, 0} 103 { 0x00, 0, 0}
89}; 104};
90 105
diff --git a/arch/x86/kernel/cpu/mcheck/mce_64.c b/arch/x86/kernel/cpu/mcheck/mce_64.c
index 1c838032fd37..fe79985ce0f2 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_64.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_64.c
@@ -295,11 +295,11 @@ void do_machine_check(struct pt_regs * regs, long error_code)
295 * If we know that the error was in user space, send a 295 * If we know that the error was in user space, send a
296 * SIGBUS. Otherwise, panic if tolerance is low. 296 * SIGBUS. Otherwise, panic if tolerance is low.
297 * 297 *
298 * do_exit() takes an awful lot of locks and has a slight 298 * force_sig() takes an awful lot of locks and has a slight
299 * risk of deadlocking. 299 * risk of deadlocking.
300 */ 300 */
301 if (user_space) { 301 if (user_space) {
302 do_exit(SIGBUS); 302 force_sig(SIGBUS, current);
303 } else if (panic_on_oops || tolerant < 2) { 303 } else if (panic_on_oops || tolerant < 2) {
304 mce_panic("Uncorrected machine check", 304 mce_panic("Uncorrected machine check",
305 &panicm, mcestart); 305 &panicm, mcestart);
@@ -490,7 +490,7 @@ static void __cpuinit mce_cpu_quirks(struct cpuinfo_x86 *c)
490 490
491} 491}
492 492
493static void __cpuinit mce_cpu_features(struct cpuinfo_x86 *c) 493static void mce_cpu_features(struct cpuinfo_x86 *c)
494{ 494{
495 switch (c->x86_vendor) { 495 switch (c->x86_vendor) {
496 case X86_VENDOR_INTEL: 496 case X86_VENDOR_INTEL:
@@ -734,6 +734,7 @@ __setup("mce=", mcheck_enable);
734static int mce_resume(struct sys_device *dev) 734static int mce_resume(struct sys_device *dev)
735{ 735{
736 mce_init(NULL); 736 mce_init(NULL);
737 mce_cpu_features(&current_cpu_data);
737 return 0; 738 return 0;
738} 739}
739 740
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd_64.c b/arch/x86/kernel/cpu/mcheck/mce_amd_64.c
index 8ae8c4ff094d..f2ee0ae29bd6 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd_64.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd_64.c
@@ -121,7 +121,7 @@ static long threshold_restart_bank(void *_tr)
121} 121}
122 122
123/* cpu init entry point, called from mce.c with preempt off */ 123/* cpu init entry point, called from mce.c with preempt off */
124void __cpuinit mce_amd_feature_init(struct cpuinfo_x86 *c) 124void mce_amd_feature_init(struct cpuinfo_x86 *c)
125{ 125{
126 unsigned int bank, block; 126 unsigned int bank, block;
127 unsigned int cpu = smp_processor_id(); 127 unsigned int cpu = smp_processor_id();
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel_64.c b/arch/x86/kernel/cpu/mcheck/mce_intel_64.c
index 4b48f251fd39..f44c36624360 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel_64.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel_64.c
@@ -30,7 +30,7 @@ asmlinkage void smp_thermal_interrupt(void)
30 irq_exit(); 30 irq_exit();
31} 31}
32 32
33static void __cpuinit intel_init_thermal(struct cpuinfo_x86 *c) 33static void intel_init_thermal(struct cpuinfo_x86 *c)
34{ 34{
35 u32 l, h; 35 u32 l, h;
36 int tm2 = 0; 36 int tm2 = 0;
@@ -84,7 +84,7 @@ static void __cpuinit intel_init_thermal(struct cpuinfo_x86 *c)
84 return; 84 return;
85} 85}
86 86
87void __cpuinit mce_intel_feature_init(struct cpuinfo_x86 *c) 87void mce_intel_feature_init(struct cpuinfo_x86 *c)
88{ 88{
89 intel_init_thermal(c); 89 intel_init_thermal(c);
90} 90}
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index e28c7a987793..a1346217e43c 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -346,6 +346,7 @@ ENTRY(save_args)
346 popq_cfi %rax /* move return address... */ 346 popq_cfi %rax /* move return address... */
347 mov %gs:pda_irqstackptr,%rsp 347 mov %gs:pda_irqstackptr,%rsp
348 EMPTY_FRAME 0 348 EMPTY_FRAME 0
349 pushq_cfi %rbp /* backlink for unwinder */
349 pushq_cfi %rax /* ... to the new stack */ 350 pushq_cfi %rax /* ... to the new stack */
350 /* 351 /*
351 * We entered an interrupt context - irqs are off: 352 * We entered an interrupt context - irqs are off:
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 1b43086b097a..231bdd3c5b1c 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -488,20 +488,21 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
488 * ignore such a protection. 488 * ignore such a protection.
489 */ 489 */
490 asm volatile( 490 asm volatile(
491 "1: " _ASM_MOV " (%[parent_old]), %[old]\n" 491 "1: " _ASM_MOV " (%[parent]), %[old]\n"
492 "2: " _ASM_MOV " %[return_hooker], (%[parent_replaced])\n" 492 "2: " _ASM_MOV " %[return_hooker], (%[parent])\n"
493 " movl $0, %[faulted]\n" 493 " movl $0, %[faulted]\n"
494 "3:\n"
494 495
495 ".section .fixup, \"ax\"\n" 496 ".section .fixup, \"ax\"\n"
496 "3: movl $1, %[faulted]\n" 497 "4: movl $1, %[faulted]\n"
498 " jmp 3b\n"
497 ".previous\n" 499 ".previous\n"
498 500
499 _ASM_EXTABLE(1b, 3b) 501 _ASM_EXTABLE(1b, 4b)
500 _ASM_EXTABLE(2b, 3b) 502 _ASM_EXTABLE(2b, 4b)
501 503
502 : [parent_replaced] "=r" (parent), [old] "=r" (old), 504 : [old] "=r" (old), [faulted] "=r" (faulted)
503 [faulted] "=r" (faulted) 505 : [parent] "r" (parent), [return_hooker] "r" (return_hooker)
504 : [parent_old] "0" (parent), [return_hooker] "r" (return_hooker)
505 : "memory" 506 : "memory"
506 ); 507 );
507 508
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 64d5ad0b8add..a00545fe5cdd 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -269,6 +269,8 @@ static void hpet_set_mode(enum clock_event_mode mode,
269 now = hpet_readl(HPET_COUNTER); 269 now = hpet_readl(HPET_COUNTER);
270 cmp = now + (unsigned long) delta; 270 cmp = now + (unsigned long) delta;
271 cfg = hpet_readl(HPET_Tn_CFG(timer)); 271 cfg = hpet_readl(HPET_Tn_CFG(timer));
272 /* Make sure we use edge triggered interrupts */
273 cfg &= ~HPET_TN_LEVEL;
272 cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | 274 cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
273 HPET_TN_SETVAL | HPET_TN_32BIT; 275 HPET_TN_SETVAL | HPET_TN_32BIT;
274 hpet_writel(cfg, HPET_Tn_CFG(timer)); 276 hpet_writel(cfg, HPET_Tn_CFG(timer));
@@ -897,7 +899,7 @@ static unsigned long hpet_rtc_flags;
897static int hpet_prev_update_sec; 899static int hpet_prev_update_sec;
898static struct rtc_time hpet_alarm_time; 900static struct rtc_time hpet_alarm_time;
899static unsigned long hpet_pie_count; 901static unsigned long hpet_pie_count;
900static unsigned long hpet_t1_cmp; 902static u32 hpet_t1_cmp;
901static unsigned long hpet_default_delta; 903static unsigned long hpet_default_delta;
902static unsigned long hpet_pie_delta; 904static unsigned long hpet_pie_delta;
903static unsigned long hpet_pie_limit; 905static unsigned long hpet_pie_limit;
@@ -905,6 +907,14 @@ static unsigned long hpet_pie_limit;
905static rtc_irq_handler irq_handler; 907static rtc_irq_handler irq_handler;
906 908
907/* 909/*
910 * Check that the hpet counter c1 is ahead of the c2
911 */
912static inline int hpet_cnt_ahead(u32 c1, u32 c2)
913{
914 return (s32)(c2 - c1) < 0;
915}
916
917/*
908 * Registers a IRQ handler. 918 * Registers a IRQ handler.
909 */ 919 */
910int hpet_register_irq_handler(rtc_irq_handler handler) 920int hpet_register_irq_handler(rtc_irq_handler handler)
@@ -1075,7 +1085,7 @@ static void hpet_rtc_timer_reinit(void)
1075 hpet_t1_cmp += delta; 1085 hpet_t1_cmp += delta;
1076 hpet_writel(hpet_t1_cmp, HPET_T1_CMP); 1086 hpet_writel(hpet_t1_cmp, HPET_T1_CMP);
1077 lost_ints++; 1087 lost_ints++;
1078 } while ((long)(hpet_readl(HPET_COUNTER) - hpet_t1_cmp) > 0); 1088 } while (!hpet_cnt_ahead(hpet_t1_cmp, hpet_readl(HPET_COUNTER)));
1079 1089
1080 if (lost_ints) { 1090 if (lost_ints) {
1081 if (hpet_rtc_flags & RTC_PIE) 1091 if (hpet_rtc_flags & RTC_PIE)
diff --git a/arch/x86/kernel/i8237.c b/arch/x86/kernel/i8237.c
index dbd6c1d1b638..b42ca694dc68 100644
--- a/arch/x86/kernel/i8237.c
+++ b/arch/x86/kernel/i8237.c
@@ -28,10 +28,10 @@ static int i8237A_resume(struct sys_device *dev)
28 28
29 flags = claim_dma_lock(); 29 flags = claim_dma_lock();
30 30
31 dma_outb(DMA1_RESET_REG, 0); 31 dma_outb(0, DMA1_RESET_REG);
32 dma_outb(DMA2_RESET_REG, 0); 32 dma_outb(0, DMA2_RESET_REG);
33 33
34 for (i = 0;i < 8;i++) { 34 for (i = 0; i < 8; i++) {
35 set_dma_addr(i, 0x000000); 35 set_dma_addr(i, 0x000000);
36 /* DMA count is a bit weird so this is not 0 */ 36 /* DMA count is a bit weird so this is not 0 */
37 set_dma_count(i, 1); 37 set_dma_count(i, 1);
@@ -51,14 +51,14 @@ static int i8237A_suspend(struct sys_device *dev, pm_message_t state)
51} 51}
52 52
53static struct sysdev_class i8237_sysdev_class = { 53static struct sysdev_class i8237_sysdev_class = {
54 .name = "i8237", 54 .name = "i8237",
55 .suspend = i8237A_suspend, 55 .suspend = i8237A_suspend,
56 .resume = i8237A_resume, 56 .resume = i8237A_resume,
57}; 57};
58 58
59static struct sys_device device_i8237A = { 59static struct sys_device device_i8237A = {
60 .id = 0, 60 .id = 0,
61 .cls = &i8237_sysdev_class, 61 .cls = &i8237_sysdev_class,
62}; 62};
63 63
64static int __init i8237A_init_sysfs(void) 64static int __init i8237A_init_sysfs(void)
@@ -68,5 +68,4 @@ static int __init i8237A_init_sysfs(void)
68 error = sysdev_register(&device_i8237A); 68 error = sysdev_register(&device_i8237A);
69 return error; 69 return error;
70} 70}
71
72device_initcall(i8237A_init_sysfs); 71device_initcall(i8237A_init_sysfs);
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c
index 1c4a1302536c..bc7ac4da90d7 100644
--- a/arch/x86/kernel/io_apic.c
+++ b/arch/x86/kernel/io_apic.c
@@ -2528,14 +2528,15 @@ static void irq_complete_move(struct irq_desc **descp)
2528 2528
2529 vector = ~get_irq_regs()->orig_ax; 2529 vector = ~get_irq_regs()->orig_ax;
2530 me = smp_processor_id(); 2530 me = smp_processor_id();
2531
2532 if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain)) {
2531#ifdef CONFIG_NUMA_MIGRATE_IRQ_DESC 2533#ifdef CONFIG_NUMA_MIGRATE_IRQ_DESC
2532 *descp = desc = move_irq_desc(desc, me); 2534 *descp = desc = move_irq_desc(desc, me);
2533 /* get the new one */ 2535 /* get the new one */
2534 cfg = desc->chip_data; 2536 cfg = desc->chip_data;
2535#endif 2537#endif
2536
2537 if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain))
2538 send_cleanup_vector(cfg); 2538 send_cleanup_vector(cfg);
2539 }
2539} 2540}
2540#else 2541#else
2541static inline void irq_complete_move(struct irq_desc **descp) {} 2542static inline void irq_complete_move(struct irq_desc **descp) {}
@@ -3840,14 +3841,24 @@ int __init io_apic_get_redir_entries (int ioapic)
3840 3841
3841void __init probe_nr_irqs_gsi(void) 3842void __init probe_nr_irqs_gsi(void)
3842{ 3843{
3843 int idx;
3844 int nr = 0; 3844 int nr = 0;
3845 3845
3846 for (idx = 0; idx < nr_ioapics; idx++) 3846 nr = acpi_probe_gsi();
3847 nr += io_apic_get_redir_entries(idx) + 1; 3847 if (nr > nr_irqs_gsi) {
3848
3849 if (nr > nr_irqs_gsi)
3850 nr_irqs_gsi = nr; 3848 nr_irqs_gsi = nr;
3849 } else {
3850 /* for acpi=off or acpi is not compiled in */
3851 int idx;
3852
3853 nr = 0;
3854 for (idx = 0; idx < nr_ioapics; idx++)
3855 nr += io_apic_get_redir_entries(idx) + 1;
3856
3857 if (nr > nr_irqs_gsi)
3858 nr_irqs_gsi = nr;
3859 }
3860
3861 printk(KERN_DEBUG "nr_irqs_gsi: %d\n", nr_irqs_gsi);
3851} 3862}
3852 3863
3853/* -------------------------------------------------------------------------- 3864/* --------------------------------------------------------------------------
diff --git a/arch/x86/kernel/irqinit_32.c b/arch/x86/kernel/irqinit_32.c
index 1507ad4e674d..10a09c2f1828 100644
--- a/arch/x86/kernel/irqinit_32.c
+++ b/arch/x86/kernel/irqinit_32.c
@@ -78,15 +78,6 @@ void __init init_ISA_irqs(void)
78 } 78 }
79} 79}
80 80
81/*
82 * IRQ2 is cascade interrupt to second interrupt controller
83 */
84static struct irqaction irq2 = {
85 .handler = no_action,
86 .mask = CPU_MASK_NONE,
87 .name = "cascade",
88};
89
90DEFINE_PER_CPU(vector_irq_t, vector_irq) = { 81DEFINE_PER_CPU(vector_irq_t, vector_irq) = {
91 [0 ... IRQ0_VECTOR - 1] = -1, 82 [0 ... IRQ0_VECTOR - 1] = -1,
92 [IRQ0_VECTOR] = 0, 83 [IRQ0_VECTOR] = 0,
@@ -178,9 +169,6 @@ void __init native_init_IRQ(void)
178 alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt); 169 alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
179#endif 170#endif
180 171
181 if (!acpi_ioapic)
182 setup_irq(2, &irq2);
183
184 /* setup after call gates are initialised (usually add in 172 /* setup after call gates are initialised (usually add in
185 * the architecture specific gates) 173 * the architecture specific gates)
186 */ 174 */
diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c
index 7a13fac63a1f..4006c522adc7 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/kernel/olpc.c
@@ -203,7 +203,7 @@ static void __init platform_detect(void)
203static void __init platform_detect(void) 203static void __init platform_detect(void)
204{ 204{
205 /* stopgap until OFW support is added to the kernel */ 205 /* stopgap until OFW support is added to the kernel */
206 olpc_platform_info.boardrev = 0xc2; 206 olpc_platform_info.boardrev = olpc_board(0xc2);
207} 207}
208#endif 208#endif
209 209
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index e4c8fb608873..c6520a4e85d4 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -268,6 +268,32 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
268 return __get_cpu_var(paravirt_lazy_mode); 268 return __get_cpu_var(paravirt_lazy_mode);
269} 269}
270 270
271void arch_flush_lazy_mmu_mode(void)
272{
273 preempt_disable();
274
275 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU) {
276 WARN_ON(preempt_count() == 1);
277 arch_leave_lazy_mmu_mode();
278 arch_enter_lazy_mmu_mode();
279 }
280
281 preempt_enable();
282}
283
284void arch_flush_lazy_cpu_mode(void)
285{
286 preempt_disable();
287
288 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU) {
289 WARN_ON(preempt_count() == 1);
290 arch_leave_lazy_cpu_mode();
291 arch_enter_lazy_cpu_mode();
292 }
293
294 preempt_enable();
295}
296
271struct pv_info pv_info = { 297struct pv_info pv_info = {
272 .name = "bare hardware", 298 .name = "bare hardware",
273 .paravirt_enabled = 0, 299 .paravirt_enabled = 0,
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index e68bb9e30864..6d12f7e37f8c 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -180,6 +180,9 @@ void mwait_idle_with_hints(unsigned long ax, unsigned long cx)
180 180
181 trace_power_start(&it, POWER_CSTATE, (ax>>4)+1); 181 trace_power_start(&it, POWER_CSTATE, (ax>>4)+1);
182 if (!need_resched()) { 182 if (!need_resched()) {
183 if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
184 clflush((void *)&current_thread_info()->flags);
185
183 __monitor((void *)&current_thread_info()->flags, 0, 0); 186 __monitor((void *)&current_thread_info()->flags, 0, 0);
184 smp_mb(); 187 smp_mb();
185 if (!need_resched()) 188 if (!need_resched())
@@ -194,6 +197,9 @@ static void mwait_idle(void)
194 struct power_trace it; 197 struct power_trace it;
195 if (!need_resched()) { 198 if (!need_resched()) {
196 trace_power_start(&it, POWER_CSTATE, 1); 199 trace_power_start(&it, POWER_CSTATE, 1);
200 if (cpu_has(&current_cpu_data, X86_FEATURE_CLFLUSH_MONITOR))
201 clflush((void *)&current_thread_info()->flags);
202
197 __monitor((void *)&current_thread_info()->flags, 0, 0); 203 __monitor((void *)&current_thread_info()->flags, 0, 0);
198 smp_mb(); 204 smp_mb();
199 if (!need_resched()) 205 if (!need_resched())
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index a546f55c77b4..bd4da2af08ae 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -104,9 +104,6 @@ void cpu_idle(void)
104 check_pgt_cache(); 104 check_pgt_cache();
105 rmb(); 105 rmb();
106 106
107 if (rcu_pending(cpu))
108 rcu_check_callbacks(cpu, 0);
109
110 if (cpu_is_offline(cpu)) 107 if (cpu_is_offline(cpu))
111 play_dead(); 108 play_dead();
112 109
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 416fb9282f4f..85b4cb5c1980 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -40,6 +40,7 @@
40#include <linux/uaccess.h> 40#include <linux/uaccess.h>
41#include <linux/io.h> 41#include <linux/io.h>
42#include <linux/ftrace.h> 42#include <linux/ftrace.h>
43#include <linux/dmi.h>
43 44
44#include <asm/pgtable.h> 45#include <asm/pgtable.h>
45#include <asm/system.h> 46#include <asm/system.h>
@@ -151,14 +152,18 @@ void __show_regs(struct pt_regs *regs, int all)
151 unsigned long d0, d1, d2, d3, d6, d7; 152 unsigned long d0, d1, d2, d3, d6, d7;
152 unsigned int fsindex, gsindex; 153 unsigned int fsindex, gsindex;
153 unsigned int ds, cs, es; 154 unsigned int ds, cs, es;
155 const char *board;
154 156
155 printk("\n"); 157 printk("\n");
156 print_modules(); 158 print_modules();
157 printk(KERN_INFO "Pid: %d, comm: %.20s %s %s %.*s\n", 159 board = dmi_get_system_info(DMI_PRODUCT_NAME);
160 if (!board)
161 board = "";
162 printk(KERN_INFO "Pid: %d, comm: %.20s %s %s %.*s %s\n",
158 current->pid, current->comm, print_tainted(), 163 current->pid, current->comm, print_tainted(),
159 init_utsname()->release, 164 init_utsname()->release,
160 (int)strcspn(init_utsname()->version, " "), 165 (int)strcspn(init_utsname()->version, " "),
161 init_utsname()->version); 166 init_utsname()->version, board);
162 printk(KERN_INFO "RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->ip); 167 printk(KERN_INFO "RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->ip);
163 printk_address(regs->ip, 1); 168 printk_address(regs->ip, 1);
164 printk(KERN_INFO "RSP: %04lx:%016lx EFLAGS: %08lx\n", regs->ss, 169 printk(KERN_INFO "RSP: %04lx:%016lx EFLAGS: %08lx\n", regs->ss,
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 0a5df5f82fb9..5a4c23d89892 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -810,12 +810,16 @@ static void ptrace_bts_untrace(struct task_struct *child)
810 810
811static void ptrace_bts_detach(struct task_struct *child) 811static void ptrace_bts_detach(struct task_struct *child)
812{ 812{
813 if (unlikely(child->bts)) { 813 /*
814 ds_release_bts(child->bts); 814 * Ptrace_detach() races with ptrace_untrace() in case
815 child->bts = NULL; 815 * the child dies and is reaped by another thread.
816 816 *
817 ptrace_bts_free_buffer(child); 817 * We only do the memory accounting at this point and
818 } 818 * leave the buffer deallocation and the bts tracer
819 * release to ptrace_bts_untrace() which will be called
820 * later on with tasklist_lock held.
821 */
822 release_locked_buffer(child->bts_buffer, child->bts_size);
819} 823}
820#else 824#else
821static inline void ptrace_bts_fork(struct task_struct *tsk) {} 825static inline void ptrace_bts_fork(struct task_struct *tsk) {}
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index ae0d8042cf69..c461f6d69074 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -607,7 +607,7 @@ struct x86_quirks *x86_quirks __initdata = &default_x86_quirks;
607static int __init dmi_low_memory_corruption(const struct dmi_system_id *d) 607static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
608{ 608{
609 printk(KERN_NOTICE 609 printk(KERN_NOTICE
610 "%s detected: BIOS may corrupt low RAM, working it around.\n", 610 "%s detected: BIOS may corrupt low RAM, working around it.\n",
611 d->ident); 611 d->ident);
612 612
613 e820_update_range(0, 0x10000, E820_RAM, E820_RESERVED); 613 e820_update_range(0, 0x10000, E820_RAM, E820_RESERVED);
diff --git a/arch/x86/kernel/time_64.c b/arch/x86/kernel/time_64.c
index e6e695acd725..241ec3923f61 100644
--- a/arch/x86/kernel/time_64.c
+++ b/arch/x86/kernel/time_64.c
@@ -115,7 +115,7 @@ unsigned long __init calibrate_cpu(void)
115 115
116static struct irqaction irq0 = { 116static struct irqaction irq0 = {
117 .handler = timer_interrupt, 117 .handler = timer_interrupt,
118 .flags = IRQF_DISABLED | IRQF_IRQPOLL | IRQF_NOBALANCING, 118 .flags = IRQF_DISABLED | IRQF_IRQPOLL | IRQF_NOBALANCING | IRQF_TIMER,
119 .mask = CPU_MASK_NONE, 119 .mask = CPU_MASK_NONE,
120 .name = "timer" 120 .name = "timer"
121}; 121};
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 98c2d055284b..a9e7548e1790 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -99,6 +99,12 @@ static inline void preempt_conditional_sti(struct pt_regs *regs)
99 local_irq_enable(); 99 local_irq_enable();
100} 100}
101 101
102static inline void conditional_cli(struct pt_regs *regs)
103{
104 if (regs->flags & X86_EFLAGS_IF)
105 local_irq_disable();
106}
107
102static inline void preempt_conditional_cli(struct pt_regs *regs) 108static inline void preempt_conditional_cli(struct pt_regs *regs)
103{ 109{
104 if (regs->flags & X86_EFLAGS_IF) 110 if (regs->flags & X86_EFLAGS_IF)
@@ -626,8 +632,10 @@ clear_dr7:
626 632
627#ifdef CONFIG_X86_32 633#ifdef CONFIG_X86_32
628debug_vm86: 634debug_vm86:
635 /* reenable preemption: handle_vm86_trap() might sleep */
636 dec_preempt_count();
629 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1); 637 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1);
630 preempt_conditional_cli(regs); 638 conditional_cli(regs);
631 return; 639 return;
632#endif 640#endif
633 641
@@ -896,7 +904,7 @@ asmlinkage void math_state_restore(void)
896EXPORT_SYMBOL_GPL(math_state_restore); 904EXPORT_SYMBOL_GPL(math_state_restore);
897 905
898#ifndef CONFIG_MATH_EMULATION 906#ifndef CONFIG_MATH_EMULATION
899asmlinkage void math_emulate(long arg) 907void math_emulate(struct math_emu_info *info)
900{ 908{
901 printk(KERN_EMERG 909 printk(KERN_EMERG
902 "math-emulation not enabled and no coprocessor found.\n"); 910 "math-emulation not enabled and no coprocessor found.\n");
@@ -906,16 +914,19 @@ asmlinkage void math_emulate(long arg)
906} 914}
907#endif /* CONFIG_MATH_EMULATION */ 915#endif /* CONFIG_MATH_EMULATION */
908 916
909dotraplinkage void __kprobes 917dotraplinkage void __kprobes do_device_not_available(struct pt_regs regs)
910do_device_not_available(struct pt_regs *regs, long error)
911{ 918{
912#ifdef CONFIG_X86_32 919#ifdef CONFIG_X86_32
913 if (read_cr0() & X86_CR0_EM) { 920 if (read_cr0() & X86_CR0_EM) {
914 conditional_sti(regs); 921 struct math_emu_info info = { };
915 math_emulate(0); 922
923 conditional_sti(&regs);
924
925 info.regs = &regs;
926 math_emulate(&info);
916 } else { 927 } else {
917 math_state_restore(); /* interrupts still off */ 928 math_state_restore(); /* interrupts still off */
918 conditional_sti(regs); 929 conditional_sti(&regs);
919 } 930 }
920#else 931#else
921 math_state_restore(); 932 math_state_restore();
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c
index 1d3302cc2ddf..bef58b4982db 100644
--- a/arch/x86/kernel/vmi_32.c
+++ b/arch/x86/kernel/vmi_32.c
@@ -321,6 +321,16 @@ static void vmi_release_pmd(unsigned long pfn)
321} 321}
322 322
323/* 323/*
324 * We use the pgd_free hook for releasing the pgd page:
325 */
326static void vmi_pgd_free(struct mm_struct *mm, pgd_t *pgd)
327{
328 unsigned long pfn = __pa(pgd) >> PAGE_SHIFT;
329
330 vmi_ops.release_page(pfn, VMI_PAGE_L2);
331}
332
333/*
324 * Helper macros for MMU update flags. We can defer updates until a flush 334 * Helper macros for MMU update flags. We can defer updates until a flush
325 * or page invalidation only if the update is to the current address space 335 * or page invalidation only if the update is to the current address space
326 * (otherwise, there is no flush). We must check against init_mm, since 336 * (otherwise, there is no flush). We must check against init_mm, since
@@ -762,6 +772,7 @@ static inline int __init activate_vmi(void)
762 if (vmi_ops.release_page) { 772 if (vmi_ops.release_page) {
763 pv_mmu_ops.release_pte = vmi_release_pte; 773 pv_mmu_ops.release_pte = vmi_release_pte;
764 pv_mmu_ops.release_pmd = vmi_release_pmd; 774 pv_mmu_ops.release_pmd = vmi_release_pmd;
775 pv_mmu_ops.pgd_free = vmi_pgd_free;
765 } 776 }
766 777
767 /* Set linear is needed in all cases */ 778 /* Set linear is needed in all cases */
diff --git a/arch/x86/kernel/vmiclock_32.c b/arch/x86/kernel/vmiclock_32.c
index c4c1f9e09402..e5b088fffa40 100644
--- a/arch/x86/kernel/vmiclock_32.c
+++ b/arch/x86/kernel/vmiclock_32.c
@@ -202,7 +202,7 @@ static irqreturn_t vmi_timer_interrupt(int irq, void *dev_id)
202static struct irqaction vmi_clock_action = { 202static struct irqaction vmi_clock_action = {
203 .name = "vmi-timer", 203 .name = "vmi-timer",
204 .handler = vmi_timer_interrupt, 204 .handler = vmi_timer_interrupt,
205 .flags = IRQF_DISABLED | IRQF_NOBALANCING, 205 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_TIMER,
206 .mask = CPU_MASK_ALL, 206 .mask = CPU_MASK_ALL,
207}; 207};
208 208
@@ -283,10 +283,13 @@ void __devinit vmi_time_ap_init(void)
283#endif 283#endif
284 284
285/** vmi clocksource */ 285/** vmi clocksource */
286static struct clocksource clocksource_vmi;
286 287
287static cycle_t read_real_cycles(void) 288static cycle_t read_real_cycles(void)
288{ 289{
289 return vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL); 290 cycle_t ret = (cycle_t)vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL);
291 return ret >= clocksource_vmi.cycle_last ?
292 ret : clocksource_vmi.cycle_last;
290} 293}
291 294
292static struct clocksource clocksource_vmi = { 295static struct clocksource clocksource_vmi = {
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index e665d1c623ca..72bd275a9b5c 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -207,7 +207,7 @@ static int __pit_timer_fn(struct kvm_kpit_state *ps)
207 hrtimer_add_expires_ns(&pt->timer, pt->period); 207 hrtimer_add_expires_ns(&pt->timer, pt->period);
208 pt->scheduled = hrtimer_get_expires_ns(&pt->timer); 208 pt->scheduled = hrtimer_get_expires_ns(&pt->timer);
209 if (pt->period) 209 if (pt->period)
210 ps->channels[0].count_load_time = hrtimer_get_expires(&pt->timer); 210 ps->channels[0].count_load_time = ktime_get();
211 211
212 return (pt->period == 0 ? 0 : 1); 212 return (pt->period == 0 ? 0 : 1);
213} 213}
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index c019b8edcdb7..cf17ed52f6fb 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -87,13 +87,6 @@ void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu)
87} 87}
88EXPORT_SYMBOL_GPL(kvm_inject_pending_timer_irqs); 88EXPORT_SYMBOL_GPL(kvm_inject_pending_timer_irqs);
89 89
90void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec)
91{
92 kvm_apic_timer_intr_post(vcpu, vec);
93 /* TODO: PIT, RTC etc. */
94}
95EXPORT_SYMBOL_GPL(kvm_timer_intr_post);
96
97void __kvm_migrate_timers(struct kvm_vcpu *vcpu) 90void __kvm_migrate_timers(struct kvm_vcpu *vcpu)
98{ 91{
99 __kvm_migrate_apic_timer(vcpu); 92 __kvm_migrate_apic_timer(vcpu);
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 2bf32a03ceec..82579ee538d0 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -89,7 +89,6 @@ static inline int irqchip_in_kernel(struct kvm *kvm)
89 89
90void kvm_pic_reset(struct kvm_kpic_state *s); 90void kvm_pic_reset(struct kvm_kpic_state *s);
91 91
92void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
93void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); 92void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
94void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); 93void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu);
95void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu); 94void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index afac68c0815c..f0b67f2cdd69 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -35,6 +35,12 @@
35#include "kvm_cache_regs.h" 35#include "kvm_cache_regs.h"
36#include "irq.h" 36#include "irq.h"
37 37
38#ifndef CONFIG_X86_64
39#define mod_64(x, y) ((x) - (y) * div64_u64(x, y))
40#else
41#define mod_64(x, y) ((x) % (y))
42#endif
43
38#define PRId64 "d" 44#define PRId64 "d"
39#define PRIx64 "llx" 45#define PRIx64 "llx"
40#define PRIu64 "u" 46#define PRIu64 "u"
@@ -511,52 +517,22 @@ static void apic_send_ipi(struct kvm_lapic *apic)
511 517
512static u32 apic_get_tmcct(struct kvm_lapic *apic) 518static u32 apic_get_tmcct(struct kvm_lapic *apic)
513{ 519{
514 u64 counter_passed; 520 ktime_t remaining;
515 ktime_t passed, now; 521 s64 ns;
516 u32 tmcct; 522 u32 tmcct;
517 523
518 ASSERT(apic != NULL); 524 ASSERT(apic != NULL);
519 525
520 now = apic->timer.dev.base->get_time();
521 tmcct = apic_get_reg(apic, APIC_TMICT);
522
523 /* if initial count is 0, current count should also be 0 */ 526 /* if initial count is 0, current count should also be 0 */
524 if (tmcct == 0) 527 if (apic_get_reg(apic, APIC_TMICT) == 0)
525 return 0; 528 return 0;
526 529
527 if (unlikely(ktime_to_ns(now) <= 530 remaining = hrtimer_expires_remaining(&apic->timer.dev);
528 ktime_to_ns(apic->timer.last_update))) { 531 if (ktime_to_ns(remaining) < 0)
529 /* Wrap around */ 532 remaining = ktime_set(0, 0);
530 passed = ktime_add(( { 533
531 (ktime_t) { 534 ns = mod_64(ktime_to_ns(remaining), apic->timer.period);
532 .tv64 = KTIME_MAX - 535 tmcct = div64_u64(ns, (APIC_BUS_CYCLE_NS * apic->timer.divide_count));
533 (apic->timer.last_update).tv64}; }
534 ), now);
535 apic_debug("time elapsed\n");
536 } else
537 passed = ktime_sub(now, apic->timer.last_update);
538
539 counter_passed = div64_u64(ktime_to_ns(passed),
540 (APIC_BUS_CYCLE_NS * apic->timer.divide_count));
541
542 if (counter_passed > tmcct) {
543 if (unlikely(!apic_lvtt_period(apic))) {
544 /* one-shot timers stick at 0 until reset */
545 tmcct = 0;
546 } else {
547 /*
548 * periodic timers reset to APIC_TMICT when they
549 * hit 0. The while loop simulates this happening N
550 * times. (counter_passed %= tmcct) would also work,
551 * but might be slower or not work on 32-bit??
552 */
553 while (counter_passed > tmcct)
554 counter_passed -= tmcct;
555 tmcct -= counter_passed;
556 }
557 } else {
558 tmcct -= counter_passed;
559 }
560 536
561 return tmcct; 537 return tmcct;
562} 538}
@@ -653,8 +629,6 @@ static void start_apic_timer(struct kvm_lapic *apic)
653{ 629{
654 ktime_t now = apic->timer.dev.base->get_time(); 630 ktime_t now = apic->timer.dev.base->get_time();
655 631
656 apic->timer.last_update = now;
657
658 apic->timer.period = apic_get_reg(apic, APIC_TMICT) * 632 apic->timer.period = apic_get_reg(apic, APIC_TMICT) *
659 APIC_BUS_CYCLE_NS * apic->timer.divide_count; 633 APIC_BUS_CYCLE_NS * apic->timer.divide_count;
660 atomic_set(&apic->timer.pending, 0); 634 atomic_set(&apic->timer.pending, 0);
@@ -1110,16 +1084,6 @@ void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu)
1110 } 1084 }
1111} 1085}
1112 1086
1113void kvm_apic_timer_intr_post(struct kvm_vcpu *vcpu, int vec)
1114{
1115 struct kvm_lapic *apic = vcpu->arch.apic;
1116
1117 if (apic && apic_lvt_vector(apic, APIC_LVTT) == vec)
1118 apic->timer.last_update = ktime_add_ns(
1119 apic->timer.last_update,
1120 apic->timer.period);
1121}
1122
1123int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu) 1087int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu)
1124{ 1088{
1125 int vector = kvm_apic_has_interrupt(vcpu); 1089 int vector = kvm_apic_has_interrupt(vcpu);
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 81858881287e..45ab6ee71209 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -12,7 +12,6 @@ struct kvm_lapic {
12 atomic_t pending; 12 atomic_t pending;
13 s64 period; /* unit: ns */ 13 s64 period; /* unit: ns */
14 u32 divide_count; 14 u32 divide_count;
15 ktime_t last_update;
16 struct hrtimer dev; 15 struct hrtimer dev;
17 } timer; 16 } timer;
18 struct kvm_vcpu *vcpu; 17 struct kvm_vcpu *vcpu;
@@ -42,7 +41,6 @@ void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data);
42void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu); 41void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu);
43int kvm_lapic_enabled(struct kvm_vcpu *vcpu); 42int kvm_lapic_enabled(struct kvm_vcpu *vcpu);
44int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu); 43int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu);
45void kvm_apic_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
46 44
47void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr); 45void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr);
48void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu); 46void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 83f11c7474a1..2d4477c71473 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1698,8 +1698,13 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1698 if (largepage) 1698 if (largepage)
1699 spte |= PT_PAGE_SIZE_MASK; 1699 spte |= PT_PAGE_SIZE_MASK;
1700 if (mt_mask) { 1700 if (mt_mask) {
1701 mt_mask = get_memory_type(vcpu, gfn) << 1701 if (!kvm_is_mmio_pfn(pfn)) {
1702 kvm_x86_ops->get_mt_mask_shift(); 1702 mt_mask = get_memory_type(vcpu, gfn) <<
1703 kvm_x86_ops->get_mt_mask_shift();
1704 mt_mask |= VMX_EPT_IGMT_BIT;
1705 } else
1706 mt_mask = MTRR_TYPE_UNCACHABLE <<
1707 kvm_x86_ops->get_mt_mask_shift();
1703 spte |= mt_mask; 1708 spte |= mt_mask;
1704 } 1709 }
1705 1710
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1452851ae258..a9e769e4e251 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1600,7 +1600,6 @@ static void svm_intr_assist(struct kvm_vcpu *vcpu)
1600 /* Okay, we can deliver the interrupt: grab it and update PIC state. */ 1600 /* Okay, we can deliver the interrupt: grab it and update PIC state. */
1601 intr_vector = kvm_cpu_get_interrupt(vcpu); 1601 intr_vector = kvm_cpu_get_interrupt(vcpu);
1602 svm_inject_irq(svm, intr_vector); 1602 svm_inject_irq(svm, intr_vector);
1603 kvm_timer_intr_post(vcpu, intr_vector);
1604out: 1603out:
1605 update_cr8_intercept(vcpu); 1604 update_cr8_intercept(vcpu);
1606} 1605}
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 6259d7467648..7611af576829 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -903,6 +903,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
903 data = vmcs_readl(GUEST_SYSENTER_ESP); 903 data = vmcs_readl(GUEST_SYSENTER_ESP);
904 break; 904 break;
905 default: 905 default:
906 vmx_load_host_state(to_vmx(vcpu));
906 msr = find_msr_entry(to_vmx(vcpu), msr_index); 907 msr = find_msr_entry(to_vmx(vcpu), msr_index);
907 if (msr) { 908 if (msr) {
908 data = msr->data; 909 data = msr->data;
@@ -3285,7 +3286,6 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
3285 } 3286 }
3286 if (vcpu->arch.interrupt.pending) { 3287 if (vcpu->arch.interrupt.pending) {
3287 vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr); 3288 vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
3288 kvm_timer_intr_post(vcpu, vcpu->arch.interrupt.nr);
3289 if (kvm_cpu_has_interrupt(vcpu)) 3289 if (kvm_cpu_has_interrupt(vcpu))
3290 enable_irq_window(vcpu); 3290 enable_irq_window(vcpu);
3291 } 3291 }
@@ -3687,8 +3687,7 @@ static int __init vmx_init(void)
3687 if (vm_need_ept()) { 3687 if (vm_need_ept()) {
3688 bypass_guest_pf = 0; 3688 bypass_guest_pf = 0;
3689 kvm_mmu_set_base_ptes(VMX_EPT_READABLE_MASK | 3689 kvm_mmu_set_base_ptes(VMX_EPT_READABLE_MASK |
3690 VMX_EPT_WRITABLE_MASK | 3690 VMX_EPT_WRITABLE_MASK);
3691 VMX_EPT_IGMT_BIT);
3692 kvm_mmu_set_mask_ptes(0ull, 0ull, 0ull, 0ull, 3691 kvm_mmu_set_mask_ptes(0ull, 0ull, 0ull, 0ull,
3693 VMX_EPT_EXECUTABLE_MASK, 3692 VMX_EPT_EXECUTABLE_MASK,
3694 VMX_EPT_DEFAULT_MT << VMX_EPT_MT_EPTE_SHIFT); 3693 VMX_EPT_DEFAULT_MT << VMX_EPT_MT_EPTE_SHIFT);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cc17546a2406..758b7a155ae9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -967,7 +967,6 @@ int kvm_dev_ioctl_check_extension(long ext)
967 case KVM_CAP_MMU_SHADOW_CACHE_CONTROL: 967 case KVM_CAP_MMU_SHADOW_CACHE_CONTROL:
968 case KVM_CAP_SET_TSS_ADDR: 968 case KVM_CAP_SET_TSS_ADDR:
969 case KVM_CAP_EXT_CPUID: 969 case KVM_CAP_EXT_CPUID:
970 case KVM_CAP_CLOCKSOURCE:
971 case KVM_CAP_PIT: 970 case KVM_CAP_PIT:
972 case KVM_CAP_NOP_IO_DELAY: 971 case KVM_CAP_NOP_IO_DELAY:
973 case KVM_CAP_MP_STATE: 972 case KVM_CAP_MP_STATE:
@@ -992,6 +991,9 @@ int kvm_dev_ioctl_check_extension(long ext)
992 case KVM_CAP_IOMMU: 991 case KVM_CAP_IOMMU:
993 r = iommu_found(); 992 r = iommu_found();
994 break; 993 break;
994 case KVM_CAP_CLOCKSOURCE:
995 r = boot_cpu_has(X86_FEATURE_CONSTANT_TSC);
996 break;
995 default: 997 default:
996 r = 0; 998 r = 0;
997 break; 999 break;
@@ -4127,9 +4129,13 @@ static void kvm_free_vcpus(struct kvm *kvm)
4127 4129
4128} 4130}
4129 4131
4130void kvm_arch_destroy_vm(struct kvm *kvm) 4132void kvm_arch_sync_events(struct kvm *kvm)
4131{ 4133{
4132 kvm_free_all_assigned_devices(kvm); 4134 kvm_free_all_assigned_devices(kvm);
4135}
4136
4137void kvm_arch_destroy_vm(struct kvm *kvm)
4138{
4133 kvm_iommu_unmap_guest(kvm); 4139 kvm_iommu_unmap_guest(kvm);
4134 kvm_free_pit(kvm); 4140 kvm_free_pit(kvm);
4135 kfree(kvm->arch.vpic); 4141 kfree(kvm->arch.vpic);
diff --git a/arch/x86/mach-default/setup.c b/arch/x86/mach-default/setup.c
index df167f265622..50b591871128 100644
--- a/arch/x86/mach-default/setup.c
+++ b/arch/x86/mach-default/setup.c
@@ -38,6 +38,15 @@ void __init pre_intr_init_hook(void)
38 init_ISA_irqs(); 38 init_ISA_irqs();
39} 39}
40 40
41/*
42 * IRQ2 is cascade interrupt to second interrupt controller
43 */
44static struct irqaction irq2 = {
45 .handler = no_action,
46 .mask = CPU_MASK_NONE,
47 .name = "cascade",
48};
49
41/** 50/**
42 * intr_init_hook - post gate setup interrupt initialisation 51 * intr_init_hook - post gate setup interrupt initialisation
43 * 52 *
@@ -53,6 +62,9 @@ void __init intr_init_hook(void)
53 if (x86_quirks->arch_intr_init()) 62 if (x86_quirks->arch_intr_init())
54 return; 63 return;
55 } 64 }
65 if (!acpi_ioapic)
66 setup_irq(2, &irq2);
67
56} 68}
57 69
58/** 70/**
@@ -84,7 +96,7 @@ void __init trap_init_hook(void)
84 96
85static struct irqaction irq0 = { 97static struct irqaction irq0 = {
86 .handler = timer_interrupt, 98 .handler = timer_interrupt,
87 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL, 99 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL | IRQF_TIMER,
88 .mask = CPU_MASK_NONE, 100 .mask = CPU_MASK_NONE,
89 .name = "timer" 101 .name = "timer"
90}; 102};
diff --git a/arch/x86/mach-voyager/setup.c b/arch/x86/mach-voyager/setup.c
index a580b9562e76..8e5118371f0f 100644
--- a/arch/x86/mach-voyager/setup.c
+++ b/arch/x86/mach-voyager/setup.c
@@ -33,20 +33,30 @@ void __init intr_init_hook(void)
33 setup_irq(2, &irq2); 33 setup_irq(2, &irq2);
34} 34}
35 35
36void __init pre_setup_arch_hook(void) 36static void voyager_disable_tsc(void)
37{ 37{
38 /* Voyagers run their CPUs from independent clocks, so disable 38 /* Voyagers run their CPUs from independent clocks, so disable
39 * the TSC code because we can't sync them */ 39 * the TSC code because we can't sync them */
40 setup_clear_cpu_cap(X86_FEATURE_TSC); 40 setup_clear_cpu_cap(X86_FEATURE_TSC);
41} 41}
42 42
43void __init pre_setup_arch_hook(void)
44{
45 voyager_disable_tsc();
46}
47
48void __init pre_time_init_hook(void)
49{
50 voyager_disable_tsc();
51}
52
43void __init trap_init_hook(void) 53void __init trap_init_hook(void)
44{ 54{
45} 55}
46 56
47static struct irqaction irq0 = { 57static struct irqaction irq0 = {
48 .handler = timer_interrupt, 58 .handler = timer_interrupt,
49 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL, 59 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL | IRQF_TIMER,
50 .mask = CPU_MASK_NONE, 60 .mask = CPU_MASK_NONE,
51 .name = "timer" 61 .name = "timer"
52}; 62};
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c
index 9840b7ec749a..7ffcdeec4631 100644
--- a/arch/x86/mach-voyager/voyager_smp.c
+++ b/arch/x86/mach-voyager/voyager_smp.c
@@ -81,7 +81,7 @@ static void enable_local_vic_irq(unsigned int irq);
81static void disable_local_vic_irq(unsigned int irq); 81static void disable_local_vic_irq(unsigned int irq);
82static void before_handle_vic_irq(unsigned int irq); 82static void before_handle_vic_irq(unsigned int irq);
83static void after_handle_vic_irq(unsigned int irq); 83static void after_handle_vic_irq(unsigned int irq);
84static void set_vic_irq_affinity(unsigned int irq, cpumask_t mask); 84static void set_vic_irq_affinity(unsigned int irq, const struct cpumask *mask);
85static void ack_vic_irq(unsigned int irq); 85static void ack_vic_irq(unsigned int irq);
86static void vic_enable_cpi(void); 86static void vic_enable_cpi(void);
87static void do_boot_cpu(__u8 cpuid); 87static void do_boot_cpu(__u8 cpuid);
@@ -211,8 +211,6 @@ static __u32 cpu_booted_map;
211static cpumask_t smp_commenced_mask = CPU_MASK_NONE; 211static cpumask_t smp_commenced_mask = CPU_MASK_NONE;
212 212
213/* This is for the new dynamic CPU boot code */ 213/* This is for the new dynamic CPU boot code */
214cpumask_t cpu_callin_map = CPU_MASK_NONE;
215cpumask_t cpu_callout_map = CPU_MASK_NONE;
216 214
217/* The per processor IRQ masks (these are usually kept in sync) */ 215/* The per processor IRQ masks (these are usually kept in sync) */
218static __u16 vic_irq_mask[NR_CPUS] __cacheline_aligned; 216static __u16 vic_irq_mask[NR_CPUS] __cacheline_aligned;
@@ -378,7 +376,7 @@ void __init find_smp_config(void)
378 cpus_addr(phys_cpu_present_map)[0] |= 376 cpus_addr(phys_cpu_present_map)[0] |=
379 voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK + 377 voyager_extended_cmos_read(VOYAGER_PROCESSOR_PRESENT_MASK +
380 3) << 24; 378 3) << 24;
381 cpu_possible_map = phys_cpu_present_map; 379 init_cpu_possible(&phys_cpu_present_map);
382 printk("VOYAGER SMP: phys_cpu_present_map = 0x%lx\n", 380 printk("VOYAGER SMP: phys_cpu_present_map = 0x%lx\n",
383 cpus_addr(phys_cpu_present_map)[0]); 381 cpus_addr(phys_cpu_present_map)[0]);
384 /* Here we set up the VIC to enable SMP */ 382 /* Here we set up the VIC to enable SMP */
@@ -1599,16 +1597,16 @@ static void after_handle_vic_irq(unsigned int irq)
1599 * change the mask and then do an interrupt enable CPI to re-enable on 1597 * change the mask and then do an interrupt enable CPI to re-enable on
1600 * the selected processors */ 1598 * the selected processors */
1601 1599
1602void set_vic_irq_affinity(unsigned int irq, cpumask_t mask) 1600void set_vic_irq_affinity(unsigned int irq, const struct cpumask *mask)
1603{ 1601{
1604 /* Only extended processors handle interrupts */ 1602 /* Only extended processors handle interrupts */
1605 unsigned long real_mask; 1603 unsigned long real_mask;
1606 unsigned long irq_mask = 1 << irq; 1604 unsigned long irq_mask = 1 << irq;
1607 int cpu; 1605 int cpu;
1608 1606
1609 real_mask = cpus_addr(mask)[0] & voyager_extended_vic_processors; 1607 real_mask = cpus_addr(*mask)[0] & voyager_extended_vic_processors;
1610 1608
1611 if (cpus_addr(mask)[0] == 0) 1609 if (cpus_addr(*mask)[0] == 0)
1612 /* can't have no CPUs to accept the interrupt -- extremely 1610 /* can't have no CPUs to accept the interrupt -- extremely
1613 * bad things will happen */ 1611 * bad things will happen */
1614 return; 1612 return;
@@ -1750,10 +1748,11 @@ static void __cpuinit voyager_smp_prepare_boot_cpu(void)
1750 init_gdt(smp_processor_id()); 1748 init_gdt(smp_processor_id());
1751 switch_to_new_gdt(); 1749 switch_to_new_gdt();
1752 1750
1753 cpu_set(smp_processor_id(), cpu_online_map); 1751 cpu_online_map = cpumask_of_cpu(smp_processor_id());
1754 cpu_set(smp_processor_id(), cpu_callout_map); 1752 cpu_callout_map = cpumask_of_cpu(smp_processor_id());
1755 cpu_set(smp_processor_id(), cpu_possible_map); 1753 cpu_callin_map = CPU_MASK_NONE;
1756 cpu_set(smp_processor_id(), cpu_present_map); 1754 cpu_present_map = cpumask_of_cpu(smp_processor_id());
1755
1757} 1756}
1758 1757
1759static int __cpuinit voyager_cpu_up(unsigned int cpu) 1758static int __cpuinit voyager_cpu_up(unsigned int cpu)
@@ -1783,9 +1782,9 @@ void __init smp_setup_processor_id(void)
1783 x86_write_percpu(cpu_number, hard_smp_processor_id()); 1782 x86_write_percpu(cpu_number, hard_smp_processor_id());
1784} 1783}
1785 1784
1786static void voyager_send_call_func(cpumask_t callmask) 1785static void voyager_send_call_func(const struct cpumask *callmask)
1787{ 1786{
1788 __u32 mask = cpus_addr(callmask)[0] & ~(1 << smp_processor_id()); 1787 __u32 mask = cpus_addr(*callmask)[0] & ~(1 << smp_processor_id());
1789 send_CPI(mask, VIC_CALL_FUNCTION_CPI); 1788 send_CPI(mask, VIC_CALL_FUNCTION_CPI);
1790} 1789}
1791 1790
diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c
index c7b06feb139b..5d87f586f8d7 100644
--- a/arch/x86/math-emu/fpu_entry.c
+++ b/arch/x86/math-emu/fpu_entry.c
@@ -131,7 +131,7 @@ u_char emulating = 0;
131static int valid_prefix(u_char *Byte, u_char __user ** fpu_eip, 131static int valid_prefix(u_char *Byte, u_char __user ** fpu_eip,
132 overrides * override); 132 overrides * override);
133 133
134asmlinkage void math_emulate(long arg) 134void math_emulate(struct math_emu_info *info)
135{ 135{
136 u_char FPU_modrm, byte1; 136 u_char FPU_modrm, byte1;
137 unsigned short code; 137 unsigned short code;
@@ -161,7 +161,7 @@ asmlinkage void math_emulate(long arg)
161 RE_ENTRANT_CHECK_ON; 161 RE_ENTRANT_CHECK_ON;
162#endif /* RE_ENTRANT_CHECKING */ 162#endif /* RE_ENTRANT_CHECKING */
163 163
164 SETUP_DATA_AREA(arg); 164 FPU_info = info;
165 165
166 FPU_ORIG_EIP = FPU_EIP; 166 FPU_ORIG_EIP = FPU_EIP;
167 167
@@ -659,7 +659,7 @@ static int valid_prefix(u_char *Byte, u_char __user **fpu_eip,
659 } 659 }
660} 660}
661 661
662void math_abort(struct info *info, unsigned int signal) 662void math_abort(struct math_emu_info *info, unsigned int signal)
663{ 663{
664 FPU_EIP = FPU_ORIG_EIP; 664 FPU_EIP = FPU_ORIG_EIP;
665 current->thread.trap_no = 16; 665 current->thread.trap_no = 16;
diff --git a/arch/x86/math-emu/fpu_proto.h b/arch/x86/math-emu/fpu_proto.h
index aa49b6a0d850..9779df436b7d 100644
--- a/arch/x86/math-emu/fpu_proto.h
+++ b/arch/x86/math-emu/fpu_proto.h
@@ -51,8 +51,8 @@ extern void ffreep(void);
51extern void fst_i_(void); 51extern void fst_i_(void);
52extern void fstp_i(void); 52extern void fstp_i(void);
53/* fpu_entry.c */ 53/* fpu_entry.c */
54asmlinkage extern void math_emulate(long arg); 54extern void math_emulate(struct math_emu_info *info);
55extern void math_abort(struct info *info, unsigned int signal); 55extern void math_abort(struct math_emu_info *info, unsigned int signal);
56/* fpu_etc.c */ 56/* fpu_etc.c */
57extern void FPU_etc(void); 57extern void FPU_etc(void);
58/* fpu_tags.c */ 58/* fpu_tags.c */
diff --git a/arch/x86/math-emu/fpu_system.h b/arch/x86/math-emu/fpu_system.h
index 13488fa153e0..50fa0ec2c8a5 100644
--- a/arch/x86/math-emu/fpu_system.h
+++ b/arch/x86/math-emu/fpu_system.h
@@ -16,10 +16,6 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18 18
19/* This sets the pointer FPU_info to point to the argument part
20 of the stack frame of math_emulate() */
21#define SETUP_DATA_AREA(arg) FPU_info = (struct info *) &arg
22
23/* s is always from a cpu register, and the cpu does bounds checking 19/* s is always from a cpu register, and the cpu does bounds checking
24 * during register load --> no further bounds checks needed */ 20 * during register load --> no further bounds checks needed */
25#define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3]) 21#define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.ldt)[(s) >> 3])
@@ -38,12 +34,12 @@
38#define I387 (current->thread.xstate) 34#define I387 (current->thread.xstate)
39#define FPU_info (I387->soft.info) 35#define FPU_info (I387->soft.info)
40 36
41#define FPU_CS (*(unsigned short *) &(FPU_info->___cs)) 37#define FPU_CS (*(unsigned short *) &(FPU_info->regs->cs))
42#define FPU_SS (*(unsigned short *) &(FPU_info->___ss)) 38#define FPU_SS (*(unsigned short *) &(FPU_info->regs->ss))
43#define FPU_DS (*(unsigned short *) &(FPU_info->___ds)) 39#define FPU_DS (*(unsigned short *) &(FPU_info->regs->ds))
44#define FPU_EAX (FPU_info->___eax) 40#define FPU_EAX (FPU_info->regs->ax)
45#define FPU_EFLAGS (FPU_info->___eflags) 41#define FPU_EFLAGS (FPU_info->regs->flags)
46#define FPU_EIP (FPU_info->___eip) 42#define FPU_EIP (FPU_info->regs->ip)
47#define FPU_ORIG_EIP (FPU_info->___orig_eip) 43#define FPU_ORIG_EIP (FPU_info->___orig_eip)
48 44
49#define FPU_lookahead (I387->soft.lookahead) 45#define FPU_lookahead (I387->soft.lookahead)
diff --git a/arch/x86/math-emu/get_address.c b/arch/x86/math-emu/get_address.c
index d701e2b39e44..420b3b6e3915 100644
--- a/arch/x86/math-emu/get_address.c
+++ b/arch/x86/math-emu/get_address.c
@@ -29,46 +29,43 @@
29#define FPU_WRITE_BIT 0x10 29#define FPU_WRITE_BIT 0x10
30 30
31static int reg_offset[] = { 31static int reg_offset[] = {
32 offsetof(struct info, ___eax), 32 offsetof(struct pt_regs, ax),
33 offsetof(struct info, ___ecx), 33 offsetof(struct pt_regs, cx),
34 offsetof(struct info, ___edx), 34 offsetof(struct pt_regs, dx),
35 offsetof(struct info, ___ebx), 35 offsetof(struct pt_regs, bx),
36 offsetof(struct info, ___esp), 36 offsetof(struct pt_regs, sp),
37 offsetof(struct info, ___ebp), 37 offsetof(struct pt_regs, bp),
38 offsetof(struct info, ___esi), 38 offsetof(struct pt_regs, si),
39 offsetof(struct info, ___edi) 39 offsetof(struct pt_regs, di)
40}; 40};
41 41
42#define REG_(x) (*(long *)(reg_offset[(x)]+(u_char *) FPU_info)) 42#define REG_(x) (*(long *)(reg_offset[(x)] + (u_char *)FPU_info->regs))
43 43
44static int reg_offset_vm86[] = { 44static int reg_offset_vm86[] = {
45 offsetof(struct info, ___cs), 45 offsetof(struct pt_regs, cs),
46 offsetof(struct info, ___vm86_ds), 46 offsetof(struct kernel_vm86_regs, ds),
47 offsetof(struct info, ___vm86_es), 47 offsetof(struct kernel_vm86_regs, es),
48 offsetof(struct info, ___vm86_fs), 48 offsetof(struct kernel_vm86_regs, fs),
49 offsetof(struct info, ___vm86_gs), 49 offsetof(struct kernel_vm86_regs, gs),
50 offsetof(struct info, ___ss), 50 offsetof(struct pt_regs, ss),
51 offsetof(struct info, ___vm86_ds) 51 offsetof(struct kernel_vm86_regs, ds)
52}; 52};
53 53
54#define VM86_REG_(x) (*(unsigned short *) \ 54#define VM86_REG_(x) (*(unsigned short *) \
55 (reg_offset_vm86[((unsigned)x)]+(u_char *) FPU_info)) 55 (reg_offset_vm86[((unsigned)x)] + (u_char *)FPU_info->regs))
56
57/* This dummy, gs is not saved on the stack. */
58#define ___GS ___ds
59 56
60static int reg_offset_pm[] = { 57static int reg_offset_pm[] = {
61 offsetof(struct info, ___cs), 58 offsetof(struct pt_regs, cs),
62 offsetof(struct info, ___ds), 59 offsetof(struct pt_regs, ds),
63 offsetof(struct info, ___es), 60 offsetof(struct pt_regs, es),
64 offsetof(struct info, ___fs), 61 offsetof(struct pt_regs, fs),
65 offsetof(struct info, ___GS), 62 offsetof(struct pt_regs, ds), /* dummy, not saved on stack */
66 offsetof(struct info, ___ss), 63 offsetof(struct pt_regs, ss),
67 offsetof(struct info, ___ds) 64 offsetof(struct pt_regs, ds)
68}; 65};
69 66
70#define PM_REG_(x) (*(unsigned short *) \ 67#define PM_REG_(x) (*(unsigned short *) \
71 (reg_offset_pm[((unsigned)x)]+(u_char *) FPU_info)) 68 (reg_offset_pm[((unsigned)x)] + (u_char *)FPU_info->regs))
72 69
73/* Decode the SIB byte. This function assumes mod != 0 */ 70/* Decode the SIB byte. This function assumes mod != 0 */
74static int sib(int mod, unsigned long *fpu_eip) 71static int sib(int mod, unsigned long *fpu_eip)
@@ -349,34 +346,34 @@ void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip,
349 } 346 }
350 switch (rm) { 347 switch (rm) {
351 case 0: 348 case 0:
352 address += FPU_info->___ebx + FPU_info->___esi; 349 address += FPU_info->regs->bx + FPU_info->regs->si;
353 break; 350 break;
354 case 1: 351 case 1:
355 address += FPU_info->___ebx + FPU_info->___edi; 352 address += FPU_info->regs->bx + FPU_info->regs->di;
356 break; 353 break;
357 case 2: 354 case 2:
358 address += FPU_info->___ebp + FPU_info->___esi; 355 address += FPU_info->regs->bp + FPU_info->regs->si;
359 if (addr_modes.override.segment == PREFIX_DEFAULT) 356 if (addr_modes.override.segment == PREFIX_DEFAULT)
360 addr_modes.override.segment = PREFIX_SS_; 357 addr_modes.override.segment = PREFIX_SS_;
361 break; 358 break;
362 case 3: 359 case 3:
363 address += FPU_info->___ebp + FPU_info->___edi; 360 address += FPU_info->regs->bp + FPU_info->regs->di;
364 if (addr_modes.override.segment == PREFIX_DEFAULT) 361 if (addr_modes.override.segment == PREFIX_DEFAULT)
365 addr_modes.override.segment = PREFIX_SS_; 362 addr_modes.override.segment = PREFIX_SS_;
366 break; 363 break;
367 case 4: 364 case 4:
368 address += FPU_info->___esi; 365 address += FPU_info->regs->si;
369 break; 366 break;
370 case 5: 367 case 5:
371 address += FPU_info->___edi; 368 address += FPU_info->regs->di;
372 break; 369 break;
373 case 6: 370 case 6:
374 address += FPU_info->___ebp; 371 address += FPU_info->regs->bp;
375 if (addr_modes.override.segment == PREFIX_DEFAULT) 372 if (addr_modes.override.segment == PREFIX_DEFAULT)
376 addr_modes.override.segment = PREFIX_SS_; 373 addr_modes.override.segment = PREFIX_SS_;
377 break; 374 break;
378 case 7: 375 case 7:
379 address += FPU_info->___ebx; 376 address += FPU_info->regs->bx;
380 break; 377 break;
381 } 378 }
382 379
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 90dfae511a41..c76ef1d701c9 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -603,8 +603,6 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
603 603
604 si_code = SEGV_MAPERR; 604 si_code = SEGV_MAPERR;
605 605
606 if (notify_page_fault(regs))
607 return;
608 if (unlikely(kmmio_fault(regs, address))) 606 if (unlikely(kmmio_fault(regs, address)))
609 return; 607 return;
610 608
@@ -634,6 +632,9 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
634 if (spurious_fault(address, error_code)) 632 if (spurious_fault(address, error_code))
635 return; 633 return;
636 634
635 /* kprobes don't want to hook the spurious faults. */
636 if (notify_page_fault(regs))
637 return;
637 /* 638 /*
638 * Don't take the mm semaphore here. If we fixup a prefetch 639 * Don't take the mm semaphore here. If we fixup a prefetch
639 * fault we could otherwise deadlock. 640 * fault we could otherwise deadlock.
@@ -641,6 +642,9 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
641 goto bad_area_nosemaphore; 642 goto bad_area_nosemaphore;
642 } 643 }
643 644
645 /* kprobes don't want to hook the spurious faults. */
646 if (notify_page_fault(regs))
647 return;
644 648
645 /* 649 /*
646 * It's safe to allow irq's after cr2 has been saved and the 650 * It's safe to allow irq's after cr2 has been saved and the
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index af750ab973b6..f45d5e29a72e 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -134,25 +134,6 @@ int page_is_ram(unsigned long pagenr)
134 return 0; 134 return 0;
135} 135}
136 136
137int pagerange_is_ram(unsigned long start, unsigned long end)
138{
139 int ram_page = 0, not_rampage = 0;
140 unsigned long page_nr;
141
142 for (page_nr = (start >> PAGE_SHIFT); page_nr < (end >> PAGE_SHIFT);
143 ++page_nr) {
144 if (page_is_ram(page_nr))
145 ram_page = 1;
146 else
147 not_rampage = 1;
148
149 if (ram_page == not_rampage)
150 return -1;
151 }
152
153 return ram_page;
154}
155
156/* 137/*
157 * Fix up the linear direct mapping of the kernel to avoid cache attribute 138 * Fix up the linear direct mapping of the kernel to avoid cache attribute
158 * conflicts. 139 * conflicts.
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index 71a14f89f89e..f3516da035d1 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -145,7 +145,7 @@ int __init compute_hash_shift(struct bootnode *nodes, int numnodes,
145 return shift; 145 return shift;
146} 146}
147 147
148int early_pfn_to_nid(unsigned long pfn) 148int __meminit __early_pfn_to_nid(unsigned long pfn)
149{ 149{
150 return phys_to_nid(pfn << PAGE_SHIFT); 150 return phys_to_nid(pfn << PAGE_SHIFT);
151} 151}
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 84ba74820ad6..7be47d1a97e4 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -508,18 +508,13 @@ static int split_large_page(pte_t *kpte, unsigned long address)
508#endif 508#endif
509 509
510 /* 510 /*
511 * Install the new, split up pagetable. Important details here: 511 * Install the new, split up pagetable.
512 * 512 *
513 * On Intel the NX bit of all levels must be cleared to make a 513 * We use the standard kernel pagetable protections for the new
514 * page executable. See section 4.13.2 of Intel 64 and IA-32 514 * pagetable protections, the actual ptes set above control the
515 * Architectures Software Developer's Manual). 515 * primary protection behavior:
516 *
517 * Mark the entry present. The current mapping might be
518 * set to not present, which we preserved above.
519 */ 516 */
520 ref_prot = pte_pgprot(pte_mkexec(pte_clrhuge(*kpte))); 517 __set_pmd_pte(kpte, address, mk_pte(base, __pgprot(_KERNPG_TABLE)));
521 pgprot_val(ref_prot) |= _PAGE_PRESENT;
522 __set_pmd_pte(kpte, address, mk_pte(base, ref_prot));
523 base = NULL; 518 base = NULL;
524 519
525out_unlock: 520out_unlock:
@@ -575,7 +570,6 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
575 address = cpa->vaddr[cpa->curpage]; 570 address = cpa->vaddr[cpa->curpage];
576 else 571 else
577 address = *cpa->vaddr; 572 address = *cpa->vaddr;
578
579repeat: 573repeat:
580 kpte = lookup_address(address, &level); 574 kpte = lookup_address(address, &level);
581 if (!kpte) 575 if (!kpte)
@@ -812,6 +806,13 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
812 806
813 vm_unmap_aliases(); 807 vm_unmap_aliases();
814 808
809 /*
810 * If we're called with lazy mmu updates enabled, the
811 * in-memory pte state may be stale. Flush pending updates to
812 * bring them up to date.
813 */
814 arch_flush_lazy_mmu_mode();
815
815 cpa.vaddr = addr; 816 cpa.vaddr = addr;
816 cpa.numpages = numpages; 817 cpa.numpages = numpages;
817 cpa.mask_set = mask_set; 818 cpa.mask_set = mask_set;
@@ -854,6 +855,13 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
854 } else 855 } else
855 cpa_flush_all(cache); 856 cpa_flush_all(cache);
856 857
858 /*
859 * If we've been called with lazy mmu updates enabled, then
860 * make sure that everything gets flushed out before we
861 * return.
862 */
863 arch_flush_lazy_mmu_mode();
864
857out: 865out:
858 return ret; 866 return ret;
859} 867}
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 7b61036427df..aebbf67a79d0 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -211,6 +211,33 @@ chk_conflict(struct memtype *new, struct memtype *entry, unsigned long *type)
211static struct memtype *cached_entry; 211static struct memtype *cached_entry;
212static u64 cached_start; 212static u64 cached_start;
213 213
214static int pat_pagerange_is_ram(unsigned long start, unsigned long end)
215{
216 int ram_page = 0, not_rampage = 0;
217 unsigned long page_nr;
218
219 for (page_nr = (start >> PAGE_SHIFT); page_nr < (end >> PAGE_SHIFT);
220 ++page_nr) {
221 /*
222 * For legacy reasons, physical address range in the legacy ISA
223 * region is tracked as non-RAM. This will allow users of
224 * /dev/mem to map portions of legacy ISA region, even when
225 * some of those portions are listed(or not even listed) with
226 * different e820 types(RAM/reserved/..)
227 */
228 if (page_nr >= (ISA_END_ADDRESS >> PAGE_SHIFT) &&
229 page_is_ram(page_nr))
230 ram_page = 1;
231 else
232 not_rampage = 1;
233
234 if (ram_page == not_rampage)
235 return -1;
236 }
237
238 return ram_page;
239}
240
214/* 241/*
215 * For RAM pages, mark the pages as non WB memory type using 242 * For RAM pages, mark the pages as non WB memory type using
216 * PageNonWB (PG_arch_1). We allow only one set_memory_uc() or 243 * PageNonWB (PG_arch_1). We allow only one set_memory_uc() or
@@ -336,20 +363,12 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
336 if (new_type) 363 if (new_type)
337 *new_type = actual_type; 364 *new_type = actual_type;
338 365
339 /* 366 is_range_ram = pat_pagerange_is_ram(start, end);
340 * For legacy reasons, some parts of the physical address range in the 367 if (is_range_ram == 1)
341 * legacy 1MB region is treated as non-RAM (even when listed as RAM in 368 return reserve_ram_pages_type(start, end, req_type,
342 * the e820 tables). So we will track the memory attributes of this 369 new_type);
343 * legacy 1MB region using the linear memtype_list always. 370 else if (is_range_ram < 0)
344 */ 371 return -EINVAL;
345 if (end >= ISA_END_ADDRESS) {
346 is_range_ram = pagerange_is_ram(start, end);
347 if (is_range_ram == 1)
348 return reserve_ram_pages_type(start, end, req_type,
349 new_type);
350 else if (is_range_ram < 0)
351 return -EINVAL;
352 }
353 372
354 new = kmalloc(sizeof(struct memtype), GFP_KERNEL); 373 new = kmalloc(sizeof(struct memtype), GFP_KERNEL);
355 if (!new) 374 if (!new)
@@ -446,19 +465,11 @@ int free_memtype(u64 start, u64 end)
446 if (is_ISA_range(start, end - 1)) 465 if (is_ISA_range(start, end - 1))
447 return 0; 466 return 0;
448 467
449 /* 468 is_range_ram = pat_pagerange_is_ram(start, end);
450 * For legacy reasons, some parts of the physical address range in the 469 if (is_range_ram == 1)
451 * legacy 1MB region is treated as non-RAM (even when listed as RAM in 470 return free_ram_pages_type(start, end);
452 * the e820 tables). So we will track the memory attributes of this 471 else if (is_range_ram < 0)
453 * legacy 1MB region using the linear memtype_list always. 472 return -EINVAL;
454 */
455 if (end >= ISA_END_ADDRESS) {
456 is_range_ram = pagerange_is_ram(start, end);
457 if (is_range_ram == 1)
458 return free_ram_pages_type(start, end);
459 else if (is_range_ram < 0)
460 return -EINVAL;
461 }
462 473
463 spin_lock(&memtype_lock); 474 spin_lock(&memtype_lock);
464 list_for_each_entry(entry, &memtype_list, nd) { 475 list_for_each_entry(entry, &memtype_list, nd) {
@@ -626,17 +637,13 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
626 unsigned long flags; 637 unsigned long flags;
627 unsigned long want_flags = (pgprot_val(*vma_prot) & _PAGE_CACHE_MASK); 638 unsigned long want_flags = (pgprot_val(*vma_prot) & _PAGE_CACHE_MASK);
628 639
629 is_ram = pagerange_is_ram(paddr, paddr + size); 640 is_ram = pat_pagerange_is_ram(paddr, paddr + size);
630 641
631 if (is_ram != 0) { 642 /*
632 /* 643 * reserve_pfn_range() doesn't support RAM pages.
633 * For mapping RAM pages, drivers need to call 644 */
634 * set_memory_[uc|wc|wb] directly, for reserve and free, before 645 if (is_ram != 0)
635 * setting up the PTE. 646 return -EINVAL;
636 */
637 WARN_ON_ONCE(1);
638 return 0;
639 }
640 647
641 ret = reserve_memtype(paddr, paddr + size, want_flags, &flags); 648 ret = reserve_memtype(paddr, paddr + size, want_flags, &flags);
642 if (ret) 649 if (ret)
@@ -693,7 +700,7 @@ static void free_pfn_range(u64 paddr, unsigned long size)
693{ 700{
694 int is_ram; 701 int is_ram;
695 702
696 is_ram = pagerange_is_ram(paddr, paddr + size); 703 is_ram = pat_pagerange_is_ram(paddr, paddr + size);
697 if (is_ram == 0) 704 if (is_ram == 0)
698 free_memtype(paddr, paddr + size); 705 free_memtype(paddr, paddr + size);
699} 706}
diff --git a/arch/x86/xen/multicalls.h b/arch/x86/xen/multicalls.h
index 858938241616..fa3e10725d98 100644
--- a/arch/x86/xen/multicalls.h
+++ b/arch/x86/xen/multicalls.h
@@ -19,8 +19,10 @@ DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags);
19 paired with xen_mc_issue() */ 19 paired with xen_mc_issue() */
20static inline void xen_mc_batch(void) 20static inline void xen_mc_batch(void)
21{ 21{
22 unsigned long flags;
22 /* need to disable interrupts until this entry is complete */ 23 /* need to disable interrupts until this entry is complete */
23 local_irq_save(__get_cpu_var(xen_mc_irq_flags)); 24 local_irq_save(flags);
25 __get_cpu_var(xen_mc_irq_flags) = flags;
24} 26}
25 27
26static inline struct multicall_space xen_mc_entry(size_t args) 28static inline struct multicall_space xen_mc_entry(size_t args)
diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index a09535377a94..bbbdc4b8ccf2 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -209,12 +209,19 @@ void blk_abort_queue(struct request_queue *q)
209{ 209{
210 unsigned long flags; 210 unsigned long flags;
211 struct request *rq, *tmp; 211 struct request *rq, *tmp;
212 LIST_HEAD(list);
212 213
213 spin_lock_irqsave(q->queue_lock, flags); 214 spin_lock_irqsave(q->queue_lock, flags);
214 215
215 elv_abort_queue(q); 216 elv_abort_queue(q);
216 217
217 list_for_each_entry_safe(rq, tmp, &q->timeout_list, timeout_list) 218 /*
219 * Splice entries to local list, to avoid deadlocking if entries
220 * get readded to the timeout list by error handling
221 */
222 list_splice_init(&q->timeout_list, &list);
223
224 list_for_each_entry_safe(rq, tmp, &list, timeout_list)
218 blk_abort_request(rq); 225 blk_abort_request(rq);
219 226
220 spin_unlock_irqrestore(q->queue_lock, flags); 227 spin_unlock_irqrestore(q->queue_lock, flags);
diff --git a/block/blktrace.c b/block/blktrace.c
index 39cc3bfe56e4..7cf9d1ff45a0 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -142,7 +142,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
142 142
143 what |= ddir_act[rw & WRITE]; 143 what |= ddir_act[rw & WRITE];
144 what |= MASK_TC_BIT(rw, BARRIER); 144 what |= MASK_TC_BIT(rw, BARRIER);
145 what |= MASK_TC_BIT(rw, SYNC); 145 what |= MASK_TC_BIT(rw, SYNCIO);
146 what |= MASK_TC_BIT(rw, AHEAD); 146 what |= MASK_TC_BIT(rw, AHEAD);
147 what |= MASK_TC_BIT(rw, META); 147 what |= MASK_TC_BIT(rw, META);
148 what |= MASK_TC_BIT(rw, DISCARD); 148 what |= MASK_TC_BIT(rw, DISCARD);
diff --git a/block/bsg.c b/block/bsg.c
index d414bb5607e8..0ce8806dd0c1 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -244,7 +244,8 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw)
244 * map sg_io_v4 to a request. 244 * map sg_io_v4 to a request.
245 */ 245 */
246static struct request * 246static struct request *
247bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm) 247bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
248 u8 *sense)
248{ 249{
249 struct request_queue *q = bd->queue; 250 struct request_queue *q = bd->queue;
250 struct request *rq, *next_rq = NULL; 251 struct request *rq, *next_rq = NULL;
@@ -306,6 +307,10 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)
306 if (ret) 307 if (ret)
307 goto out; 308 goto out;
308 } 309 }
310
311 rq->sense = sense;
312 rq->sense_len = 0;
313
309 return rq; 314 return rq;
310out: 315out:
311 if (rq->cmd != rq->__cmd) 316 if (rq->cmd != rq->__cmd)
@@ -348,9 +353,6 @@ static void bsg_rq_end_io(struct request *rq, int uptodate)
348static void bsg_add_command(struct bsg_device *bd, struct request_queue *q, 353static void bsg_add_command(struct bsg_device *bd, struct request_queue *q,
349 struct bsg_command *bc, struct request *rq) 354 struct bsg_command *bc, struct request *rq)
350{ 355{
351 rq->sense = bc->sense;
352 rq->sense_len = 0;
353
354 /* 356 /*
355 * add bc command to busy queue and submit rq for io 357 * add bc command to busy queue and submit rq for io
356 */ 358 */
@@ -419,7 +421,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
419{ 421{
420 int ret = 0; 422 int ret = 0;
421 423
422 dprintk("rq %p bio %p %u\n", rq, bio, rq->errors); 424 dprintk("rq %p bio %p 0x%x\n", rq, bio, rq->errors);
423 /* 425 /*
424 * fill in all the output members 426 * fill in all the output members
425 */ 427 */
@@ -635,7 +637,7 @@ static int __bsg_write(struct bsg_device *bd, const char __user *buf,
635 /* 637 /*
636 * get a request, fill in the blanks, and add to request queue 638 * get a request, fill in the blanks, and add to request queue
637 */ 639 */
638 rq = bsg_map_hdr(bd, &bc->hdr, has_write_perm); 640 rq = bsg_map_hdr(bd, &bc->hdr, has_write_perm, bc->sense);
639 if (IS_ERR(rq)) { 641 if (IS_ERR(rq)) {
640 ret = PTR_ERR(rq); 642 ret = PTR_ERR(rq);
641 rq = NULL; 643 rq = NULL;
@@ -922,11 +924,12 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
922 struct request *rq; 924 struct request *rq;
923 struct bio *bio, *bidi_bio = NULL; 925 struct bio *bio, *bidi_bio = NULL;
924 struct sg_io_v4 hdr; 926 struct sg_io_v4 hdr;
927 u8 sense[SCSI_SENSE_BUFFERSIZE];
925 928
926 if (copy_from_user(&hdr, uarg, sizeof(hdr))) 929 if (copy_from_user(&hdr, uarg, sizeof(hdr)))
927 return -EFAULT; 930 return -EFAULT;
928 931
929 rq = bsg_map_hdr(bd, &hdr, file->f_mode & FMODE_WRITE); 932 rq = bsg_map_hdr(bd, &hdr, file->f_mode & FMODE_WRITE, sense);
930 if (IS_ERR(rq)) 933 if (IS_ERR(rq))
931 return PTR_ERR(rq); 934 return PTR_ERR(rq);
932 935
diff --git a/block/genhd.c b/block/genhd.c
index 397960cf26af..e1eadcc9546a 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1087,6 +1087,14 @@ dev_t blk_lookup_devt(const char *name, int partno)
1087 if (strcmp(dev_name(dev), name)) 1087 if (strcmp(dev_name(dev), name))
1088 continue; 1088 continue;
1089 1089
1090 if (partno < disk->minors) {
1091 /* We need to return the right devno, even
1092 * if the partition doesn't exist yet.
1093 */
1094 devt = MKDEV(MAJOR(dev->devt),
1095 MINOR(dev->devt) + partno);
1096 break;
1097 }
1090 part = disk_get_part(disk, partno); 1098 part = disk_get_part(disk, partno);
1091 if (part) { 1099 if (part) {
1092 devt = part_devt(part); 1100 devt = part_devt(part);
diff --git a/crypto/ahash.c b/crypto/ahash.c
index ba5292d69ebd..b2d1ee32cfe8 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -214,7 +214,7 @@ static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg)
214 seq_printf(m, "async : %s\n", alg->cra_flags & CRYPTO_ALG_ASYNC ? 214 seq_printf(m, "async : %s\n", alg->cra_flags & CRYPTO_ALG_ASYNC ?
215 "yes" : "no"); 215 "yes" : "no");
216 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); 216 seq_printf(m, "blocksize : %u\n", alg->cra_blocksize);
217 seq_printf(m, "digestsize : %u\n", alg->cra_hash.digestsize); 217 seq_printf(m, "digestsize : %u\n", alg->cra_ahash.digestsize);
218} 218}
219 219
220const struct crypto_type crypto_ahash_type = { 220const struct crypto_type crypto_ahash_type = {
diff --git a/crypto/algapi.c b/crypto/algapi.c
index 7c41e7405c41..56c62e2858d5 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -149,6 +149,9 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
149 if (q == alg) 149 if (q == alg)
150 goto err; 150 goto err;
151 151
152 if (crypto_is_moribund(q))
153 continue;
154
152 if (crypto_is_larval(q)) { 155 if (crypto_is_larval(q)) {
153 if (!strcmp(alg->cra_driver_name, q->cra_driver_name)) 156 if (!strcmp(alg->cra_driver_name, q->cra_driver_name))
154 goto err; 157 goto err;
@@ -197,7 +200,7 @@ void crypto_alg_tested(const char *name, int err)
197 200
198 down_write(&crypto_alg_sem); 201 down_write(&crypto_alg_sem);
199 list_for_each_entry(q, &crypto_alg_list, cra_list) { 202 list_for_each_entry(q, &crypto_alg_list, cra_list) {
200 if (!crypto_is_larval(q)) 203 if (crypto_is_moribund(q) || !crypto_is_larval(q))
201 continue; 204 continue;
202 205
203 test = (struct crypto_larval *)q; 206 test = (struct crypto_larval *)q;
@@ -210,6 +213,7 @@ void crypto_alg_tested(const char *name, int err)
210 goto unlock; 213 goto unlock;
211 214
212found: 215found:
216 q->cra_flags |= CRYPTO_ALG_DEAD;
213 alg = test->adult; 217 alg = test->adult;
214 if (err || list_empty(&alg->cra_list)) 218 if (err || list_empty(&alg->cra_list))
215 goto complete; 219 goto complete;
diff --git a/crypto/api.c b/crypto/api.c
index 9975a7bd246c..efe77df6863f 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -557,34 +557,34 @@ err:
557 return ERR_PTR(err); 557 return ERR_PTR(err);
558} 558}
559EXPORT_SYMBOL_GPL(crypto_alloc_tfm); 559EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
560 560
561/* 561/*
562 * crypto_free_tfm - Free crypto transform 562 * crypto_destroy_tfm - Free crypto transform
563 * @mem: Start of tfm slab
563 * @tfm: Transform to free 564 * @tfm: Transform to free
564 * 565 *
565 * crypto_free_tfm() frees up the transform and any associated resources, 566 * This function frees up the transform and any associated resources,
566 * then drops the refcount on the associated algorithm. 567 * then drops the refcount on the associated algorithm.
567 */ 568 */
568void crypto_free_tfm(struct crypto_tfm *tfm) 569void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
569{ 570{
570 struct crypto_alg *alg; 571 struct crypto_alg *alg;
571 int size; 572 int size;
572 573
573 if (unlikely(!tfm)) 574 if (unlikely(!mem))
574 return; 575 return;
575 576
576 alg = tfm->__crt_alg; 577 alg = tfm->__crt_alg;
577 size = sizeof(*tfm) + alg->cra_ctxsize; 578 size = ksize(mem);
578 579
579 if (!tfm->exit && alg->cra_exit) 580 if (!tfm->exit && alg->cra_exit)
580 alg->cra_exit(tfm); 581 alg->cra_exit(tfm);
581 crypto_exit_ops(tfm); 582 crypto_exit_ops(tfm);
582 crypto_mod_put(alg); 583 crypto_mod_put(alg);
583 memset(tfm, 0, size); 584 memset(mem, 0, size);
584 kfree(tfm); 585 kfree(mem);
585} 586}
586 587EXPORT_SYMBOL_GPL(crypto_destroy_tfm);
587EXPORT_SYMBOL_GPL(crypto_free_tfm);
588 588
589int crypto_has_alg(const char *name, u32 type, u32 mask) 589int crypto_has_alg(const char *name, u32 type, u32 mask)
590{ 590{
diff --git a/crypto/lrw.c b/crypto/lrw.c
index 8ef664e3bcd9..358f80be2bf9 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -45,7 +45,13 @@ struct priv {
45 45
46static inline void setbit128_bbe(void *b, int bit) 46static inline void setbit128_bbe(void *b, int bit)
47{ 47{
48 __set_bit(bit ^ 0x78, b); 48 __set_bit(bit ^ (0x80 -
49#ifdef __BIG_ENDIAN
50 BITS_PER_LONG
51#else
52 BITS_PER_BYTE
53#endif
54 ), b);
49} 55}
50 56
51static int setkey(struct crypto_tfm *parent, const u8 *key, 57static int setkey(struct crypto_tfm *parent, const u8 *key,
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c
index 9aeeb52004a5..3de89a424401 100644
--- a/crypto/scatterwalk.c
+++ b/crypto/scatterwalk.c
@@ -54,7 +54,8 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
54 struct page *page; 54 struct page *page;
55 55
56 page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); 56 page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT);
57 flush_dcache_page(page); 57 if (!PageSlab(page))
58 flush_dcache_page(page);
58 } 59 }
59 60
60 if (more) { 61 if (more) {
diff --git a/crypto/shash.c b/crypto/shash.c
index c9df367332ff..d5a2b619c55f 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -388,10 +388,15 @@ static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm)
388 struct shash_desc *desc = crypto_tfm_ctx(tfm); 388 struct shash_desc *desc = crypto_tfm_ctx(tfm);
389 struct crypto_shash *shash; 389 struct crypto_shash *shash;
390 390
391 if (!crypto_mod_get(calg))
392 return -EAGAIN;
393
391 shash = __crypto_shash_cast(crypto_create_tfm( 394 shash = __crypto_shash_cast(crypto_create_tfm(
392 calg, &crypto_shash_type)); 395 calg, &crypto_shash_type));
393 if (IS_ERR(shash)) 396 if (IS_ERR(shash)) {
397 crypto_mod_put(calg);
394 return PTR_ERR(shash); 398 return PTR_ERR(shash);
399 }
395 400
396 desc->tfm = shash; 401 desc->tfm = shash;
397 tfm->exit = crypto_exit_shash_ops_compat; 402 tfm->exit = crypto_exit_shash_ops_compat;
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index d7f9839ba264..8a851d0f4384 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -9,6 +9,7 @@ menuconfig ACPI
9 depends on PCI 9 depends on PCI
10 depends on PM 10 depends on PM
11 select PNP 11 select PNP
12 select CPU_IDLE
12 default y 13 default y
13 ---help--- 14 ---help---
14 Advanced Configuration and Power Interface (ACPI) support for 15 Advanced Configuration and Power Interface (ACPI) support for
@@ -253,13 +254,6 @@ config ACPI_PCI_SLOT
253 help you correlate PCI bus addresses with the physical geography 254 help you correlate PCI bus addresses with the physical geography
254 of your slots. If you are unsure, say N. 255 of your slots. If you are unsure, say N.
255 256
256config ACPI_SYSTEM
257 bool
258 default y
259 help
260 This driver will enable your system to shut down using ACPI, and
261 dump your ACPI DSDT table using /proc/acpi/dsdt.
262
263config X86_PM_TIMER 257config X86_PM_TIMER
264 bool "Power Management Timer Support" if EMBEDDED 258 bool "Power Management Timer Support" if EMBEDDED
265 depends on X86 259 depends on X86
@@ -287,7 +281,7 @@ config ACPI_CONTAINER
287 support physical cpu/memory hot-plug. 281 support physical cpu/memory hot-plug.
288 282
289 If one selects "m", this driver can be loaded with 283 If one selects "m", this driver can be loaded with
290 "modprobe acpi_container". 284 "modprobe container".
291 285
292config ACPI_HOTPLUG_MEMORY 286config ACPI_HOTPLUG_MEMORY
293 tristate "Memory Hotplug" 287 tristate "Memory Hotplug"
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 65d90c720b5a..b130ea0d0759 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -52,7 +52,7 @@ obj-$(CONFIG_ACPI_PROCESSOR) += processor.o
52obj-$(CONFIG_ACPI_CONTAINER) += container.o 52obj-$(CONFIG_ACPI_CONTAINER) += container.o
53obj-$(CONFIG_ACPI_THERMAL) += thermal.o 53obj-$(CONFIG_ACPI_THERMAL) += thermal.o
54obj-y += power.o 54obj-y += power.o
55obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o 55obj-y += system.o event.o
56obj-$(CONFIG_ACPI_DEBUG) += debug.o 56obj-$(CONFIG_ACPI_DEBUG) += debug.o
57obj-$(CONFIG_ACPI_NUMA) += numa.o 57obj-$(CONFIG_ACPI_NUMA) += numa.o
58obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o 58obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 9684cc827930..22ce48985720 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -538,10 +538,9 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
538 if (ACPI_FAILURE(status)) { 538 if (ACPI_FAILURE(status)) {
539 ACPI_WARNING((AE_INFO, 539 ACPI_WARNING((AE_INFO,
540 "Truncating %u table entries!", 540 "Truncating %u table entries!",
541 (unsigned) 541 (unsigned) (table_count -
542 (acpi_gbl_root_table_list.size - 542 (acpi_gbl_root_table_list.
543 acpi_gbl_root_table_list. 543 count - 2))));
544 count)));
545 break; 544 break;
546 } 545 }
547 } 546 }
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index da9450bc60f7..9c9897dbe907 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -116,9 +116,9 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
116 return_ACPI_STATUS(AE_NO_MEMORY); 116 return_ACPI_STATUS(AE_NO_MEMORY);
117 } 117 }
118 118
119 /* Default return value is SUPPORTED */ 119 /* Default return value is 0, NOT-SUPPORTED */
120 120
121 return_desc->integer.value = ACPI_UINT32_MAX; 121 return_desc->integer.value = 0;
122 walk_state->return_desc = return_desc; 122 walk_state->return_desc = return_desc;
123 123
124 /* Compare input string to static table of supported interfaces */ 124 /* Compare input string to static table of supported interfaces */
@@ -127,10 +127,8 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
127 if (!ACPI_STRCMP 127 if (!ACPI_STRCMP
128 (string_desc->string.pointer, 128 (string_desc->string.pointer,
129 acpi_interfaces_supported[i])) { 129 acpi_interfaces_supported[i])) {
130 130 return_desc->integer.value = ACPI_UINT32_MAX;
131 /* The interface is supported */ 131 goto done;
132
133 return_ACPI_STATUS(AE_OK);
134 } 132 }
135 } 133 }
136 134
@@ -141,15 +139,14 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
141 */ 139 */
142 status = acpi_os_validate_interface(string_desc->string.pointer); 140 status = acpi_os_validate_interface(string_desc->string.pointer);
143 if (ACPI_SUCCESS(status)) { 141 if (ACPI_SUCCESS(status)) {
144 142 return_desc->integer.value = ACPI_UINT32_MAX;
145 /* The interface is supported */
146
147 return_ACPI_STATUS(AE_OK);
148 } 143 }
149 144
150 /* The interface is not supported */ 145done:
146 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, "ACPI: BIOS _OSI(%s) %ssupported\n",
147 string_desc->string.pointer,
148 return_desc->integer.value == 0 ? "not-" : ""));
151 149
152 return_desc->integer.value = 0;
153 return_ACPI_STATUS(AE_OK); 150 return_ACPI_STATUS(AE_OK);
154} 151}
155 152
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 65132f920459..69cbc57c2d1c 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -138,6 +138,29 @@ static int acpi_battery_technology(struct acpi_battery *battery)
138 138
139static int acpi_battery_get_state(struct acpi_battery *battery); 139static int acpi_battery_get_state(struct acpi_battery *battery);
140 140
141static int acpi_battery_is_charged(struct acpi_battery *battery)
142{
143 /* either charging or discharging */
144 if (battery->state != 0)
145 return 0;
146
147 /* battery not reporting charge */
148 if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN ||
149 battery->capacity_now == 0)
150 return 0;
151
152 /* good batteries update full_charge as the batteries degrade */
153 if (battery->full_charge_capacity == battery->capacity_now)
154 return 1;
155
156 /* fallback to using design values for broken batteries */
157 if (battery->design_capacity == battery->capacity_now)
158 return 1;
159
160 /* we don't do any sort of metric based on percentages */
161 return 0;
162}
163
141static int acpi_battery_get_property(struct power_supply *psy, 164static int acpi_battery_get_property(struct power_supply *psy,
142 enum power_supply_property psp, 165 enum power_supply_property psp,
143 union power_supply_propval *val) 166 union power_supply_propval *val)
@@ -155,7 +178,7 @@ static int acpi_battery_get_property(struct power_supply *psy,
155 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; 178 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
156 else if (battery->state & 0x02) 179 else if (battery->state & 0x02)
157 val->intval = POWER_SUPPLY_STATUS_CHARGING; 180 val->intval = POWER_SUPPLY_STATUS_CHARGING;
158 else if (battery->state == 0) 181 else if (acpi_battery_is_charged(battery))
159 val->intval = POWER_SUPPLY_STATUS_FULL; 182 val->intval = POWER_SUPPLY_STATUS_FULL;
160 else 183 else
161 val->intval = POWER_SUPPLY_STATUS_UNKNOWN; 184 val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 17020c12623c..fe0cdf83641a 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -163,7 +163,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
163 case ACPI_NOTIFY_BUS_CHECK: 163 case ACPI_NOTIFY_BUS_CHECK:
164 /* Fall through */ 164 /* Fall through */
165 case ACPI_NOTIFY_DEVICE_CHECK: 165 case ACPI_NOTIFY_DEVICE_CHECK:
166 printk("Container driver received %s event\n", 166 printk(KERN_WARNING "Container driver received %s event\n",
167 (type == ACPI_NOTIFY_BUS_CHECK) ? 167 (type == ACPI_NOTIFY_BUS_CHECK) ?
168 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); 168 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
169 status = acpi_bus_get_device(handle, &device); 169 status = acpi_bus_get_device(handle, &device);
@@ -174,7 +174,8 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
174 kobject_uevent(&device->dev.kobj, 174 kobject_uevent(&device->dev.kobj,
175 KOBJ_ONLINE); 175 KOBJ_ONLINE);
176 else 176 else
177 printk("Failed to add container\n"); 177 printk(KERN_WARNING
178 "Failed to add container\n");
178 } 179 }
179 } else { 180 } else {
180 if (ACPI_SUCCESS(status)) { 181 if (ACPI_SUCCESS(status)) {
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 5b30b8d91d71..35094f230b1e 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -855,10 +855,14 @@ fdd_out:
855static ssize_t show_docked(struct device *dev, 855static ssize_t show_docked(struct device *dev,
856 struct device_attribute *attr, char *buf) 856 struct device_attribute *attr, char *buf)
857{ 857{
858 struct acpi_device *tmp;
859
858 struct dock_station *dock_station = *((struct dock_station **) 860 struct dock_station *dock_station = *((struct dock_station **)
859 dev->platform_data); 861 dev->platform_data);
860 return snprintf(buf, PAGE_SIZE, "%d\n", dock_present(dock_station));
861 862
863 if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp)))
864 return snprintf(buf, PAGE_SIZE, "1\n");
865 return snprintf(buf, PAGE_SIZE, "0\n");
862} 866}
863static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); 867static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
864 868
@@ -984,7 +988,7 @@ static int dock_add(acpi_handle handle)
984 988
985 ret = device_create_file(&dock_device->dev, &dev_attr_docked); 989 ret = device_create_file(&dock_device->dev, &dev_attr_docked);
986 if (ret) { 990 if (ret) {
987 printk("Error %d adding sysfs file\n", ret); 991 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
988 platform_device_unregister(dock_device); 992 platform_device_unregister(dock_device);
989 kfree(dock_station); 993 kfree(dock_station);
990 dock_station = NULL; 994 dock_station = NULL;
@@ -992,7 +996,7 @@ static int dock_add(acpi_handle handle)
992 } 996 }
993 ret = device_create_file(&dock_device->dev, &dev_attr_undock); 997 ret = device_create_file(&dock_device->dev, &dev_attr_undock);
994 if (ret) { 998 if (ret) {
995 printk("Error %d adding sysfs file\n", ret); 999 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
996 device_remove_file(&dock_device->dev, &dev_attr_docked); 1000 device_remove_file(&dock_device->dev, &dev_attr_docked);
997 platform_device_unregister(dock_device); 1001 platform_device_unregister(dock_device);
998 kfree(dock_station); 1002 kfree(dock_station);
@@ -1001,7 +1005,7 @@ static int dock_add(acpi_handle handle)
1001 } 1005 }
1002 ret = device_create_file(&dock_device->dev, &dev_attr_uid); 1006 ret = device_create_file(&dock_device->dev, &dev_attr_uid);
1003 if (ret) { 1007 if (ret) {
1004 printk("Error %d adding sysfs file\n", ret); 1008 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1005 device_remove_file(&dock_device->dev, &dev_attr_docked); 1009 device_remove_file(&dock_device->dev, &dev_attr_docked);
1006 device_remove_file(&dock_device->dev, &dev_attr_undock); 1010 device_remove_file(&dock_device->dev, &dev_attr_undock);
1007 platform_device_unregister(dock_device); 1011 platform_device_unregister(dock_device);
@@ -1011,7 +1015,7 @@ static int dock_add(acpi_handle handle)
1011 } 1015 }
1012 ret = device_create_file(&dock_device->dev, &dev_attr_flags); 1016 ret = device_create_file(&dock_device->dev, &dev_attr_flags);
1013 if (ret) { 1017 if (ret) {
1014 printk("Error %d adding sysfs file\n", ret); 1018 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1015 device_remove_file(&dock_device->dev, &dev_attr_docked); 1019 device_remove_file(&dock_device->dev, &dev_attr_docked);
1016 device_remove_file(&dock_device->dev, &dev_attr_undock); 1020 device_remove_file(&dock_device->dev, &dev_attr_undock);
1017 device_remove_file(&dock_device->dev, &dev_attr_uid); 1021 device_remove_file(&dock_device->dev, &dev_attr_uid);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index a2b82c90a683..2fe15060dcdc 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -120,6 +120,8 @@ static struct acpi_ec {
120 spinlock_t curr_lock; 120 spinlock_t curr_lock;
121} *boot_ec, *first_ec; 121} *boot_ec, *first_ec;
122 122
123static int EC_FLAGS_MSI; /* Out-of-spec MSI controller */
124
123/* -------------------------------------------------------------------------- 125/* --------------------------------------------------------------------------
124 Transaction Management 126 Transaction Management
125 -------------------------------------------------------------------------- */ 127 -------------------------------------------------------------------------- */
@@ -259,6 +261,8 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
259 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags); 261 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
260 acpi_disable_gpe(NULL, ec->gpe); 262 acpi_disable_gpe(NULL, ec->gpe);
261 } 263 }
264 if (EC_FLAGS_MSI)
265 udelay(ACPI_EC_DELAY);
262 /* start transaction */ 266 /* start transaction */
263 spin_lock_irqsave(&ec->curr_lock, tmp); 267 spin_lock_irqsave(&ec->curr_lock, tmp);
264 /* following two actions should be kept atomic */ 268 /* following two actions should be kept atomic */
@@ -967,6 +971,11 @@ int __init acpi_ec_ecdt_probe(void)
967 /* 971 /*
968 * Generate a boot ec context 972 * Generate a boot ec context
969 */ 973 */
974 if (dmi_name_in_vendors("Micro-Star") ||
975 dmi_name_in_vendors("Notebook")) {
976 pr_info(PREFIX "Enabling special treatment for EC from MSI.\n");
977 EC_FLAGS_MSI = 1;
978 }
970 status = acpi_get_table(ACPI_SIG_ECDT, 1, 979 status = acpi_get_table(ACPI_SIG_ECDT, 1,
971 (struct acpi_table_header **)&ecdt_ptr); 980 (struct acpi_table_header **)&ecdt_ptr);
972 if (ACPI_SUCCESS(status)) { 981 if (ACPI_SUCCESS(status)) {
@@ -982,7 +991,7 @@ int __init acpi_ec_ecdt_probe(void)
982 saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 991 saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
983 if (!saved_ec) 992 if (!saved_ec)
984 return -ENOMEM; 993 return -ENOMEM;
985 memcpy(&saved_ec, boot_ec, sizeof(saved_ec)); 994 memcpy(saved_ec, boot_ec, sizeof(*saved_ec));
986 /* fall through */ 995 /* fall through */
987 } 996 }
988 /* This workaround is needed only on some broken machines, 997 /* This workaround is needed only on some broken machines,
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index adec3d15810a..5479b9f42513 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -255,12 +255,12 @@ static int acpi_platform_notify(struct device *dev)
255 } 255 }
256 type = acpi_get_bus_type(dev->bus); 256 type = acpi_get_bus_type(dev->bus);
257 if (!type) { 257 if (!type) {
258 DBG("No ACPI bus support for %s\n", dev->bus_id); 258 DBG("No ACPI bus support for %s\n", dev_name(dev));
259 ret = -EINVAL; 259 ret = -EINVAL;
260 goto end; 260 goto end;
261 } 261 }
262 if ((ret = type->find_device(dev, &handle)) != 0) 262 if ((ret = type->find_device(dev, &handle)) != 0)
263 DBG("Can't get handler for %s\n", dev->bus_id); 263 DBG("Can't get handler for %s\n", dev_name(dev));
264 end: 264 end:
265 if (!ret) 265 if (!ret)
266 acpi_bind_one(dev, handle); 266 acpi_bind_one(dev, handle);
@@ -271,10 +271,10 @@ static int acpi_platform_notify(struct device *dev)
271 271
272 acpi_get_name(dev->archdata.acpi_handle, 272 acpi_get_name(dev->archdata.acpi_handle,
273 ACPI_FULL_PATHNAME, &buffer); 273 ACPI_FULL_PATHNAME, &buffer);
274 DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer); 274 DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer);
275 kfree(buffer.pointer); 275 kfree(buffer.pointer);
276 } else 276 } else
277 DBG("Device %s -> No ACPI support\n", dev->bus_id); 277 DBG("Device %s -> No ACPI support\n", dev_name(dev));
278#endif 278#endif
279 279
280 return ret; 280 return ret;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 6729a4992f2b..b3193ec0a2ef 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -228,10 +228,10 @@ void acpi_os_vprintf(const char *fmt, va_list args)
228 if (acpi_in_debugger) { 228 if (acpi_in_debugger) {
229 kdb_printf("%s", buffer); 229 kdb_printf("%s", buffer);
230 } else { 230 } else {
231 printk("%s", buffer); 231 printk(KERN_CONT "%s", buffer);
232 } 232 }
233#else 233#else
234 printk("%s", buffer); 234 printk(KERN_CONT "%s", buffer);
235#endif 235#endif
236} 236}
237 237
@@ -1317,6 +1317,54 @@ acpi_os_validate_interface (char *interface)
1317 return AE_SUPPORT; 1317 return AE_SUPPORT;
1318} 1318}
1319 1319
1320#ifdef CONFIG_X86
1321
1322struct aml_port_desc {
1323 uint start;
1324 uint end;
1325 char* name;
1326 char warned;
1327};
1328
1329static struct aml_port_desc aml_invalid_port_list[] = {
1330 {0x20, 0x21, "PIC0", 0},
1331 {0xA0, 0xA1, "PIC1", 0},
1332 {0x4D0, 0x4D1, "ELCR", 0}
1333};
1334
1335/*
1336 * valid_aml_io_address()
1337 *
1338 * if valid, return true
1339 * else invalid, warn once, return false
1340 */
1341static bool valid_aml_io_address(uint address, uint length)
1342{
1343 int i;
1344 int entries = sizeof(aml_invalid_port_list) / sizeof(struct aml_port_desc);
1345
1346 for (i = 0; i < entries; ++i) {
1347 if ((address >= aml_invalid_port_list[i].start &&
1348 address <= aml_invalid_port_list[i].end) ||
1349 (address + length >= aml_invalid_port_list[i].start &&
1350 address + length <= aml_invalid_port_list[i].end))
1351 {
1352 if (!aml_invalid_port_list[i].warned)
1353 {
1354 printk(KERN_ERR "ACPI: Denied BIOS AML access"
1355 " to invalid port 0x%x+0x%x (%s)\n",
1356 address, length,
1357 aml_invalid_port_list[i].name);
1358 aml_invalid_port_list[i].warned = 1;
1359 }
1360 return false; /* invalid */
1361 }
1362 }
1363 return true; /* valid */
1364}
1365#else
1366static inline bool valid_aml_io_address(uint address, uint length) { return true; }
1367#endif
1320/****************************************************************************** 1368/******************************************************************************
1321 * 1369 *
1322 * FUNCTION: acpi_os_validate_address 1370 * FUNCTION: acpi_os_validate_address
@@ -1346,6 +1394,8 @@ acpi_os_validate_address (
1346 1394
1347 switch (space_id) { 1395 switch (space_id) {
1348 case ACPI_ADR_SPACE_SYSTEM_IO: 1396 case ACPI_ADR_SPACE_SYSTEM_IO:
1397 if (!valid_aml_io_address(address, length))
1398 return AE_AML_ILLEGAL_ADDRESS;
1349 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 1399 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
1350 /* Only interference checks against SystemIO and SytemMemory 1400 /* Only interference checks against SystemIO and SytemMemory
1351 are needed */ 1401 are needed */
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 1c6e73c7865e..6c772ca76bd1 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -593,7 +593,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
593 return -ENODEV; 593 return -ENODEV;
594 } else { 594 } else {
595 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; 595 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
596 printk(PREFIX "%s [%s] enabled at IRQ %d\n", 596 printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
597 acpi_device_name(link->device), 597 acpi_device_name(link->device),
598 acpi_device_bid(link->device), link->irq.active); 598 acpi_device_bid(link->device), link->irq.active);
599 } 599 }
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 66a9d8145562..7bc22a471fe3 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -66,43 +66,17 @@ ACPI_MODULE_NAME("processor_idle");
66#define ACPI_PROCESSOR_FILE_POWER "power" 66#define ACPI_PROCESSOR_FILE_POWER "power"
67#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) 67#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000)
68#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) 68#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY)
69#ifndef CONFIG_CPU_IDLE
70#define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */
71#define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */
72static void (*pm_idle_save) (void) __read_mostly;
73#else
74#define C2_OVERHEAD 1 /* 1us */ 69#define C2_OVERHEAD 1 /* 1us */
75#define C3_OVERHEAD 1 /* 1us */ 70#define C3_OVERHEAD 1 /* 1us */
76#endif
77#define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000)) 71#define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000))
78 72
79static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; 73static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
80#ifdef CONFIG_CPU_IDLE
81module_param(max_cstate, uint, 0000); 74module_param(max_cstate, uint, 0000);
82#else
83module_param(max_cstate, uint, 0644);
84#endif
85static unsigned int nocst __read_mostly; 75static unsigned int nocst __read_mostly;
86module_param(nocst, uint, 0000); 76module_param(nocst, uint, 0000);
87 77
88#ifndef CONFIG_CPU_IDLE
89/*
90 * bm_history -- bit-mask with a bit per jiffy of bus-master activity
91 * 1000 HZ: 0xFFFFFFFF: 32 jiffies = 32ms
92 * 800 HZ: 0xFFFFFFFF: 32 jiffies = 40ms
93 * 100 HZ: 0x0000000F: 4 jiffies = 40ms
94 * reduce history for more aggressive entry into C3
95 */
96static unsigned int bm_history __read_mostly =
97 (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1));
98module_param(bm_history, uint, 0644);
99
100static int acpi_processor_set_power_policy(struct acpi_processor *pr);
101
102#else /* CONFIG_CPU_IDLE */
103static unsigned int latency_factor __read_mostly = 2; 78static unsigned int latency_factor __read_mostly = 2;
104module_param(latency_factor, uint, 0644); 79module_param(latency_factor, uint, 0644);
105#endif
106 80
107/* 81/*
108 * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. 82 * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3.
@@ -224,71 +198,6 @@ static void acpi_safe_halt(void)
224 current_thread_info()->status |= TS_POLLING; 198 current_thread_info()->status |= TS_POLLING;
225} 199}
226 200
227#ifndef CONFIG_CPU_IDLE
228
229static void
230acpi_processor_power_activate(struct acpi_processor *pr,
231 struct acpi_processor_cx *new)
232{
233 struct acpi_processor_cx *old;
234
235 if (!pr || !new)
236 return;
237
238 old = pr->power.state;
239
240 if (old)
241 old->promotion.count = 0;
242 new->demotion.count = 0;
243
244 /* Cleanup from old state. */
245 if (old) {
246 switch (old->type) {
247 case ACPI_STATE_C3:
248 /* Disable bus master reload */
249 if (new->type != ACPI_STATE_C3 && pr->flags.bm_check)
250 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0);
251 break;
252 }
253 }
254
255 /* Prepare to use new state. */
256 switch (new->type) {
257 case ACPI_STATE_C3:
258 /* Enable bus master reload */
259 if (old->type != ACPI_STATE_C3 && pr->flags.bm_check)
260 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1);
261 break;
262 }
263
264 pr->power.state = new;
265
266 return;
267}
268
269static atomic_t c3_cpu_count;
270
271/* Common C-state entry for C2, C3, .. */
272static void acpi_cstate_enter(struct acpi_processor_cx *cstate)
273{
274 /* Don't trace irqs off for idle */
275 stop_critical_timings();
276 if (cstate->entry_method == ACPI_CSTATE_FFH) {
277 /* Call into architectural FFH based C-state */
278 acpi_processor_ffh_cstate_enter(cstate);
279 } else {
280 int unused;
281 /* IO port based C-state */
282 inb(cstate->address);
283 /* Dummy wait op - must do something useless after P_LVL2 read
284 because chipsets cannot guarantee that STPCLK# signal
285 gets asserted in time to freeze execution properly. */
286 unused = inl(acpi_gbl_FADT.xpm_timer_block.address);
287 }
288 start_critical_timings();
289}
290#endif /* !CONFIG_CPU_IDLE */
291
292#ifdef ARCH_APICTIMER_STOPS_ON_C3 201#ifdef ARCH_APICTIMER_STOPS_ON_C3
293 202
294/* 203/*
@@ -390,421 +299,6 @@ static int tsc_halts_in_c(int state)
390} 299}
391#endif 300#endif
392 301
393#ifndef CONFIG_CPU_IDLE
394static void acpi_processor_idle(void)
395{
396 struct acpi_processor *pr = NULL;
397 struct acpi_processor_cx *cx = NULL;
398 struct acpi_processor_cx *next_state = NULL;
399 int sleep_ticks = 0;
400 u32 t1, t2 = 0;
401
402 /*
403 * Interrupts must be disabled during bus mastering calculations and
404 * for C2/C3 transitions.
405 */
406 local_irq_disable();
407
408 pr = __get_cpu_var(processors);
409 if (!pr) {
410 local_irq_enable();
411 return;
412 }
413
414 /*
415 * Check whether we truly need to go idle, or should
416 * reschedule:
417 */
418 if (unlikely(need_resched())) {
419 local_irq_enable();
420 return;
421 }
422
423 cx = pr->power.state;
424 if (!cx || acpi_idle_suspend) {
425 if (pm_idle_save) {
426 pm_idle_save(); /* enables IRQs */
427 } else {
428 acpi_safe_halt();
429 local_irq_enable();
430 }
431
432 return;
433 }
434
435 /*
436 * Check BM Activity
437 * -----------------
438 * Check for bus mastering activity (if required), record, and check
439 * for demotion.
440 */
441 if (pr->flags.bm_check) {
442 u32 bm_status = 0;
443 unsigned long diff = jiffies - pr->power.bm_check_timestamp;
444
445 if (diff > 31)
446 diff = 31;
447
448 pr->power.bm_activity <<= diff;
449
450 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status);
451 if (bm_status) {
452 pr->power.bm_activity |= 0x1;
453 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1);
454 }
455 /*
456 * PIIX4 Erratum #18: Note that BM_STS doesn't always reflect
457 * the true state of bus mastering activity; forcing us to
458 * manually check the BMIDEA bit of each IDE channel.
459 */
460 else if (errata.piix4.bmisx) {
461 if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01)
462 || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01))
463 pr->power.bm_activity |= 0x1;
464 }
465
466 pr->power.bm_check_timestamp = jiffies;
467
468 /*
469 * If bus mastering is or was active this jiffy, demote
470 * to avoid a faulty transition. Note that the processor
471 * won't enter a low-power state during this call (to this
472 * function) but should upon the next.
473 *
474 * TBD: A better policy might be to fallback to the demotion
475 * state (use it for this quantum only) istead of
476 * demoting -- and rely on duration as our sole demotion
477 * qualification. This may, however, introduce DMA
478 * issues (e.g. floppy DMA transfer overrun/underrun).
479 */
480 if ((pr->power.bm_activity & 0x1) &&
481 cx->demotion.threshold.bm) {
482 local_irq_enable();
483 next_state = cx->demotion.state;
484 goto end;
485 }
486 }
487
488#ifdef CONFIG_HOTPLUG_CPU
489 /*
490 * Check for P_LVL2_UP flag before entering C2 and above on
491 * an SMP system. We do it here instead of doing it at _CST/P_LVL
492 * detection phase, to work cleanly with logical CPU hotplug.
493 */
494 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
495 !pr->flags.has_cst && !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
496 cx = &pr->power.states[ACPI_STATE_C1];
497#endif
498
499 /*
500 * Sleep:
501 * ------
502 * Invoke the current Cx state to put the processor to sleep.
503 */
504 if (cx->type == ACPI_STATE_C2 || cx->type == ACPI_STATE_C3) {
505 current_thread_info()->status &= ~TS_POLLING;
506 /*
507 * TS_POLLING-cleared state must be visible before we
508 * test NEED_RESCHED:
509 */
510 smp_mb();
511 if (need_resched()) {
512 current_thread_info()->status |= TS_POLLING;
513 local_irq_enable();
514 return;
515 }
516 }
517
518 switch (cx->type) {
519
520 case ACPI_STATE_C1:
521 /*
522 * Invoke C1.
523 * Use the appropriate idle routine, the one that would
524 * be used without acpi C-states.
525 */
526 if (pm_idle_save) {
527 pm_idle_save(); /* enables IRQs */
528 } else {
529 acpi_safe_halt();
530 local_irq_enable();
531 }
532
533 /*
534 * TBD: Can't get time duration while in C1, as resumes
535 * go to an ISR rather than here. Need to instrument
536 * base interrupt handler.
537 *
538 * Note: the TSC better not stop in C1, sched_clock() will
539 * skew otherwise.
540 */
541 sleep_ticks = 0xFFFFFFFF;
542
543 break;
544
545 case ACPI_STATE_C2:
546 /* Get start time (ticks) */
547 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
548 /* Tell the scheduler that we are going deep-idle: */
549 sched_clock_idle_sleep_event();
550 /* Invoke C2 */
551 acpi_state_timer_broadcast(pr, cx, 1);
552 acpi_cstate_enter(cx);
553 /* Get end time (ticks) */
554 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
555
556#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
557 /* TSC halts in C2, so notify users */
558 if (tsc_halts_in_c(ACPI_STATE_C2))
559 mark_tsc_unstable("possible TSC halt in C2");
560#endif
561 /* Compute time (ticks) that we were actually asleep */
562 sleep_ticks = ticks_elapsed(t1, t2);
563
564 /* Tell the scheduler how much we idled: */
565 sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
566
567 /* Re-enable interrupts */
568 local_irq_enable();
569 /* Do not account our idle-switching overhead: */
570 sleep_ticks -= cx->latency_ticks + C2_OVERHEAD;
571
572 current_thread_info()->status |= TS_POLLING;
573 acpi_state_timer_broadcast(pr, cx, 0);
574 break;
575
576 case ACPI_STATE_C3:
577 acpi_unlazy_tlb(smp_processor_id());
578 /*
579 * Must be done before busmaster disable as we might
580 * need to access HPET !
581 */
582 acpi_state_timer_broadcast(pr, cx, 1);
583 /*
584 * disable bus master
585 * bm_check implies we need ARB_DIS
586 * !bm_check implies we need cache flush
587 * bm_control implies whether we can do ARB_DIS
588 *
589 * That leaves a case where bm_check is set and bm_control is
590 * not set. In that case we cannot do much, we enter C3
591 * without doing anything.
592 */
593 if (pr->flags.bm_check && pr->flags.bm_control) {
594 if (atomic_inc_return(&c3_cpu_count) ==
595 num_online_cpus()) {
596 /*
597 * All CPUs are trying to go to C3
598 * Disable bus master arbitration
599 */
600 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1);
601 }
602 } else if (!pr->flags.bm_check) {
603 /* SMP with no shared cache... Invalidate cache */
604 ACPI_FLUSH_CPU_CACHE();
605 }
606
607 /* Get start time (ticks) */
608 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
609 /* Invoke C3 */
610 /* Tell the scheduler that we are going deep-idle: */
611 sched_clock_idle_sleep_event();
612 acpi_cstate_enter(cx);
613 /* Get end time (ticks) */
614 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
615 if (pr->flags.bm_check && pr->flags.bm_control) {
616 /* Enable bus master arbitration */
617 atomic_dec(&c3_cpu_count);
618 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
619 }
620
621#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
622 /* TSC halts in C3, so notify users */
623 if (tsc_halts_in_c(ACPI_STATE_C3))
624 mark_tsc_unstable("TSC halts in C3");
625#endif
626 /* Compute time (ticks) that we were actually asleep */
627 sleep_ticks = ticks_elapsed(t1, t2);
628 /* Tell the scheduler how much we idled: */
629 sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
630
631 /* Re-enable interrupts */
632 local_irq_enable();
633 /* Do not account our idle-switching overhead: */
634 sleep_ticks -= cx->latency_ticks + C3_OVERHEAD;
635
636 current_thread_info()->status |= TS_POLLING;
637 acpi_state_timer_broadcast(pr, cx, 0);
638 break;
639
640 default:
641 local_irq_enable();
642 return;
643 }
644 cx->usage++;
645 if ((cx->type != ACPI_STATE_C1) && (sleep_ticks > 0))
646 cx->time += sleep_ticks;
647
648 next_state = pr->power.state;
649
650#ifdef CONFIG_HOTPLUG_CPU
651 /* Don't do promotion/demotion */
652 if ((cx->type == ACPI_STATE_C1) && (num_online_cpus() > 1) &&
653 !pr->flags.has_cst && !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) {
654 next_state = cx;
655 goto end;
656 }
657#endif
658
659 /*
660 * Promotion?
661 * ----------
662 * Track the number of longs (time asleep is greater than threshold)
663 * and promote when the count threshold is reached. Note that bus
664 * mastering activity may prevent promotions.
665 * Do not promote above max_cstate.
666 */
667 if (cx->promotion.state &&
668 ((cx->promotion.state - pr->power.states) <= max_cstate)) {
669 if (sleep_ticks > cx->promotion.threshold.ticks &&
670 cx->promotion.state->latency <=
671 pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)) {
672 cx->promotion.count++;
673 cx->demotion.count = 0;
674 if (cx->promotion.count >=
675 cx->promotion.threshold.count) {
676 if (pr->flags.bm_check) {
677 if (!
678 (pr->power.bm_activity & cx->
679 promotion.threshold.bm)) {
680 next_state =
681 cx->promotion.state;
682 goto end;
683 }
684 } else {
685 next_state = cx->promotion.state;
686 goto end;
687 }
688 }
689 }
690 }
691
692 /*
693 * Demotion?
694 * ---------
695 * Track the number of shorts (time asleep is less than time threshold)
696 * and demote when the usage threshold is reached.
697 */
698 if (cx->demotion.state) {
699 if (sleep_ticks < cx->demotion.threshold.ticks) {
700 cx->demotion.count++;
701 cx->promotion.count = 0;
702 if (cx->demotion.count >= cx->demotion.threshold.count) {
703 next_state = cx->demotion.state;
704 goto end;
705 }
706 }
707 }
708
709 end:
710 /*
711 * Demote if current state exceeds max_cstate
712 * or if the latency of the current state is unacceptable
713 */
714 if ((pr->power.state - pr->power.states) > max_cstate ||
715 pr->power.state->latency >
716 pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)) {
717 if (cx->demotion.state)
718 next_state = cx->demotion.state;
719 }
720
721 /*
722 * New Cx State?
723 * -------------
724 * If we're going to start using a new Cx state we must clean up
725 * from the previous and prepare to use the new.
726 */
727 if (next_state != pr->power.state)
728 acpi_processor_power_activate(pr, next_state);
729}
730
731static int acpi_processor_set_power_policy(struct acpi_processor *pr)
732{
733 unsigned int i;
734 unsigned int state_is_set = 0;
735 struct acpi_processor_cx *lower = NULL;
736 struct acpi_processor_cx *higher = NULL;
737 struct acpi_processor_cx *cx;
738
739
740 if (!pr)
741 return -EINVAL;
742
743 /*
744 * This function sets the default Cx state policy (OS idle handler).
745 * Our scheme is to promote quickly to C2 but more conservatively
746 * to C3. We're favoring C2 for its characteristics of low latency
747 * (quick response), good power savings, and ability to allow bus
748 * mastering activity. Note that the Cx state policy is completely
749 * customizable and can be altered dynamically.
750 */
751
752 /* startup state */
753 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
754 cx = &pr->power.states[i];
755 if (!cx->valid)
756 continue;
757
758 if (!state_is_set)
759 pr->power.state = cx;
760 state_is_set++;
761 break;
762 }
763
764 if (!state_is_set)
765 return -ENODEV;
766
767 /* demotion */
768 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
769 cx = &pr->power.states[i];
770 if (!cx->valid)
771 continue;
772
773 if (lower) {
774 cx->demotion.state = lower;
775 cx->demotion.threshold.ticks = cx->latency_ticks;
776 cx->demotion.threshold.count = 1;
777 if (cx->type == ACPI_STATE_C3)
778 cx->demotion.threshold.bm = bm_history;
779 }
780
781 lower = cx;
782 }
783
784 /* promotion */
785 for (i = (ACPI_PROCESSOR_MAX_POWER - 1); i > 0; i--) {
786 cx = &pr->power.states[i];
787 if (!cx->valid)
788 continue;
789
790 if (higher) {
791 cx->promotion.state = higher;
792 cx->promotion.threshold.ticks = cx->latency_ticks;
793 if (cx->type >= ACPI_STATE_C2)
794 cx->promotion.threshold.count = 4;
795 else
796 cx->promotion.threshold.count = 10;
797 if (higher->type == ACPI_STATE_C3)
798 cx->promotion.threshold.bm = bm_history;
799 }
800
801 higher = cx;
802 }
803
804 return 0;
805}
806#endif /* !CONFIG_CPU_IDLE */
807
808static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) 302static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
809{ 303{
810 304
@@ -1047,11 +541,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
1047 */ 541 */
1048 cx->valid = 1; 542 cx->valid = 1;
1049 543
1050#ifndef CONFIG_CPU_IDLE
1051 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
1052#else
1053 cx->latency_ticks = cx->latency; 544 cx->latency_ticks = cx->latency;
1054#endif
1055 545
1056 return; 546 return;
1057} 547}
@@ -1121,7 +611,6 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
1121 " for C3 to be enabled on SMP systems\n")); 611 " for C3 to be enabled on SMP systems\n"));
1122 return; 612 return;
1123 } 613 }
1124 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0);
1125 } 614 }
1126 615
1127 /* 616 /*
@@ -1132,11 +621,16 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
1132 */ 621 */
1133 cx->valid = 1; 622 cx->valid = 1;
1134 623
1135#ifndef CONFIG_CPU_IDLE
1136 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
1137#else
1138 cx->latency_ticks = cx->latency; 624 cx->latency_ticks = cx->latency;
1139#endif 625 /*
626 * On older chipsets, BM_RLD needs to be set
627 * in order for Bus Master activity to wake the
628 * system from C3. Newer chipsets handle DMA
629 * during C3 automatically and BM_RLD is a NOP.
630 * In either case, the proper way to
631 * handle BM_RLD is to set it and leave it set.
632 */
633 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1);
1140 634
1141 return; 635 return;
1142} 636}
@@ -1201,20 +695,6 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
1201 695
1202 pr->power.count = acpi_processor_power_verify(pr); 696 pr->power.count = acpi_processor_power_verify(pr);
1203 697
1204#ifndef CONFIG_CPU_IDLE
1205 /*
1206 * Set Default Policy
1207 * ------------------
1208 * Now that we know which states are supported, set the default
1209 * policy. Note that this policy can be changed dynamically
1210 * (e.g. encourage deeper sleeps to conserve battery life when
1211 * not on AC).
1212 */
1213 result = acpi_processor_set_power_policy(pr);
1214 if (result)
1215 return result;
1216#endif
1217
1218 /* 698 /*
1219 * if one state of type C2 or C3 is available, mark this 699 * if one state of type C2 or C3 is available, mark this
1220 * CPU as being "idle manageable" 700 * CPU as being "idle manageable"
@@ -1312,69 +792,6 @@ static const struct file_operations acpi_processor_power_fops = {
1312 .release = single_release, 792 .release = single_release,
1313}; 793};
1314 794
1315#ifndef CONFIG_CPU_IDLE
1316
1317int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1318{
1319 int result = 0;
1320
1321 if (boot_option_idle_override)
1322 return 0;
1323
1324 if (!pr)
1325 return -EINVAL;
1326
1327 if (nocst) {
1328 return -ENODEV;
1329 }
1330
1331 if (!pr->flags.power_setup_done)
1332 return -ENODEV;
1333
1334 /*
1335 * Fall back to the default idle loop, when pm_idle_save had
1336 * been initialized.
1337 */
1338 if (pm_idle_save) {
1339 pm_idle = pm_idle_save;
1340 /* Relies on interrupts forcing exit from idle. */
1341 synchronize_sched();
1342 }
1343
1344 pr->flags.power = 0;
1345 result = acpi_processor_get_power_info(pr);
1346 if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
1347 pm_idle = acpi_processor_idle;
1348
1349 return result;
1350}
1351
1352#ifdef CONFIG_SMP
1353static void smp_callback(void *v)
1354{
1355 /* we already woke the CPU up, nothing more to do */
1356}
1357
1358/*
1359 * This function gets called when a part of the kernel has a new latency
1360 * requirement. This means we need to get all processors out of their C-state,
1361 * and then recalculate a new suitable C-state. Just do a cross-cpu IPI; that
1362 * wakes them all right up.
1363 */
1364static int acpi_processor_latency_notify(struct notifier_block *b,
1365 unsigned long l, void *v)
1366{
1367 smp_call_function(smp_callback, NULL, 1);
1368 return NOTIFY_OK;
1369}
1370
1371static struct notifier_block acpi_processor_latency_notifier = {
1372 .notifier_call = acpi_processor_latency_notify,
1373};
1374
1375#endif
1376
1377#else /* CONFIG_CPU_IDLE */
1378 795
1379/** 796/**
1380 * acpi_idle_bm_check - checks if bus master activity was detected 797 * acpi_idle_bm_check - checks if bus master activity was detected
@@ -1383,7 +800,7 @@ static int acpi_idle_bm_check(void)
1383{ 800{
1384 u32 bm_status = 0; 801 u32 bm_status = 0;
1385 802
1386 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status); 803 acpi_get_register_unlocked(ACPI_BITREG_BUS_MASTER_STATUS, &bm_status);
1387 if (bm_status) 804 if (bm_status)
1388 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1); 805 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 1);
1389 /* 806 /*
@@ -1400,25 +817,6 @@ static int acpi_idle_bm_check(void)
1400} 817}
1401 818
1402/** 819/**
1403 * acpi_idle_update_bm_rld - updates the BM_RLD bit depending on target state
1404 * @pr: the processor
1405 * @target: the new target state
1406 */
1407static inline void acpi_idle_update_bm_rld(struct acpi_processor *pr,
1408 struct acpi_processor_cx *target)
1409{
1410 if (pr->flags.bm_rld_set && target->type != ACPI_STATE_C3) {
1411 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0);
1412 pr->flags.bm_rld_set = 0;
1413 }
1414
1415 if (!pr->flags.bm_rld_set && target->type == ACPI_STATE_C3) {
1416 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1);
1417 pr->flags.bm_rld_set = 1;
1418 }
1419}
1420
1421/**
1422 * acpi_idle_do_entry - a helper function that does C2 and C3 type entry 820 * acpi_idle_do_entry - a helper function that does C2 and C3 type entry
1423 * @cx: cstate data 821 * @cx: cstate data
1424 * 822 *
@@ -1473,9 +871,6 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
1473 return 0; 871 return 0;
1474 } 872 }
1475 873
1476 if (pr->flags.bm_check)
1477 acpi_idle_update_bm_rld(pr, cx);
1478
1479 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); 874 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
1480 acpi_idle_do_entry(cx); 875 acpi_idle_do_entry(cx);
1481 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 876 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
@@ -1527,9 +922,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1527 */ 922 */
1528 acpi_state_timer_broadcast(pr, cx, 1); 923 acpi_state_timer_broadcast(pr, cx, 1);
1529 924
1530 if (pr->flags.bm_check)
1531 acpi_idle_update_bm_rld(pr, cx);
1532
1533 if (cx->type == ACPI_STATE_C3) 925 if (cx->type == ACPI_STATE_C3)
1534 ACPI_FLUSH_CPU_CACHE(); 926 ACPI_FLUSH_CPU_CACHE();
1535 927
@@ -1621,8 +1013,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1621 */ 1013 */
1622 acpi_state_timer_broadcast(pr, cx, 1); 1014 acpi_state_timer_broadcast(pr, cx, 1);
1623 1015
1624 acpi_idle_update_bm_rld(pr, cx);
1625
1626 /* 1016 /*
1627 * disable bus master 1017 * disable bus master
1628 * bm_check implies we need ARB_DIS 1018 * bm_check implies we need ARB_DIS
@@ -1795,8 +1185,6 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1795 return ret; 1185 return ret;
1796} 1186}
1797 1187
1798#endif /* CONFIG_CPU_IDLE */
1799
1800int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, 1188int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1801 struct acpi_device *device) 1189 struct acpi_device *device)
1802{ 1190{
@@ -1825,10 +1213,6 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1825 "ACPI: processor limited to max C-state %d\n", 1213 "ACPI: processor limited to max C-state %d\n",
1826 max_cstate); 1214 max_cstate);
1827 first_run++; 1215 first_run++;
1828#if !defined(CONFIG_CPU_IDLE) && defined(CONFIG_SMP)
1829 pm_qos_add_notifier(PM_QOS_CPU_DMA_LATENCY,
1830 &acpi_processor_latency_notifier);
1831#endif
1832 } 1216 }
1833 1217
1834 if (!pr) 1218 if (!pr)
@@ -1852,11 +1236,9 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1852 * platforms that only support C1. 1236 * platforms that only support C1.
1853 */ 1237 */
1854 if (pr->flags.power) { 1238 if (pr->flags.power) {
1855#ifdef CONFIG_CPU_IDLE
1856 acpi_processor_setup_cpuidle(pr); 1239 acpi_processor_setup_cpuidle(pr);
1857 if (cpuidle_register_device(&pr->power.dev)) 1240 if (cpuidle_register_device(&pr->power.dev))
1858 return -EIO; 1241 return -EIO;
1859#endif
1860 1242
1861 printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id); 1243 printk(KERN_INFO PREFIX "CPU%d (power states:", pr->id);
1862 for (i = 1; i <= pr->power.count; i++) 1244 for (i = 1; i <= pr->power.count; i++)
@@ -1864,13 +1246,6 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1864 printk(" C%d[C%d]", i, 1246 printk(" C%d[C%d]", i,
1865 pr->power.states[i].type); 1247 pr->power.states[i].type);
1866 printk(")\n"); 1248 printk(")\n");
1867
1868#ifndef CONFIG_CPU_IDLE
1869 if (pr->id == 0) {
1870 pm_idle_save = pm_idle;
1871 pm_idle = acpi_processor_idle;
1872 }
1873#endif
1874 } 1249 }
1875 1250
1876 /* 'power' [R] */ 1251 /* 'power' [R] */
@@ -1889,34 +1264,12 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
1889 if (boot_option_idle_override) 1264 if (boot_option_idle_override)
1890 return 0; 1265 return 0;
1891 1266
1892#ifdef CONFIG_CPU_IDLE
1893 cpuidle_unregister_device(&pr->power.dev); 1267 cpuidle_unregister_device(&pr->power.dev);
1894#endif
1895 pr->flags.power_setup_done = 0; 1268 pr->flags.power_setup_done = 0;
1896 1269
1897 if (acpi_device_dir(device)) 1270 if (acpi_device_dir(device))
1898 remove_proc_entry(ACPI_PROCESSOR_FILE_POWER, 1271 remove_proc_entry(ACPI_PROCESSOR_FILE_POWER,
1899 acpi_device_dir(device)); 1272 acpi_device_dir(device));
1900 1273
1901#ifndef CONFIG_CPU_IDLE
1902
1903 /* Unregister the idle handler when processor #0 is removed. */
1904 if (pr->id == 0) {
1905 if (pm_idle_save)
1906 pm_idle = pm_idle_save;
1907
1908 /*
1909 * We are about to unload the current idle thread pm callback
1910 * (pm_idle), Wait for all processors to update cached/local
1911 * copies of pm_idle before proceeding.
1912 */
1913 cpu_idle_wait();
1914#ifdef CONFIG_SMP
1915 pm_qos_remove_notifier(PM_QOS_CPU_DMA_LATENCY,
1916 &acpi_processor_latency_notifier);
1917#endif
1918 }
1919#endif
1920
1921 return 0; 1274 return 0;
1922} 1275}
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 846e227592d4..9cc769b587ff 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -31,14 +31,6 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/cpufreq.h> 32#include <linux/cpufreq.h>
33 33
34#ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
35#include <linux/proc_fs.h>
36#include <linux/seq_file.h>
37#include <linux/mutex.h>
38
39#include <asm/uaccess.h>
40#endif
41
42#ifdef CONFIG_X86 34#ifdef CONFIG_X86
43#include <asm/cpufeature.h> 35#include <asm/cpufeature.h>
44#endif 36#endif
@@ -434,96 +426,6 @@ int acpi_processor_notify_smm(struct module *calling_module)
434 426
435EXPORT_SYMBOL(acpi_processor_notify_smm); 427EXPORT_SYMBOL(acpi_processor_notify_smm);
436 428
437#ifdef CONFIG_X86_ACPI_CPUFREQ_PROC_INTF
438/* /proc/acpi/processor/../performance interface (DEPRECATED) */
439
440static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file);
441static struct file_operations acpi_processor_perf_fops = {
442 .owner = THIS_MODULE,
443 .open = acpi_processor_perf_open_fs,
444 .read = seq_read,
445 .llseek = seq_lseek,
446 .release = single_release,
447};
448
449static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
450{
451 struct acpi_processor *pr = seq->private;
452 int i;
453
454
455 if (!pr)
456 goto end;
457
458 if (!pr->performance) {
459 seq_puts(seq, "<not supported>\n");
460 goto end;
461 }
462
463 seq_printf(seq, "state count: %d\n"
464 "active state: P%d\n",
465 pr->performance->state_count, pr->performance->state);
466
467 seq_puts(seq, "states:\n");
468 for (i = 0; i < pr->performance->state_count; i++)
469 seq_printf(seq,
470 " %cP%d: %d MHz, %d mW, %d uS\n",
471 (i == pr->performance->state ? '*' : ' '), i,
472 (u32) pr->performance->states[i].core_frequency,
473 (u32) pr->performance->states[i].power,
474 (u32) pr->performance->states[i].transition_latency);
475
476 end:
477 return 0;
478}
479
480static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
481{
482 return single_open(file, acpi_processor_perf_seq_show,
483 PDE(inode)->data);
484}
485
486static void acpi_cpufreq_add_file(struct acpi_processor *pr)
487{
488 struct acpi_device *device = NULL;
489
490
491 if (acpi_bus_get_device(pr->handle, &device))
492 return;
493
494 /* add file 'performance' [R/W] */
495 proc_create_data(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO,
496 acpi_device_dir(device),
497 &acpi_processor_perf_fops, acpi_driver_data(device));
498 return;
499}
500
501static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
502{
503 struct acpi_device *device = NULL;
504
505
506 if (acpi_bus_get_device(pr->handle, &device))
507 return;
508
509 /* remove file 'performance' */
510 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
511 acpi_device_dir(device));
512
513 return;
514}
515
516#else
517static void acpi_cpufreq_add_file(struct acpi_processor *pr)
518{
519 return;
520}
521static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
522{
523 return;
524}
525#endif /* CONFIG_X86_ACPI_CPUFREQ_PROC_INTF */
526
527static int acpi_processor_get_psd(struct acpi_processor *pr) 429static int acpi_processor_get_psd(struct acpi_processor *pr)
528{ 430{
529 int result = 0; 431 int result = 0;
@@ -747,14 +649,12 @@ err_ret:
747} 649}
748EXPORT_SYMBOL(acpi_processor_preregister_performance); 650EXPORT_SYMBOL(acpi_processor_preregister_performance);
749 651
750
751int 652int
752acpi_processor_register_performance(struct acpi_processor_performance 653acpi_processor_register_performance(struct acpi_processor_performance
753 *performance, unsigned int cpu) 654 *performance, unsigned int cpu)
754{ 655{
755 struct acpi_processor *pr; 656 struct acpi_processor *pr;
756 657
757
758 if (!(acpi_processor_ppc_status & PPC_REGISTERED)) 658 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
759 return -EINVAL; 659 return -EINVAL;
760 660
@@ -781,8 +681,6 @@ acpi_processor_register_performance(struct acpi_processor_performance
781 return -EIO; 681 return -EIO;
782 } 682 }
783 683
784 acpi_cpufreq_add_file(pr);
785
786 mutex_unlock(&performance_mutex); 684 mutex_unlock(&performance_mutex);
787 return 0; 685 return 0;
788} 686}
@@ -795,7 +693,6 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
795{ 693{
796 struct acpi_processor *pr; 694 struct acpi_processor *pr;
797 695
798
799 mutex_lock(&performance_mutex); 696 mutex_lock(&performance_mutex);
800 697
801 pr = per_cpu(processors, cpu); 698 pr = per_cpu(processors, cpu);
@@ -808,8 +705,6 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
808 kfree(pr->performance->states); 705 kfree(pr->performance->states);
809 pr->performance = NULL; 706 pr->performance = NULL;
810 707
811 acpi_cpufreq_remove_file(pr);
812
813 mutex_unlock(&performance_mutex); 708 mutex_unlock(&performance_mutex);
814 709
815 return; 710 return;
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 7e3c609cbef2..519266654f06 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -90,31 +90,6 @@ void __init acpi_old_suspend_ordering(void)
90 old_suspend_ordering = true; 90 old_suspend_ordering = true;
91} 91}
92 92
93/*
94 * According to the ACPI specification the BIOS should make sure that ACPI is
95 * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
96 * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
97 * on such systems during resume. Unfortunately that doesn't help in
98 * particularly pathological cases in which SCI_EN has to be set directly on
99 * resume, although the specification states very clearly that this flag is
100 * owned by the hardware. The set_sci_en_on_resume variable will be set in such
101 * cases.
102 */
103static bool set_sci_en_on_resume;
104/*
105 * The ACPI specification wants us to save NVS memory regions during hibernation
106 * and to restore them during the subsequent resume. However, it is not certain
107 * if this mechanism is going to work on all machines, so we allow the user to
108 * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line
109 * option.
110 */
111static bool s4_no_nvs;
112
113void __init acpi_s4_no_nvs(void)
114{
115 s4_no_nvs = true;
116}
117
118/** 93/**
119 * acpi_pm_disable_gpes - Disable the GPEs. 94 * acpi_pm_disable_gpes - Disable the GPEs.
120 */ 95 */
@@ -193,6 +168,18 @@ static void acpi_pm_end(void)
193#endif /* CONFIG_ACPI_SLEEP */ 168#endif /* CONFIG_ACPI_SLEEP */
194 169
195#ifdef CONFIG_SUSPEND 170#ifdef CONFIG_SUSPEND
171/*
172 * According to the ACPI specification the BIOS should make sure that ACPI is
173 * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states. Still,
174 * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
175 * on such systems during resume. Unfortunately that doesn't help in
176 * particularly pathological cases in which SCI_EN has to be set directly on
177 * resume, although the specification states very clearly that this flag is
178 * owned by the hardware. The set_sci_en_on_resume variable will be set in such
179 * cases.
180 */
181static bool set_sci_en_on_resume;
182
196extern void do_suspend_lowlevel(void); 183extern void do_suspend_lowlevel(void);
197 184
198static u32 acpi_suspend_states[] = { 185static u32 acpi_suspend_states[] = {
@@ -396,6 +383,20 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
396#endif /* CONFIG_SUSPEND */ 383#endif /* CONFIG_SUSPEND */
397 384
398#ifdef CONFIG_HIBERNATION 385#ifdef CONFIG_HIBERNATION
386/*
387 * The ACPI specification wants us to save NVS memory regions during hibernation
388 * and to restore them during the subsequent resume. However, it is not certain
389 * if this mechanism is going to work on all machines, so we allow the user to
390 * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line
391 * option.
392 */
393static bool s4_no_nvs;
394
395void __init acpi_s4_no_nvs(void)
396{
397 s4_no_nvs = true;
398}
399
399static unsigned long s4_hardware_signature; 400static unsigned long s4_hardware_signature;
400static struct acpi_table_facs *facs; 401static struct acpi_table_facs *facs;
401static bool nosigcheck; 402static bool nosigcheck;
@@ -679,7 +680,7 @@ static void acpi_power_off_prepare(void)
679static void acpi_power_off(void) 680static void acpi_power_off(void)
680{ 681{
681 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 682 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
682 printk("%s called\n", __func__); 683 printk(KERN_DEBUG "%s called\n", __func__);
683 local_irq_disable(); 684 local_irq_disable();
684 acpi_enable_wakeup_device(ACPI_STATE_S5); 685 acpi_enable_wakeup_device(ACPI_STATE_S5);
685 acpi_enter_sleep_state(ACPI_STATE_S5); 686 acpi_enter_sleep_state(ACPI_STATE_S5);
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 775c97a282bd..a8852952fac4 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -293,7 +293,12 @@ static void __init check_multiple_madt(void)
293 293
294int __init acpi_table_init(void) 294int __init acpi_table_init(void)
295{ 295{
296 acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); 296 acpi_status status;
297
298 status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
299 if (ACPI_FAILURE(status))
300 return 1;
301
297 check_multiple_madt(); 302 check_multiple_madt();
298 return 0; 303 return 0;
299} 304}
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index f261737636da..bb5ed059114a 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1020,7 +1020,7 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
1020 } 1020 }
1021 1021
1022 seq_printf(seq, "levels: "); 1022 seq_printf(seq, "levels: ");
1023 for (i = 0; i < dev->brightness->count; i++) 1023 for (i = 2; i < dev->brightness->count; i++)
1024 seq_printf(seq, " %d", dev->brightness->levels[i]); 1024 seq_printf(seq, " %d", dev->brightness->levels[i]);
1025 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr); 1025 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
1026 1026
@@ -1059,7 +1059,7 @@ acpi_video_device_write_brightness(struct file *file,
1059 return -EFAULT; 1059 return -EFAULT;
1060 1060
1061 /* validate through the list of available levels */ 1061 /* validate through the list of available levels */
1062 for (i = 0; i < dev->brightness->count; i++) 1062 for (i = 2; i < dev->brightness->count; i++)
1063 if (level == dev->brightness->levels[i]) { 1063 if (level == dev->brightness->levels[i]) {
1064 if (ACPI_SUCCESS 1064 if (ACPI_SUCCESS
1065 (acpi_video_device_lcd_set_level(dev, level))) 1065 (acpi_video_device_lcd_set_level(dev, level)))
@@ -1260,7 +1260,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1260 printk(KERN_WARNING PREFIX 1260 printk(KERN_WARNING PREFIX
1261 "This indicates a BIOS bug. Please contact the manufacturer.\n"); 1261 "This indicates a BIOS bug. Please contact the manufacturer.\n");
1262 } 1262 }
1263 printk("%llx\n", options); 1263 printk(KERN_WARNING "%llx\n", options);
1264 seq_printf(seq, "can POST: <integrated video>"); 1264 seq_printf(seq, "can POST: <integrated video>");
1265 if (options & 2) 1265 if (options & 2)
1266 seq_printf(seq, " <PCI video>"); 1266 seq_printf(seq, " <PCI video>");
@@ -1712,7 +1712,7 @@ acpi_video_get_next_level(struct acpi_video_device *device,
1712 max = max_below = 0; 1712 max = max_below = 0;
1713 min = min_above = 255; 1713 min = min_above = 255;
1714 /* Find closest level to level_current */ 1714 /* Find closest level to level_current */
1715 for (i = 0; i < device->brightness->count; i++) { 1715 for (i = 2; i < device->brightness->count; i++) {
1716 l = device->brightness->levels[i]; 1716 l = device->brightness->levels[i];
1717 if (abs(l - level_current) < abs(delta)) { 1717 if (abs(l - level_current) < abs(delta)) {
1718 delta = l - level_current; 1718 delta = l - level_current;
@@ -1722,7 +1722,7 @@ acpi_video_get_next_level(struct acpi_video_device *device,
1722 } 1722 }
1723 /* Ajust level_current to closest available level */ 1723 /* Ajust level_current to closest available level */
1724 level_current += delta; 1724 level_current += delta;
1725 for (i = 0; i < device->brightness->count; i++) { 1725 for (i = 2; i < device->brightness->count; i++) {
1726 l = device->brightness->levels[i]; 1726 l = device->brightness->levels[i];
1727 if (l < min) 1727 if (l < min)
1728 min = l; 1728 min = l;
@@ -2006,6 +2006,12 @@ static int acpi_video_bus_add(struct acpi_device *device)
2006 device->pnp.bus_id[3] = '0' + instance; 2006 device->pnp.bus_id[3] = '0' + instance;
2007 instance ++; 2007 instance ++;
2008 } 2008 }
2009 /* a hack to fix the duplicate name "VGA" problem on Pa 3553 */
2010 if (!strcmp(device->pnp.bus_id, "VGA")) {
2011 if (instance)
2012 device->pnp.bus_id[3] = '0' + instance;
2013 instance++;
2014 }
2009 2015
2010 video->device = device; 2016 video->device = device;
2011 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); 2017 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 77bba4c083cb..a603bbf9b1b7 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -61,9 +61,14 @@
61#define EM_MSG_LED_VALUE_ON 0x00010000 61#define EM_MSG_LED_VALUE_ON 0x00010000
62 62
63static int ahci_skip_host_reset; 63static int ahci_skip_host_reset;
64static int ahci_ignore_sss;
65
64module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444); 66module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444);
65MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)"); 67MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)");
66 68
69module_param_named(ignore_sss, ahci_ignore_sss, int, 0444);
70MODULE_PARM_DESC(ignore_sss, "Ignore staggered spinup flag (0=don't ignore, 1=ignore)");
71
67static int ahci_enable_alpm(struct ata_port *ap, 72static int ahci_enable_alpm(struct ata_port *ap,
68 enum link_pm policy); 73 enum link_pm policy);
69static void ahci_disable_alpm(struct ata_port *ap); 74static void ahci_disable_alpm(struct ata_port *ap);
@@ -2692,8 +2697,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2692 host->iomap = pcim_iomap_table(pdev); 2697 host->iomap = pcim_iomap_table(pdev);
2693 host->private_data = hpriv; 2698 host->private_data = hpriv;
2694 2699
2695 if (!(hpriv->cap & HOST_CAP_SSS)) 2700 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
2696 host->flags |= ATA_HOST_PARALLEL_SCAN; 2701 host->flags |= ATA_HOST_PARALLEL_SCAN;
2702 else
2703 printk(KERN_INFO "ahci: SSS flag set, parallel bus scan disabled\n");
2697 2704
2698 if (pi.flags & ATA_FLAG_EM) 2705 if (pi.flags & ATA_FLAG_EM)
2699 ahci_reset_em(host); 2706 ahci_reset_em(host);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 88c242856dae..9fbf0595f3d4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -164,6 +164,11 @@ MODULE_LICENSE("GPL");
164MODULE_VERSION(DRV_VERSION); 164MODULE_VERSION(DRV_VERSION);
165 165
166 166
167static bool ata_sstatus_online(u32 sstatus)
168{
169 return (sstatus & 0xf) == 0x3;
170}
171
167/** 172/**
168 * ata_link_next - link iteration helper 173 * ata_link_next - link iteration helper
169 * @link: the previous link, NULL to start 174 * @link: the previous link, NULL to start
@@ -1015,18 +1020,6 @@ static const char *sata_spd_string(unsigned int spd)
1015 return spd_str[spd - 1]; 1020 return spd_str[spd - 1];
1016} 1021}
1017 1022
1018void ata_dev_disable(struct ata_device *dev)
1019{
1020 if (ata_dev_enabled(dev)) {
1021 if (ata_msg_drv(dev->link->ap))
1022 ata_dev_printk(dev, KERN_WARNING, "disabled\n");
1023 ata_acpi_on_disable(dev);
1024 ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 |
1025 ATA_DNXFER_QUIET);
1026 dev->class++;
1027 }
1028}
1029
1030static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy) 1023static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy)
1031{ 1024{
1032 struct ata_link *link = dev->link; 1025 struct ata_link *link = dev->link;
@@ -2239,6 +2232,40 @@ retry:
2239 return rc; 2232 return rc;
2240} 2233}
2241 2234
2235static int ata_do_link_spd_horkage(struct ata_device *dev)
2236{
2237 struct ata_link *plink = ata_dev_phys_link(dev);
2238 u32 target, target_limit;
2239
2240 if (!sata_scr_valid(plink))
2241 return 0;
2242
2243 if (dev->horkage & ATA_HORKAGE_1_5_GBPS)
2244 target = 1;
2245 else
2246 return 0;
2247
2248 target_limit = (1 << target) - 1;
2249
2250 /* if already on stricter limit, no need to push further */
2251 if (plink->sata_spd_limit <= target_limit)
2252 return 0;
2253
2254 plink->sata_spd_limit = target_limit;
2255
2256 /* Request another EH round by returning -EAGAIN if link is
2257 * going faster than the target speed. Forward progress is
2258 * guaranteed by setting sata_spd_limit to target_limit above.
2259 */
2260 if (plink->sata_spd > target) {
2261 ata_dev_printk(dev, KERN_INFO,
2262 "applying link speed limit horkage to %s\n",
2263 sata_spd_string(target));
2264 return -EAGAIN;
2265 }
2266 return 0;
2267}
2268
2242static inline u8 ata_dev_knobble(struct ata_device *dev) 2269static inline u8 ata_dev_knobble(struct ata_device *dev)
2243{ 2270{
2244 struct ata_port *ap = dev->link->ap; 2271 struct ata_port *ap = dev->link->ap;
@@ -2329,6 +2356,10 @@ int ata_dev_configure(struct ata_device *dev)
2329 return 0; 2356 return 0;
2330 } 2357 }
2331 2358
2359 rc = ata_do_link_spd_horkage(dev);
2360 if (rc)
2361 return rc;
2362
2332 /* let ACPI work its magic */ 2363 /* let ACPI work its magic */
2333 rc = ata_acpi_on_devcfg(dev); 2364 rc = ata_acpi_on_devcfg(dev);
2334 if (rc) 2365 if (rc)
@@ -2784,7 +2815,7 @@ int ata_bus_probe(struct ata_port *ap)
2784 /* This is the last chance, better to slow 2815 /* This is the last chance, better to slow
2785 * down than lose it. 2816 * down than lose it.
2786 */ 2817 */
2787 sata_down_spd_limit(&ap->link); 2818 sata_down_spd_limit(&ap->link, 0);
2788 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); 2819 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO);
2789 } 2820 }
2790 } 2821 }
@@ -2880,21 +2911,27 @@ void ata_port_disable(struct ata_port *ap)
2880/** 2911/**
2881 * sata_down_spd_limit - adjust SATA spd limit downward 2912 * sata_down_spd_limit - adjust SATA spd limit downward
2882 * @link: Link to adjust SATA spd limit for 2913 * @link: Link to adjust SATA spd limit for
2914 * @spd_limit: Additional limit
2883 * 2915 *
2884 * Adjust SATA spd limit of @link downward. Note that this 2916 * Adjust SATA spd limit of @link downward. Note that this
2885 * function only adjusts the limit. The change must be applied 2917 * function only adjusts the limit. The change must be applied
2886 * using sata_set_spd(). 2918 * using sata_set_spd().
2887 * 2919 *
2920 * If @spd_limit is non-zero, the speed is limited to equal to or
2921 * lower than @spd_limit if such speed is supported. If
2922 * @spd_limit is slower than any supported speed, only the lowest
2923 * supported speed is allowed.
2924 *
2888 * LOCKING: 2925 * LOCKING:
2889 * Inherited from caller. 2926 * Inherited from caller.
2890 * 2927 *
2891 * RETURNS: 2928 * RETURNS:
2892 * 0 on success, negative errno on failure 2929 * 0 on success, negative errno on failure
2893 */ 2930 */
2894int sata_down_spd_limit(struct ata_link *link) 2931int sata_down_spd_limit(struct ata_link *link, u32 spd_limit)
2895{ 2932{
2896 u32 sstatus, spd, mask; 2933 u32 sstatus, spd, mask;
2897 int rc, highbit; 2934 int rc, bit;
2898 2935
2899 if (!sata_scr_valid(link)) 2936 if (!sata_scr_valid(link))
2900 return -EOPNOTSUPP; 2937 return -EOPNOTSUPP;
@@ -2903,7 +2940,7 @@ int sata_down_spd_limit(struct ata_link *link)
2903 * If not, use cached value in link->sata_spd. 2940 * If not, use cached value in link->sata_spd.
2904 */ 2941 */
2905 rc = sata_scr_read(link, SCR_STATUS, &sstatus); 2942 rc = sata_scr_read(link, SCR_STATUS, &sstatus);
2906 if (rc == 0) 2943 if (rc == 0 && ata_sstatus_online(sstatus))
2907 spd = (sstatus >> 4) & 0xf; 2944 spd = (sstatus >> 4) & 0xf;
2908 else 2945 else
2909 spd = link->sata_spd; 2946 spd = link->sata_spd;
@@ -2913,8 +2950,8 @@ int sata_down_spd_limit(struct ata_link *link)
2913 return -EINVAL; 2950 return -EINVAL;
2914 2951
2915 /* unconditionally mask off the highest bit */ 2952 /* unconditionally mask off the highest bit */
2916 highbit = fls(mask) - 1; 2953 bit = fls(mask) - 1;
2917 mask &= ~(1 << highbit); 2954 mask &= ~(1 << bit);
2918 2955
2919 /* Mask off all speeds higher than or equal to the current 2956 /* Mask off all speeds higher than or equal to the current
2920 * one. Force 1.5Gbps if current SPD is not available. 2957 * one. Force 1.5Gbps if current SPD is not available.
@@ -2928,6 +2965,15 @@ int sata_down_spd_limit(struct ata_link *link)
2928 if (!mask) 2965 if (!mask)
2929 return -EINVAL; 2966 return -EINVAL;
2930 2967
2968 if (spd_limit) {
2969 if (mask & ((1 << spd_limit) - 1))
2970 mask &= (1 << spd_limit) - 1;
2971 else {
2972 bit = ffs(mask) - 1;
2973 mask = 1 << bit;
2974 }
2975 }
2976
2931 link->sata_spd_limit = mask; 2977 link->sata_spd_limit = mask;
2932 2978
2933 ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n", 2979 ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n",
@@ -4215,6 +4261,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4215 /* Devices that do not need bridging limits applied */ 4261 /* Devices that do not need bridging limits applied */
4216 { "MTRON MSP-SATA*", NULL, ATA_HORKAGE_BRIDGE_OK, }, 4262 { "MTRON MSP-SATA*", NULL, ATA_HORKAGE_BRIDGE_OK, },
4217 4263
4264 /* Devices which aren't very happy with higher link speeds */
4265 { "WD My Book", NULL, ATA_HORKAGE_1_5_GBPS, },
4266
4218 /* End Marker */ 4267 /* End Marker */
4219 { } 4268 { }
4220}; 4269};
@@ -4709,8 +4758,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
4709 4758
4710/** 4759/**
4711 * ata_qc_new - Request an available ATA command, for queueing 4760 * ata_qc_new - Request an available ATA command, for queueing
4712 * @ap: Port associated with device @dev 4761 * @ap: target port
4713 * @dev: Device from whom we request an available command structure
4714 * 4762 *
4715 * LOCKING: 4763 * LOCKING:
4716 * None. 4764 * None.
@@ -5175,7 +5223,7 @@ bool ata_phys_link_online(struct ata_link *link)
5175 u32 sstatus; 5223 u32 sstatus;
5176 5224
5177 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5225 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
5178 (sstatus & 0xf) == 0x3) 5226 ata_sstatus_online(sstatus))
5179 return true; 5227 return true;
5180 return false; 5228 return false;
5181} 5229}
@@ -5199,7 +5247,7 @@ bool ata_phys_link_offline(struct ata_link *link)
5199 u32 sstatus; 5247 u32 sstatus;
5200 5248
5201 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5249 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
5202 (sstatus & 0xf) != 0x3) 5250 !ata_sstatus_online(sstatus))
5203 return true; 5251 return true;
5204 return false; 5252 return false;
5205} 5253}
@@ -5412,8 +5460,8 @@ void ata_dev_init(struct ata_device *dev)
5412 dev->horkage = 0; 5460 dev->horkage = 0;
5413 spin_unlock_irqrestore(ap->lock, flags); 5461 spin_unlock_irqrestore(ap->lock, flags);
5414 5462
5415 memset((void *)dev + ATA_DEVICE_CLEAR_OFFSET, 0, 5463 memset((void *)dev + ATA_DEVICE_CLEAR_BEGIN, 0,
5416 sizeof(*dev) - ATA_DEVICE_CLEAR_OFFSET); 5464 ATA_DEVICE_CLEAR_END - ATA_DEVICE_CLEAR_BEGIN);
5417 dev->pio_mask = UINT_MAX; 5465 dev->pio_mask = UINT_MAX;
5418 dev->mwdma_mask = UINT_MAX; 5466 dev->mwdma_mask = UINT_MAX;
5419 dev->udma_mask = UINT_MAX; 5467 dev->udma_mask = UINT_MAX;
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 8147a8386370..ce2ef0475339 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -82,6 +82,10 @@ enum {
82 ATA_EH_FASTDRAIN_INTERVAL = 3000, 82 ATA_EH_FASTDRAIN_INTERVAL = 3000,
83 83
84 ATA_EH_UA_TRIES = 5, 84 ATA_EH_UA_TRIES = 5,
85
86 /* probe speed down parameters, see ata_eh_schedule_probe() */
87 ATA_EH_PROBE_TRIAL_INTERVAL = 60000, /* 1 min */
88 ATA_EH_PROBE_TRIALS = 2,
85}; 89};
86 90
87/* The following table determines how we sequence resets. Each entry 91/* The following table determines how we sequence resets. Each entry
@@ -1176,6 +1180,32 @@ void ata_eh_qc_retry(struct ata_queued_cmd *qc)
1176} 1180}
1177 1181
1178/** 1182/**
1183 * ata_dev_disable - disable ATA device
1184 * @dev: ATA device to disable
1185 *
1186 * Disable @dev.
1187 *
1188 * Locking:
1189 * EH context.
1190 */
1191void ata_dev_disable(struct ata_device *dev)
1192{
1193 if (!ata_dev_enabled(dev))
1194 return;
1195
1196 if (ata_msg_drv(dev->link->ap))
1197 ata_dev_printk(dev, KERN_WARNING, "disabled\n");
1198 ata_acpi_on_disable(dev);
1199 ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | ATA_DNXFER_QUIET);
1200 dev->class++;
1201
1202 /* From now till the next successful probe, ering is used to
1203 * track probe failures. Clear accumulated device error info.
1204 */
1205 ata_ering_clear(&dev->ering);
1206}
1207
1208/**
1179 * ata_eh_detach_dev - detach ATA device 1209 * ata_eh_detach_dev - detach ATA device
1180 * @dev: ATA device to detach 1210 * @dev: ATA device to detach
1181 * 1211 *
@@ -1849,7 +1879,7 @@ static unsigned int ata_eh_speed_down(struct ata_device *dev,
1849 /* speed down? */ 1879 /* speed down? */
1850 if (verdict & ATA_EH_SPDN_SPEED_DOWN) { 1880 if (verdict & ATA_EH_SPDN_SPEED_DOWN) {
1851 /* speed down SATA link speed if possible */ 1881 /* speed down SATA link speed if possible */
1852 if (sata_down_spd_limit(link) == 0) { 1882 if (sata_down_spd_limit(link, 0) == 0) {
1853 action |= ATA_EH_RESET; 1883 action |= ATA_EH_RESET;
1854 goto done; 1884 goto done;
1855 } 1885 }
@@ -2601,11 +2631,11 @@ int ata_eh_reset(struct ata_link *link, int classify,
2601 } 2631 }
2602 2632
2603 if (try == max_tries - 1) { 2633 if (try == max_tries - 1) {
2604 sata_down_spd_limit(link); 2634 sata_down_spd_limit(link, 0);
2605 if (slave) 2635 if (slave)
2606 sata_down_spd_limit(slave); 2636 sata_down_spd_limit(slave, 0);
2607 } else if (rc == -EPIPE) 2637 } else if (rc == -EPIPE)
2608 sata_down_spd_limit(failed_link); 2638 sata_down_spd_limit(failed_link, 0);
2609 2639
2610 if (hardreset) 2640 if (hardreset)
2611 reset = hardreset; 2641 reset = hardreset;
@@ -2744,6 +2774,8 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2744 readid_flags, dev->id); 2774 readid_flags, dev->id);
2745 switch (rc) { 2775 switch (rc) {
2746 case 0: 2776 case 0:
2777 /* clear error info accumulated during probe */
2778 ata_ering_clear(&dev->ering);
2747 new_mask |= 1 << dev->devno; 2779 new_mask |= 1 << dev->devno;
2748 break; 2780 break;
2749 case -ENOENT: 2781 case -ENOENT:
@@ -2947,9 +2979,24 @@ static int ata_eh_skip_recovery(struct ata_link *link)
2947 return 1; 2979 return 1;
2948} 2980}
2949 2981
2982static int ata_count_probe_trials_cb(struct ata_ering_entry *ent, void *void_arg)
2983{
2984 u64 interval = msecs_to_jiffies(ATA_EH_PROBE_TRIAL_INTERVAL);
2985 u64 now = get_jiffies_64();
2986 int *trials = void_arg;
2987
2988 if (ent->timestamp < now - min(now, interval))
2989 return -1;
2990
2991 (*trials)++;
2992 return 0;
2993}
2994
2950static int ata_eh_schedule_probe(struct ata_device *dev) 2995static int ata_eh_schedule_probe(struct ata_device *dev)
2951{ 2996{
2952 struct ata_eh_context *ehc = &dev->link->eh_context; 2997 struct ata_eh_context *ehc = &dev->link->eh_context;
2998 struct ata_link *link = ata_dev_phys_link(dev);
2999 int trials = 0;
2953 3000
2954 if (!(ehc->i.probe_mask & (1 << dev->devno)) || 3001 if (!(ehc->i.probe_mask & (1 << dev->devno)) ||
2955 (ehc->did_probe_mask & (1 << dev->devno))) 3002 (ehc->did_probe_mask & (1 << dev->devno)))
@@ -2962,6 +3009,25 @@ static int ata_eh_schedule_probe(struct ata_device *dev)
2962 ehc->saved_xfer_mode[dev->devno] = 0; 3009 ehc->saved_xfer_mode[dev->devno] = 0;
2963 ehc->saved_ncq_enabled &= ~(1 << dev->devno); 3010 ehc->saved_ncq_enabled &= ~(1 << dev->devno);
2964 3011
3012 /* Record and count probe trials on the ering. The specific
3013 * error mask used is irrelevant. Because a successful device
3014 * detection clears the ering, this count accumulates only if
3015 * there are consecutive failed probes.
3016 *
3017 * If the count is equal to or higher than ATA_EH_PROBE_TRIALS
3018 * in the last ATA_EH_PROBE_TRIAL_INTERVAL, link speed is
3019 * forced to 1.5Gbps.
3020 *
3021 * This is to work around cases where failed link speed
3022 * negotiation results in device misdetection leading to
3023 * infinite DEVXCHG or PHRDY CHG events.
3024 */
3025 ata_ering_record(&dev->ering, 0, AC_ERR_OTHER);
3026 ata_ering_map(&dev->ering, ata_count_probe_trials_cb, &trials);
3027
3028 if (trials > ATA_EH_PROBE_TRIALS)
3029 sata_down_spd_limit(link, 1);
3030
2965 return 1; 3031 return 1;
2966} 3032}
2967 3033
@@ -2969,7 +3035,11 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2969{ 3035{
2970 struct ata_eh_context *ehc = &dev->link->eh_context; 3036 struct ata_eh_context *ehc = &dev->link->eh_context;
2971 3037
2972 ehc->tries[dev->devno]--; 3038 /* -EAGAIN from EH routine indicates retry without prejudice.
3039 * The requester is responsible for ensuring forward progress.
3040 */
3041 if (err != -EAGAIN)
3042 ehc->tries[dev->devno]--;
2973 3043
2974 switch (err) { 3044 switch (err) {
2975 case -ENODEV: 3045 case -ENODEV:
@@ -2979,12 +3049,13 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2979 /* give it just one more chance */ 3049 /* give it just one more chance */
2980 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); 3050 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1);
2981 case -EIO: 3051 case -EIO:
2982 if (ehc->tries[dev->devno] == 1 && dev->pio_mode > XFER_PIO_0) { 3052 if (ehc->tries[dev->devno] == 1) {
2983 /* This is the last chance, better to slow 3053 /* This is the last chance, better to slow
2984 * down than lose it. 3054 * down than lose it.
2985 */ 3055 */
2986 sata_down_spd_limit(ata_dev_phys_link(dev)); 3056 sata_down_spd_limit(ata_dev_phys_link(dev), 0);
2987 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); 3057 if (dev->pio_mode > XFER_PIO_0)
3058 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO);
2988 } 3059 }
2989 } 3060 }
2990 3061
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 98ca07a2db87..619f2c33950e 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -729,7 +729,7 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
729 if (tries) { 729 if (tries) {
730 /* consecutive revalidation failures? speed down */ 730 /* consecutive revalidation failures? speed down */
731 if (reval_failed) 731 if (reval_failed)
732 sata_down_spd_limit(link); 732 sata_down_spd_limit(link, 0);
733 else 733 else
734 reval_failed = 1; 734 reval_failed = 1;
735 735
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 3c4c5ae277ba..b9747fa59e54 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -415,6 +415,7 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev,
415 415
416/** 416/**
417 * ata_get_identity - Handler for HDIO_GET_IDENTITY ioctl 417 * ata_get_identity - Handler for HDIO_GET_IDENTITY ioctl
418 * @ap: target port
418 * @sdev: SCSI device to get identify data for 419 * @sdev: SCSI device to get identify data for
419 * @arg: User buffer area for identify data 420 * @arg: User buffer area for identify data
420 * 421 *
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 0b299b0f8172..714cb046b594 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -773,18 +773,32 @@ unsigned int ata_sff_data_xfer32(struct ata_device *dev, unsigned char *buf,
773 else 773 else
774 iowrite32_rep(data_addr, buf, words); 774 iowrite32_rep(data_addr, buf, words);
775 775
776 /* Transfer trailing bytes, if any */
776 if (unlikely(slop)) { 777 if (unlikely(slop)) {
777 __le32 pad; 778 unsigned char pad[4];
779
780 /* Point buf to the tail of buffer */
781 buf += buflen - slop;
782
783 /*
784 * Use io*_rep() accessors here as well to avoid pointlessly
785 * swapping bytes to and fro on the big endian machines...
786 */
778 if (rw == READ) { 787 if (rw == READ) {
779 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); 788 if (slop < 3)
780 memcpy(buf + buflen - slop, &pad, slop); 789 ioread16_rep(data_addr, pad, 1);
790 else
791 ioread32_rep(data_addr, pad, 1);
792 memcpy(buf, pad, slop);
781 } else { 793 } else {
782 memcpy(&pad, buf + buflen - slop, slop); 794 memcpy(pad, buf, slop);
783 iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr); 795 if (slop < 3)
796 iowrite16_rep(data_addr, pad, 1);
797 else
798 iowrite32_rep(data_addr, pad, 1);
784 } 799 }
785 words++;
786 } 800 }
787 return words << 2; 801 return (buflen + 1) & ~1;
788} 802}
789EXPORT_SYMBOL_GPL(ata_sff_data_xfer32); 803EXPORT_SYMBOL_GPL(ata_sff_data_xfer32);
790 804
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index fe2839e58774..cea8014cd87e 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -79,7 +79,6 @@ extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
79 u64 block, u32 n_block, unsigned int tf_flags, 79 u64 block, u32 n_block, unsigned int tf_flags,
80 unsigned int tag); 80 unsigned int tag);
81extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev); 81extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev);
82extern void ata_dev_disable(struct ata_device *dev);
83extern void ata_pio_queue_task(struct ata_port *ap, void *data, 82extern void ata_pio_queue_task(struct ata_port *ap, void *data,
84 unsigned long delay); 83 unsigned long delay);
85extern void ata_port_flush_task(struct ata_port *ap); 84extern void ata_port_flush_task(struct ata_port *ap);
@@ -100,7 +99,7 @@ extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags);
100extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, 99extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
101 unsigned int readid_flags); 100 unsigned int readid_flags);
102extern int ata_dev_configure(struct ata_device *dev); 101extern int ata_dev_configure(struct ata_device *dev);
103extern int sata_down_spd_limit(struct ata_link *link); 102extern int sata_down_spd_limit(struct ata_link *link, u32 spd_limit);
104extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); 103extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
105extern void ata_sg_clean(struct ata_queued_cmd *qc); 104extern void ata_sg_clean(struct ata_queued_cmd *qc);
106extern void ata_qc_free(struct ata_queued_cmd *qc); 105extern void ata_qc_free(struct ata_queued_cmd *qc);
@@ -160,6 +159,7 @@ extern void ata_scsi_error(struct Scsi_Host *host);
160extern void ata_port_wait_eh(struct ata_port *ap); 159extern void ata_port_wait_eh(struct ata_port *ap);
161extern void ata_eh_fastdrain_timerfn(unsigned long arg); 160extern void ata_eh_fastdrain_timerfn(unsigned long arg);
162extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc); 161extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc);
162extern void ata_dev_disable(struct ata_device *dev);
163extern void ata_eh_detach_dev(struct ata_device *dev); 163extern void ata_eh_detach_dev(struct ata_device *dev);
164extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev, 164extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
165 unsigned int action); 165 unsigned int action);
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 3080f371222c..f1b26f7c8e4d 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -12,7 +12,7 @@
12 * 12 *
13 * Probe code based on drivers/ide/legacy/qd65xx.c 13 * Probe code based on drivers/ide/legacy/qd65xx.c
14 * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by 14 * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by
15 * Samuel Thibault <samuel.thibault@fnac.net> 15 * Samuel Thibault <samuel.thibault@ens-lyon.org>
16 */ 16 */
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 79a6c9a0b721..ba556d3e6963 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -110,7 +110,8 @@ static const struct via_isa_bridge {
110 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 110 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
111 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 111 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
112 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA }, 112 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA },
113 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES}, 113 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES },
114 { "vt6415", PCI_DEVICE_ID_VIA_6415, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES },
114 { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 115 { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
115 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 116 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
116 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 117 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
@@ -593,6 +594,7 @@ static int via_reinit_one(struct pci_dev *pdev)
593#endif 594#endif
594 595
595static const struct pci_device_id via[] = { 596static const struct pci_device_id via[] = {
597 { PCI_VDEVICE(VIA, 0x0415), },
596 { PCI_VDEVICE(VIA, 0x0571), }, 598 { PCI_VDEVICE(VIA, 0x0571), },
597 { PCI_VDEVICE(VIA, 0x0581), }, 599 { PCI_VDEVICE(VIA, 0x0581), },
598 { PCI_VDEVICE(VIA, 0x1571), }, 600 { PCI_VDEVICE(VIA, 0x1571), },
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index f2d8a020ea53..4ae1a4138b47 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -663,8 +663,8 @@ static const struct pci_device_id mv_pci_tbl[] = {
663 { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, 663 { PCI_VDEVICE(MARVELL, 0x5081), chip_508x },
664 /* RocketRAID 1720/174x have different identifiers */ 664 /* RocketRAID 1720/174x have different identifiers */
665 { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, 665 { PCI_VDEVICE(TTI, 0x1720), chip_6042 },
666 { PCI_VDEVICE(TTI, 0x1740), chip_508x }, 666 { PCI_VDEVICE(TTI, 0x1740), chip_6042 },
667 { PCI_VDEVICE(TTI, 0x1742), chip_508x }, 667 { PCI_VDEVICE(TTI, 0x1742), chip_6042 },
668 668
669 { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, 669 { PCI_VDEVICE(MARVELL, 0x6040), chip_604x },
670 { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, 670 { PCI_VDEVICE(MARVELL, 0x6041), chip_604x },
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index c49ad0e61b6f..55a8eed3f3a3 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -421,26 +421,33 @@ static struct ata_port_operations nv_generic_ops = {
421 .hardreset = ATA_OP_NULL, 421 .hardreset = ATA_OP_NULL,
422}; 422};
423 423
424/* OSDL bz3352 reports that nf2/3 controllers can't determine device 424/* nf2 is ripe with hardreset related problems.
425 * signature reliably. Also, the following thread reports detection 425 *
426 * failure on cold boot with the standard debouncing timing. 426 * kernel bz#3352 reports nf2/3 controllers can't determine device
427 * signature reliably. The following thread reports detection failure
428 * on cold boot with the standard debouncing timing.
427 * 429 *
428 * http://thread.gmane.org/gmane.linux.ide/34098 430 * http://thread.gmane.org/gmane.linux.ide/34098
429 * 431 *
430 * Debounce with hotplug timing and request follow-up SRST. 432 * And bz#12176 reports that hardreset simply doesn't work on nf2.
433 * Give up on it and just don't do hardreset.
431 */ 434 */
432static struct ata_port_operations nv_nf2_ops = { 435static struct ata_port_operations nv_nf2_ops = {
433 .inherits = &nv_common_ops, 436 .inherits = &nv_generic_ops,
434 .freeze = nv_nf2_freeze, 437 .freeze = nv_nf2_freeze,
435 .thaw = nv_nf2_thaw, 438 .thaw = nv_nf2_thaw,
436 .hardreset = nv_noclassify_hardreset,
437}; 439};
438 440
439/* CK804 finally gets hardreset right */ 441/* For initial probing after boot and hot plugging, hardreset mostly
442 * works fine on CK804 but curiously, reprobing on the initial port by
443 * rescanning or rmmod/insmod fails to acquire the initial D2H Reg FIS
444 * in somewhat undeterministic way. Use noclassify hardreset.
445 */
440static struct ata_port_operations nv_ck804_ops = { 446static struct ata_port_operations nv_ck804_ops = {
441 .inherits = &nv_common_ops, 447 .inherits = &nv_common_ops,
442 .freeze = nv_ck804_freeze, 448 .freeze = nv_ck804_freeze,
443 .thaw = nv_ck804_thaw, 449 .thaw = nv_ck804_thaw,
450 .hardreset = nv_noclassify_hardreset,
444 .host_stop = nv_ck804_host_stop, 451 .host_stop = nv_ck804_host_stop,
445}; 452};
446 453
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 9f029595f454..d0091609e210 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -324,7 +324,7 @@ static void sil_fill_sg(struct ata_queued_cmd *qc)
324 324
325 prd->addr = cpu_to_le32(addr); 325 prd->addr = cpu_to_le32(addr);
326 prd->flags_len = cpu_to_le32(sg_len); 326 prd->flags_len = cpu_to_le32(sg_len);
327 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", pi, addr, sg_len); 327 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", si, addr, sg_len);
328 328
329 last_prd = prd; 329 last_prd = prd;
330 prd++; 330 prd++;
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 0a5f055dffba..9f50f1b545dc 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -88,8 +88,6 @@ extern void driver_detach(struct device_driver *drv);
88extern int driver_probe_device(struct device_driver *drv, struct device *dev); 88extern int driver_probe_device(struct device_driver *drv, struct device *dev);
89 89
90extern void sysdev_shutdown(void); 90extern void sysdev_shutdown(void);
91extern int sysdev_suspend(pm_message_t state);
92extern int sysdev_resume(void);
93 91
94extern char *make_class_name(const char *name, struct kobject *kobj); 92extern char *make_class_name(const char *name, struct kobject *kobj);
95 93
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 315bed8d5e7f..135231239103 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -18,9 +18,11 @@
18 */ 18 */
19 19
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/delay.h>
21#include <linux/module.h> 22#include <linux/module.h>
22#include <linux/kthread.h> 23#include <linux/kthread.h>
23#include <linux/wait.h> 24#include <linux/wait.h>
25#include <linux/async.h>
24 26
25#include "base.h" 27#include "base.h"
26#include "power/power.h" 28#include "power/power.h"
@@ -168,6 +170,21 @@ int driver_probe_done(void)
168} 170}
169 171
170/** 172/**
173 * wait_for_device_probe
174 * Wait for device probing to be completed.
175 *
176 * Note: this function polls at 100 msec intervals.
177 */
178int wait_for_device_probe(void)
179{
180 /* wait for the known devices to complete their probing */
181 while (driver_probe_done() != 0)
182 msleep(100);
183 async_synchronize_full();
184 return 0;
185}
186
187/**
171 * driver_probe_device - attempt to bind device & driver together 188 * driver_probe_device - attempt to bind device & driver together
172 * @drv: driver to bind a device to 189 * @drv: driver to bind a device to
173 * @dev: device to try to bind to the driver 190 * @dev: device to try to bind to the driver
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 670c9d6c1407..2d14f4ae6c01 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -333,7 +333,6 @@ static void dpm_power_up(pm_message_t state)
333 */ 333 */
334void device_power_up(pm_message_t state) 334void device_power_up(pm_message_t state)
335{ 335{
336 sysdev_resume();
337 dpm_power_up(state); 336 dpm_power_up(state);
338} 337}
339EXPORT_SYMBOL_GPL(device_power_up); 338EXPORT_SYMBOL_GPL(device_power_up);
@@ -577,8 +576,6 @@ int device_power_down(pm_message_t state)
577 } 576 }
578 dev->power.status = DPM_OFF_IRQ; 577 dev->power.status = DPM_OFF_IRQ;
579 } 578 }
580 if (!error)
581 error = sysdev_suspend(state);
582 if (error) 579 if (error)
583 dpm_power_up(resume_event(state)); 580 dpm_power_up(resume_event(state));
584 return error; 581 return error;
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index c98c31ec2f75..b428c8c4bc64 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -303,7 +303,6 @@ void sysdev_unregister(struct sys_device * sysdev)
303 * is guaranteed by virtue of the fact that child devices are registered 303 * is guaranteed by virtue of the fact that child devices are registered
304 * after their parents. 304 * after their parents.
305 */ 305 */
306
307void sysdev_shutdown(void) 306void sysdev_shutdown(void)
308{ 307{
309 struct sysdev_class * cls; 308 struct sysdev_class * cls;
@@ -363,7 +362,6 @@ static void __sysdev_resume(struct sys_device *dev)
363 * This is only called by the device PM core, so we let them handle 362 * This is only called by the device PM core, so we let them handle
364 * all synchronization. 363 * all synchronization.
365 */ 364 */
366
367int sysdev_suspend(pm_message_t state) 365int sysdev_suspend(pm_message_t state)
368{ 366{
369 struct sysdev_class * cls; 367 struct sysdev_class * cls;
@@ -432,7 +430,7 @@ aux_driver:
432 } 430 }
433 return ret; 431 return ret;
434} 432}
435 433EXPORT_SYMBOL_GPL(sysdev_suspend);
436 434
437/** 435/**
438 * sysdev_resume - Bring system devices back to life. 436 * sysdev_resume - Bring system devices back to life.
@@ -442,7 +440,6 @@ aux_driver:
442 * 440 *
443 * Note: Interrupts are disabled when called. 441 * Note: Interrupts are disabled when called.
444 */ 442 */
445
446int sysdev_resume(void) 443int sysdev_resume(void)
447{ 444{
448 struct sysdev_class * cls; 445 struct sysdev_class * cls;
@@ -463,7 +460,7 @@ int sysdev_resume(void)
463 } 460 }
464 return 0; 461 return 0;
465} 462}
466 463EXPORT_SYMBOL_GPL(sysdev_resume);
467 464
468int __init system_bus_init(void) 465int __init system_bus_init(void)
469{ 466{
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index c237527b1aa5..5e41e6dd657b 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -18,6 +18,7 @@
18enum { 18enum {
19 AOECMD_ATA, 19 AOECMD_ATA,
20 AOECMD_CFG, 20 AOECMD_CFG,
21 AOECMD_VEND_MIN = 0xf0,
21 22
22 AOEFL_RSP = (1<<3), 23 AOEFL_RSP = (1<<3),
23 AOEFL_ERR = (1<<2), 24 AOEFL_ERR = (1<<2),
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index 30de5b1c647e..c6099ba9a4b8 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -142,6 +142,8 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
142 aoecmd_cfg_rsp(skb); 142 aoecmd_cfg_rsp(skb);
143 break; 143 break;
144 default: 144 default:
145 if (h->cmd >= AOECMD_VEND_MIN)
146 break; /* don't complain about vendor commands */
145 printk(KERN_INFO "aoe: unknown cmd %d\n", h->cmd); 147 printk(KERN_INFO "aoe: unknown cmd %d\n", h->cmd);
146 } 148 }
147exit: 149exit:
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 69e1df7dfa14..4234c11c1e4c 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1730,7 +1730,7 @@ static int __init fd_test_drive_present( int drive )
1730 1730
1731 timeout = jiffies + 2*HZ+HZ/2; 1731 timeout = jiffies + 2*HZ+HZ/2;
1732 while (time_before(jiffies, timeout)) 1732 while (time_before(jiffies, timeout))
1733 if (!(mfp.par_dt_reg & 0x20)) 1733 if (!(st_mfp.par_dt_reg & 0x20))
1734 break; 1734 break;
1735 1735
1736 status = FDC_READ( FDCREG_STATUS ); 1736 status = FDC_READ( FDCREG_STATUS );
@@ -1747,7 +1747,7 @@ static int __init fd_test_drive_present( int drive )
1747 /* dummy seek command to make WP bit accessible */ 1747 /* dummy seek command to make WP bit accessible */
1748 FDC_WRITE( FDCREG_DATA, 0 ); 1748 FDC_WRITE( FDCREG_DATA, 0 );
1749 FDC_WRITE( FDCREG_CMD, FDCCMD_SEEK ); 1749 FDC_WRITE( FDCREG_CMD, FDCCMD_SEEK );
1750 while( mfp.par_dt_reg & 0x20 ) 1750 while( st_mfp.par_dt_reg & 0x20 )
1751 ; 1751 ;
1752 status = FDC_READ( FDCREG_STATUS ); 1752 status = FDC_READ( FDCREG_STATUS );
1753 } 1753 }
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 01e69383d9c0..d2cb67b61176 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3390,6 +3390,203 @@ static void free_hba(int i)
3390 kfree(p); 3390 kfree(p);
3391} 3391}
3392 3392
3393/* Send a message CDB to the firmware. */
3394static __devinit int cciss_message(struct pci_dev *pdev, unsigned char opcode, unsigned char type)
3395{
3396 typedef struct {
3397 CommandListHeader_struct CommandHeader;
3398 RequestBlock_struct Request;
3399 ErrDescriptor_struct ErrorDescriptor;
3400 } Command;
3401 static const size_t cmd_sz = sizeof(Command) + sizeof(ErrorInfo_struct);
3402 Command *cmd;
3403 dma_addr_t paddr64;
3404 uint32_t paddr32, tag;
3405 void __iomem *vaddr;
3406 int i, err;
3407
3408 vaddr = ioremap_nocache(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
3409 if (vaddr == NULL)
3410 return -ENOMEM;
3411
3412 /* The Inbound Post Queue only accepts 32-bit physical addresses for the
3413 CCISS commands, so they must be allocated from the lower 4GiB of
3414 memory. */
3415 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
3416 if (err) {
3417 iounmap(vaddr);
3418 return -ENOMEM;
3419 }
3420
3421 cmd = pci_alloc_consistent(pdev, cmd_sz, &paddr64);
3422 if (cmd == NULL) {
3423 iounmap(vaddr);
3424 return -ENOMEM;
3425 }
3426
3427 /* This must fit, because of the 32-bit consistent DMA mask. Also,
3428 although there's no guarantee, we assume that the address is at
3429 least 4-byte aligned (most likely, it's page-aligned). */
3430 paddr32 = paddr64;
3431
3432 cmd->CommandHeader.ReplyQueue = 0;
3433 cmd->CommandHeader.SGList = 0;
3434 cmd->CommandHeader.SGTotal = 0;
3435 cmd->CommandHeader.Tag.lower = paddr32;
3436 cmd->CommandHeader.Tag.upper = 0;
3437 memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8);
3438
3439 cmd->Request.CDBLen = 16;
3440 cmd->Request.Type.Type = TYPE_MSG;
3441 cmd->Request.Type.Attribute = ATTR_HEADOFQUEUE;
3442 cmd->Request.Type.Direction = XFER_NONE;
3443 cmd->Request.Timeout = 0; /* Don't time out */
3444 cmd->Request.CDB[0] = opcode;
3445 cmd->Request.CDB[1] = type;
3446 memset(&cmd->Request.CDB[2], 0, 14); /* the rest of the CDB is reserved */
3447
3448 cmd->ErrorDescriptor.Addr.lower = paddr32 + sizeof(Command);
3449 cmd->ErrorDescriptor.Addr.upper = 0;
3450 cmd->ErrorDescriptor.Len = sizeof(ErrorInfo_struct);
3451
3452 writel(paddr32, vaddr + SA5_REQUEST_PORT_OFFSET);
3453
3454 for (i = 0; i < 10; i++) {
3455 tag = readl(vaddr + SA5_REPLY_PORT_OFFSET);
3456 if ((tag & ~3) == paddr32)
3457 break;
3458 schedule_timeout_uninterruptible(HZ);
3459 }
3460
3461 iounmap(vaddr);
3462
3463 /* we leak the DMA buffer here ... no choice since the controller could
3464 still complete the command. */
3465 if (i == 10) {
3466 printk(KERN_ERR "cciss: controller message %02x:%02x timed out\n",
3467 opcode, type);
3468 return -ETIMEDOUT;
3469 }
3470
3471 pci_free_consistent(pdev, cmd_sz, cmd, paddr64);
3472
3473 if (tag & 2) {
3474 printk(KERN_ERR "cciss: controller message %02x:%02x failed\n",
3475 opcode, type);
3476 return -EIO;
3477 }
3478
3479 printk(KERN_INFO "cciss: controller message %02x:%02x succeeded\n",
3480 opcode, type);
3481 return 0;
3482}
3483
3484#define cciss_soft_reset_controller(p) cciss_message(p, 1, 0)
3485#define cciss_noop(p) cciss_message(p, 3, 0)
3486
3487static __devinit int cciss_reset_msi(struct pci_dev *pdev)
3488{
3489/* the #defines are stolen from drivers/pci/msi.h. */
3490#define msi_control_reg(base) (base + PCI_MSI_FLAGS)
3491#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
3492
3493 int pos;
3494 u16 control = 0;
3495
3496 pos = pci_find_capability(pdev, PCI_CAP_ID_MSI);
3497 if (pos) {
3498 pci_read_config_word(pdev, msi_control_reg(pos), &control);
3499 if (control & PCI_MSI_FLAGS_ENABLE) {
3500 printk(KERN_INFO "cciss: resetting MSI\n");
3501 pci_write_config_word(pdev, msi_control_reg(pos), control & ~PCI_MSI_FLAGS_ENABLE);
3502 }
3503 }
3504
3505 pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
3506 if (pos) {
3507 pci_read_config_word(pdev, msi_control_reg(pos), &control);
3508 if (control & PCI_MSIX_FLAGS_ENABLE) {
3509 printk(KERN_INFO "cciss: resetting MSI-X\n");
3510 pci_write_config_word(pdev, msi_control_reg(pos), control & ~PCI_MSIX_FLAGS_ENABLE);
3511 }
3512 }
3513
3514 return 0;
3515}
3516
3517/* This does a hard reset of the controller using PCI power management
3518 * states. */
3519static __devinit int cciss_hard_reset_controller(struct pci_dev *pdev)
3520{
3521 u16 pmcsr, saved_config_space[32];
3522 int i, pos;
3523
3524 printk(KERN_INFO "cciss: using PCI PM to reset controller\n");
3525
3526 /* This is very nearly the same thing as
3527
3528 pci_save_state(pci_dev);
3529 pci_set_power_state(pci_dev, PCI_D3hot);
3530 pci_set_power_state(pci_dev, PCI_D0);
3531 pci_restore_state(pci_dev);
3532
3533 but we can't use these nice canned kernel routines on
3534 kexec, because they also check the MSI/MSI-X state in PCI
3535 configuration space and do the wrong thing when it is
3536 set/cleared. Also, the pci_save/restore_state functions
3537 violate the ordering requirements for restoring the
3538 configuration space from the CCISS document (see the
3539 comment below). So we roll our own .... */
3540
3541 for (i = 0; i < 32; i++)
3542 pci_read_config_word(pdev, 2*i, &saved_config_space[i]);
3543
3544 pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
3545 if (pos == 0) {
3546 printk(KERN_ERR "cciss_reset_controller: PCI PM not supported\n");
3547 return -ENODEV;
3548 }
3549
3550 /* Quoting from the Open CISS Specification: "The Power
3551 * Management Control/Status Register (CSR) controls the power
3552 * state of the device. The normal operating state is D0,
3553 * CSR=00h. The software off state is D3, CSR=03h. To reset
3554 * the controller, place the interface device in D3 then to
3555 * D0, this causes a secondary PCI reset which will reset the
3556 * controller." */
3557
3558 /* enter the D3hot power management state */
3559 pci_read_config_word(pdev, pos + PCI_PM_CTRL, &pmcsr);
3560 pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
3561 pmcsr |= PCI_D3hot;
3562 pci_write_config_word(pdev, pos + PCI_PM_CTRL, pmcsr);
3563
3564 schedule_timeout_uninterruptible(HZ >> 1);
3565
3566 /* enter the D0 power management state */
3567 pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
3568 pmcsr |= PCI_D0;
3569 pci_write_config_word(pdev, pos + PCI_PM_CTRL, pmcsr);
3570
3571 schedule_timeout_uninterruptible(HZ >> 1);
3572
3573 /* Restore the PCI configuration space. The Open CISS
3574 * Specification says, "Restore the PCI Configuration
3575 * Registers, offsets 00h through 60h. It is important to
3576 * restore the command register, 16-bits at offset 04h,
3577 * last. Do not restore the configuration status register,
3578 * 16-bits at offset 06h." Note that the offset is 2*i. */
3579 for (i = 0; i < 32; i++) {
3580 if (i == 2 || i == 3)
3581 continue;
3582 pci_write_config_word(pdev, 2*i, saved_config_space[i]);
3583 }
3584 wmb();
3585 pci_write_config_word(pdev, 4, saved_config_space[2]);
3586
3587 return 0;
3588}
3589
3393/* 3590/*
3394 * This is it. Find all the controllers and register them. I really hate 3591 * This is it. Find all the controllers and register them. I really hate
3395 * stealing all these major device numbers. 3592 * stealing all these major device numbers.
@@ -3404,6 +3601,24 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3404 int dac, return_code; 3601 int dac, return_code;
3405 InquiryData_struct *inq_buff = NULL; 3602 InquiryData_struct *inq_buff = NULL;
3406 3603
3604 if (reset_devices) {
3605 /* Reset the controller with a PCI power-cycle */
3606 if (cciss_hard_reset_controller(pdev) || cciss_reset_msi(pdev))
3607 return -ENODEV;
3608
3609 /* Some devices (notably the HP Smart Array 5i Controller)
3610 need a little pause here */
3611 schedule_timeout_uninterruptible(30*HZ);
3612
3613 /* Now try to get the controller to respond to a no-op */
3614 for (i=0; i<12; i++) {
3615 if (cciss_noop(pdev) == 0)
3616 break;
3617 else
3618 printk("cciss: no-op failed%s\n", (i < 11 ? "; re-trying" : ""));
3619 }
3620 }
3621
3407 i = alloc_cciss_hba(); 3622 i = alloc_cciss_hba();
3408 if (i < 0) 3623 if (i < 0)
3409 return -1; 3624 return -1;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index cf29cc4e6ab7..83d8ed39433d 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -558,6 +558,8 @@ static void process_fd_request(void);
558static void recalibrate_floppy(void); 558static void recalibrate_floppy(void);
559static void floppy_shutdown(unsigned long); 559static void floppy_shutdown(unsigned long);
560 560
561static int floppy_request_regions(int);
562static void floppy_release_regions(int);
561static int floppy_grab_irq_and_dma(void); 563static int floppy_grab_irq_and_dma(void);
562static void floppy_release_irq_and_dma(void); 564static void floppy_release_irq_and_dma(void);
563 565
@@ -4274,8 +4276,7 @@ static int __init floppy_init(void)
4274 FDCS->rawcmd = 2; 4276 FDCS->rawcmd = 2;
4275 if (user_reset_fdc(-1, FD_RESET_ALWAYS, 0)) { 4277 if (user_reset_fdc(-1, FD_RESET_ALWAYS, 0)) {
4276 /* free ioports reserved by floppy_grab_irq_and_dma() */ 4278 /* free ioports reserved by floppy_grab_irq_and_dma() */
4277 release_region(FDCS->address + 2, 4); 4279 floppy_release_regions(fdc);
4278 release_region(FDCS->address + 7, 1);
4279 FDCS->address = -1; 4280 FDCS->address = -1;
4280 FDCS->version = FDC_NONE; 4281 FDCS->version = FDC_NONE;
4281 continue; 4282 continue;
@@ -4284,8 +4285,7 @@ static int __init floppy_init(void)
4284 FDCS->version = get_fdc_version(); 4285 FDCS->version = get_fdc_version();
4285 if (FDCS->version == FDC_NONE) { 4286 if (FDCS->version == FDC_NONE) {
4286 /* free ioports reserved by floppy_grab_irq_and_dma() */ 4287 /* free ioports reserved by floppy_grab_irq_and_dma() */
4287 release_region(FDCS->address + 2, 4); 4288 floppy_release_regions(fdc);
4288 release_region(FDCS->address + 7, 1);
4289 FDCS->address = -1; 4289 FDCS->address = -1;
4290 continue; 4290 continue;
4291 } 4291 }
@@ -4358,6 +4358,47 @@ out_put_disk:
4358 4358
4359static DEFINE_SPINLOCK(floppy_usage_lock); 4359static DEFINE_SPINLOCK(floppy_usage_lock);
4360 4360
4361static const struct io_region {
4362 int offset;
4363 int size;
4364} io_regions[] = {
4365 { 2, 1 },
4366 /* address + 3 is sometimes reserved by pnp bios for motherboard */
4367 { 4, 2 },
4368 /* address + 6 is reserved, and may be taken by IDE.
4369 * Unfortunately, Adaptec doesn't know this :-(, */
4370 { 7, 1 },
4371};
4372
4373static void floppy_release_allocated_regions(int fdc, const struct io_region *p)
4374{
4375 while (p != io_regions) {
4376 p--;
4377 release_region(FDCS->address + p->offset, p->size);
4378 }
4379}
4380
4381#define ARRAY_END(X) (&((X)[ARRAY_SIZE(X)]))
4382
4383static int floppy_request_regions(int fdc)
4384{
4385 const struct io_region *p;
4386
4387 for (p = io_regions; p < ARRAY_END(io_regions); p++) {
4388 if (!request_region(FDCS->address + p->offset, p->size, "floppy")) {
4389 DPRINT("Floppy io-port 0x%04lx in use\n", FDCS->address + p->offset);
4390 floppy_release_allocated_regions(fdc, p);
4391 return -EBUSY;
4392 }
4393 }
4394 return 0;
4395}
4396
4397static void floppy_release_regions(int fdc)
4398{
4399 floppy_release_allocated_regions(fdc, ARRAY_END(io_regions));
4400}
4401
4361static int floppy_grab_irq_and_dma(void) 4402static int floppy_grab_irq_and_dma(void)
4362{ 4403{
4363 unsigned long flags; 4404 unsigned long flags;
@@ -4399,18 +4440,8 @@ static int floppy_grab_irq_and_dma(void)
4399 4440
4400 for (fdc = 0; fdc < N_FDC; fdc++) { 4441 for (fdc = 0; fdc < N_FDC; fdc++) {
4401 if (FDCS->address != -1) { 4442 if (FDCS->address != -1) {
4402 if (!request_region(FDCS->address + 2, 4, "floppy")) { 4443 if (floppy_request_regions(fdc))
4403 DPRINT("Floppy io-port 0x%04lx in use\n", 4444 goto cleanup;
4404 FDCS->address + 2);
4405 goto cleanup1;
4406 }
4407 if (!request_region(FDCS->address + 7, 1, "floppy DIR")) {
4408 DPRINT("Floppy io-port 0x%04lx in use\n",
4409 FDCS->address + 7);
4410 goto cleanup2;
4411 }
4412 /* address + 6 is reserved, and may be taken by IDE.
4413 * Unfortunately, Adaptec doesn't know this :-(, */
4414 } 4445 }
4415 } 4446 }
4416 for (fdc = 0; fdc < N_FDC; fdc++) { 4447 for (fdc = 0; fdc < N_FDC; fdc++) {
@@ -4432,15 +4463,11 @@ static int floppy_grab_irq_and_dma(void)
4432 fdc = 0; 4463 fdc = 0;
4433 irqdma_allocated = 1; 4464 irqdma_allocated = 1;
4434 return 0; 4465 return 0;
4435cleanup2: 4466cleanup:
4436 release_region(FDCS->address + 2, 4);
4437cleanup1:
4438 fd_free_irq(); 4467 fd_free_irq();
4439 fd_free_dma(); 4468 fd_free_dma();
4440 while (--fdc >= 0) { 4469 while (--fdc >= 0)
4441 release_region(FDCS->address + 2, 4); 4470 floppy_release_regions(fdc);
4442 release_region(FDCS->address + 7, 1);
4443 }
4444 spin_lock_irqsave(&floppy_usage_lock, flags); 4471 spin_lock_irqsave(&floppy_usage_lock, flags);
4445 usage_count--; 4472 usage_count--;
4446 spin_unlock_irqrestore(&floppy_usage_lock, flags); 4473 spin_unlock_irqrestore(&floppy_usage_lock, flags);
@@ -4501,10 +4528,8 @@ static void floppy_release_irq_and_dma(void)
4501#endif 4528#endif
4502 old_fdc = fdc; 4529 old_fdc = fdc;
4503 for (fdc = 0; fdc < N_FDC; fdc++) 4530 for (fdc = 0; fdc < N_FDC; fdc++)
4504 if (FDCS->address != -1) { 4531 if (FDCS->address != -1)
4505 release_region(FDCS->address + 2, 4); 4532 floppy_release_regions(fdc);
4506 release_region(FDCS->address + 7, 1);
4507 }
4508 fdc = old_fdc; 4533 fdc = old_fdc;
4509} 4534}
4510 4535
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 34f80fa6fed1..8299e2d3b611 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -549,6 +549,15 @@ static void do_nbd_request(struct request_queue * q)
549 549
550 BUG_ON(lo->magic != LO_MAGIC); 550 BUG_ON(lo->magic != LO_MAGIC);
551 551
552 if (unlikely(!lo->sock)) {
553 printk(KERN_ERR "%s: Attempted send on closed socket\n",
554 lo->disk->disk_name);
555 req->errors++;
556 nbd_end_request(req);
557 spin_lock_irq(q->queue_lock);
558 continue;
559 }
560
552 spin_lock_irq(&lo->queue_lock); 561 spin_lock_irq(&lo->queue_lock);
553 list_add_tail(&req->queuelist, &lo->waiting_queue); 562 list_add_tail(&req->queuelist, &lo->waiting_queue);
554 spin_unlock_irq(&lo->queue_lock); 563 spin_unlock_irq(&lo->queue_lock);
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index 9dfa27163001..c397b3ddba9b 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -422,7 +422,7 @@ static void xs(char *buf, char *targ, int len)
422 422
423 for (k = 0; k < len; k++) { 423 for (k = 0; k < len; k++) {
424 char c = *buf++; 424 char c = *buf++;
425 if (c != ' ' || c != l) 425 if (c != ' ' && c != l)
426 l = *targ++ = c; 426 l = *targ++ = c;
427 } 427 }
428 if (l == ' ') 428 if (l == ' ')
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index f5be8081cd81..735bbe2be51a 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -761,7 +761,7 @@ source "drivers/char/hw_random/Kconfig"
761 761
762config NVRAM 762config NVRAM
763 tristate "/dev/nvram support" 763 tristate "/dev/nvram support"
764 depends on ATARI || X86 || ARM || GENERIC_NVRAM 764 depends on ATARI || X86 || (ARM && RTC_DRV_CMOS) || GENERIC_NVRAM
765 ---help--- 765 ---help---
766 If you say Y here and create a character special file /dev/nvram 766 If you say Y here and create a character special file /dev/nvram
767 with major number 10 and minor number 144 using mknod ("man mknod"), 767 with major number 10 and minor number 144 using mknod ("man mknod"),
diff --git a/drivers/char/scc.h b/drivers/char/scc.h
index 93998f5baff5..341b1142bea8 100644
--- a/drivers/char/scc.h
+++ b/drivers/char/scc.h
@@ -387,7 +387,7 @@ struct scc_port {
387/* The SCC needs 3.5 PCLK cycles recovery time between to register 387/* The SCC needs 3.5 PCLK cycles recovery time between to register
388 * accesses. PCLK runs with 8 MHz on an Atari, so this delay is 3.5 * 388 * accesses. PCLK runs with 8 MHz on an Atari, so this delay is 3.5 *
389 * 125 ns = 437.5 ns. This is too short for udelay(). 389 * 125 ns = 437.5 ns. This is too short for udelay().
390 * 10/16/95: A tstb mfp.par_dt_reg takes 600ns (sure?) and thus should be 390 * 10/16/95: A tstb st_mfp.par_dt_reg takes 600ns (sure?) and thus should be
391 * quite right 391 * quite right
392 */ 392 */
393 393
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index b60be7b0decf..518f2a25d91e 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -1713,8 +1713,8 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd,
1713 for (i = 0; i < SX_NBOARDS; i++) 1713 for (i = 0; i < SX_NBOARDS; i++)
1714 sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags); 1714 sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags);
1715 sx_dprintk(SX_DEBUG_FIRMWARE, "\n"); 1715 sx_dprintk(SX_DEBUG_FIRMWARE, "\n");
1716 unlock_kernel(); 1716 rc = -EIO;
1717 return -EIO; 1717 goto out;
1718 } 1718 }
1719 1719
1720 switch (cmd) { 1720 switch (cmd) {
@@ -1746,8 +1746,10 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd,
1746 sx_dprintk(SX_DEBUG_FIRMWARE, "returning type= %ld\n", rc); 1746 sx_dprintk(SX_DEBUG_FIRMWARE, "returning type= %ld\n", rc);
1747 break; 1747 break;
1748 case SXIO_DO_RAMTEST: 1748 case SXIO_DO_RAMTEST:
1749 if (sx_initialized) /* Already initialized: better not ramtest the board. */ 1749 if (sx_initialized) { /* Already initialized: better not ramtest the board. */
1750 return -EPERM; 1750 rc = -EPERM;
1751 break;
1752 }
1751 if (IS_SX_BOARD(board)) { 1753 if (IS_SX_BOARD(board)) {
1752 rc = do_memtest(board, 0, 0x7000); 1754 rc = do_memtest(board, 0, 0x7000);
1753 if (!rc) 1755 if (!rc)
@@ -1787,7 +1789,7 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd,
1787 nbytes - i : SX_CHUNK_SIZE)) { 1789 nbytes - i : SX_CHUNK_SIZE)) {
1788 kfree(tmp); 1790 kfree(tmp);
1789 rc = -EFAULT; 1791 rc = -EFAULT;
1790 break; 1792 goto out;
1791 } 1793 }
1792 memcpy_toio(board->base2 + offset + i, tmp, 1794 memcpy_toio(board->base2 + offset + i, tmp,
1793 (i + SX_CHUNK_SIZE > nbytes) ? 1795 (i + SX_CHUNK_SIZE > nbytes) ?
@@ -1844,6 +1846,7 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd,
1844 rc = -ENOTTY; 1846 rc = -ENOTTY;
1845 break; 1847 break;
1846 } 1848 }
1849out:
1847 unlock_kernel(); 1850 unlock_kernel();
1848 func_exit(); 1851 func_exit();
1849 return rc; 1852 return rc;
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 726ee8a0277f..ecba4942fc8e 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -4,7 +4,7 @@
4 * SLD 9630 TT 1.1 and SLB 9635 TT 1.2 Trusted Platform Module 4 * SLD 9630 TT 1.1 and SLB 9635 TT 1.2 Trusted Platform Module
5 * Specifications at www.trustedcomputinggroup.org 5 * Specifications at www.trustedcomputinggroup.org
6 * 6 *
7 * Copyright (C) 2005, Marcel Selhorst <selhorst@crypto.rub.de> 7 * Copyright (C) 2005, Marcel Selhorst <m.selhorst@sirrix.com>
8 * Sirrix AG - security technologies, http://www.sirrix.com and 8 * Sirrix AG - security technologies, http://www.sirrix.com and
9 * Applied Data Security Group, Ruhr-University Bochum, Germany 9 * Applied Data Security Group, Ruhr-University Bochum, Germany
10 * Project-Homepage: http://www.prosec.rub.de/tpm 10 * Project-Homepage: http://www.prosec.rub.de/tpm
@@ -636,7 +636,7 @@ static void __exit cleanup_inf(void)
636module_init(init_inf); 636module_init(init_inf);
637module_exit(cleanup_inf); 637module_exit(cleanup_inf);
638 638
639MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>"); 639MODULE_AUTHOR("Marcel Selhorst <m.selhorst@sirrix.com>");
640MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); 640MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2");
641MODULE_VERSION("1.9"); 641MODULE_VERSION("1.9");
642MODULE_LICENSE("GPL"); 642MODULE_LICENSE("GPL");
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 6a2b036c9389..6f45b1658a67 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -117,11 +117,7 @@ static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
117 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); 117 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq);
118 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); 118 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq);
119 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); 119 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal);
120 120 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice);
121 if (!dbs_tuners_ins.ignore_nice) {
122 busy_time = cputime64_add(busy_time,
123 kstat_cpu(cpu).cpustat.nice);
124 }
125 121
126 idle_time = cputime64_sub(cur_wall_time, busy_time); 122 idle_time = cputime64_sub(cur_wall_time, busy_time);
127 if (wall) 123 if (wall)
@@ -137,23 +133,6 @@ static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)
137 if (idle_time == -1ULL) 133 if (idle_time == -1ULL)
138 return get_cpu_idle_time_jiffy(cpu, wall); 134 return get_cpu_idle_time_jiffy(cpu, wall);
139 135
140 if (dbs_tuners_ins.ignore_nice) {
141 cputime64_t cur_nice;
142 unsigned long cur_nice_jiffies;
143 struct cpu_dbs_info_s *dbs_info;
144
145 dbs_info = &per_cpu(cpu_dbs_info, cpu);
146 cur_nice = cputime64_sub(kstat_cpu(cpu).cpustat.nice,
147 dbs_info->prev_cpu_nice);
148 /*
149 * Assumption: nice time between sampling periods will be
150 * less than 2^32 jiffies for 32 bit sys
151 */
152 cur_nice_jiffies = (unsigned long)
153 cputime64_to_jiffies64(cur_nice);
154 dbs_info->prev_cpu_nice = kstat_cpu(cpu).cpustat.nice;
155 return idle_time + jiffies_to_usecs(cur_nice_jiffies);
156 }
157 return idle_time; 136 return idle_time;
158} 137}
159 138
@@ -319,6 +298,9 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
319 dbs_info = &per_cpu(cpu_dbs_info, j); 298 dbs_info = &per_cpu(cpu_dbs_info, j);
320 dbs_info->prev_cpu_idle = get_cpu_idle_time(j, 299 dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
321 &dbs_info->prev_cpu_wall); 300 &dbs_info->prev_cpu_wall);
301 if (dbs_tuners_ins.ignore_nice)
302 dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
303
322 } 304 }
323 mutex_unlock(&dbs_mutex); 305 mutex_unlock(&dbs_mutex);
324 306
@@ -419,6 +401,23 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
419 j_dbs_info->prev_cpu_idle); 401 j_dbs_info->prev_cpu_idle);
420 j_dbs_info->prev_cpu_idle = cur_idle_time; 402 j_dbs_info->prev_cpu_idle = cur_idle_time;
421 403
404 if (dbs_tuners_ins.ignore_nice) {
405 cputime64_t cur_nice;
406 unsigned long cur_nice_jiffies;
407
408 cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice,
409 j_dbs_info->prev_cpu_nice);
410 /*
411 * Assumption: nice time between sampling periods will
412 * be less than 2^32 jiffies for 32 bit sys
413 */
414 cur_nice_jiffies = (unsigned long)
415 cputime64_to_jiffies64(cur_nice);
416
417 j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
418 idle_time += jiffies_to_usecs(cur_nice_jiffies);
419 }
420
422 if (unlikely(!wall_time || wall_time < idle_time)) 421 if (unlikely(!wall_time || wall_time < idle_time))
423 continue; 422 continue;
424 423
@@ -575,6 +574,10 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
575 574
576 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, 575 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
577 &j_dbs_info->prev_cpu_wall); 576 &j_dbs_info->prev_cpu_wall);
577 if (dbs_tuners_ins.ignore_nice) {
578 j_dbs_info->prev_cpu_nice =
579 kstat_cpu(j).cpustat.nice;
580 }
578 } 581 }
579 this_dbs_info->cpu = cpu; 582 this_dbs_info->cpu = cpu;
580 /* 583 /*
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index a58993011edb..280a9d263eb3 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -518,6 +518,7 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v
518 dma_chan_name(chan), err); 518 dma_chan_name(chan), err);
519 else 519 else
520 break; 520 break;
521 chan->private = NULL;
521 chan = NULL; 522 chan = NULL;
522 } 523 }
523 } 524 }
@@ -536,6 +537,7 @@ void dma_release_channel(struct dma_chan *chan)
536 WARN_ONCE(chan->client_count != 1, 537 WARN_ONCE(chan->client_count != 1,
537 "chan reference count %d != 1\n", chan->client_count); 538 "chan reference count %d != 1\n", chan->client_count);
538 dma_chan_put(chan); 539 dma_chan_put(chan);
540 chan->private = NULL;
539 mutex_unlock(&dma_list_mutex); 541 mutex_unlock(&dma_list_mutex);
540} 542}
541EXPORT_SYMBOL_GPL(dma_release_channel); 543EXPORT_SYMBOL_GPL(dma_release_channel);
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 6b702cc46b3d..a97c07eef7ec 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -560,7 +560,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
560 unsigned long flags) 560 unsigned long flags)
561{ 561{
562 struct dw_dma_chan *dwc = to_dw_dma_chan(chan); 562 struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
563 struct dw_dma_slave *dws = dwc->dws; 563 struct dw_dma_slave *dws = chan->private;
564 struct dw_desc *prev; 564 struct dw_desc *prev;
565 struct dw_desc *first; 565 struct dw_desc *first;
566 u32 ctllo; 566 u32 ctllo;
@@ -790,7 +790,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan)
790 cfghi = DWC_CFGH_FIFO_MODE; 790 cfghi = DWC_CFGH_FIFO_MODE;
791 cfglo = 0; 791 cfglo = 0;
792 792
793 dws = dwc->dws; 793 dws = chan->private;
794 if (dws) { 794 if (dws) {
795 /* 795 /*
796 * We need controller-specific data to set up slave 796 * We need controller-specific data to set up slave
@@ -866,7 +866,6 @@ static void dwc_free_chan_resources(struct dma_chan *chan)
866 spin_lock_bh(&dwc->lock); 866 spin_lock_bh(&dwc->lock);
867 list_splice_init(&dwc->free_list, &list); 867 list_splice_init(&dwc->free_list, &list);
868 dwc->descs_allocated = 0; 868 dwc->descs_allocated = 0;
869 dwc->dws = NULL;
870 869
871 /* Disable interrupts */ 870 /* Disable interrupts */
872 channel_clear_bit(dw, MASK.XFER, dwc->mask); 871 channel_clear_bit(dw, MASK.XFER, dwc->mask);
diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw_dmac_regs.h
index 00fdd187bb0c..b252b202c5cf 100644
--- a/drivers/dma/dw_dmac_regs.h
+++ b/drivers/dma/dw_dmac_regs.h
@@ -139,8 +139,6 @@ struct dw_dma_chan {
139 struct list_head queue; 139 struct list_head queue;
140 struct list_head free_list; 140 struct list_head free_list;
141 141
142 struct dw_dma_slave *dws;
143
144 unsigned int descs_allocated; 142 unsigned int descs_allocated;
145}; 143};
146 144
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 7be2cf3514e7..a5dd7a665aa8 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -412,6 +412,7 @@ fw_card_add(struct fw_card *card,
412{ 412{
413 u32 *config_rom; 413 u32 *config_rom;
414 size_t length; 414 size_t length;
415 int err;
415 416
416 card->max_receive = max_receive; 417 card->max_receive = max_receive;
417 card->link_speed = link_speed; 418 card->link_speed = link_speed;
@@ -422,7 +423,13 @@ fw_card_add(struct fw_card *card,
422 list_add_tail(&card->link, &card_list); 423 list_add_tail(&card->link, &card_list);
423 mutex_unlock(&card_mutex); 424 mutex_unlock(&card_mutex);
424 425
425 return card->driver->enable(card, config_rom, length); 426 err = card->driver->enable(card, config_rom, length);
427 if (err < 0) {
428 mutex_lock(&card_mutex);
429 list_del(&card->link);
430 mutex_unlock(&card_mutex);
431 }
432 return err;
426} 433}
427EXPORT_SYMBOL(fw_card_add); 434EXPORT_SYMBOL(fw_card_add);
428 435
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index 261b9aa3f248..05aa2d406ac6 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/drivers/firmware/memmap.c 2 * linux/drivers/firmware/memmap.c
3 * Copyright (C) 2008 SUSE LINUX Products GmbH 3 * Copyright (C) 2008 SUSE LINUX Products GmbH
4 * by Bernhard Walle <bwalle@suse.de> 4 * by Bernhard Walle <bernhard.walle@gmx.de>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License v2.0 as published by 7 * it under the terms of the GNU General Public License v2.0 as published by
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 5130b72d593c..3a22eb9be378 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -70,7 +70,7 @@ config DRM_I915
70 select FB_CFB_FILLRECT 70 select FB_CFB_FILLRECT
71 select FB_CFB_COPYAREA 71 select FB_CFB_COPYAREA
72 select FB_CFB_IMAGEBLIT 72 select FB_CFB_IMAGEBLIT
73 depends on FB 73 select FB
74 tristate "i915 driver" 74 tristate "i915 driver"
75 help 75 help
76 Choose this option if you have a system that has Intel 830M, 845G, 76 Choose this option if you have a system that has Intel 830M, 845G,
@@ -80,18 +80,17 @@ config DRM_I915
80 XFree86 4.4 and above. If unsure, build this and i830 as modules and 80 XFree86 4.4 and above. If unsure, build this and i830 as modules and
81 the X server will load the correct one. 81 the X server will load the correct one.
82 82
83endchoice
84
85config DRM_I915_KMS 83config DRM_I915_KMS
86 bool "Enable modesetting on intel by default" 84 bool "Enable modesetting on intel by default"
87 depends on DRM_I915 85 depends on DRM_I915
88 help 86 help
89 Choose this option if you want kernel modesetting enabled by default, 87 Choose this option if you want kernel modesetting enabled by default,
90 and you have a new enough userspace to support this. Running old 88 and you have a new enough userspace to support this. Running old
91 userspaces with this enabled will cause pain. Note that this causes 89 userspaces with this enabled will cause pain. Note that this causes
92 the driver to bind to PCI devices, which precludes loading things 90 the driver to bind to PCI devices, which precludes loading things
93 like intelfb. 91 like intelfb.
94 92
93endchoice
95 94
96config DRM_MGA 95config DRM_MGA
97 tristate "Matrox g200/g400" 96 tristate "Matrox g200/g400"
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index bfce0992fefb..94a768871734 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1741,9 +1741,8 @@ out:
1741 * RETURNS: 1741 * RETURNS:
1742 * Zero on success, errno on failure. 1742 * Zero on success, errno on failure.
1743 */ 1743 */
1744void drm_fb_release(struct file *filp) 1744void drm_fb_release(struct drm_file *priv)
1745{ 1745{
1746 struct drm_file *priv = filp->private_data;
1747 struct drm_device *dev = priv->minor->dev; 1746 struct drm_device *dev = priv->minor->dev;
1748 struct drm_framebuffer *fb, *tfb; 1747 struct drm_framebuffer *fb, *tfb;
1749 1748
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 964c5eb1fada..733028b4d45e 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -512,8 +512,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
512 if (drm_mode_equal(&saved_mode, &crtc->mode)) { 512 if (drm_mode_equal(&saved_mode, &crtc->mode)) {
513 if (saved_x != crtc->x || saved_y != crtc->y || 513 if (saved_x != crtc->x || saved_y != crtc->y ||
514 depth_changed || bpp_changed) { 514 depth_changed || bpp_changed) {
515 crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y, 515 ret = !crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y,
516 old_fb); 516 old_fb);
517 goto done; 517 goto done;
518 } 518 }
519 } 519 }
@@ -552,7 +552,9 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
552 /* Set up the DPLL and any encoders state that needs to adjust or depend 552 /* Set up the DPLL and any encoders state that needs to adjust or depend
553 * on the DPLL. 553 * on the DPLL.
554 */ 554 */
555 crtc_funcs->mode_set(crtc, mode, adjusted_mode, x, y, old_fb); 555 ret = !crtc_funcs->mode_set(crtc, mode, adjusted_mode, x, y, old_fb);
556 if (!ret)
557 goto done;
556 558
557 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 559 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
558 560
@@ -752,6 +754,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
752 if (!drm_crtc_helper_set_mode(set->crtc, set->mode, 754 if (!drm_crtc_helper_set_mode(set->crtc, set->mode,
753 set->x, set->y, 755 set->x, set->y,
754 old_fb)) { 756 old_fb)) {
757 DRM_ERROR("failed to set mode on crtc %p\n",
758 set->crtc);
755 ret = -EINVAL; 759 ret = -EINVAL;
756 goto fail_set_mode; 760 goto fail_set_mode;
757 } 761 }
@@ -765,7 +769,10 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
765 old_fb = set->crtc->fb; 769 old_fb = set->crtc->fb;
766 if (set->crtc->fb != set->fb) 770 if (set->crtc->fb != set->fb)
767 set->crtc->fb = set->fb; 771 set->crtc->fb = set->fb;
768 crtc_funcs->mode_set_base(set->crtc, set->x, set->y, old_fb); 772 ret = crtc_funcs->mode_set_base(set->crtc,
773 set->x, set->y, old_fb);
774 if (ret != 0)
775 goto fail_set_mode;
769 } 776 }
770 777
771 kfree(save_encoders); 778 kfree(save_encoders);
@@ -775,8 +782,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
775fail_set_mode: 782fail_set_mode:
776 set->crtc->enabled = save_enabled; 783 set->crtc->enabled = save_enabled;
777 count = 0; 784 count = 0;
778 list_for_each_entry(connector, &dev->mode_config.connector_list, head) 785 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
786 if (!connector->encoder)
787 continue;
788
779 connector->encoder->crtc = save_crtcs[count++]; 789 connector->encoder->crtc = save_crtcs[count++];
790 }
780fail_no_encoder: 791fail_no_encoder:
781 kfree(save_crtcs); 792 kfree(save_crtcs);
782 count = 0; 793 count = 0;
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index b06a53715853..6c020fe5431c 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -457,6 +457,9 @@ int drm_release(struct inode *inode, struct file *filp)
457 if (dev->driver->driver_features & DRIVER_GEM) 457 if (dev->driver->driver_features & DRIVER_GEM)
458 drm_gem_release(dev, file_priv); 458 drm_gem_release(dev, file_priv);
459 459
460 if (dev->driver->driver_features & DRIVER_MODESET)
461 drm_fb_release(file_priv);
462
460 mutex_lock(&dev->ctxlist_mutex); 463 mutex_lock(&dev->ctxlist_mutex);
461 if (!list_empty(&dev->ctxlist)) { 464 if (!list_empty(&dev->ctxlist)) {
462 struct drm_ctx_list *pos, *n; 465 struct drm_ctx_list *pos, *n;
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 6915fb82d0b0..88d3368ffddd 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -104,8 +104,8 @@ drm_gem_init(struct drm_device *dev)
104 104
105 if (drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START, 105 if (drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START,
106 DRM_FILE_PAGE_OFFSET_SIZE)) { 106 DRM_FILE_PAGE_OFFSET_SIZE)) {
107 drm_free(mm, sizeof(struct drm_gem_mm), DRM_MEM_MM);
108 drm_ht_remove(&mm->offset_hash); 107 drm_ht_remove(&mm->offset_hash);
108 drm_free(mm, sizeof(struct drm_gem_mm), DRM_MEM_MM);
109 return -ENOMEM; 109 return -ENOMEM;
110 } 110 }
111 111
@@ -295,35 +295,37 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
295 return -EBADF; 295 return -EBADF;
296 296
297again: 297again:
298 if (idr_pre_get(&dev->object_name_idr, GFP_KERNEL) == 0) 298 if (idr_pre_get(&dev->object_name_idr, GFP_KERNEL) == 0) {
299 return -ENOMEM; 299 ret = -ENOMEM;
300 goto err;
301 }
300 302
301 spin_lock(&dev->object_name_lock); 303 spin_lock(&dev->object_name_lock);
302 if (obj->name) { 304 if (!obj->name) {
303 args->name = obj->name; 305 ret = idr_get_new_above(&dev->object_name_idr, obj, 1,
306 &obj->name);
307 args->name = (uint64_t) obj->name;
304 spin_unlock(&dev->object_name_lock); 308 spin_unlock(&dev->object_name_lock);
305 return 0;
306 }
307 ret = idr_get_new_above(&dev->object_name_idr, obj, 1,
308 &obj->name);
309 spin_unlock(&dev->object_name_lock);
310 if (ret == -EAGAIN)
311 goto again;
312 309
313 if (ret != 0) { 310 if (ret == -EAGAIN)
314 mutex_lock(&dev->struct_mutex); 311 goto again;
315 drm_gem_object_unreference(obj);
316 mutex_unlock(&dev->struct_mutex);
317 return ret;
318 }
319 312
320 /* 313 if (ret != 0)
321 * Leave the reference from the lookup around as the 314 goto err;
322 * name table now holds one
323 */
324 args->name = (uint64_t) obj->name;
325 315
326 return 0; 316 /* Allocate a reference for the name table. */
317 drm_gem_object_reference(obj);
318 } else {
319 args->name = (uint64_t) obj->name;
320 spin_unlock(&dev->object_name_lock);
321 ret = 0;
322 }
323
324err:
325 mutex_lock(&dev->struct_mutex);
326 drm_gem_object_unreference(obj);
327 mutex_unlock(&dev->struct_mutex);
328 return ret;
327} 329}
328 330
329/** 331/**
@@ -448,6 +450,7 @@ drm_gem_object_handle_free(struct kref *kref)
448 spin_lock(&dev->object_name_lock); 450 spin_lock(&dev->object_name_lock);
449 if (obj->name) { 451 if (obj->name) {
450 idr_remove(&dev->object_name_idr, obj->name); 452 idr_remove(&dev->object_name_idr, obj->name);
453 obj->name = 0;
451 spin_unlock(&dev->object_name_lock); 454 spin_unlock(&dev->object_name_lock);
452 /* 455 /*
453 * The object name held a reference to this object, drop 456 * The object name held a reference to this object, drop
@@ -460,6 +463,26 @@ drm_gem_object_handle_free(struct kref *kref)
460} 463}
461EXPORT_SYMBOL(drm_gem_object_handle_free); 464EXPORT_SYMBOL(drm_gem_object_handle_free);
462 465
466void drm_gem_vm_open(struct vm_area_struct *vma)
467{
468 struct drm_gem_object *obj = vma->vm_private_data;
469
470 drm_gem_object_reference(obj);
471}
472EXPORT_SYMBOL(drm_gem_vm_open);
473
474void drm_gem_vm_close(struct vm_area_struct *vma)
475{
476 struct drm_gem_object *obj = vma->vm_private_data;
477 struct drm_device *dev = obj->dev;
478
479 mutex_lock(&dev->struct_mutex);
480 drm_gem_object_unreference(obj);
481 mutex_unlock(&dev->struct_mutex);
482}
483EXPORT_SYMBOL(drm_gem_vm_close);
484
485
463/** 486/**
464 * drm_gem_mmap - memory map routine for GEM objects 487 * drm_gem_mmap - memory map routine for GEM objects
465 * @filp: DRM file pointer 488 * @filp: DRM file pointer
@@ -521,6 +544,14 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
521#endif 544#endif
522 vma->vm_page_prot = __pgprot(prot); 545 vma->vm_page_prot = __pgprot(prot);
523 546
547 /* Take a ref for this mapping of the object, so that the fault
548 * handler can dereference the mmap offset's pointer to the object.
549 * This reference is cleaned up by the corresponding vm_close
550 * (which should happen whether the vma was created by this call, or
551 * by a vm_open due to mremap or partial unmap or whatever).
552 */
553 drm_gem_object_reference(obj);
554
524 vma->vm_file = filp; /* Needed for drm_vm_open() */ 555 vma->vm_file = filp; /* Needed for drm_vm_open() */
525 drm_vm_open_locked(vma); 556 drm_vm_open_locked(vma);
526 557
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 69aa0ab28403..3795dbc0f50c 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -276,6 +276,7 @@ int drm_irq_uninstall(struct drm_device * dev)
276 for (i = 0; i < dev->num_crtcs; i++) { 276 for (i = 0; i < dev->num_crtcs; i++) {
277 DRM_WAKEUP(&dev->vbl_queue[i]); 277 DRM_WAKEUP(&dev->vbl_queue[i]);
278 dev->vblank_enabled[i] = 0; 278 dev->vblank_enabled[i] = 0;
279 dev->last_vblank[i] = dev->driver->get_vblank_counter(dev, i);
279 } 280 }
280 spin_unlock_irqrestore(&dev->vbl_lock, irqflags); 281 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
281 282
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 803bc9e7ce3c..bcc869bc4092 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -171,9 +171,14 @@ EXPORT_SYMBOL(drm_core_ioremap);
171 171
172void drm_core_ioremap_wc(struct drm_map *map, struct drm_device *dev) 172void drm_core_ioremap_wc(struct drm_map *map, struct drm_device *dev)
173{ 173{
174 map->handle = ioremap_wc(map->offset, map->size); 174 if (drm_core_has_AGP(dev) &&
175 dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
176 map->handle = agp_remap(map->offset, map->size, dev);
177 else
178 map->handle = ioremap_wc(map->offset, map->size);
175} 179}
176EXPORT_SYMBOL(drm_core_ioremap_wc); 180EXPORT_SYMBOL(drm_core_ioremap_wc);
181
177void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev) 182void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev)
178{ 183{
179 if (!map->handle || !map->size) 184 if (!map->handle || !map->size)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index ee64b7301f67..2d797ffe8137 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -202,7 +202,7 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
202 dev_priv->ring.map.flags = 0; 202 dev_priv->ring.map.flags = 0;
203 dev_priv->ring.map.mtrr = 0; 203 dev_priv->ring.map.mtrr = 0;
204 204
205 drm_core_ioremap(&dev_priv->ring.map, dev); 205 drm_core_ioremap_wc(&dev_priv->ring.map, dev);
206 206
207 if (dev_priv->ring.map.handle == NULL) { 207 if (dev_priv->ring.map.handle == NULL) {
208 i915_dma_cleanup(dev); 208 i915_dma_cleanup(dev);
@@ -731,8 +731,11 @@ static int i915_getparam(struct drm_device *dev, void *data,
731 case I915_PARAM_HAS_GEM: 731 case I915_PARAM_HAS_GEM:
732 value = dev_priv->has_gem; 732 value = dev_priv->has_gem;
733 break; 733 break;
734 case I915_PARAM_NUM_FENCES_AVAIL:
735 value = dev_priv->num_fence_regs - dev_priv->fence_reg_start;
736 break;
734 default: 737 default:
735 DRM_ERROR("Unknown parameter %d\n", param->param); 738 DRM_DEBUG("Unknown parameter %d\n", param->param);
736 return -EINVAL; 739 return -EINVAL;
737 } 740 }
738 741
@@ -764,8 +767,15 @@ static int i915_setparam(struct drm_device *dev, void *data,
764 case I915_SETPARAM_ALLOW_BATCHBUFFER: 767 case I915_SETPARAM_ALLOW_BATCHBUFFER:
765 dev_priv->allow_batchbuffer = param->value; 768 dev_priv->allow_batchbuffer = param->value;
766 break; 769 break;
770 case I915_SETPARAM_NUM_USED_FENCES:
771 if (param->value > dev_priv->num_fence_regs ||
772 param->value < 0)
773 return -EINVAL;
774 /* Userspace can use first N regs */
775 dev_priv->fence_reg_start = param->value;
776 break;
767 default: 777 default:
768 DRM_ERROR("unknown parameter %d\n", param->param); 778 DRM_DEBUG("unknown parameter %d\n", param->param);
769 return -EINVAL; 779 return -EINVAL;
770 } 780 }
771 781
@@ -966,10 +976,6 @@ static int i915_load_modeset_init(struct drm_device *dev)
966 if (ret) 976 if (ret)
967 goto kfree_devname; 977 goto kfree_devname;
968 978
969 dev_priv->mm.gtt_mapping =
970 io_mapping_create_wc(dev->agp->base,
971 dev->agp->agp_info.aper_size * 1024*1024);
972
973 /* Allow hardware batchbuffers unless told otherwise. 979 /* Allow hardware batchbuffers unless told otherwise.
974 */ 980 */
975 dev_priv->allow_batchbuffer = 1; 981 dev_priv->allow_batchbuffer = 1;
@@ -1081,6 +1087,23 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1081 goto free_priv; 1087 goto free_priv;
1082 } 1088 }
1083 1089
1090 dev_priv->mm.gtt_mapping =
1091 io_mapping_create_wc(dev->agp->base,
1092 dev->agp->agp_info.aper_size * 1024*1024);
1093 /* Set up a WC MTRR for non-PAT systems. This is more common than
1094 * one would think, because the kernel disables PAT on first
1095 * generation Core chips because WC PAT gets overridden by a UC
1096 * MTRR if present. Even if a UC MTRR isn't present.
1097 */
1098 dev_priv->mm.gtt_mtrr = mtrr_add(dev->agp->base,
1099 dev->agp->agp_info.aper_size *
1100 1024 * 1024,
1101 MTRR_TYPE_WRCOMB, 1);
1102 if (dev_priv->mm.gtt_mtrr < 0) {
1103 DRM_INFO("MTRR allocation failed\n. Graphics "
1104 "performance may suffer.\n");
1105 }
1106
1084#ifdef CONFIG_HIGHMEM64G 1107#ifdef CONFIG_HIGHMEM64G
1085 /* don't enable GEM on PAE - needs agp + set_memory_* interface fixes */ 1108 /* don't enable GEM on PAE - needs agp + set_memory_* interface fixes */
1086 dev_priv->has_gem = 0; 1109 dev_priv->has_gem = 0;
@@ -1089,6 +1112,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1089 dev_priv->has_gem = 1; 1112 dev_priv->has_gem = 1;
1090#endif 1113#endif
1091 1114
1115 dev->driver->get_vblank_counter = i915_get_vblank_counter;
1116 if (IS_GM45(dev))
1117 dev->driver->get_vblank_counter = gm45_get_vblank_counter;
1118
1092 i915_gem_load(dev); 1119 i915_gem_load(dev);
1093 1120
1094 /* Init HWS */ 1121 /* Init HWS */
@@ -1145,8 +1172,14 @@ int i915_driver_unload(struct drm_device *dev)
1145{ 1172{
1146 struct drm_i915_private *dev_priv = dev->dev_private; 1173 struct drm_i915_private *dev_priv = dev->dev_private;
1147 1174
1175 io_mapping_free(dev_priv->mm.gtt_mapping);
1176 if (dev_priv->mm.gtt_mtrr >= 0) {
1177 mtrr_del(dev_priv->mm.gtt_mtrr, dev->agp->base,
1178 dev->agp->agp_info.aper_size * 1024 * 1024);
1179 dev_priv->mm.gtt_mtrr = -1;
1180 }
1181
1148 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 1182 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1149 io_mapping_free(dev_priv->mm.gtt_mapping);
1150 drm_irq_uninstall(dev); 1183 drm_irq_uninstall(dev);
1151 } 1184 }
1152 1185
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f8b3df0926c0..b293ef0bae71 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -27,6 +27,7 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/device.h>
30#include "drmP.h" 31#include "drmP.h"
31#include "drm.h" 32#include "drm.h"
32#include "i915_drm.h" 33#include "i915_drm.h"
@@ -66,6 +67,14 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
66 67
67 i915_save_state(dev); 68 i915_save_state(dev);
68 69
70 /* If KMS is active, we do the leavevt stuff here */
71 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
72 if (i915_gem_idle(dev))
73 dev_err(&dev->pdev->dev,
74 "GEM idle failed, resume may fail\n");
75 drm_irq_uninstall(dev);
76 }
77
69 intel_opregion_free(dev); 78 intel_opregion_free(dev);
70 79
71 if (state.event == PM_EVENT_SUSPEND) { 80 if (state.event == PM_EVENT_SUSPEND) {
@@ -79,6 +88,9 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
79 88
80static int i915_resume(struct drm_device *dev) 89static int i915_resume(struct drm_device *dev)
81{ 90{
91 struct drm_i915_private *dev_priv = dev->dev_private;
92 int ret = 0;
93
82 pci_set_power_state(dev->pdev, PCI_D0); 94 pci_set_power_state(dev->pdev, PCI_D0);
83 pci_restore_state(dev->pdev); 95 pci_restore_state(dev->pdev);
84 if (pci_enable_device(dev->pdev)) 96 if (pci_enable_device(dev->pdev))
@@ -89,11 +101,26 @@ static int i915_resume(struct drm_device *dev)
89 101
90 intel_opregion_init(dev); 102 intel_opregion_init(dev);
91 103
92 return 0; 104 /* KMS EnterVT equivalent */
105 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
106 mutex_lock(&dev->struct_mutex);
107 dev_priv->mm.suspended = 0;
108
109 ret = i915_gem_init_ringbuffer(dev);
110 if (ret != 0)
111 ret = -1;
112 mutex_unlock(&dev->struct_mutex);
113
114 drm_irq_install(dev);
115 }
116
117 return ret;
93} 118}
94 119
95static struct vm_operations_struct i915_gem_vm_ops = { 120static struct vm_operations_struct i915_gem_vm_ops = {
96 .fault = i915_gem_fault, 121 .fault = i915_gem_fault,
122 .open = drm_gem_vm_open,
123 .close = drm_gem_vm_close,
97}; 124};
98 125
99static struct drm_driver driver = { 126static struct drm_driver driver = {
@@ -112,7 +139,6 @@ static struct drm_driver driver = {
112 .suspend = i915_suspend, 139 .suspend = i915_suspend,
113 .resume = i915_resume, 140 .resume = i915_resume,
114 .device_is_agp = i915_driver_device_is_agp, 141 .device_is_agp = i915_driver_device_is_agp,
115 .get_vblank_counter = i915_get_vblank_counter,
116 .enable_vblank = i915_enable_vblank, 142 .enable_vblank = i915_enable_vblank,
117 .disable_vblank = i915_disable_vblank, 143 .disable_vblank = i915_disable_vblank,
118 .irq_preinstall = i915_driver_irq_preinstall, 144 .irq_preinstall = i915_driver_irq_preinstall,
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index e13518252007..17fa40858d26 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -184,6 +184,8 @@ typedef struct drm_i915_private {
184 unsigned int lvds_dither:1; 184 unsigned int lvds_dither:1;
185 unsigned int lvds_vbt:1; 185 unsigned int lvds_vbt:1;
186 unsigned int int_crt_support:1; 186 unsigned int int_crt_support:1;
187 unsigned int lvds_use_ssc:1;
188 int lvds_ssc_freq;
187 189
188 struct drm_i915_fence_reg fence_regs[16]; /* assume 965 */ 190 struct drm_i915_fence_reg fence_regs[16]; /* assume 965 */
189 int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */ 191 int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */
@@ -284,6 +286,7 @@ typedef struct drm_i915_private {
284 struct drm_mm gtt_space; 286 struct drm_mm gtt_space;
285 287
286 struct io_mapping *gtt_mapping; 288 struct io_mapping *gtt_mapping;
289 int gtt_mtrr;
287 290
288 /** 291 /**
289 * List of objects currently involved in rendering from the 292 * List of objects currently involved in rendering from the
@@ -534,6 +537,7 @@ extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
534extern int i915_enable_vblank(struct drm_device *dev, int crtc); 537extern int i915_enable_vblank(struct drm_device *dev, int crtc);
535extern void i915_disable_vblank(struct drm_device *dev, int crtc); 538extern void i915_disable_vblank(struct drm_device *dev, int crtc);
536extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc); 539extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc);
540extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc);
537extern int i915_vblank_swap(struct drm_device *dev, void *data, 541extern int i915_vblank_swap(struct drm_device *dev, void *data,
538 struct drm_file *file_priv); 542 struct drm_file *file_priv);
539extern void i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask); 543extern void i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask);
@@ -601,6 +605,7 @@ int i915_gem_init_object(struct drm_gem_object *obj);
601void i915_gem_free_object(struct drm_gem_object *obj); 605void i915_gem_free_object(struct drm_gem_object *obj);
602int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment); 606int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment);
603void i915_gem_object_unpin(struct drm_gem_object *obj); 607void i915_gem_object_unpin(struct drm_gem_object *obj);
608int i915_gem_object_unbind(struct drm_gem_object *obj);
604void i915_gem_lastclose(struct drm_device *dev); 609void i915_gem_lastclose(struct drm_device *dev);
605uint32_t i915_get_gem_seqno(struct drm_device *dev); 610uint32_t i915_get_gem_seqno(struct drm_device *dev);
606void i915_gem_retire_requests(struct drm_device *dev); 611void i915_gem_retire_requests(struct drm_device *dev);
@@ -613,6 +618,7 @@ int i915_gem_init_ringbuffer(struct drm_device *dev);
613void i915_gem_cleanup_ringbuffer(struct drm_device *dev); 618void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
614int i915_gem_do_init(struct drm_device *dev, unsigned long start, 619int i915_gem_do_init(struct drm_device *dev, unsigned long start,
615 unsigned long end); 620 unsigned long end);
621int i915_gem_idle(struct drm_device *dev);
616int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); 622int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
617int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, 623int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj,
618 int write); 624 int write);
@@ -784,6 +790,11 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
784 IS_I945GM(dev) || IS_I965GM(dev) || IS_GM45(dev)) 790 IS_I945GM(dev) || IS_I965GM(dev) || IS_GM45(dev))
785 791
786#define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_GM45(dev) || IS_G4X(dev)) 792#define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_GM45(dev) || IS_G4X(dev))
793/* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
794 * rows, which changed the alignment requirements and fence programming.
795 */
796#define HAS_128_BYTE_Y_TILING(dev) (IS_I9XX(dev) && !(IS_I915G(dev) || \
797 IS_I915GM(dev)))
787#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev)) 798#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev))
788 799
789#define PRIMARY_RINGBUFFER_SIZE (128*1024) 800#define PRIMARY_RINGBUFFER_SIZE (128*1024)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index debad5c04cc0..28b726d07a0c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -34,10 +34,6 @@
34 34
35#define I915_GEM_GPU_DOMAINS (~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT)) 35#define I915_GEM_GPU_DOMAINS (~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
36 36
37static void
38i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj,
39 uint32_t read_domains,
40 uint32_t write_domain);
41static void i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj); 37static void i915_gem_object_flush_gpu_write_domain(struct drm_gem_object *obj);
42static void i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj); 38static void i915_gem_object_flush_gtt_write_domain(struct drm_gem_object *obj);
43static void i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj); 39static void i915_gem_object_flush_cpu_write_domain(struct drm_gem_object *obj);
@@ -52,7 +48,7 @@ static void i915_gem_object_free_page_list(struct drm_gem_object *obj);
52static int i915_gem_object_wait_rendering(struct drm_gem_object *obj); 48static int i915_gem_object_wait_rendering(struct drm_gem_object *obj);
53static int i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, 49static int i915_gem_object_bind_to_gtt(struct drm_gem_object *obj,
54 unsigned alignment); 50 unsigned alignment);
55static void i915_gem_object_get_fence_reg(struct drm_gem_object *obj); 51static int i915_gem_object_get_fence_reg(struct drm_gem_object *obj, bool write);
56static void i915_gem_clear_fence_reg(struct drm_gem_object *obj); 52static void i915_gem_clear_fence_reg(struct drm_gem_object *obj);
57static int i915_gem_evict_something(struct drm_device *dev); 53static int i915_gem_evict_something(struct drm_device *dev);
58static int i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj, 54static int i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
@@ -567,6 +563,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
567 pgoff_t page_offset; 563 pgoff_t page_offset;
568 unsigned long pfn; 564 unsigned long pfn;
569 int ret = 0; 565 int ret = 0;
566 bool write = !!(vmf->flags & FAULT_FLAG_WRITE);
570 567
571 /* We don't use vmf->pgoff since that has the fake offset */ 568 /* We don't use vmf->pgoff since that has the fake offset */
572 page_offset = ((unsigned long)vmf->virtual_address - vma->vm_start) >> 569 page_offset = ((unsigned long)vmf->virtual_address - vma->vm_start) >>
@@ -585,8 +582,13 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
585 582
586 /* Need a new fence register? */ 583 /* Need a new fence register? */
587 if (obj_priv->fence_reg == I915_FENCE_REG_NONE && 584 if (obj_priv->fence_reg == I915_FENCE_REG_NONE &&
588 obj_priv->tiling_mode != I915_TILING_NONE) 585 obj_priv->tiling_mode != I915_TILING_NONE) {
589 i915_gem_object_get_fence_reg(obj); 586 ret = i915_gem_object_get_fence_reg(obj, write);
587 if (ret) {
588 mutex_unlock(&dev->struct_mutex);
589 return VM_FAULT_SIGBUS;
590 }
591 }
590 592
591 pfn = ((dev->agp->base + obj_priv->gtt_offset) >> PAGE_SHIFT) + 593 pfn = ((dev->agp->base + obj_priv->gtt_offset) >> PAGE_SHIFT) +
592 page_offset; 594 page_offset;
@@ -601,8 +603,6 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
601 case -EAGAIN: 603 case -EAGAIN:
602 return VM_FAULT_OOM; 604 return VM_FAULT_OOM;
603 case -EFAULT: 605 case -EFAULT:
604 case -EBUSY:
605 DRM_ERROR("can't insert pfn?? fault or busy...\n");
606 return VM_FAULT_SIGBUS; 606 return VM_FAULT_SIGBUS;
607 default: 607 default:
608 return VM_FAULT_NOPAGE; 608 return VM_FAULT_NOPAGE;
@@ -678,6 +678,30 @@ out_free_list:
678 return ret; 678 return ret;
679} 679}
680 680
681static void
682i915_gem_free_mmap_offset(struct drm_gem_object *obj)
683{
684 struct drm_device *dev = obj->dev;
685 struct drm_i915_gem_object *obj_priv = obj->driver_private;
686 struct drm_gem_mm *mm = dev->mm_private;
687 struct drm_map_list *list;
688
689 list = &obj->map_list;
690 drm_ht_remove_item(&mm->offset_hash, &list->hash);
691
692 if (list->file_offset_node) {
693 drm_mm_put_block(list->file_offset_node);
694 list->file_offset_node = NULL;
695 }
696
697 if (list->map) {
698 drm_free(list->map, sizeof(struct drm_map), DRM_MEM_DRIVER);
699 list->map = NULL;
700 }
701
702 obj_priv->mmap_offset = 0;
703}
704
681/** 705/**
682 * i915_gem_get_gtt_alignment - return required GTT alignment for an object 706 * i915_gem_get_gtt_alignment - return required GTT alignment for an object
683 * @obj: object to check 707 * @obj: object to check
@@ -752,8 +776,11 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
752 776
753 if (!obj_priv->mmap_offset) { 777 if (!obj_priv->mmap_offset) {
754 ret = i915_gem_create_mmap_offset(obj); 778 ret = i915_gem_create_mmap_offset(obj);
755 if (ret) 779 if (ret) {
780 drm_gem_object_unreference(obj);
781 mutex_unlock(&dev->struct_mutex);
756 return ret; 782 return ret;
783 }
757 } 784 }
758 785
759 args->offset = obj_priv->mmap_offset; 786 args->offset = obj_priv->mmap_offset;
@@ -1024,6 +1051,9 @@ i915_gem_retire_requests(struct drm_device *dev)
1024 drm_i915_private_t *dev_priv = dev->dev_private; 1051 drm_i915_private_t *dev_priv = dev->dev_private;
1025 uint32_t seqno; 1052 uint32_t seqno;
1026 1053
1054 if (!dev_priv->hw_status_page)
1055 return;
1056
1027 seqno = i915_get_gem_seqno(dev); 1057 seqno = i915_get_gem_seqno(dev);
1028 1058
1029 while (!list_empty(&dev_priv->mm.request_list)) { 1059 while (!list_empty(&dev_priv->mm.request_list)) {
@@ -1211,7 +1241,7 @@ i915_gem_object_wait_rendering(struct drm_gem_object *obj)
1211/** 1241/**
1212 * Unbinds an object from the GTT aperture. 1242 * Unbinds an object from the GTT aperture.
1213 */ 1243 */
1214static int 1244int
1215i915_gem_object_unbind(struct drm_gem_object *obj) 1245i915_gem_object_unbind(struct drm_gem_object *obj)
1216{ 1246{
1217 struct drm_device *dev = obj->dev; 1247 struct drm_device *dev = obj->dev;
@@ -1445,21 +1475,26 @@ static void i915_write_fence_reg(struct drm_i915_fence_reg *reg)
1445 drm_i915_private_t *dev_priv = dev->dev_private; 1475 drm_i915_private_t *dev_priv = dev->dev_private;
1446 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1476 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1447 int regnum = obj_priv->fence_reg; 1477 int regnum = obj_priv->fence_reg;
1478 int tile_width;
1448 uint32_t val; 1479 uint32_t val;
1449 uint32_t pitch_val; 1480 uint32_t pitch_val;
1450 1481
1451 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) || 1482 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) ||
1452 (obj_priv->gtt_offset & (obj->size - 1))) { 1483 (obj_priv->gtt_offset & (obj->size - 1))) {
1453 WARN(1, "%s: object not 1M or size aligned\n", __func__); 1484 WARN(1, "%s: object 0x%08x not 1M or size (0x%zx) aligned\n",
1485 __func__, obj_priv->gtt_offset, obj->size);
1454 return; 1486 return;
1455 } 1487 }
1456 1488
1457 if (obj_priv->tiling_mode == I915_TILING_Y && (IS_I945G(dev) || 1489 if (obj_priv->tiling_mode == I915_TILING_Y &&
1458 IS_I945GM(dev) || 1490 HAS_128_BYTE_Y_TILING(dev))
1459 IS_G33(dev))) 1491 tile_width = 128;
1460 pitch_val = (obj_priv->stride / 128) - 1;
1461 else 1492 else
1462 pitch_val = (obj_priv->stride / 512) - 1; 1493 tile_width = 512;
1494
1495 /* Note: pitch better be a power of two tile widths */
1496 pitch_val = obj_priv->stride / tile_width;
1497 pitch_val = ffs(pitch_val) - 1;
1463 1498
1464 val = obj_priv->gtt_offset; 1499 val = obj_priv->gtt_offset;
1465 if (obj_priv->tiling_mode == I915_TILING_Y) 1500 if (obj_priv->tiling_mode == I915_TILING_Y)
@@ -1483,7 +1518,8 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
1483 1518
1484 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) || 1519 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) ||
1485 (obj_priv->gtt_offset & (obj->size - 1))) { 1520 (obj_priv->gtt_offset & (obj->size - 1))) {
1486 WARN(1, "%s: object not 1M or size aligned\n", __func__); 1521 WARN(1, "%s: object 0x%08x not 1M or size aligned\n",
1522 __func__, obj_priv->gtt_offset);
1487 return; 1523 return;
1488 } 1524 }
1489 1525
@@ -1503,6 +1539,7 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
1503/** 1539/**
1504 * i915_gem_object_get_fence_reg - set up a fence reg for an object 1540 * i915_gem_object_get_fence_reg - set up a fence reg for an object
1505 * @obj: object to map through a fence reg 1541 * @obj: object to map through a fence reg
1542 * @write: object is about to be written
1506 * 1543 *
1507 * When mapping objects through the GTT, userspace wants to be able to write 1544 * When mapping objects through the GTT, userspace wants to be able to write
1508 * to them without having to worry about swizzling if the object is tiled. 1545 * to them without having to worry about swizzling if the object is tiled.
@@ -1513,8 +1550,8 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
1513 * It then sets up the reg based on the object's properties: address, pitch 1550 * It then sets up the reg based on the object's properties: address, pitch
1514 * and tiling format. 1551 * and tiling format.
1515 */ 1552 */
1516static void 1553static int
1517i915_gem_object_get_fence_reg(struct drm_gem_object *obj) 1554i915_gem_object_get_fence_reg(struct drm_gem_object *obj, bool write)
1518{ 1555{
1519 struct drm_device *dev = obj->dev; 1556 struct drm_device *dev = obj->dev;
1520 struct drm_i915_private *dev_priv = dev->dev_private; 1557 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1527,12 +1564,18 @@ i915_gem_object_get_fence_reg(struct drm_gem_object *obj)
1527 WARN(1, "allocating a fence for non-tiled object?\n"); 1564 WARN(1, "allocating a fence for non-tiled object?\n");
1528 break; 1565 break;
1529 case I915_TILING_X: 1566 case I915_TILING_X:
1530 WARN(obj_priv->stride & (512 - 1), 1567 if (!obj_priv->stride)
1531 "object is X tiled but has non-512B pitch\n"); 1568 return -EINVAL;
1569 WARN((obj_priv->stride & (512 - 1)),
1570 "object 0x%08x is X tiled but has non-512B pitch\n",
1571 obj_priv->gtt_offset);
1532 break; 1572 break;
1533 case I915_TILING_Y: 1573 case I915_TILING_Y:
1534 WARN(obj_priv->stride & (128 - 1), 1574 if (!obj_priv->stride)
1535 "object is Y tiled but has non-128B pitch\n"); 1575 return -EINVAL;
1576 WARN((obj_priv->stride & (128 - 1)),
1577 "object 0x%08x is Y tiled but has non-128B pitch\n",
1578 obj_priv->gtt_offset);
1536 break; 1579 break;
1537 } 1580 }
1538 1581
@@ -1563,10 +1606,11 @@ try_again:
1563 * objects to finish before trying again. 1606 * objects to finish before trying again.
1564 */ 1607 */
1565 if (i == dev_priv->num_fence_regs) { 1608 if (i == dev_priv->num_fence_regs) {
1566 ret = i915_gem_object_wait_rendering(reg->obj); 1609 ret = i915_gem_object_set_to_gtt_domain(reg->obj, 0);
1567 if (ret) { 1610 if (ret) {
1568 WARN(ret, "wait_rendering failed: %d\n", ret); 1611 WARN(ret != -ERESTARTSYS,
1569 return; 1612 "switch to GTT domain failed: %d\n", ret);
1613 return ret;
1570 } 1614 }
1571 goto try_again; 1615 goto try_again;
1572 } 1616 }
@@ -1591,6 +1635,8 @@ try_again:
1591 i915_write_fence_reg(reg); 1635 i915_write_fence_reg(reg);
1592 else 1636 else
1593 i830_write_fence_reg(reg); 1637 i830_write_fence_reg(reg);
1638
1639 return 0;
1594} 1640}
1595 1641
1596/** 1642/**
@@ -1631,7 +1677,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
1631 if (dev_priv->mm.suspended) 1677 if (dev_priv->mm.suspended)
1632 return -EBUSY; 1678 return -EBUSY;
1633 if (alignment == 0) 1679 if (alignment == 0)
1634 alignment = PAGE_SIZE; 1680 alignment = i915_gem_get_gtt_alignment(obj);
1635 if (alignment & (PAGE_SIZE - 1)) { 1681 if (alignment & (PAGE_SIZE - 1)) {
1636 DRM_ERROR("Invalid object alignment requested %u\n", alignment); 1682 DRM_ERROR("Invalid object alignment requested %u\n", alignment);
1637 return -EINVAL; 1683 return -EINVAL;
@@ -1974,30 +2020,28 @@ i915_gem_object_set_to_cpu_domain(struct drm_gem_object *obj, int write)
1974 * drm_agp_chipset_flush 2020 * drm_agp_chipset_flush
1975 */ 2021 */
1976static void 2022static void
1977i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj, 2023i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj)
1978 uint32_t read_domains,
1979 uint32_t write_domain)
1980{ 2024{
1981 struct drm_device *dev = obj->dev; 2025 struct drm_device *dev = obj->dev;
1982 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2026 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1983 uint32_t invalidate_domains = 0; 2027 uint32_t invalidate_domains = 0;
1984 uint32_t flush_domains = 0; 2028 uint32_t flush_domains = 0;
1985 2029
1986 BUG_ON(read_domains & I915_GEM_DOMAIN_CPU); 2030 BUG_ON(obj->pending_read_domains & I915_GEM_DOMAIN_CPU);
1987 BUG_ON(write_domain == I915_GEM_DOMAIN_CPU); 2031 BUG_ON(obj->pending_write_domain == I915_GEM_DOMAIN_CPU);
1988 2032
1989#if WATCH_BUF 2033#if WATCH_BUF
1990 DRM_INFO("%s: object %p read %08x -> %08x write %08x -> %08x\n", 2034 DRM_INFO("%s: object %p read %08x -> %08x write %08x -> %08x\n",
1991 __func__, obj, 2035 __func__, obj,
1992 obj->read_domains, read_domains, 2036 obj->read_domains, obj->pending_read_domains,
1993 obj->write_domain, write_domain); 2037 obj->write_domain, obj->pending_write_domain);
1994#endif 2038#endif
1995 /* 2039 /*
1996 * If the object isn't moving to a new write domain, 2040 * If the object isn't moving to a new write domain,
1997 * let the object stay in multiple read domains 2041 * let the object stay in multiple read domains
1998 */ 2042 */
1999 if (write_domain == 0) 2043 if (obj->pending_write_domain == 0)
2000 read_domains |= obj->read_domains; 2044 obj->pending_read_domains |= obj->read_domains;
2001 else 2045 else
2002 obj_priv->dirty = 1; 2046 obj_priv->dirty = 1;
2003 2047
@@ -2007,15 +2051,17 @@ i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj,
2007 * any read domains which differ from the old 2051 * any read domains which differ from the old
2008 * write domain 2052 * write domain
2009 */ 2053 */
2010 if (obj->write_domain && obj->write_domain != read_domains) { 2054 if (obj->write_domain &&
2055 obj->write_domain != obj->pending_read_domains) {
2011 flush_domains |= obj->write_domain; 2056 flush_domains |= obj->write_domain;
2012 invalidate_domains |= read_domains & ~obj->write_domain; 2057 invalidate_domains |=
2058 obj->pending_read_domains & ~obj->write_domain;
2013 } 2059 }
2014 /* 2060 /*
2015 * Invalidate any read caches which may have 2061 * Invalidate any read caches which may have
2016 * stale data. That is, any new read domains. 2062 * stale data. That is, any new read domains.
2017 */ 2063 */
2018 invalidate_domains |= read_domains & ~obj->read_domains; 2064 invalidate_domains |= obj->pending_read_domains & ~obj->read_domains;
2019 if ((flush_domains | invalidate_domains) & I915_GEM_DOMAIN_CPU) { 2065 if ((flush_domains | invalidate_domains) & I915_GEM_DOMAIN_CPU) {
2020#if WATCH_BUF 2066#if WATCH_BUF
2021 DRM_INFO("%s: CPU domain flush %08x invalidate %08x\n", 2067 DRM_INFO("%s: CPU domain flush %08x invalidate %08x\n",
@@ -2024,9 +2070,15 @@ i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj,
2024 i915_gem_clflush_object(obj); 2070 i915_gem_clflush_object(obj);
2025 } 2071 }
2026 2072
2027 if ((write_domain | flush_domains) != 0) 2073 /* The actual obj->write_domain will be updated with
2028 obj->write_domain = write_domain; 2074 * pending_write_domain after we emit the accumulated flush for all
2029 obj->read_domains = read_domains; 2075 * of our domain changes in execbuffers (which clears objects'
2076 * write_domains). So if we have a current write domain that we
2077 * aren't changing, set pending_write_domain to that.
2078 */
2079 if (flush_domains == 0 && obj->pending_write_domain == 0)
2080 obj->pending_write_domain = obj->write_domain;
2081 obj->read_domains = obj->pending_read_domains;
2030 2082
2031 dev->invalidate_domains |= invalidate_domains; 2083 dev->invalidate_domains |= invalidate_domains;
2032 dev->flush_domains |= flush_domains; 2084 dev->flush_domains |= flush_domains;
@@ -2229,6 +2281,8 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
2229 (int) reloc.offset, 2281 (int) reloc.offset,
2230 reloc.read_domains, 2282 reloc.read_domains,
2231 reloc.write_domain); 2283 reloc.write_domain);
2284 drm_gem_object_unreference(target_obj);
2285 i915_gem_object_unpin(obj);
2232 return -EINVAL; 2286 return -EINVAL;
2233 } 2287 }
2234 2288
@@ -2458,13 +2512,15 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
2458 if (dev_priv->mm.wedged) { 2512 if (dev_priv->mm.wedged) {
2459 DRM_ERROR("Execbuf while wedged\n"); 2513 DRM_ERROR("Execbuf while wedged\n");
2460 mutex_unlock(&dev->struct_mutex); 2514 mutex_unlock(&dev->struct_mutex);
2461 return -EIO; 2515 ret = -EIO;
2516 goto pre_mutex_err;
2462 } 2517 }
2463 2518
2464 if (dev_priv->mm.suspended) { 2519 if (dev_priv->mm.suspended) {
2465 DRM_ERROR("Execbuf while VT-switched.\n"); 2520 DRM_ERROR("Execbuf while VT-switched.\n");
2466 mutex_unlock(&dev->struct_mutex); 2521 mutex_unlock(&dev->struct_mutex);
2467 return -EBUSY; 2522 ret = -EBUSY;
2523 goto pre_mutex_err;
2468 } 2524 }
2469 2525
2470 /* Look up object handles */ 2526 /* Look up object handles */
@@ -2532,9 +2588,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
2532 struct drm_gem_object *obj = object_list[i]; 2588 struct drm_gem_object *obj = object_list[i];
2533 2589
2534 /* Compute new gpu domains and update invalidate/flush */ 2590 /* Compute new gpu domains and update invalidate/flush */
2535 i915_gem_object_set_to_gpu_domain(obj, 2591 i915_gem_object_set_to_gpu_domain(obj);
2536 obj->pending_read_domains,
2537 obj->pending_write_domain);
2538 } 2592 }
2539 2593
2540 i915_verify_inactive(dev, __FILE__, __LINE__); 2594 i915_verify_inactive(dev, __FILE__, __LINE__);
@@ -2553,6 +2607,12 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
2553 (void)i915_add_request(dev, dev->flush_domains); 2607 (void)i915_add_request(dev, dev->flush_domains);
2554 } 2608 }
2555 2609
2610 for (i = 0; i < args->buffer_count; i++) {
2611 struct drm_gem_object *obj = object_list[i];
2612
2613 obj->write_domain = obj->pending_write_domain;
2614 }
2615
2556 i915_verify_inactive(dev, __FILE__, __LINE__); 2616 i915_verify_inactive(dev, __FILE__, __LINE__);
2557 2617
2558#if WATCH_COHERENCY 2618#if WATCH_COHERENCY
@@ -2610,15 +2670,6 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
2610 2670
2611 i915_verify_inactive(dev, __FILE__, __LINE__); 2671 i915_verify_inactive(dev, __FILE__, __LINE__);
2612 2672
2613 /* Copy the new buffer offsets back to the user's exec list. */
2614 ret = copy_to_user((struct drm_i915_relocation_entry __user *)
2615 (uintptr_t) args->buffers_ptr,
2616 exec_list,
2617 sizeof(*exec_list) * args->buffer_count);
2618 if (ret)
2619 DRM_ERROR("failed to copy %d exec entries "
2620 "back to user (%d)\n",
2621 args->buffer_count, ret);
2622err: 2673err:
2623 for (i = 0; i < pinned; i++) 2674 for (i = 0; i < pinned; i++)
2624 i915_gem_object_unpin(object_list[i]); 2675 i915_gem_object_unpin(object_list[i]);
@@ -2628,6 +2679,18 @@ err:
2628 2679
2629 mutex_unlock(&dev->struct_mutex); 2680 mutex_unlock(&dev->struct_mutex);
2630 2681
2682 if (!ret) {
2683 /* Copy the new buffer offsets back to the user's exec list. */
2684 ret = copy_to_user((struct drm_i915_relocation_entry __user *)
2685 (uintptr_t) args->buffers_ptr,
2686 exec_list,
2687 sizeof(*exec_list) * args->buffer_count);
2688 if (ret)
2689 DRM_ERROR("failed to copy %d exec entries "
2690 "back to user (%d)\n",
2691 args->buffer_count, ret);
2692 }
2693
2631pre_mutex_err: 2694pre_mutex_err:
2632 drm_free(object_list, sizeof(*object_list) * args->buffer_count, 2695 drm_free(object_list, sizeof(*object_list) * args->buffer_count,
2633 DRM_MEM_DRIVER); 2696 DRM_MEM_DRIVER);
@@ -2652,6 +2715,14 @@ i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment)
2652 DRM_ERROR("Failure to bind: %d", ret); 2715 DRM_ERROR("Failure to bind: %d", ret);
2653 return ret; 2716 return ret;
2654 } 2717 }
2718 /*
2719 * Pre-965 chips need a fence register set up in order to
2720 * properly handle tiled surfaces.
2721 */
2722 if (!IS_I965G(dev) &&
2723 obj_priv->fence_reg == I915_FENCE_REG_NONE &&
2724 obj_priv->tiling_mode != I915_TILING_NONE)
2725 i915_gem_object_get_fence_reg(obj, true);
2655 } 2726 }
2656 obj_priv->pin_count++; 2727 obj_priv->pin_count++;
2657 2728
@@ -2723,6 +2794,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
2723 if (obj_priv->pin_filp != NULL && obj_priv->pin_filp != file_priv) { 2794 if (obj_priv->pin_filp != NULL && obj_priv->pin_filp != file_priv) {
2724 DRM_ERROR("Already pinned in i915_gem_pin_ioctl(): %d\n", 2795 DRM_ERROR("Already pinned in i915_gem_pin_ioctl(): %d\n",
2725 args->handle); 2796 args->handle);
2797 drm_gem_object_unreference(obj);
2726 mutex_unlock(&dev->struct_mutex); 2798 mutex_unlock(&dev->struct_mutex);
2727 return -EINVAL; 2799 return -EINVAL;
2728 } 2800 }
@@ -2803,6 +2875,13 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
2803 return -EBADF; 2875 return -EBADF;
2804 } 2876 }
2805 2877
2878 /* Update the active list for the hardware's current position.
2879 * Otherwise this only updates on a delayed timer or when irqs are
2880 * actually unmasked, and our working set ends up being larger than
2881 * required.
2882 */
2883 i915_gem_retire_requests(dev);
2884
2806 obj_priv = obj->driver_private; 2885 obj_priv = obj->driver_private;
2807 /* Don't count being on the flushing list against the object being 2886 /* Don't count being on the flushing list against the object being
2808 * done. Otherwise, a buffer left on the flushing list but not getting 2887 * done. Otherwise, a buffer left on the flushing list but not getting
@@ -2855,9 +2934,6 @@ int i915_gem_init_object(struct drm_gem_object *obj)
2855void i915_gem_free_object(struct drm_gem_object *obj) 2934void i915_gem_free_object(struct drm_gem_object *obj)
2856{ 2935{
2857 struct drm_device *dev = obj->dev; 2936 struct drm_device *dev = obj->dev;
2858 struct drm_gem_mm *mm = dev->mm_private;
2859 struct drm_map_list *list;
2860 struct drm_map *map;
2861 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2937 struct drm_i915_gem_object *obj_priv = obj->driver_private;
2862 2938
2863 while (obj_priv->pin_count > 0) 2939 while (obj_priv->pin_count > 0)
@@ -2868,19 +2944,7 @@ void i915_gem_free_object(struct drm_gem_object *obj)
2868 2944
2869 i915_gem_object_unbind(obj); 2945 i915_gem_object_unbind(obj);
2870 2946
2871 list = &obj->map_list; 2947 i915_gem_free_mmap_offset(obj);
2872 drm_ht_remove_item(&mm->offset_hash, &list->hash);
2873
2874 if (list->file_offset_node) {
2875 drm_mm_put_block(list->file_offset_node);
2876 list->file_offset_node = NULL;
2877 }
2878
2879 map = list->map;
2880 if (map) {
2881 drm_free(map, sizeof(*map), DRM_MEM_DRIVER);
2882 list->map = NULL;
2883 }
2884 2948
2885 drm_free(obj_priv->page_cpu_valid, 1, DRM_MEM_DRIVER); 2949 drm_free(obj_priv->page_cpu_valid, 1, DRM_MEM_DRIVER);
2886 drm_free(obj->driver_private, 1, DRM_MEM_DRIVER); 2950 drm_free(obj->driver_private, 1, DRM_MEM_DRIVER);
@@ -2919,7 +2983,7 @@ i915_gem_evict_from_list(struct drm_device *dev, struct list_head *head)
2919 return 0; 2983 return 0;
2920} 2984}
2921 2985
2922static int 2986int
2923i915_gem_idle(struct drm_device *dev) 2987i915_gem_idle(struct drm_device *dev)
2924{ 2988{
2925 drm_i915_private_t *dev_priv = dev->dev_private; 2989 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -3065,6 +3129,7 @@ i915_gem_init_hws(struct drm_device *dev)
3065 if (dev_priv->hw_status_page == NULL) { 3129 if (dev_priv->hw_status_page == NULL) {
3066 DRM_ERROR("Failed to map status page.\n"); 3130 DRM_ERROR("Failed to map status page.\n");
3067 memset(&dev_priv->hws_map, 0, sizeof(dev_priv->hws_map)); 3131 memset(&dev_priv->hws_map, 0, sizeof(dev_priv->hws_map));
3132 i915_gem_object_unpin(obj);
3068 drm_gem_object_unreference(obj); 3133 drm_gem_object_unreference(obj);
3069 return -EINVAL; 3134 return -EINVAL;
3070 } 3135 }
@@ -3077,6 +3142,31 @@ i915_gem_init_hws(struct drm_device *dev)
3077 return 0; 3142 return 0;
3078} 3143}
3079 3144
3145static void
3146i915_gem_cleanup_hws(struct drm_device *dev)
3147{
3148 drm_i915_private_t *dev_priv = dev->dev_private;
3149 struct drm_gem_object *obj;
3150 struct drm_i915_gem_object *obj_priv;
3151
3152 if (dev_priv->hws_obj == NULL)
3153 return;
3154
3155 obj = dev_priv->hws_obj;
3156 obj_priv = obj->driver_private;
3157
3158 kunmap(obj_priv->page_list[0]);
3159 i915_gem_object_unpin(obj);
3160 drm_gem_object_unreference(obj);
3161 dev_priv->hws_obj = NULL;
3162
3163 memset(&dev_priv->hws_map, 0, sizeof(dev_priv->hws_map));
3164 dev_priv->hw_status_page = NULL;
3165
3166 /* Write high address into HWS_PGA when disabling. */
3167 I915_WRITE(HWS_PGA, 0x1ffff000);
3168}
3169
3080int 3170int
3081i915_gem_init_ringbuffer(struct drm_device *dev) 3171i915_gem_init_ringbuffer(struct drm_device *dev)
3082{ 3172{
@@ -3094,6 +3184,7 @@ i915_gem_init_ringbuffer(struct drm_device *dev)
3094 obj = drm_gem_object_alloc(dev, 128 * 1024); 3184 obj = drm_gem_object_alloc(dev, 128 * 1024);
3095 if (obj == NULL) { 3185 if (obj == NULL) {
3096 DRM_ERROR("Failed to allocate ringbuffer\n"); 3186 DRM_ERROR("Failed to allocate ringbuffer\n");
3187 i915_gem_cleanup_hws(dev);
3097 return -ENOMEM; 3188 return -ENOMEM;
3098 } 3189 }
3099 obj_priv = obj->driver_private; 3190 obj_priv = obj->driver_private;
@@ -3101,6 +3192,7 @@ i915_gem_init_ringbuffer(struct drm_device *dev)
3101 ret = i915_gem_object_pin(obj, 4096); 3192 ret = i915_gem_object_pin(obj, 4096);
3102 if (ret != 0) { 3193 if (ret != 0) {
3103 drm_gem_object_unreference(obj); 3194 drm_gem_object_unreference(obj);
3195 i915_gem_cleanup_hws(dev);
3104 return ret; 3196 return ret;
3105 } 3197 }
3106 3198
@@ -3118,7 +3210,9 @@ i915_gem_init_ringbuffer(struct drm_device *dev)
3118 if (ring->map.handle == NULL) { 3210 if (ring->map.handle == NULL) {
3119 DRM_ERROR("Failed to map ringbuffer.\n"); 3211 DRM_ERROR("Failed to map ringbuffer.\n");
3120 memset(&dev_priv->ring, 0, sizeof(dev_priv->ring)); 3212 memset(&dev_priv->ring, 0, sizeof(dev_priv->ring));
3213 i915_gem_object_unpin(obj);
3121 drm_gem_object_unreference(obj); 3214 drm_gem_object_unreference(obj);
3215 i915_gem_cleanup_hws(dev);
3122 return -EINVAL; 3216 return -EINVAL;
3123 } 3217 }
3124 ring->ring_obj = obj; 3218 ring->ring_obj = obj;
@@ -3198,20 +3292,7 @@ i915_gem_cleanup_ringbuffer(struct drm_device *dev)
3198 dev_priv->ring.ring_obj = NULL; 3292 dev_priv->ring.ring_obj = NULL;
3199 memset(&dev_priv->ring, 0, sizeof(dev_priv->ring)); 3293 memset(&dev_priv->ring, 0, sizeof(dev_priv->ring));
3200 3294
3201 if (dev_priv->hws_obj != NULL) { 3295 i915_gem_cleanup_hws(dev);
3202 struct drm_gem_object *obj = dev_priv->hws_obj;
3203 struct drm_i915_gem_object *obj_priv = obj->driver_private;
3204
3205 kunmap(obj_priv->page_list[0]);
3206 i915_gem_object_unpin(obj);
3207 drm_gem_object_unreference(obj);
3208 dev_priv->hws_obj = NULL;
3209 memset(&dev_priv->hws_map, 0, sizeof(dev_priv->hws_map));
3210 dev_priv->hw_status_page = NULL;
3211
3212 /* Write high address into HWS_PGA when disabling. */
3213 I915_WRITE(HWS_PGA, 0x1ffff000);
3214 }
3215} 3296}
3216 3297
3217int 3298int
@@ -3229,10 +3310,6 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
3229 dev_priv->mm.wedged = 0; 3310 dev_priv->mm.wedged = 0;
3230 } 3311 }
3231 3312
3232 dev_priv->mm.gtt_mapping = io_mapping_create_wc(dev->agp->base,
3233 dev->agp->agp_info.aper_size
3234 * 1024 * 1024);
3235
3236 mutex_lock(&dev->struct_mutex); 3313 mutex_lock(&dev->struct_mutex);
3237 dev_priv->mm.suspended = 0; 3314 dev_priv->mm.suspended = 0;
3238 3315
@@ -3255,7 +3332,6 @@ int
3255i915_gem_leavevt_ioctl(struct drm_device *dev, void *data, 3332i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
3256 struct drm_file *file_priv) 3333 struct drm_file *file_priv)
3257{ 3334{
3258 drm_i915_private_t *dev_priv = dev->dev_private;
3259 int ret; 3335 int ret;
3260 3336
3261 if (drm_core_check_feature(dev, DRIVER_MODESET)) 3337 if (drm_core_check_feature(dev, DRIVER_MODESET))
@@ -3264,7 +3340,6 @@ i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
3264 ret = i915_gem_idle(dev); 3340 ret = i915_gem_idle(dev);
3265 drm_irq_uninstall(dev); 3341 drm_irq_uninstall(dev);
3266 3342
3267 io_mapping_free(dev_priv->mm.gtt_mapping);
3268 return ret; 3343 return ret;
3269} 3344}
3270 3345
@@ -3273,6 +3348,9 @@ i915_gem_lastclose(struct drm_device *dev)
3273{ 3348{
3274 int ret; 3349 int ret;
3275 3350
3351 if (drm_core_check_feature(dev, DRIVER_MODESET))
3352 return;
3353
3276 ret = i915_gem_idle(dev); 3354 ret = i915_gem_idle(dev);
3277 if (ret) 3355 if (ret)
3278 DRM_ERROR("failed to idle hardware: %d\n", ret); 3356 DRM_ERROR("failed to idle hardware: %d\n", ret);
@@ -3294,7 +3372,7 @@ i915_gem_load(struct drm_device *dev)
3294 /* Old X drivers will take 0-2 for front, back, depth buffers */ 3372 /* Old X drivers will take 0-2 for front, back, depth buffers */
3295 dev_priv->fence_reg_start = 3; 3373 dev_priv->fence_reg_start = 3;
3296 3374
3297 if (IS_I965G(dev)) 3375 if (IS_I965G(dev) || IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
3298 dev_priv->num_fence_regs = 16; 3376 dev_priv->num_fence_regs = 16;
3299 else 3377 else
3300 dev_priv->num_fence_regs = 8; 3378 dev_priv->num_fence_regs = 8;
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index 241f39b7f460..7fb4191ef934 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -173,6 +173,73 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev)
173 dev_priv->mm.bit_6_swizzle_y = swizzle_y; 173 dev_priv->mm.bit_6_swizzle_y = swizzle_y;
174} 174}
175 175
176
177/**
178 * Returns the size of the fence for a tiled object of the given size.
179 */
180static int
181i915_get_fence_size(struct drm_device *dev, int size)
182{
183 int i;
184 int start;
185
186 if (IS_I965G(dev)) {
187 /* The 965 can have fences at any page boundary. */
188 return ALIGN(size, 4096);
189 } else {
190 /* Align the size to a power of two greater than the smallest
191 * fence size.
192 */
193 if (IS_I9XX(dev))
194 start = 1024 * 1024;
195 else
196 start = 512 * 1024;
197
198 for (i = start; i < size; i <<= 1)
199 ;
200
201 return i;
202 }
203}
204
205/* Check pitch constriants for all chips & tiling formats */
206static bool
207i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
208{
209 int tile_width;
210
211 /* Linear is always fine */
212 if (tiling_mode == I915_TILING_NONE)
213 return true;
214
215 if (tiling_mode == I915_TILING_Y && HAS_128_BYTE_Y_TILING(dev))
216 tile_width = 128;
217 else
218 tile_width = 512;
219
220 /* 965+ just needs multiples of tile width */
221 if (IS_I965G(dev)) {
222 if (stride & (tile_width - 1))
223 return false;
224 return true;
225 }
226
227 /* Pre-965 needs power of two tile widths */
228 if (stride < tile_width)
229 return false;
230
231 if (stride & (stride - 1))
232 return false;
233
234 /* We don't handle the aperture area covered by the fence being bigger
235 * than the object size.
236 */
237 if (i915_get_fence_size(dev, size) != size)
238 return false;
239
240 return true;
241}
242
176/** 243/**
177 * Sets the tiling mode of an object, returning the required swizzling of 244 * Sets the tiling mode of an object, returning the required swizzling of
178 * bit 6 of addresses in the object. 245 * bit 6 of addresses in the object.
@@ -191,6 +258,11 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
191 return -EINVAL; 258 return -EINVAL;
192 obj_priv = obj->driver_private; 259 obj_priv = obj->driver_private;
193 260
261 if (!i915_tiling_ok(dev, args->stride, obj->size, args->tiling_mode)) {
262 drm_gem_object_unreference(obj);
263 return -EINVAL;
264 }
265
194 mutex_lock(&dev->struct_mutex); 266 mutex_lock(&dev->struct_mutex);
195 267
196 if (args->tiling_mode == I915_TILING_NONE) { 268 if (args->tiling_mode == I915_TILING_NONE) {
@@ -207,12 +279,28 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
207 args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE; 279 args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
208 } 280 }
209 } 281 }
210 obj_priv->tiling_mode = args->tiling_mode; 282 if (args->tiling_mode != obj_priv->tiling_mode) {
211 obj_priv->stride = args->stride; 283 int ret;
212 284
213 mutex_unlock(&dev->struct_mutex); 285 /* Unbind the object, as switching tiling means we're
286 * switching the cache organization due to fencing, probably.
287 */
288 ret = i915_gem_object_unbind(obj);
289 if (ret != 0) {
290 WARN(ret != -ERESTARTSYS,
291 "failed to unbind object for tiling switch");
292 args->tiling_mode = obj_priv->tiling_mode;
293 mutex_unlock(&dev->struct_mutex);
294 drm_gem_object_unreference(obj);
295
296 return ret;
297 }
298 obj_priv->tiling_mode = args->tiling_mode;
299 }
300 obj_priv->stride = args->stride;
214 301
215 drm_gem_object_unreference(obj); 302 drm_gem_object_unreference(obj);
303 mutex_unlock(&dev->struct_mutex);
216 304
217 return 0; 305 return 0;
218} 306}
@@ -251,9 +339,8 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
251 DRM_ERROR("unknown tiling mode\n"); 339 DRM_ERROR("unknown tiling mode\n");
252 } 340 }
253 341
254 mutex_unlock(&dev->struct_mutex);
255
256 drm_gem_object_unreference(obj); 342 drm_gem_object_unreference(obj);
343 mutex_unlock(&dev->struct_mutex);
257 344
258 return 0; 345 return 0;
259} 346}
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 6290219de6c8..548ff2c66431 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -174,6 +174,19 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
174 return count; 174 return count;
175} 175}
176 176
177u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
178{
179 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
180 int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45;
181
182 if (!i915_pipe_enabled(dev, pipe)) {
183 DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe);
184 return 0;
185 }
186
187 return I915_READ(reg);
188}
189
177irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) 190irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
178{ 191{
179 struct drm_device *dev = (struct drm_device *) arg; 192 struct drm_device *dev = (struct drm_device *) arg;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 273162579e1b..9d6539a868b3 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -186,12 +186,12 @@
186#define FENCE_REG_830_0 0x2000 186#define FENCE_REG_830_0 0x2000
187#define I830_FENCE_START_MASK 0x07f80000 187#define I830_FENCE_START_MASK 0x07f80000
188#define I830_FENCE_TILING_Y_SHIFT 12 188#define I830_FENCE_TILING_Y_SHIFT 12
189#define I830_FENCE_SIZE_BITS(size) ((get_order(size >> 19) - 1) << 8) 189#define I830_FENCE_SIZE_BITS(size) ((ffs((size) >> 19) - 1) << 8)
190#define I830_FENCE_PITCH_SHIFT 4 190#define I830_FENCE_PITCH_SHIFT 4
191#define I830_FENCE_REG_VALID (1<<0) 191#define I830_FENCE_REG_VALID (1<<0)
192 192
193#define I915_FENCE_START_MASK 0x0ff00000 193#define I915_FENCE_START_MASK 0x0ff00000
194#define I915_FENCE_SIZE_BITS(size) ((get_order(size >> 20) - 1) << 8) 194#define I915_FENCE_SIZE_BITS(size) ((ffs((size) >> 20) - 1) << 8)
195 195
196#define FENCE_REG_965_0 0x03000 196#define FENCE_REG_965_0 0x03000
197#define I965_FENCE_PITCH_SHIFT 2 197#define I965_FENCE_PITCH_SHIFT 2
@@ -1371,6 +1371,9 @@
1371#define PIPE_FRAME_LOW_SHIFT 24 1371#define PIPE_FRAME_LOW_SHIFT 24
1372#define PIPE_PIXEL_MASK 0x00ffffff 1372#define PIPE_PIXEL_MASK 0x00ffffff
1373#define PIPE_PIXEL_SHIFT 0 1373#define PIPE_PIXEL_SHIFT 0
1374/* GM45+ just has to be different */
1375#define PIPEA_FRMCOUNT_GM45 0x70040
1376#define PIPEA_FLIPCOUNT_GM45 0x70044
1374 1377
1375/* Cursor A & B regs */ 1378/* Cursor A & B regs */
1376#define CURACNTR 0x70080 1379#define CURACNTR 0x70080
@@ -1439,6 +1442,9 @@
1439#define PIPEBSTAT 0x71024 1442#define PIPEBSTAT 0x71024
1440#define PIPEBFRAMEHIGH 0x71040 1443#define PIPEBFRAMEHIGH 0x71040
1441#define PIPEBFRAMEPIXEL 0x71044 1444#define PIPEBFRAMEPIXEL 0x71044
1445#define PIPEB_FRMCOUNT_GM45 0x71040
1446#define PIPEB_FLIPCOUNT_GM45 0x71044
1447
1442 1448
1443/* Display B control */ 1449/* Display B control */
1444#define DSPBCNTR 0x71180 1450#define DSPBCNTR 0x71180
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 4ca82a025525..65be30dccc77 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -135,6 +135,14 @@ parse_general_features(struct drm_i915_private *dev_priv,
135 if (general) { 135 if (general) {
136 dev_priv->int_tv_support = general->int_tv_support; 136 dev_priv->int_tv_support = general->int_tv_support;
137 dev_priv->int_crt_support = general->int_crt_support; 137 dev_priv->int_crt_support = general->int_crt_support;
138 dev_priv->lvds_use_ssc = general->enable_ssc;
139
140 if (dev_priv->lvds_use_ssc) {
141 if (IS_I855(dev_priv->dev))
142 dev_priv->lvds_ssc_freq = general->ssc_freq ? 66 : 48;
143 else
144 dev_priv->lvds_ssc_freq = general->ssc_freq ? 100 : 96;
145 }
138 } 146 }
139} 147}
140 148
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 31c3732b7a69..65b635ce28c8 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -90,12 +90,12 @@ typedef struct {
90#define I9XX_DOT_MAX 400000 90#define I9XX_DOT_MAX 400000
91#define I9XX_VCO_MIN 1400000 91#define I9XX_VCO_MIN 1400000
92#define I9XX_VCO_MAX 2800000 92#define I9XX_VCO_MAX 2800000
93#define I9XX_N_MIN 3 93#define I9XX_N_MIN 1
94#define I9XX_N_MAX 8 94#define I9XX_N_MAX 6
95#define I9XX_M_MIN 70 95#define I9XX_M_MIN 70
96#define I9XX_M_MAX 120 96#define I9XX_M_MAX 120
97#define I9XX_M1_MIN 10 97#define I9XX_M1_MIN 10
98#define I9XX_M1_MAX 20 98#define I9XX_M1_MAX 22
99#define I9XX_M2_MIN 5 99#define I9XX_M2_MIN 5
100#define I9XX_M2_MAX 9 100#define I9XX_M2_MAX 9
101#define I9XX_P_SDVO_DAC_MIN 5 101#define I9XX_P_SDVO_DAC_MIN 5
@@ -189,9 +189,7 @@ static const intel_limit_t *intel_limit(struct drm_crtc *crtc)
189 return limit; 189 return limit;
190} 190}
191 191
192/** Derive the pixel clock for the given refclk and divisors for 8xx chips. */ 192static void intel_clock(int refclk, intel_clock_t *clock)
193
194static void i8xx_clock(int refclk, intel_clock_t *clock)
195{ 193{
196 clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2); 194 clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2);
197 clock->p = clock->p1 * clock->p2; 195 clock->p = clock->p1 * clock->p2;
@@ -199,25 +197,6 @@ static void i8xx_clock(int refclk, intel_clock_t *clock)
199 clock->dot = clock->vco / clock->p; 197 clock->dot = clock->vco / clock->p;
200} 198}
201 199
202/** Derive the pixel clock for the given refclk and divisors for 9xx chips. */
203
204static void i9xx_clock(int refclk, intel_clock_t *clock)
205{
206 clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2);
207 clock->p = clock->p1 * clock->p2;
208 clock->vco = refclk * clock->m / (clock->n + 2);
209 clock->dot = clock->vco / clock->p;
210}
211
212static void intel_clock(struct drm_device *dev, int refclk,
213 intel_clock_t *clock)
214{
215 if (IS_I9XX(dev))
216 i9xx_clock (refclk, clock);
217 else
218 i8xx_clock (refclk, clock);
219}
220
221/** 200/**
222 * Returns whether any output on the specified pipe is of the specified type 201 * Returns whether any output on the specified pipe is of the specified type
223 */ 202 */
@@ -238,7 +217,7 @@ bool intel_pipe_has_type (struct drm_crtc *crtc, int type)
238 return false; 217 return false;
239} 218}
240 219
241#define INTELPllInvalid(s) { /* ErrorF (s) */; return false; } 220#define INTELPllInvalid(s) do { DRM_DEBUG(s); return false; } while (0)
242/** 221/**
243 * Returns whether the given set of divisors are valid for a given refclk with 222 * Returns whether the given set of divisors are valid for a given refclk with
244 * the given connectors. 223 * the given connectors.
@@ -318,7 +297,7 @@ static bool intel_find_best_PLL(struct drm_crtc *crtc, int target,
318 clock.p1 <= limit->p1.max; clock.p1++) { 297 clock.p1 <= limit->p1.max; clock.p1++) {
319 int this_err; 298 int this_err;
320 299
321 intel_clock(dev, refclk, &clock); 300 intel_clock(refclk, &clock);
322 301
323 if (!intel_PLL_is_valid(crtc, &clock)) 302 if (!intel_PLL_is_valid(crtc, &clock))
324 continue; 303 continue;
@@ -343,7 +322,7 @@ intel_wait_for_vblank(struct drm_device *dev)
343 udelay(20000); 322 udelay(20000);
344} 323}
345 324
346static void 325static int
347intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, 326intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
348 struct drm_framebuffer *old_fb) 327 struct drm_framebuffer *old_fb)
349{ 328{
@@ -361,11 +340,21 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
361 int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE; 340 int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE;
362 int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; 341 int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
363 u32 dspcntr, alignment; 342 u32 dspcntr, alignment;
343 int ret;
364 344
365 /* no fb bound */ 345 /* no fb bound */
366 if (!crtc->fb) { 346 if (!crtc->fb) {
367 DRM_DEBUG("No FB bound\n"); 347 DRM_DEBUG("No FB bound\n");
368 return; 348 return 0;
349 }
350
351 switch (pipe) {
352 case 0:
353 case 1:
354 break;
355 default:
356 DRM_ERROR("Can't update pipe %d in SAREA\n", pipe);
357 return -EINVAL;
369 } 358 }
370 359
371 intel_fb = to_intel_framebuffer(crtc->fb); 360 intel_fb = to_intel_framebuffer(crtc->fb);
@@ -377,28 +366,30 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
377 alignment = 64 * 1024; 366 alignment = 64 * 1024;
378 break; 367 break;
379 case I915_TILING_X: 368 case I915_TILING_X:
380 if (IS_I9XX(dev)) 369 /* pin() will align the object as required by fence */
381 alignment = 1024 * 1024; 370 alignment = 0;
382 else
383 alignment = 512 * 1024;
384 break; 371 break;
385 case I915_TILING_Y: 372 case I915_TILING_Y:
386 /* FIXME: Is this true? */ 373 /* FIXME: Is this true? */
387 DRM_ERROR("Y tiled not allowed for scan out buffers\n"); 374 DRM_ERROR("Y tiled not allowed for scan out buffers\n");
388 return; 375 return -EINVAL;
389 default: 376 default:
390 BUG(); 377 BUG();
391 } 378 }
392 379
393 if (i915_gem_object_pin(intel_fb->obj, alignment)) 380 mutex_lock(&dev->struct_mutex);
394 return; 381 ret = i915_gem_object_pin(intel_fb->obj, alignment);
395 382 if (ret != 0) {
396 i915_gem_object_set_to_gtt_domain(intel_fb->obj, 1); 383 mutex_unlock(&dev->struct_mutex);
397 384 return ret;
398 Start = obj_priv->gtt_offset; 385 }
399 Offset = y * crtc->fb->pitch + x * (crtc->fb->bits_per_pixel / 8);
400 386
401 I915_WRITE(dspstride, crtc->fb->pitch); 387 ret = i915_gem_object_set_to_gtt_domain(intel_fb->obj, 1);
388 if (ret != 0) {
389 i915_gem_object_unpin(intel_fb->obj);
390 mutex_unlock(&dev->struct_mutex);
391 return ret;
392 }
402 393
403 dspcntr = I915_READ(dspcntr_reg); 394 dspcntr = I915_READ(dspcntr_reg);
404 /* Mask out pixel format bits in case we change it */ 395 /* Mask out pixel format bits in case we change it */
@@ -419,11 +410,17 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
419 break; 410 break;
420 default: 411 default:
421 DRM_ERROR("Unknown color depth\n"); 412 DRM_ERROR("Unknown color depth\n");
422 return; 413 i915_gem_object_unpin(intel_fb->obj);
414 mutex_unlock(&dev->struct_mutex);
415 return -EINVAL;
423 } 416 }
424 I915_WRITE(dspcntr_reg, dspcntr); 417 I915_WRITE(dspcntr_reg, dspcntr);
425 418
419 Start = obj_priv->gtt_offset;
420 Offset = y * crtc->fb->pitch + x * (crtc->fb->bits_per_pixel / 8);
421
426 DRM_DEBUG("Writing base %08lX %08lX %d %d\n", Start, Offset, x, y); 422 DRM_DEBUG("Writing base %08lX %08lX %d %d\n", Start, Offset, x, y);
423 I915_WRITE(dspstride, crtc->fb->pitch);
427 if (IS_I965G(dev)) { 424 if (IS_I965G(dev)) {
428 I915_WRITE(dspbase, Offset); 425 I915_WRITE(dspbase, Offset);
429 I915_READ(dspbase); 426 I915_READ(dspbase);
@@ -440,27 +437,24 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
440 intel_fb = to_intel_framebuffer(old_fb); 437 intel_fb = to_intel_framebuffer(old_fb);
441 i915_gem_object_unpin(intel_fb->obj); 438 i915_gem_object_unpin(intel_fb->obj);
442 } 439 }
440 mutex_unlock(&dev->struct_mutex);
443 441
444 if (!dev->primary->master) 442 if (!dev->primary->master)
445 return; 443 return 0;
446 444
447 master_priv = dev->primary->master->driver_priv; 445 master_priv = dev->primary->master->driver_priv;
448 if (!master_priv->sarea_priv) 446 if (!master_priv->sarea_priv)
449 return; 447 return 0;
450 448
451 switch (pipe) { 449 if (pipe) {
452 case 0:
453 master_priv->sarea_priv->pipeA_x = x;
454 master_priv->sarea_priv->pipeA_y = y;
455 break;
456 case 1:
457 master_priv->sarea_priv->pipeB_x = x; 450 master_priv->sarea_priv->pipeB_x = x;
458 master_priv->sarea_priv->pipeB_y = y; 451 master_priv->sarea_priv->pipeB_y = y;
459 break; 452 } else {
460 default: 453 master_priv->sarea_priv->pipeA_x = x;
461 DRM_ERROR("Can't update pipe %d in SAREA\n", pipe); 454 master_priv->sarea_priv->pipeA_y = y;
462 break;
463 } 455 }
456
457 return 0;
464} 458}
465 459
466 460
@@ -708,11 +702,11 @@ static int intel_panel_fitter_pipe (struct drm_device *dev)
708 return 1; 702 return 1;
709} 703}
710 704
711static void intel_crtc_mode_set(struct drm_crtc *crtc, 705static int intel_crtc_mode_set(struct drm_crtc *crtc,
712 struct drm_display_mode *mode, 706 struct drm_display_mode *mode,
713 struct drm_display_mode *adjusted_mode, 707 struct drm_display_mode *adjusted_mode,
714 int x, int y, 708 int x, int y,
715 struct drm_framebuffer *old_fb) 709 struct drm_framebuffer *old_fb)
716{ 710{
717 struct drm_device *dev = crtc->dev; 711 struct drm_device *dev = crtc->dev;
718 struct drm_i915_private *dev_priv = dev->dev_private; 712 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -732,13 +726,14 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
732 int dspsize_reg = (pipe == 0) ? DSPASIZE : DSPBSIZE; 726 int dspsize_reg = (pipe == 0) ? DSPASIZE : DSPBSIZE;
733 int dsppos_reg = (pipe == 0) ? DSPAPOS : DSPBPOS; 727 int dsppos_reg = (pipe == 0) ? DSPAPOS : DSPBPOS;
734 int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC; 728 int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC;
735 int refclk; 729 int refclk, num_outputs = 0;
736 intel_clock_t clock; 730 intel_clock_t clock;
737 u32 dpll = 0, fp = 0, dspcntr, pipeconf; 731 u32 dpll = 0, fp = 0, dspcntr, pipeconf;
738 bool ok, is_sdvo = false, is_dvo = false; 732 bool ok, is_sdvo = false, is_dvo = false;
739 bool is_crt = false, is_lvds = false, is_tv = false; 733 bool is_crt = false, is_lvds = false, is_tv = false;
740 struct drm_mode_config *mode_config = &dev->mode_config; 734 struct drm_mode_config *mode_config = &dev->mode_config;
741 struct drm_connector *connector; 735 struct drm_connector *connector;
736 int ret;
742 737
743 drm_vblank_pre_modeset(dev, pipe); 738 drm_vblank_pre_modeset(dev, pipe);
744 739
@@ -755,6 +750,8 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
755 case INTEL_OUTPUT_SDVO: 750 case INTEL_OUTPUT_SDVO:
756 case INTEL_OUTPUT_HDMI: 751 case INTEL_OUTPUT_HDMI:
757 is_sdvo = true; 752 is_sdvo = true;
753 if (intel_output->needs_tv_clock)
754 is_tv = true;
758 break; 755 break;
759 case INTEL_OUTPUT_DVO: 756 case INTEL_OUTPUT_DVO:
760 is_dvo = true; 757 is_dvo = true;
@@ -766,9 +763,14 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
766 is_crt = true; 763 is_crt = true;
767 break; 764 break;
768 } 765 }
766
767 num_outputs++;
769 } 768 }
770 769
771 if (IS_I9XX(dev)) { 770 if (is_lvds && dev_priv->lvds_use_ssc && num_outputs < 2) {
771 refclk = dev_priv->lvds_ssc_freq * 1000;
772 DRM_DEBUG("using SSC reference clock of %d MHz\n", refclk / 1000);
773 } else if (IS_I9XX(dev)) {
772 refclk = 96000; 774 refclk = 96000;
773 } else { 775 } else {
774 refclk = 48000; 776 refclk = 48000;
@@ -777,7 +779,7 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
777 ok = intel_find_best_PLL(crtc, adjusted_mode->clock, refclk, &clock); 779 ok = intel_find_best_PLL(crtc, adjusted_mode->clock, refclk, &clock);
778 if (!ok) { 780 if (!ok) {
779 DRM_ERROR("Couldn't find PLL settings for mode!\n"); 781 DRM_ERROR("Couldn't find PLL settings for mode!\n");
780 return; 782 return -EINVAL;
781 } 783 }
782 784
783 fp = clock.n << 16 | clock.m1 << 8 | clock.m2; 785 fp = clock.n << 16 | clock.m1 << 8 | clock.m2;
@@ -827,11 +829,14 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
827 } 829 }
828 } 830 }
829 831
830 if (is_tv) { 832 if (is_sdvo && is_tv)
833 dpll |= PLL_REF_INPUT_TVCLKINBC;
834 else if (is_tv)
831 /* XXX: just matching BIOS for now */ 835 /* XXX: just matching BIOS for now */
832/* dpll |= PLL_REF_INPUT_TVCLKINBC; */ 836 /* dpll |= PLL_REF_INPUT_TVCLKINBC; */
833 dpll |= 3; 837 dpll |= 3;
834 } 838 else if (is_lvds && dev_priv->lvds_use_ssc && num_outputs < 2)
839 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
835 else 840 else
836 dpll |= PLL_REF_INPUT_DREFCLK; 841 dpll |= PLL_REF_INPUT_DREFCLK;
837 842
@@ -948,9 +953,13 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
948 I915_WRITE(dspcntr_reg, dspcntr); 953 I915_WRITE(dspcntr_reg, dspcntr);
949 954
950 /* Flush the plane changes */ 955 /* Flush the plane changes */
951 intel_pipe_set_base(crtc, x, y, old_fb); 956 ret = intel_pipe_set_base(crtc, x, y, old_fb);
957 if (ret != 0)
958 return ret;
952 959
953 drm_vblank_post_modeset(dev, pipe); 960 drm_vblank_post_modeset(dev, pipe);
961
962 return 0;
954} 963}
955 964
956/** Loads the palette/gamma unit for the CRTC with the prepared values */ 965/** Loads the palette/gamma unit for the CRTC with the prepared values */
@@ -999,6 +1008,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
999 temp = CURSOR_MODE_DISABLE; 1008 temp = CURSOR_MODE_DISABLE;
1000 addr = 0; 1009 addr = 0;
1001 bo = NULL; 1010 bo = NULL;
1011 mutex_lock(&dev->struct_mutex);
1002 goto finish; 1012 goto finish;
1003 } 1013 }
1004 1014
@@ -1021,18 +1031,19 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
1021 } 1031 }
1022 1032
1023 /* we only need to pin inside GTT if cursor is non-phy */ 1033 /* we only need to pin inside GTT if cursor is non-phy */
1034 mutex_lock(&dev->struct_mutex);
1024 if (!dev_priv->cursor_needs_physical) { 1035 if (!dev_priv->cursor_needs_physical) {
1025 ret = i915_gem_object_pin(bo, PAGE_SIZE); 1036 ret = i915_gem_object_pin(bo, PAGE_SIZE);
1026 if (ret) { 1037 if (ret) {
1027 DRM_ERROR("failed to pin cursor bo\n"); 1038 DRM_ERROR("failed to pin cursor bo\n");
1028 goto fail; 1039 goto fail_locked;
1029 } 1040 }
1030 addr = obj_priv->gtt_offset; 1041 addr = obj_priv->gtt_offset;
1031 } else { 1042 } else {
1032 ret = i915_gem_attach_phys_object(dev, bo, (pipe == 0) ? I915_GEM_PHYS_CURSOR_0 : I915_GEM_PHYS_CURSOR_1); 1043 ret = i915_gem_attach_phys_object(dev, bo, (pipe == 0) ? I915_GEM_PHYS_CURSOR_0 : I915_GEM_PHYS_CURSOR_1);
1033 if (ret) { 1044 if (ret) {
1034 DRM_ERROR("failed to attach phys object\n"); 1045 DRM_ERROR("failed to attach phys object\n");
1035 goto fail; 1046 goto fail_locked;
1036 } 1047 }
1037 addr = obj_priv->phys_obj->handle->busaddr; 1048 addr = obj_priv->phys_obj->handle->busaddr;
1038 } 1049 }
@@ -1052,10 +1063,9 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
1052 i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo); 1063 i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo);
1053 } else 1064 } else
1054 i915_gem_object_unpin(intel_crtc->cursor_bo); 1065 i915_gem_object_unpin(intel_crtc->cursor_bo);
1055 mutex_lock(&dev->struct_mutex);
1056 drm_gem_object_unreference(intel_crtc->cursor_bo); 1066 drm_gem_object_unreference(intel_crtc->cursor_bo);
1057 mutex_unlock(&dev->struct_mutex);
1058 } 1067 }
1068 mutex_unlock(&dev->struct_mutex);
1059 1069
1060 intel_crtc->cursor_addr = addr; 1070 intel_crtc->cursor_addr = addr;
1061 intel_crtc->cursor_bo = bo; 1071 intel_crtc->cursor_bo = bo;
@@ -1063,6 +1073,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
1063 return 0; 1073 return 0;
1064fail: 1074fail:
1065 mutex_lock(&dev->struct_mutex); 1075 mutex_lock(&dev->struct_mutex);
1076fail_locked:
1066 drm_gem_object_unreference(bo); 1077 drm_gem_object_unreference(bo);
1067 mutex_unlock(&dev->struct_mutex); 1078 mutex_unlock(&dev->struct_mutex);
1068 return ret; 1079 return ret;
@@ -1290,7 +1301,7 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
1290 } 1301 }
1291 1302
1292 /* XXX: Handle the 100Mhz refclk */ 1303 /* XXX: Handle the 100Mhz refclk */
1293 i9xx_clock(96000, &clock); 1304 intel_clock(96000, &clock);
1294 } else { 1305 } else {
1295 bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN); 1306 bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN);
1296 1307
@@ -1302,9 +1313,9 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
1302 if ((dpll & PLL_REF_INPUT_MASK) == 1313 if ((dpll & PLL_REF_INPUT_MASK) ==
1303 PLLB_REF_INPUT_SPREADSPECTRUMIN) { 1314 PLLB_REF_INPUT_SPREADSPECTRUMIN) {
1304 /* XXX: might not be 66MHz */ 1315 /* XXX: might not be 66MHz */
1305 i8xx_clock(66000, &clock); 1316 intel_clock(66000, &clock);
1306 } else 1317 } else
1307 i8xx_clock(48000, &clock); 1318 intel_clock(48000, &clock);
1308 } else { 1319 } else {
1309 if (dpll & PLL_P1_DIVIDE_BY_TWO) 1320 if (dpll & PLL_P1_DIVIDE_BY_TWO)
1310 clock.p1 = 2; 1321 clock.p1 = 2;
@@ -1317,7 +1328,7 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
1317 else 1328 else
1318 clock.p2 = 2; 1329 clock.p2 = 2;
1319 1330
1320 i8xx_clock(48000, &clock); 1331 intel_clock(48000, &clock);
1321 } 1332 }
1322 } 1333 }
1323 1334
@@ -1452,6 +1463,7 @@ static int intel_connector_clones(struct drm_device *dev, int type_mask)
1452 1463
1453static void intel_setup_outputs(struct drm_device *dev) 1464static void intel_setup_outputs(struct drm_device *dev)
1454{ 1465{
1466 struct drm_i915_private *dev_priv = dev->dev_private;
1455 struct drm_connector *connector; 1467 struct drm_connector *connector;
1456 1468
1457 intel_crt_init(dev); 1469 intel_crt_init(dev);
@@ -1463,13 +1475,16 @@ static void intel_setup_outputs(struct drm_device *dev)
1463 if (IS_I9XX(dev)) { 1475 if (IS_I9XX(dev)) {
1464 int found; 1476 int found;
1465 1477
1466 found = intel_sdvo_init(dev, SDVOB); 1478 if (I915_READ(SDVOB) & SDVO_DETECTED) {
1467 if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) 1479 found = intel_sdvo_init(dev, SDVOB);
1468 intel_hdmi_init(dev, SDVOB); 1480 if (!found && SUPPORTS_INTEGRATED_HDMI(dev))
1469 1481 intel_hdmi_init(dev, SDVOB);
1470 found = intel_sdvo_init(dev, SDVOC); 1482 }
1471 if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) 1483 if (!IS_G4X(dev) || (I915_READ(SDVOB) & SDVO_DETECTED)) {
1472 intel_hdmi_init(dev, SDVOC); 1484 found = intel_sdvo_init(dev, SDVOC);
1485 if (!found && SUPPORTS_INTEGRATED_HDMI(dev))
1486 intel_hdmi_init(dev, SDVOC);
1487 }
1473 } else 1488 } else
1474 intel_dvo_init(dev); 1489 intel_dvo_init(dev);
1475 1490
@@ -1592,7 +1607,9 @@ intel_user_framebuffer_create(struct drm_device *dev,
1592 1607
1593 ret = intel_framebuffer_create(dev, mode_cmd, &fb, obj); 1608 ret = intel_framebuffer_create(dev, mode_cmd, &fb, obj);
1594 if (ret) { 1609 if (ret) {
1610 mutex_lock(&dev->struct_mutex);
1595 drm_gem_object_unreference(obj); 1611 drm_gem_object_unreference(obj);
1612 mutex_unlock(&dev->struct_mutex);
1596 return NULL; 1613 return NULL;
1597 } 1614 }
1598 1615
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 8a4cc50c5b4e..957daef8edff 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -82,6 +82,7 @@ struct intel_output {
82 struct intel_i2c_chan *i2c_bus; /* for control functions */ 82 struct intel_i2c_chan *i2c_bus; /* for control functions */
83 struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */ 83 struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */
84 bool load_detect_temp; 84 bool load_detect_temp;
85 bool needs_tv_clock;
85 void *dev_priv; 86 void *dev_priv;
86}; 87};
87 88
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index afd1217b8a02..b7f0ebe9f810 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -473,7 +473,7 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
473 ret = intel_framebuffer_create(dev, &mode_cmd, &fb, fbo); 473 ret = intel_framebuffer_create(dev, &mode_cmd, &fb, fbo);
474 if (ret) { 474 if (ret) {
475 DRM_ERROR("failed to allocate fb.\n"); 475 DRM_ERROR("failed to allocate fb.\n");
476 goto out_unref; 476 goto out_unpin;
477 } 477 }
478 478
479 list_add(&fb->filp_head, &dev->mode_config.fb_kernel_list); 479 list_add(&fb->filp_head, &dev->mode_config.fb_kernel_list);
@@ -484,7 +484,7 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
484 info = framebuffer_alloc(sizeof(struct intelfb_par), device); 484 info = framebuffer_alloc(sizeof(struct intelfb_par), device);
485 if (!info) { 485 if (!info) {
486 ret = -ENOMEM; 486 ret = -ENOMEM;
487 goto out_unref; 487 goto out_unpin;
488 } 488 }
489 489
490 par = info->par; 490 par = info->par;
@@ -513,7 +513,7 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
513 size); 513 size);
514 if (!info->screen_base) { 514 if (!info->screen_base) {
515 ret = -ENOSPC; 515 ret = -ENOSPC;
516 goto out_unref; 516 goto out_unpin;
517 } 517 }
518 info->screen_size = size; 518 info->screen_size = size;
519 519
@@ -608,6 +608,8 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
608 mutex_unlock(&dev->struct_mutex); 608 mutex_unlock(&dev->struct_mutex);
609 return 0; 609 return 0;
610 610
611out_unpin:
612 i915_gem_object_unpin(fbo);
611out_unref: 613out_unref:
612 drm_gem_object_unreference(fbo); 614 drm_gem_object_unreference(fbo);
613 mutex_unlock(&dev->struct_mutex); 615 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index b36a5214d8df..0d211af98854 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -27,6 +27,7 @@
27 * Jesse Barnes <jesse.barnes@intel.com> 27 * Jesse Barnes <jesse.barnes@intel.com>
28 */ 28 */
29 29
30#include <linux/dmi.h>
30#include <linux/i2c.h> 31#include <linux/i2c.h>
31#include "drmP.h" 32#include "drmP.h"
32#include "drm.h" 33#include "drm.h"
@@ -311,10 +312,8 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
311 if (dev_priv->panel_fixed_mode != NULL) { 312 if (dev_priv->panel_fixed_mode != NULL) {
312 struct drm_display_mode *mode; 313 struct drm_display_mode *mode;
313 314
314 mutex_lock(&dev->mode_config.mutex);
315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); 315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode);
316 drm_mode_probed_add(connector, mode); 316 drm_mode_probed_add(connector, mode);
317 mutex_unlock(&dev->mode_config.mutex);
318 317
319 return 1; 318 return 1;
320 } 319 }
@@ -405,6 +404,16 @@ void intel_lvds_init(struct drm_device *dev)
405 u32 lvds; 404 u32 lvds;
406 int pipe; 405 int pipe;
407 406
407 /* Blacklist machines that we know falsely report LVDS. */
408 /* FIXME: add a check for the Aopen Mini PC */
409
410 /* Apple Mac Mini Core Duo and Mac Mini Core 2 Duo */
411 if(dmi_match(DMI_PRODUCT_NAME, "Macmini1,1") ||
412 dmi_match(DMI_PRODUCT_NAME, "Macmini2,1")) {
413 DRM_DEBUG("Skipping LVDS initialization for Apple Mac Mini\n");
414 return;
415 }
416
408 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); 417 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
409 if (!intel_output) { 418 if (!intel_output) {
410 return; 419 return;
@@ -458,7 +467,7 @@ void intel_lvds_init(struct drm_device *dev)
458 dev_priv->panel_fixed_mode = 467 dev_priv->panel_fixed_mode =
459 drm_mode_duplicate(dev, scan); 468 drm_mode_duplicate(dev, scan);
460 mutex_unlock(&dev->mode_config.mutex); 469 mutex_unlock(&dev->mode_config.mutex);
461 goto out; /* FIXME: check for quirks */ 470 goto out;
462 } 471 }
463 mutex_unlock(&dev->mode_config.mutex); 472 mutex_unlock(&dev->mode_config.mutex);
464 } 473 }
@@ -472,8 +481,6 @@ void intel_lvds_init(struct drm_device *dev)
472 if (dev_priv->panel_fixed_mode) { 481 if (dev_priv->panel_fixed_mode) {
473 dev_priv->panel_fixed_mode->type |= 482 dev_priv->panel_fixed_mode->type |=
474 DRM_MODE_TYPE_PREFERRED; 483 DRM_MODE_TYPE_PREFERRED;
475 drm_mode_probed_add(connector,
476 dev_priv->panel_fixed_mode);
477 goto out; 484 goto out;
478 } 485 }
479 } 486 }
@@ -492,7 +499,7 @@ void intel_lvds_init(struct drm_device *dev)
492 if (dev_priv->panel_fixed_mode) { 499 if (dev_priv->panel_fixed_mode) {
493 dev_priv->panel_fixed_mode->type |= 500 dev_priv->panel_fixed_mode->type |=
494 DRM_MODE_TYPE_PREFERRED; 501 DRM_MODE_TYPE_PREFERRED;
495 goto out; /* FIXME: check for quirks */ 502 goto out;
496 } 503 }
497 } 504 }
498 505
@@ -500,38 +507,6 @@ void intel_lvds_init(struct drm_device *dev)
500 if (!dev_priv->panel_fixed_mode) 507 if (!dev_priv->panel_fixed_mode)
501 goto failed; 508 goto failed;
502 509
503 /* FIXME: detect aopen & mac mini type stuff automatically? */
504 /*
505 * Blacklist machines with BIOSes that list an LVDS panel without
506 * actually having one.
507 */
508 if (IS_I945GM(dev)) {
509 /* aopen mini pc */
510 if (dev->pdev->subsystem_vendor == 0xa0a0)
511 goto failed;
512
513 if ((dev->pdev->subsystem_vendor == 0x8086) &&
514 (dev->pdev->subsystem_device == 0x7270)) {
515 /* It's a Mac Mini or Macbook Pro.
516 *
517 * Apple hardware is out to get us. The macbook pro
518 * has a real LVDS panel, but the mac mini does not,
519 * and they have the same device IDs. We'll
520 * distinguish by panel size, on the assumption
521 * that Apple isn't about to make any machines with an
522 * 800x600 display.
523 */
524
525 if (dev_priv->panel_fixed_mode != NULL &&
526 dev_priv->panel_fixed_mode->hdisplay == 800 &&
527 dev_priv->panel_fixed_mode->vdisplay == 600) {
528 DRM_DEBUG("Suspected Mac Mini, ignoring the LVDS\n");
529 goto failed;
530 }
531 }
532 }
533
534
535out: 510out:
536 drm_sysfs_connector_add(connector); 511 drm_sysfs_connector_add(connector);
537 return; 512 return;
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 407215469102..fbe6f3931b1b 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -40,13 +40,59 @@
40struct intel_sdvo_priv { 40struct intel_sdvo_priv {
41 struct intel_i2c_chan *i2c_bus; 41 struct intel_i2c_chan *i2c_bus;
42 int slaveaddr; 42 int slaveaddr;
43
44 /* Register for the SDVO device: SDVOB or SDVOC */
43 int output_device; 45 int output_device;
44 46
45 u16 active_outputs; 47 /* Active outputs controlled by this SDVO output */
48 uint16_t controlled_output;
46 49
50 /*
51 * Capabilities of the SDVO device returned by
52 * i830_sdvo_get_capabilities()
53 */
47 struct intel_sdvo_caps caps; 54 struct intel_sdvo_caps caps;
55
56 /* Pixel clock limitations reported by the SDVO device, in kHz */
48 int pixel_clock_min, pixel_clock_max; 57 int pixel_clock_min, pixel_clock_max;
49 58
59 /**
60 * This is set if we're going to treat the device as TV-out.
61 *
62 * While we have these nice friendly flags for output types that ought
63 * to decide this for us, the S-Video output on our HDMI+S-Video card
64 * shows up as RGB1 (VGA).
65 */
66 bool is_tv;
67
68 /**
69 * This is set if we treat the device as HDMI, instead of DVI.
70 */
71 bool is_hdmi;
72
73 /**
74 * Returned SDTV resolutions allowed for the current format, if the
75 * device reported it.
76 */
77 struct intel_sdvo_sdtv_resolution_reply sdtv_resolutions;
78
79 /**
80 * Current selected TV format.
81 *
82 * This is stored in the same structure that's passed to the device, for
83 * convenience.
84 */
85 struct intel_sdvo_tv_format tv_format;
86
87 /*
88 * supported encoding mode, used to determine whether HDMI is
89 * supported
90 */
91 struct intel_sdvo_encode encode;
92
93 /* DDC bus used by this SDVO output */
94 uint8_t ddc_bus;
95
50 int save_sdvo_mult; 96 int save_sdvo_mult;
51 u16 save_active_outputs; 97 u16 save_active_outputs;
52 struct intel_sdvo_dtd save_input_dtd_1, save_input_dtd_2; 98 struct intel_sdvo_dtd save_input_dtd_1, save_input_dtd_2;
@@ -147,9 +193,9 @@ static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr,
147 193
148#define SDVO_CMD_NAME_ENTRY(cmd) {cmd, #cmd} 194#define SDVO_CMD_NAME_ENTRY(cmd) {cmd, #cmd}
149/** Mapping of command numbers to names, for debug output */ 195/** Mapping of command numbers to names, for debug output */
150const static struct _sdvo_cmd_name { 196static const struct _sdvo_cmd_name {
151 u8 cmd; 197 u8 cmd;
152 char *name; 198 char *name;
153} sdvo_cmd_names[] = { 199} sdvo_cmd_names[] = {
154 SDVO_CMD_NAME_ENTRY(SDVO_CMD_RESET), 200 SDVO_CMD_NAME_ENTRY(SDVO_CMD_RESET),
155 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_DEVICE_CAPS), 201 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_DEVICE_CAPS),
@@ -186,8 +232,35 @@ const static struct _sdvo_cmd_name {
186 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_TV_FORMATS), 232 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_TV_FORMATS),
187 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TV_FORMAT), 233 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TV_FORMAT),
188 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_FORMAT), 234 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_FORMAT),
189 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_RESOLUTION_SUPPORT), 235 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_POWER_STATES),
236 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POWER_STATE),
237 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ENCODER_POWER_STATE),
238 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_DISPLAY_POWER_STATE),
190 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CONTROL_BUS_SWITCH), 239 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CONTROL_BUS_SWITCH),
240 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT),
241 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SCALED_HDTV_RESOLUTION_SUPPORT),
242 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS),
243 /* HDMI op code */
244 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPP_ENCODE),
245 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ENCODE),
246 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ENCODE),
247 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_PIXEL_REPLI),
248 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_PIXEL_REPLI),
249 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_COLORIMETRY_CAP),
250 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_COLORIMETRY),
251 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_COLORIMETRY),
252 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER),
253 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_AUDIO_STAT),
254 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_AUDIO_STAT),
255 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_INDEX),
256 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_INDEX),
257 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_INFO),
258 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_AV_SPLIT),
259 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_AV_SPLIT),
260 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_TXRATE),
261 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_TXRATE),
262 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_DATA),
263 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA),
191}; 264};
192 265
193#define SDVO_NAME(dev_priv) ((dev_priv)->output_device == SDVOB ? "SDVOB" : "SDVOC") 266#define SDVO_NAME(dev_priv) ((dev_priv)->output_device == SDVOB ? "SDVOB" : "SDVOC")
@@ -506,6 +579,50 @@ static bool intel_sdvo_set_output_timing(struct intel_output *intel_output,
506 SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd); 579 SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd);
507} 580}
508 581
582static bool
583intel_sdvo_create_preferred_input_timing(struct intel_output *output,
584 uint16_t clock,
585 uint16_t width,
586 uint16_t height)
587{
588 struct intel_sdvo_preferred_input_timing_args args;
589 uint8_t status;
590
591 args.clock = clock;
592 args.width = width;
593 args.height = height;
594 intel_sdvo_write_cmd(output, SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING,
595 &args, sizeof(args));
596 status = intel_sdvo_read_response(output, NULL, 0);
597 if (status != SDVO_CMD_STATUS_SUCCESS)
598 return false;
599
600 return true;
601}
602
603static bool intel_sdvo_get_preferred_input_timing(struct intel_output *output,
604 struct intel_sdvo_dtd *dtd)
605{
606 bool status;
607
608 intel_sdvo_write_cmd(output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1,
609 NULL, 0);
610
611 status = intel_sdvo_read_response(output, &dtd->part1,
612 sizeof(dtd->part1));
613 if (status != SDVO_CMD_STATUS_SUCCESS)
614 return false;
615
616 intel_sdvo_write_cmd(output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2,
617 NULL, 0);
618
619 status = intel_sdvo_read_response(output, &dtd->part2,
620 sizeof(dtd->part2));
621 if (status != SDVO_CMD_STATUS_SUCCESS)
622 return false;
623
624 return false;
625}
509 626
510static int intel_sdvo_get_clock_rate_mult(struct intel_output *intel_output) 627static int intel_sdvo_get_clock_rate_mult(struct intel_output *intel_output)
511{ 628{
@@ -536,36 +653,12 @@ static bool intel_sdvo_set_clock_rate_mult(struct intel_output *intel_output, u8
536 return true; 653 return true;
537} 654}
538 655
539static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder, 656static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
540 struct drm_display_mode *mode, 657 struct drm_display_mode *mode)
541 struct drm_display_mode *adjusted_mode)
542{
543 /* Make the CRTC code factor in the SDVO pixel multiplier. The SDVO
544 * device will be told of the multiplier during mode_set.
545 */
546 adjusted_mode->clock *= intel_sdvo_get_pixel_multiplier(mode);
547 return true;
548}
549
550static void intel_sdvo_mode_set(struct drm_encoder *encoder,
551 struct drm_display_mode *mode,
552 struct drm_display_mode *adjusted_mode)
553{ 658{
554 struct drm_device *dev = encoder->dev; 659 uint16_t width, height;
555 struct drm_i915_private *dev_priv = dev->dev_private; 660 uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len;
556 struct drm_crtc *crtc = encoder->crtc; 661 uint16_t h_sync_offset, v_sync_offset;
557 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
558 struct intel_output *intel_output = enc_to_intel_output(encoder);
559 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
560 u16 width, height;
561 u16 h_blank_len, h_sync_len, v_blank_len, v_sync_len;
562 u16 h_sync_offset, v_sync_offset;
563 u32 sdvox;
564 struct intel_sdvo_dtd output_dtd;
565 int sdvo_pixel_multiply;
566
567 if (!mode)
568 return;
569 662
570 width = mode->crtc_hdisplay; 663 width = mode->crtc_hdisplay;
571 height = mode->crtc_vdisplay; 664 height = mode->crtc_vdisplay;
@@ -580,93 +673,423 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
580 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start; 673 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start;
581 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start; 674 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start;
582 675
583 output_dtd.part1.clock = mode->clock / 10; 676 dtd->part1.clock = mode->clock / 10;
584 output_dtd.part1.h_active = width & 0xff; 677 dtd->part1.h_active = width & 0xff;
585 output_dtd.part1.h_blank = h_blank_len & 0xff; 678 dtd->part1.h_blank = h_blank_len & 0xff;
586 output_dtd.part1.h_high = (((width >> 8) & 0xf) << 4) | 679 dtd->part1.h_high = (((width >> 8) & 0xf) << 4) |
587 ((h_blank_len >> 8) & 0xf); 680 ((h_blank_len >> 8) & 0xf);
588 output_dtd.part1.v_active = height & 0xff; 681 dtd->part1.v_active = height & 0xff;
589 output_dtd.part1.v_blank = v_blank_len & 0xff; 682 dtd->part1.v_blank = v_blank_len & 0xff;
590 output_dtd.part1.v_high = (((height >> 8) & 0xf) << 4) | 683 dtd->part1.v_high = (((height >> 8) & 0xf) << 4) |
591 ((v_blank_len >> 8) & 0xf); 684 ((v_blank_len >> 8) & 0xf);
592 685
593 output_dtd.part2.h_sync_off = h_sync_offset; 686 dtd->part2.h_sync_off = h_sync_offset;
594 output_dtd.part2.h_sync_width = h_sync_len & 0xff; 687 dtd->part2.h_sync_width = h_sync_len & 0xff;
595 output_dtd.part2.v_sync_off_width = (v_sync_offset & 0xf) << 4 | 688 dtd->part2.v_sync_off_width = (v_sync_offset & 0xf) << 4 |
596 (v_sync_len & 0xf); 689 (v_sync_len & 0xf);
597 output_dtd.part2.sync_off_width_high = ((h_sync_offset & 0x300) >> 2) | 690 dtd->part2.sync_off_width_high = ((h_sync_offset & 0x300) >> 2) |
598 ((h_sync_len & 0x300) >> 4) | ((v_sync_offset & 0x30) >> 2) | 691 ((h_sync_len & 0x300) >> 4) | ((v_sync_offset & 0x30) >> 2) |
599 ((v_sync_len & 0x30) >> 4); 692 ((v_sync_len & 0x30) >> 4);
600 693
601 output_dtd.part2.dtd_flags = 0x18; 694 dtd->part2.dtd_flags = 0x18;
602 if (mode->flags & DRM_MODE_FLAG_PHSYNC) 695 if (mode->flags & DRM_MODE_FLAG_PHSYNC)
603 output_dtd.part2.dtd_flags |= 0x2; 696 dtd->part2.dtd_flags |= 0x2;
604 if (mode->flags & DRM_MODE_FLAG_PVSYNC) 697 if (mode->flags & DRM_MODE_FLAG_PVSYNC)
605 output_dtd.part2.dtd_flags |= 0x4; 698 dtd->part2.dtd_flags |= 0x4;
699
700 dtd->part2.sdvo_flags = 0;
701 dtd->part2.v_sync_off_high = v_sync_offset & 0xc0;
702 dtd->part2.reserved = 0;
703}
704
705static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode,
706 struct intel_sdvo_dtd *dtd)
707{
708 uint16_t width, height;
709 uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len;
710 uint16_t h_sync_offset, v_sync_offset;
711
712 width = mode->crtc_hdisplay;
713 height = mode->crtc_vdisplay;
714
715 /* do some mode translations */
716 h_blank_len = mode->crtc_hblank_end - mode->crtc_hblank_start;
717 h_sync_len = mode->crtc_hsync_end - mode->crtc_hsync_start;
718
719 v_blank_len = mode->crtc_vblank_end - mode->crtc_vblank_start;
720 v_sync_len = mode->crtc_vsync_end - mode->crtc_vsync_start;
721
722 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start;
723 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start;
724
725 mode->hdisplay = dtd->part1.h_active;
726 mode->hdisplay += ((dtd->part1.h_high >> 4) & 0x0f) << 8;
727 mode->hsync_start = mode->hdisplay + dtd->part2.h_sync_off;
728 mode->hsync_start += (dtd->part2.sync_off_width_high & 0xa0) << 2;
729 mode->hsync_end = mode->hsync_start + dtd->part2.h_sync_width;
730 mode->hsync_end += (dtd->part2.sync_off_width_high & 0x30) << 4;
731 mode->htotal = mode->hdisplay + dtd->part1.h_blank;
732 mode->htotal += (dtd->part1.h_high & 0xf) << 8;
733
734 mode->vdisplay = dtd->part1.v_active;
735 mode->vdisplay += ((dtd->part1.v_high >> 4) & 0x0f) << 8;
736 mode->vsync_start = mode->vdisplay;
737 mode->vsync_start += (dtd->part2.v_sync_off_width >> 4) & 0xf;
738 mode->vsync_start += (dtd->part2.sync_off_width_high & 0x0a) << 2;
739 mode->vsync_start += dtd->part2.v_sync_off_high & 0xc0;
740 mode->vsync_end = mode->vsync_start +
741 (dtd->part2.v_sync_off_width & 0xf);
742 mode->vsync_end += (dtd->part2.sync_off_width_high & 0x3) << 4;
743 mode->vtotal = mode->vdisplay + dtd->part1.v_blank;
744 mode->vtotal += (dtd->part1.v_high & 0xf) << 8;
745
746 mode->clock = dtd->part1.clock * 10;
747
748 mode->flags &= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
749 if (dtd->part2.dtd_flags & 0x2)
750 mode->flags |= DRM_MODE_FLAG_PHSYNC;
751 if (dtd->part2.dtd_flags & 0x4)
752 mode->flags |= DRM_MODE_FLAG_PVSYNC;
753}
754
755static bool intel_sdvo_get_supp_encode(struct intel_output *output,
756 struct intel_sdvo_encode *encode)
757{
758 uint8_t status;
759
760 intel_sdvo_write_cmd(output, SDVO_CMD_GET_SUPP_ENCODE, NULL, 0);
761 status = intel_sdvo_read_response(output, encode, sizeof(*encode));
762 if (status != SDVO_CMD_STATUS_SUCCESS) { /* non-support means DVI */
763 memset(encode, 0, sizeof(*encode));
764 return false;
765 }
766
767 return true;
768}
769
770static bool intel_sdvo_set_encode(struct intel_output *output, uint8_t mode)
771{
772 uint8_t status;
773
774 intel_sdvo_write_cmd(output, SDVO_CMD_SET_ENCODE, &mode, 1);
775 status = intel_sdvo_read_response(output, NULL, 0);
776
777 return (status == SDVO_CMD_STATUS_SUCCESS);
778}
779
780static bool intel_sdvo_set_colorimetry(struct intel_output *output,
781 uint8_t mode)
782{
783 uint8_t status;
784
785 intel_sdvo_write_cmd(output, SDVO_CMD_SET_COLORIMETRY, &mode, 1);
786 status = intel_sdvo_read_response(output, NULL, 0);
787
788 return (status == SDVO_CMD_STATUS_SUCCESS);
789}
790
791#if 0
792static void intel_sdvo_dump_hdmi_buf(struct intel_output *output)
793{
794 int i, j;
795 uint8_t set_buf_index[2];
796 uint8_t av_split;
797 uint8_t buf_size;
798 uint8_t buf[48];
799 uint8_t *pos;
800
801 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_AV_SPLIT, NULL, 0);
802 intel_sdvo_read_response(output, &av_split, 1);
803
804 for (i = 0; i <= av_split; i++) {
805 set_buf_index[0] = i; set_buf_index[1] = 0;
806 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_INDEX,
807 set_buf_index, 2);
808 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_INFO, NULL, 0);
809 intel_sdvo_read_response(output, &buf_size, 1);
810
811 pos = buf;
812 for (j = 0; j <= buf_size; j += 8) {
813 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_DATA,
814 NULL, 0);
815 intel_sdvo_read_response(output, pos, 8);
816 pos += 8;
817 }
818 }
819}
820#endif
821
822static void intel_sdvo_set_hdmi_buf(struct intel_output *output, int index,
823 uint8_t *data, int8_t size, uint8_t tx_rate)
824{
825 uint8_t set_buf_index[2];
826
827 set_buf_index[0] = index;
828 set_buf_index[1] = 0;
829
830 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_INDEX, set_buf_index, 2);
831
832 for (; size > 0; size -= 8) {
833 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_DATA, data, 8);
834 data += 8;
835 }
836
837 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_TXRATE, &tx_rate, 1);
838}
839
840static uint8_t intel_sdvo_calc_hbuf_csum(uint8_t *data, uint8_t size)
841{
842 uint8_t csum = 0;
843 int i;
844
845 for (i = 0; i < size; i++)
846 csum += data[i];
847
848 return 0x100 - csum;
849}
850
851#define DIP_TYPE_AVI 0x82
852#define DIP_VERSION_AVI 0x2
853#define DIP_LEN_AVI 13
854
855struct dip_infoframe {
856 uint8_t type;
857 uint8_t version;
858 uint8_t len;
859 uint8_t checksum;
860 union {
861 struct {
862 /* Packet Byte #1 */
863 uint8_t S:2;
864 uint8_t B:2;
865 uint8_t A:1;
866 uint8_t Y:2;
867 uint8_t rsvd1:1;
868 /* Packet Byte #2 */
869 uint8_t R:4;
870 uint8_t M:2;
871 uint8_t C:2;
872 /* Packet Byte #3 */
873 uint8_t SC:2;
874 uint8_t Q:2;
875 uint8_t EC:3;
876 uint8_t ITC:1;
877 /* Packet Byte #4 */
878 uint8_t VIC:7;
879 uint8_t rsvd2:1;
880 /* Packet Byte #5 */
881 uint8_t PR:4;
882 uint8_t rsvd3:4;
883 /* Packet Byte #6~13 */
884 uint16_t top_bar_end;
885 uint16_t bottom_bar_start;
886 uint16_t left_bar_end;
887 uint16_t right_bar_start;
888 } avi;
889 struct {
890 /* Packet Byte #1 */
891 uint8_t channel_count:3;
892 uint8_t rsvd1:1;
893 uint8_t coding_type:4;
894 /* Packet Byte #2 */
895 uint8_t sample_size:2; /* SS0, SS1 */
896 uint8_t sample_frequency:3;
897 uint8_t rsvd2:3;
898 /* Packet Byte #3 */
899 uint8_t coding_type_private:5;
900 uint8_t rsvd3:3;
901 /* Packet Byte #4 */
902 uint8_t channel_allocation;
903 /* Packet Byte #5 */
904 uint8_t rsvd4:3;
905 uint8_t level_shift:4;
906 uint8_t downmix_inhibit:1;
907 } audio;
908 uint8_t payload[28];
909 } __attribute__ ((packed)) u;
910} __attribute__((packed));
911
912static void intel_sdvo_set_avi_infoframe(struct intel_output *output,
913 struct drm_display_mode * mode)
914{
915 struct dip_infoframe avi_if = {
916 .type = DIP_TYPE_AVI,
917 .version = DIP_VERSION_AVI,
918 .len = DIP_LEN_AVI,
919 };
920
921 avi_if.checksum = intel_sdvo_calc_hbuf_csum((uint8_t *)&avi_if,
922 4 + avi_if.len);
923 intel_sdvo_set_hdmi_buf(output, 1, (uint8_t *)&avi_if, 4 + avi_if.len,
924 SDVO_HBUF_TX_VSYNC);
925}
926
927static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
928 struct drm_display_mode *mode,
929 struct drm_display_mode *adjusted_mode)
930{
931 struct intel_output *output = enc_to_intel_output(encoder);
932 struct intel_sdvo_priv *dev_priv = output->dev_priv;
606 933
607 output_dtd.part2.sdvo_flags = 0; 934 if (!dev_priv->is_tv) {
608 output_dtd.part2.v_sync_off_high = v_sync_offset & 0xc0; 935 /* Make the CRTC code factor in the SDVO pixel multiplier. The
609 output_dtd.part2.reserved = 0; 936 * SDVO device will be told of the multiplier during mode_set.
937 */
938 adjusted_mode->clock *= intel_sdvo_get_pixel_multiplier(mode);
939 } else {
940 struct intel_sdvo_dtd output_dtd;
941 bool success;
942
943 /* We need to construct preferred input timings based on our
944 * output timings. To do that, we have to set the output
945 * timings, even though this isn't really the right place in
946 * the sequence to do it. Oh well.
947 */
948
949
950 /* Set output timings */
951 intel_sdvo_get_dtd_from_mode(&output_dtd, mode);
952 intel_sdvo_set_target_output(output,
953 dev_priv->controlled_output);
954 intel_sdvo_set_output_timing(output, &output_dtd);
955
956 /* Set the input timing to the screen. Assume always input 0. */
957 intel_sdvo_set_target_input(output, true, false);
958
959
960 success = intel_sdvo_create_preferred_input_timing(output,
961 mode->clock / 10,
962 mode->hdisplay,
963 mode->vdisplay);
964 if (success) {
965 struct intel_sdvo_dtd input_dtd;
610 966
611 /* Set the output timing to the screen */ 967 intel_sdvo_get_preferred_input_timing(output,
612 intel_sdvo_set_target_output(intel_output, sdvo_priv->active_outputs); 968 &input_dtd);
613 intel_sdvo_set_output_timing(intel_output, &output_dtd); 969 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd);
970
971 } else {
972 return false;
973 }
974 }
975 return true;
976}
977
978static void intel_sdvo_mode_set(struct drm_encoder *encoder,
979 struct drm_display_mode *mode,
980 struct drm_display_mode *adjusted_mode)
981{
982 struct drm_device *dev = encoder->dev;
983 struct drm_i915_private *dev_priv = dev->dev_private;
984 struct drm_crtc *crtc = encoder->crtc;
985 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
986 struct intel_output *output = enc_to_intel_output(encoder);
987 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
988 u32 sdvox = 0;
989 int sdvo_pixel_multiply;
990 struct intel_sdvo_in_out_map in_out;
991 struct intel_sdvo_dtd input_dtd;
992 u8 status;
993
994 if (!mode)
995 return;
996
997 /* First, set the input mapping for the first input to our controlled
998 * output. This is only correct if we're a single-input device, in
999 * which case the first input is the output from the appropriate SDVO
1000 * channel on the motherboard. In a two-input device, the first input
1001 * will be SDVOB and the second SDVOC.
1002 */
1003 in_out.in0 = sdvo_priv->controlled_output;
1004 in_out.in1 = 0;
1005
1006 intel_sdvo_write_cmd(output, SDVO_CMD_SET_IN_OUT_MAP,
1007 &in_out, sizeof(in_out));
1008 status = intel_sdvo_read_response(output, NULL, 0);
1009
1010 if (sdvo_priv->is_hdmi) {
1011 intel_sdvo_set_avi_infoframe(output, mode);
1012 sdvox |= SDVO_AUDIO_ENABLE;
1013 }
1014
1015 intel_sdvo_get_dtd_from_mode(&input_dtd, mode);
1016
1017 /* If it's a TV, we already set the output timing in mode_fixup.
1018 * Otherwise, the output timing is equal to the input timing.
1019 */
1020 if (!sdvo_priv->is_tv) {
1021 /* Set the output timing to the screen */
1022 intel_sdvo_set_target_output(output,
1023 sdvo_priv->controlled_output);
1024 intel_sdvo_set_output_timing(output, &input_dtd);
1025 }
614 1026
615 /* Set the input timing to the screen. Assume always input 0. */ 1027 /* Set the input timing to the screen. Assume always input 0. */
616 intel_sdvo_set_target_input(intel_output, true, false); 1028 intel_sdvo_set_target_input(output, true, false);
617 1029
618 /* We would like to use i830_sdvo_create_preferred_input_timing() to 1030 /* We would like to use intel_sdvo_create_preferred_input_timing() to
619 * provide the device with a timing it can support, if it supports that 1031 * provide the device with a timing it can support, if it supports that
620 * feature. However, presumably we would need to adjust the CRTC to 1032 * feature. However, presumably we would need to adjust the CRTC to
621 * output the preferred timing, and we don't support that currently. 1033 * output the preferred timing, and we don't support that currently.
622 */ 1034 */
623 intel_sdvo_set_input_timing(intel_output, &output_dtd); 1035#if 0
1036 success = intel_sdvo_create_preferred_input_timing(output, clock,
1037 width, height);
1038 if (success) {
1039 struct intel_sdvo_dtd *input_dtd;
1040
1041 intel_sdvo_get_preferred_input_timing(output, &input_dtd);
1042 intel_sdvo_set_input_timing(output, &input_dtd);
1043 }
1044#else
1045 intel_sdvo_set_input_timing(output, &input_dtd);
1046#endif
624 1047
625 switch (intel_sdvo_get_pixel_multiplier(mode)) { 1048 switch (intel_sdvo_get_pixel_multiplier(mode)) {
626 case 1: 1049 case 1:
627 intel_sdvo_set_clock_rate_mult(intel_output, 1050 intel_sdvo_set_clock_rate_mult(output,
628 SDVO_CLOCK_RATE_MULT_1X); 1051 SDVO_CLOCK_RATE_MULT_1X);
629 break; 1052 break;
630 case 2: 1053 case 2:
631 intel_sdvo_set_clock_rate_mult(intel_output, 1054 intel_sdvo_set_clock_rate_mult(output,
632 SDVO_CLOCK_RATE_MULT_2X); 1055 SDVO_CLOCK_RATE_MULT_2X);
633 break; 1056 break;
634 case 4: 1057 case 4:
635 intel_sdvo_set_clock_rate_mult(intel_output, 1058 intel_sdvo_set_clock_rate_mult(output,
636 SDVO_CLOCK_RATE_MULT_4X); 1059 SDVO_CLOCK_RATE_MULT_4X);
637 break; 1060 break;
638 } 1061 }
639 1062
640 /* Set the SDVO control regs. */ 1063 /* Set the SDVO control regs. */
641 if (0/*IS_I965GM(dev)*/) { 1064 if (IS_I965G(dev)) {
642 sdvox = SDVO_BORDER_ENABLE; 1065 sdvox |= SDVO_BORDER_ENABLE |
643 } else { 1066 SDVO_VSYNC_ACTIVE_HIGH |
644 sdvox = I915_READ(sdvo_priv->output_device); 1067 SDVO_HSYNC_ACTIVE_HIGH;
645 switch (sdvo_priv->output_device) { 1068 } else {
646 case SDVOB: 1069 sdvox |= I915_READ(sdvo_priv->output_device);
647 sdvox &= SDVOB_PRESERVE_MASK; 1070 switch (sdvo_priv->output_device) {
648 break; 1071 case SDVOB:
649 case SDVOC: 1072 sdvox &= SDVOB_PRESERVE_MASK;
650 sdvox &= SDVOC_PRESERVE_MASK; 1073 break;
651 break; 1074 case SDVOC:
652 } 1075 sdvox &= SDVOC_PRESERVE_MASK;
653 sdvox |= (9 << 19) | SDVO_BORDER_ENABLE; 1076 break;
654 } 1077 }
1078 sdvox |= (9 << 19) | SDVO_BORDER_ENABLE;
1079 }
655 if (intel_crtc->pipe == 1) 1080 if (intel_crtc->pipe == 1)
656 sdvox |= SDVO_PIPE_B_SELECT; 1081 sdvox |= SDVO_PIPE_B_SELECT;
657 1082
658 sdvo_pixel_multiply = intel_sdvo_get_pixel_multiplier(mode); 1083 sdvo_pixel_multiply = intel_sdvo_get_pixel_multiplier(mode);
659 if (IS_I965G(dev)) { 1084 if (IS_I965G(dev)) {
660 /* done in crtc_mode_set as the dpll_md reg must be written 1085 /* done in crtc_mode_set as the dpll_md reg must be written early */
661 early */ 1086 } else if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) {
662 } else if (IS_I945G(dev) || IS_I945GM(dev)) { 1087 /* done in crtc_mode_set as it lives inside the dpll register */
663 /* done in crtc_mode_set as it lives inside the
664 dpll register */
665 } else { 1088 } else {
666 sdvox |= (sdvo_pixel_multiply - 1) << SDVO_PORT_MULTIPLY_SHIFT; 1089 sdvox |= (sdvo_pixel_multiply - 1) << SDVO_PORT_MULTIPLY_SHIFT;
667 } 1090 }
668 1091
669 intel_sdvo_write_sdvox(intel_output, sdvox); 1092 intel_sdvo_write_sdvox(output, sdvox);
670} 1093}
671 1094
672static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode) 1095static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode)
@@ -714,7 +1137,7 @@ static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode)
714 1137
715 if (0) 1138 if (0)
716 intel_sdvo_set_encoder_power_state(intel_output, mode); 1139 intel_sdvo_set_encoder_power_state(intel_output, mode);
717 intel_sdvo_set_active_outputs(intel_output, sdvo_priv->active_outputs); 1140 intel_sdvo_set_active_outputs(intel_output, sdvo_priv->controlled_output);
718 } 1141 }
719 return; 1142 return;
720} 1143}
@@ -752,6 +1175,9 @@ static void intel_sdvo_save(struct drm_connector *connector)
752 &sdvo_priv->save_output_dtd[o]); 1175 &sdvo_priv->save_output_dtd[o]);
753 } 1176 }
754 } 1177 }
1178 if (sdvo_priv->is_tv) {
1179 /* XXX: Save TV format/enhancements. */
1180 }
755 1181
756 sdvo_priv->save_SDVOX = I915_READ(sdvo_priv->output_device); 1182 sdvo_priv->save_SDVOX = I915_READ(sdvo_priv->output_device);
757} 1183}
@@ -759,7 +1185,6 @@ static void intel_sdvo_save(struct drm_connector *connector)
759static void intel_sdvo_restore(struct drm_connector *connector) 1185static void intel_sdvo_restore(struct drm_connector *connector)
760{ 1186{
761 struct drm_device *dev = connector->dev; 1187 struct drm_device *dev = connector->dev;
762 struct drm_i915_private *dev_priv = dev->dev_private;
763 struct intel_output *intel_output = to_intel_output(connector); 1188 struct intel_output *intel_output = to_intel_output(connector);
764 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1189 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
765 int o; 1190 int o;
@@ -790,7 +1215,11 @@ static void intel_sdvo_restore(struct drm_connector *connector)
790 1215
791 intel_sdvo_set_clock_rate_mult(intel_output, sdvo_priv->save_sdvo_mult); 1216 intel_sdvo_set_clock_rate_mult(intel_output, sdvo_priv->save_sdvo_mult);
792 1217
793 I915_WRITE(sdvo_priv->output_device, sdvo_priv->save_SDVOX); 1218 if (sdvo_priv->is_tv) {
1219 /* XXX: Restore TV format/enhancements. */
1220 }
1221
1222 intel_sdvo_write_sdvox(intel_output, sdvo_priv->save_SDVOX);
794 1223
795 if (sdvo_priv->save_SDVOX & SDVO_ENABLE) 1224 if (sdvo_priv->save_SDVOX & SDVO_ENABLE)
796 { 1225 {
@@ -916,20 +1345,173 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
916 status = intel_sdvo_read_response(intel_output, &response, 2); 1345 status = intel_sdvo_read_response(intel_output, &response, 2);
917 1346
918 DRM_DEBUG("SDVO response %d %d\n", response[0], response[1]); 1347 DRM_DEBUG("SDVO response %d %d\n", response[0], response[1]);
1348
1349 if (status != SDVO_CMD_STATUS_SUCCESS)
1350 return connector_status_unknown;
1351
919 if ((response[0] != 0) || (response[1] != 0)) 1352 if ((response[0] != 0) || (response[1] != 0))
920 return connector_status_connected; 1353 return connector_status_connected;
921 else 1354 else
922 return connector_status_disconnected; 1355 return connector_status_disconnected;
923} 1356}
924 1357
925static int intel_sdvo_get_modes(struct drm_connector *connector) 1358static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
926{ 1359{
927 struct intel_output *intel_output = to_intel_output(connector); 1360 struct intel_output *intel_output = to_intel_output(connector);
1361 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
928 1362
929 /* set the bus switch and get the modes */ 1363 /* set the bus switch and get the modes */
930 intel_sdvo_set_control_bus_switch(intel_output, SDVO_CONTROL_BUS_DDC2); 1364 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
931 intel_ddc_get_modes(intel_output); 1365 intel_ddc_get_modes(intel_output);
932 1366
1367#if 0
1368 struct drm_device *dev = encoder->dev;
1369 struct drm_i915_private *dev_priv = dev->dev_private;
1370 /* Mac mini hack. On this device, I get DDC through the analog, which
1371 * load-detects as disconnected. I fail to DDC through the SDVO DDC,
1372 * but it does load-detect as connected. So, just steal the DDC bits
1373 * from analog when we fail at finding it the right way.
1374 */
1375 crt = xf86_config->output[0];
1376 intel_output = crt->driver_private;
1377 if (intel_output->type == I830_OUTPUT_ANALOG &&
1378 crt->funcs->detect(crt) == XF86OutputStatusDisconnected) {
1379 I830I2CInit(pScrn, &intel_output->pDDCBus, GPIOA, "CRTDDC_A");
1380 edid_mon = xf86OutputGetEDID(crt, intel_output->pDDCBus);
1381 xf86DestroyI2CBusRec(intel_output->pDDCBus, true, true);
1382 }
1383 if (edid_mon) {
1384 xf86OutputSetEDID(output, edid_mon);
1385 modes = xf86OutputGetEDIDModes(output);
1386 }
1387#endif
1388}
1389
1390/**
1391 * This function checks the current TV format, and chooses a default if
1392 * it hasn't been set.
1393 */
1394static void
1395intel_sdvo_check_tv_format(struct intel_output *output)
1396{
1397 struct intel_sdvo_priv *dev_priv = output->dev_priv;
1398 struct intel_sdvo_tv_format format, unset;
1399 uint8_t status;
1400
1401 intel_sdvo_write_cmd(output, SDVO_CMD_GET_TV_FORMAT, NULL, 0);
1402 status = intel_sdvo_read_response(output, &format, sizeof(format));
1403 if (status != SDVO_CMD_STATUS_SUCCESS)
1404 return;
1405
1406 memset(&unset, 0, sizeof(unset));
1407 if (memcmp(&format, &unset, sizeof(format))) {
1408 DRM_DEBUG("%s: Choosing default TV format of NTSC-M\n",
1409 SDVO_NAME(dev_priv));
1410
1411 format.ntsc_m = true;
1412 intel_sdvo_write_cmd(output, SDVO_CMD_SET_TV_FORMAT, NULL, 0);
1413 status = intel_sdvo_read_response(output, NULL, 0);
1414 }
1415}
1416
1417/*
1418 * Set of SDVO TV modes.
1419 * Note! This is in reply order (see loop in get_tv_modes).
1420 * XXX: all 60Hz refresh?
1421 */
1422struct drm_display_mode sdvo_tv_modes[] = {
1423 { DRM_MODE("320x200", DRM_MODE_TYPE_DRIVER, 5815680, 321, 384, 416,
1424 200, 0, 232, 201, 233, 4196112, 0,
1425 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1426 { DRM_MODE("320x240", DRM_MODE_TYPE_DRIVER, 6814080, 321, 384, 416,
1427 240, 0, 272, 241, 273, 4196112, 0,
1428 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1429 { DRM_MODE("400x300", DRM_MODE_TYPE_DRIVER, 9910080, 401, 464, 496,
1430 300, 0, 332, 301, 333, 4196112, 0,
1431 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1432 { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 16913280, 641, 704, 736,
1433 350, 0, 382, 351, 383, 4196112, 0,
1434 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1435 { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 19121280, 641, 704, 736,
1436 400, 0, 432, 401, 433, 4196112, 0,
1437 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1438 { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 19121280, 641, 704, 736,
1439 400, 0, 432, 401, 433, 4196112, 0,
1440 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1441 { DRM_MODE("704x480", DRM_MODE_TYPE_DRIVER, 24624000, 705, 768, 800,
1442 480, 0, 512, 481, 513, 4196112, 0,
1443 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1444 { DRM_MODE("704x576", DRM_MODE_TYPE_DRIVER, 29232000, 705, 768, 800,
1445 576, 0, 608, 577, 609, 4196112, 0,
1446 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1447 { DRM_MODE("720x350", DRM_MODE_TYPE_DRIVER, 18751680, 721, 784, 816,
1448 350, 0, 382, 351, 383, 4196112, 0,
1449 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1450 { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 21199680, 721, 784, 816,
1451 400, 0, 432, 401, 433, 4196112, 0,
1452 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1453 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 25116480, 721, 784, 816,
1454 480, 0, 512, 481, 513, 4196112, 0,
1455 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1456 { DRM_MODE("720x540", DRM_MODE_TYPE_DRIVER, 28054080, 721, 784, 816,
1457 540, 0, 572, 541, 573, 4196112, 0,
1458 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1459 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 29816640, 721, 784, 816,
1460 576, 0, 608, 577, 609, 4196112, 0,
1461 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1462 { DRM_MODE("768x576", DRM_MODE_TYPE_DRIVER, 31570560, 769, 832, 864,
1463 576, 0, 608, 577, 609, 4196112, 0,
1464 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1465 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 34030080, 801, 864, 896,
1466 600, 0, 632, 601, 633, 4196112, 0,
1467 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1468 { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 36581760, 833, 896, 928,
1469 624, 0, 656, 625, 657, 4196112, 0,
1470 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1471 { DRM_MODE("920x766", DRM_MODE_TYPE_DRIVER, 48707040, 921, 984, 1016,
1472 766, 0, 798, 767, 799, 4196112, 0,
1473 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1474 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 53827200, 1025, 1088, 1120,
1475 768, 0, 800, 769, 801, 4196112, 0,
1476 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1477 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 87265920, 1281, 1344, 1376,
1478 1024, 0, 1056, 1025, 1057, 4196112, 0,
1479 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1480};
1481
1482static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
1483{
1484 struct intel_output *output = to_intel_output(connector);
1485 uint32_t reply = 0;
1486 uint8_t status;
1487 int i = 0;
1488
1489 intel_sdvo_check_tv_format(output);
1490
1491 /* Read the list of supported input resolutions for the selected TV
1492 * format.
1493 */
1494 intel_sdvo_write_cmd(output, SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT,
1495 NULL, 0);
1496 status = intel_sdvo_read_response(output, &reply, 3);
1497 if (status != SDVO_CMD_STATUS_SUCCESS)
1498 return;
1499
1500 for (i = 0; i < ARRAY_SIZE(sdvo_tv_modes); i++)
1501 if (reply & (1 << i))
1502 drm_mode_probed_add(connector, &sdvo_tv_modes[i]);
1503}
1504
1505static int intel_sdvo_get_modes(struct drm_connector *connector)
1506{
1507 struct intel_output *output = to_intel_output(connector);
1508 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
1509
1510 if (sdvo_priv->is_tv)
1511 intel_sdvo_get_tv_modes(connector);
1512 else
1513 intel_sdvo_get_ddc_modes(connector);
1514
933 if (list_empty(&connector->probed_modes)) 1515 if (list_empty(&connector->probed_modes))
934 return 0; 1516 return 0;
935 return 1; 1517 return 1;
@@ -978,6 +1560,65 @@ static const struct drm_encoder_funcs intel_sdvo_enc_funcs = {
978}; 1560};
979 1561
980 1562
1563/**
1564 * Choose the appropriate DDC bus for control bus switch command for this
1565 * SDVO output based on the controlled output.
1566 *
1567 * DDC bus number assignment is in a priority order of RGB outputs, then TMDS
1568 * outputs, then LVDS outputs.
1569 */
1570static void
1571intel_sdvo_select_ddc_bus(struct intel_sdvo_priv *dev_priv)
1572{
1573 uint16_t mask = 0;
1574 unsigned int num_bits;
1575
1576 /* Make a mask of outputs less than or equal to our own priority in the
1577 * list.
1578 */
1579 switch (dev_priv->controlled_output) {
1580 case SDVO_OUTPUT_LVDS1:
1581 mask |= SDVO_OUTPUT_LVDS1;
1582 case SDVO_OUTPUT_LVDS0:
1583 mask |= SDVO_OUTPUT_LVDS0;
1584 case SDVO_OUTPUT_TMDS1:
1585 mask |= SDVO_OUTPUT_TMDS1;
1586 case SDVO_OUTPUT_TMDS0:
1587 mask |= SDVO_OUTPUT_TMDS0;
1588 case SDVO_OUTPUT_RGB1:
1589 mask |= SDVO_OUTPUT_RGB1;
1590 case SDVO_OUTPUT_RGB0:
1591 mask |= SDVO_OUTPUT_RGB0;
1592 break;
1593 }
1594
1595 /* Count bits to find what number we are in the priority list. */
1596 mask &= dev_priv->caps.output_flags;
1597 num_bits = hweight16(mask);
1598 if (num_bits > 3) {
1599 /* if more than 3 outputs, default to DDC bus 3 for now */
1600 num_bits = 3;
1601 }
1602
1603 /* Corresponds to SDVO_CONTROL_BUS_DDCx */
1604 dev_priv->ddc_bus = 1 << num_bits;
1605}
1606
1607static bool
1608intel_sdvo_get_digital_encoding_mode(struct intel_output *output)
1609{
1610 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
1611 uint8_t status;
1612
1613 intel_sdvo_set_target_output(output, sdvo_priv->controlled_output);
1614
1615 intel_sdvo_write_cmd(output, SDVO_CMD_GET_ENCODE, NULL, 0);
1616 status = intel_sdvo_read_response(output, &sdvo_priv->is_hdmi, 1);
1617 if (status != SDVO_CMD_STATUS_SUCCESS)
1618 return false;
1619 return true;
1620}
1621
981bool intel_sdvo_init(struct drm_device *dev, int output_device) 1622bool intel_sdvo_init(struct drm_device *dev, int output_device)
982{ 1623{
983 struct drm_connector *connector; 1624 struct drm_connector *connector;
@@ -1040,45 +1681,76 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1040 1681
1041 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps); 1682 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps);
1042 1683
1043 memset(&sdvo_priv->active_outputs, 0, sizeof(sdvo_priv->active_outputs)); 1684 if (sdvo_priv->caps.output_flags &
1685 (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) {
1686 if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0)
1687 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS0;
1688 else
1689 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1;
1690
1691 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1692 encoder_type = DRM_MODE_ENCODER_TMDS;
1693 connector_type = DRM_MODE_CONNECTOR_DVID;
1044 1694
1045 /* TODO, CVBS, SVID, YPRPB & SCART outputs. */ 1695 if (intel_sdvo_get_supp_encode(intel_output,
1046 if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0) 1696 &sdvo_priv->encode) &&
1697 intel_sdvo_get_digital_encoding_mode(intel_output) &&
1698 sdvo_priv->is_hdmi) {
1699 /* enable hdmi encoding mode if supported */
1700 intel_sdvo_set_encode(intel_output, SDVO_ENCODE_HDMI);
1701 intel_sdvo_set_colorimetry(intel_output,
1702 SDVO_COLORIMETRY_RGB256);
1703 connector_type = DRM_MODE_CONNECTOR_HDMIA;
1704 }
1705 }
1706 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_SVID0)
1047 { 1707 {
1048 sdvo_priv->active_outputs = SDVO_OUTPUT_RGB0; 1708 sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0;
1709 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1710 encoder_type = DRM_MODE_ENCODER_TVDAC;
1711 connector_type = DRM_MODE_CONNECTOR_SVIDEO;
1712 sdvo_priv->is_tv = true;
1713 intel_output->needs_tv_clock = true;
1714 }
1715 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0)
1716 {
1717 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0;
1049 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1718 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1050 encoder_type = DRM_MODE_ENCODER_DAC; 1719 encoder_type = DRM_MODE_ENCODER_DAC;
1051 connector_type = DRM_MODE_CONNECTOR_VGA; 1720 connector_type = DRM_MODE_CONNECTOR_VGA;
1052 } 1721 }
1053 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1) 1722 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1)
1054 { 1723 {
1055 sdvo_priv->active_outputs = SDVO_OUTPUT_RGB1; 1724 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1;
1056 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1725 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1057 encoder_type = DRM_MODE_ENCODER_DAC; 1726 encoder_type = DRM_MODE_ENCODER_DAC;
1058 connector_type = DRM_MODE_CONNECTOR_VGA; 1727 connector_type = DRM_MODE_CONNECTOR_VGA;
1059 } 1728 }
1060 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) 1729 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS0)
1061 { 1730 {
1062 sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS0; 1731 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0;
1063 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1732 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1064 encoder_type = DRM_MODE_ENCODER_TMDS; 1733 encoder_type = DRM_MODE_ENCODER_LVDS;
1065 connector_type = DRM_MODE_CONNECTOR_DVID; 1734 connector_type = DRM_MODE_CONNECTOR_LVDS;
1066 } 1735 }
1067 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS1) 1736 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS1)
1068 { 1737 {
1069 sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS1; 1738 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1;
1070 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1739 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1071 encoder_type = DRM_MODE_ENCODER_TMDS; 1740 encoder_type = DRM_MODE_ENCODER_LVDS;
1072 connector_type = DRM_MODE_CONNECTOR_DVID; 1741 connector_type = DRM_MODE_CONNECTOR_LVDS;
1073 } 1742 }
1074 else 1743 else
1075 { 1744 {
1076 unsigned char bytes[2]; 1745 unsigned char bytes[2];
1077 1746
1747 sdvo_priv->controlled_output = 0;
1078 memcpy (bytes, &sdvo_priv->caps.output_flags, 2); 1748 memcpy (bytes, &sdvo_priv->caps.output_flags, 2);
1079 DRM_DEBUG("%s: No active RGB or TMDS outputs (0x%02x%02x)\n", 1749 DRM_DEBUG("%s: Unknown SDVO output type (0x%02x%02x)\n",
1080 SDVO_NAME(sdvo_priv), 1750 SDVO_NAME(sdvo_priv),
1081 bytes[0], bytes[1]); 1751 bytes[0], bytes[1]);
1752 encoder_type = DRM_MODE_ENCODER_NONE;
1753 connector_type = DRM_MODE_CONNECTOR_Unknown;
1082 goto err_i2c; 1754 goto err_i2c;
1083 } 1755 }
1084 1756
@@ -1089,6 +1761,8 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1089 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 1761 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc);
1090 drm_sysfs_connector_add(connector); 1762 drm_sysfs_connector_add(connector);
1091 1763
1764 intel_sdvo_select_ddc_bus(sdvo_priv);
1765
1092 /* Set the input timing to the screen. Assume always input 0. */ 1766 /* Set the input timing to the screen. Assume always input 0. */
1093 intel_sdvo_set_target_input(intel_output, true, false); 1767 intel_sdvo_set_target_input(intel_output, true, false);
1094 1768
diff --git a/drivers/gpu/drm/i915/intel_sdvo_regs.h b/drivers/gpu/drm/i915/intel_sdvo_regs.h
index 861a43f8693c..1117b9c151a6 100644
--- a/drivers/gpu/drm/i915/intel_sdvo_regs.h
+++ b/drivers/gpu/drm/i915/intel_sdvo_regs.h
@@ -173,6 +173,9 @@ struct intel_sdvo_get_trained_inputs_response {
173 * Returns two struct intel_sdvo_output_flags structures. 173 * Returns two struct intel_sdvo_output_flags structures.
174 */ 174 */
175#define SDVO_CMD_GET_IN_OUT_MAP 0x06 175#define SDVO_CMD_GET_IN_OUT_MAP 0x06
176struct intel_sdvo_in_out_map {
177 u16 in0, in1;
178};
176 179
177/** 180/**
178 * Sets the current mapping of SDVO inputs to outputs on the device. 181 * Sets the current mapping of SDVO inputs to outputs on the device.
@@ -206,7 +209,8 @@ struct intel_sdvo_get_trained_inputs_response {
206struct intel_sdvo_get_interrupt_event_source_response { 209struct intel_sdvo_get_interrupt_event_source_response {
207 u16 interrupt_status; 210 u16 interrupt_status;
208 unsigned int ambient_light_interrupt:1; 211 unsigned int ambient_light_interrupt:1;
209 unsigned int pad:7; 212 unsigned int hdmi_audio_encrypt_change:1;
213 unsigned int pad:6;
210} __attribute__((packed)); 214} __attribute__((packed));
211 215
212/** 216/**
@@ -305,23 +309,411 @@ struct intel_sdvo_set_target_input_args {
305# define SDVO_CLOCK_RATE_MULT_4X (1 << 3) 309# define SDVO_CLOCK_RATE_MULT_4X (1 << 3)
306 310
307#define SDVO_CMD_GET_SUPPORTED_TV_FORMATS 0x27 311#define SDVO_CMD_GET_SUPPORTED_TV_FORMATS 0x27
312/** 5 bytes of bit flags for TV formats shared by all TV format functions */
313struct intel_sdvo_tv_format {
314 unsigned int ntsc_m:1;
315 unsigned int ntsc_j:1;
316 unsigned int ntsc_443:1;
317 unsigned int pal_b:1;
318 unsigned int pal_d:1;
319 unsigned int pal_g:1;
320 unsigned int pal_h:1;
321 unsigned int pal_i:1;
322
323 unsigned int pal_m:1;
324 unsigned int pal_n:1;
325 unsigned int pal_nc:1;
326 unsigned int pal_60:1;
327 unsigned int secam_b:1;
328 unsigned int secam_d:1;
329 unsigned int secam_g:1;
330 unsigned int secam_k:1;
331
332 unsigned int secam_k1:1;
333 unsigned int secam_l:1;
334 unsigned int secam_60:1;
335 unsigned int hdtv_std_smpte_240m_1080i_59:1;
336 unsigned int hdtv_std_smpte_240m_1080i_60:1;
337 unsigned int hdtv_std_smpte_260m_1080i_59:1;
338 unsigned int hdtv_std_smpte_260m_1080i_60:1;
339 unsigned int hdtv_std_smpte_274m_1080i_50:1;
340
341 unsigned int hdtv_std_smpte_274m_1080i_59:1;
342 unsigned int hdtv_std_smpte_274m_1080i_60:1;
343 unsigned int hdtv_std_smpte_274m_1080p_23:1;
344 unsigned int hdtv_std_smpte_274m_1080p_24:1;
345 unsigned int hdtv_std_smpte_274m_1080p_25:1;
346 unsigned int hdtv_std_smpte_274m_1080p_29:1;
347 unsigned int hdtv_std_smpte_274m_1080p_30:1;
348 unsigned int hdtv_std_smpte_274m_1080p_50:1;
349
350 unsigned int hdtv_std_smpte_274m_1080p_59:1;
351 unsigned int hdtv_std_smpte_274m_1080p_60:1;
352 unsigned int hdtv_std_smpte_295m_1080i_50:1;
353 unsigned int hdtv_std_smpte_295m_1080p_50:1;
354 unsigned int hdtv_std_smpte_296m_720p_59:1;
355 unsigned int hdtv_std_smpte_296m_720p_60:1;
356 unsigned int hdtv_std_smpte_296m_720p_50:1;
357 unsigned int hdtv_std_smpte_293m_480p_59:1;
358
359 unsigned int hdtv_std_smpte_170m_480i_59:1;
360 unsigned int hdtv_std_iturbt601_576i_50:1;
361 unsigned int hdtv_std_iturbt601_576p_50:1;
362 unsigned int hdtv_std_eia_7702a_480i_60:1;
363 unsigned int hdtv_std_eia_7702a_480p_60:1;
364 unsigned int pad:3;
365} __attribute__((packed));
308 366
309#define SDVO_CMD_GET_TV_FORMAT 0x28 367#define SDVO_CMD_GET_TV_FORMAT 0x28
310 368
311#define SDVO_CMD_SET_TV_FORMAT 0x29 369#define SDVO_CMD_SET_TV_FORMAT 0x29
312 370
371/** Returns the resolutiosn that can be used with the given TV format */
372#define SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT 0x83
373struct intel_sdvo_sdtv_resolution_request {
374 unsigned int ntsc_m:1;
375 unsigned int ntsc_j:1;
376 unsigned int ntsc_443:1;
377 unsigned int pal_b:1;
378 unsigned int pal_d:1;
379 unsigned int pal_g:1;
380 unsigned int pal_h:1;
381 unsigned int pal_i:1;
382
383 unsigned int pal_m:1;
384 unsigned int pal_n:1;
385 unsigned int pal_nc:1;
386 unsigned int pal_60:1;
387 unsigned int secam_b:1;
388 unsigned int secam_d:1;
389 unsigned int secam_g:1;
390 unsigned int secam_k:1;
391
392 unsigned int secam_k1:1;
393 unsigned int secam_l:1;
394 unsigned int secam_60:1;
395 unsigned int pad:5;
396} __attribute__((packed));
397
398struct intel_sdvo_sdtv_resolution_reply {
399 unsigned int res_320x200:1;
400 unsigned int res_320x240:1;
401 unsigned int res_400x300:1;
402 unsigned int res_640x350:1;
403 unsigned int res_640x400:1;
404 unsigned int res_640x480:1;
405 unsigned int res_704x480:1;
406 unsigned int res_704x576:1;
407
408 unsigned int res_720x350:1;
409 unsigned int res_720x400:1;
410 unsigned int res_720x480:1;
411 unsigned int res_720x540:1;
412 unsigned int res_720x576:1;
413 unsigned int res_768x576:1;
414 unsigned int res_800x600:1;
415 unsigned int res_832x624:1;
416
417 unsigned int res_920x766:1;
418 unsigned int res_1024x768:1;
419 unsigned int res_1280x1024:1;
420 unsigned int pad:5;
421} __attribute__((packed));
422
423/* Get supported resolution with squire pixel aspect ratio that can be
424 scaled for the requested HDTV format */
425#define SDVO_CMD_GET_SCALED_HDTV_RESOLUTION_SUPPORT 0x85
426
427struct intel_sdvo_hdtv_resolution_request {
428 unsigned int hdtv_std_smpte_240m_1080i_59:1;
429 unsigned int hdtv_std_smpte_240m_1080i_60:1;
430 unsigned int hdtv_std_smpte_260m_1080i_59:1;
431 unsigned int hdtv_std_smpte_260m_1080i_60:1;
432 unsigned int hdtv_std_smpte_274m_1080i_50:1;
433 unsigned int hdtv_std_smpte_274m_1080i_59:1;
434 unsigned int hdtv_std_smpte_274m_1080i_60:1;
435 unsigned int hdtv_std_smpte_274m_1080p_23:1;
436
437 unsigned int hdtv_std_smpte_274m_1080p_24:1;
438 unsigned int hdtv_std_smpte_274m_1080p_25:1;
439 unsigned int hdtv_std_smpte_274m_1080p_29:1;
440 unsigned int hdtv_std_smpte_274m_1080p_30:1;
441 unsigned int hdtv_std_smpte_274m_1080p_50:1;
442 unsigned int hdtv_std_smpte_274m_1080p_59:1;
443 unsigned int hdtv_std_smpte_274m_1080p_60:1;
444 unsigned int hdtv_std_smpte_295m_1080i_50:1;
445
446 unsigned int hdtv_std_smpte_295m_1080p_50:1;
447 unsigned int hdtv_std_smpte_296m_720p_59:1;
448 unsigned int hdtv_std_smpte_296m_720p_60:1;
449 unsigned int hdtv_std_smpte_296m_720p_50:1;
450 unsigned int hdtv_std_smpte_293m_480p_59:1;
451 unsigned int hdtv_std_smpte_170m_480i_59:1;
452 unsigned int hdtv_std_iturbt601_576i_50:1;
453 unsigned int hdtv_std_iturbt601_576p_50:1;
454
455 unsigned int hdtv_std_eia_7702a_480i_60:1;
456 unsigned int hdtv_std_eia_7702a_480p_60:1;
457 unsigned int pad:6;
458} __attribute__((packed));
459
460struct intel_sdvo_hdtv_resolution_reply {
461 unsigned int res_640x480:1;
462 unsigned int res_800x600:1;
463 unsigned int res_1024x768:1;
464 unsigned int res_1280x960:1;
465 unsigned int res_1400x1050:1;
466 unsigned int res_1600x1200:1;
467 unsigned int res_1920x1440:1;
468 unsigned int res_2048x1536:1;
469
470 unsigned int res_2560x1920:1;
471 unsigned int res_3200x2400:1;
472 unsigned int res_3840x2880:1;
473 unsigned int pad1:5;
474
475 unsigned int res_848x480:1;
476 unsigned int res_1064x600:1;
477 unsigned int res_1280x720:1;
478 unsigned int res_1360x768:1;
479 unsigned int res_1704x960:1;
480 unsigned int res_1864x1050:1;
481 unsigned int res_1920x1080:1;
482 unsigned int res_2128x1200:1;
483
484 unsigned int res_2560x1400:1;
485 unsigned int res_2728x1536:1;
486 unsigned int res_3408x1920:1;
487 unsigned int res_4264x2400:1;
488 unsigned int res_5120x2880:1;
489 unsigned int pad2:3;
490
491 unsigned int res_768x480:1;
492 unsigned int res_960x600:1;
493 unsigned int res_1152x720:1;
494 unsigned int res_1124x768:1;
495 unsigned int res_1536x960:1;
496 unsigned int res_1680x1050:1;
497 unsigned int res_1728x1080:1;
498 unsigned int res_1920x1200:1;
499
500 unsigned int res_2304x1440:1;
501 unsigned int res_2456x1536:1;
502 unsigned int res_3072x1920:1;
503 unsigned int res_3840x2400:1;
504 unsigned int res_4608x2880:1;
505 unsigned int pad3:3;
506
507 unsigned int res_1280x1024:1;
508 unsigned int pad4:7;
509
510 unsigned int res_1280x768:1;
511 unsigned int pad5:7;
512} __attribute__((packed));
513
514/* Get supported power state returns info for encoder and monitor, rely on
515 last SetTargetInput and SetTargetOutput calls */
313#define SDVO_CMD_GET_SUPPORTED_POWER_STATES 0x2a 516#define SDVO_CMD_GET_SUPPORTED_POWER_STATES 0x2a
517/* Get power state returns info for encoder and monitor, rely on last
518 SetTargetInput and SetTargetOutput calls */
519#define SDVO_CMD_GET_POWER_STATE 0x2b
314#define SDVO_CMD_GET_ENCODER_POWER_STATE 0x2b 520#define SDVO_CMD_GET_ENCODER_POWER_STATE 0x2b
315#define SDVO_CMD_SET_ENCODER_POWER_STATE 0x2c 521#define SDVO_CMD_SET_ENCODER_POWER_STATE 0x2c
316# define SDVO_ENCODER_STATE_ON (1 << 0) 522# define SDVO_ENCODER_STATE_ON (1 << 0)
317# define SDVO_ENCODER_STATE_STANDBY (1 << 1) 523# define SDVO_ENCODER_STATE_STANDBY (1 << 1)
318# define SDVO_ENCODER_STATE_SUSPEND (1 << 2) 524# define SDVO_ENCODER_STATE_SUSPEND (1 << 2)
319# define SDVO_ENCODER_STATE_OFF (1 << 3) 525# define SDVO_ENCODER_STATE_OFF (1 << 3)
526# define SDVO_MONITOR_STATE_ON (1 << 4)
527# define SDVO_MONITOR_STATE_STANDBY (1 << 5)
528# define SDVO_MONITOR_STATE_SUSPEND (1 << 6)
529# define SDVO_MONITOR_STATE_OFF (1 << 7)
530
531#define SDVO_CMD_GET_MAX_PANEL_POWER_SEQUENCING 0x2d
532#define SDVO_CMD_GET_PANEL_POWER_SEQUENCING 0x2e
533#define SDVO_CMD_SET_PANEL_POWER_SEQUENCING 0x2f
534/**
535 * The panel power sequencing parameters are in units of milliseconds.
536 * The high fields are bits 8:9 of the 10-bit values.
537 */
538struct sdvo_panel_power_sequencing {
539 u8 t0;
540 u8 t1;
541 u8 t2;
542 u8 t3;
543 u8 t4;
544
545 unsigned int t0_high:2;
546 unsigned int t1_high:2;
547 unsigned int t2_high:2;
548 unsigned int t3_high:2;
549
550 unsigned int t4_high:2;
551 unsigned int pad:6;
552} __attribute__((packed));
553
554#define SDVO_CMD_GET_MAX_BACKLIGHT_LEVEL 0x30
555struct sdvo_max_backlight_reply {
556 u8 max_value;
557 u8 default_value;
558} __attribute__((packed));
559
560#define SDVO_CMD_GET_BACKLIGHT_LEVEL 0x31
561#define SDVO_CMD_SET_BACKLIGHT_LEVEL 0x32
562
563#define SDVO_CMD_GET_AMBIENT_LIGHT 0x33
564struct sdvo_get_ambient_light_reply {
565 u16 trip_low;
566 u16 trip_high;
567 u16 value;
568} __attribute__((packed));
569#define SDVO_CMD_SET_AMBIENT_LIGHT 0x34
570struct sdvo_set_ambient_light_reply {
571 u16 trip_low;
572 u16 trip_high;
573 unsigned int enable:1;
574 unsigned int pad:7;
575} __attribute__((packed));
576
577/* Set display power state */
578#define SDVO_CMD_SET_DISPLAY_POWER_STATE 0x7d
579# define SDVO_DISPLAY_STATE_ON (1 << 0)
580# define SDVO_DISPLAY_STATE_STANDBY (1 << 1)
581# define SDVO_DISPLAY_STATE_SUSPEND (1 << 2)
582# define SDVO_DISPLAY_STATE_OFF (1 << 3)
583
584#define SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS 0x84
585struct intel_sdvo_enhancements_reply {
586 unsigned int flicker_filter:1;
587 unsigned int flicker_filter_adaptive:1;
588 unsigned int flicker_filter_2d:1;
589 unsigned int saturation:1;
590 unsigned int hue:1;
591 unsigned int brightness:1;
592 unsigned int contrast:1;
593 unsigned int overscan_h:1;
594
595 unsigned int overscan_v:1;
596 unsigned int position_h:1;
597 unsigned int position_v:1;
598 unsigned int sharpness:1;
599 unsigned int dot_crawl:1;
600 unsigned int dither:1;
601 unsigned int max_tv_chroma_filter:1;
602 unsigned int max_tv_luma_filter:1;
603} __attribute__((packed));
604
605/* Picture enhancement limits below are dependent on the current TV format,
606 * and thus need to be queried and set after it.
607 */
608#define SDVO_CMD_GET_MAX_FLICKER_FITER 0x4d
609#define SDVO_CMD_GET_MAX_ADAPTIVE_FLICKER_FITER 0x7b
610#define SDVO_CMD_GET_MAX_2D_FLICKER_FITER 0x52
611#define SDVO_CMD_GET_MAX_SATURATION 0x55
612#define SDVO_CMD_GET_MAX_HUE 0x58
613#define SDVO_CMD_GET_MAX_BRIGHTNESS 0x5b
614#define SDVO_CMD_GET_MAX_CONTRAST 0x5e
615#define SDVO_CMD_GET_MAX_OVERSCAN_H 0x61
616#define SDVO_CMD_GET_MAX_OVERSCAN_V 0x64
617#define SDVO_CMD_GET_MAX_POSITION_H 0x67
618#define SDVO_CMD_GET_MAX_POSITION_V 0x6a
619#define SDVO_CMD_GET_MAX_SHARPNESS_V 0x6d
620#define SDVO_CMD_GET_MAX_TV_CHROMA 0x74
621#define SDVO_CMD_GET_MAX_TV_LUMA 0x77
622struct intel_sdvo_enhancement_limits_reply {
623 u16 max_value;
624 u16 default_value;
625} __attribute__((packed));
320 626
321#define SDVO_CMD_SET_TV_RESOLUTION_SUPPORT 0x93 627#define SDVO_CMD_GET_LVDS_PANEL_INFORMATION 0x7f
628#define SDVO_CMD_SET_LVDS_PANEL_INFORMATION 0x80
629# define SDVO_LVDS_COLOR_DEPTH_18 (0 << 0)
630# define SDVO_LVDS_COLOR_DEPTH_24 (1 << 0)
631# define SDVO_LVDS_CONNECTOR_SPWG (0 << 2)
632# define SDVO_LVDS_CONNECTOR_OPENLDI (1 << 2)
633# define SDVO_LVDS_SINGLE_CHANNEL (0 << 4)
634# define SDVO_LVDS_DUAL_CHANNEL (1 << 4)
635
636#define SDVO_CMD_GET_FLICKER_FILTER 0x4e
637#define SDVO_CMD_SET_FLICKER_FILTER 0x4f
638#define SDVO_CMD_GET_ADAPTIVE_FLICKER_FITER 0x50
639#define SDVO_CMD_SET_ADAPTIVE_FLICKER_FITER 0x51
640#define SDVO_CMD_GET_2D_FLICKER_FITER 0x53
641#define SDVO_CMD_SET_2D_FLICKER_FITER 0x54
642#define SDVO_CMD_GET_SATURATION 0x56
643#define SDVO_CMD_SET_SATURATION 0x57
644#define SDVO_CMD_GET_HUE 0x59
645#define SDVO_CMD_SET_HUE 0x5a
646#define SDVO_CMD_GET_BRIGHTNESS 0x5c
647#define SDVO_CMD_SET_BRIGHTNESS 0x5d
648#define SDVO_CMD_GET_CONTRAST 0x5f
649#define SDVO_CMD_SET_CONTRAST 0x60
650#define SDVO_CMD_GET_OVERSCAN_H 0x62
651#define SDVO_CMD_SET_OVERSCAN_H 0x63
652#define SDVO_CMD_GET_OVERSCAN_V 0x65
653#define SDVO_CMD_SET_OVERSCAN_V 0x66
654#define SDVO_CMD_GET_POSITION_H 0x68
655#define SDVO_CMD_SET_POSITION_H 0x69
656#define SDVO_CMD_GET_POSITION_V 0x6b
657#define SDVO_CMD_SET_POSITION_V 0x6c
658#define SDVO_CMD_GET_SHARPNESS 0x6e
659#define SDVO_CMD_SET_SHARPNESS 0x6f
660#define SDVO_CMD_GET_TV_CHROMA 0x75
661#define SDVO_CMD_SET_TV_CHROMA 0x76
662#define SDVO_CMD_GET_TV_LUMA 0x78
663#define SDVO_CMD_SET_TV_LUMA 0x79
664struct intel_sdvo_enhancements_arg {
665 u16 value;
666}__attribute__((packed));
667
668#define SDVO_CMD_GET_DOT_CRAWL 0x70
669#define SDVO_CMD_SET_DOT_CRAWL 0x71
670# define SDVO_DOT_CRAWL_ON (1 << 0)
671# define SDVO_DOT_CRAWL_DEFAULT_ON (1 << 1)
672
673#define SDVO_CMD_GET_DITHER 0x72
674#define SDVO_CMD_SET_DITHER 0x73
675# define SDVO_DITHER_ON (1 << 0)
676# define SDVO_DITHER_DEFAULT_ON (1 << 1)
322 677
323#define SDVO_CMD_SET_CONTROL_BUS_SWITCH 0x7a 678#define SDVO_CMD_SET_CONTROL_BUS_SWITCH 0x7a
324# define SDVO_CONTROL_BUS_PROM 0x0 679# define SDVO_CONTROL_BUS_PROM (1 << 0)
325# define SDVO_CONTROL_BUS_DDC1 0x1 680# define SDVO_CONTROL_BUS_DDC1 (1 << 1)
326# define SDVO_CONTROL_BUS_DDC2 0x2 681# define SDVO_CONTROL_BUS_DDC2 (1 << 2)
327# define SDVO_CONTROL_BUS_DDC3 0x3 682# define SDVO_CONTROL_BUS_DDC3 (1 << 3)
683
684/* HDMI op codes */
685#define SDVO_CMD_GET_SUPP_ENCODE 0x9d
686#define SDVO_CMD_GET_ENCODE 0x9e
687#define SDVO_CMD_SET_ENCODE 0x9f
688 #define SDVO_ENCODE_DVI 0x0
689 #define SDVO_ENCODE_HDMI 0x1
690#define SDVO_CMD_SET_PIXEL_REPLI 0x8b
691#define SDVO_CMD_GET_PIXEL_REPLI 0x8c
692#define SDVO_CMD_GET_COLORIMETRY_CAP 0x8d
693#define SDVO_CMD_SET_COLORIMETRY 0x8e
694 #define SDVO_COLORIMETRY_RGB256 0x0
695 #define SDVO_COLORIMETRY_RGB220 0x1
696 #define SDVO_COLORIMETRY_YCrCb422 0x3
697 #define SDVO_COLORIMETRY_YCrCb444 0x4
698#define SDVO_CMD_GET_COLORIMETRY 0x8f
699#define SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER 0x90
700#define SDVO_CMD_SET_AUDIO_STAT 0x91
701#define SDVO_CMD_GET_AUDIO_STAT 0x92
702#define SDVO_CMD_SET_HBUF_INDEX 0x93
703#define SDVO_CMD_GET_HBUF_INDEX 0x94
704#define SDVO_CMD_GET_HBUF_INFO 0x95
705#define SDVO_CMD_SET_HBUF_AV_SPLIT 0x96
706#define SDVO_CMD_GET_HBUF_AV_SPLIT 0x97
707#define SDVO_CMD_SET_HBUF_DATA 0x98
708#define SDVO_CMD_GET_HBUF_DATA 0x99
709#define SDVO_CMD_SET_HBUF_TXRATE 0x9a
710#define SDVO_CMD_GET_HBUF_TXRATE 0x9b
711 #define SDVO_HBUF_TX_DISABLED (0 << 6)
712 #define SDVO_HBUF_TX_ONCE (2 << 6)
713 #define SDVO_HBUF_TX_VSYNC (3 << 6)
714#define SDVO_CMD_GET_AUDIO_TX_INFO 0x9c
715
716struct intel_sdvo_encode{
717 u8 dvi_rev;
718 u8 hdmi_rev;
719} __attribute__ ((packed));
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index fbb35dc56f5c..56485d67369b 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -411,7 +411,7 @@ struct tv_mode {
411 * These values account for -1s required. 411 * These values account for -1s required.
412 */ 412 */
413 413
414const static struct tv_mode tv_modes[] = { 414static const struct tv_mode tv_modes[] = {
415 { 415 {
416 .name = "NTSC-M", 416 .name = "NTSC-M",
417 .clock = 107520, 417 .clock = 107520,
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 63212d7bbc28..92965dbb3c14 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -557,8 +557,10 @@ static int radeon_do_engine_reset(struct drm_device * dev)
557} 557}
558 558
559static void radeon_cp_init_ring_buffer(struct drm_device * dev, 559static void radeon_cp_init_ring_buffer(struct drm_device * dev,
560 drm_radeon_private_t * dev_priv) 560 drm_radeon_private_t *dev_priv,
561 struct drm_file *file_priv)
561{ 562{
563 struct drm_radeon_master_private *master_priv;
562 u32 ring_start, cur_read_ptr; 564 u32 ring_start, cur_read_ptr;
563 u32 tmp; 565 u32 tmp;
564 566
@@ -677,6 +679,14 @@ static void radeon_cp_init_ring_buffer(struct drm_device * dev,
677 dev_priv->scratch[2] = 0; 679 dev_priv->scratch[2] = 0;
678 RADEON_WRITE(RADEON_LAST_CLEAR_REG, 0); 680 RADEON_WRITE(RADEON_LAST_CLEAR_REG, 0);
679 681
682 /* reset sarea copies of these */
683 master_priv = file_priv->master->driver_priv;
684 if (master_priv->sarea_priv) {
685 master_priv->sarea_priv->last_frame = 0;
686 master_priv->sarea_priv->last_dispatch = 0;
687 master_priv->sarea_priv->last_clear = 0;
688 }
689
680 radeon_do_wait_for_idle(dev_priv); 690 radeon_do_wait_for_idle(dev_priv);
681 691
682 /* Sync everything up */ 692 /* Sync everything up */
@@ -1039,9 +1049,9 @@ static int radeon_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
1039 1049
1040#if __OS_HAS_AGP 1050#if __OS_HAS_AGP
1041 if (dev_priv->flags & RADEON_IS_AGP) { 1051 if (dev_priv->flags & RADEON_IS_AGP) {
1042 drm_core_ioremap(dev_priv->cp_ring, dev); 1052 drm_core_ioremap_wc(dev_priv->cp_ring, dev);
1043 drm_core_ioremap(dev_priv->ring_rptr, dev); 1053 drm_core_ioremap_wc(dev_priv->ring_rptr, dev);
1044 drm_core_ioremap(dev->agp_buffer_map, dev); 1054 drm_core_ioremap_wc(dev->agp_buffer_map, dev);
1045 if (!dev_priv->cp_ring->handle || 1055 if (!dev_priv->cp_ring->handle ||
1046 !dev_priv->ring_rptr->handle || 1056 !dev_priv->ring_rptr->handle ||
1047 !dev->agp_buffer_map->handle) { 1057 !dev->agp_buffer_map->handle) {
@@ -1215,7 +1225,7 @@ static int radeon_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
1215 } 1225 }
1216 1226
1217 radeon_cp_load_microcode(dev_priv); 1227 radeon_cp_load_microcode(dev_priv);
1218 radeon_cp_init_ring_buffer(dev, dev_priv); 1228 radeon_cp_init_ring_buffer(dev, dev_priv, file_priv);
1219 1229
1220 dev_priv->last_buf = 0; 1230 dev_priv->last_buf = 0;
1221 1231
@@ -1281,7 +1291,7 @@ static int radeon_do_cleanup_cp(struct drm_device * dev)
1281 * 1291 *
1282 * Charl P. Botha <http://cpbotha.net> 1292 * Charl P. Botha <http://cpbotha.net>
1283 */ 1293 */
1284static int radeon_do_resume_cp(struct drm_device * dev) 1294static int radeon_do_resume_cp(struct drm_device *dev, struct drm_file *file_priv)
1285{ 1295{
1286 drm_radeon_private_t *dev_priv = dev->dev_private; 1296 drm_radeon_private_t *dev_priv = dev->dev_private;
1287 1297
@@ -1304,7 +1314,7 @@ static int radeon_do_resume_cp(struct drm_device * dev)
1304 } 1314 }
1305 1315
1306 radeon_cp_load_microcode(dev_priv); 1316 radeon_cp_load_microcode(dev_priv);
1307 radeon_cp_init_ring_buffer(dev, dev_priv); 1317 radeon_cp_init_ring_buffer(dev, dev_priv, file_priv);
1308 1318
1309 radeon_do_engine_reset(dev); 1319 radeon_do_engine_reset(dev);
1310 radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1); 1320 radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1);
@@ -1479,8 +1489,7 @@ int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_pri
1479 */ 1489 */
1480int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv) 1490int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv)
1481{ 1491{
1482 1492 return radeon_do_resume_cp(dev, file_priv);
1483 return radeon_do_resume_cp(dev);
1484} 1493}
1485 1494
1486int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv) 1495int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 6cad69ed21c5..1cc967448f4d 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1300,7 +1300,13 @@ static const struct hid_device_id hid_blacklist[] = {
1300 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1300 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1301 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1301 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
1302 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1302 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
1303 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
1304 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
1305 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
1306 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
1303 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, 1307 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
1308 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
1309 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
1304 1310
1305 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) }, 1311 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) },
1306 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 1312 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
@@ -1605,6 +1611,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1605 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, 1611 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
1606 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, 1612 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
1607 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, 1613 { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
1614 { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
1608 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, 1615 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) },
1609 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) }, 1616 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD2) },
1610 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) }, 1617 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD3) },
@@ -1612,10 +1619,6 @@ static const struct hid_device_id hid_ignore_list[] = {
1612 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD5) }, 1619 { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD5) },
1613 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) }, 1620 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY1) },
1614 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) }, 1621 { HID_USB_DEVICE(USB_VENDOR_ID_TENX, USB_DEVICE_ID_TENX_IBUDDY2) },
1615 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
1616 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
1617 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) },
1618 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) },
1619 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, 1622 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
1620 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 1623 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
1621 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 1624 { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
@@ -1626,8 +1629,6 @@ static const struct hid_device_id hid_ignore_list[] = {
1626 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, 1629 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
1627 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, 1630 { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
1628 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, 1631 { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
1629 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
1630 { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
1631 { } 1632 { }
1632}; 1633};
1633 1634
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index e899f510ebeb..88511970508d 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -348,6 +348,9 @@
348#define USB_VENDOR_ID_PLAYDOTCOM 0x0b43 348#define USB_VENDOR_ID_PLAYDOTCOM 0x0b43
349#define USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII 0x0003 349#define USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII 0x0003
350 350
351#define USB_VENDOR_ID_POWERCOM 0x0d9f
352#define USB_DEVICE_ID_POWERCOM_UPS 0x0002
353
351#define USB_VENDOR_ID_SAITEK 0x06a3 354#define USB_VENDOR_ID_SAITEK 0x06a3
352#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 355#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
353 356
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 732449628971..02b19db5442e 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -267,8 +267,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
267 default: 267 default:
268 { 268 {
269 struct hid_device *hid = dev->hid; 269 struct hid_device *hid = dev->hid;
270 if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) 270 if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) {
271 return -EINVAL; 271 ret = -EINVAL;
272 break;
273 }
272 274
273 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) { 275 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) {
274 int len; 276 int len;
@@ -277,8 +279,9 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
277 len = strlen(hid->name) + 1; 279 len = strlen(hid->name) + 1;
278 if (len > _IOC_SIZE(cmd)) 280 if (len > _IOC_SIZE(cmd))
279 len = _IOC_SIZE(cmd); 281 len = _IOC_SIZE(cmd);
280 return copy_to_user(user_arg, hid->name, len) ? 282 ret = copy_to_user(user_arg, hid->name, len) ?
281 -EFAULT : len; 283 -EFAULT : len;
284 break;
282 } 285 }
283 286
284 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) { 287 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) {
@@ -288,12 +291,13 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
288 len = strlen(hid->phys) + 1; 291 len = strlen(hid->phys) + 1;
289 if (len > _IOC_SIZE(cmd)) 292 if (len > _IOC_SIZE(cmd))
290 len = _IOC_SIZE(cmd); 293 len = _IOC_SIZE(cmd);
291 return copy_to_user(user_arg, hid->phys, len) ? 294 ret = copy_to_user(user_arg, hid->phys, len) ?
292 -EFAULT : len; 295 -EFAULT : len;
296 break;
293 } 297 }
294 } 298 }
295 299
296 ret = -ENOTTY; 300 ret = -ENOTTY;
297 } 301 }
298 unlock_kernel(); 302 unlock_kernel();
299 return ret; 303 return ret;
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 609cafff86bc..5f81ddf71508 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -1872,7 +1872,7 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address,
1872 1872
1873 devid = superio_inw(sioaddr, SIO_REG_MANID); 1873 devid = superio_inw(sioaddr, SIO_REG_MANID);
1874 if (devid != SIO_FINTEK_ID) { 1874 if (devid != SIO_FINTEK_ID) {
1875 printk(KERN_INFO DRVNAME ": Not a Fintek device\n"); 1875 pr_debug(DRVNAME ": Not a Fintek device\n");
1876 goto exit; 1876 goto exit;
1877 } 1877 }
1878 1878
@@ -1932,7 +1932,7 @@ static int __init f71882fg_device_add(unsigned short address,
1932 res.name = f71882fg_pdev->name; 1932 res.name = f71882fg_pdev->name;
1933 err = acpi_check_resource_conflict(&res); 1933 err = acpi_check_resource_conflict(&res);
1934 if (err) 1934 if (err)
1935 return err; 1935 goto exit_device_put;
1936 1936
1937 err = platform_device_add_resources(f71882fg_pdev, &res, 1); 1937 err = platform_device_add_resources(f71882fg_pdev, &res, 1);
1938 if (err) { 1938 if (err) {
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
index 03705240000f..29c83b5b9697 100644
--- a/drivers/hwmon/hp_accel.c
+++ b/drivers/hwmon/hp_accel.c
@@ -153,7 +153,10 @@ static struct axis_conversion lis3lv02d_axis_y_inverted = {1, -2, 3};
153static struct axis_conversion lis3lv02d_axis_x_inverted = {-1, 2, 3}; 153static struct axis_conversion lis3lv02d_axis_x_inverted = {-1, 2, 3};
154static struct axis_conversion lis3lv02d_axis_z_inverted = {1, 2, -3}; 154static struct axis_conversion lis3lv02d_axis_z_inverted = {1, 2, -3};
155static struct axis_conversion lis3lv02d_axis_xy_rotated_left = {-2, 1, 3}; 155static struct axis_conversion lis3lv02d_axis_xy_rotated_left = {-2, 1, 3};
156static struct axis_conversion lis3lv02d_axis_xy_rotated_left_usd = {-2, 1, -3};
156static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3}; 157static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3};
158static struct axis_conversion lis3lv02d_axis_xy_rotated_right = {2, -1, 3};
159static struct axis_conversion lis3lv02d_axis_xy_swap_yz_inverted = {2, -1, -3};
157 160
158#define AXIS_DMI_MATCH(_ident, _name, _axis) { \ 161#define AXIS_DMI_MATCH(_ident, _name, _axis) { \
159 .ident = _ident, \ 162 .ident = _ident, \
@@ -163,6 +166,18 @@ static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3};
163 }, \ 166 }, \
164 .driver_data = &lis3lv02d_axis_##_axis \ 167 .driver_data = &lis3lv02d_axis_##_axis \
165} 168}
169
170#define AXIS_DMI_MATCH2(_ident, _class1, _name1, \
171 _class2, _name2, \
172 _axis) { \
173 .ident = _ident, \
174 .callback = lis3lv02d_dmi_matched, \
175 .matches = { \
176 DMI_MATCH(DMI_##_class1, _name1), \
177 DMI_MATCH(DMI_##_class2, _name2), \
178 }, \
179 .driver_data = &lis3lv02d_axis_##_axis \
180}
166static struct dmi_system_id lis3lv02d_dmi_ids[] = { 181static struct dmi_system_id lis3lv02d_dmi_ids[] = {
167 /* product names are truncated to match all kinds of a same model */ 182 /* product names are truncated to match all kinds of a same model */
168 AXIS_DMI_MATCH("NC64x0", "HP Compaq nc64", x_inverted), 183 AXIS_DMI_MATCH("NC64x0", "HP Compaq nc64", x_inverted),
@@ -172,10 +187,22 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
172 AXIS_DMI_MATCH("NC2510", "HP Compaq 2510", y_inverted), 187 AXIS_DMI_MATCH("NC2510", "HP Compaq 2510", y_inverted),
173 AXIS_DMI_MATCH("NC8510", "HP Compaq 8510", xy_swap_inverted), 188 AXIS_DMI_MATCH("NC8510", "HP Compaq 8510", xy_swap_inverted),
174 AXIS_DMI_MATCH("HP2133", "HP 2133", xy_rotated_left), 189 AXIS_DMI_MATCH("HP2133", "HP 2133", xy_rotated_left),
190 AXIS_DMI_MATCH("NC653x", "HP Compaq 653", xy_rotated_left_usd),
191 AXIS_DMI_MATCH("NC673x", "HP Compaq 673", xy_rotated_left_usd),
192 AXIS_DMI_MATCH("NC651xx", "HP Compaq 651", xy_rotated_right),
193 AXIS_DMI_MATCH("NC671xx", "HP Compaq 671", xy_swap_yz_inverted),
194 /* Intel-based HP Pavilion dv5 */
195 AXIS_DMI_MATCH2("HPDV5_I",
196 PRODUCT_NAME, "HP Pavilion dv5",
197 BOARD_NAME, "3603",
198 x_inverted),
199 /* AMD-based HP Pavilion dv5 */
200 AXIS_DMI_MATCH2("HPDV5_A",
201 PRODUCT_NAME, "HP Pavilion dv5",
202 BOARD_NAME, "3600",
203 y_inverted),
175 { NULL, } 204 { NULL, }
176/* Laptop models without axis info (yet): 205/* Laptop models without axis info (yet):
177 * "NC651xx" "HP Compaq 651"
178 * "NC671xx" "HP Compaq 671"
179 * "NC6910" "HP Compaq 6910" 206 * "NC6910" "HP Compaq 6910"
180 * HP Compaq 8710x Notebook PC / Mobile Workstation 207 * HP Compaq 8710x Notebook PC / Mobile Workstation
181 * "NC2400" "HP Compaq nc2400" 208 * "NC2400" "HP Compaq nc2400"
@@ -208,9 +235,49 @@ static struct delayed_led_classdev hpled_led = {
208 .set_brightness = hpled_set, 235 .set_brightness = hpled_set,
209}; 236};
210 237
238static acpi_status
239lis3lv02d_get_resource(struct acpi_resource *resource, void *context)
240{
241 if (resource->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) {
242 struct acpi_resource_extended_irq *irq;
243 u32 *device_irq = context;
244
245 irq = &resource->data.extended_irq;
246 *device_irq = irq->interrupts[0];
247 }
248
249 return AE_OK;
250}
251
252static void lis3lv02d_enum_resources(struct acpi_device *device)
253{
254 acpi_status status;
255
256 status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
257 lis3lv02d_get_resource, &adev.irq);
258 if (ACPI_FAILURE(status))
259 printk(KERN_DEBUG DRIVER_NAME ": Error getting resources\n");
260}
261
262static s16 lis3lv02d_read_16(acpi_handle handle, int reg)
263{
264 u8 lo, hi;
265
266 adev.read(handle, reg - 1, &lo);
267 adev.read(handle, reg, &hi);
268 /* In "12 bit right justified" mode, bit 6, bit 7, bit 8 = bit 5 */
269 return (s16)((hi << 8) | lo);
270}
271
272static s16 lis3lv02d_read_8(acpi_handle handle, int reg)
273{
274 s8 lo;
275 adev.read(handle, reg, &lo);
276 return lo;
277}
278
211static int lis3lv02d_add(struct acpi_device *device) 279static int lis3lv02d_add(struct acpi_device *device)
212{ 280{
213 u8 val;
214 int ret; 281 int ret;
215 282
216 if (!device) 283 if (!device)
@@ -224,10 +291,22 @@ static int lis3lv02d_add(struct acpi_device *device)
224 strcpy(acpi_device_class(device), ACPI_MDPS_CLASS); 291 strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
225 device->driver_data = &adev; 292 device->driver_data = &adev;
226 293
227 lis3lv02d_acpi_read(device->handle, WHO_AM_I, &val); 294 lis3lv02d_acpi_read(device->handle, WHO_AM_I, &adev.whoami);
228 if ((val != LIS3LV02DL_ID) && (val != LIS302DL_ID)) { 295 switch (adev.whoami) {
296 case LIS_DOUBLE_ID:
297 printk(KERN_INFO DRIVER_NAME ": 2-byte sensor found\n");
298 adev.read_data = lis3lv02d_read_16;
299 adev.mdps_max_val = 2048;
300 break;
301 case LIS_SINGLE_ID:
302 printk(KERN_INFO DRIVER_NAME ": 1-byte sensor found\n");
303 adev.read_data = lis3lv02d_read_8;
304 adev.mdps_max_val = 128;
305 break;
306 default:
229 printk(KERN_ERR DRIVER_NAME 307 printk(KERN_ERR DRIVER_NAME
230 ": Accelerometer chip not LIS3LV02D{L,Q}\n"); 308 ": unknown sensor type 0x%X\n", adev.whoami);
309 return -EINVAL;
231 } 310 }
232 311
233 /* If possible use a "standard" axes order */ 312 /* If possible use a "standard" axes order */
@@ -242,6 +321,9 @@ static int lis3lv02d_add(struct acpi_device *device)
242 if (ret) 321 if (ret)
243 return ret; 322 return ret;
244 323
324 /* obtain IRQ number of our device from ACPI */
325 lis3lv02d_enum_resources(adev.device);
326
245 ret = lis3lv02d_init_device(&adev); 327 ret = lis3lv02d_init_device(&adev);
246 if (ret) { 328 if (ret) {
247 flush_work(&hpled_led.work); 329 flush_work(&hpled_led.work);
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index 219d2d0d5a62..8bb2158f0453 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2007-2008 Yan Burman 4 * Copyright (C) 2007-2008 Yan Burman
5 * Copyright (C) 2008 Eric Piel 5 * Copyright (C) 2008 Eric Piel
6 * Copyright (C) 2008 Pavel Machek 6 * Copyright (C) 2008-2009 Pavel Machek
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -35,6 +35,7 @@
35#include <linux/poll.h> 35#include <linux/poll.h>
36#include <linux/freezer.h> 36#include <linux/freezer.h>
37#include <linux/uaccess.h> 37#include <linux/uaccess.h>
38#include <linux/miscdevice.h>
38#include <acpi/acpi_drivers.h> 39#include <acpi/acpi_drivers.h>
39#include <asm/atomic.h> 40#include <asm/atomic.h>
40#include "lis3lv02d.h" 41#include "lis3lv02d.h"
@@ -52,24 +53,14 @@
52 * joystick. 53 * joystick.
53 */ 54 */
54 55
55/* Maximum value our axis may get for the input device (signed 12 bits) */ 56struct acpi_lis3lv02d adev = {
56#define MDPS_MAX_VAL 2048 57 .misc_wait = __WAIT_QUEUE_HEAD_INITIALIZER(adev.misc_wait),
58};
57 59
58struct acpi_lis3lv02d adev;
59EXPORT_SYMBOL_GPL(adev); 60EXPORT_SYMBOL_GPL(adev);
60 61
61static int lis3lv02d_add_fs(struct acpi_device *device); 62static int lis3lv02d_add_fs(struct acpi_device *device);
62 63
63static s16 lis3lv02d_read_16(acpi_handle handle, int reg)
64{
65 u8 lo, hi;
66
67 adev.read(handle, reg, &lo);
68 adev.read(handle, reg + 1, &hi);
69 /* In "12 bit right justified" mode, bit 6, bit 7, bit 8 = bit 5 */
70 return (s16)((hi << 8) | lo);
71}
72
73/** 64/**
74 * lis3lv02d_get_axis - For the given axis, give the value converted 65 * lis3lv02d_get_axis - For the given axis, give the value converted
75 * @axis: 1,2,3 - can also be negative 66 * @axis: 1,2,3 - can also be negative
@@ -98,9 +89,9 @@ static void lis3lv02d_get_xyz(acpi_handle handle, int *x, int *y, int *z)
98{ 89{
99 int position[3]; 90 int position[3];
100 91
101 position[0] = lis3lv02d_read_16(handle, OUTX_L); 92 position[0] = adev.read_data(handle, OUTX);
102 position[1] = lis3lv02d_read_16(handle, OUTY_L); 93 position[1] = adev.read_data(handle, OUTY);
103 position[2] = lis3lv02d_read_16(handle, OUTZ_L); 94 position[2] = adev.read_data(handle, OUTZ);
104 95
105 *x = lis3lv02d_get_axis(adev.ac.x, position); 96 *x = lis3lv02d_get_axis(adev.ac.x, position);
106 *y = lis3lv02d_get_axis(adev.ac.y, position); 97 *y = lis3lv02d_get_axis(adev.ac.y, position);
@@ -110,26 +101,13 @@ static void lis3lv02d_get_xyz(acpi_handle handle, int *x, int *y, int *z)
110void lis3lv02d_poweroff(acpi_handle handle) 101void lis3lv02d_poweroff(acpi_handle handle)
111{ 102{
112 adev.is_on = 0; 103 adev.is_on = 0;
113 /* disable X,Y,Z axis and power down */
114 adev.write(handle, CTRL_REG1, 0x00);
115} 104}
116EXPORT_SYMBOL_GPL(lis3lv02d_poweroff); 105EXPORT_SYMBOL_GPL(lis3lv02d_poweroff);
117 106
118void lis3lv02d_poweron(acpi_handle handle) 107void lis3lv02d_poweron(acpi_handle handle)
119{ 108{
120 u8 val;
121
122 adev.is_on = 1; 109 adev.is_on = 1;
123 adev.init(handle); 110 adev.init(handle);
124 adev.write(handle, FF_WU_CFG, 0);
125 /*
126 * BDU: LSB and MSB values are not updated until both have been read.
127 * So the value read will always be correct.
128 * IEN: Interrupt for free-fall and DD, not for data-ready.
129 */
130 adev.read(handle, CTRL_REG2, &val);
131 val |= CTRL2_BDU | CTRL2_IEN;
132 adev.write(handle, CTRL_REG2, val);
133} 111}
134EXPORT_SYMBOL_GPL(lis3lv02d_poweron); 112EXPORT_SYMBOL_GPL(lis3lv02d_poweron);
135 113
@@ -162,6 +140,140 @@ static void lis3lv02d_decrease_use(struct acpi_lis3lv02d *dev)
162 mutex_unlock(&dev->lock); 140 mutex_unlock(&dev->lock);
163} 141}
164 142
143static irqreturn_t lis302dl_interrupt(int irq, void *dummy)
144{
145 /*
146 * Be careful: on some HP laptops the bios force DD when on battery and
147 * the lid is closed. This leads to interrupts as soon as a little move
148 * is done.
149 */
150 atomic_inc(&adev.count);
151
152 wake_up_interruptible(&adev.misc_wait);
153 kill_fasync(&adev.async_queue, SIGIO, POLL_IN);
154 return IRQ_HANDLED;
155}
156
157static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
158{
159 int ret;
160
161 if (test_and_set_bit(0, &adev.misc_opened))
162 return -EBUSY; /* already open */
163
164 atomic_set(&adev.count, 0);
165
166 /*
167 * The sensor can generate interrupts for free-fall and direction
168 * detection (distinguishable with FF_WU_SRC and DD_SRC) but to keep
169 * the things simple and _fast_ we activate it only for free-fall, so
170 * no need to read register (very slow with ACPI). For the same reason,
171 * we forbid shared interrupts.
172 *
173 * IRQF_TRIGGER_RISING seems pointless on HP laptops because the
174 * io-apic is not configurable (and generates a warning) but I keep it
175 * in case of support for other hardware.
176 */
177 ret = request_irq(adev.irq, lis302dl_interrupt, IRQF_TRIGGER_RISING,
178 DRIVER_NAME, &adev);
179
180 if (ret) {
181 clear_bit(0, &adev.misc_opened);
182 printk(KERN_ERR DRIVER_NAME ": IRQ%d allocation failed\n", adev.irq);
183 return -EBUSY;
184 }
185 lis3lv02d_increase_use(&adev);
186 printk("lis3: registered interrupt %d\n", adev.irq);
187 return 0;
188}
189
190static int lis3lv02d_misc_release(struct inode *inode, struct file *file)
191{
192 fasync_helper(-1, file, 0, &adev.async_queue);
193 lis3lv02d_decrease_use(&adev);
194 free_irq(adev.irq, &adev);
195 clear_bit(0, &adev.misc_opened); /* release the device */
196 return 0;
197}
198
199static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
200 size_t count, loff_t *pos)
201{
202 DECLARE_WAITQUEUE(wait, current);
203 u32 data;
204 unsigned char byte_data;
205 ssize_t retval = 1;
206
207 if (count < 1)
208 return -EINVAL;
209
210 add_wait_queue(&adev.misc_wait, &wait);
211 while (true) {
212 set_current_state(TASK_INTERRUPTIBLE);
213 data = atomic_xchg(&adev.count, 0);
214 if (data)
215 break;
216
217 if (file->f_flags & O_NONBLOCK) {
218 retval = -EAGAIN;
219 goto out;
220 }
221
222 if (signal_pending(current)) {
223 retval = -ERESTARTSYS;
224 goto out;
225 }
226
227 schedule();
228 }
229
230 if (data < 255)
231 byte_data = data;
232 else
233 byte_data = 255;
234
235 /* make sure we are not going into copy_to_user() with
236 * TASK_INTERRUPTIBLE state */
237 set_current_state(TASK_RUNNING);
238 if (copy_to_user(buf, &byte_data, sizeof(byte_data)))
239 retval = -EFAULT;
240
241out:
242 __set_current_state(TASK_RUNNING);
243 remove_wait_queue(&adev.misc_wait, &wait);
244
245 return retval;
246}
247
248static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
249{
250 poll_wait(file, &adev.misc_wait, wait);
251 if (atomic_read(&adev.count))
252 return POLLIN | POLLRDNORM;
253 return 0;
254}
255
256static int lis3lv02d_misc_fasync(int fd, struct file *file, int on)
257{
258 return fasync_helper(fd, file, on, &adev.async_queue);
259}
260
261static const struct file_operations lis3lv02d_misc_fops = {
262 .owner = THIS_MODULE,
263 .llseek = no_llseek,
264 .read = lis3lv02d_misc_read,
265 .open = lis3lv02d_misc_open,
266 .release = lis3lv02d_misc_release,
267 .poll = lis3lv02d_misc_poll,
268 .fasync = lis3lv02d_misc_fasync,
269};
270
271static struct miscdevice lis3lv02d_misc_device = {
272 .minor = MISC_DYNAMIC_MINOR,
273 .name = "freefall",
274 .fops = &lis3lv02d_misc_fops,
275};
276
165/** 277/**
166 * lis3lv02d_joystick_kthread - Kthread polling function 278 * lis3lv02d_joystick_kthread - Kthread polling function
167 * @data: unused - here to conform to threadfn prototype 279 * @data: unused - here to conform to threadfn prototype
@@ -203,7 +315,6 @@ static void lis3lv02d_joystick_close(struct input_dev *input)
203 lis3lv02d_decrease_use(&adev); 315 lis3lv02d_decrease_use(&adev);
204} 316}
205 317
206
207static inline void lis3lv02d_calibrate_joystick(void) 318static inline void lis3lv02d_calibrate_joystick(void)
208{ 319{
209 lis3lv02d_get_xyz(adev.device->handle, &adev.xcalib, &adev.ycalib, &adev.zcalib); 320 lis3lv02d_get_xyz(adev.device->handle, &adev.xcalib, &adev.ycalib, &adev.zcalib);
@@ -231,9 +342,9 @@ int lis3lv02d_joystick_enable(void)
231 adev.idev->close = lis3lv02d_joystick_close; 342 adev.idev->close = lis3lv02d_joystick_close;
232 343
233 set_bit(EV_ABS, adev.idev->evbit); 344 set_bit(EV_ABS, adev.idev->evbit);
234 input_set_abs_params(adev.idev, ABS_X, -MDPS_MAX_VAL, MDPS_MAX_VAL, 3, 3); 345 input_set_abs_params(adev.idev, ABS_X, -adev.mdps_max_val, adev.mdps_max_val, 3, 3);
235 input_set_abs_params(adev.idev, ABS_Y, -MDPS_MAX_VAL, MDPS_MAX_VAL, 3, 3); 346 input_set_abs_params(adev.idev, ABS_Y, -adev.mdps_max_val, adev.mdps_max_val, 3, 3);
236 input_set_abs_params(adev.idev, ABS_Z, -MDPS_MAX_VAL, MDPS_MAX_VAL, 3, 3); 347 input_set_abs_params(adev.idev, ABS_Z, -adev.mdps_max_val, adev.mdps_max_val, 3, 3);
237 348
238 err = input_register_device(adev.idev); 349 err = input_register_device(adev.idev);
239 if (err) { 350 if (err) {
@@ -250,6 +361,7 @@ void lis3lv02d_joystick_disable(void)
250 if (!adev.idev) 361 if (!adev.idev)
251 return; 362 return;
252 363
364 misc_deregister(&lis3lv02d_misc_device);
253 input_unregister_device(adev.idev); 365 input_unregister_device(adev.idev);
254 adev.idev = NULL; 366 adev.idev = NULL;
255} 367}
@@ -268,6 +380,19 @@ int lis3lv02d_init_device(struct acpi_lis3lv02d *dev)
268 if (lis3lv02d_joystick_enable()) 380 if (lis3lv02d_joystick_enable())
269 printk(KERN_ERR DRIVER_NAME ": joystick initialization failed\n"); 381 printk(KERN_ERR DRIVER_NAME ": joystick initialization failed\n");
270 382
383 printk("lis3_init_device: irq %d\n", dev->irq);
384
385 /* if we did not get an IRQ from ACPI - we have nothing more to do */
386 if (!dev->irq) {
387 printk(KERN_ERR DRIVER_NAME
388 ": No IRQ in ACPI. Disabling /dev/freefall\n");
389 goto out;
390 }
391
392 printk("lis3: registering device\n");
393 if (misc_register(&lis3lv02d_misc_device))
394 printk(KERN_ERR DRIVER_NAME ": misc_register failed\n");
395out:
271 lis3lv02d_decrease_use(dev); 396 lis3lv02d_decrease_use(dev);
272 return 0; 397 return 0;
273} 398}
@@ -351,6 +476,6 @@ int lis3lv02d_remove_fs(void)
351EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs); 476EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs);
352 477
353MODULE_DESCRIPTION("ST LIS3LV02Dx three-axis digital accelerometer driver"); 478MODULE_DESCRIPTION("ST LIS3LV02Dx three-axis digital accelerometer driver");
354MODULE_AUTHOR("Yan Burman and Eric Piel"); 479MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek");
355MODULE_LICENSE("GPL"); 480MODULE_LICENSE("GPL");
356 481
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h
index 223f1c0763bb..75972bf372ff 100644
--- a/drivers/hwmon/lis3lv02d.h
+++ b/drivers/hwmon/lis3lv02d.h
@@ -22,12 +22,15 @@
22/* 22/*
23 * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to 23 * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to
24 * be connected via SPI. There exists also several similar chips (such as LIS302DL or 24 * be connected via SPI. There exists also several similar chips (such as LIS302DL or
25 * LIS3L02DQ) but not in the HP laptops and they have slightly different registers. 25 * LIS3L02DQ) and they have slightly different registers, but we can provide a
26 * common interface for all of them.
26 * They can also be connected via I²C. 27 * They can also be connected via I²C.
27 */ 28 */
28 29
29#define LIS3LV02DL_ID 0x3A /* Also the LIS3LV02DQ */ 30/* 2-byte registers */
30#define LIS302DL_ID 0x3B /* Also the LIS202DL! */ 31#define LIS_DOUBLE_ID 0x3A /* LIS3LV02D[LQ] */
32/* 1-byte registers */
33#define LIS_SINGLE_ID 0x3B /* LIS[32]02DL and others */
31 34
32enum lis3lv02d_reg { 35enum lis3lv02d_reg {
33 WHO_AM_I = 0x0F, 36 WHO_AM_I = 0x0F,
@@ -44,10 +47,13 @@ enum lis3lv02d_reg {
44 STATUS_REG = 0x27, 47 STATUS_REG = 0x27,
45 OUTX_L = 0x28, 48 OUTX_L = 0x28,
46 OUTX_H = 0x29, 49 OUTX_H = 0x29,
50 OUTX = 0x29,
47 OUTY_L = 0x2A, 51 OUTY_L = 0x2A,
48 OUTY_H = 0x2B, 52 OUTY_H = 0x2B,
53 OUTY = 0x2B,
49 OUTZ_L = 0x2C, 54 OUTZ_L = 0x2C,
50 OUTZ_H = 0x2D, 55 OUTZ_H = 0x2D,
56 OUTZ = 0x2D,
51 FF_WU_CFG = 0x30, 57 FF_WU_CFG = 0x30,
52 FF_WU_SRC = 0x31, 58 FF_WU_SRC = 0x31,
53 FF_WU_ACK = 0x32, 59 FF_WU_ACK = 0x32,
@@ -159,6 +165,10 @@ struct acpi_lis3lv02d {
159 acpi_status (*write) (acpi_handle handle, int reg, u8 val); 165 acpi_status (*write) (acpi_handle handle, int reg, u8 val);
160 acpi_status (*read) (acpi_handle handle, int reg, u8 *ret); 166 acpi_status (*read) (acpi_handle handle, int reg, u8 *ret);
161 167
168 u8 whoami; /* 3Ah: 2-byte registries, 3Bh: 1-byte registries */
169 s16 (*read_data) (acpi_handle handle, int reg);
170 int mdps_max_val;
171
162 struct input_dev *idev; /* input device */ 172 struct input_dev *idev; /* input device */
163 struct task_struct *kthread; /* kthread for input */ 173 struct task_struct *kthread; /* kthread for input */
164 struct mutex lock; 174 struct mutex lock;
@@ -170,6 +180,11 @@ struct acpi_lis3lv02d {
170 unsigned char is_on; /* whether the device is on or off */ 180 unsigned char is_on; /* whether the device is on or off */
171 unsigned char usage; /* usage counter */ 181 unsigned char usage; /* usage counter */
172 struct axis_conversion ac; /* hw -> logical axis */ 182 struct axis_conversion ac; /* hw -> logical axis */
183
184 u32 irq; /* IRQ number */
185 struct fasync_struct *async_queue; /* queue for the misc device */
186 wait_queue_head_t misc_wait; /* Wait queue for the misc device */
187 unsigned long misc_opened; /* bit0: whether the device is open */
173}; 188};
174 189
175int lis3lv02d_init_device(struct acpi_lis3lv02d *dev); 190int lis3lv02d_init_device(struct acpi_lis3lv02d *dev);
diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
index b0ce37852281..73f77a9b8b18 100644
--- a/drivers/hwmon/vt1211.c
+++ b/drivers/hwmon/vt1211.c
@@ -1262,7 +1262,7 @@ static int __init vt1211_device_add(unsigned short address)
1262 res.name = pdev->name; 1262 res.name = pdev->name;
1263 err = acpi_check_resource_conflict(&res); 1263 err = acpi_check_resource_conflict(&res);
1264 if (err) 1264 if (err)
1265 goto EXIT; 1265 goto EXIT_DEV_PUT;
1266 1266
1267 err = platform_device_add_resources(pdev, &res, 1); 1267 err = platform_device_add_resources(pdev, &res, 1);
1268 if (err) { 1268 if (err) {
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index cb808d015361..feae743ba991 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1548,7 +1548,7 @@ static int __init sensors_w83627ehf_init(void)
1548 1548
1549 err = acpi_check_resource_conflict(&res); 1549 err = acpi_check_resource_conflict(&res);
1550 if (err) 1550 if (err)
1551 goto exit; 1551 goto exit_device_put;
1552 1552
1553 err = platform_device_add_resources(pdev, &res, 1); 1553 err = platform_device_add_resources(pdev, &res, 1);
1554 if (err) { 1554 if (err) {
diff --git a/drivers/ide/qd65xx.c b/drivers/ide/qd65xx.c
index 5b2e3af43c4b..08c4fa35e9b1 100644
--- a/drivers/ide/qd65xx.c
+++ b/drivers/ide/qd65xx.c
@@ -16,7 +16,7 @@
16 16
17/* 17/*
18 * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by 18 * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by
19 * Samuel Thibault <samuel.thibault@fnac.net> 19 * Samuel Thibault <samuel.thibault@ens-lyon.org>
20 */ 20 */
21 21
22#include <linux/module.h> 22#include <linux/module.h>
diff --git a/drivers/ide/qd65xx.h b/drivers/ide/qd65xx.h
index 6636f9665d16..d7e67a1a1dcc 100644
--- a/drivers/ide/qd65xx.h
+++ b/drivers/ide/qd65xx.h
@@ -4,7 +4,7 @@
4 4
5/* 5/*
6 * Authors: Petr Soucek <petr@ryston.cz> 6 * Authors: Petr Soucek <petr@ryston.cz>
7 * Samuel Thibault <samuel.thibault@fnac.net> 7 * Samuel Thibault <samuel.thibault@ens-lyon.org>
8 */ 8 */
9 9
10/* truncates a in [b,c] */ 10/* truncates a in [b,c] */
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index a329e6bd5d2d..3838bc4acaba 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -1823,6 +1823,10 @@ static int dv1394_open(struct inode *inode, struct file *file)
1823 1823
1824#endif 1824#endif
1825 1825
1826 printk(KERN_INFO "%s: NOTE, the dv1394 interface is unsupported "
1827 "and will not be available in the new firewire driver stack. "
1828 "Try libraw1394 based programs instead.\n", current->comm);
1829
1826 return 0; 1830 return 0;
1827} 1831}
1828 1832
@@ -2567,10 +2571,6 @@ static int __init dv1394_init_module(void)
2567{ 2571{
2568 int ret; 2572 int ret;
2569 2573
2570 printk(KERN_WARNING
2571 "NOTE: The dv1394 driver is unsupported and may be removed in a "
2572 "future Linux release. Use raw1394 instead.\n");
2573
2574 cdev_init(&dv1394_cdev, &dv1394_fops); 2574 cdev_init(&dv1394_cdev, &dv1394_fops);
2575 dv1394_cdev.owner = THIS_MODULE; 2575 dv1394_cdev.owner = THIS_MODULE;
2576 ret = cdev_add(&dv1394_cdev, IEEE1394_DV1394_DEV, 16); 2576 ret = cdev_add(&dv1394_cdev, IEEE1394_DV1394_DEV, 16);
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index a34338567a2a..f14813be4eff 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -328,7 +328,7 @@ static void dispatch_io(int rw, unsigned int num_regions,
328 struct dpages old_pages = *dp; 328 struct dpages old_pages = *dp;
329 329
330 if (sync) 330 if (sync)
331 rw |= (1 << BIO_RW_SYNC); 331 rw |= (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
332 332
333 /* 333 /*
334 * For multiple regions we need to be careful to rewind 334 * For multiple regions we need to be careful to rewind
diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c
index 3073618269ea..0a225da21272 100644
--- a/drivers/md/dm-kcopyd.c
+++ b/drivers/md/dm-kcopyd.c
@@ -344,7 +344,7 @@ static int run_io_job(struct kcopyd_job *job)
344{ 344{
345 int r; 345 int r;
346 struct dm_io_request io_req = { 346 struct dm_io_request io_req = {
347 .bi_rw = job->rw | (1 << BIO_RW_SYNC), 347 .bi_rw = job->rw | (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG),
348 .mem.type = DM_IO_PAGE_LIST, 348 .mem.type = DM_IO_PAGE_LIST,
349 .mem.ptr.pl = job->pages, 349 .mem.ptr.pl = job->pages,
350 .mem.offset = job->offset, 350 .mem.offset = job->offset,
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 1e3aea9eecf1..09658b218474 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -25,13 +25,13 @@ static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector)
25{ 25{
26 dev_info_t *hash; 26 dev_info_t *hash;
27 linear_conf_t *conf = mddev_to_conf(mddev); 27 linear_conf_t *conf = mddev_to_conf(mddev);
28 sector_t idx = sector >> conf->sector_shift;
28 29
29 /* 30 /*
30 * sector_div(a,b) returns the remainer and sets a to a/b 31 * sector_div(a,b) returns the remainer and sets a to a/b
31 */ 32 */
32 sector >>= conf->sector_shift; 33 (void)sector_div(idx, conf->spacing);
33 (void)sector_div(sector, conf->spacing); 34 hash = conf->hash_table[idx];
34 hash = conf->hash_table[sector];
35 35
36 while (sector >= hash->num_sectors + hash->start_sector) 36 while (sector >= hash->num_sectors + hash->start_sector)
37 hash++; 37 hash++;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 41e2509bf896..03b4cd0a6344 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -474,7 +474,7 @@ void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
474 * causes ENOTSUPP, we allocate a spare bio... 474 * causes ENOTSUPP, we allocate a spare bio...
475 */ 475 */
476 struct bio *bio = bio_alloc(GFP_NOIO, 1); 476 struct bio *bio = bio_alloc(GFP_NOIO, 1);
477 int rw = (1<<BIO_RW) | (1<<BIO_RW_SYNC); 477 int rw = (1<<BIO_RW) | (1<<BIO_RW_SYNCIO) | (1<<BIO_RW_UNPLUG);
478 478
479 bio->bi_bdev = rdev->bdev; 479 bio->bi_bdev = rdev->bdev;
480 bio->bi_sector = sector; 480 bio->bi_sector = sector;
@@ -531,7 +531,7 @@ int sync_page_io(struct block_device *bdev, sector_t sector, int size,
531 struct completion event; 531 struct completion event;
532 int ret; 532 int ret;
533 533
534 rw |= (1 << BIO_RW_SYNC); 534 rw |= (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
535 535
536 bio->bi_bdev = bdev; 536 bio->bi_bdev = bdev;
537 bio->bi_sector = sector; 537 bio->bi_sector = sector;
@@ -1481,6 +1481,11 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1481 if (find_rdev_nr(mddev, rdev->desc_nr)) 1481 if (find_rdev_nr(mddev, rdev->desc_nr))
1482 return -EBUSY; 1482 return -EBUSY;
1483 } 1483 }
1484 if (mddev->max_disks && rdev->desc_nr >= mddev->max_disks) {
1485 printk(KERN_WARNING "md: %s: array is limited to %d devices\n",
1486 mdname(mddev), mddev->max_disks);
1487 return -EBUSY;
1488 }
1484 bdevname(rdev->bdev,b); 1489 bdevname(rdev->bdev,b);
1485 while ( (s=strchr(b, '/')) != NULL) 1490 while ( (s=strchr(b, '/')) != NULL)
1486 *s = '!'; 1491 *s = '!';
@@ -2441,6 +2446,15 @@ static void analyze_sbs(mddev_t * mddev)
2441 2446
2442 i = 0; 2447 i = 0;
2443 rdev_for_each(rdev, tmp, mddev) { 2448 rdev_for_each(rdev, tmp, mddev) {
2449 if (rdev->desc_nr >= mddev->max_disks ||
2450 i > mddev->max_disks) {
2451 printk(KERN_WARNING
2452 "md: %s: %s: only %d devices permitted\n",
2453 mdname(mddev), bdevname(rdev->bdev, b),
2454 mddev->max_disks);
2455 kick_rdev_from_array(rdev);
2456 continue;
2457 }
2444 if (rdev != freshest) 2458 if (rdev != freshest)
2445 if (super_types[mddev->major_version]. 2459 if (super_types[mddev->major_version].
2446 validate_super(mddev, rdev)) { 2460 validate_super(mddev, rdev)) {
@@ -4614,13 +4628,6 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
4614 * noticed in interrupt contexts ... 4628 * noticed in interrupt contexts ...
4615 */ 4629 */
4616 4630
4617 if (rdev->desc_nr == mddev->max_disks) {
4618 printk(KERN_WARNING "%s: can not hot-add to full array!\n",
4619 mdname(mddev));
4620 err = -EBUSY;
4621 goto abort_unbind_export;
4622 }
4623
4624 rdev->raid_disk = -1; 4631 rdev->raid_disk = -1;
4625 4632
4626 md_update_sb(mddev, 1); 4633 md_update_sb(mddev, 1);
@@ -4634,9 +4641,6 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
4634 md_new_event(mddev); 4641 md_new_event(mddev);
4635 return 0; 4642 return 0;
4636 4643
4637abort_unbind_export:
4638 unbind_rdev_from_array(rdev);
4639
4640abort_export: 4644abort_export:
4641 export_rdev(rdev); 4645 export_rdev(rdev);
4642 return err; 4646 return err;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 7b4f5f7155d8..01e3cffd03b8 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1640,7 +1640,8 @@ static void raid1d(mddev_t *mddev)
1640 } 1640 }
1641 1641
1642 bio = r1_bio->bios[r1_bio->read_disk]; 1642 bio = r1_bio->bios[r1_bio->read_disk];
1643 if ((disk=read_balance(conf, r1_bio)) == -1) { 1643 if ((disk=read_balance(conf, r1_bio)) == -1 ||
1644 disk == r1_bio->read_disk) {
1644 printk(KERN_ALERT "raid1: %s: unrecoverable I/O" 1645 printk(KERN_ALERT "raid1: %s: unrecoverable I/O"
1645 " read error for block %llu\n", 1646 " read error for block %llu\n",
1646 bdevname(bio->bi_bdev,b), 1647 bdevname(bio->bi_bdev,b),
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c
index de7adaf5fa5b..78412c9c424a 100644
--- a/drivers/media/common/tuners/tuner-simple.c
+++ b/drivers/media/common/tuners/tuner-simple.c
@@ -318,7 +318,6 @@ static int simple_std_setup(struct dvb_frontend *fe,
318 u8 *config, u8 *cb) 318 u8 *config, u8 *cb)
319{ 319{
320 struct tuner_simple_priv *priv = fe->tuner_priv; 320 struct tuner_simple_priv *priv = fe->tuner_priv;
321 u8 tuneraddr;
322 int rc; 321 int rc;
323 322
324 /* tv norm specific stuff for multi-norm tuners */ 323 /* tv norm specific stuff for multi-norm tuners */
@@ -387,6 +386,7 @@ static int simple_std_setup(struct dvb_frontend *fe,
387 386
388 case TUNER_PHILIPS_TUV1236D: 387 case TUNER_PHILIPS_TUV1236D:
389 { 388 {
389 struct tuner_i2c_props i2c = priv->i2c_props;
390 /* 0x40 -> ATSC antenna input 1 */ 390 /* 0x40 -> ATSC antenna input 1 */
391 /* 0x48 -> ATSC antenna input 2 */ 391 /* 0x48 -> ATSC antenna input 2 */
392 /* 0x00 -> NTSC antenna input 1 */ 392 /* 0x00 -> NTSC antenna input 1 */
@@ -398,17 +398,15 @@ static int simple_std_setup(struct dvb_frontend *fe,
398 buffer[1] = 0x04; 398 buffer[1] = 0x04;
399 } 399 }
400 /* set to the correct mode (analog or digital) */ 400 /* set to the correct mode (analog or digital) */
401 tuneraddr = priv->i2c_props.addr; 401 i2c.addr = 0x0a;
402 priv->i2c_props.addr = 0x0a; 402 rc = tuner_i2c_xfer_send(&i2c, &buffer[0], 2);
403 rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[0], 2);
404 if (2 != rc) 403 if (2 != rc)
405 tuner_warn("i2c i/o error: rc == %d " 404 tuner_warn("i2c i/o error: rc == %d "
406 "(should be 2)\n", rc); 405 "(should be 2)\n", rc);
407 rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[2], 2); 406 rc = tuner_i2c_xfer_send(&i2c, &buffer[2], 2);
408 if (2 != rc) 407 if (2 != rc)
409 tuner_warn("i2c i/o error: rc == %d " 408 tuner_warn("i2c i/o error: rc == %d "
410 "(should be 2)\n", rc); 409 "(should be 2)\n", rc);
411 priv->i2c_props.addr = tuneraddr;
412 break; 410 break;
413 } 411 }
414 } 412 }
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 0c733c66a441..069d847ba887 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -364,16 +364,15 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
364 enum dmx_success success) 364 enum dmx_success success)
365{ 365{
366 struct dmxdev_filter *dmxdevfilter = filter->priv; 366 struct dmxdev_filter *dmxdevfilter = filter->priv;
367 unsigned long flags;
368 int ret; 367 int ret;
369 368
370 if (dmxdevfilter->buffer.error) { 369 if (dmxdevfilter->buffer.error) {
371 wake_up(&dmxdevfilter->buffer.queue); 370 wake_up(&dmxdevfilter->buffer.queue);
372 return 0; 371 return 0;
373 } 372 }
374 spin_lock_irqsave(&dmxdevfilter->dev->lock, flags); 373 spin_lock(&dmxdevfilter->dev->lock);
375 if (dmxdevfilter->state != DMXDEV_STATE_GO) { 374 if (dmxdevfilter->state != DMXDEV_STATE_GO) {
376 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags); 375 spin_unlock(&dmxdevfilter->dev->lock);
377 return 0; 376 return 0;
378 } 377 }
379 del_timer(&dmxdevfilter->timer); 378 del_timer(&dmxdevfilter->timer);
@@ -392,7 +391,7 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
392 } 391 }
393 if (dmxdevfilter->params.sec.flags & DMX_ONESHOT) 392 if (dmxdevfilter->params.sec.flags & DMX_ONESHOT)
394 dmxdevfilter->state = DMXDEV_STATE_DONE; 393 dmxdevfilter->state = DMXDEV_STATE_DONE;
395 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags); 394 spin_unlock(&dmxdevfilter->dev->lock);
396 wake_up(&dmxdevfilter->buffer.queue); 395 wake_up(&dmxdevfilter->buffer.queue);
397 return 0; 396 return 0;
398} 397}
@@ -404,12 +403,11 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
404{ 403{
405 struct dmxdev_filter *dmxdevfilter = feed->priv; 404 struct dmxdev_filter *dmxdevfilter = feed->priv;
406 struct dvb_ringbuffer *buffer; 405 struct dvb_ringbuffer *buffer;
407 unsigned long flags;
408 int ret; 406 int ret;
409 407
410 spin_lock_irqsave(&dmxdevfilter->dev->lock, flags); 408 spin_lock(&dmxdevfilter->dev->lock);
411 if (dmxdevfilter->params.pes.output == DMX_OUT_DECODER) { 409 if (dmxdevfilter->params.pes.output == DMX_OUT_DECODER) {
412 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags); 410 spin_unlock(&dmxdevfilter->dev->lock);
413 return 0; 411 return 0;
414 } 412 }
415 413
@@ -419,7 +417,7 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
419 else 417 else
420 buffer = &dmxdevfilter->dev->dvr_buffer; 418 buffer = &dmxdevfilter->dev->dvr_buffer;
421 if (buffer->error) { 419 if (buffer->error) {
422 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags); 420 spin_unlock(&dmxdevfilter->dev->lock);
423 wake_up(&buffer->queue); 421 wake_up(&buffer->queue);
424 return 0; 422 return 0;
425 } 423 }
@@ -430,7 +428,7 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
430 dvb_ringbuffer_flush(buffer); 428 dvb_ringbuffer_flush(buffer);
431 buffer->error = ret; 429 buffer->error = ret;
432 } 430 }
433 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags); 431 spin_unlock(&dmxdevfilter->dev->lock);
434 wake_up(&buffer->queue); 432 wake_up(&buffer->queue);
435 return 0; 433 return 0;
436} 434}
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index a2c1fd5d2f67..e2eca0b1fe7c 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -399,9 +399,7 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
399void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, 399void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
400 size_t count) 400 size_t count)
401{ 401{
402 unsigned long flags; 402 spin_lock(&demux->lock);
403
404 spin_lock_irqsave(&demux->lock, flags);
405 403
406 while (count--) { 404 while (count--) {
407 if (buf[0] == 0x47) 405 if (buf[0] == 0x47)
@@ -409,17 +407,16 @@ void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
409 buf += 188; 407 buf += 188;
410 } 408 }
411 409
412 spin_unlock_irqrestore(&demux->lock, flags); 410 spin_unlock(&demux->lock);
413} 411}
414 412
415EXPORT_SYMBOL(dvb_dmx_swfilter_packets); 413EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
416 414
417void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) 415void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
418{ 416{
419 unsigned long flags;
420 int p = 0, i, j; 417 int p = 0, i, j;
421 418
422 spin_lock_irqsave(&demux->lock, flags); 419 spin_lock(&demux->lock);
423 420
424 if (demux->tsbufp) { 421 if (demux->tsbufp) {
425 i = demux->tsbufp; 422 i = demux->tsbufp;
@@ -452,18 +449,17 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
452 } 449 }
453 450
454bailout: 451bailout:
455 spin_unlock_irqrestore(&demux->lock, flags); 452 spin_unlock(&demux->lock);
456} 453}
457 454
458EXPORT_SYMBOL(dvb_dmx_swfilter); 455EXPORT_SYMBOL(dvb_dmx_swfilter);
459 456
460void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) 457void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
461{ 458{
462 unsigned long flags;
463 int p = 0, i, j; 459 int p = 0, i, j;
464 u8 tmppack[188]; 460 u8 tmppack[188];
465 461
466 spin_lock_irqsave(&demux->lock, flags); 462 spin_lock(&demux->lock);
467 463
468 if (demux->tsbufp) { 464 if (demux->tsbufp) {
469 i = demux->tsbufp; 465 i = demux->tsbufp;
@@ -504,7 +500,7 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
504 } 500 }
505 501
506bailout: 502bailout:
507 spin_unlock_irqrestore(&demux->lock, flags); 503 spin_unlock(&demux->lock);
508} 504}
509 505
510EXPORT_SYMBOL(dvb_dmx_swfilter_204); 506EXPORT_SYMBOL(dvb_dmx_swfilter_204);
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c
index 67cbce82cb91..4dfed6aa2dbc 100644
--- a/drivers/media/radio/radio-si470x.c
+++ b/drivers/media/radio/radio-si470x.c
@@ -98,11 +98,16 @@
98 * - blacklisted KWorld radio in hid-core.c and hid-ids.h 98 * - blacklisted KWorld radio in hid-core.c and hid-ids.h
99 * 2008-12-03 Mark Lord <mlord@pobox.com> 99 * 2008-12-03 Mark Lord <mlord@pobox.com>
100 * - add support for DealExtreme USB Radio 100 * - add support for DealExtreme USB Radio
101 * 2009-01-31 Bob Ross <pigiron@gmx.com>
102 * - correction of stereo detection/setting
103 * - correction of signal strength indicator scaling
104 * 2009-01-31 Rick Bronson <rick@efn.org>
105 * Tobias Lorenz <tobias.lorenz@gmx.net>
106 * - add LED status output
101 * 107 *
102 * ToDo: 108 * ToDo:
103 * - add firmware download/update support 109 * - add firmware download/update support
104 * - RDS support: interrupt mode, instead of polling 110 * - RDS support: interrupt mode, instead of polling
105 * - add LED status output (check if that's not already done in firmware)
106 */ 111 */
107 112
108 113
@@ -882,6 +887,30 @@ static int si470x_rds_on(struct si470x_device *radio)
882 887
883 888
884/************************************************************************** 889/**************************************************************************
890 * General Driver Functions - LED_REPORT
891 **************************************************************************/
892
893/*
894 * si470x_set_led_state - sets the led state
895 */
896static int si470x_set_led_state(struct si470x_device *radio,
897 unsigned char led_state)
898{
899 unsigned char buf[LED_REPORT_SIZE];
900 int retval;
901
902 buf[0] = LED_REPORT;
903 buf[1] = LED_COMMAND;
904 buf[2] = led_state;
905
906 retval = si470x_set_report(radio, (void *) &buf, sizeof(buf));
907
908 return (retval < 0) ? -EINVAL : 0;
909}
910
911
912
913/**************************************************************************
885 * RDS Driver Functions 914 * RDS Driver Functions
886 **************************************************************************/ 915 **************************************************************************/
887 916
@@ -1385,20 +1414,22 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv,
1385 }; 1414 };
1386 1415
1387 /* stereo indicator == stereo (instead of mono) */ 1416 /* stereo indicator == stereo (instead of mono) */
1388 if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 1) 1417 if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 0)
1389 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
1390 else
1391 tuner->rxsubchans = V4L2_TUNER_SUB_MONO; 1418 tuner->rxsubchans = V4L2_TUNER_SUB_MONO;
1419 else
1420 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
1392 1421
1393 /* mono/stereo selector */ 1422 /* mono/stereo selector */
1394 if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 1) 1423 if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 0)
1395 tuner->audmode = V4L2_TUNER_MODE_MONO;
1396 else
1397 tuner->audmode = V4L2_TUNER_MODE_STEREO; 1424 tuner->audmode = V4L2_TUNER_MODE_STEREO;
1425 else
1426 tuner->audmode = V4L2_TUNER_MODE_MONO;
1398 1427
1399 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */ 1428 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */
1400 tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI) 1429 /* measured in units of dbµV in 1 db increments (max at ~75 dbµV) */
1401 * 0x0101; 1430 tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI);
1431 /* the ideal factor is 0xffff/75 = 873,8 */
1432 tuner->signal = (tuner->signal * 873) + (8 * tuner->signal / 10);
1402 1433
1403 /* automatic frequency control: -1: freq to low, 1 freq to high */ 1434 /* automatic frequency control: -1: freq to low, 1 freq to high */
1404 /* AFCRL does only indicate that freq. differs, not if too low/high */ 1435 /* AFCRL does only indicate that freq. differs, not if too low/high */
@@ -1632,6 +1663,9 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
1632 /* set initial frequency */ 1663 /* set initial frequency */
1633 si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */ 1664 si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
1634 1665
1666 /* set led to connect state */
1667 si470x_set_led_state(radio, BLINK_GREEN_LED);
1668
1635 /* rds buffer allocation */ 1669 /* rds buffer allocation */
1636 radio->buf_size = rds_buf * 3; 1670 radio->buf_size = rds_buf * 3;
1637 radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); 1671 radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL);
@@ -1715,6 +1749,9 @@ static void si470x_usb_driver_disconnect(struct usb_interface *intf)
1715 cancel_delayed_work_sync(&radio->work); 1749 cancel_delayed_work_sync(&radio->work);
1716 usb_set_intfdata(intf, NULL); 1750 usb_set_intfdata(intf, NULL);
1717 if (radio->users == 0) { 1751 if (radio->users == 0) {
1752 /* set led to disconnect state */
1753 si470x_set_led_state(radio, BLINK_ORANGE_LED);
1754
1718 video_unregister_device(radio->videodev); 1755 video_unregister_device(radio->videodev);
1719 kfree(radio->buffer); 1756 kfree(radio->buffer);
1720 kfree(radio); 1757 kfree(radio);
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 2ed24527ecd6..65e4901f4db7 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -422,6 +422,7 @@ static void destroy_urbs(struct gspca_dev *gspca_dev)
422 if (urb == NULL) 422 if (urb == NULL)
423 break; 423 break;
424 424
425 BUG_ON(!gspca_dev->dev);
425 gspca_dev->urb[i] = NULL; 426 gspca_dev->urb[i] = NULL;
426 if (!gspca_dev->present) 427 if (!gspca_dev->present)
427 usb_kill_urb(urb); 428 usb_kill_urb(urb);
@@ -1950,8 +1951,12 @@ void gspca_disconnect(struct usb_interface *intf)
1950{ 1951{
1951 struct gspca_dev *gspca_dev = usb_get_intfdata(intf); 1952 struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
1952 1953
1954 mutex_lock(&gspca_dev->usb_lock);
1953 gspca_dev->present = 0; 1955 gspca_dev->present = 0;
1956 mutex_unlock(&gspca_dev->usb_lock);
1954 1957
1958 destroy_urbs(gspca_dev);
1959 gspca_dev->dev = NULL;
1955 usb_set_intfdata(intf, NULL); 1960 usb_set_intfdata(intf, NULL);
1956 1961
1957 /* release the device */ 1962 /* release the device */
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index f6b3ef6e691b..c13bd2aa0bea 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -393,7 +393,7 @@ static int ivtv_g_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo
393 return 0; 393 return 0;
394 } 394 }
395 395
396 v4l2_subdev_call(itv->sd_video, video, s_fmt, fmt); 396 v4l2_subdev_call(itv->sd_video, video, g_fmt, fmt);
397 vbifmt->service_set = ivtv_get_service_set(vbifmt); 397 vbifmt->service_set = ivtv_get_service_set(vbifmt);
398 return 0; 398 return 0;
399} 399}
@@ -1748,6 +1748,18 @@ static long ivtv_default(struct file *file, void *fh, int cmd, void *arg)
1748 break; 1748 break;
1749 } 1749 }
1750 1750
1751 case IVTV_IOC_DMA_FRAME:
1752 case VIDEO_GET_PTS:
1753 case VIDEO_GET_FRAME_COUNT:
1754 case VIDEO_GET_EVENT:
1755 case VIDEO_PLAY:
1756 case VIDEO_STOP:
1757 case VIDEO_FREEZE:
1758 case VIDEO_CONTINUE:
1759 case VIDEO_COMMAND:
1760 case VIDEO_TRY_COMMAND:
1761 return ivtv_decoder_ioctls(file, cmd, (void *)arg);
1762
1751 default: 1763 default:
1752 return -EINVAL; 1764 return -EINVAL;
1753 } 1765 }
@@ -1790,18 +1802,6 @@ static long ivtv_serialized_ioctl(struct ivtv *itv, struct file *filp,
1790 ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode); 1802 ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode);
1791 return 0; 1803 return 0;
1792 1804
1793 case IVTV_IOC_DMA_FRAME:
1794 case VIDEO_GET_PTS:
1795 case VIDEO_GET_FRAME_COUNT:
1796 case VIDEO_GET_EVENT:
1797 case VIDEO_PLAY:
1798 case VIDEO_STOP:
1799 case VIDEO_FREEZE:
1800 case VIDEO_CONTINUE:
1801 case VIDEO_COMMAND:
1802 case VIDEO_TRY_COMMAND:
1803 return ivtv_decoder_ioctls(filp, cmd, (void *)arg);
1804
1805 default: 1805 default:
1806 break; 1806 break;
1807 } 1807 }
diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c
index 1a4d04664d6d..aa266e1f69b2 100644
--- a/drivers/mfd/htc-egpio.c
+++ b/drivers/mfd/htc-egpio.c
@@ -286,7 +286,7 @@ static int __init egpio_probe(struct platform_device *pdev)
286 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 286 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
287 if (!res) 287 if (!res)
288 goto fail; 288 goto fail;
289 ei->base_addr = ioremap_nocache(res->start, res->end - res->start); 289 ei->base_addr = ioremap_nocache(res->start, resource_size(res));
290 if (!ei->base_addr) 290 if (!ei->base_addr)
291 goto fail; 291 goto fail;
292 pr_debug("EGPIO phys=%08x virt=%p\n", (u32)res->start, ei->base_addr); 292 pr_debug("EGPIO phys=%08x virt=%p\n", (u32)res->start, ei->base_addr);
@@ -307,7 +307,7 @@ static int __init egpio_probe(struct platform_device *pdev)
307 307
308 ei->nchips = pdata->num_chips; 308 ei->nchips = pdata->num_chips;
309 ei->chip = kzalloc(sizeof(struct egpio_chip) * ei->nchips, GFP_KERNEL); 309 ei->chip = kzalloc(sizeof(struct egpio_chip) * ei->nchips, GFP_KERNEL);
310 if (!ei) { 310 if (!ei->chip) {
311 ret = -ENOMEM; 311 ret = -ENOMEM;
312 goto fail; 312 goto fail;
313 } 313 }
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index 24508e28e3fb..2e36057659e1 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -626,7 +626,6 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
626 } 626 }
627 627
628 if (client->irq) { 628 if (client->irq) {
629 set_irq_handler(client->irq, handle_level_irq);
630 ret = request_irq(client->irq, pcf50633_irq, 629 ret = request_irq(client->irq, pcf50633_irq,
631 IRQF_TRIGGER_LOW, "pcf50633", pcf); 630 IRQF_TRIGGER_LOW, "pcf50633", pcf);
632 631
@@ -679,6 +678,7 @@ static int __devexit pcf50633_remove(struct i2c_client *client)
679 678
680static struct i2c_device_id pcf50633_id_table[] = { 679static struct i2c_device_id pcf50633_id_table[] = {
681 {"pcf50633", 0x73}, 680 {"pcf50633", 0x73},
681 {/* end of list */}
682}; 682};
683 683
684static struct i2c_driver pcf50633_driver = { 684static struct i2c_driver pcf50633_driver = {
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 0e5761f12634..4c7b7962f6b8 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -1050,7 +1050,7 @@ static int __devinit sm501_gpio_register_chip(struct sm501_devdata *sm,
1050 return gpiochip_add(gchip); 1050 return gpiochip_add(gchip);
1051} 1051}
1052 1052
1053static int sm501_register_gpio(struct sm501_devdata *sm) 1053static int __devinit sm501_register_gpio(struct sm501_devdata *sm)
1054{ 1054{
1055 struct sm501_gpio *gpio = &sm->gpio; 1055 struct sm501_gpio *gpio = &sm->gpio;
1056 resource_size_t iobase = sm->io_res->start + SM501_GPIO; 1056 resource_size_t iobase = sm->io_res->start + SM501_GPIO;
@@ -1321,7 +1321,7 @@ static unsigned int sm501_mem_local[] = {
1321 * Common init code for an SM501 1321 * Common init code for an SM501
1322*/ 1322*/
1323 1323
1324static int sm501_init_dev(struct sm501_devdata *sm) 1324static int __devinit sm501_init_dev(struct sm501_devdata *sm)
1325{ 1325{
1326 struct sm501_initdata *idata; 1326 struct sm501_initdata *idata;
1327 struct sm501_platdata *pdata; 1327 struct sm501_platdata *pdata;
@@ -1397,7 +1397,7 @@ static int sm501_init_dev(struct sm501_devdata *sm)
1397 return 0; 1397 return 0;
1398} 1398}
1399 1399
1400static int sm501_plat_probe(struct platform_device *dev) 1400static int __devinit sm501_plat_probe(struct platform_device *dev)
1401{ 1401{
1402 struct sm501_devdata *sm; 1402 struct sm501_devdata *sm;
1403 int ret; 1403 int ret;
@@ -1586,8 +1586,8 @@ static struct sm501_platdata sm501_pci_platdata = {
1586 .gpio_base = -1, 1586 .gpio_base = -1,
1587}; 1587};
1588 1588
1589static int sm501_pci_probe(struct pci_dev *dev, 1589static int __devinit sm501_pci_probe(struct pci_dev *dev,
1590 const struct pci_device_id *id) 1590 const struct pci_device_id *id)
1591{ 1591{
1592 struct sm501_devdata *sm; 1592 struct sm501_devdata *sm;
1593 int err; 1593 int err;
@@ -1693,7 +1693,7 @@ static void sm501_dev_remove(struct sm501_devdata *sm)
1693 sm501_gpio_remove(sm); 1693 sm501_gpio_remove(sm);
1694} 1694}
1695 1695
1696static void sm501_pci_remove(struct pci_dev *dev) 1696static void __devexit sm501_pci_remove(struct pci_dev *dev)
1697{ 1697{
1698 struct sm501_devdata *sm = pci_get_drvdata(dev); 1698 struct sm501_devdata *sm = pci_get_drvdata(dev);
1699 1699
@@ -1727,16 +1727,16 @@ static struct pci_device_id sm501_pci_tbl[] = {
1727 1727
1728MODULE_DEVICE_TABLE(pci, sm501_pci_tbl); 1728MODULE_DEVICE_TABLE(pci, sm501_pci_tbl);
1729 1729
1730static struct pci_driver sm501_pci_drv = { 1730static struct pci_driver sm501_pci_driver = {
1731 .name = "sm501", 1731 .name = "sm501",
1732 .id_table = sm501_pci_tbl, 1732 .id_table = sm501_pci_tbl,
1733 .probe = sm501_pci_probe, 1733 .probe = sm501_pci_probe,
1734 .remove = sm501_pci_remove, 1734 .remove = __devexit_p(sm501_pci_remove),
1735}; 1735};
1736 1736
1737MODULE_ALIAS("platform:sm501"); 1737MODULE_ALIAS("platform:sm501");
1738 1738
1739static struct platform_driver sm501_plat_drv = { 1739static struct platform_driver sm501_plat_driver = {
1740 .driver = { 1740 .driver = {
1741 .name = "sm501", 1741 .name = "sm501",
1742 .owner = THIS_MODULE, 1742 .owner = THIS_MODULE,
@@ -1749,14 +1749,14 @@ static struct platform_driver sm501_plat_drv = {
1749 1749
1750static int __init sm501_base_init(void) 1750static int __init sm501_base_init(void)
1751{ 1751{
1752 platform_driver_register(&sm501_plat_drv); 1752 platform_driver_register(&sm501_plat_driver);
1753 return pci_register_driver(&sm501_pci_drv); 1753 return pci_register_driver(&sm501_pci_driver);
1754} 1754}
1755 1755
1756static void __exit sm501_base_exit(void) 1756static void __exit sm501_base_exit(void)
1757{ 1757{
1758 platform_driver_unregister(&sm501_plat_drv); 1758 platform_driver_unregister(&sm501_plat_driver);
1759 pci_unregister_driver(&sm501_pci_drv); 1759 pci_unregister_driver(&sm501_pci_driver);
1760} 1760}
1761 1761
1762module_init(sm501_base_init); 1762module_init(sm501_base_init);
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index e7ab0035d305..68826f1e36bc 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -38,7 +38,7 @@
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c/twl4030.h> 39#include <linux/i2c/twl4030.h>
40 40
41#ifdef CONFIG_ARM 41#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
42#include <mach/cpu.h> 42#include <mach/cpu.h>
43#endif 43#endif
44 44
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index f92595c8f165..84d5ea1ec171 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -1111,7 +1111,7 @@ int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref)
1111 do { 1111 do {
1112 schedule_timeout_interruptible(1); 1112 schedule_timeout_interruptible(1);
1113 reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1); 1113 reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1);
1114 } while (tries-- && (reg & WM8350_AUXADC_POLL)); 1114 } while (--tries && (reg & WM8350_AUXADC_POLL));
1115 1115
1116 if (!tries) 1116 if (!tries)
1117 dev_err(wm8350->dev, "adc chn %d read timeout\n", channel); 1117 dev_err(wm8350->dev, "adc chn %d read timeout\n", channel);
@@ -1297,14 +1297,29 @@ static void wm8350_client_dev_register(struct wm8350 *wm8350,
1297int wm8350_device_init(struct wm8350 *wm8350, int irq, 1297int wm8350_device_init(struct wm8350 *wm8350, int irq,
1298 struct wm8350_platform_data *pdata) 1298 struct wm8350_platform_data *pdata)
1299{ 1299{
1300 int ret = -EINVAL; 1300 int ret;
1301 u16 id1, id2, mask_rev; 1301 u16 id1, id2, mask_rev;
1302 u16 cust_id, mode, chip_rev; 1302 u16 cust_id, mode, chip_rev;
1303 1303
1304 /* get WM8350 revision and config mode */ 1304 /* get WM8350 revision and config mode */
1305 wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1); 1305 ret = wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1);
1306 wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2); 1306 if (ret != 0) {
1307 wm8350->read_dev(wm8350, WM8350_REVISION, sizeof(mask_rev), &mask_rev); 1307 dev_err(wm8350->dev, "Failed to read ID: %d\n", ret);
1308 goto err;
1309 }
1310
1311 ret = wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2);
1312 if (ret != 0) {
1313 dev_err(wm8350->dev, "Failed to read ID: %d\n", ret);
1314 goto err;
1315 }
1316
1317 ret = wm8350->read_dev(wm8350, WM8350_REVISION, sizeof(mask_rev),
1318 &mask_rev);
1319 if (ret != 0) {
1320 dev_err(wm8350->dev, "Failed to read revision: %d\n", ret);
1321 goto err;
1322 }
1308 1323
1309 id1 = be16_to_cpu(id1); 1324 id1 = be16_to_cpu(id1);
1310 id2 = be16_to_cpu(id2); 1325 id2 = be16_to_cpu(id2);
@@ -1404,14 +1419,12 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
1404 return ret; 1419 return ret;
1405 } 1420 }
1406 1421
1407 if (pdata && pdata->init) { 1422 wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0xFFFF);
1408 ret = pdata->init(wm8350); 1423 wm8350_reg_write(wm8350, WM8350_INT_STATUS_1_MASK, 0xFFFF);
1409 if (ret != 0) { 1424 wm8350_reg_write(wm8350, WM8350_INT_STATUS_2_MASK, 0xFFFF);
1410 dev_err(wm8350->dev, "Platform init() failed: %d\n", 1425 wm8350_reg_write(wm8350, WM8350_UNDER_VOLTAGE_INT_STATUS_MASK, 0xFFFF);
1411 ret); 1426 wm8350_reg_write(wm8350, WM8350_GPIO_INT_STATUS_MASK, 0xFFFF);
1412 goto err; 1427 wm8350_reg_write(wm8350, WM8350_COMPARATOR_INT_STATUS_MASK, 0xFFFF);
1413 }
1414 }
1415 1428
1416 mutex_init(&wm8350->auxadc_mutex); 1429 mutex_init(&wm8350->auxadc_mutex);
1417 mutex_init(&wm8350->irq_mutex); 1430 mutex_init(&wm8350->irq_mutex);
@@ -1430,6 +1443,15 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
1430 } 1443 }
1431 wm8350->chip_irq = irq; 1444 wm8350->chip_irq = irq;
1432 1445
1446 if (pdata && pdata->init) {
1447 ret = pdata->init(wm8350);
1448 if (ret != 0) {
1449 dev_err(wm8350->dev, "Platform init() failed: %d\n",
1450 ret);
1451 goto err;
1452 }
1453 }
1454
1433 wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0x0); 1455 wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0x0);
1434 1456
1435 wm8350_client_dev_register(wm8350, "wm8350-codec", 1457 wm8350_client_dev_register(wm8350, "wm8350-codec",
diff --git a/drivers/mfd/wm8350-regmap.c b/drivers/mfd/wm8350-regmap.c
index 68887b817d17..9a4cc954cb7c 100644
--- a/drivers/mfd/wm8350-regmap.c
+++ b/drivers/mfd/wm8350-regmap.c
@@ -3188,7 +3188,7 @@ const struct wm8350_reg_access wm8350_reg_io_map[] = {
3188 { 0x7CFF, 0x0C00, 0x7FFF }, /* R1 - ID */ 3188 { 0x7CFF, 0x0C00, 0x7FFF }, /* R1 - ID */
3189 { 0x0000, 0x0000, 0x0000 }, /* R2 */ 3189 { 0x0000, 0x0000, 0x0000 }, /* R2 */
3190 { 0xBE3B, 0xBE3B, 0x8000 }, /* R3 - System Control 1 */ 3190 { 0xBE3B, 0xBE3B, 0x8000 }, /* R3 - System Control 1 */
3191 { 0xFCF7, 0xFCF7, 0xF800 }, /* R4 - System Control 2 */ 3191 { 0xFEF7, 0xFEF7, 0xF800 }, /* R4 - System Control 2 */
3192 { 0x80FF, 0x80FF, 0x8000 }, /* R5 - System Hibernate */ 3192 { 0x80FF, 0x80FF, 0x8000 }, /* R5 - System Hibernate */
3193 { 0xFB0E, 0xFB0E, 0x0000 }, /* R6 - Interface Control */ 3193 { 0xFB0E, 0xFB0E, 0x0000 }, /* R6 - Interface Control */
3194 { 0x0000, 0x0000, 0x0000 }, /* R7 */ 3194 { 0x0000, 0x0000, 0x0000 }, /* R7 */
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 56073199ceba..c64e6798878a 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -217,6 +217,7 @@ config DELL_LAPTOP
217 depends on EXPERIMENTAL 217 depends on EXPERIMENTAL
218 depends on BACKLIGHT_CLASS_DEVICE 218 depends on BACKLIGHT_CLASS_DEVICE
219 depends on RFKILL 219 depends on RFKILL
220 depends on POWER_SUPPLY
220 default n 221 default n
221 ---help--- 222 ---help---
222 This driver adds support for rfkill and backlight control to Dell 223 This driver adds support for rfkill and backlight control to Dell
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index bf5e4d065436..558bf3f2c276 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -35,7 +35,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
35 35
36 if (!ssc_valid) { 36 if (!ssc_valid) {
37 spin_unlock(&user_lock); 37 spin_unlock(&user_lock);
38 dev_dbg(&ssc->pdev->dev, "could not find requested device\n"); 38 pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
39 return ERR_PTR(-ENODEV); 39 return ERR_PTR(-ENODEV);
40 } 40 }
41 41
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index 10c421b73eaf..f26667a7abf7 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -207,7 +207,7 @@ static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data)
207 &device_ccb->recv_ctrl); 207 &device_ccb->recv_ctrl);
208 208
209 /* give iLO some time to process stop request */ 209 /* give iLO some time to process stop request */
210 for (retries = 1000; retries > 0; retries--) { 210 for (retries = MAX_WAIT; retries > 0; retries--) {
211 doorbell_set(driver_ccb); 211 doorbell_set(driver_ccb);
212 udelay(1); 212 udelay(1);
213 if (!(ioread32(&device_ccb->send_ctrl) & (1 << CTRL_BITPOS_A)) 213 if (!(ioread32(&device_ccb->send_ctrl) & (1 << CTRL_BITPOS_A))
@@ -309,7 +309,7 @@ static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
309 doorbell_clr(driver_ccb); 309 doorbell_clr(driver_ccb);
310 310
311 /* make sure iLO is really handling requests */ 311 /* make sure iLO is really handling requests */
312 for (i = 1000; i > 0; i--) { 312 for (i = MAX_WAIT; i > 0; i--) {
313 if (ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, NULL, NULL)) 313 if (ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, NULL, NULL))
314 break; 314 break;
315 udelay(1); 315 udelay(1);
@@ -326,7 +326,7 @@ static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
326 326
327 return 0; 327 return 0;
328free: 328free:
329 pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa); 329 ilo_ccb_close(pdev, data);
330out: 330out:
331 return error; 331 return error;
332} 332}
diff --git a/drivers/misc/hpilo.h b/drivers/misc/hpilo.h
index a281207696c1..b64a20ef07e3 100644
--- a/drivers/misc/hpilo.h
+++ b/drivers/misc/hpilo.h
@@ -19,6 +19,8 @@
19#define MAX_ILO_DEV 1 19#define MAX_ILO_DEV 1
20/* max number of files */ 20/* max number of files */
21#define MAX_OPEN (MAX_CCB * MAX_ILO_DEV) 21#define MAX_OPEN (MAX_CCB * MAX_ILO_DEV)
22/* spin counter for open/close delay */
23#define MAX_WAIT 10000
22 24
23/* 25/*
24 * Per device, used to track global memory allocations. 26 * Per device, used to track global memory allocations.
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
index a5bd658c2e83..275b78896a73 100644
--- a/drivers/misc/sgi-xp/xpc.h
+++ b/drivers/misc/sgi-xp/xpc.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2004-2008 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2004-2009 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* 9/*
@@ -514,7 +514,8 @@ struct xpc_channel_uv {
514 /* partition's notify mq */ 514 /* partition's notify mq */
515 515
516 struct xpc_send_msg_slot_uv *send_msg_slots; 516 struct xpc_send_msg_slot_uv *send_msg_slots;
517 struct xpc_notify_mq_msg_uv *recv_msg_slots; 517 void *recv_msg_slots; /* each slot will hold a xpc_notify_mq_msg_uv */
518 /* structure plus the user's payload */
518 519
519 struct xpc_fifo_head_uv msg_slot_free_list; 520 struct xpc_fifo_head_uv msg_slot_free_list;
520 struct xpc_fifo_head_uv recv_msg_list; /* deliverable payloads */ 521 struct xpc_fifo_head_uv recv_msg_list; /* deliverable payloads */
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index f17f7d40ea2c..29c0502a96b2 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2008-2009 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* 9/*
@@ -1010,8 +1010,8 @@ xpc_allocate_recv_msg_slot_uv(struct xpc_channel *ch)
1010 continue; 1010 continue;
1011 1011
1012 for (entry = 0; entry < nentries; entry++) { 1012 for (entry = 0; entry < nentries; entry++) {
1013 msg_slot = ch_uv->recv_msg_slots + entry * 1013 msg_slot = ch_uv->recv_msg_slots +
1014 ch->entry_size; 1014 entry * ch->entry_size;
1015 1015
1016 msg_slot->hdr.msg_slot_number = entry; 1016 msg_slot->hdr.msg_slot_number = entry;
1017 } 1017 }
@@ -1308,9 +1308,8 @@ xpc_handle_notify_mq_msg_uv(struct xpc_partition *part,
1308 /* we're dealing with a normal message sent via the notify_mq */ 1308 /* we're dealing with a normal message sent via the notify_mq */
1309 ch_uv = &ch->sn.uv; 1309 ch_uv = &ch->sn.uv;
1310 1310
1311 msg_slot = (struct xpc_notify_mq_msg_uv *)((u64)ch_uv->recv_msg_slots + 1311 msg_slot = ch_uv->recv_msg_slots +
1312 (msg->hdr.msg_slot_number % ch->remote_nentries) * 1312 (msg->hdr.msg_slot_number % ch->remote_nentries) * ch->entry_size;
1313 ch->entry_size);
1314 1313
1315 BUG_ON(msg->hdr.msg_slot_number != msg_slot->hdr.msg_slot_number); 1314 BUG_ON(msg->hdr.msg_slot_number != msg_slot->hdr.msg_slot_number);
1316 BUG_ON(msg_slot->hdr.size != 0); 1315 BUG_ON(msg_slot->hdr.size != 0);
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 45b1f430685f..513eb09a638f 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -584,7 +584,7 @@ static int mmc_blk_probe(struct mmc_card *card)
584 if (err) 584 if (err)
585 goto out; 585 goto out;
586 586
587 string_get_size(get_capacity(md->disk) << 9, STRING_UNITS_2, 587 string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2,
588 cap_str, sizeof(cap_str)); 588 cap_str, sizeof(cap_str));
589 printk(KERN_INFO "%s: %s %s %s %s\n", 589 printk(KERN_INFO "%s: %s %s %s %s\n",
590 md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), 590 md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index b92b172074ee..b9f1e84897cc 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -494,7 +494,7 @@ static int mmc_test_basic_read(struct mmc_test_card *test)
494 494
495 sg_init_one(&sg, test->buffer, 512); 495 sg_init_one(&sg, test->buffer, 512);
496 496
497 ret = mmc_test_simple_transfer(test, &sg, 1, 0, 1, 512, 1); 497 ret = mmc_test_simple_transfer(test, &sg, 1, 0, 1, 512, 0);
498 if (ret) 498 if (ret)
499 return ret; 499 return ret;
500 500
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 76bfe16c09b1..2b1196e6142c 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -1548,9 +1548,10 @@ static bool filter(struct dma_chan *chan, void *slave)
1548{ 1548{
1549 struct dw_dma_slave *dws = slave; 1549 struct dw_dma_slave *dws = slave;
1550 1550
1551 if (dws->dma_dev == chan->device->dev) 1551 if (dws->dma_dev == chan->device->dev) {
1552 chan->private = dws;
1552 return true; 1553 return true;
1553 else 1554 } else
1554 return false; 1555 return false;
1555} 1556}
1556#endif 1557#endif
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index db37490f67ec..a631c81dce12 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -55,6 +55,7 @@
55#define VS30 (1 << 25) 55#define VS30 (1 << 25)
56#define SDVS18 (0x5 << 9) 56#define SDVS18 (0x5 << 9)
57#define SDVS30 (0x6 << 9) 57#define SDVS30 (0x6 << 9)
58#define SDVS33 (0x7 << 9)
58#define SDVSCLR 0xFFFFF1FF 59#define SDVSCLR 0xFFFFF1FF
59#define SDVSDET 0x00000400 60#define SDVSDET 0x00000400
60#define AUTOIDLE 0x1 61#define AUTOIDLE 0x1
@@ -375,6 +376,32 @@ static void mmc_omap_report_irq(struct mmc_omap_host *host, u32 status)
375} 376}
376#endif /* CONFIG_MMC_DEBUG */ 377#endif /* CONFIG_MMC_DEBUG */
377 378
379/*
380 * MMC controller internal state machines reset
381 *
382 * Used to reset command or data internal state machines, using respectively
383 * SRC or SRD bit of SYSCTL register
384 * Can be called from interrupt context
385 */
386static inline void mmc_omap_reset_controller_fsm(struct mmc_omap_host *host,
387 unsigned long bit)
388{
389 unsigned long i = 0;
390 unsigned long limit = (loops_per_jiffy *
391 msecs_to_jiffies(MMC_TIMEOUT_MS));
392
393 OMAP_HSMMC_WRITE(host->base, SYSCTL,
394 OMAP_HSMMC_READ(host->base, SYSCTL) | bit);
395
396 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & bit) &&
397 (i++ < limit))
398 cpu_relax();
399
400 if (OMAP_HSMMC_READ(host->base, SYSCTL) & bit)
401 dev_err(mmc_dev(host->mmc),
402 "Timeout waiting on controller reset in %s\n",
403 __func__);
404}
378 405
379/* 406/*
380 * MMC controller IRQ handler 407 * MMC controller IRQ handler
@@ -403,21 +430,17 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
403 (status & CMD_CRC)) { 430 (status & CMD_CRC)) {
404 if (host->cmd) { 431 if (host->cmd) {
405 if (status & CMD_TIMEOUT) { 432 if (status & CMD_TIMEOUT) {
406 OMAP_HSMMC_WRITE(host->base, SYSCTL, 433 mmc_omap_reset_controller_fsm(host, SRC);
407 OMAP_HSMMC_READ(host->base,
408 SYSCTL) | SRC);
409 while (OMAP_HSMMC_READ(host->base,
410 SYSCTL) & SRC)
411 ;
412
413 host->cmd->error = -ETIMEDOUT; 434 host->cmd->error = -ETIMEDOUT;
414 } else { 435 } else {
415 host->cmd->error = -EILSEQ; 436 host->cmd->error = -EILSEQ;
416 } 437 }
417 end_cmd = 1; 438 end_cmd = 1;
418 } 439 }
419 if (host->data) 440 if (host->data) {
420 mmc_dma_cleanup(host); 441 mmc_dma_cleanup(host);
442 mmc_omap_reset_controller_fsm(host, SRD);
443 }
421 } 444 }
422 if ((status & DATA_TIMEOUT) || 445 if ((status & DATA_TIMEOUT) ||
423 (status & DATA_CRC)) { 446 (status & DATA_CRC)) {
@@ -426,12 +449,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
426 mmc_dma_cleanup(host); 449 mmc_dma_cleanup(host);
427 else 450 else
428 host->data->error = -EILSEQ; 451 host->data->error = -EILSEQ;
429 OMAP_HSMMC_WRITE(host->base, SYSCTL, 452 mmc_omap_reset_controller_fsm(host, SRD);
430 OMAP_HSMMC_READ(host->base,
431 SYSCTL) | SRD);
432 while (OMAP_HSMMC_READ(host->base,
433 SYSCTL) & SRD)
434 ;
435 end_trans = 1; 453 end_trans = 1;
436 } 454 }
437 } 455 }
@@ -456,13 +474,20 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
456} 474}
457 475
458/* 476/*
459 * Switch MMC operating voltage 477 * Switch MMC interface voltage ... only relevant for MMC1.
478 *
479 * MMC2 and MMC3 use fixed 1.8V levels, and maybe a transceiver.
480 * The MMC2 transceiver controls are used instead of DAT4..DAT7.
481 * Some chips, like eMMC ones, use internal transceivers.
460 */ 482 */
461static int omap_mmc_switch_opcond(struct mmc_omap_host *host, int vdd) 483static int omap_mmc_switch_opcond(struct mmc_omap_host *host, int vdd)
462{ 484{
463 u32 reg_val = 0; 485 u32 reg_val = 0;
464 int ret; 486 int ret;
465 487
488 if (host->id != OMAP_MMC1_DEVID)
489 return 0;
490
466 /* Disable the clocks */ 491 /* Disable the clocks */
467 clk_disable(host->fclk); 492 clk_disable(host->fclk);
468 clk_disable(host->iclk); 493 clk_disable(host->iclk);
@@ -485,19 +510,26 @@ static int omap_mmc_switch_opcond(struct mmc_omap_host *host, int vdd)
485 OMAP_HSMMC_WRITE(host->base, HCTL, 510 OMAP_HSMMC_WRITE(host->base, HCTL,
486 OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR); 511 OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR);
487 reg_val = OMAP_HSMMC_READ(host->base, HCTL); 512 reg_val = OMAP_HSMMC_READ(host->base, HCTL);
513
488 /* 514 /*
489 * If a MMC dual voltage card is detected, the set_ios fn calls 515 * If a MMC dual voltage card is detected, the set_ios fn calls
490 * this fn with VDD bit set for 1.8V. Upon card removal from the 516 * this fn with VDD bit set for 1.8V. Upon card removal from the
491 * slot, omap_mmc_set_ios sets the VDD back to 3V on MMC_POWER_OFF. 517 * slot, omap_mmc_set_ios sets the VDD back to 3V on MMC_POWER_OFF.
492 * 518 *
493 * Only MMC1 supports 3.0V. MMC2 will not function if SDVS30 is 519 * Cope with a bit of slop in the range ... per data sheets:
494 * set in HCTL. 520 * - "1.8V" for vdds_mmc1/vdds_mmc1a can be up to 2.45V max,
521 * but recommended values are 1.71V to 1.89V
522 * - "3.0V" for vdds_mmc1/vdds_mmc1a can be up to 3.5V max,
523 * but recommended values are 2.7V to 3.3V
524 *
525 * Board setup code shouldn't permit anything very out-of-range.
526 * TWL4030-family VMMC1 and VSIM regulators are fine (avoiding the
527 * middle range) but VSIM can't power DAT4..DAT7 at more than 3V.
495 */ 528 */
496 if (host->id == OMAP_MMC1_DEVID && (((1 << vdd) == MMC_VDD_32_33) || 529 if ((1 << vdd) <= MMC_VDD_23_24)
497 ((1 << vdd) == MMC_VDD_33_34)))
498 reg_val |= SDVS30;
499 if ((1 << vdd) == MMC_VDD_165_195)
500 reg_val |= SDVS18; 530 reg_val |= SDVS18;
531 else
532 reg_val |= SDVS30;
501 533
502 OMAP_HSMMC_WRITE(host->base, HCTL, reg_val); 534 OMAP_HSMMC_WRITE(host->base, HCTL, reg_val);
503 535
@@ -517,16 +549,15 @@ static void mmc_omap_detect(struct work_struct *work)
517{ 549{
518 struct mmc_omap_host *host = container_of(work, struct mmc_omap_host, 550 struct mmc_omap_host *host = container_of(work, struct mmc_omap_host,
519 mmc_carddetect_work); 551 mmc_carddetect_work);
552 struct omap_mmc_slot_data *slot = &mmc_slot(host);
553
554 host->carddetect = slot->card_detect(slot->card_detect_irq);
520 555
521 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); 556 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
522 if (host->carddetect) { 557 if (host->carddetect) {
523 mmc_detect_change(host->mmc, (HZ * 200) / 1000); 558 mmc_detect_change(host->mmc, (HZ * 200) / 1000);
524 } else { 559 } else {
525 OMAP_HSMMC_WRITE(host->base, SYSCTL, 560 mmc_omap_reset_controller_fsm(host, SRD);
526 OMAP_HSMMC_READ(host->base, SYSCTL) | SRD);
527 while (OMAP_HSMMC_READ(host->base, SYSCTL) & SRD)
528 ;
529
530 mmc_detect_change(host->mmc, (HZ * 50) / 1000); 561 mmc_detect_change(host->mmc, (HZ * 50) / 1000);
531 } 562 }
532} 563}
@@ -538,7 +569,6 @@ static irqreturn_t omap_mmc_cd_handler(int irq, void *dev_id)
538{ 569{
539 struct mmc_omap_host *host = (struct mmc_omap_host *)dev_id; 570 struct mmc_omap_host *host = (struct mmc_omap_host *)dev_id;
540 571
541 host->carddetect = mmc_slot(host).card_detect(irq);
542 schedule_work(&host->mmc_carddetect_work); 572 schedule_work(&host->mmc_carddetect_work);
543 573
544 return IRQ_HANDLED; 574 return IRQ_HANDLED;
@@ -757,10 +787,14 @@ static void omap_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
757 case MMC_POWER_OFF: 787 case MMC_POWER_OFF:
758 mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0); 788 mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
759 /* 789 /*
760 * Reset bus voltage to 3V if it got set to 1.8V earlier. 790 * Reset interface voltage to 3V if it's 1.8V now;
791 * only relevant on MMC-1, the others always use 1.8V.
792 *
761 * REVISIT: If we are able to detect cards after unplugging 793 * REVISIT: If we are able to detect cards after unplugging
762 * a 1.8V card, this code should not be needed. 794 * a 1.8V card, this code should not be needed.
763 */ 795 */
796 if (host->id != OMAP_MMC1_DEVID)
797 break;
764 if (!(OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET)) { 798 if (!(OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET)) {
765 int vdd = fls(host->mmc->ocr_avail) - 1; 799 int vdd = fls(host->mmc->ocr_avail) - 1;
766 if (omap_mmc_switch_opcond(host, vdd) != 0) 800 if (omap_mmc_switch_opcond(host, vdd) != 0)
@@ -784,7 +818,9 @@ static void omap_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
784 } 818 }
785 819
786 if (host->id == OMAP_MMC1_DEVID) { 820 if (host->id == OMAP_MMC1_DEVID) {
787 /* Only MMC1 can operate at 3V/1.8V */ 821 /* Only MMC1 can interface at 3V without some flavor
822 * of external transceiver; but they all handle 1.8V.
823 */
788 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && 824 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
789 (ios->vdd == DUAL_VOLT_OCR_BIT)) { 825 (ios->vdd == DUAL_VOLT_OCR_BIT)) {
790 /* 826 /*
@@ -1137,7 +1173,9 @@ static int omap_mmc_suspend(struct platform_device *pdev, pm_message_t state)
1137 " level suspend\n"); 1173 " level suspend\n");
1138 } 1174 }
1139 1175
1140 if (!(OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET)) { 1176 if (host->id == OMAP_MMC1_DEVID
1177 && !(OMAP_HSMMC_READ(host->base, HCTL)
1178 & SDVSDET)) {
1141 OMAP_HSMMC_WRITE(host->base, HCTL, 1179 OMAP_HSMMC_WRITE(host->base, HCTL,
1142 OMAP_HSMMC_READ(host->base, HCTL) 1180 OMAP_HSMMC_READ(host->base, HCTL)
1143 & SDVSCLR); 1181 & SDVSCLR);
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
index 35a98eec7414..f4a67c65d301 100644
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -329,7 +329,7 @@ static void do_pio_write(struct s3cmci_host *host)
329 329
330 to_ptr = host->base + host->sdidata; 330 to_ptr = host->base + host->sdidata;
331 331
332 while ((fifo = fifo_free(host))) { 332 while ((fifo = fifo_free(host)) > 3) {
333 if (!host->pio_bytes) { 333 if (!host->pio_bytes) {
334 res = get_data_buffer(host, &host->pio_bytes, 334 res = get_data_buffer(host, &host->pio_bytes,
335 &host->pio_ptr); 335 &host->pio_ptr);
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index f07255cb17ee..8cff5f5e7f86 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -144,8 +144,7 @@ static int jmicron_probe(struct sdhci_pci_chip *chip)
144 SDHCI_QUIRK_32BIT_DMA_SIZE | 144 SDHCI_QUIRK_32BIT_DMA_SIZE |
145 SDHCI_QUIRK_32BIT_ADMA_SIZE | 145 SDHCI_QUIRK_32BIT_ADMA_SIZE |
146 SDHCI_QUIRK_RESET_AFTER_REQUEST | 146 SDHCI_QUIRK_RESET_AFTER_REQUEST |
147 SDHCI_QUIRK_BROKEN_SMALL_PIO | 147 SDHCI_QUIRK_BROKEN_SMALL_PIO;
148 SDHCI_QUIRK_FORCE_HIGHSPEED;
149 } 148 }
150 149
151 /* 150 /*
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6b2d1f99af67..f52f3053ed92 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1636,8 +1636,7 @@ int sdhci_add_host(struct sdhci_host *host)
1636 mmc->f_max = host->max_clk; 1636 mmc->f_max = host->max_clk;
1637 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ; 1637 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;
1638 1638
1639 if ((caps & SDHCI_CAN_DO_HISPD) || 1639 if (caps & SDHCI_CAN_DO_HISPD)
1640 (host->quirks & SDHCI_QUIRK_FORCE_HIGHSPEED))
1641 mmc->caps |= MMC_CAP_SD_HIGHSPEED; 1640 mmc->caps |= MMC_CAP_SD_HIGHSPEED;
1642 1641
1643 mmc->ocr_avail = 0; 1642 mmc->ocr_avail = 0;
@@ -1723,7 +1722,9 @@ int sdhci_add_host(struct sdhci_host *host)
1723#endif 1722#endif
1724 1723
1725#ifdef SDHCI_USE_LEDS_CLASS 1724#ifdef SDHCI_USE_LEDS_CLASS
1726 host->led.name = mmc_hostname(mmc); 1725 snprintf(host->led_name, sizeof(host->led_name),
1726 "%s::", mmc_hostname(mmc));
1727 host->led.name = host->led_name;
1727 host->led.brightness = LED_OFF; 1728 host->led.brightness = LED_OFF;
1728 host->led.default_trigger = mmc_hostname(mmc); 1729 host->led.default_trigger = mmc_hostname(mmc);
1729 host->led.brightness_set = sdhci_led_control; 1730 host->led.brightness_set = sdhci_led_control;
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 3efba2363941..ebb83657e27a 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -208,8 +208,6 @@ struct sdhci_host {
208#define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12) 208#define SDHCI_QUIRK_BROKEN_TIMEOUT_VAL (1<<12)
209/* Controller has an issue with buffer bits for small transfers */ 209/* Controller has an issue with buffer bits for small transfers */
210#define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13) 210#define SDHCI_QUIRK_BROKEN_SMALL_PIO (1<<13)
211/* Controller supports high speed but doesn't have the caps bit set */
212#define SDHCI_QUIRK_FORCE_HIGHSPEED (1<<14)
213 211
214 int irq; /* Device IRQ */ 212 int irq; /* Device IRQ */
215 void __iomem * ioaddr; /* Mapped address */ 213 void __iomem * ioaddr; /* Mapped address */
@@ -222,6 +220,7 @@ struct sdhci_host {
222 220
223#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 221#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
224 struct led_classdev led; /* LED control */ 222 struct led_classdev led; /* LED control */
223 char led_name[32];
225#endif 224#endif
226 225
227 spinlock_t lock; /* Mutex */ 226 spinlock_t lock; /* Mutex */
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index 7df6bbf0e4d9..6f6a0f6dafd6 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -453,7 +453,7 @@ static struct platform_driver sa1100_mtd_driver = {
453 .resume = sa1100_mtd_resume, 453 .resume = sa1100_mtd_resume,
454 .shutdown = sa1100_mtd_shutdown, 454 .shutdown = sa1100_mtd_shutdown,
455 .driver = { 455 .driver = {
456 .name = "flash", 456 .name = "sa1100-mtd",
457 .owner = THIS_MODULE, 457 .owner = THIS_MODULE,
458 }, 458 },
459}; 459};
@@ -474,4 +474,4 @@ module_exit(sa1100_mtd_exit);
474MODULE_AUTHOR("Nicolas Pitre"); 474MODULE_AUTHOR("Nicolas Pitre");
475MODULE_DESCRIPTION("SA1100 CFI map driver"); 475MODULE_DESCRIPTION("SA1100 CFI map driver");
476MODULE_LICENSE("GPL"); 476MODULE_LICENSE("GPL");
477MODULE_ALIAS("platform:flash"); 477MODULE_ALIAS("platform:sa1100-mtd");
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index c98c1570a40b..47a33cec3793 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -139,7 +139,8 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
139 struct nand_chip *nand_chip = mtd->priv; 139 struct nand_chip *nand_chip = mtd->priv;
140 struct atmel_nand_host *host = nand_chip->priv; 140 struct atmel_nand_host *host = nand_chip->priv;
141 141
142 return gpio_get_value(host->board->rdy_pin); 142 return gpio_get_value(host->board->rdy_pin) ^
143 !!host->board->rdy_pin_active_low;
143} 144}
144 145
145/* 146/*
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index d15d8b79d8e5..54b52e5b1821 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -646,7 +646,7 @@ static const struct net_device_ops etherh_netdev_ops = {
646 .ndo_get_stats = ei_get_stats, 646 .ndo_get_stats = ei_get_stats,
647 .ndo_set_multicast_list = ei_set_multicast_list, 647 .ndo_set_multicast_list = ei_set_multicast_list,
648 .ndo_validate_addr = eth_validate_addr, 648 .ndo_validate_addr = eth_validate_addr,
649 .ndo_set_mac_address = eth_set_mac_addr, 649 .ndo_set_mac_address = eth_mac_addr,
650 .ndo_change_mtu = eth_change_mtu, 650 .ndo_change_mtu = eth_change_mtu,
651#ifdef CONFIG_NET_POLL_CONTROLLER 651#ifdef CONFIG_NET_POLL_CONTROLLER
652 .ndo_poll_controller = ei_poll, 652 .ndo_poll_controller = ei_poll,
diff --git a/drivers/parport/parport_atari.c b/drivers/parport/parport_atari.c
index ad4cdd256137..0b28fccec03f 100644
--- a/drivers/parport/parport_atari.c
+++ b/drivers/parport/parport_atari.c
@@ -84,7 +84,7 @@ parport_atari_frob_control(struct parport *p, unsigned char mask,
84static unsigned char 84static unsigned char
85parport_atari_read_status(struct parport *p) 85parport_atari_read_status(struct parport *p)
86{ 86{
87 return ((mfp.par_dt_reg & 1 ? 0 : PARPORT_STATUS_BUSY) | 87 return ((st_mfp.par_dt_reg & 1 ? 0 : PARPORT_STATUS_BUSY) |
88 PARPORT_STATUS_SELECT | PARPORT_STATUS_ERROR); 88 PARPORT_STATUS_SELECT | PARPORT_STATUS_ERROR);
89} 89}
90 90
@@ -193,9 +193,9 @@ static int __init parport_atari_init(void)
193 sound_ym.wd_data = sound_ym.rd_data_reg_sel | (1 << 5); 193 sound_ym.wd_data = sound_ym.rd_data_reg_sel | (1 << 5);
194 local_irq_restore(flags); 194 local_irq_restore(flags);
195 /* MFP port I0 as input. */ 195 /* MFP port I0 as input. */
196 mfp.data_dir &= ~1; 196 st_mfp.data_dir &= ~1;
197 /* MFP port I0 interrupt on high->low edge. */ 197 /* MFP port I0 interrupt on high->low edge. */
198 mfp.active_edge &= ~1; 198 st_mfp.active_edge &= ~1;
199 p = parport_register_port((unsigned long)&sound_ym.wd_data, 199 p = parport_register_port((unsigned long)&sound_ym.wd_data,
200 IRQ_MFP_BUSY, PARPORT_DMA_NONE, 200 IRQ_MFP_BUSY, PARPORT_DMA_NONE,
201 &parport_atari_ops); 201 &parport_atari_ops);
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 101ed49a2d15..032db815b0f9 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -64,6 +64,11 @@ struct parport_pc_pci {
64 64
65static int __devinit netmos_parallel_init(struct pci_dev *dev, struct parport_pc_pci *card, int autoirq, int autodma) 65static int __devinit netmos_parallel_init(struct pci_dev *dev, struct parport_pc_pci *card, int autoirq, int autodma)
66{ 66{
67 /* the rule described below doesn't hold for this device */
68 if (dev->device == PCI_DEVICE_ID_NETMOS_9835 &&
69 dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
70 dev->subsystem_device == 0x0299)
71 return -ENODEV;
67 /* 72 /*
68 * Netmos uses the subdevice ID to indicate the number of parallel 73 * Netmos uses the subdevice ID to indicate the number of parallel
69 * and serial ports. The form is 0x00PS, where <P> is the number of 74 * and serial ports. The form is 0x00PS, where <P> is the number of
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 3dfecb20d5e7..f3f686581a90 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -61,6 +61,8 @@
61/* global iommu list, set NULL for ignored DMAR units */ 61/* global iommu list, set NULL for ignored DMAR units */
62static struct intel_iommu **g_iommus; 62static struct intel_iommu **g_iommus;
63 63
64static int rwbf_quirk;
65
64/* 66/*
65 * 0: Present 67 * 0: Present
66 * 1-11: Reserved 68 * 1-11: Reserved
@@ -268,7 +270,12 @@ static long list_size;
268 270
269static void domain_remove_dev_info(struct dmar_domain *domain); 271static void domain_remove_dev_info(struct dmar_domain *domain);
270 272
271int dmar_disabled; 273#ifdef CONFIG_DMAR_DEFAULT_ON
274int dmar_disabled = 0;
275#else
276int dmar_disabled = 1;
277#endif /*CONFIG_DMAR_DEFAULT_ON*/
278
272static int __initdata dmar_map_gfx = 1; 279static int __initdata dmar_map_gfx = 1;
273static int dmar_forcedac; 280static int dmar_forcedac;
274static int intel_iommu_strict; 281static int intel_iommu_strict;
@@ -284,9 +291,12 @@ static int __init intel_iommu_setup(char *str)
284 if (!str) 291 if (!str)
285 return -EINVAL; 292 return -EINVAL;
286 while (*str) { 293 while (*str) {
287 if (!strncmp(str, "off", 3)) { 294 if (!strncmp(str, "on", 2)) {
295 dmar_disabled = 0;
296 printk(KERN_INFO "Intel-IOMMU: enabled\n");
297 } else if (!strncmp(str, "off", 3)) {
288 dmar_disabled = 1; 298 dmar_disabled = 1;
289 printk(KERN_INFO"Intel-IOMMU: disabled\n"); 299 printk(KERN_INFO "Intel-IOMMU: disabled\n");
290 } else if (!strncmp(str, "igfx_off", 8)) { 300 } else if (!strncmp(str, "igfx_off", 8)) {
291 dmar_map_gfx = 0; 301 dmar_map_gfx = 0;
292 printk(KERN_INFO 302 printk(KERN_INFO
@@ -777,7 +787,7 @@ static void iommu_flush_write_buffer(struct intel_iommu *iommu)
777 u32 val; 787 u32 val;
778 unsigned long flag; 788 unsigned long flag;
779 789
780 if (!cap_rwbf(iommu->cap)) 790 if (!rwbf_quirk && !cap_rwbf(iommu->cap))
781 return; 791 return;
782 val = iommu->gcmd | DMA_GCMD_WBF; 792 val = iommu->gcmd | DMA_GCMD_WBF;
783 793
@@ -3129,3 +3139,15 @@ static struct iommu_ops intel_iommu_ops = {
3129 .unmap = intel_iommu_unmap_range, 3139 .unmap = intel_iommu_unmap_range,
3130 .iova_to_phys = intel_iommu_iova_to_phys, 3140 .iova_to_phys = intel_iommu_iova_to_phys,
3131}; 3141};
3142
3143static void __devinit quirk_iommu_rwbf(struct pci_dev *dev)
3144{
3145 /*
3146 * Mobile 4 Series Chipset neglects to set RWBF capability,
3147 * but needs it:
3148 */
3149 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n");
3150 rwbf_quirk = 1;
3151}
3152
3153DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 44f15ff70c1d..baba2eb5367d 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -103,14 +103,12 @@ static void msix_set_enable(struct pci_dev *dev, int enable)
103 } 103 }
104} 104}
105 105
106/*
107 * Essentially, this is ((1 << (1 << x)) - 1), but without the
108 * undefinedness of a << 32.
109 */
110static inline __attribute_const__ u32 msi_mask(unsigned x) 106static inline __attribute_const__ u32 msi_mask(unsigned x)
111{ 107{
112 static const u32 mask[] = { 1, 2, 4, 0xf, 0xff, 0xffff, 0xffffffff }; 108 /* Don't shift by >= width of type */
113 return mask[x]; 109 if (x >= 5)
110 return 0xffffffff;
111 return (1 << (1 << x)) - 1;
114} 112}
115 113
116static void msix_flush_writes(struct irq_desc *desc) 114static void msix_flush_writes(struct irq_desc *desc)
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index ab1d615425a8..93eac1423585 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -355,6 +355,8 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
355 int i = 0; 355 int i = 0;
356 356
357 if (drv && drv->suspend) { 357 if (drv && drv->suspend) {
358 pci_power_t prev = pci_dev->current_state;
359
358 pci_dev->state_saved = false; 360 pci_dev->state_saved = false;
359 361
360 i = drv->suspend(pci_dev, state); 362 i = drv->suspend(pci_dev, state);
@@ -365,12 +367,16 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
365 if (pci_dev->state_saved) 367 if (pci_dev->state_saved)
366 goto Fixup; 368 goto Fixup;
367 369
368 if (WARN_ON_ONCE(pci_dev->current_state != PCI_D0)) 370 if (pci_dev->current_state != PCI_D0
371 && pci_dev->current_state != PCI_UNKNOWN) {
372 WARN_ONCE(pci_dev->current_state != prev,
373 "PCI PM: Device state not saved by %pF\n",
374 drv->suspend);
369 goto Fixup; 375 goto Fixup;
376 }
370 } 377 }
371 378
372 pci_save_state(pci_dev); 379 pci_save_state(pci_dev);
373 pci_dev->state_saved = true;
374 /* 380 /*
375 * This is for compatibility with existing code with legacy PM support. 381 * This is for compatibility with existing code with legacy PM support.
376 */ 382 */
@@ -424,35 +430,20 @@ static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
424 pci_fixup_device(pci_fixup_resume_early, pci_dev); 430 pci_fixup_device(pci_fixup_resume_early, pci_dev);
425} 431}
426 432
427static int pci_pm_default_resume(struct pci_dev *pci_dev) 433static void pci_pm_default_resume(struct pci_dev *pci_dev)
428{ 434{
429 pci_fixup_device(pci_fixup_resume, pci_dev); 435 pci_fixup_device(pci_fixup_resume, pci_dev);
430 436
431 if (!pci_is_bridge(pci_dev)) 437 if (!pci_is_bridge(pci_dev))
432 pci_enable_wake(pci_dev, PCI_D0, false); 438 pci_enable_wake(pci_dev, PCI_D0, false);
433
434 return pci_pm_reenable_device(pci_dev);
435}
436
437static void pci_pm_default_suspend_generic(struct pci_dev *pci_dev)
438{
439 /* If device is enabled at this point, disable it */
440 pci_disable_enabled_device(pci_dev);
441 /*
442 * Save state with interrupts enabled, because in principle the bus the
443 * device is on may be put into a low power state after this code runs.
444 */
445 pci_save_state(pci_dev);
446} 439}
447 440
448static void pci_pm_default_suspend(struct pci_dev *pci_dev) 441static void pci_pm_default_suspend(struct pci_dev *pci_dev)
449{ 442{
450 pci_pm_default_suspend_generic(pci_dev); 443 /* Disable non-bridge devices without PM support */
451
452 if (!pci_is_bridge(pci_dev)) 444 if (!pci_is_bridge(pci_dev))
453 pci_prepare_to_sleep(pci_dev); 445 pci_disable_enabled_device(pci_dev);
454 446 pci_save_state(pci_dev);
455 pci_fixup_device(pci_fixup_suspend, pci_dev);
456} 447}
457 448
458static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) 449static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
@@ -497,21 +488,49 @@ static void pci_pm_complete(struct device *dev)
497static int pci_pm_suspend(struct device *dev) 488static int pci_pm_suspend(struct device *dev)
498{ 489{
499 struct pci_dev *pci_dev = to_pci_dev(dev); 490 struct pci_dev *pci_dev = to_pci_dev(dev);
500 struct device_driver *drv = dev->driver; 491 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
501 int error = 0;
502 492
503 if (pci_has_legacy_pm_support(pci_dev)) 493 if (pci_has_legacy_pm_support(pci_dev))
504 return pci_legacy_suspend(dev, PMSG_SUSPEND); 494 return pci_legacy_suspend(dev, PMSG_SUSPEND);
505 495
506 if (drv && drv->pm && drv->pm->suspend) { 496 if (!pm) {
507 error = drv->pm->suspend(dev); 497 pci_pm_default_suspend(pci_dev);
508 suspend_report_result(drv->pm->suspend, error); 498 goto Fixup;
509 } 499 }
510 500
511 if (!error) 501 pci_dev->state_saved = false;
512 pci_pm_default_suspend(pci_dev);
513 502
514 return error; 503 if (pm->suspend) {
504 pci_power_t prev = pci_dev->current_state;
505 int error;
506
507 error = pm->suspend(dev);
508 suspend_report_result(pm->suspend, error);
509 if (error)
510 return error;
511
512 if (pci_dev->state_saved)
513 goto Fixup;
514
515 if (pci_dev->current_state != PCI_D0
516 && pci_dev->current_state != PCI_UNKNOWN) {
517 WARN_ONCE(pci_dev->current_state != prev,
518 "PCI PM: State of device not saved by %pF\n",
519 pm->suspend);
520 goto Fixup;
521 }
522 }
523
524 if (!pci_dev->state_saved) {
525 pci_save_state(pci_dev);
526 if (!pci_is_bridge(pci_dev))
527 pci_prepare_to_sleep(pci_dev);
528 }
529
530 Fixup:
531 pci_fixup_device(pci_fixup_suspend, pci_dev);
532
533 return 0;
515} 534}
516 535
517static int pci_pm_suspend_noirq(struct device *dev) 536static int pci_pm_suspend_noirq(struct device *dev)
@@ -554,7 +573,7 @@ static int pci_pm_resume_noirq(struct device *dev)
554static int pci_pm_resume(struct device *dev) 573static int pci_pm_resume(struct device *dev)
555{ 574{
556 struct pci_dev *pci_dev = to_pci_dev(dev); 575 struct pci_dev *pci_dev = to_pci_dev(dev);
557 struct device_driver *drv = dev->driver; 576 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
558 int error = 0; 577 int error = 0;
559 578
560 /* 579 /*
@@ -567,12 +586,16 @@ static int pci_pm_resume(struct device *dev)
567 if (pci_has_legacy_pm_support(pci_dev)) 586 if (pci_has_legacy_pm_support(pci_dev))
568 return pci_legacy_resume(dev); 587 return pci_legacy_resume(dev);
569 588
570 error = pci_pm_default_resume(pci_dev); 589 pci_pm_default_resume(pci_dev);
571 590
572 if (!error && drv && drv->pm && drv->pm->resume) 591 if (pm) {
573 error = drv->pm->resume(dev); 592 if (pm->resume)
593 error = pm->resume(dev);
594 } else {
595 pci_pm_reenable_device(pci_dev);
596 }
574 597
575 return error; 598 return 0;
576} 599}
577 600
578#else /* !CONFIG_SUSPEND */ 601#else /* !CONFIG_SUSPEND */
@@ -589,21 +612,31 @@ static int pci_pm_resume(struct device *dev)
589static int pci_pm_freeze(struct device *dev) 612static int pci_pm_freeze(struct device *dev)
590{ 613{
591 struct pci_dev *pci_dev = to_pci_dev(dev); 614 struct pci_dev *pci_dev = to_pci_dev(dev);
592 struct device_driver *drv = dev->driver; 615 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
593 int error = 0;
594 616
595 if (pci_has_legacy_pm_support(pci_dev)) 617 if (pci_has_legacy_pm_support(pci_dev))
596 return pci_legacy_suspend(dev, PMSG_FREEZE); 618 return pci_legacy_suspend(dev, PMSG_FREEZE);
597 619
598 if (drv && drv->pm && drv->pm->freeze) { 620 if (!pm) {
599 error = drv->pm->freeze(dev); 621 pci_pm_default_suspend(pci_dev);
600 suspend_report_result(drv->pm->freeze, error); 622 return 0;
601 } 623 }
602 624
603 if (!error) 625 pci_dev->state_saved = false;
604 pci_pm_default_suspend_generic(pci_dev);
605 626
606 return error; 627 if (pm->freeze) {
628 int error;
629
630 error = pm->freeze(dev);
631 suspend_report_result(pm->freeze, error);
632 if (error)
633 return error;
634 }
635
636 if (!pci_dev->state_saved)
637 pci_save_state(pci_dev);
638
639 return 0;
607} 640}
608 641
609static int pci_pm_freeze_noirq(struct device *dev) 642static int pci_pm_freeze_noirq(struct device *dev)
@@ -646,16 +679,18 @@ static int pci_pm_thaw_noirq(struct device *dev)
646static int pci_pm_thaw(struct device *dev) 679static int pci_pm_thaw(struct device *dev)
647{ 680{
648 struct pci_dev *pci_dev = to_pci_dev(dev); 681 struct pci_dev *pci_dev = to_pci_dev(dev);
649 struct device_driver *drv = dev->driver; 682 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
650 int error = 0; 683 int error = 0;
651 684
652 if (pci_has_legacy_pm_support(pci_dev)) 685 if (pci_has_legacy_pm_support(pci_dev))
653 return pci_legacy_resume(dev); 686 return pci_legacy_resume(dev);
654 687
655 pci_pm_reenable_device(pci_dev); 688 if (pm) {
656 689 if (pm->thaw)
657 if (drv && drv->pm && drv->pm->thaw) 690 error = pm->thaw(dev);
658 error = drv->pm->thaw(dev); 691 } else {
692 pci_pm_reenable_device(pci_dev);
693 }
659 694
660 return error; 695 return error;
661} 696}
@@ -663,22 +698,29 @@ static int pci_pm_thaw(struct device *dev)
663static int pci_pm_poweroff(struct device *dev) 698static int pci_pm_poweroff(struct device *dev)
664{ 699{
665 struct pci_dev *pci_dev = to_pci_dev(dev); 700 struct pci_dev *pci_dev = to_pci_dev(dev);
666 struct device_driver *drv = dev->driver; 701 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
667 int error = 0; 702 int error = 0;
668 703
669 if (pci_has_legacy_pm_support(pci_dev)) 704 if (pci_has_legacy_pm_support(pci_dev))
670 return pci_legacy_suspend(dev, PMSG_HIBERNATE); 705 return pci_legacy_suspend(dev, PMSG_HIBERNATE);
671 706
672 if (!drv || !drv->pm) 707 if (!pm) {
673 return 0; 708 pci_pm_default_suspend(pci_dev);
709 goto Fixup;
710 }
711
712 pci_dev->state_saved = false;
674 713
675 if (drv->pm->poweroff) { 714 if (pm->poweroff) {
676 error = drv->pm->poweroff(dev); 715 error = pm->poweroff(dev);
677 suspend_report_result(drv->pm->poweroff, error); 716 suspend_report_result(pm->poweroff, error);
678 } 717 }
679 718
680 if (!error) 719 if (!pci_dev->state_saved && !pci_is_bridge(pci_dev))
681 pci_pm_default_suspend(pci_dev); 720 pci_prepare_to_sleep(pci_dev);
721
722 Fixup:
723 pci_fixup_device(pci_fixup_suspend, pci_dev);
682 724
683 return error; 725 return error;
684} 726}
@@ -719,7 +761,7 @@ static int pci_pm_restore_noirq(struct device *dev)
719static int pci_pm_restore(struct device *dev) 761static int pci_pm_restore(struct device *dev)
720{ 762{
721 struct pci_dev *pci_dev = to_pci_dev(dev); 763 struct pci_dev *pci_dev = to_pci_dev(dev);
722 struct device_driver *drv = dev->driver; 764 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
723 int error = 0; 765 int error = 0;
724 766
725 /* 767 /*
@@ -732,10 +774,14 @@ static int pci_pm_restore(struct device *dev)
732 if (pci_has_legacy_pm_support(pci_dev)) 774 if (pci_has_legacy_pm_support(pci_dev))
733 return pci_legacy_resume(dev); 775 return pci_legacy_resume(dev);
734 776
735 error = pci_pm_default_resume(pci_dev); 777 pci_pm_default_resume(pci_dev);
736 778
737 if (!error && drv && drv->pm && drv->pm->restore) 779 if (pm) {
738 error = drv->pm->restore(dev); 780 if (pm->restore)
781 error = pm->restore(dev);
782 } else {
783 pci_pm_reenable_device(pci_dev);
784 }
739 785
740 return error; 786 return error;
741} 787}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index db7ec14fa719..dfc4e0ddf241 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -768,8 +768,8 @@ pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr,
768 return -EINVAL; 768 return -EINVAL;
769 769
770 rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */ 770 rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */
771 if (!rom) 771 if (!rom || !size)
772 return 0; 772 return -EIO;
773 773
774 if (off >= size) 774 if (off >= size)
775 count = 0; 775 count = 0;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 48807556b47a..6d6120007af4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1418,10 +1418,10 @@ int pci_restore_standard_config(struct pci_dev *dev)
1418 break; 1418 break;
1419 } 1419 }
1420 1420
1421 dev->current_state = PCI_D0; 1421 pci_update_current_state(dev, PCI_D0);
1422 1422
1423 Restore: 1423 Restore:
1424 return pci_restore_state(dev); 1424 return dev->state_saved ? pci_restore_state(dev) : 0;
1425} 1425}
1426 1426
1427/** 1427/**
@@ -1540,16 +1540,21 @@ void pci_release_region(struct pci_dev *pdev, int bar)
1540} 1540}
1541 1541
1542/** 1542/**
1543 * pci_request_region - Reserved PCI I/O and memory resource 1543 * __pci_request_region - Reserved PCI I/O and memory resource
1544 * @pdev: PCI device whose resources are to be reserved 1544 * @pdev: PCI device whose resources are to be reserved
1545 * @bar: BAR to be reserved 1545 * @bar: BAR to be reserved
1546 * @res_name: Name to be associated with resource. 1546 * @res_name: Name to be associated with resource.
1547 * @exclusive: whether the region access is exclusive or not
1547 * 1548 *
1548 * Mark the PCI region associated with PCI device @pdev BR @bar as 1549 * Mark the PCI region associated with PCI device @pdev BR @bar as
1549 * being reserved by owner @res_name. Do not access any 1550 * being reserved by owner @res_name. Do not access any
1550 * address inside the PCI regions unless this call returns 1551 * address inside the PCI regions unless this call returns
1551 * successfully. 1552 * successfully.
1552 * 1553 *
1554 * If @exclusive is set, then the region is marked so that userspace
1555 * is explicitly not allowed to map the resource via /dev/mem or
1556 * sysfs MMIO access.
1557 *
1553 * Returns 0 on success, or %EBUSY on error. A warning 1558 * Returns 0 on success, or %EBUSY on error. A warning
1554 * message is also printed on failure. 1559 * message is also printed on failure.
1555 */ 1560 */
@@ -1588,12 +1593,12 @@ err_out:
1588} 1593}
1589 1594
1590/** 1595/**
1591 * pci_request_region - Reserved PCI I/O and memory resource 1596 * pci_request_region - Reserve PCI I/O and memory resource
1592 * @pdev: PCI device whose resources are to be reserved 1597 * @pdev: PCI device whose resources are to be reserved
1593 * @bar: BAR to be reserved 1598 * @bar: BAR to be reserved
1594 * @res_name: Name to be associated with resource. 1599 * @res_name: Name to be associated with resource
1595 * 1600 *
1596 * Mark the PCI region associated with PCI device @pdev BR @bar as 1601 * Mark the PCI region associated with PCI device @pdev BAR @bar as
1597 * being reserved by owner @res_name. Do not access any 1602 * being reserved by owner @res_name. Do not access any
1598 * address inside the PCI regions unless this call returns 1603 * address inside the PCI regions unless this call returns
1599 * successfully. 1604 * successfully.
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 26ddf78ac300..07c0aa5275e6 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -16,21 +16,21 @@ extern int pci_mmap_fits(struct pci_dev *pdev, int resno,
16#endif 16#endif
17 17
18/** 18/**
19 * Firmware PM callbacks 19 * struct pci_platform_pm_ops - Firmware PM callbacks
20 * 20 *
21 * @is_manageable - returns 'true' if given device is power manageable by the 21 * @is_manageable: returns 'true' if given device is power manageable by the
22 * platform firmware 22 * platform firmware
23 * 23 *
24 * @set_state - invokes the platform firmware to set the device's power state 24 * @set_state: invokes the platform firmware to set the device's power state
25 * 25 *
26 * @choose_state - returns PCI power state of given device preferred by the 26 * @choose_state: returns PCI power state of given device preferred by the
27 * platform; to be used during system-wide transitions from a 27 * platform; to be used during system-wide transitions from a
28 * sleeping state to the working state and vice versa 28 * sleeping state to the working state and vice versa
29 * 29 *
30 * @can_wakeup - returns 'true' if given device is capable of waking up the 30 * @can_wakeup: returns 'true' if given device is capable of waking up the
31 * system from a sleeping state 31 * system from a sleeping state
32 * 32 *
33 * @sleep_wake - enables/disables the system wake up capability of given device 33 * @sleep_wake: enables/disables the system wake up capability of given device
34 * 34 *
35 * If given platform is generally capable of power managing PCI devices, all of 35 * If given platform is generally capable of power managing PCI devices, all of
36 * these callbacks are mandatory. 36 * these callbacks are mandatory.
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 586b6f75910d..b0367f168af4 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -718,9 +718,9 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
718 718
719 /* 719 /*
720 * All PCIe functions are in one slot, remove one function will remove 720 * All PCIe functions are in one slot, remove one function will remove
721 * the the whole slot, so just wait 721 * the whole slot, so just wait until we are the last function left.
722 */ 722 */
723 if (!list_empty(&parent->subordinate->devices)) 723 if (!list_is_last(&pdev->bus_list, &parent->subordinate->devices))
724 goto out; 724 goto out;
725 725
726 /* All functions are removed, so just disable ASPM for the link */ 726 /* All functions are removed, so just disable ASPM for the link */
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 99a914a027f8..f9b874eaeb9f 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -55,25 +55,13 @@ static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state)
55 55
56} 56}
57 57
58static int pcie_portdrv_suspend_late(struct pci_dev *dev, pm_message_t state)
59{
60 return pci_save_state(dev);
61}
62
63static int pcie_portdrv_resume_early(struct pci_dev *dev)
64{
65 return pci_restore_state(dev);
66}
67
68static int pcie_portdrv_resume(struct pci_dev *dev) 58static int pcie_portdrv_resume(struct pci_dev *dev)
69{ 59{
70 pcie_portdrv_restore_config(dev); 60 pci_set_master(dev);
71 return pcie_port_device_resume(dev); 61 return pcie_port_device_resume(dev);
72} 62}
73#else 63#else
74#define pcie_portdrv_suspend NULL 64#define pcie_portdrv_suspend NULL
75#define pcie_portdrv_suspend_late NULL
76#define pcie_portdrv_resume_early NULL
77#define pcie_portdrv_resume NULL 65#define pcie_portdrv_resume NULL
78#endif 66#endif
79 67
@@ -292,8 +280,6 @@ static struct pci_driver pcie_portdriver = {
292 .remove = pcie_portdrv_remove, 280 .remove = pcie_portdrv_remove,
293 281
294 .suspend = pcie_portdrv_suspend, 282 .suspend = pcie_portdrv_suspend,
295 .suspend_late = pcie_portdrv_suspend_late,
296 .resume_early = pcie_portdrv_resume_early,
297 .resume = pcie_portdrv_resume, 283 .resume = pcie_portdrv_resume,
298 284
299 .err_handler = &pcie_portdrv_err_handler, 285 .err_handler = &pcie_portdrv_err_handler,
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 132a78159b60..36864a935d68 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -55,6 +55,7 @@ void pci_disable_rom(struct pci_dev *pdev)
55 55
56/** 56/**
57 * pci_get_rom_size - obtain the actual size of the ROM image 57 * pci_get_rom_size - obtain the actual size of the ROM image
58 * @pdev: target PCI device
58 * @rom: kernel virtual pointer to image of ROM 59 * @rom: kernel virtual pointer to image of ROM
59 * @size: size of PCI window 60 * @size: size of PCI window
60 * return: size of actual ROM image 61 * return: size of actual ROM image
@@ -63,7 +64,7 @@ void pci_disable_rom(struct pci_dev *pdev)
63 * The PCI window size could be much larger than the 64 * The PCI window size could be much larger than the
64 * actual image size. 65 * actual image size.
65 */ 66 */
66size_t pci_get_rom_size(void __iomem *rom, size_t size) 67size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
67{ 68{
68 void __iomem *image; 69 void __iomem *image;
69 int last_image; 70 int last_image;
@@ -72,8 +73,10 @@ size_t pci_get_rom_size(void __iomem *rom, size_t size)
72 do { 73 do {
73 void __iomem *pds; 74 void __iomem *pds;
74 /* Standard PCI ROMs start out with these bytes 55 AA */ 75 /* Standard PCI ROMs start out with these bytes 55 AA */
75 if (readb(image) != 0x55) 76 if (readb(image) != 0x55) {
77 dev_err(&pdev->dev, "Invalid ROM contents\n");
76 break; 78 break;
79 }
77 if (readb(image + 1) != 0xAA) 80 if (readb(image + 1) != 0xAA)
78 break; 81 break;
79 /* get the PCI data structure and check its signature */ 82 /* get the PCI data structure and check its signature */
@@ -159,7 +162,7 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
159 * size is much larger than the actual size of the ROM. 162 * size is much larger than the actual size of the ROM.
160 * True size is important if the ROM is going to be copied. 163 * True size is important if the ROM is going to be copied.
161 */ 164 */
162 *size = pci_get_rom_size(rom, *size); 165 *size = pci_get_rom_size(pdev, rom, *size);
163 return rom; 166 return rom;
164} 167}
165 168
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 1a266d4ab5f1..b3866ad50227 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -42,6 +42,7 @@ config ASUS_LAPTOP
42 depends on LEDS_CLASS 42 depends on LEDS_CLASS
43 depends on NEW_LEDS 43 depends on NEW_LEDS
44 depends on BACKLIGHT_CLASS_DEVICE 44 depends on BACKLIGHT_CLASS_DEVICE
45 depends on INPUT
45 ---help--- 46 ---help---
46 This is the new Linux driver for Asus laptops. It may also support some 47 This is the new Linux driver for Asus laptops. It may also support some
47 MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate 48 MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate
@@ -61,6 +62,7 @@ config DELL_LAPTOP
61 depends on EXPERIMENTAL 62 depends on EXPERIMENTAL
62 depends on BACKLIGHT_CLASS_DEVICE 63 depends on BACKLIGHT_CLASS_DEVICE
63 depends on RFKILL 64 depends on RFKILL
65 depends on POWER_SUPPLY
64 default n 66 default n
65 ---help--- 67 ---help---
66 This driver adds support for rfkill and backlight control to Dell 68 This driver adds support for rfkill and backlight control to Dell
@@ -300,6 +302,7 @@ config INTEL_MENLOW
300config EEEPC_LAPTOP 302config EEEPC_LAPTOP
301 tristate "Eee PC Hotkey Driver (EXPERIMENTAL)" 303 tristate "Eee PC Hotkey Driver (EXPERIMENTAL)"
302 depends on ACPI 304 depends on ACPI
305 depends on INPUT
303 depends on EXPERIMENTAL 306 depends on EXPERIMENTAL
304 select BACKLIGHT_CLASS_DEVICE 307 select BACKLIGHT_CLASS_DEVICE
305 select HWMON 308 select HWMON
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 8fb8b3591048..56af6cf385b0 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -46,6 +46,7 @@
46#include <acpi/acpi_drivers.h> 46#include <acpi/acpi_drivers.h>
47#include <acpi/acpi_bus.h> 47#include <acpi/acpi_bus.h>
48#include <asm/uaccess.h> 48#include <asm/uaccess.h>
49#include <linux/input.h>
49 50
50#define ASUS_LAPTOP_VERSION "0.42" 51#define ASUS_LAPTOP_VERSION "0.42"
51 52
@@ -181,6 +182,8 @@ struct asus_hotk {
181 u8 light_level; //light sensor level 182 u8 light_level; //light sensor level
182 u8 light_switch; //light sensor switch value 183 u8 light_switch; //light sensor switch value
183 u16 event_count[128]; //count for each event TODO make this better 184 u16 event_count[128]; //count for each event TODO make this better
185 struct input_dev *inputdev;
186 u16 *keycode_map;
184}; 187};
185 188
186/* 189/*
@@ -250,6 +253,37 @@ ASUS_LED(rled, "record");
250ASUS_LED(pled, "phone"); 253ASUS_LED(pled, "phone");
251ASUS_LED(gled, "gaming"); 254ASUS_LED(gled, "gaming");
252 255
256struct key_entry {
257 char type;
258 u8 code;
259 u16 keycode;
260};
261
262enum { KE_KEY, KE_END };
263
264static struct key_entry asus_keymap[] = {
265 {KE_KEY, 0x30, KEY_VOLUMEUP},
266 {KE_KEY, 0x31, KEY_VOLUMEDOWN},
267 {KE_KEY, 0x32, KEY_MUTE},
268 {KE_KEY, 0x33, KEY_SWITCHVIDEOMODE},
269 {KE_KEY, 0x34, KEY_SWITCHVIDEOMODE},
270 {KE_KEY, 0x40, KEY_PREVIOUSSONG},
271 {KE_KEY, 0x41, KEY_NEXTSONG},
272 {KE_KEY, 0x43, KEY_STOP},
273 {KE_KEY, 0x45, KEY_PLAYPAUSE},
274 {KE_KEY, 0x50, KEY_EMAIL},
275 {KE_KEY, 0x51, KEY_WWW},
276 {KE_KEY, 0x5C, BTN_EXTRA}, /* Performance */
277 {KE_KEY, 0x5D, KEY_WLAN},
278 {KE_KEY, 0x61, KEY_SWITCHVIDEOMODE},
279 {KE_KEY, 0x6B, BTN_TOUCH}, /* Lock Mouse */
280 {KE_KEY, 0x82, KEY_CAMERA},
281 {KE_KEY, 0x8A, KEY_TV},
282 {KE_KEY, 0x95, KEY_MEDIA},
283 {KE_KEY, 0x99, KEY_PHONE},
284 {KE_END, 0},
285};
286
253/* 287/*
254 * This function evaluates an ACPI method, given an int as parameter, the 288 * This function evaluates an ACPI method, given an int as parameter, the
255 * method is searched within the scope of the handle, can be NULL. The output 289 * method is searched within the scope of the handle, can be NULL. The output
@@ -720,8 +754,68 @@ static ssize_t store_gps(struct device *dev, struct device_attribute *attr,
720 return store_status(buf, count, NULL, GPS_ON); 754 return store_status(buf, count, NULL, GPS_ON);
721} 755}
722 756
757/*
758 * Hotkey functions
759 */
760static struct key_entry *asus_get_entry_by_scancode(int code)
761{
762 struct key_entry *key;
763
764 for (key = asus_keymap; key->type != KE_END; key++)
765 if (code == key->code)
766 return key;
767
768 return NULL;
769}
770
771static struct key_entry *asus_get_entry_by_keycode(int code)
772{
773 struct key_entry *key;
774
775 for (key = asus_keymap; key->type != KE_END; key++)
776 if (code == key->keycode && key->type == KE_KEY)
777 return key;
778
779 return NULL;
780}
781
782static int asus_getkeycode(struct input_dev *dev, int scancode, int *keycode)
783{
784 struct key_entry *key = asus_get_entry_by_scancode(scancode);
785
786 if (key && key->type == KE_KEY) {
787 *keycode = key->keycode;
788 return 0;
789 }
790
791 return -EINVAL;
792}
793
794static int asus_setkeycode(struct input_dev *dev, int scancode, int keycode)
795{
796 struct key_entry *key;
797 int old_keycode;
798
799 if (keycode < 0 || keycode > KEY_MAX)
800 return -EINVAL;
801
802 key = asus_get_entry_by_scancode(scancode);
803 if (key && key->type == KE_KEY) {
804 old_keycode = key->keycode;
805 key->keycode = keycode;
806 set_bit(keycode, dev->keybit);
807 if (!asus_get_entry_by_keycode(old_keycode))
808 clear_bit(old_keycode, dev->keybit);
809 return 0;
810 }
811
812 return -EINVAL;
813}
814
723static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) 815static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
724{ 816{
817 static struct key_entry *key;
818
725 /* TODO Find a better way to handle events count. */ 819 /* TODO Find a better way to handle events count. */
726 if (!hotk) 820 if (!hotk)
727 return; 821 return;
@@ -738,10 +832,24 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
738 lcd_blank(FB_BLANK_POWERDOWN); 832 lcd_blank(FB_BLANK_POWERDOWN);
739 } 833 }
740 834
741 acpi_bus_generate_proc_event(hotk->device, event, 835 acpi_bus_generate_netlink_event(hotk->device->pnp.device_class,
742 hotk->event_count[event % 128]++); 836 dev_name(&hotk->device->dev), event,
743 837 hotk->event_count[event % 128]++);
744 return; 838
839 if (hotk->inputdev) {
840 key = asus_get_entry_by_scancode(event);
841 if (!key)
842 return ;
843
844 switch (key->type) {
845 case KE_KEY:
846 input_report_key(hotk->inputdev, key->keycode, 1);
847 input_sync(hotk->inputdev);
848 input_report_key(hotk->inputdev, key->keycode, 0);
849 input_sync(hotk->inputdev);
850 break;
851 }
852 }
745} 853}
746 854
747#define ASUS_CREATE_DEVICE_ATTR(_name) \ 855#define ASUS_CREATE_DEVICE_ATTR(_name) \
@@ -959,6 +1067,38 @@ static int asus_hotk_get_info(void)
959 return AE_OK; 1067 return AE_OK;
960} 1068}
961 1069
1070static int asus_input_init(void)
1071{
1072 const struct key_entry *key;
1073 int result;
1074
1075 hotk->inputdev = input_allocate_device();
1076 if (!hotk->inputdev) {
1077 printk(ASUS_INFO "Unable to allocate input device\n");
1078 return 0;
1079 }
1080 hotk->inputdev->name = "Asus Laptop extra buttons";
1081 hotk->inputdev->phys = ASUS_HOTK_FILE "/input0";
1082 hotk->inputdev->id.bustype = BUS_HOST;
1083 hotk->inputdev->getkeycode = asus_getkeycode;
1084 hotk->inputdev->setkeycode = asus_setkeycode;
1085
1086 for (key = asus_keymap; key->type != KE_END; key++) {
1087 switch (key->type) {
1088 case KE_KEY:
1089 set_bit(EV_KEY, hotk->inputdev->evbit);
1090 set_bit(key->keycode, hotk->inputdev->keybit);
1091 break;
1092 }
1093 }
1094 result = input_register_device(hotk->inputdev);
1095 if (result) {
1096 printk(ASUS_INFO "Unable to register input device\n");
1097 input_free_device(hotk->inputdev);
1098 }
1099 return result;
1100}
1101
962static int asus_hotk_check(void) 1102static int asus_hotk_check(void)
963{ 1103{
964 int result = 0; 1104 int result = 0;
@@ -1044,7 +1184,7 @@ static int asus_hotk_add(struct acpi_device *device)
1044 /* GPS is on by default */ 1184 /* GPS is on by default */
1045 write_status(NULL, 1, GPS_ON); 1185 write_status(NULL, 1, GPS_ON);
1046 1186
1047 end: 1187end:
1048 if (result) { 1188 if (result) {
1049 kfree(hotk->name); 1189 kfree(hotk->name);
1050 kfree(hotk); 1190 kfree(hotk);
@@ -1091,10 +1231,17 @@ static void asus_led_exit(void)
1091 ASUS_LED_UNREGISTER(gled); 1231 ASUS_LED_UNREGISTER(gled);
1092} 1232}
1093 1233
1234static void asus_input_exit(void)
1235{
1236 if (hotk->inputdev)
1237 input_unregister_device(hotk->inputdev);
1238}
1239
1094static void __exit asus_laptop_exit(void) 1240static void __exit asus_laptop_exit(void)
1095{ 1241{
1096 asus_backlight_exit(); 1242 asus_backlight_exit();
1097 asus_led_exit(); 1243 asus_led_exit();
1244 asus_input_exit();
1098 1245
1099 acpi_bus_unregister_driver(&asus_hotk_driver); 1246 acpi_bus_unregister_driver(&asus_hotk_driver);
1100 sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group); 1247 sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group);
@@ -1216,6 +1363,10 @@ static int __init asus_laptop_init(void)
1216 printk(ASUS_INFO "Brightness ignored, must be controlled by " 1363 printk(ASUS_INFO "Brightness ignored, must be controlled by "
1217 "ACPI video driver\n"); 1364 "ACPI video driver\n");
1218 1365
1366 result = asus_input_init();
1367 if (result)
1368 goto fail_input;
1369
1219 result = asus_led_init(dev); 1370 result = asus_led_init(dev);
1220 if (result) 1371 if (result)
1221 goto fail_led; 1372 goto fail_led;
@@ -1242,22 +1393,25 @@ static int __init asus_laptop_init(void)
1242 1393
1243 return 0; 1394 return 0;
1244 1395
1245 fail_sysfs: 1396fail_sysfs:
1246 platform_device_del(asuspf_device); 1397 platform_device_del(asuspf_device);
1247 1398
1248 fail_platform_device2: 1399fail_platform_device2:
1249 platform_device_put(asuspf_device); 1400 platform_device_put(asuspf_device);
1250 1401
1251 fail_platform_device1: 1402fail_platform_device1:
1252 platform_driver_unregister(&asuspf_driver); 1403 platform_driver_unregister(&asuspf_driver);
1253 1404
1254 fail_platform_driver: 1405fail_platform_driver:
1255 asus_led_exit(); 1406 asus_led_exit();
1256 1407
1257 fail_led: 1408fail_led:
1409 asus_input_exit();
1410
1411fail_input:
1258 asus_backlight_exit(); 1412 asus_backlight_exit();
1259 1413
1260 fail_backlight: 1414fail_backlight:
1261 1415
1262 return result; 1416 return result;
1263} 1417}
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c
index 1e74988c7b2d..d63f26e666a4 100644
--- a/drivers/platform/x86/asus_acpi.c
+++ b/drivers/platform/x86/asus_acpi.c
@@ -143,6 +143,7 @@ struct asus_hotk {
143 S1300N, S5200N*/ 143 S1300N, S5200N*/
144 A4S, /* Z81sp */ 144 A4S, /* Z81sp */
145 F3Sa, /* (Centrino) */ 145 F3Sa, /* (Centrino) */
146 R1F,
146 END_MODEL 147 END_MODEL
147 } model; /* Models currently supported */ 148 } model; /* Models currently supported */
148 u16 event_count[128]; /* Count for each event TODO make this better */ 149 u16 event_count[128]; /* Count for each event TODO make this better */
@@ -420,7 +421,18 @@ static struct model_data model_conf[END_MODEL] = {
420 .display_get = "\\ADVG", 421 .display_get = "\\ADVG",
421 .display_set = "SDSP", 422 .display_set = "SDSP",
422 }, 423 },
423 424 {
425 .name = "R1F",
426 .mt_bt_switch = "BLED",
427 .mt_mled = "MLED",
428 .mt_wled = "WLED",
429 .mt_lcd_switch = "\\Q10",
430 .lcd_status = "\\GP06",
431 .brightness_set = "SPLV",
432 .brightness_get = "GPLV",
433 .display_set = "SDSP",
434 .display_get = "\\INFB"
435 }
424}; 436};
425 437
426/* procdir we use */ 438/* procdir we use */
@@ -1165,6 +1177,8 @@ static int asus_model_match(char *model)
1165 return W3V; 1177 return W3V;
1166 else if (strncmp(model, "W5A", 3) == 0) 1178 else if (strncmp(model, "W5A", 3) == 0)
1167 return W5A; 1179 return W5A;
1180 else if (strncmp(model, "R1F", 3) == 0)
1181 return R1F;
1168 else if (strncmp(model, "A4S", 3) == 0) 1182 else if (strncmp(model, "A4S", 3) == 0)
1169 return A4S; 1183 return A4S;
1170 else if (strncmp(model, "F3Sa", 4) == 0) 1184 else if (strncmp(model, "F3Sa", 4) == 0)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 9d93cb971e59..786ed8661cb0 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -30,6 +30,7 @@
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/rfkill.h> 32#include <linux/rfkill.h>
33#include <linux/pci.h>
33 34
34#define EEEPC_LAPTOP_VERSION "0.1" 35#define EEEPC_LAPTOP_VERSION "0.1"
35 36
@@ -161,6 +162,10 @@ static struct key_entry eeepc_keymap[] = {
161 {KE_KEY, 0x13, KEY_MUTE }, 162 {KE_KEY, 0x13, KEY_MUTE },
162 {KE_KEY, 0x14, KEY_VOLUMEDOWN }, 163 {KE_KEY, 0x14, KEY_VOLUMEDOWN },
163 {KE_KEY, 0x15, KEY_VOLUMEUP }, 164 {KE_KEY, 0x15, KEY_VOLUMEUP },
165 {KE_KEY, 0x1a, KEY_COFFEE },
166 {KE_KEY, 0x1b, KEY_ZOOM },
167 {KE_KEY, 0x1c, KEY_PROG2 },
168 {KE_KEY, 0x1d, KEY_PROG3 },
164 {KE_KEY, 0x30, KEY_SWITCHVIDEOMODE }, 169 {KE_KEY, 0x30, KEY_SWITCHVIDEOMODE },
165 {KE_KEY, 0x31, KEY_SWITCHVIDEOMODE }, 170 {KE_KEY, 0x31, KEY_SWITCHVIDEOMODE },
166 {KE_KEY, 0x32, KEY_SWITCHVIDEOMODE }, 171 {KE_KEY, 0x32, KEY_SWITCHVIDEOMODE },
@@ -510,7 +515,43 @@ static int eeepc_hotk_check(void)
510static void notify_brn(void) 515static void notify_brn(void)
511{ 516{
512 struct backlight_device *bd = eeepc_backlight_device; 517 struct backlight_device *bd = eeepc_backlight_device;
513 bd->props.brightness = read_brightness(bd); 518 if (bd)
519 bd->props.brightness = read_brightness(bd);
520}
521
522static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
523{
524 struct pci_dev *dev;
525 struct pci_bus *bus = pci_find_bus(0, 1);
526
527 if (event != ACPI_NOTIFY_BUS_CHECK)
528 return;
529
530 if (!bus) {
531 printk(EEEPC_WARNING "Unable to find PCI bus 1?\n");
532 return;
533 }
534
535 if (get_acpi(CM_ASL_WLAN) == 1) {
536 dev = pci_get_slot(bus, 0);
537 if (dev) {
538 /* Device already present */
539 pci_dev_put(dev);
540 return;
541 }
542 dev = pci_scan_single_device(bus, 0);
543 if (dev) {
544 pci_bus_assign_resources(bus);
545 if (pci_bus_add_device(dev))
546 printk(EEEPC_ERR "Unable to hotplug wifi\n");
547 }
548 } else {
549 dev = pci_get_slot(bus, 0);
550 if (dev) {
551 pci_remove_bus_device(dev);
552 pci_dev_put(dev);
553 }
554 }
514} 555}
515 556
516static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) 557static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
@@ -520,8 +561,9 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
520 return; 561 return;
521 if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) 562 if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
522 notify_brn(); 563 notify_brn();
523 acpi_bus_generate_proc_event(ehotk->device, event, 564 acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class,
524 ehotk->event_count[event % 128]++); 565 dev_name(&ehotk->device->dev), event,
566 ehotk->event_count[event % 128]++);
525 if (ehotk->inputdev) { 567 if (ehotk->inputdev) {
526 key = eepc_get_entry_by_scancode(event); 568 key = eepc_get_entry_by_scancode(event);
527 if (key) { 569 if (key) {
@@ -539,6 +581,45 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
539 } 581 }
540} 582}
541 583
584static int eeepc_register_rfkill_notifier(char *node)
585{
586 acpi_status status = AE_OK;
587 acpi_handle handle;
588
589 status = acpi_get_handle(NULL, node, &handle);
590
591 if (ACPI_SUCCESS(status)) {
592 status = acpi_install_notify_handler(handle,
593 ACPI_SYSTEM_NOTIFY,
594 eeepc_rfkill_notify,
595 NULL);
596 if (ACPI_FAILURE(status))
597 printk(EEEPC_WARNING
598 "Failed to register notify on %s\n", node);
599 } else
600 return -ENODEV;
601
602 return 0;
603}
604
605static void eeepc_unregister_rfkill_notifier(char *node)
606{
607 acpi_status status = AE_OK;
608 acpi_handle handle;
609
610 status = acpi_get_handle(NULL, node, &handle);
611
612 if (ACPI_SUCCESS(status)) {
613 status = acpi_remove_notify_handler(handle,
614 ACPI_SYSTEM_NOTIFY,
615 eeepc_rfkill_notify);
616 if (ACPI_FAILURE(status))
617 printk(EEEPC_ERR
618 "Error removing rfkill notify handler %s\n",
619 node);
620 }
621}
622
542static int eeepc_hotk_add(struct acpi_device *device) 623static int eeepc_hotk_add(struct acpi_device *device)
543{ 624{
544 acpi_status status = AE_OK; 625 acpi_status status = AE_OK;
@@ -558,7 +639,7 @@ static int eeepc_hotk_add(struct acpi_device *device)
558 ehotk->device = device; 639 ehotk->device = device;
559 result = eeepc_hotk_check(); 640 result = eeepc_hotk_check();
560 if (result) 641 if (result)
561 goto end; 642 goto ehotk_fail;
562 status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY, 643 status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY,
563 eeepc_hotk_notify, ehotk); 644 eeepc_hotk_notify, ehotk);
564 if (ACPI_FAILURE(status)) 645 if (ACPI_FAILURE(status))
@@ -569,18 +650,25 @@ static int eeepc_hotk_add(struct acpi_device *device)
569 RFKILL_TYPE_WLAN); 650 RFKILL_TYPE_WLAN);
570 651
571 if (!ehotk->eeepc_wlan_rfkill) 652 if (!ehotk->eeepc_wlan_rfkill)
572 goto end; 653 goto wlan_fail;
573 654
574 ehotk->eeepc_wlan_rfkill->name = "eeepc-wlan"; 655 ehotk->eeepc_wlan_rfkill->name = "eeepc-wlan";
575 ehotk->eeepc_wlan_rfkill->toggle_radio = eeepc_wlan_rfkill_set; 656 ehotk->eeepc_wlan_rfkill->toggle_radio = eeepc_wlan_rfkill_set;
576 ehotk->eeepc_wlan_rfkill->get_state = eeepc_wlan_rfkill_state; 657 ehotk->eeepc_wlan_rfkill->get_state = eeepc_wlan_rfkill_state;
577 if (get_acpi(CM_ASL_WLAN) == 1) 658 if (get_acpi(CM_ASL_WLAN) == 1) {
578 ehotk->eeepc_wlan_rfkill->state = 659 ehotk->eeepc_wlan_rfkill->state =
579 RFKILL_STATE_UNBLOCKED; 660 RFKILL_STATE_UNBLOCKED;
580 else 661 rfkill_set_default(RFKILL_TYPE_WLAN,
662 RFKILL_STATE_UNBLOCKED);
663 } else {
581 ehotk->eeepc_wlan_rfkill->state = 664 ehotk->eeepc_wlan_rfkill->state =
582 RFKILL_STATE_SOFT_BLOCKED; 665 RFKILL_STATE_SOFT_BLOCKED;
583 rfkill_register(ehotk->eeepc_wlan_rfkill); 666 rfkill_set_default(RFKILL_TYPE_WLAN,
667 RFKILL_STATE_SOFT_BLOCKED);
668 }
669 result = rfkill_register(ehotk->eeepc_wlan_rfkill);
670 if (result)
671 goto wlan_fail;
584 } 672 }
585 673
586 if (get_acpi(CM_ASL_BLUETOOTH) != -1) { 674 if (get_acpi(CM_ASL_BLUETOOTH) != -1) {
@@ -588,27 +676,47 @@ static int eeepc_hotk_add(struct acpi_device *device)
588 rfkill_allocate(&device->dev, RFKILL_TYPE_BLUETOOTH); 676 rfkill_allocate(&device->dev, RFKILL_TYPE_BLUETOOTH);
589 677
590 if (!ehotk->eeepc_bluetooth_rfkill) 678 if (!ehotk->eeepc_bluetooth_rfkill)
591 goto end; 679 goto bluetooth_fail;
592 680
593 ehotk->eeepc_bluetooth_rfkill->name = "eeepc-bluetooth"; 681 ehotk->eeepc_bluetooth_rfkill->name = "eeepc-bluetooth";
594 ehotk->eeepc_bluetooth_rfkill->toggle_radio = 682 ehotk->eeepc_bluetooth_rfkill->toggle_radio =
595 eeepc_bluetooth_rfkill_set; 683 eeepc_bluetooth_rfkill_set;
596 ehotk->eeepc_bluetooth_rfkill->get_state = 684 ehotk->eeepc_bluetooth_rfkill->get_state =
597 eeepc_bluetooth_rfkill_state; 685 eeepc_bluetooth_rfkill_state;
598 if (get_acpi(CM_ASL_BLUETOOTH) == 1) 686 if (get_acpi(CM_ASL_BLUETOOTH) == 1) {
599 ehotk->eeepc_bluetooth_rfkill->state = 687 ehotk->eeepc_bluetooth_rfkill->state =
600 RFKILL_STATE_UNBLOCKED; 688 RFKILL_STATE_UNBLOCKED;
601 else 689 rfkill_set_default(RFKILL_TYPE_BLUETOOTH,
690 RFKILL_STATE_UNBLOCKED);
691 } else {
602 ehotk->eeepc_bluetooth_rfkill->state = 692 ehotk->eeepc_bluetooth_rfkill->state =
603 RFKILL_STATE_SOFT_BLOCKED; 693 RFKILL_STATE_SOFT_BLOCKED;
604 rfkill_register(ehotk->eeepc_bluetooth_rfkill); 694 rfkill_set_default(RFKILL_TYPE_BLUETOOTH,
605 } 695 RFKILL_STATE_SOFT_BLOCKED);
696 }
606 697
607 end: 698 result = rfkill_register(ehotk->eeepc_bluetooth_rfkill);
608 if (result) { 699 if (result)
609 kfree(ehotk); 700 goto bluetooth_fail;
610 ehotk = NULL;
611 } 701 }
702
703 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6");
704 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7");
705
706 return 0;
707
708 bluetooth_fail:
709 if (ehotk->eeepc_bluetooth_rfkill)
710 rfkill_free(ehotk->eeepc_bluetooth_rfkill);
711 rfkill_unregister(ehotk->eeepc_wlan_rfkill);
712 ehotk->eeepc_wlan_rfkill = NULL;
713 wlan_fail:
714 if (ehotk->eeepc_wlan_rfkill)
715 rfkill_free(ehotk->eeepc_wlan_rfkill);
716 ehotk_fail:
717 kfree(ehotk);
718 ehotk = NULL;
719
612 return result; 720 return result;
613} 721}
614 722
@@ -622,6 +730,10 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type)
622 eeepc_hotk_notify); 730 eeepc_hotk_notify);
623 if (ACPI_FAILURE(status)) 731 if (ACPI_FAILURE(status))
624 printk(EEEPC_ERR "Error removing notify handler\n"); 732 printk(EEEPC_ERR "Error removing notify handler\n");
733
734 eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
735 eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
736
625 kfree(ehotk); 737 kfree(ehotk);
626 return 0; 738 return 0;
627} 739}
@@ -737,13 +849,21 @@ static void eeepc_backlight_exit(void)
737{ 849{
738 if (eeepc_backlight_device) 850 if (eeepc_backlight_device)
739 backlight_device_unregister(eeepc_backlight_device); 851 backlight_device_unregister(eeepc_backlight_device);
740 if (ehotk->inputdev) 852 eeepc_backlight_device = NULL;
741 input_unregister_device(ehotk->inputdev); 853}
854
855static void eeepc_rfkill_exit(void)
856{
742 if (ehotk->eeepc_wlan_rfkill) 857 if (ehotk->eeepc_wlan_rfkill)
743 rfkill_unregister(ehotk->eeepc_wlan_rfkill); 858 rfkill_unregister(ehotk->eeepc_wlan_rfkill);
744 if (ehotk->eeepc_bluetooth_rfkill) 859 if (ehotk->eeepc_bluetooth_rfkill)
745 rfkill_unregister(ehotk->eeepc_bluetooth_rfkill); 860 rfkill_unregister(ehotk->eeepc_bluetooth_rfkill);
746 eeepc_backlight_device = NULL; 861}
862
863static void eeepc_input_exit(void)
864{
865 if (ehotk->inputdev)
866 input_unregister_device(ehotk->inputdev);
747} 867}
748 868
749static void eeepc_hwmon_exit(void) 869static void eeepc_hwmon_exit(void)
@@ -762,6 +882,8 @@ static void eeepc_hwmon_exit(void)
762static void __exit eeepc_laptop_exit(void) 882static void __exit eeepc_laptop_exit(void)
763{ 883{
764 eeepc_backlight_exit(); 884 eeepc_backlight_exit();
885 eeepc_rfkill_exit();
886 eeepc_input_exit();
765 eeepc_hwmon_exit(); 887 eeepc_hwmon_exit();
766 acpi_bus_unregister_driver(&eeepc_hotk_driver); 888 acpi_bus_unregister_driver(&eeepc_hotk_driver);
767 sysfs_remove_group(&platform_device->dev.kobj, 889 sysfs_remove_group(&platform_device->dev.kobj,
@@ -865,6 +987,8 @@ fail_platform_driver:
865fail_hwmon: 987fail_hwmon:
866 eeepc_backlight_exit(); 988 eeepc_backlight_exit();
867fail_backlight: 989fail_backlight:
990 eeepc_input_exit();
991 eeepc_rfkill_exit();
868 return result; 992 return result;
869} 993}
870 994
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 65dc41540c62..45940f31fe9e 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -166,6 +166,7 @@ struct fujitsu_hotkey_t {
166 struct platform_device *pf_device; 166 struct platform_device *pf_device;
167 struct kfifo *fifo; 167 struct kfifo *fifo;
168 spinlock_t fifo_lock; 168 spinlock_t fifo_lock;
169 int rfkill_supported;
169 int rfkill_state; 170 int rfkill_state;
170 int logolamp_registered; 171 int logolamp_registered;
171 int kblamps_registered; 172 int kblamps_registered;
@@ -526,7 +527,7 @@ static ssize_t
526show_lid_state(struct device *dev, 527show_lid_state(struct device *dev,
527 struct device_attribute *attr, char *buf) 528 struct device_attribute *attr, char *buf)
528{ 529{
529 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) 530 if (!(fujitsu_hotkey->rfkill_supported & 0x100))
530 return sprintf(buf, "unknown\n"); 531 return sprintf(buf, "unknown\n");
531 if (fujitsu_hotkey->rfkill_state & 0x100) 532 if (fujitsu_hotkey->rfkill_state & 0x100)
532 return sprintf(buf, "open\n"); 533 return sprintf(buf, "open\n");
@@ -538,7 +539,7 @@ static ssize_t
538show_dock_state(struct device *dev, 539show_dock_state(struct device *dev,
539 struct device_attribute *attr, char *buf) 540 struct device_attribute *attr, char *buf)
540{ 541{
541 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) 542 if (!(fujitsu_hotkey->rfkill_supported & 0x200))
542 return sprintf(buf, "unknown\n"); 543 return sprintf(buf, "unknown\n");
543 if (fujitsu_hotkey->rfkill_state & 0x200) 544 if (fujitsu_hotkey->rfkill_state & 0x200)
544 return sprintf(buf, "docked\n"); 545 return sprintf(buf, "docked\n");
@@ -550,7 +551,7 @@ static ssize_t
550show_radios_state(struct device *dev, 551show_radios_state(struct device *dev,
551 struct device_attribute *attr, char *buf) 552 struct device_attribute *attr, char *buf)
552{ 553{
553 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD) 554 if (!(fujitsu_hotkey->rfkill_supported & 0x20))
554 return sprintf(buf, "unknown\n"); 555 return sprintf(buf, "unknown\n");
555 if (fujitsu_hotkey->rfkill_state & 0x20) 556 if (fujitsu_hotkey->rfkill_state & 0x20)
556 return sprintf(buf, "on\n"); 557 return sprintf(buf, "on\n");
@@ -928,8 +929,17 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
928 ; /* No action, result is discarded */ 929 ; /* No action, result is discarded */
929 vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); 930 vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
930 931
931 fujitsu_hotkey->rfkill_state = 932 fujitsu_hotkey->rfkill_supported =
932 call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); 933 call_fext_func(FUNC_RFKILL, 0x0, 0x0, 0x0);
934
935 /* Make sure our bitmask of supported functions is cleared if the
936 RFKILL function block is not implemented, like on the S7020. */
937 if (fujitsu_hotkey->rfkill_supported == UNSUPPORTED_CMD)
938 fujitsu_hotkey->rfkill_supported = 0;
939
940 if (fujitsu_hotkey->rfkill_supported)
941 fujitsu_hotkey->rfkill_state =
942 call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
933 943
934 /* Suspect this is a keymap of the application panel, print it */ 944 /* Suspect this is a keymap of the application panel, print it */
935 printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n", 945 printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
@@ -1005,8 +1015,9 @@ static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
1005 1015
1006 input = fujitsu_hotkey->input; 1016 input = fujitsu_hotkey->input;
1007 1017
1008 fujitsu_hotkey->rfkill_state = 1018 if (fujitsu_hotkey->rfkill_supported)
1009 call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); 1019 fujitsu_hotkey->rfkill_state =
1020 call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
1010 1021
1011 switch (event) { 1022 switch (event) {
1012 case ACPI_FUJITSU_NOTIFY_CODE1: 1023 case ACPI_FUJITSU_NOTIFY_CODE1:
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index de91ddab0a86..f41135f2fb29 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -463,9 +463,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
463 463
464 return 0; 464 return 0;
465register_wwan_err: 465register_wwan_err:
466 rfkill_unregister(bluetooth_rfkill); 466 if (bluetooth_rfkill)
467 rfkill_unregister(bluetooth_rfkill);
467register_bluetooth_error: 468register_bluetooth_error:
468 rfkill_unregister(wifi_rfkill); 469 if (wifi_rfkill)
470 rfkill_unregister(wifi_rfkill);
469add_sysfs_error: 471add_sysfs_error:
470 cleanup_sysfs(device); 472 cleanup_sysfs(device);
471 return err; 473 return err;
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index f30db367c82e..c47a44dcb702 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -507,7 +507,7 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc)
507 507
508 hkey_num = result & 0xf; 508 hkey_num = result & 0xf;
509 509
510 if (hkey_num < 0 || hkey_num > ARRAY_SIZE(pcc->keymap)) { 510 if (hkey_num < 0 || hkey_num >= ARRAY_SIZE(pcc->keymap)) {
511 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 511 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
512 "hotkey number out of range: %d\n", 512 "hotkey number out of range: %d\n",
513 hkey_num)); 513 hkey_num));
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
index e988ec130fcd..41aec2acbb91 100644
--- a/drivers/power/pcf50633-charger.c
+++ b/drivers/power/pcf50633-charger.c
@@ -199,7 +199,8 @@ static int adapter_get_property(struct power_supply *psy,
199 enum power_supply_property psp, 199 enum power_supply_property psp,
200 union power_supply_propval *val) 200 union power_supply_propval *val)
201{ 201{
202 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb); 202 struct pcf50633_mbc *mbc = container_of(psy,
203 struct pcf50633_mbc, adapter);
203 int ret = 0; 204 int ret = 0;
204 205
205 switch (psp) { 206 switch (psp) {
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index cced4d108319..81450fbd8b12 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -241,6 +241,12 @@ config RTC_DRV_M41T80_WDT
241 If you say Y here you will get support for the 241 If you say Y here you will get support for the
242 watchdog timer in the ST M41T60 and M41T80 RTC chips series. 242 watchdog timer in the ST M41T60 and M41T80 RTC chips series.
243 243
244config RTC_DRV_DM355EVM
245 tristate "TI DaVinci DM355 EVM RTC"
246 depends on MFD_DM355EVM_MSP
247 help
248 Supports the RTC firmware in the MSP430 on the DM355 EVM.
249
244config RTC_DRV_TWL92330 250config RTC_DRV_TWL92330
245 boolean "TI TWL92330/Menelaus" 251 boolean "TI TWL92330/Menelaus"
246 depends on MENELAUS 252 depends on MENELAUS
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 6e28021abb9d..0e697aa51caa 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
23obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o 23obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o
24obj-$(CONFIG_RTC_DRV_BFIN) += rtc-bfin.o 24obj-$(CONFIG_RTC_DRV_BFIN) += rtc-bfin.o
25obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o 25obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
26obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o
26obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o 27obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o
27obj-$(CONFIG_RTC_DRV_DS1286) += rtc-ds1286.o 28obj-$(CONFIG_RTC_DRV_DS1286) += rtc-ds1286.o
28obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o 29obj-$(CONFIG_RTC_DRV_DS1302) += rtc-ds1302.o
diff --git a/drivers/rtc/rtc-au1xxx.c b/drivers/rtc/rtc-au1xxx.c
index 8906a688e6a6..979ed0406ce9 100644
--- a/drivers/rtc/rtc-au1xxx.c
+++ b/drivers/rtc/rtc-au1xxx.c
@@ -81,7 +81,7 @@ static int __devinit au1xtoy_rtc_probe(struct platform_device *pdev)
81 if (au_readl(SYS_TOYTRIM) != 32767) { 81 if (au_readl(SYS_TOYTRIM) != 32767) {
82 /* wait until hardware gives access to TRIM register */ 82 /* wait until hardware gives access to TRIM register */
83 t = 0x00100000; 83 t = 0x00100000;
84 while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S) && t--) 84 while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S) && --t)
85 msleep(1); 85 msleep(1);
86 86
87 if (!t) { 87 if (!t) {
diff --git a/drivers/rtc/rtc-dm355evm.c b/drivers/rtc/rtc-dm355evm.c
new file mode 100644
index 000000000000..58d4e18530da
--- /dev/null
+++ b/drivers/rtc/rtc-dm355evm.c
@@ -0,0 +1,175 @@
1/*
2 * rtc-dm355evm.c - access battery-backed counter in MSP430 firmware
3 *
4 * Copyright (c) 2008 by David Brownell
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/rtc.h>
14#include <linux/platform_device.h>
15
16#include <linux/i2c/dm355evm_msp.h>
17
18
19/*
20 * The MSP430 firmware on the DM355 EVM uses a watch crystal to feed
21 * a 1 Hz counter. When a backup battery is supplied, that makes a
22 * reasonable RTC for applications where alarms and non-NTP drift
23 * compensation aren't important.
24 *
25 * The only real glitch is the inability to read or write all four
26 * counter bytes atomically: the count may increment in the middle
27 * of an operation, causing trouble when the LSB rolls over.
28 *
29 * This driver was tested with firmware revision A4.
30 */
31union evm_time {
32 u8 bytes[4];
33 u32 value;
34};
35
36static int dm355evm_rtc_read_time(struct device *dev, struct rtc_time *tm)
37{
38 union evm_time time;
39 int status;
40 int tries = 0;
41
42 do {
43 /*
44 * Read LSB(0) to MSB(3) bytes. Defend against the counter
45 * rolling over by re-reading until the value is stable,
46 * and assuming the four reads take at most a few seconds.
47 */
48 status = dm355evm_msp_read(DM355EVM_MSP_RTC_0);
49 if (status < 0)
50 return status;
51 if (tries && time.bytes[0] == status)
52 break;
53 time.bytes[0] = status;
54
55 status = dm355evm_msp_read(DM355EVM_MSP_RTC_1);
56 if (status < 0)
57 return status;
58 if (tries && time.bytes[1] == status)
59 break;
60 time.bytes[1] = status;
61
62 status = dm355evm_msp_read(DM355EVM_MSP_RTC_2);
63 if (status < 0)
64 return status;
65 if (tries && time.bytes[2] == status)
66 break;
67 time.bytes[2] = status;
68
69 status = dm355evm_msp_read(DM355EVM_MSP_RTC_3);
70 if (status < 0)
71 return status;
72 if (tries && time.bytes[3] == status)
73 break;
74 time.bytes[3] = status;
75
76 } while (++tries < 5);
77
78 dev_dbg(dev, "read timestamp %08x\n", time.value);
79
80 rtc_time_to_tm(le32_to_cpu(time.value), tm);
81 return 0;
82}
83
84static int dm355evm_rtc_set_time(struct device *dev, struct rtc_time *tm)
85{
86 union evm_time time;
87 unsigned long value;
88 int status;
89
90 rtc_tm_to_time(tm, &value);
91 time.value = cpu_to_le32(value);
92
93 dev_dbg(dev, "write timestamp %08x\n", time.value);
94
95 /*
96 * REVISIT handle non-atomic writes ... maybe just retry until
97 * byte[1] sticks (no rollover)?
98 */
99 status = dm355evm_msp_write(time.bytes[0], DM355EVM_MSP_RTC_0);
100 if (status < 0)
101 return status;
102
103 status = dm355evm_msp_write(time.bytes[1], DM355EVM_MSP_RTC_1);
104 if (status < 0)
105 return status;
106
107 status = dm355evm_msp_write(time.bytes[2], DM355EVM_MSP_RTC_2);
108 if (status < 0)
109 return status;
110
111 status = dm355evm_msp_write(time.bytes[3], DM355EVM_MSP_RTC_3);
112 if (status < 0)
113 return status;
114
115 return 0;
116}
117
118static struct rtc_class_ops dm355evm_rtc_ops = {
119 .read_time = dm355evm_rtc_read_time,
120 .set_time = dm355evm_rtc_set_time,
121};
122
123/*----------------------------------------------------------------------*/
124
125static int __devinit dm355evm_rtc_probe(struct platform_device *pdev)
126{
127 struct rtc_device *rtc;
128
129 rtc = rtc_device_register(pdev->name,
130 &pdev->dev, &dm355evm_rtc_ops, THIS_MODULE);
131 if (IS_ERR(rtc)) {
132 dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
133 PTR_ERR(rtc));
134 return PTR_ERR(rtc);
135 }
136 platform_set_drvdata(pdev, rtc);
137
138 return 0;
139}
140
141static int __devexit dm355evm_rtc_remove(struct platform_device *pdev)
142{
143 struct rtc_device *rtc = platform_get_drvdata(pdev);
144
145 rtc_device_unregister(rtc);
146 platform_set_drvdata(pdev, NULL);
147 return 0;
148}
149
150/*
151 * I2C is used to talk to the MSP430, but this platform device is
152 * exposed by an MFD driver that manages I2C communications.
153 */
154static struct platform_driver rtc_dm355evm_driver = {
155 .probe = dm355evm_rtc_probe,
156 .remove = __devexit_p(dm355evm_rtc_remove),
157 .driver = {
158 .owner = THIS_MODULE,
159 .name = "rtc-dm355evm",
160 },
161};
162
163static int __init dm355evm_rtc_init(void)
164{
165 return platform_driver_register(&rtc_dm355evm_driver);
166}
167module_init(dm355evm_rtc_init);
168
169static void __exit dm355evm_rtc_exit(void)
170{
171 platform_driver_unregister(&rtc_dm355evm_driver);
172}
173module_exit(dm355evm_rtc_exit);
174
175MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c
index e54b5c619bdf..e01b955db077 100644
--- a/drivers/rtc/rtc-ds1390.c
+++ b/drivers/rtc/rtc-ds1390.c
@@ -122,7 +122,6 @@ static const struct rtc_class_ops ds1390_rtc_ops = {
122 122
123static int __devinit ds1390_probe(struct spi_device *spi) 123static int __devinit ds1390_probe(struct spi_device *spi)
124{ 124{
125 struct rtc_device *rtc;
126 unsigned char tmp; 125 unsigned char tmp;
127 struct ds1390 *chip; 126 struct ds1390 *chip;
128 int res; 127 int res;
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index bd56a033bfd0..bb8cc05605ac 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -485,7 +485,7 @@ static void __exit pxa_rtc_exit(void)
485module_init(pxa_rtc_init); 485module_init(pxa_rtc_init);
486module_exit(pxa_rtc_exit); 486module_exit(pxa_rtc_exit);
487 487
488MODULE_AUTHOR("Robert Jarzmik"); 488MODULE_AUTHOR("Robert Jarzmik <robert.jarzmik@free.fr>");
489MODULE_DESCRIPTION("PXA27x/PXA3xx Realtime Clock Driver (RTC)"); 489MODULE_DESCRIPTION("PXA27x/PXA3xx Realtime Clock Driver (RTC)");
490MODULE_LICENSE("GPL"); 490MODULE_LICENSE("GPL");
491MODULE_ALIAS("platform:pxa-rtc"); 491MODULE_ALIAS("platform:pxa-rtc");
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index bd5914994142..08c23a921012 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -57,6 +57,8 @@ static void dasd_device_tasklet(struct dasd_device *);
57static void dasd_block_tasklet(struct dasd_block *); 57static void dasd_block_tasklet(struct dasd_block *);
58static void do_kick_device(struct work_struct *); 58static void do_kick_device(struct work_struct *);
59static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *); 59static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *);
60static void dasd_device_timeout(unsigned long);
61static void dasd_block_timeout(unsigned long);
60 62
61/* 63/*
62 * SECTION: Operations on the device structure. 64 * SECTION: Operations on the device structure.
@@ -99,6 +101,8 @@ struct dasd_device *dasd_alloc_device(void)
99 (unsigned long) device); 101 (unsigned long) device);
100 INIT_LIST_HEAD(&device->ccw_queue); 102 INIT_LIST_HEAD(&device->ccw_queue);
101 init_timer(&device->timer); 103 init_timer(&device->timer);
104 device->timer.function = dasd_device_timeout;
105 device->timer.data = (unsigned long) device;
102 INIT_WORK(&device->kick_work, do_kick_device); 106 INIT_WORK(&device->kick_work, do_kick_device);
103 device->state = DASD_STATE_NEW; 107 device->state = DASD_STATE_NEW;
104 device->target = DASD_STATE_NEW; 108 device->target = DASD_STATE_NEW;
@@ -138,6 +142,8 @@ struct dasd_block *dasd_alloc_block(void)
138 INIT_LIST_HEAD(&block->ccw_queue); 142 INIT_LIST_HEAD(&block->ccw_queue);
139 spin_lock_init(&block->queue_lock); 143 spin_lock_init(&block->queue_lock);
140 init_timer(&block->timer); 144 init_timer(&block->timer);
145 block->timer.function = dasd_block_timeout;
146 block->timer.data = (unsigned long) block;
141 147
142 return block; 148 return block;
143} 149}
@@ -915,19 +921,10 @@ static void dasd_device_timeout(unsigned long ptr)
915 */ 921 */
916void dasd_device_set_timer(struct dasd_device *device, int expires) 922void dasd_device_set_timer(struct dasd_device *device, int expires)
917{ 923{
918 if (expires == 0) { 924 if (expires == 0)
919 if (timer_pending(&device->timer)) 925 del_timer(&device->timer);
920 del_timer(&device->timer); 926 else
921 return; 927 mod_timer(&device->timer, jiffies + expires);
922 }
923 if (timer_pending(&device->timer)) {
924 if (mod_timer(&device->timer, jiffies + expires))
925 return;
926 }
927 device->timer.function = dasd_device_timeout;
928 device->timer.data = (unsigned long) device;
929 device->timer.expires = jiffies + expires;
930 add_timer(&device->timer);
931} 928}
932 929
933/* 930/*
@@ -935,8 +932,7 @@ void dasd_device_set_timer(struct dasd_device *device, int expires)
935 */ 932 */
936void dasd_device_clear_timer(struct dasd_device *device) 933void dasd_device_clear_timer(struct dasd_device *device)
937{ 934{
938 if (timer_pending(&device->timer)) 935 del_timer(&device->timer);
939 del_timer(&device->timer);
940} 936}
941 937
942static void dasd_handle_killed_request(struct ccw_device *cdev, 938static void dasd_handle_killed_request(struct ccw_device *cdev,
@@ -1586,19 +1582,10 @@ static void dasd_block_timeout(unsigned long ptr)
1586 */ 1582 */
1587void dasd_block_set_timer(struct dasd_block *block, int expires) 1583void dasd_block_set_timer(struct dasd_block *block, int expires)
1588{ 1584{
1589 if (expires == 0) { 1585 if (expires == 0)
1590 if (timer_pending(&block->timer)) 1586 del_timer(&block->timer);
1591 del_timer(&block->timer); 1587 else
1592 return; 1588 mod_timer(&block->timer, jiffies + expires);
1593 }
1594 if (timer_pending(&block->timer)) {
1595 if (mod_timer(&block->timer, jiffies + expires))
1596 return;
1597 }
1598 block->timer.function = dasd_block_timeout;
1599 block->timer.data = (unsigned long) block;
1600 block->timer.expires = jiffies + expires;
1601 add_timer(&block->timer);
1602} 1589}
1603 1590
1604/* 1591/*
@@ -1606,8 +1593,7 @@ void dasd_block_set_timer(struct dasd_block *block, int expires)
1606 */ 1593 */
1607void dasd_block_clear_timer(struct dasd_block *block) 1594void dasd_block_clear_timer(struct dasd_block *block)
1608{ 1595{
1609 if (timer_pending(&block->timer)) 1596 del_timer(&block->timer);
1610 del_timer(&block->timer);
1611} 1597}
1612 1598
1613/* 1599/*
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 300e28a531f8..34339902efb9 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -677,7 +677,7 @@ static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr,
677 struct dasd_devmap *devmap; 677 struct dasd_devmap *devmap;
678 int ff_flag; 678 int ff_flag;
679 679
680 devmap = dasd_find_busid(dev->bus_id); 680 devmap = dasd_find_busid(dev_name(dev));
681 if (!IS_ERR(devmap)) 681 if (!IS_ERR(devmap))
682 ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0; 682 ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0;
683 else 683 else
diff --git a/drivers/s390/char/sclp.c b/drivers/s390/char/sclp.c
index 1fd8f2193ed8..4377e93a43d7 100644
--- a/drivers/s390/char/sclp.c
+++ b/drivers/s390/char/sclp.c
@@ -280,8 +280,11 @@ sclp_dispatch_evbufs(struct sccb_header *sccb)
280 rc = 0; 280 rc = 0;
281 for (offset = sizeof(struct sccb_header); offset < sccb->length; 281 for (offset = sizeof(struct sccb_header); offset < sccb->length;
282 offset += evbuf->length) { 282 offset += evbuf->length) {
283 /* Search for event handler */
284 evbuf = (struct evbuf_header *) ((addr_t) sccb + offset); 283 evbuf = (struct evbuf_header *) ((addr_t) sccb + offset);
284 /* Check for malformed hardware response */
285 if (evbuf->length == 0)
286 break;
287 /* Search for event handler */
285 reg = NULL; 288 reg = NULL;
286 list_for_each(l, &sclp_reg_list) { 289 list_for_each(l, &sclp_reg_list) {
287 reg = list_entry(l, struct sclp_register, list); 290 reg = list_entry(l, struct sclp_register, list);
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index 506390496416..77ab6e34a100 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -19,6 +19,7 @@
19#include <linux/memory.h> 19#include <linux/memory.h>
20#include <asm/chpid.h> 20#include <asm/chpid.h>
21#include <asm/sclp.h> 21#include <asm/sclp.h>
22#include <asm/setup.h>
22 23
23#include "sclp.h" 24#include "sclp.h"
24 25
@@ -474,6 +475,10 @@ static void __init add_memory_merged(u16 rn)
474 goto skip_add; 475 goto skip_add;
475 if (start + size > VMEM_MAX_PHYS) 476 if (start + size > VMEM_MAX_PHYS)
476 size = VMEM_MAX_PHYS - start; 477 size = VMEM_MAX_PHYS - start;
478 if (memory_end_set && (start >= memory_end))
479 goto skip_add;
480 if (memory_end_set && (start + size > memory_end))
481 size = memory_end - start;
477 add_memory(0, start, size); 482 add_memory(0, start, size);
478skip_add: 483skip_add:
479 first_rn = rn; 484 first_rn = rn;
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index a1a511bdec8c..ed1e728763a2 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1573,9 +1573,6 @@ static int ibmvfc_queuecommand(struct scsi_cmnd *cmnd,
1573 vfc_cmd->resp_len = sizeof(vfc_cmd->rsp); 1573 vfc_cmd->resp_len = sizeof(vfc_cmd->rsp);
1574 vfc_cmd->cancel_key = (unsigned long)cmnd->device->hostdata; 1574 vfc_cmd->cancel_key = (unsigned long)cmnd->device->hostdata;
1575 vfc_cmd->tgt_scsi_id = rport->port_id; 1575 vfc_cmd->tgt_scsi_id = rport->port_id;
1576 if ((rport->supported_classes & FC_COS_CLASS3) &&
1577 (fc_host_supported_classes(vhost->host) & FC_COS_CLASS3))
1578 vfc_cmd->flags = IBMVFC_CLASS_3_ERR;
1579 vfc_cmd->iu.xfer_len = scsi_bufflen(cmnd); 1576 vfc_cmd->iu.xfer_len = scsi_bufflen(cmnd);
1580 int_to_scsilun(cmnd->device->lun, &vfc_cmd->iu.lun); 1577 int_to_scsilun(cmnd->device->lun, &vfc_cmd->iu.lun);
1581 memcpy(vfc_cmd->iu.cdb, cmnd->cmnd, cmnd->cmd_len); 1578 memcpy(vfc_cmd->iu.cdb, cmnd->cmnd, cmnd->cmd_len);
@@ -3266,6 +3263,7 @@ static int ibmvfc_alloc_target(struct ibmvfc_host *vhost, u64 scsi_id)
3266 return -ENOMEM; 3263 return -ENOMEM;
3267 } 3264 }
3268 3265
3266 memset(tgt, 0, sizeof(*tgt));
3269 tgt->scsi_id = scsi_id; 3267 tgt->scsi_id = scsi_id;
3270 tgt->new_scsi_id = scsi_id; 3268 tgt->new_scsi_id = scsi_id;
3271 tgt->vhost = vhost; 3269 tgt->vhost = vhost;
@@ -3576,9 +3574,18 @@ static void ibmvfc_log_ae(struct ibmvfc_host *vhost, int events)
3576static void ibmvfc_tgt_add_rport(struct ibmvfc_target *tgt) 3574static void ibmvfc_tgt_add_rport(struct ibmvfc_target *tgt)
3577{ 3575{
3578 struct ibmvfc_host *vhost = tgt->vhost; 3576 struct ibmvfc_host *vhost = tgt->vhost;
3579 struct fc_rport *rport; 3577 struct fc_rport *rport = tgt->rport;
3580 unsigned long flags; 3578 unsigned long flags;
3581 3579
3580 if (rport) {
3581 tgt_dbg(tgt, "Setting rport roles\n");
3582 fc_remote_port_rolechg(rport, tgt->ids.roles);
3583 spin_lock_irqsave(vhost->host->host_lock, flags);
3584 ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_NONE);
3585 spin_unlock_irqrestore(vhost->host->host_lock, flags);
3586 return;
3587 }
3588
3582 tgt_dbg(tgt, "Adding rport\n"); 3589 tgt_dbg(tgt, "Adding rport\n");
3583 rport = fc_remote_port_add(vhost->host, 0, &tgt->ids); 3590 rport = fc_remote_port_add(vhost->host, 0, &tgt->ids);
3584 spin_lock_irqsave(vhost->host->host_lock, flags); 3591 spin_lock_irqsave(vhost->host->host_lock, flags);
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h
index 87dafd0f8d44..b21e071b9862 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.h
+++ b/drivers/scsi/ibmvscsi/ibmvfc.h
@@ -32,7 +32,7 @@
32#define IBMVFC_DRIVER_VERSION "1.0.4" 32#define IBMVFC_DRIVER_VERSION "1.0.4"
33#define IBMVFC_DRIVER_DATE "(November 14, 2008)" 33#define IBMVFC_DRIVER_DATE "(November 14, 2008)"
34 34
35#define IBMVFC_DEFAULT_TIMEOUT 15 35#define IBMVFC_DEFAULT_TIMEOUT 60
36#define IBMVFC_INIT_TIMEOUT 120 36#define IBMVFC_INIT_TIMEOUT 120
37#define IBMVFC_MAX_REQUESTS_DEFAULT 100 37#define IBMVFC_MAX_REQUESTS_DEFAULT 100
38 38
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 74d07d137dae..c9aa7611e408 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -432,6 +432,7 @@ static int map_sg_data(struct scsi_cmnd *cmd,
432 sdev_printk(KERN_ERR, cmd->device, 432 sdev_printk(KERN_ERR, cmd->device,
433 "Can't allocate memory " 433 "Can't allocate memory "
434 "for indirect table\n"); 434 "for indirect table\n");
435 scsi_dma_unmap(cmd);
435 return 0; 436 return 0;
436 } 437 }
437 } 438 }
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 257c24115de9..809d32d95c76 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1998,6 +1998,8 @@ int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev)
1998 if (!shost->can_queue) 1998 if (!shost->can_queue)
1999 shost->can_queue = ISCSI_DEF_XMIT_CMDS_MAX; 1999 shost->can_queue = ISCSI_DEF_XMIT_CMDS_MAX;
2000 2000
2001 if (!shost->transportt->eh_timed_out)
2002 shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
2001 return scsi_add_host(shost, pdev); 2003 return scsi_add_host(shost, pdev);
2002} 2004}
2003EXPORT_SYMBOL_GPL(iscsi_host_add); 2005EXPORT_SYMBOL_GPL(iscsi_host_add);
@@ -2020,7 +2022,6 @@ struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
2020 shost = scsi_host_alloc(sht, sizeof(struct iscsi_host) + dd_data_size); 2022 shost = scsi_host_alloc(sht, sizeof(struct iscsi_host) + dd_data_size);
2021 if (!shost) 2023 if (!shost)
2022 return NULL; 2024 return NULL;
2023 shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
2024 2025
2025 if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) { 2026 if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) {
2026 if (qdepth != 0) 2027 if (qdepth != 0)
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index a8f30bdaff69..a7302480bc4a 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5258,6 +5258,7 @@ lpfc_send_els_event(struct lpfc_vport *vport,
5258 sizeof(struct lpfc_name)); 5258 sizeof(struct lpfc_name));
5259 break; 5259 break;
5260 default: 5260 default:
5261 kfree(els_data);
5261 return; 5262 return;
5262 } 5263 }
5263 memcpy(els_data->wwpn, &ndlp->nlp_portname, sizeof(struct lpfc_name)); 5264 memcpy(els_data->wwpn, &ndlp->nlp_portname, sizeof(struct lpfc_name));
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 33a3c13fd893..f4c57227ec18 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1265,13 +1265,6 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
1265 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags)) 1265 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
1266 msleep(1000); 1266 msleep(1000);
1267 1267
1268 if (ha->mqenable) {
1269 if (qla25xx_delete_queues(vha, 0) != QLA_SUCCESS)
1270 qla_printk(KERN_WARNING, ha,
1271 "Queue delete failed.\n");
1272 vha->req_ques[0] = ha->req_q_map[0]->id;
1273 }
1274
1275 qla24xx_disable_vp(vha); 1268 qla24xx_disable_vp(vha);
1276 1269
1277 fc_remove_host(vha->host); 1270 fc_remove_host(vha->host);
@@ -1293,6 +1286,12 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
1293 vha->host_no, vha->vp_idx, vha)); 1286 vha->host_no, vha->vp_idx, vha));
1294 } 1287 }
1295 1288
1289 if (ha->mqenable) {
1290 if (qla25xx_delete_queues(vha, 0) != QLA_SUCCESS)
1291 qla_printk(KERN_WARNING, ha,
1292 "Queue delete failed.\n");
1293 }
1294
1296 scsi_host_put(vha->host); 1295 scsi_host_put(vha->host);
1297 qla_printk(KERN_INFO, ha, "vport %d deleted\n", id); 1296 qla_printk(KERN_INFO, ha, "vport %d deleted\n", id);
1298 return 0; 1297 return 0;
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 023ee77fb027..e0c5bb54b258 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2135,6 +2135,7 @@ struct qla_msix_entry {
2135/* Work events. */ 2135/* Work events. */
2136enum qla_work_type { 2136enum qla_work_type {
2137 QLA_EVT_AEN, 2137 QLA_EVT_AEN,
2138 QLA_EVT_IDC_ACK,
2138}; 2139};
2139 2140
2140 2141
@@ -2149,6 +2150,10 @@ struct qla_work_evt {
2149 enum fc_host_event_code code; 2150 enum fc_host_event_code code;
2150 u32 data; 2151 u32 data;
2151 } aen; 2152 } aen;
2153 struct {
2154#define QLA_IDC_ACK_REGS 7
2155 uint16_t mb[QLA_IDC_ACK_REGS];
2156 } idc_ack;
2152 } u; 2157 } u;
2153}; 2158};
2154 2159
diff --git a/drivers/scsi/qla2xxx/qla_devtbl.h b/drivers/scsi/qla2xxx/qla_devtbl.h
index d78d35e681ab..d6ea69df7c5c 100644
--- a/drivers/scsi/qla2xxx/qla_devtbl.h
+++ b/drivers/scsi/qla2xxx/qla_devtbl.h
@@ -72,7 +72,7 @@ static char *qla2x00_model_name[QLA_MODEL_NAMES*2] = {
72 "QLA2462", "Sun PCI-X 2.0 to 4Gb FC, Dual Channel", /* 0x141 */ 72 "QLA2462", "Sun PCI-X 2.0 to 4Gb FC, Dual Channel", /* 0x141 */
73 "QLE2460", "Sun PCI-Express to 2Gb FC, Single Channel", /* 0x142 */ 73 "QLE2460", "Sun PCI-Express to 2Gb FC, Single Channel", /* 0x142 */
74 "QLE2462", "Sun PCI-Express to 4Gb FC, Single Channel", /* 0x143 */ 74 "QLE2462", "Sun PCI-Express to 4Gb FC, Single Channel", /* 0x143 */
75 "QEM2462" "Server I/O Module 4Gb FC, Dual Channel", /* 0x144 */ 75 "QEM2462", "Server I/O Module 4Gb FC, Dual Channel", /* 0x144 */
76 "QLE2440", "PCI-Express to 4Gb FC, Single Channel", /* 0x145 */ 76 "QLE2440", "PCI-Express to 4Gb FC, Single Channel", /* 0x145 */
77 "QLE2464", "PCI-Express to 4Gb FC, Quad Channel", /* 0x146 */ 77 "QLE2464", "PCI-Express to 4Gb FC, Quad Channel", /* 0x146 */
78 "QLA2440", "PCI-X 2.0 to 4Gb FC, Single Channel", /* 0x147 */ 78 "QLA2440", "PCI-X 2.0 to 4Gb FC, Single Channel", /* 0x147 */
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index 7abb045a0410..ffff42554087 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -1402,6 +1402,8 @@ struct access_chip_rsp_84xx {
1402#define MBA_IDC_NOTIFY 0x8101 1402#define MBA_IDC_NOTIFY 0x8101
1403#define MBA_IDC_TIME_EXT 0x8102 1403#define MBA_IDC_TIME_EXT 0x8102
1404 1404
1405#define MBC_IDC_ACK 0x101
1406
1405struct nvram_81xx { 1407struct nvram_81xx {
1406 /* NVRAM header. */ 1408 /* NVRAM header. */
1407 uint8_t id[4]; 1409 uint8_t id[4];
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index a336b4bc81a7..6de283f8f111 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -72,6 +72,7 @@ extern int qla2x00_loop_reset(scsi_qla_host_t *);
72extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int); 72extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int);
73extern int qla2x00_post_aen_work(struct scsi_qla_host *, enum 73extern int qla2x00_post_aen_work(struct scsi_qla_host *, enum
74 fc_host_event_code, u32); 74 fc_host_event_code, u32);
75extern int qla2x00_post_idc_ack_work(struct scsi_qla_host *, uint16_t *);
75 76
76extern void qla2x00_abort_fcport_cmds(fc_port_t *); 77extern void qla2x00_abort_fcport_cmds(fc_port_t *);
77extern struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *, 78extern struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *,
@@ -266,6 +267,8 @@ qla2x00_set_idma_speed(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t *);
266 267
267extern int qla84xx_verify_chip(struct scsi_qla_host *, uint16_t *); 268extern int qla84xx_verify_chip(struct scsi_qla_host *, uint16_t *);
268 269
270extern int qla81xx_idc_ack(scsi_qla_host_t *, uint16_t *);
271
269/* 272/*
270 * Global Function Prototypes in qla_isr.c source file. 273 * Global Function Prototypes in qla_isr.c source file.
271 */ 274 */
@@ -376,10 +379,8 @@ extern int qla2x00_dfs_remove(scsi_qla_host_t *);
376 379
377/* Globa function prototypes for multi-q */ 380/* Globa function prototypes for multi-q */
378extern int qla25xx_request_irq(struct rsp_que *); 381extern int qla25xx_request_irq(struct rsp_que *);
379extern int qla25xx_init_req_que(struct scsi_qla_host *, struct req_que *, 382extern int qla25xx_init_req_que(struct scsi_qla_host *, struct req_que *);
380 uint8_t); 383extern int qla25xx_init_rsp_que(struct scsi_qla_host *, struct rsp_que *);
381extern int qla25xx_init_rsp_que(struct scsi_qla_host *, struct rsp_que *,
382 uint8_t);
383extern int qla25xx_create_req_que(struct qla_hw_data *, uint16_t, uint8_t, 384extern int qla25xx_create_req_que(struct qla_hw_data *, uint16_t, uint8_t,
384 uint16_t, uint8_t, uint8_t); 385 uint16_t, uint8_t, uint8_t);
385extern int qla25xx_create_rsp_que(struct qla_hw_data *, uint16_t, uint8_t, 386extern int qla25xx_create_rsp_que(struct qla_hw_data *, uint16_t, uint8_t,
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index f6368a1d3021..986501759ad4 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1226,9 +1226,8 @@ qla24xx_config_rings(struct scsi_qla_host *vha)
1226 icb->firmware_options_2 |= 1226 icb->firmware_options_2 |=
1227 __constant_cpu_to_le32(BIT_18); 1227 __constant_cpu_to_le32(BIT_18);
1228 1228
1229 icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_22); 1229 icb->firmware_options_2 &= __constant_cpu_to_le32(~BIT_22);
1230 icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_23); 1230 icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_23);
1231 ha->rsp_q_map[0]->options = icb->firmware_options_2;
1232 1231
1233 WRT_REG_DWORD(&reg->isp25mq.req_q_in, 0); 1232 WRT_REG_DWORD(&reg->isp25mq.req_q_in, 0);
1234 WRT_REG_DWORD(&reg->isp25mq.req_q_out, 0); 1233 WRT_REG_DWORD(&reg->isp25mq.req_q_out, 0);
@@ -3493,7 +3492,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
3493 rsp = ha->rsp_q_map[i]; 3492 rsp = ha->rsp_q_map[i];
3494 if (rsp) { 3493 if (rsp) {
3495 rsp->options &= ~BIT_0; 3494 rsp->options &= ~BIT_0;
3496 ret = qla25xx_init_rsp_que(base_vha, rsp, rsp->options); 3495 ret = qla25xx_init_rsp_que(base_vha, rsp);
3497 if (ret != QLA_SUCCESS) 3496 if (ret != QLA_SUCCESS)
3498 DEBUG2_17(printk(KERN_WARNING 3497 DEBUG2_17(printk(KERN_WARNING
3499 "%s Rsp que:%d init failed\n", __func__, 3498 "%s Rsp que:%d init failed\n", __func__,
@@ -3507,7 +3506,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
3507 if (req) { 3506 if (req) {
3508 /* Clear outstanding commands array. */ 3507 /* Clear outstanding commands array. */
3509 req->options &= ~BIT_0; 3508 req->options &= ~BIT_0;
3510 ret = qla25xx_init_req_que(base_vha, req, req->options); 3509 ret = qla25xx_init_req_que(base_vha, req);
3511 if (ret != QLA_SUCCESS) 3510 if (ret != QLA_SUCCESS)
3512 DEBUG2_17(printk(KERN_WARNING 3511 DEBUG2_17(printk(KERN_WARNING
3513 "%s Req que:%d init failed\n", __func__, 3512 "%s Req que:%d init failed\n", __func__,
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index e28ad81baf1e..f250e5b7897c 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -266,6 +266,40 @@ qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0)
266 } 266 }
267} 267}
268 268
269static void
270qla81xx_idc_event(scsi_qla_host_t *vha, uint16_t aen, uint16_t descr)
271{
272 static char *event[] =
273 { "Complete", "Request Notification", "Time Extension" };
274 int rval;
275 struct device_reg_24xx __iomem *reg24 = &vha->hw->iobase->isp24;
276 uint16_t __iomem *wptr;
277 uint16_t cnt, timeout, mb[QLA_IDC_ACK_REGS];
278
279 /* Seed data -- mailbox1 -> mailbox7. */
280 wptr = (uint16_t __iomem *)&reg24->mailbox1;
281 for (cnt = 0; cnt < QLA_IDC_ACK_REGS; cnt++, wptr++)
282 mb[cnt] = RD_REG_WORD(wptr);
283
284 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation %s -- "
285 "%04x %04x %04x %04x %04x %04x %04x.\n", vha->host_no,
286 event[aen & 0xff],
287 mb[0], mb[1], mb[2], mb[3], mb[4], mb[5], mb[6]));
288
289 /* Acknowledgement needed? [Notify && non-zero timeout]. */
290 timeout = (descr >> 8) & 0xf;
291 if (aen != MBA_IDC_NOTIFY || !timeout)
292 return;
293
294 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation %s -- "
295 "ACK timeout=%d.\n", vha->host_no, event[aen & 0xff], timeout));
296
297 rval = qla2x00_post_idc_ack_work(vha, mb);
298 if (rval != QLA_SUCCESS)
299 qla_printk(KERN_WARNING, vha->hw,
300 "IDC failed to post ACK.\n");
301}
302
269/** 303/**
270 * qla2x00_async_event() - Process aynchronous events. 304 * qla2x00_async_event() - Process aynchronous events.
271 * @ha: SCSI driver HA context 305 * @ha: SCSI driver HA context
@@ -714,21 +748,9 @@ skip_rio:
714 "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3])); 748 "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3]));
715 break; 749 break;
716 case MBA_IDC_COMPLETE: 750 case MBA_IDC_COMPLETE:
717 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation "
718 "Complete -- %04x %04x %04x\n", vha->host_no, mb[1], mb[2],
719 mb[3]));
720 break;
721 case MBA_IDC_NOTIFY: 751 case MBA_IDC_NOTIFY:
722 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation "
723 "Request Notification -- %04x %04x %04x\n", vha->host_no,
724 mb[1], mb[2], mb[3]));
725 /**** Mailbox registers 4 - 7 valid!!! */
726 break;
727 case MBA_IDC_TIME_EXT: 752 case MBA_IDC_TIME_EXT:
728 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation " 753 qla81xx_idc_event(vha, mb[0], mb[1]);
729 "Time Extension -- %04x %04x %04x\n", vha->host_no, mb[1],
730 mb[2], mb[3]));
731 /**** Mailbox registers 4 - 7 valid!!! */
732 break; 754 break;
733 } 755 }
734 756
@@ -1707,7 +1729,6 @@ qla25xx_msix_rsp_q(int irq, void *dev_id)
1707 struct qla_hw_data *ha; 1729 struct qla_hw_data *ha;
1708 struct rsp_que *rsp; 1730 struct rsp_que *rsp;
1709 struct device_reg_24xx __iomem *reg; 1731 struct device_reg_24xx __iomem *reg;
1710 uint16_t msix_disabled_hccr = 0;
1711 1732
1712 rsp = (struct rsp_que *) dev_id; 1733 rsp = (struct rsp_que *) dev_id;
1713 if (!rsp) { 1734 if (!rsp) {
@@ -1720,17 +1741,8 @@ qla25xx_msix_rsp_q(int irq, void *dev_id)
1720 1741
1721 spin_lock_irq(&ha->hardware_lock); 1742 spin_lock_irq(&ha->hardware_lock);
1722 1743
1723 msix_disabled_hccr = rsp->options;
1724 if (!rsp->id)
1725 msix_disabled_hccr &= __constant_cpu_to_le32(BIT_22);
1726 else
1727 msix_disabled_hccr &= __constant_cpu_to_le32(BIT_6);
1728
1729 qla24xx_process_response_queue(rsp); 1744 qla24xx_process_response_queue(rsp);
1730 1745
1731 if (!msix_disabled_hccr)
1732 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
1733
1734 spin_unlock_irq(&ha->hardware_lock); 1746 spin_unlock_irq(&ha->hardware_lock);
1735 1747
1736 return IRQ_HANDLED; 1748 return IRQ_HANDLED;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index f94ffbb98e95..4c7504cb3990 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -3090,8 +3090,7 @@ verify_done:
3090} 3090}
3091 3091
3092int 3092int
3093qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req, 3093qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req)
3094 uint8_t options)
3095{ 3094{
3096 int rval; 3095 int rval;
3097 unsigned long flags; 3096 unsigned long flags;
@@ -3101,7 +3100,7 @@ qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req,
3101 struct qla_hw_data *ha = vha->hw; 3100 struct qla_hw_data *ha = vha->hw;
3102 3101
3103 mcp->mb[0] = MBC_INITIALIZE_MULTIQ; 3102 mcp->mb[0] = MBC_INITIALIZE_MULTIQ;
3104 mcp->mb[1] = options; 3103 mcp->mb[1] = req->options;
3105 mcp->mb[2] = MSW(LSD(req->dma)); 3104 mcp->mb[2] = MSW(LSD(req->dma));
3106 mcp->mb[3] = LSW(LSD(req->dma)); 3105 mcp->mb[3] = LSW(LSD(req->dma));
3107 mcp->mb[6] = MSW(MSD(req->dma)); 3106 mcp->mb[6] = MSW(MSD(req->dma));
@@ -3128,7 +3127,7 @@ qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req,
3128 mcp->tov = 60; 3127 mcp->tov = 60;
3129 3128
3130 spin_lock_irqsave(&ha->hardware_lock, flags); 3129 spin_lock_irqsave(&ha->hardware_lock, flags);
3131 if (!(options & BIT_0)) { 3130 if (!(req->options & BIT_0)) {
3132 WRT_REG_DWORD(&reg->req_q_in, 0); 3131 WRT_REG_DWORD(&reg->req_q_in, 0);
3133 WRT_REG_DWORD(&reg->req_q_out, 0); 3132 WRT_REG_DWORD(&reg->req_q_out, 0);
3134 } 3133 }
@@ -3142,8 +3141,7 @@ qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req,
3142} 3141}
3143 3142
3144int 3143int
3145qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp, 3144qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
3146 uint8_t options)
3147{ 3145{
3148 int rval; 3146 int rval;
3149 unsigned long flags; 3147 unsigned long flags;
@@ -3153,7 +3151,7 @@ qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp,
3153 struct qla_hw_data *ha = vha->hw; 3151 struct qla_hw_data *ha = vha->hw;
3154 3152
3155 mcp->mb[0] = MBC_INITIALIZE_MULTIQ; 3153 mcp->mb[0] = MBC_INITIALIZE_MULTIQ;
3156 mcp->mb[1] = options; 3154 mcp->mb[1] = rsp->options;
3157 mcp->mb[2] = MSW(LSD(rsp->dma)); 3155 mcp->mb[2] = MSW(LSD(rsp->dma));
3158 mcp->mb[3] = LSW(LSD(rsp->dma)); 3156 mcp->mb[3] = LSW(LSD(rsp->dma));
3159 mcp->mb[6] = MSW(MSD(rsp->dma)); 3157 mcp->mb[6] = MSW(MSD(rsp->dma));
@@ -3178,7 +3176,7 @@ qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp,
3178 mcp->tov = 60; 3176 mcp->tov = 60;
3179 3177
3180 spin_lock_irqsave(&ha->hardware_lock, flags); 3178 spin_lock_irqsave(&ha->hardware_lock, flags);
3181 if (!(options & BIT_0)) { 3179 if (!(rsp->options & BIT_0)) {
3182 WRT_REG_DWORD(&reg->rsp_q_out, 0); 3180 WRT_REG_DWORD(&reg->rsp_q_out, 0);
3183 WRT_REG_DWORD(&reg->rsp_q_in, 0); 3181 WRT_REG_DWORD(&reg->rsp_q_in, 0);
3184 } 3182 }
@@ -3193,3 +3191,29 @@ qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp,
3193 return rval; 3191 return rval;
3194} 3192}
3195 3193
3194int
3195qla81xx_idc_ack(scsi_qla_host_t *vha, uint16_t *mb)
3196{
3197 int rval;
3198 mbx_cmd_t mc;
3199 mbx_cmd_t *mcp = &mc;
3200
3201 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
3202
3203 mcp->mb[0] = MBC_IDC_ACK;
3204 memcpy(&mcp->mb[1], mb, QLA_IDC_ACK_REGS * sizeof(uint16_t));
3205 mcp->out_mb = MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
3206 mcp->in_mb = MBX_0;
3207 mcp->tov = MBX_TOV_SECONDS;
3208 mcp->flags = 0;
3209 rval = qla2x00_mailbox_command(vha, mcp);
3210
3211 if (rval != QLA_SUCCESS) {
3212 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__,
3213 vha->host_no, rval, mcp->mb[0]));
3214 } else {
3215 DEBUG11(printk("%s(%ld): done.\n", __func__, vha->host_no));
3216 }
3217
3218 return rval;
3219}
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index f53179c46423..3f23932210c4 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -396,7 +396,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
396 396
397 qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL); 397 qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL);
398 398
399 memset(vha->req_ques, 0, sizeof(vha->req_ques) * QLA_MAX_HOST_QUES); 399 memset(vha->req_ques, 0, sizeof(vha->req_ques));
400 vha->req_ques[0] = ha->req_q_map[0]->id; 400 vha->req_ques[0] = ha->req_q_map[0]->id;
401 host->can_queue = ha->req_q_map[0]->length + 128; 401 host->can_queue = ha->req_q_map[0]->length + 128;
402 host->this_id = 255; 402 host->this_id = 255;
@@ -471,7 +471,7 @@ qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req)
471 471
472 if (req) { 472 if (req) {
473 req->options |= BIT_0; 473 req->options |= BIT_0;
474 ret = qla25xx_init_req_que(vha, req, req->options); 474 ret = qla25xx_init_req_que(vha, req);
475 } 475 }
476 if (ret == QLA_SUCCESS) 476 if (ret == QLA_SUCCESS)
477 qla25xx_free_req_que(vha, req); 477 qla25xx_free_req_que(vha, req);
@@ -486,7 +486,7 @@ qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
486 486
487 if (rsp) { 487 if (rsp) {
488 rsp->options |= BIT_0; 488 rsp->options |= BIT_0;
489 ret = qla25xx_init_rsp_que(vha, rsp, rsp->options); 489 ret = qla25xx_init_rsp_que(vha, rsp);
490 } 490 }
491 if (ret == QLA_SUCCESS) 491 if (ret == QLA_SUCCESS)
492 qla25xx_free_rsp_que(vha, rsp); 492 qla25xx_free_rsp_que(vha, rsp);
@@ -502,7 +502,7 @@ int qla25xx_update_req_que(struct scsi_qla_host *vha, uint8_t que, uint8_t qos)
502 502
503 req->options |= BIT_3; 503 req->options |= BIT_3;
504 req->qos = qos; 504 req->qos = qos;
505 ret = qla25xx_init_req_que(vha, req, req->options); 505 ret = qla25xx_init_req_que(vha, req);
506 if (ret != QLA_SUCCESS) 506 if (ret != QLA_SUCCESS)
507 DEBUG2_17(printk(KERN_WARNING "%s failed\n", __func__)); 507 DEBUG2_17(printk(KERN_WARNING "%s failed\n", __func__));
508 /* restore options bit */ 508 /* restore options bit */
@@ -632,7 +632,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
632 req->max_q_depth = ha->req_q_map[0]->max_q_depth; 632 req->max_q_depth = ha->req_q_map[0]->max_q_depth;
633 mutex_unlock(&ha->vport_lock); 633 mutex_unlock(&ha->vport_lock);
634 634
635 ret = qla25xx_init_req_que(base_vha, req, options); 635 ret = qla25xx_init_req_que(base_vha, req);
636 if (ret != QLA_SUCCESS) { 636 if (ret != QLA_SUCCESS) {
637 qla_printk(KERN_WARNING, ha, "%s failed\n", __func__); 637 qla_printk(KERN_WARNING, ha, "%s failed\n", __func__);
638 mutex_lock(&ha->vport_lock); 638 mutex_lock(&ha->vport_lock);
@@ -710,7 +710,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
710 if (ret) 710 if (ret)
711 goto que_failed; 711 goto que_failed;
712 712
713 ret = qla25xx_init_rsp_que(base_vha, rsp, options); 713 ret = qla25xx_init_rsp_que(base_vha, rsp);
714 if (ret != QLA_SUCCESS) { 714 if (ret != QLA_SUCCESS) {
715 qla_printk(KERN_WARNING, ha, "%s failed\n", __func__); 715 qla_printk(KERN_WARNING, ha, "%s failed\n", __func__);
716 mutex_lock(&ha->vport_lock); 716 mutex_lock(&ha->vport_lock);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index c11f872d3e10..2f5f72531e23 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -2522,6 +2522,19 @@ qla2x00_post_aen_work(struct scsi_qla_host *vha, enum fc_host_event_code code,
2522 return qla2x00_post_work(vha, e, 1); 2522 return qla2x00_post_work(vha, e, 1);
2523} 2523}
2524 2524
2525int
2526qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb)
2527{
2528 struct qla_work_evt *e;
2529
2530 e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK, 1);
2531 if (!e)
2532 return QLA_FUNCTION_FAILED;
2533
2534 memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t));
2535 return qla2x00_post_work(vha, e, 1);
2536}
2537
2525static void 2538static void
2526qla2x00_do_work(struct scsi_qla_host *vha) 2539qla2x00_do_work(struct scsi_qla_host *vha)
2527{ 2540{
@@ -2539,6 +2552,9 @@ qla2x00_do_work(struct scsi_qla_host *vha)
2539 fc_host_post_event(vha->host, fc_get_event_number(), 2552 fc_host_post_event(vha->host, fc_get_event_number(),
2540 e->u.aen.code, e->u.aen.data); 2553 e->u.aen.code, e->u.aen.data);
2541 break; 2554 break;
2555 case QLA_EVT_IDC_ACK:
2556 qla81xx_idc_ack(vha, e->u.idc_ack.mb);
2557 break;
2542 } 2558 }
2543 if (e->flags & QLA_EVT_FLAG_FREE) 2559 if (e->flags & QLA_EVT_FLAG_FREE)
2544 kfree(e); 2560 kfree(e);
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 9c3b694c049d..284827926eff 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -684,7 +684,7 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr)
684 "end=0x%x size=0x%x.\n", le32_to_cpu(region->code), start, 684 "end=0x%x size=0x%x.\n", le32_to_cpu(region->code), start,
685 le32_to_cpu(region->end) >> 2, le32_to_cpu(region->size))); 685 le32_to_cpu(region->end) >> 2, le32_to_cpu(region->size)));
686 686
687 switch (le32_to_cpu(region->code)) { 687 switch (le32_to_cpu(region->code) & 0xff) {
688 case FLT_REG_FW: 688 case FLT_REG_FW:
689 ha->flt_region_fw = start; 689 ha->flt_region_fw = start;
690 break; 690 break;
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index cfa4c11a4797..79f7053da99b 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.03.00-k2" 10#define QLA2XXX_VERSION "8.03.00-k3"
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
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 66505bb79410..8f4de20c9deb 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -317,6 +317,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
317 return sdev; 317 return sdev;
318 318
319out_device_destroy: 319out_device_destroy:
320 scsi_device_set_state(sdev, SDEV_DEL);
320 transport_destroy_device(&sdev->sdev_gendev); 321 transport_destroy_device(&sdev->sdev_gendev);
321 put_device(&sdev->sdev_gendev); 322 put_device(&sdev->sdev_gendev);
322out: 323out:
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 8f0bd3f7a59f..516925d8b570 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1078,7 +1078,7 @@ sg_ioctl(struct inode *inode, struct file *filp,
1078 case BLKTRACESETUP: 1078 case BLKTRACESETUP:
1079 return blk_trace_setup(sdp->device->request_queue, 1079 return blk_trace_setup(sdp->device->request_queue,
1080 sdp->disk->disk_name, 1080 sdp->disk->disk_name,
1081 sdp->device->sdev_gendev.devt, 1081 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
1082 (char *)arg); 1082 (char *)arg);
1083 case BLKTRACESTART: 1083 case BLKTRACESTART:
1084 return blk_trace_startstop(sdp->device->request_queue, 1); 1084 return blk_trace_startstop(sdp->device->request_queue, 1);
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 0d934bfbdd9b..b4b39811b445 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2083,6 +2083,20 @@ static int serial8250_startup(struct uart_port *port)
2083 2083
2084 serial8250_set_mctrl(&up->port, up->port.mctrl); 2084 serial8250_set_mctrl(&up->port, up->port.mctrl);
2085 2085
2086 /* Serial over Lan (SoL) hack:
2087 Intel 8257x Gigabit ethernet chips have a
2088 16550 emulation, to be used for Serial Over Lan.
2089 Those chips take a longer time than a normal
2090 serial device to signalize that a transmission
2091 data was queued. Due to that, the above test generally
2092 fails. One solution would be to delay the reading of
2093 iir. However, this is not reliable, since the timeout
2094 is variable. So, let's just don't test if we receive
2095 TX irq. This way, we'll never enable UART_BUG_TXEN.
2096 */
2097 if (up->port.flags & UPF_NO_TXEN_TEST)
2098 goto dont_test_tx_en;
2099
2086 /* 2100 /*
2087 * Do a quick test to see if we receive an 2101 * Do a quick test to see if we receive an
2088 * interrupt when we enable the TX irq. 2102 * interrupt when we enable the TX irq.
@@ -2102,6 +2116,7 @@ static int serial8250_startup(struct uart_port *port)
2102 up->bugs &= ~UART_BUG_TXEN; 2116 up->bugs &= ~UART_BUG_TXEN;
2103 } 2117 }
2104 2118
2119dont_test_tx_en:
2105 spin_unlock_irqrestore(&up->port.lock, flags); 2120 spin_unlock_irqrestore(&up->port.lock, flags);
2106 2121
2107 /* 2122 /*
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 536d8e510f66..533f82025adf 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -798,6 +798,21 @@ pci_default_setup(struct serial_private *priv,
798 return setup_port(priv, port, bar, offset, board->reg_shift); 798 return setup_port(priv, port, bar, offset, board->reg_shift);
799} 799}
800 800
801static int skip_tx_en_setup(struct serial_private *priv,
802 const struct pciserial_board *board,
803 struct uart_port *port, int idx)
804{
805 port->flags |= UPF_NO_TXEN_TEST;
806 printk(KERN_DEBUG "serial8250: skipping TxEn test for device "
807 "[%04x:%04x] subsystem [%04x:%04x]\n",
808 priv->dev->vendor,
809 priv->dev->device,
810 priv->dev->subsystem_vendor,
811 priv->dev->subsystem_device);
812
813 return pci_default_setup(priv, board, port, idx);
814}
815
801/* This should be in linux/pci_ids.h */ 816/* This should be in linux/pci_ids.h */
802#define PCI_VENDOR_ID_SBSMODULARIO 0x124B 817#define PCI_VENDOR_ID_SBSMODULARIO 0x124B
803#define PCI_SUBVENDOR_ID_SBSMODULARIO 0x124B 818#define PCI_SUBVENDOR_ID_SBSMODULARIO 0x124B
@@ -864,6 +879,27 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
864 .init = pci_inteli960ni_init, 879 .init = pci_inteli960ni_init,
865 .setup = pci_default_setup, 880 .setup = pci_default_setup,
866 }, 881 },
882 {
883 .vendor = PCI_VENDOR_ID_INTEL,
884 .device = PCI_DEVICE_ID_INTEL_8257X_SOL,
885 .subvendor = PCI_ANY_ID,
886 .subdevice = PCI_ANY_ID,
887 .setup = skip_tx_en_setup,
888 },
889 {
890 .vendor = PCI_VENDOR_ID_INTEL,
891 .device = PCI_DEVICE_ID_INTEL_82573L_SOL,
892 .subvendor = PCI_ANY_ID,
893 .subdevice = PCI_ANY_ID,
894 .setup = skip_tx_en_setup,
895 },
896 {
897 .vendor = PCI_VENDOR_ID_INTEL,
898 .device = PCI_DEVICE_ID_INTEL_82573E_SOL,
899 .subvendor = PCI_ANY_ID,
900 .subdevice = PCI_ANY_ID,
901 .setup = skip_tx_en_setup,
902 },
867 /* 903 /*
868 * ITE 904 * ITE
869 */ 905 */
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index 89362d733d62..8f58f7ff0dd7 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -877,6 +877,10 @@ static int atmel_startup(struct uart_port *port)
877 } 877 }
878 } 878 }
879 879
880 /* Save current CSR for comparison in atmel_tasklet_func() */
881 atmel_port->irq_status_prev = UART_GET_CSR(port);
882 atmel_port->irq_status = atmel_port->irq_status_prev;
883
880 /* 884 /*
881 * Finally, enable the serial port 885 * Finally, enable the serial port
882 */ 886 */
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index 92187e28608a..ac79cbe4c2cf 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -84,6 +84,8 @@ static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
84 brd->pci_dev = pdev; 84 brd->pci_dev = pdev;
85 if (pdev->device == PCIE_DEVICE_ID_NEO_4_IBM) 85 if (pdev->device == PCIE_DEVICE_ID_NEO_4_IBM)
86 brd->maxports = 4; 86 brd->maxports = 4;
87 else if (pdev->device == PCI_DEVICE_ID_DIGI_NEO_8)
88 brd->maxports = 8;
87 else 89 else
88 brd->maxports = 2; 90 brd->maxports = 2;
89 91
@@ -212,6 +214,7 @@ static struct pci_device_id jsm_pci_tbl[] = {
212 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45), 0, 0, 2 }, 214 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45), 0, 0, 2 },
213 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45PRI), 0, 0, 3 }, 215 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45PRI), 0, 0, 3 },
214 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCIE_DEVICE_ID_NEO_4_IBM), 0, 0, 4 }, 216 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCIE_DEVICE_ID_NEO_4_IBM), 0, 0, 4 },
217 { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_NEO_8), 0, 0, 5 },
215 { 0, } 218 { 0, }
216}; 219};
217MODULE_DEVICE_TABLE(pci, jsm_pci_tbl); 220MODULE_DEVICE_TABLE(pci, jsm_pci_tbl);
diff --git a/drivers/spi/spi_gpio.c b/drivers/spi/spi_gpio.c
index 49698cabc30d..f5ed9721aabb 100644
--- a/drivers/spi/spi_gpio.c
+++ b/drivers/spi/spi_gpio.c
@@ -114,7 +114,7 @@ static inline void setmosi(const struct spi_device *spi, int is_on)
114 114
115static inline int getmiso(const struct spi_device *spi) 115static inline int getmiso(const struct spi_device *spi)
116{ 116{
117 return gpio_get_value(SPI_MISO_GPIO); 117 return !!gpio_get_value(SPI_MISO_GPIO);
118} 118}
119 119
120#undef pdata 120#undef pdata
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 6b996db0dd6a..604bd1e0d546 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -27,6 +27,7 @@ menuconfig ANDROID_RAM_CONSOLE_ERROR_CORRECTION
27 bool "Android RAM Console Enable error correction" 27 bool "Android RAM Console Enable error correction"
28 default n 28 default n
29 depends on ANDROID_RAM_CONSOLE 29 depends on ANDROID_RAM_CONSOLE
30 depends on !ANDROID_RAM_CONSOLE_EARLY_INIT
30 select REED_SOLOMON 31 select REED_SOLOMON
31 select REED_SOLOMON_ENC8 32 select REED_SOLOMON_ENC8
32 select REED_SOLOMON_DEC8 33 select REED_SOLOMON_DEC8
diff --git a/drivers/staging/android/ram_console.c b/drivers/staging/android/ram_console.c
index bf006857a87a..643ac5ce381d 100644
--- a/drivers/staging/android/ram_console.c
+++ b/drivers/staging/android/ram_console.c
@@ -224,9 +224,23 @@ static int __init ram_console_init(struct ram_console_buffer *buffer,
224 ram_console_buffer_size = 224 ram_console_buffer_size =
225 buffer_size - sizeof(struct ram_console_buffer); 225 buffer_size - sizeof(struct ram_console_buffer);
226 226
227 if (ram_console_buffer_size > buffer_size) {
228 pr_err("ram_console: buffer %p, invalid size %d, datasize %d\n",
229 buffer, buffer_size, ram_console_buffer_size);
230 return 0;
231 }
232
227#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION 233#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
228 ram_console_buffer_size -= (DIV_ROUND_UP(ram_console_buffer_size, 234 ram_console_buffer_size -= (DIV_ROUND_UP(ram_console_buffer_size,
229 ECC_BLOCK_SIZE) + 1) * ECC_SIZE; 235 ECC_BLOCK_SIZE) + 1) * ECC_SIZE;
236
237 if (ram_console_buffer_size > buffer_size) {
238 pr_err("ram_console: buffer %p, invalid size %d, "
239 "non-ecc datasize %d\n",
240 buffer, buffer_size, ram_console_buffer_size);
241 return 0;
242 }
243
230 ram_console_par_buffer = buffer->data + ram_console_buffer_size; 244 ram_console_par_buffer = buffer->data + ram_console_buffer_size;
231 245
232 246
diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index 903270cbbe02..33daff0481d2 100644
--- a/drivers/staging/android/timed_gpio.c
+++ b/drivers/staging/android/timed_gpio.c
@@ -50,7 +50,7 @@ static ssize_t gpio_enable_show(struct device *dev, struct device_attribute *att
50 if (hrtimer_active(&gpio_data->timer)) { 50 if (hrtimer_active(&gpio_data->timer)) {
51 ktime_t r = hrtimer_get_remaining(&gpio_data->timer); 51 ktime_t r = hrtimer_get_remaining(&gpio_data->timer);
52 struct timeval t = ktime_to_timeval(r); 52 struct timeval t = ktime_to_timeval(r);
53 remaining = t.tv_sec * 1000 + t.tv_usec; 53 remaining = t.tv_sec * 1000 + t.tv_usec / 1000;
54 } else 54 } else
55 remaining = 0; 55 remaining = 0;
56 56
diff --git a/drivers/staging/at76_usb/Kconfig b/drivers/staging/at76_usb/Kconfig
index 4c0e55e15448..8606f9621624 100644
--- a/drivers/staging/at76_usb/Kconfig
+++ b/drivers/staging/at76_usb/Kconfig
@@ -1,6 +1,6 @@
1config USB_ATMEL 1config USB_ATMEL
2 tristate "Atmel at76c503/at76c505/at76c505a USB cards" 2 tristate "Atmel at76c503/at76c505/at76c505a USB cards"
3 depends on MAC80211 && WLAN_80211 && USB 3 depends on WLAN_80211 && USB
4 default N 4 default N
5 select FW_LOADER 5 select FW_LOADER
6 ---help--- 6 ---help---
diff --git a/drivers/staging/at76_usb/at76_usb.c b/drivers/staging/at76_usb/at76_usb.c
index 185533e54769..c8e4d31c7df2 100644
--- a/drivers/staging/at76_usb/at76_usb.c
+++ b/drivers/staging/at76_usb/at76_usb.c
@@ -6,7 +6,6 @@
6 * Copyright (c) 2004 Nick Jones 6 * Copyright (c) 2004 Nick Jones
7 * Copyright (c) 2004 Balint Seeber <n0_5p4m_p13453@hotmail.com> 7 * Copyright (c) 2004 Balint Seeber <n0_5p4m_p13453@hotmail.com>
8 * Copyright (c) 2007 Guido Guenther <agx@sigxcpu.org> 8 * Copyright (c) 2007 Guido Guenther <agx@sigxcpu.org>
9 * Copyright (c) 2007 Kalle Valo <kalle.valo@iki.fi>
10 * 9 *
11 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 11 * modify it under the terms of the GNU General Public License as
@@ -17,13 +16,6 @@
17 * Atmel AT76C503A/505/505A. 16 * Atmel AT76C503A/505/505A.
18 * 17 *
19 * Some iw_handler code was taken from airo.c, (C) 1999 Benjamin Reed 18 * Some iw_handler code was taken from airo.c, (C) 1999 Benjamin Reed
20 *
21 * TODO for the mac80211 port:
22 * o adhoc support
23 * o RTS/CTS support
24 * o Power Save Mode support
25 * o support for short/long preambles
26 * o export variables through debugfs/sysfs
27 */ 19 */
28 20
29#include <linux/init.h> 21#include <linux/init.h>
@@ -44,7 +36,7 @@
44#include <net/ieee80211_radiotap.h> 36#include <net/ieee80211_radiotap.h>
45#include <linux/firmware.h> 37#include <linux/firmware.h>
46#include <linux/leds.h> 38#include <linux/leds.h>
47#include <net/mac80211.h> 39#include <net/ieee80211.h>
48 40
49#include "at76_usb.h" 41#include "at76_usb.h"
50 42
@@ -84,43 +76,31 @@
84#define DBG_WE_EVENTS 0x08000000 /* dump wireless events */ 76#define DBG_WE_EVENTS 0x08000000 /* dump wireless events */
85#define DBG_FW 0x10000000 /* firmware download */ 77#define DBG_FW 0x10000000 /* firmware download */
86#define DBG_DFU 0x20000000 /* device firmware upgrade */ 78#define DBG_DFU 0x20000000 /* device firmware upgrade */
87#define DBG_CMD 0x40000000
88#define DBG_MAC80211 0x80000000
89 79
90#define DBG_DEFAULTS 0 80#define DBG_DEFAULTS 0
91 81
92/* Use our own dbg macro */ 82/* Use our own dbg macro */
93#define at76_dbg(bits, format, arg...) \ 83#define at76_dbg(bits, format, arg...) \
94do { \ 84 do { \
95 if (at76_debug & (bits)) \ 85 if (at76_debug & (bits)) \
96 printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \
97} while (0)
98
99#define at76_dbg_dump(bits, buf, len, format, arg...) \
100do { \
101 if (at76_debug & (bits)) { \
102 printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \ 86 printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \
103 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \ 87 } while (0)
104 } \
105} while (0)
106 88
107static int at76_debug = DBG_DEFAULTS; 89static int at76_debug = DBG_DEFAULTS;
108 90
109#define FIRMWARE_IS_WPA(ver) ((ver.major == 1) && (ver.minor == 103))
110
111/* Protect against concurrent firmware loading and parsing */ 91/* Protect against concurrent firmware loading and parsing */
112static struct mutex fw_mutex; 92static struct mutex fw_mutex;
113 93
114static struct fwentry firmwares[] = { 94static struct fwentry firmwares[] = {
115 [0] = { "" }, 95 [0] = {""},
116 [BOARD_503_ISL3861] = { "atmel_at76c503-i3861.bin" }, 96 [BOARD_503_ISL3861] = {"atmel_at76c503-i3861.bin"},
117 [BOARD_503_ISL3863] = { "atmel_at76c503-i3863.bin" }, 97 [BOARD_503_ISL3863] = {"atmel_at76c503-i3863.bin"},
118 [BOARD_503] = { "atmel_at76c503-rfmd.bin" }, 98 [BOARD_503] = {"atmel_at76c503-rfmd.bin"},
119 [BOARD_503_ACC] = { "atmel_at76c503-rfmd-acc.bin" }, 99 [BOARD_503_ACC] = {"atmel_at76c503-rfmd-acc.bin"},
120 [BOARD_505] = { "atmel_at76c505-rfmd.bin" }, 100 [BOARD_505] = {"atmel_at76c505-rfmd.bin"},
121 [BOARD_505_2958] = { "atmel_at76c505-rfmd2958.bin" }, 101 [BOARD_505_2958] = {"atmel_at76c505-rfmd2958.bin"},
122 [BOARD_505A] = { "atmel_at76c505a-rfmd2958.bin" }, 102 [BOARD_505A] = {"atmel_at76c505a-rfmd2958.bin"},
123 [BOARD_505AMX] = { "atmel_at76c505amx-rfmd.bin" }, 103 [BOARD_505AMX] = {"atmel_at76c505amx-rfmd.bin"},
124}; 104};
125 105
126#define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops) 106#define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops)
@@ -130,133 +110,135 @@ static struct usb_device_id dev_table[] = {
130 * at76c503-i3861 110 * at76c503-i3861
131 */ 111 */
132 /* Generic AT76C503/3861 device */ 112 /* Generic AT76C503/3861 device */
133 { USB_DEVICE(0x03eb, 0x7603), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 113 {USB_DEVICE(0x03eb, 0x7603), USB_DEVICE_DATA(BOARD_503_ISL3861)},
134 /* Linksys WUSB11 v2.1/v2.6 */ 114 /* Linksys WUSB11 v2.1/v2.6 */
135 { USB_DEVICE(0x066b, 0x2211), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 115 {USB_DEVICE(0x066b, 0x2211), USB_DEVICE_DATA(BOARD_503_ISL3861)},
136 /* Netgear MA101 rev. A */ 116 /* Netgear MA101 rev. A */
137 { USB_DEVICE(0x0864, 0x4100), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 117 {USB_DEVICE(0x0864, 0x4100), USB_DEVICE_DATA(BOARD_503_ISL3861)},
138 /* Tekram U300C / Allnet ALL0193 */ 118 /* Tekram U300C / Allnet ALL0193 */
139 { USB_DEVICE(0x0b3b, 0x1612), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 119 {USB_DEVICE(0x0b3b, 0x1612), USB_DEVICE_DATA(BOARD_503_ISL3861)},
140 /* HP HN210W J7801A */ 120 /* HP HN210W J7801A */
141 { USB_DEVICE(0x03f0, 0x011c), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 121 {USB_DEVICE(0x03f0, 0x011c), USB_DEVICE_DATA(BOARD_503_ISL3861)},
142 /* Sitecom/Z-Com/Zyxel M4Y-750 */ 122 /* Sitecom/Z-Com/Zyxel M4Y-750 */
143 { USB_DEVICE(0x0cde, 0x0001), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 123 {USB_DEVICE(0x0cde, 0x0001), USB_DEVICE_DATA(BOARD_503_ISL3861)},
144 /* Dynalink/Askey WLL013 (intersil) */ 124 /* Dynalink/Askey WLL013 (intersil) */
145 { USB_DEVICE(0x069a, 0x0320), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 125 {USB_DEVICE(0x069a, 0x0320), USB_DEVICE_DATA(BOARD_503_ISL3861)},
146 /* EZ connect 11Mpbs Wireless USB Adapter SMC2662W v1 */ 126 /* EZ connect 11Mpbs Wireless USB Adapter SMC2662W v1 */
147 { USB_DEVICE(0x0d5c, 0xa001), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 127 {USB_DEVICE(0x0d5c, 0xa001), USB_DEVICE_DATA(BOARD_503_ISL3861)},
148 /* BenQ AWL300 */ 128 /* BenQ AWL300 */
149 { USB_DEVICE(0x04a5, 0x9000), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 129 {USB_DEVICE(0x04a5, 0x9000), USB_DEVICE_DATA(BOARD_503_ISL3861)},
150 /* Addtron AWU-120, Compex WLU11 */ 130 /* Addtron AWU-120, Compex WLU11 */
151 { USB_DEVICE(0x05dd, 0xff31), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 131 {USB_DEVICE(0x05dd, 0xff31), USB_DEVICE_DATA(BOARD_503_ISL3861)},
152 /* Intel AP310 AnyPoint II USB */ 132 /* Intel AP310 AnyPoint II USB */
153 { USB_DEVICE(0x8086, 0x0200), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 133 {USB_DEVICE(0x8086, 0x0200), USB_DEVICE_DATA(BOARD_503_ISL3861)},
154 /* Dynalink L11U */ 134 /* Dynalink L11U */
155 { USB_DEVICE(0x0d8e, 0x7100), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 135 {USB_DEVICE(0x0d8e, 0x7100), USB_DEVICE_DATA(BOARD_503_ISL3861)},
156 /* Arescom WL-210, FCC id 07J-GL2411USB */ 136 /* Arescom WL-210, FCC id 07J-GL2411USB */
157 { USB_DEVICE(0x0d8e, 0x7110), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 137 {USB_DEVICE(0x0d8e, 0x7110), USB_DEVICE_DATA(BOARD_503_ISL3861)},
158 /* I-O DATA WN-B11/USB */ 138 /* I-O DATA WN-B11/USB */
159 { USB_DEVICE(0x04bb, 0x0919), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 139 {USB_DEVICE(0x04bb, 0x0919), USB_DEVICE_DATA(BOARD_503_ISL3861)},
160 /* BT Voyager 1010 */ 140 /* BT Voyager 1010 */
161 { USB_DEVICE(0x069a, 0x0821), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 141 {USB_DEVICE(0x069a, 0x0821), USB_DEVICE_DATA(BOARD_503_ISL3861)},
162 /* 142 /*
163 * at76c503-i3863 143 * at76c503-i3863
164 */ 144 */
165 /* Generic AT76C503/3863 device */ 145 /* Generic AT76C503/3863 device */
166 { USB_DEVICE(0x03eb, 0x7604), USB_DEVICE_DATA(BOARD_503_ISL3863) }, 146 {USB_DEVICE(0x03eb, 0x7604), USB_DEVICE_DATA(BOARD_503_ISL3863)},
167 /* Samsung SWL-2100U */ 147 /* Samsung SWL-2100U */
168 { USB_DEVICE(0x055d, 0xa000), USB_DEVICE_DATA(BOARD_503_ISL3863) }, 148 {USB_DEVICE(0x055d, 0xa000), USB_DEVICE_DATA(BOARD_503_ISL3863)},
169 /* 149 /*
170 * at76c503-rfmd 150 * at76c503-rfmd
171 */ 151 */
172 /* Generic AT76C503/RFMD device */ 152 /* Generic AT76C503/RFMD device */
173 { USB_DEVICE(0x03eb, 0x7605), USB_DEVICE_DATA(BOARD_503) }, 153 {USB_DEVICE(0x03eb, 0x7605), USB_DEVICE_DATA(BOARD_503)},
174 /* Dynalink/Askey WLL013 (rfmd) */ 154 /* Dynalink/Askey WLL013 (rfmd) */
175 { USB_DEVICE(0x069a, 0x0321), USB_DEVICE_DATA(BOARD_503) }, 155 {USB_DEVICE(0x069a, 0x0321), USB_DEVICE_DATA(BOARD_503)},
176 /* Linksys WUSB11 v2.6 */ 156 /* Linksys WUSB11 v2.6 */
177 { USB_DEVICE(0x077b, 0x2219), USB_DEVICE_DATA(BOARD_503) }, 157 {USB_DEVICE(0x077b, 0x2219), USB_DEVICE_DATA(BOARD_503)},
178 /* Network Everywhere NWU11B */ 158 /* Network Everywhere NWU11B */
179 { USB_DEVICE(0x077b, 0x2227), USB_DEVICE_DATA(BOARD_503) }, 159 {USB_DEVICE(0x077b, 0x2227), USB_DEVICE_DATA(BOARD_503)},
180 /* Netgear MA101 rev. B */ 160 /* Netgear MA101 rev. B */
181 { USB_DEVICE(0x0864, 0x4102), USB_DEVICE_DATA(BOARD_503) }, 161 {USB_DEVICE(0x0864, 0x4102), USB_DEVICE_DATA(BOARD_503)},
182 /* D-Link DWL-120 rev. E */ 162 /* D-Link DWL-120 rev. E */
183 { USB_DEVICE(0x2001, 0x3200), USB_DEVICE_DATA(BOARD_503) }, 163 {USB_DEVICE(0x2001, 0x3200), USB_DEVICE_DATA(BOARD_503)},
184 /* Actiontec 802UAT1, HWU01150-01UK */ 164 /* Actiontec 802UAT1, HWU01150-01UK */
185 { USB_DEVICE(0x1668, 0x7605), USB_DEVICE_DATA(BOARD_503) }, 165 {USB_DEVICE(0x1668, 0x7605), USB_DEVICE_DATA(BOARD_503)},
186 /* AirVast W-Buddie WN210 */ 166 /* AirVast W-Buddie WN210 */
187 { USB_DEVICE(0x03eb, 0x4102), USB_DEVICE_DATA(BOARD_503) }, 167 {USB_DEVICE(0x03eb, 0x4102), USB_DEVICE_DATA(BOARD_503)},
188 /* Dick Smith Electronics XH1153 802.11b USB adapter */ 168 /* Dick Smith Electronics XH1153 802.11b USB adapter */
189 { USB_DEVICE(0x1371, 0x5743), USB_DEVICE_DATA(BOARD_503) }, 169 {USB_DEVICE(0x1371, 0x5743), USB_DEVICE_DATA(BOARD_503)},
190 /* CNet CNUSB611 */ 170 /* CNet CNUSB611 */
191 { USB_DEVICE(0x1371, 0x0001), USB_DEVICE_DATA(BOARD_503) }, 171 {USB_DEVICE(0x1371, 0x0001), USB_DEVICE_DATA(BOARD_503)},
192 /* FiberLine FL-WL200U */ 172 /* FiberLine FL-WL200U */
193 { USB_DEVICE(0x1371, 0x0002), USB_DEVICE_DATA(BOARD_503) }, 173 {USB_DEVICE(0x1371, 0x0002), USB_DEVICE_DATA(BOARD_503)},
194 /* BenQ AWL400 USB stick */ 174 /* BenQ AWL400 USB stick */
195 { USB_DEVICE(0x04a5, 0x9001), USB_DEVICE_DATA(BOARD_503) }, 175 {USB_DEVICE(0x04a5, 0x9001), USB_DEVICE_DATA(BOARD_503)},
196 /* 3Com 3CRSHEW696 */ 176 /* 3Com 3CRSHEW696 */
197 { USB_DEVICE(0x0506, 0x0a01), USB_DEVICE_DATA(BOARD_503) }, 177 {USB_DEVICE(0x0506, 0x0a01), USB_DEVICE_DATA(BOARD_503)},
198 /* Siemens Santis ADSL WLAN USB adapter WLL 013 */ 178 /* Siemens Santis ADSL WLAN USB adapter WLL 013 */
199 { USB_DEVICE(0x0681, 0x001b), USB_DEVICE_DATA(BOARD_503) }, 179 {USB_DEVICE(0x0681, 0x001b), USB_DEVICE_DATA(BOARD_503)},
200 /* Belkin F5D6050, version 2 */ 180 /* Belkin F5D6050, version 2 */
201 { USB_DEVICE(0x050d, 0x0050), USB_DEVICE_DATA(BOARD_503) }, 181 {USB_DEVICE(0x050d, 0x0050), USB_DEVICE_DATA(BOARD_503)},
202 /* iBlitzz, BWU613 (not *B or *SB) */ 182 /* iBlitzz, BWU613 (not *B or *SB) */
203 { USB_DEVICE(0x07b8, 0xb000), USB_DEVICE_DATA(BOARD_503) }, 183 {USB_DEVICE(0x07b8, 0xb000), USB_DEVICE_DATA(BOARD_503)},
204 /* Gigabyte GN-WLBM101 */ 184 /* Gigabyte GN-WLBM101 */
205 { USB_DEVICE(0x1044, 0x8003), USB_DEVICE_DATA(BOARD_503) }, 185 {USB_DEVICE(0x1044, 0x8003), USB_DEVICE_DATA(BOARD_503)},
206 /* Planex GW-US11S */ 186 /* Planex GW-US11S */
207 { USB_DEVICE(0x2019, 0x3220), USB_DEVICE_DATA(BOARD_503) }, 187 {USB_DEVICE(0x2019, 0x3220), USB_DEVICE_DATA(BOARD_503)},
208 /* Internal WLAN adapter in h5[4,5]xx series iPAQs */ 188 /* Internal WLAN adapter in h5[4,5]xx series iPAQs */
209 { USB_DEVICE(0x049f, 0x0032), USB_DEVICE_DATA(BOARD_503) }, 189 {USB_DEVICE(0x049f, 0x0032), USB_DEVICE_DATA(BOARD_503)},
210 /* Corega Wireless LAN USB-11 mini */ 190 /* Corega Wireless LAN USB-11 mini */
211 { USB_DEVICE(0x07aa, 0x0011), USB_DEVICE_DATA(BOARD_503) }, 191 {USB_DEVICE(0x07aa, 0x0011), USB_DEVICE_DATA(BOARD_503)},
212 /* Corega Wireless LAN USB-11 mini2 */ 192 /* Corega Wireless LAN USB-11 mini2 */
213 { USB_DEVICE(0x07aa, 0x0018), USB_DEVICE_DATA(BOARD_503) }, 193 {USB_DEVICE(0x07aa, 0x0018), USB_DEVICE_DATA(BOARD_503)},
214 /* Uniden PCW100 */ 194 /* Uniden PCW100 */
215 { USB_DEVICE(0x05dd, 0xff35), USB_DEVICE_DATA(BOARD_503) }, 195 {USB_DEVICE(0x05dd, 0xff35), USB_DEVICE_DATA(BOARD_503)},
216 /* 196 /*
217 * at76c503-rfmd-acc 197 * at76c503-rfmd-acc
218 */ 198 */
219 /* SMC2664W */ 199 /* SMC2664W */
220 { USB_DEVICE(0x083a, 0x3501), USB_DEVICE_DATA(BOARD_503_ACC) }, 200 {USB_DEVICE(0x083a, 0x3501), USB_DEVICE_DATA(BOARD_503_ACC)},
221 /* Belkin F5D6050, SMC2662W v2, SMC2662W-AR */ 201 /* Belkin F5D6050, SMC2662W v2, SMC2662W-AR */
222 { USB_DEVICE(0x0d5c, 0xa002), USB_DEVICE_DATA(BOARD_503_ACC) }, 202 {USB_DEVICE(0x0d5c, 0xa002), USB_DEVICE_DATA(BOARD_503_ACC)},
223 /* 203 /*
224 * at76c505-rfmd 204 * at76c505-rfmd
225 */ 205 */
226 /* Generic AT76C505/RFMD */ 206 /* Generic AT76C505/RFMD */
227 { USB_DEVICE(0x03eb, 0x7606), USB_DEVICE_DATA(BOARD_505) }, 207 {USB_DEVICE(0x03eb, 0x7606), USB_DEVICE_DATA(BOARD_505)},
228 /* 208 /*
229 * at76c505-rfmd2958 209 * at76c505-rfmd2958
230 */ 210 */
231 /* Generic AT76C505/RFMD, OvisLink WL-1130USB */ 211 /* Generic AT76C505/RFMD, OvisLink WL-1130USB */
232 { USB_DEVICE(0x03eb, 0x7613), USB_DEVICE_DATA(BOARD_505_2958) }, 212 {USB_DEVICE(0x03eb, 0x7613), USB_DEVICE_DATA(BOARD_505_2958)},
233 /* Fiberline FL-WL240U */ 213 /* Fiberline FL-WL240U */
234 { USB_DEVICE(0x1371, 0x0014), USB_DEVICE_DATA(BOARD_505_2958) }, 214 {USB_DEVICE(0x1371, 0x0014), USB_DEVICE_DATA(BOARD_505_2958)},
235 /* CNet CNUSB-611G */ 215 /* CNet CNUSB-611G */
236 { USB_DEVICE(0x1371, 0x0013), USB_DEVICE_DATA(BOARD_505_2958) }, 216 {USB_DEVICE(0x1371, 0x0013), USB_DEVICE_DATA(BOARD_505_2958)},
237 /* Linksys WUSB11 v2.8 */ 217 /* Linksys WUSB11 v2.8 */
238 { USB_DEVICE(0x1915, 0x2233), USB_DEVICE_DATA(BOARD_505_2958) }, 218 {USB_DEVICE(0x1915, 0x2233), USB_DEVICE_DATA(BOARD_505_2958)},
239 /* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */ 219 /* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */
240 { USB_DEVICE(0x12fd, 0x1001), USB_DEVICE_DATA(BOARD_505_2958) }, 220 {USB_DEVICE(0x12fd, 0x1001), USB_DEVICE_DATA(BOARD_505_2958)},
241 /* Corega WLAN USB Stick 11 */ 221 /* Corega WLAN USB Stick 11 */
242 { USB_DEVICE(0x07aa, 0x7613), USB_DEVICE_DATA(BOARD_505_2958) }, 222 {USB_DEVICE(0x07aa, 0x7613), USB_DEVICE_DATA(BOARD_505_2958)},
243 /* Microstar MSI Box MS6978 */ 223 /* Microstar MSI Box MS6978 */
244 { USB_DEVICE(0x0db0, 0x1020), USB_DEVICE_DATA(BOARD_505_2958) }, 224 {USB_DEVICE(0x0db0, 0x1020), USB_DEVICE_DATA(BOARD_505_2958)},
245 /* 225 /*
246 * at76c505a-rfmd2958 226 * at76c505a-rfmd2958
247 */ 227 */
248 /* Generic AT76C505A device */ 228 /* Generic AT76C505A device */
249 { USB_DEVICE(0x03eb, 0x7614), USB_DEVICE_DATA(BOARD_505A) }, 229 {USB_DEVICE(0x03eb, 0x7614), USB_DEVICE_DATA(BOARD_505A)},
250 /* Generic AT76C505AS device */ 230 /* Generic AT76C505AS device */
251 { USB_DEVICE(0x03eb, 0x7617), USB_DEVICE_DATA(BOARD_505A) }, 231 {USB_DEVICE(0x03eb, 0x7617), USB_DEVICE_DATA(BOARD_505A)},
252 /* Siemens Gigaset USB WLAN Adapter 11 */ 232 /* Siemens Gigaset USB WLAN Adapter 11 */
253 { USB_DEVICE(0x1690, 0x0701), USB_DEVICE_DATA(BOARD_505A) }, 233 {USB_DEVICE(0x1690, 0x0701), USB_DEVICE_DATA(BOARD_505A)},
234 /* OQO Model 01+ Internal Wi-Fi */
235 {USB_DEVICE(0x1557, 0x0002), USB_DEVICE_DATA(BOARD_505A)},
254 /* 236 /*
255 * at76c505amx-rfmd 237 * at76c505amx-rfmd
256 */ 238 */
257 /* Generic AT76C505AMX device */ 239 /* Generic AT76C505AMX device */
258 { USB_DEVICE(0x03eb, 0x7615), USB_DEVICE_DATA(BOARD_505AMX) }, 240 {USB_DEVICE(0x03eb, 0x7615), USB_DEVICE_DATA(BOARD_505AMX)},
259 { } 241 {}
260}; 242};
261 243
262MODULE_DEVICE_TABLE(usb, dev_table); 244MODULE_DEVICE_TABLE(usb, dev_table);
@@ -264,8 +246,26 @@ MODULE_DEVICE_TABLE(usb, dev_table);
264/* Supported rates of this hardware, bit 7 marks basic rates */ 246/* Supported rates of this hardware, bit 7 marks basic rates */
265static const u8 hw_rates[] = { 0x82, 0x84, 0x0b, 0x16 }; 247static const u8 hw_rates[] = { 0x82, 0x84, 0x0b, 0x16 };
266 248
249/* Frequency of each channel in MHz */
250static const long channel_frequency[] = {
251 2412, 2417, 2422, 2427, 2432, 2437, 2442,
252 2447, 2452, 2457, 2462, 2467, 2472, 2484
253};
254
255#define NUM_CHANNELS ARRAY_SIZE(channel_frequency)
256
267static const char *const preambles[] = { "long", "short", "auto" }; 257static const char *const preambles[] = { "long", "short", "auto" };
268 258
259static const char *const mac_states[] = {
260 [MAC_INIT] = "INIT",
261 [MAC_SCANNING] = "SCANNING",
262 [MAC_AUTH] = "AUTH",
263 [MAC_ASSOC] = "ASSOC",
264 [MAC_JOINING] = "JOINING",
265 [MAC_CONNECTED] = "CONNECTED",
266 [MAC_OWN_IBSS] = "OWN_IBSS"
267};
268
269/* Firmware download */ 269/* Firmware download */
270/* DFU states */ 270/* DFU states */
271#define STATE_IDLE 0x00 271#define STATE_IDLE 0x00
@@ -300,30 +300,17 @@ struct dfu_status {
300 300
301static inline int at76_is_intersil(enum board_type board) 301static inline int at76_is_intersil(enum board_type board)
302{ 302{
303 if (board == BOARD_503_ISL3861 || board == BOARD_503_ISL3863) 303 return (board == BOARD_503_ISL3861 || board == BOARD_503_ISL3863);
304 return 1;
305 return 0;
306} 304}
307 305
308static inline int at76_is_503rfmd(enum board_type board) 306static inline int at76_is_503rfmd(enum board_type board)
309{ 307{
310 if (board == BOARD_503 || board == BOARD_503_ACC) 308 return (board == BOARD_503 || board == BOARD_503_ACC);
311 return 1;
312 return 0;
313}
314
315static inline int at76_is_505(enum board_type board)
316{
317 if (board == BOARD_505 || board == BOARD_505_2958)
318 return 1;
319 return 0;
320} 309}
321 310
322static inline int at76_is_505a(enum board_type board) 311static inline int at76_is_505a(enum board_type board)
323{ 312{
324 if (board == BOARD_505A || board == BOARD_505AMX) 313 return (board == BOARD_505A || board == BOARD_505AMX);
325 return 1;
326 return 0;
327} 314}
328 315
329/* Load a block of the first (internal) part of the firmware */ 316/* Load a block of the first (internal) part of the firmware */
@@ -504,6 +491,41 @@ exit:
504 return ret; 491 return ret;
505} 492}
506 493
494/* Report that the scan results are ready */
495static inline void at76_iwevent_scan_complete(struct net_device *netdev)
496{
497 union iwreq_data wrqu;
498 wrqu.data.length = 0;
499 wrqu.data.flags = 0;
500 wireless_send_event(netdev, SIOCGIWSCAN, &wrqu, NULL);
501 at76_dbg(DBG_WE_EVENTS, "%s: SIOCGIWSCAN sent", netdev->name);
502}
503
504static inline void at76_iwevent_bss_connect(struct net_device *netdev,
505 u8 *bssid)
506{
507 union iwreq_data wrqu;
508 wrqu.data.length = 0;
509 wrqu.data.flags = 0;
510 memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
511 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
512 wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
513 at76_dbg(DBG_WE_EVENTS, "%s: %s: SIOCGIWAP sent", netdev->name,
514 __func__);
515}
516
517static inline void at76_iwevent_bss_disconnect(struct net_device *netdev)
518{
519 union iwreq_data wrqu;
520 wrqu.data.length = 0;
521 wrqu.data.flags = 0;
522 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
523 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
524 wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
525 at76_dbg(DBG_WE_EVENTS, "%s: %s: SIOCGIWAP sent", netdev->name,
526 __func__);
527}
528
507#define HEX2STR_BUFFERS 4 529#define HEX2STR_BUFFERS 4
508#define HEX2STR_MAX_LEN 64 530#define HEX2STR_MAX_LEN 64
509#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10) 531#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10)
@@ -575,6 +597,37 @@ static void at76_ledtrig_tx_activity(void)
575 mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4); 597 mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4);
576} 598}
577 599
600/* Check if the given ssid is hidden */
601static inline int at76_is_hidden_ssid(u8 *ssid, int length)
602{
603 static const u8 zeros[32];
604
605 if (length == 0)
606 return 1;
607
608 if (length == 1 && ssid[0] == ' ')
609 return 1;
610
611 return (memcmp(ssid, zeros, length) == 0);
612}
613
614static inline void at76_free_bss_list(struct at76_priv *priv)
615{
616 struct list_head *next, *ptr;
617 unsigned long flags;
618
619 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
620
621 priv->curr_bss = NULL;
622
623 list_for_each_safe(ptr, next, &priv->bss_list) {
624 list_del(ptr);
625 kfree(list_entry(ptr, struct bss_info, list));
626 }
627
628 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
629}
630
578static int at76_remap(struct usb_device *udev) 631static int at76_remap(struct usb_device *udev)
579{ 632{
580 int ret; 633 int ret;
@@ -598,7 +651,7 @@ static int at76_get_op_mode(struct usb_device *udev)
598 return -ENOMEM; 651 return -ENOMEM;
599 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, 652 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33,
600 USB_TYPE_VENDOR | USB_DIR_IN | 653 USB_TYPE_VENDOR | USB_DIR_IN |
601 USB_RECIP_INTERFACE, 0x01, 0, &op_mode, 1, 654 USB_RECIP_INTERFACE, 0x01, 0, op_mode, 1,
602 USB_CTRL_GET_TIMEOUT); 655 USB_CTRL_GET_TIMEOUT);
603 saved = *op_mode; 656 saved = *op_mode;
604 kfree(op_mode); 657 kfree(op_mode);
@@ -676,7 +729,7 @@ exit:
676 kfree(hwcfg); 729 kfree(hwcfg);
677 if (ret < 0) 730 if (ret < 0)
678 printk(KERN_ERR "%s: cannot get HW Config (error %d)\n", 731 printk(KERN_ERR "%s: cannot get HW Config (error %d)\n",
679 wiphy_name(priv->hw->wiphy), ret); 732 priv->netdev->name, ret);
680 733
681 return ret; 734 return ret;
682} 735}
@@ -685,15 +738,15 @@ static struct reg_domain const *at76_get_reg_domain(u16 code)
685{ 738{
686 int i; 739 int i;
687 static struct reg_domain const fd_tab[] = { 740 static struct reg_domain const fd_tab[] = {
688 { 0x10, "FCC (USA)", 0x7ff }, /* ch 1-11 */ 741 {0x10, "FCC (USA)", 0x7ff}, /* ch 1-11 */
689 { 0x20, "IC (Canada)", 0x7ff }, /* ch 1-11 */ 742 {0x20, "IC (Canada)", 0x7ff}, /* ch 1-11 */
690 { 0x30, "ETSI (most of Europe)", 0x1fff }, /* ch 1-13 */ 743 {0x30, "ETSI (most of Europe)", 0x1fff}, /* ch 1-13 */
691 { 0x31, "Spain", 0x600 }, /* ch 10-11 */ 744 {0x31, "Spain", 0x600}, /* ch 10-11 */
692 { 0x32, "France", 0x1e00 }, /* ch 10-13 */ 745 {0x32, "France", 0x1e00}, /* ch 10-13 */
693 { 0x40, "MKK (Japan)", 0x2000 }, /* ch 14 */ 746 {0x40, "MKK (Japan)", 0x2000}, /* ch 14 */
694 { 0x41, "MKK1 (Japan)", 0x3fff }, /* ch 1-14 */ 747 {0x41, "MKK1 (Japan)", 0x3fff}, /* ch 1-14 */
695 { 0x50, "Israel", 0x3fc }, /* ch 3-9 */ 748 {0x50, "Israel", 0x3fc}, /* ch 3-9 */
696 { 0x00, "<unknown>", 0xffffffff } /* ch 1-32 */ 749 {0x00, "<unknown>", 0xffffffff} /* ch 1-32 */
697 }; 750 };
698 751
699 /* Last entry is fallback for unknown domain code */ 752 /* Last entry is fallback for unknown domain code */
@@ -731,7 +784,7 @@ static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd)
731 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x22, 784 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x22,
732 USB_TYPE_VENDOR | USB_DIR_IN | 785 USB_TYPE_VENDOR | USB_DIR_IN |
733 USB_RECIP_INTERFACE, cmd, 0, stat_buf, 786 USB_RECIP_INTERFACE, cmd, 0, stat_buf,
734 sizeof(stat_buf), USB_CTRL_GET_TIMEOUT); 787 40, USB_CTRL_GET_TIMEOUT);
735 if (ret >= 0) 788 if (ret >= 0)
736 ret = stat_buf[5]; 789 ret = stat_buf[5];
737 kfree(stat_buf); 790 kfree(stat_buf);
@@ -739,24 +792,6 @@ static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd)
739 return ret; 792 return ret;
740} 793}
741 794
742#define MAKE_CMD_CASE(c) case (c): return #c
743
744static const char *at76_get_cmd_string(u8 cmd_status)
745{
746 switch (cmd_status) {
747 MAKE_CMD_CASE(CMD_SET_MIB);
748 MAKE_CMD_CASE(CMD_GET_MIB);
749 MAKE_CMD_CASE(CMD_SCAN);
750 MAKE_CMD_CASE(CMD_JOIN);
751 MAKE_CMD_CASE(CMD_START_IBSS);
752 MAKE_CMD_CASE(CMD_RADIO_ON);
753 MAKE_CMD_CASE(CMD_RADIO_OFF);
754 MAKE_CMD_CASE(CMD_STARTUP);
755 }
756
757 return "UNKNOWN";
758}
759
760static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf, 795static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf,
761 int buf_size) 796 int buf_size)
762{ 797{
@@ -772,10 +807,6 @@ static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf,
772 cmd_buf->size = cpu_to_le16(buf_size); 807 cmd_buf->size = cpu_to_le16(buf_size);
773 memcpy(cmd_buf->data, buf, buf_size); 808 memcpy(cmd_buf->data, buf, buf_size);
774 809
775 at76_dbg_dump(DBG_CMD, cmd_buf, sizeof(struct at76_command) + buf_size,
776 "issuing command %s (0x%02x)",
777 at76_get_cmd_string(cmd), cmd);
778
779 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e, 810 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e,
780 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 811 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
781 0, 0, cmd_buf, 812 0, 0, cmd_buf,
@@ -813,13 +844,13 @@ static int at76_wait_completion(struct at76_priv *priv, int cmd)
813 status = at76_get_cmd_status(priv->udev, cmd); 844 status = at76_get_cmd_status(priv->udev, cmd);
814 if (status < 0) { 845 if (status < 0) {
815 printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n", 846 printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n",
816 wiphy_name(priv->hw->wiphy), status); 847 priv->netdev->name, status);
817 break; 848 break;
818 } 849 }
819 850
820 at76_dbg(DBG_WAIT_COMPLETE, 851 at76_dbg(DBG_WAIT_COMPLETE,
821 "%s: Waiting on cmd %d, status = %d (%s)", 852 "%s: Waiting on cmd %d, status = %d (%s)",
822 wiphy_name(priv->hw->wiphy), cmd, status, 853 priv->netdev->name, cmd, status,
823 at76_get_cmd_status_string(status)); 854 at76_get_cmd_status_string(status));
824 855
825 if (status != CMD_STATUS_IN_PROGRESS 856 if (status != CMD_STATUS_IN_PROGRESS
@@ -830,7 +861,7 @@ static int at76_wait_completion(struct at76_priv *priv, int cmd)
830 if (time_after(jiffies, timeout)) { 861 if (time_after(jiffies, timeout)) {
831 printk(KERN_ERR 862 printk(KERN_ERR
832 "%s: completion timeout for command %d\n", 863 "%s: completion timeout for command %d\n",
833 wiphy_name(priv->hw->wiphy), cmd); 864 priv->netdev->name, cmd);
834 status = -ETIMEDOUT; 865 status = -ETIMEDOUT;
835 break; 866 break;
836 } 867 }
@@ -853,7 +884,7 @@ static int at76_set_mib(struct at76_priv *priv, struct set_mib_buffer *buf)
853 if (ret != CMD_STATUS_COMPLETE) { 884 if (ret != CMD_STATUS_COMPLETE) {
854 printk(KERN_INFO 885 printk(KERN_INFO
855 "%s: set_mib: at76_wait_completion failed " 886 "%s: set_mib: at76_wait_completion failed "
856 "with %d\n", wiphy_name(priv->hw->wiphy), ret); 887 "with %d\n", priv->netdev->name, ret);
857 ret = -EIO; 888 ret = -EIO;
858 } 889 }
859 890
@@ -874,7 +905,7 @@ static int at76_set_radio(struct at76_priv *priv, int enable)
874 ret = at76_set_card_command(priv->udev, cmd, NULL, 0); 905 ret = at76_set_card_command(priv->udev, cmd, NULL, 0);
875 if (ret < 0) 906 if (ret < 0)
876 printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n", 907 printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n",
877 wiphy_name(priv->hw->wiphy), cmd, ret); 908 priv->netdev->name, cmd, ret);
878 else 909 else
879 ret = 1; 910 ret = 1;
880 911
@@ -895,7 +926,44 @@ static int at76_set_pm_mode(struct at76_priv *priv)
895 ret = at76_set_mib(priv, &priv->mib_buf); 926 ret = at76_set_mib(priv, &priv->mib_buf);
896 if (ret < 0) 927 if (ret < 0)
897 printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n", 928 printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n",
898 wiphy_name(priv->hw->wiphy), ret); 929 priv->netdev->name, ret);
930
931 return ret;
932}
933
934/* Set the association id for power save mode */
935static int at76_set_associd(struct at76_priv *priv, u16 id)
936{
937 int ret = 0;
938
939 priv->mib_buf.type = MIB_MAC_MGMT;
940 priv->mib_buf.size = 2;
941 priv->mib_buf.index = offsetof(struct mib_mac_mgmt, station_id);
942 priv->mib_buf.data.word = cpu_to_le16(id);
943
944 ret = at76_set_mib(priv, &priv->mib_buf);
945 if (ret < 0)
946 printk(KERN_ERR "%s: set_mib (associd) failed: %d\n",
947 priv->netdev->name, ret);
948
949 return ret;
950}
951
952/* Set the listen interval for power save mode */
953static int at76_set_listen_interval(struct at76_priv *priv, u16 interval)
954{
955 int ret = 0;
956
957 priv->mib_buf.type = MIB_MAC;
958 priv->mib_buf.size = 2;
959 priv->mib_buf.index = offsetof(struct mib_mac, listen_interval);
960 priv->mib_buf.data.word = cpu_to_le16(interval);
961
962 ret = at76_set_mib(priv, &priv->mib_buf);
963 if (ret < 0)
964 printk(KERN_ERR
965 "%s: set_mib (listen_interval) failed: %d\n",
966 priv->netdev->name, ret);
899 967
900 return ret; 968 return ret;
901} 969}
@@ -912,7 +980,7 @@ static int at76_set_preamble(struct at76_priv *priv, u8 type)
912 ret = at76_set_mib(priv, &priv->mib_buf); 980 ret = at76_set_mib(priv, &priv->mib_buf);
913 if (ret < 0) 981 if (ret < 0)
914 printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n", 982 printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n",
915 wiphy_name(priv->hw->wiphy), ret); 983 priv->netdev->name, ret);
916 984
917 return ret; 985 return ret;
918} 986}
@@ -929,7 +997,7 @@ static int at76_set_frag(struct at76_priv *priv, u16 size)
929 ret = at76_set_mib(priv, &priv->mib_buf); 997 ret = at76_set_mib(priv, &priv->mib_buf);
930 if (ret < 0) 998 if (ret < 0)
931 printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n", 999 printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n",
932 wiphy_name(priv->hw->wiphy), ret); 1000 priv->netdev->name, ret);
933 1001
934 return ret; 1002 return ret;
935} 1003}
@@ -946,7 +1014,7 @@ static int at76_set_rts(struct at76_priv *priv, u16 size)
946 ret = at76_set_mib(priv, &priv->mib_buf); 1014 ret = at76_set_mib(priv, &priv->mib_buf);
947 if (ret < 0) 1015 if (ret < 0)
948 printk(KERN_ERR "%s: set_mib (rts) failed: %d\n", 1016 printk(KERN_ERR "%s: set_mib (rts) failed: %d\n",
949 wiphy_name(priv->hw->wiphy), ret); 1017 priv->netdev->name, ret);
950 1018
951 return ret; 1019 return ret;
952} 1020}
@@ -963,41 +1031,24 @@ static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff)
963 ret = at76_set_mib(priv, &priv->mib_buf); 1031 ret = at76_set_mib(priv, &priv->mib_buf);
964 if (ret < 0) 1032 if (ret < 0)
965 printk(KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n", 1033 printk(KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n",
966 wiphy_name(priv->hw->wiphy), ret); 1034 priv->netdev->name, ret);
967 1035
968 return ret; 1036 return ret;
969} 1037}
970 1038
971static int at76_set_tkip_bssid(struct at76_priv *priv, const void *addr) 1039static int at76_add_mac_address(struct at76_priv *priv, void *addr)
972{ 1040{
973 int ret = 0; 1041 int ret = 0;
974 1042
975 priv->mib_buf.type = MIB_MAC_ENCRYPTION; 1043 priv->mib_buf.type = MIB_MAC_ADDR;
976 priv->mib_buf.size = ETH_ALEN; 1044 priv->mib_buf.size = ETH_ALEN;
977 priv->mib_buf.index = offsetof(struct mib_mac_encryption, tkip_bssid); 1045 priv->mib_buf.index = offsetof(struct mib_mac_addr, mac_addr);
978 memcpy(priv->mib_buf.data.addr, addr, ETH_ALEN); 1046 memcpy(priv->mib_buf.data.addr, addr, ETH_ALEN);
979 1047
980 ret = at76_set_mib(priv, &priv->mib_buf); 1048 ret = at76_set_mib(priv, &priv->mib_buf);
981 if (ret < 0) 1049 if (ret < 0)
982 printk(KERN_ERR "%s: set_mib (MAC_ENCRYPTION, tkip_bssid) failed: %d\n", 1050 printk(KERN_ERR "%s: set_mib (MAC_ADDR, mac_addr) failed: %d\n",
983 wiphy_name(priv->hw->wiphy), ret); 1051 priv->netdev->name, ret);
984
985 return ret;
986}
987
988static int at76_reset_rsc(struct at76_priv *priv)
989{
990 int ret = 0;
991
992 priv->mib_buf.type = MIB_MAC_ENCRYPTION;
993 priv->mib_buf.size = 4 * 8;
994 priv->mib_buf.index = offsetof(struct mib_mac_encryption, key_rsc);
995 memset(priv->mib_buf.data.data, 0 , priv->mib_buf.size);
996
997 ret = at76_set_mib(priv, &priv->mib_buf);
998 if (ret < 0)
999 printk(KERN_ERR "%s: set_mib (MAC_ENCRYPTION, key_rsc) failed: %d\n",
1000 wiphy_name(priv->hw->wiphy), ret);
1001 1052
1002 return ret; 1053 return ret;
1003} 1054}
@@ -1016,16 +1067,16 @@ static void at76_dump_mib_mac_addr(struct at76_priv *priv)
1016 sizeof(struct mib_mac_addr)); 1067 sizeof(struct mib_mac_addr));
1017 if (ret < 0) { 1068 if (ret < 0) {
1018 printk(KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n", 1069 printk(KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n",
1019 wiphy_name(priv->hw->wiphy), ret); 1070 priv->netdev->name, ret);
1020 goto exit; 1071 goto exit;
1021 } 1072 }
1022 1073
1023 at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x", 1074 at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x",
1024 wiphy_name(priv->hw->wiphy), 1075 priv->netdev->name,
1025 mac2str(m->mac_addr), m->res[0], m->res[1]); 1076 mac2str(m->mac_addr), m->res[0], m->res[1]);
1026 for (i = 0; i < ARRAY_SIZE(m->group_addr); i++) 1077 for (i = 0; i < ARRAY_SIZE(m->group_addr); i++)
1027 at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %s, " 1078 at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %s, "
1028 "status %d", wiphy_name(priv->hw->wiphy), i, 1079 "status %d", priv->netdev->name, i,
1029 mac2str(m->group_addr[i]), m->group_addr_status[i]); 1080 mac2str(m->group_addr[i]), m->group_addr_status[i]);
1030exit: 1081exit:
1031 kfree(m); 1082 kfree(m);
@@ -1045,13 +1096,13 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv)
1045 sizeof(struct mib_mac_wep)); 1096 sizeof(struct mib_mac_wep));
1046 if (ret < 0) { 1097 if (ret < 0) {
1047 printk(KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n", 1098 printk(KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n",
1048 wiphy_name(priv->hw->wiphy), ret); 1099 priv->netdev->name, ret);
1049 goto exit; 1100 goto exit;
1050 } 1101 }
1051 1102
1052 at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: priv_invoked %u def_key_id %u " 1103 at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: priv_invoked %u def_key_id %u "
1053 "key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u " 1104 "key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u "
1054 "encr_level %u key %d", wiphy_name(priv->hw->wiphy), 1105 "encr_level %u key %d", priv->netdev->name,
1055 m->privacy_invoked, m->wep_default_key_id, 1106 m->privacy_invoked, m->wep_default_key_id,
1056 m->wep_key_mapping_len, m->exclude_unencrypted, 1107 m->wep_key_mapping_len, m->exclude_unencrypted,
1057 le32_to_cpu(m->wep_icv_error_count), 1108 le32_to_cpu(m->wep_icv_error_count),
@@ -1063,55 +1114,12 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv)
1063 1114
1064 for (i = 0; i < WEP_KEYS; i++) 1115 for (i = 0; i < WEP_KEYS; i++)
1065 at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: key %d: %s", 1116 at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: key %d: %s",
1066 wiphy_name(priv->hw->wiphy), i, 1117 priv->netdev->name, i,
1067 hex2str(m->wep_default_keyvalue[i], key_len)); 1118 hex2str(m->wep_default_keyvalue[i], key_len));
1068exit: 1119exit:
1069 kfree(m); 1120 kfree(m);
1070} 1121}
1071 1122
1072static void at76_dump_mib_mac_encryption(struct at76_priv *priv)
1073{
1074 int i;
1075 int ret;
1076 /*int key_len;*/
1077 struct mib_mac_encryption *m;
1078
1079 m = kmalloc(sizeof(struct mib_mac_encryption), GFP_KERNEL);
1080 if (!m)
1081 return;
1082
1083 ret = at76_get_mib(priv->udev, MIB_MAC_ENCRYPTION, m,
1084 sizeof(struct mib_mac_encryption));
1085 if (ret < 0) {
1086 dev_err(&priv->udev->dev,
1087 "%s: at76_get_mib (MAC_ENCRYPTION) failed: %d\n",
1088 wiphy_name(priv->hw->wiphy), ret);
1089 goto exit;
1090 }
1091
1092 at76_dbg(DBG_MIB,
1093 "%s: MIB MAC_ENCRYPTION: tkip_bssid %s priv_invoked %u "
1094 "ciph_key_id %u grp_key_id %u excl_unencr %u "
1095 "ckip_key_perm %u wep_icv_err %u wep_excluded %u",
1096 wiphy_name(priv->hw->wiphy), mac2str(m->tkip_bssid),
1097 m->privacy_invoked, m->cipher_default_key_id,
1098 m->cipher_default_group_key_id, m->exclude_unencrypted,
1099 m->ckip_key_permutation,
1100 le32_to_cpu(m->wep_icv_error_count),
1101 le32_to_cpu(m->wep_excluded_count));
1102
1103 /*key_len = (m->encryption_level == 1) ?
1104 WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN;*/
1105
1106 for (i = 0; i < CIPHER_KEYS; i++)
1107 at76_dbg(DBG_MIB, "%s: MIB MAC_ENCRYPTION: key %d: %s",
1108 wiphy_name(priv->hw->wiphy), i,
1109 hex2str(m->cipher_default_keyvalue[i],
1110 CIPHER_KEY_LEN));
1111exit:
1112 kfree(m);
1113}
1114
1115static void at76_dump_mib_mac_mgmt(struct at76_priv *priv) 1123static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
1116{ 1124{
1117 int ret; 1125 int ret;
@@ -1125,7 +1133,7 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
1125 sizeof(struct mib_mac_mgmt)); 1133 sizeof(struct mib_mac_mgmt));
1126 if (ret < 0) { 1134 if (ret < 0) {
1127 printk(KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n", 1135 printk(KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n",
1128 wiphy_name(priv->hw->wiphy), ret); 1136 priv->netdev->name, ret);
1129 goto exit; 1137 goto exit;
1130 } 1138 }
1131 1139
@@ -1136,7 +1144,7 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
1136 "pm_mode %d ibss_change %d res %d " 1144 "pm_mode %d ibss_change %d res %d "
1137 "multi_domain_capability_implemented %d " 1145 "multi_domain_capability_implemented %d "
1138 "international_roaming %d country_string %.3s", 1146 "international_roaming %d country_string %.3s",
1139 wiphy_name(priv->hw->wiphy), le16_to_cpu(m->beacon_period), 1147 priv->netdev->name, le16_to_cpu(m->beacon_period),
1140 le16_to_cpu(m->CFP_max_duration), 1148 le16_to_cpu(m->CFP_max_duration),
1141 le16_to_cpu(m->medium_occupancy_limit), 1149 le16_to_cpu(m->medium_occupancy_limit),
1142 le16_to_cpu(m->station_id), le16_to_cpu(m->ATIM_window), 1150 le16_to_cpu(m->station_id), le16_to_cpu(m->ATIM_window),
@@ -1161,7 +1169,7 @@ static void at76_dump_mib_mac(struct at76_priv *priv)
1161 ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac)); 1169 ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac));
1162 if (ret < 0) { 1170 if (ret < 0) {
1163 printk(KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n", 1171 printk(KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n",
1164 wiphy_name(priv->hw->wiphy), ret); 1172 priv->netdev->name, ret);
1165 goto exit; 1173 goto exit;
1166 } 1174 }
1167 1175
@@ -1171,8 +1179,7 @@ static void at76_dump_mib_mac(struct at76_priv *priv)
1171 "scan_type %d scan_channel %d probe_delay %u " 1179 "scan_type %d scan_channel %d probe_delay %u "
1172 "min_channel_time %d max_channel_time %d listen_int %d " 1180 "min_channel_time %d max_channel_time %d listen_int %d "
1173 "desired_ssid %s desired_bssid %s desired_bsstype %d", 1181 "desired_ssid %s desired_bssid %s desired_bsstype %d",
1174 wiphy_name(priv->hw->wiphy), 1182 priv->netdev->name, le32_to_cpu(m->max_tx_msdu_lifetime),
1175 le32_to_cpu(m->max_tx_msdu_lifetime),
1176 le32_to_cpu(m->max_rx_lifetime), 1183 le32_to_cpu(m->max_rx_lifetime),
1177 le16_to_cpu(m->frag_threshold), le16_to_cpu(m->rts_threshold), 1184 le16_to_cpu(m->frag_threshold), le16_to_cpu(m->rts_threshold),
1178 le16_to_cpu(m->cwmin), le16_to_cpu(m->cwmax), 1185 le16_to_cpu(m->cwmin), le16_to_cpu(m->cwmax),
@@ -1198,7 +1205,7 @@ static void at76_dump_mib_phy(struct at76_priv *priv)
1198 ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy)); 1205 ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy));
1199 if (ret < 0) { 1206 if (ret < 0) {
1200 printk(KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n", 1207 printk(KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n",
1201 wiphy_name(priv->hw->wiphy), ret); 1208 priv->netdev->name, ret);
1202 goto exit; 1209 goto exit;
1203 } 1210 }
1204 1211
@@ -1207,7 +1214,7 @@ static void at76_dump_mib_phy(struct at76_priv *priv)
1207 "mpdu_max_length %d cca_mode_supported %d operation_rate_set " 1214 "mpdu_max_length %d cca_mode_supported %d operation_rate_set "
1208 "0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d " 1215 "0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d "
1209 "phy_type %d current_reg_domain %d", 1216 "phy_type %d current_reg_domain %d",
1210 wiphy_name(priv->hw->wiphy), le32_to_cpu(m->ed_threshold), 1217 priv->netdev->name, le32_to_cpu(m->ed_threshold),
1211 le16_to_cpu(m->slot_time), le16_to_cpu(m->sifs_time), 1218 le16_to_cpu(m->slot_time), le16_to_cpu(m->sifs_time),
1212 le16_to_cpu(m->preamble_length), 1219 le16_to_cpu(m->preamble_length),
1213 le16_to_cpu(m->plcp_header_length), 1220 le16_to_cpu(m->plcp_header_length),
@@ -1231,14 +1238,13 @@ static void at76_dump_mib_local(struct at76_priv *priv)
1231 ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local)); 1238 ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local));
1232 if (ret < 0) { 1239 if (ret < 0) {
1233 printk(KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n", 1240 printk(KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n",
1234 wiphy_name(priv->hw->wiphy), ret); 1241 priv->netdev->name, ret);
1235 goto exit; 1242 goto exit;
1236 } 1243 }
1237 1244
1238 at76_dbg(DBG_MIB, "%s: MIB LOCAL: beacon_enable %d " 1245 at76_dbg(DBG_MIB, "%s: MIB LOCAL: beacon_enable %d "
1239 "txautorate_fallback %d ssid_size %d promiscuous_mode %d " 1246 "txautorate_fallback %d ssid_size %d promiscuous_mode %d "
1240 "preamble_type %d", wiphy_name(priv->hw->wiphy), 1247 "preamble_type %d", priv->netdev->name, m->beacon_enable,
1241 m->beacon_enable,
1242 m->txautorate_fallback, m->ssid_size, m->promiscuous_mode, 1248 m->txautorate_fallback, m->ssid_size, m->promiscuous_mode,
1243 m->preamble_type); 1249 m->preamble_type);
1244exit: 1250exit:
@@ -1257,21 +1263,118 @@ static void at76_dump_mib_mdomain(struct at76_priv *priv)
1257 sizeof(struct mib_mdomain)); 1263 sizeof(struct mib_mdomain));
1258 if (ret < 0) { 1264 if (ret < 0) {
1259 printk(KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n", 1265 printk(KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n",
1260 wiphy_name(priv->hw->wiphy), ret); 1266 priv->netdev->name, ret);
1261 goto exit; 1267 goto exit;
1262 } 1268 }
1263 1269
1264 at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s", 1270 at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s",
1265 wiphy_name(priv->hw->wiphy), 1271 priv->netdev->name,
1266 hex2str(m->channel_list, sizeof(m->channel_list))); 1272 hex2str(m->channel_list, sizeof(m->channel_list)));
1267 1273
1268 at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: tx_powerlevel %s", 1274 at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: tx_powerlevel %s",
1269 wiphy_name(priv->hw->wiphy), 1275 priv->netdev->name,
1270 hex2str(m->tx_powerlevel, sizeof(m->tx_powerlevel))); 1276 hex2str(m->tx_powerlevel, sizeof(m->tx_powerlevel)));
1271exit: 1277exit:
1272 kfree(m); 1278 kfree(m);
1273} 1279}
1274 1280
1281static int at76_get_current_bssid(struct at76_priv *priv)
1282{
1283 int ret = 0;
1284 struct mib_mac_mgmt *mac_mgmt =
1285 kmalloc(sizeof(struct mib_mac_mgmt), GFP_KERNEL);
1286
1287 if (!mac_mgmt) {
1288 ret = -ENOMEM;
1289 goto exit;
1290 }
1291
1292 ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, mac_mgmt,
1293 sizeof(struct mib_mac_mgmt));
1294 if (ret < 0) {
1295 printk(KERN_ERR "%s: at76_get_mib failed: %d\n",
1296 priv->netdev->name, ret);
1297 goto error;
1298 }
1299 memcpy(priv->bssid, mac_mgmt->current_bssid, ETH_ALEN);
1300 printk(KERN_INFO "%s: using BSSID %s\n", priv->netdev->name,
1301 mac2str(priv->bssid));
1302error:
1303 kfree(mac_mgmt);
1304exit:
1305 return ret;
1306}
1307
1308static int at76_get_current_channel(struct at76_priv *priv)
1309{
1310 int ret = 0;
1311 struct mib_phy *phy = kmalloc(sizeof(struct mib_phy), GFP_KERNEL);
1312
1313 if (!phy) {
1314 ret = -ENOMEM;
1315 goto exit;
1316 }
1317 ret = at76_get_mib(priv->udev, MIB_PHY, phy, sizeof(struct mib_phy));
1318 if (ret < 0) {
1319 printk(KERN_ERR "%s: at76_get_mib(MIB_PHY) failed: %d\n",
1320 priv->netdev->name, ret);
1321 goto error;
1322 }
1323 priv->channel = phy->channel_id;
1324error:
1325 kfree(phy);
1326exit:
1327 return ret;
1328}
1329
1330/**
1331 * at76_start_scan - start a scan
1332 *
1333 * @use_essid - use the configured ESSID in non passive mode
1334 */
1335static int at76_start_scan(struct at76_priv *priv, int use_essid)
1336{
1337 struct at76_req_scan scan;
1338
1339 memset(&scan, 0, sizeof(struct at76_req_scan));
1340 memset(scan.bssid, 0xff, ETH_ALEN);
1341
1342 if (use_essid) {
1343 memcpy(scan.essid, priv->essid, IW_ESSID_MAX_SIZE);
1344 scan.essid_size = priv->essid_size;
1345 } else
1346 scan.essid_size = 0;
1347
1348 /* jal: why should we start at a certain channel? we do scan the whole
1349 range allowed by reg domain. */
1350 scan.channel = priv->channel;
1351
1352 /* atmelwlandriver differs between scan type 0 and 1 (active/passive)
1353 For ad-hoc mode, it uses type 0 only. */
1354 scan.scan_type = priv->scan_mode;
1355
1356 /* INFO: For probe_delay, not multiplying by 1024 as this will be
1357 slightly less than min_channel_time
1358 (per spec: probe delay < min. channel time) */
1359 scan.min_channel_time = cpu_to_le16(priv->scan_min_time);
1360 scan.max_channel_time = cpu_to_le16(priv->scan_max_time);
1361 scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000);
1362 scan.international_scan = 0;
1363
1364 /* other values are set to 0 for type 0 */
1365
1366 at76_dbg(DBG_PROGRESS, "%s: start_scan (use_essid = %d, intl = %d, "
1367 "channel = %d, probe_delay = %d, scan_min_time = %d, "
1368 "scan_max_time = %d)",
1369 priv->netdev->name, use_essid,
1370 scan.international_scan, scan.channel,
1371 le16_to_cpu(scan.probe_delay),
1372 le16_to_cpu(scan.min_channel_time),
1373 le16_to_cpu(scan.max_channel_time));
1374
1375 return at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan));
1376}
1377
1275/* Enable monitor mode */ 1378/* Enable monitor mode */
1276static int at76_start_monitor(struct at76_priv *priv) 1379static int at76_start_monitor(struct at76_priv *priv)
1277{ 1380{
@@ -1292,6 +1395,86 @@ static int at76_start_monitor(struct at76_priv *priv)
1292 return ret; 1395 return ret;
1293} 1396}
1294 1397
1398static int at76_start_ibss(struct at76_priv *priv)
1399{
1400 struct at76_req_ibss bss;
1401 int ret;
1402
1403 WARN_ON(priv->mac_state != MAC_OWN_IBSS);
1404 if (priv->mac_state != MAC_OWN_IBSS)
1405 return -EBUSY;
1406
1407 memset(&bss, 0, sizeof(struct at76_req_ibss));
1408 memset(bss.bssid, 0xff, ETH_ALEN);
1409 memcpy(bss.essid, priv->essid, IW_ESSID_MAX_SIZE);
1410 bss.essid_size = priv->essid_size;
1411 bss.bss_type = ADHOC_MODE;
1412 bss.channel = priv->channel;
1413
1414 ret = at76_set_card_command(priv->udev, CMD_START_IBSS, &bss,
1415 sizeof(struct at76_req_ibss));
1416 if (ret < 0) {
1417 printk(KERN_ERR "%s: start_ibss failed: %d\n",
1418 priv->netdev->name, ret);
1419 return ret;
1420 }
1421
1422 ret = at76_wait_completion(priv, CMD_START_IBSS);
1423 if (ret != CMD_STATUS_COMPLETE) {
1424 printk(KERN_ERR "%s: start_ibss failed to complete, %d\n",
1425 priv->netdev->name, ret);
1426 return ret;
1427 }
1428
1429 ret = at76_get_current_bssid(priv);
1430 if (ret < 0)
1431 return ret;
1432
1433 ret = at76_get_current_channel(priv);
1434 if (ret < 0)
1435 return ret;
1436
1437 /* not sure what this is good for ??? */
1438 priv->mib_buf.type = MIB_MAC_MGMT;
1439 priv->mib_buf.size = 1;
1440 priv->mib_buf.index = offsetof(struct mib_mac_mgmt, ibss_change);
1441 priv->mib_buf.data.byte = 0;
1442
1443 ret = at76_set_mib(priv, &priv->mib_buf);
1444 if (ret < 0) {
1445 printk(KERN_ERR "%s: set_mib (ibss change ok) failed: %d\n",
1446 priv->netdev->name, ret);
1447 return ret;
1448 }
1449
1450 netif_carrier_on(priv->netdev);
1451 netif_start_queue(priv->netdev);
1452 return 0;
1453}
1454
1455/* Request card to join BSS in managed or ad-hoc mode */
1456static int at76_join_bss(struct at76_priv *priv, struct bss_info *ptr)
1457{
1458 struct at76_req_join join;
1459
1460 BUG_ON(!ptr);
1461
1462 memset(&join, 0, sizeof(struct at76_req_join));
1463 memcpy(join.bssid, ptr->bssid, ETH_ALEN);
1464 memcpy(join.essid, ptr->ssid, ptr->ssid_len);
1465 join.essid_size = ptr->ssid_len;
1466 join.bss_type = (priv->iw_mode == IW_MODE_ADHOC ? 1 : 2);
1467 join.channel = ptr->channel;
1468 join.timeout = cpu_to_le16(2000);
1469
1470 at76_dbg(DBG_PROGRESS,
1471 "%s join addr %s ssid %s type %d ch %d timeout %d",
1472 priv->netdev->name, mac2str(join.bssid), join.essid,
1473 join.bss_type, join.channel, le16_to_cpu(join.timeout));
1474 return at76_set_card_command(priv->udev, CMD_JOIN, &join,
1475 sizeof(struct at76_req_join));
1476}
1477
1295/* Calculate padding from txbuf->wlength (which excludes the USB TX header), 1478/* Calculate padding from txbuf->wlength (which excludes the USB TX header),
1296 likely to compensate a flaw in the AT76C503A USB part ... */ 1479 likely to compensate a flaw in the AT76C503A USB part ... */
1297static inline int at76_calc_padding(int wlen) 1480static inline int at76_calc_padding(int wlen)
@@ -1310,6 +1493,14 @@ static inline int at76_calc_padding(int wlen)
1310 return 0; 1493 return 0;
1311} 1494}
1312 1495
1496/* We are doing a lot of things here in an interrupt. Need
1497 a bh handler (Watching TV with a TV card is probably
1498 a good test: if you see flickers, we are doing too much.
1499 Currently I do see flickers... even with our tasklet :-( )
1500 Maybe because the bttv driver and usb-uhci use the same interrupt
1501*/
1502/* Or maybe because our BH handler is preempting bttv's BH handler.. BHs don't
1503 * solve everything.. (alex) */
1313static void at76_rx_callback(struct urb *urb) 1504static void at76_rx_callback(struct urb *urb)
1314{ 1505{
1315 struct at76_priv *priv = urb->context; 1506 struct at76_priv *priv = urb->context;
@@ -1319,6 +1510,1758 @@ static void at76_rx_callback(struct urb *urb)
1319 return; 1510 return;
1320} 1511}
1321 1512
1513static void at76_tx_callback(struct urb *urb)
1514{
1515 struct at76_priv *priv = urb->context;
1516 struct net_device_stats *stats = &priv->stats;
1517 unsigned long flags;
1518 struct at76_tx_buffer *mgmt_buf;
1519 int ret;
1520
1521 switch (urb->status) {
1522 case 0:
1523 stats->tx_packets++;
1524 break;
1525 case -ENOENT:
1526 case -ECONNRESET:
1527 /* urb has been unlinked */
1528 return;
1529 default:
1530 at76_dbg(DBG_URB, "%s - nonzero tx status received: %d",
1531 __func__, urb->status);
1532 stats->tx_errors++;
1533 break;
1534 }
1535
1536 spin_lock_irqsave(&priv->mgmt_spinlock, flags);
1537 mgmt_buf = priv->next_mgmt_bulk;
1538 priv->next_mgmt_bulk = NULL;
1539 spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
1540
1541 if (!mgmt_buf) {
1542 netif_wake_queue(priv->netdev);
1543 return;
1544 }
1545
1546 /* we don't copy the padding bytes, but add them
1547 to the length */
1548 memcpy(priv->bulk_out_buffer, mgmt_buf,
1549 le16_to_cpu(mgmt_buf->wlength) + AT76_TX_HDRLEN);
1550 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe,
1551 priv->bulk_out_buffer,
1552 le16_to_cpu(mgmt_buf->wlength) + mgmt_buf->padding +
1553 AT76_TX_HDRLEN, at76_tx_callback, priv);
1554 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
1555 if (ret)
1556 printk(KERN_ERR "%s: error in tx submit urb: %d\n",
1557 priv->netdev->name, ret);
1558
1559 kfree(mgmt_buf);
1560}
1561
1562/* Send a management frame on bulk-out. txbuf->wlength must be set */
1563static int at76_tx_mgmt(struct at76_priv *priv, struct at76_tx_buffer *txbuf)
1564{
1565 unsigned long flags;
1566 int ret;
1567 int urb_status;
1568 void *oldbuf = NULL;
1569
1570 netif_carrier_off(priv->netdev); /* stop netdev watchdog */
1571 netif_stop_queue(priv->netdev); /* stop tx data packets */
1572
1573 spin_lock_irqsave(&priv->mgmt_spinlock, flags);
1574
1575 urb_status = priv->tx_urb->status;
1576 if (urb_status == -EINPROGRESS) {
1577 /* cannot transmit now, put in the queue */
1578 oldbuf = priv->next_mgmt_bulk;
1579 priv->next_mgmt_bulk = txbuf;
1580 }
1581 spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
1582
1583 if (oldbuf) {
1584 /* a data/mgmt tx is already pending in the URB -
1585 if this is no error in some situations we must
1586 implement a queue or silently modify the old msg */
1587 printk(KERN_ERR "%s: removed pending mgmt buffer %s\n",
1588 priv->netdev->name, hex2str(oldbuf, 64));
1589 kfree(oldbuf);
1590 return 0;
1591 }
1592
1593 txbuf->tx_rate = TX_RATE_1MBIT;
1594 txbuf->padding = at76_calc_padding(le16_to_cpu(txbuf->wlength));
1595 memset(txbuf->reserved, 0, sizeof(txbuf->reserved));
1596
1597 if (priv->next_mgmt_bulk)
1598 printk(KERN_ERR "%s: URB status %d, but mgmt is pending\n",
1599 priv->netdev->name, urb_status);
1600
1601 at76_dbg(DBG_TX_MGMT,
1602 "%s: tx mgmt: wlen %d tx_rate %d pad %d %s",
1603 priv->netdev->name, le16_to_cpu(txbuf->wlength),
1604 txbuf->tx_rate, txbuf->padding,
1605 hex2str(txbuf->packet, le16_to_cpu(txbuf->wlength)));
1606
1607 /* txbuf was not consumed above -> send mgmt msg immediately */
1608 memcpy(priv->bulk_out_buffer, txbuf,
1609 le16_to_cpu(txbuf->wlength) + AT76_TX_HDRLEN);
1610 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe,
1611 priv->bulk_out_buffer,
1612 le16_to_cpu(txbuf->wlength) + txbuf->padding +
1613 AT76_TX_HDRLEN, at76_tx_callback, priv);
1614 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
1615 if (ret)
1616 printk(KERN_ERR "%s: error in tx submit urb: %d\n",
1617 priv->netdev->name, ret);
1618
1619 kfree(txbuf);
1620
1621 return ret;
1622}
1623
1624/* Go to the next information element */
1625static inline void next_ie(struct ieee80211_info_element **ie)
1626{
1627 *ie = (struct ieee80211_info_element *)(&(*ie)->data[(*ie)->len]);
1628}
1629
1630/* Challenge is the challenge string (in TLV format)
1631 we got with seq_nr 2 for shared secret authentication only and
1632 send in seq_nr 3 WEP encrypted to prove we have the correct WEP key;
1633 otherwise it is NULL */
1634static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,
1635 int seq_nr, struct ieee80211_info_element *challenge)
1636{
1637 struct at76_tx_buffer *tx_buffer;
1638 struct ieee80211_hdr_3addr *mgmt;
1639 struct ieee80211_auth *req;
1640 int buf_len = (seq_nr != 3 ? AUTH_FRAME_SIZE :
1641 AUTH_FRAME_SIZE + 1 + 1 + challenge->len);
1642
1643 BUG_ON(!bss);
1644 BUG_ON(seq_nr == 3 && !challenge);
1645 tx_buffer = kmalloc(buf_len + MAX_PADDING_SIZE, GFP_ATOMIC);
1646 if (!tx_buffer)
1647 return -ENOMEM;
1648
1649 req = (struct ieee80211_auth *)tx_buffer->packet;
1650 mgmt = &req->header;
1651
1652 /* make wireless header */
1653 /* first auth msg is not encrypted, only the second (seq_nr == 3) */
1654 mgmt->frame_ctl =
1655 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH |
1656 (seq_nr == 3 ? IEEE80211_FCTL_PROTECTED : 0));
1657
1658 mgmt->duration_id = cpu_to_le16(0x8000);
1659 memcpy(mgmt->addr1, bss->bssid, ETH_ALEN);
1660 memcpy(mgmt->addr2, priv->netdev->dev_addr, ETH_ALEN);
1661 memcpy(mgmt->addr3, bss->bssid, ETH_ALEN);
1662 mgmt->seq_ctl = cpu_to_le16(0);
1663
1664 req->algorithm = cpu_to_le16(priv->auth_mode);
1665 req->transaction = cpu_to_le16(seq_nr);
1666 req->status = cpu_to_le16(0);
1667
1668 if (seq_nr == 3)
1669 memcpy(req->info_element, challenge, 1 + 1 + challenge->len);
1670
1671 /* init. at76_priv tx header */
1672 tx_buffer->wlength = cpu_to_le16(buf_len - AT76_TX_HDRLEN);
1673 at76_dbg(DBG_TX_MGMT, "%s: AuthReq bssid %s alg %d seq_nr %d",
1674 priv->netdev->name, mac2str(mgmt->addr3),
1675 le16_to_cpu(req->algorithm), le16_to_cpu(req->transaction));
1676 if (seq_nr == 3)
1677 at76_dbg(DBG_TX_MGMT, "%s: AuthReq challenge: %s ...",
1678 priv->netdev->name, hex2str(req->info_element, 18));
1679
1680 /* either send immediately (if no data tx is pending
1681 or put it in pending list */
1682 return at76_tx_mgmt(priv, tx_buffer);
1683}
1684
1685static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)
1686{
1687 struct at76_tx_buffer *tx_buffer;
1688 struct ieee80211_hdr_3addr *mgmt;
1689 struct ieee80211_assoc_request *req;
1690 struct ieee80211_info_element *ie;
1691 char *essid;
1692 int essid_len;
1693 u16 capa;
1694
1695 BUG_ON(!bss);
1696
1697 tx_buffer = kmalloc(ASSOCREQ_MAX_SIZE + MAX_PADDING_SIZE, GFP_ATOMIC);
1698 if (!tx_buffer)
1699 return -ENOMEM;
1700
1701 req = (struct ieee80211_assoc_request *)tx_buffer->packet;
1702 mgmt = &req->header;
1703 ie = req->info_element;
1704
1705 /* make wireless header */
1706 mgmt->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1707 IEEE80211_STYPE_ASSOC_REQ);
1708
1709 mgmt->duration_id = cpu_to_le16(0x8000);
1710 memcpy(mgmt->addr1, bss->bssid, ETH_ALEN);
1711 memcpy(mgmt->addr2, priv->netdev->dev_addr, ETH_ALEN);
1712 memcpy(mgmt->addr3, bss->bssid, ETH_ALEN);
1713 mgmt->seq_ctl = cpu_to_le16(0);
1714
1715 /* we must set the Privacy bit in the capabilities to assure an
1716 Agere-based AP with optional WEP transmits encrypted frames
1717 to us. AP only set the Privacy bit in their capabilities
1718 if WEP is mandatory in the BSS! */
1719 capa = bss->capa;
1720 if (priv->wep_enabled)
1721 capa |= WLAN_CAPABILITY_PRIVACY;
1722 if (priv->preamble_type != PREAMBLE_TYPE_LONG)
1723 capa |= WLAN_CAPABILITY_SHORT_PREAMBLE;
1724 req->capability = cpu_to_le16(capa);
1725
1726 req->listen_interval = cpu_to_le16(2 * bss->beacon_interval);
1727
1728 /* write TLV data elements */
1729
1730 ie->id = MFIE_TYPE_SSID;
1731 ie->len = bss->ssid_len;
1732 memcpy(ie->data, bss->ssid, bss->ssid_len);
1733 next_ie(&ie);
1734
1735 ie->id = MFIE_TYPE_RATES;
1736 ie->len = sizeof(hw_rates);
1737 memcpy(ie->data, hw_rates, sizeof(hw_rates));
1738 next_ie(&ie); /* ie points behind the supp_rates field */
1739
1740 /* init. at76_priv tx header */
1741 tx_buffer->wlength = cpu_to_le16((u8 *)ie - (u8 *)mgmt);
1742
1743 ie = req->info_element;
1744 essid = ie->data;
1745 essid_len = min_t(int, IW_ESSID_MAX_SIZE, ie->len);
1746
1747 next_ie(&ie); /* points to IE of rates now */
1748 at76_dbg(DBG_TX_MGMT,
1749 "%s: AssocReq bssid %s capa 0x%04x ssid %.*s rates %s",
1750 priv->netdev->name, mac2str(mgmt->addr3),
1751 le16_to_cpu(req->capability), essid_len, essid,
1752 hex2str(ie->data, ie->len));
1753
1754 /* either send immediately (if no data tx is pending
1755 or put it in pending list */
1756 return at76_tx_mgmt(priv, tx_buffer);
1757}
1758
1759/* We got to check the bss_list for old entries */
1760static void at76_bss_list_timeout(unsigned long par)
1761{
1762 struct at76_priv *priv = (struct at76_priv *)par;
1763 unsigned long flags;
1764 struct list_head *lptr, *nptr;
1765 struct bss_info *ptr;
1766
1767 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
1768
1769 list_for_each_safe(lptr, nptr, &priv->bss_list) {
1770
1771 ptr = list_entry(lptr, struct bss_info, list);
1772
1773 if (ptr != priv->curr_bss
1774 && time_after(jiffies, ptr->last_rx + BSS_LIST_TIMEOUT)) {
1775 at76_dbg(DBG_BSS_TABLE_RM,
1776 "%s: bss_list: removing old BSS %s ch %d",
1777 priv->netdev->name, mac2str(ptr->bssid),
1778 ptr->channel);
1779 list_del(&ptr->list);
1780 kfree(ptr);
1781 }
1782 }
1783 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
1784 /* restart the timer */
1785 mod_timer(&priv->bss_list_timer, jiffies + BSS_LIST_TIMEOUT);
1786}
1787
1788static inline void at76_set_mac_state(struct at76_priv *priv,
1789 enum mac_state mac_state)
1790{
1791 at76_dbg(DBG_MAC_STATE, "%s state: %s", priv->netdev->name,
1792 mac_states[mac_state]);
1793 priv->mac_state = mac_state;
1794}
1795
1796static void at76_dump_bss_table(struct at76_priv *priv)
1797{
1798 struct bss_info *ptr;
1799 unsigned long flags;
1800 struct list_head *lptr;
1801
1802 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
1803
1804 at76_dbg(DBG_BSS_TABLE, "%s BSS table (curr=%p):", priv->netdev->name,
1805 priv->curr_bss);
1806
1807 list_for_each(lptr, &priv->bss_list) {
1808 ptr = list_entry(lptr, struct bss_info, list);
1809 at76_dbg(DBG_BSS_TABLE, "0x%p: bssid %s channel %d ssid %.*s "
1810 "(%s) capa 0x%04x rates %s rssi %d link %d noise %d",
1811 ptr, mac2str(ptr->bssid), ptr->channel, ptr->ssid_len,
1812 ptr->ssid, hex2str(ptr->ssid, ptr->ssid_len),
1813 ptr->capa, hex2str(ptr->rates, ptr->rates_len),
1814 ptr->rssi, ptr->link_qual, ptr->noise_level);
1815 }
1816 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
1817}
1818
1819/* Called upon successful association to mark interface as connected */
1820static void at76_work_assoc_done(struct work_struct *work)
1821{
1822 struct at76_priv *priv = container_of(work, struct at76_priv,
1823 work_assoc_done);
1824
1825 mutex_lock(&priv->mtx);
1826
1827 WARN_ON(priv->mac_state != MAC_ASSOC);
1828 WARN_ON(!priv->curr_bss);
1829 if (priv->mac_state != MAC_ASSOC || !priv->curr_bss)
1830 goto exit;
1831
1832 if (priv->iw_mode == IW_MODE_INFRA) {
1833 if (priv->pm_mode != AT76_PM_OFF) {
1834 /* calculate the listen interval in units of
1835 beacon intervals of the curr_bss */
1836 u32 pm_period_beacon = (priv->pm_period >> 10) /
1837 priv->curr_bss->beacon_interval;
1838
1839 pm_period_beacon = max(pm_period_beacon, 2u);
1840 pm_period_beacon = min(pm_period_beacon, 0xffffu);
1841
1842 at76_dbg(DBG_PM,
1843 "%s: pm_mode %d assoc id 0x%x listen int %d",
1844 priv->netdev->name, priv->pm_mode,
1845 priv->assoc_id, pm_period_beacon);
1846
1847 at76_set_associd(priv, priv->assoc_id);
1848 at76_set_listen_interval(priv, (u16)pm_period_beacon);
1849 }
1850 schedule_delayed_work(&priv->dwork_beacon, BEACON_TIMEOUT);
1851 }
1852 at76_set_pm_mode(priv);
1853
1854 netif_carrier_on(priv->netdev);
1855 netif_wake_queue(priv->netdev);
1856 at76_set_mac_state(priv, MAC_CONNECTED);
1857 at76_iwevent_bss_connect(priv->netdev, priv->curr_bss->bssid);
1858 at76_dbg(DBG_PROGRESS, "%s: connected to BSSID %s",
1859 priv->netdev->name, mac2str(priv->curr_bss->bssid));
1860
1861exit:
1862 mutex_unlock(&priv->mtx);
1863}
1864
1865/* We only store the new mac address in netdev struct,
1866 it gets set when the netdev is opened. */
1867static int at76_set_mac_address(struct net_device *netdev, void *addr)
1868{
1869 struct sockaddr *mac = addr;
1870 memcpy(netdev->dev_addr, mac->sa_data, ETH_ALEN);
1871 return 1;
1872}
1873
1874static struct net_device_stats *at76_get_stats(struct net_device *netdev)
1875{
1876 struct at76_priv *priv = netdev_priv(netdev);
1877 return &priv->stats;
1878}
1879
1880static struct iw_statistics *at76_get_wireless_stats(struct net_device *netdev)
1881{
1882 struct at76_priv *priv = netdev_priv(netdev);
1883
1884 at76_dbg(DBG_IOCTL, "RETURN qual %d level %d noise %d updated %d",
1885 priv->wstats.qual.qual, priv->wstats.qual.level,
1886 priv->wstats.qual.noise, priv->wstats.qual.updated);
1887
1888 return &priv->wstats;
1889}
1890
1891static void at76_set_multicast(struct net_device *netdev)
1892{
1893 struct at76_priv *priv = netdev_priv(netdev);
1894 int promisc;
1895
1896 promisc = ((netdev->flags & IFF_PROMISC) != 0);
1897 if (promisc != priv->promisc) {
1898 /* This gets called in interrupt, must reschedule */
1899 priv->promisc = promisc;
1900 schedule_work(&priv->work_set_promisc);
1901 }
1902}
1903
1904/* Stop all network activity, flush all pending tasks */
1905static void at76_quiesce(struct at76_priv *priv)
1906{
1907 unsigned long flags;
1908
1909 netif_stop_queue(priv->netdev);
1910 netif_carrier_off(priv->netdev);
1911
1912 at76_set_mac_state(priv, MAC_INIT);
1913
1914 cancel_delayed_work(&priv->dwork_get_scan);
1915 cancel_delayed_work(&priv->dwork_beacon);
1916 cancel_delayed_work(&priv->dwork_auth);
1917 cancel_delayed_work(&priv->dwork_assoc);
1918 cancel_delayed_work(&priv->dwork_restart);
1919
1920 spin_lock_irqsave(&priv->mgmt_spinlock, flags);
1921 kfree(priv->next_mgmt_bulk);
1922 priv->next_mgmt_bulk = NULL;
1923 spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
1924}
1925
1926/*******************************************************************************
1927 * at76_priv implementations of iw_handler functions:
1928 */
1929static int at76_iw_handler_commit(struct net_device *netdev,
1930 struct iw_request_info *info,
1931 void *null, char *extra)
1932{
1933 struct at76_priv *priv = netdev_priv(netdev);
1934
1935 at76_dbg(DBG_IOCTL, "%s %s: restarting the device", netdev->name,
1936 __func__);
1937
1938 if (priv->mac_state != MAC_INIT)
1939 at76_quiesce(priv);
1940
1941 /* Wait half second before the restart to process subsequent
1942 * requests from the same iwconfig in a single restart */
1943 schedule_delayed_work(&priv->dwork_restart, HZ / 2);
1944
1945 return 0;
1946}
1947
1948static int at76_iw_handler_get_name(struct net_device *netdev,
1949 struct iw_request_info *info,
1950 char *name, char *extra)
1951{
1952 strcpy(name, "IEEE 802.11b");
1953 at76_dbg(DBG_IOCTL, "%s: SIOCGIWNAME - name %s", netdev->name, name);
1954 return 0;
1955}
1956
1957static int at76_iw_handler_set_freq(struct net_device *netdev,
1958 struct iw_request_info *info,
1959 struct iw_freq *freq, char *extra)
1960{
1961 struct at76_priv *priv = netdev_priv(netdev);
1962 int chan = -1;
1963 int ret = -EIWCOMMIT;
1964 at76_dbg(DBG_IOCTL, "%s: SIOCSIWFREQ - freq.m %d freq.e %d",
1965 netdev->name, freq->m, freq->e);
1966
1967 if ((freq->e == 0) && (freq->m <= 1000))
1968 /* Setting by channel number */
1969 chan = freq->m;
1970 else {
1971 /* Setting by frequency - search the table */
1972 int mult = 1;
1973 int i;
1974
1975 for (i = 0; i < (6 - freq->e); i++)
1976 mult *= 10;
1977
1978 for (i = 0; i < NUM_CHANNELS; i++) {
1979 if (freq->m == (channel_frequency[i] * mult))
1980 chan = i + 1;
1981 }
1982 }
1983
1984 if (chan < 1 || !priv->domain)
1985 /* non-positive channels are invalid
1986 * we need a domain info to set the channel
1987 * either that or an invalid frequency was
1988 * provided by the user */
1989 ret = -EINVAL;
1990 else if (!(priv->domain->channel_map & (1 << (chan - 1)))) {
1991 printk(KERN_INFO "%s: channel %d not allowed for domain %s\n",
1992 priv->netdev->name, chan, priv->domain->name);
1993 ret = -EINVAL;
1994 }
1995
1996 if (ret == -EIWCOMMIT) {
1997 priv->channel = chan;
1998 at76_dbg(DBG_IOCTL, "%s: SIOCSIWFREQ - ch %d", netdev->name,
1999 chan);
2000 }
2001
2002 return ret;
2003}
2004
2005static int at76_iw_handler_get_freq(struct net_device *netdev,
2006 struct iw_request_info *info,
2007 struct iw_freq *freq, char *extra)
2008{
2009 struct at76_priv *priv = netdev_priv(netdev);
2010
2011 freq->m = priv->channel;
2012 freq->e = 0;
2013
2014 if (priv->channel)
2015 at76_dbg(DBG_IOCTL, "%s: SIOCGIWFREQ - freq %ld x 10e%d",
2016 netdev->name, channel_frequency[priv->channel - 1], 6);
2017
2018 at76_dbg(DBG_IOCTL, "%s: SIOCGIWFREQ - ch %d", netdev->name,
2019 priv->channel);
2020
2021 return 0;
2022}
2023
2024static int at76_iw_handler_set_mode(struct net_device *netdev,
2025 struct iw_request_info *info,
2026 __u32 *mode, char *extra)
2027{
2028 struct at76_priv *priv = netdev_priv(netdev);
2029
2030 at76_dbg(DBG_IOCTL, "%s: SIOCSIWMODE - %d", netdev->name, *mode);
2031
2032 if ((*mode != IW_MODE_ADHOC) && (*mode != IW_MODE_INFRA) &&
2033 (*mode != IW_MODE_MONITOR))
2034 return -EINVAL;
2035
2036 priv->iw_mode = *mode;
2037 if (priv->iw_mode != IW_MODE_INFRA)
2038 priv->pm_mode = AT76_PM_OFF;
2039
2040 return -EIWCOMMIT;
2041}
2042
2043static int at76_iw_handler_get_mode(struct net_device *netdev,
2044 struct iw_request_info *info,
2045 __u32 *mode, char *extra)
2046{
2047 struct at76_priv *priv = netdev_priv(netdev);
2048
2049 *mode = priv->iw_mode;
2050
2051 at76_dbg(DBG_IOCTL, "%s: SIOCGIWMODE - %d", netdev->name, *mode);
2052
2053 return 0;
2054}
2055
2056static int at76_iw_handler_get_range(struct net_device *netdev,
2057 struct iw_request_info *info,
2058 struct iw_point *data, char *extra)
2059{
2060 /* inspired by atmel.c */
2061 struct at76_priv *priv = netdev_priv(netdev);
2062 struct iw_range *range = (struct iw_range *)extra;
2063 int i;
2064
2065 data->length = sizeof(struct iw_range);
2066 memset(range, 0, sizeof(struct iw_range));
2067
2068 /* TODO: range->throughput = xxxxxx; */
2069
2070 range->min_nwid = 0x0000;
2071 range->max_nwid = 0x0000;
2072
2073 /* this driver doesn't maintain sensitivity information */
2074 range->sensitivity = 0;
2075
2076 range->max_qual.qual = 100;
2077 range->max_qual.level = 100;
2078 range->max_qual.noise = 0;
2079 range->max_qual.updated = IW_QUAL_NOISE_INVALID;
2080
2081 range->avg_qual.qual = 50;
2082 range->avg_qual.level = 50;
2083 range->avg_qual.noise = 0;
2084 range->avg_qual.updated = IW_QUAL_NOISE_INVALID;
2085
2086 range->bitrate[0] = 1000000;
2087 range->bitrate[1] = 2000000;
2088 range->bitrate[2] = 5500000;
2089 range->bitrate[3] = 11000000;
2090 range->num_bitrates = 4;
2091
2092 range->min_rts = 0;
2093 range->max_rts = MAX_RTS_THRESHOLD;
2094
2095 range->min_frag = MIN_FRAG_THRESHOLD;
2096 range->max_frag = MAX_FRAG_THRESHOLD;
2097
2098 range->pmp_flags = IW_POWER_PERIOD;
2099 range->pmt_flags = IW_POWER_ON;
2100 range->pm_capa = IW_POWER_PERIOD | IW_POWER_ALL_R;
2101
2102 range->encoding_size[0] = WEP_SMALL_KEY_LEN;
2103 range->encoding_size[1] = WEP_LARGE_KEY_LEN;
2104 range->num_encoding_sizes = 2;
2105 range->max_encoding_tokens = WEP_KEYS;
2106
2107 /* both WL-240U and Linksys WUSB11 v2.6 specify 15 dBm as output power
2108 - take this for all (ignore antenna gains) */
2109 range->txpower[0] = 15;
2110 range->num_txpower = 1;
2111 range->txpower_capa = IW_TXPOW_DBM;
2112
2113 range->we_version_source = WIRELESS_EXT;
2114 range->we_version_compiled = WIRELESS_EXT;
2115
2116 /* same as the values used in atmel.c */
2117 range->retry_capa = IW_RETRY_LIMIT;
2118 range->retry_flags = IW_RETRY_LIMIT;
2119 range->r_time_flags = 0;
2120 range->min_retry = 1;
2121 range->max_retry = 255;
2122
2123 range->num_channels = NUM_CHANNELS;
2124 range->num_frequency = 0;
2125
2126 for (i = 0; i < NUM_CHANNELS; i++) {
2127 /* test if channel map bit is raised */
2128 if (priv->domain->channel_map & (0x1 << i)) {
2129 range->num_frequency += 1;
2130
2131 range->freq[i].i = i + 1;
2132 range->freq[i].m = channel_frequency[i] * 100000;
2133 range->freq[i].e = 1; /* freq * 10^1 */
2134 }
2135 }
2136
2137 at76_dbg(DBG_IOCTL, "%s: SIOCGIWRANGE", netdev->name);
2138
2139 return 0;
2140}
2141
2142static int at76_iw_handler_set_spy(struct net_device *netdev,
2143 struct iw_request_info *info,
2144 struct iw_point *data, char *extra)
2145{
2146 struct at76_priv *priv = netdev_priv(netdev);
2147 int ret = 0;
2148
2149 at76_dbg(DBG_IOCTL, "%s: SIOCSIWSPY - number of addresses %d",
2150 netdev->name, data->length);
2151
2152 spin_lock_bh(&priv->spy_spinlock);
2153 ret = iw_handler_set_spy(priv->netdev, info, (union iwreq_data *)data,
2154 extra);
2155 spin_unlock_bh(&priv->spy_spinlock);
2156
2157 return ret;
2158}
2159
2160static int at76_iw_handler_get_spy(struct net_device *netdev,
2161 struct iw_request_info *info,
2162 struct iw_point *data, char *extra)
2163{
2164
2165 struct at76_priv *priv = netdev_priv(netdev);
2166 int ret = 0;
2167
2168 spin_lock_bh(&priv->spy_spinlock);
2169 ret = iw_handler_get_spy(priv->netdev, info,
2170 (union iwreq_data *)data, extra);
2171 spin_unlock_bh(&priv->spy_spinlock);
2172
2173 at76_dbg(DBG_IOCTL, "%s: SIOCGIWSPY - number of addresses %d",
2174 netdev->name, data->length);
2175
2176 return ret;
2177}
2178
2179static int at76_iw_handler_set_thrspy(struct net_device *netdev,
2180 struct iw_request_info *info,
2181 struct iw_point *data, char *extra)
2182{
2183 struct at76_priv *priv = netdev_priv(netdev);
2184 int ret;
2185
2186 at76_dbg(DBG_IOCTL, "%s: SIOCSIWTHRSPY - number of addresses %d)",
2187 netdev->name, data->length);
2188
2189 spin_lock_bh(&priv->spy_spinlock);
2190 ret = iw_handler_set_thrspy(netdev, info, (union iwreq_data *)data,
2191 extra);
2192 spin_unlock_bh(&priv->spy_spinlock);
2193
2194 return ret;
2195}
2196
2197static int at76_iw_handler_get_thrspy(struct net_device *netdev,
2198 struct iw_request_info *info,
2199 struct iw_point *data, char *extra)
2200{
2201 struct at76_priv *priv = netdev_priv(netdev);
2202 int ret;
2203
2204 spin_lock_bh(&priv->spy_spinlock);
2205 ret = iw_handler_get_thrspy(netdev, info, (union iwreq_data *)data,
2206 extra);
2207 spin_unlock_bh(&priv->spy_spinlock);
2208
2209 at76_dbg(DBG_IOCTL, "%s: SIOCGIWTHRSPY - number of addresses %d)",
2210 netdev->name, data->length);
2211
2212 return ret;
2213}
2214
2215static int at76_iw_handler_set_wap(struct net_device *netdev,
2216 struct iw_request_info *info,
2217 struct sockaddr *ap_addr, char *extra)
2218{
2219 struct at76_priv *priv = netdev_priv(netdev);
2220
2221 at76_dbg(DBG_IOCTL, "%s: SIOCSIWAP - wap/bssid %s", netdev->name,
2222 mac2str(ap_addr->sa_data));
2223
2224 /* if the incoming address == ff:ff:ff:ff:ff:ff, the user has
2225 chosen any or auto AP preference */
2226 if (is_broadcast_ether_addr(ap_addr->sa_data)
2227 || is_zero_ether_addr(ap_addr->sa_data))
2228 priv->wanted_bssid_valid = 0;
2229 else {
2230 /* user wants to set a preferred AP address */
2231 priv->wanted_bssid_valid = 1;
2232 memcpy(priv->wanted_bssid, ap_addr->sa_data, ETH_ALEN);
2233 }
2234
2235 return -EIWCOMMIT;
2236}
2237
2238static int at76_iw_handler_get_wap(struct net_device *netdev,
2239 struct iw_request_info *info,
2240 struct sockaddr *ap_addr, char *extra)
2241{
2242 struct at76_priv *priv = netdev_priv(netdev);
2243
2244 ap_addr->sa_family = ARPHRD_ETHER;
2245 memcpy(ap_addr->sa_data, priv->bssid, ETH_ALEN);
2246
2247 at76_dbg(DBG_IOCTL, "%s: SIOCGIWAP - wap/bssid %s", netdev->name,
2248 mac2str(ap_addr->sa_data));
2249
2250 return 0;
2251}
2252
2253static int at76_iw_handler_set_scan(struct net_device *netdev,
2254 struct iw_request_info *info,
2255 union iwreq_data *wrqu, char *extra)
2256{
2257 struct at76_priv *priv = netdev_priv(netdev);
2258 int ret = 0;
2259
2260 at76_dbg(DBG_IOCTL, "%s: SIOCSIWSCAN", netdev->name);
2261
2262 if (mutex_lock_interruptible(&priv->mtx))
2263 return -EINTR;
2264
2265 if (!netif_running(netdev)) {
2266 ret = -ENETDOWN;
2267 goto exit;
2268 }
2269
2270 /* jal: we don't allow "iwlist ethX scan" while we are
2271 in monitor mode */
2272 if (priv->iw_mode == IW_MODE_MONITOR) {
2273 ret = -EBUSY;
2274 goto exit;
2275 }
2276
2277 /* Discard old scan results */
2278 if ((jiffies - priv->last_scan) > (20 * HZ))
2279 priv->scan_state = SCAN_IDLE;
2280 priv->last_scan = jiffies;
2281
2282 /* Initiate a scan command */
2283 if (priv->scan_state == SCAN_IN_PROGRESS) {
2284 ret = -EBUSY;
2285 goto exit;
2286 }
2287
2288 priv->scan_state = SCAN_IN_PROGRESS;
2289
2290 at76_quiesce(priv);
2291
2292 /* Try to do passive or active scan if WE asks as. */
2293 if (wrqu->data.length
2294 && wrqu->data.length == sizeof(struct iw_scan_req)) {
2295 struct iw_scan_req *req = (struct iw_scan_req *)extra;
2296
2297 if (req->scan_type == IW_SCAN_TYPE_PASSIVE)
2298 priv->scan_mode = SCAN_TYPE_PASSIVE;
2299 else if (req->scan_type == IW_SCAN_TYPE_ACTIVE)
2300 priv->scan_mode = SCAN_TYPE_ACTIVE;
2301
2302 /* Sanity check values? */
2303 if (req->min_channel_time > 0)
2304 priv->scan_min_time = req->min_channel_time;
2305
2306 if (req->max_channel_time > 0)
2307 priv->scan_max_time = req->max_channel_time;
2308 }
2309
2310 /* change to scanning state */
2311 at76_set_mac_state(priv, MAC_SCANNING);
2312 schedule_work(&priv->work_start_scan);
2313
2314exit:
2315 mutex_unlock(&priv->mtx);
2316 return ret;
2317}
2318
2319static int at76_iw_handler_get_scan(struct net_device *netdev,
2320 struct iw_request_info *info,
2321 struct iw_point *data, char *extra)
2322{
2323 struct at76_priv *priv = netdev_priv(netdev);
2324 unsigned long flags;
2325 struct list_head *lptr, *nptr;
2326 struct bss_info *curr_bss;
2327 struct iw_event *iwe = kmalloc(sizeof(struct iw_event), GFP_KERNEL);
2328 char *curr_val, *curr_pos = extra;
2329 int i;
2330
2331 at76_dbg(DBG_IOCTL, "%s: SIOCGIWSCAN", netdev->name);
2332
2333 if (!iwe)
2334 return -ENOMEM;
2335
2336 if (priv->scan_state != SCAN_COMPLETED) {
2337 /* scan not yet finished */
2338 kfree(iwe);
2339 return -EAGAIN;
2340 }
2341
2342 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
2343
2344 list_for_each_safe(lptr, nptr, &priv->bss_list) {
2345 curr_bss = list_entry(lptr, struct bss_info, list);
2346
2347 iwe->cmd = SIOCGIWAP;
2348 iwe->u.ap_addr.sa_family = ARPHRD_ETHER;
2349 memcpy(iwe->u.ap_addr.sa_data, curr_bss->bssid, 6);
2350 curr_pos = iwe_stream_add_event(info, curr_pos,
2351 extra + IW_SCAN_MAX_DATA, iwe,
2352 IW_EV_ADDR_LEN);
2353
2354 iwe->u.data.length = curr_bss->ssid_len;
2355 iwe->cmd = SIOCGIWESSID;
2356 iwe->u.data.flags = 1;
2357
2358 curr_pos = iwe_stream_add_point(info, curr_pos,
2359 extra + IW_SCAN_MAX_DATA, iwe,
2360 curr_bss->ssid);
2361
2362 iwe->cmd = SIOCGIWMODE;
2363 iwe->u.mode = (curr_bss->capa & WLAN_CAPABILITY_IBSS) ?
2364 IW_MODE_ADHOC :
2365 (curr_bss->capa & WLAN_CAPABILITY_ESS) ?
2366 IW_MODE_MASTER : IW_MODE_AUTO;
2367 /* IW_MODE_AUTO = 0 which I thought is
2368 * the most logical value to return in this case */
2369 curr_pos = iwe_stream_add_event(info, curr_pos,
2370 extra + IW_SCAN_MAX_DATA, iwe,
2371 IW_EV_UINT_LEN);
2372
2373 iwe->cmd = SIOCGIWFREQ;
2374 iwe->u.freq.m = curr_bss->channel;
2375 iwe->u.freq.e = 0;
2376 curr_pos = iwe_stream_add_event(info, curr_pos,
2377 extra + IW_SCAN_MAX_DATA, iwe,
2378 IW_EV_FREQ_LEN);
2379
2380 iwe->cmd = SIOCGIWENCODE;
2381 if (curr_bss->capa & WLAN_CAPABILITY_PRIVACY)
2382 iwe->u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
2383 else
2384 iwe->u.data.flags = IW_ENCODE_DISABLED;
2385
2386 iwe->u.data.length = 0;
2387 curr_pos = iwe_stream_add_point(info, curr_pos,
2388 extra + IW_SCAN_MAX_DATA, iwe,
2389 NULL);
2390
2391 /* Add quality statistics */
2392 iwe->cmd = IWEVQUAL;
2393 iwe->u.qual.noise = 0;
2394 iwe->u.qual.updated =
2395 IW_QUAL_NOISE_INVALID | IW_QUAL_LEVEL_UPDATED;
2396 iwe->u.qual.level = (curr_bss->rssi * 100 / 42);
2397 if (iwe->u.qual.level > 100)
2398 iwe->u.qual.level = 100;
2399 if (at76_is_intersil(priv->board_type))
2400 iwe->u.qual.qual = curr_bss->link_qual;
2401 else {
2402 iwe->u.qual.qual = 0;
2403 iwe->u.qual.updated |= IW_QUAL_QUAL_INVALID;
2404 }
2405 /* Add new value to event */
2406 curr_pos = iwe_stream_add_event(info, curr_pos,
2407 extra + IW_SCAN_MAX_DATA, iwe,
2408 IW_EV_QUAL_LEN);
2409
2410 /* Rate: stuffing multiple values in a single event requires
2411 * a bit more of magic - Jean II */
2412 curr_val = curr_pos + IW_EV_LCP_LEN;
2413
2414 iwe->cmd = SIOCGIWRATE;
2415 /* Those two flags are ignored... */
2416 iwe->u.bitrate.fixed = 0;
2417 iwe->u.bitrate.disabled = 0;
2418 /* Max 8 values */
2419 for (i = 0; i < curr_bss->rates_len; i++) {
2420 /* Bit rate given in 500 kb/s units (+ 0x80) */
2421 iwe->u.bitrate.value =
2422 ((curr_bss->rates[i] & 0x7f) * 500000);
2423 /* Add new value to event */
2424 curr_val = iwe_stream_add_value(info, curr_pos,
2425 curr_val,
2426 extra +
2427 IW_SCAN_MAX_DATA, iwe,
2428 IW_EV_PARAM_LEN);
2429 }
2430
2431 /* Check if we added any event */
2432 if ((curr_val - curr_pos) > IW_EV_LCP_LEN)
2433 curr_pos = curr_val;
2434
2435 /* more information may be sent back using IWECUSTOM */
2436
2437 }
2438
2439 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
2440
2441 data->length = (curr_pos - extra);
2442 data->flags = 0;
2443
2444 kfree(iwe);
2445 return 0;
2446}
2447
2448static int at76_iw_handler_set_essid(struct net_device *netdev,
2449 struct iw_request_info *info,
2450 struct iw_point *data, char *extra)
2451{
2452 struct at76_priv *priv = netdev_priv(netdev);
2453
2454 at76_dbg(DBG_IOCTL, "%s: SIOCSIWESSID - %s", netdev->name, extra);
2455
2456 if (data->flags) {
2457 memcpy(priv->essid, extra, data->length);
2458 priv->essid_size = data->length;
2459 } else
2460 priv->essid_size = 0; /* Use any SSID */
2461
2462 return -EIWCOMMIT;
2463}
2464
2465static int at76_iw_handler_get_essid(struct net_device *netdev,
2466 struct iw_request_info *info,
2467 struct iw_point *data, char *extra)
2468{
2469 struct at76_priv *priv = netdev_priv(netdev);
2470
2471 if (priv->essid_size) {
2472 /* not the ANY ssid in priv->essid */
2473 data->flags = 1;
2474 data->length = priv->essid_size;
2475 memcpy(extra, priv->essid, data->length);
2476 } else {
2477 /* the ANY ssid was specified */
2478 if (priv->mac_state == MAC_CONNECTED && priv->curr_bss) {
2479 /* report the SSID we have found */
2480 data->flags = 1;
2481 data->length = priv->curr_bss->ssid_len;
2482 memcpy(extra, priv->curr_bss->ssid, data->length);
2483 } else {
2484 /* report ANY back */
2485 data->flags = 0;
2486 data->length = 0;
2487 }
2488 }
2489
2490 at76_dbg(DBG_IOCTL, "%s: SIOCGIWESSID - %.*s", netdev->name,
2491 data->length, extra);
2492
2493 return 0;
2494}
2495
2496static int at76_iw_handler_set_rate(struct net_device *netdev,
2497 struct iw_request_info *info,
2498 struct iw_param *bitrate, char *extra)
2499{
2500 struct at76_priv *priv = netdev_priv(netdev);
2501 int ret = -EIWCOMMIT;
2502
2503 at76_dbg(DBG_IOCTL, "%s: SIOCSIWRATE - %d", netdev->name,
2504 bitrate->value);
2505
2506 switch (bitrate->value) {
2507 case -1:
2508 priv->txrate = TX_RATE_AUTO;
2509 break; /* auto rate */
2510 case 1000000:
2511 priv->txrate = TX_RATE_1MBIT;
2512 break;
2513 case 2000000:
2514 priv->txrate = TX_RATE_2MBIT;
2515 break;
2516 case 5500000:
2517 priv->txrate = TX_RATE_5_5MBIT;
2518 break;
2519 case 11000000:
2520 priv->txrate = TX_RATE_11MBIT;
2521 break;
2522 default:
2523 ret = -EINVAL;
2524 }
2525
2526 return ret;
2527}
2528
2529static int at76_iw_handler_get_rate(struct net_device *netdev,
2530 struct iw_request_info *info,
2531 struct iw_param *bitrate, char *extra)
2532{
2533 struct at76_priv *priv = netdev_priv(netdev);
2534 int ret = 0;
2535
2536 switch (priv->txrate) {
2537 /* return max rate if RATE_AUTO */
2538 case TX_RATE_AUTO:
2539 bitrate->value = 11000000;
2540 break;
2541 case TX_RATE_1MBIT:
2542 bitrate->value = 1000000;
2543 break;
2544 case TX_RATE_2MBIT:
2545 bitrate->value = 2000000;
2546 break;
2547 case TX_RATE_5_5MBIT:
2548 bitrate->value = 5500000;
2549 break;
2550 case TX_RATE_11MBIT:
2551 bitrate->value = 11000000;
2552 break;
2553 default:
2554 ret = -EINVAL;
2555 }
2556
2557 bitrate->fixed = (priv->txrate != TX_RATE_AUTO);
2558 bitrate->disabled = 0;
2559
2560 at76_dbg(DBG_IOCTL, "%s: SIOCGIWRATE - %d", netdev->name,
2561 bitrate->value);
2562
2563 return ret;
2564}
2565
2566static int at76_iw_handler_set_rts(struct net_device *netdev,
2567 struct iw_request_info *info,
2568 struct iw_param *rts, char *extra)
2569{
2570 struct at76_priv *priv = netdev_priv(netdev);
2571 int ret = -EIWCOMMIT;
2572 int rthr = rts->value;
2573
2574 at76_dbg(DBG_IOCTL, "%s: SIOCSIWRTS - value %d disabled %s",
2575 netdev->name, rts->value, (rts->disabled) ? "true" : "false");
2576
2577 if (rts->disabled)
2578 rthr = MAX_RTS_THRESHOLD;
2579
2580 if ((rthr < 0) || (rthr > MAX_RTS_THRESHOLD))
2581 ret = -EINVAL;
2582 else
2583 priv->rts_threshold = rthr;
2584
2585 return ret;
2586}
2587
2588static int at76_iw_handler_get_rts(struct net_device *netdev,
2589 struct iw_request_info *info,
2590 struct iw_param *rts, char *extra)
2591{
2592 struct at76_priv *priv = netdev_priv(netdev);
2593
2594 rts->value = priv->rts_threshold;
2595 rts->disabled = (rts->value >= MAX_RTS_THRESHOLD);
2596 rts->fixed = 1;
2597
2598 at76_dbg(DBG_IOCTL, "%s: SIOCGIWRTS - value %d disabled %s",
2599 netdev->name, rts->value, (rts->disabled) ? "true" : "false");
2600
2601 return 0;
2602}
2603
2604static int at76_iw_handler_set_frag(struct net_device *netdev,
2605 struct iw_request_info *info,
2606 struct iw_param *frag, char *extra)
2607{
2608 struct at76_priv *priv = netdev_priv(netdev);
2609 int ret = -EIWCOMMIT;
2610 int fthr = frag->value;
2611
2612 at76_dbg(DBG_IOCTL, "%s: SIOCSIWFRAG - value %d, disabled %s",
2613 netdev->name, frag->value,
2614 (frag->disabled) ? "true" : "false");
2615
2616 if (frag->disabled)
2617 fthr = MAX_FRAG_THRESHOLD;
2618
2619 if ((fthr < MIN_FRAG_THRESHOLD) || (fthr > MAX_FRAG_THRESHOLD))
2620 ret = -EINVAL;
2621 else
2622 priv->frag_threshold = fthr & ~0x1; /* get an even value */
2623
2624 return ret;
2625}
2626
2627static int at76_iw_handler_get_frag(struct net_device *netdev,
2628 struct iw_request_info *info,
2629 struct iw_param *frag, char *extra)
2630{
2631 struct at76_priv *priv = netdev_priv(netdev);
2632
2633 frag->value = priv->frag_threshold;
2634 frag->disabled = (frag->value >= MAX_FRAG_THRESHOLD);
2635 frag->fixed = 1;
2636
2637 at76_dbg(DBG_IOCTL, "%s: SIOCGIWFRAG - value %d, disabled %s",
2638 netdev->name, frag->value,
2639 (frag->disabled) ? "true" : "false");
2640
2641 return 0;
2642}
2643
2644static int at76_iw_handler_get_txpow(struct net_device *netdev,
2645 struct iw_request_info *info,
2646 struct iw_param *power, char *extra)
2647{
2648 power->value = 15;
2649 power->fixed = 1; /* No power control */
2650 power->disabled = 0;
2651 power->flags = IW_TXPOW_DBM;
2652
2653 at76_dbg(DBG_IOCTL, "%s: SIOCGIWTXPOW - txpow %d dBm", netdev->name,
2654 power->value);
2655
2656 return 0;
2657}
2658
2659/* jal: short retry is handled by the firmware (at least 0.90.x),
2660 while long retry is not (?) */
2661static int at76_iw_handler_set_retry(struct net_device *netdev,
2662 struct iw_request_info *info,
2663 struct iw_param *retry, char *extra)
2664{
2665 struct at76_priv *priv = netdev_priv(netdev);
2666 int ret = -EIWCOMMIT;
2667
2668 at76_dbg(DBG_IOCTL, "%s: SIOCSIWRETRY disabled %d flags 0x%x val %d",
2669 netdev->name, retry->disabled, retry->flags, retry->value);
2670
2671 if (!retry->disabled && (retry->flags & IW_RETRY_LIMIT)) {
2672 if ((retry->flags & IW_RETRY_MIN) ||
2673 !(retry->flags & IW_RETRY_MAX))
2674 priv->short_retry_limit = retry->value;
2675 else
2676 ret = -EINVAL;
2677 } else
2678 ret = -EINVAL;
2679
2680 return ret;
2681}
2682
2683/* Adapted (ripped) from atmel.c */
2684static int at76_iw_handler_get_retry(struct net_device *netdev,
2685 struct iw_request_info *info,
2686 struct iw_param *retry, char *extra)
2687{
2688 struct at76_priv *priv = netdev_priv(netdev);
2689
2690 at76_dbg(DBG_IOCTL, "%s: SIOCGIWRETRY", netdev->name);
2691
2692 retry->disabled = 0; /* Can't be disabled */
2693 retry->flags = IW_RETRY_LIMIT;
2694 retry->value = priv->short_retry_limit;
2695
2696 return 0;
2697}
2698
2699static int at76_iw_handler_set_encode(struct net_device *netdev,
2700 struct iw_request_info *info,
2701 struct iw_point *encoding, char *extra)
2702{
2703 struct at76_priv *priv = netdev_priv(netdev);
2704 int index = (encoding->flags & IW_ENCODE_INDEX) - 1;
2705 int len = encoding->length;
2706
2707 at76_dbg(DBG_IOCTL, "%s: SIOCSIWENCODE - enc.flags %08x "
2708 "pointer %p len %d", netdev->name, encoding->flags,
2709 encoding->pointer, encoding->length);
2710 at76_dbg(DBG_IOCTL,
2711 "%s: SIOCSIWENCODE - old wepstate: enabled %s key_id %d "
2712 "auth_mode %s", netdev->name,
2713 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id,
2714 (priv->auth_mode ==
2715 WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
2716
2717 /* take the old default key if index is invalid */
2718 if ((index < 0) || (index >= WEP_KEYS))
2719 index = priv->wep_key_id;
2720
2721 if (len > 0) {
2722 if (len > WEP_LARGE_KEY_LEN)
2723 len = WEP_LARGE_KEY_LEN;
2724
2725 memset(priv->wep_keys[index], 0, WEP_KEY_LEN);
2726 memcpy(priv->wep_keys[index], extra, len);
2727 priv->wep_keys_len[index] = (len <= WEP_SMALL_KEY_LEN) ?
2728 WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN;
2729 priv->wep_enabled = 1;
2730 }
2731
2732 priv->wep_key_id = index;
2733 priv->wep_enabled = ((encoding->flags & IW_ENCODE_DISABLED) == 0);
2734
2735 if (encoding->flags & IW_ENCODE_RESTRICTED)
2736 priv->auth_mode = WLAN_AUTH_SHARED_KEY;
2737 if (encoding->flags & IW_ENCODE_OPEN)
2738 priv->auth_mode = WLAN_AUTH_OPEN;
2739
2740 at76_dbg(DBG_IOCTL,
2741 "%s: SIOCSIWENCODE - new wepstate: enabled %s key_id %d "
2742 "key_len %d auth_mode %s", netdev->name,
2743 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id + 1,
2744 priv->wep_keys_len[priv->wep_key_id],
2745 (priv->auth_mode ==
2746 WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
2747
2748 return -EIWCOMMIT;
2749}
2750
2751static int at76_iw_handler_get_encode(struct net_device *netdev,
2752 struct iw_request_info *info,
2753 struct iw_point *encoding, char *extra)
2754{
2755 struct at76_priv *priv = netdev_priv(netdev);
2756 int index = (encoding->flags & IW_ENCODE_INDEX) - 1;
2757
2758 if ((index < 0) || (index >= WEP_KEYS))
2759 index = priv->wep_key_id;
2760
2761 encoding->flags =
2762 (priv->auth_mode == WLAN_AUTH_SHARED_KEY) ?
2763 IW_ENCODE_RESTRICTED : IW_ENCODE_OPEN;
2764
2765 if (!priv->wep_enabled)
2766 encoding->flags |= IW_ENCODE_DISABLED;
2767
2768 if (encoding->pointer) {
2769 encoding->length = priv->wep_keys_len[index];
2770
2771 memcpy(extra, priv->wep_keys[index], priv->wep_keys_len[index]);
2772
2773 encoding->flags |= (index + 1);
2774 }
2775
2776 at76_dbg(DBG_IOCTL, "%s: SIOCGIWENCODE - enc.flags %08x "
2777 "pointer %p len %d", netdev->name, encoding->flags,
2778 encoding->pointer, encoding->length);
2779 at76_dbg(DBG_IOCTL,
2780 "%s: SIOCGIWENCODE - wepstate: enabled %s key_id %d "
2781 "key_len %d auth_mode %s", netdev->name,
2782 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id + 1,
2783 priv->wep_keys_len[priv->wep_key_id],
2784 (priv->auth_mode ==
2785 WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
2786
2787 return 0;
2788}
2789
2790static int at76_iw_handler_set_power(struct net_device *netdev,
2791 struct iw_request_info *info,
2792 struct iw_param *prq, char *extra)
2793{
2794 int err = -EIWCOMMIT;
2795 struct at76_priv *priv = netdev_priv(netdev);
2796
2797 at76_dbg(DBG_IOCTL,
2798 "%s: SIOCSIWPOWER - disabled %s flags 0x%x value 0x%x",
2799 netdev->name, (prq->disabled) ? "true" : "false", prq->flags,
2800 prq->value);
2801
2802 if (prq->disabled)
2803 priv->pm_mode = AT76_PM_OFF;
2804 else {
2805 switch (prq->flags & IW_POWER_MODE) {
2806 case IW_POWER_ALL_R:
2807 case IW_POWER_ON:
2808 break;
2809 default:
2810 err = -EINVAL;
2811 goto exit;
2812 }
2813 if (prq->flags & IW_POWER_PERIOD)
2814 priv->pm_period = prq->value;
2815
2816 if (prq->flags & IW_POWER_TIMEOUT) {
2817 err = -EINVAL;
2818 goto exit;
2819 }
2820 priv->pm_mode = AT76_PM_ON;
2821 }
2822exit:
2823 return err;
2824}
2825
2826static int at76_iw_handler_get_power(struct net_device *netdev,
2827 struct iw_request_info *info,
2828 struct iw_param *power, char *extra)
2829{
2830 struct at76_priv *priv = netdev_priv(netdev);
2831
2832 power->disabled = (priv->pm_mode == AT76_PM_OFF);
2833 if (!power->disabled) {
2834 power->flags = IW_POWER_PERIOD | IW_POWER_ALL_R;
2835 power->value = priv->pm_period;
2836 }
2837
2838 at76_dbg(DBG_IOCTL, "%s: SIOCGIWPOWER - %s flags 0x%x value 0x%x",
2839 netdev->name, power->disabled ? "disabled" : "enabled",
2840 power->flags, power->value);
2841
2842 return 0;
2843}
2844
2845/*******************************************************************************
2846 * Private IOCTLS
2847 */
2848static int at76_iw_set_short_preamble(struct net_device *netdev,
2849 struct iw_request_info *info, char *name,
2850 char *extra)
2851{
2852 struct at76_priv *priv = netdev_priv(netdev);
2853 int val = *((int *)name);
2854 int ret = -EIWCOMMIT;
2855
2856 at76_dbg(DBG_IOCTL, "%s: AT76_SET_SHORT_PREAMBLE, %d",
2857 netdev->name, val);
2858
2859 if (val < PREAMBLE_TYPE_LONG || val > PREAMBLE_TYPE_AUTO)
2860 ret = -EINVAL;
2861 else
2862 priv->preamble_type = val;
2863
2864 return ret;
2865}
2866
2867static int at76_iw_get_short_preamble(struct net_device *netdev,
2868 struct iw_request_info *info,
2869 union iwreq_data *wrqu, char *extra)
2870{
2871 struct at76_priv *priv = netdev_priv(netdev);
2872
2873 snprintf(wrqu->name, sizeof(wrqu->name), "%s (%d)",
2874 preambles[priv->preamble_type], priv->preamble_type);
2875 return 0;
2876}
2877
2878static int at76_iw_set_debug(struct net_device *netdev,
2879 struct iw_request_info *info,
2880 struct iw_point *data, char *extra)
2881{
2882 char *ptr;
2883 u32 val;
2884
2885 if (data->length > 0) {
2886 val = simple_strtol(extra, &ptr, 0);
2887
2888 if (ptr == extra)
2889 val = DBG_DEFAULTS;
2890
2891 at76_dbg(DBG_IOCTL, "%s: AT76_SET_DEBUG input %d: %s -> 0x%x",
2892 netdev->name, data->length, extra, val);
2893 } else
2894 val = DBG_DEFAULTS;
2895
2896 at76_dbg(DBG_IOCTL, "%s: AT76_SET_DEBUG, old 0x%x, new 0x%x",
2897 netdev->name, at76_debug, val);
2898
2899 /* jal: some more output to pin down lockups */
2900 at76_dbg(DBG_IOCTL, "%s: netif running %d queue_stopped %d "
2901 "carrier_ok %d", netdev->name, netif_running(netdev),
2902 netif_queue_stopped(netdev), netif_carrier_ok(netdev));
2903
2904 at76_debug = val;
2905
2906 return 0;
2907}
2908
2909static int at76_iw_get_debug(struct net_device *netdev,
2910 struct iw_request_info *info,
2911 union iwreq_data *wrqu, char *extra)
2912{
2913 snprintf(wrqu->name, sizeof(wrqu->name), "0x%08x", at76_debug);
2914 return 0;
2915}
2916
2917static int at76_iw_set_powersave_mode(struct net_device *netdev,
2918 struct iw_request_info *info, char *name,
2919 char *extra)
2920{
2921 struct at76_priv *priv = netdev_priv(netdev);
2922 int val = *((int *)name);
2923 int ret = -EIWCOMMIT;
2924
2925 at76_dbg(DBG_IOCTL, "%s: AT76_SET_POWERSAVE_MODE, %d (%s)",
2926 netdev->name, val,
2927 val == AT76_PM_OFF ? "active" : val == AT76_PM_ON ? "save" :
2928 val == AT76_PM_SMART ? "smart save" : "<invalid>");
2929 if (val < AT76_PM_OFF || val > AT76_PM_SMART)
2930 ret = -EINVAL;
2931 else
2932 priv->pm_mode = val;
2933
2934 return ret;
2935}
2936
2937static int at76_iw_get_powersave_mode(struct net_device *netdev,
2938 struct iw_request_info *info,
2939 union iwreq_data *wrqu, char *extra)
2940{
2941 struct at76_priv *priv = netdev_priv(netdev);
2942 int *param = (int *)extra;
2943
2944 param[0] = priv->pm_mode;
2945 return 0;
2946}
2947
2948static int at76_iw_set_scan_times(struct net_device *netdev,
2949 struct iw_request_info *info, char *name,
2950 char *extra)
2951{
2952 struct at76_priv *priv = netdev_priv(netdev);
2953 int mint = *((int *)name);
2954 int maxt = *((int *)name + 1);
2955 int ret = -EIWCOMMIT;
2956
2957 at76_dbg(DBG_IOCTL, "%s: AT76_SET_SCAN_TIMES - min %d max %d",
2958 netdev->name, mint, maxt);
2959 if (mint <= 0 || maxt <= 0 || mint > maxt)
2960 ret = -EINVAL;
2961 else {
2962 priv->scan_min_time = mint;
2963 priv->scan_max_time = maxt;
2964 }
2965
2966 return ret;
2967}
2968
2969static int at76_iw_get_scan_times(struct net_device *netdev,
2970 struct iw_request_info *info,
2971 union iwreq_data *wrqu, char *extra)
2972{
2973 struct at76_priv *priv = netdev_priv(netdev);
2974 int *param = (int *)extra;
2975
2976 param[0] = priv->scan_min_time;
2977 param[1] = priv->scan_max_time;
2978 return 0;
2979}
2980
2981static int at76_iw_set_scan_mode(struct net_device *netdev,
2982 struct iw_request_info *info, char *name,
2983 char *extra)
2984{
2985 struct at76_priv *priv = netdev_priv(netdev);
2986 int val = *((int *)name);
2987 int ret = -EIWCOMMIT;
2988
2989 at76_dbg(DBG_IOCTL, "%s: AT76_SET_SCAN_MODE - mode %s",
2990 netdev->name, (val = SCAN_TYPE_ACTIVE) ? "active" :
2991 (val = SCAN_TYPE_PASSIVE) ? "passive" : "<invalid>");
2992
2993 if (val != SCAN_TYPE_ACTIVE && val != SCAN_TYPE_PASSIVE)
2994 ret = -EINVAL;
2995 else
2996 priv->scan_mode = val;
2997
2998 return ret;
2999}
3000
3001static int at76_iw_get_scan_mode(struct net_device *netdev,
3002 struct iw_request_info *info,
3003 union iwreq_data *wrqu, char *extra)
3004{
3005 struct at76_priv *priv = netdev_priv(netdev);
3006 int *param = (int *)extra;
3007
3008 param[0] = priv->scan_mode;
3009 return 0;
3010}
3011
3012#define AT76_SET_HANDLER(h, f) [h - SIOCIWFIRST] = (iw_handler) f
3013
3014/* Standard wireless handlers */
3015static const iw_handler at76_handlers[] = {
3016 AT76_SET_HANDLER(SIOCSIWCOMMIT, at76_iw_handler_commit),
3017 AT76_SET_HANDLER(SIOCGIWNAME, at76_iw_handler_get_name),
3018 AT76_SET_HANDLER(SIOCSIWFREQ, at76_iw_handler_set_freq),
3019 AT76_SET_HANDLER(SIOCGIWFREQ, at76_iw_handler_get_freq),
3020 AT76_SET_HANDLER(SIOCSIWMODE, at76_iw_handler_set_mode),
3021 AT76_SET_HANDLER(SIOCGIWMODE, at76_iw_handler_get_mode),
3022 AT76_SET_HANDLER(SIOCGIWRANGE, at76_iw_handler_get_range),
3023 AT76_SET_HANDLER(SIOCSIWSPY, at76_iw_handler_set_spy),
3024 AT76_SET_HANDLER(SIOCGIWSPY, at76_iw_handler_get_spy),
3025 AT76_SET_HANDLER(SIOCSIWTHRSPY, at76_iw_handler_set_thrspy),
3026 AT76_SET_HANDLER(SIOCGIWTHRSPY, at76_iw_handler_get_thrspy),
3027 AT76_SET_HANDLER(SIOCSIWAP, at76_iw_handler_set_wap),
3028 AT76_SET_HANDLER(SIOCGIWAP, at76_iw_handler_get_wap),
3029 AT76_SET_HANDLER(SIOCSIWSCAN, at76_iw_handler_set_scan),
3030 AT76_SET_HANDLER(SIOCGIWSCAN, at76_iw_handler_get_scan),
3031 AT76_SET_HANDLER(SIOCSIWESSID, at76_iw_handler_set_essid),
3032 AT76_SET_HANDLER(SIOCGIWESSID, at76_iw_handler_get_essid),
3033 AT76_SET_HANDLER(SIOCSIWRATE, at76_iw_handler_set_rate),
3034 AT76_SET_HANDLER(SIOCGIWRATE, at76_iw_handler_get_rate),
3035 AT76_SET_HANDLER(SIOCSIWRTS, at76_iw_handler_set_rts),
3036 AT76_SET_HANDLER(SIOCGIWRTS, at76_iw_handler_get_rts),
3037 AT76_SET_HANDLER(SIOCSIWFRAG, at76_iw_handler_set_frag),
3038 AT76_SET_HANDLER(SIOCGIWFRAG, at76_iw_handler_get_frag),
3039 AT76_SET_HANDLER(SIOCGIWTXPOW, at76_iw_handler_get_txpow),
3040 AT76_SET_HANDLER(SIOCSIWRETRY, at76_iw_handler_set_retry),
3041 AT76_SET_HANDLER(SIOCGIWRETRY, at76_iw_handler_get_retry),
3042 AT76_SET_HANDLER(SIOCSIWENCODE, at76_iw_handler_set_encode),
3043 AT76_SET_HANDLER(SIOCGIWENCODE, at76_iw_handler_get_encode),
3044 AT76_SET_HANDLER(SIOCSIWPOWER, at76_iw_handler_set_power),
3045 AT76_SET_HANDLER(SIOCGIWPOWER, at76_iw_handler_get_power)
3046};
3047
3048#define AT76_SET_PRIV(h, f) [h - SIOCIWFIRSTPRIV] = (iw_handler) f
3049
3050/* Private wireless handlers */
3051static const iw_handler at76_priv_handlers[] = {
3052 AT76_SET_PRIV(AT76_SET_SHORT_PREAMBLE, at76_iw_set_short_preamble),
3053 AT76_SET_PRIV(AT76_GET_SHORT_PREAMBLE, at76_iw_get_short_preamble),
3054 AT76_SET_PRIV(AT76_SET_DEBUG, at76_iw_set_debug),
3055 AT76_SET_PRIV(AT76_GET_DEBUG, at76_iw_get_debug),
3056 AT76_SET_PRIV(AT76_SET_POWERSAVE_MODE, at76_iw_set_powersave_mode),
3057 AT76_SET_PRIV(AT76_GET_POWERSAVE_MODE, at76_iw_get_powersave_mode),
3058 AT76_SET_PRIV(AT76_SET_SCAN_TIMES, at76_iw_set_scan_times),
3059 AT76_SET_PRIV(AT76_GET_SCAN_TIMES, at76_iw_get_scan_times),
3060 AT76_SET_PRIV(AT76_SET_SCAN_MODE, at76_iw_set_scan_mode),
3061 AT76_SET_PRIV(AT76_GET_SCAN_MODE, at76_iw_get_scan_mode),
3062};
3063
3064/* Names and arguments of private wireless handlers */
3065static const struct iw_priv_args at76_priv_args[] = {
3066 /* 0 - long, 1 - short */
3067 {AT76_SET_SHORT_PREAMBLE,
3068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble"},
3069
3070 {AT76_GET_SHORT_PREAMBLE,
3071 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 10, "get_preamble"},
3072
3073 /* we must pass the new debug mask as a string, because iwpriv cannot
3074 * parse hex numbers starting with 0x :-( */
3075 {AT76_SET_DEBUG,
3076 IW_PRIV_TYPE_CHAR | 10, 0, "set_debug"},
3077
3078 {AT76_GET_DEBUG,
3079 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 10, "get_debug"},
3080
3081 /* 1 - active, 2 - power save, 3 - smart power save */
3082 {AT76_SET_POWERSAVE_MODE,
3083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_powersave"},
3084
3085 {AT76_GET_POWERSAVE_MODE,
3086 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_powersave"},
3087
3088 /* min_channel_time, max_channel_time */
3089 {AT76_SET_SCAN_TIMES,
3090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "set_scan_times"},
3091
3092 {AT76_GET_SCAN_TIMES,
3093 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, "get_scan_times"},
3094
3095 /* 0 - active, 1 - passive scan */
3096 {AT76_SET_SCAN_MODE,
3097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_scan_mode"},
3098
3099 {AT76_GET_SCAN_MODE,
3100 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_scan_mode"},
3101};
3102
3103static const struct iw_handler_def at76_handler_def = {
3104 .num_standard = ARRAY_SIZE(at76_handlers),
3105 .num_private = ARRAY_SIZE(at76_priv_handlers),
3106 .num_private_args = ARRAY_SIZE(at76_priv_args),
3107 .standard = at76_handlers,
3108 .private = at76_priv_handlers,
3109 .private_args = at76_priv_args,
3110 .get_wireless_stats = at76_get_wireless_stats,
3111};
3112
3113static const u8 snapsig[] = { 0xaa, 0xaa, 0x03 };
3114
3115/* RFC 1042 encapsulates Ethernet frames in 802.2 SNAP (0xaa, 0xaa, 0x03) with
3116 * a SNAP OID of 0 (0x00, 0x00, 0x00) */
3117static const u8 rfc1042sig[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
3118
3119static int at76_tx(struct sk_buff *skb, struct net_device *netdev)
3120{
3121 struct at76_priv *priv = netdev_priv(netdev);
3122 struct net_device_stats *stats = &priv->stats;
3123 int ret = 0;
3124 int wlen;
3125 int submit_len;
3126 struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer;
3127 struct ieee80211_hdr_3addr *i802_11_hdr =
3128 (struct ieee80211_hdr_3addr *)tx_buffer->packet;
3129 u8 *payload = i802_11_hdr->payload;
3130 struct ethhdr *eh = (struct ethhdr *)skb->data;
3131
3132 if (netif_queue_stopped(netdev)) {
3133 printk(KERN_ERR "%s: %s called while netdev is stopped\n",
3134 netdev->name, __func__);
3135 /* skip this packet */
3136 dev_kfree_skb(skb);
3137 return 0;
3138 }
3139
3140 if (priv->tx_urb->status == -EINPROGRESS) {
3141 printk(KERN_ERR "%s: %s called while tx urb is pending\n",
3142 netdev->name, __func__);
3143 /* skip this packet */
3144 dev_kfree_skb(skb);
3145 return 0;
3146 }
3147
3148 if (skb->len < ETH_HLEN) {
3149 printk(KERN_ERR "%s: %s: skb too short (%d)\n",
3150 netdev->name, __func__, skb->len);
3151 dev_kfree_skb(skb);
3152 return 0;
3153 }
3154
3155 at76_ledtrig_tx_activity(); /* tell ledtrigger we send a packet */
3156
3157 /* we can get rid of memcpy if we set netdev->hard_header_len to
3158 reserve enough space, but we would need to keep the skb around */
3159
3160 if (ntohs(eh->h_proto) <= ETH_DATA_LEN) {
3161 /* this is a 802.3 packet */
3162 if (skb->len >= ETH_HLEN + sizeof(rfc1042sig)
3163 && skb->data[ETH_HLEN] == rfc1042sig[0]
3164 && skb->data[ETH_HLEN + 1] == rfc1042sig[1]) {
3165 /* higher layer delivered SNAP header - keep it */
3166 memcpy(payload, skb->data + ETH_HLEN,
3167 skb->len - ETH_HLEN);
3168 wlen = IEEE80211_3ADDR_LEN + skb->len - ETH_HLEN;
3169 } else {
3170 printk(KERN_ERR "%s: dropping non-SNAP 802.2 packet "
3171 "(DSAP 0x%02x SSAP 0x%02x cntrl 0x%02x)\n",
3172 priv->netdev->name, skb->data[ETH_HLEN],
3173 skb->data[ETH_HLEN + 1],
3174 skb->data[ETH_HLEN + 2]);
3175 dev_kfree_skb(skb);
3176 return 0;
3177 }
3178 } else {
3179 /* add RFC 1042 header in front */
3180 memcpy(payload, rfc1042sig, sizeof(rfc1042sig));
3181 memcpy(payload + sizeof(rfc1042sig), &eh->h_proto,
3182 skb->len - offsetof(struct ethhdr, h_proto));
3183 wlen = IEEE80211_3ADDR_LEN + sizeof(rfc1042sig) + skb->len -
3184 offsetof(struct ethhdr, h_proto);
3185 }
3186
3187 /* make wireless header */
3188 i802_11_hdr->frame_ctl =
3189 cpu_to_le16(IEEE80211_FTYPE_DATA |
3190 (priv->wep_enabled ? IEEE80211_FCTL_PROTECTED : 0) |
3191 (priv->iw_mode ==
3192 IW_MODE_INFRA ? IEEE80211_FCTL_TODS : 0));
3193
3194 if (priv->iw_mode == IW_MODE_ADHOC) {
3195 memcpy(i802_11_hdr->addr1, eh->h_dest, ETH_ALEN);
3196 memcpy(i802_11_hdr->addr2, eh->h_source, ETH_ALEN);
3197 memcpy(i802_11_hdr->addr3, priv->bssid, ETH_ALEN);
3198 } else if (priv->iw_mode == IW_MODE_INFRA) {
3199 memcpy(i802_11_hdr->addr1, priv->bssid, ETH_ALEN);
3200 memcpy(i802_11_hdr->addr2, eh->h_source, ETH_ALEN);
3201 memcpy(i802_11_hdr->addr3, eh->h_dest, ETH_ALEN);
3202 }
3203
3204 i802_11_hdr->duration_id = cpu_to_le16(0);
3205 i802_11_hdr->seq_ctl = cpu_to_le16(0);
3206
3207 /* setup 'Atmel' header */
3208 tx_buffer->wlength = cpu_to_le16(wlen);
3209 tx_buffer->tx_rate = priv->txrate;
3210 /* for broadcast destination addresses, the firmware 0.100.x
3211 seems to choose the highest rate set with CMD_STARTUP in
3212 basic_rate_set replacing this value */
3213
3214 memset(tx_buffer->reserved, 0, sizeof(tx_buffer->reserved));
3215
3216 tx_buffer->padding = at76_calc_padding(wlen);
3217 submit_len = wlen + AT76_TX_HDRLEN + tx_buffer->padding;
3218
3219 at76_dbg(DBG_TX_DATA_CONTENT, "%s skb->data %s", priv->netdev->name,
3220 hex2str(skb->data, 32));
3221 at76_dbg(DBG_TX_DATA, "%s tx: wlen 0x%x pad 0x%x rate %d hdr %s",
3222 priv->netdev->name,
3223 le16_to_cpu(tx_buffer->wlength),
3224 tx_buffer->padding, tx_buffer->tx_rate,
3225 hex2str(i802_11_hdr, sizeof(*i802_11_hdr)));
3226 at76_dbg(DBG_TX_DATA_CONTENT, "%s payload %s", priv->netdev->name,
3227 hex2str(payload, 48));
3228
3229 /* send stuff */
3230 netif_stop_queue(netdev);
3231 netdev->trans_start = jiffies;
3232
3233 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe, tx_buffer,
3234 submit_len, at76_tx_callback, priv);
3235 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
3236 if (ret) {
3237 stats->tx_errors++;
3238 printk(KERN_ERR "%s: error in tx submit urb: %d\n",
3239 netdev->name, ret);
3240 if (ret == -EINVAL)
3241 printk(KERN_ERR
3242 "%s: -EINVAL: tx urb %p hcpriv %p complete %p\n",
3243 priv->netdev->name, priv->tx_urb,
3244 priv->tx_urb->hcpriv, priv->tx_urb->complete);
3245 } else {
3246 stats->tx_bytes += skb->len;
3247 dev_kfree_skb(skb);
3248 }
3249
3250 return ret;
3251}
3252
3253static void at76_tx_timeout(struct net_device *netdev)
3254{
3255 struct at76_priv *priv = netdev_priv(netdev);
3256
3257 if (!priv)
3258 return;
3259 dev_warn(&netdev->dev, "tx timeout.");
3260
3261 usb_unlink_urb(priv->tx_urb);
3262 priv->stats.tx_errors++;
3263}
3264
1322static int at76_submit_rx_urb(struct at76_priv *priv) 3265static int at76_submit_rx_urb(struct at76_priv *priv)
1323{ 3266{
1324 int ret; 3267 int ret;
@@ -1327,7 +3270,7 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
1327 3270
1328 if (!priv->rx_urb) { 3271 if (!priv->rx_urb) {
1329 printk(KERN_ERR "%s: %s: priv->rx_urb is NULL\n", 3272 printk(KERN_ERR "%s: %s: priv->rx_urb is NULL\n",
1330 wiphy_name(priv->hw->wiphy), __func__); 3273 priv->netdev->name, __func__);
1331 return -EFAULT; 3274 return -EFAULT;
1332 } 3275 }
1333 3276
@@ -1335,7 +3278,7 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
1335 skb = dev_alloc_skb(sizeof(struct at76_rx_buffer)); 3278 skb = dev_alloc_skb(sizeof(struct at76_rx_buffer));
1336 if (!skb) { 3279 if (!skb) {
1337 printk(KERN_ERR "%s: cannot allocate rx skbuff\n", 3280 printk(KERN_ERR "%s: cannot allocate rx skbuff\n",
1338 wiphy_name(priv->hw->wiphy)); 3281 priv->netdev->name);
1339 ret = -ENOMEM; 3282 ret = -ENOMEM;
1340 goto exit; 3283 goto exit;
1341 } 3284 }
@@ -1355,18 +3298,110 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
1355 "usb_submit_urb returned -ENODEV"); 3298 "usb_submit_urb returned -ENODEV");
1356 else 3299 else
1357 printk(KERN_ERR "%s: rx, usb_submit_urb failed: %d\n", 3300 printk(KERN_ERR "%s: rx, usb_submit_urb failed: %d\n",
1358 wiphy_name(priv->hw->wiphy), ret); 3301 priv->netdev->name, ret);
1359 } 3302 }
1360 3303
1361exit: 3304exit:
1362 if (ret < 0 && ret != -ENODEV) 3305 if (ret < 0 && ret != -ENODEV)
1363 printk(KERN_ERR "%s: cannot submit rx urb - please unload the " 3306 printk(KERN_ERR "%s: cannot submit rx urb - please unload the "
1364 "driver and/or power cycle the device\n", 3307 "driver and/or power cycle the device\n",
1365 wiphy_name(priv->hw->wiphy)); 3308 priv->netdev->name);
1366 3309
1367 return ret; 3310 return ret;
1368} 3311}
1369 3312
3313static int at76_open(struct net_device *netdev)
3314{
3315 struct at76_priv *priv = netdev_priv(netdev);
3316 int ret = 0;
3317
3318 at76_dbg(DBG_PROC_ENTRY, "%s(): entry", __func__);
3319
3320 if (mutex_lock_interruptible(&priv->mtx))
3321 return -EINTR;
3322
3323 /* if netdev->dev_addr != priv->mac_addr we must
3324 set the mac address in the device ! */
3325 if (compare_ether_addr(netdev->dev_addr, priv->mac_addr)) {
3326 if (at76_add_mac_address(priv, netdev->dev_addr) >= 0)
3327 at76_dbg(DBG_PROGRESS, "%s: set new MAC addr %s",
3328 netdev->name, mac2str(netdev->dev_addr));
3329 }
3330
3331 priv->scan_state = SCAN_IDLE;
3332 priv->last_scan = jiffies;
3333
3334 ret = at76_submit_rx_urb(priv);
3335 if (ret < 0) {
3336 printk(KERN_ERR "%s: open: submit_rx_urb failed: %d\n",
3337 netdev->name, ret);
3338 goto error;
3339 }
3340
3341 schedule_delayed_work(&priv->dwork_restart, 0);
3342
3343 at76_dbg(DBG_PROC_ENTRY, "%s(): end", __func__);
3344error:
3345 mutex_unlock(&priv->mtx);
3346 return ret < 0 ? ret : 0;
3347}
3348
3349static int at76_stop(struct net_device *netdev)
3350{
3351 struct at76_priv *priv = netdev_priv(netdev);
3352
3353 at76_dbg(DBG_DEVSTART, "%s: ENTER", __func__);
3354
3355 if (mutex_lock_interruptible(&priv->mtx))
3356 return -EINTR;
3357
3358 at76_quiesce(priv);
3359
3360 if (!priv->device_unplugged) {
3361 /* We are called by "ifconfig ethX down", not because the
3362 * device is not available anymore. */
3363 at76_set_radio(priv, 0);
3364
3365 /* We unlink rx_urb because at76_open() re-submits it.
3366 * If unplugged, at76_delete_device() takes care of it. */
3367 usb_kill_urb(priv->rx_urb);
3368 }
3369
3370 /* free the bss_list */
3371 at76_free_bss_list(priv);
3372
3373 mutex_unlock(&priv->mtx);
3374 at76_dbg(DBG_DEVSTART, "%s: EXIT", __func__);
3375
3376 return 0;
3377}
3378
3379static void at76_ethtool_get_drvinfo(struct net_device *netdev,
3380 struct ethtool_drvinfo *info)
3381{
3382 struct at76_priv *priv = netdev_priv(netdev);
3383
3384 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver));
3385 strncpy(info->version, DRIVER_VERSION, sizeof(info->version));
3386
3387 usb_make_path(priv->udev, info->bus_info, sizeof(info->bus_info));
3388
3389 snprintf(info->fw_version, sizeof(info->fw_version), "%d.%d.%d-%d",
3390 priv->fw_version.major, priv->fw_version.minor,
3391 priv->fw_version.patch, priv->fw_version.build);
3392}
3393
3394static u32 at76_ethtool_get_link(struct net_device *netdev)
3395{
3396 struct at76_priv *priv = netdev_priv(netdev);
3397 return priv->mac_state == MAC_CONNECTED;
3398}
3399
3400static struct ethtool_ops at76_ethtool_ops = {
3401 .get_drvinfo = at76_ethtool_get_drvinfo,
3402 .get_link = at76_ethtool_get_link,
3403};
3404
1370/* Download external firmware */ 3405/* Download external firmware */
1371static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe) 3406static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe)
1372{ 3407{
@@ -1463,6 +3498,406 @@ exit:
1463 return ret; 3498 return ret;
1464} 3499}
1465 3500
3501static int at76_match_essid(struct at76_priv *priv, struct bss_info *ptr)
3502{
3503 /* common criteria for both modi */
3504
3505 int ret = (priv->essid_size == 0 /* ANY ssid */ ||
3506 (priv->essid_size == ptr->ssid_len &&
3507 !memcmp(priv->essid, ptr->ssid, ptr->ssid_len)));
3508 if (!ret)
3509 at76_dbg(DBG_BSS_MATCH,
3510 "%s bss table entry %p: essid didn't match",
3511 priv->netdev->name, ptr);
3512 return ret;
3513}
3514
3515static inline int at76_match_mode(struct at76_priv *priv, struct bss_info *ptr)
3516{
3517 int ret;
3518
3519 if (priv->iw_mode == IW_MODE_ADHOC)
3520 ret = ptr->capa & WLAN_CAPABILITY_IBSS;
3521 else
3522 ret = ptr->capa & WLAN_CAPABILITY_ESS;
3523 if (!ret)
3524 at76_dbg(DBG_BSS_MATCH,
3525 "%s bss table entry %p: mode didn't match",
3526 priv->netdev->name, ptr);
3527 return ret;
3528}
3529
3530static int at76_match_rates(struct at76_priv *priv, struct bss_info *ptr)
3531{
3532 int i;
3533
3534 for (i = 0; i < ptr->rates_len; i++) {
3535 u8 rate = ptr->rates[i];
3536
3537 if (!(rate & 0x80))
3538 continue;
3539
3540 /* this is a basic rate we have to support
3541 (see IEEE802.11, ch. 7.3.2.2) */
3542 if (rate != (0x80 | hw_rates[0])
3543 && rate != (0x80 | hw_rates[1])
3544 && rate != (0x80 | hw_rates[2])
3545 && rate != (0x80 | hw_rates[3])) {
3546 at76_dbg(DBG_BSS_MATCH,
3547 "%s: bss table entry %p: basic rate %02x not "
3548 "supported", priv->netdev->name, ptr, rate);
3549 return 0;
3550 }
3551 }
3552
3553 /* if we use short preamble, the bss must support it */
3554 if (priv->preamble_type == PREAMBLE_TYPE_SHORT &&
3555 !(ptr->capa & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
3556 at76_dbg(DBG_BSS_MATCH,
3557 "%s: %p does not support short preamble",
3558 priv->netdev->name, ptr);
3559 return 0;
3560 } else
3561 return 1;
3562}
3563
3564static inline int at76_match_wep(struct at76_priv *priv, struct bss_info *ptr)
3565{
3566 if (!priv->wep_enabled && ptr->capa & WLAN_CAPABILITY_PRIVACY) {
3567 /* we have disabled WEP, but the BSS signals privacy */
3568 at76_dbg(DBG_BSS_MATCH,
3569 "%s: bss table entry %p: requires encryption",
3570 priv->netdev->name, ptr);
3571 return 0;
3572 }
3573 /* otherwise if the BSS does not signal privacy it may well
3574 accept encrypted packets from us ... */
3575 return 1;
3576}
3577
3578static inline int at76_match_bssid(struct at76_priv *priv, struct bss_info *ptr)
3579{
3580 if (!priv->wanted_bssid_valid ||
3581 !compare_ether_addr(ptr->bssid, priv->wanted_bssid))
3582 return 1;
3583
3584 at76_dbg(DBG_BSS_MATCH,
3585 "%s: requested bssid - %s does not match",
3586 priv->netdev->name, mac2str(priv->wanted_bssid));
3587 at76_dbg(DBG_BSS_MATCH,
3588 " AP bssid - %s of bss table entry %p",
3589 mac2str(ptr->bssid), ptr);
3590 return 0;
3591}
3592
3593/**
3594 * at76_match_bss - try to find a matching bss in priv->bss
3595 *
3596 * last - last bss tried
3597 *
3598 * last == NULL signals a new round starting with priv->bss_list.next
3599 * this function must be called inside an acquired priv->bss_list_spinlock
3600 * otherwise the timeout on bss may remove the newly chosen entry
3601 */
3602static struct bss_info *at76_match_bss(struct at76_priv *priv,
3603 struct bss_info *last)
3604{
3605 struct bss_info *ptr = NULL;
3606 struct list_head *curr;
3607
3608 curr = last ? last->list.next : priv->bss_list.next;
3609 while (curr != &priv->bss_list) {
3610 ptr = list_entry(curr, struct bss_info, list);
3611 if (at76_match_essid(priv, ptr) && at76_match_mode(priv, ptr)
3612 && at76_match_wep(priv, ptr) && at76_match_rates(priv, ptr)
3613 && at76_match_bssid(priv, ptr))
3614 break;
3615 curr = curr->next;
3616 }
3617
3618 if (curr == &priv->bss_list)
3619 ptr = NULL;
3620 /* otherwise ptr points to the struct bss_info we have chosen */
3621
3622 at76_dbg(DBG_BSS_TABLE, "%s %s: returned %p", priv->netdev->name,
3623 __func__, ptr);
3624 return ptr;
3625}
3626
3627/* Start joining a matching BSS, or create own IBSS */
3628static void at76_work_join(struct work_struct *work)
3629{
3630 struct at76_priv *priv = container_of(work, struct at76_priv,
3631 work_join);
3632 int ret;
3633 unsigned long flags;
3634
3635 mutex_lock(&priv->mtx);
3636
3637 WARN_ON(priv->mac_state != MAC_JOINING);
3638 if (priv->mac_state != MAC_JOINING)
3639 goto exit;
3640
3641 /* secure the access to priv->curr_bss ! */
3642 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
3643 priv->curr_bss = at76_match_bss(priv, priv->curr_bss);
3644 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
3645
3646 if (!priv->curr_bss) {
3647 /* here we haven't found a matching (i)bss ... */
3648 if (priv->iw_mode == IW_MODE_ADHOC) {
3649 at76_set_mac_state(priv, MAC_OWN_IBSS);
3650 at76_start_ibss(priv);
3651 goto exit;
3652 }
3653 /* haven't found a matching BSS in infra mode - try again */
3654 at76_set_mac_state(priv, MAC_SCANNING);
3655 schedule_work(&priv->work_start_scan);
3656 goto exit;
3657 }
3658
3659 ret = at76_join_bss(priv, priv->curr_bss);
3660 if (ret < 0) {
3661 printk(KERN_ERR "%s: join_bss failed with %d\n",
3662 priv->netdev->name, ret);
3663 goto exit;
3664 }
3665
3666 ret = at76_wait_completion(priv, CMD_JOIN);
3667 if (ret != CMD_STATUS_COMPLETE) {
3668 if (ret != CMD_STATUS_TIME_OUT)
3669 printk(KERN_ERR "%s: join_bss completed with %d\n",
3670 priv->netdev->name, ret);
3671 else
3672 printk(KERN_INFO "%s: join_bss ssid %s timed out\n",
3673 priv->netdev->name,
3674 mac2str(priv->curr_bss->bssid));
3675
3676 /* retry next BSS immediately */
3677 schedule_work(&priv->work_join);
3678 goto exit;
3679 }
3680
3681 /* here we have joined the (I)BSS */
3682 if (priv->iw_mode == IW_MODE_ADHOC) {
3683 struct bss_info *bptr = priv->curr_bss;
3684 at76_set_mac_state(priv, MAC_CONNECTED);
3685 /* get ESSID, BSSID and channel for priv->curr_bss */
3686 priv->essid_size = bptr->ssid_len;
3687 memcpy(priv->essid, bptr->ssid, bptr->ssid_len);
3688 memcpy(priv->bssid, bptr->bssid, ETH_ALEN);
3689 priv->channel = bptr->channel;
3690 at76_iwevent_bss_connect(priv->netdev, bptr->bssid);
3691 netif_carrier_on(priv->netdev);
3692 netif_start_queue(priv->netdev);
3693 /* just to be sure */
3694 cancel_delayed_work(&priv->dwork_get_scan);
3695 cancel_delayed_work(&priv->dwork_auth);
3696 cancel_delayed_work(&priv->dwork_assoc);
3697 } else {
3698 /* send auth req */
3699 priv->retries = AUTH_RETRIES;
3700 at76_set_mac_state(priv, MAC_AUTH);
3701 at76_auth_req(priv, priv->curr_bss, 1, NULL);
3702 at76_dbg(DBG_MGMT_TIMER,
3703 "%s:%d: starting mgmt_timer + HZ", __func__, __LINE__);
3704 schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
3705 }
3706
3707exit:
3708 mutex_unlock(&priv->mtx);
3709}
3710
3711/* Reap scan results */
3712static void at76_dwork_get_scan(struct work_struct *work)
3713{
3714 int status;
3715 int ret;
3716 struct at76_priv *priv = container_of(work, struct at76_priv,
3717 dwork_get_scan.work);
3718
3719 mutex_lock(&priv->mtx);
3720 WARN_ON(priv->mac_state != MAC_SCANNING);
3721 if (priv->mac_state != MAC_SCANNING)
3722 goto exit;
3723
3724 status = at76_get_cmd_status(priv->udev, CMD_SCAN);
3725 if (status < 0) {
3726 printk(KERN_ERR "%s: %s: at76_get_cmd_status failed with %d\n",
3727 priv->netdev->name, __func__, status);
3728 status = CMD_STATUS_IN_PROGRESS;
3729 /* INFO: Hope it was a one off error - if not, scanning
3730 further down the line and stop this cycle */
3731 }
3732 at76_dbg(DBG_PROGRESS,
3733 "%s %s: got cmd_status %d (state %s, need_any %d)",
3734 priv->netdev->name, __func__, status,
3735 mac_states[priv->mac_state], priv->scan_need_any);
3736
3737 if (status != CMD_STATUS_COMPLETE) {
3738 if ((status != CMD_STATUS_IN_PROGRESS) &&
3739 (status != CMD_STATUS_IDLE))
3740 printk(KERN_ERR "%s: %s: Bad scan status: %s\n",
3741 priv->netdev->name, __func__,
3742 at76_get_cmd_status_string(status));
3743
3744 /* the first cmd status after scan start is always a IDLE ->
3745 start the timer to poll again until COMPLETED */
3746 at76_dbg(DBG_MGMT_TIMER,
3747 "%s:%d: starting mgmt_timer for %d ticks",
3748 __func__, __LINE__, SCAN_POLL_INTERVAL);
3749 schedule_delayed_work(&priv->dwork_get_scan,
3750 SCAN_POLL_INTERVAL);
3751 goto exit;
3752 }
3753
3754 if (at76_debug & DBG_BSS_TABLE)
3755 at76_dump_bss_table(priv);
3756
3757 if (priv->scan_need_any) {
3758 ret = at76_start_scan(priv, 0);
3759 if (ret < 0)
3760 printk(KERN_ERR
3761 "%s: %s: start_scan (ANY) failed with %d\n",
3762 priv->netdev->name, __func__, ret);
3763 at76_dbg(DBG_MGMT_TIMER,
3764 "%s:%d: starting mgmt_timer for %d ticks", __func__,
3765 __LINE__, SCAN_POLL_INTERVAL);
3766 schedule_delayed_work(&priv->dwork_get_scan,
3767 SCAN_POLL_INTERVAL);
3768 priv->scan_need_any = 0;
3769 } else {
3770 priv->scan_state = SCAN_COMPLETED;
3771 /* report the end of scan to user space */
3772 at76_iwevent_scan_complete(priv->netdev);
3773 at76_set_mac_state(priv, MAC_JOINING);
3774 schedule_work(&priv->work_join);
3775 }
3776
3777exit:
3778 mutex_unlock(&priv->mtx);
3779}
3780
3781/* Handle loss of beacons from the AP */
3782static void at76_dwork_beacon(struct work_struct *work)
3783{
3784 struct at76_priv *priv = container_of(work, struct at76_priv,
3785 dwork_beacon.work);
3786
3787 mutex_lock(&priv->mtx);
3788 if (priv->mac_state != MAC_CONNECTED || priv->iw_mode != IW_MODE_INFRA)
3789 goto exit;
3790
3791 /* We haven't received any beacons from out AP for BEACON_TIMEOUT */
3792 printk(KERN_INFO "%s: lost beacon bssid %s\n",
3793 priv->netdev->name, mac2str(priv->curr_bss->bssid));
3794
3795 netif_carrier_off(priv->netdev);
3796 netif_stop_queue(priv->netdev);
3797 at76_iwevent_bss_disconnect(priv->netdev);
3798 at76_set_mac_state(priv, MAC_SCANNING);
3799 schedule_work(&priv->work_start_scan);
3800
3801exit:
3802 mutex_unlock(&priv->mtx);
3803}
3804
3805/* Handle authentication response timeout */
3806static void at76_dwork_auth(struct work_struct *work)
3807{
3808 struct at76_priv *priv = container_of(work, struct at76_priv,
3809 dwork_auth.work);
3810
3811 mutex_lock(&priv->mtx);
3812 WARN_ON(priv->mac_state != MAC_AUTH);
3813 if (priv->mac_state != MAC_AUTH)
3814 goto exit;
3815
3816 at76_dbg(DBG_PROGRESS, "%s: authentication response timeout",
3817 priv->netdev->name);
3818
3819 if (priv->retries-- >= 0) {
3820 at76_auth_req(priv, priv->curr_bss, 1, NULL);
3821 at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ",
3822 __func__, __LINE__);
3823 schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
3824 } else {
3825 /* try to get next matching BSS */
3826 at76_set_mac_state(priv, MAC_JOINING);
3827 schedule_work(&priv->work_join);
3828 }
3829
3830exit:
3831 mutex_unlock(&priv->mtx);
3832}
3833
3834/* Handle association response timeout */
3835static void at76_dwork_assoc(struct work_struct *work)
3836{
3837 struct at76_priv *priv = container_of(work, struct at76_priv,
3838 dwork_assoc.work);
3839
3840 mutex_lock(&priv->mtx);
3841 WARN_ON(priv->mac_state != MAC_ASSOC);
3842 if (priv->mac_state != MAC_ASSOC)
3843 goto exit;
3844
3845 at76_dbg(DBG_PROGRESS, "%s: association response timeout",
3846 priv->netdev->name);
3847
3848 if (priv->retries-- >= 0) {
3849 at76_assoc_req(priv, priv->curr_bss);
3850 at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ",
3851 __func__, __LINE__);
3852 schedule_delayed_work(&priv->dwork_assoc, ASSOC_TIMEOUT);
3853 } else {
3854 /* try to get next matching BSS */
3855 at76_set_mac_state(priv, MAC_JOINING);
3856 schedule_work(&priv->work_join);
3857 }
3858
3859exit:
3860 mutex_unlock(&priv->mtx);
3861}
3862
3863/* Read new bssid in ad-hoc mode */
3864static void at76_work_new_bss(struct work_struct *work)
3865{
3866 struct at76_priv *priv = container_of(work, struct at76_priv,
3867 work_new_bss);
3868 int ret;
3869 struct mib_mac_mgmt mac_mgmt;
3870
3871 mutex_lock(&priv->mtx);
3872
3873 ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, &mac_mgmt,
3874 sizeof(struct mib_mac_mgmt));
3875 if (ret < 0) {
3876 printk(KERN_ERR "%s: at76_get_mib failed: %d\n",
3877 priv->netdev->name, ret);
3878 goto exit;
3879 }
3880
3881 at76_dbg(DBG_PROGRESS, "ibss_change = 0x%2x", mac_mgmt.ibss_change);
3882 memcpy(priv->bssid, mac_mgmt.current_bssid, ETH_ALEN);
3883 at76_dbg(DBG_PROGRESS, "using BSSID %s", mac2str(priv->bssid));
3884
3885 at76_iwevent_bss_connect(priv->netdev, priv->bssid);
3886
3887 priv->mib_buf.type = MIB_MAC_MGMT;
3888 priv->mib_buf.size = 1;
3889 priv->mib_buf.index = offsetof(struct mib_mac_mgmt, ibss_change);
3890 priv->mib_buf.data.byte = 0;
3891
3892 ret = at76_set_mib(priv, &priv->mib_buf);
3893 if (ret < 0)
3894 printk(KERN_ERR "%s: set_mib (ibss change ok) failed: %d\n",
3895 priv->netdev->name, ret);
3896
3897exit:
3898 mutex_unlock(&priv->mtx);
3899}
3900
1466static int at76_startup_device(struct at76_priv *priv) 3901static int at76_startup_device(struct at76_priv *priv)
1467{ 3902{
1468 struct at76_card_config *ccfg = &priv->card_config; 3903 struct at76_card_config *ccfg = &priv->card_config;
@@ -1470,14 +3905,14 @@ static int at76_startup_device(struct at76_priv *priv)
1470 3905
1471 at76_dbg(DBG_PARAMS, 3906 at76_dbg(DBG_PARAMS,
1472 "%s param: ssid %.*s (%s) mode %s ch %d wep %s key %d " 3907 "%s param: ssid %.*s (%s) mode %s ch %d wep %s key %d "
1473 "keylen %d", wiphy_name(priv->hw->wiphy), priv->essid_size, 3908 "keylen %d", priv->netdev->name, priv->essid_size, priv->essid,
1474 priv->essid, hex2str(priv->essid, IW_ESSID_MAX_SIZE), 3909 hex2str(priv->essid, IW_ESSID_MAX_SIZE),
1475 priv->iw_mode == IW_MODE_ADHOC ? "adhoc" : "infra", 3910 priv->iw_mode == IW_MODE_ADHOC ? "adhoc" : "infra",
1476 priv->channel, priv->wep_enabled ? "enabled" : "disabled", 3911 priv->channel, priv->wep_enabled ? "enabled" : "disabled",
1477 priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]); 3912 priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]);
1478 at76_dbg(DBG_PARAMS, 3913 at76_dbg(DBG_PARAMS,
1479 "%s param: preamble %s rts %d retry %d frag %d " 3914 "%s param: preamble %s rts %d retry %d frag %d "
1480 "txrate %s auth_mode %d", wiphy_name(priv->hw->wiphy), 3915 "txrate %s auth_mode %d", priv->netdev->name,
1481 preambles[priv->preamble_type], priv->rts_threshold, 3916 preambles[priv->preamble_type], priv->rts_threshold,
1482 priv->short_retry_limit, priv->frag_threshold, 3917 priv->short_retry_limit, priv->frag_threshold,
1483 priv->txrate == TX_RATE_1MBIT ? "1MBit" : priv->txrate == 3918 priv->txrate == TX_RATE_1MBIT ? "1MBit" : priv->txrate ==
@@ -1488,7 +3923,7 @@ static int at76_startup_device(struct at76_priv *priv)
1488 at76_dbg(DBG_PARAMS, 3923 at76_dbg(DBG_PARAMS,
1489 "%s param: pm_mode %d pm_period %d auth_mode %s " 3924 "%s param: pm_mode %d pm_period %d auth_mode %s "
1490 "scan_times %d %d scan_mode %s", 3925 "scan_times %d %d scan_mode %s",
1491 wiphy_name(priv->hw->wiphy), priv->pm_mode, priv->pm_period, 3926 priv->netdev->name, priv->pm_mode, priv->pm_period,
1492 priv->auth_mode == WLAN_AUTH_OPEN ? "open" : "shared_secret", 3927 priv->auth_mode == WLAN_AUTH_OPEN ? "open" : "shared_secret",
1493 priv->scan_min_time, priv->scan_max_time, 3928 priv->scan_min_time, priv->scan_max_time,
1494 priv->scan_mode == SCAN_TYPE_ACTIVE ? "active" : "passive"); 3929 priv->scan_mode == SCAN_TYPE_ACTIVE ? "active" : "passive");
@@ -1522,8 +3957,7 @@ static int at76_startup_device(struct at76_priv *priv)
1522 ccfg->ssid_len = priv->essid_size; 3957 ccfg->ssid_len = priv->essid_size;
1523 3958
1524 ccfg->wep_default_key_id = priv->wep_key_id; 3959 ccfg->wep_default_key_id = priv->wep_key_id;
1525 memcpy(ccfg->wep_default_key_value, priv->wep_keys, 3960 memcpy(ccfg->wep_default_key_value, priv->wep_keys, 4 * WEP_KEY_LEN);
1526 sizeof(priv->wep_keys));
1527 3961
1528 ccfg->short_preamble = priv->preamble_type; 3962 ccfg->short_preamble = priv->preamble_type;
1529 ccfg->beacon_period = cpu_to_le16(priv->beacon_period); 3963 ccfg->beacon_period = cpu_to_le16(priv->beacon_period);
@@ -1532,7 +3966,7 @@ static int at76_startup_device(struct at76_priv *priv)
1532 sizeof(struct at76_card_config)); 3966 sizeof(struct at76_card_config));
1533 if (ret < 0) { 3967 if (ret < 0) {
1534 printk(KERN_ERR "%s: at76_set_card_command failed: %d\n", 3968 printk(KERN_ERR "%s: at76_set_card_command failed: %d\n",
1535 wiphy_name(priv->hw->wiphy), ret); 3969 priv->netdev->name, ret);
1536 return ret; 3970 return ret;
1537 } 3971 }
1538 3972
@@ -1578,6 +4012,69 @@ static int at76_startup_device(struct at76_priv *priv)
1578 return 0; 4012 return 0;
1579} 4013}
1580 4014
4015/* Restart the interface */
4016static void at76_dwork_restart(struct work_struct *work)
4017{
4018 struct at76_priv *priv = container_of(work, struct at76_priv,
4019 dwork_restart.work);
4020
4021 mutex_lock(&priv->mtx);
4022
4023 netif_carrier_off(priv->netdev); /* stop netdev watchdog */
4024 netif_stop_queue(priv->netdev); /* stop tx data packets */
4025
4026 at76_startup_device(priv);
4027
4028 if (priv->iw_mode != IW_MODE_MONITOR) {
4029 priv->netdev->type = ARPHRD_ETHER;
4030 at76_set_mac_state(priv, MAC_SCANNING);
4031 schedule_work(&priv->work_start_scan);
4032 } else {
4033 priv->netdev->type = ARPHRD_IEEE80211_RADIOTAP;
4034 at76_start_monitor(priv);
4035 }
4036
4037 mutex_unlock(&priv->mtx);
4038}
4039
4040/* Initiate scanning */
4041static void at76_work_start_scan(struct work_struct *work)
4042{
4043 struct at76_priv *priv = container_of(work, struct at76_priv,
4044 work_start_scan);
4045 int ret;
4046
4047 mutex_lock(&priv->mtx);
4048
4049 WARN_ON(priv->mac_state != MAC_SCANNING);
4050 if (priv->mac_state != MAC_SCANNING)
4051 goto exit;
4052
4053 /* only clear the bss list when a scan is actively initiated,
4054 * otherwise simply rely on at76_bss_list_timeout */
4055 if (priv->scan_state == SCAN_IN_PROGRESS) {
4056 at76_free_bss_list(priv);
4057 priv->scan_need_any = 1;
4058 } else
4059 priv->scan_need_any = 0;
4060
4061 ret = at76_start_scan(priv, 1);
4062
4063 if (ret < 0)
4064 printk(KERN_ERR "%s: %s: start_scan failed with %d\n",
4065 priv->netdev->name, __func__, ret);
4066 else {
4067 at76_dbg(DBG_MGMT_TIMER,
4068 "%s:%d: starting mgmt_timer for %d ticks",
4069 __func__, __LINE__, SCAN_POLL_INTERVAL);
4070 schedule_delayed_work(&priv->dwork_get_scan,
4071 SCAN_POLL_INTERVAL);
4072 }
4073
4074exit:
4075 mutex_unlock(&priv->mtx);
4076}
4077
1581/* Enable or disable promiscuous mode */ 4078/* Enable or disable promiscuous mode */
1582static void at76_work_set_promisc(struct work_struct *work) 4079static void at76_work_set_promisc(struct work_struct *work)
1583{ 4080{
@@ -1595,7 +4092,7 @@ static void at76_work_set_promisc(struct work_struct *work)
1595 ret = at76_set_mib(priv, &priv->mib_buf); 4092 ret = at76_set_mib(priv, &priv->mib_buf);
1596 if (ret < 0) 4093 if (ret < 0)
1597 printk(KERN_ERR "%s: set_mib (promiscuous_mode) failed: %d\n", 4094 printk(KERN_ERR "%s: set_mib (promiscuous_mode) failed: %d\n",
1598 wiphy_name(priv->hw->wiphy), ret); 4095 priv->netdev->name, ret);
1599 4096
1600 mutex_unlock(&priv->mtx); 4097 mutex_unlock(&priv->mtx);
1601} 4098}
@@ -1611,759 +4108,1088 @@ static void at76_work_submit_rx(struct work_struct *work)
1611 mutex_unlock(&priv->mtx); 4108 mutex_unlock(&priv->mtx);
1612} 4109}
1613 4110
1614static void at76_rx_tasklet(unsigned long param) 4111/* We got an association response */
4112static void at76_rx_mgmt_assoc(struct at76_priv *priv,
4113 struct at76_rx_buffer *buf)
1615{ 4114{
1616 struct urb *urb = (struct urb *)param; 4115 struct ieee80211_assoc_response *resp =
1617 struct at76_priv *priv = urb->context; 4116 (struct ieee80211_assoc_response *)buf->packet;
1618 struct at76_rx_buffer *buf; 4117 u16 assoc_id = le16_to_cpu(resp->aid);
1619 struct ieee80211_rx_status rx_status = { 0 }; 4118 u16 status = le16_to_cpu(resp->status);
1620 4119
1621 if (priv->device_unplugged) { 4120 at76_dbg(DBG_RX_MGMT, "%s: rx AssocResp bssid %s capa 0x%04x status "
1622 at76_dbg(DBG_DEVSTART, "device unplugged"); 4121 "0x%04x assoc_id 0x%04x rates %s", priv->netdev->name,
1623 if (urb) 4122 mac2str(resp->header.addr3), le16_to_cpu(resp->capability),
1624 at76_dbg(DBG_DEVSTART, "urb status %d", urb->status); 4123 status, assoc_id, hex2str(resp->info_element->data,
4124 resp->info_element->len));
4125
4126 if (priv->mac_state != MAC_ASSOC) {
4127 printk(KERN_INFO "%s: AssocResp in state %s ignored\n",
4128 priv->netdev->name, mac_states[priv->mac_state]);
1625 return; 4129 return;
1626 } 4130 }
1627 4131
1628 if (!priv->rx_skb || !priv->rx_skb->data) 4132 BUG_ON(!priv->curr_bss);
1629 return; 4133
1630 4134 cancel_delayed_work(&priv->dwork_assoc);
1631 buf = (struct at76_rx_buffer *)priv->rx_skb->data; 4135 if (status == WLAN_STATUS_SUCCESS) {
1632 4136 struct bss_info *ptr = priv->curr_bss;
1633 if (urb->status != 0) { 4137 priv->assoc_id = assoc_id & 0x3fff;
1634 if (urb->status != -ENOENT && urb->status != -ECONNRESET) 4138 /* update iwconfig params */
1635 at76_dbg(DBG_URB, 4139 memcpy(priv->bssid, ptr->bssid, ETH_ALEN);
1636 "%s %s: - nonzero Rx bulk status received: %d", 4140 memcpy(priv->essid, ptr->ssid, ptr->ssid_len);
1637 __func__, wiphy_name(priv->hw->wiphy), 4141 priv->essid_size = ptr->ssid_len;
1638 urb->status); 4142 priv->channel = ptr->channel;
1639 return; 4143 schedule_work(&priv->work_assoc_done);
4144 } else {
4145 at76_set_mac_state(priv, MAC_JOINING);
4146 schedule_work(&priv->work_join);
1640 } 4147 }
4148}
1641 4149
1642 at76_dbg(DBG_RX_ATMEL_HDR, 4150/* Process disassociation request from the AP */
1643 "%s: rx frame: rate %d rssi %d noise %d link %d", 4151static void at76_rx_mgmt_disassoc(struct at76_priv *priv,
1644 wiphy_name(priv->hw->wiphy), buf->rx_rate, buf->rssi, 4152 struct at76_rx_buffer *buf)
1645 buf->noise_level, buf->link_quality); 4153{
1646 4154 struct ieee80211_disassoc *resp =
1647 skb_trim(priv->rx_skb, le16_to_cpu(buf->wlength) + AT76_RX_HDRLEN); 4155 (struct ieee80211_disassoc *)buf->packet;
1648 at76_dbg_dump(DBG_RX_DATA, &priv->rx_skb->data[AT76_RX_HDRLEN], 4156 struct ieee80211_hdr_3addr *mgmt = &resp->header;
1649 priv->rx_skb->len, "RX: len=%d", 4157
1650 (int)(priv->rx_skb->len - AT76_RX_HDRLEN)); 4158 at76_dbg(DBG_RX_MGMT,
4159 "%s: rx DisAssoc bssid %s reason 0x%04x destination %s",
4160 priv->netdev->name, mac2str(mgmt->addr3),
4161 le16_to_cpu(resp->reason), mac2str(mgmt->addr1));
4162
4163 /* We are not connected, ignore */
4164 if (priv->mac_state == MAC_SCANNING || priv->mac_state == MAC_INIT
4165 || !priv->curr_bss)
4166 return;
1651 4167
1652 rx_status.signal = buf->rssi; 4168 /* Not our BSSID, ignore */
1653 /* FIXME: is rate_idx still present in structure? */ 4169 if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
1654 rx_status.rate_idx = buf->rx_rate; 4170 return;
1655 rx_status.flag |= RX_FLAG_DECRYPTED;
1656 rx_status.flag |= RX_FLAG_IV_STRIPPED;
1657 4171
1658 skb_pull(priv->rx_skb, AT76_RX_HDRLEN); 4172 /* Not for our STA and not broadcast, ignore */
1659 at76_dbg(DBG_MAC80211, "calling ieee80211_rx_irqsafe(): %d/%d", 4173 if (compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1)
1660 priv->rx_skb->len, priv->rx_skb->data_len); 4174 && !is_broadcast_ether_addr(mgmt->addr1))
1661 ieee80211_rx_irqsafe(priv->hw, priv->rx_skb, &rx_status); 4175 return;
1662 4176
1663 /* Use a new skb for the next receive */ 4177 if (priv->mac_state != MAC_ASSOC && priv->mac_state != MAC_CONNECTED
1664 priv->rx_skb = NULL; 4178 && priv->mac_state != MAC_JOINING) {
4179 printk(KERN_INFO "%s: DisAssoc in state %s ignored\n",
4180 priv->netdev->name, mac_states[priv->mac_state]);
4181 return;
4182 }
1665 4183
1666 at76_submit_rx_urb(priv); 4184 if (priv->mac_state == MAC_CONNECTED) {
4185 netif_carrier_off(priv->netdev);
4186 netif_stop_queue(priv->netdev);
4187 at76_iwevent_bss_disconnect(priv->netdev);
4188 }
4189 cancel_delayed_work(&priv->dwork_get_scan);
4190 cancel_delayed_work(&priv->dwork_beacon);
4191 cancel_delayed_work(&priv->dwork_auth);
4192 cancel_delayed_work(&priv->dwork_assoc);
4193 at76_set_mac_state(priv, MAC_JOINING);
4194 schedule_work(&priv->work_join);
1667} 4195}
1668 4196
1669/* Load firmware into kernel memory and parse it */ 4197static void at76_rx_mgmt_auth(struct at76_priv *priv,
1670static struct fwentry *at76_load_firmware(struct usb_device *udev, 4198 struct at76_rx_buffer *buf)
1671 enum board_type board_type)
1672{ 4199{
1673 int ret; 4200 struct ieee80211_auth *resp = (struct ieee80211_auth *)buf->packet;
1674 char *str; 4201 struct ieee80211_hdr_3addr *mgmt = &resp->header;
1675 struct at76_fw_header *fwh; 4202 int seq_nr = le16_to_cpu(resp->transaction);
1676 struct fwentry *fwe = &firmwares[board_type]; 4203 int alg = le16_to_cpu(resp->algorithm);
1677 4204 int status = le16_to_cpu(resp->status);
1678 mutex_lock(&fw_mutex); 4205
1679 4206 at76_dbg(DBG_RX_MGMT,
1680 if (fwe->loaded) { 4207 "%s: rx AuthFrame bssid %s alg %d seq_nr %d status %d "
1681 at76_dbg(DBG_FW, "re-using previously loaded fw"); 4208 "destination %s", priv->netdev->name, mac2str(mgmt->addr3),
1682 goto exit; 4209 alg, seq_nr, status, mac2str(mgmt->addr1));
4210
4211 if (alg == WLAN_AUTH_SHARED_KEY && seq_nr == 2)
4212 at76_dbg(DBG_RX_MGMT, "%s: AuthFrame challenge %s ...",
4213 priv->netdev->name, hex2str(resp->info_element, 18));
4214
4215 if (priv->mac_state != MAC_AUTH) {
4216 printk(KERN_INFO "%s: ignored AuthFrame in state %s\n",
4217 priv->netdev->name, mac_states[priv->mac_state]);
4218 return;
1683 } 4219 }
1684 4220 if (priv->auth_mode != alg) {
1685 at76_dbg(DBG_FW, "downloading firmware %s", fwe->fwname); 4221 printk(KERN_INFO "%s: ignored AuthFrame for alg %d\n",
1686 ret = request_firmware(&fwe->fw, fwe->fwname, &udev->dev); 4222 priv->netdev->name, alg);
1687 if (ret < 0) { 4223 return;
1688 dev_printk(KERN_ERR, &udev->dev, "firmware %s not found!\n",
1689 fwe->fwname);
1690 dev_printk(KERN_ERR, &udev->dev,
1691 "you may need to download the firmware from "
1692 "http://developer.berlios.de/projects/at76c503a/\n");
1693 goto exit;
1694 } 4224 }
1695 4225
1696 at76_dbg(DBG_FW, "got it."); 4226 BUG_ON(!priv->curr_bss);
1697 fwh = (struct at76_fw_header *)(fwe->fw->data);
1698 4227
1699 if (fwe->fw->size <= sizeof(*fwh)) { 4228 /* Not our BSSID or not for our STA, ignore */
1700 dev_printk(KERN_ERR, &udev->dev, 4229 if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid)
1701 "firmware is too short (0x%zx)\n", fwe->fw->size); 4230 || compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1))
1702 goto exit; 4231 return;
4232
4233 cancel_delayed_work(&priv->dwork_auth);
4234 if (status != WLAN_STATUS_SUCCESS) {
4235 /* try to join next bss */
4236 at76_set_mac_state(priv, MAC_JOINING);
4237 schedule_work(&priv->work_join);
4238 return;
1703 } 4239 }
1704 4240
1705 /* CRC currently not checked */ 4241 if (priv->auth_mode == WLAN_AUTH_OPEN || seq_nr == 4) {
1706 fwe->board_type = le32_to_cpu(fwh->board_type); 4242 priv->retries = ASSOC_RETRIES;
1707 if (fwe->board_type != board_type) { 4243 at76_set_mac_state(priv, MAC_ASSOC);
1708 dev_printk(KERN_ERR, &udev->dev, 4244 at76_assoc_req(priv, priv->curr_bss);
1709 "board type mismatch, requested %u, got %u\n", 4245 at76_dbg(DBG_MGMT_TIMER,
1710 board_type, fwe->board_type); 4246 "%s:%d: starting mgmt_timer + HZ", __func__, __LINE__);
1711 goto exit; 4247 schedule_delayed_work(&priv->dwork_assoc, ASSOC_TIMEOUT);
4248 return;
1712 } 4249 }
1713 4250
1714 fwe->fw_version.major = fwh->major; 4251 WARN_ON(seq_nr != 2);
1715 fwe->fw_version.minor = fwh->minor; 4252 at76_auth_req(priv, priv->curr_bss, seq_nr + 1, resp->info_element);
1716 fwe->fw_version.patch = fwh->patch; 4253 at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ", __func__,
1717 fwe->fw_version.build = fwh->build; 4254 __LINE__);
4255 schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
4256}
1718 4257
1719 str = (char *)fwh + le32_to_cpu(fwh->str_offset); 4258static void at76_rx_mgmt_deauth(struct at76_priv *priv,
1720 fwe->intfw = (u8 *)fwh + le32_to_cpu(fwh->int_fw_offset); 4259 struct at76_rx_buffer *buf)
1721 fwe->intfw_size = le32_to_cpu(fwh->int_fw_len); 4260{
1722 fwe->extfw = (u8 *)fwh + le32_to_cpu(fwh->ext_fw_offset); 4261 struct ieee80211_disassoc *resp =
1723 fwe->extfw_size = le32_to_cpu(fwh->ext_fw_len); 4262 (struct ieee80211_disassoc *)buf->packet;
4263 struct ieee80211_hdr_3addr *mgmt = &resp->header;
4264
4265 at76_dbg(DBG_RX_MGMT | DBG_PROGRESS,
4266 "%s: rx DeAuth bssid %s reason 0x%04x destination %s",
4267 priv->netdev->name, mac2str(mgmt->addr3),
4268 le16_to_cpu(resp->reason), mac2str(mgmt->addr1));
4269
4270 if (priv->mac_state != MAC_AUTH && priv->mac_state != MAC_ASSOC
4271 && priv->mac_state != MAC_CONNECTED) {
4272 printk(KERN_INFO "%s: DeAuth in state %s ignored\n",
4273 priv->netdev->name, mac_states[priv->mac_state]);
4274 return;
4275 }
1724 4276
1725 fwe->loaded = 1; 4277 BUG_ON(!priv->curr_bss);
1726 4278
1727 dev_printk(KERN_DEBUG, &udev->dev, 4279 /* Not our BSSID, ignore */
1728 "using firmware %s (version %d.%d.%d-%d)\n", 4280 if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
1729 fwe->fwname, fwh->major, fwh->minor, fwh->patch, fwh->build); 4281 return;
1730 4282
1731 at76_dbg(DBG_DEVSTART, "board %u, int %d:%d, ext %d:%d", board_type, 4283 /* Not for our STA and not broadcast, ignore */
1732 le32_to_cpu(fwh->int_fw_offset), le32_to_cpu(fwh->int_fw_len), 4284 if (compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1)
1733 le32_to_cpu(fwh->ext_fw_offset), le32_to_cpu(fwh->ext_fw_len)); 4285 && !is_broadcast_ether_addr(mgmt->addr1))
1734 at76_dbg(DBG_DEVSTART, "firmware id %s", str); 4286 return;
1735 4287
1736exit: 4288 if (priv->mac_state == MAC_CONNECTED)
1737 mutex_unlock(&fw_mutex); 4289 at76_iwevent_bss_disconnect(priv->netdev);
1738 4290
1739 if (fwe->loaded) 4291 at76_set_mac_state(priv, MAC_JOINING);
1740 return fwe; 4292 schedule_work(&priv->work_join);
1741 else 4293 cancel_delayed_work(&priv->dwork_get_scan);
1742 return NULL; 4294 cancel_delayed_work(&priv->dwork_beacon);
4295 cancel_delayed_work(&priv->dwork_auth);
4296 cancel_delayed_work(&priv->dwork_assoc);
1743} 4297}
1744 4298
1745static void at76_mac80211_tx_callback(struct urb *urb) 4299static void at76_rx_mgmt_beacon(struct at76_priv *priv,
4300 struct at76_rx_buffer *buf)
1746{ 4301{
1747 struct at76_priv *priv = urb->context; 4302 int varpar_len;
1748 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(priv->tx_skb); 4303 /* beacon content */
4304 struct ieee80211_beacon *bdata = (struct ieee80211_beacon *)buf->packet;
4305 struct ieee80211_hdr_3addr *mgmt = &bdata->header;
4306
4307 struct list_head *lptr;
4308 struct bss_info *match; /* entry matching addr3 with its bssid */
4309 int new_entry = 0;
4310 int len;
4311 struct ieee80211_info_element *ie;
4312 int have_ssid = 0;
4313 int have_rates = 0;
4314 int have_channel = 0;
4315 int keep_going = 1;
4316 unsigned long flags;
4317
4318 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
4319 if (priv->mac_state == MAC_CONNECTED) {
4320 /* in state MAC_CONNECTED we use the mgmt_timer to control
4321 the beacon of the BSS */
4322 BUG_ON(!priv->curr_bss);
4323
4324 if (!compare_ether_addr(priv->curr_bss->bssid, mgmt->addr3)) {
4325 /* We got our AP's beacon, defer the timeout handler.
4326 Kill pending work first, as schedule_delayed_work()
4327 won't do it. */
4328 cancel_delayed_work(&priv->dwork_beacon);
4329 schedule_delayed_work(&priv->dwork_beacon,
4330 BEACON_TIMEOUT);
4331 priv->curr_bss->rssi = buf->rssi;
4332 priv->beacons_received++;
4333 goto exit;
4334 }
4335 }
1749 4336
1750 at76_dbg(DBG_MAC80211, "%s()", __func__); 4337 /* look if we have this BSS already in the list */
4338 match = NULL;
1751 4339
1752 switch (urb->status) { 4340 if (!list_empty(&priv->bss_list)) {
1753 case 0: 4341 list_for_each(lptr, &priv->bss_list) {
1754 /* success */ 4342 struct bss_info *bss_ptr =
1755 /* FIXME: 4343 list_entry(lptr, struct bss_info, list);
1756 * is the frame really ACKed when tx_callback is called ? */ 4344 if (!compare_ether_addr(bss_ptr->bssid, mgmt->addr3)) {
1757 info->flags |= IEEE80211_TX_STAT_ACK; 4345 match = bss_ptr;
1758 break; 4346 break;
1759 case -ENOENT: 4347 }
1760 case -ECONNRESET: 4348 }
1761 /* fail, urb has been unlinked */
1762 /* FIXME: add error message */
1763 break;
1764 default:
1765 at76_dbg(DBG_URB, "%s - nonzero tx status received: %d",
1766 __func__, urb->status);
1767 break;
1768 } 4349 }
1769 4350
1770 memset(&info->status, 0, sizeof(info->status)); 4351 if (!match) {
4352 /* BSS not in the list - append it */
4353 match = kzalloc(sizeof(struct bss_info), GFP_ATOMIC);
4354 if (!match) {
4355 at76_dbg(DBG_BSS_TABLE,
4356 "%s: cannot kmalloc new bss info (%zd byte)",
4357 priv->netdev->name, sizeof(struct bss_info));
4358 goto exit;
4359 }
4360 new_entry = 1;
4361 list_add_tail(&match->list, &priv->bss_list);
4362 }
1771 4363
1772 ieee80211_tx_status_irqsafe(priv->hw, priv->tx_skb); 4364 match->capa = le16_to_cpu(bdata->capability);
4365 match->beacon_interval = le16_to_cpu(bdata->beacon_interval);
4366 match->rssi = buf->rssi;
4367 match->link_qual = buf->link_quality;
4368 match->noise_level = buf->noise_level;
4369 memcpy(match->bssid, mgmt->addr3, ETH_ALEN);
4370 at76_dbg(DBG_RX_BEACON, "%s: bssid %s", priv->netdev->name,
4371 mac2str(match->bssid));
4372
4373 ie = bdata->info_element;
4374
4375 /* length of var length beacon parameters */
4376 varpar_len = min_t(int, le16_to_cpu(buf->wlength) -
4377 sizeof(struct ieee80211_beacon),
4378 BEACON_MAX_DATA_LENGTH);
4379
4380 /* This routine steps through the bdata->data array to get
4381 * some useful information about the access point.
4382 * Currently, this implementation supports receipt of: SSID,
4383 * supported transfer rates and channel, in any order, with some
4384 * tolerance for intermittent unknown codes (although this
4385 * functionality may not be necessary as the useful information will
4386 * usually arrive in consecutively, but there have been some
4387 * reports of some of the useful information fields arriving in a
4388 * different order).
4389 * It does not support any more IE types although MFIE_TYPE_TIM may
4390 * be supported (on my AP at least).
4391 * The bdata->data array is about 1500 bytes long but only ~36 of those
4392 * bytes are useful, hence the have_ssid etc optimizations. */
4393
4394 while (keep_going &&
4395 ((&ie->data[ie->len] - (u8 *)bdata->info_element) <=
4396 varpar_len)) {
4397
4398 switch (ie->id) {
4399
4400 case MFIE_TYPE_SSID:
4401 if (have_ssid)
4402 break;
1773 4403
1774 priv->tx_skb = NULL; 4404 len = min_t(int, IW_ESSID_MAX_SIZE, ie->len);
1775 4405
1776 ieee80211_wake_queues(priv->hw); 4406 /* we copy only if this is a new entry,
1777} 4407 or the incoming SSID is not a hidden SSID. This
4408 will protect us from overwriting a real SSID read
4409 in a ProbeResponse with a hidden one from a
4410 following beacon. */
4411 if (!new_entry && at76_is_hidden_ssid(ie->data, len)) {
4412 have_ssid = 1;
4413 break;
4414 }
1778 4415
1779static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 4416 match->ssid_len = len;
1780{ 4417 memcpy(match->ssid, ie->data, len);
1781 struct at76_priv *priv = hw->priv; 4418 at76_dbg(DBG_RX_BEACON, "%s: SSID - %.*s",
1782 struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer; 4419 priv->netdev->name, len, match->ssid);
1783 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 4420 have_ssid = 1;
1784 int padding, submit_len, ret; 4421 break;
1785 4422
1786 at76_dbg(DBG_MAC80211, "%s()", __func__); 4423 case MFIE_TYPE_RATES:
4424 if (have_rates)
4425 break;
1787 4426
1788 if (priv->tx_urb->status == -EINPROGRESS) { 4427 match->rates_len =
1789 printk(KERN_ERR "%s: %s called while tx urb is pending\n", 4428 min_t(int, sizeof(match->rates), ie->len);
1790 wiphy_name(priv->hw->wiphy), __func__); 4429 memcpy(match->rates, ie->data, match->rates_len);
1791 return NETDEV_TX_BUSY; 4430 have_rates = 1;
1792 } 4431 at76_dbg(DBG_RX_BEACON, "%s: SUPPORTED RATES %s",
4432 priv->netdev->name,
4433 hex2str(ie->data, ie->len));
4434 break;
1793 4435
1794 ieee80211_stop_queues(hw); 4436 case MFIE_TYPE_DS_SET:
4437 if (have_channel)
4438 break;
1795 4439
1796 at76_ledtrig_tx_activity(); /* tell ledtrigger we send a packet */ 4440 match->channel = ie->data[0];
4441 have_channel = 1;
4442 at76_dbg(DBG_RX_BEACON, "%s: CHANNEL - %d",
4443 priv->netdev->name, match->channel);
4444 break;
1797 4445
1798 WARN_ON(priv->tx_skb != NULL); 4446 case MFIE_TYPE_CF_SET:
4447 case MFIE_TYPE_TIM:
4448 case MFIE_TYPE_IBSS_SET:
4449 default:
4450 at76_dbg(DBG_RX_BEACON, "%s: beacon IE id %d len %d %s",
4451 priv->netdev->name, ie->id, ie->len,
4452 hex2str(ie->data, ie->len));
4453 break;
4454 }
1799 4455
1800 priv->tx_skb = skb; 4456 /* advance to the next informational element */
1801 padding = at76_calc_padding(skb->len); 4457 next_ie(&ie);
1802 submit_len = AT76_TX_HDRLEN + skb->len + padding;
1803 4458
1804 /* setup 'Atmel' header */ 4459 /* Optimization: after all, the bdata->data array is
1805 memset(tx_buffer, 0, sizeof(*tx_buffer)); 4460 * varpar_len bytes long, whereas we get all of the useful
1806 tx_buffer->padding = padding; 4461 * information after only ~36 bytes, this saves us a lot of
1807 tx_buffer->wlength = cpu_to_le16(skb->len); 4462 * time (and trouble as the remaining portion of the array
1808 tx_buffer->tx_rate = ieee80211_get_tx_rate(hw, info)->hw_value; 4463 * could be full of junk)
1809 if (FIRMWARE_IS_WPA(priv->fw_version) && info->control.hw_key) { 4464 * Comment this out if you want to see what other information
1810 tx_buffer->key_id = (info->control.hw_key->keyidx); 4465 * comes from the AP - although little of it may be useful */
1811 tx_buffer->cipher_type = 4466 }
1812 priv->keys[info->control.hw_key->keyidx].cipher;
1813 tx_buffer->cipher_length =
1814 priv->keys[info->control.hw_key->keyidx].keylen;
1815 tx_buffer->reserved = 0;
1816 } else {
1817 tx_buffer->key_id = 0;
1818 tx_buffer->cipher_type = 0;
1819 tx_buffer->cipher_length = 0;
1820 tx_buffer->reserved = 0;
1821 };
1822 /* memset(tx_buffer->reserved, 0, sizeof(tx_buffer->reserved)); */
1823 memcpy(tx_buffer->packet, skb->data, skb->len);
1824 4467
1825 at76_dbg(DBG_TX_DATA, "%s tx: wlen 0x%x pad 0x%x rate %d hdr", 4468 at76_dbg(DBG_RX_BEACON, "%s: Finished processing beacon data",
1826 wiphy_name(priv->hw->wiphy), le16_to_cpu(tx_buffer->wlength), 4469 priv->netdev->name);
1827 tx_buffer->padding, tx_buffer->tx_rate);
1828 4470
1829 /* send stuff */ 4471 match->last_rx = jiffies; /* record last rx of beacon */
1830 at76_dbg_dump(DBG_TX_DATA_CONTENT, tx_buffer, submit_len,
1831 "%s(): tx_buffer %d bytes:", __func__, submit_len);
1832 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe, tx_buffer,
1833 submit_len, at76_mac80211_tx_callback, priv);
1834 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
1835 if (ret) {
1836 printk(KERN_ERR "%s: error in tx submit urb: %d\n",
1837 wiphy_name(priv->hw->wiphy), ret);
1838 if (ret == -EINVAL)
1839 printk(KERN_ERR
1840 "%s: -EINVAL: tx urb %p hcpriv %p complete %p\n",
1841 wiphy_name(priv->hw->wiphy), priv->tx_urb,
1842 priv->tx_urb->hcpriv, priv->tx_urb->complete);
1843 }
1844 4472
1845 return 0; 4473exit:
4474 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
1846} 4475}
1847 4476
1848static int at76_mac80211_start(struct ieee80211_hw *hw) 4477/* Calculate the link level from a given rx_buffer */
4478static void at76_calc_level(struct at76_priv *priv, struct at76_rx_buffer *buf,
4479 struct iw_quality *qual)
1849{ 4480{
1850 struct at76_priv *priv = hw->priv; 4481 /* just a guess for now, might be different for other chips */
1851 int ret; 4482 int max_rssi = 42;
1852
1853 at76_dbg(DBG_MAC80211, "%s()", __func__);
1854 4483
1855 mutex_lock(&priv->mtx); 4484 qual->level = (buf->rssi * 100 / max_rssi);
1856 4485 if (qual->level > 100)
1857 ret = at76_submit_rx_urb(priv); 4486 qual->level = 100;
1858 if (ret < 0) { 4487 qual->updated |= IW_QUAL_LEVEL_UPDATED;
1859 printk(KERN_ERR "%s: open: submit_rx_urb failed: %d\n", 4488}
1860 wiphy_name(priv->hw->wiphy), ret);
1861 goto error;
1862 }
1863 4489
1864 at76_startup_device(priv); 4490/* Calculate the link quality from a given rx_buffer */
4491static void at76_calc_qual(struct at76_priv *priv, struct at76_rx_buffer *buf,
4492 struct iw_quality *qual)
4493{
4494 if (at76_is_intersil(priv->board_type))
4495 qual->qual = buf->link_quality;
4496 else {
4497 unsigned long elapsed;
1865 4498
1866 at76_start_monitor(priv); 4499 /* Update qual at most once a second */
4500 elapsed = jiffies - priv->beacons_last_qual;
4501 if (elapsed < 1 * HZ)
4502 return;
1867 4503
1868error: 4504 qual->qual = qual->level * priv->beacons_received *
1869 mutex_unlock(&priv->mtx); 4505 msecs_to_jiffies(priv->beacon_period) / elapsed;
1870 4506
1871 return 0; 4507 priv->beacons_last_qual = jiffies;
4508 priv->beacons_received = 0;
4509 }
4510 qual->qual = (qual->qual > 100) ? 100 : qual->qual;
4511 qual->updated |= IW_QUAL_QUAL_UPDATED;
1872} 4512}
1873 4513
1874static void at76_mac80211_stop(struct ieee80211_hw *hw) 4514/* Calculate the noise quality from a given rx_buffer */
4515static void at76_calc_noise(struct at76_priv *priv, struct at76_rx_buffer *buf,
4516 struct iw_quality *qual)
1875{ 4517{
1876 struct at76_priv *priv = hw->priv; 4518 qual->noise = 0;
1877 4519 qual->updated |= IW_QUAL_NOISE_INVALID;
1878 at76_dbg(DBG_MAC80211, "%s()", __func__); 4520}
1879
1880 mutex_lock(&priv->mtx);
1881 4521
1882 if (!priv->device_unplugged) { 4522static void at76_update_wstats(struct at76_priv *priv,
1883 /* We are called by "ifconfig ethX down", not because the 4523 struct at76_rx_buffer *buf)
1884 * device is not available anymore. */ 4524{
1885 if (at76_set_radio(priv, 0) == 1) 4525 struct iw_quality *qual = &priv->wstats.qual;
1886 at76_wait_completion(priv, CMD_RADIO_ON);
1887 4526
1888 /* We unlink rx_urb because at76_open() re-submits it. 4527 if (buf->rssi && priv->mac_state == MAC_CONNECTED) {
1889 * If unplugged, at76_delete_device() takes care of it. */ 4528 qual->updated = 0;
1890 usb_kill_urb(priv->rx_urb); 4529 at76_calc_level(priv, buf, qual);
4530 at76_calc_qual(priv, buf, qual);
4531 at76_calc_noise(priv, buf, qual);
4532 } else {
4533 qual->qual = 0;
4534 qual->level = 0;
4535 qual->noise = 0;
4536 qual->updated = IW_QUAL_ALL_INVALID;
1891 } 4537 }
1892
1893 mutex_unlock(&priv->mtx);
1894} 4538}
1895 4539
1896static int at76_add_interface(struct ieee80211_hw *hw, 4540static void at76_rx_mgmt(struct at76_priv *priv, struct at76_rx_buffer *buf)
1897 struct ieee80211_if_init_conf *conf)
1898{ 4541{
1899 struct at76_priv *priv = hw->priv; 4542 struct ieee80211_hdr_3addr *mgmt =
1900 int ret = 0; 4543 (struct ieee80211_hdr_3addr *)buf->packet;
4544 u16 framectl = le16_to_cpu(mgmt->frame_ctl);
4545
4546 /* update wstats */
4547 if (priv->mac_state != MAC_INIT && priv->mac_state != MAC_SCANNING) {
4548 /* jal: this is a dirty hack needed by Tim in ad-hoc mode */
4549 /* Data packets always seem to have a 0 link level, so we
4550 only read link quality info from management packets.
4551 Atmel driver actually averages the present, and previous
4552 values, we just present the raw value at the moment - TJS */
4553 if (priv->iw_mode == IW_MODE_ADHOC
4554 || (priv->curr_bss
4555 && !compare_ether_addr(mgmt->addr3,
4556 priv->curr_bss->bssid)))
4557 at76_update_wstats(priv, buf);
4558 }
1901 4559
1902 at76_dbg(DBG_MAC80211, "%s()", __func__); 4560 at76_dbg(DBG_RX_MGMT_CONTENT, "%s rx mgmt framectl 0x%x %s",
4561 priv->netdev->name, framectl,
4562 hex2str(mgmt, le16_to_cpu(buf->wlength)));
1903 4563
1904 mutex_lock(&priv->mtx); 4564 switch (framectl & IEEE80211_FCTL_STYPE) {
4565 case IEEE80211_STYPE_BEACON:
4566 case IEEE80211_STYPE_PROBE_RESP:
4567 at76_rx_mgmt_beacon(priv, buf);
4568 break;
4569
4570 case IEEE80211_STYPE_ASSOC_RESP:
4571 at76_rx_mgmt_assoc(priv, buf);
4572 break;
1905 4573
1906 switch (conf->type) { 4574 case IEEE80211_STYPE_DISASSOC:
1907 case NL80211_IFTYPE_STATION: 4575 at76_rx_mgmt_disassoc(priv, buf);
1908 priv->iw_mode = IW_MODE_INFRA;
1909 break; 4576 break;
4577
4578 case IEEE80211_STYPE_AUTH:
4579 at76_rx_mgmt_auth(priv, buf);
4580 break;
4581
4582 case IEEE80211_STYPE_DEAUTH:
4583 at76_rx_mgmt_deauth(priv, buf);
4584 break;
4585
1910 default: 4586 default:
1911 ret = -EOPNOTSUPP; 4587 printk(KERN_DEBUG "%s: ignoring frame with framectl 0x%04x\n",
1912 goto exit; 4588 priv->netdev->name, framectl);
1913 } 4589 }
1914 4590
1915exit: 4591 return;
1916 mutex_unlock(&priv->mtx);
1917
1918 return ret;
1919} 4592}
1920 4593
1921static void at76_remove_interface(struct ieee80211_hw *hw, 4594/* Convert the 802.11 header into an ethernet-style header, make skb
1922 struct ieee80211_if_init_conf *conf) 4595 * ready for consumption by netif_rx() */
4596static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode)
1923{ 4597{
1924 at76_dbg(DBG_MAC80211, "%s()", __func__); 4598 struct ieee80211_hdr_3addr *i802_11_hdr;
1925} 4599 struct ethhdr *eth_hdr_p;
4600 u8 *src_addr;
4601 u8 *dest_addr;
1926 4602
1927static int at76_join(struct at76_priv *priv) 4603 i802_11_hdr = (struct ieee80211_hdr_3addr *)skb->data;
1928{
1929 struct at76_req_join join;
1930 int ret;
1931 4604
1932 memset(&join, 0, sizeof(struct at76_req_join)); 4605 /* That would be the ethernet header if the hardware converted
1933 memcpy(join.essid, priv->essid, priv->essid_size); 4606 * the frame for us. Make sure the source and the destination
1934 join.essid_size = priv->essid_size; 4607 * match the 802.11 header. Which hardware does it? */
1935 memcpy(join.bssid, priv->bssid, ETH_ALEN); 4608 eth_hdr_p = (struct ethhdr *)skb_pull(skb, IEEE80211_3ADDR_LEN);
1936 join.bss_type = INFRASTRUCTURE_MODE;
1937 join.channel = priv->channel;
1938 join.timeout = cpu_to_le16(2000);
1939 4609
1940 at76_dbg(DBG_MAC80211, "%s: sending CMD_JOIN", __func__); 4610 dest_addr = i802_11_hdr->addr1;
1941 ret = at76_set_card_command(priv->udev, CMD_JOIN, &join, 4611 if (iw_mode == IW_MODE_ADHOC)
1942 sizeof(struct at76_req_join)); 4612 src_addr = i802_11_hdr->addr2;
4613 else
4614 src_addr = i802_11_hdr->addr3;
1943 4615
1944 if (ret < 0) { 4616 if (!compare_ether_addr(eth_hdr_p->h_source, src_addr) &&
1945 printk(KERN_ERR "%s: at76_set_card_command failed: %d\n", 4617 !compare_ether_addr(eth_hdr_p->h_dest, dest_addr))
1946 wiphy_name(priv->hw->wiphy), ret); 4618 /* Yes, we already have an ethernet header */
1947 return 0; 4619 skb_reset_mac_header(skb);
1948 } 4620 else {
4621 u16 len;
4622
4623 /* Need to build an ethernet header */
4624 if (!memcmp(skb->data, snapsig, sizeof(snapsig))) {
4625 /* SNAP frame - decapsulate, keep proto */
4626 skb_push(skb, offsetof(struct ethhdr, h_proto) -
4627 sizeof(rfc1042sig));
4628 len = 0;
4629 } else {
4630 /* 802.3 frame, proto is length */
4631 len = skb->len;
4632 skb_push(skb, ETH_HLEN);
4633 }
1949 4634
1950 ret = at76_wait_completion(priv, CMD_JOIN); 4635 skb_reset_mac_header(skb);
1951 at76_dbg(DBG_MAC80211, "%s: CMD_JOIN returned: 0x%02x", __func__, ret); 4636 eth_hdr_p = eth_hdr(skb);
1952 if (ret != CMD_STATUS_COMPLETE) { 4637 /* This needs to be done in this order (eth_hdr_p->h_dest may
1953 printk(KERN_ERR "%s: at76_wait_completion failed: %d\n", 4638 * overlap src_addr) */
1954 wiphy_name(priv->hw->wiphy), ret); 4639 memcpy(eth_hdr_p->h_source, src_addr, ETH_ALEN);
1955 return 0; 4640 memcpy(eth_hdr_p->h_dest, dest_addr, ETH_ALEN);
4641 if (len)
4642 eth_hdr_p->h_proto = htons(len);
1956 } 4643 }
1957 4644
1958 at76_set_tkip_bssid(priv, priv->bssid); 4645 skb->protocol = eth_type_trans(skb, skb->dev);
1959 at76_set_pm_mode(priv);
1960
1961 return 0;
1962} 4646}
1963 4647
1964static void at76_dwork_hw_scan(struct work_struct *work) 4648/* Check for fragmented data in priv->rx_skb. If the packet was no fragment
4649 or it was the last of a fragment set a skb containing the whole packet
4650 is returned for further processing. Otherwise we get NULL and are
4651 done and the packet is either stored inside the fragment buffer
4652 or thrown away. Every returned skb starts with the ieee802_11 header
4653 and contains _no_ FCS at the end */
4654static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
1965{ 4655{
1966 struct at76_priv *priv = container_of(work, struct at76_priv, 4656 struct sk_buff *skb = priv->rx_skb;
1967 dwork_hw_scan.work); 4657 struct at76_rx_buffer *buf = (struct at76_rx_buffer *)skb->data;
1968 int ret; 4658 struct ieee80211_hdr_3addr *i802_11_hdr =
4659 (struct ieee80211_hdr_3addr *)buf->packet;
4660 /* seq_ctrl, fragment_number, sequence number of new packet */
4661 u16 sctl = le16_to_cpu(i802_11_hdr->seq_ctl);
4662 u16 fragnr = sctl & 0xf;
4663 u16 seqnr = sctl >> 4;
4664 u16 frame_ctl = le16_to_cpu(i802_11_hdr->frame_ctl);
1969 4665
1970 ret = at76_get_cmd_status(priv->udev, CMD_SCAN); 4666 /* Length including the IEEE802.11 header, but without the trailing
1971 at76_dbg(DBG_MAC80211, "%s: CMD_SCAN status 0x%02x", __func__, ret); 4667 * FCS and without the Atmel Rx header */
4668 int length = le16_to_cpu(buf->wlength) - IEEE80211_FCS_LEN;
1972 4669
1973 /* FIXME: add maximum time for scan to complete */ 4670 /* where does the data payload start in skb->data ? */
4671 u8 *data = i802_11_hdr->payload;
1974 4672
1975 if (ret != CMD_STATUS_COMPLETE) { 4673 /* length of payload, excl. the trailing FCS */
1976 queue_delayed_work(priv->hw->workqueue, &priv->dwork_hw_scan, 4674 int data_len = length - IEEE80211_3ADDR_LEN;
1977 SCAN_POLL_INTERVAL); 4675
1978 goto exit; 4676 int i;
4677 struct rx_data_buf *bptr, *optr;
4678 unsigned long oldest = ~0UL;
4679
4680 at76_dbg(DBG_RX_FRAGS,
4681 "%s: rx data frame_ctl %04x addr2 %s seq/frag %d/%d "
4682 "length %d data %d: %s ...", priv->netdev->name, frame_ctl,
4683 mac2str(i802_11_hdr->addr2), seqnr, fragnr, length, data_len,
4684 hex2str(data, 32));
4685
4686 at76_dbg(DBG_RX_FRAGS_SKB, "%s: incoming skb: head %p data %p "
4687 "tail %p end %p len %d", priv->netdev->name, skb->head,
4688 skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
4689 skb->len);
4690
4691 if (data_len < 0) {
4692 /* make sure data starts in the buffer */
4693 printk(KERN_INFO "%s: data frame too short\n",
4694 priv->netdev->name);
4695 return NULL;
1979 } 4696 }
1980 4697
1981 ieee80211_scan_completed(priv->hw); 4698 WARN_ON(length <= AT76_RX_HDRLEN);
4699 if (length <= AT76_RX_HDRLEN)
4700 return NULL;
1982 4701
1983 if (is_valid_ether_addr(priv->bssid)) { 4702 /* remove the at76_rx_buffer header - we don't need it anymore */
1984 ieee80211_wake_queues(priv->hw); 4703 /* we need the IEEE802.11 header (for the addresses) if this packet
1985 at76_join(priv); 4704 is the first of a chain */
4705 skb_pull(skb, AT76_RX_HDRLEN);
4706
4707 /* remove FCS at end */
4708 skb_trim(skb, length);
4709
4710 at76_dbg(DBG_RX_FRAGS_SKB, "%s: trimmed skb: head %p data %p tail %p "
4711 "end %p len %d data %p data_len %d", priv->netdev->name,
4712 skb->head, skb->data, skb_tail_pointer(skb),
4713 skb_end_pointer(skb), skb->len, data, data_len);
4714
4715 if (fragnr == 0 && !(frame_ctl & IEEE80211_FCTL_MOREFRAGS)) {
4716 /* unfragmented packet received */
4717 /* Use a new skb for the next receive */
4718 priv->rx_skb = NULL;
4719 at76_dbg(DBG_RX_FRAGS, "%s: unfragmented", priv->netdev->name);
4720 return skb;
1986 } 4721 }
1987 4722
1988 ieee80211_wake_queues(priv->hw); 4723 /* look if we've got a chain for the sender address.
4724 afterwards optr points to first free or the oldest entry,
4725 or, if i < NR_RX_DATA_BUF, bptr points to the entry for the
4726 sender address */
4727 /* determining the oldest entry doesn't cope with jiffies wrapping
4728 but I don't care to delete a young entry at these rare moments ... */
4729
4730 bptr = priv->rx_data;
4731 optr = NULL;
4732 for (i = 0; i < NR_RX_DATA_BUF; i++, bptr++) {
4733 if (!bptr->skb) {
4734 optr = bptr;
4735 oldest = 0UL;
4736 continue;
4737 }
1989 4738
1990exit: 4739 if (!compare_ether_addr(i802_11_hdr->addr2, bptr->sender))
1991 return; 4740 break;
1992}
1993 4741
1994static int at76_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) 4742 if (!optr) {
1995{ 4743 optr = bptr;
1996 struct at76_priv *priv = hw->priv; 4744 oldest = bptr->last_rx;
1997 struct at76_req_scan scan; 4745 } else if (bptr->last_rx < oldest)
1998 int ret; 4746 optr = bptr;
4747 }
1999 4748
2000 at76_dbg(DBG_MAC80211, "%s():", __func__); 4749 if (i < NR_RX_DATA_BUF) {
2001 at76_dbg_dump(DBG_MAC80211, ssid, len, "ssid %zd bytes:", len); 4750
4751 at76_dbg(DBG_RX_FRAGS, "%s: %d. cacheentry (seq/frag = %d/%d) "
4752 "matched sender addr",
4753 priv->netdev->name, i, bptr->seqnr, bptr->fragnr);
4754
4755 /* bptr points to an entry for the sender address */
4756 if (bptr->seqnr == seqnr) {
4757 int left;
4758 /* the fragment has the current sequence number */
4759 if (((bptr->fragnr + 1) & 0xf) != fragnr) {
4760 /* wrong fragment number -> ignore it */
4761 /* is & 0xf necessary above ??? */
4762 at76_dbg(DBG_RX_FRAGS,
4763 "%s: frag nr mismatch: %d + 1 != %d",
4764 priv->netdev->name, bptr->fragnr,
4765 fragnr);
4766 return NULL;
4767 }
4768 bptr->last_rx = jiffies;
4769 /* the next following fragment number ->
4770 add the data at the end */
4771
4772 /* for test only ??? */
4773 left = skb_tailroom(bptr->skb);
4774 if (left < data_len)
4775 printk(KERN_INFO
4776 "%s: only %d byte free (need %d)\n",
4777 priv->netdev->name, left, data_len);
4778 else
4779 memcpy(skb_put(bptr->skb, data_len), data,
4780 data_len);
4781
4782 bptr->fragnr = fragnr;
4783 if (frame_ctl & IEEE80211_FCTL_MOREFRAGS)
4784 return NULL;
4785
4786 /* this was the last fragment - send it */
4787 skb = bptr->skb;
4788 bptr->skb = NULL; /* free the entry */
4789 at76_dbg(DBG_RX_FRAGS, "%s: last frag of seq %d",
4790 priv->netdev->name, seqnr);
4791 return skb;
4792 }
2002 4793
2003 mutex_lock(&priv->mtx); 4794 /* got another sequence number */
4795 if (fragnr == 0) {
4796 /* it's the start of a new chain - replace the
4797 old one by this */
4798 /* bptr->sender has the correct value already */
4799 at76_dbg(DBG_RX_FRAGS,
4800 "%s: start of new seq %d, removing old seq %d",
4801 priv->netdev->name, seqnr, bptr->seqnr);
4802 bptr->seqnr = seqnr;
4803 bptr->fragnr = 0;
4804 bptr->last_rx = jiffies;
4805 /* swap bptr->skb and priv->rx_skb */
4806 skb = bptr->skb;
4807 bptr->skb = priv->rx_skb;
4808 priv->rx_skb = skb;
4809 } else {
4810 /* it from the middle of a new chain ->
4811 delete the old entry and skip the new one */
4812 at76_dbg(DBG_RX_FRAGS,
4813 "%s: middle of new seq %d (%d) "
4814 "removing old seq %d",
4815 priv->netdev->name, seqnr, fragnr,
4816 bptr->seqnr);
4817 dev_kfree_skb(bptr->skb);
4818 bptr->skb = NULL;
4819 }
4820 return NULL;
4821 }
2004 4822
2005 ieee80211_stop_queues(hw); 4823 /* if we didn't find a chain for the sender address, optr
4824 points either to the first free or the oldest entry */
2006 4825
2007 memset(&scan, 0, sizeof(struct at76_req_scan)); 4826 if (fragnr != 0) {
2008 memset(scan.bssid, 0xFF, ETH_ALEN); 4827 /* this is not the begin of a fragment chain ... */
2009 scan.scan_type = SCAN_TYPE_ACTIVE; 4828 at76_dbg(DBG_RX_FRAGS,
2010 if (priv->essid_size > 0) { 4829 "%s: no chain for non-first fragment (%d)",
2011 memcpy(scan.essid, ssid, len); 4830 priv->netdev->name, fragnr);
2012 scan.essid_size = len; 4831 return NULL;
2013 } 4832 }
2014 scan.min_channel_time = cpu_to_le16(priv->scan_min_time);
2015 scan.max_channel_time = cpu_to_le16(priv->scan_max_time);
2016 scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000);
2017 scan.international_scan = 0;
2018 4833
2019 at76_dbg(DBG_MAC80211, "%s: sending CMD_SCAN", __func__); 4834 BUG_ON(!optr);
2020 ret = at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan)); 4835 if (optr->skb) {
4836 /* swap the skb's */
4837 skb = optr->skb;
4838 optr->skb = priv->rx_skb;
4839 priv->rx_skb = skb;
2021 4840
2022 if (ret < 0) { 4841 at76_dbg(DBG_RX_FRAGS,
2023 err("CMD_SCAN failed: %d", ret); 4842 "%s: free old contents: sender %s seq/frag %d/%d",
2024 goto exit; 4843 priv->netdev->name, mac2str(optr->sender),
2025 } 4844 optr->seqnr, optr->fragnr);
2026 4845
2027 queue_delayed_work(priv->hw->workqueue, &priv->dwork_hw_scan, 4846 } else {
2028 SCAN_POLL_INTERVAL); 4847 /* take the skb from priv->rx_skb */
4848 optr->skb = priv->rx_skb;
4849 /* let at76_submit_rx_urb() allocate a new skb */
4850 priv->rx_skb = NULL;
2029 4851
2030exit: 4852 at76_dbg(DBG_RX_FRAGS, "%s: use a free entry",
2031 mutex_unlock(&priv->mtx); 4853 priv->netdev->name);
4854 }
4855 memcpy(optr->sender, i802_11_hdr->addr2, ETH_ALEN);
4856 optr->seqnr = seqnr;
4857 optr->fragnr = 0;
4858 optr->last_rx = jiffies;
2032 4859
2033 return 0; 4860 return NULL;
2034} 4861}
2035 4862
2036static int at76_config(struct ieee80211_hw *hw, u32 changed) 4863/* Rx interrupt: we expect the complete data buffer in priv->rx_skb */
4864static void at76_rx_data(struct at76_priv *priv)
2037{ 4865{
2038 struct at76_priv *priv = hw->priv; 4866 struct net_device *netdev = priv->netdev;
2039 struct ieee80211_conf *conf = &hw->conf; 4867 struct net_device_stats *stats = &priv->stats;
4868 struct sk_buff *skb = priv->rx_skb;
4869 struct at76_rx_buffer *buf = (struct at76_rx_buffer *)skb->data;
4870 struct ieee80211_hdr_3addr *i802_11_hdr;
4871 int length = le16_to_cpu(buf->wlength);
2040 4872
2041 at76_dbg(DBG_MAC80211, "%s(): channel %d radio %d", 4873 at76_dbg(DBG_RX_DATA, "%s received data packet: %s", netdev->name,
2042 __func__, conf->channel->hw_value, conf->radio_enabled); 4874 hex2str(skb->data, AT76_RX_HDRLEN));
2043 at76_dbg_dump(DBG_MAC80211, priv->essid, priv->essid_size, "ssid:");
2044 at76_dbg_dump(DBG_MAC80211, priv->bssid, ETH_ALEN, "bssid:");
2045 4875
2046 mutex_lock(&priv->mtx); 4876 at76_dbg(DBG_RX_DATA_CONTENT, "rx packet: %s",
4877 hex2str(skb->data + AT76_RX_HDRLEN, length));
2047 4878
2048 priv->channel = conf->channel->hw_value; 4879 skb = at76_check_for_rx_frags(priv);
4880 if (!skb)
4881 return;
2049 4882
2050 if (is_valid_ether_addr(priv->bssid)) { 4883 /* Atmel header and the FCS are already removed */
2051 at76_join(priv); 4884 i802_11_hdr = (struct ieee80211_hdr_3addr *)skb->data;
2052 ieee80211_wake_queues(priv->hw);
2053 } else {
2054 ieee80211_stop_queues(priv->hw);
2055 at76_start_monitor(priv);
2056 };
2057 4885
2058 mutex_unlock(&priv->mtx); 4886 skb->dev = netdev;
4887 skb->ip_summed = CHECKSUM_NONE; /* TODO: should check CRC */
2059 4888
2060 return 0; 4889 if (is_broadcast_ether_addr(i802_11_hdr->addr1)) {
2061} 4890 if (!compare_ether_addr(i802_11_hdr->addr1, netdev->broadcast))
4891 skb->pkt_type = PACKET_BROADCAST;
4892 else
4893 skb->pkt_type = PACKET_MULTICAST;
4894 } else if (compare_ether_addr(i802_11_hdr->addr1, netdev->dev_addr))
4895 skb->pkt_type = PACKET_OTHERHOST;
2062 4896
2063static int at76_config_interface(struct ieee80211_hw *hw, 4897 at76_ieee80211_to_eth(skb, priv->iw_mode);
2064 struct ieee80211_vif *vif,
2065 struct ieee80211_if_conf *conf)
2066{
2067 struct at76_priv *priv = hw->priv;
2068 4898
2069 at76_dbg_dump(DBG_MAC80211, conf->bssid, ETH_ALEN, "bssid:"); 4899 netdev->last_rx = jiffies;
4900 netif_rx(skb);
4901 stats->rx_packets++;
4902 stats->rx_bytes += length;
2070 4903
2071 mutex_lock(&priv->mtx); 4904 return;
4905}
2072 4906
2073 memcpy(priv->bssid, conf->bssid, ETH_ALEN); 4907static void at76_rx_monitor_mode(struct at76_priv *priv)
2074// memcpy(priv->essid, conf->ssid, conf->ssid_len); 4908{
2075// priv->essid_size = conf->ssid_len; 4909 struct at76_rx_radiotap *rt;
4910 u8 *payload;
4911 int skblen;
4912 struct net_device *netdev = priv->netdev;
4913 struct at76_rx_buffer *buf =
4914 (struct at76_rx_buffer *)priv->rx_skb->data;
4915 /* length including the IEEE802.11 header and the trailing FCS,
4916 but not at76_rx_buffer */
4917 int length = le16_to_cpu(buf->wlength);
4918 struct sk_buff *skb = priv->rx_skb;
4919 struct net_device_stats *stats = &priv->stats;
2076 4920
2077 if (is_valid_ether_addr(priv->bssid)) { 4921 if (length < IEEE80211_FCS_LEN) {
2078 /* mac80211 is joining a bss */ 4922 /* buffer contains no data */
2079 ieee80211_wake_queues(priv->hw); 4923 at76_dbg(DBG_MONITOR_MODE,
2080 at76_join(priv); 4924 "%s: MONITOR MODE: rx skb without data",
2081 } else 4925 priv->netdev->name);
2082 ieee80211_stop_queues(priv->hw); 4926 return;
4927 }
2083 4928
2084 mutex_unlock(&priv->mtx); 4929 skblen = sizeof(struct at76_rx_radiotap) + length;
2085 4930
2086 return 0; 4931 skb = dev_alloc_skb(skblen);
4932 if (!skb) {
4933 printk(KERN_ERR "%s: MONITOR MODE: dev_alloc_skb for radiotap "
4934 "header returned NULL\n", priv->netdev->name);
4935 return;
4936 }
4937
4938 skb_put(skb, skblen);
4939
4940 rt = (struct at76_rx_radiotap *)skb->data;
4941 payload = skb->data + sizeof(struct at76_rx_radiotap);
4942
4943 rt->rt_hdr.it_version = 0;
4944 rt->rt_hdr.it_pad = 0;
4945 rt->rt_hdr.it_len = cpu_to_le16(sizeof(struct at76_rx_radiotap));
4946 rt->rt_hdr.it_present = cpu_to_le32(AT76_RX_RADIOTAP_PRESENT);
4947
4948 rt->rt_tsft = cpu_to_le64(le32_to_cpu(buf->rx_time));
4949 rt->rt_rate = hw_rates[buf->rx_rate] & (~0x80);
4950 rt->rt_signal = buf->rssi;
4951 rt->rt_noise = buf->noise_level;
4952 rt->rt_flags = IEEE80211_RADIOTAP_F_FCS;
4953 if (buf->fragmentation)
4954 rt->rt_flags |= IEEE80211_RADIOTAP_F_FRAG;
4955
4956 memcpy(payload, buf->packet, length);
4957 skb->dev = netdev;
4958 skb->ip_summed = CHECKSUM_NONE;
4959 skb_reset_mac_header(skb);
4960 skb->pkt_type = PACKET_OTHERHOST;
4961 skb->protocol = htons(ETH_P_802_2);
4962
4963 netdev->last_rx = jiffies;
4964 netif_rx(skb);
4965 stats->rx_packets++;
4966 stats->rx_bytes += length;
2087} 4967}
2088 4968
2089/* must be atomic */ 4969/* Check if we spy on the sender address in buf and update stats */
2090static void at76_configure_filter(struct ieee80211_hw *hw, 4970static void at76_iwspy_update(struct at76_priv *priv,
2091 unsigned int changed_flags, 4971 struct at76_rx_buffer *buf)
2092 unsigned int *total_flags, int mc_count,
2093 struct dev_addr_list *mc_list)
2094{ 4972{
2095 struct at76_priv *priv = hw->priv; 4973 struct ieee80211_hdr_3addr *hdr =
2096 int flags; 4974 (struct ieee80211_hdr_3addr *)buf->packet;
2097 4975 struct iw_quality qual;
2098 at76_dbg(DBG_MAC80211, "%s(): changed_flags=0x%08x "
2099 "total_flags=0x%08x mc_count=%d",
2100 __func__, changed_flags, *total_flags, mc_count);
2101 4976
2102 flags = changed_flags & AT76_SUPPORTED_FILTERS; 4977 /* We can only set the level here */
2103 *total_flags = AT76_SUPPORTED_FILTERS; 4978 qual.updated = IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID;
4979 qual.level = 0;
4980 qual.noise = 0;
4981 at76_calc_level(priv, buf, &qual);
2104 4982
2105 /* FIXME: access to priv->promisc should be protected with 4983 spin_lock_bh(&priv->spy_spinlock);
2106 * priv->mtx, but it's impossible because this function needs to be
2107 * atomic */
2108 4984
2109 if (flags && !priv->promisc) { 4985 if (priv->spy_data.spy_number > 0)
2110 /* mac80211 wants us to enable promiscuous mode */ 4986 wireless_spy_update(priv->netdev, hdr->addr2, &qual);
2111 priv->promisc = 1;
2112 } else if (!flags && priv->promisc) {
2113 /* we need to disable promiscuous mode */
2114 priv->promisc = 0;
2115 } else
2116 return;
2117 4987
2118 queue_work(hw->workqueue, &priv->work_set_promisc); 4988 spin_unlock_bh(&priv->spy_spinlock);
2119} 4989}
2120 4990
2121static int at76_set_key_oldfw(struct ieee80211_hw *hw, enum set_key_cmd cmd, 4991static void at76_rx_tasklet(unsigned long param)
2122 const u8 *local_address, const u8 *address,
2123 struct ieee80211_key_conf *key)
2124{ 4992{
2125 struct at76_priv *priv = hw->priv; 4993 struct urb *urb = (struct urb *)param;
2126 4994 struct at76_priv *priv = urb->context;
2127 int i; 4995 struct net_device *netdev = priv->netdev;
2128 4996 struct at76_rx_buffer *buf;
2129 at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d " 4997 struct ieee80211_hdr_3addr *i802_11_hdr;
2130 "key->keylen %d", 4998 u16 frame_ctl;
2131 __func__, cmd, key->alg, key->keyidx, key->keylen);
2132 4999
2133 if (key->alg != ALG_WEP) 5000 if (priv->device_unplugged) {
2134 return -EOPNOTSUPP; 5001 at76_dbg(DBG_DEVSTART, "device unplugged");
5002 if (urb)
5003 at76_dbg(DBG_DEVSTART, "urb status %d", urb->status);
5004 return;
5005 }
2135 5006
2136 key->hw_key_idx = key->keyidx; 5007 if (!priv->rx_skb || !netdev || !priv->rx_skb->data)
5008 return;
2137 5009
2138 mutex_lock(&priv->mtx); 5010 buf = (struct at76_rx_buffer *)priv->rx_skb->data;
2139 5011
2140 switch (cmd) { 5012 i802_11_hdr = (struct ieee80211_hdr_3addr *)buf->packet;
2141 case SET_KEY:
2142 memcpy(priv->wep_keys[key->keyidx], key->key, key->keylen);
2143 priv->wep_keys_len[key->keyidx] = key->keylen;
2144 5013
2145 /* FIXME: find out how to do this properly */ 5014 frame_ctl = le16_to_cpu(i802_11_hdr->frame_ctl);
2146 priv->wep_key_id = key->keyidx;
2147 5015
2148 break; 5016 if (urb->status != 0) {
2149 case DISABLE_KEY: 5017 if (urb->status != -ENOENT && urb->status != -ECONNRESET)
2150 default: 5018 at76_dbg(DBG_URB,
2151 priv->wep_keys_len[key->keyidx] = 0; 5019 "%s %s: - nonzero Rx bulk status received: %d",
2152 break; 5020 __func__, netdev->name, urb->status);
5021 return;
2153 } 5022 }
2154 5023
2155 priv->wep_enabled = 0; 5024 at76_dbg(DBG_RX_ATMEL_HDR,
5025 "%s: rx frame: rate %d rssi %d noise %d link %d %s",
5026 priv->netdev->name, buf->rx_rate, buf->rssi, buf->noise_level,
5027 buf->link_quality, hex2str(i802_11_hdr, 48));
5028 if (priv->iw_mode == IW_MODE_MONITOR) {
5029 at76_rx_monitor_mode(priv);
5030 goto exit;
5031 }
2156 5032
2157 for (i = 0; i < WEP_KEYS; i++) { 5033 /* there is a new bssid around, accept it: */
2158 if (priv->wep_keys_len[i] != 0) 5034 if (buf->newbss && priv->iw_mode == IW_MODE_ADHOC) {
2159 priv->wep_enabled = 1; 5035 at76_dbg(DBG_PROGRESS, "%s: rx newbss", netdev->name);
5036 schedule_work(&priv->work_new_bss);
2160 } 5037 }
2161 5038
2162 at76_startup_device(priv); 5039 switch (frame_ctl & IEEE80211_FCTL_FTYPE) {
5040 case IEEE80211_FTYPE_DATA:
5041 at76_rx_data(priv);
5042 break;
2163 5043
2164 mutex_unlock(&priv->mtx); 5044 case IEEE80211_FTYPE_MGMT:
5045 /* jal: TODO: find out if we can update iwspy also on
5046 other frames than management (might depend on the
5047 radio chip / firmware version !) */
2165 5048
2166 return 0; 5049 at76_iwspy_update(priv, buf);
2167}
2168 5050
2169static int at76_set_key_newfw(struct ieee80211_hw *hw, enum set_key_cmd cmd, 5051 at76_rx_mgmt(priv, buf);
2170 const u8 *local_address, const u8 *address, 5052 break;
2171 struct ieee80211_key_conf *key)
2172{
2173 struct at76_priv *priv = hw->priv;
2174 int ret = -EOPNOTSUPP;
2175
2176 at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d "
2177 "key->keylen %d",
2178 __func__, cmd, key->alg, key->keyidx, key->keylen);
2179 5053
2180 mutex_lock(&priv->mtx); 5054 case IEEE80211_FTYPE_CTL:
5055 at76_dbg(DBG_RX_CTRL, "%s: ignored ctrl frame: %04x",
5056 priv->netdev->name, frame_ctl);
5057 break;
2181 5058
2182 priv->mib_buf.type = MIB_MAC_ENCRYPTION; 5059 default:
5060 printk(KERN_DEBUG "%s: ignoring frame with framectl 0x%04x\n",
5061 priv->netdev->name, frame_ctl);
5062 }
5063exit:
5064 at76_submit_rx_urb(priv);
5065}
2183 5066
2184 if (cmd == DISABLE_KEY) { 5067/* Load firmware into kernel memory and parse it */
2185 priv->mib_buf.size = CIPHER_KEY_LEN; 5068static struct fwentry *at76_load_firmware(struct usb_device *udev,
2186 priv->mib_buf.index = offsetof(struct mib_mac_encryption, 5069 enum board_type board_type)
2187 cipher_default_keyvalue[key->keyidx]); 5070{
2188 memset(priv->mib_buf.data.data, 0, CIPHER_KEY_LEN); 5071 int ret;
2189 if (at76_set_mib(priv, &priv->mib_buf) != CMD_STATUS_COMPLETE) 5072 char *str;
2190 ret = -EOPNOTSUPP; /* -EIO would be probably better */ 5073 struct at76_fw_header *fwh;
2191 else { 5074 struct fwentry *fwe = &firmwares[board_type];
2192 5075
2193 priv->keys[key->keyidx].cipher = CIPHER_NONE; 5076 mutex_lock(&fw_mutex);
2194 priv->keys[key->keyidx].keylen = 0;
2195 };
2196 if (priv->default_group_key == key->keyidx)
2197 priv->default_group_key = 0xff;
2198 5077
2199 if (priv->default_pairwise_key == key->keyidx) 5078 if (fwe->loaded) {
2200 priv->default_pairwise_key = 0xff; 5079 at76_dbg(DBG_FW, "re-using previously loaded fw");
2201 /* If default pairwise key is removed, fall back to
2202 * group key? */
2203 ret = 0;
2204 goto exit; 5080 goto exit;
2205 }; 5081 }
2206
2207 if (cmd == SET_KEY) {
2208 /* store key into MIB */
2209 priv->mib_buf.size = CIPHER_KEY_LEN;
2210 priv->mib_buf.index = offsetof(struct mib_mac_encryption,
2211 cipher_default_keyvalue[key->keyidx]);
2212 memset(priv->mib_buf.data.data, 0, CIPHER_KEY_LEN);
2213 memcpy(priv->mib_buf.data.data, key->key, key->keylen);
2214
2215 switch (key->alg) {
2216 case ALG_WEP:
2217 if (key->keylen == 5) {
2218 priv->keys[key->keyidx].cipher =
2219 CIPHER_WEP64;
2220 priv->keys[key->keyidx].keylen = 8;
2221 } else if (key->keylen == 13) {
2222 priv->keys[key->keyidx].cipher =
2223 CIPHER_WEP128;
2224 /* Firmware needs this */
2225 priv->keys[key->keyidx].keylen = 8;
2226 } else {
2227 ret = -EOPNOTSUPP;
2228 goto exit;
2229 };
2230 break;
2231 case ALG_TKIP:
2232 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
2233 priv->keys[key->keyidx].cipher = CIPHER_TKIP;
2234 priv->keys[key->keyidx].keylen = 12;
2235 break;
2236 5082
2237 case ALG_CCMP: 5083 at76_dbg(DBG_FW, "downloading firmware %s", fwe->fwname);
2238 if (!at76_is_505a(priv->board_type)) { 5084 ret = request_firmware(&fwe->fw, fwe->fwname, &udev->dev);
2239 ret = -EOPNOTSUPP; 5085 if (ret < 0) {
2240 goto exit; 5086 dev_printk(KERN_ERR, &udev->dev, "firmware %s not found!\n",
2241 }; 5087 fwe->fwname);
2242 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; 5088 dev_printk(KERN_ERR, &udev->dev,
2243 priv->keys[key->keyidx].cipher = CIPHER_CCMP; 5089 "you may need to download the firmware from "
2244 priv->keys[key->keyidx].keylen = 16; 5090 "http://developer.berlios.de/projects/at76c503a/");
2245 break; 5091 goto exit;
5092 }
2246 5093
2247 default: 5094 at76_dbg(DBG_FW, "got it.");
2248 ret = -EOPNOTSUPP; 5095 fwh = (struct at76_fw_header *)(fwe->fw->data);
2249 goto exit;
2250 };
2251
2252 priv->mib_buf.data.data[38] = priv->keys[key->keyidx].cipher;
2253 priv->mib_buf.data.data[39] = 1; /* Taken from atmelwlandriver,
2254 not documented */
2255
2256 if (is_valid_ether_addr(address))
2257 /* Pairwise key */
2258 priv->mib_buf.data.data[39] |= (KEY_PAIRWISE | KEY_TX);
2259 else if (is_broadcast_ether_addr(address))
2260 /* Group key */
2261 priv->mib_buf.data.data[39] |= (KEY_TX);
2262 else /* Key used only for transmission ??? */
2263 priv->mib_buf.data.data[39] |= (KEY_TX);
2264
2265 if (at76_set_mib(priv, &priv->mib_buf) !=
2266 CMD_STATUS_COMPLETE) {
2267 ret = -EOPNOTSUPP; /* -EIO would be probably better */
2268 goto exit;
2269 };
2270 5096
2271 if ((key->alg == ALG_TKIP) || (key->alg == ALG_CCMP)) 5097 if (fwe->fw->size <= sizeof(*fwh)) {
2272 at76_reset_rsc(priv); 5098 dev_printk(KERN_ERR, &udev->dev,
5099 "firmware is too short (0x%zx)\n", fwe->fw->size);
5100 goto exit;
5101 }
2273 5102
2274 key->hw_key_idx = key->keyidx; 5103 /* CRC currently not checked */
5104 fwe->board_type = le32_to_cpu(fwh->board_type);
5105 if (fwe->board_type != board_type) {
5106 dev_printk(KERN_ERR, &udev->dev,
5107 "board type mismatch, requested %u, got %u\n",
5108 board_type, fwe->board_type);
5109 goto exit;
5110 }
2275 5111
2276 /* Set up default keys */ 5112 fwe->fw_version.major = fwh->major;
2277 if (is_broadcast_ether_addr(address)) 5113 fwe->fw_version.minor = fwh->minor;
2278 priv->default_group_key = key->keyidx; 5114 fwe->fw_version.patch = fwh->patch;
2279 if (is_valid_ether_addr(address)) 5115 fwe->fw_version.build = fwh->build;
2280 priv->default_pairwise_key = key->keyidx;
2281 5116
2282 /* Set up encryption MIBs */ 5117 str = (char *)fwh + le32_to_cpu(fwh->str_offset);
5118 fwe->intfw = (u8 *)fwh + le32_to_cpu(fwh->int_fw_offset);
5119 fwe->intfw_size = le32_to_cpu(fwh->int_fw_len);
5120 fwe->extfw = (u8 *)fwh + le32_to_cpu(fwh->ext_fw_offset);
5121 fwe->extfw_size = le32_to_cpu(fwh->ext_fw_len);
2283 5122
2284 /* first block of settings */ 5123 fwe->loaded = 1;
2285 priv->mib_buf.size = 3;
2286 priv->mib_buf.index = offsetof(struct mib_mac_encryption,
2287 privacy_invoked);
2288 priv->mib_buf.data.data[0] = 1; /* privacy_invoked */
2289 priv->mib_buf.data.data[1] = priv->default_pairwise_key;
2290 priv->mib_buf.data.data[2] = priv->default_group_key;
2291 5124
2292 ret = at76_set_mib(priv, &priv->mib_buf); 5125 dev_printk(KERN_DEBUG, &udev->dev,
2293 if (ret != CMD_STATUS_COMPLETE) 5126 "using firmware %s (version %d.%d.%d-%d)\n",
2294 goto exit; 5127 fwe->fwname, fwh->major, fwh->minor, fwh->patch, fwh->build);
2295 5128
2296 /* second block of settings */ 5129 at76_dbg(DBG_DEVSTART, "board %u, int %d:%d, ext %d:%d", board_type,
2297 priv->mib_buf.size = 3; 5130 le32_to_cpu(fwh->int_fw_offset), le32_to_cpu(fwh->int_fw_len),
2298 priv->mib_buf.index = offsetof(struct mib_mac_encryption, 5131 le32_to_cpu(fwh->ext_fw_offset), le32_to_cpu(fwh->ext_fw_len));
2299 exclude_unencrypted); 5132 at76_dbg(DBG_DEVSTART, "firmware id %s", str);
2300 priv->mib_buf.data.data[0] = 1; /* exclude_unencrypted */
2301 priv->mib_buf.data.data[1] = 0; /* wep_encryption_type */
2302 priv->mib_buf.data.data[2] = 0; /* ckip_key_permutation */
2303 5133
2304 ret = at76_set_mib(priv, &priv->mib_buf);
2305 if (ret != CMD_STATUS_COMPLETE)
2306 goto exit;
2307 ret = 0;
2308 };
2309exit: 5134exit:
2310 at76_dump_mib_mac_encryption(priv); 5135 mutex_unlock(&fw_mutex);
2311 mutex_unlock(&priv->mtx);
2312 return ret;
2313}
2314
2315static int at76_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2316 const u8 *local_address, const u8 *address,
2317 struct ieee80211_key_conf *key)
2318{
2319 struct at76_priv *priv = hw->priv;
2320
2321 at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d "
2322 "key->keylen %d",
2323 __func__, cmd, key->alg, key->keyidx, key->keylen);
2324 5136
2325 if (FIRMWARE_IS_WPA(priv->fw_version)) 5137 if (fwe->loaded)
2326 return at76_set_key_newfw(hw, cmd, local_address, address, key); 5138 return fwe;
2327 else 5139 else
2328 return at76_set_key_oldfw(hw, cmd, local_address, address, key); 5140 return NULL;
2329
2330} 5141}
2331 5142
2332static const struct ieee80211_ops at76_ops = {
2333 .tx = at76_mac80211_tx,
2334 .add_interface = at76_add_interface,
2335 .remove_interface = at76_remove_interface,
2336 .config = at76_config,
2337 .config_interface = at76_config_interface,
2338 .configure_filter = at76_configure_filter,
2339 .start = at76_mac80211_start,
2340 .stop = at76_mac80211_stop,
2341 .hw_scan = at76_hw_scan,
2342 .set_key = at76_set_key,
2343};
2344
2345/* Allocate network device and initialize private data */ 5143/* Allocate network device and initialize private data */
2346static struct at76_priv *at76_alloc_new_device(struct usb_device *udev) 5144static struct at76_priv *at76_alloc_new_device(struct usb_device *udev)
2347{ 5145{
2348 struct ieee80211_hw *hw; 5146 struct net_device *netdev;
2349 struct at76_priv *priv; 5147 struct at76_priv *priv;
5148 int i;
2350 5149
2351 hw = ieee80211_alloc_hw(sizeof(struct at76_priv), &at76_ops); 5150 /* allocate memory for our device state and initialize it */
2352 if (!hw) { 5151 netdev = alloc_etherdev(sizeof(struct at76_priv));
2353 printk(KERN_ERR DRIVER_NAME ": could not register" 5152 if (!netdev) {
2354 " ieee80211_hw\n"); 5153 dev_printk(KERN_ERR, &udev->dev, "out of memory\n");
2355 return NULL; 5154 return NULL;
2356 } 5155 }
2357 5156
2358 priv = hw->priv; 5157 priv = netdev_priv(netdev);
2359 priv->hw = hw;
2360 5158
2361 priv->udev = udev; 5159 priv->udev = udev;
5160 priv->netdev = netdev;
2362 5161
2363 mutex_init(&priv->mtx); 5162 mutex_init(&priv->mtx);
5163 INIT_WORK(&priv->work_assoc_done, at76_work_assoc_done);
5164 INIT_WORK(&priv->work_join, at76_work_join);
5165 INIT_WORK(&priv->work_new_bss, at76_work_new_bss);
5166 INIT_WORK(&priv->work_start_scan, at76_work_start_scan);
2364 INIT_WORK(&priv->work_set_promisc, at76_work_set_promisc); 5167 INIT_WORK(&priv->work_set_promisc, at76_work_set_promisc);
2365 INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx); 5168 INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx);
2366 INIT_DELAYED_WORK(&priv->dwork_hw_scan, at76_dwork_hw_scan); 5169 INIT_DELAYED_WORK(&priv->dwork_restart, at76_dwork_restart);
5170 INIT_DELAYED_WORK(&priv->dwork_get_scan, at76_dwork_get_scan);
5171 INIT_DELAYED_WORK(&priv->dwork_beacon, at76_dwork_beacon);
5172 INIT_DELAYED_WORK(&priv->dwork_auth, at76_dwork_auth);
5173 INIT_DELAYED_WORK(&priv->dwork_assoc, at76_dwork_assoc);
5174
5175 spin_lock_init(&priv->mgmt_spinlock);
5176 priv->next_mgmt_bulk = NULL;
5177 priv->mac_state = MAC_INIT;
5178
5179 /* initialize empty BSS list */
5180 priv->curr_bss = NULL;
5181 INIT_LIST_HEAD(&priv->bss_list);
5182 spin_lock_init(&priv->bss_list_spinlock);
5183
5184 init_timer(&priv->bss_list_timer);
5185 priv->bss_list_timer.data = (unsigned long)priv;
5186 priv->bss_list_timer.function = at76_bss_list_timeout;
5187
5188 spin_lock_init(&priv->spy_spinlock);
5189
5190 /* mark all rx data entries as unused */
5191 for (i = 0; i < NR_RX_DATA_BUF; i++)
5192 priv->rx_data[i].skb = NULL;
2367 5193
2368 priv->rx_tasklet.func = at76_rx_tasklet; 5194 priv->rx_tasklet.func = at76_rx_tasklet;
2369 priv->rx_tasklet.data = 0; 5195 priv->rx_tasklet.data = 0;
@@ -2371,9 +5197,6 @@ static struct at76_priv *at76_alloc_new_device(struct usb_device *udev)
2371 priv->pm_mode = AT76_PM_OFF; 5197 priv->pm_mode = AT76_PM_OFF;
2372 priv->pm_period = 0; 5198 priv->pm_period = 0;
2373 5199
2374 /* unit us */
2375 priv->hw->channel_change_time = 100000;
2376
2377 return priv; 5200 return priv;
2378} 5201}
2379 5202
@@ -2436,42 +5259,11 @@ static int at76_alloc_urbs(struct at76_priv *priv,
2436 return 0; 5259 return 0;
2437} 5260}
2438 5261
2439static struct ieee80211_rate at76_rates[] = {
2440 { .bitrate = 10, .hw_value = TX_RATE_1MBIT, },
2441 { .bitrate = 20, .hw_value = TX_RATE_2MBIT, },
2442 { .bitrate = 55, .hw_value = TX_RATE_5_5MBIT, },
2443 { .bitrate = 110, .hw_value = TX_RATE_11MBIT, },
2444};
2445
2446static struct ieee80211_channel at76_channels[] = {
2447 { .center_freq = 2412, .hw_value = 1 },
2448 { .center_freq = 2417, .hw_value = 2 },
2449 { .center_freq = 2422, .hw_value = 3 },
2450 { .center_freq = 2427, .hw_value = 4 },
2451 { .center_freq = 2432, .hw_value = 5 },
2452 { .center_freq = 2437, .hw_value = 6 },
2453 { .center_freq = 2442, .hw_value = 7 },
2454 { .center_freq = 2447, .hw_value = 8 },
2455 { .center_freq = 2452, .hw_value = 9 },
2456 { .center_freq = 2457, .hw_value = 10 },
2457 { .center_freq = 2462, .hw_value = 11 },
2458 { .center_freq = 2467, .hw_value = 12 },
2459 { .center_freq = 2472, .hw_value = 13 },
2460 { .center_freq = 2484, .hw_value = 14 }
2461};
2462
2463static struct ieee80211_supported_band at76_supported_band = {
2464 .channels = at76_channels,
2465 .n_channels = ARRAY_SIZE(at76_channels),
2466 .bitrates = at76_rates,
2467 .n_bitrates = ARRAY_SIZE(at76_rates),
2468};
2469
2470/* Register network device and initialize the hardware */ 5262/* Register network device and initialize the hardware */
2471static int at76_init_new_device(struct at76_priv *priv, 5263static int at76_init_new_device(struct at76_priv *priv,
2472 struct usb_interface *interface) 5264 struct usb_interface *interface)
2473{ 5265{
2474 struct device *dev = &interface->dev; 5266 struct net_device *netdev = priv->netdev;
2475 int ret; 5267 int ret;
2476 5268
2477 /* set up the endpoint information */ 5269 /* set up the endpoint information */
@@ -2487,11 +5279,14 @@ static int at76_init_new_device(struct at76_priv *priv,
2487 /* MAC address */ 5279 /* MAC address */
2488 ret = at76_get_hw_config(priv); 5280 ret = at76_get_hw_config(priv);
2489 if (ret < 0) { 5281 if (ret < 0) {
2490 dev_err(dev, "cannot get MAC address\n"); 5282 dev_printk(KERN_ERR, &interface->dev,
5283 "cannot get MAC address\n");
2491 goto exit; 5284 goto exit;
2492 } 5285 }
2493 5286
2494 priv->domain = at76_get_reg_domain(priv->regulatory_domain); 5287 priv->domain = at76_get_reg_domain(priv->regulatory_domain);
5288 /* init. netdev->dev_addr */
5289 memcpy(netdev->dev_addr, priv->mac_addr, ETH_ALEN);
2495 5290
2496 priv->channel = DEF_CHANNEL; 5291 priv->channel = DEF_CHANNEL;
2497 priv->iw_mode = IW_MODE_INFRA; 5292 priv->iw_mode = IW_MODE_INFRA;
@@ -2501,54 +5296,47 @@ static int at76_init_new_device(struct at76_priv *priv,
2501 priv->txrate = TX_RATE_AUTO; 5296 priv->txrate = TX_RATE_AUTO;
2502 priv->preamble_type = PREAMBLE_TYPE_LONG; 5297 priv->preamble_type = PREAMBLE_TYPE_LONG;
2503 priv->beacon_period = 100; 5298 priv->beacon_period = 100;
5299 priv->beacons_last_qual = jiffies;
2504 priv->auth_mode = WLAN_AUTH_OPEN; 5300 priv->auth_mode = WLAN_AUTH_OPEN;
2505 priv->scan_min_time = DEF_SCAN_MIN_TIME; 5301 priv->scan_min_time = DEF_SCAN_MIN_TIME;
2506 priv->scan_max_time = DEF_SCAN_MAX_TIME; 5302 priv->scan_max_time = DEF_SCAN_MAX_TIME;
2507 priv->scan_mode = SCAN_TYPE_ACTIVE; 5303 priv->scan_mode = SCAN_TYPE_ACTIVE;
2508 priv->default_pairwise_key = 0xff;
2509 priv->default_group_key = 0xff;
2510
2511 /* mac80211 initialisation */
2512 priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &at76_supported_band;
2513 5304
2514 if (FIRMWARE_IS_WPA(priv->fw_version) && 5305 netdev->flags &= ~IFF_MULTICAST; /* not yet or never */
2515 (at76_is_503rfmd(priv->board_type) || 5306 netdev->open = at76_open;
2516 at76_is_505(priv->board_type))) 5307 netdev->stop = at76_stop;
2517 priv->hw->flags = IEEE80211_HW_SIGNAL_UNSPEC; 5308 netdev->get_stats = at76_get_stats;
2518 else 5309 netdev->ethtool_ops = &at76_ethtool_ops;
2519 priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 5310
2520 IEEE80211_HW_SIGNAL_UNSPEC; 5311 /* Add pointers to enable iwspy support. */
2521 5312 priv->wireless_data.spy_data = &priv->spy_data;
2522 priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 5313 netdev->wireless_data = &priv->wireless_data;
2523 5314
2524 SET_IEEE80211_DEV(priv->hw, &interface->dev); 5315 netdev->hard_start_xmit = at76_tx;
2525 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 5316 netdev->tx_timeout = at76_tx_timeout;
2526 5317 netdev->watchdog_timeo = 2 * HZ;
2527 ret = ieee80211_register_hw(priv->hw); 5318 netdev->wireless_handlers = &at76_handler_def;
5319 netdev->set_multicast_list = at76_set_multicast;
5320 netdev->set_mac_address = at76_set_mac_address;
5321 dev_alloc_name(netdev, "wlan%d");
5322
5323 ret = register_netdev(priv->netdev);
2528 if (ret) { 5324 if (ret) {
2529 dev_err(dev, "cannot register mac80211 hw (status %d)!\n", ret); 5325 dev_printk(KERN_ERR, &interface->dev,
5326 "cannot register netdevice (status %d)!\n", ret);
2530 goto exit; 5327 goto exit;
2531 } 5328 }
5329 priv->netdev_registered = 1;
2532 5330
2533 priv->mac80211_registered = 1; 5331 printk(KERN_INFO "%s: USB %s, MAC %s, firmware %d.%d.%d-%d\n",
5332 netdev->name, dev_name(&interface->dev), mac2str(priv->mac_addr),
5333 priv->fw_version.major, priv->fw_version.minor,
5334 priv->fw_version.patch, priv->fw_version.build);
5335 printk(KERN_INFO "%s: regulatory domain 0x%02x: %s\n", netdev->name,
5336 priv->regulatory_domain, priv->domain->name);
2534 5337
2535 dev_info(dev, "%s: USB %s, MAC %s, firmware %d.%d.%d-%d\n", 5338 /* we let this timer run the whole time this driver instance lives */
2536 wiphy_name(priv->hw->wiphy), 5339 mod_timer(&priv->bss_list_timer, jiffies + BSS_LIST_TIMEOUT);
2537 dev_name(&interface->dev), mac2str(priv->mac_addr),
2538 priv->fw_version.major, priv->fw_version.minor,
2539 priv->fw_version.patch, priv->fw_version.build);
2540 dev_info(dev, "%s: regulatory domain 0x%02x: %s\n",
2541 wiphy_name(priv->hw->wiphy),
2542 priv->regulatory_domain, priv->domain->name);
2543 dev_info(dev, "%s: WPA support: ", wiphy_name(priv->hw->wiphy));
2544 if (!FIRMWARE_IS_WPA(priv->fw_version))
2545 printk("none\n");
2546 else {
2547 if (!at76_is_505a(priv->board_type))
2548 printk("TKIP\n");
2549 else
2550 printk("TKIP, AES/CCMP\n");
2551 };
2552 5340
2553exit: 5341exit:
2554 return ret; 5342 return ret;
@@ -2556,13 +5344,15 @@ exit:
2556 5344
2557static void at76_delete_device(struct at76_priv *priv) 5345static void at76_delete_device(struct at76_priv *priv)
2558{ 5346{
5347 int i;
5348
2559 at76_dbg(DBG_PROC_ENTRY, "%s: ENTER", __func__); 5349 at76_dbg(DBG_PROC_ENTRY, "%s: ENTER", __func__);
2560 5350
2561 /* The device is gone, don't bother turning it off */ 5351 /* The device is gone, don't bother turning it off */
2562 priv->device_unplugged = 1; 5352 priv->device_unplugged = 1;
2563 5353
2564 if (priv->mac80211_registered) 5354 if (priv->netdev_registered)
2565 ieee80211_unregister_hw(priv->hw); 5355 unregister_netdev(priv->netdev);
2566 5356
2567 /* assuming we used keventd, it must quiesce too */ 5357 /* assuming we used keventd, it must quiesce too */
2568 flush_scheduled_work(); 5358 flush_scheduled_work();
@@ -2583,11 +5373,25 @@ static void at76_delete_device(struct at76_priv *priv)
2583 if (priv->rx_skb) 5373 if (priv->rx_skb)
2584 kfree_skb(priv->rx_skb); 5374 kfree_skb(priv->rx_skb);
2585 5375
5376 at76_free_bss_list(priv);
5377 del_timer_sync(&priv->bss_list_timer);
5378 cancel_delayed_work(&priv->dwork_get_scan);
5379 cancel_delayed_work(&priv->dwork_beacon);
5380 cancel_delayed_work(&priv->dwork_auth);
5381 cancel_delayed_work(&priv->dwork_assoc);
5382
5383 if (priv->mac_state == MAC_CONNECTED)
5384 at76_iwevent_bss_disconnect(priv->netdev);
5385
5386 for (i = 0; i < NR_RX_DATA_BUF; i++)
5387 if (priv->rx_data[i].skb) {
5388 dev_kfree_skb(priv->rx_data[i].skb);
5389 priv->rx_data[i].skb = NULL;
5390 }
2586 usb_put_dev(priv->udev); 5391 usb_put_dev(priv->udev);
2587 5392
2588 at76_dbg(DBG_PROC_ENTRY, "%s: before freeing priv/ieee80211_hw", 5393 at76_dbg(DBG_PROC_ENTRY, "%s: before freeing priv/netdev", __func__);
2589 __func__); 5394 free_netdev(priv->netdev); /* priv is in netdev */
2590 ieee80211_free_hw(priv->hw);
2591 5395
2592 at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__); 5396 at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__);
2593} 5397}
@@ -2621,8 +5425,8 @@ static int at76_probe(struct usb_interface *interface,
2621 we get 204 with 2.4.23, Fiberline FL-WL240u (505A+RFMD2958) ??? */ 5425 we get 204 with 2.4.23, Fiberline FL-WL240u (505A+RFMD2958) ??? */
2622 5426
2623 if (op_mode == OPMODE_HW_CONFIG_MODE) { 5427 if (op_mode == OPMODE_HW_CONFIG_MODE) {
2624 dev_err(&interface->dev, 5428 dev_printk(KERN_ERR, &interface->dev,
2625 "cannot handle a device in HW_CONFIG_MODE\n"); 5429 "cannot handle a device in HW_CONFIG_MODE\n");
2626 ret = -EBUSY; 5430 ret = -EBUSY;
2627 goto error; 5431 goto error;
2628 } 5432 }
@@ -2630,12 +5434,13 @@ static int at76_probe(struct usb_interface *interface,
2630 if (op_mode != OPMODE_NORMAL_NIC_WITH_FLASH 5434 if (op_mode != OPMODE_NORMAL_NIC_WITH_FLASH
2631 && op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) { 5435 && op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) {
2632 /* download internal firmware part */ 5436 /* download internal firmware part */
2633 dev_dbg(&interface->dev, "downloading internal firmware\n"); 5437 dev_printk(KERN_DEBUG, &interface->dev,
5438 "downloading internal firmware\n");
2634 ret = at76_load_internal_fw(udev, fwe); 5439 ret = at76_load_internal_fw(udev, fwe);
2635 if (ret < 0) { 5440 if (ret < 0) {
2636 dev_err(&interface->dev, 5441 dev_printk(KERN_ERR, &interface->dev,
2637 "error %d downloading internal firmware\n", 5442 "error %d downloading internal firmware\n",
2638 ret); 5443 ret);
2639 goto error; 5444 goto error;
2640 } 5445 }
2641 usb_put_dev(udev); 5446 usb_put_dev(udev);
@@ -2660,7 +5465,8 @@ static int at76_probe(struct usb_interface *interface,
2660 need_ext_fw = 1; 5465 need_ext_fw = 1;
2661 5466
2662 if (need_ext_fw) { 5467 if (need_ext_fw) {
2663 dev_dbg(&interface->dev, "downloading external firmware\n"); 5468 dev_printk(KERN_DEBUG, &interface->dev,
5469 "downloading external firmware\n");
2664 5470
2665 ret = at76_load_external_fw(udev, fwe); 5471 ret = at76_load_external_fw(udev, fwe);
2666 if (ret) 5472 if (ret)
@@ -2669,8 +5475,8 @@ static int at76_probe(struct usb_interface *interface,
2669 /* Re-check firmware version */ 5475 /* Re-check firmware version */
2670 ret = at76_get_mib(udev, MIB_FW_VERSION, &fwv, sizeof(fwv)); 5476 ret = at76_get_mib(udev, MIB_FW_VERSION, &fwv, sizeof(fwv));
2671 if (ret < 0) { 5477 if (ret < 0) {
2672 dev_err(&interface->dev, 5478 dev_printk(KERN_ERR, &interface->dev,
2673 "error %d getting firmware version\n", ret); 5479 "error %d getting firmware version\n", ret);
2674 goto error; 5480 goto error;
2675 } 5481 }
2676 } 5482 }
@@ -2681,6 +5487,7 @@ static int at76_probe(struct usb_interface *interface,
2681 goto error; 5487 goto error;
2682 } 5488 }
2683 5489
5490 SET_NETDEV_DEV(priv->netdev, &interface->dev);
2684 usb_set_intfdata(interface, priv); 5491 usb_set_intfdata(interface, priv);
2685 5492
2686 memcpy(&priv->fw_version, &fwv, sizeof(struct mib_fw_version)); 5493 memcpy(&priv->fw_version, &fwv, sizeof(struct mib_fw_version));
@@ -2708,7 +5515,7 @@ static void at76_disconnect(struct usb_interface *interface)
2708 if (!priv) 5515 if (!priv)
2709 return; 5516 return;
2710 5517
2711 printk(KERN_INFO "%s: disconnecting\n", wiphy_name(priv->hw->wiphy)); 5518 printk(KERN_INFO "%s: disconnecting\n", priv->netdev->name);
2712 at76_delete_device(priv); 5519 at76_delete_device(priv);
2713 dev_printk(KERN_INFO, &interface->dev, "disconnected\n"); 5520 dev_printk(KERN_INFO, &interface->dev, "disconnected\n");
2714} 5521}
@@ -2764,8 +5571,5 @@ MODULE_AUTHOR("Alex <alex@foogod.com>");
2764MODULE_AUTHOR("Nick Jones"); 5571MODULE_AUTHOR("Nick Jones");
2765MODULE_AUTHOR("Balint Seeber <n0_5p4m_p13453@hotmail.com>"); 5572MODULE_AUTHOR("Balint Seeber <n0_5p4m_p13453@hotmail.com>");
2766MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>"); 5573MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
2767MODULE_AUTHOR("Guido Guenther <agx@sigxcpu.org>");
2768MODULE_AUTHOR("Kalle Valo <kalle.valo@iki.fi>");
2769MODULE_AUTHOR("Milan Plzik <milan.plzik@gmail.com>");
2770MODULE_DESCRIPTION(DRIVER_DESC); 5574MODULE_DESCRIPTION(DRIVER_DESC);
2771MODULE_LICENSE("GPL"); 5575MODULE_LICENSE("GPL");
diff --git a/drivers/staging/at76_usb/at76_usb.h b/drivers/staging/at76_usb/at76_usb.h
index 8bb352f16d45..b20be9da1fa1 100644
--- a/drivers/staging/at76_usb/at76_usb.h
+++ b/drivers/staging/at76_usb/at76_usb.h
@@ -34,6 +34,23 @@ enum board_type {
34 BOARD_505AMX = 8 34 BOARD_505AMX = 8
35}; 35};
36 36
37/* our private ioctl's */
38/* preamble length (0 - long, 1 - short, 2 - auto) */
39#define AT76_SET_SHORT_PREAMBLE (SIOCIWFIRSTPRIV + 0)
40#define AT76_GET_SHORT_PREAMBLE (SIOCIWFIRSTPRIV + 1)
41/* which debug channels are enabled */
42#define AT76_SET_DEBUG (SIOCIWFIRSTPRIV + 2)
43#define AT76_GET_DEBUG (SIOCIWFIRSTPRIV + 3)
44/* power save mode (incl. the Atmel proprietary smart save mode) */
45#define AT76_SET_POWERSAVE_MODE (SIOCIWFIRSTPRIV + 4)
46#define AT76_GET_POWERSAVE_MODE (SIOCIWFIRSTPRIV + 5)
47/* min and max channel times for scan */
48#define AT76_SET_SCAN_TIMES (SIOCIWFIRSTPRIV + 6)
49#define AT76_GET_SCAN_TIMES (SIOCIWFIRSTPRIV + 7)
50/* scan mode (0 - active, 1 - passive) */
51#define AT76_SET_SCAN_MODE (SIOCIWFIRSTPRIV + 8)
52#define AT76_GET_SCAN_MODE (SIOCIWFIRSTPRIV + 9)
53
37#define CMD_STATUS_IDLE 0x00 54#define CMD_STATUS_IDLE 0x00
38#define CMD_STATUS_COMPLETE 0x01 55#define CMD_STATUS_COMPLETE 0x01
39#define CMD_STATUS_UNKNOWN 0x02 56#define CMD_STATUS_UNKNOWN 0x02
@@ -65,7 +82,6 @@ enum board_type {
65#define MIB_MAC 0x03 82#define MIB_MAC 0x03
66#define MIB_MAC_MGMT 0x05 83#define MIB_MAC_MGMT 0x05
67#define MIB_MAC_WEP 0x06 84#define MIB_MAC_WEP 0x06
68#define MIB_MAC_ENCRYPTION 0x06
69#define MIB_PHY 0x07 85#define MIB_PHY 0x07
70#define MIB_FW_VERSION 0x08 86#define MIB_FW_VERSION 0x08
71#define MIB_MDOMAIN 0x09 87#define MIB_MDOMAIN 0x09
@@ -90,26 +106,6 @@ enum board_type {
90#define AT76_PM_ON 2 106#define AT76_PM_ON 2
91#define AT76_PM_SMART 3 107#define AT76_PM_SMART 3
92 108
93/* cipher values for encryption keys */
94#define CIPHER_NONE 0 /* this value is only guessed */
95#define CIPHER_WEP64 1
96#define CIPHER_TKIP 2
97#define CIPHER_CCMP 3
98#define CIPHER_CCX 4 /* for consistency sake only */
99#define CIPHER_WEP128 5
100
101/* bit flags key types for encryption keys */
102#define KEY_PAIRWISE 2
103#define KEY_TX 4
104
105#define CIPHER_KEYS (4)
106#define CIPHER_KEY_LEN (40)
107
108struct key_config {
109 u8 cipher;
110 u8 keylen;
111};
112
113struct hwcfg_r505 { 109struct hwcfg_r505 {
114 u8 cr39_values[14]; 110 u8 cr39_values[14];
115 u8 reserved1[14]; 111 u8 reserved1[14];
@@ -151,9 +147,6 @@ union at76_hwcfg {
151 147
152#define WEP_SMALL_KEY_LEN (40 / 8) 148#define WEP_SMALL_KEY_LEN (40 / 8)
153#define WEP_LARGE_KEY_LEN (104 / 8) 149#define WEP_LARGE_KEY_LEN (104 / 8)
154#define WEP_KEYS (4)
155
156
157 150
158struct at76_card_config { 151struct at76_card_config {
159 u8 exclude_unencrypted; 152 u8 exclude_unencrypted;
@@ -168,7 +161,7 @@ struct at76_card_config {
168 u8 privacy_invoked; 161 u8 privacy_invoked;
169 u8 wep_default_key_id; /* 0..3 */ 162 u8 wep_default_key_id; /* 0..3 */
170 u8 current_ssid[32]; 163 u8 current_ssid[32];
171 u8 wep_default_key_value[4][WEP_LARGE_KEY_LEN]; 164 u8 wep_default_key_value[4][WEP_KEY_LEN];
172 u8 ssid_len; 165 u8 ssid_len;
173 u8 short_preamble; 166 u8 short_preamble;
174 __le16 beacon_period; 167 __le16 beacon_period;
@@ -193,7 +186,7 @@ struct at76_rx_buffer {
193 u8 link_quality; 186 u8 link_quality;
194 u8 noise_level; 187 u8 noise_level;
195 __le32 rx_time; 188 __le32 rx_time;
196 u8 packet[IEEE80211_MAX_FRAG_THRESHOLD]; 189 u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN];
197} __attribute__((packed)); 190} __attribute__((packed));
198 191
199/* Length of Atmel-specific Tx header before 802.11 frame */ 192/* Length of Atmel-specific Tx header before 802.11 frame */
@@ -203,11 +196,8 @@ struct at76_tx_buffer {
203 __le16 wlength; 196 __le16 wlength;
204 u8 tx_rate; 197 u8 tx_rate;
205 u8 padding; 198 u8 padding;
206 u8 key_id; 199 u8 reserved[4];
207 u8 cipher_type; 200 u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN];
208 u8 cipher_length;
209 u8 reserved;
210 u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
211} __attribute__((packed)); 201} __attribute__((packed));
212 202
213/* defines for scan_type below */ 203/* defines for scan_type below */
@@ -254,7 +244,6 @@ struct set_mib_buffer {
254 u8 byte; 244 u8 byte;
255 __le16 word; 245 __le16 word;
256 u8 addr[ETH_ALEN]; 246 u8 addr[ETH_ALEN];
257 u8 data[256]; /* we need more space for mib_mac_encryption */
258 } data; 247 } data;
259} __attribute__((packed)); 248} __attribute__((packed));
260 249
@@ -328,24 +317,10 @@ struct mib_mac_wep {
328 u8 exclude_unencrypted; 317 u8 exclude_unencrypted;
329 __le32 wep_icv_error_count; 318 __le32 wep_icv_error_count;
330 __le32 wep_excluded_count; 319 __le32 wep_excluded_count;
331 u8 wep_default_keyvalue[WEP_KEYS][WEP_LARGE_KEY_LEN]; 320 u8 wep_default_keyvalue[WEP_KEYS][WEP_KEY_LEN];
332 u8 encryption_level; /* 1 for 40bit, 2 for 104bit encryption */ 321 u8 encryption_level; /* 1 for 40bit, 2 for 104bit encryption */
333} __attribute__((packed)); 322} __attribute__((packed));
334 323
335struct mib_mac_encryption {
336 u8 cipher_default_keyvalue[CIPHER_KEYS][CIPHER_KEY_LEN];
337 u8 tkip_bssid[6];
338 u8 privacy_invoked;
339 u8 cipher_default_key_id;
340 u8 cipher_default_group_key_id;
341 u8 exclude_unencrypted;
342 u8 wep_encryption_type;
343 u8 ckip_key_permutation; /* bool */
344 __le32 wep_icv_error_count;
345 __le32 wep_excluded_count;
346 u8 key_rsc[CIPHER_KEYS][8];
347} __attribute__((packed));
348
349struct mib_phy { 324struct mib_phy {
350 __le32 ed_threshold; 325 __le32 ed_threshold;
351 326
@@ -389,6 +364,16 @@ struct at76_fw_header {
389 __le32 ext_fw_len; /* external firmware image length */ 364 __le32 ext_fw_len; /* external firmware image length */
390} __attribute__((packed)); 365} __attribute__((packed));
391 366
367enum mac_state {
368 MAC_INIT,
369 MAC_SCANNING,
370 MAC_AUTH,
371 MAC_ASSOC,
372 MAC_JOINING,
373 MAC_CONNECTED,
374 MAC_OWN_IBSS
375};
376
392/* a description of a regulatory domain and the allowed channels */ 377/* a description of a regulatory domain and the allowed channels */
393struct reg_domain { 378struct reg_domain {
394 u16 code; 379 u16 code;
@@ -396,6 +381,47 @@ struct reg_domain {
396 u32 channel_map; /* if bit N is set, channel (N+1) is allowed */ 381 u32 channel_map; /* if bit N is set, channel (N+1) is allowed */
397}; 382};
398 383
384/* how long do we keep a (I)BSS in the bss_list in jiffies
385 this should be long enough for the user to retrieve the table
386 (by iwlist ?) after the device started, because all entries from
387 other channels than the one the device locks on get removed, too */
388#define BSS_LIST_TIMEOUT (120 * HZ)
389/* struct to store BSS info found during scan */
390#define BSS_LIST_MAX_RATE_LEN 32 /* 32 rates should be enough ... */
391
392struct bss_info {
393 struct list_head list;
394
395 u8 bssid[ETH_ALEN]; /* bssid */
396 u8 ssid[IW_ESSID_MAX_SIZE]; /* essid */
397 u8 ssid_len; /* length of ssid above */
398 u8 channel;
399 u16 capa; /* BSS capabilities */
400 u16 beacon_interval; /* beacon interval, Kus (1024 microseconds) */
401 u8 rates[BSS_LIST_MAX_RATE_LEN]; /* supported rates in units of
402 500 kbps, ORed with 0x80 for
403 basic rates */
404 u8 rates_len;
405
406 /* quality of received beacon */
407 u8 rssi;
408 u8 link_qual;
409 u8 noise_level;
410
411 unsigned long last_rx; /* time (jiffies) of last beacon received */
412};
413
414/* a rx data buffer to collect rx fragments */
415struct rx_data_buf {
416 u8 sender[ETH_ALEN]; /* sender address */
417 u16 seqnr; /* sequence number */
418 u16 fragnr; /* last fragment received */
419 unsigned long last_rx; /* jiffies of last rx */
420 struct sk_buff *skb; /* == NULL if entry is free */
421};
422
423#define NR_RX_DATA_BUF 8
424
399/* Data for one loaded firmware file */ 425/* Data for one loaded firmware file */
400struct fwentry { 426struct fwentry {
401 const char *const fwname; 427 const char *const fwname;
@@ -412,9 +438,11 @@ struct fwentry {
412 438
413struct at76_priv { 439struct at76_priv {
414 struct usb_device *udev; /* USB device pointer */ 440 struct usb_device *udev; /* USB device pointer */
441 struct net_device *netdev; /* net device pointer */
442 struct net_device_stats stats; /* net device stats */
443 struct iw_statistics wstats; /* wireless stats */
415 444
416 struct sk_buff *rx_skb; /* skbuff for receiving data */ 445 struct sk_buff *rx_skb; /* skbuff for receiving data */
417 struct sk_buff *tx_skb; /* skbuff for transmitting data */
418 void *bulk_out_buffer; /* buffer for sending data */ 446 void *bulk_out_buffer; /* buffer for sending data */
419 447
420 struct urb *tx_urb; /* URB for sending data */ 448 struct urb *tx_urb; /* URB for sending data */
@@ -426,17 +454,26 @@ struct at76_priv {
426 struct mutex mtx; /* locks this structure */ 454 struct mutex mtx; /* locks this structure */
427 455
428 /* work queues */ 456 /* work queues */
457 struct work_struct work_assoc_done;
458 struct work_struct work_join;
459 struct work_struct work_new_bss;
460 struct work_struct work_start_scan;
429 struct work_struct work_set_promisc; 461 struct work_struct work_set_promisc;
430 struct work_struct work_submit_rx; 462 struct work_struct work_submit_rx;
431 struct delayed_work dwork_hw_scan; 463 struct delayed_work dwork_restart;
464 struct delayed_work dwork_get_scan;
465 struct delayed_work dwork_beacon;
466 struct delayed_work dwork_auth;
467 struct delayed_work dwork_assoc;
432 468
433 struct tasklet_struct rx_tasklet; 469 struct tasklet_struct rx_tasklet;
434 470
435 /* the WEP stuff */ 471 /* the WEP stuff */
436 int wep_enabled; /* 1 if WEP is enabled */ 472 int wep_enabled; /* 1 if WEP is enabled */
437 int wep_key_id; /* key id to be used */ 473 int wep_key_id; /* key id to be used */
438 u8 wep_keys[WEP_KEYS][WEP_LARGE_KEY_LEN]; /* WEP keys */ 474 u8 wep_keys[WEP_KEYS][WEP_KEY_LEN]; /* the four WEP keys,
439 u8 wep_keys_len[WEP_KEYS]; /* length of WEP keys */ 475 5 or 13 bytes are used */
476 u8 wep_keys_len[WEP_KEYS]; /* the length of the above keys */
440 477
441 int channel; 478 int channel;
442 int iw_mode; 479 int iw_mode;
@@ -458,13 +495,44 @@ struct at76_priv {
458 int scan_mode; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */ 495 int scan_mode; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */
459 int scan_need_any; /* if set, need to scan for any ESSID */ 496 int scan_need_any; /* if set, need to scan for any ESSID */
460 497
498 /* the list we got from scanning */
499 spinlock_t bss_list_spinlock; /* protects bss_list operations */
500 struct list_head bss_list; /* list of BSS we got beacons from */
501 struct timer_list bss_list_timer; /* timer to purge old entries
502 from bss_list */
503 struct bss_info *curr_bss; /* current BSS */
461 u16 assoc_id; /* current association ID, if associated */ 504 u16 assoc_id; /* current association ID, if associated */
462 505
506 u8 wanted_bssid[ETH_ALEN];
507 int wanted_bssid_valid; /* != 0 if wanted_bssid is to be used */
508
509 /* some data for infrastructure mode only */
510 spinlock_t mgmt_spinlock; /* this spinlock protects access to
511 next_mgmt_bulk */
512
513 struct at76_tx_buffer *next_mgmt_bulk; /* pending management msg to
514 send via bulk out */
515 enum mac_state mac_state;
516 enum {
517 SCAN_IDLE,
518 SCAN_IN_PROGRESS,
519 SCAN_COMPLETED
520 } scan_state;
521 time_t last_scan;
522
523 int retries; /* remaining retries in case of timeout when
524 * sending AuthReq or AssocReq */
463 u8 pm_mode; /* power management mode */ 525 u8 pm_mode; /* power management mode */
464 u32 pm_period; /* power management period in microseconds */ 526 u32 pm_period; /* power management period in microseconds */
465 527
466 struct reg_domain const *domain; /* reg domain description */ 528 struct reg_domain const *domain; /* reg domain description */
467 529
530 /* iwspy support */
531 spinlock_t spy_spinlock;
532 struct iw_spy_data spy_data;
533
534 struct iw_public_data wireless_data;
535
468 /* These fields contain HW config provided by the device (not all of 536 /* These fields contain HW config provided by the device (not all of
469 * these fields are used by all board types) */ 537 * these fields are used by all board types) */
470 u8 mac_addr[ETH_ALEN]; 538 u8 mac_addr[ETH_ALEN];
@@ -472,6 +540,9 @@ struct at76_priv {
472 540
473 struct at76_card_config card_config; 541 struct at76_card_config card_config;
474 542
543 /* store rx fragments until complete */
544 struct rx_data_buf rx_data[NR_RX_DATA_BUF];
545
475 enum board_type board_type; 546 enum board_type board_type;
476 struct mib_fw_version fw_version; 547 struct mib_fw_version fw_version;
477 548
@@ -479,20 +550,58 @@ struct at76_priv {
479 unsigned int netdev_registered:1; 550 unsigned int netdev_registered:1;
480 struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */ 551 struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */
481 552
553 /* beacon counting */
482 int beacon_period; /* period of mgmt beacons, Kus */ 554 int beacon_period; /* period of mgmt beacons, Kus */
555 int beacons_received;
556 unsigned long beacons_last_qual; /* time we restarted counting
557 beacons */
558};
483 559
484 struct ieee80211_hw *hw; 560struct at76_rx_radiotap {
485 int mac80211_registered; 561 struct ieee80211_radiotap_header rt_hdr;
486 562 __le64 rt_tsft;
487 struct key_config keys[4]; /* installed key types */ 563 u8 rt_flags;
488 u8 default_pairwise_key; 564 u8 rt_rate;
489 u8 default_group_key; 565 s8 rt_signal;
566 s8 rt_noise;
490}; 567};
491 568
492#define AT76_SUPPORTED_FILTERS FIF_PROMISC_IN_BSS 569#define AT76_RX_RADIOTAP_PRESENT \
570 ((1 << IEEE80211_RADIOTAP_TSFT) | \
571 (1 << IEEE80211_RADIOTAP_FLAGS) | \
572 (1 << IEEE80211_RADIOTAP_RATE) | \
573 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \
574 (1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
575
576#define BEACON_MAX_DATA_LENGTH 1500
577
578/* the maximum size of an AssocReq packet */
579#define ASSOCREQ_MAX_SIZE \
580 (AT76_TX_HDRLEN + sizeof(struct ieee80211_assoc_request) + \
581 1 + 1 + IW_ESSID_MAX_SIZE + 1 + 1 + 4)
582
583/* for shared secret auth, add the challenge text size */
584#define AUTH_FRAME_SIZE (AT76_TX_HDRLEN + sizeof(struct ieee80211_auth))
585
586/* Maximal number of AuthReq retries */
587#define AUTH_RETRIES 3
493 588
589/* Maximal number of AssocReq retries */
590#define ASSOC_RETRIES 3
591
592/* Beacon timeout in managed mode when we are connected */
593#define BEACON_TIMEOUT (10 * HZ)
594
595/* Timeout for authentication response */
596#define AUTH_TIMEOUT (1 * HZ)
597
598/* Timeout for association response */
599#define ASSOC_TIMEOUT (1 * HZ)
600
601/* Polling interval when scan is running */
494#define SCAN_POLL_INTERVAL (HZ / 4) 602#define SCAN_POLL_INTERVAL (HZ / 4)
495 603
604/* Command completion timeout */
496#define CMD_COMPLETION_TIMEOUT (5 * HZ) 605#define CMD_COMPLETION_TIMEOUT (5 * HZ)
497 606
498#define DEF_RTS_THRESHOLD 1536 607#define DEF_RTS_THRESHOLD 1536
@@ -502,6 +611,8 @@ struct at76_priv {
502#define DEF_SCAN_MIN_TIME 10 611#define DEF_SCAN_MIN_TIME 10
503#define DEF_SCAN_MAX_TIME 120 612#define DEF_SCAN_MAX_TIME 120
504 613
614#define MAX_RTS_THRESHOLD (MAX_FRAG_THRESHOLD + 1)
615
505/* the max padding size for tx in bytes (see calc_padding) */ 616/* the max padding size for tx in bytes (see calc_padding) */
506#define MAX_PADDING_SIZE 53 617#define MAX_PADDING_SIZE 53
507 618
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 5ffe269c2382..ab69c1bf36a8 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -622,7 +622,7 @@ static int set_ctrl_bits(void)
622} 622}
623 623
624/* sets ctrl & data port bits according to current signals values */ 624/* sets ctrl & data port bits according to current signals values */
625static void set_bits(void) 625static void panel_set_bits(void)
626{ 626{
627 set_data_bits(); 627 set_data_bits();
628 set_ctrl_bits(); 628 set_ctrl_bits();
@@ -707,12 +707,12 @@ static void lcd_send_serial(int byte)
707 */ 707 */
708 for (bit = 0; bit < 8; bit++) { 708 for (bit = 0; bit < 8; bit++) {
709 bits.cl = BIT_CLR; /* CLK low */ 709 bits.cl = BIT_CLR; /* CLK low */
710 set_bits(); 710 panel_set_bits();
711 bits.da = byte & 1; 711 bits.da = byte & 1;
712 set_bits(); 712 panel_set_bits();
713 udelay(2); /* maintain the data during 2 us before CLK up */ 713 udelay(2); /* maintain the data during 2 us before CLK up */
714 bits.cl = BIT_SET; /* CLK high */ 714 bits.cl = BIT_SET; /* CLK high */
715 set_bits(); 715 panel_set_bits();
716 udelay(1); /* maintain the strobe during 1 us */ 716 udelay(1); /* maintain the strobe during 1 us */
717 byte >>= 1; 717 byte >>= 1;
718 } 718 }
@@ -727,7 +727,7 @@ static void lcd_backlight(int on)
727 /* The backlight is activated by seting the AUTOFEED line to +5V */ 727 /* The backlight is activated by seting the AUTOFEED line to +5V */
728 spin_lock(&pprt_lock); 728 spin_lock(&pprt_lock);
729 bits.bl = on; 729 bits.bl = on;
730 set_bits(); 730 panel_set_bits();
731 spin_unlock(&pprt_lock); 731 spin_unlock(&pprt_lock);
732} 732}
733 733
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 8bcde8cde554..b2ceb4aff233 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_MON) += mon/
11obj-$(CONFIG_PCI) += host/ 11obj-$(CONFIG_PCI) += host/
12obj-$(CONFIG_USB_EHCI_HCD) += host/ 12obj-$(CONFIG_USB_EHCI_HCD) += host/
13obj-$(CONFIG_USB_ISP116X_HCD) += host/ 13obj-$(CONFIG_USB_ISP116X_HCD) += host/
14obj-$(CONFIG_USB_ISP1760_HCD) += host/
14obj-$(CONFIG_USB_OHCI_HCD) += host/ 15obj-$(CONFIG_USB_OHCI_HCD) += host/
15obj-$(CONFIG_USB_UHCI_HCD) += host/ 16obj-$(CONFIG_USB_UHCI_HCD) += host/
16obj-$(CONFIG_USB_FHCI_HCD) += host/ 17obj-$(CONFIG_USB_FHCI_HCD) += host/
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 97ba4a985edc..326dd7f65ee9 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1349,9 +1349,6 @@ static struct usb_device_id acm_ids[] = {
1349 { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */ 1349 { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */
1350 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1350 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1351 }, 1351 },
1352 { USB_DEVICE(0x0e8d, 0x3329), /* i-blue 747, Qstarz BT-Q1000, Holux M-241 */
1353 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1354 },
1355 { USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */ 1352 { USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */
1356 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1353 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1357 }, 1354 },
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index c54fc40458b1..a4301dc02d27 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -298,19 +298,6 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
298EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend); 298EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend);
299 299
300/** 300/**
301 * usb_hcd_pci_resume_early - resume a PCI-based HCD before IRQs are enabled
302 * @dev: USB Host Controller being resumed
303 *
304 * Store this function in the HCD's struct pci_driver as .resume_early.
305 */
306int usb_hcd_pci_resume_early(struct pci_dev *dev)
307{
308 pci_restore_state(dev);
309 return 0;
310}
311EXPORT_SYMBOL_GPL(usb_hcd_pci_resume_early);
312
313/**
314 * usb_hcd_pci_resume - power management resume of a PCI-based HCD 301 * usb_hcd_pci_resume - power management resume of a PCI-based HCD
315 * @dev: USB Host Controller being resumed 302 * @dev: USB Host Controller being resumed
316 * 303 *
@@ -333,6 +320,8 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
333 } 320 }
334#endif 321#endif
335 322
323 pci_restore_state(dev);
324
336 hcd = pci_get_drvdata(dev); 325 hcd = pci_get_drvdata(dev);
337 if (hcd->state != HC_STATE_SUSPENDED) { 326 if (hcd->state != HC_STATE_SUSPENDED) {
338 dev_dbg(hcd->self.controller, 327 dev_dbg(hcd->self.controller,
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 5b94a56bec23..f750eb1ab595 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -257,7 +257,6 @@ extern void usb_hcd_pci_remove(struct pci_dev *dev);
257 257
258#ifdef CONFIG_PM 258#ifdef CONFIG_PM
259extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t msg); 259extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t msg);
260extern int usb_hcd_pci_resume_early(struct pci_dev *dev);
261extern int usb_hcd_pci_resume(struct pci_dev *dev); 260extern int usb_hcd_pci_resume(struct pci_dev *dev);
262#endif /* CONFIG_PM */ 261#endif /* CONFIG_PM */
263 262
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index d6c5bcd40064..d701bf4698d2 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -1622,6 +1622,8 @@ static int qe_ep_disable(struct usb_ep *_ep)
1622 nuke(ep, -ESHUTDOWN); 1622 nuke(ep, -ESHUTDOWN);
1623 ep->desc = NULL; 1623 ep->desc = NULL;
1624 ep->stopped = 1; 1624 ep->stopped = 1;
1625 ep->tx_req = NULL;
1626 qe_ep_reset(udc, ep->epnum);
1625 spin_unlock_irqrestore(&udc->lock, flags); 1627 spin_unlock_irqrestore(&udc->lock, flags);
1626 1628
1627 cpm_muram_free(cpm_muram_offset(ep->rxbase)); 1629 cpm_muram_free(cpm_muram_offset(ep->rxbase));
@@ -1681,14 +1683,11 @@ static void qe_free_request(struct usb_ep *_ep, struct usb_request *_req)
1681 kfree(req); 1683 kfree(req);
1682} 1684}
1683 1685
1684/* queues (submits) an I/O request to an endpoint */ 1686static int __qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req)
1685static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1686 gfp_t gfp_flags)
1687{ 1687{
1688 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); 1688 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep);
1689 struct qe_req *req = container_of(_req, struct qe_req, req); 1689 struct qe_req *req = container_of(_req, struct qe_req, req);
1690 struct qe_udc *udc; 1690 struct qe_udc *udc;
1691 unsigned long flags;
1692 int reval; 1691 int reval;
1693 1692
1694 udc = ep->udc; 1693 udc = ep->udc;
@@ -1732,7 +1731,7 @@ static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1732 list_add_tail(&req->queue, &ep->queue); 1731 list_add_tail(&req->queue, &ep->queue);
1733 dev_vdbg(udc->dev, "gadget have request in %s! %d\n", 1732 dev_vdbg(udc->dev, "gadget have request in %s! %d\n",
1734 ep->name, req->req.length); 1733 ep->name, req->req.length);
1735 spin_lock_irqsave(&udc->lock, flags); 1734
1736 /* push the request to device */ 1735 /* push the request to device */
1737 if (ep_is_in(ep)) 1736 if (ep_is_in(ep))
1738 reval = ep_req_send(ep, req); 1737 reval = ep_req_send(ep, req);
@@ -1748,11 +1747,24 @@ static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1748 if (ep->dir == USB_DIR_OUT) 1747 if (ep->dir == USB_DIR_OUT)
1749 reval = ep_req_receive(ep, req); 1748 reval = ep_req_receive(ep, req);
1750 1749
1751 spin_unlock_irqrestore(&udc->lock, flags);
1752
1753 return 0; 1750 return 0;
1754} 1751}
1755 1752
1753/* queues (submits) an I/O request to an endpoint */
1754static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1755 gfp_t gfp_flags)
1756{
1757 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep);
1758 struct qe_udc *udc = ep->udc;
1759 unsigned long flags;
1760 int ret;
1761
1762 spin_lock_irqsave(&udc->lock, flags);
1763 ret = __qe_ep_queue(_ep, _req);
1764 spin_unlock_irqrestore(&udc->lock, flags);
1765 return ret;
1766}
1767
1756/* dequeues (cancels, unlinks) an I/O request from an endpoint */ 1768/* dequeues (cancels, unlinks) an I/O request from an endpoint */
1757static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) 1769static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1758{ 1770{
@@ -2008,7 +2020,7 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value,
2008 udc->ep0_dir = USB_DIR_IN; 2020 udc->ep0_dir = USB_DIR_IN;
2009 2021
2010 /* data phase */ 2022 /* data phase */
2011 status = qe_ep_queue(&ep->ep, &req->req, GFP_ATOMIC); 2023 status = __qe_ep_queue(&ep->ep, &req->req);
2012 2024
2013 if (status == 0) 2025 if (status == 0)
2014 return; 2026 return;
@@ -2151,6 +2163,9 @@ static int reset_irq(struct qe_udc *udc)
2151{ 2163{
2152 unsigned char i; 2164 unsigned char i;
2153 2165
2166 if (udc->usb_state == USB_STATE_DEFAULT)
2167 return 0;
2168
2154 qe_usb_disable(); 2169 qe_usb_disable();
2155 out_8(&udc->usb_regs->usb_usadr, 0); 2170 out_8(&udc->usb_regs->usb_usadr, 0);
2156 2171
@@ -2442,8 +2457,12 @@ static int __devinit qe_udc_reg_init(struct qe_udc *udc)
2442 struct usb_ctlr __iomem *qe_usbregs; 2457 struct usb_ctlr __iomem *qe_usbregs;
2443 qe_usbregs = udc->usb_regs; 2458 qe_usbregs = udc->usb_regs;
2444 2459
2445 /* Init the usb register */ 2460 /* Spec says that we must enable the USB controller to change mode. */
2446 out_8(&qe_usbregs->usb_usmod, 0x01); 2461 out_8(&qe_usbregs->usb_usmod, 0x01);
2462 /* Mode changed, now disable it, since muram isn't initialized yet. */
2463 out_8(&qe_usbregs->usb_usmod, 0x00);
2464
2465 /* Initialize the rest. */
2447 out_be16(&qe_usbregs->usb_usbmr, 0); 2466 out_be16(&qe_usbregs->usb_usbmr, 0);
2448 out_8(&qe_usbregs->usb_uscom, 0); 2467 out_8(&qe_usbregs->usb_uscom, 0);
2449 out_be16(&qe_usbregs->usb_usber, USBER_ALL_CLEAR); 2468 out_be16(&qe_usbregs->usb_usber, USBER_ALL_CLEAR);
@@ -2604,6 +2623,10 @@ static int __devinit qe_udc_probe(struct of_device *ofdev,
2604 (unsigned long)udc_controller); 2623 (unsigned long)udc_controller);
2605 /* request irq and disable DR */ 2624 /* request irq and disable DR */
2606 udc_controller->usb_irq = irq_of_parse_and_map(np, 0); 2625 udc_controller->usb_irq = irq_of_parse_and_map(np, 0);
2626 if (!udc_controller->usb_irq) {
2627 ret = -EINVAL;
2628 goto err_noirq;
2629 }
2607 2630
2608 ret = request_irq(udc_controller->usb_irq, qe_udc_irq, 0, 2631 ret = request_irq(udc_controller->usb_irq, qe_udc_irq, 0,
2609 driver_name, udc_controller); 2632 driver_name, udc_controller);
@@ -2625,6 +2648,8 @@ static int __devinit qe_udc_probe(struct of_device *ofdev,
2625err6: 2648err6:
2626 free_irq(udc_controller->usb_irq, udc_controller); 2649 free_irq(udc_controller->usb_irq, udc_controller);
2627err5: 2650err5:
2651 irq_dispose_mapping(udc_controller->usb_irq);
2652err_noirq:
2628 if (udc_controller->nullmap) { 2653 if (udc_controller->nullmap) {
2629 dma_unmap_single(udc_controller->gadget.dev.parent, 2654 dma_unmap_single(udc_controller->gadget.dev.parent,
2630 udc_controller->nullp, 256, 2655 udc_controller->nullp, 256,
@@ -2648,7 +2673,7 @@ err2:
2648 iounmap(udc_controller->usb_regs); 2673 iounmap(udc_controller->usb_regs);
2649err1: 2674err1:
2650 kfree(udc_controller); 2675 kfree(udc_controller);
2651 2676 udc_controller = NULL;
2652 return ret; 2677 return ret;
2653} 2678}
2654 2679
@@ -2710,6 +2735,7 @@ static int __devexit qe_udc_remove(struct of_device *ofdev)
2710 kfree(ep->txframe); 2735 kfree(ep->txframe);
2711 2736
2712 free_irq(udc_controller->usb_irq, udc_controller); 2737 free_irq(udc_controller->usb_irq, udc_controller);
2738 irq_dispose_mapping(udc_controller->usb_irq);
2713 2739
2714 tasklet_kill(&udc_controller->rx_tasklet); 2740 tasklet_kill(&udc_controller->rx_tasklet);
2715 2741
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 9b36205c5759..0ce4e2819847 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -904,8 +904,8 @@ static void pxa25x_ep_fifo_flush(struct usb_ep *_ep)
904 904
905 /* most IN status is the same, but ISO can't stall */ 905 /* most IN status is the same, but ISO can't stall */
906 *ep->reg_udccs = UDCCS_BI_TPC|UDCCS_BI_FTF|UDCCS_BI_TUR 906 *ep->reg_udccs = UDCCS_BI_TPC|UDCCS_BI_FTF|UDCCS_BI_TUR
907 | (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) 907 | (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC
908 ? 0 : UDCCS_BI_SST; 908 ? 0 : UDCCS_BI_SST);
909} 909}
910 910
911 911
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index bb21fb0a4969..abb9a7706ec7 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -432,7 +432,6 @@ static struct pci_driver ehci_pci_driver = {
432 432
433#ifdef CONFIG_PM 433#ifdef CONFIG_PM
434 .suspend = usb_hcd_pci_suspend, 434 .suspend = usb_hcd_pci_suspend,
435 .resume_early = usb_hcd_pci_resume_early,
436 .resume = usb_hcd_pci_resume, 435 .resume = usb_hcd_pci_resume,
437#endif 436#endif
438 .shutdown = usb_hcd_pci_shutdown, 437 .shutdown = usb_hcd_pci_shutdown,
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 5d625c3fd423..f9961b4c0da3 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -487,7 +487,6 @@ static struct pci_driver ohci_pci_driver = {
487 487
488#ifdef CONFIG_PM 488#ifdef CONFIG_PM
489 .suspend = usb_hcd_pci_suspend, 489 .suspend = usb_hcd_pci_suspend,
490 .resume_early = usb_hcd_pci_resume_early,
491 .resume = usb_hcd_pci_resume, 490 .resume = usb_hcd_pci_resume,
492#endif 491#endif
493 492
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 944f7e0ca4df..cf5e4cf7ea42 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -942,7 +942,6 @@ static struct pci_driver uhci_pci_driver = {
942 942
943#ifdef CONFIG_PM 943#ifdef CONFIG_PM
944 .suspend = usb_hcd_pci_suspend, 944 .suspend = usb_hcd_pci_suspend,
945 .resume_early = usb_hcd_pci_resume_early,
946 .resume = usb_hcd_pci_resume, 945 .resume = usb_hcd_pci_resume,
947#endif /* PM */ 946#endif /* PM */
948}; 947};
diff --git a/drivers/usb/host/whci/asl.c b/drivers/usb/host/whci/asl.c
index 2291c5f5af51..958751ccea43 100644
--- a/drivers/usb/host/whci/asl.c
+++ b/drivers/usb/host/whci/asl.c
@@ -227,13 +227,13 @@ void scan_async_work(struct work_struct *work)
227 * Now that the ASL is updated, complete the removal of any 227 * Now that the ASL is updated, complete the removal of any
228 * removed qsets. 228 * removed qsets.
229 */ 229 */
230 spin_lock(&whc->lock); 230 spin_lock_irq(&whc->lock);
231 231
232 list_for_each_entry_safe(qset, t, &whc->async_removed_list, list_node) { 232 list_for_each_entry_safe(qset, t, &whc->async_removed_list, list_node) {
233 qset_remove_complete(whc, qset); 233 qset_remove_complete(whc, qset);
234 } 234 }
235 235
236 spin_unlock(&whc->lock); 236 spin_unlock_irq(&whc->lock);
237} 237}
238 238
239/** 239/**
diff --git a/drivers/usb/host/whci/pzl.c b/drivers/usb/host/whci/pzl.c
index 7dc85a0bee7c..df8b85f07092 100644
--- a/drivers/usb/host/whci/pzl.c
+++ b/drivers/usb/host/whci/pzl.c
@@ -255,13 +255,13 @@ void scan_periodic_work(struct work_struct *work)
255 * Now that the PZL is updated, complete the removal of any 255 * Now that the PZL is updated, complete the removal of any
256 * removed qsets. 256 * removed qsets.
257 */ 257 */
258 spin_lock(&whc->lock); 258 spin_lock_irq(&whc->lock);
259 259
260 list_for_each_entry_safe(qset, t, &whc->periodic_removed_list, list_node) { 260 list_for_each_entry_safe(qset, t, &whc->periodic_removed_list, list_node) {
261 qset_remove_complete(whc, qset); 261 qset_remove_complete(whc, qset);
262 } 262 }
263 263
264 spin_unlock(&whc->lock); 264 spin_unlock_irq(&whc->lock);
265} 265}
266 266
267/** 267/**
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 537f953bd7f8..6d106e74265e 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -621,9 +621,9 @@ static int __init aircable_init(void)
621 goto failed_usb_register; 621 goto failed_usb_register;
622 return 0; 622 return 0;
623 623
624failed_serial_register:
625 usb_serial_deregister(&aircable_device);
626failed_usb_register: 624failed_usb_register:
625 usb_serial_deregister(&aircable_device);
626failed_serial_register:
627 return retval; 627 return retval;
628} 628}
629 629
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 75597337583e..f92f4d773374 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -662,6 +662,7 @@ static struct usb_device_id id_table_combined [] = {
662 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, 662 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
663 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) }, 663 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
664 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) }, 664 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) },
665 { USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID) },
665 { }, /* Optional parameter entry */ 666 { }, /* Optional parameter entry */
666 { } /* Terminating entry */ 667 { } /* Terminating entry */
667}; 668};
@@ -1064,8 +1065,10 @@ static int set_serial_info(struct tty_struct *tty,
1064 1065
1065 if (!capable(CAP_SYS_ADMIN)) { 1066 if (!capable(CAP_SYS_ADMIN)) {
1066 if (((new_serial.flags & ~ASYNC_USR_MASK) != 1067 if (((new_serial.flags & ~ASYNC_USR_MASK) !=
1067 (priv->flags & ~ASYNC_USR_MASK))) 1068 (priv->flags & ~ASYNC_USR_MASK))) {
1069 unlock_kernel();
1068 return -EPERM; 1070 return -EPERM;
1071 }
1069 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | 1072 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) |
1070 (new_serial.flags & ASYNC_USR_MASK)); 1073 (new_serial.flags & ASYNC_USR_MASK));
1071 priv->custom_divisor = new_serial.custom_divisor; 1074 priv->custom_divisor = new_serial.custom_divisor;
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 1b62eff475d2..e300c840f8ca 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -844,6 +844,9 @@
844#define TML_VID 0x1B91 /* Vendor ID */ 844#define TML_VID 0x1B91 /* Vendor ID */
845#define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */ 845#define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */
846 846
847/* NDI Polaris System */
848#define FTDI_NDI_HUC_PID 0xDA70
849
847/* Propox devices */ 850/* Propox devices */
848#define FTDI_PROPOX_JTAGCABLEII_PID 0xD738 851#define FTDI_PROPOX_JTAGCABLEII_PID 0xD738
849 852
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6c89da9c6fea..bfd0b68ceccd 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -199,14 +199,15 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
199#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 199#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
200 200
201/* FUTURE NOVATEL PRODUCTS */ 201/* FUTURE NOVATEL PRODUCTS */
202#define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 202#define NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED 0X6000
203#define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 203#define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0X6001
204#define NOVATELWIRELESS_PRODUCT_EMBEDDED_1 0x8000 204#define NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED 0X7000
205#define NOVATELWIRELESS_PRODUCT_GLOBAL_1 0x9000 205#define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED 0X7001
206#define NOVATELWIRELESS_PRODUCT_EVDO_2 0x6001 206#define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED 0X8000
207#define NOVATELWIRELESS_PRODUCT_HSPA_2 0x7001 207#define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0X8001
208#define NOVATELWIRELESS_PRODUCT_EMBEDDED_2 0x8001 208#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0X9000
209#define NOVATELWIRELESS_PRODUCT_GLOBAL_2 0x9001 209#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0X9001
210#define NOVATELWIRELESS_PRODUCT_GLOBAL 0XA001
210 211
211/* AMOI PRODUCTS */ 212/* AMOI PRODUCTS */
212#define AMOI_VENDOR_ID 0x1614 213#define AMOI_VENDOR_ID 0x1614
@@ -216,6 +217,27 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
216 217
217#define DELL_VENDOR_ID 0x413C 218#define DELL_VENDOR_ID 0x413C
218 219
220/* Dell modems */
221#define DELL_PRODUCT_5700_MINICARD 0x8114
222#define DELL_PRODUCT_5500_MINICARD 0x8115
223#define DELL_PRODUCT_5505_MINICARD 0x8116
224#define DELL_PRODUCT_5700_EXPRESSCARD 0x8117
225#define DELL_PRODUCT_5510_EXPRESSCARD 0x8118
226
227#define DELL_PRODUCT_5700_MINICARD_SPRINT 0x8128
228#define DELL_PRODUCT_5700_MINICARD_TELUS 0x8129
229
230#define DELL_PRODUCT_5720_MINICARD_VZW 0x8133
231#define DELL_PRODUCT_5720_MINICARD_SPRINT 0x8134
232#define DELL_PRODUCT_5720_MINICARD_TELUS 0x8135
233#define DELL_PRODUCT_5520_MINICARD_CINGULAR 0x8136
234#define DELL_PRODUCT_5520_MINICARD_GENERIC_L 0x8137
235#define DELL_PRODUCT_5520_MINICARD_GENERIC_I 0x8138
236
237#define DELL_PRODUCT_5730_MINICARD_SPRINT 0x8180
238#define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181
239#define DELL_PRODUCT_5730_MINICARD_VZW 0x8182
240
219#define KYOCERA_VENDOR_ID 0x0c88 241#define KYOCERA_VENDOR_ID 0x0c88
220#define KYOCERA_PRODUCT_KPC650 0x17da 242#define KYOCERA_PRODUCT_KPC650 0x17da
221#define KYOCERA_PRODUCT_KPC680 0x180a 243#define KYOCERA_PRODUCT_KPC680 0x180a
@@ -274,12 +296,6 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
274#define ERICSSON_VENDOR_ID 0x0bdb 296#define ERICSSON_VENDOR_ID 0x0bdb
275#define ERICSSON_PRODUCT_F3507G 0x1900 297#define ERICSSON_PRODUCT_F3507G 0x1900
276 298
277/* Pantech products */
278#define PANTECH_VENDOR_ID 0x106c
279#define PANTECH_PRODUCT_PC5740 0x3701
280#define PANTECH_PRODUCT_PC5750 0x3702 /* PX-500 */
281#define PANTECH_PRODUCT_UM150 0x3711
282
283static struct usb_device_id option_ids[] = { 299static struct usb_device_id option_ids[] = {
284 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 300 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
285 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 301 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -395,31 +411,37 @@ static struct usb_device_id option_ids[] = {
395 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ 411 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */
396 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ 412 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */
397 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ 413 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */
398 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ 414 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED) }, /* Novatel EVDO product */
399 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ 415 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */
400 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ 416 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */
401 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_GLOBAL_1) }, /* Novatel Global product */ 417 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, /* Novatel HSPA Embedded product */
402 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_2) }, /* Novatel EVDO product */ 418 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED) }, /* Novatel EVDO product */
403 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_2) }, /* Novatel HSPA product */ 419 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED) }, /* Novatel HSPA product */
404 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_2) }, /* Novatel Embedded product */ 420 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED) }, /* Novatel EVDO Embedded product */
405 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_GLOBAL_2) }, /* Novatel Global product */ 421 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED) }, /* Novatel HSPA Embedded product */
422 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_GLOBAL) }, /* Novatel Global product */
406 423
407 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, 424 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) },
408 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, 425 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) },
409 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) }, 426 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) },
410 427
411 { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ 428 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */
412 { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ 429 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5500_MINICARD) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
413 { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ 430 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5505_MINICARD) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
414 { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ 431 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_EXPRESSCARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */
415 { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ 432 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5510_EXPRESSCARD) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */
416 { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ 433 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD_SPRINT) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */
417 { USB_DEVICE(DELL_VENDOR_ID, 0x8129) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite ET620 CDMA/EV-DO */ 434 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD_TELUS) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite ET620 CDMA/EV-DO */
418 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 435 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_VZW) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
419 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 436 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_SPRINT) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
420 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ 437 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_TELUS) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
421 { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ 438 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_CINGULAR) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */
422 { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */ 439 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_L) }, /* Dell Wireless HSDPA 5520 */
440 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_I) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */
441 { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */
442 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
443 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
444 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
423 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ 445 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */
424 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 446 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
425 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, 447 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) },
@@ -488,9 +510,6 @@ static struct usb_device_id option_ids[] = {
488 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, 510 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) },
489 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, 511 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) },
490 { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G) }, 512 { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G) },
491 { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5740) },
492 { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5750) },
493 { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_UM150) },
494 { } /* Terminating entry */ 513 { } /* Terminating entry */
495}; 514};
496MODULE_DEVICE_TABLE(usb, option_ids); 515MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index baf591137b80..2620bf6fe5e1 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -176,7 +176,7 @@ static unsigned int product_5052_count;
176/* the array dimension is the number of default entries plus */ 176/* the array dimension is the number of default entries plus */
177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */ 177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
178/* null entry */ 178/* null entry */
179static struct usb_device_id ti_id_table_3410[7+TI_EXTRA_VID_PID_COUNT+1] = { 179static struct usb_device_id ti_id_table_3410[10+TI_EXTRA_VID_PID_COUNT+1] = {
180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
182 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 182 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -185,9 +185,11 @@ static struct usb_device_id ti_id_table_3410[7+TI_EXTRA_VID_PID_COUNT+1] = {
185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) }, 185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) }, 186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
187 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 187 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
188 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
189 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
188}; 190};
189 191
190static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 192static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
191 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
192 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 194 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 195 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -195,7 +197,7 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
195 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 197 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
196}; 198};
197 199
198static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] = { 200static struct usb_device_id ti_id_table_combined[14+2*TI_EXTRA_VID_PID_COUNT+1] = {
199 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 201 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
200 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 202 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
201 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 203 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -208,6 +210,8 @@ static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] =
208 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 210 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
209 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 211 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
210 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 212 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
213 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
214 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
211 { } 215 { }
212}; 216};
213 217
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index b7ea5dbadee5..f323c6025858 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -30,6 +30,8 @@
30#define IBM_VENDOR_ID 0x04b3 30#define IBM_VENDOR_ID 0x04b3
31#define TI_3410_PRODUCT_ID 0x3410 31#define TI_3410_PRODUCT_ID 0x3410
32#define IBM_4543_PRODUCT_ID 0x4543 32#define IBM_4543_PRODUCT_ID 0x4543
33#define IBM_454B_PRODUCT_ID 0x454b
34#define IBM_454C_PRODUCT_ID 0x454c
33#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */ 35#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */
34#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */ 36#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */
35#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */ 37#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 2a42b862aa9f..727c506417cc 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -64,6 +64,7 @@
64 */ 64 */
65#define VENDOR_ID_NOKIA 0x0421 65#define VENDOR_ID_NOKIA 0x0421
66#define VENDOR_ID_NIKON 0x04b0 66#define VENDOR_ID_NIKON 0x04b0
67#define VENDOR_ID_PENTAX 0x0a17
67#define VENDOR_ID_MOTOROLA 0x22b8 68#define VENDOR_ID_MOTOROLA 0x22b8
68 69
69/*********************************************************************** 70/***********************************************************************
@@ -158,6 +159,7 @@ static int slave_configure(struct scsi_device *sdev)
158 switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) { 159 switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) {
159 case VENDOR_ID_NOKIA: 160 case VENDOR_ID_NOKIA:
160 case VENDOR_ID_NIKON: 161 case VENDOR_ID_NIKON:
162 case VENDOR_ID_PENTAX:
161 case VENDOR_ID_MOTOROLA: 163 case VENDOR_ID_MOTOROLA:
162 if (!(us->fflags & (US_FL_FIX_CAPACITY | 164 if (!(us->fflags & (US_FL_FIX_CAPACITY |
163 US_FL_CAPACITY_OK))) 165 US_FL_CAPACITY_OK)))
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 1d5438e6363b..fb65d221cedf 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -558,32 +558,10 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
558 558
559 if (srb->result == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) { 559 if (srb->result == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) {
560 560
561 /* The command succeeded. If the capacity is odd 561 /* The command succeeded. We know this device doesn't
562 * (i.e., if the sector number is even) then the 562 * have the last-sector bug, so stop checking it.
563 * "always-even" heuristic would be wrong for this
564 * device. Issue a WARN() so that the kerneloops.org
565 * project will be notified and we will then know to
566 * mark the device with a CAPACITY_OK flag. Hopefully
567 * this will occur for only a few devices.
568 *
569 * Use the sign of us->last_sector_hacks to tell whether
570 * the warning has already been issued; we don't need
571 * more than one warning per device.
572 */ 563 */
573 if (!(sector & 1) && us->use_last_sector_hacks > 0) { 564 us->use_last_sector_hacks = 0;
574 unsigned vid = le16_to_cpu(
575 us->pusb_dev->descriptor.idVendor);
576 unsigned pid = le16_to_cpu(
577 us->pusb_dev->descriptor.idProduct);
578 unsigned rev = le16_to_cpu(
579 us->pusb_dev->descriptor.bcdDevice);
580
581 WARN(1, "%s: Successful last sector success at %u, "
582 "device %04x:%04x:%04x\n",
583 sdkp->disk->disk_name, sector,
584 vid, pid, rev);
585 us->use_last_sector_hacks = -1;
586 }
587 565
588 } else { 566 } else {
589 /* The command failed. Allow up to 3 retries in case this 567 /* The command failed. Allow up to 3 retries in case this
@@ -599,14 +577,6 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
599 srb->result = SAM_STAT_CHECK_CONDITION; 577 srb->result = SAM_STAT_CHECK_CONDITION;
600 memcpy(srb->sense_buffer, record_not_found, 578 memcpy(srb->sense_buffer, record_not_found,
601 sizeof(record_not_found)); 579 sizeof(record_not_found));
602
603 /* In theory we might want to issue a WARN() here if the
604 * capacity is even, since it could indicate the device
605 * has the READ CAPACITY bug _and_ the real capacity is
606 * odd. But it could also indicate that the device
607 * simply can't access its last sector, a failure mode
608 * which is surprisingly common. So no warning.
609 */
610 } 580 }
611 581
612 done: 582 done:
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 69269f739563..50dc33a6065b 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1214,7 +1214,7 @@ UNUSUAL_DEV( 0x07c4, 0xa400, 0x0000, 0xffff,
1214 "Datafab", 1214 "Datafab",
1215 "KECF-USB", 1215 "KECF-USB",
1216 US_SC_DEVICE, US_PR_DEVICE, NULL, 1216 US_SC_DEVICE, US_PR_DEVICE, NULL,
1217 US_FL_FIX_INQUIRY ), 1217 US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY ),
1218 1218
1219/* Reported by Rauch Wolke <rauchwolke@gmx.net> */ 1219/* Reported by Rauch Wolke <rauchwolke@gmx.net> */
1220UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff, 1220UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff,
@@ -1354,21 +1354,6 @@ UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
1354 US_SC_DEVICE, US_PR_DEVICE, NULL, 1354 US_SC_DEVICE, US_PR_DEVICE, NULL,
1355 US_FL_FIX_INQUIRY ), 1355 US_FL_FIX_INQUIRY ),
1356 1356
1357
1358/* Submitted by Per Winkvist <per.winkvist@uk.com> */
1359UNUSUAL_DEV( 0x0a17, 0x006, 0x0000, 0xffff,
1360 "Pentax",
1361 "Optio S/S4",
1362 US_SC_DEVICE, US_PR_DEVICE, NULL,
1363 US_FL_FIX_INQUIRY ),
1364
1365/* Reported by Jaak Ristioja <Ristioja@gmail.com> */
1366UNUSUAL_DEV( 0x0a17, 0x006e, 0x0100, 0x0100,
1367 "Pentax",
1368 "K10D",
1369 US_SC_DEVICE, US_PR_DEVICE, NULL,
1370 US_FL_FIX_CAPACITY ),
1371
1372/* These are virtual windows driver CDs, which the zd1211rw driver 1357/* These are virtual windows driver CDs, which the zd1211rw driver
1373 * automatically converts into WLAN devices. */ 1358 * automatically converts into WLAN devices. */
1374UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101, 1359UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101,
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index f0267706cb45..fb19803060cf 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1054,9 +1054,7 @@ config FB_RIVA_BACKLIGHT
1054 1054
1055config FB_I810 1055config FB_I810
1056 tristate "Intel 810/815 support (EXPERIMENTAL)" 1056 tristate "Intel 810/815 support (EXPERIMENTAL)"
1057 depends on FB && EXPERIMENTAL && PCI && X86_32 1057 depends on EXPERIMENTAL && FB && PCI && X86_32 && AGP_INTEL
1058 select AGP
1059 select AGP_INTEL
1060 select FB_MODE_HELPERS 1058 select FB_MODE_HELPERS
1061 select FB_CFB_FILLRECT 1059 select FB_CFB_FILLRECT
1062 select FB_CFB_COPYAREA 1060 select FB_CFB_COPYAREA
@@ -1119,9 +1117,7 @@ config FB_CARILLO_RANCH
1119 1117
1120config FB_INTEL 1118config FB_INTEL
1121 tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G/945GM/965G/965GM support (EXPERIMENTAL)" 1119 tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G/945GM/965G/965GM support (EXPERIMENTAL)"
1122 depends on FB && EXPERIMENTAL && PCI && X86 1120 depends on EXPERIMENTAL && FB && PCI && X86 && AGP_INTEL
1123 select AGP
1124 select AGP_INTEL
1125 select FB_MODE_HELPERS 1121 select FB_MODE_HELPERS
1126 select FB_CFB_FILLRECT 1122 select FB_CFB_FILLRECT
1127 select FB_CFB_COPYAREA 1123 select FB_CFB_COPYAREA
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index 8058572a7428..018850c116c6 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -841,7 +841,7 @@ static int tt_detect(void)
841 tt_dmasnd.ctrl = DMASND_CTRL_OFF; 841 tt_dmasnd.ctrl = DMASND_CTRL_OFF;
842 udelay(20); /* wait a while for things to settle down */ 842 udelay(20); /* wait a while for things to settle down */
843 } 843 }
844 mono_moni = (mfp.par_dt_reg & 0x80) == 0; 844 mono_moni = (st_mfp.par_dt_reg & 0x80) == 0;
845 845
846 tt_get_par(&par); 846 tt_get_par(&par);
847 tt_encode_var(&atafb_predefined[0], &par); 847 tt_encode_var(&atafb_predefined[0], &par);
@@ -2035,7 +2035,7 @@ static int stste_detect(void)
2035 tt_dmasnd.ctrl = DMASND_CTRL_OFF; 2035 tt_dmasnd.ctrl = DMASND_CTRL_OFF;
2036 udelay(20); /* wait a while for things to settle down */ 2036 udelay(20); /* wait a while for things to settle down */
2037 } 2037 }
2038 mono_moni = (mfp.par_dt_reg & 0x80) == 0; 2038 mono_moni = (st_mfp.par_dt_reg & 0x80) == 0;
2039 2039
2040 stste_get_par(&par); 2040 stste_get_par(&par);
2041 stste_encode_var(&atafb_predefined[0], &par); 2041 stste_encode_var(&atafb_predefined[0], &par);
@@ -2086,20 +2086,20 @@ static void st_ovsc_switch(void)
2086 return; 2086 return;
2087 local_irq_save(flags); 2087 local_irq_save(flags);
2088 2088
2089 mfp.tim_ct_b = 0x10; 2089 st_mfp.tim_ct_b = 0x10;
2090 mfp.active_edge |= 8; 2090 st_mfp.active_edge |= 8;
2091 mfp.tim_ct_b = 0; 2091 st_mfp.tim_ct_b = 0;
2092 mfp.tim_dt_b = 0xf0; 2092 st_mfp.tim_dt_b = 0xf0;
2093 mfp.tim_ct_b = 8; 2093 st_mfp.tim_ct_b = 8;
2094 while (mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */ 2094 while (st_mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */
2095 ; 2095 ;
2096 new = mfp.tim_dt_b; 2096 new = st_mfp.tim_dt_b;
2097 do { 2097 do {
2098 udelay(LINE_DELAY); 2098 udelay(LINE_DELAY);
2099 old = new; 2099 old = new;
2100 new = mfp.tim_dt_b; 2100 new = st_mfp.tim_dt_b;
2101 } while (old != new); 2101 } while (old != new);
2102 mfp.tim_ct_b = 0x10; 2102 st_mfp.tim_ct_b = 0x10;
2103 udelay(SYNC_DELAY); 2103 udelay(SYNC_DELAY);
2104 2104
2105 if (atari_switches & ATARI_SWITCH_OVSC_IKBD) 2105 if (atari_switches & ATARI_SWITCH_OVSC_IKBD)
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index db16112cf197..2181ce4d7ebd 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1475,7 +1475,7 @@ static int aty128fb_set_par(struct fb_info *info)
1475 aty128_set_pll(&par->pll, par); 1475 aty128_set_pll(&par->pll, par);
1476 aty128_set_fifo(&par->fifo_reg, par); 1476 aty128_set_fifo(&par->fifo_reg, par);
1477 1477
1478 config = aty_ld_le32(CONFIG_CNTL) & ~3; 1478 config = aty_ld_le32(CNFG_CNTL) & ~3;
1479 1479
1480#if defined(__BIG_ENDIAN) 1480#if defined(__BIG_ENDIAN)
1481 if (par->crtc.bpp == 32) 1481 if (par->crtc.bpp == 32)
@@ -1484,7 +1484,7 @@ static int aty128fb_set_par(struct fb_info *info)
1484 config |= 1; /* make aperture do 16 bit swapping */ 1484 config |= 1; /* make aperture do 16 bit swapping */
1485#endif 1485#endif
1486 1486
1487 aty_st_le32(CONFIG_CNTL, config); 1487 aty_st_le32(CNFG_CNTL, config);
1488 aty_st_8(CRTC_EXT_CNTL + 1, 0); /* turn the video back on */ 1488 aty_st_8(CRTC_EXT_CNTL + 1, 0); /* turn the video back on */
1489 1489
1490 info->fix.line_length = (par->crtc.vxres * par->crtc.bpp) >> 3; 1490 info->fix.line_length = (par->crtc.vxres * par->crtc.bpp) >> 3;
@@ -1875,7 +1875,7 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
1875 u32 dac; 1875 u32 dac;
1876 1876
1877 /* Get the chip revision */ 1877 /* Get the chip revision */
1878 chip_rev = (aty_ld_le32(CONFIG_CNTL) >> 16) & 0x1F; 1878 chip_rev = (aty_ld_le32(CNFG_CNTL) >> 16) & 0x1F;
1879 1879
1880 strcpy(video_card, "Rage128 XX "); 1880 strcpy(video_card, "Rage128 XX ");
1881 video_card[8] = ent->device >> 8; 1881 video_card[8] = ent->device >> 8;
@@ -2057,7 +2057,7 @@ static int __devinit aty128_probe(struct pci_dev *pdev, const struct pci_device_
2057 2057
2058 /* Grab memory size from the card */ 2058 /* Grab memory size from the card */
2059 // How does this relate to the resource length from the PCI hardware? 2059 // How does this relate to the resource length from the PCI hardware?
2060 par->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF; 2060 par->vram_size = aty_ld_le32(CNFG_MEMSIZE) & 0x03FFFFFF;
2061 2061
2062 /* Virtualize the framebuffer */ 2062 /* Virtualize the framebuffer */
2063 info->screen_base = ioremap(fb_addr, par->vram_size); 2063 info->screen_base = ioremap(fb_addr, par->vram_size);
@@ -2365,7 +2365,6 @@ static void fbcon_aty128_bmove(struct display *p, int sy, int sx, int dy, int dx
2365static void aty128_set_suspend(struct aty128fb_par *par, int suspend) 2365static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
2366{ 2366{
2367 u32 pmgt; 2367 u32 pmgt;
2368 u16 pwr_command;
2369 struct pci_dev *pdev = par->pdev; 2368 struct pci_dev *pdev = par->pdev;
2370 2369
2371 if (!par->pm_reg) 2370 if (!par->pm_reg)
@@ -2374,6 +2373,8 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
2374 /* Set the chip into the appropriate suspend mode (we use D2, 2373 /* Set the chip into the appropriate suspend mode (we use D2,
2375 * D3 would require a complete re-initialisation of the chip, 2374 * D3 would require a complete re-initialisation of the chip,
2376 * including PCI config registers, clocks, AGP configuration, ...) 2375 * including PCI config registers, clocks, AGP configuration, ...)
2376 *
2377 * For resume, the core will have already brought us back to D0
2377 */ 2378 */
2378 if (suspend) { 2379 if (suspend) {
2379 /* Make sure CRTC2 is reset. Remove that the day we decide to 2380 /* Make sure CRTC2 is reset. Remove that the day we decide to
@@ -2391,17 +2392,9 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
2391 aty_st_le32(BUS_CNTL1, 0x00000010); 2392 aty_st_le32(BUS_CNTL1, 0x00000010);
2392 aty_st_le32(MEM_POWER_MISC, 0x0c830000); 2393 aty_st_le32(MEM_POWER_MISC, 0x0c830000);
2393 mdelay(100); 2394 mdelay(100);
2394 pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command); 2395
2395 /* Switch PCI power management to D2 */ 2396 /* Switch PCI power management to D2 */
2396 pci_write_config_word(pdev, par->pm_reg+PCI_PM_CTRL, 2397 pci_set_power_state(pdev, PCI_D2);
2397 (pwr_command & ~PCI_PM_CTRL_STATE_MASK) | 2);
2398 pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command);
2399 } else {
2400 /* Switch back PCI power management to D0 */
2401 mdelay(100);
2402 pci_write_config_word(pdev, par->pm_reg+PCI_PM_CTRL, 0);
2403 pci_read_config_word(pdev, par->pm_reg+PCI_PM_CTRL, &pwr_command);
2404 mdelay(100);
2405 } 2398 }
2406} 2399}
2407 2400
@@ -2410,6 +2403,12 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2410 struct fb_info *info = pci_get_drvdata(pdev); 2403 struct fb_info *info = pci_get_drvdata(pdev);
2411 struct aty128fb_par *par = info->par; 2404 struct aty128fb_par *par = info->par;
2412 2405
2406 /* Because we may change PCI D state ourselves, we need to
2407 * first save the config space content so the core can
2408 * restore it properly on resume.
2409 */
2410 pci_save_state(pdev);
2411
2413 /* We don't do anything but D2, for now we return 0, but 2412 /* We don't do anything but D2, for now we return 0, but
2414 * we may want to change that. How do we know if the BIOS 2413 * we may want to change that. How do we know if the BIOS
2415 * can properly take care of D3 ? Also, with swsusp, we 2414 * can properly take care of D3 ? Also, with swsusp, we
@@ -2476,6 +2475,11 @@ static int aty128_do_resume(struct pci_dev *pdev)
2476 if (pdev->dev.power.power_state.event == PM_EVENT_ON) 2475 if (pdev->dev.power.power_state.event == PM_EVENT_ON)
2477 return 0; 2476 return 0;
2478 2477
2478 /* PCI state will have been restored by the core, so
2479 * we should be in D0 now with our config space fully
2480 * restored
2481 */
2482
2479 /* Wakeup chip */ 2483 /* Wakeup chip */
2480 aty128_set_suspend(par, 0); 2484 aty128_set_suspend(par, 0);
2481 par->asleep = 0; 2485 par->asleep = 0;
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index cc6b470073da..1207c208a30b 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -135,7 +135,7 @@
135#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \ 135#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \
136defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT) 136defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT)
137static const u32 lt_lcd_regs[] = { 137static const u32 lt_lcd_regs[] = {
138 CONFIG_PANEL_LG, 138 CNFG_PANEL_LG,
139 LCD_GEN_CNTL_LG, 139 LCD_GEN_CNTL_LG,
140 DSTN_CONTROL_LG, 140 DSTN_CONTROL_LG,
141 HFB_PITCH_ADDR_LG, 141 HFB_PITCH_ADDR_LG,
@@ -446,7 +446,7 @@ static int __devinit correct_chipset(struct atyfb_par *par)
446 par->pll_limits.ecp_max = aty_chips[i].ecp_max; 446 par->pll_limits.ecp_max = aty_chips[i].ecp_max;
447 par->features = aty_chips[i].features; 447 par->features = aty_chips[i].features;
448 448
449 chip_id = aty_ld_le32(CONFIG_CHIP_ID, par); 449 chip_id = aty_ld_le32(CNFG_CHIP_ID, par);
450 type = chip_id & CFG_CHIP_TYPE; 450 type = chip_id & CFG_CHIP_TYPE;
451 rev = (chip_id & CFG_CHIP_REV) >> 24; 451 rev = (chip_id & CFG_CHIP_REV) >> 24;
452 452
@@ -629,7 +629,7 @@ static void aty_get_crtc(const struct atyfb_par *par, struct crtc *crtc)
629 crtc->lcd_index = aty_ld_le32(LCD_INDEX, par); 629 crtc->lcd_index = aty_ld_le32(LCD_INDEX, par);
630 aty_st_le32(LCD_INDEX, crtc->lcd_index, par); 630 aty_st_le32(LCD_INDEX, crtc->lcd_index, par);
631 } 631 }
632 crtc->lcd_config_panel = aty_ld_lcd(CONFIG_PANEL, par); 632 crtc->lcd_config_panel = aty_ld_lcd(CNFG_PANEL, par);
633 crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par); 633 crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par);
634 634
635 635
@@ -676,7 +676,7 @@ static void aty_set_crtc(const struct atyfb_par *par, const struct crtc *crtc)
676 aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl & ~(CRTC_EXT_DISP_EN | CRTC_EN), par); 676 aty_st_le32(CRTC_GEN_CNTL, crtc->gen_cntl & ~(CRTC_EXT_DISP_EN | CRTC_EN), par);
677 677
678 /* update non-shadow registers first */ 678 /* update non-shadow registers first */
679 aty_st_lcd(CONFIG_PANEL, crtc->lcd_config_panel, par); 679 aty_st_lcd(CNFG_PANEL, crtc->lcd_config_panel, par);
680 aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl & 680 aty_st_lcd(LCD_GEN_CNTL, crtc->lcd_gen_cntl &
681 ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par); 681 ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN), par);
682 682
@@ -858,7 +858,7 @@ static int aty_var_to_crtc(const struct fb_info *info,
858 if (!M64_HAS(MOBIL_BUS)) 858 if (!M64_HAS(MOBIL_BUS))
859 crtc->lcd_index |= CRTC2_DISPLAY_DIS; 859 crtc->lcd_index |= CRTC2_DISPLAY_DIS;
860 860
861 crtc->lcd_config_panel = aty_ld_lcd(CONFIG_PANEL, par) | 0x4000; 861 crtc->lcd_config_panel = aty_ld_lcd(CNFG_PANEL, par) | 0x4000;
862 crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par) & ~CRTC_RW_SELECT; 862 crtc->lcd_gen_cntl = aty_ld_lcd(LCD_GEN_CNTL, par) & ~CRTC_RW_SELECT;
863 863
864 crtc->lcd_gen_cntl &= 864 crtc->lcd_gen_cntl &=
@@ -1978,7 +1978,7 @@ static int aty_power_mgmt(int sleep, struct atyfb_par *par)
1978 1978
1979 return timeout ? 0 : -EIO; 1979 return timeout ? 0 : -EIO;
1980} 1980}
1981#endif 1981#endif /* CONFIG_PPC_PMAC */
1982 1982
1983static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) 1983static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
1984{ 1984{
@@ -2002,9 +2002,15 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2002 par->asleep = 1; 2002 par->asleep = 1;
2003 par->lock_blank = 1; 2003 par->lock_blank = 1;
2004 2004
2005 /* Because we may change PCI D state ourselves, we need to
2006 * first save the config space content so the core can
2007 * restore it properly on resume.
2008 */
2009 pci_save_state(pdev);
2010
2005#ifdef CONFIG_PPC_PMAC 2011#ifdef CONFIG_PPC_PMAC
2006 /* Set chip to "suspend" mode */ 2012 /* Set chip to "suspend" mode */
2007 if (aty_power_mgmt(1, par)) { 2013 if (machine_is(powermac) && aty_power_mgmt(1, par)) {
2008 par->asleep = 0; 2014 par->asleep = 0;
2009 par->lock_blank = 0; 2015 par->lock_blank = 0;
2010 atyfb_blank(FB_BLANK_UNBLANK, info); 2016 atyfb_blank(FB_BLANK_UNBLANK, info);
@@ -2047,11 +2053,15 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2047 2053
2048 acquire_console_sem(); 2054 acquire_console_sem();
2049 2055
2056 /* PCI state will have been restored by the core, so
2057 * we should be in D0 now with our config space fully
2058 * restored
2059 */
2060
2050#ifdef CONFIG_PPC_PMAC 2061#ifdef CONFIG_PPC_PMAC
2051 if (pdev->dev.power.power_state.event == 2) 2062 if (machine_is(powermac) &&
2063 pdev->dev.power.power_state.event == PM_EVENT_SUSPEND)
2052 aty_power_mgmt(0, par); 2064 aty_power_mgmt(0, par);
2053#else
2054 pci_set_power_state(pdev, PCI_D0);
2055#endif 2065#endif
2056 2066
2057 aty_resume_chip(info); 2067 aty_resume_chip(info);
@@ -2254,7 +2264,7 @@ static int __devinit aty_init(struct fb_info *info)
2254 if (!M64_HAS(INTEGRATED)) { 2264 if (!M64_HAS(INTEGRATED)) {
2255 u32 stat0; 2265 u32 stat0;
2256 u8 dac_type, dac_subtype, clk_type; 2266 u8 dac_type, dac_subtype, clk_type;
2257 stat0 = aty_ld_le32(CONFIG_STAT0, par); 2267 stat0 = aty_ld_le32(CNFG_STAT0, par);
2258 par->bus_type = (stat0 >> 0) & 0x07; 2268 par->bus_type = (stat0 >> 0) & 0x07;
2259 par->ram_type = (stat0 >> 3) & 0x07; 2269 par->ram_type = (stat0 >> 3) & 0x07;
2260 ramname = aty_gx_ram[par->ram_type]; 2270 ramname = aty_gx_ram[par->ram_type];
@@ -2324,7 +2334,7 @@ static int __devinit aty_init(struct fb_info *info)
2324 par->dac_ops = &aty_dac_ct; 2334 par->dac_ops = &aty_dac_ct;
2325 par->pll_ops = &aty_pll_ct; 2335 par->pll_ops = &aty_pll_ct;
2326 par->bus_type = PCI; 2336 par->bus_type = PCI;
2327 par->ram_type = (aty_ld_le32(CONFIG_STAT0, par) & 0x07); 2337 par->ram_type = (aty_ld_le32(CNFG_STAT0, par) & 0x07);
2328 ramname = aty_ct_ram[par->ram_type]; 2338 ramname = aty_ct_ram[par->ram_type];
2329 /* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz otherwise */ 2339 /* for many chips, the mclk is 67 MHz for SDRAM, 63 MHz otherwise */
2330 if (par->pll_limits.mclk == 67 && par->ram_type < SDRAM) 2340 if (par->pll_limits.mclk == 67 && par->ram_type < SDRAM)
@@ -2433,7 +2443,7 @@ static int __devinit aty_init(struct fb_info *info)
2433 } 2443 }
2434 2444
2435 if (M64_HAS(MAGIC_VRAM_SIZE)) { 2445 if (M64_HAS(MAGIC_VRAM_SIZE)) {
2436 if (aty_ld_le32(CONFIG_STAT1, par) & 0x40000000) 2446 if (aty_ld_le32(CNFG_STAT1, par) & 0x40000000)
2437 info->fix.smem_len += 0x400000; 2447 info->fix.smem_len += 0x400000;
2438 } 2448 }
2439 2449
@@ -2946,7 +2956,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
2946 * Fix PROMs idea of MEM_CNTL settings... 2956 * Fix PROMs idea of MEM_CNTL settings...
2947 */ 2957 */
2948 mem = aty_ld_le32(MEM_CNTL, par); 2958 mem = aty_ld_le32(MEM_CNTL, par);
2949 chip_id = aty_ld_le32(CONFIG_CHIP_ID, par); 2959 chip_id = aty_ld_le32(CNFG_CHIP_ID, par);
2950 if (((chip_id & CFG_CHIP_TYPE) == VT_CHIP_ID) && !((chip_id >> 24) & 1)) { 2960 if (((chip_id & CFG_CHIP_TYPE) == VT_CHIP_ID) && !((chip_id >> 24) & 1)) {
2951 switch (mem & 0x0f) { 2961 switch (mem & 0x0f) {
2952 case 3: 2962 case 3:
@@ -2964,7 +2974,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
2964 default: 2974 default:
2965 break; 2975 break;
2966 } 2976 }
2967 if ((aty_ld_le32(CONFIG_STAT0, par) & 7) >= SDRAM) 2977 if ((aty_ld_le32(CNFG_STAT0, par) & 7) >= SDRAM)
2968 mem &= ~(0x00700000); 2978 mem &= ~(0x00700000);
2969 } 2979 }
2970 mem &= ~(0xcf80e000); /* Turn off all undocumented bits. */ 2980 mem &= ~(0xcf80e000); /* Turn off all undocumented bits. */
@@ -3572,7 +3582,7 @@ static int __init atyfb_atari_probe(void)
3572 } 3582 }
3573 3583
3574 /* Fake pci_id for correct_chipset() */ 3584 /* Fake pci_id for correct_chipset() */
3575 switch (aty_ld_le32(CONFIG_CHIP_ID, par) & CFG_CHIP_TYPE) { 3585 switch (aty_ld_le32(CNFG_CHIP_ID, par) & CFG_CHIP_TYPE) {
3576 case 0x00d7: 3586 case 0x00d7:
3577 par->pci_id = PCI_CHIP_MACH64GX; 3587 par->pci_id = PCI_CHIP_MACH64GX;
3578 break; 3588 break;
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index d0f1a7fc2c9d..16bb7e3c0310 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -1936,8 +1936,8 @@ static void fixup_memory_mappings(struct radeonfb_info *rinfo)
1936 OUTREG(CRTC_GEN_CNTL, save_crtc_gen_cntl | CRTC_DISP_REQ_EN_B); 1936 OUTREG(CRTC_GEN_CNTL, save_crtc_gen_cntl | CRTC_DISP_REQ_EN_B);
1937 mdelay(100); 1937 mdelay(100);
1938 1938
1939 aper_base = INREG(CONFIG_APER_0_BASE); 1939 aper_base = INREG(CNFG_APER_0_BASE);
1940 aper_size = INREG(CONFIG_APER_SIZE); 1940 aper_size = INREG(CNFG_APER_SIZE);
1941 1941
1942#ifdef SET_MC_FB_FROM_APERTURE 1942#ifdef SET_MC_FB_FROM_APERTURE
1943 /* Set framebuffer to be at the same address as set in PCI BAR */ 1943 /* Set framebuffer to be at the same address as set in PCI BAR */
@@ -2024,11 +2024,11 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
2024 ~CRTC_H_CUTOFF_ACTIVE_EN); 2024 ~CRTC_H_CUTOFF_ACTIVE_EN);
2025 } 2025 }
2026 } else { 2026 } else {
2027 tmp = INREG(CONFIG_MEMSIZE); 2027 tmp = INREG(CNFG_MEMSIZE);
2028 } 2028 }
2029 2029
2030 /* mem size is bits [28:0], mask off the rest */ 2030 /* mem size is bits [28:0], mask off the rest */
2031 rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK; 2031 rinfo->video_ram = tmp & CNFG_MEMSIZE_MASK;
2032 2032
2033 /* 2033 /*
2034 * Hack to get around some busted production M6's 2034 * Hack to get around some busted production M6's
@@ -2228,7 +2228,7 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev,
2228 */ 2228 */
2229 rinfo->errata = 0; 2229 rinfo->errata = 0;
2230 if (rinfo->family == CHIP_FAMILY_R300 && 2230 if (rinfo->family == CHIP_FAMILY_R300 &&
2231 (INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) 2231 (INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK)
2232 == CFG_ATI_REV_A11) 2232 == CFG_ATI_REV_A11)
2233 rinfo->errata |= CHIP_ERRATA_R300_CG; 2233 rinfo->errata |= CHIP_ERRATA_R300_CG;
2234 2234
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 675abdafc2d8..ca5f0dc28546 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -333,7 +333,7 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo)
333 if (!rinfo->has_CRTC2) { 333 if (!rinfo->has_CRTC2) {
334 tmp = INPLL(pllSCLK_CNTL); 334 tmp = INPLL(pllSCLK_CNTL);
335 335
336 if ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) > CFG_ATI_REV_A13) 336 if ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) > CFG_ATI_REV_A13)
337 tmp &= ~(SCLK_CNTL__FORCE_CP | SCLK_CNTL__FORCE_RB); 337 tmp &= ~(SCLK_CNTL__FORCE_CP | SCLK_CNTL__FORCE_RB);
338 tmp &= ~(SCLK_CNTL__FORCE_HDP | SCLK_CNTL__FORCE_DISP1 | 338 tmp &= ~(SCLK_CNTL__FORCE_HDP | SCLK_CNTL__FORCE_DISP1 |
339 SCLK_CNTL__FORCE_TOP | SCLK_CNTL__FORCE_SE | 339 SCLK_CNTL__FORCE_TOP | SCLK_CNTL__FORCE_SE |
@@ -468,9 +468,9 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo)
468 468
469 /*RAGE_6::A11 A12 A12N1 A13, RV250::A11 A12, R300*/ 469 /*RAGE_6::A11 A12 A12N1 A13, RV250::A11 A12, R300*/
470 if ((rinfo->family == CHIP_FAMILY_RV250 && 470 if ((rinfo->family == CHIP_FAMILY_RV250 &&
471 ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) || 471 ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) ||
472 ((rinfo->family == CHIP_FAMILY_RV100) && 472 ((rinfo->family == CHIP_FAMILY_RV100) &&
473 ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) <= CFG_ATI_REV_A13))) { 473 ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) <= CFG_ATI_REV_A13))) {
474 tmp |= SCLK_CNTL__FORCE_CP; 474 tmp |= SCLK_CNTL__FORCE_CP;
475 tmp |= SCLK_CNTL__FORCE_VIP; 475 tmp |= SCLK_CNTL__FORCE_VIP;
476 } 476 }
@@ -486,7 +486,7 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo)
486 /* RV200::A11 A12 RV250::A11 A12 */ 486 /* RV200::A11 A12 RV250::A11 A12 */
487 if (((rinfo->family == CHIP_FAMILY_RV200) || 487 if (((rinfo->family == CHIP_FAMILY_RV200) ||
488 (rinfo->family == CHIP_FAMILY_RV250)) && 488 (rinfo->family == CHIP_FAMILY_RV250)) &&
489 ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) 489 ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13))
490 tmp |= SCLK_MORE_CNTL__FORCEON; 490 tmp |= SCLK_MORE_CNTL__FORCEON;
491 491
492 OUTPLL(pllSCLK_MORE_CNTL, tmp); 492 OUTPLL(pllSCLK_MORE_CNTL, tmp);
@@ -497,7 +497,7 @@ static void radeon_pm_enable_dynamic_mode(struct radeonfb_info *rinfo)
497 /* RV200::A11 A12, RV250::A11 A12 */ 497 /* RV200::A11 A12, RV250::A11 A12 */
498 if (((rinfo->family == CHIP_FAMILY_RV200) || 498 if (((rinfo->family == CHIP_FAMILY_RV200) ||
499 (rinfo->family == CHIP_FAMILY_RV250)) && 499 (rinfo->family == CHIP_FAMILY_RV250)) &&
500 ((INREG(CONFIG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) { 500 ((INREG(CNFG_CNTL) & CFG_ATI_REV_ID_MASK) < CFG_ATI_REV_A13)) {
501 tmp = INPLL(pllPLL_PWRMGT_CNTL); 501 tmp = INPLL(pllPLL_PWRMGT_CNTL);
502 tmp |= PLL_PWRMGT_CNTL__TCL_BYPASS_DISABLE; 502 tmp |= PLL_PWRMGT_CNTL__TCL_BYPASS_DISABLE;
503 OUTPLL(pllPLL_PWRMGT_CNTL, tmp); 503 OUTPLL(pllPLL_PWRMGT_CNTL, tmp);
@@ -702,7 +702,7 @@ static void radeon_pm_restore_regs(struct radeonfb_info *rinfo)
702 OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]); 702 OUTREG(DISPLAY_BASE_ADDR, rinfo->save_regs[31]);
703 OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]); 703 OUTREG(MC_AGP_LOCATION, rinfo->save_regs[32]);
704 OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]); 704 OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]);
705 OUTREG(CONFIG_MEMSIZE, rinfo->video_ram); 705 OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
706 706
707 OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]); 707 OUTREG(DISP_MISC_CNTL, rinfo->save_regs[9]);
708 OUTREG(DISP_PWR_MAN, rinfo->save_regs[10]); 708 OUTREG(DISP_PWR_MAN, rinfo->save_regs[10]);
@@ -1723,7 +1723,7 @@ static void radeon_reinitialize_M10(struct radeonfb_info *rinfo)
1723 OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]); 1723 OUTREG(CRTC2_DISPLAY_BASE_ADDR, rinfo->save_regs[33]);
1724 OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]); 1724 OUTREG(MC_FB_LOCATION, rinfo->save_regs[30]);
1725 OUTREG(OV0_BASE_ADDR, rinfo->save_regs[80]); 1725 OUTREG(OV0_BASE_ADDR, rinfo->save_regs[80]);
1726 OUTREG(CONFIG_MEMSIZE, rinfo->video_ram); 1726 OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
1727 OUTREG(BUS_CNTL, rinfo->save_regs[36]); 1727 OUTREG(BUS_CNTL, rinfo->save_regs[36]);
1728 OUTREG(BUS_CNTL1, rinfo->save_regs[14]); 1728 OUTREG(BUS_CNTL1, rinfo->save_regs[14]);
1729 OUTREG(MPP_TB_CONFIG, rinfo->save_regs[37]); 1729 OUTREG(MPP_TB_CONFIG, rinfo->save_regs[37]);
@@ -1961,7 +1961,7 @@ static void radeon_pm_m9p_reconfigure_mc(struct radeonfb_info *rinfo)
1961 OUTMC(rinfo, ixMC_CHP_IO_CNTL_B1, rinfo->save_regs[68] /*0x141555ff*/); 1961 OUTMC(rinfo, ixMC_CHP_IO_CNTL_B1, rinfo->save_regs[68] /*0x141555ff*/);
1962 OUTMC(rinfo, ixMC_IMP_CNTL_0, rinfo->save_regs[71] /*0x00009249*/); 1962 OUTMC(rinfo, ixMC_IMP_CNTL_0, rinfo->save_regs[71] /*0x00009249*/);
1963 OUTREG(MC_IND_INDEX, 0); 1963 OUTREG(MC_IND_INDEX, 0);
1964 OUTREG(CONFIG_MEMSIZE, rinfo->video_ram); 1964 OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
1965 1965
1966 mdelay(20); 1966 mdelay(20);
1967} 1967}
@@ -2361,7 +2361,7 @@ static void radeon_reinitialize_QW(struct radeonfb_info *rinfo)
2361 OUTMC(rinfo, ixMC_IMP_CNTL_0, 0x00009249); 2361 OUTMC(rinfo, ixMC_IMP_CNTL_0, 0x00009249);
2362 OUTREG(MC_IND_INDEX, 0); 2362 OUTREG(MC_IND_INDEX, 0);
2363 2363
2364 OUTREG(CONFIG_MEMSIZE, rinfo->video_ram); 2364 OUTREG(CNFG_MEMSIZE, rinfo->video_ram);
2365 2365
2366 radeon_pm_full_reset_sdram(rinfo); 2366 radeon_pm_full_reset_sdram(rinfo);
2367 2367
@@ -2509,9 +2509,7 @@ static void radeon_reinitialize_QW(struct radeonfb_info *rinfo)
2509 2509
2510static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend) 2510static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
2511{ 2511{
2512 u16 pwr_cmd;
2513 u32 tmp; 2512 u32 tmp;
2514 int i;
2515 2513
2516 if (!rinfo->pm_reg) 2514 if (!rinfo->pm_reg)
2517 return; 2515 return;
@@ -2557,32 +2555,14 @@ static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
2557 } 2555 }
2558 } 2556 }
2559 2557
2560 for (i = 0; i < 64; ++i)
2561 pci_read_config_dword(rinfo->pdev, i * 4,
2562 &rinfo->cfg_save[i]);
2563
2564 /* Switch PCI power management to D2. */ 2558 /* Switch PCI power management to D2. */
2565 pci_disable_device(rinfo->pdev); 2559 pci_disable_device(rinfo->pdev);
2566 for (;;) { 2560 pci_save_state(rinfo->pdev);
2567 pci_read_config_word( 2561 pci_set_power_state(rinfo->pdev, PCI_D2);
2568 rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL,
2569 &pwr_cmd);
2570 if (pwr_cmd & 2)
2571 break;
2572 pci_write_config_word(
2573 rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL,
2574 (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | 2);
2575 mdelay(500);
2576 }
2577 } else { 2562 } else {
2578 printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n", 2563 printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n",
2579 pci_name(rinfo->pdev)); 2564 pci_name(rinfo->pdev));
2580 2565
2581 /* Switch back PCI powermanagment to D0 */
2582 mdelay(200);
2583 pci_write_config_word(rinfo->pdev, rinfo->pm_reg+PCI_PM_CTRL, 0);
2584 mdelay(500);
2585
2586 if (rinfo->family <= CHIP_FAMILY_RV250) { 2566 if (rinfo->family <= CHIP_FAMILY_RV250) {
2587 /* Reset the SDRAM controller */ 2567 /* Reset the SDRAM controller */
2588 radeon_pm_full_reset_sdram(rinfo); 2568 radeon_pm_full_reset_sdram(rinfo);
@@ -2598,37 +2578,10 @@ static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
2598 } 2578 }
2599} 2579}
2600 2580
2601static int radeon_restore_pci_cfg(struct radeonfb_info *rinfo)
2602{
2603 int i;
2604 static u32 radeon_cfg_after_resume[64];
2605
2606 for (i = 0; i < 64; ++i)
2607 pci_read_config_dword(rinfo->pdev, i * 4,
2608 &radeon_cfg_after_resume[i]);
2609
2610 if (radeon_cfg_after_resume[PCI_BASE_ADDRESS_0/4]
2611 == rinfo->cfg_save[PCI_BASE_ADDRESS_0/4])
2612 return 0; /* assume everything is ok */
2613
2614 for (i = PCI_BASE_ADDRESS_0/4; i < 64; ++i) {
2615 if (radeon_cfg_after_resume[i] != rinfo->cfg_save[i])
2616 pci_write_config_dword(rinfo->pdev, i * 4,
2617 rinfo->cfg_save[i]);
2618 }
2619 pci_write_config_word(rinfo->pdev, PCI_CACHE_LINE_SIZE,
2620 rinfo->cfg_save[PCI_CACHE_LINE_SIZE/4]);
2621 pci_write_config_word(rinfo->pdev, PCI_COMMAND,
2622 rinfo->cfg_save[PCI_COMMAND/4]);
2623 return 1;
2624}
2625
2626
2627int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) 2581int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2628{ 2582{
2629 struct fb_info *info = pci_get_drvdata(pdev); 2583 struct fb_info *info = pci_get_drvdata(pdev);
2630 struct radeonfb_info *rinfo = info->par; 2584 struct radeonfb_info *rinfo = info->par;
2631 int i;
2632 2585
2633 if (mesg.event == pdev->dev.power.power_state.event) 2586 if (mesg.event == pdev->dev.power.power_state.event)
2634 return 0; 2587 return 0;
@@ -2674,6 +2627,11 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2674 pmac_suspend_agp_for_card(pdev); 2627 pmac_suspend_agp_for_card(pdev);
2675#endif /* CONFIG_PPC_PMAC */ 2628#endif /* CONFIG_PPC_PMAC */
2676 2629
2630 /* It's unclear whether or when the generic code will do that, so let's
2631 * do it ourselves. We save state before we do any power management
2632 */
2633 pci_save_state(pdev);
2634
2677 /* If we support wakeup from poweroff, we save all regs we can including cfg 2635 /* If we support wakeup from poweroff, we save all regs we can including cfg
2678 * space 2636 * space
2679 */ 2637 */
@@ -2698,9 +2656,6 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2698 mdelay(20); 2656 mdelay(20);
2699 OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_DIGON)); 2657 OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_DIGON));
2700 } 2658 }
2701 // FIXME: Use PCI layer
2702 for (i = 0; i < 64; ++i)
2703 pci_read_config_dword(pdev, i * 4, &rinfo->cfg_save[i]);
2704 pci_disable_device(pdev); 2659 pci_disable_device(pdev);
2705 } 2660 }
2706 /* If we support D2, we go to it (should be fixed later with a flag forcing 2661 /* If we support D2, we go to it (should be fixed later with a flag forcing
@@ -2717,6 +2672,13 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2717 return 0; 2672 return 0;
2718} 2673}
2719 2674
2675static int radeon_check_power_loss(struct radeonfb_info *rinfo)
2676{
2677 return rinfo->save_regs[4] != INPLL(CLK_PIN_CNTL) ||
2678 rinfo->save_regs[2] != INPLL(MCLK_CNTL) ||
2679 rinfo->save_regs[3] != INPLL(SCLK_CNTL);
2680}
2681
2720int radeonfb_pci_resume(struct pci_dev *pdev) 2682int radeonfb_pci_resume(struct pci_dev *pdev)
2721{ 2683{
2722 struct fb_info *info = pci_get_drvdata(pdev); 2684 struct fb_info *info = pci_get_drvdata(pdev);
@@ -2735,20 +2697,13 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2735 printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n", 2697 printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n",
2736 pci_name(pdev), pdev->dev.power.power_state.event); 2698 pci_name(pdev), pdev->dev.power.power_state.event);
2737 2699
2738 2700 /* PCI state will have been restored by the core, so
2739 if (pci_enable_device(pdev)) { 2701 * we should be in D0 now with our config space fully
2740 rc = -ENODEV; 2702 * restored
2741 printk(KERN_ERR "radeonfb (%s): can't enable PCI device !\n", 2703 */
2742 pci_name(pdev));
2743 goto bail;
2744 }
2745 pci_set_master(pdev);
2746
2747 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { 2704 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
2748 /* Wakeup chip. Check from config space if we were powered off 2705 /* Wakeup chip */
2749 * (todo: additionally, check CLK_PIN_CNTL too) 2706 if ((rinfo->pm_mode & radeon_pm_off) && radeon_check_power_loss(rinfo)) {
2750 */
2751 if ((rinfo->pm_mode & radeon_pm_off) && radeon_restore_pci_cfg(rinfo)) {
2752 if (rinfo->reinit_func != NULL) 2707 if (rinfo->reinit_func != NULL)
2753 rinfo->reinit_func(rinfo); 2708 rinfo->reinit_func(rinfo);
2754 else { 2709 else {
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
index 3ea1b00fdd22..7351e66c7f54 100644
--- a/drivers/video/aty/radeonfb.h
+++ b/drivers/video/aty/radeonfb.h
@@ -361,8 +361,6 @@ struct radeonfb_info {
361#ifdef CONFIG_FB_RADEON_I2C 361#ifdef CONFIG_FB_RADEON_I2C
362 struct radeon_i2c_chan i2c[4]; 362 struct radeon_i2c_chan i2c[4];
363#endif 363#endif
364
365 u32 cfg_save[64];
366}; 364};
367 365
368 366
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 363b3cb2f01b..63d759498165 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -18,7 +18,7 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
18obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o 18obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
19obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o 19obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
20obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o 20obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
21obj-$(CONFIG_BACKLIGHT_DA903X) += da903x.o 21obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o
22obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o 22obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
23obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o 23obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o
24obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o 24obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o
diff --git a/drivers/video/backlight/da903x.c b/drivers/video/backlight/da903x_bl.c
index 93bb4340cc64..93bb4340cc64 100644
--- a/drivers/video/backlight/da903x.c
+++ b/drivers/video/backlight/da903x_bl.c
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index 2a423d3a2a8e..90cfddabf1f7 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -447,7 +447,7 @@ static irqreturn_t bfin_t350mcqb_irq_error(int irq, void *dev_id)
447 return IRQ_HANDLED; 447 return IRQ_HANDLED;
448} 448}
449 449
450static int __init bfin_t350mcqb_probe(struct platform_device *pdev) 450static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
451{ 451{
452 struct bfin_t350mcqbfb_info *info; 452 struct bfin_t350mcqbfb_info *info;
453 struct fb_info *fbinfo; 453 struct fb_info *fbinfo;
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
index 91b78e691505..f53b9f1d6aba 100644
--- a/drivers/video/fbcmap.c
+++ b/drivers/video/fbcmap.c
@@ -250,10 +250,6 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
250 int rc, size = cmap->len * sizeof(u16); 250 int rc, size = cmap->len * sizeof(u16);
251 struct fb_cmap umap; 251 struct fb_cmap umap;
252 252
253 if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
254 !info->fbops->fb_setcmap))
255 return -EINVAL;
256
257 memset(&umap, 0, sizeof(struct fb_cmap)); 253 memset(&umap, 0, sizeof(struct fb_cmap));
258 rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL); 254 rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL);
259 if (rc) 255 if (rc)
@@ -262,11 +258,23 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
262 copy_from_user(umap.green, cmap->green, size) || 258 copy_from_user(umap.green, cmap->green, size) ||
263 copy_from_user(umap.blue, cmap->blue, size) || 259 copy_from_user(umap.blue, cmap->blue, size) ||
264 (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) { 260 (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) {
265 fb_dealloc_cmap(&umap); 261 rc = -EFAULT;
266 return -EFAULT; 262 goto out;
267 } 263 }
268 umap.start = cmap->start; 264 umap.start = cmap->start;
265 if (!lock_fb_info(info)) {
266 rc = -ENODEV;
267 goto out;
268 }
269 if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
270 !info->fbops->fb_setcmap)) {
271 rc = -EINVAL;
272 goto out1;
273 }
269 rc = fb_set_cmap(&umap, info); 274 rc = fb_set_cmap(&umap, info);
275out1:
276 unlock_fb_info(info);
277out:
270 fb_dealloc_cmap(&umap); 278 fb_dealloc_cmap(&umap);
271 return rc; 279 return rc;
272} 280}
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 756efeb91abc..cfd9dce1ce0b 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1013,132 +1013,139 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1013 struct fb_var_screeninfo var; 1013 struct fb_var_screeninfo var;
1014 struct fb_fix_screeninfo fix; 1014 struct fb_fix_screeninfo fix;
1015 struct fb_con2fbmap con2fb; 1015 struct fb_con2fbmap con2fb;
1016 struct fb_cmap cmap_from;
1016 struct fb_cmap_user cmap; 1017 struct fb_cmap_user cmap;
1017 struct fb_event event; 1018 struct fb_event event;
1018 void __user *argp = (void __user *)arg; 1019 void __user *argp = (void __user *)arg;
1019 long ret = 0; 1020 long ret = 0;
1020 1021
1021 fb = info->fbops;
1022 if (!fb)
1023 return -ENODEV;
1024
1025 switch (cmd) { 1022 switch (cmd) {
1026 case FBIOGET_VSCREENINFO: 1023 case FBIOGET_VSCREENINFO:
1027 ret = copy_to_user(argp, &info->var, 1024 if (!lock_fb_info(info))
1028 sizeof(var)) ? -EFAULT : 0; 1025 return -ENODEV;
1026 var = info->var;
1027 unlock_fb_info(info);
1028
1029 ret = copy_to_user(argp, &var, sizeof(var)) ? -EFAULT : 0;
1029 break; 1030 break;
1030 case FBIOPUT_VSCREENINFO: 1031 case FBIOPUT_VSCREENINFO:
1031 if (copy_from_user(&var, argp, sizeof(var))) { 1032 if (copy_from_user(&var, argp, sizeof(var)))
1032 ret = -EFAULT; 1033 return -EFAULT;
1033 break; 1034 if (!lock_fb_info(info))
1034 } 1035 return -ENODEV;
1035 acquire_console_sem(); 1036 acquire_console_sem();
1036 info->flags |= FBINFO_MISC_USEREVENT; 1037 info->flags |= FBINFO_MISC_USEREVENT;
1037 ret = fb_set_var(info, &var); 1038 ret = fb_set_var(info, &var);
1038 info->flags &= ~FBINFO_MISC_USEREVENT; 1039 info->flags &= ~FBINFO_MISC_USEREVENT;
1039 release_console_sem(); 1040 release_console_sem();
1040 if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) 1041 unlock_fb_info(info);
1042 if (!ret && copy_to_user(argp, &var, sizeof(var)))
1041 ret = -EFAULT; 1043 ret = -EFAULT;
1042 break; 1044 break;
1043 case FBIOGET_FSCREENINFO: 1045 case FBIOGET_FSCREENINFO:
1044 ret = copy_to_user(argp, &info->fix, 1046 if (!lock_fb_info(info))
1045 sizeof(fix)) ? -EFAULT : 0; 1047 return -ENODEV;
1048 fix = info->fix;
1049 unlock_fb_info(info);
1050
1051 ret = copy_to_user(argp, &fix, sizeof(fix)) ? -EFAULT : 0;
1046 break; 1052 break;
1047 case FBIOPUTCMAP: 1053 case FBIOPUTCMAP:
1048 if (copy_from_user(&cmap, argp, sizeof(cmap))) 1054 if (copy_from_user(&cmap, argp, sizeof(cmap)))
1049 ret = -EFAULT; 1055 return -EFAULT;
1050 else 1056 ret = fb_set_user_cmap(&cmap, info);
1051 ret = fb_set_user_cmap(&cmap, info);
1052 break; 1057 break;
1053 case FBIOGETCMAP: 1058 case FBIOGETCMAP:
1054 if (copy_from_user(&cmap, argp, sizeof(cmap))) 1059 if (copy_from_user(&cmap, argp, sizeof(cmap)))
1055 ret = -EFAULT; 1060 return -EFAULT;
1056 else 1061 if (!lock_fb_info(info))
1057 ret = fb_cmap_to_user(&info->cmap, &cmap); 1062 return -ENODEV;
1063 cmap_from = info->cmap;
1064 unlock_fb_info(info);
1065 ret = fb_cmap_to_user(&cmap_from, &cmap);
1058 break; 1066 break;
1059 case FBIOPAN_DISPLAY: 1067 case FBIOPAN_DISPLAY:
1060 if (copy_from_user(&var, argp, sizeof(var))) { 1068 if (copy_from_user(&var, argp, sizeof(var)))
1061 ret = -EFAULT; 1069 return -EFAULT;
1062 break; 1070 if (!lock_fb_info(info))
1063 } 1071 return -ENODEV;
1064 acquire_console_sem(); 1072 acquire_console_sem();
1065 ret = fb_pan_display(info, &var); 1073 ret = fb_pan_display(info, &var);
1066 release_console_sem(); 1074 release_console_sem();
1075 unlock_fb_info(info);
1067 if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) 1076 if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
1068 ret = -EFAULT; 1077 return -EFAULT;
1069 break; 1078 break;
1070 case FBIO_CURSOR: 1079 case FBIO_CURSOR:
1071 ret = -EINVAL; 1080 ret = -EINVAL;
1072 break; 1081 break;
1073 case FBIOGET_CON2FBMAP: 1082 case FBIOGET_CON2FBMAP:
1074 if (copy_from_user(&con2fb, argp, sizeof(con2fb))) 1083 if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
1075 ret = -EFAULT; 1084 return -EFAULT;
1076 else if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) 1085 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
1077 ret = -EINVAL; 1086 return -EINVAL;
1078 else { 1087 con2fb.framebuffer = -1;
1079 con2fb.framebuffer = -1; 1088 event.data = &con2fb;
1080 event.info = info; 1089
1081 event.data = &con2fb; 1090 if (!lock_fb_info(info))
1082 fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, 1091 return -ENODEV;
1083 &event); 1092 event.info = info;
1084 ret = copy_to_user(argp, &con2fb, 1093 fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event);
1085 sizeof(con2fb)) ? -EFAULT : 0; 1094 unlock_fb_info(info);
1086 } 1095
1096 ret = copy_to_user(argp, &con2fb, sizeof(con2fb)) ? -EFAULT : 0;
1087 break; 1097 break;
1088 case FBIOPUT_CON2FBMAP: 1098 case FBIOPUT_CON2FBMAP:
1089 if (copy_from_user(&con2fb, argp, sizeof(con2fb))) { 1099 if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
1090 ret = -EFAULT; 1100 return -EFAULT;
1091 break; 1101 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
1092 } 1102 return -EINVAL;
1093 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) { 1103 if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
1094 ret = -EINVAL; 1104 return -EINVAL;
1095 break;
1096 }
1097 if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) {
1098 ret = -EINVAL;
1099 break;
1100 }
1101 if (!registered_fb[con2fb.framebuffer]) 1105 if (!registered_fb[con2fb.framebuffer])
1102 request_module("fb%d", con2fb.framebuffer); 1106 request_module("fb%d", con2fb.framebuffer);
1103 if (!registered_fb[con2fb.framebuffer]) { 1107 if (!registered_fb[con2fb.framebuffer]) {
1104 ret = -EINVAL; 1108 ret = -EINVAL;
1105 break; 1109 break;
1106 } 1110 }
1107 event.info = info;
1108 event.data = &con2fb; 1111 event.data = &con2fb;
1112 if (!lock_fb_info(info))
1113 return -ENODEV;
1114 event.info = info;
1109 ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, 1115 ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP,
1110 &event); 1116 &event);
1117 unlock_fb_info(info);
1111 break; 1118 break;
1112 case FBIOBLANK: 1119 case FBIOBLANK:
1120 if (!lock_fb_info(info))
1121 return -ENODEV;
1113 acquire_console_sem(); 1122 acquire_console_sem();
1114 info->flags |= FBINFO_MISC_USEREVENT; 1123 info->flags |= FBINFO_MISC_USEREVENT;
1115 ret = fb_blank(info, arg); 1124 ret = fb_blank(info, arg);
1116 info->flags &= ~FBINFO_MISC_USEREVENT; 1125 info->flags &= ~FBINFO_MISC_USEREVENT;
1117 release_console_sem(); 1126 release_console_sem();
1118 break;; 1127 unlock_fb_info(info);
1128 break;
1119 default: 1129 default:
1120 if (fb->fb_ioctl == NULL) 1130 if (!lock_fb_info(info))
1121 ret = -ENOTTY; 1131 return -ENODEV;
1122 else 1132 fb = info->fbops;
1133 if (fb->fb_ioctl)
1123 ret = fb->fb_ioctl(info, cmd, arg); 1134 ret = fb->fb_ioctl(info, cmd, arg);
1135 else
1136 ret = -ENOTTY;
1137 unlock_fb_info(info);
1124 } 1138 }
1125 return ret; 1139 return ret;
1126} 1140}
1127 1141
1128static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 1142static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1129__acquires(&info->lock)
1130__releases(&info->lock)
1131{ 1143{
1132 struct inode *inode = file->f_path.dentry->d_inode; 1144 struct inode *inode = file->f_path.dentry->d_inode;
1133 int fbidx = iminor(inode); 1145 int fbidx = iminor(inode);
1134 struct fb_info *info; 1146 struct fb_info *info = registered_fb[fbidx];
1135 long ret;
1136 1147
1137 info = registered_fb[fbidx]; 1148 return do_fb_ioctl(info, cmd, arg);
1138 mutex_lock(&info->lock);
1139 ret = do_fb_ioctl(info, cmd, arg);
1140 mutex_unlock(&info->lock);
1141 return ret;
1142} 1149}
1143 1150
1144#ifdef CONFIG_COMPAT 1151#ifdef CONFIG_COMPAT
@@ -1257,8 +1264,6 @@ static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd,
1257 1264
1258static long fb_compat_ioctl(struct file *file, unsigned int cmd, 1265static long fb_compat_ioctl(struct file *file, unsigned int cmd,
1259 unsigned long arg) 1266 unsigned long arg)
1260__acquires(&info->lock)
1261__releases(&info->lock)
1262{ 1267{
1263 struct inode *inode = file->f_path.dentry->d_inode; 1268 struct inode *inode = file->f_path.dentry->d_inode;
1264 int fbidx = iminor(inode); 1269 int fbidx = iminor(inode);
@@ -1266,7 +1271,6 @@ __releases(&info->lock)
1266 struct fb_ops *fb = info->fbops; 1271 struct fb_ops *fb = info->fbops;
1267 long ret = -ENOIOCTLCMD; 1272 long ret = -ENOIOCTLCMD;
1268 1273
1269 mutex_lock(&info->lock);
1270 switch(cmd) { 1274 switch(cmd) {
1271 case FBIOGET_VSCREENINFO: 1275 case FBIOGET_VSCREENINFO:
1272 case FBIOPUT_VSCREENINFO: 1276 case FBIOPUT_VSCREENINFO:
@@ -1292,7 +1296,6 @@ __releases(&info->lock)
1292 ret = fb->fb_compat_ioctl(info, cmd, arg); 1296 ret = fb->fb_compat_ioctl(info, cmd, arg);
1293 break; 1297 break;
1294 } 1298 }
1295 mutex_unlock(&info->lock);
1296 return ret; 1299 return ret;
1297} 1300}
1298#endif 1301#endif
diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c
index 751e491ca8c8..f20eff8c4a81 100644
--- a/drivers/video/geode/gx1fb_core.c
+++ b/drivers/video/geode/gx1fb_core.c
@@ -136,13 +136,10 @@ static int gx1fb_set_par(struct fb_info *info)
136{ 136{
137 struct geodefb_par *par = info->par; 137 struct geodefb_par *par = info->par;
138 138
139 if (info->var.bits_per_pixel == 16) { 139 if (info->var.bits_per_pixel == 16)
140 info->fix.visual = FB_VISUAL_TRUECOLOR; 140 info->fix.visual = FB_VISUAL_TRUECOLOR;
141 fb_dealloc_cmap(&info->cmap); 141 else
142 } else {
143 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 142 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
144 fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
145 }
146 143
147 info->fix.line_length = gx1_line_delta(info->var.xres, info->var.bits_per_pixel); 144 info->fix.line_length = gx1_line_delta(info->var.xres, info->var.bits_per_pixel);
148 145
@@ -315,6 +312,10 @@ static struct fb_info * __init gx1fb_init_fbinfo(struct device *dev)
315 if (!par->panel_x) 312 if (!par->panel_x)
316 par->enable_crt = 1; /* fall back to CRT if no panel is specified */ 313 par->enable_crt = 1; /* fall back to CRT if no panel is specified */
317 314
315 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
316 framebuffer_release(info);
317 return NULL;
318 }
318 return info; 319 return info;
319} 320}
320 321
@@ -374,8 +375,11 @@ static int __init gx1fb_probe(struct pci_dev *pdev, const struct pci_device_id *
374 release_mem_region(gx1_gx_base() + 0x8300, 0x100); 375 release_mem_region(gx1_gx_base() + 0x8300, 0x100);
375 } 376 }
376 377
377 if (info) 378 if (info) {
379 fb_dealloc_cmap(&info->cmap);
378 framebuffer_release(info); 380 framebuffer_release(info);
381 }
382
379 return ret; 383 return ret;
380} 384}
381 385
@@ -395,6 +399,7 @@ static void gx1fb_remove(struct pci_dev *pdev)
395 iounmap(par->dc_regs); 399 iounmap(par->dc_regs);
396 release_mem_region(gx1_gx_base() + 0x8300, 0x100); 400 release_mem_region(gx1_gx_base() + 0x8300, 0x100);
397 401
402 fb_dealloc_cmap(&info->cmap);
398 pci_set_drvdata(pdev, NULL); 403 pci_set_drvdata(pdev, NULL);
399 404
400 framebuffer_release(info); 405 framebuffer_release(info);
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 484118926318..2552cac39e1c 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -171,13 +171,10 @@ static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
171 171
172static int gxfb_set_par(struct fb_info *info) 172static int gxfb_set_par(struct fb_info *info)
173{ 173{
174 if (info->var.bits_per_pixel > 8) { 174 if (info->var.bits_per_pixel > 8)
175 info->fix.visual = FB_VISUAL_TRUECOLOR; 175 info->fix.visual = FB_VISUAL_TRUECOLOR;
176 fb_dealloc_cmap(&info->cmap); 176 else
177 } else {
178 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 177 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
179 fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
180 }
181 178
182 info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel); 179 info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel);
183 180
@@ -331,6 +328,11 @@ static struct fb_info * __init gxfb_init_fbinfo(struct device *dev)
331 328
332 info->var.grayscale = 0; 329 info->var.grayscale = 0;
333 330
331 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
332 framebuffer_release(info);
333 return NULL;
334 }
335
334 return info; 336 return info;
335} 337}
336 338
@@ -443,8 +445,10 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
443 pci_release_region(pdev, 1); 445 pci_release_region(pdev, 1);
444 } 446 }
445 447
446 if (info) 448 if (info) {
449 fb_dealloc_cmap(&info->cmap);
447 framebuffer_release(info); 450 framebuffer_release(info);
451 }
448 return ret; 452 return ret;
449} 453}
450 454
@@ -467,6 +471,7 @@ static void gxfb_remove(struct pci_dev *pdev)
467 iounmap(par->gp_regs); 471 iounmap(par->gp_regs);
468 pci_release_region(pdev, 1); 472 pci_release_region(pdev, 1);
469 473
474 fb_dealloc_cmap(&info->cmap);
470 pci_set_drvdata(pdev, NULL); 475 pci_set_drvdata(pdev, NULL);
471 476
472 framebuffer_release(info); 477 framebuffer_release(info);
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index b965ecdbc604..889cbe39e580 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -278,13 +278,10 @@ static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
278 278
279static int lxfb_set_par(struct fb_info *info) 279static int lxfb_set_par(struct fb_info *info)
280{ 280{
281 if (info->var.bits_per_pixel > 8) { 281 if (info->var.bits_per_pixel > 8)
282 info->fix.visual = FB_VISUAL_TRUECOLOR; 282 info->fix.visual = FB_VISUAL_TRUECOLOR;
283 fb_dealloc_cmap(&info->cmap); 283 else
284 } else {
285 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 284 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
286 fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
287 }
288 285
289 info->fix.line_length = lx_get_pitch(info->var.xres, 286 info->fix.line_length = lx_get_pitch(info->var.xres,
290 info->var.bits_per_pixel); 287 info->var.bits_per_pixel);
@@ -451,6 +448,11 @@ static struct fb_info * __init lxfb_init_fbinfo(struct device *dev)
451 448
452 info->pseudo_palette = (void *)par + sizeof(struct lxfb_par); 449 info->pseudo_palette = (void *)par + sizeof(struct lxfb_par);
453 450
451 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
452 framebuffer_release(info);
453 return NULL;
454 }
455
454 info->var.grayscale = 0; 456 info->var.grayscale = 0;
455 457
456 return info; 458 return info;
@@ -579,8 +581,10 @@ err:
579 pci_release_region(pdev, 3); 581 pci_release_region(pdev, 3);
580 } 582 }
581 583
582 if (info) 584 if (info) {
585 fb_dealloc_cmap(&info->cmap);
583 framebuffer_release(info); 586 framebuffer_release(info);
587 }
584 588
585 return ret; 589 return ret;
586} 590}
@@ -604,6 +608,7 @@ static void lxfb_remove(struct pci_dev *pdev)
604 iounmap(par->vp_regs); 608 iounmap(par->vp_regs);
605 pci_release_region(pdev, 3); 609 pci_release_region(pdev, 3);
606 610
611 fb_dealloc_cmap(&info->cmap);
607 pci_set_drvdata(pdev, NULL); 612 pci_set_drvdata(pdev, NULL);
608 framebuffer_release(info); 613 framebuffer_release(info);
609} 614}
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 2c8dff9f77da..1ed3d554e372 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -115,7 +115,7 @@ static struct w1_therm_family_converter w1_therm_families[] = {
115 115
116static inline int w1_DS18B20_convert_temp(u8 rom[9]) 116static inline int w1_DS18B20_convert_temp(u8 rom[9])
117{ 117{
118 s16 t = (rom[1] << 8) | rom[0]; 118 int t = ((s16)rom[1] << 8) | rom[0];
119 t = t*1000/16; 119 t = t*1000/16;
120 return t; 120 return t;
121} 121}
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 09a3d5522b43..325c10ff6a2c 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -406,7 +406,7 @@ config ITCO_WDT
406 ---help--- 406 ---help---
407 Hardware driver for the intel TCO timer based watchdog devices. 407 Hardware driver for the intel TCO timer based watchdog devices.
408 These drivers are included in the Intel 82801 I/O Controller 408 These drivers are included in the Intel 82801 I/O Controller
409 Hub family (from ICH0 up to ICH8) and in the Intel 6300ESB 409 Hub family (from ICH0 up to ICH10) and in the Intel 63xxESB
410 controller hub. 410 controller hub.
411 411
412 The TCO (Total Cost of Ownership) timer is a watchdog timer 412 The TCO (Total Cost of Ownership) timer is a watchdog timer
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
index 5531691f46ea..e35d54589232 100644
--- a/drivers/watchdog/at91rm9200_wdt.c
+++ b/drivers/watchdog/at91rm9200_wdt.c
@@ -107,10 +107,10 @@ static int at91_wdt_close(struct inode *inode, struct file *file)
107static int at91_wdt_settimeout(int new_time) 107static int at91_wdt_settimeout(int new_time)
108{ 108{
109 /* 109 /*
110 * All counting occurs at SLOW_CLOCK / 128 = 0.256 Hz 110 * All counting occurs at SLOW_CLOCK / 128 = 256 Hz
111 * 111 *
112 * Since WDV is a 16-bit counter, the maximum period is 112 * Since WDV is a 16-bit counter, the maximum period is
113 * 65536 / 0.256 = 256 seconds. 113 * 65536 / 256 = 256 seconds.
114 */ 114 */
115 if ((new_time <= 0) || (new_time > WDT_MAX_TIME)) 115 if ((new_time <= 0) || (new_time > WDT_MAX_TIME))
116 return -EINVAL; 116 return -EINVAL;
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index b1da287f90ec..a56ac84381b1 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -18,6 +18,7 @@
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/io.h>
21#include <linux/kernel.h> 22#include <linux/kernel.h>
22#include <linux/miscdevice.h> 23#include <linux/miscdevice.h>
23#include <linux/module.h> 24#include <linux/module.h>
diff --git a/drivers/watchdog/iTCO_vendor_support.c b/drivers/watchdog/iTCO_vendor_support.c
index 2474ebca88f6..d8264ad0be41 100644
--- a/drivers/watchdog/iTCO_vendor_support.c
+++ b/drivers/watchdog/iTCO_vendor_support.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * intel TCO vendor specific watchdog driver support 2 * intel TCO vendor specific watchdog driver support
3 * 3 *
4 * (c) Copyright 2006-2008 Wim Van Sebroeck <wim@iguana.be>. 4 * (c) Copyright 2006-2009 Wim Van Sebroeck <wim@iguana.be>.
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -19,7 +19,7 @@
19 19
20/* Module and version information */ 20/* Module and version information */
21#define DRV_NAME "iTCO_vendor_support" 21#define DRV_NAME "iTCO_vendor_support"
22#define DRV_VERSION "1.02" 22#define DRV_VERSION "1.03"
23#define PFX DRV_NAME ": " 23#define PFX DRV_NAME ": "
24 24
25/* Includes */ 25/* Includes */
@@ -77,6 +77,26 @@ MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default=0 (n
77 * 20.6 seconds. 77 * 20.6 seconds.
78 */ 78 */
79 79
80static void supermicro_old_pre_start(unsigned long acpibase)
81{
82 unsigned long val32;
83
84 /* Bit 13: TCO_EN -> 0 = Disables TCO logic generating an SMI# */
85 val32 = inl(SMI_EN);
86 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
87 outl(val32, SMI_EN); /* Needed to activate watchdog */
88}
89
90static void supermicro_old_pre_stop(unsigned long acpibase)
91{
92 unsigned long val32;
93
94 /* Bit 13: TCO_EN -> 1 = Enables the TCO logic to generate SMI# */
95 val32 = inl(SMI_EN);
96 val32 |= 0x00002000; /* Turn on SMI clearing watchdog */
97 outl(val32, SMI_EN); /* Needed to deactivate watchdog */
98}
99
80static void supermicro_old_pre_keepalive(unsigned long acpibase) 100static void supermicro_old_pre_keepalive(unsigned long acpibase)
81{ 101{
82 /* Reload TCO Timer (done in iTCO_wdt_keepalive) + */ 102 /* Reload TCO Timer (done in iTCO_wdt_keepalive) + */
@@ -228,14 +248,18 @@ static void supermicro_new_pre_set_heartbeat(unsigned int heartbeat)
228void iTCO_vendor_pre_start(unsigned long acpibase, 248void iTCO_vendor_pre_start(unsigned long acpibase,
229 unsigned int heartbeat) 249 unsigned int heartbeat)
230{ 250{
231 if (vendorsupport == SUPERMICRO_NEW_BOARD) 251 if (vendorsupport == SUPERMICRO_OLD_BOARD)
252 supermicro_old_pre_start(acpibase);
253 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
232 supermicro_new_pre_start(heartbeat); 254 supermicro_new_pre_start(heartbeat);
233} 255}
234EXPORT_SYMBOL(iTCO_vendor_pre_start); 256EXPORT_SYMBOL(iTCO_vendor_pre_start);
235 257
236void iTCO_vendor_pre_stop(unsigned long acpibase) 258void iTCO_vendor_pre_stop(unsigned long acpibase)
237{ 259{
238 if (vendorsupport == SUPERMICRO_NEW_BOARD) 260 if (vendorsupport == SUPERMICRO_OLD_BOARD)
261 supermicro_old_pre_stop(acpibase);
262 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
239 supermicro_new_pre_stop(); 263 supermicro_new_pre_stop();
240} 264}
241EXPORT_SYMBOL(iTCO_vendor_pre_stop); 265EXPORT_SYMBOL(iTCO_vendor_pre_stop);
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 5b395a4ddfdf..352334947ea3 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * intel TCO Watchdog Driver (Used in i82801 and i6300ESB chipsets) 2 * intel TCO Watchdog Driver (Used in i82801 and i63xxESB chipsets)
3 * 3 *
4 * (c) Copyright 2006-2008 Wim Van Sebroeck <wim@iguana.be>. 4 * (c) Copyright 2006-2009 Wim Van Sebroeck <wim@iguana.be>.
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -63,7 +63,7 @@
63 63
64/* Module and version information */ 64/* Module and version information */
65#define DRV_NAME "iTCO_wdt" 65#define DRV_NAME "iTCO_wdt"
66#define DRV_VERSION "1.04" 66#define DRV_VERSION "1.05"
67#define PFX DRV_NAME ": " 67#define PFX DRV_NAME ": "
68 68
69/* Includes */ 69/* Includes */
@@ -236,16 +236,16 @@ MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
236 236
237/* Address definitions for the TCO */ 237/* Address definitions for the TCO */
238/* TCO base address */ 238/* TCO base address */
239#define TCOBASE iTCO_wdt_private.ACPIBASE + 0x60 239#define TCOBASE iTCO_wdt_private.ACPIBASE + 0x60
240/* SMI Control and Enable Register */ 240/* SMI Control and Enable Register */
241#define SMI_EN iTCO_wdt_private.ACPIBASE + 0x30 241#define SMI_EN iTCO_wdt_private.ACPIBASE + 0x30
242 242
243#define TCO_RLD TCOBASE + 0x00 /* TCO Timer Reload and Curr. Value */ 243#define TCO_RLD TCOBASE + 0x00 /* TCO Timer Reload and Curr. Value */
244#define TCOv1_TMR TCOBASE + 0x01 /* TCOv1 Timer Initial Value */ 244#define TCOv1_TMR TCOBASE + 0x01 /* TCOv1 Timer Initial Value */
245#define TCO_DAT_IN TCOBASE + 0x02 /* TCO Data In Register */ 245#define TCO_DAT_IN TCOBASE + 0x02 /* TCO Data In Register */
246#define TCO_DAT_OUT TCOBASE + 0x03 /* TCO Data Out Register */ 246#define TCO_DAT_OUT TCOBASE + 0x03 /* TCO Data Out Register */
247#define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */ 247#define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */
248#define TCO2_STS TCOBASE + 0x06 /* TCO2 Status Register */ 248#define TCO2_STS TCOBASE + 0x06 /* TCO2 Status Register */
249#define TCO1_CNT TCOBASE + 0x08 /* TCO1 Control Register */ 249#define TCO1_CNT TCOBASE + 0x08 /* TCO1 Control Register */
250#define TCO2_CNT TCOBASE + 0x0a /* TCO2 Control Register */ 250#define TCO2_CNT TCOBASE + 0x0a /* TCO2 Control Register */
251#define TCOv2_TMR TCOBASE + 0x12 /* TCOv2 Timer Initial Value */ 251#define TCOv2_TMR TCOBASE + 0x12 /* TCOv2 Timer Initial Value */
@@ -338,7 +338,6 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
338static int iTCO_wdt_start(void) 338static int iTCO_wdt_start(void)
339{ 339{
340 unsigned int val; 340 unsigned int val;
341 unsigned long val32;
342 341
343 spin_lock(&iTCO_wdt_private.io_lock); 342 spin_lock(&iTCO_wdt_private.io_lock);
344 343
@@ -351,11 +350,6 @@ static int iTCO_wdt_start(void)
351 return -EIO; 350 return -EIO;
352 } 351 }
353 352
354 /* Bit 13: TCO_EN -> 0 = Disables TCO logic generating an SMI# */
355 val32 = inl(SMI_EN);
356 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
357 outl(val32, SMI_EN);
358
359 /* Force the timer to its reload value by writing to the TCO_RLD 353 /* Force the timer to its reload value by writing to the TCO_RLD
360 register */ 354 register */
361 if (iTCO_wdt_private.iTCO_version == 2) 355 if (iTCO_wdt_private.iTCO_version == 2)
@@ -378,7 +372,6 @@ static int iTCO_wdt_start(void)
378static int iTCO_wdt_stop(void) 372static int iTCO_wdt_stop(void)
379{ 373{
380 unsigned int val; 374 unsigned int val;
381 unsigned long val32;
382 375
383 spin_lock(&iTCO_wdt_private.io_lock); 376 spin_lock(&iTCO_wdt_private.io_lock);
384 377
@@ -390,11 +383,6 @@ static int iTCO_wdt_stop(void)
390 outw(val, TCO1_CNT); 383 outw(val, TCO1_CNT);
391 val = inw(TCO1_CNT); 384 val = inw(TCO1_CNT);
392 385
393 /* Bit 13: TCO_EN -> 1 = Enables the TCO logic to generate SMI# */
394 val32 = inl(SMI_EN);
395 val32 |= 0x00002000;
396 outl(val32, SMI_EN);
397
398 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ 386 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
399 iTCO_wdt_set_NO_REBOOT_bit(); 387 iTCO_wdt_set_NO_REBOOT_bit();
400 388
@@ -649,6 +637,7 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
649 int ret; 637 int ret;
650 u32 base_address; 638 u32 base_address;
651 unsigned long RCBA; 639 unsigned long RCBA;
640 unsigned long val32;
652 641
653 /* 642 /*
654 * Find the ACPI/PM base I/O address which is the base 643 * Find the ACPI/PM base I/O address which is the base
@@ -695,6 +684,10 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
695 ret = -EIO; 684 ret = -EIO;
696 goto out; 685 goto out;
697 } 686 }
687 /* Bit 13: TCO_EN -> 0 = Disables TCO logic generating an SMI# */
688 val32 = inl(SMI_EN);
689 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
690 outl(val32, SMI_EN);
698 691
699 /* The TCO I/O registers reside in a 32-byte range pointed to 692 /* The TCO I/O registers reside in a 32-byte range pointed to
700 by the TCOBASE value */ 693 by the TCOBASE value */
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 9b91617b9582..56892a142ee2 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -45,6 +45,13 @@ static int xen_suspend(void *data)
45 err); 45 err);
46 return err; 46 return err;
47 } 47 }
48 err = sysdev_suspend(PMSG_SUSPEND);
49 if (err) {
50 printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n",
51 err);
52 device_power_up(PMSG_RESUME);
53 return err;
54 }
48 55
49 xen_mm_pin_all(); 56 xen_mm_pin_all();
50 gnttab_suspend(); 57 gnttab_suspend();
@@ -61,6 +68,7 @@ static int xen_suspend(void *data)
61 gnttab_resume(); 68 gnttab_resume();
62 xen_mm_unpin_all(); 69 xen_mm_unpin_all();
63 70
71 sysdev_resume();
64 device_power_up(PMSG_RESUME); 72 device_power_up(PMSG_RESUME);
65 73
66 if (!*cancelled) { 74 if (!*cancelled) {
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index e3ff2b9e602f..33b7235f853b 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1208,9 +1208,11 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
1208 * check for an ELF header. If we find one, dump the first page to 1208 * check for an ELF header. If we find one, dump the first page to
1209 * aid in determining what was mapped here. 1209 * aid in determining what was mapped here.
1210 */ 1210 */
1211 if (FILTER(ELF_HEADERS) && vma->vm_file != NULL && vma->vm_pgoff == 0) { 1211 if (FILTER(ELF_HEADERS) &&
1212 vma->vm_pgoff == 0 && (vma->vm_flags & VM_READ)) {
1212 u32 __user *header = (u32 __user *) vma->vm_start; 1213 u32 __user *header = (u32 __user *) vma->vm_start;
1213 u32 word; 1214 u32 word;
1215 mm_segment_t fs = get_fs();
1214 /* 1216 /*
1215 * Doing it this way gets the constant folded by GCC. 1217 * Doing it this way gets the constant folded by GCC.
1216 */ 1218 */
@@ -1223,7 +1225,15 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
1223 magic.elfmag[EI_MAG1] = ELFMAG1; 1225 magic.elfmag[EI_MAG1] = ELFMAG1;
1224 magic.elfmag[EI_MAG2] = ELFMAG2; 1226 magic.elfmag[EI_MAG2] = ELFMAG2;
1225 magic.elfmag[EI_MAG3] = ELFMAG3; 1227 magic.elfmag[EI_MAG3] = ELFMAG3;
1226 if (get_user(word, header) == 0 && word == magic.cmp) 1228 /*
1229 * Switch to the user "segment" for get_user(),
1230 * then put back what elf_core_dump() had in place.
1231 */
1232 set_fs(USER_DS);
1233 if (unlikely(get_user(word, header)))
1234 word = 0;
1235 set_fs(fs);
1236 if (word == magic.cmp)
1227 return PAGE_SIZE; 1237 return PAGE_SIZE;
1228 } 1238 }
1229 1239
diff --git a/fs/bio.c b/fs/bio.c
index 062299acbccd..72ab251cdb9c 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -302,9 +302,10 @@ void bio_init(struct bio *bio)
302struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs) 302struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
303{ 303{
304 struct bio *bio = NULL; 304 struct bio *bio = NULL;
305 void *p;
305 306
306 if (bs) { 307 if (bs) {
307 void *p = mempool_alloc(bs->bio_pool, gfp_mask); 308 p = mempool_alloc(bs->bio_pool, gfp_mask);
308 309
309 if (p) 310 if (p)
310 bio = p + bs->front_pad; 311 bio = p + bs->front_pad;
@@ -329,7 +330,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
329 } 330 }
330 if (unlikely(!bvl)) { 331 if (unlikely(!bvl)) {
331 if (bs) 332 if (bs)
332 mempool_free(bio, bs->bio_pool); 333 mempool_free(p, bs->bio_pool);
333 else 334 else
334 kfree(bio); 335 kfree(bio);
335 bio = NULL; 336 bio = NULL;
diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
index f8fcf999ea1b..7bb3c020e570 100644
--- a/fs/btrfs/Kconfig
+++ b/fs/btrfs/Kconfig
@@ -16,3 +16,16 @@ config BTRFS_FS
16 module will be called btrfs. 16 module will be called btrfs.
17 17
18 If unsure, say N. 18 If unsure, say N.
19
20config BTRFS_FS_POSIX_ACL
21 bool "Btrfs POSIX Access Control Lists"
22 depends on BTRFS_FS
23 select FS_POSIX_ACL
24 help
25 POSIX Access Control Lists (ACLs) support permissions for users and
26 groups beyond the owner/group/world scheme.
27
28 To learn more about Access Control Lists, visit the POSIX ACLs for
29 Linux website <http://acl.bestbits.at/>.
30
31 If you don't know what Access Control Lists are, say N
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 8e2fec05dbe0..c84ca1f5259a 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -16,11 +16,11 @@
16 * Boston, MA 021110-1307, USA. 16 * Boston, MA 021110-1307, USA.
17 */ 17 */
18 18
19#include <linux/version.h>
20#include <linux/kthread.h> 19#include <linux/kthread.h>
21#include <linux/list.h> 20#include <linux/list.h>
22#include <linux/spinlock.h> 21#include <linux/spinlock.h>
23# include <linux/freezer.h> 22#include <linux/freezer.h>
23#include <linux/ftrace.h>
24#include "async-thread.h" 24#include "async-thread.h"
25 25
26#define WORK_QUEUED_BIT 0 26#define WORK_QUEUED_BIT 0
@@ -143,6 +143,7 @@ static int worker_loop(void *arg)
143 struct btrfs_work *work; 143 struct btrfs_work *work;
144 do { 144 do {
145 spin_lock_irq(&worker->lock); 145 spin_lock_irq(&worker->lock);
146again_locked:
146 while (!list_empty(&worker->pending)) { 147 while (!list_empty(&worker->pending)) {
147 cur = worker->pending.next; 148 cur = worker->pending.next;
148 work = list_entry(cur, struct btrfs_work, list); 149 work = list_entry(cur, struct btrfs_work, list);
@@ -165,14 +166,50 @@ static int worker_loop(void *arg)
165 check_idle_worker(worker); 166 check_idle_worker(worker);
166 167
167 } 168 }
168 worker->working = 0;
169 if (freezing(current)) { 169 if (freezing(current)) {
170 worker->working = 0;
171 spin_unlock_irq(&worker->lock);
170 refrigerator(); 172 refrigerator();
171 } else { 173 } else {
172 set_current_state(TASK_INTERRUPTIBLE);
173 spin_unlock_irq(&worker->lock); 174 spin_unlock_irq(&worker->lock);
174 if (!kthread_should_stop()) 175 if (!kthread_should_stop()) {
176 cpu_relax();
177 /*
178 * we've dropped the lock, did someone else
179 * jump_in?
180 */
181 smp_mb();
182 if (!list_empty(&worker->pending))
183 continue;
184
185 /*
186 * this short schedule allows more work to
187 * come in without the queue functions
188 * needing to go through wake_up_process()
189 *
190 * worker->working is still 1, so nobody
191 * is going to try and wake us up
192 */
193 schedule_timeout(1);
194 smp_mb();
195 if (!list_empty(&worker->pending))
196 continue;
197
198 /* still no more work?, sleep for real */
199 spin_lock_irq(&worker->lock);
200 set_current_state(TASK_INTERRUPTIBLE);
201 if (!list_empty(&worker->pending))
202 goto again_locked;
203
204 /*
205 * this makes sure we get a wakeup when someone
206 * adds something new to the queue
207 */
208 worker->working = 0;
209 spin_unlock_irq(&worker->lock);
210
175 schedule(); 211 schedule();
212 }
176 __set_current_state(TASK_RUNNING); 213 __set_current_state(TASK_RUNNING);
177 } 214 }
178 } while (!kthread_should_stop()); 215 } while (!kthread_should_stop());
@@ -350,13 +387,14 @@ int btrfs_requeue_work(struct btrfs_work *work)
350{ 387{
351 struct btrfs_worker_thread *worker = work->worker; 388 struct btrfs_worker_thread *worker = work->worker;
352 unsigned long flags; 389 unsigned long flags;
390 int wake = 0;
353 391
354 if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags)) 392 if (test_and_set_bit(WORK_QUEUED_BIT, &work->flags))
355 goto out; 393 goto out;
356 394
357 spin_lock_irqsave(&worker->lock, flags); 395 spin_lock_irqsave(&worker->lock, flags);
358 atomic_inc(&worker->num_pending);
359 list_add_tail(&work->list, &worker->pending); 396 list_add_tail(&work->list, &worker->pending);
397 atomic_inc(&worker->num_pending);
360 398
361 /* by definition we're busy, take ourselves off the idle 399 /* by definition we're busy, take ourselves off the idle
362 * list 400 * list
@@ -368,10 +406,16 @@ int btrfs_requeue_work(struct btrfs_work *work)
368 &worker->workers->worker_list); 406 &worker->workers->worker_list);
369 spin_unlock_irqrestore(&worker->workers->lock, flags); 407 spin_unlock_irqrestore(&worker->workers->lock, flags);
370 } 408 }
409 if (!worker->working) {
410 wake = 1;
411 worker->working = 1;
412 }
371 413
372 spin_unlock_irqrestore(&worker->lock, flags); 414 spin_unlock_irqrestore(&worker->lock, flags);
373 415 if (wake)
416 wake_up_process(worker->task);
374out: 417out:
418
375 return 0; 419 return 0;
376} 420}
377 421
@@ -398,9 +442,10 @@ int btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work)
398 } 442 }
399 443
400 spin_lock_irqsave(&worker->lock, flags); 444 spin_lock_irqsave(&worker->lock, flags);
445
446 list_add_tail(&work->list, &worker->pending);
401 atomic_inc(&worker->num_pending); 447 atomic_inc(&worker->num_pending);
402 check_busy_worker(worker); 448 check_busy_worker(worker);
403 list_add_tail(&work->list, &worker->pending);
404 449
405 /* 450 /*
406 * avoid calling into wake_up_process if this thread has already 451 * avoid calling into wake_up_process if this thread has already
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index ee848d8585d9..ab07627084f1 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -32,7 +32,6 @@
32#include <linux/swap.h> 32#include <linux/swap.h>
33#include <linux/writeback.h> 33#include <linux/writeback.h>
34#include <linux/bit_spinlock.h> 34#include <linux/bit_spinlock.h>
35#include <linux/version.h>
36#include <linux/pagevec.h> 35#include <linux/pagevec.h>
37#include "compat.h" 36#include "compat.h"
38#include "ctree.h" 37#include "ctree.h"
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 9e46c0776816..42491d728e99 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -38,22 +38,64 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
38static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, 38static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
39 struct btrfs_path *path, int level, int slot); 39 struct btrfs_path *path, int level, int slot);
40 40
41inline void btrfs_init_path(struct btrfs_path *p)
42{
43 memset(p, 0, sizeof(*p));
44}
45
46struct btrfs_path *btrfs_alloc_path(void) 41struct btrfs_path *btrfs_alloc_path(void)
47{ 42{
48 struct btrfs_path *path; 43 struct btrfs_path *path;
49 path = kmem_cache_alloc(btrfs_path_cachep, GFP_NOFS); 44 path = kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS);
50 if (path) { 45 if (path)
51 btrfs_init_path(path);
52 path->reada = 1; 46 path->reada = 1;
53 }
54 return path; 47 return path;
55} 48}
56 49
50/*
51 * set all locked nodes in the path to blocking locks. This should
52 * be done before scheduling
53 */
54noinline void btrfs_set_path_blocking(struct btrfs_path *p)
55{
56 int i;
57 for (i = 0; i < BTRFS_MAX_LEVEL; i++) {
58 if (p->nodes[i] && p->locks[i])
59 btrfs_set_lock_blocking(p->nodes[i]);
60 }
61}
62
63/*
64 * reset all the locked nodes in the patch to spinning locks.
65 *
66 * held is used to keep lockdep happy, when lockdep is enabled
67 * we set held to a blocking lock before we go around and
68 * retake all the spinlocks in the path. You can safely use NULL
69 * for held
70 */
71noinline void btrfs_clear_path_blocking(struct btrfs_path *p,
72 struct extent_buffer *held)
73{
74 int i;
75
76#ifdef CONFIG_DEBUG_LOCK_ALLOC
77 /* lockdep really cares that we take all of these spinlocks
78 * in the right order. If any of the locks in the path are not
79 * currently blocking, it is going to complain. So, make really
80 * really sure by forcing the path to blocking before we clear
81 * the path blocking.
82 */
83 if (held)
84 btrfs_set_lock_blocking(held);
85 btrfs_set_path_blocking(p);
86#endif
87
88 for (i = BTRFS_MAX_LEVEL - 1; i >= 0; i--) {
89 if (p->nodes[i] && p->locks[i])
90 btrfs_clear_lock_blocking(p->nodes[i]);
91 }
92
93#ifdef CONFIG_DEBUG_LOCK_ALLOC
94 if (held)
95 btrfs_clear_lock_blocking(held);
96#endif
97}
98
57/* this also releases the path */ 99/* this also releases the path */
58void btrfs_free_path(struct btrfs_path *p) 100void btrfs_free_path(struct btrfs_path *p)
59{ 101{
@@ -261,7 +303,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
261 trans->transid, level, &ins); 303 trans->transid, level, &ins);
262 BUG_ON(ret); 304 BUG_ON(ret);
263 cow = btrfs_init_new_buffer(trans, root, prealloc_dest, 305 cow = btrfs_init_new_buffer(trans, root, prealloc_dest,
264 buf->len); 306 buf->len, level);
265 } else { 307 } else {
266 cow = btrfs_alloc_free_block(trans, root, buf->len, 308 cow = btrfs_alloc_free_block(trans, root, buf->len,
267 parent_start, 309 parent_start,
@@ -272,6 +314,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
272 if (IS_ERR(cow)) 314 if (IS_ERR(cow))
273 return PTR_ERR(cow); 315 return PTR_ERR(cow);
274 316
317 /* cow is set to blocking by btrfs_init_new_buffer */
318
275 copy_extent_buffer(cow, buf, 0, 0, cow->len); 319 copy_extent_buffer(cow, buf, 0, 0, cow->len);
276 btrfs_set_header_bytenr(cow, cow->start); 320 btrfs_set_header_bytenr(cow, cow->start);
277 btrfs_set_header_generation(cow, trans->transid); 321 btrfs_set_header_generation(cow, trans->transid);
@@ -388,17 +432,20 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle *trans,
388 WARN_ON(1); 432 WARN_ON(1);
389 } 433 }
390 434
391 spin_lock(&root->fs_info->hash_lock);
392 if (btrfs_header_generation(buf) == trans->transid && 435 if (btrfs_header_generation(buf) == trans->transid &&
393 btrfs_header_owner(buf) == root->root_key.objectid && 436 btrfs_header_owner(buf) == root->root_key.objectid &&
394 !btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) { 437 !btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN)) {
395 *cow_ret = buf; 438 *cow_ret = buf;
396 spin_unlock(&root->fs_info->hash_lock);
397 WARN_ON(prealloc_dest); 439 WARN_ON(prealloc_dest);
398 return 0; 440 return 0;
399 } 441 }
400 spin_unlock(&root->fs_info->hash_lock); 442
401 search_start = buf->start & ~((u64)(1024 * 1024 * 1024) - 1); 443 search_start = buf->start & ~((u64)(1024 * 1024 * 1024) - 1);
444
445 if (parent)
446 btrfs_set_lock_blocking(parent);
447 btrfs_set_lock_blocking(buf);
448
402 ret = __btrfs_cow_block(trans, root, buf, parent, 449 ret = __btrfs_cow_block(trans, root, buf, parent,
403 parent_slot, cow_ret, search_start, 0, 450 parent_slot, cow_ret, search_start, 0,
404 prealloc_dest); 451 prealloc_dest);
@@ -504,6 +551,8 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
504 if (parent_nritems == 1) 551 if (parent_nritems == 1)
505 return 0; 552 return 0;
506 553
554 btrfs_set_lock_blocking(parent);
555
507 for (i = start_slot; i < end_slot; i++) { 556 for (i = start_slot; i < end_slot; i++) {
508 int close = 1; 557 int close = 1;
509 558
@@ -564,6 +613,7 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
564 search_start = last_block; 613 search_start = last_block;
565 614
566 btrfs_tree_lock(cur); 615 btrfs_tree_lock(cur);
616 btrfs_set_lock_blocking(cur);
567 err = __btrfs_cow_block(trans, root, cur, parent, i, 617 err = __btrfs_cow_block(trans, root, cur, parent, i,
568 &cur, search_start, 618 &cur, search_start,
569 min(16 * blocksize, 619 min(16 * blocksize,
@@ -862,6 +912,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
862 return 0; 912 return 0;
863 913
864 mid = path->nodes[level]; 914 mid = path->nodes[level];
915
865 WARN_ON(!path->locks[level]); 916 WARN_ON(!path->locks[level]);
866 WARN_ON(btrfs_header_generation(mid) != trans->transid); 917 WARN_ON(btrfs_header_generation(mid) != trans->transid);
867 918
@@ -883,8 +934,9 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
883 934
884 /* promote the child to a root */ 935 /* promote the child to a root */
885 child = read_node_slot(root, mid, 0); 936 child = read_node_slot(root, mid, 0);
886 btrfs_tree_lock(child);
887 BUG_ON(!child); 937 BUG_ON(!child);
938 btrfs_tree_lock(child);
939 btrfs_set_lock_blocking(child);
888 ret = btrfs_cow_block(trans, root, child, mid, 0, &child, 0); 940 ret = btrfs_cow_block(trans, root, child, mid, 0, &child, 0);
889 BUG_ON(ret); 941 BUG_ON(ret);
890 942
@@ -900,6 +952,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
900 952
901 add_root_to_dirty_list(root); 953 add_root_to_dirty_list(root);
902 btrfs_tree_unlock(child); 954 btrfs_tree_unlock(child);
955
903 path->locks[level] = 0; 956 path->locks[level] = 0;
904 path->nodes[level] = NULL; 957 path->nodes[level] = NULL;
905 clean_tree_block(trans, root, mid); 958 clean_tree_block(trans, root, mid);
@@ -924,6 +977,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
924 left = read_node_slot(root, parent, pslot - 1); 977 left = read_node_slot(root, parent, pslot - 1);
925 if (left) { 978 if (left) {
926 btrfs_tree_lock(left); 979 btrfs_tree_lock(left);
980 btrfs_set_lock_blocking(left);
927 wret = btrfs_cow_block(trans, root, left, 981 wret = btrfs_cow_block(trans, root, left,
928 parent, pslot - 1, &left, 0); 982 parent, pslot - 1, &left, 0);
929 if (wret) { 983 if (wret) {
@@ -934,6 +988,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
934 right = read_node_slot(root, parent, pslot + 1); 988 right = read_node_slot(root, parent, pslot + 1);
935 if (right) { 989 if (right) {
936 btrfs_tree_lock(right); 990 btrfs_tree_lock(right);
991 btrfs_set_lock_blocking(right);
937 wret = btrfs_cow_block(trans, root, right, 992 wret = btrfs_cow_block(trans, root, right,
938 parent, pslot + 1, &right, 0); 993 parent, pslot + 1, &right, 0);
939 if (wret) { 994 if (wret) {
@@ -1109,6 +1164,8 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
1109 u32 left_nr; 1164 u32 left_nr;
1110 1165
1111 btrfs_tree_lock(left); 1166 btrfs_tree_lock(left);
1167 btrfs_set_lock_blocking(left);
1168
1112 left_nr = btrfs_header_nritems(left); 1169 left_nr = btrfs_header_nritems(left);
1113 if (left_nr >= BTRFS_NODEPTRS_PER_BLOCK(root) - 1) { 1170 if (left_nr >= BTRFS_NODEPTRS_PER_BLOCK(root) - 1) {
1114 wret = 1; 1171 wret = 1;
@@ -1155,7 +1212,10 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
1155 */ 1212 */
1156 if (right) { 1213 if (right) {
1157 u32 right_nr; 1214 u32 right_nr;
1215
1158 btrfs_tree_lock(right); 1216 btrfs_tree_lock(right);
1217 btrfs_set_lock_blocking(right);
1218
1159 right_nr = btrfs_header_nritems(right); 1219 right_nr = btrfs_header_nritems(right);
1160 if (right_nr >= BTRFS_NODEPTRS_PER_BLOCK(root) - 1) { 1220 if (right_nr >= BTRFS_NODEPTRS_PER_BLOCK(root) - 1) {
1161 wret = 1; 1221 wret = 1;
@@ -1210,8 +1270,7 @@ static noinline void reada_for_search(struct btrfs_root *root,
1210 struct btrfs_disk_key disk_key; 1270 struct btrfs_disk_key disk_key;
1211 u32 nritems; 1271 u32 nritems;
1212 u64 search; 1272 u64 search;
1213 u64 lowest_read; 1273 u64 target;
1214 u64 highest_read;
1215 u64 nread = 0; 1274 u64 nread = 0;
1216 int direction = path->reada; 1275 int direction = path->reada;
1217 struct extent_buffer *eb; 1276 struct extent_buffer *eb;
@@ -1235,8 +1294,7 @@ static noinline void reada_for_search(struct btrfs_root *root,
1235 return; 1294 return;
1236 } 1295 }
1237 1296
1238 highest_read = search; 1297 target = search;
1239 lowest_read = search;
1240 1298
1241 nritems = btrfs_header_nritems(node); 1299 nritems = btrfs_header_nritems(node);
1242 nr = slot; 1300 nr = slot;
@@ -1256,27 +1314,80 @@ static noinline void reada_for_search(struct btrfs_root *root,
1256 break; 1314 break;
1257 } 1315 }
1258 search = btrfs_node_blockptr(node, nr); 1316 search = btrfs_node_blockptr(node, nr);
1259 if ((search >= lowest_read && search <= highest_read) || 1317 if ((search <= target && target - search <= 65536) ||
1260 (search < lowest_read && lowest_read - search <= 16384) || 1318 (search > target && search - target <= 65536)) {
1261 (search > highest_read && search - highest_read <= 16384)) {
1262 readahead_tree_block(root, search, blocksize, 1319 readahead_tree_block(root, search, blocksize,
1263 btrfs_node_ptr_generation(node, nr)); 1320 btrfs_node_ptr_generation(node, nr));
1264 nread += blocksize; 1321 nread += blocksize;
1265 } 1322 }
1266 nscan++; 1323 nscan++;
1267 if (path->reada < 2 && (nread > (64 * 1024) || nscan > 32)) 1324 if ((nread > 65536 || nscan > 32))
1268 break; 1325 break;
1326 }
1327}
1269 1328
1270 if (nread > (256 * 1024) || nscan > 128) 1329/*
1271 break; 1330 * returns -EAGAIN if it had to drop the path, or zero if everything was in
1331 * cache
1332 */
1333static noinline int reada_for_balance(struct btrfs_root *root,
1334 struct btrfs_path *path, int level)
1335{
1336 int slot;
1337 int nritems;
1338 struct extent_buffer *parent;
1339 struct extent_buffer *eb;
1340 u64 gen;
1341 u64 block1 = 0;
1342 u64 block2 = 0;
1343 int ret = 0;
1344 int blocksize;
1345
1346 parent = path->nodes[level - 1];
1347 if (!parent)
1348 return 0;
1272 1349
1273 if (search < lowest_read) 1350 nritems = btrfs_header_nritems(parent);
1274 lowest_read = search; 1351 slot = path->slots[level];
1275 if (search > highest_read) 1352 blocksize = btrfs_level_size(root, level);
1276 highest_read = search; 1353
1354 if (slot > 0) {
1355 block1 = btrfs_node_blockptr(parent, slot - 1);
1356 gen = btrfs_node_ptr_generation(parent, slot - 1);
1357 eb = btrfs_find_tree_block(root, block1, blocksize);
1358 if (eb && btrfs_buffer_uptodate(eb, gen))
1359 block1 = 0;
1360 free_extent_buffer(eb);
1361 }
1362 if (slot < nritems) {
1363 block2 = btrfs_node_blockptr(parent, slot + 1);
1364 gen = btrfs_node_ptr_generation(parent, slot + 1);
1365 eb = btrfs_find_tree_block(root, block2, blocksize);
1366 if (eb && btrfs_buffer_uptodate(eb, gen))
1367 block2 = 0;
1368 free_extent_buffer(eb);
1277 } 1369 }
1370 if (block1 || block2) {
1371 ret = -EAGAIN;
1372 btrfs_release_path(root, path);
1373 if (block1)
1374 readahead_tree_block(root, block1, blocksize, 0);
1375 if (block2)
1376 readahead_tree_block(root, block2, blocksize, 0);
1377
1378 if (block1) {
1379 eb = read_tree_block(root, block1, blocksize, 0);
1380 free_extent_buffer(eb);
1381 }
1382 if (block1) {
1383 eb = read_tree_block(root, block2, blocksize, 0);
1384 free_extent_buffer(eb);
1385 }
1386 }
1387 return ret;
1278} 1388}
1279 1389
1390
1280/* 1391/*
1281 * when we walk down the tree, it is usually safe to unlock the higher layers 1392 * when we walk down the tree, it is usually safe to unlock the higher layers
1282 * in the tree. The exceptions are when our path goes through slot 0, because 1393 * in the tree. The exceptions are when our path goes through slot 0, because
@@ -1328,6 +1439,32 @@ static noinline void unlock_up(struct btrfs_path *path, int level,
1328} 1439}
1329 1440
1330/* 1441/*
1442 * This releases any locks held in the path starting at level and
1443 * going all the way up to the root.
1444 *
1445 * btrfs_search_slot will keep the lock held on higher nodes in a few
1446 * corner cases, such as COW of the block at slot zero in the node. This
1447 * ignores those rules, and it should only be called when there are no
1448 * more updates to be done higher up in the tree.
1449 */
1450noinline void btrfs_unlock_up_safe(struct btrfs_path *path, int level)
1451{
1452 int i;
1453
1454 if (path->keep_locks || path->lowest_level)
1455 return;
1456
1457 for (i = level; i < BTRFS_MAX_LEVEL; i++) {
1458 if (!path->nodes[i])
1459 continue;
1460 if (!path->locks[i])
1461 continue;
1462 btrfs_tree_unlock(path->nodes[i]);
1463 path->locks[i] = 0;
1464 }
1465}
1466
1467/*
1331 * look for key in the tree. path is filled in with nodes along the way 1468 * look for key in the tree. path is filled in with nodes along the way
1332 * if key is found, we return zero and you can find the item in the leaf 1469 * if key is found, we return zero and you can find the item in the leaf
1333 * level of the path (level 0) 1470 * level of the path (level 0)
@@ -1387,32 +1524,30 @@ again:
1387 int wret; 1524 int wret;
1388 1525
1389 /* is a cow on this block not required */ 1526 /* is a cow on this block not required */
1390 spin_lock(&root->fs_info->hash_lock);
1391 if (btrfs_header_generation(b) == trans->transid && 1527 if (btrfs_header_generation(b) == trans->transid &&
1392 btrfs_header_owner(b) == root->root_key.objectid && 1528 btrfs_header_owner(b) == root->root_key.objectid &&
1393 !btrfs_header_flag(b, BTRFS_HEADER_FLAG_WRITTEN)) { 1529 !btrfs_header_flag(b, BTRFS_HEADER_FLAG_WRITTEN)) {
1394 spin_unlock(&root->fs_info->hash_lock);
1395 goto cow_done; 1530 goto cow_done;
1396 } 1531 }
1397 spin_unlock(&root->fs_info->hash_lock);
1398 1532
1399 /* ok, we have to cow, is our old prealloc the right 1533 /* ok, we have to cow, is our old prealloc the right
1400 * size? 1534 * size?
1401 */ 1535 */
1402 if (prealloc_block.objectid && 1536 if (prealloc_block.objectid &&
1403 prealloc_block.offset != b->len) { 1537 prealloc_block.offset != b->len) {
1538 btrfs_release_path(root, p);
1404 btrfs_free_reserved_extent(root, 1539 btrfs_free_reserved_extent(root,
1405 prealloc_block.objectid, 1540 prealloc_block.objectid,
1406 prealloc_block.offset); 1541 prealloc_block.offset);
1407 prealloc_block.objectid = 0; 1542 prealloc_block.objectid = 0;
1543 goto again;
1408 } 1544 }
1409 1545
1410 /* 1546 /*
1411 * for higher level blocks, try not to allocate blocks 1547 * for higher level blocks, try not to allocate blocks
1412 * with the block and the parent locks held. 1548 * with the block and the parent locks held.
1413 */ 1549 */
1414 if (level > 1 && !prealloc_block.objectid && 1550 if (level > 0 && !prealloc_block.objectid) {
1415 btrfs_path_lock_waiting(p, level)) {
1416 u32 size = b->len; 1551 u32 size = b->len;
1417 u64 hint = b->start; 1552 u64 hint = b->start;
1418 1553
@@ -1425,6 +1560,8 @@ again:
1425 goto again; 1560 goto again;
1426 } 1561 }
1427 1562
1563 btrfs_set_path_blocking(p);
1564
1428 wret = btrfs_cow_block(trans, root, b, 1565 wret = btrfs_cow_block(trans, root, b,
1429 p->nodes[level + 1], 1566 p->nodes[level + 1],
1430 p->slots[level + 1], 1567 p->slots[level + 1],
@@ -1446,6 +1583,22 @@ cow_done:
1446 if (!p->skip_locking) 1583 if (!p->skip_locking)
1447 p->locks[level] = 1; 1584 p->locks[level] = 1;
1448 1585
1586 btrfs_clear_path_blocking(p, NULL);
1587
1588 /*
1589 * we have a lock on b and as long as we aren't changing
1590 * the tree, there is no way to for the items in b to change.
1591 * It is safe to drop the lock on our parent before we
1592 * go through the expensive btree search on b.
1593 *
1594 * If cow is true, then we might be changing slot zero,
1595 * which may require changing the parent. So, we can't
1596 * drop the lock until after we know which slot we're
1597 * operating on.
1598 */
1599 if (!cow)
1600 btrfs_unlock_up_safe(p, level + 1);
1601
1449 ret = check_block(root, p, level); 1602 ret = check_block(root, p, level);
1450 if (ret) { 1603 if (ret) {
1451 ret = -1; 1604 ret = -1;
@@ -1453,6 +1606,7 @@ cow_done:
1453 } 1606 }
1454 1607
1455 ret = bin_search(b, key, level, &slot); 1608 ret = bin_search(b, key, level, &slot);
1609
1456 if (level != 0) { 1610 if (level != 0) {
1457 if (ret && slot > 0) 1611 if (ret && slot > 0)
1458 slot -= 1; 1612 slot -= 1;
@@ -1460,7 +1614,16 @@ cow_done:
1460 if ((p->search_for_split || ins_len > 0) && 1614 if ((p->search_for_split || ins_len > 0) &&
1461 btrfs_header_nritems(b) >= 1615 btrfs_header_nritems(b) >=
1462 BTRFS_NODEPTRS_PER_BLOCK(root) - 3) { 1616 BTRFS_NODEPTRS_PER_BLOCK(root) - 3) {
1463 int sret = split_node(trans, root, p, level); 1617 int sret;
1618
1619 sret = reada_for_balance(root, p, level);
1620 if (sret)
1621 goto again;
1622
1623 btrfs_set_path_blocking(p);
1624 sret = split_node(trans, root, p, level);
1625 btrfs_clear_path_blocking(p, NULL);
1626
1464 BUG_ON(sret > 0); 1627 BUG_ON(sret > 0);
1465 if (sret) { 1628 if (sret) {
1466 ret = sret; 1629 ret = sret;
@@ -1468,9 +1631,19 @@ cow_done:
1468 } 1631 }
1469 b = p->nodes[level]; 1632 b = p->nodes[level];
1470 slot = p->slots[level]; 1633 slot = p->slots[level];
1471 } else if (ins_len < 0) { 1634 } else if (ins_len < 0 &&
1472 int sret = balance_level(trans, root, p, 1635 btrfs_header_nritems(b) <
1473 level); 1636 BTRFS_NODEPTRS_PER_BLOCK(root) / 4) {
1637 int sret;
1638
1639 sret = reada_for_balance(root, p, level);
1640 if (sret)
1641 goto again;
1642
1643 btrfs_set_path_blocking(p);
1644 sret = balance_level(trans, root, p, level);
1645 btrfs_clear_path_blocking(p, NULL);
1646
1474 if (sret) { 1647 if (sret) {
1475 ret = sret; 1648 ret = sret;
1476 goto done; 1649 goto done;
@@ -1504,7 +1677,7 @@ cow_done:
1504 * of the btree by dropping locks before 1677 * of the btree by dropping locks before
1505 * we read. 1678 * we read.
1506 */ 1679 */
1507 if (level > 1) { 1680 if (level > 0) {
1508 btrfs_release_path(NULL, p); 1681 btrfs_release_path(NULL, p);
1509 if (tmp) 1682 if (tmp)
1510 free_extent_buffer(tmp); 1683 free_extent_buffer(tmp);
@@ -1519,6 +1692,7 @@ cow_done:
1519 free_extent_buffer(tmp); 1692 free_extent_buffer(tmp);
1520 goto again; 1693 goto again;
1521 } else { 1694 } else {
1695 btrfs_set_path_blocking(p);
1522 if (tmp) 1696 if (tmp)
1523 free_extent_buffer(tmp); 1697 free_extent_buffer(tmp);
1524 if (should_reada) 1698 if (should_reada)
@@ -1528,14 +1702,29 @@ cow_done:
1528 b = read_node_slot(root, b, slot); 1702 b = read_node_slot(root, b, slot);
1529 } 1703 }
1530 } 1704 }
1531 if (!p->skip_locking) 1705 if (!p->skip_locking) {
1532 btrfs_tree_lock(b); 1706 int lret;
1707
1708 btrfs_clear_path_blocking(p, NULL);
1709 lret = btrfs_try_spin_lock(b);
1710
1711 if (!lret) {
1712 btrfs_set_path_blocking(p);
1713 btrfs_tree_lock(b);
1714 btrfs_clear_path_blocking(p, b);
1715 }
1716 }
1533 } else { 1717 } else {
1534 p->slots[level] = slot; 1718 p->slots[level] = slot;
1535 if (ins_len > 0 && 1719 if (ins_len > 0 &&
1536 btrfs_leaf_free_space(root, b) < ins_len) { 1720 btrfs_leaf_free_space(root, b) < ins_len) {
1537 int sret = split_leaf(trans, root, key, 1721 int sret;
1722
1723 btrfs_set_path_blocking(p);
1724 sret = split_leaf(trans, root, key,
1538 p, ins_len, ret == 0); 1725 p, ins_len, ret == 0);
1726 btrfs_clear_path_blocking(p, NULL);
1727
1539 BUG_ON(sret > 0); 1728 BUG_ON(sret > 0);
1540 if (sret) { 1729 if (sret) {
1541 ret = sret; 1730 ret = sret;
@@ -1549,12 +1738,16 @@ cow_done:
1549 } 1738 }
1550 ret = 1; 1739 ret = 1;
1551done: 1740done:
1741 /*
1742 * we don't really know what they plan on doing with the path
1743 * from here on, so for now just mark it as blocking
1744 */
1745 btrfs_set_path_blocking(p);
1552 if (prealloc_block.objectid) { 1746 if (prealloc_block.objectid) {
1553 btrfs_free_reserved_extent(root, 1747 btrfs_free_reserved_extent(root,
1554 prealloc_block.objectid, 1748 prealloc_block.objectid,
1555 prealloc_block.offset); 1749 prealloc_block.offset);
1556 } 1750 }
1557
1558 return ret; 1751 return ret;
1559} 1752}
1560 1753
@@ -1578,6 +1771,8 @@ int btrfs_merge_path(struct btrfs_trans_handle *trans,
1578 ret = btrfs_cow_block(trans, root, eb, NULL, 0, &eb, 0); 1771 ret = btrfs_cow_block(trans, root, eb, NULL, 0, &eb, 0);
1579 BUG_ON(ret); 1772 BUG_ON(ret);
1580 1773
1774 btrfs_set_lock_blocking(eb);
1775
1581 parent = eb; 1776 parent = eb;
1582 while (1) { 1777 while (1) {
1583 level = btrfs_header_level(parent); 1778 level = btrfs_header_level(parent);
@@ -1602,6 +1797,7 @@ int btrfs_merge_path(struct btrfs_trans_handle *trans,
1602 eb = read_tree_block(root, bytenr, blocksize, 1797 eb = read_tree_block(root, bytenr, blocksize,
1603 generation); 1798 generation);
1604 btrfs_tree_lock(eb); 1799 btrfs_tree_lock(eb);
1800 btrfs_set_lock_blocking(eb);
1605 } 1801 }
1606 1802
1607 /* 1803 /*
@@ -1626,6 +1822,7 @@ int btrfs_merge_path(struct btrfs_trans_handle *trans,
1626 eb = read_tree_block(root, bytenr, blocksize, 1822 eb = read_tree_block(root, bytenr, blocksize,
1627 generation); 1823 generation);
1628 btrfs_tree_lock(eb); 1824 btrfs_tree_lock(eb);
1825 btrfs_set_lock_blocking(eb);
1629 } 1826 }
1630 1827
1631 ret = btrfs_cow_block(trans, root, eb, parent, slot, 1828 ret = btrfs_cow_block(trans, root, eb, parent, slot,
@@ -2172,6 +2369,8 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
2172 2369
2173 right = read_node_slot(root, upper, slot + 1); 2370 right = read_node_slot(root, upper, slot + 1);
2174 btrfs_tree_lock(right); 2371 btrfs_tree_lock(right);
2372 btrfs_set_lock_blocking(right);
2373
2175 free_space = btrfs_leaf_free_space(root, right); 2374 free_space = btrfs_leaf_free_space(root, right);
2176 if (free_space < data_size) 2375 if (free_space < data_size)
2177 goto out_unlock; 2376 goto out_unlock;
@@ -2367,6 +2566,8 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
2367 2566
2368 left = read_node_slot(root, path->nodes[1], slot - 1); 2567 left = read_node_slot(root, path->nodes[1], slot - 1);
2369 btrfs_tree_lock(left); 2568 btrfs_tree_lock(left);
2569 btrfs_set_lock_blocking(left);
2570
2370 free_space = btrfs_leaf_free_space(root, left); 2571 free_space = btrfs_leaf_free_space(root, left);
2371 if (free_space < data_size) { 2572 if (free_space < data_size) {
2372 ret = 1; 2573 ret = 1;
@@ -2825,6 +3026,12 @@ int btrfs_split_item(struct btrfs_trans_handle *trans,
2825 path->keep_locks = 0; 3026 path->keep_locks = 0;
2826 BUG_ON(ret); 3027 BUG_ON(ret);
2827 3028
3029 /*
3030 * make sure any changes to the path from split_leaf leave it
3031 * in a blocking state
3032 */
3033 btrfs_set_path_blocking(path);
3034
2828 leaf = path->nodes[0]; 3035 leaf = path->nodes[0];
2829 BUG_ON(btrfs_leaf_free_space(root, leaf) < sizeof(struct btrfs_item)); 3036 BUG_ON(btrfs_leaf_free_space(root, leaf) < sizeof(struct btrfs_item));
2830 3037
@@ -3354,6 +3561,7 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
3354 BUG(); 3561 BUG();
3355 } 3562 }
3356out: 3563out:
3564 btrfs_unlock_up_safe(path, 1);
3357 return ret; 3565 return ret;
3358} 3566}
3359 3567
@@ -3441,15 +3649,22 @@ noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans,
3441{ 3649{
3442 int ret; 3650 int ret;
3443 u64 root_gen = btrfs_header_generation(path->nodes[1]); 3651 u64 root_gen = btrfs_header_generation(path->nodes[1]);
3652 u64 parent_start = path->nodes[1]->start;
3653 u64 parent_owner = btrfs_header_owner(path->nodes[1]);
3444 3654
3445 ret = del_ptr(trans, root, path, 1, path->slots[1]); 3655 ret = del_ptr(trans, root, path, 1, path->slots[1]);
3446 if (ret) 3656 if (ret)
3447 return ret; 3657 return ret;
3448 3658
3659 /*
3660 * btrfs_free_extent is expensive, we want to make sure we
3661 * aren't holding any locks when we call it
3662 */
3663 btrfs_unlock_up_safe(path, 0);
3664
3449 ret = btrfs_free_extent(trans, root, bytenr, 3665 ret = btrfs_free_extent(trans, root, bytenr,
3450 btrfs_level_size(root, 0), 3666 btrfs_level_size(root, 0),
3451 path->nodes[1]->start, 3667 parent_start, parent_owner,
3452 btrfs_header_owner(path->nodes[1]),
3453 root_gen, 0, 1); 3668 root_gen, 0, 1);
3454 return ret; 3669 return ret;
3455} 3670}
@@ -3721,6 +3936,7 @@ find_next_key:
3721 */ 3936 */
3722 if (slot >= nritems) { 3937 if (slot >= nritems) {
3723 path->slots[level] = slot; 3938 path->slots[level] = slot;
3939 btrfs_set_path_blocking(path);
3724 sret = btrfs_find_next_key(root, path, min_key, level, 3940 sret = btrfs_find_next_key(root, path, min_key, level,
3725 cache_only, min_trans); 3941 cache_only, min_trans);
3726 if (sret == 0) { 3942 if (sret == 0) {
@@ -3738,16 +3954,20 @@ find_next_key:
3738 unlock_up(path, level, 1); 3954 unlock_up(path, level, 1);
3739 goto out; 3955 goto out;
3740 } 3956 }
3957 btrfs_set_path_blocking(path);
3741 cur = read_node_slot(root, cur, slot); 3958 cur = read_node_slot(root, cur, slot);
3742 3959
3743 btrfs_tree_lock(cur); 3960 btrfs_tree_lock(cur);
3961
3744 path->locks[level - 1] = 1; 3962 path->locks[level - 1] = 1;
3745 path->nodes[level - 1] = cur; 3963 path->nodes[level - 1] = cur;
3746 unlock_up(path, level, 1); 3964 unlock_up(path, level, 1);
3965 btrfs_clear_path_blocking(path, NULL);
3747 } 3966 }
3748out: 3967out:
3749 if (ret == 0) 3968 if (ret == 0)
3750 memcpy(min_key, &found_key, sizeof(found_key)); 3969 memcpy(min_key, &found_key, sizeof(found_key));
3970 btrfs_set_path_blocking(path);
3751 return ret; 3971 return ret;
3752} 3972}
3753 3973
@@ -3843,6 +4063,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
3843 if (ret < 0) 4063 if (ret < 0)
3844 return ret; 4064 return ret;
3845 4065
4066 btrfs_set_path_blocking(path);
3846 nritems = btrfs_header_nritems(path->nodes[0]); 4067 nritems = btrfs_header_nritems(path->nodes[0]);
3847 /* 4068 /*
3848 * by releasing the path above we dropped all our locks. A balance 4069 * by releasing the path above we dropped all our locks. A balance
@@ -3873,6 +4094,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
3873 free_extent_buffer(next); 4094 free_extent_buffer(next);
3874 } 4095 }
3875 4096
4097 /* the path was set to blocking above */
3876 if (level == 1 && (path->locks[1] || path->skip_locking) && 4098 if (level == 1 && (path->locks[1] || path->skip_locking) &&
3877 path->reada) 4099 path->reada)
3878 reada_for_search(root, path, level, slot, 0); 4100 reada_for_search(root, path, level, slot, 0);
@@ -3881,6 +4103,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
3881 if (!path->skip_locking) { 4103 if (!path->skip_locking) {
3882 WARN_ON(!btrfs_tree_locked(c)); 4104 WARN_ON(!btrfs_tree_locked(c));
3883 btrfs_tree_lock(next); 4105 btrfs_tree_lock(next);
4106 btrfs_set_lock_blocking(next);
3884 } 4107 }
3885 break; 4108 break;
3886 } 4109 }
@@ -3897,12 +4120,15 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path)
3897 path->locks[level] = 1; 4120 path->locks[level] = 1;
3898 if (!level) 4121 if (!level)
3899 break; 4122 break;
4123
4124 btrfs_set_path_blocking(path);
3900 if (level == 1 && path->locks[1] && path->reada) 4125 if (level == 1 && path->locks[1] && path->reada)
3901 reada_for_search(root, path, level, slot, 0); 4126 reada_for_search(root, path, level, slot, 0);
3902 next = read_node_slot(root, next, 0); 4127 next = read_node_slot(root, next, 0);
3903 if (!path->skip_locking) { 4128 if (!path->skip_locking) {
3904 WARN_ON(!btrfs_tree_locked(path->nodes[level])); 4129 WARN_ON(!btrfs_tree_locked(path->nodes[level]));
3905 btrfs_tree_lock(next); 4130 btrfs_tree_lock(next);
4131 btrfs_set_lock_blocking(next);
3906 } 4132 }
3907 } 4133 }
3908done: 4134done:
@@ -3927,6 +4153,7 @@ int btrfs_previous_item(struct btrfs_root *root,
3927 4153
3928 while (1) { 4154 while (1) {
3929 if (path->slots[0] == 0) { 4155 if (path->slots[0] == 0) {
4156 btrfs_set_path_blocking(path);
3930 ret = btrfs_prev_leaf(root, path); 4157 ret = btrfs_prev_leaf(root, path);
3931 if (ret != 0) 4158 if (ret != 0)
3932 return ret; 4159 return ret;
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index eee060f88113..766b31ae3186 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -43,11 +43,7 @@ struct btrfs_ordered_sum;
43 43
44#define BTRFS_ACL_NOT_CACHED ((void *)-1) 44#define BTRFS_ACL_NOT_CACHED ((void *)-1)
45 45
46#ifdef CONFIG_LOCKDEP 46#define BTRFS_MAX_LEVEL 8
47# define BTRFS_MAX_LEVEL 7
48#else
49# define BTRFS_MAX_LEVEL 8
50#endif
51 47
52/* holds pointers to all of the tree roots */ 48/* holds pointers to all of the tree roots */
53#define BTRFS_ROOT_TREE_OBJECTID 1ULL 49#define BTRFS_ROOT_TREE_OBJECTID 1ULL
@@ -454,17 +450,11 @@ struct btrfs_timespec {
454 __le32 nsec; 450 __le32 nsec;
455} __attribute__ ((__packed__)); 451} __attribute__ ((__packed__));
456 452
457typedef enum { 453enum btrfs_compression_type {
458 BTRFS_COMPRESS_NONE = 0, 454 BTRFS_COMPRESS_NONE = 0,
459 BTRFS_COMPRESS_ZLIB = 1, 455 BTRFS_COMPRESS_ZLIB = 1,
460 BTRFS_COMPRESS_LAST = 2, 456 BTRFS_COMPRESS_LAST = 2,
461} btrfs_compression_type; 457};
462
463/* we don't understand any encryption methods right now */
464typedef enum {
465 BTRFS_ENCRYPTION_NONE = 0,
466 BTRFS_ENCRYPTION_LAST = 1,
467} btrfs_encryption_type;
468 458
469struct btrfs_inode_item { 459struct btrfs_inode_item {
470 /* nfs style generation number */ 460 /* nfs style generation number */
@@ -701,9 +691,7 @@ struct btrfs_fs_info {
701 struct btrfs_transaction *running_transaction; 691 struct btrfs_transaction *running_transaction;
702 wait_queue_head_t transaction_throttle; 692 wait_queue_head_t transaction_throttle;
703 wait_queue_head_t transaction_wait; 693 wait_queue_head_t transaction_wait;
704
705 wait_queue_head_t async_submit_wait; 694 wait_queue_head_t async_submit_wait;
706 wait_queue_head_t tree_log_wait;
707 695
708 struct btrfs_super_block super_copy; 696 struct btrfs_super_block super_copy;
709 struct btrfs_super_block super_for_commit; 697 struct btrfs_super_block super_for_commit;
@@ -711,7 +699,6 @@ struct btrfs_fs_info {
711 struct super_block *sb; 699 struct super_block *sb;
712 struct inode *btree_inode; 700 struct inode *btree_inode;
713 struct backing_dev_info bdi; 701 struct backing_dev_info bdi;
714 spinlock_t hash_lock;
715 struct mutex trans_mutex; 702 struct mutex trans_mutex;
716 struct mutex tree_log_mutex; 703 struct mutex tree_log_mutex;
717 struct mutex transaction_kthread_mutex; 704 struct mutex transaction_kthread_mutex;
@@ -730,10 +717,6 @@ struct btrfs_fs_info {
730 atomic_t async_submit_draining; 717 atomic_t async_submit_draining;
731 atomic_t nr_async_bios; 718 atomic_t nr_async_bios;
732 atomic_t async_delalloc_pages; 719 atomic_t async_delalloc_pages;
733 atomic_t tree_log_writers;
734 atomic_t tree_log_commit;
735 unsigned long tree_log_batch;
736 u64 tree_log_transid;
737 720
738 /* 721 /*
739 * this is used by the balancing code to wait for all the pending 722 * this is used by the balancing code to wait for all the pending
@@ -833,7 +816,14 @@ struct btrfs_root {
833 struct kobject root_kobj; 816 struct kobject root_kobj;
834 struct completion kobj_unregister; 817 struct completion kobj_unregister;
835 struct mutex objectid_mutex; 818 struct mutex objectid_mutex;
819
836 struct mutex log_mutex; 820 struct mutex log_mutex;
821 wait_queue_head_t log_writer_wait;
822 wait_queue_head_t log_commit_wait[2];
823 atomic_t log_writers;
824 atomic_t log_commit[2];
825 unsigned long log_transid;
826 unsigned long log_batch;
837 827
838 u64 objectid; 828 u64 objectid;
839 u64 last_trans; 829 u64 last_trans;
@@ -1721,7 +1711,8 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
1721 u64 empty_size); 1711 u64 empty_size);
1722struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, 1712struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans,
1723 struct btrfs_root *root, 1713 struct btrfs_root *root,
1724 u64 bytenr, u32 blocksize); 1714 u64 bytenr, u32 blocksize,
1715 int level);
1725int btrfs_alloc_extent(struct btrfs_trans_handle *trans, 1716int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
1726 struct btrfs_root *root, 1717 struct btrfs_root *root,
1727 u64 num_bytes, u64 parent, u64 min_bytes, 1718 u64 num_bytes, u64 parent, u64 min_bytes,
@@ -1840,7 +1831,9 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
1840void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p); 1831void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p);
1841struct btrfs_path *btrfs_alloc_path(void); 1832struct btrfs_path *btrfs_alloc_path(void);
1842void btrfs_free_path(struct btrfs_path *p); 1833void btrfs_free_path(struct btrfs_path *p);
1843void btrfs_init_path(struct btrfs_path *p); 1834void btrfs_set_path_blocking(struct btrfs_path *p);
1835void btrfs_unlock_up_safe(struct btrfs_path *p, int level);
1836
1844int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root, 1837int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1845 struct btrfs_path *path, int slot, int nr); 1838 struct btrfs_path *path, int slot, int nr);
1846int btrfs_del_leaf(struct btrfs_trans_handle *trans, 1839int btrfs_del_leaf(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 81a313874ae5..adda739a0215 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -16,7 +16,6 @@
16 * Boston, MA 021110-1307, USA. 16 * Boston, MA 021110-1307, USA.
17 */ 17 */
18 18
19#include <linux/version.h>
20#include <linux/fs.h> 19#include <linux/fs.h>
21#include <linux/blkdev.h> 20#include <linux/blkdev.h>
22#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
@@ -76,6 +75,40 @@ struct async_submit_bio {
76 struct btrfs_work work; 75 struct btrfs_work work;
77}; 76};
78 77
78/* These are used to set the lockdep class on the extent buffer locks.
79 * The class is set by the readpage_end_io_hook after the buffer has
80 * passed csum validation but before the pages are unlocked.
81 *
82 * The lockdep class is also set by btrfs_init_new_buffer on freshly
83 * allocated blocks.
84 *
85 * The class is based on the level in the tree block, which allows lockdep
86 * to know that lower nodes nest inside the locks of higher nodes.
87 *
88 * We also add a check to make sure the highest level of the tree is
89 * the same as our lockdep setup here. If BTRFS_MAX_LEVEL changes, this
90 * code needs update as well.
91 */
92#ifdef CONFIG_DEBUG_LOCK_ALLOC
93# if BTRFS_MAX_LEVEL != 8
94# error
95# endif
96static struct lock_class_key btrfs_eb_class[BTRFS_MAX_LEVEL + 1];
97static const char *btrfs_eb_name[BTRFS_MAX_LEVEL + 1] = {
98 /* leaf */
99 "btrfs-extent-00",
100 "btrfs-extent-01",
101 "btrfs-extent-02",
102 "btrfs-extent-03",
103 "btrfs-extent-04",
104 "btrfs-extent-05",
105 "btrfs-extent-06",
106 "btrfs-extent-07",
107 /* highest possible level */
108 "btrfs-extent-08",
109};
110#endif
111
79/* 112/*
80 * extents on the btree inode are pretty simple, there's one extent 113 * extents on the btree inode are pretty simple, there's one extent
81 * that covers the entire device 114 * that covers the entire device
@@ -348,6 +381,15 @@ static int check_tree_block_fsid(struct btrfs_root *root,
348 return ret; 381 return ret;
349} 382}
350 383
384#ifdef CONFIG_DEBUG_LOCK_ALLOC
385void btrfs_set_buffer_lockdep_class(struct extent_buffer *eb, int level)
386{
387 lockdep_set_class_and_name(&eb->lock,
388 &btrfs_eb_class[level],
389 btrfs_eb_name[level]);
390}
391#endif
392
351static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end, 393static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
352 struct extent_state *state) 394 struct extent_state *state)
353{ 395{
@@ -393,6 +435,8 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
393 } 435 }
394 found_level = btrfs_header_level(eb); 436 found_level = btrfs_header_level(eb);
395 437
438 btrfs_set_buffer_lockdep_class(eb, found_level);
439
396 ret = csum_tree_block(root, eb, 1); 440 ret = csum_tree_block(root, eb, 1);
397 if (ret) 441 if (ret)
398 ret = -EIO; 442 ret = -EIO;
@@ -800,7 +844,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
800 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); 844 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid);
801 845
802 if (ret == 0) 846 if (ret == 0)
803 buf->flags |= EXTENT_UPTODATE; 847 set_bit(EXTENT_BUFFER_UPTODATE, &buf->bflags);
804 else 848 else
805 WARN_ON(1); 849 WARN_ON(1);
806 return buf; 850 return buf;
@@ -814,6 +858,10 @@ int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
814 if (btrfs_header_generation(buf) == 858 if (btrfs_header_generation(buf) ==
815 root->fs_info->running_transaction->transid) { 859 root->fs_info->running_transaction->transid) {
816 WARN_ON(!btrfs_tree_locked(buf)); 860 WARN_ON(!btrfs_tree_locked(buf));
861
862 /* ugh, clear_extent_buffer_dirty can be expensive */
863 btrfs_set_lock_blocking(buf);
864
817 clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, 865 clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree,
818 buf); 866 buf);
819 } 867 }
@@ -850,6 +898,14 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
850 spin_lock_init(&root->list_lock); 898 spin_lock_init(&root->list_lock);
851 mutex_init(&root->objectid_mutex); 899 mutex_init(&root->objectid_mutex);
852 mutex_init(&root->log_mutex); 900 mutex_init(&root->log_mutex);
901 init_waitqueue_head(&root->log_writer_wait);
902 init_waitqueue_head(&root->log_commit_wait[0]);
903 init_waitqueue_head(&root->log_commit_wait[1]);
904 atomic_set(&root->log_commit[0], 0);
905 atomic_set(&root->log_commit[1], 0);
906 atomic_set(&root->log_writers, 0);
907 root->log_batch = 0;
908 root->log_transid = 0;
853 extent_io_tree_init(&root->dirty_log_pages, 909 extent_io_tree_init(&root->dirty_log_pages,
854 fs_info->btree_inode->i_mapping, GFP_NOFS); 910 fs_info->btree_inode->i_mapping, GFP_NOFS);
855 911
@@ -934,15 +990,16 @@ int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans,
934 return 0; 990 return 0;
935} 991}
936 992
937int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, 993static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
938 struct btrfs_fs_info *fs_info) 994 struct btrfs_fs_info *fs_info)
939{ 995{
940 struct btrfs_root *root; 996 struct btrfs_root *root;
941 struct btrfs_root *tree_root = fs_info->tree_root; 997 struct btrfs_root *tree_root = fs_info->tree_root;
998 struct extent_buffer *leaf;
942 999
943 root = kzalloc(sizeof(*root), GFP_NOFS); 1000 root = kzalloc(sizeof(*root), GFP_NOFS);
944 if (!root) 1001 if (!root)
945 return -ENOMEM; 1002 return ERR_PTR(-ENOMEM);
946 1003
947 __setup_root(tree_root->nodesize, tree_root->leafsize, 1004 __setup_root(tree_root->nodesize, tree_root->leafsize,
948 tree_root->sectorsize, tree_root->stripesize, 1005 tree_root->sectorsize, tree_root->stripesize,
@@ -951,12 +1008,23 @@ int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans,
951 root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID; 1008 root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID;
952 root->root_key.type = BTRFS_ROOT_ITEM_KEY; 1009 root->root_key.type = BTRFS_ROOT_ITEM_KEY;
953 root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; 1010 root->root_key.offset = BTRFS_TREE_LOG_OBJECTID;
1011 /*
1012 * log trees do not get reference counted because they go away
1013 * before a real commit is actually done. They do store pointers
1014 * to file data extents, and those reference counts still get
1015 * updated (along with back refs to the log tree).
1016 */
954 root->ref_cows = 0; 1017 root->ref_cows = 0;
955 1018
956 root->node = btrfs_alloc_free_block(trans, root, root->leafsize, 1019 leaf = btrfs_alloc_free_block(trans, root, root->leafsize,
957 0, BTRFS_TREE_LOG_OBJECTID, 1020 0, BTRFS_TREE_LOG_OBJECTID,
958 trans->transid, 0, 0, 0); 1021 trans->transid, 0, 0, 0);
1022 if (IS_ERR(leaf)) {
1023 kfree(root);
1024 return ERR_CAST(leaf);
1025 }
959 1026
1027 root->node = leaf;
960 btrfs_set_header_nritems(root->node, 0); 1028 btrfs_set_header_nritems(root->node, 0);
961 btrfs_set_header_level(root->node, 0); 1029 btrfs_set_header_level(root->node, 0);
962 btrfs_set_header_bytenr(root->node, root->node->start); 1030 btrfs_set_header_bytenr(root->node, root->node->start);
@@ -968,7 +1036,48 @@ int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans,
968 BTRFS_FSID_SIZE); 1036 BTRFS_FSID_SIZE);
969 btrfs_mark_buffer_dirty(root->node); 1037 btrfs_mark_buffer_dirty(root->node);
970 btrfs_tree_unlock(root->node); 1038 btrfs_tree_unlock(root->node);
971 fs_info->log_root_tree = root; 1039 return root;
1040}
1041
1042int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans,
1043 struct btrfs_fs_info *fs_info)
1044{
1045 struct btrfs_root *log_root;
1046
1047 log_root = alloc_log_tree(trans, fs_info);
1048 if (IS_ERR(log_root))
1049 return PTR_ERR(log_root);
1050 WARN_ON(fs_info->log_root_tree);
1051 fs_info->log_root_tree = log_root;
1052 return 0;
1053}
1054
1055int btrfs_add_log_tree(struct btrfs_trans_handle *trans,
1056 struct btrfs_root *root)
1057{
1058 struct btrfs_root *log_root;
1059 struct btrfs_inode_item *inode_item;
1060
1061 log_root = alloc_log_tree(trans, root->fs_info);
1062 if (IS_ERR(log_root))
1063 return PTR_ERR(log_root);
1064
1065 log_root->last_trans = trans->transid;
1066 log_root->root_key.offset = root->root_key.objectid;
1067
1068 inode_item = &log_root->root_item.inode;
1069 inode_item->generation = cpu_to_le64(1);
1070 inode_item->size = cpu_to_le64(3);
1071 inode_item->nlink = cpu_to_le32(1);
1072 inode_item->nbytes = cpu_to_le64(root->leafsize);
1073 inode_item->mode = cpu_to_le32(S_IFDIR | 0755);
1074
1075 btrfs_set_root_bytenr(&log_root->root_item, log_root->node->start);
1076 btrfs_set_root_generation(&log_root->root_item, trans->transid);
1077
1078 WARN_ON(root->log_root);
1079 root->log_root = log_root;
1080 root->log_transid = 0;
972 return 0; 1081 return 0;
973} 1082}
974 1083
@@ -1136,7 +1245,6 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
1136{ 1245{
1137 struct btrfs_fs_info *info = (struct btrfs_fs_info *)congested_data; 1246 struct btrfs_fs_info *info = (struct btrfs_fs_info *)congested_data;
1138 int ret = 0; 1247 int ret = 0;
1139 struct list_head *cur;
1140 struct btrfs_device *device; 1248 struct btrfs_device *device;
1141 struct backing_dev_info *bdi; 1249 struct backing_dev_info *bdi;
1142#if 0 1250#if 0
@@ -1144,8 +1252,7 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
1144 btrfs_congested_async(info, 0)) 1252 btrfs_congested_async(info, 0))
1145 return 1; 1253 return 1;
1146#endif 1254#endif
1147 list_for_each(cur, &info->fs_devices->devices) { 1255 list_for_each_entry(device, &info->fs_devices->devices, dev_list) {
1148 device = list_entry(cur, struct btrfs_device, dev_list);
1149 if (!device->bdev) 1256 if (!device->bdev)
1150 continue; 1257 continue;
1151 bdi = blk_get_backing_dev_info(device->bdev); 1258 bdi = blk_get_backing_dev_info(device->bdev);
@@ -1163,13 +1270,11 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
1163 */ 1270 */
1164static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page) 1271static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
1165{ 1272{
1166 struct list_head *cur;
1167 struct btrfs_device *device; 1273 struct btrfs_device *device;
1168 struct btrfs_fs_info *info; 1274 struct btrfs_fs_info *info;
1169 1275
1170 info = (struct btrfs_fs_info *)bdi->unplug_io_data; 1276 info = (struct btrfs_fs_info *)bdi->unplug_io_data;
1171 list_for_each(cur, &info->fs_devices->devices) { 1277 list_for_each_entry(device, &info->fs_devices->devices, dev_list) {
1172 device = list_entry(cur, struct btrfs_device, dev_list);
1173 if (!device->bdev) 1278 if (!device->bdev)
1174 continue; 1279 continue;
1175 1280
@@ -1447,7 +1552,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1447 INIT_LIST_HEAD(&fs_info->dead_roots); 1552 INIT_LIST_HEAD(&fs_info->dead_roots);
1448 INIT_LIST_HEAD(&fs_info->hashers); 1553 INIT_LIST_HEAD(&fs_info->hashers);
1449 INIT_LIST_HEAD(&fs_info->delalloc_inodes); 1554 INIT_LIST_HEAD(&fs_info->delalloc_inodes);
1450 spin_lock_init(&fs_info->hash_lock);
1451 spin_lock_init(&fs_info->delalloc_lock); 1555 spin_lock_init(&fs_info->delalloc_lock);
1452 spin_lock_init(&fs_info->new_trans_lock); 1556 spin_lock_init(&fs_info->new_trans_lock);
1453 spin_lock_init(&fs_info->ref_cache_lock); 1557 spin_lock_init(&fs_info->ref_cache_lock);
@@ -1535,10 +1639,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1535 init_waitqueue_head(&fs_info->transaction_throttle); 1639 init_waitqueue_head(&fs_info->transaction_throttle);
1536 init_waitqueue_head(&fs_info->transaction_wait); 1640 init_waitqueue_head(&fs_info->transaction_wait);
1537 init_waitqueue_head(&fs_info->async_submit_wait); 1641 init_waitqueue_head(&fs_info->async_submit_wait);
1538 init_waitqueue_head(&fs_info->tree_log_wait);
1539 atomic_set(&fs_info->tree_log_commit, 0);
1540 atomic_set(&fs_info->tree_log_writers, 0);
1541 fs_info->tree_log_transid = 0;
1542 1642
1543 __setup_root(4096, 4096, 4096, 4096, tree_root, 1643 __setup_root(4096, 4096, 4096, 4096, tree_root,
1544 fs_info, BTRFS_ROOT_TREE_OBJECTID); 1644 fs_info, BTRFS_ROOT_TREE_OBJECTID);
@@ -1627,6 +1727,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1627 * low idle thresh 1727 * low idle thresh
1628 */ 1728 */
1629 fs_info->endio_workers.idle_thresh = 4; 1729 fs_info->endio_workers.idle_thresh = 4;
1730 fs_info->endio_meta_workers.idle_thresh = 4;
1731
1630 fs_info->endio_write_workers.idle_thresh = 64; 1732 fs_info->endio_write_workers.idle_thresh = 64;
1631 fs_info->endio_meta_write_workers.idle_thresh = 64; 1733 fs_info->endio_meta_write_workers.idle_thresh = 64;
1632 1734
@@ -1720,7 +1822,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1720 ret = find_and_setup_root(tree_root, fs_info, 1822 ret = find_and_setup_root(tree_root, fs_info,
1721 BTRFS_DEV_TREE_OBJECTID, dev_root); 1823 BTRFS_DEV_TREE_OBJECTID, dev_root);
1722 dev_root->track_dirty = 1; 1824 dev_root->track_dirty = 1;
1723
1724 if (ret) 1825 if (ret)
1725 goto fail_extent_root; 1826 goto fail_extent_root;
1726 1827
@@ -1740,13 +1841,13 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1740 fs_info->system_alloc_profile = fs_info->metadata_alloc_profile; 1841 fs_info->system_alloc_profile = fs_info->metadata_alloc_profile;
1741 fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root, 1842 fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root,
1742 "btrfs-cleaner"); 1843 "btrfs-cleaner");
1743 if (!fs_info->cleaner_kthread) 1844 if (IS_ERR(fs_info->cleaner_kthread))
1744 goto fail_csum_root; 1845 goto fail_csum_root;
1745 1846
1746 fs_info->transaction_kthread = kthread_run(transaction_kthread, 1847 fs_info->transaction_kthread = kthread_run(transaction_kthread,
1747 tree_root, 1848 tree_root,
1748 "btrfs-transaction"); 1849 "btrfs-transaction");
1749 if (!fs_info->transaction_kthread) 1850 if (IS_ERR(fs_info->transaction_kthread))
1750 goto fail_cleaner; 1851 goto fail_cleaner;
1751 1852
1752 if (btrfs_super_log_root(disk_super) != 0) { 1853 if (btrfs_super_log_root(disk_super) != 0) {
@@ -1828,13 +1929,14 @@ fail_sb_buffer:
1828fail_iput: 1929fail_iput:
1829 invalidate_inode_pages2(fs_info->btree_inode->i_mapping); 1930 invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
1830 iput(fs_info->btree_inode); 1931 iput(fs_info->btree_inode);
1831fail: 1932
1832 btrfs_close_devices(fs_info->fs_devices); 1933 btrfs_close_devices(fs_info->fs_devices);
1833 btrfs_mapping_tree_free(&fs_info->mapping_tree); 1934 btrfs_mapping_tree_free(&fs_info->mapping_tree);
1935 bdi_destroy(&fs_info->bdi);
1834 1936
1937fail:
1835 kfree(extent_root); 1938 kfree(extent_root);
1836 kfree(tree_root); 1939 kfree(tree_root);
1837 bdi_destroy(&fs_info->bdi);
1838 kfree(fs_info); 1940 kfree(fs_info);
1839 kfree(chunk_root); 1941 kfree(chunk_root);
1840 kfree(dev_root); 1942 kfree(dev_root);
@@ -1995,7 +2097,6 @@ static int write_dev_supers(struct btrfs_device *device,
1995 2097
1996int write_all_supers(struct btrfs_root *root, int max_mirrors) 2098int write_all_supers(struct btrfs_root *root, int max_mirrors)
1997{ 2099{
1998 struct list_head *cur;
1999 struct list_head *head = &root->fs_info->fs_devices->devices; 2100 struct list_head *head = &root->fs_info->fs_devices->devices;
2000 struct btrfs_device *dev; 2101 struct btrfs_device *dev;
2001 struct btrfs_super_block *sb; 2102 struct btrfs_super_block *sb;
@@ -2011,8 +2112,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
2011 2112
2012 sb = &root->fs_info->super_for_commit; 2113 sb = &root->fs_info->super_for_commit;
2013 dev_item = &sb->dev_item; 2114 dev_item = &sb->dev_item;
2014 list_for_each(cur, head) { 2115 list_for_each_entry(dev, head, dev_list) {
2015 dev = list_entry(cur, struct btrfs_device, dev_list);
2016 if (!dev->bdev) { 2116 if (!dev->bdev) {
2017 total_errors++; 2117 total_errors++;
2018 continue; 2118 continue;
@@ -2045,8 +2145,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
2045 } 2145 }
2046 2146
2047 total_errors = 0; 2147 total_errors = 0;
2048 list_for_each(cur, head) { 2148 list_for_each_entry(dev, head, dev_list) {
2049 dev = list_entry(cur, struct btrfs_device, dev_list);
2050 if (!dev->bdev) 2149 if (!dev->bdev)
2051 continue; 2150 continue;
2052 if (!dev->in_fs_metadata || !dev->writeable) 2151 if (!dev->in_fs_metadata || !dev->writeable)
@@ -2260,6 +2359,8 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
2260 u64 transid = btrfs_header_generation(buf); 2359 u64 transid = btrfs_header_generation(buf);
2261 struct inode *btree_inode = root->fs_info->btree_inode; 2360 struct inode *btree_inode = root->fs_info->btree_inode;
2262 2361
2362 btrfs_set_lock_blocking(buf);
2363
2263 WARN_ON(!btrfs_tree_locked(buf)); 2364 WARN_ON(!btrfs_tree_locked(buf));
2264 if (transid != root->fs_info->generation) { 2365 if (transid != root->fs_info->generation) {
2265 printk(KERN_CRIT "btrfs transid mismatch buffer %llu, " 2366 printk(KERN_CRIT "btrfs transid mismatch buffer %llu, "
@@ -2302,14 +2403,13 @@ int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid)
2302 int ret; 2403 int ret;
2303 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); 2404 ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid);
2304 if (ret == 0) 2405 if (ret == 0)
2305 buf->flags |= EXTENT_UPTODATE; 2406 set_bit(EXTENT_BUFFER_UPTODATE, &buf->bflags);
2306 return ret; 2407 return ret;
2307} 2408}
2308 2409
2309int btree_lock_page_hook(struct page *page) 2410int btree_lock_page_hook(struct page *page)
2310{ 2411{
2311 struct inode *inode = page->mapping->host; 2412 struct inode *inode = page->mapping->host;
2312 struct btrfs_root *root = BTRFS_I(inode)->root;
2313 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; 2413 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
2314 struct extent_buffer *eb; 2414 struct extent_buffer *eb;
2315 unsigned long len; 2415 unsigned long len;
@@ -2324,9 +2424,7 @@ int btree_lock_page_hook(struct page *page)
2324 goto out; 2424 goto out;
2325 2425
2326 btrfs_tree_lock(eb); 2426 btrfs_tree_lock(eb);
2327 spin_lock(&root->fs_info->hash_lock);
2328 btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN); 2427 btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN);
2329 spin_unlock(&root->fs_info->hash_lock);
2330 btrfs_tree_unlock(eb); 2428 btrfs_tree_unlock(eb);
2331 free_extent_buffer(eb); 2429 free_extent_buffer(eb);
2332out: 2430out:
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index c0ff404c31b7..95029db227be 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -98,5 +98,17 @@ int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans,
98 struct btrfs_fs_info *fs_info); 98 struct btrfs_fs_info *fs_info);
99int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, 99int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans,
100 struct btrfs_fs_info *fs_info); 100 struct btrfs_fs_info *fs_info);
101int btrfs_add_log_tree(struct btrfs_trans_handle *trans,
102 struct btrfs_root *root);
101int btree_lock_page_hook(struct page *page); 103int btree_lock_page_hook(struct page *page);
104
105
106#ifdef CONFIG_DEBUG_LOCK_ALLOC
107void btrfs_set_buffer_lockdep_class(struct extent_buffer *eb, int level);
108#else
109static inline void btrfs_set_buffer_lockdep_class(struct extent_buffer *eb,
110 int level)
111{
112}
113#endif
102#endif 114#endif
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 293da650873f..0a5d796c9f7e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -19,7 +19,7 @@
19#include <linux/pagemap.h> 19#include <linux/pagemap.h>
20#include <linux/writeback.h> 20#include <linux/writeback.h>
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/version.h> 22#include <linux/sort.h>
23#include "compat.h" 23#include "compat.h"
24#include "hash.h" 24#include "hash.h"
25#include "crc32c.h" 25#include "crc32c.h"
@@ -30,7 +30,6 @@
30#include "volumes.h" 30#include "volumes.h"
31#include "locking.h" 31#include "locking.h"
32#include "ref-cache.h" 32#include "ref-cache.h"
33#include "compat.h"
34 33
35#define PENDING_EXTENT_INSERT 0 34#define PENDING_EXTENT_INSERT 0
36#define PENDING_EXTENT_DELETE 1 35#define PENDING_EXTENT_DELETE 1
@@ -326,10 +325,8 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,
326 u64 flags) 325 u64 flags)
327{ 326{
328 struct list_head *head = &info->space_info; 327 struct list_head *head = &info->space_info;
329 struct list_head *cur;
330 struct btrfs_space_info *found; 328 struct btrfs_space_info *found;
331 list_for_each(cur, head) { 329 list_for_each_entry(found, head, list) {
332 found = list_entry(cur, struct btrfs_space_info, list);
333 if (found->flags == flags) 330 if (found->flags == flags)
334 return found; 331 return found;
335 } 332 }
@@ -1326,8 +1323,25 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
1326int btrfs_extent_post_op(struct btrfs_trans_handle *trans, 1323int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
1327 struct btrfs_root *root) 1324 struct btrfs_root *root)
1328{ 1325{
1329 finish_current_insert(trans, root->fs_info->extent_root, 1); 1326 u64 start;
1330 del_pending_extents(trans, root->fs_info->extent_root, 1); 1327 u64 end;
1328 int ret;
1329
1330 while(1) {
1331 finish_current_insert(trans, root->fs_info->extent_root, 1);
1332 del_pending_extents(trans, root->fs_info->extent_root, 1);
1333
1334 /* is there more work to do? */
1335 ret = find_first_extent_bit(&root->fs_info->pending_del,
1336 0, &start, &end, EXTENT_WRITEBACK);
1337 if (!ret)
1338 continue;
1339 ret = find_first_extent_bit(&root->fs_info->extent_ins,
1340 0, &start, &end, EXTENT_WRITEBACK);
1341 if (!ret)
1342 continue;
1343 break;
1344 }
1331 return 0; 1345 return 0;
1332} 1346}
1333 1347
@@ -1525,15 +1539,55 @@ out:
1525 return ret; 1539 return ret;
1526} 1540}
1527 1541
1528int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, 1542/* when a block goes through cow, we update the reference counts of
1529 struct extent_buffer *orig_buf, struct extent_buffer *buf, 1543 * everything that block points to. The internal pointers of the block
1530 u32 *nr_extents) 1544 * can be in just about any order, and it is likely to have clusters of
1545 * things that are close together and clusters of things that are not.
1546 *
1547 * To help reduce the seeks that come with updating all of these reference
1548 * counts, sort them by byte number before actual updates are done.
1549 *
1550 * struct refsort is used to match byte number to slot in the btree block.
1551 * we sort based on the byte number and then use the slot to actually
1552 * find the item.
1553 *
1554 * struct refsort is smaller than strcut btrfs_item and smaller than
1555 * struct btrfs_key_ptr. Since we're currently limited to the page size
1556 * for a btree block, there's no way for a kmalloc of refsorts for a
1557 * single node to be bigger than a page.
1558 */
1559struct refsort {
1560 u64 bytenr;
1561 u32 slot;
1562};
1563
1564/*
1565 * for passing into sort()
1566 */
1567static int refsort_cmp(const void *a_void, const void *b_void)
1568{
1569 const struct refsort *a = a_void;
1570 const struct refsort *b = b_void;
1571
1572 if (a->bytenr < b->bytenr)
1573 return -1;
1574 if (a->bytenr > b->bytenr)
1575 return 1;
1576 return 0;
1577}
1578
1579
1580noinline int btrfs_inc_ref(struct btrfs_trans_handle *trans,
1581 struct btrfs_root *root,
1582 struct extent_buffer *orig_buf,
1583 struct extent_buffer *buf, u32 *nr_extents)
1531{ 1584{
1532 u64 bytenr; 1585 u64 bytenr;
1533 u64 ref_root; 1586 u64 ref_root;
1534 u64 orig_root; 1587 u64 orig_root;
1535 u64 ref_generation; 1588 u64 ref_generation;
1536 u64 orig_generation; 1589 u64 orig_generation;
1590 struct refsort *sorted;
1537 u32 nritems; 1591 u32 nritems;
1538 u32 nr_file_extents = 0; 1592 u32 nr_file_extents = 0;
1539 struct btrfs_key key; 1593 struct btrfs_key key;
@@ -1542,6 +1596,8 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1542 int level; 1596 int level;
1543 int ret = 0; 1597 int ret = 0;
1544 int faili = 0; 1598 int faili = 0;
1599 int refi = 0;
1600 int slot;
1545 int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *, 1601 int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
1546 u64, u64, u64, u64, u64, u64, u64, u64); 1602 u64, u64, u64, u64, u64, u64, u64, u64);
1547 1603
@@ -1553,6 +1609,9 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1553 nritems = btrfs_header_nritems(buf); 1609 nritems = btrfs_header_nritems(buf);
1554 level = btrfs_header_level(buf); 1610 level = btrfs_header_level(buf);
1555 1611
1612 sorted = kmalloc(sizeof(struct refsort) * nritems, GFP_NOFS);
1613 BUG_ON(!sorted);
1614
1556 if (root->ref_cows) { 1615 if (root->ref_cows) {
1557 process_func = __btrfs_inc_extent_ref; 1616 process_func = __btrfs_inc_extent_ref;
1558 } else { 1617 } else {
@@ -1565,6 +1624,11 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1565 process_func = __btrfs_update_extent_ref; 1624 process_func = __btrfs_update_extent_ref;
1566 } 1625 }
1567 1626
1627 /*
1628 * we make two passes through the items. In the first pass we
1629 * only record the byte number and slot. Then we sort based on
1630 * byte number and do the actual work based on the sorted results
1631 */
1568 for (i = 0; i < nritems; i++) { 1632 for (i = 0; i < nritems; i++) {
1569 cond_resched(); 1633 cond_resched();
1570 if (level == 0) { 1634 if (level == 0) {
@@ -1581,6 +1645,32 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1581 continue; 1645 continue;
1582 1646
1583 nr_file_extents++; 1647 nr_file_extents++;
1648 sorted[refi].bytenr = bytenr;
1649 sorted[refi].slot = i;
1650 refi++;
1651 } else {
1652 bytenr = btrfs_node_blockptr(buf, i);
1653 sorted[refi].bytenr = bytenr;
1654 sorted[refi].slot = i;
1655 refi++;
1656 }
1657 }
1658 /*
1659 * if refi == 0, we didn't actually put anything into the sorted
1660 * array and we're done
1661 */
1662 if (refi == 0)
1663 goto out;
1664
1665 sort(sorted, refi, sizeof(struct refsort), refsort_cmp, NULL);
1666
1667 for (i = 0; i < refi; i++) {
1668 cond_resched();
1669 slot = sorted[i].slot;
1670 bytenr = sorted[i].bytenr;
1671
1672 if (level == 0) {
1673 btrfs_item_key_to_cpu(buf, &key, slot);
1584 1674
1585 ret = process_func(trans, root, bytenr, 1675 ret = process_func(trans, root, bytenr,
1586 orig_buf->start, buf->start, 1676 orig_buf->start, buf->start,
@@ -1589,25 +1679,25 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1589 key.objectid); 1679 key.objectid);
1590 1680
1591 if (ret) { 1681 if (ret) {
1592 faili = i; 1682 faili = slot;
1593 WARN_ON(1); 1683 WARN_ON(1);
1594 goto fail; 1684 goto fail;
1595 } 1685 }
1596 } else { 1686 } else {
1597 bytenr = btrfs_node_blockptr(buf, i);
1598 ret = process_func(trans, root, bytenr, 1687 ret = process_func(trans, root, bytenr,
1599 orig_buf->start, buf->start, 1688 orig_buf->start, buf->start,
1600 orig_root, ref_root, 1689 orig_root, ref_root,
1601 orig_generation, ref_generation, 1690 orig_generation, ref_generation,
1602 level - 1); 1691 level - 1);
1603 if (ret) { 1692 if (ret) {
1604 faili = i; 1693 faili = slot;
1605 WARN_ON(1); 1694 WARN_ON(1);
1606 goto fail; 1695 goto fail;
1607 } 1696 }
1608 } 1697 }
1609 } 1698 }
1610out: 1699out:
1700 kfree(sorted);
1611 if (nr_extents) { 1701 if (nr_extents) {
1612 if (level == 0) 1702 if (level == 0)
1613 *nr_extents = nr_file_extents; 1703 *nr_extents = nr_file_extents;
@@ -1616,6 +1706,7 @@ out:
1616 } 1706 }
1617 return 0; 1707 return 0;
1618fail: 1708fail:
1709 kfree(sorted);
1619 WARN_ON(1); 1710 WARN_ON(1);
1620 return ret; 1711 return ret;
1621} 1712}
@@ -2137,13 +2228,12 @@ static int finish_current_insert(struct btrfs_trans_handle *trans,
2137 u64 end; 2228 u64 end;
2138 u64 priv; 2229 u64 priv;
2139 u64 search = 0; 2230 u64 search = 0;
2140 u64 skipped = 0;
2141 struct btrfs_fs_info *info = extent_root->fs_info; 2231 struct btrfs_fs_info *info = extent_root->fs_info;
2142 struct btrfs_path *path; 2232 struct btrfs_path *path;
2143 struct pending_extent_op *extent_op, *tmp; 2233 struct pending_extent_op *extent_op, *tmp;
2144 struct list_head insert_list, update_list; 2234 struct list_head insert_list, update_list;
2145 int ret; 2235 int ret;
2146 int num_inserts = 0, max_inserts; 2236 int num_inserts = 0, max_inserts, restart = 0;
2147 2237
2148 path = btrfs_alloc_path(); 2238 path = btrfs_alloc_path();
2149 INIT_LIST_HEAD(&insert_list); 2239 INIT_LIST_HEAD(&insert_list);
@@ -2159,18 +2249,19 @@ again:
2159 ret = find_first_extent_bit(&info->extent_ins, search, &start, 2249 ret = find_first_extent_bit(&info->extent_ins, search, &start,
2160 &end, EXTENT_WRITEBACK); 2250 &end, EXTENT_WRITEBACK);
2161 if (ret) { 2251 if (ret) {
2162 if (skipped && all && !num_inserts) { 2252 if (restart && !num_inserts &&
2163 skipped = 0; 2253 list_empty(&update_list)) {
2254 restart = 0;
2164 search = 0; 2255 search = 0;
2165 continue; 2256 continue;
2166 } 2257 }
2167 mutex_unlock(&info->extent_ins_mutex);
2168 break; 2258 break;
2169 } 2259 }
2170 2260
2171 ret = try_lock_extent(&info->extent_ins, start, end, GFP_NOFS); 2261 ret = try_lock_extent(&info->extent_ins, start, end, GFP_NOFS);
2172 if (!ret) { 2262 if (!ret) {
2173 skipped = 1; 2263 if (all)
2264 restart = 1;
2174 search = end + 1; 2265 search = end + 1;
2175 if (need_resched()) { 2266 if (need_resched()) {
2176 mutex_unlock(&info->extent_ins_mutex); 2267 mutex_unlock(&info->extent_ins_mutex);
@@ -2189,7 +2280,7 @@ again:
2189 list_add_tail(&extent_op->list, &insert_list); 2280 list_add_tail(&extent_op->list, &insert_list);
2190 search = end + 1; 2281 search = end + 1;
2191 if (num_inserts == max_inserts) { 2282 if (num_inserts == max_inserts) {
2192 mutex_unlock(&info->extent_ins_mutex); 2283 restart = 1;
2193 break; 2284 break;
2194 } 2285 }
2195 } else if (extent_op->type == PENDING_BACKREF_UPDATE) { 2286 } else if (extent_op->type == PENDING_BACKREF_UPDATE) {
@@ -2205,7 +2296,6 @@ again:
2205 * somebody marked this thing for deletion then just unlock it and be 2296 * somebody marked this thing for deletion then just unlock it and be
2206 * done, the free_extents will handle it 2297 * done, the free_extents will handle it
2207 */ 2298 */
2208 mutex_lock(&info->extent_ins_mutex);
2209 list_for_each_entry_safe(extent_op, tmp, &update_list, list) { 2299 list_for_each_entry_safe(extent_op, tmp, &update_list, list) {
2210 clear_extent_bits(&info->extent_ins, extent_op->bytenr, 2300 clear_extent_bits(&info->extent_ins, extent_op->bytenr,
2211 extent_op->bytenr + extent_op->num_bytes - 1, 2301 extent_op->bytenr + extent_op->num_bytes - 1,
@@ -2227,6 +2317,10 @@ again:
2227 if (!list_empty(&update_list)) { 2317 if (!list_empty(&update_list)) {
2228 ret = update_backrefs(trans, extent_root, path, &update_list); 2318 ret = update_backrefs(trans, extent_root, path, &update_list);
2229 BUG_ON(ret); 2319 BUG_ON(ret);
2320
2321 /* we may have COW'ed new blocks, so lets start over */
2322 if (all)
2323 restart = 1;
2230 } 2324 }
2231 2325
2232 /* 2326 /*
@@ -2234,9 +2328,9 @@ again:
2234 * need to make sure everything is cleaned then reset everything and 2328 * need to make sure everything is cleaned then reset everything and
2235 * go back to the beginning 2329 * go back to the beginning
2236 */ 2330 */
2237 if (!num_inserts && all && skipped) { 2331 if (!num_inserts && restart) {
2238 search = 0; 2332 search = 0;
2239 skipped = 0; 2333 restart = 0;
2240 INIT_LIST_HEAD(&update_list); 2334 INIT_LIST_HEAD(&update_list);
2241 INIT_LIST_HEAD(&insert_list); 2335 INIT_LIST_HEAD(&insert_list);
2242 goto again; 2336 goto again;
@@ -2293,27 +2387,19 @@ again:
2293 BUG_ON(ret); 2387 BUG_ON(ret);
2294 2388
2295 /* 2389 /*
2296 * if we broke out of the loop in order to insert stuff because we hit 2390 * if restart is set for whatever reason we need to go back and start
2297 * the maximum number of inserts at a time we can handle, then loop 2391 * searching through the pending list again.
2298 * back and pick up where we left off 2392 *
2299 */ 2393 * We just inserted some extents, which could have resulted in new
2300 if (num_inserts == max_inserts) { 2394 * blocks being allocated, which would result in new blocks needing
2301 INIT_LIST_HEAD(&insert_list); 2395 * updates, so if all is set we _must_ restart to get the updated
2302 INIT_LIST_HEAD(&update_list); 2396 * blocks.
2303 num_inserts = 0;
2304 goto again;
2305 }
2306
2307 /*
2308 * again, if we need to make absolutely sure there are no more pending
2309 * extent operations left and we know that we skipped some, go back to
2310 * the beginning and do it all again
2311 */ 2397 */
2312 if (all && skipped) { 2398 if (restart || all) {
2313 INIT_LIST_HEAD(&insert_list); 2399 INIT_LIST_HEAD(&insert_list);
2314 INIT_LIST_HEAD(&update_list); 2400 INIT_LIST_HEAD(&update_list);
2315 search = 0; 2401 search = 0;
2316 skipped = 0; 2402 restart = 0;
2317 num_inserts = 0; 2403 num_inserts = 0;
2318 goto again; 2404 goto again;
2319 } 2405 }
@@ -2547,6 +2633,7 @@ again:
2547 if (ret) { 2633 if (ret) {
2548 if (all && skipped && !nr) { 2634 if (all && skipped && !nr) {
2549 search = 0; 2635 search = 0;
2636 skipped = 0;
2550 continue; 2637 continue;
2551 } 2638 }
2552 mutex_unlock(&info->extent_ins_mutex); 2639 mutex_unlock(&info->extent_ins_mutex);
@@ -2633,6 +2720,8 @@ again:
2633 goto again; 2720 goto again;
2634 } 2721 }
2635 2722
2723 if (!err)
2724 finish_current_insert(trans, extent_root, 0);
2636 return err; 2725 return err;
2637} 2726}
2638 2727
@@ -2700,13 +2789,9 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
2700 /* if metadata always pin */ 2789 /* if metadata always pin */
2701 if (owner_objectid < BTRFS_FIRST_FREE_OBJECTID) { 2790 if (owner_objectid < BTRFS_FIRST_FREE_OBJECTID) {
2702 if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { 2791 if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) {
2703 struct btrfs_block_group_cache *cache; 2792 mutex_lock(&root->fs_info->pinned_mutex);
2704 2793 btrfs_update_pinned_extents(root, bytenr, num_bytes, 1);
2705 /* btrfs_free_reserved_extent */ 2794 mutex_unlock(&root->fs_info->pinned_mutex);
2706 cache = btrfs_lookup_block_group(root->fs_info, bytenr);
2707 BUG_ON(!cache);
2708 btrfs_add_free_space(cache, bytenr, num_bytes);
2709 put_block_group(cache);
2710 update_reserved_extents(root, bytenr, num_bytes, 0); 2795 update_reserved_extents(root, bytenr, num_bytes, 0);
2711 return 0; 2796 return 0;
2712 } 2797 }
@@ -2787,7 +2872,8 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
2787 2872
2788 if (data & BTRFS_BLOCK_GROUP_METADATA) { 2873 if (data & BTRFS_BLOCK_GROUP_METADATA) {
2789 last_ptr = &root->fs_info->last_alloc; 2874 last_ptr = &root->fs_info->last_alloc;
2790 empty_cluster = 64 * 1024; 2875 if (!btrfs_test_opt(root, SSD))
2876 empty_cluster = 64 * 1024;
2791 } 2877 }
2792 2878
2793 if ((data & BTRFS_BLOCK_GROUP_DATA) && btrfs_test_opt(root, SSD)) 2879 if ((data & BTRFS_BLOCK_GROUP_DATA) && btrfs_test_opt(root, SSD))
@@ -3014,7 +3100,6 @@ loop_check:
3014static void dump_space_info(struct btrfs_space_info *info, u64 bytes) 3100static void dump_space_info(struct btrfs_space_info *info, u64 bytes)
3015{ 3101{
3016 struct btrfs_block_group_cache *cache; 3102 struct btrfs_block_group_cache *cache;
3017 struct list_head *l;
3018 3103
3019 printk(KERN_INFO "space_info has %llu free, is %sfull\n", 3104 printk(KERN_INFO "space_info has %llu free, is %sfull\n",
3020 (unsigned long long)(info->total_bytes - info->bytes_used - 3105 (unsigned long long)(info->total_bytes - info->bytes_used -
@@ -3022,8 +3107,7 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes)
3022 (info->full) ? "" : "not "); 3107 (info->full) ? "" : "not ");
3023 3108
3024 down_read(&info->groups_sem); 3109 down_read(&info->groups_sem);
3025 list_for_each(l, &info->block_groups) { 3110 list_for_each_entry(cache, &info->block_groups, list) {
3026 cache = list_entry(l, struct btrfs_block_group_cache, list);
3027 spin_lock(&cache->lock); 3111 spin_lock(&cache->lock);
3028 printk(KERN_INFO "block group %llu has %llu bytes, %llu used " 3112 printk(KERN_INFO "block group %llu has %llu bytes, %llu used "
3029 "%llu pinned %llu reserved\n", 3113 "%llu pinned %llu reserved\n",
@@ -3332,7 +3416,8 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
3332 3416
3333struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, 3417struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans,
3334 struct btrfs_root *root, 3418 struct btrfs_root *root,
3335 u64 bytenr, u32 blocksize) 3419 u64 bytenr, u32 blocksize,
3420 int level)
3336{ 3421{
3337 struct extent_buffer *buf; 3422 struct extent_buffer *buf;
3338 3423
@@ -3340,9 +3425,13 @@ struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans,
3340 if (!buf) 3425 if (!buf)
3341 return ERR_PTR(-ENOMEM); 3426 return ERR_PTR(-ENOMEM);
3342 btrfs_set_header_generation(buf, trans->transid); 3427 btrfs_set_header_generation(buf, trans->transid);
3428 btrfs_set_buffer_lockdep_class(buf, level);
3343 btrfs_tree_lock(buf); 3429 btrfs_tree_lock(buf);
3344 clean_tree_block(trans, root, buf); 3430 clean_tree_block(trans, root, buf);
3431
3432 btrfs_set_lock_blocking(buf);
3345 btrfs_set_buffer_uptodate(buf); 3433 btrfs_set_buffer_uptodate(buf);
3434
3346 if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { 3435 if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) {
3347 set_extent_dirty(&root->dirty_log_pages, buf->start, 3436 set_extent_dirty(&root->dirty_log_pages, buf->start,
3348 buf->start + buf->len - 1, GFP_NOFS); 3437 buf->start + buf->len - 1, GFP_NOFS);
@@ -3351,6 +3440,7 @@ struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans,
3351 buf->start + buf->len - 1, GFP_NOFS); 3440 buf->start + buf->len - 1, GFP_NOFS);
3352 } 3441 }
3353 trans->blocks_used++; 3442 trans->blocks_used++;
3443 /* this returns a buffer locked for blocking */
3354 return buf; 3444 return buf;
3355} 3445}
3356 3446
@@ -3379,7 +3469,8 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
3379 return ERR_PTR(ret); 3469 return ERR_PTR(ret);
3380 } 3470 }
3381 3471
3382 buf = btrfs_init_new_buffer(trans, root, ins.objectid, blocksize); 3472 buf = btrfs_init_new_buffer(trans, root, ins.objectid,
3473 blocksize, level);
3383 return buf; 3474 return buf;
3384} 3475}
3385 3476
@@ -3388,36 +3479,73 @@ int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
3388{ 3479{
3389 u64 leaf_owner; 3480 u64 leaf_owner;
3390 u64 leaf_generation; 3481 u64 leaf_generation;
3482 struct refsort *sorted;
3391 struct btrfs_key key; 3483 struct btrfs_key key;
3392 struct btrfs_file_extent_item *fi; 3484 struct btrfs_file_extent_item *fi;
3393 int i; 3485 int i;
3394 int nritems; 3486 int nritems;
3395 int ret; 3487 int ret;
3488 int refi = 0;
3489 int slot;
3396 3490
3397 BUG_ON(!btrfs_is_leaf(leaf)); 3491 BUG_ON(!btrfs_is_leaf(leaf));
3398 nritems = btrfs_header_nritems(leaf); 3492 nritems = btrfs_header_nritems(leaf);
3399 leaf_owner = btrfs_header_owner(leaf); 3493 leaf_owner = btrfs_header_owner(leaf);
3400 leaf_generation = btrfs_header_generation(leaf); 3494 leaf_generation = btrfs_header_generation(leaf);
3401 3495
3496 sorted = kmalloc(sizeof(*sorted) * nritems, GFP_NOFS);
3497 /* we do this loop twice. The first time we build a list
3498 * of the extents we have a reference on, then we sort the list
3499 * by bytenr. The second time around we actually do the
3500 * extent freeing.
3501 */
3402 for (i = 0; i < nritems; i++) { 3502 for (i = 0; i < nritems; i++) {
3403 u64 disk_bytenr; 3503 u64 disk_bytenr;
3404 cond_resched(); 3504 cond_resched();
3405 3505
3406 btrfs_item_key_to_cpu(leaf, &key, i); 3506 btrfs_item_key_to_cpu(leaf, &key, i);
3507
3508 /* only extents have references, skip everything else */
3407 if (btrfs_key_type(&key) != BTRFS_EXTENT_DATA_KEY) 3509 if (btrfs_key_type(&key) != BTRFS_EXTENT_DATA_KEY)
3408 continue; 3510 continue;
3511
3409 fi = btrfs_item_ptr(leaf, i, struct btrfs_file_extent_item); 3512 fi = btrfs_item_ptr(leaf, i, struct btrfs_file_extent_item);
3513
3514 /* inline extents live in the btree, they don't have refs */
3410 if (btrfs_file_extent_type(leaf, fi) == 3515 if (btrfs_file_extent_type(leaf, fi) ==
3411 BTRFS_FILE_EXTENT_INLINE) 3516 BTRFS_FILE_EXTENT_INLINE)
3412 continue; 3517 continue;
3413 /* 3518
3414 * FIXME make sure to insert a trans record that
3415 * repeats the snapshot del on crash
3416 */
3417 disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi); 3519 disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi);
3520
3521 /* holes don't have refs */
3418 if (disk_bytenr == 0) 3522 if (disk_bytenr == 0)
3419 continue; 3523 continue;
3420 3524
3525 sorted[refi].bytenr = disk_bytenr;
3526 sorted[refi].slot = i;
3527 refi++;
3528 }
3529
3530 if (refi == 0)
3531 goto out;
3532
3533 sort(sorted, refi, sizeof(struct refsort), refsort_cmp, NULL);
3534
3535 for (i = 0; i < refi; i++) {
3536 u64 disk_bytenr;
3537
3538 disk_bytenr = sorted[i].bytenr;
3539 slot = sorted[i].slot;
3540
3541 cond_resched();
3542
3543 btrfs_item_key_to_cpu(leaf, &key, slot);
3544 if (btrfs_key_type(&key) != BTRFS_EXTENT_DATA_KEY)
3545 continue;
3546
3547 fi = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item);
3548
3421 ret = __btrfs_free_extent(trans, root, disk_bytenr, 3549 ret = __btrfs_free_extent(trans, root, disk_bytenr,
3422 btrfs_file_extent_disk_num_bytes(leaf, fi), 3550 btrfs_file_extent_disk_num_bytes(leaf, fi),
3423 leaf->start, leaf_owner, leaf_generation, 3551 leaf->start, leaf_owner, leaf_generation,
@@ -3428,6 +3556,8 @@ int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
3428 wake_up(&root->fs_info->transaction_throttle); 3556 wake_up(&root->fs_info->transaction_throttle);
3429 cond_resched(); 3557 cond_resched();
3430 } 3558 }
3559out:
3560 kfree(sorted);
3431 return 0; 3561 return 0;
3432} 3562}
3433 3563
@@ -3437,9 +3567,25 @@ static noinline int cache_drop_leaf_ref(struct btrfs_trans_handle *trans,
3437{ 3567{
3438 int i; 3568 int i;
3439 int ret; 3569 int ret;
3440 struct btrfs_extent_info *info = ref->extents; 3570 struct btrfs_extent_info *info;
3571 struct refsort *sorted;
3572
3573 if (ref->nritems == 0)
3574 return 0;
3575
3576 sorted = kmalloc(sizeof(*sorted) * ref->nritems, GFP_NOFS);
3577 for (i = 0; i < ref->nritems; i++) {
3578 sorted[i].bytenr = ref->extents[i].bytenr;
3579 sorted[i].slot = i;
3580 }
3581 sort(sorted, ref->nritems, sizeof(struct refsort), refsort_cmp, NULL);
3441 3582
3583 /*
3584 * the items in the ref were sorted when the ref was inserted
3585 * into the ref cache, so this is already in order
3586 */
3442 for (i = 0; i < ref->nritems; i++) { 3587 for (i = 0; i < ref->nritems; i++) {
3588 info = ref->extents + sorted[i].slot;
3443 ret = __btrfs_free_extent(trans, root, info->bytenr, 3589 ret = __btrfs_free_extent(trans, root, info->bytenr,
3444 info->num_bytes, ref->bytenr, 3590 info->num_bytes, ref->bytenr,
3445 ref->owner, ref->generation, 3591 ref->owner, ref->generation,
@@ -3453,6 +3599,7 @@ static noinline int cache_drop_leaf_ref(struct btrfs_trans_handle *trans,
3453 info++; 3599 info++;
3454 } 3600 }
3455 3601
3602 kfree(sorted);
3456 return 0; 3603 return 0;
3457} 3604}
3458 3605
@@ -3497,6 +3644,152 @@ static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start,
3497} 3644}
3498 3645
3499/* 3646/*
3647 * this is used while deleting old snapshots, and it drops the refs
3648 * on a whole subtree starting from a level 1 node.
3649 *
3650 * The idea is to sort all the leaf pointers, and then drop the
3651 * ref on all the leaves in order. Most of the time the leaves
3652 * will have ref cache entries, so no leaf IOs will be required to
3653 * find the extents they have references on.
3654 *
3655 * For each leaf, any references it has are also dropped in order
3656 *
3657 * This ends up dropping the references in something close to optimal
3658 * order for reading and modifying the extent allocation tree.
3659 */
3660static noinline int drop_level_one_refs(struct btrfs_trans_handle *trans,
3661 struct btrfs_root *root,
3662 struct btrfs_path *path)
3663{
3664 u64 bytenr;
3665 u64 root_owner;
3666 u64 root_gen;
3667 struct extent_buffer *eb = path->nodes[1];
3668 struct extent_buffer *leaf;
3669 struct btrfs_leaf_ref *ref;
3670 struct refsort *sorted = NULL;
3671 int nritems = btrfs_header_nritems(eb);
3672 int ret;
3673 int i;
3674 int refi = 0;
3675 int slot = path->slots[1];
3676 u32 blocksize = btrfs_level_size(root, 0);
3677 u32 refs;
3678
3679 if (nritems == 0)
3680 goto out;
3681
3682 root_owner = btrfs_header_owner(eb);
3683 root_gen = btrfs_header_generation(eb);
3684 sorted = kmalloc(sizeof(*sorted) * nritems, GFP_NOFS);
3685
3686 /*
3687 * step one, sort all the leaf pointers so we don't scribble
3688 * randomly into the extent allocation tree
3689 */
3690 for (i = slot; i < nritems; i++) {
3691 sorted[refi].bytenr = btrfs_node_blockptr(eb, i);
3692 sorted[refi].slot = i;
3693 refi++;
3694 }
3695
3696 /*
3697 * nritems won't be zero, but if we're picking up drop_snapshot
3698 * after a crash, slot might be > 0, so double check things
3699 * just in case.
3700 */
3701 if (refi == 0)
3702 goto out;
3703
3704 sort(sorted, refi, sizeof(struct refsort), refsort_cmp, NULL);
3705
3706 /*
3707 * the first loop frees everything the leaves point to
3708 */
3709 for (i = 0; i < refi; i++) {
3710 u64 ptr_gen;
3711
3712 bytenr = sorted[i].bytenr;
3713
3714 /*
3715 * check the reference count on this leaf. If it is > 1
3716 * we just decrement it below and don't update any
3717 * of the refs the leaf points to.
3718 */
3719 ret = drop_snap_lookup_refcount(root, bytenr, blocksize, &refs);
3720 BUG_ON(ret);
3721 if (refs != 1)
3722 continue;
3723
3724 ptr_gen = btrfs_node_ptr_generation(eb, sorted[i].slot);
3725
3726 /*
3727 * the leaf only had one reference, which means the
3728 * only thing pointing to this leaf is the snapshot
3729 * we're deleting. It isn't possible for the reference
3730 * count to increase again later
3731 *
3732 * The reference cache is checked for the leaf,
3733 * and if found we'll be able to drop any refs held by
3734 * the leaf without needing to read it in.
3735 */
3736 ref = btrfs_lookup_leaf_ref(root, bytenr);
3737 if (ref && ref->generation != ptr_gen) {
3738 btrfs_free_leaf_ref(root, ref);
3739 ref = NULL;
3740 }
3741 if (ref) {
3742 ret = cache_drop_leaf_ref(trans, root, ref);
3743 BUG_ON(ret);
3744 btrfs_remove_leaf_ref(root, ref);
3745 btrfs_free_leaf_ref(root, ref);
3746 } else {
3747 /*
3748 * the leaf wasn't in the reference cache, so
3749 * we have to read it.
3750 */
3751 leaf = read_tree_block(root, bytenr, blocksize,
3752 ptr_gen);
3753 ret = btrfs_drop_leaf_ref(trans, root, leaf);
3754 BUG_ON(ret);
3755 free_extent_buffer(leaf);
3756 }
3757 atomic_inc(&root->fs_info->throttle_gen);
3758 wake_up(&root->fs_info->transaction_throttle);
3759 cond_resched();
3760 }
3761
3762 /*
3763 * run through the loop again to free the refs on the leaves.
3764 * This is faster than doing it in the loop above because
3765 * the leaves are likely to be clustered together. We end up
3766 * working in nice chunks on the extent allocation tree.
3767 */
3768 for (i = 0; i < refi; i++) {
3769 bytenr = sorted[i].bytenr;
3770 ret = __btrfs_free_extent(trans, root, bytenr,
3771 blocksize, eb->start,
3772 root_owner, root_gen, 0, 1);
3773 BUG_ON(ret);
3774
3775 atomic_inc(&root->fs_info->throttle_gen);
3776 wake_up(&root->fs_info->transaction_throttle);
3777 cond_resched();
3778 }
3779out:
3780 kfree(sorted);
3781
3782 /*
3783 * update the path to show we've processed the entire level 1
3784 * node. This will get saved into the root's drop_snapshot_progress
3785 * field so these drops are not repeated again if this transaction
3786 * commits.
3787 */
3788 path->slots[1] = nritems;
3789 return 0;
3790}
3791
3792/*
3500 * helper function for drop_snapshot, this walks down the tree dropping ref 3793 * helper function for drop_snapshot, this walks down the tree dropping ref
3501 * counts as it goes. 3794 * counts as it goes.
3502 */ 3795 */
@@ -3511,7 +3804,6 @@ static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
3511 struct extent_buffer *next; 3804 struct extent_buffer *next;
3512 struct extent_buffer *cur; 3805 struct extent_buffer *cur;
3513 struct extent_buffer *parent; 3806 struct extent_buffer *parent;
3514 struct btrfs_leaf_ref *ref;
3515 u32 blocksize; 3807 u32 blocksize;
3516 int ret; 3808 int ret;
3517 u32 refs; 3809 u32 refs;
@@ -3538,17 +3830,46 @@ static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
3538 if (path->slots[*level] >= 3830 if (path->slots[*level] >=
3539 btrfs_header_nritems(cur)) 3831 btrfs_header_nritems(cur))
3540 break; 3832 break;
3833
3834 /* the new code goes down to level 1 and does all the
3835 * leaves pointed to that node in bulk. So, this check
3836 * for level 0 will always be false.
3837 *
3838 * But, the disk format allows the drop_snapshot_progress
3839 * field in the root to leave things in a state where
3840 * a leaf will need cleaning up here. If someone crashes
3841 * with the old code and then boots with the new code,
3842 * we might find a leaf here.
3843 */
3541 if (*level == 0) { 3844 if (*level == 0) {
3542 ret = btrfs_drop_leaf_ref(trans, root, cur); 3845 ret = btrfs_drop_leaf_ref(trans, root, cur);
3543 BUG_ON(ret); 3846 BUG_ON(ret);
3544 break; 3847 break;
3545 } 3848 }
3849
3850 /*
3851 * once we get to level one, process the whole node
3852 * at once, including everything below it.
3853 */
3854 if (*level == 1) {
3855 ret = drop_level_one_refs(trans, root, path);
3856 BUG_ON(ret);
3857 break;
3858 }
3859
3546 bytenr = btrfs_node_blockptr(cur, path->slots[*level]); 3860 bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
3547 ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]); 3861 ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]);
3548 blocksize = btrfs_level_size(root, *level - 1); 3862 blocksize = btrfs_level_size(root, *level - 1);
3549 3863
3550 ret = drop_snap_lookup_refcount(root, bytenr, blocksize, &refs); 3864 ret = drop_snap_lookup_refcount(root, bytenr, blocksize, &refs);
3551 BUG_ON(ret); 3865 BUG_ON(ret);
3866
3867 /*
3868 * if there is more than one reference, we don't need
3869 * to read that node to drop any references it has. We
3870 * just drop the ref we hold on that node and move on to the
3871 * next slot in this level.
3872 */
3552 if (refs != 1) { 3873 if (refs != 1) {
3553 parent = path->nodes[*level]; 3874 parent = path->nodes[*level];
3554 root_owner = btrfs_header_owner(parent); 3875 root_owner = btrfs_header_owner(parent);
@@ -3567,46 +3888,12 @@ static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
3567 3888
3568 continue; 3889 continue;
3569 } 3890 }
3891
3570 /* 3892 /*
3571 * at this point, we have a single ref, and since the 3893 * we need to keep freeing things in the next level down.
3572 * only place referencing this extent is a dead root 3894 * read the block and loop around to process it
3573 * the reference count should never go higher.
3574 * So, we don't need to check it again
3575 */ 3895 */
3576 if (*level == 1) { 3896 next = read_tree_block(root, bytenr, blocksize, ptr_gen);
3577 ref = btrfs_lookup_leaf_ref(root, bytenr);
3578 if (ref && ref->generation != ptr_gen) {
3579 btrfs_free_leaf_ref(root, ref);
3580 ref = NULL;
3581 }
3582 if (ref) {
3583 ret = cache_drop_leaf_ref(trans, root, ref);
3584 BUG_ON(ret);
3585 btrfs_remove_leaf_ref(root, ref);
3586 btrfs_free_leaf_ref(root, ref);
3587 *level = 0;
3588 break;
3589 }
3590 }
3591 next = btrfs_find_tree_block(root, bytenr, blocksize);
3592 if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
3593 free_extent_buffer(next);
3594
3595 next = read_tree_block(root, bytenr, blocksize,
3596 ptr_gen);
3597 cond_resched();
3598#if 0
3599 /*
3600 * this is a debugging check and can go away
3601 * the ref should never go all the way down to 1
3602 * at this point
3603 */
3604 ret = lookup_extent_ref(NULL, root, bytenr, blocksize,
3605 &refs);
3606 BUG_ON(ret);
3607 WARN_ON(refs != 1);
3608#endif
3609 }
3610 WARN_ON(*level <= 0); 3897 WARN_ON(*level <= 0);
3611 if (path->nodes[*level-1]) 3898 if (path->nodes[*level-1])
3612 free_extent_buffer(path->nodes[*level-1]); 3899 free_extent_buffer(path->nodes[*level-1]);
@@ -3631,11 +3918,16 @@ out:
3631 root_owner = btrfs_header_owner(parent); 3918 root_owner = btrfs_header_owner(parent);
3632 root_gen = btrfs_header_generation(parent); 3919 root_gen = btrfs_header_generation(parent);
3633 3920
3921 /*
3922 * cleanup and free the reference on the last node
3923 * we processed
3924 */
3634 ret = __btrfs_free_extent(trans, root, bytenr, blocksize, 3925 ret = __btrfs_free_extent(trans, root, bytenr, blocksize,
3635 parent->start, root_owner, root_gen, 3926 parent->start, root_owner, root_gen,
3636 *level, 1); 3927 *level, 1);
3637 free_extent_buffer(path->nodes[*level]); 3928 free_extent_buffer(path->nodes[*level]);
3638 path->nodes[*level] = NULL; 3929 path->nodes[*level] = NULL;
3930
3639 *level += 1; 3931 *level += 1;
3640 BUG_ON(ret); 3932 BUG_ON(ret);
3641 3933
@@ -3687,6 +3979,7 @@ static noinline int walk_down_subtree(struct btrfs_trans_handle *trans,
3687 3979
3688 next = read_tree_block(root, bytenr, blocksize, ptr_gen); 3980 next = read_tree_block(root, bytenr, blocksize, ptr_gen);
3689 btrfs_tree_lock(next); 3981 btrfs_tree_lock(next);
3982 btrfs_set_lock_blocking(next);
3690 3983
3691 ret = btrfs_lookup_extent_ref(trans, root, bytenr, blocksize, 3984 ret = btrfs_lookup_extent_ref(trans, root, bytenr, blocksize,
3692 &refs); 3985 &refs);
@@ -3754,6 +4047,13 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
3754 if (slot < btrfs_header_nritems(path->nodes[i]) - 1) { 4047 if (slot < btrfs_header_nritems(path->nodes[i]) - 1) {
3755 struct extent_buffer *node; 4048 struct extent_buffer *node;
3756 struct btrfs_disk_key disk_key; 4049 struct btrfs_disk_key disk_key;
4050
4051 /*
4052 * there is more work to do in this level.
4053 * Update the drop_progress marker to reflect
4054 * the work we've done so far, and then bump
4055 * the slot number
4056 */
3757 node = path->nodes[i]; 4057 node = path->nodes[i];
3758 path->slots[i]++; 4058 path->slots[i]++;
3759 *level = i; 4059 *level = i;
@@ -3765,6 +4065,11 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
3765 return 0; 4065 return 0;
3766 } else { 4066 } else {
3767 struct extent_buffer *parent; 4067 struct extent_buffer *parent;
4068
4069 /*
4070 * this whole node is done, free our reference
4071 * on it and go up one level
4072 */
3768 if (path->nodes[*level] == root->node) 4073 if (path->nodes[*level] == root->node)
3769 parent = path->nodes[*level]; 4074 parent = path->nodes[*level];
3770 else 4075 else
@@ -4444,7 +4749,7 @@ static noinline int replace_one_extent(struct btrfs_trans_handle *trans,
4444 u64 lock_end = 0; 4749 u64 lock_end = 0;
4445 u64 num_bytes; 4750 u64 num_bytes;
4446 u64 ext_offset; 4751 u64 ext_offset;
4447 u64 first_pos; 4752 u64 search_end = (u64)-1;
4448 u32 nritems; 4753 u32 nritems;
4449 int nr_scaned = 0; 4754 int nr_scaned = 0;
4450 int extent_locked = 0; 4755 int extent_locked = 0;
@@ -4452,7 +4757,6 @@ static noinline int replace_one_extent(struct btrfs_trans_handle *trans,
4452 int ret; 4757 int ret;
4453 4758
4454 memcpy(&key, leaf_key, sizeof(key)); 4759 memcpy(&key, leaf_key, sizeof(key));
4455 first_pos = INT_LIMIT(loff_t) - extent_key->offset;
4456 if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS) { 4760 if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS) {
4457 if (key.objectid < ref_path->owner_objectid || 4761 if (key.objectid < ref_path->owner_objectid ||
4458 (key.objectid == ref_path->owner_objectid && 4762 (key.objectid == ref_path->owner_objectid &&
@@ -4501,7 +4805,7 @@ next:
4501 if ((key.objectid > ref_path->owner_objectid) || 4805 if ((key.objectid > ref_path->owner_objectid) ||
4502 (key.objectid == ref_path->owner_objectid && 4806 (key.objectid == ref_path->owner_objectid &&
4503 key.type > BTRFS_EXTENT_DATA_KEY) || 4807 key.type > BTRFS_EXTENT_DATA_KEY) ||
4504 (key.offset >= first_pos + extent_key->offset)) 4808 key.offset >= search_end)
4505 break; 4809 break;
4506 } 4810 }
4507 4811
@@ -4534,8 +4838,10 @@ next:
4534 num_bytes = btrfs_file_extent_num_bytes(leaf, fi); 4838 num_bytes = btrfs_file_extent_num_bytes(leaf, fi);
4535 ext_offset = btrfs_file_extent_offset(leaf, fi); 4839 ext_offset = btrfs_file_extent_offset(leaf, fi);
4536 4840
4537 if (first_pos > key.offset - ext_offset) 4841 if (search_end == (u64)-1) {
4538 first_pos = key.offset - ext_offset; 4842 search_end = key.offset - ext_offset +
4843 btrfs_file_extent_ram_bytes(leaf, fi);
4844 }
4539 4845
4540 if (!extent_locked) { 4846 if (!extent_locked) {
4541 lock_start = key.offset; 4847 lock_start = key.offset;
@@ -4724,7 +5030,7 @@ next:
4724 } 5030 }
4725skip: 5031skip:
4726 if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS && 5032 if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS &&
4727 key.offset >= first_pos + extent_key->offset) 5033 key.offset >= search_end)
4728 break; 5034 break;
4729 5035
4730 cond_resched(); 5036 cond_resched();
@@ -4778,6 +5084,7 @@ int btrfs_reloc_tree_cache_ref(struct btrfs_trans_handle *trans,
4778 ref->bytenr = buf->start; 5084 ref->bytenr = buf->start;
4779 ref->owner = btrfs_header_owner(buf); 5085 ref->owner = btrfs_header_owner(buf);
4780 ref->generation = btrfs_header_generation(buf); 5086 ref->generation = btrfs_header_generation(buf);
5087
4781 ret = btrfs_add_leaf_ref(root, ref, 0); 5088 ret = btrfs_add_leaf_ref(root, ref, 0);
4782 WARN_ON(ret); 5089 WARN_ON(ret);
4783 btrfs_free_leaf_ref(root, ref); 5090 btrfs_free_leaf_ref(root, ref);
@@ -5351,7 +5658,9 @@ static noinline int relocate_one_extent(struct btrfs_root *extent_root,
5351 prev_block = block_start; 5658 prev_block = block_start;
5352 } 5659 }
5353 5660
5661 mutex_lock(&extent_root->fs_info->trans_mutex);
5354 btrfs_record_root_in_trans(found_root); 5662 btrfs_record_root_in_trans(found_root);
5663 mutex_unlock(&extent_root->fs_info->trans_mutex);
5355 if (ref_path->owner_objectid >= BTRFS_FIRST_FREE_OBJECTID) { 5664 if (ref_path->owner_objectid >= BTRFS_FIRST_FREE_OBJECTID) {
5356 /* 5665 /*
5357 * try to update data extent references while 5666 * try to update data extent references while
@@ -5957,9 +6266,11 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
5957 path = btrfs_alloc_path(); 6266 path = btrfs_alloc_path();
5958 BUG_ON(!path); 6267 BUG_ON(!path);
5959 6268
5960 btrfs_remove_free_space_cache(block_group); 6269 spin_lock(&root->fs_info->block_group_cache_lock);
5961 rb_erase(&block_group->cache_node, 6270 rb_erase(&block_group->cache_node,
5962 &root->fs_info->block_group_cache_tree); 6271 &root->fs_info->block_group_cache_tree);
6272 spin_unlock(&root->fs_info->block_group_cache_lock);
6273 btrfs_remove_free_space_cache(block_group);
5963 down_write(&block_group->space_info->groups_sem); 6274 down_write(&block_group->space_info->groups_sem);
5964 list_del(&block_group->list); 6275 list_del(&block_group->list);
5965 up_write(&block_group->space_info->groups_sem); 6276 up_write(&block_group->space_info->groups_sem);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index e086d407f1fa..ebe6b29e6069 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -9,7 +9,6 @@
9#include <linux/spinlock.h> 9#include <linux/spinlock.h>
10#include <linux/blkdev.h> 10#include <linux/blkdev.h>
11#include <linux/swap.h> 11#include <linux/swap.h>
12#include <linux/version.h>
13#include <linux/writeback.h> 12#include <linux/writeback.h>
14#include <linux/pagevec.h> 13#include <linux/pagevec.h>
15#include "extent_io.h" 14#include "extent_io.h"
@@ -31,7 +30,7 @@ static LIST_HEAD(buffers);
31static LIST_HEAD(states); 30static LIST_HEAD(states);
32 31
33#define LEAK_DEBUG 0 32#define LEAK_DEBUG 0
34#ifdef LEAK_DEBUG 33#if LEAK_DEBUG
35static DEFINE_SPINLOCK(leak_lock); 34static DEFINE_SPINLOCK(leak_lock);
36#endif 35#endif
37 36
@@ -120,7 +119,7 @@ void extent_io_tree_init(struct extent_io_tree *tree,
120static struct extent_state *alloc_extent_state(gfp_t mask) 119static struct extent_state *alloc_extent_state(gfp_t mask)
121{ 120{
122 struct extent_state *state; 121 struct extent_state *state;
123#ifdef LEAK_DEBUG 122#if LEAK_DEBUG
124 unsigned long flags; 123 unsigned long flags;
125#endif 124#endif
126 125
@@ -130,7 +129,7 @@ static struct extent_state *alloc_extent_state(gfp_t mask)
130 state->state = 0; 129 state->state = 0;
131 state->private = 0; 130 state->private = 0;
132 state->tree = NULL; 131 state->tree = NULL;
133#ifdef LEAK_DEBUG 132#if LEAK_DEBUG
134 spin_lock_irqsave(&leak_lock, flags); 133 spin_lock_irqsave(&leak_lock, flags);
135 list_add(&state->leak_list, &states); 134 list_add(&state->leak_list, &states);
136 spin_unlock_irqrestore(&leak_lock, flags); 135 spin_unlock_irqrestore(&leak_lock, flags);
@@ -145,11 +144,11 @@ static void free_extent_state(struct extent_state *state)
145 if (!state) 144 if (!state)
146 return; 145 return;
147 if (atomic_dec_and_test(&state->refs)) { 146 if (atomic_dec_and_test(&state->refs)) {
148#ifdef LEAK_DEBUG 147#if LEAK_DEBUG
149 unsigned long flags; 148 unsigned long flags;
150#endif 149#endif
151 WARN_ON(state->tree); 150 WARN_ON(state->tree);
152#ifdef LEAK_DEBUG 151#if LEAK_DEBUG
153 spin_lock_irqsave(&leak_lock, flags); 152 spin_lock_irqsave(&leak_lock, flags);
154 list_del(&state->leak_list); 153 list_del(&state->leak_list);
155 spin_unlock_irqrestore(&leak_lock, flags); 154 spin_unlock_irqrestore(&leak_lock, flags);
@@ -416,8 +415,6 @@ static int split_state(struct extent_io_tree *tree, struct extent_state *orig,
416 415
417 node = tree_insert(&tree->state, prealloc->end, &prealloc->rb_node); 416 node = tree_insert(&tree->state, prealloc->end, &prealloc->rb_node);
418 if (node) { 417 if (node) {
419 struct extent_state *found;
420 found = rb_entry(node, struct extent_state, rb_node);
421 free_extent_state(prealloc); 418 free_extent_state(prealloc);
422 return -EEXIST; 419 return -EEXIST;
423 } 420 }
@@ -2378,11 +2375,6 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
2378 int scanned = 0; 2375 int scanned = 0;
2379 int range_whole = 0; 2376 int range_whole = 0;
2380 2377
2381 if (wbc->nonblocking && bdi_write_congested(bdi)) {
2382 wbc->encountered_congestion = 1;
2383 return 0;
2384 }
2385
2386 pagevec_init(&pvec, 0); 2378 pagevec_init(&pvec, 0);
2387 if (wbc->range_cyclic) { 2379 if (wbc->range_cyclic) {
2388 index = mapping->writeback_index; /* Start from prev offset */ 2380 index = mapping->writeback_index; /* Start from prev offset */
@@ -2855,6 +2847,98 @@ out:
2855 return sector; 2847 return sector;
2856} 2848}
2857 2849
2850int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2851 __u64 start, __u64 len, get_extent_t *get_extent)
2852{
2853 int ret;
2854 u64 off = start;
2855 u64 max = start + len;
2856 u32 flags = 0;
2857 u64 disko = 0;
2858 struct extent_map *em = NULL;
2859 int end = 0;
2860 u64 em_start = 0, em_len = 0;
2861 unsigned long emflags;
2862 ret = 0;
2863
2864 if (len == 0)
2865 return -EINVAL;
2866
2867 lock_extent(&BTRFS_I(inode)->io_tree, start, start + len,
2868 GFP_NOFS);
2869 em = get_extent(inode, NULL, 0, off, max - off, 0);
2870 if (!em)
2871 goto out;
2872 if (IS_ERR(em)) {
2873 ret = PTR_ERR(em);
2874 goto out;
2875 }
2876 while (!end) {
2877 off = em->start + em->len;
2878 if (off >= max)
2879 end = 1;
2880
2881 em_start = em->start;
2882 em_len = em->len;
2883
2884 disko = 0;
2885 flags = 0;
2886
2887 switch (em->block_start) {
2888 case EXTENT_MAP_LAST_BYTE:
2889 end = 1;
2890 flags |= FIEMAP_EXTENT_LAST;
2891 break;
2892 case EXTENT_MAP_HOLE:
2893 flags |= FIEMAP_EXTENT_UNWRITTEN;
2894 break;
2895 case EXTENT_MAP_INLINE:
2896 flags |= (FIEMAP_EXTENT_DATA_INLINE |
2897 FIEMAP_EXTENT_NOT_ALIGNED);
2898 break;
2899 case EXTENT_MAP_DELALLOC:
2900 flags |= (FIEMAP_EXTENT_DELALLOC |
2901 FIEMAP_EXTENT_UNKNOWN);
2902 break;
2903 default:
2904 disko = em->block_start;
2905 break;
2906 }
2907 if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags))
2908 flags |= FIEMAP_EXTENT_ENCODED;
2909
2910 emflags = em->flags;
2911 free_extent_map(em);
2912 em = NULL;
2913
2914 if (!end) {
2915 em = get_extent(inode, NULL, 0, off, max - off, 0);
2916 if (!em)
2917 goto out;
2918 if (IS_ERR(em)) {
2919 ret = PTR_ERR(em);
2920 goto out;
2921 }
2922 emflags = em->flags;
2923 }
2924 if (test_bit(EXTENT_FLAG_VACANCY, &emflags)) {
2925 flags |= FIEMAP_EXTENT_LAST;
2926 end = 1;
2927 }
2928
2929 ret = fiemap_fill_next_extent(fieinfo, em_start, disko,
2930 em_len, flags);
2931 if (ret)
2932 goto out_free;
2933 }
2934out_free:
2935 free_extent_map(em);
2936out:
2937 unlock_extent(&BTRFS_I(inode)->io_tree, start, start + len,
2938 GFP_NOFS);
2939 return ret;
2940}
2941
2858static inline struct page *extent_buffer_page(struct extent_buffer *eb, 2942static inline struct page *extent_buffer_page(struct extent_buffer *eb,
2859 unsigned long i) 2943 unsigned long i)
2860{ 2944{
@@ -2892,15 +2976,17 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
2892 gfp_t mask) 2976 gfp_t mask)
2893{ 2977{
2894 struct extent_buffer *eb = NULL; 2978 struct extent_buffer *eb = NULL;
2895#ifdef LEAK_DEBUG 2979#if LEAK_DEBUG
2896 unsigned long flags; 2980 unsigned long flags;
2897#endif 2981#endif
2898 2982
2899 eb = kmem_cache_zalloc(extent_buffer_cache, mask); 2983 eb = kmem_cache_zalloc(extent_buffer_cache, mask);
2900 eb->start = start; 2984 eb->start = start;
2901 eb->len = len; 2985 eb->len = len;
2902 mutex_init(&eb->mutex); 2986 spin_lock_init(&eb->lock);
2903#ifdef LEAK_DEBUG 2987 init_waitqueue_head(&eb->lock_wq);
2988
2989#if LEAK_DEBUG
2904 spin_lock_irqsave(&leak_lock, flags); 2990 spin_lock_irqsave(&leak_lock, flags);
2905 list_add(&eb->leak_list, &buffers); 2991 list_add(&eb->leak_list, &buffers);
2906 spin_unlock_irqrestore(&leak_lock, flags); 2992 spin_unlock_irqrestore(&leak_lock, flags);
@@ -2912,7 +2998,7 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
2912 2998
2913static void __free_extent_buffer(struct extent_buffer *eb) 2999static void __free_extent_buffer(struct extent_buffer *eb)
2914{ 3000{
2915#ifdef LEAK_DEBUG 3001#if LEAK_DEBUG
2916 unsigned long flags; 3002 unsigned long flags;
2917 spin_lock_irqsave(&leak_lock, flags); 3003 spin_lock_irqsave(&leak_lock, flags);
2918 list_del(&eb->leak_list); 3004 list_del(&eb->leak_list);
@@ -2980,8 +3066,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
2980 unlock_page(p); 3066 unlock_page(p);
2981 } 3067 }
2982 if (uptodate) 3068 if (uptodate)
2983 eb->flags |= EXTENT_UPTODATE; 3069 set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
2984 eb->flags |= EXTENT_BUFFER_FILLED;
2985 3070
2986 spin_lock(&tree->buffer_lock); 3071 spin_lock(&tree->buffer_lock);
2987 exists = buffer_tree_insert(tree, start, &eb->rb_node); 3072 exists = buffer_tree_insert(tree, start, &eb->rb_node);
@@ -3135,7 +3220,7 @@ int clear_extent_buffer_uptodate(struct extent_io_tree *tree,
3135 unsigned long num_pages; 3220 unsigned long num_pages;
3136 3221
3137 num_pages = num_extent_pages(eb->start, eb->len); 3222 num_pages = num_extent_pages(eb->start, eb->len);
3138 eb->flags &= ~EXTENT_UPTODATE; 3223 clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
3139 3224
3140 clear_extent_uptodate(tree, eb->start, eb->start + eb->len - 1, 3225 clear_extent_uptodate(tree, eb->start, eb->start + eb->len - 1,
3141 GFP_NOFS); 3226 GFP_NOFS);
@@ -3206,7 +3291,7 @@ int extent_buffer_uptodate(struct extent_io_tree *tree,
3206 struct page *page; 3291 struct page *page;
3207 int pg_uptodate = 1; 3292 int pg_uptodate = 1;
3208 3293
3209 if (eb->flags & EXTENT_UPTODATE) 3294 if (test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
3210 return 1; 3295 return 1;
3211 3296
3212 ret = test_range_bit(tree, eb->start, eb->start + eb->len - 1, 3297 ret = test_range_bit(tree, eb->start, eb->start + eb->len - 1,
@@ -3242,7 +3327,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
3242 struct bio *bio = NULL; 3327 struct bio *bio = NULL;
3243 unsigned long bio_flags = 0; 3328 unsigned long bio_flags = 0;
3244 3329
3245 if (eb->flags & EXTENT_UPTODATE) 3330 if (test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
3246 return 0; 3331 return 0;
3247 3332
3248 if (test_range_bit(tree, eb->start, eb->start + eb->len - 1, 3333 if (test_range_bit(tree, eb->start, eb->start + eb->len - 1,
@@ -3273,7 +3358,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
3273 } 3358 }
3274 if (all_uptodate) { 3359 if (all_uptodate) {
3275 if (start_i == 0) 3360 if (start_i == 0)
3276 eb->flags |= EXTENT_UPTODATE; 3361 set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
3277 goto unlock_exit; 3362 goto unlock_exit;
3278 } 3363 }
3279 3364
@@ -3309,7 +3394,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
3309 } 3394 }
3310 3395
3311 if (!ret) 3396 if (!ret)
3312 eb->flags |= EXTENT_UPTODATE; 3397 set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
3313 return ret; 3398 return ret;
3314 3399
3315unlock_exit: 3400unlock_exit:
@@ -3406,7 +3491,6 @@ int map_extent_buffer(struct extent_buffer *eb, unsigned long start,
3406 unmap_extent_buffer(eb, eb->map_token, km); 3491 unmap_extent_buffer(eb, eb->map_token, km);
3407 eb->map_token = NULL; 3492 eb->map_token = NULL;
3408 save = 1; 3493 save = 1;
3409 WARN_ON(!mutex_is_locked(&eb->mutex));
3410 } 3494 }
3411 err = map_private_extent_buffer(eb, start, min_len, token, map, 3495 err = map_private_extent_buffer(eb, start, min_len, token, map,
3412 map_start, map_len, km); 3496 map_start, map_len, km);
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index c5b483a79137..1f9df88afbf6 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -22,6 +22,10 @@
22/* flags for bio submission */ 22/* flags for bio submission */
23#define EXTENT_BIO_COMPRESSED 1 23#define EXTENT_BIO_COMPRESSED 1
24 24
25/* these are bit numbers for test/set bit */
26#define EXTENT_BUFFER_UPTODATE 0
27#define EXTENT_BUFFER_BLOCKING 1
28
25/* 29/*
26 * page->private values. Every page that is controlled by the extent 30 * page->private values. Every page that is controlled by the extent
27 * map has page->private set to one. 31 * map has page->private set to one.
@@ -95,11 +99,19 @@ struct extent_buffer {
95 unsigned long map_start; 99 unsigned long map_start;
96 unsigned long map_len; 100 unsigned long map_len;
97 struct page *first_page; 101 struct page *first_page;
102 unsigned long bflags;
98 atomic_t refs; 103 atomic_t refs;
99 int flags;
100 struct list_head leak_list; 104 struct list_head leak_list;
101 struct rb_node rb_node; 105 struct rb_node rb_node;
102 struct mutex mutex; 106
107 /* the spinlock is used to protect most operations */
108 spinlock_t lock;
109
110 /*
111 * when we keep the lock held while blocking, waiters go onto
112 * the wq
113 */
114 wait_queue_head_t lock_wq;
103}; 115};
104 116
105struct extent_map_tree; 117struct extent_map_tree;
@@ -193,6 +205,8 @@ int extent_commit_write(struct extent_io_tree *tree,
193 unsigned from, unsigned to); 205 unsigned from, unsigned to);
194sector_t extent_bmap(struct address_space *mapping, sector_t iblock, 206sector_t extent_bmap(struct address_space *mapping, sector_t iblock,
195 get_extent_t *get_extent); 207 get_extent_t *get_extent);
208int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
209 __u64 start, __u64 len, get_extent_t *get_extent);
196int set_range_dirty(struct extent_io_tree *tree, u64 start, u64 end); 210int set_range_dirty(struct extent_io_tree *tree, u64 start, u64 end);
197int set_state_private(struct extent_io_tree *tree, u64 start, u64 private); 211int set_state_private(struct extent_io_tree *tree, u64 start, u64 private);
198int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private); 212int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private);
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 4a83e33ada32..50da69da20ce 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -3,7 +3,6 @@
3#include <linux/slab.h> 3#include <linux/slab.h>
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/spinlock.h> 5#include <linux/spinlock.h>
6#include <linux/version.h>
7#include <linux/hardirq.h> 6#include <linux/hardirq.h>
8#include "extent_map.h" 7#include "extent_map.h"
9 8
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 90268334145e..872f104576e5 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -29,7 +29,6 @@
29#include <linux/writeback.h> 29#include <linux/writeback.h>
30#include <linux/statfs.h> 30#include <linux/statfs.h>
31#include <linux/compat.h> 31#include <linux/compat.h>
32#include <linux/version.h>
33#include "ctree.h" 32#include "ctree.h"
34#include "disk-io.h" 33#include "disk-io.h"
35#include "transaction.h" 34#include "transaction.h"
@@ -1215,15 +1214,15 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
1215 } 1214 }
1216 mutex_unlock(&root->fs_info->trans_mutex); 1215 mutex_unlock(&root->fs_info->trans_mutex);
1217 1216
1218 root->fs_info->tree_log_batch++; 1217 root->log_batch++;
1219 filemap_fdatawrite(inode->i_mapping); 1218 filemap_fdatawrite(inode->i_mapping);
1220 btrfs_wait_ordered_range(inode, 0, (u64)-1); 1219 btrfs_wait_ordered_range(inode, 0, (u64)-1);
1221 root->fs_info->tree_log_batch++; 1220 root->log_batch++;
1222 1221
1223 /* 1222 /*
1224 * ok we haven't committed the transaction yet, lets do a commit 1223 * ok we haven't committed the transaction yet, lets do a commit
1225 */ 1224 */
1226 if (file->private_data) 1225 if (file && file->private_data)
1227 btrfs_ioctl_trans_end(file); 1226 btrfs_ioctl_trans_end(file);
1228 1227
1229 trans = btrfs_start_transaction(root, 1); 1228 trans = btrfs_start_transaction(root, 1);
@@ -1232,7 +1231,7 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
1232 goto out; 1231 goto out;
1233 } 1232 }
1234 1233
1235 ret = btrfs_log_dentry_safe(trans, root, file->f_dentry); 1234 ret = btrfs_log_dentry_safe(trans, root, dentry);
1236 if (ret < 0) 1235 if (ret < 0)
1237 goto out; 1236 goto out;
1238 1237
@@ -1246,7 +1245,7 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
1246 * file again, but that will end up using the synchronization 1245 * file again, but that will end up using the synchronization
1247 * inside btrfs_sync_log to keep things safe. 1246 * inside btrfs_sync_log to keep things safe.
1248 */ 1247 */
1249 mutex_unlock(&file->f_dentry->d_inode->i_mutex); 1248 mutex_unlock(&dentry->d_inode->i_mutex);
1250 1249
1251 if (ret > 0) { 1250 if (ret > 0) {
1252 ret = btrfs_commit_transaction(trans, root); 1251 ret = btrfs_commit_transaction(trans, root);
@@ -1254,7 +1253,7 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync)
1254 btrfs_sync_log(trans, root); 1253 btrfs_sync_log(trans, root);
1255 ret = btrfs_end_transaction(trans, root); 1254 ret = btrfs_end_transaction(trans, root);
1256 } 1255 }
1257 mutex_lock(&file->f_dentry->d_inode->i_mutex); 1256 mutex_lock(&dentry->d_inode->i_mutex);
1258out: 1257out:
1259 return ret > 0 ? EIO : ret; 1258 return ret > 0 ? EIO : ret;
1260} 1259}
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index 2aa79873eb46..cc7334d833c9 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -84,7 +84,6 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
84 search_key.type = 0; 84 search_key.type = 0;
85 search_key.offset = 0; 85 search_key.offset = 0;
86 86
87 btrfs_init_path(path);
88 start_found = 0; 87 start_found = 0;
89 ret = btrfs_search_slot(trans, root, &search_key, path, 0, 0); 88 ret = btrfs_search_slot(trans, root, &search_key, path, 0, 0);
90 if (ret < 0) 89 if (ret < 0)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8adfe059ab41..3cee77ae03c8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -34,7 +34,6 @@
34#include <linux/statfs.h> 34#include <linux/statfs.h>
35#include <linux/compat.h> 35#include <linux/compat.h>
36#include <linux/bit_spinlock.h> 36#include <linux/bit_spinlock.h>
37#include <linux/version.h>
38#include <linux/xattr.h> 37#include <linux/xattr.h>
39#include <linux/posix_acl.h> 38#include <linux/posix_acl.h>
40#include <linux/falloc.h> 39#include <linux/falloc.h>
@@ -51,6 +50,7 @@
51#include "tree-log.h" 50#include "tree-log.h"
52#include "ref-cache.h" 51#include "ref-cache.h"
53#include "compression.h" 52#include "compression.h"
53#include "locking.h"
54 54
55struct btrfs_iget_args { 55struct btrfs_iget_args {
56 u64 ino; 56 u64 ino;
@@ -91,6 +91,16 @@ static noinline int cow_file_range(struct inode *inode,
91 u64 start, u64 end, int *page_started, 91 u64 start, u64 end, int *page_started,
92 unsigned long *nr_written, int unlock); 92 unsigned long *nr_written, int unlock);
93 93
94static int btrfs_init_inode_security(struct inode *inode, struct inode *dir)
95{
96 int err;
97
98 err = btrfs_init_acl(inode, dir);
99 if (!err)
100 err = btrfs_xattr_security_init(inode, dir);
101 return err;
102}
103
94/* 104/*
95 * a very lame attempt at stopping writes when the FS is 85% full. There 105 * a very lame attempt at stopping writes when the FS is 85% full. There
96 * are countless ways this is incorrect, but it is better than nothing. 106 * are countless ways this is incorrect, but it is better than nothing.
@@ -350,6 +360,19 @@ again:
350 nr_pages = (end >> PAGE_CACHE_SHIFT) - (start >> PAGE_CACHE_SHIFT) + 1; 360 nr_pages = (end >> PAGE_CACHE_SHIFT) - (start >> PAGE_CACHE_SHIFT) + 1;
351 nr_pages = min(nr_pages, (128 * 1024UL) / PAGE_CACHE_SIZE); 361 nr_pages = min(nr_pages, (128 * 1024UL) / PAGE_CACHE_SIZE);
352 362
363 /*
364 * we don't want to send crud past the end of i_size through
365 * compression, that's just a waste of CPU time. So, if the
366 * end of the file is before the start of our current
367 * requested range of bytes, we bail out to the uncompressed
368 * cleanup code that can deal with all of this.
369 *
370 * It isn't really the fastest way to fix things, but this is a
371 * very uncommon corner.
372 */
373 if (actual_end <= start)
374 goto cleanup_and_bail_uncompressed;
375
353 total_compressed = actual_end - start; 376 total_compressed = actual_end - start;
354 377
355 /* we want to make sure that amount of ram required to uncompress 378 /* we want to make sure that amount of ram required to uncompress
@@ -494,6 +517,7 @@ again:
494 goto again; 517 goto again;
495 } 518 }
496 } else { 519 } else {
520cleanup_and_bail_uncompressed:
497 /* 521 /*
498 * No compression, but we still need to write the pages in 522 * No compression, but we still need to write the pages in
499 * the file we've been given so far. redirty the locked 523 * the file we've been given so far. redirty the locked
@@ -1324,12 +1348,11 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
1324 struct inode *inode, u64 file_offset, 1348 struct inode *inode, u64 file_offset,
1325 struct list_head *list) 1349 struct list_head *list)
1326{ 1350{
1327 struct list_head *cur;
1328 struct btrfs_ordered_sum *sum; 1351 struct btrfs_ordered_sum *sum;
1329 1352
1330 btrfs_set_trans_block_group(trans, inode); 1353 btrfs_set_trans_block_group(trans, inode);
1331 list_for_each(cur, list) { 1354
1332 sum = list_entry(cur, struct btrfs_ordered_sum, list); 1355 list_for_each_entry(sum, list, list) {
1333 btrfs_csum_file_blocks(trans, 1356 btrfs_csum_file_blocks(trans,
1334 BTRFS_I(inode)->root->fs_info->csum_root, sum); 1357 BTRFS_I(inode)->root->fs_info->csum_root, sum);
1335 } 1358 }
@@ -2013,6 +2036,7 @@ void btrfs_read_locked_inode(struct inode *inode)
2013 BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item); 2036 BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item);
2014 2037
2015 alloc_group_block = btrfs_inode_block_group(leaf, inode_item); 2038 alloc_group_block = btrfs_inode_block_group(leaf, inode_item);
2039
2016 BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 0, 2040 BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 0,
2017 alloc_group_block, 0); 2041 alloc_group_block, 0);
2018 btrfs_free_path(path); 2042 btrfs_free_path(path);
@@ -2039,6 +2063,7 @@ void btrfs_read_locked_inode(struct inode *inode)
2039 inode->i_mapping->backing_dev_info = &root->fs_info->bdi; 2063 inode->i_mapping->backing_dev_info = &root->fs_info->bdi;
2040 break; 2064 break;
2041 default: 2065 default:
2066 inode->i_op = &btrfs_special_inode_operations;
2042 init_special_inode(inode, inode->i_mode, rdev); 2067 init_special_inode(inode, inode->i_mode, rdev);
2043 break; 2068 break;
2044 } 2069 }
@@ -2108,6 +2133,7 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans,
2108 goto failed; 2133 goto failed;
2109 } 2134 }
2110 2135
2136 btrfs_unlock_up_safe(path, 1);
2111 leaf = path->nodes[0]; 2137 leaf = path->nodes[0];
2112 inode_item = btrfs_item_ptr(leaf, path->slots[0], 2138 inode_item = btrfs_item_ptr(leaf, path->slots[0],
2113 struct btrfs_inode_item); 2139 struct btrfs_inode_item);
@@ -2429,6 +2455,8 @@ next_node:
2429 ref->generation = leaf_gen; 2455 ref->generation = leaf_gen;
2430 ref->nritems = 0; 2456 ref->nritems = 0;
2431 2457
2458 btrfs_sort_leaf_ref(ref);
2459
2432 ret = btrfs_add_leaf_ref(root, ref, 0); 2460 ret = btrfs_add_leaf_ref(root, ref, 0);
2433 WARN_ON(ret); 2461 WARN_ON(ret);
2434 btrfs_free_leaf_ref(root, ref); 2462 btrfs_free_leaf_ref(root, ref);
@@ -2476,7 +2504,7 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
2476 struct btrfs_path *path; 2504 struct btrfs_path *path;
2477 struct btrfs_key key; 2505 struct btrfs_key key;
2478 struct btrfs_key found_key; 2506 struct btrfs_key found_key;
2479 u32 found_type; 2507 u32 found_type = (u8)-1;
2480 struct extent_buffer *leaf; 2508 struct extent_buffer *leaf;
2481 struct btrfs_file_extent_item *fi; 2509 struct btrfs_file_extent_item *fi;
2482 u64 extent_start = 0; 2510 u64 extent_start = 0;
@@ -2503,8 +2531,6 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
2503 key.offset = (u64)-1; 2531 key.offset = (u64)-1;
2504 key.type = (u8)-1; 2532 key.type = (u8)-1;
2505 2533
2506 btrfs_init_path(path);
2507
2508search_again: 2534search_again:
2509 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); 2535 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
2510 if (ret < 0) 2536 if (ret < 0)
@@ -2663,6 +2689,8 @@ next:
2663 if (pending_del_nr) 2689 if (pending_del_nr)
2664 goto del_pending; 2690 goto del_pending;
2665 btrfs_release_path(root, path); 2691 btrfs_release_path(root, path);
2692 if (found_type == BTRFS_INODE_ITEM_KEY)
2693 break;
2666 goto search_again; 2694 goto search_again;
2667 } 2695 }
2668 2696
@@ -2679,6 +2707,8 @@ del_pending:
2679 BUG_ON(ret); 2707 BUG_ON(ret);
2680 pending_del_nr = 0; 2708 pending_del_nr = 0;
2681 btrfs_release_path(root, path); 2709 btrfs_release_path(root, path);
2710 if (found_type == BTRFS_INODE_ITEM_KEY)
2711 break;
2682 goto search_again; 2712 goto search_again;
2683 } 2713 }
2684 } 2714 }
@@ -3265,7 +3295,7 @@ skip:
3265 3295
3266 /* Reached end of directory/root. Bump pos past the last item. */ 3296 /* Reached end of directory/root. Bump pos past the last item. */
3267 if (key_type == BTRFS_DIR_INDEX_KEY) 3297 if (key_type == BTRFS_DIR_INDEX_KEY)
3268 filp->f_pos = INT_LIMIT(typeof(filp->f_pos)); 3298 filp->f_pos = INT_LIMIT(off_t);
3269 else 3299 else
3270 filp->f_pos++; 3300 filp->f_pos++;
3271nopos: 3301nopos:
@@ -3458,7 +3488,14 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3458 root->highest_inode = objectid; 3488 root->highest_inode = objectid;
3459 3489
3460 inode->i_uid = current_fsuid(); 3490 inode->i_uid = current_fsuid();
3461 inode->i_gid = current_fsgid(); 3491
3492 if (dir && (dir->i_mode & S_ISGID)) {
3493 inode->i_gid = dir->i_gid;
3494 if (S_ISDIR(mode))
3495 mode |= S_ISGID;
3496 } else
3497 inode->i_gid = current_fsgid();
3498
3462 inode->i_mode = mode; 3499 inode->i_mode = mode;
3463 inode->i_ino = objectid; 3500 inode->i_ino = objectid;
3464 inode_set_bytes(inode, 0); 3501 inode_set_bytes(inode, 0);
@@ -3586,7 +3623,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
3586 if (IS_ERR(inode)) 3623 if (IS_ERR(inode))
3587 goto out_unlock; 3624 goto out_unlock;
3588 3625
3589 err = btrfs_init_acl(inode, dir); 3626 err = btrfs_init_inode_security(inode, dir);
3590 if (err) { 3627 if (err) {
3591 drop_inode = 1; 3628 drop_inode = 1;
3592 goto out_unlock; 3629 goto out_unlock;
@@ -3649,7 +3686,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
3649 if (IS_ERR(inode)) 3686 if (IS_ERR(inode))
3650 goto out_unlock; 3687 goto out_unlock;
3651 3688
3652 err = btrfs_init_acl(inode, dir); 3689 err = btrfs_init_inode_security(inode, dir);
3653 if (err) { 3690 if (err) {
3654 drop_inode = 1; 3691 drop_inode = 1;
3655 goto out_unlock; 3692 goto out_unlock;
@@ -3772,7 +3809,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
3772 3809
3773 drop_on_err = 1; 3810 drop_on_err = 1;
3774 3811
3775 err = btrfs_init_acl(inode, dir); 3812 err = btrfs_init_inode_security(inode, dir);
3776 if (err) 3813 if (err)
3777 goto out_fail; 3814 goto out_fail;
3778 3815
@@ -4158,9 +4195,10 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
4158 return -EINVAL; 4195 return -EINVAL;
4159} 4196}
4160 4197
4161static sector_t btrfs_bmap(struct address_space *mapping, sector_t iblock) 4198static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4199 __u64 start, __u64 len)
4162{ 4200{
4163 return extent_bmap(mapping, iblock, btrfs_get_extent); 4201 return extent_fiemap(inode, fieinfo, start, len, btrfs_get_extent);
4164} 4202}
4165 4203
4166int btrfs_readpage(struct file *file, struct page *page) 4204int btrfs_readpage(struct file *file, struct page *page)
@@ -4223,7 +4261,7 @@ static int btrfs_releasepage(struct page *page, gfp_t gfp_flags)
4223{ 4261{
4224 if (PageWriteback(page) || PageDirty(page)) 4262 if (PageWriteback(page) || PageDirty(page))
4225 return 0; 4263 return 0;
4226 return __btrfs_releasepage(page, gfp_flags); 4264 return __btrfs_releasepage(page, gfp_flags & GFP_NOFS);
4227} 4265}
4228 4266
4229static void btrfs_invalidatepage(struct page *page, unsigned long offset) 4267static void btrfs_invalidatepage(struct page *page, unsigned long offset)
@@ -4733,7 +4771,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
4733 if (IS_ERR(inode)) 4771 if (IS_ERR(inode))
4734 goto out_unlock; 4772 goto out_unlock;
4735 4773
4736 err = btrfs_init_acl(inode, dir); 4774 err = btrfs_init_inode_security(inode, dir);
4737 if (err) { 4775 if (err) {
4738 drop_inode = 1; 4776 drop_inode = 1;
4739 goto out_unlock; 4777 goto out_unlock;
@@ -4987,13 +5025,24 @@ static struct extent_io_ops btrfs_extent_io_ops = {
4987 .clear_bit_hook = btrfs_clear_bit_hook, 5025 .clear_bit_hook = btrfs_clear_bit_hook,
4988}; 5026};
4989 5027
5028/*
5029 * btrfs doesn't support the bmap operation because swapfiles
5030 * use bmap to make a mapping of extents in the file. They assume
5031 * these extents won't change over the life of the file and they
5032 * use the bmap result to do IO directly to the drive.
5033 *
5034 * the btrfs bmap call would return logical addresses that aren't
5035 * suitable for IO and they also will change frequently as COW
5036 * operations happen. So, swapfile + btrfs == corruption.
5037 *
5038 * For now we're avoiding this by dropping bmap.
5039 */
4990static struct address_space_operations btrfs_aops = { 5040static struct address_space_operations btrfs_aops = {
4991 .readpage = btrfs_readpage, 5041 .readpage = btrfs_readpage,
4992 .writepage = btrfs_writepage, 5042 .writepage = btrfs_writepage,
4993 .writepages = btrfs_writepages, 5043 .writepages = btrfs_writepages,
4994 .readpages = btrfs_readpages, 5044 .readpages = btrfs_readpages,
4995 .sync_page = block_sync_page, 5045 .sync_page = block_sync_page,
4996 .bmap = btrfs_bmap,
4997 .direct_IO = btrfs_direct_IO, 5046 .direct_IO = btrfs_direct_IO,
4998 .invalidatepage = btrfs_invalidatepage, 5047 .invalidatepage = btrfs_invalidatepage,
4999 .releasepage = btrfs_releasepage, 5048 .releasepage = btrfs_releasepage,
@@ -5017,6 +5066,7 @@ static struct inode_operations btrfs_file_inode_operations = {
5017 .removexattr = btrfs_removexattr, 5066 .removexattr = btrfs_removexattr,
5018 .permission = btrfs_permission, 5067 .permission = btrfs_permission,
5019 .fallocate = btrfs_fallocate, 5068 .fallocate = btrfs_fallocate,
5069 .fiemap = btrfs_fiemap,
5020}; 5070};
5021static struct inode_operations btrfs_special_inode_operations = { 5071static struct inode_operations btrfs_special_inode_operations = {
5022 .getattr = btrfs_getattr, 5072 .getattr = btrfs_getattr,
@@ -5032,4 +5082,8 @@ static struct inode_operations btrfs_symlink_inode_operations = {
5032 .follow_link = page_follow_link_light, 5082 .follow_link = page_follow_link_light,
5033 .put_link = page_put_link, 5083 .put_link = page_put_link,
5034 .permission = btrfs_permission, 5084 .permission = btrfs_permission,
5085 .setxattr = btrfs_setxattr,
5086 .getxattr = btrfs_getxattr,
5087 .listxattr = btrfs_listxattr,
5088 .removexattr = btrfs_removexattr,
5035}; 5089};
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index c2aa33e3feb5..988fdc8b49eb 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -38,7 +38,6 @@
38#include <linux/compat.h> 38#include <linux/compat.h>
39#include <linux/bit_spinlock.h> 39#include <linux/bit_spinlock.h>
40#include <linux/security.h> 40#include <linux/security.h>
41#include <linux/version.h>
42#include <linux/xattr.h> 41#include <linux/xattr.h>
43#include <linux/vmalloc.h> 42#include <linux/vmalloc.h>
44#include "compat.h" 43#include "compat.h"
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 39bae7761db6..85506c4a3af7 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -25,64 +25,203 @@
25#include "extent_io.h" 25#include "extent_io.h"
26#include "locking.h" 26#include "locking.h"
27 27
28static inline void spin_nested(struct extent_buffer *eb)
29{
30 spin_lock(&eb->lock);
31}
32
28/* 33/*
29 * locks the per buffer mutex in an extent buffer. This uses adaptive locks 34 * Setting a lock to blocking will drop the spinlock and set the
30 * and the spin is not tuned very extensively. The spinning does make a big 35 * flag that forces other procs who want the lock to wait. After
31 * difference in almost every workload, but spinning for the right amount of 36 * this you can safely schedule with the lock held.
32 * time needs some help.
33 *
34 * In general, we want to spin as long as the lock holder is doing btree
35 * searches, and we should give up if they are in more expensive code.
36 */ 37 */
38void btrfs_set_lock_blocking(struct extent_buffer *eb)
39{
40 if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags)) {
41 set_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags);
42 spin_unlock(&eb->lock);
43 }
44 /* exit with the spin lock released and the bit set */
45}
37 46
38int btrfs_tree_lock(struct extent_buffer *eb) 47/*
48 * clearing the blocking flag will take the spinlock again.
49 * After this you can't safely schedule
50 */
51void btrfs_clear_lock_blocking(struct extent_buffer *eb)
39{ 52{
40 int i; 53 if (test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags)) {
54 spin_nested(eb);
55 clear_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags);
56 smp_mb__after_clear_bit();
57 }
58 /* exit with the spin lock held */
59}
41 60
42 if (mutex_trylock(&eb->mutex)) 61/*
43 return 0; 62 * unfortunately, many of the places that currently set a lock to blocking
63 * don't end up blocking for every long, and often they don't block
64 * at all. For a dbench 50 run, if we don't spin one the blocking bit
65 * at all, the context switch rate can jump up to 400,000/sec or more.
66 *
67 * So, we're still stuck with this crummy spin on the blocking bit,
68 * at least until the most common causes of the short blocks
69 * can be dealt with.
70 */
71static int btrfs_spin_on_block(struct extent_buffer *eb)
72{
73 int i;
44 for (i = 0; i < 512; i++) { 74 for (i = 0; i < 512; i++) {
45 cpu_relax(); 75 cpu_relax();
46 if (mutex_trylock(&eb->mutex)) 76 if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
47 return 0; 77 return 1;
78 if (need_resched())
79 break;
48 } 80 }
49 cpu_relax();
50 mutex_lock_nested(&eb->mutex, BTRFS_MAX_LEVEL - btrfs_header_level(eb));
51 return 0; 81 return 0;
52} 82}
53 83
54int btrfs_try_tree_lock(struct extent_buffer *eb) 84/*
85 * This is somewhat different from trylock. It will take the
86 * spinlock but if it finds the lock is set to blocking, it will
87 * return without the lock held.
88 *
89 * returns 1 if it was able to take the lock and zero otherwise
90 *
91 * After this call, scheduling is not safe without first calling
92 * btrfs_set_lock_blocking()
93 */
94int btrfs_try_spin_lock(struct extent_buffer *eb)
55{ 95{
56 return mutex_trylock(&eb->mutex); 96 int i;
97
98 spin_nested(eb);
99 if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
100 return 1;
101 spin_unlock(&eb->lock);
102
103 /* spin for a bit on the BLOCKING flag */
104 for (i = 0; i < 2; i++) {
105 if (!btrfs_spin_on_block(eb))
106 break;
107
108 spin_nested(eb);
109 if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
110 return 1;
111 spin_unlock(&eb->lock);
112 }
113 return 0;
57} 114}
58 115
59int btrfs_tree_unlock(struct extent_buffer *eb) 116/*
117 * the autoremove wake function will return 0 if it tried to wake up
118 * a process that was already awake, which means that process won't
119 * count as an exclusive wakeup. The waitq code will continue waking
120 * procs until it finds one that was actually sleeping.
121 *
122 * For btrfs, this isn't quite what we want. We want a single proc
123 * to be notified that the lock is ready for taking. If that proc
124 * already happen to be awake, great, it will loop around and try for
125 * the lock.
126 *
127 * So, btrfs_wake_function always returns 1, even when the proc that we
128 * tried to wake up was already awake.
129 */
130static int btrfs_wake_function(wait_queue_t *wait, unsigned mode,
131 int sync, void *key)
60{ 132{
61 mutex_unlock(&eb->mutex); 133 autoremove_wake_function(wait, mode, sync, key);
62 return 0; 134 return 1;
63} 135}
64 136
65int btrfs_tree_locked(struct extent_buffer *eb) 137/*
138 * returns with the extent buffer spinlocked.
139 *
140 * This will spin and/or wait as required to take the lock, and then
141 * return with the spinlock held.
142 *
143 * After this call, scheduling is not safe without first calling
144 * btrfs_set_lock_blocking()
145 */
146int btrfs_tree_lock(struct extent_buffer *eb)
66{ 147{
67 return mutex_is_locked(&eb->mutex); 148 DEFINE_WAIT(wait);
149 wait.func = btrfs_wake_function;
150
151 while(1) {
152 spin_nested(eb);
153
154 /* nobody is blocking, exit with the spinlock held */
155 if (!test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
156 return 0;
157
158 /*
159 * we have the spinlock, but the real owner is blocking.
160 * wait for them
161 */
162 spin_unlock(&eb->lock);
163
164 /*
165 * spin for a bit, and if the blocking flag goes away,
166 * loop around
167 */
168 if (btrfs_spin_on_block(eb))
169 continue;
170
171 prepare_to_wait_exclusive(&eb->lock_wq, &wait,
172 TASK_UNINTERRUPTIBLE);
173
174 if (test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
175 schedule();
176
177 finish_wait(&eb->lock_wq, &wait);
178 }
179 return 0;
68} 180}
69 181
70/* 182/*
71 * btrfs_search_slot uses this to decide if it should drop its locks 183 * Very quick trylock, this does not spin or schedule. It returns
72 * before doing something expensive like allocating free blocks for cow. 184 * 1 with the spinlock held if it was able to take the lock, or it
185 * returns zero if it was unable to take the lock.
186 *
187 * After this call, scheduling is not safe without first calling
188 * btrfs_set_lock_blocking()
73 */ 189 */
74int btrfs_path_lock_waiting(struct btrfs_path *path, int level) 190int btrfs_try_tree_lock(struct extent_buffer *eb)
75{ 191{
76 int i; 192 if (spin_trylock(&eb->lock)) {
77 struct extent_buffer *eb; 193 if (test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags)) {
78 for (i = level; i <= level + 1 && i < BTRFS_MAX_LEVEL; i++) { 194 /*
79 eb = path->nodes[i]; 195 * we've got the spinlock, but the real owner is
80 if (!eb) 196 * blocking. Drop the spinlock and return failure
81 break; 197 */
82 smp_mb(); 198 spin_unlock(&eb->lock);
83 if (!list_empty(&eb->mutex.wait_list)) 199 return 0;
84 return 1; 200 }
201 return 1;
85 } 202 }
203 /* someone else has the spinlock giveup */
86 return 0; 204 return 0;
87} 205}
88 206
207int btrfs_tree_unlock(struct extent_buffer *eb)
208{
209 /*
210 * if we were a blocking owner, we don't have the spinlock held
211 * just clear the bit and look for waiters
212 */
213 if (test_and_clear_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags))
214 smp_mb__after_clear_bit();
215 else
216 spin_unlock(&eb->lock);
217
218 if (waitqueue_active(&eb->lock_wq))
219 wake_up(&eb->lock_wq);
220 return 0;
221}
222
223int btrfs_tree_locked(struct extent_buffer *eb)
224{
225 return test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags) ||
226 spin_is_locked(&eb->lock);
227}
diff --git a/fs/btrfs/locking.h b/fs/btrfs/locking.h
index bc1faef12519..6bb0afbff928 100644
--- a/fs/btrfs/locking.h
+++ b/fs/btrfs/locking.h
@@ -22,6 +22,10 @@
22int btrfs_tree_lock(struct extent_buffer *eb); 22int btrfs_tree_lock(struct extent_buffer *eb);
23int btrfs_tree_unlock(struct extent_buffer *eb); 23int btrfs_tree_unlock(struct extent_buffer *eb);
24int btrfs_tree_locked(struct extent_buffer *eb); 24int btrfs_tree_locked(struct extent_buffer *eb);
25
25int btrfs_try_tree_lock(struct extent_buffer *eb); 26int btrfs_try_tree_lock(struct extent_buffer *eb);
26int btrfs_path_lock_waiting(struct btrfs_path *path, int level); 27int btrfs_try_spin_lock(struct extent_buffer *eb);
28
29void btrfs_set_lock_blocking(struct extent_buffer *eb);
30void btrfs_clear_lock_blocking(struct extent_buffer *eb);
27#endif 31#endif
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index a20940170274..77c2411a5f0f 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -613,7 +613,6 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
613 struct btrfs_sector_sum *sector_sums; 613 struct btrfs_sector_sum *sector_sums;
614 struct btrfs_ordered_extent *ordered; 614 struct btrfs_ordered_extent *ordered;
615 struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree; 615 struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree;
616 struct list_head *cur;
617 unsigned long num_sectors; 616 unsigned long num_sectors;
618 unsigned long i; 617 unsigned long i;
619 u32 sectorsize = BTRFS_I(inode)->root->sectorsize; 618 u32 sectorsize = BTRFS_I(inode)->root->sectorsize;
@@ -624,8 +623,7 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
624 return 1; 623 return 1;
625 624
626 mutex_lock(&tree->mutex); 625 mutex_lock(&tree->mutex);
627 list_for_each_prev(cur, &ordered->list) { 626 list_for_each_entry_reverse(ordered_sum, &ordered->list, list) {
628 ordered_sum = list_entry(cur, struct btrfs_ordered_sum, list);
629 if (disk_bytenr >= ordered_sum->bytenr) { 627 if (disk_bytenr >= ordered_sum->bytenr) {
630 num_sectors = ordered_sum->len / sectorsize; 628 num_sectors = ordered_sum->len / sectorsize;
631 sector_sums = ordered_sum->sums; 629 sector_sums = ordered_sum->sums;
diff --git a/fs/btrfs/ref-cache.c b/fs/btrfs/ref-cache.c
index 6f0acc4c9eab..d0cc62bccb94 100644
--- a/fs/btrfs/ref-cache.c
+++ b/fs/btrfs/ref-cache.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/sort.h>
20#include "ctree.h" 21#include "ctree.h"
21#include "ref-cache.h" 22#include "ref-cache.h"
22#include "transaction.h" 23#include "transaction.h"
diff --git a/fs/btrfs/ref-cache.h b/fs/btrfs/ref-cache.h
index 16f3183d7c59..bc283ad2db73 100644
--- a/fs/btrfs/ref-cache.h
+++ b/fs/btrfs/ref-cache.h
@@ -73,5 +73,4 @@ int btrfs_add_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref,
73int btrfs_remove_leaf_refs(struct btrfs_root *root, u64 max_root_gen, 73int btrfs_remove_leaf_refs(struct btrfs_root *root, u64 max_root_gen,
74 int shared); 74 int shared);
75int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref); 75int btrfs_remove_leaf_ref(struct btrfs_root *root, struct btrfs_leaf_ref *ref);
76
77#endif 76#endif
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index db9fb3bc1e33..19a4daf03ccb 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -37,7 +37,6 @@
37#include <linux/ctype.h> 37#include <linux/ctype.h>
38#include <linux/namei.h> 38#include <linux/namei.h>
39#include <linux/miscdevice.h> 39#include <linux/miscdevice.h>
40#include <linux/version.h>
41#include <linux/magic.h> 40#include <linux/magic.h>
42#include "compat.h" 41#include "compat.h"
43#include "ctree.h" 42#include "ctree.h"
@@ -380,7 +379,6 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
380 btrfs_start_delalloc_inodes(root); 379 btrfs_start_delalloc_inodes(root);
381 btrfs_wait_ordered_extents(root, 0); 380 btrfs_wait_ordered_extents(root, 0);
382 381
383 btrfs_clean_old_snapshots(root);
384 trans = btrfs_start_transaction(root, 1); 382 trans = btrfs_start_transaction(root, 1);
385 ret = btrfs_commit_transaction(trans, root); 383 ret = btrfs_commit_transaction(trans, root);
386 sb->s_dirt = 0; 384 sb->s_dirt = 0;
@@ -512,6 +510,10 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
512 struct btrfs_root *root = btrfs_sb(sb); 510 struct btrfs_root *root = btrfs_sb(sb);
513 int ret; 511 int ret;
514 512
513 ret = btrfs_parse_options(root, data);
514 if (ret)
515 return -EINVAL;
516
515 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) 517 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
516 return 0; 518 return 0;
517 519
@@ -583,17 +585,18 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
583 struct btrfs_ioctl_vol_args *vol; 585 struct btrfs_ioctl_vol_args *vol;
584 struct btrfs_fs_devices *fs_devices; 586 struct btrfs_fs_devices *fs_devices;
585 int ret = -ENOTTY; 587 int ret = -ENOTTY;
586 int len;
587 588
588 if (!capable(CAP_SYS_ADMIN)) 589 if (!capable(CAP_SYS_ADMIN))
589 return -EPERM; 590 return -EPERM;
590 591
591 vol = kmalloc(sizeof(*vol), GFP_KERNEL); 592 vol = kmalloc(sizeof(*vol), GFP_KERNEL);
593 if (!vol)
594 return -ENOMEM;
595
592 if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) { 596 if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) {
593 ret = -EFAULT; 597 ret = -EFAULT;
594 goto out; 598 goto out;
595 } 599 }
596 len = strnlen(vol->name, BTRFS_PATH_NAME_MAX);
597 600
598 switch (cmd) { 601 switch (cmd) {
599 case BTRFS_IOC_SCAN_DEV: 602 case BTRFS_IOC_SCAN_DEV:
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 8a08f9443340..4112d53d4f4d 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -688,7 +688,9 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root,
688 num_bytes -= btrfs_root_used(&dirty->root->root_item); 688 num_bytes -= btrfs_root_used(&dirty->root->root_item);
689 bytes_used = btrfs_root_used(&root->root_item); 689 bytes_used = btrfs_root_used(&root->root_item);
690 if (num_bytes) { 690 if (num_bytes) {
691 mutex_lock(&root->fs_info->trans_mutex);
691 btrfs_record_root_in_trans(root); 692 btrfs_record_root_in_trans(root);
693 mutex_unlock(&root->fs_info->trans_mutex);
692 btrfs_set_root_used(&root->root_item, 694 btrfs_set_root_used(&root->root_item,
693 bytes_used - num_bytes); 695 bytes_used - num_bytes);
694 } 696 }
@@ -852,11 +854,9 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
852{ 854{
853 struct btrfs_pending_snapshot *pending; 855 struct btrfs_pending_snapshot *pending;
854 struct list_head *head = &trans->transaction->pending_snapshots; 856 struct list_head *head = &trans->transaction->pending_snapshots;
855 struct list_head *cur;
856 int ret; 857 int ret;
857 858
858 list_for_each(cur, head) { 859 list_for_each_entry(pending, head, list) {
859 pending = list_entry(cur, struct btrfs_pending_snapshot, list);
860 ret = create_pending_snapshot(trans, fs_info, pending); 860 ret = create_pending_snapshot(trans, fs_info, pending);
861 BUG_ON(ret); 861 BUG_ON(ret);
862 } 862 }
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index 3e8358c36165..98d25fa4570e 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -74,6 +74,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
74 u32 nritems; 74 u32 nritems;
75 75
76 root_node = btrfs_lock_root_node(root); 76 root_node = btrfs_lock_root_node(root);
77 btrfs_set_lock_blocking(root_node);
77 nritems = btrfs_header_nritems(root_node); 78 nritems = btrfs_header_nritems(root_node);
78 root->defrag_max.objectid = 0; 79 root->defrag_max.objectid = 0;
79 /* from above we know this is not a leaf */ 80 /* from above we know this is not a leaf */
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index d81cda2e077c..9c462fbd60fa 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -78,104 +78,6 @@ static int link_to_fixup_dir(struct btrfs_trans_handle *trans,
78 */ 78 */
79 79
80/* 80/*
81 * btrfs_add_log_tree adds a new per-subvolume log tree into the
82 * tree of log tree roots. This must be called with a tree log transaction
83 * running (see start_log_trans).
84 */
85static int btrfs_add_log_tree(struct btrfs_trans_handle *trans,
86 struct btrfs_root *root)
87{
88 struct btrfs_key key;
89 struct btrfs_root_item root_item;
90 struct btrfs_inode_item *inode_item;
91 struct extent_buffer *leaf;
92 struct btrfs_root *new_root = root;
93 int ret;
94 u64 objectid = root->root_key.objectid;
95
96 leaf = btrfs_alloc_free_block(trans, root, root->leafsize, 0,
97 BTRFS_TREE_LOG_OBJECTID,
98 trans->transid, 0, 0, 0);
99 if (IS_ERR(leaf)) {
100 ret = PTR_ERR(leaf);
101 return ret;
102 }
103
104 btrfs_set_header_nritems(leaf, 0);
105 btrfs_set_header_level(leaf, 0);
106 btrfs_set_header_bytenr(leaf, leaf->start);
107 btrfs_set_header_generation(leaf, trans->transid);
108 btrfs_set_header_owner(leaf, BTRFS_TREE_LOG_OBJECTID);
109
110 write_extent_buffer(leaf, root->fs_info->fsid,
111 (unsigned long)btrfs_header_fsid(leaf),
112 BTRFS_FSID_SIZE);
113 btrfs_mark_buffer_dirty(leaf);
114
115 inode_item = &root_item.inode;
116 memset(inode_item, 0, sizeof(*inode_item));
117 inode_item->generation = cpu_to_le64(1);
118 inode_item->size = cpu_to_le64(3);
119 inode_item->nlink = cpu_to_le32(1);
120 inode_item->nbytes = cpu_to_le64(root->leafsize);
121 inode_item->mode = cpu_to_le32(S_IFDIR | 0755);
122
123 btrfs_set_root_bytenr(&root_item, leaf->start);
124 btrfs_set_root_generation(&root_item, trans->transid);
125 btrfs_set_root_level(&root_item, 0);
126 btrfs_set_root_refs(&root_item, 0);
127 btrfs_set_root_used(&root_item, 0);
128
129 memset(&root_item.drop_progress, 0, sizeof(root_item.drop_progress));
130 root_item.drop_level = 0;
131
132 btrfs_tree_unlock(leaf);
133 free_extent_buffer(leaf);
134 leaf = NULL;
135
136 btrfs_set_root_dirid(&root_item, 0);
137
138 key.objectid = BTRFS_TREE_LOG_OBJECTID;
139 key.offset = objectid;
140 btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
141 ret = btrfs_insert_root(trans, root->fs_info->log_root_tree, &key,
142 &root_item);
143 if (ret)
144 goto fail;
145
146 new_root = btrfs_read_fs_root_no_radix(root->fs_info->log_root_tree,
147 &key);
148 BUG_ON(!new_root);
149
150 WARN_ON(root->log_root);
151 root->log_root = new_root;
152
153 /*
154 * log trees do not get reference counted because they go away
155 * before a real commit is actually done. They do store pointers
156 * to file data extents, and those reference counts still get
157 * updated (along with back refs to the log tree).
158 */
159 new_root->ref_cows = 0;
160 new_root->last_trans = trans->transid;
161
162 /*
163 * we need to make sure the root block for this new tree
164 * is marked as dirty in the dirty_log_pages tree. This
165 * is how it gets flushed down to disk at tree log commit time.
166 *
167 * the tree logging mutex keeps others from coming in and changing
168 * the new_root->node, so we can safely access it here
169 */
170 set_extent_dirty(&new_root->dirty_log_pages, new_root->node->start,
171 new_root->node->start + new_root->node->len - 1,
172 GFP_NOFS);
173
174fail:
175 return ret;
176}
177
178/*
179 * start a sub transaction and setup the log tree 81 * start a sub transaction and setup the log tree
180 * this increments the log tree writer count to make the people 82 * this increments the log tree writer count to make the people
181 * syncing the tree wait for us to finish 83 * syncing the tree wait for us to finish
@@ -184,6 +86,14 @@ static int start_log_trans(struct btrfs_trans_handle *trans,
184 struct btrfs_root *root) 86 struct btrfs_root *root)
185{ 87{
186 int ret; 88 int ret;
89
90 mutex_lock(&root->log_mutex);
91 if (root->log_root) {
92 root->log_batch++;
93 atomic_inc(&root->log_writers);
94 mutex_unlock(&root->log_mutex);
95 return 0;
96 }
187 mutex_lock(&root->fs_info->tree_log_mutex); 97 mutex_lock(&root->fs_info->tree_log_mutex);
188 if (!root->fs_info->log_root_tree) { 98 if (!root->fs_info->log_root_tree) {
189 ret = btrfs_init_log_root_tree(trans, root->fs_info); 99 ret = btrfs_init_log_root_tree(trans, root->fs_info);
@@ -193,9 +103,10 @@ static int start_log_trans(struct btrfs_trans_handle *trans,
193 ret = btrfs_add_log_tree(trans, root); 103 ret = btrfs_add_log_tree(trans, root);
194 BUG_ON(ret); 104 BUG_ON(ret);
195 } 105 }
196 atomic_inc(&root->fs_info->tree_log_writers);
197 root->fs_info->tree_log_batch++;
198 mutex_unlock(&root->fs_info->tree_log_mutex); 106 mutex_unlock(&root->fs_info->tree_log_mutex);
107 root->log_batch++;
108 atomic_inc(&root->log_writers);
109 mutex_unlock(&root->log_mutex);
199 return 0; 110 return 0;
200} 111}
201 112
@@ -212,13 +123,12 @@ static int join_running_log_trans(struct btrfs_root *root)
212 if (!root->log_root) 123 if (!root->log_root)
213 return -ENOENT; 124 return -ENOENT;
214 125
215 mutex_lock(&root->fs_info->tree_log_mutex); 126 mutex_lock(&root->log_mutex);
216 if (root->log_root) { 127 if (root->log_root) {
217 ret = 0; 128 ret = 0;
218 atomic_inc(&root->fs_info->tree_log_writers); 129 atomic_inc(&root->log_writers);
219 root->fs_info->tree_log_batch++;
220 } 130 }
221 mutex_unlock(&root->fs_info->tree_log_mutex); 131 mutex_unlock(&root->log_mutex);
222 return ret; 132 return ret;
223} 133}
224 134
@@ -228,10 +138,11 @@ static int join_running_log_trans(struct btrfs_root *root)
228 */ 138 */
229static int end_log_trans(struct btrfs_root *root) 139static int end_log_trans(struct btrfs_root *root)
230{ 140{
231 atomic_dec(&root->fs_info->tree_log_writers); 141 if (atomic_dec_and_test(&root->log_writers)) {
232 smp_mb(); 142 smp_mb();
233 if (waitqueue_active(&root->fs_info->tree_log_wait)) 143 if (waitqueue_active(&root->log_writer_wait))
234 wake_up(&root->fs_info->tree_log_wait); 144 wake_up(&root->log_writer_wait);
145 }
235 return 0; 146 return 0;
236} 147}
237 148
@@ -1704,6 +1615,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
1704 1615
1705 btrfs_tree_lock(next); 1616 btrfs_tree_lock(next);
1706 clean_tree_block(trans, root, next); 1617 clean_tree_block(trans, root, next);
1618 btrfs_set_lock_blocking(next);
1707 btrfs_wait_tree_block_writeback(next); 1619 btrfs_wait_tree_block_writeback(next);
1708 btrfs_tree_unlock(next); 1620 btrfs_tree_unlock(next);
1709 1621
@@ -1750,6 +1662,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
1750 next = path->nodes[*level]; 1662 next = path->nodes[*level];
1751 btrfs_tree_lock(next); 1663 btrfs_tree_lock(next);
1752 clean_tree_block(trans, root, next); 1664 clean_tree_block(trans, root, next);
1665 btrfs_set_lock_blocking(next);
1753 btrfs_wait_tree_block_writeback(next); 1666 btrfs_wait_tree_block_writeback(next);
1754 btrfs_tree_unlock(next); 1667 btrfs_tree_unlock(next);
1755 1668
@@ -1807,6 +1720,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
1807 1720
1808 btrfs_tree_lock(next); 1721 btrfs_tree_lock(next);
1809 clean_tree_block(trans, root, next); 1722 clean_tree_block(trans, root, next);
1723 btrfs_set_lock_blocking(next);
1810 btrfs_wait_tree_block_writeback(next); 1724 btrfs_wait_tree_block_writeback(next);
1811 btrfs_tree_unlock(next); 1725 btrfs_tree_unlock(next);
1812 1726
@@ -1879,6 +1793,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
1879 1793
1880 btrfs_tree_lock(next); 1794 btrfs_tree_lock(next);
1881 clean_tree_block(trans, log, next); 1795 clean_tree_block(trans, log, next);
1796 btrfs_set_lock_blocking(next);
1882 btrfs_wait_tree_block_writeback(next); 1797 btrfs_wait_tree_block_writeback(next);
1883 btrfs_tree_unlock(next); 1798 btrfs_tree_unlock(next);
1884 1799
@@ -1902,26 +1817,65 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
1902 } 1817 }
1903 } 1818 }
1904 btrfs_free_path(path); 1819 btrfs_free_path(path);
1905 if (wc->free)
1906 free_extent_buffer(log->node);
1907 return ret; 1820 return ret;
1908} 1821}
1909 1822
1910static int wait_log_commit(struct btrfs_root *log) 1823/*
1824 * helper function to update the item for a given subvolumes log root
1825 * in the tree of log roots
1826 */
1827static int update_log_root(struct btrfs_trans_handle *trans,
1828 struct btrfs_root *log)
1829{
1830 int ret;
1831
1832 if (log->log_transid == 1) {
1833 /* insert root item on the first sync */
1834 ret = btrfs_insert_root(trans, log->fs_info->log_root_tree,
1835 &log->root_key, &log->root_item);
1836 } else {
1837 ret = btrfs_update_root(trans, log->fs_info->log_root_tree,
1838 &log->root_key, &log->root_item);
1839 }
1840 return ret;
1841}
1842
1843static int wait_log_commit(struct btrfs_root *root, unsigned long transid)
1911{ 1844{
1912 DEFINE_WAIT(wait); 1845 DEFINE_WAIT(wait);
1913 u64 transid = log->fs_info->tree_log_transid; 1846 int index = transid % 2;
1914 1847
1848 /*
1849 * we only allow two pending log transactions at a time,
1850 * so we know that if ours is more than 2 older than the
1851 * current transaction, we're done
1852 */
1915 do { 1853 do {
1916 prepare_to_wait(&log->fs_info->tree_log_wait, &wait, 1854 prepare_to_wait(&root->log_commit_wait[index],
1917 TASK_UNINTERRUPTIBLE); 1855 &wait, TASK_UNINTERRUPTIBLE);
1918 mutex_unlock(&log->fs_info->tree_log_mutex); 1856 mutex_unlock(&root->log_mutex);
1919 if (atomic_read(&log->fs_info->tree_log_commit)) 1857 if (root->log_transid < transid + 2 &&
1858 atomic_read(&root->log_commit[index]))
1920 schedule(); 1859 schedule();
1921 finish_wait(&log->fs_info->tree_log_wait, &wait); 1860 finish_wait(&root->log_commit_wait[index], &wait);
1922 mutex_lock(&log->fs_info->tree_log_mutex); 1861 mutex_lock(&root->log_mutex);
1923 } while (transid == log->fs_info->tree_log_transid && 1862 } while (root->log_transid < transid + 2 &&
1924 atomic_read(&log->fs_info->tree_log_commit)); 1863 atomic_read(&root->log_commit[index]));
1864 return 0;
1865}
1866
1867static int wait_for_writer(struct btrfs_root *root)
1868{
1869 DEFINE_WAIT(wait);
1870 while (atomic_read(&root->log_writers)) {
1871 prepare_to_wait(&root->log_writer_wait,
1872 &wait, TASK_UNINTERRUPTIBLE);
1873 mutex_unlock(&root->log_mutex);
1874 if (atomic_read(&root->log_writers))
1875 schedule();
1876 mutex_lock(&root->log_mutex);
1877 finish_wait(&root->log_writer_wait, &wait);
1878 }
1925 return 0; 1879 return 0;
1926} 1880}
1927 1881
@@ -1933,57 +1887,114 @@ static int wait_log_commit(struct btrfs_root *log)
1933int btrfs_sync_log(struct btrfs_trans_handle *trans, 1887int btrfs_sync_log(struct btrfs_trans_handle *trans,
1934 struct btrfs_root *root) 1888 struct btrfs_root *root)
1935{ 1889{
1890 int index1;
1891 int index2;
1936 int ret; 1892 int ret;
1937 unsigned long batch;
1938 struct btrfs_root *log = root->log_root; 1893 struct btrfs_root *log = root->log_root;
1894 struct btrfs_root *log_root_tree = root->fs_info->log_root_tree;
1939 1895
1940 mutex_lock(&log->fs_info->tree_log_mutex); 1896 mutex_lock(&root->log_mutex);
1941 if (atomic_read(&log->fs_info->tree_log_commit)) { 1897 index1 = root->log_transid % 2;
1942 wait_log_commit(log); 1898 if (atomic_read(&root->log_commit[index1])) {
1943 goto out; 1899 wait_log_commit(root, root->log_transid);
1900 mutex_unlock(&root->log_mutex);
1901 return 0;
1944 } 1902 }
1945 atomic_set(&log->fs_info->tree_log_commit, 1); 1903 atomic_set(&root->log_commit[index1], 1);
1904
1905 /* wait for previous tree log sync to complete */
1906 if (atomic_read(&root->log_commit[(index1 + 1) % 2]))
1907 wait_log_commit(root, root->log_transid - 1);
1946 1908
1947 while (1) { 1909 while (1) {
1948 batch = log->fs_info->tree_log_batch; 1910 unsigned long batch = root->log_batch;
1949 mutex_unlock(&log->fs_info->tree_log_mutex); 1911 mutex_unlock(&root->log_mutex);
1950 schedule_timeout_uninterruptible(1); 1912 schedule_timeout_uninterruptible(1);
1951 mutex_lock(&log->fs_info->tree_log_mutex); 1913 mutex_lock(&root->log_mutex);
1952 1914 wait_for_writer(root);
1953 while (atomic_read(&log->fs_info->tree_log_writers)) { 1915 if (batch == root->log_batch)
1954 DEFINE_WAIT(wait);
1955 prepare_to_wait(&log->fs_info->tree_log_wait, &wait,
1956 TASK_UNINTERRUPTIBLE);
1957 mutex_unlock(&log->fs_info->tree_log_mutex);
1958 if (atomic_read(&log->fs_info->tree_log_writers))
1959 schedule();
1960 mutex_lock(&log->fs_info->tree_log_mutex);
1961 finish_wait(&log->fs_info->tree_log_wait, &wait);
1962 }
1963 if (batch == log->fs_info->tree_log_batch)
1964 break; 1916 break;
1965 } 1917 }
1966 1918
1967 ret = btrfs_write_and_wait_marked_extents(log, &log->dirty_log_pages); 1919 ret = btrfs_write_and_wait_marked_extents(log, &log->dirty_log_pages);
1968 BUG_ON(ret); 1920 BUG_ON(ret);
1969 ret = btrfs_write_and_wait_marked_extents(root->fs_info->log_root_tree, 1921
1970 &root->fs_info->log_root_tree->dirty_log_pages); 1922 btrfs_set_root_bytenr(&log->root_item, log->node->start);
1923 btrfs_set_root_generation(&log->root_item, trans->transid);
1924 btrfs_set_root_level(&log->root_item, btrfs_header_level(log->node));
1925
1926 root->log_batch = 0;
1927 root->log_transid++;
1928 log->log_transid = root->log_transid;
1929 smp_mb();
1930 /*
1931 * log tree has been flushed to disk, new modifications of
1932 * the log will be written to new positions. so it's safe to
1933 * allow log writers to go in.
1934 */
1935 mutex_unlock(&root->log_mutex);
1936
1937 mutex_lock(&log_root_tree->log_mutex);
1938 log_root_tree->log_batch++;
1939 atomic_inc(&log_root_tree->log_writers);
1940 mutex_unlock(&log_root_tree->log_mutex);
1941
1942 ret = update_log_root(trans, log);
1943 BUG_ON(ret);
1944
1945 mutex_lock(&log_root_tree->log_mutex);
1946 if (atomic_dec_and_test(&log_root_tree->log_writers)) {
1947 smp_mb();
1948 if (waitqueue_active(&log_root_tree->log_writer_wait))
1949 wake_up(&log_root_tree->log_writer_wait);
1950 }
1951
1952 index2 = log_root_tree->log_transid % 2;
1953 if (atomic_read(&log_root_tree->log_commit[index2])) {
1954 wait_log_commit(log_root_tree, log_root_tree->log_transid);
1955 mutex_unlock(&log_root_tree->log_mutex);
1956 goto out;
1957 }
1958 atomic_set(&log_root_tree->log_commit[index2], 1);
1959
1960 if (atomic_read(&log_root_tree->log_commit[(index2 + 1) % 2]))
1961 wait_log_commit(log_root_tree, log_root_tree->log_transid - 1);
1962
1963 wait_for_writer(log_root_tree);
1964
1965 ret = btrfs_write_and_wait_marked_extents(log_root_tree,
1966 &log_root_tree->dirty_log_pages);
1971 BUG_ON(ret); 1967 BUG_ON(ret);
1972 1968
1973 btrfs_set_super_log_root(&root->fs_info->super_for_commit, 1969 btrfs_set_super_log_root(&root->fs_info->super_for_commit,
1974 log->fs_info->log_root_tree->node->start); 1970 log_root_tree->node->start);
1975 btrfs_set_super_log_root_level(&root->fs_info->super_for_commit, 1971 btrfs_set_super_log_root_level(&root->fs_info->super_for_commit,
1976 btrfs_header_level(log->fs_info->log_root_tree->node)); 1972 btrfs_header_level(log_root_tree->node));
1973
1974 log_root_tree->log_batch = 0;
1975 log_root_tree->log_transid++;
1976 smp_mb();
1977
1978 mutex_unlock(&log_root_tree->log_mutex);
1979
1980 /*
1981 * nobody else is going to jump in and write the the ctree
1982 * super here because the log_commit atomic below is protecting
1983 * us. We must be called with a transaction handle pinning
1984 * the running transaction open, so a full commit can't hop
1985 * in and cause problems either.
1986 */
1987 write_ctree_super(trans, root->fs_info->tree_root, 2);
1977 1988
1978 write_ctree_super(trans, log->fs_info->tree_root, 2); 1989 atomic_set(&log_root_tree->log_commit[index2], 0);
1979 log->fs_info->tree_log_transid++;
1980 log->fs_info->tree_log_batch = 0;
1981 atomic_set(&log->fs_info->tree_log_commit, 0);
1982 smp_mb(); 1990 smp_mb();
1983 if (waitqueue_active(&log->fs_info->tree_log_wait)) 1991 if (waitqueue_active(&log_root_tree->log_commit_wait[index2]))
1984 wake_up(&log->fs_info->tree_log_wait); 1992 wake_up(&log_root_tree->log_commit_wait[index2]);
1985out: 1993out:
1986 mutex_unlock(&log->fs_info->tree_log_mutex); 1994 atomic_set(&root->log_commit[index1], 0);
1995 smp_mb();
1996 if (waitqueue_active(&root->log_commit_wait[index1]))
1997 wake_up(&root->log_commit_wait[index1]);
1987 return 0; 1998 return 0;
1988} 1999}
1989 2000
@@ -2019,38 +2030,18 @@ int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root)
2019 start, end, GFP_NOFS); 2030 start, end, GFP_NOFS);
2020 } 2031 }
2021 2032
2022 log = root->log_root; 2033 if (log->log_transid > 0) {
2023 ret = btrfs_del_root(trans, root->fs_info->log_root_tree, 2034 ret = btrfs_del_root(trans, root->fs_info->log_root_tree,
2024 &log->root_key); 2035 &log->root_key);
2025 BUG_ON(ret); 2036 BUG_ON(ret);
2037 }
2026 root->log_root = NULL; 2038 root->log_root = NULL;
2027 kfree(root->log_root); 2039 free_extent_buffer(log->node);
2040 kfree(log);
2028 return 0; 2041 return 0;
2029} 2042}
2030 2043
2031/* 2044/*
2032 * helper function to update the item for a given subvolumes log root
2033 * in the tree of log roots
2034 */
2035static int update_log_root(struct btrfs_trans_handle *trans,
2036 struct btrfs_root *log)
2037{
2038 u64 bytenr = btrfs_root_bytenr(&log->root_item);
2039 int ret;
2040
2041 if (log->node->start == bytenr)
2042 return 0;
2043
2044 btrfs_set_root_bytenr(&log->root_item, log->node->start);
2045 btrfs_set_root_generation(&log->root_item, trans->transid);
2046 btrfs_set_root_level(&log->root_item, btrfs_header_level(log->node));
2047 ret = btrfs_update_root(trans, log->fs_info->log_root_tree,
2048 &log->root_key, &log->root_item);
2049 BUG_ON(ret);
2050 return ret;
2051}
2052
2053/*
2054 * If both a file and directory are logged, and unlinks or renames are 2045 * If both a file and directory are logged, and unlinks or renames are
2055 * mixed in, we have a few interesting corners: 2046 * mixed in, we have a few interesting corners:
2056 * 2047 *
@@ -2711,11 +2702,6 @@ next_slot:
2711 2702
2712 btrfs_free_path(path); 2703 btrfs_free_path(path);
2713 btrfs_free_path(dst_path); 2704 btrfs_free_path(dst_path);
2714
2715 mutex_lock(&root->fs_info->tree_log_mutex);
2716 ret = update_log_root(trans, log);
2717 BUG_ON(ret);
2718 mutex_unlock(&root->fs_info->tree_log_mutex);
2719out: 2705out:
2720 return 0; 2706 return 0;
2721} 2707}
@@ -2846,7 +2832,9 @@ again:
2846 BUG_ON(!wc.replay_dest); 2832 BUG_ON(!wc.replay_dest);
2847 2833
2848 wc.replay_dest->log_root = log; 2834 wc.replay_dest->log_root = log;
2835 mutex_lock(&fs_info->trans_mutex);
2849 btrfs_record_root_in_trans(wc.replay_dest); 2836 btrfs_record_root_in_trans(wc.replay_dest);
2837 mutex_unlock(&fs_info->trans_mutex);
2850 ret = walk_log_tree(trans, log, &wc); 2838 ret = walk_log_tree(trans, log, &wc);
2851 BUG_ON(ret); 2839 BUG_ON(ret);
2852 2840
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3451e1cca2b5..1316139bf9e8 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -20,7 +20,6 @@
20#include <linux/buffer_head.h> 20#include <linux/buffer_head.h>
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/random.h> 22#include <linux/random.h>
23#include <linux/version.h>
24#include <asm/div64.h> 23#include <asm/div64.h>
25#include "compat.h" 24#include "compat.h"
26#include "ctree.h" 25#include "ctree.h"
@@ -104,10 +103,8 @@ static noinline struct btrfs_device *__find_device(struct list_head *head,
104 u64 devid, u8 *uuid) 103 u64 devid, u8 *uuid)
105{ 104{
106 struct btrfs_device *dev; 105 struct btrfs_device *dev;
107 struct list_head *cur;
108 106
109 list_for_each(cur, head) { 107 list_for_each_entry(dev, head, dev_list) {
110 dev = list_entry(cur, struct btrfs_device, dev_list);
111 if (dev->devid == devid && 108 if (dev->devid == devid &&
112 (!uuid || !memcmp(dev->uuid, uuid, BTRFS_UUID_SIZE))) { 109 (!uuid || !memcmp(dev->uuid, uuid, BTRFS_UUID_SIZE))) {
113 return dev; 110 return dev;
@@ -118,11 +115,9 @@ static noinline struct btrfs_device *__find_device(struct list_head *head,
118 115
119static noinline struct btrfs_fs_devices *find_fsid(u8 *fsid) 116static noinline struct btrfs_fs_devices *find_fsid(u8 *fsid)
120{ 117{
121 struct list_head *cur;
122 struct btrfs_fs_devices *fs_devices; 118 struct btrfs_fs_devices *fs_devices;
123 119
124 list_for_each(cur, &fs_uuids) { 120 list_for_each_entry(fs_devices, &fs_uuids, list) {
125 fs_devices = list_entry(cur, struct btrfs_fs_devices, list);
126 if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0) 121 if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0)
127 return fs_devices; 122 return fs_devices;
128 } 123 }
@@ -159,6 +154,7 @@ static noinline int run_scheduled_bios(struct btrfs_device *device)
159loop: 154loop:
160 spin_lock(&device->io_lock); 155 spin_lock(&device->io_lock);
161 156
157loop_lock:
162 /* take all the bios off the list at once and process them 158 /* take all the bios off the list at once and process them
163 * later on (without the lock held). But, remember the 159 * later on (without the lock held). But, remember the
164 * tail and other pointers so the bios can be properly reinserted 160 * tail and other pointers so the bios can be properly reinserted
@@ -208,7 +204,7 @@ loop:
208 * is now congested. Back off and let other work structs 204 * is now congested. Back off and let other work structs
209 * run instead 205 * run instead
210 */ 206 */
211 if (pending && bdi_write_congested(bdi) && 207 if (pending && bdi_write_congested(bdi) && num_run > 16 &&
212 fs_info->fs_devices->open_devices > 1) { 208 fs_info->fs_devices->open_devices > 1) {
213 struct bio *old_head; 209 struct bio *old_head;
214 210
@@ -220,7 +216,8 @@ loop:
220 tail->bi_next = old_head; 216 tail->bi_next = old_head;
221 else 217 else
222 device->pending_bio_tail = tail; 218 device->pending_bio_tail = tail;
223 device->running_pending = 0; 219
220 device->running_pending = 1;
224 221
225 spin_unlock(&device->io_lock); 222 spin_unlock(&device->io_lock);
226 btrfs_requeue_work(&device->work); 223 btrfs_requeue_work(&device->work);
@@ -229,6 +226,11 @@ loop:
229 } 226 }
230 if (again) 227 if (again)
231 goto loop; 228 goto loop;
229
230 spin_lock(&device->io_lock);
231 if (device->pending_bios)
232 goto loop_lock;
233 spin_unlock(&device->io_lock);
232done: 234done:
233 return 0; 235 return 0;
234} 236}
@@ -345,14 +347,11 @@ error:
345 347
346int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices) 348int btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices)
347{ 349{
348 struct list_head *tmp; 350 struct btrfs_device *device, *next;
349 struct list_head *cur;
350 struct btrfs_device *device;
351 351
352 mutex_lock(&uuid_mutex); 352 mutex_lock(&uuid_mutex);
353again: 353again:
354 list_for_each_safe(cur, tmp, &fs_devices->devices) { 354 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
355 device = list_entry(cur, struct btrfs_device, dev_list);
356 if (device->in_fs_metadata) 355 if (device->in_fs_metadata)
357 continue; 356 continue;
358 357
@@ -383,14 +382,12 @@ again:
383 382
384static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices) 383static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
385{ 384{
386 struct list_head *cur;
387 struct btrfs_device *device; 385 struct btrfs_device *device;
388 386
389 if (--fs_devices->opened > 0) 387 if (--fs_devices->opened > 0)
390 return 0; 388 return 0;
391 389
392 list_for_each(cur, &fs_devices->devices) { 390 list_for_each_entry(device, &fs_devices->devices, dev_list) {
393 device = list_entry(cur, struct btrfs_device, dev_list);
394 if (device->bdev) { 391 if (device->bdev) {
395 close_bdev_exclusive(device->bdev, device->mode); 392 close_bdev_exclusive(device->bdev, device->mode);
396 fs_devices->open_devices--; 393 fs_devices->open_devices--;
@@ -439,7 +436,6 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
439{ 436{
440 struct block_device *bdev; 437 struct block_device *bdev;
441 struct list_head *head = &fs_devices->devices; 438 struct list_head *head = &fs_devices->devices;
442 struct list_head *cur;
443 struct btrfs_device *device; 439 struct btrfs_device *device;
444 struct block_device *latest_bdev = NULL; 440 struct block_device *latest_bdev = NULL;
445 struct buffer_head *bh; 441 struct buffer_head *bh;
@@ -450,8 +446,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
450 int seeding = 1; 446 int seeding = 1;
451 int ret = 0; 447 int ret = 0;
452 448
453 list_for_each(cur, head) { 449 list_for_each_entry(device, head, dev_list) {
454 device = list_entry(cur, struct btrfs_device, dev_list);
455 if (device->bdev) 450 if (device->bdev)
456 continue; 451 continue;
457 if (!device->name) 452 if (!device->name)
@@ -578,7 +573,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
578 *(unsigned long long *)disk_super->fsid, 573 *(unsigned long long *)disk_super->fsid,
579 *(unsigned long long *)(disk_super->fsid + 8)); 574 *(unsigned long long *)(disk_super->fsid + 8));
580 } 575 }
581 printk(KERN_INFO "devid %llu transid %llu %s\n", 576 printk(KERN_CONT "devid %llu transid %llu %s\n",
582 (unsigned long long)devid, (unsigned long long)transid, path); 577 (unsigned long long)devid, (unsigned long long)transid, path);
583 ret = device_list_add(path, disk_super, devid, fs_devices_ret); 578 ret = device_list_add(path, disk_super, devid, fs_devices_ret);
584 579
@@ -1017,14 +1012,12 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1017 } 1012 }
1018 1013
1019 if (strcmp(device_path, "missing") == 0) { 1014 if (strcmp(device_path, "missing") == 0) {
1020 struct list_head *cur;
1021 struct list_head *devices; 1015 struct list_head *devices;
1022 struct btrfs_device *tmp; 1016 struct btrfs_device *tmp;
1023 1017
1024 device = NULL; 1018 device = NULL;
1025 devices = &root->fs_info->fs_devices->devices; 1019 devices = &root->fs_info->fs_devices->devices;
1026 list_for_each(cur, devices) { 1020 list_for_each_entry(tmp, devices, dev_list) {
1027 tmp = list_entry(cur, struct btrfs_device, dev_list);
1028 if (tmp->in_fs_metadata && !tmp->bdev) { 1021 if (tmp->in_fs_metadata && !tmp->bdev) {
1029 device = tmp; 1022 device = tmp;
1030 break; 1023 break;
@@ -1280,7 +1273,6 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1280 struct btrfs_trans_handle *trans; 1273 struct btrfs_trans_handle *trans;
1281 struct btrfs_device *device; 1274 struct btrfs_device *device;
1282 struct block_device *bdev; 1275 struct block_device *bdev;
1283 struct list_head *cur;
1284 struct list_head *devices; 1276 struct list_head *devices;
1285 struct super_block *sb = root->fs_info->sb; 1277 struct super_block *sb = root->fs_info->sb;
1286 u64 total_bytes; 1278 u64 total_bytes;
@@ -1304,8 +1296,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1304 mutex_lock(&root->fs_info->volume_mutex); 1296 mutex_lock(&root->fs_info->volume_mutex);
1305 1297
1306 devices = &root->fs_info->fs_devices->devices; 1298 devices = &root->fs_info->fs_devices->devices;
1307 list_for_each(cur, devices) { 1299 list_for_each_entry(device, devices, dev_list) {
1308 device = list_entry(cur, struct btrfs_device, dev_list);
1309 if (device->bdev == bdev) { 1300 if (device->bdev == bdev) {
1310 ret = -EEXIST; 1301 ret = -EEXIST;
1311 goto error; 1302 goto error;
@@ -1704,7 +1695,6 @@ static u64 div_factor(u64 num, int factor)
1704int btrfs_balance(struct btrfs_root *dev_root) 1695int btrfs_balance(struct btrfs_root *dev_root)
1705{ 1696{
1706 int ret; 1697 int ret;
1707 struct list_head *cur;
1708 struct list_head *devices = &dev_root->fs_info->fs_devices->devices; 1698 struct list_head *devices = &dev_root->fs_info->fs_devices->devices;
1709 struct btrfs_device *device; 1699 struct btrfs_device *device;
1710 u64 old_size; 1700 u64 old_size;
@@ -1723,8 +1713,7 @@ int btrfs_balance(struct btrfs_root *dev_root)
1723 dev_root = dev_root->fs_info->dev_root; 1713 dev_root = dev_root->fs_info->dev_root;
1724 1714
1725 /* step one make some room on all the devices */ 1715 /* step one make some room on all the devices */
1726 list_for_each(cur, devices) { 1716 list_for_each_entry(device, devices, dev_list) {
1727 device = list_entry(cur, struct btrfs_device, dev_list);
1728 old_size = device->total_bytes; 1717 old_size = device->total_bytes;
1729 size_to_free = div_factor(old_size, 1); 1718 size_to_free = div_factor(old_size, 1);
1730 size_to_free = min(size_to_free, (u64)1 * 1024 * 1024); 1719 size_to_free = min(size_to_free, (u64)1 * 1024 * 1024);
@@ -2905,10 +2894,6 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
2905 free_extent_map(em); 2894 free_extent_map(em);
2906 } 2895 }
2907 2896
2908 map = kzalloc(sizeof(*map), GFP_NOFS);
2909 if (!map)
2910 return -ENOMEM;
2911
2912 em = alloc_extent_map(GFP_NOFS); 2897 em = alloc_extent_map(GFP_NOFS);
2913 if (!em) 2898 if (!em)
2914 return -ENOMEM; 2899 return -ENOMEM;
@@ -3117,6 +3102,8 @@ int btrfs_read_sys_array(struct btrfs_root *root)
3117 if (!sb) 3102 if (!sb)
3118 return -ENOMEM; 3103 return -ENOMEM;
3119 btrfs_set_buffer_uptodate(sb); 3104 btrfs_set_buffer_uptodate(sb);
3105 btrfs_set_buffer_lockdep_class(sb, 0);
3106
3120 write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE); 3107 write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE);
3121 array_size = btrfs_super_sys_array_size(super_copy); 3108 array_size = btrfs_super_sys_array_size(super_copy);
3122 3109
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index 7f332e270894..a9d3bf4d2689 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -21,6 +21,7 @@
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/rwsem.h> 22#include <linux/rwsem.h>
23#include <linux/xattr.h> 23#include <linux/xattr.h>
24#include <linux/security.h>
24#include "ctree.h" 25#include "ctree.h"
25#include "btrfs_inode.h" 26#include "btrfs_inode.h"
26#include "transaction.h" 27#include "transaction.h"
@@ -45,9 +46,12 @@ ssize_t __btrfs_getxattr(struct inode *inode, const char *name,
45 /* lookup the xattr by name */ 46 /* lookup the xattr by name */
46 di = btrfs_lookup_xattr(NULL, root, path, inode->i_ino, name, 47 di = btrfs_lookup_xattr(NULL, root, path, inode->i_ino, name,
47 strlen(name), 0); 48 strlen(name), 0);
48 if (!di || IS_ERR(di)) { 49 if (!di) {
49 ret = -ENODATA; 50 ret = -ENODATA;
50 goto out; 51 goto out;
52 } else if (IS_ERR(di)) {
53 ret = PTR_ERR(di);
54 goto out;
51 } 55 }
52 56
53 leaf = path->nodes[0]; 57 leaf = path->nodes[0];
@@ -62,6 +66,14 @@ ssize_t __btrfs_getxattr(struct inode *inode, const char *name,
62 ret = -ERANGE; 66 ret = -ERANGE;
63 goto out; 67 goto out;
64 } 68 }
69
70 /*
71 * The way things are packed into the leaf is like this
72 * |struct btrfs_dir_item|name|data|
73 * where name is the xattr name, so security.foo, and data is the
74 * content of the xattr. data_ptr points to the location in memory
75 * where the data starts in the in memory leaf
76 */
65 data_ptr = (unsigned long)((char *)(di + 1) + 77 data_ptr = (unsigned long)((char *)(di + 1) +
66 btrfs_dir_name_len(leaf, di)); 78 btrfs_dir_name_len(leaf, di));
67 read_extent_buffer(leaf, buffer, data_ptr, 79 read_extent_buffer(leaf, buffer, data_ptr,
@@ -86,7 +98,7 @@ int __btrfs_setxattr(struct inode *inode, const char *name,
86 if (!path) 98 if (!path)
87 return -ENOMEM; 99 return -ENOMEM;
88 100
89 trans = btrfs_start_transaction(root, 1); 101 trans = btrfs_join_transaction(root, 1);
90 btrfs_set_trans_block_group(trans, inode); 102 btrfs_set_trans_block_group(trans, inode);
91 103
92 /* first lets see if we already have this xattr */ 104 /* first lets see if we already have this xattr */
@@ -176,7 +188,6 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
176 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 188 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
177 if (ret < 0) 189 if (ret < 0)
178 goto err; 190 goto err;
179 ret = 0;
180 advance = 0; 191 advance = 0;
181 while (1) { 192 while (1) {
182 leaf = path->nodes[0]; 193 leaf = path->nodes[0];
@@ -320,3 +331,34 @@ int btrfs_removexattr(struct dentry *dentry, const char *name)
320 return -EOPNOTSUPP; 331 return -EOPNOTSUPP;
321 return __btrfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE); 332 return __btrfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE);
322} 333}
334
335int btrfs_xattr_security_init(struct inode *inode, struct inode *dir)
336{
337 int err;
338 size_t len;
339 void *value;
340 char *suffix;
341 char *name;
342
343 err = security_inode_init_security(inode, dir, &suffix, &value, &len);
344 if (err) {
345 if (err == -EOPNOTSUPP)
346 return 0;
347 return err;
348 }
349
350 name = kmalloc(XATTR_SECURITY_PREFIX_LEN + strlen(suffix) + 1,
351 GFP_NOFS);
352 if (!name) {
353 err = -ENOMEM;
354 } else {
355 strcpy(name, XATTR_SECURITY_PREFIX);
356 strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix);
357 err = __btrfs_setxattr(inode, name, value, len, 0);
358 kfree(name);
359 }
360
361 kfree(suffix);
362 kfree(value);
363 return err;
364}
diff --git a/fs/btrfs/xattr.h b/fs/btrfs/xattr.h
index 5b1d08f8e68d..c71e9c3cf3f7 100644
--- a/fs/btrfs/xattr.h
+++ b/fs/btrfs/xattr.h
@@ -36,4 +36,6 @@ extern int btrfs_setxattr(struct dentry *dentry, const char *name,
36 const void *value, size_t size, int flags); 36 const void *value, size_t size, int flags);
37extern int btrfs_removexattr(struct dentry *dentry, const char *name); 37extern int btrfs_removexattr(struct dentry *dentry, const char *name);
38 38
39extern int btrfs_xattr_security_init(struct inode *inode, struct inode *dir);
40
39#endif /* __XATTR__ */ 41#endif /* __XATTR__ */
diff --git a/fs/buffer.c b/fs/buffer.c
index b58208f1640a..9f697419ed8e 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -777,6 +777,7 @@ static int __set_page_dirty(struct page *page,
777 __inc_zone_page_state(page, NR_FILE_DIRTY); 777 __inc_zone_page_state(page, NR_FILE_DIRTY);
778 __inc_bdi_stat(mapping->backing_dev_info, 778 __inc_bdi_stat(mapping->backing_dev_info,
779 BDI_RECLAIMABLE); 779 BDI_RECLAIMABLE);
780 task_dirty_inc(current);
780 task_io_account_write(PAGE_CACHE_SIZE); 781 task_io_account_write(PAGE_CACHE_SIZE);
781 } 782 }
782 radix_tree_tag_set(&mapping->page_tree, 783 radix_tree_tag_set(&mapping->page_tree,
@@ -2688,7 +2689,7 @@ int nobh_write_end(struct file *file, struct address_space *mapping,
2688 struct buffer_head *bh; 2689 struct buffer_head *bh;
2689 BUG_ON(fsdata != NULL && page_has_buffers(page)); 2690 BUG_ON(fsdata != NULL && page_has_buffers(page));
2690 2691
2691 if (unlikely(copied < len) && !page_has_buffers(page)) 2692 if (unlikely(copied < len) && head)
2692 attach_nobh_buffers(page, head); 2693 attach_nobh_buffers(page, head);
2693 if (page_has_buffers(page)) 2694 if (page_has_buffers(page))
2694 return generic_write_end(file, mapping, pos, len, 2695 return generic_write_end(file, mapping, pos, len,
@@ -3108,7 +3109,7 @@ int sync_dirty_buffer(struct buffer_head *bh)
3108 if (test_clear_buffer_dirty(bh)) { 3109 if (test_clear_buffer_dirty(bh)) {
3109 get_bh(bh); 3110 get_bh(bh);
3110 bh->b_end_io = end_buffer_write_sync; 3111 bh->b_end_io = end_buffer_write_sync;
3111 ret = submit_bh(WRITE_SYNC, bh); 3112 ret = submit_bh(WRITE, bh);
3112 wait_on_buffer(bh); 3113 wait_on_buffer(bh);
3113 if (buffer_eopnotsupp(bh)) { 3114 if (buffer_eopnotsupp(bh)) {
3114 clear_buffer_eopnotsupp(bh); 3115 clear_buffer_eopnotsupp(bh);
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 73ac7ebd1dfc..851388fafc73 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,3 +1,13 @@
1Version 1.57
2------------
3Improve support for multiple security contexts to the same server. We
4used to use the same "vcnumber" for all connections which could cause
5the server to treat subsequent connections, especially those that
6are authenticated as guest, as reconnections, invalidating the earlier
7user's smb session. This fix allows cifs to mount multiple times to the
8same server with different userids without risking invalidating earlier
9established security contexts.
10
1Version 1.56 11Version 1.56
2------------ 12------------
3Add "forcemandatorylock" mount option to allow user to use mandatory 13Add "forcemandatorylock" mount option to allow user to use mandatory
@@ -7,7 +17,10 @@ specified and user does not have access to query information about the
7top of the share. Fix problem in 2.6.28 resolving DFS paths to 17top of the share. Fix problem in 2.6.28 resolving DFS paths to
8Samba servers (worked to Windows). Fix rmdir so that pending search 18Samba servers (worked to Windows). Fix rmdir so that pending search
9(readdir) requests do not get invalid results which include the now 19(readdir) requests do not get invalid results which include the now
10removed directory. 20removed directory. Fix oops in cifs_dfs_ref.c when prefixpath is not reachable
21when using DFS. Add better file create support to servers which support
22the CIFS POSIX protocol extensions (this adds support for new flags
23on create, and improves semantics for write of locked ranges).
11 24
12Version 1.55 25Version 1.55
13------------ 26------------
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 7ac481841f87..2b1d28a9ee28 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -100,5 +100,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
100extern const struct export_operations cifs_export_ops; 100extern const struct export_operations cifs_export_ops;
101#endif /* EXPERIMENTAL */ 101#endif /* EXPERIMENTAL */
102 102
103#define CIFS_VERSION "1.56" 103#define CIFS_VERSION "1.57"
104#endif /* _CIFSFS_H */ 104#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 94c1ca0ec953..e004f6db5fc8 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -164,9 +164,12 @@ struct TCP_Server_Info {
164 /* multiplexed reads or writes */ 164 /* multiplexed reads or writes */
165 unsigned int maxBuf; /* maxBuf specifies the maximum */ 165 unsigned int maxBuf; /* maxBuf specifies the maximum */
166 /* message size the server can send or receive for non-raw SMBs */ 166 /* message size the server can send or receive for non-raw SMBs */
167 unsigned int maxRw; /* maxRw specifies the maximum */ 167 unsigned int max_rw; /* maxRw specifies the maximum */
168 /* message size the server can send or receive for */ 168 /* message size the server can send or receive for */
169 /* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */ 169 /* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */
170 unsigned int max_vcs; /* maximum number of smb sessions, at least
171 those that can be specified uniquely with
172 vcnumbers */
170 char sessid[4]; /* unique token id for this session */ 173 char sessid[4]; /* unique token id for this session */
171 /* (returned on Negotiate */ 174 /* (returned on Negotiate */
172 int capabilities; /* allow selective disabling of caps by smb sess */ 175 int capabilities; /* allow selective disabling of caps by smb sess */
@@ -210,6 +213,7 @@ struct cifsSesInfo {
210 unsigned overrideSecFlg; /* if non-zero override global sec flags */ 213 unsigned overrideSecFlg; /* if non-zero override global sec flags */
211 __u16 ipc_tid; /* special tid for connection to IPC share */ 214 __u16 ipc_tid; /* special tid for connection to IPC share */
212 __u16 flags; 215 __u16 flags;
216 __u16 vcnum;
213 char *serverOS; /* name of operating system underlying server */ 217 char *serverOS; /* name of operating system underlying server */
214 char *serverNOS; /* name of network operating system of server */ 218 char *serverNOS; /* name of network operating system of server */
215 char *serverDomain; /* security realm of server */ 219 char *serverDomain; /* security realm of server */
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 382ba6298809..083dfc57c7a3 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -42,6 +42,7 @@ extern void _FreeXid(unsigned int);
42#define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current_fsuid())); 42#define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current_fsuid()));
43#define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__func__,curr_xid,(int)rc));} 43#define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__func__,curr_xid,(int)rc));}
44extern char *build_path_from_dentry(struct dentry *); 44extern char *build_path_from_dentry(struct dentry *);
45extern char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb);
45extern char *build_wildcard_path_from_dentry(struct dentry *direntry); 46extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
46/* extern void renew_parental_timestamps(struct dentry *direntry);*/ 47/* extern void renew_parental_timestamps(struct dentry *direntry);*/
47extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *, 48extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *,
@@ -91,6 +92,9 @@ extern u64 cifs_UnixTimeToNT(struct timespec);
91extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time); 92extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time);
92extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time); 93extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time);
93 94
95extern void posix_fill_in_inode(struct inode *tmp_inode,
96 FILE_UNIX_BASIC_INFO *pData, int isNewInode);
97extern struct inode *cifs_new_inode(struct super_block *sb, __u64 *inum);
94extern int cifs_get_inode_info(struct inode **pinode, 98extern int cifs_get_inode_info(struct inode **pinode,
95 const unsigned char *search_path, 99 const unsigned char *search_path,
96 FILE_ALL_INFO *pfile_info, 100 FILE_ALL_INFO *pfile_info,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 552642a507c4..939e2f76b959 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -528,14 +528,15 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
528 server->maxReq = le16_to_cpu(rsp->MaxMpxCount); 528 server->maxReq = le16_to_cpu(rsp->MaxMpxCount);
529 server->maxBuf = min((__u32)le16_to_cpu(rsp->MaxBufSize), 529 server->maxBuf = min((__u32)le16_to_cpu(rsp->MaxBufSize),
530 (__u32)CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); 530 (__u32)CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
531 server->max_vcs = le16_to_cpu(rsp->MaxNumberVcs);
531 GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey); 532 GETU32(server->sessid) = le32_to_cpu(rsp->SessionKey);
532 /* even though we do not use raw we might as well set this 533 /* even though we do not use raw we might as well set this
533 accurately, in case we ever find a need for it */ 534 accurately, in case we ever find a need for it */
534 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) { 535 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) {
535 server->maxRw = 0xFF00; 536 server->max_rw = 0xFF00;
536 server->capabilities = CAP_MPX_MODE | CAP_RAW_MODE; 537 server->capabilities = CAP_MPX_MODE | CAP_RAW_MODE;
537 } else { 538 } else {
538 server->maxRw = 0;/* we do not need to use raw anyway */ 539 server->max_rw = 0;/* do not need to use raw anyway */
539 server->capabilities = CAP_MPX_MODE; 540 server->capabilities = CAP_MPX_MODE;
540 } 541 }
541 tmp = (__s16)le16_to_cpu(rsp->ServerTimeZone); 542 tmp = (__s16)le16_to_cpu(rsp->ServerTimeZone);
@@ -638,7 +639,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
638 /* probably no need to store and check maxvcs */ 639 /* probably no need to store and check maxvcs */
639 server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize), 640 server->maxBuf = min(le32_to_cpu(pSMBr->MaxBufferSize),
640 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE); 641 (__u32) CIFSMaxBufSize + MAX_CIFS_HDR_SIZE);
641 server->maxRw = le32_to_cpu(pSMBr->MaxRawSize); 642 server->max_rw = le32_to_cpu(pSMBr->MaxRawSize);
642 cFYI(DBG2, ("Max buf = %d", ses->server->maxBuf)); 643 cFYI(DBG2, ("Max buf = %d", ses->server->maxBuf));
643 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey); 644 GETU32(ses->server->sessid) = le32_to_cpu(pSMBr->SessionKey);
644 server->capabilities = le32_to_cpu(pSMBr->Capabilities); 645 server->capabilities = le32_to_cpu(pSMBr->Capabilities);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 2209be943051..da0f4ffa0613 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -23,7 +23,6 @@
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/wait.h> 25#include <linux/wait.h>
26#include <linux/ipv6.h>
27#include <linux/pagemap.h> 26#include <linux/pagemap.h>
28#include <linux/ctype.h> 27#include <linux/ctype.h>
29#include <linux/utsname.h> 28#include <linux/utsname.h>
@@ -35,6 +34,7 @@
35#include <linux/freezer.h> 34#include <linux/freezer.h>
36#include <asm/uaccess.h> 35#include <asm/uaccess.h>
37#include <asm/processor.h> 36#include <asm/processor.h>
37#include <net/ipv6.h>
38#include "cifspdu.h" 38#include "cifspdu.h"
39#include "cifsglob.h" 39#include "cifsglob.h"
40#include "cifsproto.h" 40#include "cifsproto.h"
@@ -1379,8 +1379,8 @@ cifs_find_tcp_session(struct sockaddr_storage *addr)
1379 server->addr.sockAddr.sin_addr.s_addr)) 1379 server->addr.sockAddr.sin_addr.s_addr))
1380 continue; 1380 continue;
1381 else if (addr->ss_family == AF_INET6 && 1381 else if (addr->ss_family == AF_INET6 &&
1382 memcmp(&server->addr.sockAddr6.sin6_addr, 1382 !ipv6_addr_equal(&server->addr.sockAddr6.sin6_addr,
1383 &addr6->sin6_addr, sizeof(addr6->sin6_addr))) 1383 &addr6->sin6_addr))
1384 continue; 1384 continue;
1385 1385
1386 ++server->srv_count; 1386 ++server->srv_count;
@@ -2180,6 +2180,33 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info,
2180 "mount option supported")); 2180 "mount option supported"));
2181} 2181}
2182 2182
2183static int
2184is_path_accessible(int xid, struct cifsTconInfo *tcon,
2185 struct cifs_sb_info *cifs_sb, const char *full_path)
2186{
2187 int rc;
2188 __u64 inode_num;
2189 FILE_ALL_INFO *pfile_info;
2190
2191 rc = CIFSGetSrvInodeNumber(xid, tcon, full_path, &inode_num,
2192 cifs_sb->local_nls,
2193 cifs_sb->mnt_cifs_flags &
2194 CIFS_MOUNT_MAP_SPECIAL_CHR);
2195 if (rc != -EOPNOTSUPP)
2196 return rc;
2197
2198 pfile_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
2199 if (pfile_info == NULL)
2200 return -ENOMEM;
2201
2202 rc = CIFSSMBQPathInfo(xid, tcon, full_path, pfile_info,
2203 0 /* not legacy */, cifs_sb->local_nls,
2204 cifs_sb->mnt_cifs_flags &
2205 CIFS_MOUNT_MAP_SPECIAL_CHR);
2206 kfree(pfile_info);
2207 return rc;
2208}
2209
2183int 2210int
2184cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, 2211cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2185 char *mount_data, const char *devname) 2212 char *mount_data, const char *devname)
@@ -2190,6 +2217,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2190 struct cifsSesInfo *pSesInfo = NULL; 2217 struct cifsSesInfo *pSesInfo = NULL;
2191 struct cifsTconInfo *tcon = NULL; 2218 struct cifsTconInfo *tcon = NULL;
2192 struct TCP_Server_Info *srvTcp = NULL; 2219 struct TCP_Server_Info *srvTcp = NULL;
2220 char *full_path;
2193 2221
2194 xid = GetXid(); 2222 xid = GetXid();
2195 2223
@@ -2426,6 +2454,23 @@ mount_fail_check:
2426 cifs_sb->rsize = min(cifs_sb->rsize, 2454 cifs_sb->rsize = min(cifs_sb->rsize,
2427 (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)); 2455 (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE));
2428 2456
2457 if (!rc && cifs_sb->prepathlen) {
2458 /* build_path_to_root works only when we have a valid tcon */
2459 full_path = cifs_build_path_to_root(cifs_sb);
2460 if (full_path == NULL) {
2461 rc = -ENOMEM;
2462 goto mount_fail_check;
2463 }
2464 rc = is_path_accessible(xid, tcon, cifs_sb, full_path);
2465 if (rc) {
2466 cERROR(1, ("Path %s in not accessible: %d",
2467 full_path, rc));
2468 kfree(full_path);
2469 goto mount_fail_check;
2470 }
2471 kfree(full_path);
2472 }
2473
2429 /* volume_info->password is freed above when existing session found 2474 /* volume_info->password is freed above when existing session found
2430 (in which case it is not needed anymore) but when new sesion is created 2475 (in which case it is not needed anymore) but when new sesion is created
2431 the password ptr is put in the new session structure (in which case the 2476 the password ptr is put in the new session structure (in which case the
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 964aad03c5ad..89fb72832652 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * vfs operations that deal with dentries 4 * vfs operations that deal with dentries
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2002,2008 6 * Copyright (C) International Business Machines Corp., 2002,2009
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or modify 9 * This library is free software; you can redistribute it and/or modify
@@ -129,6 +129,78 @@ cifs_bp_rename_retry:
129 return full_path; 129 return full_path;
130} 130}
131 131
132static int cifs_posix_open(char *full_path, struct inode **pinode,
133 struct super_block *sb, int mode, int oflags,
134 int *poplock, __u16 *pnetfid, int xid)
135{
136 int rc;
137 __u32 oplock;
138 FILE_UNIX_BASIC_INFO *presp_data;
139 __u32 posix_flags = 0;
140 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
141
142 cFYI(1, ("posix open %s", full_path));
143
144 presp_data = kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
145 if (presp_data == NULL)
146 return -ENOMEM;
147
148/* So far cifs posix extensions can only map the following flags.
149 There are other valid fmode oflags such as FMODE_LSEEK, FMODE_PREAD, but
150 so far we do not seem to need them, and we can treat them as local only */
151 if ((oflags & (FMODE_READ | FMODE_WRITE)) ==
152 (FMODE_READ | FMODE_WRITE))
153 posix_flags = SMB_O_RDWR;
154 else if (oflags & FMODE_READ)
155 posix_flags = SMB_O_RDONLY;
156 else if (oflags & FMODE_WRITE)
157 posix_flags = SMB_O_WRONLY;
158 if (oflags & O_CREAT)
159 posix_flags |= SMB_O_CREAT;
160 if (oflags & O_EXCL)
161 posix_flags |= SMB_O_EXCL;
162 if (oflags & O_TRUNC)
163 posix_flags |= SMB_O_TRUNC;
164 if (oflags & O_APPEND)
165 posix_flags |= SMB_O_APPEND;
166 if (oflags & O_SYNC)
167 posix_flags |= SMB_O_SYNC;
168 if (oflags & O_DIRECTORY)
169 posix_flags |= SMB_O_DIRECTORY;
170 if (oflags & O_NOFOLLOW)
171 posix_flags |= SMB_O_NOFOLLOW;
172 if (oflags & O_DIRECT)
173 posix_flags |= SMB_O_DIRECT;
174
175
176 rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode,
177 pnetfid, presp_data, &oplock, full_path,
178 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
179 CIFS_MOUNT_MAP_SPECIAL_CHR);
180 if (rc)
181 goto posix_open_ret;
182
183 if (presp_data->Type == cpu_to_le32(-1))
184 goto posix_open_ret; /* open ok, caller does qpathinfo */
185
186 /* get new inode and set it up */
187 if (!pinode)
188 goto posix_open_ret; /* caller does not need info */
189
190 *pinode = cifs_new_inode(sb, &presp_data->UniqueId);
191
192 /* We do not need to close the file if new_inode fails since
193 the caller will retry qpathinfo as long as inode is null */
194 if (*pinode == NULL)
195 goto posix_open_ret;
196
197 posix_fill_in_inode(*pinode, presp_data, 1);
198
199posix_open_ret:
200 kfree(presp_data);
201 return rc;
202}
203
132static void setup_cifs_dentry(struct cifsTconInfo *tcon, 204static void setup_cifs_dentry(struct cifsTconInfo *tcon,
133 struct dentry *direntry, 205 struct dentry *direntry,
134 struct inode *newinode) 206 struct inode *newinode)
@@ -150,7 +222,14 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
150 int xid; 222 int xid;
151 int create_options = CREATE_NOT_DIR; 223 int create_options = CREATE_NOT_DIR;
152 int oplock = 0; 224 int oplock = 0;
153 /* BB below access is too much for the mknod to request */ 225 int oflags;
226 /*
227 * BB below access is probably too much for mknod to request
228 * but we have to do query and setpathinfo so requesting
229 * less could fail (unless we want to request getatr and setatr
230 * permissions (only). At least for POSIX we do not have to
231 * request so much.
232 */
154 int desiredAccess = GENERIC_READ | GENERIC_WRITE; 233 int desiredAccess = GENERIC_READ | GENERIC_WRITE;
155 __u16 fileHandle; 234 __u16 fileHandle;
156 struct cifs_sb_info *cifs_sb; 235 struct cifs_sb_info *cifs_sb;
@@ -174,13 +253,43 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
174 } 253 }
175 254
176 mode &= ~current->fs->umask; 255 mode &= ~current->fs->umask;
256 if (oplockEnabled)
257 oplock = REQ_OPLOCK;
177 258
178 if (nd && (nd->flags & LOOKUP_OPEN)) { 259 if (nd && (nd->flags & LOOKUP_OPEN))
179 int oflags = nd->intent.open.flags; 260 oflags = nd->intent.open.flags;
261 else
262 oflags = FMODE_READ;
263
264 if (tcon->unix_ext && (tcon->ses->capabilities & CAP_UNIX) &&
265 (CIFS_UNIX_POSIX_PATH_OPS_CAP &
266 le64_to_cpu(tcon->fsUnixInfo.Capability))) {
267 rc = cifs_posix_open(full_path, &newinode, inode->i_sb,
268 mode, oflags, &oplock, &fileHandle, xid);
269 /* EIO could indicate that (posix open) operation is not
270 supported, despite what server claimed in capability
271 negotation. EREMOTE indicates DFS junction, which is not
272 handled in posix open */
273
274 if ((rc == 0) && (newinode == NULL))
275 goto cifs_create_get_file_info; /* query inode info */
276 else if (rc == 0) /* success, no need to query */
277 goto cifs_create_set_dentry;
278 else if ((rc != -EIO) && (rc != -EREMOTE) &&
279 (rc != -EOPNOTSUPP)) /* path not found or net err */
280 goto cifs_create_out;
281 /* else fallthrough to retry, using older open call, this is
282 case where server does not support this SMB level, and
283 falsely claims capability (also get here for DFS case
284 which should be rare for path not covered on files) */
285 }
180 286
287 if (nd && (nd->flags & LOOKUP_OPEN)) {
288 /* if the file is going to stay open, then we
289 need to set the desired access properly */
181 desiredAccess = 0; 290 desiredAccess = 0;
182 if (oflags & FMODE_READ) 291 if (oflags & FMODE_READ)
183 desiredAccess |= GENERIC_READ; 292 desiredAccess |= GENERIC_READ; /* is this too little? */
184 if (oflags & FMODE_WRITE) { 293 if (oflags & FMODE_WRITE) {
185 desiredAccess |= GENERIC_WRITE; 294 desiredAccess |= GENERIC_WRITE;
186 if (!(oflags & FMODE_READ)) 295 if (!(oflags & FMODE_READ))
@@ -199,8 +308,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
199 308
200 /* BB add processing to set equivalent of mode - e.g. via CreateX with 309 /* BB add processing to set equivalent of mode - e.g. via CreateX with
201 ACLs */ 310 ACLs */
202 if (oplockEnabled)
203 oplock = REQ_OPLOCK;
204 311
205 buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); 312 buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
206 if (buf == NULL) { 313 if (buf == NULL) {
@@ -233,116 +340,112 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
233 } 340 }
234 if (rc) { 341 if (rc) {
235 cFYI(1, ("cifs_create returned 0x%x", rc)); 342 cFYI(1, ("cifs_create returned 0x%x", rc));
236 } else { 343 goto cifs_create_out;
237 /* If Open reported that we actually created a file 344 }
238 then we now have to set the mode if possible */ 345
239 if ((tcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) { 346 /* If Open reported that we actually created a file
240 struct cifs_unix_set_info_args args = { 347 then we now have to set the mode if possible */
348 if ((tcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
349 struct cifs_unix_set_info_args args = {
241 .mode = mode, 350 .mode = mode,
242 .ctime = NO_CHANGE_64, 351 .ctime = NO_CHANGE_64,
243 .atime = NO_CHANGE_64, 352 .atime = NO_CHANGE_64,
244 .mtime = NO_CHANGE_64, 353 .mtime = NO_CHANGE_64,
245 .device = 0, 354 .device = 0,
246 }; 355 };
247 356
248 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 357 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
249 args.uid = (__u64) current_fsuid(); 358 args.uid = (__u64) current_fsuid();
250 if (inode->i_mode & S_ISGID) 359 if (inode->i_mode & S_ISGID)
251 args.gid = (__u64) inode->i_gid; 360 args.gid = (__u64) inode->i_gid;
252 else 361 else
253 args.gid = (__u64) current_fsgid(); 362 args.gid = (__u64) current_fsgid();
254 } else {
255 args.uid = NO_CHANGE_64;
256 args.gid = NO_CHANGE_64;
257 }
258 CIFSSMBUnixSetInfo(xid, tcon, full_path, &args,
259 cifs_sb->local_nls,
260 cifs_sb->mnt_cifs_flags &
261 CIFS_MOUNT_MAP_SPECIAL_CHR);
262 } else { 363 } else {
263 /* BB implement mode setting via Windows security 364 args.uid = NO_CHANGE_64;
264 descriptors e.g. */ 365 args.gid = NO_CHANGE_64;
265 /* CIFSSMBWinSetPerms(xid,tcon,path,mode,-1,-1,nls);*/
266
267 /* Could set r/o dos attribute if mode & 0222 == 0 */
268 } 366 }
367 CIFSSMBUnixSetInfo(xid, tcon, full_path, &args,
368 cifs_sb->local_nls,
369 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
370 } else {
371 /* BB implement mode setting via Windows security
372 descriptors e.g. */
373 /* CIFSSMBWinSetPerms(xid,tcon,path,mode,-1,-1,nls);*/
269 374
270 /* server might mask mode so we have to query for it */ 375 /* Could set r/o dos attribute if mode & 0222 == 0 */
271 if (tcon->unix_ext) 376 }
272 rc = cifs_get_inode_info_unix(&newinode, full_path, 377
273 inode->i_sb, xid); 378cifs_create_get_file_info:
274 else { 379 /* server might mask mode so we have to query for it */
275 rc = cifs_get_inode_info(&newinode, full_path, 380 if (tcon->unix_ext)
276 buf, inode->i_sb, xid, 381 rc = cifs_get_inode_info_unix(&newinode, full_path,
277 &fileHandle); 382 inode->i_sb, xid);
278 if (newinode) { 383 else {
279 if (cifs_sb->mnt_cifs_flags & 384 rc = cifs_get_inode_info(&newinode, full_path, buf,
280 CIFS_MOUNT_DYNPERM) 385 inode->i_sb, xid, &fileHandle);
281 newinode->i_mode = mode; 386 if (newinode) {
282 if ((oplock & CIFS_CREATE_ACTION) && 387 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
283 (cifs_sb->mnt_cifs_flags & 388 newinode->i_mode = mode;
284 CIFS_MOUNT_SET_UID)) { 389 if ((oplock & CIFS_CREATE_ACTION) &&
285 newinode->i_uid = current_fsuid(); 390 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)) {
286 if (inode->i_mode & S_ISGID) 391 newinode->i_uid = current_fsuid();
287 newinode->i_gid = 392 if (inode->i_mode & S_ISGID)
288 inode->i_gid; 393 newinode->i_gid = inode->i_gid;
289 else 394 else
290 newinode->i_gid = 395 newinode->i_gid = current_fsgid();
291 current_fsgid();
292 }
293 } 396 }
294 } 397 }
398 }
295 399
296 if (rc != 0) { 400cifs_create_set_dentry:
297 cFYI(1, ("Create worked, get_inode_info failed rc = %d", 401 if (rc == 0)
298 rc)); 402 setup_cifs_dentry(tcon, direntry, newinode);
299 } else 403 else
300 setup_cifs_dentry(tcon, direntry, newinode); 404 cFYI(1, ("Create worked, get_inode_info failed rc = %d", rc));
301 405
302 if ((nd == NULL /* nfsd case - nfs srv does not set nd */) || 406 /* nfsd case - nfs srv does not set nd */
303 (!(nd->flags & LOOKUP_OPEN))) { 407 if ((nd == NULL) || (!(nd->flags & LOOKUP_OPEN))) {
304 /* mknod case - do not leave file open */ 408 /* mknod case - do not leave file open */
305 CIFSSMBClose(xid, tcon, fileHandle); 409 CIFSSMBClose(xid, tcon, fileHandle);
306 } else if (newinode) { 410 } else if (newinode) {
307 struct cifsFileInfo *pCifsFile = 411 struct cifsFileInfo *pCifsFile =
308 kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); 412 kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
309 413
310 if (pCifsFile == NULL) 414 if (pCifsFile == NULL)
311 goto cifs_create_out; 415 goto cifs_create_out;
312 pCifsFile->netfid = fileHandle; 416 pCifsFile->netfid = fileHandle;
313 pCifsFile->pid = current->tgid; 417 pCifsFile->pid = current->tgid;
314 pCifsFile->pInode = newinode; 418 pCifsFile->pInode = newinode;
315 pCifsFile->invalidHandle = false; 419 pCifsFile->invalidHandle = false;
316 pCifsFile->closePend = false; 420 pCifsFile->closePend = false;
317 init_MUTEX(&pCifsFile->fh_sem); 421 init_MUTEX(&pCifsFile->fh_sem);
318 mutex_init(&pCifsFile->lock_mutex); 422 mutex_init(&pCifsFile->lock_mutex);
319 INIT_LIST_HEAD(&pCifsFile->llist); 423 INIT_LIST_HEAD(&pCifsFile->llist);
320 atomic_set(&pCifsFile->wrtPending, 0); 424 atomic_set(&pCifsFile->wrtPending, 0);
321 425
322 /* set the following in open now 426 /* set the following in open now
323 pCifsFile->pfile = file; */ 427 pCifsFile->pfile = file; */
324 write_lock(&GlobalSMBSeslock); 428 write_lock(&GlobalSMBSeslock);
325 list_add(&pCifsFile->tlist, &tcon->openFileList); 429 list_add(&pCifsFile->tlist, &tcon->openFileList);
326 pCifsInode = CIFS_I(newinode); 430 pCifsInode = CIFS_I(newinode);
327 if (pCifsInode) { 431 if (pCifsInode) {
328 /* if readable file instance put first in list*/ 432 /* if readable file instance put first in list*/
329 if (write_only) { 433 if (write_only) {
330 list_add_tail(&pCifsFile->flist, 434 list_add_tail(&pCifsFile->flist,
331 &pCifsInode->openFileList); 435 &pCifsInode->openFileList);
332 } else { 436 } else {
333 list_add(&pCifsFile->flist, 437 list_add(&pCifsFile->flist,
334 &pCifsInode->openFileList); 438 &pCifsInode->openFileList);
335 }
336 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
337 pCifsInode->clientCanCacheAll = true;
338 pCifsInode->clientCanCacheRead = true;
339 cFYI(1, ("Exclusive Oplock inode %p",
340 newinode));
341 } else if ((oplock & 0xF) == OPLOCK_READ)
342 pCifsInode->clientCanCacheRead = true;
343 } 439 }
344 write_unlock(&GlobalSMBSeslock); 440 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
441 pCifsInode->clientCanCacheAll = true;
442 pCifsInode->clientCanCacheRead = true;
443 cFYI(1, ("Exclusive Oplock inode %p",
444 newinode));
445 } else if ((oplock & 0xF) == OPLOCK_READ)
446 pCifsInode->clientCanCacheRead = true;
345 } 447 }
448 write_unlock(&GlobalSMBSeslock);
346 } 449 }
347cifs_create_out: 450cifs_create_out:
348 kfree(buf); 451 kfree(buf);
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index bcf7b5184664..4690a360c855 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -199,6 +199,49 @@ static void fill_fake_finddataunix(FILE_UNIX_BASIC_INFO *pfnd_dat,
199 pfnd_dat->Gid = cpu_to_le64(pinode->i_gid); 199 pfnd_dat->Gid = cpu_to_le64(pinode->i_gid);
200} 200}
201 201
202/**
203 * cifs_new inode - create new inode, initialize, and hash it
204 * @sb - pointer to superblock
205 * @inum - if valid pointer and serverino is enabled, replace i_ino with val
206 *
207 * Create a new inode, initialize it for CIFS and hash it. Returns the new
208 * inode or NULL if one couldn't be allocated.
209 *
210 * If the share isn't mounted with "serverino" or inum is a NULL pointer then
211 * we'll just use the inode number assigned by new_inode(). Note that this can
212 * mean i_ino collisions since the i_ino assigned by new_inode is not
213 * guaranteed to be unique.
214 */
215struct inode *
216cifs_new_inode(struct super_block *sb, __u64 *inum)
217{
218 struct inode *inode;
219
220 inode = new_inode(sb);
221 if (inode == NULL)
222 return NULL;
223
224 /*
225 * BB: Is i_ino == 0 legal? Here, we assume that it is. If it isn't we
226 * stop passing inum as ptr. Are there sanity checks we can use to
227 * ensure that the server is really filling in that field? Also,
228 * if serverino is disabled, perhaps we should be using iunique()?
229 */
230 if (inum && (CIFS_SB(sb)->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM))
231 inode->i_ino = (unsigned long) *inum;
232
233 /*
234 * must set this here instead of cifs_alloc_inode since VFS will
235 * clobber i_flags
236 */
237 if (sb->s_flags & MS_NOATIME)
238 inode->i_flags |= S_NOATIME | S_NOCMTIME;
239
240 insert_inode_hash(inode);
241
242 return inode;
243}
244
202int cifs_get_inode_info_unix(struct inode **pinode, 245int cifs_get_inode_info_unix(struct inode **pinode,
203 const unsigned char *full_path, struct super_block *sb, int xid) 246 const unsigned char *full_path, struct super_block *sb, int xid)
204{ 247{
@@ -233,22 +276,11 @@ int cifs_get_inode_info_unix(struct inode **pinode,
233 276
234 /* get new inode */ 277 /* get new inode */
235 if (*pinode == NULL) { 278 if (*pinode == NULL) {
236 *pinode = new_inode(sb); 279 *pinode = cifs_new_inode(sb, &find_data.UniqueId);
237 if (*pinode == NULL) { 280 if (*pinode == NULL) {
238 rc = -ENOMEM; 281 rc = -ENOMEM;
239 goto cgiiu_exit; 282 goto cgiiu_exit;
240 } 283 }
241 /* Is an i_ino of zero legal? */
242 /* note ino incremented to unique num in new_inode */
243 /* Are there sanity checks we can use to ensure that
244 the server is really filling in that field? */
245 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
246 (*pinode)->i_ino = (unsigned long)find_data.UniqueId;
247
248 if (sb->s_flags & MS_NOATIME)
249 (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME;
250
251 insert_inode_hash(*pinode);
252 } 284 }
253 285
254 inode = *pinode; 286 inode = *pinode;
@@ -465,11 +497,9 @@ int cifs_get_inode_info(struct inode **pinode,
465 497
466 /* get new inode */ 498 /* get new inode */
467 if (*pinode == NULL) { 499 if (*pinode == NULL) {
468 *pinode = new_inode(sb); 500 __u64 inode_num;
469 if (*pinode == NULL) { 501 __u64 *pinum = &inode_num;
470 rc = -ENOMEM; 502
471 goto cgii_exit;
472 }
473 /* Is an i_ino of zero legal? Can we use that to check 503 /* Is an i_ino of zero legal? Can we use that to check
474 if the server supports returning inode numbers? Are 504 if the server supports returning inode numbers? Are
475 there other sanity checks we can use to ensure that 505 there other sanity checks we can use to ensure that
@@ -486,22 +516,26 @@ int cifs_get_inode_info(struct inode **pinode,
486 516
487 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 517 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
488 int rc1 = 0; 518 int rc1 = 0;
489 __u64 inode_num;
490 519
491 rc1 = CIFSGetSrvInodeNumber(xid, pTcon, 520 rc1 = CIFSGetSrvInodeNumber(xid, pTcon,
492 full_path, &inode_num, 521 full_path, pinum,
493 cifs_sb->local_nls, 522 cifs_sb->local_nls,
494 cifs_sb->mnt_cifs_flags & 523 cifs_sb->mnt_cifs_flags &
495 CIFS_MOUNT_MAP_SPECIAL_CHR); 524 CIFS_MOUNT_MAP_SPECIAL_CHR);
496 if (rc1) { 525 if (rc1) {
497 cFYI(1, ("GetSrvInodeNum rc %d", rc1)); 526 cFYI(1, ("GetSrvInodeNum rc %d", rc1));
527 pinum = NULL;
498 /* BB EOPNOSUPP disable SERVER_INUM? */ 528 /* BB EOPNOSUPP disable SERVER_INUM? */
499 } else /* do we need cast or hash to ino? */ 529 }
500 (*pinode)->i_ino = inode_num; 530 } else {
501 } /* else ino incremented to unique num in new_inode*/ 531 pinum = NULL;
502 if (sb->s_flags & MS_NOATIME) 532 }
503 (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; 533
504 insert_inode_hash(*pinode); 534 *pinode = cifs_new_inode(sb, pinum);
535 if (*pinode == NULL) {
536 rc = -ENOMEM;
537 goto cgii_exit;
538 }
505 } 539 }
506 inode = *pinode; 540 inode = *pinode;
507 cifsInfo = CIFS_I(inode); 541 cifsInfo = CIFS_I(inode);
@@ -621,7 +655,7 @@ static const struct inode_operations cifs_ipc_inode_ops = {
621 .lookup = cifs_lookup, 655 .lookup = cifs_lookup,
622}; 656};
623 657
624static char *build_path_to_root(struct cifs_sb_info *cifs_sb) 658char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)
625{ 659{
626 int pplen = cifs_sb->prepathlen; 660 int pplen = cifs_sb->prepathlen;
627 int dfsplen; 661 int dfsplen;
@@ -678,7 +712,7 @@ struct inode *cifs_iget(struct super_block *sb, unsigned long ino)
678 return inode; 712 return inode;
679 713
680 cifs_sb = CIFS_SB(inode->i_sb); 714 cifs_sb = CIFS_SB(inode->i_sb);
681 full_path = build_path_to_root(cifs_sb); 715 full_path = cifs_build_path_to_root(cifs_sb);
682 if (full_path == NULL) 716 if (full_path == NULL)
683 return ERR_PTR(-ENOMEM); 717 return ERR_PTR(-ENOMEM);
684 718
@@ -1017,7 +1051,7 @@ out_reval:
1017 return rc; 1051 return rc;
1018} 1052}
1019 1053
1020static void posix_fill_in_inode(struct inode *tmp_inode, 1054void posix_fill_in_inode(struct inode *tmp_inode,
1021 FILE_UNIX_BASIC_INFO *pData, int isNewInode) 1055 FILE_UNIX_BASIC_INFO *pData, int isNewInode)
1022{ 1056{
1023 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); 1057 struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode);
@@ -1114,24 +1148,14 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
1114 else 1148 else
1115 direntry->d_op = &cifs_dentry_ops; 1149 direntry->d_op = &cifs_dentry_ops;
1116 1150
1117 newinode = new_inode(inode->i_sb); 1151 newinode = cifs_new_inode(inode->i_sb,
1152 &pInfo->UniqueId);
1118 if (newinode == NULL) { 1153 if (newinode == NULL) {
1119 kfree(pInfo); 1154 kfree(pInfo);
1120 goto mkdir_get_info; 1155 goto mkdir_get_info;
1121 } 1156 }
1122 1157
1123 /* Is an i_ino of zero legal? */
1124 /* Are there sanity checks we can use to ensure that
1125 the server is really filling in that field? */
1126 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
1127 newinode->i_ino =
1128 (unsigned long)pInfo->UniqueId;
1129 } /* note ino incremented to unique num in new_inode */
1130 if (inode->i_sb->s_flags & MS_NOATIME)
1131 newinode->i_flags |= S_NOATIME | S_NOCMTIME;
1132 newinode->i_nlink = 2; 1158 newinode->i_nlink = 2;
1133
1134 insert_inode_hash(newinode);
1135 d_instantiate(direntry, newinode); 1159 d_instantiate(direntry, newinode);
1136 1160
1137 /* we already checked in POSIXCreate whether 1161 /* we already checked in POSIXCreate whether
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 9f51f9bf0292..c2c01ff4c32c 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -56,35 +56,34 @@ static inline void dump_cifs_file_struct(struct file *file, char *label)
56} 56}
57#endif /* DEBUG2 */ 57#endif /* DEBUG2 */
58 58
59/* Returns one if new inode created (which therefore needs to be hashed) */ 59/* Returns 1 if new inode created, 2 if both dentry and inode were */
60/* Might check in the future if inode number changed so we can rehash inode */ 60/* Might check in the future if inode number changed so we can rehash inode */
61static int construct_dentry(struct qstr *qstring, struct file *file, 61static int
62 struct inode **ptmp_inode, struct dentry **pnew_dentry) 62construct_dentry(struct qstr *qstring, struct file *file,
63 struct inode **ptmp_inode, struct dentry **pnew_dentry,
64 __u64 *inum)
63{ 65{
64 struct dentry *tmp_dentry; 66 struct dentry *tmp_dentry = NULL;
65 struct cifs_sb_info *cifs_sb; 67 struct super_block *sb = file->f_path.dentry->d_sb;
66 struct cifsTconInfo *pTcon;
67 int rc = 0; 68 int rc = 0;
68 69
69 cFYI(1, ("For %s", qstring->name)); 70 cFYI(1, ("For %s", qstring->name));
70 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
71 pTcon = cifs_sb->tcon;
72 71
73 qstring->hash = full_name_hash(qstring->name, qstring->len); 72 qstring->hash = full_name_hash(qstring->name, qstring->len);
74 tmp_dentry = d_lookup(file->f_path.dentry, qstring); 73 tmp_dentry = d_lookup(file->f_path.dentry, qstring);
75 if (tmp_dentry) { 74 if (tmp_dentry) {
75 /* BB: overwrite old name? i.e. tmp_dentry->d_name and
76 * tmp_dentry->d_name.len??
77 */
76 cFYI(0, ("existing dentry with inode 0x%p", 78 cFYI(0, ("existing dentry with inode 0x%p",
77 tmp_dentry->d_inode)); 79 tmp_dentry->d_inode));
78 *ptmp_inode = tmp_dentry->d_inode; 80 *ptmp_inode = tmp_dentry->d_inode;
79/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/
80 if (*ptmp_inode == NULL) { 81 if (*ptmp_inode == NULL) {
81 *ptmp_inode = new_inode(file->f_path.dentry->d_sb); 82 *ptmp_inode = cifs_new_inode(sb, inum);
82 if (*ptmp_inode == NULL) 83 if (*ptmp_inode == NULL)
83 return rc; 84 return rc;
84 rc = 1; 85 rc = 1;
85 } 86 }
86 if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
87 (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
88 } else { 87 } else {
89 tmp_dentry = d_alloc(file->f_path.dentry, qstring); 88 tmp_dentry = d_alloc(file->f_path.dentry, qstring);
90 if (tmp_dentry == NULL) { 89 if (tmp_dentry == NULL) {
@@ -93,15 +92,14 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
93 return rc; 92 return rc;
94 } 93 }
95 94
96 *ptmp_inode = new_inode(file->f_path.dentry->d_sb); 95 if (CIFS_SB(sb)->tcon->nocase)
97 if (pTcon->nocase)
98 tmp_dentry->d_op = &cifs_ci_dentry_ops; 96 tmp_dentry->d_op = &cifs_ci_dentry_ops;
99 else 97 else
100 tmp_dentry->d_op = &cifs_dentry_ops; 98 tmp_dentry->d_op = &cifs_dentry_ops;
99
100 *ptmp_inode = cifs_new_inode(sb, inum);
101 if (*ptmp_inode == NULL) 101 if (*ptmp_inode == NULL)
102 return rc; 102 return rc;
103 if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
104 (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
105 rc = 2; 103 rc = 2;
106 } 104 }
107 105
@@ -822,7 +820,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
822/* inode num, inode type and filename returned */ 820/* inode num, inode type and filename returned */
823static int cifs_get_name_from_search_buf(struct qstr *pqst, 821static int cifs_get_name_from_search_buf(struct qstr *pqst,
824 char *current_entry, __u16 level, unsigned int unicode, 822 char *current_entry, __u16 level, unsigned int unicode,
825 struct cifs_sb_info *cifs_sb, int max_len, ino_t *pinum) 823 struct cifs_sb_info *cifs_sb, int max_len, __u64 *pinum)
826{ 824{
827 int rc = 0; 825 int rc = 0;
828 unsigned int len = 0; 826 unsigned int len = 0;
@@ -842,9 +840,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
842 len = strnlen(filename, PATH_MAX); 840 len = strnlen(filename, PATH_MAX);
843 } 841 }
844 842
845 /* BB fixme - hash low and high 32 bits if not 64 bit arch BB */ 843 *pinum = pFindData->UniqueId;
846 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
847 *pinum = pFindData->UniqueId;
848 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) { 844 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
849 FILE_DIRECTORY_INFO *pFindData = 845 FILE_DIRECTORY_INFO *pFindData =
850 (FILE_DIRECTORY_INFO *)current_entry; 846 (FILE_DIRECTORY_INFO *)current_entry;
@@ -907,7 +903,7 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
907 struct qstr qstring; 903 struct qstr qstring;
908 struct cifsFileInfo *pCifsF; 904 struct cifsFileInfo *pCifsF;
909 unsigned int obj_type; 905 unsigned int obj_type;
910 ino_t inum; 906 __u64 inum;
911 struct cifs_sb_info *cifs_sb; 907 struct cifs_sb_info *cifs_sb;
912 struct inode *tmp_inode; 908 struct inode *tmp_inode;
913 struct dentry *tmp_dentry; 909 struct dentry *tmp_dentry;
@@ -940,20 +936,18 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
940 if (rc) 936 if (rc)
941 return rc; 937 return rc;
942 938
943 rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry); 939 /* only these two infolevels return valid inode numbers */
940 if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX ||
941 pCifsF->srch_inf.info_level == SMB_FIND_FILE_ID_FULL_DIR_INFO)
942 rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry,
943 &inum);
944 else
945 rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry,
946 NULL);
947
944 if ((tmp_inode == NULL) || (tmp_dentry == NULL)) 948 if ((tmp_inode == NULL) || (tmp_dentry == NULL))
945 return -ENOMEM; 949 return -ENOMEM;
946 950
947 if (rc) {
948 /* inode created, we need to hash it with right inode number */
949 if (inum != 0) {
950 /* BB fixme - hash the 2 32 quantities bits together if
951 * necessary BB */
952 tmp_inode->i_ino = inum;
953 }
954 insert_inode_hash(tmp_inode);
955 }
956
957 /* we pass in rc below, indicating whether it is a new inode, 951 /* we pass in rc below, indicating whether it is a new inode,
958 so we can figure out whether to invalidate the inode cached 952 so we can figure out whether to invalidate the inode cached
959 data if the file has changed */ 953 data if the file has changed */
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 5f22de7b79a9..5c68b4282be9 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -34,15 +34,99 @@
34extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, 34extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
35 unsigned char *p24); 35 unsigned char *p24);
36 36
37/* Checks if this is the first smb session to be reconnected after
38 the socket has been reestablished (so we know whether to use vc 0).
39 Called while holding the cifs_tcp_ses_lock, so do not block */
40static bool is_first_ses_reconnect(struct cifsSesInfo *ses)
41{
42 struct list_head *tmp;
43 struct cifsSesInfo *tmp_ses;
44
45 list_for_each(tmp, &ses->server->smb_ses_list) {
46 tmp_ses = list_entry(tmp, struct cifsSesInfo,
47 smb_ses_list);
48 if (tmp_ses->need_reconnect == false)
49 return false;
50 }
51 /* could not find a session that was already connected,
52 this must be the first one we are reconnecting */
53 return true;
54}
55
56/*
57 * vc number 0 is treated specially by some servers, and should be the
58 * first one we request. After that we can use vcnumbers up to maxvcs,
59 * one for each smb session (some Windows versions set maxvcs incorrectly
60 * so maxvc=1 can be ignored). If we have too many vcs, we can reuse
61 * any vc but zero (some servers reset the connection on vcnum zero)
62 *
63 */
64static __le16 get_next_vcnum(struct cifsSesInfo *ses)
65{
66 __u16 vcnum = 0;
67 struct list_head *tmp;
68 struct cifsSesInfo *tmp_ses;
69 __u16 max_vcs = ses->server->max_vcs;
70 __u16 i;
71 int free_vc_found = 0;
72
73 /* Quoting the MS-SMB specification: "Windows-based SMB servers set this
74 field to one but do not enforce this limit, which allows an SMB client
75 to establish more virtual circuits than allowed by this value ... but
76 other server implementations can enforce this limit." */
77 if (max_vcs < 2)
78 max_vcs = 0xFFFF;
79
80 write_lock(&cifs_tcp_ses_lock);
81 if ((ses->need_reconnect) && is_first_ses_reconnect(ses))
82 goto get_vc_num_exit; /* vcnum will be zero */
83 for (i = ses->server->srv_count - 1; i < max_vcs; i++) {
84 if (i == 0) /* this is the only connection, use vc 0 */
85 break;
86
87 free_vc_found = 1;
88
89 list_for_each(tmp, &ses->server->smb_ses_list) {
90 tmp_ses = list_entry(tmp, struct cifsSesInfo,
91 smb_ses_list);
92 if (tmp_ses->vcnum == i) {
93 free_vc_found = 0;
94 break; /* found duplicate, try next vcnum */
95 }
96 }
97 if (free_vc_found)
98 break; /* we found a vcnumber that will work - use it */
99 }
100
101 if (i == 0)
102 vcnum = 0; /* for most common case, ie if one smb session, use
103 vc zero. Also for case when no free vcnum, zero
104 is safest to send (some clients only send zero) */
105 else if (free_vc_found == 0)
106 vcnum = 1; /* we can not reuse vc=0 safely, since some servers
107 reset all uids on that, but 1 is ok. */
108 else
109 vcnum = i;
110 ses->vcnum = vcnum;
111get_vc_num_exit:
112 write_unlock(&cifs_tcp_ses_lock);
113
114 return le16_to_cpu(vcnum);
115}
116
37static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB) 117static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
38{ 118{
39 __u32 capabilities = 0; 119 __u32 capabilities = 0;
40 120
41 /* init fields common to all four types of SessSetup */ 121 /* init fields common to all four types of SessSetup */
42 /* note that header is initialized to zero in header_assemble */ 122 /* Note that offsets for first seven fields in req struct are same */
123 /* in CIFS Specs so does not matter which of 3 forms of struct */
124 /* that we use in next few lines */
125 /* Note that header is initialized to zero in header_assemble */
43 pSMB->req.AndXCommand = 0xFF; 126 pSMB->req.AndXCommand = 0xFF;
44 pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf); 127 pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
45 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); 128 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
129 pSMB->req.VcNumber = get_next_vcnum(ses);
46 130
47 /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */ 131 /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
48 132
@@ -71,7 +155,6 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB)
71 if (ses->capabilities & CAP_UNIX) 155 if (ses->capabilities & CAP_UNIX)
72 capabilities |= CAP_UNIX; 156 capabilities |= CAP_UNIX;
73 157
74 /* BB check whether to init vcnum BB */
75 return capabilities; 158 return capabilities;
76} 159}
77 160
@@ -228,7 +311,7 @@ static int decode_unicode_ssetup(char **pbcc_area, int bleft,
228 311
229 kfree(ses->serverOS); 312 kfree(ses->serverOS);
230 /* UTF-8 string will not grow more than four times as big as UCS-16 */ 313 /* UTF-8 string will not grow more than four times as big as UCS-16 */
231 ses->serverOS = kzalloc(4 * len, GFP_KERNEL); 314 ses->serverOS = kzalloc((4 * len) + 2 /* trailing null */, GFP_KERNEL);
232 if (ses->serverOS != NULL) 315 if (ses->serverOS != NULL)
233 cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, nls_cp); 316 cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, nls_cp);
234 data += 2 * (len + 1); 317 data += 2 * (len + 1);
@@ -241,7 +324,7 @@ static int decode_unicode_ssetup(char **pbcc_area, int bleft,
241 return rc; 324 return rc;
242 325
243 kfree(ses->serverNOS); 326 kfree(ses->serverNOS);
244 ses->serverNOS = kzalloc(4 * len, GFP_KERNEL); /* BB this is wrong length FIXME BB */ 327 ses->serverNOS = kzalloc((4 * len) + 2 /* trailing null */, GFP_KERNEL);
245 if (ses->serverNOS != NULL) { 328 if (ses->serverNOS != NULL) {
246 cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len, 329 cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len,
247 nls_cp); 330 nls_cp);
diff --git a/fs/compat.c b/fs/compat.c
index 65a070e705ab..d0145ca27572 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1407,7 +1407,7 @@ int compat_do_execve(char * filename,
1407 bprm->cred = prepare_exec_creds(); 1407 bprm->cred = prepare_exec_creds();
1408 if (!bprm->cred) 1408 if (!bprm->cred)
1409 goto out_unlock; 1409 goto out_unlock;
1410 check_unsafe_exec(bprm); 1410 check_unsafe_exec(bprm, current->files);
1411 1411
1412 file = open_exec(filename); 1412 file = open_exec(filename);
1413 retval = PTR_ERR(file); 1413 retval = PTR_ERR(file);
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index c8f8d5904f5e..39bd4d38e889 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -785,7 +785,7 @@ static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
785 785
786 if (copy_in_user(&sgio->status, &sgio32->status, 786 if (copy_in_user(&sgio->status, &sgio32->status,
787 (4 * sizeof(unsigned char)) + 787 (4 * sizeof(unsigned char)) +
788 (2 * sizeof(unsigned (short))) + 788 (2 * sizeof(unsigned short)) +
789 (3 * sizeof(int)))) 789 (3 * sizeof(int))))
790 return -EFAULT; 790 return -EFAULT;
791 791
@@ -1938,6 +1938,8 @@ ULONG_IOCTL(SET_BITMAP_FILE)
1938/* Big K */ 1938/* Big K */
1939COMPATIBLE_IOCTL(PIO_FONT) 1939COMPATIBLE_IOCTL(PIO_FONT)
1940COMPATIBLE_IOCTL(GIO_FONT) 1940COMPATIBLE_IOCTL(GIO_FONT)
1941COMPATIBLE_IOCTL(PIO_CMAP)
1942COMPATIBLE_IOCTL(GIO_CMAP)
1941ULONG_IOCTL(KDSIGACCEPT) 1943ULONG_IOCTL(KDSIGACCEPT)
1942COMPATIBLE_IOCTL(KDGETKEYCODE) 1944COMPATIBLE_IOCTL(KDGETKEYCODE)
1943COMPATIBLE_IOCTL(KDSETKEYCODE) 1945COMPATIBLE_IOCTL(KDSETKEYCODE)
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index c01e043670e2..f6caeb1d1106 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1716,7 +1716,7 @@ static int ecryptfs_copy_filename(char **copied_name, size_t *copied_name_size,
1716{ 1716{
1717 int rc = 0; 1717 int rc = 0;
1718 1718
1719 (*copied_name) = kmalloc((name_size + 2), GFP_KERNEL); 1719 (*copied_name) = kmalloc((name_size + 1), GFP_KERNEL);
1720 if (!(*copied_name)) { 1720 if (!(*copied_name)) {
1721 rc = -ENOMEM; 1721 rc = -ENOMEM;
1722 goto out; 1722 goto out;
@@ -1726,7 +1726,7 @@ static int ecryptfs_copy_filename(char **copied_name, size_t *copied_name_size,
1726 * in printing out the 1726 * in printing out the
1727 * string in debug 1727 * string in debug
1728 * messages */ 1728 * messages */
1729 (*copied_name_size) = (name_size + 1); 1729 (*copied_name_size) = name_size;
1730out: 1730out:
1731 return rc; 1731 return rc;
1732} 1732}
diff --git a/fs/exec.c b/fs/exec.c
index 0dd60a01f1b4..929b58004b7e 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1049,16 +1049,32 @@ EXPORT_SYMBOL(install_exec_creds);
1049 * - the caller must hold current->cred_exec_mutex to protect against 1049 * - the caller must hold current->cred_exec_mutex to protect against
1050 * PTRACE_ATTACH 1050 * PTRACE_ATTACH
1051 */ 1051 */
1052void check_unsafe_exec(struct linux_binprm *bprm) 1052void check_unsafe_exec(struct linux_binprm *bprm, struct files_struct *files)
1053{ 1053{
1054 struct task_struct *p = current; 1054 struct task_struct *p = current, *t;
1055 unsigned long flags;
1056 unsigned n_fs, n_files, n_sighand;
1055 1057
1056 bprm->unsafe = tracehook_unsafe_exec(p); 1058 bprm->unsafe = tracehook_unsafe_exec(p);
1057 1059
1058 if (atomic_read(&p->fs->count) > 1 || 1060 n_fs = 1;
1059 atomic_read(&p->files->count) > 1 || 1061 n_files = 1;
1060 atomic_read(&p->sighand->count) > 1) 1062 n_sighand = 1;
1063 lock_task_sighand(p, &flags);
1064 for (t = next_thread(p); t != p; t = next_thread(t)) {
1065 if (t->fs == p->fs)
1066 n_fs++;
1067 if (t->files == files)
1068 n_files++;
1069 n_sighand++;
1070 }
1071
1072 if (atomic_read(&p->fs->count) > n_fs ||
1073 atomic_read(&p->files->count) > n_files ||
1074 atomic_read(&p->sighand->count) > n_sighand)
1061 bprm->unsafe |= LSM_UNSAFE_SHARE; 1075 bprm->unsafe |= LSM_UNSAFE_SHARE;
1076
1077 unlock_task_sighand(p, &flags);
1062} 1078}
1063 1079
1064/* 1080/*
@@ -1273,7 +1289,7 @@ int do_execve(char * filename,
1273 bprm->cred = prepare_exec_creds(); 1289 bprm->cred = prepare_exec_creds();
1274 if (!bprm->cred) 1290 if (!bprm->cred)
1275 goto out_unlock; 1291 goto out_unlock;
1276 check_unsafe_exec(bprm); 1292 check_unsafe_exec(bprm, displaced);
1277 1293
1278 file = open_exec(filename); 1294 file = open_exec(filename);
1279 retval = PTR_ERR(file); 1295 retval = PTR_ERR(file);
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index da8bdeaa2e6d..7c6e3606f0ec 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1185,9 +1185,12 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
1185 es = sbi->s_es; 1185 es = sbi->s_es;
1186 if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) != 1186 if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
1187 (old_mount_opt & EXT2_MOUNT_XIP)) && 1187 (old_mount_opt & EXT2_MOUNT_XIP)) &&
1188 invalidate_inodes(sb)) 1188 invalidate_inodes(sb)) {
1189 ext2_warning(sb, __func__, "busy inodes while remounting "\ 1189 ext2_warning(sb, __func__, "refusing change of xip flag "
1190 "xip remain in cache (no functional problem)"); 1190 "with busy inodes while remounting");
1191 sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
1192 sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
1193 }
1191 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) 1194 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
1192 return 0; 1195 return 0;
1193 if (*flags & MS_RDONLY) { 1196 if (*flags & MS_RDONLY) {
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index b70d90e08a3c..4a970411a458 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2428,12 +2428,13 @@ static void ext3_write_super (struct super_block * sb)
2428 2428
2429static int ext3_sync_fs(struct super_block *sb, int wait) 2429static int ext3_sync_fs(struct super_block *sb, int wait)
2430{ 2430{
2431 sb->s_dirt = 0; 2431 tid_t target;
2432 if (wait)
2433 ext3_force_commit(sb);
2434 else
2435 journal_start_commit(EXT3_SB(sb)->s_journal, NULL);
2436 2432
2433 sb->s_dirt = 0;
2434 if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) {
2435 if (wait)
2436 log_wait_commit(EXT3_SB(sb)->s_journal, target);
2437 }
2437 return 0; 2438 return 0;
2438} 2439}
2439 2440
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index aafc9eba1c25..b0c87dce66a3 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -868,7 +868,7 @@ static inline unsigned ext4_rec_len_from_disk(__le16 dlen)
868{ 868{
869 unsigned len = le16_to_cpu(dlen); 869 unsigned len = le16_to_cpu(dlen);
870 870
871 if (len == EXT4_MAX_REC_LEN) 871 if (len == EXT4_MAX_REC_LEN || len == 0)
872 return 1 << 16; 872 return 1 << 16;
873 return len; 873 return len;
874} 874}
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 03ba20be1329..cbd2ca99d113 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -47,8 +47,10 @@
47static inline int ext4_begin_ordered_truncate(struct inode *inode, 47static inline int ext4_begin_ordered_truncate(struct inode *inode,
48 loff_t new_size) 48 loff_t new_size)
49{ 49{
50 return jbd2_journal_begin_ordered_truncate(&EXT4_I(inode)->jinode, 50 return jbd2_journal_begin_ordered_truncate(
51 new_size); 51 EXT4_SB(inode->i_sb)->s_journal,
52 &EXT4_I(inode)->jinode,
53 new_size);
52} 54}
53 55
54static void ext4_invalidatepage(struct page *page, unsigned long offset); 56static void ext4_invalidatepage(struct page *page, unsigned long offset);
@@ -2437,6 +2439,7 @@ static int ext4_da_writepages(struct address_space *mapping,
2437 int no_nrwrite_index_update; 2439 int no_nrwrite_index_update;
2438 int pages_written = 0; 2440 int pages_written = 0;
2439 long pages_skipped; 2441 long pages_skipped;
2442 int range_cyclic, cycled = 1, io_done = 0;
2440 int needed_blocks, ret = 0, nr_to_writebump = 0; 2443 int needed_blocks, ret = 0, nr_to_writebump = 0;
2441 struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb); 2444 struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb);
2442 2445
@@ -2488,9 +2491,15 @@ static int ext4_da_writepages(struct address_space *mapping,
2488 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) 2491 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
2489 range_whole = 1; 2492 range_whole = 1;
2490 2493
2491 if (wbc->range_cyclic) 2494 range_cyclic = wbc->range_cyclic;
2495 if (wbc->range_cyclic) {
2492 index = mapping->writeback_index; 2496 index = mapping->writeback_index;
2493 else 2497 if (index)
2498 cycled = 0;
2499 wbc->range_start = index << PAGE_CACHE_SHIFT;
2500 wbc->range_end = LLONG_MAX;
2501 wbc->range_cyclic = 0;
2502 } else
2494 index = wbc->range_start >> PAGE_CACHE_SHIFT; 2503 index = wbc->range_start >> PAGE_CACHE_SHIFT;
2495 2504
2496 mpd.wbc = wbc; 2505 mpd.wbc = wbc;
@@ -2504,6 +2513,7 @@ static int ext4_da_writepages(struct address_space *mapping,
2504 wbc->no_nrwrite_index_update = 1; 2513 wbc->no_nrwrite_index_update = 1;
2505 pages_skipped = wbc->pages_skipped; 2514 pages_skipped = wbc->pages_skipped;
2506 2515
2516retry:
2507 while (!ret && wbc->nr_to_write > 0) { 2517 while (!ret && wbc->nr_to_write > 0) {
2508 2518
2509 /* 2519 /*
@@ -2546,6 +2556,7 @@ static int ext4_da_writepages(struct address_space *mapping,
2546 pages_written += mpd.pages_written; 2556 pages_written += mpd.pages_written;
2547 wbc->pages_skipped = pages_skipped; 2557 wbc->pages_skipped = pages_skipped;
2548 ret = 0; 2558 ret = 0;
2559 io_done = 1;
2549 } else if (wbc->nr_to_write) 2560 } else if (wbc->nr_to_write)
2550 /* 2561 /*
2551 * There is no more writeout needed 2562 * There is no more writeout needed
@@ -2554,6 +2565,13 @@ static int ext4_da_writepages(struct address_space *mapping,
2554 */ 2565 */
2555 break; 2566 break;
2556 } 2567 }
2568 if (!io_done && !cycled) {
2569 cycled = 1;
2570 index = 0;
2571 wbc->range_start = index << PAGE_CACHE_SHIFT;
2572 wbc->range_end = mapping->writeback_index - 1;
2573 goto retry;
2574 }
2557 if (pages_skipped != wbc->pages_skipped) 2575 if (pages_skipped != wbc->pages_skipped)
2558 printk(KERN_EMERG "This should not happen leaving %s " 2576 printk(KERN_EMERG "This should not happen leaving %s "
2559 "with nr_to_write = %ld ret = %d\n", 2577 "with nr_to_write = %ld ret = %d\n",
@@ -2561,6 +2579,7 @@ static int ext4_da_writepages(struct address_space *mapping,
2561 2579
2562 /* Update index */ 2580 /* Update index */
2563 index += pages_written; 2581 index += pages_written;
2582 wbc->range_cyclic = range_cyclic;
2564 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) 2583 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
2565 /* 2584 /*
2566 * set the writeback_index so that range_cyclic 2585 * set the writeback_index so that range_cyclic
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index deba54f6cbed..4415beeb0b62 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3693,6 +3693,8 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
3693 pa->pa_free = pa->pa_len; 3693 pa->pa_free = pa->pa_len;
3694 atomic_set(&pa->pa_count, 1); 3694 atomic_set(&pa->pa_count, 1);
3695 spin_lock_init(&pa->pa_lock); 3695 spin_lock_init(&pa->pa_lock);
3696 INIT_LIST_HEAD(&pa->pa_inode_list);
3697 INIT_LIST_HEAD(&pa->pa_group_list);
3696 pa->pa_deleted = 0; 3698 pa->pa_deleted = 0;
3697 pa->pa_linear = 0; 3699 pa->pa_linear = 0;
3698 3700
@@ -3755,6 +3757,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
3755 atomic_set(&pa->pa_count, 1); 3757 atomic_set(&pa->pa_count, 1);
3756 spin_lock_init(&pa->pa_lock); 3758 spin_lock_init(&pa->pa_lock);
3757 INIT_LIST_HEAD(&pa->pa_inode_list); 3759 INIT_LIST_HEAD(&pa->pa_inode_list);
3760 INIT_LIST_HEAD(&pa->pa_group_list);
3758 pa->pa_deleted = 0; 3761 pa->pa_deleted = 0;
3759 pa->pa_linear = 1; 3762 pa->pa_linear = 1;
3760 3763
@@ -4476,23 +4479,26 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
4476 pa->pa_free -= ac->ac_b_ex.fe_len; 4479 pa->pa_free -= ac->ac_b_ex.fe_len;
4477 pa->pa_len -= ac->ac_b_ex.fe_len; 4480 pa->pa_len -= ac->ac_b_ex.fe_len;
4478 spin_unlock(&pa->pa_lock); 4481 spin_unlock(&pa->pa_lock);
4479 /*
4480 * We want to add the pa to the right bucket.
4481 * Remove it from the list and while adding
4482 * make sure the list to which we are adding
4483 * doesn't grow big.
4484 */
4485 if (likely(pa->pa_free)) {
4486 spin_lock(pa->pa_obj_lock);
4487 list_del_rcu(&pa->pa_inode_list);
4488 spin_unlock(pa->pa_obj_lock);
4489 ext4_mb_add_n_trim(ac);
4490 }
4491 } 4482 }
4492 ext4_mb_put_pa(ac, ac->ac_sb, pa);
4493 } 4483 }
4494 if (ac->alloc_semp) 4484 if (ac->alloc_semp)
4495 up_read(ac->alloc_semp); 4485 up_read(ac->alloc_semp);
4486 if (pa) {
4487 /*
4488 * We want to add the pa to the right bucket.
4489 * Remove it from the list and while adding
4490 * make sure the list to which we are adding
4491 * doesn't grow big. We need to release
4492 * alloc_semp before calling ext4_mb_add_n_trim()
4493 */
4494 if (pa->pa_linear && likely(pa->pa_free)) {
4495 spin_lock(pa->pa_obj_lock);
4496 list_del_rcu(&pa->pa_inode_list);
4497 spin_unlock(pa->pa_obj_lock);
4498 ext4_mb_add_n_trim(ac);
4499 }
4500 ext4_mb_put_pa(ac, ac->ac_sb, pa);
4501 }
4496 if (ac->ac_bitmap_page) 4502 if (ac->ac_bitmap_page)
4497 page_cache_release(ac->ac_bitmap_page); 4503 page_cache_release(ac->ac_bitmap_page);
4498 if (ac->ac_buddy_page) 4504 if (ac->ac_buddy_page)
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 734abca25e35..fe64d9f79852 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -481,7 +481,7 @@ int ext4_ext_migrate(struct inode *inode)
481 + 1); 481 + 1);
482 if (IS_ERR(handle)) { 482 if (IS_ERR(handle)) {
483 retval = PTR_ERR(handle); 483 retval = PTR_ERR(handle);
484 goto err_out; 484 return retval;
485 } 485 }
486 tmp_inode = ext4_new_inode(handle, 486 tmp_inode = ext4_new_inode(handle,
487 inode->i_sb->s_root->d_inode, 487 inode->i_sb->s_root->d_inode,
@@ -489,8 +489,7 @@ int ext4_ext_migrate(struct inode *inode)
489 if (IS_ERR(tmp_inode)) { 489 if (IS_ERR(tmp_inode)) {
490 retval = -ENOMEM; 490 retval = -ENOMEM;
491 ext4_journal_stop(handle); 491 ext4_journal_stop(handle);
492 tmp_inode = NULL; 492 return retval;
493 goto err_out;
494 } 493 }
495 i_size_write(tmp_inode, i_size_read(inode)); 494 i_size_write(tmp_inode, i_size_read(inode));
496 /* 495 /*
@@ -618,8 +617,7 @@ err_out:
618 617
619 ext4_journal_stop(handle); 618 ext4_journal_stop(handle);
620 619
621 if (tmp_inode) 620 iput(tmp_inode);
622 iput(tmp_inode);
623 621
624 return retval; 622 return retval;
625} 623}
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index e5f06a5f045e..a5732c58f676 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3046,14 +3046,17 @@ static void ext4_write_super(struct super_block *sb)
3046static int ext4_sync_fs(struct super_block *sb, int wait) 3046static int ext4_sync_fs(struct super_block *sb, int wait)
3047{ 3047{
3048 int ret = 0; 3048 int ret = 0;
3049 tid_t target;
3049 3050
3050 trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait); 3051 trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait);
3051 sb->s_dirt = 0; 3052 sb->s_dirt = 0;
3052 if (EXT4_SB(sb)->s_journal) { 3053 if (EXT4_SB(sb)->s_journal) {
3053 if (wait) 3054 if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal,
3054 ret = ext4_force_commit(sb); 3055 &target)) {
3055 else 3056 if (wait)
3056 jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, NULL); 3057 jbd2_log_wait_commit(EXT4_SB(sb)->s_journal,
3058 target);
3059 }
3057 } else { 3060 } else {
3058 ext4_commit_super(sb, EXT4_SB(sb)->s_es, wait); 3061 ext4_commit_super(sb, EXT4_SB(sb)->s_es, wait);
3059 } 3062 }
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 6903d37af037..9b800d97a687 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -108,7 +108,8 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
108 108
109 if (hugetlb_reserve_pages(inode, 109 if (hugetlb_reserve_pages(inode,
110 vma->vm_pgoff >> huge_page_order(h), 110 vma->vm_pgoff >> huge_page_order(h),
111 len >> huge_page_shift(h), vma)) 111 len >> huge_page_shift(h), vma,
112 vma->vm_flags))
112 goto out; 113 goto out;
113 114
114 ret = 0; 115 ret = 0;
@@ -947,7 +948,7 @@ static int can_do_hugetlb_shm(void)
947 can_do_mlock()); 948 can_do_mlock());
948} 949}
949 950
950struct file *hugetlb_file_setup(const char *name, size_t size) 951struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
951{ 952{
952 int error = -ENOMEM; 953 int error = -ENOMEM;
953 struct file *file; 954 struct file *file;
@@ -981,7 +982,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size)
981 982
982 error = -ENOMEM; 983 error = -ENOMEM;
983 if (hugetlb_reserve_pages(inode, 0, 984 if (hugetlb_reserve_pages(inode, 0,
984 size >> huge_page_shift(hstate_inode(inode)), NULL)) 985 size >> huge_page_shift(hstate_inode(inode)), NULL,
986 acctflag))
985 goto out_inode; 987 goto out_inode;
986 988
987 d_instantiate(dentry, inode); 989 d_instantiate(dentry, inode);
diff --git a/fs/internal.h b/fs/internal.h
index 53af885f1732..0d8ac497b3d5 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -43,7 +43,7 @@ extern void __init chrdev_init(void);
43/* 43/*
44 * exec.c 44 * exec.c
45 */ 45 */
46extern void check_unsafe_exec(struct linux_binprm *); 46extern void check_unsafe_exec(struct linux_binprm *, struct files_struct *);
47 47
48/* 48/*
49 * namespace.c 49 * namespace.c
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 9e4fa52d7dc8..e79c07812afa 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -427,7 +427,7 @@ int __log_space_left(journal_t *journal)
427} 427}
428 428
429/* 429/*
430 * Called under j_state_lock. Returns true if a transaction was started. 430 * Called under j_state_lock. Returns true if a transaction commit was started.
431 */ 431 */
432int __log_start_commit(journal_t *journal, tid_t target) 432int __log_start_commit(journal_t *journal, tid_t target)
433{ 433{
@@ -495,7 +495,8 @@ int journal_force_commit_nested(journal_t *journal)
495 495
496/* 496/*
497 * Start a commit of the current running transaction (if any). Returns true 497 * Start a commit of the current running transaction (if any). Returns true
498 * if a transaction was started, and fills its tid in at *ptid 498 * if a transaction is going to be committed (or is currently already
499 * committing), and fills its tid in at *ptid
499 */ 500 */
500int journal_start_commit(journal_t *journal, tid_t *ptid) 501int journal_start_commit(journal_t *journal, tid_t *ptid)
501{ 502{
@@ -505,15 +506,19 @@ int journal_start_commit(journal_t *journal, tid_t *ptid)
505 if (journal->j_running_transaction) { 506 if (journal->j_running_transaction) {
506 tid_t tid = journal->j_running_transaction->t_tid; 507 tid_t tid = journal->j_running_transaction->t_tid;
507 508
508 ret = __log_start_commit(journal, tid); 509 __log_start_commit(journal, tid);
509 if (ret && ptid) 510 /* There's a running transaction and we've just made sure
511 * it's commit has been scheduled. */
512 if (ptid)
510 *ptid = tid; 513 *ptid = tid;
511 } else if (journal->j_committing_transaction && ptid) { 514 ret = 1;
515 } else if (journal->j_committing_transaction) {
512 /* 516 /*
513 * If ext3_write_super() recently started a commit, then we 517 * If ext3_write_super() recently started a commit, then we
514 * have to wait for completion of that transaction 518 * have to wait for completion of that transaction
515 */ 519 */
516 *ptid = journal->j_committing_transaction->t_tid; 520 if (ptid)
521 *ptid = journal->j_committing_transaction->t_tid;
517 ret = 1; 522 ret = 1;
518 } 523 }
519 spin_unlock(&journal->j_state_lock); 524 spin_unlock(&journal->j_state_lock);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index eb343008eded..58144102bf25 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -450,7 +450,7 @@ int __jbd2_log_space_left(journal_t *journal)
450} 450}
451 451
452/* 452/*
453 * Called under j_state_lock. Returns true if a transaction was started. 453 * Called under j_state_lock. Returns true if a transaction commit was started.
454 */ 454 */
455int __jbd2_log_start_commit(journal_t *journal, tid_t target) 455int __jbd2_log_start_commit(journal_t *journal, tid_t target)
456{ 456{
@@ -518,7 +518,8 @@ int jbd2_journal_force_commit_nested(journal_t *journal)
518 518
519/* 519/*
520 * Start a commit of the current running transaction (if any). Returns true 520 * Start a commit of the current running transaction (if any). Returns true
521 * if a transaction was started, and fills its tid in at *ptid 521 * if a transaction is going to be committed (or is currently already
522 * committing), and fills its tid in at *ptid
522 */ 523 */
523int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid) 524int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid)
524{ 525{
@@ -528,15 +529,19 @@ int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid)
528 if (journal->j_running_transaction) { 529 if (journal->j_running_transaction) {
529 tid_t tid = journal->j_running_transaction->t_tid; 530 tid_t tid = journal->j_running_transaction->t_tid;
530 531
531 ret = __jbd2_log_start_commit(journal, tid); 532 __jbd2_log_start_commit(journal, tid);
532 if (ret && ptid) 533 /* There's a running transaction and we've just made sure
534 * it's commit has been scheduled. */
535 if (ptid)
533 *ptid = tid; 536 *ptid = tid;
534 } else if (journal->j_committing_transaction && ptid) { 537 ret = 1;
538 } else if (journal->j_committing_transaction) {
535 /* 539 /*
536 * If ext3_write_super() recently started a commit, then we 540 * If ext3_write_super() recently started a commit, then we
537 * have to wait for completion of that transaction 541 * have to wait for completion of that transaction
538 */ 542 */
539 *ptid = journal->j_committing_transaction->t_tid; 543 if (ptid)
544 *ptid = journal->j_committing_transaction->t_tid;
540 ret = 1; 545 ret = 1;
541 } 546 }
542 spin_unlock(&journal->j_state_lock); 547 spin_unlock(&journal->j_state_lock);
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 46b4e347ed7d..28ce21d8598e 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -2129,26 +2129,46 @@ done:
2129} 2129}
2130 2130
2131/* 2131/*
2132 * This function must be called when inode is journaled in ordered mode 2132 * File truncate and transaction commit interact with each other in a
2133 * before truncation happens. It starts writeout of truncated part in 2133 * non-trivial way. If a transaction writing data block A is
2134 * case it is in the committing transaction so that we stand to ordered 2134 * committing, we cannot discard the data by truncate until we have
2135 * mode consistency guarantees. 2135 * written them. Otherwise if we crashed after the transaction with
2136 * write has committed but before the transaction with truncate has
2137 * committed, we could see stale data in block A. This function is a
2138 * helper to solve this problem. It starts writeout of the truncated
2139 * part in case it is in the committing transaction.
2140 *
2141 * Filesystem code must call this function when inode is journaled in
2142 * ordered mode before truncation happens and after the inode has been
2143 * placed on orphan list with the new inode size. The second condition
2144 * avoids the race that someone writes new data and we start
2145 * committing the transaction after this function has been called but
2146 * before a transaction for truncate is started (and furthermore it
2147 * allows us to optimize the case where the addition to orphan list
2148 * happens in the same transaction as write --- we don't have to write
2149 * any data in such case).
2136 */ 2150 */
2137int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *inode, 2151int jbd2_journal_begin_ordered_truncate(journal_t *journal,
2152 struct jbd2_inode *jinode,
2138 loff_t new_size) 2153 loff_t new_size)
2139{ 2154{
2140 journal_t *journal; 2155 transaction_t *inode_trans, *commit_trans;
2141 transaction_t *commit_trans;
2142 int ret = 0; 2156 int ret = 0;
2143 2157
2144 if (!inode->i_transaction && !inode->i_next_transaction) 2158 /* This is a quick check to avoid locking if not necessary */
2159 if (!jinode->i_transaction)
2145 goto out; 2160 goto out;
2146 journal = inode->i_transaction->t_journal; 2161 /* Locks are here just to force reading of recent values, it is
2162 * enough that the transaction was not committing before we started
2163 * a transaction adding the inode to orphan list */
2147 spin_lock(&journal->j_state_lock); 2164 spin_lock(&journal->j_state_lock);
2148 commit_trans = journal->j_committing_transaction; 2165 commit_trans = journal->j_committing_transaction;
2149 spin_unlock(&journal->j_state_lock); 2166 spin_unlock(&journal->j_state_lock);
2150 if (inode->i_transaction == commit_trans) { 2167 spin_lock(&journal->j_list_lock);
2151 ret = filemap_fdatawrite_range(inode->i_vfs_inode->i_mapping, 2168 inode_trans = jinode->i_transaction;
2169 spin_unlock(&journal->j_list_lock);
2170 if (inode_trans == commit_trans) {
2171 ret = filemap_fdatawrite_range(jinode->i_vfs_inode->i_mapping,
2152 new_size, LLONG_MAX); 2172 new_size, LLONG_MAX);
2153 if (ret) 2173 if (ret)
2154 jbd2_journal_abort(journal, ret); 2174 jbd2_journal_abort(journal, ret);
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 6063a8e4b9f3..763b78a6e9de 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -427,7 +427,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
427 goto out; 427 goto out;
428 case -EAGAIN: 428 case -EAGAIN:
429 ret = nlm_lck_denied; 429 ret = nlm_lck_denied;
430 goto out; 430 break;
431 case FILE_LOCK_DEFERRED: 431 case FILE_LOCK_DEFERRED:
432 if (wait) 432 if (wait)
433 break; 433 break;
@@ -443,6 +443,10 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
443 goto out; 443 goto out;
444 } 444 }
445 445
446 ret = nlm_lck_denied;
447 if (!wait)
448 goto out;
449
446 ret = nlm_lck_blocked; 450 ret = nlm_lck_blocked;
447 451
448 /* Append to list of blocked */ 452 /* Append to list of blocked */
diff --git a/fs/namespace.c b/fs/namespace.c
index 228d8c4bfd18..06f8e63f6cb1 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -614,9 +614,11 @@ static inline void __mntput(struct vfsmount *mnt)
614 */ 614 */
615 for_each_possible_cpu(cpu) { 615 for_each_possible_cpu(cpu) {
616 struct mnt_writer *cpu_writer = &per_cpu(mnt_writers, cpu); 616 struct mnt_writer *cpu_writer = &per_cpu(mnt_writers, cpu);
617 if (cpu_writer->mnt != mnt)
618 continue;
619 spin_lock(&cpu_writer->lock); 617 spin_lock(&cpu_writer->lock);
618 if (cpu_writer->mnt != mnt) {
619 spin_unlock(&cpu_writer->lock);
620 continue;
621 }
620 atomic_add(cpu_writer->count, &mnt->__mnt_writers); 622 atomic_add(cpu_writer->count, &mnt->__mnt_writers);
621 cpu_writer->count = 0; 623 cpu_writer->count = 0;
622 /* 624 /*
diff --git a/fs/notify/inotify/inotify.c b/fs/notify/inotify/inotify.c
index dae3f28f30d4..331f2e88e284 100644
--- a/fs/notify/inotify/inotify.c
+++ b/fs/notify/inotify/inotify.c
@@ -156,7 +156,7 @@ static int inotify_handle_get_wd(struct inotify_handle *ih,
156 int ret; 156 int ret;
157 157
158 do { 158 do {
159 if (unlikely(!idr_pre_get(&ih->idr, GFP_KERNEL))) 159 if (unlikely(!idr_pre_get(&ih->idr, GFP_NOFS)))
160 return -ENOSPC; 160 return -ENOSPC;
161 ret = idr_get_new_above(&ih->idr, watch, ih->last_wd+1, &watch->wd); 161 ret = idr_get_new_above(&ih->idr, watch, ih->last_wd+1, &watch->wd);
162 } while (ret == -EAGAIN); 162 } while (ret == -EAGAIN);
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index d861096c9d81..60fe74035db5 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -5390,6 +5390,9 @@ int ocfs2_remove_btree_range(struct inode *inode,
5390 goto out; 5390 goto out;
5391 } 5391 }
5392 5392
5393 vfs_dq_free_space_nodirty(inode,
5394 ocfs2_clusters_to_bytes(inode->i_sb, len));
5395
5393 ret = ocfs2_remove_extent(inode, et, cpos, len, handle, meta_ac, 5396 ret = ocfs2_remove_extent(inode, et, cpos, len, handle, meta_ac,
5394 dealloc); 5397 dealloc);
5395 if (ret) { 5398 if (ret) {
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index b1cc7c381e88..e9d7c2038c0f 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -38,6 +38,7 @@
38#include "dlmglue.h" 38#include "dlmglue.h"
39#include "file.h" 39#include "file.h"
40#include "inode.h" 40#include "inode.h"
41#include "super.h"
41 42
42 43
43static int ocfs2_dentry_revalidate(struct dentry *dentry, 44static int ocfs2_dentry_revalidate(struct dentry *dentry,
@@ -294,6 +295,34 @@ out_attach:
294 return ret; 295 return ret;
295} 296}
296 297
298static DEFINE_SPINLOCK(dentry_list_lock);
299
300/* We limit the number of dentry locks to drop in one go. We have
301 * this limit so that we don't starve other users of ocfs2_wq. */
302#define DL_INODE_DROP_COUNT 64
303
304/* Drop inode references from dentry locks */
305void ocfs2_drop_dl_inodes(struct work_struct *work)
306{
307 struct ocfs2_super *osb = container_of(work, struct ocfs2_super,
308 dentry_lock_work);
309 struct ocfs2_dentry_lock *dl;
310 int drop_count = DL_INODE_DROP_COUNT;
311
312 spin_lock(&dentry_list_lock);
313 while (osb->dentry_lock_list && drop_count--) {
314 dl = osb->dentry_lock_list;
315 osb->dentry_lock_list = dl->dl_next;
316 spin_unlock(&dentry_list_lock);
317 iput(dl->dl_inode);
318 kfree(dl);
319 spin_lock(&dentry_list_lock);
320 }
321 if (osb->dentry_lock_list)
322 queue_work(ocfs2_wq, &osb->dentry_lock_work);
323 spin_unlock(&dentry_list_lock);
324}
325
297/* 326/*
298 * ocfs2_dentry_iput() and friends. 327 * ocfs2_dentry_iput() and friends.
299 * 328 *
@@ -318,16 +347,23 @@ out_attach:
318static void ocfs2_drop_dentry_lock(struct ocfs2_super *osb, 347static void ocfs2_drop_dentry_lock(struct ocfs2_super *osb,
319 struct ocfs2_dentry_lock *dl) 348 struct ocfs2_dentry_lock *dl)
320{ 349{
321 iput(dl->dl_inode);
322 ocfs2_simple_drop_lockres(osb, &dl->dl_lockres); 350 ocfs2_simple_drop_lockres(osb, &dl->dl_lockres);
323 ocfs2_lock_res_free(&dl->dl_lockres); 351 ocfs2_lock_res_free(&dl->dl_lockres);
324 kfree(dl); 352
353 /* We leave dropping of inode reference to ocfs2_wq as that can
354 * possibly lead to inode deletion which gets tricky */
355 spin_lock(&dentry_list_lock);
356 if (!osb->dentry_lock_list)
357 queue_work(ocfs2_wq, &osb->dentry_lock_work);
358 dl->dl_next = osb->dentry_lock_list;
359 osb->dentry_lock_list = dl;
360 spin_unlock(&dentry_list_lock);
325} 361}
326 362
327void ocfs2_dentry_lock_put(struct ocfs2_super *osb, 363void ocfs2_dentry_lock_put(struct ocfs2_super *osb,
328 struct ocfs2_dentry_lock *dl) 364 struct ocfs2_dentry_lock *dl)
329{ 365{
330 int unlock = 0; 366 int unlock;
331 367
332 BUG_ON(dl->dl_count == 0); 368 BUG_ON(dl->dl_count == 0);
333 369
diff --git a/fs/ocfs2/dcache.h b/fs/ocfs2/dcache.h
index c091c34d9883..d06e16c06640 100644
--- a/fs/ocfs2/dcache.h
+++ b/fs/ocfs2/dcache.h
@@ -29,8 +29,13 @@
29extern struct dentry_operations ocfs2_dentry_ops; 29extern struct dentry_operations ocfs2_dentry_ops;
30 30
31struct ocfs2_dentry_lock { 31struct ocfs2_dentry_lock {
32 /* Use count of dentry lock */
32 unsigned int dl_count; 33 unsigned int dl_count;
33 u64 dl_parent_blkno; 34 union {
35 /* Linked list of dentry locks to release */
36 struct ocfs2_dentry_lock *dl_next;
37 u64 dl_parent_blkno;
38 };
34 39
35 /* 40 /*
36 * The ocfs2_dentry_lock keeps an inode reference until 41 * The ocfs2_dentry_lock keeps an inode reference until
@@ -47,6 +52,8 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry, struct inode *inode,
47void ocfs2_dentry_lock_put(struct ocfs2_super *osb, 52void ocfs2_dentry_lock_put(struct ocfs2_super *osb,
48 struct ocfs2_dentry_lock *dl); 53 struct ocfs2_dentry_lock *dl);
49 54
55void ocfs2_drop_dl_inodes(struct work_struct *work);
56
50struct dentry *ocfs2_find_local_alias(struct inode *inode, u64 parent_blkno, 57struct dentry *ocfs2_find_local_alias(struct inode *inode, u64 parent_blkno,
51 int skip_unhashed); 58 int skip_unhashed);
52 59
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index b0c4cadd4c45..206a2370876a 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2860,6 +2860,10 @@ static void ocfs2_unlock_ast(void *opaque, int error)
2860 case OCFS2_UNLOCK_CANCEL_CONVERT: 2860 case OCFS2_UNLOCK_CANCEL_CONVERT:
2861 mlog(0, "Cancel convert success for %s\n", lockres->l_name); 2861 mlog(0, "Cancel convert success for %s\n", lockres->l_name);
2862 lockres->l_action = OCFS2_AST_INVALID; 2862 lockres->l_action = OCFS2_AST_INVALID;
2863 /* Downconvert thread may have requeued this lock, we
2864 * need to wake it. */
2865 if (lockres->l_flags & OCFS2_LOCK_BLOCKED)
2866 ocfs2_wake_downconvert_thread(ocfs2_get_lockres_osb(lockres));
2863 break; 2867 break;
2864 case OCFS2_UNLOCK_DROP_LOCK: 2868 case OCFS2_UNLOCK_DROP_LOCK:
2865 lockres->l_level = DLM_LOCK_IV; 2869 lockres->l_level = DLM_LOCK_IV;
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 3c3532e1307c..172850a9a12a 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -513,8 +513,10 @@ static inline int ocfs2_jbd2_file_inode(handle_t *handle, struct inode *inode)
513static inline int ocfs2_begin_ordered_truncate(struct inode *inode, 513static inline int ocfs2_begin_ordered_truncate(struct inode *inode,
514 loff_t new_size) 514 loff_t new_size)
515{ 515{
516 return jbd2_journal_begin_ordered_truncate(&OCFS2_I(inode)->ip_jinode, 516 return jbd2_journal_begin_ordered_truncate(
517 new_size); 517 OCFS2_SB(inode->i_sb)->journal->j_journal,
518 &OCFS2_I(inode)->ip_jinode,
519 new_size);
518} 520}
519 521
520#endif /* OCFS2_JOURNAL_H */ 522#endif /* OCFS2_JOURNAL_H */
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index ad5c24a29edd..077384135f4e 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -210,6 +210,7 @@ struct ocfs2_journal;
210struct ocfs2_slot_info; 210struct ocfs2_slot_info;
211struct ocfs2_recovery_map; 211struct ocfs2_recovery_map;
212struct ocfs2_quota_recovery; 212struct ocfs2_quota_recovery;
213struct ocfs2_dentry_lock;
213struct ocfs2_super 214struct ocfs2_super
214{ 215{
215 struct task_struct *commit_task; 216 struct task_struct *commit_task;
@@ -325,6 +326,11 @@ struct ocfs2_super
325 struct list_head blocked_lock_list; 326 struct list_head blocked_lock_list;
326 unsigned long blocked_lock_count; 327 unsigned long blocked_lock_count;
327 328
329 /* List of dentry locks to release. Anyone can add locks to
330 * the list, ocfs2_wq processes the list */
331 struct ocfs2_dentry_lock *dentry_lock_list;
332 struct work_struct dentry_lock_work;
333
328 wait_queue_head_t osb_mount_event; 334 wait_queue_head_t osb_mount_event;
329 335
330 /* Truncate log info */ 336 /* Truncate log info */
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index f4efa89baee5..1ed0f7c86869 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -754,7 +754,9 @@ static int ocfs2_mark_dquot_dirty(struct dquot *dquot)
754 if (dquot->dq_flags & mask) 754 if (dquot->dq_flags & mask)
755 sync = 1; 755 sync = 1;
756 spin_unlock(&dq_data_lock); 756 spin_unlock(&dq_data_lock);
757 if (!sync) { 757 /* This is a slight hack but we can't afford getting global quota
758 * lock if we already have a transaction started. */
759 if (!sync || journal_current_handle()) {
758 status = ocfs2_write_dquot(dquot); 760 status = ocfs2_write_dquot(dquot);
759 goto out; 761 goto out;
760 } 762 }
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 43ed11345b59..b1cb38fbe807 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1887,6 +1887,9 @@ static int ocfs2_initialize_super(struct super_block *sb,
1887 INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery); 1887 INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery);
1888 journal->j_state = OCFS2_JOURNAL_FREE; 1888 journal->j_state = OCFS2_JOURNAL_FREE;
1889 1889
1890 INIT_WORK(&osb->dentry_lock_work, ocfs2_drop_dl_inodes);
1891 osb->dentry_lock_list = NULL;
1892
1890 /* get some pseudo constants for clustersize bits */ 1893 /* get some pseudo constants for clustersize bits */
1891 osb->s_clustersize_bits = 1894 osb->s_clustersize_bits =
1892 le32_to_cpu(di->id2.i_super.s_clustersize_bits); 1895 le32_to_cpu(di->id2.i_super.s_clustersize_bits);
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index e1d638af6ac3..915039fffe6e 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -4729,13 +4729,6 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
4729 vb.vb_xv = (struct ocfs2_xattr_value_root *) 4729 vb.vb_xv = (struct ocfs2_xattr_value_root *)
4730 (vb.vb_bh->b_data + offset % blocksize); 4730 (vb.vb_bh->b_data + offset % blocksize);
4731 4731
4732 ret = ocfs2_xattr_bucket_journal_access(ctxt->handle, bucket,
4733 OCFS2_JOURNAL_ACCESS_WRITE);
4734 if (ret) {
4735 mlog_errno(ret);
4736 goto out;
4737 }
4738
4739 /* 4732 /*
4740 * From here on out we have to dirty the bucket. The generic 4733 * From here on out we have to dirty the bucket. The generic
4741 * value calls only modify one of the bucket's bhs, but we need 4734 * value calls only modify one of the bucket's bhs, but we need
@@ -4748,12 +4741,18 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
4748 ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt); 4741 ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt);
4749 if (ret) { 4742 if (ret) {
4750 mlog_errno(ret); 4743 mlog_errno(ret);
4751 goto out_dirty; 4744 goto out;
4745 }
4746
4747 ret = ocfs2_xattr_bucket_journal_access(ctxt->handle, bucket,
4748 OCFS2_JOURNAL_ACCESS_WRITE);
4749 if (ret) {
4750 mlog_errno(ret);
4751 goto out;
4752 } 4752 }
4753 4753
4754 xe->xe_value_size = cpu_to_le64(len); 4754 xe->xe_value_size = cpu_to_le64(len);
4755 4755
4756out_dirty:
4757 ocfs2_xattr_bucket_journal_dirty(ctxt->handle, bucket); 4756 ocfs2_xattr_bucket_journal_dirty(ctxt->handle, bucket);
4758 4757
4759out: 4758out:
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 3e76bb9b3ad6..d8bb5c671f42 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -485,8 +485,10 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
485 } 485 }
486 } 486 }
487 unlock_new_inode(inode); 487 unlock_new_inode(inode);
488 } else 488 } else {
489 module_put(de->owner); 489 module_put(de->owner);
490 de_put(de);
491 }
490 return inode; 492 return inode;
491 493
492out_ino: 494out_ino:
diff --git a/fs/seq_file.c b/fs/seq_file.c
index b569ff1c4dc8..a1a4cfe19210 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -48,12 +48,78 @@ int seq_open(struct file *file, const struct seq_operations *op)
48 */ 48 */
49 file->f_version = 0; 49 file->f_version = 0;
50 50
51 /* SEQ files support lseek, but not pread/pwrite */ 51 /*
52 file->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 52 * seq_files support lseek() and pread(). They do not implement
53 * write() at all, but we clear FMODE_PWRITE here for historical
54 * reasons.
55 *
56 * If a client of seq_files a) implements file.write() and b) wishes to
57 * support pwrite() then that client will need to implement its own
58 * file.open() which calls seq_open() and then sets FMODE_PWRITE.
59 */
60 file->f_mode &= ~FMODE_PWRITE;
53 return 0; 61 return 0;
54} 62}
55EXPORT_SYMBOL(seq_open); 63EXPORT_SYMBOL(seq_open);
56 64
65static int traverse(struct seq_file *m, loff_t offset)
66{
67 loff_t pos = 0, index;
68 int error = 0;
69 void *p;
70
71 m->version = 0;
72 index = 0;
73 m->count = m->from = 0;
74 if (!offset) {
75 m->index = index;
76 return 0;
77 }
78 if (!m->buf) {
79 m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
80 if (!m->buf)
81 return -ENOMEM;
82 }
83 p = m->op->start(m, &index);
84 while (p) {
85 error = PTR_ERR(p);
86 if (IS_ERR(p))
87 break;
88 error = m->op->show(m, p);
89 if (error < 0)
90 break;
91 if (unlikely(error)) {
92 error = 0;
93 m->count = 0;
94 }
95 if (m->count == m->size)
96 goto Eoverflow;
97 if (pos + m->count > offset) {
98 m->from = offset - pos;
99 m->count -= m->from;
100 m->index = index;
101 break;
102 }
103 pos += m->count;
104 m->count = 0;
105 if (pos == offset) {
106 index++;
107 m->index = index;
108 break;
109 }
110 p = m->op->next(m, p, &index);
111 }
112 m->op->stop(m, p);
113 m->index = index;
114 return error;
115
116Eoverflow:
117 m->op->stop(m, p);
118 kfree(m->buf);
119 m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
120 return !m->buf ? -ENOMEM : -EAGAIN;
121}
122
57/** 123/**
58 * seq_read - ->read() method for sequential files. 124 * seq_read - ->read() method for sequential files.
59 * @file: the file to read from 125 * @file: the file to read from
@@ -73,6 +139,22 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
73 int err = 0; 139 int err = 0;
74 140
75 mutex_lock(&m->lock); 141 mutex_lock(&m->lock);
142
143 /* Don't assume *ppos is where we left it */
144 if (unlikely(*ppos != m->read_pos)) {
145 m->read_pos = *ppos;
146 while ((err = traverse(m, *ppos)) == -EAGAIN)
147 ;
148 if (err) {
149 /* With prejudice... */
150 m->read_pos = 0;
151 m->version = 0;
152 m->index = 0;
153 m->count = 0;
154 goto Done;
155 }
156 }
157
76 /* 158 /*
77 * seq_file->op->..m_start/m_stop/m_next may do special actions 159 * seq_file->op->..m_start/m_stop/m_next may do special actions
78 * or optimisations based on the file->f_version, so we want to 160 * or optimisations based on the file->f_version, so we want to
@@ -172,8 +254,10 @@ Fill:
172Done: 254Done:
173 if (!copied) 255 if (!copied)
174 copied = err; 256 copied = err;
175 else 257 else {
176 *ppos += copied; 258 *ppos += copied;
259 m->read_pos += copied;
260 }
177 file->f_version = m->version; 261 file->f_version = m->version;
178 mutex_unlock(&m->lock); 262 mutex_unlock(&m->lock);
179 return copied; 263 return copied;
@@ -186,63 +270,6 @@ Efault:
186} 270}
187EXPORT_SYMBOL(seq_read); 271EXPORT_SYMBOL(seq_read);
188 272
189static int traverse(struct seq_file *m, loff_t offset)
190{
191 loff_t pos = 0, index;
192 int error = 0;
193 void *p;
194
195 m->version = 0;
196 index = 0;
197 m->count = m->from = 0;
198 if (!offset) {
199 m->index = index;
200 return 0;
201 }
202 if (!m->buf) {
203 m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
204 if (!m->buf)
205 return -ENOMEM;
206 }
207 p = m->op->start(m, &index);
208 while (p) {
209 error = PTR_ERR(p);
210 if (IS_ERR(p))
211 break;
212 error = m->op->show(m, p);
213 if (error < 0)
214 break;
215 if (unlikely(error)) {
216 error = 0;
217 m->count = 0;
218 }
219 if (m->count == m->size)
220 goto Eoverflow;
221 if (pos + m->count > offset) {
222 m->from = offset - pos;
223 m->count -= m->from;
224 m->index = index;
225 break;
226 }
227 pos += m->count;
228 m->count = 0;
229 if (pos == offset) {
230 index++;
231 m->index = index;
232 break;
233 }
234 p = m->op->next(m, p, &index);
235 }
236 m->op->stop(m, p);
237 return error;
238
239Eoverflow:
240 m->op->stop(m, p);
241 kfree(m->buf);
242 m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
243 return !m->buf ? -ENOMEM : -EAGAIN;
244}
245
246/** 273/**
247 * seq_lseek - ->llseek() method for sequential files. 274 * seq_lseek - ->llseek() method for sequential files.
248 * @file: the file in question 275 * @file: the file in question
@@ -265,16 +292,18 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
265 if (offset < 0) 292 if (offset < 0)
266 break; 293 break;
267 retval = offset; 294 retval = offset;
268 if (offset != file->f_pos) { 295 if (offset != m->read_pos) {
269 while ((retval=traverse(m, offset)) == -EAGAIN) 296 while ((retval=traverse(m, offset)) == -EAGAIN)
270 ; 297 ;
271 if (retval) { 298 if (retval) {
272 /* with extreme prejudice... */ 299 /* with extreme prejudice... */
273 file->f_pos = 0; 300 file->f_pos = 0;
301 m->read_pos = 0;
274 m->version = 0; 302 m->version = 0;
275 m->index = 0; 303 m->index = 0;
276 m->count = 0; 304 m->count = 0;
277 } else { 305 } else {
306 m->read_pos = offset;
278 retval = file->f_pos = offset; 307 retval = file->f_pos = offset;
279 } 308 }
280 } 309 }
diff --git a/fs/super.c b/fs/super.c
index 645e5403f2a0..8349ed6b1412 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -82,7 +82,22 @@ static struct super_block *alloc_super(struct file_system_type *type)
82 * lock ordering than usbfs: 82 * lock ordering than usbfs:
83 */ 83 */
84 lockdep_set_class(&s->s_lock, &type->s_lock_key); 84 lockdep_set_class(&s->s_lock, &type->s_lock_key);
85 down_write(&s->s_umount); 85 /*
86 * sget() can have s_umount recursion.
87 *
88 * When it cannot find a suitable sb, it allocates a new
89 * one (this one), and tries again to find a suitable old
90 * one.
91 *
92 * In case that succeeds, it will acquire the s_umount
93 * lock of the old one. Since these are clearly distrinct
94 * locks, and this object isn't exposed yet, there's no
95 * risk of deadlocks.
96 *
97 * Annotate this by putting this lock in a different
98 * subclass.
99 */
100 down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING);
86 s->s_count = S_BIAS; 101 s->s_count = S_BIAS;
87 atomic_set(&s->s_active, 1); 102 atomic_set(&s->s_active, 1);
88 mutex_init(&s->s_vfs_rename_mutex); 103 mutex_init(&s->s_vfs_rename_mutex);
@@ -301,7 +316,7 @@ void generic_shutdown_super(struct super_block *sb)
301 /* 316 /*
302 * wait for asynchronous fs operations to finish before going further 317 * wait for asynchronous fs operations to finish before going further
303 */ 318 */
304 async_synchronize_full_special(&sb->s_async_list); 319 async_synchronize_full_domain(&sb->s_async_list);
305 320
306 /* bad name - it should be evict_inodes() */ 321 /* bad name - it should be evict_inodes() */
307 invalidate_inodes(sb); 322 invalidate_inodes(sb);
@@ -470,7 +485,7 @@ restart:
470 sb->s_count++; 485 sb->s_count++;
471 spin_unlock(&sb_lock); 486 spin_unlock(&sb_lock);
472 down_read(&sb->s_umount); 487 down_read(&sb->s_umount);
473 async_synchronize_full_special(&sb->s_async_list); 488 async_synchronize_full_domain(&sb->s_async_list);
474 if (sb->s_root && (wait || sb->s_dirt)) 489 if (sb->s_root && (wait || sb->s_dirt))
475 sb->s_op->sync_fs(sb, wait); 490 sb->s_op->sync_fs(sb, wait);
476 up_read(&sb->s_umount); 491 up_read(&sb->s_umount);
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 6a123b8ff3f5..b042bd7034b1 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -186,10 +186,9 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
186 BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC); 186 BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);
187 BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK); 187 BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK);
188 188
189 if (flags & ~(TFD_CLOEXEC | TFD_NONBLOCK)) 189 if ((flags & ~TFD_CREATE_FLAGS) ||
190 return -EINVAL; 190 (clockid != CLOCK_MONOTONIC &&
191 if (clockid != CLOCK_MONOTONIC && 191 clockid != CLOCK_REALTIME))
192 clockid != CLOCK_REALTIME)
193 return -EINVAL; 192 return -EINVAL;
194 193
195 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 194 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -201,7 +200,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
201 hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); 200 hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS);
202 201
203 ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, 202 ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx,
204 flags & (O_CLOEXEC | O_NONBLOCK)); 203 flags & TFD_SHARED_FCNTL_FLAGS);
205 if (ufd < 0) 204 if (ufd < 0)
206 kfree(ctx); 205 kfree(ctx);
207 206
@@ -219,7 +218,8 @@ SYSCALL_DEFINE4(timerfd_settime, int, ufd, int, flags,
219 if (copy_from_user(&ktmr, utmr, sizeof(ktmr))) 218 if (copy_from_user(&ktmr, utmr, sizeof(ktmr)))
220 return -EFAULT; 219 return -EFAULT;
221 220
222 if (!timespec_valid(&ktmr.it_value) || 221 if ((flags & ~TFD_SETTIME_FLAGS) ||
222 !timespec_valid(&ktmr.it_value) ||
223 !timespec_valid(&ktmr.it_interval)) 223 !timespec_valid(&ktmr.it_interval))
224 return -EINVAL; 224 return -EINVAL;
225 225
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
index 175f9c590b77..f393620890ee 100644
--- a/fs/ubifs/budget.c
+++ b/fs/ubifs/budget.c
@@ -689,7 +689,7 @@ long long ubifs_reported_space(const struct ubifs_info *c, long long free)
689} 689}
690 690
691/** 691/**
692 * ubifs_get_free_space - return amount of free space. 692 * ubifs_get_free_space_nolock - return amount of free space.
693 * @c: UBIFS file-system description object 693 * @c: UBIFS file-system description object
694 * 694 *
695 * This function calculates amount of free space to report to user-space. 695 * This function calculates amount of free space to report to user-space.
@@ -704,16 +704,14 @@ long long ubifs_reported_space(const struct ubifs_info *c, long long free)
704 * traditional file-systems, because they have way less overhead than UBIFS. 704 * traditional file-systems, because they have way less overhead than UBIFS.
705 * So, to keep users happy, UBIFS tries to take the overhead into account. 705 * So, to keep users happy, UBIFS tries to take the overhead into account.
706 */ 706 */
707long long ubifs_get_free_space(struct ubifs_info *c) 707long long ubifs_get_free_space_nolock(struct ubifs_info *c)
708{ 708{
709 int min_idx_lebs, rsvd_idx_lebs, lebs; 709 int rsvd_idx_lebs, lebs;
710 long long available, outstanding, free; 710 long long available, outstanding, free;
711 711
712 spin_lock(&c->space_lock); 712 ubifs_assert(c->min_idx_lebs == ubifs_calc_min_idx_lebs(c));
713 min_idx_lebs = c->min_idx_lebs;
714 ubifs_assert(min_idx_lebs == ubifs_calc_min_idx_lebs(c));
715 outstanding = c->budg_data_growth + c->budg_dd_growth; 713 outstanding = c->budg_data_growth + c->budg_dd_growth;
716 available = ubifs_calc_available(c, min_idx_lebs); 714 available = ubifs_calc_available(c, c->min_idx_lebs);
717 715
718 /* 716 /*
719 * When reporting free space to user-space, UBIFS guarantees that it is 717 * When reporting free space to user-space, UBIFS guarantees that it is
@@ -726,15 +724,14 @@ long long ubifs_get_free_space(struct ubifs_info *c)
726 * Note, the calculations below are similar to what we have in 724 * Note, the calculations below are similar to what we have in
727 * 'do_budget_space()', so refer there for comments. 725 * 'do_budget_space()', so refer there for comments.
728 */ 726 */
729 if (min_idx_lebs > c->lst.idx_lebs) 727 if (c->min_idx_lebs > c->lst.idx_lebs)
730 rsvd_idx_lebs = min_idx_lebs - c->lst.idx_lebs; 728 rsvd_idx_lebs = c->min_idx_lebs - c->lst.idx_lebs;
731 else 729 else
732 rsvd_idx_lebs = 0; 730 rsvd_idx_lebs = 0;
733 lebs = c->lst.empty_lebs + c->freeable_cnt + c->idx_gc_cnt - 731 lebs = c->lst.empty_lebs + c->freeable_cnt + c->idx_gc_cnt -
734 c->lst.taken_empty_lebs; 732 c->lst.taken_empty_lebs;
735 lebs -= rsvd_idx_lebs; 733 lebs -= rsvd_idx_lebs;
736 available += lebs * (c->dark_wm - c->leb_overhead); 734 available += lebs * (c->dark_wm - c->leb_overhead);
737 spin_unlock(&c->space_lock);
738 735
739 if (available > outstanding) 736 if (available > outstanding)
740 free = ubifs_reported_space(c, available - outstanding); 737 free = ubifs_reported_space(c, available - outstanding);
@@ -742,3 +739,21 @@ long long ubifs_get_free_space(struct ubifs_info *c)
742 free = 0; 739 free = 0;
743 return free; 740 return free;
744} 741}
742
743/**
744 * ubifs_get_free_space - return amount of free space.
745 * @c: UBIFS file-system description object
746 *
747 * This function calculates and retuns amount of free space to report to
748 * user-space.
749 */
750long long ubifs_get_free_space(struct ubifs_info *c)
751{
752 long long free;
753
754 spin_lock(&c->space_lock);
755 free = ubifs_get_free_space_nolock(c);
756 spin_unlock(&c->space_lock);
757
758 return free;
759}
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 792c5a16c182..e975bd82f38b 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -620,9 +620,11 @@ void dbg_dump_budg(struct ubifs_info *c)
620 c->dark_wm, c->dead_wm, c->max_idx_node_sz); 620 c->dark_wm, c->dead_wm, c->max_idx_node_sz);
621 printk(KERN_DEBUG "\tgc_lnum %d, ihead_lnum %d\n", 621 printk(KERN_DEBUG "\tgc_lnum %d, ihead_lnum %d\n",
622 c->gc_lnum, c->ihead_lnum); 622 c->gc_lnum, c->ihead_lnum);
623 for (i = 0; i < c->jhead_cnt; i++) 623 /* If we are in R/O mode, journal heads do not exist */
624 printk(KERN_DEBUG "\tjhead %d\t LEB %d\n", 624 if (c->jheads)
625 c->jheads[i].wbuf.jhead, c->jheads[i].wbuf.lnum); 625 for (i = 0; i < c->jhead_cnt; i++)
626 printk(KERN_DEBUG "\tjhead %d\t LEB %d\n",
627 c->jheads[i].wbuf.jhead, c->jheads[i].wbuf.lnum);
626 for (rb = rb_first(&c->buds); rb; rb = rb_next(rb)) { 628 for (rb = rb_first(&c->buds); rb; rb = rb_next(rb)) {
627 bud = rb_entry(rb, struct ubifs_bud, rb); 629 bud = rb_entry(rb, struct ubifs_bud, rb);
628 printk(KERN_DEBUG "\tbud LEB %d\n", bud->lnum); 630 printk(KERN_DEBUG "\tbud LEB %d\n", bud->lnum);
@@ -637,10 +639,7 @@ void dbg_dump_budg(struct ubifs_info *c)
637 /* Print budgeting predictions */ 639 /* Print budgeting predictions */
638 available = ubifs_calc_available(c, c->min_idx_lebs); 640 available = ubifs_calc_available(c, c->min_idx_lebs);
639 outstanding = c->budg_data_growth + c->budg_dd_growth; 641 outstanding = c->budg_data_growth + c->budg_dd_growth;
640 if (available > outstanding) 642 free = ubifs_get_free_space_nolock(c);
641 free = ubifs_reported_space(c, available - outstanding);
642 else
643 free = 0;
644 printk(KERN_DEBUG "Budgeting predictions:\n"); 643 printk(KERN_DEBUG "Budgeting predictions:\n");
645 printk(KERN_DEBUG "\tavailable: %lld, outstanding %lld, free %lld\n", 644 printk(KERN_DEBUG "\tavailable: %lld, outstanding %lld, free %lld\n",
646 available, outstanding, free); 645 available, outstanding, free);
@@ -861,6 +860,65 @@ void dbg_dump_index(struct ubifs_info *c)
861} 860}
862 861
863/** 862/**
863 * dbg_save_space_info - save information about flash space.
864 * @c: UBIFS file-system description object
865 *
866 * This function saves information about UBIFS free space, dirty space, etc, in
867 * order to check it later.
868 */
869void dbg_save_space_info(struct ubifs_info *c)
870{
871 struct ubifs_debug_info *d = c->dbg;
872
873 ubifs_get_lp_stats(c, &d->saved_lst);
874
875 spin_lock(&c->space_lock);
876 d->saved_free = ubifs_get_free_space_nolock(c);
877 spin_unlock(&c->space_lock);
878}
879
880/**
881 * dbg_check_space_info - check flash space information.
882 * @c: UBIFS file-system description object
883 *
884 * This function compares current flash space information with the information
885 * which was saved when the 'dbg_save_space_info()' function was called.
886 * Returns zero if the information has not changed, and %-EINVAL it it has
887 * changed.
888 */
889int dbg_check_space_info(struct ubifs_info *c)
890{
891 struct ubifs_debug_info *d = c->dbg;
892 struct ubifs_lp_stats lst;
893 long long avail, free;
894
895 spin_lock(&c->space_lock);
896 avail = ubifs_calc_available(c, c->min_idx_lebs);
897 spin_unlock(&c->space_lock);
898 free = ubifs_get_free_space(c);
899
900 if (free != d->saved_free) {
901 ubifs_err("free space changed from %lld to %lld",
902 d->saved_free, free);
903 goto out;
904 }
905
906 return 0;
907
908out:
909 ubifs_msg("saved lprops statistics dump");
910 dbg_dump_lstats(&d->saved_lst);
911 ubifs_get_lp_stats(c, &lst);
912 ubifs_msg("current lprops statistics dump");
913 dbg_dump_lstats(&d->saved_lst);
914 spin_lock(&c->space_lock);
915 dbg_dump_budg(c);
916 spin_unlock(&c->space_lock);
917 dump_stack();
918 return -EINVAL;
919}
920
921/**
864 * dbg_check_synced_i_size - check synchronized inode size. 922 * dbg_check_synced_i_size - check synchronized inode size.
865 * @inode: inode to check 923 * @inode: inode to check
866 * 924 *
@@ -1349,7 +1407,7 @@ int dbg_check_tnc(struct ubifs_info *c, int extra)
1349 * @c: UBIFS file-system description object 1407 * @c: UBIFS file-system description object
1350 * @leaf_cb: called for each leaf node 1408 * @leaf_cb: called for each leaf node
1351 * @znode_cb: called for each indexing node 1409 * @znode_cb: called for each indexing node
1352 * @priv: private date which is passed to callbacks 1410 * @priv: private data which is passed to callbacks
1353 * 1411 *
1354 * This function walks the UBIFS index and calls the @leaf_cb for each leaf 1412 * This function walks the UBIFS index and calls the @leaf_cb for each leaf
1355 * node and @znode_cb for each indexing node. Returns zero in case of success 1413 * node and @znode_cb for each indexing node. Returns zero in case of success
@@ -2409,7 +2467,7 @@ void ubifs_debugging_exit(struct ubifs_info *c)
2409 * Root directory for UBIFS stuff in debugfs. Contains sub-directories which 2467 * Root directory for UBIFS stuff in debugfs. Contains sub-directories which
2410 * contain the stuff specific to particular file-system mounts. 2468 * contain the stuff specific to particular file-system mounts.
2411 */ 2469 */
2412static struct dentry *debugfs_rootdir; 2470static struct dentry *dfs_rootdir;
2413 2471
2414/** 2472/**
2415 * dbg_debugfs_init - initialize debugfs file-system. 2473 * dbg_debugfs_init - initialize debugfs file-system.
@@ -2421,9 +2479,9 @@ static struct dentry *debugfs_rootdir;
2421 */ 2479 */
2422int dbg_debugfs_init(void) 2480int dbg_debugfs_init(void)
2423{ 2481{
2424 debugfs_rootdir = debugfs_create_dir("ubifs", NULL); 2482 dfs_rootdir = debugfs_create_dir("ubifs", NULL);
2425 if (IS_ERR(debugfs_rootdir)) { 2483 if (IS_ERR(dfs_rootdir)) {
2426 int err = PTR_ERR(debugfs_rootdir); 2484 int err = PTR_ERR(dfs_rootdir);
2427 ubifs_err("cannot create \"ubifs\" debugfs directory, " 2485 ubifs_err("cannot create \"ubifs\" debugfs directory, "
2428 "error %d\n", err); 2486 "error %d\n", err);
2429 return err; 2487 return err;
@@ -2437,7 +2495,7 @@ int dbg_debugfs_init(void)
2437 */ 2495 */
2438void dbg_debugfs_exit(void) 2496void dbg_debugfs_exit(void)
2439{ 2497{
2440 debugfs_remove(debugfs_rootdir); 2498 debugfs_remove(dfs_rootdir);
2441} 2499}
2442 2500
2443static int open_debugfs_file(struct inode *inode, struct file *file) 2501static int open_debugfs_file(struct inode *inode, struct file *file)
@@ -2452,13 +2510,13 @@ static ssize_t write_debugfs_file(struct file *file, const char __user *buf,
2452 struct ubifs_info *c = file->private_data; 2510 struct ubifs_info *c = file->private_data;
2453 struct ubifs_debug_info *d = c->dbg; 2511 struct ubifs_debug_info *d = c->dbg;
2454 2512
2455 if (file->f_path.dentry == d->dump_lprops) 2513 if (file->f_path.dentry == d->dfs_dump_lprops)
2456 dbg_dump_lprops(c); 2514 dbg_dump_lprops(c);
2457 else if (file->f_path.dentry == d->dump_budg) { 2515 else if (file->f_path.dentry == d->dfs_dump_budg) {
2458 spin_lock(&c->space_lock); 2516 spin_lock(&c->space_lock);
2459 dbg_dump_budg(c); 2517 dbg_dump_budg(c);
2460 spin_unlock(&c->space_lock); 2518 spin_unlock(&c->space_lock);
2461 } else if (file->f_path.dentry == d->dump_tnc) { 2519 } else if (file->f_path.dentry == d->dfs_dump_tnc) {
2462 mutex_lock(&c->tnc_mutex); 2520 mutex_lock(&c->tnc_mutex);
2463 dbg_dump_tnc(c); 2521 dbg_dump_tnc(c);
2464 mutex_unlock(&c->tnc_mutex); 2522 mutex_unlock(&c->tnc_mutex);
@@ -2469,7 +2527,7 @@ static ssize_t write_debugfs_file(struct file *file, const char __user *buf,
2469 return count; 2527 return count;
2470} 2528}
2471 2529
2472static const struct file_operations debugfs_fops = { 2530static const struct file_operations dfs_fops = {
2473 .open = open_debugfs_file, 2531 .open = open_debugfs_file,
2474 .write = write_debugfs_file, 2532 .write = write_debugfs_file,
2475 .owner = THIS_MODULE, 2533 .owner = THIS_MODULE,
@@ -2494,36 +2552,32 @@ int dbg_debugfs_init_fs(struct ubifs_info *c)
2494 struct dentry *dent; 2552 struct dentry *dent;
2495 struct ubifs_debug_info *d = c->dbg; 2553 struct ubifs_debug_info *d = c->dbg;
2496 2554
2497 sprintf(d->debugfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id); 2555 sprintf(d->dfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id);
2498 d->debugfs_dir = debugfs_create_dir(d->debugfs_dir_name, 2556 d->dfs_dir = debugfs_create_dir(d->dfs_dir_name, dfs_rootdir);
2499 debugfs_rootdir); 2557 if (IS_ERR(d->dfs_dir)) {
2500 if (IS_ERR(d->debugfs_dir)) { 2558 err = PTR_ERR(d->dfs_dir);
2501 err = PTR_ERR(d->debugfs_dir);
2502 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", 2559 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n",
2503 d->debugfs_dir_name, err); 2560 d->dfs_dir_name, err);
2504 goto out; 2561 goto out;
2505 } 2562 }
2506 2563
2507 fname = "dump_lprops"; 2564 fname = "dump_lprops";
2508 dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c, 2565 dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops);
2509 &debugfs_fops);
2510 if (IS_ERR(dent)) 2566 if (IS_ERR(dent))
2511 goto out_remove; 2567 goto out_remove;
2512 d->dump_lprops = dent; 2568 d->dfs_dump_lprops = dent;
2513 2569
2514 fname = "dump_budg"; 2570 fname = "dump_budg";
2515 dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c, 2571 dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops);
2516 &debugfs_fops);
2517 if (IS_ERR(dent)) 2572 if (IS_ERR(dent))
2518 goto out_remove; 2573 goto out_remove;
2519 d->dump_budg = dent; 2574 d->dfs_dump_budg = dent;
2520 2575
2521 fname = "dump_tnc"; 2576 fname = "dump_tnc";
2522 dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c, 2577 dent = debugfs_create_file(fname, S_IWUGO, d->dfs_dir, c, &dfs_fops);
2523 &debugfs_fops);
2524 if (IS_ERR(dent)) 2578 if (IS_ERR(dent))
2525 goto out_remove; 2579 goto out_remove;
2526 d->dump_tnc = dent; 2580 d->dfs_dump_tnc = dent;
2527 2581
2528 return 0; 2582 return 0;
2529 2583
@@ -2531,7 +2585,7 @@ out_remove:
2531 err = PTR_ERR(dent); 2585 err = PTR_ERR(dent);
2532 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n", 2586 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n",
2533 fname, err); 2587 fname, err);
2534 debugfs_remove_recursive(d->debugfs_dir); 2588 debugfs_remove_recursive(d->dfs_dir);
2535out: 2589out:
2536 return err; 2590 return err;
2537} 2591}
@@ -2542,7 +2596,7 @@ out:
2542 */ 2596 */
2543void dbg_debugfs_exit_fs(struct ubifs_info *c) 2597void dbg_debugfs_exit_fs(struct ubifs_info *c)
2544{ 2598{
2545 debugfs_remove_recursive(c->dbg->debugfs_dir); 2599 debugfs_remove_recursive(c->dbg->dfs_dir);
2546} 2600}
2547 2601
2548#endif /* CONFIG_UBIFS_FS_DEBUG */ 2602#endif /* CONFIG_UBIFS_FS_DEBUG */
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
index 9820d6999f7e..c1cd73b2e06e 100644
--- a/fs/ubifs/debug.h
+++ b/fs/ubifs/debug.h
@@ -41,15 +41,17 @@
41 * @chk_lpt_wastage: used by LPT tree size checker 41 * @chk_lpt_wastage: used by LPT tree size checker
42 * @chk_lpt_lebs: used by LPT tree size checker 42 * @chk_lpt_lebs: used by LPT tree size checker
43 * @new_nhead_offs: used by LPT tree size checker 43 * @new_nhead_offs: used by LPT tree size checker
44 * @new_ihead_lnum: used by debugging to check ihead_lnum 44 * @new_ihead_lnum: used by debugging to check @c->ihead_lnum
45 * @new_ihead_offs: used by debugging to check ihead_offs 45 * @new_ihead_offs: used by debugging to check @c->ihead_offs
46 * 46 *
47 * debugfs_dir_name: name of debugfs directory containing this file-system's 47 * @saved_lst: saved lprops statistics (used by 'dbg_save_space_info()')
48 * files 48 * @saved_free: saved free space (used by 'dbg_save_space_info()')
49 * debugfs_dir: direntry object of the file-system debugfs directory 49 *
50 * dump_lprops: "dump lprops" debugfs knob 50 * dfs_dir_name: name of debugfs directory containing this file-system's files
51 * dump_budg: "dump budgeting information" debugfs knob 51 * dfs_dir: direntry object of the file-system debugfs directory
52 * dump_tnc: "dump TNC" debugfs knob 52 * dfs_dump_lprops: "dump lprops" debugfs knob
53 * dfs_dump_budg: "dump budgeting information" debugfs knob
54 * dfs_dump_tnc: "dump TNC" debugfs knob
53 */ 55 */
54struct ubifs_debug_info { 56struct ubifs_debug_info {
55 void *buf; 57 void *buf;
@@ -69,11 +71,14 @@ struct ubifs_debug_info {
69 int new_ihead_lnum; 71 int new_ihead_lnum;
70 int new_ihead_offs; 72 int new_ihead_offs;
71 73
72 char debugfs_dir_name[100]; 74 struct ubifs_lp_stats saved_lst;
73 struct dentry *debugfs_dir; 75 long long saved_free;
74 struct dentry *dump_lprops; 76
75 struct dentry *dump_budg; 77 char dfs_dir_name[100];
76 struct dentry *dump_tnc; 78 struct dentry *dfs_dir;
79 struct dentry *dfs_dump_lprops;
80 struct dentry *dfs_dump_budg;
81 struct dentry *dfs_dump_tnc;
77}; 82};
78 83
79#define ubifs_assert(expr) do { \ 84#define ubifs_assert(expr) do { \
@@ -297,7 +302,8 @@ int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb,
297 dbg_znode_callback znode_cb, void *priv); 302 dbg_znode_callback znode_cb, void *priv);
298 303
299/* Checking functions */ 304/* Checking functions */
300 305void dbg_save_space_info(struct ubifs_info *c);
306int dbg_check_space_info(struct ubifs_info *c);
301int dbg_check_lprops(struct ubifs_info *c); 307int dbg_check_lprops(struct ubifs_info *c);
302int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot); 308int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot);
303int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot); 309int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot);
@@ -439,6 +445,8 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c);
439 445
440#define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0 446#define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0
441#define dbg_old_index_check_init(c, zroot) 0 447#define dbg_old_index_check_init(c, zroot) 0
448#define dbg_save_space_info(c) ({})
449#define dbg_check_space_info(c) 0
442#define dbg_check_old_index(c, zroot) 0 450#define dbg_check_old_index(c, zroot) 0
443#define dbg_check_cats(c) 0 451#define dbg_check_cats(c) 0
444#define dbg_check_ltab(c) 0 452#define dbg_check_ltab(c) 0
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index f448ab1f9c38..f55d523c52bb 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -482,30 +482,29 @@ static int ubifs_dir_release(struct inode *dir, struct file *file)
482} 482}
483 483
484/** 484/**
485 * lock_2_inodes - lock two UBIFS inodes. 485 * lock_2_inodes - a wrapper for locking two UBIFS inodes.
486 * @inode1: first inode 486 * @inode1: first inode
487 * @inode2: second inode 487 * @inode2: second inode
488 *
489 * We do not implement any tricks to guarantee strict lock ordering, because
490 * VFS has already done it for us on the @i_mutex. So this is just a simple
491 * wrapper function.
488 */ 492 */
489static void lock_2_inodes(struct inode *inode1, struct inode *inode2) 493static void lock_2_inodes(struct inode *inode1, struct inode *inode2)
490{ 494{
491 if (inode1->i_ino < inode2->i_ino) { 495 mutex_lock_nested(&ubifs_inode(inode1)->ui_mutex, WB_MUTEX_1);
492 mutex_lock_nested(&ubifs_inode(inode1)->ui_mutex, WB_MUTEX_2); 496 mutex_lock_nested(&ubifs_inode(inode2)->ui_mutex, WB_MUTEX_2);
493 mutex_lock_nested(&ubifs_inode(inode2)->ui_mutex, WB_MUTEX_3);
494 } else {
495 mutex_lock_nested(&ubifs_inode(inode2)->ui_mutex, WB_MUTEX_2);
496 mutex_lock_nested(&ubifs_inode(inode1)->ui_mutex, WB_MUTEX_3);
497 }
498} 497}
499 498
500/** 499/**
501 * unlock_2_inodes - unlock two UBIFS inodes inodes. 500 * unlock_2_inodes - a wrapper for unlocking two UBIFS inodes.
502 * @inode1: first inode 501 * @inode1: first inode
503 * @inode2: second inode 502 * @inode2: second inode
504 */ 503 */
505static void unlock_2_inodes(struct inode *inode1, struct inode *inode2) 504static void unlock_2_inodes(struct inode *inode1, struct inode *inode2)
506{ 505{
507 mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
508 mutex_unlock(&ubifs_inode(inode2)->ui_mutex); 506 mutex_unlock(&ubifs_inode(inode2)->ui_mutex);
507 mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
509} 508}
510 509
511static int ubifs_link(struct dentry *old_dentry, struct inode *dir, 510static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
@@ -527,6 +526,8 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
527 dbg_gen("dent '%.*s' to ino %lu (nlink %d) in dir ino %lu", 526 dbg_gen("dent '%.*s' to ino %lu (nlink %d) in dir ino %lu",
528 dentry->d_name.len, dentry->d_name.name, inode->i_ino, 527 dentry->d_name.len, dentry->d_name.name, inode->i_ino,
529 inode->i_nlink, dir->i_ino); 528 inode->i_nlink, dir->i_ino);
529 ubifs_assert(mutex_is_locked(&dir->i_mutex));
530 ubifs_assert(mutex_is_locked(&inode->i_mutex));
530 err = dbg_check_synced_i_size(inode); 531 err = dbg_check_synced_i_size(inode);
531 if (err) 532 if (err)
532 return err; 533 return err;
@@ -580,6 +581,8 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
580 dbg_gen("dent '%.*s' from ino %lu (nlink %d) in dir ino %lu", 581 dbg_gen("dent '%.*s' from ino %lu (nlink %d) in dir ino %lu",
581 dentry->d_name.len, dentry->d_name.name, inode->i_ino, 582 dentry->d_name.len, dentry->d_name.name, inode->i_ino,
582 inode->i_nlink, dir->i_ino); 583 inode->i_nlink, dir->i_ino);
584 ubifs_assert(mutex_is_locked(&dir->i_mutex));
585 ubifs_assert(mutex_is_locked(&inode->i_mutex));
583 err = dbg_check_synced_i_size(inode); 586 err = dbg_check_synced_i_size(inode);
584 if (err) 587 if (err)
585 return err; 588 return err;
@@ -667,7 +670,8 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
667 670
668 dbg_gen("directory '%.*s', ino %lu in dir ino %lu", dentry->d_name.len, 671 dbg_gen("directory '%.*s', ino %lu in dir ino %lu", dentry->d_name.len,
669 dentry->d_name.name, inode->i_ino, dir->i_ino); 672 dentry->d_name.name, inode->i_ino, dir->i_ino);
670 673 ubifs_assert(mutex_is_locked(&dir->i_mutex));
674 ubifs_assert(mutex_is_locked(&inode->i_mutex));
671 err = check_dir_empty(c, dentry->d_inode); 675 err = check_dir_empty(c, dentry->d_inode);
672 if (err) 676 if (err)
673 return err; 677 return err;
@@ -922,59 +926,30 @@ out_budg:
922} 926}
923 927
924/** 928/**
925 * lock_3_inodes - lock three UBIFS inodes for rename. 929 * lock_3_inodes - a wrapper for locking three UBIFS inodes.
926 * @inode1: first inode 930 * @inode1: first inode
927 * @inode2: second inode 931 * @inode2: second inode
928 * @inode3: third inode 932 * @inode3: third inode
929 * 933 *
930 * For 'ubifs_rename()', @inode1 may be the same as @inode2 whereas @inode3 may 934 * This function is used for 'ubifs_rename()' and @inode1 may be the same as
931 * be null. 935 * @inode2 whereas @inode3 may be %NULL.
936 *
937 * We do not implement any tricks to guarantee strict lock ordering, because
938 * VFS has already done it for us on the @i_mutex. So this is just a simple
939 * wrapper function.
932 */ 940 */
933static void lock_3_inodes(struct inode *inode1, struct inode *inode2, 941static void lock_3_inodes(struct inode *inode1, struct inode *inode2,
934 struct inode *inode3) 942 struct inode *inode3)
935{ 943{
936 struct inode *i1, *i2, *i3; 944 mutex_lock_nested(&ubifs_inode(inode1)->ui_mutex, WB_MUTEX_1);
937 945 if (inode2 != inode1)
938 if (!inode3) { 946 mutex_lock_nested(&ubifs_inode(inode2)->ui_mutex, WB_MUTEX_2);
939 if (inode1 != inode2) { 947 if (inode3)
940 lock_2_inodes(inode1, inode2); 948 mutex_lock_nested(&ubifs_inode(inode3)->ui_mutex, WB_MUTEX_3);
941 return;
942 }
943 mutex_lock_nested(&ubifs_inode(inode1)->ui_mutex, WB_MUTEX_1);
944 return;
945 }
946
947 if (inode1 == inode2) {
948 lock_2_inodes(inode1, inode3);
949 return;
950 }
951
952 /* 3 different inodes */
953 if (inode1 < inode2) {
954 i3 = inode2;
955 if (inode1 < inode3) {
956 i1 = inode1;
957 i2 = inode3;
958 } else {
959 i1 = inode3;
960 i2 = inode1;
961 }
962 } else {
963 i3 = inode1;
964 if (inode2 < inode3) {
965 i1 = inode2;
966 i2 = inode3;
967 } else {
968 i1 = inode3;
969 i2 = inode2;
970 }
971 }
972 mutex_lock_nested(&ubifs_inode(i1)->ui_mutex, WB_MUTEX_1);
973 lock_2_inodes(i2, i3);
974} 949}
975 950
976/** 951/**
977 * unlock_3_inodes - unlock three UBIFS inodes for rename. 952 * unlock_3_inodes - a wrapper for unlocking three UBIFS inodes for rename.
978 * @inode1: first inode 953 * @inode1: first inode
979 * @inode2: second inode 954 * @inode2: second inode
980 * @inode3: third inode 955 * @inode3: third inode
@@ -982,11 +957,11 @@ static void lock_3_inodes(struct inode *inode1, struct inode *inode2,
982static void unlock_3_inodes(struct inode *inode1, struct inode *inode2, 957static void unlock_3_inodes(struct inode *inode1, struct inode *inode2,
983 struct inode *inode3) 958 struct inode *inode3)
984{ 959{
985 mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
986 if (inode1 != inode2)
987 mutex_unlock(&ubifs_inode(inode2)->ui_mutex);
988 if (inode3) 960 if (inode3)
989 mutex_unlock(&ubifs_inode(inode3)->ui_mutex); 961 mutex_unlock(&ubifs_inode(inode3)->ui_mutex);
962 if (inode1 != inode2)
963 mutex_unlock(&ubifs_inode(inode2)->ui_mutex);
964 mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
990} 965}
991 966
992static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry, 967static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
@@ -1020,6 +995,11 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
1020 "dir ino %lu", old_dentry->d_name.len, old_dentry->d_name.name, 995 "dir ino %lu", old_dentry->d_name.len, old_dentry->d_name.name,
1021 old_inode->i_ino, old_dir->i_ino, new_dentry->d_name.len, 996 old_inode->i_ino, old_dir->i_ino, new_dentry->d_name.len,
1022 new_dentry->d_name.name, new_dir->i_ino); 997 new_dentry->d_name.name, new_dir->i_ino);
998 ubifs_assert(mutex_is_locked(&old_dir->i_mutex));
999 ubifs_assert(mutex_is_locked(&new_dir->i_mutex));
1000 if (unlink)
1001 ubifs_assert(mutex_is_locked(&new_inode->i_mutex));
1002
1023 1003
1024 if (unlink && is_dir) { 1004 if (unlink && is_dir) {
1025 err = check_dir_empty(c, new_inode); 1005 err = check_dir_empty(c, new_inode);
@@ -1199,7 +1179,7 @@ int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1199 return 0; 1179 return 0;
1200} 1180}
1201 1181
1202struct inode_operations ubifs_dir_inode_operations = { 1182const struct inode_operations ubifs_dir_inode_operations = {
1203 .lookup = ubifs_lookup, 1183 .lookup = ubifs_lookup,
1204 .create = ubifs_create, 1184 .create = ubifs_create,
1205 .link = ubifs_link, 1185 .link = ubifs_link,
@@ -1219,7 +1199,7 @@ struct inode_operations ubifs_dir_inode_operations = {
1219#endif 1199#endif
1220}; 1200};
1221 1201
1222struct file_operations ubifs_dir_operations = { 1202const struct file_operations ubifs_dir_operations = {
1223 .llseek = ubifs_dir_llseek, 1203 .llseek = ubifs_dir_llseek,
1224 .release = ubifs_dir_release, 1204 .release = ubifs_dir_release,
1225 .read = generic_read_dir, 1205 .read = generic_read_dir,
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index bf37374567fa..93b6de51f261 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -432,7 +432,6 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
432 int uninitialized_var(err), appending = !!(pos + len > inode->i_size); 432 int uninitialized_var(err), appending = !!(pos + len > inode->i_size);
433 struct page *page; 433 struct page *page;
434 434
435
436 ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size); 435 ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size);
437 436
438 if (unlikely(c->ro_media)) 437 if (unlikely(c->ro_media))
@@ -1541,7 +1540,7 @@ static int ubifs_file_mmap(struct file *file, struct vm_area_struct *vma)
1541 return 0; 1540 return 0;
1542} 1541}
1543 1542
1544struct address_space_operations ubifs_file_address_operations = { 1543const struct address_space_operations ubifs_file_address_operations = {
1545 .readpage = ubifs_readpage, 1544 .readpage = ubifs_readpage,
1546 .writepage = ubifs_writepage, 1545 .writepage = ubifs_writepage,
1547 .write_begin = ubifs_write_begin, 1546 .write_begin = ubifs_write_begin,
@@ -1551,7 +1550,7 @@ struct address_space_operations ubifs_file_address_operations = {
1551 .releasepage = ubifs_releasepage, 1550 .releasepage = ubifs_releasepage,
1552}; 1551};
1553 1552
1554struct inode_operations ubifs_file_inode_operations = { 1553const struct inode_operations ubifs_file_inode_operations = {
1555 .setattr = ubifs_setattr, 1554 .setattr = ubifs_setattr,
1556 .getattr = ubifs_getattr, 1555 .getattr = ubifs_getattr,
1557#ifdef CONFIG_UBIFS_FS_XATTR 1556#ifdef CONFIG_UBIFS_FS_XATTR
@@ -1562,14 +1561,14 @@ struct inode_operations ubifs_file_inode_operations = {
1562#endif 1561#endif
1563}; 1562};
1564 1563
1565struct inode_operations ubifs_symlink_inode_operations = { 1564const struct inode_operations ubifs_symlink_inode_operations = {
1566 .readlink = generic_readlink, 1565 .readlink = generic_readlink,
1567 .follow_link = ubifs_follow_link, 1566 .follow_link = ubifs_follow_link,
1568 .setattr = ubifs_setattr, 1567 .setattr = ubifs_setattr,
1569 .getattr = ubifs_getattr, 1568 .getattr = ubifs_getattr,
1570}; 1569};
1571 1570
1572struct file_operations ubifs_file_operations = { 1571const struct file_operations ubifs_file_operations = {
1573 .llseek = generic_file_llseek, 1572 .llseek = generic_file_llseek,
1574 .read = do_sync_read, 1573 .read = do_sync_read,
1575 .write = do_sync_write, 1574 .write = do_sync_write,
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 9832f9abe28e..a711d33b3d3e 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -31,6 +31,26 @@
31 * to be reused. Garbage collection will cause the number of dirty index nodes 31 * to be reused. Garbage collection will cause the number of dirty index nodes
32 * to grow, however sufficient space is reserved for the index to ensure the 32 * to grow, however sufficient space is reserved for the index to ensure the
33 * commit will never run out of space. 33 * commit will never run out of space.
34 *
35 * Notes about dead watermark. At current UBIFS implementation we assume that
36 * LEBs which have less than @c->dead_wm bytes of free + dirty space are full
37 * and not worth garbage-collecting. The dead watermark is one min. I/O unit
38 * size, or min. UBIFS node size, depending on what is greater. Indeed, UBIFS
39 * Garbage Collector has to synchronize the GC head's write buffer before
40 * returning, so this is about wasting one min. I/O unit. However, UBIFS GC can
41 * actually reclaim even very small pieces of dirty space by garbage collecting
42 * enough dirty LEBs, but we do not bother doing this at this implementation.
43 *
44 * Notes about dark watermark. The results of GC work depends on how big are
45 * the UBIFS nodes GC deals with. Large nodes make GC waste more space. Indeed,
46 * if GC move data from LEB A to LEB B and nodes in LEB A are large, GC would
47 * have to waste large pieces of free space at the end of LEB B, because nodes
48 * from LEB A would not fit. And the worst situation is when all nodes are of
49 * maximum size. So dark watermark is the amount of free + dirty space in LEB
50 * which are guaranteed to be reclaimable. If LEB has less space, the GC migh
51 * be unable to reclaim it. So, LEBs with free + dirty greater than dark
52 * watermark are "good" LEBs from GC's point of few. The other LEBs are not so
53 * good, and GC takes extra care when moving them.
34 */ 54 */
35 55
36#include <linux/pagemap.h> 56#include <linux/pagemap.h>
@@ -381,7 +401,7 @@ int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp)
381 401
382 /* 402 /*
383 * Don't release the LEB until after the next commit, because 403 * Don't release the LEB until after the next commit, because
384 * it may contain date which is needed for recovery. So 404 * it may contain data which is needed for recovery. So
385 * although we freed this LEB, it will become usable only after 405 * although we freed this LEB, it will become usable only after
386 * the commit. 406 * the commit.
387 */ 407 */
@@ -810,8 +830,9 @@ out:
810 * ubifs_destroy_idx_gc - destroy idx_gc list. 830 * ubifs_destroy_idx_gc - destroy idx_gc list.
811 * @c: UBIFS file-system description object 831 * @c: UBIFS file-system description object
812 * 832 *
813 * This function destroys the idx_gc list. It is called when unmounting or 833 * This function destroys the @c->idx_gc list. It is called when unmounting
814 * remounting read-only so locks are not needed. 834 * so locks are not needed. Returns zero in case of success and a negative
835 * error code in case of failure.
815 */ 836 */
816void ubifs_destroy_idx_gc(struct ubifs_info *c) 837void ubifs_destroy_idx_gc(struct ubifs_info *c)
817{ 838{
@@ -824,7 +845,6 @@ void ubifs_destroy_idx_gc(struct ubifs_info *c)
824 list_del(&idx_gc->list); 845 list_del(&idx_gc->list);
825 kfree(idx_gc); 846 kfree(idx_gc);
826 } 847 }
827
828} 848}
829 849
830/** 850/**
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index 01682713af69..e8e632a1dcdf 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -29,7 +29,7 @@
29 * would have been wasted for padding to the nearest minimal I/O unit boundary. 29 * would have been wasted for padding to the nearest minimal I/O unit boundary.
30 * Instead, data first goes to the write-buffer and is flushed when the 30 * Instead, data first goes to the write-buffer and is flushed when the
31 * buffer is full or when it is not used for some time (by timer). This is 31 * buffer is full or when it is not used for some time (by timer). This is
32 * similarto the mechanism is used by JFFS2. 32 * similar to the mechanism is used by JFFS2.
33 * 33 *
34 * Write-buffers are defined by 'struct ubifs_wbuf' objects and protected by 34 * Write-buffers are defined by 'struct ubifs_wbuf' objects and protected by
35 * mutexes defined inside these objects. Since sometimes upper-level code 35 * mutexes defined inside these objects. Since sometimes upper-level code
@@ -75,7 +75,7 @@ void ubifs_ro_mode(struct ubifs_info *c, int err)
75 * @lnum: logical eraseblock number 75 * @lnum: logical eraseblock number
76 * @offs: offset within the logical eraseblock 76 * @offs: offset within the logical eraseblock
77 * @quiet: print no messages 77 * @quiet: print no messages
78 * @chk_crc: indicates whether to always check the CRC 78 * @must_chk_crc: indicates whether to always check the CRC
79 * 79 *
80 * This function checks node magic number and CRC checksum. This function also 80 * This function checks node magic number and CRC checksum. This function also
81 * validates node length to prevent UBIFS from becoming crazy when an attacker 81 * validates node length to prevent UBIFS from becoming crazy when an attacker
@@ -83,11 +83,17 @@ void ubifs_ro_mode(struct ubifs_info *c, int err)
83 * node length in the common header could cause UBIFS to read memory outside of 83 * node length in the common header could cause UBIFS to read memory outside of
84 * allocated buffer when checking the CRC checksum. 84 * allocated buffer when checking the CRC checksum.
85 * 85 *
86 * This function returns zero in case of success %-EUCLEAN in case of bad CRC 86 * This function may skip data nodes CRC checking if @c->no_chk_data_crc is
87 * or magic. 87 * true, which is controlled by corresponding UBIFS mount option. However, if
88 * @must_chk_crc is true, then @c->no_chk_data_crc is ignored and CRC is
89 * checked. Similarly, if @c->always_chk_crc is true, @c->no_chk_data_crc is
90 * ignored and CRC is checked.
91 *
92 * This function returns zero in case of success and %-EUCLEAN in case of bad
93 * CRC or magic.
88 */ 94 */
89int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, 95int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum,
90 int offs, int quiet, int chk_crc) 96 int offs, int quiet, int must_chk_crc)
91{ 97{
92 int err = -EINVAL, type, node_len; 98 int err = -EINVAL, type, node_len;
93 uint32_t crc, node_crc, magic; 99 uint32_t crc, node_crc, magic;
@@ -123,9 +129,9 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum,
123 node_len > c->ranges[type].max_len) 129 node_len > c->ranges[type].max_len)
124 goto out_len; 130 goto out_len;
125 131
126 if (!chk_crc && type == UBIFS_DATA_NODE && !c->always_chk_crc) 132 if (!must_chk_crc && type == UBIFS_DATA_NODE && !c->always_chk_crc &&
127 if (c->no_chk_data_crc) 133 c->no_chk_data_crc)
128 return 0; 134 return 0;
129 135
130 crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); 136 crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8);
131 node_crc = le32_to_cpu(ch->crc); 137 node_crc = le32_to_cpu(ch->crc);
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 9b7c54e0cd2a..a11ca0958a23 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -208,7 +208,7 @@ again:
208 offs = 0; 208 offs = 0;
209 209
210out: 210out:
211 err = ubifs_wbuf_seek_nolock(wbuf, lnum, offs, UBI_SHORTTERM); 211 err = ubifs_wbuf_seek_nolock(wbuf, lnum, offs, wbuf->dtype);
212 if (err) 212 if (err)
213 goto out_unlock; 213 goto out_unlock;
214 214
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index dfd2bcece27a..4cdd284dea56 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -635,10 +635,10 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c,
635 * @c: UBIFS file-system description object 635 * @c: UBIFS file-system description object
636 * @st: return statistics 636 * @st: return statistics
637 */ 637 */
638void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *st) 638void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst)
639{ 639{
640 spin_lock(&c->space_lock); 640 spin_lock(&c->space_lock);
641 memcpy(st, &c->lst, sizeof(struct ubifs_lp_stats)); 641 memcpy(lst, &c->lst, sizeof(struct ubifs_lp_stats));
642 spin_unlock(&c->space_lock); 642 spin_unlock(&c->space_lock);
643} 643}
644 644
@@ -678,6 +678,9 @@ int ubifs_change_one_lp(struct ubifs_info *c, int lnum, int free, int dirty,
678 678
679out: 679out:
680 ubifs_release_lprops(c); 680 ubifs_release_lprops(c);
681 if (err)
682 ubifs_err("cannot change properties of LEB %d, error %d",
683 lnum, err);
681 return err; 684 return err;
682} 685}
683 686
@@ -714,6 +717,9 @@ int ubifs_update_one_lp(struct ubifs_info *c, int lnum, int free, int dirty,
714 717
715out: 718out:
716 ubifs_release_lprops(c); 719 ubifs_release_lprops(c);
720 if (err)
721 ubifs_err("cannot update properties of LEB %d, error %d",
722 lnum, err);
717 return err; 723 return err;
718} 724}
719 725
@@ -737,6 +743,8 @@ int ubifs_read_one_lp(struct ubifs_info *c, int lnum, struct ubifs_lprops *lp)
737 lpp = ubifs_lpt_lookup(c, lnum); 743 lpp = ubifs_lpt_lookup(c, lnum);
738 if (IS_ERR(lpp)) { 744 if (IS_ERR(lpp)) {
739 err = PTR_ERR(lpp); 745 err = PTR_ERR(lpp);
746 ubifs_err("cannot read properties of LEB %d, error %d",
747 lnum, err);
740 goto out; 748 goto out;
741 } 749 }
742 750
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index 96ca95707175..3216a1f277f8 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -556,23 +556,23 @@ no_space:
556} 556}
557 557
558/** 558/**
559 * next_pnode - find next pnode. 559 * next_pnode_to_dirty - find next pnode to dirty.
560 * @c: UBIFS file-system description object 560 * @c: UBIFS file-system description object
561 * @pnode: pnode 561 * @pnode: pnode
562 * 562 *
563 * This function returns the next pnode or %NULL if there are no more pnodes. 563 * This function returns the next pnode to dirty or %NULL if there are no more
564 * pnodes. Note that pnodes that have never been written (lnum == 0) are
565 * skipped.
564 */ 566 */
565static struct ubifs_pnode *next_pnode(struct ubifs_info *c, 567static struct ubifs_pnode *next_pnode_to_dirty(struct ubifs_info *c,
566 struct ubifs_pnode *pnode) 568 struct ubifs_pnode *pnode)
567{ 569{
568 struct ubifs_nnode *nnode; 570 struct ubifs_nnode *nnode;
569 int iip; 571 int iip;
570 572
571 /* Try to go right */ 573 /* Try to go right */
572 nnode = pnode->parent; 574 nnode = pnode->parent;
573 iip = pnode->iip + 1; 575 for (iip = pnode->iip + 1; iip < UBIFS_LPT_FANOUT; iip++) {
574 if (iip < UBIFS_LPT_FANOUT) {
575 /* We assume here that LEB zero is never an LPT LEB */
576 if (nnode->nbranch[iip].lnum) 576 if (nnode->nbranch[iip].lnum)
577 return ubifs_get_pnode(c, nnode, iip); 577 return ubifs_get_pnode(c, nnode, iip);
578 } 578 }
@@ -583,8 +583,11 @@ static struct ubifs_pnode *next_pnode(struct ubifs_info *c,
583 nnode = nnode->parent; 583 nnode = nnode->parent;
584 if (!nnode) 584 if (!nnode)
585 return NULL; 585 return NULL;
586 /* We assume here that LEB zero is never an LPT LEB */ 586 for (; iip < UBIFS_LPT_FANOUT; iip++) {
587 } while (iip >= UBIFS_LPT_FANOUT || !nnode->nbranch[iip].lnum); 587 if (nnode->nbranch[iip].lnum)
588 break;
589 }
590 } while (iip >= UBIFS_LPT_FANOUT);
588 591
589 /* Go right */ 592 /* Go right */
590 nnode = ubifs_get_nnode(c, nnode, iip); 593 nnode = ubifs_get_nnode(c, nnode, iip);
@@ -593,12 +596,29 @@ static struct ubifs_pnode *next_pnode(struct ubifs_info *c,
593 596
594 /* Go down to level 1 */ 597 /* Go down to level 1 */
595 while (nnode->level > 1) { 598 while (nnode->level > 1) {
596 nnode = ubifs_get_nnode(c, nnode, 0); 599 for (iip = 0; iip < UBIFS_LPT_FANOUT; iip++) {
600 if (nnode->nbranch[iip].lnum)
601 break;
602 }
603 if (iip >= UBIFS_LPT_FANOUT) {
604 /*
605 * Should not happen, but we need to keep going
606 * if it does.
607 */
608 iip = 0;
609 }
610 nnode = ubifs_get_nnode(c, nnode, iip);
597 if (IS_ERR(nnode)) 611 if (IS_ERR(nnode))
598 return (void *)nnode; 612 return (void *)nnode;
599 } 613 }
600 614
601 return ubifs_get_pnode(c, nnode, 0); 615 for (iip = 0; iip < UBIFS_LPT_FANOUT; iip++)
616 if (nnode->nbranch[iip].lnum)
617 break;
618 if (iip >= UBIFS_LPT_FANOUT)
619 /* Should not happen, but we need to keep going if it does */
620 iip = 0;
621 return ubifs_get_pnode(c, nnode, iip);
602} 622}
603 623
604/** 624/**
@@ -688,7 +708,7 @@ static int make_tree_dirty(struct ubifs_info *c)
688 pnode = pnode_lookup(c, 0); 708 pnode = pnode_lookup(c, 0);
689 while (pnode) { 709 while (pnode) {
690 do_make_pnode_dirty(c, pnode); 710 do_make_pnode_dirty(c, pnode);
691 pnode = next_pnode(c, pnode); 711 pnode = next_pnode_to_dirty(c, pnode);
692 if (IS_ERR(pnode)) 712 if (IS_ERR(pnode))
693 return PTR_ERR(pnode); 713 return PTR_ERR(pnode);
694 } 714 }
diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c
index 71d5493bf565..a88f33801b98 100644
--- a/fs/ubifs/master.c
+++ b/fs/ubifs/master.c
@@ -354,7 +354,7 @@ int ubifs_write_master(struct ubifs_info *c)
354 int err, lnum, offs, len; 354 int err, lnum, offs, len;
355 355
356 if (c->ro_media) 356 if (c->ro_media)
357 return -EINVAL; 357 return -EROFS;
358 358
359 lnum = UBIFS_MST_LNUM; 359 lnum = UBIFS_MST_LNUM;
360 offs = c->mst_offs + c->mst_node_alsz; 360 offs = c->mst_offs + c->mst_node_alsz;
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c
index 9e6f403f170e..152a7b34a141 100644
--- a/fs/ubifs/orphan.c
+++ b/fs/ubifs/orphan.c
@@ -46,7 +46,7 @@
46 * Orphans are accumulated in a rb-tree. When an inode's link count drops to 46 * Orphans are accumulated in a rb-tree. When an inode's link count drops to
47 * zero, the inode number is added to the rb-tree. It is removed from the tree 47 * zero, the inode number is added to the rb-tree. It is removed from the tree
48 * when the inode is deleted. Any new orphans that are in the orphan tree when 48 * when the inode is deleted. Any new orphans that are in the orphan tree when
49 * the commit is run, are written to the orphan area in 1 or more orph nodes. 49 * the commit is run, are written to the orphan area in 1 or more orphan nodes.
50 * If the orphan area is full, it is consolidated to make space. There is 50 * If the orphan area is full, it is consolidated to make space. There is
51 * always enough space because validation prevents the user from creating more 51 * always enough space because validation prevents the user from creating more
52 * than the maximum number of orphans allowed. 52 * than the maximum number of orphans allowed.
@@ -231,7 +231,7 @@ static int tot_avail_orphs(struct ubifs_info *c)
231} 231}
232 232
233/** 233/**
234 * do_write_orph_node - write a node 234 * do_write_orph_node - write a node to the orphan head.
235 * @c: UBIFS file-system description object 235 * @c: UBIFS file-system description object
236 * @len: length of node 236 * @len: length of node
237 * @atomic: write atomically 237 * @atomic: write atomically
@@ -264,11 +264,11 @@ static int do_write_orph_node(struct ubifs_info *c, int len, int atomic)
264} 264}
265 265
266/** 266/**
267 * write_orph_node - write an orph node 267 * write_orph_node - write an orphan node.
268 * @c: UBIFS file-system description object 268 * @c: UBIFS file-system description object
269 * @atomic: write atomically 269 * @atomic: write atomically
270 * 270 *
271 * This function builds an orph node from the cnext list and writes it to the 271 * This function builds an orphan node from the cnext list and writes it to the
272 * orphan head. On success, %0 is returned, otherwise a negative error code 272 * orphan head. On success, %0 is returned, otherwise a negative error code
273 * is returned. 273 * is returned.
274 */ 274 */
@@ -326,11 +326,11 @@ static int write_orph_node(struct ubifs_info *c, int atomic)
326} 326}
327 327
328/** 328/**
329 * write_orph_nodes - write orph nodes until there are no more to commit 329 * write_orph_nodes - write orphan nodes until there are no more to commit.
330 * @c: UBIFS file-system description object 330 * @c: UBIFS file-system description object
331 * @atomic: write atomically 331 * @atomic: write atomically
332 * 332 *
333 * This function writes orph nodes for all the orphans to commit. On success, 333 * This function writes orphan nodes for all the orphans to commit. On success,
334 * %0 is returned, otherwise a negative error code is returned. 334 * %0 is returned, otherwise a negative error code is returned.
335 */ 335 */
336static int write_orph_nodes(struct ubifs_info *c, int atomic) 336static int write_orph_nodes(struct ubifs_info *c, int atomic)
@@ -478,14 +478,14 @@ int ubifs_orphan_end_commit(struct ubifs_info *c)
478} 478}
479 479
480/** 480/**
481 * clear_orphans - erase all LEBs used for orphans. 481 * ubifs_clear_orphans - erase all LEBs used for orphans.
482 * @c: UBIFS file-system description object 482 * @c: UBIFS file-system description object
483 * 483 *
484 * If recovery is not required, then the orphans from the previous session 484 * If recovery is not required, then the orphans from the previous session
485 * are not needed. This function locates the LEBs used to record 485 * are not needed. This function locates the LEBs used to record
486 * orphans, and un-maps them. 486 * orphans, and un-maps them.
487 */ 487 */
488static int clear_orphans(struct ubifs_info *c) 488int ubifs_clear_orphans(struct ubifs_info *c)
489{ 489{
490 int lnum, err; 490 int lnum, err;
491 491
@@ -547,9 +547,9 @@ static int insert_dead_orphan(struct ubifs_info *c, ino_t inum)
547 * do_kill_orphans - remove orphan inodes from the index. 547 * do_kill_orphans - remove orphan inodes from the index.
548 * @c: UBIFS file-system description object 548 * @c: UBIFS file-system description object
549 * @sleb: scanned LEB 549 * @sleb: scanned LEB
550 * @last_cmt_no: cmt_no of last orph node read is passed and returned here 550 * @last_cmt_no: cmt_no of last orphan node read is passed and returned here
551 * @outofdate: whether the LEB is out of date is returned here 551 * @outofdate: whether the LEB is out of date is returned here
552 * @last_flagged: whether the end orph node is encountered 552 * @last_flagged: whether the end orphan node is encountered
553 * 553 *
554 * This function is a helper to the 'kill_orphans()' function. It goes through 554 * This function is a helper to the 'kill_orphans()' function. It goes through
555 * every orphan node in a LEB and for every inode number recorded, removes 555 * every orphan node in a LEB and for every inode number recorded, removes
@@ -580,8 +580,8 @@ static int do_kill_orphans(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
580 /* 580 /*
581 * The commit number on the master node may be less, because 581 * The commit number on the master node may be less, because
582 * of a failed commit. If there are several failed commits in a 582 * of a failed commit. If there are several failed commits in a
583 * row, the commit number written on orph nodes will continue to 583 * row, the commit number written on orphan nodes will continue
584 * increase (because the commit number is adjusted here) even 584 * to increase (because the commit number is adjusted here) even
585 * though the commit number on the master node stays the same 585 * though the commit number on the master node stays the same
586 * because the master node has not been re-written. 586 * because the master node has not been re-written.
587 */ 587 */
@@ -589,9 +589,9 @@ static int do_kill_orphans(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
589 c->cmt_no = cmt_no; 589 c->cmt_no = cmt_no;
590 if (cmt_no < *last_cmt_no && *last_flagged) { 590 if (cmt_no < *last_cmt_no && *last_flagged) {
591 /* 591 /*
592 * The last orph node had a higher commit number and was 592 * The last orphan node had a higher commit number and
593 * flagged as the last written for that commit number. 593 * was flagged as the last written for that commit
594 * That makes this orph node, out of date. 594 * number. That makes this orphan node, out of date.
595 */ 595 */
596 if (!first) { 596 if (!first) {
597 ubifs_err("out of order commit number %llu in " 597 ubifs_err("out of order commit number %llu in "
@@ -658,10 +658,10 @@ static int kill_orphans(struct ubifs_info *c)
658 /* 658 /*
659 * Orph nodes always start at c->orph_first and are written to each 659 * Orph nodes always start at c->orph_first and are written to each
660 * successive LEB in turn. Generally unused LEBs will have been unmapped 660 * successive LEB in turn. Generally unused LEBs will have been unmapped
661 * but may contain out of date orph nodes if the unmap didn't go 661 * but may contain out of date orphan nodes if the unmap didn't go
662 * through. In addition, the last orph node written for each commit is 662 * through. In addition, the last orphan node written for each commit is
663 * marked (top bit of orph->cmt_no is set to 1). It is possible that 663 * marked (top bit of orph->cmt_no is set to 1). It is possible that
664 * there are orph nodes from the next commit (i.e. the commit did not 664 * there are orphan nodes from the next commit (i.e. the commit did not
665 * complete successfully). In that case, no orphans will have been lost 665 * complete successfully). In that case, no orphans will have been lost
666 * due to the way that orphans are written, and any orphans added will 666 * due to the way that orphans are written, and any orphans added will
667 * be valid orphans anyway and so can be deleted. 667 * be valid orphans anyway and so can be deleted.
@@ -718,7 +718,7 @@ int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only)
718 if (unclean) 718 if (unclean)
719 err = kill_orphans(c); 719 err = kill_orphans(c);
720 else if (!read_only) 720 else if (!read_only)
721 err = clear_orphans(c); 721 err = ubifs_clear_orphans(c);
722 722
723 return err; 723 return err;
724} 724}
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 89556ee72518..1182b66a5491 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -397,6 +397,7 @@ static int ubifs_statfs(struct dentry *dentry, struct kstatfs *buf)
397 buf->f_namelen = UBIFS_MAX_NLEN; 397 buf->f_namelen = UBIFS_MAX_NLEN;
398 buf->f_fsid.val[0] = le32_to_cpu(uuid[0]) ^ le32_to_cpu(uuid[2]); 398 buf->f_fsid.val[0] = le32_to_cpu(uuid[0]) ^ le32_to_cpu(uuid[2]);
399 buf->f_fsid.val[1] = le32_to_cpu(uuid[1]) ^ le32_to_cpu(uuid[3]); 399 buf->f_fsid.val[1] = le32_to_cpu(uuid[1]) ^ le32_to_cpu(uuid[3]);
400 ubifs_assert(buf->f_bfree <= c->block_cnt);
400 return 0; 401 return 0;
401} 402}
402 403
@@ -432,33 +433,24 @@ static int ubifs_sync_fs(struct super_block *sb, int wait)
432 int i, err; 433 int i, err;
433 struct ubifs_info *c = sb->s_fs_info; 434 struct ubifs_info *c = sb->s_fs_info;
434 struct writeback_control wbc = { 435 struct writeback_control wbc = {
435 .sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_NONE, 436 .sync_mode = WB_SYNC_ALL,
436 .range_start = 0, 437 .range_start = 0,
437 .range_end = LLONG_MAX, 438 .range_end = LLONG_MAX,
438 .nr_to_write = LONG_MAX, 439 .nr_to_write = LONG_MAX,
439 }; 440 };
440 441
441 /* 442 /*
442 * Note by akpm about WB_SYNC_NONE used above: zero @wait is just an 443 * Zero @wait is just an advisory thing to help the file system shove
443 * advisory thing to help the file system shove lots of data into the 444 * lots of data into the queues, and there will be the second
444 * queues. If some gets missed then it'll be picked up on the second
445 * '->sync_fs()' call, with non-zero @wait. 445 * '->sync_fs()' call, with non-zero @wait.
446 */ 446 */
447 if (!wait)
448 return 0;
447 449
448 if (sb->s_flags & MS_RDONLY) 450 if (sb->s_flags & MS_RDONLY)
449 return 0; 451 return 0;
450 452
451 /* 453 /*
452 * Synchronize write buffers, because 'ubifs_run_commit()' does not
453 * do this if it waits for an already running commit.
454 */
455 for (i = 0; i < c->jhead_cnt; i++) {
456 err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
457 if (err)
458 return err;
459 }
460
461 /*
462 * VFS calls '->sync_fs()' before synchronizing all dirty inodes and 454 * VFS calls '->sync_fs()' before synchronizing all dirty inodes and
463 * pages, so synchronize them first, then commit the journal. Strictly 455 * pages, so synchronize them first, then commit the journal. Strictly
464 * speaking, it is not necessary to commit the journal here, 456 * speaking, it is not necessary to commit the journal here,
@@ -469,6 +461,16 @@ static int ubifs_sync_fs(struct super_block *sb, int wait)
469 */ 461 */
470 generic_sync_sb_inodes(sb, &wbc); 462 generic_sync_sb_inodes(sb, &wbc);
471 463
464 /*
465 * Synchronize write buffers, because 'ubifs_run_commit()' does not
466 * do this if it waits for an already running commit.
467 */
468 for (i = 0; i < c->jhead_cnt; i++) {
469 err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
470 if (err)
471 return err;
472 }
473
472 err = ubifs_run_commit(c); 474 err = ubifs_run_commit(c);
473 if (err) 475 if (err)
474 return err; 476 return err;
@@ -572,15 +574,8 @@ static int init_constants_early(struct ubifs_info *c)
572 c->ranges[UBIFS_IDX_NODE].max_len = INT_MAX; 574 c->ranges[UBIFS_IDX_NODE].max_len = INT_MAX;
573 575
574 /* 576 /*
575 * Initialize dead and dark LEB space watermarks. 577 * Initialize dead and dark LEB space watermarks. See gc.c for comments
576 * 578 * about these values.
577 * Dead space is the space which cannot be used. Its watermark is
578 * equivalent to min. I/O unit or minimum node size if it is greater
579 * then min. I/O unit.
580 *
581 * Dark space is the space which might be used, or might not, depending
582 * on which node should be written to the LEB. Its watermark is
583 * equivalent to maximum UBIFS node size.
584 */ 579 */
585 c->dead_wm = ALIGN(MIN_WRITE_SZ, c->min_io_size); 580 c->dead_wm = ALIGN(MIN_WRITE_SZ, c->min_io_size);
586 c->dark_wm = ALIGN(UBIFS_MAX_NODE_SZ, c->min_io_size); 581 c->dark_wm = ALIGN(UBIFS_MAX_NODE_SZ, c->min_io_size);
@@ -741,12 +736,12 @@ static void init_constants_master(struct ubifs_info *c)
741 * take_gc_lnum - reserve GC LEB. 736 * take_gc_lnum - reserve GC LEB.
742 * @c: UBIFS file-system description object 737 * @c: UBIFS file-system description object
743 * 738 *
744 * This function ensures that the LEB reserved for garbage collection is 739 * This function ensures that the LEB reserved for garbage collection is marked
745 * unmapped and is marked as "taken" in lprops. We also have to set free space 740 * as "taken" in lprops. We also have to set free space to LEB size and dirty
746 * to LEB size and dirty space to zero, because lprops may contain out-of-date 741 * space to zero, because lprops may contain out-of-date information if the
747 * information if the file-system was un-mounted before it has been committed. 742 * file-system was un-mounted before it has been committed. This function
748 * This function returns zero in case of success and a negative error code in 743 * returns zero in case of success and a negative error code in case of
749 * case of failure. 744 * failure.
750 */ 745 */
751static int take_gc_lnum(struct ubifs_info *c) 746static int take_gc_lnum(struct ubifs_info *c)
752{ 747{
@@ -757,10 +752,6 @@ static int take_gc_lnum(struct ubifs_info *c)
757 return -EINVAL; 752 return -EINVAL;
758 } 753 }
759 754
760 err = ubifs_leb_unmap(c, c->gc_lnum);
761 if (err)
762 return err;
763
764 /* And we have to tell lprops that this LEB is taken */ 755 /* And we have to tell lprops that this LEB is taken */
765 err = ubifs_change_one_lp(c, c->gc_lnum, c->leb_size, 0, 756 err = ubifs_change_one_lp(c, c->gc_lnum, c->leb_size, 0,
766 LPROPS_TAKEN, 0, 0); 757 LPROPS_TAKEN, 0, 0);
@@ -966,13 +957,16 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
966 957
967 token = match_token(p, tokens, args); 958 token = match_token(p, tokens, args);
968 switch (token) { 959 switch (token) {
960 /*
961 * %Opt_fast_unmount and %Opt_norm_unmount options are ignored.
962 * We accepte them in order to be backware-compatible. But this
963 * should be removed at some point.
964 */
969 case Opt_fast_unmount: 965 case Opt_fast_unmount:
970 c->mount_opts.unmount_mode = 2; 966 c->mount_opts.unmount_mode = 2;
971 c->fast_unmount = 1;
972 break; 967 break;
973 case Opt_norm_unmount: 968 case Opt_norm_unmount:
974 c->mount_opts.unmount_mode = 1; 969 c->mount_opts.unmount_mode = 1;
975 c->fast_unmount = 0;
976 break; 970 break;
977 case Opt_bulk_read: 971 case Opt_bulk_read:
978 c->mount_opts.bulk_read = 2; 972 c->mount_opts.bulk_read = 2;
@@ -1094,12 +1088,7 @@ static int check_free_space(struct ubifs_info *c)
1094 ubifs_err("insufficient free space to mount in read/write mode"); 1088 ubifs_err("insufficient free space to mount in read/write mode");
1095 dbg_dump_budg(c); 1089 dbg_dump_budg(c);
1096 dbg_dump_lprops(c); 1090 dbg_dump_lprops(c);
1097 /* 1091 return -ENOSPC;
1098 * We return %-EINVAL instead of %-ENOSPC because it seems to
1099 * be the closest error code mentioned in the mount function
1100 * documentation.
1101 */
1102 return -EINVAL;
1103 } 1092 }
1104 return 0; 1093 return 0;
1105} 1094}
@@ -1286,10 +1275,19 @@ static int mount_ubifs(struct ubifs_info *c)
1286 if (err) 1275 if (err)
1287 goto out_orphans; 1276 goto out_orphans;
1288 err = ubifs_rcvry_gc_commit(c); 1277 err = ubifs_rcvry_gc_commit(c);
1289 } else 1278 } else {
1290 err = take_gc_lnum(c); 1279 err = take_gc_lnum(c);
1291 if (err) 1280 if (err)
1292 goto out_orphans; 1281 goto out_orphans;
1282
1283 /*
1284 * GC LEB may contain garbage if there was an unclean
1285 * reboot, and it should be un-mapped.
1286 */
1287 err = ubifs_leb_unmap(c, c->gc_lnum);
1288 if (err)
1289 return err;
1290 }
1293 1291
1294 err = dbg_check_lprops(c); 1292 err = dbg_check_lprops(c);
1295 if (err) 1293 if (err)
@@ -1298,6 +1296,16 @@ static int mount_ubifs(struct ubifs_info *c)
1298 err = ubifs_recover_size(c); 1296 err = ubifs_recover_size(c);
1299 if (err) 1297 if (err)
1300 goto out_orphans; 1298 goto out_orphans;
1299 } else {
1300 /*
1301 * Even if we mount read-only, we have to set space in GC LEB
1302 * to proper value because this affects UBIFS free space
1303 * reporting. We do not want to have a situation when
1304 * re-mounting from R/O to R/W changes amount of free space.
1305 */
1306 err = take_gc_lnum(c);
1307 if (err)
1308 goto out_orphans;
1301 } 1309 }
1302 1310
1303 spin_lock(&ubifs_infos_lock); 1311 spin_lock(&ubifs_infos_lock);
@@ -1310,14 +1318,17 @@ static int mount_ubifs(struct ubifs_info *c)
1310 else { 1318 else {
1311 c->need_recovery = 0; 1319 c->need_recovery = 0;
1312 ubifs_msg("recovery completed"); 1320 ubifs_msg("recovery completed");
1321 /* GC LEB has to be empty and taken at this point */
1322 ubifs_assert(c->lst.taken_empty_lebs == 1);
1313 } 1323 }
1314 } 1324 } else
1325 ubifs_assert(c->lst.taken_empty_lebs == 1);
1315 1326
1316 err = dbg_debugfs_init_fs(c); 1327 err = dbg_check_filesystem(c);
1317 if (err) 1328 if (err)
1318 goto out_infos; 1329 goto out_infos;
1319 1330
1320 err = dbg_check_filesystem(c); 1331 err = dbg_debugfs_init_fs(c);
1321 if (err) 1332 if (err)
1322 goto out_infos; 1333 goto out_infos;
1323 1334
@@ -1351,7 +1362,6 @@ static int mount_ubifs(struct ubifs_info *c)
1351 c->uuid[4], c->uuid[5], c->uuid[6], c->uuid[7], 1362 c->uuid[4], c->uuid[5], c->uuid[6], c->uuid[7],
1352 c->uuid[8], c->uuid[9], c->uuid[10], c->uuid[11], 1363 c->uuid[8], c->uuid[9], c->uuid[10], c->uuid[11],
1353 c->uuid[12], c->uuid[13], c->uuid[14], c->uuid[15]); 1364 c->uuid[12], c->uuid[13], c->uuid[14], c->uuid[15]);
1354 dbg_msg("fast unmount: %d", c->fast_unmount);
1355 dbg_msg("big_lpt %d", c->big_lpt); 1365 dbg_msg("big_lpt %d", c->big_lpt);
1356 dbg_msg("log LEBs: %d (%d - %d)", 1366 dbg_msg("log LEBs: %d (%d - %d)",
1357 c->log_lebs, UBIFS_LOG_LNUM, c->log_last); 1367 c->log_lebs, UBIFS_LOG_LNUM, c->log_last);
@@ -1475,10 +1485,8 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1475{ 1485{
1476 int err, lnum; 1486 int err, lnum;
1477 1487
1478 if (c->ro_media)
1479 return -EINVAL;
1480
1481 mutex_lock(&c->umount_mutex); 1488 mutex_lock(&c->umount_mutex);
1489 dbg_save_space_info(c);
1482 c->remounting_rw = 1; 1490 c->remounting_rw = 1;
1483 c->always_chk_crc = 1; 1491 c->always_chk_crc = 1;
1484 1492
@@ -1514,6 +1522,12 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1514 err = ubifs_recover_inl_heads(c, c->sbuf); 1522 err = ubifs_recover_inl_heads(c, c->sbuf);
1515 if (err) 1523 if (err)
1516 goto out; 1524 goto out;
1525 } else {
1526 /* A readonly mount is not allowed to have orphans */
1527 ubifs_assert(c->tot_orphans == 0);
1528 err = ubifs_clear_orphans(c);
1529 if (err)
1530 goto out;
1517 } 1531 }
1518 1532
1519 if (!(c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY))) { 1533 if (!(c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY))) {
@@ -1569,7 +1583,7 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1569 if (c->need_recovery) 1583 if (c->need_recovery)
1570 err = ubifs_rcvry_gc_commit(c); 1584 err = ubifs_rcvry_gc_commit(c);
1571 else 1585 else
1572 err = take_gc_lnum(c); 1586 err = ubifs_leb_unmap(c, c->gc_lnum);
1573 if (err) 1587 if (err)
1574 goto out; 1588 goto out;
1575 1589
@@ -1582,8 +1596,9 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1582 c->vfs_sb->s_flags &= ~MS_RDONLY; 1596 c->vfs_sb->s_flags &= ~MS_RDONLY;
1583 c->remounting_rw = 0; 1597 c->remounting_rw = 0;
1584 c->always_chk_crc = 0; 1598 c->always_chk_crc = 0;
1599 err = dbg_check_space_info(c);
1585 mutex_unlock(&c->umount_mutex); 1600 mutex_unlock(&c->umount_mutex);
1586 return 0; 1601 return err;
1587 1602
1588out: 1603out:
1589 vfree(c->orph_buf); 1604 vfree(c->orph_buf);
@@ -1603,43 +1618,18 @@ out:
1603} 1618}
1604 1619
1605/** 1620/**
1606 * commit_on_unmount - commit the journal when un-mounting.
1607 * @c: UBIFS file-system description object
1608 *
1609 * This function is called during un-mounting and re-mounting, and it commits
1610 * the journal unless the "fast unmount" mode is enabled.
1611 */
1612static void commit_on_unmount(struct ubifs_info *c)
1613{
1614 struct super_block *sb = c->vfs_sb;
1615 long long bud_bytes;
1616
1617 /*
1618 * This function is called before the background thread is stopped, so
1619 * we may race with ongoing commit, which means we have to take
1620 * @c->bud_lock to access @c->bud_bytes.
1621 */
1622 spin_lock(&c->buds_lock);
1623 bud_bytes = c->bud_bytes;
1624 spin_unlock(&c->buds_lock);
1625
1626 if (!c->fast_unmount && !(sb->s_flags & MS_RDONLY) && bud_bytes)
1627 ubifs_run_commit(c);
1628}
1629
1630/**
1631 * ubifs_remount_ro - re-mount in read-only mode. 1621 * ubifs_remount_ro - re-mount in read-only mode.
1632 * @c: UBIFS file-system description object 1622 * @c: UBIFS file-system description object
1633 * 1623 *
1634 * We rely on VFS to have stopped writing. Possibly the background thread could 1624 * We assume VFS has stopped writing. Possibly the background thread could be
1635 * be running a commit, however kthread_stop will wait in that case. 1625 * running a commit, however kthread_stop will wait in that case.
1636 */ 1626 */
1637static void ubifs_remount_ro(struct ubifs_info *c) 1627static void ubifs_remount_ro(struct ubifs_info *c)
1638{ 1628{
1639 int i, err; 1629 int i, err;
1640 1630
1641 ubifs_assert(!c->need_recovery); 1631 ubifs_assert(!c->need_recovery);
1642 commit_on_unmount(c); 1632 ubifs_assert(!(c->vfs_sb->s_flags & MS_RDONLY));
1643 1633
1644 mutex_lock(&c->umount_mutex); 1634 mutex_lock(&c->umount_mutex);
1645 if (c->bgt) { 1635 if (c->bgt) {
@@ -1647,27 +1637,29 @@ static void ubifs_remount_ro(struct ubifs_info *c)
1647 c->bgt = NULL; 1637 c->bgt = NULL;
1648 } 1638 }
1649 1639
1640 dbg_save_space_info(c);
1641
1650 for (i = 0; i < c->jhead_cnt; i++) { 1642 for (i = 0; i < c->jhead_cnt; i++) {
1651 ubifs_wbuf_sync(&c->jheads[i].wbuf); 1643 ubifs_wbuf_sync(&c->jheads[i].wbuf);
1652 del_timer_sync(&c->jheads[i].wbuf.timer); 1644 del_timer_sync(&c->jheads[i].wbuf.timer);
1653 } 1645 }
1654 1646
1655 if (!c->ro_media) { 1647 c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY);
1656 c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY); 1648 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS);
1657 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); 1649 c->mst_node->gc_lnum = cpu_to_le32(c->gc_lnum);
1658 c->mst_node->gc_lnum = cpu_to_le32(c->gc_lnum); 1650 err = ubifs_write_master(c);
1659 err = ubifs_write_master(c); 1651 if (err)
1660 if (err) 1652 ubifs_ro_mode(c, err);
1661 ubifs_ro_mode(c, err);
1662 }
1663 1653
1664 ubifs_destroy_idx_gc(c);
1665 free_wbufs(c); 1654 free_wbufs(c);
1666 vfree(c->orph_buf); 1655 vfree(c->orph_buf);
1667 c->orph_buf = NULL; 1656 c->orph_buf = NULL;
1668 vfree(c->ileb_buf); 1657 vfree(c->ileb_buf);
1669 c->ileb_buf = NULL; 1658 c->ileb_buf = NULL;
1670 ubifs_lpt_free(c, 1); 1659 ubifs_lpt_free(c, 1);
1660 err = dbg_check_space_info(c);
1661 if (err)
1662 ubifs_ro_mode(c, err);
1671 mutex_unlock(&c->umount_mutex); 1663 mutex_unlock(&c->umount_mutex);
1672} 1664}
1673 1665
@@ -1760,11 +1752,20 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
1760 } 1752 }
1761 1753
1762 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { 1754 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
1755 if (c->ro_media) {
1756 ubifs_msg("cannot re-mount due to prior errors");
1757 return -EROFS;
1758 }
1763 err = ubifs_remount_rw(c); 1759 err = ubifs_remount_rw(c);
1764 if (err) 1760 if (err)
1765 return err; 1761 return err;
1766 } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) 1762 } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) {
1763 if (c->ro_media) {
1764 ubifs_msg("cannot re-mount due to prior errors");
1765 return -EROFS;
1766 }
1767 ubifs_remount_ro(c); 1767 ubifs_remount_ro(c);
1768 }
1768 1769
1769 if (c->bulk_read == 1) 1770 if (c->bulk_read == 1)
1770 bu_init(c); 1771 bu_init(c);
@@ -1774,10 +1775,11 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
1774 c->bu.buf = NULL; 1775 c->bu.buf = NULL;
1775 } 1776 }
1776 1777
1778 ubifs_assert(c->lst.taken_empty_lebs == 1);
1777 return 0; 1779 return 0;
1778} 1780}
1779 1781
1780struct super_operations ubifs_super_operations = { 1782const struct super_operations ubifs_super_operations = {
1781 .alloc_inode = ubifs_alloc_inode, 1783 .alloc_inode = ubifs_alloc_inode,
1782 .destroy_inode = ubifs_destroy_inode, 1784 .destroy_inode = ubifs_destroy_inode,
1783 .put_super = ubifs_put_super, 1785 .put_super = ubifs_put_super,
@@ -2044,15 +2046,6 @@ out_close:
2044 2046
2045static void ubifs_kill_sb(struct super_block *sb) 2047static void ubifs_kill_sb(struct super_block *sb)
2046{ 2048{
2047 struct ubifs_info *c = sb->s_fs_info;
2048
2049 /*
2050 * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()'
2051 * in order to be outside BKL.
2052 */
2053 if (sb->s_root)
2054 commit_on_unmount(c);
2055 /* The un-mount routine is actually done in put_super() */
2056 generic_shutdown_super(sb); 2049 generic_shutdown_super(sb);
2057} 2050}
2058 2051
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index f7e36f545527..fa28a84c6a1b 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -443,6 +443,11 @@ static int tnc_read_node_nm(struct ubifs_info *c, struct ubifs_zbranch *zbr,
443 * This function performs that same function as ubifs_read_node except that 443 * This function performs that same function as ubifs_read_node except that
444 * it does not require that there is actually a node present and instead 444 * it does not require that there is actually a node present and instead
445 * the return code indicates if a node was read. 445 * the return code indicates if a node was read.
446 *
447 * Note, this function does not check CRC of data nodes if @c->no_chk_data_crc
448 * is true (it is controlled by corresponding mount option). However, if
449 * @c->always_chk_crc is true, @c->no_chk_data_crc is ignored and CRC is always
450 * checked.
446 */ 451 */
447static int try_read_node(const struct ubifs_info *c, void *buf, int type, 452static int try_read_node(const struct ubifs_info *c, void *buf, int type,
448 int len, int lnum, int offs) 453 int len, int lnum, int offs)
@@ -470,9 +475,8 @@ static int try_read_node(const struct ubifs_info *c, void *buf, int type,
470 if (node_len != len) 475 if (node_len != len)
471 return 0; 476 return 0;
472 477
473 if (type == UBIFS_DATA_NODE && !c->always_chk_crc) 478 if (type == UBIFS_DATA_NODE && !c->always_chk_crc && c->no_chk_data_crc)
474 if (c->no_chk_data_crc) 479 return 1;
475 return 0;
476 480
477 crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); 481 crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8);
478 node_crc = le32_to_cpu(ch->crc); 482 node_crc = le32_to_cpu(ch->crc);
@@ -1506,7 +1510,7 @@ out:
1506 * 1510 *
1507 * Note, if the bulk-read buffer length (@bu->buf_len) is known, this function 1511 * Note, if the bulk-read buffer length (@bu->buf_len) is known, this function
1508 * makes sure bulk-read nodes fit the buffer. Otherwise, this function prepares 1512 * makes sure bulk-read nodes fit the buffer. Otherwise, this function prepares
1509 * maxumum possible amount of nodes for bulk-read. 1513 * maximum possible amount of nodes for bulk-read.
1510 */ 1514 */
1511int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu) 1515int ubifs_tnc_get_bu_keys(struct ubifs_info *c, struct bu_info *bu)
1512{ 1516{
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index fc2a4cc66d03..039a68bee29a 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -426,9 +426,9 @@ struct ubifs_unclean_leb {
426 * LEB properties flags. 426 * LEB properties flags.
427 * 427 *
428 * LPROPS_UNCAT: not categorized 428 * LPROPS_UNCAT: not categorized
429 * LPROPS_DIRTY: dirty > 0, not index 429 * LPROPS_DIRTY: dirty > free, dirty >= @c->dead_wm, not index
430 * LPROPS_DIRTY_IDX: dirty + free > @c->min_idx_node_sze and index 430 * LPROPS_DIRTY_IDX: dirty + free > @c->min_idx_node_sze and index
431 * LPROPS_FREE: free > 0, not empty, not index 431 * LPROPS_FREE: free > 0, dirty < @c->dead_wm, not empty, not index
432 * LPROPS_HEAP_CNT: number of heaps used for storing categorized LEBs 432 * LPROPS_HEAP_CNT: number of heaps used for storing categorized LEBs
433 * LPROPS_EMPTY: LEB is empty, not taken 433 * LPROPS_EMPTY: LEB is empty, not taken
434 * LPROPS_FREEABLE: free + dirty == leb_size, not index, not taken 434 * LPROPS_FREEABLE: free + dirty == leb_size, not index, not taken
@@ -961,7 +961,6 @@ struct ubifs_debug_info;
961 * @cs_lock: commit state lock 961 * @cs_lock: commit state lock
962 * @cmt_wq: wait queue to sleep on if the log is full and a commit is running 962 * @cmt_wq: wait queue to sleep on if the log is full and a commit is running
963 * 963 *
964 * @fast_unmount: do not run journal commit before un-mounting
965 * @big_lpt: flag that LPT is too big to write whole during commit 964 * @big_lpt: flag that LPT is too big to write whole during commit
966 * @no_chk_data_crc: do not check CRCs when reading data nodes (except during 965 * @no_chk_data_crc: do not check CRCs when reading data nodes (except during
967 * recovery) 966 * recovery)
@@ -1202,7 +1201,6 @@ struct ubifs_info {
1202 spinlock_t cs_lock; 1201 spinlock_t cs_lock;
1203 wait_queue_head_t cmt_wq; 1202 wait_queue_head_t cmt_wq;
1204 1203
1205 unsigned int fast_unmount:1;
1206 unsigned int big_lpt:1; 1204 unsigned int big_lpt:1;
1207 unsigned int no_chk_data_crc:1; 1205 unsigned int no_chk_data_crc:1;
1208 unsigned int bulk_read:1; 1206 unsigned int bulk_read:1;
@@ -1405,13 +1403,13 @@ extern struct list_head ubifs_infos;
1405extern spinlock_t ubifs_infos_lock; 1403extern spinlock_t ubifs_infos_lock;
1406extern atomic_long_t ubifs_clean_zn_cnt; 1404extern atomic_long_t ubifs_clean_zn_cnt;
1407extern struct kmem_cache *ubifs_inode_slab; 1405extern struct kmem_cache *ubifs_inode_slab;
1408extern struct super_operations ubifs_super_operations; 1406extern const struct super_operations ubifs_super_operations;
1409extern struct address_space_operations ubifs_file_address_operations; 1407extern const struct address_space_operations ubifs_file_address_operations;
1410extern struct file_operations ubifs_file_operations; 1408extern const struct file_operations ubifs_file_operations;
1411extern struct inode_operations ubifs_file_inode_operations; 1409extern const struct inode_operations ubifs_file_inode_operations;
1412extern struct file_operations ubifs_dir_operations; 1410extern const struct file_operations ubifs_dir_operations;
1413extern struct inode_operations ubifs_dir_inode_operations; 1411extern const struct inode_operations ubifs_dir_inode_operations;
1414extern struct inode_operations ubifs_symlink_inode_operations; 1412extern const struct inode_operations ubifs_symlink_inode_operations;
1415extern struct backing_dev_info ubifs_backing_dev_info; 1413extern struct backing_dev_info ubifs_backing_dev_info;
1416extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; 1414extern struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
1417 1415
@@ -1428,7 +1426,7 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
1428int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum, 1426int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum,
1429 int offs, int dtype); 1427 int offs, int dtype);
1430int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum, 1428int ubifs_check_node(const struct ubifs_info *c, const void *buf, int lnum,
1431 int offs, int quiet, int chk_crc); 1429 int offs, int quiet, int must_chk_crc);
1432void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad); 1430void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad);
1433void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last); 1431void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last);
1434int ubifs_io_init(struct ubifs_info *c); 1432int ubifs_io_init(struct ubifs_info *c);
@@ -1495,6 +1493,7 @@ void ubifs_release_ino_dirty(struct ubifs_info *c, struct inode *inode,
1495void ubifs_cancel_ino_op(struct ubifs_info *c, struct inode *inode, 1493void ubifs_cancel_ino_op(struct ubifs_info *c, struct inode *inode,
1496 struct ubifs_budget_req *req); 1494 struct ubifs_budget_req *req);
1497long long ubifs_get_free_space(struct ubifs_info *c); 1495long long ubifs_get_free_space(struct ubifs_info *c);
1496long long ubifs_get_free_space_nolock(struct ubifs_info *c);
1498int ubifs_calc_min_idx_lebs(struct ubifs_info *c); 1497int ubifs_calc_min_idx_lebs(struct ubifs_info *c);
1499void ubifs_convert_page_budget(struct ubifs_info *c); 1498void ubifs_convert_page_budget(struct ubifs_info *c);
1500long long ubifs_reported_space(const struct ubifs_info *c, long long free); 1499long long ubifs_reported_space(const struct ubifs_info *c, long long free);
@@ -1603,6 +1602,7 @@ void ubifs_delete_orphan(struct ubifs_info *c, ino_t inum);
1603int ubifs_orphan_start_commit(struct ubifs_info *c); 1602int ubifs_orphan_start_commit(struct ubifs_info *c);
1604int ubifs_orphan_end_commit(struct ubifs_info *c); 1603int ubifs_orphan_end_commit(struct ubifs_info *c);
1605int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only); 1604int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only);
1605int ubifs_clear_orphans(struct ubifs_info *c);
1606 1606
1607/* lpt.c */ 1607/* lpt.c */
1608int ubifs_calc_lpt_geom(struct ubifs_info *c); 1608int ubifs_calc_lpt_geom(struct ubifs_info *c);
@@ -1646,7 +1646,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c,
1646 const struct ubifs_lprops *lp, 1646 const struct ubifs_lprops *lp,
1647 int free, int dirty, int flags, 1647 int free, int dirty, int flags,
1648 int idx_gc_cnt); 1648 int idx_gc_cnt);
1649void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *stats); 1649void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst);
1650void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, 1650void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops,
1651 int cat); 1651 int cat);
1652void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops, 1652void ubifs_replace_cat(struct ubifs_info *c, struct ubifs_lprops *old_lprops,
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index d71dc44e21ed..cb329edc925b 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -166,6 +166,75 @@ test_page_region(
166} 166}
167 167
168/* 168/*
169 * Mapping of multi-page buffers into contiguous virtual space
170 */
171
172typedef struct a_list {
173 void *vm_addr;
174 struct a_list *next;
175} a_list_t;
176
177static a_list_t *as_free_head;
178static int as_list_len;
179static DEFINE_SPINLOCK(as_lock);
180
181/*
182 * Try to batch vunmaps because they are costly.
183 */
184STATIC void
185free_address(
186 void *addr)
187{
188 a_list_t *aentry;
189
190#ifdef CONFIG_XEN
191 /*
192 * Xen needs to be able to make sure it can get an exclusive
193 * RO mapping of pages it wants to turn into a pagetable. If
194 * a newly allocated page is also still being vmap()ed by xfs,
195 * it will cause pagetable construction to fail. This is a
196 * quick workaround to always eagerly unmap pages so that Xen
197 * is happy.
198 */
199 vunmap(addr);
200 return;
201#endif
202
203 aentry = kmalloc(sizeof(a_list_t), GFP_NOWAIT);
204 if (likely(aentry)) {
205 spin_lock(&as_lock);
206 aentry->next = as_free_head;
207 aentry->vm_addr = addr;
208 as_free_head = aentry;
209 as_list_len++;
210 spin_unlock(&as_lock);
211 } else {
212 vunmap(addr);
213 }
214}
215
216STATIC void
217purge_addresses(void)
218{
219 a_list_t *aentry, *old;
220
221 if (as_free_head == NULL)
222 return;
223
224 spin_lock(&as_lock);
225 aentry = as_free_head;
226 as_free_head = NULL;
227 as_list_len = 0;
228 spin_unlock(&as_lock);
229
230 while ((old = aentry) != NULL) {
231 vunmap(aentry->vm_addr);
232 aentry = aentry->next;
233 kfree(old);
234 }
235}
236
237/*
169 * Internal xfs_buf_t object manipulation 238 * Internal xfs_buf_t object manipulation
170 */ 239 */
171 240
@@ -264,7 +333,7 @@ xfs_buf_free(
264 uint i; 333 uint i;
265 334
266 if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1)) 335 if ((bp->b_flags & XBF_MAPPED) && (bp->b_page_count > 1))
267 vm_unmap_ram(bp->b_addr - bp->b_offset, bp->b_page_count); 336 free_address(bp->b_addr - bp->b_offset);
268 337
269 for (i = 0; i < bp->b_page_count; i++) { 338 for (i = 0; i < bp->b_page_count; i++) {
270 struct page *page = bp->b_pages[i]; 339 struct page *page = bp->b_pages[i];
@@ -386,8 +455,10 @@ _xfs_buf_map_pages(
386 bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset; 455 bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset;
387 bp->b_flags |= XBF_MAPPED; 456 bp->b_flags |= XBF_MAPPED;
388 } else if (flags & XBF_MAPPED) { 457 } else if (flags & XBF_MAPPED) {
389 bp->b_addr = vm_map_ram(bp->b_pages, bp->b_page_count, 458 if (as_list_len > 64)
390 -1, PAGE_KERNEL); 459 purge_addresses();
460 bp->b_addr = vmap(bp->b_pages, bp->b_page_count,
461 VM_MAP, PAGE_KERNEL);
391 if (unlikely(bp->b_addr == NULL)) 462 if (unlikely(bp->b_addr == NULL))
392 return -ENOMEM; 463 return -ENOMEM;
393 bp->b_addr += bp->b_offset; 464 bp->b_addr += bp->b_offset;
@@ -1672,6 +1743,8 @@ xfsbufd(
1672 count++; 1743 count++;
1673 } 1744 }
1674 1745
1746 if (as_list_len > 0)
1747 purge_addresses();
1675 if (count) 1748 if (count)
1676 blk_run_address_space(target->bt_mapping); 1749 blk_run_address_space(target->bt_mapping);
1677 1750
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index 2ed035354c26..a608e72fa405 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -371,7 +371,11 @@ xfs_quiesce_attr(
371 /* flush inodes and push all remaining buffers out to disk */ 371 /* flush inodes and push all remaining buffers out to disk */
372 xfs_quiesce_fs(mp); 372 xfs_quiesce_fs(mp);
373 373
374 ASSERT_ALWAYS(atomic_read(&mp->m_active_trans) == 0); 374 /*
375 * Just warn here till VFS can correctly support
376 * read-only remount without racing.
377 */
378 WARN_ON(atomic_read(&mp->m_active_trans) != 0);
375 379
376 /* Push the superblock and write an unmount record */ 380 /* Push the superblock and write an unmount record */
377 error = xfs_log_sbcount(mp, 1); 381 error = xfs_log_sbcount(mp, 1);
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index b4c1ee713492..f8278cfcc1d3 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -55,17 +55,11 @@ xfs_swapext(
55 struct file *file, *target_file; 55 struct file *file, *target_file;
56 int error = 0; 56 int error = 0;
57 57
58 sxp = kmem_alloc(sizeof(xfs_swapext_t), KM_MAYFAIL);
59 if (!sxp) {
60 error = XFS_ERROR(ENOMEM);
61 goto out;
62 }
63
64 /* Pull information for the target fd */ 58 /* Pull information for the target fd */
65 file = fget((int)sxp->sx_fdtarget); 59 file = fget((int)sxp->sx_fdtarget);
66 if (!file) { 60 if (!file) {
67 error = XFS_ERROR(EINVAL); 61 error = XFS_ERROR(EINVAL);
68 goto out_free_sxp; 62 goto out;
69 } 63 }
70 64
71 if (!(file->f_mode & FMODE_WRITE) || (file->f_flags & O_APPEND)) { 65 if (!(file->f_mode & FMODE_WRITE) || (file->f_flags & O_APPEND)) {
@@ -109,8 +103,6 @@ xfs_swapext(
109 fput(target_file); 103 fput(target_file);
110 out_put_file: 104 out_put_file:
111 fput(file); 105 fput(file);
112 out_free_sxp:
113 kmem_free(sxp);
114 out: 106 out:
115 return error; 107 return error;
116} 108}
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 35cca98bd94c..b1047de2fffd 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -70,16 +70,21 @@ STATIC void xlog_recover_check_summary(xlog_t *);
70xfs_buf_t * 70xfs_buf_t *
71xlog_get_bp( 71xlog_get_bp(
72 xlog_t *log, 72 xlog_t *log,
73 int num_bblks) 73 int nbblks)
74{ 74{
75 ASSERT(num_bblks > 0); 75 if (nbblks <= 0 || nbblks > log->l_logBBsize) {
76 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
77 XFS_ERROR_REPORT("xlog_get_bp(1)",
78 XFS_ERRLEVEL_HIGH, log->l_mp);
79 return NULL;
80 }
76 81
77 if (log->l_sectbb_log) { 82 if (log->l_sectbb_log) {
78 if (num_bblks > 1) 83 if (nbblks > 1)
79 num_bblks += XLOG_SECTOR_ROUNDUP_BBCOUNT(log, 1); 84 nbblks += XLOG_SECTOR_ROUNDUP_BBCOUNT(log, 1);
80 num_bblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, num_bblks); 85 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks);
81 } 86 }
82 return xfs_buf_get_noaddr(BBTOB(num_bblks), log->l_mp->m_logdev_targp); 87 return xfs_buf_get_noaddr(BBTOB(nbblks), log->l_mp->m_logdev_targp);
83} 88}
84 89
85void 90void
@@ -102,6 +107,13 @@ xlog_bread(
102{ 107{
103 int error; 108 int error;
104 109
110 if (nbblks <= 0 || nbblks > log->l_logBBsize) {
111 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
112 XFS_ERROR_REPORT("xlog_bread(1)",
113 XFS_ERRLEVEL_HIGH, log->l_mp);
114 return EFSCORRUPTED;
115 }
116
105 if (log->l_sectbb_log) { 117 if (log->l_sectbb_log) {
106 blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no); 118 blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no);
107 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); 119 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks);
@@ -139,6 +151,13 @@ xlog_bwrite(
139{ 151{
140 int error; 152 int error;
141 153
154 if (nbblks <= 0 || nbblks > log->l_logBBsize) {
155 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
156 XFS_ERROR_REPORT("xlog_bwrite(1)",
157 XFS_ERRLEVEL_HIGH, log->l_mp);
158 return EFSCORRUPTED;
159 }
160
142 if (log->l_sectbb_log) { 161 if (log->l_sectbb_log) {
143 blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no); 162 blk_no = XLOG_SECTOR_ROUNDDOWN_BLKNO(log, blk_no);
144 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks); 163 nbblks = XLOG_SECTOR_ROUNDUP_BBCOUNT(log, nbblks);
diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h
index e72bfdd887f9..552637b0d051 100644
--- a/include/acpi/pdc_intel.h
+++ b/include/acpi/pdc_intel.h
@@ -14,6 +14,7 @@
14#define ACPI_PDC_SMP_T_SWCOORD (0x0080) 14#define ACPI_PDC_SMP_T_SWCOORD (0x0080)
15#define ACPI_PDC_C_C1_FFH (0x0100) 15#define ACPI_PDC_C_C1_FFH (0x0100)
16#define ACPI_PDC_C_C2C3_FFH (0x0200) 16#define ACPI_PDC_C_C2C3_FFH (0x0200)
17#define ACPI_PDC_SMP_P_HWCOORD (0x0800)
17 18
18#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \ 19#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \
19 ACPI_PDC_C_C1_HALT | \ 20 ACPI_PDC_C_C1_HALT | \
@@ -22,6 +23,7 @@
22#define ACPI_PDC_EST_CAPABILITY_SWSMP (ACPI_PDC_SMP_C1PT | \ 23#define ACPI_PDC_EST_CAPABILITY_SWSMP (ACPI_PDC_SMP_C1PT | \
23 ACPI_PDC_C_C1_HALT | \ 24 ACPI_PDC_C_C1_HALT | \
24 ACPI_PDC_SMP_P_SWCOORD | \ 25 ACPI_PDC_SMP_P_SWCOORD | \
26 ACPI_PDC_SMP_P_HWCOORD | \
25 ACPI_PDC_P_FFH) 27 ACPI_PDC_P_FFH)
26 28
27#define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \ 29#define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \
diff --git a/include/asm-frv/pgtable.h b/include/asm-frv/pgtable.h
index 83c51aba534b..e16fdb1f4f4f 100644
--- a/include/asm-frv/pgtable.h
+++ b/include/asm-frv/pgtable.h
@@ -478,7 +478,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
478#define __swp_type(x) (((x).val >> 2) & 0x1f) 478#define __swp_type(x) (((x).val >> 2) & 0x1f)
479#define __swp_offset(x) ((x).val >> 8) 479#define __swp_offset(x) ((x).val >> 8)
480#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 2) | ((offset) << 8) }) 480#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 2) | ((offset) << 8) })
481#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte }) 481#define __pte_to_swp_entry(_pte) ((swp_entry_t) { (_pte).pte })
482#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 482#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
483 483
484static inline int pte_file(pte_t pte) 484static inline int pte_file(pte_t pte)
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index cd16d6e668ce..d797e119e3d5 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -222,7 +222,7 @@ static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm)
222 222
223static inline void crypto_free_shash(struct crypto_shash *tfm) 223static inline void crypto_free_shash(struct crypto_shash *tfm)
224{ 224{
225 crypto_free_tfm(crypto_shash_tfm(tfm)); 225 crypto_destroy_tfm(tfm, crypto_shash_tfm(tfm));
226} 226}
227 227
228static inline unsigned int crypto_shash_alignmask( 228static inline unsigned int crypto_shash_alignmask(
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8190b9bcc2d9..e5f4ae989abf 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1321,6 +1321,8 @@ void drm_gem_object_free(struct kref *kref);
1321struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, 1321struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1322 size_t size); 1322 size_t size);
1323void drm_gem_object_handle_free(struct kref *kref); 1323void drm_gem_object_handle_free(struct kref *kref);
1324void drm_gem_vm_open(struct vm_area_struct *vma);
1325void drm_gem_vm_close(struct vm_area_struct *vma);
1324int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); 1326int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
1325 1327
1326static inline void 1328static inline void
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index d54de24bf371..5ded1acfb543 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -609,7 +609,7 @@ extern char *drm_get_dvi_i_subconnector_name(int val);
609extern char *drm_get_dvi_i_select_name(int val); 609extern char *drm_get_dvi_i_select_name(int val);
610extern char *drm_get_tv_subconnector_name(int val); 610extern char *drm_get_tv_subconnector_name(int val);
611extern char *drm_get_tv_select_name(int val); 611extern char *drm_get_tv_select_name(int val);
612extern void drm_fb_release(struct file *filp); 612extern void drm_fb_release(struct drm_file *file_priv);
613extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group); 613extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
614extern struct edid *drm_get_edid(struct drm_connector *connector, 614extern struct edid *drm_get_edid(struct drm_connector *connector,
615 struct i2c_adapter *adapter); 615 struct i2c_adapter *adapter);
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index 0c6f0e11b41b..0b0d236c2154 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -54,13 +54,13 @@ struct drm_crtc_helper_funcs {
54 struct drm_display_mode *mode, 54 struct drm_display_mode *mode,
55 struct drm_display_mode *adjusted_mode); 55 struct drm_display_mode *adjusted_mode);
56 /* Actually set the mode */ 56 /* Actually set the mode */
57 void (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode, 57 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
58 struct drm_display_mode *adjusted_mode, int x, int y, 58 struct drm_display_mode *adjusted_mode, int x, int y,
59 struct drm_framebuffer *old_fb); 59 struct drm_framebuffer *old_fb);
60 60
61 /* Move the crtc on the current fb to the given position *optional* */ 61 /* Move the crtc on the current fb to the given position *optional* */
62 void (*mode_set_base)(struct drm_crtc *crtc, int x, int y, 62 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
63 struct drm_framebuffer *old_fb); 63 struct drm_framebuffer *old_fb);
64}; 64};
65 65
66struct drm_encoder_helper_funcs { 66struct drm_encoder_helper_funcs {
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index b3bcf72dc656..912cd52db965 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -261,6 +261,7 @@ typedef struct drm_i915_irq_wait {
261#define I915_PARAM_LAST_DISPATCH 3 261#define I915_PARAM_LAST_DISPATCH 3
262#define I915_PARAM_CHIPSET_ID 4 262#define I915_PARAM_CHIPSET_ID 4
263#define I915_PARAM_HAS_GEM 5 263#define I915_PARAM_HAS_GEM 5
264#define I915_PARAM_NUM_FENCES_AVAIL 6
264 265
265typedef struct drm_i915_getparam { 266typedef struct drm_i915_getparam {
266 int param; 267 int param;
@@ -272,6 +273,7 @@ typedef struct drm_i915_getparam {
272#define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1 273#define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
273#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2 274#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
274#define I915_SETPARAM_ALLOW_BATCHBUFFER 3 275#define I915_SETPARAM_ALLOW_BATCHBUFFER 3
276#define I915_SETPARAM_NUM_USED_FENCES 4
275 277
276typedef struct drm_i915_setparam { 278typedef struct drm_i915_setparam {
277 int param; 279 int param;
diff --git a/include/linux/async.h b/include/linux/async.h
index c4ecacd0b327..68a9530196f2 100644
--- a/include/linux/async.h
+++ b/include/linux/async.h
@@ -17,9 +17,11 @@ typedef u64 async_cookie_t;
17typedef void (async_func_ptr) (void *data, async_cookie_t cookie); 17typedef void (async_func_ptr) (void *data, async_cookie_t cookie);
18 18
19extern async_cookie_t async_schedule(async_func_ptr *ptr, void *data); 19extern async_cookie_t async_schedule(async_func_ptr *ptr, void *data);
20extern async_cookie_t async_schedule_special(async_func_ptr *ptr, void *data, struct list_head *list); 20extern async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
21 struct list_head *list);
21extern void async_synchronize_full(void); 22extern void async_synchronize_full(void);
22extern void async_synchronize_full_special(struct list_head *list); 23extern void async_synchronize_full_domain(struct list_head *list);
23extern void async_synchronize_cookie(async_cookie_t cookie); 24extern void async_synchronize_cookie(async_cookie_t cookie);
24extern void async_synchronize_cookie_special(async_cookie_t cookie, struct list_head *list); 25extern void async_synchronize_cookie_domain(async_cookie_t cookie,
26 struct list_head *list);
25 27
diff --git a/include/linux/ata.h b/include/linux/ata.h
index a53318b8cbd0..08a86d5cdf1b 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -731,12 +731,17 @@ static inline int ata_id_current_chs_valid(const u16 *id)
731 731
732static inline int ata_id_is_cfa(const u16 *id) 732static inline int ata_id_is_cfa(const u16 *id)
733{ 733{
734 if (id[ATA_ID_CONFIG] == 0x848A) /* Standard CF */ 734 if (id[ATA_ID_CONFIG] == 0x848A) /* Traditional CF */
735 return 1; 735 return 1;
736 /* Could be CF hiding as standard ATA */ 736 /*
737 if (ata_id_major_version(id) >= 3 && 737 * CF specs don't require specific value in the word 0 anymore and yet
738 id[ATA_ID_COMMAND_SET_1] != 0xFFFF && 738 * they forbid to report the ATA version in the word 80 and require the
739 (id[ATA_ID_COMMAND_SET_1] & (1 << 2))) 739 * CFA feature set support to be indicated in the word 83 in this case.
740 * Unfortunately, some cards only follow either of this requirements,
741 * and while those that don't indicate CFA feature support need some
742 * sort of quirk list, it seems impractical for the ones that do...
743 */
744 if ((id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004)
740 return 1; 745 return 1;
741 return 0; 746 return 0;
742} 747}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 2aa283ab062b..1b16108a5417 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -171,8 +171,6 @@ struct bio {
171#define BIO_RW_FAILFAST_TRANSPORT 8 171#define BIO_RW_FAILFAST_TRANSPORT 8
172#define BIO_RW_FAILFAST_DRIVER 9 172#define BIO_RW_FAILFAST_DRIVER 9
173 173
174#define BIO_RW_SYNC (BIO_RW_SYNCIO | BIO_RW_UNPLUG)
175
176#define bio_rw_flagged(bio, flag) ((bio)->bi_rw & (1 << (flag))) 174#define bio_rw_flagged(bio, flag) ((bio)->bi_rw & (1 << (flag)))
177 175
178/* 176/*
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 25379cba2370..6e915878e88c 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -15,6 +15,7 @@ enum blktrace_cat {
15 BLK_TC_WRITE = 1 << 1, /* writes */ 15 BLK_TC_WRITE = 1 << 1, /* writes */
16 BLK_TC_BARRIER = 1 << 2, /* barrier */ 16 BLK_TC_BARRIER = 1 << 2, /* barrier */
17 BLK_TC_SYNC = 1 << 3, /* sync IO */ 17 BLK_TC_SYNC = 1 << 3, /* sync IO */
18 BLK_TC_SYNCIO = BLK_TC_SYNC,
18 BLK_TC_QUEUE = 1 << 4, /* queueing/merging */ 19 BLK_TC_QUEUE = 1 << 4, /* queueing/merging */
19 BLK_TC_REQUEUE = 1 << 5, /* requeueing */ 20 BLK_TC_REQUEUE = 1 << 5, /* requeueing */
20 BLK_TC_ISSUE = 1 << 6, /* issue */ 21 BLK_TC_ISSUE = 1 << 6, /* issue */
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index e4e8e117d27d..499900d0cee7 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -378,6 +378,7 @@ struct cgroup_subsys {
378 * - initiating hotplug events 378 * - initiating hotplug events
379 */ 379 */
380 struct mutex hierarchy_mutex; 380 struct mutex hierarchy_mutex;
381 struct lock_class_key subsys_key;
381 382
382 /* 383 /*
383 * Link to parent, and list entry in parent's children. 384 * Link to parent, and list entry in parent's children.
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 3bacd71509fb..1f2e9020acc6 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -552,7 +552,12 @@ struct crypto_tfm *crypto_alloc_tfm(const char *alg_name,
552 const struct crypto_type *frontend, 552 const struct crypto_type *frontend,
553 u32 type, u32 mask); 553 u32 type, u32 mask);
554struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask); 554struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
555void crypto_free_tfm(struct crypto_tfm *tfm); 555void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm);
556
557static inline void crypto_free_tfm(struct crypto_tfm *tfm)
558{
559 return crypto_destroy_tfm(tfm, tfm);
560}
556 561
557int alg_test(const char *driver, const char *alg, u32 type, u32 mask); 562int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
558 563
diff --git a/include/linux/device.h b/include/linux/device.h
index 45e5b1921fbb..47f343c7bdda 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -147,6 +147,8 @@ extern void put_driver(struct device_driver *drv);
147extern struct device_driver *driver_find(const char *name, 147extern struct device_driver *driver_find(const char *name,
148 struct bus_type *bus); 148 struct bus_type *bus);
149extern int driver_probe_done(void); 149extern int driver_probe_done(void);
150extern int wait_for_device_probe(void);
151
150 152
151/* sysfs interface for exporting driver attributes */ 153/* sysfs interface for exporting driver attributes */
152 154
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 3e68469c1885..f0413845f20e 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -121,6 +121,7 @@ struct dma_chan_percpu {
121 * @local: per-cpu pointer to a struct dma_chan_percpu 121 * @local: per-cpu pointer to a struct dma_chan_percpu
122 * @client-count: how many clients are using this channel 122 * @client-count: how many clients are using this channel
123 * @table_count: number of appearances in the mem-to-mem allocation table 123 * @table_count: number of appearances in the mem-to-mem allocation table
124 * @private: private data for certain client-channel associations
124 */ 125 */
125struct dma_chan { 126struct dma_chan {
126 struct dma_device *device; 127 struct dma_device *device;
@@ -134,6 +135,7 @@ struct dma_chan {
134 struct dma_chan_percpu *local; 135 struct dma_chan_percpu *local;
135 int client_count; 136 int client_count;
136 int table_count; 137 int table_count;
138 void *private;
137}; 139};
138 140
139/** 141/**
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 818fe21257e8..31527e17076b 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -960,6 +960,21 @@ extern struct fb_info *registered_fb[FB_MAX];
960extern int num_registered_fb; 960extern int num_registered_fb;
961extern struct class *fb_class; 961extern struct class *fb_class;
962 962
963static inline int lock_fb_info(struct fb_info *info)
964{
965 mutex_lock(&info->lock);
966 if (!info->fbops) {
967 mutex_unlock(&info->lock);
968 return 0;
969 }
970 return 1;
971}
972
973static inline void unlock_fb_info(struct fb_info *info)
974{
975 mutex_unlock(&info->lock);
976}
977
963static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, 978static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
964 u8 *src, u32 s_pitch, u32 height) 979 u8 *src, u32 s_pitch, u32 height)
965{ 980{
diff --git a/include/linux/firmware-map.h b/include/linux/firmware-map.h
index 6e199c8dfacc..cca686b39123 100644
--- a/include/linux/firmware-map.h
+++ b/include/linux/firmware-map.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/linux/firmware-map.h: 2 * include/linux/firmware-map.h:
3 * Copyright (C) 2008 SUSE LINUX Products GmbH 3 * Copyright (C) 2008 SUSE LINUX Products GmbH
4 * by Bernhard Walle <bwalle@suse.de> 4 * by Bernhard Walle <bernhard.walle@gmx.de>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License v2.0 as published by 7 * it under the terms of the GNU General Public License v2.0 as published by
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6022f44043f2..92734c0012e6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -54,24 +54,30 @@ struct inodes_stat_t {
54#define MAY_ACCESS 16 54#define MAY_ACCESS 16
55#define MAY_OPEN 32 55#define MAY_OPEN 32
56 56
57/*
58 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
59 * to O_WRONLY and O_RDWR via the strange trick in __dentry_open()
60 */
61
57/* file is open for reading */ 62/* file is open for reading */
58#define FMODE_READ ((__force fmode_t)1) 63#define FMODE_READ ((__force fmode_t)1)
59/* file is open for writing */ 64/* file is open for writing */
60#define FMODE_WRITE ((__force fmode_t)2) 65#define FMODE_WRITE ((__force fmode_t)2)
61/* file is seekable */ 66/* file is seekable */
62#define FMODE_LSEEK ((__force fmode_t)4) 67#define FMODE_LSEEK ((__force fmode_t)4)
63/* file can be accessed using pread/pwrite */ 68/* file can be accessed using pread */
64#define FMODE_PREAD ((__force fmode_t)8) 69#define FMODE_PREAD ((__force fmode_t)8)
65#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */ 70/* file can be accessed using pwrite */
71#define FMODE_PWRITE ((__force fmode_t)16)
66/* File is opened for execution with sys_execve / sys_uselib */ 72/* File is opened for execution with sys_execve / sys_uselib */
67#define FMODE_EXEC ((__force fmode_t)16) 73#define FMODE_EXEC ((__force fmode_t)32)
68/* File is opened with O_NDELAY (only set for block devices) */ 74/* File is opened with O_NDELAY (only set for block devices) */
69#define FMODE_NDELAY ((__force fmode_t)32) 75#define FMODE_NDELAY ((__force fmode_t)64)
70/* File is opened with O_EXCL (only set for block devices) */ 76/* File is opened with O_EXCL (only set for block devices) */
71#define FMODE_EXCL ((__force fmode_t)64) 77#define FMODE_EXCL ((__force fmode_t)128)
72/* File is opened using open(.., 3, ..) and is writeable only for ioctls 78/* File is opened using open(.., 3, ..) and is writeable only for ioctls
73 (specialy hack for floppy.c) */ 79 (specialy hack for floppy.c) */
74#define FMODE_WRITE_IOCTL ((__force fmode_t)128) 80#define FMODE_WRITE_IOCTL ((__force fmode_t)256)
75 81
76/* 82/*
77 * Don't update ctime and mtime. 83 * Don't update ctime and mtime.
@@ -87,10 +93,10 @@ struct inodes_stat_t {
87#define WRITE 1 93#define WRITE 1
88#define READA 2 /* read-ahead - don't block if no resources */ 94#define READA 2 /* read-ahead - don't block if no resources */
89#define SWRITE 3 /* for ll_rw_block() - wait for buffer lock */ 95#define SWRITE 3 /* for ll_rw_block() - wait for buffer lock */
90#define READ_SYNC (READ | (1 << BIO_RW_SYNC)) 96#define READ_SYNC (READ | (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG))
91#define READ_META (READ | (1 << BIO_RW_META)) 97#define READ_META (READ | (1 << BIO_RW_META))
92#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) 98#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG))
93#define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC)) 99#define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG))
94#define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER)) 100#define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER))
95#define DISCARD_NOBARRIER (1 << BIO_RW_DISCARD) 101#define DISCARD_NOBARRIER (1 << BIO_RW_DISCARD)
96#define DISCARD_BARRIER ((1 << BIO_RW_DISCARD) | (1 << BIO_RW_BARRIER)) 102#define DISCARD_BARRIER ((1 << BIO_RW_DISCARD) | (1 << BIO_RW_BARRIER))
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index f1d2fba19ea0..03be7f29ca01 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -33,7 +33,8 @@ unsigned long hugetlb_total_pages(void);
33int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, 33int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
34 unsigned long address, int write_access); 34 unsigned long address, int write_access);
35int hugetlb_reserve_pages(struct inode *inode, long from, long to, 35int hugetlb_reserve_pages(struct inode *inode, long from, long to,
36 struct vm_area_struct *vma); 36 struct vm_area_struct *vma,
37 int acctflags);
37void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); 38void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);
38 39
39extern unsigned long hugepages_treat_as_movable; 40extern unsigned long hugepages_treat_as_movable;
@@ -138,7 +139,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
138 139
139extern const struct file_operations hugetlbfs_file_operations; 140extern const struct file_operations hugetlbfs_file_operations;
140extern struct vm_operations_struct hugetlb_vm_ops; 141extern struct vm_operations_struct hugetlb_vm_ops;
141struct file *hugetlb_file_setup(const char *name, size_t); 142struct file *hugetlb_file_setup(const char *name, size_t, int);
142int hugetlb_get_quota(struct address_space *mapping, long delta); 143int hugetlb_get_quota(struct address_space *mapping, long delta);
143void hugetlb_put_quota(struct address_space *mapping, long delta); 144void hugetlb_put_quota(struct address_space *mapping, long delta);
144 145
@@ -158,9 +159,9 @@ static inline void set_file_hugepages(struct file *file)
158} 159}
159#else /* !CONFIG_HUGETLBFS */ 160#else /* !CONFIG_HUGETLBFS */
160 161
161#define is_file_hugepages(file) 0 162#define is_file_hugepages(file) 0
162#define set_file_hugepages(file) BUG() 163#define set_file_hugepages(file) BUG()
163#define hugetlb_file_setup(name,size) ERR_PTR(-ENOSYS) 164#define hugetlb_file_setup(name,size,acctflag) ERR_PTR(-ENOSYS)
164 165
165#endif /* !CONFIG_HUGETLBFS */ 166#endif /* !CONFIG_HUGETLBFS */
166 167
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index ea0ea1a4c36f..e752d973fa21 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -48,12 +48,11 @@ extern struct fs_struct init_fs;
48 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ 48 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
49 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ 49 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
50 .rlim = INIT_RLIMITS, \ 50 .rlim = INIT_RLIMITS, \
51 .cputime = { .totals = { \ 51 .cputimer = { \
52 .utime = cputime_zero, \ 52 .cputime = INIT_CPUTIME, \
53 .stime = cputime_zero, \ 53 .running = 0, \
54 .sum_exec_runtime = 0, \ 54 .lock = __SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \
55 .lock = __SPIN_LOCK_UNLOCKED(sig.cputime.totals.lock), \ 55 }, \
56 }, }, \
57} 56}
58 57
59extern struct nsproxy init_nsproxy; 58extern struct nsproxy init_nsproxy;
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index b28b37eb11c6..4d248b3f1323 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1150,7 +1150,8 @@ extern int jbd2_journal_clear_err (journal_t *);
1150extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *); 1150extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *);
1151extern int jbd2_journal_force_commit(journal_t *); 1151extern int jbd2_journal_force_commit(journal_t *);
1152extern int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *inode); 1152extern int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *inode);
1153extern int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *inode, loff_t new_size); 1153extern int jbd2_journal_begin_ordered_truncate(journal_t *journal,
1154 struct jbd2_inode *inode, loff_t new_size);
1154extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode); 1155extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode);
1155extern void jbd2_journal_release_jbd_inode(journal_t *journal, struct jbd2_inode *jinode); 1156extern void jbd2_journal_release_jbd_inode(journal_t *journal, struct jbd2_inode *jinode);
1156 1157
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 343df9ef2412..7fa371898e3e 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -480,7 +480,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
480/* 480/*
481 * swap - swap value of @a and @b 481 * swap - swap value of @a and @b
482 */ 482 */
483#define swap(a, b) ({ typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; }) 483#define swap(a, b) \
484 do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
484 485
485/** 486/**
486 * container_of - cast a member of a structure out to the containing structure 487 * container_of - cast a member of a structure out to the containing structure
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 5715f1907601..0424326f1679 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -58,10 +58,10 @@ struct kvm_irqchip {
58 __u32 pad; 58 __u32 pad;
59 union { 59 union {
60 char dummy[512]; /* reserving space */ 60 char dummy[512]; /* reserving space */
61#ifdef CONFIG_X86 61#ifdef __KVM_HAVE_PIT
62 struct kvm_pic_state pic; 62 struct kvm_pic_state pic;
63#endif 63#endif
64#if defined(CONFIG_X86) || defined(CONFIG_IA64) 64#ifdef __KVM_HAVE_IOAPIC
65 struct kvm_ioapic_state ioapic; 65 struct kvm_ioapic_state ioapic;
66#endif 66#endif
67 } chip; 67 } chip;
@@ -384,16 +384,16 @@ struct kvm_trace_rec {
384#define KVM_CAP_MP_STATE 14 384#define KVM_CAP_MP_STATE 14
385#define KVM_CAP_COALESCED_MMIO 15 385#define KVM_CAP_COALESCED_MMIO 15
386#define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 386#define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */
387#if defined(CONFIG_X86)||defined(CONFIG_IA64) 387#ifdef __KVM_HAVE_DEVICE_ASSIGNMENT
388#define KVM_CAP_DEVICE_ASSIGNMENT 17 388#define KVM_CAP_DEVICE_ASSIGNMENT 17
389#endif 389#endif
390#define KVM_CAP_IOMMU 18 390#define KVM_CAP_IOMMU 18
391#if defined(CONFIG_X86) 391#ifdef __KVM_HAVE_MSI
392#define KVM_CAP_DEVICE_MSI 20 392#define KVM_CAP_DEVICE_MSI 20
393#endif 393#endif
394/* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ 394/* Bug in KVM_SET_USER_MEMORY_REGION fixed: */
395#define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 395#define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21
396#if defined(CONFIG_X86) 396#ifdef __KVM_HAVE_USER_NMI
397#define KVM_CAP_USER_NMI 22 397#define KVM_CAP_USER_NMI 22
398#endif 398#endif
399 399
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ec49d0be7f52..bf6f703642fc 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -285,6 +285,7 @@ void kvm_free_physmem(struct kvm *kvm);
285struct kvm *kvm_arch_create_vm(void); 285struct kvm *kvm_arch_create_vm(void);
286void kvm_arch_destroy_vm(struct kvm *kvm); 286void kvm_arch_destroy_vm(struct kvm *kvm);
287void kvm_free_all_assigned_devices(struct kvm *kvm); 287void kvm_free_all_assigned_devices(struct kvm *kvm);
288void kvm_arch_sync_events(struct kvm *kvm);
288 289
289int kvm_cpu_get_interrupt(struct kvm_vcpu *v); 290int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
290int kvm_cpu_has_interrupt(struct kvm_vcpu *v); 291int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index bca3ba25f52a..5d87bc09a1f5 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -380,6 +380,7 @@ enum {
380 ATA_HORKAGE_ATAPI_MOD16_DMA = (1 << 11), /* use ATAPI DMA for commands 380 ATA_HORKAGE_ATAPI_MOD16_DMA = (1 << 11), /* use ATAPI DMA for commands
381 not multiple of 16 bytes */ 381 not multiple of 16 bytes */
382 ATA_HORKAGE_FIRMWARE_WARN = (1 << 12), /* firwmare update warning */ 382 ATA_HORKAGE_FIRMWARE_WARN = (1 << 12), /* firwmare update warning */
383 ATA_HORKAGE_1_5_GBPS = (1 << 13), /* force 1.5 Gbps */
383 384
384 /* DMA mask for user DMA control: User visible values; DO NOT 385 /* DMA mask for user DMA control: User visible values; DO NOT
385 renumber */ 386 renumber */
@@ -580,7 +581,7 @@ struct ata_device {
580 acpi_handle acpi_handle; 581 acpi_handle acpi_handle;
581 union acpi_object *gtf_cache; 582 union acpi_object *gtf_cache;
582#endif 583#endif
583 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ 584 /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */
584 u64 n_sectors; /* size of device, if ATA */ 585 u64 n_sectors; /* size of device, if ATA */
585 unsigned int class; /* ATA_DEV_xxx */ 586 unsigned int class; /* ATA_DEV_xxx */
586 unsigned long unpark_deadline; 587 unsigned long unpark_deadline;
@@ -605,20 +606,22 @@ struct ata_device {
605 u16 heads; /* Number of heads */ 606 u16 heads; /* Number of heads */
606 u16 sectors; /* Number of sectors per track */ 607 u16 sectors; /* Number of sectors per track */
607 608
608 /* error history */
609 int spdn_cnt;
610 struct ata_ering ering;
611
612 union { 609 union {
613 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ 610 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
614 u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */ 611 u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
615 }; 612 };
613
614 /* error history */
615 int spdn_cnt;
616 /* ering is CLEAR_END, read comment above CLEAR_END */
617 struct ata_ering ering;
616}; 618};
617 619
618/* Offset into struct ata_device. Fields above it are maintained 620/* Fields between ATA_DEVICE_CLEAR_BEGIN and ATA_DEVICE_CLEAR_END are
619 * acress device init. Fields below are zeroed. 621 * cleared to zero on ata_dev_init().
620 */ 622 */
621#define ATA_DEVICE_CLEAR_OFFSET offsetof(struct ata_device, n_sectors) 623#define ATA_DEVICE_CLEAR_BEGIN offsetof(struct ata_device, n_sectors)
624#define ATA_DEVICE_CLEAR_END offsetof(struct ata_device, ering)
622 625
623struct ata_eh_info { 626struct ata_eh_info {
624 struct ata_device *dev; /* offending device */ 627 struct ata_device *dev; /* offending device */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index e8ddc98b8405..065cdf8c09fb 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1041,10 +1041,23 @@ extern void free_bootmem_with_active_regions(int nid,
1041typedef int (*work_fn_t)(unsigned long, unsigned long, void *); 1041typedef int (*work_fn_t)(unsigned long, unsigned long, void *);
1042extern void work_with_active_regions(int nid, work_fn_t work_fn, void *data); 1042extern void work_with_active_regions(int nid, work_fn_t work_fn, void *data);
1043extern void sparse_memory_present_with_active_regions(int nid); 1043extern void sparse_memory_present_with_active_regions(int nid);
1044#ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
1045extern int early_pfn_to_nid(unsigned long pfn);
1046#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
1047#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */ 1044#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
1045
1046#if !defined(CONFIG_ARCH_POPULATES_NODE_MAP) && \
1047 !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID)
1048static inline int __early_pfn_to_nid(unsigned long pfn)
1049{
1050 return 0;
1051}
1052#else
1053/* please see mm/page_alloc.c */
1054extern int __meminit early_pfn_to_nid(unsigned long pfn);
1055#ifdef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
1056/* there is a per-arch backend function. */
1057extern int __meminit __early_pfn_to_nid(unsigned long pfn);
1058#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
1059#endif
1060
1048extern void set_dma_reserve(unsigned long new_dma_reserve); 1061extern void set_dma_reserve(unsigned long new_dma_reserve);
1049extern void memmap_init_zone(unsigned long, int, unsigned long, 1062extern void memmap_init_zone(unsigned long, int, unsigned long,
1050 unsigned long, enum memmap_context); 1063 unsigned long, enum memmap_context);
@@ -1129,8 +1142,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1129 unsigned long flag, unsigned long pgoff); 1142 unsigned long flag, unsigned long pgoff);
1130extern unsigned long mmap_region(struct file *file, unsigned long addr, 1143extern unsigned long mmap_region(struct file *file, unsigned long addr,
1131 unsigned long len, unsigned long flags, 1144 unsigned long len, unsigned long flags,
1132 unsigned int vm_flags, unsigned long pgoff, 1145 unsigned int vm_flags, unsigned long pgoff);
1133 int accountable);
1134 1146
1135static inline unsigned long do_mmap(struct file *file, unsigned long addr, 1147static inline unsigned long do_mmap(struct file *file, unsigned long addr,
1136 unsigned long len, unsigned long prot, 1148 unsigned long len, unsigned long prot,
@@ -1160,6 +1172,7 @@ extern int filemap_fault(struct vm_area_struct *, struct vm_fault *);
1160 1172
1161/* mm/page-writeback.c */ 1173/* mm/page-writeback.c */
1162int write_one_page(struct page *page, int wait); 1174int write_one_page(struct page *page, int wait);
1175void task_dirty_inc(struct task_struct *tsk);
1163 1176
1164/* readahead.c */ 1177/* readahead.c */
1165#define VM_MAX_READAHEAD 128 /* kbytes */ 1178#define VM_MAX_READAHEAD 128 /* kbytes */
@@ -1305,5 +1318,6 @@ void vmemmap_populate_print_last(void);
1305 1318
1306extern void *alloc_locked_buffer(size_t size); 1319extern void *alloc_locked_buffer(size_t size);
1307extern void free_locked_buffer(void *buffer, size_t size); 1320extern void free_locked_buffer(void *buffer, size_t size);
1321extern void release_locked_buffer(void *buffer, size_t size);
1308#endif /* __KERNEL__ */ 1322#endif /* __KERNEL__ */
1309#endif /* _LINUX_MM_H */ 1323#endif /* _LINUX_MM_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 09c14e213b63..1aca6cebbb78 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1071,7 +1071,7 @@ void sparse_init(void);
1071#endif /* CONFIG_SPARSEMEM */ 1071#endif /* CONFIG_SPARSEMEM */
1072 1072
1073#ifdef CONFIG_NODES_SPAN_OTHER_NODES 1073#ifdef CONFIG_NODES_SPAN_OTHER_NODES
1074#define early_pfn_in_nid(pfn, nid) (early_pfn_to_nid(pfn) == (nid)) 1074bool early_pfn_in_nid(unsigned long pfn, int nid);
1075#else 1075#else
1076#define early_pfn_in_nid(pfn, nid) (1) 1076#define early_pfn_in_nid(pfn, nid) (1)
1077#endif 1077#endif
diff --git a/include/linux/module.h b/include/linux/module.h
index f3b8329eb5b8..145a75528cc1 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -407,7 +407,6 @@ static inline local_t *__module_ref_addr(struct module *mod, int cpu)
407static inline void __module_get(struct module *module) 407static inline void __module_get(struct module *module)
408{ 408{
409 if (module) { 409 if (module) {
410 BUG_ON(module_refcount(module) == 0);
411 local_inc(__module_ref_addr(module, get_cpu())); 410 local_inc(__module_ref_addr(module, get_cpu()));
412 put_cpu(); 411 put_cpu();
413 } 412 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 48890cf3f96e..7bd624bfdcfd 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -684,7 +684,7 @@ int pci_enable_rom(struct pci_dev *pdev);
684void pci_disable_rom(struct pci_dev *pdev); 684void pci_disable_rom(struct pci_dev *pdev);
685void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); 685void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size);
686void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); 686void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
687size_t pci_get_rom_size(void __iomem *rom, size_t size); 687size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size);
688 688
689/* Power management related routines */ 689/* Power management related routines */
690int pci_save_state(struct pci_dev *dev); 690int pci_save_state(struct pci_dev *dev);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 52a9fe08451c..aca8c458aa8a 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1312,6 +1312,7 @@
1312#define PCI_DEVICE_ID_VIA_VT3351 0x0351 1312#define PCI_DEVICE_ID_VIA_VT3351 0x0351
1313#define PCI_DEVICE_ID_VIA_VT3364 0x0364 1313#define PCI_DEVICE_ID_VIA_VT3364 0x0364
1314#define PCI_DEVICE_ID_VIA_8371_0 0x0391 1314#define PCI_DEVICE_ID_VIA_8371_0 0x0391
1315#define PCI_DEVICE_ID_VIA_6415 0x0415
1315#define PCI_DEVICE_ID_VIA_8501_0 0x0501 1316#define PCI_DEVICE_ID_VIA_8501_0 0x0501
1316#define PCI_DEVICE_ID_VIA_82C561 0x0561 1317#define PCI_DEVICE_ID_VIA_82C561 0x0561
1317#define PCI_DEVICE_ID_VIA_82C586_1 0x0571 1318#define PCI_DEVICE_ID_VIA_82C586_1 0x0571
@@ -1444,6 +1445,7 @@
1444#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071 1445#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071
1445#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072 1446#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072
1446#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073 1447#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073
1448#define PCI_DEVICE_ID_DIGI_NEO_8 0x00B1
1447#define PCI_DEVICE_ID_NEO_2DB9 0x00C8 1449#define PCI_DEVICE_ID_NEO_2DB9 0x00C8
1448#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9 1450#define PCI_DEVICE_ID_NEO_2DB9PRI 0x00C9
1449#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA 1451#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA
@@ -2321,6 +2323,9 @@
2321#define PCI_DEVICE_ID_INTEL_82378 0x0484 2323#define PCI_DEVICE_ID_INTEL_82378 0x0484
2322#define PCI_DEVICE_ID_INTEL_I960 0x0960 2324#define PCI_DEVICE_ID_INTEL_I960 0x0960
2323#define PCI_DEVICE_ID_INTEL_I960RM 0x0962 2325#define PCI_DEVICE_ID_INTEL_I960RM 0x0962
2326#define PCI_DEVICE_ID_INTEL_8257X_SOL 0x1062
2327#define PCI_DEVICE_ID_INTEL_82573E_SOL 0x1085
2328#define PCI_DEVICE_ID_INTEL_82573L_SOL 0x108F
2324#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130 2329#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130
2325#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132 2330#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132
2326#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 2331#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
diff --git a/include/linux/pm.h b/include/linux/pm.h
index de2e0a8f6728..24ba5f67b3a3 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -381,10 +381,12 @@ struct dev_pm_info {
381 381
382#ifdef CONFIG_PM_SLEEP 382#ifdef CONFIG_PM_SLEEP
383extern void device_pm_lock(void); 383extern void device_pm_lock(void);
384extern int sysdev_resume(void);
384extern void device_power_up(pm_message_t state); 385extern void device_power_up(pm_message_t state);
385extern void device_resume(pm_message_t state); 386extern void device_resume(pm_message_t state);
386 387
387extern void device_pm_unlock(void); 388extern void device_pm_unlock(void);
389extern int sysdev_suspend(pm_message_t state);
388extern int device_power_down(pm_message_t state); 390extern int device_power_down(pm_message_t state);
389extern int device_suspend(pm_message_t state); 391extern int device_suspend(pm_message_t state);
390extern int device_prepare_suspend(pm_message_t state); 392extern int device_prepare_suspend(pm_message_t state);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 5a7c76388731..8981e52c714f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -453,23 +453,33 @@ struct task_cputime {
453 cputime_t utime; 453 cputime_t utime;
454 cputime_t stime; 454 cputime_t stime;
455 unsigned long long sum_exec_runtime; 455 unsigned long long sum_exec_runtime;
456 spinlock_t lock;
457}; 456};
458/* Alternate field names when used to cache expirations. */ 457/* Alternate field names when used to cache expirations. */
459#define prof_exp stime 458#define prof_exp stime
460#define virt_exp utime 459#define virt_exp utime
461#define sched_exp sum_exec_runtime 460#define sched_exp sum_exec_runtime
462 461
462#define INIT_CPUTIME \
463 (struct task_cputime) { \
464 .utime = cputime_zero, \
465 .stime = cputime_zero, \
466 .sum_exec_runtime = 0, \
467 }
468
463/** 469/**
464 * struct thread_group_cputime - thread group interval timer counts 470 * struct thread_group_cputimer - thread group interval timer counts
465 * @totals: thread group interval timers; substructure for 471 * @cputime: thread group interval timers.
466 * uniprocessor kernel, per-cpu for SMP kernel. 472 * @running: non-zero when there are timers running and
473 * @cputime receives updates.
474 * @lock: lock for fields in this struct.
467 * 475 *
468 * This structure contains the version of task_cputime, above, that is 476 * This structure contains the version of task_cputime, above, that is
469 * used for thread group CPU clock calculations. 477 * used for thread group CPU timer calculations.
470 */ 478 */
471struct thread_group_cputime { 479struct thread_group_cputimer {
472 struct task_cputime totals; 480 struct task_cputime cputime;
481 int running;
482 spinlock_t lock;
473}; 483};
474 484
475/* 485/*
@@ -518,10 +528,10 @@ struct signal_struct {
518 cputime_t it_prof_incr, it_virt_incr; 528 cputime_t it_prof_incr, it_virt_incr;
519 529
520 /* 530 /*
521 * Thread group totals for process CPU clocks. 531 * Thread group totals for process CPU timers.
522 * See thread_group_cputime(), et al, for details. 532 * See thread_group_cputimer(), et al, for details.
523 */ 533 */
524 struct thread_group_cputime cputime; 534 struct thread_group_cputimer cputimer;
525 535
526 /* Earliest-expiration cache. */ 536 /* Earliest-expiration cache. */
527 struct task_cputime cputime_expires; 537 struct task_cputime cputime_expires;
@@ -558,7 +568,7 @@ struct signal_struct {
558 * Live threads maintain their own counters and add to these 568 * Live threads maintain their own counters and add to these
559 * in __exit_signal, except for the group leader. 569 * in __exit_signal, except for the group leader.
560 */ 570 */
561 cputime_t cutime, cstime; 571 cputime_t utime, stime, cutime, cstime;
562 cputime_t gtime; 572 cputime_t gtime;
563 cputime_t cgtime; 573 cputime_t cgtime;
564 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; 574 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
@@ -567,6 +577,14 @@ struct signal_struct {
567 struct task_io_accounting ioac; 577 struct task_io_accounting ioac;
568 578
569 /* 579 /*
580 * Cumulative ns of schedule CPU time fo dead threads in the
581 * group, not including a zombie group leader, (This only differs
582 * from jiffies_to_ns(utime + stime) if sched_clock uses something
583 * other than jiffies.)
584 */
585 unsigned long long sum_sched_runtime;
586
587 /*
570 * We don't bother to synchronize most readers of this at all, 588 * We don't bother to synchronize most readers of this at all,
571 * because there is no reader checking a limit that actually needs 589 * because there is no reader checking a limit that actually needs
572 * to get both rlim_cur and rlim_max atomically, and either one 590 * to get both rlim_cur and rlim_max atomically, and either one
@@ -2182,27 +2200,14 @@ static inline int spin_needbreak(spinlock_t *lock)
2182/* 2200/*
2183 * Thread group CPU time accounting. 2201 * Thread group CPU time accounting.
2184 */ 2202 */
2185 2203void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
2186static inline 2204void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times);
2187void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
2188{
2189 struct task_cputime *totals = &tsk->signal->cputime.totals;
2190 unsigned long flags;
2191
2192 spin_lock_irqsave(&totals->lock, flags);
2193 *times = *totals;
2194 spin_unlock_irqrestore(&totals->lock, flags);
2195}
2196 2205
2197static inline void thread_group_cputime_init(struct signal_struct *sig) 2206static inline void thread_group_cputime_init(struct signal_struct *sig)
2198{ 2207{
2199 sig->cputime.totals = (struct task_cputime){ 2208 sig->cputimer.cputime = INIT_CPUTIME;
2200 .utime = cputime_zero, 2209 spin_lock_init(&sig->cputimer.lock);
2201 .stime = cputime_zero, 2210 sig->cputimer.running = 0;
2202 .sum_exec_runtime = 0,
2203 };
2204
2205 spin_lock_init(&sig->cputime.totals.lock);
2206} 2211}
2207 2212
2208static inline void thread_group_cputime_free(struct signal_struct *sig) 2213static inline void thread_group_cputime_free(struct signal_struct *sig)
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 40ea5058c2ec..f616f31576d7 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -19,6 +19,7 @@ struct seq_file {
19 size_t from; 19 size_t from;
20 size_t count; 20 size_t count;
21 loff_t index; 21 loff_t index;
22 loff_t read_pos;
22 u64 version; 23 u64 version;
23 struct mutex lock; 24 struct mutex lock;
24 const struct seq_operations *op; 25 const struct seq_operations *op;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 90bbbf0b1161..df9245c7bd3b 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -296,6 +296,7 @@ struct uart_port {
296#define UPF_HARDPPS_CD ((__force upf_t) (1 << 11)) 296#define UPF_HARDPPS_CD ((__force upf_t) (1 << 11))
297#define UPF_LOW_LATENCY ((__force upf_t) (1 << 13)) 297#define UPF_LOW_LATENCY ((__force upf_t) (1 << 13))
298#define UPF_BUGGY_UART ((__force upf_t) (1 << 14)) 298#define UPF_BUGGY_UART ((__force upf_t) (1 << 14))
299#define UPF_NO_TXEN_TEST ((__force upf_t) (1 << 15))
299#define UPF_MAGIC_MULTIPLIER ((__force upf_t) (1 << 16)) 300#define UPF_MAGIC_MULTIPLIER ((__force upf_t) (1 << 16))
300#define UPF_CONS_FLOW ((__force upf_t) (1 << 23)) 301#define UPF_CONS_FLOW ((__force upf_t) (1 << 23))
301#define UPF_SHARE_IRQ ((__force upf_t) (1 << 24)) 302#define UPF_SHARE_IRQ ((__force upf_t) (1 << 24))
diff --git a/include/linux/slab.h b/include/linux/slab.h
index f96d13c281e8..24c5602bee99 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -127,6 +127,7 @@ int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr);
127void * __must_check __krealloc(const void *, size_t, gfp_t); 127void * __must_check __krealloc(const void *, size_t, gfp_t);
128void * __must_check krealloc(const void *, size_t, gfp_t); 128void * __must_check krealloc(const void *, size_t, gfp_t);
129void kfree(const void *); 129void kfree(const void *);
130void kzfree(const void *);
130size_t ksize(const void *); 131size_t ksize(const void *);
131 132
132/* 133/*
diff --git a/include/linux/soundcard.h b/include/linux/soundcard.h
index 523d069c862c..1904afedb82f 100644
--- a/include/linux/soundcard.h
+++ b/include/linux/soundcard.h
@@ -1045,50 +1045,36 @@ typedef struct mixer_vol_table {
1045 */ 1045 */
1046#define LOCL_STARTAUDIO 1 1046#define LOCL_STARTAUDIO 1
1047 1047
1048#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) 1048#if !defined(__KERNEL__) || defined(USE_SEQ_MACROS)
1049/* 1049/*
1050 * Some convenience macros to simplify programming of the 1050 * Some convenience macros to simplify programming of the
1051 * /dev/sequencer interface 1051 * /dev/sequencer interface
1052 * 1052 *
1053 * These macros define the API which should be used when possible. 1053 * This is a legacy interface for applications written against
1054 * the OSSlib-3.8 style interface. It is no longer possible
1055 * to actually link against OSSlib with this header, but we
1056 * still provide these macros for programs using them.
1057 *
1058 * If you want to use OSSlib, it is recommended that you get
1059 * the GPL version of OSS-4.x and build against that version
1060 * of the header.
1061 *
1062 * We redefine the extern keyword so that make headers_check
1063 * does not complain about SEQ_USE_EXTBUF.
1054 */ 1064 */
1055#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() 1065#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF()
1056 1066
1057void seqbuf_dump(void); /* This function must be provided by programs */ 1067void seqbuf_dump(void); /* This function must be provided by programs */
1058 1068
1059extern int OSS_init(int seqfd, int buflen);
1060extern void OSS_seqbuf_dump(int fd, unsigned char *buf, int buflen);
1061extern void OSS_seq_advbuf(int len, int fd, unsigned char *buf, int buflen);
1062extern void OSS_seq_needbuf(int len, int fd, unsigned char *buf, int buflen);
1063extern void OSS_patch_caching(int dev, int chn, int patch,
1064 int fd, unsigned char *buf, int buflen);
1065extern void OSS_drum_caching(int dev, int chn, int patch,
1066 int fd, unsigned char *buf, int buflen);
1067extern void OSS_write_patch(int fd, unsigned char *buf, int len);
1068extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
1069
1070#define SEQ_PM_DEFINES int __foo_bar___ 1069#define SEQ_PM_DEFINES int __foo_bar___
1071#ifdef OSSLIB 1070
1072# define SEQ_USE_EXTBUF() \ 1071#define SEQ_LOAD_GMINSTR(dev, instr)
1073 extern unsigned char *_seqbuf; \ 1072#define SEQ_LOAD_GMDRUM(dev, drum)
1074 extern int _seqbuflen;extern int _seqbufptr 1073
1075# define SEQ_DEFINEBUF(len) SEQ_USE_EXTBUF();static int _requested_seqbuflen=len 1074#define _SEQ_EXTERN extern
1076# define _SEQ_ADVBUF(len) OSS_seq_advbuf(len, seqfd, _seqbuf, _seqbuflen) 1075#define SEQ_USE_EXTBUF() \
1077# define _SEQ_NEEDBUF(len) OSS_seq_needbuf(len, seqfd, _seqbuf, _seqbuflen) 1076 _SEQ_EXTERN unsigned char _seqbuf[]; \
1078# define SEQ_DUMPBUF() OSS_seqbuf_dump(seqfd, _seqbuf, _seqbuflen) 1077 _SEQ_EXTERN int _seqbuflen; _SEQ_EXTERN int _seqbufptr
1079
1080# define SEQ_LOAD_GMINSTR(dev, instr) \
1081 OSS_patch_caching(dev, -1, instr, seqfd, _seqbuf, _seqbuflen)
1082# define SEQ_LOAD_GMDRUM(dev, drum) \
1083 OSS_drum_caching(dev, -1, drum, seqfd, _seqbuf, _seqbuflen)
1084#else /* !OSSLIB */
1085
1086# define SEQ_LOAD_GMINSTR(dev, instr)
1087# define SEQ_LOAD_GMDRUM(dev, drum)
1088
1089# define SEQ_USE_EXTBUF() \
1090 extern unsigned char _seqbuf[]; \
1091 extern int _seqbuflen;extern int _seqbufptr
1092 1078
1093#ifndef USE_SIMPLE_MACROS 1079#ifndef USE_SIMPLE_MACROS
1094/* Sample seqbuf_dump() implementation: 1080/* Sample seqbuf_dump() implementation:
@@ -1131,7 +1117,6 @@ extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
1131 */ 1117 */
1132#define _SEQ_NEEDBUF(len) /* empty */ 1118#define _SEQ_NEEDBUF(len) /* empty */
1133#endif 1119#endif
1134#endif /* !OSSLIB */
1135 1120
1136#define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\ 1121#define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\
1137 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 1122 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
@@ -1215,14 +1200,8 @@ extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
1215 _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0) 1200 _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
1216 1201
1217#define SEQ_SET_PATCH SEQ_PGM_CHANGE 1202#define SEQ_SET_PATCH SEQ_PGM_CHANGE
1218#ifdef OSSLIB 1203#define SEQ_PGM_CHANGE(dev, chn, patch) \
1219# define SEQ_PGM_CHANGE(dev, chn, patch) \
1220 {OSS_patch_caching(dev, chn, patch, seqfd, _seqbuf, _seqbuflen); \
1221 _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0);}
1222#else
1223# define SEQ_PGM_CHANGE(dev, chn, patch) \
1224 _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0) 1204 _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
1225#endif
1226 1205
1227#define SEQ_CONTROL(dev, chn, controller, value) \ 1206#define SEQ_CONTROL(dev, chn, controller, value) \
1228 _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value) 1207 _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
@@ -1300,19 +1279,12 @@ extern int OSS_write_patch2(int fd, unsigned char *buf, int len);
1300/* 1279/*
1301 * Patch loading. 1280 * Patch loading.
1302 */ 1281 */
1303#ifdef OSSLIB 1282#define SEQ_WRPATCH(patchx, len) \
1304# define SEQ_WRPATCH(patchx, len) \
1305 OSS_write_patch(seqfd, (char*)(patchx), len)
1306# define SEQ_WRPATCH2(patchx, len) \
1307 OSS_write_patch2(seqfd, (char*)(patchx), len)
1308#else
1309# define SEQ_WRPATCH(patchx, len) \
1310 {if (_seqbufptr) SEQ_DUMPBUF();\ 1283 {if (_seqbufptr) SEQ_DUMPBUF();\
1311 if (write(seqfd, (char*)(patchx), len)==-1) \ 1284 if (write(seqfd, (char*)(patchx), len)==-1) \
1312 perror("Write patch: /dev/sequencer");} 1285 perror("Write patch: /dev/sequencer");}
1313# define SEQ_WRPATCH2(patchx, len) \ 1286#define SEQ_WRPATCH2(patchx, len) \
1314 (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len)) 1287 (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))
1315#endif
1316 1288
1317#endif 1289#endif
1318#endif 1290#endif
diff --git a/include/linux/spi/spi_bitbang.h b/include/linux/spi/spi_bitbang.h
index bf8de281b4ed..eed4254bd503 100644
--- a/include/linux/spi/spi_bitbang.h
+++ b/include/linux/spi/spi_bitbang.h
@@ -83,6 +83,13 @@ extern int spi_bitbang_stop(struct spi_bitbang *spi);
83 * int getmiso(struct spi_device *); 83 * int getmiso(struct spi_device *);
84 * void spidelay(unsigned); 84 * void spidelay(unsigned);
85 * 85 *
86 * setsck()'s is_on parameter is a zero/nonzero boolean.
87 *
88 * setmosi()'s is_on parameter is a zero/nonzero boolean.
89 *
90 * getmiso() is required to return 0 or 1 only. Any other value is invalid
91 * and will result in improper operation.
92 *
86 * A non-inlined routine would call bitbang_txrx_*() routines. The 93 * A non-inlined routine would call bitbang_txrx_*() routines. The
87 * main loop could easily compile down to a handful of instructions, 94 * main loop could easily compile down to a handful of instructions,
88 * especially if the delay is a NOP (to run at peak speed). 95 * especially if the delay is a NOP (to run at peak speed).
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index e0c0fccced46..a0c66a2e00ad 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -124,7 +124,12 @@ do { \
124#ifdef CONFIG_GENERIC_LOCKBREAK 124#ifdef CONFIG_GENERIC_LOCKBREAK
125#define spin_is_contended(lock) ((lock)->break_lock) 125#define spin_is_contended(lock) ((lock)->break_lock)
126#else 126#else
127
128#ifdef __raw_spin_is_contended
127#define spin_is_contended(lock) __raw_spin_is_contended(&(lock)->raw_lock) 129#define spin_is_contended(lock) __raw_spin_is_contended(&(lock)->raw_lock)
130#else
131#define spin_is_contended(lock) (((void)(lock), 0))
132#endif /*__raw_spin_is_contended*/
128#endif 133#endif
129 134
130/** 135/**
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 0eda02ff2414..f9f900cfd066 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -95,13 +95,13 @@ struct old_linux_dirent;
95#define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__) 95#define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__)
96#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__) 96#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
97 97
98#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void) 98#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
99#define SYSCALL_DEFINE1(...) SYSCALL_DEFINEx(1, __VA_ARGS__) 99#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
100#define SYSCALL_DEFINE2(...) SYSCALL_DEFINEx(2, __VA_ARGS__) 100#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
101#define SYSCALL_DEFINE3(...) SYSCALL_DEFINEx(3, __VA_ARGS__) 101#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
102#define SYSCALL_DEFINE4(...) SYSCALL_DEFINEx(4, __VA_ARGS__) 102#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
103#define SYSCALL_DEFINE5(...) SYSCALL_DEFINEx(5, __VA_ARGS__) 103#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
104#define SYSCALL_DEFINE6(...) SYSCALL_DEFINEx(6, __VA_ARGS__) 104#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
105 105
106#ifdef CONFIG_PPC64 106#ifdef CONFIG_PPC64
107#define SYSCALL_ALIAS(alias, name) \ 107#define SYSCALL_ALIAS(alias, name) \
@@ -121,21 +121,21 @@ struct old_linux_dirent;
121 121
122#define SYSCALL_DEFINE(name) static inline long SYSC_##name 122#define SYSCALL_DEFINE(name) static inline long SYSC_##name
123#define SYSCALL_DEFINEx(x, name, ...) \ 123#define SYSCALL_DEFINEx(x, name, ...) \
124 asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__)); \ 124 asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \
125 static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__)); \ 125 static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \
126 asmlinkage long SyS_##name(__SC_LONG##x(__VA_ARGS__)) \ 126 asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \
127 { \ 127 { \
128 __SC_TEST##x(__VA_ARGS__); \ 128 __SC_TEST##x(__VA_ARGS__); \
129 return (long) SYSC_##name(__SC_CAST##x(__VA_ARGS__)); \ 129 return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \
130 } \ 130 } \
131 SYSCALL_ALIAS(sys_##name, SyS_##name); \ 131 SYSCALL_ALIAS(sys##name, SyS##name); \
132 static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__)) 132 static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__))
133 133
134#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ 134#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
135 135
136#define SYSCALL_DEFINE(name) asmlinkage long sys_##name 136#define SYSCALL_DEFINE(name) asmlinkage long sys_##name
137#define SYSCALL_DEFINEx(x, name, ...) \ 137#define SYSCALL_DEFINEx(x, name, ...) \
138 asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__)) 138 asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))
139 139
140#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ 140#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
141 141
diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h
index 86cb0501d3e2..2d0792983f8c 100644
--- a/include/linux/timerfd.h
+++ b/include/linux/timerfd.h
@@ -11,13 +11,21 @@
11/* For O_CLOEXEC and O_NONBLOCK */ 11/* For O_CLOEXEC and O_NONBLOCK */
12#include <linux/fcntl.h> 12#include <linux/fcntl.h>
13 13
14/* Flags for timerfd_settime. */ 14/*
15 * CAREFUL: Check include/asm-generic/fcntl.h when defining
16 * new flags, since they might collide with O_* ones. We want
17 * to re-use O_* flags that couldn't possibly have a meaning
18 * from eventfd, in order to leave a free define-space for
19 * shared O_* flags.
20 */
15#define TFD_TIMER_ABSTIME (1 << 0) 21#define TFD_TIMER_ABSTIME (1 << 0)
16
17/* Flags for timerfd_create. */
18#define TFD_CLOEXEC O_CLOEXEC 22#define TFD_CLOEXEC O_CLOEXEC
19#define TFD_NONBLOCK O_NONBLOCK 23#define TFD_NONBLOCK O_NONBLOCK
20 24
25#define TFD_SHARED_FCNTL_FLAGS (TFD_CLOEXEC | TFD_NONBLOCK)
26/* Flags for timerfd_create. */
27#define TFD_CREATE_FLAGS TFD_SHARED_FCNTL_FLAGS
28/* Flags for timerfd_settime. */
29#define TFD_SETTIME_FLAGS TFD_TIMER_ABSTIME
21 30
22#endif /* _LINUX_TIMERFD_H */ 31#endif /* _LINUX_TIMERFD_H */
23
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 506e7620a986..9c0890c7a06a 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -84,6 +84,10 @@ extern struct vm_struct *get_vm_area_caller(unsigned long size,
84 unsigned long flags, void *caller); 84 unsigned long flags, void *caller);
85extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags, 85extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
86 unsigned long start, unsigned long end); 86 unsigned long start, unsigned long end);
87extern struct vm_struct *__get_vm_area_caller(unsigned long size,
88 unsigned long flags,
89 unsigned long start, unsigned long end,
90 void *caller);
87extern struct vm_struct *get_vm_area_node(unsigned long size, 91extern struct vm_struct *get_vm_area_node(unsigned long size,
88 unsigned long flags, int node, 92 unsigned long flags, int node,
89 gfp_t gfp_mask); 93 gfp_t gfp_mask);
diff --git a/include/linux/wait.h b/include/linux/wait.h
index ef609f842fac..a210ede73b56 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -132,6 +132,8 @@ static inline void __remove_wait_queue(wait_queue_head_t *head,
132 list_del(&old->task_list); 132 list_del(&old->task_list);
133} 133}
134 134
135void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
136 int nr_exclusive, int sync, void *key);
135void __wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key); 137void __wake_up(wait_queue_head_t *q, unsigned int mode, int nr, void *key);
136extern void __wake_up_locked(wait_queue_head_t *q, unsigned int mode); 138extern void __wake_up_locked(wait_queue_head_t *q, unsigned int mode);
137extern void __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr); 139extern void __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr);
@@ -333,16 +335,19 @@ do { \
333 for (;;) { \ 335 for (;;) { \
334 prepare_to_wait_exclusive(&wq, &__wait, \ 336 prepare_to_wait_exclusive(&wq, &__wait, \
335 TASK_INTERRUPTIBLE); \ 337 TASK_INTERRUPTIBLE); \
336 if (condition) \ 338 if (condition) { \
339 finish_wait(&wq, &__wait); \
337 break; \ 340 break; \
341 } \
338 if (!signal_pending(current)) { \ 342 if (!signal_pending(current)) { \
339 schedule(); \ 343 schedule(); \
340 continue; \ 344 continue; \
341 } \ 345 } \
342 ret = -ERESTARTSYS; \ 346 ret = -ERESTARTSYS; \
347 abort_exclusive_wait(&wq, &__wait, \
348 TASK_INTERRUPTIBLE, NULL); \
343 break; \ 349 break; \
344 } \ 350 } \
345 finish_wait(&wq, &__wait); \
346} while (0) 351} while (0)
347 352
348#define wait_event_interruptible_exclusive(wq, condition) \ 353#define wait_event_interruptible_exclusive(wq, condition) \
@@ -431,6 +436,8 @@ extern long interruptible_sleep_on_timeout(wait_queue_head_t *q,
431void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state); 436void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state);
432void prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state); 437void prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state);
433void finish_wait(wait_queue_head_t *q, wait_queue_t *wait); 438void finish_wait(wait_queue_head_t *q, wait_queue_t *wait);
439void abort_exclusive_wait(wait_queue_head_t *q, wait_queue_t *wait,
440 unsigned int mode, void *key);
434int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key); 441int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
435int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key); 442int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
436 443
diff --git a/include/video/aty128.h b/include/video/aty128.h
index 7079beb005e8..51ac69f05bdc 100644
--- a/include/video/aty128.h
+++ b/include/video/aty128.h
@@ -21,9 +21,9 @@
21#define I2C_CNTL_1 0x0094 21#define I2C_CNTL_1 0x0094
22#define PALETTE_INDEX 0x00b0 22#define PALETTE_INDEX 0x00b0
23#define PALETTE_DATA 0x00b4 23#define PALETTE_DATA 0x00b4
24#define CONFIG_CNTL 0x00e0 24#define CNFG_CNTL 0x00e0
25#define GEN_RESET_CNTL 0x00f0 25#define GEN_RESET_CNTL 0x00f0
26#define CONFIG_MEMSIZE 0x00f8 26#define CNFG_MEMSIZE 0x00f8
27#define MEM_CNTL 0x0140 27#define MEM_CNTL 0x0140
28#define MEM_POWER_MISC 0x015c 28#define MEM_POWER_MISC 0x015c
29#define AGP_BASE 0x0170 29#define AGP_BASE 0x0170
diff --git a/include/video/mach64.h b/include/video/mach64.h
index a8332e528ec1..89e91c0cb737 100644
--- a/include/video/mach64.h
+++ b/include/video/mach64.h
@@ -103,7 +103,7 @@
103#define CUR_HORZ_VERT_OFF 0x0070 /* Dword offset 0_1C */ 103#define CUR_HORZ_VERT_OFF 0x0070 /* Dword offset 0_1C */
104#define CUR2_HORZ_VERT_OFF 0x0070 /* Dword offset 0_1C */ 104#define CUR2_HORZ_VERT_OFF 0x0070 /* Dword offset 0_1C */
105 105
106#define CONFIG_PANEL_LG 0x0074 /* Dword offset 0_1D (LG) */ 106#define CNFG_PANEL_LG 0x0074 /* Dword offset 0_1D (LG) */
107 107
108/* General I/O Control */ 108/* General I/O Control */
109#define GP_IO 0x0078 /* Dword offset 0_1E */ 109#define GP_IO 0x0078 /* Dword offset 0_1E */
@@ -146,8 +146,8 @@
146#define CLOCK_SEL_CNTL 0x0090 /* Dword offset 0_24 */ 146#define CLOCK_SEL_CNTL 0x0090 /* Dword offset 0_24 */
147 147
148/* Configuration */ 148/* Configuration */
149#define CONFIG_STAT1 0x0094 /* Dword offset 0_25 */ 149#define CNFG_STAT1 0x0094 /* Dword offset 0_25 */
150#define CONFIG_STAT2 0x0098 /* Dword offset 0_26 */ 150#define CNFG_STAT2 0x0098 /* Dword offset 0_26 */
151 151
152/* Bus Control */ 152/* Bus Control */
153#define BUS_CNTL 0x00A0 /* Dword offset 0_28 */ 153#define BUS_CNTL 0x00A0 /* Dword offset 0_28 */
@@ -190,9 +190,9 @@
190#define POWER_MANAGEMENT_LG 0x00D8 /* Dword offset 0_36 (LG) */ 190#define POWER_MANAGEMENT_LG 0x00D8 /* Dword offset 0_36 (LG) */
191 191
192/* Configuration */ 192/* Configuration */
193#define CONFIG_CNTL 0x00DC /* Dword offset 0_37 (CT, ET, VT) */ 193#define CNFG_CNTL 0x00DC /* Dword offset 0_37 (CT, ET, VT) */
194#define CONFIG_CHIP_ID 0x00E0 /* Dword offset 0_38 */ 194#define CNFG_CHIP_ID 0x00E0 /* Dword offset 0_38 */
195#define CONFIG_STAT0 0x00E4 /* Dword offset 0_39 */ 195#define CNFG_STAT0 0x00E4 /* Dword offset 0_39 */
196 196
197/* Test and Debug */ 197/* Test and Debug */
198#define CRC_SIG 0x00E8 /* Dword offset 0_3A */ 198#define CRC_SIG 0x00E8 /* Dword offset 0_3A */
@@ -851,17 +851,17 @@
851#define PLL_YCLK_CNTL 0x29 851#define PLL_YCLK_CNTL 0x29
852#define PM_DYN_CLK_CNTL 0x2A 852#define PM_DYN_CLK_CNTL 0x2A
853 853
854/* CONFIG_CNTL register constants */ 854/* CNFG_CNTL register constants */
855#define APERTURE_4M_ENABLE 1 855#define APERTURE_4M_ENABLE 1
856#define APERTURE_8M_ENABLE 2 856#define APERTURE_8M_ENABLE 2
857#define VGA_APERTURE_ENABLE 4 857#define VGA_APERTURE_ENABLE 4
858 858
859/* CONFIG_STAT0 register constants (GX, CX) */ 859/* CNFG_STAT0 register constants (GX, CX) */
860#define CFG_BUS_TYPE 0x00000007 860#define CFG_BUS_TYPE 0x00000007
861#define CFG_MEM_TYPE 0x00000038 861#define CFG_MEM_TYPE 0x00000038
862#define CFG_INIT_DAC_TYPE 0x00000e00 862#define CFG_INIT_DAC_TYPE 0x00000e00
863 863
864/* CONFIG_STAT0 register constants (CT, ET, VT) */ 864/* CNFG_STAT0 register constants (CT, ET, VT) */
865#define CFG_MEM_TYPE_xT 0x00000007 865#define CFG_MEM_TYPE_xT 0x00000007
866 866
867#define ISA 0 867#define ISA 0
@@ -942,7 +942,7 @@
942#define PCI_ATI_VENDOR_ID 0x1002 942#define PCI_ATI_VENDOR_ID 0x1002
943 943
944 944
945/* CONFIG_CHIP_ID register constants */ 945/* CNFG_CHIP_ID register constants */
946#define CFG_CHIP_TYPE 0x0000FFFF 946#define CFG_CHIP_TYPE 0x0000FFFF
947#define CFG_CHIP_CLASS 0x00FF0000 947#define CFG_CHIP_CLASS 0x00FF0000
948#define CFG_CHIP_REV 0xFF000000 948#define CFG_CHIP_REV 0xFF000000
@@ -951,7 +951,7 @@
951#define CFG_CHIP_MINOR 0xC0000000 951#define CFG_CHIP_MINOR 0xC0000000
952 952
953 953
954/* Chip IDs read from CONFIG_CHIP_ID */ 954/* Chip IDs read from CNFG_CHIP_ID */
955 955
956/* mach64GX family */ 956/* mach64GX family */
957#define GX_CHIP_ID 0xD7 /* mach64GX (ATI888GX00) */ 957#define GX_CHIP_ID 0xD7 /* mach64GX (ATI888GX00) */
@@ -1254,7 +1254,7 @@
1254#define CRTC2_DISPLAY_DIS 0x00000400 1254#define CRTC2_DISPLAY_DIS 0x00000400
1255 1255
1256/* LCD register indices */ 1256/* LCD register indices */
1257#define CONFIG_PANEL 0x00 1257#define CNFG_PANEL 0x00
1258#define LCD_GEN_CNTL 0x01 1258#define LCD_GEN_CNTL 0x01
1259#define DSTN_CONTROL 0x02 1259#define DSTN_CONTROL 0x02
1260#define HFB_PITCH_ADDR 0x03 1260#define HFB_PITCH_ADDR 0x03
diff --git a/include/video/radeon.h b/include/video/radeon.h
index 1cd09cc5b169..e072b16b39ab 100644
--- a/include/video/radeon.h
+++ b/include/video/radeon.h
@@ -11,13 +11,13 @@
11#define HI_STAT 0x004C 11#define HI_STAT 0x004C
12#define BUS_CNTL1 0x0034 12#define BUS_CNTL1 0x0034
13#define I2C_CNTL_1 0x0094 13#define I2C_CNTL_1 0x0094
14#define CONFIG_CNTL 0x00E0 14#define CNFG_CNTL 0x00E0
15#define CONFIG_MEMSIZE 0x00F8 15#define CNFG_MEMSIZE 0x00F8
16#define CONFIG_APER_0_BASE 0x0100 16#define CNFG_APER_0_BASE 0x0100
17#define CONFIG_APER_1_BASE 0x0104 17#define CNFG_APER_1_BASE 0x0104
18#define CONFIG_APER_SIZE 0x0108 18#define CNFG_APER_SIZE 0x0108
19#define CONFIG_REG_1_BASE 0x010C 19#define CNFG_REG_1_BASE 0x010C
20#define CONFIG_REG_APER_SIZE 0x0110 20#define CNFG_REG_APER_SIZE 0x0110
21#define PAD_AGPINPUT_DELAY 0x0164 21#define PAD_AGPINPUT_DELAY 0x0164
22#define PAD_CTLR_STRENGTH 0x0168 22#define PAD_CTLR_STRENGTH 0x0168
23#define PAD_CTLR_UPDATE 0x016C 23#define PAD_CTLR_UPDATE 0x016C
@@ -509,7 +509,7 @@
509/* CLOCK_CNTL_INDEX bit constants */ 509/* CLOCK_CNTL_INDEX bit constants */
510#define PLL_WR_EN 0x00000080 510#define PLL_WR_EN 0x00000080
511 511
512/* CONFIG_CNTL bit constants */ 512/* CNFG_CNTL bit constants */
513#define CFG_VGA_RAM_EN 0x00000100 513#define CFG_VGA_RAM_EN 0x00000100
514#define CFG_ATI_REV_ID_MASK (0xf << 16) 514#define CFG_ATI_REV_ID_MASK (0xf << 16)
515#define CFG_ATI_REV_A11 (0 << 16) 515#define CFG_ATI_REV_A11 (0 << 16)
@@ -980,7 +980,7 @@
980 980
981/* masks */ 981/* masks */
982 982
983#define CONFIG_MEMSIZE_MASK 0x1f000000 983#define CNFG_MEMSIZE_MASK 0x1f000000
984#define MEM_CFG_TYPE 0x40000000 984#define MEM_CFG_TYPE 0x40000000
985#define DST_OFFSET_MASK 0x003fffff 985#define DST_OFFSET_MASK 0x003fffff
986#define DST_PITCH_MASK 0x3fc00000 986#define DST_PITCH_MASK 0x3fc00000
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 708105e163df..8d4ff5afc1d8 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -370,10 +370,14 @@ void __init prepare_namespace(void)
370 ssleep(root_delay); 370 ssleep(root_delay);
371 } 371 }
372 372
373 /* wait for the known devices to complete their probing */ 373 /*
374 while (driver_probe_done() != 0) 374 * wait for the known devices to complete their probing
375 msleep(100); 375 *
376 async_synchronize_full(); 376 * Note: this is a potential source of long boot delays.
377 * For example, it is not atypical to wait 5 seconds here
378 * for the touchpad of a laptop to initialize.
379 */
380 wait_for_device_probe();
377 381
378 md_run_setup(); 382 md_run_setup();
379 383
@@ -399,6 +403,7 @@ void __init prepare_namespace(void)
399 while (driver_probe_done() != 0 || 403 while (driver_probe_done() != 0 ||
400 (ROOT_DEV = name_to_dev_t(saved_root_name)) == 0) 404 (ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
401 msleep(100); 405 msleep(100);
406 async_synchronize_full();
402 } 407 }
403 408
404 is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR; 409 is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
index ff95e3192884..9bdddbcb3d6a 100644
--- a/init/do_mounts_md.c
+++ b/init/do_mounts_md.c
@@ -281,8 +281,9 @@ static void __init autodetect_raid(void)
281 */ 281 */
282 printk(KERN_INFO "md: Waiting for all devices to be available before autodetect\n"); 282 printk(KERN_INFO "md: Waiting for all devices to be available before autodetect\n");
283 printk(KERN_INFO "md: If you don't use raid, use raid=noautodetect\n"); 283 printk(KERN_INFO "md: If you don't use raid, use raid=noautodetect\n");
284 while (driver_probe_done() < 0) 284
285 msleep(100); 285 wait_for_device_probe();
286
286 fd = sys_open("/dev/md0", 0, 0); 287 fd = sys_open("/dev/md0", 0, 0);
287 if (fd >= 0) { 288 if (fd >= 0) {
288 sys_ioctl(fd, RAID_AUTORUN, raid_autopart); 289 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
diff --git a/ipc/shm.c b/ipc/shm.c
index c0a021f7f41a..05d51d2a792c 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -340,6 +340,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
340 struct file * file; 340 struct file * file;
341 char name[13]; 341 char name[13];
342 int id; 342 int id;
343 int acctflag = 0;
343 344
344 if (size < SHMMIN || size > ns->shm_ctlmax) 345 if (size < SHMMIN || size > ns->shm_ctlmax)
345 return -EINVAL; 346 return -EINVAL;
@@ -364,11 +365,12 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
364 365
365 sprintf (name, "SYSV%08x", key); 366 sprintf (name, "SYSV%08x", key);
366 if (shmflg & SHM_HUGETLB) { 367 if (shmflg & SHM_HUGETLB) {
367 /* hugetlb_file_setup takes care of mlock user accounting */ 368 /* hugetlb_file_setup applies strict accounting */
368 file = hugetlb_file_setup(name, size); 369 if (shmflg & SHM_NORESERVE)
370 acctflag = VM_NORESERVE;
371 file = hugetlb_file_setup(name, size, acctflag);
369 shp->mlock_user = current_user(); 372 shp->mlock_user = current_user();
370 } else { 373 } else {
371 int acctflag = 0;
372 /* 374 /*
373 * Do not allow no accounting for OVERCOMMIT_NEVER, even 375 * Do not allow no accounting for OVERCOMMIT_NEVER, even
374 * if it's asked for. 376 * if it's asked for.
@@ -565,11 +567,15 @@ static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss,
565 struct hstate *h = hstate_file(shp->shm_file); 567 struct hstate *h = hstate_file(shp->shm_file);
566 *rss += pages_per_huge_page(h) * mapping->nrpages; 568 *rss += pages_per_huge_page(h) * mapping->nrpages;
567 } else { 569 } else {
570#ifdef CONFIG_SHMEM
568 struct shmem_inode_info *info = SHMEM_I(inode); 571 struct shmem_inode_info *info = SHMEM_I(inode);
569 spin_lock(&info->lock); 572 spin_lock(&info->lock);
570 *rss += inode->i_mapping->nrpages; 573 *rss += inode->i_mapping->nrpages;
571 *swp += info->swapped; 574 *swp += info->swapped;
572 spin_unlock(&info->lock); 575 spin_unlock(&info->lock);
576#else
577 *rss += inode->i_mapping->nrpages;
578#endif
573 } 579 }
574 580
575 total++; 581 total++;
diff --git a/kernel/Makefile b/kernel/Makefile
index 170a9213c1b6..e4791b3ba55d 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_UID16) += uid16.o
51obj-$(CONFIG_MODULES) += module.o 51obj-$(CONFIG_MODULES) += module.o
52obj-$(CONFIG_KALLSYMS) += kallsyms.o 52obj-$(CONFIG_KALLSYMS) += kallsyms.o
53obj-$(CONFIG_PM) += power/ 53obj-$(CONFIG_PM) += power/
54obj-$(CONFIG_FREEZER) += power/
54obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o 55obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
55obj-$(CONFIG_KEXEC) += kexec.o 56obj-$(CONFIG_KEXEC) += kexec.o
56obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o 57obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
diff --git a/kernel/async.c b/kernel/async.c
index 608b32b42812..f565891f2c9b 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -54,6 +54,7 @@ asynchronous and synchronous parts of the kernel.
54#include <linux/sched.h> 54#include <linux/sched.h>
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/kthread.h> 56#include <linux/kthread.h>
57#include <linux/delay.h>
57#include <asm/atomic.h> 58#include <asm/atomic.h>
58 59
59static async_cookie_t next_cookie = 1; 60static async_cookie_t next_cookie = 1;
@@ -132,21 +133,23 @@ static void run_one_entry(void)
132 entry = list_first_entry(&async_pending, struct async_entry, list); 133 entry = list_first_entry(&async_pending, struct async_entry, list);
133 134
134 /* 2) move it to the running queue */ 135 /* 2) move it to the running queue */
135 list_del(&entry->list); 136 list_move_tail(&entry->list, entry->running);
136 list_add_tail(&entry->list, &async_running);
137 spin_unlock_irqrestore(&async_lock, flags); 137 spin_unlock_irqrestore(&async_lock, flags);
138 138
139 /* 3) run it (and print duration)*/ 139 /* 3) run it (and print duration)*/
140 if (initcall_debug && system_state == SYSTEM_BOOTING) { 140 if (initcall_debug && system_state == SYSTEM_BOOTING) {
141 printk("calling %lli_%pF @ %i\n", entry->cookie, entry->func, task_pid_nr(current)); 141 printk("calling %lli_%pF @ %i\n", (long long)entry->cookie,
142 entry->func, task_pid_nr(current));
142 calltime = ktime_get(); 143 calltime = ktime_get();
143 } 144 }
144 entry->func(entry->data, entry->cookie); 145 entry->func(entry->data, entry->cookie);
145 if (initcall_debug && system_state == SYSTEM_BOOTING) { 146 if (initcall_debug && system_state == SYSTEM_BOOTING) {
146 rettime = ktime_get(); 147 rettime = ktime_get();
147 delta = ktime_sub(rettime, calltime); 148 delta = ktime_sub(rettime, calltime);
148 printk("initcall %lli_%pF returned 0 after %lld usecs\n", entry->cookie, 149 printk("initcall %lli_%pF returned 0 after %lld usecs\n",
149 entry->func, ktime_to_ns(delta) >> 10); 150 (long long)entry->cookie,
151 entry->func,
152 (long long)ktime_to_ns(delta) >> 10);
150 } 153 }
151 154
152 /* 4) remove it from the running queue */ 155 /* 4) remove it from the running queue */
@@ -205,18 +208,44 @@ static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct l
205 return newcookie; 208 return newcookie;
206} 209}
207 210
211/**
212 * async_schedule - schedule a function for asynchronous execution
213 * @ptr: function to execute asynchronously
214 * @data: data pointer to pass to the function
215 *
216 * Returns an async_cookie_t that may be used for checkpointing later.
217 * Note: This function may be called from atomic or non-atomic contexts.
218 */
208async_cookie_t async_schedule(async_func_ptr *ptr, void *data) 219async_cookie_t async_schedule(async_func_ptr *ptr, void *data)
209{ 220{
210 return __async_schedule(ptr, data, &async_pending); 221 return __async_schedule(ptr, data, &async_running);
211} 222}
212EXPORT_SYMBOL_GPL(async_schedule); 223EXPORT_SYMBOL_GPL(async_schedule);
213 224
214async_cookie_t async_schedule_special(async_func_ptr *ptr, void *data, struct list_head *running) 225/**
226 * async_schedule_domain - schedule a function for asynchronous execution within a certain domain
227 * @ptr: function to execute asynchronously
228 * @data: data pointer to pass to the function
229 * @running: running list for the domain
230 *
231 * Returns an async_cookie_t that may be used for checkpointing later.
232 * @running may be used in the async_synchronize_*_domain() functions
233 * to wait within a certain synchronization domain rather than globally.
234 * A synchronization domain is specified via the running queue @running to use.
235 * Note: This function may be called from atomic or non-atomic contexts.
236 */
237async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
238 struct list_head *running)
215{ 239{
216 return __async_schedule(ptr, data, running); 240 return __async_schedule(ptr, data, running);
217} 241}
218EXPORT_SYMBOL_GPL(async_schedule_special); 242EXPORT_SYMBOL_GPL(async_schedule_domain);
219 243
244/**
245 * async_synchronize_full - synchronize all asynchronous function calls
246 *
247 * This function waits until all asynchronous function calls have been done.
248 */
220void async_synchronize_full(void) 249void async_synchronize_full(void)
221{ 250{
222 do { 251 do {
@@ -225,13 +254,30 @@ void async_synchronize_full(void)
225} 254}
226EXPORT_SYMBOL_GPL(async_synchronize_full); 255EXPORT_SYMBOL_GPL(async_synchronize_full);
227 256
228void async_synchronize_full_special(struct list_head *list) 257/**
258 * async_synchronize_full_domain - synchronize all asynchronous function within a certain domain
259 * @list: running list to synchronize on
260 *
261 * This function waits until all asynchronous function calls for the
262 * synchronization domain specified by the running list @list have been done.
263 */
264void async_synchronize_full_domain(struct list_head *list)
229{ 265{
230 async_synchronize_cookie_special(next_cookie, list); 266 async_synchronize_cookie_domain(next_cookie, list);
231} 267}
232EXPORT_SYMBOL_GPL(async_synchronize_full_special); 268EXPORT_SYMBOL_GPL(async_synchronize_full_domain);
233 269
234void async_synchronize_cookie_special(async_cookie_t cookie, struct list_head *running) 270/**
271 * async_synchronize_cookie_domain - synchronize asynchronous function calls within a certain domain with cookie checkpointing
272 * @cookie: async_cookie_t to use as checkpoint
273 * @running: running list to synchronize on
274 *
275 * This function waits until all asynchronous function calls for the
276 * synchronization domain specified by the running list @list submitted
277 * prior to @cookie have been done.
278 */
279void async_synchronize_cookie_domain(async_cookie_t cookie,
280 struct list_head *running)
235{ 281{
236 ktime_t starttime, delta, endtime; 282 ktime_t starttime, delta, endtime;
237 283
@@ -247,14 +293,22 @@ void async_synchronize_cookie_special(async_cookie_t cookie, struct list_head *r
247 delta = ktime_sub(endtime, starttime); 293 delta = ktime_sub(endtime, starttime);
248 294
249 printk("async_continuing @ %i after %lli usec\n", 295 printk("async_continuing @ %i after %lli usec\n",
250 task_pid_nr(current), ktime_to_ns(delta) >> 10); 296 task_pid_nr(current),
297 (long long)ktime_to_ns(delta) >> 10);
251 } 298 }
252} 299}
253EXPORT_SYMBOL_GPL(async_synchronize_cookie_special); 300EXPORT_SYMBOL_GPL(async_synchronize_cookie_domain);
254 301
302/**
303 * async_synchronize_cookie - synchronize asynchronous function calls with cookie checkpointing
304 * @cookie: async_cookie_t to use as checkpoint
305 *
306 * This function waits until all asynchronous function calls prior to @cookie
307 * have been done.
308 */
255void async_synchronize_cookie(async_cookie_t cookie) 309void async_synchronize_cookie(async_cookie_t cookie)
256{ 310{
257 async_synchronize_cookie_special(cookie, &async_running); 311 async_synchronize_cookie_domain(cookie, &async_running);
258} 312}
259EXPORT_SYMBOL_GPL(async_synchronize_cookie); 313EXPORT_SYMBOL_GPL(async_synchronize_cookie);
260 314
@@ -315,7 +369,11 @@ static int async_manager_thread(void *unused)
315 ec = atomic_read(&entry_count); 369 ec = atomic_read(&entry_count);
316 370
317 while (tc < ec && tc < MAX_THREADS) { 371 while (tc < ec && tc < MAX_THREADS) {
318 kthread_run(async_thread, NULL, "async/%i", tc); 372 if (IS_ERR(kthread_run(async_thread, NULL, "async/%i",
373 tc))) {
374 msleep(100);
375 continue;
376 }
319 atomic_inc(&thread_count); 377 atomic_inc(&thread_count);
320 tc++; 378 tc++;
321 } 379 }
@@ -330,7 +388,9 @@ static int async_manager_thread(void *unused)
330static int __init async_init(void) 388static int __init async_init(void)
331{ 389{
332 if (async_enabled) 390 if (async_enabled)
333 kthread_run(async_manager_thread, NULL, "async/mgr"); 391 if (IS_ERR(kthread_run(async_manager_thread, NULL,
392 "async/mgr")))
393 async_enabled = 0;
334 return 0; 394 return 0;
335} 395}
336 396
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 5a54ff42874e..9edb5c4b79b4 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1122,8 +1122,8 @@ static void cgroup_kill_sb(struct super_block *sb) {
1122 1122
1123 mutex_unlock(&cgroup_mutex); 1123 mutex_unlock(&cgroup_mutex);
1124 1124
1125 kfree(root);
1126 kill_litter_super(sb); 1125 kill_litter_super(sb);
1126 kfree(root);
1127} 1127}
1128 1128
1129static struct file_system_type cgroup_fs_type = { 1129static struct file_system_type cgroup_fs_type = {
@@ -2351,7 +2351,7 @@ static void cgroup_lock_hierarchy(struct cgroupfs_root *root)
2351 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { 2351 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
2352 struct cgroup_subsys *ss = subsys[i]; 2352 struct cgroup_subsys *ss = subsys[i];
2353 if (ss->root == root) 2353 if (ss->root == root)
2354 mutex_lock_nested(&ss->hierarchy_mutex, i); 2354 mutex_lock(&ss->hierarchy_mutex);
2355 } 2355 }
2356} 2356}
2357 2357
@@ -2637,6 +2637,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
2637 BUG_ON(!list_empty(&init_task.tasks)); 2637 BUG_ON(!list_empty(&init_task.tasks));
2638 2638
2639 mutex_init(&ss->hierarchy_mutex); 2639 mutex_init(&ss->hierarchy_mutex);
2640 lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key);
2640 ss->active = 1; 2641 ss->active = 1;
2641} 2642}
2642 2643
diff --git a/kernel/exit.c b/kernel/exit.c
index f80dec3f1875..efd30ccf3858 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -118,6 +118,8 @@ static void __exit_signal(struct task_struct *tsk)
118 * We won't ever get here for the group leader, since it 118 * We won't ever get here for the group leader, since it
119 * will have been the last reference on the signal_struct. 119 * will have been the last reference on the signal_struct.
120 */ 120 */
121 sig->utime = cputime_add(sig->utime, task_utime(tsk));
122 sig->stime = cputime_add(sig->stime, task_stime(tsk));
121 sig->gtime = cputime_add(sig->gtime, task_gtime(tsk)); 123 sig->gtime = cputime_add(sig->gtime, task_gtime(tsk));
122 sig->min_flt += tsk->min_flt; 124 sig->min_flt += tsk->min_flt;
123 sig->maj_flt += tsk->maj_flt; 125 sig->maj_flt += tsk->maj_flt;
@@ -126,6 +128,7 @@ static void __exit_signal(struct task_struct *tsk)
126 sig->inblock += task_io_get_inblock(tsk); 128 sig->inblock += task_io_get_inblock(tsk);
127 sig->oublock += task_io_get_oublock(tsk); 129 sig->oublock += task_io_get_oublock(tsk);
128 task_io_accounting_add(&sig->ioac, &tsk->ioac); 130 task_io_accounting_add(&sig->ioac, &tsk->ioac);
131 sig->sum_sched_runtime += tsk->se.sum_exec_runtime;
129 sig = NULL; /* Marker for below. */ 132 sig = NULL; /* Marker for below. */
130 } 133 }
131 134
diff --git a/kernel/fork.c b/kernel/fork.c
index 242a706e7721..a66fbde20715 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -851,13 +851,14 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
851 sig->tty_old_pgrp = NULL; 851 sig->tty_old_pgrp = NULL;
852 sig->tty = NULL; 852 sig->tty = NULL;
853 853
854 sig->cutime = sig->cstime = cputime_zero; 854 sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero;
855 sig->gtime = cputime_zero; 855 sig->gtime = cputime_zero;
856 sig->cgtime = cputime_zero; 856 sig->cgtime = cputime_zero;
857 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; 857 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0;
858 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; 858 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0;
859 sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0; 859 sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0;
860 task_io_accounting_init(&sig->ioac); 860 task_io_accounting_init(&sig->ioac);
861 sig->sum_sched_runtime = 0;
861 taskstats_tgid_init(sig); 862 taskstats_tgid_init(sig);
862 863
863 task_lock(current->group_leader); 864 task_lock(current->group_leader);
@@ -1005,6 +1006,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1005 * triggers too late. This doesn't hurt, the check is only there 1006 * triggers too late. This doesn't hurt, the check is only there
1006 * to stop root fork bombs. 1007 * to stop root fork bombs.
1007 */ 1008 */
1009 retval = -EAGAIN;
1008 if (nr_threads >= max_threads) 1010 if (nr_threads >= max_threads)
1009 goto bad_fork_cleanup_count; 1011 goto bad_fork_cleanup_count;
1010 1012
@@ -1093,7 +1095,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1093#ifdef CONFIG_DEBUG_MUTEXES 1095#ifdef CONFIG_DEBUG_MUTEXES
1094 p->blocked_on = NULL; /* not blocked yet */ 1096 p->blocked_on = NULL; /* not blocked yet */
1095#endif 1097#endif
1096 if (unlikely(ptrace_reparented(current))) 1098 if (unlikely(current->ptrace))
1097 ptrace_fork(p, clone_flags); 1099 ptrace_fork(p, clone_flags);
1098 1100
1099 /* Perform scheduler related setup. Assign this task to a CPU. */ 1101 /* Perform scheduler related setup. Assign this task to a CPU. */
diff --git a/kernel/futex.c b/kernel/futex.c
index f89d373a9c6d..438701adce23 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1165,6 +1165,7 @@ static int futex_wait(u32 __user *uaddr, int fshared,
1165 u32 val, ktime_t *abs_time, u32 bitset, int clockrt) 1165 u32 val, ktime_t *abs_time, u32 bitset, int clockrt)
1166{ 1166{
1167 struct task_struct *curr = current; 1167 struct task_struct *curr = current;
1168 struct restart_block *restart;
1168 DECLARE_WAITQUEUE(wait, curr); 1169 DECLARE_WAITQUEUE(wait, curr);
1169 struct futex_hash_bucket *hb; 1170 struct futex_hash_bucket *hb;
1170 struct futex_q q; 1171 struct futex_q q;
@@ -1216,11 +1217,13 @@ retry:
1216 1217
1217 if (!ret) 1218 if (!ret)
1218 goto retry; 1219 goto retry;
1219 return ret; 1220 goto out;
1220 } 1221 }
1221 ret = -EWOULDBLOCK; 1222 ret = -EWOULDBLOCK;
1222 if (uval != val) 1223 if (unlikely(uval != val)) {
1223 goto out_unlock_put_key; 1224 queue_unlock(&q, hb);
1225 goto out_put_key;
1226 }
1224 1227
1225 /* Only actually queue if *uaddr contained val. */ 1228 /* Only actually queue if *uaddr contained val. */
1226 queue_me(&q, hb); 1229 queue_me(&q, hb);
@@ -1284,38 +1287,38 @@ retry:
1284 */ 1287 */
1285 1288
1286 /* If we were woken (and unqueued), we succeeded, whatever. */ 1289 /* If we were woken (and unqueued), we succeeded, whatever. */
1290 ret = 0;
1287 if (!unqueue_me(&q)) 1291 if (!unqueue_me(&q))
1288 return 0; 1292 goto out_put_key;
1293 ret = -ETIMEDOUT;
1289 if (rem) 1294 if (rem)
1290 return -ETIMEDOUT; 1295 goto out_put_key;
1291 1296
1292 /* 1297 /*
1293 * We expect signal_pending(current), but another thread may 1298 * We expect signal_pending(current), but another thread may
1294 * have handled it for us already. 1299 * have handled it for us already.
1295 */ 1300 */
1301 ret = -ERESTARTSYS;
1296 if (!abs_time) 1302 if (!abs_time)
1297 return -ERESTARTSYS; 1303 goto out_put_key;
1298 else {
1299 struct restart_block *restart;
1300 restart = &current_thread_info()->restart_block;
1301 restart->fn = futex_wait_restart;
1302 restart->futex.uaddr = (u32 *)uaddr;
1303 restart->futex.val = val;
1304 restart->futex.time = abs_time->tv64;
1305 restart->futex.bitset = bitset;
1306 restart->futex.flags = 0;
1307
1308 if (fshared)
1309 restart->futex.flags |= FLAGS_SHARED;
1310 if (clockrt)
1311 restart->futex.flags |= FLAGS_CLOCKRT;
1312 return -ERESTART_RESTARTBLOCK;
1313 }
1314 1304
1315out_unlock_put_key: 1305 restart = &current_thread_info()->restart_block;
1316 queue_unlock(&q, hb); 1306 restart->fn = futex_wait_restart;
1317 put_futex_key(fshared, &q.key); 1307 restart->futex.uaddr = (u32 *)uaddr;
1308 restart->futex.val = val;
1309 restart->futex.time = abs_time->tv64;
1310 restart->futex.bitset = bitset;
1311 restart->futex.flags = 0;
1312
1313 if (fshared)
1314 restart->futex.flags |= FLAGS_SHARED;
1315 if (clockrt)
1316 restart->futex.flags |= FLAGS_CLOCKRT;
1318 1317
1318 ret = -ERESTART_RESTARTBLOCK;
1319
1320out_put_key:
1321 put_futex_key(fshared, &q.key);
1319out: 1322out:
1320 return ret; 1323 return ret;
1321} 1324}
diff --git a/kernel/irq/numa_migrate.c b/kernel/irq/numa_migrate.c
index ecf765c6a77a..acd88356ac76 100644
--- a/kernel/irq/numa_migrate.c
+++ b/kernel/irq/numa_migrate.c
@@ -71,7 +71,7 @@ static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
71 desc = irq_desc_ptrs[irq]; 71 desc = irq_desc_ptrs[irq];
72 72
73 if (desc && old_desc != desc) 73 if (desc && old_desc != desc)
74 goto out_unlock; 74 goto out_unlock;
75 75
76 node = cpu_to_node(cpu); 76 node = cpu_to_node(cpu);
77 desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node); 77 desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
@@ -84,10 +84,15 @@ static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
84 init_copy_one_irq_desc(irq, old_desc, desc, cpu); 84 init_copy_one_irq_desc(irq, old_desc, desc, cpu);
85 85
86 irq_desc_ptrs[irq] = desc; 86 irq_desc_ptrs[irq] = desc;
87 spin_unlock_irqrestore(&sparse_irq_lock, flags);
87 88
88 /* free the old one */ 89 /* free the old one */
89 free_one_irq_desc(old_desc, desc); 90 free_one_irq_desc(old_desc, desc);
91 spin_unlock(&old_desc->lock);
90 kfree(old_desc); 92 kfree(old_desc);
93 spin_lock(&desc->lock);
94
95 return desc;
91 96
92out_unlock: 97out_unlock:
93 spin_unlock_irqrestore(&sparse_irq_lock, flags); 98 spin_unlock_irqrestore(&sparse_irq_lock, flags);
diff --git a/kernel/itimer.c b/kernel/itimer.c
index 6a5fe93dd8bd..58762f7077ec 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -62,7 +62,7 @@ int do_getitimer(int which, struct itimerval *value)
62 struct task_cputime cputime; 62 struct task_cputime cputime;
63 cputime_t utime; 63 cputime_t utime;
64 64
65 thread_group_cputime(tsk, &cputime); 65 thread_group_cputimer(tsk, &cputime);
66 utime = cputime.utime; 66 utime = cputime.utime;
67 if (cputime_le(cval, utime)) { /* about to fire */ 67 if (cputime_le(cval, utime)) { /* about to fire */
68 cval = jiffies_to_cputime(1); 68 cval = jiffies_to_cputime(1);
@@ -82,7 +82,7 @@ int do_getitimer(int which, struct itimerval *value)
82 struct task_cputime times; 82 struct task_cputime times;
83 cputime_t ptime; 83 cputime_t ptime;
84 84
85 thread_group_cputime(tsk, &times); 85 thread_group_cputimer(tsk, &times);
86 ptime = cputime_add(times.utime, times.stime); 86 ptime = cputime_add(times.utime, times.stime);
87 if (cputime_le(cval, ptime)) { /* about to fire */ 87 if (cputime_le(cval, ptime)) { /* about to fire */
88 cval = jiffies_to_cputime(1); 88 cval = jiffies_to_cputime(1);
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 8a6d7b08864e..483899578259 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1465,6 +1465,11 @@ int kernel_kexec(void)
1465 error = device_power_down(PMSG_FREEZE); 1465 error = device_power_down(PMSG_FREEZE);
1466 if (error) 1466 if (error)
1467 goto Enable_irqs; 1467 goto Enable_irqs;
1468
1469 /* Suspend system devices */
1470 error = sysdev_suspend(PMSG_FREEZE);
1471 if (error)
1472 goto Power_up_devices;
1468 } else 1473 } else
1469#endif 1474#endif
1470 { 1475 {
@@ -1477,6 +1482,8 @@ int kernel_kexec(void)
1477 1482
1478#ifdef CONFIG_KEXEC_JUMP 1483#ifdef CONFIG_KEXEC_JUMP
1479 if (kexec_image->preserve_context) { 1484 if (kexec_image->preserve_context) {
1485 sysdev_resume();
1486 Power_up_devices:
1480 device_power_up(PMSG_RESTORE); 1487 device_power_up(PMSG_RESTORE);
1481 Enable_irqs: 1488 Enable_irqs:
1482 local_irq_enable(); 1489 local_irq_enable();
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index fa07da94d7be..e976e505648d 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -230,6 +230,71 @@ static int cpu_clock_sample(const clockid_t which_clock, struct task_struct *p,
230 return 0; 230 return 0;
231} 231}
232 232
233void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
234{
235 struct sighand_struct *sighand;
236 struct signal_struct *sig;
237 struct task_struct *t;
238
239 *times = INIT_CPUTIME;
240
241 rcu_read_lock();
242 sighand = rcu_dereference(tsk->sighand);
243 if (!sighand)
244 goto out;
245
246 sig = tsk->signal;
247
248 t = tsk;
249 do {
250 times->utime = cputime_add(times->utime, t->utime);
251 times->stime = cputime_add(times->stime, t->stime);
252 times->sum_exec_runtime += t->se.sum_exec_runtime;
253
254 t = next_thread(t);
255 } while (t != tsk);
256
257 times->utime = cputime_add(times->utime, sig->utime);
258 times->stime = cputime_add(times->stime, sig->stime);
259 times->sum_exec_runtime += sig->sum_sched_runtime;
260out:
261 rcu_read_unlock();
262}
263
264static void update_gt_cputime(struct task_cputime *a, struct task_cputime *b)
265{
266 if (cputime_gt(b->utime, a->utime))
267 a->utime = b->utime;
268
269 if (cputime_gt(b->stime, a->stime))
270 a->stime = b->stime;
271
272 if (b->sum_exec_runtime > a->sum_exec_runtime)
273 a->sum_exec_runtime = b->sum_exec_runtime;
274}
275
276void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
277{
278 struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
279 struct task_cputime sum;
280 unsigned long flags;
281
282 spin_lock_irqsave(&cputimer->lock, flags);
283 if (!cputimer->running) {
284 cputimer->running = 1;
285 /*
286 * The POSIX timer interface allows for absolute time expiry
287 * values through the TIMER_ABSTIME flag, therefore we have
288 * to synchronize the timer to the clock every time we start
289 * it.
290 */
291 thread_group_cputime(tsk, &sum);
292 update_gt_cputime(&cputimer->cputime, &sum);
293 }
294 *times = cputimer->cputime;
295 spin_unlock_irqrestore(&cputimer->lock, flags);
296}
297
233/* 298/*
234 * Sample a process (thread group) clock for the given group_leader task. 299 * Sample a process (thread group) clock for the given group_leader task.
235 * Must be called with tasklist_lock held for reading. 300 * Must be called with tasklist_lock held for reading.
@@ -457,7 +522,7 @@ void posix_cpu_timers_exit_group(struct task_struct *tsk)
457{ 522{
458 struct task_cputime cputime; 523 struct task_cputime cputime;
459 524
460 thread_group_cputime(tsk, &cputime); 525 thread_group_cputimer(tsk, &cputime);
461 cleanup_timers(tsk->signal->cpu_timers, 526 cleanup_timers(tsk->signal->cpu_timers,
462 cputime.utime, cputime.stime, cputime.sum_exec_runtime); 527 cputime.utime, cputime.stime, cputime.sum_exec_runtime);
463} 528}
@@ -616,6 +681,33 @@ static void cpu_timer_fire(struct k_itimer *timer)
616} 681}
617 682
618/* 683/*
684 * Sample a process (thread group) timer for the given group_leader task.
685 * Must be called with tasklist_lock held for reading.
686 */
687static int cpu_timer_sample_group(const clockid_t which_clock,
688 struct task_struct *p,
689 union cpu_time_count *cpu)
690{
691 struct task_cputime cputime;
692
693 thread_group_cputimer(p, &cputime);
694 switch (CPUCLOCK_WHICH(which_clock)) {
695 default:
696 return -EINVAL;
697 case CPUCLOCK_PROF:
698 cpu->cpu = cputime_add(cputime.utime, cputime.stime);
699 break;
700 case CPUCLOCK_VIRT:
701 cpu->cpu = cputime.utime;
702 break;
703 case CPUCLOCK_SCHED:
704 cpu->sched = cputime.sum_exec_runtime + task_delta_exec(p);
705 break;
706 }
707 return 0;
708}
709
710/*
619 * Guts of sys_timer_settime for CPU timers. 711 * Guts of sys_timer_settime for CPU timers.
620 * This is called with the timer locked and interrupts disabled. 712 * This is called with the timer locked and interrupts disabled.
621 * If we return TIMER_RETRY, it's necessary to release the timer's lock 713 * If we return TIMER_RETRY, it's necessary to release the timer's lock
@@ -676,7 +768,7 @@ int posix_cpu_timer_set(struct k_itimer *timer, int flags,
676 if (CPUCLOCK_PERTHREAD(timer->it_clock)) { 768 if (CPUCLOCK_PERTHREAD(timer->it_clock)) {
677 cpu_clock_sample(timer->it_clock, p, &val); 769 cpu_clock_sample(timer->it_clock, p, &val);
678 } else { 770 } else {
679 cpu_clock_sample_group(timer->it_clock, p, &val); 771 cpu_timer_sample_group(timer->it_clock, p, &val);
680 } 772 }
681 773
682 if (old) { 774 if (old) {
@@ -824,7 +916,7 @@ void posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec *itp)
824 read_unlock(&tasklist_lock); 916 read_unlock(&tasklist_lock);
825 goto dead; 917 goto dead;
826 } else { 918 } else {
827 cpu_clock_sample_group(timer->it_clock, p, &now); 919 cpu_timer_sample_group(timer->it_clock, p, &now);
828 clear_dead = (unlikely(p->exit_state) && 920 clear_dead = (unlikely(p->exit_state) &&
829 thread_group_empty(p)); 921 thread_group_empty(p));
830 } 922 }
@@ -964,6 +1056,19 @@ static void check_thread_timers(struct task_struct *tsk,
964 } 1056 }
965} 1057}
966 1058
1059static void stop_process_timers(struct task_struct *tsk)
1060{
1061 struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
1062 unsigned long flags;
1063
1064 if (!cputimer->running)
1065 return;
1066
1067 spin_lock_irqsave(&cputimer->lock, flags);
1068 cputimer->running = 0;
1069 spin_unlock_irqrestore(&cputimer->lock, flags);
1070}
1071
967/* 1072/*
968 * Check for any per-thread CPU timers that have fired and move them 1073 * Check for any per-thread CPU timers that have fired and move them
969 * off the tsk->*_timers list onto the firing list. Per-thread timers 1074 * off the tsk->*_timers list onto the firing list. Per-thread timers
@@ -987,13 +1092,15 @@ static void check_process_timers(struct task_struct *tsk,
987 sig->rlim[RLIMIT_CPU].rlim_cur == RLIM_INFINITY && 1092 sig->rlim[RLIMIT_CPU].rlim_cur == RLIM_INFINITY &&
988 list_empty(&timers[CPUCLOCK_VIRT]) && 1093 list_empty(&timers[CPUCLOCK_VIRT]) &&
989 cputime_eq(sig->it_virt_expires, cputime_zero) && 1094 cputime_eq(sig->it_virt_expires, cputime_zero) &&
990 list_empty(&timers[CPUCLOCK_SCHED])) 1095 list_empty(&timers[CPUCLOCK_SCHED])) {
1096 stop_process_timers(tsk);
991 return; 1097 return;
1098 }
992 1099
993 /* 1100 /*
994 * Collect the current process totals. 1101 * Collect the current process totals.
995 */ 1102 */
996 thread_group_cputime(tsk, &cputime); 1103 thread_group_cputimer(tsk, &cputime);
997 utime = cputime.utime; 1104 utime = cputime.utime;
998 ptime = cputime_add(utime, cputime.stime); 1105 ptime = cputime_add(utime, cputime.stime);
999 sum_sched_runtime = cputime.sum_exec_runtime; 1106 sum_sched_runtime = cputime.sum_exec_runtime;
@@ -1164,7 +1271,7 @@ void posix_cpu_timer_schedule(struct k_itimer *timer)
1164 clear_dead_task(timer, now); 1271 clear_dead_task(timer, now);
1165 goto out_unlock; 1272 goto out_unlock;
1166 } 1273 }
1167 cpu_clock_sample_group(timer->it_clock, p, &now); 1274 cpu_timer_sample_group(timer->it_clock, p, &now);
1168 bump_cpu_timer(timer, now); 1275 bump_cpu_timer(timer, now);
1169 /* Leave the tasklist_lock locked for the call below. */ 1276 /* Leave the tasklist_lock locked for the call below. */
1170 } 1277 }
@@ -1259,7 +1366,7 @@ static inline int fastpath_timer_check(struct task_struct *tsk)
1259 if (!task_cputime_zero(&sig->cputime_expires)) { 1366 if (!task_cputime_zero(&sig->cputime_expires)) {
1260 struct task_cputime group_sample; 1367 struct task_cputime group_sample;
1261 1368
1262 thread_group_cputime(tsk, &group_sample); 1369 thread_group_cputimer(tsk, &group_sample);
1263 if (task_cputime_expired(&group_sample, &sig->cputime_expires)) 1370 if (task_cputime_expired(&group_sample, &sig->cputime_expires))
1264 return 1; 1371 return 1;
1265 } 1372 }
@@ -1341,7 +1448,7 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
1341 struct list_head *head; 1448 struct list_head *head;
1342 1449
1343 BUG_ON(clock_idx == CPUCLOCK_SCHED); 1450 BUG_ON(clock_idx == CPUCLOCK_SCHED);
1344 cpu_clock_sample_group(clock_idx, tsk, &now); 1451 cpu_timer_sample_group(clock_idx, tsk, &now);
1345 1452
1346 if (oldval) { 1453 if (oldval) {
1347 if (!cputime_eq(*oldval, cputime_zero)) { 1454 if (!cputime_eq(*oldval, cputime_zero)) {
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index d7a10167a25b..720ea4f781bd 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -3,7 +3,7 @@ ifeq ($(CONFIG_PM_DEBUG),y)
3EXTRA_CFLAGS += -DDEBUG 3EXTRA_CFLAGS += -DDEBUG
4endif 4endif
5 5
6obj-y := main.o 6obj-$(CONFIG_PM) += main.o
7obj-$(CONFIG_PM_SLEEP) += console.o 7obj-$(CONFIG_PM_SLEEP) += console.o
8obj-$(CONFIG_FREEZER) += process.o 8obj-$(CONFIG_FREEZER) += process.o
9obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o 9obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
diff --git a/kernel/power/console.c b/kernel/power/console.c
index b8628be2a465..a3961b205de7 100644
--- a/kernel/power/console.c
+++ b/kernel/power/console.c
@@ -78,6 +78,12 @@ void pm_restore_console(void)
78 } 78 }
79 set_console(orig_fgconsole); 79 set_console(orig_fgconsole);
80 release_console_sem(); 80 release_console_sem();
81
82 if (vt_waitactive(orig_fgconsole)) {
83 pr_debug("Resume: Can't switch VCs.");
84 return;
85 }
86
81 kmsg_redirect = orig_kmsg; 87 kmsg_redirect = orig_kmsg;
82} 88}
83#endif 89#endif
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 432ee575c9ee..4a4a206b1979 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -227,6 +227,12 @@ static int create_image(int platform_mode)
227 "aborting hibernation\n"); 227 "aborting hibernation\n");
228 goto Enable_irqs; 228 goto Enable_irqs;
229 } 229 }
230 sysdev_suspend(PMSG_FREEZE);
231 if (error) {
232 printk(KERN_ERR "PM: Some devices failed to power down, "
233 "aborting hibernation\n");
234 goto Power_up_devices;
235 }
230 236
231 if (hibernation_test(TEST_CORE)) 237 if (hibernation_test(TEST_CORE))
232 goto Power_up; 238 goto Power_up;
@@ -242,9 +248,11 @@ static int create_image(int platform_mode)
242 if (!in_suspend) 248 if (!in_suspend)
243 platform_leave(platform_mode); 249 platform_leave(platform_mode);
244 Power_up: 250 Power_up:
251 sysdev_resume();
245 /* NOTE: device_power_up() is just a resume() for devices 252 /* NOTE: device_power_up() is just a resume() for devices
246 * that suspended with irqs off ... no overall powerup. 253 * that suspended with irqs off ... no overall powerup.
247 */ 254 */
255 Power_up_devices:
248 device_power_up(in_suspend ? 256 device_power_up(in_suspend ?
249 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); 257 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE);
250 Enable_irqs: 258 Enable_irqs:
@@ -335,6 +343,7 @@ static int resume_target_kernel(void)
335 "aborting resume\n"); 343 "aborting resume\n");
336 goto Enable_irqs; 344 goto Enable_irqs;
337 } 345 }
346 sysdev_suspend(PMSG_QUIESCE);
338 /* We'll ignore saved state, but this gets preempt count (etc) right */ 347 /* We'll ignore saved state, but this gets preempt count (etc) right */
339 save_processor_state(); 348 save_processor_state();
340 error = restore_highmem(); 349 error = restore_highmem();
@@ -357,6 +366,7 @@ static int resume_target_kernel(void)
357 swsusp_free(); 366 swsusp_free();
358 restore_processor_state(); 367 restore_processor_state();
359 touch_softlockup_watchdog(); 368 touch_softlockup_watchdog();
369 sysdev_resume();
360 device_power_up(PMSG_RECOVER); 370 device_power_up(PMSG_RECOVER);
361 Enable_irqs: 371 Enable_irqs:
362 local_irq_enable(); 372 local_irq_enable();
@@ -440,6 +450,7 @@ int hibernation_platform_enter(void)
440 local_irq_disable(); 450 local_irq_disable();
441 error = device_power_down(PMSG_HIBERNATE); 451 error = device_power_down(PMSG_HIBERNATE);
442 if (!error) { 452 if (!error) {
453 sysdev_suspend(PMSG_HIBERNATE);
443 hibernation_ops->enter(); 454 hibernation_ops->enter();
444 /* We should never get here */ 455 /* We should never get here */
445 while (1); 456 while (1);
@@ -595,6 +606,12 @@ static int software_resume(void)
595 unsigned int flags; 606 unsigned int flags;
596 607
597 /* 608 /*
609 * If the user said "noresume".. bail out early.
610 */
611 if (noresume)
612 return 0;
613
614 /*
598 * name_to_dev_t() below takes a sysfs buffer mutex when sysfs 615 * name_to_dev_t() below takes a sysfs buffer mutex when sysfs
599 * is configured into the kernel. Since the regular hibernate 616 * is configured into the kernel. Since the regular hibernate
600 * trigger path is via sysfs which takes a buffer mutex before 617 * trigger path is via sysfs which takes a buffer mutex before
@@ -610,6 +627,11 @@ static int software_resume(void)
610 mutex_unlock(&pm_mutex); 627 mutex_unlock(&pm_mutex);
611 return -ENOENT; 628 return -ENOENT;
612 } 629 }
630 /*
631 * Some device discovery might still be in progress; we need
632 * to wait for this to finish.
633 */
634 wait_for_device_probe();
613 swsusp_resume_device = name_to_dev_t(resume_file); 635 swsusp_resume_device = name_to_dev_t(resume_file);
614 pr_debug("PM: Resume from partition %s\n", resume_file); 636 pr_debug("PM: Resume from partition %s\n", resume_file);
615 } else { 637 } else {
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 239988873971..c9632f841f64 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -57,16 +57,6 @@ int pm_notifier_call_chain(unsigned long val)
57#ifdef CONFIG_PM_DEBUG 57#ifdef CONFIG_PM_DEBUG
58int pm_test_level = TEST_NONE; 58int pm_test_level = TEST_NONE;
59 59
60static int suspend_test(int level)
61{
62 if (pm_test_level == level) {
63 printk(KERN_INFO "suspend debug: Waiting for 5 seconds.\n");
64 mdelay(5000);
65 return 1;
66 }
67 return 0;
68}
69
70static const char * const pm_tests[__TEST_AFTER_LAST] = { 60static const char * const pm_tests[__TEST_AFTER_LAST] = {
71 [TEST_NONE] = "none", 61 [TEST_NONE] = "none",
72 [TEST_CORE] = "core", 62 [TEST_CORE] = "core",
@@ -125,14 +115,24 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
125} 115}
126 116
127power_attr(pm_test); 117power_attr(pm_test);
128#else /* !CONFIG_PM_DEBUG */ 118#endif /* CONFIG_PM_DEBUG */
129static inline int suspend_test(int level) { return 0; }
130#endif /* !CONFIG_PM_DEBUG */
131 119
132#endif /* CONFIG_PM_SLEEP */ 120#endif /* CONFIG_PM_SLEEP */
133 121
134#ifdef CONFIG_SUSPEND 122#ifdef CONFIG_SUSPEND
135 123
124static int suspend_test(int level)
125{
126#ifdef CONFIG_PM_DEBUG
127 if (pm_test_level == level) {
128 printk(KERN_INFO "suspend debug: Waiting for 5 seconds.\n");
129 mdelay(5000);
130 return 1;
131 }
132#endif /* !CONFIG_PM_DEBUG */
133 return 0;
134}
135
136#ifdef CONFIG_PM_TEST_SUSPEND 136#ifdef CONFIG_PM_TEST_SUSPEND
137 137
138/* 138/*
@@ -298,8 +298,12 @@ static int suspend_enter(suspend_state_t state)
298 goto Done; 298 goto Done;
299 } 299 }
300 300
301 if (!suspend_test(TEST_CORE)) 301 error = sysdev_suspend(PMSG_SUSPEND);
302 error = suspend_ops->enter(state); 302 if (!error) {
303 if (!suspend_test(TEST_CORE))
304 error = suspend_ops->enter(state);
305 sysdev_resume();
306 }
303 307
304 device_power_up(PMSG_RESUME); 308 device_power_up(PMSG_RESUME);
305 Done: 309 Done:
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 6da14358537c..505f319e489c 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -60,6 +60,7 @@ static struct block_device *resume_bdev;
60static int submit(int rw, pgoff_t page_off, struct page *page, 60static int submit(int rw, pgoff_t page_off, struct page *page,
61 struct bio **bio_chain) 61 struct bio **bio_chain)
62{ 62{
63 const int bio_rw = rw | (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
63 struct bio *bio; 64 struct bio *bio;
64 65
65 bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1); 66 bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1);
@@ -80,7 +81,7 @@ static int submit(int rw, pgoff_t page_off, struct page *page,
80 bio_get(bio); 81 bio_get(bio);
81 82
82 if (bio_chain == NULL) { 83 if (bio_chain == NULL) {
83 submit_bio(rw | (1 << BIO_RW_SYNC), bio); 84 submit_bio(bio_rw, bio);
84 wait_on_page_locked(page); 85 wait_on_page_locked(page);
85 if (rw == READ) 86 if (rw == READ)
86 bio_set_pages_dirty(bio); 87 bio_set_pages_dirty(bio);
@@ -90,7 +91,7 @@ static int submit(int rw, pgoff_t page_off, struct page *page,
90 get_page(page); /* These pages are freed later */ 91 get_page(page); /* These pages are freed later */
91 bio->bi_private = *bio_chain; 92 bio->bi_private = *bio_chain;
92 *bio_chain = bio; 93 *bio_chain = bio;
93 submit_bio(rw | (1 << BIO_RW_SYNC), bio); 94 submit_bio(bio_rw, bio);
94 } 95 }
95 return 0; 96 return 0;
96} 97}
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 005b93d839ba..6c85359364f2 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -95,15 +95,15 @@ static int snapshot_open(struct inode *inode, struct file *filp)
95 data->swap = swsusp_resume_device ? 95 data->swap = swsusp_resume_device ?
96 swap_type_of(swsusp_resume_device, 0, NULL) : -1; 96 swap_type_of(swsusp_resume_device, 0, NULL) : -1;
97 data->mode = O_RDONLY; 97 data->mode = O_RDONLY;
98 error = pm_notifier_call_chain(PM_RESTORE_PREPARE); 98 error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
99 if (error) 99 if (error)
100 pm_notifier_call_chain(PM_POST_RESTORE); 100 pm_notifier_call_chain(PM_POST_HIBERNATION);
101 } else { 101 } else {
102 data->swap = -1; 102 data->swap = -1;
103 data->mode = O_WRONLY; 103 data->mode = O_WRONLY;
104 error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE); 104 error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
105 if (error) 105 if (error)
106 pm_notifier_call_chain(PM_POST_HIBERNATION); 106 pm_notifier_call_chain(PM_POST_RESTORE);
107 } 107 }
108 if (error) 108 if (error)
109 atomic_inc(&snapshot_device_available); 109 atomic_inc(&snapshot_device_available);
diff --git a/kernel/printk.c b/kernel/printk.c
index 69188f226a93..e3602d0755b0 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -73,7 +73,6 @@ EXPORT_SYMBOL(oops_in_progress);
73 * driver system. 73 * driver system.
74 */ 74 */
75static DECLARE_MUTEX(console_sem); 75static DECLARE_MUTEX(console_sem);
76static DECLARE_MUTEX(secondary_console_sem);
77struct console *console_drivers; 76struct console *console_drivers;
78EXPORT_SYMBOL_GPL(console_drivers); 77EXPORT_SYMBOL_GPL(console_drivers);
79 78
@@ -891,12 +890,14 @@ void suspend_console(void)
891 printk("Suspending console(s) (use no_console_suspend to debug)\n"); 890 printk("Suspending console(s) (use no_console_suspend to debug)\n");
892 acquire_console_sem(); 891 acquire_console_sem();
893 console_suspended = 1; 892 console_suspended = 1;
893 up(&console_sem);
894} 894}
895 895
896void resume_console(void) 896void resume_console(void)
897{ 897{
898 if (!console_suspend_enabled) 898 if (!console_suspend_enabled)
899 return; 899 return;
900 down(&console_sem);
900 console_suspended = 0; 901 console_suspended = 0;
901 release_console_sem(); 902 release_console_sem();
902} 903}
@@ -912,11 +913,9 @@ void resume_console(void)
912void acquire_console_sem(void) 913void acquire_console_sem(void)
913{ 914{
914 BUG_ON(in_interrupt()); 915 BUG_ON(in_interrupt());
915 if (console_suspended) {
916 down(&secondary_console_sem);
917 return;
918 }
919 down(&console_sem); 916 down(&console_sem);
917 if (console_suspended)
918 return;
920 console_locked = 1; 919 console_locked = 1;
921 console_may_schedule = 1; 920 console_may_schedule = 1;
922} 921}
@@ -926,6 +925,10 @@ int try_acquire_console_sem(void)
926{ 925{
927 if (down_trylock(&console_sem)) 926 if (down_trylock(&console_sem))
928 return -1; 927 return -1;
928 if (console_suspended) {
929 up(&console_sem);
930 return -1;
931 }
929 console_locked = 1; 932 console_locked = 1;
930 console_may_schedule = 0; 933 console_may_schedule = 0;
931 return 0; 934 return 0;
@@ -979,7 +982,7 @@ void release_console_sem(void)
979 unsigned wake_klogd = 0; 982 unsigned wake_klogd = 0;
980 983
981 if (console_suspended) { 984 if (console_suspended) {
982 up(&secondary_console_sem); 985 up(&console_sem);
983 return; 986 return;
984 } 987 }
985 988
diff --git a/kernel/profile.c b/kernel/profile.c
index 784933acf5b8..7724e0409bae 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -114,12 +114,15 @@ int __ref profile_init(void)
114 if (!slab_is_available()) { 114 if (!slab_is_available()) {
115 prof_buffer = alloc_bootmem(buffer_bytes); 115 prof_buffer = alloc_bootmem(buffer_bytes);
116 alloc_bootmem_cpumask_var(&prof_cpu_mask); 116 alloc_bootmem_cpumask_var(&prof_cpu_mask);
117 cpumask_copy(prof_cpu_mask, cpu_possible_mask);
117 return 0; 118 return 0;
118 } 119 }
119 120
120 if (!alloc_cpumask_var(&prof_cpu_mask, GFP_KERNEL)) 121 if (!alloc_cpumask_var(&prof_cpu_mask, GFP_KERNEL))
121 return -ENOMEM; 122 return -ENOMEM;
122 123
124 cpumask_copy(prof_cpu_mask, cpu_possible_mask);
125
123 prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL); 126 prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL);
124 if (prof_buffer) 127 if (prof_buffer)
125 return 0; 128 return 0;
diff --git a/kernel/sched.c b/kernel/sched.c
index 242d0d47a70d..410eec404133 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2266,16 +2266,6 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
2266 if (!sched_feat(SYNC_WAKEUPS)) 2266 if (!sched_feat(SYNC_WAKEUPS))
2267 sync = 0; 2267 sync = 0;
2268 2268
2269 if (!sync) {
2270 if (current->se.avg_overlap < sysctl_sched_migration_cost &&
2271 p->se.avg_overlap < sysctl_sched_migration_cost)
2272 sync = 1;
2273 } else {
2274 if (current->se.avg_overlap >= sysctl_sched_migration_cost ||
2275 p->se.avg_overlap >= sysctl_sched_migration_cost)
2276 sync = 0;
2277 }
2278
2279#ifdef CONFIG_SMP 2269#ifdef CONFIG_SMP
2280 if (sched_feat(LB_WAKEUP_UPDATE)) { 2270 if (sched_feat(LB_WAKEUP_UPDATE)) {
2281 struct sched_domain *sd; 2271 struct sched_domain *sd;
@@ -3890,19 +3880,24 @@ int select_nohz_load_balancer(int stop_tick)
3890 int cpu = smp_processor_id(); 3880 int cpu = smp_processor_id();
3891 3881
3892 if (stop_tick) { 3882 if (stop_tick) {
3893 cpumask_set_cpu(cpu, nohz.cpu_mask);
3894 cpu_rq(cpu)->in_nohz_recently = 1; 3883 cpu_rq(cpu)->in_nohz_recently = 1;
3895 3884
3896 /* 3885 if (!cpu_active(cpu)) {
3897 * If we are going offline and still the leader, give up! 3886 if (atomic_read(&nohz.load_balancer) != cpu)
3898 */ 3887 return 0;
3899 if (!cpu_active(cpu) && 3888
3900 atomic_read(&nohz.load_balancer) == cpu) { 3889 /*
3890 * If we are going offline and still the leader,
3891 * give up!
3892 */
3901 if (atomic_cmpxchg(&nohz.load_balancer, cpu, -1) != cpu) 3893 if (atomic_cmpxchg(&nohz.load_balancer, cpu, -1) != cpu)
3902 BUG(); 3894 BUG();
3895
3903 return 0; 3896 return 0;
3904 } 3897 }
3905 3898
3899 cpumask_set_cpu(cpu, nohz.cpu_mask);
3900
3906 /* time for ilb owner also to sleep */ 3901 /* time for ilb owner also to sleep */
3907 if (cpumask_weight(nohz.cpu_mask) == num_online_cpus()) { 3902 if (cpumask_weight(nohz.cpu_mask) == num_online_cpus()) {
3908 if (atomic_read(&nohz.load_balancer) == cpu) 3903 if (atomic_read(&nohz.load_balancer) == cpu)
@@ -4697,8 +4692,8 @@ EXPORT_SYMBOL(default_wake_function);
4697 * started to run but is not in state TASK_RUNNING. try_to_wake_up() returns 4692 * started to run but is not in state TASK_RUNNING. try_to_wake_up() returns
4698 * zero in this (rare) case, and we handle it by continuing to scan the queue. 4693 * zero in this (rare) case, and we handle it by continuing to scan the queue.
4699 */ 4694 */
4700static void __wake_up_common(wait_queue_head_t *q, unsigned int mode, 4695void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
4701 int nr_exclusive, int sync, void *key) 4696 int nr_exclusive, int sync, void *key)
4702{ 4697{
4703 wait_queue_t *curr, *next; 4698 wait_queue_t *curr, *next;
4704 4699
@@ -6949,20 +6944,26 @@ static void free_rootdomain(struct root_domain *rd)
6949 6944
6950static void rq_attach_root(struct rq *rq, struct root_domain *rd) 6945static void rq_attach_root(struct rq *rq, struct root_domain *rd)
6951{ 6946{
6947 struct root_domain *old_rd = NULL;
6952 unsigned long flags; 6948 unsigned long flags;
6953 6949
6954 spin_lock_irqsave(&rq->lock, flags); 6950 spin_lock_irqsave(&rq->lock, flags);
6955 6951
6956 if (rq->rd) { 6952 if (rq->rd) {
6957 struct root_domain *old_rd = rq->rd; 6953 old_rd = rq->rd;
6958 6954
6959 if (cpumask_test_cpu(rq->cpu, old_rd->online)) 6955 if (cpumask_test_cpu(rq->cpu, old_rd->online))
6960 set_rq_offline(rq); 6956 set_rq_offline(rq);
6961 6957
6962 cpumask_clear_cpu(rq->cpu, old_rd->span); 6958 cpumask_clear_cpu(rq->cpu, old_rd->span);
6963 6959
6964 if (atomic_dec_and_test(&old_rd->refcount)) 6960 /*
6965 free_rootdomain(old_rd); 6961 * If we dont want to free the old_rt yet then
6962 * set old_rd to NULL to skip the freeing later
6963 * in this function:
6964 */
6965 if (!atomic_dec_and_test(&old_rd->refcount))
6966 old_rd = NULL;
6966 } 6967 }
6967 6968
6968 atomic_inc(&rd->refcount); 6969 atomic_inc(&rd->refcount);
@@ -6973,6 +6974,9 @@ static void rq_attach_root(struct rq *rq, struct root_domain *rd)
6973 set_rq_online(rq); 6974 set_rq_online(rq);
6974 6975
6975 spin_unlock_irqrestore(&rq->lock, flags); 6976 spin_unlock_irqrestore(&rq->lock, flags);
6977
6978 if (old_rd)
6979 free_rootdomain(old_rd);
6976} 6980}
6977 6981
6978static int __init_refok init_rootdomain(struct root_domain *rd, bool bootmem) 6982static int __init_refok init_rootdomain(struct root_domain *rd, bool bootmem)
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index a7e50ba185ac..0566f2a03c42 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1191,15 +1191,20 @@ wake_affine(struct sched_domain *this_sd, struct rq *this_rq,
1191 int idx, unsigned long load, unsigned long this_load, 1191 int idx, unsigned long load, unsigned long this_load,
1192 unsigned int imbalance) 1192 unsigned int imbalance)
1193{ 1193{
1194 struct task_struct *curr = this_rq->curr;
1195 struct task_group *tg;
1194 unsigned long tl = this_load; 1196 unsigned long tl = this_load;
1195 unsigned long tl_per_task; 1197 unsigned long tl_per_task;
1196 struct task_group *tg;
1197 unsigned long weight; 1198 unsigned long weight;
1198 int balanced; 1199 int balanced;
1199 1200
1200 if (!(this_sd->flags & SD_WAKE_AFFINE) || !sched_feat(AFFINE_WAKEUPS)) 1201 if (!(this_sd->flags & SD_WAKE_AFFINE) || !sched_feat(AFFINE_WAKEUPS))
1201 return 0; 1202 return 0;
1202 1203
1204 if (sync && (curr->se.avg_overlap > sysctl_sched_migration_cost ||
1205 p->se.avg_overlap > sysctl_sched_migration_cost))
1206 sync = 0;
1207
1203 /* 1208 /*
1204 * If sync wakeup then subtract the (maximum possible) 1209 * If sync wakeup then subtract the (maximum possible)
1205 * effect of the currently running task from the load 1210 * effect of the currently running task from the load
@@ -1426,7 +1431,9 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int sync)
1426 if (!sched_feat(WAKEUP_PREEMPT)) 1431 if (!sched_feat(WAKEUP_PREEMPT))
1427 return; 1432 return;
1428 1433
1429 if (sched_feat(WAKEUP_OVERLAP) && sync) { 1434 if (sched_feat(WAKEUP_OVERLAP) && (sync ||
1435 (se->avg_overlap < sysctl_sched_migration_cost &&
1436 pse->avg_overlap < sysctl_sched_migration_cost))) {
1430 resched_task(curr); 1437 resched_task(curr);
1431 return; 1438 return;
1432 } 1439 }
diff --git a/kernel/sched_stats.h b/kernel/sched_stats.h
index 8ab0cef8ecab..a8f93dd374e1 100644
--- a/kernel/sched_stats.h
+++ b/kernel/sched_stats.h
@@ -296,19 +296,21 @@ sched_info_switch(struct task_struct *prev, struct task_struct *next)
296static inline void account_group_user_time(struct task_struct *tsk, 296static inline void account_group_user_time(struct task_struct *tsk,
297 cputime_t cputime) 297 cputime_t cputime)
298{ 298{
299 struct task_cputime *times; 299 struct thread_group_cputimer *cputimer;
300 struct signal_struct *sig;
301 300
302 /* tsk == current, ensure it is safe to use ->signal */ 301 /* tsk == current, ensure it is safe to use ->signal */
303 if (unlikely(tsk->exit_state)) 302 if (unlikely(tsk->exit_state))
304 return; 303 return;
305 304
306 sig = tsk->signal; 305 cputimer = &tsk->signal->cputimer;
307 times = &sig->cputime.totals;
308 306
309 spin_lock(&times->lock); 307 if (!cputimer->running)
310 times->utime = cputime_add(times->utime, cputime); 308 return;
311 spin_unlock(&times->lock); 309
310 spin_lock(&cputimer->lock);
311 cputimer->cputime.utime =
312 cputime_add(cputimer->cputime.utime, cputime);
313 spin_unlock(&cputimer->lock);
312} 314}
313 315
314/** 316/**
@@ -324,19 +326,21 @@ static inline void account_group_user_time(struct task_struct *tsk,
324static inline void account_group_system_time(struct task_struct *tsk, 326static inline void account_group_system_time(struct task_struct *tsk,
325 cputime_t cputime) 327 cputime_t cputime)
326{ 328{
327 struct task_cputime *times; 329 struct thread_group_cputimer *cputimer;
328 struct signal_struct *sig;
329 330
330 /* tsk == current, ensure it is safe to use ->signal */ 331 /* tsk == current, ensure it is safe to use ->signal */
331 if (unlikely(tsk->exit_state)) 332 if (unlikely(tsk->exit_state))
332 return; 333 return;
333 334
334 sig = tsk->signal; 335 cputimer = &tsk->signal->cputimer;
335 times = &sig->cputime.totals; 336
337 if (!cputimer->running)
338 return;
336 339
337 spin_lock(&times->lock); 340 spin_lock(&cputimer->lock);
338 times->stime = cputime_add(times->stime, cputime); 341 cputimer->cputime.stime =
339 spin_unlock(&times->lock); 342 cputime_add(cputimer->cputime.stime, cputime);
343 spin_unlock(&cputimer->lock);
340} 344}
341 345
342/** 346/**
@@ -352,7 +356,7 @@ static inline void account_group_system_time(struct task_struct *tsk,
352static inline void account_group_exec_runtime(struct task_struct *tsk, 356static inline void account_group_exec_runtime(struct task_struct *tsk,
353 unsigned long long ns) 357 unsigned long long ns)
354{ 358{
355 struct task_cputime *times; 359 struct thread_group_cputimer *cputimer;
356 struct signal_struct *sig; 360 struct signal_struct *sig;
357 361
358 sig = tsk->signal; 362 sig = tsk->signal;
@@ -361,9 +365,12 @@ static inline void account_group_exec_runtime(struct task_struct *tsk,
361 if (unlikely(!sig)) 365 if (unlikely(!sig))
362 return; 366 return;
363 367
364 times = &sig->cputime.totals; 368 cputimer = &sig->cputimer;
369
370 if (!cputimer->running)
371 return;
365 372
366 spin_lock(&times->lock); 373 spin_lock(&cputimer->lock);
367 times->sum_exec_runtime += ns; 374 cputimer->cputime.sum_exec_runtime += ns;
368 spin_unlock(&times->lock); 375 spin_unlock(&cputimer->lock);
369} 376}
diff --git a/kernel/signal.c b/kernel/signal.c
index b6b36768b758..2a74fe87c0dd 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1367,7 +1367,6 @@ int do_notify_parent(struct task_struct *tsk, int sig)
1367 struct siginfo info; 1367 struct siginfo info;
1368 unsigned long flags; 1368 unsigned long flags;
1369 struct sighand_struct *psig; 1369 struct sighand_struct *psig;
1370 struct task_cputime cputime;
1371 int ret = sig; 1370 int ret = sig;
1372 1371
1373 BUG_ON(sig == -1); 1372 BUG_ON(sig == -1);
@@ -1397,9 +1396,10 @@ int do_notify_parent(struct task_struct *tsk, int sig)
1397 info.si_uid = __task_cred(tsk)->uid; 1396 info.si_uid = __task_cred(tsk)->uid;
1398 rcu_read_unlock(); 1397 rcu_read_unlock();
1399 1398
1400 thread_group_cputime(tsk, &cputime); 1399 info.si_utime = cputime_to_clock_t(cputime_add(tsk->utime,
1401 info.si_utime = cputime_to_jiffies(cputime.utime); 1400 tsk->signal->utime));
1402 info.si_stime = cputime_to_jiffies(cputime.stime); 1401 info.si_stime = cputime_to_clock_t(cputime_add(tsk->stime,
1402 tsk->signal->stime));
1403 1403
1404 info.si_status = tsk->exit_code & 0x7f; 1404 info.si_status = tsk->exit_code & 0x7f;
1405 if (tsk->exit_code & 0x80) 1405 if (tsk->exit_code & 0x80)
diff --git a/kernel/sys.c b/kernel/sys.c
index e7dc0e10a485..f145c415bc16 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1525,22 +1525,14 @@ SYSCALL_DEFINE2(setrlimit, unsigned int, resource, struct rlimit __user *, rlim)
1525 return -EINVAL; 1525 return -EINVAL;
1526 if (copy_from_user(&new_rlim, rlim, sizeof(*rlim))) 1526 if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
1527 return -EFAULT; 1527 return -EFAULT;
1528 if (new_rlim.rlim_cur > new_rlim.rlim_max)
1529 return -EINVAL;
1528 old_rlim = current->signal->rlim + resource; 1530 old_rlim = current->signal->rlim + resource;
1529 if ((new_rlim.rlim_max > old_rlim->rlim_max) && 1531 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
1530 !capable(CAP_SYS_RESOURCE)) 1532 !capable(CAP_SYS_RESOURCE))
1531 return -EPERM; 1533 return -EPERM;
1532 1534 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
1533 if (resource == RLIMIT_NOFILE) { 1535 return -EPERM;
1534 if (new_rlim.rlim_max == RLIM_INFINITY)
1535 new_rlim.rlim_max = sysctl_nr_open;
1536 if (new_rlim.rlim_cur == RLIM_INFINITY)
1537 new_rlim.rlim_cur = sysctl_nr_open;
1538 if (new_rlim.rlim_max > sysctl_nr_open)
1539 return -EPERM;
1540 }
1541
1542 if (new_rlim.rlim_cur > new_rlim.rlim_max)
1543 return -EINVAL;
1544 1536
1545 retval = security_task_setrlimit(resource, &new_rlim); 1537 retval = security_task_setrlimit(resource, &new_rlim);
1546 if (retval) 1538 if (retval)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 790f9d785663..c5ef44ff850f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -101,6 +101,7 @@ static int two = 2;
101 101
102static int zero; 102static int zero;
103static int one = 1; 103static int one = 1;
104static unsigned long one_ul = 1;
104static int one_hundred = 100; 105static int one_hundred = 100;
105 106
106/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 107/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
@@ -974,7 +975,7 @@ static struct ctl_table vm_table[] = {
974 .mode = 0644, 975 .mode = 0644,
975 .proc_handler = &dirty_background_bytes_handler, 976 .proc_handler = &dirty_background_bytes_handler,
976 .strategy = &sysctl_intvec, 977 .strategy = &sysctl_intvec,
977 .extra1 = &one, 978 .extra1 = &one_ul,
978 }, 979 },
979 { 980 {
980 .ctl_name = VM_DIRTY_RATIO, 981 .ctl_name = VM_DIRTY_RATIO,
@@ -995,7 +996,7 @@ static struct ctl_table vm_table[] = {
995 .mode = 0644, 996 .mode = 0644,
996 .proc_handler = &dirty_bytes_handler, 997 .proc_handler = &dirty_bytes_handler,
997 .strategy = &sysctl_intvec, 998 .strategy = &sysctl_intvec,
998 .extra1 = &one, 999 .extra1 = &one_ul,
999 }, 1000 },
1000 { 1001 {
1001 .procname = "dirty_writeback_centisecs", 1002 .procname = "dirty_writeback_centisecs",
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index e2a4ff6fc3a6..34e707e5ab87 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -52,6 +52,7 @@ config FUNCTION_TRACER
52 depends on HAVE_FUNCTION_TRACER 52 depends on HAVE_FUNCTION_TRACER
53 depends on DEBUG_KERNEL 53 depends on DEBUG_KERNEL
54 select FRAME_POINTER 54 select FRAME_POINTER
55 select KALLSYMS
55 select TRACING 56 select TRACING
56 select CONTEXT_SWITCH_TRACER 57 select CONTEXT_SWITCH_TRACER
57 help 58 help
@@ -238,6 +239,7 @@ config STACK_TRACER
238 depends on DEBUG_KERNEL 239 depends on DEBUG_KERNEL
239 select FUNCTION_TRACER 240 select FUNCTION_TRACER
240 select STACKTRACE 241 select STACKTRACE
242 select KALLSYMS
241 help 243 help
242 This special tracer records the maximum stack footprint of the 244 This special tracer records the maximum stack footprint of the
243 kernel and displays it in debugfs/tracing/stack_trace. 245 kernel and displays it in debugfs/tracing/stack_trace.
@@ -302,4 +304,27 @@ config FTRACE_STARTUP_TEST
302 functioning properly. It will do tests on all the configured 304 functioning properly. It will do tests on all the configured
303 tracers of ftrace. 305 tracers of ftrace.
304 306
307config MMIOTRACE
308 bool "Memory mapped IO tracing"
309 depends on HAVE_MMIOTRACE_SUPPORT && DEBUG_KERNEL && PCI
310 select TRACING
311 help
312 Mmiotrace traces Memory Mapped I/O access and is meant for
313 debugging and reverse engineering. It is called from the ioremap
314 implementation and works via page faults. Tracing is disabled by
315 default and can be enabled at run-time.
316
317 See Documentation/tracers/mmiotrace.txt.
318 If you are not helping to develop drivers, say N.
319
320config MMIOTRACE_TEST
321 tristate "Test module for mmiotrace"
322 depends on MMIOTRACE && m
323 help
324 This is a dumb module for testing mmiotrace. It is very dangerous
325 as it will write garbage to IO memory starting at a given address.
326 However, it should be safe to use on e.g. unused portion of VRAM.
327
328 Say N, unless you absolutely know what you are doing.
329
305endmenu 330endmenu
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 7dcf6e9f2b04..fdf913dfc7e8 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1737,9 +1737,12 @@ static void clear_ftrace_pid(struct pid *pid)
1737{ 1737{
1738 struct task_struct *p; 1738 struct task_struct *p;
1739 1739
1740 rcu_read_lock();
1740 do_each_pid_task(pid, PIDTYPE_PID, p) { 1741 do_each_pid_task(pid, PIDTYPE_PID, p) {
1741 clear_tsk_trace_trace(p); 1742 clear_tsk_trace_trace(p);
1742 } while_each_pid_task(pid, PIDTYPE_PID, p); 1743 } while_each_pid_task(pid, PIDTYPE_PID, p);
1744 rcu_read_unlock();
1745
1743 put_pid(pid); 1746 put_pid(pid);
1744} 1747}
1745 1748
@@ -1747,9 +1750,11 @@ static void set_ftrace_pid(struct pid *pid)
1747{ 1750{
1748 struct task_struct *p; 1751 struct task_struct *p;
1749 1752
1753 rcu_read_lock();
1750 do_each_pid_task(pid, PIDTYPE_PID, p) { 1754 do_each_pid_task(pid, PIDTYPE_PID, p) {
1751 set_tsk_trace_trace(p); 1755 set_tsk_trace_trace(p);
1752 } while_each_pid_task(pid, PIDTYPE_PID, p); 1756 } while_each_pid_task(pid, PIDTYPE_PID, p);
1757 rcu_read_unlock();
1753} 1758}
1754 1759
1755static void clear_ftrace_pid_task(struct pid **pid) 1760static void clear_ftrace_pid_task(struct pid **pid)
@@ -2028,7 +2033,7 @@ free:
2028static int start_graph_tracing(void) 2033static int start_graph_tracing(void)
2029{ 2034{
2030 struct ftrace_ret_stack **ret_stack_list; 2035 struct ftrace_ret_stack **ret_stack_list;
2031 int ret; 2036 int ret, cpu;
2032 2037
2033 ret_stack_list = kmalloc(FTRACE_RETSTACK_ALLOC_SIZE * 2038 ret_stack_list = kmalloc(FTRACE_RETSTACK_ALLOC_SIZE *
2034 sizeof(struct ftrace_ret_stack *), 2039 sizeof(struct ftrace_ret_stack *),
@@ -2037,6 +2042,10 @@ static int start_graph_tracing(void)
2037 if (!ret_stack_list) 2042 if (!ret_stack_list)
2038 return -ENOMEM; 2043 return -ENOMEM;
2039 2044
2045 /* The cpu_boot init_task->ret_stack will never be freed */
2046 for_each_online_cpu(cpu)
2047 ftrace_graph_init_task(idle_task(cpu));
2048
2040 do { 2049 do {
2041 ret = alloc_retstack_tasklist(ret_stack_list); 2050 ret = alloc_retstack_tasklist(ret_stack_list);
2042 } while (ret == -EAGAIN); 2051 } while (ret == -EAGAIN);
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index fffcb069f1dc..80e503ef6136 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -9,6 +9,7 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/mmiotrace.h> 10#include <linux/mmiotrace.h>
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <asm/atomic.h>
12 13
13#include "trace.h" 14#include "trace.h"
14 15
@@ -19,6 +20,7 @@ struct header_iter {
19static struct trace_array *mmio_trace_array; 20static struct trace_array *mmio_trace_array;
20static bool overrun_detected; 21static bool overrun_detected;
21static unsigned long prev_overruns; 22static unsigned long prev_overruns;
23static atomic_t dropped_count;
22 24
23static void mmio_reset_data(struct trace_array *tr) 25static void mmio_reset_data(struct trace_array *tr)
24{ 26{
@@ -121,11 +123,11 @@ static void mmio_close(struct trace_iterator *iter)
121 123
122static unsigned long count_overruns(struct trace_iterator *iter) 124static unsigned long count_overruns(struct trace_iterator *iter)
123{ 125{
124 unsigned long cnt = 0; 126 unsigned long cnt = atomic_xchg(&dropped_count, 0);
125 unsigned long over = ring_buffer_overruns(iter->tr->buffer); 127 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
126 128
127 if (over > prev_overruns) 129 if (over > prev_overruns)
128 cnt = over - prev_overruns; 130 cnt += over - prev_overruns;
129 prev_overruns = over; 131 prev_overruns = over;
130 return cnt; 132 return cnt;
131} 133}
@@ -310,8 +312,10 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
310 312
311 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 313 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
312 &irq_flags); 314 &irq_flags);
313 if (!event) 315 if (!event) {
316 atomic_inc(&dropped_count);
314 return; 317 return;
318 }
315 entry = ring_buffer_event_data(event); 319 entry = ring_buffer_event_data(event);
316 tracing_generic_entry_update(&entry->ent, 0, preempt_count()); 320 tracing_generic_entry_update(&entry->ent, 0, preempt_count());
317 entry->ent.type = TRACE_MMIO_RW; 321 entry->ent.type = TRACE_MMIO_RW;
@@ -338,8 +342,10 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
338 342
339 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 343 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
340 &irq_flags); 344 &irq_flags);
341 if (!event) 345 if (!event) {
346 atomic_inc(&dropped_count);
342 return; 347 return;
348 }
343 entry = ring_buffer_event_data(event); 349 entry = ring_buffer_event_data(event);
344 tracing_generic_entry_update(&entry->ent, 0, preempt_count()); 350 tracing_generic_entry_update(&entry->ent, 0, preempt_count());
345 entry->ent.type = TRACE_MMIO_MAP; 351 entry->ent.type = TRACE_MMIO_MAP;
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 88c8eb70f54a..bc8e80a86bca 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -23,10 +23,20 @@ static int trace_test_buffer_cpu(struct trace_array *tr, int cpu)
23{ 23{
24 struct ring_buffer_event *event; 24 struct ring_buffer_event *event;
25 struct trace_entry *entry; 25 struct trace_entry *entry;
26 unsigned int loops = 0;
26 27
27 while ((event = ring_buffer_consume(tr->buffer, cpu, NULL))) { 28 while ((event = ring_buffer_consume(tr->buffer, cpu, NULL))) {
28 entry = ring_buffer_event_data(event); 29 entry = ring_buffer_event_data(event);
29 30
31 /*
32 * The ring buffer is a size of trace_buf_size, if
33 * we loop more than the size, there's something wrong
34 * with the ring buffer.
35 */
36 if (loops++ > trace_buf_size) {
37 printk(KERN_CONT ".. bad ring buffer ");
38 goto failed;
39 }
30 if (!trace_valid_entry(entry)) { 40 if (!trace_valid_entry(entry)) {
31 printk(KERN_CONT ".. invalid entry %d ", 41 printk(KERN_CONT ".. invalid entry %d ",
32 entry->type); 42 entry->type);
@@ -57,11 +67,20 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
57 67
58 cnt = ring_buffer_entries(tr->buffer); 68 cnt = ring_buffer_entries(tr->buffer);
59 69
70 /*
71 * The trace_test_buffer_cpu runs a while loop to consume all data.
72 * If the calling tracer is broken, and is constantly filling
73 * the buffer, this will run forever, and hard lock the box.
74 * We disable the ring buffer while we do this test to prevent
75 * a hard lock up.
76 */
77 tracing_off();
60 for_each_possible_cpu(cpu) { 78 for_each_possible_cpu(cpu) {
61 ret = trace_test_buffer_cpu(tr, cpu); 79 ret = trace_test_buffer_cpu(tr, cpu);
62 if (ret) 80 if (ret)
63 break; 81 break;
64 } 82 }
83 tracing_on();
65 __raw_spin_unlock(&ftrace_max_lock); 84 __raw_spin_unlock(&ftrace_max_lock);
66 local_irq_restore(flags); 85 local_irq_restore(flags);
67 86
diff --git a/kernel/user.c b/kernel/user.c
index 477b6660f447..3551ac742395 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -72,6 +72,7 @@ static void uid_hash_insert(struct user_struct *up, struct hlist_head *hashent)
72static void uid_hash_remove(struct user_struct *up) 72static void uid_hash_remove(struct user_struct *up)
73{ 73{
74 hlist_del_init(&up->uidhash_node); 74 hlist_del_init(&up->uidhash_node);
75 put_user_ns(up->user_ns);
75} 76}
76 77
77static struct user_struct *uid_hash_find(uid_t uid, struct hlist_head *hashent) 78static struct user_struct *uid_hash_find(uid_t uid, struct hlist_head *hashent)
@@ -334,7 +335,6 @@ static void free_user(struct user_struct *up, unsigned long flags)
334 atomic_inc(&up->__count); 335 atomic_inc(&up->__count);
335 spin_unlock_irqrestore(&uidhash_lock, flags); 336 spin_unlock_irqrestore(&uidhash_lock, flags);
336 337
337 put_user_ns(up->user_ns);
338 INIT_WORK(&up->work, remove_user_sysfs_dir); 338 INIT_WORK(&up->work, remove_user_sysfs_dir);
339 schedule_work(&up->work); 339 schedule_work(&up->work);
340} 340}
@@ -357,7 +357,6 @@ static void free_user(struct user_struct *up, unsigned long flags)
357 sched_destroy_user(up); 357 sched_destroy_user(up);
358 key_put(up->uid_keyring); 358 key_put(up->uid_keyring);
359 key_put(up->session_keyring); 359 key_put(up->session_keyring);
360 put_user_ns(up->user_ns);
361 kmem_cache_free(uid_cachep, up); 360 kmem_cache_free(uid_cachep, up);
362} 361}
363 362
diff --git a/kernel/wait.c b/kernel/wait.c
index cd87131f2fc2..42a2dbc181c8 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -91,6 +91,15 @@ prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state)
91} 91}
92EXPORT_SYMBOL(prepare_to_wait_exclusive); 92EXPORT_SYMBOL(prepare_to_wait_exclusive);
93 93
94/*
95 * finish_wait - clean up after waiting in a queue
96 * @q: waitqueue waited on
97 * @wait: wait descriptor
98 *
99 * Sets current thread back to running state and removes
100 * the wait descriptor from the given waitqueue if still
101 * queued.
102 */
94void finish_wait(wait_queue_head_t *q, wait_queue_t *wait) 103void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
95{ 104{
96 unsigned long flags; 105 unsigned long flags;
@@ -117,6 +126,39 @@ void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
117} 126}
118EXPORT_SYMBOL(finish_wait); 127EXPORT_SYMBOL(finish_wait);
119 128
129/*
130 * abort_exclusive_wait - abort exclusive waiting in a queue
131 * @q: waitqueue waited on
132 * @wait: wait descriptor
133 * @state: runstate of the waiter to be woken
134 * @key: key to identify a wait bit queue or %NULL
135 *
136 * Sets current thread back to running state and removes
137 * the wait descriptor from the given waitqueue if still
138 * queued.
139 *
140 * Wakes up the next waiter if the caller is concurrently
141 * woken up through the queue.
142 *
143 * This prevents waiter starvation where an exclusive waiter
144 * aborts and is woken up concurrently and noone wakes up
145 * the next waiter.
146 */
147void abort_exclusive_wait(wait_queue_head_t *q, wait_queue_t *wait,
148 unsigned int mode, void *key)
149{
150 unsigned long flags;
151
152 __set_current_state(TASK_RUNNING);
153 spin_lock_irqsave(&q->lock, flags);
154 if (!list_empty(&wait->task_list))
155 list_del_init(&wait->task_list);
156 else if (waitqueue_active(q))
157 __wake_up_common(q, mode, 1, 0, key);
158 spin_unlock_irqrestore(&q->lock, flags);
159}
160EXPORT_SYMBOL(abort_exclusive_wait);
161
120int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key) 162int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key)
121{ 163{
122 int ret = default_wake_function(wait, mode, sync, key); 164 int ret = default_wake_function(wait, mode, sync, key);
@@ -177,17 +219,20 @@ int __sched
177__wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q, 219__wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q,
178 int (*action)(void *), unsigned mode) 220 int (*action)(void *), unsigned mode)
179{ 221{
180 int ret = 0;
181
182 do { 222 do {
223 int ret;
224
183 prepare_to_wait_exclusive(wq, &q->wait, mode); 225 prepare_to_wait_exclusive(wq, &q->wait, mode);
184 if (test_bit(q->key.bit_nr, q->key.flags)) { 226 if (!test_bit(q->key.bit_nr, q->key.flags))
185 if ((ret = (*action)(q->key.flags))) 227 continue;
186 break; 228 ret = action(q->key.flags);
187 } 229 if (!ret)
230 continue;
231 abort_exclusive_wait(wq, &q->wait, mode, &q->key);
232 return ret;
188 } while (test_and_set_bit(q->key.bit_nr, q->key.flags)); 233 } while (test_and_set_bit(q->key.bit_nr, q->key.flags));
189 finish_wait(wq, &q->wait); 234 finish_wait(wq, &q->wait);
190 return ret; 235 return 0;
191} 236}
192EXPORT_SYMBOL(__wait_on_bit_lock); 237EXPORT_SYMBOL(__wait_on_bit_lock);
193 238
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 29044f500269..1bcf9cd4baa0 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -838,7 +838,7 @@ config FIREWIRE_OHCI_REMOTE_DMA
838 838
839 If unsure, say N. 839 If unsure, say N.
840 840
841menuconfig BUILD_DOCSRC 841config BUILD_DOCSRC
842 bool "Build targets in Documentation/ tree" 842 bool "Build targets in Documentation/ tree"
843 depends on HEADERS_CHECK 843 depends on HEADERS_CHECK
844 help 844 help
diff --git a/mm/fremap.c b/mm/fremap.c
index 736ba7f3306a..b6ec85abbb39 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -198,7 +198,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
198 flags &= MAP_NONBLOCK; 198 flags &= MAP_NONBLOCK;
199 get_file(file); 199 get_file(file);
200 addr = mmap_region(file, start, size, 200 addr = mmap_region(file, start, size,
201 flags, vma->vm_flags, pgoff, 1); 201 flags, vma->vm_flags, pgoff);
202 fput(file); 202 fput(file);
203 if (IS_ERR_VALUE(addr)) { 203 if (IS_ERR_VALUE(addr)) {
204 err = addr; 204 err = addr;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 618e98304080..107da3d809a8 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2269,12 +2269,18 @@ void hugetlb_change_protection(struct vm_area_struct *vma,
2269 2269
2270int hugetlb_reserve_pages(struct inode *inode, 2270int hugetlb_reserve_pages(struct inode *inode,
2271 long from, long to, 2271 long from, long to,
2272 struct vm_area_struct *vma) 2272 struct vm_area_struct *vma,
2273 int acctflag)
2273{ 2274{
2274 long ret, chg; 2275 long ret, chg;
2275 struct hstate *h = hstate_inode(inode); 2276 struct hstate *h = hstate_inode(inode);
2276 2277
2277 if (vma && vma->vm_flags & VM_NORESERVE) 2278 /*
2279 * Only apply hugepage reservation if asked. At fault time, an
2280 * attempt will be made for VM_NORESERVE to allocate a page
2281 * and filesystem quota without using reserves
2282 */
2283 if (acctflag & VM_NORESERVE)
2278 return 0; 2284 return 0;
2279 2285
2280 /* 2286 /*
@@ -2299,13 +2305,31 @@ int hugetlb_reserve_pages(struct inode *inode,
2299 if (chg < 0) 2305 if (chg < 0)
2300 return chg; 2306 return chg;
2301 2307
2308 /* There must be enough filesystem quota for the mapping */
2302 if (hugetlb_get_quota(inode->i_mapping, chg)) 2309 if (hugetlb_get_quota(inode->i_mapping, chg))
2303 return -ENOSPC; 2310 return -ENOSPC;
2311
2312 /*
2313 * Check enough hugepages are available for the reservation.
2314 * Hand back the quota if there are not
2315 */
2304 ret = hugetlb_acct_memory(h, chg); 2316 ret = hugetlb_acct_memory(h, chg);
2305 if (ret < 0) { 2317 if (ret < 0) {
2306 hugetlb_put_quota(inode->i_mapping, chg); 2318 hugetlb_put_quota(inode->i_mapping, chg);
2307 return ret; 2319 return ret;
2308 } 2320 }
2321
2322 /*
2323 * Account for the reservations made. Shared mappings record regions
2324 * that have reservations as they are shared by multiple VMAs.
2325 * When the last VMA disappears, the region map says how much
2326 * the reservation was and the page cache tells how much of
2327 * the reservation was consumed. Private mappings are per-VMA and
2328 * only the consumed reservations are tracked. When the VMA
2329 * disappears, the original reservation is the VMA size and the
2330 * consumed reservations are stored in the map. Hence, nothing
2331 * else has to be done for private mappings here
2332 */
2309 if (!vma || vma->vm_flags & VM_SHARED) 2333 if (!vma || vma->vm_flags & VM_SHARED)
2310 region_add(&inode->i_mapping->private_list, from, to); 2334 region_add(&inode->i_mapping->private_list, from, to);
2311 return 0; 2335 return 0;
diff --git a/mm/memory.c b/mm/memory.c
index 22bfa7a47a0b..baa999e87cd2 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1999,7 +1999,7 @@ gotten:
1999 * Don't let another task, with possibly unlocked vma, 1999 * Don't let another task, with possibly unlocked vma,
2000 * keep the mlocked page. 2000 * keep the mlocked page.
2001 */ 2001 */
2002 if (vma->vm_flags & VM_LOCKED) { 2002 if ((vma->vm_flags & VM_LOCKED) && old_page) {
2003 lock_page(old_page); /* for LRU manipulation */ 2003 lock_page(old_page); /* for LRU manipulation */
2004 clear_page_mlock(old_page); 2004 clear_page_mlock(old_page);
2005 unlock_page(old_page); 2005 unlock_page(old_page);
diff --git a/mm/migrate.c b/mm/migrate.c
index 2bb4e1d63520..a9eff3f092f6 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1129,7 +1129,7 @@ int migrate_vmas(struct mm_struct *mm, const nodemask_t *to,
1129 struct vm_area_struct *vma; 1129 struct vm_area_struct *vma;
1130 int err = 0; 1130 int err = 0;
1131 1131
1132 for(vma = mm->mmap; vma->vm_next && !err; vma = vma->vm_next) { 1132 for (vma = mm->mmap; vma && !err; vma = vma->vm_next) {
1133 if (vma->vm_ops && vma->vm_ops->migrate) { 1133 if (vma->vm_ops && vma->vm_ops->migrate) {
1134 err = vma->vm_ops->migrate(vma, to, from, flags); 1134 err = vma->vm_ops->migrate(vma, to, from, flags);
1135 if (err) 1135 if (err)
diff --git a/mm/mlock.c b/mm/mlock.c
index 028ec482fdd4..cbe9e0581b75 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -311,7 +311,10 @@ long mlock_vma_pages_range(struct vm_area_struct *vma,
311 is_vm_hugetlb_page(vma) || 311 is_vm_hugetlb_page(vma) ||
312 vma == get_gate_vma(current))) { 312 vma == get_gate_vma(current))) {
313 313
314 return __mlock_vma_pages_range(vma, start, end, 1); 314 __mlock_vma_pages_range(vma, start, end, 1);
315
316 /* Hide errors from mmap() and other callers */
317 return 0;
315 } 318 }
316 319
317 /* 320 /*
@@ -657,7 +660,7 @@ void *alloc_locked_buffer(size_t size)
657 return buffer; 660 return buffer;
658} 661}
659 662
660void free_locked_buffer(void *buffer, size_t size) 663void release_locked_buffer(void *buffer, size_t size)
661{ 664{
662 unsigned long pgsz = PAGE_ALIGN(size) >> PAGE_SHIFT; 665 unsigned long pgsz = PAGE_ALIGN(size) >> PAGE_SHIFT;
663 666
@@ -667,6 +670,11 @@ void free_locked_buffer(void *buffer, size_t size)
667 current->mm->locked_vm -= pgsz; 670 current->mm->locked_vm -= pgsz;
668 671
669 up_write(&current->mm->mmap_sem); 672 up_write(&current->mm->mmap_sem);
673}
674
675void free_locked_buffer(void *buffer, size_t size)
676{
677 release_locked_buffer(buffer, size);
670 678
671 kfree(buffer); 679 kfree(buffer);
672} 680}
diff --git a/mm/mmap.c b/mm/mmap.c
index 214b6a258eeb..00ced3ee49a8 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -918,7 +918,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
918 struct inode *inode; 918 struct inode *inode;
919 unsigned int vm_flags; 919 unsigned int vm_flags;
920 int error; 920 int error;
921 int accountable = 1;
922 unsigned long reqprot = prot; 921 unsigned long reqprot = prot;
923 922
924 /* 923 /*
@@ -1019,8 +1018,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1019 return -EPERM; 1018 return -EPERM;
1020 vm_flags &= ~VM_MAYEXEC; 1019 vm_flags &= ~VM_MAYEXEC;
1021 } 1020 }
1022 if (is_file_hugepages(file))
1023 accountable = 0;
1024 1021
1025 if (!file->f_op || !file->f_op->mmap) 1022 if (!file->f_op || !file->f_op->mmap)
1026 return -ENODEV; 1023 return -ENODEV;
@@ -1053,8 +1050,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1053 if (error) 1050 if (error)
1054 return error; 1051 return error;
1055 1052
1056 return mmap_region(file, addr, len, flags, vm_flags, pgoff, 1053 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
1057 accountable);
1058} 1054}
1059EXPORT_SYMBOL(do_mmap_pgoff); 1055EXPORT_SYMBOL(do_mmap_pgoff);
1060 1056
@@ -1092,17 +1088,23 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
1092 1088
1093/* 1089/*
1094 * We account for memory if it's a private writeable mapping, 1090 * We account for memory if it's a private writeable mapping,
1095 * and VM_NORESERVE wasn't set. 1091 * not hugepages and VM_NORESERVE wasn't set.
1096 */ 1092 */
1097static inline int accountable_mapping(unsigned int vm_flags) 1093static inline int accountable_mapping(struct file *file, unsigned int vm_flags)
1098{ 1094{
1095 /*
1096 * hugetlb has its own accounting separate from the core VM
1097 * VM_HUGETLB may not be set yet so we cannot check for that flag.
1098 */
1099 if (file && is_file_hugepages(file))
1100 return 0;
1101
1099 return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE; 1102 return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE;
1100} 1103}
1101 1104
1102unsigned long mmap_region(struct file *file, unsigned long addr, 1105unsigned long mmap_region(struct file *file, unsigned long addr,
1103 unsigned long len, unsigned long flags, 1106 unsigned long len, unsigned long flags,
1104 unsigned int vm_flags, unsigned long pgoff, 1107 unsigned int vm_flags, unsigned long pgoff)
1105 int accountable)
1106{ 1108{
1107 struct mm_struct *mm = current->mm; 1109 struct mm_struct *mm = current->mm;
1108 struct vm_area_struct *vma, *prev; 1110 struct vm_area_struct *vma, *prev;
@@ -1128,18 +1130,22 @@ munmap_back:
1128 1130
1129 /* 1131 /*
1130 * Set 'VM_NORESERVE' if we should not account for the 1132 * Set 'VM_NORESERVE' if we should not account for the
1131 * memory use of this mapping. We only honor MAP_NORESERVE 1133 * memory use of this mapping.
1132 * if we're allowed to overcommit memory.
1133 */ 1134 */
1134 if ((flags & MAP_NORESERVE) && sysctl_overcommit_memory != OVERCOMMIT_NEVER) 1135 if ((flags & MAP_NORESERVE)) {
1135 vm_flags |= VM_NORESERVE; 1136 /* We honor MAP_NORESERVE if allowed to overcommit */
1136 if (!accountable) 1137 if (sysctl_overcommit_memory != OVERCOMMIT_NEVER)
1137 vm_flags |= VM_NORESERVE; 1138 vm_flags |= VM_NORESERVE;
1139
1140 /* hugetlb applies strict overcommit unless MAP_NORESERVE */
1141 if (file && is_file_hugepages(file))
1142 vm_flags |= VM_NORESERVE;
1143 }
1138 1144
1139 /* 1145 /*
1140 * Private writable mapping: check memory availability 1146 * Private writable mapping: check memory availability
1141 */ 1147 */
1142 if (accountable_mapping(vm_flags)) { 1148 if (accountable_mapping(file, vm_flags)) {
1143 charged = len >> PAGE_SHIFT; 1149 charged = len >> PAGE_SHIFT;
1144 if (security_vm_enough_memory(charged)) 1150 if (security_vm_enough_memory(charged))
1145 return -ENOMEM; 1151 return -ENOMEM;
@@ -2078,12 +2084,8 @@ void exit_mmap(struct mm_struct *mm)
2078 unsigned long end; 2084 unsigned long end;
2079 2085
2080 /* mm's last user has gone, and its about to be pulled down */ 2086 /* mm's last user has gone, and its about to be pulled down */
2081 arch_exit_mmap(mm);
2082 mmu_notifier_release(mm); 2087 mmu_notifier_release(mm);
2083 2088
2084 if (!mm->mmap) /* Can happen if dup_mmap() received an OOM */
2085 return;
2086
2087 if (mm->locked_vm) { 2089 if (mm->locked_vm) {
2088 vma = mm->mmap; 2090 vma = mm->mmap;
2089 while (vma) { 2091 while (vma) {
@@ -2092,7 +2094,13 @@ void exit_mmap(struct mm_struct *mm)
2092 vma = vma->vm_next; 2094 vma = vma->vm_next;
2093 } 2095 }
2094 } 2096 }
2097
2098 arch_exit_mmap(mm);
2099
2095 vma = mm->mmap; 2100 vma = mm->mmap;
2101 if (!vma) /* Can happen if dup_mmap() received an OOM */
2102 return;
2103
2096 lru_add_drain(); 2104 lru_add_drain();
2097 flush_cache_mm(mm); 2105 flush_cache_mm(mm);
2098 tlb = tlb_gather_mmu(mm, 1); 2106 tlb = tlb_gather_mmu(mm, 1);
diff --git a/mm/mprotect.c b/mm/mprotect.c
index abe2694e13f4..258197b76fb4 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -151,10 +151,11 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
151 /* 151 /*
152 * If we make a private mapping writable we increase our commit; 152 * If we make a private mapping writable we increase our commit;
153 * but (without finer accounting) cannot reduce our commit if we 153 * but (without finer accounting) cannot reduce our commit if we
154 * make it unwritable again. 154 * make it unwritable again. hugetlb mapping were accounted for
155 * even if read-only so there is no need to account for them here
155 */ 156 */
156 if (newflags & VM_WRITE) { 157 if (newflags & VM_WRITE) {
157 if (!(oldflags & (VM_ACCOUNT|VM_WRITE| 158 if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_HUGETLB|
158 VM_SHARED|VM_NORESERVE))) { 159 VM_SHARED|VM_NORESERVE))) {
159 charged = nrpages; 160 charged = nrpages;
160 if (security_vm_enough_memory(charged)) 161 if (security_vm_enough_memory(charged))
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index b493db7841dc..74dc57c74349 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -209,7 +209,7 @@ int dirty_bytes_handler(struct ctl_table *table, int write,
209 struct file *filp, void __user *buffer, size_t *lenp, 209 struct file *filp, void __user *buffer, size_t *lenp,
210 loff_t *ppos) 210 loff_t *ppos)
211{ 211{
212 int old_bytes = vm_dirty_bytes; 212 unsigned long old_bytes = vm_dirty_bytes;
213 int ret; 213 int ret;
214 214
215 ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos); 215 ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos);
@@ -240,7 +240,7 @@ void bdi_writeout_inc(struct backing_dev_info *bdi)
240} 240}
241EXPORT_SYMBOL_GPL(bdi_writeout_inc); 241EXPORT_SYMBOL_GPL(bdi_writeout_inc);
242 242
243static inline void task_dirty_inc(struct task_struct *tsk) 243void task_dirty_inc(struct task_struct *tsk)
244{ 244{
245 prop_inc_single(&vm_dirties, &tsk->dirties); 245 prop_inc_single(&vm_dirties, &tsk->dirties);
246} 246}
@@ -1051,13 +1051,25 @@ continue_unlock:
1051 } 1051 }
1052 } 1052 }
1053 1053
1054 if (wbc->sync_mode == WB_SYNC_NONE) { 1054 if (nr_to_write > 0) {
1055 wbc->nr_to_write--; 1055 nr_to_write--;
1056 if (wbc->nr_to_write <= 0) { 1056 if (nr_to_write == 0 &&
1057 wbc->sync_mode == WB_SYNC_NONE) {
1058 /*
1059 * We stop writing back only if we are
1060 * not doing integrity sync. In case of
1061 * integrity sync we have to keep going
1062 * because someone may be concurrently
1063 * dirtying pages, and we might have
1064 * synced a lot of newly appeared dirty
1065 * pages, but have not synced all of the
1066 * old dirty pages.
1067 */
1057 done = 1; 1068 done = 1;
1058 break; 1069 break;
1059 } 1070 }
1060 } 1071 }
1072
1061 if (wbc->nonblocking && bdi_write_congested(bdi)) { 1073 if (wbc->nonblocking && bdi_write_congested(bdi)) {
1062 wbc->encountered_congestion = 1; 1074 wbc->encountered_congestion = 1;
1063 done = 1; 1075 done = 1;
@@ -1067,7 +1079,7 @@ continue_unlock:
1067 pagevec_release(&pvec); 1079 pagevec_release(&pvec);
1068 cond_resched(); 1080 cond_resched();
1069 } 1081 }
1070 if (!cycled) { 1082 if (!cycled && !done) {
1071 /* 1083 /*
1072 * range_cyclic: 1084 * range_cyclic:
1073 * We hit the last page and there is more work to be done: wrap 1085 * We hit the last page and there is more work to be done: wrap
@@ -1218,6 +1230,7 @@ int __set_page_dirty_nobuffers(struct page *page)
1218 __inc_zone_page_state(page, NR_FILE_DIRTY); 1230 __inc_zone_page_state(page, NR_FILE_DIRTY);
1219 __inc_bdi_stat(mapping->backing_dev_info, 1231 __inc_bdi_stat(mapping->backing_dev_info,
1220 BDI_RECLAIMABLE); 1232 BDI_RECLAIMABLE);
1233 task_dirty_inc(current);
1221 task_io_account_write(PAGE_CACHE_SIZE); 1234 task_io_account_write(PAGE_CACHE_SIZE);
1222 } 1235 }
1223 radix_tree_tag_set(&mapping->page_tree, 1236 radix_tree_tag_set(&mapping->page_tree,
@@ -1250,7 +1263,7 @@ EXPORT_SYMBOL(redirty_page_for_writepage);
1250 * If the mapping doesn't provide a set_page_dirty a_op, then 1263 * If the mapping doesn't provide a set_page_dirty a_op, then
1251 * just fall through and assume that it wants buffer_heads. 1264 * just fall through and assume that it wants buffer_heads.
1252 */ 1265 */
1253static int __set_page_dirty(struct page *page) 1266int set_page_dirty(struct page *page)
1254{ 1267{
1255 struct address_space *mapping = page_mapping(page); 1268 struct address_space *mapping = page_mapping(page);
1256 1269
@@ -1268,14 +1281,6 @@ static int __set_page_dirty(struct page *page)
1268 } 1281 }
1269 return 0; 1282 return 0;
1270} 1283}
1271
1272int set_page_dirty(struct page *page)
1273{
1274 int ret = __set_page_dirty(page);
1275 if (ret)
1276 task_dirty_inc(current);
1277 return ret;
1278}
1279EXPORT_SYMBOL(set_page_dirty); 1284EXPORT_SYMBOL(set_page_dirty);
1280 1285
1281/* 1286/*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5675b3073854..5c44ed49ca93 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2989,7 +2989,7 @@ static int __meminit next_active_region_index_in_nid(int index, int nid)
2989 * was used and there are no special requirements, this is a convenient 2989 * was used and there are no special requirements, this is a convenient
2990 * alternative 2990 * alternative
2991 */ 2991 */
2992int __meminit early_pfn_to_nid(unsigned long pfn) 2992int __meminit __early_pfn_to_nid(unsigned long pfn)
2993{ 2993{
2994 int i; 2994 int i;
2995 2995
@@ -3000,10 +3000,33 @@ int __meminit early_pfn_to_nid(unsigned long pfn)
3000 if (start_pfn <= pfn && pfn < end_pfn) 3000 if (start_pfn <= pfn && pfn < end_pfn)
3001 return early_node_map[i].nid; 3001 return early_node_map[i].nid;
3002 } 3002 }
3003 /* This is a memory hole */
3004 return -1;
3005}
3006#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
3007
3008int __meminit early_pfn_to_nid(unsigned long pfn)
3009{
3010 int nid;
3003 3011
3012 nid = __early_pfn_to_nid(pfn);
3013 if (nid >= 0)
3014 return nid;
3015 /* just returns 0 */
3004 return 0; 3016 return 0;
3005} 3017}
3006#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */ 3018
3019#ifdef CONFIG_NODES_SPAN_OTHER_NODES
3020bool __meminit early_pfn_in_nid(unsigned long pfn, int node)
3021{
3022 int nid;
3023
3024 nid = __early_pfn_to_nid(pfn);
3025 if (nid >= 0 && nid != node)
3026 return false;
3027 return true;
3028}
3029#endif
3007 3030
3008/* Basic iterator support to walk early_node_map[] */ 3031/* Basic iterator support to walk early_node_map[] */
3009#define for_each_active_range_index_in_nid(i, nid) \ 3032#define for_each_active_range_index_in_nid(i, nid) \
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 7006a11350c8..ceecfbb143fa 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -114,7 +114,8 @@ static int __init_refok init_section_page_cgroup(unsigned long pfn)
114 nid = page_to_nid(pfn_to_page(pfn)); 114 nid = page_to_nid(pfn_to_page(pfn));
115 table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION; 115 table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
116 if (slab_is_available()) { 116 if (slab_is_available()) {
117 base = kmalloc_node(table_size, GFP_KERNEL, nid); 117 base = kmalloc_node(table_size,
118 GFP_KERNEL | __GFP_NOWARN, nid);
118 if (!base) 119 if (!base)
119 base = vmalloc_node(table_size, nid); 120 base = vmalloc_node(table_size, nid);
120 } else { 121 } else {
diff --git a/mm/page_io.c b/mm/page_io.c
index dc6ce0afbded..3023c475e041 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -111,7 +111,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
111 goto out; 111 goto out;
112 } 112 }
113 if (wbc->sync_mode == WB_SYNC_ALL) 113 if (wbc->sync_mode == WB_SYNC_ALL)
114 rw |= (1 << BIO_RW_SYNC); 114 rw |= (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
115 count_vm_event(PSWPOUT); 115 count_vm_event(PSWPOUT);
116 set_page_writeback(page); 116 set_page_writeback(page);
117 unlock_page(page); 117 unlock_page(page);
diff --git a/mm/rmap.c b/mm/rmap.c
index ac4af8cffbf9..16521664010d 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1072,7 +1072,8 @@ static int try_to_unmap_file(struct page *page, int unlock, int migration)
1072 spin_lock(&mapping->i_mmap_lock); 1072 spin_lock(&mapping->i_mmap_lock);
1073 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) { 1073 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
1074 if (MLOCK_PAGES && unlikely(unlock)) { 1074 if (MLOCK_PAGES && unlikely(unlock)) {
1075 if (!(vma->vm_flags & VM_LOCKED)) 1075 if (!((vma->vm_flags & VM_LOCKED) &&
1076 page_mapped_in_vma(page, vma)))
1076 continue; /* must visit all vmas */ 1077 continue; /* must visit all vmas */
1077 ret = SWAP_MLOCK; 1078 ret = SWAP_MLOCK;
1078 } else { 1079 } else {
diff --git a/mm/slab.c b/mm/slab.c
index ddc41f337d58..4d00855629c4 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4457,3 +4457,4 @@ size_t ksize(const void *objp)
4457 4457
4458 return obj_size(virt_to_cache(objp)); 4458 return obj_size(virt_to_cache(objp));
4459} 4459}
4460EXPORT_SYMBOL(ksize);
diff --git a/mm/slob.c b/mm/slob.c
index bf7e8fc3aed8..52bc8a2bd9ef 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -521,6 +521,7 @@ size_t ksize(const void *block)
521 } else 521 } else
522 return sp->page.private; 522 return sp->page.private;
523} 523}
524EXPORT_SYMBOL(ksize);
524 525
525struct kmem_cache { 526struct kmem_cache {
526 unsigned int size, align; 527 unsigned int size, align;
diff --git a/mm/slub.c b/mm/slub.c
index bdc9abb08a23..0280eee6cf37 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2736,6 +2736,7 @@ size_t ksize(const void *object)
2736 */ 2736 */
2737 return s->size; 2737 return s->size;
2738} 2738}
2739EXPORT_SYMBOL(ksize);
2739 2740
2740void kfree(const void *x) 2741void kfree(const void *x)
2741{ 2742{
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 7e6304dfafab..312fafe0ab6e 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -635,7 +635,7 @@ int swap_type_of(dev_t device, sector_t offset, struct block_device **bdev_p)
635 635
636 if (!bdev) { 636 if (!bdev) {
637 if (bdev_p) 637 if (bdev_p)
638 *bdev_p = sis->bdev; 638 *bdev_p = bdget(sis->bdev->bd_dev);
639 639
640 spin_unlock(&swap_lock); 640 spin_unlock(&swap_lock);
641 return i; 641 return i;
@@ -647,7 +647,7 @@ int swap_type_of(dev_t device, sector_t offset, struct block_device **bdev_p)
647 struct swap_extent, list); 647 struct swap_extent, list);
648 if (se->start_block == offset) { 648 if (se->start_block == offset) {
649 if (bdev_p) 649 if (bdev_p)
650 *bdev_p = sis->bdev; 650 *bdev_p = bdget(sis->bdev->bd_dev);
651 651
652 spin_unlock(&swap_lock); 652 spin_unlock(&swap_lock);
653 bdput(bdev); 653 bdput(bdev);
diff --git a/mm/util.c b/mm/util.c
index cb00b748ce47..37eaccdf3054 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -129,6 +129,26 @@ void *krealloc(const void *p, size_t new_size, gfp_t flags)
129} 129}
130EXPORT_SYMBOL(krealloc); 130EXPORT_SYMBOL(krealloc);
131 131
132/**
133 * kzfree - like kfree but zero memory
134 * @p: object to free memory of
135 *
136 * The memory of the object @p points to is zeroed before freed.
137 * If @p is %NULL, kzfree() does nothing.
138 */
139void kzfree(const void *p)
140{
141 size_t ks;
142 void *mem = (void *)p;
143
144 if (unlikely(ZERO_OR_NULL_PTR(mem)))
145 return;
146 ks = ksize(mem);
147 memset(mem, 0, ks);
148 kfree(mem);
149}
150EXPORT_SYMBOL(kzfree);
151
132/* 152/*
133 * strndup_user - duplicate an existing string from user space 153 * strndup_user - duplicate an existing string from user space
134 * @s: The string to duplicate 154 * @s: The string to duplicate
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 75f49d312e8c..903cad46e796 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1012,6 +1012,8 @@ void __init vmalloc_init(void)
1012void unmap_kernel_range(unsigned long addr, unsigned long size) 1012void unmap_kernel_range(unsigned long addr, unsigned long size)
1013{ 1013{
1014 unsigned long end = addr + size; 1014 unsigned long end = addr + size;
1015
1016 flush_cache_vunmap(addr, end);
1015 vunmap_page_range(addr, end); 1017 vunmap_page_range(addr, end);
1016 flush_tlb_kernel_range(addr, end); 1018 flush_tlb_kernel_range(addr, end);
1017} 1019}
@@ -1106,6 +1108,14 @@ struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
1106} 1108}
1107EXPORT_SYMBOL_GPL(__get_vm_area); 1109EXPORT_SYMBOL_GPL(__get_vm_area);
1108 1110
1111struct vm_struct *__get_vm_area_caller(unsigned long size, unsigned long flags,
1112 unsigned long start, unsigned long end,
1113 void *caller)
1114{
1115 return __get_vm_area_node(size, flags, start, end, -1, GFP_KERNEL,
1116 caller);
1117}
1118
1109/** 1119/**
1110 * get_vm_area - reserve a contiguous kernel virtual area 1120 * get_vm_area - reserve a contiguous kernel virtual area
1111 * @size: size of the area 1121 * @size: size of the area
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9a27c44aa327..6177e3bcd66b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2057,31 +2057,31 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
2057 int pass, struct scan_control *sc) 2057 int pass, struct scan_control *sc)
2058{ 2058{
2059 struct zone *zone; 2059 struct zone *zone;
2060 unsigned long nr_to_scan, ret = 0; 2060 unsigned long ret = 0;
2061 enum lru_list l;
2062 2061
2063 for_each_zone(zone) { 2062 for_each_zone(zone) {
2063 enum lru_list l;
2064 2064
2065 if (!populated_zone(zone)) 2065 if (!populated_zone(zone))
2066 continue; 2066 continue;
2067
2068 if (zone_is_all_unreclaimable(zone) && prio != DEF_PRIORITY) 2067 if (zone_is_all_unreclaimable(zone) && prio != DEF_PRIORITY)
2069 continue; 2068 continue;
2070 2069
2071 for_each_evictable_lru(l) { 2070 for_each_evictable_lru(l) {
2071 enum zone_stat_item ls = NR_LRU_BASE + l;
2072 unsigned long lru_pages = zone_page_state(zone, ls);
2073
2072 /* For pass = 0, we don't shrink the active list */ 2074 /* For pass = 0, we don't shrink the active list */
2073 if (pass == 0 && 2075 if (pass == 0 && (l == LRU_ACTIVE_ANON ||
2074 (l == LRU_ACTIVE || l == LRU_ACTIVE_FILE)) 2076 l == LRU_ACTIVE_FILE))
2075 continue; 2077 continue;
2076 2078
2077 zone->lru[l].nr_scan += 2079 zone->lru[l].nr_scan += (lru_pages >> prio) + 1;
2078 (zone_page_state(zone, NR_LRU_BASE + l)
2079 >> prio) + 1;
2080 if (zone->lru[l].nr_scan >= nr_pages || pass > 3) { 2080 if (zone->lru[l].nr_scan >= nr_pages || pass > 3) {
2081 unsigned long nr_to_scan;
2082
2081 zone->lru[l].nr_scan = 0; 2083 zone->lru[l].nr_scan = 0;
2082 nr_to_scan = min(nr_pages, 2084 nr_to_scan = min(nr_pages, lru_pages);
2083 zone_page_state(zone,
2084 NR_LRU_BASE + l));
2085 ret += shrink_list(l, nr_to_scan, zone, 2085 ret += shrink_list(l, nr_to_scan, zone,
2086 sc, prio); 2086 sc, prio);
2087 if (ret >= nr_pages) 2087 if (ret >= nr_pages)
@@ -2089,7 +2089,6 @@ static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
2089 } 2089 }
2090 } 2090 }
2091 } 2091 }
2092
2093 return ret; 2092 return ret;
2094} 2093}
2095 2094
@@ -2112,7 +2111,6 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
2112 .may_swap = 0, 2111 .may_swap = 0,
2113 .swap_cluster_max = nr_pages, 2112 .swap_cluster_max = nr_pages,
2114 .may_writepage = 1, 2113 .may_writepage = 1,
2115 .swappiness = vm_swappiness,
2116 .isolate_pages = isolate_pages_global, 2114 .isolate_pages = isolate_pages_global,
2117 }; 2115 };
2118 2116
@@ -2146,10 +2144,8 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
2146 int prio; 2144 int prio;
2147 2145
2148 /* Force reclaiming mapped pages in the passes #3 and #4 */ 2146 /* Force reclaiming mapped pages in the passes #3 and #4 */
2149 if (pass > 2) { 2147 if (pass > 2)
2150 sc.may_swap = 1; 2148 sc.may_swap = 1;
2151 sc.swappiness = 100;
2152 }
2153 2149
2154 for (prio = DEF_PRIORITY; prio >= 0; prio--) { 2150 for (prio = DEF_PRIORITY; prio >= 0; prio--) {
2155 unsigned long nr_to_scan = nr_pages - ret; 2151 unsigned long nr_to_scan = nr_pages - ret;
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 6bb2635b5ded..7bc992976d29 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -3,11 +3,16 @@
3 * 3 *
4 * This is an implementation of the CIPSO 2.2 protocol as specified in 4 * This is an implementation of the CIPSO 2.2 protocol as specified in
5 * draft-ietf-cipso-ipsecurity-01.txt with additional tag types as found in 5 * draft-ietf-cipso-ipsecurity-01.txt with additional tag types as found in
6 * FIPS-188, copies of both documents can be found in the Documentation 6 * FIPS-188. While CIPSO never became a full IETF RFC standard many vendors
7 * directory. While CIPSO never became a full IETF RFC standard many vendors
8 * have chosen to adopt the protocol and over the years it has become a 7 * have chosen to adopt the protocol and over the years it has become a
9 * de-facto standard for labeled networking. 8 * de-facto standard for labeled networking.
10 * 9 *
10 * The CIPSO draft specification can be found in the kernel's Documentation
11 * directory as well as the following URL:
12 * http://netlabel.sourceforge.net/files/draft-ietf-cipso-ipsecurity-01.txt
13 * The FIPS-188 specification can be found at the following URL:
14 * http://www.itl.nist.gov/fipspubs/fip188.htm
15 *
11 * Author: Paul Moore <paul.moore@hp.com> 16 * Author: Paul Moore <paul.moore@hp.com>
12 * 17 *
13 */ 18 */
diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl
index b0246307aac4..12caa822a232 100644
--- a/scripts/bootgraph.pl
+++ b/scripts/bootgraph.pl
@@ -51,7 +51,7 @@ my %pidctr;
51 51
52while (<>) { 52while (<>) {
53 my $line = $_; 53 my $line = $_;
54 if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_]+)\+/) { 54 if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_\.]+)\+/) {
55 my $func = $2; 55 my $func = $2;
56 if ($done == 0) { 56 if ($done == 0) {
57 $start{$func} = $1; 57 $start{$func} = $1;
@@ -87,7 +87,7 @@ while (<>) {
87 $count = $count + 1; 87 $count = $count + 1;
88 } 88 }
89 89
90 if ($line =~ /([0-9\.]+)\] initcall ([a-zA-Z0-9\_]+)\+.*returned/) { 90 if ($line =~ /([0-9\.]+)\] initcall ([a-zA-Z0-9\_\.]+)\+.*returned/) {
91 if ($done == 0) { 91 if ($done == 0) {
92 $end{$2} = $1; 92 $end{$2} = $1;
93 $maxtime = $1; 93 $maxtime = $1;
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 8bb83a100edb..0f11870116dc 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1827,6 +1827,40 @@ sub reset_state {
1827 $state = 0; 1827 $state = 0;
1828} 1828}
1829 1829
1830sub syscall_munge() {
1831 my $void = 0;
1832
1833 $prototype =~ s@[\r\n\t]+@ @gos; # strip newlines/CR's/tabs
1834## if ($prototype =~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) {
1835 if ($prototype =~ m/SYSCALL_DEFINE0/) {
1836 $void = 1;
1837## $prototype = "long sys_$1(void)";
1838 }
1839
1840 $prototype =~ s/SYSCALL_DEFINE.*\(/long sys_/; # fix return type & func name
1841 if ($prototype =~ m/long (sys_.*?),/) {
1842 $prototype =~ s/,/\(/;
1843 } elsif ($void) {
1844 $prototype =~ s/\)/\(void\)/;
1845 }
1846
1847 # now delete all of the odd-number commas in $prototype
1848 # so that arg types & arg names don't have a comma between them
1849 my $count = 0;
1850 my $len = length($prototype);
1851 if ($void) {
1852 $len = 0; # skip the for-loop
1853 }
1854 for (my $ix = 0; $ix < $len; $ix++) {
1855 if (substr($prototype, $ix, 1) eq ',') {
1856 $count++;
1857 if ($count % 2 == 1) {
1858 substr($prototype, $ix, 1) = ' ';
1859 }
1860 }
1861 }
1862}
1863
1830sub process_state3_function($$) { 1864sub process_state3_function($$) {
1831 my $x = shift; 1865 my $x = shift;
1832 my $file = shift; 1866 my $file = shift;
@@ -1839,11 +1873,15 @@ sub process_state3_function($$) {
1839 elsif ($x =~ /([^\{]*)/) { 1873 elsif ($x =~ /([^\{]*)/) {
1840 $prototype .= $1; 1874 $prototype .= $1;
1841 } 1875 }
1876
1842 if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) { 1877 if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) {
1843 $prototype =~ s@/\*.*?\*/@@gos; # strip comments. 1878 $prototype =~ s@/\*.*?\*/@@gos; # strip comments.
1844 $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. 1879 $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
1845 $prototype =~ s@^\s+@@gos; # strip leading spaces 1880 $prototype =~ s@^\s+@@gos; # strip leading spaces
1846 dump_function($prototype,$file); 1881 if ($prototype =~ /SYSCALL_DEFINE/) {
1882 syscall_munge();
1883 }
1884 dump_function($prototype, $file);
1847 reset_state(); 1885 reset_state();
1848 } 1886 }
1849} 1887}
diff --git a/scripts/markup_oops.pl b/scripts/markup_oops.pl
index d40449cafa84..528492bcba5b 100644
--- a/scripts/markup_oops.pl
+++ b/scripts/markup_oops.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl -w 1#!/usr/bin/perl
2 2
3use File::Basename; 3use File::Basename;
4 4
@@ -29,27 +29,151 @@ my $filename = $vmlinux_name;
29my $target = "0"; 29my $target = "0";
30my $function; 30my $function;
31my $module = ""; 31my $module = "";
32my $func_offset; 32my $func_offset = 0;
33my $vmaoffset = 0; 33my $vmaoffset = 0;
34 34
35my %regs;
36
37
38sub parse_x86_regs
39{
40 my ($line) = @_;
41 if ($line =~ /EAX: ([0-9a-f]+) EBX: ([0-9a-f]+) ECX: ([0-9a-f]+) EDX: ([0-9a-f]+)/) {
42 $regs{"%eax"} = $1;
43 $regs{"%ebx"} = $2;
44 $regs{"%ecx"} = $3;
45 $regs{"%edx"} = $4;
46 }
47 if ($line =~ /ESI: ([0-9a-f]+) EDI: ([0-9a-f]+) EBP: ([0-9a-f]+) ESP: ([0-9a-f]+)/) {
48 $regs{"%esi"} = $1;
49 $regs{"%edi"} = $2;
50 $regs{"%esp"} = $4;
51 }
52 if ($line =~ /RAX: ([0-9a-f]+) RBX: ([0-9a-f]+) RCX: ([0-9a-f]+)/) {
53 $regs{"%eax"} = $1;
54 $regs{"%ebx"} = $2;
55 $regs{"%ecx"} = $3;
56 }
57 if ($line =~ /RDX: ([0-9a-f]+) RSI: ([0-9a-f]+) RDI: ([0-9a-f]+)/) {
58 $regs{"%edx"} = $1;
59 $regs{"%esi"} = $2;
60 $regs{"%edi"} = $3;
61 }
62 if ($line =~ /RBP: ([0-9a-f]+) R08: ([0-9a-f]+) R09: ([0-9a-f]+)/) {
63 $regs{"%r08"} = $2;
64 $regs{"%r09"} = $3;
65 }
66 if ($line =~ /R10: ([0-9a-f]+) R11: ([0-9a-f]+) R12: ([0-9a-f]+)/) {
67 $regs{"%r10"} = $1;
68 $regs{"%r11"} = $2;
69 $regs{"%r12"} = $3;
70 }
71 if ($line =~ /R13: ([0-9a-f]+) R14: ([0-9a-f]+) R15: ([0-9a-f]+)/) {
72 $regs{"%r13"} = $1;
73 $regs{"%r14"} = $2;
74 $regs{"%r15"} = $3;
75 }
76}
77
78sub reg_name
79{
80 my ($reg) = @_;
81 $reg =~ s/r(.)x/e\1x/;
82 $reg =~ s/r(.)i/e\1i/;
83 $reg =~ s/r(.)p/e\1p/;
84 return $reg;
85}
86
87sub process_x86_regs
88{
89 my ($line, $cntr) = @_;
90 my $str = "";
91 if (length($line) < 40) {
92 return ""; # not an asm istruction
93 }
94
95 # find the arguments to the instruction
96 if ($line =~ /([0-9a-zA-Z\,\%\(\)\-\+]+)$/) {
97 $lastword = $1;
98 } else {
99 return "";
100 }
101
102 # we need to find the registers that get clobbered,
103 # since their value is no longer relevant for previous
104 # instructions in the stream.
105
106 $clobber = $lastword;
107 # first, remove all memory operands, they're read only
108 $clobber =~ s/\([a-z0-9\%\,]+\)//g;
109 # then, remove everything before the comma, thats the read part
110 $clobber =~ s/.*\,//g;
111
112 # if this is the instruction that faulted, we haven't actually done
113 # the write yet... nothing is clobbered.
114 if ($cntr == 0) {
115 $clobber = "";
116 }
117
118 foreach $reg (keys(%regs)) {
119 my $clobberprime = reg_name($clobber);
120 my $lastwordprime = reg_name($lastword);
121 my $val = $regs{$reg};
122 if ($val =~ /^[0]+$/) {
123 $val = "0";
124 } else {
125 $val =~ s/^0*//;
126 }
127
128 # first check if we're clobbering this register; if we do
129 # we print it with a =>, and then delete its value
130 if ($clobber =~ /$reg/ || $clobberprime =~ /$reg/) {
131 if (length($val) > 0) {
132 $str = $str . " $reg => $val ";
133 }
134 $regs{$reg} = "";
135 $val = "";
136 }
137 # now check if we're reading this register
138 if ($lastword =~ /$reg/ || $lastwordprime =~ /$reg/) {
139 if (length($val) > 0) {
140 $str = $str . " $reg = $val ";
141 }
142 }
143 }
144 return $str;
145}
146
147# parse the oops
35while (<STDIN>) { 148while (<STDIN>) {
36 my $line = $_; 149 my $line = $_;
37 if ($line =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) { 150 if ($line =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) {
38 $target = $1; 151 $target = $1;
39 } 152 }
153 if ($line =~ /RIP: 0010:\[\<([a-z0-9]+)\>\]/) {
154 $target = $1;
155 }
40 if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) { 156 if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
41 $function = $1; 157 $function = $1;
42 $func_offset = $2; 158 $func_offset = $2;
43 } 159 }
160 if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) {
161 $function = $1;
162 $func_offset = $2;
163 }
44 164
45 # check if it's a module 165 # check if it's a module
46 if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) { 166 if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) {
47 $module = $3; 167 $module = $3;
48 } 168 }
169 if ($line =~ /RIP: 0010:\[\<[0-9a-f]+\>\] \[\<[0-9a-f]+\>\] ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) {
170 $module = $3;
171 }
172 parse_x86_regs($line);
49} 173}
50 174
51my $decodestart = hex($target) - hex($func_offset); 175my $decodestart = hex($target) - hex($func_offset);
52my $decodestop = $decodestart + 8192; 176my $decodestop = hex($target) + 8192;
53if ($target eq "0") { 177if ($target eq "0") {
54 print "No oops found!\n"; 178 print "No oops found!\n";
55 print "Usage: \n"; 179 print "Usage: \n";
@@ -84,6 +208,7 @@ my $counter = 0;
84my $state = 0; 208my $state = 0;
85my $center = 0; 209my $center = 0;
86my @lines; 210my @lines;
211my @reglines;
87 212
88sub InRange { 213sub InRange {
89 my ($address, $target) = @_; 214 my ($address, $target) = @_;
@@ -188,16 +313,36 @@ while ($finish < $counter) {
188 313
189my $i; 314my $i;
190 315
191my $fulltext = ""; 316
317# start annotating the registers in the asm.
318# this goes from the oopsing point back, so that the annotator
319# can track (opportunistically) which registers got written and
320# whos value no longer is relevant.
321
322$i = $center;
323while ($i >= $start) {
324 $reglines[$i] = process_x86_regs($lines[$i], $center - $i);
325 $i = $i - 1;
326}
327
192$i = $start; 328$i = $start;
193while ($i < $finish) { 329while ($i < $finish) {
330 my $line;
194 if ($i == $center) { 331 if ($i == $center) {
195 $fulltext = $fulltext . "*$lines[$i] <----- faulting instruction\n"; 332 $line = "*$lines[$i] ";
196 } else { 333 } else {
197 $fulltext = $fulltext . " $lines[$i]\n"; 334 $line = " $lines[$i] ";
335 }
336 print $line;
337 if (defined($reglines[$i]) && length($reglines[$i]) > 0) {
338 my $c = 60 - length($line);
339 while ($c > 0) { print " "; $c = $c - 1; };
340 print "| $reglines[$i]";
198 } 341 }
342 if ($i == $center) {
343 print "<--- faulting instruction";
344 }
345 print "\n";
199 $i = $i +1; 346 $i = $i +1;
200} 347}
201 348
202print $fulltext;
203
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 491b8b1b6abf..4eea60b1693e 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -210,6 +210,7 @@ static void do_usb_table(void *symval, unsigned long size,
210static int do_hid_entry(const char *filename, 210static int do_hid_entry(const char *filename,
211 struct hid_device_id *id, char *alias) 211 struct hid_device_id *id, char *alias)
212{ 212{
213 id->bus = TO_NATIVE(id->bus);
213 id->vendor = TO_NATIVE(id->vendor); 214 id->vendor = TO_NATIVE(id->vendor);
214 id->product = TO_NATIVE(id->product); 215 id->product = TO_NATIVE(id->product);
215 216
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 2500886fb90a..ee448cdc6a2b 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -86,6 +86,14 @@ echo "%endif"
86echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" 86echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
87 87
88echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" 88echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
89
90echo "%ifnarch ppc64"
91echo 'cp vmlinux vmlinux.orig'
92echo 'bzip2 -9 vmlinux'
93echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
94echo 'mv vmlinux.orig vmlinux'
95echo "%endif"
96
89echo "" 97echo ""
90echo "%clean" 98echo "%clean"
91echo '#echo -rf $RPM_BUILD_ROOT' 99echo '#echo -rf $RPM_BUILD_ROOT'
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index f6946cf99ce1..f1c4b35bc324 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -58,14 +58,7 @@ fi
58# Check for svn and a svn repo. 58# Check for svn and a svn repo.
59if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then 59if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
60 rev=`echo $rev | awk '{print $NF}'` 60 rev=`echo $rev | awk '{print $NF}'`
61 changes=`svn status 2>/dev/null | grep '^[AMD]' | wc -l` 61 printf -- '-svn%s' "$rev"
62
63 # Are there uncommitted changes?
64 if [ $changes != 0 ]; then
65 printf -- '-svn%s%s' "$rev" -dirty
66 else
67 printf -- '-svn%s' "$rev"
68 fi
69 62
70 # All done with svn 63 # All done with svn
71 exit 64 exit
diff --git a/scripts/tags.sh b/scripts/tags.sh
index fdbe78bb5e2b..5bd8b1003d44 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -76,7 +76,10 @@ all_sources()
76 76
77all_kconfigs() 77all_kconfigs()
78{ 78{
79 find_sources $ALLSOURCE_ARCHS 'Kconfig*' 79 for arch in $ALLSOURCE_ARCHS; do
80 find_sources $arch 'Kconfig*'
81 done
82 find_other_sources 'Kconfig*'
80} 83}
81 84
82all_defconfigs() 85all_defconfigs()
@@ -99,7 +102,8 @@ exuberant()
99 -I ____cacheline_internodealigned_in_smp \ 102 -I ____cacheline_internodealigned_in_smp \
100 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 103 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
101 --extra=+f --c-kinds=+px \ 104 --extra=+f --c-kinds=+px \
102 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' 105 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \
106 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/'
103 107
104 all_kconfigs | xargs $1 -a \ 108 all_kconfigs | xargs $1 -a \
105 --langdef=kconfig --language-force=kconfig \ 109 --langdef=kconfig --language-force=kconfig \
@@ -117,7 +121,9 @@ exuberant()
117 121
118emacs() 122emacs()
119{ 123{
120 all_sources | xargs $1 -a 124 all_sources | xargs $1 -a \
125 --regex='/^ENTRY(\([^)]*\)).*/\1/' \
126 --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
121 127
122 all_kconfigs | xargs $1 -a \ 128 all_kconfigs | xargs $1 -a \
123 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' 129 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
diff --git a/security/selinux/netlabel.c b/security/selinux/netlabel.c
index f58701a7b728..3f4b26647386 100644
--- a/security/selinux/netlabel.c
+++ b/security/selinux/netlabel.c
@@ -490,8 +490,10 @@ int selinux_netlbl_socket_setsockopt(struct socket *sock,
490 lock_sock(sk); 490 lock_sock(sk);
491 rc = netlbl_sock_getattr(sk, &secattr); 491 rc = netlbl_sock_getattr(sk, &secattr);
492 release_sock(sk); 492 release_sock(sk);
493 if (rc == 0 && secattr.flags != NETLBL_SECATTR_NONE) 493 if (rc == 0)
494 rc = -EACCES; 494 rc = -EACCES;
495 else if (rc == -ENOMSG)
496 rc = 0;
495 netlbl_secattr_destroy(&secattr); 497 netlbl_secattr_destroy(&secattr);
496 } 498 }
497 499
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 89096e811a4b..772901e41ecb 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -90,7 +90,7 @@ static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
90 */ 90 */
91 do { 91 do {
92 v = readl(aaci->base + AACI_SLFR); 92 v = readl(aaci->base + AACI_SLFR);
93 } while ((v & (SLFR_1TXB|SLFR_2TXB)) && timeout--); 93 } while ((v & (SLFR_1TXB|SLFR_2TXB)) && --timeout);
94 94
95 if (!timeout) 95 if (!timeout)
96 dev_err(&aaci->dev->dev, 96 dev_err(&aaci->dev->dev,
@@ -126,7 +126,7 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
126 */ 126 */
127 do { 127 do {
128 v = readl(aaci->base + AACI_SLFR); 128 v = readl(aaci->base + AACI_SLFR);
129 } while ((v & SLFR_1TXB) && timeout--); 129 } while ((v & SLFR_1TXB) && --timeout);
130 130
131 if (!timeout) { 131 if (!timeout) {
132 dev_err(&aaci->dev->dev, "timeout on slot 1 TX busy\n"); 132 dev_err(&aaci->dev->dev, "timeout on slot 1 TX busy\n");
@@ -147,7 +147,7 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
147 do { 147 do {
148 cond_resched(); 148 cond_resched();
149 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV); 149 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV);
150 } while ((v != (SLFR_1RXV|SLFR_2RXV)) && timeout--); 150 } while ((v != (SLFR_1RXV|SLFR_2RXV)) && --timeout);
151 151
152 if (!timeout) { 152 if (!timeout) {
153 dev_err(&aaci->dev->dev, "timeout on RX valid\n"); 153 dev_err(&aaci->dev->dev, "timeout on RX valid\n");
diff --git a/sound/core/jack.c b/sound/core/jack.c
index dd4a12dc09aa..077a85262c1c 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -47,7 +47,7 @@ static int snd_jack_dev_register(struct snd_device *device)
47 int err; 47 int err;
48 48
49 snprintf(jack->name, sizeof(jack->name), "%s %s", 49 snprintf(jack->name, sizeof(jack->name), "%s %s",
50 card->longname, jack->id); 50 card->shortname, jack->id);
51 jack->input_dev->name = jack->name; 51 jack->input_dev->name = jack->name;
52 52
53 /* Default to the sound card device. */ 53 /* Default to the sound card device. */
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index e17836680f49..0a1798eafb0b 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1767,7 +1767,7 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
1767 AFMT_S8 | AFMT_U16_LE | 1767 AFMT_S8 | AFMT_U16_LE |
1768 AFMT_U16_BE | 1768 AFMT_U16_BE |
1769 AFMT_S32_LE | AFMT_S32_BE | 1769 AFMT_S32_LE | AFMT_S32_BE |
1770 AFMT_S24_LE | AFMT_S24_LE | 1770 AFMT_S24_LE | AFMT_S24_BE |
1771 AFMT_S24_PACKED; 1771 AFMT_S24_PACKED;
1772 params = kmalloc(sizeof(*params), GFP_KERNEL); 1772 params = kmalloc(sizeof(*params), GFP_KERNEL);
1773 if (!params) 1773 if (!params)
diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c
index 5b89c0883d60..48b64e6b2670 100644
--- a/sound/drivers/mtpav.c
+++ b/sound/drivers/mtpav.c
@@ -706,7 +706,6 @@ static int __devinit snd_mtpav_probe(struct platform_device *dev)
706 mtp_card->card = card; 706 mtp_card->card = card;
707 mtp_card->irq = -1; 707 mtp_card->irq = -1;
708 mtp_card->share_irq = 0; 708 mtp_card->share_irq = 0;
709 mtp_card->inmidiport = 0xffffffff;
710 mtp_card->inmidistate = 0; 709 mtp_card->inmidistate = 0;
711 mtp_card->outmidihwport = 0xffffffff; 710 mtp_card->outmidihwport = 0xffffffff;
712 init_timer(&mtp_card->timer); 711 init_timer(&mtp_card->timer);
@@ -719,6 +718,8 @@ static int __devinit snd_mtpav_probe(struct platform_device *dev)
719 if (err < 0) 718 if (err < 0)
720 goto __error; 719 goto __error;
721 720
721 mtp_card->inmidiport = mtp_card->num_ports + MTPAV_PIDX_BROADCAST;
722
722 err = snd_mtpav_get_ISA(mtp_card); 723 err = snd_mtpav_get_ISA(mtp_card);
723 if (err < 0) 724 if (err < 0)
724 goto __error; 725 goto __error;
diff --git a/sound/oss/dmasound/dmasound_atari.c b/sound/oss/dmasound/dmasound_atari.c
index 57d9f154c88b..38931f2f6967 100644
--- a/sound/oss/dmasound/dmasound_atari.c
+++ b/sound/oss/dmasound/dmasound_atari.c
@@ -847,23 +847,23 @@ static int __init AtaIrqInit(void)
847 of events. So all we need to keep the music playing is 847 of events. So all we need to keep the music playing is
848 to provide the sound hardware with new data upon 848 to provide the sound hardware with new data upon
849 an interrupt from timer A. */ 849 an interrupt from timer A. */
850 mfp.tim_ct_a = 0; /* ++roman: Stop timer before programming! */ 850 st_mfp.tim_ct_a = 0; /* ++roman: Stop timer before programming! */
851 mfp.tim_dt_a = 1; /* Cause interrupt after first event. */ 851 st_mfp.tim_dt_a = 1; /* Cause interrupt after first event. */
852 mfp.tim_ct_a = 8; /* Turn on event counting. */ 852 st_mfp.tim_ct_a = 8; /* Turn on event counting. */
853 /* Register interrupt handler. */ 853 /* Register interrupt handler. */
854 if (request_irq(IRQ_MFP_TIMA, AtaInterrupt, IRQ_TYPE_SLOW, "DMA sound", 854 if (request_irq(IRQ_MFP_TIMA, AtaInterrupt, IRQ_TYPE_SLOW, "DMA sound",
855 AtaInterrupt)) 855 AtaInterrupt))
856 return 0; 856 return 0;
857 mfp.int_en_a |= 0x20; /* Turn interrupt on. */ 857 st_mfp.int_en_a |= 0x20; /* Turn interrupt on. */
858 mfp.int_mk_a |= 0x20; 858 st_mfp.int_mk_a |= 0x20;
859 return 1; 859 return 1;
860} 860}
861 861
862#ifdef MODULE 862#ifdef MODULE
863static void AtaIrqCleanUp(void) 863static void AtaIrqCleanUp(void)
864{ 864{
865 mfp.tim_ct_a = 0; /* stop timer */ 865 st_mfp.tim_ct_a = 0; /* stop timer */
866 mfp.int_en_a &= ~0x20; /* turn interrupt off */ 866 st_mfp.int_en_a &= ~0x20; /* turn interrupt off */
867 free_irq(IRQ_MFP_TIMA, AtaInterrupt); 867 free_irq(IRQ_MFP_TIMA, AtaInterrupt);
868} 868}
869#endif /* MODULE */ 869#endif /* MODULE */
@@ -1599,7 +1599,7 @@ static int __init dmasound_atari_init(void)
1599 is_falcon = 0; 1599 is_falcon = 0;
1600 } else 1600 } else
1601 return -ENODEV; 1601 return -ENODEV;
1602 if ((mfp.int_en_a & mfp.int_mk_a & 0x20) == 0) 1602 if ((st_mfp.int_en_a & st_mfp.int_mk_a & 0x20) == 0)
1603 return dmasound_init(); 1603 return dmasound_init();
1604 else { 1604 else {
1605 printk("DMA sound driver: Timer A interrupt already in use\n"); 1605 printk("DMA sound driver: Timer A interrupt already in use\n");
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index b7bba7dc7cf1..d03f99298be9 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -487,7 +487,6 @@ int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
487{ 487{
488 struct hda_bus *bus; 488 struct hda_bus *bus;
489 int err; 489 int err;
490 char qname[8];
491 static struct snd_device_ops dev_ops = { 490 static struct snd_device_ops dev_ops = {
492 .dev_register = snd_hda_bus_dev_register, 491 .dev_register = snd_hda_bus_dev_register,
493 .dev_free = snd_hda_bus_dev_free, 492 .dev_free = snd_hda_bus_dev_free,
@@ -517,10 +516,12 @@ int /*__devinit*/ snd_hda_bus_new(struct snd_card *card,
517 mutex_init(&bus->cmd_mutex); 516 mutex_init(&bus->cmd_mutex);
518 INIT_LIST_HEAD(&bus->codec_list); 517 INIT_LIST_HEAD(&bus->codec_list);
519 518
520 snprintf(qname, sizeof(qname), "hda%d", card->number); 519 snprintf(bus->workq_name, sizeof(bus->workq_name),
521 bus->workq = create_workqueue(qname); 520 "hd-audio%d", card->number);
521 bus->workq = create_singlethread_workqueue(bus->workq_name);
522 if (!bus->workq) { 522 if (!bus->workq) {
523 snd_printk(KERN_ERR "cannot create workqueue %s\n", qname); 523 snd_printk(KERN_ERR "cannot create workqueue %s\n",
524 bus->workq_name);
524 kfree(bus); 525 kfree(bus);
525 return -ENOMEM; 526 return -ENOMEM;
526 } 527 }
@@ -3087,6 +3088,16 @@ int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
3087} 3088}
3088EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare); 3089EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare);
3089 3090
3091int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
3092 struct hda_multi_out *mout)
3093{
3094 mutex_lock(&codec->spdif_mutex);
3095 cleanup_dig_out_stream(codec, mout->dig_out_nid);
3096 mutex_unlock(&codec->spdif_mutex);
3097 return 0;
3098}
3099EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_cleanup);
3100
3090/* 3101/*
3091 * release the digital out 3102 * release the digital out
3092 */ 3103 */
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 5810ef588402..09a332ada0c6 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -614,6 +614,7 @@ struct hda_bus {
614 614
615 /* unsolicited event queue */ 615 /* unsolicited event queue */
616 struct hda_bus_unsolicited *unsol; 616 struct hda_bus_unsolicited *unsol;
617 char workq_name[16];
617 struct workqueue_struct *workq; /* common workqueue for codecs */ 618 struct workqueue_struct *workq; /* common workqueue for codecs */
618 619
619 /* assigned PCMs */ 620 /* assigned PCMs */
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index 300ab407cf42..482fb0304ca9 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -175,7 +175,7 @@ static int reconfig_codec(struct hda_codec *codec)
175 err = snd_hda_codec_build_controls(codec); 175 err = snd_hda_codec_build_controls(codec);
176 if (err < 0) 176 if (err < 0)
177 return err; 177 return err;
178 return 0; 178 return snd_card_register(codec->bus->card);
179} 179}
180 180
181/* 181/*
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 11e791b965f6..c8d9178f47e5 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1947,16 +1947,13 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1947 return 0; 1947 return 0;
1948} 1948}
1949 1949
1950static int azx_resume_early(struct pci_dev *pci)
1951{
1952 return pci_restore_state(pci);
1953}
1954
1955static int azx_resume(struct pci_dev *pci) 1950static int azx_resume(struct pci_dev *pci)
1956{ 1951{
1957 struct snd_card *card = pci_get_drvdata(pci); 1952 struct snd_card *card = pci_get_drvdata(pci);
1958 struct azx *chip = card->private_data; 1953 struct azx *chip = card->private_data;
1959 1954
1955 pci_set_power_state(pci, PCI_D0);
1956 pci_restore_state(pci);
1960 if (pci_enable_device(pci) < 0) { 1957 if (pci_enable_device(pci) < 0) {
1961 printk(KERN_ERR "hda-intel: pci_enable_device failed, " 1958 printk(KERN_ERR "hda-intel: pci_enable_device failed, "
1962 "disabling device\n"); 1959 "disabling device\n");
@@ -2468,7 +2465,6 @@ static struct pci_driver driver = {
2468 .remove = __devexit_p(azx_remove), 2465 .remove = __devexit_p(azx_remove),
2469#ifdef CONFIG_PM 2466#ifdef CONFIG_PM
2470 .suspend = azx_suspend, 2467 .suspend = azx_suspend,
2471 .resume_early = azx_resume_early,
2472 .resume = azx_resume, 2468 .resume = azx_resume,
2473#endif 2469#endif
2474}; 2470};
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 1dd8716c387f..44f189cb97ae 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -251,6 +251,8 @@ int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
251 unsigned int stream_tag, 251 unsigned int stream_tag,
252 unsigned int format, 252 unsigned int format,
253 struct snd_pcm_substream *substream); 253 struct snd_pcm_substream *substream);
254int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
255 struct hda_multi_out *mout);
254int snd_hda_multi_out_analog_open(struct hda_codec *codec, 256int snd_hda_multi_out_analog_open(struct hda_codec *codec,
255 struct hda_multi_out *mout, 257 struct hda_multi_out *mout,
256 struct snd_pcm_substream *substream, 258 struct snd_pcm_substream *substream,
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 7ca66d654148..144b85276d5a 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -399,7 +399,8 @@ static void print_conn_list(struct snd_info_buffer *buffer,
399{ 399{
400 int c, curr = -1; 400 int c, curr = -1;
401 401
402 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX) 402 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX &&
403 wid_type != AC_WID_VOL_KNB)
403 curr = snd_hda_codec_read(codec, nid, 0, 404 curr = snd_hda_codec_read(codec, nid, 0,
404 AC_VERB_GET_CONNECT_SEL, 0); 405 AC_VERB_GET_CONNECT_SEL, 0);
405 snd_iprintf(buffer, " Connection: %d\n", conn_len); 406 snd_iprintf(buffer, " Connection: %d\n", conn_len);
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 2e7371ec2e23..e48612323aa0 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -275,6 +275,14 @@ static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
275 format, substream); 275 format, substream);
276} 276}
277 277
278static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
279 struct hda_codec *codec,
280 struct snd_pcm_substream *substream)
281{
282 struct ad198x_spec *spec = codec->spec;
283 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
284}
285
278/* 286/*
279 * Analog capture 287 * Analog capture
280 */ 288 */
@@ -333,7 +341,8 @@ static struct hda_pcm_stream ad198x_pcm_digital_playback = {
333 .ops = { 341 .ops = {
334 .open = ad198x_dig_playback_pcm_open, 342 .open = ad198x_dig_playback_pcm_open,
335 .close = ad198x_dig_playback_pcm_close, 343 .close = ad198x_dig_playback_pcm_close,
336 .prepare = ad198x_dig_playback_pcm_prepare 344 .prepare = ad198x_dig_playback_pcm_prepare,
345 .cleanup = ad198x_dig_playback_pcm_cleanup
337 }, 346 },
338}; 347};
339 348
@@ -1885,8 +1894,8 @@ static hda_nid_t ad1988_capsrc_nids[3] = {
1885#define AD1988_SPDIF_OUT_HDMI 0x0b 1894#define AD1988_SPDIF_OUT_HDMI 0x0b
1886#define AD1988_SPDIF_IN 0x07 1895#define AD1988_SPDIF_IN 0x07
1887 1896
1888static hda_nid_t ad1989b_slave_dig_outs[2] = { 1897static hda_nid_t ad1989b_slave_dig_outs[] = {
1889 AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI 1898 AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI, 0
1890}; 1899};
1891 1900
1892static struct hda_input_mux ad1988_6stack_capture_source = { 1901static struct hda_input_mux ad1988_6stack_capture_source = {
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c
index 3564f4e4b74c..fcc77fec4487 100644
--- a/sound/pci/hda/patch_intelhdmi.c
+++ b/sound/pci/hda/patch_intelhdmi.c
@@ -49,11 +49,6 @@ static struct hda_verb pinout_enable_verb[] = {
49 {} /* terminator */ 49 {} /* terminator */
50}; 50};
51 51
52static struct hda_verb pinout_disable_verb[] = {
53 {PIN_NID, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00},
54 {}
55};
56
57static struct hda_verb unsolicited_response_verb[] = { 52static struct hda_verb unsolicited_response_verb[] = {
58 {PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 53 {PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN |
59 INTEL_HDMI_EVENT_TAG}, 54 INTEL_HDMI_EVENT_TAG},
@@ -248,10 +243,6 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid,
248 243
249static void hdmi_enable_output(struct hda_codec *codec) 244static void hdmi_enable_output(struct hda_codec *codec)
250{ 245{
251 /* Enable Audio InfoFrame Transmission */
252 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
253 snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
254 AC_DIPXMIT_BEST);
255 /* Unmute */ 246 /* Unmute */
256 if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) 247 if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP)
257 snd_hda_codec_write(codec, PIN_NID, 0, 248 snd_hda_codec_write(codec, PIN_NID, 0,
@@ -260,17 +251,24 @@ static void hdmi_enable_output(struct hda_codec *codec)
260 snd_hda_sequence_write(codec, pinout_enable_verb); 251 snd_hda_sequence_write(codec, pinout_enable_verb);
261} 252}
262 253
263static void hdmi_disable_output(struct hda_codec *codec) 254/*
255 * Enable Audio InfoFrame Transmission
256 */
257static void hdmi_start_infoframe_trans(struct hda_codec *codec)
264{ 258{
265 snd_hda_sequence_write(codec, pinout_disable_verb); 259 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
266 if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) 260 snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
267 snd_hda_codec_write(codec, PIN_NID, 0, 261 AC_DIPXMIT_BEST);
268 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); 262}
269 263
270 /* 264/*
271 * FIXME: noises may arise when playing music after reloading the 265 * Disable Audio InfoFrame Transmission
272 * kernel module, until the next X restart or monitor repower. 266 */
273 */ 267static void hdmi_stop_infoframe_trans(struct hda_codec *codec)
268{
269 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
270 snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT,
271 AC_DIPXMIT_DISABLE);
274} 272}
275 273
276static int hdmi_get_channel_count(struct hda_codec *codec) 274static int hdmi_get_channel_count(struct hda_codec *codec)
@@ -368,11 +366,16 @@ static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
368 struct hdmi_audio_infoframe *ai) 366 struct hdmi_audio_infoframe *ai)
369{ 367{
370 u8 *params = (u8 *)ai; 368 u8 *params = (u8 *)ai;
369 u8 sum = 0;
371 int i; 370 int i;
372 371
373 hdmi_debug_dip_size(codec); 372 hdmi_debug_dip_size(codec);
374 hdmi_clear_dip_buffers(codec); /* be paranoid */ 373 hdmi_clear_dip_buffers(codec); /* be paranoid */
375 374
375 for (i = 0; i < sizeof(ai); i++)
376 sum += params[i];
377 ai->checksum = - sum;
378
376 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0); 379 hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0);
377 for (i = 0; i < sizeof(ai); i++) 380 for (i = 0; i < sizeof(ai); i++)
378 hdmi_write_dip_byte(codec, PIN_NID, params[i]); 381 hdmi_write_dip_byte(codec, PIN_NID, params[i]);
@@ -419,14 +422,18 @@ static int hdmi_setup_channel_allocation(struct hda_codec *codec,
419 /* 422 /*
420 * CA defaults to 0 for basic stereo audio 423 * CA defaults to 0 for basic stereo audio
421 */ 424 */
422 if (!eld->eld_ver)
423 return 0;
424 if (!eld->spk_alloc)
425 return 0;
426 if (channels <= 2) 425 if (channels <= 2)
427 return 0; 426 return 0;
428 427
429 /* 428 /*
429 * HDMI sink's ELD info cannot always be retrieved for now, e.g.
430 * in console or for audio devices. Assume the highest speakers
431 * configuration, to _not_ prohibit multi-channel audio playback.
432 */
433 if (!eld->spk_alloc)
434 eld->spk_alloc = 0xffff;
435
436 /*
430 * expand ELD's speaker allocation mask 437 * expand ELD's speaker allocation mask
431 * 438 *
432 * ELD tells the speaker mask in a compact(paired) form, 439 * ELD tells the speaker mask in a compact(paired) form,
@@ -485,6 +492,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
485 hdmi_setup_channel_mapping(codec, &ai); 492 hdmi_setup_channel_mapping(codec, &ai);
486 493
487 hdmi_fill_audio_infoframe(codec, &ai); 494 hdmi_fill_audio_infoframe(codec, &ai);
495 hdmi_start_infoframe_trans(codec);
488} 496}
489 497
490 498
@@ -562,7 +570,7 @@ static int intel_hdmi_playback_pcm_close(struct hda_pcm_stream *hinfo,
562{ 570{
563 struct intel_hdmi_spec *spec = codec->spec; 571 struct intel_hdmi_spec *spec = codec->spec;
564 572
565 hdmi_disable_output(codec); 573 hdmi_stop_infoframe_trans(codec);
566 574
567 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 575 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
568} 576}
@@ -582,8 +590,6 @@ static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
582 590
583 hdmi_setup_audio_infoframe(codec, substream); 591 hdmi_setup_audio_infoframe(codec, substream);
584 592
585 hdmi_enable_output(codec);
586
587 return 0; 593 return 0;
588} 594}
589 595
@@ -628,8 +634,7 @@ static int intel_hdmi_build_controls(struct hda_codec *codec)
628 634
629static int intel_hdmi_init(struct hda_codec *codec) 635static int intel_hdmi_init(struct hda_codec *codec)
630{ 636{
631 /* disable audio output as early as possible */ 637 hdmi_enable_output(codec);
632 hdmi_disable_output(codec);
633 638
634 snd_hda_sequence_write(codec, unsolicited_response_verb); 639 snd_hda_sequence_write(codec, unsolicited_response_verb);
635 640
@@ -679,6 +684,7 @@ static struct hda_codec_preset snd_hda_preset_intelhdmi[] = {
679 { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, 684 { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi },
680 { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, 685 { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi },
681 { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, 686 { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi },
687 { .id = 0x80862804, .name = "G45 DEVIBX", .patch = patch_intel_hdmi },
682 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, 688 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi },
683 {} /* terminator */ 689 {} /* terminator */
684}; 690};
@@ -687,6 +693,7 @@ MODULE_ALIAS("snd-hda-codec-id:808629fb");
687MODULE_ALIAS("snd-hda-codec-id:80862801"); 693MODULE_ALIAS("snd-hda-codec-id:80862801");
688MODULE_ALIAS("snd-hda-codec-id:80862802"); 694MODULE_ALIAS("snd-hda-codec-id:80862802");
689MODULE_ALIAS("snd-hda-codec-id:80862803"); 695MODULE_ALIAS("snd-hda-codec-id:80862803");
696MODULE_ALIAS("snd-hda-codec-id:80862804");
690MODULE_ALIAS("snd-hda-codec-id:10951392"); 697MODULE_ALIAS("snd-hda-codec-id:10951392");
691 698
692MODULE_LICENSE("GPL"); 699MODULE_LICENSE("GPL");
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 7884a4e07061..ed8fcbd60003 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1037,6 +1037,7 @@ do_sku:
1037 case 0x10ec0267: 1037 case 0x10ec0267:
1038 case 0x10ec0268: 1038 case 0x10ec0268:
1039 case 0x10ec0269: 1039 case 0x10ec0269:
1040 case 0x10ec0272:
1040 case 0x10ec0660: 1041 case 0x10ec0660:
1041 case 0x10ec0662: 1042 case 0x10ec0662:
1042 case 0x10ec0663: 1043 case 0x10ec0663:
@@ -1065,6 +1066,7 @@ do_sku:
1065 case 0x10ec0882: 1066 case 0x10ec0882:
1066 case 0x10ec0883: 1067 case 0x10ec0883:
1067 case 0x10ec0885: 1068 case 0x10ec0885:
1069 case 0x10ec0887:
1068 case 0x10ec0889: 1070 case 0x10ec0889:
1069 snd_hda_codec_write(codec, 0x20, 0, 1071 snd_hda_codec_write(codec, 0x20, 0,
1070 AC_VERB_SET_COEF_INDEX, 7); 1072 AC_VERB_SET_COEF_INDEX, 7);
@@ -7012,6 +7014,7 @@ static int patch_alc882(struct hda_codec *codec)
7012 break; 7014 break;
7013 case 0x106b1000: /* iMac 24 */ 7015 case 0x106b1000: /* iMac 24 */
7014 case 0x106b2800: /* AppleTV */ 7016 case 0x106b2800: /* AppleTV */
7017 case 0x106b3e00: /* iMac 24 Aluminium */
7015 board_config = ALC885_IMAC24; 7018 board_config = ALC885_IMAC24;
7016 break; 7019 break;
7017 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ 7020 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
@@ -8475,6 +8478,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8475 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), 8478 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8476 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8479 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8477 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8480 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8481 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
8478 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), 8482 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
8479 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), 8483 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8480 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), 8484 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
@@ -8514,6 +8518,8 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8514 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 8518 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
8515 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 8519 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8516 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 8520 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8521 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8522 ALC883_FUJITSU_PI2515),
8517 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), 8523 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
8518 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530", 8524 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8519 ALC888_FUJITSU_XA3530), 8525 ALC888_FUJITSU_XA3530),
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index b787b3cc096f..8027edf3c8f2 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -1799,11 +1799,13 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2, 1799 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1800 "HP dv5", STAC_HP_M4), 1800 "HP dv5", STAC_HP_M4),
1801 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4, 1801 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1802 "HP dv7", STAC_HP_M4), 1802 "HP dv7", STAC_HP_DV5),
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7, 1803 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7,
1804 "HP dv4", STAC_HP_DV5), 1804 "HP dv4", STAC_HP_DV5),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc, 1805 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
1806 "HP dv7", STAC_HP_M4), 1806 "HP dv7", STAC_HP_M4),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3600,
1808 "HP dv5", STAC_HP_DV5),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603, 1809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
1808 "HP dv5", STAC_HP_DV5), 1810 "HP dv5", STAC_HP_DV5),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, 1811 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
@@ -2440,6 +2442,14 @@ static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2440 stream_tag, format, substream); 2442 stream_tag, format, substream);
2441} 2443}
2442 2444
2445static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2446 struct hda_codec *codec,
2447 struct snd_pcm_substream *substream)
2448{
2449 struct sigmatel_spec *spec = codec->spec;
2450 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2451}
2452
2443 2453
2444/* 2454/*
2445 * Analog capture callbacks 2455 * Analog capture callbacks
@@ -2484,7 +2494,8 @@ static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2484 .ops = { 2494 .ops = {
2485 .open = stac92xx_dig_playback_pcm_open, 2495 .open = stac92xx_dig_playback_pcm_open,
2486 .close = stac92xx_dig_playback_pcm_close, 2496 .close = stac92xx_dig_playback_pcm_close,
2487 .prepare = stac92xx_dig_playback_pcm_prepare 2497 .prepare = stac92xx_dig_playback_pcm_prepare,
2498 .cleanup = stac92xx_dig_playback_pcm_cleanup
2488 }, 2499 },
2489}; 2500};
2490 2501
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 19d3391e229f..e900cdc84849 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -617,7 +617,7 @@ static int snd_intel8x0_ali_codec_semaphore(struct intel8x0 *chip)
617 int time = 100; 617 int time = 100;
618 if (chip->buggy_semaphore) 618 if (chip->buggy_semaphore)
619 return 0; /* just ignore ... */ 619 return 0; /* just ignore ... */
620 while (time-- && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY)) 620 while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY))
621 udelay(1); 621 udelay(1);
622 if (! time && ! chip->in_ac97_init) 622 if (! time && ! chip->in_ac97_init)
623 snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n"); 623 snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n");
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 18c7c91786bc..6c870c12a177 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -26,7 +26,7 @@
26 * SPI 0 -> 1st PCM1796 (front) 26 * SPI 0 -> 1st PCM1796 (front)
27 * SPI 1 -> 2nd PCM1796 (surround) 27 * SPI 1 -> 2nd PCM1796 (surround)
28 * SPI 2 -> 3rd PCM1796 (center/LFE) 28 * SPI 2 -> 3rd PCM1796 (center/LFE)
29 * SPI 4 -> 4th PCM1796 (back) and EEPROM self-destruct (do not use!) 29 * SPI 4 -> 4th PCM1796 (back)
30 * 30 *
31 * GPIO 2 -> M0 of CS5381 31 * GPIO 2 -> M0 of CS5381
32 * GPIO 3 -> M1 of CS5381 32 * GPIO 3 -> M1 of CS5381
@@ -207,12 +207,6 @@ static void xonar_gpio_changed(struct oxygen *chip);
207static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec, 207static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec,
208 u8 reg, u8 value) 208 u8 reg, u8 value)
209{ 209{
210 /*
211 * We don't want to do writes on SPI 4 because the EEPROM, which shares
212 * the same pin, might get confused and broken. We'd better take care
213 * that the driver works with the default register values ...
214 */
215#if 0
216 /* maps ALSA channel pair number to SPI output */ 210 /* maps ALSA channel pair number to SPI output */
217 static const u8 codec_map[4] = { 211 static const u8 codec_map[4] = {
218 0, 1, 2, 4 212 0, 1, 2, 4
@@ -223,7 +217,6 @@ static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec,
223 (codec_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | 217 (codec_map[codec] << OXYGEN_SPI_CODEC_SHIFT) |
224 OXYGEN_SPI_CEN_LATCH_CLOCK_HI, 218 OXYGEN_SPI_CEN_LATCH_CLOCK_HI,
225 (reg << 8) | value); 219 (reg << 8) | value);
226#endif
227} 220}
228 221
229static inline void pcm1796_write_i2c(struct oxygen *chip, unsigned int codec, 222static inline void pcm1796_write_i2c(struct oxygen *chip, unsigned int codec,
@@ -757,9 +750,6 @@ static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -12700, 100, 0);
757 750
758static int xonar_d2_control_filter(struct snd_kcontrol_new *template) 751static int xonar_d2_control_filter(struct snd_kcontrol_new *template)
759{ 752{
760 if (!strncmp(template->name, "Master Playback ", 16))
761 /* disable volume/mute because they would require SPI writes */
762 return 1;
763 if (!strncmp(template->name, "CD Capture ", 11)) 753 if (!strncmp(template->name, "CD Capture ", 11))
764 /* CD in is actually connected to the video in pin */ 754 /* CD in is actually connected to the video in pin */
765 template->private_value ^= AC97_CD ^ AC97_VIDEO; 755 template->private_value ^= AC97_CD ^ AC97_VIDEO;
@@ -850,8 +840,9 @@ static const struct oxygen_model model_xonar_d2 = {
850 .dac_volume_min = 0x0f, 840 .dac_volume_min = 0x0f,
851 .dac_volume_max = 0xff, 841 .dac_volume_max = 0xff,
852 .misc_flags = OXYGEN_MISC_MIDI, 842 .misc_flags = OXYGEN_MISC_MIDI,
853 .function_flags = OXYGEN_FUNCTION_SPI, 843 .function_flags = OXYGEN_FUNCTION_SPI |
854 .dac_i2s_format = OXYGEN_I2S_FORMAT_I2S, 844 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
845 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
855 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 846 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
856}; 847};
857 848
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index c5d67900d666..ff0054b76502 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -10,7 +10,7 @@
10 * Based on at91-ssc.c by 10 * Based on at91-ssc.c by
11 * Frank Mandarino <fmandarino@endrelia.com> 11 * Frank Mandarino <fmandarino@endrelia.com>
12 * Based on pxa2xx Platform drivers by 12 * Based on pxa2xx Platform drivers by
13 * Liam Girdwood <liam.girdwood@wolfsonmicro.com> 13 * Liam Girdwood <lrg@slimlogic.co.uk>
14 * 14 *
15 * This program is free software; you can redistribute it and/or modify 15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by 16 * it under the terms of the GNU General Public License as published by
diff --git a/sound/soc/atmel/atmel_ssc_dai.h b/sound/soc/atmel/atmel_ssc_dai.h
index a828746e8a2f..391135f9c6c1 100644
--- a/sound/soc/atmel/atmel_ssc_dai.h
+++ b/sound/soc/atmel/atmel_ssc_dai.h
@@ -10,7 +10,7 @@
10 * Based on at91-ssc.c by 10 * Based on at91-ssc.c by
11 * Frank Mandarino <fmandarino@endrelia.com> 11 * Frank Mandarino <fmandarino@endrelia.com>
12 * Based on pxa2xx Platform drivers by 12 * Based on pxa2xx Platform drivers by
13 * Liam Girdwood <liam.girdwood@wolfsonmicro.com> 13 * Liam Girdwood <lrg@slimlogic.co.uk>
14 * 14 *
15 * This program is free software; you can redistribute it and/or modify 15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by 16 * it under the terms of the GNU General Public License as published by
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index b47a749c5ea2..aea0cb72d80a 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -165,10 +165,13 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,
165 struct snd_ctl_elem_value *ucontrol) 165 struct snd_ctl_elem_value *ucontrol)
166{ 166{
167 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); 167 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
168 int reg = kcontrol->private_value & 0xff; 168 struct soc_mixer_control *mc =
169 int shift = (kcontrol->private_value >> 8) & 0x0f; 169 (struct soc_mixer_control *)kcontrol->private_value;
170 int mask = (kcontrol->private_value >> 16) & 0xff; 170 unsigned int reg = mc->reg;
171 int invert = (kcontrol->private_value >> 24) & 0x01; 171 unsigned int shift = mc->shift;
172 int max = mc->max;
173 unsigned int mask = (1 << fls(max)) - 1;
174 unsigned int invert = mc->invert;
172 unsigned short val, val_mask; 175 unsigned short val, val_mask;
173 int ret; 176 int ret;
174 struct snd_soc_dapm_path *path; 177 struct snd_soc_dapm_path *path;
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index e3989d406f54..35d99750c383 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. 4 * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
5 * 5 *
6 * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com> 6 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index 5b5afc144478..a5731faa150c 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -2,8 +2,7 @@
2 * wm8990.c -- WM8990 ALSA Soc Audio driver 2 * wm8990.c -- WM8990 ALSA Soc Audio driver
3 * 3 *
4 * Copyright 2008 Wolfson Microelectronics PLC. 4 * Copyright 2008 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood 5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
6 * lg@opensource.wolfsonmicro.com or linux@wolfsonmicro.com
7 * 6 *
8 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
@@ -177,7 +176,9 @@ static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
177 struct snd_ctl_elem_value *ucontrol) 176 struct snd_ctl_elem_value *ucontrol)
178{ 177{
179 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 178 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
180 int reg = kcontrol->private_value & 0xff; 179 struct soc_mixer_control *mc =
180 (struct soc_mixer_control *)kcontrol->private_value;
181 int reg = mc->reg;
181 int ret; 182 int ret;
182 u16 val; 183 u16 val;
183 184
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index b0362dfd5b71..dd3bb2933762 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -175,9 +175,10 @@ static int omap_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
175{ 175{
176 struct snd_pcm_runtime *runtime = substream->runtime; 176 struct snd_pcm_runtime *runtime = substream->runtime;
177 struct omap_runtime_data *prtd = runtime->private_data; 177 struct omap_runtime_data *prtd = runtime->private_data;
178 unsigned long flags;
178 int ret = 0; 179 int ret = 0;
179 180
180 spin_lock_irq(&prtd->lock); 181 spin_lock_irqsave(&prtd->lock, flags);
181 switch (cmd) { 182 switch (cmd) {
182 case SNDRV_PCM_TRIGGER_START: 183 case SNDRV_PCM_TRIGGER_START:
183 case SNDRV_PCM_TRIGGER_RESUME: 184 case SNDRV_PCM_TRIGGER_RESUME:
@@ -195,7 +196,7 @@ static int omap_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
195 default: 196 default:
196 ret = -EINVAL; 197 ret = -EINVAL;
197 } 198 }
198 spin_unlock_irq(&prtd->lock); 199 spin_unlock_irqrestore(&prtd->lock, flags);
199 200
200 return ret; 201 return ret;
201} 202}
diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c
index ad97836818b1..e226fa75669c 100644
--- a/sound/soc/omap/sdp3430.c
+++ b/sound/soc/omap/sdp3430.c
@@ -91,7 +91,7 @@ static struct snd_soc_dai_link sdp3430_dai = {
91}; 91};
92 92
93/* Audio machine driver */ 93/* Audio machine driver */
94static struct snd_soc_machine snd_soc_machine_sdp3430 = { 94static struct snd_soc_card snd_soc_sdp3430 = {
95 .name = "SDP3430", 95 .name = "SDP3430",
96 .platform = &omap_soc_platform, 96 .platform = &omap_soc_platform,
97 .dai_link = &sdp3430_dai, 97 .dai_link = &sdp3430_dai,
@@ -100,7 +100,7 @@ static struct snd_soc_machine snd_soc_machine_sdp3430 = {
100 100
101/* Audio subsystem */ 101/* Audio subsystem */
102static struct snd_soc_device sdp3430_snd_devdata = { 102static struct snd_soc_device sdp3430_snd_devdata = {
103 .machine = &snd_soc_machine_sdp3430, 103 .card = &snd_soc_sdp3430,
104 .codec_dev = &soc_codec_dev_twl4030, 104 .codec_dev = &soc_codec_dev_twl4030,
105}; 105};
106 106
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 55fdb4abb179..ec3f8bb4b51d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1385,7 +1385,10 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
1385 1385
1386 mutex_lock(&codec->mutex); 1386 mutex_lock(&codec->mutex);
1387#ifdef CONFIG_SND_SOC_AC97_BUS 1387#ifdef CONFIG_SND_SOC_AC97_BUS
1388 if (ac97) { 1388 /* Only instantiate AC97 if not already done by the adaptor
1389 * for the generic AC97 subsystem.
1390 */
1391 if (ac97 && strcmp(codec->name, "AC97") != 0) {
1389 ret = soc_ac97_dev_register(codec); 1392 ret = soc_ac97_dev_register(codec);
1390 if (ret < 0) { 1393 if (ret < 0) {
1391 printk(KERN_ERR "asoc: AC97 device register failed\n"); 1394 printk(KERN_ERR "asoc: AC97 device register failed\n");
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index c709b9563226..19e37451c216 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2524,7 +2524,6 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
2524 * build the rate table and bitmap flags 2524 * build the rate table and bitmap flags
2525 */ 2525 */
2526 int r, idx; 2526 int r, idx;
2527 unsigned int nonzero_rates = 0;
2528 2527
2529 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); 2528 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
2530 if (fp->rate_table == NULL) { 2529 if (fp->rate_table == NULL) {
@@ -2532,24 +2531,27 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
2532 return -1; 2531 return -1;
2533 } 2532 }
2534 2533
2535 fp->nr_rates = nr_rates; 2534 fp->nr_rates = 0;
2536 fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); 2535 fp->rate_min = fp->rate_max = 0;
2537 for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { 2536 for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) {
2538 unsigned int rate = combine_triple(&fmt[idx]); 2537 unsigned int rate = combine_triple(&fmt[idx]);
2538 if (!rate)
2539 continue;
2539 /* C-Media CM6501 mislabels its 96 kHz altsetting */ 2540 /* C-Media CM6501 mislabels its 96 kHz altsetting */
2540 if (rate == 48000 && nr_rates == 1 && 2541 if (rate == 48000 && nr_rates == 1 &&
2541 chip->usb_id == USB_ID(0x0d8c, 0x0201) && 2542 (chip->usb_id == USB_ID(0x0d8c, 0x0201) ||
2543 chip->usb_id == USB_ID(0x0d8c, 0x0102)) &&
2542 fp->altsetting == 5 && fp->maxpacksize == 392) 2544 fp->altsetting == 5 && fp->maxpacksize == 392)
2543 rate = 96000; 2545 rate = 96000;
2544 fp->rate_table[r] = rate; 2546 fp->rate_table[fp->nr_rates] = rate;
2545 nonzero_rates |= rate; 2547 if (!fp->rate_min || rate < fp->rate_min)
2546 if (rate < fp->rate_min)
2547 fp->rate_min = rate; 2548 fp->rate_min = rate;
2548 else if (rate > fp->rate_max) 2549 if (!fp->rate_max || rate > fp->rate_max)
2549 fp->rate_max = rate; 2550 fp->rate_max = rate;
2550 fp->rates |= snd_pcm_rate_to_rate_bit(rate); 2551 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
2552 fp->nr_rates++;
2551 } 2553 }
2552 if (!nonzero_rates) { 2554 if (!fp->nr_rates) {
2553 hwc_debug("All rates were zero. Skipping format!\n"); 2555 hwc_debug("All rates were zero. Skipping format!\n");
2554 return -1; 2556 return -1;
2555 } 2557 }
@@ -2966,6 +2968,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
2966 return -EINVAL; 2968 return -EINVAL;
2967 } 2969 }
2968 alts = &iface->altsetting[fp->altset_idx]; 2970 alts = &iface->altsetting[fp->altset_idx];
2971 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2969 usb_set_interface(chip->dev, fp->iface, 0); 2972 usb_set_interface(chip->dev, fp->iface, 0);
2970 init_usb_pitch(chip->dev, fp->iface, alts, fp); 2973 init_usb_pitch(chip->dev, fp->iface, alts, fp);
2971 init_usb_sample_rate(chip->dev, fp->iface, alts, fp, fp->rate_max); 2974 init_usb_sample_rate(chip->dev, fp->iface, alts, fp, fp->rate_max);
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 320641ab5be7..26bad373fe65 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -1625,6 +1625,7 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi,
1625 } 1625 }
1626 1626
1627 ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 1627 ep_info.out_ep = get_endpoint(hostif, 2)->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
1628 ep_info.out_interval = 0;
1628 ep_info.out_cables = endpoint->out_cables & 0x5555; 1629 ep_info.out_cables = endpoint->out_cables & 0x5555;
1629 err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]); 1630 err = snd_usbmidi_out_endpoint_create(umidi, &ep_info, &umidi->endpoints[0]);
1630 if (err < 0) 1631 if (err < 0)
diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
index e9693a29d00e..4c4037503600 100644
--- a/virt/kvm/iommu.c
+++ b/virt/kvm/iommu.c
@@ -73,14 +73,13 @@ static int kvm_iommu_map_memslots(struct kvm *kvm)
73{ 73{
74 int i, r = 0; 74 int i, r = 0;
75 75
76 down_read(&kvm->slots_lock);
77 for (i = 0; i < kvm->nmemslots; i++) { 76 for (i = 0; i < kvm->nmemslots; i++) {
78 r = kvm_iommu_map_pages(kvm, kvm->memslots[i].base_gfn, 77 r = kvm_iommu_map_pages(kvm, kvm->memslots[i].base_gfn,
79 kvm->memslots[i].npages); 78 kvm->memslots[i].npages);
80 if (r) 79 if (r)
81 break; 80 break;
82 } 81 }
83 up_read(&kvm->slots_lock); 82
84 return r; 83 return r;
85} 84}
86 85
@@ -190,12 +189,11 @@ static void kvm_iommu_put_pages(struct kvm *kvm,
190static int kvm_iommu_unmap_memslots(struct kvm *kvm) 189static int kvm_iommu_unmap_memslots(struct kvm *kvm)
191{ 190{
192 int i; 191 int i;
193 down_read(&kvm->slots_lock); 192
194 for (i = 0; i < kvm->nmemslots; i++) { 193 for (i = 0; i < kvm->nmemslots; i++) {
195 kvm_iommu_put_pages(kvm, kvm->memslots[i].base_gfn, 194 kvm_iommu_put_pages(kvm, kvm->memslots[i].base_gfn,
196 kvm->memslots[i].npages); 195 kvm->memslots[i].npages);
197 } 196 }
198 up_read(&kvm->slots_lock);
199 197
200 return 0; 198 return 0;
201} 199}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 3a5a08298aab..29a667ce35b0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -173,7 +173,6 @@ static void kvm_assigned_dev_interrupt_work_handler(struct work_struct *work)
173 assigned_dev->host_irq_disabled = false; 173 assigned_dev->host_irq_disabled = false;
174 } 174 }
175 mutex_unlock(&assigned_dev->kvm->lock); 175 mutex_unlock(&assigned_dev->kvm->lock);
176 kvm_put_kvm(assigned_dev->kvm);
177} 176}
178 177
179static irqreturn_t kvm_assigned_dev_intr(int irq, void *dev_id) 178static irqreturn_t kvm_assigned_dev_intr(int irq, void *dev_id)
@@ -181,8 +180,6 @@ static irqreturn_t kvm_assigned_dev_intr(int irq, void *dev_id)
181 struct kvm_assigned_dev_kernel *assigned_dev = 180 struct kvm_assigned_dev_kernel *assigned_dev =
182 (struct kvm_assigned_dev_kernel *) dev_id; 181 (struct kvm_assigned_dev_kernel *) dev_id;
183 182
184 kvm_get_kvm(assigned_dev->kvm);
185
186 schedule_work(&assigned_dev->interrupt_work); 183 schedule_work(&assigned_dev->interrupt_work);
187 184
188 disable_irq_nosync(irq); 185 disable_irq_nosync(irq);
@@ -213,6 +210,7 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
213 } 210 }
214} 211}
215 212
213/* The function implicit hold kvm->lock mutex due to cancel_work_sync() */
216static void kvm_free_assigned_irq(struct kvm *kvm, 214static void kvm_free_assigned_irq(struct kvm *kvm,
217 struct kvm_assigned_dev_kernel *assigned_dev) 215 struct kvm_assigned_dev_kernel *assigned_dev)
218{ 216{
@@ -228,11 +226,24 @@ static void kvm_free_assigned_irq(struct kvm *kvm,
228 if (!assigned_dev->irq_requested_type) 226 if (!assigned_dev->irq_requested_type)
229 return; 227 return;
230 228
231 if (cancel_work_sync(&assigned_dev->interrupt_work)) 229 /*
232 /* We had pending work. That means we will have to take 230 * In kvm_free_device_irq, cancel_work_sync return true if:
233 * care of kvm_put_kvm. 231 * 1. work is scheduled, and then cancelled.
234 */ 232 * 2. work callback is executed.
235 kvm_put_kvm(kvm); 233 *
234 * The first one ensured that the irq is disabled and no more events
235 * would happen. But for the second one, the irq may be enabled (e.g.
236 * for MSI). So we disable irq here to prevent further events.
237 *
238 * Notice this maybe result in nested disable if the interrupt type is
239 * INTx, but it's OK for we are going to free it.
240 *
241 * If this function is a part of VM destroy, please ensure that till
242 * now, the kvm state is still legal for probably we also have to wait
243 * interrupt_work done.
244 */
245 disable_irq_nosync(assigned_dev->host_irq);
246 cancel_work_sync(&assigned_dev->interrupt_work);
236 247
237 free_irq(assigned_dev->host_irq, (void *)assigned_dev); 248 free_irq(assigned_dev->host_irq, (void *)assigned_dev);
238 249
@@ -285,8 +296,8 @@ static int assigned_device_update_intx(struct kvm *kvm,
285 296
286 if (irqchip_in_kernel(kvm)) { 297 if (irqchip_in_kernel(kvm)) {
287 if (!msi2intx && 298 if (!msi2intx &&
288 adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI) { 299 (adev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)) {
289 free_irq(adev->host_irq, (void *)kvm); 300 free_irq(adev->host_irq, (void *)adev);
290 pci_disable_msi(adev->dev); 301 pci_disable_msi(adev->dev);
291 } 302 }
292 303
@@ -455,6 +466,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
455 struct kvm_assigned_dev_kernel *match; 466 struct kvm_assigned_dev_kernel *match;
456 struct pci_dev *dev; 467 struct pci_dev *dev;
457 468
469 down_read(&kvm->slots_lock);
458 mutex_lock(&kvm->lock); 470 mutex_lock(&kvm->lock);
459 471
460 match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head, 472 match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head,
@@ -516,6 +528,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
516 528
517out: 529out:
518 mutex_unlock(&kvm->lock); 530 mutex_unlock(&kvm->lock);
531 up_read(&kvm->slots_lock);
519 return r; 532 return r;
520out_list_del: 533out_list_del:
521 list_del(&match->list); 534 list_del(&match->list);
@@ -527,6 +540,7 @@ out_put:
527out_free: 540out_free:
528 kfree(match); 541 kfree(match);
529 mutex_unlock(&kvm->lock); 542 mutex_unlock(&kvm->lock);
543 up_read(&kvm->slots_lock);
530 return r; 544 return r;
531} 545}
532#endif 546#endif
@@ -789,11 +803,19 @@ static int kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn,
789 return young; 803 return young;
790} 804}
791 805
806static void kvm_mmu_notifier_release(struct mmu_notifier *mn,
807 struct mm_struct *mm)
808{
809 struct kvm *kvm = mmu_notifier_to_kvm(mn);
810 kvm_arch_flush_shadow(kvm);
811}
812
792static const struct mmu_notifier_ops kvm_mmu_notifier_ops = { 813static const struct mmu_notifier_ops kvm_mmu_notifier_ops = {
793 .invalidate_page = kvm_mmu_notifier_invalidate_page, 814 .invalidate_page = kvm_mmu_notifier_invalidate_page,
794 .invalidate_range_start = kvm_mmu_notifier_invalidate_range_start, 815 .invalidate_range_start = kvm_mmu_notifier_invalidate_range_start,
795 .invalidate_range_end = kvm_mmu_notifier_invalidate_range_end, 816 .invalidate_range_end = kvm_mmu_notifier_invalidate_range_end,
796 .clear_flush_young = kvm_mmu_notifier_clear_flush_young, 817 .clear_flush_young = kvm_mmu_notifier_clear_flush_young,
818 .release = kvm_mmu_notifier_release,
797}; 819};
798#endif /* CONFIG_MMU_NOTIFIER && KVM_ARCH_WANT_MMU_NOTIFIER */ 820#endif /* CONFIG_MMU_NOTIFIER && KVM_ARCH_WANT_MMU_NOTIFIER */
799 821
@@ -883,6 +905,7 @@ static void kvm_destroy_vm(struct kvm *kvm)
883{ 905{
884 struct mm_struct *mm = kvm->mm; 906 struct mm_struct *mm = kvm->mm;
885 907
908 kvm_arch_sync_events(kvm);
886 spin_lock(&kvm_lock); 909 spin_lock(&kvm_lock);
887 list_del(&kvm->vm_list); 910 list_del(&kvm->vm_list);
888 spin_unlock(&kvm_lock); 911 spin_unlock(&kvm_lock);